atcoder#ABC267B. [ABC267B] Split?

[ABC267B] Split?

Score : 200200 points

Problem Statement

Bowling pins are numbered 11 through 1010. The following figure is a top view of the arrangement of the pins:

0

Let us call each part between two dotted lines in the figure a column. For example, Pins 11 and 55 belong to the same column, and so do Pin 33 and 99.

When some of the pins are knocked down, a special situation called split may occur. A placement of the pins is a split if both of the following conditions are satisfied:

  • Pin 11 is knocked down.
  • There are two different columns that satisfy both of the following conditions:- Each of the columns has one or more standing pins.
    • There exists a column between these columns such that all pins in the column are knocked down.
  • Each of the columns has one or more standing pins.
  • There exists a column between these columns such that all pins in the column are knocked down.

See also Sample Inputs and Outputs for examples.

Now, you are given a placement of the pins as a string SS of length 1010. For i=1,,10i = 1, \dots, 10, the ii-th character of SS is 0 if Pin ii is knocked down, and is 1 if it is standing. Determine if the placement of the pins represented by SS is a split.

Constraints

  • SS is a string of length 1010 consisting of 0 and 1.

Input

Input is given from Standard Input in the following format:

SS

Output

If the placement of the pins represented by SS is a split, print Yes; otherwise, print No.

0101110101
Yes

In the figure below, the knocked-down pins are painted gray, and the standing pins are painted white:

ex0

Between the column containing a standing pin 55 and the column containing a standing pin 66 is a column containing Pins 33 and 99. Since Pins 33 and 99 are both knocked down, the placement is a split.

0100101001
Yes

ex1

0000100110
No

ex2

This placement is not a split.

1101110101
No

ex3

This is not a split because Pin 11 is not knocked down.