import java.util.*; import java.util.regex.*; import java.io.*; /** * Solution to Polling * * @author vanb */ public class polling_vanb { public Scanner sc; public PrintStream ps; public void doit() throws Exception { sc = new Scanner( System.in ); ps = System.out; // A HashMap to hold the count of votes for each candidate HashMap counts = new HashMap(); // A list of the best candidates LinkedList best = new LinkedList(); int n = sc.nextInt(); int max = 0; for( int i=0; imax ) { // If this candidate is better than any we've seen before, // clear out the best list. max = count; best.clear(); best.add( candidate ); } } // Sort the winners String winners[] = (String[])best.toArray(new String[best.size()]); Arrays.sort( winners ); // And, print them for( String winner : winners ) { ps.println( winner ); } } public static void main( String[] args ) throws Exception { new polling_vanb().doit(); } }