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

```c
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define S(i) scanf("%d",i);

int n,D,tmp,d[500001],Q,q,memo[500001],now=1,ans[500001];

main() {
    S(&n)S(&D)
    tmp = D;
    rep(i,n) {
        S(&d[i])
        if (tmp*2 > d[i]) tmp = abs(tmp-d[i]);
        memo[i] = tmp;
    }
    for(int i=n;i>0;--i) {
        if (memo[i-1] >= now) ans[i] = 1;
        if (2*now > d[i]) now += d[i];
    }
    if (D >= now) ans[0] = 1;
    S(&Q)
    rep(i,Q) {
        S(&q)
        if (ans[q-1]) printf("YES ");
        else printf("NO ");
    }
}

```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	n
	.bss
	.align 4
	.type	n, @object
	.size	n, 4
n:
	.zero	4
	.globl	D
	.align 4
	.type	D, @object
	.size	D, 4
D:
	.zero	4
	.globl	tmp
	.align 4
	.type	tmp, @object
	.size	tmp, 4
tmp:
	.zero	4
	.globl	d
	.align 32
	.type	d, @object
	.size	d, 2000004
d:
	.zero	2000004
	.globl	Q
	.align 4
	.type	Q, @object
	.size	Q, 4
Q:
	.zero	4
	.globl	q
	.align 4
	.type	q, @object
	.size	q, 4
q:
	.zero	4
	.globl	memo
	.align 32
	.type	memo, @object
	.size	memo, 2000004
memo:
	.zero	2000004
	.globl	now
	.data
	.align 4
	.type	now, @object
	.size	now, 4
now:
	.long	1
	.globl	ans
	.bss
	.align 32
	.type	ans, @object
	.size	ans, 2000004
ans:
	.zero	2000004
	.section	.rodata
.LC0:
	.string	"%d"
.LC1:
	.string	"YES "
.LC2:
	.string	"NO "
	.text
	.globl	main
	.type	main, @function
main:
.LFB0:
	.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	scanf@PLT
	leaq	D(%rip), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	scanf@PLT
	movl	D(%rip), %eax
	movl	%eax, tmp(%rip)
	movl	$0, -12(%rbp)
	jmp	.L2
.L4:
	movl	-12(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	d(%rip), %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	scanf@PLT
	movl	tmp(%rip), %eax
	leal	(%rax,%rax), %ecx
	movl	-12(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	d(%rip), %rax
	movl	(%rdx,%rax), %eax
	cmpl	%eax, %ecx
	jle	.L3
	movl	tmp(%rip), %eax
	movl	-12(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	d(%rip), %rdx
	movl	(%rcx,%rdx), %edx
	subl	%edx, %eax
	movl	%eax, %edx
	negl	%edx
	cmovns	%edx, %eax
	movl	%eax, tmp(%rip)
.L3:
	movl	tmp(%rip), %eax
	movl	-12(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	memo(%rip), %rdx
	movl	%eax, (%rcx,%rdx)
	addl	$1, -12(%rbp)
.L2:
	movl	n(%rip), %eax
	cmpl	%eax, -12(%rbp)
	jl	.L4
	movl	n(%rip), %eax
	movl	%eax, -8(%rbp)
	jmp	.L5
.L8:
	movl	-8(%rbp), %eax
	subl	$1, %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	memo(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	now(%rip), %eax
	cmpl	%eax, %edx
	jl	.L6
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	ans(%rip), %rax
	movl	$1, (%rdx,%rax)
.L6:
	movl	now(%rip), %eax
	leal	(%rax,%rax), %ecx
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	d(%rip), %rax
	movl	(%rdx,%rax), %eax
	cmpl	%eax, %ecx
	jle	.L7
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	d(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	now(%rip), %eax
	addl	%edx, %eax
	movl	%eax, now(%rip)
.L7:
	subl	$1, -8(%rbp)
.L5:
	cmpl	$0, -8(%rbp)
	jg	.L8
	movl	D(%rip), %edx
	movl	now(%rip), %eax
	cmpl	%eax, %edx
	jl	.L9
	movl	$1, ans(%rip)
.L9:
	leaq	Q(%rip), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	scanf@PLT
	movl	$0, -4(%rbp)
	jmp	.L10
.L13:
	leaq	q(%rip), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	scanf@PLT
	movl	q(%rip), %eax
	subl	$1, %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	ans(%rip), %rax
	movl	(%rdx,%rax), %eax
	testl	%eax, %eax
	je	.L11
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	jmp	.L12
.L11:
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
.L12:
	addl	$1, -4(%rbp)
.L10:
	movl	Q(%rip), %eax
	cmpl	%eax, -4(%rbp)
	jl	.L13
	movl	$0, %eax
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.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
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d"
.LC1:
	.string	"YES "
.LC2:
	.string	"NO "
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB0:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	leaq	n(%rip), %rsi
	xorl	%eax, %eax
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	xorl	%r13d, %r13d
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	leaq	memo(%rip), %r12
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	leaq	.LC0(%rip), %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	movq	%rbp, %rdi
	leaq	d(%rip), %rbx
	movq	%rbx, %r14
	subq	$8, %rsp
	.cfi_def_cfa_offset 64
	call	scanf@PLT
	leaq	D(%rip), %rsi
	movq	%rbp, %rdi
	xorl	%eax, %eax
	call	scanf@PLT
	movl	D(%rip), %eax
	movl	n(%rip), %ecx
	movl	%eax, tmp(%rip)
	testl	%ecx, %ecx
	jle	.L3
	.p2align 4,,10
	.p2align 3
.L7:
	movq	%r14, %rsi
	movq	%rbp, %rdi
	xorl	%eax, %eax
	call	scanf@PLT
	movl	tmp(%rip), %eax
	movl	(%r14), %edx
	leal	(%rax,%rax), %ecx
	cmpl	%edx, %ecx
	jle	.L4
	subl	%edx, %eax
	movl	%eax, %edx
	negl	%edx
	cmovns	%edx, %eax
	movl	%eax, tmp(%rip)
.L4:
	movl	%eax, (%r12,%r13,4)
	movslq	n(%rip), %rax
	addq	$1, %r13
	addq	$4, %r14
	cmpl	%r13d, %eax
	jg	.L7
	movl	now(%rip), %edx
	testl	%eax, %eax
	jle	.L30
	xorl	%r8d, %r8d
	leaq	-4+memo(%rip), %rdi
	leaq	ans(%rip), %r9
	.p2align 4,,10
	.p2align 3
.L11:
	cmpl	%edx, (%rdi,%rax,4)
	jl	.L9
	movl	$1, (%r9,%rax,4)
.L9:
	movl	(%rbx,%rax,4), %ecx
	leal	(%rdx,%rdx), %esi
	cmpl	%ecx, %esi
	jle	.L10
	addl	%ecx, %edx
	movl	$1, %r8d
.L10:
	subq	$1, %rax
	testl	%eax, %eax
	jg	.L11
	movl	D(%rip), %eax
	testb	%r8b, %r8b
	je	.L3
	movl	%edx, now(%rip)
.L3:
	cmpl	now(%rip), %eax
	jl	.L12
	movl	$1, ans(%rip)
.L12:
	leaq	Q(%rip), %rsi
	movq	%rbp, %rdi
	xorl	%eax, %eax
	xorl	%ebx, %ebx
	call	scanf@PLT
	movl	Q(%rip), %edx
	leaq	ans(%rip), %r13
	leaq	q(%rip), %r12
	leaq	.LC2(%rip), %r15
	leaq	.LC1(%rip), %r14
	testl	%edx, %edx
	jle	.L19
	.p2align 4,,10
	.p2align 3
.L13:
	movq	%rbp, %rdi
	movq	%r12, %rsi
	xorl	%eax, %eax
	call	scanf@PLT
	movl	q(%rip), %eax
	movq	%r14, %rdi
	subl	$1, %eax
	cltq
	movl	0(%r13,%rax,4), %eax
	testl	%eax, %eax
	jne	.L28
	movq	%r15, %rdi
.L28:
	xorl	%eax, %eax
	addl	$1, %ebx
	call	printf@PLT
	cmpl	%ebx, Q(%rip)
	jg	.L13
.L19:
	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
.L30:
	.cfi_restore_state
	movl	D(%rip), %eax
	jmp	.L3
	.cfi_endproc
.LFE0:
	.size	main, .-main
	.globl	ans
	.bss
	.align 32
	.type	ans, @object
	.size	ans, 2000004
ans:
	.zero	2000004
	.globl	now
	.data
	.align 4
	.type	now, @object
	.size	now, 4
now:
	.long	1
	.globl	memo
	.bss
	.align 32
	.type	memo, @object
	.size	memo, 2000004
memo:
	.zero	2000004
	.globl	q
	.align 4
	.type	q, @object
	.size	q, 4
q:
	.zero	4
	.globl	Q
	.align 4
	.type	Q, @object
	.size	Q, 4
Q:
	.zero	4
	.globl	d
	.align 32
	.type	d, @object
	.size	d, 2000004
d:
	.zero	2000004
	.globl	tmp
	.align 4
	.type	tmp, @object
	.size	tmp, 4
tmp:
	.zero	4
	.globl	D
	.align 4
	.type	D, @object
	.size	D, 4
D:
	.zero	4
	.globl	n
	.align 4
	.type	n, @object
	.size	n, 4
n:
	.zero	4
	.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
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d"
.LC1:
	.string	"YES "
.LC2:
	.string	"NO "
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB0:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	leaq	n(%rip), %rsi
	xorl	%eax, %eax
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	xorl	%r13d, %r13d
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	leaq	memo(%rip), %r12
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	leaq	.LC0(%rip), %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	movq	%rbp, %rdi
	leaq	d(%rip), %rbx
	movq	%rbx, %r14
	subq	$8, %rsp
	.cfi_def_cfa_offset 64
	call	scanf@PLT
	leaq	D(%rip), %rsi
	movq	%rbp, %rdi
	xorl	%eax, %eax
	call	scanf@PLT
	movl	D(%rip), %eax
	movl	n(%rip), %ecx
	movl	%eax, tmp(%rip)
	testl	%ecx, %ecx
	jle	.L3
	.p2align 4,,10
	.p2align 3
.L7:
	movq	%r14, %rsi
	movq	%rbp, %rdi
	xorl	%eax, %eax
	call	scanf@PLT
	movl	tmp(%rip), %eax
	movl	(%r14), %edx
	leal	(%rax,%rax), %ecx
	cmpl	%edx, %ecx
	jle	.L4
	subl	%edx, %eax
	movl	%eax, %edx
	negl	%edx
	cmovns	%edx, %eax
	movl	%eax, tmp(%rip)
.L4:
	movl	%eax, (%r12,%r13,4)
	movslq	n(%rip), %rax
	addq	$1, %r13
	addq	$4, %r14
	cmpl	%r13d, %eax
	jg	.L7
	movl	now(%rip), %edx
	testl	%eax, %eax
	jle	.L30
	xorl	%r8d, %r8d
	leaq	-4+memo(%rip), %rdi
	leaq	ans(%rip), %r9
	.p2align 4,,10
	.p2align 3
.L11:
	cmpl	%edx, (%rdi,%rax,4)
	jl	.L9
	movl	$1, (%r9,%rax,4)
.L9:
	movl	(%rbx,%rax,4), %ecx
	leal	(%rdx,%rdx), %esi
	cmpl	%ecx, %esi
	jle	.L10
	addl	%ecx, %edx
	movl	$1, %r8d
.L10:
	subq	$1, %rax
	testl	%eax, %eax
	jg	.L11
	movl	D(%rip), %eax
	testb	%r8b, %r8b
	je	.L3
	movl	%edx, now(%rip)
.L3:
	cmpl	now(%rip), %eax
	jl	.L12
	movl	$1, ans(%rip)
.L12:
	leaq	Q(%rip), %rsi
	movq	%rbp, %rdi
	xorl	%eax, %eax
	xorl	%ebx, %ebx
	call	scanf@PLT
	movl	Q(%rip), %edx
	leaq	ans(%rip), %r13
	leaq	q(%rip), %r12
	leaq	.LC2(%rip), %r15
	leaq	.LC1(%rip), %r14
	testl	%edx, %edx
	jle	.L19
	.p2align 4,,10
	.p2align 3
.L13:
	movq	%rbp, %rdi
	movq	%r12, %rsi
	xorl	%eax, %eax
	call	scanf@PLT
	movl	q(%rip), %eax
	movq	%r14, %rdi
	subl	$1, %eax
	cltq
	movl	0(%r13,%rax,4), %eax
	testl	%eax, %eax
	jne	.L28
	movq	%r15, %rdi
.L28:
	xorl	%eax, %eax
	addl	$1, %ebx
	call	printf@PLT
	cmpl	%ebx, Q(%rip)
	jg	.L13
.L19:
	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
.L30:
	.cfi_restore_state
	movl	D(%rip), %eax
	jmp	.L3
	.cfi_endproc
.LFE0:
	.size	main, .-main
	.globl	ans
	.bss
	.align 32
	.type	ans, @object
	.size	ans, 2000004
ans:
	.zero	2000004
	.globl	now
	.data
	.align 4
	.type	now, @object
	.size	now, 4
now:
	.long	1
	.globl	memo
	.bss
	.align 32
	.type	memo, @object
	.size	memo, 2000004
memo:
	.zero	2000004
	.globl	q
	.align 4
	.type	q, @object
	.size	q, 4
q:
	.zero	4
	.globl	Q
	.align 4
	.type	Q, @object
	.size	Q, 4
Q:
	.zero	4
	.globl	d
	.align 32
	.type	d, @object
	.size	d, 2000004
d:
	.zero	2000004
	.globl	tmp
	.align 4
	.type	tmp, @object
	.size	tmp, 4
tmp:
	.zero	4
	.globl	D
	.align 4
	.type	D, @object
	.size	D, 4
D:
	.zero	4
	.globl	n
	.align 4
	.type	n, @object
	.size	n, 4
n:
	.zero	4
	.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:

#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define S(i) scanf("%d",i);

int n,D,tmp,d[500001],Q,q,memo[500001],now=1,ans[500001];

main() {
    S(&n)S(&D)
    tmp = D;
    rep(i,n) {
        S(&d[i])
        if (tmp*2 > d[i]) tmp = abs(tmp-d[i]);
        memo[i] = tmp;
    }
    for(int i=n;i>0;--i) {
        if (memo[i-1] >= now) ans[i] = 1;
        if (2*now > d[i]) now += d[i];
    }
    if (D >= now) ans[0] = 1;
    S(&Q)
    rep(i,Q) {
        S(&q)
        if (ans[q-1]) printf("YES ");
        else printf("NO ");
    }
}


5 9
4 4 2 3 4
5
1 4 2 3 5
 6 15
4 3 5 4 2 1
6
1 2 3 0 5 6
 6 15
4 3 5 4 2 1
6
1 2 4 0 5 6
 6 15
4 3 5 4 0 1
6
1 2 3 4 5 6
 4 10
3 2 3 3
2
4 3
 6 15
4 3 5 4 2 1
6
1 3 3 0 5 6
 6 15
4 3 5 4 0 1
6
2 2 4 0 5 6
 6 15
4 3 5 3 0 1
6
0 2 4 0 5 6
 6 15
4 1 5 4 2 1
6
1 2 3 4 5 6
 6 15
4 3 5 4 0 1
6
1 2 1 4 4 6

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

```c
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define S(i) scanf("%d",i);

int n,D,tmp,d[500001],Q,q,memo[500001],now=1,ans[500001];

main() {
    S(&n)S(&D)
    tmp = D;
    rep(i,n) {
        S(&d[i])
        if (tmp*2 > d[i]) tmp = abs(tmp-d[i]);
        memo[i] = tmp;
    }
    for(int i=n;i>0;--i) {
        if (memo[i-1] >= now) ans[i] = 1;
        if (2*now > d[i]) now += d[i];
    }
    if (D >= now) ans[0] = 1;
    S(&Q)
    rep(i,Q) {
        S(&q)
        if (ans[q-1]) printf("YES ");
        else printf("NO ");
    }
}

```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	n
	.bss
	.align 4
	.type	n, @object
	.size	n, 4
n:
	.zero	4
	.globl	D
	.align 4
	.type	D, @object
	.size	D, 4
D:
	.zero	4
	.globl	tmp
	.align 4
	.type	tmp, @object
	.size	tmp, 4
tmp:
	.zero	4
	.globl	d
	.align 32
	.type	d, @object
	.size	d, 2000004
d:
	.zero	2000004
	.globl	Q
	.align 4
	.type	Q, @object
	.size	Q, 4
Q:
	.zero	4
	.globl	q
	.align 4
	.type	q, @object
	.size	q, 4
q:
	.zero	4
	.globl	memo
	.align 32
	.type	memo, @object
	.size	memo, 2000004
memo:
	.zero	2000004
	.globl	now
	.data
	.align 4
	.type	now, @object
	.size	now, 4
now:
	.long	1
	.globl	ans
	.bss
	.align 32
	.type	ans, @object
	.size	ans, 2000004
ans:
	.zero	2000004
	.section	.rodata
.LC0:
	.string	"%d"
.LC1:
	.string	"YES "
.LC2:
	.string	"NO "
	.text
	.globl	main
	.type	main, @function
main:
.LFB0:
	.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	scanf@PLT
	leaq	D(%rip), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	scanf@PLT
	movl	D(%rip), %eax
	movl	%eax, tmp(%rip)
	movl	$0, -12(%rbp)
	jmp	.L2
.L4:
	movl	-12(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	d(%rip), %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	scanf@PLT
	movl	tmp(%rip), %eax
	leal	(%rax,%rax), %ecx
	movl	-12(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	d(%rip), %rax
	movl	(%rdx,%rax), %eax
	cmpl	%eax, %ecx
	jle	.L3
	movl	tmp(%rip), %eax
	movl	-12(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	d(%rip), %rdx
	movl	(%rcx,%rdx), %edx
	subl	%edx, %eax
	movl	%eax, %edx
	negl	%edx
	cmovns	%edx, %eax
	movl	%eax, tmp(%rip)
.L3:
	movl	tmp(%rip), %eax
	movl	-12(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	memo(%rip), %rdx
	movl	%eax, (%rcx,%rdx)
	addl	$1, -12(%rbp)
.L2:
	movl	n(%rip), %eax
	cmpl	%eax, -12(%rbp)
	jl	.L4
	movl	n(%rip), %eax
	movl	%eax, -8(%rbp)
	jmp	.L5
.L8:
	movl	-8(%rbp), %eax
	subl	$1, %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	memo(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	now(%rip), %eax
	cmpl	%eax, %edx
	jl	.L6
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	ans(%rip), %rax
	movl	$1, (%rdx,%rax)
.L6:
	movl	now(%rip), %eax
	leal	(%rax,%rax), %ecx
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	d(%rip), %rax
	movl	(%rdx,%rax), %eax
	cmpl	%eax, %ecx
	jle	.L7
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	d(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	now(%rip), %eax
	addl	%edx, %eax
	movl	%eax, now(%rip)
.L7:
	subl	$1, -8(%rbp)
.L5:
	cmpl	$0, -8(%rbp)
	jg	.L8
	movl	D(%rip), %edx
	movl	now(%rip), %eax
	cmpl	%eax, %edx
	jl	.L9
	movl	$1, ans(%rip)
.L9:
	leaq	Q(%rip), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	scanf@PLT
	movl	$0, -4(%rbp)
	jmp	.L10
.L13:
	leaq	q(%rip), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	scanf@PLT
	movl	q(%rip), %eax
	subl	$1, %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	ans(%rip), %rax
	movl	(%rdx,%rax), %eax
	testl	%eax, %eax
	je	.L11
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	jmp	.L12
.L11:
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
.L12:
	addl	$1, -4(%rbp)
.L10:
	movl	Q(%rip), %eax
	cmpl	%eax, -4(%rbp)
	jl	.L13
	movl	$0, %eax
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.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	n
	.bss
	.align 4
	.type	n, @object
	.size	n, 4
n:
	.zero	4
	.globl	D
	.align 4
	.type	D, @object
	.size	D, 4
D:
	.zero	4
	.globl	tmp
	.align 4
	.type	tmp, @object
	.size	tmp, 4
tmp:
	.zero	4
	.globl	d
	.align 32
	.type	d, @object
	.size	d, 2000004
d:
	.zero	2000004
	.globl	Q
	.align 4
	.type	Q, @object
	.size	Q, 4
Q:
	.zero	4
	.globl	q
	.align 4
	.type	q, @object
	.size	q, 4
q:
	.zero	4
	.globl	memo
	.align 32
	.type	memo, @object
	.size	memo, 2000004
memo:
	.zero	2000004
	.globl	now
	.data
	.align 4
	.type	now, @object
	.size	now, 4
now:
	.long	1
	.globl	ans
	.bss
	.align 32
	.type	ans, @object
	.size	ans, 2000004
ans:
	.zero	2000004
	.section	.rodata
.LC0:
	.string	"%d"
.LC1:
	.string	"YES "
.LC2:
	.string	"NO "
	.text
	.globl	main
	.type	main, @function
main:
.LFB0:
	.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	scanf@PLT
	leaq	D(%rip), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	scanf@PLT
	movl	D(%rip), %eax
	movl	%eax, tmp(%rip)
	movl	$0, -12(%rbp)
	jmp	.L2
.L4:
	movl	-12(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	d(%rip), %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	scanf@PLT
	movl	tmp(%rip), %eax
	leal	(%rax,%rax), %ecx
	movl	-12(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	d(%rip), %rax
	movl	(%rdx,%rax), %eax
	cmpl	%eax, %ecx
	jle	.L3
	movl	tmp(%rip), %eax
	movl	-12(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	d(%rip), %rdx
	movl	(%rcx,%rdx), %edx
	subl	%edx, %eax
	movl	%eax, %edx
	negl	%edx
	cmovns	%edx, %eax
	movl	%eax, tmp(%rip)
.L3:
	movl	tmp(%rip), %eax
	movl	-12(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	memo(%rip), %rdx
	movl	%eax, (%rcx,%rdx)
	addl	$1, -12(%rbp)
.L2:
	movl	n(%rip), %eax
	cmpl	%eax, -12(%rbp)
	jl	.L4
	movl	n(%rip), %eax
	movl	%eax, -8(%rbp)
	jmp	.L5
.L8:
	movl	-8(%rbp), %eax
	subl	$1, %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	memo(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	now(%rip), %eax
	cmpl	%eax, %edx
	jl	.L6
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	ans(%rip), %rax
	movl	$1, (%rdx,%rax)
.L6:
	movl	now(%rip), %eax
	leal	(%rax,%rax), %ecx
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	d(%rip), %rax
	movl	(%rdx,%rax), %eax
	cmpl	%eax, %ecx
	jle	.L7
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	d(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	now(%rip), %eax
	addl	%edx, %eax
	movl	%eax, now(%rip)
.L7:
	subl	$1, -8(%rbp)
.L5:
	cmpl	$0, -8(%rbp)
	jg	.L8
	movl	D(%rip), %edx
	movl	now(%rip), %eax
	cmpl	%eax, %edx
	jl	.L9
	movl	$1, ans(%rip)
.L9:
	leaq	Q(%rip), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	scanf@PLT
	movl	$0, -4(%rbp)
	jmp	.L10
.L13:
	leaq	q(%rip), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	scanf@PLT
	movl	q(%rip), %eax
	subl	$1, %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	ans(%rip), %rax
	movl	(%rdx,%rax), %eax
	testl	%eax, %eax
	je	.L11
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	jmp	.L12
.L11:
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
.L12:
	addl	$1, -4(%rbp)
.L10:
	movl	Q(%rip), %eax
	cmpl	%eax, -4(%rbp)
	jl	.L13
	movl	$0, %eax
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.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:
