#C13405. Consecutive Character Frequency

    ID: 42940 Type: Default 1000ms 256MiB

Consecutive Character Frequency

Consecutive Character Frequency

Given a string, your task is to generate a new string by encoding consecutive characters with their corresponding frequency counts. Specifically, for each group of consecutive identical characters in the input string, output the character immediately followed by the number of times it appears consecutively. For example, if the input is aabccc, then the output should be a2b1c3. If the input string is empty, output an empty string.

The problem can be formally described as follows: Let ( s ) be a string. You need to form a new string by grouping all consecutive identical characters and appending the character with its count. Use the standard input and standard output for processing.

inputFormat

The input consists of a single line containing the string ( s ). The string may be empty or contain only characters.

outputFormat

Output a single line containing the encoded string, where each group of consecutive identical characters is replaced by the character followed by the number of times it appears consecutively.## sample

aabccc
a2b1c3