No.1469 programing
Problem Statement
harurun is bad at English and writes programming as programing.
We call this way of writing, in which $2$ consecutive identical characters are written as $1$ character, $harurun$ notation.
You are given $1$ string $S$. Output it in $harurun$ notation.
However, a string in which $3$ or more identical characters are consecutive is never given.
The formal problem statement is as follows.
You are given a string $S$.
Output the string $S$ after performing the following operation as many times as possible.
When $2$ adjacent characters are the same, delete one of them.
However, a string in which $3$ or more identical characters are consecutive, such as abbb, is not given.
(AC has been confirmed with Python3, PyPy3, C, C++17(1z), Java15, Javascript, and Rust, but slow languages such as Bash may not be able to get AC.)
Input
$S$
The string $S$ is given on line $1$.
Constraints
$S_i (1≤i≤|S|)$ is a lowercase English letter.
$1≤|S|≤5\times10^6$
When $S_i$ and $S_{i+1}$ are the same character, $S_{i+1}$ and $S_{i+2}$ are different characters. $(1≤i<|S|-1)$
($S_{i}$ denotes the $i$-th character of $S$, and $|S|$ denotes the length of $S$.)
Output
Output the answer on one line.
Print a newline at the end.
Sample
Sample 1
Input
programming
Output
programing
You only need to delete 1 of the consecutive m's.
Sample 2
Input
aabbccb
Output
abcb
Strings that are not real English words may also be given.
Sample 3
Input
abcdefghijklmnopqrstuvwxyz
Output
abcdefghijklmnopqrstuvwxyz
There may be nothing to delete.
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。
harurun
hamamu
nok0