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):
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):  
    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"):  
    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):  
    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"):  
    if isinstance(startcode, str):
        startcode = ord(startcode)
    return [ord(i) - startcode for i in input()]


def YesNo(s):  
    if s:
        print("Yes")
    else:
        print("No")


def fprint(s):  
    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):  
    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:
        
        pass
    return ret


def inv(n, mod):  
    return power(n, mod - 2)


def power(n, p, mod_=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()

Solution (Python):
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)))

Solution (Python):
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)

Solution (Python):
counts = {}

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

words = []
highest_count = 0


for word, count in counts.items():
    if count > highest_count:
        highest_count = count
        words = [word]
    elif count == highest_count:
        words.append(word)

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

Solution (Python):
n=int(input())
max=-1
a=[0]*n
a[0]=1
s =list()
for _ in range(n):
    s.append(input().split())
s.sort()
for i in range(1,n):
    if(s[i-1]==s[i]):
        a[i]=a[i-1]+1
    else:
        a[i]=1
        if max<a[i-1]:
            max=a[i-1]
if max<a[n-1]:
    max=a[n-1]
for i in range(n):
    if(max==a[i]):
        print(*s[i])

Solution (Python):
import collections
N = int(input())
s=[]
for i in range(N):
    s.append(input())
c=collections.Counter(s)
values, counts = zip(*c.most_common())
d=collections.Counter(counts)
numberOfMost=d[counts[0]]
ans =sorted([values[i] for i in range(numberOfMost)])
for i in range(numberOfMost):
    print(ans[i])

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

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

c = collections.Counter(s)
c_m = c.most_common()
max = c.most_common()[0][1]
print()
ans = []
for i in range(len(c_m)):
    if max != c_m[i][1]:
        break
    ans.append(c_m[i][0])
ans.sort()
for i in ans:
    print(i)

Solution (Python):
N = int(input())
lists = [list(map(str, input().split())) for i in range(N)]

dict = {}
for i in lists:
    if not i[0] in dict.keys():
        dict[i[0]] = 0
    if i[0] in dict.keys():
        dict[i[0]] += 1

max_index = max(dict.values())
value_ = []
for i, j in dict.items():
    if j == max_index:
        value_.append(i)
value_ = sorted(value_)


for i in value_:
    print(i)

Solution (Python):
from collections import defaultdict

n=int(input())

d=defaultdict(int)


for i in range(n):
    d[input()] +=1

m =max(d.values())

for i,j in sorted(d.items()):
    if j == m :print(i)

Solution (Python):
from collections import Counter

N = int(input())
S = [input() for _ in range(N)]
Clist = Counter(S).most_common()
num = Clist[0][1]
anses = [Clist[0][0]]
for X in Clist[1:]:
    if X[1] == num:
        anses.append(X[0])
anses.sort()
for ans in anses:
    print(ans)

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

d = {};

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

mx = 0;
for s in d:
    if d[s] > mx:
        mx = d[s];

res = [];

for s in d:
    if d[s] == mx:
        res.append(s);

res.sort();

for s in res:
    print(s);

Solution (Python):
import collections

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

i = 0

common = c.most_common()
common.sort(key = lambda x: x[1], reverse=True)

ans = []

while common[i][1] >= common[0][1]:
	ans.append(common[i][0])

	if i < len(common)-1:
		i += 1
	else:
		break

ans.sort()

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

Solution (Python):
n = int(input())
dic = {}
m = 0
for ind in range(n):
    word = input()
    if not word in dic.keys():
        dic[word] = 1
    else:
        dic[word] = dic[word] + 1
    m = max(m, dic[word])

l = []
for key in dic.keys():
    if dic[key] == m:
        l.append(key)
l.sort()
for elm in l:
    print(elm)

Solution (Python):
import collections


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

Scol = collections.Counter(S).most_common()
Sset = set([Si[0] for Si in Scol if Si[1]==Scol[0][1]])

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

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

dic = dict()
mode_words = list()

for _ in range(n):
  word = input()
  if word not in dic:
    dic[word] = 1
  else:
    dic[word] += 1

mode = max(dic.values())

for word, times in dic.items():
  if times == mode:
    mode_words.append(word)

mode_words.sort()

for word in mode_words:
  print(word)

Solution (Python):
n = int(input())
dic = {}
for _ in range(n):
    s = input()
    if s not in dic:
        dic[s] = 1
    else:
        dic[s] += 1
m = max(dic.values())
anslis = []
for k, v in dic.items():
    if v == m:
        anslis.append(k)
print('\n'.join(sorted(anslis)))

Solution (Python):

import collections


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

    most_counters = collections.Counter(s).most_common()
    most_count = most_counters[0][1]

    for t in sorted(map(lambda x: x[0], filter(lambda x: x[1] == most_count, most_counters))):
        print(t)


if __name__ == '__main__':
    main()

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

s_counter = Counter(s).most_common()
check_num = s_counter[0][1]

for i in s_counter:
  if i[1] == check_num:
    ans.append(i[0])
  else:
    break
ans.sort()
for i in ans:
  print(i)

Solution (Python):
N = int(input())
d={}
for x in range(N):
    s = input()
    if d.get(s) is None: d[s] = 1
    else: d[s] += 1
    
m = max(d.values())
ans = []
b={}
for x in d.items():
    if x[1] == m and b.get(x[0]) is None:
        ans.append(x[0])
        b[x[0]] = True
        
print('\n'.join(sorted(ans)))

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

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

dic_S = dict()
set_S = set()
for s in list_S:
    if s in set_S:
        dic_S[s] += 1
    else:
        dic_S[s] = 1
        set_S.add(s)

list_ans = sorted(dic_S.items(), key=lambda x:x[1], reverse=True)
a = 0
ans = []
for i in range(len(list_ans)):
    l = list_ans[i]
    a = max(a, l[1])
    if a <= l[1]:
        ans.append(l[0])
ans.sort()
for s in ans:
    print(s)

Solution (Python):

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

d = {}
for st in s:
    d[st] = d.get(st, 0) + 1


t = max(d.values())
ans = []
for p in d:
    if d[p] == t:
        ans.append(p)


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

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

s=sorted(s.items(),key=lambda x:(x[1],x[0]))
max=s[-1][1]
for i in s:
	if i[1]==max:
		print(i[0])

Solution (Python):
n=int(input())
list1=[]
for i in range(n):
    list1.append(input())
dict1={}
for i in list1:
    if i in dict1:
        dict1[i]+=1
    else:
        dict1[i]=1
dict2={}
for i in dict1:
    if dict1[i] in dict2:
        dict2[dict1[i]].append(i)
    else:
        dict2[dict1[i]]=[]
        dict2[dict1[i]].append(i)
l=sorted(dict2,reverse=True)
for i in l:
    l=sorted(dict2[i])
    break
for i in l:
    print(i)

Solution (Python):
N = int(input())
res = dict()
for i in range(N):
  word = input()
  if word not in res:
    res[word] = 0
  res[word] += 1
MAX = max(res.values())
max_word = [word[0] for word in res.items() if word[1] == MAX]
max_word.sort()
for el in max_word:
    print(el)

Solution (Python):
N=int(input())
dic={}
for i in range(N):
 a=input()
 if a in dic:
  dic[a]+=1
 else:
  dic[a]=1
c=max(dic.values())
keys = [k for k, v in dic.items() if v == c]
keys.sort()
for j in range(len(keys)):
 print(keys[j])

Solution (Python):
x=int(input())
List=[input() for i in range (x)]
List=sorted(List)
sum=-1
count=1
ans=[]
for i in range (x-1):
    if List[i] == List[i+1]:
        count+=1
    elif sum>count:
        count=1
    elif sum==count:
        count=1
        ans+=[List[i]]
    else:
        sum=count
        count=1
        ans=[]
        ans+=[List[i]]
if sum==count:
    ans+=[List[-1]]
elif sum<count:
        sum=count
        count=1
        ans=[]
        ans+=[List[i]]
ans=sorted(ans)
for i in ans:
    print(i)

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

import collections

c = collections.Counter(l)


value_max = max(c.values())


for k in sorted(k for k in c if c[k] == value_max ):
    print(k)

Solution (Python):
import sys
from collections import Counter

input = sys.stdin.readline

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

c = Counter(S)
max = max(c.values())

words = [k for k, v in c.items() if max == v]
words.sort()

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

Solution (Python):
import sys
from collections import Counter

input = sys.stdin.readline

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

c = Counter(S).most_common()

words = []
max = c[0][1]
for i in range(len(c)):
    if max == c[i][1]:
        words.append(c[i][0])

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

Solution (Python):
N = int(input())
S = []
for _ in range(N):
    S.append(input())
    
import collections
c = collections.Counter(S)
most = c.most_common()
answerlist = [most[0][0]]
i = 0
if len(most) > 1:
    while most[i][1] == most[i+1][1]:
        answerlist.append(most[i+1][0])
        i += 1
        if i == len(most)-1:
            break
sortanswer = sorted(answerlist)
for i in range(len(sortanswer)):
    print(sortanswer[i])

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

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

from collections import Counter

word = list(set(words))

dict = Counter(words)

max = max(dict.values())

for a in word:
    if dict[a] == max:
        continue
    else:
        del dict[a]

dict2 = sorted(dict.keys())

for a in dict2:
    print(a)

Solution (Python):
def solution():
    n = int(input())
    s = [input() for i in range(n)]
    s.sort()
    ss = [] 
    prev_str = s[0]
    max_cnt = same_cnt = 1
    s.pop(0)
    for si in s:
        if prev_str == si:
            same_cnt += 1
        else:
            ss.append([same_cnt, prev_str])
            if max_cnt < same_cnt:
                max_cnt = same_cnt
            same_cnt = 1
            prev_str = si
    ss.append([same_cnt, prev_str])
    if max_cnt < same_cnt:
        max_cnt = same_cnt
    for sss in ss:
        if sss[0] == max_cnt:
            print(sss[1])

solution()

Solution (Python):
import sys
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def dp2(ini, i, j): return [[ini]*i for i2 in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for i2 in range(j)] for i3 in range(k)]

from collections import defaultdict 
'''
N = ii()
A = li()
 
right = 1
cnt = 0
'''
'''
mae = A[0]
for left in range(N):
    if left==right:
        right += 1
    mae = A[right-1]
    while right < N and A[right] > mae:
        mae = A[right]
        right += 1
    
    
    cnt += right-left
'''
'''
for left in range(N):
    while right < N and A[right] > A[right-1]:
        right += 1
 
    cnt += right-left
    if left+1 == right:
        right += 1
 
print(cnt)
'''

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

for word in S:
    d[word] += 1


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

num = d2[0][1]
ans = []
for i in range(len(d2)):
    if num != d2[i][1]:
        break
    ans.append(d2[i][0])

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

Solution (Python):
n=int(input())
s=[input() for i in range(n)]
s=sorted(s)
s.append('')
s1=s[0]
ans=['']
tmp=1
kaisu=0
for i in range(1,n+1):
    if s[i]==s1:
        
        tmp+=1
    else:
        if kaisu<tmp:
        
        
        
            ans=['']
            ans.append(s1)
            kaisu=tmp
        elif kaisu==tmp:
        
            ans.append(s1)
        tmp=1
        s1=s[i]
        
for i in range(1,len(ans)):
    print(ans[i])

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

for st in s:
    d[st] = d.get(st, 0) + 1

t = max(d.values())
ans_append = ans.append

for x in d:
    if d[x] == t:
        ans_append(x)

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

Solution (Python):
import collections
n=int(input())
str_list=[input() for i in range(n)]
cal=collections.Counter(str_list)
cal=cal.most_common()
ans=cal[0][1]
answer=cal.sort()

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

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

import collections

c = collections.Counter(S)

c = dict(c)

value_c = []
for value in c.values():
    value_c.append(value)
max_c = max(set(value_c))

value = []
for item, key in c.items():
    if key == max_c:
        value.append(item)
        
value.sort()
for i in value:
    print(i)

Solution (Python):
from collections import defaultdict
S = defaultdict(lambda: 0)
N = int(input())
ma = 0
for _ in range(N):
    s = input()
    S[s] += 1
    ma = max(ma, S[s])
res = [s for (s, cnt) in S.items() if cnt == ma]
res.sort()
print(*res, sep='\n')

Solution (Python):
import collections

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

c = collections.Counter(a)
most_count = c.most_common()[0][1]
most_values = []
for i in c.items():
    if i[1] == most_count:
        most_values.append(i[0])

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

Solution (Python):
n=int(input())
a_dict={}
for i in range(n):
    a=input()
    if a not in a_dict:
        a_dict[a]=0
    else:
        a_dict[a]+=1
k=max(a_dict.values())
moji=[i for i,j in a_dict.items() if j==k ]





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

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

moji=[]
j=max(a_dict.values())
for i,k in a_dict.items():
    if k==j:
        moji.append(i)
moji=sorted(moji)
for i in moji:
    print(i)

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

moji=[]
j=max(a_dict.values())
for i,k in a_dict.items():
    if k==j:
        moji.append(i)
moji=sorted(moji)
for i in moji:
    print(i)

Solution (Python):
from collections import*;n,*s=open(0);c=Counter(s).most_common();print(*sorted(t for t,i in c if i==c[0][1]))

Solution (Python):
import collections
N = int(input()) 
S = [0]*N
m = 0
for i in range(N):
    S[i] = input()
c = collections.Counter(S)
values,counts = zip(*c.most_common())
X = c.most_common()[0][1]
list = []
for i in range(0,len(c.most_common())):
    if counts[i] == X:
        list.append(values[i])
        m+=1
    else:
        break
list.sort()
for i in range(0,m):
    print(list[i])

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

d = {}
for st in s:
    d[st] = d.get(st, 0) + 1

t = max(d.values())
ans = []
for p in d:
    if d[p] == t:
        ans.append(p)

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

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

d = {}
for str in s:
    d[str] = d.get(str,0) + 1

t = max(d.values())
ans = []
for p in d:
    if d[p] == t : ans.append(p)

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

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

c = Counter(lst)
max_num = max(c.values())
most_lst = sorted([k for k, v in c.items() if v == max_num])
for x in most_lst:
    print(x)

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

lst_af = sorted(lst)

word = lst_af[0]
most_lst = []
most_lst.append(word)
max_num = 1
cnt = 1

for i in range(1, n):
    now_word = lst_af[i]
    if now_word == word:
        cnt += 1
    else:
        cnt = 1
    if max_num == cnt:
        most_lst.append(now_word)
    if max_num < cnt:
        most_lst = []
        most_lst.append(now_word)
        max_num = cnt
    word = now_word

for x in most_lst:
    print(x)

Solution (Python):
from collections import Counter

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

c = Counter(s)
m = c.most_common()

top_count = m[0][1]
ans = [m[0][0]]
for word, count in m[1:]:
    if count == top_count:
        ans.append(word)
    else:
        break

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

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

d ={}
for _ in range( n ):
  s = input()
  if d.get( s ):
    d[ s ] += 1
  else:
    d[ s ] = 1
m = max( d.values() )

l=[]
for k, v in d.items():
  if v == m:
    l.append(k)
l = sorted( l )
for i in l:
  print( i )

Solution (Python):
import collections
N = int(input())
S = [""]*N
for i in range(N):
    S[i] = input()
    
c = collections.Counter(S)
an = sorted(c.items(), key=lambda x:x[0])
ans = sorted(an, key=lambda x:x[1], reverse=True)

print(ans[0][0])
for i in range(1, len(c)):
    if(ans[i-1][1] != ans[i][1]):
        break
    print(ans[i][0])

Solution (Python):
n = int(input())
l = [input() for i in range(n)]
d = {}
for i in l:
    if i in d:
        d[i] += 1
    else:
        d[i] = 1
d_max = max(d.values())
for i in sorted(d):
    if d[i] == d_max:
        print(i)

Solution (Python):
import collections
N = int(input()) 
S = [0]*N
for i in range(N):
    S[i] = input()
c = collections.Counter(S)
values,counts = zip(*c.most_common())
m = 0
for j in range(1,len(values)):
    if len(values) == 1:
        break
    if counts[j-1] != counts[j]:
        break
    m+=1
common = []
for n in range(m+1):
    common.append(values[n])
new = sorted(common)
for u in range(m+1):
    print(new[u])

Solution (Python):
import bisect
import heapq
import sys
import queue


input = sys.stdin.readline
sys.setrecursionlimit(100000)


class V:
    def __init__(self, f):
        self.f = f
        self.v = None

    def __str__(self):
        return str(self.v)

    def ud(self, n):
        if self.v is None:
            self.v = n
        else:
            self.v = self.f(self.v, n)

    def get(self):
        return self.v


def read_values():
    return map(int, input().split())


def read_list():
    return list(read_values())


def main():
    N = int(input())
    D = {}
    for _ in range(N):
        s = input().strip()
        D[s] = D.setdefault(s, 0) + 1

    vm = max(D.values())
    ks = [k for k, v in D.items() if v == vm]
    ks.sort()
    print("\n".join(ks))


if __name__ == "__main__":
    main()

Solution (Python):
n=int(input())
s={}
for _ in range(n):
    a=str(input())
    s[a]=s.get(a,0)
    s[a]+=1
t=(max(s.values()))
ans=[]
for k in s:
  if s[k]==t:
    ans.append(k)
ans.sort()
print(*ans)

Solution (Python):
N = int(input())
S = [input() for _ in range(N)]
d = {}

for i in S:
    if i in d:
        d[i] += 1
    else:
        d[i] = 1

M = max(d.values())

for s in sorted(k for k in d if d[k] == M):
    print(s)

Solution (Python):
N = int(input())
S = sorted([input() for _ in range(N)]) + ['']
ans = []
tmpnum = 1
tmpmax = 1

for i in range(1, N+1):
    if S[i] == S[i-1]:
        tmpnum += 1
    else:
        if tmpnum == tmpmax:
            ans.append(S[i-1])
            tmpnum = 1
        elif tmpnum > tmpmax:
            tmpmax = tmpnum
            ans = [S[i-1]]
            tmpnum = 1
        else:
            tmpnum = 1

for i in ans:
    print(i)

Solution (Python):
from collections import Counter
lst=[]
for i in range(int(input())):
    lst.append(input())
dic=Counter(lst)
lst=dic.most_common()
lst2=[]
for i in lst:
    if i[1]==lst[0][1]:
        lst2.append(i[0])
lst2.sort()
for i in lst2:
    print(i)

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

Solution (Python):
from collections import Counter
n = int(input())
d = [input() for _ in range(n)]
c = Counter(d)
m = c.most_common()[0][1]

ans = []
for k, v in c.items():
    if v == m:
        ans.append(k)
ans.sort()
for a in ans:
    print(a)

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

for i in range(n):
    s = input()
    a.setdefault(s, 0)
    a[s] += 1

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

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

Solution (Python):
from collections import Counter
n = int(input())
s = [input() for i in range(n)]
mc = Counter(s).most_common()
ans = [i[0] for i in mc if i[1] == mc[0][1]]
ans.sort()
for i in ans:
    print(i)

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

Solution (Python):
from collections import Counter

N = int(input())
l = []
for _ in range(N):
    l.append(input())
c = Counter(l)
max_count = c.most_common()[0][1]


output = []
for v in c.most_common():
    if v[1] == max_count:
        output.append(v[0])
    else:
        break

output.sort()
for elem in output:
    print(elem)

Solution (Python):
n = int(input())
d = dict()
for i in range(n):
    a = input()
    if a in d:
        d[a] = d[a] + 1
    else:
        d[a] = 0
m = max(d.values())
l = []
for i in d:
    if d[i] == m:
        l.append(i)
l.sort()
for i in l:
    print(i)

Solution (Python):
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))

n = ii()
count = {}
cmax = 0
for i in range(n):
    s = input()
    c = count.get(s,0)+1
    cmax = max(c,cmax)
    count[s] = c
ans = sorted([kv[0] for kv in count.items() if kv[1] == cmax])
for item in ans:
    print(item)

Solution (Python):
N = int(input())
dic = {}
s = []
for _ in range(N):
   s.append(input())

for i in s:
    if i in dic.keys():
        dic[i] += 1
    else:
        dic[i] = 1
result = []
num = 0
for i in dic.keys():
    if dic[i] > num:
        result = []
        result.append(i)
        num = dic[i]
    elif dic[i] == num:
        result.append(i)
result.sort()
for i in result:
    print(i)

Solution (Python):
import collections
N = int(input())
l = [input() for i in range(N)]
L = collections.Counter(l)
a = L.most_common()
M = a[0][1]
A = [j[0] for j in a if j[1] == M]
[print(k) for k in sorted(A)]

Solution (Python):
N=int(input())
dic={}
for _ in range(N):
  S=input()
  if S in dic:
    dic[S]+=1
  else:
    dic[S]=1
ls=list(dic.items())
ls.sort()
ls=sorted(ls, key=lambda x:-x[1])
a=ls[0][1]
for i in range(len(ls)):
  if ls[i][1]==a:
    print(ls[i][0])

Solution (Python):
from collections import defaultdict

N = int(input())
S = [input() for _ in range(N)]
Sd = defaultdict(int)
for i in S:
    Sd[i] += 1
Sd = sorted(Sd.items(), key = lambda x: x[1], reverse=True)

maxv = Sd[0][1]
ans = []
for i, j in Sd:
    if maxv != j:
        break
    else:
        ans.append(i)

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

Solution (Python):
N=int(input())
S=[]
for i in range(N):
    S.append(input())
S.sort()
T=sorted(set(S))

cnt=0
i=0
cnt_array=[0]*(len(T))
while cnt<len(T) and i<N:
    if S[i]==T[cnt]:
        cnt_array[cnt]+=1
        i+=1
    else:
        cnt+=1

M=max(cnt_array)
for i in range(len(T)):
    if cnt_array[i]==M:
        print(T[i])

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


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




max_value = max(S.values())
ans = sorted([k for k, v in S.items() if v == max_value])


for a in ans:
    print(a)

Solution (Python):
n = int(input())
s = [""] * n
for i in range(n):
    s[i] = input()
s = sorted(s)
t = 1
tmax=1
for i in range(1, n):
    if s[i-1] == s[i]:
        t += 1
        tmax=max(tmax,t)
    else:
        t = 1
        tmax = max(tmax, t)
t = 1
if tmax == 1:
    for i in range(n):
        print(s[i])
    exit()
if tmax == n:
    print(s[0])
    exit()
for i in range(1,n):
    if s[i-1] == s[i]:
        t += 1
    else:
        t=1
    if t == tmax:
        print(s[i])

Solution (Python):
import pdb

N = int(input())
i = 0
list = [0] * N

while i < N:
  list[i] = input()
  i += 1

list.sort()
k = 1
count_list = [0]*N
count_list[0] = 1
ans_list = [0] * N
ans_list[0] = list[0]
l = 0



while k < N:
  if list[k] != list[k-1]:
    l +=1
    ans_list[l] = list[k]

  count_list[l] += 1
  k += 1

s = max(count_list)

for i in range(N):
  if count_list[i] == s:
    print(ans_list[i])

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

Solution (Python):

N = int(input())
S = [input() for _ in range(N)]
L = [0 for _ in range(N)]
L1 = ["" for _ in range(N)]
S.sort()
k = 0


for i in range(N):
    if i == 0:
        L[k] = 1 
        L1[k] = S[i]
    else:
        if S[i-1] == S[i]:
            L[k] = L[k] + 1
        else:
            L[k+1] = 1
            L1[k+1] = S[i]
            k += 1

m = max(L)
for i in range(N):
    if L[i] == m:
        print(L1[i])

Solution (Python):
from collections import defaultdict
n = int(input())
strings = defaultdict(int)
for i in range(n):
    strings[input()] += 1
max_value = max(value for value in strings.values())
for i in sorted(key for key, value in strings.items() if value==max_value):
    print(i)