Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
N =int(input())
lisA =list(map(int,input().split()))
lisB = list(map(int,input().split()))
lisC = list(map(int,input().split()))

lisA.sort()
lisB.sort()
lisC.sort()
cnt = 0

for b in lisB:
    cnt+= bisect.bisect_left(lisA,b)*(N-bisect.bisect_right(lisC,b))

print(cnt)

Fixed submission:
import bisect
N =int(input())
lisA =list(map(int,input().split()))
lisB = list(map(int,input().split()))
lisC = list(map(int,input().split()))

lisA.sort()
lisB.sort()
lisC.sort()
cnt = 0

for b in lisB:
    cnt += bisect.bisect_left(lisA,b)*(N-bisect.bisect_right(lisC,b))

print(cnt)

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

lisA.sort()
lisB.sort()
lisC.sort()
cnt = 0

for b in lisB:
    cnt+= bisect.bisect_left(lisA,b)*(N-bisect.bisect_right(lisC,b))

print(cnt)

Fixed submission:
import bisect
N =int(input())
lisA =list(map(int,input().split()))
lisB = list(map(int,input().split()))
lisC = list(map(int,input().split()))

lisA.sort()
lisB.sort()
lisC.sort()
cnt = 0

for b in lisB:
    cnt += bisect.bisect_left(lisA,b)*(N-bisect.bisect_right(lisC,b))

print(cnt)

Buggy python submission (verdict: Runtime Error):
N =int(input())
lisA =sorted(list(map(int,input().split())))
lisB = sorted(list(map(int,input().split())))
lisC = sorted(list(map(int,input().split())))



print(sum(bisect.bisect_left(lisA,b)*(N-bisect.bisect_right(lisC,b))for b in  lisB))

Fixed submission:
import bisect
N =int(input())
lisA =list(map(int,input().split()))
lisB = list(map(int,input().split()))
lisC = list(map(int,input().split()))

lisA.sort()
lisB.sort()
lisC.sort()
cnt = 0

for b in lisB:
    cnt += bisect.bisect_left(lisA,b)*(N-bisect.bisect_right(lisC,b))

print(cnt)

Buggy python submission (verdict: Runtime Error):
N =int(input())
lisA =sorted(list(map(int,input().split())))
lisB = sorted(list(map(int,input().split())))
lisC = sorted(list(map(int,input().split())))



print(sum(bisect.bisect_left(lisA,b)*(N-bisect.bisect_right(lisC,b))for b in  lisB))

Fixed submission:
import bisect
N =int(input())
lisA =list(map(int,input().split()))
lisB = list(map(int,input().split()))
lisC = list(map(int,input().split()))

lisA.sort()
lisB.sort()
lisC.sort()
cnt = 0

for b in lisB:
    cnt += bisect.bisect_left(lisA,b)*(N-bisect.bisect_right(lisC,b))

print(cnt)

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



print(sum(bisect.bisect_left(lisA,b)*(N-bisect.bisect_right(lisC,b))for b in  lisB))

Fixed submission:
import bisect
N =int(input())
lisA =list(map(int,input().split()))
lisB = list(map(int,input().split()))
lisC = list(map(int,input().split()))

lisA.sort()
lisB.sort()
lisC.sort()
cnt = 0

for b in lisB:
    cnt += bisect.bisect_left(lisA,b)*(N-bisect.bisect_right(lisC,b))

print(cnt)
Buggy python submission (verdict: Runtime Error):
n = input()
for i in range(6):
  if 2**i <= n and 2**(i+1) > n:
    print(2**i)
    

Fixed submission:
n = input()
for i in range(7):
    if 2**i <= int(n) and 2**(i+1) > int(n):
        print(2**i)
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python

def dfs(node, edge, vis):
    if vis[node]:
        return 0
    vis[node] = True
    count = 1
    vq = []
    vq.append(node)
    while vq:
        fnode = vq[0]
        del vq[0]
        for b in edge[fnode]:
            if not vis[b]:
                count += 1
                vq.append(b)
                vis[b] = True
    return count

n, m = [int(i) for i in input().split(' ')]

edge = [[] for i in range(n)]

for _ in range(m):
    a, b = [int(i) for i in input().split(' ')]
    edge[a-1].append(b-1)
    edge[b-1].append(a-1)

vis = [False]*n

count = 0

for i in range(n):
    if not vis[i]:
        count = max(count, dfs(i, edge, vis))

print(count)


Fixed submission:
#!/usr/bin/env python

import queue

def dfs(node, edge, vis):
    vis[node] = True
    count = 1
    vq = []
    vq.append(node)
    vq = queue.LifoQueue()
    vq.put(node)
    while not vq.empty():
        fnode = vq.get()
        for b in edge[fnode]:
            if not vis[b]:
                count += 1
                vq.put(b)
                vis[b] = True
    return count

n, m = [int(i) for i in input().split(' ')]

edge = [[] for i in range(n)]

for _ in range(m):
    a, b = [int(i) for i in input().split(' ')]
    edge[a-1].append(b-1)
    edge[b-1].append(a-1)

vis = [False]*n

count = 0

for i in range(n):
    if not vis[i]:
        count = max(count, dfs(i, edge, vis))

print(count)

Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python

def dfs(node, edge, vis):
    if vis[node]:
        return 0
    vis[node] = True
    count = 1
    for b in edge[node]:
        if not vis[b]:
            count += dfs(b, edge, vis)
    return count

n, m = [int(i) for i in input().split(' ')]

edge = [[] for i in range(n)]

for _ in range(m):
    a, b = [int(i) for i in input().split(' ')]
    edge[a-1].append(b-1)
    edge[b-1].append(a-1)

vis = [False]*n

count = 0

for i in range(n):
    if not vis[i]:
        count = max(count, dfs(i, edge, vis))

print(count)


Fixed submission:
#!/usr/bin/env python

import queue

def dfs(node, edge, vis):
    vis[node] = True
    count = 1
    vq = []
    vq.append(node)
    vq = queue.LifoQueue()
    vq.put(node)
    while not vq.empty():
        fnode = vq.get()
        for b in edge[fnode]:
            if not vis[b]:
                count += 1
                vq.put(b)
                vis[b] = True
    return count

n, m = [int(i) for i in input().split(' ')]

edge = [[] for i in range(n)]

for _ in range(m):
    a, b = [int(i) for i in input().split(' ')]
    edge[a-1].append(b-1)
    edge[b-1].append(a-1)

vis = [False]*n

count = 0

for i in range(n):
    if not vis[i]:
        count = max(count, dfs(i, edge, vis))

print(count)
Buggy python submission (verdict: Runtime Error):
a = int(input())

print(a*(1+a(1+a)))

Fixed submission:
a = int(input())

print( a*(1+a*(1+a)) )
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3

n, k = [int(i) for i in input().split(' ')]
k += 1

harr = [int(i) for i in input().split(' ')]

dp = [10**9]*n
dp[0] = 0


for i in range(1, n):
    for j in range(1, k):
        if i - j < 0:
            break
        dp[i] = min(dp[i], dp[i-j] + abs(harr[i]-harr[i-j]))

print(dp[n-1])


Fixed submission:
#!/usr/bin/env python3

n, k = [int(i) for i in input().split(' ')]

arr = [int(i) for i in input().split(' ')]

dp = [10**10]*n

k += 1
dp[0] = 0

for i in range(0, n):
    for j in range(1, k):
        if i+j < n:
            dp[i+j] = min(dp[i+j], dp[i] + abs(arr[i+j]-arr[i]))

print(dp[n-1])
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))

ans = 0
for i in range(N):
    ans += A[i] * sum(A[i+1:])

ans = ans % 1000000007

print(ans)

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

ans = 0
S = sum(A)
for i in range(N):
    S -= A[i]
    ans += A[i] * S

ans = ans % (10**9+7)

print(int(ans))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(str, input().split()))
a = '+'.join(A)

Q = int(input())
for i in range(Q):
    B, C= map(str, input().split())
    a = a.replace(B, C)
    print(eval(a))


Fixed submission:
import collections

N = int(input())
A = list(map(int, input().split()))
Q = int(input())
C = collections.Counter(A)
ans = sum(A)

for _ in range(Q):
    b, c = map(int, input().split())
    ans += c*C[b] - b*C[b]
    C[c] += C[b]
    C[b] = 0
    print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))

ans = 1
for i in range(N):
    ans = ans*A[i]

if ans > 10 ** 18:
    print(-1)
else:
    print(ans)

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

A = sorted(A)
ans = 1
for i in range(N):
    ans = ans*A[i]
    if ans == 0:
        print(ans)
        exit()
    if ans > 10 ** 18:
        print(-1)
        exit()

print(ans)
Buggy python submission (verdict: Runtime Error):
import collections
N, M = map(int, input().split())
H = list(map(int, input().split()))

root = dict()
non_root = []
if M == 1:
    print(N-1)

for i in range(M):
    A, B = map(int, input().split())
    non_root.append(A)
    non_root.append(B)

    if H[A-1] > H[B-1]:
        root[A] = H[A-1]
        if B in root.keys():
            root.pop(root[B])
    elif H[A-1] < H[B-1]:
        root[B] = H[B - 1]
        if A in root.keys():
            root.pop(root[A])
    else:
        if B in root.keys():
            root.pop(root[B])
        if A in root.keys():
            root.pop(root[A])

print(len(root)+ (N- len(set(non_root))))

Fixed submission:
import copy
N, M = map(int, input().split())
H = list(map(int, input().split()))

H2 = copy.copy(H)
for i in range(M):
    A, B = map(int, input().split())
    if H[A - 1] > H[B - 1]:
        H2[B - 1] = False
    elif H[A - 1] < H[B - 1]:
        H2[A-1] = False
    else:
        H2[A - 1] = False
        H2[B - 1] = False

H3 = H2.count(False)

print(len(H) - H3)

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

root = dict()
if M == 1:
    print(N-1)

for i in range(M):
    A, B = map(int, input().split())
    if H[A-1] > H[B-1]:
        root[A] = H[A-1]
        if B in root.keys():
            root.pop(root[B])
    elif H[A-1] < H[B-1]:
        root[B] = H[B - 1]
        if A in root.keys():
            root.pop(root[A])
    else:
        if B in root.keys():
            root.pop(root[B])
        if A in root.keys():
            root.pop(root[A])

print(len(root))

Fixed submission:
import copy
N, M = map(int, input().split())
H = list(map(int, input().split()))

H2 = copy.copy(H)
for i in range(M):
    A, B = map(int, input().split())
    if H[A - 1] > H[B - 1]:
        H2[B - 1] = False
    elif H[A - 1] < H[B - 1]:
        H2[A-1] = False
    else:
        H2[A - 1] = False
        H2[B - 1] = False

H3 = H2.count(False)

print(len(H) - H3)

Buggy python submission (verdict: Runtime Error):
import collections
N, M = map(int, input().split())
H = list(map(int, input().split()))

root = dict()

for i in range(M):
    A, B = map(int, input().split())
    if H[A-1] >= H[B-1]:
        root[A-1] = H[A-1]
        if B-1 in root.keys():
            root.pop(root[B-1])
    else:
        root[B - 1] = H[B - 1]
        if A-1 in root.keys():
            root.pop(root[A-1])


print(len(root))


Fixed submission:
import copy
N, M = map(int, input().split())
H = list(map(int, input().split()))

H2 = copy.copy(H)
for i in range(M):
    A, B = map(int, input().split())
    if H[A - 1] > H[B - 1]:
        H2[B - 1] = False
    elif H[A - 1] < H[B - 1]:
        H2[A-1] = False
    else:
        H2[A - 1] = False
        H2[B - 1] = False

H3 = H2.count(False)

print(len(H) - H3)
Buggy python submission (verdict: Time Limit Exceeded):
import math
A, B, N = map(int, input().split())

d = 0
ans = 0

mid = N//2
if (math.floor((A*mid)/B) - A*math.floor(mid/B)) < (math.floor((A*(mid+1))/B) - A*math.floor((mid+1)/B)):
    for i in range(mid, N+1):
        d = math.floor((A * i) / B) - A * math.floor(i / B)
        if ans <= d:
            ans = d
        else:
            print(ans)
            exit()
else:
    for i in range(0, mid+1):
        d = math.floor((A * i) / B) - A * math.floor(i / B)
        if ans <= d:
            ans = d
        else:
            print(ans)
            exit()

print(ans)

Fixed submission:
import math

A, B, N = map(int, input().split())
print(math.floor((A * min(B-1, N)) / B) - A * math.floor(min(B-1, N) / B))

Buggy python submission (verdict: Time Limit Exceeded):
import math
A, B, N = map(int, input().split())

d = 0
ans = 0
# for i in range(1, N+1):
#     d = math.floor((A*i)/B) - A*math.floor(i/B)
#     if ans <= d:
#         ans = d
#     else:
#         print(ans)
#         exit()
#
# print(ans)

mid = N//2
if (math.floor((A*mid)/B) - A*math.floor(mid/B)) < (math.floor((A*(mid+1))/B) - A*math.floor((mid+1)/B)):
    for i in range(mid, N+1):
        d = math.floor((A * i) / B) - A * math.floor(i / B)
        if ans <= d:
            ans = d
        else:
            print(ans)
            exit()
else:
    for i in range(0, mid+1):
        d = math.floor((A * i) / B) - A * math.floor(i / B)
        if ans <= d:
            ans = d
        else:
            print(ans)
            exit()

print(ans)

Fixed submission:
import math

A, B, N = map(int, input().split())
print(math.floor((A * min(B-1, N)) / B) - A * math.floor(min(B-1, N) / B))

Buggy python submission (verdict: Time Limit Exceeded):
import math
A, B, N = map(int, input().split())

d = 0
ans = 0
for i in range(1, N+1):
    d = math.floor((A*i)/B) - A*math.floor(i/B)
    if ans <= d:
        ans = d
    else:
        print(ans)
        exit()
        
print(ans)

Fixed submission:
import math

A, B, N = map(int, input().split())
print(math.floor((A * min(B-1, N)) / B) - A * math.floor(min(B-1, N) / B))

Buggy python submission (verdict: Time Limit Exceeded):
import math
A, B, N = map(int, input().split())

d = 0
ans = 0
for i in range(1, N+1):
    d = math.floor((A*i)/B) - A*math.floor(i/B)
    if ans <d:
        ans = d

print(ans)

Fixed submission:
import math

A, B, N = map(int, input().split())
print(math.floor((A * min(B-1, N)) / B) - A * math.floor(min(B-1, N) / B))
Buggy python submission (verdict: Runtime Error):
import collections
N = int(input())
A = deque(map(int, input().split()))

C = collections.Counter(A)

for i in range(1, N+1):
    if i in C.keys():
        print(C[i])
    else:
        print(0)

Fixed submission:
import collections
N = int(input())
A = list(map(int, input().split()))

C = collections.Counter(A)

for i in range(1, N+1):
    if i in C.keys():
        print(C[i])
    else:
        print(0)

Buggy python submission (verdict: Time Limit Exceeded):
import collections
N = int(input())
A = list(map(int, input().split()))

for i in range(1, N+1):
    print(A.count(i))

Fixed submission:
import collections
N = int(input())
A = list(map(int, input().split()))

C = collections.Counter(A)

for i in range(1, N+1):
    if i in C.keys():
        print(C[i])
    else:
        print(0)
Buggy python submission (verdict: Time Limit Exceeded):
import math
from functools import reduce
import itertools

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

N = int(input())

i = 0
for a, b, c in itertools.product(range(1,N+1), range(1,N+1),range(1,N+1)):
    i += gcd(a, b, c)

print(i)

Fixed submission:
from math import gcd 
N = int(input())
i = 0
 
for a in range(1, N+1):
    for b in range(1, N+1):
        for c in range(1, N+1):
            i += gcd(gcd(a, b), c)
            
print(i)

Buggy python submission (verdict: Time Limit Exceeded):
import math
from functools import reduce

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

N = int(input())
i = 0

for a in range(1, N+1):
    for b in range(1, N+1):
        for c in range(1, N+1):
            i += gcd(a, b, c)
            
print(i)

Fixed submission:
from math import gcd 
N = int(input())
i = 0
 
for a in range(1, N+1):
    for b in range(1, N+1):
        for c in range(1, N+1):
            i += gcd(gcd(a, b), c)
            
print(i)
Buggy python submission (verdict: Runtime Error):
from collections import deque

K = int(input()) 
a = deque([1, 2, 3, 4, 5, 6, 7, 8, 9])

for i in range(K-1):
    j = a.popleft()
    if j%10 != 0:
        a.append((10*j) + ((j%10) -1))
        
    a.append((10*j)+j%10)
    
    if j%10 != 9:
        a.append((10*j) +((j%10)+1))
    
a.popleft()

Fixed submission:
i = list(map(int, input().split())) 
X = i[0]
Y = i[1]
Z = i[2]

print(Z, X, Y)

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

K = int(input()) 
a = deque([1, 2, 3, 4, 5, 6, 7, 8, 9])

for i in range(K):
    j = a.popleft()
    print(j)
    if j%10 != 0:
        a.append((10*j) + ((j%10) -1))
        
    a.append((10*j)+j%10)
    
    if j%10 != 9:
        a.append((10*j) +((j%10)+1))

Fixed submission:
i = list(map(int, input().split())) 
X = i[0]
Y = i[1]
Z = i[2]

print(Z, X, Y)
Buggy python submission (verdict: Runtime Error):
K = input()
from collections import deque

a = deque()

for i in range(1,10):
    a.append(i)
    
for i in range(K):
    j = a.popleft()
    if j%10 != 0:
        a.append((10*j) + ((j%10) -1))
        
    a.append((10*j)+j%10)
    
    if j%10 != 9:
        a.append((10*j) +((j%10)+1))
        
a.popleft()

Fixed submission:
from collections import deque

K = int(input()) 
a = deque([1, 2, 3, 4, 5, 6, 7, 8, 9])

for i in range(K-1):
    j = a.popleft()
    if j%10 != 0:
        a.append((10*j) + ((j%10) -1))
        
    a.append((10*j)+j%10)
    
    if j%10 != 9:
        a.append((10*j) +((j%10)+1))
    
print(a.popleft())
Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque
import collections
import math
def comb(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

N = int(input())
A = list(map(int, input().split()))
d2 = deque()
d = deque(A)
ans = 0

for i in range(N):
    d2.append(d.popleft())
    if i > 0:
        d.append(d2.popleft())
    c = collections.Counter(d)
    for i in c.keys():
        if c[i] >= 2:
            ans += comb(c[i], 2)
    print(int(ans))
    ans =0


Fixed submission:
import collections

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

c = collections.Counter(A)
keys = c.keys()
comb = 0
for i in keys:
    comb += (c[i] * (c[i]-1)) //2

for i in A:
    ans = comb - (c[i]-1)
    print(ans)

Buggy python submission (verdict: Runtime Error):
from collections import deque
import collections
from scipy.special import comb

N = int(input())
A = list(map(int, input().split()))
d2 = deque()
d = deque(A)
ans = 0

for i in range(N):
    d2.append(d.popleft())
    if i > 0:
        d.append(d2.popleft())
    c = collections.Counter(d)
    for i in c.keys():
        if c[i] >= 2:
            ans += comb(c[i], 2)
    print(int(ans))
    ans =0


Fixed submission:
import collections

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

c = collections.Counter(A)
keys = c.keys()
comb = 0
for i in keys:
    comb += (c[i] * (c[i]-1)) //2

for i in A:
    ans = comb - (c[i]-1)
    print(ans)
Buggy python submission (verdict: Runtime Error):
from decimal import *
import math

i = list(map(int, input().split()))
A = Decimal(i[0])
B = Decimal(i[1])

A_min = A // Decimal("0.08")
A_max = math.ceil(Decimal(A + 1) / Decimal("0.08"))
B_min = B // Decimal("0.1")
B_max = math.ceil(Decimal(B+1) / Decimal(0.1))

if A_max < B_min:
    print(-1)
elif A_min > B_max:
    print(-1)
elif A_min < B_min:
    print(B_min)
else:
    print(A_min)

Fixed submission:
S = str(input())
 
if S[0] == S[1] == S[2]:
  print("No")
else:
  print("Yes")

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

N = int(i[0])
A = int(i[1])
B = int(i[2])

count_blue = 0

syou = N // (A + B)
amari = N % (A + B)

if amari > A:
    count_blue = A * syou + A
else:
    count_blue = A * syou + amari
   
print(count_blue)

Fixed submission:
S = str(input())
 
if S[0] == S[1] == S[2]:
  print("No")
else:
  print("Yes")

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

N = int(i[0])
A = int(i[1])
B = int(i[2])

count_blue = 0

syou = N // (A + B)
amari = N % (A + B)

if amari > A:
    count_blue = A * syou + A
else:
    count_blue = A * syou + amari
    
count_blue

Fixed submission:
S = str(input())
 
if S[0] == S[1] == S[2]:
  print("No")
else:
  print("Yes")
Buggy python submission (verdict: Time Limit Exceeded):
i = list(map(int, input().split()))

N = int(i[0])
A = int(i[1])
B = int(i[2])

l = []

while len(l) < N:
    for i in range(A):
        if len(l) == N:
            break
        l.append(0)

    for i in range(B):
        if len(l) == N:
            break
        l.append(1)
        
print(l.count(0))

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

N = int(i[0])
A = int(i[1])
B = int(i[2])

count_blue = 0

syou = N // (A + B)
amari = N % (A + B)

if amari > A:
    count_blue = A * syou + A
else:
    count_blue = A * syou + amari

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

j = True
for i in range(N):
    if A[i] % 2 == 0:
        if A[i] %3 == 0 or A[i] % 5 ==0:
            pass
        else:
            j = False
            exit()
            
if j == Ture:
    print("APPROVED")
else:
    print("DENIED") 

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
 
j = True
for i in range(N):
    if A[i] % 2 == 0:
        if A[i] %3 == 0 or A[i] % 5 ==0:
            pass
        else:
            j = False
            
if j == True:
    print("APPROVED")
else:
    print("DENIED")
Buggy python submission (verdict: Time Limit Exceeded):
d = {}
N = int(input())

for _ in range(N):
    s = str(input())
    if s in d.keys():
        d[s] += 1
    else:
        d[s] = 1

ans = []

for key in d.keys():
    if d[key] == max(d.values()):
        ans.append(key)

ans = sorted(ans)

for _ in range(len(ans)):
    print(ans[_])

Fixed submission:
N = int(input())
l = []

for _ in range(N):
    s = str(input())
    l.append(s)

import collections
c = collections.Counter(l)
c = c.most_common()

most_count = c[0][1]
c.sort()

for i in range(len(c)):
    if c[i][1] == most_count:
        print(c[i][0])

Buggy python submission (verdict: Runtime Error):
d = {}
N = int(input())

for _ in range(N):
    s = str(input())
    if s in d.keys():
        d[s] += 1
    else:
        d[s] = 1

ans = []

for i in range(len(d)):
    if d[i][1] == max(d.values()):
        ans.append(d[i][0])

ans = sorted(ans)

for _ in range(len(ans)):
    print(ans[_])

Fixed submission:
N = int(input())
l = []

for _ in range(N):
    s = str(input())
    l.append(s)

import collections
c = collections.Counter(l)
c = c.most_common()

most_count = c[0][1]
c.sort()

for i in range(len(c)):
    if c[i][1] == most_count:
        print(c[i][0])

Buggy python submission (verdict: Runtime Error):
d = {}
N = int(input())

for _ in range(N):
    s = str(input())
    if s in d.keys():
        d[s] += 1
    else:
        d[s] = 1

ans = []

for i in range(len(sd)):
    if sd[i][1] == max(d.values()):
        ans.append(sd[i][0])

ans = sorted(ans)
for _ in range(len(ans)):
    print(ans[_])

Fixed submission:
N = int(input())
l = []

for _ in range(N):
    s = str(input())
    l.append(s)

import collections
c = collections.Counter(l)
c = c.most_common()

most_count = c[0][1]
c.sort()

for i in range(len(c)):
    if c[i][1] == most_count:
        print(c[i][0])

Buggy python submission (verdict: Time Limit Exceeded):
d = {}
N = int(input())

for _ in range(N):
    s = str(input())
    if s in d.keys():
        d[s] += 1
    else:
        d[s] = 1

sd = sorted(d.items())

for i in range(len(sd)):
    if sd[i][1] == max(d.values()):
        print(sd[i][0])

Fixed submission:
N = int(input())
l = []

for _ in range(N):
    s = str(input())
    l.append(s)

import collections
c = collections.Counter(l)
c = c.most_common()

most_count = c[0][1]
c.sort()

for i in range(len(c)):
    if c[i][1] == most_count:
        print(c[i][0])

Buggy python submission (verdict: Time Limit Exceeded):
d = {}
N = int(input())

for _ in range(N):
    s = str(input())
    if s in d.keys():
        d[s] += 1
    else:
        d[s] = 1

max_list = [kv for kv in d.items() if kv[1] == max(d.values())]

sml = sorted(max_list)

for _ in range(len(sml)):
    print(sml[_][0])

Fixed submission:
N = int(input())
l = []

for _ in range(N):
    s = str(input())
    l.append(s)

import collections
c = collections.Counter(l)
c = c.most_common()

most_count = c[0][1]
c.sort()

for i in range(len(c)):
    if c[i][1] == most_count:
        print(c[i][0])