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

import sys

def solve(N, ls_v):
    # Uncomment the following if you want to check the input.
    #print('N =', N)
    #print('ls_v =', ls_v)
    inc=[]
    incc={}
    count=0
    for i in ls_v:
        if i not in incc:
            incc[i] = 1
        else:
            incc[i] += 1
    cl =[i for i in incc.values()]
    cls =[i for i in incc.keys()]
    a = max(cl)
    a = cl.index(a)
    a = cls[a]
    counter = 0
    counter2 = 0
    reco = 0
    counter3 = 0
    ckk = ""
    ck = ""
    rk = ""
    for key,value in incc.items():
        #print(key,value)
        if key == a:
            ckk,counter2 = key,value
        elif key != a and counter < value:
            counter,ck = value,key
        if (key != a and key != ck) and reco <= value:
            rk,reco = key,value
            #print("c")
        else:
            counter3 += 1
    #print("1",reco,rk)
    corli = []
    corli1 = []
    corli2 = []
    corli3 = []
    corli4 = []
    corli5 = []
    i = 10
    for line in ls_v:
        if i%2 == 0:
            corli.append(ckk)
            corli1.append(ck)
            corli2.append(rk)
            corli3.append(ck)
            corli4.append(rk)
            corli5.append(ckk)
        elif i%2 != 0:
            corli.append(ck)
            corli1.append(ckk)
            corli2.append(ck)
            corli3.append(rk)
            corli4.append(ckk)
            corli5.append(rk)
        i += 1
    #print(corli2)
    cc,c1,c2,c3,c4 = 0,0,0,0,0
    c = 0
    for (line1,line2) in zip(ls_v,corli):
        if line1 != line2:
            c += 1
    for (line1,line2) in zip(ls_v,corli1):
        if line1 != line2:
            cc += 1
    for (line1,line2) in zip(ls_v,corli2):
        #print(line1,line2)
        if line1 != line2:
            c1 += 1
    for (line1,line2) in zip(ls_v,corli3):
        if line1 != line2:
            c2 += 1
    for (line1,line2) in zip(ls_v,corli4):
        if line1 != line2:
            c3 += 1
    for (line1,line2) in zip(ls_v,corli5):
        if line1 != line2:
            c4 += 1
    #print(c,cc,c1,c2,c3,c4)
    if cc == 0 or c == 0:
        return 0
    else:
        return min(c,cc,c1,c2,c3,c4)
        #print(corli,corli1,corli3,corli4,corli5)

def readQuestion():
    ws = sys.stdin.readline().strip().split()
    N = int(ws[0])
    ws = sys.stdin.readline().strip().split()
    ls_v = list(map(int, ws))
    return (N, ls_v)

def main():
    print(solve(*readQuestion()))

main()