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:
import collections
N = int(input())
S = sorted([input() for i in range(N)])
list1 = []
count = 1

for s in S:
  
  c = S.count(s)
  if c == count:
    list1.append(s)
  elif c > count:
    list1 = [s]
    count = c
  #while s in S:
   #   S.remove(s)
  
cc = collections.Counter(list1)
for i in cc:  
  print(i)

Submission status: Time Limit Exceeded

Solution code:
import collections

n = int(input())  # nは入力回数
string_list = [input() for _ in range(n)]
c = collections.Counter(string_list)
set_list = sorted(set(string_list))
num_list = []

for i in range(len(set_list)):
    num_list.append(c[set_list[i]])

for i in range(len(set_list)):
    if num_list[i] == max(num_list):
        print(set_list[i])

Submission status: Time Limit Exceeded

Solution code:
import collections

n = int(input())  # nは入力回数
string_list = [input() for _ in range(n)]
c = collections.Counter(string_list)
ans_list = []

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

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

Submission status: Time Limit Exceeded

Solution code:
import collections

n = int(input())  # nは入力回数
string_list = [input() for _ in range(n)]
a = sorted(string_list)
c = collections.Counter(a)
ans_list = []

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

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
ls = []
cnt = []

for _ in range(N):
  S = input()
  if S in ls:
    cnt[ls.index(S)] += 1
    continue
  
  ls.append(S)
  cnt.append(1)
  
max_cnt = max(cnt)

res = []
for i,j in zip(ls,cnt):
  if j == max_cnt:
    res.append(i)
    
res.sort()
for ans in res:
  print(ans)

Submission status: Time Limit Exceeded

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

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

for j in range(len(cnt)):
    if max(cnt) == cnt[j]:
        ans.append(S[j])

ans.sort()
for x in range(len(ans)):
    print(ans[x])

Submission status: Time Limit Exceeded

Solution code:
N=int(input())
S=[input() for _ in range(N)]
s=sorted(list(set(S)))
l=len(s)
x=[0]*l
for i in range(l):
    x[i]+=S.count(s[i])
m=max(x)
for i in range(l):
    if m==x[i]:
        print(s[i])

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
s=[input() for i in range(n)]
data=0
for i in s:
  data=max(s.count(i),data)
  
d=[]
for i in range(n):
  if s.count(s[i])==data and s[i] not in d:
    d.append(s[i])
d.sort()
for i in d:
  print(i)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
S = list(input() for _ in range(N))
D = list(set(S))
D.sort()
n = 0
for d in D:
  if n < S.count(d):
    n = S.count(d)
    li = []
    li.append(d)
  elif n == S.count(d):
    li.append(d)
for l in li:
  print(l)

Submission status: Time Limit Exceeded

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

n, c, l = 0, [], []

for s in S:
  if not s in c:
    c.append(s)
    l.append(1)
  else: l[-1] += 1
  n = max(n, l[-1])

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

for i in range(len(l)):
  if l[i] == n: print(S[i])

Submission status: Time Limit Exceeded

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

N = int(input())
S = [input() for _ in range(N)]
 
T = sorted(set(S))
t = len(T)
l = [S.count(T[i]) for i in range(t)]
  
for i in range(t):
  if l[i] == max(l):
    print(T[i])

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
S = [input() for _ in range(N)]
 
T = sorted(set(S))
t = len(T)
l = [S.count(T[i]) for i in range(t)]
  
for i in range(t):
  if l[i] == max(l):
    print(T[i])

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
S = [input() for _ in range(N)]
 
T = sorted(set(S))
t = len(T)
l = [0] * t
 
for i in range(t):
  l[i] = S.count(T[i])
  
for i in range(t):
  if l[i] == max(l):
    print(T[i])

Submission status: Time Limit Exceeded

Solution code:
#!/usr/bin/env python3
import sys
def input():
    return sys.stdin.readline()[:-1]

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

    T = sorted(list(set(S)))
    C = []
    for i in T:
        C.append(S.count(i))

    for i in range(len(C)):
        if C[i] == max(C):
            print(T[i])

if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
#!/usr/bin/env python3
import sys
def input():
    return sys.stdin.readline()[:-1]

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

    T = list(set(sorted(S)))
    C = []
    for i in T:
        C.append(S.count(i) * -1)

    Z = zip(C, T)
    Z = sorted(Z)
    C, T = zip(*Z)

    for i in range(len(C)):
        if C[i] == min(C):
            print(T[i])

if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
import collections

N = int(input())

S_list = []

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

c = collections.Counter(S_list)
c_max = c.most_common()
max_num = c.most_common()[0][1]
ans_list = []
ans_list.append(c.most_common()[0][0])

for i in range(1, len(c_max)):
    if c.most_common()[i][1] != max_num:
        break
    else:
        ans_list.append(c.most_common()[i][0])

print(*sorted(ans_list), sep='\n')

Submission status: Time Limit Exceeded

Solution code:
import collections

N = int(input())

S_list = []

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

c = collections.Counter(S_list)
c_max = c.most_common()
max_num = c.most_common()[0][1]
ans_list = []
ans_list.append(c.most_common()[0][0])

for i in range(1, len(c_max)):
    if c.most_common()[i][1] != max_num:
        break
    else:
        ans_list.append(c.most_common()[i][0])

print(*sorted(ans_list), sep='\n')

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
a = [input() for _ in range(n)]
b = []
for i in range(n):
    if a[i] not in b:
        b.append(a[i])
b.sort()
c = [0]*len(b)
for i in range(len(b)):
    c[i] += a.count(b[i])
for i in range(len(b)):
    if c[i] == max(c):
        print(b[i])

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
a = [input() for _ in range(n)]
b = []
a.sort()
for i in range(n):
    if a[i] not in b:
        b.append(a[i])
b.sort()
c = [0]*len(b)
for i in range(len(b)):
    c[i] += a.count(b[i])
for i in range(len(b)):
    if c[i] == max(c):
        print(b[i])

Submission status: Time Limit Exceeded

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

for i in range(N):
  key = input()
  if key in dic:
    dic[key] += 1
  else:
    dic[key] = 1
ans = sorted([kv[0] for kv in dic.items() if kv[1] == max(dic.values())])

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

Submission status: Time Limit Exceeded

Solution code:
import collections

N = int(input())
S = [input() for i in range(N)]
c = collections.Counter(S)
a = [kv for kv in c.items() if kv[1] == max(c.values())]
ans = sorted(a, key= lambda x:x[0])
for i in range(len(ans)):
  print(ans[i][0])

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-
N = int(input())

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

unique_str = (list(set(all_str)))
unique_str.sort()
max_cnt = 0
str_num = dict()
for i in unique_str:
    cnt = all_str.count(i)
    str_num[i] = cnt
    if max_cnt < cnt:
        max_cnt = cnt

disp_list = []
for i in str_num:
    current_cnt = str_num[i]
    if current_cnt == max_cnt:    
        disp_list.append(i)
    

for i in disp_list:
    print(i)

Submission status: Time Limit Exceeded

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

c=collections.Counter(s)

m=[]

for v in c.values():
    m.append(v)

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

keys.sort()

print('\n'.join(keys))

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
s=[input() for i in range(n)]
t=sorted(list(set(s)))
a=0
for i in t:
  if s.count(i)>a:
    a=s.count(i)
for j in t:
  if s.count(j)==a:
    print(j)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
s = [input() for _ in range(n)]
dic1 = {}
for i in s:
    if i not in dic1.keys():
        dic1[i] = s.count(i)
dic2 = sorted(dic1.items())

for k in range(len(dic2)):
    if dic2[k][1] == max(dic1.values()):
        print(dic2[k][0])

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

log = []
s = []
for _ in range(n):
  line = input()
  if line in log:
    i = log.index(line)
    s[i] += 1
  else:
    log.append(line)
    s.append(1)

t = len(s)
ans = []
M = max(s)
for i in range(t):
  if s[i] == M:
    ans.append(log[i])
for l in sorted(ans):
  print(l)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

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

c = [A[0]]
d =[1] + [0]*(N-1)

for j in range(1,N):
  if A[j] in c:
    e = c.index(A[j])
    d[e] += 1
  else:
    c.append(A[j])
    e = c.index(A[j])
    d[e] += 1
    
f = max(d)
g = []

for k in range(N):
  if d[k] == f:
    g.append(c[k])
    
g.sort()

for n in range(len(g)):
  print(g[n])

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
S = [input() for _ in range(N)]
SS = sorted(list(set(S)))
count = [0]*len(SS)
for i in S:
    count[SS.index(i)] += 1
ans = max(count)
for j in range(len(SS)):
    if count[j] == ans:
        print(SS[j])

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
S = [input() for _ in range(N)]
SS = sorted(list(set(S)))
count = []
for i in SS:
    count.append(S.count(i))
ans = max(count)
for j in range(len(SS)):
    if count[j] == ans:
        print(SS[j])

Submission status: Time Limit Exceeded

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

N = int(input())

for i in range(N):
    Poll_Dict[str(input())] += 1
Max_List = sorted([k[0] for k in Poll_Dict.items() if k[1] == max(Poll_Dict.values())])

for i in Max_List:
    print(i)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
aux = 0
palavras = list()
resultado = list()

while aux < n:
  palavra = input()

  if palavras != []:
    length = len(palavras)
    flag = True

    for i in range(length):
      if palavras[i][0] == palavra:
        palavras[i][1] = palavras[i][1] + 1
        flag = False
        continue

    if flag:
      palavras.append([palavra, 1])
  
  else:
    palavras.append([palavra, 1])

  aux += 1

maior = 1
for j in palavras:
  if j[1] > maior:
    maior = j[1]
for k in palavras:
  if k[1] == maior:
    resultado.append(k[0])
resultado.sort()
for l in resultado:
  print(l)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
s = [input() for _ in range(n)]
lists = sorted(list(set(s)))
num = list()
for i in lists:
    cnt = 0
    for j in s:
        if i == j:
            cnt += 1
    num.append(cnt)
maxnum = max(num)
for j in range(len(lists)):
    if num[j] == maxnum:
        print(lists[j])

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
s = [input() for _ in range(n)]
lists = sorted(list(set(s)))
num = list()
for i in lists:
    num.append(s.count(i))
maxnum = max(num)
for j in range(len(lists)):
    if num[j] == maxnum:
        print(lists[j])

Submission status: Time Limit Exceeded

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

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

ans = [["" for i in range(2)] for i in range(len(S_set))]
n = 0
for i in range(len(S_set)):
  count = S.count(S_set[i])
  ans[i][0] = S_set[i]
  ans[i][1] = count
  if n < count:
    n = count
    
for i in range(len(S_set)):
  if ans[i][1] == n:
    print(ans[i][0])

Submission status: Time Limit Exceeded

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

d = {}
for i in s:
    if i not in d:
        d[i] = 1
    else:
        d[i] += 1

l = []
for k in d.keys():
    if d[k] == max(d.values()):
        l.append(k)

l_s = sorted(l)
                
for ans in l_s:
    print(ans)

Submission status: Time Limit Exceeded

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

d = {}
for i in s:
    if i not in d:
        d[i] = 1
    else:
        d[i] += 1

l = []
for k in d.keys():
    if d[k] == max(d.values()):
        l.append(k)
        
for ans in sorted(l):
    print(ans)

Submission status: Time Limit Exceeded

Solution code:
n=(int)(input())
a = list(input() for i in range(n))
lis = sorted(list(set(a)))
big = [0 for i in range(len(lis))]
maxi = 0
for i in range(len(lis)):
  big[i] = a.count(lis[i])
maxi = max(big)
for i in range(len(lis)):
  if big[i] == maxi:
    print(lis[i])

Submission status: Time Limit Exceeded

Solution code:
n=(int)(input())
a = list(input() for i in range(n))
lis = sorted(list(set(a)))
big = []
maxi = 0
for i in lis:
  temp = a.count(i)
  if temp > maxi:
    big = [i]
    maxi = temp
  elif temp == maxi:
    big.append(i)
for i in range(len(big)):
  print(big[i])

Submission status: Time Limit Exceeded

Solution code:
n=(int)(input())
a = list(input() for i in range(n))
maxi = 0
big = []
#print(a)
for i in range(n):
  temp = a.count(a[i])
  if temp > maxi:
    big = [a[i]]
    maxi = temp
  elif temp == maxi:
    big.append(a[i])
ans = sorted(list(set(big)))
for i in range(len(ans)):
  print(ans[i])

Submission status: Time Limit Exceeded

Solution code:
#C - Poll
N = int(input())
S = [input() for _ in range(N)]
S_set = list(sorted(set(S)))

counter = [0]*(len(S_set))

for i in S:
    counter[S_set.index(i)] += 1

maxim = max(counter)
ans= [S_set[i] for i in range(len(S_set)) if counter[i] == maxim ]
for j in ans:
    print(j)

Submission status: Time Limit Exceeded

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

from collections import Counter
results = Counter(s)

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

Submission status: Time Limit Exceeded

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

from collections import Counter
results = Counter(s)

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

Submission status: Time Limit Exceeded

Solution code:
def resolve():
    N = int(input())
    S = []
    for _ in range(N):
        s = input()
        S.append(s)
    SS = sorted(list(set(S)))
    ans = []
    for i in SS:
        ans.append(S.count(i))
    ooki = max(ans)
    for j in range(len(SS)):
        if ans[j] == ooki:
            print(SS[j])
resolve()

Submission status: Time Limit Exceeded

Solution code:
def resolve():
    N = int(input())
    S = []
    for _ in range(N):
        s = input()
        S.append(s)
    SS = list(set(S))
    ans = []
    for i in SS:
        ans.append(S.count(i))
    ooki = max(ans)
    aans = []
    for j in range(len(SS)):
        if ans[j] == ooki:
            aans.append(SS[j])
    aaans = sorted(aans)
    for __ in aaans:
        print(__)
resolve()

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-
N = int(input())
S = list()
word = {}
for i in range(N):
  s = input()
  S.append(s)
  if s in word:
    word[s] += 1
  else:
    word[s] = 1

max_k_list = [kv[0] for kv in word.items() if kv[1] == max(word.values())]
ans_list = sorted(max_k_list)
for ans in ans_list:
  print(ans)

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
name=[]
num=[]
for i in range(n):
    s=input()
    if s in name:
        num[name.index(s)]+=1
    else:
        name.append(s)
        num.append(1)
x=max(num)
res=[]
for i in range(len(num)):
    if num[i]==x:
        res.append(name[i])
res.sort()
print(*res)

Submission status: Time Limit Exceeded

Solution code:
from collections import Counter
n = int(input())
d = list(input() for _ in range(n))
D = Counter(d)
m = D.most_common()[0][1]
for i in range(len(D)):
  k = D.most_common()[i][1]
  if m != k:
    break
  p = i
D = D.most_common()[:p+1]
D = sorted(D)
for i in D:
  print(i[0])

Submission status: Time Limit Exceeded

Solution code:
import collections

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

cnt = collections.Counter(S)

ans_list = []

for key, value in cnt.items():
    if value == max(cnt.values()):
        ans_list.append(key)

print(*sorted(ans_list), sep='\n')

Submission status: Time Limit Exceeded

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

l= sorted(l)
#print(l)

import collections
c = collections.Counter(l)
#print(c.most_common())

ans =[]

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

Submission status: Time Limit Exceeded

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

import collections
c = collections.Counter(l)

ans =[]

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

ans= sorted(ans)
for i in range(len(ans)):
    print(ans[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 = []
flag = 0

for n in range(len(C)):
    if int(C.most_common()[n][1]) < flag:
        break
    else:
        ans.append(C.most_common()[n][0])
        flag = int(C.most_common()[n][1])

ans.sort()

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

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
s=[input() for _ in range(n)]
a=set(s)
c=[]
d=0
for i in a:
    b=s.count(i)
    c.append([i,b])
    d=max(d,b)
e=[]
for i in range(len(c)):
    if c[i][1]==d:
        e.append(c[i][0])
e=sorted(e)
for i in range(len(e)):
    print(e[i])

Submission status: Time Limit Exceeded

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

newS = sorted(list(set(S)))
frq = [0] * len(newS)

for i in range(N):
    for j in range(len(newS)):
        if S[i] == newS[j]:
            frq[j] += 1
            break
ma = max(frq)
for i in range(len(newS)):
    if frq[i] == ma:
        print(newS[i])

Submission status: Time Limit Exceeded

Solution code:
N=int(input())
L=[]
for i in range(N):
  K=input()
  L.append(K)
H=list(set(L))
ans=[0]*len(H)
for k in range(len(H)):
  ans[k]=L.count(H[k])
G=max(ans)
rem=[]
for i in range(len(H)):
  if ans[i]==G:
    rem.append(H[i])
rem=list(sorted(rem))
for k in range(len(rem)):
  print(rem[k])

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import collections

N = int(input())
cnt_dic = collections.defaultdict(int)

for _ in range(N):
  s = input()
  cnt_dic[s] += 1

cnt_dic = {k: v for k, v in cnt_dic.items() if v == max(cnt_dic.values())}

for s in sorted(cnt_dic.keys()):
  print(s)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
A = [str(input()) for i in range(N)]
B = list(set(A))
B.sort()
Adict = {}
for i in range(len(B)):
  Adict[B[i]] = 0
for i in range(N):
  Adict[A[i]] += 1
ans = [x[0] for x in Adict.items() if x[1]==max(Adict.values())] 
for i in range(len(ans)):
  print(ans[i])

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
A = [str(input()) for i in range(N)]
A.sort()
B = list(set(A))
B.sort()
ans = [0 for _ in range(len(B))]
for i in range(len(B)):
  ans[i] = A.count(B[i])
i_max = [i for i, x in enumerate(ans) if(max(ans)==x)]
for i in range(len(i_max)):
  print(B[i_max[i]])

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
l,d =[], {}
for i in range(n):
    l.append(input())

for i in set(l):
    d.setdefault(i,0)

for k in d.keys():
    d[k] = l.count(k)

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

Submission status: Time Limit Exceeded

Solution code:
from collections import defaultdict

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

for s in sorted(filter(lambda x: S[x] == max(S.values()), S), key=lambda x: x):
    print(s)

Submission status: Time Limit Exceeded

Solution code:
from collections import Counter
n = int(input())
s = Counter([input() for i in range(n)])
print(*sorted([k for k, v in s.items() if v == max(s.values())]), sep='\n')

Submission status: Time Limit Exceeded

Solution code:
from collections import Counter
def main():
    n = int(input())
    s = [input() for _ in range(n)]
    s_c = Counter(s)
    # keys = [k for k, v in s_c.items() if v == max(s_c.values())]
    # keys_s = sorted(keys)
    keys =[k for k, v in s_c.items() if v == s_c.most_common()[0][1]]
    keys_s = sorted(keys)
    print(*keys_s, sep='\n')

if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
from collections import Counter
def main():
    n = int(input())
    s = [input() for _ in range(n)]
    s_c = Counter(s)
    keys = [k for k, v in s_c.items() if v == max(s_c.values())]
    keys_s = sorted(keys)
    print(*keys_s, sep='\n')

if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
import collections

Row = int(input())
List = []
for i in range (Row):
  List.append(input())
c = collections.Counter(List)
tryList = []
k=""
for i in range(len(c)):
  if c.most_common()[i][1] == c.most_common()[0][1]:
    tryList.append(c.most_common()[i][0])
  else:
    break
tryList.sort()
for element in tryList:
  print(element)

Submission status: Time Limit Exceeded

Solution code:
import collections

Row = int(input())
List = []
for i in range (Row):
  List.append(input())
c = collections.Counter(List)
tryList = []
k=""
s_l = set(List)
n= len(s_l)
for i in range(n):
  k=s_l.pop()
  if List.count(k) == c.most_common()[0][1]:
    tryList.append(k)
tryList.sort()
for element in tryList:
  print(element)

Submission status: Time Limit Exceeded

Solution code:
Row = int(input())
List = []
for i in range (Row):
  List.append(input())
mid = 0
s_l = set(List)
n = len(s_l)
for i in range(n):
  mid = max(mid,List.count(s_l.pop()))
s_l = set(List)
k=""
tryList = []
for i in range(n):
  k=s_l.pop()
  if List.count(k) == mid:
    tryList.append(k)
tryList.sort()
for element in tryList:
  print(element)

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

# print(dic)
# dic2 = sorted(dic.items(), key=lambda x:x[1])
# print(max(dic.values()))
# print(max(dic, key=dic.get))
#
# print(dic.items())

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

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

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
s = list(input() for _ in range(n))
ss = sorted(list(set(s)))
dpl = []
for i in ss:
    dpl.append(s.count(i))
for j in range(len(dpl)):
    if dpl[j] == max(dpl):
        print(ss[j])

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
maxCount = 0
maxValue = []
countS = {}
values = []
for i in range(n):
  p = input()
  values.append(p)
  if p in countS.keys():
    countS[i] += 1
  else:
    countS[i] = 0
  if values.count(p) > maxCount:
    maxCount = values.count(p);
    maxValue = [p]
  elif values.count(p) == maxCount:
    maxValue.append(p)
maxValue.sort()
for i in maxValue:
  print(i)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

S = []

import collections

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

S = sorted(S)
cnt = collections.Counter()

for word in S:
	cnt[word] += 1
    
V = cnt.most_common(1)

D = V[0][1]

String = [V[0][0]]

for i in range (1, len(set(S))):
	if cnt.most_common()[i][1] == D:
		String.append(cnt.most_common()[i][0])

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

Submission status: Time Limit Exceeded

Solution code:
def resolve():
    N = int(input())
    S = []
    for _ in range(N):
        s = input()
        S.append(s)
    SS = list(sorted(set(S)))
    count = []
    for i in range(len(SS)):
        count.append(S.count(SS[i]))
    ooki = max(count)
    for j in range(len(SS)):
        if count[j] == ooki:
            print(SS[j])
resolve()

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

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

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

d3 = sorted(d2)

for s in d3:
  print(s)

Submission status: Time Limit Exceeded

Solution code:
import collections
n = int(input())
s = [input() for l in range(n)]
word = collections.Counter(s)
z = [kv for kv in word.items() if kv[1] == max(word.values())]
z = sorted(z)
for c in z:
  print(c[0])

Submission status: Time Limit Exceeded

Solution code:
from sys import stdin
import sys
import math
from functools import reduce
import itertools

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

c = []
a = []

for i in range(n):
    s = stdin.readline().rstrip()

    if s not in a:
        a.append(s)
        c.append(1)
    else:
        idx = a.index(s)
        c[idx] = c[idx] + 1

b = [i for i, v in enumerate(c) if v == max(c)]
d = [a[i] for i in b]
d.sort()

for dd in d:
    print(dd)

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
lst=[input() for i in range(n)]
xs=list(set(lst))
ans=[]
for i in xs:
  cnt=lst.count(i)
  ans.append([i,cnt])
ans.sort(key=lambda x:x[1])
pin=ans[-1][1]
ans2=[]
for i in ans:
  if i[1]==pin:
    ans2.append(i[0])
ans2.sort()
for i in ans2:
  print(i)

Submission status: Time Limit Exceeded

Solution code:
n,*s=map(str,open(0).read().split())
mydict={}
for i in set(s):
    mydict[i]=1
for i in range(int(n)):
    mydict[s[i]]+=1
    """
    if s[i] in mydict:
        mydict[s[i]]+=1
    else:
        mydict[s[i]]=1
    """
for i in sorted([kv[0] for kv in mydict.items() if kv[1]==max(mydict.values())]):
    print(i)

Submission status: Time Limit Exceeded

Solution code:
n,*s=map(str,open(0).read().split())
mydict={}
for i in range(int(n)):
    if s[i] in mydict:
        mydict[s[i]]+=1
    else:
        mydict[s[i]]=1
for j in sorted([kv[0] for kv in mydict.items() if kv[1]==max(mydict.values())]):
    print(j)

Submission status: Time Limit Exceeded

Solution code:
N=int(input())
L=list(input() for i in range(N))
M=sorted(set(L))
S=[]
for i in M:
  c=0
  for j in range(N):
    if L[j]==i:
      c+=1
  S.append(c)
maxs=0
for i in range(len(S)):
  if S[i]>maxs:
    maxl=[]
    maxl.append(i)
    maxs=S[i]
  elif S[i]==maxs:
    maxl.append(i)
for i in maxl:
  print(M[i])

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

S = []

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

set_S = list(set(S))
ans = []
max_cnt = 0
for i in range(len(set_S)):
  cnt = 0
  for j in range(N):
    if set_S[i] == S[j]:
      cnt += 1
  if max_cnt <= cnt:
    max_cnt = cnt
    temp = [set_S[i],cnt]
    ans.append(temp)

ans_f = []

for i in range(len(ans)):
  if ans[i][1] == max_cnt:
    ans_f.append(ans[i][0])

ans_f.sort()

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

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

S = []

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

set_S = list(set(S))
ans = []
for i in range(len(set_S)):
  cnt = 0
  for j in range(N):
    if set_S[i] == S[j]:
      cnt += 1
  temp = [set_S[i],cnt]
  ans.append(temp)

max_cnt = 0
for i in range(len(set_S)):
  if ans[i][1] > max_cnt:
    max_cnt = ans[i][1]

ans_f = []

for i in range(len(set_S)):
  if ans[i][1] == max_cnt:
    ans_f.append(ans[i][0])

ans_f.sort()

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

Submission status: Time Limit Exceeded

Solution code:
import sys

def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def main():
    n = I()
    S = [input() for _ in range(n)]
    word = sorted(list(set(S)))
    word_cnt = [0]*len(word)
    maxi = 0
    for i, w in enumerate(word):
        word_cnt[i] = S.count(w)
        maxi = max(maxi, word_cnt[i])
    for i, w in enumerate(word):
        if word_cnt[i] == maxi:
            print(w)


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))

def do():
    n=INT()
    dic=[]
    ct=[0]*n
    for i in range(n):
        s=STR()
        if s in dic:
            t=dic.index(s)
            ct[t]+=1
        else:
            dic.append(s)
            ct[len(dic)-1]+=1

    mct=max(ct)
    ans=[]
    for i in range(n):
        if ct[i]==mct:
            ans.append(dic[i])

    ans=sorted(ans)

    for i in ans:
        print(i)

if __name__=='__main__':
    do()

Submission status: Time Limit Exceeded

Solution code:
import collections

n = int(input())
s = list(input() for i in range(n))
c = collections.Counter(s)
p = max(c.values())
t = []

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

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

Submission status: Time Limit Exceeded

Solution code:
def main():   
    n = int(input())
    a = [input() for _ in range(n)]

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

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

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

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