Buggy python submission (verdict: Time Limit Exceeded):
import heapq
n=int(input())
v=list(map(int,input().split()))
odd=v[1::2]
even=v[0::2]
a=[]
b=[]
lodd=list(set(odd))
leven=list(set(even))
for i in range(len(lodd)):
    a.append((odd.count(lodd[i]),lodd[i]))
for i in range(len(leven)):
    b.append((even.count(leven[i]),leven[i]))
if max(a)[1]!=max(b)[1]:
    print(n-max(a)[0]-max(b)[0])
elif max(a)[1]==max(b)[1]:
    if len(a)>1 and len(b)>1:
        print(min(n-max(a)[0]-heapq.nlargest(2,b)[1][0],n-heapq.nlargest(2,a)[1][0]-max(b)[0]))
    elif len(a)>1 and len(b)==1:
        print(n-heapq.nlargest(2,a)[1][0]-max(b)[0])
    elif len(a)==1 and len(b)>1:
        print(n-max(a)[0]-heapq.nlargest(2,b)[1][0])
    elif len(a)==1 and len(b)==1:
        print(n//2)

Fixed submission:
from collections import Counter
n=int(input())
v=list(map(int,input().split()))
odd=v[1::2]
even=v[0::2]
a=Counter(odd)
b=Counter(even)
if a.most_common()[0][0]!=b.most_common()[0][0]:
    print(n-a.most_common()[0][1]-b.most_common()[0][1])
else:
    if len(a)>1 and len(b)>1:
        print(min(n-a.most_common()[0][1]-b.most_common()[1][1],n-a.most_common()[1][1]-b.most_common()[0][1]))
    elif len(a)>1 and len(b)==1:
        print(n-a.most_common()[1][1]-b.most_common()[0][1])
    elif len(a)==1 and len(b)>1:
        print(n-a.most_common()[0][1]-b.most_common()[1][1])
    elif len(a)==1 and len(b)==1:
        print(n//2)

Buggy python submission (verdict: Time Limit Exceeded):
import heapq
n=int(input())
v=list(map(int,input().split()))
odd=v[1::2]
even=v[0::2]
a=[]
b=[]
lodd=list(set(odd))
leven=list(set(even))
for i in range(len(lodd)):
    a.append([odd.count(lodd[i]),lodd[i]])
for i in range(len(leven)):
    b.append([even.count(leven[i]),leven[i]])
if max(a)[1]!=max(b)[1]:
    print(n-max(a)[0]-max(b)[0])
elif max(a)[1]==max(b)[1]:
    if len(a)>1 and len(b)>1:
        print(min(n-max(a)[0]-heapq.nlargest(2,b)[1][0],n-heapq.nlargest(2,a)[1][0]-max(b)[0]))
    elif len(a)>1 and len(b)==1:
        print(n-heapq.nlargest(2,a)[1][0]-max(b)[0])
    elif len(a)==1 and len(b)>1:
        print(n-max(a)[0]-heapq.nlargest(2,b)[1][0])
    elif len(a)==1 and len(b)==1:
        print(n//2)

Fixed submission:
from collections import Counter
n=int(input())
v=list(map(int,input().split()))
odd=v[1::2]
even=v[0::2]
a=Counter(odd)
b=Counter(even)
if a.most_common()[0][0]!=b.most_common()[0][0]:
    print(n-a.most_common()[0][1]-b.most_common()[0][1])
else:
    if len(a)>1 and len(b)>1:
        print(min(n-a.most_common()[0][1]-b.most_common()[1][1],n-a.most_common()[1][1]-b.most_common()[0][1]))
    elif len(a)>1 and len(b)==1:
        print(n-a.most_common()[1][1]-b.most_common()[0][1])
    elif len(a)==1 and len(b)>1:
        print(n-a.most_common()[0][1]-b.most_common()[1][1])
    elif len(a)==1 and len(b)==1:
        print(n//2)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
v=list(map(int,input().split()))
odd=v[1::2]
even=v[0::2]
a=[]
b=[]
lodd=list(set(odd))
leven=list(set(even))
for i in range(len(lodd)):
    a.append([odd.count(lodd[i]),lodd[i]])
for i in range(len(leven)):
    b.append([even.count(leven[i]),leven[i]])
a.sort()
b.sort()
if a[-1][1]!=b[-1][1]:
    print(n-a[-1][0]-b[-1][0])
elif a[-1][1]==b[-1][1]:
    if len(a)>1 and len(b)>1:
        print(min(n-a[-1][0]-b[-2][0],n-a[-2][0]-b[-1][0]))
    elif len(a)>1 and len(b)==1:
        print(n-a[-2][0]-b[0][0])
    elif len(a)==1 and len(b)>1:
        print(n-a[0][0]-b[-2][0])
    elif len(a)==1 and len(b)==1:
        print(n//2)

Fixed submission:
from collections import Counter
n=int(input())
v=list(map(int,input().split()))
odd=v[1::2]
even=v[0::2]
a=Counter(odd)
b=Counter(even)
if a.most_common()[0][0]!=b.most_common()[0][0]:
    print(n-a.most_common()[0][1]-b.most_common()[0][1])
else:
    if len(a)>1 and len(b)>1:
        print(min(n-a.most_common()[0][1]-b.most_common()[1][1],n-a.most_common()[1][1]-b.most_common()[0][1]))
    elif len(a)>1 and len(b)==1:
        print(n-a.most_common()[1][1]-b.most_common()[0][1])
    elif len(a)==1 and len(b)>1:
        print(n-a.most_common()[0][1]-b.most_common()[1][1])
    elif len(a)==1 and len(b)==1:
        print(n//2)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
v=list(map(int,input().split()))
odd=v[1::2]
even=v[0::2]
a=[]
b=[]
lodd=list(set(odd))
leven=list(set(even))
for i in range(len(lodd)):
    a.append([odd.count(lodd[i]),lodd[i]])
for i in range(len(leven)):
    b.append([even.count(leven[i]),leven[i]])
a.sort()
b.sort()
if a[-1][1]!=b[-1][1]:
    print(n-a[-1][0]-b[-1][0])
if a[-1][1]==b[-1][1]:
    if len(a)>1 and len(b)>1:
        print(min(n-a[-1][0]-b[-2][0],n-a[-2][0]-b[-1][0]))
    if len(a)>1 and len(b)==1:
        print(n-a[-2][0]-b[-1][0])
    if len(a)==1 and len(b)>1:
        print(n-a[-1][0]-b[-2][0])
    if len(a)==1 and len(b)==1:
        print(n//2)

Fixed submission:
from collections import Counter
n=int(input())
v=list(map(int,input().split()))
odd=v[1::2]
even=v[0::2]
a=Counter(odd)
b=Counter(even)
if a.most_common()[0][0]!=b.most_common()[0][0]:
    print(n-a.most_common()[0][1]-b.most_common()[0][1])
else:
    if len(a)>1 and len(b)>1:
        print(min(n-a.most_common()[0][1]-b.most_common()[1][1],n-a.most_common()[1][1]-b.most_common()[0][1]))
    elif len(a)>1 and len(b)==1:
        print(n-a.most_common()[1][1]-b.most_common()[0][1])
    elif len(a)==1 and len(b)>1:
        print(n-a.most_common()[0][1]-b.most_common()[1][1])
    elif len(a)==1 and len(b)==1:
        print(n//2)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
v=list(map(int,input().split()))
odd=v[1::2]
even=v[0::2]
a=[]
b=[]
lodd=list(set(odd))
leven=list(set(even))
for i in range(len(lodd)):
    a.append([odd.count(lodd[i]),lodd[i]])
for i in range(len(leven)):
    b.append([even.count(leven[i]),leven[i]])
a.sort()
b.sort()
if a[-1][1]!=b[-1][1]:
    print(n-a[-1][0]-b[-1][0])
if a[-1][1]==b[-1][1]:
    if len(a)>1 and len(b)>1:
        print(min(n-a[-1][0]-b[-2][0],n-a[-2][0]-b[-1][0]))
    if len(a)>1 and len(b)==1:
        print(n-a[-2][0]-b[-1][0])
    if len(a)==1 and len(b)>1:
        print(n-a[-1][0]-b[-2][0])
    if len(a)==1 and len(b)==1:
        print(n//2)

Fixed submission:
from collections import Counter
n=int(input())
v=list(map(int,input().split()))
odd=v[1::2]
even=v[0::2]
a=Counter(odd)
b=Counter(even)
if a.most_common()[0][0]!=b.most_common()[0][0]:
    print(n-a.most_common()[0][1]-b.most_common()[0][1])
else:
    if len(a)>1 and len(b)>1:
        print(min(n-a.most_common()[0][1]-b.most_common()[1][1],n-a.most_common()[1][1]-b.most_common()[0][1]))
    elif len(a)>1 and len(b)==1:
        print(n-a.most_common()[1][1]-b.most_common()[0][1])
    elif len(a)==1 and len(b)>1:
        print(n-a.most_common()[0][1]-b.most_common()[1][1])
    elif len(a)==1 and len(b)==1:
        print(n//2)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
v=list(map(int,input().split()))
odd=[]
even=[]
a=[]
b=[]
for i in range(n//2):
    odd.append(v[2*i+1])
    even.append(v[2*i])
lodd=list(set(odd))
leven=list(set(even))
for i in range(len(lodd)):
    a.append([odd.count(lodd[i]),lodd[i]])
for i in range(len(leven)):
    b.append([even.count(leven[i]),leven[i]])
a.sort()
b.sort()
if a[-1][1]!=b[-1][1]:
    print(n-a[-1][0]-b[-1][0])
if a[-1][1]==b[-1][1]:
    if len(a)>1 and len(b)>1:
        print(min(n-a[-1][0]-b[-2][0],n-a[-2][0]-b[-1][0]))
    if len(a)>1 and len(b)==1:
        print(n-a[-2][0]-b[-1][0])
    if len(a)==1 and len(b)>1:
        print(n-a[-1][0]-b[-2][0])
    if len(a)==1 and len(b)==1:
        print(n//2)

Fixed submission:
from collections import Counter
n=int(input())
v=list(map(int,input().split()))
odd=v[1::2]
even=v[0::2]
a=Counter(odd)
b=Counter(even)
if a.most_common()[0][0]!=b.most_common()[0][0]:
    print(n-a.most_common()[0][1]-b.most_common()[0][1])
else:
    if len(a)>1 and len(b)>1:
        print(min(n-a.most_common()[0][1]-b.most_common()[1][1],n-a.most_common()[1][1]-b.most_common()[0][1]))
    elif len(a)>1 and len(b)==1:
        print(n-a.most_common()[1][1]-b.most_common()[0][1])
    elif len(a)==1 and len(b)>1:
        print(n-a.most_common()[0][1]-b.most_common()[1][1])
    elif len(a)==1 and len(b)==1:
        print(n//2)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
v=list(map(int,input().split()))
odd=[]
even=[]
a=[]
b=[]
for i in range(n//2):
    odd.append(v[2*i+1])
    even.append(v[2*i])
lodd=list(set(odd))
leven=list(set(even))
for i in range(len(lodd)):
    a.append([odd.count(lodd[i]),lodd[i]])
for i in range(len(leven)):
    b.append([even.count(leven[i]),leven[i]])
a.sort()
b.sort()
if a[-1][1]!=b[-1][1]:
    print(n-a[-1][0]-b[-1][0])
if a[-1][1]==b[-1][1]:
    if len(a)>1 and len(b)>1:
        print(min(n-a[-1][0]-b[-2][0],n-a[-2][0]-b[-1][0]))
    if len(a)>1 and len(b)==1:
        print(n-a[-2][0]-b[-1][0])
    if len(a)==1 and len(b)>1:
        print(n-a[-1][0]-b[-2][0])
    if len(a)==1 and len(b)==1:
        print(n//2)

Fixed submission:
from collections import Counter
n=int(input())
v=list(map(int,input().split()))
odd=v[1::2]
even=v[0::2]
a=Counter(odd)
b=Counter(even)
if a.most_common()[0][0]!=b.most_common()[0][0]:
    print(n-a.most_common()[0][1]-b.most_common()[0][1])
else:
    if len(a)>1 and len(b)>1:
        print(min(n-a.most_common()[0][1]-b.most_common()[1][1],n-a.most_common()[1][1]-b.most_common()[0][1]))
    elif len(a)>1 and len(b)==1:
        print(n-a.most_common()[1][1]-b.most_common()[0][1])
    elif len(a)==1 and len(b)>1:
        print(n-a.most_common()[0][1]-b.most_common()[1][1])
    elif len(a)==1 and len(b)==1:
        print(n//2)