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:
n=int(input())
max=-1
a=[0]*n
a[0]=1
s =list()
for _ in range(n):
    s.append(input().split())
s.sort()
for i in range(1,n):
    if(s[i-1]==s[i]):
        a[i]=a[i-1]+1
    else:
        a[i]=1
        if max<a[i-1]:
            max=a[i-1]
if max<a[n-1]:
    max=a[n-1]
for i in range(n):
    if(max==a[i]):
        print(*s[i])

Submission status: Accepted

Solution code:
import collections
N = int(input())
s=[]
for i in range(N):
    s.append(input())
c=collections.Counter(s)
values, counts = zip(*c.most_common())
d=collections.Counter(counts)
numberOfMost=d[counts[0]]
ans =sorted([values[i] for i in range(numberOfMost)])
for i in range(numberOfMost):
    print(ans[i])

Submission status: Accepted

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

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

c = collections.Counter(s)
c_m = c.most_common()
max = c.most_common()[0][1]
print()
ans = []
for i in range(len(c_m)):
    if max != c_m[i][1]:
        break
    ans.append(c_m[i][0])
ans.sort()
for i in ans:
    print(i)

Submission status: Accepted

Solution code:
N = int(input())
lists = [list(map(str, input().split())) for i in range(N)]

dict = {}
for i in lists:
    if not i[0] in dict.keys():
        dict[i[0]] = 0
    if i[0] in dict.keys():
        dict[i[0]] += 1

max_index = max(dict.values())
value_ = []
for i, j in dict.items():
    if j == max_index:
        value_.append(i)
value_ = sorted(value_)
# print(value_)

for i in value_:
    print(i)

Submission status: Accepted

Solution code:
from collections import defaultdict

n=int(input())

d=defaultdict(int)


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

m =max(d.values())

for i,j in sorted(d.items()):
    if j == m :print(i)

Submission status: Accepted

Solution code:
from collections import Counter

N = int(input())
S = [input() for _ in range(N)]
Clist = Counter(S).most_common()
num = Clist[0][1]
anses = [Clist[0][0]]
for X in Clist[1:]:
    if X[1] == num:
        anses.append(X[0])
anses.sort()
for ans in anses:
    print(ans)

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 = 0;
for s in d:
    if d[s] > mx:
        mx = d[s];

res = [];

for s in d:
    if d[s] == mx:
        res.append(s);

res.sort();

for s in res:
    print(s);

Submission status: Accepted

Solution code:
import collections

n = int(input())
a = [input() for i in range(n)]
c = collections.Counter(a)

i = 0

common = c.most_common()
common.sort(key = lambda x: x[1], reverse=True)

ans = []

while common[i][1] >= common[0][1]:
	ans.append(common[i][0])

	if i < len(common)-1:
		i += 1
	else:
		break

ans.sort()

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

Submission status: Accepted

Solution code:
n = int(input())
dic = {}
m = 0
for ind in range(n):
    word = input()
    if not word in dic.keys():
        dic[word] = 1
    else:
        dic[word] = dic[word] + 1
    m = max(m, dic[word])

l = []
for key in dic.keys():
    if dic[key] == m:
        l.append(key)
l.sort()
for elm in l:
    print(elm)

Submission status: Accepted

Solution code:
import collections

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

Scol = collections.Counter(S).most_common()
Sset = set([Si[0] for Si in Scol if Si[1]==Scol[0][1]])

print("\n".join(sorted(Sset)))

Submission status: Accepted

Solution code:
n = int(input())

dic = dict()
mode_words = list()

for _ in range(n):
  word = input()
  if word not in dic:
    dic[word] = 1
  else:
    dic[word] += 1

mode = max(dic.values())

for word, times in dic.items():
  if times == mode:
    mode_words.append(word)

mode_words.sort()

for word in mode_words:
  print(word)

Submission status: Accepted

Solution code:
n = int(input())
dic = {}
for _ in range(n):
    s = input()
    if s not in dic:
        dic[s] = 1
    else:
        dic[s] += 1
m = max(dic.values())
anslis = []
for k, v in dic.items():
    if v == m:
        anslis.append(k)
print('\n'.join(sorted(anslis)))

Submission status: Accepted

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


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

    most_counters = collections.Counter(s).most_common()
    most_count = most_counters[0][1]

    for t in sorted(map(lambda x: x[0], filter(lambda x: x[1] == most_count, most_counters))):
        print(t)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
from collections import Counter
n = int(input())
s = []
ans = []
for i in range(n):
  s.append(input())
#s_set = set(s)
s_counter = Counter(s).most_common()
check_num = s_counter[0][1]
#print(s_counter)
for i in s_counter:
  if i[1] == check_num:
    ans.append(i[0])
  else:
    break
ans.sort()
for i in ans:
  print(i)

Submission status: Accepted

Solution code:
N = int(input())
d={}
for x in range(N):
    s = input()
    if d.get(s) is None: d[s] = 1
    else: d[s] += 1
    
m = max(d.values())
ans = []
b={}
for x in d.items():
    if x[1] == m and b.get(x[0]) is None:
        ans.append(x[0])
        b[x[0]] = True
        
print('\n'.join(sorted(ans)))

Submission status: Accepted

Solution code:
from collections import Counter
n = int(input())
list_S = [input() for _ in range(n)]
dic_S = Counter(list_S)
m = 0
for i in dic_S.values():
    m = max(m, i)
ans = []
for k, v in dic_S.items():
    if v == m:
       ans.append(k)
ans.sort()
for s in ans:
    print(s)

Submission status: Accepted

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

dic_S = dict()
set_S = set()
for s in list_S:
    if s in set_S:
        dic_S[s] += 1
    else:
        dic_S[s] = 1
        set_S.add(s)

list_ans = sorted(dic_S.items(), key=lambda x:x[1], reverse=True)
a = 0
ans = []
for i in range(len(list_ans)):
    l = list_ans[i]
    a = max(a, l[1])
    if a <= l[1]:
        ans.append(l[0])
ans.sort()
for s in ans:
    print(s)

Submission status: Accepted

Solution code:

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

d = {}
for st in s:
    d[st] = d.get(st, 0) + 1
#print(d)

t = max(d.values())
ans = []
for p in d:
    if d[p] == t:
        ans.append(p)
#print(ans)

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

Submission status: Accepted

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

s=sorted(s.items(),key=lambda x:(x[1],x[0]))
max=s[-1][1]
for i in s:
	if i[1]==max:
		print(i[0])

Submission status: Accepted

Solution code:
n=int(input())
list1=[]
for i in range(n):
    list1.append(input())
dict1={}
for i in list1:
    if i in dict1:
        dict1[i]+=1
    else:
        dict1[i]=1
dict2={}
for i in dict1:
    if dict1[i] in dict2:
        dict2[dict1[i]].append(i)
    else:
        dict2[dict1[i]]=[]
        dict2[dict1[i]].append(i)
l=sorted(dict2,reverse=True)
for i in l:
    l=sorted(dict2[i])
    break
for i in l:
    print(i)

Submission status: Accepted

Solution code:
N = int(input())
res = dict()
for i in range(N):
  word = input()
  if word not in res:
    res[word] = 0
  res[word] += 1
MAX = max(res.values())
max_word = [word[0] for word in res.items() if word[1] == MAX]
max_word.sort()
for el in max_word:
    print(el)

Submission status: Accepted

Solution code:
N=int(input())
dic={}
for i in range(N):
 a=input()
 if a in dic:
  dic[a]+=1
 else:
  dic[a]=1
c=max(dic.values())
keys = [k for k, v in dic.items() if v == c]
keys.sort()
for j in range(len(keys)):
 print(keys[j])

Submission status: Accepted

Solution code:
x=int(input())
List=[input() for i in range (x)]
List=sorted(List)
sum=-1
count=1
ans=[]
for i in range (x-1):
    if List[i] == List[i+1]:
        count+=1
    elif sum>count:
        count=1
    elif sum==count:
        count=1
        ans+=[List[i]]
    else:
        sum=count
        count=1
        ans=[]
        ans+=[List[i]]
if sum==count:
    ans+=[List[-1]]
elif sum<count:
        sum=count
        count=1
        ans=[]
        ans+=[List[i]]
ans=sorted(ans)
for i in ans:
    print(i)

Submission status: Accepted

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

import collections

c = collections.Counter(l)
#各要素ごとの出現回数

value_max = max(c.values())

#valueで大きい順(降順)にソートする(タプルになる)
for k in sorted(k for k in c if c[k] == value_max ):
    print(k)

Submission status: Accepted

Solution code:
import sys
from collections import Counter

input = sys.stdin.readline

n = int(input())
S = [input().rstrip() for _ in range(n)]

c = Counter(S)
max = max(c.values())

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

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

Submission status: Accepted

Solution code:
import sys
from collections import Counter

input = sys.stdin.readline

n = int(input())
S = [input().rstrip() for _ in range(n)]

c = Counter(S).most_common()

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

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

Submission status: Accepted

Solution code:
N = int(input())
S = []
for _ in range(N):
    S.append(input())
    
import collections
c = collections.Counter(S)
most = c.most_common()
answerlist = [most[0][0]]
i = 0
if len(most) > 1:
    while most[i][1] == most[i+1][1]:
        answerlist.append(most[i+1][0])
        i += 1
        if i == len(most)-1:
            break
sortanswer = sorted(answerlist)
for i in range(len(sortanswer)):
    print(sortanswer[i])

Submission status: Accepted

Solution code:
from collections import Counter
n = int(input())
s = [input() for _ in range(n)]
c = Counter(s)
m = 0
for v in c.values():
	m = max(m, v)
ans = []
for k, v in c.items():
	if v == m:
		ans.append(k)
ans.sort()
print(*ans, sep="\n")

Submission status: Accepted

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

from collections import Counter

word = list(set(words))

dict = Counter(words)

max = max(dict.values())

for a in word:
    if dict[a] == max:
        continue
    else:
        del dict[a]

dict2 = sorted(dict.keys())

for a in dict2:
    print(a)

Submission status: Accepted

Solution code:
def solution():
    n = int(input())
    s = [input() for i in range(n)]
    s.sort()
    ss = [] 
    prev_str = s[0]
    max_cnt = same_cnt = 1
    s.pop(0)
    for si in s:
        if prev_str == si:
            same_cnt += 1
        else:
            ss.append([same_cnt, prev_str])
            if max_cnt < same_cnt:
                max_cnt = same_cnt
            same_cnt = 1
            prev_str = si
    ss.append([same_cnt, prev_str])
    if max_cnt < same_cnt:
        max_cnt = same_cnt
    for sss in ss:
        if sss[0] == max_cnt:
            print(sss[1])

solution()

Submission status: Accepted

Solution code:
import sys
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def dp2(ini, i, j): return [[ini]*i for i2 in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for i2 in range(j)] for i3 in range(k)]
#import bisect #bisect.bisect_left(B, a)
from collections import defaultdict #d = defaultdict(int) d[key] += value
'''
N = ii()
A = li()
 
right = 1
cnt = 0
'''
'''
mae = A[0]
for left in range(N):
    if left==right:
        right += 1
    mae = A[right-1]
    while right < N and A[right] > mae:
        mae = A[right]
        right += 1
    
    #print(left, right, mae)
    cnt += right-left
'''
'''
for left in range(N):
    while right < N and A[right] > A[right-1]:
        right += 1
 
    cnt += right-left
    if left+1 == right:
        right += 1
 
print(cnt)
'''

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

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


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

num = d2[0][1]
ans = []
for i in range(len(d2)):
    if num != d2[i][1]:
        break
    ans.append(d2[i][0])

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

Submission status: Accepted

Solution code:
n=int(input())
s=[input() for i in range(n)]
s=sorted(s)
s.append('')
s1=s[0]
ans=['']
tmp=1
kaisu=0
for i in range(1,n+1):
    if s[i]==s1:
        #ひとつ前と同じものだったら回数を１増やす
        tmp+=1
    else:
        if kaisu<tmp:
        #これまでの要素の最高登場回数よりも
        # 当該要素の登場回数が多ければ
        # リストを書き換える
            ans=['']
            ans.append(s1)
            kaisu=tmp
        elif kaisu==tmp:
        #最高回数と等しければリストに追加する
            ans.append(s1)
        tmp=1
        s1=s[i]
        
for i in range(1,len(ans)):
    print(ans[i])

Submission status: Accepted

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

for st in s:
    d[st] = d.get(st, 0) + 1

t = max(d.values())
ans_append = ans.append

for x in d:
    if d[x] == t:
        ans_append(x)

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

Submission status: Accepted

Solution code:
import collections
n=int(input())
str_list=[input() for i in range(n)]
cal=collections.Counter(str_list)
cal=cal.most_common()
ans=cal[0][1]
answer=cal.sort()

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

Submission status: Accepted

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

import collections

c = collections.Counter(S)

c = dict(c)

value_c = []
for value in c.values():
    value_c.append(value)
max_c = max(set(value_c))

value = []
for item, key in c.items():
    if key == max_c:
        value.append(item)
        
value.sort()
for i in value:
    print(i)

Submission status: Accepted

Solution code:
from collections import defaultdict
S = defaultdict(lambda: 0)
N = int(input())
ma = 0
for _ in range(N):
    s = input()
    S[s] += 1
    ma = max(ma, S[s])
res = [s for (s, cnt) in S.items() if cnt == ma]
res.sort()
print(*res, sep='\n')

Submission status: Accepted

Solution code:
import collections

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

c = collections.Counter(a)
most_count = c.most_common()[0][1]
most_values = []
for i in c.items():
    if i[1] == most_count:
        most_values.append(i[0])

print("\n".join(sorted(most_values)))

Submission status: Accepted

Solution code:
n=int(input())
a_dict={}
for i in range(n):
    a=input()
    if a not in a_dict:
        a_dict[a]=0
    else:
        a_dict[a]+=1
k=max(a_dict.values())
moji=[i for i,j in a_dict.items() if j==k ]
# moji=[]
# j=max(a_dict.values())
# for i,k in a_dict.items():
#     if k==j:
#         moji.append(i)
moji=sorted(moji)
for i in moji:
    print(i)

Submission status: Accepted

Solution code:
n=int(input())
a_dict={}
for i in range(n):
    a=input()
    if a not in a_dict:
        a_dict[a]=0
    else:
        a_dict[a]+=1
# moji=[i for i,j in a_dict.items() if j==max(a_dict.values()) ]
moji=[]
j=max(a_dict.values())
for i,k in a_dict.items():
    if k==j:
        moji.append(i)
moji=sorted(moji)
for i in moji:
    print(i)

Submission status: Accepted

Solution code:
from collections import*;n,*s=open(0);c=Counter(s).most_common();print(*sorted(t for t,i in c if i==c[0][1]))

Submission status: Accepted

Solution code:
import collections
N = int(input()) 
S = [0]*N
m = 0
for i in range(N):
    S[i] = input()
c = collections.Counter(S)
values,counts = zip(*c.most_common())
X = c.most_common()[0][1]
list = []
for i in range(0,len(c.most_common())):
    if counts[i] == X:
        list.append(values[i])
        m+=1
    else:
        break
list.sort()
for i in range(0,m):
    print(list[i])

Submission status: Accepted

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

d = {}
for st in s:
    d[st] = d.get(st, 0) + 1

t = max(d.values())
ans = []
for p in d:
    if d[p] == t:
        ans.append(p)

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

Submission status: Accepted

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

d = {}
for str in s:
    d[str] = d.get(str,0) + 1

t = max(d.values())
ans = []
for p in d:
    if d[p] == t : ans.append(p)

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

Submission status: Accepted

Solution code:
from collections import Counter
n = int(input())
lst = [0]*n
for i in range(n):
    s = input()
    lst[i] = s

c = Counter(lst)
max_num = max(c.values())
most_lst = sorted([k for k, v in c.items() if v == max_num])
for x in most_lst:
    print(x)

Submission status: Accepted

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

lst_af = sorted(lst)

word = lst_af[0]
most_lst = []
most_lst.append(word)
max_num = 1
cnt = 1

for i in range(1, n):
    now_word = lst_af[i]
    if now_word == word:
        cnt += 1
    else:
        cnt = 1
    if max_num == cnt:
        most_lst.append(now_word)
    if max_num < cnt:
        most_lst = []
        most_lst.append(now_word)
        max_num = cnt
    word = now_word

for x in most_lst:
    print(x)

Submission status: Accepted

Solution code:
from collections import Counter

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

c = Counter(s)
m = c.most_common()

top_count = m[0][1]
ans = [m[0][0]]
for word, count in m[1:]:
    if count == top_count:
        ans.append(word)
    else:
        break

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

Submission status: Accepted

Solution code:
n = int( input() )

d ={}
for _ in range( n ):
  s = input()
  if d.get( s ):
    d[ s ] += 1
  else:
    d[ s ] = 1
m = max( d.values() )

l=[]
for k, v in d.items():
  if v == m:
    l.append(k)
l = sorted( l )
for i in l:
  print( i )

Submission status: Accepted

Solution code:
import collections
N = int(input())
S = [""]*N
for i in range(N):
    S[i] = input()
    
c = collections.Counter(S)
an = sorted(c.items(), key=lambda x:x[0])
ans = sorted(an, key=lambda x:x[1], reverse=True)

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

Submission status: Accepted

Solution code:
n = int(input())
l = [input() for i in range(n)]
d = {}
for i in l:
    if i in d:
        d[i] += 1
    else:
        d[i] = 1
d_max = max(d.values())
for i in sorted(d):
    if d[i] == d_max:
        print(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)
values,counts = zip(*c.most_common())
m = 0
for j in range(1,len(values)):
    if len(values) == 1:
        break
    if counts[j-1] != counts[j]:
        break
    m+=1
common = []
for n in range(m+1):
    common.append(values[n])
new = sorted(common)
for u in range(m+1):
    print(new[u])

Submission status: Accepted

Solution code:
import bisect
import heapq
import sys
import queue


input = sys.stdin.readline
sys.setrecursionlimit(100000)


class V:
    def __init__(self, f):
        self.f = f
        self.v = None

    def __str__(self):
        return str(self.v)

    def ud(self, n):
        if self.v is None:
            self.v = n
        else:
            self.v = self.f(self.v, n)

    def get(self):
        return self.v


def read_values():
    return map(int, input().split())


def read_list():
    return list(read_values())


def main():
    N = int(input())
    D = {}
    for _ in range(N):
        s = input().strip()
        D[s] = D.setdefault(s, 0) + 1

    vm = max(D.values())
    ks = [k for k, v in D.items() if v == vm]
    ks.sort()
    print("\n".join(ks))


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
n=int(input())
s={}
for _ in range(n):
    a=str(input())
    s[a]=s.get(a,0)
    s[a]+=1
t=(max(s.values()))
ans=[]
for k in s:
  if s[k]==t:
    ans.append(k)
ans.sort()
print(*ans)

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

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())
S = sorted([input() for _ in range(N)]) + ['']
ans = []
tmpnum = 1
tmpmax = 1

for i in range(1, N+1):
    if S[i] == S[i-1]:
        tmpnum += 1
    else:
        if tmpnum == tmpmax:
            ans.append(S[i-1])
            tmpnum = 1
        elif tmpnum > tmpmax:
            tmpmax = tmpnum
            ans = [S[i-1]]
            tmpnum = 1
        else:
            tmpnum = 1

for i in ans:
    print(i)

Submission status: Accepted

Solution code:
from collections import Counter
lst=[]
for i in range(int(input())):
    lst.append(input())
dic=Counter(lst)
lst=dic.most_common()
lst2=[]
for i in lst:
    if i[1]==lst[0][1]:
        lst2.append(i[0])
lst2.sort()
for i in lst2:
    print(i)

Submission status: Accepted

Solution code:
n = int(input())
s = [input() for i in range(n)]
from collections import Counter
s1 = Counter(s)
max_s = max(s1.values())
ans = []
for k,v in s1.items(): 
    if v == max_s:
        ans.append(k)
ans.sort()
for a in ans:
    print(a)

Submission status: Accepted

Solution code:
from collections import Counter
n = int(input())
d = [input() for _ in range(n)]
c = Counter(d)
m = c.most_common()[0][1]

ans = []
for k, v in c.items():
    if v == m:
        ans.append(k)
ans.sort()
for a in ans:
    print(a)

Submission status: Accepted

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

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

ans = []
mx = 0
for key, value in a.items():
    if mx < value:
        mx = value
        ans = [key]
    elif mx == value: ans.append(key)

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

Submission status: Accepted

Solution code:
from collections import Counter
n = int(input())
s = [input() for i in range(n)]
mc = Counter(s).most_common()
ans = [i[0] for i in mc if i[1] == mc[0][1]]
ans.sort()
for i in ans:
    print(i)

Submission status: Accepted

Solution code:
from collections import Counter
n = int(input())
s = [input() for i in range(n)]
c = Counter(s)
mc = c.most_common()
ans = [i[0] for i in mc if i[1] == mc[0][1]]
ans.sort()
for i in ans:
    print(i)

Submission status: Accepted

Solution code:
from collections import Counter

N = int(input())
l = []
for _ in range(N):
    l.append(input())
c = Counter(l)
max_count = c.most_common()[0][1]


output = []
for v in c.most_common():
    if v[1] == max_count:
        output.append(v[0])
    else:
        break

output.sort()
for elem in output:
    print(elem)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))

n = ii()
count = {}
cmax = 0
for i in range(n):
    s = input()
    c = count.get(s,0)+1
    cmax = max(c,cmax)
    count[s] = c
ans = sorted([kv[0] for kv in count.items() if kv[1] == cmax])
for item in ans:
    print(item)

Submission status: Accepted

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

for i in s:
    if i in dic.keys():
        dic[i] += 1
    else:
        dic[i] = 1
result = []
num = 0
for i in dic.keys():
    if dic[i] > num:
        result = []
        result.append(i)
        num = dic[i]
    elif dic[i] == num:
        result.append(i)
result.sort()
for i in result:
    print(i)

Submission status: Accepted

Solution code:
import collections
N = int(input())
l = [input() for i in range(N)]
L = collections.Counter(l)
a = L.most_common()
M = a[0][1]
A = [j[0] for j in a if j[1] == M]
[print(k) for k in sorted(A)]

Submission status: Accepted

Solution code:
N=int(input())
dic={}
for _ in range(N):
  S=input()
  if S in dic:
    dic[S]+=1
  else:
    dic[S]=1
ls=list(dic.items())
ls.sort()
ls=sorted(ls, key=lambda x:-x[1])
a=ls[0][1]
for i in range(len(ls)):
  if ls[i][1]==a:
    print(ls[i][0])

Submission status: Accepted

Solution code:
from collections import defaultdict

N = int(input())
S = [input() for _ in range(N)]
Sd = defaultdict(int)
for i in S:
    Sd[i] += 1
Sd = sorted(Sd.items(), key = lambda x: x[1], reverse=True)

maxv = Sd[0][1]
ans = []
for i, j in Sd:
    if maxv != j:
        break
    else:
        ans.append(i)

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

Submission status: Accepted

Solution code:
N=int(input())
S=[]
for i in range(N):
    S.append(input())
S.sort()
T=sorted(set(S))

cnt=0
i=0
cnt_array=[0]*(len(T))
while cnt<len(T) and i<N:
    if S[i]==T[cnt]:
        cnt_array[cnt]+=1
        i+=1
    else:
        cnt+=1

M=max(cnt_array)
for i in range(len(T)):
    if cnt_array[i]==M:
        print(T[i])

Submission status: Accepted

Solution code:
N = int(input())

# 文字列の出現回数を格納
S = {}
for _ in range(N):
    s = input()
    if s in S:
        S[s] += 1
    else:
        S[s] = 1

# 出現回数が最大の文字列をansに格納し、昇順にソートする
# ans = [k for k, v in S.items() if v == max(S.values())]
# ans.sort()
max_value = max(S.values())
ans = sorted([k for k, v in S.items() if v == max_value])

# 出力
for a in ans:
    print(a)

Submission status: Accepted

Solution code:
n = int(input())
s = [""] * n
for i in range(n):
    s[i] = input()
s = sorted(s)
t = 1
tmax=1
for i in range(1, n):
    if s[i-1] == s[i]:
        t += 1
        tmax=max(tmax,t)
    else:
        t = 1
        tmax = max(tmax, t)
t = 1
if tmax == 1:
    for i in range(n):
        print(s[i])
    exit()
if tmax == n:
    print(s[0])
    exit()
for i in range(1,n):
    if s[i-1] == s[i]:
        t += 1
    else:
        t=1
    if t == tmax:
        print(s[i])

Submission status: Accepted

Solution code:
import pdb

N = int(input())
i = 0
list = [0] * N

while i < N:
  list[i] = input()
  i += 1

list.sort()
k = 1
count_list = [0]*N
count_list[0] = 1
ans_list = [0] * N
ans_list[0] = list[0]
l = 0



while k < N:
  if list[k] != list[k-1]:
    l +=1
    ans_list[l] = list[k]

  count_list[l] += 1
  k += 1

s = max(count_list)

for i in range(N):
  if count_list[i] == s:
    print(ans_list[i])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#300
N = int(input())
S = [input() for _ in range(N)]
L = [0 for _ in range(N)]
L1 = ["" for _ in range(N)]
S.sort()
k = 0


for i in range(N):
    if i == 0:
        L[k] = 1 
        L1[k] = S[i]
    else:
        if S[i-1] == S[i]:
            L[k] = L[k] + 1
        else:
            L[k+1] = 1
            L1[k+1] = S[i]
            k += 1

m = max(L)
for i in range(N):
    if L[i] == m:
        print(L1[i])

Submission status: Accepted

Solution code:
from collections import defaultdict
n = int(input())
strings = defaultdict(int)
for i in range(n):
    strings[input()] += 1
max_value = max(value for value in strings.values())
for i in sorted(key for key, value in strings.items() if value==max_value):
    print(i)

Submission status: Accepted

Solution code:
def resolve():
    N = int(input())
    from collections import defaultdict
    cnt = defaultdict(int)
    for _ in range(N):
        cnt[input()] += 1
    items = sorted(cnt.items(), key=lambda x: (-x[1], x[0]))
    max_v = items[0][1]
    for item in items:
        if max_v != item[1]:
            break
        print(item[0])

resolve()

Submission status: Accepted

Solution code:
from collections import defaultdict
from collections import OrderedDict

N = int(input())

words = dict()
wordsFromValue = defaultdict(list)

for idx in range(N) :
  word = str(input())
  
  if word in words :
    words[word] += 1
  else :
    words[word] = 1
  
for key, value in sorted(words.items()) :
  wordsFromValue[value].append(key)
  
for val in wordsFromValue[max(wordsFromValue)] : 
  print(val)

Submission status: Accepted

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


s=collections.Counter(S).most_common()
s.sort(key=lambda x: x[0])
s.sort(key=lambda x: x[1], reverse=True)
for k, v in s:
    if v==s[0][1]:
        print(k)
    else:
        break

Submission status: Accepted

Solution code:
N=int(input())
S=[input() for i in range(N)]
cnt={}
maxCnt=0
for s in S:
    if s in cnt:
        cnt[s]+=1
    else:
        cnt[s]=1
    if(cnt[s]>maxCnt):
        maxCnt=cnt[s]
for s in sorted(cnt.keys()):
    if cnt[s]==maxCnt:
        print(s)

Submission status: Accepted

Solution code:
# coding: utf-8
import collections

n = int(input())
# 複数行標準入力
S = []
for _ in range(n):
    S.append(input())  # S += [input()] とも書ける

c = collections.Counter(S)
m = c.most_common()[0][1]
ans = []
for _c in c.items():
    if _c[1] == m:
        ans.append(_c[0])

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

Submission status: Accepted

Solution code:
from collections import Counter

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

c = Counter(s)
c = c.most_common()
c.sort(key=lambda x: x[0])
c.sort(key=lambda x: x[1], reverse=True)

most_cnt = c[0][1]
for key, cnt in c:
    if cnt == most_cnt:
        print(key)
    else:
        break

Submission status: Accepted

Solution code:
str_list = []
n = int(input())
a = {}
name_list = []
for i in range(n):
    name = input()
    a[name] = 0
    name_list.append(name)
    
    
#a = {}
for i in name_list:
    a[i] += 1
    
    
max_val = max(a.values())
a = sorted(a.items())
for i in range(len(a)):
    if a[i][1] == max_val:
        print(a[i][0])

Submission status: Accepted

Solution code:
from collections import Counter
N = int(input())
S = []
for _ in range(N):
  S.append(input())
C = Counter(S).most_common()
_,M = C[0]
L = []
for a,b in C:
  if b == M:
    L.append(a)
print(*sorted(L) ,sep = "\n")

Submission status: Accepted

Solution code:
from collections import defaultdict
from collections import OrderedDict

N = int(input())

words = dict()
wordsFromValue = defaultdict(list)

for idx in range(N) :
  word = str(input())
  
  if word in words :
    words[word] += 1
  else :
    words[word] = 1
  
for key, value in sorted(words.items()) :
  wordsFromValue[value].append(key)
  

for val in wordsFromValue[max(wordsFromValue)] : 
  print(val)