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

```c
// AOJ 0615 Cake 2
// 2018.2.27 bal4u

#include <stdio.h>

int n;
int a[2002];
long long memo[2002][2002];

//#define getchar_unlocked()  getchar()
int in()
{
	int n = 0;
	int c = getchar_unlocked();
	do n = 10*n + (c & 0xf), c = getchar_unlocked();
	while (c >= '0');
	return n;
}

long long calc(int l, int r, int s)
{
	int nl, nr;
	long long k, k2;

	if (memo[l][r]) return memo[l][r];
	if (l == r) {
		if (s) return memo[l][r] = 1;
		return memo[l][r] = a[l] + 1;
	}
	nl = l+1; if (nl == n) nl = 0;
	nr = r-1+n; if (nr >= n) nr -= n;
	if (s) {
		if (a[l] > a[r]) return memo[l][r] = calc(nl, r, 0);
		else             return memo[l][r] = calc(l, nr, 0);
	}
	k  = calc(nl, r, 1) + a[l];
	k2 = calc(l, nr, 1) + a[r];
	if (k2 > k) k = k2;
	return memo[l][r] = k;
}

int main()
{
	int i, i1, i2;
	long long k, ans;

	n = in();
	for (i = 0; i < n; i++) a[i] = in();
	a[n] = a[0];

	ans = 0;
	i1 = 1, i2 = n-1; for (i = 0; i < n; i++) {
		if (i1 == n) i1 = 0;
		if (i2 == n) i2 = 0;
		k = calc(i1, i2, 1) + a[i] - 1;
		if (k > ans) ans = k;
		i1++, i2++;
	}
	printf("%lld\n", ans);
	return 0;
}
```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	n
	.bss
	.align 4
	.type	n, @object
	.size	n, 4
n:
	.zero	4
	.globl	a
	.align 32
	.type	a, @object
	.size	a, 8008
a:
	.zero	8008
	.globl	memo
	.align 32
	.type	memo, @object
	.size	memo, 32064032
memo:
	.zero	32064032
	.text
	.globl	in
	.type	in, @function
in:
.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
	movl	$0, -8(%rbp)
	call	getchar_unlocked@PLT
	movl	%eax, -4(%rbp)
.L2:
	movl	-8(%rbp), %edx
	movl	%edx, %eax
	sall	$2, %eax
	addl	%edx, %eax
	addl	%eax, %eax
	movl	%eax, %edx
	movl	-4(%rbp), %eax
	andl	$15, %eax
	addl	%edx, %eax
	movl	%eax, -8(%rbp)
	call	getchar_unlocked@PLT
	movl	%eax, -4(%rbp)
	cmpl	$47, -4(%rbp)
	jg	.L2
	movl	-8(%rbp), %eax
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	in, .-in
	.globl	calc
	.type	calc, @function
calc:
.LFB1:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$48, %rsp
	movl	%edi, -36(%rbp)
	movl	%esi, -40(%rbp)
	movl	%edx, -44(%rbp)
	movl	-40(%rbp), %eax
	movslq	%eax, %rdx
	movl	-36(%rbp), %eax
	cltq
	imulq	$2002, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,8), %rdx
	leaq	memo(%rip), %rax
	movq	(%rdx,%rax), %rax
	testq	%rax, %rax
	je	.L5
	movl	-40(%rbp), %eax
	movslq	%eax, %rdx
	movl	-36(%rbp), %eax
	cltq
	imulq	$2002, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,8), %rdx
	leaq	memo(%rip), %rax
	movq	(%rdx,%rax), %rax
	jmp	.L6
.L5:
	movl	-36(%rbp), %eax
	cmpl	-40(%rbp), %eax
	jne	.L7
	cmpl	$0, -44(%rbp)
	je	.L8
	movl	-40(%rbp), %eax
	movslq	%eax, %rdx
	movl	-36(%rbp), %eax
	cltq
	imulq	$2002, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,8), %rdx
	leaq	memo(%rip), %rax
	movq	$1, (%rdx,%rax)
	movl	-40(%rbp), %eax
	movslq	%eax, %rdx
	movl	-36(%rbp), %eax
	cltq
	imulq	$2002, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,8), %rdx
	leaq	memo(%rip), %rax
	movq	(%rdx,%rax), %rax
	jmp	.L6
.L8:
	movl	-36(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	a(%rip), %rax
	movl	(%rdx,%rax), %eax
	addl	$1, %eax
	cltq
	movl	-40(%rbp), %edx
	movslq	%edx, %rcx
	movl	-36(%rbp), %edx
	movslq	%edx, %rdx
	imulq	$2002, %rdx, %rdx
	addq	%rcx, %rdx
	leaq	0(,%rdx,8), %rcx
	leaq	memo(%rip), %rdx
	movq	%rax, (%rcx,%rdx)
	movl	-40(%rbp), %eax
	movslq	%eax, %rdx
	movl	-36(%rbp), %eax
	cltq
	imulq	$2002, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,8), %rdx
	leaq	memo(%rip), %rax
	movq	(%rdx,%rax), %rax
	jmp	.L6
.L7:
	movl	-36(%rbp), %eax
	addl	$1, %eax
	movl	%eax, -24(%rbp)
	movl	n(%rip), %eax
	cmpl	%eax, -24(%rbp)
	jne	.L9
	movl	$0, -24(%rbp)
.L9:
	movl	-40(%rbp), %eax
	leal	-1(%rax), %edx
	movl	n(%rip), %eax
	addl	%edx, %eax
	movl	%eax, -20(%rbp)
	movl	n(%rip), %eax
	cmpl	%eax, -20(%rbp)
	jl	.L10
	movl	n(%rip), %eax
	subl	%eax, -20(%rbp)
.L10:
	cmpl	$0, -44(%rbp)
	je	.L11
	movl	-36(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	a(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	-40(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	a(%rip), %rax
	movl	(%rcx,%rax), %eax
	cmpl	%eax, %edx
	jle	.L12
	movl	-40(%rbp), %ecx
	movl	-24(%rbp), %eax
	movl	$0, %edx
	movl	%ecx, %esi
	movl	%eax, %edi
	call	calc
	movl	-40(%rbp), %edx
	movslq	%edx, %rcx
	movl	-36(%rbp), %edx
	movslq	%edx, %rdx
	imulq	$2002, %rdx, %rdx
	addq	%rcx, %rdx
	leaq	0(,%rdx,8), %rcx
	leaq	memo(%rip), %rdx
	movq	%rax, (%rcx,%rdx)
	movl	-40(%rbp), %eax
	movslq	%eax, %rdx
	movl	-36(%rbp), %eax
	cltq
	imulq	$2002, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,8), %rdx
	leaq	memo(%rip), %rax
	movq	(%rdx,%rax), %rax
	jmp	.L6
.L12:
	movl	-20(%rbp), %ecx
	movl	-36(%rbp), %eax
	movl	$0, %edx
	movl	%ecx, %esi
	movl	%eax, %edi
	call	calc
	movl	-40(%rbp), %edx
	movslq	%edx, %rcx
	movl	-36(%rbp), %edx
	movslq	%edx, %rdx
	imulq	$2002, %rdx, %rdx
	addq	%rcx, %rdx
	leaq	0(,%rdx,8), %rcx
	leaq	memo(%rip), %rdx
	movq	%rax, (%rcx,%rdx)
	movl	-40(%rbp), %eax
	movslq	%eax, %rdx
	movl	-36(%rbp), %eax
	cltq
	imulq	$2002, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,8), %rdx
	leaq	memo(%rip), %rax
	movq	(%rdx,%rax), %rax
	jmp	.L6
.L11:
	movl	-40(%rbp), %ecx
	movl	-24(%rbp), %eax
	movl	$1, %edx
	movl	%ecx, %esi
	movl	%eax, %edi
	call	calc
	movq	%rax, %rcx
	movl	-36(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	a(%rip), %rax
	movl	(%rdx,%rax), %eax
	cltq
	addq	%rcx, %rax
	movq	%rax, -16(%rbp)
	movl	-20(%rbp), %ecx
	movl	-36(%rbp), %eax
	movl	$1, %edx
	movl	%ecx, %esi
	movl	%eax, %edi
	call	calc
	movq	%rax, %rcx
	movl	-40(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	a(%rip), %rax
	movl	(%rdx,%rax), %eax
	cltq
	addq	%rcx, %rax
	movq	%rax, -8(%rbp)
	movq	-8(%rbp), %rax
	cmpq	-16(%rbp), %rax
	jle	.L13
	movq	-8(%rbp), %rax
	movq	%rax, -16(%rbp)
.L13:
	movl	-40(%rbp), %eax
	movslq	%eax, %rdx
	movl	-36(%rbp), %eax
	cltq
	imulq	$2002, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,8), %rcx
	leaq	memo(%rip), %rdx
	movq	-16(%rbp), %rax
	movq	%rax, (%rcx,%rdx)
	movl	-40(%rbp), %eax
	movslq	%eax, %rdx
	movl	-36(%rbp), %eax
	cltq
	imulq	$2002, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,8), %rdx
	leaq	memo(%rip), %rax
	movq	(%rdx,%rax), %rax
.L6:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE1:
	.size	calc, .-calc
	.section	.rodata
.LC0:
	.string	"%lld\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB2:
	.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	$0, %eax
	call	in
	movl	%eax, n(%rip)
	movl	$0, -28(%rbp)
	jmp	.L15
.L16:
	movl	$0, %eax
	call	in
	movl	-28(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	a(%rip), %rdx
	movl	%eax, (%rcx,%rdx)
	addl	$1, -28(%rbp)
.L15:
	movl	n(%rip), %eax
	cmpl	%eax, -28(%rbp)
	jl	.L16
	movl	n(%rip), %edx
	movl	a(%rip), %eax
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	a(%rip), %rdx
	movl	%eax, (%rcx,%rdx)
	movq	$0, -16(%rbp)
	movl	$1, -24(%rbp)
	movl	n(%rip), %eax
	subl	$1, %eax
	movl	%eax, -20(%rbp)
	movl	$0, -28(%rbp)
	jmp	.L17
.L21:
	movl	n(%rip), %eax
	cmpl	%eax, -24(%rbp)
	jne	.L18
	movl	$0, -24(%rbp)
.L18:
	movl	n(%rip), %eax
	cmpl	%eax, -20(%rbp)
	jne	.L19
	movl	$0, -20(%rbp)
.L19:
	movl	-20(%rbp), %ecx
	movl	-24(%rbp), %eax
	movl	$1, %edx
	movl	%ecx, %esi
	movl	%eax, %edi
	call	calc
	movq	%rax, %rcx
	movl	-28(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	a(%rip), %rax
	movl	(%rdx,%rax), %eax
	cltq
	addq	%rcx, %rax
	subq	$1, %rax
	movq	%rax, -8(%rbp)
	movq	-8(%rbp), %rax
	cmpq	-16(%rbp), %rax
	jle	.L20
	movq	-8(%rbp), %rax
	movq	%rax, -16(%rbp)
.L20:
	addl	$1, -24(%rbp)
	addl	$1, -20(%rbp)
	addl	$1, -28(%rbp)
.L17:
	movl	n(%rip), %eax
	cmpl	%eax, -28(%rbp)
	jl	.L21
	movq	-16(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE2:
	.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	in
	.type	in, @function
in:
.LFB23:
	.cfi_startproc
	endbr64
	movq	stdin(%rip), %rdi
	pushq	%r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	movq	8(%rdi), %rax
	movq	16(%rdi), %rcx
	cmpq	%rcx, %rax
	jnb	.L11
	leaq	1(%rax), %rdx
	movq	%rdx, 8(%rdi)
	movzbl	(%rax), %eax
.L3:
	xorl	%r12d, %r12d
	jmp	.L7
	.p2align 4,,10
	.p2align 3
.L4:
	leaq	1(%rdx), %rax
	movq	%rax, 8(%rdi)
	movzbl	(%rdx), %eax
	cmpl	$47, %eax
	jle	.L1
.L5:
	movq	8(%rdi), %rdx
	movq	16(%rdi), %rcx
.L7:
	leal	(%r12,%r12,4), %esi
	andl	$15, %eax
	leal	(%rax,%rsi,2), %r12d
	cmpq	%rcx, %rdx
	jb	.L4
	call	__uflow@PLT
	cmpl	$47, %eax
	jle	.L1
	movq	stdin(%rip), %rdi
	jmp	.L5
	.p2align 4,,10
	.p2align 3
.L1:
	movl	%r12d, %eax
	popq	%r12
	.cfi_remember_state
	.cfi_def_cfa_offset 8
	ret
	.p2align 4,,10
	.p2align 3
.L11:
	.cfi_restore_state
	call	__uflow@PLT
	movq	stdin(%rip), %rdi
	movq	8(%rdi), %rdx
	movq	16(%rdi), %rcx
	jmp	.L3
	.cfi_endproc
.LFE23:
	.size	in, .-in
	.p2align 4
	.globl	calc
	.type	calc, @function
calc:
.LFB24:
	.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
	movslq	%edi, %r13
	movl	%edx, %edi
	imulq	$2002, %r13, %r9
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	movslq	%esi, %r12
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	leaq	memo(%rip), %rbx
	leaq	(%r9,%r12), %rdx
	subq	$24, %rsp
	.cfi_def_cfa_offset 80
	movq	(%rbx,%rdx,8), %rax
	testq	%rax, %rax
	jne	.L12
	movq	%r13, %rbp
	cmpl	%esi, %r13d
	je	.L35
	movl	n(%rip), %r8d
	leal	1(%r13), %r14d
	xorl	%ecx, %ecx
	cmpl	%r8d, %r14d
	cmove	%ecx, %r14d
	leal	-1(%rsi), %ecx
	leal	(%r8,%rcx), %r15d
	cmpl	%r15d, %r8d
	cmovle	%ecx, %r15d
	testl	%edi, %edi
	je	.L18
	leaq	a(%rip), %rdx
	movl	(%rdx,%r13,4), %ecx
	cmpl	(%rdx,%r12,4), %ecx
	jg	.L36
	movslq	%r15d, %rdx
	leaq	(%r9,%rdx), %rax
	movq	(%rbx,%rax,8), %rax
	testq	%rax, %rax
	jne	.L34
	cmpl	%r15d, %r13d
	je	.L37
	xorl	%edx, %edx
	movl	%r15d, %esi
	movl	%r13d, %edi
	call	calc.part.0
	.p2align 4,,10
	.p2align 3
.L34:
	imulq	$2002, %r13, %rdx
	addq	%r12, %rdx
	movq	%rax, (%rbx,%rdx,8)
.L12:
	addq	$24, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 56
	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
.L35:
	.cfi_restore_state
	testl	%edi, %edi
	je	.L15
	imulq	$2003, %r12, %r12
	movl	$1, %eax
	movq	$1, (%rbx,%r12,8)
	addq	$24, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 56
	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
.L36:
	.cfi_restore_state
	movslq	%r14d, %rdi
	imulq	$2002, %rdi, %rcx
	leaq	(%rcx,%r12), %rax
	movq	(%rbx,%rax,8), %rax
	testq	%rax, %rax
	jne	.L34
	cmpl	%r14d, %esi
	je	.L38
	xorl	%edx, %edx
	movl	%r14d, %edi
	call	calc.part.0
	jmp	.L34
	.p2align 4,,10
	.p2align 3
.L15:
	leaq	a(%rip), %rax
	movl	(%rax,%r12,4), %eax
	imulq	$2003, %r12, %r12
	addl	$1, %eax
	cltq
	movq	%rax, (%rbx,%r12,8)
	addq	$24, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 56
	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
.L18:
	.cfi_restore_state
	movslq	%r14d, %r10
	leaq	a(%rip), %r9
	imulq	$2002, %r10, %rdx
	leaq	(%rdx,%r12), %rcx
	movq	(%rbx,%rcx,8), %rax
	testq	%rax, %rax
	jne	.L24
	cmpl	%r14d, %esi
	je	.L39
	leal	1(%r14), %r11d
	movl	(%r9,%r12,4), %eax
	movq	%rcx, 8(%rsp)
	movl	$0, %edx
	cmpl	%r11d, %r8d
	movl	%r8d, (%rsp)
	cmove	%edi, %r11d
	cmpl	%eax, (%r9,%r10,4)
	jle	.L27
	movl	%r11d, %edi
	call	calc
	movq	8(%rsp), %rcx
	movl	(%rsp), %r8d
	leaq	a(%rip), %r9
	movq	%rax, (%rbx,%rcx,8)
.L24:
	movslq	(%r9,%r13,4), %rcx
	imulq	$2002, %r13, %r10
	movq	%rcx, %rsi
	addq	%rax, %rcx
	movslq	%r15d, %rax
	addq	%rax, %r10
	movq	(%rbx,%r10,8), %rdx
	testq	%rdx, %rdx
	jne	.L28
	cmpl	%r15d, %ebp
	je	.L40
	leal	-1(%r15), %edx
	movq	%r10, 8(%rsp)
	leal	(%r8,%rdx), %r11d
	movq	%rcx, (%rsp)
	cmpl	%r11d, %r8d
	cmovle	%edx, %r11d
	cmpl	(%r9,%rax,4), %esi
	movl	$0, %edx
	jle	.L31
	movl	%r15d, %esi
	movl	%r14d, %edi
	call	calc
	movq	8(%rsp), %r10
	movq	(%rsp), %rcx
	leaq	a(%rip), %r9
	movq	%rax, %rdx
	movq	%rax, (%rbx,%r10,8)
.L28:
	movslq	(%r9,%r12,4), %rax
	addq	%rdx, %rax
	cmpq	%rcx, %rax
	cmovl	%rcx, %rax
	jmp	.L34
	.p2align 4,,10
	.p2align 3
.L31:
	movl	%r11d, %esi
	movl	%ebp, %edi
	call	calc
	movq	8(%rsp), %r10
	movq	(%rsp), %rcx
	leaq	a(%rip), %r9
	movq	%rax, %rdx
	movq	%rax, (%rbx,%r10,8)
	jmp	.L28
	.p2align 4,,10
	.p2align 3
.L27:
	movl	%r15d, %esi
	movl	%r14d, %edi
	call	calc
	movq	8(%rsp), %rcx
	movl	(%rsp), %r8d
	leaq	a(%rip), %r9
	movq	%rax, (%rbx,%rcx,8)
	jmp	.L24
	.p2align 4,,10
	.p2align 3
.L38:
	movl	(%rdx,%rdi,4), %eax
	addq	%rdi, %rcx
	addl	$1, %eax
	cltq
	movq	%rax, (%rbx,%rcx,8)
	jmp	.L34
	.p2align 4,,10
	.p2align 3
.L37:
	imulq	$2003, %rdx, %rdx
	addl	$1, %ecx
	movslq	%ecx, %rax
	movq	%rax, (%rbx,%rdx,8)
	jmp	.L34
	.p2align 4,,10
	.p2align 3
.L40:
	imulq	$2003, %rax, %rax
	movl	$1, %edx
	movq	$1, (%rbx,%rax,8)
	jmp	.L28
	.p2align 4,,10
	.p2align 3
.L39:
	addq	%r10, %rdx
	movl	$1, %eax
	movq	$1, (%rbx,%rdx,8)
	jmp	.L24
	.cfi_endproc
.LFE24:
	.size	calc, .-calc
	.p2align 4
	.type	calc.part.0, @function
calc.part.0:
.LFB26:
	.cfi_startproc
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	movl	%edx, %eax
	xorl	%edx, %edx
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	leal	1(%rdi), %r14d
	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
	movl	%edi, %ebp
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$24, %rsp
	.cfi_def_cfa_offset 80
	movl	n(%rip), %ecx
	cmpl	%ecx, %r14d
	cmove	%edx, %r14d
	leal	-1(%rsi), %edx
	leal	(%rcx,%rdx), %r15d
	cmpl	%r15d, %ecx
	cmovle	%edx, %r15d
	testl	%eax, %eax
	je	.L44
	leaq	a(%rip), %rdx
	movslq	%edi, %rbx
	movslq	%esi, %r13
	movl	(%rdx,%rbx,4), %ecx
	leaq	memo(%rip), %r12
	cmpl	(%rdx,%r13,4), %ecx
	jle	.L45
	movslq	%r14d, %rdi
	imulq	$2002, %rdi, %rcx
	leaq	(%rcx,%r13), %rax
	movq	(%r12,%rax,8), %rax
	testq	%rax, %rax
	jne	.L48
	cmpl	%r14d, %esi
	je	.L61
	xorl	%edx, %edx
	movl	%r14d, %edi
	call	calc.part.0
.L48:
	imulq	$2002, %rbx, %rbx
	addq	%r13, %rbx
	movq	%rax, (%r12,%rbx,8)
	addq	$24, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 56
	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
.L45:
	.cfi_restore_state
	imulq	$2002, %rbx, %rax
	movslq	%r15d, %rdx
	addq	%rdx, %rax
	movq	(%r12,%rax,8), %rax
	testq	%rax, %rax
	jne	.L48
	cmpl	%r15d, %edi
	je	.L62
	xorl	%edx, %edx
	movl	%r15d, %esi
	call	calc.part.0
	jmp	.L48
	.p2align 4,,10
	.p2align 3
.L44:
	movslq	%r14d, %r8
	movslq	%esi, %r13
	leaq	memo(%rip), %r12
	imulq	$2002, %r8, %rdi
	leaq	a(%rip), %r9
	leaq	(%rdi,%r13), %rbx
	movq	(%r12,%rbx,8), %rdx
	testq	%rdx, %rdx
	jne	.L51
	cmpl	%r14d, %esi
	je	.L63
	leal	1(%r14), %edi
	movl	%ecx, (%rsp)
	movl	$0, %edx
	cmpl	%edi, %ecx
	cmove	%eax, %edi
	movl	(%r9,%r13,4), %eax
	cmpl	%eax, (%r9,%r8,4)
	jle	.L54
	call	calc
	movl	(%rsp), %ecx
	leaq	a(%rip), %r9
	movq	%rax, (%r12,%rbx,8)
	movq	%rax, %rdx
.L51:
	movslq	%ebp, %rbx
	movslq	%r15d, %rax
	imulq	$2002, %rbx, %r10
	movslq	(%r9,%rbx,4), %r8
	movq	%r8, %rsi
	addq	%rdx, %r8
	addq	%rax, %r10
	movq	(%r12,%r10,8), %rdx
	testq	%rdx, %rdx
	jne	.L55
	cmpl	%r15d, %ebp
	je	.L64
	leal	-1(%r15), %edx
	movq	%r10, 8(%rsp)
	leal	(%rcx,%rdx), %r11d
	movq	%r8, (%rsp)
	cmpl	%r11d, %ecx
	cmovle	%edx, %r11d
	cmpl	(%r9,%rax,4), %esi
	movl	$0, %edx
	jle	.L58
	movl	%r15d, %esi
	movl	%r14d, %edi
	call	calc
	movq	8(%rsp), %r10
	movq	(%rsp), %r8
	leaq	a(%rip), %r9
	movq	%rax, %rdx
	movq	%rax, (%r12,%r10,8)
.L55:
	movslq	(%r9,%r13,4), %rax
	addq	%rdx, %rax
	cmpq	%r8, %rax
	cmovl	%r8, %rax
	jmp	.L48
	.p2align 4,,10
	.p2align 3
.L61:
	movl	(%rdx,%rdi,4), %eax
	addq	%rdi, %rcx
	addl	$1, %eax
	cltq
	movq	%rax, (%r12,%rcx,8)
	jmp	.L48
	.p2align 4,,10
	.p2align 3
.L62:
	imulq	$2003, %rdx, %rdx
	addl	$1, %ecx
	movslq	%ecx, %rax
	movq	%rax, (%r12,%rdx,8)
	jmp	.L48
	.p2align 4,,10
	.p2align 3
.L64:
	imulq	$2003, %rax, %rax
	movl	$1, %edx
	movq	$1, (%r12,%rax,8)
	jmp	.L55
	.p2align 4,,10
	.p2align 3
.L63:
	addq	%r8, %rdi
	movl	$1, %edx
	movq	$1, (%r12,%rdi,8)
	jmp	.L51
	.p2align 4,,10
	.p2align 3
.L54:
	movl	%r15d, %esi
	movl	%r14d, %edi
	call	calc
	movl	(%rsp), %ecx
	leaq	a(%rip), %r9
	movq	%rax, (%r12,%rbx,8)
	movq	%rax, %rdx
	jmp	.L51
	.p2align 4,,10
	.p2align 3
.L58:
	movl	%r11d, %esi
	movl	%ebp, %edi
	call	calc
	movq	8(%rsp), %r10
	movq	(%rsp), %r8
	leaq	a(%rip), %r9
	movq	%rax, %rdx
	movq	%rax, (%r12,%r10,8)
	jmp	.L55
	.cfi_endproc
.LFE26:
	.size	calc.part.0, .-calc.part.0
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%lld\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB25:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	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
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$72, %rsp
	.cfi_def_cfa_offset 128
	call	in
	movl	%eax, n(%rip)
	testl	%eax, %eax
	jle	.L66
	xorl	%ebp, %ebp
	.p2align 4,,10
	.p2align 3
.L73:
	movq	stdin(%rip), %rdi
	movq	8(%rdi), %rax
	movq	16(%rdi), %rcx
	cmpq	%rcx, %rax
	jnb	.L107
	leaq	1(%rax), %rdx
	movq	%rdx, 8(%rdi)
	movzbl	(%rax), %eax
.L68:
	xorl	%ebx, %ebx
	jmp	.L72
	.p2align 4,,10
	.p2align 3
.L69:
	leaq	1(%rdx), %rax
	movq	%rax, 8(%rdi)
	movzbl	(%rdx), %eax
	cmpl	$47, %eax
	jle	.L71
.L70:
	movq	8(%rdi), %rdx
	movq	16(%rdi), %rcx
.L72:
	leal	(%rbx,%rbx,4), %esi
	andl	$15, %eax
	leal	(%rax,%rsi,2), %ebx
	cmpq	%rdx, %rcx
	ja	.L69
	call	__uflow@PLT
	cmpl	$47, %eax
	jle	.L71
	movq	stdin(%rip), %rdi
	jmp	.L70
	.p2align 4,,10
	.p2align 3
.L71:
	leaq	a(%rip), %rax
	movl	%ebx, (%rax,%rbp,4)
	movl	n(%rip), %ebx
	addq	$1, %rbp
	cmpl	%ebp, %ebx
	jg	.L73
	movl	(%rax), %edx
	movq	%rax, %rcx
	movslq	%ebx, %rax
	leal	-1(%rbx), %r10d
	movl	%edx, (%rcx,%rax,4)
	testl	%ebx, %ebx
	jle	.L106
	movl	%r10d, %eax
	leaq	4(%rcx), %rdx
	movq	%rcx, %r13
	xorl	%r11d, %r11d
	leaq	(%rdx,%rax,4), %rax
	movl	$1, %r12d
	leaq	memo(%rip), %r9
	movl	%r10d, %r15d
	movq	%rax, 8(%rsp)
	.p2align 4,,10
	.p2align 3
.L96:
	cmpl	%r12d, %ebx
	je	.L98
	movl	%r12d, %r8d
	addl	$1, %r12d
	cmpl	%r15d, %ebx
	je	.L99
.L112:
	movl	%r15d, %esi
	addl	$1, %r15d
.L76:
	movslq	%r8d, %rbp
	movslq	%esi, %r14
	imulq	$2002, %rbp, %rdi
	leaq	(%rdi,%r14), %rax
	movq	(%r9,%rax,8), %rax
	testq	%rax, %rax
	jne	.L77
	cmpl	%esi, %r8d
	je	.L108
	xorl	%edx, %edx
	cmpl	%r12d, %ebx
	movl	%edx, %eax
	cmovne	%r12d, %eax
	movl	%eax, 16(%rsp)
	leal	-1(%rsi), %eax
	leal	(%rbx,%rax), %r10d
	cmpl	%r10d, %ebx
	cmovle	%eax, %r10d
	leaq	a(%rip), %rax
	movslq	(%rax,%rbp,4), %rcx
	movl	(%rax,%r14,4), %eax
	movl	%eax, 24(%rsp)
	cmpl	%eax, %ecx
	jle	.L81
	movslq	16(%rsp), %rcx
	imulq	$2002, %rcx, %rdi
	leaq	(%rdi,%r14), %rax
	movq	(%r9,%rax,8), %rax
	testq	%rax, %rax
	jne	.L89
	cmpl	%ecx, %esi
	je	.L109
	leal	1(%rcx), %edi
	cmpl	%edi, %ebx
	cmove	%edx, %edi
	movslq	%edi, %r8
	imulq	$2002, %r8, %rdx
	leaq	(%rdx,%r14), %rax
	movq	(%r9,%rax,8), %rax
	testq	%rax, %rax
	jne	.L85
	cmpl	%edi, %esi
	je	.L110
	movl	$1, %edx
	movq	%r11, 48(%rsp)
	movq	%rcx, 40(%rsp)
	movl	%r10d, 32(%rsp)
	call	calc.part.0
	movq	48(%rsp), %r11
	movq	40(%rsp), %rcx
	leaq	memo(%rip), %r9
	movl	32(%rsp), %r10d
.L85:
	leaq	a(%rip), %rsi
	movslq	(%rsi,%rcx,4), %rdx
	movslq	%r10d, %rsi
	leaq	(%rdx,%rax), %r8
	imulq	$2002, %rcx, %rax
	addq	%rsi, %rax
	movq	(%r9,%rax,8), %rdx
	testq	%rdx, %rdx
	jne	.L87
	cmpl	%r10d, 16(%rsp)
	je	.L111
	movl	16(%rsp), %edi
	movl	$1, %edx
	movl	%r10d, %esi
	movq	%r11, 48(%rsp)
	movq	%rcx, 40(%rsp)
	movq	%r8, 32(%rsp)
	call	calc.part.0
	movq	48(%rsp), %r11
	movq	40(%rsp), %rcx
	leaq	memo(%rip), %r9
	movq	32(%rsp), %r8
	movq	%rax, %rdx
.L87:
	movslq	24(%rsp), %rax
	addq	%rdx, %rax
	cmpq	%r8, %rax
	cmovl	%r8, %rax
	imulq	$2002, %rcx, %rdx
	addq	%r14, %rdx
	movq	%rax, (%r9,%rdx,8)
.L89:
	imulq	$2002, %rbp, %rbp
	addq	%r14, %rbp
	movq	%rax, (%r9,%rbp,8)
.L77:
	movslq	0(%r13), %rdx
	leaq	-1(%rax,%rdx), %rax
	cmpq	%rax, %r11
	cmovl	%rax, %r11
	addq	$4, %r13
	cmpq	%r13, 8(%rsp)
	jne	.L96
.L74:
	movq	%r11, %rdx
	leaq	.LC0(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	addq	$72, %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
.L98:
	.cfi_restore_state
	movl	$1, %r12d
	xorl	%r8d, %r8d
	cmpl	%r15d, %ebx
	jne	.L112
.L99:
	movl	$1, %r15d
	xorl	%esi, %esi
	jmp	.L76
	.p2align 4,,10
	.p2align 3
.L108:
	imulq	$2003, %r14, %r14
	movl	$1, %eax
	movq	$1, (%r9,%r14,8)
	jmp	.L77
	.p2align 4,,10
	.p2align 3
.L81:
	movslq	%r10d, %rax
	addq	%rax, %rdi
	movq	%rax, 24(%rsp)
	movq	(%r9,%rdi,8), %rax
	testq	%rax, %rax
	jne	.L89
	cmpl	%r10d, %r8d
	je	.L113
	leal	-1(%r10), %eax
	leal	(%rbx,%rax), %esi
	cmpl	%esi, %ebx
	cmovg	%esi, %eax
	movl	%eax, 32(%rsp)
	movslq	16(%rsp), %rax
	movq	%rax, %rsi
	imulq	$2002, %rax, %rax
	addq	24(%rsp), %rax
	movq	(%r9,%rax,8), %rax
	testq	%rax, %rax
	jne	.L92
	cmpl	%r10d, %esi
	je	.L114
	movl	16(%rsp), %edi
	movl	$1, %edx
	movl	%r10d, %esi
	movl	%ecx, 48(%rsp)
	movq	%r11, 56(%rsp)
	movl	%r8d, 40(%rsp)
	call	calc.part.0
	movq	56(%rsp), %r11
	movslq	48(%rsp), %rcx
	leaq	memo(%rip), %r9
	movl	40(%rsp), %r8d
.L92:
	addq	%rax, %rcx
	imulq	$2002, %rbp, %rax
	movslq	32(%rsp), %rsi
	addq	%rsi, %rax
	movq	(%r9,%rax,8), %rdx
	testq	%rdx, %rdx
	jne	.L94
	cmpl	%esi, %r8d
	je	.L115
	movl	32(%rsp), %esi
	movl	$1, %edx
	movl	%r8d, %edi
	movq	%r11, 40(%rsp)
	movq	%rcx, 16(%rsp)
	call	calc.part.0
	movq	40(%rsp), %r11
	movq	16(%rsp), %rcx
	leaq	memo(%rip), %r9
	movq	%rax, %rdx
.L94:
	movq	24(%rsp), %rsi
	leaq	a(%rip), %rax
	movslq	(%rax,%rsi,4), %rax
	addq	%rdx, %rax
	cmpq	%rcx, %rax
	cmovl	%rcx, %rax
	imulq	$2002, %rbp, %rdx
	imulq	$2002, %rbp, %rbp
	addq	%rsi, %rdx
	addq	%r14, %rbp
	movq	%rax, (%r9,%rdx,8)
	movq	%rax, (%r9,%rbp,8)
	jmp	.L77
	.p2align 4,,10
	.p2align 3
.L107:
	call	__uflow@PLT
	movq	stdin(%rip), %rdi
	movq	8(%rdi), %rdx
	movq	16(%rdi), %rcx
	jmp	.L68
.L113:
	imulq	$2003, 24(%rsp), %rdx
	leal	1(%rcx), %eax
	cltq
	movq	%rax, (%r9,%rdx,8)
	jmp	.L89
.L109:
	leaq	a(%rip), %rax
	addq	%rcx, %rdi
	movl	(%rax,%rcx,4), %eax
	movl	%eax, 16(%rsp)
	addl	$1, %eax
	cltq
	movq	%rax, (%r9,%rdi,8)
	jmp	.L89
.L114:
	imulq	$2003, 24(%rsp), %rax
	movq	$1, (%r9,%rax,8)
	movl	$1, %eax
	jmp	.L92
.L110:
	addq	%r8, %rdx
	movl	$1, %eax
	movq	$1, (%r9,%rdx,8)
	jmp	.L85
.L111:
	imulq	$2003, %rsi, %rsi
	movl	$1, %edx
	movq	$1, (%r9,%rsi,8)
	jmp	.L87
.L115:
	imulq	$2003, %rsi, %rsi
	movl	$1, %edx
	movq	$1, (%r9,%rsi,8)
	jmp	.L94
.L66:
	movl	a(%rip), %ecx
	cltq
	leaq	a(%rip), %rdx
	movl	%ecx, (%rdx,%rax,4)
.L106:
	xorl	%r11d, %r11d
	jmp	.L74
	.cfi_endproc
.LFE25:
	.size	main, .-main
	.globl	memo
	.bss
	.align 32
	.type	memo, @object
	.size	memo, 32064032
memo:
	.zero	32064032
	.globl	a
	.align 32
	.type	a, @object
	.size	a, 8008
a:
	.zero	8008
	.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
	.p2align 4
	.globl	in
	.type	in, @function
in:
.LFB23:
	.cfi_startproc
	endbr64
	movq	stdin(%rip), %rdi
	pushq	%r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	movq	8(%rdi), %rax
	movq	16(%rdi), %rcx
	cmpq	%rcx, %rax
	jnb	.L11
	leaq	1(%rax), %rdx
	movq	%rdx, 8(%rdi)
	movzbl	(%rax), %eax
.L3:
	xorl	%r12d, %r12d
	jmp	.L7
	.p2align 4,,10
	.p2align 3
.L4:
	leaq	1(%rdx), %rax
	movq	%rax, 8(%rdi)
	movzbl	(%rdx), %eax
	cmpl	$47, %eax
	jle	.L1
.L5:
	movq	8(%rdi), %rdx
	movq	16(%rdi), %rcx
.L7:
	leal	(%r12,%r12,4), %esi
	andl	$15, %eax
	leal	(%rax,%rsi,2), %r12d
	cmpq	%rcx, %rdx
	jb	.L4
	call	__uflow@PLT
	cmpl	$47, %eax
	jle	.L1
	movq	stdin(%rip), %rdi
	jmp	.L5
	.p2align 4,,10
	.p2align 3
.L1:
	movl	%r12d, %eax
	popq	%r12
	.cfi_remember_state
	.cfi_def_cfa_offset 8
	ret
	.p2align 4,,10
	.p2align 3
.L11:
	.cfi_restore_state
	call	__uflow@PLT
	movq	stdin(%rip), %rdi
	movq	8(%rdi), %rdx
	movq	16(%rdi), %rcx
	jmp	.L3
	.cfi_endproc
.LFE23:
	.size	in, .-in
	.p2align 4
	.globl	calc
	.type	calc, @function
calc:
.LFB24:
	.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
	movslq	%edi, %r13
	movl	%edx, %edi
	imulq	$2002, %r13, %r9
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	movslq	%esi, %r12
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	leaq	memo(%rip), %rbx
	leaq	(%r9,%r12), %rdx
	subq	$24, %rsp
	.cfi_def_cfa_offset 80
	movq	(%rbx,%rdx,8), %rax
	testq	%rax, %rax
	jne	.L12
	movq	%r13, %rbp
	cmpl	%esi, %r13d
	je	.L35
	movl	n(%rip), %r8d
	leal	1(%r13), %r14d
	xorl	%ecx, %ecx
	cmpl	%r8d, %r14d
	cmove	%ecx, %r14d
	leal	-1(%rsi), %ecx
	leal	(%r8,%rcx), %r15d
	cmpl	%r15d, %r8d
	cmovle	%ecx, %r15d
	testl	%edi, %edi
	je	.L18
	leaq	a(%rip), %rdx
	movl	(%rdx,%r13,4), %ecx
	cmpl	(%rdx,%r12,4), %ecx
	jg	.L36
	movslq	%r15d, %rdx
	leaq	(%r9,%rdx), %rax
	movq	(%rbx,%rax,8), %rax
	testq	%rax, %rax
	jne	.L34
	cmpl	%r15d, %r13d
	je	.L37
	xorl	%edx, %edx
	movl	%r15d, %esi
	movl	%r13d, %edi
	call	calc.part.0
	.p2align 4,,10
	.p2align 3
.L34:
	imulq	$2002, %r13, %rdx
	addq	%r12, %rdx
	movq	%rax, (%rbx,%rdx,8)
.L12:
	addq	$24, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 56
	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
.L35:
	.cfi_restore_state
	testl	%edi, %edi
	je	.L15
	imulq	$2003, %r12, %r12
	movl	$1, %eax
	movq	$1, (%rbx,%r12,8)
	addq	$24, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 56
	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
.L36:
	.cfi_restore_state
	movslq	%r14d, %rdi
	imulq	$2002, %rdi, %rcx
	leaq	(%rcx,%r12), %rax
	movq	(%rbx,%rax,8), %rax
	testq	%rax, %rax
	jne	.L34
	cmpl	%r14d, %esi
	je	.L38
	xorl	%edx, %edx
	movl	%r14d, %edi
	call	calc.part.0
	jmp	.L34
	.p2align 4,,10
	.p2align 3
.L15:
	leaq	a(%rip), %rax
	movl	(%rax,%r12,4), %eax
	imulq	$2003, %r12, %r12
	addl	$1, %eax
	cltq
	movq	%rax, (%rbx,%r12,8)
	addq	$24, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 56
	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
.L18:
	.cfi_restore_state
	movslq	%r14d, %r10
	leaq	a(%rip), %r9
	imulq	$2002, %r10, %rdx
	leaq	(%rdx,%r12), %rcx
	movq	(%rbx,%rcx,8), %rax
	testq	%rax, %rax
	jne	.L24
	cmpl	%r14d, %esi
	je	.L39
	leal	1(%r14), %r11d
	movl	(%r9,%r12,4), %eax
	movq	%rcx, 8(%rsp)
	movl	$0, %edx
	cmpl	%r11d, %r8d
	movl	%r8d, (%rsp)
	cmove	%edi, %r11d
	cmpl	%eax, (%r9,%r10,4)
	jle	.L27
	movl	%r11d, %edi
	call	calc
	movq	8(%rsp), %rcx
	movl	(%rsp), %r8d
	leaq	a(%rip), %r9
	movq	%rax, (%rbx,%rcx,8)
.L24:
	movslq	(%r9,%r13,4), %rcx
	imulq	$2002, %r13, %r10
	movq	%rcx, %rsi
	addq	%rax, %rcx
	movslq	%r15d, %rax
	addq	%rax, %r10
	movq	(%rbx,%r10,8), %rdx
	testq	%rdx, %rdx
	jne	.L28
	cmpl	%r15d, %ebp
	je	.L40
	leal	-1(%r15), %edx
	movq	%r10, 8(%rsp)
	leal	(%r8,%rdx), %r11d
	movq	%rcx, (%rsp)
	cmpl	%r11d, %r8d
	cmovle	%edx, %r11d
	cmpl	(%r9,%rax,4), %esi
	movl	$0, %edx
	jle	.L31
	movl	%r15d, %esi
	movl	%r14d, %edi
	call	calc
	movq	8(%rsp), %r10
	movq	(%rsp), %rcx
	leaq	a(%rip), %r9
	movq	%rax, %rdx
	movq	%rax, (%rbx,%r10,8)
.L28:
	movslq	(%r9,%r12,4), %rax
	addq	%rdx, %rax
	cmpq	%rcx, %rax
	cmovl	%rcx, %rax
	jmp	.L34
	.p2align 4,,10
	.p2align 3
.L31:
	movl	%r11d, %esi
	movl	%ebp, %edi
	call	calc
	movq	8(%rsp), %r10
	movq	(%rsp), %rcx
	leaq	a(%rip), %r9
	movq	%rax, %rdx
	movq	%rax, (%rbx,%r10,8)
	jmp	.L28
	.p2align 4,,10
	.p2align 3
.L27:
	movl	%r15d, %esi
	movl	%r14d, %edi
	call	calc
	movq	8(%rsp), %rcx
	movl	(%rsp), %r8d
	leaq	a(%rip), %r9
	movq	%rax, (%rbx,%rcx,8)
	jmp	.L24
	.p2align 4,,10
	.p2align 3
.L38:
	movl	(%rdx,%rdi,4), %eax
	addq	%rdi, %rcx
	addl	$1, %eax
	cltq
	movq	%rax, (%rbx,%rcx,8)
	jmp	.L34
	.p2align 4,,10
	.p2align 3
.L37:
	imulq	$2003, %rdx, %rdx
	addl	$1, %ecx
	movslq	%ecx, %rax
	movq	%rax, (%rbx,%rdx,8)
	jmp	.L34
	.p2align 4,,10
	.p2align 3
.L40:
	imulq	$2003, %rax, %rax
	movl	$1, %edx
	movq	$1, (%rbx,%rax,8)
	jmp	.L28
	.p2align 4,,10
	.p2align 3
.L39:
	addq	%r10, %rdx
	movl	$1, %eax
	movq	$1, (%rbx,%rdx,8)
	jmp	.L24
	.cfi_endproc
.LFE24:
	.size	calc, .-calc
	.p2align 4
	.type	calc.part.0, @function
calc.part.0:
.LFB26:
	.cfi_startproc
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	movl	%edx, %eax
	xorl	%edx, %edx
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	leal	1(%rdi), %r14d
	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
	movl	%edi, %ebp
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$24, %rsp
	.cfi_def_cfa_offset 80
	movl	n(%rip), %ecx
	cmpl	%ecx, %r14d
	cmove	%edx, %r14d
	leal	-1(%rsi), %edx
	leal	(%rcx,%rdx), %r15d
	cmpl	%r15d, %ecx
	cmovle	%edx, %r15d
	testl	%eax, %eax
	je	.L44
	leaq	a(%rip), %rdx
	movslq	%edi, %rbx
	movslq	%esi, %r13
	movl	(%rdx,%rbx,4), %ecx
	leaq	memo(%rip), %r12
	cmpl	(%rdx,%r13,4), %ecx
	jle	.L45
	movslq	%r14d, %rdi
	imulq	$2002, %rdi, %rcx
	leaq	(%rcx,%r13), %rax
	movq	(%r12,%rax,8), %rax
	testq	%rax, %rax
	jne	.L48
	cmpl	%r14d, %esi
	je	.L61
	xorl	%edx, %edx
	movl	%r14d, %edi
	call	calc.part.0
.L48:
	imulq	$2002, %rbx, %rbx
	addq	%r13, %rbx
	movq	%rax, (%r12,%rbx,8)
	addq	$24, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 56
	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
.L45:
	.cfi_restore_state
	imulq	$2002, %rbx, %rax
	movslq	%r15d, %rdx
	addq	%rdx, %rax
	movq	(%r12,%rax,8), %rax
	testq	%rax, %rax
	jne	.L48
	cmpl	%r15d, %edi
	je	.L62
	xorl	%edx, %edx
	movl	%r15d, %esi
	call	calc.part.0
	jmp	.L48
	.p2align 4,,10
	.p2align 3
.L44:
	movslq	%r14d, %r8
	movslq	%esi, %r13
	leaq	memo(%rip), %r12
	imulq	$2002, %r8, %rdi
	leaq	a(%rip), %r9
	leaq	(%rdi,%r13), %rbx
	movq	(%r12,%rbx,8), %rdx
	testq	%rdx, %rdx
	jne	.L51
	cmpl	%r14d, %esi
	je	.L63
	leal	1(%r14), %edi
	movl	%ecx, (%rsp)
	movl	$0, %edx
	cmpl	%edi, %ecx
	cmove	%eax, %edi
	movl	(%r9,%r13,4), %eax
	cmpl	%eax, (%r9,%r8,4)
	jle	.L54
	call	calc
	movl	(%rsp), %ecx
	leaq	a(%rip), %r9
	movq	%rax, (%r12,%rbx,8)
	movq	%rax, %rdx
.L51:
	movslq	%ebp, %rbx
	movslq	%r15d, %rax
	imulq	$2002, %rbx, %r10
	movslq	(%r9,%rbx,4), %r8
	movq	%r8, %rsi
	addq	%rdx, %r8
	addq	%rax, %r10
	movq	(%r12,%r10,8), %rdx
	testq	%rdx, %rdx
	jne	.L55
	cmpl	%r15d, %ebp
	je	.L64
	leal	-1(%r15), %edx
	movq	%r10, 8(%rsp)
	leal	(%rcx,%rdx), %r11d
	movq	%r8, (%rsp)
	cmpl	%r11d, %ecx
	cmovle	%edx, %r11d
	cmpl	(%r9,%rax,4), %esi
	movl	$0, %edx
	jle	.L58
	movl	%r15d, %esi
	movl	%r14d, %edi
	call	calc
	movq	8(%rsp), %r10
	movq	(%rsp), %r8
	leaq	a(%rip), %r9
	movq	%rax, %rdx
	movq	%rax, (%r12,%r10,8)
.L55:
	movslq	(%r9,%r13,4), %rax
	addq	%rdx, %rax
	cmpq	%r8, %rax
	cmovl	%r8, %rax
	jmp	.L48
	.p2align 4,,10
	.p2align 3
.L61:
	movl	(%rdx,%rdi,4), %eax
	addq	%rdi, %rcx
	addl	$1, %eax
	cltq
	movq	%rax, (%r12,%rcx,8)
	jmp	.L48
	.p2align 4,,10
	.p2align 3
.L62:
	imulq	$2003, %rdx, %rdx
	addl	$1, %ecx
	movslq	%ecx, %rax
	movq	%rax, (%r12,%rdx,8)
	jmp	.L48
	.p2align 4,,10
	.p2align 3
.L64:
	imulq	$2003, %rax, %rax
	movl	$1, %edx
	movq	$1, (%r12,%rax,8)
	jmp	.L55
	.p2align 4,,10
	.p2align 3
.L63:
	addq	%r8, %rdi
	movl	$1, %edx
	movq	$1, (%r12,%rdi,8)
	jmp	.L51
	.p2align 4,,10
	.p2align 3
.L54:
	movl	%r15d, %esi
	movl	%r14d, %edi
	call	calc
	movl	(%rsp), %ecx
	leaq	a(%rip), %r9
	movq	%rax, (%r12,%rbx,8)
	movq	%rax, %rdx
	jmp	.L51
	.p2align 4,,10
	.p2align 3
.L58:
	movl	%r11d, %esi
	movl	%ebp, %edi
	call	calc
	movq	8(%rsp), %r10
	movq	(%rsp), %r8
	leaq	a(%rip), %r9
	movq	%rax, %rdx
	movq	%rax, (%r12,%r10,8)
	jmp	.L55
	.cfi_endproc
.LFE26:
	.size	calc.part.0, .-calc.part.0
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%lld\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB25:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	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
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$72, %rsp
	.cfi_def_cfa_offset 128
	call	in
	movl	%eax, n(%rip)
	testl	%eax, %eax
	jle	.L66
	xorl	%ebp, %ebp
	.p2align 4,,10
	.p2align 3
.L73:
	movq	stdin(%rip), %rdi
	movq	8(%rdi), %rax
	movq	16(%rdi), %rcx
	cmpq	%rcx, %rax
	jnb	.L107
	leaq	1(%rax), %rdx
	movq	%rdx, 8(%rdi)
	movzbl	(%rax), %eax
.L68:
	xorl	%ebx, %ebx
	jmp	.L72
	.p2align 4,,10
	.p2align 3
.L69:
	leaq	1(%rdx), %rax
	movq	%rax, 8(%rdi)
	movzbl	(%rdx), %eax
	cmpl	$47, %eax
	jle	.L71
.L70:
	movq	8(%rdi), %rdx
	movq	16(%rdi), %rcx
.L72:
	leal	(%rbx,%rbx,4), %esi
	andl	$15, %eax
	leal	(%rax,%rsi,2), %ebx
	cmpq	%rdx, %rcx
	ja	.L69
	call	__uflow@PLT
	cmpl	$47, %eax
	jle	.L71
	movq	stdin(%rip), %rdi
	jmp	.L70
	.p2align 4,,10
	.p2align 3
.L71:
	leaq	a(%rip), %rax
	movl	%ebx, (%rax,%rbp,4)
	movl	n(%rip), %ebx
	addq	$1, %rbp
	cmpl	%ebp, %ebx
	jg	.L73
	movl	(%rax), %edx
	movq	%rax, %rcx
	movslq	%ebx, %rax
	leal	-1(%rbx), %r10d
	movl	%edx, (%rcx,%rax,4)
	testl	%ebx, %ebx
	jle	.L106
	movl	%r10d, %eax
	leaq	4(%rcx), %rdx
	movq	%rcx, %r13
	xorl	%r11d, %r11d
	leaq	(%rdx,%rax,4), %rax
	movl	$1, %r12d
	leaq	memo(%rip), %r9
	movl	%r10d, %r15d
	movq	%rax, 8(%rsp)
	.p2align 4,,10
	.p2align 3
.L96:
	cmpl	%r12d, %ebx
	je	.L98
	movl	%r12d, %r8d
	addl	$1, %r12d
	cmpl	%r15d, %ebx
	je	.L99
.L112:
	movl	%r15d, %esi
	addl	$1, %r15d
.L76:
	movslq	%r8d, %rbp
	movslq	%esi, %r14
	imulq	$2002, %rbp, %rdi
	leaq	(%rdi,%r14), %rax
	movq	(%r9,%rax,8), %rax
	testq	%rax, %rax
	jne	.L77
	cmpl	%esi, %r8d
	je	.L108
	xorl	%edx, %edx
	cmpl	%r12d, %ebx
	movl	%edx, %eax
	cmovne	%r12d, %eax
	movl	%eax, 16(%rsp)
	leal	-1(%rsi), %eax
	leal	(%rbx,%rax), %r10d
	cmpl	%r10d, %ebx
	cmovle	%eax, %r10d
	leaq	a(%rip), %rax
	movslq	(%rax,%rbp,4), %rcx
	movl	(%rax,%r14,4), %eax
	movl	%eax, 24(%rsp)
	cmpl	%eax, %ecx
	jle	.L81
	movslq	16(%rsp), %rcx
	imulq	$2002, %rcx, %rdi
	leaq	(%rdi,%r14), %rax
	movq	(%r9,%rax,8), %rax
	testq	%rax, %rax
	jne	.L89
	cmpl	%ecx, %esi
	je	.L109
	leal	1(%rcx), %edi
	cmpl	%edi, %ebx
	cmove	%edx, %edi
	movslq	%edi, %r8
	imulq	$2002, %r8, %rdx
	leaq	(%rdx,%r14), %rax
	movq	(%r9,%rax,8), %rax
	testq	%rax, %rax
	jne	.L85
	cmpl	%edi, %esi
	je	.L110
	movl	$1, %edx
	movq	%r11, 48(%rsp)
	movq	%rcx, 40(%rsp)
	movl	%r10d, 32(%rsp)
	call	calc.part.0
	movq	48(%rsp), %r11
	movq	40(%rsp), %rcx
	leaq	memo(%rip), %r9
	movl	32(%rsp), %r10d
.L85:
	leaq	a(%rip), %rsi
	movslq	(%rsi,%rcx,4), %rdx
	movslq	%r10d, %rsi
	leaq	(%rdx,%rax), %r8
	imulq	$2002, %rcx, %rax
	addq	%rsi, %rax
	movq	(%r9,%rax,8), %rdx
	testq	%rdx, %rdx
	jne	.L87
	cmpl	%r10d, 16(%rsp)
	je	.L111
	movl	16(%rsp), %edi
	movl	$1, %edx
	movl	%r10d, %esi
	movq	%r11, 48(%rsp)
	movq	%rcx, 40(%rsp)
	movq	%r8, 32(%rsp)
	call	calc.part.0
	movq	48(%rsp), %r11
	movq	40(%rsp), %rcx
	leaq	memo(%rip), %r9
	movq	32(%rsp), %r8
	movq	%rax, %rdx
.L87:
	movslq	24(%rsp), %rax
	addq	%rdx, %rax
	cmpq	%r8, %rax
	cmovl	%r8, %rax
	imulq	$2002, %rcx, %rdx
	addq	%r14, %rdx
	movq	%rax, (%r9,%rdx,8)
.L89:
	imulq	$2002, %rbp, %rbp
	addq	%r14, %rbp
	movq	%rax, (%r9,%rbp,8)
.L77:
	movslq	0(%r13), %rdx
	leaq	-1(%rax,%rdx), %rax
	cmpq	%rax, %r11
	cmovl	%rax, %r11
	addq	$4, %r13
	cmpq	%r13, 8(%rsp)
	jne	.L96
.L74:
	movq	%r11, %rdx
	leaq	.LC0(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	addq	$72, %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
.L98:
	.cfi_restore_state
	movl	$1, %r12d
	xorl	%r8d, %r8d
	cmpl	%r15d, %ebx
	jne	.L112
.L99:
	movl	$1, %r15d
	xorl	%esi, %esi
	jmp	.L76
	.p2align 4,,10
	.p2align 3
.L108:
	imulq	$2003, %r14, %r14
	movl	$1, %eax
	movq	$1, (%r9,%r14,8)
	jmp	.L77
	.p2align 4,,10
	.p2align 3
.L81:
	movslq	%r10d, %rax
	addq	%rax, %rdi
	movq	%rax, 24(%rsp)
	movq	(%r9,%rdi,8), %rax
	testq	%rax, %rax
	jne	.L89
	cmpl	%r10d, %r8d
	je	.L113
	leal	-1(%r10), %eax
	leal	(%rbx,%rax), %esi
	cmpl	%esi, %ebx
	cmovg	%esi, %eax
	movl	%eax, 32(%rsp)
	movslq	16(%rsp), %rax
	movq	%rax, %rsi
	imulq	$2002, %rax, %rax
	addq	24(%rsp), %rax
	movq	(%r9,%rax,8), %rax
	testq	%rax, %rax
	jne	.L92
	cmpl	%r10d, %esi
	je	.L114
	movl	16(%rsp), %edi
	movl	$1, %edx
	movl	%r10d, %esi
	movl	%ecx, 48(%rsp)
	movq	%r11, 56(%rsp)
	movl	%r8d, 40(%rsp)
	call	calc.part.0
	movq	56(%rsp), %r11
	movslq	48(%rsp), %rcx
	leaq	memo(%rip), %r9
	movl	40(%rsp), %r8d
.L92:
	addq	%rax, %rcx
	imulq	$2002, %rbp, %rax
	movslq	32(%rsp), %rsi
	addq	%rsi, %rax
	movq	(%r9,%rax,8), %rdx
	testq	%rdx, %rdx
	jne	.L94
	cmpl	%esi, %r8d
	je	.L115
	movl	32(%rsp), %esi
	movl	$1, %edx
	movl	%r8d, %edi
	movq	%r11, 40(%rsp)
	movq	%rcx, 16(%rsp)
	call	calc.part.0
	movq	40(%rsp), %r11
	movq	16(%rsp), %rcx
	leaq	memo(%rip), %r9
	movq	%rax, %rdx
.L94:
	movq	24(%rsp), %rsi
	leaq	a(%rip), %rax
	movslq	(%rax,%rsi,4), %rax
	addq	%rdx, %rax
	cmpq	%rcx, %rax
	cmovl	%rcx, %rax
	imulq	$2002, %rbp, %rdx
	imulq	$2002, %rbp, %rbp
	addq	%rsi, %rdx
	addq	%r14, %rbp
	movq	%rax, (%r9,%rdx,8)
	movq	%rax, (%r9,%rbp,8)
	jmp	.L77
	.p2align 4,,10
	.p2align 3
.L107:
	call	__uflow@PLT
	movq	stdin(%rip), %rdi
	movq	8(%rdi), %rdx
	movq	16(%rdi), %rcx
	jmp	.L68
.L113:
	imulq	$2003, 24(%rsp), %rdx
	leal	1(%rcx), %eax
	cltq
	movq	%rax, (%r9,%rdx,8)
	jmp	.L89
.L109:
	leaq	a(%rip), %rax
	addq	%rcx, %rdi
	movl	(%rax,%rcx,4), %eax
	movl	%eax, 16(%rsp)
	addl	$1, %eax
	cltq
	movq	%rax, (%r9,%rdi,8)
	jmp	.L89
.L114:
	imulq	$2003, 24(%rsp), %rax
	movq	$1, (%r9,%rax,8)
	movl	$1, %eax
	jmp	.L92
.L110:
	addq	%r8, %rdx
	movl	$1, %eax
	movq	$1, (%r9,%rdx,8)
	jmp	.L85
.L111:
	imulq	$2003, %rsi, %rsi
	movl	$1, %edx
	movq	$1, (%r9,%rsi,8)
	jmp	.L87
.L115:
	imulq	$2003, %rsi, %rsi
	movl	$1, %edx
	movq	$1, (%r9,%rsi,8)
	jmp	.L94
.L66:
	movl	a(%rip), %ecx
	cltq
	leaq	a(%rip), %rdx
	movl	%ecx, (%rdx,%rax,4)
.L106:
	xorl	%r11d, %r11d
	jmp	.L74
	.cfi_endproc
.LFE25:
	.size	main, .-main
	.globl	memo
	.bss
	.align 32
	.type	memo, @object
	.size	memo, 32064032
memo:
	.zero	32064032
	.globl	a
	.align 32
	.type	a, @object
	.size	a, 8008
a:
	.zero	8008
	.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:

// AOJ 0615 Cake 2
// 2018.2.27 bal4u

#include <stdio.h>

int n;
int a[2002];
long long memo[2002][2002];

//#define getchar_unlocked()  getchar()
int in()
{
	int n = 0;
	int c = getchar_unlocked();
	do n = 10*n + (c & 0xf), c = getchar_unlocked();
	while (c >= '0');
	return n;
}

long long calc(int l, int r, int s)
{
	int nl, nr;
	long long k, k2;

	if (memo[l][r]) return memo[l][r];
	if (l == r) {
		if (s) return memo[l][r] = 1;
		return memo[l][r] = a[l] + 1;
	}
	nl = l+1; if (nl == n) nl = 0;
	nr = r-1+n; if (nr >= n) nr -= n;
	if (s) {
		if (a[l] > a[r]) return memo[l][r] = calc(nl, r, 0);
		else             return memo[l][r] = calc(l, nr, 0);
	}
	k  = calc(nl, r, 1) + a[l];
	k2 = calc(l, nr, 1) + a[r];
	if (k2 > k) k = k2;
	return memo[l][r] = k;
}

int main()
{
	int i, i1, i2;
	long long k, ans;

	n = in();
	for (i = 0; i < n; i++) a[i] = in();
	a[n] = a[0];

	ans = 0;
	i1 = 1, i2 = n-1; for (i = 0; i < n; i++) {
		if (i1 == n) i1 = 0;
		if (i2 == n) i2 = 0;
		k = calc(i1, i2, 1) + a[i] - 1;
		if (k > ans) ans = k;
		i1++, i2++;
	}
	printf("%lld\n", ans);
	return 0;
}

5
2
8
1
10
12
 5
2
8
1
10
13
 5
2
8
1
18
24
 5
3
8
0
18
24
 5
3
5
0
18
24
 5
3
5
0
17
4
 5
5
5
0
26
4
 5
2
8
1
0
9
 5
2
3
1
10
12
 5
4
8
1
18
13

21
 22
 33
 32
 29
 20
 31
 17
 16
 23

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

```c
// AOJ 0615 Cake 2
// 2018.2.27 bal4u

#include <stdio.h>

int n;
int a[2002];
long long memo[2002][2002];

//#define getchar_unlocked()  getchar()
int in()
{
	int n = 0;
	int c = getchar_unlocked();
	do n = 10*n + (c & 0xf), c = getchar_unlocked();
	while (c >= '0');
	return n;
}

long long calc(int l, int r, int s)
{
	int nl, nr;
	long long k, k2;

	if (memo[l][r]) return memo[l][r];
	if (l == r) {
		if (s) return memo[l][r] = 1;
		return memo[l][r] = a[l] + 1;
	}
	nl = l+1; if (nl == n) nl = 0;
	nr = r-1+n; if (nr >= n) nr -= n;
	if (s) {
		if (a[l] > a[r]) return memo[l][r] = calc(nl, r, 0);
		else             return memo[l][r] = calc(l, nr, 0);
	}
	k  = calc(nl, r, 1) + a[l];
	k2 = calc(l, nr, 1) + a[r];
	if (k2 > k) k = k2;
	return memo[l][r] = k;
}

int main()
{
	int i, i1, i2;
	long long k, ans;

	n = in();
	for (i = 0; i < n; i++) a[i] = in();
	a[n] = a[0];

	ans = 0;
	i1 = 1, i2 = n-1; for (i = 0; i < n; i++) {
		if (i1 == n) i1 = 0;
		if (i2 == n) i2 = 0;
		k = calc(i1, i2, 1) + a[i] - 1;
		if (k > ans) ans = k;
		i1++, i2++;
	}
	printf("%lld\n", ans);
	return 0;
}
```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	n
	.bss
	.align 4
	.type	n, @object
	.size	n, 4
n:
	.zero	4
	.globl	a
	.align 32
	.type	a, @object
	.size	a, 8008
a:
	.zero	8008
	.globl	memo
	.align 32
	.type	memo, @object
	.size	memo, 32064032
memo:
	.zero	32064032
	.text
	.globl	in
	.type	in, @function
in:
.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
	movl	$0, -8(%rbp)
	call	getchar_unlocked@PLT
	movl	%eax, -4(%rbp)
.L2:
	movl	-8(%rbp), %edx
	movl	%edx, %eax
	sall	$2, %eax
	addl	%edx, %eax
	addl	%eax, %eax
	movl	%eax, %edx
	movl	-4(%rbp), %eax
	andl	$15, %eax
	addl	%edx, %eax
	movl	%eax, -8(%rbp)
	call	getchar_unlocked@PLT
	movl	%eax, -4(%rbp)
	cmpl	$47, -4(%rbp)
	jg	.L2
	movl	-8(%rbp), %eax
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	in, .-in
	.globl	calc
	.type	calc, @function
calc:
.LFB1:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$48, %rsp
	movl	%edi, -36(%rbp)
	movl	%esi, -40(%rbp)
	movl	%edx, -44(%rbp)
	movl	-40(%rbp), %eax
	movslq	%eax, %rdx
	movl	-36(%rbp), %eax
	cltq
	imulq	$2002, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,8), %rdx
	leaq	memo(%rip), %rax
	movq	(%rdx,%rax), %rax
	testq	%rax, %rax
	je	.L5
	movl	-40(%rbp), %eax
	movslq	%eax, %rdx
	movl	-36(%rbp), %eax
	cltq
	imulq	$2002, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,8), %rdx
	leaq	memo(%rip), %rax
	movq	(%rdx,%rax), %rax
	jmp	.L6
.L5:
	movl	-36(%rbp), %eax
	cmpl	-40(%rbp), %eax
	jne	.L7
	cmpl	$0, -44(%rbp)
	je	.L8
	movl	-40(%rbp), %eax
	movslq	%eax, %rdx
	movl	-36(%rbp), %eax
	cltq
	imulq	$2002, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,8), %rdx
	leaq	memo(%rip), %rax
	movq	$1, (%rdx,%rax)
	movl	-40(%rbp), %eax
	movslq	%eax, %rdx
	movl	-36(%rbp), %eax
	cltq
	imulq	$2002, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,8), %rdx
	leaq	memo(%rip), %rax
	movq	(%rdx,%rax), %rax
	jmp	.L6
.L8:
	movl	-36(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	a(%rip), %rax
	movl	(%rdx,%rax), %eax
	addl	$1, %eax
	cltq
	movl	-40(%rbp), %edx
	movslq	%edx, %rcx
	movl	-36(%rbp), %edx
	movslq	%edx, %rdx
	imulq	$2002, %rdx, %rdx
	addq	%rcx, %rdx
	leaq	0(,%rdx,8), %rcx
	leaq	memo(%rip), %rdx
	movq	%rax, (%rcx,%rdx)
	movl	-40(%rbp), %eax
	movslq	%eax, %rdx
	movl	-36(%rbp), %eax
	cltq
	imulq	$2002, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,8), %rdx
	leaq	memo(%rip), %rax
	movq	(%rdx,%rax), %rax
	jmp	.L6
.L7:
	movl	-36(%rbp), %eax
	addl	$1, %eax
	movl	%eax, -24(%rbp)
	movl	n(%rip), %eax
	cmpl	%eax, -24(%rbp)
	jne	.L9
	movl	$0, -24(%rbp)
.L9:
	movl	-40(%rbp), %eax
	leal	-1(%rax), %edx
	movl	n(%rip), %eax
	addl	%edx, %eax
	movl	%eax, -20(%rbp)
	movl	n(%rip), %eax
	cmpl	%eax, -20(%rbp)
	jl	.L10
	movl	n(%rip), %eax
	subl	%eax, -20(%rbp)
.L10:
	cmpl	$0, -44(%rbp)
	je	.L11
	movl	-36(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	a(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	-40(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	a(%rip), %rax
	movl	(%rcx,%rax), %eax
	cmpl	%eax, %edx
	jle	.L12
	movl	-40(%rbp), %ecx
	movl	-24(%rbp), %eax
	movl	$0, %edx
	movl	%ecx, %esi
	movl	%eax, %edi
	call	calc
	movl	-40(%rbp), %edx
	movslq	%edx, %rcx
	movl	-36(%rbp), %edx
	movslq	%edx, %rdx
	imulq	$2002, %rdx, %rdx
	addq	%rcx, %rdx
	leaq	0(,%rdx,8), %rcx
	leaq	memo(%rip), %rdx
	movq	%rax, (%rcx,%rdx)
	movl	-40(%rbp), %eax
	movslq	%eax, %rdx
	movl	-36(%rbp), %eax
	cltq
	imulq	$2002, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,8), %rdx
	leaq	memo(%rip), %rax
	movq	(%rdx,%rax), %rax
	jmp	.L6
.L12:
	movl	-20(%rbp), %ecx
	movl	-36(%rbp), %eax
	movl	$0, %edx
	movl	%ecx, %esi
	movl	%eax, %edi
	call	calc
	movl	-40(%rbp), %edx
	movslq	%edx, %rcx
	movl	-36(%rbp), %edx
	movslq	%edx, %rdx
	imulq	$2002, %rdx, %rdx
	addq	%rcx, %rdx
	leaq	0(,%rdx,8), %rcx
	leaq	memo(%rip), %rdx
	movq	%rax, (%rcx,%rdx)
	movl	-40(%rbp), %eax
	movslq	%eax, %rdx
	movl	-36(%rbp), %eax
	cltq
	imulq	$2002, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,8), %rdx
	leaq	memo(%rip), %rax
	movq	(%rdx,%rax), %rax
	jmp	.L6
.L11:
	movl	-40(%rbp), %ecx
	movl	-24(%rbp), %eax
	movl	$1, %edx
	movl	%ecx, %esi
	movl	%eax, %edi
	call	calc
	movq	%rax, %rcx
	movl	-36(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	a(%rip), %rax
	movl	(%rdx,%rax), %eax
	cltq
	addq	%rcx, %rax
	movq	%rax, -16(%rbp)
	movl	-20(%rbp), %ecx
	movl	-36(%rbp), %eax
	movl	$1, %edx
	movl	%ecx, %esi
	movl	%eax, %edi
	call	calc
	movq	%rax, %rcx
	movl	-40(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	a(%rip), %rax
	movl	(%rdx,%rax), %eax
	cltq
	addq	%rcx, %rax
	movq	%rax, -8(%rbp)
	movq	-8(%rbp), %rax
	cmpq	-16(%rbp), %rax
	jle	.L13
	movq	-8(%rbp), %rax
	movq	%rax, -16(%rbp)
.L13:
	movl	-40(%rbp), %eax
	movslq	%eax, %rdx
	movl	-36(%rbp), %eax
	cltq
	imulq	$2002, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,8), %rcx
	leaq	memo(%rip), %rdx
	movq	-16(%rbp), %rax
	movq	%rax, (%rcx,%rdx)
	movl	-40(%rbp), %eax
	movslq	%eax, %rdx
	movl	-36(%rbp), %eax
	cltq
	imulq	$2002, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,8), %rdx
	leaq	memo(%rip), %rax
	movq	(%rdx,%rax), %rax
.L6:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE1:
	.size	calc, .-calc
	.section	.rodata
.LC0:
	.string	"%lld\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB2:
	.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	$0, %eax
	call	in
	movl	%eax, n(%rip)
	movl	$0, -28(%rbp)
	jmp	.L15
.L16:
	movl	$0, %eax
	call	in
	movl	-28(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	a(%rip), %rdx
	movl	%eax, (%rcx,%rdx)
	addl	$1, -28(%rbp)
.L15:
	movl	n(%rip), %eax
	cmpl	%eax, -28(%rbp)
	jl	.L16
	movl	n(%rip), %edx
	movl	a(%rip), %eax
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	a(%rip), %rdx
	movl	%eax, (%rcx,%rdx)
	movq	$0, -16(%rbp)
	movl	$1, -24(%rbp)
	movl	n(%rip), %eax
	subl	$1, %eax
	movl	%eax, -20(%rbp)
	movl	$0, -28(%rbp)
	jmp	.L17
.L21:
	movl	n(%rip), %eax
	cmpl	%eax, -24(%rbp)
	jne	.L18
	movl	$0, -24(%rbp)
.L18:
	movl	n(%rip), %eax
	cmpl	%eax, -20(%rbp)
	jne	.L19
	movl	$0, -20(%rbp)
.L19:
	movl	-20(%rbp), %ecx
	movl	-24(%rbp), %eax
	movl	$1, %edx
	movl	%ecx, %esi
	movl	%eax, %edi
	call	calc
	movq	%rax, %rcx
	movl	-28(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	a(%rip), %rax
	movl	(%rdx,%rax), %eax
	cltq
	addq	%rcx, %rax
	subq	$1, %rax
	movq	%rax, -8(%rbp)
	movq	-8(%rbp), %rax
	cmpq	-16(%rbp), %rax
	jle	.L20
	movq	-8(%rbp), %rax
	movq	%rax, -16(%rbp)
.L20:
	addl	$1, -24(%rbp)
	addl	$1, -20(%rbp)
	addl	$1, -28(%rbp)
.L17:
	movl	n(%rip), %eax
	cmpl	%eax, -28(%rbp)
	jl	.L21
	movq	-16(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE2:
	.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	a
	.align 32
	.type	a, @object
	.size	a, 8008
a:
	.zero	8008
	.globl	memo
	.align 32
	.type	memo, @object
	.size	memo, 32064032
memo:
	.zero	32064032
	.text
	.globl	in
	.type	in, @function
in:
.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
	movl	$0, -8(%rbp)
	call	getchar_unlocked@PLT
	movl	%eax, -4(%rbp)
.L2:
	movl	-8(%rbp), %edx
	movl	%edx, %eax
	sall	$2, %eax
	addl	%edx, %eax
	addl	%eax, %eax
	movl	%eax, %edx
	movl	-4(%rbp), %eax
	andl	$15, %eax
	addl	%edx, %eax
	movl	%eax, -8(%rbp)
	call	getchar_unlocked@PLT
	movl	%eax, -4(%rbp)
	cmpl	$47, -4(%rbp)
	jg	.L2
	movl	-8(%rbp), %eax
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	in, .-in
	.globl	calc
	.type	calc, @function
calc:
.LFB1:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$48, %rsp
	movl	%edi, -36(%rbp)
	movl	%esi, -40(%rbp)
	movl	%edx, -44(%rbp)
	movl	-40(%rbp), %eax
	movslq	%eax, %rdx
	movl	-36(%rbp), %eax
	cltq
	imulq	$2002, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,8), %rdx
	leaq	memo(%rip), %rax
	movq	(%rdx,%rax), %rax
	testq	%rax, %rax
	je	.L5
	movl	-40(%rbp), %eax
	movslq	%eax, %rdx
	movl	-36(%rbp), %eax
	cltq
	imulq	$2002, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,8), %rdx
	leaq	memo(%rip), %rax
	movq	(%rdx,%rax), %rax
	jmp	.L6
.L5:
	movl	-36(%rbp), %eax
	cmpl	-40(%rbp), %eax
	jne	.L7
	cmpl	$0, -44(%rbp)
	je	.L8
	movl	-40(%rbp), %eax
	movslq	%eax, %rdx
	movl	-36(%rbp), %eax
	cltq
	imulq	$2002, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,8), %rdx
	leaq	memo(%rip), %rax
	movq	$1, (%rdx,%rax)
	movl	-40(%rbp), %eax
	movslq	%eax, %rdx
	movl	-36(%rbp), %eax
	cltq
	imulq	$2002, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,8), %rdx
	leaq	memo(%rip), %rax
	movq	(%rdx,%rax), %rax
	jmp	.L6
.L8:
	movl	-36(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	a(%rip), %rax
	movl	(%rdx,%rax), %eax
	addl	$1, %eax
	cltq
	movl	-40(%rbp), %edx
	movslq	%edx, %rcx
	movl	-36(%rbp), %edx
	movslq	%edx, %rdx
	imulq	$2002, %rdx, %rdx
	addq	%rcx, %rdx
	leaq	0(,%rdx,8), %rcx
	leaq	memo(%rip), %rdx
	movq	%rax, (%rcx,%rdx)
	movl	-40(%rbp), %eax
	movslq	%eax, %rdx
	movl	-36(%rbp), %eax
	cltq
	imulq	$2002, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,8), %rdx
	leaq	memo(%rip), %rax
	movq	(%rdx,%rax), %rax
	jmp	.L6
.L7:
	movl	-36(%rbp), %eax
	addl	$1, %eax
	movl	%eax, -24(%rbp)
	movl	n(%rip), %eax
	cmpl	%eax, -24(%rbp)
	jne	.L9
	movl	$0, -24(%rbp)
.L9:
	movl	-40(%rbp), %eax
	leal	-1(%rax), %edx
	movl	n(%rip), %eax
	addl	%edx, %eax
	movl	%eax, -20(%rbp)
	movl	n(%rip), %eax
	cmpl	%eax, -20(%rbp)
	jl	.L10
	movl	n(%rip), %eax
	subl	%eax, -20(%rbp)
.L10:
	cmpl	$0, -44(%rbp)
	je	.L11
	movl	-36(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	a(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	-40(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	a(%rip), %rax
	movl	(%rcx,%rax), %eax
	cmpl	%eax, %edx
	jle	.L12
	movl	-40(%rbp), %ecx
	movl	-24(%rbp), %eax
	movl	$0, %edx
	movl	%ecx, %esi
	movl	%eax, %edi
	call	calc
	movl	-40(%rbp), %edx
	movslq	%edx, %rcx
	movl	-36(%rbp), %edx
	movslq	%edx, %rdx
	imulq	$2002, %rdx, %rdx
	addq	%rcx, %rdx
	leaq	0(,%rdx,8), %rcx
	leaq	memo(%rip), %rdx
	movq	%rax, (%rcx,%rdx)
	movl	-40(%rbp), %eax
	movslq	%eax, %rdx
	movl	-36(%rbp), %eax
	cltq
	imulq	$2002, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,8), %rdx
	leaq	memo(%rip), %rax
	movq	(%rdx,%rax), %rax
	jmp	.L6
.L12:
	movl	-20(%rbp), %ecx
	movl	-36(%rbp), %eax
	movl	$0, %edx
	movl	%ecx, %esi
	movl	%eax, %edi
	call	calc
	movl	-40(%rbp), %edx
	movslq	%edx, %rcx
	movl	-36(%rbp), %edx
	movslq	%edx, %rdx
	imulq	$2002, %rdx, %rdx
	addq	%rcx, %rdx
	leaq	0(,%rdx,8), %rcx
	leaq	memo(%rip), %rdx
	movq	%rax, (%rcx,%rdx)
	movl	-40(%rbp), %eax
	movslq	%eax, %rdx
	movl	-36(%rbp), %eax
	cltq
	imulq	$2002, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,8), %rdx
	leaq	memo(%rip), %rax
	movq	(%rdx,%rax), %rax
	jmp	.L6
.L11:
	movl	-40(%rbp), %ecx
	movl	-24(%rbp), %eax
	movl	$1, %edx
	movl	%ecx, %esi
	movl	%eax, %edi
	call	calc
	movq	%rax, %rcx
	movl	-36(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	a(%rip), %rax
	movl	(%rdx,%rax), %eax
	cltq
	addq	%rcx, %rax
	movq	%rax, -16(%rbp)
	movl	-20(%rbp), %ecx
	movl	-36(%rbp), %eax
	movl	$1, %edx
	movl	%ecx, %esi
	movl	%eax, %edi
	call	calc
	movq	%rax, %rcx
	movl	-40(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	a(%rip), %rax
	movl	(%rdx,%rax), %eax
	cltq
	addq	%rcx, %rax
	movq	%rax, -8(%rbp)
	movq	-8(%rbp), %rax
	cmpq	-16(%rbp), %rax
	jle	.L13
	movq	-8(%rbp), %rax
	movq	%rax, -16(%rbp)
.L13:
	movl	-40(%rbp), %eax
	movslq	%eax, %rdx
	movl	-36(%rbp), %eax
	cltq
	imulq	$2002, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,8), %rcx
	leaq	memo(%rip), %rdx
	movq	-16(%rbp), %rax
	movq	%rax, (%rcx,%rdx)
	movl	-40(%rbp), %eax
	movslq	%eax, %rdx
	movl	-36(%rbp), %eax
	cltq
	imulq	$2002, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,8), %rdx
	leaq	memo(%rip), %rax
	movq	(%rdx,%rax), %rax
.L6:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE1:
	.size	calc, .-calc
	.section	.rodata
.LC0:
	.string	"%lld\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB2:
	.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	$0, %eax
	call	in
	movl	%eax, n(%rip)
	movl	$0, -28(%rbp)
	jmp	.L15
.L16:
	movl	$0, %eax
	call	in
	movl	-28(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	a(%rip), %rdx
	movl	%eax, (%rcx,%rdx)
	addl	$1, -28(%rbp)
.L15:
	movl	n(%rip), %eax
	cmpl	%eax, -28(%rbp)
	jl	.L16
	movl	n(%rip), %edx
	movl	a(%rip), %eax
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	a(%rip), %rdx
	movl	%eax, (%rcx,%rdx)
	movq	$0, -16(%rbp)
	movl	$1, -24(%rbp)
	movl	n(%rip), %eax
	subl	$1, %eax
	movl	%eax, -20(%rbp)
	movl	$0, -28(%rbp)
	jmp	.L17
.L21:
	movl	n(%rip), %eax
	cmpl	%eax, -24(%rbp)
	jne	.L18
	movl	$0, -24(%rbp)
.L18:
	movl	n(%rip), %eax
	cmpl	%eax, -20(%rbp)
	jne	.L19
	movl	$0, -20(%rbp)
.L19:
	movl	-20(%rbp), %ecx
	movl	-24(%rbp), %eax
	movl	$1, %edx
	movl	%ecx, %esi
	movl	%eax, %edi
	call	calc
	movq	%rax, %rcx
	movl	-28(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	a(%rip), %rax
	movl	(%rdx,%rax), %eax
	cltq
	addq	%rcx, %rax
	subq	$1, %rax
	movq	%rax, -8(%rbp)
	movq	-8(%rbp), %rax
	cmpq	-16(%rbp), %rax
	jle	.L20
	movq	-8(%rbp), %rax
	movq	%rax, -16(%rbp)
.L20:
	addl	$1, -24(%rbp)
	addl	$1, -20(%rbp)
	addl	$1, -28(%rbp)
.L17:
	movl	n(%rip), %eax
	cmpl	%eax, -28(%rbp)
	jl	.L21
	movq	-16(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE2:
	.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:
