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: Accepted

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

count = Counter(s)
maxNum = max(count.values())
t = sorted(list(set(s)))
for i in t:
  if count[i] == maxNum:
    print(i)

Submission status: Accepted

Solution code:
n = int(input())
d = {}
for _ in range(n):
    s = input()
    d[s] = d.get(s, 0) + 1

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

res = []

for i in range(len(sorted_d)):
    if sorted_d[i][1] == ma:
        res.append(sorted_d[i][0])

res.sort()

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

Submission status: Accepted

Solution code:
from collections import defaultdict

n = int(input())

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

ans = sorted(sorted(d.items()), key=lambda x:x[1], reverse=True)
max_v = ans[0][1]
for s, v in ans:
    if v < max_v:
        break
    print(s)

Submission status: Accepted

Solution code:
n = int(input())
d = dict()

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

tmp = sorted(d.items())
ans = sorted(tmp, key=lambda x:x[1], reverse=True)

max = ans[0][1]
for i in ans:
    if i[1] < max:
        break
    print(i[0])

Submission status: Accepted

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

from collections import Counter

C = Counter(sorted(S))

ans = []
numMax = C.most_common()[0][1]
for key, num in C.most_common():
    if num == numMax:
        ans.append(key)
[print(a) for a in sorted(ans)]

Submission status: Accepted

Solution code:
n = int(input())
li = []
lia = []
ans = 0
f = 1
li.insert(0,"0")
for i in range(n):
    li.append(input())
li.sort()
for i in range(n):
    if li[i] == li[i+1]:
        f += 1
    else:
        f = 1
    if f == ans:
        lia.append(li[i+1])
    if f > ans:
        lia = []
        ans = f
        lia.append(li[i+1])
for i in range(len(lia)):
    print(lia[i])

Submission status: Accepted

Solution code:
from collections import Counter
n = int(input())
s = []
ans = []

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

c = Counter(s)
c_s = c.most_common()
m = c.most_common()[0][1]

for j in range(len(c_s)):
    if c_s[j][1] != m:
        break
    else:
        ans.append(c_s[j][0])

ans.sort()
for t in ans:
    print(t)

Submission status: Accepted

Solution code:
from collections import Counter

n, *s = open(0).read().split()

c = Counter(s)
max_poll = c.most_common()[0][1]
candidates = []
for tpl in c.most_common():
    if tpl[1] == max_poll:
        candidates.append(tpl[0])

candidates.sort()

for candidate in candidates:
    print(candidate)

Submission status: Accepted

Solution code:
from collections import Counter
N = int(input())
L = [str(input()) for i in range(N)]
Lc = Counter(L).most_common()
Llist = []             
L_max = Lc[0][1]       
i = 0
while True:
  Llist.append(Lc[i][0])
  if i<len(Lc)-1 and Lc[i+1][1]==L_max:
    i+=1
  else:
    break
print("\n".join(sorted(Llist)))

Submission status: Accepted

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

from collections import Counter
c = Counter(s).most_common()
l =[c[0][0]]
for i in range(1,len(c)):
    if c[i][1]==c[0][1]:
        l.append(c[i][0])
l = sorted(l)
for j in range(len(l)):
    print(l[j])

Submission status: Accepted

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

most_com = max(S.values())
keys = [k for k,v in S.items() if v == most_com]
keys.sort()

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

Submission status: Accepted

Solution code:
n=int(input())
ss=set()
d=dict()
for ii in range(n):
  s=input()
  if s in ss:
    d[s]+=1
  else:
    ss.add(s)
    d[s]=1
ss=list(ss)
ss.sort()
mx=max(d.values())
for ii in ss:
  if d[ii]==mx:
    print(ii)

Submission status: Accepted

Solution code:
n = int(input())

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



max_s_val = max(s.values())
t = [k for k, v in s.items() if v == max_s_val]
t.sort()

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

Submission status: Accepted

Solution code:
from collections import Counter

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

counter = Counter(s)
count = counter.most_common()
most = count[0][1]

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

c.sort()
print(*c, sep='\n')

Submission status: Accepted

Solution code:
n = int(input())

s_dic = {}

for i in range(n):
    tmp = str(input())
    if tmp not in s_dic:
        s_dic[tmp] = 1
    else:
        s_dic[tmp] += 1

tmp = max(s_dic.values())
max_s_key = [s_value[0] for s_value in s_dic.items() if s_value[1] == tmp]

max_s_key = sorted(max_s_key)

for i in max_s_key:
    print(i)

Submission status: Accepted

Solution code:
n = int(input())

s_dic = {}

for i in range(n):
    tmp = str(input())
    if tmp not in s_dic:
        s_dic[tmp] = 1
    else:
        s_dic[tmp] += 1

max_value = max(s_dic.values())
s_dic = sorted(s_dic.items(), key=lambda x:x[0])

for i in s_dic:
    if i[1] == max_value:
        print(i[0])

Submission status: Accepted

Solution code:
n=int(input())
dict={}
for i in range(0,n):
  temp=str(input())
  if temp in dict:
    dict[temp]=dict[temp]+1
  else:
    dict[temp]=1
temp=max(dict.values())
max_list=[dict[0] for dict in dict.items() if dict[1]==temp] 
max_list.sort()
for i in range(0,len(max_list)):
  print(max_list[i])

Submission status: Accepted

Solution code:
import math
import queue
from collections import defaultdict

def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()
def factorization(n):
	res = []
	if n%2==0:
		res.append(2)
	for i in range(3,math.floor(n//2)+1,2):
		if n%i==0:
			c = 0
			for j in res:
				if i%j==0:
					c=1
			if c==0:
				res.append(i)
	return res
def fact2(n):
	p = factorization(n)
	res = []
	for i in p:
		c=0
		z=n
		while 1:
			if z%i==0:
				c+=1
				z/=i
			else:
				break
		res.append([i,c])
	return res
def fact(n):#階乗
	ans = 1
	m=n
	for _i in range(n-1):
		ans*=m
		m-=1
	return ans
def comb(n,r):#コンビネーション
	if n<r:
		return 0
	l = min(r,n-r)
	m=n
	u=1
	for _i in range(l):
		u*=m
		m-=1
	return u//fact(l)
def combmod(n,r,mod):
	return (fact(n)/fact(n-r)*pow(fact(r),mod-2,mod))%mod
def printQueue(q):
	r=qb
	ans=[0]*r.qsize()
	for i in range(r.qsize()-1,-1,-1):
		ans[i] = r.get()
	print(ans)
def dq():
	return queue.deque()
class UnionFind():
	def __init__(self, n):
		self.n = n
		self.parents = [-1]*n

	def find(self, x): # root
		if self.parents[x]<0:
			return x
		else:
			self.parents[x] = self.find(self.parents[x])
			return self.parents[x]

	def union(self,x,y):
		x = self.find(x)
		y = self.find(y)

		if x==y:
			return

		if self.parents[x]>self.parents[y]:
			x,y = y,x

		self.parents[x]+=self.parents[y]
		self.parents[y]=x

	def size(self,x):
		return -1*self.parents[self.find(x)]

	def same(self,x,y):
		return self.find(x)==self.find(y)

	def members(self,x): # much time
		root = self.find(x)
		return [i for i in range(self.n) if self.find(i)==root]

	def roots(self):
		return [i for i,x in enumerate(self.parents) if x<0]

	def group_count(self):
		return len(self.roots())

	def all_group_members(self):
		return {r: self.members(r) for r in self.roots()} # 1~n
def bitArr(n):#ビット全探索
	x = 1
	zero = "0"*n
	ans = []
	ans.append([0]*n)
	for i in range(2**n-1):
		ans.append(list(map(lambda x:int(x),list((zero+bin(x)[2:])[-1*n:]))))
		x+=1
	return ans;
def arrsSum(a1,a2):
	for i in range(len(a1)):
		a1[i]+=a2[i]
	return a1
def maxValue(a,b,v):
	v2 = v
	for i in range(v2,-1,-1):
		for j in range(v2//a+1): #j:aの個数
			k = i-a*j
			if k%b==0:
				return i
	return -1


n = readInt()
d = defaultdict(int)
for i in range(n):
	d[readChar()]+=1

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

ans = []

for i in range(len(d)):
	if d[i][1]==maxCount:
		ans.append(d[i][0])
	else:
		break

ans.sort()

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

Submission status: Accepted

Solution code:
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

n = ni()
s = dict()

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

ss = sorted([(_[1], _[0]) for _ in s.items()])[::-1]

mx = ss[0][0]

ssr = []
for ssi in ss:
  if ssi[0] == mx:
    ssr.append(ssi[1])
sss = sorted(ssr)

for sssi in sss:
  print(sssi)

Submission status: Accepted

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

c = collections.Counter(s)
ret = []
tmp = []
max_v = max(c.values())

for k, v in c.most_common():
  if max_v == v:
    ret.append(k)
  else:
    break

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

Submission status: Accepted

Solution code:
n = int(input())
s = [input() for _ in range(n)]
d = {}
for i in s:
  if i in d:
    d[i] += 1
  else:
    d[i] = 1
vmax = max(d.values())
ans = [kv[0] for kv in d.items() if kv[1] == vmax]
ans.sort()
print('\n'.join(ans))

Submission status: Accepted

Solution code:
from collections import Counter

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

counter = Counter(S)
max_cnt = max(counter.values())
ans = [name for name, cnt in counter.items() if cnt == max_cnt]
ans.sort()
 
print(*ans, sep='\n')

Submission status: Accepted

Solution code:
N = int(input())
S_dict = {}
for i in range(N):
    s = input()
    if s not in S_dict:
        S_dict[s] = 1
    else:
        S_dict[s] += 1
        
max_poll = max(S_dict.values())
ans_list = []
for key, poll in S_dict.items():
    if poll == max_poll:
        ans_list.append(key)

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

Submission status: Accepted

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

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

k = max(dic.values())
dic = sorted(dic.items(), key=lambda x:x[0])
for el in dic:
  if el[1] == k:
    print(el[0])

Submission status: Accepted

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

N = int(input())
S = [input().strip('\n') for _ in range(N)]
c = Counter(S)
mx = 0

for k, v in c.items():
  mx = max(mx, v)

ans = []
for k, v in c.items():
  if mx == v:
    ans += [k]

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

Submission status: Accepted

Solution code:
import collections

N = int(input())
S_list = [None]*N
for i in range(N):
    S_list[i] = input()

dict_S = dict(collections.Counter(S_list))
max_count = max(dict_S.values())

max_list = []
for k, v in dict_S.items():
    if v == max_count:
        max_list.append(k)

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

Submission status: Accepted

Solution code:
n = int(input())
dic = {}
for i in range(n):
    w = input()
    if dic.get(w) is None:
        dic[w] = 1
    else:
        dic[w] += 1

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

maxn = ans[0][1]

ans = [x for x,y in ans if maxn==y]
ans.sort()
for i in ans:
    print(i)

Submission status: Accepted

Solution code:
n=int(input())
#n,m=map(int,input().split())
#hl=list(map(int,input().split()))
#l=[list(map(int,input().split())) for i in range(n)]

dic={}

for i in range(n):
    s=input()
    dic[s]=dic.get(s,0)+1

mx=max(dic.values())
ansl=[]
for k, v in dic.items():
    if v==mx:
        ansl.append(k)

ansl.sort()

for st in ansl:
    print(st)

Submission status: Accepted

Solution code:
n=int(input())
#n,m=map(int,input().split())
#hl=list(map(int,input().split()))
#l=[list(map(int,input().split())) for i in range(n)]

dic={}

for i in range(n):
    s=input()
    dic[s]=dic.get(s,0)+1

mx=max(dic.values())
ansl=[]
for k, v in dic.items():
    if v==mx:
        ansl.append(k)

ansl.sort()

for st in ansl:
    print(st)

Submission status: Accepted

Solution code:
import sys
from collections import Counter
N = int(sys.stdin.readline())
S = sys.stdin.read().split()

count = Counter(S)
max_num = max(count.values())
max_list = [i for i,j in count.items() if j==max_num]

max_list.sort()
print('\n'.join(max_list))

Submission status: Accepted

Solution code:
n = int(input())

d = {}

for i in range(n):
    a = input()
    if a in d:
        d[a] += 1
    else:
        d[a] = 1

m = max(d.values())
d = sorted(d.items())

for j in d:
    if j[1] == m:
        print(j[0])

Submission status: Accepted

Solution code:
N = int(input())
S = {}
for n in range(N):
  s = input()
  if s not in S.keys():
    S[s] = 1
  else:
    S[s] += 1
m = max(S.values())
S2 = sorted(S)
for s in S2:
  if S[s] == m:
    print(s)

Submission status: Accepted

Solution code:
n=int(input())
l={}
ans=[]
for i in range(n):
    s=input()
    if s in l:
        l[s]+=1
    else:
        l.setdefault(s,1)
max_l=max(l.values())

for i in l.keys():
  if l[i]==max_l:
    ans.append(i)
    
ans.sort()
 
for j in ans:
  print(j)

Submission status: Accepted

Solution code:
N=int(input())
h={}
for i in range(N):
  S=input()
  if S in h:
    h[S] += 1
  else:
    h[S]=0
result=sorted(h.items(), key=lambda x:x[1], reverse=True)
max_val=result[0][1]
keys = [k for k, v in h.items() if v == max_val]
for i in sorted(keys):
  print(i)

Submission status: Accepted

Solution code:
N = int(input())

S = {}

for i in range(N):
    s = input()

    if s not in S:
        S[s] = 1
    else:
        S[s] += 1
maxNum = 0
Smx = []
for s in S:
    if maxNum == S[s]:
       Smx.append(s)
    elif maxNum < S[s]:
        maxNum = S[s]
        Smx = [s]

for s in sorted(Smx):
    print(s)

Submission status: Accepted

Solution code:
n=int(input())
d={}
for i in range(n):
  s=input()
  if s not in d:
    d.setdefault(s,1)
    
  else:
    d[s]+=1
    
largest =max(d.values())
list_d=[]
for i in d.keys():
  if d[i]==largest:
    list_d.append(i)
    
list_d.sort()

for i in list_d:
  print(i)

Submission status: Accepted

Solution code:
# ABC155C ref. ABC008B

d = {}
max_value = 1
n = int(input())
for i in range(n):
    t = input()
    if t in d.keys():
        d[t] += 1
        if d[t] > max_value:
            max_value = d[t]
    else:
        d.setdefault(t, 1)
#print(f"d = {d}")
#print(f"max_value = {max_value}")
#print(f"d.keys() = {d.keys()}")
#print(f"d.values() = {d.values()}")
d = sorted(d.items())
#print(d)
for k, v in d:
    if v == max_value:
        print(k)

Submission status: Accepted

Solution code:
n = int(input())
d = {}
for i in range(n):
    s = input()
    if not s in d:
        d[s] = 1
    else:
        d[s] += 1
largest = max(d.values())
common_values = []
for key in d.keys():
    if d[key] == largest:
        common_values.append(key)
common_values = sorted(common_values)
for val in common_values:
    print(val)

Submission status: Accepted

Solution code:
n = int(input())
l = [input() for _ in range(n)]
d ={}
for i in l:
    if i in d:
        d[i] +=1
    if i not in d:
        d[i] =1
        
dic = sorted(d.items(), key=lambda x:x[1],reverse=True)
a = dic[0][1]
lis = []
for j in dic:
    if j[1] == a:
        lis.append(j[0])
    else:
        break
        
answerlist = sorted(lis)
[print(i) for i in answerlist]

Submission status: Accepted

Solution code:
import sys
from io import StringIO
import unittest


def resolve():
    N = int(input())
    S = {}
    maxs = 0
    for _ in range(N):
        s = input()
        if s in S.keys():
            S[s] += 1
            maxs = max(maxs, S[s])
        else:
            S[s] = 1
            maxs = max(maxs, S[s])
    # S.keys().sort()
    keys = sorted(S.keys())
    for key in keys:
        if S[key] == maxs:
            print(key)


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """7
beat
vet
beet
bed
vet
bet
beet"""
        output = """beet
vet"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """8
buffalo
buffalo
buffalo
buffalo
buffalo
buffalo
buffalo
buffalo"""
        output = """buffalo"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """7
bass
bass
kick
kick
bass
kick
kick"""
        output = """kick"""
        self.assertIO(input, output)

    def test_入力例_4(self):
        input = """4
ushi
tapu
nichia
kun"""
        output = """kun
nichia
tapu
ushi"""
        self.assertIO(input, output)


if __name__ == "__main__":
    # unittest.main()
    resolve()

Submission status: Accepted

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

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

c = Counter(s)
t = c.most_common()[0][1]
l = []
for i in c.most_common():
    if t == i[1]: 
        l.append(i[0])
l.sort()
for i in l:
    print(i)

Submission status: Accepted

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

import collections as cl
c=cl.Counter(s)
saidai=max(c.values())

ans=[]
for i in c.keys():
  if c[i]==saidai:
    ans.append(i)

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

Submission status: Accepted

Solution code:
N = int(input())
d = dict()
m = 0
for _ in range(N):
    s = input()
    d[s] = d.get(s, 0) + 1
    m = max(m, d[s])
ans = sorted(k for k, v in d.items() if v == m)
print(*ans, sep="\n")

Submission status: Accepted

Solution code:
n=int(input())
arr=[input() for _ in range(n)]
dic={}

for i in range(n): #各単語の出現回数を数える
    if arr[i] not in dic:
        dic[arr[i]]=1
    else:
        dic[arr[i]]+=1

largest=max(dic.values()) #最大の出現回数を求める
ans=[]

for keys in dic.keys():
    if dic[keys]==largest: #出現回数が最も多い単語を集計する
        ans.append(keys)

ans=sorted(ans) #単語を辞書順に並べ替えて出力する
for words in ans:
    print(words)

Submission status: Accepted

Solution code:
from collections import Counter

stdin = open(0)
N = int(stdin.readline())
S = stdin.read().split()

counter = Counter(S)
max_cnt = max(counter.values())
names = [name for name, cnt in counter.items() if cnt == max_cnt]
names.sort()

print(*names, sep='\n')

Submission status: Accepted

Solution code:
n=int(input())
s=[input() for _ in range(n)]
s.sort()
ans,be=[],""
cnt,maxcount=1,0

for i in range(n):
  if be==s[i]:
    cnt+=1
    
  else:
    if cnt>=1:
      if cnt>maxcount:
        maxcount=cnt
        ans.clear()
        ans.append(be)
      
      elif cnt==maxcount:
        ans.append(be)
      
      cnt=1
  be=s[i]
  if i==n-1:
    if cnt>=1:
      if cnt>maxcount:
        maxcount=cnt
        ans.clear()
        ans.append(be)
      
      elif cnt==maxcount:
        ans.append(be)
    
ans.sort()
for i in ans:
  if i!="":
    print(i)

Submission status: Accepted

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

dic=OrderedDict()
s=[input() for i in range(n)]
s.sort()
#print(s)
for i in range(n):
  if s[i] in dic.keys():
    dic[s[i]]+=1
  else:
    dic[s[i]]=0
    
ma = max(dic.values())
for k,v in dic.items():
  if v==ma:
    print(k)

Submission status: Accepted

Solution code:
import collections
n=int(input())
s=[]
for _ in range(n):
    s.append(str(input()))
ans=collections.Counter(s)
a=max(ans.values())
ans=[i for i,k in ans.items() if a==k]
print(*sorted(ans),sep="\n")

Submission status: Accepted

Solution code:
import itertools
import math
import fractions
import functools
n = int(input())
s = []
for i in range(n):
    s.append(input())

dic = {}

for i in range(n):
    current = dic.get(s[i],0)
    dic[s[i]] = current + 1

result = []
maximum = max(list(dic.values()))
for key in dic:
    if dic[key] == maximum:
        result.append(key)

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

Submission status: Accepted

Solution code:
from collections import Counter
n = int(input())
S = []
for _ in range(n):
    s = input()
    S.append(s)
cnt = Counter(S)
l = max(cnt.values())

ans = []
for k,v in cnt.items():
  if v == l:
    ans.append(k)

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

Submission status: Accepted

Solution code:
n = int(input())
L = sorted(input() for _ in range(n))
s = sorted(set(L))
c = [0] * len(s)
prev = L[0]
cnt = 1
l = 0
for i in range(1, len(L)):
    if L[i] == prev:
        cnt += 1
    else:
        c[l] = cnt
        l += 1
        cnt = 1
        prev = L[i]
c[-1] = cnt
m = max(c)
for j in range(len(c)):
    if c[j] == m:
        print(s[j])

Submission status: Accepted

Solution code:
import collections
n = int(input())
counter = collections.defaultdict(lambda:0)
most = 0
for _ in range(n):
  s = input()
  counter[s] += 1
  most = max(most, counter[s])

for i,v in sorted(counter.items()):
  if v == most:
    print(i)

Submission status: Accepted

Solution code:
from collections import Counter

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

c = Counter(s)

m = max(c.values())

ans = []
for x in c.keys():
    if c[x]==m:
        ans.append(x)

print('\n'.join(sorted(ans)))

Submission status: Accepted

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


def main():
    N = int(input())
    S = list(input().strip() for _ in range(N))
    assert N == len(S)
    count = collections.Counter(S)
    answer = []
    frequency = 0
    for word in count:
        if count[word] > frequency:
            answer = []
            answer.append(word)
            frequency = count[word]
        elif count[word] == frequency:
            answer.append(word)
    answer.sort()
    for s in answer:
        print(s)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
from collections import Counter
n = int(input())
s = [input() for i in range(n)]
c = Counter(s)
cks = list(c.keys())
cvs = c.values()
cvm = max(cvs)
l = []
for i,cvi in enumerate(cvs):
    if cvi==cvm:
        l.append(cks[i])
for ai in sorted(l):
    print(ai)

Submission status: Accepted

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

c = {}
for _ in range(n):
    s = input()
    c[s] = c.get(s, 0) + 1

u = max(c.values())
print("\n".join(sorted([ k for k,v in c.items() if v == u ])))

Submission status: Accepted

Solution code:
from collections import defaultdict
n = int(input())
S = [input() for _ in range(n)]
d = defaultdict(int)
for s in S:
    d[s] += 1
m = max(d.values())
items = d.items()
a = sorted([c[0] for c in items if c[1] == m])
[print(i) for i in a]

Submission status: Accepted

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

c = Counter(s)
ma = max(c.values())
ans = []
for k,v in c.items():
  if ma == v:
    ans.append(k)

ans = sorted(ans)

for a in ans:
  print(a)

Submission status: Accepted

Solution code:
n = int(input())

d = {}

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

m = max(d[i] for i in d)

for j in sorted(d):
    if d[j] == m:
        print(j)

Submission status: Accepted

Solution code:
N=int(input())
cnt = {}
for _ in range(N):
  s = input()
  if s not in cnt:cnt[s]=0
  cnt[s]+=1
max_val = max([cnt[v] for v in cnt])
l = [v for v in cnt if cnt[v]==max_val]
l.sort()

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

Submission status: Accepted

Solution code:

n = int(input())
s = [str(input()) for _ in range(n)]
 
from collections import Counter
s = Counter(s).most_common()
 
b =[]
a = s[0][1]
for i in range(len(s)):
    if s[i][1] == a :
        b.append(s[i][0])
b= sorted(b)
for i in range(len(b)):
    print(b[i])

Submission status: Accepted

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

from collections import Counter
s = Counter(s).most_common()

b =[]
a = s[0][1]
for i in range(len(s)):
    if s[i][1] == a :
        b.append(s[i][0])
b= sorted(b)
for i in range(len(b)):
    print(b[i])

Submission status: Accepted

Solution code:
from collections import Counter
n = int(input())
s = [input() for _ in range(n)]
c=Counter(s)
max_cnt=0
for key in c:
    max_cnt=max(max_cnt,c[key])
ans=[]
for key in c:
    if c[key]==max_cnt:
        ans.append(key)
    else:
        continue
ans.sort()
for item in ans:
    print(item)

Submission status: Accepted

Solution code:
n = int(input())
arr = [input() for _ in range(n)]
dic = {}
for i in range(n):  # 各単語の出現回数を数える
    if arr[i] not in dic:
        dic[arr[i]] = 1
    else:
        dic[arr[i]] += 1
largest = max(dic.values())  # 最大の出現回数を求める
ans = []
for keys in dic.keys():
    if dic[keys] == largest:  # 出現回数が最も多い単語を集計する
        ans.append(keys)
ans = sorted(ans)  # 単語を辞書順に並べ替えて出力する
for words in ans:
    print(words)

Submission status: Accepted

Solution code:
count = int(input())

ls = {}

for i in range(count):
    s = input()
    if s in ls:
        ls[s] += ls[s] + 1
    else:
        ls.setdefault(s, 1)

m = max(ls.values())

ans = [k for k, v in ls.items() if v == m]

print('\n'.join(sorted(ans)))

Submission status: Accepted

Solution code:
import sys
from collections import defaultdict


def input():
    return sys.stdin.readline().strip()


sys.setrecursionlimit(20000000)

MOD = 10 ** 9 + 7


def main():
    N = int(input())
    D = defaultdict(int)
    for _ in range(N):
        S = input()
        D[S] += 1
    K = list(D.keys())
    V = list(D.values())
    M = max(V)
    L = []
    for k in K:
        if D[k] == M:
            L.append(k)
    L.sort()
    print(*L, sep="\n")


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
from collections import Counter

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

c = Counter(S)
l = list(c.most_common())
A = []
for i,j in l:
    if j == l[0][1]:
        A.append(i)

A.sort()

for i in A:
    print(i)

Submission status: Accepted

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

Submission status: Accepted

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

for i in range(N):
    S = input()
    if S in data.keys():
        data[S] += 1
    else:
        data[S] = 1

m = max(data.values())

L = []

for x in data.keys():
    if data[x] == m:
        L.append(x)

L.sort()

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

Submission status: Accepted

Solution code:
from collections import Counter

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

cS = Counter(S)
largest = max(cS.values())
ans = []
for k, v in cS.items():
    if v == largest:
        ans.append(k)
ans.sort()
for w in ans:
    print(w)

Submission status: Accepted

Solution code:
from collections import Counter
n=int(input())
list=[input() for _ in range(n)]
list.sort()
c=Counter(list).most_common()
most=c[0][1]
c.sort()
for i in range(len(c)):
    if c[i][1]==most:
        print(c[i][0])

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]=0
m=max(d.values())
ans=[]
for x in d.keys():
  if d[x]==m:
    ans.append(x)
ans.sort()
for x in ans:
  print(x)

Submission status: Accepted

Solution code:
from collections import Counter
 
n = int(input())
sss = [input() for _ in range(n)]
cnt = Counter(sss)
l = max(cnt.values())
ans = [s for s, c in cnt.items() if c == l]
ans.sort()
print('\n'.join(ans))

Submission status: Accepted

Solution code:
n = int(input())
L = []
for i in range(n):
    L.append(input())
    
from collections import Counter
L = Counter(L)
L =L.most_common()

li = []
for i in range(len(L)):
    if L[i][1] == L[0][1]:
        li.append(L[i][0])
li.sort()

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

Submission status: Accepted

Solution code:
n = int(input())

d = {}
for _ in range(n):
  s = input()
  d[s] = d.get(s, 0) + 1

m = max(d.values())
ans = []
for s in d:
  if d[s] == m:
    ans.append(s)
    
ans.sort()
for a in ans:
  print(a)

Submission status: Accepted

Solution code:
n=int(input())
s = {}
maxs = 1
wdlst = set()
for i in range(n):
  si = input()
  if si in s:
    s[si] = s[si] + 1
    maxs = max(maxs,s[si])
  else:
    s[si] = 1
    wdlst.add(si)
res = list()
for x in wdlst:
  if s[x]==maxs:
    res.append(x)
res.sort()
for x in res:
  print(x)

Submission status: Accepted

Solution code:
import collections
n=int(input())
s=[str(input()) for i in range(n)]
c=collections.Counter(s)
lst=[]
maxi=max(c.values())
for i in c.keys():
  if c[i]==maxi:
    lst.append(i)
lst.sort()
for k in range(len(lst)):
  print(lst[k])

Submission status: Accepted

Solution code:
N = int(input())

S_list = []

for i in range(N):
    S_list.append(input())
    
import collections
c = collections.Counter(S_list)

max_num_of_occur = max(c.values())
most_common_list = []

for k,v in c.items():
    if v==max_num_of_occur:
        most_common_list.append(k)

NO_OUTPUT = [print(x) for x in sorted(most_common_list)]

Submission status: Accepted

Solution code:
n = int(input())

words = {}

for i in range(n):
    key = input()
    if key not in words:
        words[key] = 0
    words[key] += 1

l = []
th = max(words.values())

for i,j in words.items():
    if th == j:
        l.append(i)

l.sort()

print(*l, sep="\n", end="")

Submission status: Accepted

Solution code:
from collections import *
_,*a=map(lambda x:x.rstrip(), open(0))
a=Counter(a).most_common()
a=sorted([i[0] for i in a if i[1]==a[0][1]])
print(*a,sep="\n")

Submission status: Accepted

Solution code:
import collections

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

c = collections.Counter(s)
c_s = c.most_common()
m = c.most_common()[0][1]
ans = []
for j in range(len(c_s)):
    if c_s[j][1] != m:
        break
    else:
        ans.append(c_s[j][0])
ans.sort()
for t in ans:
    print(t)

Submission status: Accepted

Solution code:
import collections

n = int(input())
s = []

while True:
  try:
    s.append(input())
    
  except:
    break
words = []
c = collections.Counter(s)
MAX = c.most_common()[0][1]
for i,j in c.most_common():
  if j==MAX:
    words.append(i)
  else:
    break

L = sorted(set(words))

for i in L:
  print(i)

Submission status: Accepted

Solution code:
import collections
N = int(input())
S = [input() for i in range(N)]
votes_collection = collections.Counter(S)
vote_max_num = votes_collection.most_common(1)[0][1]
max_votes = sorted([i[0]
                    for i in votes_collection.items() if i[1] == vote_max_num])
for i in max_votes:
    print(i)

Submission status: Accepted

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

from collections import Counter
counter=Counter(A)
m=max(counter.values())
C=[]
for i,value in counter.items():
    if value==m:
        C.append(i)
C=sorted(C)
print(*C,sep='\n')