Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
n,q=map(int,input().split())
s=input()
ans=[0]*n
for i in range(len(s)-1):
    if s[i:i+2]=='AC':ans[i]=1
for _ in range(q):
    l,r=map(int,input().split())
    print(ans[l-1:r-1].count(1))

Fixed submission:
n,q=map(int,input().split())
s=input()
ans=[0]*n
cnt=0
for i in range(len(s)-1):
    if s[i:i+2]=='AC': cnt+=1
    ans[i]=cnt
for _ in range(q):
    l,r=map(int,input().split())
    print(ans[r-2]-ans[l-2])

Buggy python submission (verdict: Time Limit Exceeded):
n,q=map(int,input().split())
s=input()
ans=[]
for i in range(len(s)-1):
    if s[i:i+2]=='AC':ans.append(i)
for _ in range(q):
    l,r=map(int,input().split())
    cnt=0
    print(len([n for n in ans if l-1<=n<r-1]))

Fixed submission:
n,q=map(int,input().split())
s=input()
ans=[0]*n
cnt=0
for i in range(len(s)-1):
    if s[i:i+2]=='AC': cnt+=1
    ans[i]=cnt
for _ in range(q):
    l,r=map(int,input().split())
    print(ans[r-2]-ans[l-2])

Buggy python submission (verdict: Time Limit Exceeded):
n,q=map(int,input().split())
s=input()
ans=[]
for i in range(len(s)-1):
    if s[i:i+2]=='AC':ans.append(i)
for _ in range(q):
    l,r=map(int,input().split())
    cnt=0
    for x in ans:
        if l-1<=x<r-1: cnt+=1
    print(cnt)

Fixed submission:
n,q=map(int,input().split())
s=input()
ans=[0]*n
cnt=0
for i in range(len(s)-1):
    if s[i:i+2]=='AC': cnt+=1
    ans[i]=cnt
for _ in range(q):
    l,r=map(int,input().split())
    print(ans[r-2]-ans[l-2])

Buggy python submission (verdict: Time Limit Exceeded):
n,q=map(int,input().split())
s=input()
for _ in range(q):
    l,r=map(int,input().split())
    print(s[l-1:r].count('AC'))

Fixed submission:
n,q=map(int,input().split())
s=input()
ans=[0]*n
cnt=0
for i in range(len(s)-1):
    if s[i:i+2]=='AC': cnt+=1
    ans[i]=cnt
for _ in range(q):
    l,r=map(int,input().split())
    print(ans[r-2]-ans[l-2])
Buggy python submission (verdict: Time Limit Exceeded):
S=list(input())
ans=len(S)
l=[]
f=0
while f==0 and len(S)>=2:
    a=S.pop()
    b=S.pop()
    while a==b:
        if len(S)==0:
            l.append(a)
            l.append(b)
            f=1
            break
        l.append(a)
        a,b=b,S.pop()
    while len(l):
        S.append(l.pop())
print(ans-len(S))

Fixed submission:
S=input()
stack=[]
cnt=0
for s in S:
    if not stack: stack.append(s)
    elif stack[-1]!=s:
        stack.pop()
        cnt+=2
    else: stack.append(s)
print(cnt)
Buggy python submission (verdict: Runtime Error):
n,m=map(int,input().split())
like=[]
for i in range(n):
    like+=list(map(int,input()))
print(len(set(like)))

Fixed submission:
n,m=map(int,input().split())
like=[]
for i in range(n):
    k,*a=map(int,input().split())
    like+=a
ans=0
for i in range(1,m+1):
    if like.count(i)==n:
        ans+=1
print(ans)
Buggy python submission (verdict: Runtime Error):
n=int(input())
t,a=map(int,input().split())
h=list(map(int,input().split()))
ab=[0]*n
for i in range(n): ab[i]=abs(a-(t-h[i]*0.006))
print(h.index(min(ab))+1)

Fixed submission:
n=int(input())
t,a=map(int,input().split())
h=list(map(int,input().split()))
ab=[0]*n
for i in range(n): ab[i]=abs(a-(t-h[i]*0.006))
print(ab.index(min(ab))+1)
Buggy python submission (verdict: Time Limit Exceeded):
import collections as coll
n,m=map(int,input().split())
py=[list(map(int,input().split())) for _ in range(m)]
a=coll.defaultdict(list)
for x,y in sorted(py): a[x].append(y)
for x,y in py:
    z=a[x].index(y)+1
    print('%06d%06d'%(x,z))

Fixed submission:
import collections as coll
import bisect
n,m=map(int,input().split())
py=[list(map(int,input().split())) for _ in range(m)]
a=coll.defaultdict(list)
for x,y in sorted(py): a[x].append(y)
for x,y in py:
    z=bisect.bisect(a[x],y)
    print('%06d%06d'%(x,z))
Buggy python submission (verdict: Runtime Error):
print('Yes' if eval(input().replace(' ',*))%2 else 'No')

Fixed submission:
print('Yes' if eval(input().replace(' ','*'))%2 else 'No')
Buggy python submission (verdict: Time Limit Exceeded):
l=sorted(map(int,input().split()))
cnt=0
while l[2]-l[1]>1 or l[2]-l[0]>1:
    print(0)
    if l[2]-1>l[0]: l[1]+=2
    else: l[1]+=2
    cnt+=1
if l[0]==l[1]==l[2]: print(cnt)
elif l[1]==l[0]:print(cnt+1)
else:print(cnt+2)

Fixed submission:
l=sorted(map(int,input().split()))
cnt=0
while l[2]-l[1]>1 or l[2]-l[0]>1:
    if l[2]-1>l[0]: l[0]+=2
    else: l[1]+=2
    cnt+=1
if l[0]==l[1]==l[2]: print(cnt)
elif l[1]==l[0]:print(cnt+1)
else:print(cnt+2)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list(map(int,input().split()))
for i in range(n):
    ans,x=0,0
    for j in range(n):
        if j==i: continue
        ans+=abs(x-a[j])
        x=a[j]
    print(ans+abs(x))

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
x,m=0,0
for i in range(n):
    m+=abs(x-a[i])
    x=a[i]
m+=abs(x)
for i in range(n):
    ans=m
    if i==0: ans+=abs(a[i+1])-abs(a[i+1]-a[i])-abs(a[i])
    elif i==n-1:
        ans+=abs(a[i-1])-abs(a[i])-abs(a[i]-a[i-1])
    else:
        ans+=abs(a[i+1]-a[i-1])-abs(a[i]-a[i-1])-abs(a[i]-a[i+1])
    print(ans)
Buggy python submission (verdict: Runtime Error):
a=sorted(list(int(input()) for _ in range(int(input()))),reverse=True)
print(sum(a[::2])-sum(a[1::2]))

Fixed submission:
input()
a=sorted(list(map(int,input().split())),reverse=True)
print(sum(a[::2])-sum(a[1::2]))
Buggy python submission (verdict: Runtime Error):
N=list(int(input()))
if N[1]==N[2]:
    if N[1]==N[0]:
        print('Yes')
    elif N[2]==N[3]:
        print('Yes')
    else:
        print('No')
else:
    print('No')

Fixed submission:
N=list(input())
if N[1]==N[2]:
    if N[1]==N[0]:
        print('Yes')
    elif N[2]==N[3]:
        print('Yes')
    else:
        print('No')
else:
    print('No')
Buggy python submission (verdict: Time Limit Exceeded):
A=[int(input()) for _ in range(int(input()))]
l=sorted(set(A))
cnt=0
for i in range(len(l)):
    if A.count(l[i])%2: cnt+=1
print(cnt)

Fixed submission:
n=int(input())
a={}
for _ in range(n):
    x=int(input())
    if x in a: a[x]+=1
    else: a[x]=1
ans=0
for i in a:
    if a[i]%2: ans+=1
print(ans)
Buggy python submission (verdict: Runtime Error):
n=int(input())
if n==1:
    print(n):
    exit()
i=2
for _ in range(9):
    i**=2
    if i==n:
        print(i)
        exit()
    elif i>n:
        print(i//2)
        exit()

Fixed submission:
n=int(input())
for i in range(9):
    if n==2**i:
        print(n)
        exit()
    elif n<2**i:
        print(2**(i-1))
        exit()
Buggy python submission (verdict: Runtime Error):
n,k=map(int,input().split())
l=sort(list(map(int,input().split())),reverse=True)
ans=0
for i in range(k): ans+=l[i]
print(ans)

Fixed submission:
n,k=map(int,input().split())
l=sorted(list(map(int,input().split())),reverse=True)
ans=0
for i in range(k): ans+=l[i]
print(ans)
Buggy python submission (verdict: Runtime Error):
a=list(map(int,input().split())
print(sum(a)-max(a))

Fixed submission:
a=list(map(int,input().split()))
print(sum(a)-max(a))
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list(input().split())
ans=[]
i=1
for A in a:
    if i%2: ans.insert(0,A)
    else: ans.append(A)
    i+=1
if i%2: ans.reverse() 
print(*ans,sep=' ')

Fixed submission:
import queue as que
n=int(input())
a=list(input().split())
q=que.Queue()
s=[]
i=1
if n%2:
    for A in a:
        if i%2: s.append(A)
        else: q.put(A)
        i+=1
else:
    for A in a:
        if i%2: q.put(A)
        else: s.append(A)
        i+=1
for _ in range(len(s)): print(s.pop())
while not q.empty() :print(q.get())

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list(input().split())
ans=[]
for A in a:
    ans.append(A)
    ans.reverse()
print(*ans,sep=' ')

Fixed submission:
import queue as que
n=int(input())
a=list(input().split())
q=que.Queue()
s=[]
i=1
if n%2:
    for A in a:
        if i%2: s.append(A)
        else: q.put(A)
        i+=1
else:
    for A in a:
        if i%2: q.put(A)
        else: s.append(A)
        i+=1
for _ in range(len(s)): print(s.pop())
while not q.empty() :print(q.get())
Buggy python submission (verdict: Runtime Error):
o=input()
e=input()
for i in range(len(o)):
    print(o[i],end='')
    print(e[i],end='')
    

Fixed submission:
o=input()
e=input()
for i in range(len(e)):
    print(o[i],end='')
    print(e[i],end='')
if len(o)>len(e):print(o[len(o)-1])
Buggy python submission (verdict: Runtime Error):
a,b=map(int,input().split())
if a==b: print('Draw')
elif a==1: print('Alice')
elif b==1: print('Bob')
else print('Alice' if a>b else 'Bob')

Fixed submission:
a,b=map(int,input().split())
if a==b: print('Draw')
elif a==1: print('Alice')
elif b==1: print('Bob')
else: print('Alice' if a>b else 'Bob')
Buggy python submission (verdict: Time Limit Exceeded):
k,s=map(int,input().split())
print(sum(x+y+z==s for x in range(k+1) for y in range(k+1) for z in range(k+1)))

Fixed submission:
k,s=map(int,input().split())
ans=0
for i in range(k+1):
    for j in range(k+1):
        if s-i-j<0: break
        if s-i-j<=k: ans+=1
print(ans)
Buggy python submission (verdict: Runtime Error):
k = int(input())
s = input()
if len(s) == k :
    print(s)
else :
    for i in range (k) :
        print(s[i],end="")
    print("...")

Fixed submission:
k = int(input())
s = input()
if len(s) <= k :
    print(s)
else :
    for i in range (k) :
        print(s[i],end="")
    print("...")
Buggy python submission (verdict: Runtime Error):
#N, M = list(map(int, input().strip().split()))
X = int(input())

for i in range(-100, 101):
  for j in range(-100, 101):
    if i**5 - j**5 == X:
      A, B = i, j
      break
print(A, B)

Fixed submission:
#N, M = list(map(int, input().strip().split()))
X = int(input())

start = -200
end = 201

for i in range(start, end):
  for j in range(start, end):
    if i**5 - j**5 == X:
      A, B = i, j
      break
print(A, B)
Buggy python submission (verdict: Time Limit Exceeded):
#import math
N, K = list(map(int, input().strip().split()))

def gcd(a,b):
  a, b = max(a, b), min(a, b)
  while b!=0:
    a,b=b,a%b
  return a

def gcd2(a, b):
  while True:
    if a > b:
      if a % b == 0:
        return 0
      else:
        a = abs(a-b)
    elif a == b:
      return 0
    else:
      return min(a, abs(a-b))

ans = gcd2(N, K)
if ans == K:
  print(0)
else:
  print(ans)

"""
if N < K:
  print(min(N, abs(N-K)))
elif N == K:
  print(0)
else:
  ans = gcd(N, K)
  if ans == K:
    print(0)
  else:
    print(ans)
"""

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

def gcd2(a, b):
  while True:
    if a > b:
      if a % b == 0:
        return 0
      else:
        #a = a-b
        a = a % b
    elif a == b:
      return 0
    else:
      return min(a, abs(a-b))

ans = gcd2(N, K)
if ans == K:
  print(0)
else:
  print(ans)
Buggy python submission (verdict: Runtime Error):
#X = int(input().strip())

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

ans = 0
p = A[0]
low_index = 1
high_index = N-1
Done = set([p])

while len(A) > len(Done):
  #print('p:' + str(p))
  #print(Done)
  #print(ans)
  if abs(A[low_index] - p) < abs(p - A[high_index]):
    #print('low')
    Done.add(A[low_index])
    ans += A[low_index] - p
    p = A[low_index]
    for i in range(1, N):
      if low_index + i not in Done:
        low_index += i
        break
  else:
    #print('high')
    Done.add(A[high_index])    
    ans += K - A[high_index]
    p = A[high_index]
    for i in range(1, N):
      if high_index - i not in Done:
        high_index -= i
        break

print(ans)    

Fixed submission:
#X = int(input().strip())

K, N = list(map(int, input().strip().split()))
A = list(map(int, input().strip().split()))
m = 0
ind = 0
ans = 0

for i in range(N-1):
  _m = A[i+1] - A[i]
  if _m > m:
    m = _m
    ind = i+1
    last = i

_m = K + A[0] - A[N-1]
if _m > m:
  m = _m
  ind = 0
  last = N-1

#print(m)
#print(ind)
#print(last)
i = ind
while i != last:
  #print(ans)
  if i < N-1:
    ans += A[i+1] - A[i]
    i += 1
  else:
    ans += K + A[0] - A[i]
    i = 0

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import math

S = input().strip()
Q = int(input().strip())
order = 1

for i in range(Q):
  q = input().strip().split()
  #print(q)
  if q[0] == '1':
    # 反転
    # S = S[::-1]
    order *= -1
  else:
    F = q[1]
    if F == '1':
      if order == 1:
        # 先頭にCを追加
        S = q[2] + S
      else:
        # 末尾にCを追加
        S = S + q[2]
    else:
      if order == 1:
        # 末尾にCを追加
        S = S + q[2]        
      else:
        # 先頭にCを追加
        S = q[2] + S
        
print(S[::order])

Fixed submission:
import math

S = input().strip()
Q = int(input().strip())
order = 1
tmp = 'T'

for i in range(Q):
  q = input().strip().split()
  #print(q)
  if q[0] == '1':
    # 反転
    # S = S[::-1]
    order *= -1
  else:
    F = q[1]
    if F == '1':
      if order == 1:
        # 先頭にCを追加
        # S = q[2] + S
        tmp = q[2] + tmp
      else:
        # 末尾にCを追加
        # S = S + q[2]
        tmp = tmp + q[2]
    else:
      if order == 1:
        # 末尾にCを追加
        # S = S + q[2]        
        tmp = tmp + q[2]
      else:
        # 先頭にCを追加
        # S = q[2] + S
        tmp = q[2] + tmp

S = tmp.replace('T', S)        
print(S[::order])

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

S = input().strip()
Q = int(input().strip())

for i in range(Q):
  q = input().strip().split()
  #print(q)
  if q[0] == '1':
    # 反転
    S = S[::-1]    
  else:
    F = q[1]
    if F == '1':
      # 先頭にCを追加
      S = q[2] + S     
    else:
      # 末尾にCを追加
      S = S + q[2]
    
print(S)

Fixed submission:
import math

S = input().strip()
Q = int(input().strip())
order = 1
tmp = 'T'

for i in range(Q):
  q = input().strip().split()
  #print(q)
  if q[0] == '1':
    # 反転
    # S = S[::-1]
    order *= -1
  else:
    F = q[1]
    if F == '1':
      if order == 1:
        # 先頭にCを追加
        # S = q[2] + S
        tmp = q[2] + tmp
      else:
        # 末尾にCを追加
        # S = S + q[2]
        tmp = tmp + q[2]
    else:
      if order == 1:
        # 末尾にCを追加
        # S = S + q[2]        
        tmp = tmp + q[2]
      else:
        # 先頭にCを追加
        # S = q[2] + S
        tmp = q[2] + tmp

S = tmp.replace('T', S)        
print(S[::order])
Buggy python submission (verdict: Time Limit Exceeded):
def judge(x, y):
  #if x < 0 or y < 0:
  #  return True
  if P[x] > P[y]:
    return True
  #if P[x] == P[y]:
  #  return judge(x-1, y-1)
  return False

N, K = list(map(int, input().strip().split()))
P = list(map(int, input().strip().split()))
start = 0
_sum = 0
for i in range(1, N - K + 1):
  if judge(i+K-1, i-1):
    tmp = sum(P[i:i+K])
    if tmp > _sum:
      _sum = tmp
      start = i
    #print(start)
ans = 0.0
for _p in P[start:start+K]:
  ans += (1+_p) / 2
print(ans)
#print(P[start:start+K])

Fixed submission:
N, K = list(map(int, input().strip().split()))
P = list(map(int, input().strip().split()))
start = 0
rec_sum = sum(P[0:K])
max_sum = rec_sum
for i in range(1, N - K + 1):
  rec_sum = rec_sum - P[i-1] + P[i+K-1]
  if rec_sum > max_sum:
    start = i
    max_sum = rec_sum
    
ans = 0.0
for _p in P[start:start+K]:
  ans += (1+_p) / 2
print(ans)
#print(P[start:start+K])

Buggy python submission (verdict: Time Limit Exceeded):
N, K = list(map(int, input().strip().split()))
P = list(map(int, input().strip().split()))
start = 0
_max = 0
for i in range(0, N - K + 1):
  tmp =  sum(P[i:i+K])
  if tmp > _max:
    _max = tmp
    start = i
ans = 0.0
for _p in P[start:start+K]:
  ans += (1+_p) / 2
print(ans)

Fixed submission:
N, K = list(map(int, input().strip().split()))
P = list(map(int, input().strip().split()))
start = 0
rec_sum = sum(P[0:K])
max_sum = rec_sum
for i in range(1, N - K + 1):
  rec_sum = rec_sum - P[i-1] + P[i+K-1]
  if rec_sum > max_sum:
    start = i
    max_sum = rec_sum
    
ans = 0.0
for _p in P[start:start+K]:
  ans += (1+_p) / 2
print(ans)
#print(P[start:start+K])
Buggy python submission (verdict: Time Limit Exceeded):
import copy

N = int(input().strip())
P = list(map(int, input().strip().split()))
ans = 0
for i in range(N):
  Q = copy.copy(P[0:i+1])
  Q.sort()
  #print(P)
  #print(Q)
  if Q[0] >= P[i]:
    ans += 1
  """
  flag = True
  for j in range(0, i):
    if P[i] > P[j]:
      flag = False
      break
  if flag:
    ans += 1
  """
print(ans)

Fixed submission:
import copy

N = int(input().strip())
P = list(map(int, input().strip().split()))
ans = 0
min = 1e10
for i in range(N):
  #Q = copy.copy(P[0:i+1])
  #Q.sort()
  #print(P)
  #print(Q)
  #if Q[0] >= P[i]:
  #  ans += 1
  if P[i] < min:
    min = P[i]
    ans += 1
  """
  flag = True
  for j in range(0, i):
    if P[i] > P[j]:
      flag = False
      break
  if flag:
    ans += 1
  """
  
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input().strip())
P = list(map(int, input().strip().split()))
ans = 0
for i in range(N):
  flag = True
  for j in range(0, i):
    if P[i] > P[j]:
      flag = False
      break
  if flag:
    ans += 1
print(ans)

Fixed submission:
import copy

N = int(input().strip())
P = list(map(int, input().strip().split()))
ans = 0
min = 1e10
for i in range(N):
  #Q = copy.copy(P[0:i+1])
  #Q.sort()
  #print(P)
  #print(Q)
  #if Q[0] >= P[i]:
  #  ans += 1
  if P[i] < min:
    min = P[i]
    ans += 1
  """
  flag = True
  for j in range(0, i):
    if P[i] > P[j]:
      flag = False
      break
  if flag:
    ans += 1
  """
  
print(ans)
Buggy python submission (verdict: Runtime Error):
k = int(input())
a, b = map(int, input())
flag = False
for i in range(a, b+1):
    if i % k == 0:
        flag = True
        break
if flag:
    print('OK')
else:
    print('NG')


Fixed submission:
k = int(input())
a, b = map(int, input().split())
flag = False
for i in range(a, b+1):
    if i % k == 0:
        flag = True
        break
if flag:
    print('OK')
else:
    print('NG')
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = input()
r = [False]*n
g = [False]*n
b = [False]*n
for i in range(len((s))):
    if s[i] == 'R':
        r[i] = True
    elif s[i] == 'G':
        g[i] = True
    else:
        b[i] = True
count = 0
for i in range(n):
    for j in range(i + 1, n):
        for k in range(j + 1, n):
            if r[i] and g[j] and b[k] and j - i != k - j:
                count += 1
            if r[i] and g[k] and b[j] and j - i != k - j:
                count += 1
            if r[j] and g[i] and b[k] and j - i != k - j:
                count += 1
            if r[j] and g[k] and b[i] and j - i != k - j:
                count += 1
            if r[k] and g[i] and b[j] and j - i != k - j:
                count += 1
            if r[k] and g[j] and b[i] and j - i != k - j:
                count += 1
print(count)


Fixed submission:
# https://atcoder.jp/contests/abc162/submissions/11837869
# tamazooさんを参考に書いた
n = int(input())
s = input()
x = [0] * n
num_r, num_g, num_b = 0, 0, 0
for i in range(n):
    if s[i] == 'R':
        x[i] = 1
        num_r += 1
    elif s[i] == 'G':
        x[i] = 2
        num_g += 1
    elif s[i] == 'B':
        x[i] = 4
        num_b += 1

num = num_r * num_g * num_b

for i in range(n):
    for j in range(1, n):
        if i - j < 0 or n <= i + j:
            break
        else:
            if (x[i - j] + x[i] + x[i + j]) == 7:
                num -= 1
print(num)
Buggy python submission (verdict: Runtime Error):
# 未完成
import math
a = list(map(int, input().split()))

x = [a[0] / 0.08, (a[0] + 1) / 0.08]
y = [a[1] / 0.1, (a[1] + 1) / 0.1]
ans = [max([a[0] / 0.08, a[1] / 0.1]),
       min([(a[0] + 1) / 0.08, (a[1] + 1) / 0.1])]
if ((a[1] + 1) / 0.1 > (a[1] + 1) / 0.1) or (a[1] / 0.1 > (a[0] + 1) / 0.08):
    print(-1)
else:
    if math.ceil(ans[0]) > ans[1]:
        print(-1)
    else:
        print(math.ceil(ans[0]))


Fixed submission:
a = input()
if a == "AAA" or a == "BBB":
    print("No")
else:
    print("Yes")
Buggy python submission (verdict: Runtime Error):
def get():
    return list(map(int, input().split()))


a = get()
if a[0] < 10:
    print(a[1]+100(10 - a[0]))
else:
    print(a[1])


Fixed submission:
def get():
    return list(map(int, input().split()))


a = get()
if a[0] < 10:
    print(a[1]+100*(10 - a[0]))
else:
    print(a[1])
Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
counter = 1
while n != 1:
    n = int(n / k)
    counter += 1
print(counter)


Fixed submission:
n, k = map(int, input().split())
counter = 1
while n >= k:
    n = int(n / k)
    counter += 1
print(counter)
Buggy python submission (verdict: Time Limit Exceeded):
import collections
n = int(input())

s = []
sLen = len(s)
for i in range(n):
    s.append(input())
c = collections.Counter(s)
max = c.most_common()[0][1]
print()
ans = []
for i in range(len(c.most_common())):
    if max == c.most_common()[i][1]:
        ans.append(c.most_common()[i][0])
    else:
        break
ans.sort()
for i in ans:
    print(i)


Fixed submission:
import collections
n = int(input())

s = []
sLen = len(s)
for i in range(n):
    s.append(input())

c = collections.Counter(s)
c_m = c.most_common()
max = c.most_common()[0][1]
print()
ans = []
for i in range(len(c_m)):
    if max != c_m[i][1]:
        break
    ans.append(c_m[i][0])
ans.sort()
for i in ans:
    print(i)
Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
p = list(map(int, input().split()))
M = 0
for i in range(len(p) - k + 1):
    savesum = sum(p[i:i + k])
    if savesum > M:
        M = savesum
print((k+M)/2)

Fixed submission:
import sys
n, k = map(int, input().split())
p = list(map(int, input().split()))
# 下の同値の場合を除外しないとrange(k,k)=[]となりfor文が回らない
if n == k:
    print((sum(p) + k) / 2)
    sys.exit(0)
saveSum = sum(p[0:k])
M = 0
for i in range(k, len(p)):
    saveSum = saveSum + p[i] - p[i - k]
    if saveSum > M:
        M = saveSum
print((k+M)/2)
Buggy python submission (verdict: Runtime Error):
import math

a, b = map(int, input().split())
print(int(a*b/math.gcd(a, b)))


Fixed submission:
def gcd(a, b):
    if b == 0:
        return a
    else:
        return gcd(b, a % b)


a, b = map(int, input().split())
if a < b:
    save = a
    a = b
    b = save
print(int(a*b/gcd(a, b)))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
ans = []
counter = 1
while counter <= n:
    for see in a:
        if see == counter:
            ans.append(a.index(see) + 1)
            counter += 1
            break
[print(x, end=' ')for x in ans]


Fixed submission:
n = int(input())
a = list(map(int, input().split()))
L = {}
for i in range(len(a)):
    L[i] = a[i]
sort_L = sorted(L.items(), key=lambda x: x[1])
[print(j[0]+1, end=' ')for j in sort_L]