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 9.2.1) (judge verdict: Wrong Answer)

#include <bits/stdc++.h>
using namespace std;

const int MOD = 1000000007;
const int INF = 1e9;

int n;
const int max_n = 1e5;
vector<int> v1;
vector<int> v2;
int v1_num, v2_num;

tuple<int, int, int> solver(vector<int>& x){
  
  sort(x.begin(), x.end());

  int cnt = 1;
  int max_cnt = 0;
  int second_cnt = 0;
  int num = 0;
  int second_num = 0;
  int s = 0;
  // cout << "vector size = " << x.size() << endl;
  for(int i = 1; i < x.size(); i++){
    if(x[i] != x[i-1]){
      cnt = i-1 - s + 1;
      if(max_cnt <= cnt) {
        second_cnt = max_cnt;
        max_cnt = cnt;
        second_num = num;
        num = x[i-1];
      }
      s = i;
    }
    if(i == x.size() - 1){
      cnt = i - s + 1;
      if(max_cnt <= cnt){
        second_cnt = cnt;
        max_cnt = cnt;
        second_num = num;
        num = x[i];
      }
    }
  }

  int ans = x.size() - max_cnt;
  int second_ans = x.size() - second_cnt;
  

  return make_tuple(num, ans, second_ans);
}

int main(){

  cin >> n;

  for(int i = 0; i < n; i++){
    int v;
    cin >> v;
    if(i%2 == 0) v1.push_back(v);
    else v2.push_back(v);
  }

  // solver(v1);
  // solver(v2);

  // cout << get<1>(solver(v1)) + get<2>(solver(v2)) << endl;

  if(get<0>(solver(v1)) != get<0>(solver(v2))){
    cout << get<1>(solver(v1)) + get<1>(solver(v2)) << endl;
  }else{
    // cout << "dif" << endl;
    cout << min(get<1>(solver(v1)) + get<2>(solver(v2)), get<2>(solver(v1)) + get<1>(solver(v2))) << endl;
  }


  return 0;
}