A computer programmer and mathematician, Kumar Harikrishnan, has developed a new data compression system—ACM (Advanced Compression Method)—which will incorporate all of his brilliant ideas.
The first component of ACM will be a modification of the well-known RLE algorithm, called Improved RLE. Since Kumar has much more difficult tasks to accomplish (such as writing Improved Hamming and Improved Lempel-Ziv), he asks you to implement this simple, yet important, part of the system.
The algorithm should replace repeating substrings of the source string with a single instance of the substring concatenated with the number of repetitions. If a substring is not repeated, it is concatenated with the number .
Your program must find the shortest possible compression of the given string.
A single line of the input file contains the string to be compressed. It may contain spaces but does not contain digits, as Kumar has invented a complex digit-escaping system to prevent uncompressing ambiguity.
The output file must contain the minimal length compression of the source string. There should be no extra whitespace characters before or after the string.
Example 1
The length of the source string is from to characters.