#C13724. Count File Extensions

    ID: 43294 Type: Default 1000ms 256MiB

Count File Extensions

Count File Extensions

You are given a list of filenames. Your task is to extract the file extension from each filename and count how many times each extension occurs. The extension is defined as the substring after the last period ('.') in the filename. If a filename does not contain a period, it should be ignored. Finally, output the counts for each extension in lexicographical order.

Note: If no valid extension is found, the program should output nothing.

Mathematically, if we denote the set of filenames as \(F\), then for each filename \(f \in F\), if \(f = s_1.s_2\) (with \(s_2 \neq \emptyset\)), count \(s_2\). Otherwise, ignore \(f\).

inputFormat

The first line of input contains a single integer \(N\) representing the number of filenames.

The following \(N\) lines each contain a filename.

outputFormat

For each distinct file extension found in the list, output a line containing the extension and its count separated by a space. The output must be sorted in lexicographical order of the extensions. If no file has a valid extension, output nothing.

## sample
3
file1.txt
file2.txt
file3.txt
txt 3