#C4065. Run-Length String Compression

    ID: 47562 Type: Default 1000ms 256MiB

Run-Length String Compression

Run-Length String Compression

This problem focuses on compressing a string using a simple run-length encoding mechanism. Given an input string s, you need to create a compressed version where each contiguous group of the same character is replaced by the character followed by the count if the count is greater than 1. If the character appears only once, it remains unchanged.

For example:

  • Input: AABBBCCCCD → Output: A2B3C4D
  • Input: AAABBC → Output: A3B2C
  • Input: ABCDE → Output: ABCDE

Your solution should read the input from standard input and print the result to standard output.

inputFormat

The input consists of a single line containing the string s (1 ≤ |s| ≤ 105) composed of uppercase English letters.

You should read the input from standard input.

outputFormat

Output the compressed string according to the run-length encoding rule described above. Write the result to standard output.

## sample
AABBBCCCCD
A2B3C4D