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())
a = [input() for _ in range(n)]

a_dict = {i:0 for i in set(a)}
a_list = list(set(a))

for i in a_list:
    a_dict[i] = a.count(i)

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

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_dict = {i:0 for i in set(a)}

for i in a:
    for j in a_dict:
        if i == j:
            a_dict[j] += 1

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

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_dict = {i:0 for i in set(a)}

for i in a:
    for j in a_dict:
        if i == j:
            a_dict[j] += 1

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

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

Submission status: Time Limit Exceeded

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

a_dict = {i:0 for i in set(a)}
for i in a:
    for j in a_dict:
        if i == j:
            a_dict[j] += 1

ans = []
for key, value in a_dict.items():
    if value == max(a_dict.values()):
        ans.append(key)
ans.sort()
for i in ans:
  print(i)

Submission status: Time Limit Exceeded

Solution code:
from collections import Counter

N = int(input())

s = [input() for _ in range(N)]
s_dict = Counter(s)

max_keys = [k for k, v in s_dict.items() if v == max(s_dict.values())]
max_keys.sort()
for k in max_keys:
  print(k)

Submission status: Time Limit Exceeded

Solution code:
from collections import Counter

N = int(input())

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

max_keys = [k for k, v in s_dict.items() if v == max(s_dict.values())]
max_keys.sort()
for k in max_keys:
  print(k)

Submission status: Time Limit Exceeded

Solution code:
from collections import Counter

N = int(input())

s_list = []
for _ in range(N):
  s = input()
  s_list.append(s)

s_dict = Counter(s_list)

max_keys = [k for k, v in s_dict.items() if v == max(s_dict.values())]
max_keys.sort()
for k in max_keys:
  print(k)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
D = {}
for _ in range(N):
  s = input()
  if s in D:
    D[s] += 1
  else:
    D[s] = 1
L = [d[0] for d in D.items() if d[1] == max(D.values())]
for l in sorted(L):
  print(l)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
Ss = []
c = []
for i in range(N):
  s = input()
  if s in Ss:
    c[Ss.index(s)] += 1
  else:
    Ss.append(s)
    c.append(1)
mostPoll = max(c)
winners = []
for i in range(len(c)):
  if c[i] == mostPoll:
    winners.append(Ss[i])
winners.sort()
for s in winners:
  print(s)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
ss = [input() for i in range(N)]
setss = set(ss)
maxes = [0]*len(setss)
listsetss = list(setss)
for i in range(len(setss)):
  maxes[i] = ss.count(listsetss[i])
mostPoll = max(maxes)
winners = []
for i in range(len(maxes)):
  if maxes[i] == mostPoll:
    winners.append(listsetss[i])
winners.sort()

for s in winners:
  print(s)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
words_list = list()
cnt = []
ans = []
for i in range(n) :
    words_list.append(input())
candidates = list(set(words_list))
for word in candidates :
    cnt.append(words_list.count(word))
mx = max(cnt)
for i in range(len(cnt)) :
    if cnt[i] == mx :
        ans.append(candidates[i])
ans = sorted(ans)
for i in range(len(ans)) :
    print(ans[i])

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
words_list = list()
cnt = []
d = {}
for i in range(n) :
    words_list.append(input())
candidates = sorted(list(set(words_list)))
for word in candidates :
    cnt.append(words_list.count(word))
mx = max(cnt)
for i in range(len(cnt)) :
    if cnt[i] == mx :
        print(candidates[i])

Submission status: Time Limit Exceeded

Solution code:
from collections import Counter
import sys
n=int(sys.stdin.readline().rstrip())
S=[sys.stdin.readline().rstrip() for _ in range(n)]
    
cnt=Counter(S)
list=[]
for k in cnt.most_common():
    if k[1] != cnt.most_common()[0][1]:
        break
    list.append(k[0])

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

Submission status: Time Limit Exceeded

Solution code:
from collections import Counter
import sys
n=int(sys.stdin.readline().rstrip())
S=[]
for _ in range(n):
    S.append(sys.stdin.readline().rstrip())
    
cnt=Counter(S)
list=[]
for k in cnt.most_common():
    if k[1] != cnt.most_common()[0][1]:
        break
    list.append(k[0])

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

Submission status: Time Limit Exceeded

Solution code:
from collections import Counter
n=int(input())
S=[]
for _ in range(n):
    S.append(input())
    
cnt=Counter(S)
list=[]
for k in cnt.most_common():
    if k[1] != cnt.most_common()[0][1]:
        break
    list.append(k[0])
list.sort()

for i in list:
    print(i)

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-
# ABC155_C
N = int(input())
S = [str(input()) for _ in range(N)]

SS = list(set(S))
M = len(SS)

lst = [0]*M
for i in range(M):
    lst[i] = S.count(SS[i])

ans = []
for j in range(M):
    if lst[j] == max(lst):
        ans.append(SS[j])

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

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
s=[]
u=[]
for i in range(n):
    a=input()
    s.append(a)
    if a not in u:
        u.append(a)
d={}
t=0
for i in range(n):
    if s[i] not in d:
        d[s[i]]=1
        if t==0:
            t=1
    else:
        d[s[i]]+=1
        if t<d[s[i]]:
            t=d[s[i]]
b=[]
for i in range(len(u)):
    if d[u[i]]==t and (u[i] not in b):
        b.append(u[i])
b.sort()
for i in range(len(b)):
    print(b[i])

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

w = {}
ans = []
m_cnt = 0
for _ in range(n):
    s = input()
    w[s] = w.get(s, 0) + 1
    if w[s] > m_cnt:
        m_cnt = w[s]
        ans = [s,]
    elif s not in ans and w[s] == m_cnt:
        ans.append(s)

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

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

w = {}
for _ in range(n):
    s = input()
    w[s] = w.get(s, 0) + 1
ans = sorted(i for i, j in w.items() if j == max(w.values()))
for i in ans:
    print(i)

Submission status: Time Limit Exceeded

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

w = {}

for i in s:
    w[i] = w.get(i, 0) + 1

ans = sorted(i for i, j in w.items() if j == max(w.values()))

for i in ans:
    print(i)

Submission status: Time Limit Exceeded

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

for i in range(n):
    if not s[i] in t:
        t.append(s[i])
        r.append(1)
    else:
        j = t.index(s[i])
        r[j] += 1

m = max(r)
z = []

for i in range(len(t)):
    if r[i] == m:
        z.append(t[i])

z.sort()

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

Submission status: Time Limit Exceeded

Solution code:
import collections

n = int(input())
s = list(input() for i in range(n))
c = collections.Counter(s)
m = c.most_common()[0][1]

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

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

Submission status: Time Limit Exceeded

Solution code:
if __name__ == '__main__':

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

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

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
from collections import Counter

n = int(input())
a = []
for i in range(n):
    a.append(input())
b = Counter(a)
for k, v in sorted(b.items()):
    if v == max(b.values()):
        print(k)

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
hoge={}
for i in range(n):
  tmp=input()
  if(tmp in  hoge):
    hoge[tmp]+=1
  else:
    hoge[tmp]=1
keys = [k for k, v in hoge.items() if v ==max(hoge.values())]
hoge=sorted(keys)
for i in range(len(hoge)):
  print(hoge[i])

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
s = [input() for s in range(n)]
l = len(set(s))
tmp,ans,lans = [],[0]*l,[]
for i in range(n):
	if not s[i] in tmp:
		tmp.append(s[i])
		ans[tmp.index(s[i])] += 1
	else:
		ans[tmp.index(s[i])] += 1

for j in range(l):
	if ans[j] == max(ans):
		lans.append(tmp[j])
lans.sort()
for h in range(len(lans)):
	print(lans[h])

Submission status: Time Limit Exceeded

Solution code:
from sys import stdin
def read():
    return stdin.readline().strip()

dict={}
output=[]

iteration=int(read())

max_val=-1

for _ in range(iteration):
    item=read()
    
    if dict.get(item) is None:
        dict[item]=0 
    dict[item]+=1 
    max_val = max(dict[item],max_val)

while(bool(dict)):
    max_key=max(dict,key=dict.get)
    if(max_val!=dict[max_key]):
        break
    output.append(max_key)
    
    del dict[max_key]
output.sort()
print('\n'.join(output))

Submission status: Time Limit Exceeded

Solution code:
from sys import stdin
def read():
    return stdin.readline().strip()

dict={}
output=[]

iteration=read()

iteration=int(iteration)

for _ in range(iteration):
    item=read()
    
    if dict.get(item) is None:
        dict[item]=0 
    dict[item]+=1 
max_val=max(dict.values())
while(bool(dict)):
    max_key=max(dict,key=dict.get)
    if(max_val!=dict[max_key]):
        break
    output.append(max_key)
    
    del dict[max_key]
output.sort()
print('\n'.join(output))

Submission status: Time Limit Exceeded

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

    S_dict = {}
    for s in S_list:
        S_dict[s]=0
    for s in S_list:
        S_dict[s]+=1



    max_k_list = [kv[0] for kv in S_dict.items() if kv[1] == max(S_dict.values())]
    max_k_list.sort()
    for k in max_k_list:
        print(k)

if __name__ == '__main__':
     main()

Submission status: Time Limit Exceeded

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

S_dict = {}
for s in S_list:
    S_dict[s]=0
for s in S_list:
    S_dict[s]+=1

max_k_list = [kv[0] for kv in S_dict.items() if kv[1] == max(S_dict.values())]
max_k_list.sort()
for k in max_k_list:
    print(k)

Submission status: Time Limit Exceeded

Solution code:
N=int(input())
S=[""]*N
Sdic={}
for i in range(N):
  S[i]=input()
  
for i in set(S):
  Sdic[i] = S.count(i)

Smax=max(Sdic.values())
result=[]
for a, b in Sdic.items():
  if b == Smax:
    result.append(a)
result.sort()
result= " ".join(result)
print(result)

Submission status: Time Limit Exceeded

Solution code:
# coding: utf-8
# Your code here!

from collections import Counter

n = int(input())
s = [input() for i in range(n)]
s = sorted(s)
c = Counter(s)
c_values = c.values()
for j in c.items():
    if j[1] == max(c_values):
        print(j[0])

Submission status: Time Limit Exceeded

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

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

for a in A:
    print(a)

Submission status: Time Limit Exceeded

Solution code:
a=[]
b={1:"b",2:"a"}

max=0

for _ in range (int(input())):
    a.append(input())
for item in a:
    if(max<a.count(item)):
        b.clear()
        max=a.count(item)
        b[item]=item
        
    elif (max==a.count(item)):
         
        b[item]=item

for item in sorted(b.values()):
    print(item)

Submission status: Time Limit Exceeded

Solution code:


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



names = [0]*len(Sset)

for i, name in enumerate(Sset):
    cnt = 0
    for s in S:
        if(name==s):
            cnt += 1
            names[i] = (name, cnt)
max = 0
for n in names:
    if max<n[1]:
        max = n[1]
ans = []
for n in names:
    if n[1]==max:
        ans.append(n[0])

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

Submission status: Time Limit Exceeded

Solution code:


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



names = [0]*len(Sset)

for i, name in enumerate(Sset):
    cnt = 0
    for s in S:
        if(name==s):
            cnt += 1
            names[i] = (name, cnt)
max = 0
for n in names:
    if max<n[1]:
        max = n[1]
ans = []
for n in names:
    if n[1]==max:
        ans.append(n[0])

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import collections

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

s_count = collections.Counter(s)

values = []
ans = []

for key in list(s_count.keys()):
    values.append(s_count.get(key))

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

ans.sort()

for word in ans:
    print(word)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
s = [input() for i in range(n)]
t = set(s)
ma = 0
tmp = []
for i in t:
    tmp2 = s.count(i)
    if ma < tmp2:
        ma = tmp2
        tmp = [i]
    elif ma == tmp2:
        tmp.append(i)
tmp.sort()
#print()
for i in tmp:
    print(i)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
s = [input() for i in range(n)]
t = set(s)
ma = 0
tmp = []
for i in t:
    if ma < s.count(i):
        ma = s.count(i)
for i in t:
    if ma == s.count(i):
        tmp.append(i)
tmp.sort()
#print()
for i in tmp:
    print(i)

Submission status: Time Limit Exceeded

Solution code:
from collections import Counter
n = int(input())
s = [str(input()) for _ in range(n)]
num = Counter(s).most_common()[0][1]
ans = []
for i in range(len(Counter(s).most_common())):
    if Counter(s).most_common()[i][1] == num:
        ans.append(Counter(s).most_common()[i][0])
ans.sort()
for i in range(len(ans)):
    print(ans[i])

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
freq = []
slst = []
sset = set()
for i in range(n):
  temp = input()
  if temp not in sset:
    slst.append(temp)
    sset.add(temp)
    freq.append(0)
  else:
    freq[slst.index(temp)] += 1
fmax = max(freq)
for i in range(len(freq)):
  if freq[i] < fmax:
    sset.discard(slst[i])
mflst = list(sset)
mflst.sort()
for i in range(len(mflst)):
  print(mflst[i])

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
freq = []
slst = []
sset = set()
for i in range(n):
  temp = input()
  if temp not in sset:
    slst.append(temp)
    sset.add(temp)
    freq.append(0)
  else:
    freq[slst.index(temp)] += 1
fmax = max(freq)
mflst = []
for i in range(len(freq)):
  if freq[i] == fmax:
    mflst.append(slst[i])
mflst.sort()
for i in range(len(mflst)):
  print(mflst[i])

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
freq = []
slst = []
for i in range(n):
  temp = input()
  if temp not in slst:
    slst.append(temp)
    freq.append(0)
  else:
    freq[slst.index(temp)] += 1
fmax = max(freq)
mflst = []
for i in range(len(freq)):
  if freq[i] == fmax:
    mflst.append(slst[i])
mflst.sort()
for i in range(len(mflst)):
  print(mflst[i])

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
a=[input() for i in range(n)]
b=list(set(a))
c=[]
d=0
for i in b:
  if a.count(i)>d:
    c=[i]
    d=a.count(i)
  elif a.count(i)==d:
    c+=[i]
c.sort()
for i in c:
  print(i)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

dic ={}

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

l = [j for j, k in dic.items() if k == max(dic.values())]
l.sort()

for a in l:
    print(a)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import collections
N = int(input())
S = {}
for i in range(N):
    value = input()
    if value in S:
        S[value] += 1
    else:
        S[value] = 1
S_sorted = sorted([k for k, v in S.items() if v == max(S.values())])
for ans in S_sorted:
    print(ans)

Submission status: Time Limit Exceeded

Solution code:
import collections
N = int(input())
S = []
for i in range(N):
    S.append(input())
S_counter = collections.Counter(S)
S_max = [Sv[0] for Sv in S_counter.items() if Sv[1] == max(S_counter.values())]
S_max_sorted = sorted(S_max)
for ans in S_max_sorted:
    print(ans)

Submission status: Time Limit Exceeded

Solution code:
import collections
N = int(input())
S = []
for i in range(N):
    S.append(input())
S_counter = collections.Counter(sorted(S))
S_max = [Sv[0] for Sv in S_counter.items() if Sv[1] == max(S_counter.values())]
S_max_sorted = sorted(S_max)
for ans in S_max_sorted:
    print(ans)

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

Submission status: Time Limit Exceeded

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

keys = [k for k, v in count.items() if v == max(count.values())]
for w in sorted(keys):
    print(w)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
input_line = [input() for _ in range(N)]
temp = 0
result = []
for x in list(set(input_line)):
    if temp < input_line.count(x):
        temp = input_line.count(x)
        result = []
        result.append(x)
    elif temp == input_line.count(x):
        temp = input_line.count(x)
        result.append(x)
for x in sorted(result):
    print(x)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
#155
def main():
    N = int(input())
    S = [input() for i in range(N)]
    S_set = set(S)
    max_num = 0
    candidate = []
    for s in S_set:
        if S.count(s) == max_num: 
            candidate.append(s)
        elif S.count(s) > max_num:
            max_num = S.count(s)
            candidate=[s]
    candidate.sort()
    for c in candidate:
        print(c)
main()

Submission status: Time Limit Exceeded

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

for s_idx in range(N):
    s = input()
    
    if s not in S_dict.keys():
        S_dict.update({s:1})
    else:
        S_dict.update({s:S_dict[s]+1})
        
s_max=max(S_dict.values())

ans = []    
 
for a,b in S_dict.items():
    if b == s_max:
        ans.append(a)
    
ans.sort()
 
for i in ans:
    print(i)

Submission status: Time Limit Exceeded

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

for s_idx in range(N):
    s = input()
    
    if s not in S_dict.keys():
        S_dict[s]=1
    else:
        S_dict[s]+=1
        
s_max=max(S_dict.values())

ans = []    
 
for a,b in S_dict.items():
    if b == s_max:
        ans.append(a)
    
ans.sort()
 
for i in ans:
    print(i)

Submission status: Time Limit Exceeded

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

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

s_max=0
s_max_key=[]

for s_key in S_dict.keys():
    if s_max < S_dict[s_key]:
        s_max_key=[]
        s_max=S_dict[s_key]
        s_max_key.append(s_key)
    elif s_max == S_dict[s_key]:
        s_max=S_dict[s_key]
        s_max_key.append(s_key)
        
s_max_key.sort()

for ans in s_max_key:
    print(ans)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
S = []
Count = [0]*N

for T in range(0,N):
    Poll = input()
    if Poll in S:
        Count[S.index(Poll)] += 1
    else:
        S.append(Poll)
        Count[len(S)-1] += 1

Count = Count[:len(S)]
MaxIndex = [N for N,V in enumerate(Count) if V==max(Count)]
MaxS = sorted([S[I] for I in MaxIndex])
print('\n'.join(MaxS))

Submission status: Time Limit Exceeded

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

N = int(input())

counter = []
num = []

for i in range(N):
    temp = input()
    if temp in counter:
        num[counter.index(temp)] += 1
    else:
        counter.append(temp)
        num.append(1)

m = max(num)

joined = []
for i in range(len(num)):
    joined.append([-1 * num[i], counter[i]])

joined.sort()

for i in range(len(num)):
    if joined[i][0] == -1 * m:
        print(joined[i][1])
    else:
        break

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
input_line = [input() for _ in range(N)]
count = {}
for x in list(set(input_line)):
    count[x] = input_line.count(x)
max_count = max(count.values())
result = sorted([k for k, v in count.items() if v == max_count])
for x in result:
    print(x)

Submission status: Time Limit Exceeded

Solution code:
import collections
N = int(input())
S = [input() for i in range(N)]
D = collections.Counter(S)
print(*[j[0] for j in sorted(D.items()) if j[1] == max(D.values())], sep="\n")

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
D = {}
for i in range(N):
    s = input()
    if s in D:
        D[s] += 1
    else:
        D[s] = 0
print(*[j[0] for j in sorted(D.items()) if j[1] == max(D.values())], sep="\n")

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
D = {}
for i in range(N):
    s = input()
    if s in D:
        D[s] += 1
    else:
        D[s] = 0
E = sorted(D.items())
G = [j[0] for j in E if j[1] == max(D.values())]
print(*G, sep="\n")

Submission status: Time Limit Exceeded

Solution code:
n=int(input())

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

keys=sorted([k for k,v in dic.items() if v==max(dic.values()) ])
for i in keys:
    print(i)

Submission status: Time Limit Exceeded

Solution code:
n=int(input())

dic={}
for i in range(n):
    s=input()
    if s not in dic:
        dic[s]=1
    else:
        dic[s]+=1
dic2=sorted(dic.items(), key=lambda x:x[1],reverse=True)

keys=sorted([k for k,v in dic.items() if v==max(dic.values()) ])
for i in keys:
    print(i)

Submission status: Time Limit Exceeded

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

P = list(set(S))
ANS1 = []
ANS2 = []
for i in range(len(P)):
  ANS1.append([S.count(P[i]), P[i]])
  ANS2.append(S.count(P[i]))
  
M = max(ANS2)
ANS = []
for i in range(len(ANS1)):
  if ANS1[i][0] == M:
    ANS.append(ANS1[i][1])
  else:
    pass
  
ANS.sort()
for i in range(len(ANS)):
  print(ANS[i])

Submission status: Time Limit Exceeded

Solution code:
from collections import Counter

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

for _ in range(N):
    s=input()
    S.append(s)

c=Counter(S)

max_s_list= [kv[0] for kv in c.items() if kv[1]==max(c.values())]

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

Submission status: Time Limit Exceeded

Solution code:
N=int(input())
Sarr1=[]
Sarr2=[]
for _ in range(N):
    s=input()
    if Sarr1.count(s)==0:
        Sarr1.append(s)
        Sarr2.append(0)
    else:
        i=Sarr1.index(s)
        Sarr2[i]+=1
ans=[]
for i in range(len(Sarr2)):
    if Sarr2[i]==max(Sarr2):
        ans.append(Sarr1[i])
    else:
        pass
FA=sorted(ans)
for z in FA:
    print(z)

Submission status: Time Limit Exceeded

Solution code:
N=int(input())
Sarr1=[]
Sarr2=[]
for _ in range(N):
    s=input()
    if Sarr1.count(s)==0:
        Sarr1.append(s)
        Sarr2.append(0)
    else:
        i=Sarr1.index(s)
        Sarr2[i]+=1
ans=[]
m=max(Sarr2)
for i in range(len(Sarr2)):
    if Sarr2[i]==m:
        ans.append(Sarr1[i])
    else:
        pass
FA=sorted(ans)
for z in FA:
    print(z)

Submission status: Time Limit Exceeded

Solution code:
N=int(input())
Sarr1=[]
Sarr2=[]
for _ in range(N):
    s=input()
    if Sarr1.count(s)==0:
        Sarr1.append(s)
        Sarr2.append(0)
    else:
        i=Sarr1.index(s)
        Sarr2[i]+=1
ans=[]
for i in range(len(Sarr2)):
    if Sarr2[i]==max(Sarr2):
        ans.append(Sarr1[i])
    else:
        pass
FA=sorted(ans)
for z in FA:
    print(z)

Submission status: Time Limit Exceeded

Solution code:
import collections

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

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

s = collections.Counter(S)

max_list = [ml[0] for ml in s.items() if ml[1] == max(s.values())]
max_list.sort()

for i in max_list:
    print(i)

Submission status: Time Limit Exceeded

Solution code:
def main():
  K=list()
  L=list()
  N=int(input())
  R=[0]*N
  t=set()
  for i in range(N):
    A=input()
    if A in t:
      R[L.index(A)]+=1
      L.append(A)
    else:
      R[i]=1
      L.append(A)
    t=set(L)
  c=max(R)
  for i in range(N):
    if R[i]==c:
      K.append(L[i])
  K=sorted(K)
  for i in range(len(K)):
    print(K[i])
if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
K=list()
L=list()
N=int(input())
R=[0]*N
for i in range(N):
  A=input()
  if A in L:
    R[L.index(A)]+=1
    L.append(A)
  else:
    R[i]+=1
    L.append(A)
c=max(R)
for i in range(N):
  if R[i]==c:
    K.append(L[i])
K=sorted(K)
for i in range(len(K)):
  print(K[i])

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
you=[]
al=[]
vot=[]
for i in range(n):
  s=input()
  al.append(s)
  if not s in you:
    you.append(s)
vot=[]
for i in you:
   vot.append(al.count(i)) 
inum = [n for n, v in enumerate(vot) if v==max(vot)]

ans=[]
for i in inum:
  ans.append(you[i])
ans.sort()
for i in ans:
  print(i)

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
lis=[]
vot=[]
for i in range(n):
  s=input()
  if not s in lis:
    lis.append(s)
    vot.append(1)
  else:
    vot[lis.index(s)]+=1
inum = [n for n, v in enumerate(vot) if v==max(vot)]

ans=[]
for i in inum:
  ans.append(lis[i])
ans.sort()
for i in ans:
  print(i)

Submission status: Time Limit Exceeded

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

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

max_kv_list = [kv[0] for kv in dic.items() if kv[1] == 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:
def v_count(l, v):
  n = 0
  while v in l:
    l.remove(v)
    n += 1
  return n

def main():
  N = int(input())
  S = [input() for i in range(N)]
  result = []
  max = 0
  while len(S) > 0:
    buf = S[0]
    n = v_count(S, buf)
    if n > max:
      max = n
      result = [buf]
    elif n == max:
      result.append(buf)
      
  result.sort()

  for s in result:
    print(s)

main()

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(indexlist):
    print(setlist[j])