Problem:
Mode Value

Your task is to write a program which reads a sequence of integers and prints mode values of the sequence.
The mode value is the element which occurs most frequently.

Input

A sequence of integers ai (1 ≤ ai ≤ 100). The number of integers is less than or equals to 100.

Output

Print the mode values. If there are several mode values, print them in ascending order.

Sample Input

5
6
3
5
8
7
5
3
9
7
3
4

Output for the Sample Input

3
5

For example, 3 and 5 respectively occur three times, 7 occurs two times, and others occur only one. So, the mode values are 3 and 5.

Solution in Scala (judge verdict: Accepted)

object Main extends App {
  val src: List[Int] = io.Source.stdin.getLines.map(_.toInt).toList

  val maxVal: Int = src.max

  val countedList: List[Int] = (for (i <- 1 to maxVal) yield (src.count(_ == i))).toList

  val maxModes = countedList.max

  def countLiWithIndex(li: List[Int]): List[(Int, Int)] = li.zipWithIndex

  def pickModes(li: List[(Int, Int)]): List[Int] = {
    for { tup <- li
        if (tup._1 == maxModes)
    } yield {
      tup._2 + 1
    }
  }

  pickModes(countLiWithIndex(countedList)).foreach(println)
}