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())
s = [input() for _ in range(n)]
 
d = {}
for i in s:
    if i not in d:
        d[i] = 1
    else:
        d[i] += 1
        
m = max(d.values())

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

Submission status: Accepted

Solution code:
n = int(input())
d = {}
for i in range(n):
    S = input()
    d[S] = d[S]+1 if S in d else 1
L = sorted(d.items(), key=lambda x: x[1], reverse=True)
print(*sorted([l[0] for l in L if l[1] == L[0][1]]), sep='\n')

Submission status: Accepted

Solution code:
from collections import Counter

n = int(input())
s = Counter()

for _ in range(n):
    s.update({input():1})

t = s.most_common()

ans = []
for item in t:
    if item[1] != t[0][1]:
        break
    ans.append(item[0])

ans = sorted(ans)

for i in ans:
    print(i)

Submission status: Accepted

Solution code:
votos = dict()

quantidade = int(input())

for i in range(0, quantidade):
    nome = input()

    if(len(votos) == 0):
        votos[nome] = 1
    elif nome in votos:
            votos[nome] += 1
    else:
        votos[nome] = 1

maior = 0

for i in votos:
    if(votos[i] > maior):
        maior = votos[i]

nome = list()
for i in votos:
    if(votos[i] == maior):
        nome.append(i)

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

Submission status: Accepted

Solution code:
N = int(input())
 
dict = {}
strings = []
for i in range(N):
    x = input()
    if x in dict.keys():
        dict[x] += 1
    else:
        dict[x] = 1
 
maximum = 1
for i in dict:
    maximum = max(maximum,dict[i])
 
for word in dict:
    if dict[word] == maximum:
        strings.append(word)
strings.sort()
for word in strings:
    print(word)

Submission status: Accepted

Solution code:
def main():
    dic = {}

    n = int(input())
    for _ in range(n):
        nome = input()
        try:
            dic[nome] += 1
        except KeyError:
            dic[nome] = 1

    resp = []
    Max = 0
    
    for nome, voto in dic.items():
        if voto > Max:
            Max = voto
            resp = [nome]
            
        elif voto == Max:
            resp.append(nome)

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

main()

Submission status: Accepted

Solution code:
import collections

N = int(input())
S_list = []
for n in range(N):
  S_list.append(input())

c = collections.Counter(S_list)
max_list = []
_max_value = 0
for idx, value in enumerate(c.most_common()):
  if idx == 0:
    max_list.append(value[0])
    _max = value[1]
    continue
  if _max == value[1]:
    max_list.append(value[0])
  else:
    break

for answer in sorted(max_list):
  print(answer)

Submission status: Accepted

Solution code:
from collections import Counter

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

SC = Counter(S)
maxval = max(SC.values())
listmaxval = [key for key in SC if SC[key] == maxval]
listmaxval.sort()
ans = "\r\n".join(listmaxval)
print(ans)

Submission status: Accepted

Solution code:
from collections import defaultdict
N = int(input())
dic = defaultdict(int)
for i in range(N):
    s = input()
    dic[s]+=1
m = 0
for i in dic:
    m = max(m, dic[i])
ans = []
for i in dic:
    if dic[i]==m:
        ans.append(i)
ans.sort()
for i in ans:
    print(i)

Submission status: Accepted

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

d = {}
for i in s:
    if i not in d:
        d[i] = 1
    else:
        d[i] += 1
        
m = max(d.values())

l = []
for k in d.keys():
    if d[k] == m:
        l.append(k)

l_s = sorted(l)
                
for ans in l_s:
    print(ans)

Submission status: Accepted

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

word_list = {}

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

word_list_s = sorted(word_list.items(), key=lambda x:x[1], reverse=True)
word_list_s_max = []
for i in range(len(word_list_s)):
    if word_list_s[i][1] == word_list_s[0][1]:
        word_list_s_max.append(word_list_s[i])
word_list_s_2 = sorted(word_list_s_max, key=lambda x:x[0])

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

Submission status: Accepted

Solution code:
N = int(input())
word = [str(input()) for i in range(N)]
dic = {}
for i in word:
  if i in dic:
    dic[i] += 1
  else:
    dic[i] = 1
max_num = max(dic.values())
can_word = []
for i,j in dic.items():
  if j == max_num:
    can_word.append(i)
can_word.sort()
for i in can_word:
  print(i)

Submission status: Accepted

Solution code:
n=(int)(input())
a = sorted(list(input() for i in range(n)))
lis = sorted(list(set(a)))
big = [0 for i in range(len(lis))]
maxi = 0
counter = 1
check = 0
#print(a)
for i in range(len(a) - 1):
  #print(a[i])
  if a[i] == a[i + 1]:
    counter += 1
  else:
    big[check] = counter
    counter = 1
    check += 1
else:
  big[-1] = counter
maxi = max(big)
#print(lis, big)
for i in range(len(lis)):
  if big[i] == maxi:
    print(lis[i])

Submission status: Accepted

Solution code:
#k = int(input())
#s = input()
#a, b = map(int, input().split())
#s, t = map(str, input().split())
#l = list(map(int, input().split()))
#l = [list(map(int,input().split())) for i in range(n)]
#a = [input() for _ in range(n)]


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


h = {}

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


ans = []
highScore = max(h.values())

for k,v in h.items():
    if v== highScore:
        ans.append(k)

ans.sort()

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

Submission status: Accepted

Solution code:
from collections import Counter

n = int(input())

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

c = Counter(s)

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

maxc = csort[0][1]
ans = []
for s,v in csort:
    if v == maxc:
        ans.append(s)
        
anssort = sorted(ans)

for s in anssort:
    print(s)

Submission status: Accepted

Solution code:
import re
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
import functools
def v(): return input()
def k(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7
cnt = 0
ans = 0
inf = float("inf")

n = k()
ss = [v() for i in range(n)]

c = Counter(ss)
a = list(c.most_common())
maxc = a[0][1]

Ans = []
for i in a:
    if i[1] == maxc:
        Ans.append(i)
    
Ans.sort()
for i in Ans:
    print(i[0])

Submission status: Accepted

Solution code:
N = int(input())
hashmap = {}
Array = [[] for _ in range(N+1)]
for _ in range(N):
  st = input()
  if st not in hashmap:
    hashmap[st] = 0
  hashmap[st]+=1
max_num = max(hashmap.values())
tup = []
for k,v in hashmap.items():
  if v == max_num:
    tup.append(k)
tup.sort()
for i in tup:
  print(i)

Submission status: Accepted

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

dict = {}

for s in S :
    dict.setdefault(s, 0)
    dict[s] += 1

max_value =  max(dict.values())
ans = sorted([ k for k,v in dict.items() if v == max_value])

for a in ans :
    print(a)

Submission status: Accepted

Solution code:
n = int(input())

moziretu={}
a=1
for i in range(n):
    s=input()

    if s in moziretu:
        moziretu[s]=moziretu[s]+1
        a=max(a,moziretu[s])
    else:
        moziretu[s]=1

ans=[k for k, v in moziretu.items() if v == a]
ans.sort()
for i in ans:
    print(i)

Submission status: Accepted

Solution code:
#listの要素をキー、その出現数を値として持つディクショナリを返す
def count(list):
    dict = {}
    for i in range(len(list)):
        dict[list[i]] = dict.get(list[i], 0) + 1
    return dict

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

dic = count(s)
lst = sorted(dic.items(), key=lambda x: x[1], reverse=True)
value_max = lst[0][1]
output = []

for name in lst:
    if name[1] == value_max:
        output.append(name[0])
    else:
        break

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

Submission status: Accepted

Solution code:
from collections import Counter
n = int(input())
s = [str(input()) for i in range(n)]
s = Counter(s).most_common()
w = []
for h in s:
    if s[0][1] == h[1]:
        w.append(h[0])
w.sort()
for j in w:
    print(j)

Submission status: Accepted

Solution code:
N = int(input())

dict = {}
strings = []
for i in range(N):
    x = input()
    if x in dict.keys():
        dict[x] += 1
    else:
        dict[x] = 1

maximum = 1
for i in dict:
    maximum = max(maximum,dict[i])

for word in dict:
    if dict[word] == maximum:
        strings.append(word)
strings.sort()
for word in strings:
    print(word)

Submission status: Accepted

Solution code:
#C - Poll
N = int(input())
S = [input() for _ in range(N)]
S_set = list(sorted(set(S)))

counter = {}
for k in S_set:
    counter[k] = 0
for i in S:
    counter[i] += 1
    
maxim = max(counter.values())
ans = [i for i in S if counter[i] == maxim]
ans = list(sorted(set(ans))) 

for j in ans:
    print(j)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


def sum_of_arithmetic_progression(s, d, n):
    return n * (2 * s + (n - 1) * d) // 2


def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)


def lcm(a, b):
    g = gcd(a, b)
    return a / g * b


def solve():
    N = int(input())
    d = defaultdict(int)

    maxi = 0
    for _ in range(N):
        S = input()
        d[S] += 1
        maxi = max(maxi, d[S])

    ans = []
    for k, v in d.items():
        if v == maxi:
            ans.append(k)
    for a in sorted(ans):
        print(a)


def main():
    solve()


if __name__ == '__main__':
    main()

Submission status: Accepted

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

from collections import Counter
results = Counter(s)

max_num = results.most_common()[0][1]
max_key_list = [kv[0] for kv in results.items() if kv[1] == max_num]
for i in sorted(max_key_list):
  print(i)

Submission status: Accepted

Solution code:
from collections import Counter
k = [input() for _ in range(int(input()))]
l = Counter(k)
m = l[max(l , key = lambda x: l[x])]
ans = sorted(filter(lambda x:l[x]==m ,l))
print(*ans, sep='\n')

Submission status: Accepted

Solution code:
# row = [int(x) for x in input().rstrip().split(" ")]
# n = int(input().rstrip())
# s = input().rstrip()

def resolve():
    import sys
    input = sys.stdin.readline

    n = int(input().rstrip())

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

    from collections import Counter
    c = Counter(s_list)

    max_count = c.most_common()[0][1]

    words = [word for word, count in c.most_common() if count == max_count]
    words.sort()
    print("\n".join(words))




if __name__ == "__main__":
    resolve()

Submission status: Accepted

Solution code:
n=int(input())
s=[str(input()) for _ in range(n)]
import collections
cnt=collections.Counter(s)
cntt=cnt.most_common()
maxn=cntt[0][1]
ansl=[]
for c in cntt:
  if c[1]==maxn:
    ansl.append(c[0])
  else:
    break
ansl.sort()
for i in ansl:
  print(i)

Submission status: Accepted

Solution code:
from collections import Counter


def main():
    n = int(input())
    s = (input() for i in range(n))
    d = Counter(s)
    num = d.most_common(1)[0][1]
    ans = sorted(j[0] for j in d.items() if j[1] == num)
    for i in ans:
        print(i)

main()

Submission status: Accepted

Solution code:
number = int(input())
words = {}
answer = []
maxnum = 0
for i in range(number):
    word = input()
    if word in words:
        words[word] += 1
    else:
        words[word] = 1
    if maxnum < words[word]:
        maxnum = words[word]
        answer.clear()
        answer.append(word)
    elif maxnum == words[word]:
        answer.append(word)
answer.sort()
for j in range(len(answer)):
    print(answer[j])

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
N = int(input())
S = list()
words = {}
for i in range(N):
  s = input()
  S.append(s)
  if s in words:
    words[s] += 1
  else:
    words[s] = 1

max_value = max(words.values())
max_list = list()
for k,v in words.items():
  if v == max_value:
    max_list.append(k)
ans_list = sorted(max_list)
for ans in ans_list:
  print(ans)

Submission status: Accepted

Solution code:
N = int(input())

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

max = max(dict.values())
for key, val in sorted(dict.items()):
    if(val == max):
        print(key)

Submission status: Accepted

Solution code:
from collections import Counter
N = int(input())
S = []
for _ in range(N):
    S.append(input())
S.sort()
C = Counter(S)
C = sorted(C.items(), key=lambda x:x[1], reverse=True)
vm = 0
for k, v in C:
    if v >= vm:
        vm = v
        print(k)
    else:
        break

Submission status: Accepted

Solution code:
n=int(input())
s=list()
for i in range(n):
  s.append(input())

import collections

c=collections.Counter(s)



l=list()
max_=0
for cc in c.values():
  max_=max(cc, max_)

for ca,cb in c.items():
  if max_==cb:
    l.append(ca)

l.sort()
for ll in l:
  print(ll)

Submission status: Accepted

Solution code:
import sys
from collections import defaultdict

N = int(sys.stdin.readline().rstrip())

d = defaultdict(int)

for _ in range(N):
    s = sys.stdin.readline().rstrip()
    d[s] += 1

# print(d)
d2 = sorted([(v, k) for k, v in d.items()])
m = max(d2)[0]  # v の回数で max を拾う
# print(m)
for v, k in d2:
    if v == m:
        print(k)

Submission status: Accepted

Solution code:
import collections

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

cs = collections.Counter(s)
mcs = cs.most_common()
cnt = mcs[0][1]

fcs = [i[0] for i in cs.items() if i[1] == cnt]
ans = sorted(fcs)
for s in ans:
    print(s)

Submission status: Accepted

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

l = list(S.items())
l.sort(key=lambda s: (-s[1], s[0]))
M = l[0][1]
print("\n".join([a[0] for a in list(filter(lambda b: b[1] == M, l))]))

Submission status: Accepted

Solution code:
from collections import Counter
n = int(input())
d = list(input() for _ in range(n))
D = Counter(d)
m = max(D.values())
l = []
for i,j in D.most_common():
  if m != j:
    break
  l.append(i)
l.sort()
for i in l:
  print(i)

Submission status: Accepted

Solution code:
n=int(input())
d={}
l=[]
for i in range(n):
  s=input()
  if s not in d:
    d[s]=1
  else:
    d[s]=d[s]+1
k=max(d.values())
for i,j in d.items():
  if j==k:
    l.append(i)
l.sort()
for i in range(len(l)):
  print(l[i])

Submission status: Accepted

Solution code:
import collections

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

cnt = collections.Counter(S)
max_cnt = max(cnt.values())

ans_list = []

for key, value in cnt.items():
    if value == max_cnt:
        ans_list.append(key)

print(*sorted(ans_list), sep='\n')

Submission status: Accepted

Solution code:
from collections import Counter
N = int(input())
S = [input() for _ in range(N)]
cntr = Counter(S)
mc = cntr.most_common()
n = mc[0][1]
ans = []
for k, v in mc:
    if n!=v:
        break
    ans.append(k)
ans.sort()
print("\n".join(ans))

Submission status: Accepted

Solution code:
c={}
N=int(input())
for i in range(N):
  s=input()
  if s not in c:
    c[s]=1
  else:
    c[s]+=1
n=max(c.values())
L=list()
for i in c:
  if c[i]==n:
    L.append(i)
L=sorted(L)
for i in L:
  print(i)

Submission status: Accepted

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

l= sorted(l)

import collections
c = collections.Counter(l)
d = c.most_common()

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

Submission status: Accepted

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

for i in range(N):
  S = input()
  if S in BOX:
    BOX[S] = (BOX[S] + 1)
  else:
    BOX[S] = 0

MAX = max(BOX.values())
keys = [k for k, v in BOX.items() if v == MAX]
keys = sorted(keys)
for i in range(len(keys)):
  print(keys[i])

Submission status: Accepted

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

res = {}
for s in S:
    if s in res:
        res[s] += 1
    else:
        res[s] = 1
max_ = max(res.values())

ans = []
for k in res:
    if res[k] == max_:
        ans.append(k)
ans.sort()

for a in ans:
    print(a)

Submission status: Accepted

Solution code:
from collections import Counter
N = int(input())
S = [input() for _ in range(N)]
S.sort()
n = Counter()
for s in S:
    n[s] += 1
max = max(n.values())
S = set(S)
for s in S:
    if n[s] == max:
        print(s)

Submission status: Accepted

Solution code:
def resolve():
    N = int(input())
    S = [input() for _ in range(N)]
    import collections
    counter = collections.Counter(S)
    answers = []
    maxcnt = 0
    for k, v in counter.items():
        if maxcnt < v:
            maxcnt = v
            answers = [k]
        elif maxcnt == v:
            answers.append(k)
    [print(s) for s in sorted(answers)]

if '__main__' == __name__:
    resolve()

Submission status: Accepted

Solution code:
import collections

N = int(input())
S = [input() for i in range(N)]
C = collections.Counter(S)
L = C.most_common()

ans = []
flag = 0

for n in range(len(C)):
    if L[n][1] < flag:
        break
    else:
        ans.append(L[n][0])
        flag = (L[n][1])

ans.sort()

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

Submission status: Accepted

Solution code:
n=int(input())
a={}
for i in range(n):
    key=input()
    if key in a:
        a[key]+=1
    else:
        a[key]=1
b=max(list(a.values()))
c=[]
for k,v in a.items():
    if v==b:
        c.append(k)
c=sorted(c)
for i in range(len(c)):
    print(c[i])

Submission status: Accepted

Solution code:
import sys
import collections

S = int(next(sys.stdin))
_A = (s.strip() for s in sys.stdin)
A = collections.Counter(_A)

# print(A)
# print(max(A.values()))

m = max(A.values())
keys = [k for k, v in A.items() if v == m]
keys.sort()
for s in keys:
  print(s)

Submission status: Accepted

Solution code:
n = int(input())
a = {}
for i in range(n):
    s = input()
    if s in a:
        a[s] += 1
    else:
        a[s] = 1
a = sorted(a.items(), key=lambda x: x[1], reverse=True)
max_a = a[0][1]
w = []
for i in range(len(a)):
    if a[i][1] == max_a:
        w.append(a[i][0])
    else:
        break
w = sorted(w)
for i in range(len(w)):
    print(w[i])

Submission status: Accepted

Solution code:
N = int(input())
import collections
a = []

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

l = collections.Counter(a)

x = max(l.values())

ans = [k for k, v in l.items() if v == x]
ans = sorted(ans)


for i in ans:
    print(i)

Submission status: Accepted

Solution code:
from collections import Counter

N = int(input())
S = [input() for _ in range(N)]
S.sort()
s = Counter(S)
max_len = max([n for n in s.values()])
#print("------------------")
for a, b in s.items():
    if b == max_len:
        print(a)

Submission status: Accepted

Solution code:
N = int(input())

from collections import Counter

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

B = Counter(A)
MaxC = max(B.values())
Arg = list(B.values()).count(MaxC)
C = sorted(B.items(),key=lambda x:(x[1],x[0]))[::-1]
for i in range(Arg):
    print(C[Arg-i-1][0])

Submission status: Accepted

Solution code:
n=int(input(""))
liss=[]
for i in range(n):
    liss+=[input("")]
liss.sort()
lisk=[]
maxt=1
t=0
s=liss[0]
for i in liss:
    if(s==i):
        t+=1
        if(t==maxt):
            lisk+=[i]
        elif(t>=maxt):
            lisk=[i]
            maxt=t
    else:
        s=i
        t=1
        if(t==maxt):
            lisk+=[i]
for i in lisk:
    print(i)

Submission status: Accepted

Solution code:
n = int(input())
S=[]
for i in range(n):
    s=input()
    S.append(s)
S.sort()
import collections
c = collections.Counter(S)
values, counts = zip(*c.most_common())
print(values[0])
for i in range(len(counts)-1):
    if counts[i] == counts[i+1]:
        print(values[i+1])
    else:
        exit()

Submission status: Accepted

Solution code:
from fractions import gcd
from collections import Counter, deque, defaultdict
from heapq import heappush, heappop, heappushpop, heapify, heapreplace, merge
from bisect import bisect_left, bisect_right, bisect, insort_left, insort_right, insort
from itertools import product, combinations,permutations
from copy import deepcopy
import sys
sys.setrecursionlimit(4100000)



if __name__ == '__main__':
    N = int(input())
    S_list = []

    s_hash = dict()

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

    for s in S_list:
        if s not in s_hash:
            s_hash[s] = 1
        else:
            s_hash[s] += 1
    max_p = 0
    max_p_name = []
    for k, v in s_hash.items():
        if max_p < v:
            max_p_name = []
            max_p = v
        if max_p == v:
            max_p_name.append(k)
    
    for p in sorted(max_p_name):
        print(p)

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())
d = {}
for _ in range(N):
    w = input().strip()
    if w in d:
        d[w] += 1
    else:
        d[w] = 1
m = max(d.values())
r = []
for k, v in d.items():
    if v == m:
        r.append(k)
for w in sorted(r):
    print(w)

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 = {}
c = 0
for _ in range(N):
	s = input()
	if s not in S:
		S[s] = 1
	else:
		S[s] += 1
	c = max(c, S[s])
ans = []
for k, v in S.items():
	if v == c:
		ans.append(k)
ans.sort()
for a in ans:
	print(a)

Submission status: Accepted

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

d = {}
for si in s:
    if si not in d:
        d[si] = 0
    d[si] += 1

s_list = list(sorted(list(d.keys())))
value = max(d.values())
for si in s_list:
    if d[si] == value:
        print(si)

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={}
maxr=0
for i in range(n):
    s=input()
    if s in S:
        S[s]+=1
    else:
        S[s]=1

maxc = max(S.values())

ans=[]
for s in S:
    if S[s]==maxc :
        ans.append(s)

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

Submission status: Accepted

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

for k,v in s.items():
  if v==cou:
    l.append(k)
    
ans=sorted(l)

for i in ans:
  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_list = [i for i in c.keys() if c[i]==m]
[print(ans) for ans in sorted(ans_list)]

Submission status: Accepted

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

S = sorted(S)
newS = sorted(list(set(S)))
frq = [0] * len(newS)

si = index = 0
for i in range(N):
    if i == N-1:
        frq[index] = N - si
    elif S[i] != S[i+1]:
        frq[index] = i + 1 - si
        si = i + 1
        index += 1
    
ma = max(frq)
for i in range(len(newS)):
    if frq[i] == ma:
        print(newS[i])

Submission status: Accepted

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

for n in range(N):
  S = input()
  D[S] = D.get(S,0)+1

L = max(D.values())

for k,v in sorted(D.items()):
  if v==L:
    print(k)

Submission status: Accepted

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

#sが新規キーか否かで操作を変える
    if s in dic:
        dic[s] += 1
#新規ではないならvalueを1増やす
    else:
        dic[s] = 1
          
m = max(dic.values())

for i in dic:
    if dic[i] == m:
        l += [i]

print(*sorted(l))

Submission status: Accepted

Solution code:
import collections
n = int(input())
dic = collections.defaultdict(int)
for _ in range(n):
    s = input()
    dic[s] +=1
sorted_dic = sorted(dic.items(), key = lambda x:(-x[1],x[0]))
val = sorted_dic[0][1]
for k,v in sorted_dic:
    if v==val:
        print(k)

Submission status: Accepted

Solution code:
n=int(input())
hoge={}
for i in range(n):
  tmp=input()
  if(tmp in  hoge):
    hoge[tmp]+=1
  else:
    hoge[tmp]=1
    
key_max=max(hoge.values())
keys = [k for k, v in hoge.items() if v ==key_max]
hoge=sorted(keys)
for i in range(len(hoge)):
  print(hoge[i])

Submission status: Accepted

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

S.sort()

maxint = 1

sdic = {}

for s in S:
    if s in sdic:
        sdic[s] += 1
        if sdic[s] > maxint:
            maxint = sdic[s]

    else:
        sdic[s] = 1

for s in sdic:
    if sdic[s] == maxint:
        print(s)

Submission status: Accepted

Solution code:
d={}
for _ in range(int(input())):
 s=input()
 d[s]=d.get(s,0)+1
c=max(d.values())
for s,v in sorted(d.items()):
 if v==c: print(s)

Submission status: Accepted

Solution code:
N=int(input())
d={}
for _ in range(N):
    s=input()
    d[s]=d.get(s,0)+1
c=max(d.values())
for s,v in sorted(d.items()):
  if v==c: print(s)

Submission status: Accepted

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

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

for s,v in l:
  if v==c: print(s)
  else: break

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())
ans=[]
for i,k in d.items():
  if m==k:
    ans.append(i)
for i in sorted(ans):
  print(i)

Submission status: Accepted

Solution code:
def solve():
    N = int(input())
    word_count = {}
    max_count = 0
    for i in range(N):
        word = input()
        word_count[word] = word_count.get(word, 0) + 1
        max_count = max(word_count[word], max_count)
    ans_words = []
    for w,c in word_count.items():
        if c == max_count:
            ans_words.append(w)
    print('\n'.join(sorted(ans_words)))

if __name__ == "__main__":
    solve()

Submission status: Accepted

Solution code:
import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)
INF = float('inf')


N = int(input())

import collections
d = collections.defaultdict(int)

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

c = collections.Counter(d)
cnt = c.most_common()[0][-1]

a = []
for k, v in collections.Counter(d).most_common():
    if v != cnt:
        break
    a.append(k)

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

Submission status: Accepted

Solution code:
from collections import Counter

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

C = Counter(S)

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


cnt_max = C[0][1]
ans = []
for i in range(len(C)):
    if cnt_max > C[i][1]:
        break
    else:
        ans.append(C[i][0])

ans.sort()

for w in ans:
    print(w)

Submission status: Accepted

Solution code:
from collections import Counter


def main():
    n = int(input())
    s = [input() for _ in range(n)]
    counter = Counter(s)
    most_common = counter.most_common()
    max_num = most_common[0][1]
    values, counts = zip(*most_common)
    for i, cnt in enumerate(counts):
        if cnt != max_num:
            last_index = i
            break
    else:
        last_index = len(counter)
    ans = list(values[:last_index])
    ans.sort()
    print("\n".join(ans))


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
import collections

N = int(input())
cnt = collections.defaultdict(int)

for _ in range(N):
  s = input()
  cnt[s] += 1

max_v = max(cnt.values())
ans   = sorted([k for k, v in cnt.items() if v == max_v])
for s in ans:
  print(s)

Submission status: Accepted

Solution code:
import collections

N = int(input())
cnt_dic = collections.defaultdict(int)

for _ in range(N):
  s = input()
  cnt_dic[s] += 1

max_v = max(cnt_dic.values())

ans_lis = [k for k, v in cnt_dic.items() if v == max_v]

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

Submission status: Accepted

Solution code:
import math
from math import gcd
INF = float("inf")

import sys
input=sys.stdin.readline
import itertools

def main():
    n = int(input())
    dic = {}
    for i in range(n):
        k = input().rstrip()
        dic[k] = dic.get(k,0) + 1

    m = max(list(dic.values()))
    ans = []
    for i,k in dic.items():
        if k == m:
            ans.append(i)
    print("\n".join(sorted(ans)))




if __name__=="__main__":
    main()

Submission status: Accepted

Solution code:
N = int(input())
p = dict()
for i in range(N):
    s = input()
    if not s in p:
        p[s] = 0
    p[s] += 1
m = max(p.values())
ans = [k for k in p.keys() if p[k] == m]
ans = sorted(ans)
for j in range(len(ans)):
    print(ans[j])

Submission status: Accepted

Solution code:
import collections
 
N,*S = open(0).read().split()
C = collections.Counter(S)
 
i = C.most_common()[0][1]
print(*sorted([k for k,v in C.most_common() if v == i]), sep='\n')

Submission status: Accepted

Solution code:
import collections

N,*S = open(0).read().split()
C = collections.Counter(S)

i = C.most_common()[0][1]
print(*sorted([k for k,v in C.most_common() if v == i]), sep='\n')