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 5.4.1) (judge verdict: Time Limit Exceeded)

#include <stdio.h>
#include <string.h>

char s[200001][11];//入力受け取り
char results[200001][11];//結果表示用

void Swap(char *a, char *b){
  char tmp[11];
   if(strcmp(a, b) > 0){
      strcpy(tmp, a);
      strcpy(a, b);
      strcpy(b, tmp);
   }
}

void QSort(int left, int right)
{
    int i, j;
    char pivot[11];
    
    i = left;                      /* ソートする配列の一番小さい要素の添字 */
    j = right;                     /* ソートする配列の一番大きい要素の添字 */
    
    strcpy(pivot, results[(left + right) / 2]); /* 基準値を配列の中央付近にとる */
    
    while (1) {                    /* 無限ループ */
        
        while (strcmp(results[i], pivot) < 0)       /* pivot より大きい値が */
            i++;                   /* 出るまで i を増加させる */
        
        while (strcmp(pivot, results[j]) < 0)       /* pivot より小さい値が */
            j--;                   /*  出るまで j を減少させる */
        if (i >= j)                /* i >= j なら */
            break;                 /* 無限ループから抜ける */
        
        Swap(results[i], results[j]);             /* x[i] と x[j]を交換 */
        i++;                       /* 次のデータ */
        j--;
    }
    //ShowData(x, 10);               /* 途中経過を表示 */
    
    if (left < i - 1)              /* 基準値の左に 2 以上要素があれば */
        QSort(left, i - 1);     /* 左の配列を Q ソートする */
    if (j + 1 <  right)            /* 基準値の右に 2 以上要素があれば */
        QSort(j + 1, right);    /* 右の配列を Q ソートする */
}

int main(void){
  int n, i, j, match=0, count=0, result=0, max=0;
  int c[200001] = {0};//出現回数
  char tmp[11];
  
  scanf("%d", &n);
  for(i=1;i<=n;i++){
    scanf("%10s", tmp);
    
    match=0;
    for(j=0;j<count;j++){
      if(strcmp(tmp, s[j]) == 0){
        c[j]++;
        if(c[j] > max) max = c[j];
        match=1;
        break;
      }
    }
    
    if(match == 0){
      strcpy(s[count],tmp);
      c[count] = 1;
      count++;
    }
    
  }
  
  for(i=0;i<count;i++){
    if(c[i] >= max){
      strcpy(results[result], s[i]);
      result++;
    }else continue;
  }
  
  QSort(0, result-1);
  
  for(i=0;i<result;i++) printf("%s\n", results[i]);
  
  return 0;
}