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())

from collections import defaultdict

dd = defaultdict(int)

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

maxv = max(dd.values())
res = sorted(dd.items(), key=lambda x: x[0])

for k,v in res:
    if v == maxv:
        print(k)

Solution (Python):
n = int(input())
l = [input() for _ in [0]*n]
d = {}
for s in l:
  if s in d:
    d[s]+=1
  else:
    d[s]=0
m = max(list(d.values()))
ans = []
for s in d:
  if d[s] == m:
    ans.append(s)
ans.sort()
for s in ans:
  print(s)

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

m = max(c.values())
for i in c:
    if c[i] == m:
        ans.append(i)
ans.sort()
 
for i in ans:
    print(i)

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

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

m = max(d.values())
for i in sorted(k for k in d if d[k] == m):
    print(i)

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

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

list = []
maxnum = max(d.values())

for i in d:
    if d[i] == maxnum:
        list.append(i)
list.sort()
for i in list:
    print(i)

Solution (Python):
d = {}
r = []
max = 0

n = int(input())

for i in range(n):
  k = input()
  if k in d:
    d[k] += 1
    if max < d[k]:
      max = d[k]
  else:
    d[k] = 1
    if max == 0:
      max += 1

for i in d:
  if d[i] == max:
    r.append(i)

r.sort()

for i in r:
  print(i)

Solution (Python):
import collections

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

c=collections.Counter(l)
cc=c.most_common()
ccc=[]
for j in cc:
    if j[1]==cc[0][1]:
        ccc.append(j[0])

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

Solution (Python):
n = int(input())
max=0
d={}
m=[]
for i in range(n):
    k=input()
    if k in d:
        d[k]+=1
    else:
        d[k]=1
for e in d:
    if max<d[e]:
        max=d[e]
for e in d:
    if d[e]==max:
        m.append(e)
m.sort()        
for e in m:
    print(e)

Solution (Python):
n=int(input())
a=[str(input()) for i in range(n)]
b={}
for i in a:
  if i in b:
    b[i]+=1
  else:
    b[i]=0
maxb=max(b.values())
b=sorted(b.items(),key=lambda x:x[0])
for i,j in b:
  if maxb==j:
    print(i)

Solution (Python):
N = int(input())
l = [input() for _ in range(N)]
import collections
l1 = collections.Counter(l).most_common()
l1_max = l1[0][1]
l2 = []
for name, i in l1:
    if i == l1_max:
        l2.append(name)
    else:
        break
l2.sort()
for i in l2:
    print(i)

Solution (Python):
N = int(input())
A = [""] * N
for i in range(N):
	A[i] = input()
A.sort()

c, m = 1, [1, []]
for i in range(1, N):
	if A[i - 1] == A[i]:
		c += 1
	else:
		if m[0] == c:
			m[1].append(A[i - 1])
		elif m[0] < c:
			m[1].clear()
			m[1].append(A[i - 1])
			m[0] = c
		c = 1

if m[0] == c:
	m[1].append(A[-1])
elif m[0] < c:
	m[1].clear()
	m[1].append(A[-1])

for i in m[1]:
	print(i)

Solution (Python):
import collections
polls = collections.Counter()

N = int(input())
for n in range(N):
    polls[input()] += 1

flag = True
top = polls.most_common()[0][1]
ans = [polls.most_common()[0][0]]
for p in polls.most_common()[1:]:
    if(p[1] != top):
        break
    ans.append(p[0])
ans.sort()
for a in ans:
    print(a)

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


dict = {}
for i in range(n):
  s = input()
  if(s not in dict):
    dict[s] = 0
  dict[s]+=1
  
m = max(dict.values())
strs = dict.keys()
strs = filter(lambda x: dict[x] == m , strs)
strs = sorted(strs)
for s in strs:
  print(s)

Solution (Python):
N = int(input())
List_S = [input() for i in range(N)]
List_S.sort()
List_S.append(-1)

result = []
count_list = []
count = 1
for i in range(N):
    if List_S[i] == List_S[i + 1]:
        count += 1
    else:
        result.append(List_S[i])
        count_list.append(count)
        count = 1

ma = max(count_list)

for i in range(len(result)):
    if count_list[i] == ma:
        print(result[i])

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

counts = {}
max_count = 0
for _ in range(n):
    s = input()
    if s not in counts:
        counts[s] = 1
    else:
        counts[s] += 1
    if counts[s] > max_count:
        max_count = counts[s]

outputs = []
for key, value in counts.items():
    if value == max_count:
        outputs.append(key)
outputs.sort()
for output in outputs:
    print(output)

Solution (Python):

import numpy as np
from collections import Counter

n = int(input())
sl = list(input() for _ in range(n))
sl_dct = Counter(sl)
m = 0
for i in sl_dct.values():
    m = max(m,i)

sl_s =  list(set(sl))
sl_s.sort()
for i in sl_s:
    if sl_dct[i] == m:
        print(i)

Solution (Python):
import sys
readline = sys.stdin.readline
N = int(readline())
sn = {}
maxn = 0
for _ in range(N):
    S = readline()
    if S in sn:
        sn[S] += 1
    else:
        sn[S] = 0
    maxn = max(maxn, sn[S])
ans = sorted(s for s, n in sn.items() if n == maxn)
for s in ans:
    print(s, end="")

Solution (Python):
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  

n = ni()
d = {}
for i in range(n):
    s = input()
    if s not in d.keys():
        d[s] = 1
    else:
        d[s] += 1
m = max(d.values())
ans = []
for k, v in d.items():
    if v == m:
        ans.append(k)
print(*sorted(ans))

Solution (Python):
dic = {}
ans = []
a = 0

N = int( input() )
for i in range( N ):
  let = input()
  if let not in dic:
    dic.update( { let : 1 } )
  else:
    num=dic[ let ]
    dic[ let ] = num + 1
dic_sorted = sorted(dic.items(), key=lambda x:x[1],reverse=True)
for each in dic_sorted:
  if each[1] >= a:
    ans.append(each[0])
    a=each[1]
  else:
    break
ans.sort()
for each in ans:
  print(each)

Solution (Python):
N=int(input())
answers={}
for a in range(N):
    S=input()
    if S in answers:
        answers[S]+=1
    else:
        answers[S]=1
a=max(answers.values())
keys = [k for k, v in answers.items() if v == a]
answer=sorted(keys)
for a in answer:
    print(a)

Solution (Python):
import collections
n = int(input())
s = [input() for i in range(n)]
s = collections.Counter(s)
m = 0
ans = []

for i in s.values():
  m = max(m,i)

for k, j in s.items():
  if j == m:
    ans.append(k)
ans.sort()

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

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

maxi = 0

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

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

    if st[s] > maxi:
        maxi = st[s]

ans = []
for k, v in st.items():
    if v==maxi:
        ans.append(k)

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

Solution (Python):
N = int(input(''))
dict = {}
for i in range(N):
    S = input('')
    if S in dict:
        dict[S] += 1
    else:
        dict[S] = 1
M = max(dict.values())
out = [j for j in dict.keys() if dict[j] == M]
out.sort()
for k in out:
    print(k)

Solution (Python):
n = int(input())
s_dict = dict()
for i in range(n):
    a = input()
    if a in s_dict:
        s_dict[a] += 1
    else:
        s_dict.update({a : 1})
maxi = max(s_dict.values())
ans_lst = []
for key, value in s_dict.items():
    if value == maxi:
        ans_lst.append(key)
ans_lst.sort()
for i in ans_lst:
    print(i)

Solution (Python):
N = int(input(''))
dict = {}
for i in range(N):
    S = input('')
    if S in dict:
        dict[S] += 1
    else:
        dict[S] = 1
M = max(dict.values())
out = [j for j in dict.keys() if dict[j] == M]
out.sort()
for k in out:
    print(k)

Solution (Python):
n =int(input())
s_list = list(input() for i in range(1,n+1))

from collections import Counter

c = Counter(s_list)
max = max(list(c.values()))

list = []
for kv in c.items():
    if kv[1]== max:
        list.append(kv[0])


list.sort()
list_new = '\n'.join(list)

print(list_new)

Solution (Python):
def resolve():
    import sys
    from collections import Counter

    input = sys.stdin.readline

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

    words = [input().rstrip() for i in range(n)]
    words.sort()

    word_counter = Counter(words)

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

    output_words = [c[0] for c in word_counter.most_common() if c[1] == max_count]
    output_words.sort()

    [print(w) for w in output_words]
 
resolve()

Solution (Python):
from collections import Counter

def resolve():
    N = int(input())
    c = Counter()
    for _ in range(N):
        c.update([input().strip()])

    ans = []
    commons = c.most_common()
    N = commons[0][1]
    for s,c in commons:
        if N != c:
            break
        ans += [s]
    print('\n'.join(sorted(ans)))

resolve()

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

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

dic = {}

for s in lis:
    dic[s] = dic.get(s, 0) + 1
max_num = max(dic.values())

res = []
for k, v in dic.items():
    if v == max_num:
        res.append(k)
res = sorted(res, reverse=False)
for r in res:
    print(r)

Solution (Python):
import collections
n=int(input())
s=[input() for _ in range(n)]
c=collections.Counter(s)
m=max(c.values())
ans=[]
for k,v in c.items():
  if v==m:
    ans.append(k)
ans.sort()
for a in ans:
  print(a)

Solution (Python):
from __future__ import print_function

import sys

import re
import array
import copy
import functools
import operator

import math
import string
import fractions
from fractions import Fraction
from fractions import gcd



import collections
import itertools
import bisect

import random
import time

import heapq
from heapq import heappush
from heapq import heappop
from heapq import heappushpop
from heapq import heapify
from heapq import heapreplace
from queue import PriorityQueue as pq
from queue import Queue

from itertools import accumulate

from collections import deque
from collections import Counter

from operator import mul
from functools import reduce

input = sys.stdin.readline


def eprint(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)
    return


def lcm(n, m):
    return int(n * m / gcd(n, m))


def coprimize(p, q):
    common = fractions.gcd(p, q)
    return (p // common, q // common)


def combinations_count(n, r):
    r = min(r, n - r)
    numer = reduce(mul, range(n, n - r, -1), 1)
    denom = reduce(mul, range(1, r + 1), 1)
    return numer // denom


def main():
    
    n = int(input().strip())
    C = Counter()
    frequency_max = 0
    for _ in range(n):
        S_temp = input().strip()
        C[S_temp] += 1
        frequency_max = max(frequency_max, C[S_temp])

    
    l_str=[]
    for key, value in C.items():
        if value == frequency_max:
            l_str.append(key)

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

if __name__ == '__main__':
    main()

Solution (Python):
import collections
n = int(input())
l = [input() for _ in range(n)]
d = collections.Counter(l)
M=max(d.values())
ans = []
j = list(d.values())
k = list(d.keys())
for i in range(len(j)):
  if j[i] == M:
    ans.append(k[i])
ans.sort()
for i in ans:
  print(i)

Solution (Python):
from collections import Counter

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

c = Counter(ss)
ans = []
top = c.most_common()[0][1]
for k, v in c.most_common():
    if v < top:
        break
    ans.append(k)
ans.sort()
print(*ans, sep="\n")

Solution (Python):
N = int(input())
sdic={}
for i in range(N):
  s = input()
  if s in sdic:
    sdic[s] += 1
  else:
    sdic[s] = 1
maxi = max(sdic.values())
anslist = [k for k, v in sdic.items() if v == maxi]
anslist.sort()
for ans in anslist:
  print(ans)

Solution (Python):

import sys


def solve(N: int, S: "List[str]"):
    dic = {}
    for s in S:
        if s in dic:
            dic[s] += 1
        else:
            dic[s] = 1
    mx = max(dic.values())
    max_str = []
    for k in dic:
        if dic[k] == mx:
            max_str.append(k)
    max_str.sort()
    for s in max_str:
        print(s)



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)]  
    solve(N, S)

if __name__ == '__main__':
    main()

Solution (Python):
num = int(input())
words = {}
ans = []

for _ in range(num):
    word = input()
    if word in words.keys():
        words[word] += 1
    else:
        words[word] = 1

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

for item in words:
    if count <= item[1]:
        count = item[1]
        ans.append(item[0])
    else:
        break

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

Solution (Python):
N = int(input())
from collections import Counter
Sc = Counter([input() for _ in range(N)])
max_count = max(Sc.values())
ans = sorted([k for k, v in Sc.items() if v == max_count])
print(*ans, sep="\n")

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

for word in range(n):
    word = input()
    if not word in dic:
        dic[word] = 1
    else:
        dic[word] += 1
max_v = max(dic.values())
ans = [kv[0] for kv in dic.items() if kv[1] == max_v]

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

Solution (Python):
def solve():
    N = int(raw_input())
    S = [raw_input() for i in range(N)]
    S.sort()
    curr = S[0]
    count = [[S[0], 1]]
    for i in range(1, N):
        if S[i] == curr:
            count[-1][1] += 1
        else:
            curr = S[i]
            count.append([curr, 1])
    count.sort(key = lambda x:-x[1])
    for i in range(len(count)):
        if count[i][1] == count[0][1]:
            print count[i][0]

if __name__ == '__main__':
    solve()

Solution (Python):
N = int(input())
d = {}
for i in range(N):
  key = input()
  if key in d:
    d[key] += 1
  else:
    d[key] = 1
d_max = max(d.values())
l_max = [kv[0] for kv in d.items() if kv[1] == d_max]
l_max.sort()
for ch in l_max:
  print(ch)

Solution (Python):
import collections
N = int(input())
S = [input() for i in range(N)]
ans = collections.defaultdict(int)
for i in S:
  ans[i] += 1
  
max_num = max(ans.values())
max_list = [kv[0] for kv in ans.items() if kv[1] == max_num] 
max_list.sort()
for i in max_list:
  print(i)

Solution (Python):
from collections import Counter
n = int(input())
li = [input() for _ in range(n)]
a = Counter(li)
mx = max(a.values())
keys = [k for k, v in a.items() if v == mx]
keys = sorted(keys)
for i in keys:
    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] = 1

max = 0
for i in dic:
    max = dic[i] if dic[i] > max else max




ans = []
for k,v in dic.items():
    if v == max: ans.append(k)
ans.sort()
for i in range(len(ans)):
    print(ans[i])

Solution (Python):
import collections

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

    s_list = []

    for i in range(n):
        s = str(input())
        s_list.append(s)

    c = collections.Counter(s_list)
    c_list = c.most_common()

    print_count = len(c_list)
    new_list = []

    for j in range(len(c_list)):
        new_list.append(c_list[j][0])
        if j != len(c_list)-1:
            if c_list[j+1][1] < c_list[j][1]:
                print_count = j+1
                break
    
    sorted_list = sorted(new_list)
    for k in sorted_list:
        print(k)
    

if __name__ == '__main__':
    main()

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

B = Counter(A)

saidai = max(B.values())

C=[]
for i, j in B.items():
    if j == saidai:
        C.append(i)
C.sort()
for i in C:
    print(i)

Solution (Python):
from collections import Counter

N = int(input())

S = [input() for i in range(N)]
C = Counter(S)
max_vote = max(C.values())
ans = []

for k, v in C.items():
    if v == max_vote:
        ans.append(k)
ans = sorted(ans)
print('\n'.join(ans))

Solution (Python):
from collections import Counter
N = int(input())
S = list(str(input()) for i in range(N))
c = Counter(S)
max = c.most_common()[0][1]
for max_key in sorted([k for k,v in c.items() if v==max]):
    print(max_key)

Solution (Python):
import collections

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

c = collections.Counter(s)
c_s = c.most_common()
m = c.most_common()[0][1]
ans = []
for j in range(len(c_s)):
    if c_s[j][1] != m:
        break
    else:
        ans.append(c_s[j][0])
ans.sort()
for t in ans:
    print(t)

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

import collections
cnt = collections.Counter(s)
dict = sorted(cnt)

max_vote = max(cnt.values())
ans = []
for a,b in cnt.items():
  if max_vote == b:
    ans.append(a)
ans = sorted(ans)
print('\n'.join(ans))

Solution (Python):
from collections import Counter as ct

n = int(input())
d = ct([input() for _ in range(n)]).most_common()

ans = []
tmp = d[0][1]
for i, j in d:
    if tmp == j:
        ans.append(i)
    else:
        break
print(*sorted(ans), sep="\n")

Solution (Python):
from collections import Counter
 

N = int(input())
S = Counter(input() for _ in range(N))


max_count = max(S.values())

for s in sorted(s for s in S if S[s] == max_count):
    print(s)

Solution (Python):


def submit():
    n = int(input())
    count = {}

    for _ in range(n):
        s = input().strip()
        if s not in count.keys():
            count[s] = 1
        else:
            count[s] += 1

    
    max_count = max(count.values())

    
    max_votes = []
    for s, c in count.items():
        if max_count == c:
            max_votes.append(s)
    
    max_votes.sort()
    for v in max_votes:
        print(v)


if __name__ == "__main__":
    submit()

Solution (Python):
num = int(input())
ans = []
a = [input() for i in range(num)]
a.sort()

cnt, tmp=0, 0
for i in range(len(a)-1):
  if a[i]==a[i+1]:
    tmp += 1
    if cnt == tmp:
      ans.append(a[i])
    elif cnt < tmp:
      ans.clear()
      ans.append(a[i])
      cnt = tmp
  else:
    tmp = 0

if len(ans)==0:
  a.sort()
  for i in range(len(a)):
    print(a[i])
else:
  for i in range(len(ans)):
    print(ans[i])

Solution (Python):
def main():
    from collections import Counter
    import sys
    input = sys.stdin.readline
    n=int(input())
    s=[]
    ap = s.append
    for _ in [0]*n:
        ap(input().rstrip())
    c = Counter(s)
    ans=[]
    max_vote = max(c.values())
    for i,j in c.items():
        if j == max_vote:
            ans.append(i)
    print("\n".join(sorted(ans)))
main()

Solution (Python):
def main():
    from collections import Counter
    import sys
    input = sys.stdin.readline
    n=int(input())
    s=[]
    for _ in [0]*n:
        s.append(input().rstrip())
    c = Counter(s)
    ans=[]
    max_vote = max(c.values())
    for i,j in c.items():
        if j == max_vote:
            ans.append(i)
    print("\n".join(sorted(ans)))
main()

Solution (Python):
def main():
    from collections import Counter
    import sys
    input = sys.stdin.readline
    n=int(input())
    s=[]
    for _ in range(n):
        s.append(input().rstrip())
    c = Counter(s)
    ans=[]
    max_vote = max(c.values())
    for i,j in c.items():
        if j == max_vote:
            ans.append(i)
    print("\n".join(sorted(ans)))
main()

Solution (Python):
from collections import Counter
import sys
input = sys.stdin.readline
n=int(input())
s=[]
for _ in range(n):
    s.append(input().rstrip())
c = Counter(s)
ans=[]
max_vote = max(c.values())
for i,j in c.items():
    if j == max_vote:
        ans.append(i)
print("\n".join(sorted(ans)))

Solution (Python):
from collections import Counter
n=int(input())
s=[]
for _ in range(n):
    s.append(input())
c = Counter(s)
ans=[]
max_vote = max(c.values())
for i,j in c.items():
    if j == max_vote:
        ans.append(i)
print("\n".join(sorted(ans)))

Solution (Python):
from collections import Counter
N = int(input())
S  = []
for i in range(N):
  S.append(input())
cnt = Counter(S)
ans = []
max_vote = max(cnt.values())
for a,b in cnt.items():
  if max_vote==b:
    ans.append(a)
ans = sorted(ans)
print("\r\n".join(ans))

Solution (Python):

a = int(input())
from collections import defaultdict
d = defaultdict(int)

for _ in range(a):
    d[input()]+=1
d_max = max(d.values())
ret_d = [k for k,v in d.items() if v==d_max]
ret_d.sort()
for i in ret_d:
    print(i)

Solution (Python):
import numpy as np
from collections import Counter


def mode(list):
    c = Counter(list)
    freq_scores = c.most_common()
    max_count = freq_scores[0][1]
    modes = []
    for num in freq_scores:
        if num[1] == max_count:
            modes.append(num[0])
    return(modes)

def main():
  n = int(input())
  s_list = ["a"] * n
  for i in range(n):
    s_list[i] = input()
  ans_list = mode(s_list)
  ans_list.sort()
  for i in ans_list:
    print(i)

main()

Solution (Python):
import numpy as np
from collections import Counter

def mode(list):
    c = Counter(list)
    freq_scores = c.most_common()
    max_count = freq_scores[0][1]
    modes = []
    for num in freq_scores:
        if num[1] == max_count:
            modes.append(num[0])
    return(modes)

n = int(input())
s_list = ["a"] * n
for i in range(n):
  s_list[i] = input()
ans_list = mode(s_list)
ans_list.sort()
for i in ans_list:
  print(i)

Solution (Python):
import itertools,collections
a=int(input())
l1=[str(input()) for n in range(0,a)]
c = collections.Counter(l1)
aa=int(c.most_common()[0][1])


a2 =[w for w,r in c.most_common() if r==aa]
a2=list(sorted(a2))
a3=[print(w1) for w1 in a2]

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

max_val = max(dic.values()) 

for w in sorted(dict(filter(lambda x: x[1] == max_val, list(dic.items()))).keys()):
    print(w)

Solution (Python):
from collections import Counter

N = int(input())
S = Counter(input() for _ in range(N))

max_count = max(S.values())
for s in sorted(s for s in S if S[s] == max_count):
    print(s)

Solution (Python):
from collections import Counter

def solve():
    N = int(input())
    S = [input() for _ in range(N)]
    counter = Counter(S)
    ret_t = sorted(counter.most_common(), key=lambda x:(-x[1],x[0]))
    ret_t = [t for t in ret_t if t[1] == ret_t[0][1]]
    print('\n'.join(map(lambda x:x[0],ret_t)))
    
solve()

Solution (Python):
import collections

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

for _ in range(N):
    S.append(input())
    
c = collections.Counter(S)
m = c.most_common()
mc = m[0][1]
a = list(filter(lambda x: x[1] == mc, m))
b = sorted(a)
for e in b:
    print(e[0])

Solution (Python):
import collections

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

s_counter = collections.Counter(S)
count_many = max(s_counter.values())

keys = [k for k, v in s_counter.items() if v == count_many]
for str in sorted(keys):
    print(str)

Solution (Python):
import collections

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

for _ in range(n):
	s.append(input())

count = collections.Counter(s)

c = count.most_common()

max_num = 0
ans = []
for string,num in c:
	if max_num <= num:
		max_num = num
		ans.append(string)
	else:
		break
ans.sort()
for i in ans:
	print(i)

Solution (Python):
n=int(input())
s=[input() for c in range(n)]
dic={}
ans=[]

for i in s:
  if i in dic:
    dic[i]+=1
  elif i not in dic:
    dic[i]=1
    
cntmax=max(dic.values())

for j in dic.keys():
  if dic[j]==cntmax:
    ans.append(j)
    
ans=sorted(ans)

print(" ".join(ans))

Solution (Python):
N = int(input())
test = []
name = {}


for i in range(N):
  add = str(input())
  test.append(add)


for i in test:
  if i in name:
    name[i] += 1
  if i not in name:
    name[i] =1



max_num = max(name.values())


word = []
for i in name:
  if name[i] == max_num:
    word.append(i)

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

Solution (Python):
from collections import defaultdict as DD
N = int(input())
S = DD(int)
for i in range(N):
  S[input()] += 1
M = max(S.values())
L = []
for k,v in S.items():
  if v == M:
    L.append(k)
for x in sorted(L):
  print (x)

Solution (Python):
n=int(input())
arr=[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):
n = int(input())
d = {}
for i in range(n):
    s = input()
    if s in d:
        d[s] += 1
    else :
        d[s] = 1
m = max(d.values())
ans = sorted([i for i in d if d[i] == m])
for i in ans:
    print(i)

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


dic = {}
S = list(input()for _ in range(n))
for s in S:
    if s not in dic:
        dic[s] = 0
    dic[s] += 1
sort_dic = sorted(dic.items(), key=lambda x: x[0])
max_cnt = max(dic.values())
for i in range(len(sort_dic)):
    if sort_dic[i][1] == max_cnt:
        print(sort_dic[i][0])

Solution (Python):
from sys import stdin
n=int(stdin.readline().rstrip())

dic={}
for i in range(n):
    s=stdin.readline().rstrip()
    if s in dic.keys():
        dic[s] +=1
    else:
        dic[s]=1


sup=0
suc=[]
for (i,number) in dic.items():
    if number>sup:
        suc=[]
        sup=number
        suc.append(i)
    elif number==sup:
        suc.append(i)
for k in (sorted(suc)):
    print(k)

Solution (Python):
from collections import defaultdict

n = int(input())
ss = [input().strip() for _ in range(n)]

counts = defaultdict(int)

for s in ss:
    counts[s] += 1

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

max_value = items[0][1]
max_items = [item for item in items if item[1] == max_value]

keys = [item[0] for item in max_items]
keys = sorted(keys)

for key in keys:
    print(key)

Solution (Python):
N=int(input())
string=[input() for _ in range(N)]
string.sort()
string.append("0")
max=0
cnt=1
ans=[]
for i in range(N):
    if string[i]==string[i+1]:
        cnt+=1
    elif cnt>max:
        ans=[string[i]]
        max=cnt
        cnt=1
    elif cnt==max:
        ans.append(string[i])
        cnt=1
    else:
        cnt=1
for word in ans:
    print(word)

Solution (Python):
n = int(input())
s = []
for i in range(n):
    s.append(input())
s.sort()
ans = 1
ansar = [s[0]]
now = 1
for i in range(len(s)-1):
    if s[i] == s[i+1]:
        now = now +1
    else:
        now = 1
    if now == ans:
        ansar.append(s[i+1])
    if now > ans:
        ans = now
        ansar = [s[i+1]]
for i in range(len(ansar)):
    print(ansar[i])

Solution (Python):
import collections
import sys
N = int(input())
S = [input() for _ in range(N)]

c = collections.Counter(S)
ans = []
li=c.most_common()
for i in range(len(li)):
    if i == 0:
        ans.append(((li[0][0])))
    
    if i != 0:
        if (li[i-1][1]) == (li[i][1]):
            
            ans.append(((li[i][0])))
        else:
            break

ans.sort()

for i in ans:
    print(i)

Solution (Python):
from sys import stdin
import math

n = int(stdin.readline().rstrip())

d = {}
max = 0
for i in range(n):
    s = stdin.readline().rstrip()
    if s in d.keys():
        d[s] += 1
    else:
        d[s] = 1
    if max < d[s]:
        max = d[s]

result = []
for key, value in d.items():
    if value == max:
        result.append(key)

result.sort()

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

Solution (Python):
import collections
import sys
N = int(input())
S = [input() for _ in range(N)]

c = collections.Counter(S)
ans = []
li=c.most_common()
for i in range(len(li)):
    if i == 0:
        ans.append(((li[0][0])))
    
    if i != 0:
        if (li[i-1][1]) == (li[i][1]):
            
            ans.append(((li[i][0])))
        else:
            break

ans.sort()

for i in ans:
    print(i)

Solution (Python):
import collections
N = int(input())
k = []
for i in range(N):
  k.append(input())
c = collections.Counter(k)
l = list(c.most_common())
P = l[0][1]
a = []
for i in range(len(l)):
  if l[i][1] == P:
    a.append(l[i][0])
  else:
    break
a.sort()
for j in range(len(a)):
  print(a[j])

Solution (Python):
n = int(input())
d = dict()
S = list()
ans = list()
for _ in range(n):
    s = input()
    S.append(s)
    d[s] = 0
for s in S:
    if s in d:
        d[s] += 1
d = sorted(d.items(),key = lambda x:x[1], reverse = True)
max = d[0][1]
for word in d:
    if word[1] == max:
        ans.append(word[0])
    else:
        break
ans.sort()
for w in ans:
    print('{}\n'.format(w))

Solution (Python):
n = int(input())
ar = [input() for _ in range(n)]

d = {}

for a in ar:
    if a in d:
        d[a] += 1
    else:
        d[a] = 1

max_val = max(d.values())
print("\n".join(sorted([key for key in d if d[key] == max_val])))

Solution (Python):
import collections as c

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

clist = c.Counter(alist)
anlist = clist.most_common()
anslist = []
for i in range(0,len(anlist)):
    if anlist[0][1] == anlist[i][1]:
        anslist.append(anlist[i][0])
anslistt = sorted(anslist)

for i in (anslistt):
    print(i)

Solution (Python):
import collections as c

n = int(input())
l = [input() for _ in range(n)]
c = c.Counter(l)
c = c.most_common()
ans = []
for i in c:
  if i[1] == c[0][1]: 
    ans.append(i[0])
ans.sort()
for i in ans:
  print(i)

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

dict = {}

for i in range(n):
    if s[i] in dict:
        dict[s[i]] += 1
    else:
        dict[s[i]] = 1
        
m = max(dict.values())

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

Solution (Python):
N = int(input())
s_list = {}
for i in range(N):
  S = input()
  if S in s_list.keys():
    s_list[S] += 1
  else:
    s_list[S] = 0
max = 0
maxs = []
for s,c in s_list.items():
  if c > max:
    maxs = [s]
    max = c
  elif c == max:
    maxs.append(s)
maxs.sort()
for m in maxs:
  print(m)

Solution (Python):
from collections import defaultdict
n = int(input())
d = defaultdict(int)
for i in range(n): d[input()]+=1
ds = sorted(d.items(), key = lambda x : (-x[1], x[0]))
nmx = ds[0][1]
for i in ds:
  if nmx != i[1]: break
  print(i[0])

Solution (Python):
n=int(input())
d={}
ans=[]
max=1
for i in range(n):
    s=input()
    if s in d:
        d[s]+=1
        if d[s]>max:
            max=d[s]
    else:
        d[s]=1
for word,count in d.items():
    if count==max:
        ans.append(word)
ans.sort()
for word in ans:
    print(word)

Solution (Python):
n = int(input())
p = [str(input()) for _ in range(n)]
import collections
c = collections.Counter(p)
m = max(c.values())
keys = [k for k, v in c.items() if v == m]
keys.sort()
for i in keys:
    print(i)