Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
s=[input() for _ in range(n)]

maxx=s.count(max(s))
ans=[]

for i in s:
  if s.count(i)==maxx:
    ans.append(i)

ans=set(ans)
answer=[]
for i in ans:
  answer.append(i)

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

Fixed submission:
n=int(input())
s=[input() for _ in range(n)]
s.sort()
ans,be=[],""
cnt,maxcount=1,0

for i in range(n):
  if be==s[i]:
    cnt+=1
    
  else:
    if cnt>=1:
      if cnt>maxcount:
        maxcount=cnt
        ans.clear()
        ans.append(be)
      
      elif cnt==maxcount:
        ans.append(be)
      
      cnt=1
  be=s[i]
  if i==n-1:
    if cnt>=1:
      if cnt>maxcount:
        maxcount=cnt
        ans.clear()
        ans.append(be)
      
      elif cnt==maxcount:
        ans.append(be)
    
ans.sort()
for i in ans:
  if i!="":
    print(i)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
s=[input() for _ in range(n)]
ls=[0]*n

for i in s:
  ls[s.index(i)]+=1
  
maxcount=max(ls)
li=[]

for i in s:
  if s.count(i)==maxcount:
    li.append(i)
    
lis=[]
for i in li:
  if i in lis:
    pass
  else:
    lis.append(i)
    
lis=sorted(lis)
for i in lis:
  print(i)

Fixed submission:
n=int(input())
s=[input() for _ in range(n)]
s.sort()
ans,be=[],""
cnt,maxcount=1,0

for i in range(n):
  if be==s[i]:
    cnt+=1
    
  else:
    if cnt>=1:
      if cnt>maxcount:
        maxcount=cnt
        ans.clear()
        ans.append(be)
      
      elif cnt==maxcount:
        ans.append(be)
      
      cnt=1
  be=s[i]
  if i==n-1:
    if cnt>=1:
      if cnt>maxcount:
        maxcount=cnt
        ans.clear()
        ans.append(be)
      
      elif cnt==maxcount:
        ans.append(be)
    
ans.sort()
for i in ans:
  if i!="":
    print(i)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
s=[input()for _ in range(n)]
maxcount,ls=0,[]

for i in s:
  if s.count(i)==maxcount:
    ls.append(i)
    maxcount=s.count(i)
    continue
      
  elif s.count(i)>maxcount:
    ls=[i]
    maxcount=s.count(i)
    continue  
      
ls=sorted(set(ls))
for i in ls:
  print(i)

Fixed submission:
n=int(input())
s=[input() for _ in range(n)]
s.sort()
ans,be=[],""
cnt,maxcount=1,0

for i in range(n):
  if be==s[i]:
    cnt+=1
    
  else:
    if cnt>=1:
      if cnt>maxcount:
        maxcount=cnt
        ans.clear()
        ans.append(be)
      
      elif cnt==maxcount:
        ans.append(be)
      
      cnt=1
  be=s[i]
  if i==n-1:
    if cnt>=1:
      if cnt>maxcount:
        maxcount=cnt
        ans.clear()
        ans.append(be)
      
      elif cnt==maxcount:
        ans.append(be)
    
ans.sort()
for i in ans:
  if i!="":
    print(i)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
s=[input()for _ in range(n)]
ls,w,word=[],[],[]

for i in s:
  w.append(i)
  if i in w:
    ls.append(w.count(i))
    
  else:
    ls.append(1)

for i in range(n):
  if ls[i]==max(ls):
    word.append(w[i])
    
if set(word)==1:
  print(word[0])
  
else:
  word=sorted(set(word))
  for i in range(len(word)):
    print(word[i])

Fixed submission:
n=int(input())
s=[input() for _ in range(n)]
s.sort()
ans,be=[],""
cnt,maxcount=1,0

for i in range(n):
  if be==s[i]:
    cnt+=1
    
  else:
    if cnt>=1:
      if cnt>maxcount:
        maxcount=cnt
        ans.clear()
        ans.append(be)
      
      elif cnt==maxcount:
        ans.append(be)
      
      cnt=1
  be=s[i]
  if i==n-1:
    if cnt>=1:
      if cnt>maxcount:
        maxcount=cnt
        ans.clear()
        ans.append(be)
      
      elif cnt==maxcount:
        ans.append(be)
    
ans.sort()
for i in ans:
  if i!="":
    print(i)