Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
mod = pow(10, 9) + 7
class Combination:
    def __init__(self, N):
        self.fac = [1] * (N + 1)
        for i in range(1, N + 1):
            self.fac[i] = (self.fac[i - 1] * i) % mod
        self.invmod = [1] * (N + 1)
        self.invmod[N] = pow(self.fac[N], mod - 2, mod)
        for i in range(N, 0, -1):
            self.invmod[i - 1] = (self.invmod[i] * i) % mod

    def calc(self, n, k):  # nCk
        return self.fac[n] * self.invmod[k] % mod * self.invmod[n - k] % mod

x, y = map(int, input().split())
left, right = 0, 0
a, b = max(x, y), min(x, y)

if (2*b - a) % 3 == 0:
    d, s = a - b, (2*b - a)//3
    p, q = d + s, s
    C = Combination(p+q)
    print(C.calc(p+q, q))
else:
    print(0)

Fixed submission:
from functools import reduce
x, y = map(int, input().split())
mod = pow(10,9)+7

min_value = min(x, y)
max_value = max(x, y)
#print(min_value, max_value)
dif_value = max_value - min_value
#print(dif_value)
a_value   = min_value - dif_value
a_num     = int(a_value*2*(1/3))
#print(a_value, a_num)
n = dif_value + a_num
r = int(a_num*0.5)
#print(n, r)

def nCr(n,r,DIV):
  if r<n-r:
    r=n-r
  if r==0:
    return 1
  f=lambda x,y:x*y%DIV
  X=reduce(f,range(n-r+1,n+1))
  Y=reduce(f,range(1,r+1))
  return X*pow(Y,DIV-2,DIV)%DIV

if a_value % 3 == 0:
    print(nCr(n, r, mod))
else:
    print(0)
Buggy python submission (verdict: Runtime Error):
n = int(input())

#約数
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

list_n = make_divisors(n)

a = len(list_n)
ans = []
for i in range(0, a, 2):
    ans.append(list_n[i]+list_n[i+1])

ans.sort()

print(ans[0]-2)

Fixed submission:
n = int(input())

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            divisors.append(n//i)

    # divisors.sort()
    return divisors

n_list = make_divisors(n)
n_ans = []

for i in range(0, len(n_list)-1, 2):
    n_ans.append(n_list[i]+n_list[i+1])

n_ans.sort()

print(n_ans[0]-2)
Buggy python submission (verdict: Time Limit Exceeded):
import itertools

n = int(input())
list_score = list(map(int, input().split()))
list_score.sort()
ans = 0

for i in range(0, n):
    for j in range(i+1, n):
        for k in range(i+1, j):
            if list_score[k] + list_score[i] > list_score[j]:
                ans += 1

print(ans)

Fixed submission:
from bisect import bisect_left
n = int(input())
list_L = list(map(int, input().split()))
list_L.sort()
ans = 0

for i in range(n):
    for j in range(i+1, n):
        ans += bisect_left(list_L, list_L[i]+list_L[j]) - j - 1

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import itertools

n = int(input())
list_score = list(map(int, input().split()))
list_score.sort()
p_list = list(itertools.combinations(list_score, 3))
a = len(p_list)
ans = 0

for i in range(a):
    if p_list[i][0] + p_list[i][1] > p_list[i][2]:
       ans += 1

print(ans)

Fixed submission:
from bisect import bisect_left
n = int(input())
list_L = list(map(int, input().split()))
list_L.sort()
ans = 0

for i in range(n):
    for j in range(i+1, n):
        ans += bisect_left(list_L, list_L[i]+list_L[j]) - j - 1

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import itertools

n = int(input())
list_score = list(map(int, input().split()))

p_list = list(itertools.combinations(list_score, 3))
a = len(p_list)
ans = 0

for i in range(a):
    if p_list[i][0] + p_list[i][1] > p_list[i][2] and p_list[i][1] + p_list[i][2] > p_list[i][0] and p_list[i][2] + p_list[i][0] > p_list[i][1]:
       ans += 1

print(ans)

Fixed submission:
from bisect import bisect_left
n = int(input())
list_L = list(map(int, input().split()))
list_L.sort()
ans = 0

for i in range(n):
    for j in range(i+1, n):
        ans += bisect_left(list_L, list_L[i]+list_L[j]) - j - 1

print(ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())
list_score = list(map(int, input().split()))
ans = []
score = 0

for i in range(n-1):
    if list_score[i] >= list_score[i+1]:
        score += 1
    else:
        ans.append(score)
        score = 0
    if i == n-2:
        ans.append(score)

    #print(score, ans)

print(max(ans))

Fixed submission:
n = int(input())
list_score = list(map(int, input().split()))
ans = []
score = 0
if len(list_score) == 1:
    print(0)
else:
    for i in range(n-1):
        if list_score[i] >= list_score[i+1]:
            score += 1
        else:
            ans.append(score)
            score = 0
        if i == n-2:
            ans.append(score)

        #print(score, ans)

    print(max(ans))

Buggy python submission (verdict: Runtime Error):
n = int(input())
list_score = list(map(int, input().split()))
ans = []
score = 0

for i in range(n-1):
    if list_score[i] >= list_score[i+1]:
        score += 1
    else:
        ans.append(score)
        score = 0
    if i == n-2:
        ans.append(score)

    #print(score, ans)

print(max(ans))

Fixed submission:
n = int(input())
list_score = list(map(int, input().split()))
ans = []
score = 0
if len(list_score) == 1:
    print(0)
else:
    for i in range(n-1):
        if list_score[i] >= list_score[i+1]:
            score += 1
        else:
            ans.append(score)
            score = 0
        if i == n-2:
            ans.append(score)

        #print(score, ans)

    print(max(ans))
Buggy python submission (verdict: Time Limit Exceeded):
n, q = map(int, input().split())
tree = [[] for _ in range(n)]
point = [0] * n
for _ in range(n-1):
    a, b = map(int, input().split())
    tree[a-1].append(b-1)
    tree[b-1].append(a-1)

for _ in range(q):
    p, x = map(int, input().split())
    point[p-1] += x

q = [[0, 0]]
while True:
    if len(q) == 0:
        break
    child, parent = q.pop(0)
    p = point[child]
    for i in tree[child]:
        if i == parent:
            continue
        point[i] += p
        q.append([i, child])

print(*point)

Fixed submission:
n, q = map(int, input().split())
tree = [[] for _ in range(n)]
point = [0] * n
for _ in range(n-1):
    a, b = map(int, input().split())
    tree[a-1].append(b-1)
    tree[b-1].append(a-1)

for _ in range(q):
    p, x = map(int, input().split())
    point[p-1] += x

stack = [[0, 0, -1]]
while stack:
  v, p, parent = stack.pop()
  point[v] += p
  for child in tree[v]:
    if child == parent:
      continue
    stack.append([child,point[v],v])

print(*point)

Buggy python submission (verdict: Time Limit Exceeded):
n, q = map(int, input().split())
tree = [[] for _ in range(n)]
point = [0] * n
for _ in range(n-1):
    a, b = map(int, input().split())
    tree[a-1].append(b-1)
    tree[b-1].append(a-1)

for _ in range(q):
    p, x = map(int, input().split())
    point[p-1] += x

q = [[0, 0]]
while True:
    if len(q) == 0:
        break
    child, parent = q.pop(0)
    for i in tree[child]:
        if i == parent:
            continue
        point[i] += point[child]
        q.append([i, child])

print(*point)

Fixed submission:
n, q = map(int, input().split())
tree = [[] for _ in range(n)]
point = [0] * n
for _ in range(n-1):
    a, b = map(int, input().split())
    tree[a-1].append(b-1)
    tree[b-1].append(a-1)

for _ in range(q):
    p, x = map(int, input().split())
    point[p-1] += x

stack = [[0, 0, -1]]
while stack:
  v, p, parent = stack.pop()
  point[v] += p
  for child in tree[v]:
    if child == parent:
      continue
    stack.append([child,point[v],v])

print(*point)
Buggy python submission (verdict: Time Limit Exceeded):
import heapq

n = int(input())
list_score = []
for i in range(n):
    list_score.append(int(input()))

list_ans = list_score.copy()
list_ans.sort()
heapq.heapify(list_ans)

for i in range(n):
    a = list_score[i]
    list_ans.remove(a)
    print(list_ans[-1])
    heapq.heappush(list_ans, a)

Fixed submission:
import heapq

n = int(input())
list_score = []
for i in range(n):
    list_score.append(int(input()))

list_ans = list_score.copy()
list_ans.sort()


for i in range(n):
    a = list_score[i]
    if a == list_ans[-1]:
        print(list_ans[-2])
    else:
        print(list_ans[-1])
Buggy python submission (verdict: Time Limit Exceeded):
a, b = map(int, input().split())
ans = 200000
for i in range(a, b):
    for j in range(a+1, b+1):
        ans = min(ans, i*j%2019)
        if ans == 0:
            break

print(ans)

Fixed submission:
a, b = map(int, input().split())
ans = 20000000
n = a//2019
m = b//2019
a = a % 2019
b = b % 2019

if a > b:
    ans = 0
else:
    for i in range(a, b):
        for j in range(a+1, b+1):
            ans = min(ans, i*j%2019)
if m != n:
    ans = 0

if a == b:
    ans = 0

print(ans)
Buggy python submission (verdict: Runtime Error):
import math
a, b, c, d = map(int, input().split())
ans = 0

def lcm(x, y):
    return (x * y) // math.gcd(x, y)

k = b-a+1

amri_c = a % c
if amri_c == 0:
    amri_c = c
    k_c = (k - (amri_c - 1)) // c
else:
    k_c = (k - (amri_c - 1)) // c + 1

amri_d = a % d
if amri_d == 0:
    amri_d = d
    k_d = (k - (amri_d - 1)) // d
else:
    k_d = (k - (amri_d - 1)) // d + 1

amri_cd = a % lcm(c, d)
if amri_cd == 0:
    amri_cd = lcm(c, d)
    k_cd = (k - (amri_cd - 1)) // lcm(c, d)
else:
    k_cd = (k - (amri_cd - 1)) // lcm(c, d) + 1

ans = k-k_c-k_d+k_cd

print(ans)

Fixed submission:
import fractions
a, b, c, d = map(int, input().split())
ans = 0

def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)

def k(x):
    return x - (x//c + x//d - x//lcm(c, d))

print(k(b)-k(a-1))
Buggy python submission (verdict: Runtime Error):
w, h, x, y = map(int, input().split())

are_w = min(w*y, w*(h-y))
are_h = min(x*h, (w-x)*h)

ans_are = max(are_w, are_h)
ans = 0
if are_w == are_h:
    ans = 1

if x == w and y == h:
    ans_are = w*h/2
    ans = 0

if x == 0 and y == 0:
    ans_are = w*h/2
    ans = 0
    
if x == 0 and y == h:
    ans_are = w*h/2
    ans = 0

if x == w and y == 0:
    ans_are = w*h/2
    ans = 0

if w/h == x/y:
    ans_are = w*h/2
    ans = 0

print(ans_are, ans)



Fixed submission:
w, h, x, y = map(int, input().split())
ans = 0
if w == 2*x and h == 2*y:
    ans = 1
print(w*h/2, ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
list_L = [int(input()) for _ in range(5)]
list_H = [n, 0, 0, 0, 0, 0]
ans = 1
while True:
    if list_H[5] == n:
        break
    for i in range(4, -1, -1):
        if list_H[i] >= list_L[i]:
            list_H[i+1] += list_L[i]
            list_H[i] -= list_L[i]
        else:
            list_H[i+1] += list_H[i]
            list_H[i] -= list_H[i]
    ans += 1

print(ans-1)

Fixed submission:
n = int(input())
list_L = [int(input()) for _ in range(5)]
list_L.sort()
ans = 0
ans += 5 + n//list_L[0]

if n%list_L[0] == 0:
    ans -= 1

print(ans)
Buggy python submission (verdict: Runtime Error):
s = input()
list_s = list(s)
k = 0
ans = []
for i in range(len(list_s)):
    c = list_s[i]
    if c == "A" or c == "C" or c == "G" or c == "T":
        k += 1
    else:
        ans.append(k)
        k = 0

print(max(ans))

Fixed submission:
s = input()
list_s = list(s)
k = 0
ans = []
for i in range(len(list_s)):
    c = list_s[i]
    if c == "A" or c == "C" or c == "G" or c == "T":
        k += 1
    else:
        ans.append(k)
        k = 0
if k != 0:
    ans.append(k)
print(max(ans))

Buggy python submission (verdict: Runtime Error):
s = input()
list_s = list(s)
k = 0
ans = []
for c in list_s:
    if c == "A" or c == "C" or c == "G" or c == "T":
        k += 1
    else:
        ans.append(k)
        k = 0

print(max(ans))

Fixed submission:
s = input()
list_s = list(s)
k = 0
ans = []
for i in range(len(list_s)):
    c = list_s[i]
    if c == "A" or c == "C" or c == "G" or c == "T":
        k += 1
    else:
        ans.append(k)
        k = 0
if k != 0:
    ans.append(k)
print(max(ans))
Buggy python submission (verdict: Time Limit Exceeded):
n, q = map(int, input().split())
s = input()
list_s = list(s)
list_score = [ list(map(int,input().split(" "))) for i in range(q)]
list_c = []
for i in range(n-1):
    if list_s[i] == "A" and list_s[i+1] == "C":
        list_c.append(1)
    else:
        list_c.append(0)

for i in range(q):
    g = list_score[i]
    print(sum(list_c[g[0]-1:g[1]-1]))

Fixed submission:
n, q = map(int, input().split())
s = input()
list_s = list(s)
list_score = [ list(map(int,input().split(" "))) for i in range(q)]
list_c = [0]
a = 0
for i in range(n-1):
    if list_s[i] == "A" and list_s[i+1] == "C":
        a += 1
        list_c.append(a)
    else:
        list_c.append(a)

for i in range(q):
    g = list_score[i]
    print(list_c[g[1]-1]-list_c[g[0]-1])

Buggy python submission (verdict: Time Limit Exceeded):
n, q = map(int, input().split())
s = input()
list_s = list(s)
list_score = [ list(map(int,input().split(" "))) for i in range(q)]
list_c = []
for i in range(n-1):
    if list_s[i] == "A" and list_s[i+1] == "C":
        list_c.append([i+1, i+2])


ans = 0

for i in range(q):
    g = list_score[i]
    ans = 0
    for j in range(len(list_c)):
        f = list_c[j]
        if g[0] <= f[0] and f[1] <= g[1]:
            ans += 1

    print(ans)




Fixed submission:
n, q = map(int, input().split())
s = input()
list_s = list(s)
list_score = [ list(map(int,input().split(" "))) for i in range(q)]
list_c = [0]
a = 0
for i in range(n-1):
    if list_s[i] == "A" and list_s[i+1] == "C":
        a += 1
        list_c.append(a)
    else:
        list_c.append(a)

for i in range(q):
    g = list_score[i]
    print(list_c[g[1]-1]-list_c[g[0]-1])

Buggy python submission (verdict: Time Limit Exceeded):
n, q = map(int, input().split())
s = input()
list_s = list(s)
list_score = [ list(map(int,input().split(" "))) for i in range(q)]

for i in range(q):
    a = list_score[i]
    b = list_s[a[0]-1:a[1]]
    c = "".join(b)
    print(c.count("AC"))

Fixed submission:
n, q = map(int, input().split())
s = input()
list_s = list(s)
list_score = [ list(map(int,input().split(" "))) for i in range(q)]
list_c = [0]
a = 0
for i in range(n-1):
    if list_s[i] == "A" and list_s[i+1] == "C":
        a += 1
        list_c.append(a)
    else:
        list_c.append(a)

for i in range(q):
    g = list_score[i]
    print(list_c[g[1]-1]-list_c[g[0]-1])
Buggy python submission (verdict: Time Limit Exceeded):
a, b = map(int, input().split())
ans = a
for i in range(a+1, b+1):
    ans ^= i

print(ans)

Fixed submission:
a, b = map(int, input().split())
p, q = (a+1)//4, (b+1)//4
x, y = (a+1)%4, (b+1)%4
if abs(a-b) < 4:
    ans = a
    for i in range(a+1, b+1):
        ans ^= i
    print(ans)

else:
    if x == 0:
        ans = a

        if y == 1:
            ans ^= b
        elif y == 2:
            ans ^= b
            ans ^= (b-1)
        elif y == 3:
            ans ^= b
            ans ^= (b-1)
            ans ^= (b-2)
        elif y == 0:
            ans ^= 0

        print(ans)

    elif x == 1:
        ans = 0

        if y == 1:
            ans ^= b
        elif y == 2:
            ans ^= b
            ans ^= (b-1)
        elif y == 3:
            ans ^= b
            ans ^= (b-1)
            ans ^= (b-2)
        elif y == 0:
            ans ^= 0

        print(ans)

    elif x == 2:
        ans = a
        ans ^= (a+1)
        ans ^= (a+2)

        if y == 1:
            ans ^= b
        elif y == 2:
            ans ^= b
            ans ^= (b-1)
        elif y == 3:
            ans ^= b
            ans ^= (b-1)
            ans ^= (b-2)
        elif y == 0:
            ans ^= 0

        print(ans)

    elif x == 3:
        ans = a
        ans ^= (a+1)

        if y == 1:
            ans ^= b
        elif y == 2:
            ans ^= b
            ans ^= (b-1)
        elif y == 3:
            ans ^= b
            ans ^= (b-1)
            ans ^= (b-2)
        elif y == 0:
            ans ^= 0

        print(ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())
list_A = list(map(int, input().split()))

ans = 0
min_value = max(list_A)
for s in list_A:
    if s % 2 == 1:
        ans = 1
        break
    if s <= min_value:
        min_value = s
        ans = s
if max(list_A) == min(list_A)
    ans = list_A[0]
print(ans)


Fixed submission:
import fractions

n = int(input())
list_A = list(map(int, input().split()))
ans = fractions.gcd(list_A[0], list_A[1])
for i in range(2, n):
    ans = fractions.gcd(ans, list_A[i])

print(ans)
Buggy python submission (verdict: Runtime Error):
n, k = map(int, input().split())
list_H = [int(input()) for _ in range(n)]

list_H.sort()
ans = []

for i in range(n-k+1):
    ans.append(list_H[i+2]-list_H[i])

print(min(ans))

Fixed submission:
n, k = map(int, input().split())
list_H = [int(input()) for _ in range(n)]

list_H.sort()
ans = []

for i in range(n-k+1):
    ans.append(list_H[i+k-1]-list_H[i])

print(min(ans))
Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())
list_PY = [ list(map(int,input().split(" "))) for _ in range(m)]
list_K = [[] for _ in range(n + 1)]

for p, y in list_PY:
    list_K[p].append(y)

for l in list_K:
    l.sort()

for p, y in list_PY:
    u = str(p)
    u = "0" * (6 - len(u)) + u

    d = str(list_K[p].index(y) + 1)
    d = "0" * (6 - len(d)) + d

    print(u + d)

Fixed submission:
n, m = map(int, input().split())
list_PY = [ list(map(int,input().split(" "))) for i in range(m)]

for i in range(m):
    l = list_PY[i]
    l.append(i)
list_PY.sort(key=lambda x:(x[0], x[1]))

cnt = 0
k = 0
for i in range(m):
    l = list_PY[i]
    if l[0] == k:
        cnt += 1
        a = len(list(str(l[0])))
        b = "0"*(6 - a) + str(l[0])
        c = len(list(str(cnt)))
        d = "0"*(6 - c) + str(cnt)
    else:
        k = l[0]
        cnt = 1
        a = len(list(str(l[0])))
        b = "0" * (6 - a) + str(l[0])
        c = len(list(str(cnt)))
        d = "0" * (6 - c) + str(cnt)
    l.append(b+d)


list_PY.sort(key=lambda x:x[2])

for i in range(m):
    print(list_PY[i][3])

Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())
list_PY = [ list(map(int,input().split(" "))) for _ in range(m)]
list_K = [[] for _ in range(n + 1)]

for p, y in list_PY:
    list_K[p].append(y)

for l in list_K:
    l.sort()

for p, y in list_PY:
    u = str(p)
    while True:
        if len(u) == 6:
            break
        u = "0" + u

    d = str(list_K[p].index(y) + 1)

    while True:
        if len(d) == 6:
            break
        d = "0" + d

    print(u + d)

Fixed submission:
n, m = map(int, input().split())
list_PY = [ list(map(int,input().split(" "))) for i in range(m)]

for i in range(m):
    l = list_PY[i]
    l.append(i)
list_PY.sort(key=lambda x:(x[0], x[1]))

cnt = 0
k = 0
for i in range(m):
    l = list_PY[i]
    if l[0] == k:
        cnt += 1
        a = len(list(str(l[0])))
        b = "0"*(6 - a) + str(l[0])
        c = len(list(str(cnt)))
        d = "0"*(6 - c) + str(cnt)
    else:
        k = l[0]
        cnt = 1
        a = len(list(str(l[0])))
        b = "0" * (6 - a) + str(l[0])
        c = len(list(str(cnt)))
        d = "0" * (6 - c) + str(cnt)
    l.append(b+d)


list_PY.sort(key=lambda x:x[2])

for i in range(m):
    print(list_PY[i][3])
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
list_XYH = []
m = pow(10, 10)
for _ in range(n):
    x, y, h = map(int, input().split())
    m = min(m, h)
    list_XYH.append([x, y, h])

for X in range(0, 101):
    for Y in range(0, 101):
        for H in range(m, m + 201):
            cnt = 0
            for x, y, h in list_XYH:
                if max(H - abs(x - X) - abs(y - Y), 0) == h:
                    cnt += 1

            if cnt == n:
                print(X, Y, H)
                exit()

Fixed submission:
n = int(input())
list_XYH1, list_XYH = [ list(map(int,input().split(" "))) for _ in range(n)], []
for x, y, h in list_XYH1:
    if h != 0:
        list_XYH.append([x, y, h])

for i in range(0, 101):
    for j in range(0, 101):
        cnt = 0
        x, y, h = list_XYH[0]
        H = h + abs(i - x) + abs(j - y)
        for x, y, h in list_XYH:
            if h + abs(i - x) + abs(j - y) == H:
                cnt += 1

        if cnt == len(list_XYH) and cnt != 0 and cnt != 1:
            print(i, j, H)
            exit()

list_XYH2 = []
m = pow(10, 10)
for x, y, h in list_XYH1:
    m = min(m, h)
    list_XYH2.append([x, y, h])

for X in range(0, 101):
    for Y in range(0, 101):
        for H in range(m, m + 201):
            cnt = 0
            for x, y, h in list_XYH2:
                if max(H - abs(x - X) - abs(y - Y), 0) == h:
                    cnt += 1

            if cnt == n:
                print(X, Y, H)
                exit()
Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())
h = m // n
ans = 0

while True:
    if m % h == 0:
        break
    h -= 1

print(h)

Fixed submission:
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

n, m = map(int, input().split())
h = m // n
ans = 0

for d in make_divisors(m):
    if d <= h:
        ans = max(ans, d)

print(ans)
Buggy python submission (verdict: Runtime Error):
import itertools

n = int(input())
list_A = list(map(int, input().split()))
L, R = [], []
A, B = [[-1, 0], [-1, 0]]

for i in range(n):
    if i % 2 == 0:
        L.append(list_A[i])
    else:
        R.append(list_A[i])

L = itertools.groupby(L)
for key, group in L:
    A.append([key, len(list(group))])

A.sort(key=lambda x:x[1], reverse=True)

R = itertools.groupby(R)
for key, group in R:
    B.append([key, len(list(group))])

B.sort(key=lambda x:x[1], reverse=True)

if A[0][0] != B[0][0]:
    print(n - A[0][1] - B[0][1])
else:
    print(min(n - A[1][1] - B[0][1], n - A[0][1] - B[1][1]))

Fixed submission:
n = int(input())
list_V = list(map(int, input().split()))

list_Vx = []
list_Vy = []

for i, s in enumerate(list_V):
    if i % 2 == 0:
        list_Vx.append(s)
    else:
        list_Vy.append(s)

list_Vx_Count = [0 for _ in range(pow(10, 5))]
list_Vy_Count = [0 for _ in range(pow(10, 5))]

for i in list_Vx:
    list_Vx_Count[i-1] += 1
for i in list_Vy:
    list_Vy_Count[i-1] += 1

ans = n - max(list_Vx_Count) - max(list_Vy_Count)

if list_Vx_Count.count(max(list_Vx_Count)) == 1 and list_Vy_Count.count(max(list_Vy_Count)):
    if list_Vx_Count.index(max(list_Vx_Count)) == list_Vy_Count.index(max(list_Vy_Count)):
        ans = n - max(max(list_Vx_Count)+sorted(list_Vx_Count)[-2], max(list_Vy_Count)+sorted(list_Vy_Count)[-2])

print(ans)
Buggy python submission (verdict: Runtime Error):
s = list(input())
t = list(input())

st = list(zip(s, t))
st.sort(key=lambda x:x[1])
dic_ST = set()
ans = "Yes"

for i in range(len(s)-1):
    if st[i][1] == st[i+1][1]:
        if st[i][0] != st[i+1][0]:
            ans = "No"
        if st[i][0] in dic_ST:
            ans = " No"
    else:
        dic_ST.add(st[i][0])

if st[-2][1] == st[-1][1]:
    if st[-2][0] != st[-1][0]:
        ans = "No"
    if st[-1][0] in dic_ST:
        ans = " No"
else:
    dic_ST.add(st[-1][0])

print(ans)

Fixed submission:
from collections import Counter
s=input()
t=input()
list_S=Counter(s)
list_T=Counter(t)

if sorted(list_S.values()) == sorted(list_T.values()):
    print("Yes")
else:
    print("No")