Problem p03244 (python)

Fixed submission:
import collections

N = int(input())
V = list(int(i) for i in input().split())
even = V[0::2]
odd =  V[1::2]
all_length = len(V)
even = collections.Counter(even).most_common(2)
odd = collections.Counter(odd).most_common(2)
if (even[0][0] != odd[0][0]):
    print(all_length - even[0][1] - odd[0][1])
else:
    if(len(even) == 1 and len(odd) == 1):
        print(all_length // 2)
    elif(len(even)==1):
        print(all_length // 2 - odd[1][1])
    elif(len(odd)==1):
        print(all_length // 2 - even[1][1])    
    else:
        print(min(all_length - even[0][1] - odd[1][1], all_length - even[1][1] - odd[0][1]))

Buggy submission (verdict: Runtime Error):
import collections

N = int(input())
V = list(int(i) for i in input().split())
even = V[0::2]
odd =  V[1::2]
all_length = len(V)
even = collections.Counter(even).most_common(2)
odd = collections.Counter(odd).most_common(2)
if (even[0][0] != odd[0][0]):
    print(all_length - even[0][1] - odd[0][1])
else:
    if(len(even)==1 and len(odd)==1):
        print(all_length//2)
    elif(len(even)==1):
        print(all_length - odd[0][1])
    elif(len(odd)==1):
        print(all_length - even[0][1])    
    else:
        print(min(all_length - even[0][1] - odd[0][2], all_length - even[0][2] - odd[0][1]))

Buggy submission (verdict: Runtime Error):
import collections

N = int(input())
V = list(int(i) for i in input().split())
even = V[0::2]
odd =  V[1::2]
all_length = len(V)
even = collections.Counter(even).most_common(2)
odd = collections.Counter(odd).most_common(2)
if (even[0][0] != odd[0][0]):
    print(all_length - even[0][1] - odd[0][1])
else:
    if not(len(even)!=1 and len(odd)!=1):
        print(min(all_length - even[0][1] - odd[0][2], all_length - even[0][2] - odd[0][1]))
    elif(len(even)==1):
        print(all_length - odd[0][1])
    else:
        print(all_length - even[0][1])

Buggy submission (verdict: Runtime Error):
import collections

N = int(input())
V = list(int(i) for i in input().split())
even = V[0::2]
odd =  V[1::2]
all_length = len(V)
even = collections.Counter(even).most_common(2)
odd = collections.Counter(odd).most_common(2)
if (even[0][0] != odd[0][0]):
    print(all_length - even[0][1] - odd[0][1])
else:
    out1 = all_length - even[0][1] - odd[0][2]
    out2 = all_length - even[0][2] - odd[0][1]
    if(out1 > out2):
        print(out2)
    else:
        print(out1)

Buggy submission (verdict: Runtime Error):
import collections

N = int(input())
V = list(int(i) for i in input().split())
even = V[0::2]
odd =  V[1::2]
half_count = len(even)
even = collections.Counter(even).most_common(1)
even_elem = even[0][0]
even_count = even[0][1]
odd = collections.Counter(odd).most_common(1)
odd_elem = odd[0][0]
odd_count = odd[0][1]

if (even_count > odd_count):
    print((half_count - even_count) + (half_count + len(odd.count(even_elem))))
elif (even_count < odd_count):
    print((half_count - odd_count) + (half_count + len(even.count(odd_elem))))
else:
    print(0)

Buggy submission (verdict: Runtime Error):
import collections
N = int(input())
V = list(int(i) for i in input().split())
even = V[0::2]
odd =  V[1::2]
even_count = collections.Counter(even).most_common(2)
odd_count = collections.Counter(odd).most_common(2)

if even_count == N/2:
    print(N / 2 - odd_count)
elif odd_count == N/2:
    print(N / 2 - even_count)
else:
    print(N - odd_count - even_count)