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

Submission status: Time Limit Exceeded

Solution code:
import collections
 
N = int(input())
data = list([input() for i in range(N)])
 
dicdata = collections.Counter(data)
 
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:
def main():
    n =int( input())
    sn=[]

    for i in range(n):
        inWord = str(input())
        addFlag = True
        for s in sn:
            if s["word"] == inWord and len(sn) !=0:
                s["count"]+=1
                addFlag = False
                break
        if addFlag ==True:
            sn.append( {"word":inWord,"count":1})
    
    sn.sort(reverse=True,key=lambda x:x['count'])
    
    most = int(sn[0]["count"])
    mostWords=[]
    for elm in sn:
        if elm["count"] == most:
            mostWords.append(elm["word"])
        else:
            break
    mostWords.sort()

    for elm in mostWords:
        print(elm)
    return
main()

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
votes = [input() for i in range(n)]
candidates = sorted(set(votes))
nof_votes = [votes.count(c) for c in candidates]
max_nof_votes = max(nof_votes)

for i in range(len(candidates)):
    if nof_votes[i] == max_nof_votes:
        print(candidates[i])

Submission status: Time Limit Exceeded

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

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

s.sort()
n =set(s)
n=list(n)

f = []

for i in range(len(n)):
    f.append([n[i],s.count(n[i])])

f.sort(reverse=True,key=lambda f:f[1])
max = f[0][1]
fl=[]
for i in range (len(f)):
    if f[i][1] == max:
        fl.append(f[i][0])
    else:
        break

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

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

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
votes = [0] * n

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

candidates = sorted(set(votes))
nof_votes = [votes.count(c) for c in candidates]
max_nof_votes = max(nof_votes)

for i in range(len(candidates)):
    if nof_votes[i] == max_nof_votes:
        print(candidates[i])

Submission status: Time Limit Exceeded

Solution code:
def main():
    n =int( input())
    sn=[]

    for i in range(n):
        inWord = str(input())
        addFlag = True
        for s in sn:
            if s["word"] == inWord and len(sn) !=0:
                s["count"]+=1
                addFlag = False
                break
        if addFlag ==True:
            sn.append( {"word":inWord,"count":1})
    
    a= sorted(sn, reverse=True,key=lambda x:x['count'])

    most = int(a[0]["count"])
    mostWords=[]
    for elm in a:
        if elm["count"] == most:
            mostWords.append(elm["word"])
    mostWords.sort()

    for elm in mostWords:
        print(elm)
    return
main()

Submission status: Time Limit Exceeded

Solution code:

n = int(input())

s = {}
i = 0
while n > i:
    s_tmp = input()
    if s.get(s_tmp):
        s[s_tmp] += 1
    else:
        s.setdefault(s_tmp, 1)
    i += 1
    
max_k_list = [kv[0] for kv in s.items() if kv[1] == max(s.values())]
max_k_list.sort()

for i in max_k_list:
    print(i)

Submission status: Time Limit Exceeded

Solution code:
#!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations
import sys
import math
import bisect


def LI(): return [int(x) for x in sys.stdin.readline().split()]


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


def LS(): return [list(x) for x in sys.stdin.readline().split()]


def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res


def IR(n):
    return [I() for i in range(n)]


def LIR(n):
    return [LI() for i in range(n)]


def SR(n):
    return [S() for i in range(n)]


def LSR(n):
    return [LS() for i in range(n)]


sys.setrecursionlimit(1000000)
mod = 1000000007


def solve():
    n = I()
    sli = [input() for i in range(n)]
    rank = defaultdict(lambda: 0)
    for i in sli:
        rank[i] += 1
    for i in sorted([k for k, v in rank.items() if v == max(rank.values())]):
        print(i)


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

Submission status: Time Limit Exceeded

Solution code:
import collections

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

c = collections.Counter(List)


leng = len(c)

res.append(c.most_common()[0][0])
for i in range(1, leng):
    if c.most_common()[i][1] >= c.most_common()[i-1][1]:
        res.append(c.most_common()[i][0])
    else:
        break

#res = sorted(res)
res.sort()
for j in range(len(res)):
    print(res[j])

Submission status: Time Limit Exceeded

Solution code:
inp = int(input())
 
l = []
for i in range(0, inp):
  l.append(input())
max_num = 1
max_words = []
for i in list(set(l)):
  c = l.count(i)
  if c < max_num:
    pass
  elif c == max_num:
    max_words.append(i)
  elif c > max_num:
    max_num = c
    max_words = [i]
print("\n".join(sorted(max_words)))

Submission status: Time Limit Exceeded

Solution code:
#!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations
import sys
import math
import bisect


def LI(): return [int(x) for x in sys.stdin.readline().split()]


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


def LS(): return [list(x) for x in sys.stdin.readline().split()]


def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res


def IR(n):
    return [I() for i in range(n)]


def LIR(n):
    return [LI() for i in range(n)]


def SR(n):
    return [S() for i in range(n)]


def LSR(n):
    return [LS() for i in range(n)]


sys.setrecursionlimit(1000000)
mod = 1000000007


def solve():
    n = I()
    sli = [input() for i in range(n)]
    setli = set(sli)
    rank = defaultdict(lambda: 0)
    for i in setli:
        j = sli.count(i)
        rank[i] = j
    for i in sorted([k for k, v in rank.items() if v == max(rank.values())]):
        print(i)


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

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
votes = [0] * n

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

candidates = sorted(list(set(votes)))
nof_votes = [votes.count(c) for c in candidates]
max_nof_votes = max(nof_votes)

for i in range(len(candidates)):
    if nof_votes[i] == max_nof_votes:
        print(candidates[i])

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
lit = [input() for i in range(N)]
lit_new_cnt = []
for i in range(N):
    A = lit.count(lit[i])
    lit_new_cnt.append(A)
B = max(lit_new_cnt)
lit2 = []
for i in range(N):
    if lit_new_cnt[i] == B:
        lit2.append(lit[i])
lit3 = list(set(lit2))
lit3.sort()
for x in lit3:
    print(x)

Submission status: Time Limit Exceeded

Solution code:
dic={}
s=set()
n=int(input())
d=[]
for i in range(n):
  d.append(input())
  s.add(d[-1])
mx=0
for w in s:
  dic[w]=d.count(w)
  mx=max(mx,dic[w])

for k,v in sorted(dic.items(),key=lambda x:(-x[1],x[0])):
  if mx==v:
    print(k)

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
            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:
dic={}
n=int(input())
d=[]
for i in range(n):
  d.append(input())
mx=0
for w in d:
  dic[w]=d.count(w)
  mx=max(mx,dic[w])

for k,v in sorted(dic.items(),key=lambda x:(-x[1],x[0])):
  if mx==v:
    print(k)

Submission status: Time Limit Exceeded

Solution code:
import collections
import sys
def main():
  input = sys.stdin.readline
  n = int(input())
  li=[input() for _ in range(n)]
  li1 = []
  for s in li:
    s = s.strip("\n")
    li1.append(s)
  c = collections.Counter(li1)
  max_list = [kv[0] for kv in c.items() if kv[1] == max(c.values())]
  max_list.sort()
  for s in max_list:
    if(s!='\n'):
      print(s)

if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
from collections import Counter

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

c=Counter(l)

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

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

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
s = [input() for i in range(N)]
	
myDict = {}
for i in s:
  myDict[i] = s.count(i)
max_k_list = [kv[0] for kv in myDict.items() if kv[1] == max(myDict.values())]
sortList = sorted(max_k_list)
s_n = '\n'.join(sortList)
print(s_n)

Submission status: Time Limit Exceeded

Solution code:
import collections

N = int(input())
S = list(input() for i in range(N))
dict = {}

for l in S:
        if l in dict:
            dict[l] += 1;
        else:
            dict[l] = 1;

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

max_k_list.sort()

for i in max_k_list:
    print(i)

Submission status: Time Limit Exceeded

Solution code:
import heapq
 
n= int(input())
s=[input() for i in range(n)]
 
ss = list(set(s))
 
if(len(s)==len(ss)):
    s.sort()
    for i in s:
        print(i)
 
else:
    li = []
    heapq.heapify(li)
    for i in ss:
        ans = s.count(i)
        heapq.heappush(li,(-ans,i))
    
    for i in range(len(ss)):
        amount,st = heapq.heappop(li)
        if(i==0):
            print(st)
            ri=amount
            continue
        
        if(ri==amount):
            print(st)
        else:
            break

Submission status: Time Limit Exceeded

Solution code:
import collections
N = int(input())
S_list = []
for i in range(N):
  S_list.append(input())
 
c = collections.Counter(S_list)
 
words = []
counter = 0
 
 
while(True):
  words.append(c.most_common()[counter][0])
  try:
    if c.most_common()[counter][1] == c.most_common()[counter+1][1]:
      counter += 1
    else:
      break
  except:
    break
 
words = sorted(words)
for j in range(len(words)):
  print(words[j])

Submission status: Time Limit Exceeded

Solution code:
import collections


N = int(input())

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

count = collections.Counter(S)
result = []

max_k, mx = max(count.items(), key=lambda x : x[1])

result.append(max_k)
del count[max_k]
for i in range(len(count)):
    max_k, max_v = max(count.items(), key=lambda x : x[1])
    if max_v == mx:
        result.append(max_k)
        del count[max_k]
    else:
        break
print("\n".join(sorted(result)))

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
content = []
count = []
for i in range(n):
  str_input = input()
  check = 0
  if (str_input in content) == True:
    count[content.index(str_input)] += 1
  else:
    content.append(str_input)
    count.append(1)

max_count = max(count)
max_index = []
for i in range(len(content)):
  if count[i] == max_count:
    max_index.append(content[i])
    
max_index.sort()

for answer in max_index:
  print(answer)

Submission status: Time Limit Exceeded

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

S = set(s)
c_m = int(0)
l = []

for i in range(len(S)):
    a = S.pop()
    c_i = int(s.count(a))
    if c_i > c_m:
        c_m = c_i
        l = [a]
    elif c_i == c_m:
        l.append(a)

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

Submission status: Time Limit Exceeded

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

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

for i in sortList:
  print(i)

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

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

#空のリストを用意
word_list = []
counter_list = []

for i in range(N):
	word = input()
	if word in word_list:
		num = word_list.index(word)
		counter_list[num] += 1
	else:
		word_list.append(word)
		counter_list.append(1)

maxIndex_list = [i for i, x in enumerate(counter_list) if x == max(counter_list)]

#答えを格納するリスト
answer_list = []
for i in maxIndex_list:
	answer_list.append(word_list[i])
	
answer_list.sort()

for answer in answer_list:
	print(answer)

Submission status: Time Limit Exceeded

Solution code:
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_]
    answer=[S_[i] for i,x in enumerate(chofuku_number) if x==max(chofuku_number)]
    answer.sort()
    for i in range(len(answer)):
        print(answer[i])

Submission status: Time Limit Exceeded

Solution code:
import numpy as np

def bubble_sort(arr):
    change = True
    while change:
        change = False
        for i in range(len(arr) - 1):
            if arr[i] > arr[i + 1]:
                arr[i], arr[i + 1] = arr[i + 1], arr[i]
                change = True
    return arr

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 = max(cnt)
ans2 = np.array(buf)[np.array(cnt) == aaa]
ans2.sort()

for i in ans2:
    print(i)

Submission status: Time Limit Exceeded

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

from collections import Counter

N, *a = open(0).read().split()
c = Counter(a)
keys = [k for k, v in c.items() if v ==c.most_common()[0][1] ]

keys.sort()
string = "\n".join(keys)
print(string)

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(ans)):
    if a == li[j][1]:
        print(li[j][0])
    else:
        break

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
b=0
c=0
d=0
e=0
list=[]
list2=[]
for i in range(n):
    s=input()
    list.append(s)
for x in list:
    b=list.count(x)
    if b>=c:
        c=b
for x in list:
    if c==list.count(x):
        list2.append(x)
e=len(list2)
for i in range(e):
    if list2.count(list2[d])>=2:
        list2.remove(list2[d])
    else:
        d+=1
list2.sort()
for x in list2:
    print(x)

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 = {}
cnt = 0
ls = []
for key in keys:
    ans[key] = len(np.where(S == key)[0])

max_v = max(ans.values())
keys = [k for k, v in ans.items() if v == max_v]
keys.sort()
for key in keys:
    print(key)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
sett = set()
L=[]
Dic = {}
for n in range(N):
    S = input()
    sett.add(S)
    L.append(S)


for i in list(sett):
    Dic[i]=0

for j in L:
    Dic[j] = Dic[j] + 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:
a=int(input())

listing=[]

for i in range(a):
    listing.append(input())

set_list=list(set(listing))

num_list=[0]*len(set_list)
counter=0
for i in set_list:
    num_list[counter] = listing.count(i)
    counter +=1

res_list=[]
for i in range(num_list.count(max(num_list))):
    res_list.append(set_list[num_list.index(max(num_list))])
    set_list.remove(set_list[num_list.index(max(num_list))])
    num_list.remove(max(num_list))

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

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
listOfS = []
for count in range(N):
    S = input()
    listOfS.append(S)
maximumValue = 0
listOfMaximumS = []
index = 0
for count in range(len(listOfS)):
    S = listOfS[count-index]
    if (listOfMaximumS.count(S)>0):
        listOfS.remove(S)
        index += 1
        continue
    countValue = listOfS.count(S)
    if (countValue > maximumValue):
        listOfMaximumS = []
        listOfMaximumS.append(S)
        maximumValue = countValue
    elif (countValue == maximumValue):
        if (not (listOfMaximumS.count(S)>0)):
            listOfMaximumS.append(S)
sorted_list = sorted(listOfMaximumS, key=str.lower)
for count in range(len(sorted_list)):
    print(sorted_list[count])

Submission status: Time Limit Exceeded

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

li = sorted(string_list)
uniq_li = list(set(li))
n_li = []

for s in uniq_li:
  num = li.count(s)
  n_li.append([num, s])

n_li.sort(reverse=True)

max = n_li[0][0]

out_list = []

for i in n_li:
    if i[0] == max:
        out_list.append(i[1])
    else:
      break;

out_list.sort()

for i in out_list:
  print(i)

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()#同じ文字列は固まる
js = sorted(s)
ans.append(s[0])
for j in range(len(js)-1):
    if s.count(js[j]) < s.count(js[j+1]):
        ans.append(js[j+1])
        ans.pop(0)
    elif s.count(s[j]) == s.count(s[j+1]) and js[j] != js[j+1]:
        ans.append(js[j+1])
for a in ans :
    print(a)

Submission status: Time Limit Exceeded

Solution code:
import collections


N = int(input())

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

count = collections.Counter(S)
result = []

max_k, mx = max(count.items(), key=lambda x : x[1])

result.append(max_k)
del count[max_k]
for i in range(len(count)):
    max_k, max_v = max(count.items(), key=lambda x : x[1])
    if max_v == mx:
        result.append(max_k)
        del count[max_k]
    else:
        break

for r in sorted(result):
    print(r)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
listOfS = []
for count in range(N):
    S = input()
    listOfS.append(S)
maximumValue = 0
listOfMaximumS = []
index = 0
for count in range(len(listOfS)):
    S = listOfS[count-index]
    
    if (listOfMaximumS.count(S)>0):
        listOfS.remove(S)
        index += 1
        next
    countValue = listOfS.count(S)
    if (countValue > maximumValue):
        listOfMaximumS = []
        listOfMaximumS.append(S)
        maximumValue = countValue
    elif (countValue == maximumValue):
        if (not (listOfMaximumS.count(S)>0)):
            listOfMaximumS.append(S)
sorted_list = sorted(listOfMaximumS, key=str.lower)
for count in range(len(sorted_list)):
    print(sorted_list[count])

Submission status: Time Limit Exceeded

Solution code:
import collections
import itertools
import sys
def input():
    return sys.stdin.readline()[:-1]
N=int(input())
S=[]


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

counted= collections.Counter(S)

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

ans=sorted(ret)
print(*ans, sep="\n")

Submission status: Time Limit Exceeded

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

S = set(s)
c_m = int(0)
l = []

for i in range(len(S)):
    a = S.pop()
    c_i = int(s.count(a))
    if c_i > c_m:
        c_m = c_i
        l = [a]
    elif c_i == c_m:
        l.append(a)

l.sort()
for i in range(len(l)):
  print(l[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]))
maxnum = max(checklist)
anslist = [i for i, v in enumerate(checklist) if v == maxnum]
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:
N=int(input())
S=[str(input()) for i in range(N)]

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

m=max(d)
sm=[]
for i in range(l):
  if d[i]==m:
    sm.append(SA[i])

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

Submission status: Time Limit Exceeded

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

sl_s = sorted(list(set(sl)))

# if len(sl_s) == 1:
#     print(sl[0])
# else:
#     ans = []
#     count = 1
#     for s in sl_s:
#         if sl.count(s) == count and ans.count(s) == 0:
#             ans.append(s)
#         elif sl.count(s) > count and ans.count(s) == 0:
#             ans.clear()
#             ans.append(s)
#             count = sl.count(s)
#     print('\n'.join(ans))


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

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

Submission status: Time Limit Exceeded

Solution code:
import collections

N = int(input())
S = [input() for i in range(N)]
c = collections.Counter(S)
uniqueS = list(set(S))
result = []
max = c.most_common()[0][1]

for i in range(len(uniqueS)):
    nowmax = c.most_common()[i][1]
    if nowmax != max:
        break
    result.append(c.most_common()[i][0])
result.sort()

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

Submission status: Time Limit Exceeded

Solution code:
from collections import Counter

N, *a = open(0).read().split()
c = Counter(a)
keys = [k for k, v in c.items() if v ==c.most_common()[0][1] ]

keys.sort()
string = "\n".join(keys)
print(string)

Submission status: Time Limit Exceeded

Solution code:
import numpy as np

def bubble_sort(arr):
    change = True
    while change:
        change = False
        for i in range(len(arr) - 1):
            if arr[i] > arr[i + 1]:
                arr[i], arr[i + 1] = arr[i + 1], arr[i]
                change = True
    return arr

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 = max(cnt)
ans2 = np.array(buf)[np.array(cnt) == aaa]
ans3 = bubble_sort(ans2)

for i in ans3:
    print(i)

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
a = [input() for i in range(n)]
b = sorted(list(set(a)))
d = {}
m = 0

for i in b:
    t = a.count(i)
    if m > 0 and t < m:
        continue

    d.setdefault(t,[])
    d[t].append(i)
    if t > m:
        m = t

for i in d[max(d.keys())]:
    print(i)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
listOfS = []
for count in range(N):
    S = input()
    listOfS.append(S)
maximumValue = 0
listOfMaximumS = []
index = 0
for count in range(len(listOfS)):
    S = listOfS[count-index]
    
    if (listOfMaximumS.count(S)>0):
        listOfS.remove(S)
        index += 1
    countValue = listOfS.count(S)
    if (countValue > maximumValue):
        listOfMaximumS = []
        listOfMaximumS.append(S)
        maximumValue = countValue
    elif (countValue == maximumValue):
        if (not (listOfMaximumS.count(S)>0)):
            listOfMaximumS.append(S)
sorted_list = sorted(listOfMaximumS, key=str.lower)
for count in range(len(sorted_list)):
    print(sorted_list[count])

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

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]) and max <= int(c.most_common()[i][1])):
            b.append(c.most_common()[i][0])
            max = c.most_common()[i][1]

    b.sort()

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

Submission status: Time Limit Exceeded

Solution code:
inp = int(input())
 
l = []
for i in range(0, inp):
  l.append(input())
 
# print(sorted(l))
max_num = 1
max_words = []
for i in list(set(l)):
  c = l.count(i)
  if c < max_num:
    pass
  elif c == max_num:
    max_words.append(i)
  elif c > max_num:
    max_num = c
    max_words = [i]
 
for i in sorted(max_words):
  print(i)

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
s=sorted([input() for k in range(n)])
s3 = sorted(list(set(s)))
if(len(set(s))==len(s)):
    for u in range(len(s)):
        print(s[u])
    exit()
else:
    s1=s2 = [m for m in s3 if s.count(m)>1]
    i = 2
    while(len(s2)!=0):
        s2 = [m for m in s3 if s.count(m)>i]
        if(len(s2)==0):
               break
        s1 = s2
        i+=1
for j in s1:
    print(j)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

s_list,count_list = [],[]
for i in range(0,n):
  Si = str(input())
  if Si in s_list :
    count_list[s_list.index(Si)] += 1
  else :
    s_list.append(Si)
    count_list.append(0)
    
ans = []
for i in [i for i, x in enumerate(count_list) if x == max(count_list)] :
  ans.append([s_list[i]])

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

Submission status: Time Limit Exceeded

Solution code:
import collections
n = int(input())
list0 = [] 
list2 = []
for i in range(0, n):
  list0.append(input())
counter=collections.Counter(list0)
max = max(counter.keys(), key=(lambda k: counter[k]))
list3 = []
for i in list0:
  if i not in list3:
    list3.append(i)
for i in list3:
  if list0.count(i) == counter[max]:
    list2.append(i)
list2.sort()
for i in list2:
  print(i)

Submission status: Time Limit Exceeded

Solution code:
def main():
    n =int( input())
    sn=[]
    
    for i in range(n):
        inWord = str(input())
        addFlag = True
        for s in sn:
            if s["word"] == inWord and len(sn) !=0:
                s["count"]+=1
                addFlag = False
                break
        if addFlag ==True:
            sn.append( {"word":inWord,"count":1})
    
    a= sorted(sn, reverse=True,key=lambda x:x['count'])

    most = a[0]["count"]
    mostWords=[]
    for elm in a:
        if elm["count"] == most:
            mostWords.append(elm["word"])
    mostWords.sort()
    for elm in mostWords:
        print(elm)
    return
main()

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
L = []
Dic = {}
for n in range(N):
    S = input()
    L.append(S)
Unique = list(set(L))

for i in Unique:
    Dic[i]=0

for j in L:
    Dic[j] = Dic[j] + 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()) #1行目のNを取得する
s = [input() for i in range(N)] #複数行の数値の入力を取得

moji = sorted(s)

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

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

ou=[mo2[i] for i in range(len(mo2)) if moji.count(mo2[i]) == m_co]

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

Submission status: Time Limit Exceeded

Solution code:
import collections
import itertools
import sys
def input():
    return sys.stdin.readline()[:-1]
N=int(input())
S=[]


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

counted= collections.Counter(S)

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

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

Submission status: Time Limit Exceeded

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

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

cand = []

for i in range(N):
    if not S[i] in cand:
        cand.append(S[i])

cand_count = []

for i in range(len(cand)):
    cand_count.append(S.count(cand[i]))

#print(cand)
#print(cand_count)
#[i for i, v in enumerate(cand_count) if v == max(cand_count)]

cand_max_ind = []

roop = 0
max_count = 0
while max_count <= max(cand_count):
    max_count = max(cand_count)
    cand_max_ind.append(cand[cand_count.index(max(cand_count))+roop])
    #print(cand_count.index(max(cand_count))+roop)
    cand_count.pop(cand_count.index(max(cand_count)))
    if len(cand_count) == 0:
        break
    roop = roop+1
    #print(cand_count)

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