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: Wrong Answer

Solution code:
n = int(input())
s = []
for _ in range(n):
    s.append(input())
d = {}
name = set(s)
for a in name:
    d.update({a:0})
for x in s:
    d[x] += 1
ds = sorted(d.items(), key=lambda x:x[1])
max = ds[-1][1]
ans = []
print(max)
for x in reversed(ds):
    print(x[1])
    if x[1]==max:
        ans.append(x[0])
    else:
        break
ans.sort()
for x in ans:
    print(x)

Submission status: Wrong Answer

Solution code:
# N枚の投票用紙
N = int(input())

s = {}
for _ in range(N):
    tmp = input()
    try:
        if s[tmp]:
            s[tmp] +=1
    except:
        s[tmp] = 1
    
#print(s)
max_kv_list = [kv[0] for kv in s.items() if kv[1] == max(s.values())]
#print(max_kv_list)

for tmp in max_kv_list:
    print(tmp)

Submission status: Wrong Answer

Solution code:
N = int(input())
D = dict()
for _ in range(N):
    cand = input()
    if cand not in D:
        D[cand] = 1
    else:
        D[cand] += 1
mx = max(D.values())
A = sorted(D.items(), key=lambda x:-x[1],)

for k, m in A:
    if m == mx:
        print(k)
    if m != mx:
        exit()

Submission status: Wrong Answer

Solution code:
n = int(input())
s = [str(input()) for i in range(n)]
d = {}
for name in s:
    if name in d.keys():
        d[name] = d[name] + 1
    else:
        d.setdefault(name, 1)
max_k_list = [kv[0] for kv in d.items() if kv[1] == max(d.values())]
for i in max_k_list:
    print(i)

Submission status: Wrong Answer

Solution code:
case = int(input())
l = [""] * case
for i in range(case):
  l[i] = input()

for str in sorted(set(l)):
  print(str)

Submission status: Wrong Answer

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

from collections import defaultdict
d = defaultdict(int)

for k in S:
    d[k]+=1

d=dict(d)
dmax=max(d)
ansn=d[dmax]
ans=[]
for i in d.keys():
    if d[i]==ansn:
        ans.append(i)

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

Submission status: Wrong Answer

Solution code:
import collections
N = int(input())
S_list = [input() for i in range(N)]
C = collections.Counter(S_list)
L = C.most_common()
max_ = L[0][1]
for i in L:
    if i[1] == max_:
        print(i[0])
    else:
        exit()

Submission status: Wrong Answer

Solution code:
from collections import Counter

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

counter = Counter(s)
index = 0
ans = []
for k, v in counter.most_common():
    if index == 0:
        max_v = v
        ans.append(k)
    else:
        if v == max_v:
            ans.append(k)
        else:
            exit()
    index += 1
ans = sorted(ans)
for i in range(len(ans)):
    print(ans[i])

Submission status: Wrong Answer

Solution code:
from collections import defaultdict

n = int(input())

d = defaultdict(int)

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

n = max(d.values())
  
for k, v in d.items():
    if v==n:
      print(k)

Submission status: Wrong Answer

Solution code:
n = int(input())
d = dict()
a = []
for i in range(n):
    b = input()
    if b not in a:
        a.append(b)
    if b not in d:
        d[b] = 1
    else:
        d[b] += 1
a.sort(key=lambda x: d[x])
i = len(a) - 1
while i >= 0 and d[a[i]] == d[a[len(a) - 1]]:
    print(a[i])
    i -= 1

Submission status: Wrong Answer

Solution code:
N = int(input())
ans = {}
for i in range(N):
	cood = input()
	if  cood not in ans:
		ans[cood] = 1
	else:
		ans[cood] += 1
max_k_list = [kv[0] for kv in ans.items() if kv[1] == max(ans.values())]
for i in range(len(max_k_list)):
	print(max_k_list[i])

Submission status: Wrong Answer

Solution code:
import collections

n = int(input())


d = collections.defaultdict(lambda:0)

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

d = dict(d)

a = collections.Counter(d).most_common()

most = 0

for k, v in a:
    if most <= v:
        most = v
        print(k)
    else:
        break

Submission status: Wrong Answer

Solution code:
import sys #sys.stdin.readline()
import heapq #heap
from collections import defaultdict
fastinp = lambda: sys.stdin.readline().split(' ')[0].split('\n')
inp = lambda: input().split(' ')
ml = lambda x, y=int: list(map(y, x))
debug = lambda *args: print(*args, sep=' | ')
n = int(fastinp()[0])
hmap = defaultdict(int)
for i in range(n):
    hmap[fastinp()[0]] += 1
m = 0
for k, v in hmap.items():
    m = max(m, v)
for k, v in hmap.items():
    if v == m:
        print(k)

Submission status: Wrong Answer

Solution code:
case = int(input())
l = [""] * case
for i in range(case):
  l[i] = input()

for str in set(l):
  print(str)

Submission status: Wrong Answer

Solution code:
N = int(input())
d = {}
for _ in range(N):
  s = input()
  if not s in d:
    d[s] = 1
  else:
    d[s] += 1
x = sorted(list(d.items()), key=lambda x:x[1], reverse=True)
n = 0
l = []
for k, v in x:
  if v >= n:
    n = v
    l.append(v)
for y in sorted(l):
  print(y)

Submission status: Wrong Answer

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

dic={}
for string in poll:
  if string not in dic:
    dic[string]=1
  else:
    dic[string]+=1

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

Submission status: Wrong Answer

Solution code:
N = int(input())
s = [0] * N
time = [1] * N
j = 0
for i in range(N):
  inp = str(input())
  if inp in s:
    x = s.index(inp)
    time[x] += 1
  else:
    s[j] = inp
    j += 1
    
ans = max(time)
#print(s, time)
for i in range(N):
  if time[i] == ans:
    if s[i] != 0:
      print(s[i])

Submission status: Wrong Answer

Solution code:
n = int(input())
s = {}

for i in range(n):
    ss = input()

    if ss in s:
        s[ss] += 1
    else:
        s[ss] = 1

s2 = sorted(s.items(), key=lambda x:x[1])

s2.reverse()

max_value = s2[0][1]
ret = []

for sss in s2:
    if sss[1] == max_value:
        ret.append(sss[0])
    else:
        break

ret2 = sorted(ret)
ret2.reverse()
print(ret2)

Submission status: Wrong Answer

Solution code:
from collections import defaultdict
N = int(input())
S = [input() for _ in range(N)]
d = defaultdict(int)
maxn = 0

for i in range(N):
    d[S[i]] += 1
    maxn = max(maxn, d[S[i]])

for k, v in d.items():
    if v == maxn:
        print(k)

Submission status: Wrong Answer

Solution code:
N=int(input())
A = [input() for x in range(N)]
max=-1
for a in set(A):
  if A.count(a)>max:
    max=A.count(a)

for b in set(A):
  if A.count(b)==max:
    print(b)

Submission status: Wrong Answer

Solution code:
import sys
stdin = sys.stdin
from collections import defaultdict

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))

n = ni()
d = defaultdict(int)
for _ in range(n):
    s = ns()
    d[s] += 1
d = sorted(d.items(), key = lambda x:x[1], reverse=True)
ki, vi = d[0]
print(ki)
for k, v in d[1:]:
    if v == vi:
        print(k)
    else:
        quit()

Submission status: Wrong Answer

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

from collections import Counter

x = sorted(Counter(s_list).items(),key=lambda x:x[1],reverse=True)
max_num = x[0][1]

result = [i[0] for i in x if i[1] == max_num]

for i in result[::-1]:
    print(i)

Submission status: Wrong Answer

Solution code:
from collections import Counter
n = int(input())
s = [input() for _ in range(n)]
s.sort()
s_cnt = Counter(s)
max_cnt = s_cnt.most_common()[0][1]
s_cnt_common = s_cnt.most_common()
for i in range(len(s_cnt_common)):
    if s_cnt_common[i][1] == max_cnt:
        print(s_cnt_common[i][0])
    else:
        exit()

Submission status: Wrong Answer

Solution code:
n = int(input())
ans = {}
li = []
for _ in range(n):
    li.append(input())

ma = 0

for i in li:
    if i in ans:
        ans[i] += 1
        if ma < ans[i]:
            ma = ans[i]
    else:
        ans[i] = 1

ans = [i for i, j in ans.items() if j==ma]
ans.sort()
for i in ans:
    print(i)

Submission status: Wrong Answer

Solution code:
n = int(input())
s = {}

for i in range(n):
    ss = input()

    if ss in s:
        s[ss] += 1
    else:
        s[ss] = 1

s2 = sorted(s.items(), key=lambda x:x[1])

s2.reverse()

max_value = s2[0][1]
ret = []

for sss in s2:
    if sss[1] == max_value:
        ret.append(sss[0])
    else:
        break

ret2 = sorted(ret)
print(ret2)

Submission status: Wrong Answer

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

ans = sorted(dic.items(), key=lambda x:x[1])

check = ans[-1][1]

for i in range(len(ans)-1,-1,-1):
    if ans[i][1] == check:
        print(ans[i][0])

Submission status: Wrong Answer

Solution code:
import collections
import itertools

n = int(input())
s = [0] * n
for i in range(n):
    s[i] = input()
s = sorted(s)
c = collections.Counter(s)
cc = c.most_common()

num = cc[0][1]
for i in cc:
    if i[1] == num:
        print(i[0])

Submission status: Wrong Answer

Solution code:
import collections

n = int(input())


d = collections.defaultdict(lambda:0)

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

d = dict(d)

a = collections.Counter(d)

most = 0

for k, v in a.items():
    if most <= v:
        most = v
        print(k)
    else:
        break

Submission status: Wrong Answer

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


def solve(N: int, S: "List[str]"):
    counter = dict(Counter(S).most_common())
    prev_value = None
    answer_list = []
    for key,value in counter.items():
        if prev_value == None or prev_value == value:
            answer_list.append(key)
            prev_value = value
        else:
            break
    
    answer_list = list(set(answer_list))
    answer_list.sort()

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

    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    S = [next(tokens) for _ in range(N)]  # type: "List[str]"
    solve(N, S)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
S = [input() for i in range(N)]
S.sort()
c = Counter(S)
m = 0
for word,num in c.items():
    m = max(m, num)
for word, num in c.items():
    if num == m:
        print(word)

Submission status: Wrong Answer

Solution code:
n=int(input())
l=[input() for i in range(n)]
from collections import Counter as co
k=co(l).most_common()
d=k[0][1]
for a,s in k:
  if s!=d:break
  else:
      print(a)

Submission status: Wrong Answer

Solution code:
N = int(input())
d = {}
for _ in range(N):
  s = input()
  if not s in d:
    d[s] = 1
  else:
    d[s] += 1
x = sorted(list(d.items()), key=lambda x:x[1], reverse=True)
n = 0
for k, v in x:
  if v >= n:
    n = v
    print(k)

Submission status: Wrong Answer

Solution code:
def main():
    N = int(input())
    strings = {}
    for _ in range(N):
        s = input()
        if s in strings.keys():
            strings[s] += 1
        else:
            strings[s] = 1
    strings = sorted(strings.items(), key=lambda x: x[0], reverse=True)
    maximum = strings[0][1]
    answer = []
    for s in strings:
        if s[1] == maximum:
            answer.append(s[0])
    answer.sort()
    for ans in answer:
        print(ans)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
n = int(input())
l = [input() for _ in range(n)]
d = {}
for w in l:
  d[w] = d.get(w,0)+1
m = max(d.values())
lt = sorted(d.items(),key=lambda k:-k[1])
ans = sorted([k for k,v in lt if v==m])
print(ans,sep='\n')

Submission status: Wrong Answer

Solution code:
n=int(input())
d={}
for i in range(n):
    s=input()
    try:
        if d[s]==1:
            d[s]+=1
    except:
        d[s]=1
l=[]
maxi=-1
for i in d:
    if d[i]>maxi:
        maxi=d[i]
for i in d:
    if d[i]==maxi:
        l.append(i)
l.sort()
for i in l:
    print(i)

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10 ** 6)
MOD = 10**9+7
 

def input():
    return sys.stdin.readline()[:-1]
 

def main():
    n = int(input())
    d = dict()
    for _ in range(n):
        s = input()
        d.setdefault(s, 0)
        d[s] += 1
    d = sorted(d.items(), key=lambda x: -x[1])
    maxc = d[0][1]
    for row in d:
        if row[1]<maxc:
            break
        print(row[0])
 
if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
n = int(input())
s = {}

for i in range(n):
    ss = input()

    if ss in s:
        s[ss] += 1
    else:
        s[ss] = 1

s2 = sorted(s.items(), key=lambda x:x[1])

s2.reverse()

max_value = s2[0][1]

for sss in s2:
    if sss[1] == max_value:
        print(sss[0])
    else:
        break

Submission status: Wrong Answer

Solution code:
N = int(input())
S = [0]*N
for i in range(N):
    S[i] = input()
A = {}
for s in S:
    if s not in A:
        A[s] = 1
    else:
        A[s] += 1

B = [(a, A[a]) for a in A]
# print(B)
B.sort(reverse=True, key=lambda x: x[1])
# print(B)
count = B[0][1]
for b in B:
    if b[1] == count:
        print(b[0])

Submission status: Wrong Answer

Solution code:
N = int(input())
S = ['0'] * N
for i in range(N):
    S[i] = input()
import collections
c = collections.Counter(S)
li = list(c.values())
ca = list(c.keys())
li.sort()
max = li[-1]
for i in ca:
    if c[i] == max:
        print(i)

Submission status: Wrong Answer

Solution code:
N = int(input())
d = {}
for _ in range(N):
    s = input()
    if s not in d:
        d[s] = 0
    d[s] += 1

n = d[max(d)]

res = []

for k, v in d.items():
    if v == n:
        res.append(k)

res.sort()

for s in res:
    print(s)

Submission status: Wrong Answer

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

from collections import Counter

cnt_s = Counter(S)

t = max(cnt_s.values())
kv=cnt_s.items()
for k,v in kv:
    if v==t:
        print(k)

Submission status: Wrong Answer

Solution code:
from collections import Counter
c = Counter()
n = int(input())
for _ in range(n):
    c[input()] += 1

_, m = c.most_common(1)[0]

for x, y in c.most_common():
    if y == m:
        print(x)
    else:
        break

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
n=int(input())
s=[input().strip() for _ in range(n)]
from collections import Counter
s=Counter(s).most_common()
a=s[0][1]
for w,k in s:
    if k==a:
        print(w)

Submission status: Wrong Answer

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

from collections import Counter

cnt_s = Counter(S)

t = max(cnt_s.values())

for k,v in cnt_s.items():
    if v==t:
        print(k)

Submission status: Wrong Answer

Solution code:
N = int(input())
d = {}
for _ in range(N):
  s = input()
  if not s in d:
    d[s] = 1
  else:
    d[s] += 1
x = sorted(list(d.items()), key=lambda x:x[1])
n = 0
for k, v in x:
  if v >= n:
    n = v
    print(k)

Submission status: Wrong Answer

Solution code:
def main():
    N = int(input())
    S = [input() for i in range(N)]
    from collections import Counter
    c = Counter(S)
    cnt = c.most_common()[0][1]
    for s in c.most_common():
        # print(s)
        if s[1] == cnt:
            print(s[0])


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
# ABC155c


def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**6)
    # 再帰関数を使わない限りPypyで出すこと

    n = int(input())
    s = [input()[:-1] for _ in range(n)]
    from collections import Counter
    ma = 0
    ans = []
    for st, cou in Counter(s).most_common():
        ma = max(ma, cou)
        if cou == ma:
            ans.append(st)
        else:
            exit(0)
    ans.sort()
    print(*ans, sep='\n')


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
from collections import Counter

N = int(input())
Ss = Counter([input().rstrip() for _ in range(N)])
m = max(Ss.values())
for k, v in Ss.items():
    if v == m:
        print(k)

Submission status: Wrong Answer

Solution code:
N = int(input())
D = {}
for i in range(N):
  S = input()
  if S in D:
    D[S] += 1
  else:
    D[S] = 1
M = max(D)
L = []
for i in D:
  if D[i] == M:
    L.append(i)
L.sort()
for i in range(len(L)):
  print(L[i])

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
s = list(input() for _ in range(n))
ss = sorted(list(set(s)))
lens = len(ss)
l = [0]*lens
for i in range(n):
        l[ss.index(s[i])] += 1
for i in range(lens):
    if l[i] == max(l):
        print(ss[i])

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
s = list(input() for _ in range(n))
ss = sorted(list(set(s)))
lens = len(ss)
l = [0]*lens
for i in range(lens):
    l[i] = s.count(ss[i])
for i in range(lens):
    if l[i] == max(l):
        print(ss[i])

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
s = list(input() for _ in range(n))
ss = sorted(list(set(s)))
lens = len(ss)
l = [0]*len(ss)
for i in range(lens):
    l[i] =s.count(ss[i])
for i in range(lens):
    if l[i] == max(l):
        print(ss[i])

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

count = []
s_set = list(set(s))
max_count = 0

for i in range(len(s_set)):
    co = s.count(s_set[i])
    count.append(co)
    if co > max_count:
        max_count = co

ans = []
for i in range(len(count)):
    if max_count==count[i]:
        ans.append(s_set[i])

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

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

d = {}
ans = []

for i in range(N):
    S = input()
    d.setdefault(S,0)
    d[S] += 1

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

for word in ans:
    print(word)

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
s=[]
for _ in range(n):
    s.append(input())
ans=[]
cnt=0
for str in set(s):
    cnt_tmp=s.count(str)
    if cnt==cnt_tmp:
        ans.append(str)
    if cnt<cnt_tmp:
        ans=[str]
        cnt=cnt_tmp
ans.sort()
for i in range(len(ans)):
    print(ans[i])

Submission status: Time Limit Exceeded

Solution code:
from collections import OrderedDict 
n=int(input())
d={}
for i in range(n):
    s=str(input())
    if(s not in d):
        d[s]=1
    else:
        d[s]=d[s]+1
d = OrderedDict(sorted(d.items()))
for j,k in d.items():
    if (k==max(d.values())):
        print(j)

Submission status: Time Limit Exceeded

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

from collections import Counter
c=Counter(l)
d=dict(c.most_common())

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

for v in max_k_list:
  print(v)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
d = {}
for i in range(0,n):
  c = input()
  if c in d:
    d[c] +=1
  else:
    d[c] = 1
max_k_list = sorted([kv[0] for kv in d.items() if kv[1] == max(d.values())])
for i in max_k_list:
  print(i)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
d = {}
for i in range(0,n):
  c = input()
  if c in d:
    d[c] +=1
  else:
    d[c] = 1
max_k_list = [kv[0] for kv in d.items() if kv[1] == max(d.values())]
max_k_list.sort()
for i in range(0,len(max_k_list)):
  print(max_k_list[i])

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
dic, rst = {}, []
for i in range(N):
    s = input()
    if s in dic:
        dic[s] += 1
    else:
        dic[s] = 1
rst = [ key for key, val in dic.items() if val == max(dic.values()) ]
[ print(i) for i in sorted(rst) ]

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

dct = {}

lst = [input() for _ in range(N)]

for i in range(N):
    if not lst[i] in dct:
        dct[lst[i]] = 1

    else:
        dct[lst[i]] +=  1
    
ans = []
for key in dct.keys():
    if dct[key] == max(dct.values()):
        ans.append(key)

for j in sorted(ans):
    print(j)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

dct = {}

for i in range(N):
    s = input()
    if not s in dct:
        dct[s] = 1

    else:
        dct[s] +=  1
    
ans = []
for key in dct.keys():
    if dct[key] == max(dct.values()):
        ans.append(key)

for j in sorted(ans):
    print(j)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

dct = {}

for i in range(N):
    s = input()
    if not s in dct:
        dct[s] = 1

    else:
        dct[s] +=  1
    
ans = [x[0] for x in dct.items() if x[1] == max(dct.values())]
for j in sorted(ans):
    print(j)

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
A=[]
for i in range(n):
    a=str(input())
    A.append(a)
import collections
c = collections.Counter(A)
C=[i[0] for i in c.items() if i[1] >= c.most_common()[0][1]]
C.sort(reverse=False)
for j in range(len(C)):
    print(C[j])

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
s=[]
for i in range(n):
    a=input()
    s.append(a)
d={}
t=0
for i in range(n):
    if s[i] not in d:
        d[s[i]]=1
        if t==0:
            t=1
    else:
        d[s[i]]+=1
        if t<d[s[i]]:
            t=d[s[i]]
b=[]
for i in range(n):
    if d[s[i]]==t and (s[i] not in b):
        b.append(s[i])
b.sort()
for i in range(len(b)):
    print(b[i])

Submission status: Time Limit Exceeded

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

import collections
c = collections.Counter(s)
ans = []
word,count = c.most_common()[0]
ans.append(word)
for i in range(1,len(c)):
    wordi,counti = c.most_common()[i]
    if counti == count:
        ans.append(wordi)
    else:
        break
ans.sort()
print(*ans, sep = "\n")

Submission status: Time Limit Exceeded

Solution code:
from collections import defaultdict

d = defaultdict(int)
for _ in range(int(input())):
    d[input()] += 1
print('\n'.join(sorted([k for k in d.keys() if d[k] == max(d.values())])))

Submission status: Time Limit Exceeded

Solution code:
N=int(input())
Slist=[]
for _ in range(N):
    Slist.append(input())
maxi=0
anslist=[]
for strings in Slist:
    if Slist.count(strings)>maxi:
        maxi=Slist.count(strings)
        if not strings in anslist:
            anslist=[strings]
    elif Slist.count(strings)==maxi:
        if not strings in anslist:
            anslist.append(strings)
for string in sorted(anslist):
    print(string)

Submission status: Time Limit Exceeded

Solution code:
import math
import statistics
a=int(input())
#b,c=int(input()),int(input())
# c=[]
# for i in b:
#     c.append(i)
#e1,e2 = map(int,input().split())
# f = list(map(int,input().split()))
j = [input() for _ in range(a)]
# h = []
# for i in range(e1):
#     h.append(list(map(int,input().split())))
s=set(j)
s2=list(s)
s2.sort()
an = []
for i in s2:
    an.append(j.count(i))
s4=[i for i, v in enumerate(an) if v == max(an)]
for i in s4:
    print(s2[i])

Submission status: Time Limit Exceeded

Solution code:
import math
import statistics
a=int(input())
#b,c=int(input()),int(input())
# c=[]
# for i in b:
#     c.append(i)
#e1,e2 = map(int,input().split())
# f = list(map(int,input().split()))
j = [input() for _ in range(a)]
# h = []
# for i in range(e1):
#     h.append(list(map(int,input().split())))
s=set(j)
s2=list(s)
s3=sorted(s2)
an = []
for i in s3:
    an.append(j.count(i))
s4=[i for i, v in enumerate(an) if v == max(an)]
for i in s4:
    print(s3[i])

Submission status: Time Limit Exceeded

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

c = collections.Counter(s)

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

e = sorted(D)

for i in e:
    print(i)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
L = []
res = []

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

max_cnt = 0
cnt = 0

L.append(0)

for i in range(len(L) - 1):
    if L[i] == L[i+1]:
        cnt += 1
    else:
        if cnt > max_cnt:
            max_cnt = cnt
            res = []
            res.append(L[i])
        elif cnt == max_cnt:
            res.append(L[i])
        cnt = 0

for i in res:
    print(i)

Submission status: Time Limit Exceeded

Solution code:
import collections

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

S_C=collections.Counter(S).most_common()

keys,values=zip(*S_C)
ans=[]
for i in range(len(values)):
	if values[i]==max(values):
		ans.append(keys[i])

ans=sorted(ans)

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

Submission status: Time Limit Exceeded

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

T = list(set(S))
t = 1
U = []
for i in range(len(T)):
    x = S.count(T[i])
    if t < x:
        t = x
        U = [T[i]]
    elif t == x:
        U.append(T[i])

U_ = list(sorted(U))
for i in range(len(U_)):
    print(U_[i])

Submission status: Time Limit Exceeded

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

T = list(set(S))
t = 1
U = []
for i in range(len(T)):
    x = S.count(T[i])
    if t < x:
        t = x
        U = [T[i]]
    elif t == x:
        U.append(T[i])

U_ = list(sorted(U))
for i in range(len(U_)):
    print(U_[i])

Submission status: Time Limit Exceeded

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

T = list(set(S))
t = 1
U = []
for i in range(len(T)):
    if t < S.count(T[i]):
        t = S.count(T[i])
        U = [T[i]]
    elif t == S.count(T[i]):
        U.append(T[i])

U_ = list(sorted(U))
for i in range(len(U_)):
    print(U_[i])

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
A1 = {}
A2 = []
for i in range(N):
  s = input()
  if s not in A2:
    A1[s] = 1
    A2.append(s)
  else:
    A1[s] += 1
sai = max(A1.values())
A2.sort()
for j in A2:
  if A1[j] == sai:
    print(j)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
name = []
ans = []
ma = 1

for i in range(N):
    S = str(input())
    if S not in name:
        name.append(S)
        ans.append((S, 1))
    else:
        n, cnt = ans[name.index(S)]
        cnt += 1
        if ma < cnt:
            ma = cnt
        ans[name.index(S)] = (n, cnt)

ans = sorted(ans)
for j in range(len(ans)):
    S, cnt = ans[j]
    if cnt == ma:
        print(S)

Submission status: Time Limit Exceeded

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

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

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

ans = sorted(ans)
for x in range(len(ans)):
    print(ans[x])

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
con = 0
con2 = 0
c = 1
A1 = []
win = []
for a in range(1,N+1):
  b = str(input())
  A1.append(b)
A2 = list(set(A1))
A1.sort()
A2.sort()
for i in range(len(A2)):
  for j in range(len(A1)):
    if A2[i] == A1[j]:
      con += 1
  if con2 == con:
    win.append(A2[i])
  if con2 < con:
    con2 = con
    win = []
    c = A2[i]
    win.append(c)
  con = 0
win.sort()
for k in range(len(win)):
  print(win[k])

Submission status: Time Limit Exceeded

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

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


x = [ i[0] for i in dic.items() if i[1] == max(dic.values())]

x.sort()

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

Submission status: Time Limit Exceeded

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

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


x = [ i[0] for i in dic.items() if i[1] == max(dic.values())]
x.sort()
for i in range(len(x)):
  print(x[i])

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
d={}
a=[]
for i in range(n):
  s=input()
  if s not in a:
    a.append(s)
  if s not in d:
    d[s]=1
  else:
    d[s]+=1
a.sort()
m=max(d.values())
for i in a:
  if d[i]==m:
    print(i)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
S = ['']*n
T = []
for i in range(n):
    S[i] = input()
mxcnt = 0
for s in S:
    mxcnt = max(mxcnt,S.count(s))
for s in S:
    if S.count(s) == mxcnt and s not in T:
        T.append(s)
T.sort()
for t in T:
    print(t)

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

Solution code:
n = int(input())  # nは入力回数
string_list = [input() for _ in range(n)]
set_list = list(sorted(set(string_list)))
num_list = [string_list.count(set_list[i]) for i in range(len(set_list))]

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

Submission status: Time Limit Exceeded

Solution code:
n = int(input())  # nは入力回数
string_list = [input() for _ in range(n)]
set_list = list(sorted(set(string_list)))
num_list = [string_list.count(set_list[i]) for i in range(len(set_list))]
# num_list = []

# for i in range(len(set_list)):
#     num_list.append(string_list.count(set_list[i]))

for i in range(len(num_list)):
    if num_list[i] == max(num_list):
        print(set_list[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 = list(c.items())
b = list(c.values())

list1 =sorted( [kv[0] for kv in a if kv[1] == max(b)])
for i in range(len(list1)):
  print(list1[i])