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
N=int(input())
S=[input() for i in range(N)]
cnt=collections.Counter(S)
cnt=cnt.most_common()
ans=[]
cnt=sorted(cnt,key=lambda x :x[1],reverse=True)
max=cnt[0][1]
num=len(cnt)
for i in range(num):
  if cnt[i][1]==max:
    ans.append(cnt[i][0])
ans=sorted(ans)
for i in ans:
  print(i)

Submission status: Accepted

Solution code:
n = int(input())
v_list = []
dict = {}

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

max_id = max(dict.values())
ans_list = []

for i in dict:
    if dict[i] == max_id:
        ans_list.append(i)

ans_list = sorted(ans_list)

for i in ans_list:
    print(i)

Submission status: Accepted

Solution code:
import collections
n=int(input())
ans=[]
s=["".join(input()) for _ in range(n)]
c=collections.Counter(s)
m=max(c.values())
for k,v in c.items():
  if v==m:
    ans.append(k)

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

Submission status: Accepted

Solution code:
def solve(N, Ss):
    d = {}
    _max = 0
    for s in Ss:
        d.setdefault(s, 0)
        d[s] += 1
        _max = max(_max, d[s])

    d = [x[0] for x in d.items() if x[1] == _max]
    d.sort()
    for s in d:
        print(s)


if __name__ == '__main__':
    N = int(input())
    Ss = [input() for _ in range(N)]
    solve(N, Ss)

Submission status: Accepted

Solution code:
from collections import Counter
N = int(input())
A = [None for i in range(N)]
for i in range(N):
  A[i] = input()
A = Counter(A)
keyA = list(A.keys())
valuesA = list(A.values())
most = max(valuesA)

ans = [None for _ in range(N)]
for i in range(len(valuesA)):
  if valuesA[i] == most:
    ans[i] = keyA[i]
ans = [a for a in ans if type(a) == str]
ans = sorted(ans)
for i in range(len(ans)):
  print(ans[i])

Submission status: Accepted

Solution code:
N=int(input())
S =[]
for n in range(N):
    S.append(input())
from collections import Counter
S_C = Counter(S)
S_C =sorted(S_C.items(),key = lambda x:(-x[1],x[0]) )
m = S_C[0][1]
for s in S_C:
    if m==s[1]:
        print(s[0])

Submission status: Accepted

Solution code:
from collections import Counter
n = int(input())
s = list(input() for _ in range(n))
ls = Counter(s).most_common()
a = []
a.append(ls[0][0])
for i in range(1, len(ls)):
    if ls[i][1] == ls[0][1]:
        a.append(ls[i][0])
for i in sorted(a):
    print(i)

Submission status: Accepted

Solution code:
import collections
n = int(input())
s = [input() for i in range(n)]
#print(s)
c = collections.Counter(s)
#print(c.most_common())
a = []
b = (c.most_common())
#print(b)
a.append(b[0][0])
for i in range(1,len(b)):
    if b[0][1] == b[i][1]:
        a.append(b[i][0])
print(*sorted(a))

Submission status: Accepted

Solution code:
from collections import Counter

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

counter = Counter(S)

max_val = max(counter.values())
ans = []
for key, value in counter.items():
    if value == max_val:
        ans.append(key)

ans = sorted(ans)

for s in ans:
    print(s)

Submission status: Accepted

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

from collections import Counter
ls = Counter(S).most_common()
MAX = ls[0][1]
ans = []
for s,length in ls:
    if MAX == length:
        ans.append(s)
    else:
        break;

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

Submission status: Accepted

Solution code:
N = int(input())
word_cnts = {}
curr_max = 0
for _ in range(N):
    word = input()
    if word in word_cnts:
        word_cnts[word] += 1
    else:
        word_cnts[word] = 1
    curr_max = max(curr_max, word_cnts[word])

for word in sorted(k for k in word_cnts if word_cnts[k] == curr_max):
    print(word)

Submission status: Accepted

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

D={}
for i in range(N):
    try:
        if D[S[i]]>=1:
            D[S[i]]+=1
    except:
        D[S[i]]=1
E=sorted(D.items(),key=lambda x:x[1])
m=E[-1][1]
ans=[]
for i in E:
    if i[1]==m:
        ans.append(i[0])
for i in sorted(ans):
    print(i)

Submission status: Accepted

Solution code:
n = int(input())
s = [str(input()) for i in range(n)]
dic = {}
m = 1
for a in s:
    if not a in dic:
        dic[a] = 1
    else:
        dic[a] += 1
        cnt = dic[a]
        m = max(m, cnt)
se = set()
for a in s:
    if dic[a] == m:
        se.add(a)
l = ['a'] * len(se)
for i in range(len(se)):
    l[i] = se.pop()
l.sort()
for i in range(len(l)):
    print(l[i])

Submission status: Accepted

Solution code:
dic = {}
for i in range(int(input())):
    s = input()
    if s in dic:
        dic[s] = dic[s] + 1
    else:
        dic[s] = 1
max_v = max(dic.values())
ret = [k for k, v in dic.items() if v == max_v]

ret.sort()
print('\n'.join(ret))

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys
import collections

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines


def main():
    _ = readline()
    Ss = [s.rstrip().decode() for s in readlines()]
    counter = collections.Counter(Ss)
    mc = counter.most_common()
    ans = [mc[0][0]]
    max_v = mc[0][1]
    for key, value in mc[1:]:
        if value == max_v:
            ans.append(key)
        else:
            break
    ans.sort()
    for a in ans:
        print(a)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N = int(input())
string = {}
ans = []

for _ in range(N):
    S = input()
    try:
        string[S] += 1
    except KeyError:
        string[S] = 1

most_frequent = max(string.values())

for s,num in string.items():
    if num == most_frequent:
        ans.append(s)

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

Submission status: Accepted

Solution code:
N=int(input())
s={}
maxs=0
for i in range(N):
  S=input()
  if S not in s:
    s[S]=0
  else:
    s[S]+=1
    maxs=max(maxs,s[S])
s=sorted(s.items(), key=lambda x:x[0])

ans= [S for S, i in s if i == maxs]
for A in ans:
  print(A)

Submission status: Accepted

Solution code:
import sys
#import numpy as np
import math
#from fractions import Fraction
#import itertools
from collections import deque
#import heapq
from fractions  import gcd

#input=sys.stdin.readline
n=int(input())
dic={}
for i in range(n):
    s=input()
    if s not in dic:
        dic[s]=1
    else:
        dic[s]+=1
m=max(dic.values())
dic=sorted(dic.items(),key=lambda x: x[0])
for i in range(len(dic)):
    if dic[i][1]==m:
        print(dic[i][0])

Submission status: Accepted

Solution code:
n = int(input())
S = [input() for i in range(n)]
from collections import Counter
C = Counter(S)
n = C.most_common()[0][1]
L = []
for k in C.keys():
	if C[k] == n:
		L.append(k)
print(*sorted(L), sep='\n')

Submission status: Accepted

Solution code:
N = int(input())
count = {}
for i in range(N):
    s = input()
    count.setdefault(s, 0)
    count[s] += 1
p = max(count.values())
ans = []
for k in count.keys():
    if count[k] == p:
        ans.append(k)
ans.sort()
for a in ans:
    print(a)

Submission status: Accepted

Solution code:
def main():
    n = int(input())
    ss = {}
    max_s = 0
    for _ in range(n):
        s = input()
        if s not in ss:
            ss[s] = 0
        else:
            ss[s] += 1
            max_s = max(max_s, ss[s])

    ss = sorted(ss.items(), key=lambda x: x[0])
    anss = [s for s, i in ss if i == max_s]
    for ans in anss:
        print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

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

#s = ['b','b','c','ab','ab','aa','aa','a','a']

c ={}
for i in s :
  if i in c :
    c[i] += 1
  else :
    c[i] = 1

x = max(c.values())

ans = []
for i in c.items(): # i ('a', 2)
  if i[1] == x :
    ans.append(i[0])

ans.sort()
out = '\n'.join(ans)
print(out)

Submission status: Accepted

Solution code:
#!/usr/bin/env python
import sys
from collections import Counter, defaultdict

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

    ans_name = c.most_common(1)[0][0]
    ans_val = c.most_common(1)[0][1]
    
    ans_set = set()
    ans_set.add(ans_name)

    for key in c:
        if key not in ans_set and c[key] == ans_val:
            ans_set.add(key)


    ans = list(ans_set)
    ans.sort()
    print(*ans, sep='\n')


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import collections

n = int(input())
d = {}
for _ in range(n):
    s = input()
    if d.get(s):
        d[s] += 1
    else:
        d[s] = 1
m = 0
ans = []
for k, v in d.items():
    if m < v:
        m = v
        ans = [k]
    elif m == v:
        ans.append(k)
for i in sorted(ans):
    print(i)

Submission status: Accepted

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

max_cnt=-1
for _ in range(n):
    s=input()
    d[s]+=1
    max_cnt=max(max_cnt, d[s])


ans=sorted([k for (k,v) in d.items() if v==max_cnt])
    
for a in ans:
    print(a)

Submission status: Accepted

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

if len(S) == len(set(S)):
  ans = S
else:
  ans = []
  c = collections.Counter(S)
  c_common = c.most_common()
  max_vote = c_common[0][1]
  for k in range(len(set(S))):
    if c_common[k][1]== max_vote:
      ans.append(c_common[k][0])
    else:
      break
[print(a) for a in sorted(ans)]

Submission status: Accepted

Solution code:
from collections import Counter

n = int(input())

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

c = Counter(s).most_common()


m = c[0][1]

ans = []

for i in range(len(c)):
    if c[i][1] == m:
        ans.append(c[i][0])

ans.sort()

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

Submission status: Accepted

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

dic = {}

for x in s:
    if x in dic.keys():
        dic[x] += 1
    else:
        dic[x] = 1

max_v = max(dic.values())
a = []
for k, v in dic.items():
    if v == max_v:
        a.append(k)

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

Submission status: Accepted

Solution code:
from collections import Counter
n = int(input())
s = [input() for _ in range(n)]
cnt = Counter(s)
max_v = max(cnt.values())
ans = [s for s,c in cnt.items() if c==max_v]
ans.sort()
print('\n'.join(ans))

Submission status: Accepted

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

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

dict = sorted(d.items(), key=lambda x:x[1], reverse=True)
max_v = max(d.values())

dict_li = []
for a in dict:
    if a[1]==max_v:
        dict_li.append(a[0])

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

Submission status: Accepted

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

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

dict = sorted(d.items(), key=lambda x:x[1], reverse=True)
max_v = max(d.values())

dict_li = []
for a in dict:
    if a[1]==max_v:
        dict_li.append(a[0])

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

Submission status: Accepted

Solution code:
n=int(input())
dict = {}
mx=1
for i in range(n):
  s=input()
  if s in dict:
    dict[s]+=1
    mx=max(dict[s],mx)
  else:
    dict[s]=1
v=[]
for s,i in dict.items():
  if i==mx:
    v.append(s)
print(*sorted(v))

Submission status: Accepted

Solution code:
N = int(input())
S = list()
for i in range(N):
    S.append(str(input()))

import collections

counter = collections.Counter(S)

max_cnt = max(counter.values())

names = [n for n,c in counter.items() if c==max_cnt]
names.sort()
print(*names, sep='\n')

Submission status: Accepted

Solution code:
n = int(input())

x = {}
a = [0]*n
c = []
ans = []
#a[0] input()
for i in range(0,n):
  tmp = input()
  if(tmp in x):
    valu = x.get(tmp)
    x[tmp] = valu + 1
    #print(x)
  else:
    x[tmp] = 1
    
#x = sorted(x.items(), key=lambda x:x[1])
#x = sorted(x.key())
#print(s)
ma = max(x.values())
#x = list(x)
#print(x)
i=0
for key, value in x.items():
  #print(key,value)
  if(value == ma):
    c.append(key)
    #print(key)

c.sort()
#print(c)
for i in c:
  print(i)

Submission status: Accepted

Solution code:
from collections import Counter

stdin = open(0)
N = int(stdin.readline())
S = stdin.read().split()

counter = Counter(S)
max_cnt = max(counter.values())
names = [n for n,c in counter.items() if c==max_cnt]
names.sort()
print(*names, sep='\n')

Submission status: Accepted

Solution code:

from collections import Counter

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

l = Counter(S)
m = l.most_common()[0][1]
values, counts = zip(*l.most_common())
c = counts.count(m)
v = values[:c]
for vv in sorted(v):
    print(vv)

Submission status: Accepted

Solution code:
N,*S=open(0).read().split()
import collections

C=collections.Counter(S)
M=max(C.values())
keys = [k for k, v in C.items() if v == M]
keys.sort()

for i in keys:
    print(i)

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
  else:
    d[s]+=1
    
m=max(d.values())

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

for word in a:
  print(word)

Submission status: Accepted

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

c = collections.Counter(S)
value,count = zip(*c.most_common())

s = sorted(value)
ans = []
if len(set(count)) == 1 :
    for i in s:
        print(i)
else: 
    for i in range(len(value)):
        ans.append(value[i])
        if count[i] > count[i+1]:
            [print(i) for i in sorted(ans)]
            exit()

Submission status: Accepted

Solution code:
from collections import Counter
 
N = int(input())
S = list(input() for i in range(N))
 
d = Counter(S)

num = max(d.values())
max_k_list = [i for i,j in d.items() if j == num]

ans = '\n'.join(sorted(max_k_list))
print(ans)

Submission status: Accepted

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

S_c = Counter(S)
max_count = max(S_c.values())

ans = []

for key, value in S_c.items():
  if value == max_count:
    ans.append(key)
    
ans.sort()

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

Submission status: Accepted

Solution code:
from collections import defaultdict
N=int(input())
ans=[]
d=defaultdict(int)
for _ in range(N):
    d[input()]+=1
maxv=max(d.values())
for i in d.keys():
    if d[i]==maxv:
        ans.append(i)
ans.sort()
[print(i) for i in ans]

Submission status: Accepted

Solution code:
N = int(input())
dic = {}
for _ in range(N):
    s = input()
    if not s in dic.keys():
        dic[s] = 0
    dic[s]+=1
list2 = sorted(dic.items(),key=lambda x:-x[1]) 

max1 = list2[0][1]
anslist = []
for d in list2:
    if d[1] == max1:
        anslist.append(d[0])
    else:
        break

anslist2 = sorted(anslist,key=lambda x:x)
for d in anslist2:
    print(d)

Submission status: Accepted

Solution code:
N=int(input())
li=[]
import collections

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

li.sort()

c=collections.Counter(li)
cl=c.values()
m=max(cl)
keys=[k for k,v in c.items() if v==m]
keys.sort()

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

Submission status: Accepted

Solution code:
import math
import collections

class abc_155:
    
    def __init__(self):
        pass
    
    def A(self):
       pass
    def B(self):
        pass
        
    def C(self):
        N=int(input())
        S=[input() for i in range(N)]
        c=collections.Counter(S).most_common()
        ans=[]
        ans.append(c[0][0])
        roop=c[0][1]
        
        for i in range(1,len(c)):
            if roop==c[i][1]:ans.append(c[i][0])
            else:break
        ans.sort()
        for i in ans:print(i)
                
    def D(self):
        pass
        
    def E(self):
        pass
    
    def F(self):
        pass
    
    
if __name__=='__main__':
    obj=abc_155()
    obj.C()

Submission status: Accepted

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

SC = Counter(S)
max_count = max(SC.values())

ans = []

for key,value in SC.items():
  if value == max_count:
    ans.append(key)

ans.sort()

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

Submission status: Accepted

Solution code:
# import sys
# import math
# import itertools
# from collections import deque
# from collections import defaultdict
# import heapq
# import copy
# import bisect
# import numpy as np
# from scipy.special import comb

# def my_input(): return sys.stdin.readline().rstrip()
# sys.setrecursionlimit(100000)
# INF = 1001001001001
# MOD = 1000000007


def main():

    N = int(input())
    d = dict()

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

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

    l = -1
    ans = []
    for k, v in d:
        if v < l:
            break
        else:
            l = v
            ans.append(k)

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


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
from collections import Counter

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

dic = Counter(S)

max = dic.most_common()[0][1]
ans = sorted([i[0] for i in dic.items() if i[1] == max])

for v in ans:
    print(v)

Submission status: Accepted

Solution code:
from collections import Counter
n=int(input())
s=[input() for _ 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)

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

Submission status: Accepted

Solution code:
# For taking integer inputs.
import math


def inp():
    return(int(input()))


# For taking List inputs.
def inlist():
    return(list(map(int, input().split())))


# For taking string inputs. Actually it returns a List of Characters, instead of a string, which is easier to use in Python, because in Python, Strings are Immutable.
def instr():
    s = input()
    return(list(s[:len(s)]))


# For taking space seperated integer variable inputs.
def invr():
    return(map(int, input().split()))


N = inp()
count = dict()
while N:
    s = input()
    if s in count:
        count[s] += 1
    else:
        count[s] = 1
    N -= 1
m = max(count.values())
res = []
for key, value in count.items():
    if value == m:
        res.append(key)
res = sorted(res)
for i in res:
    print(i)

Submission status: Accepted

Solution code:
from collections import defaultdict
n = int(input())
dics = defaultdict(int)
for i in range(n):
    s = input()
    dics[s] += 1
max_v = max(dics.values())
max_k_list = [kv[0] for kv in dics.items() if kv[1] == max_v]
max_k_list.sort()
print(*max_k_list, sep='\n')

Submission status: Accepted

Solution code:
import collections
n = int(input())
l = []
s = collections.Counter([input() for i in range(n)])
mn = 0
for i in s.most_common():
    if i[1] >= mn:
        mn = i[1]
        l.append(i[0])
    else:
        break
for i in sorted(l):
        print(i)

Submission status: Accepted

Solution code:
import collections
N = int(input())
S = [input() for _ in range(N)]
C = collections.Counter(S)
MAX = 0
L = []
for c in C.most_common():
    if c[1] > MAX:
        MAX = c[1]
        L = [c[0]]
    elif c[1] == MAX:
        L.append(c[0])
for l in sorted(L):
    print(l)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
A={}
for i in range(N):
    tmp=input()
    if tmp in A:
        A[tmp]+=1
    else:
        A[tmp]=1
        
B=max(A.values())
keys = [k for k, v in A.items() if v == B]
nk=sorted(keys)

print(*nk,sep='\n')

Submission status: Accepted

Solution code:
import collections
def main():
    N = int(input())
    S = [input() for _ in range(N)]
    coll = collections.Counter(S)
    maxval = max(coll.values())
    ans = []
    for k,v in coll.most_common():
        if v!=maxval:
            break
        ans.append(k)
    print(*sorted(ans), sep="\n")

main()

Submission status: Accepted

Solution code:
def main():
    n = int(input())
    a = [input() for _ in range(n)]
    
    d = {}
    for i in a:
        if i in d:
            d[i] += 1
        else:
            d[i] = 1
    m = max(d.values())
    for k, v in sorted(d.items()):
        if v == m:
            print(k)
    
if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
from collections import Counter
n = int(input())
s = [input() for i in range(n)]
c = Counter(s)
m = c.most_common()[0][1]
l = []
for i in c.keys():
    if c[i] == m:
        l.append(i)
l.sort()
print(*l, sep="\n")

Submission status: Accepted

Solution code:
from collections import Counter

N = int(input())
counter = Counter()

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

results = sorted([k for k, v in counter.items() if v == max_count])
print('\n'.join(results))

Submission status: Accepted

Solution code:
from collections import Counter

N = int(input())
counter = Counter()

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

max_count = max(counter.values())

results = sorted([k for k, v in counter.items() if v == max_count])
print('\n'.join(results))

Submission status: Accepted

Solution code:
from collections import Counter
N = int(input())
S = Counter([input() for i in range(N)])
most = S.most_common()[0][1]
ans = []
for name, num in S.items():
  if num != most:
    continue
  ans.append(name)
ans.sort()
for a in ans:
  print(a)

Submission status: Accepted

Solution code:
n = int(input())

import collections

s = [0]*n
for i in range(n):
    s[i] = input()
c = collections.Counter(s)

D = []
for k, v in sorted(c.items(), key=lambda x: -x[1]):
    D.append([k,v])
sortsecond = lambda val : -val[1]
D.sort(key=sortsecond)

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

Submission status: Accepted

Solution code:
n = int(input())
s = []
while True:
    try:
        s.append(input())
    except EOFError:
        break

word_counter = {}
for word in s:
    if word in word_counter:
        word_counter[word] += 1
    else:
        word_counter[word] = 0

results = sorted(word_counter.items(), key=lambda x: x[1], reverse=True)
max_v = results[0][1]

pick_ups = [result[0] for result in results if result[1] == max_v]
sorted_pick_ups = sorted(pick_ups)
print(*sorted_pick_ups, sep='\n')

Submission status: Accepted

Solution code:
#参考
def resolve():
    n=int(input())
    dic={}
    for _ in range(n):
        s=input()
        if not s in dic.keys():
            dic[s]=0
        else:
            dic[s]+=1
    m=max(dic.values())
    ans=[]
    for each in dic.keys():
        if dic[each]==m:
            ans.append(each)
    for each in sorted(ans):
        print(each)
resolve()

Submission status: Accepted

Solution code:
#10e5程度ならソートしてもTLEならないらしい？
n = int(input())
dic = {}
lis = []
lis2 = []

for i in range(n):
  moji = input()
  if moji not in dic:
    dic[moji] = 0
  dic[moji] += 1
  
for i in sorted(dic.items(), key=lambda x:x[1]):
    lis.append(i)
  
lis.reverse()

for j in lis:
  if lis[0][1] == j[1]:
    lis2.append(j[0])
  else:
    break

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

Submission status: Accepted

Solution code:
n = int(input())
dic = {}
lis = []
lis2 = []

for i in range(n):
  moji = input()
  if moji not in dic:
    dic[moji] = 0
  dic[moji] += 1
  
for i in sorted(dic.items(), key=lambda x:x[1]):
    lis.append(i)
  
lis.reverse()

for j in lis:
  if lis[0][1] == j[1]:
    lis2.append(j[0])
  else:
    break

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

Submission status: Accepted

Solution code:
import collections
from collections import Counter
n=int(input())
s=[input() for i in range(n)]
s=Counter(s)
p=[]
k=s.most_common()
p.append(k[0][0])
for i in range(len(collections.Counter(s))-1):
    if k[i][1]==k[i+1][1]:
        p.append(k[i+1][0])
    else:
        break
p=sorted(p)
for i in range(len(p)):
    print(p[i])

Submission status: Accepted

Solution code:

def resolve():
    n=int(input())
    dic={}
    for _ in range(n):
        s=input()
        if not s in dic.keys():
            dic[s]=0
        else:
            dic[s]+=1
    m=max(dic.values())
    ans=[]
    for each in dic.keys():
        if dic[each]==m:
            ans.append(each)
    for each in sorted(ans):
        print(each)
resolve()

Submission status: Accepted

Solution code:
from collections import defaultdict

n = int(input())

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

count_max = max(s_dict.values())
s_list = sorted([s for s, count in s_dict.items() if count == count_max])
print("\n".join(s_list))

Submission status: Accepted

Solution code:
from collections import defaultdict

n = int(input())

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

count_max = max(s_dict.values())
s_list = sorted([s for s, count in s_dict.items() if count == count_max])
for s in s_list:
    print(s)

Submission status: Accepted

Solution code:
from collections import defaultdict
n = int(input())
s_dict = defaultdict(int)
for _ in range(n):
    s_dict[input()] += 1
count_max = sorted(s_dict.values())[-1]
s_list = sorted([s for s, count in s_dict.items() if count == count_max])
for s in s_list:
    print(s)

Submission status: Accepted

Solution code:
from collections import defaultdict
from operator import itemgetter

n = int(input())

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

def multisort(xs, specs):
    for key, reverse in reversed(specs):
        xs.sort(key=itemgetter(key), reverse=reverse)
    return xs

s_list = multisort(list(s_dict.items()), ((1, True), (0, False)))
count_max = s_list[0][1]
for s, count in s_list:
    if count < count_max:
        break
    print(s)

Submission status: Accepted

Solution code:
n = int(input())
a = [input() for i in range(n)]
a.sort()
b =[]
k = 1
tmp = 1
d = 0
for i in range(n):
    if(i == 0):
        d = a[i]
        continue;
    if(a[i] != d):
        if(tmp == k):
            b.append(d)
        elif(tmp > k):
            k = tmp
            b = []
            b.append(d)
        tmp = 0
    tmp += 1
    d = a[i]

    if(i == n-1):
        if(tmp == k):
            b.append(a[i])
        elif(tmp > k):
            k = tmp
            b = []
            b.append(a[i])

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

Submission status: Accepted

Solution code:
N = int(input())
M = { }
for i in range(N):
  S = input()
  if S not in M:
    M[S] = 0
  M[S] += 1
#print(M)
n = max(M.values())
l = []
for S in M.keys():
  if M[S] == n:
    l.append(S)
l.sort()
for S in l:
  print(S)

Submission status: Accepted

Solution code:
count = 0
ans = []
dic = {}
n = int(input())
for i in range(n):
    s = input()
    number = dic.get(s, 0) + 1
    count = max(count, number)
    dic[s] = number
for key in dic:
    if dic[key] == count:
        ans.append(key)
ans.sort()
for k in ans:
    print(k)

Submission status: Accepted

Solution code:
import sys
import math
import itertools
import numpy
import collections

rl = sys.stdin.readline

n = int(rl())

li = []
for _ in range(n):
    li.append(rl().rstrip())
c = collections.Counter(li)
max_cnt = 0
li = []
for k, v in c.items():
    if v < max_cnt:
        continue
    elif v == max_cnt:
        li.append(k)
    else:
        max_cnt = v
        li = [k]
li.sort()
print('\n'.join(li))

Submission status: Accepted

Solution code:
import sys
import math
import itertools
import numpy
import collections

rl = sys.stdin.readline

n = int(rl())

li = []
for _ in range(n):
    li.append(rl().rstrip())
c = collections.Counter(li)
max_cnt = 0
li = []
for k, v in c.items():
    if v < max_cnt:
        continue
    elif v == max_cnt:
        li.append(k)
    else:
        max_cnt = v
        li = [k]
li.sort()
for i in li:
    print(i)

Submission status: Accepted

Solution code:
import sys
import math
from decimal import Decimal, ROUND_HALF_UP, ROUND_HALF_EVEN
from collections import deque
from bisect import bisect_left
from itertools import product
def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
#文字列を一文字ずつ数字に変換、'5678'を[5,6,7,8]とできる
def LSI(): return list(map(int, list(sys.stdin.readline().rstrip())))
def LSI2(N): return [list(map(int, list(sys.stdin.readline().rstrip()))) for i in range(N)]
#文字列として取得
def ST(): return sys.stdin.readline().rstrip()
def LST(): return sys.stdin.readline().rstrip().split()
def LST2(N): return [sys.stdin.readline().rstrip().split() for i in range(N)]
def FILL(i,h): return [i for j in range(h)]
def FILL2(i,h,w): return [FILL(i,w) for j in range(h)]
def FILL3(i,h,w,d): return [FILL2(i,w,d) for j in range(h)]
def FILL4(i,h,w,d,d2): return [FILL3(i,w,d,d2) for j in range(h)]
def sisha(num,digit): return Decimal(str(num)).quantize(Decimal(digit),rounding=ROUND_HALF_UP)
#'0.01'や'1E1'などで指定、整数に戻すならintをかます
MOD = 1000000007
INF = float("inf")
sys.setrecursionlimit(10**6+10)

N = I()
d = {}
for i in range(N):
    s = ST()
    d[s] = d.get(s,0)+1
    max_i = 0
for k,i in d.items():

    if i>max_i:
        ans = [k]
        max_i = i
    elif i == max_i:
        ans.append(k)
ans.sort()
for i in ans:
    print(i)

Submission status: Accepted

Solution code:
N = int(input())
S = [input() for _ in range(N)]
from collections import Counter
c = Counter(S)
name = []
num = 0
for k,v in c.items():
    if v>num:
        num = v
        name = [k]
    elif v == num:
        name.append(k)
n_sort = sorted(name)
for i in range(len(n_sort)):
    print(n_sort[i])

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
from collections import Counter

n = int(input())
s = [input() for _ in range(n)]
cnt = Counter(s)
m = max(cnt.values())
ans = []
for k, v in cnt.items():
    if v == m:
        ans.append(k)
print(*sorted(ans), sep="\n")

Submission status: Accepted

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