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:
# -*- coding: utf-8 -*-

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

S.sort()
count = list()
now = 0
for i in range(N - 1):
    if S[i] != S[i + 1]:
        count.append([now, i - now + 1])
        now = i + 1
    if i + 1 == N - 1:
        count.append([now, len(S) - now])

m = max([c[1] for c in count])
for c in count:
    if c[1] == m:
        print(S[c[0]])

Submission status: Accepted

Solution code:
N = int(input())
D = {}
for n in range(N):
    w = input()
    if w not in D:
        D[w] = 1
    else:
        D[w] += 1
m = max(D.values())
l = []
for (key, value) in D.items():
    if value == m:
        l.append(key)
for s in sorted(l):
	print(s)

Submission status: Accepted

Solution code:
import sys

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

#sort by value
counter_sorted = sorted(counter.items(), key=lambda x:x[1], reverse = True)

tmp = counter_sorted[0][1]
output = []
L = len(counter)
for i in range(L):
    if tmp == counter_sorted[i][1]:
        output.append(counter_sorted[i][0])
    else:
        break

#sort by key
output = sorted(output)
for i in output:
    print(i)

Submission status: Accepted

Solution code:
N = int(input())
dic = {}
for i in range(0,N):
  inp = input()
  if inp not in dic:
    dic[inp] = 1
  else:
    dic[inp] +=1

m = max(dic.values())

keys = [k for k,v in dic.items() if v == m]

keys.sort()

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

Submission status: Accepted

Solution code:
import collections
import itertools

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

counted = collections.Counter(S)

# 最頻値を求める
m = max(counted.values())

# 頻出数の文字を集める
chars = [key for key, value in counted.items()
             if value == m]
chars=sorted(chars)
for a in chars:
  print(a)

Submission status: Accepted

Solution code:
from collections import  Counter
N = int(input())
votes = [input() for i in range(N)]
count = dict(Counter(votes))
max_vote = max(count.values())
res = []
for i in count:
    if count[i] == max_vote:
        res.append(i)
        continue
res.sort()
for i in res:
    print(i)

Submission status: Accepted

Solution code:
n = int(input())
s = [input() for _ in range(n)]
import collections
c = collections.Counter(s)
d = c.most_common()
# print(d)
e = [d[0][0]]
for i in range(len(d)-1):
    if d[i][1] == d[i+1][1]:
        e.append(d[i+1][0])
    else:
        break
# print(e)
f = sorted(e)
# print(f)
[print(i) for i in f]

Submission status: Accepted

Solution code:
from collections import defaultdict

N = int(input())
ans = dict()
for _ in range(N):
    k = str(input())
    if k in ans:
        ans[k] += 1
    else:
        ans.update({k: 1})
groupedByValue = defaultdict(list)
for key, value in sorted(ans.items()):
    groupedByValue[value].append(key)
l = groupedByValue[max(groupedByValue)]
for i in l:
    print(i)

Submission status: Accepted

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


def solve(N: int, S: "List[str]"):
    
    word = {}

    for s in S:
        if s not in word.keys():
            word[s] = 1
        else:
            word[s] = word[s] + 1

    max_n = max(word.values())

    max_w = [key for key in word.keys() if word[key] == max_n]

    max_w.sort()

    for st in max_w:
        print(st)

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

Solution code:
import collections

N = int(input().strip())
words = []
for i in range(N):
  word = input().strip()
  words.append(word)
  
c = collections.Counter(words)
num = c.most_common()[0][1]
#print(num)

ans = []
for name, freq in c.most_common():
  if freq == num:
    ans.append(name)
  else:
    break
    
for i in sorted(ans):
  print(i)

Submission status: Accepted

Solution code:
n = int(input())
poll = {}
m = 0
for i in range(n):
    word = input()
    if word in poll:
        poll[word] += 1
    else:
        poll[word] = 1
    
    if poll[word] > m:
        m = poll[word]

words = [k for k, v in poll.items() if v == m]
words = sorted(words)
for word in words:
    print(word)

Submission status: Accepted

Solution code:
import sys
n = int(input())
a_dict = {}
max_val = 1
max_key_list = []
for s in sys.stdin:
  s = s.rstrip()
  if s not in a_dict:
    a_dict[s] = 1
    if max_val == 1:
      max_key_list.append(s)
  else:
    a_dict[s] += 1
    if a_dict[s] > max_val:
      max_val = a_dict[s]
      max_key_list = [s]
    elif a_dict[s] == max_val:
      max_key_list.append(s)
max_key_list.sort()
for s in max_key_list:
  print(s)

Submission status: Accepted

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

L = sorted(L)
k = 0
T.append([L[0],1])  
for i in range(1,N):
    for j in range(k,len(T)):
        if L[i] == T[j][0]:
            T[j][1] += 1
        else:
            k = j + 1
            T.append([L[i],1])
            break

Max = 0
for i in range(0,len(T)):
    if T[i][1] > Max:
        Max = T[i][1]

ans = []
for i in range(0,len(T)):
    if T[i][1] == Max:
        ans.append(T[i][0])

ans = sorted(ans)

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

Submission status: Accepted

Solution code:
n = int(input())
s = [input() for i in range(n)]
a = [0]*n
count=m=0;

s.sort()

for i in list(range(1,n)):
    if(s[i]==s[i-1]):
        count+=1
    else:
        count=0
    a[i]=count
    if(m<count):m=count

for i in range(n):
    if(a[i]==m):
        print(s[i])

Submission status: Accepted

Solution code:
from collections import Counter

def print_cnt(l):
    counter = Counter(l)
    max_cnt = counter.most_common(1)[0][1]
    ret = [v for v,c in counter.most_common() if c == max_cnt] # 最多２個以上にするなら ～if c > 1 and c == max_cnt
    ret=sorted(ret)
    for a in ret:
        print(a)


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

Submission status: Accepted

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

info.sort()


ans = [info[0]]
record = 1
tem_record = 1
for i in range(n-1):
    if info[i] == info[i+1]:
        tem_record += 1
        if i == n-2:
            if tem_record > record:
                record = tem_record
                ans = [info[i]]
            elif tem_record == record and i != 0:
                ans.append(info[i])
    else:
        if tem_record > record:
            record = tem_record
            ans = [info[i]]
        elif tem_record == record and i != 0:
            ans.append(info[i])

        tem_record = 1

if record == 1 and info[n-1] != info[n-2]:
    ans.append(info[n-1])


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

Submission status: Accepted

Solution code:
def main():
    import sys
    import collections
    input = sys.stdin.readline
    N = int(input())
    S = [input() for i in range(N)]
    c = collections.Counter(S)
    max_num = c.most_common(1)[0][1]
    ss = [cc[0] for cc in c.most_common() if cc[1] == max_num]
    ss.sort()
    for s in ss:
        print(s,end="")

if __name__ == "__main__":
    main()

Submission status: Accepted

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

import collections

c = collections.Counter(S)

#最頻値の個数
mx = c.most_common()[0][1]#c[max(c)]


L = set()
for s in S:
    if c[s] == mx:
        L.add(s)

L = list(L)
L.sort()
for l in L:
    print(l)

Submission status: Accepted

Solution code:
from collections import defaultdict
import pprint
n = int(input())
d1 = defaultdict(int)
for i in range(n):
  d1[input()]+=1
max1 = max(d1.values())
for x in sorted([k for k,v in d1.items() if v == max1]):
  print(x)

Submission status: Accepted

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

word_count = {}

for index in range(len(S)):
    word = S[index]
    if word in word_count:
        word_count[word] = word_count[word] + 1
    else:
        word_count[word] = 1

max = 0
for key in word_count.keys():
    count = word_count[key]
    if count > max:
        max = count

max_words = []
for key in word_count.keys():
    count = word_count[key]
    if count == max:
        max_words.append(key)

max_words.sort()
for word in max_words:
    print(word)

Submission status: Accepted

Solution code:
num=int(input())
dic={}
for i in range(num):
  s=input()
  if s not in dic:
    dic[s]=1
  else:
    dic[s]+=1
sorteddic=sorted(dic.items(),reverse=True,key=lambda x:x[1])
res = []
cnt=0
temp = 0
for i in sorteddic:
  if cnt ==0 or temp == i[1]:
    res.append(i[0])
    temp = i[1]
  else:
    break
  cnt+=1  
for i in sorted(res):
  print(i)

Submission status: Accepted

Solution code:
N = int(input())
name = [input() for i in range(N)]
import collections
'''
name = ""
dic = {}
for i in range(N):
  name = input()
  dic[name] += 1
print(dic)
'''
c = collections.Counter(name)
values, counts = zip(*c.most_common(N))
maxim = counts[0]
answer = []
for val, cnt in zip(values,counts):
  if ( cnt == maxim):
    answer.append(val)
  else:
    break
answer = sorted(answer)
for i in answer:
  print(i)

Submission status: Accepted

Solution code:
import collections

N = int(input())
S = []
A = []
m=0

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

c = collections.Counter(S)

for k, v in c.most_common(2*10**5):
#  print(k,v)
  if v>=m:
#      print(k)
    A.append(k)
    m=v
  else:
    break
A.sort()
for j in range(0,len(A)):
  print(A[j])

Submission status: Accepted

Solution code:
#coding:utf-8

n = int(input())

dic = {}
for _ in range(n):
    key = input()
    if key in dic:
        dic[key] += 1
    else:
        dic[key] = 1
        

max_v = max(dic.values())
li = []


for key in dic:
    if max_v == dic[key]:
        li.append(key)
        
li = sorted(li)
for v in li:
    print(v)

Submission status: Accepted

Solution code:
import collections
import itertools

N=int(input())
A=[]
B=[]


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

counter = collections.Counter(A)

mode_v = counter.most_common()[0][-1]

it = itertools.takewhile(
    lambda kv: kv[-1] == mode_v, counter.most_common()
)

for k,v in it:
  B.append(k)
B.sort()

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

Submission status: Accepted

Solution code:
import collections

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

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

c = collections.Counter(s)

for i in c.items():
    if i[1] > max:
        max = i[1]

s2 = [i[0] for i in c.items() if i[1] == max]

s2.sort()

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

Submission status: Accepted

Solution code:
import collections
N = int(input())
S = [input() for _ in range(N)]
C = collections.Counter(S)
max_cnt = C.most_common()[0][1]
tmp = sorted([k for k,v in C.items() if v == max_cnt])
for ans in tmp:
    print(ans)

Submission status: Accepted

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

S_set= sorted(list(set(S)))

dic = dict(zip(S_set, [0 for _ in range(len(S_set))]))

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

K_max = max(list(dic.values()))
        
for (i,s) in enumerate(sorted(S_set)): 
    if dic[s] == K_max: 
        print(s)

Submission status: Accepted

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

maxv = max(poll.values())
a = [k for k, v in poll.items() if v == maxv]
a.sort()

for el in a:
    print(el)

Submission status: Accepted

Solution code:
n=int(input())
string_list=[input() for i in range(n)]
import collections
import numpy as np
c = collections.Counter(string_list)
d=c.most_common()
x=int(d[0][1])
z=[]
for i in range(len(d)):
  y=int(d[i][1])
  if x==y:
    z.append(str(d[i][0]))
    
z.sort()
for i in range(len(z)):
  print(z[i])

Submission status: Accepted

Solution code:
def main():
    n = int(input())
    s = {}
    for _ in range(n):
        string = input()
        if string in s:
            s[string] += 1
        else:
            s[string] = 1
    s = sorted(list(s.items()), key=lambda x: (x[1], x[0]), reverse=True)
    lst = []
    max_num = s[0][1]
    if n == len(s):
        for string, num in reversed(s):
            print(string)
    else:
        for string, num in s:
            if num != max_num:
                break
            lst.append(string)
    for l in reversed(lst):
        print(l)


if __name__ == "__main__":
    main()

Submission status: Accepted

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

S.sort()
a = S[0]
c = 0
moji = []

for i in S:
    if a != i:
        moji.append([c,a])
        a = i
        c = 0
    c += 1
if c > 0:
    moji.append([c,a])

moji.sort(reverse=True)
maxc = moji[0][0]
x = []
for j in moji:
    if j[0] < maxc: break
    x.append(j[1])
x.sort()
for j in x:
    print(j)

Submission status: Accepted

Solution code:
from collections import Counter

def calculate_mode(data):
    c = Counter(data)
    freq_scores = c.most_common()
    max_count = freq_scores[0][1]

    modes = []

    for num in freq_scores:
        if num[1] == max_count:
            modes.append(num[0])
    modes.sort()
    return(modes)

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

modes = calculate_mode(data)

for mode in modes:
    print(mode)

Submission status: Accepted

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

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

c = collections.Counter(s)
c_max = c.most_common(1)[0][1]

c_word = [i[0] for i in c.items() if i[1] == c_max]

dic = sorted(c_word)

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

Submission status: Accepted

Solution code:
from collections import defaultdict
from collections import OrderedDict
n = int(input())
answer = dict()
for _ in range(n):
    z = str(input())
    if z in answer:
        answer[z]+=1
    else:
        answer.update({z:1})
groupedByValue = defaultdict(list)
for key, value in sorted(answer.items()):
    groupedByValue[value].append(key)
M = groupedByValue[max(groupedByValue)]
for i in M:
    print(i)

Submission status: Accepted

Solution code:
n = int(input())
s = []
for i in range(0,n):
    s.append(input())
s.sort()
b = [0] * (n - 1)
for i in range(0,n-1):
    if s[i] == s[i+1]:
        b[i] = 1
j = n-2
while j > 0:
    if b[j-1] != 0:
        b[j-1] += b[j]
    j-=1
max = 0
for i in range(0,n-1):
    if b[i] > max:
        max = b[i]
for i in range(0,n-1):
    if b[i] == max:
        print(s[i])
if b[n-2] == 0:
    print(s[n-1])

Submission status: Accepted

Solution code:
def main():
    N = int(input())
    S = [0]*N
    count=[1]*N
    for i in range(N):
        S[i] = input()
    ss=sorted(S)
    ss.append("zettainai")
    flag=0
    for i in range(N):
        if ss[i]==ss[i+1]:
            flag= flag+1
        else:
            count[i]=count[i]+flag
            flag=0
    maxx=max(count)
    for i in range(N):
        if count[i]==maxx:
            print(ss[i])
main()

Submission status: Accepted

Solution code:
from collections import Counter
n=int(input())
s=[]
for i in range(n):
  s.append(input())
c=list(Counter(s).items())
t=[]
for i in range(len(c)):
  t.append(c[i][1])
m=max(t)
a=[]
for i in range(len(c)):
  if c[i][1]==m:
    a.append(c[i][0])
a.sort()
for i in range(len(a)):
  print(a[i])

Submission status: Accepted

Solution code:
N = int(input())
S = list(str(input()) for _ in range(N))
S2 = sorted(S)
cnt1 = [0,]
cnt2 = [0,]*N
word = [0,]
for i in range(N-1):
    if S2[i] != S2[i+1]:
        cnt1.append(i+1)
        word.append(S2[i])
cnt2 = [0,]*len(cnt1)
for i in range(1,len(cnt1)):
    cnt2[i] = cnt1[i] - cnt1[i-1]
cnt2.append(N-sum(cnt2))
word.append(S2[N-1])
X = max(cnt2)
for i in range(len(cnt2)):
    if cnt2[i] == X:
        print(word[i])

Submission status: Accepted

Solution code:
n = int(input())
S = []
for i in range(n):
    s = input()
    S.append(s)
S.sort()
A = list(set(S))
A.sort()
#print(A)
#print(S)
NUM =[0]*len(A)
j = 0
for i in range(len(S)):
    if(i+1<len(S)):
        if (S[i] == S[int(i)+1]):
            NUM[j] = NUM[j]+ 1
        else:
            j += 1
import numpy as np
b = np.argmax(NUM)
#print(NUM,b)
for e,i in enumerate(NUM):
    #print(NUM[b])
    if (i == NUM[b]):
        print(A[e])

Submission status: Accepted

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

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

max_value = max(hash.values())

result = {}
for key in hash.keys():
    if hash[key] == max_value:
        result[key] = True

for key in sorted(result.keys()):
    print(key)

Submission status: Accepted

Solution code:
import sys
from collections import defaultdict

input_methods=['clipboard','file','key']
using_method=0
input_method=input_methods[using_method]

IN=lambda : map(int, input().split())
mod=1000000007

#+++++

def main():
	n = int(input())
	dd=defaultdict(lambda :0)
	for i in range(n):
		s = input()
		dd[s]+=1
		
	maxv=0
	mml=[]
	for k in dd.keys():
		if dd[k]==maxv:
			mml.append(k)
		elif dd[k]>maxv:
			maxv=dd[k]
			mml=[k]
		else:
			pass
			
	mml.sort()
	for k in mml:
		print(k)
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)
		
def input_clipboard():
	import clipboard
	input_text=clipboard.get()
	input_l=input_text.splitlines()
	for l in input_l:
		yield l

if __name__ == "__main__":
	if sys.platform =='ios':
		if input_method==input_methods[0]:
			ic=input_clipboard()
			input = lambda : ic.__next__()
		elif input_method==input_methods[1]:
			sys.stdin=open('inputFile.txt')
		else:
			pass
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

Submission status: Accepted

Solution code:
def inverse_lookup(d, x):
    a = []
    for k,v in d.items():
        if x == v:
          a.append(k)
    return sorted(a)

n = int(input())
w = {}
for _ in range(n):
  i = input()
  if i in w:
    w[i] += 1
  else:
    w[i] = 1
m = max(w.values())
for j in inverse_lookup(w,m):
  print(j)

Submission status: Accepted

Solution code:
from collections import defaultdict
import collections
N=int(input())
ss = []
for i in range(N):
  ss.append(input())
#d = defaultdict(lambda: 0)
c = collections.Counter(ss)
d_=c.most_common()
mx = d_[0][1]
d_.sort()
#print(d_)
m=len(d_)
for i in range(m):
  if d_[i][1] == mx:
    print(d_[i][0])
  else:
    pass

Submission status: Accepted

Solution code:
from collections import Counter

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

mycounter = Counter(S).most_common()[::1]
result = []
maxcount = mycounter[0][1]
for i in range(len(mycounter)):
    if maxcount == mycounter[i][1]:
        result.append(mycounter[i][0])

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

Submission status: Accepted

Solution code:
import collections

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


s = collections.Counter(S)

s = s.most_common()

pri_l = [s[0][0]]
for i in range(1,len(s)):
	if s[0][1] == s[i][1]:
		pri_l.append(s[i][0])

	else:
		break

pri_l = sorted(pri_l)
#print("======")
for i in range(len(pri_l)):
	print(pri_l[i])

Submission status: Accepted

Solution code:
from collections import Counter
n=int(input())
string_list = [input() for i in range(n)]
str_counter = Counter(string_list)
most_count = 0
l = []
for v in str_counter.values():
  if v > most_count:
    most_count = v

for k,v in str_counter.items():
  if v == most_count:
    l.append(k)
l.sort()
for i in l:
  print(i)

Submission status: Accepted

Solution code:
n = int(input())
s = []
for i in range(n):
    s.append(input())
sort_s = sorted(s)
x = [0] * n
y = [0] * n
count = 1
ans = []
max_c = 1
for i in range(n-1):
    if sort_s[i] == sort_s[i + 1]:
        count += 1
    else:
        x[i] = sort_s[i]
        y[i] = count
        count = 1
x[n-1] = sort_s[n-1]
y[n-1] = count
m = max(y)
ans = []
for i in range(n):
    if y[i] == m:
        ans.append(i)
for i in ans:
    print(x[i])

Submission status: Accepted

Solution code:
import collections

N = int(input())

S = [0] * N

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

c= collections.Counter(S)

mc = c.most_common()
mxf = mc[0][1]

ans = []
for i in range(len(c)):
    if(mc[i][1] == mxf):
        ans.append(mc[i][0])

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

Submission status: Accepted

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

m = max(dic.values())
l = []
for v in dic.items():
  if v[1] == m:
    l.append(v[0])
sortl = sorted(l)
for i in range(len(sortl)):
  print(sortl[i])

Submission status: Accepted

Solution code:
from collections import defaultdict
from collections import OrderedDict
N = int(input())
ans = dict()
for _ in range(N):
    k = str(input())
    if k in ans:
        ans[k]+=1
    else:
        ans.update({k:1})
groupedByValue = defaultdict(list)
for key, value in sorted(ans.items()):
    groupedByValue[value].append(key)
l = groupedByValue[max(groupedByValue)]
for i in l:
    print(i)

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
l = list(d.items())
l = sorted(l, key=lambda x:x[1])
nn = len(l)
m = l[nn-1][1]
i = nn - 1
ll = []
while l[i][1] == m:
	ll.append(l[i][0])
	i -= 1
	if i == -1:
		break
ll.sort()
for i in range(len(ll)):
	print(ll[i])

Submission status: Accepted

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


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

Submission status: Accepted

Solution code:
import collections

n = int(input())
words = [input() for _ in range(n)]
c = collections.Counter(words)
max_c = c.most_common()
ans = [max_c[0][0]]

for i in range(1, len(max_c)):
    if max_c[i][1] == max_c[i-1][1]:
        ans.append(max_c[i][0])
    else:
        break

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

Submission status: Accepted

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

import collections

Ss_counted = collections.Counter(Ss)
max_val = max(Ss_counted.values())

# # https://note.nkmk.me/python-dict-value-max-min/

result = []
for k, v in Ss_counted.items():
    if v == max_val:
        result.append(k)

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

Submission status: Accepted

Solution code:
n=int(input())

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

s_dict={}
for word in s:
    if word in s_dict:
        s_dict[word] += 1
    else:
        s_dict[word] = 1

Ms = max(s_dict.values())

keys = [k for k, v in s_dict.items() if v == Ms]


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

Submission status: Accepted

Solution code:
import collections
N = int(input())
a=[]
ans=[]
max =0
for i in range(N):
    a.append(input())
c = collections.Counter(a)
score_sorted = sorted(c.items(), key=lambda x:x[1], reverse=True)
for i in range(len(score_sorted)):
    max=score_sorted[0][1]
    if score_sorted[i][1] == max:
        ans.append(score_sorted[i][0])
    else:
        break
ans.sort()
for j in range(len(ans)):
    print(ans[j])
#print(c.values())

Submission status: Accepted

Solution code:
import collections

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

c = collections.Counter(s)
max = 0
for i in c.values():
  if max < i:
    max = i

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

for i in keys:
  print(i)

Submission status: Accepted

Solution code:
n=int(input())
l=[input() for i in range(n)]
l.sort()
ll=list(set(l))
ll.sort()
m=len(ll)
ans=[0]*m
count=0
j=0
for i in range(len(l)-1):
  if l[i]==l[i+1]:
    count+=1
    if i+1==n-1:
      ans[j]+=count
  else:
    ans[j]+=count
    count=0
    j+=1
g=max(ans)
for i in range(m):
  if ans[i]==g:
    print(ll[i])

Submission status: Accepted

Solution code:
import collections
import itertools

n = int(input())
l = [input() for _ in [0] * n]

counter = collections.Counter(l)

a = counter.most_common()[0][-1]
b = itertools.takewhile(
    lambda kv: kv[-1] == a, counter.most_common()
)

c = sorted(list(k for k, v in b))
print(*c,sep='\n')

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-

n=int(input())  #数値入力 「N」だけの入力のとき
i=0
lst ={}
while i < n: 
    s = input()
    if s not in lst:
        lst[s]=1
    else:
        lst[s]+=1
    i+=1
maxi = max(lst.values())
res = []
for i,j in lst.items():
    if j == maxi:
       res.append(i) 
res.sort()
for i in res:
     print(i)

Submission status: Accepted

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

S_max = max(S_count.values())
S_count_sorted = sorted([key for key, val in S_count.items()\
                  if val == S_max])
 
print('\n'.join(S_count_sorted))

Submission status: Accepted

Solution code:
from collections import Counter

if __name__=="__main__":
    n = int(input())
    s=[]
    for i in range(n):
        s.append(input())
        
    s_most = Counter(s).most_common()

    ans_list = [s_most[0][0]]
    for i in range(1,len(s_most)):
        if s_most[i][1]==s_most[0][1]:
            ans_list.append(s_most[i][0])
        else:
            break

    ans_list.sort()

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

Submission status: Accepted

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

dic = {}
for moji in s:
    if moji in dic.keys():
        dic[moji] += 1 
    else: dic[moji] = 1
max_dic = max(dic.values())
ans_list= [k for k, v in dic.items() if v == max_dic]  
ans_list = sorted(ans_list)
for al in ans_list:
    print(al)

Submission status: Accepted

Solution code:
N = int(input())
L = []
for x in range(N):
    L.append(input())
#print(L)
M = {}
for x in L:
    if((x in M) != True):
        M[x] = 1
    else:
       # print(M[x])
        M[x] = M[x] + 1
#print(M)
max_m = max(M.values())
##print(M)
ans = []
for x,y in M.items():
    if(max_m == y):
        ans.append(x)
#print(ans)
ans.sort()
for x in ans:
    print(x)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-

import os
import datetime

def main():

    str_dict = {}
    val_1 = int(input())
    for i in range(val_1):
        val_x = input()

        if not val_x in str_dict:
            str_dict[val_x] = 1
        else:
            num = str_dict.get(val_x)
            str_dict[val_x] = num + 1

    max_count = max(str_dict.values())
    max_list = []

    for k, v in sorted(str_dict.items(), key=lambda x: -x[1]):
        if max_count == v:
            max_list.append(k)

    new_list = sorted(max_list)

    for key in new_list:
        print(key)





if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
from collections import Counter
input_int = int(input())
input_list = []

for i in range(input_int):
    input_line = input()
    input_list.append(input_line)

counter = Counter(input_list)

max_val = max(counter.values())
keys_of_max_val = [key for key in counter if counter[key] == max_val]

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

Submission status: Accepted

Solution code:
#python3
from collections import defaultdict
from operator import itemgetter

def main():
    n = int(input())
    a = [input() for _ in range(n)]
    s = defaultdict(int)
    for i in a:
        s[i]+=1  
    
    t = []
    for i, j in s.items():
        t.append((i, j))

    t.sort(reverse=True,key=itemgetter(1))
    MAX = t[0][1]
    ans = []
    for i, j in t:
        if j == MAX:
            ans.append(i)
    ans.sort()
    for i in ans:
        print(i)
main()

Submission status: Accepted

Solution code:
import collections

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

C = collections.Counter(S).most_common()
M = C[0][1]

ans = []
for c in C:
    if c[1] == M:
        ans.append(c[0])
    else:
        break

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

Submission status: Accepted

Solution code:
import collections

N = int(input())

data = []
val = [0]*N

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

data.sort()
c = collections.Counter(data)

mostc = c.most_common()
mostv = mostc[0][1]

ans = []
for x in mostc:
    if x[1] == mostv:
        ans.append(x[0])

ans.sort()

for y in ans:
    print(y)

Submission status: Accepted

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

l = [kv[0] for kv in s.items() if kv[1] == m]

l.sort()

for i in l:
  print(i)

Submission status: Accepted

Solution code:
from collections import Counter

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

c = Counter(S).most_common()

l = list(filter(lambda v: v[1] == c[0][1], c))
l.sort()

a = l[0][1]
for s in l:
    if s[1] != a: break
    print(s[0])

Submission status: Accepted

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

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

#print(A)

B = dict()

MAX = 0

c = 0


for i in A:
    if(c == 0):
        MAX = i[1]
        B[i[0]] = i[1]
        c += 1
    else:
        if(i[1] == MAX):
            B[i[0]] = i[1]
        else:
            break

#print(B)


B_sorted = sorted(B.items(), key=lambda x:x[0])

for i in B_sorted:
    print(i[0])

Submission status: Accepted

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

l = [input() for i in range(n)]
l.sort()
c = Counter(l)

max = c.most_common()[0][1]
outs = []
for k, v in c.most_common():
    if v == max:
        outs.append(k)

outs.sort()
for out in outs:
    print(out)