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:
import collections
import sys

N=int(input())
S = []
for i in range(N):
  S.append(input())
S.sort()
c = collections.Counter(S)
ans = c.most_common()

if len(ans)==1:
  print(ans[0][0])
  sys.exit(0)
  
print(ans[0][0],sep=" ")
for i in range(N-1):
  if ans[i][1]==ans[i+1][1]:
    print(ans[i+1][0],sep=" ")
  else:
    sys.exit(0)

Submission status: Accepted

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

max_ = max(dict.values())
A = [k for k,v in dict.items() if v == max_]
A.sort()

for a in A:
    print(a)

Submission status: Accepted

Solution code:
from collections import Counter
n=int(input())
S=[]
for i in range(n):
    S.append(input())
T=Counter(S)
S=list(set(S))
M=max(T.values())
U=[]
j=0
for i in S:
    if T[i]==M:
        U.append(S[j])
    j+=1
U.sort()
for i in U:
    print(i)

Submission status: Accepted

Solution code:
n = int(input())
s = [input() for _ in range(n)]
x = dict()
s.sort()
for si in s:
  if si in x:
    x[si] += 1
  else :
    x[si] = 1

n = max(x.values())
for xi in x.keys():
  if x[xi] == n:
    print(xi)

Submission status: Accepted

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

ans = sorted(ans)

for i in ans:
    print(i)

Submission status: Accepted

Solution code:

import math
import collections

def main():
  N = int(input())
  S = list()
  S = [input() for _ in range(N)]
  
  s = collections.Counter(S)
  
  MaxCount = max(s.values())
  
  ans = []
  
  for key, value in s.items():
    if value == MaxCount:
      ans.append(key)
                 
  ans.sort()
  
  for i in ans:
    print(i)
  
  
  
  
main()

Submission status: Accepted

Solution code:
import collections

N = int(input())
S = []

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

s = collections.Counter(S)

count_max = max(s.values())

ans =[]
for key,value in s.items():
    if value == count_max:
        ans.append(key)
        
ans.sort()

for i in ans:
    print(i)

Submission status: Accepted

Solution code:
N = int(input())

word_count = {}
for _ in range(N):
    s = input()
    if s in word_count:
        word_count[s] += 1
    else:
        word_count[s] = 1

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

words = []
count = ""
for val in word_count_sorted:
    if not count:
        count = val[1]
    if count == val[1]:
        words.append(val[0])

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

Submission status: Accepted

Solution code:
from collections import Counter

N = int(input())
count = Counter([input() for _ in range(N)])
ans = []

count_max = max(count.values())

for key, value in count.items():
  if value == count_max:
    ans.append(key)
    
ans.sort()

for i in ans:
  print(i)

Submission status: Accepted

Solution code:
n = int(input())
D ={}
for i in range(n):
    s = input()
    if s in D.keys(): #sが辞書Dにあるのかチェック(これはある場合)
        D[s] += 1 #D[s] += 1 ->{'s':今までに出てきた回数+1}となる
    else:  #sが辞書Dにない場合
        D[s] = 1 #D[s] = 1 ->{'s':1}となる
maxD = max(D.values())
poll = [k for k,v in D.items() if v == maxD]
poll.sort()
for j in range(len(poll)):
    print(poll[j])

#print('\n'.join(sorted(poll)))

Submission status: Accepted

Solution code:
n = int(input())
D ={}
for i in range(n):
    s = input()
    if s in D.keys(): #sが辞書Dにあるのかチェック(これはある場合)
        D[s] += 1 #D[s] += 1 ->{'s':今までに出てきた回数+1}となる
    else:  #sが辞書Dにない場合
        D[s] = 1 #D[s] = 1 ->{'s':1}となる
maxD = max(D.values())
poll = [k for k,v in D.items() if v == maxD]
print('\n'.join(sorted(poll)))

Submission status: Accepted

Solution code:
import collections

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

s_count = collections.Counter(s)
largest = max(list(s_count.values()))
ans = []

for key in list(s_count.keys()):
    if s_count.get(key) == largest:
        ans.append(key)

ans.sort()

for word in ans:
    print(word)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import collections


n = int(input())
s = [input() for i in range(n)]
cnt = collections.Counter(s)
largest= max(list(cnt.values()))
l = []

for k in cnt.keys():
  if cnt[k] == largest:
    l.append(k)

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

Submission status: Accepted

Solution code:
import sys 
from collections import Counter
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
N = int(readline())
l = read().decode().split()
c = Counter(l)
max = c.most_common()[0][1]
ans = [i[0] for i in c.items() if i[1] >= max]
print('\n'.join(sorted(ans)))

Submission status: Accepted

Solution code:
import itertools
import functools
import math
from collections import Counter
from itertools import combinations
import re


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


C = Counter(S)
D = list(set(S))
D.sort()


max = 0
for i in range(len(D)):
    chk = C[D[i]]
    if max < chk:
        max = chk

for i in range(len(D)):
    chk = C[D[i]]
    if max == chk:
        print(D[i])

Submission status: Accepted

Solution code:
N = int(input())
word_count = {}
for i in range(N):
  word = input()
  if word in word_count.keys():
    word_count[word] += 1
  else: 
    word_count[word] = 1
sorted_word_count = sorted(word_count.items(), key=lambda x:x[1], reverse=True)
answer = []
first = True
max_count = 0
for word in sorted_word_count:
  if (first):
    answer.append(word[0])
    max_count = word[1]
    first = False
  else:
    if (max_count == word[1]):
      answer.append(word[0])
    else:
      break
sorted_answer = sorted(answer)
for a in sorted_answer:
  print(a)

Submission status: Accepted

Solution code:
n = int(input())
s = [input() for i in range(n)]
s.sort()
count = 1
ma = 0
for i in range(1,n):
    if s[i] == s[i-1]:
        count+=1
    else:
        ma = max(ma,count)
        count=1
ma = max(ma,count)
count=1
ans = []
for i in range(1,n):
    if s[i] == s[i-1]:
        count+=1
    else:
        if count == ma:
            ans.append(s[i-1])
        count=1
if count == ma:
    ans.append(s[-1])
for i in ans:
    print(i)

Submission status: Accepted

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

N = int(input())
Sss = [input().rstrip() for _ in range(N)]

cnt = Counter(Sss)

num = max(cnt.values())

anss = []
for key in sorted(cnt.keys()):
    if cnt[key] == num:
        anss.append(key)

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

Submission status: Accepted

Solution code:
n = int(input())

dic = {}
for _ in range(n):

    s =input()
    if s in dic:
        dic[s] += 1
    else:
        dic[s]=1

maxdic = max(dic.values())

ans = [i for i in dic if dic[i]==maxdic]
print('\n'.join(sorted(ans)))

Submission status: Accepted

Solution code:
from collections import defaultdict

n = int(input())
d = defaultdict(int)
m = 0
for i in range(n):
    s = input()
    d[s] += 1
    m = max(m,d[s])

ans = []
for k,v in d.items():
    if v == m:
        ans.append(k)

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

Submission status: Accepted

Solution code:
n=int(input())
l=[]
import collections
for _ in range(n):
  l.append(str(input()))
c = collections.Counter(l)
m=max(c.values())
x=[]
for i in sorted(c):
  if c[i]==m:
    print(i)

Submission status: Accepted

Solution code:
N=int(input())
D={}
M=1
for _ in range(N):
    S=input()
    if S in D:
        D[S]+=1
        M=max(M,D[S])
    else:
        D[S]=1

K=[a for a in D if D[a]==M]
K.sort()
for a in K:
    print(a)

Submission status: Accepted

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

MAX = 0
for i in range(N):
    s = input()
    A[s] = A.get(s,0) + 1
    MAX = max(MAX, A[s])

B = sorted(A.items())
for k, v in B:
    if v == MAX:
        print(k)

Submission status: Accepted

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

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_val = max(d.values())
key_list = [kv[0] for kv in d.items() if kv[1] == max_val]
for k in sorted(key_list):
    print(k)

Submission status: Accepted

Solution code:
n = int(input())
dic = {}
for i in range(n):
    s = input()
    try:
        dic[s] += 1
    except:
        dic[s] = 1
high=max(dic.values())
val= sorted(dic.items())
for i in val:
    if(i[1]==high):
        print(i[0])

Submission status: Accepted

Solution code:
n = int(input())
dic = {}
for i in range(n):
    s = input()
    try:
        dic[s] += 1
    except:
        dic[s] = 1

mx = max(dic.values())
sorted = sorted(dic.items())

ans = []
for i in sorted:
    if i[1] == mx:
        print(i[0])

Submission status: Accepted

Solution code:
c={}
for _ in range(int(input())): s=input(); c[s]=c.get(s,0)+1
m = max(c.values())
print(*sorted(k for k in c if c[k]==m))

Submission status: Accepted

Solution code:
from collections import Counter
n = int(input())
s = [input() for _ in range(n)]
s.sort()
d = Counter(s)
a = max(d.values())
for k in d.keys():
  if d[k]==a:
    print(k)

Submission status: Accepted

Solution code:
from collections import Counter
n = int(input())
s = [input() for _ in range(n)]
s.sort()
d = Counter(s)
a = 0
for v in d.values():
  if v>a:
    a = v
for k in d.keys():
  if d[k]==a:
    print(k)

Submission status: Accepted

Solution code:
N = int(input())
d = {}
M = 1

for i in range(N) :
    S = input()
    if S in d.keys() :
        d[S] += 1
        if d[S] > M :
            M = d[S]
    else :
        d.setdefault(S,1)

d = sorted(d.items())
for w,t in d :
    if t == M :
        print(w)

Submission status: Accepted

Solution code:
from collections import Counter
import numpy as np
N = int(input())
S = []
for i in range(N):
    S.append(input())

c = Counter(S)
c_keys=np.array(list(c.keys()))
c_values=list(c.values())
max_value=max(c_values)
index_list=[index for index, value in enumerate(c_values) if value == max_value]
ans_list=list(c_keys[index_list])
ans_list.sort()
for text in ans_list:
    print(text)

Submission status: Accepted

Solution code:
from collections import Counter

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

max = s[0][1]
max_s = []

for i in range(len(s)):
    if int(s[i][1]) == int(max):
        max_s.append(s[i][0])
max_s.sort()

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

Submission status: Accepted

Solution code:
def main():
    d = {}
    N = int(input())
    for i in range(N):
        s = input()
        d.setdefault(s, 1)
        d[s] += 1
    
    d = sorted(d.items())
    d = sorted(d, key=lambda x:x[1], reverse=True)
    n = d[0][1]
    for i in range(len(d)):
        if d[i][1] != n:
            break
        print(d[i][0])

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import collections

N = int(input())
S = sorted([input() for i in range(N)])
slist = collections.Counter(S)

items = list(slist.keys())
numbers = list(slist.values())

maximum = max(numbers)

for i in range(len(numbers)):
    if numbers[i] == maximum:
        print(items[i])

Submission status: Accepted

Solution code:
n = int(input())
s = dict()

cnt = 0
for _ in range(n):
    si = input()
    if si not in s.keys():
        s[si] = 1
    else:
        s[si] += 1

    cnt = max(cnt, s[si])

for k in sorted(s):
    if s[k] == cnt:
        print(k)

Submission status: Accepted

Solution code:
n = int(input())
#freq = []
#slst = []
dic1 = {}
for i in range(n):
  temp = input()
  dic1.setdefault(temp, 0)
  dic1[temp] += 1
fmax = max(dic1.values())
mflst = []
ks = list(dic1.keys())
for i in dic1:
  if dic1[i] == fmax:
    mflst.append(i)
    
mflst.sort()
for i in range(len(mflst)):
  print(mflst[i])

Submission status: Accepted

Solution code:
n=int(input())
s=[]
for _ in range(n):
  s.append(input())
import collections 
d=collections.Counter(s)
larger=max(list(d.values()))
ans=[]
for key in d.keys():
  if d[key]==larger:
    ans.append(key)
ans.sort()
for _ in range(len(ans)):
  print(ans[_])

Submission status: Accepted

Solution code:
n=int(input())
s=[]
for _ in range(n):
  s.append(input())
import collections
d=collections.Counter(s)
largest=max(list(d.values()))
ans=[]
for key in d.keys():
  if d[key]==largest:
    ans.append(key)
ans.sort(reverse=True)
while len(ans)>0:
  print(ans.pop(-1))

Submission status: Accepted

Solution code:
n=int(input())
s=[]
for _ in range(n):
  s.append(input())
import collections
d=collections.Counter(s)
largest=max(list(d.values()))
ans=[]
for key in d.keys():
  if d[key]==largest:
    ans.append(key)
ans.sort()
for _ in range(len(ans)):
  print(ans[_])

Submission status: Accepted

Solution code:
import collections
n = int(input())
s = [input() for i in range(n)]
d = collections.Counter(s)
largest = max(d.values())
ans = []
for key in d.keys():
    if d[key] == largest:
        ans.append(key)
common_values = sorted(ans)
for val in common_values:
    print(val)

Submission status: Accepted

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

count = {}
for s_i in s:
    try:
        count[ s_i ] += 1
    except KeyError:
        count[ s_i ] = 1

max_count = 0
for t in count.keys():
    if count[ t ] > max_count:
        max_count = count[ t ]

max_t = []
for t in count.keys():
    if count[ t ] == max_count:
        max_t.append( t )

max_t.sort()

for t in max_t:
    print( t )

Submission status: Accepted

Solution code:
from collections import Counter
N = int(input())
l = []
for i in range(N):
  l.append(input())
  
c = Counter(l).most_common()
ma = c[0][1]
ans = []
for i in c:
  if i[1] == ma:
    ans.append(i[0])
  else:
    break;
    
ans.sort()
for i in ans:
  print(i)

Submission status: Accepted

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

dic = {}
for i in S:
  dic[i] = 0
for i in S:
  dic[i] += 1
M = max(dic.values())
for i in dic:
  if dic[i] == M:
    print(i)

Submission status: Accepted

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

S.sort()

l=[]
c=[]
prev=S[0]
cnt=0
for n in range(len(S)):
    if S[n]==prev:
        cnt+=1
    else:
        c.append(cnt)
        cnt=1
        l.append(prev)
        prev=S[n]
if cnt!=0:
    c.append(cnt)
    l.append(prev)

max_cnt=max(c)

max_str=[]
for n in range(len(c)):
    if c[n]==max_cnt:
       max_str.append(l[n])
max_str.sort()

for e in max_str:
    print(e)

Submission status: Accepted

Solution code:
N=int(input())
t=dict()
ans=list()
for i in range(N):
    tmp=input()
    if tmp in t:
        t[tmp]+=1
    else:
        t[tmp]=1
max_v=max(t.values())
ans=[kv[0] for kv in t.items() if kv[1] == max_v]
ans.sort()
for i in ans:
    print(i)

Submission status: Accepted

Solution code:
N = int(input())

dic = {}

for _ in range(N):
    a = input()
    if a in dic:
        dic[a] += 1
    else:
        dic[a] = 1

m = max(dic.values())
l = [k for k in dic if dic[k] == m]
l.sort()
for s in l:
    print(s)

Submission status: Accepted

Solution code:
N = int(input())

dic = {}

for _ in range(N):
    a = input()
    if a in dic:
        dic[a] += 1
    else:
        dic[a] = 1

m = max(dic.values())

for s in sorted(k for k in dic if dic[k] == m):
    print(s)

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:
import sys
read = sys.stdin.read
from collections import Counter
def main():
    n, *s = read().split()
    n = int(n)
    sc = Counter(s)
    scm = sc.most_common()
    maxnum = scm[0][1]
    r = []
    for scme in scm:
        if scme[1] == maxnum:
            r.append(scme[0])
        else:
            break
    r.sort()
    print(*r, sep="\n")

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=int(input())
from collections import *
c=Counter()
for _ in range(n): c[input()]+=1
m=max(c.values())
print(*sorted(k for k,v in c.items() if v==m))

Submission status: Accepted

Solution code:
n=int(input())
c={}
for _ in range(n): s=input(); c[s]=c.get(s,0)+1
m=max(c.values())
print(*sorted(k for k,v in c.items() if v==m))

Submission status: Accepted

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

# In[12]:


import collections


# In[22]:


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


# In[26]:


mylist = collections.Counter(sorted(S)).most_common()
cnt_tmp = mylist[0][1]
for word, cnt in mylist:
    if cnt != cnt_tmp:
        break
    print(word)
    cnt_tmp = cnt


# In[ ]:

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
d = {}
for _ in range(n):
    s = str(input())
    d[s] = 1 if s not in d else d[s] + 1
M = max(d.values())
L = []
for k, v in d.items():
    if v == M:
        L.append(k)
L.sort()
for x in L:
    print(x)

Submission status: Accepted

Solution code:
import collections
N = int(input())
S = {}
for i in range(N):
    value = input()
    if value not in S:
        S[value] = 1
    else:
        S[value] += 1
S_largest = max(S.values())
S_sorted = sorted(S.items(), key=lambda x:x[1], reverse=True)
ans = []
for i in range(len(S_sorted)):
    if S_sorted[i][1] == S_largest:
        ans.append(S_sorted[i][0])
    else:
        break
ans_sorted = sorted(ans)
for a in ans_sorted:
    print(a)

Submission status: Accepted

Solution code:
n = int(input())
s = dict()
for i in range(n):
    si = input()
    if si in s:
        s[si] +=1
    else:
        s[si] = 0
l = max(s.values())
ans = []
for i in s:
    if s[i] ==l:
        ans.append(i)
ans.sort()
for i in ans:
    print(i)

Submission status: Accepted

Solution code:
n=int(input())
ar = []
for i in range(n):
    a = input()
    ar.append(a)
dic = {}

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

highest = max(dic.values())
ans = []

for keys in dic.keys():
    if dic[keys] == highest:
        ans.append(keys)

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

Submission status: Accepted

Solution code:
n=int(input())
s=dict()
for i in range(n):
    si=input()
    if si in s:
        s[si]+=1
    else:
        s[si]=0
l=max(s.values())
ans=[]
for i in s:
    if s[i]==l:
        ans.append(i)
ans.sort()
for i in ans:
    print(i)

Submission status: Accepted

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

x=co.Counter(s)
x=x.most_common()
ans=[]
m=0

for i in x:
    if i[1]<m:
        break
    else:
        ans.append(i[0])
        m=i[1]

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

Submission status: Accepted

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

c = Counter(s)
d = c.most_common()

t = []
t.append(d[0])
cnt = 1

if len(d)>1:
    for i in range(len(d)-1):
        if d[i+1][1]==t[0][1]:
            t.append(d[i+1])
            cnt+=1
        else:
            break

    t= sorted(t)

    for i in range(cnt):
        print(t[i][0])

else:
    print(d[0][0])

Submission status: Accepted

Solution code:

import collections as col

n = int(input())

s = []

for i in range(n):
    s.append(input())
    
x = col.Counter(s)

m = 0

x = x.most_common()

ans = []

for i in x:
    if i[1]<m:
        break
    else:
        ans.append(i[0])
        m = i[1]
        
ans.sort()

for i in ans:
    print(i)

Submission status: Accepted

Solution code:
n = int(input())
cnt_dict = {}
for _ in range(n):
    s = input()
    cnt_dict.setdefault(s,0)
    cnt_dict[s] += 1

cnt_t = sorted(cnt_dict.items(), key=lambda x:(-1)*x[1])

ans_s = []
max_cnt = cnt_t[0][1]
for t in cnt_t:
    if t[1] != max_cnt:
        break
    ans_s.append(t[0])

ans_s.sort()
for s in ans_s:
    print(s)

Submission status: Accepted

Solution code:
import bisect,collections,copy,heapq,itertools,math,numpy,string
import sys
sys.setrecursionlimit(10**7)

def _S(): return sys.stdin.readline().rstrip()
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())

def main():
    N = I()
    S = [_S() for _ in range(N)]
    S_count = collections.Counter(S).most_common()
    S_most = list(filter(lambda t:t[1]>=S_count[0][1],S_count))
    for s in sorted(S_most,key=lambda tup:tup[0]):
        print(s[0])

main()

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_val = max(d.values())
key_list = [kv[0] for kv in d.items() if kv[1] == max_val]
for k in sorted(key_list):
    print(k)

Submission status: Accepted

Solution code:
def resolve():
    N = int(input())
    S = [str(input()) for _ in range(N)]
    words = dict(zip(set(S), [0] * len(S)))
    for s in S:
        if s in words:
            words[s] += 1

    words = sorted(words.items(), key=lambda x: x[1], reverse=True)
    mx = words[0][1]
    words = sorted(words, key=lambda x: x[0])
    for word in words:
        if word[1] == mx:
            print(word[0])

    return


resolve()

Submission status: Accepted

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

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

mx=0
for i,j in d.items():
    if j>mx:
        mx=j

ans=[]
for i, j in d.items():
    if j==mx:
        ans.append(i)

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

Submission status: Accepted

Solution code:
N = int(input())
# input_line = [input() for _ in range(N)]
count = {}
for w in [input() for _ in range(N)]:
    if w in count:
        count[w] += 1
    else:
        count[w] = 1
max_values = max(count.values())
keys = [k for k, v in count.items() if v == max_values]
for w in sorted(keys):
    print(w)

Submission status: Accepted

Solution code:
N = int(input())
input_line = [input() for _ in range(N)]
count = {}
for w in input_line:
    if w in count:
        count[w] += 1
    else:
        count[w] = 1
max_values = max(count.values())
keys = [k for k, v in count.items() if v == max_values]
for w in sorted(keys):
    print(w)

Submission status: Accepted

Solution code:
n = int(input())
s = [input() for i in range(n)]
ans = []
d = {}
for i in s:
    d.setdefault(i, 0)
    d[i] += 1

maxv = 0
for i in d.values():
    maxv = max(maxv,i)
for i in d.keys():
    if d[i] == maxv:
        ans.append(i)

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

Submission status: Accepted

Solution code:
import collections
N=int(input())
S = [str(input()) for _ in range(N)]
c = collections.Counter(S)
most = []
most_num=c.most_common()[0][1]
for i in c.most_common():
    if i[1]==most_num:
        most.append(i[0])
most.sort()
for i in most:
    print(i)

Submission status: Accepted

Solution code:
#155
def main():
    N = int(input())
    S = [input() for i in range(N)]
    S.sort()
    ans = []
    max_len = 0
    streak = 1
    for i in range(N-1):
        if(S[i]==S[i+1]):
            streak+=1
            if(i==N-2):
                if(streak>max_len):
                    max_len = streak
                    ans = [S[i]]
                elif(streak==max_len):
                    ans.append(S[i])
        else:
            if(streak>max_len):
                max_len = streak
                ans = [S[i]]
            elif(streak==max_len):
                ans.append(S[i])
            streak=1
    if(N==1 or S[-2]!=S[-1]):
        ans.append(S[-1])
    for a in ans:
        print(a)
main()

Submission status: Accepted

Solution code:
import collections
N = int(input())
List = [str(input()) for i in range(N)]
c = collections.Counter(List)
#print(c.most_common()[0])
#print(c.most_common()[1])
#print(c.most_common())

most=[]
most_num=c.most_common()[0][1]
for i in c.most_common():
    if i[1]==most_num:
        most.append(i[0])
most.sort()
for i in most:
    print(i)

Submission status: Accepted

Solution code:
N=int(input())
S_dict={}
 
for s_idx in range(N):
    s = input()
    
    if s not in S_dict:
        S_dict.update({s:1})
    else:
        S_dict.update({s:S_dict[s]+1})
        
s_max=max(S_dict.values())
 
ans = []    
 
for a,b in S_dict.items():
    if b == s_max:
        ans.append(a)
    
ans.sort()
 
for i in ans:
    print(i)

Submission status: Accepted

Solution code:
N = int(input())
 
counter = {}
 
for i in range(N):
    temp = input()
    if temp not in counter:
        counter.update({temp : 1})
    else:
        counter.update({temp : counter[temp] + 1})
 
m = max(counter.values())
        
ans = []    
 
for a,b in counter.items():
    if b == m:
        ans.append(a)
    
ans.sort()
 
for i in ans:
    print(i)

Submission status: Accepted

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

count = Counter(s)
t = max(count.values())
ans = []
for i in count.items():
  if i[1] == t:
    ans.append(i[0])
print(*sorted(ans), sep='\n')

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
sc=[[] for _ in range(n+1)]
mx=0
for i in dic:
  sc[dic[i]].append(i)
  mx=max(mx,dic[i])

for i in sorted(sc[mx]):
  print(i)

Submission status: Accepted

Solution code:
n=int(input())
S=[]
for i in range(n):
    S.append(input())
S=sorted(S)
from collections import defaultdict
d = defaultdict(int)

for k in S:
    d[k]+=1

d=dict(d)
dmax=max(d.values())
ans=[]
for i in d.keys():
    if d[i]==dmax:
        ans.append(i)

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

Submission status: Accepted

Solution code:
import collections
N = int(input())
S = ['']*N
for T in range(0,N):
    S[T] = input()
Count = collections.Counter(S).most_common()
MaxC = Count[0][1]
Disp = []
for T in range(0,len(Count)):
    if Count[T][1] < MaxC:
        break
    Disp.append(Count[T][0])
print('\n'.join(sorted(Disp)))

Submission status: Accepted

Solution code:
# coding cell (SUBMIT ONLY THIS CELL)

N = int(input())

counter = {}

for i in range(N):
    temp = input()
    if temp not in counter:
        counter.update({temp : 1})
    else:
        counter.update({temp : counter[temp] + 1})

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

for a,b in counter.items():
    if b == m:
        ans.append(a)
    
ans.sort()

for i in ans:
    print(i)

Submission status: Accepted

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

Submission status: Accepted

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

max_count = 0
word_dict = {}
for i in range(n):
    s = input()
    if s in word_dict:
        word_dict[s] += 1
    else:
        word_dict[s] = 1
    if max_count < word_dict[s]:
         max_count = word_dict[s]

#print("{}".format(word_dict))

ret_dict = []
for k, v in word_dict.items():
    if v == max_count:
        ret_dict.append(k)
ret_dict.sort()

for ret in ret_dict:
    print("{}".format(ret))

Submission status: Accepted

Solution code:
N=int(input())
S=[input() for i in range(N)]
dictionary={}
for word in S:
  if word in dictionary:
    dictionary[word]+=1
  else:
    dictionary[word]=1
maximum=max(dictionary.values())
for key, value in sorted(dictionary.items()):
  if value==maximum:
    print(key)

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10**7) #再帰関数の上限,10**5以上の場合python
import math
from copy import copy, deepcopy
from copy import deepcopy as dcp
from operator import itemgetter
from bisect import bisect_left, bisect, bisect_right#2分探索
#bisect_left(l,x), bisect(l,x)#aはソート済みである必要あり。aの中からx未満の要素数を返す。rightだと以下
from collections import deque
#deque(l), pop(), append(x), popleft(), appendleft(x)
##listでqueの代用をするとO(N)の計算量がかかってしまうので注意
from collections import Counter#文字列を個数カウント辞書に、
#S=Counter(l),S.most_common(x),S.keys(),S.values(),S.items()
from itertools import accumulate#累積和
#list(accumulate(l))
from heapq import heapify,heappop,heappush
#heapify(q),heappush(q,a),heappop(q) #q=heapify(q)としないこと、返り値はNone
#import fractions#古いatcoderコンテストの場合GCDなどはここからimportする
from functools import lru_cache#pypyでもうごく

def input(): return sys.stdin.readline()[:-1]
def printl(li): _=print(*li, sep="\n") if li else None
def argsort(s, return_sorted=False): 
    inds=sorted(range(len(s)), key=lambda k: s[k])
    if return_sorted: return inds, [s[i] for i in inds]
    return inds
def alp2num(c,cap=False): return ord(c)-97 if not cap else ord(c)-65
def num2alp(i,cap=False): return chr(i+97) if not cap else chr(i+65)
def matmat(A,B):
    K,N,M=len(B),len(A),len(B[0])
    return [[sum([(A[i][k]*B[k][j]) for k in range(K)]) for j in range(M)] for i in range(N)]
def matvec(M,v):
    N,size=len(v),len(M)
    return [sum([M[i][j]*v[j] for j in range(N)]) for i in range(size)]
def T(M):
    n,m=len(M),len(M[0])
    return [[M[j][i] for j in range(n)] for i in range(m)]
def main():
    mod = 1000000007
    #w.sort(key=itemgetter(1),reversed=True)  #二個目の要素で降順並び替え

    N = int(input())
    #N, K = map(int, input().split())
    #A = tuple(map(int, input().split())) #1行ベクトル
    L = tuple(input() for i in range(N)) #改行ベクトル
    #S = tuple(tuple(map(int, input().split())) for i in range(N)) #改行行列

    l=Counter(L)
    m=max(l.values())
    ans=[]
    for s in l.keys():
        n=l[s]
        if n==m:
            ans.append(s)
    ans.sort()
    printl(ans)



if __name__ == "__main__":
    main()