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())
S = [input() for i in range(N)]
count_dict = {}
for s in S:
  if not s in count_dict.keys():
    count_dict[s] = 1
  else:
    count_dict[s] += 1
count_dict = dict(filter(lambda x: x[1] >= max(count_dict.values()), count_dict.items()))
ans = list(count_dict.keys())
ans.sort()
for s in ans:
  print(s)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

s_dict={}
for i in range(n):
  s=str(input())
  if s in s_dict:
    s_dict[s] += 1
  else:
    s_dict[s] = 1  
    
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:
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=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:
N = int(input())
S = []
for i in range(N):
  S.append(input())

letter = []
num_letter = []

letter.append(S[0])
num_letter.append(1)
max_num_letter = 1
for i in range(1,N):
  flag = 0
  for j in range(len(letter)):
    if letter[j] == S[i]:
      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[i])
    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:
#300
N = int(input())
S = [input() for _ in range(N)]
L = [0 for _ in range(N)]
L1 = ["" for _ in range(N)]
S.sort()
k = 0


for i in range(N):
    if i == 0:
        L[k] = 1 
        L1[k] = S[i]
    else:
        if S[i-1] == S[i]:
            L[k] = L[k] + 1
        else:
            L[k+1] = 1
            L1[k+1] = S[i]
            k += 1

for i in range(N):
    if L[i] == max(L):
        print(L1[i])

Submission status: Time Limit Exceeded

Solution code:
import sys
import math
import fractions
import bisect
import queue
import heapq
from collections import deque
sys.setrecursionlimit(4100000)

MOD = int(1e9+7)
PI = 3.14159265358979323846264338327950288
INF = 1e18

'''
1行のint=====================================
N, K = map(int, input().split())

A, B = map(int, input().split())

H, W = map(int, input().split())

L, R = map(int, input().split())

1行のstring=================================
S, T = input().split()

1行の整数配列================================
P = list(map(int,input().split()))

A = list(map(int,input().split()))
B = list(map(int,input().split()))

D = list(map(int,input().split()))

L = list(map(int,input().split()))
R = list(map(int,input().split()))

T = list(map(int,input().split()))

改行あり整数==================================
X = []
Y = []
for i in range(N):
    x1,y1=[int(i) for i in input().split()]
    X.append(x1)
    Y.append(y1)

A = []
B = []
for i in range(N):
    x1,y1=[int(i) for i in input().split()]
    A.append(x1)
    B.append(y1)

Pair = []
for i in range(N):
    x1,y1=[int(i) for i in input().split()]
    Pair.append((x1, y1))


N行M列の初期化====================================
dp = [[VAL] * RETU for i in range(GYO)]

'''

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

S.sort()

ans = [] # (name, times)



for i in range(N):
    renzoku = 0

    for j in range(i, N):
        if S[i]==S[j]:
            renzoku+=1
            if j == N-1:
                ans.append((renzoku, S[i]))
                break

        else:
            ans.append((renzoku, S[i]))
            i=j-1
            break


ans.sort()
saidai = ans[-1][0]

for a in ans:
    if a[0] == saidai:
        print(a[1])

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

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

m = 0
ans = []
for i in range(N):
    if m < S.count(S[i]):
        ans = []
        ans.append(S[i])
        m = S.count(S[i])
    if m == S.count(S[i]):
        ans.append(S[i])

a = sorted(set(ans))

for i in a:
    print(i)

Submission status: Time Limit Exceeded

Solution code:
N=int(input())
A=[]
int_max=0
str_max=[]
for i in range(N):
    A.append(input())
B=list(set(A))
for i in range(len(B)):
    if int_max<A.count(B[i]):
        str_max=[B[i]]
        int_max=A.count(B[i])
    elif int_max==A.count(B[i]):
        str_max.append(B[i])
str_max.sort()
for i in str_max:
    print(i)

Submission status: Time Limit Exceeded

Solution code:
import collections
N = int(input())
A = []
for i in range(N):
  A.append(input())
a = collections.Counter(A)
n = a.most_common()[0][1]
l = []
for i in range(len(a)):
  if a.most_common()[i][1] != n:
    break
  l.append(a.most_common()[i][0])
l.sort()
for o in l:
  print(o)

Submission status: Time Limit Exceeded

Solution code:
import collections

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

setted_S = set(S)
counted_S = collections.Counter(S)

ans_ls = []
for k, v in counted_S.items():
    if v == max(counted_S.values()):
        ans_ls.append(k)

ans_ls.sort()

for i in ans_ls:
    print(i)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
s = []
for i in range(n):
    si = input()
    s.append(si)
    
s.sort()
sset = set(s)
ns = len(sset)
cou = []
pri = []
pre = 0

for i in range(ns):
    c = s.count(s[pre])
    cou.append(c)
    pre += c
    pri.append(s[pre-1])
    
M = max(cou)
for i in range(ns):
    if cou[i] == M:
        print(pri[i])

Submission status: Time Limit Exceeded

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

done_list = []
res_list = []
max_str = 0  

for st in s:
  if st in done_list:
    continue
    
  done_list.append(st)
  temp_str = s.count(st)
  if temp_str > max_str:
    res_list = []
    res_list.append(st)
    max_str = temp_str
  elif temp_str == max_str:
    res_list.append(st)

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

Submission status: Time Limit Exceeded

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

counter = collections.Counter(S)

answers = [k for k, v in counter.items() if v == max(counter.values())]
answers.sort()
for x in answers:
  print(x)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

LL = []
for count in range(N):
    LL.append(str(input()))
LLCount = []
for count in range(N):
    LLCount.append(LL.count(LL[count]))

LLS = []
ss = max(LLCount)

for count in range(N):
    if LLCount[count] == ss:
        LLS.append(LL[count])

ans = list(dict.fromkeys(LLS))
ans.sort()
for aa in ans:
    print(aa)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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


dict = {}
for s in sl:
    if s in dict:
        dict[s] += 1
    else:
        dict[s] = 1

# max_num = max(dict.values())
#
# dict = sorted(dict.items())
# for k, v in dict.items():
#     if v == max_num:
#         print(k)


# dict_s2 = sorted(dict.items(), key=lambda x:x[1], reverse=True)

ans = [k for k, v in dict.items() if v == max(dict.values())]
ans = sorted(ans)
ans_ = '\n'.join(ans)
print(ans_)

Submission status: Time Limit Exceeded

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

for s in S_set:
    cnt1 = S.count(s)
    if cnt < cnt1:
        ans.clear()
        ans.append(s)
        cnt = cnt1
    elif cnt == cnt1:
        ans.append(s)

ans.sort()

for a in ans:
    print(a)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
mydict = {}
for i in range(N):
  t = input()
  if t in mydict:
    mydict[t]+=1
  else:
    mydict[t] = 1
max_k_list = [kv[0] for kv in mydict.items() if kv[1] == max(mydict.values())]
max_k_list.sort()
for i in max_k_list:
  print(i)
  """
  li.append(mydict[i])
li.sort()
for i in li:
  print(i)
"""

Submission status: Time Limit Exceeded

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import sys

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

mx = 0
d = {}
r = []

for a in A:
    if not a in d:
        d[a] = 0
    d[a] += 1
    if d[a] > mx:
        r = [a]
        mx = d[a]
    elif d[a] == mx:
        if not a in r:
            r.append(a)
            r.sort()

for i in r:
    print(i)

Submission status: Time Limit Exceeded

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

d = {}

for item in s:
    if not item in d.keys():
        d[item] = 1
    else:
        d[item] += 1

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

for item in m:
    print(item)

Submission status: Time Limit Exceeded

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

#S.sort()

dic = list((set(S)))
times = [0] * len(dic)

for s in S :
    for i in range(len(dic)):
        if dic[i] == s:
            times[i] += 1

ans = [0] * len(dic)
ma = max(times)

s_ans = []

for a in range(len(dic)):
    if times[a] == ma:
        s_ans.append(dic[a])

s_ans.sort()

for j in range(len(s_ans)):
    print(s_ans[j])

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

S = []

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

cnt_ar = list(set(S))
cnt_ar.sort()

ar = []

for i in range(len(cnt_ar)):
  ar.append(S.count(cnt_ar[i]))

for i in range(len(ar)):
  if ar[i] == max(ar):
    print(cnt_ar[i])

Submission status: Time Limit Exceeded

Solution code:
N=int(input())
S = [input() for i in range(N)]
P={}
A=[]
for i in range(len(S)):
    P[S[i]] = S.count(S[i])

m=P[S[0]]
for k in range(len(S)):
    if m<P[S[k]]:
        m=P[S[k]]

for k in range(len(S)):
    if P[S[k]]==m:
        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())
lisa=[]
ans=0
for i in range(n):
    a=input()
    lisa.append(a)
    if ans<lisa.count(a):
        ans=lisa.count(a)
add=[]
for i in range(n):
    if lisa.count(lisa[i])==ans:
        add.append(lisa[i])
add=sorted(list(set(add)))
for i in range(len(add)):
    print(add[i])

Submission status: Time Limit Exceeded

Solution code:
from collections import defaultdict
import sys

def main():
    input = sys.stdin.readline
    n=int(input())
    dic=defaultdict(int)
    for i in range(n):
        dic[input().strip('\n')]+=1
    max_kv_list=[k for k,v in dic.items() if v==max(dic.values())]
    max_kv_list.sort()
    for i in range(len(max_kv_list)):
        print(max_kv_list[i])

if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
sl = []
s_count = []

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

ans = []
s_max = max(s_count)
for i in range(len(s_count)):
    if s_count[i] == s_max:
        ans.append(sl[i])

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

Submission status: Time Limit Exceeded

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

a = d.items()
b = d.values()
max_k_list = [kv[0] for kv in a if kv[1] == max(b)]
[print(i) for i in sorted(max_k_list)]

Submission status: Time Limit Exceeded

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

a = list(set(S))

b = []
n = 0
for i in range(len(a)):
  if n == S.count(a[i]):
    b.append(a[i])
  elif n < S.count(a[i]):
    b = [a[i]]
    n = S.count(a[i])

b.sort()
for j in b:
  print(j)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
li = []
for i in range(n):
  li.append(input())
li_a = sorted(list(set(li)))
li_ans = [0 for i in range(len(li_a))]
for x in li:
  b = li_a.index(x)
  li_ans[b] += 1
for i in range(len(li_ans)):
  if li_ans[i] == max(li_ans):
    print(li_a[i])

Submission status: Time Limit Exceeded

Solution code:
from collections import OrderedDict
def resolve():
    n = int(input())

    l = []
    for _ in range(n):
        l.append(input())

    count = OrderedDict()

    for name in l:
        if name not in count.keys():
            count[name] = 1

        else:
            count[name] += 1

    count = OrderedDict(
        sorted(count.items(), key=lambda x: x[0])
    )
    max_polls = max(count.values())

    for k, v in count.items():
        if v == max_polls:
            print(k)
            
resolve()

Submission status: Time Limit Exceeded

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

from fractions import gcd

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

num = 0
ans = []

for i in range(0,N):
    if S.count(S[i])>num:
        num=S.count(S[i])

for i in range(0,N):
    if S.count(S[i])==num:
        ans.append(S[i])

ans=list(set(ans))
ans.sort()

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

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

dic = dict()

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

# dic = sorted(dic.items(), key=lambda x:x[0])

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

max_list.sort()

for lis in max_list:
  print(lis)

Submission status: Time Limit Exceeded

Solution code:
n =int(input())
ss = []
ans = []
for i in range(n):
    s = input()
    if s in ss:
        ans[ss.index(s)] += 1
    else:
        ss.append(s)
        ans.append(1)
    
m = max(ans)
for i in range(len(ans)):
    if ans[i] != m:
        ss[i] = ""
ss = sorted([i for i in ss if i != ""])
for i in ss:
    print(i)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

existed_dict = {}
for _ in range(N):
    text = input()
    if text in existed_dict.keys():
        existed_dict[text] += 1
    else:
        existed_dict[text] = 1

max_count = max(existed_dict.values())

max_dict = {}
for k, v in existed_dict.items():
    if v == max_count:
        max_dict[k] = v
    else:
        pass

sorted_hash = sorted(max_dict, reverse=False)
for text in sorted_hash:
    print(text)

Submission status: Time Limit Exceeded

Solution code:
from collections import Counter

N = int(input())
c = Counter()
for i in range(N):
    k = input()
    v = c.setdefault(k, 0)
    c[k] = v + 1
ans = sorted([k for k,n in c.items() if n == max(c.values())])
[print(k) for k in ans]

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
s=[input() for i in range(n)]
l=list(sorted(set(s)))
li=[]
m=0
for x in l:
    m= max(m,s.count(x))
for x in l:
    if s.count(x)==m:
        li.append(x)
li=list(sorted(li))
for x in li:
    print(x)

Submission status: Time Limit Exceeded

Solution code:
import bisect

n = int(input())

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

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

Submission status: Time Limit Exceeded

Solution code:
import numpy as np

N = int(input())

dicdata = {}
for i in range(N):
	data = input()
	if data in dicdata:
		dicdata[data] += 1
	else:
		dicdata[data] = 1

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

newdata = sorted(newdata)

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

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
wordlist = [input() for i in range(n)]
wordset = set(wordlist)
wordlist2 = list(wordset)
checklist = []
ans = []
for j in range(len(wordlist2)) :
    checklist.append(wordlist.count(wordlist2[j]))
position = [i for i, x in enumerate(checklist) if x == max(checklist)]
for k in position :
    ans.append(wordlist2[k])
ans.sort()
for l in range(len(ans)) :
    print(ans[l])

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
S = []
m = 0
for i in range(n):
    S.append(input())
A = set(S)
al = {}
for i in A:
    al[i] = S.count(i)
    if S.count(i) > m:
        m = S.count(i)
s = []
for i in al:
    if al[i] == m:
        s.append(i)
s.sort()
for i in s:
    print(i)

Submission status: Time Limit Exceeded

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

d = {}

for key in s:
    if key not in d:
        # キーが存在しない場合の処理
        d[key] = 0
    d[key] += 1

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

Submission status: Time Limit Exceeded

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

ss = set(s)
sd = {}
for i in ss:
    sd[i] = s.count(i)
    
x = max(sd.values())
dl = []

for i in sd.items():
    if i[1] != x:
        dl.append(i[0])
        
for i in dl:
    del sd[i]
        
for i in sorted(sd):
    print(i)

Submission status: Time Limit Exceeded

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import sys

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

mx = 0
d = {}
r = []

for a in A:
    if not a in d:
        d[a] = 0
    d[a] += 1
    if d[a] > mx:
        r = [a]
        mx = d[a]
    elif d[a] == mx:
        if not a in r:
            r.append(a)

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

Submission status: Time Limit Exceeded

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

dic={poll2[i]:0 for i in range(len(poll2))}
for string in poll:
    dic[string]+=1

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

Submission status: Time Limit Exceeded

Solution code:
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())])

for ans in max_k_list:
    print(ans)

Submission status: Time Limit Exceeded

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

for _ in range(n):
  s = str(input())
  c += Counter([s])
  
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:
N=int(input())
S=[input() for _ in range(N)]
S.sort()
cnt=[0]*N
cnt[0]=1

for i in range(1,N):
    if S[i]==S[i-1]:
        cnt[i]=cnt[i-1]+1
    else:
        cnt[i]=1
cmax=max(cnt)
while cmax in cnt:
    A=cnt.index(cmax)
    print(S[A])
    cnt[A]=0

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

C = [0] * len(B)

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

ans = []
for i in ans_i:
  ans.append(B[i])
  
ans.sort()
for s in ans:
  print(s)

Submission status: Time Limit Exceeded

Solution code:
import bisect

n = int(input())

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

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

li = []
ans = [0] * n
for i in range(n):
    if s[i] in li:
        ans[li.index(s[i])] += 1
    else:
        li.append(s[i])
        ans[li.index(s[i])] += 1

mx = max(ans)
m = [i for i, j in enumerate(ans) if j == mx]

a = []
for k in range(len(m)):
    a.append(li[m[k]])

a.sort()
for n in range(len(a)):
    print(a[n])

Submission status: Time Limit Exceeded

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

max_s = 0
m_str = []
for i in range(n):
	temp = s.count(s[i])
	#print(temp,s[i],m_str)
	if temp > max_s :
		#print("if")
		max_s = temp
		m_str = []
		m_str.append(s[i])
	elif temp == max_s :
		#print("elif")
		if not s[i] in m_str:
			#print("if not")
			m_str.append(s[i])
score = {}
for i in m_str: score[i] = 1
#print(score)
score_sorted = sorted(score.items(),key=lambda x:x[0])
for ans in score_sorted:
	print(ans[0])

Submission status: Time Limit Exceeded

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

import collections
c =  collections.Counter(S)
MAX = max(c.values())
SET = []
for i in range(N):
    if S.count(S[i])==MAX:
        SET.append(S[i])
SET = list(set(SET))
SET.sort()
for item in SET:
    print(item)

Submission status: Time Limit Exceeded

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

words = []
cnt = dict()
for i in range(n):
  if s[i] not in words:
    words.append(s[i])
    cnt[s[i]] = 1
  else:
    cnt[s[i]] += 1

cnt_sorted = sorted(cnt.items(), key=lambda x:x[1], reverse=True)
top_words = []
for j in range(len(cnt_sorted)):
  if cnt_sorted[j][1] == cnt_sorted[0][1]:
    top_words.append(cnt_sorted[j][0])
  else:
    break

top_words =sorted(top_words)
for i in range(len(top_words)):
  print(top_words[i])

Submission status: Time Limit Exceeded

Solution code:
from collections import Counter

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

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

c = Counter(s)

max_count = c.most_common()[0][1]

a = []

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

b = sorted(a)

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

Submission status: Time Limit Exceeded

Solution code:
len = int(input())
namedic = {}
for i in range(len):
  name = input()
  if name in namedic:
    namedic[name] += 1
  else:
    namedic[name] = 1

max_k_list = [k[0] for k in namedic.items() if k[1] == max(namedic.values())]
for i in sorted(max_k_list):
  print(i)

Submission status: Time Limit Exceeded

Solution code:
N=int(input())

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

d_ =[k for k, v in d.items() if v == max(d.values())]
d_.sort()
for st in d_:
  print(st)

Submission status: Time Limit Exceeded

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

for i in range(len(a)):
	ans.append([s.count(a[i]),a[i]])

ans.sort(key=lambda x: x[1])
ans.sort(key=lambda x: x[0], reverse = True)

y = ans[0][0]

for i, j in ans:
	if y == i:
		print(j)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
s = {}
for _ in range(n) :
    s_sub = input()

    if s_sub in s.keys() :
        s[s_sub] += 1
    else :
        s[s_sub] = 1


s_sorted = sorted(s)

for j in s_sorted :
    if s[j] == max(s.values()):
        print(j)

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()
tmp = max(ans_list)

ans = [i[1] for i in ans_list if i[0] == tmp[0]]
[print(i) for i in ans]

Submission status: Time Limit Exceeded

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

dic = {}

for s in S:
  if s not in dic.keys():
    dic.setdefault(s, 0)
  dic[s] += 1

answers = [k for k, v in dic.items() if v == max(dic.values())]
answers.sort()
for x in answers:
  print(x)

Submission status: Time Limit Exceeded

Solution code:
import queue
import collections

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

c = collections.Counter(Ss)
mc = c.most_common()
_, prev = mc[0]
q = queue.PriorityQueue()
for k, v in mc:
    if prev != v:
        break
    q.put(k)
    prev = v

while not(q.empty()):
    print(q.get())

Submission status: Time Limit Exceeded

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

mydict = {}

for i in range(n):
    if List[i] in mydict.keys():
        mydict[List[i]] += 1
    else:
        mydict[List[i]] = 1
        
#sortdict = sorted(mydict.items(), reverse=True) 
res = [kv[0] for kv in mydict.items() if kv[1] == max(mydict.values())]


#print(sortdict)
res = sorted(res)
leng = len(res)
for i in range(leng):
    print(res[i])

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
lst = []
for i in range(n):
  lst.append(input())
  
count = {}
countLst = []
for i in lst:
  count[i] = lst.count(i)
  countLst.append(lst.count(i))
  
res = []
for i in count:
  if count[i] == max(countLst):
    res.append(i)
    
for i in sorted(res):
  print(i)

Submission status: Time Limit Exceeded

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


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

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

Submission status: Time Limit Exceeded

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

def solve(N: int, S: "List[str]"):

    d = defaultdict(int)
    for s in S:
        d[s]+=1

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


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    S = [next(tokens) for _ in range(N)]  # type: "List[str]"
    print(solve(N, S))

if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

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

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

S_dict = sorted(list(set(S)))
#print(S_dict)
cnt = [0] * len(S_dict)

for i, item in enumerate(S_dict):
  cnt[i] = S.count(item)
#print(cnt)

m_cnt = max(cnt)

for i, item in enumerate(cnt):
  if m_cnt == item:
    print(S_dict[i])

Submission status: Time Limit Exceeded

Solution code:
import sys

def main():
    flg=True
    tmp = int(input().replace('\n',''))
    strlist=[]
    for i in range(tmp):
        strlist.append(input().replace('\n',''))
    setstrlist = set(strlist)
    res = []
    for i in set(strlist):
        res.append([strlist.count(i),i])
    res = sorted(res,reverse=True)
    maxtmp = res[0][0]
    res2=[]
    for i in res:
        if i[0] == maxtmp:
            res2.append(i[1])
        else:
            break
    res2 = sorted(res2)
    print('\n'.join(res2))
if __name__ == '__main__':
    input = sys.stdin.readline
    main()

Submission status: Time Limit Exceeded

Solution code:
from collections import Counter

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

c = Counter(S)

l = list(filter(lambda v: v[1] == c.most_common()[0][1], c.most_common()))
l.sort()

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

Submission status: Time Limit Exceeded

Solution code:
N=int(input())
S = [input() for i in range(N)]
P={}
A=[]
for i in range(len(S)):
    P[S[i]] = 0
    for j in range(len(S)):
        if S[i]==S[j]:
            P[S[i]] += 1

m=P[S[0]]
for k in range(len(S)):
    if m<P[S[k]]:
        m=P[S[k]]

for k in range(len(S)):
    if P[S[k]]==m:
        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 = []
max = 0

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

s.sort()

for i in range(n):
    if max < s.count(str(s[i])):
        max = s.count(str(s[i]))

for i in range(n):
    if i == 0 and max == s.count(str(s[i])):
        print(s[i])
    elif max == s.count(str(s[i])) and s[i] != s[i-1]:
        print(s[i])

Submission status: Time Limit Exceeded

Solution code:
if __name__=="__main__":
    n = int(input())
    s=[]
    for i in range(n):
        s.append(input())
        
    unique_s = []
    cnt_s = []
    for i in range(n):
        if s[i] not in unique_s:
            unique_s.append(s[i])
            cnt_s.append(1)
        else:
            for j in range(len(unique_s)):
                if s[i] == unique_s[j]:
                    cnt_s[j] += 1
                    break

    max_cnt_s = max(cnt_s)
    top_list = []
    for i in range(len(cnt_s)):
        if cnt_s[i] == max_cnt_s:
            top_list.append(unique_s[i])

    top_list.sort()

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

Submission status: Time Limit Exceeded

Solution code:

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

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

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

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


if __name__ == "__main__":
    resolve()

Submission status: Time Limit Exceeded

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

o=[i[0] for i in s.items() if i[1]==max(s.values())]

o.sort()

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

Submission status: Time Limit Exceeded

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

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