Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
import math
s = int(input())
ans = [0] * 10000
a = 0
b = 0
c = 0

for i in range(3, 3 * math.floor(math.sqrt(s))):
    for j in range(1, i):
        a = j
        for k in range(1, i - j):
            b = k
            c = i - a - b
            d = a*a + b*b + c*c + a*b + b*c + c*a
            ans[d - 1] += 1

for i in range(s):
    print(str(ans[i]))

Fixed submission:
import math
s = int(input())
ans = [0] * 100000
a = 0
b = 0
c = 0

for i in range(3, 3 * math.floor(math.sqrt(s))):
    for j in range(1, i):
        a = j
        for k in range(1, i - j):
            b = k
            c = i - a - b
            d = a*a + b*b + c*c + a*b + b*c + c*a
            ans[d - 1] += 1

for i in range(s):
    print(str(ans[i]))

Buggy python submission (verdict: Runtime Error):
import math
s = int(input())
ans = [0] * 10000
a = 0
b = 0
c = 0

for i in range(3, 3 * math.floor(math.sqrt(s))):
    for j in range(1, i):
        a = j
        for k in range(1, i - j):
            b = k
            c = i - a - b
            d = a*a + b*b + c*c + a*b + b*c + c*a
            ans[d - 1] += 1

for i in range(s):
    print(str(ans[i]))

Fixed submission:
import math
s = int(input())
ans = [0] * 100000
a = 0
b = 0
c = 0

for i in range(3, 3 * math.floor(math.sqrt(s))):
    for j in range(1, i):
        a = j
        for k in range(1, i - j):
            b = k
            c = i - a - b
            d = a*a + b*b + c*c + a*b + b*c + c*a
            ans[d - 1] += 1

for i in range(s):
    print(str(ans[i]))
Buggy python submission (verdict: Runtime Error):
a = list(map(int,input().split()))
b = [input() for l in range(a[0])]
ans = 0
cnt = 0
allcnt = 0
nongyou = []
cnt2 = 0
for i in range(a[0]):
    allcnt += b[i].count('#')

for i in range(2 ** a[0]):
    cnt = allcnt
    nongyou = []
    for j in range(a[0]):
        if ((i >> j) & 1):
            cnt -= b[i].count('#')
            nongyou.append(i)
    for m in range(2 ** a[1]):
        cnt2 = cnt
        for n in range(a[1]):
            if ((m >> n) & 1):
                for k in range(a[0]):
                    if k in nongyou:
                        continue
                    else:
                        cnt2 -= b[k][m].count('#')                  
        if cnt2 == a[2]:
            ans += 1

print(str(ans))

Fixed submission:
a = list(map(int,input().split()))
b = [input() for l in range(a[0])]
ans = 0
cnt = 0
allcnt = 0
nongyou = []
cnt2 = 0
for i in range(a[0]):
    allcnt += b[i].count('#')

for i in range(2 ** a[0]):
    cnt = allcnt
    nongyou = []
    for j in range(a[0]):
        if ((i >> j) & 1):
            cnt -= b[j].count('#')
            nongyou.append(j)
    for m in range(2 ** a[1]):
        cnt2 = cnt
        for n in range(a[1]):
            if ((m >> n) & 1):
                for k in range(a[0]):
                    if k in nongyou:
                        continue
                    else:
                        cnt2 -= b[k][n].count('#')                  
        if cnt2 == a[2]:
            ans += 1

print(str(ans))
Buggy python submission (verdict: Time Limit Exceeded):
a = int(input())
b = list(map(int,input().split()))
ans = 0
c = 0
list.sort(b, reverse=True)
ans += b.pop(0)
b.extend(b)
list.sort(b, reverse=True)

for i in range(2,a):
    ans += b.pop(0)
print(str(ans))

Fixed submission:
a = int(input())
b = list(map(int,input().split()))
ans = 0
c = 0
list.sort(b, reverse=True)
ans += b.pop(0)
b.extend(b)
list.sort(b, reverse=True)

ans += sum(b[0:a-2])
print(str(ans))

Buggy python submission (verdict: Time Limit Exceeded):
a = int(input())
b = list(map(int,input().split()))
c = []

ans = 0    

b = sorted(b, reverse=True)
c.append(b.pop(0))
ans += c[0]
c.append(b.pop(0))
nmax = 0
maxindex = 0
if a > 2:
    ans += c[1]
    c.append(b.pop(0))
    if a > 3:
        for i in range(a - 3):
            nmax = 0
            maxindex = 0
            for j in range(len(c)):
                if j + 1 == len(c):
                    s = min(c[j], c[0])
                else:
                    s = min(c[j], c[j + 1])
                if nmax < s:
                    nmax = s
                    maxindex = j + 1
            ans += nmax
            c.insert(maxindex, b.pop(0))
print(str(ans))
                

Fixed submission:
a = int(input())
b = list(map(int,input().split()))
ans = 0
c = 0
list.sort(b, reverse=True)
ans += b.pop(0)
b.extend(b)
list.sort(b, reverse=True)

ans += sum(b[0:a-2])
print(str(ans))

Buggy python submission (verdict: Time Limit Exceeded):

a = int(input())
b = list(map(int,input().split()))
c = []

ans = 0    

b = sorted(b, reverse=True)
c.append(b.pop(0))
ans += c[0]
c.append(b.pop(0))
nmax = 0
maxindex = 0
if a > 2:
    ans += c[1]
    c.append(b.pop(0))
    if a > 3:
        for i in range(a - 3):
            nmax = 0
            maxindex = 0
            for j in range(len(c)):
                if j + 1 == len(c):
                    s = min(c[j], c[0])
                else:
                    s = min(c[j], c[j + 1])
                if nmax < s:
                    nmax = s
                    maxindex = j + 1
            ans += nmax
            c.insert(maxindex, b.pop(0))
print(str(ans))

Fixed submission:
a = int(input())
b = list(map(int,input().split()))
ans = 0
c = 0
list.sort(b, reverse=True)
ans += b.pop(0)
b.extend(b)
list.sort(b, reverse=True)

ans += sum(b[0:a-2])
print(str(ans))
Buggy python submission (verdict: Runtime Error):
W,H,x,y = list(map(float,input().split()))

ans = W * H
ans = float(float(ans) / 2.0)
ans2 = 0
if x == float(float(W) / 2) and y == float(float(H) / 2):
    ans2 = 1

print(ans + " " + ans2)

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

ans = W * H
ans = float(float(ans) / 2.0)
ans2 = 0
if x == float(float(W) / 2) and y == float(float(H) / 2):
    ans2 = 1

print(str(ans) + " " + str(ans2))
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int,input().split))
ans = [0] * n
for i in range(n):
    ac = a
    del ac[i]
    for j in range(0, n):
        if j == 0:
            ans[i] += abs(ac[0])
        else:
            ans[i] += abs(ac[j]-ac[j - 1])

for k in ans:
    print(str(k))

Fixed submission:
n = int(input())
a = [0] + list(map(int,input().split())) + [0]
ans = 0
anslist = [0] * n
for j in range(1, n + 2):
    if j == 1:
        ans += abs(a[j])
    elif j == n + 1:
        ans += abs(a[n])
    else:
        ans += abs(a[j]-a[j - 1])

for i in range(1, n + 1):
    anslist[i - 1] = ans - abs(a[i - 1] - a[i]) - abs(a[i] - a[i + 1]) + abs(a[i - 1] - a[i + 1])
            
for k in anslist:
    print(k)
Buggy python submission (verdict: Time Limit Exceeded):
a=int(input())
li = list(map(int,input().split()))

sum=1

for i in range(a):
    sum = sum*li[i]

if sum <= 10**18:
    print(sum)
else:
    print(-1)


Fixed submission:
#１文字をインプット
a=int(input())
#1行をint型でインプット
li = list(map(int,input().split()))

#初期値をセット
sum=1

#リストに入っている分だけ掛ける
if 0 in li:#もしリストに0が入っていたら合計を0にして、34行目へ
    sum = 0
else:
    for i in range(a):
        sum = sum*li[i]
        if sum > 10**18:
            break

if sum <= 10**18:#10の18乗以下の場合、答えを出力
    print(sum)
else:#10の18乗を超える場合、'-1'を出力
    print(-1)
Buggy python submission (verdict: Runtime Error):
K=int(input())

#関数定義(最大公約数)
def gcd(*numbers):
    return reduce(math.gcd, numbers)

sum=0

for a in range(1,K+1):
    for b in range(1,K+1):
        for c in range(1,K+1):
            sum+=(gcd(a, b, c))

print(sum)

Fixed submission:
import math
from functools import reduce

K=int(input())

#関数定義(最大公約数)
def gcd(*numbers):
    return reduce(math.gcd, numbers)

sum=0

for a in range(1,K+1):
    for b in range(1,K+1):
        for c in range(1,K+1):
            sum+=(gcd(a, b, c))

print(sum)
Buggy python submission (verdict: Runtime Error):
import math

N,M = map(int,input().split())

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

print(combinations_count(N, 2)+combinations_count(M, 2))

Fixed submission:
from itertools import combinations

N,M = map(int,input().split())

a=["A" for i in range(0,N)]
b=["B" for i in range(0,M)]

tmp1=(len(list(combinations(a,2))))
tmp2=(len(list(combinations(b,2))))

print(tmp1+tmp2)

Buggy python submission (verdict: Runtime Error):
import math

N,M = map(int,input().split())

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

print(combinations_count(N, 2)+combinations_count(M, 2))

Fixed submission:
from itertools import combinations

N,M = map(int,input().split())

a=["A" for i in range(0,N)]
b=["B" for i in range(0,M)]

tmp1=(len(list(combinations(a,2))))
tmp2=(len(list(combinations(b,2))))

print(tmp1+tmp2)

Buggy python submission (verdict: Runtime Error):
from scipy.special import comb
N,M = map(int,input().split())

print(comb(N, 2,exact=True)+(comb(M, 2,exact=True)))

Fixed submission:
from itertools import combinations

N,M = map(int,input().split())

a=["A" for i in range(0,N)]
b=["B" for i in range(0,M)]

tmp1=(len(list(combinations(a,2))))
tmp2=(len(list(combinations(b,2))))

print(tmp1+tmp2)
Buggy python submission (verdict: Time Limit Exceeded):
import math
N, K = map(int, input().split())
As = list(map(int, input().split()))


def cut_num(a, cut_length):
    return math.ceil(a/cut_length) - 1


"""cut length N binary search
if cut num > K, search more longer cut length,
"""
l = 1
r = max(As)

ans = r
while True:
    m = (l+r)//2
    current_cut_num = sum([cut_num(a, m) for a in As])
    if current_cut_num <= K:
        r = m
    else:
        l = m

    if r - l < 1:
        break

if sum([cut_num(a, l) for a in As]) <= K:
    print(l)
else:
    print(r)

Fixed submission:
import math
N, K = map(int, input().split())
As = list(map(int, input().split()))


def cut_num(a, cut_length):
    return math.ceil(a/cut_length) - 1


"""cut length N binary search
if cut num > K, search more longer cut length,
"""
l = 1
r = max(As)
m = (l+r)//2
ans = r
while r > l + 1:
    current_cut_num = sum([cut_num(a, m) for a in As])
    if current_cut_num <= K:
        r = m
    else:
        l = m
    m = (l+r)//2

if sum([cut_num(a, l) for a in As]) <= K:
    print(l)
else:
    print(r)
Buggy python submission (verdict: Runtime Error):
N,M,K = map(int, input().split())
As = [int(n) for n in input().split()]
Bs = [int(n) for n in input().split()]

a_sum = [0] * (len(As) + 1)
b_sum = [0] * (len(Bs) + 1)

for i in range(1, len(As)):
    a_sum[i] = a_sum[i-1] + As[i]

for j in range(1, len(Bs)):
    b_sum[i] = b_sum[i-1] + Bs[i]

max_book_num = 0
j = M
for i in range(N+1):
    if a_sum[i] > K:
        continue

    while b_sum[j] + a_sum[i] > K:
        j -= 1
    
    max_book_num = max(max_book_num, i + j)

        
print(max_book_num)    



Fixed submission:
N,M,K = map(int, input().split())
As = [int(n) for n in input().split()]
Bs = [int(n) for n in input().split()]

a_sum = [0]
b_sum = [0]

for i in range(len(As)):
    a_sum.append(a_sum[-1] + As[i])

for j in range(len(Bs)):
    b_sum.append(b_sum[-1] + Bs[j])

 
max_book_num = 0
j = M
for i in range(N+1):
    if a_sum[i] > K:
        continue

    while b_sum[j] + a_sum[i] > K:
        j -= 1
    
    max_book_num = max(max_book_num, i + j)

        
print(max_book_num)
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
n = int(input())
n = str(n)
if len(n) => 3:
    p = n[-3]+n[-2]+n[-1]
if len(n) == 2:
    p = n[-2]+n[-1]
if len(n) == 1:
    p = n[-1]
print(int(p))

Fixed submission:
# -*- coding: utf-8 -*-
n = int(input())
a = 1000-n%1000
if a != 1000:
    print(a)
else:
    print(0)

Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
n = int(input())
n = str(n)
if len(p) => 3:
    p = n[-3]+n[-2]+n[-1]
if len(p) == 2:
    p = n[-2]+n[-1]
if len(p) == 1:
    p = n[-1]
print(int(p))

Fixed submission:
# -*- coding: utf-8 -*-
n = int(input())
a = 1000-n%1000
if a != 1000:
    print(a)
else:
    print(0)

Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
n = int(input())
n = str(n)
p = n[-3]+n[-2]+n[-1]
print(int(p))

Fixed submission:
# -*- coding: utf-8 -*-
n = int(input())
a = 1000-n%1000
if a != 1000:
    print(a)
else:
    print(0)

Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
n = input()
p = n[-3]+n[-2]+n[-1]
print(int(p))

Fixed submission:
# -*- coding: utf-8 -*-
n = int(input())
a = 1000-n%1000
if a != 1000:
    print(a)
else:
    print(0)
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
x, n = map(int, input().split())
aa = 0
if n == 0:
  aa = 1
if aa == 0:
    p = list(map(int, input().split()))
    p.sort()
    i = 0
    flg = 0
    dis = []
    while flg == 0:
        if i > 100:
            flg = 1
        if i in p:
            dis.append(5000)
        else:
            dis.append(abs(x-i))
        i += 1
    for i in dis:
        if dis[i] == min(dis):
            print(i)
            break
else:
    print(x)

Fixed submission:
# -*- coding: utf-8 -*-
x, n = map(int, input().split())
aa = 0
if n == 0:
   aa = 1
if aa == 0:
    p = list(map(int, input().split()))
    p.sort()
    i = 0
    flg = 0
    dis = []
    while flg == 0:
        if i > 100:
            flg = 1
        if i in p:
            dis.append(5000)
        else:
            dis.append(abs(x-i))
        i += 1
    for i in range(len(dis)):
        if dis[i] == min(dis):
            print(i)
            break
else:
    print(x)
Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-
"""
Created on Sun May 31 21:01:36 2020

@author: 81807
"""


n = int(input())
a = list(map(int, input().split()))
q = 1
for i in a:
    q *= i
if q > 10**18:
    print(-1)
else:
    print(q)

Fixed submission:
# -*- coding: utf-8 -*-
import math
n = int(input())
a = list(map(int, input().split()))
a.sort()
q = 1
f = 0
for i in a:
    q *= i
    if q > 10**18:
        f = 1
        break
if f == 1:
    print(-1)
else:
    print(q)
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
a, b, c, k = map(int, input().split())
L = [1]*a+[0]*b+[-1]*c
cnt = 0
for i in range(k):
    cnt += L[i]
print(cnt)

Fixed submission:
# -*- coding: utf-8 -*-
a, b, c, k = map(int, input().split())
cnt = 0
if k <= a:
    cnt += k
elif (a < k <= a+b):
    cnt += a
elif (a+b < k < a+b+c):
    cnt += a - (k-(a+b))
else:
    cnt += a - c
print(cnt)
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
n, m, x = map(int, input().split())
L = []
J = []
for i in range(n):
    l = list(map(int, input().split()))
    L.append(l)
for i in range(2**n):
    cost = 0
    f = 0
    M = [0]*m
    for j in range(n):
        
        if (i>>j)&1 == 1:
            cost += L[j][0]
            for k in range(m):
                M[k] += L[j][k+1]
    for p in M:
        if p < x:
            f = 1
    if f == 0:
        J.append(cost)
print(min(J))

Fixed submission:
# -*- coding: utf-8 -*-
n, m, x = map(int, input().split())
L = []
J = []
for i in range(n):
    l = list(map(int, input().split()))
    L.append(l)
for i in range(2**n):
    cost = 0
    f = 0
    M = [0]*m
    for j in range(n):
        
        if (i>>j)&1 == 1:
            cost += L[j][0]
            for k in range(m):
                M[k] += L[j][k+1]
    for p in M:
        if p < x:
            f = 1
    if f == 0:
        J.append(cost)
if J != []:
  print(min(J))
else:
  print(-1)
Buggy python submission (verdict: Runtime Error):
s, w = map(int, input().split())
if s > w:
  print("safe")
 else:
  print("unsafe")

Fixed submission:
s, w = map(int, input().split())
if s > w:
  print("safe")
else:
  print("unsafe")
Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-
N = int(input())
S = []
A = []
for i in range(N):
    s = input()
    S.append(s)    

n = len(S)
for i in range(n):
    cnt = 0
    for j in range(n):
        if S[i] == S[j]:
            cnt += 1
            if cnt == 2:
                S[j] = 0
print(len([i for i in S if i != 0]))

Fixed submission:
# -*- coding: utf-8 -*-
N = int(input())
S = []
for i in range(N):
    s = input()
    S.append(s)    
print(len(set(S)))
Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-
import math
from functools import reduce
 
def gcd(*numbers):
    return reduce(math.gcd, numbers)
 
K = int(input())
ans = 0
 
for i in range(1, K+1):
    for j in range(1, K+1):
        for k in range(1, K+1):
            ans += gcd(i, j, k)
print(ans)

Fixed submission:
# -*- coding: utf-8 -*-
import math
from functools import reduce
 
def gcd(*numbers):
    return reduce(math.gcd, numbers)
 
K = int(input())
ans = 0
 
for i in range(1, K+1):
    for j in range(1, K+1):
        for k in range(1, K+1):
            ans += gcd(i, j, k)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-
import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)

def gcd_list(numbers):
    return reduce(math.gcd, numbers)

K = int(input())
ans = 0

for i in range(1, K+1):
    for j in range(1, K+1):
        for k in range(1, K+1):
            ans += gcd(i, j, k)
print(ans)

Fixed submission:
# -*- coding: utf-8 -*-
import math
from functools import reduce
 
def gcd(*numbers):
    return reduce(math.gcd, numbers)
 
K = int(input())
ans = 0
 
for i in range(1, K+1):
    for j in range(1, K+1):
        for k in range(1, K+1):
            ans += gcd(i, j, k)
print(ans)
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
N, M = map(int, input().split())
A = list(map(int, input().split()))
cnt = 0
for Ai in A:
    k = 1/(4*M)
    if (sum(A))*k <= Ai:
        cnt += 1
if cnt >= M:
    print("Yes")
else:
    print("No")

Fixed submission:
# -*- coding: utf-8 -*-
BOX = list(map(int, input().split()))
print(BOX[2], BOX[0], BOX[1])
Buggy python submission (verdict: Runtime Error):
S = input()
if S[2] == S[3] and S[4] == S[5]:
  print(Yes)
else:
  print(No)

Fixed submission:
S = input()
if S[2] == S[3] and S[4] == S[5]:
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
a1 = list(map(int, input().split()))
a2 = list(map(int, input().split()))
a3 = list(map(int, input().split()))
a = [a1, a2, a3]
n = int(input())
b = []
for i in range(n):
    bn = int(input())
    b.append(bn)
for i in range(3):
    for j in range(3):
        if a[i][j] in b:
            a[i][j] = -5
for i in range(3):
    if sum(a[i]) == -15:
        bng = 1
for i in range(3):
     cnt = 0
     for j in range(3):
       cnt += a[j][i]
       if cnt == -15:
         bng = 1
        
cnt = 0
for i in range(3):
        cnt += a[i][i]
if cnt == -15:
        bng = 1 
                
if bng == 1:
    print("Yes")
else:
    print("No")

Fixed submission:
# -*- coding: utf-8 -*-
a1 = list(map(int, input().split()))
a2 = list(map(int, input().split()))
a3 = list(map(int, input().split()))
a = [a1, a2, a3]
n = int(input())
b = []
bng = 0
for i in range(n):
    bn = int(input())
    b.append(bn)
for i in range(3):
    for j in range(3):
        if a[i][j] in b:
            a[i][j] = -5
for i in range(3):
    if sum(a[i]) == -15:
        bng = 1
for i in range(3):
     cnt = 0
     for j in range(3):
       cnt += a[j][i]
       if cnt == -15:
         bng = 1
        
cnt = 0
for i in range(3):
        cnt += a[i][i]
if cnt == -15:
        bng = 1 
if a[0][2] + a[1][1] + a[2][0] == -15:
    bng = 1
                
if bng == 1:
    print("Yes")
else:
    print("No")

Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
a1 = list(map(int, input().split()))
a2 = list(map(int, input().split()))
a3 = list(map(int, input().split()))
a = [a1, a2, a3]
n = int(input())
b = []
for i in range(n):
    bn = int(input())
    b.append(bn)
for i in range(3):
    for j in range(3):
        if a[i][j] in b:
            a[i][j] = -5
print(*a)
for i in range(3):
    if sum(a[i]) == -15:
        bng = 1
for i in range(3):
     cnt = 0
     for j in range(3):
       cnt += a[j][i]
       if cnt == -15:
         bng = 1
        
cnt = 0
for i in range(3):
        cnt += a[i][i]
if cnt == -15:
        bng = 1 
                
if bng == 1:
    print("Yes")
else:
    print("No")

Fixed submission:
# -*- coding: utf-8 -*-
a1 = list(map(int, input().split()))
a2 = list(map(int, input().split()))
a3 = list(map(int, input().split()))
a = [a1, a2, a3]
n = int(input())
b = []
bng = 0
for i in range(n):
    bn = int(input())
    b.append(bn)
for i in range(3):
    for j in range(3):
        if a[i][j] in b:
            a[i][j] = -5
for i in range(3):
    if sum(a[i]) == -15:
        bng = 1
for i in range(3):
     cnt = 0
     for j in range(3):
       cnt += a[j][i]
       if cnt == -15:
         bng = 1
        
cnt = 0
for i in range(3):
        cnt += a[i][i]
if cnt == -15:
        bng = 1 
if a[0][2] + a[1][1] + a[2][0] == -15:
    bng = 1
                
if bng == 1:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-
N = int(input())
s = []
c = []
d = []
for i in range(N):
    S = input()
    s.append(S)
for i in range(N):
    c.append(s.count(s[i]))
for i in range(N):
    if max(c) == c[i]:
        d.append(s[i])
d = set(d)
d = list(d)
d.sort()
for i in range(len(d)):
    print(list(d)[i])

Fixed submission:
# -*- coding: utf-8 -*-
from collections import Counter
N = int(input())
S = []
U = []
X = []
Y = []
for i in range(N):
    s = input()
    S.append(s)
S = Counter(S)
for i in S.most_common():
    X.append(i[0])
    U.append(i[1])
for i in range(U.count(max(U))):
    Y.append(X[i])
Y.sort()
print(*Y, sep = "\n")

Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-
N = int(input())
s = []
c = []
d = []
for i in range(N):
    S = input()
    s.append(S)
for i in range(N):
    c.append(s.count(s[i]))
for i in range(N):
    if max(c) == c[i]:
        d.append(s[i])
d = set(d)
d = list(d)
d.sort()
for i in range(len(d)):
    print(list(d)[i])

Fixed submission:
# -*- coding: utf-8 -*-
from collections import Counter
N = int(input())
S = []
U = []
X = []
Y = []
for i in range(N):
    s = input()
    S.append(s)
S = Counter(S)
for i in S.most_common():
    X.append(i[0])
    U.append(i[1])
for i in range(U.count(max(U))):
    Y.append(X[i])
Y.sort()
print(*Y, sep = "\n")
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
N, K = map(int, input().split())
p = list(map(int, input().split()))
Exp = [0]*(N-K+1)
for i in range(N-K+1):
    x = 0
    for j in range(i, i+K):
        x += (sum(range(1, p[j]+1)))/p[j]
    Exp[i] = x
print(max(Exp))

Fixed submission:
# -*- coding: utf-8 -*-
s, t = input().split()
a, b = map(int, input().split())
u = input()
if u == s:
    a -= 1
if u == t:
    b -= 1
print(a, b)
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
n, k, m = map(int, input().split())
a = list(map(int, input().split()))
an = m*n-sum(a)
if (0 <= an <= k):
    print(an)
if 0 > an:
    print(0)
if k < an:
    print(-1)

Fixed submission:
# -*- coding: utf-8 -*-
a = input()
alp = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']
for i in range(len(alp)):
    if a == alp[i]:
        print(alp[i+1])
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
N = int(input())
S = [i for i in input()]
ans = 0
for i in range(N):
    if S[i] == "A":
        if S[i+1] == "B":
            if S[i+2] == "C":
                ans += 1
print(ans)

Fixed submission:
# -*- coding: utf-8 -*-
K, X = map(int, input().split())
if 500*K >= X:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
N = int(input())
S = [i for i in input()]
ans = 0
for i in range(N):
    if S[i] == "A":
        if S[i+1] == "B":
            if S[i+2] == "C":
                ans += 1
print(ans)

Fixed submission:
# -*- coding: utf-8 -*-
N = int(input())
S = [i for i in input()] + [-1, -1]
ans = 0
for i in range(N):
    if S[i] == "A":
        if S[i+1] == "B":
            if S[i+2] == "C":
                ans += 1
print(ans)