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=[]
for i in range(n):
    s.append(input())

s=sorted(s)
t=0
c=1
ct=[]
for i in range(1,n):
    if i==n-1:
        if s[t]==s[i]:
            ct.append(c+1)
        else:
            ct.append(c)
            ct.append(1)
    else:
        if s[t]==s[i]:
            c+=1
        else:
            t=i
            ct.append(c)
            c=1
u=0
for i in ct:
    if i==max(ct):
        print(s[u])
    u+=i

Submission status: Time Limit Exceeded

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

S_set = set(S)
Cnt = []
max = 0
for i in S_set:
    Cnt.append([i, S.count(i)])
    if max < S.count(i):
        max = S.count(i)

Cnt_l = sorted(Cnt, reverse = False , key=lambda x: x[0])

x = [Cnt_l[i][0] for i in range(len(Cnt_l)) if Cnt_l[i][1] == max]
for i in x:
    print(i)

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
string_list=[input() for i in range(n)]
s=set(string_list)
t=list(s)
l=[0]*len(t)
a = len(t)
for i in range(n):
  for j in range(a):
    if t[j] == string_list[i]:
      l[j]+=1
u=[]
for k in range(len(t)):
  if l[k] == max(l):
    u.append(t[k])
u.sort()
for x in u:
	print(x)

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
s=[input() for _ in range(n)]
s.sort()
s.append("")
a=[]
count=[]
i=0
while i<n:
    a.append(s[i])
    s_count=s.count(s[i])
    count.append(s_count)
    i+=s_count
count_max=max(count)
for i in range(len(a)):
    if count[i]==count_max:
        print(a[i])

Submission status: Time Limit Exceeded

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

Dict = list(zip(Counted, num))
Dict_sorted = sorted(Dict,key=lambda x: x[1], reverse = True)
 
VVV = []
 
for i in range(len(Dict_sorted)):
  if Dict_sorted[i][1] == Dict_sorted[0][1]:
    VVV.append(Dict_sorted[i][0])
  else:
    break

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

Submission status: Time Limit Exceeded

Solution code:
import collections

N = int(input())

a = list()

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

c = collections.Counter(a)

#print(c.most_common()[0][1])

b =list()

if(N == len(c)):
    b = list(set(a))
    b.sort()
    for i in range(len(b)):
        print(b[i])
else:
    for i in range(len(c)):
        if (int(c.most_common()[0][1]) == int(c.most_common()[i][1])):
            b.append(c.most_common()[i][0])

    b.sort()

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

Submission status: Time Limit Exceeded

Solution code:
a = int(input())
b = []
for i in range(a):
    b.append(input())
c = list(set(b))
d = []
for i in c:
    d.append(b.count(i))
e = [i for i, x in enumerate(d) if x == max(d)]
f = []
for i in e:
    f.append(c[i])
f.sort()
for i in f:
    print(i)

Submission status: Time Limit Exceeded

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

d = Counter(s)

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

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
s = [input() for _ in range(n)]
s.sort()
p = [s[0]]
for i in range(1,len(s)):
    if s[i] != s[i-1]:
        p.append(s[i])
k = [] 
for i in p:
    k.append(s.count(i))
max_k = max(k)
for i in range(len(p)):
    if k[i] == max_k:
        print(p[i])

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
s = [0] * n
li = []
ans = []
for i in range(n):
    s[i] = input()
    if s[i] in ans:
        li[ans.index(s[i])][1] += 1
    else:
        li.append([s[i], 1])
        ans.append(s[i])
              
li.sort(key = lambda x: x[0])
li.sort(key = lambda x: x[1] , reverse = True)

a = li[0][1]
for j in range(len(li)):
    if a == li[j][1]:
        print(li[j][0])
    else:
        break

Submission status: Time Limit Exceeded

Solution code:
def main():

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

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

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

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

    for ans in max_k_list:
        print(ans)

if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
S = [0]*N
for i in range(N):
  S[i] = input()
B = sorted(list(set(S)))
n = 1
for j in range(len(B)):
  if S.count(B[j])> n:
    n = S.count(B[j])
  
for j in range(len(B)):
  if S.count(B[j])== n:
    print(B[j])

Submission status: Time Limit Exceeded

Solution code:
from collections import Counter
n = int(input())
ls = []
for _ in range(n):
    ls.append(input())
res = []
counter = Counter(ls).most_common(1)
for x in set(ls):
    if ls.count(x) == counter[0][1]:
        res.append(x)
r = sorted(res)
print("\n".join(r))

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
s = []
ans = []
nowcount = 0
bestcount = 0
for i in range(n):
    s.append(str(input()))
s.sort()#同じ文字列は固まる
ans.append(s[0])
for j in range(n-1):
    if s.count(s[j]) < s.count(s[j+1]):
        ans.append(s[j+1])
        ans.pop(0)
    elif s.count(s[j]) == s.count(s[j+1]) and s[j] != s[j+1]:
        ans.append(s[j+1])
for a in ans :
    print(a)

Submission status: Time Limit Exceeded

Solution code:
import collections
import sys
input = sys.stdin.readline
n=int(input())
string_list = [sys.stdin.readline().rstrip() for dummy in range(n)]
l = collections.Counter(string_list)
keys = [k for k, v in l.items() if v == max(l.values())]
keys.sort()
for x in range(len(keys)):
	print(keys[x])

Submission status: Time Limit Exceeded

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

count = max(collections.Counter(all_str).values())

max_all_str = []
for hikaku in sorted(set(all_str)):
  if all_str.count(hikaku) == count:
    print(hikaku)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
S = []
for i in range(N):
    S.append(str(input()))
dict_uni = {x:S.count(x) for x in set(S) if S.count(x)>=1}
dict_sorted = sorted(dict_uni.items(), key=lambda x:x[1], reverse=True)
MAX = dict_sorted[0][1]
ans = []
for i in dict_sorted:
    if i[1] == MAX:
        ans.append(i[0])
ans.sort()
for i in ans:
    print(i)

Submission status: Time Limit Exceeded

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

n=int(input())
for _ in range(n):
    s=str(input())
    d[s]+=1

d=dict(d)
l=d.items()
m= [kv[0] for kv in l if kv[1] == max(d.values())]
m.sort()
for i in range(len(m)):
    print(m[i])

Submission status: Time Limit Exceeded

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

S.sort()

while S != []:
  count = S.count(S[0])
  
  if count > i:
    A = [S[0]]
    i = count
  elif count == i:
    A = A + [S[0]]
    
  S[0:count] = []

for val in A:
	print(val)

Submission status: Time Limit Exceeded

Solution code:
import collections

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

c = collections.Counter(List)

res = [kv[0] for kv in c.items() if kv[1] == max(c.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())

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

cnt_dict = {_ : str_list.count(_) for _ in set(str_list)}


for ans in sorted([l[0] for l in cnt_dict.items() if l[1] == max(cnt_dict.values())]):
	print(ans)

Submission status: Time Limit Exceeded

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

list_val = list(set(L))
list_val.sort()
list_size = []
for i in list_val:
    list_size.append(L.count(i))

max_size = max(list_size)

while max(list_size) == max_size:
    max_idx = list_size.index(max_size)
    print(list_val[max_idx])
    list_size[max_idx] = 0

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

s = [0] * n
v = [0] * (n - 1)
w = [0]

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

t = sorted(s)

for i in range(n - 1):
    if t[i] == t[i + 1]:
        v[i] = 1

u = sorted(set(t), key=t.index)

for i in range(n - 1):
    if v[i] != 0:
        w[len(w) - 1] += 1
    else:
        w.append(0)

for i in range(len(w)):
    if max(w) == w[i]:
        print(u[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)
ret = [letter for letter,count in a.most_common() if count == a.most_common()[0][1]]
ret.sort()
for r in ret:
  print(r)

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
string_list=[input() for i in range(n)]
s=set(string_list)
t=list(s)
l=[0]*len(t)

for i in range(n):
  for j in range(len(t)):
    if t[j] == string_list[i]:
      l[j]+=1
u=[]
for k in range(len(t)):
  if l[k] == max(l):
    u.append(t[k])
u.sort()
for x in u:
	print(x)

Submission status: Time Limit Exceeded

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

ss=sorted(s)
t=0
c=1
count=[]
for i in range(1,n):
    if i==n-1:
        if ss[t]==ss[i]:
            count.append(c+1)
        else:
            count.append(c)
            count.append(1)
    else:
        if ss[t]==ss[i]:
            c+=1
        else:
            t=i
            count.append(c)
            c=1
u=0
for i in count:
    if i==max(count):
        print(ss[u])
    u+=i

Submission status: Time Limit Exceeded

Solution code:
import collections

N=int(input())
A=[input() for i in range(N)]
ans=collections.Counter(A)
ans=dict.items(ans)
ans=sorted(ans, key=lambda x:(-x[1],x[0]))
re_ans=""
for j in range(len(set(A))):
    if ans[j][1]==ans[0][1]:
        re_ans=re_ans+"\n"+ans[j][0]
print(re_ans.lstrip("\n"))

Submission status: Time Limit Exceeded

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

l = list(set(s))

if len(l) == len(s):
    s.sort()
    for i in s:
        print(i)
    exit()

count = [0] * len(l)
for i, v in enumerate(l):
    count[i] = s.count(v)

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

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

ans.sort()

for i in ans:
    print(i)

Submission status: Time Limit Exceeded

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

box = []
S_box = []
last = []
sss = set(S)
an = []

for k in sss:
    S_box.append(k)

ab = len(sss)
    
for i in range(0, ab):
    box.append(S.count(S_box[i]))

num = max(box)
bc = len(box)

for a in range(0, bc):
    if num == box[a]:
        last.append(a)

for l in last:
    an.append(S_box[l])
an = sorted(an)
for p in an:
    print(p)

Submission status: Time Limit Exceeded

Solution code:
import sys
def main():
    input = sys.stdin.readline
    N = int(input())
    counts = {}
    for i in range(N):
        string = input().strip('\n')
        if string in counts:
            counts[string] += 1
        else:
            counts[string] = 1
    max_k_list = [kv[0] for kv in counts.items() if kv[1] == max(counts.values())]
    max_k_list.sort()
    for j in max_k_list:
        print(j)
if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
import collections
# from collections import OrderedDict

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

c = collections.Counter(S)

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

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
s = [0] * n
li = []
ans = []
for i in range(n):
    s[i] = input()
    if s[i] in ans:
        li[ans.index(s[i])][1] += 1
    else:
        li.append([s[i], 1])
        ans.append(s[i])
              
li.sort(key = lambda x: x[0])
li.sort(key = lambda x: x[1] , reverse = True)

a = li[0][1]
for i in range(len(li)):
    if a == li[i][1]:
        print(li[i][0])
    else:
        break

Submission status: Time Limit Exceeded

Solution code:
import bisect

n = int(input())
sl = []
for i in range(n):
    s = input()
    index = bisect.bisect_left(sl, s)  # 2 最も左(前)の挿入箇所が返ってきている
    sl.insert(index, s)

# print(sl)
c = 0
anss = []
max_n = 0
for i, t in enumerate(sl):
    if i == 0:
        c += 1
        target = t
        continue

    if t == target:
        c += 1
    else:
        if max_n < c:
            anss = []
            anss.append(target)
            max_n = c
        elif max_n == c:
            anss.append(target)
            max_n = c
        target = t
        c = 1

if max_n < c:
    anss = []
    anss.append(t)
elif max_n == c:
    anss.append(t)


print(*anss)

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-
N=int(input())
S=[]
count=[]
ans=[]
for i in range(N):
    s=input()
    if s in S:
        count[S.index(str(s))][0]=count[S.index(str(s))][0]+1
    else:
        S.append(s)
        count.append([0,s])
count.sort()
base=count[-1][0]
for j in range(len(count)-1,-1,-1):
  if count[j][0]!=base:
    break
  else:
    ans.append(count[j][1])
ans.sort()
for i in range(len(ans)):
  print(ans[i])

Submission status: Time Limit Exceeded

Solution code:
def main():
    n = int(input())
    words = {}
    for _ in range(n):
        a = input()
        if a in words:
            words[a] += 1
        else:
            words[a] = 1
    results = [key
               for key in words.keys() if words[key] == max(words.values())]
    results.sort()
    print(' '.join(map(str, results)))


if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

Solution code:
import collections
n = int(input())
s = [input() for i in range(n)]
p = collections.Counter(s)
res = sorted(p.items(), key=lambda x: x[1],reverse = True)

keys = []
#keys = [i for i,m in p.items() if m == p.values()]
for i,m in res:
  if(m == max(p.values())):
    keys.append(i)
  else:
    break
keys=sorted(keys)
for i in range(len(keys)):
  print(keys[i])

Submission status: Time Limit Exceeded

Solution code:
import collections

N = int(input())
S = []
for _ in range(N):
    S.append(input())
c = collections.Counter(S)
ans = []
max = c.most_common()[0][1]
i = 0
current = c.most_common()[i]
while current[1] == max:
    ans.append(current[0])
    i += 1
    if len(c) <= i:
        break
    current = c.most_common()[i]

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.append(input())
A = []
from collections import Counter
d = Counter(S)
for key, value in d.items():
    if value == max(d.values()):
        A.append(key)
As = sorted(A)
for i in range(len(As)):
    print(As[i])

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
wordlist = [input() for i in range(n)]
wordtuple = tuple(set(wordlist))
checklist = []
ans = []
a = len(wordtuple)
for j in range(a) :
    checklist.append(wordlist.count(wordtuple[j]))
anslist = [i for i, v in enumerate(checklist) if v == max(checklist)]
for k in anslist :
    ans.append(wordtuple[k])
ans.sort()
for l in range(len(ans)) :
    print(ans[l])

Submission status: Time Limit Exceeded

Solution code:
##C
N = int(input())
S = list(input() for i in range(N))

import collections

c = collections.Counter(S)
ans = 0

if c.most_common()[0][1] == N:
    print(S[0])
else:
    for j in range(N):
        if c.most_common()[0][1] == c.most_common()[j][1]:
            ans += 1
        else:
            break
    ansl = list()
    for k in range(ans):
        ansl.append((c.most_common()[k][0]))
    ansl.sort()
    for l in ansl:
        print(l)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

s = []
t = []

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

s.sort()

for j in range(n):
    t.append(s.count(s[j]))

u = max(t)

st = 0

for k in range(n):
    if s.count(s[k]) == u:
        if st != s[k]:
            print (s[k])
            st = s[k]

Submission status: Time Limit Exceeded

Solution code:
num = int(input())
value = [input() for i in range(num)]
string_count = list(set(value))
string_count.sort()
number = 0
list_data = list()
for data in string_count:
    if number == value.count(data):
        list_data.append(data)
    elif number < value.count(data):
        number = value.count((data))
        list_data = []
        list_data.append(data)

for i in list_data:
    print(i)

Submission status: Time Limit Exceeded

Solution code:
def main():
    N = int(input())
    S = [str(input()) for _ in range(N)]
    S_ = [x for x in set(S) if S.count(x) > 1] #重複している要素を取り出す
    if len(S_)==0:
        S.sort()
        for i in range(len(S)):
            print(S[i])
    else:
        chofuku_number=[S.count(x) for x in S_]
        max_chofuku = max(chofuku_number)
        answer=[S_[i] for i in range(len(chofuku_number)) if chofuku_number[i]==max_chofuku]
        answer.sort()
        for i in range(len(answer)):
            print(answer[i])
if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
from collections import defaultdict
N = int(input())
S = [input() for i in range(N)]
input_dict = defaultdict(int)
for key in S:
    input_dict[key] += 1
max_list = [kv for kv in input_dict.items() if kv[1] == max(input_dict.values())]
max_list.sort()
for i in range(len(max_list)):
    print(max_list[i][0])

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
s = [input() for i in range(n)]
set_s = set(s)
max_count = max([s.count(i) for i in set_s])
for i in sorted(set_s):
    if s.count(i) == max_count:
        print(i)

Submission status: Time Limit Exceeded

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

Dict = list(zip(Counted, num))
Dict_sorted = sorted(Dict,key=lambda x: x[1], reverse = True)
 
VVV = []
 
for i in range(len(Dict_sorted)):
  if Dict_sorted[i][1] == Dict_sorted[0][1]:
    VVV.append(Dict_sorted[i][0])
  else:
    break

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

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
S = [input() for i in range(N)]
S_set = list(set(S))
#print(S_set)
word_buf = []
cnt = []
mmax = -1

for i in range(len(S_set)) :
    cnt.append(S.count(S_set[i]))
    if i == 0 :
        word_buf.append(S_set[i])
    else :
        if cnt[i] < mmax :
            pass
        elif cnt[i] == mmax :
            word_buf.append(S_set[i])
        elif cnt[i] > mmax :
            word_buf.clear()
            word_buf.append(S_set[i])
    mmax = max(mmax,cnt[i]) # 現時点での最大値
word_buf = sorted(word_buf)
#print("--")
for i in range(len(word_buf)) :
    print(word_buf[i])

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
import collections

N = int(input())
S = [input() for i in range(N)]
SS = []
c = collections.Counter(S)
n = len(c.most_common())
for j in range(1, n):
    if(c.most_common()[0][1] == c.most_common()[j][1]):
        b = c.most_common()[j][0]
        SS.append(b)
SS.append(c.most_common()[0][0])
sortedS = sorted(SS)
[print(k) for k in sortedS]

Submission status: Time Limit Exceeded

Solution code:
num = int(input())

from collections import defaultdict
from collections import OrderedDict
dic = defaultdict(int)
import operator

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

d = OrderedDict(sorted(dic.items()))

k = {}
k = [key for m in [max(d.values())] for key,val in d.items() if val == m]

for i in k:
  print(i)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
str_lis = []
max_str_lis = []
max_num = 1
for i in range(N):
  A = str(input())
  str_lis.append(A)
  times = str_lis.count(A)
  if times > max_num:
    max_str_lis = []
    max_str_lis.append(A)
    max_num = times
  if times == max_num and not A in max_str_lis:
    max_str_lis.append(A)

new_max_str_lis = sorted(max_str_lis)
for i in new_max_str_lis:
  print(i)

Submission status: Time Limit Exceeded

Solution code:
from collections import Counter

N = int(input())
S = [input() for i in range(N)]
S.sort(reverse=False)
clist = Counter(S)
tmp = 0
rlist = []

for i in range(len(clist)):
	if tmp <= int(clist.most_common()[i][1]):
		tmp = int(clist.most_common()[i][1])
		rlist.append(clist.most_common()[i][0])

rlist.sort(reverse=False)

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

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
s={}
for i in range(0,n):
  cs=input()
  if cs in s.keys():
    s[cs]+=1
  else:
    s[cs]=1

maxks=[kv[0] for kv in s.items() if kv[1]==max(s.values())]
maxks.sort()
print('\n'.join(maxks))

Submission status: Time Limit Exceeded

Solution code:
#C




n = int(input())
s = [input() for i in range(n)]
t = list(set(s))
m = 0
l = []
for i in range(len(t)):
    if m < s.count(t[i]):
        l = [t[i]]
        m = s.count(t[i])
    elif m == s.count(t[i]):
        l.append(t[i])
l = sorted(list(set(l)))
for i in l:
    print(i) 
# beat
# vet
# beet
# bed
# vet
# bet
# beet

Submission status: Time Limit Exceeded

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

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

ans=max(s)
for i in range(len(s)):
    if s[i]==ans:
        ansl.append(li[i])

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

Submission status: Time Limit Exceeded

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

myList = []
for i in s:
  if i not in myList:
    myList.append(i)
    
counter = []
for i in myList:
  counter.append(s.count(i))

myDist = dict(zip(myList,counter))

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

for i in sortList:
  print(i)

Submission status: Time Limit Exceeded

Solution code:
from sys import stdin
n = int(stdin.readline().rstrip())
data = [stdin.readline().rstrip() for _ in range(n)]

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

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

Submission status: Time Limit Exceeded

Solution code:
#!usr/bin/env python3


import sys


def I(): return int(sys.stdin.readline())


def solve():
    n = I()
    sli = [input() for i in range(n)]
    setli = set(sli)
    rank = {}
    for i in setli:
        j = sli.count(i)
        rank[i] = j
    ans = [k for k, v in rank.items() if v == max(rank.values())]
    ans.sort()
    for i in ans:
        print(i)


# Solve
if __name__ == "__main__":
    solve()

Submission status: Time Limit Exceeded

Solution code:
import sys
import collections
n = int(input())
li=[input() for _ in range(n)]
c = collections.Counter(li)
max_list = [kv[0] for kv in c.items() if kv[1] == max(c.values())]
max_list.sort()
for s in max_list:
  print(s)

Submission status: Time Limit Exceeded

Solution code:
import collections
 
n=int(input())
s=[]
 
for i in range(n):
    s.append(input())
 
d=collections.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 range(len(max_k_list)):
    print(max_k_list[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 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=input()
list=[]
a=[]
b=[]
c=[]
s=[]
t=0
for i in range(int(N)):
    list.append(input())
    # for l in range(len(a)):
    #     if(a[l]==list[i]):
    #         b[l]+=1
    #         t=1
    #         break
    # if t==0:
    #     a.append(list[i])
    #     b.append(1)
    # else:
    #     t=0
    if(list[i] in a):
        b[a.index(list[i])]+=1
    else:
        a.append(list[i])
        b.append(1)
m=max(b)
for i in range(len(a)):
    if b[i]==m:
        c.append(a[i])
s=sorted(c)
for i in range(len(s)):
    print(s[i])

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
N = int(input())
S = [input() for __ in range(N)]

S = np.array(S)
keys = set(S)
ans = {}
for key in keys:
    ans[key] = len(np.where(S == key)[0])
v = np.array(sorted(ans.values(),reverse = True))
k = sorted(ans.items())

keys = []
for k, val in sorted(ans.items(), key=lambda x: -x[1]):
    keys.append(k)

count = len(np.where(v == v[0])[0])
keys = keys[:count]
keys.sort()
for key in keys:
  print(key)

Submission status: Time Limit Exceeded

Solution code:
# coding: utf-8

num = int(input())
line = []
result = []
point =False

for i in range(num):
    line.append(input())

for i in range(num):
    for j in range(len(result)):
        if result[j][0] == line[i]:
            result[j][1] += 1
            point = True
    if point == False:
        result.append([line[i],1])
    else:
        point = False

count = 0
for i in range(len(result)):
    if count < result[i][1]:
        count = result[i][1]


result_a = []
for i in range(len(result)):
    if count == result[i][1]:
        result_a.append(result[i][0])

newlist = sorted(result_a)

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

Submission status: Time Limit Exceeded

Solution code:

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

moji = sorted(s)

#重複削除
mow = set(moji)
mo2 = sorted(mow)

co=[]
for i in range(len(mo2)) :
	co.append(moji.count(mo2[i]))
	
	
#最大値
m_co = max(co)
i = 0
ou=[]

#
for i in range(len(mo2)) :
	
	if moji.count(mo2[i]) == m_co:
		ou.append(mo2[i])
	
print('\n'.join(map(str, ou)))

Submission status: Time Limit Exceeded

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

P=collections.Counter(S)

A = [k for k, v in P.items() if v == max(P.values())]

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 = [input() for _ in range(N)]

box = []
S_box = []
last = []
sss = set(S)
an = []

for k in sss:
    S_box.append(k)

for i in range(0, len(sss)):
    box.append(S.count(S_box[i]))

num = max(box)

for a in range(0, len(box)):
    if num == box[a]:
        last.append(a)

for iii in last:
    an.append(S_box[iii])
an = sorted(an)
for aaa in an:
    print(aaa)

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
s=sorted([input() for k in range(n)])
p=[]
if(len(set(s))==len(s)):
    for u in range(len(s)):
        print(s[u])
    exit()
else:
    s1 = [m for m in sorted(list(set(s))) if s.count(m)>1]
    for i in s1:
        p.append(s.count(i))
max=max(p)
for j, x in enumerate(p):
    if(x == max):
        print(s1[j])

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
S = [input() for i in range(N)]
S_set = sorted(list(set(S)))
#print(S_set)
cnt = [0 for i in range(len(S_set))]
word_buf = []
mmax = -1

for i in range(len(S_set)) :
    cnt[i] = S.count(S_set[i])
    if i == 0 :
        word_buf.append(S_set[i])
    else :
        if cnt[i] < mmax :
            pass
        elif cnt[i] == mmax :
            word_buf.append(S_set[i])
        elif cnt[i] > mmax :
            word_buf.clear()
            word_buf.append(S_set[i])
    mmax = max(mmax,cnt[i]) # 現時点での最大値
#print("--")
for i in range(len(word_buf)) :
    print(word_buf[i])

Submission status: Time Limit Exceeded

Solution code:
from collections import Counter


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

counted = Counter(s)
#最頻値が同値である場合全て出力したい
#頻出数ではなく、文字だけ出力したい
#print(s.most_common()[0])

ret = [letter for letter,count in counted.most_common() if count == counted.most_common()[0][1]]
new_ret=sorted(ret)
[print(i) for i in new_ret]

Submission status: Time Limit Exceeded

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

dic = {}

for i in s:
    c = s.count(i)
    if(len(dic) == 0):
        dic[i] = c
    elif(c == max(dic.values())):
        dic[i] = c
    elif(c > max(dic.values())):
        dic = {i : c}

k = list(dic.keys())

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

Submission status: Time Limit Exceeded

Solution code:
import numpy as np

n = int(input())

buf = []
cnt = []

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

aaa = np.max(cnt)
ans2 = np.array(buf)[np.array(cnt) == aaa]
ans3 = np.sort(ans2)

for i in ans3:
    print(i)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
t = []
c = 0
for i in range(n):
    s = input()
    for j in range(len(t)):
        if s == t[j][0]:
            t[j][1] += 1
            c = 1
            break
    if c == 0:
        t.append([s, 1])
    c = 0
a = []
b = 0
for i in range(len(t)):
    if b < t[i][1]:
        b = t[i][1]
        a = [t[i][0]]
    elif b == t[i][1]:
        a.append(t[i][0])
a.sort()
for i in a:
    print(i)