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

def main():
    n = int(input())
    str_list = [input() for _ in range(n)]

    if len(str_list) == len(set(str_list)):
        str_list.sort()
        print(*str_list,sep='\n')
        exit()

    count_list = collections.Counter(str_list)

    max_num = max(count_list.values())

    output_list = []

    for k, v in count_list.items():
        if max_num == v:
            output_list.append(k)

    output_list.sort()

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

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N = int(input())
A = [input() for i in range(N)]
import collections
c = dict(collections.Counter(A))
max_value = max(list(c.values()))
ans = []
for k ,v in c.items():
    if max_value == v:
        ans.append(k)
for i in sorted(ans):
    print(i)

Submission status: Accepted

Solution code:
from collections import defaultdict

N = int(input())
D = defaultdict(int)
for i in range(N):
    D[input()] += 1

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

num = max(D.values())
ans = []
for key, value in sorted_D:
    if value == num:
        ans.append(key)
    else:
        break
ans.sort()
for i in ans:
    print(i)

Submission status: Accepted

Solution code:
N = int(input())
S = [input() for i in range(N)]
count_dict = {}
for s in S:
  if not s in count_dict.keys():
    count_dict[s] = 1
  else:
    count_dict[s] += 1
maxnum = max(count_dict.values())
count_dict = dict(filter(lambda x: x[1] == maxnum, count_dict.items()))
ans = list(count_dict.keys())
ans.sort()
for s in ans:
  print(s)

Submission status: Accepted

Solution code:
import collections

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

c = collections.Counter(S)
m = c.most_common()

ans = m[0][1]
ans_list = [i[0] for i in c.items() if i[1] >= ans]
ans_list.sort()
for i in ans_list:
    print(i)

Submission status: Accepted

Solution code:
from collections import Counter
n=int(input())
x=[]
for i in range(n):
    x.append(input())
x=Counter(x)    
x=x.most_common()
max_count=x[0][1]
max_list=[x[0][0]]
if len(x)>1:
    for i in range(1,n):
        if x[i][1] < max_count:
            break
        else:
            max_list.append(x[i][0])

#y=max_list.sort()
max_list=sorted(max_list)
for w in max_list:
    print(w)

Submission status: Accepted

Solution code:
n = int(input())
sl = {}

for i in range(n):
    s = input()
    if not(s in sl):
        sl[s] = 0
    else:
        sl[s] += 1

ans = []
s_max = max(sl.values())
for key in sl:
    if sl[key] == s_max:
        ans.append(key)

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

Submission status: Accepted

Solution code:
from collections import Counter
def main():
    N = int(input())
    S = list(input() for _ in range(N))
    counter = Counter(S)
    most_count = []
    max_count = 0
    for i, (word, cnt) in enumerate(counter.most_common()):
        if max_count>cnt:
            break
        max_count = cnt
        most_count.append(word)
    most_count.sort()
    for m in most_count:
        print(m)



if __name__=='__main__':
    main()

Submission status: Accepted

Solution code:

def main():
    N = int(input())
    S = {}
    for i in range(N):
        K = str(input())
        if(K not in S):
            S[K] = 0
        else:
            S[K] += 1
    max_v = max(S.items(), key = lambda x: x[1])
    ans = []
    for k, v in S.items():
        if v == max_v[1]:
            ans.append(k)
    ans.sort()
    for a in ans:
        print(a)
#     print(k[v.index(max(v))])
#     print(max(S, key=lambda k: S[k]))
#     print(Main(N, S))

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N=int(input())
dic={}
for i in range(N):
    s = input()
    try:
      dic[s]+=1
    except:
      dic[s]=0
slis = sorted(dic.items(), key=lambda x:x[1],reverse=True)
maxv=slis[0][1]
lis = []
for i in range(len(slis)):
  if slis[i][1]==maxv:
    lis += [slis[i][0]]
  else:
    break
lis=sorted(lis)
for s in lis:
  print(s)

Submission status: Accepted

Solution code:
from itertools import groupby
from operator import itemgetter

a = sorted(input() for _ in range(int(input())))
a = sorted((-sum(1 for _ in g), s) for s, g in groupby(a))
for _, s in next(groupby(a, itemgetter(0)))[1]:
  print(s)

Submission status: Accepted

Solution code:
import collections

N = int(input())

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

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

ans = list()
for s in c.most_common():
	if s[1] == max_value:
		ans.append(s[0])
	else:
		break

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

Submission status: Accepted

Solution code:
n = int(input())
s = {}

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

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

cnt = s[0][1]
ans = []
for i in range(len(s)):
    if s[i][1] == cnt:
        ans += [s[i][0]]
    else:
        break

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

Submission status: Accepted

Solution code:
def main():
  num = int(input())
  x = {}
  for i in range(num):
    s = input()
    if s in x:
      x[s] += 1
    else:
      x[s] = 1
  sl = []
  max_cnt = 0
  for key in x:
    if x[key] > max_cnt:
      max_cnt = x[key]
      sl = []
    if x[key] == max_cnt:
      sl.append(key)
#  print(x)
#  print(sl)
  sl.sort()
  for s in sl:
    print(s)


main()

Submission status: Accepted

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

d = dict()
m = 1

for i in range(N):
    if A[i] in d:
        d[A[i]] = d[A[i]] + 1
        if m < d[A[i]]:
            m = d[A[i]]
    else:
        d[A[i]] = 1

ans = []
keys = list(d.keys())

for i in range(len(keys)):
    if m == d[keys[i]]:
        ans.append(keys[i])

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

Submission status: Accepted

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


def solve(N: int, S: "List[str]"):
    c = collections.Counter(S)
    values, counts = zip(*c.most_common())

    max_value = counts[0]
    result_index = 0
    for count in counts[1:]:
        if count == max_value:
            result_index += 1
        else:
            pass
    results = sorted(values[: result_index + 1])
    for result in results:
        print(result)

    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word

    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    S = [next(tokens) for _ in range(N)]  # type: "List[str]"
    solve(N, S)


if __name__ == "__main__":
    main()

Submission status: Accepted

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

import collections
import copy

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

s_count = collections.Counter(s).most_common()
max_count = s_count[0][1]
roop = True
index = 1
s_count_len = len(s_count)
while roop and index < s_count_len:
    if s_count[index][1] == max_count:
        index += 1
    else:
        roop = False

values, counts = zip(*s_count[0:index])

out_list = sorted(values)
print("\n".join(out_list))

Submission status: Accepted

Solution code:
from collections import defaultdict
n=int(input())
d={}
for _ in range(n):
    n=input()
    if n in d:
        d[n]+=1
    else:
        d[n]=1
l=[]
mm=0
for y in d.values():
    if y>mm:
        mm=y
for x,y in d.items():
    if y==mm:
        l.append(x)
l=sorted(l)
for i in l:
    print(i)

Submission status: Accepted

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

mx=0

S.sort()
ni=0
ans=[]
for i in range(n):
    if ni>mx:
        ans=S[i]
        mx=ni
    elif ni==mx:
        ans+=S[i]
    if i<n-1:
        if S[i+1]==S[i]:
            ni+=1
        else:
            ni=0

    
[print(i) for i in ans]

Submission status: Accepted

Solution code:
N = int(input())

d = dict()
m = 0
for i in range(N):
    s = input()
    if s in d:
        d[s] += 1
    else:
        d[s] = 1
    if d[s] >= m:
        m = d[s]

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

Submission status: Accepted

Solution code:
# import numpy as np
N = int(input())

mydict = {}

for i in range(N):
    moji = input()
    if moji in mydict:
        mydict[moji] = mydict[moji] + 1
    else:
        mydict[moji] = 1

values = list(mydict.values())
list.sort(values, reverse=True)

max_value = values[0]
keys = list()
for key, value in mydict.items():
    if value == max_value:
        keys.append(key)
list.sort(keys)

for i in keys:
    print(i)

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] = 1

val_max = max(s.values())
keys_val_max = [k for k in s if s[k] == val_max]

keys_val_max.sort()
for k in keys_val_max:
	print(k)

Submission status: Accepted

Solution code:
n=int(input())
lis=[]
dic={}
lis2=[]
lis3=[]
b=0
for i in range(n):
    lis.append(input())
for i in lis:
    if i in dic:
        dic[i]+=1
    else:
        dic[i]=1
for i in dic.keys():
    lis2.append(dic[i])
lis2=sorted(lis2)
a=lis2[-1]
for i in dic.keys():
    if dic[i]==a:
        lis3.append(i)
lis3=sorted(lis3)
for i in lis3:
    print(i)

Submission status: Accepted

Solution code:
import collections

n = int(input())

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

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

out = list()
for e in c:
        if e[1] == mx:
                out += [e[0]]
        else:
                break
out.sort()
print(*out, sep='\n')

Submission status: Accepted

Solution code:
N = int(input())

sdict = {}

for i in range(N):
    inp = input()
    if inp in sdict:
        sdict[inp] += 1
    else:
        sdict[inp] = 1

# print(sdict)

maximum = sdict[max(sdict, key=sdict.get)]
# print(maximum)

rlist=[]

for k, v in sdict.items():
    if v == maximum:
        rlist.append(k)

rlist.sort()

for r in rlist:
    print(r)

Submission status: Accepted

Solution code:
import collections

n = int(input())
s_list = []
for _ in range(n):
    s_list.append(input())
s_data = list(collections.Counter(s_list).most_common())
s_count = int(s_data[0][1])
s_index = 0
for s in s_data:
    if int(s[1]) == s_count:
        s_index += 1
    else:
        break
output = []
for i in range(s_index):
    output.append(s_data[i][0])
output.sort()
for s in output:
    print(s)

Submission status: Accepted

Solution code:
# import numpy as np
# import math
# import copy
# from collections import deque
import sys
input = sys.stdin.readline
# sys.setrecursionlimit(10000)


def main():
    N = int(input())
    S = [input().rstrip() for _ in range(N)]

    dict = {S[0]:1}

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

    res = []

    most = max(dict.values())

    for i in dict:
        if dict[i] == most:
            res.append(i)

    res.sort()

    M = len(res)

    for i in range(M):
        print(res[i])



main()

Submission status: Accepted

Solution code:
n = int(input())

d = {}
m = 0
for i in range(n):
    s = input()
    if s not in d:
        d[s] = 0
    d[s] += 1
    if d[s] > m:
        m = d[s]
al = []
for t in d:
    if d[t] == m:
        al.append(t)
al.sort()
for t in al:
    print(t)

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
import collections

def main():
    n=int(input())
    sdic={}
    for i in range(n):
        s=input()
        if s in sdic.keys():
            sdic[s]+=1
        else:
            sdic.setdefault(s,0)
    sdic_sorted = sorted(sdic.values(), reverse=True)
    mn=sdic_sorted[0]
    ans=[]
    for k,v in sdic.items():
        if v==mn:
            ans.append(k)
    ans.sort()
    for i in ans:
        print(i.rstrip('\n'))


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

import collections
c = collections.Counter(S)
values, counts = zip(*c.most_common())
#print(c)
if len(counts)==1:
  print(values[0])
else:
  n = 0
  for j in range(1,N):
    if counts[j]!=counts[j-1]:
      n = j
      break
    else:
      n = j+1
  #print(n)
  ans = list(values[:n])
  ans = sorted(list(ans))
  #print(ans)
  for k in ans:
    print(k)

Submission status: Accepted

Solution code:
import collections
N = int(input())
S = [input() for i in range(N)]
c = collections.Counter(S)
max = max(c.values())
d = sorted(c.items(), key=lambda x: x[0])

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

Submission status: Accepted

Solution code:
from collections import defaultdict

def run():
    n = int(input())
    s = defaultdict(int)
    lst = []

    for _ in range(n):
        string = input()
        s[string] += 1
    
    max_ = 0
    
    for key in s:
        if max_ < s[key]:
            lst = [key]
            max_ = s[key]
        elif max_ == s[key]:
            lst.append(key)
    lst = sorted(lst)
    for i in lst:
        print(i)
        
    

if __name__ == "__main__":
    run()

Submission status: Accepted

Solution code:
lenght = int(input())
items = []
for _ in range(lenght):
  items.append(input())
counts = dict()
for i in items:
  counts[i] = counts.get(i, 0) + 1
a = sorted(counts.items(), key=lambda x: x[0])    
b = sorted(a, key=lambda x: x[1], reverse = True)
for i in b:
  if(i[1] == b[0][1]):
    print(i[0])
  else:
    break

Submission status: Accepted

Solution code:
n = int(input())

poll = {}
max_val = 1
for i in range(n):
    name = input()

    if name not in poll:
        poll[name] = 1
    else:
        poll[name] += 1
        max_val = max(poll[name], max_val)

winner = []

for name, vote in poll.items():
    if vote == max_val:
        winner.append(name)
        
winner.sort()
for w in winner:
    print(w)

Submission status: Accepted

Solution code:
import collections

cou = int(input())
a = []
momo = []

for i in range(cou):
    s = str(input())
    a.append(s)

c = collections.Counter(a)
values, counts = zip(*c.most_common())

d = counts.count(counts[0])

for i in range(d):
    momo.append(values[i])
    
ans = sorted(momo)

for i in ans:
    print(i)

Submission status: Accepted

Solution code:
N = int(input())
S = [input() for i in range(N)]
mydict = {}
for i in range(N):
    if S[i] not in mydict.keys():
        mydict[S[i]] = 1
    else:
        mydict[S[i]] += 1
sortedDict = sorted(mydict.items(), key=lambda x:x[1], reverse=True)
mylist = [sortedDict[0][0]]
length = len(sortedDict)
if(length > 1):
    for i in range(length-1):
        if sortedDict[i][1] == sortedDict[i+1][1]:
            mylist += [sortedDict[i+1][0]]
            i += 1
        else: break
    mylist.sort()
for i in range(len(mylist)):
    print(mylist[i])

Submission status: Accepted

Solution code:
import collections
n = int(input())
s = [input() for _ in range(n)]
c = collections.Counter(s)
if len(c) == 1:
    print(s[0])
    exit()
a = c.most_common()[0][1]
b = c.most_common()
d = collections.deque()
for i in range(n):
    if b[i][1] == a:
        d.append(b[i][0])
    else:
        break
for i in sorted(list(d)):
    print(i)

Submission status: Accepted

Solution code:
#import numpy as np
#import sys
#sys.setrecursionlimit(10**7)
#from functools import reduce
#from fractions import gcd

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

# process
d = {S[0]:1,}
for i in range(1, N):
    s = S[i]
    if s in d:
        d[s] += 1
    else:
        d[s] = 1

ans = []
mx = max(d.values())
for k, v in d.items():
    if v == mx:
        ans.append(k)

ans.sort()

# output
for a in ans:
    print(a)

Submission status: Accepted

Solution code:
import sys
input=sys.stdin.readline

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

for i in range(N):
    s_list.append(input().strip())

s_list.sort()
s_old=s_list[0]
cnt=1
maxc=0
max_list=[]
for s in s_list[1:]:
    if s==s_old:
        cnt+=1
    else:
        if cnt>maxc:
            max_list=[s_old]
            maxc=cnt
        elif cnt==maxc:
            max_list.append(s_old)
        else:
            pass

        cnt=1

    s_old=s

if cnt>maxc:
    max_list=[s_list[-1]]
elif cnt==maxc:
    max_list.append(s_list[-1])

for s in max_list:
    print(s)

Submission status: Accepted

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

c = collections.Counter(S)

values, counts = zip(*c.most_common())

ans=[]
cnt=0
m=counts[0]
for i in range(len(values)):
    if counts[i]==m:
        ans.append(values[i])
        cnt+=1
    else:
        break
ans.sort()
for i in range(cnt):
    print(ans[i])

Submission status: Accepted

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

a1 = collections.Counter(a)
values, counts = zip(*a1.most_common())

ans = values[0:counts.count(counts[0])]
ans = sorted(ans)
for i in ans:
  print(i)

Submission status: Accepted

Solution code:
import collections

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

setted_S = set(S)
counted_S = collections.Counter(S)
sorted_S = sorted(counted_S.items(), key=lambda x: x[1], reverse=True)

ans_ls = []
for s in sorted_S:
    a = sorted_S[0][1]
    if s[1] == a:
        ans_ls.append(s[0])
    else:
        break

ans_ls.sort()

for i in ans_ls:
    print(i)

Submission status: Accepted

Solution code:
import collections

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

A = []

d = collections.Counter(S)
max_v = max(d.values())

for k, v in d.items():
    if v == max_v:
        A.append(k)

A.sort()

for result in A:
    print(result)

Submission status: Accepted

Solution code:
n=int(input())
s={}
ans=[]
max=0
for i in range(n):
    st=input()
    if st in s:
        s[st]+=1
    else:
        s[st]=1
    if max<s[st]:
        max=s[st]
        ans=[st]
    elif max==s[st]:
        ans.append(st)
ans.sort()
for i in ans:
    print(i)

Submission status: Accepted

Solution code:
from collections import Counter

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

counter_S = Counter(S)

max_val = max(counter_S.values())

for k,v in sorted(counter_S.items()):
    if (v == max_val):
        print(k)

Submission status: Accepted

Solution code:
N = int(input())
S = [0] * N
for i in range(N):
    S[i] = str(input())
S.sort()
#print(S)
cnt_max = 1
cnt = 1
ans = [0] * N
ans[0] = S[0]
flag = 0
for i in range(1, N):
    if S[i-1] == S[i]:
        cnt += 1
        if i == N-1:
            if cnt > cnt_max:
                print(S[i])
                exit()
            elif cnt == cnt_max:
                ans[flag] = S[i]
    else:
        if cnt > cnt_max:
            ans = [0] * N
            ans[0] = S[i-1]
            flag = 1
            cnt_max = cnt
        elif cnt == cnt_max:
            ans[flag] = S[i-1]
            flag += 1
        cnt = 1
        if cnt == cnt_max and i == N-1:
            ans = S
    #print(cnt)

#print(ans)
i = 0
while ans[i] != 0:
    i += 1
    if i == N:
      break
ans = ans[:i]
for i in range(len(ans)):
    print(ans[i])

Submission status: Accepted

Solution code:
from collections import Counter

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

S = Counter(S)
max_val = max(S.values()) 
k_list = [ k for k, v in S.items() if v == max_val]

for k in sorted(k_list):
    print(k)

Submission status: Accepted

Solution code:
import collections
from collections import Counter
n = int(input())
s = []
ans = []
for i in range(n):
    S = input()
    s.append(S)
count = collections.Counter(s)
values, counts = zip(*count.most_common())
counts2 = list(counts).sort(reverse = True)
ans.append(values[0])
for j in range(1,len(counts)):
    if counts[0] == counts[j]:
        ans.append(values[j])
    else:
        break
ans.sort()
for k in ans:
    print(k)

Submission status: Accepted

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

dic = {}
mx = 0

for i in range(N):
  s = input()
  if s in dic:
    dic[s] = dic[s] + 1
  else:
    dic[s] = 1
  
  if mx < dic[s]:
    mx = dic[s]


for s in sorted({k for k,v in dic.items() if v==mx}):
  print(s)

Submission status: Accepted

Solution code:

N = int(input())
L = [ input() for i in range(N)]
#print(L)
    
dic = {}
m = 0

for i in L:
    if i in dic:
        dic[i] = dic[i] + 1
    else:
        dic[i] = 1
        
    if m < dic[i]:
        m = dic[i]

n = []
for i in dic:
    if dic[i] == m:
        n.append(i)
n.sort()
for i in n:
    print(i)

Submission status: Accepted

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

S = sorted(S.items(), key=lambda x: x[1], reverse=True)
max_str = []
before = S[0][1]
for i in range(len(S)):
    if before > S[i][1]:
        break
    max_str.append(S[i][0])
    before = S[i][1]
max_str.sort()
for s in max_str:
  print(s)

Submission status: Accepted

Solution code:
n = int(input())
s = ["" for i in range(n)]
for j in range(n):
    s[j] = str(input())
s.sort()
count = [0 for _ in range(len(set(s)))]
l = 0
name = list(sorted(set(s)))
for k in range(n-1):
    count[l] += 1
    if(s[k] != s[k+1]):
        l += 1

count[-1] += 1

m_v = max(count)
ansnum = []

for h in range(len(count)):
    if(count[h] == m_v):
        ansnum.append(name[h])

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

Submission status: Accepted

Solution code:
n = int(input())

dict = {}
max_count = 0
for i in range(n):
  input_line = input()
  if input_line in dict:
    dict[input_line] += 1
  else:
    dict[input_line] = 1
  if max_count < dict[input_line]:
    max_count = dict[input_line]

keys = [k for k, v in dict.items() if v == max_count]
keys.sort()
print("\n".join(keys))

Submission status: Accepted

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

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

top = D_sorted[0][1]
for k in D_sorted:
  if top == k[1]:
    print(k[0])
  else:
    exit()

Submission status: Accepted

Solution code:
N = int(input())

A = [input() for i in range(N)]

dic = {}

for i in A:
        if i not in dic:
                dic[i] = 1
        else:
                dic[i] += 1

de = 0

ans_list = []
#dic2 =　sorted(dic.values(), reverse=True)

for k, v in sorted(dic.items(), key=lambda x: x[1], reverse = True):
        if v != de and de !=0:
                break
        else:
                ans_list.append(k)
        de = v

ans_list_n = sorted(ans_list)


for i in ans_list_n:
        print(i)

Submission status: Accepted

Solution code:
n = int(input())
mymap = {}
maxi = 1
for x in range(n):
	inp = input()
	if inp in mymap:
		mymap[inp] += 1
		if mymap[inp] > maxi:
			maxi = mymap[inp]
	else:
		mymap[inp] = 1

answer = []

for x in mymap:
	if mymap[x] == maxi:
		answer.append(x)

answer.sort()

for x in answer:
	print(x)

Submission status: Accepted

Solution code:
N=int(input())
dictionary={}
for i in range(N):
    a=input()
    if a not in dictionary:
        dictionary[a] =1
    else:
        dictionary[a] +=1
dict_sorted = sorted(dictionary.items(), key=lambda x:x[0])
dict_sorted = sorted(dict_sorted, key=lambda x:x[1],reverse=True)
max_count=dict_sorted[0][1]
for i,j in dict_sorted:
    if j==max_count:
        print(i)

Submission status: Accepted

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

Submission status: Accepted

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

# max value search
max_value = sorted(str_fq_dic.values(), reverse=True)[0]
# max key search
ans_list = []
for s in str_fq_dic:
    if str_fq_dic[s]==max_value:
        ans_list.append(s)

# print output
# alphabet sort
ans_list = sorted(ans_list)
for a in ans_list:
    print(a)

Submission status: Accepted

Solution code:
N = int(input())
S = []
for _ in range(N):
    S.append(input())
T = sorted(S)
T.append("uuuuuuuuuuuuu")
s = 0
t = 0
u = 0
d = []
for i in range(0,N):
    if T[i] != T[i+1]:
        s = i + 1 -t
        t = i + 1
        if s > u:
            d = [T[i]]
            u = s
        elif s == u:
            d.append(T[i])
            u = s
s_n = '\n'.join(d)
print(s_n)

Submission status: Accepted

Solution code:
N = int(input())
tmps = input()
max_val = 1
Sdic = {tmps:1}
max_string = [tmps]
for i in range(1, N):
    tmps = input()
    if tmps in Sdic:
        Sdic[tmps] += 1
    else:
        Sdic[tmps] = 1

    if Sdic[tmps] > max_val:
        max_val = Sdic[tmps]
        max_string = [tmps]
    elif Sdic[tmps] == max_val:
        max_string.append(tmps)
max_string.sort()
for string in max_string:
    print(string)

Submission status: Accepted

Solution code:
N = int(input())
S = [input() for i in range(N)]
s = sorted(S)
import collections
c = collections.Counter(s)
C = c.most_common()
 
a = C[0][1]
b = []
for i in range(len(C)):
  if a == C[i][1]:
    b.append(C[i][0])
  else:
    break
B = sorted(b)
 
for i in B:
  print(i)

Submission status: Accepted

Solution code:
import collections

N = int(input())
area = []
for i in range(N):
    area.append(input())
c = collections.Counter(area)
max_val = max(c.values())
keys_of_max_val = [key for key in c if c[key] == max_val]
keys_of_max_val.sort()
for i in keys_of_max_val:
    print(i)

Submission status: Accepted

Solution code:
n = int(input())

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

s.sort()

tmp = -1
kouho = []
#print(s)


for i in range(n-1):
    #print(i,s[i+1])
    if s[i] == s[i+1]:
       tmp -= 1
       if i+1 == n-1:
           kouho.append([tmp,s[i]])
    else:
        kouho.append([tmp,s[i]])
        tmp = -1
        if i+1 == n-1:
            kouho.append([tmp,s[i+1]])

kouho.sort()

num = 0
print(kouho[0][1])


if len(kouho) == 1:
    exit()

for i in range(n-1):
    if kouho[0][0] == kouho[i+1][0]:
        print(kouho[i+1][1])
    else:
        exit()



#print(kouho)

Submission status: Accepted

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

S.sort()

dic = list((set(S)))
dic.sort()
times = [0] * len(dic)
aa=0

for s in S :
    if dic[aa] == s:
        times[aa] += 1
    else:
        aa += 1
        times[aa] += 1

ans = [0] * len(dic)
ma = max(times)

s_ans = []

for a in range(len(dic)):
    if times[a] == ma:
        s_ans.append(dic[a])

s_ans.sort()

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

Submission status: Accepted

Solution code:
import collections

n = int(input())
s =[]
for i in range(n):
    s.append(input())
ans = collections.Counter(s)
temp = ans.values()
temp2 = max(temp)
# print(ans)
# print(ans[temp2])
temp3 = [k for k ,v in ans.items() if v == temp2]
# print("\n")
temp3 = sorted(temp3)
for i in temp3:
    print(i)
# print(sorted(temp3))

Submission status: Accepted

Solution code:
import collections
n = int(input())
moji = []
for i in range(n):
    moji.append(input())
ans = dict(collections.Counter(moji))
mx = max(ans.values())
ans = sorted(ans.items(),key=lambda x:x[0])
mx = [kv[0] for kv in ans if kv[1]==mx]
for i in mx:
    print(i)

Submission status: Accepted

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

S.sort()

max = 0
Output = []
pt = 0
while pt < N:
    st,tmp = S[pt],0
    while pt < N and st == S[pt]:
        pt += 1
        tmp += 1
        if max == tmp:
            Output.append(st)
        if max < tmp:
            max = tmp
            Output.clear()
            Output.append(st)

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

Submission status: Accepted

Solution code:
from collections import Counter
N = int(input())
ele_l = [input() for _ in range(N)]
ans = sorted(Counter(ele_l).items(),key=lambda x:-x[1])
maxnum = ans[0][1]
ans = sorted(list(map(lambda x:x[0],list(filter(lambda x:x[1]==maxnum,ans)))))
for a in ans:
    print(a)

Submission status: Accepted

Solution code:
from collections import Counter

N = int(input())
c = Counter()
l = 0
for i in range(N):
    k = input()
    v = c.setdefault(k, 0)
    c[k] = v + 1
    if l < c[k]:
        l = c[k]
ans = sorted([k for k, n in c.items() if n==l])
[print(k) for k in ans]

Submission status: Accepted

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

def main(lst_S):
    
    lst_S = sorted(lst_S)

    prev_S = lst_S[0]
    count  = 1
    S_with_count = {}
    for S in lst_S[1:]:

        if S == prev_S:
            count += 1
        else:
            S_with_count[prev_S] = count
            count = 1

        prev_S = S

    else:
        S_with_count[S] = count
    
    max_count = max(list(S_with_count.values()))
    answer_S  = []
    for key, value in sorted(
        S_with_count.items(), key=lambda x: x[1], reverse=True
        ):
        if value == max_count:
            answer_S.append(key)
        
    return sorted(answer_S)
        
if __name__ == "__main__":

    lst_answer = main(lst_S)
    for answer in lst_answer:
        print(answer)

Submission status: Accepted

Solution code:
import collections
N = int(input())
A=[input() for i in range(N)]
c = collections.Counter(A)
values, counts = zip(*c.most_common())
k = max (counts)
l =counts.count(k)
V = []
for i in range(l):
  V.append(values[i])
L = sorted(V)
for j in range(len(L)):
  print(L[j])

Submission status: Accepted

Solution code:
import collections

N = int(input())
S = [input() for _ in range(0, N)]
mc = collections.Counter(S).most_common()
c = mc[0][1]

s = map(lambda x: x[0], filter(lambda x: x[1] == c, mc))
s = list(s)
s.sort()

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