#C12260. Top 10 Most Frequent Words

    ID: 41668 Type: Default 1000ms 256MiB

Top 10 Most Frequent Words

Top 10 Most Frequent Words

In this problem, you are given a text input from standard input. Your task is to remove all punctuation, convert the text to lowercase, and then count the frequency of each word. Finally, output the top 10 most frequent words along with their frequencies. If there are fewer than 10 distinct words, output all of them in descending order of frequency. In case of ties (i.e. two words with the same frequency), the word that appears first in the text should come first in the output. For any formulas, use LaTeX format, e.g. f(x)=x2f(x)=x^2.

inputFormat

The input consists of multiple lines containing the text to process. Read the entire input from standard input until EOF.

outputFormat

Output the top words, one per line. Each line should contain a word and its frequency, separated by a single space. Only output as many words as appear in the text (up to 10). If no words are present, output nothing.## sample

Hello world! This is a test sample file. Hello again, world.
hello 2

world 2 this 1 is 1 a 1 test 1 sample 1 file 1 again 1

</p>