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$).


-----Input-----

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-----

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).


-----Examples-----
Input
3
101

Output
Yes

Input
4
1011

Output
No

Input
5
10001

Output
No



-----Note-----

In 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.

Difficulty: EASY
Tags: Complete search

Constructive algorithms
Skill types: Complete search

Starter code:

Solutions:
n = int(input())
s = '0' + input() + '0'
if '000' in s or '11' in s:
	print('no')
else:
	print('yes')


def check(n, s):
	for i in range(1, n):
		if s[i] == s[i - 1] and s[i] == 1:
			return False
	return True
n = int(input())
st = input()
s = []
for i in range(n):
	s.append(int(st[i]))
result = check(n, s)
for i in range(n):
	if s[i] == 0:
		s[i] = 1
		if result:
			result = not check(n, s)
		s[i] = 0
if result:
	print('Yes')
else:
	print('No')


a = int(input())
b = input()
done = 1
s1 = []
s2 = []
for i in range(1, len(b) - 1):
	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' and (b[i + 1] == '0'):
		done = 0
	if b[i] == '1' and b[i - 1] == '1':
		done = 0
if len(b) > 1:
	if b[len(b) - 1] == '0' and b[len(b) - 2] == '0':
		done = 0
	if b[0] == '0' and b[1] == '0':
		done = 0
	if b[len(b) - 1] == '1' and b[len(b) - 2] == '1':
		done = 0
	if b[0] == '0' and b[1] == '0':
		done = 0
if len(b) == 1:
	if b[0] == '0':
		done = 0
if len(b) == 2:
	if b == '00':
		done = 0
if done == 1:
	print('Yes')
else:
	print('No')


n = int(input())
s = input()
if s.count('11') == 0 and s.count('000') == 0 and (s[:2] != '00') and (s[-2:] != '00') and (s != '0'):
	print('YES')
else:
	print('NO')


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


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


n = int(input())
s = input()
zeros = 0
has_neighbours = False
prev = '-'
i = 0
while i < n:
	x = s[i]
	if prev == '1' and x == '1':
		has_neighbours = True
		break
	if x == '0':
		zeros += 1
	else:
		zeros = 0
	if zeros >= 3 or (zeros == 2 and i == 1) or (zeros == 2 and i == n - 1) or (zeros == 1 and n == 1):
		has_neighbours = True
		break
	prev = x
	i += 1
print('No' if has_neighbours else 'Yes')


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


def a():
	n = int(input())
	s = input()
	if n == 1:
		if s[0] == '0':
			print('No')
		else:
			print('Yes')
		return
	for i in range(1, n):
		if s[i] == '1' and s[i - 1] == '1':
			print('No')
			return
	if n >= 2:
		if s[0] == '0' and s[1] == '0':
			print('No')
			return
		if s[n - 1] == '0' and s[n - 2] == '0':
			print('No')
			return
	for i in range(1, n - 1):
		if s[i - 1] == '0' and s[i] == '0' and (s[i + 1] == '0'):
			print('No')
			return
	print('Yes')
a()


import re
input()
if re.search('000|11', '0' + input() + '0'):
	print('No')
else:
	print('Yes')


import math
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] == s[1]:
		print('No')
	else:
		print('Yes')
elif s[0] == s[1] or s[-1] == s[-2]:
	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]:
				f = 1
				break
		if f:
			print('No')
		else:
			print('Yes')


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


n = int(input())
s = input()
from sys import exit
if n > 1:
	if s[0] == '0' and s[1] == '0':
		print('No')
		exit()
else:
	if s[0] == '0':
		print('No')
	else:
		print('Yes')
	exit()
k = 0
for (i, x) in enumerate(s):
	if x == '1':
		if k == 0 and i > 0:
			print('No')
			exit()
		else:
			k = 0
	elif k == 2:
		print('No')
		exit()
	else:
		k += 1
if k == 2:
	print('No')
else:
	print('Yes')


m = input()
x = input()
k = 0
if m == '1':
	if x[0] == '1':
		print('Yes')
	else:
		print('No')
else:
	for i in range(1, len(x) - 1):
		if x[i] == '0' and x[i - 1] == '0' and (x[i + 1] == '0'):
			k = 1
		if x[i] == '1' and x[i + 1] == '1':
			k = 1
	if x[0] == '0' and x[1] == '0':
		k = 1
	if x[0] == '1' and x[1] == '1':
		k = 1
	if x[len(x) - 2] == '0' and x[len(x) - 1] == '0':
		k = 1
	if k == 1:
		print('No')
	else:
		print('Yes')


n = int(input())
a = input()
flag = 1
ct0 = 0
ct1 = 0
for i in range(n):
	if a[i] == '1':
		ct1 += 1
		ct0 = 0
	else:
		ct0 += 1
		ct1 = 0
	if ct0 > 2 or ct1 > 1:
		flag = 0
		break
if n != 1:
	if a[0] == '0' and a[1] == '0':
		flag = 0
	if a[-1] == '0' and a[-2] == '0':
		flag = 0
if n == 1 and a[i] == '0':
	flag = 0
if flag == 0:
	print('NO')
else:
	print('YES')


n = int(input())
s = input()
f = 0
if len(s) == 1:
	if s[0] == '0':
		print('NO')
	else:
		print('YES')
else:
	s1 = ''
	s1 = '0' + s + '0'
	if '11' in s1:
		print('NO')
	elif '000' in s1:
		print('NO')
	else:
		print('yeS')


n = int(input())
s = input()
if s.find('000') != -1 or s.find('11') != -1 or s.find('001') == 0 or (s[::-1].find('001') == 0) or (s.find('1') == -1):
	print('No')
else:
	print('Yes')


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().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')


def isFree(s, pos):
	if s[pos] == '1':
		return False
	if pos != 0:
		if s[pos - 1] == '1':
			return False
	if pos != len(s) - 1:
		if s[pos + 1] == '1':
			return False
	return True

def rassadka(s, pos):
	if s[pos] == '0':
		return False
	if pos != 0:
		if s[pos - 1] == '1':
			return True
	if pos != len(s) - 1:
		if s[pos + 1] == '1':
			return True
	return False
n = int(input())
s = input()
lst1 = list()
lst2 = list()
for i in range(len(s)):
	lst1.append(isFree(s, i))
	lst2.append(rassadka(s, i))
if lst1 == lst2:
	print('Yes')
else:
	print('No')


import math
n = int(input())
s = str(input())
flag1 = 0
if n >= 2:
	if s[0] == '0' and s[1] == '0':
		flag1 = 1
flag = 0
prev = s[0]
cons = 0
for i in range(1, n):
	if s[i] == '1':
		cons = 0
		if prev == '1':
			flag = 1
			break
		prev = '1'
	else:
		cons += 1
		if cons >= 3:
			flag = 1
			break
		prev = '0'
if n == 3:
	if s[1] == '1' and s[0] == '0' and (s[2] == '0'):
		print('Yes')
	elif s[0] == '1' and s[1] == '0' and (s[2] == '1'):
		print('Yes')
	else:
		print('No')
elif n == 2:
	if s[0] == '0' and s[1] == '1' or (s[0] == '1' and s[1] == '0'):
		print('Yes')
	else:
		print('No')
elif n == 1:
	if s[0] == '1':
		print('Yes')
	else:
		print('No')
elif flag == 0 and cons < 2 and (flag1 == 0):
	print('Yes')
else:
	print('No')


import re
n = int(input())
s = input()
pattern = '^((0)?1(01|001)*(0)?)$'
if re.match(pattern, s):
	print('Yes')
else:
	print('No')


import math as mt
import itertools as it
import functools as ft
import random as rnd
stdin = lambda type_='int', sep=' ': list(map(eval(type_), input().split(sep)))
joint = lambda sep=' ', *args: sep.join((str(i) if type(i) != list else sep.join(map(str, i)) for i in args))
n = int(input())
s = input()
if any((s[i] == s[i - 1] and s[i] == '1' for i in range(1, len(s)))):
	print('No')
else:
	ex = False
	for i in range(len(s)):
		if s[i] == '0' and (i == 0 or s[i - 1] == '0') and (i == len(s) - 1 or s[i + 1] == '0'):
			ex = True
			break
	print('Yes' if not ex else 'No')


from sys import stdin

def solve(tc):
	n = int(stdin.readline().strip())
	s = stdin.readline().strip()
	res = True
	if n == 1 and s[0] == '0':
		res = False
	for i in range(1, n):
		if s[i] == '1' and s[i - 1] == '1':
			res = False
		if s[i] == '0' and s[i - 1] == '0':
			if i == 1:
				res = False
			elif i < n - 1:
				if s[i + 1] == '0':
					res = False
			else:
				res = False
	print('Yes' if res else 'No')
	pass
LOCAL_TEST = not __debug__
if LOCAL_TEST:
	infile = __file__.split('.')[0] + '-test.in'
	stdin = open(infile, 'r')
tcs = int(stdin.readline().strip()) if LOCAL_TEST else 1
tc = 1
while tc <= tcs:
	solve(tc)
	tc += 1


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


(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)])


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


n = int(input())
a = list(map(int, input()))
if len(a) == 1:
	print('Yes' if a[0] == 1 else 'No')
	exit()
if a[0] == a[1] == 0 or a[-1] == a[-2] == 0:
	print('No')
	exit()
i = 0
while i < n:
	cnt = 0
	while i < n and a[i] == 0:
		cnt += 1
		if cnt > 2:
			print('No')
			exit()
		i += 1
	if i != 0 and cnt < 1:
		print('No')
		exit()
	i += 1
print('Yes')


n = int(input())
s = list(input())
ans = 'Yes'
for i in range(n - 1):
	if ''.join(s[i:i + 2]) == '11':
		ans = 'No'
		break
for i in range(n):
	if s[i] == '0' and (i == 0 or s[i - 1] == '0') and (i == n - 1 or s[i + 1] == '0'):
		ans = 'No'
		break
print(ans)


n = int(input())
a = list(map(int, list(input())))
m = 'Yes'
if n == 1:
	if a == [0]:
		m = 'No'
else:
	for i in range(n - 1):
		if a[i] + a[i + 1] == 2:
			m = 'No'
		if i < n - 2:
			if sum(a[i:i + 3]) == 0:
				m = 'No'
	if a[0] + a[1] == 0 or a[-1] + a[-2] == 0:
		m = 'No'
print(m)


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


q = int(input())
a = input()
t = 1
if q >= 3:
	if a[1] == '1' and a[0] == '1':
		t = 0
	if a[1] == '0' and a[0] == '0':
		t = 0
	if a[q - 1] == '0' and a[q - 2] == '0':
		t = 0
	for i in range(2, q):
		if a[i] == '1' and a[i - 1] == '1':
			t = 0
			break
		if a[i] == '0' and a[i - 1] == '0' and (a[i - 2] == '0'):
			t = 0
			break
elif a == '0' or a == '00' or a == '11':
	t = 0
if t == 0:
	print('No')
else:
	print('Yes')


n = int(input())
s = input()
e = s.count('11')
r = s.count('000')
if s == '0':
	print('No')
	exit()
if len(s) >= 2:
	q1 = s[0] + s[1]
	q2 = s[-2] + s[-1]
	if q1 == '00' or q2 == '00':
		print('No')
		exit()
if r > 0 or e > 0:
	print('No')
	exit()
print('Yes')


n = int(input())
c = 1
for i in input():
	if i == '0':
		c += 1
	else:
		if c == 0:
			print('NO')
			quit()
		c = 0
	if c > 2:
		print('NO')
		quit()
if c == 2:
	print('NO')
else:
	print('YES')


n = int(input())
s = input()
c = 1
if '11' in s or '000' in s or (n == 1 and s == '0') or (s[0] == '0' and s[1] == '0') or (s[n - 2] == '0' and s[n - 1] == '0'):
	c = 0
if c == 1:
	print('Yes')
else:
	print('No')


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())
a = '0' + input() + '0'
if '000' in a or '11' in a:
	print('No')
else:
	print('Yes')


n = int(input())
s = input()
t1 = '01' * (n // 2)
t2 = '10' * (n // 2)
if n % 2 != 0:
	t1 += '0'
	t2 += '1'
if n == 1:
	if s == '1':
		print('Yes')
	else:
		print('No')
else:
	f = 1
	for i in range(n):
		if s[i] == '1':
			if i - 1 >= 0 and s[i - 1] == '1':
				f = 0
				break
			if i + 1 < n and s[i + 1] == '1':
				f = 0
				break
		if s[i] == '0':
			(k1, k2) = (1, 1)
			if i - 1 >= 0 and s[i - 1] == '1':
				k1 = 0
			if i + 1 < n and s[i + 1] == '1':
				k2 = 0
			if k1 == 1 and k2 == 1:
				f = 0
				break
	if f == 1:
		print('Yes')
	else:
		print('No')


n = int(input())
s = input()
print('Yes' if s == '1' and n == 1 or (n > 1 and s.count('000') == 0 and (s[0] != s[1]) and (s[-1] != s[-2]) and (s.count('11') == 0)) else 'No')


n = int(input())
x = input()
x = [int(i) for i in x]
zero = 0
one = 0
flag = 1
if n > 1:
	for i in x:
		if i == 1:
			zero = 0
			one += 1
		if i == 0:
			one = 0
			zero += 1
		if one > 1:
			flag = 0
			break
		if zero > 2:
			flag = 0
			break
	if zero == 2:
		flag = 0
	if flag != 0 and x[0] == 0:
		if x[1] == 0:
			flag = 0
	print('Yes' if flag == 1 else 'No')
elif x[0] == 0:
	print('No')
else:
	print('Yes')


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[:2] == '00' or s[-2:] == '00':
	flag = False
for i in range(1, n):
	if s[i - 1] == s[i] == '1':
		flag = False
if s == '0':
	flag = False
if flag:
	print('Yes')
else:
	print('No')


n = int(input(''))
data = input('')
judge = 0
if n == 1:
	if data == '1':
		print('Yes')
	else:
		print('No')
else:
	for i in range(0, n - 1):
		if data[i] == '1':
			if data[i + 1] == '1':
				break
			else:
				judge += 1
		else:
			judge += 1
	for i in range(0, n):
		if i == 0:
			if data[i] == '0' and data[i + 1] == '0':
				break
			else:
				judge += 1
		elif i == n - 1:
			if data[i] == '0' and data[i - 1] == '0':
				break
			else:
				judge += 1
		elif i > 0 and i < n - 1:
			if data[i] == '0' and data[i - 1] == '0' and (data[i + 1] == '0'):
				break
			else:
				judge += 1
	if judge == 2 * n - 1:
		print('Yes')
	else:
		print('No')


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


n = int(input())
s = input()
result = True
if n == 1 and s == '0':
	result = False
if '11' in s or '000' in s:
	result = False
if s[0:2] == '00' or s[n - 2:n] == '00':
	result = False
if result:
	print('Yes')
else:
	print('No')


input()
s = input()
if s == '0':
	print('No')
elif s.startswith('00') or s.endswith('00'):
	print('No')
else:
	print('No' if s.find('11') != -1 or s.find('000') != -1 else 'Yes')


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()


n = int(input())
seq = list(input())
yes = True
for i in range(len(seq)):
	if seq[i] == '1':
		if i != 0 and seq[i - 1] == '1' or (i != len(seq) - 1 and seq[i + 1] == '1'):
			yes = False
			break
		if i != 0 and seq[i - 1] == '0':
			seq[i - 1] = 'x'
		if i != len(seq) - 1 and seq[i + 1] == '0':
			seq[i + 1] = 'x'
if yes and '0' in seq:
	yes = False
print('YES' if yes else 'NO')


inp = input()
data = {'tokens': None, 'i': 0}
data['tokens'] = inp.split()

def get_str():
	if data['i'] == len(data['tokens']):
		data['tokens'] = input().split()
		data['i'] = 0
	token = data['tokens'][data['i']]
	data['i'] += 1
	return token

def get_int():
	return int(get_str())
n = get_int()
seats = get_str()
seats_mod = '0' + seats + '0'
if '000' in seats_mod or '11' in seats_mod:
	print('No')
else:
	print('Yes')


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


input()
s = input()
if len(s) > 1:
	f = '11' not in s and (not ('000' in s or s[:2] == '00' or s[-2:] == '00'))
else:
	f = s == '1'
print('Yes' if f else 'No')


n = int(input())
s = input()
a = []
s = '10' + s + '01'
for i in range(0, n + 4):
	if s[i] == '1':
		a.append(i)
k = 0
for i in range(1, len(a)):
	if a[i] - a[i - 1] <= 1 or a[i] - a[i - 1] > 3:
		k = 1
if k == 1:
	print('NO')
else:
	print('YES')


n = int(input())
s = input()
if len(s) == 1:
	print(['No', 'Yes'][s == '1'])
else:
	print(['No', 'Yes']['11' not in s and '000' not in s and (s[:2] != '00') and (s[-2:] != '00')])


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


def f(n, s):
	fl = True
	for i in range(0, n - 1):
		if s[i] == '1' and s[i + 1] == '1':
			fl = False
	return fl
n = int(input())
s = input()
flag = f(n, s)
for i in range(n):
	if s[i] == '0':
		s = list(s)
		s[i] = '1'
		s = ''.join(s)
		if f(n, s):
			flag = False
		s = list(s)
		s[i] = '0'
		s = ''.join(s)
if flag:
	print('Yes')
else:
	print('No')


n = int(input())
s = '0' + input() + '0'
res = 1
for i in range(1, n):
	if s[i] == '1' and s[i + 1] == '1':
		res = 0
for i in range(1, n + 1):
	if s[i] == '1':
		continue
	if s[i - 1] == '0' and s[i + 1] == '0':
		res = 0
print('Yes' if res else 'No')


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


from sys import exit
N = int(input())
ls = input()
if N == 1:
	if ls[0] == '0':
		print('No')
	else:
		print('Yes')
	exit()
if '11' not in ls:
	if '000' in ls:
		print('No')
	elif ls[0] == '0' and ls[1] == '0' or (ls[-1] == '0' and ls[-2] == '0'):
		print('No')
	else:
		print('Yes')
else:
	print('No')


def row(n, cadeiras):
	cadeirasOcupadasAdjacentes = 0
	cadeirasVagasAdjacentes = 0
	if cadeiras == '1':
		return 'Yes'
	if cadeiras == '0':
		return 'No'
	i = 0
	while i < n:
		if cadeiras[i] == '1':
			cadeirasVagasAdjacentes = 0
			cadeirasOcupadasAdjacentes += 1
			if cadeirasOcupadasAdjacentes == 2:
				return 'No'
		else:
			cadeirasOcupadasAdjacentes = 0
			cadeirasVagasAdjacentes += 1
			if cadeirasVagasAdjacentes == 3 or (cadeirasVagasAdjacentes == 2 and (i == 1 or i == n - 1)):
				return 'No'
		i += 1
	return 'Yes'
n = int(input())
cadeiras = input()
result = row(n, cadeiras)
print(result)


a = int(input())
n = input()
if '11' in n or '000' in n or '1' not in n or (a > 1 and (n[0] + n[1] == '00' or n[-1] + n[-2] == '00')):
	print('No')
else:
	print('Yes')


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()
		ans = 'Yes'

		def neighs(idx):
			ns = []

			def get_idxes(idx):
				return (idx - 1, idx + 1)
			for i in get_idxes(idx):
				if i > -1 and i < n:
					ns.append(row[i])
			return ns
		for idx in range(n):
			if row[idx] == '0' and all((x == '0' for x in neighs(idx))):
				ans = 'No'
				break
			elif row[idx] == '1' and any((x == '1' for x in neighs(idx))):
				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
Solve.solve_a()


input()
s = input()
if len(s) == 1:
	if s == '1':
		print('Yes')
	else:
		print('No')
elif '11' in s or '000' in s or s[:2] == '00' or (s[-2:] == '00'):
	print('No')
else:
	print('Yes')


n = int(input())
s = input().strip()
ans = True
for i in range(1, n):
	if s[i - 1] == '1' and s[i] == '1':
		ans = False
for i in range(n):
	if (i == 0 or s[i - 1] == '0') and (i == n - 1 or s[i + 1] == '0') and (s[i] == '0'):
		ans = False
print('Yes' if ans else 'No')


import re
input()
print('No' if re.fullmatch('0|00.*|.*000.*|.*00|.*11.*', input()) else 'Yes')


n = int(input())
s = input()
if s == '0':
	print('NO')
	exit()
if s == '1':
	print('YES')
	exit()
for i in range(1, n):
	if s[i] == '1' and s[i - 1] == '1':
		print('NO')
		exit()
if s == '11' or s == '00':
	print('NO')
	exit()
if s == '01' or s == '10':
	print('YES')
	exit()
if s[0] == '0' and s[1] == '0':
	print('NO')
	exit()
if s[-1] == '0' and s[-2] == '0':
	print('NO')
	exit()
for i in range(2, n):
	if s[i] == '0' and s[i - 1] == '0' and (s[i - 2] == '0'):
		print('NO')
		exit()
print('YES')


def func(seating):
	N = len(seating)
	if N == 1:
		if seating[0] == '1':
			return 'Yes'
		else:
			return 'No'
	for i in range(1, N - 1):
		if seating[i] == '1':
			if seating[i - 1] == '1' or seating[i + 1] == '1':
				return 'No'
	for i in range(1, N - 1):
		if seating[i] == '0':
			if seating[i - 1] == '0' and seating[i + 1] == '0':
				return 'No'
	if seating[0] == '1':
		if seating[1] == '1':
			return 'No'
	elif seating[1] == '0':
		return 'No'
	if len(seating) >= 2:
		if seating[len(seating) - 1] == '1':
			if seating[len(seating) - 2] == '1':
				return 'No'
		elif seating[len(seating) - 2] == '0':
			return 'No'
	return 'Yes'
N = int(input())
seating = input()
print(func(seating))


n = int(input())
s = input()
cnt = 0
if n == 1:
	if s == '1':
		print('YES')
	else:
		print('NO')
	exit()
if s[0] == '0':
	cnt += 1
for i in range(1, n):
	if s[i] == s[i - 1] and s[i] == '1':
		print('NO')
		exit()
	if s[i] == '0':
		cnt += 1
	if cnt == 3:
		print('NO')
		exit()
	if s[i] == '1':
		cnt = 0
if s[0] == '0' and s[1] == '0' or (s[-1] == '0' and s[-2] == '0'):
	print('NO')
else:
	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')


n = int(input())
c = input()
p = 0
num = 0
n0 = 1
n1 = 0
while p < n:
	if c[p] == '1':
		n0 = 0
		n1 += 1
	else:
		n0 += 1
		n1 = 0
	if n0 == 3 or n1 == 2:
		print('No')
		quit(0)
	p += 1
if n0 == 2:
	print('No')
else:
	print('Yes')


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


n = int(input())
s = input()
c1 = 0
c0 = 0
count = 0
b = True
for c in s:
	if c == '1':
		c1 += 1
		c0 = 0
		count += 1
	else:
		c0 += 1
		c1 = 0
	if c0 > 2 or c1 > 1 or (count == 0 and c0 > 1):
		b = False
		break
if c0 > 1 or c1 > 1 or count == 0:
	b = False
if b:
	print('Yes')
else:
	print('No')


n = int(input())
r = input()

def neigh(i, d):
	if i + d < 0 or i + d >= n:
		return '0'
	else:
		return r[i + d]

def solve():
	for i in range(n):
		if r[i] == '1':
			if r[i] == neigh(i, -1) or r[i] == neigh(i, 1):
				return 'No'
		if r[i] == '0':
			if r[i] == neigh(i, -1) and r[i] == neigh(i, 1):
				return 'No'
	return 'Yes'
print(solve())


n = int(input())
string = input()
last = string[0]
for_last = '0'
maximal = True
for i in range(1, n):
	if string[i] == '1' and last == '1':
		maximal = False
	elif i + 1 < n and string[i] == '0' and (last == '0') and (string[i + 1] == '0'):
		maximal = False
	elif string[i] == '0' and last == '0' and (i == n - 1 or i == 1):
		maximal = False
	last = string[i]
if n == 1 and string[0] == '0':
	print('No')
else:
	print('Yes' if maximal else 'No')


k = int(input())
a = input()
if (a.count('11') >= 1 or a.count('000') >= 1) == 1:
	print('No')
elif k == 1 and a[0] == '0':
	print('No')
elif k >= 2 and (a[0] + a[1] == '00' or a[-1] + a[-2] == '00'):
	print('No')
else:
	print('Yes')


T = int(input())
m = str(input())
flag = 1
free = 0
if T != 1:
	for i in range(T):
		if m[i] == '1':
			if i != T - 1:
				if m[i + 1] == '1':
					print('no')
					flag = 0
					break
		elif i != 0 and i != T - 1:
			if m[i - 1] == '0' and m[i + 1] == '0':
				free += 1
		elif i == 0 and m[1] == '0':
			free += 1
		elif i == T - 1 and m[-2] == '0':
			free += 1
	if flag != 0:
		if free == 0:
			print('yes')
		else:
			print('no')
elif m == '1':
	print('yes')
else:
	print('no')


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


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


n = int(input())
s = input()
flag = True
if n == 1 and (not s == '1'):
	flag = False
else:
	temp = [0 for i in range(n)]
	for i in range(n):
		if s[i] == '1':
			temp[i] += 2
			if i - 1 >= 0:
				temp[i - 1] += 1
			if i + 1 < n:
				temp[i + 1] += 1
	for i in range(n):
		if temp[i] != 2 and temp[i] != 1:
			flag = False
if flag:
	print('Yes')
else:
	print('No')


n = int(input())
seats = input()
result = True
for i in range(n):
	seat = seats[i]
	if i > 0 and seat == '1' and (seats[i - 1] == '1'):
		result = False
		break
	if i > 1 and seat == '0' and (seats[i - 1] == '0') and (seats[i - 2] == '0'):
		result = False
		break
	if i == n - 1 and seat == '0' and (i == 0 or seats[i - 1] == '0'):
		result = False
		break
	if i == 1 and seat == '0' and (seats[i - 1] == '0'):
		result = False
		break
if result:
	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()
	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')


input()
print(('No', 'Yes')[all((0 < len(x) < 3 for x in ('0' + input() + '0').split('1')))])


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()
	elif 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 main():
	n = int(input())
	print(proc(maxk(input())))

def maxk(inp):
	if inp == '0':
		return False
	if '11' in inp:
		return False
	if '000' in inp:
		return False
	if inp[0:2] == '00':
		return False
	n = len(inp)
	if inp[n - 2:n] == '00':
		return False
	return True

def proc(x):
	if x:
		return 'Yes'
	return 'No'
main()


num = input()
chairs = input()
true = 0
output = ['Yes', 'No']
if int(num) == 1 and chairs == '0':
	true = 1
elif int(num) == 2 and (chairs == '00' or chairs == '11'):
	true = 1
else:
	for i in range(int(num)):
		if i + 1 < int(num) and int(chairs[i]) == 1 and (int(chairs[i + 1]) == 1):
			true = 1
			break
		if i + 2 < int(num) - 1 and int(chairs[i]) == 0 and (int(chairs[i + 1]) == 0) and (int(chairs[i + 2]) == 0):
			true = 1
			break
		if i + 2 > int(num) - 1 and i + 1 <= int(num) - 1 and (int(chairs[i]) == 0) and (int(chairs[i + 1]) == 0):
			true = 1
			break
		if i == 0 and int(chairs[0]) == 0 and (int(chairs[1]) == 0):
			true = 1
			break
print(output[true])


N = int(input())
a = input()
if N == 1:
	if a[0] == '1':
		print('Yes')
	else:
		print('No')
else:
	s = []
	for i in range(N):
		s.append(int(a[i]))
	e = 1
	if N % 2 == 1:
		e = 0
	flag = 0
	if a.find('000') != -1:
		flag = 1
	elif a[:2] == '00' or a[N - 2:] == '00':
		flag = 1
	else:
		for i in range(N):
			if i != N - 1:
				if s[i] == s[i + 1] == 1:
					flag = 1
					break
	if flag == 1:
		print('No')
	else:
		print('Yes')


n = int(input())
ch = input()
cond = True
c = 0
if n == 1:
	if ch[0] == '1':
		print('Yes')
	else:
		print('No')
elif n == 2:
	if ch == '01' or ch == '10':
		print('Yes')
	else:
		print('No')
elif n == 3:
	if ch == '101' or ch == '010':
		print('Yes')
	else:
		print('No')
elif ch[n - 1] == '0' and ch[n - 2] == '0' or (ch[0] == '0' and ch[1] == '0'):
	print('No')
else:
	if ch[0] == '0':
		cond = True
		c = 1
	else:
		cond = False
	m = 0
	for i in range(1, n):
		if ch[i] == '1' and cond == False:
			print('No')
			exit()
		if ch[i] == '1':
			cond = False
			c = 0
		else:
			cond = True
			c += 1
		m = max(c, m)
	if m < 3:
		print('Yes')
	else:
		print('No')


n = int(input())
s = input()
a = []
for i in s:
	a.append(int(i))
flag = 0
if n == 1 and a[0] == 0:
	flag = 1
if n == 1 and flag == 0:
	print('Yes')
elif n == 1 and flag == 1:
	print('No')
else:
	c = 0
	f = 0
	for i in range(n - 1):
		if a[i] == 1 and a[i + 1] == 1:
			c = 1
			break
	for i in range(n):
		if i != 0 and i != n - 1:
			if a[i] == 0 and (a[i - 1] == 0 and a[i + 1] == 0):
				f = 1
				break
		elif i == 0:
			if a[0] == 0 and a[1] == 0:
				f = 1
				break
		elif i == n - 1:
			if a[n - 1] == 0 and a[i - 1] == 0:
				f = 1
				break
	if c == 0 and f == 0:
		print('Yes')
	else:
		print('No')


def pairs(a):
	prev = 't'
	for x in a:
		if prev != 't':
			yield (prev, x)
		prev = x

def zeropair(p1, p2):
	if p1[1] == str(0) and p1[0] == str(0) and (p2[0] == str(0)) and (p2[1] == str(0)):
		return True
	else:
		return False
b = int(input()) == 1
a = input()
lp = (1, 1)
for x in pairs(a):
	if x[0] == str(1) and str(1) == x[1] or zeropair(x, lp):
		print('No')
		break
	lp = x
else:
	if b and a[0] == str(0) or tuple(a[-2:]) == ('0', '0') or tuple(a[0:2]) == ('0', '0'):
		print('No')
	else:
		print('Yes')


n = int(input())
s = input()
s = '0' + s + '0'
if s.count('11') == 0 and s.count('000') == 0:
	print('Yes')
else:
	print('No')


def solve(n, s):
	if sum(s[-2:]) == 0:
		return False
	if sum(s[:2]) == 0:
		return False
	for i in range(1, n):
		if s[i - 1] + s[i] == 2:
			return False
		if i + 1 < n and s[i - 1] + s[i] + s[i + 1] == 0:
			return False
	return True
n = int(input())
s = list(map(int, input().strip()))
if solve(n, s):
	print('Yes')
else:
	print('No')


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


n = int(input())
s = input()
all_ok = True
s = '0' + s + '0'
for i in range(1, len(s) - 1):
	if s[i] == '1' and (s[i - 1] == '1' or s[i + 1] == '1'):
		all_ok = False
		break
	if s[i] == '0' and s[i - 1] == '0' and (s[i + 1] == '0'):
		all_ok = False
		break
if all_ok:
	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
else:

	def test():
		for i in range(len(l) - 1):
			if int(l[i]) + int(l[i + 1]) > 1:
				chk = False
				return False
		return True
	chk = 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')


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')
elif '000' in b:
	print('no')
elif '11' in b:
	print('no')
elif b[-2::1] == '00':
	print('no')
else:
	print('yes')


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


def ii():
	return int(input())

def ai():
	return map(int, input().split())
n = ii()
s = input()
if n == 1:
	if s == '1':
		print('Yes')
	else:
		print('No')
	exit(0)
if '11' in s or '000' in s:
	print('No')
elif s[0:2] == '00' or s[n - 2:n] == '00':
	print('No')
else:
	print('Yes')


a = int(input())
b = input()
c = 0
c1 = 0
c2 = 0
for i in range(a - 1):
	if b[i] == b[i + 1] == '1':
		c += 1
if a >= 2:
	if b[a - 1] == b[a - 2] == '0' or b[0] == b[1] == '0':
		c2 += 1
for i in range(a - 2):
	if b[i] == b[i + 1] == b[i + 2] == '0':
		c1 += 1
	if c1 >= 1:
		break
if c >= 1 or c1 >= 1 or c2 >= 1 or (a == 1 and b[0] == '0'):
	print('NO')
else:
	print('YES')


def lei(s):
	t = False
	for c in s:
		if c == '1':
			if t:
				return False
			t = True
		else:
			t = False
	start = -2
	end = None
	for (i, c) in enumerate(s):
		if c == '1':
			end = i
			if end - start >= 4:
				return False
			start = end
	if start <= len(s) - 3:
		return False
	return True
n = int(input())
s = input().strip()
assert n == len(s)
if lei(s):
	print('Yes')
else:
	print('No')


def main():
	input()
	l = [len(s) for s in input().split('1')]
	if len(l) == 1:
		r = 0
	else:
		(a, *l, z) = l
		l += [2]
		r = a < 2 > z and max(l) < 3 and (min(l) > 0)
	print(('No', 'Yes')[r])
main()


n = int(input())
s = input()
count0 = 0
count1 = 0
if n == 1:
	flag = s == '1'
else:
	flag = s.count('000') == 0 and s[0] != s[1] and (s[-1] != s[-2]) and (s.count('11') == 0)
print('Yes' if flag else 'No')


def main():
	size = int(input())
	string = input()
	if size == 1:
		if string == '0':
			print('No')
			return
		else:
			print('Yes')
			return
	for i in range(1, size - 1):
		if string[i] == '0':
			if string[i + 1] == '0' and string[i - 1] == '0':
				print('No')
				return
		if string[i] == '1':
			if string[i + 1] == '1' or string[i - 1] == '1':
				print('No')
				return
	if string[0] == '0' and string[1] == '0' or (string[0] == '1' and string[1] == '1'):
		print('No')
		return
	if string[size - 1] == '0' and string[size - 2] == '0' or (string[size - 1] == '1' and string[size - 2] == '1'):
		print('No')
		return
	print('Yes')
main()


__author__ = 'Juan Barros'

def solve(n, a):
	result = False
	zeroCount = 1
	for i in range(n):
		if a[i] == 0:
			if zeroCount == 0:
				result = False
				break
			zeroCount -= 1
		else:
			if zeroCount == 2:
				result = False
				break
			zeroCount = 2
			result = True
	return 'Yes' if result and zeroCount > 0 else 'No'
n = int(input())
a = [int(element) for element in input()]
print(solve(n, a))


def exists(s):
	maxRun = 0
	run = 0
	run = 1 if s[0] == '0' else 0
	for i in range(1, len(s)):
		if s[i] == '1':
			run = 0
		else:
			run += 1
			maxRun = max(run, maxRun)
	return maxRun >= 3
n = int(input())
s = input()
if n == 1:
	print('Yes' if s == '1' else 'No')
elif n == 2:
	if s == '11' or s == '00':
		print('No')
	else:
		print('Yes')
else:
	numAdj = 0
	for i in range(1, n):
		if s[i] == '1' and s[i - 1] == '1':
			numAdj += 1
	if numAdj:
		print('No')
	elif s[:2] == '00':
		print('No')
	elif s[n - 2:] == '00':
		print('No')
	elif exists(s):
		print('No')
	else:
		print('Yes')


input()
s = '0' + input() + '0'
if '11' in s:
	print('No')
	exit()
if '000' in s:
	print('No')
	exit()
print('Yes')


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:]
first_chars = word[0:2]
if '00' in first_chars:
	print('No')
	exit()
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 = int(input())
s = input()
flag = 0
if len(s) == 1:
	if s[0] == '0':
		print('NO')
	else:
		print('YES')
else:
	for i in range(len(s)):
		if s[i] == '1':
			if i > 0:
				if s[i - 1] == '1':
					print('NO')
					flag = 1
					break
			if i < len(s) - 1:
				if s[i + 1] == '1':
					print('NO')
					flag = 1
					break
		elif i == 0 and i < len(s) - 1:
			if s[i + 1] == '0':
				print('NO')
				flag = 1
				break
		elif i > 0 and i == len(s) - 1:
			if s[i - 1] == '0':
				print('NO')
				flag = 1
				break
		elif s[i + 1] == '0' and s[i - 1] == '0':
			print('NO')
			flag = 1
			break
	if flag == 0:
		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 > 1:
			print('NO')
			return
	if first > -1:
		l = s.index('1')
		if l > 1:
			print('NO')
			return
	if check_val(maximum) and check_val(minimum):
		print('YES')
		return
	else:
		print('NO')
		return
check()


n = int(input())
s = input()
f = 0
if n == 1:
	f = 1
	if s == '1':
		print('yes')
	else:
		print('no')
elif n == 2:
	f = 1
	if s == '00':
		print('no')
	elif s == '10' or s == '01':
		print('yes')
	else:
		print('no')
else:
	for i in range(n):
		if i == 0:
			if s[0] == '0':
				if s[1] == '0':
					print('no')
					f = 1
					break
				else:
					continue
			elif s[1] == '1':
				print('no')
				f = 1
				break
			else:
				continue
		elif i == n - 1:
			if s[n - 1] == '0':
				if s[n - 1] == '0':
					if s[n - 2] == '0':
						print('no')
						f = 1
						break
					else:
						continue
			elif s[n - 2] == '1':
				print('no')
				f = 1
				break
			else:
				continue
		elif s[i] == '0':
			if s[i - 1] == '0' and s[i + 1] == '0':
				print('no')
				f = 1
				break
			else:
				continue
		elif s[i - 1] == '1' or s[i + 1] == '1':
			print('no')
			f = 1
			break
		else:
			continue
if f == 0:
	print('yes')


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')


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))
			huha = khela(str(checking))
			if huha == 1:
				fino = 'NO'
				xx = 1
		li1 = list(li2)
if xx == 0:
	fino = 'YES'
print(fino)


N = int(input())
s = input()
s = list(s)
ans = 1
for i in range(N):
	if s[i] is '0' or s[i] is '-1':
		continue
	if i > 0:
		if s[i - 1] is '0':
			s[i - 1] = '-1'
		elif s[i - 1] != '-1':
			ans = 0
	if i < N - 1:
		if s[i + 1] is '0':
			s[i + 1] = '-1'
		else:
			ans = 0
if ans is 0:
	print('No')
else:
	s = str(s)
	print('Yes' if s.count('1') == N else 'No')


n = int(input())
line = input()
if n == 1:
	print('Yes' if line == '1' else 'No')
else:
	print('Yes' if line.find('11') == -1 and (not line.endswith('00')) and (not line.startswith('00')) and (line.find('000') == -1) else 'No')


n = int(input())
a = str(input())
flag = 0
if len(a) == 1:
	if a[0] == '1':
		print('YES')
	else:
		print('NO')
elif len(a) == 2:
	if a[0] == a[1] == '1' or a[0] == a[1] == '0':
		print('NO')
	else:
		print('YES')
else:
	for i in range(0, len(a)):
		if i == 0 and a[i] == '1':
			if a[i + 1] == '1':
				flag = 1
				break
		elif i == len(a) - 1 and a[i] == '1':
			if a[i - 1] == '1':
				flag = 1
				break
		elif a[i] == '1':
			if a[i + 1] == '1' or a[i - 1] == '1':
				flag = 1
				break
	for i in range(0, len(a) - 2):
		if a[i] == a[i + 1] == a[i + 2] == '0':
			flag = 1
			break
	if a[-1] == a[-2] == '0' or a[0] == a[1] == '0':
		flag = 1
	if flag == 0:
		print('YES')
	else:
		print('NO')


n = int(input())
arr = input()
flag = 0
if n == 1:
	if arr[0] == '1':
		print('YES')
	else:
		print('NO')
else:
	for i in range(1, n):
		if n <= 3:
			if arr[i - 1:i + 1] == '11' or arr[i - 1:i + 1] == '00':
				flag = 1
				print('NO')
				break
		else:
			if arr[i - 1] == '1' and arr[i] == '1':
				print('NO')
				flag = 1
				break
			if arr[i - 1:i + 2] == '000':
				print('NO')
				flag = 1
				break
	if flag == 0:
		if arr[-2:] == '00' or arr[:2] == '00':
			print('NO')
		else:
			print('YES')


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


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


import re
n = int(input())
a = input()
if re.search('11|000', '0' + a + '0') != None:
	print('NO')
else:
	print('YES')


import re
n = int(input())
seat = input()
if seat == '0':
	print('No')
	exit()
for i in range(len(seat) - 1):
	if seat[i] == '1' and seat[i + 1] == '1':
		print('No')
		exit()
finddd = re.findall('0{3,}', seat)
if len(finddd) > 0:
	print('No')
	exit()
if len(seat) > 0:
	if seat[0] == '0' and seat[1] == '0' or (seat[-1] == '0' and seat[-2] == '0'):
		print('No')
		exit()
print('Yes')


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


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


import sys
data = sys.stdin.readlines()[1]
estado = 'Yes'
if data == '0\n' or data == '00\n':
	estado = 'No'
if '100\n' in data:
	estado = 'No'
if '001' == data[0:3]:
	estado = 'No'
if '11' in data:
	estado = 'No'
if '000' in data:
	estado = 'No'
print(estado)


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


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())
s = input()
if len(s) == 1:
	print('No' if s == '0' else 'Yes')
	exit(0)
print('Yes' if s.count('11') == 0 and s.count('000') == 0 and (s[0] + s[1] != '00') and (s[n - 1] + s[n - 2] != '00') else 'No')


n = int(input())
po = str(input())
ta = []
ta.append('.')
x = 0
poi = 0
if len(po) == 1 and po[0] == '0':
	print('No')
elif len(po) == 1 and po[0] == '1':
	print('Yes')
elif '000' in po:
	print('No')
elif '11' in po:
	print('No')
elif po[0:2] == '00':
	print('No')
elif po[-2:] == '00':
	print('No')
else:
	print('Yes')


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


n = int(input())
s = input()
ans = 'Yes'
for i in s.split('0'):
	if len(i) > 1:
		ans = 'No'
for i in s.split('1')[1:-1]:
	if len(i) > 2:
		ans = 'No'
x = s.split('1')
if len(x[0]) > 1 or len(x[-1]) > 1 or s == '0':
	ans = 'No'
print(ans)


n = int(input())
n += 2
st = input()
st = '0' + st + '0'
cond = True
for i in range(1, n):
	if st[i] == st[i - 1] and st[i] == '1':
		cond = False
if cond and st.count('000') == 0:
	print('Yes')
else:
	print('No')


import math
n = int(input())
s = input()
if len(s) <= 2:
	if '1' not in s or '11' in s:
		ans = 'No'
	else:
		ans = 'Yes'
elif '000' not in s and '11' not in s and (s[:2] != '00') and (s[-2:] != '00'):
	ans = 'Yes'
else:
	ans = 'No'
print(ans)


import sys
import math

def fun():
	n = int(input())
	arr = input()
	ok = 1
	first = 1
	count0 = 0
	if n == 1 and arr[0] == '0':
		print('No')
		return
	for i in arr:
		if i == '0':
			count0 += 1
		elif first == 1:
			if count0 > 1:
				print('No')
				return
			first = 0
			count0 = 0
		else:
			if count0 > 2 or count0 < 1:
				print('No')
				return
			count0 = 0
	if count0 > 1:
		print('No')
		return
	print('Yes')
	return
fun()


n = int(input().strip())
a = input().strip()
flag = False
if n == 1 and a[0] == '0':
	flag = True
elif n > 1:
	if a[0] == a[1] or a[n - 2] == a[n - 1]:
		flag = True
	for i in range(1, n - 1):
		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()
if n == 1:
	print('Yes' if s == '1' else 'No')
else:
	print('Yes' if s[:2] != '00' and s[-2:] != '00' and (s.find('000') == -1) and (s.find('11') == -1) else 'No')


import math

def has_two_adjacents_zeros_index(seats, index):
	if len(seats) < 2:
		return False
	if seats[index] == '0' and seats[index + 1] == '0':
		return True
	else:
		return False

def has_adjacents_ones(seats, n):
	for i in range(n - 1):
		if seats[i] == '1' and seats[i + 1] == '1':
			return True
	return False

def has_three_adjacents_zeros(seats, n):
	for i in range(n - 3):
		if seats[i] == '0' and seats[i + 1] == '0' and (seats[i + 2] == '0'):
			return True
	return False
n = int(input())
seats = input()
if len(seats) == 1 and seats[0] == '0':
	print('No')
elif has_two_adjacents_zeros_index(seats, 0) or has_two_adjacents_zeros_index(seats, len(seats) - 2):
	print('No')
elif has_adjacents_ones(seats, n) or has_three_adjacents_zeros(seats, n):
	print('No')
else:
	print('Yes')


n = int(input())
s = input()[:n]
for i in range(len(s)):
	if s[i] == '1':
		if i - 1 >= 0 and s[i - 1] != '0':
			print('No')
			exit()
		if i + 1 < len(s) and s[i + 1] != '0':
			print('No')
			exit()
	elif s[i] == '0':
		if (i - 1 < 0 or s[i - 1] == '0') and (i + 1 >= len(s) or s[i + 1] == '0'):
			print('No')
			exit()
print('Yes')


n = int(input())
myList = list(input())
indicator = 0
if n == 1:
	if myList[0] == '1':
		print('YES')
		indicator = 1
	else:
		print('NO')
		indicator = 1
elif n == 2:
	if myList[0] == '0' and myList[1] == '0':
		print('NO')
		indicator = 1
	elif myList[0] == '0' and myList[1] == '1':
		print('YES')
		indicator = 1
	elif myList[0] == '1' and myList[1] == '0':
		print('YES')
		indicator = 1
	elif myList[0] == '1' and myList[1] == '1':
		print('NO')
		indicator = 1
else:
	for i in range(0, len(myList) - 1):
		if myList[i] == '1' and myList[i + 1] == '1':
			print('NO')
			indicator = 1
			break
	if indicator == 0:
		if myList[0] == '0' and myList[1] == '0':
			print('NO')
			indicator = 1
		elif myList[-1] == '0' and myList[-2] == '0':
			print('NO')
			indicator = 1
		else:
			for j in range(0, len(myList) - 2):
				if myList[j] == '0' and myList[j + 1] == '0' and (myList[j + 2] == '0'):
					print('NO')
					indicator = 1
					break
if indicator == 0:
	print('YES')


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


import os, sys, math
import re

def main():
	T = int(input())
	testcase()

def testcase():
	l = input()
	if solve(l):
		print('Yes')
	else:
		print('No')

def solve(l):
	if l == '0':
		return False
	if re.search('11', l):
		return False
	if re.search('000', l):
		return False
	if re.search('00$', l):
		return False
	if re.search('^00', l):
		return False
	return True

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


noe = int(input())
ins = '0' + input() + '0'
print('NO' if '11' in ins or '000' in ins else 'YES')


l = int(input())
s = input()
if l == 1:
	if s == '0':
		print('NO')
	else:
		print('YES')
elif l == 2:
	if s[0] == '0' and s[1] == '0':
		print('NO')
	elif s[0] == '1' and s[1] == '1':
		print('NO')
	else:
		print('YES')
else:
	count = 0
	flag = 0
	for i in range(l - 1):
		if s[i] == '1' and s[i + 1] == '1':
			flag = 1
	for i in range(l - 2):
		if s[i] == '0' and s[i + 1] == '0' and (s[i + 2] == '0'):
			flag = 1
	if s[0] == '0' and s[1] == '0':
		flag = 1
	if s[l - 2] == '0' and s[l - 1] == '0':
		flag = 1
	if flag == 0:
		print('YES')
	else:
		print('NO')


import sys
n = int(input())
s = input()
if s[:2] == '00' or s[-2:n] == '00' or s == '0':
	print('No')
	sys.exit()
for i in range(n - 2):
	if s[i:i + 3] == '000':
		print('No')
		sys.exit()
for i in range(n - 1):
	if s[i:i + 2] == '11':
		print('No')
		sys.exit()
print('Yes')


import sys
from sys import stdin as In, stdout as Out

def mp():
	return map(int, In.readline().split())
n = int(In.readline())
a = list(In.readline())
if n == 1 and a[0] == '0':
	print('No')
	sys.exit()
elif n == 1 and a[0] == '1':
	print('Yes')
	sys.exit()
for i in range(n):
	if a[i] == '1':
		if i - 1 >= 0:
			if a[i - 1] == a[i]:
				print('No')
				sys.exit()
		if i + 1 < n:
			if a[i + 1] == a[i]:
				print('No')
				sys.exit()
if ''.join(a).find('000') != -1:
	print('No')
	sys.exit()
if a[0] == '0' and a[1] == '0':
	print('No')
	sys.exit()
if a[n - 1] == '0' and a[n - 2] == '0':
	print('No')
	sys.exit()
print('Yes')


input()
a = input()
if a == '1':
	print('Yes')
elif a == '0' or a.count('11') > 0 or a.count('000') > 0 or (a[0] + a[1] == '00') or (a[-1] + a[-2] == '00'):
	print('No')
else:
	print('Yes')


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


n = int(input())
str = input()
in1 = str.find('11')
if in1 != -1:
	print('No')
	exit()
if n == 1:
	if str == '0':
		print('No')
	else:
		print('Yes')
	exit()
if n == 2:
	if str == '00':
		print('No')
	else:
		print('Yes')
	exit()
if str[0] == '0' and str[1] == '0' or (str[len(str) - 1] == '0' and str[len(str) - 2] == '0'):
	print('No')
else:
	in1 = str.find('000')
	if in1 == -1:
		print('Yes')
	else:
		print('No')


input()
s = '0' + input() + '0'
print('NO' if s.count('000') or s.count('11') else 'YES')


n = int(input())
string = input()
if n == 1:
	if string[0] == '0':
		print('No')
		exit()
	else:
		print('Yes')
		exit()
if string[0] == '0' and string[1] == '0':
	print('No')
	exit()
l = len(string)
if string[l - 1] == '0' and string[l - 2] == '0':
	print('No')
	exit()
oneCount = 0
zeroCount = 0
for s in string:
	if s == '1':
		oneCount += 1
		zeroCount = 0
	else:
		zeroCount += 1
		oneCount = 0
	if oneCount >= 2 or zeroCount > 2:
		print('No')
		exit()
print('Yes')


n = int(input())
s = input()
if n == 1 and s[0] == '1':
	print('Yes')
elif n == 1 and s[0] == '0':
	print('No')
else:
	flag = 0
	for i in range(0, n - 1):
		if s[i] == '1' and s[i + 1] == s[i]:
			flag = flag + 1
			break
	s = s.split('1')
	for i in s:
		if len(i) >= 3:
			flag = flag + 1
			break
		m = len(s)
	if len(s[0]) >= 2 or len(s[m - 1]) >= 2:
		flag = flag + 1
	if flag == 0:
		print('Yes')
	else:
		print('No')


n = int(input())
s = input()
if len(s) > 1 and (s[0:2] == '00' or s[-1:-3:-1] == '00'):
	b = 1
else:
	b = 0
if s.rfind('000') == -1 and s.rfind('11') == -1 and (s != '0') and (not b):
	print('Yes')
else:
	print('NO')


def maximize():
	n = int(input())
	final = ['0']
	seats = list(input())
	seats.append('0')
	final += seats
	answer = 'Yes'
	if n == 1 and seats[0] == '0':
		answer = 'No'
	else:
		for i in range(n + 1):
			if final[i] == '1' and final[i + 1] == '1':
				answer = 'No'
				break
		for j in range(n):
			if final[j] == '0' and final[j + 1] == '0' and (final[j + 2] == '0'):
				answer = 'No'
				break
	return answer
print(maximize())


n = int(input())
s = input()
if n == 1:
	print('Yes') if s == '1' else print('No')
elif s[0:2] == '00' or s[n - 2:n] == '00':
	print('No')
else:
	if s[0] == '1':
		s = s[1:]
	if s[len(s) - 1] == '1':
		s = s[0:len(s) - 1]
	l = s.split('1')
	h = 0
	for x in l:
		if len(x) == 0 or len(x) > 2:
			h = 1
			break
	print('No') if h else print('Yes')


n = int(input())
s = input()
d = 0
e = 0
for i in range(0, n):
	if s[i] == '0':
		d = d + 1
if n == 1:
	if s == '1':
		print('Yes')
		exit(0)
	else:
		print('No')
		exit(0)
if '11' in s:
	print('No')
	exit(0)
else:
	for i in range(n):
		s1 = s
		if s1[i] == '0':
			s2 = s1[:i] + '1' + s1[i + 1:]
			if '11' in s2:
				e = e + 1
if e == d:
	print('Yes')
else:
	print('No')


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


n = int(input())
a = input()
a = list(a)
b = []
d = 0
e = 1
if len(a) == 1:
	if a[0] == '0':
		e = 0
else:
	for i in range(n):
		if a[i] == '1':
			b.append(i)
	if a[0] == '0' and a[1] == '0' or (a[-1] == '0' and a[-2] == '0'):
		e = 0
	else:
		for i in range(len(b) - 1):
			for j in range(b[i], b[i + 1] + 1):
				if a[j] == '0':
					d += 1
			if d > 2 or d == 0:
				e = 0
				break
			d = 0
if e == 1:
	print('Yes')
else:
	print('No')


n = int(input())
s = input()
if s == '0' or '11' in s or '000' in s or (s == '00'):
	print('NO')
elif s.startswith('001') or s.endswith('100'):
	print('NO')
else:
	print('YES')


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


n = int(input())
a = input()
if a.find('000') != -1:
	print('no')
	exit()
if a.startswith('00') or a.endswith('00'):
	print('no')
	exit()
if a.find('11') != -1:
	print('no')
	exit()
if a == '0':
	print('no')
	exit()
print('yes')


n = int(input())
g = input()
s = []
for i in range(0, n):
	s.append(int(g[i]))
for i in range(0, n - 1):
	if s[i] == 1 and s[i + 1] == 1:
		print('no')
		exit(0)
for i in range(0, n - 2):
	if s[i] == 0 and s[i + 1] == 0 and (s[i + 2] == 0):
		print('no')
		exit(0)
if n > 1:
	if s[0] == 0 and s[1] == 0:
		print('no')
		exit(0)
	if s[n - 1] == 0 and s[n - 2] == 0:
		print('no')
		exit(0)
elif s[0] == 0:
	print('no')
	exit(0)
print('yes')


n = int(input())
a = str(input())
if a == '0' or (a[n - 2] == '0' and a[n - 1] == '0') or (a[0] == '0' and a[1] == '0'):
	print('NO')
elif a.count('11') > 0 or a.count('000') > 0:
	print('NO')
else:
	print('YES')


n = int(input()) + 1
row = str(input())
row = list('0' + row + '0')

def check_arr(arr, n):
	ok = True
	for i in range(1, n):
		if arr[i] == '1':
			if arr[i - 1] != '0' or arr[i + 1] != '0':
				ok = False
				break
	return ok
if check_arr(row, n):
	ok2 = True
	for i in range(1, n):
		if row[i] == '0':
			row[i] = '1'
			if check_arr(row, n):
				ok2 = False
				break
			row[i] = '0'
	if ok2:
		print('Yes')
	else:
		print('No')
else:
	print('No')


n = int(input())
s = input().strip()
if n <= 2:
	if s in ['10', '01', '1']:
		print('Yes')
	else:
		print('No')
elif '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())
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 = 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())
a = input()
for i in range(n - 1):
	if a[i] == '1' and a[i + 1] == '1':
		print('No')
		exit()
for i in range(n - 1, 0, -1):
	if a[i] == '1' and a[i - 1] == '1':
		print('No')
		exit()
c = 0
for i in range(n):
	if i == n - 1 and a[i] == '0' and (a[i - 1] == '0') or (i == 0 and a[i] == '0' and (a[i + 1] == '0')):
		print('No')
		exit()
	if a[i] == '0':
		c += 1
	else:
		if c >= 3:
			print('No')
			exit()
		c = 0
print('Yes')


n = int(input())
s = input()
a = 0
b = 0
l = 'X'
F = True
t = '0' + s + '0'
for c in t:
	if c == '0':
		a += 1
		l = c
	if c == '1':
		b += 1
		if l == c:
			F = False
		l = c
	else:
		pass
if '000' in t:
	F = False
print('Yes' if F else 'No')


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


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

def check(n, s):
	if n == 1:
		if s == '000':
			return 'No'
		return 'Yes'
	for i in range(n):
		if int(s[i]) + int(s[i + 1]) > 1:
			return 'No'
		if int(s[i]) + int(s[i + 1]) + int(s[i + 2]) == 0:
			return 'No'
	return 'Yes'
print(check(n, '0' + s + '0'))


n = int(input())
seats = input()
if n == 1:
	if seats[0] != '1':
		print('No')
	else:
		print('Yes')
elif n == 2:
	if seats == '01' or seats == '10':
		print('Yes')
	else:
		print('No')
elif seats[0] == '0' and seats[1] == '0':
	print('No')
else:
	if seats[0] == '1':
		last = 0
	else:
		last = 1
	f = last
	isMax = True
	for i in range(f + 1, n):
		if seats[i] == '1':
			if i - last == 1 or i - last > 3:
				isMax = False
				break
			last = i
	if isMax and last >= n - 2:
		print('Yes')
	else:
		print('No')


n = int(input())
flag = 1
zro = 0
one = 0
count = 0
b = input()
for i in range(0, n):
	if b[i] == '1':
		one += 1
		zro = 0
		count += 1
		if one == 2:
			flag = 0
			break
	else:
		zro += 1
		one = 0
		if zro == 2 and (i == 1 or i == n - 1):
			flag = 0
		if zro == 3:
			flag = 0
			break
if count < 1:
	flag = 0
if flag == 1:
	print('YES')
else:
	print('No')


n = int(input())
line = input()
if any((name in line for name in ('11', '000'))):
	print('No')
elif n == 1 and line == '0':
	print('No')
elif line.startswith('00') or line.endswith('00'):
	print('No')
else:
	print('Yes')


n = int(input())
a = input()
x = a.count('0')
y = -3
z = -3
if '00' in a:
	y = a.index('00')
	z = a[::-1].index('00')
if '000' in a or '11' in a or x == n or (y == 0) or (z == 0):
	print('No')
elif n % 2 == 1 and x == n // 2 + 1:
	print('Yes')
else:
	print('Yes')


import re
input()
s = '0' + input() + '0'
print(('Yes', 'No')['11' in s or '000' in s])


k = int(input())
s = input()
if len(s) == 1 and s == '0':
	print('No')
	exit()
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')


a = eval(input())
b = input() + '0'
zeros = 1
ans = True
for c in b:
	if c == '1':
		if zeros == 0:
			ans = False
		zeros = 0
	else:
		zeros = zeros + 1
		if zeros > 2:
			ans = False
if ans:
	print('Yes')
else:
	print('No')


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'
		elif '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'
		elif '0' in self.seating:
			self.result = 'No'
		else:
			self.result = 'Yes'

	def get_result(self):
		return self.result
Solution = CodeforcesTask982ASolution()
Solution.read_input()
Solution.process_task()
print(Solution.get_result())


def solve(s):
	res = []
	counter = 1
	for i in range(1, len(s)):
		if s[i - 1] == s[i]:
			counter += 1
		else:
			if s[i - 1] == '1':
				res.append(counter)
			counter = 1
	if s[-1] == '1':
		res.append(counter)
	if len(set(res)) == 1 and res[0] == 1:
		valid = True
	else:
		valid = False
	return valid
n = int(input())
seats = input()
possible = []
if solve(seats) == False:
	print('NO')
	exit()
for s in range(n):
	if seats[s] == '0':
		possible.append(s)
for p in possible:
	mod = seats[:p] + '1' + seats[p + 1:]
	if solve(mod):
		print('NO')
		exit()
print('YES')


n = int(input())
s = input()
sch = 0
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]:
		sch += 1
		if i == 0 or i == n - 2:
			print('No')
			exit(0)
		if s[i] == '0' and sch > 1:
			print('No')
			exit(0)
		elif s[i] == '1':
			print('No')
			exit(0)
	else:
		sch = 0
print('Yes')


(_, sa) = (input(), input())
print('No' if ('11' in sa or '000' in sa or sa.startswith('00') or sa.endswith('00')) or sa == '0' else 'Yes')


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')
main()


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


slen = int(input())
seating = input()
if slen == 1:
	print(['No', 'Yes'][int(seating[0])])
elif slen == 2:
	if seating in ['11', '00']:
		print('No')
	else:
		print('Yes')
else:
	maximal = 1
	for i in range(len(seating) - 2):
		if seating[i] == seating[i + 1] == '1' or seating[i] == seating[i + 1] == seating[i + 2] == '0':
			maximal = 0
			break
	if seating[0] == seating[1] == '0' or seating[-1] == seating[-2] == '0':
		maximal = 0
	if seating[-1] == seating[-2] == '1':
		maximal = 0
	print(['No', 'Yes'][maximal])


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) > 1 and s[0] == '0' and (s[1] == '0'):
	ans = False
if len(s) > 1 and s[n - 1] == '0' and (s[n - 2] == '0'):
	ans = False
if ans:
	print('Yes')
else:
	print('No')


def has_adjacent_ones(row):
	for i in range(len(row) - 1):
		if row[i] == '1' and row[i + 1] == '1':
			return True
	return False
n = int(input())
row = input()
if n == 1:
	print('No' if row[0] == '0' else 'Yes')
elif row[0] == '0' and row[1] == '0' or (row[-1] == '0' and row[-2] == '0'):
	print('No')
else:
	zeroes = row.split('1')
	length = map(len, zeroes)
	invalid = list(filter(lambda x: x > 2, length))
	print('No' if len(invalid) > 0 or has_adjacent_ones(row) else 'Yes')


import logging
fmt = '%(levelname)s - %(name)s (line:%(lineno)s) - %(message)s'
formatter = logging.Formatter(fmt)
ch = logging.StreamHandler()
ch.setLevel(logging.NOTSET)
ch.setFormatter(formatter)
logger = logging.getLogger('row')
logger.setLevel(logging.NOTSET)
logger.addHandler(ch)

def solve(s):
	if len(s) == 1 and s == '0':
		return False
	elif len(s) == 1 and s == '1':
		return True
	elif len(s) == 2 and '1' in s and ('0' in s):
		return True
	if '11' in s:
		return False
	if '000' in s or s[:2] == '00' or s[-2:] == '00':
		return False
	return True

def main():
	_ = input()
	s = input()
	result = solve(s)
	print('Yes' if result else 'No')

def __starting_point():
	main()
__starting_point()


n = int(input())
s = '0' + input() + '0'
ok = True
for i in range(1, n + 1):
	if s[i] == '0':
		if s[i - 1] == s[i + 1] == '0':
			ok = False
	elif s[i - 1] == '1' or s[i + 1] == '1':
		ok = False
if ok:
	print('Yes')
else:
	print('No')


n = int(input())
a = input()
if n == 1:
	if a == '1':
		print('Yes')
	else:
		print('No')
elif n == 2:
	if a.count('1') == 1:
		print('Yes')
	else:
		print('No')
elif a[:2] == '00' or a[-2:] == '00' or a.count('000') or a.count('11'):
	print('No')
else:
	print('Yes')


n = int(input())
s = input()
c = 0
if n == 1 and s[0] == '0':
	c = 1
for i in range(1, n):
	if s[i - 1] == '1' and s[i] == '1':
		c = 1
for i in range(2, n):
	if s[i] == '0' and s[i - 1] == '0' and (s[i - 2] == '0'):
		c = 1
		break
if n >= 2:
	if s[1] == '0' and s[0] == '0':
		c = 1
	if s[n - 1] == '0' and s[n - 2] == '0':
		c = 1
if c == 1:
	print('NO')
else:
	print('YES')


import sys
START = 0
FREE = 1
OCCUPIED = 2
POSSIBLE_ADJ = 3
ADJ = 4
FAIL = 5
TRANSITIONS = {START: {0: FREE, 1: OCCUPIED}, FREE: {0: POSSIBLE_ADJ, 1: OCCUPIED}, POSSIBLE_ADJ: {0: ADJ, 1: OCCUPIED}, OCCUPIED: {1: FAIL, 0: FREE}}

def tokenizer(n_chairs, in_stream):
	yield 0
	for i in range(0, n_chairs):
		yield int(in_stream.read(1))
	yield 0

def is_maximal(tokens):
	state = START
	for token in tokens:
		state = TRANSITIONS[state][token]
		if state == FAIL:
			return False
		if state == ADJ:
			return False
	return True
in_stream = sys.stdin
n_chairs = int(in_stream.readline())
is_max = is_maximal(tokenizer(n_chairs, in_stream))
print('yes' if is_max else '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')


n = input()
s = input()
if s[0] == '0':
	last = '1'
else:
	last = '0'
oneBeforeLast = '1'
flag = 0
for c in s:
	if c == last == '1' or oneBeforeLast == last == c == '0':
		flag = 1
		break
	oneBeforeLast = last
	last = c
if n == '1' and s[0] == '0':
	flag = 1
if int(n) > 1:
	if s[0] == s[1] == '0' or s[-2] == s[-1] == '0':
		flag = 1
if flag == 0:
	print('YES')
else:
	print('NO')


n = int(input())
s = input()
flag = True
if len(s) > 1:
	if s[0] == '1' and s[1] == '1':
		flag = False
	if s[len(s) - 1] == '1' and s[len(s) - 2] == '1':
		flag = False
if flag:
	for i in range(1, n - 1):
		if s[i] == '1' and (s[i - 1] == '1' or s[i + 1] == '1'):
			flag = False
	if len(s) >= 2 and s[0] == '0' and (s[1] == '0'):
		flag = False
	if flag:
		count = 0
		for i in range(n):
			if s[i] == '1':
				if count > 2:
					flag = False
				count = 0
			else:
				count += 1
		if count >= 2 or s == '00' or s == '0':
			flag = False
if flag:
	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')
elif 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 = int(input())
s = input()
f = True
if n == 1:
	if s[0] == '0':
		print('No')
	else:
		print('Yes')
	exit(0)
if n == 2:
	if s[0] == '0' and s[1] == '0':
		print('No')
	elif s[0] == '1' and s[1] == '1':
		print('No')
	else:
		print('Yes')
	exit(0)
(z, o) = (0, 0)
for i in range(n):
	if s[i] == '0':
		z += 1
		o = 0
	else:
		o += 1
		z = 0
	if z == 3 or o == 2:
		f = False
		break
if n >= 3:
	if s[0] == '0' and s[1] == '0' and (s[2] == '1'):
		f = False
	if s[n - 1] == '0' and s[n - 2] == '0' and (s[n - 3] == '1'):
		f = False
if f:
	print('Yes')
else:
	print('No')


n = int(input())
(a, s) = ([], input())
for i in range(n):
	if s[i] == '1':
		a.append(i)
if len(a) == 0:
	print('No')
elif a[0] > 1 or a[-1] < n - 2:
	print('No')
else:
	for i in range(1, len(a)):
		if not 1 < a[i] - a[i - 1] < 4:
			print('No')
			exit(0)
	print('Yes')


n = int(input())
s = input()
(m, c) = (0, 0)
if n <= 2:
	if n == 1 and s[0] == '1':
		print('yes')
	elif n == 1 and s[0] == '0':
		print('no')
	elif n == 2 and s in ['10', '01']:
		print('yes')
	else:
		print('no')
elif s[:2] == '00' or s[n - 2:] in ['00', '11']:
	print('no')
else:
	f = 1
	for i in range(n - 2):
		if s[i:i + 3] == '000' or s[i:i + 2] == '11':
			f = 0
			print('no')
			break
	if f == 1:
		print('yes')


input()
s = '0' + input() + '0'
if s.count('000') or s.count('11'):
	print('no')
else:
	print('yes')


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')


def rule1(ls, n):
	for i in range(n):
		if ls[i:i + 2] == ['1', '1']:
			return False
	return True

def rule2(s, n, ts):
	for i in range(n):
		if s[i] == '0':
			ts[i] = '1'
			if rule1(ts, n) == True:
				return False
			else:
				ts = list(s)
	return True
n = int(input())
s = input()
ls = list(s)
ts = list(s)
if rule1(ls, n) == True and rule2(s, n, ts) == True:
	print('Yes')
else:
	print('No')


n = int(input().strip())
arr = input().strip()
continuous1 = False
continuous0x3 = False
poss = False
prev1 = -1
prev2 = -1
for i in range(len(arr)):
	if arr[i] == '0':
		if prev1 == 0 and prev2 == 0:
			continuous0x3 = True
			print('No')
			break
		if i == len(arr) - 1 or i == 1:
			if prev1 != 1:
				poss = True
				print('No')
				break
	elif arr[i] == '1':
		if prev1 == 1:
			continuous1 = True
			print('No')
			break
	prev2 = prev1
	prev1 = int(arr[i])
else:
	print('Yes')


n = int(input())
s = input()
if s == '1' or ('000' not in s and '11' not in s and (len(s) > 1 and (not (s[0] == '0' and s[1] == '0')) and (not (s[-1] == '0' and s[-2] == '0')))):
	print('YES')
else:
	print('NO')


n = int(input())
s = input()
isMax = True
cnt1 = 0
cnt0 = 0
max1 = 0
max0 = 0
for i in range(n):
	if s[i] == '0':
		cnt0 += 1
		max1 = max(cnt1, max1)
		cnt1 = 0
	else:
		cnt1 += 1
		max0 = max(cnt0, max0)
		cnt0 = 0
max0 = max(cnt0, max0)
max1 = max(cnt1, max1)
if n >= 2:
	if s[0] == s[1] and s[1] == '0' or (s[n - 1] == s[n - 2] and s[n - 1] == '0'):
		isMax = False
isMax = isMax and (not max0 >= 3) and (not max1 >= 2) and (not s == '0')
if isMax:
	print('Yes')
else:
	print('No')


n = eval(input())
x = input()
if n == 1:
	if x == '1':
		print('Yes')
	else:
		print('No')
elif x[0] == '0' and x[1] == '0' or (x[len(x) - 2] == '0' and x[len(x) - 1] == '0'):
	print('No')
else:
	i = 0
	f = True
	while i < len(x) - 1:
		if x[i] == '1' and x[i + 1] == '1':
			print('No')
			f = False
			break
		i += 1
	i = 0
	z = 0
	while i < len(x) - 1 and f == True:
		if x[i] == '0':
			z += 1
		if z == 3:
			print('No')
			f = False
			break
		if x[i + 1] == '1':
			z = 0
			i += 1
		i += 1
	if f == True:
		print('Yes')


N = int(input())
S = input().strip()
if N <= 1:
	if S == '0':
		print('No')
	else:
		print('Yes')
elif '11' not in S and '000' not in S:
	if S[:2] == '00' or S[::-1][:2] == '00':
		print('No')
	else:
		print('Yes')
else:
	print('No')


def getIntList():
	return list(map(int, input().split()))

def getTransIntList(n):
	first = getIntList()
	m = len(first)
	result = [[0] * n for _ in range(m)]
	for i in range(m):
		result[i][0] = first[i]
	for j in range(1, n):
		curr = getIntList()
		for i in range(m):
			result[i][j] = curr[i]
	return result
n = int(input())
s = input()
chairs = [int(s[i]) for i in range(n)]

def solve(chairs):
	if n == 1:
		if chairs[0] == 0:
			return 'No'
		else:
			return 'Yes'
	prev = 0
	countZero = 0
	if chairs[0] == chairs[1] == 0 or chairs[-1] == chairs[-2] == 0:
		return 'No'
	for curr in chairs:
		if curr == 0:
			countZero += 1
			if countZero == 3:
				return 'No'
		else:
			countZero = 0
		if prev == curr == 1:
			return 'No'
		prev = curr
	return 'Yes'
print(solve(chairs))


input()
s = input()
if s.find('000') != -1 or s.find('11') != -1 or s == '0' or (s[0] == '0' and s[1] == '0') or (s[-1] == '0' and s[-2] == '0'):
	print('NO')
else:
	print('YES')


n = int(input())
a = [0]
a = a + [int(x) for x in input()]
a.append(0)
c = 0
for i in range(1, n + 1):
	if a[i] == 0 and (a[i - 1] == 0 and a[i + 1] == 0):
		c = 1
		break
	elif a[i] == 1 and (a[i - 1] == 1 or a[i + 1] == 1):
		c = 1
		break
if c:
	print('No')
else:
	print('Yes')


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')
elif 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')


n = int(input())
l = input()
if n == 1:
	if l[0] == '1':
		print('YES')
	else:
		print('NO')
elif n == 2:
	if l == '10' or l == '01':
		print('YES')
	else:
		print('NO')
elif '000' in l or '11' in l:
	print('NO')
elif l[0] + l[1] == '00' or l[n - 2] + l[n - 1] == '00':
	print('NO')
else:
	print('YES')


n = int(input())
s = input()
fl = False
if n == 1 and s == '0':
	print('No')
elif n == 1 and s == '1':
	print('Yes')
elif s[0] + s[1] == '00' or s[n - 2] + s[n - 1] == '00':
	print('No')
else:
	for i in range(len(s) - 2):
		if s[i:i + 3] == '000':
			fl = True
	if fl:
		print('No')
	else:
		for i in range(n - 1):
			if s[i] + s[i + 1] == '11' or s[i] + s[i + 1] == '11':
				fl = True
		if fl:
			print('No')
		else:
			print('Yes')


input()
s = '0' + input() + '0'
if '11' in s:
	print('No')
	return
if '000' in s:
	print('No')
	return
print('Yes')


def check(s):
	s = '0' + s + '0'
	for i in range(1, len(s) - 1):
		if s[i] == '1' and (s[i - 1] == '1' or s[i + 1] == '1'):
			return False
		if s[i] == '0' and s[i - 1] == '0' and (s[i + 1] == '0'):
			return False
	return True
n = int(input())
s = input()
if check(s):
	print('Yes')
else:
	print('No')


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


def thr(arr):
	for i in range(len(arr)):
		s = arr[i]
		if i > 0:
			s += arr[i - 1]
		if i < len(arr) - 1:
			s += arr[i + 1]
		if arr[i] == 0 and s == 0 or (arr[i] == 1 and s > 1):
			return True
n = int(input())
s = list(map(int, input()))
if thr(s):
	print('No')
else:
	print('Yes')


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')
elif s == '010':
	print('YES')
else:
	print('NO')


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


n = int(input())
l = '0' + input() + '0'
o = 0
z = 0
flag = True
for i in l:
	if i == '0' and z < 2:
		z += 1
		o = 0
	elif i == '1' and o != 1:
		o = 1
		z = 0
	else:
		flag = False
		break
if flag:
	print('Yes')
else:
	print('No')


n = int(input())
s = input()
if s.count('11') > 0 or s.count('000') > 0 or (n == 1 and s == '0') or (n >= 2 and s[-1] == '0' and (s[-2] == '0')) or (n >= 2 and s[0] == '0' and (s[1] == '0')):
	print('NO')
else:
	print('YES')


input()
s = input()
ok = True
for i in range(len(s)):
	l = r = True
	if i > 0:
		l = s[i - 1] == '0'
	if i < len(s) - 1:
		r = s[i + 1] == '0'
	if s[i] == '0' and l and r:
		ok = False
	if s[i] == '1' and (not l or not r):
		ok = False
	if not ok:
		break
print('Yes' if ok else 'No')


n = int(input())
s = str(input())
if n == 1 and s[0] == '1':
	print('Yes')
	exit()
elif n == 1 and s[0] == '0':
	print('No')
	exit()
elif n == 2:
	if s == '01' or s == '10':
		print('Yes')
		exit()
	else:
		print('No')
		exit()
elif n % 2 == 0:
	for i in range(n - 2):
		if s[i] == '1' and s[i + 1] == '1' or (s[i + 1] == '1' and s[i + 2] == '1') or (s[i] == '0' and s[i + 1] == '0' and (s[i + 2] == '0')):
			print('No')
			exit()
	if s[-1] == '0' and s[-2] == '0' or (s[0] == '0' and s[1] == '0'):
		print('No')
	else:
		print('Yes')
else:
	for i in range(n - 2):
		if s[i] == '1' and s[i + 1] == '1' or (s[i + 1] == '1' and s[i + 2] == '1') or (s[i] == '0' and s[i + 1] == '0' and (s[i + 2] == '0')):
			print('No')
			exit()
	if s[-1] == '0' and s[-2] == '0' or (s[0] == '0' and s[1] == '0'):
		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')


import sys
amount = int(input())
string = input()
counter = 0
i = 0
string = '0' + string
string += '0'
for i in range(len(string) - 1):
	if string[i] == '1' and string[i + 1] == '1':
		print('No')
		sys.exit(0)
for i in range(len(string) - 2):
	if string[i] == '0' and string[i + 1] == '0' and (string[i + 2] == '0'):
		print('No')
		sys.exit(0)
print('Yes')


n = int(input())
k = '0' + input() + '0'
ans = 'YES'
for i in range(1, len(k) - 1):
	if k[i] == '1':
		if k[i - 1] == '1' or k[i + 1] == '1':
			ans = 'NO'
			break
	if k[i] == '0':
		if k[i - 1] == '0' and k[i + 1] == '0':
			ans = 'NO'
			break
if k == '0' or k == '00':
	ans = 'NO'
print(ans)


n = int(input())
ns = input()

def fun():
	if n == 1:
		if ns[0] == '1':
			return 'Yes'
		else:
			return 'No'
	for i in range(1, n):
		if ns[i] == '1' and ns[i - 1] == '1':
			return 'No'
	if n >= 2:
		if ns[0] == '0' and ns[1] == '0':
			return 'No'
		if ns[-1] == '0' and ns[-2] == '0':
			return 'No'
	num = 0
	for c in ns:
		if c == '0':
			num += 1
		if c == '1':
			num = 0
		if num > 2:
			return 'No'
	if num > 2:
		return 'No'
	return 'Yes'
print(fun())


from bisect import bisect_left, bisect_right

def tuple_input(type):
	return map(type, input().strip().split())
n = int(input())
s = list(input().strip())
for i in range(n):
	if s[i] == '0':
		if i == 0 or (i > 0 and s[i - 1] == '0'):
			if i + 1 == n or (i + 1 < n and s[i + 1] == '0'):
				print('No')
				exit(0)
	else:
		if i > 0 and s[i - 1] == '1':
			print('No')
			exit(0)
		if i + 1 < n and s[i + 1] == '1':
			print('No')
			exit(0)
print('Yes')


z = input
z()
b = '0' + z() + '0'
print('YNeos'['000' in b or '11' in b::2])


def main():
	n = int(input())
	s = input()
	if n == 1 and s[0] == '0':
		print('No')
		return
	if n >= 2:
		if s[0] == s[1] == '0' or s[0] == s[1] == '1' or s[n - 1] == s[n - 2] == '0' or (s[n - 1] == s[n - 2] == '1'):
			print('No')
			return
	for i in range(1, n - 1):
		(p, c, n) = map(int, (s[i - 1], s[i], s[i + 1]))
		if c == 1 and (p == 1 or n == 1) or (c == 0 and p == 0 and (n == 0)):
			print('No')
			return
	print('Yes')
main()


input()
a = '0' + input() + '0'
print('YNEOS'[a.count('000') > 0 or a.count('11') > 0::2])


n = int(input())
A = input()
good = True
if A == '0':
	good = False
for i in range(len(A) - 1):
	if A[i] == '1' and A[i + 1] == '1':
		good = False
good = good and all([len(x) <= 2 for x in A.split('1')])
good = good and len(A.split('1')[0]) < 2 and (len(A.split('1')[-1]) < 2)
if good:
	print('Yes')
else:
	print('No')


n = int(input())
seating = input()
l = 0
ok = True
for i in range(n):
	if seating[i] == '1':
		l = i + 1
		if i < n - 1 and seating[i + 1] == '1':
			print('No')
			ok = False
			break
	else:
		nums = i - l + 1
		if nums >= 3 or (i == n - 1 and nums == 2) or (i == 1 and nums == 2) or (n == 1 and nums == 1):
			print('No')
			ok = False
			break
if ok:
	print('Yes')


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


n = int(input())
s = input()
c = 0
if n == 1 and s == '1':
	print('Yes')
	c = 1
if c == 0 and n == 1 and (s == '0'):
	print('No')
	c = 1
if c == 0 and s == '00':
	print('No')
	c = 1
if c == 0 and ('11' in s or '000' in s):
	print('No')
	c = 1
if c == 0 and ('001' in s or '100' in s):
	if '001' in s and s.index('001') == 0:
		print('No')
		c = 1
	if c == 0 and '100' in s and (s[len(s) - 3:] == '100'):
		print('No')
		c = 1
if c == 0:
	print('Yes')


n = int(input())
seating = input().strip()
flag = False
if n >= 3:
	for i in range(n):
		if seating[i] == '1':
			if i == 0:
				if seating[i + 1] == '1':
					break
			elif i == n - 1:
				flag = True
				break
			elif seating[i - 1] == '1' or seating[i + 1] == '1':
				break
		elif i == 0:
			if seating[i + 1] == '0':
				break
		elif i == n - 1:
			if seating[i - 1] == '1':
				flag = True
		elif seating[i - 1] == '0' and seating[i + 1] == '0':
			break
elif n == 2:
	if seating == '01' or seating == '10':
		flag = True
elif seating == '1':
	flag = True
if flag:
	print('Yes')
else:
	print('No')


def main():
	n = lie()
	s = input()
	s = '0' + s + '0'
	for i in range(1, n + 1):
		if s[i - 1] == '0' and s[i] == '0' and (s[i + 1] == '0'):
			print('No')
			exit()
		if s[i] == '1' and s[i + 1] == '1':
			print('No')
			exit()
	print('Yes')

def binary(temp):
	s = ''
	while temp:
		s += str(temp % 2)
		temp //= 2
	return s[::-1]

def fun(s):
	if len(s) % 2 == 1:
		f = True
		k = (len(s) - 1) // 2
		for i in range(k + 1):
			if s[i] != '1':
				f = False
				break
		for i in range(k + 1, len(s)):
			if s[i] != '0':
				f = False
				break
		return f
	else:
		return False
from sys import *
import inspect
import re
from math import *
import threading
from collections import *
from pprint import pprint as pp
mod = 998244353
MAX = 10 ** 5

def lie():
	return int(input())

def liee():
	return map(int, input().split())

def array():
	return list(map(int, input().split()))

def deb(p):
	for line in inspect.getframeinfo(inspect.currentframe().f_back)[3]:
		m = re.search('\\bdeb\\s*\\(\\s*([A-Za-z_][A-Za-z0-9_]*)\\s*\\)', line)
		print('%s %d' % (m.group(1), p))

def vector(size, val=0):
	vec = [val for i in range(size)]
	return vec

def matrix(rowNum, colNum, val=0):
	mat = []
	for i in range(rowNum):
		collumn = [val for j in range(colNum)]
		mat.append(collumn)
	return mat

def dmain():
	setrecursionlimit(100000000)
	threading.stack_size(40960000)
	thread = threading.Thread(target=main)
	thread.start()
dmain()


N = int(input())
chairs = input()
ones = 0
zeros = 1
flag = 1
for i in range(N):
	if chairs[i] == '0':
		zeros += 1
		ones = 0
		if zeros == 3:
			print('No')
			flag = 0
			break
	elif chairs[i] == '1':
		ones += 1
		zeros = 0
		if ones == 2:
			print('No')
			flag = 0
			break
	else:
		ones = 0
		zeros = 0
if zeros == 2:
	print('No')
elif flag == 1:
	print('Yes')


a = int(input())
b = input()
masih = True
if '11' in b:
	masih = False
b = '0' + b + '0'
if '000' in b:
	masih = False
if masih:
	print('YES')
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'
if s[:2] == '00':
	ans = 'No'
if s[-2:] == '00':
	ans = 'No'
print(ans)


t = input()
s = input()
s = '0' + s + '0'
if s.find('000') != -1 or s.find('11') != -1:
	print('No')
else:
	print('Yes')


n = input()
s = input()
print(['No', 'Yes'][('000' not in s and '11' not in s) and (not s[:2] == '00') and (not s[-2:] == '00') and (not s == '0')])


def main():
	n = int(input())
	s = input()
	flag = False
	if n == 1:
		if s == '0':
			print('No')
		else:
			print('Yes')
		return
	for i in range(n):
		if s[i] == '1' and i + 1 < n:
			if s[i + 1] == '1':
				flag = True
				break
		if s[i] == '0':
			if 1 <= i < n - 1:
				if s[i - 1] == '0' and s[i + 1] == '0':
					flag = True
					break
			elif i == 0 and s[i + 1] == '0':
				flag = True
				break
			elif i == n - 1 and s[i - 1] == '0':
				flag = True
				break
	if flag:
		print('No')
	else:
		print('Yes')
main()


import sys
import math
n = int(input())
lista = str(input())
flag = False
for i in range(n - 1):
	if lista[i] == '1' and lista[i + 1] == '1':
		flag = True
	elif lista[i] == '0' and lista[i + 1] == '0':
		if i == n - 2 or i == 0:
			flag = True
		elif lista[i + 2] == '0':
			flag = True
	if flag == True:
		break
if n == 1 and lista == '0':
	flag = True
if flag == False:
	print('Yes')
else:
	print('No')


n = int(input())
s = input()
ok = 1
for i in range(n):
	if s[i] == '1':
		if i > 0:
			ok &= s[i - 1] == '0'
		if i < n - 1:
			ok &= s[i + 1] == '0'
	else:
		res = 0
		if i > 0:
			res |= s[i - 1] == '1'
		if i < n - 1:
			res |= s[i + 1] == '1'
		ok &= res
print('Yes' if ok else 'No')


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


n = int(input())
string = list(map(int, input()))
zeroCounter = 0
oneCounter = 0
execptionReached = False
if n >= 2:
	if string[0] == 0 and string[1] == 0 or (string[-1] == 0 and string[-2] == 0):
		print('No')
	else:
		for i in range(n):
			if string[i] == 0:
				oneCounter = 0
				zeroCounter += 1
				if zeroCounter == 3:
					print('No')
					execptionReached = True
					break
			else:
				oneCounter += 1
				zeroCounter = 0
				if oneCounter == 2:
					print('No')
					execptionReached = True
					break
		if not execptionReached:
			print('Yes')
elif string[0] == 0:
	print('No')
else:
	print('Yes')


n = int(input())
seats = input()
if n == 1:
	if seats == '1':
		print('yes')
	else:
		print('no')
elif n == 2:
	if seats == '10' or seats == '01':
		print('yes')
	else:
		print('no')
elif seats[:2] == '00' or seats[-2:] == '00' or seats.count('000') or seats.count('11'):
	print('no')
else:
	print('yes')


n = int(input())
a = str(input())
b = list(a)
for i in range(n):
	b[i] = int(b[i])
k = 0
if n == 1 and b[0] == 0:
	k = k + 1
if n == 2 and b[0] == b[1] == 0:
	k = k + 1
if n > 2:
	if b[0] == b[1] == 0:
		k = k + 1
	if b[n - 1] == b[n - 2] == 0:
		k = k + 1
if a.find('11') >= 0:
	k = k + 1
if a.find('000') >= 0:
	k = k + 1
if k == 0:
	print('Yes')
else:
	print('No')


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')


n = int(input())
a = input()
e = True
if n == 1 and a == '0':
	e = False
if n > 1 and (a[0] == a[1] == '0' or a[n - 1] == a[n - 2] == '0'):
	e = False
for i in range(1, n):
	if a[i - 1] == a[i] == '1':
		e = False
for i in range(2, n):
	if a[i - 2] == a[i - 1] == a[i] == '0':
		e = False
if e:
	print('Yes')
else:
	print('No')


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


n = int(input())
s = input()
f = True
if '000' in s or '11' in s:
	f = False
if n > 1:
	if s[0] == s[1] or s[n - 1] == s[n - 2]:
		f = False
elif s[0] == '0':
	f = False
if f:
	print('yes')
else:
	print('no')


n = int(input())
a = '#' + input().strip() + '#'
ans = 'Yes'
if n == 1 and a[1] == '0':
	ans = 'No'
else:
	for i in range(1, n + 1):
		if a[i] == '1':
			if a[i - 1] == '1' or a[i + 1] == '1':
				ans = 'No'
				break
		elif (a[i - 1] == '0' or a[i - 1] == '#') and (a[i + 1] == '0' or a[i + 1] == '#'):
			ans = 'No'
			break
print(ans)


def F(a):
	a = '0' + a + '0'
	if len(a) == 1:
		print('Yes')
		return
	else:
		if a.find('11') == -1:
			if a.find('000') == -1:
				print('Yes')
				return
		print('No')
		return
n = input()
a = str(input())
F(a)


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


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[0] == '0':
			bbbb = 0
	if a[-1] == a[-2]:
		if a[-1] == '0':
			bbbb = 0
	bb = 1
	if bbbb == 0:
		print('NO')
	else:
		for i in range(n - 1):
			if a[i] == a[i + 1]:
				if a[i] == '1':
					bb = 0
					break
		for i in range(n - 2):
			if a[i] == a[i + 1]:
				if a[i] == '0':
					if a[i + 2] == a[i]:
						bb = 0
						break
		if bb == 1:
			print('YES')
		else:
			print('NO')


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


n = int(input())
s = input()
t = 0 if s[0] == '0' else 1
for i in s[1:]:
	if i == '0':
		if t == -1:
			t = -100
			break
		t -= 1
	else:
		if t == 1:
			t = -100
			break
		t = 1
print('No' if t == -100 or s == '0' or s[:2] == '00' or (s[n - 2:] == '00') else 'Yes')


def main():
	input()
	seat = input()
	if '11' in seat or '000' in seat or seat.startswith('00') or seat.endswith('00') or (seat == '0'):
		print('No')
	else:
		print('Yes')
main()


n = int(input())
s = input()
flag = True
zero = 0
one = 0
for i in range(len(s)):
	if s[i] == '0':
		if one >= 2:
			flag = False
			break
		zero += 1
		one = 0
	else:
		one += 1
		if zero >= 3:
			flag = False
			break
		zero = 0
if n == 1:
	if s == '0':
		print('No')
	else:
		print('Yes')
elif s[:2] == '00' or s[:2] == '11':
	print('No')
elif s[-2:] == '00' or s[-2:] == '11':
	print('No')
elif flag:
	print('Yes')
else:
	print('No')


input()
s = input()
f = 1
if len(s) > 1:
	for i in range(len(s)):
		if s[i] == '0':
			if i == 0 and s[i + 1] == '0':
				f = 0
				break
			elif i == len(s) - 1 and s[i - 1] == '0':
				f = 0
				break
			elif s[i - 1] == '0' and s[i + 1] == '0':
				f = 0
				break
		elif i != len(s) - 1 and s[i + 1] == '1':
			f = 0
			break
		elif i != 0 and s[i - 1] == '1':
			f = 0
			break
if f == 1 and s != '0':
	print('Yes')
else:
	print('No')


n = int(input())
s = input()
q = s[::-1]
if n == 1:
	if s[0] == '0':
		print('No')
		exit(0)
if s.find('11') != -1:
	print('No')
	exit(0)
if s.find('000') != -1:
	print('No')
	exit(0)
if q[:2] == '00' or s[:2] == '00':
	print('No')
	exit(0)
print('Yes')


import sys

def main():
	n = int(sys.stdin.readline().strip('\n'))
	s = sys.stdin.readline().strip('\n')
	s = '0' + s + '0'
	if '11' in s or '000' in s:
		print('NO')
	else:
		print('YES')
main()


n = int(input())
s = str(input())
if n == 1:
	if s[0] == '1':
		print('Yes')
	else:
		print('No')
else:
	flag1 = 0
	for i in range(n - 1):
		if s[i] == s[i + 1]:
			if s[i] == '1':
				flag1 = 1
				break
	if s[0] == '0' and s[1] == '0':
		flag1 = 1
	if s[n - 2] == '0' and s[n - 1] == '0':
		flag1 = 1
	k = s.count('000')
	if k > 0:
		flag1 = 1
	if flag1 == 1:
		print('No')
	else:
		print('Yes')


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

def solve(n, s):
	if '11' in s:
		return False
	if '000' in s:
		return False
	if s.endswith('00') or s.startswith('00'):
		return False
	if s == '0':
		return False
	return True
if solve(n, s):
	print('Yes')
else:
	print('No')


n = int(input())
line = input()
for i in range(1, n):
	if line[i] == line[i - 1] and line[i] == '1':
		print('No')
		exit()
	if i > 1 and line[i] == line[i - 1] and (line[i - 1] == line[i - 2]):
		print('No')
		exit()
if len(line) > 1 and line[0] == '0' and (line[1] == '0'):
	print('No')
	exit()
if len(line) > 1 and line[len(line) - 1] == '0' and (line[len(line) - 2] == '0'):
	print('No')
	exit()
if len(line) == 1 and line[0] == '0':
	print('No')
else:
	print('Yes')


import sys

def main():
	n = int(sys.stdin.readline().strip('\n'))
	s = sys.stdin.readline().strip('\n')
	s = '0' + s + '0'
	if n == 1 and s == '0' or (n == 2 and s == '00'):
		print('NO')
	else:
		for i in range(n + 2):
			if i <= n and s[i] + s[i + 1] == '11':
				print('NO')
				break
			if i <= n - 1 and s[i] + s[i + 1] + s[i + 2] == '000':
				print('NO')
				break
		if i == n + 1:
			print('YES')
main()


n = int(input())
s = input()
i = 2
ans = 1
while i < n:
	if s[i] == s[i - 1] and s[i] == '1':
		ans = 0
		break
	if s[i] == s[i - 1] and s[i] == s[i - 2]:
		ans = 0
		break
	i += 1
if n > 1 and s[0] == s[1]:
	ans = 0
if n > 1 and s[n - 1] == s[n - 2]:
	ans = 0
if n == 1 and s[0] == '0':
	ans = 0
if ans == 1:
	print('Yes')
else:
	print('No')


n = int(input())
a = input()
c = 0
for i in range(n):
	if n > 1:
		if i == 0:
			if a[0] + a[1] == '10' or a[0] + a[1] == '01':
				continue
			else:
				print('No')
				c = 1
				break
		elif i == n - 1:
			if a[n - 2] + a[n - 1] == '10' or a[n - 2] + a[n - 1] == '01':
				continue
			else:
				print('No')
				c = 1
				break
		elif a[i] == '1':
			if a[i - 1] + a[i + 1] == '10':
				print('No')
				c = 1
				break
			if a[i - 1] + a[i + 1] == '01':
				print('No')
				c = 1
				break
			if a[i - 1] + a[i + 1] == '11':
				print('No')
				c = 1
				break
			else:
				continue
		else:
			if a[i - 1] + a[i + 1] == '10':
				continue
			if a[i - 1] + a[i + 1] == '01':
				continue
			if a[i - 1] + a[i + 1] == '11':
				continue
			else:
				print('No')
				c = 1
				break
	elif a == '0':
		print('No')
		c = 1
		break
if c == 0:
	print('Yes')


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


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


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