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())
ls = []
for _ in range(n):
    ls.append(input())
res = []
counter = ls.count(max(set(ls),key=ls.count))
for x in set(ls):
    if ls.count(x) == counter:
        res.append(x)
r = sorted(res)
print("\n".join(r))

Submission status: Time Limit Exceeded

Solution code:
N=int(input())
S=[]
L=[]
C=[]

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

S.sort()
L.append(S[0])
C.append(S.count(S[0]))

for i in range(1,N):
    if S[i]!=S[i-1]:
        L.append(S[i])
        C.append(S.count(S[i]))
count_max=max(C)
for i in range(len(L)):
    if C[i]==count_max:
        print(L[i])

Submission status: Time Limit Exceeded

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


data_set = set(data_list)
sorted_list = sorted(data_set)

count_list = [0] * len(sorted_list)

for i in range(len(sorted_list)):
    count_list[i] = data_list.count(sorted_list[i])

max_indexes = [i for i, x in enumerate(count_list) if x == max(count_list)]

for i in range(len(max_indexes)):
    print(sorted_list[max_indexes[i]])

Submission status: Time Limit Exceeded

Solution code:
N=int(input())
S = [input() for i in range(N)]
P=[]
P0=[]
A=[]
for i in range(len(S)):
    c=S.count(S[i])
    P0.append(c)
    if i==0:
        P.append(c)
    elif P[-1] < c:
        P.append(c)

for k in range(len(P0)):
    if P0[k]==P[-1]:
        A.append(S[k])

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

for List in A1:
    print(List)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
from collections import Counter


N=int(input())
l=['']*N
for i in range(N):
    l[i]=input()

c = Counter(l).most_common()
top=c.pop(0)
ans=[top[0]]
freq=top[1]

while len(c) > 0:
    top=c.pop(0)
    if top[1] == freq:
        ans.append(top[0])
    else:
        break

ans.sort()

for e in ans:
    print(e)

Submission status: Time Limit Exceeded

Solution code:
N=int(input())
s10=[]*10
S=[s10]*N
Li=[]
Ls=[]
Ld=[]
max_id=0
for i in range(N):
    S[i]=input()
for i in range(N):
    if S[i] in Ls:
        idx=Ls.index(S[i])
        Li[idx]+=1
        a=Li[idx]
    else:
        Ls.append(S[i])
        Li.append(1)
        a=1
    if max_id<a:
        max_id=a
for i in range(len(Li)):
    if max_id==Li[i]:
        Ld.append(Ls[i])
Ld=sorted(Ld)
for i in range(len(Ld)):
    print(Ld[i])

Submission status: Time Limit Exceeded

Solution code:
from operator import itemgetter 

import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
N = int(readline())
S = read().split()

dic = {}
for i in S:
    if i in dic:
        dic[i] += 1
    else:
        dic[i] = 1
        
dic_sorted = sorted(dic.items(), key=itemgetter(1, 0))[::-1]

res = []
n = dic_sorted[0][1]
i = 0
l = len(dic_sorted)
while i < l and dic_sorted[i][1] == n:
    #print(dic_sorted[i][0])
    res = [dic_sorted[i][0].decode()] + res
    i += 1
    
print('\n'.join(res))

Submission status: Time Limit Exceeded

Solution code:
N=int(input())
index=[]
count=[]
for i in range(N):
    inp=input()
    if inp in index:
        count[index.index(inp)]=count[index.index(inp)]+1
    else:
        index.append(inp)
        count.append(1)

rank=set(count)
rank=sorted(rank)[-1]
o=[]
while rank in count:
    o.append(index.pop(count.index(rank)))
    del count[count.index(rank)]
o.sort()
for i in o:
    print(i)

Submission status: Time Limit Exceeded

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

c = sorted(list(set(s)))
l_c = [0] * len(c)

for i in range(len(c)):
    l_c[i] = s.count(c[i])

m = max(l_c)

ans = [i for i, x in enumerate(l_c) if x == m]

for i in ans:
    print(c[i])

Submission status: Time Limit Exceeded

Solution code:
import sys
input = sys.stdin.readline

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

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

Submission status: Time Limit Exceeded

Solution code:
from collections import defaultdict
import heapq

N = int(input())
mm = defaultdict(int)

for i in range(N):
    key = input()
    mm[key] += 1


max_mms = [kv for kv in mm.items() if kv[1] == max(mm.values()) ]
max_mms.sort()

for i,k in max_mms:
    print(i)

Submission status: Time Limit Exceeded

Solution code:
n = int(input()) #1行目のNを取得する
s = [input() for i in range(n)]
s2 = list(set(s))
s2.sort()
li = [0]*len(s2)

for i in range(len(s2)):
    li[i] = 0
    for j in range(len(s)):
        if s2[i] == s[j]:
            li[i]+=1

max_value = max(li)

for i in range(len(s2)):
    if max_value == li[i]:
        print(s2[i])

Submission status: Time Limit Exceeded

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

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

for i in range(N):
	for j in range(N):
		if S[i]==S[j]:
			count[i]+=1              

for i in range(N):
	if max(count)==count[i]:
		A.append(S[i])
A=sorted(set(A))

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

Submission status: Time Limit Exceeded

Solution code:
input_line=int(input())
count=0
input_list=[]
while count < input_line:
  input_list.append(input())
  count+=1
ans={}
max_appeard=0
ans_list=[]
for item in input_list:
    appeard=input_list.count(item)
    ans[item]=appeard
    if appeard > max_appeard:
        max_appeard=appeard
for key,value in ans.items():
    if value==max_appeard:
        ans_list.append(key)
ans_list.sort()
for item in ans_list:
  print (item)

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
import collections

N = int(input())
data = list([input() for i in range(N)])

dicdata = collections.Counter(data)

newdata = [k for k, v in dicdata.items() if v == max(dicdata.values())]

newdata = sorted(newdata)

[print(i) for i in newdata]

Submission status: Time Limit Exceeded

Solution code:
def main():
    N=int(input())
    A=[input() for i in range(N)]
    NA=[A.count(A[i]) for i in range(N)]
    NIN=[i for i, v in enumerate(NA) if v == max(NA)]
    NM=sorted(list(set([A[NIN[i]] for i in range (len(NIN))])))
    for i in range (len(NM)):
        print(NM[i])
if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
from collections import Counter
import collections

N = int(input())
a = [input() for i in range(N)]



c = collections.Counter(a)

list = []
if(len(c.most_common()) == 1):
	list.append(c.most_common()[0][0])



for i in range(0,len(c.most_common())-1):
    if(c.most_common()[i][1] == c.most_common()[0][1]):
        list.append(c.most_common()[i][0])

if(len(c.most_common()) == N):
  list.append(c.most_common()[N-1][0])

list.sort()

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

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
D = {}
for n in range(N):
    w = input()
    if w not in D:
        D[w] = 0
    else:
        D[w] += 1
d = sorted(D.items())
d = sorted(D.items(),key=lambda x:-x[1])
m = d[0][1]
l = []
for (key, value) in d:
    if value == m:
        l.append(key)
    else:
        break
for s in sorted(l):
	print(s)

Submission status: Time Limit Exceeded

Solution code:
N=int(input())
counts=[]
A=[]
S=[]
T=[]
U=[]
for _ in range(N):
    s=input()
    S.append(s)
    if s not in T:
        T.append(s)
t=sorted(T)
for i in t:
    U.append(S.count(i))
V=[j for j,v in enumerate(U) if v==max(U)]

for k in V:
    print(t[k])

Submission status: Time Limit Exceeded

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

s_cnt = [0]*n
for i in range(n):
  s_cnt[s.index(s[i])] += 1

cnt_max = max(s_cnt)
s_unique = []
for i in range(n):
  if (s_cnt[i] == cnt_max):
    s_unique.append(s[i])

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

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

s = []
cnt = [0] * n
_max = 0
for i in range(n):
  tmp = input()
  if tmp not in s:
    s.append(tmp)
  else:
    cnt[s.index(tmp)] += 1
    if _max < cnt[s.index(tmp)]:
      _max = cnt[s.index(tmp)]
    
results = []
for i in range(len(cnt)):
  if cnt[i] == _max:
    results.append(s[i])

results.sort()
for result in results:
  print(result)

Submission status: Time Limit Exceeded

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

unique_S_lis = list(set(S_lis))
res = [S_lis.count(us) for us in unique_S_lis]
maxind = [i for i, x in enumerate(res) if x == max(res)]
lis_ans = sorted([unique_S_lis[i] for i in maxind])

for ans in lis_ans:
    print(ans)

Submission status: Time Limit Exceeded

Solution code:
# ABC155 C

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

for _ in range(n):
    S.append(input())

set_S = list(set(S))
count_S = []

for string in set_S:
    count_S.append(S.count(string))

max_S = max(count_S)

index_nums = [n for n, v in enumerate(count_S) if v == max_S]
res = []

for i in index_nums:
    res.append(set_S[i])

for _ in sorted(res):
    print(_)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
S = []
for i in range(N):
    dummy = input()
    S.append(dummy)
#print(S)
S = sorted(S)
#print(S)
CNT = []
for i in range(N):
    CNT.append(S.count(S[i]))
#print(CNT)
MAX = max(CNT)
i = 0
while i < N:
    if(CNT[i] == MAX):
        print(S[i])
    i += CNT[i]

Submission status: Time Limit Exceeded

Solution code:
import sys
input = sys.stdin.readline
n = input()
n = int(n)
slist = []
countlist = []
resultlist = []

for i in range(0,n):
  slist.append(input())

setlist = list(set(slist))

for i in setlist:
  countlist.append(slist.count(i))

for i in setlist:
  if slist.count(i) == max(countlist):
    resultlist.append(i)
resultlist = sorted(resultlist)
for i in resultlist:
  print(i)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
S = list(str(input()) for _ in range(N))
S2 = sorted(S)
cnt1 = [0,]
cnt2 = [0,]*N
word = [0,]
for i in range(N-1):
    if S2[i] != S2[i+1]:
        cnt1.append(i+1)
        word.append(S2[i])
cnt2 = [0,]*len(cnt1)
for i in range(1,len(cnt1)):
    cnt2[i] = cnt1[i] - cnt1[i-1]
cnt2.append(N-sum(cnt2))
word.append(S2[N-1])
for i in range(len(cnt2)):
    if cnt2[i] == max(cnt2):
        print(word[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.index(s) + 1] += 1
    else:
        S.append(s)
        S.append(1)

max = 0
for i in range(len(S) // 2):
    if S[i * 2 + 1] > max:
        max = S[i * 2 + 1]

# 結果の表示
result=[]
for t in S:
    # print(t)
    if t == max:
        # print(S.index(t) - 1)
        result.append(S[S.index(t) - 1])
        S[S.index(t)] = 0
# print('result---------')
# print(S)

result.sort()
for r in result:
    print(r)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
s = [input() for i in range(n)]
s.sort()
l = sorted(set(s))
ms = len(s) - len(l)
if ms == 0:
    print("\n".join(s))
    exit()

ans = 0
ans_l = []
for i in l:
    sc = s.count(i)
    if sc > ans:
        ans_l = [i]
        ans = sc
    elif sc == ans:
        ans_l.append(i)
      
print("\n".join(ans_l))

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
s=['']*n
sn=[0]*n
l=0

for _ in range(n):
  t = input()
  for i in range(l):
    if t == s[i]:
      sn[i]+=1
      break
      continue
  s[l]=t
  sn[l]+=1
  l+=1
m=max(sn)
ans=[]
for i in range(l):
  if sn[i]==m:
    ans.append(s[i])
ans.sort()
for i in range(len(ans)):
  print(ans[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:
        d[s[i]] += 1
    else:
        d[s[i]] = 1

ma = [m[0] for m in d.items() if m[1] == max(d.values())]
print(*sorted(ma))

Submission status: Time Limit Exceeded

Solution code:
import collections

a = int(input())
max = -1

mos = []
aom = []

for i in range(a):
    b = input()
    mos.append(b)

if len(set(mos)) == a:
    mos.sort()
    for i in mos:
        print(i)
elif len(set(mos)) == 1:
    print(mos[0])
else:
    c = collections.Counter(mos)
    for i in range(len(mos)):
        if max == -1:
            aom.append(c.most_common()[i][0])
            max = int(c.most_common()[i][1])
        elif max == int(c.most_common()[i][1]):
            aom.append(c.most_common()[i][0])
        else:
            break
    



aom.sort()

for i in aom:
    print(i)

Submission status: Time Limit Exceeded

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

for i in range(n):
    s=input()
    if not a.get(s):
        a[s]=1
    else:
        v=a[s]
        v+=1
        a[s]=v
ans=[]
for i in a.items():
    if i[1]==max(a.values()):
        ans.append(i[0])

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

Submission status: Time Limit Exceeded

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

s_list=[]
for i in range(n):
  s=str(input())
  s_list.append(s)
  
s_dict=collections.Counter(s_list)
    
ans = [kv[0] for kv in s_dict.items() if kv[1] == max(s_dict.values())]
for a in sorted(ans):
  print(a)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
S = []
for i in range(N):
  S.append(input())
C = []
for i in range(N):
  C.append(S.count(S[i]))
m = max(C)
S_new = sorted(set(S))
for s in S_new:
  if S.count(s) == m:
    print(s)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
words = list()
for i in range(0, n):
    words.append(input())

s_words = set(words)
d_words = {}
for word in s_words:
    d_words.update({word: words.count(word)})

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

for a in answer:
    print(a)

Submission status: Time Limit Exceeded

Solution code:
import collections


N = int(input()) #1行目のNを取得する
s = [input() for i in range(N)] #複数行の数値の入力を取得

counted = collections.Counter(s)
#最頻値が同値である場合全て出力したい
#頻出数ではなく、文字だけ出力したい
ret = [letter for letter,count in counted.most_common() if count == counted.most_common()[0][1]]
new_ret=sorted(ret)
[print(i) for i in new_ret]

Submission status: Time Limit Exceeded

Solution code:
from bisect import insort_left
from sys import stdin

input = stdin.readline
n = int(input())

d = {}
m = 1
for i in range(n):
    s = input().rstrip()
    d.setdefault(s, 0)
    d[s] += 1
    if m < d[s]:
        m = d[s]

l = []
for i, j in d.items():
    if j == m:
        insort_left(l, i)
        
print("\n".join(l))

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
Counted = []
num = [0 for _ in range(N)]

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

Dict = list(zip(Counted, num))
Dict_sorted = sorted(Dict,key=lambda x: x[1], reverse = True)

VVV = []

for i in range(len(Dict_sorted)):
  if Dict_sorted[i][1] == Dict_sorted[0][1]:
    VVV.append(Dict_sorted[i][0])
  else:
    break

SSS = sorted(VVV)

for _ in range(len(SSS)):
  print(SSS[_])

Submission status: Time Limit Exceeded

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


data_set = set(data_list)
sorted_list = sorted(data_set)

count_list = [0] * len(sorted_list)

for i in range(len(sorted_list)):
    for j in range(len(data_list)):
        if sorted_list[i] == data_list[j]:
            count_list[i] +=1

max_indexes = [i for i, x in enumerate(count_list) if x == max(count_list)]

for i in range(len(max_indexes)):
    print(sorted_list[max_indexes[i]])

Submission status: Time Limit Exceeded

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

c = collections.Counter(s)
k = c.most_common()[0][1]

if n == 1:
    print(s[0])
elif n >= 2 and len(c.keys()) == 1:
    print(c.most_common()[0][0])
else:
    for i in range(n):
        if k == c.most_common()[i][1]:
            ans.append(c.most_common()[i][0])
        else:
            break

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

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
s=["as"]*n
for i in range(0,n):
  s[i]=input()
st=[s[0]]
count=[1]
#st.append(st[0])
#count.append(1)
for i in range(1,n):
  k=0
  for j in range(0,len(st)):
    if s[i]==st[j]:
      count[j]+=1
    else:
      k+=1
  if k==len(st):
    st.append(s[i])
    count.append(1)
maxcount=0
maxs=[]
maxn=[]
for i in range(0,len(st)):
  if count[i]>maxcount:
    maxn=[i]
    maxs=[st[i]]
    maxcount=count[i]
    #maxn.append(i)
    #maxs.append(st[i])
  elif count[i]==maxcount:
    maxn.append(i)
    maxs.append(st[i])
maxed=sorted(maxs)
for i in range(0,len(maxed)):
  print("%s"% maxed[i])

Submission status: Time Limit Exceeded

Solution code:
import collections

n=int(input())
l=[]
for i in range(n):
    l.append(input())
l2=collections.Counter(l)


max_k_list = [kv[0] for kv in l2.items() if kv[1] == max(l2.values())]
l3=sorted(max_k_list)
print("\n".join(l3))

Submission status: Time Limit Exceeded

Solution code:
inp = int(input())

l = []
for i in range(0, inp):
  l.append(input())

# print(sorted(l))
max_num = 1
max_words = []
for i in list(set(l)):
  c = l.count(i)
  if c < max_num:
    pass
  elif c == max_num:
    max_words.append(i)
  elif c > max_num:
    max_num = l.count(i)
    max_words = [i]

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

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
words = [[]]*N
for i in range(N):
  words[i] = str(input())
maximum = 1
for j in set(words):
  maximum = max(maximum, words.count(j))
wlist = []
for k in set(words):
  if words.count(k) == maximum:
    wlist.append(k)
wlist.sort()
for l in range(len(wlist)):
  print(wlist[l])

Submission status: Time Limit Exceeded

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

S_set= list(set(S))

dic = dict(zip(S_set, [0 for _ in range(len(S_set))]))

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

K_max = max(list(dic.values()))

for (k, v) in dic.items():
    if K_max != v:
        S_set.pop(S_set.index(k))
        
for s in sorted(S_set): print(s)

Submission status: Time Limit Exceeded

Solution code:
from collections import Counter
import heapq

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

word_count=Counter(word)

ans=[k for k, v in word_count.items() if v == max(word_count.values())]
cnt=len(ans)
heapq.heapify(ans)
for i in range(cnt):
    print(heapq.heappop(ans))

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

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

no_ol = list(set(S))
max_s = 0
ans_list = []

for i in range(len(no_ol)):
    tmp = S.count(no_ol[i])
    if max_s == tmp:
        ans_list.append(no_ol[i])
    elif tmp>max_s:
        ans_list = []
        max_s = tmp
        ans_list.append(no_ol[i])


ans_list.sort()
[print(i) for i in ans_list]

Submission status: Time Limit Exceeded

Solution code:
import numpy as np


n = int(input())
s = []

# for i in range(n):
#     s.append(input())

buf = []
cnt = []

for i in range(n):
    buf2 = input()
    if buf2 not in buf:
        buf.append(buf2)
        cnt.append(0)
    cnt[buf.index(buf2)] += 1

# for i in s:
#     if i not in buf:
#         buf.append(i)
#         cnt.append(0)
#     cnt[buf.index(i)] += 1

ans = np.where(cnt == np.max(cnt))[0].tolist()


# ans = [i for i, x in enumerate(cnt) if x == max(cnt)]

ans2 = [buf[i] for i in range(len(buf)) if i in ans]

ans3 = sorted(ans2)

for i in ans3:
    print(i)

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
a=[]
for i in range(n):
    a.append(input())
z= set(a)
c=list(z)
l=len(c)
b=[0]*l
for i in range(n):
    if(a[i] in c):
        inn=c.index(a[i])
        b[inn]=b[inn]+1
d=[]
tt=0
maxi=0
for i in range(l):
    if(b[i]>maxi):
        maxi=b[i]
        d.clear()
        tt=1
        d.append(c[i])
    elif(b[i]==maxi):
        tt=tt+1
        d.append(c[i])
d.sort()
for i in range(tt):
    print(d[i])

Submission status: Time Limit Exceeded

Solution code:
import sys
input = sys.stdin.readline

n = int(input())

s = []
cnt = [0] * n
for i in range(n):
  tmp = input()
  tmp = tmp.strip()
  if tmp not in s:
    s.append(tmp)
  else:
    cnt[s.index(tmp)] += 1

_max = 0
for c in cnt:
  if _max < c:
    _max = c
    
results = []
for i in range(len(cnt)):
  if cnt[i] == _max:
    results.append(s[i])

results.sort()
for result in results:
  print(result)

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:
        d[s[i]] += 1
    else:
        d[s[i]] = 1

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

ma = [m[0] for m in d.items() if m[1] == max(d.values())]
print(*sorted(ma))

Submission status: Time Limit Exceeded

Solution code:
def main():
    N=int(input())
    A=[input() for i in range(N)]
    NA=[A.count(A[i]) for i in range(N)]
    NIN=[i for i, v in enumerate(NA) if v == max(NA)]
    NM=[A[NIN[i]] for i in range (len(NIN))]
    NM=sorted(list(set(NM)))
    for i in range (len(NM)):
        print(NM[i])
if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
import collections


N = int(input()) #1行目のNを取得する
s = [input() for i in range(N)] #複数行の数値の入力を取得

counted = collections.Counter(s)
#最頻値が同値である場合全て出力したい
#頻出数ではなく、文字だけ出力したい
ret = [letter for letter,count in counted.most_common() if count == counted.most_common()[0][1]]
new_ret=sorted(ret)
for i in range(len(new_ret)):
    print(new_ret[i])# ['a', 'c']

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
a = [input() for i in range(N)]
b = []
ans = []
flag = 1
for i in range(N):
    c = a.count(a[i])
    b.append(c)
    if flag == 1:
        max = c
        flag = 0
    if c > max:
        max = c
for i in range(N):
    if b[i] == max:
        if(ans.count(a[i]) < 1):
            ans.append(a[i])
ans = sorted(ans, key=str.lower)

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

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
a = []
max_list = []
max_i = 0

for i in range(n):
    a.append(str(input()))

a2 = a
for i in set(a2):
    if max_i < a.count(i):
        max_i = a.count(i)

max_list = [x for x in set(a) if a.count(x) == max_i]

max_list.sort()

for i in max_list:
    print(i)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
T = []
L = []
for i in range(0,N):
    S = str(input())
    L.append(S)

T.append([L[0],1])  
for i in range(1,N):
    for j in range(0,len(T)):
        if L[i] == T[j][0]:
            T[j][1] += 1
            break
        elif j == len(T)-1:
            T.append([L[i],1])

Max = 0
for i in range(0,len(T)):
    if T[i][1] > Max:
        Max = T[i][1]

ans = []
for i in range(0,len(T)):
    if T[i][1] == Max:
        ans.append(T[i][0])

ans = sorted(ans)

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
N = int(input()) #1行目のNを取得する
s = [input() for i in range(N)] #複数行の数値の入力を取得

import collections
counted = collections.Counter(s)
#最頻値が同値である場合全て出力したい
#頻出数ではなく、文字だけ出力したい
ret = [letter for letter,count in counted.most_common() if count == counted.most_common()[0][1]]
new_ret=sorted(ret)
for i in range(len(new_ret)):
    print(new_ret[i])# ['a', 'c']

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
S = []
for i in range(N):
  S.append(input())
import collections
d = collections.Counter(S)
l = [k for k, v in d.items() if v == max(d.values())]
#print('\n'.join(sorted(l)))
for i in sorted(l):
  print(i)

Submission status: Time Limit Exceeded

Solution code:
# ABC155 C

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

for _ in range(n):
    S.append(input())

set_S = list(set(S))
count_S = []

for string in set_S:
    count_S.append(S.count(string))

index_nums = [n for n, v in enumerate(count_S) if v == max(count_S)]
res = []

for i in index_nums:
    res.append(set_S[i])

for _ in sorted(res):
    print(_)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

letter = []
num_letter = []
letter.append(input())
num_letter.append(1)
max_num_letter = 1

for i in range(1,N):
  S = input()
  flag = 0
  for j in range(len(letter)):
    if letter[j] == S:
      num_letter[j]+=1
      flag = 1
      break
  if flag == 0:
    letter.append(S)
    num_letter.append(1)

max_num_letter = max(num_letter)
max_letter = []

max_letter = [letter[i] for i in range(len(letter)) if num_letter[i] == max_num_letter]
max_letter = sorted(max_letter)
for i in range(len(max_letter)):
  print(max_letter[i])

Submission status: Time Limit Exceeded

Solution code:
from collections import Counter

input_line=int(input())
count=0
input_list=[]
while count < input_line:
  input_list.append(input())
  count+=1
ans_list=[]
list_set=set(input_list)
max_appeard=Counter(input_list).most_common(1)[0][1]
for item in list_set:
    appeard=Counter(input_list)[item]
    if appeard >= max_appeard:
        max_appeard=appeard
        ans_list.append(item)
ans_list.sort()
for item in ans_list:
  print (item)

Submission status: Time Limit Exceeded

Solution code:
import sys
from collections import defaultdict
d = defaultdict(int)
input = sys.stdin.readline


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

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

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

for ans in max_k_list:
    print(ans)

Submission status: Time Limit Exceeded

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

P=sorted(list(set(S)))
T=[]
m=S.count(P[0])
T.append(P[0])
for i in range(1,len(P)):
    if S.count(P[i])>m:
        m=S.count(P[i])
        T.clear()
        T.append(P[i])
    elif S.count(P[i])==m:
        T.append(P[i])
for j in range(len(T)):
    print(T[j])

Submission status: Time Limit Exceeded

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


def main():
    while True:
        unique = list(set(S))
        #print(unique)

        if len(unique) == len(S):
            return S

        for u in unique:
            S.remove(u)

        #print(S)


out = main()
out = sorted(out)
for o in out:
    print(o)

Submission status: Time Limit Exceeded

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

def main():
    n = int(input())
    d = dict()

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

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

if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

Solution code:
from collections import Counter
N=int(input())
S=list()
Y=list()
for i in range(N):
    S.append(input())
X=Counter(S)
Y.append(X.most_common()[0][0])
for i in range(len(X)-1):
    if X.most_common()[i][1] == X.most_common()[i+1][1]:
        Y.append(X.most_common()[i+1][0])
    else:
        break
Y.sort()
for i in range(len(Y)):
    print(Y[i])

Submission status: Time Limit Exceeded

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

for i in range (0,N):
    a = input()
    list_a.append(a)
dict_a = collections.Counter(list_a)


list_ans = []

list_ans.append(dict_a.most_common()[0][0])
for i in range (1,len(dict_a)):
    if dict_a.most_common()[0][1] == dict_a.most_common()[i][1]:
        list_ans.append(dict_a.most_common()[i][0])

list_ans.sort()
for i in range (0,len(list_ans)):
    print(list_ans[i])

Submission status: Time Limit Exceeded

Solution code:
from sys import stdin

n = int(stdin.readline().rstrip())
s = []
d = [0] * 200000 
max = 1

for i in range(n):
    t = stdin.readline().rstrip()
    d[i] = 1
    for ss in s:
        if t == ss:
            d[i] = d[i] + 1
            if max < d[i]:
                max = d[i]
    s.append(t)

result = []        
for cnt in range(len(d)):
    if d[cnt] == max:
        result.append(s[cnt])

result.sort()
for r in result:
    print(r)

Submission status: Time Limit Exceeded

Solution code:
inp = int(input())

l = []
for i in range(0, inp):
  l.append(input())

# print(sorted(l))
max_num = 1
max_words = []
for i in list(set(l)):
  c = l.count(i)
  if c == max_num:
    max_words.append(i)
  elif c > max_num:
    max_num = l.count(i)
    max_words = [i]

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
wordlist = [input() for i in range(n)]
wordlist2 = list(set(wordlist))
ans = []
maxnum = 0
for j in range(len(wordlist2)) :
    countnum = wordlist.count(wordlist2[j])
    if countnum == maxnum :
        ans.append(wordlist2[j])
    if countnum > maxnum :
        maxnum = countnum
        ans = []
        ans.append(wordlist2[j])
    while wordlist2[j] in wordlist :
        wordlist.remove(wordlist2[j])
ans.sort()
for l in range(len(ans)) :
    print(ans[l])

Submission status: Time Limit Exceeded

Solution code:

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

    if x in S:
        num=S.index(x)
        Snum[num]+=1

    else:
        S.append(x)
        Snum.append(0)

maxnum=max(Snum)
ans=[]

indexes = [i for i, x in enumerate(Snum) if x == maxnum]

for i in indexes:
    ans.append(S[i])


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

Submission status: Time Limit Exceeded

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