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())
startlist=[]
for _ in range(n):
    startlist.append(input())
dictlist=sorted(startlist)
setlist=sorted(list(set(dictlist)))
countlist=[0]*(int(len(setlist)))
count=1
count2=1
for i in range(n):
    if i==n-1:
        countlist[i-count2+1]+=count
    elif dictlist[i+1]==dictlist[i]:
        count+=1
        count2+=1
    else:
        countlist[i-count2+1]+=count
        count=1
indexlist=[i for i,x in enumerate(countlist) if x==max(countlist)]
for j in tuple(sorted(indexlist)):
    print(setlist[j])

Submission status: Time Limit Exceeded

Solution code:
import sys
import collections
input = lambda: sys.stdin.readline().rstrip()

def main():
    n = int(input())
    s = [input() for _ in range(n)]
    cnt = collections.Counter(s)
    d = sorted([k for k, v in cnt.items() if v == max(cnt.values())])
    print(*d, sep='\n')

if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
import sys
import collections
input = lambda: sys.stdin.readline().rstrip()

def main():
    n = int(input())
    s = [input() for _ in range(n)]
    cnt = collections.Counter(s)
    d = [k for k, v in cnt.items() if v == max(cnt.values())]
    d = sorted(d)
    for i in d:
        print(i)    

if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
import sys
import collections
input = lambda: sys.stdin.readline().rstrip()
 
def main():
    n = int(input())
    s = [input() for _ in range(n)]
    cnt = collections.Counter(s)
    d = sorted([k for k, v in cnt.items() if v == max(cnt.values())])
    for i in d:
        print(i)    
 
if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
import sys
import collections
input = lambda: sys.stdin.readline().rstrip()

def main():
    n = int(input())
    s = [input() for _ in range(n)]
    cnt = collections.Counter(s)
    d = sorted([k for k, v in cnt.items() if v == max(cnt.values())])
    for i in d:
        print(i)    

if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
S = []
for i in range(n):
  S.append(input())
T = list(set(S))
count = []
for i in range(len(T)):
  count.append(S.count(T[i]))
best = max(count)
ans = []
for i in range(len(T)):
  if count[i] == best:
    ans.append( T[i])
ans = sorted(ans)
for i in range(len(ans)):
  print(ans[i])

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
S = []
for i in range(n):
  S.append(input())
T = list(set(S))
count = []
counter =  []
for i in range(len(T)):
  count.append(S.count(T[i]))
  counter.append(T[i])
best = max(count)
ans = []
for i in range(len(T)):
  if count[i] == best:
    ans.append(counter[i])
ans = sorted(ans)
for i in range(len(ans)):
  print(ans[i])

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
A = []
for n in range(N):
    A.append(input())
A.sort()
B = []
for n in range(N):
    C = 0
    for i in range(N):
        if A[n] == A[i]:
            C += 1
    B.append(C)
m = max(B)
D = []
for i in range(N):
    if m <= B[i]:
        D.append(A[i])
D = list(set(D))
for i in range(len(D)):
    print(D[i])

Submission status: Time Limit Exceeded

Solution code:
import collections
n=int(input())
s=[input() for i in range(n)]
c = collections.Counter(s)
ans=[]
for i in range(len(set(s))):
    if c.most_common()[i][1]==c.most_common()[0][1]:
        ans+=[c.most_common()[i][0]]
ans.sort()
for i in ans:
    print(i)

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
a=[input() for _ in range(n)]
a.sort()
b=[]
c=[]
w=""
for m in a:
  if m == w:
    c[-1]+=1
  else:
    b.append(m)
    c.append(1)
    w=m
for m in range(len(b)):
  if c[m]==max(c):
    print (b[m])

Submission status: Time Limit Exceeded

Solution code:
N=int(input())
A=[]
Q={}
for i in range(N):
    B=input()
    A.append(B)
    Q[B]=0
    
    
for i in A:
    Q[i]+=1
    
max_Q = [kv[0] for kv in Q.items() if kv[1] == max(Q.values())] ##辞書式でvalueが最大のもののkeyの並び替え
QQ=sorted(max_Q)
for i in range(len(QQ)):
    print(QQ[i])

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

d = {}

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


max_kv_list = [kv[0] for kv in d.items() if kv[1] == max(d.values())]
max_kv_list = sorted(max_kv_list)
for ans in max_kv_list:
    print(ans)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

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

P = []
for i in range(N):
    P.append(V.count(V[i]))

A = []
for i in range(N):
    if max(P) == P[i]:
        A.append(V[i])

A = list(set(A))
A.sort()

for i in A:
    print(i)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
ls = [input() for i in range(n)]
ls.sort()
p = []
k = 0
for j in range(n-1):
    if ls[j] == ls[j+1]:
        k += 1
    else:
        p.append(k)
        k = 0
p.append(k)
new = list(set(ls))
new.sort()
for l in range(len(p)):
    if p[l] == max(p):
        print(new[l])

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
N=int(input())
X=[]
places=[]
for i in range(N):
    inp=input()
    X.append(inp)
    places.append(X.count(inp))
ans=[]
mode=max(places)
for j in range(N):
    if places[j]==mode:
        ans.append(X[j])
ans.sort()
for a in ans:
    print(a)

Submission status: Time Limit Exceeded

Solution code:
N=int(input())
X=[]
places=[]
for i in range(N):
    inp=input()
    X.append(inp)
    places.append(X.count(inp))
ans=[]
for j in range(N):
    if places[j]==max(places):
        ans.append(X[j])
ans.sort()
for a in ans:
    print(a)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
key = []
value = []

for i in range(n):
    s = input()
    if s in key:
        value[key.index(s)] += 1
    else:
        key.append(s) 
        value.append(1)

m = max(value)
arr = []
y = len(key)

for j in range(y):
    if value[j] == m:
        arr.append(key[j])

arr.sort()
x = len(arr)
for k in range(x):
    print(arr[k])

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

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

W = []
for i in range(N):
    if V[i] == max(V):
        W.append(S[i])

W = list(set(W))
W.sort()

for i in W:
    print(i)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

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

W = []
for i in range(N):
    if V[i] == max(V):
        W.append(S[i])

W = list(dict.fromkeys(W))
W.sort()

for i in W:
    print(i)

Submission status: Time Limit Exceeded

Solution code:
#整数の入力
N = int(input())
S_list = []
for i in range(N):
  S = input()
  S_list.append(S)
  
S_set = sorted(list(set(S_list)))
S_count = []

for i in range(len(S_set)):
  S_count.append(S_list.count(S_set[i]))
  
max_ = max(S_count)


for i in range(len(S_set)):
  if(S_count[i] == max_):
    print(S_set[i])

Submission status: Time Limit Exceeded

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

l = max(S.count(i) for i in S)
ans = []
for j in S:
  if S.count(j) == l:
    if j not in ans:
      ans.append(j)
      print(j)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
S = []
for _ in range(n):
  s = input()
  S.append(s)
t = []
for i in S:
  l = S.count(i)
  t.append(l)
lm = max(t)
ans = []
for j in S:
  if S.count(j) == lm:
    if j not in ans:
      ans.append(j)
ans.sort()
for k in ans:
  print(k)

Submission status: Time Limit Exceeded

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 = []
a.append(c.most_common()[0][0])
for i in range(1,len(c.most_common())):
    if c.most_common()[0][1]==c.most_common()[i][1]:
        a.append(c.most_common()[i][0])
print(*sorted(a))

Submission status: Time Limit Exceeded

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)
l = []
for a in s:
    if not a in l and dic[a] == m:
        l.append(a)
l.sort()
for i in range(len(l)):
    print(l[i])

Submission status: Time Limit Exceeded

Solution code:
import collections

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

ans = []
c = collections.Counter(s)
for k, v in c.most_common():
    if v == c.most_common()[0][1]:
        ans.append(k)
ans = sorted(ans)
for i in ans:
    print(i)

Submission status: Time Limit Exceeded

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

if len(S) == len(set(S)):
  [print(a) for a in sorted(S)]
else:
  c = collections.Counter(S)
  ans = sorted([i[0] for i in c.items() if i[1] == c.most_common()[0][1]])
  [print(a) for a in ans]

Submission status: Time Limit Exceeded

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

c = collections.Counter(S)

ans = sorted([i[0] for i in c.items() if i[1] == c.most_common()[0][1]])
  
[print(a) for a in ans]

Submission status: Time Limit Exceeded

Solution code:
from collections import Counter


def main():
    n = int(input())
    ss = [input() for _ in range(n)]
    max_num = Counter(ss).most_common()[0][1]
    max_verbs = [Counter(ss).most_common()[0][0]]
    for i in range(1, len(Counter(ss).most_common())):
        if Counter(ss).most_common()[i][1] != max_num:
            break
        max_verbs.append(Counter(ss).most_common()[i][0])

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


if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

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

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

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

Submission status: Time Limit Exceeded

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

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

for i in keys:
    print(i)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
S = []
for _ in range(N):
    S.append(input())
s_set = set(S)
s_dict = {}
for s in s_set:
    s_dict[s] = S.count(s)

s_list = sorted(s_dict.items(),key=lambda x:x[1],reverse=True)
num = s_list[0][1]
ans_list = []
for i in range(len(s_set)):
    if num == s_list[i][1]:
        ans_list.append(s_list[i][0])
    else:
        break
ans_list.sort()
for i in ans_list:
    print(i)

Submission status: Time Limit Exceeded

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

#重複チェック
dup = [x for x in set(S) if S.count(x) > 1]
l = len(dup)

if not dup:
    ans = sorted(S)
    for i in ans:
        print(i)
else:
    c = collections.Counter(S)
    value,count = zip(*c.most_common(l))

    if len(set(count)) == 1:
        s = sorted(value)
        for i in s:
            print(i)
    else:
        for i in value:
            print(i)
            exit()

Submission status: Time Limit Exceeded

Solution code:
from collections import Counter

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

d = Counter(S)
max_k_list = [kv[0] for kv in d.items() if kv[1] == max(d.values())]
ans = '\n'.join(sorted(max_k_list))
print(ans)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
S = [input() for i in range(N)]
S_set = sorted(list(set(S)))
L = len(S_set)

count = [0]*L
for i in range(L):
  count[i] = S.count(S_set[i])

#print(S_set)
M = max(count)
for i in range(L):
  if count[i] == M:
    print(S_set[i])

Submission status: Time Limit Exceeded

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

count = [0]*len(S_set)
for i in range(len(S_set)):
  count[i] = S.count(S_set[i])

#print(S_set)
for i in range(len(S_set)):
  if count[i] == max(count):
    print(S_set[i])

Submission status: Time Limit Exceeded

Solution code:
N=int(input())
S=[str(input()) for _ in range(N)]
dic=[]
n=0
for i in S:
  m=S.count(i)
  if n<m:
    n=m
    dic=[]
    dic.append(i)
  if n==m:
    n=m
    dic.append(i)
    
for j in sorted(set(dic)):
  print(j)

Submission status: Time Limit Exceeded

Solution code:
N=int(input())
S = [input() for i in range(N)]
S.sort()
max_count=0
ans=[]
for s in S:
	max_count= max(max_count, S.count(s))
for s in set(S):
	if S.count(s)==max_count:
		ans.append(s)
ans.sort()
for a in ans:
	print(a)

Submission status: Time Limit Exceeded

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

kensaku = list(set(h))
result = 0
list = []
#print(kensaku)
for i in range(len(kensaku)):
    

    if h.count(kensaku[i]) > result:
        result = h.count(kensaku[i])
        list = []
        list.append(kensaku[i])
    elif h.count(kensaku[i]) == result:
        
        list.append(kensaku[i])
        list.sort()

#print(list)

for h in range(len(list)):
    print(list[h])

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
s = [input() for i in range(n)]
ss = sorted(set(s))
l = []
for i in ss:
    l.append([i, s.count(i)])
l = sorted(l, key = lambda x:(-x[1],x[0]))
for i in l:
    if i[1]==l[0][1]:
        print(i[0])

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

D={}
for i in range(N):
    if (S[i] in D.keys())==True:
        D[S[i]]+=1
    elif (S[i] in D.keys())==False:
        D[S[i]]=1

m=max(D.values())

M=[]
for i in D.keys():
    if D[i]==m:
        M.append(i)

M2=sorted(M)
for i in M2:
    print(i)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
s = [input() for i in range(n)]
ss = sorted(set(s))
d = []
for i in ss:
    d.append([i,0])
for i in s:
    d[ss.index(i)][1]+=1
d = sorted(d, key = lambda x:(-x[1],x[0]))
for i in d:
    if i[1]==d[0][1]:
        print(i[0])
    else:
        break

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
s = [input() for i in range(n)]
ss = sorted(set(s))
l = len(ss)
d = []
for i in ss:
    d.append([i,0])
for i in s:
    d[ss.index(i)][1]+=1
d = sorted(d, key = lambda x:(-x[1],x[0]))
for i in range(l):
    if d[i][1]==d[0][1]:
        print(d[i][0])

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
A = [input() for i in range(N)]
B = list(set(A))
C = [0]*len(B)
for i in range(len(B)):
  C[i] = A.count(B[i])
D = max(C)
for s in sorted([B[i] for i, x in enumerate(C) if x == D]):
    print(s)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
A = [input() for i in range(N)]
B = list(set(A))
C = [0]*len(B)
for i in range(len(B)):
  C[i] = A.count(B[i])
D = max(C)
E = sorted([B[i] for i, x in enumerate(C) if x == D])
for i in range(len(E)):
  print(E[i])

Submission status: Time Limit Exceeded

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

s=set(S)

D={}
for i in s:
    total=0
    for j in S:
        if i==j:
            total+=1
    D[i]=total

V=[]
for value in D.values():
       V.append(value)
m=max(V)

A=[]
for i in D.keys():
    if D[i]==m:
        A.append(i)

B=sorted(A)
for i in B:
    print(i)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
S = [input() for _ in range(n)]
SetS = sorted(set(S))
Hit = [0]*n
for i, item in enumerate(SetS):
    Hit[i] = S.count(item)
Ind = [i for i, x in enumerate(Hit) if x == max(Hit)]
for ind in Ind:
    print(SetS[ind])

Submission status: Time Limit Exceeded

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

kensaku = list(set(h))
result = 0
list = []

for i in range(len(kensaku)):
    

    if h.count(kensaku[i]) > result:
        result = h.count(kensaku[i])
        list = []
        list.append(kensaku[i])
    elif h.count(kensaku[i]) == result:
        list.append(kensaku[i])

result = sorted(list)

for h in range(len(result)):
    print(result[h])

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

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

t = [k for k, v in s.items() if v == max(s.values())]
t.sort()

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

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
T = {}
for _ in range(N):
  S = input().split()
  if not S[0] in T:
    T[S[0]] = 0
  T[S[0]] += 1

for i in range(len([k for k, v in T.items() if v == max(T.values())])):
  print(sorted([k for k, v in T.items() if v == max(T.values())])[i])

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
S = []
T = {}
for _ in range(N):
  S += input().split()
for v in S:
  if not v in T:
    T[v] = 0
  T[v] += 1

for i in range(len([k for k, v in T.items() if v == max(T.values())])):
  print(sorted([k for k, v in T.items() if v == max(T.values())])[i])

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
s=[""]*n
for ii in range(n):
  s[ii]=input()
ss=list(set(s))
ss.sort()
c=[0]*len(ss)
for ii in range(n):
  c[ss.index(s[ii])]+=1
#print(c)
mx=max(c)
for ii in range(len(ss)):
  if c[ii]==mx:
    print(ss[ii])

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
s=[""]*n
for ii in range(n):
  s[ii]=input()
ss=list(set(s))
#print(ss)
#print(s)
r=[]
for ii in range(len(ss)):
  l=[1 if x==ss[ii] else 0 for x in s]
  r.append([n-sum(l),ss[ii]])
r.sort()
#pint(r)
for ii in range(len(ss)):
  if r[ii][0]==r[0][0]:
    print(r[ii][1])
  else:
    exit()

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

s_dic = {}

for i in range(n):
    tmp = str(input())
    if tmp not in s_dic:
        s_dic[tmp] = 1
    else:
        s_dic[tmp] += 1


max_s_key = [s_value[0] for s_value in s_dic.items() if s_value[1] == max(s_dic.values())]

max_s_key = sorted(max_s_key)

for i in max_s_key:
    print(i)

Submission status: Time Limit Exceeded

Solution code:
#155c
import collections
n = int(input())
s = [input() for _ in range(n)]

c = collections.Counter(s)
ret = []
tmp = []

for k, v in c.most_common():
  if max(c.values()) == v:
    ret.append(k)
  else:
    break

for r in sorted(ret):
  print(r)

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
s= []
for _ in range(n):
    s.append(input())
S=list(set(s))
ans=[0]*len(S)
p=sorted(S)
for i in range(n):
    for j in range(len(S)):
        if s[i]==p[j]:
            ans[j]=ans[j]+1
m=max(ans)
for i in range(len(S)):
    if ans[i]==m:
        print(p[i])

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

cnt = []
for i in S:
    cnt.append(S.count(i))
M = max(cnt)

ans = [s for s in S if S.count(s) == M]

print(*sorted(set(ans)), sep = "\n")

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
S = [input() for _ in range(N)]
cnt = []
for i in S:
    cnt.append(S.count(i))
M = max(cnt)

ans = []
for k in range(N):
    if cnt[k] == M:
        ans.append(S[k])
print(*sorted(set(ans)), sep = "\n")

Submission status: Time Limit Exceeded

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

for name in m:
  d[name] = l.count(name)
  
max_in_d = max(d.values())
max_kv_list = sorted([kv[0] for kv in d.items() if kv[1] == max_in_d])
for name in max_kv_list:
  print(name)

Submission status: Time Limit Exceeded

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

for name in m:
  d[name] = l.count(name)
  

max_kv_list = sorted([kv[0] for kv in d.items() if kv[1] == max(d.values())])
for name in max_kv_list:
  print(name)

Submission status: Time Limit Exceeded

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

for name in m:
  d[name] = l.count(name)
  
  
max_kv_list = sorted([kv[0] for kv in d.items() if kv[1] == max(d.values())])
for name in max_kv_list:
  print(name)

Submission status: Time Limit Exceeded

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

d = {}
ans = []

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

ans = [j[0] for j in d.items() if j[1] == max(d.values())]

ans.sort()

print('\n'.join(map(str, ans)))

Submission status: Time Limit Exceeded

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


c = collections.Counter(l)

ans = [j[0] for j in c.items() if j[1] == max(c.values())]

ans.sort()

print('\n'.join(map(str, ans)))

Submission status: Time Limit Exceeded

Solution code:
import collections
n = int(input())
l = []
ans = []

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

c = collections.Counter(l)

ans = [i[0] for i in c.items() if i[1] == max(c.values())]

ans.sort()

print('\n'.join(map(str, ans)))

Submission status: Time Limit Exceeded

Solution code:
import collections
n = int(input())
l = []
ans = []

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

c = collections.Counter(l)

ans.append(c.most_common()[0][0])

for i in range(1, len(c)):
    if c.most_common()[0][1] == c.most_common()[i][1]:
        ans.append(c.most_common()[i][0])
    else:
        break

ans.sort()

print('\n'.join(map(str, ans)))

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
candidate = {}
for i in range(n):
  inp = input()
  if inp not in candidate:
    candidate[inp] = 1
  else:
    candidate[inp] += 1
ans = [j[0] for j in candidate.items() if j[1] == max(candidate.values())]
ans.sort()
print('\n'.join(ans))

Submission status: Time Limit Exceeded

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

maxx=s.count(max(s))
ans=[]

for i in s:
  if s.count(i)==maxx:
    ans.append(i)

ans=set(ans)
answer=[]
for i in ans:
  answer.append(i)

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

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
s=[]
ans=set()
for _ in range(n):
    s.append(str(input()))
count=[0]*len(set(s))
for i in range(len(set(s))):
    count[i]+=s.count(list(set(s))[i])
for k in range(len(set(s))):
    if max(count)==count[k]:
        ans.add(list(set(s))[k])
for l in range(len(ans)):
    print(sorted(ans)[l])

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
s=[]
ans=set()
for _ in range(n):
    s.append(str(input()))
count=[0]*len(set(s))
for i in range(len(set(s))):
    for j in range(len(s)):
        if list(set(s))[i]==s[j]:
            count[i]+=1
for k in range(len(set(s))):
    if max(count)==count[k]:
        ans.add(list(set(s))[k])
for l in range(len(ans)):
    print(sorted(ans)[l])

Submission status: Time Limit Exceeded

Solution code:
import itertools
import math
import fractions
import functools
n = int(input())
s = []
for i in range(n):
    s.append(input())

dic = {}

for i in range(n):
    if (s[i] in dic.keys()):
        dic[s[i]] += 1
    else:
        dic[s[i]] = 1
result = []
maximum = max(list(dic.values()))
for key in dic:
    if dic[key] == maximum:
        result.append(key)

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

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
L = [input() for _ in range(n)]
s = sorted(set(L))
c = [0] * len(s)
for i in range(len(s)):
    c[i] = L.count(s[i])
m = max(c)
for j in range(len(c)):
    if c[j] == m:
        print(s[j])

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
L = sorted(input() for _ in range(n))
s = sorted(set(L))
c = [0] * len(s)
for i in range(len(s)):
    c[i] = L.count(s[i])
m = max(c)
for j in range(len(c)):
    if c[j] == m:
        print(s[j])

Submission status: Time Limit Exceeded

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

c = {}
for _ in range(n):
    s = input()
    c[s] = c.get(s, 0) + 1

print("\n".join(sorted([ k for k,v in c.items() if v == max(c.values()) ])))

Submission status: Time Limit Exceeded

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

dic = {}
for _ in range(n):
    s = input()
    dic[s] = dic.get(s, 0) + 1

print("\n".join(sorted([ k for k,v in dic.items() if v == max(dic.values()) ])))

Submission status: Time Limit Exceeded

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

dic = {}
for _ in range(n):
    s = input()
    dic[s] = dic.get(s, 0) + 1

c = collections.Counter(dic)

print("\n".join(sorted([ k for k,v in c.items() if v == max(c.values()) ])))

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

lnam = list()
lnum = list()

for i in range(N):
    s = input()
    if s in lnam:
        lnum[lnam.index(s)] += 1
    else:
        lnam.append(s)
        lnum.append(1)

lall = list(zip(lnum, lnam))

fms = max(lnum)

lwin = list()
for i in range(len(lall)):
    if lall[i][0] == fms:
        lwin.append(lall[i][1])

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

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

lnam = list()
lnum = list()

for i in range(N):
    s = input()
    if s in lnam:
        lnum[lnam.index(s)] += 1
    else:
        lnam.append(s)
        lnum.append(1)

lall = list(zip(lnam, lnum))
ldwn = sorted(lall, key=lambda x:x[1], reverse=True)

lwin = list()
i = 0
while i != len(ldwn) and ldwn[i][1] == ldwn[0][1]:
    lwin.append(ldwn[i][0])
    i += 1

lans = sorted(lwin)
for j in range(len(lans)):
    print(lans[j])

Submission status: Time Limit Exceeded

Solution code:
count = int(input())

ls = []

for i in range(count):
    ls.append(input())

max = 0
ans = []

for s in set(ls):
    i = ls.count(s)
    if i >= max:
        if i > max:
            ans = []

        ans.append(s)
        max = i

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

Submission status: Time Limit Exceeded

Solution code:
count = int(input())

ls = []

for i in range(count):
    ls.append(input())

max = 0
ans = []

for s in set(ls):
    i = ls.count(s)
    if i >= max:
        if i > max:
            ans.clear()

        ans.append(s)
        max = i

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

Submission status: Time Limit Exceeded

Solution code:
import collections

N = int(input())
S = [input() for _ in range(N)]
s = collections.Counter(S).most_common()
a = [s[0][0]]
for i in range(1,len(s)):
  if s[0][1] <= s[i][1]:
    a.append(s[i][0])
  else:
    break
for i in range(len(a)):
  print(sorted(a)[i])

Submission status: Time Limit Exceeded

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

for i in s:
  ls[s.index(i)]+=1
  
maxcount=max(ls)
li=[]

for i in s:
  if s.count(i)==maxcount:
    li.append(i)
    
lis=[]
for i in li:
  if i in lis:
    pass
  else:
    lis.append(i)
    
lis=sorted(lis)
for i in lis:
  print(i)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

s = []

t =  set()

for i in range(n):
    k = input()
    s.append(k)
    t.add(k)

t = list(t)

a = []

for i in t:
    a.append([s.count(i),i])

a.sort(reverse = True)

maxa = a[0][0]

ans = []

for i in a:
    if i[0] == maxa:
        ans.append(i[1])
    else:
        break

ans.sort()

for i in ans:
    print(i)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

bariety = []

h = []

for i in range(n):
    t = input()
    if t not in bariety:
        bariety.append(t)
        h.append([1,t])
    else:
        h[bariety.index(t)][0] += 1
    
h.sort(reverse = True)

maxh = h[0][0]

ans = []

for i in h:
    if i[0] == maxh:
        ans.append(i[1])
    else:
        break
        
ans.sort()

for i in ans:
    print(i)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

bariety = []

h = []

for i in range(n):
    t = input()
    if t not in bariety:
        bariety.append(t)
        h.append([t,1])
    else:
        h[bariety.index(t)][1] += 1
        
for i in h:
    i.reverse()
    
h.sort(reverse = True)

maxh = h[0][0]

ans = []

for i in h:
    if i[0] == maxh:
        ans.append(i[1])
        
ans.sort()

for i in ans:
    print(i)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

l = [0] * n
for i in range(n):
    l[i] = input()

k = set(l)
m = 0
ans = []

for i in k:
    cnt = l.count(i)
    if cnt > m:
        m = cnt
        del ans[:]
        ans.append(i)
    elif cnt == m:
        ans.append(i)

ans.sort()

print(*ans, sep="\n", end="")

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

l = [0] * n
for i in range(n):
    l[i] = input()

k = set(l)
m = 0
ans = []

for i in k:
    cnt = l.count(i)
    if cnt > m:
        m = cnt
        ans.clear()
        ans.append(i)
    elif cnt == m:
        ans.append(i)

ans.sort()

for i in ans:
    print(i)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

words = {}

for i in range(n):
    key = input()
    if key not in words:
        words[key] = 0
    words[key] += 1

l = []

for i,j in words.items():
    if max(words.values()) == j:
        l.append(i)
        
l.sort()

print(*l, sep="\n")

Submission status: Time Limit Exceeded

Solution code:
N=int(input())
A=[input() for i in range(N)]
D=dict()
C=[]
for i in set(A):
    D[i]=0
for i in A:
    D[i]+=1
ans=0
for i in D.keys():
    if D[i]==max(D.values()):
        C.append(i)
C=sorted(C)
print(*C,sep='\n')