qyliang/CodeNanoFix huggingface dataset:
Buggy code:
from collections import Counter
n = int(input())
s = []
ans = []

for i in range(n):
    s.append(input())

c = Counter(s)
c_s = c.most_common()
m = c.most_common()[0][1]
print(c_s)
print(m)

for j in range(len(c_s)):
    if c_s[j][1] != m:
        break
    else:
        ans.append(c_s[j][0])

ans.sort()
for t in ans:
    print(t)

Fixed code:
from collections import Counter
n = int(input())
s = []
ans = []

for i in range(n):
    s.append(input())

c = Counter(s)
c_s = c.most_common()
m = c.most_common()[0][1]

for j in range(len(c_s)):
    if c_s[j][1] != m:
        break
    else:
        ans.append(c_s[j][0])

ans.sort()
for t in ans:
    print(t)
Buggy code:
dic = {}
ans = []
a = 0

N = int( input() )
for i in range( N ):
  let = input()
  if let not in dic:
    dic.update( { let : 1 } )
  else:
    num=dic[ let ]
    dic[ let ] = num + 1
dic_sorted = sorted(dic.items(), key=lambda x:x[1])
for each in dic_sorted.keys():
  if dic_sorted[ each ] >= a:
    ans+=1
    a=dic_sorted[ each ]
  else:
    break
ans.sort()
for each in ans:
  print(each)

Fixed code:
dic = {}
ans = []
a = 0

N = int( input() )
for i in range( N ):
  let = input()
  if let not in dic:
    dic.update( { let : 1 } )
  else:
    num=dic[ let ]
    dic[ let ] = num + 1
dic_sorted = sorted(dic.items(), key=lambda x:x[1],reverse=True)
for each in dic_sorted:
  if each[1] >= a:
    ans.append(each[0])
    a=each[1]
  else:
    break
ans.sort()
for each in ans:
  print(each)
Buggy code:
import collections

N=int(input())
data=[input() for i in range(N)]
c = collections.Counter(data)
score=c
com=c.most_common()

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

val=score_sorted

count="Yes"
ii=0
ansa=1
while count=="Yes":
    if val[ii][1]==val[ii+1][1]:
        ii+=1
        ansa+=1
    else:
        count="No"
data2=[]
for i in range(ansa):
    data2.append(val[i][0])
    
data2.sort()
for i in range(ansa):
    print(data2[i])

Fixed code:
import collections

N=int(input())
data=[input() for i in range(N)]
c = collections.Counter(data)
score=c
com=c.most_common()

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

val=score_sorted
L=len(val)
count="Yes"
ii=0
ansa=1
if L==1:
    print(val[0][0])
else:
    while count=="Yes":
        if val[ii][1]==val[ii+1][1]:
            ii+=1

            ansa+=1
            if ii == L-1:
                break
        else:
            count="No"
    data2=[]
    for i in range(ansa):
        data2.append(val[i][0])

    data2.sort()
    for i in range(ansa):
        print(data2[i])
Buggy code:
i=int(input())
l=[""]*i
for k in range(i):
  l[k]=input()
l.sort()
maxi=0
kosu=0
for k in l:
  kosu+=1
  if kosu=maxi:
    li.append(k)
  elif kosu>maxi:
    li.clear()
    li.append(k)
print(*li)

Fixed code:
i=int(input())
l=[""]*i
for k in range(i):
  l[k]=input()
l.sort()
maxi=0
kosu=0
li=[]
subk=""
for k in l:
  if subk!=k:
    kosu=0
    subk=k
  kosu+=1
  if kosu==maxi:
    li.append(k)
  elif kosu>maxi:
    li.clear()
    li.append(k)
    maxi=kosu
for k in li:
  print(k)
Buggy code:
n = int(input())

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

_max = 0
for v in dic.values():
  if _max < v:
    _max = v

for k,v in dic.items():
  if v == _max:
    print(k)

Fixed code:
n = int(input())

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

_max = 0
for v in dic.values():
  if _max < v:
    _max = v
dic2 = sorted(dic.items())

for (k,v) in dic2:
  if v == _max:
    print(k)
Buggy code:
import collections

N = int(input())
S = [0]*N
for i in range(N):
  S[i] = input()

dic = collections.Counter(S)
max_value = max(dic.values())

for k, v in dic.items():
  if v == max_value:
    print(k)

Fixed code:
import collections

N = int(input())
S = [0]*N
for i in range(N):
  S[i] = input()

dic = collections.Counter(S)
max_value = max(dic.values())

A = []

for k, v in dic.items():
  if v == max_value:
    A.append(k)

A = sorted(A)

for i in A:
  print(i)
Buggy code:
from collections import Counter
N=int(input())
listS=[]
for i in range(N):
  S=input()
  listS+=[S]
listS=Counter(listS).most_common()
ans=[]
MAX=listS[0][1]
for i in range(N):
  if listS[i][1]==MAX:
    ans+=[listS[i][0]]
  else:
    break   
ans.sort()
for i in ans:
  print(i)

Fixed code:
from collections import Counter
N=int(input())
listS=[]
for i in range(N):
  S=input()
  listS+=[S]
listS=Counter(listS).most_common()
ans=[]
MAX=listS[0][1]
for i in range(len(listS)):
  if listS[i][1]==MAX:
    ans+=[listS[i][0]]
  else:
    break   
ans.sort()
for i in ans:
  print(i)
Buggy code:
N=int(input())
listS=[]
for i in range(N):
  S=input()
  listS+=[S]
listS.sort()
counter=[]
count=1
for i in range(N-1):
  if listS[i]==listS[i+1]:
    count+=1
  else:
    counter+=[count]
    count=1
    
MAX=max(counter)

for i in range(N-1):
  if listS[i]==listS[i+1]:
    count+=1
    if count==MAX:
      print(listS[i+1])
  else:
    counter+=[count]
    count=1

Fixed code:
N=int(input())
listS=[]
for i in range(N):
  S=input()
  listS+=[S]
listS.sort()
counter=[]
count=1
for i in range(N-1):
  if listS[i]==listS[i+1]:
    count+=1
  else:
    counter+=[count]
    count=1
    
counter+=[count]    
MAX=max(counter)
count=1

for i in range(N-1):
  if listS[i]==listS[i+1]:
    count+=1
  else:
    count=1
  if count==MAX:
    print(listS[i])
    
if MAX==1:
  print(listS[-1])
Buggy code:
import collections
n = int(input())
ls = [input() for i in range(n)]    
c = collections.Counter(ls)
count = c.most_common()[0][1]
ans = []
if c.most_common()[0][1] == 1:
    ls.sort()
    for i in ls:
        print(i)
else:
    c.sort()
    for i in range(len(c)):
        p = c.most_common()
        if p[i][1] == count:
            print(p[i][0])
        else:
            break   

Fixed code:
import collections

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

count = c.most_common()[0][1]
ans = []
p = c.most_common()
for i in range(len(c)):
    if p[i][1] == count:
        ans.append(p[i][0])
    else:
        break   
ans = sorted(ans)
for i in ans:
    print(i)
Buggy code:
import collections
n = int(input())
ls = [input() for i in range(n)]    
c = collections.Counter(ls)
count = c.most_common()[0][1]
ans = []
if c.most_common()[0][1] == 1:
    ls.sort()
    for i in ls:
        print(i)
else:
    for i in range(len(c)):
        p = c.most_common()
        if p[i][1] == count:
            ans.append(p[i][0])
        else:
            break   
    ans = sorted(ans
    for i in ans:
      print(i)

Fixed code:
import collections
from collections import Counter

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

count = c[0][1]
ans = []

for i in range(len(c)):
    if c[i][1] == count:
        ans.append(c[i][0])
    else:
        break   
ans = sorted(ans)
for i in ans:
    print(i)
Buggy code:
import collections

n = int(input())
words = [input() for _ in range(n)]
c = collections.Counter(words)
max_c = c.most_common()
ans = [max_c[0][0]]

for i in range(1, len(max_c)):
    if max_c[i][1] == max_c[i-1][1]:
        ans.append(max_c[i][0])
    else:
        break

ans_sorted = sorted(ans, reverse=True)
for i in range(len(ans)):
    print(ans_sorted[i])

Fixed code:
import collections

n = int(input())
words = [input() for _ in range(n)]
c = collections.Counter(words)
max_c = c.most_common()
ans = [max_c[0][0]]

for i in range(1, len(max_c)):
    if max_c[i][1] == max_c[i-1][1]:
        ans.append(max_c[i][0])
    else:
        break

ans_sorted = sorted(ans)
for i in range(len(ans)):
    print(ans_sorted[i])
Buggy code:
import sys
input = sys.stdin.readline
n=int(input())
s=[input().strip() for _ in range(n)]
from collections import Counter
s=Counter(s).most_common()
a=s[0][1]
for w,k in s:
    if k==a:
        print(w)


Fixed code:
import sys
input = sys.stdin.readline
n=int(input())
s=[input().strip() for _ in range(n)]
from collections import Counter
s=Counter(s).most_common()
a=s[0][1]
ans=[]
for w,k in s:
    if k==a:
        ans.append(w)
ans.sort()
for a in ans:
    print(a)
Buggy code:
import sys
read = sys.stdin.read
from collections import Counter
def main():
    n, *s = read().split()
    n = int(n)
    sc = Counter(s)
    scm = sc.most_common()
    maxnum = scm[0][1]
    r = []
    for i1 in range(n):
        if scm[i1][1] == maxnum:
            r.append(scm[i1][0])
        else:
            break
    r.sort()
    print(*r, sep="\n")

if __name__ == '__main__':
    main()


Fixed code:
import sys
read = sys.stdin.read
from collections import Counter
def main():
    n, *s = read().split()
    n = int(n)
    sc = Counter(s)
    scm = sc.most_common()
    maxnum = scm[0][1]
    r = []
    for scme in scm:
        if scme[1] == maxnum:
            r.append(scme[0])
        else:
            break
    r.sort()
    print(*r, sep="\n")

if __name__ == '__main__':
    main()
Buggy code:
N = int(input())
word_count = {}
for i in range(N):
    word = input()
    if word not in word_count:
        word_count[word] = 1
    else:
        word_count[word] += 1

counts = [val for (key, val) in word_count.items()]
max_count = max(counts)
words = [key for (key, val) in word_count.items() if val == max_count]
for word in words:
    print(word)


Fixed code:
N = int(input())
word_count = {}
for i in range(N):
    word = input()
    if word not in word_count:
        word_count[word] = 1
    else:
        word_count[word] += 1

counts = [val for (key, val) in word_count.items()]
max_count = max(counts)
words = sorted([key for (key, val) in word_count.items() if val == max_count])
for word in words:
    print(word)
Buggy code:
n = int(input())
dic = {}
for i in range(n):
  elem = input()
  if not elem in dic:
    dic[elem] = 1
  else:
    dic[elem] += 1
max_ = max(dic.values())

for k, v in dic.items():
  if v == max_:
    print(k)
      


Fixed code:
n = int(input())
dic = {}
for i in range(n):
  elem = input()
  if not elem in dic:
    dic[elem] = 1
  else:
    dic[elem] += 1
max_ = max(dic.values())

res = []
for k, v in dic.items():
  if v == max_:
    res.append(k)

res = sorted(res)
for elem in res:
  print(elem)
Buggy code:
def main():
    n = int(input())
    s = {}
    for _ in range(n):
        string = input()
        if string in s:
            s[string] += 1
        else:
            s[string] = 1
    s = sorted(list(s.items()), key=lambda x: (x[1], x[0]), reverse=True)
    lst = []
    max_num = s[0][1]
    if n == len(s):
        print(s.items()[0])
        return
    for string, num in s:
        if num != max_num:
            break
        lst.append(string)
    for l in reversed(lst):
        print(l)


if __name__ == "__main__":
    main()


Fixed code:
def main():
    n = int(input())
    s = {}
    for _ in range(n):
        string = input()
        if string in s:
            s[string] += 1
        else:
            s[string] = 1
    s = sorted(list(s.items()), key=lambda x: (x[1], x[0]), reverse=True)
    lst = []
    max_num = s[0][1]
    if n == len(s):
        for string, num in reversed(s):
            print(string)
    else:
        for string, num in s:
            if num != max_num:
                break
            lst.append(string)
    for l in reversed(lst):
        print(l)


if __name__ == "__main__":
    main()
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])

s2.reverse()

max_value = s2[0][1]
ret = []

for sss in s2:
    if sss[1] == max_value:
        ret.append(sss[0])
    else:
        break

ret2 = sorted(ret)
print(ret2)

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])

s2.reverse()

max_value = s2[0][1]
ret = []

for sss in s2:
    if sss[1] == max_value:
        ret.append(sss[0])
    else:
        break

ret2 = sorted(ret)
for r in ret2:
    print(r)
Buggy code:
n=int(input())
d=dict()

for i in range(n):
  a=input()
  d.setdefault(s,0)
  d[s] += 1

mx=0
result=[]
for key,value in d.items:
  if mx < value:
    mx = value
    result=[key]
  elif mx == value:
    result.append(key)

result.sort()

for i in range(len(result)):
  print(i)

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

for i in range(n):
  a=input()
  d.setdefault(a,0)
  d[a] += 1

mx=0
result=[]
for key,value in d.items():
  if mx < value:
    mx = value
    result=[key]
  elif mx == value:
    result.append(key)

result.sort()

for i in range(len(result)):
  print(result[i])
Buggy code:
N = input()
dic = {}
max = 0
for i in range(int(N)):
  word = input()
  if word not in dic.keys():
    
    if max == 0:
      max += 1
    dic['word'] = 1
    
  else:
    
    if max == dic['word']:
      max += 1
    dic['word'] += 1
    
candidates = sorted([word for word in dic.keys() if dic[key] == max])
for word in candidates:
  print(word)

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

candidates = sorted([word for word in dic.keys() if dic[word] == max])
for word in candidates:
  print(word)
Buggy code:
N=int(input())
ans={}
cnt=0
for i in range():
  t=input()
  if not t in ans.keys():
    ans[i]==1
  else:
    ans[i]+=1
  if cnt<ans[i]:
    cnt=ans[i]
tmp =[]
for i in ans.keys():
  if ans[i]  == cnt:
    tmp.append(i)
for i in sort(tmp):
  print(i)


Fixed code:
N=int(input())
ans={}
cnt=0
for i in range(N):
  t=input()
  if not t in ans.keys():
    ans[t]=1
  else:
    ans[t]+=1
  if cnt<ans[t]:
    cnt=ans[t]
tmp =[]
for i in ans.keys():
  if ans[i]  == cnt:
    tmp.append(i)
tmp.sort()
for i in tmp:
  print(i)
Buggy code:
from collections import defaultdict
n=int(input())
dic=defaultdict(int)
for _ in range(n):
    s = input()
    dic[s]+=1
L=list(dic.items())
L.sort(key=lambda x:x[0])
c=L[0][1]
for a,b in L:
    c=max(c,b)
for p in L:
    if p[1] == c:
        print(p[0])
    else:
        break


Fixed code:
from collections import defaultdict
n=int(input())
dic=defaultdict(int)
for _ in range(n):
    s = input()
    dic[s]+=1
L=list(dic.items())
L.sort(key=lambda x:x[0])
c=L[0][1]
for a,b in L:
    c=max(c,b)
for a,b in L:
    if b == c:
        print(a)
Buggy code:
N = int(input())
S = [input() for x in range(N)]
S.sort()

T = [[S[0]]]
for i in S[1:N]:
  if i == T[-1][-1]:
    T[-1].append(i)
  else:
    T.append([i])
T.sort(key=lambda x: len(x))
U = []

U.append(T[-1][0])
c = -2
for i in T[0:len(T)-1]:
  if len(i) == len(T[-1]):
    U.append(i[0])
  else:
    break


U.sort()
for x in U:
  print(x)


Fixed code:
N = int(input())
S = [input() for x in range(N)]
S.sort()

T = [[S[0]]]
for i in S[1:N]:
  if i == T[-1][-1]:
    T[-1].append(i)
  else:
    T.append([i])
T.sort(key=lambda x: len(x))
U = []

for i in T[::-1]:
  if len(i) == len(T[-1]):
    U.append(i[0])
  else:
    break

U.sort()
for x in U:
  print(x)
Buggy code:
n = input()
s = [input() for i in range(n)]
u = set(s)
dic = dict(zip(u, [0]*len(u)))
for i in range(n):
    dic[s[i]] += 1
m = max(dic.values())
res = []
for k, v in dic.items():
    if v == m:
        res.appned(k)
res.sort()
print(*res, sep="\n")

Fixed code:
n = int(input())
s = [input() for i in range(n)]
u = set(s)
dic = dict(zip(u, [0]*len(u)))
for i in range(n):
    dic[s[i]] += 1
m = max(dic.values())
res = []
for k, v in dic.items():
    if v == m:
        res.append(k)
res.sort()
print(*res, sep="\n")
Buggy code:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
N = int(readline())
S = read().split()

S = sorted(S)
ls = [[] for i in range(N + 1)]
max_num = 0
left = 0
right = 0
while right < N:
    while right < N and S[left] == S[right]:
        right += 1
    if (right  - left) >= max_num:
        ls[right - left].append(S[left])
        max_num = right - left
    left = right
    
print('\n'.join(ls[max_num]))

Fixed code:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
N = int(readline())
S = read().split()

S = sorted(S)
ls = [[] for i in range(N + 1)]
max_num = 0
left = 0
right = 0
while right < N:
    while right < N and S[left] == S[right]:
        right += 1
    if (right  - left) >= max_num:
        ls[right - left].append(S[left].decode())
        max_num = right - left
    left = right
    
print('\n'.join(ls[max_num]))
Buggy code:
N=int(input())
S = []
for j in range(N):
    S.append(input())
from collections import Counter
S2=collections.Counter(S)
S1=S2.most_common()

S3=[]
S3.append(S1[0][0])
for i in range(1,len(S1)):
    if S1[i][1]==S1[0][1]:
        S3.append(S1[i][0])
    else:
        break
S3=sorted(S3)
[print(i) for i in S3]

Fixed code:
N=int(input())
S = []
for j in range(N):
    S.append(input())
import collections
S2=collections.Counter(S)
S1=S2.most_common()

S3=[]
S3.append(S1[0][0])
for i in range(1,len(S1)):
    if S1[i][1]==S1[0][1]:
        S3.append(S1[i][0])
    else:
        break
S3=sorted(S3)
for i in range(0, len(S3)):
    print(S3[i])
Buggy code:
# coding: utf-8


def main():
    n = int(input())
    polls_dict = {}
    for _ in range(n):
        poll = input()
        if poll not in polls_dict:
            polls_dict[poll] = 1
        else:
            polls_dict[poll] += 1

    max_poll = max(polls_dict.values())
    #polls_set = sorted(polls_dict.keys())
    polls_dict = sorted(polls_dict)

    for key, value in polls_dict.items():
        if value == max_poll:
            print(key)
        else:
            pass

    #for poll in polls_set:
    #    print(poll)
    
    return 0


if __name__ == '__main__':
    main()


Fixed code:
# coding: utf-8


def main():
    n = int(input())
    polls_dict = {}
    for _ in range(n):
        poll = input()
        if poll not in polls_dict:
            polls_dict[poll] = 1
        else:
            polls_dict[poll] += 1

    max_poll = max(polls_dict.values())
    
    polls_set = set()
    for key, value in polls_dict.items():
        if value == max_poll:
            polls_set.add(key)

    polls_set = sorted(polls_set)
    for poll in polls_set:
        print(poll)
    
    return 0


if __name__ == '__main__':
    main()
Buggy code:
N = int(input())

strList = list([])

for i in range(N):
  strList.append(str(input()))

strDict = {}

for item in strList:
  if item not in strDict.keys():
    strDict[item] = 1
  else:
    strDict[item] += 1

maxList = list([])

for strKeys in strDict.keys():
  if strDict[strKeys] == max(strDict.values()):
    maxList.append(strKeys)

print(sorted(maxList))

Fixed code:
N = int(input())

strList = list([])

for i in range(N):
  strList.append(str(input()))

strDict = {}

for item in strList:
  if item not in strDict.keys():
    strDict[item] = 1
  else:
    strDict[item] += 1

maxList = list([])
maxNum = max(strDict.values())

for strKeys in strDict.keys():
  if strDict[strKeys] == maxNum:
    maxList.append(strKeys)

for srtedItem in sorted(maxList):
  print(srtedItem)
Buggy code:
n = int(input())
dict = {}
mx = 0
for i in range(n):
    s = input()
    if s not in dict:
        dict[s] = 0
    dict[s] += 1
    mx = max(mx, dict[s])
print(dict)
print(mx)
ans = []
for s in dict:
    if dict[s] == mx:
        ans.append(s)
ans.sort()
for s in ans:
    print(s)

Fixed code:
n = int(input())
dict = {}
mx = 0
for i in range(n):
    s = input()
    if s not in dict:
        dict[s] = 0
    dict[s] += 1
    mx = max(mx, dict[s])
ans = []
for s in dict:
    if dict[s] == mx:
        ans.append(s)
ans.sort()
for s in ans:
    print(s)
Buggy code:
dct = {}
for i in range(N):
    S = input()
    if dct.get(S) == None:
        dct[S] = 1
    else:
        dct[S] += 1
sortedDct = sorted(dct.items(), key=lambda x: -x[1])
L = []
maxNum = 0
for k, v in sortedDct:
    if (maxNum <= v):
        L.append(k)
        maxNum = v
L.sort()
for l in L:
    print(l)

Fixed code:
N = int(input())
dct = {}
for i in range(N):
    S = input()
    if dct.get(S) == None:
        dct[S] = 1
    else:
        dct[S] += 1
sortedDct = sorted(dct.items(), key=lambda x: -x[1])
L = []
maxNum = 0
for k, v in sortedDct:
    if (maxNum <= v):
        L.append(k)
        maxNum = v
L.sort()
for l in L:
    print(l)
Buggy code:
n = int(input())
dic = {}
for _ in range(n):
    s = input()
    if s not in dic:
        dic[s] = 1
    else:
        dic[s] += 1
m = max(dic.values())
anslis = []
for k, v in dic.items():
    if v == m:
        anslis.append(k)
print('/n'.join(anslis))

Fixed code:
n = int(input())
dic = {}
for _ in range(n):
    s = input()
    if s not in dic:
        dic[s] = 1
    else:
        dic[s] += 1
m = max(dic.values())
anslis = []
for k, v in dic.items():
    if v == m:
        anslis.append(k)
print('\n'.join(sorted(anslis)))
Buggy code:
n = int(input())
a={}
b=[]
for i in range(n):
    s=input()
    if s in a:
        a[s]=a[s]+1
    else:
        a[s]=int(1)
        b.append(s)
c=0
for i in b:
    if c < a[i]:
        c=a[i]
for i in b:
    if a[i]==c:
        print(i)
# print(a)


Fixed code:
n = int(input())
a={}
b=[]
for i in range(n):
    s=input()
    if s in a:
        a[s]=a[s]+1
    else:
        a[s]=int(1)
        b.append(s)
c=0
print()
for i in b:
    if c < a[i]:
        c=a[i]
b.sort()
for i in b:
    if a[i]==c:
        print(i)
# print(a)
Buggy code:
import sys
import os
import math

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

MOD = 10 ** 9 + 7


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N = ii()
    ret = 0
    di = {}
    mx = 0
    for n in range(N):
        s = iss()
        if s in di:
            di[s] += 1
            mx = max(di[s], mx)
        else:
            di[s] = 0

    for s in di:
        if di[s] == mx: print(s)


if __name__ == '__main__':
    main()


Fixed code:
import sys
import os
import math

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

MOD = 10 ** 9 + 7


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N = ii()
    S = [iss() for _ in range(N)]
    S.sort()
    di = {}
    mx = 0
    for s in S:
        if s in di:
            di[s] += 1
            mx = max(di[s], mx)
        else:
            di[s] = 0

    ret = []
    for s in di:
        if di[s] == mx: ret.append(s)
    print(*sorted(ret), sep='\n')


if __name__ == '__main__':
    main()
Buggy code:
n=int(input())
s=[input() for i in range(n)]
s.sort()
cnt=1
ans=0
pri=[]
for i in range(n-1):
    if s[i]==s[i+1]:
        cnt+=1
    else:
        ans=max(cnt,ans)
        cnt=1
ans=max(cnt,ans)
cnt=1
for i in range(n-1):
    if s[i]==s[i+1]:
        cnt+=1
    else:
        if cnt==ans:
            pri.append(s[i])
            cnt=1
        else:
            cnt=1
if cnt==ans:
    pri.append(s[-1])
print(ans)
for i in range(len(pri)):
    print(pri[i])

Fixed code:
n=int(input())
s=[input() for i in range(n)]
s.sort()
cnt=1
ans=0
pri=[]
for i in range(n-1):
    if s[i]==s[i+1]:
        cnt+=1
    else:
        ans=max(cnt,ans)
        cnt=1
ans=max(cnt,ans)
cnt=1
for i in range(n-1):
    if s[i]==s[i+1]:
        cnt+=1
    else:
        if cnt==ans:
            pri.append(s[i])
            cnt=1
        else:
            cnt=1
if cnt==ans:
    pri.append(s[-1])
for i in range(len(pri)):
    print(pri[i])