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>
#define rep(i, l, r) for (int i = l; i < r; i++)
#define max(a,b) (a > b ? a : b)
#define MAX 100001

int main(void) {
  int n;
  scanf("%d", &n);
  int v[MAX];
  rep(i, 0, n)
    scanf("%d", &v[i]);
  
  /* 最頻値を数える */
  int mode1[MAX] = {0};
  int mode2[MAX] = {0};
  // 奇数列
  for (int i = 0; i < n; i += 2)
    mode1[v[i]]++;
  // 偶数列
  for (int i = 1; i < n; i += 2)
    mode2[v[i]]++;

  int max1[2] = {0}, next1 = 0;  // max[頻度][数], 2番目の頻値
  int max2[2] = {0}, next2 = 0; 
  rep(i, 0, MAX) {
    if (mode1[i] > max1[0]) {
      next1 = max1[0];
      max1[0] = mode1[i];
      max1[1] = i;
    } else if (mode1[i] > next1) {
      next1 = mode1[i];
    }
  }
  rep(i, 0, MAX) {
    if (mode2[i] > max2[0]) {
      next2 = max2[0];
      max2[0] = mode2[i];
      max2[1] = i;
    } else if (mode2[i] > next2) {
      next2 = mode2[i];
    }
  }
  
  int ans;
  if (max1[1] == max2[1]) {
    // if (next1 > next2) 
    //   ans = n - next1 - max2[0];
    // else
    //   ans = n - next2 - max1[0]; 
    ans = n - max(next1 + max2[0], next2 + max1[0]);
  } else
    ans = n - max1[0] - max2[0];
  printf("%d\n", ans);
  return 0;
}
```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.string	"%d"
.LC1:
	.string	"%d\n"
	.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
	leaq	-1196032(%rsp), %r11
.LPSRL0:
	subq	$4096, %rsp
	orq	$0, (%rsp)
	cmpq	%r11, %rsp
	jne	.LPSRL0
	subq	$4080, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	leaq	-1200100(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -1200096(%rbp)
	jmp	.L2
.L3:
	leaq	-1200048(%rbp), %rdx
	movl	-1200096(%rbp), %eax
	cltq
	salq	$2, %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -1200096(%rbp)
.L2:
	movl	-1200100(%rbp), %eax
	cmpl	%eax, -1200096(%rbp)
	jl	.L3
	leaq	-800032(%rbp), %rax
	movl	$400004, %edx
	movl	$0, %esi
	movq	%rax, %rdi
	call	memset@PLT
	leaq	-400016(%rbp), %rax
	movl	$400004, %edx
	movl	$0, %esi
	movq	%rax, %rdi
	call	memset@PLT
	movl	$0, -1200092(%rbp)
	jmp	.L4
.L5:
	movl	-1200092(%rbp), %eax
	cltq
	movl	-1200048(%rbp,%rax,4), %eax
	movslq	%eax, %rdx
	movl	-800032(%rbp,%rdx,4), %edx
	addl	$1, %edx
	cltq
	movl	%edx, -800032(%rbp,%rax,4)
	addl	$2, -1200092(%rbp)
.L4:
	movl	-1200100(%rbp), %eax
	cmpl	%eax, -1200092(%rbp)
	jl	.L5
	movl	$1, -1200088(%rbp)
	jmp	.L6
.L7:
	movl	-1200088(%rbp), %eax
	cltq
	movl	-1200048(%rbp,%rax,4), %eax
	movslq	%eax, %rdx
	movl	-400016(%rbp,%rdx,4), %edx
	addl	$1, %edx
	cltq
	movl	%edx, -400016(%rbp,%rax,4)
	addl	$2, -1200088(%rbp)
.L6:
	movl	-1200100(%rbp), %eax
	cmpl	%eax, -1200088(%rbp)
	jl	.L7
	movq	$0, -1200064(%rbp)
	movl	$0, -1200084(%rbp)
	movq	$0, -1200056(%rbp)
	movl	$0, -1200080(%rbp)
	movl	$0, -1200076(%rbp)
	jmp	.L8
.L11:
	movl	-1200076(%rbp), %eax
	cltq
	movl	-800032(%rbp,%rax,4), %edx
	movl	-1200064(%rbp), %eax
	cmpl	%eax, %edx
	jle	.L9
	movl	-1200064(%rbp), %eax
	movl	%eax, -1200084(%rbp)
	movl	-1200076(%rbp), %eax
	cltq
	movl	-800032(%rbp,%rax,4), %eax
	movl	%eax, -1200064(%rbp)
	movl	-1200076(%rbp), %eax
	movl	%eax, -1200060(%rbp)
	jmp	.L10
.L9:
	movl	-1200076(%rbp), %eax
	cltq
	movl	-800032(%rbp,%rax,4), %eax
	cmpl	%eax, -1200084(%rbp)
	jge	.L10
	movl	-1200076(%rbp), %eax
	cltq
	movl	-800032(%rbp,%rax,4), %eax
	movl	%eax, -1200084(%rbp)
.L10:
	addl	$1, -1200076(%rbp)
.L8:
	cmpl	$100000, -1200076(%rbp)
	jle	.L11
	movl	$0, -1200072(%rbp)
	jmp	.L12
.L15:
	movl	-1200072(%rbp), %eax
	cltq
	movl	-400016(%rbp,%rax,4), %edx
	movl	-1200056(%rbp), %eax
	cmpl	%eax, %edx
	jle	.L13
	movl	-1200056(%rbp), %eax
	movl	%eax, -1200080(%rbp)
	movl	-1200072(%rbp), %eax
	cltq
	movl	-400016(%rbp,%rax,4), %eax
	movl	%eax, -1200056(%rbp)
	movl	-1200072(%rbp), %eax
	movl	%eax, -1200052(%rbp)
	jmp	.L14
.L13:
	movl	-1200072(%rbp), %eax
	cltq
	movl	-400016(%rbp,%rax,4), %eax
	cmpl	%eax, -1200080(%rbp)
	jge	.L14
	movl	-1200072(%rbp), %eax
	cltq
	movl	-400016(%rbp,%rax,4), %eax
	movl	%eax, -1200080(%rbp)
.L14:
	addl	$1, -1200072(%rbp)
.L12:
	cmpl	$100000, -1200072(%rbp)
	jle	.L15
	movl	-1200060(%rbp), %edx
	movl	-1200052(%rbp), %eax
	cmpl	%eax, %edx
	jne	.L16
	movl	-1200100(%rbp), %ecx
	movl	-1200064(%rbp), %edx
	movl	-1200080(%rbp), %eax
	addl	%eax, %edx
	movl	-1200056(%rbp), %esi
	movl	-1200084(%rbp), %eax
	addl	%esi, %eax
	cmpl	%eax, %edx
	cmovl	%eax, %edx
	movl	%ecx, %eax
	subl	%edx, %eax
	movl	%eax, -1200068(%rbp)
	jmp	.L17
.L16:
	movl	-1200100(%rbp), %eax
	movl	-1200064(%rbp), %edx
	subl	%edx, %eax
	movl	-1200056(%rbp), %edx
	subl	%edx, %eax
	movl	%eax, -1200068(%rbp)
.L17:
	movl	-1200068(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L19
	call	__stack_chk_fail@PLT
.L19:
	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	"%d\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB23:
	.cfi_startproc
	endbr64
	pushq	%r14
	.cfi_def_cfa_offset 16
	.cfi_offset 14, -16
	pushq	%r13
	.cfi_def_cfa_offset 24
	.cfi_offset 13, -24
	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
	leaq	-1196032(%rsp), %r11
	.cfi_def_cfa 11, 1196080
.LPSRL0:
	subq	$4096, %rsp
	orq	$0, (%rsp)
	cmpq	%r11, %rsp
	jne	.LPSRL0
	.cfi_def_cfa_register 7
	subq	$4032, %rsp
	.cfi_def_cfa_offset 1200112
	leaq	.LC0(%rip), %r14
	movq	%r14, %rdi
	movq	%fs:40, %rax
	movq	%rax, 1200056(%rsp)
	xorl	%eax, %eax
	leaq	12(%rsp), %rsi
	call	__isoc99_scanf@PLT
	movl	12(%rsp), %ebx
	testl	%ebx, %ebx
	jle	.L2
	leaq	16(%rsp), %r13
	xorl	%ebp, %ebp
	movq	%r13, %r12
	.p2align 4,,10
	.p2align 3
.L3:
	movq	%r12, %rsi
	movq	%r14, %rdi
	xorl	%eax, %eax
	addl	$1, %ebp
	call	__isoc99_scanf@PLT
	movl	12(%rsp), %ebx
	addq	$4, %r12
	cmpl	%ebp, %ebx
	jg	.L3
	leaq	400032(%rsp), %rbp
	movl	$400004, %edx
	xorl	%esi, %esi
	movq	%rbp, %rdi
	call	memset@PLT
	leaq	800048(%rsp), %r9
	movl	$400004, %edx
	xorl	%esi, %esi
	movq	%r9, %rdi
	call	memset@PLT
	movq	%rax, %r9
	testl	%ebx, %ebx
	jle	.L7
	leal	-1(%rbx), %edx
	leaq	8(%r13), %rax
	shrl	%edx
	leaq	(%rax,%rdx,8), %rcx
	jmp	.L5
	.p2align 4,,10
	.p2align 3
.L26:
	addq	$8, %rax
.L5:
	movslq	0(%r13), %rdx
	movq	%rax, %r13
	addl	$1, 400032(%rsp,%rdx,4)
	cmpq	%rcx, %rax
	jne	.L26
	cmpl	$1, %ebx
	jle	.L7
	leal	-2(%rbx), %edx
	leaq	20(%rsp), %rax
	shrl	%edx
	leaq	28(%rsp,%rdx,8), %rcx
	.p2align 4,,10
	.p2align 3
.L6:
	movslq	(%rax), %rdx
	addq	$8, %rax
	addl	$1, 800048(%rsp,%rdx,4)
	cmpq	%rcx, %rax
	jne	.L6
.L7:
	xorl	%eax, %eax
	xorl	%r10d, %r10d
	xorl	%edi, %edi
	xorl	%r8d, %r8d
	jmp	.L9
	.p2align 4,,10
	.p2align 3
.L28:
	cmpl	%edx, %r8d
	cmovl	%edx, %r8d
	addq	$1, %rax
	cmpq	$100001, %rax
	je	.L27
.L9:
	movl	0(%rbp,%rax,4), %edx
	cmpl	%edx, %edi
	jge	.L28
	movl	%eax, %r10d
	addq	$1, %rax
	movl	%edi, %r8d
	movl	%edx, %edi
	cmpq	$100001, %rax
	jne	.L9
.L27:
	xorl	%eax, %eax
	xorl	%r11d, %r11d
	xorl	%ecx, %ecx
	xorl	%esi, %esi
	jmp	.L11
	.p2align 4,,10
	.p2align 3
.L30:
	cmpl	%edx, %esi
	cmovl	%edx, %esi
	addq	$1, %rax
	cmpq	$100001, %rax
	je	.L29
.L11:
	movl	(%r9,%rax,4), %edx
	cmpl	%ecx, %edx
	jle	.L30
	movl	%eax, %r11d
	addq	$1, %rax
	movl	%ecx, %esi
	movl	%edx, %ecx
	cmpq	$100001, %rax
	jne	.L11
.L29:
	movl	%ebx, %edx
	subl	%edi, %edx
	subl	%ecx, %edx
	cmpl	%r10d, %r11d
	jne	.L13
	addl	%edi, %esi
	addl	%r8d, %ecx
	cmpl	%ecx, %esi
	cmovl	%ecx, %esi
	subl	%esi, %ebx
	movl	%ebx, %edx
.L13:
	xorl	%eax, %eax
	leaq	.LC1(%rip), %rsi
	movl	$1, %edi
	call	__printf_chk@PLT
	movq	1200056(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L31
	addq	$1200064, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 48
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 40
	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
.L2:
	.cfi_restore_state
	leaq	400032(%rsp), %rbp
	movl	$400004, %edx
	xorl	%esi, %esi
	movq	%rbp, %rdi
	call	memset@PLT
	leaq	800048(%rsp), %r9
	movl	$400004, %edx
	xorl	%esi, %esi
	movq	%r9, %rdi
	call	memset@PLT
	movq	%rax, %r9
	jmp	.L7
.L31:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE23:
	.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:

rule
	.file	"temp.c"
	.text
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d"
.LC1:
	.string	"%d\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB23:
	.cfi_startproc
	endbr64
	pushq	%r14
	.cfi_def_cfa_offset 16
	.cfi_offset 14, -16
	pushq	%r13
	.cfi_def_cfa_offset 24
	.cfi_offset 13, -24
	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
	leaq	-1196032(%rsp), %r11
	.cfi_def_cfa 11, 1196080
.LPSRL0:
	subq	$4096, %rsp
	orq	$0, (%rsp)
	cmpq	%r11, %rsp
	jne	.LPSRL0
	.cfi_def_cfa_register 7
	subq	$4032, %rsp
	.cfi_def_cfa_offset 1200112
	leaq	.LC0(%rip), %r14
	movq	%r14, %rdi
	movq	%fs:40, %rax
	movq	%rax, 1200056(%rsp)
	xorl	%eax, %eax
	leaq	12(%rsp), %rsi
	call	__isoc99_scanf@PLT
	movl	12(%rsp), %ebx
	testl	%ebx, %ebx
	jle	.L2
	leaq	16(%rsp), %r13
	xorl	%ebp, %ebp
	movq	%r13, %r12
	.p2align 4,,10
	.p2align 3
.L3:
	movq	%r12, %rsi
	movq	%r14, %rdi
	xorl	%eax, %eax
	addl	$1, %ebp
	call	__isoc99_scanf@PLT
	movl	12(%rsp), %ebx
	addq	$4, %r12
	cmpl	%ebp, %ebx
	jg	.L3
	leaq	400032(%rsp), %rbp
	movl	$400004, %edx
	xorl	%esi, %esi
	movq	%rbp, %rdi
	call	memset@PLT
	leaq	800048(%rsp), %r9
	movl	$400004, %edx
	xorl	%esi, %esi
	movq	%r9, %rdi
	call	memset@PLT
	movq	%rax, %r9
	testl	%ebx, %ebx
	jle	.L7
	leal	-1(%rbx), %edx
	leaq	8(%r13), %rax
	shrl	%edx
	leaq	(%rax,%rdx,8), %rcx
	jmp	.L5
	.p2align 4,,10
	.p2align 3
.L26:
	addq	$8, %rax
.L5:
	movslq	0(%r13), %rdx
	movq	%rax, %r13
	addl	$1, 400032(%rsp,%rdx,4)
	cmpq	%rcx, %rax
	jne	.L26
	cmpl	$1, %ebx
	jle	.L7
	leal	-2(%rbx), %edx
	leaq	20(%rsp), %rax
	shrl	%edx
	leaq	28(%rsp,%rdx,8), %rcx
	.p2align 4,,10
	.p2align 3
.L6:
	movslq	(%rax), %rdx
	addq	$8, %rax
	addl	$1, 800048(%rsp,%rdx,4)
	cmpq	%rcx, %rax
	jne	.L6
.L7:
	xorl	%eax, %eax
	xorl	%r10d, %r10d
	xorl	%edi, %edi
	xorl	%r8d, %r8d
	jmp	.L9
	.p2align 4,,10
	.p2align 3
.L28:
	cmpl	%edx, %r8d
	cmovl	%edx, %r8d
	addq	$1, %rax
	cmpq	$100001, %rax
	je	.L27
.L9:
	movl	0(%rbp,%rax,4), %edx
	cmpl	%edx, %edi
	jge	.L28
	movl	%eax, %r10d
	addq	$1, %rax
	movl	%edi, %r8d
	movl	%edx, %edi
	cmpq	$100001, %rax
	jne	.L9
.L27:
	xorl	%eax, %eax
	xorl	%r11d, %r11d
	xorl	%ecx, %ecx
	xorl	%esi, %esi
	jmp	.L11
	.p2align 4,,10
	.p2align 3
.L30:
	cmpl	%edx, %esi
	cmovl	%edx, %esi
	addq	$1, %rax
	cmpq	$100001, %rax
	je	.L29
.L11:
	movl	(%r9,%rax,4), %edx
	cmpl	%ecx, %edx
	jle	.L30
	movl	%eax, %r11d
	addq	$1, %rax
	movl	%ecx, %esi
	movl	%edx, %ecx
	cmpq	$100001, %rax
	jne	.L11
.L29:
	movl	%ebx, %edx
	subl	%edi, %edx
	subl	%ecx, %edx
	cmpl	%r10d, %r11d
	jne	.L13
	addl	%edi, %esi
	addl	%r8d, %ecx
	cmpl	%ecx, %esi
	cmovl	%ecx, %esi
	subl	%esi, %ebx
	movl	%ebx, %edx
.L13:
	xorl	%eax, %eax
	leaq	.LC1(%rip), %rsi
	movl	$1, %edi
	call	__printf_chk@PLT
	movq	1200056(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L31
	addq	$1200064, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 48
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 40
	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
.L2:
	.cfi_restore_state
	leaq	400032(%rsp), %rbp
	movl	$400004, %edx
	xorl	%esi, %esi
	movq	%rbp, %rdi
	call	memset@PLT
	leaq	800048(%rsp), %r9
	movl	$400004, %edx
	xorl	%esi, %esi
	movq	%r9, %rdi
	call	memset@PLT
	movq	%rax, %r9
	jmp	.L7
.L31:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE23:
	.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:

#include <stdio.h>
#define rep(i, l, r) for (int i = l; i < r; i++)
#define max(a,b) (a > b ? a : b)
#define MAX 100001

int main(void) {
  int n;
  scanf("%d", &n);
  int v[MAX];
  rep(i, 0, n)
    scanf("%d", &v[i]);
  
  /* 最頻値を数える */
  int mode1[MAX] = {0};
  int mode2[MAX] = {0};
  // 奇数列
  for (int i = 0; i < n; i += 2)
    mode1[v[i]]++;
  // 偶数列
  for (int i = 1; i < n; i += 2)
    mode2[v[i]]++;

  int max1[2] = {0}, next1 = 0;  // max[頻度][数], 2番目の頻値
  int max2[2] = {0}, next2 = 0; 
  rep(i, 0, MAX) {
    if (mode1[i] > max1[0]) {
      next1 = max1[0];
      max1[0] = mode1[i];
      max1[1] = i;
    } else if (mode1[i] > next1) {
      next1 = mode1[i];
    }
  }
  rep(i, 0, MAX) {
    if (mode2[i] > max2[0]) {
      next2 = max2[0];
      max2[0] = mode2[i];
      max2[1] = i;
    } else if (mode2[i] > next2) {
      next2 = mode2[i];
    }
  }
  
  int ans;
  if (max1[1] == max2[1]) {
    // if (next1 > next2) 
    //   ans = n - next1 - max2[0];
    // else
    //   ans = n - next2 - max1[0]; 
    ans = n - max(next1 + max2[0], next2 + max1[0]);
  } else
    ans = n - max1[0] - max2[0];
  printf("%d\n", ans);
  return 0;
}

4
3 2 3 2
 6
105 119 204 119 105 119
 4
4 1 3 2
 6
105 120 54 119 105 78
 6
105 120 54 119 190 78
 6
105 119 204 119 105 78
 4
4 1 3 0
 6
105 119 54 119 105 78
 4
4 1 3 1
 4
4 1 6 1

0
 1
 2
 3
 4
 2
 2
 2
 1
 1

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>
#define rep(i, l, r) for (int i = l; i < r; i++)
#define max(a,b) (a > b ? a : b)
#define MAX 100001

int main(void) {
  int n;
  scanf("%d", &n);
  int v[MAX];
  rep(i, 0, n)
    scanf("%d", &v[i]);
  
  /* 最頻値を数える */
  int mode1[MAX] = {0};
  int mode2[MAX] = {0};
  // 奇数列
  for (int i = 0; i < n; i += 2)
    mode1[v[i]]++;
  // 偶数列
  for (int i = 1; i < n; i += 2)
    mode2[v[i]]++;

  int max1[2] = {0}, next1 = 0;  // max[頻度][数], 2番目の頻値
  int max2[2] = {0}, next2 = 0; 
  rep(i, 0, MAX) {
    if (mode1[i] > max1[0]) {
      next1 = max1[0];
      max1[0] = mode1[i];
      max1[1] = i;
    } else if (mode1[i] > next1) {
      next1 = mode1[i];
    }
  }
  rep(i, 0, MAX) {
    if (mode2[i] > max2[0]) {
      next2 = max2[0];
      max2[0] = mode2[i];
      max2[1] = i;
    } else if (mode2[i] > next2) {
      next2 = mode2[i];
    }
  }
  
  int ans;
  if (max1[1] == max2[1]) {
    // if (next1 > next2) 
    //   ans = n - next1 - max2[0];
    // else
    //   ans = n - next2 - max1[0]; 
    ans = n - max(next1 + max2[0], next2 + max1[0]);
  } else
    ans = n - max1[0] - max2[0];
  printf("%d\n", ans);
  return 0;
}
```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.string	"%d"
.LC1:
	.string	"%d\n"
	.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
	leaq	-1196032(%rsp), %r11
.LPSRL0:
	subq	$4096, %rsp
	orq	$0, (%rsp)
	cmpq	%r11, %rsp
	jne	.LPSRL0
	subq	$4080, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	leaq	-1200100(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -1200096(%rbp)
	jmp	.L2
.L3:
	leaq	-1200048(%rbp), %rdx
	movl	-1200096(%rbp), %eax
	cltq
	salq	$2, %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -1200096(%rbp)
.L2:
	movl	-1200100(%rbp), %eax
	cmpl	%eax, -1200096(%rbp)
	jl	.L3
	leaq	-800032(%rbp), %rax
	movl	$400004, %edx
	movl	$0, %esi
	movq	%rax, %rdi
	call	memset@PLT
	leaq	-400016(%rbp), %rax
	movl	$400004, %edx
	movl	$0, %esi
	movq	%rax, %rdi
	call	memset@PLT
	movl	$0, -1200092(%rbp)
	jmp	.L4
.L5:
	movl	-1200092(%rbp), %eax
	cltq
	movl	-1200048(%rbp,%rax,4), %eax
	movslq	%eax, %rdx
	movl	-800032(%rbp,%rdx,4), %edx
	addl	$1, %edx
	cltq
	movl	%edx, -800032(%rbp,%rax,4)
	addl	$2, -1200092(%rbp)
.L4:
	movl	-1200100(%rbp), %eax
	cmpl	%eax, -1200092(%rbp)
	jl	.L5
	movl	$1, -1200088(%rbp)
	jmp	.L6
.L7:
	movl	-1200088(%rbp), %eax
	cltq
	movl	-1200048(%rbp,%rax,4), %eax
	movslq	%eax, %rdx
	movl	-400016(%rbp,%rdx,4), %edx
	addl	$1, %edx
	cltq
	movl	%edx, -400016(%rbp,%rax,4)
	addl	$2, -1200088(%rbp)
.L6:
	movl	-1200100(%rbp), %eax
	cmpl	%eax, -1200088(%rbp)
	jl	.L7
	movq	$0, -1200064(%rbp)
	movl	$0, -1200084(%rbp)
	movq	$0, -1200056(%rbp)
	movl	$0, -1200080(%rbp)
	movl	$0, -1200076(%rbp)
	jmp	.L8
.L11:
	movl	-1200076(%rbp), %eax
	cltq
	movl	-800032(%rbp,%rax,4), %edx
	movl	-1200064(%rbp), %eax
	cmpl	%eax, %edx
	jle	.L9
	movl	-1200064(%rbp), %eax
	movl	%eax, -1200084(%rbp)
	movl	-1200076(%rbp), %eax
	cltq
	movl	-800032(%rbp,%rax,4), %eax
	movl	%eax, -1200064(%rbp)
	movl	-1200076(%rbp), %eax
	movl	%eax, -1200060(%rbp)
	jmp	.L10
.L9:
	movl	-1200076(%rbp), %eax
	cltq
	movl	-800032(%rbp,%rax,4), %eax
	cmpl	%eax, -1200084(%rbp)
	jge	.L10
	movl	-1200076(%rbp), %eax
	cltq
	movl	-800032(%rbp,%rax,4), %eax
	movl	%eax, -1200084(%rbp)
.L10:
	addl	$1, -1200076(%rbp)
.L8:
	cmpl	$100000, -1200076(%rbp)
	jle	.L11
	movl	$0, -1200072(%rbp)
	jmp	.L12
.L15:
	movl	-1200072(%rbp), %eax
	cltq
	movl	-400016(%rbp,%rax,4), %edx
	movl	-1200056(%rbp), %eax
	cmpl	%eax, %edx
	jle	.L13
	movl	-1200056(%rbp), %eax
	movl	%eax, -1200080(%rbp)
	movl	-1200072(%rbp), %eax
	cltq
	movl	-400016(%rbp,%rax,4), %eax
	movl	%eax, -1200056(%rbp)
	movl	-1200072(%rbp), %eax
	movl	%eax, -1200052(%rbp)
	jmp	.L14
.L13:
	movl	-1200072(%rbp), %eax
	cltq
	movl	-400016(%rbp,%rax,4), %eax
	cmpl	%eax, -1200080(%rbp)
	jge	.L14
	movl	-1200072(%rbp), %eax
	cltq
	movl	-400016(%rbp,%rax,4), %eax
	movl	%eax, -1200080(%rbp)
.L14:
	addl	$1, -1200072(%rbp)
.L12:
	cmpl	$100000, -1200072(%rbp)
	jle	.L15
	movl	-1200060(%rbp), %edx
	movl	-1200052(%rbp), %eax
	cmpl	%eax, %edx
	jne	.L16
	movl	-1200100(%rbp), %ecx
	movl	-1200064(%rbp), %edx
	movl	-1200080(%rbp), %eax
	addl	%eax, %edx
	movl	-1200056(%rbp), %esi
	movl	-1200084(%rbp), %eax
	addl	%esi, %eax
	cmpl	%eax, %edx
	cmovl	%eax, %edx
	movl	%ecx, %eax
	subl	%edx, %eax
	movl	%eax, -1200068(%rbp)
	jmp	.L17
.L16:
	movl	-1200100(%rbp), %eax
	movl	-1200064(%rbp), %edx
	subl	%edx, %eax
	movl	-1200056(%rbp), %edx
	subl	%edx, %eax
	movl	%eax, -1200068(%rbp)
.L17:
	movl	-1200068(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L19
	call	__stack_chk_fail@PLT
.L19:
	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
	.section	.rodata
.LC0:
	.string	"%d"
.LC1:
	.string	"%d\n"
	.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
	leaq	-1196032(%rsp), %r11
.LPSRL0:
	subq	$4096, %rsp
	orq	$0, (%rsp)
	cmpq	%r11, %rsp
	jne	.LPSRL0
	subq	$4080, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	leaq	-1200100(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -1200096(%rbp)
	jmp	.L2
.L3:
	leaq	-1200048(%rbp), %rdx
	movl	-1200096(%rbp), %eax
	cltq
	salq	$2, %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -1200096(%rbp)
.L2:
	movl	-1200100(%rbp), %eax
	cmpl	%eax, -1200096(%rbp)
	jl	.L3
	leaq	-800032(%rbp), %rax
	movl	$400004, %edx
	movl	$0, %esi
	movq	%rax, %rdi
	call	memset@PLT
	leaq	-400016(%rbp), %rax
	movl	$400004, %edx
	movl	$0, %esi
	movq	%rax, %rdi
	call	memset@PLT
	movl	$0, -1200092(%rbp)
	jmp	.L4
.L5:
	movl	-1200092(%rbp), %eax
	cltq
	movl	-1200048(%rbp,%rax,4), %eax
	movslq	%eax, %rdx
	movl	-800032(%rbp,%rdx,4), %edx
	addl	$1, %edx
	cltq
	movl	%edx, -800032(%rbp,%rax,4)
	addl	$2, -1200092(%rbp)
.L4:
	movl	-1200100(%rbp), %eax
	cmpl	%eax, -1200092(%rbp)
	jl	.L5
	movl	$1, -1200088(%rbp)
	jmp	.L6
.L7:
	movl	-1200088(%rbp), %eax
	cltq
	movl	-1200048(%rbp,%rax,4), %eax
	movslq	%eax, %rdx
	movl	-400016(%rbp,%rdx,4), %edx
	addl	$1, %edx
	cltq
	movl	%edx, -400016(%rbp,%rax,4)
	addl	$2, -1200088(%rbp)
.L6:
	movl	-1200100(%rbp), %eax
	cmpl	%eax, -1200088(%rbp)
	jl	.L7
	movq	$0, -1200064(%rbp)
	movl	$0, -1200084(%rbp)
	movq	$0, -1200056(%rbp)
	movl	$0, -1200080(%rbp)
	movl	$0, -1200076(%rbp)
	jmp	.L8
.L11:
	movl	-1200076(%rbp), %eax
	cltq
	movl	-800032(%rbp,%rax,4), %edx
	movl	-1200064(%rbp), %eax
	cmpl	%eax, %edx
	jle	.L9
	movl	-1200064(%rbp), %eax
	movl	%eax, -1200084(%rbp)
	movl	-1200076(%rbp), %eax
	cltq
	movl	-800032(%rbp,%rax,4), %eax
	movl	%eax, -1200064(%rbp)
	movl	-1200076(%rbp), %eax
	movl	%eax, -1200060(%rbp)
	jmp	.L10
.L9:
	movl	-1200076(%rbp), %eax
	cltq
	movl	-800032(%rbp,%rax,4), %eax
	cmpl	%eax, -1200084(%rbp)
	jge	.L10
	movl	-1200076(%rbp), %eax
	cltq
	movl	-800032(%rbp,%rax,4), %eax
	movl	%eax, -1200084(%rbp)
.L10:
	addl	$1, -1200076(%rbp)
.L8:
	cmpl	$100000, -1200076(%rbp)
	jle	.L11
	movl	$0, -1200072(%rbp)
	jmp	.L12
.L15:
	movl	-1200072(%rbp), %eax
	cltq
	movl	-400016(%rbp,%rax,4), %edx
	movl	-1200056(%rbp), %eax
	cmpl	%eax, %edx
	jle	.L13
	movl	-1200056(%rbp), %eax
	movl	%eax, -1200080(%rbp)
	movl	-1200072(%rbp), %eax
	cltq
	movl	-400016(%rbp,%rax,4), %eax
	movl	%eax, -1200056(%rbp)
	movl	-1200072(%rbp), %eax
	movl	%eax, -1200052(%rbp)
	jmp	.L14
.L13:
	movl	-1200072(%rbp), %eax
	cltq
	movl	-400016(%rbp,%rax,4), %eax
	cmpl	%eax, -1200080(%rbp)
	jge	.L14
	movl	-1200072(%rbp), %eax
	cltq
	movl	-400016(%rbp,%rax,4), %eax
	movl	%eax, -1200080(%rbp)
.L14:
	addl	$1, -1200072(%rbp)
.L12:
	cmpl	$100000, -1200072(%rbp)
	jle	.L15
	movl	-1200060(%rbp), %edx
	movl	-1200052(%rbp), %eax
	cmpl	%eax, %edx
	jne	.L16
	movl	-1200100(%rbp), %ecx
	movl	-1200064(%rbp), %edx
	movl	-1200080(%rbp), %eax
	addl	%eax, %edx
	movl	-1200056(%rbp), %esi
	movl	-1200084(%rbp), %eax
	addl	%esi, %eax
	cmpl	%eax, %edx
	cmovl	%eax, %edx
	movl	%ecx, %eax
	subl	%edx, %eax
	movl	%eax, -1200068(%rbp)
	jmp	.L17
.L16:
	movl	-1200100(%rbp), %eax
	movl	-1200064(%rbp), %edx
	subl	%edx, %eax
	movl	-1200056(%rbp), %edx
	subl	%edx, %eax
	movl	%eax, -1200068(%rbp)
.L17:
	movl	-1200068(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L19
	call	__stack_chk_fail@PLT
.L19:
	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:
