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:
from collections import Counter

num = int(input())

tmp = [input() for i in range(num)]

count = Counter(tmp)

tmp2 = [k for k, v in count.items() if count.most_common(1)[0][1] == v]

for t in sorted(tmp2):
  print(t)

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_list = [i]
        max_i = a.count(i)
    elif max_i == a.count(i):
        max_list.append(i)

max_list.sort()

for i in max_list:
    print(i)

Submission status: Time Limit Exceeded

Solution code:
n= int(input())
s = [input()for i in range(n)]
t = set(s)
t=sorted(t)
ans =[]
for i in t:
    ans.append(s.count(i))
mx = max(ans)
for i in range(len(t)):
    if mx == ans[i]:
        print(t[i])

Submission status: Time Limit Exceeded

Solution code:
import bisect 
N = int(input())
max_keys = []
max_cnt = 1
c = {}
for _ in range(N):
    s = input()
    if s in set(c.keys()):
        c[s] += 1
    else:
        c[s] = 1

    if max_cnt == c[s]:
        bisect.insort(max_keys, s)
    elif max_cnt < c[s]:
        max_keys = [s]
        max_cnt = c[s]

for x in max_keys:
    print(x)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
sList = [input() for _ in range(n)]
sSet = set(sList)
num = [[sList.count(i), i] for i in sSet]
ind = 0
ans = []
for i in range(len(sSet)):
    if ind < num[i][0]:
        ans = [num[i][1]]
        ind = num[i][0]
    elif ind == num[i][0]:
        ans.append(num[i][1])
ans.sort()
print("\n".join(ans))

Submission status: Time Limit Exceeded

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


s=[]
m=0
for i in range(n):
    if li.count(li[i])>m:
        s=[li[i]]
        m=li.count(li[i])
    elif li.count(li[i])==m:
        s.append(li[i])

s=set(s)
s=list(s)
s.sort()
l=len(s)
for i in range(l):
    print(s[i])

Submission status: Time Limit Exceeded

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

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

S_KEYS = set(S)


n= 1

for key in S_KEYS:
    m = S.count(key)
    if n < m:
        n = m
        
ANS = []
for key in S_KEYS:
    if S.count(key) == n:
        ANS +=[key]

ANS= sorted(ANS)
 
for key in ANS:
        print(key)

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)):
  if l.count(i) == max_num:
    max_words.append(i)
  elif l.count(i) > 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())
l = []
for i in range(N):
    l.append(input())
s = set(l)
cd = {}
m = 0
for i in range(len(s)):
    st = s.pop()
    ct = l.count(st)
    cd[st] = ct
    if ct > m:
        m = ct

ans = []

for i in cd:
    if cd[i] == m:
        ans.append(i)

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

Submission status: Time Limit Exceeded

Solution code:
# C - Poll
N = int(input())
S = [input() for i in range(N)]
Ss = list(set(S))
scounts = {}
for s in Ss:
    scounts[s] = S.count(s)

maximam = max(scounts.values())
answers = list()
for s in Ss:
    if scounts[s] == maximam:
        answers.append(s)

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

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
s=[[0, 'papa']]

for _ in range(n):
  t = str(input())
  l=len(s)
  for i in range(l):
    if t == s[i][1]:
      s[i][0]+=1
      break
      continue
  s.append([1, t])
s.sort()
l=len(s)
m=s[l-1][0]
for i in range(l):
  if s[i][0]==m:
    print(s[i][1])

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
s = [input() for i in range(n)]
dist = set(s)
dic = {}
ans = []
[dic.update({i: s.count(i)}) for i in dist]
max_num = max(dic.values())
[ans.append(i) for i in dic if dic[i] == max_num]
for i in sorted(ans):
    print(i)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
L = {}
for i in range(n):
  a = input()
  if a not in L:  
    L[a] = 1
  else:
    L[a] += 1
M = [k for k, v in L.items() if v == max(L.values())]
M.sort()
for i in range(len(M)):
  print(M[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 = list()

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 c.most_common()[0][1] == 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 = ""
for _ in range(n):
    s += input()+" "
ls = s.split()
counter = 0
res = []
for x in ls:
    if ls.count(x) > counter:
        counter = ls.count(x)
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 = []
res_list = []
max_str = 0
for i in range(n):
  in_str = str(input())
  s.append(in_str)
  temp_str = s.count(in_str)
  if temp_str > max_str:
    res_list = []
    res_list.append(in_str)
    max_str = temp_str
  elif temp_str == max_str:
    res_list.append(in_str)

res_list = list(set(res_list))

res_list.sort()
for res in res_list:
  print(res)

Submission status: Time Limit Exceeded

Solution code:
amount = int(input())
l = []
max = 1

for i in range(amount):
    a = input()
    l.append(a)

output = []

for i in range(len(l)):
    many = l.count(l[i])
    if many == max:
        if l[i] not in output:
            output.append(l[i])
    elif many > max:
        output = []
        max = many
        output.append(l[i])

output.sort()
for k in range(len(output)):
    print(output[k])

Submission status: Time Limit Exceeded

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

tmp = []
m = 0
for i in range(n):
    if s.count(s[i]) == m and (s[i] in tmp) == False:
        tmp.append(s[i])
    elif s.count(s[i]) > m:
        tmp = [s[i]]
        m = s.count(s[i])

tmp.sort()

for i in tmp:
    print(i)

Submission status: Time Limit Exceeded

Solution code:
def main():
	n = int(input())
	l = [str(input()) for i in range(n)]
	ans = []
	ans_2 = []
	for i in range(n):
		if ans.count(l[i]) == 0:
			ans.append(l[i])
			ans_2.append(l.count(l[i]))
	indexes = [i for i, x in enumerate(ans_2) if x == max(ans_2)]
	ans_3 = []
	for s in indexes:
		ans_3.append(ans[s])
	ans_3.sort()


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


	
	
 
if __name__ == '__main__':
	main()

Submission status: Time Limit Exceeded

Solution code:
import collections

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

#print(N,S)
#print("------------")
c = collections.Counter(S)
#print(c.most_common())
max_count = c.most_common()[0][1]

T = []
for i in range(N):
    if len(c.most_common()) > 1:
        if c.most_common()[i][1] == max_count:
            T.append(c.most_common()[i][0])
        else:
            break
    else:
        T.append(c.most_common()[0][0])
        break

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

Submission status: Time Limit Exceeded

Solution code:
import collections
n=int(input())
s=[input() for k in range(n)]
s1=sorted(list(set(s)))
c=collections.Counter(s)
p=[]
for i in s1:
    p.append(c[i])
for j, x in enumerate(p):
    if(x == max(p)):
        print(s1[j])

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
a=[]
for i in range(n):
    a.append(input())
c=[]
for i in range(n):
    if(a[i] not in c):
        c.append(a[i])
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
max=0
for i in range(l):
    if(b[i]>max):
        max=b[i]
        d.clear()
        tt=1
        d.append(c[i])
    elif(b[i]==max):
        tt=tt+1
        d.append(c[i])
d.sort()
for i in range(tt):
    print(d[i])

Submission status: Time Limit Exceeded

Solution code:
N=int(input())
S=[input() for i in range(N)]
S.sort()
def list_count(my_list):
    dic={} #辞書型の宣言
    for num in my_list:
        if num in dic: #もしnumがkeyとして辞書にあれば
            dic[num]+=1 #valueに+1
        else: #なければ
            dic[num]=1 #dicにnumというkeyを追加し、対応するvalueを1とする
    return dic

A=list_count(S)
max_k_list = [kv[0] for kv in A.items() if kv[1] == max(A.values())]
max_k_list.sort()
for j in range(len(max_k_list)):
    print(max_k_list[j])

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
lst = []
dic = {}
for i in range(0,N):
  inp = input()
  if inp not in dic:
    dic[inp] = 1
  else:
    dic[inp] +=1

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

keys.sort()

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

Submission status: Time Limit Exceeded

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

SA=list(set(S))
d=[0]*len(SA)
for i in range(len(SA)):
  d[i]=S.count(SA[i])

MAX=[i for i, v in enumerate(d) if v == max(d)]

SB=[]
for i in MAX:
  SB.append(SA[i])

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

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
s=[input() for _ in range(n)]
s.sort()
s.append("")
#print(s)
a=[]
count=[]
buf=1
for i in range(n):
    if s[i]==s[i+1]:
        buf+=1
    else:
        a.append(s[i])
        count.append(buf)
        buf=1
#print(a)
#print(count)
for i in range(len(a)):
    if count[i]==max(count):
        print(a[i])

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

mes_dict = {}
for i in range(N):
  m = input()
  if m not in mes_dict:
    mes_dict[m] = 0
  mes_dict[m] += 1

answer = sorted([k for k, v in mes_dict.items() if v == max(mes_dict.values())])
for ans in answer:
  print(ans)

Submission status: Time Limit Exceeded

Solution code:
import sys

n = input()
arr = [_.replace('\n', '') for _ in sys.stdin]
dic = {}
for s in arr:
  if s in dic.keys():
    dic[s] += 1
  else:
    dic[s] = 1
s = [k for k,v in dic.items() if v == max(dic.values())]
for i in sorted(s):
  print(i)

Submission status: Time Limit Exceeded

Solution code:
from collections import Counter
N = int(input())
L = []
for n in range(N):
    S = input()
    L.append(S)
Dic = Counter(L)
max_k_list = [kv[0] for kv in Dic.items() if kv[1] == max(Dic.values())]
max_k_list = sorted(max_k_list)
for t in max_k_list:
    print(t)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

A = [''] * N
for i in range(N):
  A[i] = str(input())
  
B = list(set(A))
B.sort()

C = [0] * len(B)

for i in range(len(B)):
  C[i] = A.count(B[i])
  
m = max(C)
ans = [n for n, v in enumerate(C) if v == m]

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

Submission status: Time Limit Exceeded

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


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:
# -*- coding: utf-8 -*-
# 整数の入力
#a = int(input())
# スペース区切りの整数の入力
#b, c = map(int, input().split())
# スペース区切りの整数リストの入力
#l = list(map(int, input().split()))
# 文字列の入力
#s = input()
# 出力
#print("{} {}".format(a+b+c, s))
#Print Yes or No
#print('YNeos'[1::2])
#print('YNeos'[0::2])
#print('NYoe s'[1::2])
#print('NYoe s'[0::2])
#print('YNEOS'[0::2])
#print('NYOE S'[1::2])


import re
import numpy as np
import math

#a = int(input())
#b, c = map(int, input().split())
#l = list(map(int, input().split()))


n = int(input())
s=[]
c=[]
for i in range(0,n):
  ns=input()
  if ns in s:
    c[s.index(ns)] += 1
  else:
    #new
    s.append(ns)
    c.append(1)

cmax = max(c)
c = np.array(c)
anss=np.array(s)[c==cmax]

anss.sort()
print("\n".join(anss))

Submission status: Time Limit Exceeded

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

data_list_a = set(data_list)
data_list_a = list(data_list_a)

data_a = [0 for i in range(len(data_list_a))]

for i in range(len(data_list_a)):
    for j in range(n):
        if data_list[j] == data_list_a[i]:
            data_a[i] += 1


#print(data_list)
#print(data_list_a)
#print(data_a)
ans_a = []
d = max(data_a)
for i in range(len(data_list_a)):
    if data_a[i] == d:
        ans_a.append(i)

ans = []

for i in range(len(ans_a)):
    ans.append(data_list_a[ans_a[i]])

ans.sort()

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

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
hako = []
jisho = {}
for i in range(n):
  hako.append(input())
hako_2 = set(hako)
for h in hako_2:
  jisho[h] = hako.count(h)
#print(jisho)
jisho_sorted = sorted(jisho.items(), key=lambda x:x[1])
#print(jisho_sorted)
saidai = jisho_sorted[-1][-1]
kotae = []
for i in jisho_sorted:
  if i[-1] == saidai:
    kotae.append(i[0])
kotae.sort()
for ans in kotae:
  print(ans)

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={}
max_appeard=0
ans_list=[]
list_set=set(input_list)
for item in list_set:
    appeard=Counter(input_list)[item]
    if appeard >= max_appeard:
        max_appeard=appeard
        ans[item]=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:
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 = []
for i in range(len(letter)):
  if num_letter[i] == max_num_letter:
    max_letter.append(letter[i])
max_letter = sorted(max_letter)
for i in range(len(max_letter)):
  print(max_letter[i])

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
S = [input() for i in range(N)]
S_uni = set(S)
# print(S)
# print(S_uni)
m = 0
l = []
for i in S_uni:
    c = S.count(i)
    # print(i,c)
    if c > m:
        m = c
        l = [i]
    elif c == m:
        l.append(i)

# print("============")
l.sort()
for i in l:
    print(i)

Submission status: Time Limit Exceeded

Solution code:
a = int(input())
b = [input() for i in range(a)]

q = sorted(set(b))
e = [b.count(k) for k in q]

t = max(e)
for l, p in enumerate(e):
  if p == t:
    print(q[l])

Submission status: Time Limit Exceeded

Solution code:


N=int(input())

S_list = []
S_count = []
max = 1
for i in range(N):
    s = input()
    if s in S_list:
        index = S_list.index(s)
        #S_count.append(S_count[index]+1)
        S_count[index] += 1
        if max < S_count[index]:
            max = S_count[index]
    else:
        S_list.append(s)
        S_count.append(1)
        #if max < S_count[i]:
        #    max = S_count[i]
     
#print(S_list)
#print(S_count)
#print(max)
S_max = []
for j in range(len(S_list)):
    if S_count[j] == max:
        S_max.append(S_list[j])

S_max.sort()
for k in range(len(S_max)):
    print(S_max[k])

Submission status: Time Limit Exceeded

Solution code:
S = [input() for _ in range(int(input()))]
T = set(S)
cnt =0
ans = dict()
for t in T:
    li = S.count(t)
    ans[t] = li
    cnt = max(cnt,li)
ans = sorted(ans.items(),reverse=True, key=lambda x:x[1])
key = sorted([k for k,v in ans if v == cnt])
for a in key:print(a)

Submission status: Time Limit Exceeded

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

S = sorted(S)

v = S[0]
c = S.count(v)
del S[0:c]
L = [[v,c]]

while S != []:
    v = S[0]
    c = S.count(v)
    del S[0:c]
    if L[0][1] == c:
        L.append([v,c])
    elif L[0][1] < c:
        L = [[v,c]]

for l in L:
    print(l[0])

Submission status: Time Limit Exceeded

Solution code:
import collections

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

c = collections.Counter(a)
naga=len(c)
ma=c.most_common()[0][1]

for i in range(naga):
    if c.most_common()[::-1][i][1]==ma:
        print(c.most_common()[::-1][i][0])

Submission status: Time Limit Exceeded

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

setTexts = set(texts)

maxFreq = 0
for i in setTexts:
  num = texts.count(i)
  if maxFreq < num:
    maxFreq = num

mostFreqTexts = []
for i in setTexts:
  num = texts.count(i)
  if maxFreq == num:
    mostFreqTexts.append(i)

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

Submission status: Time Limit Exceeded

Solution code:
n = int(input())


s_count ={}

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



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

result = sorted(max_s_list)

for k in result:
    print(k)

Submission status: Time Limit Exceeded

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

for i in range(N):
  s=input()
  if s in dict:
    dict[s]=dict[s]+1
  else:
    dict[s]=1
    
keys = [k for k, v in dict.items() if v == max(dict.values())]
res = sorted(keys)
for word in res:
  print(word)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
s_list = []

for i in range(n):
    s_list.append(input())
    
import collections
s_dict = collections.Counter(s_list)
max_s_dict = [k for k, v in s_dict.items() if v == max(s_dict.values())]
max_s_dict.sort()
for i in range (len(max_s_dict)):
    print(max_s_dict[i])

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

name = []
num = []

max_temp = 1

for _ in range(N):
    temp = input()
    if not temp in name:
        name.append(temp)
        num.append(1)
    else:
        x = name.index(temp)
        num[x] += 1
        if num[x] > max_temp:
            max_temp = num[x]
            
        
output = []

for i in range(len(num)):
    if num[i] == max_temp:
        output.append(name[i])
        
output.sort()

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

Submission status: Time Limit Exceeded

Solution code:
import collections
n=int(input())
string_list=[input() for i in range(n)]
l = collections.Counter(string_list)
keys = [k for k, v in l.items() if v == max(l.values())]
keys = sorted(keys)
for x in range(len(keys)):
	print(keys[x])

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
        print()
    else:
        S.append(x)
        Snum.append(0)

maxnum=max(Snum)
ans=[]
for i in range(len(Snum)):
    if Snum[i]==maxnum:
        ans.append(S[i])


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

Submission status: Time Limit Exceeded

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

new_s_lst = list(set(s_lst))
ans_list = []
for i in new_s_lst:
    ans_list.append([s_lst.count(i),i])

ans_list.sort(reverse=True)
tmp = ans_list[0][0]
ans = []
for i in ans_list:
    if i[0] == tmp:
        ans.append(i[1])
    else:
        break
ans.sort()
[print(i) for i in ans]

Submission status: Time Limit Exceeded

Solution code:
from collections import defaultdict

d = defaultdict(int)
S = []

N = int(input())
for i in range(N):
    d[input()] += 1

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

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

Submission status: Time Limit Exceeded

Solution code:
from collections import Counter

num = int(input())

# tmp = []
# for n in range(num):
#   tmp.append(input())

tmp = [input() for i in range(num)]

count = Counter(tmp)

tmp2 = []
for k, v in count.items():
  if count.most_common(1)[0][1] == v:
    tmp2.append(k)

for t in sorted(tmp2):
  print(t)

Submission status: Time Limit Exceeded

Solution code:
import collections


n = int(input())
ss = []
for i in range(n):
    s = input()
    ss.append(s)
ss = sorted(ss, key=str.lower)

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

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

Submission status: Time Limit Exceeded

Solution code:
import collections
def resolve_c():
    n = input()
    s_l = [input() for i in range(int(n))]
    c = collections.Counter(s_l)
    results = [k for k, v in c.items() if v == c.most_common()[0][1]]
    results = sorted(results)
    for r in results:
        print(r)
resolve_c()

Submission status: Time Limit Exceeded

Solution code:
num = int(input())

words = []
for _ in range(num):
    words.append(input())


max_words = []
max_count = 0
for word in words:
    if word in max_words:
        continue

    if words.count(word) > max_count:
        max_count = words.count(word)
        max_words = [word]
    elif words.count(word) == max_count:
        max_words.append(word)

max_words.sort()

for max_word in max_words:
    print(max_word)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
max_keys = []
max_cnt = 1
c = {}
for _ in range(N):
    s = input()
    if s in set(c.keys()):
        c[s] += 1
    else:
        c[s] = 1

    if max_cnt == c[s]:
        max_keys.append(s)
    elif max_cnt < c[s]:
        max_keys = [s]
        max_cnt = c[s]

for x in sorted(max_keys):
    print(x)

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)

for i in range(len(c)):
    if (l_c[i] == m):
        print(c[i])

Submission status: Time Limit Exceeded

Solution code:
n, *str_n = open(0).read().split()
n = int(n)
dictionary = list(set(str_n))
dictionary.sort()
dic_num = [0] * len(dictionary)

for i in range(n):
    for word in dictionary:
        if str_n[i] == word:
            dic_num[dictionary.index(word)] += 1

max_vote = [i for i, v in enumerate(dic_num) if v == max(dic_num)]

for i in max_vote:
    print(dictionary[i])

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

existed_dict = {}
max_count = 0
max_text_list = []
for _ in range(N):
    text = input()
    if text in existed_dict.keys():
        existed_dict[text] += 1
    else:
        existed_dict[text] = 1
    if existed_dict[text] == max_count:
        max_count = existed_dict[text]
        max_text_list.append(text)
    elif existed_dict[text] > max_count:
        max_count = existed_dict[text]
        max_text_list = []
        max_text_list.append(text)
    else:
        pass

for text in sorted(max_text_list):
    print(text)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
S_list = []
S_count_list = []

for n in range(N):
    s = input()

    if s in S_list:
        index_s = S_list.index(s)
        S_count_list[index_s] += 1
    
    else:
        S_list.append(s)
        S_count_list.append(1)

max_list = [i for i, v in enumerate(S_count_list) if v == max(S_count_list)]

max_S_list = []
for i in max_list:
    max_S_list.append(S_list[i])

max_S_list.sort()

for ans_s in max_S_list:
    print(ans_s)

Submission status: Time Limit Exceeded

Solution code:
from collections import Counter

num = int(input())

# tmp = []
# for n in range(num):
#   tmp.append(input())

tmp = [input() for i in range(num)]

count = Counter(tmp)

tmp2 = []
for k, v in count.items():
  if count.most_common(1)[0][1] == v:
    tmp2.append(k)

for t in sorted(tmp2):
  print(t)

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 = 0
max_words = []
for i in list(set(l)):
  if l.count(i) > max_num:
    max_num = l.count(i)
    max_words = [i]
  elif l.count(i) == max_num:
    max_words.append(i)

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

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
s = [input() for i in range(n)]
s.sort()
l = sorted(set(s))
ans = 0
ans_l = []

for i in l:
    if s.count(i) > ans:
      ans_l.clear()
      ans_l.append(i)
      ans = s.count(i)
    elif s.count(i) == ans:
      ans_l.append(i)
    del s[:s.count(i)-1]
      

print("\n".join(ans_l))

Submission status: Time Limit Exceeded

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

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

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

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())
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])

Submission status: Time Limit Exceeded

Solution code:
import collections
n=int(input())
a=collections.OrderedDict()
for i in range(n):
    tmp=input()
    if not tmp in a:
        a[tmp] = 1
    else:
        a[tmp] += 1
a = collections.OrderedDict(
    sorted(a.items(), key=lambda x: x[0])
)
for k, v in a.items():
    if v == max(a.values()):
        print(k)

Submission status: Time Limit Exceeded

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

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

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:
n = int(input())
s = []
for i in range(n):
  s.append(input())
dic = {}
for i in set(s):
  if s.count(i) not in dic.keys():
    dic[s.count(i)] = [i]
  else:
    dic[s.count(i)].append(i)
a = max(list(dic.keys()))
dic[a] = sorted(dic[a])
for i in dic[a]:
  print(i)

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
      if num_letter[j] > max_num_letter:
        max_num_letter = num_letter[j]
      flag = 1
      break
  if flag == 0:
    letter.append(S)
    num_letter.append(1)

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

Submission status: Time Limit Exceeded

Solution code:
a = int(input())
b = list()
for i in range(a):
    b.append(str(input()))
c = dict()
for j in b:
    if j in c:
        c[j] += 1
    else:
        c[j] = 1
maxes = [k for k, v in c.items() if v == max(c.values())]
for i in sorted(maxes):
    print(i)

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
from collections import Counter
n = int(input())
c = Counter()

for _ in range(n):
  c += Counter([input()])
  
m = 0
mc = []
  
for item, count in c.most_common():  
  if m == 0:
    m = count
  
  if m > count:
    break
  
  mc += [item]

mc.sort()

for item in mc:
  print(item)

Submission status: Time Limit Exceeded

Solution code:
import numpy as np

inp = int(input())

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

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

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

Submission status: Time Limit Exceeded

Solution code:
a=int(input())

index_list=[]
list=[]

for i in range(a):
    #print(i)
    inpu=input()
    if inpu in list:
        index_list[list.index(inpu)] +=1
    else:
        list.append(inpu)
        index_list.append(1)

maxm=max(index_list)
max_count=index_list.count(maxm)

res_list=[]
for i in range(max_count):
    res_list.append(list[index_list.index(maxm)])
    list.remove(list[index_list.index(maxm)])
    index_list.remove(maxm)

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

Submission status: Time Limit Exceeded

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

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

# calc
s2 = sorted(set(s))
times = []

for word in s2: 
    times.append(s.count(word)) 

maxtimes = max(times)
answords = []

for i in range(len(s2)):
    if maxtimes == times[i]:
        answords.append(s2[i])

answords = sorted(answords)
for word in answords:
    print(word)

Submission status: Time Limit Exceeded

Solution code:
import collections

n=int(input())

li=[]
ma=0
an=[]

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

c=collections.Counter(li)
ma=c.most_common()[0][1]


for j in range(n):
    if c.most_common()[j][1]==ma:
        an.append(c.most_common()[j][0])
        
        if len(c)==j+1:
            break
    else:
        break

an.sort()

for k in range(len(an)):
    print(an[k])

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
S = [None]*N
for i in range(N):
    S[i] =input()
S = sorted(S)
num = 0
temp = 1
lis_num=[None]*N
lis_name = [None]*N
for i in range(N):
    if i !=N-1:
        if S [i] == S[i+1]:
            temp+=1
        else :
            lis_num[num] = temp
            temp=1
            lis_name[num] = S[i]
            num+=1
    else:
        lis_num[num] = temp
        temp=1
        lis_name[num] = S[i]
        num+=1

for i in range(num):
    if lis_num[i] == max(lis_num[0:num]):
        print(lis_name[i])