qyliang/CodeNanoFix huggingface dataset:
Buggy code:
def solve(n: int, words: list):
    word_map = dict()
    max_count = 0
    for word in words:
        count = word_map.get(word, 0) + 1
        word_map[word] = count
        max_count = max(max_count, count)
   
    for word in sorted(word_map):
        if(word_map[word] == max_count):
            print(word)


def main():
    n = int(input())
    li = []
    for i in range(n):
        li.append(input())
        
    solve(n, li)    

Fixed code:
def solve(n: int, words: list):
    word_map = dict()
    max_count = 0
    for word in words:
        count = word_map.get(word, 0) + 1
        word_map[word] = count
        max_count = max(max_count, count)
   
    for word in sorted(word_map.keys()):
        if(word_map[word] == max_count):
            print(word)


def main():
    n = int(input())
    li = []
    for i in range(n):
        li.append(input())
    solve(n, li)


main()
Buggy code:
import collections
N = int(input())
S = [input() for i in range(N)]
c = collections.Counter(S)
l = c.most_common()
n, m = l[0]
ans = []
for i, j in l:
    if j == m:
        ans.append(i)
print(ans.sort())


Fixed code:
import collections
N = int(input())
S = [input() for i in range(N)]
c = collections.Counter(S)
l = c.most_common()
n, m = l[0]
ans = []
for i, j in l:
    if j == m:
        ans.append(i)
for a in sorted(ans):
    print(a)
Buggy code:
N = int(input())
s_list = {}
for i in range(N):
  S = input()
  if S in s_list:
    s_list[S] += 1
  else:
    s_list[S] = 0
max = 0
maxs = []
for s,c in s_list.items():
  if c > max:
    maxs = [s]
    max = c
  elif c == max:
    maxs.append(s)
for m in maxs:
  print(m)

Fixed code:
N = int(input())
s_list = {}
for i in range(N):
  S = input()
  if S in s_list.keys():
    s_list[S] += 1
  else:
    s_list[S] = 0
max = 0
maxs = []
for s,c in s_list.items():
  if c > max:
    maxs = [s]
    max = c
  elif c == max:
    maxs.append(s)
maxs.sort()
for m in maxs:
  print(m)
Buggy code:
from collections import defaultdict
from collections import OrderedDict
n = int(input())
ans = dict()
for _ in range(n):
    z = str(input())
    if z in answer:
        ans[z]+=1
    else:
        answer.update({z:1})
groupedByValue = defaultdict(list)
for key, value in sorted(answer.items()):
    groupedByValue[value].append(key)
M = groupedByValue[max(groupedByValue)]
for i in M:
    print(i)

Fixed code:
from collections import defaultdict
from collections import OrderedDict
n = int(input())
answer = dict()
for _ in range(n):
    z = str(input())
    if z in answer:
        answer[z]+=1
    else:
        answer.update({z:1})
groupedByValue = defaultdict(list)
for key, value in sorted(answer.items()):
    groupedByValue[value].append(key)
M = groupedByValue[max(groupedByValue)]
for i in M:
    print(i)
Buggy code:
def main():
    n = int(input())
    ss = {}
    max_s = -1
    for _ in range(n):
        s = input()
        if s not in ss:
            ss[s] = 0
        else:
            ss[s] += 1
            max_s = max(max_s, ss[s])

    ss = sorted(ss.items(), key=lambda x: x[0])
    anss = [s for s, i in ss if i == max_s]
    for ans in anss:
        print(ans)


if __name__ == "__main__":
    main()


Fixed code:
def main():
    n = int(input())
    ss = {}
    max_s = 0
    for _ in range(n):
        s = input()
        if s not in ss:
            ss[s] = 0
        else:
            ss[s] += 1
            max_s = max(max_s, ss[s])

    ss = sorted(ss.items(), key=lambda x: x[0])
    anss = [s for s, i in ss if i == max_s]
    for ans in anss:
        print(ans)


if __name__ == "__main__":
    main()
Buggy code:
import collections

n=int(input())
l=[]
for _ in range(n):
    l.append(input())

c=collections.Counter(l)
ccc=[]
for j in cc:
    if j[1]==max(c.values()):
        ccc.append(j[0])

for k in sorted(ccc):
    print(k)

Fixed code:
import collections

n=int(input())
l=[]
for _ in range(n):
    l.append(input())

c=collections.Counter(l)
cc=c.most_common()
ccc=[]
for j in cc:
    if j[1]==cc[0][1]:
        ccc.append(j[0])

for k in sorted(ccc):
    print(k)
Buggy code:
n = int(input())
s_lst = [str(input()) for i in range(n)]
s_lst.sort()

count_lst = []
count = 1
for i in range(n-1):
    s1 = s_lst[i]
    s2 = s_lst[i+1]

    if s1==s2:
        count += 1
        if i==n-2:
            count_lst.append(count)
    else:
        count_lst.append(count)
        count = 1

if n>1:
    if s_lst[-1]!=s_lst[-2]:
        count_lst.append(1)
if n==1:
    count_lst.append(1)

new_slst = list(set(s_lst))
max_count = max(count_lst)
answer_lst = []

for i in range(len(count_lst)):
    cou = count_lst[i]
    s = new_slst[i]
    if cou==max_count:
        answer_lst.append(s)

answer_lst.sort()
for i in range(len(answer_lst)):
    answer = answer_lst[i]
    print(answer)

Fixed code:
n = int(input())
s_lst = [str(input()) for i in range(n)]
s_lst.sort()

count_lst = []
count = 1

if n==1:
    count_lst.append(1)
else:
    for i in range(1,n):
        s1 = s_lst[i-1]
        s2 = s_lst[i]

        if s1==s2:
            count += 1
            if i==n-1:
                count_lst.append(count)
        else:
            count_lst.append(count)
            count = 1

    if s_lst[-1]!=s_lst[-2]:
        count_lst.append(1)


new_slst = list(set(s_lst))
new_slst.sort()
max_count = max(count_lst)
answer_lst = []

for i in range(len(count_lst)):
    cou = count_lst[i]
    s = new_slst[i]
    if cou==max_count:
        answer_lst.append(s)

answer_lst.sort()
for i in range(len(answer_lst)):
    answer = answer_lst[i]
    print(answer)
Buggy code:
N = int(input())

dic = {}
for i in range(N):
    if i not in dic:
        dic[i] = 1
    else:
        dic[i] = dic[i]+1

l = dic.items()
max = 0
for i in l:
    if i[1] > max:
        max = i[1]

result = []
for i in l:
    if i[1] == max:
        result.append(i[0])

result.sort()

for i in result:
    print(i)

Fixed code:
N = int(input())


inin = []
for i in range(N):
    inin.append(str(input()))
    
dic = {}
for i in inin:
    if i not in dic:
        dic[i] = 1
    else:
        dic[i] = dic[i]+1

l = dic.items()
max = 0
for i in l:
    if i[1] > max:
        max = i[1]

result = []
for i in l:
    if i[1] == max:
        result.append(i[0])

result.sort()

for i in result:
    print(i)
Buggy code:
n = int(input())
s = [input() for i in range(n)]
d = {}
for i in s:
    if i in d.keys():
        d[i]=d[i]+1
    else:
        d[i]=1
d_sorted = sorted(d.items(), key=lambda x:x[1])
d_name = [x[0] for x in d_sorted if x[1] == d_sorted[-1][0]]
d_name.sort()
print("\n".join(d_name))

Fixed code:
n = int(input())
s = [input() for i in range(n)]
d = {}
for i in s:
    if i in d.keys():
        d[i]=d[i]+1
    else:
        d[i]=1
d_sorted = sorted(d.items(), key=lambda x:x[1])
d_name = [x[0] for x in d_sorted if x[1] == d_sorted[-1][1]]
d_name.sort()
print("\n".join(d_name))
Buggy code:
from collections import defaultdict

def solve():
    N = int(input())
    d = defaultdict(int)
    for _ in range(N):
        a = input()
        d[a] += 1

    m = 0
    for k, v in d.items():
        m = max(m, v)
    
    l = []
    for k, v in d.items():
        if m == v:
            l.append(k)
    l.sort()
    for ans in l:
        print(ans)
    
print(solve())

Fixed code:
from collections import defaultdict

def solve():
    N = int(input())
    d = defaultdict(int)
    for _ in range(N):
        a = input()
        d[a] += 1

    m = 0
    for k, v in d.items():
        m = max(m, v)
    
    l = []
    for k, v in d.items():
        if m == v:
            l.append(k)
    l.sort()
    for ans in l:
        print(ans)
    
solve()
Buggy code:
N = int(input())
d = {}
for i in range(N):
    s = input()
    if s not in d:
        d[s] = 1
    else:
        d[s] += 1

print(d)

list = sorted(d.values())
print(list)
max_value = max(list)
sorted_list = sorted(d.items(), key=lambda x: x[0])
print(sorted_list)

for i, j in sorted_list:
    if j == max_value:
        print(i)

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

list = sorted(d.values())
max_value = max(list)
sorted_list = sorted(d.items(), key=lambda x: x[0])

for i, j in sorted_list:
    if j == max_value:
        print(i)
Buggy code:
from collections import Counter
N = int(input())
arr = []
arr_max = []
for i in range(N):
    arr.append(input())
dic = Counter(arr)
inverse = [(value, key) for key, value in dic.items()]
max_s = max(inverse)[0]
for key,value in dic.items():
    if value == max_s: 
        arr_max.append(key)
    else: continue
for j in arr_max: print (j)

Fixed code:
from collections import Counter
N = int(input())
arr = []
arr_max = []
for i in range(N):
    arr.append(input())
dic = Counter(arr)
inverse = [(value, key) for key, value in dic.items()]
max_s = max(inverse)[0]
for key,value in dic.items():
    if value == max_s: 
        arr_max.append(key)
    else: continue
for j in sorted(arr_max): print (j)
Buggy code:
d={}
k=0
j=0
for i in range(int(input())):
    s=input()
    if d.get(s) is None:
        d[s]=1
    else:
        d[s]+=1
for i in sorted(d,key=d.get,reverse=True):
    print(i)
    k=d[i]
    break
for i in sorted(d,key=d.get,reverse=True):
    j+=1
    if j>1:
        if d[i]==k:
            print(i)


Fixed code:
d={}
k=0
j=0
l=[]
for i in range(int(input())):
    s=input()
    if d.get(s) is None:
        d[s]=1
    else:
        d[s]+=1
for i in sorted(d,key=d.get,reverse=True):
    l.append(i)
    k=d[i]
    break
for i in sorted(d,key=d.get,reverse=True):
    j+=1
    if j>1:
        if d[i]==k:
            l.append(i)
l.sort()
for i in l:
    print(i)
Buggy code:
from collections import Counter
N=int(input())
S=[input() for i in range(N)]
s=Counter(S)
m=max(s.values())
s=sorted(s.items() ,key=lambda s:s[0])

print(s)


Fixed code:
from collections import Counter
N=int(input())
S=[input() for i in range(N)]
s=Counter(S)
m=max(s.values())
s=sorted(s.items() ,key=lambda s:s[0])
for a in s:
    if a[1]==m:
        print(a[0])
Buggy code:
import sys
input = sys.stdin.readline
N = int(input())
S = []
for _ in range(N):
    s = input().replace("\n", "")
    S.append(s)
S.sort()
f = 0
tres = 0
res = []
for i in range(1, N):
    if S[i] == S[i-1]:
        f += 1
    else:
        f = 0
    if f == tres:
        res.append(S[i])
    elif f > tres:
        tres = f
        res = [S[i]]

print("\n".join(map(str, res)))


Fixed code:
import sys
input = sys.stdin.readline
N = int(input())
S = []
for _ in range(N):
    s = input().replace("\n", "")
    S.append(s)
S.sort()
f = 0
tres = 0
res = [S[0]]
for i in range(1, N):
    if S[i] == S[i-1]:
        f += 1
    else:
        f = 0
    if f == tres:
        res.append(S[i])
    elif f > tres:
        tres = f
        res = [S[i]]

print("\n".join(map(str, res)))
Buggy code:
import collections
N=int(input())
S=[]
for i in range(N):
  s=str(input())
  S +=[s]
T=collections.Counter(S)
answer=T.most_common()
for i in range(len(T)):
  if answer[i][1]==answer[0][1]:
    print(answer[i][0])
  else:
    break

Fixed code:
import collections
N=int(input())
S=[]
for i in range(N):
  s=str(input())
  S +=[s]
T=collections.Counter(S)
answer=T.most_common()
A=[]
for i in range(len(T)):
  if answer[i][1]==answer[0][1]:
    A +=[answer[i][0]]
  else:
    break
A=sorted(A)
for a in A:
  print(a)
Buggy code:
n = int(input())
s = list(input() for i in range(n))

import collections
A = collections.Counter(S)
 
B = max(A.values())
C = [i for i in A if A[i] == B]
C = sorted(C)
 
for i in C:
    print(i)

Fixed code:
n = int(input())
s = list(input() for i in range(n))

import collections
A = collections.Counter(s)
 
B = max(A.values())
C = [i for i in A if A[i] == B]
C = sorted(C)
 
for i in C:
    print(i)
Buggy code:
N = int(input())

cdic = {}
for i in range(N):
    si = input()
    if si not in cdic.keys():
        cdic[si] = 1
    else:
        cdic[si] += 1
        
spair = sorted(cdic.items(), key=lambda x:x[1], reverse=True)
vmax = -1
maxes = []
for pair in spair:
    if pair[1] >= vmax:
        maxes.append(pair[0])
    else:
        break
        
smaxes = sorted(maxes)
for s in smaxes:
    print(s)


Fixed code:
N = int(input())

cdic = {}
for i in range(N):
    si = input()
    if si not in cdic.keys():
        cdic[si] = 1
    else:
        cdic[si] += 1
        
spair = sorted(cdic.items(), key=lambda x:x[1], reverse=True)


# print(cdic)
# print(spair)


vmax = -1
maxes = []
for pair in spair:
    if pair[1] >= vmax:
        maxes.append(pair[0])
        vmax = pair[1]
    else:
        break
        
# print(maxes)
smaxes = sorted(maxes)
# print(smaxes)
# print('---')

for s in smaxes:
    print(s)
Buggy code:
import collections
n = int(input())
s_list = []
for _ in range(n):
    i = input()
    s_list.append(i)
c = collections.Counter(s_list)

values, counts = zip(*c.most_common())
index = 0

for i in range(len(counts)-1):
    if counts[i] == counts[i+1]:
        index += 1
    else:
        break

for j in range(index+1):
    print(values[j])
    

Fixed code:
import collections
n = int(input())
s_list = []
for _ in range(n):
    i = input()
    s_list.append(i)
c = collections.Counter(s_list)

values, counts = zip(*c.most_common())
index = 0
for i in range(len(counts)-1):
    if counts[i] == counts[i+1]:
        index += 1
    else:
        break
        
ans_list = []
for j in range(index+1):
    ans_list.append(values[j])
ans_list.sort()
for ans in ans_list:
    print(ans)
Buggy code:
def main():
    N = int(input())

    count = dict()
    for i in range(N):
        s = input()
        try:
            count[s] += 1
        except:
            count[s] = 1
    
    sort_ = sorted(count.items(), key=lambda x:x[0], reverse=True)

    max_value = sort_[0][1]
    item = []
    for key,value in sort_:
        print(value)
        if value == max_value:
            item.append(key)
        else:
            break
        
    item.sort()
    for ans in item:
        print(ans)
    

if __name__ == '__main__':
    main()

Fixed code:
def main():
    N = int(input())

    count = dict()
    for i in range(N):
        s = input()
        try:
            count[s] += 1
        except:
            count[s] = 1
    
    sort_ = sorted(count.items(), key=lambda x:x[1], reverse=True)

    max_value = sort_[0][1]
    item = []
    for key,value in sort_:
        if value == max_value:
            item.append(key)
        else:
            break
    
    item.sort()
    for ans in item:
        print(ans)
    
if __name__ == '__main__':
    main()
Buggy code:
import collections

n = int(input())
s = list(input() for i in range(n))
sorted(s)
c = collections.Counter(s)
p = max(c.values())
s = list(set(s))

for i in range(len(s)):
    if c[s[i]] == p:
        print(s[i])

Fixed code:
import collections

n = int(input())
s = list(input() for i in range(n))
s = sorted(s)
c = collections.Counter(s)
p = max(c.values())
s = sorted(list(set(s)))

for i in range(len(s)):
    if c[s[i]] == p:
        print(s[i])
Buggy code:
import collections

N = int(input())
l = [input() for _ in range(N)]

c = collections.Counter(l)

L = c.most_common()

values, counts = zip(*c.most_common())

A = list(values)
B = list(counts)

b = B.count(B[0])

a = A[0:b + 1]

for i in a[0:]:
print(i)

Fixed code:
import collections
 
N = int(input())
l = [input() for _ in range(N)]
 
c = collections.Counter(l)
 
L = c.most_common()
 
values, counts = zip(*c.most_common())
 
A = list(values)
B = list(counts)
 
b = B.count(B[0])
 
a = A[0:b]
c = sorted(a)

for i in c[0:]:
		print(i)
Buggy code:
N = int(input())
A = [""] * N
for i in range(N):
	A[i] = input()
A.sort()

c, m = 1, [1, [A[0]]]
for i in range(1, N):
	if A[i - 1] == A[i]:
		c += 1
	else:
		if m[0] == c:
			m[1].append(A[i - 1])
		elif m[0] < c:
			m[1].clear()
			m[1].append(A[i - 1])
			m[0] = c
		c = 1

if m[0] == c:
	m[1].append(A[-1])
elif m[0] < c:
	m[1].clear()
	m[1].append(A[-1])

for i in m[1]:
	print(i)

Fixed code:
N = int(input())
A = [""] * N
for i in range(N):
	A[i] = input()
A.sort()

c, m = 1, [1, []]
for i in range(1, N):
	if A[i - 1] == A[i]:
		c += 1
	else:
		if m[0] == c:
			m[1].append(A[i - 1])
		elif m[0] < c:
			m[1].clear()
			m[1].append(A[i - 1])
			m[0] = c
		c = 1

if m[0] == c:
	m[1].append(A[-1])
elif m[0] < c:
	m[1].clear()
	m[1].append(A[-1])

for i in m[1]:
	print(i)
Buggy code:
import sys
from collections import Counter
N=int(input())
S=['']*N
for i in range(N):
    S[i]=input()
counter = Counter(S)
ans=[0]*len(counter)
num=0
for word, cnt in counter.most_common():
    ans[num]=cnt
    num+=1
anker=ans[0]
ankernum=0
for j in range(len(counter)):
    if ans[j]!=anker:
        ankernum=j
        break
word_ans=['']*len(counter)
k=0
for word, cnt in counter.most_common():
    word_ans[k]=word
    k+=1

print(sorted(word_ans[:ankernum]))

Fixed code:
import sys
from collections import Counter
N=int(input())
S=['']*N
for i in range(N):
    S[i]=input()
counter = Counter(S)
ans=[0]*len(counter)
num=0
for word, cnt in counter.most_common():
    ans[num]=cnt
    num+=1
anker=ans[0]
ankernum=0
for j in range(len(counter)):
    if ans[j]!=anker:
        ankernum=j
        break
    elif j==len(counter)-1:
        ankernum=j+1
word_ans=['']*len(counter)
k=0
for word, cnt in counter.most_common():
    word_ans[k]=word
    k+=1

for l in sorted(word_ans[:ankernum]):
    print(l)
Buggy code:
import collections
n = int(input())
s = collections.Counter([input() for i in range(n)])

values, counts = zip(*s.most_common())

len = counts.count(max(counts))

for i in range(len):
    print(values[i])


Fixed code:
import collections
n = int(input())
s = collections.Counter([input() for i in range(n)])

values, counts = zip(*s.most_common())

len = counts.count(max(counts))
values = sorted(values[:len])

for i in range(len):
    print(values[i])
Buggy code:
import collections

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

c = collections.Counter(s)
c2 = c.most_common()
a = c2[0][1]
ans = []

for i in range(len(c)):
    ans.append(c2[i][0])

ans.sort()
print(*ans,sep="\n")


Fixed code:
from collections import Counter

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

c =Counter(s)
c2 = c.most_common()
a = c2[0][1]
ans = []

for i in range(len(c)):
    if c2[i][1] == a:
        ans.append(c2[i][0])
ans.sort()
print(*ans,sep="\n")
Buggy code:
N = int(input())

S = [None] * N

m = dict()

for i in range(N):
  s = input()
  if not s in m.keys():
    m[s] = 1
  else:
    m[s] += 1

max_cnt = max(m.values())

ret = []

for k, v in sorted(m.items(), key=lambda x: x[1], reverse=True):
  if v < max_cnt:
    break
  ret.append(k)

ret.sort()
print(ret)

Fixed code:
N = int(input())
 
S = [None] * N
 
m = dict()
 
for i in range(N):
  s = input()
  if not s in m.keys():
    m[s] = 1
  else:
    m[s] += 1
 
max_cnt = max(m.values())
 
ret = []
 
for k, v in sorted(m.items(), key=lambda x: x[1], reverse=True):
  if v < max_cnt:
    break
  ret.append(k)
 
ret.sort()
for s in ret:
  print(s)
Buggy code:
import collections

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

cnt = collections.Counter(S)
max_cnt = max(cnt.values())

ans_list = []

for key, value in cnt.items():
    print(key, value)
    if value == max_cnt:
        ans_list.append(key)

print(*sorted(ans_list), sep='\n')



Fixed code:
import collections

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

cnt = collections.Counter(S)
max_cnt = max(cnt.values())

ans_list = []

for key, value in cnt.items():
    if value == max_cnt:
        ans_list.append(key)

print(*sorted(ans_list), sep='\n')
Buggy code:
n=int(input())
dict={}
cnt=0
for i in range(n):
  s=input()
  if s in dict:
    dict[s]+=1
    cnt=max(cnt,dict[s])
  else:
    dict[s]=1
dict_sorted=sorted(dict.items())
for j in range(len(dict_sorted)):
  if dict_sorted[j][1]==cnt:
    print(dict_sorted[j][0])

Fixed code:
n=int(input())
dict={}
cnt=1
for i in range(n):
  s=input()
  if s in dict:
    dict[s]+=1
    cnt=max(cnt,dict[s])
  else:
    dict[s]=1
dict_sorted=sorted(dict.items())
for j in range(len(dict_sorted)):
  if dict_sorted[j][1]==cnt:
    print(dict_sorted[j][0])
Buggy code:
from collections import Counter
N = int(input())
L = [str(input()) for i in range(N)]
Lc = Counter(L).most_common()
Llist = []             
L_max = Lc[0][1]       
i = 0
while True:
  Llist.append(Lc[i][0])
  if Lc[i+1][1]==L_max:
    i+=1
  else:
    break
print("\n".join(sorted(Llist)))

Fixed code:
from collections import Counter
N = int(input())
L = [str(input()) for i in range(N)]
Lc = Counter(L).most_common()
Llist = []             
L_max = Lc[0][1]       
i = 0
while True:
  Llist.append(Lc[i][0])
  if i<len(Lc)-1 and Lc[i+1][1]==L_max:
    i+=1
  else:
    break
print("\n".join(sorted(Llist)))
Buggy code:
from collections import Counter

# input
N = int(input())
S = []
s_append = S.append

for i in range(N):
    s = input()
    s_append(s)

# check
s_counter = Counter(S)
max = max(s_counter.values())

printed_items = []
append = printed_items.append
for i in [s[0] for s in s_counter.items() if s[1] == max]:
    print(i)

Fixed code:
from collections import Counter

# input
N = int(input())
S = []
s_append = S.append

for i in range(N):
    s = input()
    s_append(s)

# check
s_counter = Counter(S)
max = max(s_counter.values())

printed_items = []
append = printed_items.append
max_s = [s[0] for s in s_counter.items() if s[1] == max]
for i in sorted(max_s):
    print(i)
Buggy code:
from collections import Counter

N = int(input())
A = [input() for x in range(N)]
cnt = Counter(A)
mx = max(cnt.values())
sorted(cnt.items())
print('\n'.join(s for s, v in cnt.items() if v == mx))

Fixed code:
from collections import Counter

N = int(input())
A = [input() for x in range(N)]
cnt = Counter(A)
mx = max(cnt.values())
s = [s for s, v in cnt.items() if v == mx]
s.sort()
print('\n'.join(s))
Buggy code:
from collections import Counter

N = int(input())
S = [input() for x in range(N)]
E = Counter(a)
c = max(E.values())
s = [s for s, g in b.items() if g == c]
s.sort()
print('\n'.join(s))

Fixed code:
from collections import Counter

n = int(input())
a = [input() for x in range(n)]
b = Counter(a)
c = max(b.values())
s = [s for s, g in b.items() if g == c]
s.sort()
print('\n'.join(s))
Buggy code:
import collections

number = int(input())

array = []

for i in range(number):
    array.append(input())

dic = collections.Counter(array).most_common()

max_dic = [dic[0][0]]

for i in range(len(dic) - 1):
    if dic[i + 1][1] == dic[0][1]:
        max_dic.append(dic[i + 1][0])

for i in range(len(max_dic)):
    print(max_dic[i])

Fixed code:
import collections

number = int(input())

array = []

for i in range(number):
    array.append(input())

dic = collections.Counter(array).most_common()

max_dic = [dic[0][0]]

for i in range(len(dic) - 1):
    if dic[i + 1][1] == dic[0][1]:
        max_dic.append(dic[i + 1][0])
        
max_dic.sort()

for i in range(len(max_dic)):
    print(max_dic[i])
Buggy code:
n = int(input())
m = {}
for i in n:
  s = input()
  if s in m:
    m[s] += 1
  else:
    m[s] = 1
    
maxim = max(m.values())
mySet = set(key if value == maxim for key, value in m.items())
for i in mySet:
  print(i)
  

Fixed code:
n = int(input())
m = {}
for i in range(n):
    s = input()
    if s in m:
        m[s] += 1
    else:
        m[s] = 1

maxim = max(m.values())
mySet = set(key for key, value in m.items() if value == maxim)
for i in sorted(mySet):
    print(i)
Buggy code:
N = int(input())
dic = {}
for i in range(1,N+1):
    key = input()
    if key not in dic:
        dic[key] = 1
    else:
        dic[key] += 1
lis = []
for key,val in dic.items():
    lis.append([val,key])
lis.sort(reverse = True)

lis2 = []
fnum = lis[0][0]
j = 0
while lis[j][0] == fnum:
    lis2.append(lis[j][1])
    j += 1
lis2.sort()
for k in lis2:
    print(k)
    

Fixed code:
N = int(input())
dic = {}
for i in range(1,N+1):
    key = input()
    if key not in dic:
        dic[key] = 1
    else:
        dic[key] += 1
lis = []
for key,val in dic.items():
    lis.append([val,key])
lis.sort(reverse = True)

lis2 = []
fnum = lis[0][0]

for j in range(0,len(lis)): 
    if lis[j][0] == fnum:
        lis2.append(lis[j][1])
    else:
        break
lis2.sort()
for k in lis2:
    print(k)