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;
typedef long long unsigned int ll;

// definition {{{ 1

// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)

#define Scll(x) scanf("%llu", &x)
#define Scll2(x,y) scanf("%llu%llu", &x, &y)
#define Scll3(x,y,z) scanf("%llu%llu%llu", &x, &y, &z)

#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2

// constants {{{ 2
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
// }}} 2

// systems {{{ 2
#define Rep(x,y) for(int x = 0; x < y; x++)
#define Repe(x,y,z) for(int x = z; x < y; x++)
// }}} 2

// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n");
// }}} 2

// }}} 1

typedef pair<int,int> Pii;

int main() {

    int n;

    int v;
    int cnt1[100001];
    int cnt2[100001];

    int maxv = 0;
    Scd(n);

    Rep(i,n){
        Scd(v);
        if(i % 2){
            cnt1[v]++;
        }else{
            cnt2[v]++;
        }
        maxv = max(maxv,v);
    }
    maxv++;

    int ans1 = 0, ans2 = 0;
    int hit1 = 0, hit2 = 0;
    Rep(i,maxv){
        if(cnt1[i] > ans1){
            ans1 = cnt1[i];
            hit1 = i;
        }
        if(cnt2[i] > ans2){
            ans2 = cnt2[i];
            hit2 = i;
        }
    }


    int pre1 = 0, pre2 = 0;
    int preans = ans1 + ans2;
    if( hit1 == hit2 ){
        Rep(i,maxv){
            if(i == hit1) continue;
            if(cnt2[i] > pre2){
                pre2 = cnt2[i];
            }
        }
        Rep(i,maxv){
            if(i == hit1) continue;
            if(cnt1[i] > pre1){
                pre1 = cnt1[i];
            }
        }
        int preans1 = pre1 + ans2;
        int preans2 = pre2 + ans1;
        preans = max(preans1,preans2);
    }



    int ans = n - preans;
    printf ("%d\n", ans);

    return 0;
}