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

def index_Multi(List,liter):
    #Listはリスト本体・literは検索したい文字
    index_L = []
    for i in range(len(List)):
        if liter == List[i]:
            index_L.append(i)
    return index_L

s = []
cnt = [0] * n

for i in range(n):
  tmp = input()
  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


inds = index_Multi(cnt,_max)
results = []
for ind in inds:
  results.append(s[ind])

results.sort()

for result in results:
  print(result)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

S = {}

for i in range(N):
  word = input()
  if word in S:
  	S[word] += 1
  else:
    S[word] = 1
    
max_S = [kv[0] for kv in S.items() if kv[1] == max(S.values())]

max_S.sort()
for out in max_S:
  print(out)

Submission status: Time Limit Exceeded

Solution code:
n =  int(input())
d = {}
for i in range(n):
    s = input()
    if s not in d:
        d[s] = 0
    d[s] += 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:
from collections import Counter
n = int(input())
s = []
for i in range(n):
    s.append(input())
counter = Counter(s)
ansarr = [k for k, v in counter.items() if v == max(counter.values())]
ansarr.sort()
for ans in ansarr:
    print(ans)

Submission status: Time Limit Exceeded

Solution code:
from collections import Counter

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

S = Counter(S)

k_list = [ k for k, v in S.items() if v == max(S.values())]

for k in sorted(k_list):
    print(k)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
S = []
for _ in range(N):
    S.append(input())
S_list = sorted(S)
t=0
t_list=[]
s_list=[]
for i in range(N-1):
  if S_list[i]==S_list[i+1]:
    t+=1
  else:
    t_list.append(t)
    s_list.append(S_list[i])
    t=0
t_list.append(t)
s_list.append(S_list[N-1])
for i in range(len(t_list)):
  if t_list[i]==max(t_list):
    print(s_list[i])

Submission status: Time Limit Exceeded

Solution code:
#C
from collections import Counter
import itertools

N = int(input())
S = [None] * N
for i in range(N):
    Si = input()
    S[i] = Si

counter = Counter(S)
ret = [letter for letter,count in counter.most_common() if count == counter.most_common()[0][1]]

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

Submission status: Time Limit Exceeded

Solution code:
# coding:utf-8

import sys
import math
import time
import numpy as np
import collections
from collections import deque
import queue
import copy

# 最大公約数
def gcd(m,n):
  x = max(m,n)
  y = min(m,n)
  if x%y == 0:
    return y
  else:
    while x%y != 0:
      z = x%y
      x = y
      y = z
    else:
      return z

# 幅優先探索(BFS)でスタート座標(x, y)からの最大距離返す
def bfs(SS, x, y, H, W):#入力(座標系(迷路), x, y, xの端, yの端)
  x_next = [0, 0, -1, 1]
  y_next = [1, -1, 0, 0]
  tempx = x
  tempy = y
  mlength = 0
  q = deque()
  xytuple = (x, y, 0)
  q.append(xytuple)


  while q:
    xytuple = q.popleft()
    SS[xytuple[0]][xytuple[1]] = "x" #探索した場所は探索できないようにする
    for i in range(4): #このforで上下左右を調べてる
      tempx = xytuple[0] + x_next[i]
      tempy = xytuple[1] + y_next[i]
      #print(tempx, tempy, xytuple[2])
      #print(S)
      if(0 <= tempx and tempx < H and 0 <= tempy and tempy < W and SS[tempx][tempy] == "."):
        temptuple = (tempx, tempy, xytuple[2]+1)
        SS[temptuple[0]][temptuple[1]] = "x" #探索した場所は探索できないようにする
        mlength = max(mlength, xytuple[2] +1)
        q.append(temptuple)
      #print(q)
  return mlength

def brick(a,n,m,N):#ABC 148
  #n番目以降にmがあるか調べる
  if not m in a[n:]:
    print(N-(m-1))
  else:
    #b = copy.deepcopy(a)
    brick(a,a[n:].index(m),m+1,N)

#X = str(input()).split()
#a = [int(x) for x in input().split()]

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

c = collections.Counter(S)

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


for i in range(len(c.most_common())-1):
    if(c.most_common()[i][1]==c.most_common()[i+1][1]):
        B.append(c.most_common()[i+1][0])
    else:
        break
B.sort()

for i in range(len(B)):
    print(B[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.rstrip('\n'))

Submission status: Time Limit Exceeded

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

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

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

s2.sort()

for i in range(len(s2)):
    if i == 0:
        print(s2[i])
    elif s2[i] != s2[i-1]:
        print(s2[i])

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
lst=[]
while n>0:
    lst.append(input())
    n-=1

s=set(lst)
a={ele:lst.count(ele)for ele in s}

maximum = max(lst.count(ele)for ele in s)

re=[]
for k,v in a.items():
    if v==maximum:
        re.append(k)

for ele in sorted(re):
    print(ele)

Submission status: Time Limit Exceeded

Solution code:
import collections
import sys
input = sys.stdin.readline
n = int(input())
s = []
for i in range(n):
  s.append(input())
#print(s)
c = collections.Counter(s)
#print(c.most_common())
m = c.most_common()[0][1]
l = len(c.most_common())
ans = []
for i in range(l):
  if c.most_common()[i][1] == m:
    ans.append(c.most_common()[i][0])
  else:
    break
ans0 = sorted(ans)
for i in range(len(ans0)):
  print(ans0[i],end="")

Submission status: Time Limit Exceeded

Solution code:
from collections import defaultdict
N=int(input())
ss = []
for i in range(N):
  ss.append(input())
d = defaultdict(lambda: 0)

for i in range(N):
  s = ss[i]
  d[s] += 1

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

Submission status: Time Limit Exceeded

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

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

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()
    [print(i) for i in max_kv_list]
    

if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
dictionary = {}
for i in range(n) :
    new_word = input()
    if new_word in dictionary.keys() :
        dictionary[new_word] += 1
    else :
        dictionary[new_word] = 1

max_word_list = [k for k, v in dictionary.items() if v == max(dictionary.values())]

max_word_list.sort()

for word in max_word_list :
    print(word)

Submission status: Time Limit Exceeded

Solution code:
from collections import Counter

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

c = Counter(s)
ans_number = c.most_common()[0][1]
    
s_max = []
for i in range(n):
  if s.count(s[i]) == ans_number:
    s_max.append(s[i])
    
s_max = list(set(s_max))
s_max.sort()
for i in range(len(s_max)):
  print(s_max[i])

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

top_words = []
max_val = 0
for k, v in cnt.items():
  if v > max_val:
    max_val = v
    top_words = [k]
  elif v == max_val:
    top_words.append(k)

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

Submission status: Time Limit Exceeded

Solution code:
N, strings, answers = int(input()), [], []
for x in range(N):
    string = input()
    strings.append(string)
max_char = strings.count(max(strings, key=strings.count))
for x in strings:
    if strings.count(x) == max_char:
        answers.append(x)
for x in sorted(set(answers), key=str.lower):
    print(x)

Submission status: Time Limit Exceeded

Solution code:
import collections
N = int(input())
S = [input() for i in range(N)]
c = collections.Counter(S)
max_k_list = [kv[0] for kv in c.items() if kv[1] == max(c.values())]
max_k_list.sort()
for max_k in max_k_list:
    print(max_k)

Submission status: Time Limit Exceeded

Solution code:
from collections import Counter
n=int(input())
s = [0]*n
for i in range(n):
    s[i]=input()
d = Counter(s)
max_k_list = [kv[0] for kv in d.items() if kv[1] == max(d.values())]
max_k_list.sort()
for i in max_k_list:
    print(i)

Submission status: Time Limit Exceeded

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

maxi = 0
s = set(arr)
res = list()
while True:
    flag = True
    x = ""
    if s:
        for i in s:
            if arr.count(i) >= maxi:
                x = i
                maxi = arr.count(i)
                flag = False
        if flag:
            break
        res.append(x)
        while x in arr:
            arr.remove(x)
    else:
        break
for i in sorted(res):
    print(i)

Submission status: Time Limit Exceeded

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

loop_s = set(s)

res_list = []
max_str = 0  

for st in loop_s:
  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:
N = int(input())

S = []

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

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

length = len(cnt_ar)

ar = [0 for i in range(length)]

for i in range(length):
  ar[i] = S.count(cnt_ar[i])

max_num = max(ar)

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

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
s = [0 for i in range(n)]
dics = {}
for i in range(n):
    try:
        s = input()
        a = dics[s]
        dics[s] += 1
    except KeyError:
        dics[s] = 1
max_v = max(dics.values())
max_k_list = [kv[0] for kv in dics.items() if kv[1] == max(dics.values())]
max_k_list.sort()
for i in max_k_list:
    print(i)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
s = [input() for _ in range(n)]
t = list(set(s))
p = []
m = 0
for i in t:
    if m <= s.count(i):
        if m < s.count(i):
            p = []
        m = s.count(i)
        p.append(i)

for u in sorted(p):
    print(u)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
str_dic = {}
for _ in range(n):
    inp = input()
    if inp in str_dic:
        str_dic[inp] += 1
    else:
        str_dic[inp] = 1

max_str = [s[0] for s in str_dic.items() if s[1] == max(str_dic.values())]

sorted_max_str = sorted(max_str)

for s in sorted_max_str:
    print(s)

Submission status: Time Limit Exceeded

Solution code:
import math

N = int(input())
S = [0]*N
kaisuu = [0]*N
solution = []
index = 0

for i in range(N):
  tmp = input()
  
  if (tmp in S) == False:
    S[index] = tmp
    kaisuu[index] = 1
    index += 1
  
  if (tmp in S) == True:
    index_tmp = S.index(tmp)
    kaisuu[index_tmp] += 1
  
max_ = max(kaisuu)

for i in range(N):
  if kaisuu[i] == max_:
    solution.append(S[i])

solution.sort()

for i in solution:
  print(i)

Submission status: Time Limit Exceeded

Solution code:
def main():
    N = int(input())
    S = [input() for i in range(N)]
    set_S = set(S)
    cnt = 0
    ll = []
    for s in set_S:
        s_num = S.count(s)
        if cnt < s_num:
            cnt = s_num
            ll = [s]
        elif cnt == s_num:
            ll.append(s)
        elif cnt > s_num:
            pass

    lll = sorted(ll)
    for l in lll:
        print(l)


if __name__ == "__main__":
    main()

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)):
        if c.most_common()[i][1] == count:
            ans.append(c.most_common()[i][0])
        else:
            break   
    ans.sort()
    for i in ans:
      print(i)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
lst = []
dic = {}
for i in range(0,N):
  lst.append(input())

for i in list(set(lst)):
  dic[i] = lst.count(i)

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:
from collections import defaultdict
d = defaultdict(int)

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

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

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
s = [input() for i in range(n)]
st = list(set(s))
st.sort()

c_l = []

for i in st:
    c_l.append(s.count(i))

c_m = max(c_l)

i_l = [i for i, _x in enumerate(c_l) if _x == c_m]

for i in i_l:
    print(st[i])

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
S = []
SS = []
for i in range(N):
    tmp = input()
    S.append(tmp)
    if tmp not in SS:
        SS.append(tmp)
S.sort()
SS.sort()
T = {}
for i in range(N):
    if S[i] in T:
        T[S[i]] += 1
    else:
        T[S[i]] = 1
m = 0
for i in SS:
    m = max(T[i],m)
##print("--------")
for i in SS:
    if T[i] == m:
        print(i)

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)

[print(i) for i in newdata]

Submission status: Time Limit Exceeded

Solution code:
import collections

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

c=collections.Counter(l)

ret = [letter for letter,count in c.most_common() if count == c.most_common()[0][1]]
ret.sort()

s_n = '\n'.join(ret)
print(s_n)

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 = []

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

S_KEYS = set(S)

ANS = []

for key in S_KEYS:
    ANS +=[S.count(key)]

n= (max(ANS))

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

a=sorted(a.items(),key=lambda x:x[1],reverse=True)
num=list(a[0])[1]
i=0
l=[]
while i+1<=len(a) and list(a[i])[1]==num:
  l.append(list(a[i])[0])
  i+=1
l=sorted(l)
for i in range(len(l)):
  print(l[i])

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
s = [input() for i in range(n)]
dist = set(s)
dic = {}
ans = []

for i in dist:
    dic.update({i: s.count(i)})

max_num = max(dic.values())

for i in dic:
    if dic[i] == max_num:
        ans.append(i)

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

Submission status: Time Limit Exceeded

Solution code:
from collections import Counter

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

c = Counter(s)
ans_number = c.most_common()[0][1]
    
s_max = []
for i in range(n):
  if s.count(s[i]) == ans_number:
    s_max.append(s[i])
    
s_max = list(set(s_max))
s_max.sort()
for i in range(len(s_max)):
  print(s_max[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:
        num[name.index(temp)] += 1
        if num[name.index(temp)] > max_temp:
            max_temp = num[name.index(temp)]
            
        
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 math

N = int(input())
S = [0]*N
kaisuu = [0]*N
solution = []
index = 0

for i in range(N):
  tmp = input()
  
  if (tmp in S) == False:
    S[index] = tmp
    kaisuu[index] = 1
    index += 1
  
  if (tmp in S) == True:
    index_tmp = S.index(tmp)
    kaisuu[index_tmp] += 1
  
max_ = max(kaisuu)

for i in range(N):
  if kaisuu[i] == max_:
    solution.append(S[i])

solution.sort()

for i in solution:
  print(i)

Submission status: Time Limit Exceeded

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

l = list(set(s))

count = []
for i in l:
    count.append(s.count(i))


indexes = [i for i, x in enumerate(count) if x == max(count)]

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

ans.sort()

for i in ans:
    print(i)

Submission status: Time Limit Exceeded

Solution code:
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)
anss=[]
for i in range(0,len(c)):
  if c[i]==cmax:
    anss.append(s[i])

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

Submission status: Time Limit Exceeded

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

a = sorted(list(set(S)))
b = [0] * len(a)
for i in range(N):
  b[a.index(S[i])] += 1
  
for j in range(len(a)):
  if b[j] == max(b):
    print(a[j])

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)
    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())
S = []
for i in range(N):
    S.append(input())
S.sort()
B = [S[0]]
C = [1]
for i in range(N-1):
    if S[i] == S[i+1]:
        C[B.index(S[i+1])] += 1
    else:
        B.append(S[i+1])
        C.append(1)

for i in range(len(C)):
    if C[i] == max(C):
        print(B[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]))
                i= INF
                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())

ans = []

for _ in range(N):
    tmp = input()

    # if len(ans) == 0:
    #     ans.append([tmp, 1])
    #     continue

    for a in ans:
        if a[0] == tmp:
            a[1] = a[1] + 1
            continue
    
    ans.append([tmp, 1])

n = 0
for a in ans:
    if a[1] > n:
        n = a[1]

last = []
for a in ans:
    if a[1] == n:
        last.append(a[0])
last.sort()
for l in last:
    print(l)

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)
    s.remove(i)
      

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

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 np.unique(np.array(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())
Dic = {}
for n in range(N):
    S = input()
    if S in Dic.keys():
        Dic[S] = Dic[S] + 1
    else:
        Dic[S] = 1
        
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())
s = []

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

buf = []
cnt = [0]*n
for i in s:
    if i not in buf:
        buf.append(i)
    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:
#!/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:
        r.append(a)
        r.sort()

for i in r:
    print(i)

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:
n=int(input())
s={}
ans=[]
max=0
for i in range(n):
    st=input()
    if st in s:
        s[st]+=1
    else:
        s[st]=1
    if max<s[st]:
        max=s[st]
        ans=[st]
    elif max==s[st]:
        if not st in ans:
            ans.append(st)
ans.sort()
for i in ans:
    print(i)

Submission status: Time Limit Exceeded

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

mmax = -1
word_buf = []
cnt = 0

for i in range(len(S_set)) :
    cnt = S.count(S_set[i])
    mmax = max(mmax,cnt)

for i in range(len(S_set)) :
    if S.count(S_set[i]) == mmax :
        word_buf.append(S_set[i])

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

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
S = [input() for i in range(n)]
ss = sorted(list(set(S)))
L = {}
for i in ss:
    L[i] = S.count(i)

K = sorted([kv[0] for kv in L.items() if kv[1] == max(L.values())])
for i in range(len(K)):
    print(K[i])

Submission status: Time Limit Exceeded

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

counter = collections.Counter([input() for _ in range(N)])

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

N = int(input())
s = [input() for i in range(N)] 
c = collections.Counter(s)

output = [kv[0] for kv in c.items() if kv[1] == max(c.values())]
output.sort()
[print(output[i]) for i in range(len(output))]

Submission status: Time Limit Exceeded

Solution code:
import collections

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

count = collections.Counter(S)

# print(count)

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

max_k_list.sort()

for i in max_k_list:
    print(i)

Submission status: Time Limit Exceeded

Solution code:
import collections

N = int(input())

S_list = []

for i in range(N):
    tmp = str(input())
    S_list.append(tmp)

c = collections.Counter(S_list)

appear = max(list(c.values()))

keys = [k for k, v in c.items() if v == appear]

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

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
s = [input() for i in range(N)]
dict = []
cnt = []
ans = []
max = 0

for i in range(N):
  if(dict.count(s[i]) == 0):
    dict.append(s[i])
    cnt.append(1)
  else:
    for j in range(len(dict)):
      if(dict[j] == s[i]):
        cnt[j] += 1
        
for i in range(len(cnt)):
  if(cnt[i] > max):
    max = cnt[i]


for i in range(len(cnt)):
  if(cnt[i] == max):
    ans.append(dict[i])
ans = sorted(ans)
for i in range(len(ans)):
  print(ans[i])

Submission status: Time Limit Exceeded

Solution code:
def main():
    N = int(input())
    S = ["a"]*N
    for i in range(N) : S[i]=input()
    S.sort()

    wds = [S[0]]
    cnt = [1]
    for wd in S[1:]:
        if wd == wds[-1]:
            cnt[-1] +=1
        else:
            wds.append(wd)
            cnt.append(1)

    maxcnt = max(cnt)
    maxidx = cnt.index(maxcnt)
    ans = [wds[maxidx]]
    cnt[maxidx] = 0

    while max(cnt) == maxcnt:
        maxidx = cnt.index(maxcnt)
        ans.append(wds[maxidx])
        cnt[maxidx] = 0

    for s in ans: print(s)


    return

if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

Solution code:
from collections import Counter

num = int(input())

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

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:
N = int(input())
S = []
words ={}
for _ in range(N):
    si = input()
    if si not in words.keys():
        words[si] = 1
    else:
        words[si] += 1

words_sorted = sorted(words.items(), key=lambda x: x[0])
words_sorted = sorted(words_sorted, key=lambda x: x[1], reverse=True)

max_n = words_sorted[0][1]

for w in words_sorted:
    if w[1] == max_n:
        print(w[0])
    else:
        break

Submission status: Time Limit Exceeded

Solution code:
import sys
import collections
n = int(input())
s = [input() for i in range(n)]
s = sorted(s)
c = set(s)
c = list(c)
li = []
for i in range(len(c)):
    li.append(c[i])
li2 = [0 for i in range(len(li))]
for i in range(n):
    for j in range(len(li)):
        if s[i] == li[j]:
            li2[j]+=1
max_v = max(li2)
li3 = []
for i in range(len(li2)):
    if li2[i] == max_v:
        li3.append(li[i])
li3 = sorted(li3)
for i in range(len(li3)):
    print(li3[i])

Submission status: Time Limit Exceeded

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

for _ in range(N):
    S.append(input())
s=sorted(S)
T=set(s)
t=sorted(list(T))

for i in range(len(T)):
    counts.append(s.count(t[i]))

for j in range(len(t)):
    if counts[j]==max(counts):
        A.append(j)
for k in A:
    print(t[k])

Submission status: Time Limit Exceeded

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

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)
else:
    for i in range(len(c)):
        if c.most_common()[i][1] == count:
            ans.append(c.most_common()[i][0])
        else:
            break   
    ans.sort()
    for i in ans:
      print(i)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
a = list(input() for i in range(N))
ls = []
ls3 = []
for i in range(N):
  if a[i] not in ls:
    ls.append(a[i])
ls2 = [0 for i in range(len(ls))]
for i in range(len(ls)):
  for j in range(len(a)):
    if ls[i] == a[j]:
      ls2[i] += 1
for i in range(len(ls)):
  if ls2[i] == max(ls2):
    ls3.append(ls[i])
ls3.sort()
for i in range(len(ls3)):
  print(ls3[i])