#K65437. Reduce Consecutive Characters

    ID: 32197 Type: Default 1000ms 256MiB

Reduce Consecutive Characters

Reduce Consecutive Characters

Given a string \(s\), construct a new string where each sequence of consecutive duplicate characters is replaced by a single instance of that character. For example, if \(s = \texttt{aaabbbcccaaa}\), the output should be \(\texttt{abca}\). This problem tests basic string manipulation and ensures careful handling of character sequences.

inputFormat

Input is read from standard input (stdin). A single line contains the string (s) (its length is between 0 and 1000).

outputFormat

Output the processed string to standard output (stdout), where every group of consecutive identical characters in (s) is compressed into one occurrence.## sample

aaabbbcccaaa
abca