Run-length encoding - MarisaOJ: Marisa Online Judge

Run-length encoding

Time limit: 1000 ms
Memory limit: 256 MB
Using the Run-Length Encoding string compression technique, we replace consecutive repeated characters with a single character followed by the count of its repetitions. For example, `aabbbbccccc` would be compressed to `2a4b5c`. Write a program to compress a string using Run-Length Encoding and to decode a compressed string. ### Input - The first line contains a string to be compressed. - The second line contains a string to be decoded. ### Output - The first line should print the compressed result of the input string. - The second line should print the decoded result of the input string. ### Constraints - Ensure that the length of the string to be compressed and the length of the string after decoding do not exceed $10^5$. The strings consist only of lowercase letters. ### Sample test ``` aabbbbccccc 1a1b1c ``` Output: ``` 2a4b5c abc ```