Buggy python submission (verdict: Runtime Error):
import itertools
import math
import sys

n = int(input())
v = list(map(int, input().split()))
if len(set(v)) == 1:
    print(n // 2)
else:
    odd_cnt = [0] * (10 ** 5)
    even_cnt = [0] * (10 ** 5)
    for i in range(len(v)):
        if i % 2 == 0:
            even_cnt[v[i]] += 1
        else:
            odd_cnt[v[i]] += 1
    odd = odd_cnt.index(max(odd_cnt))
    even = even_cnt.index(max(even_cnt))
    ans = 0
    for i in range(len(v)):
        if i % 2 == 0:
            if v[i] != even:
                ans += 1
        else:
            if v[i] != odd:
                ans += 1
    print(ans)


Fixed submission:
import itertools
import math
import sys
from collections import Counter

n = int(input())
v = list(map(int, input().split()))
e = Counter(v[0::2]).most_common()
o = Counter(v[1::2]).most_common()
if len(e) == 1 and len(o) == 1:
    if e[0][0] == o[0][0]:
        print(n // 2)
    else:
        print(0)
elif len(e) == 1:
    if e[0][0] != o[0][0]:
        print(n - e[0][1] - o[0][1])
    else:
        print(n - max(e[0][1] + o[0][1], o[1][1]))
elif len(o) == 1:
    if e[0][0] != o[0][0]:
        print(n - e[0][1] - o[0][1])
    else:
        print(n - max(e[0][1] + o[0][1], e[1][1]))
else:
    if e[0][0] != o[0][0]:
        print(n - e[0][1] - o[0][1])
    else:
        print(n - max(e[0][1] + o[1][1], e[1][1] + o[0][1]))

Buggy python submission (verdict: Runtime Error):
import itertools
import math
import sys

n = int(input())
v = list(map(int, input().split()))
if len(set(v)) == 1:
    print(n // 2)
else:
    odd_cnt = [0] * 10 ** 5
    even_cnt = [0] * 10 ** 5
    for i in range(len(v)):
        if i % 2 == 0:
            even_cnt[v[i]] += 1
        else:
            odd_cnt[v[i]] += 1
    odd = odd_cnt.index(max(odd_cnt))
    even = even_cnt.index(max(even_cnt))
    ans = 0
    for i in range(len(v)):
        if i % 2 == 0:
            if v[i] != even:
                ans += 1
        else:
            if v[i] != odd:
                ans += 1
    print(ans)


Fixed submission:
import itertools
import math
import sys
from collections import Counter

n = int(input())
v = list(map(int, input().split()))
e = Counter(v[0::2]).most_common()
o = Counter(v[1::2]).most_common()
if len(e) == 1 and len(o) == 1:
    if e[0][0] == o[0][0]:
        print(n // 2)
    else:
        print(0)
elif len(e) == 1:
    if e[0][0] != o[0][0]:
        print(n - e[0][1] - o[0][1])
    else:
        print(n - max(e[0][1] + o[0][1], o[1][1]))
elif len(o) == 1:
    if e[0][0] != o[0][0]:
        print(n - e[0][1] - o[0][1])
    else:
        print(n - max(e[0][1] + o[0][1], e[1][1]))
else:
    if e[0][0] != o[0][0]:
        print(n - e[0][1] - o[0][1])
    else:
        print(n - max(e[0][1] + o[1][1], e[1][1] + o[0][1]))

Buggy python submission (verdict: Runtime Error):
import itertools
import math
import sys

n = int(input())
v = list(map(int, input().split()))
if len(set(v)) == 1:
    print(n // 2)
else:
    odd_cnt = [0] * 10 ** 5
    even_cnt = [0] * 10 ** 5
    for i in range(len(v)):
        if i % 2 == 0:
            even_cnt[v[i]] += 1
        else:
            odd_cnt[v[i]] += 1
    odd = odd_cnt.index(max(odd_cnt))
    even = even_cnt.index(max(even_cnt))
    ans = 0
    print("odd =", odd)
    print("even =", even)
    for i in range(len(v)):
        if i % 2 == 0:
            if v[i] != even:
                ans += 1
        else:
            if v[i] != odd:
                ans += 1
    print(ans)


Fixed submission:
import itertools
import math
import sys
from collections import Counter

n = int(input())
v = list(map(int, input().split()))
e = Counter(v[0::2]).most_common()
o = Counter(v[1::2]).most_common()
if len(e) == 1 and len(o) == 1:
    if e[0][0] == o[0][0]:
        print(n // 2)
    else:
        print(0)
elif len(e) == 1:
    if e[0][0] != o[0][0]:
        print(n - e[0][1] - o[0][1])
    else:
        print(n - max(e[0][1] + o[0][1], o[1][1]))
elif len(o) == 1:
    if e[0][0] != o[0][0]:
        print(n - e[0][1] - o[0][1])
    else:
        print(n - max(e[0][1] + o[0][1], e[1][1]))
else:
    if e[0][0] != o[0][0]:
        print(n - e[0][1] - o[0][1])
    else:
        print(n - max(e[0][1] + o[1][1], e[1][1] + o[0][1]))