Buggy python submission (verdict: Runtime Error):
from collections import Counter

def solve(size=int(input()), ary=list(map(int, input().split()))):
    if len(set(ary)) < 2: return len(ary) // 2

    even, odd = Counter(ary[::2]), Counter(ary[1::2])
    (e, em), (_, es) = even.most_common(2)
    (o, om), (_, os) = odd.most_common(2)
    return size - max(em + os, es + om) if e == o else size - em - om

print(solve())

Fixed submission:
from collections import Counter

def solve(size=int(input()), ary=list(map(int, input().split()))):
    even, odd = Counter(ary[::2]), Counter(ary[1::2])
    even[0], odd[0] = 0, 0
    (e, em), (_, es) = even.most_common(2)
    (o, om), (_, os) = odd.most_common(2)
    return size - max(em + os, es + om) if e == o else size - em - om

print(solve())

Buggy python submission (verdict: Runtime Error):
from collections import Counter
def solve(size=int(input()), ary=list(map(int, input().split()))):
    even, odd = Counter(ary[::2]), Counter(ary[1::2])
    (e, em), (_, es) = even.most_common(2)
    (o, om), (_, os) = odd.most_common(2)
    return size - max(em + os, es + om) if e == o else size - em - om
print(solve())

Fixed submission:
from collections import Counter

def solve(size=int(input()), ary=list(map(int, input().split()))):
    even, odd = Counter(ary[::2]), Counter(ary[1::2])
    even[0], odd[0] = 0, 0
    (e, em), (_, es) = even.most_common(2)
    (o, om), (_, os) = odd.most_common(2)
    return size - max(em + os, es + om) if e == o else size - em - om

print(solve())

Buggy python submission (verdict: Runtime Error):
from collections import Counter

given1 = int(input())
given2 = [int(_) for _ in input().split()]

def solve(size=given1, ary=given2):
    even, odd = Counter(ary[::2]), Counter(ary[1::2])

    emst, esec = even.most_common(2)
    eme, emf = emst
    ese, esf = esec

    omst, osec = odd.most_common(2)
    ome, omf = omst
    ose, osf = osec

    return size - max(emf + osf, omf + esf) if eme == ome else size - esf - osf


print(solve())


Fixed submission:
from collections import Counter

def solve(size=int(input()), ary=list(map(int, input().split()))):
    even, odd = Counter(ary[::2]), Counter(ary[1::2])
    even[0], odd[0] = 0, 0
    (e, em), (_, es) = even.most_common(2)
    (o, om), (_, os) = odd.most_common(2)
    return size - max(em + os, es + om) if e == o else size - em - om

print(solve())

Buggy python submission (verdict: Time Limit Exceeded):
def given(_dummy=int(input())): return [int(_) for _ in input().split()]


def solve(ary):
    if len(set(ary)) < 2:
        return len(ary) // 2

    even, odd = [], []
    for i, _ in enumerate(ary):
        even.append(_) if i % 2 == 0 else odd.append(_)

    even_key, odd_key = list(set(even)), list(set(odd))

    res = len(ary)
    most = 0

    if len(even_key) != 1:
        l_cache = 0
        for n in even:
            curr = max(l_cache, even.count(n))
            if l_cache != curr:
                most = n
            l_cache = curr

        res -= l_cache
    else:
        res -= len(even)

    if len(odd_key) != 1:
        r_cache = 0
        for n in odd:
            if n == most:
                continue
            curr = max(r_cache, odd.count(n))
            r_cache = curr

        res -= r_cache
    else:
        res -= len(odd)

    return res


print(solve(given()))

Fixed submission:
from collections import Counter

def solve(size=int(input()), ary=list(map(int, input().split()))):
    even, odd = Counter(ary[::2]), Counter(ary[1::2])
    even[0], odd[0] = 0, 0
    (e, em), (_, es) = even.most_common(2)
    (o, om), (_, os) = odd.most_common(2)
    return size - max(em + os, es + om) if e == o else size - em - om

print(solve())