#119Medium
Word frequencies
Time: 1 s · Memory: 256 MB
- Maps and sets
Statement
You are given a text of words made of lowercase Latin letters and separated by single spaces. Find how many times each distinct word occurs. Print the words in alphabetical order.
Input format
A single line with the text — up to characters; words are separated by single spaces, with no spaces at the start or end.
Output format
A separate line for each distinct word: the word and its count.
Examples
Input
olma nok olma uzum nok olma
Output
nok 2 olma 3 uzum 1
Input
b a c a b a
Output
a 3 b 2 c 1
Note
In the dictionary the key is the word and the value is its counter. At the end sort the keys and print them. Alphabetical order is plain string comparison: a < aa < aaa < b. In the first example: nok 2, olma 3, uzum 1.
