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=[input() for _ in range(n)]
S_set = set(S)
cnt={}

for s in S_set:
    cnt[s] = S.count(s)

m=max(cnt.values())
L=[]

for a in cnt.keys():
    if cnt[a] == m:
        L.append(a)
L.sort()
for i in range(len(L)):
    print(L[i])

Submission status: Time Limit Exceeded

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

from collections import defaultdict
d = defaultdict(int)
    
for _ in range(n):
    d[input()] += 1

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

for l in li:
    print(l)

Submission status: Time Limit Exceeded

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

# print(S)

import collections

c = collections.Counter(S)

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

ls_ans = []
ls_ans.append( c.most_common()[0][0] )

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

ans = sorted(ls_ans)

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

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

Ss = [None for _ in range(N)]

dic = dict()

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

for s in Ss:
  if s in dic:
    dic[s] += 1
  else:
    dic[s] = 1

# dic = sorted(dic.items(), key=lambda x:x[0])

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

max_list.sort()

for lis in max_list:
  print(lis)

Submission status: Time Limit Exceeded

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

cnt=Counter(S)
maxcnt=cnt.most_common()[0][1]
ans=[]
for i in range(len(cnt)):
  if cnt.most_common()[i][1]==maxcnt:
    ans.append(cnt.most_common()[i][0])
  else:
    break
ans.sort()
print(*ans,sep='\n')

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
s_list = []
for _ in range(n):
    s_list.append(input())
s_list.sort()
dic = sorted(set(s_list), key=s_list.index)
max_count=0
ans = []
for d in dic:
    coun = s_list.count(d)
    if max_count < coun:
        ans = [d]
        max_count = coun
    elif max_count == coun:
        ans.append(d)
    else:
        pass


for a in ans:
    print(a)

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
l=[input() for _ in range(n)]
sl = set(l)
m = 0

for s in sl:
  if m <= l.count(s):
    m = l.count(s)
    
ans = []
    
for s in sl:
  if m == l.count(s):
    ans.append(s)
    
ans = sorted(ans)

for a in ans:
  print(a)

Submission status: Time Limit Exceeded

Solution code:
import sys
# import math
# import decimal
# import queue
# import bisect
# import heapq
import time
# import itertools

mod = int(1e9+7)
INF = 1<<29

def main():
    n = int(input())
    m = {}
    for i in range(n):
        s = input()
        if s in m.keys():
            m[s] += 1
        else:
            m[s] = 1
    l = []
    for k in m.keys():
        l.append([-1 * m[k],k])
    l.sort()
    ans = l[0][0]
    for i in range(len(l)):
        if l[i][0] == ans:
            print(l[i][1])
        else:
            break
    return

if __name__=='__main__':
    main()

Submission status: Time Limit Exceeded

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

S_unique = set(S)

a = {}
for s in S_unique:
    a[s] = S.count(s)    


maxval = max(a.values())

anss = []
for s in a:
    if a[s] == maxval:
        anss.append(s)

anss = sorted(anss)

for a in anss:
    print(a)

Submission status: Time Limit Exceeded

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

d = {}

for w in w_l:
    if d.get(w, 0) == 0:
        d[w] = 1
    else:
        d[w] += 1

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

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

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-
my_dict = dict()
n = int(input())
for i in range(n):
    my_input = input()
    if my_input in my_dict:
        my_dict[my_input] = my_dict[my_input] + 1
    else:
        my_dict[my_input] = 1

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

max_k_list.sort()

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

Submission status: Time Limit Exceeded

Solution code:
#import numpy as np
from sys import stdin
from copy import deepcopy
from functools import reduce
from fractions import gcd
import math
import itertools
from collections import Counter
from itertools import chain  ##list(chain.from_iterable(l)) ##flatten
from heapq import heappush, heappop
import bisect

"""
N = int(input())
A, B = map(int,input().split())
A = list(map(int,input().split())) ## 横一列
A = [int(input()) for _ in range(N)] ## 縦一列
lst = [list(map(int,input().split())) for i in range(M)] ## 二次元
"""

N = int(input())
S = [input() for _ in range(N)] ## 縦一列


cnt = list(Counter(S).items())
cnt = sorted(cnt, key=lambda x: (-x[1], x[0]))

max_cnt = cnt[0][1]
for i in range(len(cnt)):
  if cnt[i][1] == max_cnt:
    print(cnt[i][0])
  else:
    exit()

Submission status: Time Limit Exceeded

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

M = max([S.count(s) for s in set(S)])

R = [s for s in set(S) if S.count(s)==M]
R.sort()

for r in R:
    print(r)

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

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

dic = defaultdict(int)

for x in S:
	dic[x] += 1

ma = max(dic.values())

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

for i in max_k_list:
	print(i)

Submission status: Time Limit Exceeded

Solution code:
from collections import defaultdict
n = int(input())

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

max_k_list = [kv[0] for kv in d.items() if kv[1] == max(d.values())]
#print(max_k_list)
# ['a', 'd']

max_k_list.sort()
for v in max_k_list:
    print(v)

Submission status: Time Limit Exceeded

Solution code:
n=int(raw_input())
a=[0]*n
for i in range(n):
    a[i]=str(raw_input())
s=set(a)
ans=[-1]
m=0
for i in s:
    if(a.count(i)==m):
        m=a.count(i)
        ans.append(i)
    elif(a.count(i)>m):
        m=a.count(i)
        ans.pop()
        ans.append(i)
ans.sort()
for i in ans:
    print i

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
s=[input() for i in [0]*n]
k=list(set(s))
p=[]
q=0
for i in k:
    r=s.count(i)
    if r>q:
        p=[i]
    if r==q:
        p+=[i]
    if r>=q:
        q=r
p.sort()
for i in p:
    print(i)

Submission status: Time Limit Exceeded

Solution code:
# coding: utf-8
import re
import math
import itertools
from copy import deepcopy
import fractions
import random
from functools import lru_cache
from heapq import heappop,heappush
import time
import sys
readline = sys.stdin.readline
sys.setrecursionlimit(2000)
#import numpy as np
alphabet="abcdefghijklmnopqrstuvwxyz"
mod=int(10**9+7)
inf=int(10**20)
def yn(b):
    if b:
        print("yes")
    else:
        print("no")
def Yn(b):
    if b:
        print("Yes")
    else:
        print("No")
def YN(b):
    if b:
        print("YES")
    else:
        print("NO")
class union_find():
    def __init__(self,n):
        self.n=n
        self.P=[a for a in range(N)]
        self.rank=[0]*n
 
    def find(self,x):
        if(x!=self.P[x]):self.P[x]=self.find(self.P[x])
        return self.P[x]
 
    def same(self,x,y):
        return self.find(x)==self.find(y)
 
    def link(self,x,y):
        if self.rank[x]<self.rank[y]:
            self.P[x]=y
        elif self.rank[y]<self.rank[x]:
            self.P[y]=x
        else:
            self.P[x]=y
            self.rank[y]+=1
 
    def unite(self,x,y):
        self.link(self.find(x),self.find(y))
 
    def size(self):
        S=set()
        for a in range(self.n):
            S.add(self.find(a))
        return len(S)
def bin_(num,size):
    A=[0]*size
    for a in range(size):
        if (num>>(size-a-1))&1==1:
            A[a]=1
        else:
            A[a]=0
    return A
def fac_list(n,mod_=0):
    A=[1]*(n+1)
    for a in range(2,len(A)):
        A[a]=A[a-1]*a
        if(mod>0):A[a]%=mod_
    return A
def comb(n,r,mod,fac):
    if(n-r<0):return 0
    return (fac[n]*pow(fac[n-r],mod-2,mod)*pow(fac[r],mod-2,mod))%mod
def next_comb(num,size):
    x=num&(-num)
    y=num+x
    z=num&(~y)
    z//=x
    z=z>>1
    num=(y|z)
    if(num>=(1<<size)):return False
    else:
        return num
def get_primes(n,type="int"):
    A=[True]*(n+1)
    A[0]=False
    A[1]=False
    for a in range(2,n+1):
        if A[a]:
            for b in range(a*2,n+1,a):
                A[b]=False
    if(type=="bool"):return A
    B=[]
    for a in range(n+1):
        if(A[a]):B.append(a)
    return B
def is_prime(num):
    if(num<=2):return False
    i=2
    while i*i<=num:
       if(num%i==0):return False
       i+=1
    return True
def join(A,c=" "):
    n=len(A)
    A=list(map(str,A))
    s=""
    for a in range(n):
        s+=A[a]
        if(a<n-1):s+=c
    return s

#main
n=int(input())
#A,B,C=map(int,input().split())
S=[]
C={}
for a in range(n):
    s=input()
    if not s in C:
        C[s]=1
    else:
        C[s]+=1
A=[]
for a,b in C.items():
    A.append([b,a])
A.sort(key=lambda x:(-x[0],x[1]))
max_=A[0][0]
for a in A:
    if(a[0]!=max_):break
    print(a[1])

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

saidai = 0
nakami = []
kaisu = []

for i in range(N):
    S = input()
    mita = False
    for j in range( len(nakami) ):
        if nakami[j]==S:
            mita = True
            break
    if mita:
        kaisu[j] = kaisu[j] +1
    else:
        nakami.append(S)
        kaisu.append(1)

for i in range(len(nakami)):
    if kaisu[i]>saidai:
        saidai = kaisu[i]

nakamisaidai= []
for i in range(len(nakami)):
    if kaisu[i]==saidai:
        nakamisaidai.append(nakami[i])

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

Submission status: Time Limit Exceeded

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

count = dict()
for x in S:
    count[x] = count.get(x, 0) + 1

sorted_kv = list(sorted(count.items(), key=lambda x: (-x[1], x[0])))
max_val = sorted_kv[0][1]

res = []
for k, v in sorted_kv:
    if v == max_val:
        print(k)
    else:
        break

Submission status: Time Limit Exceeded

Solution code:
from collections import Counter

def s_in():
    return input()

def n_in():
    return int(input())

def l_in():
    return list(map(int, input().split()))

class Interval():
    def __init__(self, li):
        self.li = li
        self.n = len(li)
        self.sum_li = [li[0]]
        for i in range(1, self.n):
            self.sum_li.append(self.sum_li[i-1] + li[i])

    def sum(self, a, b=None):
        if b is None:
            return self.sum(0, a)

        res = self.sum_li[min(self.n-1, b-1)]
        if a > 0:
            res -= self.sum_li[a-1]
        return res


N = n_in()
S = []
counter = Counter()

for i in range(N):
    counter[s_in()] += 1


for s in sorted((map(lambda a: a[0], filter(lambda a: a[1] == counter.most_common()[0][1],  counter.most_common())))):
    print(s)

Submission status: Time Limit Exceeded

Solution code:
#import sys
MOD = 10 ** 9 + 7
INFI = 10**10
#input = sys.stdin.readline
import math

import itertools

#import bisect

import copy
from functools import lru_cache

def sosuhante(n):
    for k in range(2, int(math.sqrt(n))+1):
        if n% k ==0:
            return False
    return True
def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

def kingaku(a,b,n):
    keta=len(str(n))
    return a*n+b*keta

def my_index(l, x, default=False):
    if x in l:
        return l.index(x)
    else:
        return default

#    h,w,a,b = map(int, input().split())
#    c = [[0 for j in range(n)] for i in range(n)]



def main():
    n=int(input())
    s=[]
    sn=[0 for i in range(n)]
    for i in range(n):
        a=input()
        if a in s:
            sn[s.index(a)]+=1
        else:
            s.append(a)
    maxn=max(sn)
    ans=[]
    for i in range(n):
        if sn[i]==maxn:
            ans.append(s[i])
    ans=sorted(ans)

    for i in ans:
        print(i)



if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

Solution code:

N = int(input())
#N,K = map(int, input().split())
dct = {}
for z in range(N):
    x = input()
    if x in dct.keys():
        dct[x] += 1
    else:
        dct[x] = 1
mx = dct[max(dct, key=dct.get)]
ans = []
for key in dct.keys():
    if dct[key] == mx:
        ans.append(key)
ans.sort()
for elem in ans:
    print(elem)

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

ans=0
ans_s=[]
for s in S_:
    x=S.count(s)
    if ans<x:
        ans=x
        ans_s=[s]
    elif ans==x:
        ans_s.append(s)

ans_s.sort()

for a in ans_s:
    print(a)

Submission status: Time Limit Exceeded

Solution code:
from collections import Counter
N = int(input())
S_lis = []
for n in range(N):
    S = input()
    S_lis.append(S)

ans_lis = []
for key, value in Counter(S_lis).items():
    if value == max(Counter(S_lis).values()):
        ans_lis.append(key)
for item in sorted(ans_lis):
    print(item)

Submission status: Time Limit Exceeded

Solution code:
from collections import defaultdict
d = defaultdict(int)
N = int(input())
for i in range(N):
    d[input()] += 1
ans = [kv[0] for kv in d.items() if kv[1] == max(d.values())]
ans.sort()
for s in ans:
    print(s)

Submission status: Time Limit Exceeded

Solution code:
from collections import defaultdict

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

    ans = [kv[0] for kv in d.items() if kv[1] == max(d.values())]
    ans.sort()
    for a in ans:
        print(a)
    
    



if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
l=[]
for i in range(n):
  l.append(input())
noo=[]
for i in range(n):
  noo.append(l.count(l[i]))
x=max(noo)
res=[]
for i in range(n):
  if noo[i]==x:
    res.append(l[i])
res=set(res)
res=list(res)
res.sort()
for i in res:
  print(i)

Submission status: Accepted

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

m = max(d.values())
l=[]
for i in d:
    if d[i] == m:
        l.append(i)
for i in sorted(l):
    print(i)

Submission status: Accepted

Solution code:
n = int(input())
s = list(input() for _ in range(n))
d = {}
for i in range(n):
    if s[i] in d:
        d[s[i]] += 1
    else:
        d[s[i]] = 1
m = max(d.values())
for s in sorted(k for k in d if d[k] == m):
    print(s)

Submission status: Accepted

Solution code:
N = int(input())

d = {}
for _ in range(N):
    S = input()
    if S in d:
        d[S] += 1
    else:
        d[S] = 1

m = max(d.values())
for s in sorted(k for k in d if d[k] == m):
    print(s)

Submission status: Accepted

Solution code:
import collections
def resolve():
    n = int(input())
    s = [input() for _ in range(n)]
    c = collections.Counter(s)
    max_count = c.most_common()[0][1]
    ans = [i[0] for i in c.items() if i[1]==max_count]
    for i in sorted(ans): print(i)
resolve()

Submission status: Accepted

Solution code:
n = int(input())
d = {}
m = 0
for i in range(n):
    s = input()
    d[s] = d.get(s, 0) + 1
    if m <= d[s]:
        m = d[s]
c = []
for i in d:
    if d[i]==m:
        c.append(i)
c.sort()
for x in c:
    print(x)

Submission status: Accepted

Solution code:
N = int(input())

d = {}
ans = []

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

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

for word in ans:
    print(word)

Submission status: Accepted

Solution code:
n=int(input())
s={}
for i in range(n):
  si = input()
  if si not in s:
    s[si] = 1
  else:
    s[si]+=1
sa = sorted(s.items())
ma = max(s.values())
for a in sorted(a for a in s if s[a]==ma):
  print(a)

Submission status: Accepted

Solution code:
N = int(input())

d = {}

for i in range(N):
  key = input()
  try:
    d[key] += 1
  except KeyError:
    d[key] = 1
    
d = sorted(d.items(), key=lambda x: x[1], reverse=True)

ans = []
max = 0
for i in d:
  if i[1] >= max:
    ans.append(i[0])
    max = i[1]
  else:
    break
    
for i in sorted(ans):
  print(i)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import collections

n = int(input())

li=[]


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

cnt = collections.Counter(li)
S = cnt.most_common()


C =len(cnt)

li_1 = [S[0][0]]

for i in range(C-1):
    if S[i][1] == S[i+1][1]:
        li_1.append(S[i+1][0])
    else:
        break

li_1.sort()

for i in li_1:
    print(i)

Submission status: Accepted

Solution code:
q=int(input())
dic={}
for i in range(q):
    s=input()
    if not s in dic:
        dic[s]=1
    else:
        dic[s]+=1
max_val=max(dic.values())
a=sorted([i for i, k in dic.items() if k == max_val])
for i in a:
    print(i)

Submission status: Accepted

Solution code:
from collections import defaultdict

n = int(input())
max_ = 0
dd = defaultdict(int)
for _ in range(n):
  s = input()
  dd[s] += 1
  max_ = max(max_, dd[s])
ans = []
for key, value in dd.items():
  if value == max_:
    ans.append(key)
ans.sort()
print(*ans, sep = "\n")

Submission status: Accepted

Solution code:
# coding: utf-8
from collections import defaultdict


def main():
    N = int(input())
    dic = defaultdict(int)
    max_p = 0

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

    d = dict(dic)
    l = []

    for key, value in d.items():
        l.append([key, value])
        if max_p < value: max_p = value
    
    l.sort(key=lambda x: (-x[1], x[0]), reverse=False)

    for i, j in l:
        if j == max_p:
            print(i)
        else:
            break


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
from collections import defaultdict
n = int(input())
dic = defaultdict(int)
for i in range(n):
    dic[input()] += 1
tmp = [(key, value) for key, value in dic.items()]
tmp.sort(key=lambda x: (x[1], x[0]))
m = tmp[-1][1]
for i in range(len(dic)):
    if tmp[i][1] == m:
        print (tmp[i][0])

Submission status: Accepted

Solution code:
from collections import Counter
n=int(input())
s=Counter([input()for _ in[0]*n])
m=s.most_common(1)[0][1]
r=sorted((k for k,v in s.items() if v==m))
for a in r:print(a)

Submission status: Accepted

Solution code:
n = int(input())
L = list(input() for _ in range(n))
D = dict.fromkeys(set(L),0)

for l in L:
  D[l] += 1

m = max(D.values())
SD = sorted(D.items(), key=lambda x:x[0])

for k, v in SD:
  if v == m:
    print(k)

Submission status: Accepted

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

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

max_val = max(d.values())
keys_of_max_val = [key for key in d if d[key] == max_val]
print("\n".join(sorted(keys_of_max_val)))

Submission status: Accepted

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

from collections import Counter

cnt=Counter(S)
max_cnt=cnt.most_common()[0][1]
ans=[name for name, cnt in cnt.items() if cnt==max_cnt]
print(*sorted(ans), sep="\n")

Submission status: Accepted

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

from collections import Counter

cnt=Counter(S)
max_cnt=cnt.most_common()[0][1]
ans=[]
for k, v in cnt.items():
	if v!=max_cnt:
		continue
	ans.append(k)
print(*sorted(ans), sep="\n")

Submission status: Accepted

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

from collections import Counter

cnt=Counter(S)
max_cnt=cnt.most_common()[0][1]
ans=[]
for k, v in cnt.items():
	if v!=max_cnt:
		continue
	ans.append(k)

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

Submission status: Accepted

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
max_val = max(dic.values())
rst = [ key for key, val in dic.items() if val == max_val ]
[ print(i) for i in sorted(rst) ]

Submission status: Accepted

Solution code:
n = int(input())
s = [input() for i in range(n)]
dic = {}
for i in range(n):
    if s[i] in dic.keys():
        dic[s[i]] += 1
    else:
        dic[s[i]] = 1
max1 = max(dic.values())
ans = []
for keys in dic.keys():
    if dic[keys] == max1:
        ans.append(keys)
ans.sort()
for i in ans:
    print(i)

Submission status: Accepted

Solution code:
n=int(input())
dic={}
for i in range(n):
    s=input()
    if not s in dic:
        dic[s]=1
    else:
        dic[s]+=1
max_val=max(dic.values())
a=sorted([i for i, k in dic.items() if k == max_val])
for i in a:
    print(i)

Submission status: Accepted

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

d = {}
for s in s_l:
    try:
        d[s] += 1
    except:
        d[s] = 1

max_c = max([ v for _,v in d.items() ])
ans = [ i for i, v in d.items() if v == max_c ]

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
d = {}
for i in range(n):
    s = input()
    if s in d:
        d[s] += 1
    else:
        d[s] = 1
mx = max(d.values())
ans = ['']
for k, v in d.items():
    if v == mx:
        ans.append(k)
ans.sort()
print(*ans, sep='\n')

Submission status: Accepted

Solution code:
import collections
N=int(input())
s=[str(input()) for i in range(N)]
c=collections.Counter(s)
maximum =max(c.values()) 
max_c_list = sorted(key for key,value in c.items() if value == maximum)
for s in max_c_list:
  print(s)

Submission status: Accepted

Solution code:

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    from collections import defaultdict
    dd = defaultdict(int)
    
    N=I()
    M=0
    for i in range(N):
        s=input()
        dd[s]+=1
        M=max(M,dd[s])
        
        
    ans=[]
    for k,v in dd.items():
        if v==M:
            ans.append(k)
            
    ans.sort()
    for k in ans:
        print(k)
        
    

main()

Submission status: Accepted

Solution code:
n=int(input())

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


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

ma=dic[0][1]
for i,v in dic:
  if v!=ma:
    break
  else:
    print(i)

Submission status: Accepted

Solution code:
from collections import Counter

n = int(input())
s = Counter([str(input()) for _ in range(n)])
l = []
c = 1

for stri, count in s.items():
    if count == c:
        c = count
        l.append(stri)
    elif count > c:
        c = count
        l.clear()
        l.append(stri)


sort_l = sorted(l)

for i in sort_l:
    print(i)

Submission status: Accepted

Solution code:
N=int(input())
d=dict()
for _ in range(N):
    S=input()
    if S not in d:
        d[S]=0
    d[S]+=1
M=max(d.values())
ans=[]
for S in d.keys():
    if d[S]==M:
        ans.append(S)
ans.sort()
for S in ans:
    print(S)

Submission status: Accepted

Solution code:
N = int(input())
S = [input() for i in range(N)]
ans = dict()
for i in range(N):
    if S[i] in ans:
        ans[S[i]] += 1
    else:
        ans[S[i]] = 1
ans = sorted(ans.items(), key=lambda x:x[1] , reverse = True)
i = 0
kotae = []
while i < len(ans) and ans[0][1] == ans[i][1]:
    kotae.append(ans[i][0])
    i += 1
kotae.sort()
for j in kotae:
    print(j)

Submission status: Accepted

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
max_val = max(dic.values())
rst = [ key for key, val in dic.items() if val == max_val ]
[ print(i) for i in sorted(rst) ]

Submission status: Accepted

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
    
m = max(dct.values())
for s in sorted(k for k in dct if dct[k] == m):
    print(s)

Submission status: Accepted

Solution code:
from collections import Counter

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

c = Counter(s)
m = c.most_common()[0][1]
k = list(c.keys())
v = list(c.values())

l = []
for i in range(len(c)):
  if v[i] == m:
    l.append(k[i])

l.sort()
    
print(*l,sep="\n")

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=int(input())
s=[]
for i in range(n):
    s.append(input())
s.sort()
t=1
m=0
a=s[0]
for i in range(n-1):
    if s[i+1]==a:
        t+=1
    else:
        a=s[i+1]
        m=max(t,m)
        t=1
m=max(t,m)
t=1
x=[]
a=s[0]
for i in range(n-1):
    if s[i+1]==a:
        t+=1
    else:
        a=s[i+1]
        if t==m:
            x.append(s[i])
        t=1
if  t==m:
    x.append(s[len(s)-1])
for i in range(len(x)):
    print(x[i])

Submission status: Accepted

Solution code:
# C
from collections import Counter
N = int(input())
S = [input() for _ in range(N)]
countS = Counter(S)
maxS = max(countS.values())
ans = []
for key,value in countS.items():
  if value == maxS:
    ans.append(key)

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

Submission status: Accepted

Solution code:
import collections
n = int(input())
l = []
for i in range(n):
  l.append(input())
c = collections.Counter(l)
m = max(c.values())
chars = [key for key, value in c.items() if value == m]
chars.sort()
for s in chars:
  print(s)

Submission status: Accepted

Solution code:
n = int(input())
s = [input() for _ in range(n)]
ans = []
d = {}
for i in s:
    try: d[i] += 1
    except KeyError: d[i] = 1
mx = 0
for value in d.values():
    if value > mx: mx = value
for key, value in d.items():
    if value == mx:
        ans.append(key)
for v in sorted(ans):
    print(v)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
n = int(input())

dic = {}

for x in range(n):
    a = input()
    dic.setdefault(a,0)
    dic[a] += 1

dic2 = sorted(dic.items(),key=lambda x:x[1],reverse=True)

max_word = [k for k,v in dic2 if v == dic2[0][1] ]

max_word.sort()

for x in max_word:
    print(x)

Submission status: Accepted

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

S = sorted(dic.values())
t = S[-1]

X = []
for key in dic:
    if dic[key] == t:
        X.append(key)
x = sorted(X)

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

Submission status: Accepted

Solution code:
N = int(input())
S = [input() for _ in range(N)]
dic = {}
for i in range(N):
    if S[i] not in dic.keys():
        dic[S[i]] = 1
    else:
        dic[S[i]] += 1

maxI = max(dic.values())
ans = []

for keys in dic.keys():
    if dic[keys] == maxI:
        ans.append(keys)

ans.sort()

for i in ans:
    print(i)