#K56612. Remove Adjacent Duplicates

    ID: 30238 Type: Default 1000ms 256MiB

Remove Adjacent Duplicates

Remove Adjacent Duplicates

Given a string consisting of lowercase alphabets, your task is to remove all consecutive duplicate characters so that no two adjacent characters are identical. For example, if the input string is abbaca, after processing the string becomes abaca.

The process is straightforward: scan the string from left to right and build a new string by adding each character only if it is different from the immediately preceding character.

This problem tests your ability to perform simple string manipulation and ensures that edge cases, such as empty strings or strings with all identical characters, are handled correctly.

inputFormat

The input is read from standard input (stdin) and consists of a single line containing the string S made up of lowercase alphabets.

outputFormat

Output to standard output (stdout) the processed string after removing consecutive duplicate characters.## sample

abbaca
abaca