Problem p03244 (python)

Fixed submission:
from collections import Counter

n = int(input())
v = list(map(int, input().split(' ')))

v1 = v[::2]
v2 = v[1::2]

counter1 = dict(Counter(v1))
counter2 = dict(Counter(v2))
x1 = max(counter1, key=counter1.get)
x2 = max(counter2, key=counter2.get)
x1_c = counter1[x1]
x2_c = counter2[x2]
del counter1[x1]
del counter2[x2]
y1_c = 0
y2_c = 0
if len(counter1) != 0:
    y1_c = max(counter1.values())
if len(counter2) != 0:
    y2_c = max(counter2.values())

n = n//2
ans = 0
if x1 == x2:
    ans = min((n - x1_c) + (n - y2_c), (n - y1_c) + (n - x2_c))
    """
    if x1_c > x2_c:
        ans = (n - x1_c) + (n - y2_c)
    else:
        ans =  (n - y1_c) + (n - x2_c)
    """
else:
    ans = (n - x1_c) + (n - x2_c)

print(ans)

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

n = int(input())
v = list(map(int, input().split(' ')))

v1 = v[::2]
v2 = v[1::2]

counter1 = Counter(v1)
x1 = counter1.most_common()[0:2]
counter2 = Counter(v2)
x2 = counter2.most_common()[0:2]

n = n//2
ans = 0
if x1[0][0] == x2[0][0]:
    if x1[0][1] > x2[0][1]:
        ans = (n - x1[0][1]) + (n - x2[1][1])
    else:
        ans =  (n - x2[0][1]) + (n - x1[1][1])
else:
    ans = (n - x1[0][1]) + (n - x2[0][1])

print(ans)

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

n = int(input())
v = list(map(int, input().split(' ')))

v1 = v[::2]
v2 = v[1::2]

counter1 = Counter(v1)
x1 = counter1.most_common(2)
counter2 = Counter(v2)
x2 = counter2.most_common(2)

n = n//2
ans = 0
if x1[0][0] == x2[0][0]:
    if x1[0][1] > x2[0][1]:
        ans = (n - x1[0][1]) + (n - x2[1][1])
    else:
        ans =  (n - x2[0][1]) + (n - x1[1][1])
else:
    ans = (n - x1[0][1]) + (n - x2[0][1])
print(ans)

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

n = int(input())
v = list(map(int, input().split(' ')))

v1 = v[::2]
v2 = v[1::2]

counter1 = Counter(v1)
x1 = counter1.most_common()[0:2]
counter2 = Counter(v2)
x2 = counter2.most_common()[0:2]

n = n//2
ans = 0
if x1[0][0] == x2[0][0]:
    if x1[0][1] > x2[0][1]:
        ans = (n - x1[0][1]) + (n - x2[1][1])
    else:
        ans =  (n - x2[0][1]) + (n - x1[1][1])
else:
    ans = (n - x1[0][1]) + (n - x2[0][1])
print(ans)

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

n = int(input())
v = list(map(int, input().split(' ')))

v1 = v[::2]
v2 = v[1::2]

counter1 = Counter(v1)
x1 = counter1.most_common()[0][0]
counter2 = Counter(v2)
x2 = counter2.most_common()[0][0]

x1_count = counter1.most_common()[0][1]
x2_count = counter2.most_common()[0][1]

n = n//2
ans = 0
if x1 == x2:
    if x1_count > x2_count:
        ans = (n - x1_count) + (n - counter2.most_common()[1][1])
    else:
        ans = (n - x2_count) + (n - counter1.most_common()[1][1])
else:
    ans = (n - x1_count) + (n - x2_count)
print(ans)

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

n = int(input())
v = list(map(int, input().split(' ')))

v1 = v[::2]
v2 = v[1::2]

counter1 = Counter(v1)
x1 = counter1.most_common()[0][0]
counter2 = Counter(v2)
x2 = counter2.most_common()[0][0]

x1_count = v1.count(x1)
x2_count = v2.count(x2)

n = n//2
ans = 0
if x1 == x2:
    if x1_count > x2_count:
        ans = (n - x1_count) + (n - counter2.most_common()[1][1])
    else:
        ans = (n - x2_count) + (n - counter1.most_common()[1][1])
else:
    ans = (n - x1_count) + (n - x2_count)
print(ans)

Buggy submission (verdict: Runtime Error):
from statistics import mode

n = int(input())
v = list(map(int, input().split(' ')))

v1 = v[::2]
v2 = v[1::2]

x1_count = v1.count(mode(v1))
x2_count = v2.count(mode(v2))

n = n//2
ans = (n - x1_count) + (n - x2_count)
print(ans)