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 in C++ (GCC 9.2.1) (judge verdict: Accepted)


#include <bits/stdc++.h>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<string.h>
using namespace std;
#define pb push_back
#define all(v) v. begin(),v. end()
#define  rep(i,n,v) for(i=n;i<v;i++)
#define per(i,n,v) for(i=n;i>v;i--)
#define ff first 
#define ss second 
#define pp pair<ll,ll>
#define ll  long long
#define endl '\n'
void solve()
{
  ll n, a,m=1,b=1, c,k=0, i, j,l=1e9+7;
  string s, r, y;
  cin>>n;
  vector<string>v;
  map<string,int>hash;
  rep(i,0,n) {cin>>s;hash[s]++;}
  for(auto x:hash)
  {
    if(x.ss>k)k=x.ss;
  }
  for(auto it=hash.begin();it!=hash.end();it++)
  {
    if(it->ss==k) cout<<it->ff<<endl;
  }
  /*rep(i,0,v.size()) hash[v[i]]++;
  int max_count = 0, res = -1; 

    for (auto i : hash) { 

        if (max_count < i.second) { 

            //res = i.first; 

            max_count = i.second; 

        } 

    }
    vector<string>vec;
    for (auto i : hash) { 

        if (max_count == i.second) { */
/*r=i.first;
sort(r.begin(),r. end());
            cout<<r<<endl;*/
            /*  vec. pb(i.first);

            max_count = i.second; 

        } }
        rep(i,0,vec.size()) cout<<vec[i]<<endl;*/
    
  /*sort(all(v));
  rep(i,0,v.size())
  {
    if(v[i]==v[i+1] && i+1<v.size()) {k++;continue;}
    if(k>m) {m=k;k=0;}
  }
  k=0;
  rep(i,0,v.size())
  {
    if(v[i]==v[i+1] && i+1<v.size()) {k++;continue;}
    if(k==m) {sort(v[i].begin(),v[i].end());cout<<v[i]<<endl;}
    k=0;
  }*/
  
  /*sort(r.begin(),r. end());
  cout<<r;*/
}
int main()
{
 ios_base::sync_with_stdio(false);
  cin. tie(0);cout. tie(0);
    ll t=1;
   //cin>>t;
    while(t--)
    {
      solve();
    }
    return 0;
}