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)

#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_C main
#include "bits/stdc++.h"
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LONG_MAX/2)
const int MGN = 8;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
// functions
bool second_greater(const pii& left, const pii& right) {
    return left.second > right.second;
}
#endif


int main_C() {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int N; cin >> N;
    vi v(N); REP(i, N) cin >> v[i];

    bool same = true;
    REP(i,N-1) {
        if (v[i] != v[i+1]){
            same = false;
            break;
        }
    }
    if (same) {
        cout << N / 2 << endl;
        return 0;
    }

    const int VMAX = 100000;
    vi ho(VMAX + 1, 0), he(VMAX + 1, 0);
    REP(i,N) {
        if (i % 2 == 0) {
            ho[v[i]]++;
        } else {
            he[v[i]]++;
        }
    }

    vector<pii> mdO;
    FOR(i,1,VMAX+1) {
        if (0 < ho[i]) {
            mdO.push_back(pii(i, ho[i]));
        }
    }
    sort(mdO.begin(), mdO.end(), second_greater);

    vector<pii> mdE;
    FOR(i,1,VMAX+1) {
        if (0 < he[i]) {
            mdE.push_back(pii(i, he[i]));
        }
    }
    sort(mdE.begin(), mdE.end(), second_greater);

    int mo = mdO[0].first, me = mdE[0].first;

    int ans;
    if (mo == me){
        int mo2 = mdO[1].first, me2 = mdE[1].first;
        if (ho[mo] - ho[mo2] <= he[me] - he[me2]) {
            ans = N - ho[mo] - he[me2];
        } else {
            ans = N - ho[mo2] - he[me];
        }
    } else {
        ans = N - ho[mo] - he[me];
    }
    cout << ans << endl;

    return 0;
}