#C12630. Counting Strings
Counting Strings
Counting Strings
You are given a list of strings. Your task is to count the number of occurrences of each unique string in the list. The output should list each unique string along with its count, with the strings sorted in lexicographical order.
For example, given the list of strings ['apple', 'banana', 'cherry'], the output should be:
apple: 1 banana: 1 cherry: 1
Note that strings are case-sensitive. In addition, empty strings are valid and should be counted accordingly. Use the following input/output format described below.
If needed, you can refer to the formula for counting: \( \text{count}(s) = \sum_{i=1}^{n} \mathbf{1}_{\{s_i = s\}} \) for each string \(s\) in the list.
inputFormat
The input is read from standard input. The first line contains an integer \(N\) representing the number of strings. The following \(N\) lines each contain a string. The strings may be empty.
outputFormat
Print the count of each unique string on a separate line in the format:
key: count
where the keys are printed in lexicographical order. If a string is empty, its line will start with an empty key followed by a colon and its count.
## sample3
apple
banana
cherry
apple: 1
banana: 1
cherry: 1