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 numpy as np
from collections import Counter
 
N = int(input())
S = [input() for _ in range(N)]
c = Counter(S)
d = c.most_common()
t = 1

for i in range(1, len(d)):
  if d[0][1] == d[i][1]:
    t += 1
  else:
    pass

L = [[]]*t
for j in range(t):
  L[j] = d[j][0]
  
L = sorted(L)
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)]

c = collections.Counter(s)

b, most = c.most_common(1)[0]

ans = []
for i,j in c.most_common():
  if j != most:
    break
  ans.append(i)
for ans_v in sorted(ans):
  print(ans_v)

Submission status: Accepted

Solution code:
from collections import Counter

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

def calculate_mode(data):
    c = Counter(data)
    # すべての要素とその出現回数を取り出します。
    freq_scores = c.most_common()
    #c.most_common内の最も多い要素[0]の最大出現回数[1]を[0][1]で指定
    max_count = freq_scores[0][1]

    modes = []
    #出現回数と最大出現回数が等しいかを確認します。
    for num in freq_scores:
        if num[1] == max_count:
            modes.append(num[0])
    return(modes)

if __name__ == '__main__':
    modes = calculate_mode(S)

    modes.sort()
    for mode in modes:
        print(mode)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
N = int(input())

dic = {}

for i in range(N):
    S = input()
    dic[S] = dic.setdefault(S, 0) + 1

sdic = sorted(dic.items(), key=lambda x:x[1]*-1)

l = []

k = -1
for s in sdic:
    if k == -1:
        k = dic[s[0]]
    if k == dic[s[0]]:
        l.append(s[0])
    else:
        break

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

Submission status: Accepted

Solution code:
import collections

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

# print(S)

count = collections.Counter(S)

# print(count)

max_value = max(count.values())

max_k_list = []

for k, v in sorted(count.items(), key=lambda x: x[1], reverse=True):
    if v == max_value:
        max_k_list.append(k)
    else:
        break

max_k_list.sort()

for i in max_k_list:
    print(i)

Submission status: Accepted

Solution code:
import collections

if __name__ == "__main__":
    N = int(input())
    S = []
    for i in range(N):
        S.append(input())
    S_collect = collections.Counter(S)
    S_tp = []
    for word in S_collect.most_common():
        S_tp.append(word)
    S_tp_sort = []
    for i in S_tp:
        if i[1] == S_tp[0][1]:
            S_tp_sort.append(i[0])
        else:
            break
    S_tp_sort = sorted(S_tp_sort)
    for s in S_tp_sort:
        print(s)

Submission status: Accepted

Solution code:
import collections

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

a = collections.Counter(S)
m = max(a.values())
s = []
for i in a:
    if a[i] == m:
        s.append(i)
s.sort()
for i in s:
    print(i)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import collections

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

c = collections.Counter(S)
most_common = c.most_common()
#print(most_common)

max_count = most_common[0][1]

# for t in most_common:
#     print(t[1])
c_list = [t[0] for t in most_common if t[1] == max_count]
# print(sorted(c_list))

out = sorted(c_list)
for o in out:
    print(o)

Submission status: Accepted

Solution code:
N=int(input())
S = [input() for i in range(N)]
import collections
c = collections.Counter(S)
values, counts = zip(*c.most_common())

n=0
for i in range(len(counts)-1):
  if counts[i]==counts[i+1]:
    n=n+1
  else:
    break
answer=[]    
for i in range(n+1):
  answer.append(values[i])
answer=sorted(answer)

for i in answer:
  print(i)

Submission status: Accepted

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

maxv=1
count=1
P=[]

for j in range(N-1):  
    if S[j]==S[j+1]:
        count+=1
    else:
        if count==maxv:
            P+=[S[j]]
        elif count>maxv:
            maxv=count
            P=[S[j]]  
        count=1
        
if count==maxv:
    P+=[S[N-1]]
elif count>maxv:
    maxv=count
    P=[S[N-1]]  

    

            
        
for k in range(len(P)):
    print(P[k])

Submission status: Accepted

Solution code:
import collections

from collections import Counter
N = int(input())
P = []
for i in range (N):
    P.append(str(input()))

counted = collections.Counter(P)
m = max(counted.values())
chars = {key for key, value in counted.items() if value == m}

chars2 = sorted(chars)

for i in range (len(chars2)):
    print("{}".format(chars2[i]))

Submission status: Accepted

Solution code:
from collections import defaultdict
inpl = lambda: list(map(int,input().split()))
N = int(input())
T = defaultdict(int)
for i in range(N):
    T[input()] += 1
U = []
M = 0
for k in T.keys():
    n = T[k]
    if n > M:
        M = n
        U = [k]
    elif n == M:
        U.append(k)
U.sort()
for u in U:
    print(u)

Submission status: Accepted

Solution code:
n = int(input())
max_num = 0
s_dic = {}
for i in range(n):
    input_line = input()
    if input_line in s_dic:
        s_dic[input_line] = s_dic[input_line] + 1
    else:
        s_dic[input_line] = 1
    if s_dic[input_line] > max_num:
        max_num = s_dic[input_line]

anser_list = []
for key,value in s_dic.items():
    if value == max_num:
        anser_list.append(key)

anser_list.sort()
for key in anser_list:
    print(key)

Submission status: Accepted

Solution code:
n = int(input())
arr = []

res = {}
for i in range(n):
    s = input()
    if res.get(s) == None:
        res.__setitem__(s, 1)
    else:
        res.__setitem__(s, res.get(s) + 1)


def calculate(n,res):
    values = list(res.values())
    maxValue = max(values)

    results = []
    for re in res.keys():
        if res.get(re) == maxValue:
            results.append(re)

    results = sorted(results)
    for res in results:
        print(res)

calculate(n,res)

Submission status: Accepted

Solution code:
n = int(input())
my_dic={}
for i in range(n):
	k = input()
	if k in my_dic:
		my_dic[k]+=1
	else:
		my_dic[k]=1

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

Submission status: Accepted

Solution code:
sz = int(input(''))
ary = []
for i in range(0,sz):
  s = input()
  ary.append(s)

map = {}
for w in ary:
  if not w in map:
    map[w] = 1
  else:
    map[w] +=1

max = 0
maxes = []
for k,v in map.items():
  if v > max:
    max = v

for k,v in map.items():
  if v == max:
    maxes.append(k)

for m in sorted(maxes):
  print(m)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import Counter
import collections

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

c = collections.Counter(a)
hoge = c.most_common()
i = 0

list = []
if(len(hoge) == 1):
	list.append(hoge[0][0])
elif(len(hoge) == N):
  list = a
else:
  ##for i in range(0,len(c.most_common())-1):
    while(hoge[i][1] == hoge[0][1]):
        list.append(hoge[i][0])
        i += 1



list.sort()

print(' \n'.join(map(str, list)))

Submission status: Accepted

Solution code:
import collections

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

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

t = collections.Counter(S)


maxt = max(t.values())
maxvt = [key for key in t if t[key] == maxt]
maxvt.sort()

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

Submission status: Accepted

Solution code:
import sys
from collections import Counter

def main():
    
    # sys.stdin = open('input155c.txt')
   
    n = int(input())
    
    a = []
    for _ in range(n):
        a.append(input())

    b = Counter(a)    
    max_val = max(b.values())
    max_val = [key for key in b if b[key] == max_val]

    sort_val = sorted(max_val)
    
    for i in sort_val:
        print(i)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
from collections import Counter
n = int(input())
#li = ['apple', 'orange', 'apple', 'banana', 'grape','orange']
li = []
for i in range(n):
    li.append(input())

#print(li)
#出現回数がもっとも多いタプルを返す（でもこれだと同一の場合１つしか出てこない...）
dic = Counter(li)
#print(dic.most_common())
#print(max(dic.values()))
max = max(dic.values())

list=[]

for k,v in dic.items():
    if(v == max):    
        list.append(k)


list = sorted(list)

#print(list)

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

Submission status: Accepted

Solution code:
import collections

n=int(input())
l=[]
for i in range(n):
    l.append(input())
l2=collections.Counter(l)
max=max(l2.values())

max_k_list = [kv[0] for kv in l2.items() if kv[1] == max]
l3=sorted(max_k_list)
print("\n".join(l3))

Submission status: Accepted

Solution code:
N = int(input())
strList=[input() for i in range(N)]
#print(strList)
strList.sort()
#print(strList)

maxNum = 0
Num = 1
maxStr = [strList[0]]
temp = strList[0]

for i in range(1,N):
  if(strList[i] != temp):
    #print(strList[i])
    if(Num > maxNum):
      maxNum = Num
      Num = 1
      del maxStr[:]
      maxStr.append(strList[i-1])
      temp = strList[i]
    elif(Num == maxNum):
      Num = 1
      maxStr.append(strList[i-1])
      temp = strList[i]
    else:
      Num = 1
      temp = strList[i]
  else:
    Num += 1

if(Num > maxNum):
  maxNum = Num
  Num = 1
  del maxStr[:]
  maxStr.append(strList[i])
  temp = strList[i]
elif(Num == maxNum):
  Num = 1
  maxStr.append(strList[i])
  temp = strList[i]

length = len(maxStr)
for i in range(length):
  print(maxStr[i])

Submission status: Accepted

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

S_common = S.most_common()

for i in range(len(S_common)):
	if S_common[0][1] == S_common[i][1]:
		S_print.append(S_common[i][0])

S_print_new = sorted(S_print)
#print(S_print_new)
for i in range(len(S_print_new)):
	print(S_print_new[i])

Submission status: Accepted

Solution code:
'''
.append(要素) リストに要素を追加
.extend(リスト) リストを連結する
.insert(場所,要素) 指定した場所に要素追加
del 配列名[場所]
-1で末尾で末尾から一つ前

sort()
sorted(reverse=true)

配列の初期化
配列名=[a]*n+[b]*m

Decimal()
'''

from sys import stdin


from collections import Counter


Num = int(stdin.readline().rstrip())
data = []
for el in range(Num):
    data.append(stdin.readline().rstrip())
data.sort()

counter = Counter(data)

count = 0
check = 0
res = []
for el in counter.most_common():
    if count == 0:
        res.append(el[0])
        check = el[1]
        count = 1
        continue
    if check == el[1]:
        res.append(el[0])
res.sort()
for el in res:
    print(el)

Submission status: Accepted

Solution code:
import sys
from collections import Counter
N=int(input())
S=['']*N
for i in range(N):
    S[i]=input()
counter = Counter(S)
ans=[0]*len(counter)
num=0
for word, cnt in counter.most_common():
    ans[num]=cnt
    num+=1
anker=ans[0]
ankernum=0
for j in range(len(counter)):
    if ans[j]!=anker:
        ankernum=j
        break
    elif j==len(counter)-1:
        ankernum=j+1
word_ans=['']*len(counter)
k=0
for word, cnt in counter.most_common():
    word_ans[k]=word
    k+=1

for l in sorted(word_ans[:ankernum]):
    print(l)

Submission status: Accepted

Solution code:
N = int(input())
arr = []

for i in range(N):
  a = input()
  arr.append(a)
  
arr.sort()
arr.append("")

a = [[] for i in range(N+1)]
cnt = 0

for i in range(1,N+1):
  
  if arr[0] != arr[1] and i == 1:
    a[1].append(arr[0])
  
  if arr[i] == arr[i-1]:
    if cnt == 0:
      cnt += 1
    cnt += 1	
  else:
    if cnt > 1:
      a[cnt].append(arr[i-1])
      cnt = 1
    else:
      cnt = 1
      if arr[0] != arr[i-1]:
        a[1].append(arr[i-1])
for i in range(N):
  if a[N-i] == []:
    p = 0
  else:
    b = a[N-i]
    b.sort()
    for j in b:
      if j != "":
        print(j)
    break

Submission status: Accepted

Solution code:
N = int(input())

occ = {}

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

best = 0
for s in occ: best = max(best, occ[s])

res = []
for s in occ:
    if occ[s] == best: 
        res.append(s)

res.sort()

for i in res:
    print(i)

Submission status: Accepted

Solution code:
# coding: utf-8
import itertools

n = int(input())
s = [input() for i in range(n)]
s.sort()
grs = itertools.groupby(s)
ss = []
for key, group in grs:
    cnt = len(list(group))
    ss.append([cnt, key])
sss = sorted(ss)
maxn = sss[-1][0]

for w in sss:
    if w[0] == maxn:
        print(w[1])

Submission status: Accepted

Solution code:
n = int(input())
d = {}
l = []
for i in range(n):
  w = str(input())
  if w in d.keys():
    d[w]+=1
  else:
    d[w] = 1
m = max(d.values())
for k, v in sorted(d.items(), key=lambda x: -x[1]):
  if m == v:
    l.append(k)
  else:
    break
for j in sorted(l):
  print(j)

Submission status: Accepted

Solution code:
N = int(input())
S = [input() for _ in range(N)]
 
s = {}
for i in S:
  if i in s:
    s[i] += 1
  else:
    s[i] = 1
 
max_val = max(s.values())
tmp = []
for key, value in s.items():
  if value == max_val:
    tmp.append(key)

for j in sorted(tmp):
  print(j)

Submission status: Accepted

Solution code:
import collections
a = int(input())
line = [input() for k in range(a)]
c = collections.Counter(line)
common = c.most_common()
max_number = common[0][1]
a = len(common)
max_common = []
for k in range(a):
  if common[k][1] == max_number:
    max_common.append(common[k][0])
  else:
    break
for k in sorted(max_common):
  print(k)

Submission status: Accepted

Solution code:
N = int(input())
arr = []
for i in range(N):
  arr.append(input())
found = {}

# print(found, arr)

for candidate in arr:
  try:
    found[candidate] += 1
  except KeyError:
    found[candidate] = 1

s = sorted(found.items(), key=lambda n: n[1])
max = s[len(s) - 1][1]
s = list(filter(lambda t: t[1] == max, s))
s = sorted(s, key=lambda c: c[0])

print("\n".join(list(map(lambda t: t[0], s))))

Submission status: Accepted

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

d = {}
m = 0
for x in s:
    if x in d:
        d[x] += 1
        m = max(m, d[x])
    else:
        d[x] = 0

for x in sorted({k:v for k, v in d.items() if v == m}.keys()):
    print(x)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import Counter

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

c = Counter(s)

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

c = sorted(c.items())

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
# 整数の入力
n = int(input())
word_list = []

for i in range(n):
  word_list.append(input())
    
w_dictionary = {} 
for i in range(n):
  if word_list[i] not in w_dictionary:
    w_dictionary[word_list[i]] = 1
  else:
    w_dictionary[word_list[i]] += 1

score_sorted = sorted(w_dictionary.items(), key=lambda x:-x[1])
max_score = score_sorted[0][1]

key_sorted = sorted(w_dictionary.items())
for key,value in key_sorted:
  if value == max_score:
    print(key)

Submission status: Accepted

Solution code:
N = int(input())

strList = list([])

for i in range(N):
  strList.append(str(input()))

strDict = {}

for item in strList:
  if item not in strDict.keys():
    strDict[item] = 1
  else:
    strDict[item] += 1

maxList = list([])
maxNum = max(strDict.values())

for strKeys in strDict.keys():
  if strDict[strKeys] == maxNum:
    maxList.append(strKeys)

for srtedItem in sorted(maxList):
  print(srtedItem)

Submission status: Accepted

Solution code:
import collections

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

MaxStr = []
# VoteStrの値を調べて、重複回数を計算する？
# 回数が一番多いものを辞書順にする。最大数が同列ならそれらを全て。

col = collections.Counter(VoteStr)
most_value = col.most_common()[0][1]

# 出現回数が最大数かどうかをしらべる
for val, num in col.items():
    if num == most_value:
        MaxStr.append(val)

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

Submission status: Accepted

Solution code:
import collections

case = int(input())
l = [""] * case
for i in range(case):
  l[i] = input()

c = collections.Counter(l)

values, counts = zip(*c.most_common())
cnt = 0
str_list = []
for i in range(len(counts)):
  if cnt < counts[i]:
    cnt = counts[i]
    str_list.append(values[i])
  elif cnt == counts[i]:
    str_list.append(values[i])
  else:
    break

str_list = sorted(str_list)
for tar_str in str_list:
  print(tar_str)

Submission status: Accepted

Solution code:
import collections

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

counted = collections.Counter(s)

m = max(counted.values())

chars = [key for key, value in counted.items()
             if value == m]
chars.sort()

moji = '\n'.join(chars)

print(moji)

Submission status: Accepted

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

result = []
m = 0
word = s[0]
count = 0
for i in range(n):
    if word == s[i]:
        count += 1
    else:
        result.append([word, count])
        word = s[i]
        count = 1
    if count > m:
        m = count
result.append([word, count])

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

Submission status: Accepted

Solution code:
import sys
import collections

n = input()
arr = [_.replace('\n', '') for _ in sys.stdin]
dic = collections.Counter(arr)
cnt = list(dic.values()).count(max(dic.values()))
s = [k for k,v in dic.most_common(cnt)]

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

Submission status: Accepted

Solution code:
#coding utf-8
import collections

def main():
    question_c()

def question_c():
    n = int(input())
    st = [input() for i in range(n)]

    c = collections.Counter(st)
    most = list(c.most_common())

    ans = []

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

    ans = sorted(ans)
    for box in ans:
        print(box)
main()

Submission status: Accepted

Solution code:
from collections import Counter

n = int(input())

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

maxl = 0
ans = []
for i in m.most_common():
    maxl = max(maxl, i[1])
    if maxl == i[1]:
        ans.append(i[0])

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

Submission status: Accepted

Solution code:
from collections import Counter

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

CC = Counter(S)

mcnt = max(CC.values())

for key in sorted([k for k, v in CC.most_common() if v == mcnt]):
    print(key)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
N = int(input())
S = []
for i in range(N):
  S.append(input())

dic = {}

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

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

st = [dic_sorted[0][0]]
num = dic_sorted[0][1]

for i in range(1, NN):
  if(dic_sorted[i][1] == num):
    st.append(dic_sorted[i][0])
  else:
    break

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

Submission status: Accepted

Solution code:
import collections
n = int(input())
S = [input() for _ in range(n)]
c = collections.Counter(S)
C = sorted(c.most_common(),key=lambda x: x[0])
C = sorted(C,key=lambda x: x[1], reverse=True)
t = C[0][1]
for i in range(len(C)):
    if C[i][1] == t:
        print(C[i][0])

Submission status: Accepted

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

S.sort()

ans = []
most = 0
tmpstr = S[0]
tmpcnt = 0


for s in S:
    if tmpstr == s:
        tmpcnt += 1
    else:
        if tmpcnt > most:
            ans.clear()
            ans.append(tmpstr)
            most = tmpcnt

        elif tmpcnt == most:
            ans.append(tmpstr)

        tmpcnt = 1
        tmpstr = s

if tmpcnt > most:
    ans.clear()
    ans.append(tmpstr)
    most = tmpcnt
elif tmpcnt == most:
    ans.append(tmpstr)

for a in ans:
    print(a)

Submission status: Accepted

Solution code:
import collections


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

count = collections.Counter(vote_list).most_common()


mode = count[0]
mode = int(mode[1])
count= sorted(count)

for i in range(len(count)):
    temp = count[i]
    if(temp[1] == mode):
        print(temp[0])
    else:
        pass

Submission status: Accepted

Solution code:
n = int(input())
l = {}
for i in range(n):
  a = input()
  if not a in l:
    l[a] = 1
  else:
    l[a] += 1
#print(n)
#print(l)
l2 = sorted(l.items(), key=lambda val:-val[1])
#print(l2)
max_val = l2[0][1]
#print(max_val)
l3 = []
for k, v in l2:
  if max_val == v:
    #print(k)
    l3.append(k)
    continue
  break
for k in sorted(l3):
  print(k)

Submission status: Accepted

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

ini = S[0]
l = [0]
for i in range(N):
    if ini != S[i]:
        # print(ini,S[i])
        ini = S[i]
        l.append(i)
l.append(N)
l_sabun = [l[i+1] - l[i] for i in range(len(l)-1)]
# print(l)
# print(l_sabun )

S_set = list(set(S))
S_set.sort()

# print(S_set)

m = max(l_sabun)
ans = [S_set[i] for i, x in enumerate(l_sabun) if x == m]

# print(m,ans)


# print("============")

for i in ans:
    print(i)

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!
import collections

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

# 出現回数最大となる文字列の出現回数
count_max = c.most_common()[0][1]

ans_list = []
values, counts = zip(*c.most_common())

for i, count in enumerate(counts):
    if(count == count_max):
        ans_list.append(values[i])
      
for ans in sorted(ans_list):
    print(ans)

Submission status: Accepted

Solution code:
d={}
k=0
j=0
l=[]
for i in range(int(input())):
    s=input()
    if d.get(s) is None:
        d[s]=1
    else:
        d[s]+=1
for i in sorted(d,key=d.get,reverse=True):
    l.append(i)
    k=d[i]
    break
for i in sorted(d,key=d.get,reverse=True):
    j+=1
    if j>1:
        if d[i]==k:
            l.append(i)
l.sort()
for i in l:
    print(i)

Submission status: Accepted

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

from collections import Counter

co = Counter(l).most_common()
l = [co[0][0]]

for n in range(len(co)-1):
    if co[n+1][1] == co[n][1]:
        l.append(co[n+1][0])
    else:
        break
l.sort()

for n in range(len(l)):
    print(l[n])

Submission status: Accepted

Solution code:
N=int(input())
import collections
List=[input() for i in range(N)]
A=collections.Counter(List)
m=max(A.values())
X=[i for i, value in A.items() if value==m]
Y=sorted(X)
for Z in Y:
    print(Z)

Submission status: Accepted

Solution code:
from sys import stdin
#from collections import deque
#from math import sqrt, floor, ceil, log, log2, log10, pi, gcd, sin, cos, asin, tan


def ii(): return int(stdin.readline())


def fi(): return float(stdin.readline())


def mi(): return map(int, stdin.readline().split())


def fmi(): return map(float, stdin.readline().split())


def li(): return list(mi())


def lsi():
    x=list(stdin.readline())
    x.pop()
    return x


def si(): return stdin.readline()


def sieve(x):
    a=[True]*(x+1)
    sq=floor(sqrt(x))
    for i in range(3, sq+1, 2):
        if a[i]:
            for j in range(i*i, x+1, i):
                a[j]=False
    if x>1:
        p=[2]
    else:
        p=[]
    for i in range(3, x+1, 2):
        if a[i]:
            p.append(i)
    return p
def prime_factor(x):
    c=1
    i=0
    while p[i]*p[i]<=x:
        if not x%p[i]:
            c+=1
            while not x%p[i]:
                x//=p[i]
        i+=1
    if x>1:
        c+=1
    return c
res=['APPROVED', 'DENIED']
#vowel={'a', 'e', 'i', 'o', 'u', 'y', 'A', 'E', 'I', 'O', 'U', 'Y'}
#pow=[1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288, 1048576, 2097152, 4194304, 8388608, 16777216, 33554432, 67108864, 134217728, 268435456, 536870912, 1073741824, 2147483648, 4294967296, 8589934592, 17179869184, 34359738368, 68719476736, 137438953472, 274877906944, 549755813888, 1099511627776, 2199023255552, 4398046511104, 8796093022208, 17592186044416, 35184372088832, 70368744177664, 140737488355328, 281474976710656, 562949953421312, 1125899906842624, 2251799813685248, 4503599627370496, 9007199254740992, 18014398509481984, 36028797018963968, 72057594037927936, 144115188075855872, 288230376151711744, 576460752303423488, 1152921504606846976, 2305843009213693952, 4611686018427387904, 9223372036854775808]
############# CODE STARTS HERE #############
d={}
mx=1
a=[]
for i in range(ii()):
    s=si()
    if s in d:
        d[s]+=1
        mx=max(mx, d[s])
    else:
        d[s]=1
for i in d:
    if d[i]==mx:
        a.append(i)
a.sort()
for i in a:
    print(i[:-1])

Submission status: Accepted

Solution code:
N = int(input())
 
S = {}
max = 0
 
for i in range(N):
  word = input()
  if word in S:
  	S[word] += 1
  else:
    S[word] = 1
  if S[word] > max:
    S_list = []
    max = S[word]
    S_list.append(word)
  elif S[word] == max:
    S_list.append(word)
    
S_list.sort()
for out in S_list:
  print(out)

Submission status: Accepted

Solution code:
N = int(input())
S = []

for i in range(N):
    tmp = input()
    S.append(tmp)
S.sort()
if N == 1:
    print(S[0])
    exit()
ans = []
SS = []
count = 1

for i in range(N-1):
    if i == N-2:
        if S[i] == S[i+1]:
            count += 1
            ans.append(count)
            SS.append(S[i])
        else:
            ans.append(count)
            SS.append(S[i])
            ans.append(1)
            SS.append(S[i+1])
    elif S[i] == S[i+1]:
        count += 1
    else:
        ans.append(count)
        SS.append(S[i])
        count = 1

m = max(ans)

for i in range(len(SS)):
    if ans[i] == m:
        print(SS[i])

Submission status: Accepted

Solution code:
import collections
def main(N,S):
    counterS = collections.Counter(S)
    maxcount = max(counterS.values())
    keys = [k for k, v in counterS.items() if v == maxcount]
    keys.sort()
    for j in keys:
        print(j)

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

Submission status: Accepted

Solution code:
import collections
import itertools
N=int(input())
#P=list(map(int,input().split()))
st=[]
for i in range(N):
    s=str(input())
    st.append(s)
c = collections.Counter(st)
count=c.most_common()
max=count[0][1]
min=count[-1][1]
if max==min:
    st=list(set(st))
    st.sort()
    for k in st:
        print(k)
    exit()
ret=[]
for letter,cou in count:

     if cou == max:
         ret.append(letter)
     else:
         break
ret.sort()
for r in ret:
    print(r)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
S = [input() for _ in range(N)]
S.sort()
h = {}
name = set(S)
for n in name:
    h[n] = 0

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

max_h = max(h.values())
l = []
for s in set(S):
    if h[s] == max_h:
        l.append(s)

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

Submission status: Accepted

Solution code:
N=int(input())
S=[]
L=[]
C=[]

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

S.sort()
L.append(S[0])
C.append(1)
cur=0

for i in range(1,N):
    if S[i]!=S[i-1]:
        L.append(S[i])
        C.append(1)
        cur+=1
    else:
        C[cur]+=1
count_max=max(C)
for i in range(len(L)):
    if C[i]==count_max:
        print(L[i])

Submission status: Accepted

Solution code:
import queue
import collections

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

mc = collections.Counter(Ss).most_common()
_, prev = mc[0]
q = queue.PriorityQueue()
for k, v in mc:
    if prev != v:
        break
    q.put(k)
    prev = v

while not(q.empty()):
    print(q.get())

Submission status: Accepted

Solution code:
n = int(input())
l_d = {}
max_n = 0
max_w = []
for i in range(n):
    n = str(input())
    if n in l_d:
        l_d[n] += 1
        if l_d[n] > max_n:
            max_w = []
            max_w.append(n)
            max_n = l_d[n]
        elif l_d[n] == max_n:
            max_w.append(n)
    else:
        l_d[n] = 1
        if max_n <= 1:
            max_w.append(n)
            
max_w.sort()
for j in max_w:
    print(j)

Submission status: Accepted

Solution code:
N = int(input())
S = [input() for i in range(N)]
S.sort()
maxi = 0
tmp = 1
ans = []
for i in range(N-1):
  if S[i] == S[i+1]:
    tmp += 1
  else:
    if tmp > maxi:
      maxi = tmp
      ans.clear()
      ans.append(S[i])
    elif tmp == maxi:
      ans.append(S[i])
    tmp = 1
  if i == N-2:
      if S[i] == S[i+1]:
        if tmp > maxi:
          maxi = tmp
          ans.clear()
          ans.append(S[i])
        elif tmp == maxi:
          ans.append(S[i])
      else:
        if maxi == 1:
          ans.append(S[N-1])
for i in range(len(ans)):
  print(ans[i])

Submission status: Accepted

Solution code:
import collections
n =int(input())
ss = []
ans = []
for i in range(n):
    ss.append(input())
a = collections.Counter(ss)

m = max(a.values())

for i,s in a.items():

    if s == m:
        ans.append(i)
ans = sorted(ans)

for i in ans:
    print(i)