#K44142. Count Messages by Location

    ID: 27466 Type: Default 1000ms 256MiB

Count Messages by Location

Count Messages by Location

You are given a series of messages. Each message may contain a location tag of the format [LOC:XXXX], where XXXX is an alphanumeric string. Note that the location tag is case insensitive; for example, [LOC:hn37] must be treated as [LOC:HN37].

Your task is to count how many messages belong to each location tag and output the result in the form of a dictionary. The dictionary keys should be the location tags in uppercase, and the corresponding values should be the count of messages that contain that tag.

The pattern for a valid location tag can be represented in LaTeX as: \(\[LOC:([A-Z0-9]+)\]\).

inputFormat

The input is given via standard input (stdin). The first line contains a single integer n (0 ≤ n ≤ 105) representing the number of messages. Each of the following n lines contains a message (a non-empty string) which may include a location tag.

outputFormat

Output the dictionary (in JSON style) containing the counts of messages for each location tag. The keys (location tags) must be in uppercase. For example, if the dictionary is empty, output {}, otherwise output something like {"HN37": 2, "HQ29": 1, "FR56": 1}.

## sample
4
Message transmission initiated. [LOC:HN37]
Transmission successful. [LOC:HQ29]
Awaiting response from central server. [LOC:HN37]
Data packet lost in transit. [LOC:FR56]
{"HN37": 2, "HQ29": 1, "FR56": 1}