MCL - Most Common Letter

no tags 

Many word processors have a word count feature, which can tell you not only how many words are in a file, but also how many characters, lines, paragraphs, and pages. But who cares about that? All you really need to know is which of the 26 letters of the English alphabet (A - Z) you've used the most in your text. Write a program which implements this feature.

Input

The input will be several lines, each representing a different test case. No test case will exceed 1024 characters in length, and each will contain at least one alphabetic character.

Output

For each test case, output one line, containing the most common letter and the number of times it appears in the test case, separated by a space. Break ties in favor of the letter that occurs first alphabetically. Ignore non-alphabetic characters. Counting should be case-insensitive, and output should be uppercase.

Example

Input:
Hello World!
Never gonna give you up, never gonna let you down...
You just lost the game.
I'm going to sleep *yawn* ZZZzzz

Output:
L 3
N 7
T 3
Z 6

hide comments
thewarrior: 2010-12-16 05:14:49

you mean EOF like end of line '\0' or when someone input EOF?

codebugger: 2009-10-21 19:02:50

or you could just take
while(getline(cin,str))
{
//code goes here
}

Luka Hrabar: 2009-10-18 10:17:31

Input ends with EOF

unique: 2009-10-18 08:37:18

how do we know that its the end of input?

Thanks Luka , got ac after using EOF . Hats Off!!!

Last edit: 2009-10-18 16:54:55

Added by:Miorel Palii
Date:2009-10-04
Time limit:1.970s
Source limit:4096B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: ERL NODEJS PERL6 VB.NET
Resource:University of Florida Local Contest - April 13, 2009