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):
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")

Solution (Python):
import collections

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

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

max_c = [c2[0][0]]


for i in range(len(c.values())-1):
    if c2[i][1] == c2[i+1][1]:
        max_c.append(c2[i+1][0])
    else :
        break

max_c= sorted(max_c)

for i in max_c:
    print(i)

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

Solution (Python):
import collections

N = int(input())
s_list = []
for i in range(N):
    s_list.append(input())
dict = collections.Counter(s_list)
max_num = 0
for i in dict.values():
    max_num = max(max_num,i)
top_vote = []
for i,j in dict.items():
    if j == max_num:
        top_vote.append(i)
top_vote.sort()
for i in top_vote:
    print(i)

Solution (Python):
import collections

n = int(input())
s = [input() for i in range(n)]
t = collections.Counter(s)
tm = t.most_common()
x = [tm[i][0] for i in range(len(tm)) if tm[i][1]==tm[0][1]]
x.sort()
for i in range(len(x)):
    print(x[i])

Solution (Python):
from collections import defaultdict

d = defaultdict(lambda: 0)
N = int(input())
max = 0
for _ in range(N):
    word = input()
    new_value = d[word] + 1
    if new_value > max:
        max = new_value
    d[word] = new_value

result = []
for key in d:
    if d[key] == max:
        result.append(key)

result.sort()
for a in result:
    print(a)

Solution (Python):
import collections

N = int(input())

chars = [input() for _ in range(N)]
char_counts = collections.Counter(chars)

max_count = max(char_counts.values())
max_count_chars = sorted([key for key, value in char_counts.items() if value == max_count])

for char in max_count_chars:
  print(char)

Solution (Python):

from collections import Counter

n = int(input())
s = [input() for i in range(n)]
c = Counter(s)
C = c.most_common()
a = C[0][1]
ans = []
for i in range(len(c)):
  if C[i][1] == a:
    ans.append(C[i][0])

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

Solution (Python):
n = int(input())
l = [input() for i in range(n)]
d={}

for i in range(len(l)):
    if l[i] in d:
        d[l[i]]+=1
    else:
        d[l[i]]=1

largest=max(d.values())
ans=[]
for key in d.keys():
    if d[key]==largest:
        ans.append(key)
ans=sorted(ans)
for word in ans:
    print(word)

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

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

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

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

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

Solution (Python):
def main():
    N=int(input())
    S=[input() for i in range(N)]
    
    dictionary={}
    for word in S:
        if word in dictionary:
            dictionary[word]+=1
            
        else:
            dictionary[word]=1
            
    maximum=max(dictionary.values())
    for key,value in sorted(dictionary.items()):
        if value==maximum:
            print(key)

if __name__ == "__main__":
    main()

Solution (Python):
N = int(input())
S = list(input() for i in range(N))  

A = {}
for i in S:
    A.setdefault(i, 1)
    A[i] += 1

B = max(A.values())
C = [i for i in A if A[i] == B]
C = sorted(C)

for i in C:
    print(i)

Solution (Python):
N = int(input())
S = [input() for i in range(N)]
dictionary = {}
for word in S:
    if word in dictionary:
        dictionary[word] += 1
    else:
        dictionary[word] = 1

maximum = max(dictionary.values())
for key, value in sorted(dictionary.items()):
    if value == maximum:
        print(key)

Solution (Python):
def solve():
    names = {}
    for si in s:
        if si in names:
            names[si]+=1
        else:
            names[si] = 1
    maxi = 0
    winners = []
    for n in names:
        maxi = max(maxi, names[n])
    for n in names:
        if names[n] == maxi:
            winners.append(n)
    winners.sort()
    for winner in winners:
        print(winner)
    return



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


solve()

Solution (Python):

import collections
n=int(input())
s=[]
for i in range(n):
    s.append(input())
c = collections.Counter(s)
count=max(c.values())
l=[]
for key, value in c.items():
    if value==count:
        l.append(key)
l.sort()
for x in l:
    print(x)

Solution (Python):
N = int(input())
a = [input()for i in range(N)]
p = []
a.sort()
q = 1
for i  in range(N-1):
    if a[i] == a[i+1]:
        q = q+1
    else:
        p.append([q,a[i]])
        q = 1
p.append([q,a[N-1]])
s = 0
for i in range(len(p)):
    s = max(s,p[i][0])
for i in range(len(p)):
    if p[i][0] == s:
        print(p[i][1])

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

m=0
ans=[]
for k,v in c:
  if v>=m:
    ans.append(k)
    m=v
ans.sort()
print(*ans,sep='\n')

Solution (Python):
n = int(input())
a = [input() for _ in range(n)]
dic = {}
for x in a:
    if x not in dic:
        dic[x] = 0
for x in a:
    dic[x] += 1
dic = sorted(dic.items(),reverse = True ,key = lambda x : x[1])
res = []
maxv = dic[0][1]
for i in range(len(dic)):
    if maxv == dic[i][1]:
        res.append(dic[i][0])
resN = sorted(res)
[print(x) for x in resN]

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

s_unique = list(set(s))

dic = {}
for u in s_unique:
    dic[u] = 0

for word in s:
    dic[word] += 1

max = max(dic.values())

l = []
for u in s_unique:
    l.append([dic[u], u])

l.sort(reverse=True)

l_ans = []
for a in l:
    if a[0] != max:
        continue
    l_ans.append(a[1])

l_ans.sort()

for ans in l_ans:
    print(ans)

Solution (Python):
N = int(input())
S = [str(input()) for i in range(N)]
dic = {}
for a in S:
    if a not in dic:
        dic[a] = 1
    else:
        dic[a] += 1
m = max(dic.values())
max_list = [kv[0] for kv in dic.items() if kv[1] == m]
max_list.sort()
for a in max_list:
    print(a)

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

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

max_count = 0
for i in range(N):
    max_count = max(max_count, word[L[i]])
    
ans = []
for i in range(N):
    if word[L[i]] == max_count:
        ans.append(L[i])
  
ans = list(set(ans))
ans.sort()

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

Solution (Python):


import collections

N = int(input())
S = [input() for i in range(N)]
S_count = collections.Counter(S)
S_most = S_count.most_common()
a, b = S_most[0]
ans = []

for i, j in S_most:
    if j == b:
        ans.append(i)
for i in sorted(ans):
    print(i)

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

max_val = max(D.values())
D = sorted(D.items(),key=lambda x:(-x[1],x[0]))
for key,val in D:
    if val==max_val:
        print(key)
    else:
        exit()

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

Solution (Python):
N=int(input())
S=[input() for i in range(N)]
dictionary={}
for word in S:
    if word in dictionary:
        dictionary[word]+=1
    else:
        dictionary[word]=1
maximum=max(dictionary.values())
for key,value in sorted(dictionary.items()):
    if value==maximum:
        print(key)

Solution (Python):

import collections
N = int(input())
S = [input() for i in range(N)]
s = collections.Counter(S) 

maximum = max(s.values()) 
list = sorted(key for key,value in s.items() if value==maximum)


for i in list:
    print(i)

Solution (Python):

import collections
N = int(input())
S = [input() for i in range(N)]
s = collections.Counter(S) 

maximum = max(s.values()) 
list = sorted(key for key,value in s.items() if value==maximum)


for i in list:
    print(i)

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

count = 0
words_dict = {}
top_words = []

for i in range(N):
    word = input()

    if word in words_dict:
        words_dict[word] += 1
    else:
        words_dict[word] = 1

    if words_dict[word] == count:
        top_words.append(word)
    if words_dict[word] > count:
        top_words = [word]
        count += 1

for word in sorted(top_words):
    print(word)

Solution (Python):
import collections

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



a = collections.Counter(s)


max_a = max(a.values())



keys = [k for k, v in a.items() if v == max_a]
keys.sort()

for word in keys:
    print(word)

Solution (Python):
import collections

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



a = collections.Counter(s)


max_a = max(a.values())



keys = [k for k, v in a.items() if v == max_a]
keys.sort()

[print(word) for word in keys]

Solution (Python):
n,*s=open(0).read().split()
l=[]
for i,t in enumerate(sorted(s)):
  if i==0: 
    b=t
    c=1
    continue
  if t==b: 
    c+=1
    if i==int(n)-1:
      l+=[[c,t]]
  else: 
    l+=[[c,b]]
    if i==int(n)-1:
      l+=[[c,t]]
    b=t
    c=1
l=sorted(l,key=lambda x:x[0],reverse=True)
m=l[0][0]
for c,s in l:
  if c!=m:break
  print(s)

Solution (Python):
import collections
n =int(input())
s =[input() for i in range(n)]
counter =collections.Counter(s)
s_max =max(counter.values())
for j in sorted(counter):
    if counter[j] ==s_max:
        print(j)

Solution (Python):
import collections
n = int(input())
s = [input() for i in range(n)]
counter = collections.Counter(s)
m = max(counter.values())
for j in sorted(counter):
    if counter[j] == m:
        print(j)

Solution (Python):
import collections
n = int(input())
s = [input() for _ in range(n)]
counter = collections.Counter(s)
m = max(counter.values())
for v in sorted(counter):
    if counter[v] == m:
        print(v)

Solution (Python):
from collections import Counter

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

c = Counter(S).most_common()
num = c[0][1]
v_l = []
for v ,s in c:
    if s == num:
        v_l.append(v)

print(*sorted(v_l))

Solution (Python):
from collections import defaultdict
table=defaultdict(int)
n=int(input())
m=0
for i in range(n):
    word =input()
    table[word]+=1
    if table[word]<m:
        pass
    else:
        m=table[word]
rtable=[]
for i in table.keys():
    if table[i]==m:
        rtable.append(i)

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

Solution (Python):
N = int(input())
S = [input() for _ in range(N)]
import collections
c = collections.Counter(S)
A = sorted(c.items(), key=lambda x: x[1], reverse=True)
count = 0
B = []
for a, b in A:
    if b >= count:
        B.append(a)
        count = b
    else:
        break

C = sorted(B)
for a in C:
    print(a)

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

c = collections.Counter(S)
a = max(c.values())
l = []
for k, v in c.items():
    if v == a:
        l.append(k)
l.sort()
for c in l:
    print(c)

Solution (Python):

from collections import Counter

def main():
    *I, = map(str, open(0).read().split())
    N = I[0]
    N = I[1:]
    
    cnt = Counter(N)
    m = max(cnt.values())

    for val in sorted(ele for ele, val in cnt.items() if val == m):
	    print(val)



main()

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

count = Counter(S)
maxnum = max(count.values())
maxlist= [i for i,j in count.items() if j==maxnum]

maxlist.sort()

for m in maxlist:
	print(m)

Solution (Python):
def main():
  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)
    
if __name__ == '__main__':
    main()

Solution (Python):
N = int(input())
ss = []
for _ in range(N): ss.append(input())

from collections import Counter

ctr = Counter(ss)
counted = ctr.most_common()

ans = []
for i in range(len(counted)):
    tup = counted[i]
    if i == 0:
        ans.append(tup[0])
        continue
    if counted[i][1] != counted[i - 1][1]:
        break
    ans.append(tup[0])

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

Solution (Python):
from collections import Counter

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

c = Counter(s)
tmp = c.most_common()
ans = []

for i in range(len(tmp)):
    if tmp[i][1] != tmp[0][1]:
        break
    else:
        ans.append(tmp[i][0])

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

Solution (Python):
n = int(input())
d = {}
for i in range(n):
  s = input()
  if s in d:
    d[s] += 1
  else:
    d[s] = 1
max_d = max(d.values())
d = sorted(d.items(), key = lambda x : x[0])
for i in range(len(d)):
  if d[i][1] == max_d:
    print(d[i][0])

Solution (Python):
n = int(input())
d = {}
for _ in range(n):
    s = input()
    if s in d:
        d[s] += 1
    else:
        d[s] = 0
        
m = max(d.values())
ans = []
for t in d:
    if d[t] == m:
        ans.append(t)
ans.sort()
for u in ans:
    print(u)

Solution (Python):
from collections import Counter
n = int(input())
word = Counter([input() for i in range(n)]).most_common()
print('\n'.join(sorted([num[0] for num in word if int(num[1]) == word[0][1]])))

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

for i in range(n-1):
    if s[i] == s[i+1]:
        c[i+1] += c[i]
m = max(c)

for i in range(n):
    if c[i] == m:
        print(s[i])

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

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

s_dic = Counter(s_inputs)
s_max = max(s_dic.values())
print('\n'.join(sorted([k for k,v in s_dic.items() if v==s_max])))

Solution (Python):
from collections import Counter
n = int(input())
s = [input() for _ in range(n)]
c = Counter(s).most_common()
mx = c[0][1]
ans = []
for x, cnt in c:
    if cnt == mx: ans.append(x)
ans.sort()
print(*ans, sep="\n")

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

b = list(set(a))
b.sort()
most_n = max(t.values())
for i in b:
    if t[i] == most_n:
        print(i)

Solution (Python):
from collections import Counter

n=int(input())
s=[input() for i in range(n)]
a=Counter(s)
b=a.most_common()
c=list(a.values())
d=max(c)
e=[]

for i in range(len(b)):
    if b[i][1]==d:
        e.append(b[i][0])

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

Solution (Python):
from collections import Counter
a=open(0)
n=int(a.readline())
l=a.read().split()
c=Counter(l)
d=max(c.values())
max_list=[k for k,v in c.items() if v==d]
max_list.sort()
print(*max_list,sep="\n")

Solution (Python):
from collections import Counter

n=int(input())
l=[input() for i in range(n)]
c=Counter(l)
d=max(c.values())
max_list=[k for k,v in c.items() if v==d]
max_list.sort()
print(*max_list,sep="\n")

Solution (Python):
from collections import Counter

n=int(input())
l=[input() for i in range(n)]
c=Counter(l)
d=max(c.values())
max_list=[k for k,v in c.items() if v==d]
max_list.sort()
for j in max_list:
  print(j)

Solution (Python):
from collections import Counter
a=open(0)
n=int(a.readline())
l=a.read().split()
c=Counter(l)
d=max(c.values())
max_list=[k for k,v in c.items() if v==d]
max_list.sort()
print(*max_list,sep="\n")

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)]
d = {}
for w in s:
    if w not in d:
        d[w] = 0
    d[w] += 1
d2 = sorted(d.items(), key=lambda x:x[1], reverse=True)
maxcnts = [w[0] for w in d2 if w[1] == d2[0][1]]
maxcnts.sort()
for ans in maxcnts:
    print(ans)

Solution (Python):

url = "https://atcoder.jp//contests/abc155/tasks/abc155_c"

def main():
    n = int(input())
    words = [input() for i in range(n)]

    words_count = {}
    for w in words:
        words_count.setdefault(w, 0)
        words_count[w] += 1
    ans = ''
    count = 0
    for w in words_count:
        count = words_count[w] if words_count[w] > count else count
    ans = []
    for w in words_count:
        if words_count[w] == count:
            ans.append(w)
    ans = sorted(ans)
    for w in ans:
        print(w)




if __name__ == '__main__':
    main()

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

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

m = max(d.values())

li = []
for i in d:
    if d[i] == m:
       li.append(i)
li.sort()
for j in li:
    print(j)

Solution (Python):
from collections import defaultdict
def main():
    N = int(input())
    vote = defaultdict(int)
    for i in range(N):
        vote[input()] += 1
    max_vote = max(vote.values())
    new_vote = sorted(list(vote.items()), key= lambda x : x[0])
    new_vote = sorted(new_vote, key= lambda x : x[1], reverse = True)
    for k, v in new_vote:
        if v == max_vote:
            print(k)
        else:
            break
if __name__ == "__main__":
    main()

Solution (Python):



import sys


def main():
    N = int(input())
    mp = {}
    mx = 0
    for i in range(N):
        s = input()
        if s in mp:
            mp[s] += 1
            mx = max(mx, mp[s])
        else:
            mp[s] = 0
    ret = []
    for s, c in mp.items():
        if c == mx:
            ret.append(s)
    ret.sort()
    print('\n'.join(ret))

if __name__ == '__main__':
    main()

Solution (Python):
def main():
    n = int(input())
    words = [input() for i in range(n)]

    words_count = {}
    for w in words:
        words_count.setdefault(w, 0)
        words_count[w] += 1
    ans = ''
    count = 0
    for w in words_count:
        count = words_count[w] if words_count[w] > count else count
    ans = []
    for w in words_count:
        if words_count[w] == count:
            ans.append(w)
    ans = sorted(ans)
    for w in ans:
        print(w)




if __name__ == '__main__':
    main()

Solution (Python):
from collections import defaultdict

N = int(input())
S_dic = defaultdict(int)

for i in range(N):
  S = input()
  S_dic[S] += 1

m = max(S_dic.values())
max_S = [i[0] for i in S_dic.items() if i[1] == m ]
max_S.sort()
print("\n".join(max_S))

Solution (Python):
n = int(input())
s_dict = {}
for i in range(n):
    s = input()
    if s in s_dict.keys():
        s_dict[s] += 1
    else:
        s_dict[s] = 1

max_count = max(s_dict.values())
answer_list = []
for k, v in s_dict.items():
    if v == max_count:
        answer_list.append(k)

for answer in sorted(answer_list):
    print(answer)

Solution (Python):
n = int(input())
s = [0]*n
c = [1]*n

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

s.sort()    
    
for i in range(n-1): 
	if s[i] == s[i+1]:
		c[i+1] += c[i]
      
M = max(c)

for i in range(n):
	if c[i] == M:
		print(s[i])

Solution (Python):
import collections 
n = int(input())
s = [input() for i in range(n)]
words = list(collections.Counter(s).most_common())
S = []
i = 0
maxcount = words[0][1]
for word in words:
    if word[1] != maxcount:
        break
    S.append(word[0])
S.sort()
for s_word in S:
    print(s_word)

Solution (Python):
n = int(input())
s = [0]*n
c = [1]*n
A = [0]*n
k = 0

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

s.sort()    
    
for i in range(n-1): 
	if s[i] == s[i+1]:
		c[i+1] += c[i]
      
M = max(c)

for i in range(n):
	if c[i] == M:
		print(s[i])

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

m = max(D.values())
ans=[]
for key in D:
	if D[key]==m:
		ans.append(key)

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

Solution (Python):
n = int(input())
cnt = {}
for _ in range(n):
    s = input()
    if not s in cnt:
        cnt[s] = 1
    else:
        cnt[s] = cnt[s] + 1

maxv = max(cnt.values())
ans = []
for x, c in cnt.items():
    if c == maxv: ans.append(x)
ans.sort()
for x in ans:
    print(x)

Solution (Python):
from collections import defaultdict


def main():
    d = defaultdict(int)
    N = int(input())
    for _ in range(N):
        d[input()] += 1
    freq, words = 0, set()
    for key in d.keys():
        if freq < d[key]:
            words = {key}
            freq = d[key]
        if freq == d[key]:
            words.add(key)
    print('\n'.join(sorted(words)))


if __name__ == '__main__':
    main()

Solution (Python):
import collections
n=int(input())
s=[input() for _ in range(n)]
c=collections.Counter(s)
l=c.most_common()
k=l[0][1]
l1=[]
for i in range(len(l)):
    if l[i][1]==k:l1.append(l[i][0])
    else:break
l1.sort()
for i in range(len(l1)):
    print(l1[i])

Solution (Python):
from collections import defaultdict
N = int(input())
li = []
d = defaultdict(int)
for i in range(N):
  s = input()
  d[s] += 1
e = max(d, key=d.get)
li.append(e)
n = d.pop(e)
tmp = [k for k, v in d.items() if v == n]
li += tmp
li.sort()
print('\n'.join(li))

Solution (Python):
import collections
import itertools

n = int(input())
word = [input() for i in range(n)]
counter = collections.Counter(word)
rank_word = counter.most_common()
most_common = rank_word[0][1]
most_common_lst = [i[0] for i in rank_word if i[1] == most_common]
lst = sorted(most_common_lst)
for i in lst:
    print(i)

Solution (Python):
import collections
n = int(input())
s = [str(input()) for _ in range(n)]
c = collections.Counter(s)
values, counts = zip(*c.most_common())

ans = [values[0]]
count = counts[0]
for i in range(1,len(c)):
    if counts[i] == count:
        ans.append(values[i])
    else:
        break
ans.sort()
for a in ans:
    print(a)

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

num = max(words.values())
max_k_list = [kv[0] for kv in words.items() if kv[1] == num]
max_k_list.sort()
print('\n'.join(max_k_list))

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

max_num = max(words.values())
max_name_list = [word[0] for word in words.items() if word[1] == max_num]

max_name_list = sorted(max_name_list)

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

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

S_dict = {}
for i in range(N):
  S = str(input())
  S_dict[S] = S_dict.get(S,0) + 1

S_dict_sorted = sorted(S_dict.items(), key=lambda x:x[1],reverse=True)
ans_list = []

max_num = S_dict_sorted[0][1]
for i in range(len(S_dict_sorted)):
  if max_num == S_dict_sorted[i][1]:
    ans_list.append(S_dict_sorted[i][0])
  else:
    break

ans_list = sorted(ans_list)

for ans in ans_list:
  print(ans)

Solution (Python):
n = int(input())
S = []
A = {}
for i in range(n):
  S.append(input())
for i in range(n):
  A[S[i]] = A.get(S[i])+1 if A.get(S[i]) != None else 1
A = sorted(A.items(), key=lambda x:x[1], reverse=True)
maxNum = A[0][1]
ans = []
for i in range(len(A)):
  if A[i][1] == maxNum:
    ans.append(A[i][0])
ans.sort()
for a in ans:
  print(a)

Solution (Python):
from collections import Counter
N = int(input())
data = [0] * N


for i in range(0, N):
    data[i] = input()

count = Counter(data)


most = count.most_common()
mostNum = most[0][1]
'''
print(count)    
print(most)     
print(mostNum)  
'''
most.sort()

for i in most:
    if (i[1] == mostNum):
        print(i[0])

Solution (Python):
from collections import Counter
N=int(input())
a = [input() for i in range(N)]
c=Counter(a)
d=c.most_common()
e=[]

e.append(d[0][0])

for j in range(len(d)-1):
  if d[0][1]==d[j+1][1]:
    e.append(d[j+1][0])
f=sorted(e)
for i in range(len(f)):
  print(f[i])

Solution (Python):
from collections import Counter
N = int(input())

counter = Counter()
for i in range(N):
    s = input()
    counter[s] += 1


lst = list(counter.most_common())
max_num = lst[0][1]

for l in sorted(lst):
    if l[1] == max_num:
        print(l[0])

Solution (Python):
import collections

words = []
n = int(input())
for i in range(n):
    words.append(input())
c = collections.Counter(words)
l = c.most_common()
ans = []
maxi = l[0][1]
for pair in l:
    if pair[1] == maxi:
        ans.append(pair[0])
ans = sorted(ans)
for i in ans:
    print(i)

Solution (Python):
import collections
N = int(input())
S = [input() for _ in range(N)]
st = []
strings = dict(collections.Counter(S))
strings_sorted = sorted(strings.items(), key = lambda x:x[1], reverse=True)
max_num = strings_sorted[0][1]
for i in range(len(strings_sorted)):
    if strings_sorted[i][1] == max_num:
        st.append(strings_sorted[i][0])
st.sort()
for item in st:
    print(item)

Solution (Python):
from collections import Counter

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

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


c = Counter(s_list)
l = c.most_common()    
count = l[0][1]
l.sort()
for i in l:
    if count == i[1]:
        print(i[0])

Solution (Python):
from collections import Counter

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

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

s_list.sort()
c = Counter(s_list)
l = c.most_common()    
count = l[0][1]
l.sort()
for i in l:
    if count == i[1]:
        print(i[0])

Solution (Python):
import collections
n=int(input())
s=list(input() for _ in range(n))
s1=collections.Counter(s)
count=list(s1.values()).count(max(s1.values()))
values, counts = zip(*s1.most_common(count))
ans=list(values)
ans.sort()
print('\n'.join(ans))

Solution (Python):
import collections
n=int(input())
s=list(input() for _ in range(n))

s1=collections.Counter(s)
s2=max(s1.values()) 
count=list(s1.values()).count(s2)
values, counts = zip(*s1.most_common(count))
ans=list(values)
ans.sort()
print('\n'.join(ans))

Solution (Python):
import collections
n = int(input())
words = []
[words.append(input()) for i in range(n)]
c = collections.Counter(words)
cc = c.most_common()
max_w = []
for i in cc:
  if i[1]==cc[0][1]:
    max_w.append(i[0])
max_w.sort()
[print(j) for j in max_w]

Solution (Python):
N=int(input())
d=dict()
for i in range(N):
    s=input()
    if s in d:
        d[s]+=1
    else:
        d[s]=1
max_value=max(d.values())
list_dic=[]
for key,value in d.items():
    if value==max_value:
        list_dic.append(key)
list_dic.sort()
for i in list_dic:
    print(i)

Solution (Python):
N = int(input())
ret = {}
for i in range(N):
    word = input()
    if word not in ret:
        ret[word] = 0
    else:
        ret[word] += 1
max_value = max(ret.values())
max_keys = [key[0] for key in ret.items() if key[1]==max_value]
max_keys = sorted(max_keys)
for key in max_keys:
    print(key)

Solution (Python):




N = int( input() )
S = list()
for ii in range(N):
    S.append( input() )


from collections import Counter
 
C       = Counter( S )
max_cnt = max(C.values())

words = list()
for word, cnt in C.items():
    if cnt == max_cnt:
        words.append(word)
words.sort()

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

Solution (Python):
from collections import deque, Counter as cnt
from collections import defaultdict as dd
from operator import itemgetter as ig
from bisect import bisect_right as bsr
from math import factorial, ceil, floor
import sys
sys.setrecursionlimit(1000000)


args = None
INF = float("inf")
MOD = int(1e9 + 7)


def input(*ps):
    if type(ps[0]) is list:
        return [input(*ps[0][:-1]) for _ in range(ps[0][-1])]
    elif len(ps) == 1:
        return ps[0](next(args))
    else:
        return [p(next(args)) for p in ps]


def nlist(n, v):
    if not n:
        return [] if type(v) is list else v
    return [nlist(n[1:], v) for _ in range(n[0])]


def yesno(v, yes="Yes", no="No"):
    print([yes, no][not v])


def main():
    """エントリーポイント"""
    N = input(int)
    S = input([str, N])
    count = dd(int)
    max_ = [0, {}]
    for s in S:
        count[s] += 1
        if max_[0] == count[s]:
            max_[1] |= {s}
        elif max_[0] < count[s]:
            max_[0] = count[s]
            max_[1] = {s}
    for ans in sorted(max_[1]):
        print(ans)


if __name__ == '__main__':
    args = iter(sys.stdin.read().split())
    main()

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

ss = collections.Counter(si)
n_ma = max(ss.values())
ans = []
for i in ss.keys():
    if ss[i] == n_ma:
        ans.append(i)
ans.sort()
for i in range(len(ans)):
    print(ans[i])

Solution (Python):
n=int(input())
s=[input() for i in range(n)]
s.sort()
dic=[0]*n
for i in range(n-1):
  if s[i]==s[i+1]:
    dic[i+1]=dic[i+1]+dic[i]+1
max=max(dic)
for i in range(n):
  if dic[i]==max:
    print(s[i])

Solution (Python):

def inputlist(): return [int(k) for k in input().split()]

N = int(input())
s = [0]*N
for i in range(N):
    s[i] = input()
from collections import Counter
c = Counter(s)
li = []
m = max(list(c.values()))
for i in list(c.keys()):
    if c[i] == m:
        li.append(i)
li.sort()
for i in range(len(li)):
    print(li[i])

Solution (Python):
n=int(input())
s=[input() for _ in range(n)]
dic={}
for i in range(n):
  if s[i] not in dic:
    dic[s[i]]=1
  else:
    dic[s[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):
n = int(input())
d = {}
for _ in range(n):
    s = input()
    if s in d:
        d[s] += 1
    else:
        d[s] = 1

m = max(d.values())
for i in sorted(k for k in d if d[k] == m):
    print(i)