Problem:
Score : 300 points

Problem Statement

A sequence a_1,a_2,... ,a_n is said to be /\/\/\/ when the following conditions are satisfied:

For each i = 1,2,..., n-2, a_i = a_{i+2}.

Exactly two different numbers appear in the sequence.

You are given a sequence v_1,v_2,...,v_n whose length is even.
We would like to make this sequence /\/\/\/ by replacing some of its elements.
Find the minimum number of elements that needs to be replaced.

Constraints

2 \leq n \leq 10^5

n is even.

1 \leq v_i \leq 10^5

v_i is an integer.

Input

Input is given from Standard Input in the following format:

n
v_1 v_2 ... v_n

Output

Print the minimum number of elements that needs to be replaced.

Sample Input 1

4
3 1 3 2

Sample Output 1

1

The sequence 3,1,3,2 is not /\/\/\/, but we can make it /\/\/\/ by replacing one of its elements: for example, replace the fourth element to make it 3,1,3,1.

Sample Input 2

6
105 119 105 119 105 119

Sample Output 2

0

The sequence 105,119,105,119,105,119 is /\/\/\/.

Sample Input 3

4
1 1 1 1

Sample Output 3

2

The elements of the sequence 1,1,1,1 are all the same, so it is not /\/\/\/.

Solution in C (GCC 5.4.1) (judge verdict: Wrong Answer)

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
 
int main()
{
  int a, b, c, d, X, Y;
  int D, G;
  //char s[101][101]={};
  char sv[101]={};
  char ss[101]={};
//  char s_temp[101]={};
  char t[101]={};
//  char s[10000000000000000001]={};
  char s[2][100001]={};
  int len=0;
  int N, M;
//  int A[1000000001]={};
  int A[10000001]={};
//  long int A[1001]={};
  int B[20000]={};
  int C[20000]={};
  int i,j,k;
  int flag=0;
  int tmp=0;
  int min=0;
  int cnt=0;
  int ans=0;
  int max_o=0;
  int max2_o=0;
  int max_o_num=0;
  int max_e=0;
  int max2_e=0;
  int max_e_num=0;
//  int ans=0;
  int str_len=0;
//  char alp[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
  int ans_o[10000001]={};
  int ans_e[10000001]={};


  scanf("%d", &a);
  
   for(i=0;i<a/2;i++){
     scanf("%d", &b);
     ans_e[b]++;
     if(max_e<ans_e[b]){
       max2_e=max_e;
       max_e=ans_e[b];
       max_e_num=b;
     }
     //printf("%d",max_e);
     scanf("%d", &c);     
     ans_o[c]++;
     if(max_o<ans_o[c]){
       max2_o=max_o;
       max_o=ans_o[c];      
       max_o_num=c;
     }
     if(max_e_num == max_o_num){
       if(max_e<max_o){
         max_e=max2_e;
       } else{
         max_o=max2_o;
       }  
     }
//     if(max_o<ans_o[A[i]]) max_o=ans_o[A[i]];
     //printf("%d",max_o);
   } 
  printf("%d\n", a-max_e-max_o);
   
//   printf("%d\n",a-b+1);
  
return 0;
}