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++14 (GCC 5.4.1) (judge verdict: Wrong Answer)

#include <bits/stdc++.h>
using namespace std;
int max1,max2,index1,index2;
vector<int> vec(200000);
int saihin(vector<int> v,int n){
  max1 = 0;
  max2 = 0;
  index1 = -1;
  index2 = -2;
  for(int i=0; i<200000; i++){
    vec.at(i) = 0;
  }
  for(int i=0; i<v.size(); i++){
    vec.at(v.at(i))++;
  }
  for(int i=0; i<200000; i++){
    if(max1 < vec.at(i)){
      max1 = vec.at(i);
      index1 = i;
      }
    if(max1 >= vec.at(i) && max2 <= vec.at(i) && index1 != i){
      max2 = vec.at(i);
      index2 = i;
      }
    }
  if(n==1){return index1;}
  if(n==2){return index2;}
}

int igai(vector<int> v,int n){
  int cntigai = 0;
  for(int i=0; i<v.size(); i++){
    if(v.at(i) != n){
      cntigai++;
    }
  }
  return cntigai;
}
int main(){
  int n;
  cin >> n;
  vector<int> e(n/2);
  vector<int> o(n/2);
  for(int i=0; i<n/2; i++){
    cin >> e.at(i) >> o.at(i);
  }
  int e1 = saihin(e,1);
  int e2 = saihin(e,2);
  int o1 = saihin(o,1);
  int o2 = saihin(o,2);
  
 
  /*cout << e1 << e2 << o1 << o2 <<endl;
  for(int i=0; i<n/2; i++){
    cout << e.at(i) << " ";
  }  
  cout << endl;
  for(int i=0; i<n/2; i++){
    cout << o.at(i) << " ";
  }
  cout << endl;*/
  
  
  if(e1 != o1){
    cout << igai(e,e1)+igai(o,o1) << endl;
  }else{
    cout << min(igai(e,e1)+igai(o,o2),igai(e,e2)+igai(o,o1)) << endl;
  }
  return 0;
}