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[100001]={};
//  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[100001]={};
  int ans_e[100001]={};


  scanf("%d", &a);
  
   for(i=0;i<a/2;i++){
     scanf("%d", &A[i]);
     ans_e[A[i]]++;
     if(max_e<ans_e[A[i]]){
       max2_e=max_e;
       max_e=ans_e[A[i]];
       max_e_num=A[i];
     }
     //printf("%d",max_e);
     scanf("%d", &A[i]);     
     ans_o[A[i]]++;
     if(max_o<ans_o[A[i]]){
       max2_o=max_o;
       max_o=ans_o[A[i]];      
       max_o_num=A[i];
     }
     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;
}