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: Time Limit Exceeded

Solution code:
n=int(input())
lisa=[]
for i in range(n):
    a=input()
    lisa.append(a)
ans=0
add=[]
for i in range(n):
    if ans<lisa.count(lisa[i]):
        ans=lisa.count(lisa[i])
for i in range(n):
    if lisa.count(lisa[i])==ans:
        add.append(lisa[i])
add=sorted(list(set(add)))
for i in range(len(add)):
    print(add[i])

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
all_str = []
count = 0
for i in range(N):
  in_str = input()
  all_str.append(in_str)
  if count < all_str.count(in_str):
    count = all_str.count(in_str)

max_all_str = []
for i in range(N):
  if (all_str.count(all_str[i]) == count) & (max_all_str.count(all_str[i]) == 0) :
    max_all_str.append(all_str[i])
max_all_str = sorted(max_all_str)

for i in max_all_str:
  print(i)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

S = []
for i in range(n):
    S.append(input())
    
count = {}
for s in S:
    if s in count:
        count[s] += 1
    else:
        count[s] = 1
        
res = [kv[0] for kv in count.items() if kv[1] == max(count.values())]
res.sort()

for i in res:
    print(i)

Submission status: Time Limit Exceeded

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

n = d[max(d)]

res = [kv[0] for kv in d.items() if kv[1] == max(d.values())]

res.sort()

for s in res:
    print(s)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

target = dict()
for i in range(N):
	S = str(input())
	if S in target:
		count = target[S]
		target[S] += 1
	else: 
		target[S] = 1
ans = [k for k, v in target.items() if v == max(target.values())]
ans.sort()

for i in ans:
	print(i)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
s_list, s_set = [], []
max_count, max_string = 0, []
for _ in range(n):
    s_list.append(input())
s_set = list(set(s_list))
for s in s_set:
    s_count = s_list.count(s)
    if s_count == max_count:
        max_string.append(s)
    elif s_count > max_count:
        max_count = s_count
        max_string.clear()
        max_string.append(s)

max_string = sorted(list(max_string))

for s in max_string:
    print(s)

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
S=[input() for _ in range(n)]
S_set = set(S)
setl = sorted(S_set)
cnt={}

for s in S_set:
    cnt[s] = S.count(s)

m=max(cnt.values())
L=[]

for a in setl:
    if cnt[a] == m:
        print(a)

Submission status: Time Limit Exceeded

Solution code:
N=int(input())
KnL=[]
VnL=[]

for _ in range(N):
  inp=str(input())
  if not inp in KnL:
    KnL.append(inp)
    VnL.append([0,inp])
  VnL[KnL.index(inp)][0]+=1

VnL.sort()
VnL.reverse()

CL=[]
for i in range(len(VnL)):
  if VnL[0][0]>VnL[i][0]:
    break
  CL.append(VnL[i][1])

CL.sort()
for j in range(len(CL)):
  print(CL[j])

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

dic = {}

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

max_k_list = [kv[0] for kv in dic.items() if kv[1] == max(dic.values())]
max_k_list.sort()

for s in max_k_list:
    print(s)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
S = []
for x in range(N):
    S.append(input())
maxi = max([S.count(x) for x in S])
P = sorted(set([x for x in S if S.count(x) == maxi]))
for x in P:
    print(x)

Submission status: Time Limit Exceeded

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

for i in range(n):
    tmpword=input()
    if tmpword in word:
        word[tmpword] = word[tmpword]+1
    else:
        word[tmpword] = 1


#ans.append(max(word.items(),key=lambda x:x[1])[0])
ans=[k for k, v in word.items() if v == max(word.values())]
ans.sort()
for i in ans:
    print(i)

Submission status: Time Limit Exceeded

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

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

SS = sorted(list((set(S))))
count = list()
for ss in SS:
    count.append(S.count(ss))

m = max(count)
ans = list()
for i in range(len(count)):
    if count[i] == m:
        print(SS[i])

Submission status: Time Limit Exceeded

Solution code:
# AtCoder Beginner Contest 155: C (2020/02/16)
N = int(input())
A = []
C = []
for i in range(N):
    S = str(input())
    if S not in A:
        A.append(S)
        C.append(1)
    else:
        C[A.index(S)] = C[A.index(S)] + 1
cnt = max(C)
X = []
for i in range(len(A)):
    if C[i] == cnt:
        X.append(A[i])
X.sort()
for i in range(len(X)):
    print(X[i])

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
s = []
ns = []

for i in range(n):
  text = input()
  if s.count(text) != 0:
    ns[s.index(text)] += 1
  else:
    s.append(text)
    ns.append(1)

maxn = max(ns)
ms = []
for i in range(len(s)):
  if ns[i] == maxn:
    ms.append(s[i])

ms.sort()

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

Submission status: Time Limit Exceeded

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

ss = set(s)
ans = 0
ma = 0
li = []
for i in ss:
    ans = s.count(i)
    if(ans==ma):
        li.append(i)
    if(ans>ma):
        ma = ans
        li = [i]

li.sort()


if(len(li)==1):
    print(li[0])
else:
    for i in li:
        print(i)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

S_list = []
S_count = []
ans = set()

for _ in range(N):
    S = input()
    if (S in S_list):
        S_count[S_list.index(S)] += 1
    else:
        S_list.append(S)
        S_count.append(0)

M = max(S_count)

for i, s in enumerate(S_count):
    if s == M:
        ans.add(S_list[i])

ans = sorted(ans)

for a in ans:
    print(a)

Submission status: Time Limit Exceeded

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

a = []
a_num = []

for i in range(n):
    if s[i] not in a:
        a.append(s[i])
        a_num.append(0)
    else:
        a_num[a.index(s[i])] += 1

ans_num = max(a_num)
ans = []

for i in range(len(a)):
    if a_num[i] == ans_num:
        ans.append(a[i])
ans.sort()
print("\n".join(ans))

Submission status: Time Limit Exceeded

Solution code:
t = int(input())
txl = []
for i in range(t):
  txl.append(input())
txr0 = txl.copy()
txr0 = list(set(txr0))
td0 = {}
for i in range(len(txr0)):
  td0[txr0[i]] = txl.count(txr0[i])
td1 = sorted(td0.items(), key=lambda x:x[1], reverse=True)
v = 0
l1 = []
for i in range(len(td1)):
  if i == 0:
    l1.append(td1[i][0])
    v = int(td1[i][1])
  else:
    if int(td1[i][1]) < v:
      break
    else:
      l1.append(td1[i][0])
      v = int(td1[i][1])
for i in range(len(l1)):
  print(sorted(l1)[i])

Submission status: Time Limit Exceeded

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

n=int(input())  #数値入力 「N」だけの入力のとき
i=0
lst ={}
while i < n: 
    s = input()
    if s not in lst:
        lst[s]=1
    else:
        lst[s]+=1
    i+=1

max_lst = [kv[0] for kv in lst.items() if kv[1] == max(lst.values())]
max_lst.sort()
for i in max_lst:
    print(i)
# ans = sorted(lst.items(), key=lambda x:x[1])
# for key in ans:
#     print(key)

Submission status: Time Limit Exceeded

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

Max = max(d.values())
max_k_list = [kv[0] for kv in d.items() if kv[1] == max(d.values())]
max_k_list.sort()
for i in max_k_list:
    print(i)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
s = [input() for i in range(n)]
l = set(s)
l = list(sorted(l))
ans = 0
ans_l = []
for i in l:
    if s.count(i) > ans:
      ans_l = [i]
      ans = s.count(i)
    elif s.count(i) == ans:
      ans_l.append(i)
print("\n".join(ans_l))

Submission status: Time Limit Exceeded

Solution code:
from collections import Counter
N = int(input())
S = Counter([input() for _ in range(N)])
v = S.values()
if len(S) == 1:
    print(list(S)[0])
    exit()

for x in sorted([key for key, val in list(S.most_common()) if val == max(v)]):
    print(x)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

s_dict={}
for i in range(n):
  s=str(input())
  if s not in s_dict:
    s_dict[s] = 1
  else:
    s_dict[s] += 1  
    
ans = [k for k, v in s_dict.items() if v == max(s_dict.values())]
for a in sorted(ans):
  print(a)

Submission status: Time Limit Exceeded

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

for i in range(n):
  if ans_number < s.count(s[i]):
    ans_number = s.count(s[i])
    
s_max = []
for i in range(n):
  if s.count(s[i]) == ans_number:
    s_max.append(s[i])
    
s_max = list(set(s_max))
s_max.sort()
for i in range(len(s_max)):
  print(s_max[i])

Submission status: Time Limit Exceeded

Solution code:
from collections import Counter
n=int(input())
s = [0]*n
for i in range(n):
    s[i]=input()
d = Counter(s)
max_k_list = [kv[0] for kv in d.items() if kv[1] == max(d.values())]
max_k_list.sort()
for i in max_k_list:
    print(i)

Submission status: Time Limit Exceeded

Solution code:
n= int(input())
s= [input() for i in range(n)]
p=set(s)
p1=list(p)
N=len(p)
c=[0]*N
for i in range(N):
	c[i]=s.count(p1[i])
m =max(c)
c1=c.count(m)
ans =[]
for i in range(N):
	if c[i]==m:
		ans.append(p1[i])
ans1 = sorted(ans)
for i in range(c1):
	print(ans1[i])

Submission status: Time Limit Exceeded

Solution code:
import collections
N = int(input())
s = [input() for i in range(N)]
counter = collections.Counter(s)
max_k_list = [kv[0] for kv in dict(counter).items() if kv[1] == max(dict(counter).values())]
for i in range (len(max_k_list)):
  print(sorted(max_k_list)[i])

Submission status: Time Limit Exceeded

Solution code:
import collections

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

c = collections.Counter(S)

ans = [i[0] for i in c.items() if i[1] >= c.most_common(1)[0][1]]
ans.sort()

for a in ans:
    print(a)

Submission status: Time Limit Exceeded

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

words ={}

for si in S:
    if si not in words.keys():
        words[si] = 1
    else:
        words[si] += 1

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

max_n = words_sorted[0][1]

for w in words_sorted:
    if w[1] == max_n:
        print(w[0])
    else:
        break

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
d = {}
for _ in range(n):
    s = input()
    if not s in d:
        d[s] = 1
    else:
        d[s] += 1
ans = [k for k, v in d.items() if v == max(d.values())]
print('\n'.join(map(str, sorted(ans))))

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
s_list = []
max_count, max_string = 0, []
for _ in range(n):
    s_list.append(input())

for s in s_list:
    if s_list.count(s) == max_count:
        max_string.append(s)
    elif s_list.count(s) > max_count:
        max_count = s_list.count(s)
        max_string.clear()
        max_string.append(s)

max_string = sorted(list(set(max_string)))

for s in max_string:
    print(s)

Submission status: Time Limit Exceeded

Solution code:
import collections
n = int(input())
l = []
for i in range(n):
    s = str(input())
    l.append(s)
l = collections.Counter(l)
t = [kv[0] for kv in l.items() if kv[1] == max(l.values())]
t.sort()
for i in range(len(t)):
    print(t[i])

Submission status: Time Limit Exceeded

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

d = {}

max_v = 0
for w in w_l:
    if d.get(w, 0) == 0:
        d[w] = 1
    else:
        d[w] += 1

max_k_list = [kv[0] for kv in d.items() if kv[1] == max(d.values())]

max_k_list.sort()

for k in max_k_list:
    print(k)

Submission status: Time Limit Exceeded

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

num = 0
for i in l:
   num = max(num,l.count(i)) 
ans = []
for i in l:
    if num == l.count(i):
        ans.append(i)

l= list(set(ans))
l.sort()
for i in l:
    print(i)

Submission status: Time Limit Exceeded

Solution code:
import numpy as np

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

a=sorted(a)
b=[]
c=[]

tmp="."
count=0

for i in range(n):
  if tmp != a[i]:
    b.append(tmp)
    c.append(count)
    tmp=a[i]
    count=1
  else:
    count += 1
 
b.append(tmp)
c.append(count)

for i in range(len(b)):
  if c[i]==np.max(c):
    print(b[i])

Submission status: Time Limit Exceeded

Solution code:
from collections import defaultdict

d = defaultdict(int)
S = []

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

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

max_kv_list = [kv for kv in d.items() if kv[1] == max(d.values())]

for k,v in sorted(max_kv_list):
    print(k)

Submission status: Time Limit Exceeded

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

# setに変換
setS = set(s)

maxList = []
maxCount = 0
for word in setS:
    # 文字列の出現回数を数える
    cnt = s.count(word)
    if cnt > maxCount:
        maxCount = cnt
        # 初期化
        maxList = []
        maxList.append(word)
    elif cnt == maxCount:
        maxList.append(word)

maxList.sort()

for word in maxList:
    print(word)

Submission status: Time Limit Exceeded

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

s = set(l)
c = [l.count(i) for i in s]

res = sorted([[c[i],list(s)[i]] for i in range(len(s))],key=lambda x: (-x[0],x[1]))
[print(i[1]) for i in res if i[0] == res[0][0]]

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
A = []
B = set()

for i in range(N):
    a = input()
    A.append(a)
    B.add(a)

B_ = list(B)
A.sort()
B_.sort()
ma = 0

for i in B_:
    if ma < A.count(i):
        ma = A.count(i)

for i in B_:
    if ma == A.count(i):
        print(i)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

S = list()
counter = list()

for _ in range(N):
	s = input()
	if s in S:
		index = S.index(s)
		counter[index] += 1
	else:
		S.append(s)
		counter.append(1)

# print(counter)
max_value = max(counter)

ans = list()
for i,x in enumerate(counter):
	if x == max_value:
		ans.append(S[i])

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

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
S = []
for i in range(N):
    S.append(input())
MAX = 0
for i in range(N):
    MAX = max(S.count(S[i]),MAX)
SET = []
for i in range(N):
    if S.count(S[i])==MAX:
        SET.append(S[i])
SET = list(set(SET))
SET.sort()
for item in SET:
    print(item)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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
l = [k for k, v in d.items() if v == max(d.values())]
print('\n'.join(sorted(l)))

Submission status: Time Limit Exceeded

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

import collections

c = collections.Counter(S)

ls_ans = []
ls_ans.append( c.most_common()[0][0] )

a = c.most_common()[0][1]
for i in range(1,len(c)):
    if c.most_common()[i][1]==a:
        ls_ans.append(c.most_common()[i][0])
    else:
        break
ans = sorted(ls_ans)
print("\n".join(ans))
exit()

Submission status: Time Limit Exceeded

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

setS = set(S)
C = {s:S.count(s) for s in setS}
M = max(C.values())

R = [s for s in setS if C[s]==M]
R.sort()

for r in R:
    print(r)

Submission status: Time Limit Exceeded

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

lis = collections.Counter(cnt_lis)
ans = []
tmp = 0
for i in range(len(lis)):
    if tmp <= lis.most_common()[i][1]:
        ans.append(lis.most_common()[i][0])
        tmp = lis.most_common()[i][1]
    else:
        continue
ans.sort()
for i in ans:
    print(i)

Submission status: Time Limit Exceeded

Solution code:

from collections import defaultdict
def resolve():
    N = int(input())
    S = [input() for _ in range(N)]
    
    res = defaultdict(lambda: 0)

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

    max_k_list = [kv[0] for kv in res.items() if kv[1] == max(res.values())]

    max_k_list.sort()
    for k in max_k_list:
        print(k)


if __name__ == "__main__":
    resolve()

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

S_set = list(set(S))
S_dic = {}
M = 0
for s in S_set:
    S_dic[s] = S.count(s)
    M = max(M, S.count(s))

S_dic_sorted = sorted(S_dic.items(), key=lambda x: x[0])
for l in S_dic_sorted:
    if l[1] == M:
        print(l[0])

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

saidai = 0
nakami = []
kaisu = []
z1 = []
zs = 0

for i in range(N):
    S = input()
    mita = False
    for j in range( len(nakami) ):
        if nakami[j]==S:
            mita = True
            break
    if mita:
        kaisu[j] = kaisu[j] +1
        if kaisu[j]==zs:
            z1.append(S)
        if kaisu[j]>zs:
            z1 = [S]
            zs = kaisu[j]
            
    else:
        nakami.append(S)
        kaisu.append(1)
        if zs==0:
            zs = 1
        if zs==1:
            z1.append(S)
            

#for i in range(len(nakami)):
#    if kaisu[i]>saidai:
#        saidai = kaisu[i]

#nakamisaidai= []
#for i in range(len(nakami)):
#    if kaisu[i]==saidai:
#        nakamisaidai.append(nakami[i])

#nakamisaidai.sort()
z1.sort()

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

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
ans = {}
for i in range(N):
	cood = input()
	if  cood not in ans:
		ans[cood] = 1
	else:
		ans[cood] += 1
max_k_list = [kv[0] for kv in ans.items() if kv[1] == max(ans.values())]
max_k_list.sort()
for i in range(len(max_k_list)):
	print(max_k_list[i])

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
s = [str(input()) for i in range(n)]
d = {}
for name in s:
    if name in d.keys():
        d[name] = d[name] + 1
    else:
        d.setdefault(name, 1)
max_k_list = [kv[0] for kv in d.items() if kv[1] == max(d.values())]
for i in sorted(max_k_list):
    print(i)

Submission status: Time Limit Exceeded

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

maxlist = [kv for kv in di.items() if kv[1] == max(di.values())]
dic2 = sorted(maxlist)
for d in dic2:
    print(d[0])

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
s_list=[]
for i in range(n):
  s=str(input())
  s_list.append(s)
  
s_dict={}
for s in s_list:
  if s not in s_dict:
    s_dict[s] = 1
  else:
    s_dict[s] += 1
    
ans = [k for k, v in s_dict.items() if v == max(s_dict.values())]
for a in sorted(ans):
  print(a)

Submission status: Time Limit Exceeded

Solution code:
import sys
import math
import itertools as it
def i():return int(sys.stdin.readline().replace("\n",""))
def i2():return map(int,sys.stdin.readline().replace("\n","").split())
def s():return str(sys.stdin.readline().replace("\n",""))
def l():return list(sys.stdin.readline().replace("\n",""))
def intl():return [int(k) for k in sys.stdin.readline().replace("\n","").split()]
def lx():return list(map(lambda x:int(x)*-1,sys.stdin.readline().replace("\n","").split()))
def t():return tuple(map(int,sys.stdin.readline().replace("\n","").split()))

if __name__ == "__main__":pass
n = i()
s = [input() for _ in range(n)]
s.sort()
ss = list(set(s))
ss.sort()
a = [0]*len(ss)
i = 0
while n-1 > i:
    if s[i] == s[i+1]:
        a[ss.index(s[i])] += 1
        i += 1
    else:
        i += 1
m = max(a)
for k in range(len(a)):
    if a[k] == m:
        print(ss[k])

Submission status: Time Limit Exceeded

Solution code:
import collections


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


tmp = collections.Counter(ss).most_common()

target = collections.Counter(ss).most_common()[0][1]
ans = ''
for i in tmp:
    if i[1] == target:
        ans += i[0] + ' '
    else:
        break
ans = sorted(ans.split(), key=str.lower)
print(*ans)

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
s={}
for i in range(n):
    st=input()
    if st in s:
        s[st]+=1
    else:
        s[st]=1
ans=[kv[0] for kv in s.items() if kv[1] == max(s.values())]
ans.sort()
for i in ans:
    print(i)

Submission status: Time Limit Exceeded

Solution code:
N=int(input())
S=[input() for _ in range(N)]
cnt=[0]*N
cnt[0]=1
for i in range(1,N):
    if S[i] in S[:i]:
        cnt[S.index(S[i])]+=1
    else:
        cnt[i]=1
cmax=max(cnt)
ans=[]
for j in range(N):
    if cnt[j]==cmax:
        ans.append(S[j])
ans.sort()
for k in ans:
    print(k)

Submission status: Time Limit Exceeded

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

key = set(li)
c = [0]*len(key)
ind = 0
ans = [[] for _ in range(len(key))]
for i in key:
    ans[ind] = [li.count(i), i]
    ind += 1

ans.sort(reverse=True)
p = ans[0][0]
q = []
for i in range(len(ans)):
    if ans[i][0] == p:
        q.append(ans[i][1])
q.sort()
[print(i) for i in q]

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
s=[input() for i in [0]*n]
p=[]
q=0
for i in s:
    if i in p:
        continue
    r=s.count(i)
    if r>q:
        p=[i]
    if r==q:
        p+=[i]
    if r>=q:
        q=r
p.sort()
for i in p:
    print(i)

Submission status: Time Limit Exceeded

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

L = sorted([kv[0] for kv in S.items() if kv[1] == max(S.values())])
for i in range(len(L)):
    print(L[i])

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
a = [[input(), 1]]
for i in range(N-1):
  p = input()
  f = 0
  for n in range(len(a)):
    if a[n][0] == p:
      a[n][1] = a[n][1] + 1
      f = 1
      break
  if f == 0:
    a.append([p, 1])
MAX = 0
MAX_n = []
for n in range(len(a)):
  if a[n][1] == MAX:
    MAX_n.append(a[n][0])
  elif a[n][1] > MAX:
    MAX = a[n][1]
    MAX_n = [a[n][0]]
MAX_n.sort()
for i in MAX_n:
  print(i)

Submission status: Time Limit Exceeded

Solution code:
# N枚の投票用紙
N = int(input())

s = {}
for _ in range(N):
    tmp = input()
    try:
        if s[tmp]:
            s[tmp] +=1
    except:
        s[tmp] = 1
    
#print(s)
max_kv_list = [kv[0] for kv in s.items() if kv[1] == max(s.values())]
#print(max_kv_list)

max_kv_list.sort()
for tmp in max_kv_list:
    print(tmp)

Submission status: Time Limit Exceeded

Solution code:
def solve():
    N = int(input())
    s_lst = [input() for i in range(N)]
    a_lst = []
    s_dict = {}
    for w in s_lst:
        if not w in s_dict.keys():
            s_dict[w] = 1
        else:
            s_dict[w] += 1
    s_max = max(list(s_dict.values()))
    for w in s_lst:
        if s_dict[w] == s_max and not w in a_lst:
            a_lst.append(w)
    a_lst.sort()
    for i in range(len(a_lst)):
        print(a_lst[i])

if __name__ == '__main__':
    solve()

Submission status: Time Limit Exceeded

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

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

d=dict(d)
m= [kv[0] for kv in d.items() if kv[1] == max(d.values())]
m.sort()
for i in range(len(m)):
    print(m[i])

Submission status: Time Limit Exceeded

Solution code:
import bisect

n = int(input())

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

l = []
for i in d:
    if d[i] == m:
        bisect.insort_left(l, i)
        
for i in l:
    print(i)

Submission status: Time Limit Exceeded

Solution code:
import collections
n = int(input())
x = []
for _ in range(n):
    x.append(input())
c = collections.Counter(x)
a = c.most_common()[0][1]
y = []
if len(c) == 1:
    print(x[0])
    exit()
for i in range(n):
    if c.most_common()[i][1] == a:
        y.append(c.most_common()[i][0])
    else:
        break
for i in sorted(y):
    print(i)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
s = [0] * N
time = [1] * N
j = 0
for i in range(N):
  inp = str(input())
  if inp in s:
    x = s.index(inp)
    time[x] += 1
  else:
    s[j] = inp
    j += 1
    
ans = max(time)
#print(s, time)
ans_list = []
for i in range(N):
  if time[i] == ans:
    if s[i] != 0:
      ans_list.append(s[i])
      
ans_list = sorted(ans_list)
for i in range(len(ans_list)):
  print(ans_list[i])

Submission status: Time Limit Exceeded

Solution code:
N=int(input())
A = [input() for x in range(N)]
max=-1
ans=[]
for a in set(A):
  tmp = A.count(a)
  if tmp>max:
    max=tmp
    ans=[a]
  elif tmp==max:
    ans.append(a)

[print(i) for i in sorted(ans)]

Submission status: Time Limit Exceeded

Solution code:
#from fractions import gcd
#mod = 10 ** 9 + 7
#N = int(input())
#a = list(map(int,input().split()))
#a,b,c = map(int,input().split())
#ans = [0] * N
#math.ceilで切り上げ
#dp = [[0] * 4 for i in range(3)] #2次元配列初期化
#dp = [[[0] * 2 for i in range(3)] for j in range(5)]
#(ord('A'))でASCII出力 Aは65
import math
import string

def intinput():
    return int(input())

def listintinput():
    return list(map(int,input().split()))

def splitintinput():
    return map(int,input().split())

N = intinput()
A = {}

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

maxalist = [kv[0] for kv in A.items() if kv[1] == max(A.values())]
maxalist.sort()
for i in maxalist:
    print(i)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
for i in range(n):
    if i == 0:
        s = input()
        S = {s: 1}
    else:
        s = input()
        if s in S:
            S[s] += 1
        else:
            S[s] = 1
max_k_list = [kv[0] for kv in S.items() if kv[1] == max(S.values())]
ans = sorted(max_k_list)
for a in ans:
    print(a, sep="\n")

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
dict = {}
for _ in range(n):
    s = input()
    if s in dict:
        dict[s] += 1
    else:
        dict[s] = 0
max_list = [k for k, v in dict.items() if v == max(dict.values())]
max_list.sort()
for i in max_list:
    print(i)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
S = []
for x in range(N):
    S.append(input())
P = sorted(set(S))
maxi = max([S.count(x) for x in P])
done = []
for x in P:
    if S.count(x) == maxi:
        print(x)

Submission status: Time Limit Exceeded

Solution code:
N=int(input())
from collections import defaultdict
d = defaultdict(int)
for i in range(N):
  S=input()
  d[S]+=1
max_k_list = [kv[0] for kv in d.items() if kv[1] == max(d.values())]
A=sorted(max_k_list)
for a in A:
  print(a)

Submission status: Time Limit Exceeded

Solution code:
from sys import stdin

if __name__ == '__main__':
    N = int(stdin.readline().rstrip())
    d = {}
    for i in range(N):
        poll = stdin.readline().rstrip()
        if not poll in d:
            d[poll] = 1
        else:
            d[poll] += 1
    max_k_list = [kv[0] for kv in d.items() if kv[1] == max(d.values())]
    for key in sorted(max_k_list):
        print(key)

Submission status: Time Limit Exceeded

Solution code:
import collections

def solution():
    n = int(input().strip())
    d = collections.defaultdict(int)
    for _ in range(n):
        d[input().strip()] += 1
    res = list(d.items())
    res.sort(key=lambda x:(-x[1], x[0]))
    for x in res:
        if x[1] == res[0][1]:
            print(x[0])
        else:
            break

def main():    
    # T = int(input().strip())
    for _ in range(1):
        solution()
    

main()

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
s_list = {}
already = set()
for _ in range(N):
    s = input()
    if s in already:
        s_list[s] += 1
    else:
        s_list[s] = 0
    already.add(s)


max_kv_list = [kv for kv in s_list.items() if kv[1] == max(s_list.values())]
kv_list = []
for kv in max_kv_list:
    kv_list.append(kv[0])
kv_list.sort()
for kv in kv_list:
    print(kv)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
vote_ls = []
vote_num = [0]*n
for i in range(n):
    aaa = input()
    if aaa in vote_ls:
        #print("a")
        vote_num[vote_ls.index(aaa)]+=1
    else:
        vote_ls.append(aaa)
        vote_num[vote_ls.index(aaa)]+=1
#print(vote_num)
sub_ls = []
max_vote = max(vote_num)
for i in range(n):
    if vote_num[i] == max_vote:
        sub_ls.append(vote_ls[i])
sub_ls.sort()
for i in range(len(sub_ls)):
    print(sub_ls[i])

Submission status: Time Limit Exceeded

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

dic={}
for string in poll:
  if string not in dic:
    dic[string]=1
  else:
    dic[string]+=1

max_k=[k for k, v in dic.items() if v == max(dic.values())]
max_k.sort() 
print(*max_k,sep='\n')

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

dicts = {}

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

max_list = [kv[0] for kv in dicts.items() if kv[1] == max(dicts.values())]

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

Submission status: Time Limit Exceeded

Solution code:
#300
N = int(input())
S = [input() for _ in range(N)]
L = []
S.sort()
Set = set(S)
SetL = list(Set)
SetL.sort()

for i in range(N):
    if i == 0:
        L.append(1)
    else:
        if S[i-1] == S[i]:
            L[len(L)-1] = L[len(L)-1] + 1
        else:
            L.append(1)

for i in range(len(L)):
    if L[i] == max(L):
        print(SetL[i])

Submission status: Time Limit Exceeded

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

ll=[]
for i in range(n):
    ll.append(l.count(l[i]))

lll=[]
for i in range(n):
    if ll[i]==max(ll):
        lll.append(l[i])

lll=sorted(set(lll))
for i in lll:
    print(i)