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

Solution (Python):
n = int(input())
d = {}
for i in range(n):
    s=input()
    if s not in d:
        d[s] = 1
    else:
        d[s] += 1
max_d = max(d.values())
print(*sorted([kv[0] for kv in d.items() if kv[1] == max_d]))

Solution (Python):
import collections
n = int(input())
s = [input() for _ in range(n)]
c = collections.Counter(s)
c = c.most_common()
base = c[0][1]
ans = []
for i in range(len(c)):
    if (c[i][1]==base):
        ans.append(c[i][0])
    else:
        break
ans.sort()
print(*ans, sep="\n")

Solution (Python):
n = int(input())
d = {}
for i in range(n):
    s=input()
    if s not in d:
        d[s] = 1
    else:
        d[s] += 1
max_d = max(d.values())
print(*sorted([kv[0] for kv in d.items() if kv[1] == max_d]))

Solution (Python):
d=dict()
for i in range(int(input())):
    s=input()
    if s not in d:
        d[s]=1
    else:
        d[s]+=1
max_v = max(d.values())
print(*sorted([kv[0] for kv in d.items() if kv[1] == max_v]))

Solution (Python):


import sys



from collections import defaultdict          















def main():
    mod = 1000000007                  
    inf = float('inf')
    sys.setrecursionlimit(10**6)    
    def input(): return sys.stdin.readline().rstrip()
    def ii():  return int(input())
    def mi():  return map(int, input().split())
    def mi_0(): return map(lambda x: int(x)-1, input().split())
    def lmi(): return list(map(int, input().split()))
    def lmi_0(): return list(map(lambda x: int(x)-1, input().split()))
    def li():  return list(input())
    
    
    n = ii()
    d = defaultdict(int)
    for _ in range(n):
        s = input()
        d[s] += 1
    max_num = - float('inf')
    for k, v in d.items():
        max_num = max(max_num, v)
    L = list(d.items())
    L.sort(key=lambda x: x[0])
    for elm in L:
        if elm[1] == max_num:
            print(elm[0])

if __name__ == "__main__":
    main()

Solution (Python):
n=int(input())
s1=[]
for i in range(n):
    s=input()
    s1.append(s)
s1.sort()
s2=sorted(list(set(s1)))
s3=[0]*(len(s2))
cnt=0
for i in range(n):
    if s2[cnt]==s1[i]:
        s3[cnt]+=1
    else:
        cnt+=1
        s3[cnt]+=1
max=max(s3)
for i in range(len(s3)):
    if max==s3[i]:
        print(s2[i])

Solution (Python):
n=int(input())
s1=[]
for i in range(n):
    s=input()
    s1.append(s)
s1.sort()
s2=sorted(list(set(s1)))
s3=[0]*(len(s2))
cnt=0
for i in range(n):
    if s2[cnt]==s1[i]:
        s3[cnt]+=1
    else:
        cnt+=1
        s3[cnt]+=1
max=max(s3)
for i in range(len(s3)):
    if max==s3[i]:
        print(s2[i])

Solution (Python):
from collections import Counter

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

S.sort() 
counted = Counter(S)
l = counted.most_common()
m = l[0][1]
l.sort()
for i in l:
    if m == i[1]:
        print(i[0])

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

Solution (Python):
from collections import Counter
N = int(input())
S =[input() for i in range(N)]
cnts = Counter(S)
mx = 0
for v in cnts.values():
    mx = max(mx, v)
    
max_words = [k for k, v in cnts.items() if v == mx]
max_words = sorted(max_words)
print(*max_words, sep ="\n")

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

d = {}
for word in s:
    if word not in d.keys():
        d[word] = 1
    else:
        d[word] += 1

max_v = max(d.values())
d = sorted(d.items(), key=lambda x: x[0])

for k, v in d:
    if v == max_v:
        print(k)

Solution (Python):
n = int(input())
s = [input() for _ in [0]*n]
d = {}
for i in s:
    if i not in d: d[i] = 1
    else: d[i] += 1
num = max(d.values())
ans = [i for i in d if d[i]==num]
print('\n'.join(sorted(ans)))

Solution (Python):

















  
n = int(input())
list_a = []

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

max_value = max(d.values())
key = sorted([k for k, v in d.items() if v == max_value])
for i in key:
    print(i)

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

a = {}

for j in range(n):
    if not(s[j] in a):
        a[s[j]] = 1
    else:
        a[s[j]] += 1

b = 0
for num in a.values():
  if num > b:
    b = num

c = []
for name,num in a.items():
  if num==b:
    c.append(name)

d=sorted(c)

for k in d:
    print(k)

Solution (Python):
n=int(input())
s=[input() for i in range(n)]
s.sort()
b=list(set(s))
b.sort()
a=s[0]
m=[0]
for i in range(n):
  if s[i]!=a:
    m.append(i)
    a=s[i]
m.append(n)
o=[]
for i in range(len(m)-1):
  o.append(m[i+1]-m[i])
num=max(o)
for i in range(len(o)):
  if o[i]==num:
    print(b[i])

Solution (Python):
n=int(input())
box={}
for i in range(n):
  vote=input()
  if not(vote in box):
    box[vote]=1
  else:
    box[vote]+=1
m=0
win=[]
for num in box.values():
  if num > m:
    m=num
for name,num in box.items():
  if num==m:
    win.append(name)
win=sorted(win)
for i in win:
  print(i)

Solution (Python):
N = int(input())
s_dict = {}

for _ in range(N):
    s = input()
    if s not in s_dict:
        s_dict[s] = 1
    else:
        s_dict[s] += 1

max_ = max(s_dict.values())
ans = []

for key in s_dict.keys():
    if s_dict[key] == max_:
       ans.append(key)
    else:
        continue

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

Solution (Python):
from collections import Counter
from itertools import groupby

def main():
    n = int(input())

    l = []
    for i in range(n):
        l.append(str(input()))

    freqs = groupby(Counter(l).most_common(), lambda x:x[1])
    d = [val for val,count in next(freqs)[1]]
    d.sort()
    for i in d:
        print(i)

main()

Solution (Python):
stdin = open(0).read().split('\n')
d={}
for i in range(1,int(stdin[0])+1):
    s=stdin[i]
    if s in d:
        d[s] = d[s]+1
    else:
        d[s] =1
max=1
for num in d.values():
    if num>max:max=num
for k,v in sorted(d.items()):
    if v==max:print(k)

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

maxs = max(s.values())
ss = []
for k, v in s.items():
  if maxs == v:
    ss.append(k)
ss.sort()
for si in ss:
  print(si)

Solution (Python):
from collections import defaultdict

n = int(input())
st = [input() for _ in range(n)]
d = defaultdict(int)
p = []
max = 0

for s in st:
  d[s] += 1
  if max < d[s]:
    max = d[s]
  
for key in d.keys():
  if d[key] == max:
    p.append(key)
p=sorted(p)
for pi in p:
  print(pi)

Solution (Python):
import sys
from collections import Counter

n, *s = sys.stdin.read().split()

def main():
    c = Counter(s)
    m = max(c.values())
    ans = [s for s, v in c.items() if v == m]
    print(*sorted(ans), sep='\n')
         
if __name__ ==  '__main__':
    main()

Solution (Python):
import sys
from collections import Counter

n, *s = sys.stdin.read().split()

def main():
    cnt = sorted(Counter(s).items(), key=lambda x: -x[1])
    m = cnt[0][1]
    ans = [s for s, c in cnt if c == m]
    print(*sorted(ans), sep='\n')
         

if __name__ ==  '__main__':
    main()

Solution (Python):
N=int(input())

d={}
for _ in range(N):
    S=input()
    if S in d:
        d[S]+=1
    else:
        d[S]=1
        
m=max(d.values())
for s in sorted(k for k in d if d[k]==m):
    print(s)

Solution (Python):
def main():
    n = int(input())
    cnt = {"":0}
    ans = 0

    for i in range(n):
        s = input()
        if cnt.get(s) == None:
            cnt[s] = 1
        else:
            cnt[s] += 1
        ans = max(ans, cnt[s])

    ls = []
    for k in cnt:
        if cnt[k] == ans:
            ls.append(k)

    ls.sort()

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

main()

Solution (Python):
N = int(input())
arr = sorted([input() for _ in range(N)])

dict ={}
for i in arr:
    if i not in dict:
        dict[i] = 1
    else:
        dict[i] += 1

max_n = max(dict.values())

ans =[]
for i in dict:
    if dict[i] == max_n:
        ans.append(i)

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

Solution (Python):
N = int(input())

d = {}

max = 0

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

ans = []

for key in d:
    if d[key]==max:
        ans.append(key)

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

Solution (Python):
N = int(input())
S =[]
times = {}
for i in range(N):
  word = input()
  if word in times:
    times[word] = times[word] + 1
  else:
    times[word] = 1
max_value = max(times.values())
words = []
for i in times.items():
  if i[1] == max_value:
    words.append(i[0])
words = sorted(words)
for i in words:
  print(i)

Solution (Python):
import sys
import os
import math

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

MOD = 10 ** 9 + 7


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N = ii()
    S = [iss() for _ in range(N)]
    S.sort()
    di = {}
    mx = 0
    for s in S:
        if s in di:
            di[s] += 1
            mx = max(di[s], mx)
        else:
            di[s] = 0

    ret = []
    for s in di:
        if di[s] == mx: ret.append(s)
    print(*sorted(ret), sep='\n')


if __name__ == '__main__':
    main()

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


m = max(times.items(), key = lambda x:x[1])[1]
a = []
for t in times.items():
	if(t[1]==m):
		a.append(t[0])
 
a.sort()
for t in a:
	print(t)

Solution (Python):
N = int(input())
S =[]
times = {}
for i in range(N):
  word = input()
  if word in times:
    times[word] = times[word] + 1
  else:
    times[word] = 1
m = max(times.items(), key = lambda x:x[1])[1]
a = []
for t in times.items():
	if(t[1]==m):
		a.append(t[0])
 
a.sort()
for t in a:
	print(t)

Solution (Python):
import collections

n = int(input());
S = [];

for i in range(n):
  S.append(input());

c = collections.Counter(S)

num = c.most_common()[0][1];
ans = [];

for a,b in c.most_common():
    if b == num:
      ans.append(a);
      continue;
    
    else:
      break;

ans = sorted(ans);

for i in ans:
  print(i);

Solution (Python):
N = int(input())
S = [input() for _ in range(N)]
import collections
max = max(collections.Counter(S).values())
letter = [a for a , b in collections.Counter(S).most_common() if b == max]
for a in sorted(letter):
    print(a)

Solution (Python):
n = int(input())
ans = {}
for i in range(n):
	s = input()
	if(ans.get(s)):
		ans[s] +=1
	else:
		ans[s] = 1

m = max(ans.items(), key = lambda x:x[1])[1]
a = []
for t in ans.items():
	if(t[1]==m):
		a.append(t[0])

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

Solution (Python):

import sys


def solve(N: int, S: "List[str]"):
    from itertools import groupby
    S = sorted(S)
    t = [(len(list(v)), k) for k, v in groupby(S)]
    n = max(tt[0] for tt in t)
    return sorted([k for _, k in filter(lambda tt: tt[0] == n, t)])



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  
    S = [next(tokens) for _ in range(N)]  
    print(*solve(N, S), sep='\n')

if __name__ == '__main__':
    main()

Solution (Python):
n = int(input())
d = dict()
for i in range(n):
    s = input()
    if not s in d:
        d[s] = 1
    else:
        d[s] += 1

sorted_d = sorted(d.items(), reverse=True, key=lambda x:x[1])
ans_list = []
for x in sorted_d:
    if x[1] == sorted_d[0][1]:
        ans_list.append(x[0])
    else:
        break

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

Solution (Python):










mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))
def main():
    n = int(input())
    dic = {}
    for i in range(n):
        s = input()
        if s in dic:
            dic[s] += 1
        else:
            dic[s] = 1
    max_ = max(dic.values())
    L = []
    for k,v in dic.items():
        if v == max_:
            L.append(k)
    L = sorted(L)
    print(*L,sep='\n')
if __name__ == '__main__':
  main()

Solution (Python):
d = {}
max_value = 1
n = int(input())
for i in range(n):
    t = input()
    if t in d.keys():
        d[t] += 1
        if d[t] > max_value:
            max_value = d[t]
    else:
        d.setdefault(t, 1)




d = sorted(d.items())

for k, v in d:
    if v == max_value:
        print(k)

Solution (Python):
def main():
    n = int(input())

    m = dict()
    n_max = -1;
    for _ in range(n):
        s = input()
        if s not in m:
            m[s] = 0
        else:
            m[s] += 1

        n_max = max(m[s], n_max)

    for k, v in sorted(m.items(), key=lambda x: x[0]):
        if v == n_max:
            print(k)


if __name__ == "__main__":
    main()

Solution (Python):
import sys
input = sys.stdin.readline
ini = lambda: int(input())
inl = lambda: list(map(int, input().split()))
ins = lambda: input().strip()
mod = 10**9 + 7

N = ini()
S = []
for i in range(N):
	S.append(ins())

import collections
cnt = collections.Counter(S)
max_c = max(cnt.values())
ans = []
for s, c in cnt.items():
	if c == max_c:
		ans.append(s)
for a in sorted(ans):
	print(a)

Solution (Python):
n = int(input())
s_dict = {}

for _ in range(n):
  s = input()
  if s_dict.get(s, -1) == -1:
    s_dict[s] = 1
  else:
    s_dict[s] += 1

if len(s_dict) == 1:
  print(list(s_dict.keys())[0])
  exit()
  
s_dict2 = sorted(s_dict.items(), key=lambda x:x[1], reverse=True)
s_list = []
i = 0

while s_dict2[i][1] == s_dict2[0][1]:
  s_list.append(s_dict2[i][0])
  i += 1
  if i == len(s_dict2):
    break

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

Solution (Python):
n = int(input())

ll = [str(input()) for i in range(n)]

import collections
c = collections.Counter(ll)

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

m = max(list(counts))

l = []
for i in range(len(values)):
  if counts[i] == m:
    l.append(values[i])

l = sorted(l)

for i in l:
  print(i)

Solution (Python):
N=int(input())
S=[input() for i in range(N)]
S=sorted(S)
cnt=1
max_cnt=1
ans=[S[0]]
for i in range(N-1):
    if S[i]==S[i+1]:
        cnt+=1
    else:
        cnt=1
    if cnt==max_cnt:
        ans.append(S[i+1])
    if cnt>max_cnt:
        max_cnt=cnt
        ans=[S[i+1]]
ans=sorted(ans)
for i in ans:
    print(i)

Solution (Python):
'''
INPUT SHORTCUTS
N, K = map(int,input().split())
N ,A,B = map(int,input().split())
string = str(input())
arr = list(map(int,input().split()))
N = int(input())
'''

N = int(input())
h = {}
maxnum = 1
for _ in range(N):
	string = ''
	string = str(input())
	if string in h:
		h[string]+=1
		maxnum = max(maxnum,h[string])
	else:
		h[string]=1
maxList = []
for i in h.keys():
	if h[i]==maxnum:
		maxList.append(i)
maxList.sort()
for x in maxList:
	print(x)

Solution (Python):
from collections import Counter
n = int(input())
s = [input() for _ in range(n)]
c = Counter(s)
ans = []
max_values = max(c.values())

for k in c.keys():
    if c[k] == max_values:
        ans.append(k)

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

Solution (Python):

def myAnswer(N:int,dic:dict) -> None:
   MAX = max(dic.values())
   dic2 = sorted(dic.items())
   for key,value in dic2:
      if(MAX == value):
         print(key)

def main():
   N = int(input())
   dic = {}
   for _ in range(N):
      s = input()
      if(s in dic.keys()):
         dic[s]+=1
      else:
         dic[s]=1
   myAnswer(N,dic)
if __name__ == '__main__':
   main()

Solution (Python):
def myAnswer(N:int,S:list) -> None:
   dic = {}
   for s in S:
      if(s in dic.keys()):
         dic[s]+=1
      else:
         dic[s]=1
   MAX = max(dic.values())
   dic2 = sorted(dic.items())
   for key,value in dic2:
      if(MAX == value):
         print(key)
   

def modelAnswer():
   tmp=1
def main():
   N = int(input())
   S = []
   for _ in range(N):
      S.append(input())
   myAnswer(N,S[:])
if __name__ == '__main__':
   main()

Solution (Python):
from collections import Counter
N = int(input())
work = [input() for _ in range(N)]
work = Counter(work)
i = -1
result = []
for key, value in work.most_common():
    if i == -1 or i == value:
        i = value
        result.append(key)
for r in sorted(result):
    print(r)

Solution (Python):
n=int(input())
s=[input() for i in range(n)]
nl={i:0 for i in set(s)}
c=0
for i in s:
  nl[i]+=1
  if nl[i]>c:
    c=nl[i]
ans=[i for i in set(s) if nl[i]==c]
ans.sort()
[print(i) for i in ans]

Solution (Python):
N=int(input())
S = [input() for _ in range(N)]
import collections 
C=collections.Counter(S)
maxC=max(C.values())
keys = [k for k, v in C.items() if v == maxC]
[print(j) for j in sorted(keys)]

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

S.sort()
ans=[S[0]]
num=1
max_num=1
for i in range(N-1):
  if(S[i]==S[i+1]):
    num+=1
  else:
    num=1
  if(num==max_num):
    ans.append(S[i+1])
  if(num>max_num):
    max_num=num
    ans=[S[i+1]]
  
ans.sort()
for i in range(len(ans)):
  print(ans[i])

Solution (Python):
from collections import defaultdict


def main():
    n = int(input())
    strings = [input() for i in range(n)]
    s_dict = defaultdict(int)
    for s in strings:
        s_dict[s] -= 1
    s_sorted = sorted(s_dict.items(), key=lambda x: (x[1], x[0]))

    max_num = s_sorted[0][1]
    for t in s_sorted:
        if t[1] == max_num:
            print(t[0])
        else:
            break
 

if __name__ == "__main__":
    main()

Solution (Python):
n = int(input())
s = []
for i in range(n):
    s.append(input())
ans = {}
for i in s:
    if i in ans:
        ans[i] += 1
    else:
        ans[i] = 1
ans2 = sorted(ans.items(), key=lambda x:x[1], reverse=True)
ans_list = {ans2[0][0]}
ans_cnt = ans2[0][1]
for i, j in ans2:
    if ans_cnt == j:
        ans_list.add(i)

ans_list2 = list(ans_list)
ans_list2.sort(reverse=False)
for i in ans_list2:
    print(i)

Solution (Python):
from collections import Counter
n=int(input())
mylist=[]
for i in range(n):
    s=input()
    mylist.append(s)

c=Counter(mylist)


answer=[]
flag=0

for word,i in c.most_common():
    
    if flag==0:
        max=i
        flag+=1
        answer.append(word)
    else:
        if i==max:
            answer.append(word)
        else:
            break

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

Solution (Python):
from collections import Counter
N = int(input())
S = Counter(input() for _ in range(N))
m = max(S.values())
for v in sorted(k for k, v in S.items() if v == m):
	print(v)

Solution (Python):
n=int(input())
arr=list(input() for _ in range(n))
dic={}

for i in range(n):
  if arr[i] not in dic:
    dic[arr[i]]=1
  else:
    dic[arr[i]]+=1
     
largest=max(dic.values())
ans=[]
for keys in dic.keys():
  if dic[keys]==largest:
    ans.append(keys)
ans=sorted(ans)

for words in ans:
  print(words)

Solution (Python):

from collections import Counter


import sys



class BufferedTokenizer:
    pass

def read_ints():
    return [int(token) for token in input().split()]

def read_tokens():
    return input().split()

def main():
    N = read_ints()[0]
    votes = Counter(input() for _ in range(N))
    best = votes.most_common(1)[0][1]
    for vote in sorted(v[0] for v in votes.most_common() if v[1] == best):
        print(vote)

if __name__ == '__main__':
    main()

Solution (Python):
from collections import defaultdict

dic = defaultdict(int)
N = int(input())
for i in range(N):
    S = input()
    dic[S] += 1
candidate = list(zip(*sorted(dic.items(), key=lambda x: (-x[1], x[0]))))
for i in range(len(candidate[0])):
    if candidate[1][i] != candidate[1][0]:
        exit()
    print(candidate[0][i])

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

max = max(dic.values())
for key, value in sorted(dic.items()):
    if value == max:
        print(key)

Solution (Python):
N=int(input())
S=[input() for i in range(N)]
dictionary={}
for word in S:
    if word in dictionary:
        dictionary[word]+=1
    else:
        dictionary[word]=1
maximum=max(dictionary.values())
for key,value in sorted(dictionary.items()):
    if value==maximum:
        print(key)

Solution (Python):
n=int(input())

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

max_k_list = []
maxvalue=max(candidates.values())
for candidate in candidates:
    if candidates[candidate]==maxvalue:
        max_k_list.append(candidate)


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

Solution (Python):
import collections
n = int(input())
s = [input() for _ in range(n)]
ss = collections.Counter(s)


n_ma = max(ss.values())
ans = []
for k in ss.keys():
    if ss[k] == n_ma:
        ans.append(k)
ans = sorted(ans)
for a in ans:
    print(a)

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

m = max(S.values())

ans = [k for k, v in S.items() if v == m]
ans.sort()



for i in ans:
    print(i)

Solution (Python):
N=int(input())
a=[]
for i in range(N):
	a.append(str(input()))
a=sorted(a)
a.append('A')
M=0
temp=0
ans=[]
for i in range(N):
	if a[i]==a[i+1]:
		temp+=1
	else:
		if M<temp:
			ans=[a[i]]
			M=temp
			temp=0
		elif M==temp:
			ans.append(a[i])
			temp=0
		else:
			temp=0
for i in range(len(ans)):
	print(ans[i])

Solution (Python):


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

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

import collections
c = collections.Counter(S)
m = max(c.values())

words = []

for k,v in c.most_common():
  if v == m:
    words += [k]
  else:
    break

for w in sorted(words):
  print(w)

Solution (Python):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

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

cnt = Counter(S)
tmp = cnt.most_common()[0][1]

all_sort = sorted(cnt.most_common(), key=lambda x:x[0])

for key, val in all_sort:
  if val == tmp:
    print(key)

Solution (Python):
from collections import Counter

N = int(input())
S = [input() for _ in range(N)]
clist = Counter(S)
M = max(clist.values())
rlist = []

for i in clist.keys():
    if clist[i] == M:
        rlist.append(i)

rlist.sort(reverse=False)

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

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

table = {}
for Si in S:
    table[Si] = 1 if table.get(Si) is None else table.get(Si) + 1

maximum = max(table.values())

condition = lambda maxium: lambda item: item[1] == maximum
condition = condition(maximum)

answer = filter(condition, table.items())
answer = dict(answer)
answer = list(answer.keys())
answer.sort()
answer = "\n".join(answer)

print(answer)

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

table = {}
for Si in S:
    table[Si] = 1 if table.get(Si) is None else table.get(Si) + 1

maximum = max(table.values())

condition = lambda maxium: lambda item: item[1] == maximum
answer = filter(condition(maximum), table.items())
answer = dict(answer)
answer = list(answer.keys())
answer.sort()
answer = "\n".join(answer)

print(answer)

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

table = {}
for Si in S:
    table[Si] = 1 if table.get(Si) is None else table.get(Si) + 1

maximum = max(table.values())

foo = lambda item: item[1] == maximum
filtered = filter(foo, table.items())
filtered = dict(filtered)
bar = list(filtered.keys())
bar.sort()

answer = "\n".join(bar)

print(answer)

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

table = {}
for Si in S:
    table[Si] = 1 if table.get(Si) is None else table.get(Si) + 1

maximum = max(table.values())

answer = []
for key, value in table.items():
    if value != maximum: continue
    
    answer.append(key)
answer.sort()
answer = "\n".join(answer)


print(answer)

Solution (Python):
N = int(input())
S = {}

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

    if s in S.keys():
        S[s] += 1
    else:
        S[s] = 1

m = max(S.values())
for s in sorted(map(lambda x: x[0], filter(lambda x: x[1] == m, S.items()))):
    print(s)

Solution (Python):
n = int(input())
dic = {}
for i in range(n):
  s = input()
  if s not in dic: dic[s] = 1
  else: dic[s] += 1
v = dic.values()
v = sorted(v)
max_num = v[len(v)-1]
ans = []
for s in dic:
  if dic[s]==max_num:
    ans.append(s)
ans = sorted(ans)
for i in range(len(ans)):
  print(ans[i])

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

n_ma = max(ss.values())
ans = []
for i in ss.keys():
    if ss[i] == n_ma:
        ans.append(i)

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

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

l = sorted(dic.items(), key=lambda x: x[1], reverse=True)
num = l[0][1]
ok = []
for i in range(len(l)):
    if l[i][1] == num:
        ok.append(l[i][0])
    else:
        break
ok.sort()
for i in ok:
    print(i)

Solution (Python):
N=int(input())
dic={}
for i in range(N):
    s=input()
    if s in dic:
        dic[s]+=1
    else:
        dic[s]=0
m=max(dic[i] for i in dic)
ans=[]
for j in dic:
    if dic[j]==m:
        ans.append(j)
ans.sort()
for k in range(len(ans)):
    print(ans[k])

Solution (Python):
N=int(input())
dic={}
for i in range(N):
    s=input()
    if s in dic:
        dic[s]+=1
    else:
        dic[s]=0
m=max(dic[i] for i in dic)
ans=[]
for j in dic:
    if dic[j]==m:
        ans.append(j)
ans.sort()
for k in range(len(ans)):
    print(ans[k])

Solution (Python):
from collections import defaultdict
N = int(input())
Ss = [input() for i in range(N)]
d = defaultdict(int)

for s in Ss:
    d[s] += 1
mx = max([d[k] for k in d.keys()])
ans = []
for k in d.keys():
    if d[k] == mx:
       ans.append(k)
for a in sorted(ans):
    print(a)

Solution (Python):
from collections import defaultdict
N = int(input())
Ss = [input() for i in range(N)]

d = defaultdict(int)
for S in Ss:
    d[S] += 1

mx = max([d[k] for k in d.keys()])

ans = []
for k in d.keys():
    if d[k] == mx:
       ans.append(k)
       
for a in sorted(ans):
    print(a)

Solution (Python):
cnt = int(input())
dict = {}

for i in range(cnt):
    vote = input()
    if vote in dict:
        dict[vote] += 1
    else:
        dict[vote] = 1
        
max_vote = max(dict.values())
a = filter(lambda x: x[1] == max_vote, dict.items())
b = map(lambda x: x[0], a)
lst = list(b)
lst.sort()
for word in lst:
    print(word)

Solution (Python):
from math import floor,ceil,sqrt,factorial,log
from collections import Counter, deque
from functools import reduce
def S(): return input()
def I(): return int(input())
def MS(): return map(str,input().split())
def MI(): return map(int,input().split())
def LS(): return list(MS())
def LI(): return list(MI())
def LLS(): return [list(map(str, l.split() )) for l in input()]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def LLSN(n: int): return [LS() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]

N = I()
L = []

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

max = []
m = 0
cnt = Counter(L)

for v, c in cnt.most_common():
     if m < c:
        max.clear()
        max.append(v)
        m = c
     elif m == c:
        max.append(v)

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

Solution (Python):
import collections

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

c = collections.Counter(l)
c = c.most_common()
 
most_count = c[0][1]
c.sort()
 
for i in range(len(c)):
    if c[i][1] == most_count:
        print(c[i][0])

Solution (Python):
N = int(input())
l = []

for _ in range(N):
    s = str(input())
    l.append(s)

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

most_count = c[0][1]
c.sort()

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

Solution (Python):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
 
N = INT()
S = [input() for _ in range(N)]
 
cnt_s = Counter(S)
tmp = cnt_s.most_common()[0][1]
for key, val in sorted(cnt_s.most_common(), key=itemgetter(0)):
		if val == tmp:
      			print(key)