Harryxun/GPT-100-sft-dataset huggingface dataset:
Problem p02812 (python)

Fixed submission:
N = input()
S = input()

res = 0
for i in range(len(S)-2):
  if S[i] == 'A' and S[i+1] == 'B' and S[i+2] == 'C':
    res += 1
    
print(res)

Buggy submission (verdict: Runtime Error):
S = intput()

res = 0
for i in range(len(S)-2):
  if S[i] == 'A' and S[i+1] == 'B' and S[i+2] == 'C':
    res += 1
    
print(res)
Problem p02844 (python)

Fixed submission:
N = int(input())
S = input()

ans = 0
tmp = [0 for _ in range(10)]
for i in range(len(S)):
    tmp[int(S[i])] += 1

for i in range(1000):
    flag = True

    if i < 10:
        dic = {"0": 2}
    elif i < 100:
        dic = {"0": 1}
    else:
        dic = {}
    for j in range(len(str(i))):
        if str(i)[j] in dic:
            dic[str(i)[j]] += 1
        else:
            dic[str(i)[j]] = 1

    for k, v in dic.items():
        if dic[k] > tmp[int(k)]:
            flag = False
            break

    if flag:
        if i < 10:
            tmp_i = "00" + str(i)
        elif i < 100:
            tmp_i = "0" + str(i)
        else:
            tmp_i = str(i)
        t = 0
        for j in range(len(S)):
            if tmp_i[t] == S[j]:
                t += 1
            if t == 3:
                ans += 1
                break

print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
S = input()

ans = 0
tmp = [0 for _ in range(10)]
for i in range(len(S)):
    tmp[int(S[i])] += 1

for i in range(1000):
    flag = True

    if i < 10:
        dic = {"0": 2}
    elif i < 100:
        dic = {"0": 1}
    else:
        dic = {}
    for j in range(len(str(i))):
        if str(i)[j] in dic:
            dic[str(i)[j]] += 1
        else:
            dic[str(i)[j]] = 1

    for k, v in dic.items():
        if dic[k] > tmp[int(k)]:
            flag = False
            break

    if flag:
        t = 0
        for j in range(len(S)):
            if str(i)[t] == S[j]:
                t += 1
            if t == 3:
                ans += 1
                break

print(ans)
Problem p02882 (python)

Fixed submission:
import math
a, b, x = map(int, input().split())

if a * a * b == x:
    print(0)
# 台形の場合
elif a * a * b < 2 * x:
    y = 2 * x / (a*a) - b
    print(90 - math.degrees(math.atan(a/(b-y))))

else:
    y = 2 * x / a / b
    print(90 - math.degrees(math.atan(y/b)))

Buggy submission (verdict: Runtime Error):
import math
a, b, x = map(int, input().split())

# 台形の場合
if a * a * b < 2 * x:
    y = 2 * x / (a*a) - b
    print(90 - math.degrees(math.atan(a/(b-y))))

elif a * a * b == 2 * x:
    print(90 - math.degrees(math.atan(a/b)))

else:
    y = 2 * x / a / b
    print(90 - math.degrees(math.atan(y/b)))

Buggy submission (verdict: Runtime Error):
import math
a, b, x = map(int, input().split())

# 台形の場合
if a * a * b <= 2 * x:
    y = 2 * x / (a*a) - b
    print(90 - math.degrees(math.atan(a/(b-y))))

else:
    y = 2 * x / a / b
    print(90 - math.degrees(math.atan(y/b)))

Buggy submission (verdict: Runtime Error):
import math
a, b, x = map(int, input().split())

y = 2 * x / (a*a) - b
print(90 - math.degrees(math.atan(a/(b-y))))

Buggy submission (verdict: Runtime Error):
import math
a, b, x = map(int, input().split())

y = 2 * x / (a*a) - b
print(math.degrees(math.atan(a/(b-y))))
Problem p02887 (python)

Fixed submission:
N = int(input())
L = input()

res = 1
for i in range(N-1):
  if L[i+1] != L[i]:
    res += 1
    
print(res)

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

res = 1
for i in range(N-1):
  if L[i+1] != L[i]:
    res += 1
    
print(res)
Problem p02910 (python)

Fixed submission:
n = input()

flag = True
for i in range(len(n)):
  if i%2 == 0:
    if n[i] == 'R' or n[i] == 'U' or n[i] == 'D':
      pass
    else:
      flag = False
      
  else:
    if n[i] == 'L' or n[i] == 'U' or n[i] == 'D':
      pass
    else:
      flag = False
      
if flag:
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
n = input()

flag = True
for i in range(N):
  if i%2 == 0:
    if n[i] == 'R' or n[i] == 'U' or n[i] == 'D':
      pass
    else:
      flag = False
      
  else:
    if n[i] == 'L' or n[i] == 'U' or n[i] == 'D':
      pass
    else:
      flag = False
      
if flag:
  print('Yes')
else:
  print('No')
Problem p02911 (python)

Fixed submission:
N, K, Q = map(int, input().split())

A = [int(input()) for _ in range(Q)]

dic = {}

for i in range(N):
    dic[i+1] = 0

for i in range(Q):
  if A[i] in dic:
    dic[A[i]] += 1
  else:
    dic[A[i]] = 1
    
    
for i in range(N):
  if K - (Q - dic[i+1]) <= 0:
    print('No')
    
  else:
    print('Yes')

Buggy submission (verdict: Runtime Error):
N, K, Q = map(int, input().split())

A = [int(input()) for _ in range(Q)]

dic = {}

for i in range(Q):
  if A[i] in dic:
    dic[A[i]] += 1
  else:
    dic[A[i]] = 1
    
    
for i in range(N):
  if K - (N - dic[A[i]]) <= 0:
    print('No')
    
  else:
    print('Yes')
Problem p02922 (python)

Fixed submission:
A, B = map(int, input().split())

tmp = 1
res = 0

while tmp < B:
  tmp -= 1
  tmp += A
  res += 1
  
print(res)

Buggy submission (verdict: Runtime Error):
A, B = map(input().split())

tmp = 1
ans = 0
while True:
    if tmp >= B:
        print(ans)
        break
    tmp += A - 1
Problem p02936 (python)

Fixed submission:
from collections import deque
import numpy as np

N, Q = map(int, input().split())
A = [list(map(int, input().split())) for _ in range(N-1)]
P = [list(map(int, input().split())) for _ in range(Q)]

link = [[] for _ in range(N)]
for i in range(N-1):
    link[A[i][0]-1].append(A[i][1]-1)
    link[A[i][1]-1].append(A[i][0]-1)


ans = [0 for _ in range(N)]
for i in range(Q):
  ans[P[i][0] - 1] += P[i][1]

dist = [-1 for _ in range(N)]
dist[0] = 0
d = deque([0])
while d:
    now = d.pop()
    for i in range(len(link[now])):
        if dist[link[now][i]] == -1:
            ans[link[now][i]] += ans[now]
            dist[link[now][i]] = 0
            d.append(link[now][i])

for i in range(N):
    if i != N - 1:
        print(ans[i], end=" ")
    else:
        print(ans[i])

Buggy submission (verdict: Runtime Error):
from collections import deque
import numpy as np

N, Q = map(int, input().split())
A = [list(map(int, input().split())) for _ in range(N-1)]
P = [list(map(int, input().split())) for _ in range(Q)]

dist = [-1 for _ in range(N)]
ans = [0 for _ in range(N)]
parent = [[] for _ in range(N)]
dist[0] = 0
d = deque([0])
while d:
    now = d.popleft()
    for i in range(N-1):
        if A[i][0] - 1 == now and dist[A[i][1] - 1] == -1:
            dist[A[i][1] - 1] = now + 1
            d.append(A[i][1] - 1)
            parent[A[i][1] - 1].append(dist[A[i][0] - 1])

        if A[i][1] - 1 == now and dist[A[i][0] - 1] == -1:
            dist[A[i][0] - 1] = now + 1
            d.append(A[i][0] - 1)
            parent[A[i][0] - 1].append(dist[A[i][1] - 1])

arg_dist = np.argsort(np.array(dist))

for i in range(Q):
    ans[P[i][0] - 1] += P[i][1]

for i in range(N):
    for j in range(len(parent[arg_dist[i]])):
        ans[arg_dist[i]] = ans[arg_dist[i]] + ans[parent[arg_dist[i]][j]]

for i in range(N):
    if i != N - 1:
        print(ans[arg_dist[i]], end=" ")
    else:
        print(ans[arg_dist[i]])

Buggy submission (verdict: Runtime Error):
from collections import deque
import numpy as np

N, Q = map(int, input().split())
A = [list(map(int, input().split())) for _ in range(N-1)]
P = [list(map(int, input().split())) for _ in range(Q)]

dist = [-1 for _ in range(N)]
ans = [0 for _ in range(N)]
parent = [[] for _ in range(N)]
dist[0] = 0
d = deque([0])
while d:
    now = d.popleft()
    for i in range(N-1):
        if A[i][0] - 1 == now and dist[A[i][1] - 1] == -1:
            dist[A[i][1] - 1] = now + 1
            d.append(A[i][1] - 1)
            parent[A[i][1] - 1].append(dist[A[i][0] - 1])

        if A[i][1] - 1 == now and dist[A[i][0] - 1] == -1:
            dist[A[i][0] - 1] = now + 1
            d.append(A[i][0] - 1)
            parent[A[i][0] - 1].append(dist[A[i][1] - 1])

arg_dist = np.argsort(np.array(dist))

for i in range(Q):
    ans[P[i][0] - 1] += P[i][1]

for i in range(N):
    for j in range(len(parent[arg_dist[i]])):
        ans[arg_dist[i]] = ans[arg_dist[i]] + ans[parent[arg_dist[i]][j]]

for i in range(N):
    if i != N - 1:
        print(ans[arg_dist[i]], end=" ")
    else:
        print(ans[arg_dist[i]])
Problem p03001 (python)

Fixed submission:
W, H, x, y = map(int, input().split())


if x == W / 2 and y == H / 2:
    print(W*H/2, 1)
else:
    print(W*H/2, 0)

Buggy submission (verdict: Runtime Error):
W, H, x, y = map(int, input().split())


ans1_1 = W * (H - y)
ans1_2 = W * y

ans2_1 = x * H
ans2_2 = (W - x) * H

if (x == 0 and y == 0) or (x == W and y == H) or (x == 0 and y == H) or (x == W and y == 0):
    print(W * H / 2, 0)
    
elif x == 0 or x == W 
    print(W * (y + (H - y))/2, 0)
    
elif y == 0 or y == H:
    print(H * (x + (W - x))/2, 0)
    
elif abs(ans1_1 - ans1_2) <  abs(ans2_1 - ans2_2):
    
    print(min(ans1_1, ans1_2), 0)
    
elif abs(ans1_1 - ans1_2) ==  abs(ans2_1 - ans2_2):
    
    print(min(ans1_1, ans1_2), 1)
    
else:
    print(min(ans2_1, ans2_2), 0)
Problem p03067 (python)

Fixed submission:
A, B, C = map(int, input().split())

res = "No"
if B > A:
    for i in range(A, B+1):
        if i == C:
            res = 'Yes'
            break
else:
    for i in range(B, A+1):
        if i == C:
            res = 'Yes'
            break
print(res)

Buggy submission (verdict: Runtime Error):
N = int(input())
S = input()
S = list(S)

tmp = [0 for _ in range(N+1)]

if S[0] == '.':
    tmp[0] = 1

for i in range(N):
    if S[i] == '.':
        tmp[i+1] = tmp[i] + 1
    else:
        tmp[i+1] = tmp[i]
  
res1 = 10 ** 9
for i in range(N):
    res1 = min((i+1) - tmp[i] + tmp[N] - tmp[i+1], res1)
        
b = 0
w = 0
for i in range(N):
    if S[i] == '#':
        b += 1
    else:
        w += 1

res3 = N - max(b, w)

print(min(res1, res3))
Problem p03069 (python)

Fixed submission:
N = int(input())
S = input()
S = list(S)

tmp = [0 for _ in range(N+1)]

#if S[0] == '.':
   # tmp[0] = 1

for i in range(N):
    if S[i] == '.':
        tmp[i+1] = tmp[i] + 1
    else:
        tmp[i+1] = tmp[i]
  
res1 = 10 ** 9
for i in range(N):
    res1 = min((i+1) - tmp[i+1] + tmp[N] - tmp[i+1], res1)
        
b = 0
w = 0
for i in range(N):
    if S[i] == '#':
        b += 1
    else:
        w += 1

res3 = N - max(b, w)

print(min(res1, res3))

Buggy submission (verdict: Runtime Error):
N = int(input())
S = input()
S = list(S)
K = S.copy()
T = S.copy()

tmp = [0 for _ in range(N)]

if S[0] == '.':
    tmp[0] = 1

for i in range(N-1):
    if S[i] == '.':
        tmp[i+1] = tmp[i] + 1
    else:
        tmp[i+1] = tmp[i]
  
res1 = 10 ** 9
for i in range(N):
    res1 = min( (i + 1) - tmp[i] + tmp[N-1] - tmp[i], res1)
        

b = 0
w = 0
for i in range(N):
    if K[i] == '#':
        b += 1
    else:
        w += 1

res3 = N - max(b, w)

print(min(res1, res2, res3))
Problem p03074 (python)

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

seq = []
tmp = 0
for i in range(N-1):
    if S[i] != S[i+1]:
        tmp += 1
        seq.append(tmp)
        tmp = 0
            
    else:
        tmp += 1

seq.append(tmp+1)

seq_sum = [0 for _ in range(len(seq)+1)]

for i in range(len(seq)):
    seq_sum[i+1] = seq_sum[i] + seq[i]

res = -1
if S[0] == '0':
    for i in range(len(seq_sum)):
        if i%2 == 0:
            r = min(i + 2*K, len(seq_sum)-1)
            res = max(res, seq_sum[r] - seq_sum[i]) 
        else:
            r = min(i + 2*K+1, len(seq_sum)-1)
            res = max(res, seq_sum[r] - seq_sum[i])
        
else:
    for i in range(len(seq_sum)):
        if i%2 == 0:
            r = min(i + 2*K+1, len(seq_sum)-1)
            res = max(res, seq_sum[r] - seq_sum[i])
        else:
            r = min(i + 2*K, len(seq_sum)-1)
            res = max(res, seq_sum[r] - seq_sum[i]) 

            
print(res)

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

seq = []

flag = False
tmp = 0
for i in range(N-1):
    if S[i] != S[i+1]:
        tmp += 1
        seq.append(tmp)
        tmp = 0
            
    else:
        tmp += 1

res1 = []     
res2 = []

seq.append(tmp+1)

seq_sum = [0 for _ in range(len(seq)+1)]

for i in range(len(seq)):
    seq_sum[i+1] = seq_sum[i] + seq[i]

res = 1
if S[0] == '0':
    for i in range(len(seq_sum) - 2 * K - 1):
        if i%2 == 0:
            r = min(i + 2*K, len(seq_sum))
            res = max(res, seq_sum[r] - seq_sum[i]) 
        else:
            r = min(i + 2*K+1, len(seq_sum))
            res = max(res, seq_sum[r] - seq_sum[i])
        
else:
    for i in range(len(seq_sum) - 2 * K):
        if i%2 == 0:
            r = min(i + 2*K+1, len(seq_sum))
            res = max(res, seq_sum[r] - seq_sum[i])
        else:
            r = min(i + 2*K, len(seq_sum))
            res = max(res, seq_sum[r] - seq_sum[i]) 
 


print(res)
Problem p03085 (python)

Fixed submission:
b = input()

if b == 'A':
    print('T')
elif b == 'T':
    print('A')
    
elif b == 'G':
    print('C')
else:
    print('G')

Buggy submission (verdict: Runtime Error):
b = input()

if b == 'A':
    print('T')
elif b == 'T':
    print('A')
    
elif B == 'G':
    print('C')
else:
    print('G')
Problem p03106 (python)

Fixed submission:
A, B, K = map(int, input().split())

t_list = []
for i in range(1, 10 ** 5):
    if A%i == 0 and B%i == 0:
        t_list.append(i)
           
print(t_list[-K])

Buggy submission (verdict: Runtime Error):
A, B, K = map(int, input().split())

t_list = []
for i in range(1, 10 ** 5):
    if A%i == 0 and B%i == 0:
        count += 1
        t_list.append(i)
        
        

        
print(t_list[-K])
Problem p03128 (python)

Fixed submission:
N, M = map(int, input().split())
A = list(map(int, input().split()))
match = {1:2, 2:5, 3:5, 4:4, 5:5, 6:6, 7:3, 8:7, 9:6}

dp = [-1 for i in range(N + 1)]

cost = []
for i in range(M):
    cost.append([A[i], match[A[i]]])

dp[0] = 0
for i in range(N):
    for k in range(M):
        if i + 1 - cost[k][1] >= 0:
            dp[i + 1] = max(dp[i + 1], dp[i + 1 - cost[k][1]] + 1)

tmp = 0 #使ったマッチの数
res = ''
cost.sort(key=lambda x: x[0], reverse=True)
for i in range(dp[N]):
    for j in range(M):
        if N - cost[j][1] - tmp >= 0:
            if dp[N - cost[j][1] - tmp] == dp[N - tmp] - 1:
                res = res + str(cost[j][0])
                tmp += cost[j][1]
                break
            
print(res)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
A = list(map(int, input().split()))
match = {1:2, 2:5, 3:5, 4:4, 5:5, 6:6, 7:3, 8:7, 9:6}

dp = [-1 for i in range(N + 1)]

cost = []
for i in range(M):
    cost.append([A[i], match[A[i]]])

dp[0] = 0
for i in range(N):
    for k in range(M):
        if i + 1 - cost[k][1] >= 0:
            dp[i + 1] = max(dp[i + 1], dp[i + 1 - cost[k][1]] + 1)

tmp = 0 #使ったマッチの数
res = ''
cost.sort(key=lambda x: x[0], reverse=True)
for i in range(dp[N]):
    for j in range(M):
        if dp[N - cost[j][1] - tmp] == dp[N - tmp] - 1:
            res = res + str(cost[j][0])
            tmp += cost[j][1]
            break
            
print(res)
Problem p03155 (python)

Fixed submission:
N = int(input())
H = int(input())
W = int(input())

print((N - H + 1) * (N - W + 1))

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

H, W = map(int, input().split())
S = [input() for _ in range(H)]

res = 0
for i in range(H):
    for j in range(W):
        stack = deque([])
        flag = [[False for _ in range(W)] for _ in range(H)]
        stack.append([i, j])
        flag[i][j] = True
        start = S[i][j]
        while len(stack) > 0:
            y, x = stack.popleft()
            for nx, ny in ([1, 0], [0, 1], [-1, 0], [0, -1]):
                if 0<= x + nx < W and 0 <= y + ny < H:
                    if S[y][x] != S[y+ny][x+nx] and flag[y+ny][x+nx] == False:
                        stack.append([y+ny, x+nx])
                        flag[y+ny][x+nx] = True
                        if S[y+ny][x+nx] != start:
                            res += 1
            
                
            
            
print(res//2)

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

H, W = map(int, input().split())
S = [input() for _ in range(H)]

res = 0
for i in range(H):
    for j in range(W):
        stack = deque([])
        flag = [[False for _ in range(W)] for _ in range(H)]
        stack.append([i, j])
        flag[i][j] = True
        start = S[i][j]
        while len(stack) > 0:
            y, x = stack.popleft()
            for nx, ny in ([1, 0], [0, 1], [-1, 0], [0, -1]):
                if 0<= x + nx < W and 0 <= y + ny < H:
                    if S[y][x] != S[y+ny][x+nx] and flag[y+ny][x+nx] == False:
                        stack.append([y+ny, x+nx])
                        flag[y+ny][x+nx] = True
                        if S[y+ny][x+nx] != start:
                            res += 1
            
                
            
            
print(res//2)
Problem p03194 (python)

Fixed submission:
N, P = map(int, input().split())
def prime_decomposition(n):
  i = 2
  table = []
  while i * i <= n:
    while n % i == 0:
      n /= i
      table.append(i)
    i += 1
  if n > 1:
    table.append(n)
  return table
prime = prime_decomposition(P)
now = -1
count = 0
res = 1
for i in range(len(prime)):
    if now != prime[-i-1]:
        count = 0
        now = prime[-i-1]
    count += 1
    if count == N:
        res *= prime[-i-1]
        count = 0
print(int(res))

Buggy submission (verdict: Runtime Error):
N, P = map(int, input().split())
prime = prime_decomposition(P)
now = -1
count = 0
res = 1
for i in range(len(prime)):
    if now != prime[-i-1]:
        count = 0
        now = prime[-i-1]
    count += 1
    if count == N:
        res *= prime[-i-1]
print(int(res))
Problem p03212 (python)

Fixed submission:
import itertools

N = int(input())
nums = [3, 5, 7]
res = 0
for i in range(10):
  for balls in itertools.product(nums, repeat=i):
    num = ''
    if 3 in balls and 5 in balls and 7 in balls:
      for j in range(i):
        num += str(balls[j])
      if int(num) > N:
        break
      res += 1

print(res)

Buggy submission (verdict: Runtime Error):
import itertools

N = int(input())

number = [7, 5, 3]

ans = 0
for i in range(10):
    for conv in itertools.product(number, repeat=i+1):
        
        tmp = 0
        for j in range(len(conv)):
            tmp += conv[j] * 10 ** (len(conv) - j - 1)
            
        
        if ((3 in conv) and (5 in conv) and (7 in conv)) and tmp =< N:
            ans += 1
            
        
print(ans)
Problem p03227 (python)

Fixed submission:
N = input()
a = N.split()
if len(N) == 2:
    print(N)
else:
    print(N[2]+N[1]+N[0])

Buggy submission (verdict: Runtime Error):
N = int(input())
l=[int(input()) for i in range(N)]
l.sort()
res = 0
k = 0
o = 0
if N%2 == 0:
    a = l[:int(N/2)]
    a.reverse()
    b = l[int(N/2):]
    b.reverse()
    for i in range(N-1):
        res += b[k] - a[o]
        if i%2 == 0:
            o += 1
        if i%2 == 1:
            k += 1
else:
    a = l[:int(N/2)]
    b = l[int(N/2)+1:]
    b.reverse()
    for i in range(N-2):
        res += b[k] - a[o]
        if i%2 == 0:
            k += 1
        if i%2 == 1:
            o += 1
    res += max(abs(a[-1] - l[int(N/2)]), abs(b[-1] - l[int(N/2)]))
print(res)
Problem p03238 (python)

Fixed submission:
N = int(input())

if N == 1:
  print("Hello World")
else:
  A= int(input())
  B= int(input())
  print(A+B)

Buggy submission (verdict: Runtime Error):
N = int(input())

if N == 1:
  print("Hello World")
else:
  A, B = map(int, input().split())
  print(A+B)

Buggy submission (verdict: Runtime Error):
N = input()
if N == 1:
  print("Hello World")
else:
  A, B = map(int, input().split())
  print(A+B)
Problem p03239 (python)

Fixed submission:
N, T = map(int, input().split())
L = [list(map(int, input().split())) for i in range(N)]

res = 10000

for i in range(N):
  if L[i][1] <= T:
    if res > L[i][0]:
      res = L[i][0]
     
if res == 10000:
  res = 'TLE'
print(res)

Buggy submission (verdict: Runtime Error):
N, T = map(int, input().split())
L = [list(map(int, input().split())) for i in range(N)]

res = 10000

for i in range(N):
  if L[1] <= T:
    if res > L[0]:
      res = L[0]
     
if res == 10000:
  res = 'TLE'
print(res)
Problem p03244 (python)

Fixed submission:
import collections

N = int(input())
l = list(map(int, input().split()))

a = []
b = []
a_f = 0
b_f = 0
a_s = 0
b_s = 0
for i in range(N):
    if i%2 == 0:
        a.append(l[i])
    else:
        b.append(l[i])
        
c_a = collections.Counter(a)
c_b = collections.Counter(b)

a_f = c_a.most_common()[0]
b_f = c_b.most_common()[0]

if a_f[0] != b_f[0]:
    print(N - a_f[1] - b_f[1])

elif len(set(a)) == 1 and len(set(b)) == 1:
    print(int(N/2))
elif len(set(a)) == 1:
    print(int(N/2 - c_b.most_common()[1][1]))
elif len(set(b)) == 1:
    print(int(N/2 - c_a.most_common()[1][1]))
elif a_f[1] == b_f[1]:
    second_a = c_a.most_common()[1][1]
    second_b = c_b.most_common()[1][1]
    if second_a >= second_b:
        print(int(N - b_f[1] - second_a))
    else:
        print(int(N - a_f[1] - second_b))
elif a_f[1] > b_f[1]:
    print(int(N - a_f[1] - c_b.most_common()[1][1]))
else:
    print(int(N - b_f[1] - c_a.most_common()[1][1]))

Buggy submission (verdict: Runtime Error):
import collections

N = int(input())
l = list(map(int, input().split()))

a = []
b = []
a_f = 0
b_f = 0
a_s = 0
b_s = 0
for i in range(N):
    if i%2 == 0:
        a.append(l[i])
    else:
        b.append(l[i])
        
c_a = collections.Counter(a)
c_b = collections.Counter(b)

a_f = c_a.most_common()[0]
b_f = c_b.most_common()[0]

if a_f[0] != b_f[0]:
    print(N - a_f[1] - b_f[1])

elif len(set(a)) == 1 and len(set(b)) == 1:
    print(int(N/2))
elif len(set(a)) == 1:
    print(int(N/2 - c_b.most_common()[1][1]))
elif len(set(b)) == 1:
    print(int(N/2 - c_a.most_common()[1][1]))
elif a_f[1] == b_f[1]:
    second_a = c_a.most_common()[1][1]
    second_b = c_b.most_common()[1][1]
    if second_a >= second_b:
        print(int(N - b_f[1] - second_a)
    else:
        print(int(N - a_f[1] - second_b)
elif a_f[1] > b_f[1]:
    print(int(N - a_f[1] - c_b.most_common()[1][1]))
else:
    print(int(N - b_f[1] - c_a.most_common()[1][1]))

Buggy submission (verdict: Runtime Error):
import collections

N = int(input())
l = list(map(int, input().split()))

a = []
b = []
a_f = 0
b_f = 0
a_s = 0
b_s = 0
for i in range(N):
    if i%2 == 0:
        a.append(l[i])
    else:
        b.append(l[i])
        
c_a = collections.Counter(a)
c_b = collections.Counter(b)

a_f = c_a.most_common()[0]
b_f = c_b.most_common()[0]

if a_f[0] != b_f[0]:
    print(N - a_f[1] - b_f[1])

elif len(set(a)) == 1 and len(set(b)) == 1:
    print(int(N/2))
elif len(set(a)) == 1:
    print(int(N/2 - c_b.most_common()[1][1]))
elif len(set(b)) == 1:
    print(int(N/2 - c_a.most_common()[1][1]))
elif a_f[1] == b_f[1]:
    if c_a.most_common()[1][1] >= c_b.most_common()[1][1]:
        print(int(N - b_f[1] - c_a.most_common()[1][1]))
    else:
        print(int(N - a_f[1] - b_a.most_common()[1][1]))
elif a_f[1] > b_f[1]:
    print(int(N - a_f[1] - c_b.most_common()[1][1]))
else:
    print(int(N - b_f[1] - c_a.most_common()[1][1]))