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

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)

Submission status: Accepted

Solution code:
import collections

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

# リストsに含まれる単語と出現回数の辞書を作成
# keyに要素　valueに出現回数 
a = collections.Counter(s)

# 出現回数の最大値を取得
max_a = max(a.values())

# value=max_a　なら　keys　に key（単語） を書き込む
# k / for k, v in a.items() / if v == max_a
keys = [k for k, v in a.items() if v == max_a]
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)]

# リストsに含まれる単語と出現回数の辞書を作成
# keyに要素　valueに出現回数 
a = collections.Counter(s)

# 出現回数の最大値を取得
max_a = max(a.values())

# value=max_a　なら　keys　に key（単語） を書き込む
# k / for k, v in a.items() / if v == max_a
keys = [k for k, v in a.items() if v == max_a]
keys.sort()

[print(word) for word in keys]

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
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()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

from collections import Counter

ctr = Counter(ss)
counted = ctr.most_common()
# print(counted)
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)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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')

Submission status: Accepted

Solution code:

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin python3
# -*- coding: utf-8 -*-

import sys
#input = sys.stdin.readline

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#155 Poll
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))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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


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

count = Counter(data)
#count = sorted(count, key=lambda x: x[0])
#count = sorted(count)
most = count.most_common()
mostNum = most[0][1]
'''
print(count)    # counter_object
print(most)     # list;[(val,num),(val,num),/////]
print(mostNum)  # number of most
'''
most.sort()

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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]

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

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

# calc 
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')

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#template
def inputlist(): return [int(k) for k in input().split()]
#template
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])

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
d = {}
for i in range(n):
    s=input()
    if s not in d:
        d[s] = 1
    else:
        d[s] += 1
max_d = max(d.values())
print(*sorted([kv[0] for kv in d.items() if kv[1] == max_d]))

Submission status: Accepted

Solution code:
import collections
n = int(input())
s = [input() for _ in range(n)]
c = collections.Counter(s)
c = c.most_common()
base = c[0][1]
ans = []
for i in range(len(c)):
    if (c[i][1]==base):
        ans.append(c[i][0])
    else:
        break
ans.sort()
print(*ans, sep="\n")

Submission status: Accepted

Solution code:
d=dict()
for i in range(int(input())):
    s=input()
    if s not in d:
        d[s]=1
    else:
        d[s]+=1
max_v = max(d.values())
print(*sorted([kv[0] for kv in d.items() if kv[1] == max_v]))

Submission status: Accepted

Solution code:
#!/usr/bin/env python3

import sys
# import math
# import re                                    # re.compile(pattern) => ptn obj; p.search(s), p.match(s), p.finditer(s) => match obj; p.sub(after, s)
# from collections import deque                # deque class. deque(L): dq.append(x), dq.appendleft(x), dq.pop(), dq.popleft(), dq.rotate()
from collections import defaultdict          # subclass of dict. defaultdict(facroty)
# from collections import Counter              # subclass of dict. Counter(iter): c.elements(), c.most_common(n), c.subtract(iter)
# from heapq import heapify, heappush, heappop # built-in list. heapify(L) changes list in-place to min-heap in O(n), heappush(heapL, x) and heappop(heapL) in O(lgn).
# from heapq import nlargest, nsmallest        # nlargest(n, iter[, key]) returns k-largest-list in O(n+klgn).
# from itertools import count, cycle, repeat   # count(start[,step]), cycle(iter), repeat(elm[,n])
# from itertools import groupby                # [(k, list(g)) for k, g in groupby('000112')] returns [('0',['0','0','0']), ('1',['1','1']), ('2',['2'])]
# from itertools import starmap                # starmap(pow, [[2,5], [3,2]]) returns [32, 9]
# from itertools import product                # product(iter, repeat=n)
# from itertools import accumulate             # accumulate(iter[, f])
# from functools import reduce                 # reduce(f, iter[, init])
# from functools import lru_cache              # @lrucache ...arguments of functions should be able to be keys of dict
# from bisect import bisect_left, bisect_right # bisect_left(a, x, lo=0, hi=len(a)) returns i such that all(val<x for val in a[lo:i]) and all(val>-=x for val in a[i:hi]).
# from copy import deepcopy                    # to copy multi-dimentional matrix without reference
# from fractions import gcd                    # for Python 3.4


def main():
    mod = 1000000007                  # 10^9+7
    inf = float('inf')
    sys.setrecursionlimit(10**6)    # 1000 -> 1000000
    def input(): return sys.stdin.readline().rstrip()
    def ii():  return int(input())
    def mi():  return map(int, input().split())
    def mi_0(): return map(lambda x: int(x)-1, input().split())
    def lmi(): return list(map(int, input().split()))
    def lmi_0(): return list(map(lambda x: int(x)-1, input().split()))
    def li():  return list(input())
    
    
    n = ii()
    d = defaultdict(int)
    for _ in range(n):
        s = input()
        d[s] += 1
    max_num = - float('inf')
    for k, v in d.items():
        max_num = max(max_num, v)
    L = list(d.items())
    L.sort(key=lambda x: x[0])
    for elm in L:
        if elm[1] == max_num:
            print(elm[0])

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
n=int(input())
s1=[]
for i in range(n):
    s=input()
    s1.append(s)
s1.sort()
s2=sorted(list(set(s1)))
s3=[0]*(len(s2))
cnt=0
for i in range(n):
    if s2[cnt]==s1[i]:
        s3[cnt]+=1
    else:
        cnt+=1
        s3[cnt]+=1
max=max(s3)
for i in range(len(s3)):
    if max==s3[i]:
        print(s2[i])

Submission status: Accepted

Solution code:
from collections import Counter

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

S.sort() #l = sorted(S)と同義 *Sは変化させたくないときはsorted使う◎
counted = Counter(S)
l = counted.most_common()
m = l[0][1]
l.sort()
for i in l:
    if m == i[1]:
        print(i[0])

Submission status: Accepted

Solution code:
n = int(input())
s = [input() for i in range(n)]
from collections import Counter
c = Counter(s)
x = c.most_common()
ans = []
maxcnt = x[0][1]
for i in range(len(x)):
    if x[i][1] == maxcnt:
        ans.append(x[i][0])
    else:
        break
ans.sort()
for i in range(len(ans)):
    print(ans[i])

Submission status: Accepted

Solution code:
from collections import Counter
N = int(input())
S =[input() for i in range(N)]
cnts = Counter(S)
mx = 0
for v in cnts.values():
    mx = max(mx, v)
    
max_words = [k for k, v in cnts.items() if v == mx]
max_words = sorted(max_words)
print(*max_words, sep ="\n")

Submission status: Accepted

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

d = {}
for word in s:
    if word not in d.keys():
        d[word] = 1
    else:
        d[word] += 1

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

for k, v in d:
    if v == max_v:
        print(k)

Submission status: Accepted

Solution code:
n = int(input())
s = [input() for _ in [0]*n]
d = {}
for i in s:
    if i not in d: d[i] = 1
    else: d[i] += 1
num = max(d.values())
ans = [i for i in d if d[i]==num]
print('\n'.join(sorted(ans)))

Submission status: Accepted

Solution code:
# n = int(input())
# list_a = []

# for i in range(n):
#   list_a.append(input())

# d = {}
# for i in list_a:
#   if i in d:
#     d[i] = d[i] + 1
#   else:
#     d[i] = 1

# key = sorted([k for k, v in d.items() if v == d[max(d)]])
# for i in key:
#   print(i)

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

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

max_value = max(d.values())
key = sorted([k for k, v in d.items() if v == max_value])
for i in key:
    print(i)

Submission status: Accepted

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

a = {}

for j in range(n):
    if not(s[j] in a):
        a[s[j]] = 1
    else:
        a[s[j]] += 1

b = 0
for num in a.values():
  if num > b:
    b = num

c = []
for name,num in a.items():
  if num==b:
    c.append(name)

d=sorted(c)

for k in d:
    print(k)

Submission status: Accepted

Solution code:
n=int(input())
s=[input() for i in range(n)]
s.sort()
b=list(set(s))
b.sort()
a=s[0]
m=[0]
for i in range(n):
  if s[i]!=a:
    m.append(i)
    a=s[i]
m.append(n)
o=[]
for i in range(len(m)-1):
  o.append(m[i+1]-m[i])
num=max(o)
for i in range(len(o)):
  if o[i]==num:
    print(b[i])