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 <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <cmath>
#include <queue>
#include <numeric>
#include <climits>
#include <iterator>
#include <iomanip>
#include <stack>
#include <set>
#include <cstdio>
#include <bitset>
#include <functional>
#include <tuple>
#include <list>
#include <deque>
using namespace std;
const constexpr int INF = 1e9;
typedef pair<int, int> P;

#define FOR(i, a, n) for (ll i = (ll)a; i<(ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)

typedef long long ll;
typedef vector<int> VI;
const constexpr ll MOD = 1e9 + 7;
const int BITSIZE = 100010;

struct Less{
    bool operator()(const pair<int, int>& x, const pair<int, int>& y) const {
        return x.first < y.first;
    }
};
struct More {
	bool operator()(const pair<int, int>& x, const pair<int, int>& y) const {
		return x.first > y.first;
	}
};

int GCD(int a, int b){
    if(a<b) swap(a, b);
    if(b==0) return a;
    return GCD(b, a%b);
}
//1-indexed
int bit[100010];

int bit_query(int i) {
	int res = 0;
	for (; i >= 1; i -= i & -i) res = max(res, bit[i]);
	return res;
}

void bit_set(int x, int v) {
	for (; x <= BITSIZE; x += x & -x) {
		bit[x] = max(bit[x], v);
	}
}

ll pow_mod(ll a, ll b){
    ll sum =1;
    while(b>0){
        if(b&1){
            sum *= a%MOD;
        }
        a = a* a%MOD;
        b >>= 1;
    }
    return sum;
}


vector<int> v1, v2;

map<int, int> a;
map<int, int> b;
int main() {
    cin.tie(0);
   	ios::sync_with_stdio(false);
    int n; cin >> n;
    REP(i, n) {
        int m; cin >> m;
        if(i%2==0){
            v1.push_back(m); //偶数番目 0indexed
        }else{
            v2.push_back(m); //奇数番目
        }
    }     
    
    REP(i, v1.size()){
        a[v1[i]]++;
    }
    REP(i, v2.size()){
        b[v2[i]]++;
    }
    auto it = a.begin();
    int maxidx1=(*it).first;
    int maxV1=(*it).second;
    int subm1=0;
    for(auto it=a.begin(); it!=a.end(); ++it){
        if((*it).second>maxV1){
            subm1 = maxV1;
            maxidx1 = (*it).first;
            maxV1 = (*it).second;
        }
    }
    it = b.begin();
    int maxidx2=(*it).first;
    int maxV2=(*it).second;
    int subm2=0;
    
    for(auto it=b.begin(); it!=b.end(); ++it){
        if((*it).second>maxV2){
            subm2 = maxV2;
            maxidx2 = (*it).first;
            maxV2 = (*it).second;
        }
    }
    if(maxidx1!=maxidx2){
        cout << n-maxV1-maxV2 << endl;
    }else{
        if(maxV1<maxV2){
            cout << n - subm1 - maxV2 << endl;
        }else{
            cout << n - maxV1 - subm2 << endl;
        }
        
    }
    
    
    
	return 0;
}