Buggy python submission (verdict: Runtime Error):
N = int(input())
V = list(map(int, input().split()))

odd = {}
even = {}

for idx in range(N):
  if idx%2 == 0:
    if V[idx] in even:
      even[V[idx]] += 1
    else:
      even[V[idx]] = 1
  else:
    if V[idx] in odd:
      odd[V[idx]] += 1
    else:
      odd[V[idx]] = 1
sorted_odd = sorted(odd.items(), key=lambda x: -x[1])
sorted_even = sorted(even.items(), key=lambda x: -x[1])
fs_odd = sorted_odd[0][0]
fs_even = sorted_even[0][0]
if fs_odd == fs_even:
  elif sorted_odd[0][1] > sorted_even[0][1]:
    fs_even = sorted_even[1][0]
    print(N-odd[fs_odd]-even[fs_even])
  else:
    fs_odd = sorted_odd[1][0]
    print(N-odd[fs_odd]-even[fs_even])
else:
  print(N-odd[fs_odd]-even[fs_even])



Fixed submission:
N = int(input())
V = list(map(int, input().split()))

odd = {}
even = {}

for idx in range(N):
  if idx%2 == 0:
    if V[idx] in even:
      even[V[idx]] += 1
    else:
      even[V[idx]] = 1
  else:
    if V[idx] in odd:
      odd[V[idx]] += 1
    else:
      odd[V[idx]] = 1
sorted_odd = sorted(odd.items(), key=lambda x: -x[1])
sorted_even = sorted(even.items(), key=lambda x: -x[1])
fs_odd = sorted_odd[0][0]
fs_even = sorted_even[0][0]
if fs_odd == fs_even:
  if sorted_odd[0][1] > sorted_even[0][1]:
    fs_even = sorted_even[1][0]
    print(N-odd[fs_odd]-even[fs_even])
  elif sorted_odd[0][1] < sorted_even[0][1]:
    fs_odd = sorted_odd[1][0]
    print(N-odd[fs_odd]-even[fs_even])
  else:
    if len(sorted_odd) == 1:
      print(N//2)
    else:
      if sorted_odd[1][1] > sorted_even[1][1]:
        fs_odd = sorted_odd[1][0]
        print(N-odd[fs_odd]-even[fs_even])
      else:
        fs_even = sorted_even[1][0]
        print(N-odd[fs_odd]-even[fs_even])
else:
  print(N-odd[fs_odd]-even[fs_even])

Buggy python submission (verdict: Runtime Error):
N = int(input())
V = list(map(int, input().split()))

odd = {}
even = {}

for idx in range(N):
  if idx%2 == 0:
    if V[idx] in even:
      even[V[idx]] += 1
    else:
      even[V[idx]] = 1
  else:
    if V[idx] in odd:
      odd[V[idx]] += 1
    else:
      odd[V[idx]] = 1
sorted_odd = sorted(odd.items(), key=lambda x: -x[1])
sorted_even = sorted(even.items(), key=lambda x: -x[1])
fs_odd = sorted_odd[0][0]
fs_even = sorted_even[0][0]
if fs_odd == fs_even:
  elif sorted_odd[0][1] > sorted_even[0][1]:
    fs_odd = sorted_odd[0][0]
    print(N-odd[fs_odd]-even[fs_even])
  else:
    fs_even = sorted_even[0][0]
    print(N-odd[fs_odd]-even[fs_even])
else:
  print(N-odd[fs_odd]-even[fs_even])



Fixed submission:
N = int(input())
V = list(map(int, input().split()))

odd = {}
even = {}

for idx in range(N):
  if idx%2 == 0:
    if V[idx] in even:
      even[V[idx]] += 1
    else:
      even[V[idx]] = 1
  else:
    if V[idx] in odd:
      odd[V[idx]] += 1
    else:
      odd[V[idx]] = 1
sorted_odd = sorted(odd.items(), key=lambda x: -x[1])
sorted_even = sorted(even.items(), key=lambda x: -x[1])
fs_odd = sorted_odd[0][0]
fs_even = sorted_even[0][0]
if fs_odd == fs_even:
  if sorted_odd[0][1] > sorted_even[0][1]:
    fs_even = sorted_even[1][0]
    print(N-odd[fs_odd]-even[fs_even])
  elif sorted_odd[0][1] < sorted_even[0][1]:
    fs_odd = sorted_odd[1][0]
    print(N-odd[fs_odd]-even[fs_even])
  else:
    if len(sorted_odd) == 1:
      print(N//2)
    else:
      if sorted_odd[1][1] > sorted_even[1][1]:
        fs_odd = sorted_odd[1][0]
        print(N-odd[fs_odd]-even[fs_even])
      else:
        fs_even = sorted_even[1][0]
        print(N-odd[fs_odd]-even[fs_even])
else:
  print(N-odd[fs_odd]-even[fs_even])

Buggy python submission (verdict: Runtime Error):
N = int(input())
V = list(map(int, input().split()))

odd = {}
even = {}

for idx in range(N):
  if idx%2 == 0:
    if V[idx] in even:
      even[V[idx]] += 1
    else:
      even[V[idx]] = 1
  else:
    if V[idx] in odd:
      odd[V[idx]] += 1
    else:
      odd[V[idx]] = 1
sorted_odd = sorted(odd.items(), key=lambda x: -x[1])
sorted_even = sorted(even.items(), key=lambda x: -x[1])
fs_odd = sorted_odd[0][0]
fs_even = sorted_even[0][0]
if fs_odd == fs_even:
  if sorted_odd[1][1] > sorted_even[1][1]:
    fs_odd = sorted_odd[1][0]
    print(N-odd[fs_odd]-even[fs_even])
  else:
    fs_even = sorted_even[1][0]
    print(N-odd[fs_odd]-even[fs_even])
else:
  print(N-odd[fs_odd]-even[fs_even])



Fixed submission:
N = int(input())
V = list(map(int, input().split()))

odd = {}
even = {}

for idx in range(N):
  if idx%2 == 0:
    if V[idx] in even:
      even[V[idx]] += 1
    else:
      even[V[idx]] = 1
  else:
    if V[idx] in odd:
      odd[V[idx]] += 1
    else:
      odd[V[idx]] = 1
sorted_odd = sorted(odd.items(), key=lambda x: -x[1])
sorted_even = sorted(even.items(), key=lambda x: -x[1])
fs_odd = sorted_odd[0][0]
fs_even = sorted_even[0][0]
if fs_odd == fs_even:
  if sorted_odd[0][1] > sorted_even[0][1]:
    fs_even = sorted_even[1][0]
    print(N-odd[fs_odd]-even[fs_even])
  elif sorted_odd[0][1] < sorted_even[0][1]:
    fs_odd = sorted_odd[1][0]
    print(N-odd[fs_odd]-even[fs_even])
  else:
    if len(sorted_odd) == 1:
      print(N//2)
    else:
      if sorted_odd[1][1] > sorted_even[1][1]:
        fs_odd = sorted_odd[1][0]
        print(N-odd[fs_odd]-even[fs_even])
      else:
        fs_even = sorted_even[1][0]
        print(N-odd[fs_odd]-even[fs_even])
else:
  print(N-odd[fs_odd]-even[fs_even])

Buggy python submission (verdict: Runtime Error):
N = int(input())
V = list(map(int, input().split()))

odd = {}
even = {}

for idx in range(N):
  if idx%2 == 0:
    if V[i] in even:
      even[V[i]] = 1
    else:
      even[V[i]] += 1
  else:
    if V[i] in odd:
      odd[V[i]] = 1
    else:
      odd[V[i]] += 1
print(N-max(odd.values)-max(even.values))
    

Fixed submission:
N = int(input())
V = list(map(int, input().split()))

odd = {}
even = {}

for idx in range(N):
  if idx%2 == 0:
    if V[idx] in even:
      even[V[idx]] += 1
    else:
      even[V[idx]] = 1
  else:
    if V[idx] in odd:
      odd[V[idx]] += 1
    else:
      odd[V[idx]] = 1
sorted_odd = sorted(odd.items(), key=lambda x: -x[1])
sorted_even = sorted(even.items(), key=lambda x: -x[1])
fs_odd = sorted_odd[0][0]
fs_even = sorted_even[0][0]
if fs_odd == fs_even:
  if sorted_odd[0][1] > sorted_even[0][1]:
    fs_even = sorted_even[1][0]
    print(N-odd[fs_odd]-even[fs_even])
  elif sorted_odd[0][1] < sorted_even[0][1]:
    fs_odd = sorted_odd[1][0]
    print(N-odd[fs_odd]-even[fs_even])
  else:
    if len(sorted_odd) == 1:
      print(N//2)
    else:
      if sorted_odd[1][1] > sorted_even[1][1]:
        fs_odd = sorted_odd[1][0]
        print(N-odd[fs_odd]-even[fs_even])
      else:
        fs_even = sorted_even[1][0]
        print(N-odd[fs_odd]-even[fs_even])
else:
  print(N-odd[fs_odd]-even[fs_even])