Question
Remove All Lights Challenge

In a digital world, you’re given a sequence of lights represented by a binary string T, where ‘0’ represents an off light and ‘1’ represents an on light. You have a special tool that allows you to select and remove any even-length segment of lights that are either all off (‘0’s) or all on (‘1’s). Your goal is to keep using this tool until all the lights are removed, if possible. Can you clear the entire sequence and turn off all the lights?

Input
The first line of the input contains a string S.

Constraints
1 ≤ Length(S) ≤ 105
S is a binary string. It consists only of 0's or 1's
Output
Print (without quotes) "YES", if you can get an empty string, else print "NO".
Example
Sample Input
1001
Sample Output
YES
Explanation
First we remove the substring "00" from the string. It becomes "11".
Now, we remove "11" and the string becomes empty.

Sample Input
10
Sample Output
NO

Online