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



Sample input:
7
beat
vet
beet
bed
vet
bet
beet


Sample output:
beet
vet

Submission status: Accepted

Solution code:
N = int(input())
d = {}
for _ in range(N):
  s = input()
  if(s not in d):
    d[s] = 1
  else:
    d[s] += 1
d2 = sorted(d.items(),key=lambda x:x[1], reverse=True)
s1=[]
s1.append(d2[0][0])
p=d2[0][1]
for t in d2[1:]:
  q=t[1]
  if(q==p):
    s1.append(t[0])
  else:
    break
s1=sorted(s1)
for i in s1:
  print(i)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import collections 

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

b=collections.Counter(a) 
mx=max(b.values())
ans=[]

for word,counts in b.items():
    if counts==mx:
        ans.append(word)
        
ans=sorted(ans)
for i in ans:
    print(i)

Submission status: Accepted

Solution code:
N = int(input())
d = {}
for i in range(N):
  s = input()
  if s not in d.keys():
    d[s] = 1
  else:
    d[s] += 1
a = max(d.values())
d = sorted(d.items(), key=lambda x: x[1])
l = []
for i, j in d:
  if j == a:
    l.append(i)
l = sorted(l)
for i in range(len(l)):
  print(l[i])

Submission status: Accepted

Solution code:
import collections

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

c = collections.Counter(S)

ans = c.most_common()[0][1]

a=sorted([i[0] for i in c.items() if i[1] == ans])
            
for i in a:
    print(i)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys
from collections import defaultdict

def main():
    N = int(input())
    S = defaultdict(int)
    for _ in range(N):
        S[input()] += 1
    S = sorted(S.items(), key=lambda x:x[1])

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

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

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
from collections import Counter
n = int(input())

s = Counter([input() for _ in range(n)])
mx = max(s.values())
ans = []
for k,v in s.items():
    if v==mx:
        ans.append(k)
for i in sorted(ans):
    print(i)

Submission status: Accepted

Solution code:
from collections import Counter
n = int(input())

s = Counter([input() for _ in range(n)])
mx = max(s.values())

for k in sorted(x for x,y in s.items() if y == mx) :
    print(k)

Submission status: Accepted

Solution code:
from collections import Counter
C=Counter()
for _ in range(int(input())):
  C[input()]+=1
m=max(C.values())
ans=[]
for key,val in C.items():
  if val==m:
    ans.append(key)
ans.sort()
print(*ans)

Submission status: Accepted

Solution code:
import collections

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

c = collections.Counter(polls)
maxval = c.most_common()[0][1]

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

ans = []

for i in c.most_common():
    if i[1] == maxval:
        ans.append(i[0])
    else:
        break

ans.sort()

for i in ans:
    print(i)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import Counter
N = int(input())
S = Counter(input() for _ in range(N))
m = max(S.values())
for v in sorted(k for k, v in S.items() if v == m):
	print(v)

Submission status: Accepted

Solution code:
n=int(input())
list_ = [input() for i in range(n)]
dic = {}
for a in list_:
    if a in dic:
        dic[a] += 1
    else:
        dic[a]   = 1
maxa = max(dic.values())
ans = [x for x, y in dic.items() if y == maxa]
for A in sorted(ans):
    print(A)

Submission status: Accepted

Solution code:
n = int(input())
dic ={}
for i in range(n):
    key = input()
    if key not in dic:
        dic[key] = 1
    if key in dic:
        dic[key] += 1
max_v = max(dic.values())
res = sorted(list(filter(lambda key:dic[key]==max_v,list(dic))))
for key in res:
    print(key)

Submission status: Accepted

Solution code:
def readints():
    return list(map(int, input().split()))


n = int(input())
s = [input() for i in range(n)]
# print(s)
s.sort()
# print(s)
L = []
M = -1
i = 0
while i < n:
    j = i
    while j < n and s[i] == s[j]:
        j += 1
    l = j-i
    L.append(l)
    i = j
for i in L:
    if i > M:
        M = i
#print(M, L)
index = 0
for i in L:
    # print(index)
    if i == M:
        print(s[index])
    index += i

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def LS(): return list(map(list, input().split()))
def S(): return input().rstrip()
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#solve
def solve():
    n = II()
    s = SR(n)
    d = defaultdict(int)
    for si in s:
        d[si] += 1
    item = list(d.items())
    item.sort(key=lambda x: x[1], reverse=True)
    m = item[0][1]
    ans = []
    for i, v in item:
        if v == m:
            ans.append(i)
        else:
            break
    ans.sort()
    print("\n".join(ans))
    return


#main
if __name__ == '__main__':
    solve()

Submission status: Accepted

Solution code:
import numpy as np
from collections import Counter

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

counter = Counter(S)
m = max(counter.values())

most_common_let = [i for i in counter.keys() if counter[i] == m]
sorted_list = sorted(most_common_let)
for i in sorted_list:
    print(i)

Submission status: Accepted

Solution code:
N = int(input())

dict = {}
L = []

for i in range(N):
  s = input()
  if s in dict:
    dict[s] = dict[s] + 1
  else:
    dict[s]=1
    L.append(s)

L.sort()

M = 0
for i in dict:
  M = max(M, dict[i])

for i in L:
  if dict[i] == M:
    print(i)

Submission status: Accepted

Solution code:
N=int(input())
d={}
for _ in range(N):
    x=input()
    if x in d.keys():
        d[x]+=1
    else:
        d.update({x:1})
        
s=max(d.values())
moji=[]
for i in d.items():
    if i[1]==s:
        moji.append(i[0])
for i in sorted(moji):
    print(i)

Submission status: Accepted

Solution code:
from collections import Counter

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

c = Counter(s)
c2 = c.most_common()
m = c2[0][1]#最大値
ans = [i[0] for i in c2 if i[1] == m]#回数が最大となるもの
ans.sort()
print(*ans)

Submission status: Accepted

Solution code:
from collections import Counter

n = int(input())

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

count = Counter(a)
most = count.most_common()
tmp = []
mostidx = most[0][1]
for ss, ii in most:
    if ii == mostidx:
        tmp.append(ss)
tmp.sort()
for t in tmp:
    print(t)

Submission status: Accepted

Solution code:
dict = {}
for i in range(int(input())):
    a = input()
    if dict.get(a):
        dict[a] += 1
    else:
        dict[a] = 1

max_v = max(dict.values())


ans = [key for key, value in dict.items() if value == max_v]
ans.sort()
for i in ans:
    print(i)

Submission status: Accepted

Solution code:
from collections import Counter
 
N = int(input())
A = [input() for i in range(N)]
 
c = Counter(A).most_common()
k, v = zip(*c)
 
[print(s) for s in sorted(k[:v.count(v[0])])]

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import collections as cl
import sys
input = sys.stdin.readline

N = int(input().strip())
S_list = [input().strip() for _ in range(N)]
# print(S_list)
c = cl.Counter(S_list)
# print(c)
max_num = max(c.values())

max_list = sorted([kv[0] for kv in c.items() if kv[1] == max_num])
print(*max_list)

Submission status: Accepted

Solution code:
N=int(input())
S=[input() for i in range(N)]
D=dict()
k=0
for i in range(N):
    if S[i] in D:
        D[S[i]]+=1
    else:
        D[S[i]]=1
    k=max(D[S[i]],k)
X=[]
for i in D:
    if D[i]==k:
        X.append(i)
for line in sorted(X):
    print(line)
#私はdictのmaxの仕様を勘違いしてしまいました。

Submission status: Accepted

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

ans = {}
for i in S:
  if i in ans:
    ans[i] += 1
  else:
    ans[i] = 1

max_value = max(ans.values())
ANS = []
for key, value in ans.items():
  if ans[key] == max_value:
    ANS.append(key)
    
for i in sorted(ANS):
  print(i)

Submission status: Accepted

Solution code:
n = int(input())
words = {}
for _ in range(n):
    word = input()
    if word in words:
        words[word] += 1
    else:
        words[word] = 1

words_sorted = sorted(words.items(), key=lambda x: x[1], reverse=True)
max_keys = [words_sorted[0][0]]
init = words_sorted[0][1]
for word in words_sorted[1:]:
    if word[1] == init:
        max_keys.append(word[0])
    else:
        break
max_keys.sort()
for i in max_keys:
    print(i)

Submission status: Accepted

Solution code:
import sys
readline = sys.stdin.readline
from collections import Counter
N = int(readline())
C = Counter()

for _ in range(N):
    S = readline().strip()
    C[S] += 1

ma = max(C.values())
K = [k for k, v in C.items() if v == ma]
K.sort()
print('\n'.join(K))

Submission status: Accepted

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

ans = {}
for i in S:
    if i in ans:
        ans[i] += 1
    else:
        ans[i] = 1

max_v = max(ans.values())        
ANS = []
for key, value in ans.items():
    if ans[key] == max_v:
        ANS.append(key)

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

Submission status: Accepted

Solution code:
n = int(input())
s = []

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

word_buf = {}

for i in s:
    if i in word_buf.keys():
        word_buf[i] += 1
    else:
        word_buf[i] = 1

max_cnt = max(word_buf.values())
max_word = [i[0] for i in word_buf.items() if i[1] == max_cnt]
max_word.sort()

for i in max_word:
    print(i)

Submission status: Accepted

Solution code:
from collections import Counter

n = int(input())

cnt = []
for i in range(n):
    cnt.append(input())
    
cnt = Counter(cnt)

tmp = cnt.most_common()

ans = [name for name,cnt in tmp if cnt==tmp[0][1]]

ans = sorted(ans)

for a in ans:
    print(a)

Submission status: Accepted

Solution code:
# ABC155 C

n = int(input())
S = {}
max_S = 0
res = []

for _ in range(n):
    s = input()
    if s in S:
        S[s] += 1
        if S[s] > max_S:
            max_S = S[s]
    else:
        S[s] = 1
        if S[s] > max_S:
            max_S = S[s]

for key in S:
    if S[key] == max_S:
        res.append(key)

for _ in sorted(res):
    print(_)

Submission status: Accepted

Solution code:
n = int(input())
sd = {}

for _ in range(n):
  s=input()
  if s in sd:
    sd[s]+=1
  else:
    sd[s] =1
m=max(sd.values())
ans=[]
for i in sd:
  if sd[i]==m:
    ans.append(i)
ans.sort()
for i in ans:
  print(i)

Submission status: Accepted

Solution code:
N = int(input())
dic = {}
for i in range(N):
  s = input()
  if s in dic:
    dic[s] += 1
  else:
    dic[s] = 1
m = 0
for v in dic.values():
  if v > m:
    m = v
l = []
for k, v in dic.items():
  if v == m:
    l.append(k)
l.sort()
for ans in l:
  print(ans)

Submission status: Accepted

Solution code:
import collections
n = int(input())
s = []
for _ in range(n):
    s.append(input())

c = collections.Counter(s)
ma = max(c.items(), key=lambda x: x[1])[1]
ans = []
for _s, cnt in c.items():
    if ma == cnt:
        ans.append(_s)

for _ans in sorted(ans):
    print(_ans)

Submission status: Accepted

Solution code:
#abc155c
from collections import Counter

n=int(input())
s=[]
for i in range(n):
 s.append(input())
c=Counter(s)
mc=c.most_common()
s=[]
ref=mc[0][1]
i=0
while i<len(c):
 if mc[i][1]==ref:
  s.append(mc[i][0])
 i+=1
s.sort()
for i in range(len(s)):
 print(s[i])

Submission status: Accepted

Solution code:
import collections

n = int(input())
s = []
for i in range(n):
  s.append(input())
count = list(collections.Counter(s).items())
count = sorted(count, key=lambda x: x[1], reverse=True)
result = sorted([i for i in count if i[1] == count[0][1]], key=lambda x:x[0])

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

Submission status: Accepted

Solution code:
#import pysnooper
#import numpy
#import os,re,sys,operator
from collections import Counter,deque
#from operator import itemgetter,mul
#from itertools import accumulate,combinations,groupby,combinations_with_replacement,permutations
from sys import stdin,setrecursionlimit
#from bisect import bisect_left,bisect_right
#from copy import deepcopy
#import heapq
#import math
#import string
#from time import time
#from functools import lru_cache,reduce
#from math import factorial,hypot
#import sys
#from fractions import gcd
setrecursionlimit(10**6)
input=stdin.readline

def main():
    n=int(input().rstrip())
    d=dict()
    for _ in range(n):
        s=input().rstrip()
        if s not in d: d[s]=1
        else: d[s]+=1
    ans=Counter(d).most_common()
    ans.sort(key=lambda x: (-x[1],x[0]))
    ma=ans[0][1]
    for i in ans:
        if i[1]!=ma: break
        print(i[0])

if __name__=="__main__":
    main()

Submission status: Accepted

Solution code:
N = int(input())

S = []

for _ in range(N):
	s = input()
	S.append(s)

S.sort()

A = [1]

for i in range(N):
	if i == 0:
		continue
	else:
		if S[i] == S[i-1]:
			A.append(A[i-1] + 1)
		else:
			A.append(1)

M = 0

for i in range(N):
	if A[i] > M:
		M = A[i]

for i in range(N):
	if A[i] == M:
		print(S[i])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
S_dic = {}
for i in range(N):
    S = input()
    if S in S_dic:
        S_dic[S] += 1
    else:
        S_dic[S] = 1
max_v = max(S_dic.values())
ans_list = [key for key, val in S_dic.items() if val == max_v]
ans_list.sort()
print("\n".join(ans_list))

Submission status: Accepted

Solution code:
N = int(input())
S = [input() for _ in range(N)]
dic = {}
for s in S:
    if(s not in dic):
        dic[s] = 1
    else:
        dic[s] += 1

max_d = max(dic.values())
ans = []
for k in dic:
    if(dic[k]==max_d):
        ans.append(k)

ans.sort()

for a in ans:
    print(a)

Submission status: Accepted

Solution code:
n = int(input())
words = {}

for i in range(n) :
    new_word = input()
    if new_word in words.keys() :
        words[new_word] += 1
    else :
        words[new_word] = 1

mx_freq = max(words.values())
mx_words = [k for k in words.keys() if words[k] == mx_freq]

mx_words.sort()

for mx_word in mx_words :
    print(mx_word)

Submission status: Accepted

Solution code:
n = int(input())
words = {}

for i in range(n) :
    new_word = input()
    if new_word in words.keys() :
        words[new_word] += 1
    else :
        words[new_word] = 1

mx_freq = max(words.values())
mx_words = [k for k, v in words.items() if words[k] == mx_freq]

mx_words.sort()

for mx_word in mx_words :
    print(mx_word)

Submission status: Accepted

Solution code:
from collections import Counter

N=int(input())
c=Counter([input() for _ in range(N)])
ans=[]
_max_values=max(list(c.values()))
for i in c:
    if c[i]==_max_values:
        ans.append(i)
ans=sorted(set(ans))
for i in ans:
    print(i)

Submission status: Accepted

Solution code:
a = int(input())

b = {}
for _ in range(a):
    S = input()
    if S in b:
        b[S] += 1
    else:
        b[S] = 1

m = max(b.values())
l = []
for k in b:
    v = b[k]
    if v != m:
        continue
    l.append(k)

for s in sorted(l):
    print(s)

Submission status: Accepted

Solution code:
import collections

N = int(input())
wordDict = {}
maxNum = 0
for i in range(N):
    word = input()
    if( word in wordDict ):
        wordDict[word] += 1
    else:
        wordDict[word] = 1
    
max_v = max(wordDict.values())
keys = [k for k, v in wordDict.items() if v == max_v]

keys.sort()

for word in keys:
    print(word)

Submission status: Accepted

Solution code:
import collections
N = int(input())
S = [input() for i in range(N)]
c = collections.Counter(S).most_common()

ans = []
for i in c:
  if c[0][1] == i[1]:
    ans.append(i[0])
ans.sort()

for i in ans:
  print(i)

Submission status: Accepted

Solution code:
n = int(input())
a = {}
for i in range(n):
    s = input()
    if s in a:
        a[s] += 1
    else:
        a[s] = 1
d = []
m = max(a.values())
for key, value in a.items():
    if m == value:
        d.append(key)
d.sort()
print(*d, sep='\n')

Submission status: Accepted

Solution code:
import sys
from collections import Counter

read = sys.stdin.read

N, *S = map(str, read().split())
s = Counter(S)
n = max(s.values())
answer = [i for i, j in s.items() if j == n]
answer.sort()
print('\n'.join(answer))

Submission status: Accepted

Solution code:
import sys
from collections import Counter

read = sys.stdin.read

N, *S = map(str, read().split())
s = Counter(S).most_common()
n = s[0][1]
answer = [i for i, j in s if j == n]
answer.sort()
print('\n'.join(answer))

Submission status: Accepted

Solution code:
n = int(input())
s = [input() for _ in range(n)]
s.sort()

a = ""
tt = [[],[]]
for i in s:
    if a != i:
        a = i
        tt[0] += [i]
        tt[1] += [1]
    else:
        tt[1][-1] += 1
t = tt
m = max(t[1])
ans = []
for i in range(len(t[1])):
    if t[1][i] == m:
        ans += [t[0][i]]

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

Submission status: Accepted

Solution code:
def main():
    n =int( input())

    cnt=dict()
    
    for _ in range(n):
        s=input()
        if s in cnt:
            cnt[s]+=1
        else :
            cnt[s]=1
    #print(cnt)
    
    num = 0
    res =[]
    for key,value in cnt.items():
        #print(key,":::",value)
        if value > num:
            num=value
            res=[]
            res.append(key)

        elif value==num:
            res.append(key)

    #print("res::",res)

    
    #a = [k for k, v in cnt.items() if v == max(cnt.values())]


    #print("結果発表：：：：",len(res))
    res.sort()
    for elm in res:
        print(elm)


main()

Submission status: Accepted

Solution code:
import collections as coll

N = int(input())
A = [input() for _ in range(N)]
C = coll.Counter(A).most_common()
C = sorted([k for k,v in C if v == C[0][1]])
print(*C, sep='\n')

Submission status: Accepted

Solution code:
n = int(input())
dictionary = {}

for _ in range(n):
    s = input()
    if s in dictionary.keys():
        dictionary[s] = dictionary[s] + 1
    else:
        dictionary[s] = 1


lst = []

for e in dictionary.items():
    lst.append(list(e))

lst.sort(key=lambda x: (-x[1],x[0]))

memo = lst[0][1]
for key,value in lst:
    if value == memo:
        print(key)
    else:
        break

Submission status: Accepted

Solution code:
import collections

N = int(input())

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

c = collections.Counter(s)
max_n = max(c.values())

ans = []
for key, val in c.items():
  if val == max_n:
    ans.append(key)
print("\n".join(sorted(list(set(ans)))))

Submission status: Accepted

Solution code:
from collections import Counter


def words_sort_ordered(words_list):
    word_cnt = Counter()
    for word in words_list:
        word_cnt[word] += 1

    word_written_max_time = 0
    for each_word_ct in word_cnt.values():
        if each_word_ct > word_written_max_time:
            word_written_max_time = each_word_ct

    answer_words_list = []
    for word, number in dict(word_cnt).items():
        if number == word_written_max_time:
            answer_words_list.append(word)

    return sorted(answer_words_list)


if __name__ == '__main__':
    words_num = int(input())
    words_list = [input() for i in range(words_num)]
    for w in words_sort_ordered(words_list):
        print(w)

Submission status: Accepted

Solution code:
from collections import Counter

n = int(input())
L = [input() for i in range(n)]
C = Counter(L)
maxv = max(C.values())
A = [k for k, v in C.items() if v == maxv]
A.sort()
print('\n'.join(A))

Submission status: Accepted

Solution code:
# 解き直し
from collections import defaultdict
N = int(input())
c = defaultdict(int)
for _ in range(N):
    s = input()
    c[s] += 1
max_cnt = max(c.values())

anss = []
for k, v in c.items():
    if v == max_cnt:
        anss.append(k)

for ans in sorted(anss):
    print(ans)

Submission status: Accepted

Solution code:
N = int(input())
S = {}
for i in range(N):
    s = input()
    S[s] = S.get(s, 0) + 1

keys = list(S.keys())
keys.sort(key=lambda x: -S[x])

top_mode = S[keys[0]]

ans = []
for i in range(len(keys)):
    if top_mode == S[keys[i]]:
        ans.append(keys[i])

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

Submission status: Accepted

Solution code:
import pprint
N = int(input())
S = {}
for i in range(N):
    tmp = input()
    if tmp in S.keys():
        S[tmp] = S[tmp] + 1
    else:
        S[tmp] = 1
    #pprint.pprint(S)

num = 0
v = []
for key,value in S.items():
    if value > num:
        num = value
        v = [key]
    elif value == num:
        v.append(key)

v.sort()

for i in v:
    print(i)

Submission status: Accepted

Solution code:
from  collections import Counter
n=int(input())
S=[input() for _ in range(n)]
# M = {s:0 for s in S}
# for s in S: M[s]+=1
M = Counter(S)
mx = max(M.values())
L = sorted(M.items())
for k,v in L:
    if mx==v: print(k)

Submission status: Accepted

Solution code:
n = int(input().rstrip())
 
current_max = 0
current = []
table = {}
 
for i in range(n):
    s = input().rstrip()
    table[s] = table[s] + 1 if table.get(s) is not None else 1
 
score_sorted = sorted(table.items(), key=lambda x:-x[1])

max = 0
results = []
for k, v in score_sorted:
    if max > v:
      break
    max = v
    results.append(k)

results.sort()

for word in results:
  print(word)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import Counter
n = int(input())
lst = [input() for i in range(n)]
c = Counter(lst)
c2 = c.most_common()
m = c2[0][1]
ans = [i[0] for i in c2 if i[1] == m]
print('\n'.join(sorted(ans)))

Submission status: Accepted

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

S_cnt = Counter(S)
max_cnt = max(S_cnt.values())
# print(max_cnt)

names = [name for name, v in S_cnt.items() if v == max_cnt]
names.sort()

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

Submission status: Accepted

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

S_cnt = Counter(S)
max_cnt = max(S_cnt.values())
# print(max_cnt)

names = [name for name, v in S_cnt.items() if v == max_cnt]
names.sort()

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

Submission status: Accepted

Solution code:
from collections import Counter
n=int(input())
a=[input() for _ in range(n)]
c=Counter(a)
max_cnt=max(c.values())
names=[name for name,v in c.items() if v==max_cnt]
names.sort()
print(*names,sep='\n')

Submission status: Accepted

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

d = {}
for ss in s:
    d[ss] = d.get(ss, 0) + 1

maxi = max(d.values())
t = list(set([ ss for ss in s if d[ss] == maxi]))
t.sort()
print("\n".join(t))

Submission status: Accepted

Solution code:
from collections import Counter
 
c = Counter(input() for _ in range(int(input())))
m = max(c.values())
for s in sorted(s for s, k in c.items() if k == m): 
  print(s)

Submission status: Accepted

Solution code:
from itertools import groupby
from operator import itemgetter

a = groupby(sorted(input() for _ in range(int(input()))))
a = [(len(tuple(g)), s) for s, g in a]
m = max(a, key=itemgetter(0))[0]
for k, s in a:
  if k == m:
    print(s)

Submission status: Accepted

Solution code:
from itertools import groupby

a = groupby(sorted(input() for _ in range(int(input()))))
a = [(len(tuple(g)), s) for s, g in a]
m = max(a)[0]
for k, s in a:
  if k == m:
    print(s)

Submission status: Accepted

Solution code:
from collections import defaultdict
N = int(input())
cnt = defaultdict(int)

for _ in range(N):
    cnt[input()] += 1

mx = max(cnt.values())
cnt = [s for s, n in cnt.items() if n == mx]
cnt.sort()

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

Submission status: Accepted

Solution code:
import collections

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

i = 0
ans = []
while (True):
    ans.append(c_most[i][0])
#    print(c_most[i][0])
    i += 1
    if i == len(c_most):
        break
    if c_most[i][1] != c_most[i - 1][1]:
        break
ans.sort()
for i in range(len(ans)):
    print(ans[i])

Submission status: Accepted

Solution code:
from collections import Counter

c = Counter(input() for _ in range(int(input())))
m = max(c.values())
for s in sorted(s for s, k in c.items() if k == m): 
  print(s)

Submission status: Accepted

Solution code:
from collections import Counter

c = Counter(input() for _ in range(int(input())))
m = max(c.values())
for s in sorted(s for s in c if c[s] == m): 
  print(s)

Submission status: Accepted

Solution code:
from collections import Counter
N = int(input())
S = [input() for _ in range(N)]
counter = Counter(S)
max_val = max(counter.values())
for k, v in sorted(counter.items()):
    if v == max_val:
        print(k)

Submission status: Accepted

Solution code:
from collections import Counter

c = Counter(input() for _ in range(int(input())))
m = c.most_common(1)[0][1]
for s in sorted(s for s, k in c.items() if k == m): 
  print(s)

Submission status: Accepted

Solution code:
N = int(input())
S = dict()
Max = 1
for i in range(N):
    s = input()
    if s in S:
        S[s] += 1
        if S[s] > Max:
            Max = S[s]
    else:
        S[s] = 1
for key, value in sorted(S.items()):
    if value == Max:
        print(key)

Submission status: Accepted

Solution code:
def main():
    from collections import defaultdict
    from operator import itemgetter

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

    d = defaultdict(int)
    for w in s:
        d[w] += 1

    mx = max(d.values())
    for key, cnt in sorted(d.items(), key=itemgetter(0)):
        if cnt != mx: continue
        print(key)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N = int(input())
S = ['0'] * N
for i in range(N):
    S[i] = input()
import collections
c = collections.Counter(S)
li = list(c.values())
ca = c.keys()
li.sort()
max = li[-1]
from collections import deque
lia = deque()
for i in ca:
    if c[i] == max:
        lia.append(i)
liaa = list(lia)
liaa.sort()
n = len(lia)
for i in range(n):
    print(liaa[i])

Submission status: Accepted

Solution code:
def main():
    n = int(input())
    words = {}
    for _ in range(n):
        a = input()
        if a in words:
            words[a] += 1
        else:
            words[a] = 1

    max_val = max(words.values())
    # words_sorted = sorted(words.items(), key=lambda x: x[0])
    for key, value in sorted(words.items()):
        if value != max_val:
            continue
        else:
            print(key)
            # key valueを両方printするとき
            # print('{}:{}'.format(key, value))


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
import collections

N = int(input())

S = []
for _ in range(N):
  S.append(input())
  
c = collections.Counter(S)

d = c.most_common()[0][1]

e = sorted([k for k,v in c.items() if v == d])

for f in e:
  print(f)

Submission status: Accepted

Solution code:
from collections import Counter
n = int(input())
c = Counter((input() for _ in range(n))).most_common()
ci = c[0][1]
ans = []
for s, i in c:
    if i < ci:
        break
    ans.append(s)
for a in sorted(ans):
    print(a)

Submission status: Accepted

Solution code:
def main():
    n = int(input())
    words = {}
    for _ in range(n):
        a = input()
        if a in words:
            words[a] += 1
        else:
            words[a] = 1

    max_val = max(words.values())
    words_sorted = sorted(words.items(), key=lambda x: x[0])
    for key, value in words_sorted:
        if value != max_val:
            continue
        else:
            print(key)


if __name__ == "__main__":
    main()