Given the following C code and unoptimized assembly code, your task is to generate highly optimized x86-64 assembly code.
C Code:

```c
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

typedef long long ll;
typedef struct {
    ll a, b;
} BUG;

BUG foo[300000];
int n;

int seg[1 << 19][2];
int seg_size;

ll _max(ll a, ll b)
{
    return (a > b ? a : b);
}

void init(int n)
{
    seg_size = 1;
    
    while (n > seg_size){
        seg_size *= 2;
    }
    memset(seg, -1, sizeof(seg));
}

void update(int k, int x)
{
    k += seg_size;
    
    seg[k][0] = x;
    seg[k][1] = k - seg_size;
    
    while (k != 0){
        k = (k - 1) / 2;
        if (seg[k * 2 + 1][0] > seg[k * 2 + 2][0]){
            seg[k][0] = seg[k * 2 + 1][0];
            seg[k][1] = seg[k * 2 + 1][1];
        }
        else {
            seg[k][0] = seg[k * 2 + 2][0];
            seg[k][1] = seg[k * 2 + 2][1];
        }
    }
}

int comp(const void *a, const void *b)
{
    BUG x, y;
    x = *(BUG *)a;
    y = *(BUG *)b;
    
    if (x.b != y.b){
        return (y.b - x.b);
    }
    else {
        return (x.a - y.a);
    }
}

int canPut(int piv)
{
    int i;
    ll lim;
    
    init(piv);
    
    lim = 0;
    for (i = 0; i < piv - 1; i++){
        lim += foo[i].a;
        update(i, foo[i].a);
    }
    
    while (i < n){
        if (i == piv - 1){
            lim += foo[i].a;
            update(i, foo[i].a);
        }
        else {
            lim -= seg[0][0];
            lim += foo[i].a;
            update(seg[0][1], foo[i].a);
        }
        
        if (lim <= foo[i].b * piv){
            return (1);
        }
        i++;
    }
    
    return (0);
}

int main(void)
{
    int i;
    int left, right, center;
    
    scanf("%d", &n);
    
    for (i = 0; i < n; i++){
        scanf("%lld %lld", &foo[i].a, &foo[i].b);
    }
    
    left = 0;
    right = n;
    
    qsort(foo, n, sizeof(BUG), comp);
    
    while (left != right){
        center = (left + right + 1) / 2;
        
        if (canPut(center)){
            left = center;
        }
        else {
            right = center - 1;
        }
    }
    
    printf("%d\n", left);
    
    return (0);
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	foo
	.bss
	.align 32
	.type	foo, @object
	.size	foo, 4800000
foo:
	.zero	4800000
	.globl	n
	.align 4
	.type	n, @object
	.size	n, 4
n:
	.zero	4
	.globl	seg
	.align 32
	.type	seg, @object
	.size	seg, 4194304
seg:
	.zero	4194304
	.globl	seg_size
	.align 4
	.type	seg_size, @object
	.size	seg_size, 4
seg_size:
	.zero	4
	.text
	.globl	_max
	.type	_max, @function
_max:
.LFB6:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movq	%rdi, -8(%rbp)
	movq	%rsi, -16(%rbp)
	movq	-16(%rbp), %rdx
	movq	-8(%rbp), %rax
	cmpq	%rax, %rdx
	cmovge	%rdx, %rax
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.size	_max, .-_max
	.globl	init
	.type	init, @function
init:
.LFB7:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$16, %rsp
	movl	%edi, -4(%rbp)
	movl	$1, seg_size(%rip)
	jmp	.L4
.L5:
	movl	seg_size(%rip), %eax
	addl	%eax, %eax
	movl	%eax, seg_size(%rip)
.L4:
	movl	seg_size(%rip), %eax
	cmpl	%eax, -4(%rbp)
	jg	.L5
	movl	$4194304, %edx
	movl	$-1, %esi
	leaq	seg(%rip), %rax
	movq	%rax, %rdi
	call	memset@PLT
	nop
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE7:
	.size	init, .-init
	.globl	update
	.type	update, @function
update:
.LFB8:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movl	%edi, -4(%rbp)
	movl	%esi, -8(%rbp)
	movl	seg_size(%rip), %eax
	addl	%eax, -4(%rbp)
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rcx
	leaq	seg(%rip), %rdx
	movl	-8(%rbp), %eax
	movl	%eax, (%rcx,%rdx)
	movl	seg_size(%rip), %edx
	movl	-4(%rbp), %eax
	subl	%edx, %eax
	movl	%eax, %ecx
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	4+seg(%rip), %rax
	movl	%ecx, (%rdx,%rax)
	jmp	.L7
.L9:
	movl	-4(%rbp), %eax
	subl	$1, %eax
	movl	%eax, %edx
	shrl	$31, %edx
	addl	%edx, %eax
	sarl	%eax
	movl	%eax, -4(%rbp)
	movl	-4(%rbp), %eax
	addl	%eax, %eax
	addl	$1, %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	seg(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	-4(%rbp), %eax
	addl	$1, %eax
	addl	%eax, %eax
	cltq
	leaq	0(,%rax,8), %rcx
	leaq	seg(%rip), %rax
	movl	(%rcx,%rax), %eax
	cmpl	%eax, %edx
	jle	.L8
	movl	-4(%rbp), %eax
	addl	%eax, %eax
	addl	$1, %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	seg(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	-4(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,8), %rcx
	leaq	seg(%rip), %rdx
	movl	%eax, (%rcx,%rdx)
	movl	-4(%rbp), %eax
	addl	%eax, %eax
	addl	$1, %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	4+seg(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	-4(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,8), %rcx
	leaq	4+seg(%rip), %rdx
	movl	%eax, (%rcx,%rdx)
	jmp	.L7
.L8:
	movl	-4(%rbp), %eax
	addl	$1, %eax
	addl	%eax, %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	seg(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	-4(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,8), %rcx
	leaq	seg(%rip), %rdx
	movl	%eax, (%rcx,%rdx)
	movl	-4(%rbp), %eax
	addl	$1, %eax
	addl	%eax, %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	4+seg(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	-4(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,8), %rcx
	leaq	4+seg(%rip), %rdx
	movl	%eax, (%rcx,%rdx)
.L7:
	cmpl	$0, -4(%rbp)
	jne	.L9
	nop
	nop
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE8:
	.size	update, .-update
	.globl	comp
	.type	comp, @function
comp:
.LFB9:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movq	%rdi, -40(%rbp)
	movq	%rsi, -48(%rbp)
	movq	-40(%rbp), %rax
	movq	8(%rax), %rdx
	movq	(%rax), %rax
	movq	%rax, -32(%rbp)
	movq	%rdx, -24(%rbp)
	movq	-48(%rbp), %rax
	movq	8(%rax), %rdx
	movq	(%rax), %rax
	movq	%rax, -16(%rbp)
	movq	%rdx, -8(%rbp)
	movq	-24(%rbp), %rdx
	movq	-8(%rbp), %rax
	cmpq	%rax, %rdx
	je	.L11
	movq	-8(%rbp), %rax
	movl	%eax, %edx
	movq	-24(%rbp), %rax
	movl	%eax, %ecx
	movl	%edx, %eax
	subl	%ecx, %eax
	jmp	.L13
.L11:
	movq	-32(%rbp), %rax
	movl	%eax, %edx
	movq	-16(%rbp), %rax
	movl	%eax, %ecx
	movl	%edx, %eax
	subl	%ecx, %eax
.L13:
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE9:
	.size	comp, .-comp
	.globl	canPut
	.type	canPut, @function
canPut:
.LFB10:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$32, %rsp
	movl	%edi, -20(%rbp)
	movl	-20(%rbp), %eax
	movl	%eax, %edi
	call	init
	movq	$0, -8(%rbp)
	movl	$0, -12(%rbp)
	jmp	.L15
.L16:
	movl	-12(%rbp), %eax
	cltq
	salq	$4, %rax
	movq	%rax, %rdx
	leaq	foo(%rip), %rax
	movq	(%rdx,%rax), %rax
	addq	%rax, -8(%rbp)
	movl	-12(%rbp), %eax
	cltq
	salq	$4, %rax
	movq	%rax, %rdx
	leaq	foo(%rip), %rax
	movq	(%rdx,%rax), %rax
	movl	%eax, %edx
	movl	-12(%rbp), %eax
	movl	%edx, %esi
	movl	%eax, %edi
	call	update
	addl	$1, -12(%rbp)
.L15:
	movl	-20(%rbp), %eax
	subl	$1, %eax
	cmpl	%eax, -12(%rbp)
	jl	.L16
	jmp	.L17
.L22:
	movl	-20(%rbp), %eax
	subl	$1, %eax
	cmpl	%eax, -12(%rbp)
	jne	.L18
	movl	-12(%rbp), %eax
	cltq
	salq	$4, %rax
	movq	%rax, %rdx
	leaq	foo(%rip), %rax
	movq	(%rdx,%rax), %rax
	addq	%rax, -8(%rbp)
	movl	-12(%rbp), %eax
	cltq
	salq	$4, %rax
	movq	%rax, %rdx
	leaq	foo(%rip), %rax
	movq	(%rdx,%rax), %rax
	movl	%eax, %edx
	movl	-12(%rbp), %eax
	movl	%edx, %esi
	movl	%eax, %edi
	call	update
	jmp	.L19
.L18:
	movl	seg(%rip), %eax
	cltq
	subq	%rax, -8(%rbp)
	movl	-12(%rbp), %eax
	cltq
	salq	$4, %rax
	movq	%rax, %rdx
	leaq	foo(%rip), %rax
	movq	(%rdx,%rax), %rax
	addq	%rax, -8(%rbp)
	movl	-12(%rbp), %eax
	cltq
	salq	$4, %rax
	movq	%rax, %rdx
	leaq	foo(%rip), %rax
	movq	(%rdx,%rax), %rax
	movl	%eax, %edx
	movl	4+seg(%rip), %eax
	movl	%edx, %esi
	movl	%eax, %edi
	call	update
.L19:
	movl	-12(%rbp), %eax
	cltq
	salq	$4, %rax
	movq	%rax, %rdx
	leaq	8+foo(%rip), %rax
	movq	(%rdx,%rax), %rdx
	movl	-20(%rbp), %eax
	cltq
	imulq	%rdx, %rax
	cmpq	%rax, -8(%rbp)
	jg	.L20
	movl	$1, %eax
	jmp	.L21
.L20:
	addl	$1, -12(%rbp)
.L17:
	movl	n(%rip), %eax
	cmpl	%eax, -12(%rbp)
	jl	.L22
	movl	$0, %eax
.L21:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE10:
	.size	canPut, .-canPut
	.section	.rodata
.LC0:
	.string	"%d"
.LC1:
	.string	"%lld %lld"
.LC2:
	.string	"%d\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB11:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$16, %rsp
	leaq	n(%rip), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -16(%rbp)
	jmp	.L24
.L25:
	movl	-16(%rbp), %eax
	cltq
	salq	$4, %rax
	movq	%rax, %rdx
	leaq	foo(%rip), %rax
	addq	%rdx, %rax
	leaq	8(%rax), %rdx
	movl	-16(%rbp), %eax
	cltq
	salq	$4, %rax
	movq	%rax, %rcx
	leaq	foo(%rip), %rax
	addq	%rcx, %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -16(%rbp)
.L24:
	movl	n(%rip), %eax
	cmpl	%eax, -16(%rbp)
	jl	.L25
	movl	$0, -12(%rbp)
	movl	n(%rip), %eax
	movl	%eax, -8(%rbp)
	movl	n(%rip), %eax
	cltq
	leaq	comp(%rip), %rdx
	movq	%rdx, %rcx
	movl	$16, %edx
	movq	%rax, %rsi
	leaq	foo(%rip), %rax
	movq	%rax, %rdi
	call	qsort@PLT
	jmp	.L26
.L28:
	movl	-12(%rbp), %edx
	movl	-8(%rbp), %eax
	addl	%edx, %eax
	addl	$1, %eax
	movl	%eax, %edx
	shrl	$31, %edx
	addl	%edx, %eax
	sarl	%eax
	movl	%eax, -4(%rbp)
	movl	-4(%rbp), %eax
	movl	%eax, %edi
	call	canPut
	testl	%eax, %eax
	je	.L27
	movl	-4(%rbp), %eax
	movl	%eax, -12(%rbp)
	jmp	.L26
.L27:
	movl	-4(%rbp), %eax
	subl	$1, %eax
	movl	%eax, -8(%rbp)
.L26:
	movl	-12(%rbp), %eax
	cmpl	-8(%rbp), %eax
	jne	.L28
	movl	-12(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE11:
	.size	main, .-main
	.ident	"GCC: (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:
```

Only output the optimized assembly code. Do not include any other text. Do not write any comments in the assembly code. Wrap the assembly code in ```assembly``` tags.
user
	.file	"temp.c"
	.text
	.p2align 4
	.globl	comp
	.type	comp, @function
comp:
.LFB54:
	.cfi_startproc
	endbr64
	movq	8(%rdi), %rdx
	movq	8(%rsi), %rax
	cmpq	%rax, %rdx
	je	.L2
	subl	%edx, %eax
	ret
	.p2align 4,,10
	.p2align 3
.L2:
	movq	(%rdi), %rax
	subl	(%rsi), %eax
	ret
	.cfi_endproc
.LFE54:
	.size	comp, .-comp
	.p2align 4
	.globl	_max
	.type	_max, @function
_max:
.LFB51:
	.cfi_startproc
	endbr64
	cmpq	%rdi, %rsi
	movq	%rdi, %rax
	cmovge	%rsi, %rax
	ret
	.cfi_endproc
.LFE51:
	.size	_max, .-_max
	.p2align 4
	.globl	init
	.type	init, @function
init:
.LFB52:
	.cfi_startproc
	endbr64
	movl	$1, seg_size(%rip)
	cmpl	$1, %edi
	jle	.L7
	movl	$1, %eax
	.p2align 4,,10
	.p2align 3
.L8:
	addl	%eax, %eax
	cmpl	%edi, %eax
	jl	.L8
	movl	%eax, seg_size(%rip)
.L7:
	movl	$4194304, %edx
	movl	$-1, %esi
	leaq	seg(%rip), %rdi
	jmp	memset@PLT
	.cfi_endproc
.LFE52:
	.size	init, .-init
	.p2align 4
	.globl	update
	.type	update, @function
update:
.LFB53:
	.cfi_startproc
	endbr64
	movl	%edi, %ecx
	movd	%esi, %xmm0
	addl	seg_size(%rip), %ecx
	movd	%edi, %xmm2
	movslq	%ecx, %rax
	leaq	seg(%rip), %r8
	punpckldq	%xmm2, %xmm0
	movq	%xmm0, (%r8,%rax,8)
	jne	.L14
	jmp	.L10
	.p2align 4,,10
	.p2align 3
.L19:
	movl	4(%r8,%rdi,8), %edi
	movl	%r9d, %esi
.L13:
	movd	%esi, %xmm0
	movd	%edi, %xmm1
	movslq	%eax, %rdx
	punpckldq	%xmm1, %xmm0
	movq	%xmm0, (%r8,%rdx,8)
	testl	%eax, %eax
	je	.L10
.L14:
	subl	$1, %ecx
	movl	%ecx, %eax
	shrl	$31, %eax
	addl	%ecx, %eax
	sarl	%eax
	leal	(%rax,%rax), %edx
	movl	%eax, %ecx
	leal	1(%rdx), %edi
	addl	$2, %edx
	movslq	%edi, %rdi
	movslq	%edx, %rdx
	movl	(%r8,%rdi,8), %r9d
	movl	(%r8,%rdx,8), %esi
	cmpl	%esi, %r9d
	jg	.L19
	movl	4(%r8,%rdx,8), %edi
	jmp	.L13
	.p2align 4,,10
	.p2align 3
.L10:
	ret
	.cfi_endproc
.LFE53:
	.size	update, .-update
	.p2align 4
	.globl	canPut
	.type	canPut, @function
canPut:
.LFB55:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	movslq	%edi, %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	leal	-1(%rbp), %r12d
	subq	$8, %rsp
	.cfi_def_cfa_offset 64
	movl	$1, seg_size(%rip)
	cmpl	$1, %ebp
	jle	.L21
	movl	$1, %ebx
	.p2align 4,,10
	.p2align 3
.L22:
	addl	%ebx, %ebx
	cmpl	%ebx, %ebp
	jg	.L22
	movl	$4194304, %edx
	leaq	seg(%rip), %rcx
	movl	$-1, %esi
	movl	%ebx, seg_size(%rip)
	movq	%rcx, %rdi
	call	memset@PLT
	movq	%rax, %rcx
.L42:
	movslq	%ebx, %rax
	leaq	foo(%rip), %r13
	movl	%ebx, %r11d
	xorl	%r10d, %r10d
	leaq	(%rcx,%rax,8), %r14
	xorl	%r9d, %r9d
	.p2align 4,,10
	.p2align 3
.L26:
	movd	0(%r13), %xmm0
	movd	%r10d, %xmm5
	addq	0(%r13), %r9
	movl	%r11d, %esi
	punpckldq	%xmm5, %xmm0
	movq	%xmm0, (%r14,%r10,8)
	testl	%r11d, %r11d
	jne	.L25
	jmp	.L29
	.p2align 4,,10
	.p2align 3
.L60:
	movl	4(%rcx,%r8,8), %r8d
.L28:
	movd	%edi, %xmm0
	movd	%r8d, %xmm2
	movslq	%eax, %rdx
	punpckldq	%xmm2, %xmm0
	movq	%xmm0, (%rcx,%rdx,8)
	testl	%eax, %eax
	je	.L29
.L25:
	subl	$1, %esi
	movl	%esi, %eax
	shrl	$31, %eax
	addl	%esi, %eax
	sarl	%eax
	leal	(%rax,%rax), %edx
	movl	%eax, %esi
	leal	1(%rdx), %r8d
	addl	$2, %edx
	movslq	%r8d, %r8
	movslq	%edx, %rdx
	movl	(%rcx,%r8,8), %edi
	movl	(%rcx,%rdx,8), %r15d
	cmpl	%r15d, %edi
	jg	.L60
	movl	4(%rcx,%rdx,8), %r8d
	movl	%r15d, %edi
	jmp	.L28
	.p2align 4,,10
	.p2align 3
.L29:
	addq	$1, %r10
	addq	$16, %r13
	addl	$1, %r11d
	cmpl	%r10d, %r12d
	jg	.L26
	movl	$2, %eax
	cmpl	%eax, %ebp
	cmovge	%ebp, %eax
	leal	-1(%rax), %r10d
.L24:
	movl	n(%rip), %r14d
	cmpl	%r10d, %r14d
	jle	.L41
	movslq	%r10d, %r11
	leaq	foo(%rip), %rax
	leal	(%r10,%rbx), %r13d
	salq	$4, %r11
	addq	%rax, %r11
	.p2align 4,,10
	.p2align 3
.L40:
	movq	(%r11), %rax
	movd	%r10d, %xmm4
	movd	%eax, %xmm0
	punpckldq	%xmm4, %xmm0
	cmpl	%r12d, %r10d
	je	.L61
	movslq	(%rcx), %rdx
	movd	4+seg(%rip), %xmm6
	movl	%ebx, %esi
	movd	%eax, %xmm0
	subq	%rdx, %r9
	punpckldq	%xmm6, %xmm0
	addq	%rax, %r9
	addl	4+seg(%rip), %esi
	movslq	%esi, %rdx
	movq	%xmm0, (%rcx,%rdx,8)
	jne	.L39
	jmp	.L33
	.p2align 4,,10
	.p2align 3
.L62:
	movd	4(%rcx,%r8,8), %xmm0
.L38:
	movd	%edi, %xmm1
	movslq	%eax, %rdx
	punpckldq	%xmm0, %xmm1
	movq	%xmm1, (%rcx,%rdx,8)
	testl	%eax, %eax
	je	.L33
.L39:
	subl	$1, %esi
	movl	%esi, %eax
	shrl	$31, %eax
	addl	%esi, %eax
	sarl	%eax
	leal	(%rax,%rax), %edx
	movl	%eax, %esi
	leal	1(%rdx), %r8d
	addl	$2, %edx
	movslq	%r8d, %r8
	movslq	%edx, %rdx
	movl	(%rcx,%r8,8), %edi
	movl	(%rcx,%rdx,8), %r15d
	cmpl	%r15d, %edi
	jg	.L62
	movd	4(%rcx,%rdx,8), %xmm0
	movl	%r15d, %edi
	jmp	.L38
	.p2align 4,,10
	.p2align 3
.L33:
	movq	8(%r11), %rax
	imulq	%rbp, %rax
	cmpq	%r9, %rax
	jge	.L44
	addl	$1, %r10d
	addq	$16, %r11
	addl	$1, %r13d
	cmpl	%r10d, %r14d
	jne	.L40
.L41:
	addq	$8, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 56
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%rbp
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	ret
	.p2align 4,,10
	.p2align 3
.L61:
	.cfi_restore_state
	addq	%rax, %r9
	movslq	%r13d, %rax
	movl	%r13d, %esi
	movq	%xmm0, (%rcx,%rax,8)
	testl	%r13d, %r13d
	jne	.L36
	jmp	.L33
	.p2align 4,,10
	.p2align 3
.L63:
	movl	4(%rcx,%r8,8), %r8d
.L35:
	movd	%edi, %xmm0
	movd	%r8d, %xmm3
	movslq	%eax, %rdx
	punpckldq	%xmm3, %xmm0
	movq	%xmm0, (%rcx,%rdx,8)
	testl	%eax, %eax
	je	.L33
.L36:
	subl	$1, %esi
	movl	%esi, %eax
	shrl	$31, %eax
	addl	%esi, %eax
	sarl	%eax
	leal	(%rax,%rax), %edx
	movl	%eax, %esi
	leal	1(%rdx), %r8d
	addl	$2, %edx
	movslq	%r8d, %r8
	movslq	%edx, %rdx
	movl	(%rcx,%r8,8), %edi
	movl	(%rcx,%rdx,8), %r15d
	cmpl	%r15d, %edi
	jg	.L63
	movl	4(%rcx,%rdx,8), %r8d
	movl	%r15d, %edi
	jmp	.L35
.L44:
	addq	$8, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 56
	movl	$1, %eax
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%rbp
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	ret
.L21:
	.cfi_restore_state
	movl	$4194304, %edx
	movl	$-1, %esi
	movl	$1, %ebx
	leaq	seg(%rip), %rcx
	movq	%rcx, %rdi
	call	memset@PLT
	movq	%rax, %rcx
	testl	%r12d, %r12d
	jg	.L42
	xorl	%r9d, %r9d
	xorl	%r10d, %r10d
	jmp	.L24
	.cfi_endproc
.LFE55:
	.size	canPut, .-canPut
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d"
.LC1:
	.string	"%lld %lld"
.LC2:
	.string	"%d\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB56:
	.cfi_startproc
	endbr64
	pushq	%r14
	.cfi_def_cfa_offset 16
	.cfi_offset 14, -16
	leaq	n(%rip), %rsi
	leaq	.LC0(%rip), %rdi
	xorl	%eax, %eax
	pushq	%r13
	.cfi_def_cfa_offset 24
	.cfi_offset 13, -24
	leaq	foo(%rip), %r14
	pushq	%r12
	.cfi_def_cfa_offset 32
	.cfi_offset 12, -32
	pushq	%rbp
	.cfi_def_cfa_offset 40
	.cfi_offset 6, -40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	.cfi_offset 3, -48
	call	__isoc99_scanf@PLT
	movl	n(%rip), %r12d
	testl	%r12d, %r12d
	jle	.L65
	movq	%r14, %rbx
	xorl	%ebp, %ebp
	leaq	.LC1(%rip), %r13
	.p2align 4,,10
	.p2align 3
.L66:
	leaq	8(%rbx), %rdx
	movq	%rbx, %rsi
	movq	%r13, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	n(%rip), %r12d
	addl	$1, %ebp
	addq	$16, %rbx
	cmpl	%ebp, %r12d
	jg	.L66
.L65:
	movslq	%r12d, %rsi
	leaq	comp(%rip), %rcx
	movl	$16, %edx
	movq	%r14, %rdi
	call	qsort@PLT
	testl	%r12d, %r12d
	je	.L67
	xorl	%ebp, %ebp
	.p2align 4,,10
	.p2align 3
.L70:
	leal	1(%rbp,%r12), %eax
	movl	%eax, %ebx
	shrl	$31, %ebx
	addl	%eax, %ebx
	sarl	%ebx
	movl	%ebx, %edi
	call	canPut
	testl	%eax, %eax
	jne	.L68
	leal	-1(%rbx), %r12d
	cmpl	%ebp, %r12d
	jne	.L70
.L67:
	movl	%r12d, %edx
	leaq	.LC2(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	popq	%rbx
	.cfi_remember_state
	.cfi_def_cfa_offset 40
	xorl	%eax, %eax
	popq	%rbp
	.cfi_def_cfa_offset 32
	popq	%r12
	.cfi_def_cfa_offset 24
	popq	%r13
	.cfi_def_cfa_offset 16
	popq	%r14
	.cfi_def_cfa_offset 8
	ret
	.p2align 4,,10
	.p2align 3
.L68:
	.cfi_restore_state
	cmpl	%r12d, %ebx
	je	.L67
	movl	%ebx, %ebp
	jmp	.L70
	.cfi_endproc
.LFE56:
	.size	main, .-main
	.globl	seg_size
	.bss
	.align 4
	.type	seg_size, @object
	.size	seg_size, 4
seg_size:
	.zero	4
	.globl	seg
	.align 32
	.type	seg, @object
	.size	seg, 4194304
seg:
	.zero	4194304
	.globl	n
	.align 4
	.type	n, @object
	.size	n, 4
n:
	.zero	4
	.globl	foo
	.align 32
	.type	foo, @object
	.size	foo, 4800000
foo:
	.zero	4800000
	.ident	"GCC: (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:

rule
	.file	"temp.c"
	.text
	.p2align 4
	.globl	comp
	.type	comp, @function
comp:
.LFB54:
	.cfi_startproc
	endbr64
	movq	8(%rdi), %rdx
	movq	8(%rsi), %rax
	cmpq	%rax, %rdx
	je	.L2
	subl	%edx, %eax
	ret
	.p2align 4,,10
	.p2align 3
.L2:
	movq	(%rdi), %rax
	subl	(%rsi), %eax
	ret
	.cfi_endproc
.LFE54:
	.size	comp, .-comp
	.p2align 4
	.globl	_max
	.type	_max, @function
_max:
.LFB51:
	.cfi_startproc
	endbr64
	cmpq	%rdi, %rsi
	movq	%rdi, %rax
	cmovge	%rsi, %rax
	ret
	.cfi_endproc
.LFE51:
	.size	_max, .-_max
	.p2align 4
	.globl	init
	.type	init, @function
init:
.LFB52:
	.cfi_startproc
	endbr64
	movl	$1, seg_size(%rip)
	cmpl	$1, %edi
	jle	.L7
	movl	$1, %eax
	.p2align 4,,10
	.p2align 3
.L8:
	addl	%eax, %eax
	cmpl	%edi, %eax
	jl	.L8
	movl	%eax, seg_size(%rip)
.L7:
	movl	$4194304, %edx
	movl	$-1, %esi
	leaq	seg(%rip), %rdi
	jmp	memset@PLT
	.cfi_endproc
.LFE52:
	.size	init, .-init
	.p2align 4
	.globl	update
	.type	update, @function
update:
.LFB53:
	.cfi_startproc
	endbr64
	movl	%edi, %ecx
	movd	%esi, %xmm0
	addl	seg_size(%rip), %ecx
	movd	%edi, %xmm2
	movslq	%ecx, %rax
	leaq	seg(%rip), %r8
	punpckldq	%xmm2, %xmm0
	movq	%xmm0, (%r8,%rax,8)
	jne	.L14
	jmp	.L10
	.p2align 4,,10
	.p2align 3
.L19:
	movl	4(%r8,%rdi,8), %edi
	movl	%r9d, %esi
.L13:
	movd	%esi, %xmm0
	movd	%edi, %xmm1
	movslq	%eax, %rdx
	punpckldq	%xmm1, %xmm0
	movq	%xmm0, (%r8,%rdx,8)
	testl	%eax, %eax
	je	.L10
.L14:
	subl	$1, %ecx
	movl	%ecx, %eax
	shrl	$31, %eax
	addl	%ecx, %eax
	sarl	%eax
	leal	(%rax,%rax), %edx
	movl	%eax, %ecx
	leal	1(%rdx), %edi
	addl	$2, %edx
	movslq	%edi, %rdi
	movslq	%edx, %rdx
	movl	(%r8,%rdi,8), %r9d
	movl	(%r8,%rdx,8), %esi
	cmpl	%esi, %r9d
	jg	.L19
	movl	4(%r8,%rdx,8), %edi
	jmp	.L13
	.p2align 4,,10
	.p2align 3
.L10:
	ret
	.cfi_endproc
.LFE53:
	.size	update, .-update
	.p2align 4
	.globl	canPut
	.type	canPut, @function
canPut:
.LFB55:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	movslq	%edi, %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	leal	-1(%rbp), %r12d
	subq	$8, %rsp
	.cfi_def_cfa_offset 64
	movl	$1, seg_size(%rip)
	cmpl	$1, %ebp
	jle	.L21
	movl	$1, %ebx
	.p2align 4,,10
	.p2align 3
.L22:
	addl	%ebx, %ebx
	cmpl	%ebx, %ebp
	jg	.L22
	movl	$4194304, %edx
	leaq	seg(%rip), %rcx
	movl	$-1, %esi
	movl	%ebx, seg_size(%rip)
	movq	%rcx, %rdi
	call	memset@PLT
	movq	%rax, %rcx
.L42:
	movslq	%ebx, %rax
	leaq	foo(%rip), %r13
	movl	%ebx, %r11d
	xorl	%r10d, %r10d
	leaq	(%rcx,%rax,8), %r14
	xorl	%r9d, %r9d
	.p2align 4,,10
	.p2align 3
.L26:
	movd	0(%r13), %xmm0
	movd	%r10d, %xmm5
	addq	0(%r13), %r9
	movl	%r11d, %esi
	punpckldq	%xmm5, %xmm0
	movq	%xmm0, (%r14,%r10,8)
	testl	%r11d, %r11d
	jne	.L25
	jmp	.L29
	.p2align 4,,10
	.p2align 3
.L60:
	movl	4(%rcx,%r8,8), %r8d
.L28:
	movd	%edi, %xmm0
	movd	%r8d, %xmm2
	movslq	%eax, %rdx
	punpckldq	%xmm2, %xmm0
	movq	%xmm0, (%rcx,%rdx,8)
	testl	%eax, %eax
	je	.L29
.L25:
	subl	$1, %esi
	movl	%esi, %eax
	shrl	$31, %eax
	addl	%esi, %eax
	sarl	%eax
	leal	(%rax,%rax), %edx
	movl	%eax, %esi
	leal	1(%rdx), %r8d
	addl	$2, %edx
	movslq	%r8d, %r8
	movslq	%edx, %rdx
	movl	(%rcx,%r8,8), %edi
	movl	(%rcx,%rdx,8), %r15d
	cmpl	%r15d, %edi
	jg	.L60
	movl	4(%rcx,%rdx,8), %r8d
	movl	%r15d, %edi
	jmp	.L28
	.p2align 4,,10
	.p2align 3
.L29:
	addq	$1, %r10
	addq	$16, %r13
	addl	$1, %r11d
	cmpl	%r10d, %r12d
	jg	.L26
	movl	$2, %eax
	cmpl	%eax, %ebp
	cmovge	%ebp, %eax
	leal	-1(%rax), %r10d
.L24:
	movl	n(%rip), %r14d
	cmpl	%r10d, %r14d
	jle	.L41
	movslq	%r10d, %r11
	leaq	foo(%rip), %rax
	leal	(%r10,%rbx), %r13d
	salq	$4, %r11
	addq	%rax, %r11
	.p2align 4,,10
	.p2align 3
.L40:
	movq	(%r11), %rax
	movd	%r10d, %xmm4
	movd	%eax, %xmm0
	punpckldq	%xmm4, %xmm0
	cmpl	%r12d, %r10d
	je	.L61
	movslq	(%rcx), %rdx
	movd	4+seg(%rip), %xmm6
	movl	%ebx, %esi
	movd	%eax, %xmm0
	subq	%rdx, %r9
	punpckldq	%xmm6, %xmm0
	addq	%rax, %r9
	addl	4+seg(%rip), %esi
	movslq	%esi, %rdx
	movq	%xmm0, (%rcx,%rdx,8)
	jne	.L39
	jmp	.L33
	.p2align 4,,10
	.p2align 3
.L62:
	movd	4(%rcx,%r8,8), %xmm0
.L38:
	movd	%edi, %xmm1
	movslq	%eax, %rdx
	punpckldq	%xmm0, %xmm1
	movq	%xmm1, (%rcx,%rdx,8)
	testl	%eax, %eax
	je	.L33
.L39:
	subl	$1, %esi
	movl	%esi, %eax
	shrl	$31, %eax
	addl	%esi, %eax
	sarl	%eax
	leal	(%rax,%rax), %edx
	movl	%eax, %esi
	leal	1(%rdx), %r8d
	addl	$2, %edx
	movslq	%r8d, %r8
	movslq	%edx, %rdx
	movl	(%rcx,%r8,8), %edi
	movl	(%rcx,%rdx,8), %r15d
	cmpl	%r15d, %edi
	jg	.L62
	movd	4(%rcx,%rdx,8), %xmm0
	movl	%r15d, %edi
	jmp	.L38
	.p2align 4,,10
	.p2align 3
.L33:
	movq	8(%r11), %rax
	imulq	%rbp, %rax
	cmpq	%r9, %rax
	jge	.L44
	addl	$1, %r10d
	addq	$16, %r11
	addl	$1, %r13d
	cmpl	%r10d, %r14d
	jne	.L40
.L41:
	addq	$8, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 56
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%rbp
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	ret
	.p2align 4,,10
	.p2align 3
.L61:
	.cfi_restore_state
	addq	%rax, %r9
	movslq	%r13d, %rax
	movl	%r13d, %esi
	movq	%xmm0, (%rcx,%rax,8)
	testl	%r13d, %r13d
	jne	.L36
	jmp	.L33
	.p2align 4,,10
	.p2align 3
.L63:
	movl	4(%rcx,%r8,8), %r8d
.L35:
	movd	%edi, %xmm0
	movd	%r8d, %xmm3
	movslq	%eax, %rdx
	punpckldq	%xmm3, %xmm0
	movq	%xmm0, (%rcx,%rdx,8)
	testl	%eax, %eax
	je	.L33
.L36:
	subl	$1, %esi
	movl	%esi, %eax
	shrl	$31, %eax
	addl	%esi, %eax
	sarl	%eax
	leal	(%rax,%rax), %edx
	movl	%eax, %esi
	leal	1(%rdx), %r8d
	addl	$2, %edx
	movslq	%r8d, %r8
	movslq	%edx, %rdx
	movl	(%rcx,%r8,8), %edi
	movl	(%rcx,%rdx,8), %r15d
	cmpl	%r15d, %edi
	jg	.L63
	movl	4(%rcx,%rdx,8), %r8d
	movl	%r15d, %edi
	jmp	.L35
.L44:
	addq	$8, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 56
	movl	$1, %eax
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%rbp
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	ret
.L21:
	.cfi_restore_state
	movl	$4194304, %edx
	movl	$-1, %esi
	movl	$1, %ebx
	leaq	seg(%rip), %rcx
	movq	%rcx, %rdi
	call	memset@PLT
	movq	%rax, %rcx
	testl	%r12d, %r12d
	jg	.L42
	xorl	%r9d, %r9d
	xorl	%r10d, %r10d
	jmp	.L24
	.cfi_endproc
.LFE55:
	.size	canPut, .-canPut
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d"
.LC1:
	.string	"%lld %lld"
.LC2:
	.string	"%d\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB56:
	.cfi_startproc
	endbr64
	pushq	%r14
	.cfi_def_cfa_offset 16
	.cfi_offset 14, -16
	leaq	n(%rip), %rsi
	leaq	.LC0(%rip), %rdi
	xorl	%eax, %eax
	pushq	%r13
	.cfi_def_cfa_offset 24
	.cfi_offset 13, -24
	leaq	foo(%rip), %r14
	pushq	%r12
	.cfi_def_cfa_offset 32
	.cfi_offset 12, -32
	pushq	%rbp
	.cfi_def_cfa_offset 40
	.cfi_offset 6, -40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	.cfi_offset 3, -48
	call	__isoc99_scanf@PLT
	movl	n(%rip), %r12d
	testl	%r12d, %r12d
	jle	.L65
	movq	%r14, %rbx
	xorl	%ebp, %ebp
	leaq	.LC1(%rip), %r13
	.p2align 4,,10
	.p2align 3
.L66:
	leaq	8(%rbx), %rdx
	movq	%rbx, %rsi
	movq	%r13, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	n(%rip), %r12d
	addl	$1, %ebp
	addq	$16, %rbx
	cmpl	%ebp, %r12d
	jg	.L66
.L65:
	movslq	%r12d, %rsi
	leaq	comp(%rip), %rcx
	movl	$16, %edx
	movq	%r14, %rdi
	call	qsort@PLT
	testl	%r12d, %r12d
	je	.L67
	xorl	%ebp, %ebp
	.p2align 4,,10
	.p2align 3
.L70:
	leal	1(%rbp,%r12), %eax
	movl	%eax, %ebx
	shrl	$31, %ebx
	addl	%eax, %ebx
	sarl	%ebx
	movl	%ebx, %edi
	call	canPut
	testl	%eax, %eax
	jne	.L68
	leal	-1(%rbx), %r12d
	cmpl	%ebp, %r12d
	jne	.L70
.L67:
	movl	%r12d, %edx
	leaq	.LC2(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	popq	%rbx
	.cfi_remember_state
	.cfi_def_cfa_offset 40
	xorl	%eax, %eax
	popq	%rbp
	.cfi_def_cfa_offset 32
	popq	%r12
	.cfi_def_cfa_offset 24
	popq	%r13
	.cfi_def_cfa_offset 16
	popq	%r14
	.cfi_def_cfa_offset 8
	ret
	.p2align 4,,10
	.p2align 3
.L68:
	.cfi_restore_state
	cmpl	%r12d, %ebx
	je	.L67
	movl	%ebx, %ebp
	jmp	.L70
	.cfi_endproc
.LFE56:
	.size	main, .-main
	.globl	seg_size
	.bss
	.align 4
	.type	seg_size, @object
	.size	seg_size, 4
seg_size:
	.zero	4
	.globl	seg
	.align 32
	.type	seg, @object
	.size	seg, 4194304
seg:
	.zero	4194304
	.globl	n
	.align 4
	.type	n, @object
	.size	n, 4
n:
	.zero	4
	.globl	foo
	.align 32
	.type	foo, @object
	.size	foo, 4800000
foo:
	.zero	4800000
	.ident	"GCC: (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:

#include <stdio.h>
#include <string.h>
#include <stdlib.h>

typedef long long ll;
typedef struct {
    ll a, b;
} BUG;

BUG foo[300000];
int n;

int seg[1 << 19][2];
int seg_size;

ll _max(ll a, ll b)
{
    return (a > b ? a : b);
}

void init(int n)
{
    seg_size = 1;
    
    while (n > seg_size){
        seg_size *= 2;
    }
    memset(seg, -1, sizeof(seg));
}

void update(int k, int x)
{
    k += seg_size;
    
    seg[k][0] = x;
    seg[k][1] = k - seg_size;
    
    while (k != 0){
        k = (k - 1) / 2;
        if (seg[k * 2 + 1][0] > seg[k * 2 + 2][0]){
            seg[k][0] = seg[k * 2 + 1][0];
            seg[k][1] = seg[k * 2 + 1][1];
        }
        else {
            seg[k][0] = seg[k * 2 + 2][0];
            seg[k][1] = seg[k * 2 + 2][1];
        }
    }
}

int comp(const void *a, const void *b)
{
    BUG x, y;
    x = *(BUG *)a;
    y = *(BUG *)b;
    
    if (x.b != y.b){
        return (y.b - x.b);
    }
    else {
        return (x.a - y.a);
    }
}

int canPut(int piv)
{
    int i;
    ll lim;
    
    init(piv);
    
    lim = 0;
    for (i = 0; i < piv - 1; i++){
        lim += foo[i].a;
        update(i, foo[i].a);
    }
    
    while (i < n){
        if (i == piv - 1){
            lim += foo[i].a;
            update(i, foo[i].a);
        }
        else {
            lim -= seg[0][0];
            lim += foo[i].a;
            update(seg[0][1], foo[i].a);
        }
        
        if (lim <= foo[i].b * piv){
            return (1);
        }
        i++;
    }
    
    return (0);
}

int main(void)
{
    int i;
    int left, right, center;
    
    scanf("%d", &n);
    
    for (i = 0; i < n; i++){
        scanf("%lld %lld", &foo[i].a, &foo[i].b);
    }
    
    left = 0;
    right = n;
    
    qsort(foo, n, sizeof(BUG), comp);
    
    while (left != right){
        center = (left + right + 1) / 2;
        
        if (canPut(center)){
            left = center;
        }
        else {
            right = center - 1;
        }
    }
    
    printf("%d\n", left);
    
    return (0);
}
6
12 8
5 9
2 4
10 12
6 7
6 9
 6
12 9
5 9
2 4
10 12
6 12
6 9
 6
12 8
5 5
2 4
10 12
6 7
13 9
 6
12 8
5 9
2 4
10 6
6 7
6 9
 6
12 26
5 9
0 14
10 9
6 12
6 9
 6
12 9
5 9
2 4
10 12
6 7
6 9
 6
12 13
5 9
2 4
10 12
6 12
6 9
 6
12 26
5 9
2 4
10 12
6 12
6 9
 6
12 38
5 9
2 4
10 12
6 12
6 9
 6
12 38
5 9
2 4
10 4
6 12
6 9

4
 5
 2
 3
 6
 4
 5
 5
 5
 4

Given the following C code and unoptimized assembly code, your task is to generate highly optimized x86-64 assembly code.
C Code:

```c
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

typedef long long ll;
typedef struct {
    ll a, b;
} BUG;

BUG foo[300000];
int n;

int seg[1 << 19][2];
int seg_size;

ll _max(ll a, ll b)
{
    return (a > b ? a : b);
}

void init(int n)
{
    seg_size = 1;
    
    while (n > seg_size){
        seg_size *= 2;
    }
    memset(seg, -1, sizeof(seg));
}

void update(int k, int x)
{
    k += seg_size;
    
    seg[k][0] = x;
    seg[k][1] = k - seg_size;
    
    while (k != 0){
        k = (k - 1) / 2;
        if (seg[k * 2 + 1][0] > seg[k * 2 + 2][0]){
            seg[k][0] = seg[k * 2 + 1][0];
            seg[k][1] = seg[k * 2 + 1][1];
        }
        else {
            seg[k][0] = seg[k * 2 + 2][0];
            seg[k][1] = seg[k * 2 + 2][1];
        }
    }
}

int comp(const void *a, const void *b)
{
    BUG x, y;
    x = *(BUG *)a;
    y = *(BUG *)b;
    
    if (x.b != y.b){
        return (y.b - x.b);
    }
    else {
        return (x.a - y.a);
    }
}

int canPut(int piv)
{
    int i;
    ll lim;
    
    init(piv);
    
    lim = 0;
    for (i = 0; i < piv - 1; i++){
        lim += foo[i].a;
        update(i, foo[i].a);
    }
    
    while (i < n){
        if (i == piv - 1){
            lim += foo[i].a;
            update(i, foo[i].a);
        }
        else {
            lim -= seg[0][0];
            lim += foo[i].a;
            update(seg[0][1], foo[i].a);
        }
        
        if (lim <= foo[i].b * piv){
            return (1);
        }
        i++;
    }
    
    return (0);
}

int main(void)
{
    int i;
    int left, right, center;
    
    scanf("%d", &n);
    
    for (i = 0; i < n; i++){
        scanf("%lld %lld", &foo[i].a, &foo[i].b);
    }
    
    left = 0;
    right = n;
    
    qsort(foo, n, sizeof(BUG), comp);
    
    while (left != right){
        center = (left + right + 1) / 2;
        
        if (canPut(center)){
            left = center;
        }
        else {
            right = center - 1;
        }
    }
    
    printf("%d\n", left);
    
    return (0);
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	foo
	.bss
	.align 32
	.type	foo, @object
	.size	foo, 4800000
foo:
	.zero	4800000
	.globl	n
	.align 4
	.type	n, @object
	.size	n, 4
n:
	.zero	4
	.globl	seg
	.align 32
	.type	seg, @object
	.size	seg, 4194304
seg:
	.zero	4194304
	.globl	seg_size
	.align 4
	.type	seg_size, @object
	.size	seg_size, 4
seg_size:
	.zero	4
	.text
	.globl	_max
	.type	_max, @function
_max:
.LFB6:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movq	%rdi, -8(%rbp)
	movq	%rsi, -16(%rbp)
	movq	-16(%rbp), %rdx
	movq	-8(%rbp), %rax
	cmpq	%rax, %rdx
	cmovge	%rdx, %rax
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.size	_max, .-_max
	.globl	init
	.type	init, @function
init:
.LFB7:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$16, %rsp
	movl	%edi, -4(%rbp)
	movl	$1, seg_size(%rip)
	jmp	.L4
.L5:
	movl	seg_size(%rip), %eax
	addl	%eax, %eax
	movl	%eax, seg_size(%rip)
.L4:
	movl	seg_size(%rip), %eax
	cmpl	%eax, -4(%rbp)
	jg	.L5
	movl	$4194304, %edx
	movl	$-1, %esi
	leaq	seg(%rip), %rax
	movq	%rax, %rdi
	call	memset@PLT
	nop
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE7:
	.size	init, .-init
	.globl	update
	.type	update, @function
update:
.LFB8:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movl	%edi, -4(%rbp)
	movl	%esi, -8(%rbp)
	movl	seg_size(%rip), %eax
	addl	%eax, -4(%rbp)
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rcx
	leaq	seg(%rip), %rdx
	movl	-8(%rbp), %eax
	movl	%eax, (%rcx,%rdx)
	movl	seg_size(%rip), %edx
	movl	-4(%rbp), %eax
	subl	%edx, %eax
	movl	%eax, %ecx
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	4+seg(%rip), %rax
	movl	%ecx, (%rdx,%rax)
	jmp	.L7
.L9:
	movl	-4(%rbp), %eax
	subl	$1, %eax
	movl	%eax, %edx
	shrl	$31, %edx
	addl	%edx, %eax
	sarl	%eax
	movl	%eax, -4(%rbp)
	movl	-4(%rbp), %eax
	addl	%eax, %eax
	addl	$1, %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	seg(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	-4(%rbp), %eax
	addl	$1, %eax
	addl	%eax, %eax
	cltq
	leaq	0(,%rax,8), %rcx
	leaq	seg(%rip), %rax
	movl	(%rcx,%rax), %eax
	cmpl	%eax, %edx
	jle	.L8
	movl	-4(%rbp), %eax
	addl	%eax, %eax
	addl	$1, %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	seg(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	-4(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,8), %rcx
	leaq	seg(%rip), %rdx
	movl	%eax, (%rcx,%rdx)
	movl	-4(%rbp), %eax
	addl	%eax, %eax
	addl	$1, %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	4+seg(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	-4(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,8), %rcx
	leaq	4+seg(%rip), %rdx
	movl	%eax, (%rcx,%rdx)
	jmp	.L7
.L8:
	movl	-4(%rbp), %eax
	addl	$1, %eax
	addl	%eax, %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	seg(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	-4(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,8), %rcx
	leaq	seg(%rip), %rdx
	movl	%eax, (%rcx,%rdx)
	movl	-4(%rbp), %eax
	addl	$1, %eax
	addl	%eax, %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	4+seg(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	-4(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,8), %rcx
	leaq	4+seg(%rip), %rdx
	movl	%eax, (%rcx,%rdx)
.L7:
	cmpl	$0, -4(%rbp)
	jne	.L9
	nop
	nop
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE8:
	.size	update, .-update
	.globl	comp
	.type	comp, @function
comp:
.LFB9:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movq	%rdi, -40(%rbp)
	movq	%rsi, -48(%rbp)
	movq	-40(%rbp), %rax
	movq	8(%rax), %rdx
	movq	(%rax), %rax
	movq	%rax, -32(%rbp)
	movq	%rdx, -24(%rbp)
	movq	-48(%rbp), %rax
	movq	8(%rax), %rdx
	movq	(%rax), %rax
	movq	%rax, -16(%rbp)
	movq	%rdx, -8(%rbp)
	movq	-24(%rbp), %rdx
	movq	-8(%rbp), %rax
	cmpq	%rax, %rdx
	je	.L11
	movq	-8(%rbp), %rax
	movl	%eax, %edx
	movq	-24(%rbp), %rax
	movl	%eax, %ecx
	movl	%edx, %eax
	subl	%ecx, %eax
	jmp	.L13
.L11:
	movq	-32(%rbp), %rax
	movl	%eax, %edx
	movq	-16(%rbp), %rax
	movl	%eax, %ecx
	movl	%edx, %eax
	subl	%ecx, %eax
.L13:
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE9:
	.size	comp, .-comp
	.globl	canPut
	.type	canPut, @function
canPut:
.LFB10:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$32, %rsp
	movl	%edi, -20(%rbp)
	movl	-20(%rbp), %eax
	movl	%eax, %edi
	call	init
	movq	$0, -8(%rbp)
	movl	$0, -12(%rbp)
	jmp	.L15
.L16:
	movl	-12(%rbp), %eax
	cltq
	salq	$4, %rax
	movq	%rax, %rdx
	leaq	foo(%rip), %rax
	movq	(%rdx,%rax), %rax
	addq	%rax, -8(%rbp)
	movl	-12(%rbp), %eax
	cltq
	salq	$4, %rax
	movq	%rax, %rdx
	leaq	foo(%rip), %rax
	movq	(%rdx,%rax), %rax
	movl	%eax, %edx
	movl	-12(%rbp), %eax
	movl	%edx, %esi
	movl	%eax, %edi
	call	update
	addl	$1, -12(%rbp)
.L15:
	movl	-20(%rbp), %eax
	subl	$1, %eax
	cmpl	%eax, -12(%rbp)
	jl	.L16
	jmp	.L17
.L22:
	movl	-20(%rbp), %eax
	subl	$1, %eax
	cmpl	%eax, -12(%rbp)
	jne	.L18
	movl	-12(%rbp), %eax
	cltq
	salq	$4, %rax
	movq	%rax, %rdx
	leaq	foo(%rip), %rax
	movq	(%rdx,%rax), %rax
	addq	%rax, -8(%rbp)
	movl	-12(%rbp), %eax
	cltq
	salq	$4, %rax
	movq	%rax, %rdx
	leaq	foo(%rip), %rax
	movq	(%rdx,%rax), %rax
	movl	%eax, %edx
	movl	-12(%rbp), %eax
	movl	%edx, %esi
	movl	%eax, %edi
	call	update
	jmp	.L19
.L18:
	movl	seg(%rip), %eax
	cltq
	subq	%rax, -8(%rbp)
	movl	-12(%rbp), %eax
	cltq
	salq	$4, %rax
	movq	%rax, %rdx
	leaq	foo(%rip), %rax
	movq	(%rdx,%rax), %rax
	addq	%rax, -8(%rbp)
	movl	-12(%rbp), %eax
	cltq
	salq	$4, %rax
	movq	%rax, %rdx
	leaq	foo(%rip), %rax
	movq	(%rdx,%rax), %rax
	movl	%eax, %edx
	movl	4+seg(%rip), %eax
	movl	%edx, %esi
	movl	%eax, %edi
	call	update
.L19:
	movl	-12(%rbp), %eax
	cltq
	salq	$4, %rax
	movq	%rax, %rdx
	leaq	8+foo(%rip), %rax
	movq	(%rdx,%rax), %rdx
	movl	-20(%rbp), %eax
	cltq
	imulq	%rdx, %rax
	cmpq	%rax, -8(%rbp)
	jg	.L20
	movl	$1, %eax
	jmp	.L21
.L20:
	addl	$1, -12(%rbp)
.L17:
	movl	n(%rip), %eax
	cmpl	%eax, -12(%rbp)
	jl	.L22
	movl	$0, %eax
.L21:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE10:
	.size	canPut, .-canPut
	.section	.rodata
.LC0:
	.string	"%d"
.LC1:
	.string	"%lld %lld"
.LC2:
	.string	"%d\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB11:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$16, %rsp
	leaq	n(%rip), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -16(%rbp)
	jmp	.L24
.L25:
	movl	-16(%rbp), %eax
	cltq
	salq	$4, %rax
	movq	%rax, %rdx
	leaq	foo(%rip), %rax
	addq	%rdx, %rax
	leaq	8(%rax), %rdx
	movl	-16(%rbp), %eax
	cltq
	salq	$4, %rax
	movq	%rax, %rcx
	leaq	foo(%rip), %rax
	addq	%rcx, %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -16(%rbp)
.L24:
	movl	n(%rip), %eax
	cmpl	%eax, -16(%rbp)
	jl	.L25
	movl	$0, -12(%rbp)
	movl	n(%rip), %eax
	movl	%eax, -8(%rbp)
	movl	n(%rip), %eax
	cltq
	leaq	comp(%rip), %rdx
	movq	%rdx, %rcx
	movl	$16, %edx
	movq	%rax, %rsi
	leaq	foo(%rip), %rax
	movq	%rax, %rdi
	call	qsort@PLT
	jmp	.L26
.L28:
	movl	-12(%rbp), %edx
	movl	-8(%rbp), %eax
	addl	%edx, %eax
	addl	$1, %eax
	movl	%eax, %edx
	shrl	$31, %edx
	addl	%edx, %eax
	sarl	%eax
	movl	%eax, -4(%rbp)
	movl	-4(%rbp), %eax
	movl	%eax, %edi
	call	canPut
	testl	%eax, %eax
	je	.L27
	movl	-4(%rbp), %eax
	movl	%eax, -12(%rbp)
	jmp	.L26
.L27:
	movl	-4(%rbp), %eax
	subl	$1, %eax
	movl	%eax, -8(%rbp)
.L26:
	movl	-12(%rbp), %eax
	cmpl	-8(%rbp), %eax
	jne	.L28
	movl	-12(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE11:
	.size	main, .-main
	.ident	"GCC: (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:
```

Only output the optimized assembly code. Do not include any other text. Do not write any comments in the assembly code. Wrap the assembly code in ```assembly``` tags.
train
	.file	"temp.c"
	.text
	.globl	foo
	.bss
	.align 32
	.type	foo, @object
	.size	foo, 4800000
foo:
	.zero	4800000
	.globl	n
	.align 4
	.type	n, @object
	.size	n, 4
n:
	.zero	4
	.globl	seg
	.align 32
	.type	seg, @object
	.size	seg, 4194304
seg:
	.zero	4194304
	.globl	seg_size
	.align 4
	.type	seg_size, @object
	.size	seg_size, 4
seg_size:
	.zero	4
	.text
	.globl	_max
	.type	_max, @function
_max:
.LFB6:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movq	%rdi, -8(%rbp)
	movq	%rsi, -16(%rbp)
	movq	-16(%rbp), %rdx
	movq	-8(%rbp), %rax
	cmpq	%rax, %rdx
	cmovge	%rdx, %rax
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.size	_max, .-_max
	.globl	init
	.type	init, @function
init:
.LFB7:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$16, %rsp
	movl	%edi, -4(%rbp)
	movl	$1, seg_size(%rip)
	jmp	.L4
.L5:
	movl	seg_size(%rip), %eax
	addl	%eax, %eax
	movl	%eax, seg_size(%rip)
.L4:
	movl	seg_size(%rip), %eax
	cmpl	%eax, -4(%rbp)
	jg	.L5
	movl	$4194304, %edx
	movl	$-1, %esi
	leaq	seg(%rip), %rax
	movq	%rax, %rdi
	call	memset@PLT
	nop
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE7:
	.size	init, .-init
	.globl	update
	.type	update, @function
update:
.LFB8:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movl	%edi, -4(%rbp)
	movl	%esi, -8(%rbp)
	movl	seg_size(%rip), %eax
	addl	%eax, -4(%rbp)
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rcx
	leaq	seg(%rip), %rdx
	movl	-8(%rbp), %eax
	movl	%eax, (%rcx,%rdx)
	movl	seg_size(%rip), %edx
	movl	-4(%rbp), %eax
	subl	%edx, %eax
	movl	%eax, %ecx
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	4+seg(%rip), %rax
	movl	%ecx, (%rdx,%rax)
	jmp	.L7
.L9:
	movl	-4(%rbp), %eax
	subl	$1, %eax
	movl	%eax, %edx
	shrl	$31, %edx
	addl	%edx, %eax
	sarl	%eax
	movl	%eax, -4(%rbp)
	movl	-4(%rbp), %eax
	addl	%eax, %eax
	addl	$1, %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	seg(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	-4(%rbp), %eax
	addl	$1, %eax
	addl	%eax, %eax
	cltq
	leaq	0(,%rax,8), %rcx
	leaq	seg(%rip), %rax
	movl	(%rcx,%rax), %eax
	cmpl	%eax, %edx
	jle	.L8
	movl	-4(%rbp), %eax
	addl	%eax, %eax
	addl	$1, %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	seg(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	-4(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,8), %rcx
	leaq	seg(%rip), %rdx
	movl	%eax, (%rcx,%rdx)
	movl	-4(%rbp), %eax
	addl	%eax, %eax
	addl	$1, %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	4+seg(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	-4(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,8), %rcx
	leaq	4+seg(%rip), %rdx
	movl	%eax, (%rcx,%rdx)
	jmp	.L7
.L8:
	movl	-4(%rbp), %eax
	addl	$1, %eax
	addl	%eax, %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	seg(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	-4(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,8), %rcx
	leaq	seg(%rip), %rdx
	movl	%eax, (%rcx,%rdx)
	movl	-4(%rbp), %eax
	addl	$1, %eax
	addl	%eax, %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	4+seg(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	-4(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,8), %rcx
	leaq	4+seg(%rip), %rdx
	movl	%eax, (%rcx,%rdx)
.L7:
	cmpl	$0, -4(%rbp)
	jne	.L9
	nop
	nop
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE8:
	.size	update, .-update
	.globl	comp
	.type	comp, @function
comp:
.LFB9:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movq	%rdi, -40(%rbp)
	movq	%rsi, -48(%rbp)
	movq	-40(%rbp), %rax
	movq	8(%rax), %rdx
	movq	(%rax), %rax
	movq	%rax, -32(%rbp)
	movq	%rdx, -24(%rbp)
	movq	-48(%rbp), %rax
	movq	8(%rax), %rdx
	movq	(%rax), %rax
	movq	%rax, -16(%rbp)
	movq	%rdx, -8(%rbp)
	movq	-24(%rbp), %rdx
	movq	-8(%rbp), %rax
	cmpq	%rax, %rdx
	je	.L11
	movq	-8(%rbp), %rax
	movl	%eax, %edx
	movq	-24(%rbp), %rax
	movl	%eax, %ecx
	movl	%edx, %eax
	subl	%ecx, %eax
	jmp	.L13
.L11:
	movq	-32(%rbp), %rax
	movl	%eax, %edx
	movq	-16(%rbp), %rax
	movl	%eax, %ecx
	movl	%edx, %eax
	subl	%ecx, %eax
.L13:
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE9:
	.size	comp, .-comp
	.globl	canPut
	.type	canPut, @function
canPut:
.LFB10:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$32, %rsp
	movl	%edi, -20(%rbp)
	movl	-20(%rbp), %eax
	movl	%eax, %edi
	call	init
	movq	$0, -8(%rbp)
	movl	$0, -12(%rbp)
	jmp	.L15
.L16:
	movl	-12(%rbp), %eax
	cltq
	salq	$4, %rax
	movq	%rax, %rdx
	leaq	foo(%rip), %rax
	movq	(%rdx,%rax), %rax
	addq	%rax, -8(%rbp)
	movl	-12(%rbp), %eax
	cltq
	salq	$4, %rax
	movq	%rax, %rdx
	leaq	foo(%rip), %rax
	movq	(%rdx,%rax), %rax
	movl	%eax, %edx
	movl	-12(%rbp), %eax
	movl	%edx, %esi
	movl	%eax, %edi
	call	update
	addl	$1, -12(%rbp)
.L15:
	movl	-20(%rbp), %eax
	subl	$1, %eax
	cmpl	%eax, -12(%rbp)
	jl	.L16
	jmp	.L17
.L22:
	movl	-20(%rbp), %eax
	subl	$1, %eax
	cmpl	%eax, -12(%rbp)
	jne	.L18
	movl	-12(%rbp), %eax
	cltq
	salq	$4, %rax
	movq	%rax, %rdx
	leaq	foo(%rip), %rax
	movq	(%rdx,%rax), %rax
	addq	%rax, -8(%rbp)
	movl	-12(%rbp), %eax
	cltq
	salq	$4, %rax
	movq	%rax, %rdx
	leaq	foo(%rip), %rax
	movq	(%rdx,%rax), %rax
	movl	%eax, %edx
	movl	-12(%rbp), %eax
	movl	%edx, %esi
	movl	%eax, %edi
	call	update
	jmp	.L19
.L18:
	movl	seg(%rip), %eax
	cltq
	subq	%rax, -8(%rbp)
	movl	-12(%rbp), %eax
	cltq
	salq	$4, %rax
	movq	%rax, %rdx
	leaq	foo(%rip), %rax
	movq	(%rdx,%rax), %rax
	addq	%rax, -8(%rbp)
	movl	-12(%rbp), %eax
	cltq
	salq	$4, %rax
	movq	%rax, %rdx
	leaq	foo(%rip), %rax
	movq	(%rdx,%rax), %rax
	movl	%eax, %edx
	movl	4+seg(%rip), %eax
	movl	%edx, %esi
	movl	%eax, %edi
	call	update
.L19:
	movl	-12(%rbp), %eax
	cltq
	salq	$4, %rax
	movq	%rax, %rdx
	leaq	8+foo(%rip), %rax
	movq	(%rdx,%rax), %rdx
	movl	-20(%rbp), %eax
	cltq
	imulq	%rdx, %rax
	cmpq	%rax, -8(%rbp)
	jg	.L20
	movl	$1, %eax
	jmp	.L21
.L20:
	addl	$1, -12(%rbp)
.L17:
	movl	n(%rip), %eax
	cmpl	%eax, -12(%rbp)
	jl	.L22
	movl	$0, %eax
.L21:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE10:
	.size	canPut, .-canPut
	.section	.rodata
.LC0:
	.string	"%d"
.LC1:
	.string	"%lld %lld"
.LC2:
	.string	"%d\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB11:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$16, %rsp
	leaq	n(%rip), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -16(%rbp)
	jmp	.L24
.L25:
	movl	-16(%rbp), %eax
	cltq
	salq	$4, %rax
	movq	%rax, %rdx
	leaq	foo(%rip), %rax
	addq	%rdx, %rax
	leaq	8(%rax), %rdx
	movl	-16(%rbp), %eax
	cltq
	salq	$4, %rax
	movq	%rax, %rcx
	leaq	foo(%rip), %rax
	addq	%rcx, %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -16(%rbp)
.L24:
	movl	n(%rip), %eax
	cmpl	%eax, -16(%rbp)
	jl	.L25
	movl	$0, -12(%rbp)
	movl	n(%rip), %eax
	movl	%eax, -8(%rbp)
	movl	n(%rip), %eax
	cltq
	leaq	comp(%rip), %rdx
	movq	%rdx, %rcx
	movl	$16, %edx
	movq	%rax, %rsi
	leaq	foo(%rip), %rax
	movq	%rax, %rdi
	call	qsort@PLT
	jmp	.L26
.L28:
	movl	-12(%rbp), %edx
	movl	-8(%rbp), %eax
	addl	%edx, %eax
	addl	$1, %eax
	movl	%eax, %edx
	shrl	$31, %edx
	addl	%edx, %eax
	sarl	%eax
	movl	%eax, -4(%rbp)
	movl	-4(%rbp), %eax
	movl	%eax, %edi
	call	canPut
	testl	%eax, %eax
	je	.L27
	movl	-4(%rbp), %eax
	movl	%eax, -12(%rbp)
	jmp	.L26
.L27:
	movl	-4(%rbp), %eax
	subl	$1, %eax
	movl	%eax, -8(%rbp)
.L26:
	movl	-12(%rbp), %eax
	cmpl	-8(%rbp), %eax
	jne	.L28
	movl	-12(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE11:
	.size	main, .-main
	.ident	"GCC: (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:
