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())
s=[input() for i in range(n)]
s=sorted(s)
poll=[s[0]]
counta=[1]
kind=0
for i in range(1,n):
  if s[i]==s[i-1]:
    counta[kind]+=1
  else:
    kind+=1
    poll.append(s[i])
    counta.append(1)
m=max(counta)
for i in range(kind+1):
  if counta[i]==m:
    print(poll[i])

Submission status: Accepted

Solution code:
import sys

stdin = sys.stdin

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))

n=ni()
dic= {}
for i in range(n):
    s=ns()
    if s in dic:
        dic[s]+=1
    else:
        dic[s]=1
maxnum=0
for i in dic.items():
    if maxnum<i[1]:
        maxnum=i[1]
ans=[]
for i in dic.items():
    if maxnum==i[1]:
        ans.append(i[0])
ans.sort()

for i in ans:
    print(i)

Submission status: Accepted

Solution code:
import collections

N=int(input())
S=[]
for i in range(N):
	S.append(input())
M=collections.Counter(S)
A=max(M.values())
tmp=[]
for i,j in M.items():
	if j==A:
		tmp.append(i)
ans=sorted(tmp)
for i in range(len(ans)):
	print(ans[i])

Submission status: Accepted

Solution code:
import collections
n = int(input())
c = [0 for _ in range(n)]
for i in range(n):
    c[i] = input()
c = collections.Counter(c).most_common()
ans = []
first = c[0][1]
for i in c:
    if i[1] == first:
        ans.append(i[0])

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

Submission status: Accepted

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

max=max(c.values())

ans=[]
for i,j in c.items():
    if j == max:
        ans.append(i)
ans=sorted(ans)
print('\n'.join(ans))

Submission status: Accepted

Solution code:
N = int(input())
word_count = {}
for i in range(N):
    word = input()
    if word not in word_count:
        word_count[word] = 1
    else:
        word_count[word] += 1

counts = [val for (key, val) in word_count.items()]
max_count = max(counts)
words = sorted([key for (key, val) in word_count.items() if val == max_count])
for word in words:
    print(word)

Submission status: Accepted

Solution code:
import sys
#input = sys.stdin.buffer.readline
from collections import defaultdict
from operator import itemgetter

def main():
    N = int(input())
    d = defaultdict(int)
    for _ in range(N):
        s = input()
        d[s] -= 1

    cnt = list(d.items())
    cnt.sort(key=itemgetter(1,0))
    
    mc = cnt[0][1]
    for x,y in cnt:
        if y == mc:
            print(x)
        else:
            break
    
if __name__ == "__main__":
    main()

Submission status: Accepted

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

x = set(S)
d = {}
for i in x:
    d[i] = 0
for s in S:
    d[s]+=1

y = 0
for key, value in d.items():
    y = max(y, value)
name = []
for key, value in d.items():
    if value==y:
        name.append(key)
name.sort()
for n in name:
    print(n)

Submission status: Accepted

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

count=0
for i in range(n):
  s=input()
  if s in x:
    x[s]+=1
  else:
    x[s]=1

a=max(x.values())
keys=[k for k,v in x.items() if v==a]
answer=sorted(keys)
  
for a in answer:
  print(a)

Submission status: Accepted

Solution code:
from collections import defaultdict
dd = defaultdict(int)
a=int(input())
li =[]
for i in range(a):
    b=input()
    li.append(b)
for b in li:
    dd[b] += 1
M = 1
l=[]
for i in dd.keys():
    if dd[i] > M:
        M = dd[i]
        l = []
        l.append(i)
    elif dd[i] == M:
        l.append(i)
    else:
        continue
l.sort()
for i in range(len(l)):
    print(l[i])

Submission status: Accepted

Solution code:
import collections


def main():
    n = int(input())
    word_list = [input() for _ in range(n)]
    
    c = collections.Counter(word_list)
    max_freq = max(c.values())
    most_freq_word = sorted([i for i in c if c[i] == max_freq])
    print('\n'.join(most_freq_word))


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import collections


def main():
    n = int(input())
    word_list = []

    for _ in range(n):
        word_list.append(input())

    c = collections.Counter(word_list)
    max_freq = max(c.values())
    most_freq_word = sorted([i for i in c if c[i] == max_freq])
    print('\n'.join(most_freq_word))


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
from collections import Counter

n = int(input())
ss = []
for _ in range(n):
    ss.append(input().rstrip())
ctr = Counter(ss)

a = sorted([(-v, k) for k, v in ctr.items()])
maxv = a[0][0]
for i in range(len(a)):
    if a[i][0] != maxv:
        break
    print(a[i][1])

Submission status: Accepted

Solution code:
from collections import Counter
import heapq

n = int(input())
ss = []
for _ in range(n):
    ss.append(input().rstrip())
ctr = Counter(ss)
heap = [(-v, k) for k, v in ctr.items()]
heapq.heapify(heap)
maxv = heap[0][0]
while heap:
    c = heapq.heappop(heap)
    if c[0] != maxv:
        break
    print(c[1])

Submission status: Accepted

Solution code:
#!/usr/local/bin python
# -*- coding: utf-8 -*-
#
# ~/PycharmProjects/atcoder/C-.py
#
import collections

n = int(input())
l = [str(input()) for i in range(n)]
# l = ["beat", "vet", "beet", "bed", "vet", "bet", "beet"]
c = collections.Counter(l)
number_of_words = len(c)
counted_list = c.most_common()
ans_before_sort = [counted_list[0][0]]

for i in range(number_of_words-1):
    if counted_list[i][1] == counted_list[i+1][1]:
        ans_before_sort.append(counted_list[i+1][0])
    else:
        break

ans_after_sort = sorted(ans_before_sort)
print('\n'.join(ans_after_sort))

Submission status: Accepted

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

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

import collections

c = collections.Counter(str_list)

x = c.most_common()
str_list_2 = []

num = x[0][1]
for i in x:
    if i[1] != num:
        break
    else:
        str_list_2.append(i[0])

str_list_2.sort()

for i in str_list_2:
    print(i)

Submission status: Accepted

Solution code:
from collections import Counter

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

sorted_si = Counter(si).most_common()
last = -1
names = []
for s in sorted_si:
    if last <= s[1]:
        names.append(s[0])
        last = s[1]

for name in sorted(names):
    print(name)

Submission status: Accepted

Solution code:
import collections                                                              
                                                                                
N = int(input())                                                                
S = []                                                                          
for i in range(N):                                                              
    S.append(input().strip())                                                   
counter = collections.Counter(S)                                                
common_word_num = counter.most_common()[0][1]                                   
                                                                                
ans = [i[0] for i in counter.items() if i[1] == common_word_num]                
ans.sort()                                                                      
for w in ans:                                                                   
    print(w)

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()[0][1]

s = list(set(s)) #sの重複した要素を消す
s.sort()

for i in s:
    if a[i] == b:
        print(i)

Submission status: Accepted

Solution code:
import collections
n = int(input())
a = [input() for _ in range(n)]
c = collections.Counter(a).most_common()
m = []
saidai = c[0][1]
for i in c:
  if saidai <= i[1]:
    m += [i[0]]
m.sort()
print('\n'.join(m))

Submission status: Accepted

Solution code:
import collections

n = int(input())
s = [input() for i in range(n)]
c = collections.Counter(s)
x = c.most_common()[0][1]

s = list(set(s))
s.sort()

for item in s:
  if c[item] == x:
  	print(item)

Submission status: Accepted

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

s.sort()
count=1
maximum=0

for j in range (N-1):
  if s[j]==s[j+1]:
    count+=1
    if j==N-2:
      if count>maximum:
        a=[]
        a.clear()
        a.append(s[j])
        maximum=count
        number=1
      elif count==maximum:
        a.append(s[j])
        number+=1
  else:
    if count>maximum:
      a=[]
      a.clear()
      a.append(s[j])
      maximum=count
      number=1
    elif count==maximum:
      a.append(s[j])
      number+=1
    count=1   
  if maximum==1 and j==N-2:
    a.append(s[N-1])
    number+=1
for p in range (number):
  print(a[p])

Submission status: Accepted

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

ans = []
max = 0
tmp = 1

for i in range(1,n):
  if s[i] == s[i-1]:
    tmp += 1
  if s[i] != s[i-1]:
    if max == tmp:
      ans.append(s[i-1])
    if max < tmp:
      ans = [s[i-1]]
      max = tmp
    tmp = 1
###print(ans)
if max == tmp:
  ans.append(s[n-1])
if max < tmp:
  ans = [s[n-1]]
  
for i in ans:
  print(i)

Submission status: Accepted

Solution code:
import collections
N = int(input())
arr = [input() for i in range(N)]
c = collections.Counter(arr)
# print(max(c.values()))
# ans = [c[x] for x in c]
MAX = max(c.values())
ans = sorted([x for x in c if c[x] == MAX])
# ans = [x for x in c]
for i in ans:
    print(i)

Submission status: Accepted

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

l=[]
x = [input() for _ in range(a)]
count=Counter(x)
x=count.most_common()
x.sort()
y=x.copy()
y.sort(key=lambda x:x[1],reverse=True)
tmp=y[0][1]
for i in x:
    if tmp <= i[1]:
        l.append(i[0])
        tmp=i[1]

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

Submission status: Accepted

Solution code:
import collections
N=int(input())
S=list(input() for i in range(N))
S=collections.Counter(S)
S=S.most_common()
if len(S)==1:
  print(S[0][0])
elif S[0][1]>S[1][1]:
  print(S[0][0])
else:
  s=[i for i in S if i[1]==S[0][1]]
  s=dict(s)
  s=list(s.keys())
  s=sorted(s)
  for i in s:
    print(i)

Submission status: Accepted

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

dict=collections.Counter(S)
#print(dict)
std=sorted(dict)
#print(std)
M=max(dict.values())
for el in std:
   if dict[el]==M:
       print(el)

Submission status: Accepted

Solution code:
N = int(input())
d = {}
for i in range(N):
    s = input()
    if s in d.keys():
        d[s] += 1
    else:
        d[s] = 1
Max = max(d.values())
keys = [k for k, v in d.items() if v == Max]
keys.sort()
for k in keys:
    print(k)

Submission status: Accepted

Solution code:
n = int(input())
cnt = {}
mx = 0
for i in range(n):
  s = input()
  if s not in cnt:
    cnt[s] = 0
  cnt[s] += 1
  mx = max(mx,cnt[s])
ans = []
for s in cnt:
  if cnt[s] == mx:
    ans.append(s)
ans.sort()
for i in ans:
  print(i)

Submission status: Accepted

Solution code:
# 入力の取得
# 数値:1行1件
n = int(input())

# 処理
# 辞書オブジェクト生成
dictionary = dict()

# 文字:N行_1件_1行ずつ取得
for i in range(n):
    data = input()

    # 辞書オブジェクトに存在する場合は対象キーの値を加算
    if data in dictionary:
        dictionary[data] += 1
    else:
        dictionary[data] = 0

# データソート
# ソートは、 安定 (stable) であることが保証されている。https://docs.python.org/ja/3/howto/sorting.html
# 複数のキーで並べ替えしたい場合、優先度の低いキーから順番にソートすれば良い。
# ソート1(キーの昇順)
data_sorted = sorted(dictionary.items(), key=lambda x: x[0])
# ソート2(値の降順)
data_sorted = sorted(data_sorted, key=lambda x: x[1], reverse=True)

# データ出力
count = data_sorted[0][1]
for key, val in data_sorted:
    if count == val:
        print(key)
    else:
        exit

Submission status: Accepted

Solution code:
n = int(input())
d = {}
for i in range(n):
    s = str(input())
    if s in d.keys():
        d[s] += 1
    else:
        d[s] = 1
max = max(d.values())
k = [x for x, y in d.items() if y ==max]
k.sort()
for i in k:
    print(i)

Submission status: Accepted

Solution code:
n=int(input())
s=[""]*n
dic={}
for i in range(n):
  a=input()
  if (a in dic):
    dic[a]+=1
  else:
    dic[a]=1
#dic=sorted(dic.items(), key=lambda x:x[1], reverse=True)
v_max=max(dic.values())
keys=[k for k,v in dic.items() if v==v_max ]
keys=sorted(keys)
for i in range(len(keys)):
  print(keys[i])

Submission status: Accepted

Solution code:
from collections import deque, Counter
n = int(input())
s = deque([])
for i in range(n):
    s.append(input())
s_count = Counter(s).most_common()
s_count.sort()
s_count.sort(key=lambda x: x[1], reverse=True)
cnt_max = -1
for word, cnt in s_count:
    if cnt_max == -1:
        cnt_max = cnt
    if cnt_max == cnt:
        print(word)
    else:
        break

Submission status: Accepted

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

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

max_count = max(count_list.values())
key = [k for k, v in count_list.items() if v == max_count]
key.sort()
for k in key:
    print(k)

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 s in sorted(k for k in d if d[k]==m):
    print(s)

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
    
max_N = max(list(dic.values()))
keys = sorted([k for k, v in dic.items() if v == max_N])

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

Submission status: Accepted

Solution code:
# 初期入力
N = int(input())
word = [ input() for i in range(N) ]

# 単語をキーに数を数えて辞書
from collections import Counter
kazu_word = Counter(word)

#一番多い単語を抜き出す
kazu_word_a = max(kazu_word.values()) #　内包表記の中で毎回MAXを計算するより出したほうが１回で済む
kazu_word_max =[i for i,v in kazu_word.items() if v == kazu_word_a ]
kazu_word_max_sorted = sorted(kazu_word_max)
"""
print(kazu_word)
print(kazu_word_max)
"""
print(*kazu_word_max_sorted,sep="\n")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
d = dict()
m = 0
for _ in range(n):
    x = input()
    if x in d:
        d[x] += 1
    else:
        d[x] = 1
    if m < d[x]:
        m = d[x]
for p in sorted([e for e in iter(d) if d[e] == m]):
    print(p)

Submission status: Accepted

Solution code:
n=int(input())
D={}
ma=1
for i in range(n):
    s=input()
    if s in D:
        D[s]+=1
        ma=max(ma,D[s])
    else:
        D[s]=1

L=[]
for i in D:
    if D[i]==ma:
        L.append(i)
L.sort()
for i in L:
    print(i)

Submission status: Accepted

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

n_dict = {}

for i in S:
    if i not in n_dict:
        n_dict[i] = 1
    else:
        n_dict[i] +=1
    
m = max(n_dict.values())
ans =[]
for k, v in n_dict.items():
    if v == m:
        ans.append(k)

ans.sort()

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

Submission status: Accepted

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

S.sort()
S_dict = {}
for key in S:
    S_dict[key] = 0

for key in S:
    S_dict[key] += 1

max_value = max(S_dict.values())

ans = []
for key in S_dict:
    if S_dict[key] == max_value:
        ans.append(key)
ans.sort()

for i in ans:
    print(i)

Submission status: Accepted

Solution code:
'''
    Auther: ghoshashis545 Ashis Ghosh
    College: jalpaiguri Govt Enggineerin College
    Date:24/03/2020
'''

def main():
    
    # for _ in range(ii()):
    n=int(input())
    m={}
    for i in range(n):
        s=input()
        if s not in m:
            m[s]=1
        else:
            m[s]+=1
    maxv=0
    a=[]
    for i in m.keys():
        maxv=max(maxv,m[i])
    for i in m.keys():
        if(m[i]==maxv):
            a.append(i)
    a.sort()
    for i in a:
        print(i)
        
















    
    
if __name__ =="__main__":
    main()

Submission status: Accepted

Solution code:
from collections import Counter
N = int(input())
A = []
for i in range(N):
  A.append(input())
C= Counter(A)
B = 0
for v in C.values():
  B = max(B,v)
ans = []
for k, v in C.items():
  if v == B:
    ans.append(k)
ans.sort()
print(*ans,sep='\n')

Submission status: Accepted

Solution code:
N = int(input())
result = {}
maximum = 1
for i in range(N):
    S = input()
    if S in result:
        result[S] += 1
        maximum = max(maximum, result[S])
    else:
        result[S] = 1
for name in sorted(result):
    if result[name] == maximum:
        print(name)

Submission status: Accepted

Solution code:
from collections import Counter

N, *S = open(0).read().split()
count = Counter(S)
max_value = max(count.values())
ans_list = [i for i, j in count.items() if j == max_value]
ans_list.sort()
print("\n".join(ans_list))

Submission status: Accepted

Solution code:
from collections import Counter

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

count = Counter(S).most_common()
mode = count[0][1]
count.sort()
##print("--")
for i in range(len(count)):
    if count[i][1] == mode:
        print(count[i][0])

Submission status: Accepted

Solution code:
from collections import Counter

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

Submission status: Accepted

Solution code:
import collections
import itertools

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

c = collections.Counter(l)
l = c.most_common()
x = c.most_common()[0][1]

ans = []
ans.append(l[0][0])
for i in range(len(l)-1):
    if l[i+1][1] == x:
        ans.append(l[i+1][0])
    else:
        break

ans.sort()

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

Submission status: Accepted

Solution code:
N = int(input())
S = [input() for _ in range(N)]
from collections import Counter
C = Counter(S)
kv = [(k,v) for k,v in C.items()]

m = max(C.values())
ans = [k for k,v in C.items() if v == m]
ans.sort()

for k in ans: print(k)

Submission status: Accepted

Solution code:
from collections import Counter
N = int(input())
S = [input() for i in range(N)]
C = Counter(S)
freq = max(C.values())
M = [kv[0] for kv in C.items() if kv[1] == freq]
M.sort()
A = '\n'.join(M)
print(A)

Submission status: Accepted

Solution code:
from collections import Counter
N = int(input())
S = [input() for i in range(N)]
C = Counter(S)
dekai = max(C.values())
M = [kv[0] for kv in C.items() if kv[1] == dekai]
M.sort()
A = '\n'.join(M)
print(A)

Submission status: Accepted

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

ans = []
#
for i in range(len(s_most)):
    if s_most[i][1] == s_most[0][1]:
        ans.append(s_most[i][0])
    else:
        break
for i in sorted(ans):
    print(i)

Submission status: Accepted

Solution code:
N = int(input())

S = {}

A = [""]*N
for i in range(0, N):
    A[i] = A[i] + input()

for i in range(0, N):
    if not (A[i] in S.keys()):
        S[A[i]] = 1
    else:
        S[A[i]] = S[A[i]] + 1

max = 0
for value in S.values():
    if value > max:
        max = value

S0 = {}
n = 0
for key, value in S.items():
    if value == max:
        S0[key] = 0
        n += 1

T = [""]*n
i = 0
for key in S0.keys():
    T[i] = key
    i += 1

T.sort()
for p in range(0, n):
    print(T[p])

Submission status: Accepted

Solution code:
import collections

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

lis=collections.Counter(S)

max_lis_v=sorted(list(lis.values()))[-1]
lis_i=sorted(list(lis.items()))

for i in lis_i:
    if i[1]==max_lis_v:
        print(i[0])

Submission status: Accepted

Solution code:
from collections import Counter
import sys
n = int(sys.stdin.readline())
sn = sys.stdin.read().split()
c = Counter(sn)
num = max(c.values())
ans = [i for i, j in c.items() if j == num]
ans.sort()
print('\n'.join(ans))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import Counter
n = int(input())
s = []
for i in range(n):
  si = input()
  s.append(si)
  
C = Counter(s)
s_num = C.values()
m = max(s_num)
s_max = []
for k, v in C.items():
  if v == m:
    s_max.append(k)
s_max = sorted(s_max)
for sj in s_max:
  print(sj)

Submission status: Accepted

Solution code:
n = int(input())
s = {}
for i in range(n) :
  name = input()
  if name in s :
    s[name] += 1
  else :
    s[name] = 1

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

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

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

Submission status: Accepted

Solution code:
##======================================python3
''' ===========================================
## null
##
##
=========================================== '''
import sys
from sys import stdin #read(), readline()
input = stdin.readline
import heapq #heappush(trgt, val) heappop(trgt) trgt[0] __lt__<
import collections #Counter() .most_common()
sys.setrecursionlimit(10**6)
INF = 1<<50

if __name__ == '__main__':
    n = int(input())
    
    sip = []
    for i in range(n):
        sip.append(input().replace("\n",""))
    cnt = collections.Counter(sip)
    
    num_max = max(cnt.values())
    ans = [i for i, j in cnt.items() if j == num_max]
    ans.sort()
    
    print('\n'.join(ans))

Submission status: Accepted

Solution code:
N = int(input())
ls = [input() for _ in range(N)]
ans_ls = []
from collections import Counter
c = Counter(ls)
m = sorted(c.values())[-1]
for k,v in c.items():
    if v == m:
        ans_ls.append(k)
ans_ls.sort()
print(*ans_ls,sep="\n")

Submission status: Accepted

Solution code:
# 200216 C

import collections

N = int(input())
S = [""] * N
dic = {}
for i in range(N):
    S = input()
    if S in dic:
        dic[S] += 1
    else:
        dic[S] = 1

maxs = max(list(dic.values()))
ans = []
for i in dic:
    if dic[i] == maxs:
        ans.append(i)
ans = sorted(ans)
for i in ans:
    print(i,end=" ")
print("")

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
    
max_N = max(list(dic.values()))
keys = sorted([k for k, v in dic.items() if v == max_N])

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

Submission status: Accepted

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

C = collections.Counter(A).most_common()
ans = []
for k, v in C:
    if v == C[0][1]:
        ans.append(k)

print(*sorted(ans), sep='\n')

Submission status: Accepted

Solution code:
from collections import Counter

n = int(input())

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

c = Counter(strings)

times = 0
ans_list = []
for item in c.most_common():
    if not times:
        times = item[1]
    elif times != item[1]:
        break

    ans_list.append(item[0])

ans_list.sort()

for ans in ans_list:
    print(ans)

Submission status: Accepted

Solution code:
from collections import Counter

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

c = Counter(s)
max_count = max(c.values())

for k, v in c.items():
    if v == max_count:
        ans.append(k)

ans.sort()

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

Submission status: Accepted

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

c = Counter(s)
max_count = max(c.values())

for k, v in c.items():
    if v == max_count:
        ans.append(k)
ans.sort()
print('\n'.join(ans))

Submission status: Accepted

Solution code:
#155_C
from collections import Counter
n = int(input())
s = [input() for _ in range(n)]
s = Counter(s).most_common()

x0 = s[0][1]
ans = []
for t, x in s:
    if x == x0:
        ans.append(t)
ans.sort()
print('\n'.join(ans))

Submission status: Accepted

Solution code:
import collections as co
N = int(input())
names = [input() for _ in range(N)]
names = co.Counter(names)
maxval = max(names.values())
for ans in sorted(names):
    if names[ans] == maxval:
        print(ans)

Submission status: Accepted

Solution code:
N=int(input())

word = {}
ans={}
for i in range(N):
    s=input()
    if s in word:
        word[s]+=1
    else:
        word[s]=1
    
#print(word)
M=max(word.values())
#print(M)

for key in word:
    if word[key] == M:
        cnt=0
        for i in range(len(key)):
            cnt+=ord(key[i])-ord('a')
        ans.setdefault(key, cnt)
        
        
for value in sorted(ans.keys()):
    print(value)

Submission status: Accepted

Solution code:
from collections import*
n,*s=open(0)
cnt=Counter(s).most_common()
ans=sorted(a*(b==cnt[0][1])for a,b in cnt)
for i in ans:
    print(i,end="")

Submission status: Accepted

Solution code:
N = int(input())
D = dict()
for i in range(N):
    s = input()
    if s not in D:
        D[s] = 1
    else:
        D[s] += 1
# print(D)
# print(max(D))
m = max(D.values())
# print(m)
D = sorted(D.items(), key=lambda x:x[1], reverse=True)
# print(D)
Y = []
for i in D:
    if i[1] == m:
        Y.append(i[0])
        # print(Y)
Y.sort()
# print(Y)
for i in Y:
    print(i)

Submission status: Accepted

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

# 辞書作成
s_dict = dict()
for i in s:
    if i not in s_dict:
        s_dict[i] = 1
    else:
        s_dict[i] += 1

m = max(s_dict.values())
ans = []
for k, v in s_dict.items():
    if v == m:
        ans.append(k)
ans.sort()
# ソート
print(*ans, sep="\n")

Submission status: Accepted

Solution code:
import collections
N=int(input())
S=list(input() for _ in range(N))
S=collections.Counter(S)
maxnum=max(S.values())
[print(res) for res in sorted([s for s in S if S[s]==maxnum])]

Submission status: Accepted

Solution code:
from collections import Counter
n = int(input())
s = [input() for _ in range(n)]
ans = []
charctor_count = Counter(s)
max_count = max(charctor_count.values())
for k, v in charctor_count.items():
  if v == max_count:
    ans.append( k)
print("\n".join(sorted(ans)))

Submission status: Accepted

Solution code:
N = int(input())
Si = [""] * N

for n in range(N):
  Si[n] = input()
Si = sorted(Si)

newSi = ["",0]*N
cnt = 0
newSi[0] = [Si[0],1]
maxnum = 1
for n in range(1,N):
  if Si[n] == newSi[cnt][0]:
    newSi[cnt][1] = newSi[cnt][1] + 1
    if newSi[cnt][1] > maxnum: maxnum = newSi[cnt][1]
  else:
    cnt = cnt+1
    newSi[cnt] = [Si[n],1]

for c in range(cnt+1):
  if newSi[c][1] == maxnum: print(newSi[c][0])

Submission status: Accepted

Solution code:
from sys import stdin
from collections import defaultdict

N = int(stdin.readline().rstrip())
S = [stdin.readline().rstrip() for i in range(N)]

D = defaultdict(int)

for s in S:
    D[s] += 1

ans = sorted(D.items(), key=lambda x: (-x[1], x[0]))

for a in ans:
    if a[1] < ans[0][1]:
        break
    print(a[0])

Submission status: Accepted

Solution code:
n = int(input())
name = {}
for i in range(n):
    st = str(input())
    if st in name:
        tmp = name[st] + 1
        name[st] = tmp
    else:
        name[st] = 1

max_val = max(name.values())
max_name = [k for k, v in name.items() if v==max_val]
max_name = sorted(max_name)

for n in max_name:
    print(n)

Submission status: Accepted

Solution code:
n = int(input())
dic = {}
for i in range(n):
    s = input()
    if s not in dic:
        dic[s] = 1
    else:
        dic[s] += 1
dic_sorted = sorted(dic.items(), key=lambda x:x[1], reverse=True)
ans = []
s = []
for k, v in dic_sorted:
    s.append(v)
pre = s[0]
for k, v in dic_sorted:
    if v == pre:
        ans.append(k)
    else:
        break
ans.sort()
for i in ans:
    print(i)

Submission status: Accepted

Solution code:
n=int(input())
A=[]
for i in range(n):
  A.append(input())
from collections import Counter
C=Counter(A)
qq=max(C.values())
ans=[]
for word,times in C.items():
  if times==qq:
    ans.append(word)
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()
max = 0
count = 1
for i in range(1,n):
    if s[i] == s[i-1]:
        count+=1
    else:
        if max < count:
            max = count
            count=1
        else:
            count=1
if max < count:
    max = count
count = 1
ans = []
for i in range(1,n):
    if s[i] == s[i-1]:
        count+=1
    else:
        if max == count:
            ans.append(s[i-1])
            count = 1
        else:
            count = 1
if max == count:
    ans.append(s[n-1])
for i in range(len(ans)):
    print(ans[i])

Submission status: Accepted

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

s_c = Counter(s).most_common()
m = s_c[0][1]

ans = []

for j in range(len(s_c)):
    if s_c[j][1] != m:
        break
    else:
        ans.append(s_c[j][0])
        
ans.sort()

for k in ans:
    print(k)

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline

def main():
    N = int(input())
    dic = {}
    for i in range(N):
        s = input().strip()
        if s in dic:
            dic[s] += 1
        else:
            dic[s] = 1
    
    dic = sorted(dic.items(), key=lambda x: (-x[1], x[0]))
    n = dic[0][1]
    for i in range(len(dic)):
        if dic[i][1] == n:
            print(dic[i][0])
        else:
            break


if __name__ == "__main__":
    main()

Submission status: Accepted

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

max_cnt = max(d.values())
for v in sorted([key for key,value in d.items() if value == max_cnt]):
  print(v)

Submission status: Accepted

Solution code:
N = int(input())

from collections import defaultdict

dd = defaultdict(int)

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

maxv = max(dd.values())
res = sorted(dd.items(), key=lambda x: x[0])

for k,v in res:
    if v == maxv:
        print(k)