#C816. Character Frequency

    ID: 52111 Type: Default 1000ms 256MiB

Character Frequency

Character Frequency

Given a string s provided through standard input, determine the frequency of each character in the string. The output should be a JSON object (i.e. a dictionary) that maps each character to its corresponding occurrence count. The keys in the JSON object must be sorted in lexicographical order.

Examples:

  • For s = "hello", the output should be {"e": 1, "h": 1, "l": 2, "o": 1} (since 'e' comes before 'h' lexicographically).
  • For s = "apple", the output should be {"a": 1, "e": 1, "l": 1, "p": 2}.

You need to read the input from standard input (stdin) and write the output to standard output (stdout).

inputFormat

The input consists of a single line containing the string s. The string may contain any characters. You can assume that the input string is non-empty.

outputFormat

Output a JSON object (dictionary) in which the keys are the characters from the input string and the values are the corresponding counts. The keys must be sorted in lexicographical (increasing) order. The output should be printed to standard output (stdout).

## sample
a
{"a": 1}