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

words = [input() for _ in range(n)]

d = {}

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

m = max(d.values())
ANS = []

for keys in d.keys():
    if d[keys] == m:
        ANS.append(keys)

ANS = sorted(ANS)

for i in ANS:
    print(i)

Submission status: Accepted

Solution code:
from collections import Counter


def solve(string):
    n, *s = string.split()
    c = Counter(s)
    _, v = c.most_common(1)[0]
    l = sorted([k for k, _v in c.items() if _v == v])
    return "\n".join(l)


if __name__ == '__main__':
    import sys
    print(solve(sys.stdin.read().strip()))

Submission status: Accepted

Solution code:
from collections import Counter
N = int(input())
l=[input() for i in range(N)]
count=Counter(l).most_common()
d = []
most = count[0][1]
for si,c in count:
  if c==most:
    d.append(si)
d.sort()
for i in d:
  print(i)



# # O(N)
# max_word_list = [kv[0] for kv in word_count.items() if kv[1] == max(word_count.values())]

# # 辞書順にソートして出力
# max_word_list = sorted(max_word_list)
# for word in max_word_list:
#   print(word)

Submission status: Accepted

Solution code:
from collections import Counter
n=int(input())
l=[input() for i in range(n)]
count=Counter(l).most_common()
d,most=[],count[0][1]
for si,c in count:
  if c==most:
    d.append(si)
d.sort()
for i in sorted(d):
  print(i)

Submission status: Accepted

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

c = Counter(A)
maxcnt = c.most_common()[0][1]
l = []
for i in c.most_common():
  if i[1] != maxcnt:
    break
  l.append(i[0])

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

Submission status: Accepted

Solution code:
from collections import Counter

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

words = Counter(s).most_common()
d, most = [], words[0][1]
for si, c in words:
    if c == most:
        d.append(si)

for si in sorted(d):
    print(si)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
from collections import Counter
def main():
    N = int(input())
    S = [input() for i in range(N)]
    c = Counter(S)
    ans = []
    tmp = []
    tmp = c.most_common()
    cmax = c.most_common()[0][1]
    ans = [k for k , j in c.items() if j == cmax]
    ans.sort()
    print('\n'.join(ans))
if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
from collections import Counter

n = int(input())
A = [input() for _ in range(n)]
A = Counter(A)
maxw = []

v, i = zip(*A.most_common())
wordcnt = i.count(max(i))
for j in range(wordcnt):
    maxw.append(v[j])
maxw.sort()

for k in maxw:
    print(k)

Submission status: Accepted

Solution code:
from collections import Counter
k=int(input())
p=Counter(input() for f in range(k))
j=sorted(p.most_common(), key=lambda a:1-a[1])
j=[m[0] for m in j if m[1]==j[0][1]]
print("\n".join(sorted(j)))

Submission status: Accepted

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

c = collections.Counter(s)
m = c.most_common()[0]

ans = []
for _c in c.items():
    if _c[1] == m[1]:
        ans.append(_c[0])

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

Submission status: Accepted

Solution code:
N = int(input())
list0 = {}
for i in range(N):
  x = input()
  if x in list0:
    list0[x] = list0[x] + 1
  else:
    list0[x] = 1
m = max(list0.values())
k_m = [key for key in list0 if list0[key] == m]
k_m.sort()
for i in range(len(k_m)):
  print(k_m[i])

Submission status: Accepted

Solution code:
import collections
N = int(input())
S = [str(input()) for i in range(N)]
new_S = collections.Counter(S)
M = max(new_S.values())
X = []
for K,V in new_S.items():
  if V == M:
    X.append(K)
X.sort()
for x in X:
  print(x)

Submission status: Accepted

Solution code:
import collections

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

S = collections.Counter(S) 
maxFreq = S.most_common()[0][1]

S = sorted(S.items())
values, counts = zip(*S)

for v, c in zip(values, counts):
    if c == maxFreq:
        print(v)

Submission status: Accepted

Solution code:
import collections
n = int(input())
l1 = list()
for i in range(n):
  l1.append(input())
c = collections.Counter(l1)
m = max(c.values())
C = sorted(c.items())
for i in C:
  if i[1]==m:
    print(i[0])

Submission status: Accepted

Solution code:
import sys
input = lambda: sys.stdin.readline().rstrip()
d={} ; a=[]
from collections import Counter
for _ in range(int(input())):
    s=input()
    a.append(s)
d=Counter(a)
maxx=max(d.values())
ans=[]
for i in d:
    if d[i]==maxx:
        ans.append(i)
ans.sort()
for i in ans:
    print(i)

Submission status: Accepted

Solution code:
d={} ; a=[]
from collections import Counter
for _ in range(int(input())):
    s=input()
    a.append(s)
d=Counter(a)
maxx=max(d.values())
ans=[]
for i in d:
    if d[i]==maxx:
        ans.append(i)
ans.sort()
for i in ans:
    print(i)

Submission status: Accepted

Solution code:
n = int(input())
mozi = list()
for i in range(n):
    mozi.append(input())

di = dict()
for i in mozi:
    if (i in di.keys()):
        di[i] += 1
    else :
        di[i] = 1

m = max(di.values())
di = sorted(di.items())

for i in di:
    if (i[1] == m):
        print(i[0])

Submission status: Accepted

Solution code:
import collections

n = int(input())
mozi = list()
for i in range(n):
    mozi.append(input())

c = collections.Counter(mozi)
m = max(c.values())
c = sorted(c.items())

for i in c:
    if (i[1] == m):
        print(i[0])

Submission status: Accepted

Solution code:
n = int(input())

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

max = max(s.values())
s = sorted(s.items())
for i in s:
  if i[1] == max:
    print(i[0])

Submission status: Accepted

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

    #for i in range(N):
    #    S.append(input())
    #    S_uniquie = sorted(set(S))

#    S_uniquie = sorted(set(S))
#    c = 0
    target = {}

    for word in S:
        if word in target:
            target[word] += 1
        else:
            target[word] = 1
#    for i in S_uniquie:
#        c = S.count(i)
#        target[i] = c

    maximum = max(target.values())

    for key,val in sorted(target.items()):
        if(val == maximum):
            print(key)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import collections
N=int(input())
S=collections.Counter(input() for i in range(N))
maximum=max(S.values())
sort=sorted(key for key,value in S.items() if value==maximum)
for s in sort:
    print(s)

Submission status: Accepted

Solution code:
n=int(input())
d=dict()
for i in range(n):
    s=input()
    if s not in d.keys():
        d[s]=-1
    else:
        d[s]-=1

a=sorted(d.items(),key=lambda x:(x[1],x[0]))
for k,v in a:
    if v!=a[0][1]:
        break
    print(k)

Submission status: Accepted

Solution code:
n = int(input())
ans = {}
for i in range(n):
  tmp = input()
  if tmp in ans:
    ans[tmp] += 1
  else:
    ans[tmp] = 1
    
s = []
m = max(ans.values())
for i in ans.keys():
  if ans[i] == m:
    s.append(i)
[print(i) for i in sorted(s)]

Submission status: Accepted

Solution code:
import collections
#H  = map(int, input().split())
H  = int(input())
dic = collections.defaultdict(int)
for _ in range(H):
    dic[input()]+=1
ma = max(dic.values())
res = []
for k in dic.keys():
    if dic[k] == ma:
        res.append(k)
for s in sorted(res):
    print(s)

Submission status: Accepted

Solution code:
import collections

N = int(input())
words = []
top = int()
for i in range(N):
    words.append(input())
c = collections.Counter(words)

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

top = int(c_sorted[0][1])
answer = []
count = int(0)
length = len(c_sorted)
unko = str()

if length == 1:
    unko = "unko"
else:
    for i in range(N):
        if int(c_sorted[i][1]) == top:
            answer.append(c_sorted[i][0])
            count = count + 1
        else:
            break

answer.sort()

if unko == "unko":
    print(c_sorted[0][0])
else:
    for i in range(count):
        print(answer[i])

Submission status: Accepted

Solution code:
import numpy as np
import math as m

def main(**kwargs):
    c = {}
    maxc = 0

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

        else:
            c[s] = 1
        
        maxc = max(c[s], maxc)

    rs = []

    for ckey, cvalue in c.items():
        if cvalue == maxc:
            rs.append(ckey)

    rs.sort()
    r = "\n".join(rs)
    return r

if __name__ == "__main__":
    cin = np.array(input().split(" ")).astype("int")
    n, *_ = cin
    S = []
    
    for i in range(n):
        cin = input()
        S.append(cin)
    
    cout = main(n=n, S=S)
    print(cout)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
from collections import Counter
# input
n = int(input())
s = []
for i in range(n):
    s.append(input())
c = Counter(s)
# output
ma = c.most_common()[0][1]
#o = list(k for k, v in c.items() if v == c.most_common()[0][1])
o = [k for k, v in c.items() if v == ma]
# o.sort()
# print('\n'.join(o))
for i in sorted(o):
    print(i)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
from collections import Counter
# input
n = int(input())
s = []
for i in range(n):
    s.append(input())
c = Counter(s)
# output
ma = c.most_common()[0][1]
o = [k for k, v in c.items() if v == ma]
o.sort()
print('\n'.join(o))

Submission status: Accepted

Solution code:
import collections
#H  = map(int, input().split())
H  = int(input())
dic = collections.defaultdict(int)
for _ in range(H):
    dic[input()]+=1
ma = max(dic.values())
res = []
for k in dic.keys():
    if dic[k] == ma:
        res.append(k)
for s in sorted(res):
    print(s)

Submission status: Accepted

Solution code:
import collections

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

l=collections.Counter(s).most_common()
i=0
ans=[l[0][0]]
if len(l)>2:
    while i<len(l)-1 and l[i][1]==l[i+1][1]:
        ans.append(l[i+1][0])
        i+=1
ll=sorted(ans)
for i in range(len(ll)):
    print(ll[i])

Submission status: Accepted

Solution code:
n=int(input())
x=[]
for k in range(n):
  x.append(input())
x.sort()
count=[1]
head=[0]
for k in range(1,n):
  if x[k]!=x[k-1]:
    head.append(k)
    count.append(1)
  else:
    count[-1]+=1
maxim=max(count)
for k in range(len(count)):
  if count[k]==maxim:
    print(x[head[k]])

Submission status: Accepted

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

sc=Counter(s).most_common()
max_idx=sc[0][1]
ans=[]
for i, j in sc:
    if j==max_idx:
        ans.append(i)
ans=sorted(ans)
print(*ans)

Submission status: Accepted

Solution code:
import collections

n=int(input())
lst=[]
for k in range(0,n):
  lst.append(input())
c0=collections.Counter(lst)
a,b=zip(*c0.most_common())
maxb=max(b)
op=[]
for sa,sb in zip(a,b):
  if sb==maxb:
    op.append(sa)
op.sort()
for ss in op:
  print(ss)

Submission status: Accepted

Solution code:
n = int(input())
s = []
for i in range(n):
  s.append(input())
s = sorted(s)
max_count = 1
count = 1
ans = []
for i in range(n-1):
  if s[i] == s[i+1]:
    count += 1
    if count == max_count:
      ans.append(s[i])
    if count > max_count:
      max_count = count
      ans = [s[i]]
  else:
    count = 1
    if max_count == 1:
      ans.append(s[i])
if max_count == 1:
  ans.append(s[n-1])
ans = sorted(ans)
for i in range(len(ans)):
  print(ans[i])

Submission status: Accepted

Solution code:
from collections import defaultdict
n = int(input())
S = [input() for i in range(n)]
d = defaultdict(int)
num=0
for s in S:
  d[s] += 1
  if d[s] > num: num=d[s]
  
max_strs = []
for s in S:
  if d[s]==num: max_strs.append(s)

max_strs = list(set(max_strs))
max_strs.sort()
for i in range(len(max_strs)): print(max_strs[i])

Submission status: Accepted

Solution code:
n = int(input())
counts = {}
for i in range(n):
    str = input()
    if not str in counts:
        counts[str] = 0
    counts[str] += 1

most = -1
answer = []
for k, v in sorted(counts.items(), key=lambda x: x[1], reverse=True):
    if most == -1:
        most = v
    if most > v:
         break
    answer.append(k)

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

Submission status: Accepted

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

count = {}
max_v = 0
max_lst = []
for i in range(n):
    word = s[i]
    if word in count.keys():
        count[word] += 1
    else:
        count[word] = 1
    if max_v < count[word]:
        max_v = count[word]

# max_v = max(count.values())
# max_lst = [kv[1] for kv in count.items() if kv[1] == max_v]
for kv in count.items():
    if kv[1] == max_v:
        max_lst.append(kv[0])

max_lst.sort()
for w in max_lst:
    print(w)

Submission status: Accepted

Solution code:
import sys
sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))
from collections import defaultdict
def resolve():
    N = ir()
    S = defaultdict(int)
    for i in range(N):
        S[sr()] += 1
    max_value = max(S.values())
    max_k_list = sorted([kv[0] for kv in S.items() if kv[1] == max_value])
    for l in max_k_list:
        print(l)
resolve()

Submission status: Accepted

Solution code:
import sys
from math import *
from collections import deque, Counter, defaultdict
from fractions import gcd
input = lambda: sys.stdin.readline().rstrip()

def eprint(s):
    sys.stderr.write('DEBUG: {}'.format(s))
    return

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

    c = Counter(Ss)
    mc = c.most_common()
    mcn = mc[0][1]

    ans = list()

    for i in range(len(mc)):
        if mc[i][1] == mcn:
            ans.append(mc[i][0])
        else:
            break
    ans.sort()
    
    for i in range(len(ans)):
        print(ans[i])
    
    return

if __name__ == '__main__':
    main()

Submission status: Accepted

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

ans = []
c = max(d.values())
for k, v in d.items():
    if v == c:
        ans += [k]
for x in sorted(ans):
    print(x)

Submission status: Accepted

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

counter = Counter(words).most_common()
ans =[]
for i in range(int(len(counter))):
    if counter[0][1] > counter[i][1]:
        break
    ans.append(counter[i][0])
ans.sort()

for i in ans:
    print(i)

Submission status: Accepted

Solution code:
import collections

num = int(input())

num_list = []
count_list = []
ans = []

for i in range(0,num):
  num_list.append(input())

num_list_2 =collections.Counter(num_list).most_common()

for i in range(0,len(num_list_2)):
  if num_list_2[0][1] > num_list_2[i][1]:
    break
  
  ans.append(num_list_2[i][0])

ans.sort()

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

Submission status: Accepted

Solution code:
def poll(s_list):
  s_dict = {}
  for s in s_list:
    if s not in s_dict:
      s_dict[s] = 1
    else:
      s_dict[s] += 1
#  sorted_dict = sorted(s_dict.items(), key=lambda x:x[1])
  max_val = max(s_dict.values())
  max_key = [key for key in s_dict if s_dict[key] == max_val]
#  new_s_list = sorted(dict(sorted_dict).keys())
  new_s_list = sorted(max_key)
  return new_s_list

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

new_list = poll(s_list)

for s in new_list:
  print(s)

Submission status: Accepted

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy,copy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

def main():
	n = INT()
	count = Counter([input() for _ in range(n)])
	m = max(count.values())
	[print(s) for s in sorted([x for x in count if count[x] == m])]

if __name__=='__main__':
	main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import collections

if __name__ == '__main__':

    n = int(input())
    s = [input() for i in range(n)]
    c = collections.Counter(s).most_common()
    n = c[0][1]
    
    result = [i[0] for i in c if i[1] == n]
    
    for i in sorted(result):
        print(i)

Submission status: Accepted

Solution code:
N = int(input())
d = {}
max = 0
ans = []

for _ in range(N):
    key = input()
    if not(key in d):
        d[key] = 1
        if max<d[key]:
            max = d[key]
    else:
        d[key] += 1
        if max<d[key]:
            max = d[key]

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

ans.sort()

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

Submission status: Accepted

Solution code:
s = {}
m = 0
for _ in range(int(input())):
  t = input()
  if t in s:
    s[t] += 1
  else:
    s[t] = 1
  m = max(m, s[t])
ans = []
for el in s:
  if s[el] == m:
    ans.append(el)
ans.sort()
for a in ans:
  print(a)

Submission status: Accepted

Solution code:
import collections
a=int(input())
s=[input()for _ in range(a)]
c=collections.Counter(s)
m=0 
for v in c.values(): 
    m=max(m,v)
ans=[]
for k,v in c.items():
    if m == v:
        ans.append(k)
ans.sort()
for i in ans:
    print(i)

Submission status: Accepted

Solution code:
import collections

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

c = collections.Counter(l)

v, counts = zip(*c.most_common())#出現回数順に並べた要素リストと出現回数リスと

c1 = collections.Counter(list(counts))
n = c1[max(c1.keys())]

v = list(v)
v = v[:n]
v.sort()

#print(c1,n,v)
for i in v:
  print(i)

Submission status: Accepted

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

maxi = 1
count = 1
i = 0
tmp = [0]
while i<N-1:
    if S_S[i] == S_S[i+1]:
        count = count + 1
        if count > maxi:
            maxi = count
            tmp = []
        i = i + 1
    else:
        count = 1
        i = i + 1
    if maxi == count:
        tmp.append(i)
#print(maxi)
#print(S_S)
for i in range(len(tmp)):
    print(S_S[tmp[i]])

Submission status: Accepted

Solution code:
import collections
n = int(input())
s = [input() for i in range(n)]
s.sort()
t = collections.Counter(s)
maxv = max(t.values())
li = []
for key,value in t.items():
    if value == maxv:
        li.append(key)
li.sort()
for i in range(len(li)):
    print(li[i])

Submission status: Accepted

Solution code:
from collections import defaultdict

N = int(input())
d = defaultdict(int)

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

v = max(d.values())
for s in sorted([i[0] for i in d.items() if i[1]==v]):
    print(s)

Submission status: Accepted

Solution code:
n = int(input())
dic = {}
for i in range(n):
  elem = input()
  if not elem in dic:
    dic[elem] = 1
  else:
    dic[elem] += 1
max_ = max(dic.values())

res = []
for k, v in dic.items():
  if v == max_:
    res.append(k)

res = sorted(res)
for elem in res:
  print(elem)

Submission status: Accepted

Solution code:
N = int(input())
voteString = {}
count = 0
highList = []

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

for key in voteString:
  count = max(voteString[key], count)
  
for key in voteString:
  if voteString[key] == count:
    highList.append(key)

highList.sort()

for element in highList:
  print(element)

#print(voteString)

Submission status: Accepted

Solution code:
N = int(input())
S_map = {}
for _ in range(N):
    Si = input().rstrip('\r')
    if S_map.get(Si) == None:
        S_map[Si] = 1
    else:
        S_map[Si] += 1
S_map_sorted = sorted(S_map.items(), reverse=True, key=lambda x:x[1])
count = S_map_sorted[0][1]
ans = []
for s, c in S_map_sorted:
    if c == count:
        ans.append(s)
    else:
        break
for s in sorted(ans):
    print(s)

Submission status: Accepted

Solution code:
import collections

n = int(input())
s_n = [input() for i in range(n)]
c = collections.Counter(s_n).most_common()

ans = []
for index, s in enumerate(c):

    if index == 0:
        ans.append(s[0])
    elif c[index][1] == c[index-1][1]:
        ans.append(s[0])
    else:
        break
for result in sorted(ans):
    print(result)

Submission status: Accepted

Solution code:
from collections import Counter

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

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

Submission status: Accepted

Solution code:
from collections import Counter

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

c = Counter(S)

m = max(c.values())
ans = []

for i, j in c.items():
    if j == m:
        ans.append(i)
ans.sort()

for i in ans:
    print(i)

Submission status: Accepted

Solution code:
dic={}
max1=0
ans=[]
n=int(input())
for i in range(n):
    word=input()
    if word in dic:
        dic[word]+=1
    else:
        dic[word]=1

for k in dic.values():
    if k>max1:
        max1=k

for n,b in dic.items():
    if b==max1:
        ans.append(n)


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

Submission status: Accepted

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

from collections import Counter

c = Counter(s)
m = max(c.values())
ans = []
for k,v in c.items():
    if v == m:
        ans.append(k)
ans.sort()
for i in ans:
    print(i)

Submission status: Accepted

Solution code:
from collections import Counter

n = int(input())
s = [str(input()) for i in range(n)]
cnt = Counter(s)
l = max(cnt.values())  # カウントされたもので最大値を表す
ans = [s for s, c in cnt.items() if c == l]
ans.sort()
print('\n'.join(ans))

Submission status: Accepted

Solution code:
import collections

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

c = collections.Counter(S)
values, counts = zip(*c.most_common())

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

Submission status: Accepted

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

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

dic = {}    
for vote in votes:
    if vote in dic:
        dic[vote] += 1
    else:
        dic[vote] = 0

maxv = 0        

for value in dic:
    maxv = max(maxv,dic[value])

results =[]    
for value in dic:
    if dic[value] == maxv:
        results.append(value)
        
results.sort()

for result in results:
    print(result)

Submission status: Accepted

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

from collections import Counter

counter = Counter(S)
ans = []
c = counter.most_common(1)[0][1]
for word, cnt in counter.most_common():
    if cnt == c:
        ans.append(word)

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

Submission status: Accepted

Solution code:
N = int(input())

res = {}
res_res = []
biggest = 0

for i in range(N):
    x = input()
    if x not in res:
        res[x] = 1
    else:
        res[x] = res[x] + 1

for i in res:
    if res[i] > biggest:
        biggest = res[i]

for i in res:
    if res[i] == biggest:
        res_res.append(i)

res_res = sorted(res_res)

for i in res_res:
    print(i)

Submission status: Accepted

Solution code:
N = int(input())

x = {}
for _ in range(N):
    a = input()
    if a not in x:
        x[a] = 0
    x[a] += 1

mx = max(x.values())

ans = []
for k in x.keys():
    if x[k] == mx:
        ans.append(k)
ans.sort()
for a in ans:
    print(a)

Submission status: Accepted

Solution code:
from collections import defaultdict

N = int(input())
counter = defaultdict(int)
max_ = 0
for _ in range(N):
    s = input()
    counter[s] += 1
    max_ = max(counter[s], max_)

words = [word for word, n in counter.items() if n == max_]
words.sort()
for word in words:
    print(word)

Submission status: Accepted

Solution code:
# coding: utf-8

count_dic = {}

item_count = int(input().rstrip())

for i in range(item_count):
    w = input().rstrip()
    if w in count_dic:
        count_dic[w] += 1
    else:
        count_dic[w] = 1
max_count = max(count_dic.values())
keys = [k for k,v in count_dic.items() if v == max_count]
for k in sorted(keys):
    print(k)

Submission status: Accepted

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

for count in range(n):
    txt = input()
    if(txt in dict_str):
        dict_str[txt] += 1
    else:
        dict_str[txt] = 1
# print(dict_str)

max = max(dict_str.values())

ans = []
ans = [k for k, v in dict_str.items() if v == max]

ans.sort()
for txt in ans:
    # print(end='---')
    print(txt)

Submission status: Accepted

Solution code:
N=int(input())
a=[]
for i in range(N):
  a.append(input())
b={}
for j in range(len(a)):
  if a[j] in b:
    b[a[j]]+=1
  else:
    b[a[j]]=1
max_b=max(b.values())
c=[]
for k,l in b.items():
  if l==max_b:
    c.append(k)
c.sort()
for m in c:
  print(m)

Submission status: Accepted

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

dic = {}
for i in range(n):
    if s[i] in dic:
        dic[s[i]] += 1
    else:
        dic[s[i]] = 1

max_dic = max(dic.values())
ans = [i for i, j in dic.items() if j == max_dic]
ans.sort()

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

Submission status: Accepted

Solution code:
n = int(input())
moji = dict()
for i in range(n):
    s = input()
    moji[s] = moji.get(s, 0) + 1
max_cnt = max([value for value in moji.values()])
for key, value in sorted(moji.items(), key=lambda x: x[0]):
    if value == max_cnt:
        print(key)

Submission status: Accepted

Solution code:
N = input()
dic = {}
max = 0
for i in range(int(N)):
  word = input()
  if word not in dic.keys():
    
    if max == 0:
      max += 1
    dic[word] = 1
    
  else:
    
    if max == dic[word]:
      max += 1
    dic[word] += 1

candidates = sorted([word for word in dic.keys() if dic[word] == max])
for word in candidates:
  print(word)

Submission status: Accepted

Solution code:
n = int(input())
dict = {}
max = 1
for i in range(n):
  str = input()
  if str in dict:
    dict[str] = dict[str] + 1
    if dict[str] > max:
      max += 1
  else:
    dict[str] = 1
keys = [k for k, v in dict.items() if v == max]
keys.sort()
for i in range(len(keys)):
  print(keys[i])

Submission status: Accepted

Solution code:
n = int(input())

s = []

for _ in range(n):
    x = input()
    s.append(x)

s.sort()

l = [1] * n

for i in range(1, n):
    if s[i] == s[i - 1]:
        l[i] = l[i - 1] + 1

m = max(l)

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

Submission status: Accepted

Solution code:
from collections import Counter

n = int(input())
d = Counter()
for _ in range(n):
    s = input()
    d[s] += 1
mc = d.most_common()
occ = mc[0][1]
ret = []
for w, o in mc:
    if o == occ:
        ret.append(w)
    else:
        break
for w in sorted(ret):
    print(w)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
stats = {}
for i in range(N):
  s = input()
  if s not in stats:
    stats[s] = 1
  else:
    stats[s] += 1
max = max(stats.values())
out = sorted([name for name, num in stats.items() if num == max])
for i in out:
  print(i)

Submission status: Accepted

Solution code:
def main():
    dic = {}
    n = int(input())
    for _ in range(n):
        s = input().rstrip()
        if s in dic.keys():
            dic[s] += 1
        else:
            dic[s] =  1
    m = max(dic.values())
    ans = [key for key, val in dic.items() if val == m]
    for a in sorted(ans):
        print(a)

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
N= int(input())

dict = {}
for count in range(N):
    tcount = 0
    S= str(input())
    
    if S in dict.keys():
        tcount = dict[S] + 1
        dict.pop(S)
        dict[S] = tcount
    else:
        dict[S] = 1

maxval = max(dict.values())

keys = [k for k, val in dict.items() if val == maxval]
keys.sort()

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

Submission status: Accepted

Solution code:
#A155C
import sys
from collections import Counter
n = int(sys.stdin.readline())
S = [sys.stdin.readline().rstrip() for _ in range(n)]
S = Counter(S)
max_cnt = S.most_common()[0][1]

ans = [key for key, value in S.items() if value==max_cnt]

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

Submission status: Accepted

Solution code:
n = int(input())
s = [input() for _ in range(n)]
import collections
c = collections.Counter(s)
d = c.most_common()
e = [d[0][0]]
for i in range(len(d)-1): #nじゃない　dの長さ
   if d[0][1] == d[i+1][1]:
      e.append(d[i+1][0])       #辞書順にする
e.sort()
print('\n'.join(e))   #print(repr(e))でもいける？

Submission status: Accepted

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

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

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

list.sort()
for str in list:
  print(str)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
from collections import Counter


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

    SM = S.most_common()[0][1]
    S = sorted(S.items(), key=lambda x: [-x[1], x[0]])
    for key, value in S:
        if value == SM:
            print(key)
        else:
            break


if __name__ == "__main__":
    main()

Submission status: Accepted

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

S_dict = {}

for string in S_list:
    if not string in S_dict:
        S_dict[string] = 1
    else:
        S_dict[string] += 1

max_k = max(S_dict.values())
result = []
for k, v in S_dict.items():
    if v == max_k:
        result.append(k)

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