#K95752. Counting Month Occurrences

    ID: 38933 Type: Default 1000ms 256MiB

Counting Month Occurrences

Counting Month Occurrences

You are given a list of dates in the format YYYY-MM-DD. Your task is to count the number of occurrences of each month. The month is represented as a two-digit string extracted from the date. For example, if the date is 2022-03-15, the month is 03.

The solution should read input from stdin and write the result to stdout in the form of a dictionary (or map) where the keys are the months (as two-digit strings) and the values are the counts of dates belonging to that month. All months that appear in the input must be present in the output in sorted order (by key).

Mathematically, if we let \( M(d) \) be the month part extracted from a date \( d \) (i.e. \( M(d)=d[5:7] \)) and let \( f(m) \) be the frequency of month \( m \) among all dates, then your program should output a dictionary defined as:

[ { ; m : f(m) ; | ; m \text{ is a two-digit month string from one or more input dates} } ]

inputFormat

The input is given via stdin as follows:

  1. The first line contains an integer n indicating the number of dates.
  2. The following n lines each contain a date string in the format YYYY-MM-DD.

outputFormat

Output to stdout a dictionary (or map) in which the keys are months (as two-digit strings) and the values are the counts of occurrences. The keys should be output in sorted order and formatted exactly as shown in the examples.

## sample
1
2022-03-15
{"03": 1}