Олимпиадный тренинг

Задача 33480. Most common amount


You are given a set of N positive integers. For each number, the sum of the last two digits in its decimal notation is calculated (for single-digit numbers, the penultimate digit is considered equal to zero). It is necessary to determine what amount is obtained most often. If there are several such sums,
you need to display the largest of them.
Write a time and memory efficient program to solve this problem.
A program is considered to be time efficient if increasing the number of initial numbers N by k times increases the running time of the program by no more than k times.
A program is considered memory efficient if the memory required to store all program variables does not exceed 1 KB and does increase with N.
Maximum score for a correct (without syntax errors and giving the correct answer for any valid input data) program that is efficient in time and memory, – 4 points.
Maximum score for a correct program that is efficient only in time or only in memory, – 3 points.
Maximum mark for a correct program that does not meet performance requirements, – 2 points.
You may take one or two problem solving programs. If you take two programs, each will be graded independently of the other, the higher of the two grades will be the final score.
Before the text of the program, briefly describe the solution algorithm. Specify the programming language used and its version.

Description of input and output data
The first line of the input specifies the number of numbers N (1 ≤ N ≤ 1000).
The next N lines contain one natural number not exceeding 10 000.
Sample input:
5
15
417
123
6
4841
Sample output for the example input above:
6
The sums of the last two digits for numbers from this set are 6, 8, 5, 6, 5.
More often than others (twice each) there are 6 and 5, the larger of these sums is displayed in the answer.