#C2142. Run-Length Encoding

    ID: 45426 Type: Default 1000ms 256MiB

Run-Length Encoding

Run-Length Encoding

This problem requires you to implement a run-length encoding algorithm. In run-length encoding, consecutive occurrences of the same character are replaced by the count of repetitions followed by the character. For example, given the string aaabbbccddde, the encoded result is 3a3b2c3d1e. Your task is to read a single string from standard input and output its run-length encoded version.

Examples:

  • Input: aaabbbccddde → Output: 3a3b2c3d1e
  • Input: abcd → Output: 1a1b1c1d
  • Input: "" (empty string) → Output: "" (empty string)

Your solution should handle both uppercase and lowercase letters and treat them as distinct characters.

inputFormat

The input consists of a single line from standard input containing the string s to be encoded. The string may include letters, digits, or other characters and can be empty.

outputFormat

Output the run-length encoded string corresponding to the input string on standard output. Ensure no extra spaces or newlines are printed.

## sample
aaabbbccddde
3a3b2c3d1e