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:
from collections import Counter
import heapq

n = int(input())
sc = Counter()

for x in range(n):
  s = input()
  sc.update([s])

max_num = sc.most_common()[0][1]
q = []
for v in sc.items():
  if v[1] == max_num:
    heapq.heappush(q, v[0])

for _ in range(len(q)):
  print(heapq.heappop(q))

Submission status: Accepted

Solution code:
N = int(input())

ss = dict()
for i in range(N):
    s = input()
    ss[s] = ss.get(s, 0) + 1
sss = [(-b, a) for a, b in ss.items()]
sss.sort()
maxa = sss[0][0]
for a, b in sss:
    if maxa != a:
        break
    print(b)

Submission status: Accepted

Solution code:
from collections import defaultdict

d = defaultdict(int)
for _ in range(int(input())):
    d[input()] += 1
mx = max(d.values())
print('\n'.join(sorted([k for k in d.keys() if d[k] == mx])))

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.keys():
    dic[S[i]] = 1
    
  else:
    dic[S[i]] += 1
    
maxim = max(dic.values())
ans = []

for keys in dic.keys():
  if dic[keys] == maxim:
    ans.append(keys)
    
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)]
c = {}

for s in S:
    if c.get(s):
        c[s] += 1
    else:
        c[s] = 1


s_items = sorted(c.items(), key=lambda x: x[1], reverse=True)
n_max = s_items[0][1]

print('\n'.join(sorted(map(lambda x: x[0], filter(lambda x: x[1] == n_max, s_items)))))

Submission status: Accepted

Solution code:
n = int(input())
dd = {}
for i in range(n):
	s = input()
	if s in dd.keys():
		dd[s] += 1
	else:
		dd[s] = 1
ma = max(dd.values())
lst = []
for k, v in dd.items():
	if v == ma:
		lst.append(k)
for l in sorted(lst):
	print(l)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import defaultdict
charnums=defaultdict(int)
N=int(input())
for _ in range(N):
    charnums[input()]+=1
ans=[]
m=max(charnums.values())
for key,value in charnums.items():
    if value==m:
        ans.append(key)
for an in sorted(ans):
    print(an)

Submission status: Accepted

Solution code:
import collections
N=int(input())
S=[]
for i in range(N):
  s=input()
  S.append(s)

l=collections.Counter(S)
keys=l.keys()
k=max(l.values())
ans=[]
for i in keys:
  if l[i]==k:
    ans.append(i)

ans.sort()
n=len(ans)

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

Submission status: Accepted

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


def main():
    N = int(input())
    S = [input().rstrip() for _ in range(N)]
    c = collections.Counter(S).most_common()
    max_freq = None
    max_S = []
    for s, freq in c:
        if max_freq is None:
            max_freq = freq
            max_S.append(s)
        elif freq == max_freq:
            max_S.append(s)
        else:
            break
    print('\n'.join(sorted(max_S)))


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
import collections
N = int(input())
S = []
ans = []
for i in range(N):
  S.append(input())
d = collections.Counter(S)
ome = max(d.values())
for k, v in d.items():
  if v == ome:
    ans.append(k)
ans.sort()
for x in ans:
  print(x)

Submission status: Accepted

Solution code:
N = int(input())
S = [input() for i in range(N)]
d = {}
m = 0
for i in S:
    if i in d:
        d[i] += 1
        if d[i] > m:
            m = d[i]
    else:
        d[i] = 1
        
d = dict(sorted(d.items(), reverse=True))
a = {}
for i in d.keys():
    if m <= d[i]:
        a[i] = 0
a = sorted(a)
for i in a:
    print(i)

Submission status: Accepted

Solution code:
N = int(input())
S = [input() for i in range(N)]
d = {}
m = 0
for i in S:
    if i in d:
        d[i] += 1
        if d[i] > m:
            m = d[i]
    else:
        d[i] = 1
        
d = dict(sorted(d.items(), key = lambda x:x[1], reverse=True))
a = {}
for i in d.keys():
    if m <= d[i]:
        a[i] = 0
a = sorted(a)
for i in a:
    print(i)

Submission status: Accepted

Solution code:
N = int(input())
S = dict()
for i in range(N):
    s = input()
    if s in S:
        S[s] += 1
    else:
        S[s] = 1

max_val = max(S.values())
max_key = [key for key in S if S[key] == max_val]
print("\n".join(sorted(max_key)))

Submission status: Accepted

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


C = collections.Counter(S)

M = C.most_common()
V = C.values()
MAX = max(V)

for i in range(len(M)):
    if M[i][1] == MAX:
        print(M[i][0])

Submission status: Accepted

Solution code:
import os, sys, re, math

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

d = {}
for s in S:
    if not s in d:
        d[s] = 0
    d[s] += 1

d = sorted(d.items(), key=lambda x:x[1], reverse=True)
names = [v[0] for v in d if v[1] == d[0][1]]

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

Submission status: Accepted

Solution code:
import math
import statistics
import collections
a=int(input())
#b,c=int(input()),int(input())
# c=[]
#  for i in b:
#     c.append(i)
#e1,e2 = map(int,input().split())
# f = list(map(int,input().split()))
g = [input() for _ in range(a)]
# h = []
# for i in range(e1):
#     h.append(list(map(int,input().split())))

g.sort()

ma=0
count=1
#最大値求める
for i in range(a-1):
    if g[i]==g[i+1]:
        count+=1
    else:
        ma=max(ma,count)
        count=1

ma=max(ma,count)
count=1
ans=[]
#最大値の位置
for i in range(a-1):
    if g[i]==g[i+1]:
        count+=1
    else:
        if count==ma:
            ans.append(g[i])
        count=1
if count==ma:
    ans.append(g[-1])

for i in ans:
    print(i)

Submission status: Accepted

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

res = 0
cnt = 1
for i in range(N-1):
    if S[i] == S[i+1]:
        cnt+=1
    else:
        res = max(res,cnt)
        cnt = 1

res = max(res,cnt)

cnt = 1
ans = []
for i in range(N-1):
    if S[i] == S[i+1]:
        cnt+=1
    else:
        if res == cnt:
            ans.append(S[i])
        cnt = 1

if cnt == res:
    ans.append(S[i+1])

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

Submission status: Accepted

Solution code:
import collections
n = int(input())
ans = list(input() for i in range(n))
ans = collections.Counter(ans)
m = max(ans.values())
keys = [k for k, v in ans.items() if v == m]
[print(j) for j in sorted(keys)]

Submission status: Accepted

Solution code:
from collections import defaultdict

n = int(input())
counter = defaultdict(int)
for _ in range(n):
    s = input()
    counter[s] += 1

l = [(-n, s) for s, n in counter.items()]
l.sort()
m = l[0][0]

for x, s in l:
    if x != m:
        break
    print(s)

Submission status: Accepted

Solution code:
from collections import Counter
n = int(input())
s = list(input() for i in range(n))
c = Counter(s)
m = max(c.values())
s = sorted(list(set(s)))
for i in range(len(s)):
    if c[s[i]] == m:
        print(s[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
s_max = max(A.values())
for j in sorted(k for k in A if A[k] == s_max):
  print(j)

Submission status: Accepted

Solution code:
N = int(input())
L = []
res = []

for i in range(N):
    S = input()
    L.append(S)

L.sort()

max_cnt = 0
cnt = 0

L.append(0)

for i in range(len(L) - 1):
    if L[i] == L[i+1]:
        cnt += 1
    else:
        if cnt > max_cnt:
            max_cnt = cnt
            res = []
            res.append(L[i])
        elif cnt == max_cnt:
            res.append(L[i])
        cnt = 0

for i in res:
    print(i)

Submission status: Accepted

Solution code:
n=int(input())
ans={"b":0}
ma=0
pr=[]
for i in range(n):
    name=input()
    if name in ans.keys():
        ans[name]=ans[name]+1
    else:
        ans[name]=1
for j,k in ans.items():
    if k>ma:
        ma=k 
        pr=[j]
    elif k==ma:
        pr.append(j)
pr.sort()
for l in pr:
    print(l)

Submission status: Accepted

Solution code:
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush
from bisect import bisect_left,bisect_right 
import sys,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n = inp()
d = []
s = set()
dd = {}
ind = 0
for i in range(n):
    x = input()
    if x in s:
        d[dd[x]][1] += 1
    else:
        dd[x] = ind
        d.append([x,1])
        ind += 1
        s.add(x)
d.sort(key = lambda x:x[1], reverse = True)
# print(d)
res = []
for key,va in d:
    if va < d[0][1]:
        break
    res.append(key)
res.sort()
for x in res:
    print(x)

Submission status: Accepted

Solution code:
import bisect, collections, copy, heapq, itertools, math, string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int, sys.stdin.readline().rstrip().split())
def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())

from  collections import defaultdict
from collections import Counter
def main():
    N = I()
    s_list = []
    for i in range(N):
        s = S()
        s_list.append(s)
    c = Counter(s_list)
    a = max(c.values())
    ans_list = []
    for key in c.keys():
        if c[key] == a:
            ans_list.append(key)
    ans_list.sort()
    for ans in ans_list:
        print(ans)



if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
from collections import defaultdict

def main():
    N = int(input())

    dd = defaultdict(int)

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

    maxv = max(dd.items(), key = lambda item: item[1])[-1]
    strings = [key for key, val in dd.items() if val == maxv]

    strings = sorted(strings)

    for string in strings:
        print(string)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
from collections import Counter
n = int(input())
s = list(input() for i in range(n))
c = Counter(s)
m = max(c.values())
s = sorted(list(set(s)))
for i in range(len(s)):
    if c[s[i]] == m:
        print(s[i])

Submission status: Accepted

Solution code:
N=int(input())
Sdict={}

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

vmax=max(Sdict.values())

#Sdict_sorted=sorted(Sdict.items(), key=lambda x:x[1])
#print(Sdict_sorted)

anskeys = [k for k, v in Sdict.items() if v == vmax]
for ans in sorted(anskeys):
	print(ans)

Submission status: Accepted

Solution code:
N = int(input())

dic = dict()
count = 0
for i in range(N):
    t = input()
    if t not in dic:
        dic[t] = 1
        if count==0:
            count += 1
    if t in dic:
        dic[t] += 1
        if count < dic[t]:
            count = dic[t]

ans = list()
for s in dic.keys():
    if dic[s] == count:
        ans.append(s)

ans.sort()

[print(s) for s in ans]

Submission status: Accepted

Solution code:
N = int(input())
l = []
for i in range(N):
    l.append(input())
l.sort()
a = l[0]
k = [1]
n = [str(l[0])]
for i in range(1,N):
    if a == l[i]:
        k[-1] += 1
    else:
        a = l[i]
        k.append(1)
        n.append(l[i])
m = max(k)
ans = []
for i in range(len(k)):
    if k[i] == m:
        ans.append(n[i])

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

Submission status: Accepted

Solution code:
from collections import defaultdict
n = int(input())
dic = defaultdict(int)
for i in range(n):
  dic[input()] += 1
max_s = max(dic.values())
for k, v in sorted(dic.items()):
  if v == max_s:
    print(k)

Submission status: Accepted

Solution code:
import collections
n=int(input())
s = [(input()) for _ in range(n)]
c = collections.Counter(s)
b = max(c.values())
l = [key for key in c.keys() if c[key] == b]
l.sort()
for i in l:
    print(i)

Submission status: Accepted

Solution code:
from collections import Counter
n = int(input())
s = [input() for i in range(n)]
num = Counter(s)
mx = max(num.values())
for i in sorted(num):
    if num[i] == mx:
        print(i)

Submission status: Accepted

Solution code:
N = int(input())
dic, rst = {}, []
for i in range(N):
    S = input()
    if S in dic:
        dic[S] += 1
    else:
        dic[S] = 1
max_val = max(dic.values())
[ rst.append(key) for key, val in dic.items() if val == max_val ]
[ print(i) for i in sorted(rst) ]

Submission status: Accepted

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

# ABC-081-Cの類題！
# 方針：各文字列の出現回数を数え、出現回数が最大なる文字列を昇順に出力する
 
# 各単語の出現回数を数える（辞書型を用いる！！）
dic = {}
for i in range(N):
  s = S[i]
  if s not in dic: dic[s] = 1
  else: dic[s] += 1

max_count = max(dic.values()) # 最大の出現回数
 
# 出現回数が最も多い単語を集計する
l = [key for key in dic.keys() if dic[key] == max_count]
 
# 昇順にソートして出力
for i in sorted(l):
  print(i)

Submission status: Accepted

Solution code:
N = int(input())
S = [input() for _ in range(N)]
 
# 方針：各文字列の出現回数を数え、出現回数が最大なる文字列を昇順に出力する
 
# 各単語の出現回数を数える（辞書型を用いる！！）
dic = {}
for i in range(N):
  s = S[i]
  if s not in dic: dic[s] = 1
  else: dic[s] += 1

max_count = max(dic.values()) # 最大の出現回数
 
# 出現回数が最も多い単語を集計する
l = [key for key in dic.keys() if dic[key] == max_count]
 
# 昇順にソートして出力
for i in sorted(l):
  print(i)

Submission status: Accepted

Solution code:
from collections import defaultdict
def main():
    n = int(input())
    s =defaultdict(lambda:0)
    for i in range(n):
        s[input()] += 1
    max_s = max(s.values())
    for key, value in sorted(s.items()):
        if value == max_s:
            print(key)

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
def main():
    from collections import defaultdict

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

    d = defaultdict(int)
    for s in S:
        d[s] += 1
    
    # d = sorted(d.items())
    d = sorted(d.items(), key=lambda d: d[1], reverse=True)
    res = d[0][1]
    lst = []
    for i in d:
        if res > i[1]:
            break
        lst.append(i[0])
        res = i[1]
    for i in sorted(lst):
        print(i)


if __name__ == '__main__':
    main()

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

sai = max(dic.values())

for j in sorted(k for k in dic if dic[k] == sai):
  print(j)

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
sorted_words = sorted(words.items(), key=lambda x: (-x[1], x[0]))
max_v = sorted_words[0][1]
for k, v in sorted_words:
  if v == max_v:
    print(k)
  else:
    exit()

Submission status: Accepted

Solution code:
import sys
mapin = lambda: map(int, sys.stdin.readline().split())
listin = lambda: list(map(int, sys.stdin.readline().split()))
inp = lambda: sys.stdin.readline()

N = int(inp())
mp = {}
for i in range(N):
    S = inp()
    S = S[:-1]
    if S in mp:
        mp[S] += 1
    else:
        mp[S] = 1
ans = 0
vec = []
for i in mp.values():
    if ans < i:
        ans = i
for i in mp.keys():
    if mp[i] == ans:
        vec.append(i)
vec.sort()
for i in vec:
    print(i)

Submission status: Accepted

Solution code:
N=int(input())
S=[]
for _ in range(N):
    _=input()
    S.append(_)
import collections
a=collections.Counter(S)
b=max(a.values())
new_a=[k for k, v in a.items() if v==b]
new_a.sort()
for i in range(len(new_a)):
    print(new_a[i])

Submission status: Accepted

Solution code:
N = int(input())
A1 = {}
for i in range(N):
  s = input()
  if s in A1:
    A1[s] += 1
  else:
    A1[s] = 1
sai = max(A1.values())
for j in sorted(k for k in A1 if A1[k] == sai):
  print(j)

Submission status: Accepted

Solution code:
from collections import Counter

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

c = Counter(s)
m = max(list(c.values()))
d = sorted(c.items(), key=lambda x: x[1], reverse=True)

t = set()
for i, j in d:
    if j == m:
        t.add(i)
    else:
        break
for i in sorted(t):
    print(i)

Submission status: Accepted

Solution code:
from collections import Counter

def solve():
    N = int(input())
    c = Counter([input() for _ in range(N)])
    cnt = -1
    ans = []
    for i in c.most_common():
        if cnt == -1:
            cnt = i[1]
            ans.append(i[0])
        elif cnt == i[1]:
            ans.append(i[0])
        else:
            break
    for a in sorted(ans):
        print(a)
    
if __name__ == "__main__":
    solve()

Submission status: Accepted

Solution code:
import sys
N = int(input())

input = sys.stdin.readline
lis = {}
for i in range(N):
  s = input().rstrip()
  if s in lis:
    lis[s] += 1
  else:
    lis[s] = 1
lis2 = sorted(lis.items(), key=lambda x:x[1], reverse=True)
x = next(iter(lis2))
keys = []
for i in lis2:
  if i[1] == x[1]:
    keys.append(i[0])
ans = sorted(keys)
for i in ans:
  print(i)

Submission status: Accepted

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

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

d = sorted(d.items(), key=lambda x: x[1], reverse=True)
maxv = d[0][1]
ans = []
for s in d:
    if s[1] == maxv:
        ans.append(s[0])
    else:
        break

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

Submission status: Accepted

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

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


d = sorted(d.items(), key=lambda x: x[1], reverse=True)
maxv = d[0][1]
ans = []
for s in d:
    if s[1] == maxv:
        ans.append(s[0])
    else:
        break

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

Submission status: Accepted

Solution code:
import sys
import collections

input = sys.stdin.readline

def main():
    N = int(input())
    Slist = []
    for _ in range(N):
        Slist.append(str(input()[:-1]))
    SlistCounter = list(collections.Counter(Slist).items())
    SlistCounter.sort(key=lambda x: x[0])
    SlistCounter.sort(key=lambda x: x[1], reverse=True)
    maxcnt = SlistCounter[0][1]
    for s, cnt in SlistCounter:
        if cnt != maxcnt:
            break
        print(s)

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
n=int(input())
d={}
a=[]
for i in range(n):
  s=input()
  if s not in d:
    d[s]=1
    a.append(s)
  else:
    d[s]+=1
m=max(d.values())
a.sort()
for i in a:
  if d[i]==m:
    print(i)

Submission status: Accepted

Solution code:
from collections import Counter
n = int(input())
s = [input() for i in range(n)]
num = Counter(s)
mx = max(num.values())
T = []
for n in sorted(num):
    if num[n] == mx:
        print(n)

Submission status: Accepted

Solution code:
n = int(input())
S = ['']*n
T = []
for i in range(n):
    S[i] = input()
S.sort()
if n == 1:
    print(S[0])
    exit()
cnt = 1
mxcnt = 1
for i in range(n-1):
    if S[i] == S[i+1]:
        cnt += 1
    else:
        cnt = 1
    mxcnt = max(mxcnt,cnt)
cnt = 1
for i in range(n-1):
    if S[i] == S[i+1]:
        cnt += 1
    else:
        cnt = 1
    if cnt == mxcnt:
        T.append(S[i])
if mxcnt == 1:
    T.append(S[-1])
for t in T:
    print(t)

Submission status: Accepted

Solution code:
n = int(input())

words = {}
for i 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)    
score = words_sorted[0][1]
answers = []
for word in words_sorted:
  if score == word[1]:
    answers.append(word[0])
  else :
    break
    
for answer in sorted(answers) :
  print(answer)

Submission status: Accepted

Solution code:
from collections import Counter
n = int(input())
s = [str(input()) for _ in range(n)]
num = Counter(s)
ans = []
ma = max(num.values())
for i in sorted(num):
    if num[i] == ma:
        print(i)

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

C = sorted(dic.items())
max_dic = max(dic.values())

for name,i in C:
    if i == max_dic:
        print(name)

Submission status: Accepted

Solution code:
from collections import defaultdict
N = int(input())
dic = defaultdict(lambda:0)
for _ in range(N):
    key = input()
    dic[key] += 1

maxnum = max(dic.values())
collection = []
for key, value in dic.items():
    if value == maxnum:
        collection.append(key)

collection.sort()
for word in collection:
    print(word)

Submission status: Accepted

Solution code:
N = int(input())
index = {}

for _ in range(N):
  S = input()
  if S not in index: index[S] = 1
  else: index[S] += 1

max_cnt = max(index.values())

ls = [key for key in index.keys() if index[key] == max_cnt]

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

Submission status: Accepted

Solution code:
import collections

N=int(input())
S=sorted([input() for _ in range(N)])
s=sorted(list(set(S)))
l=len(s)
c=collections.Counter(S)
max_v = max(c.values())
for i in range(l):
    if max_v==c[s[i]]:
        print(s[i])

Submission status: Accepted

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

# 方針：各文字列の出現回数を数え、出現回数が最大なる文字列を昇順に出力する

# 各単語の出現回数を数える（辞書型を用いる！！）
dic = {}
for i in range(N):
  s = S[i]
  if s not in dic: dic[s] = 1
  else: dic[s] += 1

max_count = max(dic.values()) # 最大の出現回数

# 出現回数が最も多い単語を集計する
l = [key for key in dic.keys() if dic[key] == max_count]

# 昇順にソートして出力
for i in sorted(l):
  print(i)

Submission status: Accepted

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

# 方針：各文字列の出現回数を数え、出現回数が最大なる文字列を昇順に出力する
# Counter(リスト) は辞書型のサブクラスであり、キーに要素・値に出現回数という形式
# Counter(リスト).most_common() は(要素, 出現回数)というタプルを出現回数順に並べたリスト
S = Counter(S).most_common()

max_count = S[0][1] # 最大の出現回数

# 出現回数が最も多い単語を集計する
l = [s[0] for s in S if s[1] == max_count]

# 昇順にソートして出力
for i in sorted(l):
  print(i)

Submission status: Accepted

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

# 方針：各文字列の出現回数を数え、出現回数が最大なる文字列を昇順に出力する
# Counter(リスト) は辞書型のサブクラスであり、キーに要素・値に出現回数という形式
# Counter(リスト).most_common() は(要素, 出現回数)というタプルを出現回数順に並べたリスト
S = Counter(S).most_common()
max_count = S[0][1] # 最大の出現回数
# 最大の出現回数を取る文字列を出力する
l = [s[0] for s in S if s[1] == max_count]

# 昇順にソートして出力
for i in sorted(l):
  print(i)

Submission status: Accepted

Solution code:
n=int(input())
wl={}
for i in range(n):
    w=input()
    if w not in wl:
        wl[w]=0
    wl[w]+=1
wm=max(wl.values())
wl3=sorted(wl.items())
for i in range(len(wl3)):
    if wl3[i][1]==wm:
        print(wl3[i][0])

Submission status: Accepted

Solution code:
from collections import Counter as c
N = int(input())
S = list(input() for _ in range(N))
S.sort()
C, i = c(S).most_common(), 0
l, n = len(C), C[0][1]
while i < l:
  if n == C[i][1]: print(C[i][0])
  else: break
  i += 1

Submission status: Accepted

Solution code:
from collections import Counter
n=int(input())
a=[]
for i in range(n):
  a.append(input())
ac=Counter(a)
acs=sorted(ac.items(),key=lambda x:x[1],reverse=1)
z=len(acs)
i=0
temp=[]

while i<=z-1 and acs[i][1]==acs[0][1] :
  temp.append(acs[i][0])
  i+=1
temp.sort()
for i in temp:
  print(i)

Submission status: Accepted

Solution code:
from collections import Counter

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

S = Counter(S).most_common()
l = []
for i in S:
  if i[1] == S[0][1]: l.append(i[0])

l = sorted(l)
for i in l:
  print(i)

Submission status: Accepted

Solution code:
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    from collections import Counter

    N = int(readline())
    c = Counter()

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

    _, cnt = c.most_common(1)[0]

    res = []
    for key, val in c.items():
        if val == cnt:
            res.append(key)

    res.sort()

    for x in res:
        print(x)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys
def input():
    return sys.stdin.readline()[:-1]

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

    T = sorted((set(S)))
    l = len(T)

    D = {}
    for i in range(l):
        D[T[i]] = 0
    for i in range(N):
        D[S[i]] += 1

    m = max(D.values())
    for i in range(l):
        if D[T[i]] == m:
            print(T[i])


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n = int(input())

dc = {}

def cnt_str(s , d:dict):
    if s in d.keys():
        d[s]+=1
    else:
        d[s]=1

for i in range(n):
    cnt_str(input(), dc)

maxc = max([c for k, c in dc.items()])

[print(s) for s in sorted(dc.keys()) if dc[s]==maxc]

Submission status: Accepted

Solution code:
N=int(input())
S=[input() for i in range(N)]
L=dict()
for i in range(N):
  if S[i] in L:
    L[S[i]]+=1
  else:
    L[S[i]]=1
M=max(L.values())
ans=list()
for X in L:
  if L[X]==M:
    ans.append(X)
ans.sort()
for X in ans:
  print(X)

Submission status: Accepted

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

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

ans = []
for s, v in S.items():
    if v == m:
        ans.append(s)
ans.sort()

for a in ans:
    print(a)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import collections

N = int(input())

all_str = []
for i in range(N):
    str_temp = input()
    all_str.append(str_temp)
all_str.sort()
coll_str = (collections.Counter(all_str))
count_max = 0
j = 0
max_str = coll_str.most_common()
for i in max_str:
    
    num_of_str =  i[1]
    if num_of_str == count_max or j == 0:
        print(i[0])
        j = 1
        count_max = num_of_str
        
    if num_of_str < count_max:
        break

Submission status: Accepted

Solution code:
import collections

N = int(input())

S_list = []

for i in range(N):
    s = input()
    S_list.append(s)

c = collections.Counter(S_list)
c_max = c.most_common()
max_num = c.most_common()[0][1]
ans_list = []
ans_list.append(c.most_common()[0][0])

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

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

Submission status: Accepted

Solution code:
n = int(input())
a = [input() for _ in range(n)]
cnt = {}
for i in range(n):
    if a[i] not in cnt:
        cnt[a[i]] = 1
    else:
        cnt[a[i]] += 1
mx = max(cnt.values())
ans = []
for i in cnt.keys():
    if cnt[i] == mx:
        ans.append(i)
ans.sort()
for _ in ans:
    print(_)

Submission status: Accepted

Solution code:
N = int(input())

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

d = {}
for s in S:
    if s in d:
        d[s] += 1
    else:
        d[s] = 1

maxcount = max([d[k] for k in d])
maxlist = list(filter(lambda x: d[x] == maxcount, d))
maxlist = sorted(maxlist)
for m in maxlist:
    print(m)

Submission status: Accepted

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

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

    max_appear = max(s_dict.values())
    lst = []

    for key, value in s_dict.items():
        if value == max_appear:
            lst.append(key)

    lst.sort()

    for s in lst:
        print(s)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
from collections import *
n=int(input())
l=[]
for i in range(n):
    l.append(input())
c=Counter(l)
m=max(c.values())
d=[]
for i in c:
    if(c[i]==m):
        d.append(i)
d.sort()
for i in d:
    print(i)

Submission status: Accepted

Solution code:
n=int(input())
s=[input() for _ in range(n)]
from collections import Counter
c=Counter(s)
d=[]
x=c.most_common()[0][1]
for k in c.keys():
    if c[k]==x:
        d.append(k)

d.sort()
print(*d,sep='\n')

Submission status: Accepted

Solution code:
from collections import defaultdict
dic=defaultdict(int)
n=int(input())
for _ in range(n): dic[input()]+=1
lis=sorted(dic.items(),key=lambda x:x[1],reverse=True)
M=lis[0][1]
ans=[]
for i in range(len(lis)):
    if lis[i][1]==M: ans.append(lis[i][0])
    else: break
ans.sort()
for i in ans: print(i)

Submission status: Accepted

Solution code:
n = int(input())

d = {}

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

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

name = []
cnt = dsorted[0][1]

for i in dsorted:
  if i[1] == cnt:
    name.append(i[0])
  else:
    break

name.sort()

for i in name:
  print(i)

Submission status: Accepted

Solution code:
def main():
    from sys import stdin
    from collections import Counter
    readline = stdin.readline

    n = int(readline())
    S = [readline()[:-1] for _ in [0]*n]

    s = Counter(S)
    most = s.most_common(1)[0][1]

    answers = [i[0] for i in s.items() if i[1] == most]
    answers = sorted(answers)

    for ans in answers:
        print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n= int(input())
l={}
a=0

for i in range(n):
  s=input()
  if s in l:
    l[s]+=1
  else:
    l[s]=1
  if a<l[s]:
    a=l[s]
  
ans=[]
for i in l.keys():
  if l[i]==a:
    ans.append(i)

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

Submission status: Accepted

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

import sys
from collections import Counter

count_dict = Counter(S)
most_freq = count_dict.most_common(1)[0][1]

words = []

for word, freq in sorted(count_dict.items(), key=lambda x: -x[1]):
    if freq == most_freq:
        words.append(word)

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

Submission status: Accepted

Solution code:
n= int(input())
ls={}
ma=0
for i in range(n):
  s=input()
  if s in ls:
    ls[s]+=1
  else:
    ls[s]=1
  if ma<ls[s]:
    ma=ls[s]
  
ans=[]
for i in ls.keys():
  if ls[i]==ma:
    ans.append(i)
    
ans.sort()
for j in ans:
  print(j)