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++14 (GCC 5.4.1) (judge verdict: Wrong Answer)

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

struct NameCount {
  string name;
  long int count;
};

bool cmp(const NameCount &a, const NameCount &b)
{
    return a.count > b.count;
}

int main() {
  // 入力
  long int N;
  cin >> N;

  vector<string> S;
  for (long int i=0; i<N; i++) {
    string S_tmp;
    cin >> S_tmp;
    S.push_back(S_tmp);
  }
  
  sort(S.begin(), S.end());

  // cout << S[0] << " " << S[1] << " " << S[2] << " " << S[3] << " " << S[4] << " " << S[5] << " " << S[6] << endl;
  
  vector<NameCount> name_count;
  long int count_tmp = 1;
  for (long int i=0; i<N-1; i++) {
    if (S[i]==S[i+1]) {
      count_tmp++;
      if (i+1==N-1) {
        NameCount name_count_tmp = {S[i], count_tmp};
        name_count.push_back(name_count_tmp);
        count_tmp = 1;
      }
    } else {
      NameCount name_count_tmp = {S[i], count_tmp};
      name_count.push_back(name_count_tmp);
      count_tmp = 1;
    }
  }
  
  if (S[N-2]!=S[N-1]) {
    NameCount name_count_tmp = {S[N-1], 1};
    name_count.push_back(name_count_tmp);
  }

  sort(name_count.begin(), name_count.end(), cmp);

  // cout << name_count[0].name << " " << name_count[1].name << " " << name_count[2].name << " " << name_count[3].name << endl;
  // cout << name_count[0].name << " " << name_count[1].name << " " << name_count[2].name << " " << name_count[3].name << " " << name_count[4].name << endl;
  // cout << name_count[0].count << " " << name_count[1].count << " " << name_count[2].count << " " << name_count[3].count << " " << name_count[4].count << endl;
  
  if (name_count.size() > 1) {
    for (long int i=0; i<name_count.size()-1; i++) {
      if (name_count[i].count == name_count[i+1].count) {
        cout << name_count[i].name << endl;
        if (i+1 == name_count.size()-1) {
          cout << name_count[i+1].name << endl;
        }
      } else {
        cout << name_count[i].name << endl;
        break;
      }
    }
  } else {
    cout << name_count[0].name << endl;
  }

  return 0;
}