qyliang/CodeNanoFix huggingface dataset:
Buggy code:
import sys

N = int(input())
S = [None]*N
counter = {}
for i in range(N):
    tmp = input()
    if tmp in counter:
        counter[tmp] += 1
    else:
        counter[tmp] = 1

#sort by value
counter_sorted = sorted(counter.items(), key=lambda x:x[1], reverse = True)

print
print(counter_sorted)
print

tmp = counter_sorted[0][1]
output = []
L = len(counter)
for i in range(L):
    if tmp == counter_sorted[i][1]:
        output.append(counter_sorted[i][0])
    else:
        break

#sort by key
output = sorted(output)
for i in output:
    print(i)

Fixed code:
import sys

N = int(input())
S = [None]*N
counter = {}
for i in range(N):
    tmp = input()
    if tmp in counter:
        counter[tmp] += 1
    else:
        counter[tmp] = 1

#sort by value
counter_sorted = sorted(counter.items(), key=lambda x:x[1], reverse = True)

tmp = counter_sorted[0][1]
output = []
L = len(counter)
for i in range(L):
    if tmp == counter_sorted[i][1]:
        output.append(counter_sorted[i][0])
    else:
        break

#sort by key
output = sorted(output)
for i in output:
    print(i)
Buggy code:
n = int(input())
counts = {}
best = 0
best_words = []
for idx in range(n):
    string = input()
    if counts.get(string) is None: counts[string] = 1
    else: counts[string] += 1

    score = counts[string]

    if score > best:
        best = score
        best_words = [string]
    
    elif score == best:
        best_words.append(string)

for string in best_words:
    print(string)

Fixed code:
n = int(input())
counts = {}
best = 0
best_words = []
for idx in range(n):
    string = input()
    if counts.get(string) is None: counts[string] = 1
    else: counts[string] += 1

    score = counts[string]

    if score > best:
        best = score
        best_words = [string]
    
    elif score == best:
        best_words.append(string)

for string in sorted(best_words):
    print(string)
Buggy code:
n = int(input())
d = dict()
max_value = 0
for i in range(n):
  x = input()
  if x in d:
    d[x] += 1
  else:
    d[x] = 1
  max_value = max([max_value, d[x]])

for key, value in d.items():
  if value == max_value:
    print(key)

Fixed code:
n = int(input())
d = dict()
max_value = 0
for i in range(n):
  x = input()
  if x in d:
    d[x] += 1
  else:
    d[x] = 1
  max_value = max([max_value, d[x]])

d = sorted([(key, value) for key, value in d.items()], key = lambda x: x[0])
for key, value in d:
  if value == max_value:
    print(key)
Buggy code:
n = int(input())
s = [input() for _ in range(n)]

s_sort = sorted(s)

s_num = [1]*n

for i in range(1,n):
    if s_sort[i] == s_sort[i-1]:
        s_num[i] += s_num[i-1]

Maxnum = max(s_num)

index_num = [n for n, v in enumerate(s_num) if v == Maxnum]

[print(s_sort[i]) for i in index_num,]


Fixed code:
n = int(input())
s = [input() for _ in range(n)]

s_sort = sorted(s)

s_num = [1]*n

for i in range(1,n):
    if s_sort[i] == s_sort[i-1]:
        s_num[i] += s_num[i-1]

Maxnum = max(s_num)

index_num = [n for n, v in enumerate(s_num) if v == Maxnum]

[print(s_sort[i]) for i in index_num]
Buggy code:
import collections
import sys
N = int(input())
S = [input() for _ in range(N)]



c = collections.Counter(S)
ans = []

for i in range(len(c.most_common())):
    if i == 0:
        print(c.most_common()[0][0])
    
    if i != 0:
        if (c.most_common()[i-1][1]) == (c.most_common()[i][1]):
            ans.append(((c.most_common()[i][0])))
        else:
            break
ans.sort()

for i in ans:
    print(i)

Fixed code:
import collections
import sys
N = int(input())
S = [input() for _ in range(N)]

c = collections.Counter(S)
ans = []
li=c.most_common()
for i in range(len(li)):
    if i == 0:
        ans.append(((li[0][0])))
    
    if i != 0:
        if (li[i-1][1]) == (li[i][1]):
            
            ans.append(((li[i][0])))
        else:
            break

ans.sort()

for i in ans:
    print(i)
Buggy code:
# input1 = list(map(int, (input().split())))
# input2 = list(map(int, (input().split())))
N = int(input())
input2 = []
for i in range(N):
    input2.append(input())

jisyo = {}

for a in input2:
    if a not in jisyo:
        jisyo[a] = 1
    else:
        jisyo[a] += 1

result = sorted(jisyo.items(), key=lambda x: x[1], reverse=True)

m = result[0][1]
for r in result:
    if m != r[1]:
        exit(0)
    print(r[0])


Fixed code:
# input1 = list(map(int, (input().split())))
# input2 = list(map(int, (input().split())))
N = int(input())
input2 = []
for i in range(N):
    input2.append(input())

jisyo = {}

for a in input2:
    if a not in jisyo:
        jisyo[a] = 1
    else:
        jisyo[a] += 1

result = sorted(jisyo.items(), key=lambda x: x[1], reverse=True)

m = result[0][1]
liststr = []
for r in result:
    if m != r[1]:
        break
    liststr.append(r[0])

liststr.sort()

for a in liststr:
    print(a)
Buggy code:
from collections import Counter
n=int(input())
s=Counter([input()for _ in[0]*n])
m=s.most_common(1)[0][1]
r=(k for k,v in s.items() if v==m)
for a in r:print(a)

Fixed code:
from collections import Counter
n=int(input())
s=Counter([input()for _ in[0]*n])
m=s.most_common(1)[0][1]
r=sorted((k for k,v in s.items() if v==m))
for a in r:print(a)
Buggy code:
N = int(input())
from collections import defaultdict
d = defaultdict(int)
for i in range(N):
  d[input()] += 1

max_cnt = max(d.value())
for v in sorted([key for key,value in d.items() if value == max_cnt]):
  print(v)

Fixed code:
N = int(input())
from collections import defaultdict
d = defaultdict(int)
for i in range(N):
  d[input()] += 1

max_cnt = max(d.values())
for v in sorted([key for key,value in d.items() if value == max_cnt]):
  print(v)
Buggy code:
dic={}
max1=0
ans=[]
n=int(input())
for i in range(n):
    word=input()
    if word in dic:
        dic[word]+=1
    else:
        dic[word]=1

for k in dic.values():
    if k>max1:
        max1=k
print(max1)

for n,b in dic.items():
    print(n,b)
    if b==max1:
        ans.append(n)
print(ans)


Fixed code:
dic={}
max1=0
ans=[]
n=int(input())
for i in range(n):
    word=input()
    if word in dic:
        dic[word]+=1
    else:
        dic[word]=1

for k in dic.values():
    if k>max1:
        max1=k

for n,b in dic.items():
    if b==max1:
        ans.append(n)


for i in sorted(ans):
    print(i)
Buggy code:
import collections

n = int(input())
s = [input() for i in range(n)]
c = collections.Counter(s)
m = c.most_common()

maxn = m[0][1]
ans = []

for i in range(len(m)-1):
    if m[i][1] == maxn:
        ans.append(m[i][0])
    else:
        break
for i in sorted(ans):
    print(i)


Fixed code:
import collections

n = int(input())
s = [input() for i in range(n)]
c = collections.Counter(s)
m = c.most_common()

maxn = m[0][1]
ans = []

ans.append(m[0][0])
for i in range(len(m)-1):
    if m[i+1][1] == maxn:
        ans.append(m[i+1][0])
    else:
        break
for i in sorted(ans):
    print(i)
Buggy code:
from collections import Counter
c = Counter()
n = int(input())
for _ in range(n):
    c[input()] += 1

_, m = c.most_common(1)[0]

for x, y in c.most_common():
    if y == m:
        print(x)
    else:
        break

Fixed code:
from collections import Counter
c = Counter()
n = int(input())
for _ in range(n):
    c[input()] += 1

_, m = c.most_common(1)[0]

ans = []
for x, y in c.most_common():
    if y == m:
        ans.append(x)
    else:
        break

for x in sorted(ans):
    print(x)
Buggy code:
from collections import Counter
n = int(input())
s = [input() for _ in range(n)]
d = Counter(s)
a = 0
for v in d.values():
  if v>a:
    a = v
for k in d.keys():
  if d[k]==a:
    print(k)

Fixed code:
from collections import Counter
n = int(input())
s = [input() for _ in range(n)]
s.sort()
d = Counter(s)
a = 0
for v in d.values():
  if v>a:
    a = v
for k in d.keys():
  if d[k]==a:
    print(k)
Buggy code:
from collections import Counter

n=int(input())
S=[input() for _ in range(n)]

c=Counter(s)
m=max(c.values())
ans = sorted(k for k,v in c.items() if v == m)
print("\n".join(ans))

Fixed code:
from collections import Counter

n=int(input())
S=[input() for _ in range(n)]

c=Counter(S)
m=max(c.values())
ans = sorted(k for k,v in c.items() if v == m)
print("\n".join(ans))
Buggy code:
n = int(input())
s = ["" for _ in range(n)]
for i in range(n):
    s[i] = input()
s.sort()
cnt = 0
m = -1
ans = []
for i in range(n-1):
    if s[i] == s[i + 1]:
        cnt += 1
    else:
        if cnt > m:
            m = cnt
            ans = [s[i]]
        elif cnt == m:
            ans.append(s[i])
        cnt = 0
if cnt > m:
    m = cnt
    ans = [s[i]]
elif cnt == m:
    ans.append(s[i])
# print(s)
for word in ans:
    print(word)

Fixed code:
n = int(input())
s = ["" for _ in range(n)]
for i in range(n):
    s[i] = input()
s.sort()
s.append("")
cnt = 0
m = -1
ans = []
for i in range(n):
    if s[i] == s[i + 1]:
        cnt += 1
    else:
        if cnt > m:
            m = cnt
            ans = [s[i]]
        elif cnt == m:
            ans.append(s[i])
        cnt = 0
for word in ans:
    print(word)
Buggy code:
N = int(input())
List = [input() for i in range(N)]
from collections import Counter
C = Counter(List)
C = C.most_common()
Newlist = []

for p in range(N):
  if C[p][1] == C[0][1]:
    Newlist.append(C[p][0])
  else:
    break
Newlist.sort()
for i in range(len(Newlist)):
  print(Newlist[i])

Fixed code:
N = int(input())
List = [input() for i in range(N)]
from collections import Counter
C = Counter(List)
C = C.most_common()
Newlist = []

for p in range(len(C)):
  if C[p][1] == C[0][1]:
    Newlist.append(C[p][0])
  else:
    break
Newlist.sort()
for i in range(len(Newlist)):
  print(Newlist[i])
Buggy code:
import collections
n=int(input())
s = []
sort=[]
for i in range(n):
    s.append(input())
ans=collections.Counter(s).most_common()
oldnum=ans[0][1]
for i in range(n):
    if oldnum == ans[i][1]:
        sort.append(ans[i][0])
        oldnum=ans[i][1]
    else:
        break
sort.sort()
for i in range(len(sort)):
    print(sort[i])


Fixed code:
import collections
n=int(input())
s = []
sort=[]
for i in range(n):
    s.append(input())
ans=collections.Counter(s).most_common()
oldnum=ans[0][1]
for i in range(len(ans)):
    if oldnum == ans[i][1]:
        sort.append(ans[i][0])
        oldnum=ans[i][1]
    else:
        break
sort.sort()
for i in range(len(sort)):
    print(sort[i])
Buggy code:
N = int(input())
S = []
maxnum = 0
maxyouso = {}
anslist = []
for kai in range (N):
    S.append(input())
for moji in S:
    if moji not in maxyouso:
        maxyouso[moji] = 1
    else:
        maxyouso[moji] = maxyouso[moji] + 1
print(maxyouso)
for num in maxyouso:
    if maxyouso[num] > maxnum:
        maxnum = maxyouso[num]
for num in maxyouso:
    if maxyouso[num] == maxnum:
        anslist.append(num)
anslist.sort()
for k in anslist:
    print(k)

Fixed code:
N = int(input())
S = []
maxnum = 0
maxyouso = {}
anslist = []
for kai in range (N):
    S.append(input())
for moji in S:
    if moji not in maxyouso:
        maxyouso[moji] = 1
    else:
        maxyouso[moji] = maxyouso[moji] + 1
for num in maxyouso:
    if maxyouso[num] > maxnum:
        maxnum = maxyouso[num]
for num in maxyouso:
    if maxyouso[num] == maxnum:
        anslist.append(num)
anslist.sort()
for k in anslist:
    print(k)
Buggy code:
from collections import *
_,*a=map(lambda x:x.rstrip(), open(0))
a=Counter(a).most_common()
a=[i[0] for i in a if i[1]==a[0][1]]
print(*a,sep="\n")

Fixed code:
from collections import *
_,*a=map(lambda x:x.rstrip(), open(0))
a=Counter(a).most_common()
a=sorted([i[0] for i in a if i[1]==a[0][1]])
print(*a,sep="\n")
Buggy code:
N = int(input())
dictionary = {}
for i in range(N):
    S = input()
    if S not in dictionary.keys():
        dictionary[S] = 1
    else:
        dictionary[S] += 1


value_max = max(dictionary.values())

max_list = []
for k, v in dictionary.items():
    if v == value_max:
        max_list.append(k)

for i in max_list:
    print(i)

Fixed code:
N = int(input())
dictionary = {}
for i in range(N):
    S = input()
    if S not in dictionary.keys():
        dictionary[S] = 1
    else:
        dictionary[S] += 1


value_max = max(dictionary.values())

max_list = []
for k, v in dictionary.items():
    if v == value_max:
        max_list.append(k)

max_list.sort()
for i in max_list:
    print(i)
Buggy code:
from collections import Counter


def main(n, s):
    c = Counter(s)
    max_count = c.most_common()[0][1]
    res = []
    for keys, count in c.most_common():
        if max_count == count:
            res.append(keys)
        else:
            print("\n".join(sorted(res)))
            return


if __name__ == "__main__":
    n = int(input())
    s = [input() for _ in range(n)]


Fixed code:
from collections import Counter


def main(n, s):
    c = Counter(s)
    max_count = c.most_common()[0][1]
    res = []
    for keys, count in c.most_common():
        if max_count == count:
            res.append(keys)

    print("\n".join(sorted(res)))


if __name__ == "__main__":
    n = int(input())
    s = [input() for _ in range(n)]

    main(n, s)
Buggy code:
from collections import Counter

n = int(input())
s = [input() for _ in range(n)]

counter = Counter(s)
count = counter.most_common()
print(counter, count)
most = count[0][1]

c = []
for i in range(len(count)):
    print(count[i][1])
    if most == count[i][1]:
        c.append(count[i][0])

c.sort()
print(*c, sep='\n')

Fixed code:
from collections import Counter

n = int(input())
s = [input() for _ in range(n)]

counter = Counter(s)
count = counter.most_common()
most = count[0][1]

c = []
for i in range(len(count)):
    if most == count[i][1]:
        c.append(count[i][0])

c.sort()
print(*c, sep='\n')
Buggy code:
n=int(input())
s = {}
for i in range(n):
    ss = input()
    if ss in s:
        s[ss] += 1
    else:
        s[ss] = 1
s2 = sorted(s.items(),key=lambda x:x[1], reverse = True)

va = -1
for key,value in s2:
    if va == -1:
        va = value
        print(key)
    else:
        if va == value:
            print(key)

Fixed code:
n=int(input())
s = {}
for i in range(n):
    ss = input()
    if ss in s:
        s[ss] += 1
    else:
        s[ss] = 1
s2 = sorted(s.items(),key=lambda x:x[1], reverse = True)
ans = []
va = -1
for key,value in s2:
    if va == -1:
        va = value
        ans.append(key)
    else:
        if va == value:
            ans.append(key)

ans.sort()
for x in ans:
    print(x)
Buggy code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import collections
import sys
input = sys.stdin.readline


def main():
    n = int(input())
    s = list()
    for i in range(n):
        s.append(str(input()).replace('\n', ''))

    c = dict(collections.Counter(s))
    max_count = max(c.values())
    for k, v in c.items():
        if v == max_count:
            print(k)


if __name__ == '__main__':
    main()


Fixed code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import collections
import sys
input = sys.stdin.readline


def main():
    n = int(input())
    s = list()
    for i in range(n):
        s.append(str(input()).replace('\n', ''))

    c = dict(collections.Counter(s))
    max_count = max(c.values())
    ans = list()
    for k, v in c.items():
        if v == max_count:
            ans.append(k)

    for i in sorted(ans):
        print(i)


if __name__ == '__main__':
    main()
Buggy code:
import sys #sys.stdin.readline()
import heapq #heap
from collections import defaultdict
fastinp = lambda: sys.stdin.readline().split(' ')[0].split('\n')
inp = lambda: input().split(' ')
ml = lambda x, y=int: list(map(y, x))
debug = lambda *args: print(*args, sep=' | ')
n = int(fastinp()[0])
hmap = defaultdict(int)
for i in range(n):
    hmap[fastinp()[0]] += 1
m = 0
for k, v in hmap.items():
    m = max(m, v)
for k, v in hmap.items():
    if v == m:
        print(k)


Fixed code:
import sys #sys.stdin.readline()
import heapq #heap
from collections import defaultdict
fastinp = lambda: sys.stdin.readline().split(' ')[0].split('\n')
inp = lambda: input().split(' ')
ml = lambda x, y=int: list(map(y, x))
debug = lambda *args: print(*args, sep=' | ')
n = int(fastinp()[0])
hmap = defaultdict(int)
for i in range(n):
    hmap[fastinp()[0]] += 1
m = 0
for k, v in hmap.items():
    m = max(m, v)
list = []
for k, v in hmap.items():
    if v == m:
        list.append(k)
print(*sorted(list), sep='\n')
Buggy code:
N = int(input())
S = [input() for _ in range(N)]

dic = {}

for i in range(N):
  if S[i] not in dic.keys():
    dic[S[i]] = 1
    
  else:
    dic[S[i]] += 1
    
maxim = max(dic.values())
ans = []

for i in dic.keys():
  if dic[keys] == maxim:
    ans.apend(keys)
    
ans.sort()

for i in ans:
  print(ans[i])

Fixed code:
N = int(input())
S = [input() for _ in range(N)]

dic = {}

for i in range(N):
  if S[i] not in dic.keys():
    dic[S[i]] = 1
    
  else:
    dic[S[i]] += 1
    
maxim = max(dic.values())
ans = []

for keys in dic.keys():
  if dic[keys] == maxim:
    ans.append(keys)
    
ans.sort()

for i in range(len(ans)):
  print(ans[i])
Buggy code:
n=int(input())
d={}
for i in range(n):
  s=input()
  if s in d:
    d[s]+=1
  else:
    d[s]=0
m=max(d.values())
for x in d.keys():
  if d[x]==m:
    print(x)

Fixed code:
n=int(input())
d={}
for i in range(n):
  s=input()
  if s in d:
    d[s]+=1
  else:
    d[s]=0
m=max(d.values())
ans=[]
for x in d.keys():
  if d[x]==m:
    ans.append(x)
ans.sort()
for x in ans:
  print(x)
Buggy code:
n = int(input())
d = dict()

for i in range(n):
    s = input()
    if s in d:
        d[s] += 1
    else:
        d[s] = 1

M = max(d.values())

ans_list = []
for k,v in d.items():
    if v == M:
        ans_list.append(k)

ans_list.sort()
for i in ans_list:
    print(i

Fixed code:
n = int(input())
d = dict()

for i in range(n):
    s = input()
    if s in d:
        d[s] += 1
    else:
        d[s] = 1

M = max(d.values())

ans_list = []
for k,v in d.items():
    if v == M:
        ans_list.append(k)

ans_list.sort()
for i in ans_list:
    print(i)
Buggy code:
N = int(input())
dic = {}
s = []
for _ in range(N):
   s.append(input())

for i in s:
    if i in dic.keys():
        dic[i] += 1
    else:
        dic[i] = 1
result = []
num = 0
for i in dic.keys():
    if dic[i] > num:
        result = []
        result.append(i)
        num = dic[i]
    elif dic[i] == num:
        result.append(i)
for i in result:
    print(i)

Fixed code:
N = int(input())
dic = {}
s = []
for _ in range(N):
   s.append(input())

for i in s:
    if i in dic.keys():
        dic[i] += 1
    else:
        dic[i] = 1
result = []
num = 0
for i in dic.keys():
    if dic[i] > num:
        result = []
        result.append(i)
        num = dic[i]
    elif dic[i] == num:
        result.append(i)
result.sort()
for i in result:
    print(i)
Buggy code:

from collections import Counter


N = int(input())
S = []
for i in range(N):
    S.append(input())

C=Counter(S).most_common()
L=len(C)

print(C[0][0])

for i in range(1,L):
    if C[0][1]==C[i][1]:
        print(C[i][0])

Fixed code:

from collections import Counter


N = int(input())
S = []
for i in range(N):
    S.append(input())

C=Counter(S).most_common()
L=len(C)

D=[]

D.append(C[0][0])

for i in range(1,L):
    if C[0][1]==C[i][1]:
        D.append(C[i][0])
D.sort()
M=len(D)

for i in range(M):
    print(D[i])
Buggy code:
import collections

n = int(input())
s = [input() for i in range(n)]

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

Fixed code:
import collections
 
n = int(input())
s = [input() for i in range(n)]
 
counter = collections.Counter(s)
most = counter.most_common()
ans = []
for i in range(len(counter.keys())):
    if most[i][1] == most[0][1]:
        ans.append(most[i][0])
    else:
        break
ans.sort()
for i in ans:
    print(i)
Buggy code:
from collections import Counter
import numpy as np
N = int(input())
S = [input() for _ in range(N)]
c = Counter(S)
candidate = np.array(list(c.keys()))[np.array(list(c.values())) == max(c.values())]
for i in range(len(candidate)):
  print(candidate[i])

Fixed code:
from collections import Counter
import numpy as np
N = int(input())
S = [input() for _ in range(N)]
c = Counter(S)
candidate = sorted(np.array(list(c.keys()))[np.array(list(c.values())) == max(c.values())])
for i in range(len(candidate)):
  print(candidate[i])
Buggy code:
n = int(input())
s = [input() for _ in range(n)]
t = s.sort()
x = 0
maxx = 0
for i in range(n-1):
    if s[i] == s[i+1]:
        x += 1
        if x == maxx:
            maxx = x
            t.append(s[i])
        elif x > maxx:
            maxx = x
            t = [s[i]]
    else:
        x = 0
for j in t:
    print(j)

Fixed code:
n = int(input())
s = [input() for _ in range(n)]
ss = sorted(s)
t = ss
x = 0
maxx = 0
for i in range(n-1):
    if ss[i] == ss[i+1]:
        x += 1
        if x == maxx:
            maxx = x
            t.append(ss[i])
        elif x > maxx:
            maxx = x
            t = [ss[i]]
    else:
        x = 0
for j in t:
    print(j)
Buggy code:
from collections import Counter
n=int(input())
name=[input() for _ in range(n)]

cnt=Counter(name)
l=max(cnt.values())
ans=[s for s,c in cnt.items() if c==1]
ans.sort()
print('\n'.join(ans))

Fixed code:
from collections import Counter
 
n = int(input())
sss = [input() for _ in range(n)]
cnt = Counter(sss)
l = max(cnt.values())
ans = [s for s, c in cnt.items() if c == l]
ans.sort()
print('\n'.join(ans))
Buggy code:
import collections
n = int(input())
S = [input() for i in range(n)]
c = collections.Counter(S)
li = c.most_common()
M = li[0][1]
for x in li:
    if x[1] == M:
        print(x[0])
    else:
        break

Fixed code:
import collections
n = int(input())
S = [input() for i in range(n)]
c = collections.Counter(S)
li = c.most_common()
M = li[0][1]
ans = []
for x in li:
    if x[1] == M:
        ans.append(x[0])
    else:
        break
ans.sort()
for x in ans:
    print(x)
Buggy code:
N = int(input())
name = [input() for i in range(N)]
import collections
'''
name = ""
dic = {}
for i in range(N):
  name = input()
  dic[name] += 1
print(dic)
'''
c = collections.Counter(name)
values, counts = zip(*c.most_common(N))
maxim = counts[0]
answer = []
for val, cnt in zip(values,counts):
  if ( cnt == maxim):
    answer.append(val)
  else:
    break
sorted(answer)
for i in answer:
  print(i)

Fixed code:
N = int(input())
name = [input() for i in range(N)]
import collections
'''
name = ""
dic = {}
for i in range(N):
  name = input()
  dic[name] += 1
print(dic)
'''
c = collections.Counter(name)
values, counts = zip(*c.most_common(N))
maxim = counts[0]
answer = []
for val, cnt in zip(values,counts):
  if ( cnt == maxim):
    answer.append(val)
  else:
    break
answer = sorted(answer)
for i in answer:
  print(i)
Buggy code:
n = int(input())
s = [input() for _ in range(n)]
s.sort()

count = {}
for s_i in s:
    if not s_i in count:
        count[s_i] = 0
    count[s_i] += 1
res = sorted(zip(count.keys(), count.values()),
             key=lambda x: x[1], reverse=True)

num = res[0][1]
res2 = []
for res_i in res:
    if res_i[1] != num:
        exit(0)
    res2.append(res_i[0])

res2.sort()
for res2_i in res2:
    print(res2_i)


Fixed code:
n = int(input())
s = [input() for _ in range(n)]
s.sort()

count = {}
for s_i in s:
    if not s_i in count:
        count[s_i] = 0
    count[s_i] += 1
res = sorted(zip(count.keys(), count.values()),
             key=lambda x: x[1], reverse=True)

num = res[0][1]
res2 = []
for res_i in res:
    if res_i[1] != num:
        break
    res2.append(res_i[0])

res2.sort()
for res2_i in res2:
    print(res2_i)
Buggy code:
N = int(input())
words = {}
for i in range(N):
  name = input()
  if name not in words:
    words[name] = 1
  elif name in words:
    words[name] += 1
    
res_name = []
for i in res_dict.keys():
  if res_dict[i] == max(res_dict.values()):
    res_name.append(i)
res_name = sorted(res_name)
for i in res_name:
  print(i)

Fixed code:
N = int(input())
words = {}
for i in range(N):
  name = input()
  if name not in words:
    words[name] = 1
  elif name in words:
    words[name] += 1
    
res_name = []
Max = max(words.values())
for i in words.keys():
  if words[i] == Max:
    res_name.append(i)
res_name = sorted(res_name)
for i in res_name:
  print(i)