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

using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static string InputPattern = "InputX";

    static List<string> GetInputList()
    {
        var WillReturn = new List<string>();

        if (InputPattern == "Input1") {
            WillReturn.Add("7");
            WillReturn.Add("beat");
            WillReturn.Add("vet");
            WillReturn.Add("beet");
            WillReturn.Add("bed");
            WillReturn.Add("vet");
            WillReturn.Add("bet");
            WillReturn.Add("beet");
            //beet
            //vet
        }
        else if (InputPattern == "Input2") {
            WillReturn.Add("8");
            WillReturn.Add("buffalo");
            WillReturn.Add("buffalo");
            WillReturn.Add("buffalo");
            WillReturn.Add("buffalo");
            WillReturn.Add("buffalo");
            WillReturn.Add("buffalo");
            WillReturn.Add("buffalo");
            WillReturn.Add("buffalo");
            //buffalo
        }
        else if (InputPattern == "Input3") {
            WillReturn.Add("7");
            WillReturn.Add("bass");
            WillReturn.Add("bass");
            WillReturn.Add("kick");
            WillReturn.Add("kick");
            WillReturn.Add("bass");
            WillReturn.Add("kick");
            WillReturn.Add("kick");
            //kick
        }
        else if (InputPattern == "Input4") {
            WillReturn.Add("4");
            WillReturn.Add("ushi");
            WillReturn.Add("tapu");
            WillReturn.Add("nichia");
            WillReturn.Add("kun");
            //kun
            //nichia
            //tapu
            //ushi
        }
        else {
            string wkStr;
            while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr);
        }
        return WillReturn;
    }

    static void Main()
    {
        List<string> InputList = GetInputList();

        string[] SArr = InputList.Skip(1).ToArray();

        var CntDict = new Dictionary<string, int>();
        foreach (string EachStr in SArr) {
            if (CntDict.ContainsKey(EachStr)) {
                CntDict[EachStr]++;
            }
            else {
                CntDict[EachStr] = 1;
            }
        }

        int MaxCnt = CntDict.Values.Max();
        var wkList = new List<string>();
        foreach (var EachPair in CntDict) {
            if (EachPair.Value == MaxCnt) {
                wkList.Add(EachPair.Key);
            }
        }
        wkList.Sort();
        wkList.ForEach(pX => Console.WriteLine(pX));

        //var tmp1 = SArr.GroupBy(pX => pX).Select(pX => new { pX.Key, Cnt = pX.Count() });
        //var tmp2 = tmp1.OrderByDescending(pX => pX.Cnt).ThenBy(pX => pX.Key);
        //int MaxCnt = int.MinValue;
        //foreach (var EachPair in tmp2) {
        //    if (MaxCnt > EachPair.Cnt) break;
        //    MaxCnt = EachPair.Cnt;
        //    Console.WriteLine(EachPair.Key);
        //}
    }
}