Buggy python submission (verdict: Runtime Error):
n = int(input())
v = [int(i) for i in input().split()]
even = [0] * int(1e5+1)
odd = [0] * int(1e5+1)

for i, k in enumerate(v):
    if (i & 1 == 0):
        even[k] += 1
    else:
        odd[k] += 1

if even.index(max(even)) == odd.index(max(odd)):
    print(min(n - sorted(even, reverse=True)[1] - sorted(odd, reverse=True)[0],
              n - sorted(even, reverse=True)[0] - sorted(odd, reverse=True)[1]))
else:
    print(n - sorted(even, reverse=True)[0] - sorted(odd, reverse=True)[0])
n = int(input())
v = [int(i) for i in input().split()]
even = [0] * int(1e5+1)
odd = [0] * int(1e5+1)

for i, k in enumerate(v):
    if (i & 1 == 0):
        even[k] += 1
    else:
        odd[k] += 1

if even.index(max(even)) == odd.index(max(odd)):
    even.sort(reverse=True)
    odd.sort(reverse=True)
    print(min(n - even[1] - odd[0],
              n - even[0] - odd[1]))
else:
    even.sort(reverse=True)
    odd.sort(reverse=True)
    print(n - even[0] - odd[0])


Fixed submission:
n = int(input())
v = [int(i) for i in input().split()]
even = [0] * int(1e5+1)
odd = [0] * int(1e5+1)

for i, k in enumerate(v):
    if (i & 1 == 0):
        even[k] += 1
    else:
        odd[k] += 1

if even.index(max(even)) == odd.index(max(odd)):
    even.sort(reverse=True)
    odd.sort(reverse=True)
    print(min(n - even[1] - odd[0],
              n - even[0] - odd[1]))
else:
    even.sort(reverse=True)
    odd.sort(reverse=True)
    print(n - even[0] - odd[0])

Buggy python submission (verdict: Runtime Error):
n = int(input())
v = [int(i) for i in input().split()]
odd = [v[i] for i in range(n) if i % 2 == 1]
even = [v[i] for i in range(n) if i % 2 == 0]
summ_odd = {i: odd.count(i) for i in set(odd)}
summ_even = {i: even.count(i) for i in set(even)}
odd_max_k = max(summ_odd.items(), key=lambda x: x[1])[0]
even_max_k = max(summ_even.items(), key=lambda x: x[1])[0]
if odd_max_k == even_max_k:
    if len(summ_odd) == 1:
        if len(summ_even) == 1:
            print(n//2)
            exit()
        else:
            tmp = summ_even.pop(even_max_k)
            even_max_k = max(summ_even.items(), key=lambda x: x[1])[0]
            summ_even.upddate(tmp)
    else:
        tmp = summ_odd.pop(odd_max_k)
        odd_max_k = max(summ_odd.items(), key=lambda x: x[1])[0]
        summ_odd.upddate(tmp)

summ_odd.pop(odd_max_k)
summ_even.pop(even_max_k)
res = sum(summ_odd.values()) + sum(summ_even.values())
print(res)

Fixed submission:
n = int(input())
v = [int(i) for i in input().split()]
even = [0] * int(1e5+1)
odd = [0] * int(1e5+1)

for i, k in enumerate(v):
    if (i & 1 == 0):
        even[k] += 1
    else:
        odd[k] += 1

if even.index(max(even)) == odd.index(max(odd)):
    even.sort(reverse=True)
    odd.sort(reverse=True)
    print(min(n - even[1] - odd[0],
              n - even[0] - odd[1]))
else:
    even.sort(reverse=True)
    odd.sort(reverse=True)
    print(n - even[0] - odd[0])

Buggy python submission (verdict: Runtime Error):
n = int(input())
v = [int(i) for i in input().split()]
odd = [v[i] for i in range(n) if i % 2 == 1]
even = [v[i] for i in range(n) if i % 2 == 0]
summ_odd = {i: odd.count(i) for i in set(odd)}
summ_even = {i: even.count(i) for i in set(even)}
odd_max_k = max(summ_odd.items(), key=lambda x: x[1])[0]
even_max_k = max(summ_even.items(), key=lambda x: x[1])[0]
if odd_max_k == even_max_k:
    if len(summ_odd) == 1:
        if len(summ_even) == 1:
            print(n//2)
            exit()
        else:
            tmp = summ_even.pop(even_max_k)
            even_max_k = max(summ_even.items(), key=lambda x: x[1])[0]
            summ_even.upddate(tmp)
    else:
        tmp = summ_odd.pop(odd_max_k)
        odd_max_k = max(summ_odd.items(), key=lambda x: x[1])[0]
        summ_odd.upddate(tmp)

summ_odd.pop(odd_max_k)
summ_even.pop(even_max_k)
res = sum(summ_odd.values()) + sum(summ_even.values())
print(res)

Fixed submission:
n = int(input())
v = [int(i) for i in input().split()]
even = [0] * int(1e5+1)
odd = [0] * int(1e5+1)

for i, k in enumerate(v):
    if (i & 1 == 0):
        even[k] += 1
    else:
        odd[k] += 1

if even.index(max(even)) == odd.index(max(odd)):
    even.sort(reverse=True)
    odd.sort(reverse=True)
    print(min(n - even[1] - odd[0],
              n - even[0] - odd[1]))
else:
    even.sort(reverse=True)
    odd.sort(reverse=True)
    print(n - even[0] - odd[0])