Buggy python submission (verdict: Runtime Error):
n = int(input())
S = list(input())
S0 = {}
S1 = {}
for i, item in enumerate(S):
  if i%2 == 0:
    if item not in S0:
      S0[item] =1
    else:
      S0[item] += 1
  else:
    if item not in S1:
      S1[item] =1
    else:
      S1[item] += 1

S0list = list(S0.values()).sort(reverse=True)
S1list = list(S1.values()).sort(reverse=True)

S00 = S0list[0]
if len(S0list) == 1:
  S01 = 0
else:
  S01 = S0list[1]
S10 = S1list[0]
if len(S1list) == 1:
  S11 = 0
else:
  S11 = S1list[1]
Answer = min(len(S) - S00 - S11,len(S) - S01 - S10)

print(Answer)

Fixed submission:
n = int(input())
S = [int(x) for x in input().split()]

S0 = {}
S1 = {}
for i in range(len(S)):
  if i%2 == 0:
    if S[i] not in S0:
      S0[S[i]] =1
    else:
      S0[S[i]] += 1
  else:
    if S[i] not in S1:
      S1[S[i]] =1
    else:
      S1[S[i]] += 1

if max(S0, key = S0.get) != max(S1, key = S1.get):
  Answer = len(S) - max(S0.values()) -max(S1.values())
  print(Answer)
  exit()
      
S0list = sorted(list(S0.values()),reverse = True)
S1list = sorted(list(S1.values()),reverse = True)

S00 = S0list[0]

if len(S0list) == 1:
  S01 = 0
else:
  S01 = S0list[1]
S10 = S1list[0]
if len(S1list) == 1:
  S11 = 0
else:
  S11 = S1list[1]
Answer = min(len(S) - S00 - S11,len(S) - S01 - S10)

print(Answer)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
A = [int(x) for x in input().split()]
A1 = [A[2*i] for i in range(int(n/2))]
A2 = [A[2*i+1] for i in range(int(n/2))]
A1_count = [A1.count(A1[i]) for i in range(len(A1))]
A2_count = [A2.count(A2[i]) for i in range(len(A2))]
x= len(A1)+len(A2) - max(A1_count) -max(A2_count)
if (x==0) and (max(A1) == max(A2)):
  print(len(A1))
else:
  print(x)

Fixed submission:
n = int(input())
S = [int(x) for x in input().split()]

S0 = {}
S1 = {}
for i in range(len(S)):
  if i%2 == 0:
    if S[i] not in S0:
      S0[S[i]] =1
    else:
      S0[S[i]] += 1
  else:
    if S[i] not in S1:
      S1[S[i]] =1
    else:
      S1[S[i]] += 1

if max(S0, key = S0.get) != max(S1, key = S1.get):
  Answer = len(S) - max(S0.values()) -max(S1.values())
  print(Answer)
  exit()
      
S0list = sorted(list(S0.values()),reverse = True)
S1list = sorted(list(S1.values()),reverse = True)

S00 = S0list[0]

if len(S0list) == 1:
  S01 = 0
else:
  S01 = S0list[1]
S10 = S1list[0]
if len(S1list) == 1:
  S11 = 0
else:
  S11 = S1list[1]
Answer = min(len(S) - S00 - S11,len(S) - S01 - S10)

print(Answer)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
A = [int(x) for x in input().split()]
A1 = [A[2*i] for i in range(int(n/2))]
A2 = [A[2*i+1] for i in range(int(n/2))]
A1_count = [A1.count(A1[i]) for i in range(len(A1))]
A2_count = [A2.count(A2[i]) for i in range(len(A2))]
x= len(A1)+len(A2) - max(A1_count) -max(A2_count)
if (len(A1)==max(A1_count)) and (len(A2) == max(A2_count)) and (A1[0] == A2[0]):
  print(len(A1))
else:
  print(x)

Fixed submission:
n = int(input())
S = [int(x) for x in input().split()]

S0 = {}
S1 = {}
for i in range(len(S)):
  if i%2 == 0:
    if S[i] not in S0:
      S0[S[i]] =1
    else:
      S0[S[i]] += 1
  else:
    if S[i] not in S1:
      S1[S[i]] =1
    else:
      S1[S[i]] += 1

if max(S0, key = S0.get) != max(S1, key = S1.get):
  Answer = len(S) - max(S0.values()) -max(S1.values())
  print(Answer)
  exit()
      
S0list = sorted(list(S0.values()),reverse = True)
S1list = sorted(list(S1.values()),reverse = True)

S00 = S0list[0]

if len(S0list) == 1:
  S01 = 0
else:
  S01 = S0list[1]
S10 = S1list[0]
if len(S1list) == 1:
  S11 = 0
else:
  S11 = S1list[1]
Answer = min(len(S) - S00 - S11,len(S) - S01 - S10)

print(Answer)