Problem:
 Score: 300 points    Problem Statement  We have N voting papers. The i -th vote (1 \leq i \leq N) has the string S_i written on it.  Print all strings that are written on the most number of votes, in lexicographical order.      Constraints   1 \leq N \leq 2 \times 10^5  S_i  (1 \leq i \leq N) are strings consisting of lowercase English letters.  The length of S_i  (1 \leq i \leq N) is between 1 and 10 (inclusive).         Input  Input is given from Standard Input in the following format:  N  S_1  :  S_N       Output  Print all strings in question in lexicographical order.        Sample Input 1 7
beat
vet
beet
bed
vet
bet
beet      Sample Output 1 beet
vet  beet and vet are written on two sheets each, while beat , bed , and bet are written on one vote each. Thus, we should print the strings beet and vet .       Sample Input 2 8
buffalo
buffalo
buffalo
buffalo
buffalo
buffalo
buffalo
buffalo      Sample Output 2 buffalo       Sample Input 3 7
bass
bass
kick
kick
bass
kick
kick      Sample Output 3 kick       Sample Input 4 4
ushi
tapu
nichia
kun      Sample Output 4 kun
nichia
tapu
ushi

Solution (Python):
import sys
from io import StringIO
import unittest


def resolve():
    N = int(input())
    S = {}
    maxs = 0
    for _ in range(N):
        s = input()
        if s in S.keys():
            S[s] += 1
            maxs = max(maxs, S[s])
        else:
            S[s] = 1
            maxs = max(maxs, S[s])
    
    keys = sorted(S.keys())
    for key in keys:
        if S[key] == maxs:
            print(key)


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """7
beat
vet
beet
bed
vet
bet
beet"""
        output = """beet
vet"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """8
buffalo
buffalo
buffalo
buffalo
buffalo
buffalo
buffalo
buffalo"""
        output = """buffalo"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """7
bass
bass
kick
kick
bass
kick
kick"""
        output = """kick"""
        self.assertIO(input, output)

    def test_入力例_4(self):
        input = """4
ushi
tapu
nichia
kun"""
        output = """kun
nichia
tapu
ushi"""
        self.assertIO(input, output)


if __name__ == "__main__":
    
    resolve()

Solution (Python):
n = int(input())
from collections  import Counter
s= []

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

c = Counter(s)
t = c.most_common()[0][1]
l = []
for i in c.most_common():
    if t == i[1]: 
        l.append(i[0])
l.sort()
for i in l:
    print(i)

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

import collections as cl
c=cl.Counter(s)
saidai=max(c.values())

ans=[]
for i in c.keys():
  if c[i]==saidai:
    ans.append(i)

ans=sorted(ans)
for i in range(len(ans)):
  print(ans[i])

Solution (Python):
N = int(input())
d = dict()
m = 0
for _ in range(N):
    s = input()
    d[s] = d.get(s, 0) + 1
    m = max(m, d[s])
ans = sorted(k for k, v in d.items() if v == m)
print(*ans, sep="\n")

Solution (Python):
n=int(input())
arr=[input() for _ in range(n)]
dic={}

for i in range(n): 
    if arr[i] not in dic:
        dic[arr[i]]=1
    else:
        dic[arr[i]]+=1

largest=max(dic.values()) 
ans=[]

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

ans=sorted(ans) 
for words in ans:
    print(words)

Solution (Python):
from collections import Counter

stdin = open(0)
N = int(stdin.readline())
S = stdin.read().split()

counter = Counter(S)
max_cnt = max(counter.values())
names = [name for name, cnt in counter.items() if cnt == max_cnt]
names.sort()

print(*names, sep='\n')

Solution (Python):
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)

Solution (Python):
from collections import OrderedDict
n=int(input())

dic=OrderedDict()
s=[input() for i in range(n)]
s.sort()

for i in range(n):
  if s[i] in dic.keys():
    dic[s[i]]+=1
  else:
    dic[s[i]]=0
    
ma = max(dic.values())
for k,v in dic.items():
  if v==ma:
    print(k)

Solution (Python):
import collections
n=int(input())
s=[]
for _ in range(n):
    s.append(str(input()))
ans=collections.Counter(s)
a=max(ans.values())
ans=[i for i,k in ans.items() if a==k]
print(*sorted(ans),sep="\n")

Solution (Python):
import itertools
import math
import fractions
import functools
n = int(input())
s = []
for i in range(n):
    s.append(input())

dic = {}

for i in range(n):
    current = dic.get(s[i],0)
    dic[s[i]] = current + 1

result = []
maximum = max(list(dic.values()))
for key in dic:
    if dic[key] == maximum:
        result.append(key)

result.sort()
for i in range(len(result)):
    print(result[i])

Solution (Python):
from collections import Counter
n = int(input())
S = []
for _ in range(n):
    s = input()
    S.append(s)
cnt = Counter(S)
l = max(cnt.values())

ans = []
for k,v in cnt.items():
  if v == l:
    ans.append(k)

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

Solution (Python):
n = int(input())
L = sorted(input() for _ in range(n))
s = sorted(set(L))
c = [0] * len(s)
prev = L[0]
cnt = 1
l = 0
for i in range(1, len(L)):
    if L[i] == prev:
        cnt += 1
    else:
        c[l] = cnt
        l += 1
        cnt = 1
        prev = L[i]
c[-1] = cnt
m = max(c)
for j in range(len(c)):
    if c[j] == m:
        print(s[j])

Solution (Python):
import collections
n = int(input())
counter = collections.defaultdict(lambda:0)
most = 0
for _ in range(n):
  s = input()
  counter[s] += 1
  most = max(most, counter[s])

for i,v in sorted(counter.items()):
  if v == most:
    print(i)

Solution (Python):
from collections import Counter

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

c = Counter(s)

m = max(c.values())

ans = []
for x in c.keys():
    if c[x]==m:
        ans.append(x)

print('\n'.join(sorted(ans)))

Solution (Python):
import sys
import collections
input = sys.stdin.readline


def main():
    N = int(input())
    S = list(input().strip() for _ in range(N))
    assert N == len(S)
    count = collections.Counter(S)
    answer = []
    frequency = 0
    for word in count:
        if count[word] > frequency:
            answer = []
            answer.append(word)
            frequency = count[word]
        elif count[word] == frequency:
            answer.append(word)
    answer.sort()
    for s in answer:
        print(s)


if __name__ == '__main__':
    main()

Solution (Python):
from collections import Counter
n = int(input())
s = [input() for i in range(n)]
c = Counter(s)
cks = list(c.keys())
cvs = c.values()
cvm = max(cvs)
l = []
for i,cvi in enumerate(cvs):
    if cvi==cvm:
        l.append(cks[i])
for ai in sorted(l):
    print(ai)

Solution (Python):
import collections
n = int(input())

c = {}
for _ in range(n):
    s = input()
    c[s] = c.get(s, 0) + 1

u = max(c.values())
print("\n".join(sorted([ k for k,v in c.items() if v == u ])))

Solution (Python):
from collections import defaultdict
n = int(input())
S = [input() for _ in range(n)]
d = defaultdict(int)
for s in S:
    d[s] += 1
m = max(d.values())
items = d.items()
a = sorted([c[0] for c in items if c[1] == m])
[print(i) for i in a]

Solution (Python):
from collections import Counter
n = int(input())
s = [input() for _ in range(n)]

c = Counter(s)
ma = max(c.values())
ans = []
for k,v in c.items():
  if ma == v:
    ans.append(k)

ans = sorted(ans)

for a in ans:
  print(a)

Solution (Python):
n = int(input())

d = {}

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

m = max(d[i] for i in d)

for j in sorted(d):
    if d[j] == m:
        print(j)

Solution (Python):
N=int(input())
cnt = {}
for _ in range(N):
  s = input()
  if s not in cnt:cnt[s]=0
  cnt[s]+=1
max_val = max([cnt[v] for v in cnt])
l = [v for v in cnt if cnt[v]==max_val]
l.sort()

print('\n'.join(l))

Solution (Python):

n = int(input())
s = [str(input()) for _ in range(n)]
 
from collections import Counter
s = Counter(s).most_common()
 
b =[]
a = s[0][1]
for i in range(len(s)):
    if s[i][1] == a :
        b.append(s[i][0])
b= sorted(b)
for i in range(len(b)):
    print(b[i])

Solution (Python):
n = int(input())
s = [str(input()) for _ in range(n)]

from collections import Counter
s = Counter(s).most_common()

b =[]
a = s[0][1]
for i in range(len(s)):
    if s[i][1] == a :
        b.append(s[i][0])
b= sorted(b)
for i in range(len(b)):
    print(b[i])

Solution (Python):
from collections import Counter
n = int(input())
s = [input() for _ in range(n)]
c=Counter(s)
max_cnt=0
for key in c:
    max_cnt=max(max_cnt,c[key])
ans=[]
for key in c:
    if c[key]==max_cnt:
        ans.append(key)
    else:
        continue
ans.sort()
for item in ans:
    print(item)

Solution (Python):
n = int(input())
arr = [input() for _ in range(n)]
dic = {}
for i in range(n):  
    if arr[i] not in dic:
        dic[arr[i]] = 1
    else:
        dic[arr[i]] += 1
largest = max(dic.values())  
ans = []
for keys in dic.keys():
    if dic[keys] == largest:  
        ans.append(keys)
ans = sorted(ans)  
for words in ans:
    print(words)

Solution (Python):
count = int(input())

ls = {}

for i in range(count):
    s = input()
    if s in ls:
        ls[s] += ls[s] + 1
    else:
        ls.setdefault(s, 1)

m = max(ls.values())

ans = [k for k, v in ls.items() if v == m]

print('\n'.join(sorted(ans)))

Solution (Python):
import sys
from collections import defaultdict


def input():
    return sys.stdin.readline().strip()


sys.setrecursionlimit(20000000)

MOD = 10 ** 9 + 7


def main():
    N = int(input())
    D = defaultdict(int)
    for _ in range(N):
        S = input()
        D[S] += 1
    K = list(D.keys())
    V = list(D.values())
    M = max(V)
    L = []
    for k in K:
        if D[k] == M:
            L.append(k)
    L.sort()
    print(*L, sep="\n")


if __name__ == "__main__":
    main()

Solution (Python):
from collections import Counter

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

c = Counter(S)
l = list(c.most_common())
A = []
for i,j in l:
    if j == l[0][1]:
        A.append(i)

A.sort()

for i in A:
    print(i)

Solution (Python):
n = int(input())
d = {}
for i in range(n):
  s = input()
  d[s] = d.get(s,0)+1
m = max(d[i] for i in d)
for s in sorted(d):
  if d[s]==m:
    print(s)

Solution (Python):
N = int(input())
data = {}

for i in range(N):
    S = input()
    if S in data.keys():
        data[S] += 1
    else:
        data[S] = 1

m = max(data.values())

L = []

for x in data.keys():
    if data[x] == m:
        L.append(x)

L.sort()

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

Solution (Python):
from collections import Counter

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

cS = Counter(S)
largest = max(cS.values())
ans = []
for k, v in cS.items():
    if v == largest:
        ans.append(k)
ans.sort()
for w in ans:
    print(w)

Solution (Python):
from collections import Counter
n=int(input())
list=[input() for _ in range(n)]
list.sort()
c=Counter(list).most_common()
most=c[0][1]
c.sort()
for i in range(len(c)):
    if c[i][1]==most:
        print(c[i][0])

Solution (Python):
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)

Solution (Python):
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))

Solution (Python):
n = int(input())
L = []
for i in range(n):
    L.append(input())
    
from collections import Counter
L = Counter(L)
L =L.most_common()

li = []
for i in range(len(L)):
    if L[i][1] == L[0][1]:
        li.append(L[i][0])
li.sort()

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

Solution (Python):
n = int(input())

d = {}
for _ in range(n):
  s = input()
  d[s] = d.get(s, 0) + 1

m = max(d.values())
ans = []
for s in d:
  if d[s] == m:
    ans.append(s)
    
ans.sort()
for a in ans:
  print(a)

Solution (Python):
n=int(input())
s = {}
maxs = 1
wdlst = set()
for i in range(n):
  si = input()
  if si in s:
    s[si] = s[si] + 1
    maxs = max(maxs,s[si])
  else:
    s[si] = 1
    wdlst.add(si)
res = list()
for x in wdlst:
  if s[x]==maxs:
    res.append(x)
res.sort()
for x in res:
  print(x)

Solution (Python):
import collections
n=int(input())
s=[str(input()) for i in range(n)]
c=collections.Counter(s)
lst=[]
maxi=max(c.values())
for i in c.keys():
  if c[i]==maxi:
    lst.append(i)
lst.sort()
for k in range(len(lst)):
  print(lst[k])

Solution (Python):
N = int(input())

S_list = []

for i in range(N):
    S_list.append(input())
    
import collections
c = collections.Counter(S_list)

max_num_of_occur = max(c.values())
most_common_list = []

for k,v in c.items():
    if v==max_num_of_occur:
        most_common_list.append(k)

NO_OUTPUT = [print(x) for x in sorted(most_common_list)]

Solution (Python):
n = int(input())

words = {}

for i in range(n):
    key = input()
    if key not in words:
        words[key] = 0
    words[key] += 1

l = []
th = max(words.values())

for i,j in words.items():
    if th == j:
        l.append(i)

l.sort()

print(*l, sep="\n", end="")

Solution (Python):
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")

Solution (Python):
import collections

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

c = collections.Counter(s)
c_s = c.most_common()
m = c.most_common()[0][1]
ans = []
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)

Solution (Python):
import collections

n = int(input())
s = []

while True:
  try:
    s.append(input())
    
  except:
    break
words = []
c = collections.Counter(s)
MAX = c.most_common()[0][1]
for i,j in c.most_common():
  if j==MAX:
    words.append(i)
  else:
    break

L = sorted(set(words))

for i in L:
  print(i)

Solution (Python):
import collections
N = int(input())
S = [input() for i in range(N)]
votes_collection = collections.Counter(S)
vote_max_num = votes_collection.most_common(1)[0][1]
max_votes = sorted([i[0]
                    for i in votes_collection.items() if i[1] == vote_max_num])
for i in max_votes:
    print(i)

Solution (Python):
N=int(input())
A=[input() for i in range(N)]

from collections import Counter
counter=Counter(A)
m=max(counter.values())
C=[]
for i,value in counter.items():
    if value==m:
        C.append(i)
C=sorted(C)
print(*C,sep='\n')

Solution (Python):
N = int(input())
S = [str(input()) for _ in range(N)]

S.sort()
lst = [1]
for i in range(1, N):
    if S[i] == S[i-1]:
        lst[-1] += 1
    else:
        lst.append(1)

candidate = list(set(S))
candidate.sort()


max_value = max(lst)
max_index = [i for i, x in enumerate(lst) if x == max_value]


for j in range(len(max_index)):
    print(candidate[max_index[j]])

Solution (Python):
from collections import OrderedDict
n = int(input())
d = {}
for i in range(n):
    s = input()
    if s in d:
        d[s] += 1
    else:
        d[s] = 1
d = OrderedDict(sorted(d.items()))
mx = 0
for v in d.values():
    mx = max(v, mx)
for k, v in d.items():
    if v == mx:
        print(k)

Solution (Python):
n = int(input())
s = [input() for _ in range(n)]
s.sort()
s.append(0)
k = 1
m = 0
ans = []
for i in range(n):
    if s[i] == s[i+1]:
        k += 1
    else:
        if m < k:
            ans = []
            ans.append(s[i])
            m = k
        elif m == k:
            ans.append(s[i])
        k = 1
for s in ans:
    print(s)

Solution (Python):
import sys
stdin = sys.stdin
sys.setrecursionlimit(10 ** 7)

def LI(): return list(map(int, stdin.readline().split()))
def LS(): return list(stdin.readline())

from collections import Counter
n = int(input())
s = Counter([input() for i in range(n)])
high = max(s.values())
ans = [k for k,v in s.items() if v==high]
print('\n'.join(sorted(ans)))

Solution (Python):

import sys

sysread = sys.stdin.readline
read = sys.stdin.read

from collections import defaultdict
sys.setrecursionlimit(10**7)


def run():
    N, *S = read().split()
    dic = defaultdict(lambda:0)
    for s in S:
        dic[s] += 1
    dic = sorted(dic.items(), key = lambda x:x[1], reverse=True)
    num = dic[0][1]
    ret = []
    for s, n in dic:
        if n != num:break
        ret.append(s)
    print('\n'.join(sorted(ret)))


if __name__ == "__main__":
    run()

Solution (Python):
from sys import stdin, setrecursionlimit


def main():
    n = int(stdin.readline())
    s = [stdin.readline()[:-1] for _ in range(n)]
    keys = list(set(s))
    keys.sort()
    summary = {}

    for key in keys:
        summary[key] = 0

    m = 0
    for si in s:
        summary[si] += 1
        m = max(summary[si], m)

    for key in keys:
        if summary[key] == m:
            print(key)


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()

Solution (Python):
from collections import Counter

N, *S = open(0).read().split()

C = Counter(S)

ma = max(C.values())
ans = sorted(k for k, v in C.items() if v == ma)

print("\n".join(ans))

Solution (Python):
from collections import Counter
n = int(input())
s = [input() for _ in range(n)]
c = Counter(s)
a = max([c[i] for i in set(s)])
r = []
for i in set(s):
    if c[i] >= a:
        r.append(i)
r.sort()
[print(i) for i in r]

Solution (Python):
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])

Solution (Python):

"""
Created on Thu May  7 22:30:26 2020

@author: shinba
"""

from operator import itemgetter

N = int(input())

data = {}

for i in range(N):
    string = input()
    if string in data:
        data[string] += 1
    else:
        data[string] = 1

s = sorted(data.items(),key=itemgetter(1),reverse = True)

M = s[0][1]

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

ans.sort()

for i in ans:
    print(i)

Solution (Python):
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    n=int(input())
    l=[input() for i in range(n)]
    from collections import Counter
    c=Counter(l)
    csort=c.most_common()
    maxl=[]
    for i in range(len(csort)):
        if csort[i][1]==csort[0][1]:
            maxl.append(csort[i][0])
    maxl.sort()
    for i in maxl:
        print(i)
resolve()

Solution (Python):
from collections import deque

N = int(input())
S = [""] * N
for i in range(N):
    S[i] = input()
mostfrequent = deque()
wordcount = {}
frequentoccurence = 0

for s in S:
    if not s in wordcount:
        wordcount[s] = 1
    else:
        wordcount[s] += 1
    if wordcount[s] == frequentoccurence:
        mostfrequent.append(s)
    if wordcount[s] > frequentoccurence:
        frequentoccurence = wordcount[s]
        mostfrequent.clear()
        mostfrequent.append(s)
frequentlist = list(mostfrequent)
frequentlist.sort()
print("\n".join(frequentlist))

Solution (Python):
import collections
n = int(input())
s = [str(input()) for i in range(n)]

temp = collections.Counter(s)
temp = temp.most_common()

ans = []
num = temp[0][1]

for i,j in temp:
    if num == j:
        ans.append(i)
    else:
        break

print(*sorted(ans))

Solution (Python):
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)

Solution (Python):
from collections import Counter
def resolve():
    n=int(input())
    l=[input() for i in range(n)]
    c=Counter(l)
    maxl=[]
    cntmax=max(c.values())
    for name,kazu in c.items():
        if kazu==cntmax:
            maxl.append(name)
    maxl.sort()
    for i in maxl:
        print(i)
resolve()

Solution (Python):
import sys
import collections
from collections import Counter

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

cur = Counter(s)
mx = 0
for v in cur.values():
    mx = max(mx, v)

ans = []
for k, v in cur.items():
    if v == mx:
        ans.append(k)
ans.sort()
for i in ans:
    print(i)

Solution (Python):
import collections
n = int(input())
s_ = [input() for i in range(n)]

cnt = collections.Counter(s_)
cntList = list(cnt.most_common())
cnt_f = cnt.most_common()[0][1]

resList = []
for i in range(len(cntList)):
    if cntList[i][1] == cnt_f:
        resList.append(cntList[i][0])
    else:
        break

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

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

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

Solution (Python):
import collections
n=int(input())
s=[input() for _ in range(n)]
c=collections.Counter(s)
common=c.most_common()
value,cnt=zip(*common)
common.sort(key=lambda x:x[0])
m=max(cnt)
for cc in common:
  if cc[1]==m:
    print(cc[0])

Solution (Python):
import collections
n=int(input())
s=[input() for i in range(n)]
dic=collections.Counter(s)
ans=[]
largest=max(dic.values())
for keys in dic.keys():
    if dic[keys]==largest:
        ans.append(keys)
ans=sorted(ans)
print(*ans)

Solution (Python):
import collections
n = int(input())
s = [0]*n
for i in range(n):
    s[i] = input()

set_s = set(s)
cnt_s = collections.Counter(s)

m=0
for i in set_s:
    m = max(m,cnt_s[i])
ans=[]
for i in set_s:
    if cnt_s[i]==m:
        ans.append(i)
ans = sorted(ans)

for a in ans:
    print(a)

Solution (Python):
import collections








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

c = collections.Counter(S)
cmc = c.most_common()
nmc = c.most_common()[0][1]

ans = []
for cmc_ in cmc:
  if cmc_[1] == nmc:
    ans.append(cmc_[0])
  else:
    break

ans.sort()
[print(ans_) for ans_ in ans]

Solution (Python):
N = int(input())
dic = dict()
lis = list()
for i in range(N):
    tmp = input()
    lis.append(tmp)
    dic[tmp] =0
maxi = 0
for i in lis:
    dic[i] +=1
    if maxi < dic[i]:
        maxi = dic[i]
result = list()
for name in dic:
    if dic[name] == maxi:
        result.append(name)

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

Solution (Python):
from collections import Counter
 
N = int(input())
S = []
for i in range(N):
    S.append(input())
S.sort()

c = Counter(S).most_common()

m = c[0][1]
c.sort()
for i in range(len(c)):
    if c[i][1] == m:
        print(c[i][0])

Solution (Python):
N=int(input())
data={}
for i in range(N):
    name=input()
    if data.get(name) == None:
        data[name]=0
    data[name] += 1
data = sorted(data.items(),key=lambda x:x[1])
if len(data) == 1:
    print(data[-1][0])
else:
    mx=data[-1][1]
    l=[]
    for i in range(N):
        if data[len(data)-i-1][1] == mx:
            l.append(data[len(data)-i-1][0])
        else:
            break
    l.sort()
    for i in l: print(i)

Solution (Python):
N=int(input())
S=[]
dict={}

for n in range(N):
  S.append(input())

S.sort()

for n in range(N):
  if n!=0 and S[n]==S[n-1]:
    dict[S[n]]+=1
  else:
    dict[S[n]]=1
    
MAX=max(dict.values())
S2=[]

for k,v in dict.items():
  if v==MAX:
    S2.append(k)

S2.sort()
for s2 in S2:
  print(s2)

Solution (Python):
import collections

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

col = collections.Counter(s)
col = col.most_common()

count = [0]
k = 0

for i in range(len(col)):
    if i == 0:
        count[k] = col[i][1]
        k += 1
    elif count[k-1] == col[i][1]:
        count.append(col[i][1])

ans = [0]*len(count)

for i in range(len(count)):
    ans[i] = col[i][0]
ans.sort()

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

Solution (Python):
N = int(input())
dict1 = {}
for _ in range(N):
  s = input()
  if s in dict1:
    dict1[s] += 1
  else:
    dict1[s] = 1
max_num= max(dict1.values())
list1 = [d[0] for d in dict1.items() if d[1]==max_num]
list1.sort()
for s in list1:
  print(s)

Solution (Python):
n = int(input())

words = []
dict = {}
for i in range(n):
    s = input()
    words.append(s)
    if s not in dict:
        dict[s] = 0
    dict[s] += 1

max = max(dict.values())
for s in sorted([d for d in dict if dict[d] == max]):
    print(s)

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

m=max(d.values())
n=[]
for i in d.keys():
        if d[i]==m:
                n.append(i)
n.sort()
for i in n:
        print(str(i))

Solution (Python):
import collections
n=int(input())
s = [0]*n
for i in range(n):
    s[i] = input()
c = collections.Counter(s).most_common()
maxn = c[0][1]
ans = []
for i in range(len(c)):
    if c[i][1] == maxn:
        ans.append(c[i][0])
print('\n'.join(sorted(ans)))

Solution (Python):


N = int(input())
D = {}
mx = 0
for _ in range(N):
    s = str(input())
    if s not in D:
        D[s] = 0
    D[s] += 1
    if mx < D[s]:
        mx = D[s]

for a in sorted([d for d in D if D[d] == mx]):
    print(a)

Solution (Python):
n = int(input())

result = {}
max = 0
for i in range(n):
    a = str(input())
    if not a in result:
        result[a] = 0
    result[a] += 1
    if max < result[a]:
        max = result[a]

result = sorted(result.items(), key=lambda x: (x[1], x[0]))
for val in result:
    if max == val[1]:
        print(val[0])

Solution (Python):
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop
from itertools import permutations, accumulate
from math import sqrt, ceil, floor, factorial
from bisect import bisect_left, bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
import sys
def I(): return int(input())  
def Is(): return map(int, input().split())  
def LI(): return list(map(int, input().split()))  
def TI(): return tuple(map(int, input().split()))  
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def TIR(n): return [TI() for _ in range(n)]
def S(): return input()
def Ss(): return input().split()  
def LS(): return list(input())  
def SR(n): return [S() for _ in range(n)]
def SsR(n): return [Ss() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
sys.setrecursionlimit(1000000)
MOD = 1000000007
INF = float('inf')

n = I()
s = SR(n)
sc = Counter(s)
most = sc.most_common()[0][1]
ans = []
for s, num in sc.most_common():
    if num == most:
        ans.append(s)
ans.sort()
for x in ans:
    print(x)

Solution (Python):


N = int(input().strip())
S_list = [input().strip() for _ in range(N)]


S_dic = {}

for s in S_list:
    S_dic.setdefault(s, 0)
    S_dic[s] += 1

S_dic_sorted = sorted(S_dic.items(), key = lambda x: x[1], reverse=True)
max_cnt_S = S_dic_sorted[0][1]
ans = []

for k,v in S_dic_sorted:
    if v == max_cnt_S:
        ans.append(k)

ans.sort()

for word in ans:
    print(word)

Solution (Python):
from collections import Counter

N = int(input())
S = []
for i in range(N):
    S.append(input())
S.sort()
c = Counter(S).most_common()
m = c[0][1]
c.sort()
for i in range(len(c)):
    if c[i][1] == m:
        print(c[i][0])

Solution (Python):
import collections

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

counter_ = collections.Counter(data)

max_ = max(list(counter_.values()))

ans = []
for c_name in counter_:
  if counter_[c_name] == max_:
    ans.append(c_name)

ans = sorted(ans)
for a in ans:
  print(a)

Solution (Python):
import collections

N = int(input())

A = [input() for i in range(N)]

sA = list(set(A))


c = collections.Counter(A)




count = [] 



for i in range(len(sA)):
    w = sA[i]
    count.append(c[w])
    
    


point = []

maX = max(count)



point2 = [i for i, x in enumerate(count) if x == maX]

ancer = [sA[point2[i]] for i in range(len(point2))]



ancerABC = sorted(ancer)

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

Solution (Python):
from collections import Counter
n = int(input())
lst = [(input()) for _ in range(n)]
c = Counter(lst)
d = c.most_common()
e = d[0][1]
lst_new = []
for f in c.keys():
    if c[f] == e:
        lst_new.append(f)
lst_new.sort()
for g in lst_new:
    print(g)

Solution (Python):
from collections import defaultdict

n = int(input())
dict1 = defaultdict(int)

for i in range(n):
    s = str(input())
    dict1[s] += 1

dict1 = sorted(dict1.items(), key=lambda x:x[1], reverse=True)
max = dict1[0][1]
ans = []
for i in range(len(dict1)):
    if dict1[i][1] == max:
        ans.append(dict1[i][0])
    else:
        break

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

Solution (Python):
N = int(input())
S = {}

for i in range(N):
    s = input()
    if s in S:
        S[s] += 1
    else:
        S[s] = 0

S = sorted(S.items(), key=lambda x: (-x[1], x[0]))
n = S[0][1]
for s in S:
    if s[1] != n:
        break
    print(s[0])

Solution (Python):
import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline
n = int(readline())
s = [readline().rstrip() for _ in range(n)]

import collections

c = collections.Counter(s)
c = c.most_common()

ans = [c[0][0]]
v_max = c[0][1]
for k,v in c[1:]:
    if v == v_max:
        ans.append(k)
ans.sort()

for a in ans:
    print(a)

Solution (Python):
n=int(input())
dic={}
maxx=1
for i in range(n):
  s=input()
  if s in dic:
    dic[s]+=1
  else:
    dic[s]=1
  if dic[s]>maxx:
    maxx=dic[s]
lis=[]
for i in range(len(dic)):
  kk=dic.popitem()
  if kk[1]==maxx:
    lis.append(kk[0])
lis.sort()
for i in range(0,len(lis)):
  print(lis[i])

Solution (Python):
import collections
n=int(input())
s=[]
for i in range(n):
    s.append(input())
c=collections.Counter(s).most_common()

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

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

Solution (Python):
n = int(input())
Ss = []
for i in range(n):
    s = input()
    Ss.append(s)

ssdict = {}
for i in range(n):
    if Ss[i] in ssdict:
        ssdict[Ss[i]] += 1
    else:
        ssdict[Ss[i]] = 0

cnt = 0
ans = []
for key in ssdict:
    if ssdict[key] > cnt:
        ans = []
        ans.append(key)
        cnt = ssdict[key]
    elif ssdict[key] == cnt:
        ans.append(key)
    else:
        continue

srt = sorted(ans)
for value in srt:
    print(value)

Solution (Python):
n = int(input())
dic = {}
for i in range(n):
    string = input()
    if string not in dic:
        dic[string] = 1
    else:
        dic[string] += 1

Mx = max(dic.values())
ans = []
for key in dic.keys():    
    if dic[key] == Mx:
        ans.append(key)
ans.sort()
for i in ans:
    print(i)