#C3773. Remove Consecutive Characters

    ID: 47237 Type: Default 1000ms 256MiB

Remove Consecutive Characters

Remove Consecutive Characters

You are given a string (s) consisting of lowercase English letters. Your task is to remove the minimum number of characters from the string such that the resulting string does not contain any occurrence of three consecutive identical characters. In other words, whenever three or more identical characters appear consecutively, you must remove some characters so that at most two appear consecutively. This process should be applied individually on multiple test cases.

inputFormat

The input consists of an integer (T) on the first line, indicating the number of test cases. Each of the following (T) lines contains a non-empty string (s) made up of lowercase English letters.

outputFormat

For each test case, output the resulting string after removing characters so that no three identical characters appear consecutively. Each answer should be printed on its own line.## sample

3
aaabbbccc
aabbaabb
abcabcabc
aabbcc

aabbaabb abcabcabc

</p>