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:
import collections
# from collections import OrderedDict

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

c = collections.Counter(S)
# max_vale = c.most_common()[0][1]
max_vale = max(c.values())

hoge = []
for k, v in c.items():
    if max_vale == v:
        hoge.append(k)

hoge = sorted(hoge)
for i in hoge:
    print(i)



# for i in c.most_common():
#     print(i)

Submission status: Accepted

Solution code:
import collections
# from collections import OrderedDict

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

c = collections.Counter(S)
max_vale = c.most_common()[0][1]

hoge = []
for k, v in c.items():
    if max_vale == v:
        hoge.append(k)

hoge = sorted(hoge)
for i in hoge:
    print(i)



# for i in c.most_common():
#     print(i)

Submission status: Accepted

Solution code:
from collections import Counter

n = int(input())
S = []
for _ in range(n):
    S.append(input())  # S += [input()] とも書ける

# 要素数チェック
counter = Counter(S)
# 要素数最大の要素を全て取得する->リスト
mostnum = 0
ans = []
for c in counter.most_common():
    if mostnum <= c[1]:
        mostnum = c[1]
        ans.append(c[0])
    else:
        break
# リストを辞書順に並び替える
ans.sort()
# リストを改行で出力
for a in ans:
    print(a)

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(12345678)
import itertools
from collections import Counter
from collections import defaultdict
from collections import deque
import bisect
from heapq import heappush, heappop


def main():
    n = int(input())
    dic = defaultdict(lambda: 0)
    count = 0
    for _ in range(n):
        s = input()
        dic[s] += 1
        count = max(count, dic[s])

    candidates = []
    for key in dic.keys():
        if dic[key] == count:
            candidates.append(key)

    candidates.sort()
    for c in candidates:
        print(c)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import collections

def resolve():
    N = int(input())
    S_list = []
    for i in range(N):
        S_list.append(input())
    
    cc = collections.Counter(S_list)
    cc_list = cc.most_common()

    most_num = cc_list[0][1]
    tmp_list = []

    for i in cc_list:
        if most_num == i[1]:
            tmp_list.append(i[0])
        else:
            break

    tmp_list_sorted = sorted(tmp_list)
    for tls in tmp_list_sorted:
        print(tls)


if __name__ == "__main__":
    resolve()

Submission status: Accepted

Solution code:
N = int(input())
count = {}
for _ in range(N):
    s = str(input())
    if s in count.keys():
        count[s] += 1
    else:
        count[s] = 1

max_value = max(count.values())
max_key_list = [kv[0] for kv in count.items() if kv[1] == max_value]
max_key_list.sort()
for key in max_key_list:
    print(key)

Submission status: Accepted

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

c = Counter(S)
cnt = 1
c = c.most_common()
for i in range(len(c)-1):
    if c[i][1] == c[i+1][1]:
        cnt += 1
    else:
        break
ans_list = [""] * cnt
for i in range(cnt):
    ans_list[i] = c[i][0]
ans_list.sort()
for i in range(cnt):
    print(ans_list[i])

Submission status: Accepted

Solution code:
import collections
N = int(input())
listA = []
listB = []
for i in range(N):
    listA.append(input())
c = collections.Counter(listA)
c = c.most_common()
max_number = c[0][1]
listB.append(c[0][0])
A = len(c)
for i in range(1,A):
    if max_number == c[i][1]:
        listB.append(str(c[i][0]))
    else:
        break
listB.sort()
for i in listB:
    print(i)

Submission status: Accepted

Solution code:
countStr = {}
maxKeys = []

n = int(input())

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

maxValue = max(countStr.values())

countStr = list(countStr.items())

for i in countStr:
    if i[1] == maxValue:
        maxKeys.append(i[0])

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

Submission status: Accepted

Solution code:
from collections import Counter

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

cnt = Counter(s).most_common()

res = [cnt[0][0]]
if len(cnt) > 1:
    for i in range(1, n):
        if cnt[i-1][1] == cnt[i][1]:
            res.append(cnt[i][0])
        else:
            break

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

Submission status: Accepted

Solution code:
from collections import Counter

N = int(input())
c = Counter([input() for _ in range(N)])
mv = max(c.values())
[print(w) for w in sorted(c.keys()) if c[w] == mv]

Submission status: Accepted

Solution code:
N = int(input())
d = {}
mv = 0
mfw = []
for _ in range(N):
    w = input()
    d[w] = d.get(w, 0) + 1
    if d[w] > mv:
        mv += 1
        mfw.clear()
        mfw.append(w)
    elif d[w] == mv:
        mfw.append(w)
[print(w) for w in sorted(mfw)]

Submission status: Accepted

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

d = {}
for s in S:
  if s in d:
    d[s] += 1
  else:
    d[s] = 1
d = sorted(d.items(), key = lambda x:(-x[1],x[0]))

for di in d:
  if di[1] == d[0][1]:
    print(di[0])
  else:
    break

Submission status: Accepted

Solution code:
n = int(input())

words = {}
for i in range(n):
    str = input()
    if words.get(str) is None:
        words[str] = 1
    else:
        words[str] += 1
        
max_num = max(words.values())
max_items = []

for x in words.items():
    if x[1] >= max_num:
        max_items.append(x[0])

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

Submission status: Accepted

Solution code:
# TODO:review test cases (https://www.dropbox.com/sh/arnpe0ef5wds8cv/AAAk_SECQ2Nc6SVGii3rHX6Fa?dl=0)

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

# f = open('sub1_19.txt')
# n = int(f.readline().replace('\n',''))
# Strings = [f.readline().replace('\n','') for _ in range(n)]

dic = {}

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

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

for s in dic:
    if dic[s] == maxValue:
        ans.append(s)

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

Submission status: Accepted

Solution code:
from collections import Counter
n=int(input())
a=[]
for _ in range(n):
  a.append(input())
x=Counter()
for i in a:
  x[i]+=1
maxi=0
for i in x.keys():
  maxi=max(maxi,x[i])
ans=[]
for i in x.keys():
  if maxi==x[i]:
    ans.append(i)

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

Submission status: Accepted

Solution code:
from collections import*
n,*s=open(0)
c=Counter(s)
mc=c.most_common()
ans=sorted(s*(t==mc[0][1])for s,t in mc)
for a in ans:
    print(a,end="")

Submission status: Accepted

Solution code:
N = int(input())
S = []
for i in range(N):
    S.append(input())
S.sort()
MAX = 0
cnt = 0
WORD = []
for i in range(N):
    if i == 0:
        cnt = 1
        MAX = 1
        WORD.append(S[i])
    elif S[i] == S[i-1]:
        cnt+=1
        if cnt == MAX:
            WORD.append(S[i])
        if cnt > MAX:
            MAX = cnt
            WORD.clear()
            WORD.append(S[i])
    else:
        cnt = 1
        if cnt == MAX:
            WORD.append(S[i])

for ans in WORD:
    print(ans)

Submission status: Accepted

Solution code:
from collections import Counter

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

counter = Counter(S)
m = max(counter.values())

for name in counter.keys():
    if m==counter[name]:
        result.append(name)

result_sort=sorted(result)

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

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
from collections import defaultdict
n=int(input())
dic=defaultdict(int)
for i in range(n):
   dic[input()]+=1
m=max(dic.values())
for k in sorted(dic.keys()):
  if dic[k]==m:
    print(k)

Submission status: Accepted

Solution code:
import collections

ans = []
n = int(input())
s = [input() for _ in range(n)]
dic = collections.Counter(s).most_common()
max_num = dic[0][1]
for k, v in dic:
    if v == max_num:
        ans.append(k)
    else:
        break
ans.sort()
print("\n".join(ans))

Submission status: Accepted

Solution code:
import collections
n = int(input())
s = [input() for _ in range(n)]
c = collections.Counter(s)
C = c.most_common()
most_count = C[0][1]
answer = []

for i in range(len(C)):
  if most_count == C[i][1]:
    answer.append(C[i][0])

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

Submission status: Accepted

Solution code:
from collections import Counter

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

s = Counter(S)
max_cnt = s.most_common()[0][1]
names = [name for name, cnt in s.items() if cnt == max_cnt]
names.sort()

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

Submission status: Accepted

Solution code:
from collections import Counter

n = int(input())
s = [input() for i in range(n)]
c = Counter(s)
c.most_common()
ans = []
m = -1
for i, item in enumerate(c.most_common()):
    if i == 0:
        m = item[1]
        ans.append(item[0])
    elif item[1] == m:
        ans.append(item[0])
    else:
        break
ans.sort()
print(*ans, sep='\n')

Submission status: Accepted

Solution code:
from collections import Counter

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

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

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

Submission status: Accepted

Solution code:
N=int(input())
S = {}
for i in range(N):
    let = input()
    try:
        S[let] += 1
    except:
        S[let] = 1
max_val = max(S.values())
answers = []
for k,v in S.items():
    if v == max_val:
        answers.append(k)
answers.sort()
for ans in answers:
    print(ans)

Submission status: Accepted

Solution code:
def list_count(my_list):
    dic={} #辞書型の宣言
    for num in my_list:
        if num in dic: #もしnumがkeyとして辞書にあれば
            dic[num]+=1 #valueに+1
        else: #なければ
            dic[num]=1 #dicにnumというkeyを追加し、対応するvalueを1とする
    return dic
n=int(input())
a=[input() for i in range(n)]
b=list_count(a)
m=max(b.values())
c=[]
#print(b)
for i in range(n):
    #print(a[i],b[a[i]],m)
    if b[a[i]]==m:
        c.append(a[i])
c=sorted(list(set(c)))
for s in c:
    print(s)

Submission status: Accepted

Solution code:
N = int(input())

_dict = {}
max_cnt = 0
for n in range(N):
  _ = input()
  if _ not in _dict:
    _dict[_] = 1
  else:
    _dict[_] += 1
    
  if _dict[_] > max_cnt:
    max_cnt = _dict[_]


ans = [k for k, v in _dict.items() if v == max_cnt]
ans.sort()
for _ in ans:
  print(_)

Submission status: Accepted

Solution code:
import collections

n = int(input())

S = []
ans = []
key = []
max = 0
for i in range(n):
    s = input('')
    S.append(s)
c = collections.Counter(S)
C = sorted(c.items(), key = lambda x:x[1],reverse = True)
#keys = c.keys()
for k in c.keys():
    key.append(k)
for i in range(len(C)):
    max = C[0][1]
    if c[key[i]] == max:
        ans.append(key[i])
ans = sorted(set(ans))
for i in ans:
    print(i)

Submission status: Accepted

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

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

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

result.sort()

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

Submission status: Accepted

Solution code:
import collections
N = int(input())
S = [input() for _ in range(N)]
c = collections.Counter(S)
C=c.most_common()
result = []
for i in range(len(C)):
  if C[i][1] == C[0][1]:
    result.append(C[i][0])
  else:
    break
result.sort()
for j in range(len(result)):
  print(result[j])

Submission status: Accepted

Solution code:
import collections

def solve(N, Ss):
    counter = collections.Counter()
    counter.update(Ss)
    max_count = counter.most_common()[0][1]
    ans = []
    for s, count in counter.most_common():
        if count == max_count:
            ans.append(s)

    return "\n".join(sorted(ans))

if __name__ == "__main__":
    N = int(input())
    Ss = []
    for _ in range(N):
        Ss.append(input())
    print(solve(N, Ss))

Submission status: Accepted

Solution code:
import collections
n = int(input())
s_list = [input() for i in range(n)]
c_dict = collections.Counter(s_list).most_common()
ans_list = [c[0] for c in c_dict if c[1] == c_dict[0][1]]
print(*sorted(ans_list), sep="\n")

Submission status: Accepted

Solution code:
n = int(input())

s = {}

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

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

Submission status: Accepted

Solution code:
from sys import stdin, stdout
from collections import defaultdict
n = int(stdin.readline().strip())
word_map = defaultdict(lambda: 0)
maxi = 0
for i in range(n):
  word = stdin.readline().strip()
  x = word_map[word]
  word_map[word] = x + 1
  maxi = max(maxi, x+1)
  
word_list = []
for key, value in word_map.items():
  if value == maxi:
    word_list.append(key)
word_list.sort()
for word in word_list:
  stdout.write(word+'\n')

Submission status: Accepted

Solution code:
n = int(input())

s_cnt = {}
for _ in range(n):
    s = input()
    if s in s_cnt.keys():
        s_cnt[s] += 1
    else:
        s_cnt[s] = 1

data = sorted(s_cnt.items(),
              key=lambda item: (-item[1], item[0]), reverse=True)

val = data[-1][1]
for item in reversed(data):
    if item[1] != val:
        break
    print(item[0])

Submission status: Accepted

Solution code:
import collections

N = int(input())
A =[]
for i in range(N):
    A.append(input())
    
ans =[]
c = collections.Counter(A)
m = c.most_common()
ma = m[0][1]

for i in range(len(m)):
    if m[i][1] == ma:
        ans.append(m[i][0])
ans.sort()

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

Submission status: Accepted

Solution code:
import collections

N = int(input())
A =[]
for i in range(N):
    A.append(input())
    
ans =[]
c = collections.Counter(A)
m = c.most_common()
ma = m[0][1]

for i in range(len(m)):
    if m[i][1] == ma:
        ans.append(m[i][0])
ans.sort()

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

Submission status: Accepted

Solution code:
d = {}
n = int(input())
for _ in range(n):
    let = input()
    try:
        d[let] += 1
    except:
        d[let] = 1
max_val = max(d.values())
print('\n'.join(sorted(key for key in d if d[key] == max_val)))

Submission status: Accepted

Solution code:
import collections

n = int(input())
strings = list()
for line in range(0,n):
    strings.append(str(input()))

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

outputs = list()
for key , val in c.items():
    if val == most_common:
        outputs.append(key)

outputs = sorted(outputs)
for line in outputs:
    print(line)

Submission status: Accepted

Solution code:

#gcdは3.4.3だとfractionsにある
from fractions import gcd
import math

from math import factorial as f

from math import ceil,floor,sqrt


import bisect
import re
import heapq


from copy import deepcopy
import itertools

from sys import exit

ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))

yes = 'APPROVED'
no = 'DENIED'

def main():
    n = ii()
    s = []
    for i in range(n):
        tmp = input()
        s.append(tmp)
    
    s = sorted(s)

    anslist = []

    cnt = 0
    cntmax = 0
    tmp = ""
    for i in range(n):
        if cntmax == 0:
            anslist.append(s[i])
        if s[i] == tmp:
            cnt+=1
            if cntmax == cnt:
                anslist.append(s[i])
            if cntmax < cnt:
                cntmax = cnt
                anslist = [s[i]]
        else:
            cnt = 0
            tmp = s[i]
    for i in range(len(anslist)):
        print(anslist[i])



main()

Submission status: Accepted

Solution code:
N = int(input())
s = [input() for i in range(N)]
import collections
s1 = sorted(s)
 
c = collections.Counter(s1)
s2 = c.most_common()
 
s3 = []
a = 0
for i in range(len(s2)):
    if s2[0][1] == s2[i][1]:
        s3.append(s2[i][0])
s4 = sorted(s3)
for i in range(len(s4)):
    print(s4[i])

Submission status: Accepted

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

count = collections.Counter(temp)
counter = 1
ll = count.most_common()
for i in range(len(ll) -1):
    if ll[i][1] == ll[i + 1][1]:
        counter += 1
    else:
        break

l = count.most_common(counter)
l.sort()
for i in range(len(l)):
    print(l[i][0])

Submission status: Accepted

Solution code:
import collections
n = int(input())
S = [input() for i in range(n)]
c = collections.Counter(S)
li = c.most_common()
M = li[0][1]
ans = []
for x in li:
    if x[1] == M:
        ans.append(x[0])
    else:
        break
ans.sort()
for x in ans:
    print(x)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
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:
from collections import Counter


def main():
    N = int(input())
    A = [input() for _ in range(N)]

    C = Counter(A)
    most_c = C.most_common()
    max_num = most_c[0][1]
    ANS = []
    for c in most_c:
        if c[1] < max_num:
            break
        ANS.append(c[0])
    ANS.sort()
    for ans in ANS:
        print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
from collections import Counter


def main():
    N = int(input())
    A = [input() for _ in range(N)]

    c = Counter(A)
    max_num = c.most_common()[0][1]
    ANS = [i[0] for i in c.items() if i[1] == max_num]
    ANS.sort()
    for ans in ANS:
        print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
# coding: utf-8

n = input()
ss = [raw_input() for _ in xrange(n)]

ws = {}
for s in ss:
    if s not in ws:
        ws[s] = 1
    else:
        ws[s] += 1

m = max(ws[k] for k in ws)
for x in sorted(k for k in ws if ws[k] == m):
    print x

Submission status: Accepted

Solution code:
from collections import Counter


def main():
    N = int(input())
    A = [input() for _ in range(N)]

    C = Counter(A)
    most_c = C.most_common()
    max_num = most_c[0][1]
    ANS = []
    for c in most_c:
        if c[1] < max_num:
            break
        ANS.append(c[0])
    for ans in sorted(ANS):
        print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
from collections import Counter


def main():
    N = int(input())
    A = [input() for _ in range(N)]

    c = Counter(A)
    d = c.most_common()
    ans = [i[0] for i in c.items() if i[1] == d[0][1]]
    for i in sorted(ans):
        print(i)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
from collections import Counter


def main():
    N = int(input())
    A = [input() for _ in range(N)]

    c = Counter(A)
    d = c.most_common()
    ans = []
    for i in c.items():
        if i[1] == d[0][1]:
            ans.append(i[0])
    for i in sorted(ans):
        print(i)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import collections
from sys import stdin
N = int(stdin.readline().rstrip())
data = []
for i in range(N):
    s = (stdin.readline().rstrip())
    data.append(s)
c = collections.Counter(data)
maxc = max(c.values())
for j in sorted(c.keys()):
    if c[j] == maxc:
        print(j)

Submission status: Accepted

Solution code:
# coding: utf-8
import collections

N = int(input())
S=[]
l=[]

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

m=max(c.values())

for i in c:
    if c[i]==m:
        l.append(i)

l.sort()

for i in l:
    print(i)

Submission status: Accepted

Solution code:
N=int(input())
dc={}
for i in range(N):
    key=input()
    if key not in dc:
        dc[key]=1
    else:
        dc[key]+=1
max=0
lst=[]
for i in dc:
  if dc[i]>max:
    max=dc[i]
    lst.clear()
    lst.append(i)
  elif dc[i]==max:
    lst.append(i)
lst.sort()
for i in lst:
  print(i)

Submission status: Accepted

Solution code:
import sys
import collections
N = int(input())
strs = []
for _ in range(N):
  s = input()
  strs.append(s)
#print('strs', strs)
c = collections.Counter(strs)
maxv = -1
ans = []
for k , v in c.most_common():
  if v != maxv and maxv != -1:
    break
  ans.append(k)
  maxv = v
for a in sorted(ans):
  print(a)

Submission status: Accepted

Solution code:
def calc(N, S):
    d = {}
    n_max = 0
    for s in S:
        d[s] = 1 + (d[s] if s in d else 0)
        n_max = max(n_max, d[s])
    result = [s for s in d.keys() if d[s] == n_max]
    result.sort()
    return '\n'.join(result)


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

Submission status: Accepted

Solution code:
import sys
import math
import fractions
from collections import deque
from collections import defaultdict
sys.setrecursionlimit(10**7)

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

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

max = S[0][1]
for k, v in S:
    if max != v:
        sys.exit()
    print(k)

Submission status: Accepted

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

T = [[S[0]]]
for i in S[1:N]:
  if i == T[-1][-1]:
    T[-1].append(i)
  else:
    T.append([i])
T.sort(key=lambda x: len(x))
U = []

for i in T[::-1]:
  if len(i) == len(T[-1]):
    U.append(i[0])
  else:
    break

U.sort()
for x in U:
  print(x)

Submission status: Accepted

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

from collections import Counter
dict_C = Counter(list_S)
max = max(dict_C.values())

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

for ans in keys :
    print(ans)

Submission status: Accepted

Solution code:
N = int(input())
ans = {}
for i in range(N):
    a = input()
    ans[a] = ans.get(a,0) + 1

t = max(ans.values())
ans2 = [k for k, v in ans.items() if v ==t ]
ans2.sort()
[print(i) for i in ans2]

Submission status: Accepted

Solution code:
N = int(input())

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

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

Submission status: Accepted

Solution code:
n = int(input())
s = {}
m = 1
for _ in range(n):
    t = input()
    if t in s:
        s[t] += 1
        if s[t] > m:
            m = s[t]
    else:
        s.update({t : 1})
ans = [i for i, j in s.items() if j == m]
ans.sort()
for i in ans:
    print(i)

Submission status: Accepted

Solution code:
n = int(input())

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

max_v = max(list(votes.values()))
res = [k for k,v in votes.items() if v == max_v]

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

Submission status: Accepted

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

for n in range(N):
    S = input()

    if S in S_dic:
        S_dic[S] += 1
    else:
        S_dic[S] = 1


# 最大のvalueを取得する
max_value = max(S_dic.values())

max_S_list = [k for k, v in S_dic.items() if v == max_value]
max_S_list = sorted(max_S_list)

for max_S in max_S_list:
    print(max_S)

Submission status: Accepted

Solution code:
from collections import Counter
def main(n,s):
    c = Counter(s)
    maxVal = max(c.values())
    res = sorted([k for k,v in c.items() if v == maxVal])
    return res

n = int(input())
s = [input() for _ in range(n)]
for i in main(n,s):
    print(i)

Submission status: Accepted

Solution code:
import collections
import heapq

n = int(input())
l = [input() for _ in range(n)]
c = collections.Counter(l)
max_count = 0
ans = []
for word, count in c.most_common():
  if(max_count <= count):
    heapq.heappush(ans, word)
    max_count = count
  else:
    break
for _ in range(len(ans)):
  print(heapq.heappop(ans))

Submission status: Accepted

Solution code:
import collections
strlist = []
answer = []
N = int(input())
for i in range(N):
    strlist.append(str(input()))
    
c = collections.Counter(strlist)
p = max(c.values())
ans = sorted([k for k,v in c.items() if p==v])
print('\n'.join(ans))

Submission status: Accepted

Solution code:
n = int(input())
dic = {}
list = []

maxnum=0

for i in range(0,n,1):
	name = input()
	
	if name in dic:
		dic[name] = dic[name]+1
	else:
		dic[name] = 1
	
	if dic[name] > maxnum:
		maxnum = dic[name]

for name in dic.keys():
	if dic[name] == maxnum:
		list.append(name)
		
for i in sorted(list):
	print(i)

Submission status: Accepted

Solution code:
from collections import Counter

N = int(input())
S = [input() for _ in range(N)]
c = Counter(S)
m = max(c.values())
ans = sorted([k for k,v in c.items() if m==v])
print('\n'.join(ans))

Submission status: Accepted

Solution code:
N = int(input())

cdic = {}
for i in range(N):
    si = input()
    if si not in cdic.keys():
        cdic[si] = 1
    else:
        cdic[si] += 1
        
spair = sorted(cdic.items(), key=lambda x:x[1], reverse=True)


# print(cdic)
# print(spair)


vmax = -1
maxes = []
for pair in spair:
    if pair[1] >= vmax:
        maxes.append(pair[0])
        vmax = pair[1]
    else:
        break
        
# print(maxes)
smaxes = sorted(maxes)
# print(smaxes)
# print('---')

for s in smaxes:
    print(s)

Submission status: Accepted

Solution code:
n = int(input())

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

maxi = 0
lst = []
for key in dic.keys():
    if dic[key] > maxi:
        maxi = dic[key]
        lst = [key]
    elif dic[key] == maxi:
        lst.append(key)

lst = sorted(lst)
for i in lst:
    print(i)

Submission status: Accepted

Solution code:
#C-Poll
import collections
n=int(input())
words = [input() for _ in range(n)]
count = collections.Counter(words)
leng = len(count)
ansallay = []
#抽出用に何回出てればansに出すかを変数に突っ込む
record = count.most_common()[0][1]
ms=count.most_common()
for num in range(leng):
    if(ms[num][1] == record):
        ansallay.append(ms[num][0])
    else:
        break
ansallay.sort()
for word in ansallay:
    print(word)

Submission status: Accepted

Solution code:
import math
import sys

max=0
N = int(input())
dict = {}
for _ in range(N):
    S = input()
    # print(S)
    if S in dict:
        dict[S] = dict[S] + 1
    else:
        dict[S] = 1

    if max < dict[S]:
        max = dict[S]

    # print(S,dict[S])

lists = []
for s, n in dict.items():
    if n == max:
        lists.append(s)

lists.sort()
for s in lists:
    print(s)

Submission status: Accepted

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


M = max(Sdict.values())
ans = []
for k in Sdict.keys():
    if Sdict[k] == M:
        ans.append(k)

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

Submission status: Accepted

Solution code:
N = int(input())
S = {}
name_list = []
for i in range(N):
  name = input()
  if name not in S:
    S[name] = 1
    name_list.append(name)
  else:
    S[name] += 1
name_list = sorted(name_list)
max_vote_name = []
max_vote = -float('inf')
for name in name_list:
  if S[name] > max_vote:
    max_vote = S[name]
    max_vote_list = [name]
  elif S[name] == max_vote:
    max_vote_list.append(name)
for name in max_vote_list:
  print (name)

Submission status: Accepted

Solution code:
def main():
  n = int(input())
  dict = {}
  for i in range(n):
    s = input()
    dict.setdefault(s, 0)
    dict[s] += 1
  max_val = 0
  ans_ls = []
  for kv in dict.items():
    if kv[1] > max_val:
      max_val = kv[1]
      ans_ls = [kv[0]]    
    elif kv[1] == max_val:
      ans_ls.append(kv[0])
  ans_ls = sorted(ans_ls)
  for name in ans_ls:
    print(name)
 
 
if __name__ == '__main__':
  main()

Submission status: Accepted

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

set_key = list(set(s))
set_key.sort()
dic = dict(zip(set_key, [0]*len(set_key)))

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

n_max = max(dic.values())

for c in set_key:
  if dic[c] == n_max:
    print(c)

Submission status: Accepted

Solution code:
a = {}

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

a = sorted(a.items(), key=lambda x:x[1], reverse=True)
n = a[0][1]
i = 1
while i < len(a) and a[i][1] == n: i += 1
a = a[:i]
a = sorted(a, key=lambda x:x[0])

for s,t in a:
  print(s)

Submission status: Accepted

Solution code:
n = int(input())
s = sorted([input() for i in range(n)])
s_ = sorted(list(set(s)))
if len(s_) != n:
    s.append(0)
    co = [1] + [0 for i in range(len(s_)-1)]
    ind = 0
    for i in range(1, n):
        if s[i-1] == s[i]:
            co[ind] += 1
        else:
            ind += 1
            co[ind] += 1
    ma = max(co)
    arg = [i for i in range(len(s_)) if co[i]==ma]
    ans = [s_[i] for i in arg]
    print("\n".join(sorted(ans)))
    
else:
    print("\n".join(s))

Submission status: Accepted

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

max_num = max(c.values())

result = [i[0] for i in c.items() if i[1]==max_num]
result.sort()
 
for i in range(len(result)):
    print(result[i])

Submission status: Accepted

Solution code:
from collections import Counter
N=int(input())
lis=list(input() for _ in range(N))
ans=[]

counter=Counter(lis)
high=counter.most_common()[0][1]

for k,v in counter.most_common():
  if v==high:
    ans.append(k)
  else:
    break
ans.sort()
for i in ans:
  print(i)

Submission status: Accepted

Solution code:
n = int(input())
dic = {}
for i in range(n):
	s = input()
	if s in dic:
		dic[s] += 1
	else:
		dic[s] = 1
dic_sorted = sorted(dic.items(), key = lambda x: x[1], reverse = True)
ans = []
temp = 0
for k, v in dic_sorted:
	if not temp:
		temp = v
	if temp == v:
		ans.append(k)
	else:
		break
ans.sort()
for e in ans:
	print(e)

Submission status: Accepted

Solution code:
N = int(input())
S_dict = {}
for i in range(0, N):
  char = input()

  if char in S_dict:
    S_dict[char] += 1
  else:
    S_dict[char] = 1

S_dict_sorted = sorted(S_dict.items(), key=lambda x: -x[1])
_, value = S_dict_sorted[0]
ans_list = []
for k, v in S_dict_sorted:
  if value == v:
    ans_list.append(k)

ans_list.sort()
for item in ans_list:
  print(item)