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: Wrong Answer)

#include <stdio.h>
#include <stdlib.h>

#define NUM 200001
#define HASH 200001

typedef struct List {
	struct List *next;
	int id;
} list;

int hash_string(char* s)
{
	long long x = 0;
	int i;
	for (i = 0; s[i] != 0; i++) {
		x += s[i] - 'a';
		x = x << 5;
	}
	return x % HASH;
}

int lex_smaller(char* s1, char* s2)
{
	int i;
	for (i = 0; s1[i] != 0 && s2[i] != 0; i++) {
		if (s1[i] < s2[i]) return 1;
		else if (s1[i] > s2[i]) return -1;
	}
	if (s1[i] == s2[i]) return 0;
	else if (s1[i] == 0) return 1;
	else return -1;
}

void push(char* s, char** heap, int* n)
{
	int i = *n;
	char *tmp;
	heap[(*n)++] = s;
	while (1) {
		if (i == 0) break;
		else if (lex_smaller(heap[i], heap[(i - 1) / 2]) == 1) {
			tmp = heap[(i - 1) / 2];
			heap[(i - 1) / 2] = heap[i];
			heap[i] = tmp;
			i = (i - 1) / 2;
		} else break;
	}
}

char* pop(char** heap, int* n)
{
	int i = 0, j;
	char *tmp, *output = heap[0];
	heap[0] = heap[--(*n)];
	while (1) {
		if (i * 2 + 1 >= *n) break;
		else if (i * 2 + 2 >= *n) j = i * 2 + 1;
		else if (lex_smaller(heap[i * 2 + 1], heap[i * 2 + 2]) == 1) j = i * 2 + 1;
		else j = i * 2 + 2;
		if (lex_smaller(heap[j], heap[i]) == 1) {
			tmp = heap[j];
			heap[j] = heap[i];
			heap[i] = tmp;
			i = j;
		} else break;
	}
	return output;
}

int main()
{
	int i, N;
	char S[NUM][11];
	scanf("%d", &N);
	for (i = 1; i <= N; i++) scanf("%s", S[i]);
	
	list data[NUM], *hash[HASH] = {}, *hp;
	int h, j, k, count[NUM] = {}, type[NUM] = {};
	for (i = 1, k = 0; i <= N; i++) {
		h = hash_string(S[i]);
		for (hp = hash[h]; hp != NULL; hp = hp->next) {
			if (lex_smaller(S[i], S[type[hp->id]]) == 0) {
				count[hp->id]++;
				break;
			}
		}
		if (hp == NULL) {
			type[k] = i;
			data[i].id = k++;
			data[i].next = hash[h];
			hash[h] = &(data[i]);
		}
	}

	int p = 0, max = -1, argmax[NUM] = {};
	for (j = 0; j < k; j++) {
		if (count[j] > max) {
			max = count[j];
			argmax[0] = j;
			for (; p > 0; argmax[--p] = 0);
		} else if (count[j] == max) argmax[++p] = j;
	}
	
	int n = 0;
	char **heap = (char**)malloc(sizeof(char*) * (++p));
	for (i = 0; i < p; i++) push(S[type[argmax[i]]], heap, &n);
	while (n > 0) printf("%s\n", pop(heap, &n));

	fflush(stdout);
	return 0;
}