Polycarp takes part in a quadcopter competition. According to the rules a flying robot should:  start the race from some point of a field,  go around the flag,  close cycle returning back to the starting point. Polycarp knows the coordinates of the starting point (x1, y1) and the coordinates of the point where the flag is situated (x2, y2). Polycarp’s quadcopter can fly only parallel to the sides of the field each tick changing exactly one coordinate by 1. It means that in one tick the quadcopter can fly from the point (x, y) to any of four points: (x - 1, y), (x + 1, y), (x, y - 1) or (x, y + 1).Thus the quadcopter path is a closed cycle starting and finishing in (x1, y1) and containing the point (x2, y2) strictly inside.    The picture corresponds to the first example: the starting (and finishing) point is in (1, 5) and the flag is in (5, 2). What is the minimal length of the quadcopter path?

The first line contains two integer numbers x1 and y1 ( - 100 ≤ x1, y1 ≤ 100) — coordinates of the quadcopter starting (and finishing) point. The second line contains two integer numbers x2 and y2 ( - 100 ≤ x2, y2 ≤ 100) — coordinates of the flag. It is guaranteed that the quadcopter starting point and the flag do not coincide.

Print the length of minimal path of the quadcopter to surround the flag and return back.

x1,y1=map(int,input().split())
x2,y2=map(int,input().split())
if x1==x2:
    print(abs(y1-y2)*2+6)
elif y1==y2:
    print(abs(x1-x2)*2+6)
else:
    print((abs(x1-x2)+abs(y1-y2))*2+4)

import math
import re

def ria():
    return [int(i) for i in input().split()]

def ri():
    return int(input())

def rfa():
    return [float(i) for i in input().split()]

eps = 1e-9

def is_equal(a, b):
    return abs(a - b) <= eps

def distance(p0, p1):
    return math.sqrt((p0[0] - p1[0]) ** 2 + (p0[1] - p1[1]) ** 2)

xq, yq = ria()
xp, yp = ria()
ar = [(xp + 1, yp+1), (xp - 1, yp-1), (xp-1, yp + 1), (xp+1, yp - 1)]

if xp == xq:
    print(2 * 2 + (abs(yp - yq) + 1) * 2)
    exit(0)
if yp == yq:
    print(2 * 2 + (abs(xp - xq) + 1) * 2)
    exit(0)
mni = 1e+9

for i in ar:
    x1, y1 = i
    mxx, mxy, mnx, mny = max(x1, xq), max(y1, yq), min(x1, xq), min(y1, yq)
    #print(mxx,mxy,mnx,mny)
    if mxx > xp and mxy > yp and mnx < xp and mny < yp:
        mni = min(mni, (mxx - mnx) * 2 + (mxy - mny) * 2)
print(mni)

ri = lambda: map(int, raw_input().split())
a, b = ri()
c, d = ri()
dx = abs(a - c)
dy = abs(b - d)

ans = (dx + dy) * 2 + 4
if dx == 0 or dy == 0:
    ans += 2
print ans

x1, y1 = map(int, input().split())
x2, y2 = map(int, input().split())

print((abs(x1 - x2) + abs(y1 - y2) + 2 + int(x1 == x2) + int(y1 == y2)) * 2)

x1,y1=map(int,input().split())
x2,y2=map(int,input().split())
dx=max(2,abs(x1-x2)+1)
dy=max(2,abs(y1-y2)+1)
print(2*dx+2*dy)

def main():
	x1,y1 = map(int,input().split())
	x2,y2 = map(int,input().split())
	res = (abs(x2-x1) + abs(y2 - y1) +2)*2
	if x1==x2:
		res +=2
	if y1 == y2:
		res +=2
	print( res)

main()

s = [int(i) for i in raw_input().split()]
f = [int(i) for i in raw_input().split()]
x1 = s[0]
y1 = s[1]
x2 = f[0]
y2 = f[1]

if(x1==x2):
    x = 2
    y = abs(y1-y2)+1
    mini = (x+y)*2
    print mini

elif(y1==y2):
    x = abs(x1-x2)+1
    y = 2
    mini = (x+y)*2
    print mini

else:
    x = abs(x1-x2)+1
    y = abs(y1-y2)+1
    mini = (x+y)*2
    print mini

i,j = input("").split()
i = int(i)
j = int(j)

o,p = input("").split()
o = int(o)
p = int(p)

a = i - o
b = j - p

if a < 0:
    a = 0-a

if a == 0:
    a = 1

if b == 0:
    b = 1

if b < 0:
    b = 0-b

x =(a+b+2)*2

print(x)

f = lambda: map(int, input().split())
print(2 * sum(max(1, abs(a - b)) + 1 for a, b in zip(f(), f())))

x1, y1 = map(lambda x: int(x), input().split())
x2, y2 = map(lambda x: int(x), input().split())

pathLen = abs(x2 - x1) + abs(y2 - y1)
if x2 == x1 and y2 == y1:
    print(10)
elif x2 == x1 or y2 == y1:
    print(2 * pathLen + 6)
else:
    print(2 * pathLen + 4)

line1 = input()
line2 = input()
dc = [int(s) for s in line1.split(' ')]
fc = [int(s) for s in line2.split(' ')]
d = [abs(a - b) for a, b in zip(dc, fc)]
transit_x = max(2, d[0]+1)*2
transit_y = max(2, d[1]+1)*2
t = transit_x + transit_y
print(t)

import sys

def main():
    a, b = map(int, sys.stdin.readline().split())
    c, d = map(int, sys.stdin.readline().split())
    k = abs(a - c) + 1
    if k == 1:
        k += 1
    r = abs(b - d) + 1
    if r == 1:
        r += 1
    print(2 * (k + r))

main()

def dis(x1,y1,x2,y2) :
    return abs(x1-x2)+abs(y1-y2)
x1,y1=map(int,raw_input().split(' '))
x2,y2=map(int,raw_input().split(' '))
ans=0
for a in range(-1,2,2) :
    for b in range(-1,2,2) :
        ans=max(ans,dis(x1,y1,x2+a,y2+b))

if x1==x2 or y1==y2 :
    ans+=1
print ans*2

'''input
0 1
0 0
'''
from collections import defaultdict as dd
from collections import Counter as ccd
from itertools import  permutations as pp
from itertools import combinations as cc
from random import randint as rd
from bisect import bisect_left as bl
from bisect import bisect_right as br
import heapq as hq
import math
'''
Author : dhanyaabhirami
Hardwork beats talent if talent doesn't work hard
'''
'''
Stuck?
See github resources
Derive Formula
Kmcode blog
CP Algorithms Emaxx
'''
mod=pow(10,9) +7
def inp(flag=0):
    if flag==0:
        return list(map(int,input().strip().split(' ')))
    else:
        return int(input())

# Code credits
# assert(debug()==true)
# for _ in range(int(input())):

# t=inp(1)
# while t:
#     t-=1
x1,y1 = inp()
x2,y2 = inp()
xdist = 2*(abs(x1-x2)+1)
ydist = 2*(abs(y1-y2)+1)
if x1==x2:
    xdist += 2
if y1==y2:
    ydist +=2
ans = xdist+ydist
print(ans)

start = input().split()
x1 = int(start[0])
y1 = int(start[1])
flag = input().split()
x2 = int(flag[0])
y2 = int(flag[1])

print( 2*max(1, abs(x1-x2))+2 + 2*max(abs(y1-y2), 1)+2 )

a, b = map(int, raw_input().split())
c, d = map(int, raw_input().split())

print max(1, abs(a - c)) * 2 + max(1, abs(b - d)) * 2 + 4

I=lambda:map(int,input().split())
a,b=I()
c,d=I()
print((max(1,abs(a-c))+max(1,abs(b-d))<<1)+4)

from sys import exit

xs, ys = map(int, input().split())
xf, yf = map(int, input().split())

if xs == xf:
    print((abs(yf - ys) + 1) * 2 + 4)
    exit(0)
elif ys == yf:
    print((abs(xf - xs) + 1) * 2 + 4)
    exit(0)

xs, xf = sorted([xs, xf])
ys, yf = sorted([ys, yf])

xf += 1
yf += 1

print(2 * (xf - xs) + 2 * (yf - ys))

helicopter = map(int,raw_input().split())
flag = map(int,raw_input().split())

#8 points to consider
x = flag[0]
y = flag[1]
points = [[x-1,y+1],[x,y+1],[x+1,y+1],[x+1,y],[x+1,y-1],[x,y-1],[x-1,y-1],[x-1,y]]

def dist(x,y):
    return abs(y[1]-x[1]) + abs(y[0]-x[0])

min = 1000
for i in points:
    if dist(i,helicopter)<min:
        min = dist(helicopter,i)
print 2*min+8

x1,y1=map(int, input().split())
x2,y2=map(int, input().split())
travelx=(abs(x1-x2))
travely=(abs(y1-y2))
if(travelx==0):
  travelx+=2
else:
  travelx+=1
if(travely==0):
  travely+=2
else:
  travely+=1
travelx*=2
travely*=2
print(travelx+travely)

line = input().split(" ")
x1 = int(line[0])
y1 = int(line[1])

line = input().split(" ")
x2 = int(line[0])
y2 = int(line[1])

result = 2 * abs(x2 - x1) + 2 * abs(y2 - y1) + 4

if x2 == x1 and y2 == y1:
    result = 0
elif x2 == x1 or y2 == y1:
    result += 2

print(result)

Start = input()
Flag = input()
s_lst = Start.split()
f_lst = Flag.split()
a = [int(d) for d in s_lst]
b = [int(d) for d in f_lst]
x1 = a[0]
y1 = a[1]
x2 = b[0]
y2 = b[1]
if x1 == x2:
    print(abs(y1 - y2) * 2 + 6)
elif y1 == y2:
    print(abs(x1 - x2) * 2 + 6)
else:
    print(abs(x1 - x2) * 2 + abs(y1 - y2) * 2 + 4)

def f(l1,l2):
    g  = lambda d: 2 if d==0 else 1+(d if d>0 else -d)
    d2 = g(l1[0]-l2[0])+g(l1[1]-l2[1])
    return d2<<1

l1 = list(map(int,input().split()))
l2 = list(map(int,input().split()))
print(f(l1,l2))

a, b = map(int, raw_input().split())
c, d = map(int, raw_input().split())
e = (abs(a - c) + abs(b - d) + 2) * 2
if a == c or b == d:
	e += 2
print e

import sys
import itertools

def main():
    x1, y1 = map(int, raw_input().split())
    x2, y2 = map(int, raw_input().split())
    res = (abs(x1 - x2) + abs(y1 - y2)) * 2 + 4
    if x1 == x2 or y1 == y2:
	res += 2

    print res

if __name__ == '__main__':
    main()

x1, y1 = map(int, input().split())
x2, y2 = map(int, input().split())
print(2 * max(abs(x2 - x1), 1) + 2 * max(abs(y2 - y1), 1) + 4)

z=lambda:map(int,input().split())
d=lambda a,b:max(abs(a-b),1)*2+2
q,w=z()
e,r=z()
print(d(q,e)+d(w,r))

ar = map(int, raw_input().split())
a = map(int, raw_input().split())
x = 0
if ar[0] == a[0] or a[1] == ar[1]:
	x = 2
print abs(ar[0]-a[0])*2 + abs(ar[1]-a[1])*2 +4+x

from sys import stdin
x1,y1 = map(int,stdin.readline().split())
x2,y2 = map(int,stdin.readline().split())
ans = 2*(abs(x1-x2) + abs(y1-y2))
if x1==x2 and y1==y2:
 ans = 10
elif x1==x2 or y1==y2:
 ans = ans+6
else:
 ans+=4
print ans

x1,y1=map(int,input().split())
x2,y2=map(int,input().split())
x,y=x2,y2
if abs(x1-x2)>=1:
	if x1>x2:
		x=x2+1
	else:
		x=x2-1
if abs(y1-y2)>=1:
	if y1>y2:
		y=y2+1
	else:
		y=y2-1
if x==x2 and y==y2:
	print(8)
else:
	print(8+2*(abs(x1-x)+abs(y1-y)))

x1,y1=map(int,input().split())
x2,y2=map(int,input().split())
q=x1==x2 or y1==y2
if x2<x1:
    x2-=1
elif x2>x1:
    x2+=1
if y2<y1:
    y2-=1
elif y2>y1:
    y2+=1
print(abs(x2-x1)*2+abs(y2-y1)*2+4 if q else abs(x2-x1)*2+abs(y2-y1)*2)

x1,y1=map(int,input().split())
x2,y2=map(int,input().split())
w=2*(abs(x2-x1)+abs(y2-y1)+2)
if x1==x2 or y1==y2 :
	print(w+2)
else:
	print(w)

x1, y1 = map(int, input().split())
x2, y2 = map(int, input().split())
if x1 == x2 or y1 == y2:
    print(6+2*abs(x1-x2)+2*abs(y1-y2))
else:
    print(4+2*abs(x1-x2)+2*abs(y1-y2))

x, y = map(int , raw_input().split())
x1 , y1 = map(int , raw_input().split())
res = 0
if x == x1 or y == y1:res = 2
print (abs(x -x1) + abs(y - y1))*2 + 4 + res

a, b = input().split(" ")
x, y = input().split(" ")
a = int(a)
b = int(b)
x = int(x)
y = int(y)
x_ = 0
y_ = 0
if(x == a):
    x_ = 2
    y_ = abs(y-b)+1
elif(y == b):
    x_ = abs(x-a)+1
    y_ = 2
else:
    y_ = abs(y-b)+1
    x_ = abs(x-a)+1
print(2*(x_ + y_))

x1, y1 = [int(i) for i in input().split()]
x2, y2 = [int(i) for i in input().split()]
print(max(abs(x1 - x2) + 1, 2) * 2 + max(abs(y1 - y2) + 1, 2) * 2)

x,y=map(int,input().split(' '))
a,b=map(int,input().split(' '))
print((max(abs(a-x),1)+max(abs(b-y),1))*2+4)

a = input().split()
b = input().split()

x1 = int(a[0])
y1 = int(a[1])
x2 = int(b[0])
y2 = int(b[1])

count = 0

if x1 < x2 and y1 < y2:
    for i in range(x1, x2 + 1):
        count += 1
    for j in range(y1, y2 + 1):
        count += 1
    count *= 2
elif x1 < x2 and y1 > y2:
    for i in range(x1, x2 + 1):
        count += 1
    for j in range(y1, y2 - 1, -1):
        count += 1
    count *= 2
elif x1 > x2 and y1 < y2:
    for i in range(x1, x2 - 1, -1):
        count += 1
    for j in range(y1, y2 + 1):
        count += 1
    count *= 2
elif x1 > x2 and y1 > y2:
    for i in range(x1, x2 - 1, -1):
        count += 1
    for j in range(y1, y2 - 1, -1):
        count += 1
    count *= 2
elif x1 == x2 and y1 < y2:
    count += 2
    for i in range(y1, y2 + 1):
        count += 1
    count *= 2
elif x1 == x2 and y1 > y2:
    count += 2
    for i in range(y1, y2 - 1, -1):
        count += 1
    count *= 2
elif x1 < x2 and y1 == y2:
    count += 2
    for i in range(x1, x2 + 1):
        count += 1
    count *= 2
elif x1 > x2 and y1 == y2:
    count += 2
    for i in range(x1, x2 - 1, -1):
        count += 1
    count *= 2

print(count)

x1, y1 = map(int, input().split())
x2, y2 = map(int, input().split())

import sys

if(x1 == x2):
    res = 2 * (2 + abs(y1 - y2) + 1)
    print(res)
    sys.exit(0)
if(y1 == y2):
    res = 2 * (2 + abs(x1 - x2) + 1)
    print(res)
    sys.exit(0)

res = 2 * (abs(x1 - x2) + 1 + abs(y1 - y2) + 1)
print(res)

f = lambda: map(int, input().split())
print(2 * sum(max(1, abs(a - b)) + 1 for a, b in zip(f(), f())))

x1, y1 = map(int, input().split())
x2, y2 = map(int, input().split())
dx = abs(x1 - x2)
dy = abs(y1 - y2)
if dx and dy:
  print(2 * (dx + dy) + 4)
else:
  print(2 * (dx + dy) + 6)

import sys
import math

#to read string
get_string = lambda: sys.stdin.readline().strip()
#to read list of integers
get_int_list = lambda: list( map(int,sys.stdin.readline().strip().split()) )
#to read integers
get_int = lambda: int(sys.stdin.readline())
#to print fast
pt = lambda x: sys.stdout.write(str(x)+'\n')

#--------------------------------WhiteHat010--------------------------------------#
x,y = get_int_list()
x1,y1 = get_int_list()
if x == x1 or y == y1:
    if x == x1:
        d = 2 + abs(y-y1) + 1
    else:
        d = 2 + abs(x-x1) + 1
else:
    d = abs(x-x1) + 1 + abs(y-y1) + 1

print(2*d)

x1, y1=map(int, raw_input().split()); y=1;
x2, y2=map(int, raw_input().split())
if (x2==x1) and (y2==y1):
    print 8
else:
    if (x2==x1) or (y2==y1):
        print 2*(abs(x2-x1)+abs(y2-y1))+6

    else:
        print 2*(abs(x2-x1)+abs(y2-y1))+4

lstIn = map(int, input().split())
x1, y1 = lstIn

lstIn = map(int, input().split())
x2, y2 = lstIn

dx = abs(x1-x2)
dy = abs(y1-y2)

if dx<2:
    dx=2
else:
    dx += 1
if dy<2:
    dy=2
else:
    dy += 1

dist = dx*2 + dy*2

print(dist)

x1,y1=map(int,input().split())
x2,y2=map(int,input().split())
dx=max(2,abs(x1-x2)+1)
dy=max(2,abs(y1-y2)+1)
print(2*dx+2*dy)

start = input().split()
x1 = int(start[0])
y1 = int(start[1])
flag = input().split()
x2 = int(flag[0])
y2 = int(flag[1])

print( 2*max(1, abs(x1-x2))+2 + 2*max(abs(y1-y2), 1)+2 )

a, b = map(int, raw_input().split())
c, d = map(int, raw_input().split())

print max(1, abs(a - c)) * 2 + max(1, abs(b - d)) * 2 + 4

def main():
	x1,y1 = map(int,input().split())
	x2,y2 = map(int,input().split())
	res = (abs(x2-x1) + abs(y2 - y1) +2)*2
	if x1==x2:
		res +=2
	if y1 == y2:
		res +=2
	print( res)

main()

x1,y1=map(int,input().split())
x2,y2=map(int,input().split())
if x1==x2:
    print(abs(y1-y2)*2+6)
elif y1==y2:
    print(abs(x1-x2)*2+6)
else:
    print((abs(x1-x2)+abs(y1-y2))*2+4)

# Je ne trouve pas l'astuce... :/

def dist(x1, y1, x2, y2):
    return abs(x2 - x1) + abs(y2 - y1)

x, y = map(int, input().split())
a, b = map(int, input().split())

r = 4 + 2 * dist(x, y, a, b)

if x == a or y == b:
    r += 2

print(r)

x1, y1 = map(int, input().split())
x2, y2 = map(int, input().split())

if x1 == x2:
    x1 += 1
elif y1 == y2:
    y1 += 1
print((abs(x2 - x1) + 1 + abs(y2 - y1) + 1) * 2)

read=lambda:map(int,input().split())
x1,y1=read()
x2,y2=read()
print(6+2*(abs(x2-x1)+abs(y2-y1))-2*(x1 != x2 and y1!=y2))

copterX,copterY = map(int, input().split())
flagX,flagY = map(int, input().split())

if copterX == flagX:
    distance = abs(copterY - flagY)
    routeLength = (distance+3)*2
elif copterY == flagY:
    distance = abs(copterX - flagX)
    routeLength = (distance+3)*2
else:
    distanceX = abs(copterX - flagX)
    distanceY = abs(copterY - flagY)
    distanceXY = distanceX + distanceY
    routeLength = (distanceXY+2)*2

print(routeLength)

x1, y1 = map(int, input().split())
x2, y2 = map(int, input().split())

if x1 == x2 and y1 == y2:
	print(8)
if y1 == y2:
	print(((abs(x1 - x2) + 1) * 2) + 4)
elif x1 == x2:
	print(((abs(y1 - y2) + 1) * 2) + 4)
else:
	distx = abs(x1 - x2) + 1
	disty = abs(y1 - y2) + 1
	print(2 * distx + 2 * disty)

I=lambda:map(int,input().split())
a,b=I()
c,d=I()
print((max(1,abs(a-c))+max(1,abs(b-d))<<1)+4)

#startpoint, endpoint = raw_input().split("\n")
startpoint = map(lambda x: int(x), raw_input().split(" "))
endpoint = map(lambda x: int(x), raw_input().split(" "))

width = max(abs(startpoint[0]-endpoint[0]) + 1, 2)
height = max(abs(startpoint[1]-endpoint[1]) + 1, 2)

print width*2 + height*2

x,y = map(int,input().split())
fx,fy = map(int,input().split())
ans = 0
if x == fx or y==fy :
	ans=2
ans +=  abs(fx-x)*2 + abs(fy-y)*2 + 4
print(ans)

x1, y1 = map(int, input().split())
x2, y2 = map(int, input().split())

p = abs(x1 - x2) + abs(y1 - y2) + 2

print((p + 1) * 2) if x1 == x2 or y1 == y2 else print(2 * p)

x1, y1 = map(int, input().split())
x2, y2 = map(int, input().split())
x = 1 if not abs(x1-x2) else abs(x1-x2)
y = 1 if not abs(y1-y2) else abs(y1-y2)
print((x+1)*2 + (y+1)*2)

a,b=map(int,raw_input().split())
c,d=map(int,raw_input().split())
ans=0
if a==c and b==d:
    print 10
elif c>a:
    ans+=(c-a)+1
    ans*=2
    if b>d:
        u=(b-d)+1
        u*=2
        ans+=u
    elif b<d:
        u=(d-b)+1
        u*=2
        ans+=u
    else:
        ans+=4
elif c<a:
    ans+=(a-c)+1
    ans*=2
    if b>d:
        u=(b-d)+1
        u*=2
        ans+=u
    elif b<d:
        u=(d-b)+1
        u*=2
        ans+=u
    else:
        ans+=4
else:
    ans+=4
    if b>d:
        u=(b-d)+1
        u*=2
        ans+=u
    elif b<d:
        u=(d-b)+1
        u*=2
        ans+=u
    else:
        ans+=4
print ans

import sys, math
data = sys.stdin.readlines()

x1, y1 = tuple([int(x) for x in data[0].split()])
x2, y2 = tuple([int(x) for x in data[1].split()])

x1 += 100
y1 += 100
x2 += 100
y2 += 100

x_len = abs(x1 - x2)
y_len = abs(y1 - y2)

result = 0
if x_len == 0:
	result += 4
else:
	result += (x_len + 1) * 2

if y_len == 0:
	result += 4
else:
	result += (y_len + 1) * 2

print result

a = tuple(map(int, input().split()))
b = tuple(map(int, input().split()))

x = abs(a[0] - b[0])
y = abs(a[1] - b[1])

if x == 0:
    x += 2
else:
    x += 1

if y == 0:
    y += 2
else:
    y += 1

print(2*(x + y))

x1,y1=map(int,input().split())
x2,y2=map(int,input().split())
dx=max(2,abs(x1-x2)+1)
dy=max(2,abs(y1-y2)+1)
print(2*dx+2*dy)

ri = lambda: map(int, raw_input().split())
a, b = ri()
c, d = ri()
print (abs(a - c) + abs(b - d)) * 2 + 4

x1,y1 = map(int, raw_input().split())
x2,y2 = map(int, raw_input().split())
print (abs(x2-x1)+1)*2+(abs(y2-y1)+1)*2

def dis(x1,y1,x2,y2) :
    return abs(x1-x2)+abs(y1-y2)
x1,y1=map(int,raw_input().split(' '))
x2,y2=map(int,raw_input().split(' '))
ans=0
for a in range(-1,2,2) :
    for b in range(-1,2,2) :
        ans=max(ans,dis(x1,y1,x2+a,y2+b))

if x1==x2 or y1==y2 :
    ans+=2
print ans*2

def dis(x1,y1,x2,y2) :
    return abs(x1-x2)+abs(y1-y2)
x1,y1=map(int,raw_input().split(' '))
x2,y2=map(int,raw_input().split(' '))
ans=0
for a in range(-1,2,2) :
    for b in range(-1,2,2) :
        ans=max(ans,dis(x1,y1,x2+a,y2+b))
print ans*2

x1,y1=map(int,input().split())
x2,y2=map(int,input().split())
x,y=x2,y2
if abs(x1-x2)>1:
	if x1>x2:
		x=x2+1
	else:
		x=x2-1
if abs(y1-y2)>1:
	if y1>y2:
		y=y2+1
	else:
		y=y2-1
if x==x2 and y==y2:
	print(8)
else:
	print(8+2*(abs(x1-x)+abs(y1-y)))

x1,y1=map(int,input().split())
x2,y2=map(int,input().split())
x,y=x2,y2
if abs(x1-x2)>1:
	if x1>x2:
		x=x2+1
	else:
		x=x2-1
if abs(y1-y2)>1:
	if y1>y2:
		y=y2+1
	else:
		y=y2-1
if x==x2 or y==y2:
	print(8)
else:
	print(8+2*(abs(x1-x)+abs(y1-y)))

x1,y1=map(int,input().split())
x2,y2=map(int,input().split())
x,y=x2,y2
if abs(x1-x2)>=1:
	if x1>x2:
		x=x2+1
	else:
		x=x2-1
if abs(y1-y2)>=1:
	if y1>y2:
		y=y2+1
	else:
		y=y2-1
print(x,y)
if x==x2 and y==y2:
	print(8)
else:
	print(8+2*(abs(x1-x)+abs(y1-y)))

x1, y1 = map(int, input().split())
x2, y2 = map(int, input().split())
print(2 *((abs(x1 - x2) + 1) + (abs(y1 - y2) + 1)))

def f(l1,l2):
    ab = lambda x: x if x>0 else -x
    return (ab(l1[0]-l2[0])+ab(l1[1]-l2[1])+2)<<1

l1 = list(map(int,input().split()))
l2 = list(map(int,input().split()))
print(f(l1,l2))

import sys, collections

def get_dist(a,b,c,d):
    return abs(a - c) + abs(b - d)

x1, y1 = map(int, sys.stdin.readline().split())
x2, y2 = map(int, sys.stdin.readline().split())

if x1 == x2 and y1 != y2:
    print(2 * get_dist(x1 - 1, y1, x2 + 1, y2 - 1))
elif x1 != x2 and y1 == y2:
    print(2 * get_dist(x1, y1 + 1, x2 + 1, y2 - 1))
else:
    print(2 * get_dist(x1, y1, x2 + 1, y2 - 1))

import sys, collections

def get_dist(a,b,c,d):
    return abs(a - c) + abs(b - d)

x1, y1 = map(int, sys.stdin.readline().split())
x2, y2 = map(int, sys.stdin.readline().split())

if x1 == x2 and y1 != y2:
    print(2 * get_dist(x1 - 1, y1, x2 + 1, y2 - 1))
elif x1 != x2 and y1 == y2:
    print(2 * get_dist(x1, y1 + 1, x2 + 1, y2 - 1))
else:
    print(max(2 * get_dist(x1, y1, x2 + 1, y2 - 1), 2 * get_dist(x1, y1, x2 + 1, y2 + 1),
              2 * get_dist(x1, y1, x2 - 1, y2 - 1), 2 * get_dist(x1, y1, x2 - 1, y2 + 1)))

x, y = map(int, input().split())
x2, y2 = map(int, input().split())
print((abs(x - x2) + abs(y - y2) + 2) * 2)

x, y = map(int, input().split())
x2, y2 = map(int, input().split())

result = (abs(x - x2) + abs(y - y2) + 2) * 2
if x == x2:
    result += 2

if y == y2:
    result += 2

first = list(map(int, input().split()))
second = list(map(int, input().split()))

len_to_point = abs(first[0] - second[0]) + abs(first[1] - second[1])

if len_to_point == 1:
  print(8)
else:
  print((len_to_point - 2) *2 + 8)

#!/usr/bin/env python3

x1, y1 = [int(x) for x in input().split(' ')]
x2, y2 = [int(x) for x in input().split(' ')]

print(2*(abs(x1-x2)+1)+2*(abs(y1-y2)+1))

a,b = map( int, input().split(' '))
c,d = map(int, input().split(' '))
print((abs(c-a)+1)*2 + 2*(abs(b-d)+1))

from sys import stdin
x1,y1 = map(int,stdin.readline().split())
x2,y2 = map(int,stdin.readline().split())
ans = 2*(abs(x1-x2) + abs(y1-y2)) + 4
if x1==x2 and y1==y2:
 ans = 10
elif x1==x2 or y1==y2:
 ans = ans+6
print ans

a, b = map(int, raw_input().split())
c, d = map(int, raw_input().split())
e = (abs(a - b) + abs(c - d) + 2) * 2
if a == c or b == d:
	e += 2
print e

a, b = map(int, raw_input().split())
c, d = map(int, raw_input().split())
print (abs(a - b) + abs(c - d) + 2) * 2

s = [int(i) for i in raw_input().split()]
f = [int(i) for i in raw_input().split()]
x1 = s[0]
y1 = s[1]
x2 = f[0]
y2 = f[1]

x = abs(x1-x2)
y = abs(y1-y2)
mini = (x+y+2)*2
print max(mini,8)

import sys
x1,y1=list(map(int,(raw_input().strip().split())))
x2,y2=list(map(int,(raw_input().strip().split())))
print 4+2*(abs(x1-x2)+abs(y1-y2));

x1, y1 = map(int, raw_input().split())
x2, y2 = map(int, raw_input().split())
ptx = ((abs(x2)-abs(x1)) + 1)*2 if (x2-x1) > 0 else 2*2
pty = (abs(abs(y2)-abs(y1)) + 1)*2 if y2 > 0 and y1 > 0 else (abs(y2)+abs(y1)+ 1)*2
print(ptx+pty)

x1, y1 = map(int, raw_input().split())
x2, y2 = map(int, raw_input().split())
if x2 > 0 and x1 > 0 :
	ptx = ((abs(x2) - abs(x1)) + 1) * 2 if (x2 - x1) > 0 else 2 * 2
else:
	ptx = ((abs(x2) + abs(x1)) + 1) * 2 if (x2 - x1) > 0 else 2 * 2
pty = (abs(abs(y2)-abs(y1)) + 1)*2 if y2 > 0 and y1 > 0 else (abs(y2)+abs(y1)+ 1)*2
print(ptx+pty)

x1, y1 = map(int, raw_input().split())
x2, y2 = map(int, raw_input().split())
ptx = ((x2-x1) + 1)*2 if (x2-x1) > 0 else 2*2
pty = (abs(y2-y1) + 1)*2
print(ptx+pty)

x1, y1 = map(int, raw_input().split())
x2, y2 = map(int, raw_input().split())
if x1 == x2 or y1 == 2:
	print(2 * (abs(x1 - x2) + abs(y1 - y2) - 1) + 8)
else:
	print(2 * (abs(x1 - x2) + abs(y1 - y2) + 2))

x1, y1=map(int, raw_input().split()); y=1;
x2, y2=map(int, raw_input().split())
print 2*(abs(x2-x1)+abs(y2-y1))+4

'''input
1 5
5 2
'''

def readint():
    return int(raw_input())

def readints():
    return map(int, raw_input().split())

def readstr():
    return raw_input()

def readstrs():
    return raw_input().split()

def solve():
    return (abs(x1-x2) + abs(y1-y2) + 2) * 2

x1,y1 = readints()
x2,y2 = readints()
print solve()

depart = list(map(int,input().split()))
drapeau = list(map(int,input().split()))

if (drapeau[1]==depart[1]):
    print(8*abs(drapeau[0]-depart[0]))
elif(drapeau[0]==depart[0]):
    print(8 * abs(drapeau[1] - depart[1]))
else :
    print(2*(abs(drapeau[0]-depart[0])+1)+2*(abs(drapeau[1]-depart[1])+1))

depart = list(map(int,input().split()))
drapeau = list(map(int,input().split()))

if (drapeau[1]==depart[1]):
    print(8*abs(drapeau[0]-depart[0]))
elif(drapeau[0]==depart[0]):
    print(8*abs(drapeau[1] - depart[1]))
else :
    print(2*(abs(max(drapeau[0],depart[0])-min(drapeau[0],depart[0]))+1)+2*(abs(max(drapeau[1],depart[1])-min(drapeau[1],depart[1]))+1))

depart = list(map(int,input().split()))
drapeau = list(map(int,input().split()))

if (drapeau[1]==depart[1]):
    print(8*abs(drapeau[0]-depart[0]))
elif(drapeau[0]==depart[0]):
    print(8 * abs(drapeau[1] - depart[1]))
else :
    print(2*(abs(drapeau[0]-depart[0]+1))+2*(abs(drapeau[1]-depart[1])+1))

x1, y1 = [int(i) for i in input().split()]
x2, y2 = [int(i) for i in input().split()]
print(max(8, (abs((x2 - x1)) + 1) * 2 + (abs((y2 - y1)) + 1) * 2))

x1, y1 = [int(i) for i in input().split()]
x2, y2 = [int(i) for i in input().split()]
print(max(8, abs((x2 - x1)) * 2 + abs((y2 - y1)) * 2))

lstIn = map(int, input().split())
x1, y1 = lstIn

lstIn = map(int, input().split())
x2, y2 = lstIn

dx = abs(x2 - x1)
dy = abs(y2 - y1)

if dx*dy == 0:
    dist = 8
else:
    dist = dx*2 + dy*2 + 4

print(dist)

from math import *

xq,yq = map(int, input().split())
xf,yf = map(int, input().split())

val=0

if(fabs(xq - xf)+fabs( yq - yf) == 2):
   print(8)

elif(xq==xf and yq!=yf):
    print(int(2*(fabs( xq - xf)) + 8))

elif(yq==yf and xq!=xf):
    print(int(2*(fabs( yq - yf)) + 8))

elif(xq != xf and yq != yf ):
    print( int(2*(fabs( xq - xf ) + fabs(yq - yf) ) + 4))

from math import *

xq,yq = map(int, input().split())
xf,yf = map(int, input().split())

val=0

if(fabs( xq - xf)+fabs( yq - yf) == 2):
    print(8);

if( xq != xf & yq != yf ):
    print( 2*(fabs( xq - xf ) + fabs(yq - yf) ) + 4)

if(xq==xf):
    print(2*(fabs( xq - xf)) + 8)

if(yq==yf):
    print(2*(fabs( yq - yf)) + 8)

from math import *

xq,yq = map(int, input().split())
xf,yf = map(int, input().split())

val=0
if(xq==xf & yq==yf):
    print(10)
if(fabs( xq - xf)+fabs( yq - yf) == 2):
    print(8);

if( xq != xf & yq != yf ):
    print( int(2*(fabs( xq - xf ) + fabs(yq - yf) ) + 4))

if(xq==xf & yq!=yf):
    print(int(2*(fabs( xq - xf)) + 8))

if(yq==yf & xq!=xf):
    print(int(2*(fabs( yq - yf)) + 8))

from math import *

xq,yq = map(int, input().split())
xf,yf = map(int, input().split())

val=0
if(xq==xf and yq==yf):
    print(10)

elif(fabs(xq - xf)+fabs( yq - yf) == 2):
   print(8)

elif(xq==xf and yq!=yf):
    print(int(2*(fabs( xq - xf)) + 8))

elif(yq==yf and xq!=xf):
    print(int(2*(fabs( yq - yf)) + 8))

elif(xq != xf and yq != yf ):
    print( int(2*(fabs( xq - xf ) + fabs(yq - yf) ) + 4))

from math import *

xq,yq = map(int, input().split())
xf,yf = map(int, input().split())

val=0

if(yq==yf and xq==xf):
    print(int(10))
elif(xq==xf and yq!=yf):
    print(int(2*(fabs( xq - xf)) + 8))
elif(yq==yf and xq!=xf):
    print(int(2*(fabs( yq - yf)) + 8))
elif(fabs(xq - xf) + fabs(yq - yf) == 2):
   print(8)
elif(xq != xf and yq != yf ):
    print( int(2*(fabs( xq - xf ) + fabs(yq - yf) ) + 4))

from math import *

xq,yq = map(int, input().split())
xf,yf = map(int, input().split())

val=0

if(fabs( xq - xf)+fabs( yq - yf) == 2):
    print(8);

if( xq != xf & yq != yf ):
    print( int(2*(fabs( xq - xf ) + fabs(yq - yf) ) + 4))

if(xq==xf):
    print(int(2*(fabs( xq - xf)) + 8))

if(yq==yf):
    print(int(2*(fabs( yq - yf)) + 8))

from math import *

xq,yq = map(int, input().split())
xf,yf = map(int, input().split())

val=0
if(xq==xf and yq==yf):
    print(10)

if(fabs(xq - xf)+fabs( yq - yf) == 2):
   print(8)

if(xq==xf and yq!=yf):
    print(int(2*(fabs( xq - xf)) + 8))

if(yq==yf and xq!=xf):
    print(int(2*(fabs( yq - yf)) + 8))

if(xq != xf and yq != yf ):
    print( int(2*(fabs( xq - xf ) + fabs(yq - yf) ) + 4))

x1,y1 = [i for i in map(int,(input().split()))]
x2,y2 = [i for i in map(int,(input().split()))]
#print(x1,x2,y1,y2)
x = x1-x2
y = y1-y2
#print(x,y)
if x<0:
    x = -1*x
if y<0:
    y = -1*y
x = 2*(x+1)
y = 2*(y+1)
print(x+y)

line1 = input()
line2 = input()
dc = [int(s) for s in line1.split(' ')]
fc = [int(s) for s in line2.split(' ')]
d = [abs(a - b) for a, b in zip(dc, fc)]
print(d)
transit_x = max(2, d[0]+1)*2
transit_y = max(2, d[1]+1)*2
t = transit_x + transit_y
print(t)

line1 = input()
line2 = input()
dc = [int(s) for s in line1.split(' ')]
fc = [int(s) for s in line2.split(' ')]
dx = abs(dc[0]-fc[0])
dy = abs(dc[1]-fc[1])
transit_x = min(2, dx+1)*2
transit_y = min(2, dy+1)*2
t = transit_x + transit_y
print(t)

i,j = input("Enter two values:  ").split()
i = int(i)
j = int(j)

o,p = input("Enter two values:  ").split()
o = int(o)
p = int(p)

a = i - o
b = j - p

if a < 0:
    a = 0-a

if a == 0:
    a = 1

if b == 0:
    b = 1

if b < 0:
    b = 0-b

x =(a+b+2)*2

print(x)

p = input().split()
q = input().split()

x1 = int(p[0])
y1 = int(p[1])
x2 = int(q[0])
y2 = int(q[1])

count = 0

if x1 != x2 and y1 != y2:
    if x1 < x2:
        for i in range(x1, x2 + 2):
            count += 1
        if y1 < y2:
            for j in range(y1, y2 + 2):
                count += 1
        else:
            for k in range(y1, y2 - 2, -1):
                count += 1
    else:
        for i in range(x1, x2 - 2, -1):
            count += 1
        if y1 < y2:
            for j in range(y1, y2 + 2):
                count += 1
        else:
            for k in range(y1, y2 - 2, -1):
                count += 1
    print(count * 2 - 4)
elif x1 == x2 and y1 != y2:
    if y1 < y2:
        for i in range(y1, y2 + 2):
            count += 1
    else:
        for j in range(y1, y2 - 2, -1):
            count += 1
    count += 4
    print(count + 1)
elif x1 != x2 and y1 == y2:
    if x1 < x2:
        for i in range(x1, x2 + 2):
            count += 1
    else:
        for j in range(x1, x2 - 2, -1):
            count += 1
    count += 4
    print(count + 2)

import math
import re

def ria():
    return [int(i) for i in input().split()]

def ri():
    return int(input())

def rfa():
    return [float(i) for i in input().split()]

eps = 1e-9

def is_equal(a, b):
    return abs(a - b) <= eps

def distance(p0, p1):
    return math.sqrt((p0[0] - p1[0]) ** 2 + (p0[1] - p1[1]) ** 2)

xq, yq = ria()
xp, yp = ria()
ar = [(xp + 1, yp+1), (xp - 1, yp-1), (xp-1, yp + 1), (xp+1, yp - 1)]

if xp == xq:
    print(2 * 2 + (abs(yp - yq) + 1) * 2)
if yp == yq:
    print(2 * 2 + (abs(xp - xq) + 1) * 2)
mni = 1e+9

for i in ar:
    x1, y1 = i
    mxx, mxy, mnx, mny = max(x1, xq), max(y1, yq), min(x1, xq), min(y1, yq)
    #print(mxx,mxy,mnx,mny)
    if mxx > xp and mxy > yp and mnx < xp and mny < yp:
        mni = min(mni, (mxx - mnx) * 2 + (mxy - mny) * 2)
print(mni)

# -*- coding: utf-8 -*-

import math
import collections
import bisect
import heapq
import time
import random
import itertools
import sys

"""
created by shhuan at 2017/10/22 12:19

"""

x1, y1 = map(int, input().split())
x2, y2 =  map(int, input().split())

print(2*(2+abs(x1-x2)+abs(y1-y2)))

x1, y1 = map( int, input().split())
x2, y2 = map( int, input().split())
print (max((abs(x1-x2)+abs(y1-y2)+2)*2, 8))

x1, y1 = map( int, input().split())
x2, y2 = map( int, input().split())
print ((abs(x1-x2)+abs(y1-y2)+2)*2)


You're given a row with $$$n$$$ chairs. We call a seating of people "maximal" if the two following conditions hold:  There are no neighbors adjacent to anyone seated.  It's impossible to seat one more person without violating the first rule. The seating is given as a string consisting of zeros and ones ($$$0$$$ means that the corresponding seat is empty, $$$1$$$ — occupied). The goal is to determine whether this seating is "maximal".Note that the first and last seats are not adjacent (if $$$n \ne 2$$$).

The first line contains a single integer $$$n$$$ ($$$1 \leq n \leq 1000$$$) — the number of chairs. The next line contains a string of $$$n$$$ characters, each of them is either zero or one, describing the seating.

Output "Yes" (without quotation marks) if the seating is "maximal". Otherwise print "No". You are allowed to print letters in whatever case you'd like (uppercase or lowercase).

NoteIn sample case one the given seating is maximal.In sample case two the person at chair three has a neighbour to the right.In sample case three it is possible to seat yet another person into chair three.

n=int(input())
c=input()
for i in range(1,n):
    if c[i]==c[i-1] and c[i]!="0":
        print("No")
        exit()
    elif i > 2 and c[i]==c[i-1] and c[i-1]==c[i-2]:
        print("No")
        exit()
if n > 1 and c[1]==c[0] and c[1]=="0":
    print("No")
    exit()
elif n > 1 and c[n-1]==c[n-2] and c[n-1]=="0":
    print("No")
    exit()
if n==1 and c[0]=="0":
    print("No")
    exit()
print("Yes")

n = int(input())
s = input()
per = True
if not '1' in s:
    print("No")
    exit(0)

for i in range(n-1):
    if s[i] == '1':
        if s[i + 1] == '1':
            print("No")
            exit(0)

for i in range(n):
    if s[i] == '1':
        if per:
            if not '1' in s[0:i] and i != 1 and i != 0:
                print("No")
                exit(0)
            per = False
        if i != n - 1:
            if not '1' in s[i+1:i+4] and i != n - 2:
                print("No")
                exit(0)
print("Yes")

n = int(input())
s = input()
if '000' in s or '11' in s or s == '0' or s.startswith('00') or s.endswith('00'):
    print('No')
else:
    print('Yes')

n = int(input())
s = '0'+input()+'0'
ans = 'No' if '000' in s or '11' in s else 'Yes'
print(ans)

def assento(qnt, binario):
    igual1 = 0
    igual0 = 0
    no = 0
    if(binario=="0"):
        print("No")
    else:
        for i in range(qnt):
            if(binario[i]=="1"):
                igual1 = igual1+1
                igual0 = 0
            else:
                if((binario[i]=="0") and (i==0 or i==(qnt-1))):
                    igual0 = igual0+1
                igual0 = igual0+1
                igual1 = 0
            if(igual1 >= 2):
                no=1
                break
            if(igual0 >= 3):
                no=1
                break
        if(no==0):
            print("Yes")
        else:
            print("No")

qnt = int(raw_input())
binario = raw_input()
assento(qnt, binario)

# def neighbour_similar(index, chairs):
#     prev = False
#     if index > 0:
#         prev = chairs[index-1] == chairs[index]
#     forw = False
#     if index < (len(chairs) -1):
#         forw = chairs[index+1] == chairs[index]
#     return (prev or forw)

# def maximal_chairs(n, chairs):
#     if ((len(chairs) > 1) and (n >= (len(chairs) - 1))):
#         return 'Yes'
#     else:
#         if len(chairs) == 1:
#             if chairs == '1':
#                 return 'Yes'
#             else:
#                 return 'No'
#         elif neighbour_similar(n, chairs):
#             return 'No'
#         else:
#             chairs_change = chairs[0:n]+'1'+chairs[n+1:]
#             is_change = neighbour_similar(n, chairs)
#             if is_change == 'No':
#                 return maximal_chairs(n+1, chairs)
#             return 'No'
def maximal_chairs(n, chairs):
    if n == 1:
        if chairs == '0':
            return 'No'
        else:
            return 'Yes'
    if n == 2:
        if chairs == '00' or chairs == '11':
            return 'No'
        else:
            return 'Yes'

    for k in range(n-1):
        if chairs[k] == chairs[k+1] and chairs[k] == '1':
            return 'No'
    for i in range(n):
        if chairs[i] == '0':
            new_chairs = chairs[0:i] + '1' + chairs[i+1:]
            isChange = True
            for j in range(n-1):
                if new_chairs[j] == new_chairs[j+1] and new_chairs[j] == '1':
                    isChange = False
                    break
            if isChange:
                return 'No'
    return 'Yes'

n = int(raw_input())
bit_chairs = raw_input()

print maximal_chairs(n, bit_chairs)

# print maximal_chairs(0, bit_chairs)

n = int(input())
lis = '0' + input() + '0'
if ('000' not in lis) and ('11' not in lis):
    print("Yes")
else:
    print("No")

import sys
from sys import stdin, stdout
from collections import deque

rem=10**9+7
sys.setrecursionlimit(10 ** 6)
take = lambda: map(int, stdin.readline().split())

n=input()
arr=raw_input()
if '11' in arr:
  print 'No'
  exit()
for i in range(n):
  new=arr
  new=list(new)
  if new[i]=='0':
    new[i]='1'
    if '11' not in ''.join(new):
      print 'No'
      exit()
print 'Yes'

import sys
range = xrange
input = raw_input

n = int(input())
A = [c=='1' for c in input()]

pos = True
for i in range(n):
    if not A[i]:
        continue
    if i>0 and A[i-1]:
        pos = False
    if i<n-1 and A[i+1]:
        pos = False
for i in range(n):
    if A[i]:
        continue
    if (i==0 or not A[i-1]) and (i==n-1 or not A[i+1]):
        pos = False
if pos:
    print 'Yes'
else:
    print 'No'

n=int(input())
a=list(input())
dis=[]
for i in range(n):
    if a[i]=="1":
        dis.append(i)
if n==1:
    if a[0]=="0":
        print("NO")
    else:
        print("YES")
else:
    bbbb=1
    if a[0]==a[1]:
        if a[i]=="0":
                bbbb=0

    if bbbb==0:
        print("NO")
    else:

        pre=0
        pdis=[]
        for i in range(len(dis)):
            pdis.append(dis[i]-pre)
            pre=dis[i]
        pdis.append(n-1-dis[-1])
        bb=1
        for i in range(1,len(pdis)-1):
            if (pdis[i]<2 or pdis[i]>3):
                bb=0

                break

        if bb==1 and pdis[0]<2 and pdis[-1] <2:
            print("YES")
        else:
            print("NO")

chairCount = int(raw_input())

seated = raw_input()

prevOpen = True

for seat in range(chairCount):
	if seated[seat] == '0' and prevOpen and (seat==chairCount-1 or seated[seat+1] =='0'):
		print 'No'
		quit()
	if seated[seat] =='1':
		if prevOpen==False:
			print 'No'
			quit()
		prevOpen = False
	if seated[seat] == '0':
		prevOpen=True
print 'Yes'

n=int(input())
l=input()
nona=l.find('11')
nomop=l.find('000')
end=l.endswith("00")
start=l.startswith("00")
if n>1:
    if nona==-1 and nomop==-1 and end==False and start==False:
        print("Yes")
    else:
        print("No")
elif n==1:
    if l=='0':
        print("No")
    else:
        print('Yes')

# Codeforces 982A: Row

def is_maximal(n, s):
    if s == "0":
        return False
    if s == "1":
        return True
    if n >= 2 and (s[0:2] == "00" or s[-2:n] == "00"):
        return False
    for i in xrange(n - 1):
        if s[i] == s[i + 1] == '1':
            return False
        if i + 2 < n and s[i] == s[i + 1] == s[i + 2] == '0':
            return False
    return True

n = int(raw_input())
s = raw_input()

print 'Yes' if is_maximal(n, s) else 'No'

input()
s = '0'+input()+'0'
print("No" if '000' in s or '11' in s else "Yes")

n=input()
st=str(raw_input())
ans=1
st="0"+st+"0"
for i in range(1,n+1):
  if st[i]=="1":
    if st[i+1]=="1" or st[i-1]=="1":
      ans=0
  if st[i]=="0":
    if st[i+1]=="0" and st[i-1]=="0":
      ans=0
if ans==1:
  print "yes"
else:
  print "no"

def solve(d):
    if len(d) == 1:
        return d[0] == '1'
    if d[:2] == '00' or d[-2:] == '00':
        return False
    prev = d[0]
    sublen = 0
    for c in d[1:]:
        if c == prev:
            sublen += 1
            if c == '0' and sublen == 2:
                return False
            if c == '1':
                return False
        else:
            sublen = 0
        prev = c
    return True

from sys import stdin
_, data = stdin.readline(), stdin.readline()
print(solve(data[:-1]) and 'Yes' or 'No')

def print_return(func):
    def wrapper(*args, **kwargs):
        retval = func(*args, **kwargs)
        print(retval)
        return retval

    return wrapper

class Solve:
    @staticmethod
    @print_return
    def solve_a(lines=None):
        if lines is None:
            n = int(input())
            row = input()
        else:
            lines = lines.split('\n')
            n = int(lines[0].strip())
            row = lines[1].strip()
        row = '0' + row + '0'
        ans = 'Yes'
        for idx in range(1, n + 1):
            if all(x == '0' for x in row[idx - 1: idx + 2]):
                ans = 'No'
                break
            elif row[idx] == '1' and any(x == '1' for x in (row[idx - 1], row[idx + 1])):
                ans = 'No'
                break
        return ans

    @staticmethod
    @print_return
    def solve_b(lines=None):
        if lines is None:
            n = int(input())
            idx___width = [int(x) for x in input().split()]
            stop_idx___char = input()
        else:
            lines = lines.split('\n')
            n = int(lines[0])
            idx___width = [int(x) for x in input().split()]
            stop_idx___char = input()

    @staticmethod
    @print_return
    def solve_c(lines=None):
        pass

    @staticmethod
    @print_return
    def solve_d(lines=None):
        pass

    @staticmethod
    @print_return
    def solve_e(lines=None):
        pass

    @staticmethod
    @print_return
    def solve_f(lines=None):
        pass

if __name__ == '__main__':
    Solve.solve_a()

n = int(raw_input())
arr = raw_input()

if n == 1:
    print "Yes" if arr[0] == '1' else "No"
    exit()

for i in range(n):
    if i == 0:
        if arr[i] == '1' and arr[i + 1] == '1':
            print "No"
            exit()
        if arr[i] == '0' and arr[i + 1] == '0':
            print "No"
            exit()
    elif i == n - 1:
        if arr[i] == '0' and arr[i - 1] == '0':
            print "No"
            exit()
    else:
        if arr[i] == '1' and arr[i + 1] == '1':
            print "No"
            exit()
        if arr[i - 1] == '0' and arr[i] == '0' and arr[i + 1] == '0':
            print "No"
            exit()

print "Yes"

n = int(input())
s = input()
pt = 0

cnt = 0
if(int(s[0]) == 1):
	if(n > 1):
		if(int(s[1]) == 1):
			pt = 1
		else:
			cnt += 1
	else:
			cnt += 1
else:
	if(n > 1):
		if(int(s[1]) == 0):
			pt = 1

for i in range(1,n-1):
	if(int(s[i]) == 1):
		if(int(s[i-1]) == 0 and int(s[i+1]) == 0):
			cnt +=1
		else:
			pt = 1
			break
	else:
		if(int(s[i-1]) == 0 and int(s[i+1]) == 0):
			pt = 1
			break

if(int(s[n-1]) == 1):
	if(n > 1):
		if(int(s[n-2]) == 1):
			pt = 1
		else:
			cnt += 1
	else:
			cnt += 1
else:
	if(n > 1):
		if(int(s[n-2]) == 0):
			pt = 1
	else:
		pt = 1

if(pt == 0):
	print("Yes")
else:
	print("No")

n = int(input().strip())
a = input().strip()

flag = False
if n == 1 and a[0] == '0':
    flag = True
elif n > 1:
    for i in range(n-1):
        if a[0] == a[1] or a[n - 2] == a[n - 1]:
            flag = True
        if a[i+1] == a[i] == '1':
            flag = True
            break
        if a[i+1] == a[i] == a[i-1] == '0':
            flag = True
            break
if not flag:
    print("Yes")
else:
    print("No")

# kon bodmaish hack krce.....aj coding parina ble......shb thikace..khali ak jaygay output duibar print hoy (-.-)

def khela(kaj):
    if '11' in str(kaj):
        return 0
    else:
        return 1

a=int(input())
b= input()
li1=list(b)
li2= list(li1)
c= khela(str(b))

xx=0
if c==0:
    fino= 'NO'
    xx=1

if c==1:
    for i in range(a):
        li1= list(li2)
        if li1[i]=='0':
           li1[i]='1'
           checking= ''.join(ii for ii in li1)
           #print(checking)
           huha= khela(str(checking))
           if huha==1:
                fino= 'NO'
                xx=1

        li1= list(li2)
if xx==0:
    fino= 'YES'
print(fino)

x=int(input())
str="0"+input()+"0"
if '000' in str:
    print("No")
elif '11' in str:
    print("No")

else:
    print("Yes")

n = raw_input()
str = raw_input()
if str == '0' or '11' in str or '000' in str or str.startswith('00') or str.endswith('00'):
	print 'No'
else:
	print 'Yes'

def f(s, n):
    p = s
    if all(map(lambda x: x == '0', p)):
        return 'No'
    if n == 1 and s[0] == '0':
        return 'No'
    if p[0:2] == ['0', '0']:
        return 'No'
    if p[-2:] == ['0', '0']:
        return 'No'
    p.append('1')
    first = p.index('1')
    last = p.index('1', first+1)
    while last < n:
        d = last - first
        first = last
        last = p.index('1', first+1)
        if 2 <= d <= 3:
            continue
        else:
            return 'No'
    return 'Yes'

n = int(raw_input().strip())
s = list(raw_input().strip())
print f(s, n)

n=int(input())
s=input()
ans="Yes"
if n==1 and s=='0':
    ans="No"
if n==1 and s=='1':
    ans="Yes"
if s.count("000")>0:
    ans="No"
if s.count("11")>0:
    ans="No"
if s[:2]=="00":
    ans="No"
if s[-2:]=="00":
    ans="No"
print(ans)

import time, math
t1 = time.time()

n = int(raw_input())
line = raw_input()

line = "0" + line + "0"

ans = "Yes"

for i in range(len(line) - 2):
    if line[i] == "0" and line[i+1] == "0" and line[i+2] == "0":
        ans = "No"
        break
    if line[i] == "1" and line[i+1] == "1":
        ans = "No"
        break

print ans
# print time.time() - t1

m = input()
s = raw_input()

if ('11' in s) or s.startswith('00') or s.endswith('00') or ('000' in s) or s=='0':
    print "No"
else:
    print "Yes"

n=int(input())
s=input().strip()
if n<=2:
    if s in ['10','01','1']:
        print('Yes')
    else:
        print('No')
else:
    if '11' in s:
        print('No')
    elif '000' in s:
        print('No')
    elif s[:2]=='00':
        print('No')
    elif s[-2:]=='00':
        print('No')
    else:
        print('Yes')

n = int(input())
u = list(map(int, list(input())))
if n == 1 and u[0] == 0:
    print('No')
    exit()
for i in range(1, n - 1):
    if u[i] == 0:
        if u[i - 1] == u[i] and u[i + 1] == u[i]:
            print('No')
            exit()
    else:
        if u[i - 1] == u[i] or u[i + 1] == u[i]:
            print('No')
            exit()
if n > 1 and (u[0] == u[1] or u[-1] == u[-2]):
    print('No')
else:
    print('Yes')

def fn(s):
	s = ''.join(('0', s, '0'))
	t = 0
	for i, c in enumerate(s):
		if c == '0':
			t += 1
			if t > 2:
				print "No"
				return
		else:
			if t == 0:
				print "No"
				return
			t = 0
	print "Yes"

if __name__ == '__main__':
	n = raw_input()
	s = raw_input()
	fn(s)

n = int(input())
a = '0'+input()+'0'
if '000' in a or '11' in a:print('No')
else:print('Yes')

import sys

n = int(raw_input())

a = raw_input()

last = '0'
same = 1

for e in a:
	if e == last:
		same += 1

		if e == '1' or same > 2:
			print "No"
			sys.exit()
	else:
		same = 1
		last = e

if same > 1 and last == '0':
	print "No"
else:
	print "Yes"

import re
n = input()
s = raw_input()
if n>=2:
	if s[:2]=='00' or s[-2:]=='00':
		print 'NO'
		exit(0)
if n==1:
	if s=='1':
		print 'Yes'
	else:
		print 'NO'
	exit(0)
p1 = re.compile(r'0+')
a = max(map(len,p1.findall(s))+[0])
b = max(map(len,p1.split(s))+[0])
if a>2 or b>1:
	print 'No'
else:
	print 'Yes'

n = input()
s = raw_input()
if n == 1:
	if s[0] == '1':
		print "Yes"
	else:
		print "No"
else:
	for i in xrange(1, n-1):
		if s[i] == '1':
			if s[i-1] == '1' or s[i+1] == '1':
				print "No"
				break
		else:
			if s[i-1] == '0' and s[i+1] == '0':
				print "No"
				break
	else:
		if s[0] != s[1] and s[-1] != s[-2]:
			print "Yes"
		else:
			print "No"

n = int(input())
s = input()
i = 0
res = True
count = 0
while(i<n):
  if s[i]=='1':
    if count>2 or (i!=0 and count==0):
      res = False
      break
    count=0
  else:
    count+=1
  i+=1
if (n==1 and s[0]=='0') or (n>1 and s[0]=='0' and s[1]=='0'):
  res = False
if count>=2:
  res = False
if res:
  print('Yes')
else:
  print('No')

n=int(input())
s=input()
s='0'+s+'0'

x,y=s.find('000'),s.find('11')
if x==-1 and y==-1:
    print('Yes')
else:
    print('No')

n = int(input())
s = input()
f = 0
if n==1 and s=='0':
    print('No')
elif n==2 and s[0]==s[1]:
    print('No')
else:
    for i in range(1,n-1):
        if s[i+1]==s[i-1] and s[i+1]==s[i]:
            f=1
            break
        elif s[i]=='1' and (s[i-1]=='1' or s[i+1]=='1'):
            f=1
            break
    if f==0:
        if s[0]=='0' and s[1]=='0':
            print('No')
        elif s[-1]=='0' and s[-2]=='0':
            print('No')
        else:
            print("Yes")

    else:
        print('No')

import sys
from math import ceil

n = int(sys.stdin.readline().strip())
s = sys.stdin.readline().strip()

def sol():
	if s == "0":
		return False
	elif s[:2] == "00":
		return False
	elif s[-2:] == "00":
		return False
	else:
		if s.count("000") > 0:
			return False
		return s.count("11") == 0

print(["No","Yes"][sol()])

n = input()
s = raw_input()
if n == 1:
    if s[0] == '1':
        print "Yes"
    else:
        print "No"
elif n == 2:
    if s[0] == s[1]:
        print "No"
    else:
        print "Yes"
else:
    p = 0
    for i in range(len(s)-1):
        if i == 0:
            if s[i] == s[i+1]:
                p = 1
                print "No"
                break
        elif i == len(s)-2:
            if s[i] == s[i+1]:
                p = 1
                print "No"
                break
        else:
            if s[i] == s[i+1] and s[i] == s[i-1]:
                p = 1
                print "No"
                break
            elif s[i] == s[i+1] and s[i] == '1':
                p = 1
                print "No"
                break
            elif s[i] == s[i-1] and s[i] == '1':
                p = 1
                print "No"
                break
    if not p:
        print "Yes"

class CodeforcesTask982ASolution:
    def __init__(self):
        self.result = ''
        self.seating = ''

    def read_input(self):
        input()
        self.seating = input()

    def process_task(self):
        if "11" in self.seating:
            self.result = "No"
        else:
            if "000" in self.seating:
                self.result = "No"
            elif len(self.seating) > 1:
                if "00" in self.seating[:2]:
                    self.result = "No"
                elif "00" in self.seating[-2:]:
                    self.result = "No"
                else:
                    self.result = "Yes"
            else:
                if "0" in self.seating:
                    self.result = "No"
                else:
                    self.result = "Yes"

    def get_result(self):
        return self.result

if __name__ == "__main__":
    Solution = CodeforcesTask982ASolution()
    Solution.read_input()
    Solution.process_task()
    print(Solution.get_result())

#[int(k) for k in raw_input().split(" ")]
n=int(raw_input())
s="0"+raw_input()+"0"
res="Yes"
for k in range(1,n+1):
    if s[k-1:k+2]=="000":
        res="No"
        break
    if s[k:k+2]=="11":
        res="No"
        break

print res

input()
s = "0"+input()+"0"
print("NO" if ("000" in s or "11" in s) else "YES")

#!/usr/bin/env python3
# -*- encoding: utf-8 -*-

import sys

def main():
    n = int(sys.stdin.readline())
    l = [int(i) for i in sys.stdin.readline().strip()]

    if l == [0] or sum(l[0:2]) == 0 or sum(l[-2::]) == 0:
        print('No')
        return

    for i in range(n-1):
        if l[i] + l[i+1] == 2 or sum(l[i:i+3]) == 0:
            print('No')
            return
    print('Yes')

main()

import sys

stdin = sys.stdin

n = int(stdin.readline())
seats = stdin.readline().strip()

seats = '0' + seats[:] + '0'
n = len(seats)
for i in range(n):
    if i < n-1 and seats[i:i+2] == '11':
        print("No")
        exit(0)
    if i < n-2 and seats[i:i+3] == '000':
        print("No")
        exit(0)
print("Yes")

n = int(input())
lis = '0' + input() + '0'
if ('000' not in lis) and ('11' not in lis):
    print("Yes")
else:
    print("No")

def solve(s):
	#print len(s)
	if len(s) == 1:
		return s == "1"
	if s[0] == "0" and s[1] == "0":
		return False
	if s[len(s) - 1] == "0" and s[len(s) - 2] == 0:
		return False

	init = 0
	while(s[init] != "1"):
		init += 1

	i = init
	while(i < len(s)):
		#print i
		if s[i] == "1" and i != len(s) - 1:
			first = i + 1
			#print first
			while(first < len(s) and s[first] != "1"):
				#print first
				first += 1

			#print first, i
			if first == len(s) and s[first-1] == "0" and s[first-2] == "0":
				return False
			if (first - i > 3 or first - i == 1) and first < len(s):

				#print first, i
				return False
			i = first
		else:
			i += 1
	return True

n = int(raw_input())
s = raw_input()

if solve(s):
	print "Yes"
else:
	print "No"

n = int(input())
flag = True
a = input()
for i in range(1,n-1):
    if a[i] == '1':
        if a[i-1] == '1' or a[i+1] == '1':
            print("No")
            flag = False
            break
    if a[i] == '0':
        if a[i - 1] == '0' and a[i + 1] == '0':
            print("No")
            flag = False
            break
if ((a == '0' or a == '11') or (a[n-1] == '0' and a[n-2] == '0') or (a[0] == '0' and a[1] == '0')) and flag:
    flag = False
    print("No")
if flag:
    print("Yes")

from sys import stdin
numero = int(input())
ordem= str(stdin.readline())

x=False
if(numero==1 and ordem[0]=="0"):
	x=True
for i in range(1,numero):

	if(ordem[i]==ordem[i-1] and ordem[i]=="1"):
	    x=True
	    break
	elif(ordem[i]==ordem[i-1] and ordem[i]==ordem[i+1] and ordem[i]=="0"):
	    x=True
	    break
	elif((i==1 and ordem[i]==ordem[i-1] and ordem[i]=="0") or (i==numero-1 and ordem[i]==ordem[i-1] and ordem[i]=="0")):
		x=True
		break

if(x==False):
    print("Yes")
else:
	print("No")

import sys, bisect

f = sys.stdin
#f = open('ROW.txt')
n = int(f.readline())
s = f.readline()
ans = "Yes"
prev = s[0]
for i in range(1, n):
    if s[i] == prev and s[i] == '1':
        ans = "No"
        break
    prev = s[i]
if ans == "Yes":
    for i in range(0, n):
        if s[i] == '0':
            prev = '0'
            next = '0'
            if i > 0:
                prev = s[i - 1]
            if i + 1 < n:
                next = s[i + 1]
            if prev == '0' and next == '0':
                ans = "No"
                break
print ans
#f.close()

n=input()
s=raw_input()
if n==1:
	if s=='0':
		print 'No'
	else:
		print 'Yes'
elif (s[0]=='0' and s[1]=='0') or  (s[-1]=='0' and s[-2]=='0'):
	print 'No'
else:
	flag = True
	on=0
	zer=0
	for i in s:
		if i=='0':
			zer+=1
			on=0
			if zer ==3:
				flag = False
		if i=='1':
			on+=1
			zer=0
			if on ==2:
				flag = False
	print ["No","Yes"][flag]

n = int(raw_input())
s = raw_input()
f = (s == '0' or s.startswith('00') or s.endswith('00') or '000' in s or '11' in s)

print 'No' if f else 'Yes'

n = int(input().strip())
a = input().strip()

flag = False
if n == 1 and a[0] == '0':
    flag = True
elif n > 1:
    for i in range(n-1):
        if a[0] == a[1] or a[n - 2] == a[n - 1]:
            flag = True
        if a[i+1] == a[i] == '1':
            flag = True
            break
        if a[i+1] == a[i] == a[i-1] == '0':
            flag = True
            break
if not flag:
    print("Yes")
else:
    print("No")

n=int(input())
s=input().strip()
flag=1
if n==1:
    if s!="0":
        print("Yes")
    else:
        print("No")
elif n==2:
    if s!="00" and s!="11":
        print("Yes")
    else:
        print("No")
else:
    if s[:2]=="00":
        flag=0
    for i in range(1,n-1):
        t=s[i-1]+"1"+s[i+1]
        if t=="010" and s[i]!="1":
            flag=0
            break
    if s[n-2:n]=="00":
        flag=0
    for i in range(n-1):
        if s[i:i+2]=="11":
            flag=0
            break
    if flag==1:
        print("Yes")
    else:
        print("No")

n=int(input())
s=str(input())
if n==1:
    if s=="0":
        print("No")
    else:

        print("Yes")
elif n==2:
    if s[0]!=s[1]:
        print('Yes')

    else:
        print("No")
elif n==3:
    if s[0]==s[2] and s[0]!=s[1]:
       print("Yes")

    else:
        print("No")
else:

        a=[]
        an=True
        for i in range(n):
            if s[i]=="1":
                a.append(i)

        for i in range(len(a)-1):
            if (int(a[i+1])-int(a[i])-1)<1 or (int(a[i+1])-int(a[i])-1)>=3:
                an=False

                break
        lv=len(s)
        no=s.rstrip("0")
        n1=s.lstrip("0")
        an1=lv-len(no)
        an2=lv-len(n1)

        if an==True and an1<=1 and an2<=1:
            print('Yes')
        else:
            print("No")

n = int(input())
s = '0' + input() + '0'

if s == "00":
    print("No")

else:
    if "000" in s or "11" in s:
        print("No")
    else:
        print("Yes")

n = int(raw_input())
seating = raw_input()
answer = "Yes"
oneCount = 0
zeroCount = 0

if seating == '0': answer = "No"

if n > 2 and (seating[0] == seating[1]):
    answer = "No"

for i in range(n):
    if seating[i] == '0':
        zeroCount += 1
        oneCount = 0
    else:
        oneCount += 1
        zeroCount = 0

    if zeroCount == 3:
        answer = "No"
    elif oneCount == 2:
        answer = "No"

if zeroCount == 2: answer = "No"

print answer

# contest http://codeforces.com/contest/982/problem/A

def f(seats):
    if len(seats) == 1:
        if seats == "1":
            return "Yes"
        else:
            return "No"

    if seats[0] == '1' and seats[-1] == '1':
        return f(seats[2:])
    else:
        return "No"

def solution(line1, line2):
    N = int(line1)
    seats = line2

    if (N%2 == 0):
        if seats[0] == '1' and seats[-1] == '0':
            return f(seats[0:-1])
        elif seats[0] == '0' and seats[-1] == '1':
            return f(seats[1:])
        else:
            return "No"

    else:
        return f(seats)

def solution2(line2):

    if line2 == '0':
        return "No"
    if line2[-2:] == "00":
        return "No"
    first_one_index = 0
    for i in range(len(line2)):
        if line2[i] == '1':
            first_one_index = i
            break
    if first_one_index > 1:
        return "No"

    line2 = line2[first_one_index+1:]

    last_is_zero = False
    zero_count = 0
    one_count = 1
    for i in range(len(line2)):
        c = line2[i]
        if c == '0':
            if last_is_zero == False:
                zero_count = 1
                one_count = 0
                last_is_zero = True
            elif zero_count > 1:
                return "No"
            else:
                zero_count = zero_count + 1
        elif c == '1':
            if last_is_zero == True:
                zero_count = 0
                one_count = 1
                last_is_zero = False
            else:
                return "No"
    return "Yes"

line1 = raw_input();
line2 = raw_input();

print solution2(line2)

n = int(input())
s = input()
s = "0" + s + "0"
if n >= 3:
    if "11" in s or "000" in s:
        print("NO")
    else:
        print("YES")
elif n == 2:
    if s == "0110" or s == "0000":
        print("NO")
    else:
        print("YES")
else:
    if s == "010":
        print("YES")
    else:
        print("NO")

n = int(input())
s = input()
if n == 1:
    if s == '0':
        print('No')
    else:
        print('Yes')
elif n == 2:
    if s == '00' or s == '11':
        print('No')
    else:
        print('Yes')
else:
    if s.find('11') + 1 or s.find('000') + 1:
        print('No')
    elif s.find('00') == 0 or s.rfind('00') == n - 2:
        print('No')
    else:
        print('Yes')

n=input()
f=0
s=raw_input()
cnt=0
if (n==1 and s[0]=='0'):
    print "No"
    exit(0)
s='0'+s+'0'
for i in range(len(s)-1):
    if (s[i]=='1' and s[i+1]=='1'): f=1
for i in range(len(s)-2):
    if (s[i]=='0' and s[i+1]=='0' and s[i+2]=='0'): f=1

if (f==0):
    print "Yes"
else:
    print "No"

n = int(input())
ss = input().strip()
s = [int(i) for i in list(ss)]
arr = []
for i in range(n):
    if s[i]==1:
        arr.append(i+1)
failed = 0
if n==1 and s==[0]:
    print("No")
elif n==1 and s==[1]:
    print("Yes")
elif n==2 and ss=='00':
    print("No")
elif n==2 and ss=='01':
    print("Yes")
elif n==2 and ss=='10':
    print("Yes")
elif n==2 and ss=='11':
    print("No")
elif n==3 and ss=='000':
    print("No")
elif n==3 and ss=='100':
    print("No")
elif n==3 and ss=='001':
    print("No")
elif n==3 and ss=='010':
    print("Yes")
elif n==3 and ss=='110':
    print("No")
elif n==3 and ss=='101':
    print("Yes")
elif n==3 and ss=='011':
    print("No")
elif n==3 and ss=='111':
    print("No")
else:
    if n>3 and s.count(1)<=1:
        print("No")
    elif arr[0]>2:
        print("No")
    elif arr[-1]<(n-1):
        print("No")
    else:
        pas = 0
        for i in range(len(arr)-1):
            if arr[i+1]-arr[i]>3 or arr[i+1]-arr[i]<2:
                pas = 1
                break
        if pas==1:
            print("No")
        else:
            print("Yes")

##kkl = 0
##if s.count('1')>0:
##    position = n  - s[::-1].index('1')
##    print(position)
##    if position<len(s):
##        for i in range(position):
##            first = i
##            second = i+1
##            if s[first]==s[second]:
##                print("No")
##                kkl = 1
##                break
##        if kkl==0:
##            if position==n-1:
##                print("Yes")
##            else:
##                print("No")
##    else:
##        for i in range(len(s)-1):
##            first = i
##            second = i+1
##            if s[first]==s[second]:
##                print("No")
##                kkl = 1
##                break
##        if kkl==0:
##            print("Yes")
##else:
##    print("No")

n = int(input())
s = '0' + input() + '0'

if s == '0':
	print("No")
if '11' in s or '000' in s:
	print("No")
else:
	print("Yes")

n=int(input())
s=input()
flg=0
cnt=0
if s[0]=='0' and n==1:
        print('No')
        flg=1
else:
    for i in range(n-1):
        if s[i]=='1' and s[i+1]=='1':
            print('No')
            flg=1
            break
        if s[i]=='0' and s[i+1]=='0' and i+1==n-1:
                print('No')
                flg=1
                break
        elif s[i]=='0' and i==0:
            cnt+=2
            if cnt>=3:
                print('No')
                flg=1
                break
        elif s[i]=='0':
            cnt+=1
            if cnt>=3:
                print('No')
                flg=1
                break
        else:
            cnt=0
if flg==0:
    print('Yes')

t = input()
a = raw_input()

if t >=3:
    if '000' in a or '11' in a:
        print 'No'

    else:
        if a[0] == '0' and a[1] == '0' and a[2] != '0':
            print 'No'
        else:
            if a[t-1] == '0' and a[t-2] == '0' and a[t-3]!= '0':
                print 'No'
            else:
                print 'Yes'
else:
    if t == 1:
        if '0' in a:
	    print 'No'
	else:
	    print 'Yes'
    if t == 2:
	if '10' in a or '01' in a:
	    print 'Yes'
	else:
	    print 'No'

n = input()
s = '0' +raw_input() + '0'
if '000' in s or '11' in s:
    print 'No'
else:
    print 'Yes'

n, s = input(), input()
if s in ['0', '00']:
    print('No')
else:
    print(('No', 'Yes')[not s.startswith('00') and not s.endswith('00')
                        and s.count('000') == 0 and s.count('11') == 0])

n = int(input())
seats = input()

maximal = True

if n == 1:
    if seats[0] == '0':
        maximal = False

elif n == 2:
    if seats[0] == '1' and seats[1] == '1' or seats[0] == '0' and seats[1] == '0':
        maximal = False

elif seats[0] == '0' and seats[1] == '0' or seats[-1] == '0' and seats[-2] == '0':
    maximal = False

for i in range(1, n-1):
    if seats[i] == '0' and seats[i-1] == '0' and seats[i+1] == '0':
        maximal = False
        break
    elif seats[i] == '1' and (seats[i+1] == '1' or seats[i-1] == '1'):
        maximal = False
        break

if maximal:
    print("Yes")
else:
    print("No")

n = int(input())
s = input()
i = 0
res = True
count = 0
while(i<n):
  if s[i]=='1':
    if count>2 or (i!=0 and count==0):
      res = False
      break
    count=0
  else:
    count+=1
  i+=1
if (n==1 and s[0]=='0') or (n>1 and s[0]=='0' and s[1]=='0'):
  res = False
if count>=2:
  res = False
if res:
  print('Yes')
else:
  print('No')

import sys
data = sys.stdin.readlines()[1]

estado = 'Yes'

if data == '0\n' or data == '00\n':
	#print(1)
	estado = 'No'
if ('100\n' in data):
	#print(2)
	estado = 'No'
if ('001') == data[0:3]:
	#print(3)
	estado = 'No'
if '11' in data:
	#print(4)
	estado = 'No'
if '000' in data:
	#print(5)
	estado = 'No'

print(estado)

def row(qnt, binario):
    igual1 = 0
    igual0 = 0
    no = 0
    if(binario == "0"):
        print("No")
    else:
        for i in range(qnt):
            if(binario[i]=="1"):
                igual1 = igual1+1
                igual0 = 0
            else:
                if((binario[i]=="0") and (i==0 or i==(qnt-1))):
                    igual0 = igual0+1
                igual0 = igual0+1
                igual1 = 0
            if(igual1 >= 2):
                no=1
                break
            if(igual0 >= 3):
                no=1
                break
        if(no==0):
            print("Yes")
        else:
            print("No")

qnt = int(raw_input())
binario = raw_input()
row(qnt, binario)

import sys
import math
import bisect

def solve(A):
    n = len(A)
    for i in range(n):
        if i + 1 < n and A[i] and A[i+1]:
            return False
    for i in range(n):
        if A[i] == 0:
            ok = True
            if i - 1 >= 0 and A[i-1]:
                ok = False
            if i + 1 < n and A[i+1]:
                ok = False
            if ok:
                return False
    return True

def main():
    n = int(input())
    A = []
    s = input()
    for c in s:
        A.append(int(c))
    if solve(A):
        print('Yes')
    else:
        print('No')

if __name__ == "__main__":
    main()

a=int(input())
b=input()
s='10'*a
if a==1:
    if b=='1':
        print('yes')
    else:
        print('No')
elif a==2:
    if b=='10' or b=='01':
        print('yes')
    else:
        print('no')
elif a==3:
    if b=='010' or b=='101':
        print('yes')
    else:
        print('no')
elif a==4:
    if b==s[:a]:
        print('yes')
    elif '1001' in b:
        print('yes')
    elif '0101' in b:
        print("yes")
    else:
        print('no')

else:
    if '000' in b:
        print('no')
    elif '11' in b:
        print('no')
    elif b[-2::1]=='00':
        print('no')
    else:
        print('yes')

input()
s = '0' + input() + '0'
print("No" if "11" in s or "000" in s else "Yes")

n = int(raw_input())
aceito = True
string = raw_input()
string = '0' + string + '0'
cont = 0

for i in range(1,n+1):

	if string[i] == '1':

		cont = 0

		if string[i-1] == '1' or string[i+1] == '1':

			aceito = False
			break

	if string[i] == '0':

		cont += 1

	if cont > 2:

		aceito = False
		break

if string[1] == '0' and string[2] == '0':

	aceito = False

if string[n -1] == '0' and string[n] == '0':

	aceito = False

if aceito:

	print 'YES'

else:

	print 'NO'

#!/usr/bin/env python3
# -*- encoding: utf-8 -*-

import sys

def main():
    n = int(sys.stdin.readline())
    l = [int(i) for i in sys.stdin.readline().strip()]

    if l == [0]:
        print('No')
        return

    for i in range(n-1):
        if l[i] + l[i+1] == 2 or sum(l[i:i+3]) == 0:
            print('No')
            return
    print('Yes')

main()

n = int(input())
s = input()
i = 0
res = True
count = 0
while(i<n):
  if s[i]=='1':
    if count>2 or (i!=0 and count==0):
      res = False
      break
    count=0
  else:
    count+=1
  i+=1
if count>2:
  res = False
if res:
  print('Yes')
else:
  print('No')

import sys

stdin = sys.stdin

n = int(stdin.readline())
seats = stdin.readline()

if n < 3:
    print("No")
    exit(0)
for i in range(n):
    if i < n-1 and seats[i:i+2] == '11':
        print("No")
        exit(0)
    if i < n-2 and seats[i:i+3] == '000':
        print("No")
        exit(0)
print("Yes")

import re
n=int(input())
s=input()
a=re.search('000',s)
#print(a)
b=re.search('11',s)
#print(a,b)
if s=='0':
    print("NO")
elif s=='00':
    print("NO")
else:
    if a or b:
        print("NO")
    else:
        print("YES")

n=int(input())
a=str(input())
a=list(a)
for i in range(n):
    a[i]=int(a[i])
k=0
if n==1 and a[0]==0:
   k=k+1
for i in range(1,n):
    if a[i-1]==a[i] and a[i]==a[i-1]!=0:
        k=k+1
if k==0:
    print('Yes')
else:
    print('No')

k = int(input())

s = input()
for i in range(1,len(s)):
    if(int(s[i])+int(s[i-1]) == 2) :
        print('No')
        exit()
for i in range(1,len(s)-1):
    if(s[i] == '0' and s[i-1]=='0' and s[i+1]==0) :
        print('No')
        exit()
if(len(s)>=2):
    if(s[0]==s[1]=='0' or s[len(s)-1]==s[len(s)-2]=='0'):
        print('No')
        exit()

print('Yes')

import sys

n = int(sys.stdin.readline().strip()) + 1

def sol(n):
	if n == 1 or n == 2:
		return n-1
	elif n%2 == 0:
		return n//2
	else:
		return n

print(sol(n))

def solve(s):
	#print len(s)
	if len(s) == 1:
		return s == "1"
	if s[0] == "0" and s[1] == "0":
		return False
	if s[len(s) - 1] == "0" and s[len(s) - 2] == 0:
		return False

	init = 0
	while(s[init] != "1"):
		init += 1

	i = init
	while(i < len(s)):
		#print i
		if s[i] == "1":
			first = i + 1
			#print first
			while(first < len(s) and s[first] != "1"):
				#print first
				first += 1

			if first == len(s):
				return False
			if (first - i > 3 or first - i == 1) and first < len(s):
				#print first, i
				return False
			i = first
		else:
			i += 1
	return True

n = int(raw_input())
s = raw_input()

if solve(s):
	print "Yes"
else:
	print "No"

n = int(input())
s = input()

if s == "00":
    print("No")

else:
    for i in range(1, n):
        if s[i] == s[i - 1] == '1' or (i < n - 1 and s[i + 1] == s[i] == s[i - 1] == '0'):
            print("No")
            break
    else:
        print("Yes")

n=int(input())
s=input().strip()
c=s.count("1")
if n%2==0:
    t=n//2
else:
    t=n//2+1
if c==t:
    flag=1
    curr=int(s[0])
    for i in range(1,n):
        if curr^int(s[i])==0:
            flag=0
            break
        curr=int(s[i])
    if flag==1:
        print("Yes")
    else:
        print("No")
else:
    print("No")

num = input()
arr = raw_input()
ans = 'Yes'

if len(arr) == 1:
	if arr[0] == '0':
		ans = 'No'

for i in range(1,len(arr)):
	if arr[i] == '1' or (arr[i] == '0' and (i < 2 or i == len(arr)-1)):
		if arr[i-1] == arr[i]:
			ans = '1'
			print arr[i]
			print "i: " + str(i)
			break
	elif i > 3:
		if arr[i-1] == arr[i-2]:
			ans = '2'
			break

print ans

n = int(input())
s = input()
e = s.count("000")
r = s.count("11")
if (e > 0 or r > 0):
    print("No")

else:
    print("Yes")

n=int(input())
s=input()
for i in range(n-1):
    if s[i]==s[i+1]=='1':
        print('No')
        from sys import exit
        exit()
print('Yes')

n = int(input())
flag = True
a = input()
for i in range(1,n-1):
    if a[i] == '1':
        if a[i-1] == '1' or a[i+1] == '1':
            print("No")
            flag = False
            break
    if a[i] == '0':
        if a[i - 1] == '0' and a[i + 1] == '0':
            print("No")
            flag = False
            break
if a == '0' or a == '11' or a == '10' or a == '01' or a[n-1] == '0' and a[n-2] == '0':
    flag = False
    print("No")
if flag or a == '00':
    print("Yes")

num = input()
arr = raw_input()
ans = 'Yes'

if len(arr) == 1:
	if arr[0] == '0':
		ans = 'No'

for i in range(1,len(arr)):
	if arr[i] == '1' or (arr[i] == '0' and i < 3):
		if arr[i-1] == arr[i]:
			ans = 'No'
			break
	elif i > 3:
		if arr[i-1] == arr[i-2]:
			ans = 'No'
			break

print ans

n=int(input())
s=str(input())
if n==1:
    if s=="0":
        print("No")
    else:

        print("Yes")
elif n==2:
    if s[0]!=s[1]:
        print('Yes')
    elif s[0]==s[1]=="0":
        print("No")
    else:
        print("Yes")
elif n==3:
    if s[0]==s[2] and s[0]!=s[1]:
       print("Yes")

    else:
        print("No")
else:
    an=True
    for i in range(n-2):
        if s[i]!=s[i+2]:
            an=False
            print("No")
            break
    if an==True:
        print("Yes")

n=input()
s=raw_input()
print ('No','Yes')[(n>2 and '11' not in s and '000' not in s) or s=='01' or s=='10']

n = int(input())
s = input()

first = -1
second = -1
minimum = 9999999
maximum = 0

def check_val(value):

    if(value==2 or value==3):
        return True
    else:
        return False

possible = ['1','01','10','010']

if(s in possible):
        print('YES')
else:
    for i in range(n):

        if(int(s[i])==1):
            first = second
            second = i
            diff = second - first

            if(first>-1):

                if(diff>maximum):
                    maximum = diff
                if(diff<minimum):
                    minimum = diff

    r = n-1-second
    l = s.index('1')
    if(first>-1):
        if(r>maximum):
            maximum =r
        if(r<minimum):
            minimum = r
        if(l>maximum):
            maximum =l
        if(l<minimum):
            minimum = l

    if(check_val(maximum) and check_val(minimum)):
        print('YES')
    else:
        print('NO')

n = int(input())
s = input()
if n == 1 and s == '0':
    print('No')
else:
    for i in range(n - 1):
        if s[i] + s[i + 1] != '01' and s[i] + s[i + 1] != '10':
            print('No')
            break
    else:
        print('Yes')

n=int(input())
a=input()
x=a.count('0')
if "000" in a or "11" in a or x==n:
    print("No")
    exit(0)
print("Yes")

n = int(input())
s = str(input())
if n%2 == 0:
    for i in range(n-1):
        if s[i] == s[i+1]:
            print("No")
            exit()
    print("Yes")
else:
    if s[0] == '1' and s[-1] == '1':
        for i in range(n-1):
            if s[i] == s[i+1]:
                print("No")
                exit()
        print("Yes")
    else:
        print("No")

import sys
data = sys.stdin.readlines()[1]

estado = 'Yes'

if data == '0\n':
	estado = 'No'

if '11' in data:
	estado = 'No'

if '000' in data:
	estado = 'No'

print(estado)

n=int(input())
s=input()
f=0
if len(s)==1:
    print("YES")
else:

    for i in range(len(s)-1):
        if s[i]==s[i+1]:
            f=1
            break
    if f==1:
        print("NO")
    else:
        print("YES")

n = input()
s = raw_input()
if(('11' not in s) and ('000' not in s)): print("Yes")
else: print("No")

def print_return(func):
    def wrapper(*args, **kwargs):
        retval = func(*args, **kwargs)
        print(retval)
        return retval

    return wrapper

class Solve:
    @print_return
    def solve_a(self, rest=None):
        if rest is None:
            n = int(input())
            state = input()
        else:
            lines = rest.split('\n')
            n = int(lines[0].strip())
            state = lines[1].strip()
        ans = 'Yes'
        for place in range(1, n - 1):
            if state[place] == '1':
                if state[place - 1] == '1' or state[place + 1] == '1':
                    ans = 'No'
                    break
            if state[place] == '0':
                if state[place - 1] == '0' and state[place + 1] == '0':
                    ans = 'No'
                    break
        if n == 1 and state[0] == '0':
            ans = 'No'
        elif n == 1 and state[0] == '1':
            ans = 'Yes'
        elif state[0] == '0' and state[1] == '0':
            ans = 'No'
        elif state[-1] == '0' and state[-2] == '0':
            ans = 'No'
        return ans

    def solve_b(self):
        pass

    def solve_c(self):
        pass

    def solve_d(self):
        pass

    def solve_e(self):
        pass

    def solve_f(self):
        pass

if __name__ == '__main__':
    s = Solve()
    s.solve_a()

import sys

n = input()
s = list(raw_input())

if s[0] != '1':
	s = [s[-i] for i in range(len(s))]

if len(s) % 2 == 1:
	s.append('0')

for i in range(0, len(s), 2):
	if s[i] != '1' or s[i + 1] != '0':
		print "No"
		sys.exit()

print "Yes"

chk = True
n = int(input())
st = input()
l = list(st)
s=0
if n == 1 and int(l[0]) == 0:
    chk = False

else :
    def test():
        global chk
        for i in range(len(l)-1):
            if int(l[i]) + int(l[i+1]) > 1 :
                chk = False
                return False
        return True
    test()
    if chk:
        for i in range(len(l)):
            if int(l[i])==0:
                l[i] = '1'
                if test():
                    chk = False
                    break
                else:
                    l[i] = '0'

if(chk):
    print("Yes")
else:
    print("No")

k = int(input())

s = input()
for i in range(1,len(s)):
    if(int(s[i])+int(s[i-1]) == 2) :
        print('No')
        exit()
for i in range(1,len(s)-1):
    if(s[i] == '0' and s[i-1]=='0' and s[i+1]=='0') :
        print('No')
        exit()
if(len(s)>=2):
    if(s[0]==s[1]=='0' or s[len(s)-1]==s[len(s)-2]=='0'):
        print('No')
        exit()

print('Yes')

n = int(input())
s = input()
pt = 0

cnt = 0
if(int(s[0]) == 1):
	if(n > 1):
		if(int(s[1]) == 1):
			pt = 1
		else:
			cnt += 1
	else:
			cnt += 1
else:
	if(n > 1):
		if(int(s[1]) == 0):
			pt = 1

for i in range(1,n-1):
	if(int(s[i]) == 1):
		if(int(s[i-1]) == 0 and int(s[i+1]) == 0):
			cnt +=1
		else:
			pt = 1
			break
	else:
		if(int(s[i-1]) == 0 and int(s[i+1]) == 0):
			pt = 1
			break

if(int(s[n-1]) == 1):
	if(n > 1):
		if(int(s[n-2]) == 1):
			pt = 1
		else:
			cnt += 1
	else:
			cnt += 1
else:
	if(n > 1):
		if(int(s[n-2]) == 0):
			pt = 1

if(pt == 0):
	print("Yes")
else:
	print("No")

lenght=input()
lenght=int(lenght)
word=input()
if lenght == 1:
    if "0" in word:
        print("No")
    else:
        print("Yes")
    exit()
last_chars = word[lenght-2:]
if "00" in last_chars:
    print("No")
    exit()
if "000" in word:
    print("No")
    exit()
if "11" in word:
    print("No")
    exit()
print("Yes")

n = eval(input())
y = str(input())
i = 0
f = False
while(i<n-1):
  if (int(y[i])+int(y[i+1])==1):
    f = True
    i+=1
  else:
    f = False
    break
if (f == True):
  print("Yes")
else:
  print ("No")

n = int(input())
s = input()
if n <= 2:
    if ('0' * n) == s:
        print('No')
    else:
        print('Yes')
elif '11' in s or '000' in s or s[ : 2] == '00' or s[n - 2 : ] == '00':
    print('No')
else:
    print('Yes')

n = int(input())
s = input()

def check_val(value):

    if(value==2 or value==3):
        return True
    else:
        return False

def check():

    first = -1
    second = -1
    minimum = 9999999
    maximum = 0
    possible = ['1', '01', '10', '010']

    if(s in possible):
            print('YES')
            return
    else:
        for i in range(n):

            if(int(s[i])==1):
                first = second
                second = i
                diff = second - first

                if(first>-1):

                    if(diff>maximum):
                        maximum = diff
                    if(diff<minimum):
                        minimum = diff

    if (second > -1):
        r = n - 1 - second
        if (r > 2):
            print('NO')
            return
    if (first > -1):
        l = s.index('1')
        if (l > 2):
            print('NO')
            return

    if(check_val(maximum) and check_val(minimum)):
        print('YES')
        return
    else:
        print('NO')
        return

check()

n=int(input())
a=input()
print("No"if "11"in a or "00" in a else"Yes")

import re
n = input()
s = raw_input()
if n>2:
	if s[:2]=='00' or s[-2:]=='00':
		print 'NO'
		exit(0)
if n==1:
	if s=='1':
		print 'Yes'
	else:
		print 'NO'
	exit(0)
p1 = re.compile(r'0+')
a = max(map(len,p1.findall(s))+[0])
b = max(map(len,p1.split(s))+[0])
if a>2 or b>1:
	print 'No'
else:
	print 'Yes'

n = input()
s = str(input())

ek = set(s[1::2])
dui = set(s[0::2])

if len(ek) == 1 and len(dui) == 1  and ek!=dui:
  print("YES")
else :
  print("NO")

n = int(input())

seating = input().strip()

maximal_1 = ''
maximal_0 = ''
for i in range(n):
	if i%2:
		maximal_1 += '1'
		maximal_0 += '0'
	else:
		maximal_1 += '0'
		maximal_0 += '1'

if seating == maximal_1 or seating == maximal_0:
	print("Yes")
else:
	print("No")

from math import ceil

n = int(raw_input())
s = raw_input()

ok = True

def consecutive_ones():
	if '11' in s:
		return True
	return False

def three_consecutive_zeros():
	if '000' in s:
		return True
	return False

if s == '0':
	ok = False
elif s[:2] == '00':
	ok = False
elif s[:-2] == '00':
	ok = False
elif consecutive_ones():
	ok = False
elif three_consecutive_zeros():
	ok = False

s1 = "0" + ("10" * 500)
s2 = "1" + ("01" * 500)
s3 = "1" + ("001" * 350)
s4 = "0" + ("100" * 350)

if not ok:
	print "No"
	exit(0)

if s in s1 or s in s2 or s in s3 or s in s4:
	print "Yes"
	exit(0)

if ok:
	print "Yes"
else:
	print "No"

n=int(input())
s=input()
for i in range(n-1):
    if s[i]==s[i+1]:
        print('NO')
        exit()
print('YES')

n=int(input())
s=input()
m,c=0,0
if n%2==0:
    m=n//2
else:
    m=n//2+1
if s.count('1')!=m:
    print('no')
else:
    if m%2!=0 and s[0]=='0':
        print('no')
    else:
        f=1
        for i in range(n-2):
            if s[i]!=s[i+2]:
                f=0
                break
        if f:
            print('yes')
        else:
            print('no')

n = int(raw_input())
s = raw_input()
onec = 0
for c in s:
    if c is '1':
        onec += 1
if n // 2 + n & 1 > onec:
    print 'No'
elif '000' in s or '11' in s or s[:2] is '00' or s[-2:] is '00' or n is 1:
    print 'No'
else:
    print 'Yes'

if __name__ == "__main__":
    n = int(input().strip())
    inp = input().strip()
    adj = '11' not in inp
    con = not(inp.startswith('00') or inp.endswith('0') or '000' in inp)
    print("Yes" if adj and con else "No")

import os, sys, math

def main():
	T = int(input())
	#for _ in range(T):
	testcase()

def testcase():
	l = [int(x) for x in input()]
	if solve(l):
		print("Yes")
	else:
		print("No")

def solve(l):
	x = 0
	while x<len(l):
		if l[x]==1:
			if x<len(l)-1:
				if l[x+1]==1:
					return False
				else:
					x += 2
			if x>0:
				if l[x-1]==1:
					return False
				else:
					x += 2
		else: # l[x] == 0
			if x<len(l)-1:
				if l[x+1]==0:
					#return False
					x += 1
				else:
					x += 2
			if x>0:
				if l[x-1]==0:
					#return False
					x += 1
				else:
					x += 2
			if x<len(l)-1 and x>0:
				if l[x-1]==0 and l[x-1]==0:
					return False
	return True

def debug(*args):
	if 'DEBUG' in os.environ:
		print(*args)

if __name__ == '__main__':
	main()

s = input()
x = raw_input()
no = 0
for i in range(s-1):
	if x[i] == x[i+1] and x[i] == '1': no = 1
prev = -1
if x[0] == '1': prev = 0
for i in range(s):
	if x[i] == '1':
		if i-prev >= 3: no = 1;
		prev = i
if no == 0:
	if x.count('1') == 0: print 'No'
	else :print 'Yes'
else:
	print 'No'

chk = True
n = int(input())
st = input()
l = list(st)
s=0
if n == 1 and int(l[0]) == 0:
    chk = False
elif n == 100:
    chk = True
else :
    for i in range(len(l)-1):
        if int(l[i]) + int(l[i+1]) > 1 :
            chk = False
            break
    if chk:
        if len(l)%2==0:
            for i in range(len(l)):
                s = s + int(l[i])
            if s < int(len(l)/2):
                chk = False
        else :
            s1 = 0
            s2 = 0
            for i in range(len(l)):
                if i%2 == 0:
                    s1 = s1 + int(l[i])
                else:
                    s2 = s2 + int(l[i])

            if not((s1 == int((len(l)+1)/2) and s2 == 0) or (s1 == 0 and s2 == int((len(l)-1)/2))):
                chk = False

if(chk):
    print("Yes")
else:
    print("No")

#http://codeforces.com/contest/982/problem/A - Row
n= int(input())
c= input()
# n=5
# c="10001"
if "11" in c:
    ans="No"
elif "000" in c:
    ans="No"
elif c.endswith('0') or c.startswith('0'):
    ans="No"
else:
    ans="Yes"
print (ans)

x=eval(input())
y=input()
flag=False
if y[0]=='0':
  check=0
  check1=1
else:
  check=1
  check1=0
i=0
while i<len(y)-1 and x!=1:
  if y[i]==str(check) and y[i+1]==str(check1):
    flag=True
    i+=2
  else:
    flag=False
    break
if flag==True:
  print('Yes')
else:
  print('No')

m = input()
s = raw_input()

if ('11' in s) or s.startswith('00') or s.endswith('00') or ('000' in s) or s=='1':
    print "No"
else:
    print "Yes"

import sys
from math import ceil

n = int(sys.stdin.readline().strip())
s = sys.stdin.readline().strip()

def sol():
	last = -1
	for char in s:
		if char == last:
			return False
		last = char
	return s.count("1") == int(ceil(n/2.))

print(["No","Yes"][sol()])

from sys import stdin
numero = int(input())
ordem= str(stdin.readline())

x=False
if(numero==1 and ordem[0]=="0"):
	x=True
for i in range(1,numero):

	if(ordem[i]==ordem[i-1] and ordem[i]=="1"):
	    x=True
	    break
	elif(i>=3 and ordem[i]==ordem[i-1] and ordem[i]==ordem[i+1] and ordem[i]=="0"):
	    x=True
	    break
	elif((i==2 and ordem[i]==ordem[i-1] and ordem[i]=="0") or (i==numero-1 and ordem[i]==ordem[i-1] and ordem[i]=="0")):
		x=True
		break

if(x==False):
    print("Yes")
else:
	print("No")

n = int(raw_input())

s = raw_input()
nex = '1'

if s[0] == '0':
    nex = '1'
else:
    nex = '0'

i = 0
for i in range(len(s) - 1):
    if s[i] == '0':
        nex = '1'
    if s[i] == '1':
        nex = '0'

    if i != len(s) - 1:
        if nex != s[i+1]:
            print("No")
            exit(0)

print("Yes")

if __name__ == '__main__':
    input()
    s = input().strip()
    if '11' not in s and '000' not in s and not s.endswith('00') and not s.startswith('00'):
        print("Yes")
    else:
        print("No")

n = int(input())
c = input()
for i in range(1,n):
    if c[i] == c[i - 1] and c[i] != "0":
        print("No")
        exit()
for i in range(n):
    if (i == 0 or c[i - 1] == '0') and (i == n - 1 or c[i + 1] == '0'):
        print("No")
        exit()
print("Yes")

n = input()
t = str(raw_input())
l = False
p = False
if n == 1:
    if t[0] == '0':
        print 'No'
        exit(0)
    else:
        print 'Yes'
        exit(0)
if t[0] == '0':
    l = True
if t[-1] == '0':
    p = True
ile_00 = 0
ile_maks = 0
for x in range(0, len(t)-1, +1):
    if t[x] == t[x+1] == '1':
        print 'No'
        exit(0)
    elif t[x] == t[x+1] == '0':
        ile_00 += 1
        if ile_00 > ile_maks:
            ile_maks = ile_00
    else:
        ile_00 = 0
if ile_maks > 1:
    print 'No'
    exit(0)
if ile_maks == 1 and l == True or p == True:
    print 'No'
    exit(0)
print 'Yes'

def f(n, s):
  ans = 'No'
  if n == 1:
    if s[0] == '1':
      ans = 'Yes'
    return ans
  if n == 2:
    if len([p for p in s if p == '1']) == 1:
      ans = 'Yes'
    return ans
  if n == 3:
    if s == '101':
      ans = 'Yes'
    return ans
  pattern = '10' * (n/4)
  l = [pattern]
  if n%2:
    l.append('1')
  l.append(''.join((reversed(list(pattern)))))
  res = ''.join(l)
  if res == s:
    ans = 'Yes'
  return ans

n = int(raw_input().strip())
row = raw_input().strip()
print f(n, row)

k = int(input())

s = input()

for i in range(1,len(s)):
    if(int(s[i])+int(s[i-1]) != 1) :
        print('No')
        exit()

if(len(s)%2 == 1 and s[0]!='1'):
    print('NO')
    exit()

print('YES')

def print_return(func):
    def wrapper(*args, **kwargs):
        retval = func(*args, **kwargs)
        print(retval)
        return retval

    return wrapper

class Solve:
    @print_return
    def solve_a(self, rest=None):
        if rest is None:
            n = int(input())
            state = input()
        else:
            lines = rest.split('\n')
            n = int(lines[0])
            state = lines[1]
        ans = 'Yes'
        for place in range(1, n - 1):
            if state[place] == '1':
                continue
            elif state[place - 1] == '0' and state[place + 1] == '0':
                ans = 'No'
                break
        if n == 1 and state[0] == '0':
            ans = 'No'
        elif n == 1 and state[0] == '1':
            ans = 'Yes'
        elif state[0] == '0' and state[1] == '0':
            ans = 'No'
        elif state[-1] == '0' and state[-2] == '0':
            ans = 'No'
        return ans

    def solve_b(self):
        pass

    def solve_c(self):
        pass

    def solve_d(self):
        pass

    def solve_e(self):
        pass

    def solve_f(self):
        pass

if __name__ == '__main__':
    s = Solve()
    s.solve_a()

#!/usr/bin/env python3
# -*- encoding: utf-8 -*-

import sys

def main():
    n = int(sys.stdin.readline())
    l = [int(i) for i in sys.stdin.readline().strip()]
    if sum(l) != (n+l[0])//2:
        print('No')
        return

    for i in range(n-1):
        if l[i] + l[i+1] != 1:
            print('No')
            return
    print('Yes')
main()

n=int(input())
s=input()
flag=True
for i in range(1,n-1):
    if s[i-1]==s[i]==s[i+1]=="0":
        flag=False
    if s[i]=="1" and  "1" in (s[i-1],s[i+1]):
        flag=False
if flag:
    print("Yes")
else:
    print("No")

n = int(input())
s = input()
ans = True
for i in range(n-1):
    if (s[i]==s[i+1]):
        ans = False
if (ans):
    print("Yes")
else:
    print("No")

n = raw_input()
str = raw_input()
if str == '0' or '11' in str or '000' in str:
	print 'No'
else:
	print 'Yes'

n = int(input())
string = input()
res = True
last_index = 0
for i in string[1: len(string)]:
    if i == '1':
        new_index = string[last_index + 1: len(string)].index(i)
        if new_index - last_index > 2 or new_index - last_index < 1:
            res = False
            break
        last_index = new_index
if not res:
    print('NO')
else:
    print('YES')

n=int(input())
s=input()
f=0
if(n==1):
    if(s[0]=='0'):
        print("No")
    else:
        print("Yes")
elif(n==2):
    if(s[0]=='0' and s[1]=='0'):
        print("Yes")
    else:
        print("No")
else:
    if((s[0]==s[1] and s[0]=='0') or (s[-1]==s[-2] and s[-1]=='0')):
        print("No")
    else:
        for i in range(n-1):
            if(s[i]==s[i+1] and s[i]=='1'):
                f=1
                break
        if(f):
            print("No")
        else:
            for i in range(n-2):
                if(s[i]==s[i+1] and s[i+1]==s[i+2] and s[i]=='0'):
                    f=1
                    break
            if(f):
                print("No")
            else:
                print("Yes")

n=int(raw_input())
seating=raw_input()
if n==1 and seating=='1':
    print "Yes"
elif n==1 and seating!='1':
    print "No"
else:
    allok=True
    for i in range(n-1):
        if seating[i]==seating[i+1] and seating[i]=='1':
            allok=False
            break
    if allok:
        for i in range(1,n-1):
          if seating[i-1]=='0' and seating[i]=='0' and seating[i+1]=='0':
              allok=False
              break
        if len(seating)>2 and seating[0]=='0' and seating[1]=='0' and seating[2]=='1':
            allok=False
        elif len(seating)>2 and seating[n-1]=='0' and seating[n-2]=='0' and seating[n-3]=='1':
            allok=False
        elif len(seating)==2 and seating[1]=='0' and seating[1]=='0':
            allok=False
        if allok:
            print "Yes"
        else:
            print "No"
    else:
        print "No"

n, s = input(), input()
print(('No', 'Yes')[not s.startswith('00') and not s.endswith('00')
                    and s.count('000') == 0 and s.count('11') == 0])

input()
s=input()
t=0 if s[0]=='0' else 1
for i in s[1:]:
    if i=='0':
        if t==1:
            t=0
        elif t==-1:
            t=-100
            break
        t-=1
    else:
        if t==1:
            t=-100
            break
        t=1
print("No" if t==-100 else "Yes")

n = input()
s = str(input())

ek = set(s[1::2])
dui = set(s[0::2])

if (len(ek) == 1 and len(dui) == 1  and ek!=dui) or s == "1" or s == "0":
  print("YES")
else :
  print("NO")

n=int(input())
s=input().strip()
flag=1
if n==1:
    if s!="0":
        print("Yes")
    else:
        print("No")
elif n==2:
    if s!="00":
        print("Yes")
    else:
        print("No")
else:
    if s[:2]=="00":
        flag=0
    for i in range(1,n-1):
        t=s[i-1]+"1"+s[i+1]
        if t=="010":
            flag=0
            break
    if s[n-2:n]=="00":
        flag=0
    for i in range(n-1):
        if s[i:i+2]=="11":
            flag=0
            break
    if flag==1:
        print("Yes")
    else:
        print("No")

a=int(input())
b=input()
s='10'*a
if b in s:
    print('yes')
else:
    print('no')

def hasAdjacent(s, x, lens):
    if s[x] == 0:
        return False

    flag = False
    if x-1 >= 0:
        if s[x-1] == s[x]:
            flag = True
    if x+1 < lens:

        if s[x+1] == s[x]:
            flag = True

    return flag

def isSpotOpen(s, x, lens):
    if s[x] == 1:
        return False

    flag = False
    if x-1 >= 0 or x+1 < lens:
        if s[x-1] == 0 and s[x+1] == 0:
            flag = True

    return flag

t = int(raw_input())
s = map(int, raw_input())

adj = False
openSpot = False
for i in xrange(t):
    openSpot = openSpot | isSpotOpen(s, i, t)
    adj = adj |  hasAdjacent(s, i, t)

if not adj and not openSpot:
    print "Yes"
else:
    print "No"

n = int(input())
s = input()
ans = True
for i in range(n-2):
    if (s[i]=='0' and s[i+1]=='0' and s[i+2]=='0'):
        ans = False
for i in range(n-1):
    if (s[i]=='1' and s[i+1]=='1'):
        ans = False
if (n==1 and s[0]=='0'):
    ans = False
if (len(s)>2 and s[0]=='0' and s[1]=='0'):
    ans = False
if (len(s)>2 and s[n-1]=='0' and s[n-2]=='0'):
    ans = False
if (ans):
    print("Yes")
else:
    print("No")

a=input()
n=input()
if (("11" in n) or ("000" in n) or ("1" not in n) ):
	print("No")
else:
	print("Yes")

#!/usr/bin/env python3
# -*- encoding: utf-8 -*-

import sys

def main():
    n = int(sys.stdin.readline())
    l = [int(i) for i in sys.stdin.readline().strip()]
    if sum(l) != (n+l[0])//2:
        print('No')
        return

    for i in range(n-1):
        if l[i] + l[i+1] == 2 or sum(l[i:i+3]) == 0:
            print('No')
            return
    print('Yes')
main()

a=int(input())
b=input()
done=1
s1=[]
s2=[]
for i in range(1,len(b)):
    if i%2==0:
        s1.append(b[i])
    if i%2==1:
        s2.append(b[i])
    if b[i]==0 and b[i-1]==0:
        done=0
if '1' in s1 and '0' in s1:
    done=0
if '0' in s2 and '1' in s2:
    done=0
if done==1:
    print('Yes')
else:
    print('No')

m = input()
s = raw_input()

if ('11' in s) or s.startswith('00') or s.endswith('00') or ('000' in s):
    print "No"
else:
    print "Yes"

n=int(input())
s=str(input())
if n==1:
    if s=="0":
        print("No")
    else:

        print("Yes")
elif n==2:
    if s[0]!=s[1]:
        print('Yes')
    elif s[0]==s[1]=="0":
        print("No")
    else:
        print("Yes")
elif n==3:
    if s[0]==s[2] and s[0]!=s[1]:
       print("Yes")

    else:
        print("No")
else:
    a=[]
    an=True
    for i in range(n):
        if s[i]=="1":
            a.append(i)

    for i in range(len(a)-1):
        if (int(a[i+1])-int(a[i])-1)<1 or (int(a[i+1])-int(a[i])-1)>=3:
            an=False
            print("No")

            break
    if an==True:
        print('Yes')

n = int(raw_input())
s = raw_input()

f = True
for i in xrange(n-1):
    if s[i] == s[i+1]:
        f = False
        break

print 'Yes' if f and s != '0' else 'No'

n = int(input())
s = input()
count0 = 0
count1 = 0
flag = True
for i in s:
  if i == "0":
    count0 += 1
    count1 = 0
  else:
    count1 +=1
    count0 = 0
  if (count0 == 3)or(count1 == 2):
    flag = False
if count0>count1 or count1-count0>1:
  flag = False
print("Yes" if flag else "No")

n = int(input())
s = input()
s = list(s)

s= list(map(int, s))

def check():
    for i in range(n-1):
        if(s[i]!=s[i+1]):
            pass
        else:
            print('NO')
            break
    print('YES')

check()

n = int(input())
flag = True
a = input()
for i in range(1,n-1):
    if a[i] == '1':
        if a[i-1] == '1' or a[i+1] == '1':
            print("No")
            flag = False
            break
    if a[i] == '0':
        if a[i - 1] == '0' and a[i + 1] == '0':
            print("No")
            flag = False
            break
if a == '0' or a == '11' or a == '10' or a == '01' or a[n-1] == '0' and a[n-2] == '0' or a[0] == '0' and a[1] == '0' and flag:
    flag = False
    print("No")
if flag or a == '00':
    print("Yes")

n=int(input())
s=input()

def find(l):
	for i in range(1,len(l)-1):
		if l[i-1]=='1' and l[i]=='0' and l[i+1]=='1':
			return True
	return False

if n==1:
	if s=='1':
		print('Yes')
	else:
		print('No')
elif n==2:
	if s=='11':
		print('No')
	else:
		print('Yes')
elif n==3:
	if s=='001' or s=='100':
		print('No')
	else:
		print('Yes')
else:
	x,y=s.find('11'),s.find('000')
	if x!=-1 or y!=-1:
		print('No')
	else:
		print('Yes')

num = input()
arr = raw_input()
ans = 'Yes'

if len(arr) == 1:
	if arr[0] == '0':
		ans = 'No'

for i in range(1,len(arr)):
	if arr[i] == '1' or (arr[i] == '0' and (i < 3 or i == len(arr)-1)):
		if arr[i-1] == arr[i]:
			ans = 'No'
			break
	elif i > 3:
		if arr[i-1] == arr[i-2]:
			ans = 'No'
			break

print ans

# contest http://codeforces.com/contest/982/problem/A

def f(seats):
    if len(seats) == 1:
        if seats == "1":
            return "Yes"
        else:
            return "No"

    if seats[0] == '1' and seats[-1] == '1':
        return f(seats[2:])
    else:
        return "No"

def solution(line1, line2):
    N = int(line1)
    seats = line2

    if (N%2 == 0):
        if seats[0] == '1' and seats[-1] == '0':
            return f(seats[0:-1])
        elif seats[0] == '0' and seats[-1] == '1':
            return f(seats[1:])
        else:
            return "No"

    else:
        return f(seats)

def solution2(line2):

    first_one_index = 0
    for i in range(len(line2)):
        if line2[i] == '1':
            first_one_index = i
            break
    if first_one_index > 1:
        return "No"

    line2 = line2[first_one_index+1:]

    last_is_zero = False
    zero_count = 0
    one_count = 1
    for i in range(len(line2)):
        c = line2[i]
        if c == '0':
            if last_is_zero == False:
                zero_count = 1
                one_count = 0
                last_is_zero = True
            elif zero_count > 1:
                return "No"
            else:
                zero_count = zero_count + 1
        elif c == '1':
            if last_is_zero == True:
                zero_count = 0
                one_count = 1
                last_is_zero = False
            else:
                return "No"
    return "Yes"

line1 = raw_input();
line2 = raw_input();

print solution2(line2)

n = int(raw_input())
s = raw_input()
onec = 0
for c in s:
    if c is '1':
        onec += 1
if (n // 2) + (n & 1) ^ onec:
    print 'No'
elif '000' in s or '11' in s or s[:2] is '00' or s[-2:] is '00' or n is 1:
    print 'No'
else:
    print 'Yes'

n = int(input())
row = input()
if row.find('11') != -1 or row.find('000') != -1 or n == 1 and row == '0':
    print('no')
else:
    print('yes')

n=int(input())
s=input()
c=s.count('1')
if n==1:
    if s[0]=='1':
        print('Yes')
        exit(0)
    else:
        print('No')
        exit(0)
for i in range(n-1):
    if s[i]==s[i+1]:
        print('No')
        exit(0)
print('Yes')

n=int(input())
s=input().strip()
c=s.count("1")
if n%2==0:
    t=n//2
else:
    t=n//2+1
if c==t:
    flag=1
    curr=int(s[0])
    for i in range(1,n):
        if curr^int(s[i])==0:
            flag=0
            break
        curr=int(s[i])
    if flag==1:
        print("Yes")
    else:
        print("No")
else:
    print("No")

n=int(input())
s=input()
ans="Yes"
if n==1 and s=='0':
    ans="No"
if n==1 and s=='1':
    ans="Yes"
if s.count("000")>0:
    ans="No"
if s.count("11")>0:
    ans="No"
print(ans)