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>
#define REP(i, n) for(long long i=0; i<n; i++)
#define REPR(i, n) for(long long i=n-1; i>=0; i--)
#define FOR(i, m, n) for(long long i=m; i<=n; i++)
#define FORR(i, m, n) for(long long i=m; i>=n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
#define FIN ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;
const ll mod = 1e9+7;
const ll inf = 1e15;



int main(){FIN

    ll n;cin>>n;
    vll a(n); REP(i,n) cin>>a[i];
    map<ll,ll> m1,m2;
    REP(i,n){

        if(i%2==0) m1[a[i]]++;
        else m2[a[i]]++;
    }
    vector<P> v1,v2;
    for(auto p: m1) v1.push_back(make_pair(p.second, p.first));
    for(auto p: m2) v2.push_back(make_pair(p.second, p.first));
    VSORT(v1); VSORT(v2);
    if(v1[0].second != v2[0].second){
        ll ans = n - v1[0].first - v2[0].first;
        cout<<ans<<endl;
        return 0;
    }
    ll ans1 = inf, ans2 = inf;
    // cout<<v1.size()<<v2.size()<<endl;
    if(v1.size()>1) ans1 = n - v1[1].first - v2[0].first;
    if(v2.size()>1) ans2 = n - v1[0].first - v2[1].first;
    if (ans1==inf && ans2 == inf) {cout<<n/2<<endl; return 0;}
    cout<<min(ans1,ans2)<<endl;

    return 0;
}