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 sys
from collections import Counter
from operator import itemgetter
def input(): return sys.stdin.readline().rstrip()
def main():
    n=int(input())
    S=[input()for _ in range(n)]
    s_cnt=Counter(S)
    s_list=sorted(list(s_cnt.items()),key=itemgetter(1),reverse=True)
    s_list=[s[0] for s in s_list if s[1]==s_list[0][1]]
    s_list.sort()
    for s in s_list:
        print(s)
if __name__=='__main__':
    main()

Submission status: Accepted

Solution code:
N = int(input())

cnt = dict()
maxcnt = 0
for _ in range(N):
    s = input()
    if s not in cnt:
        cnt[s] = 1
    else:
        cnt[s] += 1
    maxcnt = max(maxcnt, cnt[s])

ans = [s for s, c in cnt.items() if c == maxcnt]
ans = sorted(ans)
for s in ans:
    print(s)

Submission status: Accepted

Solution code:
N=int(input())
d=dict()
A=[]
ma=0
for i in range(N):
  s=input()
  if s not in d:
    d[s]=0
  d[s]+=1
ma=max(d.values())
for i,j in sorted(d.items()):
  if j==ma:
    print(i)

Submission status: Accepted

Solution code:
from collections import OrderedDict
N=int(input())
d=dict()
A=[]
ma=0
for i in range(N):
  s=input()
  if s not in d:
    d[s]=0
  d[s]+=1
d=OrderedDict(sorted(d.items(), key=lambda x:x[1], reverse=True))
for i in d:
  if ma<=d[i]:
    ma=d[i]
  if ma!=d[i]:
    break
  A.append(i)
print(*sorted(A),sep="\n")

Submission status: Accepted

Solution code:
n = int(input())
strings = [input().strip() for i in range(n)]
counter = {}

for string in strings:
    counter[string] = counter.get(string, 0) + 1

res = sorted(list(counter.items()), key=lambda x: -x[1])

result2 = []

for string, count in res:
    if count == res[0][1]:
        result2.append(string)
    else:
        break
result2.sort()
print('\n'.join(result2))

Submission status: Accepted

Solution code:
n= int(input())
s= sorted([input() for i in range(n)])
s.append("END")
ans=[]
max=-1
past=s[0]
c=1
for i in range(1,n+1):
	if past==s[i]:
		c+=1
	else:
		if c>max:
			max=c
			ans=[]
			ans.append(s[i-1])
		elif c==max:
			ans.append(s[i-1])
		c=1
	past=s[i]
for i in range(len(ans)):
	print(ans[i])

Submission status: Accepted

Solution code:
from collections import Counter
N=int(input())
s_li=[]
for i in range(N):
    s=input()
    s_li.append(s)
c=Counter(s_li)
c=c.most_common()
tmp=c[0][1]
res=[]
for j in range(len(c)):
    if tmp>c[j][1]:
        break
    res.append(c[j][0])
res.sort()
for k in range(len(res)):
    print(res[k])

Submission status: Accepted

Solution code:
from collections import Counter
_, *s = open(0)
c = Counter(s).most_common()
print(*sorted(a*(b == c[0][1]) for a,b in c))

Submission status: Accepted

Solution code:
#!/usr/bin/env python3

n = int(input())

string_dict = {}

for i in range(n):
    s = str(input())
    if s in string_dict.keys():
        string_dict[s] += 1
    else:
        string_dict[s] = 1

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

ans.sort()

for i in ans:
    print(i)

Submission status: Accepted

Solution code:
from collections import Counter

N=int(input())
S=[input() for _ in range(N)]
S=Counter(S)
count=S.most_common()
count.sort(key=lambda x:x[0])
count.sort(key=lambda x:x[1], reverse=True)

n=count[0][1]
for i in range(len(count)):
  if n==count[i][1]:
    print(count[i][0])
  else:
    break

Submission status: Accepted

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

from collections import *

cnt = Counter(S).most_common()
ans = []
for a,b in cnt:
    if b == cnt[0][1]:
        ans.append(a)
for i in sorted(ans):
    print(i)

Submission status: Accepted

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

import collections

a = collections.Counter(s)
b = a.most_common()
c = len(b)

ans = [b[0][0]]
for i in range(c-1):
    if b[i][1] > b[i+1][1]:
        break
    else:
        ans.append(b[i+1][0])

ans.sort()

for i in ans:
    print(i)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3

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

d = {}
for i in s:
    if i in d.keys():
        d[i] += 1
    else:
        d[i] = 1 
ans = []
m = max(d.values())
for k, v in d.items():
    if v == m:
        ans.append(k)

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

Submission status: Accepted

Solution code:
n=int(input())
x={}
for i in range(n):
    s=input()
    if s in x: x[s]+=1
    else :     x[s] =0
m=max(x[i] for i in x)
q=[]
for i in x:
    if x[i]==m: q.append(i)
print(*sorted(q),sep='\n')

Submission status: Accepted

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

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

largest=max(dic.values())
ans=list()

for key in dic.keys():
    if dic[key]==largest:
        ans.append(key)

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

Submission status: Accepted

Solution code:
n = int(input())
dic = {}
for i in range(n):
    s = input()
    if not s in dic.keys():
        dic[s]=1
    else:
        dic[s]+=1
maxv = max(dic.values())
ls = [i for i in dic if dic[i] == maxv]
for key in sorted(ls):
    print(key)

Submission status: Accepted

Solution code:
from collections import defaultdict

d = defaultdict(int)

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

for i in li:
    d[i] += 1
    
d = sorted(d.items(), key=lambda x:x[1], reverse=True)

ans = []

s = 0
for i in range(len(d)):
    if s == 0:
        s = d[i][1]
    
    if s == d[i][1]:
        ans.append(d[i][0])
    else:
        break
    
ans.sort()

for i in ans:
    print(i)

Submission status: Accepted

Solution code:
import operator
n = int(input())
arr=[]
for i in range(n):
    arr.append(input())
d={}
for i in arr:
    d[i]=0
for i in arr:
    d[i]+=1

val = sorted(d.values(),reverse=True)[0]

ans=[]
for i in d:
    if(d[i]==val):
        ans.append(i)

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

Submission status: Accepted

Solution code:
import os

def main():
        num = int(input())
        dict_list = {}
        for i in range(num):
                strings = input()
                if strings in dict_list.keys():
                        dict_list[strings] += 1
                else:
                        dict_list[strings] = 1 

        max_num = max(dict_list.values())
        result = []
        
        for k,v in dict_list.items():
                if v == max_num:
                        result.append(k)
        result.sort()
        for i in result:
                print(i)

if __name__ == "__main__":
        main()

Submission status: Accepted

Solution code:
from collections import Counter as cnt
n = int(input())
S = [input().replace('\n', '') for _ in range(n)]
S = cnt(S)
m = max(S.values())
S = sorted(S.items(), key=lambda x: x[0])
for s, i in S:
    if i==m: print(s)

Submission status: Accepted

Solution code:
n = int(input())

s = []
for i in range(n):
  s.append(input())
  
s.sort()
t =[]
count = 1
for i in range(1,n):
  if s[i-1] == s[i] and i != n-1:
    count+=1
  elif s[i-1] == s[i] and i == n-1:
    count += 1
    t.append([s[i-1],count])
  elif i == n-1:
    t.append([s[i-1],1])
    t.append([s[i],1])
    
  else:
    t.append([s[i-1],count])
    count = 1

t.sort(key=lambda x:x[1])
ma = t[len(t)-1][1]

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

Submission status: Accepted

Solution code:
N=int(input())

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

label=1
l=1
out=[]
for i in range(N-1):
    if S[i]==S[i+1]:
        l+=1
    else:
        if label<l:
            out=[S[i]]
            label=l
        elif label==l:
            out.append(S[i])
        l=1
if label<l:
    out=[S[-1]]
elif label==l:
    out.append(S[-1])

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

Submission status: Accepted

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

max = 0
for i in range(n):
    string = input()
    dic.setdefault(string, 0)
    dic[string] = dic[string] + 1
    if(dic[string] > max):
        max = dic[string]

dic2 = sorted(dic.items())
for s ,val in dic2:
    if(val == max):
        print(s)

Submission status: Accepted

Solution code:
N = int(input())

S = {}
for i in range(N):
    a = input()
    if not a in S.keys():
        S[a] = 1
    else:
        S[a] += 1

maxv = max(S.values())
ans = []
for i, j in S.items():
    if j == maxv:
        ans.append(i)

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

Submission status: Accepted

Solution code:

n = int (input ())
s = []
ha = {}
for i in range (n) :
    s.append (input ())
    if (s[i] not in ha.keys()) :
        ha[s[i]] = 1
    else :
        ha[s[i]] += 1

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

k = ans[0][1]
i = 0
while (i < len (ans) and ans[i][1] == k) :
    i += 1

ans = ans[ : i]
ans.sort()
for ss in ans :
    print (ss[0])

Submission status: Accepted

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

S = sorted(S)

words = [0]
word_num = 0
word_count = []
count = 0
max = 0
for i in range(0,N):
    if len(words) == 0:
        words.append(S[i])
        word_num += 1
        count += 1
    elif len(words) != 0 and S[i] != words[word_num]:
        word_count.append(count)
        if count > max:
            max = count
        count = 1
        words.append(S[i])
        word_num += 1
    elif words[word_num] == S[i]:
        count += 1
word_count.append(count)
if count > max:
            max = count

max_words = []
for i in range(0,len(words)):
    if word_count[i] == max:
        max_words.append(words[i])

for i in max_words:
    print(i)

Submission status: Accepted

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

for _ in range(n):
  s = input()
  d[s] = d.get(s, 0) + 1 

n = max(d.values())
max_k_list = [kv[0] for kv in d.items() if kv[1] == n]

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

Submission status: Accepted

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

for _ in range(n):
  s = input()
  d[s] = d.get(s, 0) + 1 

n = max(d.values())
max_k_list = [kv[0] for kv in d.items() if kv[1] == n]
max_k_list.sort()

for i in max_k_list:
  print(i)

Submission status: Accepted

Solution code:
n = int(input())
s_li = [input() for x in range(n)]
from collections import Counter
c = Counter(s_li)
c = c.most_common()
tmp = c[0][1]
res = []
for x in c:
    if tmp > x[1]:
        break
    res.append(x[0])
res.sort()
for x in res:
    print(x)

Submission status: Accepted

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

#処理
result={}
for i in S:
    if i in result:
        result[i]+=1
    else:
        result[i]=1

x=max(result.values())

Z=[]
for i in result.items():
    if i[1]==x:
        Z.append(i[0])
Z.sort()
for i in Z:
    print(i)

Submission status: Accepted

Solution code:
#
N=int(input())
S={}
for i in range(N):
    x=input()
    if x in S:
        S[x]+=1
    else:
        S[x]=1
t=max(S.values())
ans=[k for (k,v) in S.items() if v==t]
ans.sort()

for i in ans:
    print(i)
""""
#
while len(S):
    if len(S)==1:
        x = [S.pop(), 1]
        ans.append(x)
        break
    x = [S.pop(), 1]
    for i in S[:]:
        if x[0] == i:
            S.remove(i)
            x[1]+=1
    ans.append(x)
ans.sort()
ans.sort(key=lambda x:x[1],reverse=True)

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



import queue

q=queue.Queue()
for i in S:
    q.put(i)

while not q.empty():
    x = [q.get(), 1]
    if len(ans)==0:
        ans.append(x)
        continue
    t=0
    for i in range(len(ans)):
        if x[0] == ans[i][0]:
            ans[i][1]+=1
            t+=1
            break
    if t==0:
        ans.append(x)
ans.sort()
ans.sort(key=lambda x:x[1],reverse=True)

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

"""

Submission status: Accepted

Solution code:
from collections import Counter

n = int(input())
s = [input() for _ in range(n)]
cnt = Counter(s)
l = max(cnt.values())
ans = [s for s, j in cnt.items() if j == l]
ans.sort()

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

Submission status: Accepted

Solution code:
n = int(input())
table = [input() for _ in range(n)]
d = dict()
for s in table:
    if s in d.keys():
        d[s] += 1
    else:
        d[s] = 0
m = max(d.values())
l = [key for key, value in d.items() if value == m]
l.sort()
print(*l, sep = "\n")

Submission status: Accepted

Solution code:
from collections import Counter
n = int(input())
table = [input() for _ in range(n)]
c = Counter(table)
m = max(c.values())
l = [key for key, value in c.items() if value == m]
l.sort()
print(*l, sep = "\n")

Submission status: Accepted

Solution code:
# 1st:0407,2nd-:0408

#ABC041-C
if False:
    N=int(input())
    A=[int(i) for i in input().split()]
    ans=[(i,a) for i,a in enumerate(A)]
    ans.sort(key=lambda x: x[1],reverse=True)
    for i in range(N): print(ans[i][0]+1)

#AGC017-A
if False:
    N,P=map(int,input().split())
    A=[int(i) for i in input().split()]
    flag=True # 偶数のみか
    for a in A:
        if a%2==1:
            flag=False
            break
    if flag:
        if P==0:
            print(2**N)
        else:
            print(0)
    else:
        print(2**(N-1))

#3rd: ABC155-A
if False:
    print('Yes' if len(set(input().split()))==2 else 'No')
#4th: ABC155-B
if False:
    N=int(input())
    A=[int(i) for i in input().split()]
    ans='APPROVED'
    for a in A:
        if a%2==0:
            if not(a%3==0 or a%5==0):
                ans='DENIED'
    print(ans)
#5th: ABC155-C
if True:
    # dictで数える
    def cnt(lis): # list を渡す
        ret={}
        for x in set(lis):
            ret[x]=0
        for e in lis:
            ret[e]+=1
        return ret

    # dictをタプルのリストにする
    def DtoL(dic):
        return list(zip(dic.keys(),dic.values()))

    N=int(input())
    S=[input() for _ in range(N)]
    RES=DtoL(cnt(S))
    # print(RES)
    MAX=max(RES,key=lambda x: x[1])
    ANS=[]
    for r in RES:
        if r[1]==MAX[1]:
            ANS.append(r)
    ANS.sort(key=lambda x: x[0])
    for ans in ANS:
        print(ans[0])

Submission status: Accepted

Solution code:
from collections import defaultdict
d = defaultdict(int)
N = int(input())
MAX = 0
max_keys = []
for i in range(N):
    k = input()
    d[k] += 1
    if d[k] == MAX:
        max_keys.append(k)
    elif d[k] > MAX:
        MAX = d[k]
        max_keys = [k]

for i in sorted(max_keys):
    print(i)
# for i in sorted([i for i, v in d.items() if v == max(d.values())]):
#     print(i)

Submission status: Accepted

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

items = list(dic.items())
max_num = max([v[1] for v in items])
ans = []

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

ans.sort()

for v in ans:
    print(v)

Submission status: Accepted

Solution code:
import collections


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

count = collections.Counter(S)
max_n = max(count.values())
# print(max_n)

keys = [k for k, v in count.items() if v == max_n]
keys.sort()

for s in keys:
    print(s)

Submission status: Accepted

Solution code:
N = int(input())
A = [input() for i in range(N)]
import collections
c = collections.Counter(A)
#print(c)
max = c.most_common()[0][1]
#print(max)
#print(c.most_common()[0][0])
li = list(c)
#print(li)
keys = [k for k, v in c.items() if v == max]
#print(keys)
keys.sort()
for i in keys:
    print(i)

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
mv=max(d.values())
l=list()
for k,v in d.items():
    if v==mv:
        l.append(k)
l.sort()
for li in l:
    print(li)

Submission status: Accepted

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

for _ in range(n):
    s = input()

    if s in d:
        d[s] += 1
    else:
        d[s] = 1


items = list(d.items())
max_num = max([v[1] for v in items])
ans = []

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

ans.sort()

for v in ans:
    print(v)

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
import numpy as np
def print_ans(N, ar):
    """Test Case
    >>> print_ans(7, ["beat", "vet", "beet", "bed", "vet", "bet", "beet"])
    beet
    vet
    >>> print_ans(8, ["buffalo", "buffalo", "buffalo", "buffalo", "buffalo", "buffalo", "buffalo", "buffalo"])
    buffalo
    >>> print_ans(7, ["bass", "bass", "kick", "kick", "bass", "kick", "kick"])
    kick
    >>> print_ans(4, ["ushi", "tapu", "nichia", "kun"])
    kun
    nichia
    tapu
    ushi
    """
    dict = {}
    for a in ar:
        if a in dict:
            dict[a] = dict[a] + 1
        else:
            dict[a] = 0
    max_val = max(dict.values())
    key_list = sorted([key for key in dict if dict[key] == max_val])
    for key in key_list:
        print(key)


    
    

if __name__ == '__main__':
    N = int(input().rstrip())
    ar = [ input().rstrip() for _ in range(N)]
    print_ans(N, ar)

Submission status: Accepted

Solution code:
from collections import Counter
n = int(input())
l = Counter([input() for _ in range(n)])
a = sorted(list(l.items()),key=lambda x:x[1])[::-1]
t = a[0][1]
q = []
for i in range(len(l)):
  if t == a[i][1]:
    q.append(a[i][0])
  else:
    break
c = sorted(q)
print(*c,sep="\n")

Submission status: Accepted

Solution code:
n = int(input())

dic = {}

for i in range(n):
  word = input()
  if word not in dic:
    dic[word] = 1
  else:
    dic[word] += 1
    
max_num = max(dic[word] for word in dic)
l = []
for word in dic:
  if dic[word]==max_num:
    l.append(word)
    
l = sorted(l)
for i in range(len(l)):
  print(l[i])

Submission status: Accepted

Solution code:
n=int(input())
d={}
for i in range(n):
  k=input()
  d[k]=d.get(k,0)+1
val=list(d.values())
key=list(d.keys())
m=max(val)
key.sort()
for i in key:
  if d[i]==m:
    print(i)

Submission status: Accepted

Solution code:
n = int(input())

s_dict = {}
for _ in range(n):
    s = input()
    if s not in s_dict:
        s_dict[s] = 0
    s_dict[s] += 1
# print(s_dict)

count_max = sorted(s_dict.values())[-1]
# print(count_max)

s_list = []
for s, count in s_dict.items():
    if count == count_max:
        s_list.append(s)
s_list.sort()
# print(s_list)

for s in s_list:
    print(s)

Submission status: Accepted

Solution code:
import collections
N = int(input())
S = [input() for _ in range(N)]
c = collections.Counter(S)
cnt=max(c.values())
tmp = [k for k, v in c.items() if cnt==v]
print(*sorted(tmp), sep='\n')

Submission status: Accepted

Solution code:
import collections
N = int(input())
S = [input() for _ in range(N)]
c = dict(collections.Counter(S))
tmp=[]
cnt=max(c.values())
for k, v in c.items():
    if v==cnt:
        tmp.append(k)
print(*sorted(tmp), sep='\n')

Submission status: Accepted

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

m=1
c=1
L={S[0]}
for i in range(N-1):
    if S[i]==S[i+1]:
        c+=1
        if c==m:
            L.add(S[i])
        elif c>m:
            L.clear()
            L.add(S[i])
            m=c
    else:
        if c==m:
            if 0<=i<N-2:
                L.add(S[i])
            else:
                L.add(S[i])
                L.add(S[i+1])
        c=1
    #print(S,m,c,L)

R=sorted(list(L))
for j in range(len(R)):
    print(R[j])

Submission status: Accepted

Solution code:
import collections as col
N = int(input())
l = [0]*N
for i in range(N):
    l[i] = input()
ans = []

counter = col.Counter(l)
common = counter.most_common()
ans = []
ans.append(common[0][0])

for i in range(len(common)-1):
    if common[i][1] == common[i+1][1]:
        ans.append(common[i+1][0])
        i += 1
    else:
        break

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).most_common()
cnt_max = c[0][1]
ans = []
for s, cnt in c:
    if cnt != cnt_max:
        break
    ans.append(s)

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

Submission status: Accepted

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

poll = Counter(S)
max_c = max(list(poll.values()))
ans = [k for k in poll.keys() if poll[k] == max_c]
ans.sort()
for a in ans:
     print(a)

Submission status: Accepted

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

dct = {}
for st in lst:
    if st not in dct:
        dct[st] = 1

    dct[st] += 1


dct_srt = sorted(dct.items(), key=lambda x: x[1], reverse=True)
mx = 0
ans_ = []
for key, value in dct_srt:
    if value >= mx:
        mx = value
        ans_.append(key)
    else:
        break

ans = sorted(ans_)
for i in ans:
    print(i)

Submission status: Accepted

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

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

largest=max(dic.values())
ans=list()

for key in dic.keys():
    if dic[key]==largest:
        ans.append(key)

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

Submission status: Accepted

Solution code:
def s0():return input()
def s1():return input().split()
def s2(n):return [input() for x in range(n)]
def n0():return int(input())
def n1():return [int(x) for x in input().split()]
def n2(n):return [int(input()) for _ in range(n)]
def n3(n):return [[int(x) for x in input().split()] for _ in range(n)]

n=n0()
s=s2(n)

from collections import Counter
c=Counter(s)
d=dict(c.most_common())
m=max(d.values())
a=[x for x,y in d.items() if y==m]
[print(x) for x in sorted(a)]

Submission status: Accepted

Solution code:
import sys
import math

from collections import defaultdict
from collections import deque
def load(vtype=int):
    return vtype(input().strip())
def load_list(seplator=" ", vtype=int):
    return [vtype(v) for v in input().strip().split(seplator)]
def exit():
    import sys
    sys.exit(0)
def perm_sub(li, used):
    if len(li) == len(used):
        return [deque()]
    k = []
    for i in range(len(li)):
        if i in used:
            continue
        used.add(i)
        sub_list = perm_sub(li, used)
        for sub in sub_list:
            sub.appendleft(li[i])
        k.extend(sub_list)
        used.discard(i)
    return k
def perm_li(li):
    return perm_sub(li, set())
def perm_n(n):
    return perm_sub(list(range(n)), set())
def join_i(li, sep=""):
    return sep.join([str(e) for e in li])
def li2n(li):
    n, base = 0, 1
    for i in range(len(li)-1, -1, -1):
        n += li[i] * base
        base *= 10
    return n
def sli2ili(li):
    return [int(s) for s in li] 
def prime_list(n):
    li = [i for i in range(2, n+1)]
    for i in range(len(li)):
        if li[i] >= int(math.sqrt(n)):
            break
        if li[i] == -1:
            continue
        for j in range(i+1, len(li)):
            if li[j] % li[i] == 0:
                li[j] = -1
    return [n for n in li if n != -1]
def gcd(a, b):
    a, b = max(a, b), min(a, b)
    while True:
        r = a % b
        if r == 0: return b
        a, b = b, r
def lcm(a, b):
    return int(a * b / gcd(a,b))
def all_subset(li):
    s = []
    n = len(li)
    for bit in range(0, (1<<(n+1))):
        ss = set()
        for i in range(0, n):
            if (bit & (1 << i)):
                ss.add(li[i])
        s.append(ss)
    return s
def factorial(n):
    if n == 1:
        return 1
    return n * factorial(n-1)
def mCn(m, n):
    def factorial_ntimes(m, n):
        r = 1
        while n:
            r *= m
            m -= 1
            n -= 1
        return r
    return int(factorial_ntimes(m, n) / factorial(n))

n = load()
A = []
for _ in range(n):
    A.append(load(str))

cnt = defaultdict(int)
mx = 0
mxl = []

for a in A:
    cnt[a] += 1

for key, value in cnt.items():
    if value == mx:
        mxl.append(key)
        continue
    if value > mx:
        mx = value
        mxl = [key]
        continue

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

Submission status: Accepted

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


key_list=list(c.keys())
value_list=list(c.values())
list2=[]

curerent=0
k=max(value_list)
for i,item in enumerate(key_list) :
  if value_list[i]==k :
    list2.append(item)
  

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

Submission status: Accepted

Solution code:
mod = 10 ** 9 + 7
mod2 = 2 ** 61 + 1
from collections import deque
import heapq
from bisect import bisect_left, insort_left, bisect_right

_NUMINT_ALL = list(range(10))


def main():
    ans = solve()

    if ans is True or ans is False:
        YesNo(ans)
    elif ans is not None:
        print(ans)




def solve():
    N = iip(False)
    S = iipt(N, num_only=False)

    d = count_elements(S)

    dm = max(list(d.values()))
    res = []
    for k, v in d.items():
        if dm == v:
            res.append(k)
    res.sort()
    split_print_enter(res)


#####################################################ライブラリ集ここから

def kiriage_warizan(a, b):
    return -(-a//b)


def iip(listed=True, num_only=True):  # 数字のinputをlistで受け取る
    if num_only:
        ret = [int(i) for i in input().split()]
    else:
        ret = [int(i) if i in _NUMINT_ALL else i for i in input().split()]

    if len(ret) == 1 and not listed:
        return ret[0]
    return ret


def saidai_kouyakusuu(A):  # 最大公約数
    l = len(A)
    while True:
        m = min(A)
        mx = max(A)
        if m == mx:
            return m

        for i in range(l):
            if A[i] % m == 0:
                A[i] = m
            else:
                A[i] %= m


def make_graph_edge_flat(N):  # グラフ作成のための辺をリストで返す
    ret = []
    for i in range(N-1):
        a, b, c = iip()
        a -= 1
        b -= 1
        ret[a].append((b, c))
        ret[b].append((a, c))
    return ret


def sort_tuples(l, index):  # タプルのリストを特定のインデックスでソートする
    if isinstance(l, list):
        l.sort(key=lambda x: x[index])
        return l
    else:
        l = list(l)
        return sorted(l, key=lambda x: x[index])


def count_elements(l):  # リストの中身の個数を種類分けして辞書で返す
    d = {}
    for i in l:
        if i in d:
            d[i] += 1
        else:
            d[i] = 1
    return d


def safeget(l, index, default="exception"):  # listの中身を取り出す時、listからはみ出たり
    if index >= len(l):                      # マイナスインデックスになったりするのを防ぐ
        if default == "exception":
            raise Exception("".join(["safegetに不正な値 ", index, "が渡されました。配列の長さは", len(l), "です"]))
        else:
            return default
    elif index < 0:
        if default == "exception":
            raise Exception("".join(["safegetに不正な値 ", index, "が渡されました。負の値は許可されていません"]))
        else:
            return default
    else:
        return l[index]


def iipt(l, listed=False, num_only=True):  # 縦向きに並んでいるデータをリストに落とし込む(iip利用)
    ret = []
    for i in range(l):
        ret.append(iip(listed=listed, num_only=num_only))
    return ret


def sortstr(s):  # 文字列をソートする
    return "".join(sorted(s))


def iip_ord(startcode="a"):  # 文字列を数字の列に変換する(数字と文字は1:1対応)
    if isinstance(startcode, str):
        startcode = ord(startcode)
    return [ord(i) - startcode for i in input()]


def YesNo(s):  # TrueFalseや1, 0をYesNoに変換する
    if s:
        print("Yes")
    else:
        print("No")


def fprint(s):  # リストを平たくしてprintする(二次元リストを見やすくしたりとか)
    for i in s:
        print(i)


def bitall(N):  # ビット全探索用のインデックスを出力
    ret = []
    for i in range(2 ** N):
        a = []
        for j in range(N):
            a.append(i % 2)
            i //= 2
        ret.append(a)
    return ret

def split_print_space(s):  # リストの中身をスペース区切りで出力する
    print(" ".join([str(i) for i in s]))


def split_print_enter(s):  # リストの中身を改行区切りで出力する
    print("\n".join([str(i) for i in s]))


def soinsuu_bunkai(n):  # 素因数分解
    ret = []
    for i in range(2, int(n ** 0.5) + 1):
        while n % i == 0:
            n //= i
            ret.append(i)
        if i > n:
            break
    if n != 1:
        ret.append(n)
    return ret


def conbination(n, r, mod, test=False):  # nCrをmodを使って計算する
    if n <= 0:
        return 0
    if r == 0:
        return 1
    if r < 0:
        return 0
    if r == 1:
        return n
    ret = 1
    for i in range(n - r + 1, n + 1):
        ret *= i
        ret = ret % mod

    bunbo = 1
    for i in range(1, r + 1):
        bunbo *= i
        bunbo = bunbo % mod

    ret = (ret * inv(bunbo, mod)) % mod
    if test:
        # print(f"{n}C{r} = {ret}")
        pass
    return ret


def inv(n, mod):  #  modnにおける逆元を計算
    return power(n, mod - 2)


def power(n, p, mod_=mod):  # 繰り返し二乗法でn**p % modを計算
    if p == 0:
        return 1
    if p % 2 == 0:
        return (power(n, p // 2, mod_) ** 2) % mod_
    if p % 2 == 1:
        return (n * power(n, p - 1, mod_)) % mod_


def nibutan_func(func, target, left, right, side="left"): # 関数を二分探索
    l = left
    r = right
    while r-l > 1:
        x = (l+r)//2
        if func(x) == target:
            return x
        elif func(x) > target:
            r = x
        else:
            l = x

    if side == "left" or func(x) == target:
        return l
    else:
        return r


def nibutan_list(list_, target, side="left"):  # リストを二分探索
    if not isinstance(list_, list):
        list_ = list(list_)

    l = 0
    r = len(list_)
    while r-l > 1:
        x = (l+r)//2
        if list_[x] == target:
            return x
        elif list_[x] > target:
            r = x
        else:
            l = x

    if side == "left" or list_[x] == target:
        return l
    else:
        return r

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
import collections
N = int(input())
S = [input() for _ in range(N)]
count = collections.Counter(S)
maxV = max(count.values())
c = [k for k, v in count.items() if v == maxV]
print('\n'.join(sorted(c)))

Submission status: Accepted

Solution code:
from collections import Counter

N = input()
votes = []

for _ in range(int(N)):
    votes.append(input())
c = Counter(votes)
max_value = max(c.values())

output = [key for key in c.keys() if c[key]==max_value]
output.sort()
for o in output:
  print(o)

Submission status: Accepted

Solution code:
counts = {}

for _ in range(int(input())):
    s = input()
    counts[s] = counts.get(s, 0) + 1

words = []
highest_count = 0
#print(counts)

for word, count in counts.items():
    if count > highest_count:
        highest_count = count
        words = [word]
    elif count == highest_count:
        words.append(word)
#print(words)
print("\n".join(sorted(words)))