ZhenlongDai/ACPR huggingface dataset:
Problem: p02953
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
h = list(map(int, input().split()))

res = 'Yes'
hmax = 0
tmp = 0

for i in h:
    if tmp > i:
        hmax = tmp
    if hmax >= i+1:
        res = 'No'
        break
    tmp = i

print(res)

Failing test case input:
5
0 1 0 0 6

Expected output:
Yes


Actual output:
No


Fixed submission (verdict: Accepted):
n = int(input())
h = list(map(int, input().split()))

res = 'Yes'
hmax = 0
tmp = 0

for i in h:
    if hmax < tmp:
        hmax = tmp
    if hmax >= i+2:
        res = 'No'
        break
    tmp = i

print(res)

Problem: p02953
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N=int(input())
H=[int(i) for i in input().split()]
A=1
if N>1:
    for i in range(N-1):
        if H[-i-1] <= H[-i]:
            A+=1
        elif H[-i-1]-1 == H[-1]:
            A+=1
            H[-i-1]-=1
    if A==N:
        print('Yes')
    else:
        print('No')
elif N==1:
    print('Yes')


Failing test case input:
5
1 2 3 6 5

Expected output:
Yes


Actual output:
No


Fixed submission (verdict: Accepted):
N=int(input())
H=[int(i) for i in input().split()]
A=1
if N>1:
    for i in range(N-1):
        if H[-(i+1)-1] <= H[-(i+1)]:
            A+=1
        elif H[-(i+1)-1]-1 == H[-(i+1)]:
            A+=1
            H[-(i+1)-1]-=1
    if A==N:
        print('Yes')
    else:
        print('No')
elif N==1:
    print('Yes')

Problem: p02953
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
def getlist():
    return list(map(int, input().split()))


N = int(input())
H = getlist()

j = "Yes"
val = H[0]
for i in range(1, N):
    if H[i] > val:
        val = H[i]
    else:
        if H[i] + 2 < val:
            j = "No"
            break

print(j)

Failing test case input:
5
0 2 0 1 3

Expected output:
No


Actual output:
Yes


Fixed submission (verdict: Accepted):
def getlist():
    return list(map(int, input().split()))


N = int(input())
H = getlist()

j = "Yes"
val = H[0]
for i in range(1, N):
    if H[i] > val:
        val = H[i]
    else:
        if H[i] + 2 <= val:
            j = "No"
            break

print(j)

Problem: p02953
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
from sys import stdin
def ii(): return int(stdin.readline())
def mi(): return map(int, stdin.readline().split())
def li(): return list(mi())
n=ii()-2
a=li()
for i in range(n, -1, -1):
    if a[i]>a[i+1]:
        a[i]-=1
        if a[i]>a[i-1]:
            print('No')
            exit()
print('Yes')

Failing test case input:
5
5 3 -1 -1 4

Expected output:
No


Actual output:
Yes


Fixed submission (verdict: Accepted):
from sys import stdin
def ii(): return int(stdin.readline())
def mi(): return map(int, stdin.readline().split())
def li(): return list(mi())
n=ii()-2
a=li()
for i in range(n, -1, -1):
    if a[i]>a[i+1]:
        a[i]-=1
        if a[i]>a[i+1]:
            print('No')
            exit()
print('Yes')
Problem: p02953
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
N = int(input())
H = list(map(int,input().split()))

maxH = 0
for i in range(N-1):
  if H[i+1] >= maxH-1:
    maxH = max(maxH,H[i+1])
  else:
    print("No")
    print(maxH)
    exit()
    
print("Yes")

Failing test case input:
5
1 2 0 1 3

Expected output:
No


Actual output:
No
2


Fixed submission (verdict: Accepted):
N = int(input())
H = list(map(int,input().split()))

maxH = 0
for i in range(N-1):
  if H[i+1] >= maxH-1:
    maxH = max(maxH,H[i+1])
  else:
    print("No")
    exit()
    
print("Yes")

Problem: p02953
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
H = list(map(int, input().split()))

def f():
    if N == 1:
        return True

    for i in range(N - 1):
        if H[i + 1] - H[i] >= 2:
            return False

    return True

print("Yes" if f() else "No")

Failing test case input:
5
0 0 0 0 9

Expected output:
Yes


Actual output:
No


Fixed submission (verdict: Accepted):
N = int(input())
H = list(map(int, input().split()))[::-1]

def f():
    if N == 1:
        return True

    for i in range(N - 1):
        if H[i] >= H[i + 1]:
            continue

        d = H[i + 1] - H[i]
        if d == 1:
            H[i + 1] -= 1
            continue

        return False

    return True


print("Yes" if f() else "No")

Problem: p02953
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n=int(input())
h=list(map(int,input().split()))
ans="Yes"
if n>2:
  for i in range(n-2):
    if h[i]-2>h[i+2]:
      ans="No"
      break
elif n==2 and h[0]-2>h[1]:
    ans="No"
print(ans)

Failing test case input:
4
0 0 4 0

Expected output:
No


Actual output:
Yes


Fixed submission (verdict: Accepted):
n=int(input())
h=list(map(int,input().split()))
ans="Yes"
if n>3:
  m=h.pop(0)
  for i in h:
    if m<i:
      m=i
    elif m-1>i:
      ans="No"
      break
elif n==3 and (h[0]-1>h[2] or h[1]-1>h[2]):
    ans="No"
elif n==2 and h[0]-1>h[1]:
    ans="No"
print(ans)

Problem: p02953
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

n, *h = map(int, read().split())

if len(h) == 1:
    print('Yes')
    exit()
l = [max(h[0]-1,1)]
for i in range(1, n):
    if 1 <= h[i] - l[i - 1] <= 2:
        l.append(h[i] - 1)
    elif h[i] - l[i - 1] == 0:
        l.append(h[i])
    else:
        print('No')
        exit()

print('Yes')

Failing test case input:
5
0 1 0 2 3

Expected output:
Yes


Actual output:
No


Fixed submission (verdict: Accepted):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

n, *h = map(int, read().split())
if len(h) == 1:
    print('Yes')
    exit()

h = h[::-1]

for i in range(1, n):
    if h[i - 1] < h[i]:
        h[i] -= 1
    if h[i - 1] < h[i]:
        print('No')
        exit()

print('Yes')
Problem: p02953
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
H = [int(i) for i in input().split()]

ans = "Yes"

for i in range(N):
  if i == 0:
    H[0] -= 1
  else:
    if H[i-1] ==  H[i]:
      H[i-1] = H[i]
    elif H[i-1] > H[i]-1:
      print(i)
      ans = "No"
      break
    else:
      H[i] -= 1

print(ans)


Failing test case input:
5
0 2 0 2 5

Expected output:
No


Actual output:
2
No


Fixed submission (verdict: Accepted):
N = int(input())
H = [int(i) for i in input().split()]

ans = "Yes"

for i in range(N):
  if i == 0:
    H[0] -= 1
  else:
    if H[i-1] ==  H[i]:
      H[i-1] = H[i]
    elif H[i-1] > H[i]-1:
      ans = "No"
      break
    else:
      H[i] -= 1

print(ans)

Problem: p02953
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
N = int(input())
H = list(map(int, input().split()))
flag = True

for i in range(0, N-1):
  if H[i] - H[i+1] == -1:
    H[i+1] -= 1
  elif H[i] - H[i-1] > 1:
    flag = False
    break
  
if flag:
  print("Yes")
else:
  print("No")
    
  

Failing test case input:
5
4 3 1 -1 4

Expected output:
No


Actual output:
Yes


Fixed submission (verdict: Accepted):
N = int(input())
H = list(map(int, input().split()))
flag = True

for i in range(N-1):
  if H[i] - H[i+1] == 1:
    H[i+1]+= 1
  elif H[i] - H[i+1] > 1:
    flag = False
    break

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

Problem: p02953
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n=int(input())
h=list(map(int,input().split()))
ans='Yes'
for i in range(n-1,0,-1):
    print(h[i])
    if h[i]>=h[i-1]:
        continue
    elif h[i]+1==h[i-1]:
        h[i-1]-=1
    else:
        ans='No'
print(ans)

Failing test case input:
4
2 0 18 1

Expected output:
No


Actual output:
1
18
0
No


Fixed submission (verdict: Accepted):
n=int(input())
h=list(map(int,input().split()))
ans='Yes'
for i in range(n-1,0,-1):
    if h[i]>=h[i-1]:
        continue
    elif h[i]+1==h[i-1]:
        h[i-1]-=1
    else:
        ans='No'
print(ans)

Problem: p02953
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):

N = int(input())

H = list(map(int,input().split()))

for i in range(1,len(H)):
    if H[i-1] > H[i]:
        H[i-1] -= 1
        if  H[i-1] > H[i]:
            print('No')
            exit()

print('Yes')

Failing test case input:
4
1 3 2 1

Expected output:
No

Actual output:
Yes


Fixed submission (verdict: Accepted):
N = int(input())
H = list(map(int, input().split()))
a = H[0]
for i in range(1,N-1):
    a = max(H[i], a)
    b = H[i+1]
    if a - b >= 2:
        print("No")
        exit()
print("Yes")

Problem: p02953
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n=int(input())
a=[0]+list(map(int,input().split()))+[1e9+1]
for i in range(1,n+1):
    if a[i-1]<a[i]:
        a[i]-=1
    if a[i]>a[i+1]-1:
        print("No")
        break
else:
    print("Yes")

Failing test case input:
5
0 1 0 0 10

Expected output:
Yes


Actual output:
No


Fixed submission (verdict: Accepted):
n=int(input())
a=list(map(int,input().split()))
for i in range(1,n):
    if a[i-1]<a[i]:
        a[i]-=1
    if a[i-1]>a[i]:
        print("No")
        break
else:
    print("Yes")
Problem: p02953
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N=int(input())
H=list(map(int,input().split()))
A=0
for i in range(N-1):
    if H[i]-H[i+1]>1 :
        print('No')
        break
    elif H[i]-H[i+1]==1:
        H[i+1]=H[i+1]-1
    else:
        continue
print('Yes')

Failing test case input:
5
0 2 0 0 6

Expected output:
No


Actual output:
No
Yes


Fixed submission (verdict: Accepted):
import sys
N=int(input())
H=list(map(int,input().split()))
A=0
for i in range(N-1):
    if H[i]-H[i+1]>1 :
        print('No')
        sys.exit()
    elif H[i]-H[i+1]==1:
        H[i+1]=H[i+1]+1
    else:
        continue
print('Yes')

Problem: p02953
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
n=int(input())
l = list(map( int, input().split()))
for i in range(n-1):
  if not l[i+1]>=(l[i] -1):
    print('No',l[i]);  break
else: 
  print('Yes')

Failing test case input:
5
4 2 -1 1 2

Expected output:
No


Actual output:
No 4


Fixed submission (verdict: Accepted):
n = int(input())
a = list(map(int, input().split()))
p = 0
for i in a:
  if p > i:
    print('No')
    exit()
  if p < i:
    p = i - 1
print('Yes')

Problem: p02953
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
Hs = [int(i) for i in input().split()]

is_Yes = True
for i in range(1, N-1):
    if Hs[i-1] == Hs[i]:
        continue
    elif Hs[i] > Hs[i-1]:
        Hs[i] -= 1
    else:
        is_Yes = False
        break

if is_Yes:
    print('Yes')
else:
    print('No')


Failing test case input:
4
0 0 7 1

Expected output:
No


Actual output:
Yes


Fixed submission (verdict: Accepted):
N = int(input())
Hs = [int(i) for i in input().split()]

is_Yes = True
for i in range(1, N):
    if Hs[i-1] == Hs[i]:
        continue
    elif Hs[i] > Hs[i-1]:
        Hs[i] -= 1
    else:
        is_Yes = False
        break

if is_Yes:
    print('Yes')
else:
    print('No')

Problem: p02953
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
h = list(map(int, input().split()))
for i in range(n - 2, -1, -1):
  if h[i] == h[i + 1] + 1:
    h[i] -= 1
  elif h[i] == h[i + 1]:
    pass
  else:
    print('No')
    exit()
print('Yes')

Failing test case input:
5
0 0 0 0 9

Expected output:
Yes


Actual output:
No


Fixed submission (verdict: Accepted):
n = int(input())
h = list(map(int, input().split()))
for i in range(n - 2, -1, -1):
  if h[i] == h[i + 1] + 1:
    h[i] -= 1
  elif h[i] - h[i + 1] >= 2:
    print('No')
    exit()
print('Yes')

Problem: p02953
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
A = list(map(int, input().split()))

flag = True
for i in range(n-1, 0, -1):
    if A[i-1] >= A[i] + 2:
        flag = False
        break
    elif A[i-1] == A[i] + 1:
        A[i-1] -= 1

if flag:
    print("YES")
else:
    print("NO")

Failing test case input:
5
1 2 0 1 5

Expected output:
No


Actual output:
NO


Fixed submission (verdict: Accepted):
n = int(input())
A = list(map(int, input().split()))

flag = True
for i in range(n-1, 0, -1):
    if A[i-1] >= A[i] + 2:
        flag = False
        break
    elif A[i-1] == A[i] + 1:
        A[i-1] -= 1

if flag:
    print("Yes")
else:
    print("No")
Problem: p02953
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
h = list(map(int, input().split()))

ans = 0

if n == 1:
	print('Yes')

else:
	for i in range(n-2):
		if h[i] + 1 == h[i + 1]:
			print('Yes')
			break
		elif h[i] == h[i + 1]:
			continue
		else:
			print('No')
			break


Failing test case input:
5
1 2 0 1 3

Expected output:
No


Actual output:
Yes


Fixed submission (verdict: Accepted):
n = int(input())
h = list(map(int, input().split()))

check = 0

if n == 1:
	print('Yes')

else:
	for i in range(n-2):
		if h[i] < h[i+1]:
			h[i+1] -= 1
	for i in range(n-1):
		if h[i] > h[i+1]:
			print('No')
			break
		if h[i] <= h[i+1]:
			check += 1
	if check == n-1:
		print('Yes')

Problem: p02953
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
A = list(map(int, input().split()))
if N > 1:
    A[0] -= 1
    for i in range(1,N-1):
        if A[i]<A[i+1]:
            A[i+1] -= 1
    for i in range(N-1):
        if A[i] > A[i+1]:
            print("No")
            break
    else:
        print("Yes")
elif N == 1:
    print("Yes")


Failing test case input:
5
0 1 0 1 3

Expected output:
Yes


Actual output:
No


Fixed submission (verdict: Accepted):
N = int(input())
A = list(map(int, input().split()))
if N > 1:
    A[0] -= 1
    for i in range(N-1):
        if A[i]<A[i+1]:
            A[i+1] -= 1
    for i in range(N-1):
        if A[i] > A[i+1]:
            print("No")
            break
    else:
        print("Yes")
elif N == 1:
    print("Yes")

Problem: p02953
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N=int(input())
H=list(map(int, input().split()))

if N==1:
    print('Yes')
    exit()

for ii in range( N-1 ):
    if H[ii]<=H[ii+1] or H[ii]-1==H[ii+1]:
        continue
    else:
        print('No')
        exit()

print('Yes')


Failing test case input:
4
1 3 2 1

Expected output:
No

Actual output:
Yes


Fixed submission (verdict: Accepted):
N=int(input())
H=list(map(int, input().split()))

if N==1:
    print('Yes')
    exit()

for ii in reversed( range(1, N) ):
    if H[ii-1] <= H[ii]:
        continue
    elif H[ii-1] - 1 == H[ii]:
        H[ii-1] -= 1
    else:
        print('No')
        exit()

print('Yes')

Problem: p02953
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
def solve():
    n = int(input())
    h = list(map(int, input().split()))
    flag = True
    for i in range(1, n):
        if abs(h[i]-h[i-1]) <= 1:
            flag = False
            break
    if flag:
        print('Yes')
    else:
        print('No')


solve()


Failing test case input:
4
2 0 5 1

Expected output:
No


Actual output:
Yes


Fixed submission (verdict: Accepted):
def solve():
    n = int(input())
    h = list(map(int, input().split()))
    right = h[len(h)-1]
    flag = True
    for i in reversed(h):
        if i <= right:
            right = i
            continue
        elif i-1 == right:
            continue
        else:
            flag = False
            break
    if flag:
        print('Yes')
    else:
        print('No')


solve()
Problem: p02953
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
N = int(input())
H = list(map(int, input().split()))
flag = True

for i in range(1, N):
  if H[i] - H[i-1] == 1:
    H[i] -= 1
  elif H[i] - H[i-1] < 0:
    flag = False
    break

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

Failing test case input:
5
1 2 3 6 5

Expected output:
Yes


Actual output:
No


Fixed submission (verdict: Accepted):
N = int(input())
H = list(map(int, input().split()))
flag = True

for i in range(N-1):
  if H[i] - H[i+1] == 1:
    H[i+1]+= 1
  elif H[i] - H[i+1] > 1:
    flag = False
    break

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

Problem: p02953
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
h = [int(i) for i in input().split()]
if h[0] != 1:
    h[0] -= 1
if len(h) == 1:
    print('Yes')
else:
    for i in range(1, n):
        if h[i - 1] < h[i]:
            h[i] -= 1
        elif h[i - 1] > h[1]:
            print('No')
            exit()
    print('Yes')


Failing test case input:
5
0 3 0 1 3

Expected output:
No


Actual output:
Yes


Fixed submission (verdict: Accepted):
n = int(input())
h = [int(i) for i in input().split()]
h[0] -= 1
flag = [True]
if len(h) == 1:
    print('Yes')
else:
    for i in range(1, n):
        if h[i] > h[i - 1]:
            h[i] -= 1
        elif h[i] < h[i - 1]:
            print('No')
            exit()
    print('Yes')

Problem: p02953
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
import sys
import heapq
from decimal import Decimal

input = sys.stdin.readline

n = int(input())
h_list = list(map(int, input().split()))

tmp = 0
flag = False

for h in h_list:

    if tmp == 0:
        tmp = h
        continue

    if tmp > h:
        tmp = h
        if flag:
            print("No")
            exit(0)
        else:
            flag = True
    else:
        tmp = h
        flag = False

print("Yes")


Failing test case input:
5
0 2 0 1 3

Expected output:
No


Actual output:
Yes


Fixed submission (verdict: Accepted):
import sys

input = sys.stdin.readline

n = int(input())
h_list = list(map(int, input().split()))

tmp = 0
flag = False

for h in h_list:

    if tmp == 0:
        tmp = h
        continue

    if tmp > h:
        if tmp - 2 >= h:
            print("No")
            exit(0)
        tmp = h
        if flag:
            print("No")
            exit(0)
        else:
            flag = True
    elif tmp < h:
        tmp = h
        flag = False

print("Yes")

Problem: p02953
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import sys

n = int(sys.stdin.readline())
h = list(map(int, sys.stdin.readline().split()))

ans = 'Yes'
for i in range(n - 1):
    if h[i + 1] - h[i] < 0:
        ans = 'No'
        break
    elif h[i + 1] - h[i] == 1:
        h[i + 1] -= 1
print(ans)


Failing test case input:
5
1 2 3 6 5

Expected output:
Yes


Actual output:
No


Fixed submission (verdict: Accepted):
import sys

n = int(sys.stdin.readline())
h = list(map(int, sys.stdin.readline().split()))

ans = 'Yes'
h[0] -= 1
for i in range(n - 1):
    if h[i + 1] < h[i]:
        ans = 'No'
        break
    elif h[i + 1] > h[i]:
        h[i + 1] -= 1
print(ans)
Problem: p02953
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
n = int(input())
aaa = list(map(int, input().split(' ')))
before = 0
ans = 'Yes'
for i in range(n-1):
    if aaa[i] == aaa[i+1] - 1:
        aaa[i] -= 1
for i in range(n-1):
    if aaa[i] > aaa[i+1]:
        ans = 'No'
print(ans)

Failing test case input:
5
0 1 0 0 6

Expected output:
Yes


Actual output:
No


Fixed submission (verdict: Accepted):
n = int(input())
aaa = list(map(int, input().split(' ')))
before = 0
ans = 'Yes'
for i in range(n-2, -1, -1):
    if aaa[i] == aaa[i+1] + 1:
        aaa[i] -= 1
for i in range(n-1):
    if aaa[i] > aaa[i+1]:
        ans = 'No'
print(ans)

Problem: p02953
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
H = list(map(int, input().split()))

lis = list()
for i in range(len(H)-1):
    if H[i] - H[i+1] < -1:
        H[i+1] = H[i+1] - 1
        lis.append(1)
    else:
        lis.append(0)

if all(lis):
    print("Yes")
else:
    print("No")

Failing test case input:
5
1 2 3 4 5

Expected output:
Yes

Actual output:
No


Fixed submission (verdict: Accepted):
N = int(input())
H = list(map(int,input().split()))
H_max = 0

for i in range(N-1):
    if H_max < H[i]:
        H_max = H[i]
    if H[i+1] < H_max - 1:
        print("No")
        break
else:
    print("Yes")

Problem: p02953
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n= int(input())
h = list(map(int,input().split()))
count=0
mainasu=0
for i in range(n-1):
  if h[i]<=h[i+1]:
    count+=1 
  elif (h[i]-1)==h[i+1] and mainasu==0:
      mainasu+=1
if count==n-1:
  print("Yes")
else:
  print("No")

Failing test case input:
5
0 1 0 2 5

Expected output:
Yes


Actual output:
No


Fixed submission (verdict: Accepted):
n= int(input())
h = list(map(int,input().split()))
count=0
a=h[0]
for i in range(n-1):
  if a<h[i+1]:
    count+=1
    a=(h[i+1]-1)
  if a==h[i+1]:
    a=h[i+1]
    count+=1
if count==(n-1):
  print("Yes")
else:
  print("No")

Problem: p02953
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n= int(input())
h = list(map(int,input().split()))
count=0
mainasu=0
for i in range(n-1):
  if h[i]<=h[i+1]:
    count+=1 
  elif (h[i]-1)==h[i+1] and mainasu==0:
    mainasu=1
    count+=1
if count==n-1:
  print("Yes")
else:
  print(count)

Failing test case input:
5
4 2 -2 1 3

Expected output:
No


Actual output:
2


Fixed submission (verdict: Accepted):
n= int(input())
h = list(map(int,input().split()))
count=0
a=h[0]
for i in range(n-1):
  if a<h[i+1]:
    count+=1
    a=(h[i+1]-1)
  if a==h[i+1]:
    a=h[i+1]
    count+=1
if count==(n-1):
  print("Yes")
else:
  print("No")
Problem: p02953
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
H = list(map(int,input().split()))
cnt = 0
for i in range(N-1):
  if H[i]-H[i+1]==1:
    H[i] = H[i]-1
  elif H[i]-H[i+1]>1:
    cnt = 1
    break
if cnt == 0:
  print('Yes')
else:
  print('No')

Failing test case input:
4
1 3 2 1

Expected output:
No

Actual output:
Yes


Fixed submission (verdict: Accepted):
N = int(input())
H = list(map(int,input().split()))
H.reverse()
cnt = 0
for i in range(N-1):
  if H[i+1]-H[i]==1:
    H[i+1] = H[i+1]-1
  elif H[i+1]-H[i]>1:
    cnt = 1
    break
if cnt == 0:
  print('Yes')
else:
  print('No')

Problem: p02953
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n=int(input())
a=list(map(int,input().split()))
b=0
for i in range(n-1):
  if a[i]-a[i+1]>=2:
    b+=1
if b==0:
  print("Yes")
else:
  print("No")



Failing test case input:
4
1 3 2 1

Expected output:
No

Actual output:
Yes


Fixed submission (verdict: Accepted):
n=int(input())
a=list(map(int,input().split()))
b=0
c=a.reverse()
d=0
for i in range(n-1):
  if a[i]-a[i+1]==-1:
    a[i+1]=a[i+1]-1
  elif a[i]-a[i+1]<=-2:
    b+=1
  else:
    d=d
    
if b==0:
  print("Yes")
else:
  print("No")

Problem: p02953
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
h = list(map(int, input().split()))
x = h[-1]
ans = "Yes"
for i in reversed(range(n - 1)):
    hi = h[i]
    if hi <= x:
        pass
    else:
        if abs(x - hi) >= 2:
            ans = "No"
        else:
            h[i] -= 1
print(ans)


Failing test case input:
5
5 3 -1 -1 4

Expected output:
No


Actual output:
Yes


Fixed submission (verdict: Accepted):
n = int(input())
h = list(map(int, input().split()))
x = h[-1]
ans = "Yes"
for i in reversed(range(n - 1)):
    hi = h[i]
    if hi <= x:
        pass
    else:
        if abs(x - hi) >= 2:
            ans = "No"
        else:
            h[i] -= 1
    x = h[i]
print(ans)

Problem: p02953
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
h = list(map(int,input().split()))
th = h[0]
flag = 0
res = 'Yes'
if n != 1:
    for i in range(1,n):
        if h[i]<th:
            h[i] -= 1
        if h[i]<th:
            res = 'No'
            break
        th = h[i]

print(res)

Failing test case input:
5
1 2 3 6 5

Expected output:
Yes


Actual output:
No


Fixed submission (verdict: Accepted):
n = int(input())
h = list(map(int,input().split()))
res = 'Yes'
if n != 1:
    for i in range(n-1,0,-1):
        if h[i]<h[i-1]:
            h[i-1] -= 1
        if h[i]<h[i-1]:
            res = 'No'
            break
print(res)

Problem: p02953
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
a = list(map(int, input().split()))

prev = 0
for v in a:
    if not (v - prev >= -1):
        print("No")
        break
    prev = v
else:
    print("Yes")


Failing test case input:
4
1 3 2 1

Expected output:
No

Actual output:
Yes


Fixed submission (verdict: Accepted):
n = int(input())
a = list(map(int, input().split()))

prev = 0
for v in a:
    if v > prev:
        v -= 1
    if v < prev:
        print("No")
        break
    prev = v
else:
    print("Yes")
Problem: p02953
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
A = list(map(int,input().split()))
ans = 0
for i in range(n-1):
  if A[i+1]-A[i] >= -1:
    if max(A[i],A[i+1]) >= ans:
      ans = max(A[i]-1,A[i+1]-1,ans)
      print(i)
    else:
      print('No')
      exit()
  else:
    print('No')
    exit()
print('Yes')

Failing test case input:
5
1 4 0 1 5

Expected output:
No


Actual output:
0
No


Fixed submission (verdict: Accepted):
n = int(input())
A = list(map(int,input().split()))
ans = 0
for i in range(n-1):
  if ans > A[i+1]:
    print('No')
    exit()
  if A[i+1]-A[i] >= -1:
    ans = max(A[i+1]-1,A[i]-1,ans)
    if A[i+1] >= A[i] and A[i+1] > ans :
      A[i+1] -=1
  else:
    print('No')
    exit()
print('Yes')

Problem: p02953
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
N=int(input())
List = list(map(int, input().split()))
flg = True
if N ==1: print("Yes")
else:
  for i in range(1,N):
    if List[i]>=List[i-1] or List[i]-1>=List[i-1]:
      pass
    else:
      flg=False
      break
  if flg:
    print("Yes")
  else:
    print("No")

Failing test case input:
5
0 1 0 1 3

Expected output:
Yes


Actual output:
No


Fixed submission (verdict: Accepted):
N=int(input())
List = list(map(int, input().split()))
flg = True
if N ==1: print("Yes")
else:
  for i in range(1,N):
    if List[i]==List[i-1]:
      pass
    elif List[i]>List[i-1] or List[i]-1>=List[i-1]:
      List[i] = List[i]-1
    else:
      flg=False
      break
  if flg:
    print("Yes")
  else:
    print("No")

Problem: p02953
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
H = list(map(int,input().split()))
for i in range(N-1):
    if H[i] < H[i+1]:
        pass
    elif H[i] == H[i+1]:
        for k in range(i+2, N-1):
            if H[i] < H[k]:
                pass
            else:
                H[i] = H[i] - 1
                break
    else:
        H[i] = H[i]-1

count = 0
for j in range(N-1):
    if H[j] <= H[j+1]:
        count = count + 1
    else:
        count = -1
        break

if 0 <= count <= N:
    print("YES")
else:
    print("NO")


Failing test case input:
5
4 3 0 -1 4

Expected output:
No


Actual output:
NO


Fixed submission (verdict: Accepted):
N = int(input())
H = list(map(int,input().split()))

for i in range(1, N):
    H[i] = H[i] - 1
    if H[i] < H[i-1]:
        H[i] = H[i] + 1
    else:
        pass


count = 0
for k in range(N-1):
    if H[k] <= H[k + 1]:
        count = count + 1
    else:
        count = -1
        break

if 0 <= count <= N:
    print("Yes")
else:
    print("No")

Problem: p02953
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
n = int(input())
h = list(map(int,input().split()))
m = h[0]
for i in range(1,n-1):
    m = max(m,h[i])
    if h[i] >= m-1:
        continue
    print('No')
    exit()


print('Yes')

Failing test case input:
4
1 3 2 1

Expected output:
No

Actual output:
Yes


Fixed submission (verdict: Accepted):
n = int(input())
h = list(map(int,input().split()))
m = h[0]
for i in range(1,n):
    m = max(m,h[i])
    if h[i] >= m-1:
        continue
    print('No')
    exit()


print('Yes')
Problem: p02953
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
h = list(map(int,input().split()))

for i in range(1, n-1):
    if h[i] - 1 == h[i-1]:
        h[i] = h[i]-1

for j in range(n-1):
    if h[j] > h[j+1]:
        print("No")
        exit()

print("Yes")

Failing test case input:
5
1 2 3 6 5

Expected output:
Yes


Actual output:
No


Fixed submission (verdict: Accepted):
n = int(input())
h = list(map(int,input().split()))

for i in range(n-1,0,-1):
    if h[i-1] - 1 == h[i]:
        h[i-1] -= 1

for j in range(n-1):
    if h[j] > h[j+1]:
        print('No')
        break
else:
    print('Yes')

Problem: p02953
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
h = [int(i) for i in input().split()]

if N > 1:
    for i in range(N-2):
        if h[i+1] >= h[i] + 2:
            print("No")
            exit()

    if h[N-1] >= h[N-3]:
        print("Yes")
    else:
        print("No")

else:
    print("Yes")


Failing test case input:
5
0 1 0 2 5

Expected output:
Yes


Actual output:
No


Fixed submission (verdict: Accepted):
N = int(input())
h = [int(i) for i in input().split()]

for i in range(N-1):
    if h[-(i+2)] > h[-(i+1)] + 1:
        print("No")
        exit()
    
    elif h[-(i+2)] == h[-(i+1)] + 1:
        h[-(i+2)] -= 1
    
    else:
        continue

print("Yes")

Problem: p02953
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
h = list(map(int, input().split()))

jud = "Yes"
for i in range(N-2):
    if h[i] > h[i+1] and h[i+1] > h[i+2]:
        jud = "No"
        break
    if h[i] - h[i+1] > 2:
        jud = "No"
        break
if h[N-2] - h[N-1] >2:
    jud = "No"

print(jud)

Failing test case input:
5
0 2 0 2 5

Expected output:
No


Actual output:
Yes


Fixed submission (verdict: Accepted):
N = int(input())
h = list(map(int, input().split()))

jud = "Yes"
cnt = 0
for i in range(N-1):
    if h[i] > h[i+1]:
        cnt += 1
    if h[i] < h[i+1]:
        cnt = 0
    if cnt == 2:
        jud = "No"
        break
    if h[i] - h[i+1] > 1:
        jud = "No"
        break

if h[N-2] - h[N-1] > 1:
    jud = "No"

print(jud)

Problem: p02953
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N=int(input())
H=list(map(int,input().split()))
for i in range(N-1):
  if H[i]>=H[i+1]:
    H[i]-=1
if H==sorted(H):
  print("Yes")
else:
  print("No")


Failing test case input:
5
0 1 0 0 6

Expected output:
Yes


Actual output:
No


Fixed submission (verdict: Accepted):
N=int(input())
H=list(map(int,input().split()))
H[0]-=1
for i in range(1,N):
  if H[i-1]<H[i]:
    H[i]-=1
if H==sorted(H):
  print("Yes")
else:
  print("No")
Problem: p02953
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n=int(input())
h=list(map(int,input().split()))
ans="Yes"
cngh=0
bkh=0
for i in range(n):
  if bkh>h[i]:
    if cngh!=h[i] and bkh==h[i]-1:
      cngh=h[i]-1
    elif (cngh!=h[i] and bkh!=h[i]-1) or (cngh==h[i] and cngh!=h[i]):
      ans="No"
      break
  bkh=h[i]
print(ans)

Failing test case input:
5
1 2 3 6 5

Expected output:
Yes


Actual output:
No


Fixed submission (verdict: Accepted):
n=int(input())
h=list(map(int,input().split()))
ans="Yes"
cngh=0
bkh=0
for i in range(n):
  if bkh>h[i]:
    if cngh!=h[i-1]:
      if bkh-1==h[i]:
      	cngh=h[i]
      else:
        ans="No"
        break
    else:
      if cngh!=h[i]:
        ans="No"
        break
  bkh=h[i]
print(ans)

Problem: p02953
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
h = list(map(int,input().split()))
flag = 1
if N == 1:
    print("Yes")
else:
    for i in range(N-1):
        if h[i] > h[i+1]:
            h[i] -= 1
    for i in range(N-1):
        if h[i] <= h[i+1]:
            flag = 1
        else:
            flag = 0
    if flag == 1:
        print('Yes')
    else:
        print('No')

Failing test case input:
5
0 2 0 1 3

Expected output:
No


Actual output:
Yes


Fixed submission (verdict: Accepted):
N = int(input())
h = list(map(int,input().split()))
ans = True
for i in range(N-2,-1,-1):
    if h[i] > h[i+1]:
        h[i]-=1
for i in range(N-1):
    if h[i] <= h[i+1]:
        ans = True
    else:
        ans = False
        break
if ans:
    print('Yes')
else:
    print('No')

Problem: p02953
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n=int(input())
h=list(map(int, input().split()))
ok=1
for i in range(n-2, -1, -1):
    if (h[i] - 1) > h[i+1]:
        ok=0
print(('No','Yes')[ok])


Failing test case input:
4
1 3 2 1

Expected output:
No

Actual output:
Yes


Fixed submission (verdict: Accepted):
n=int(input())
h=list(map(int, input().split()))
ok=1
for i in range(n-2, -1, -1):
    if h[i] > h[i+1]:
        h[i] -= 1
    if h[i] > h[i+1]:
        ok=0
print(('No','Yes')[ok])

Problem: p02953
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
num_list = [int(i) for i in input().split()]
 
answer = "Yes"
 
for i in range(n-1):
  if num_list[i] - num_list[i+1] >= 2:
    answer = "No"
    break
    
print(answer)

Failing test case input:
4
1 3 2 1

Expected output:
No

Actual output:
Yes


Fixed submission (verdict: Accepted):
n = int(input())
num_list = [int(i) for i in input().split()]
 
answer = "Yes"
 
for i in range(n-1):
  if num_list[i] - num_list[i+1] >= 2:
    answer = "No"
    break
  elif num_list[i] - num_list[i+1] >= 1:
    num_list[i+1] += 1
    
print(answer)
Problem: p02953
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
h = list(map(int, input().split()))

for i in range(1, n-1):
    if h[i+1] >= h[i]:
        pass
    elif h[i] - h[i+1] == 1 and h[i] - h[i-1] == 1:
        h[i] -= 1
    else:
        print('No')
        exit()
print('Yes')
        

Failing test case input:
5
1 2 3 6 5

Expected output:
Yes


Actual output:
No


Fixed submission (verdict: Accepted):
n = int(input())
h = list(map(int, input().split()))

if n == 1:
    print('Yes')
    exit()

for i in range(n-1, 0, -1):
    if h[i-1] - h[i] > 1:
        print('No')
        exit()
    elif h[i-1] - h[i] == 1:
        h[i-1] -= 1
    else:
        pass

print('Yes')

Problem: p02953
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import sys
N = int(input())
H = input().split()
for i in range(N):
    H[i] = int(H[i])
    
for i in range(N-1):
    if H[i] > H[i+1]:
        H[i] = H[i]-1
        if H[i] != H[i+1]:
            print('No')
            sys.exit() 
print('Yes')


Failing test case input:
4
1 3 2 1

Expected output:
No

Actual output:
Yes


Fixed submission (verdict: Accepted):
import sys
N = int(input())
H = input().split()
for i in range(N):
    H[i] = int(H[i])
H.reverse()

for i in range(N-1):
    if H[i] < H[i+1]:
        H[i+1] = H[i+1]-1
    if H[i] < H[i+1]:
        print('No')
        sys.exit() 
print('Yes')

Problem: p02953
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
import sys

fin = sys.stdin.readline
N = [int(elem) for elem in fin().split()][0]
h_list = [int(elem) for elem in fin().split()]
original_h_list = [x for x in h_list]

flag = True
result = 'Yes'
h_list = [-1] + h_list + [10**10]
for i in range(len(h_list)-2, 0, -1):
    
    

    
    if not (h_list[i + 1] >= h_list[i] >= h_list[i - 1]):
        h_list[i] -= 1
        if not (h_list[i + 1] >= h_list[i] >= h_list[i - 1]):
            flag = False
    
    if not flag:
        result = 'No'
        break


if max(original_h_list) - min(original_h_list) <= 1:
    result = 'Yes'
print(result)


Failing test case input:
5
0 1 0 2 5

Expected output:
Yes


Actual output:
No


Fixed submission (verdict: Accepted):
import sys

fin = sys.stdin.readline
N = [int(elem) for elem in fin().split()][0]
h_list = [int(elem) for elem in fin().split()]
original_h_list = [x for x in h_list]

flag = True
result = 'Yes'
h_list = [-1] + h_list + [10**10]
min_h_list = min(h_list[1:-1])
for i in range(1, len(h_list)-1):
    if h_list[i] - 1 >= h_list[i-1]:
        h_list[i] -= 1

for i in range(1, len(h_list)-1):
    if not (h_list[i-1] <= h_list[i] <= h_list[i+1]):
        result = 'No'

print(result)
Problem: p02953
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N=int(input())
h_list=[int(x) for x in input().split()]

flag=True

m=h_list[0]
for j in range(len(h_list)-1):
    if m<h_list[j]:
        m=h_list[j]
    if h_list[j+1]>m:
        flag=False
        break        
    
    
if flag:
    print("Yes")
else:
    print("No")

Failing test case input:
5
5 2 -5 0 3

Expected output:
No


Actual output:
Yes


Fixed submission (verdict: Accepted):
N=int(input())
h_list=[int(x) for x in input().split()]

flag=True

m=h_list[0]
for j in range(len(h_list)-1):
    if m<h_list[j]:
        m=h_list[j]
    if m-h_list[j+1]>=2:
        flag=False
        break        
    
if flag:
    print("Yes")
else:
    print("No")

Problem: p02953
Buggy submission (Python (3.4.3), verdict: Wrong Answer):

def main():
    input()
    t = list(map(int, input().split()))
    m = 0
    flg = True
    for i in range(len(t)):
        m = t[i] - 1 if m < t[i] else m
        if i == len(t) - 1:
            pass
        elif t[i] - 1 > t[i + 1]:
            flg = False
        elif t[i] > t[i + 1] and m >= t[i]:
            flg = False
    print('Yes')

if __name__ == '__main__':
    main()

Failing test case input:
5
1 2 0 6 5

Expected output:
No


Actual output:
Yes


Fixed submission (verdict: Accepted):
def main():
    input()
    t = list(map(int, input().split()))
    m = 0
    flg = True
    for i in range(len(t)):
        if 0 == i or i == len(t) - 1:
            continue
        if t[i-1] < t[i]:
            t[i] -= 1
        if t[i - 1] <= t[i] <= t[i + 1]:
            pass
        else:
            print('No')
            exit()
    print('Yes')

if __name__ == '__main__':
    main()

Problem: p02953
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
from collections import Counter, defaultdict
import sys
sys.setrecursionlimit(10 ** 5 + 10)

from math import factorial

def main():
    num = int(input())
    data = list(map(int, input().split()))

    now_num = data[0]

    for i in range(1, num):
        if now_num + 1 > data[i]:
            print('No')
            sys.exit()
        now_num = min(now_num, data[i])

    print('Yes')






if __name__ == '__main__':
    main()

Failing test case input:
5
0 0 0 0 10

Expected output:
Yes


Actual output:
No


Fixed submission (verdict: Accepted):
from collections import Counter, defaultdict
import sys
sys.setrecursionlimit(10 ** 5 + 10)

from math import factorial

def main():
    num = int(input())
    data = list(map(int, input().split()))

    now_num = data[0]

    for i in range(1, num):
        if data[i] > now_num:
            now_num = data[i] - 1
        elif data[i] == now_num:
            pass
        else:
            print('No')
            sys.exit()

    print('Yes')






if __name__ == '__main__':
    main()
Problem: p02953
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
H = list(map(int,input().split()))
a = "Yes"

for i in range(N-1):
  if H[i]<H[i+1]:
    pass
  else:
    H[i]-=1

for i in range(N-1):
  if H[i]>H[i+1]:
    a = "No"

print(H)

Failing test case input:
4
0 0 4 0

Expected output:
No


Actual output:
[-1, 0, 3, 0]


Fixed submission (verdict: Accepted):
N = int(input())
H = list(map(int,input().split()))
h = H[0]-1
a = "Yes"

for i in range(N):
  if H[i]==h:
    pass
  elif h<H[i]:
    h=H[i]-1
  else:
    a = "No"

print(a)

Problem: p02953
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
h = list(map(int, input().split()))

ans = "Yes"
max = max(h[0] - 1, 0)
for i in range(n-1):
    if h[i] - h[i+1] > 1:
        ans = "No"
        break     
    elif h[i] - h[i+1] == 1:
        if h[i+1] - 1 > max:
            ans = "No"
            break
        max = h[i] - 1
print(ans)


Failing test case input:
5
1 2 3 6 5

Expected output:
Yes


Actual output:
No


Fixed submission (verdict: Accepted):
n = int(input())
h = list(map(int, input().split()))

ans = "Yes"
last_max = max(h[0] - 1, 0)
for i in range(n-1):
    if h[i] - h[i+1] > 1:
        ans = "No"
        break     
    elif h[i] - h[i+1] == 1:
        if h[i] - 1 < last_max:
            ans = "No"
            break
        last_max = h[i] - 1
print(ans)

Problem: p02953
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
n = int(input())
h = list(map(int,input().split()))
i = 1

while i < n:
    if h[i] < h[i-1]:
        h[i-1] -= 1
    elif h[i] > h[i-1]:
        h[i] -= 1
    else:
        pass

    i += 2

l = list(h)
l.sort()
if h == l:
    print('YES')
else:
    print('NO')

Failing test case input:
4
0 1 4 0

Expected output:
No


Actual output:
NO


Fixed submission (verdict: Accepted):
n = int(input())
h = list(map(int,input().split()))
j = h[0]

for i in range(1,n):
    if h[i] > j:
        h[i] -= 1
        j = h[i]
    else:
        pass

l = list(h)
l.sort()
if h == l:
    print('Yes')
else:
    print('No')

Problem: p02953
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
H = list(map(int, input().split()))

ans = 1
for i in range(1, N-1, 1):
    
    if ((H[i-1] - H[i]) == 1) & ((H[i] - H[i+1]) == 0):
        continue
    elif ((H[i-1] - H[i]) <= 0) & ((H[i] - H[i+1]) <= 0):
        continue
    else:
        print('No')
        ans = -1
        break

if (ans == 1): print('Yes')

Failing test case input:
5
0 1 0 2 3

Expected output:
Yes


Actual output:
No


Fixed submission (verdict: Accepted):
N = int(input())
H = list(map(int, input().split()))

ans = 1
for i in reversed(range(1, N, 1)):
    if (H[i-1] - H[i]) == 1:
        H[i-1] -= 1
    if (H[i-1] - H[i]) > 1:
        print('No')
        ans = -1
        break
if ans == 1: print('Yes')
Problem: p02953
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n=int(input())
l=list(map(int,input().split()))
fin=True
if n>1 and l[0] == l[1]:l[0] += -1
for i in range(1,n):
  if n==1:break
  prev=l[i-1]
  now=l[i]
  if i == n-1:
    break
  else:
    next_=l[i+1]
  if now>prev and now+1 >= next_:
    l[i] += -1
  elif now <= next_ :continue
  elif now-1<prev:
    fin=False
    break
if fin==True:print("Yes")
else:print("No")

Failing test case input:
5
0 3 0 1 3

Expected output:
No


Actual output:
Yes


Fixed submission (verdict: Accepted):
n=int(input())
l=list(map(int,input().split()))
fin=True
if n>1 and l[0] == l[1]:l[0] += -1
for i in range(1,n):
  if n==1:break
  prev=l[i-1]
  now=l[i]
  if i == n-1:
    if prev>now:
      fin=False
    break
  else:
    next_=l[i+1]
  if prev < now and now >= next_:
    l[i] += -1
  elif prev>now:
    fin=False
    break
if fin==True:print("Yes")
else:print("No")

Problem: p02953
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
h = list(map(int, input().split()))

li1 = []
cnt = 0
if n == 1:
    print('Yes')
else:
    for i in range(0, n-1):
        if h[i+1] < h[i]:
            if h[i] - h[i+1] > 1:
                print('No')
                break
            cnt += 1
            if cnt == 2:
                print('No')
                break
        else:
            cnt = 0
            if i == n-2:
                print('Yes')


Failing test case input:
5
1 2 3 6 5

Expected output:
Yes


Actual output:

Fixed submission (verdict: Accepted):
n = int(input())
h = list(map(int, input().split()))

if n == 1:
    print('Yes')
else:
    for i in range(n-1, 0, -1):
        if i == 1:
                print('Yes')
        else:
            if h[i] - h[i-1] == -1:
                h[i-1] -= 1
            elif h[i] - h[i-1] < -1:
                print('No')
                break

Problem: p02953
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
from sys import stdin

n = int(stdin.readline().rstrip())
h = list(map(int, stdin.readline().rstrip().split(' ')))

if n == 1:
    print("Yes")
    exit()
for i in range(1, n):
    if h[i] - h[i-1] == 1:
        h[i] -= 1
    elif h[i] - h[i-1] < 0:
        print("No")
        exit()
print("Yes")

Failing test case input:
5
1 2 3 6 5

Expected output:
Yes


Actual output:
No


Fixed submission (verdict: Accepted):
from sys import stdin

n = int(stdin.readline().rstrip())
h = list(map(int, stdin.readline().rstrip().split(' ')))

if n == 1:
    print("Yes")
    exit()
for i in range(n-2, -1, -1):
    if h[i] - h[i+1] == 1:
        h[i] -= 1
    elif h[i] - h[i+1] > 1:
        print("No")
        exit()
print("Yes")
Problem: p02953
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import sys
N = int(input())
a = list(map(int,input().split()))
l = []
for i in range(N-1):
    l.append(a[i+1]-a[i])
if any(i<=-2 for i in l):
    print("No")
for i in range(N-1):
    total = l[i]
    for k in range(1,N-1):
        if total <0:
            total += l[k]
            if k == N-2:
                print("No")
                sys.exit()
        else:
            break
print("Yes")

Failing test case input:
4
1 -1 4 0

Expected output:
No


Actual output:
No
Yes


Fixed submission (verdict: Accepted):
N = int(input())
a = list(map(int,input().split()))
l = []
for i in range(N-1):
    if a[i+1]-a[i] != 0:
        l.append(a[i+1]-a[i])

if any(i<=-2 for i in l):
    print("No")
    exit()



for i in range(len(l)-1):
    if l[i] == -1 and l[i+1] == -1:
        print("No")
        exit()
print("Yes")

Problem: p02953
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n=int(input())
h=list(map(int,input().split()))
err=0
for i in range(n-1):
    if(h[i]>h[i+1]):
        h[i]=h[i]-1
    if(i>=1):
        if(h[i-1]>h[i]):
            err=1
if(err==1):
    print('No')
else:
    print('Yes')

Failing test case input:
4
1 0 5 1

Expected output:
No


Actual output:
Yes


Fixed submission (verdict: Accepted):
n=int(input())
h=list(map(int,input().split()))
err=0
for i in range(n-1)[::-1]:
    if(h[i]>h[i+1]):
        h[i]=h[i]-1
    if(i<n-2):
        if(h[i]>h[i+1]):
            err=1
if(h[n-2]>h[n-1]):
    err=1
if(err==1):
    print('No')
else:
    print('Yes')

Problem: p02953
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
H = list(map(int, input().split()))
h = 0
for i in range(N-1):
    if h <= H[i]-1 or H[i] <= H[i+1]:
        h = max(H[i]-1,h)
    else:
        print('No')
        break
else:
    print('Yes')

Failing test case input:
4
1 1 4 1

Expected output:
No


Actual output:
Yes


Fixed submission (verdict: Accepted):
N = int(input())
H = list(map(int, input().split()))
h = 0
for i in range(N-1):
    
    if h <= H[i]-1 <= H[i+1] or h <= H[i] <= H[i+1]:
        h = max(H[i]-1,h)
    else:
        print('No')
        break
else:
    print('Yes')

Problem: p02953
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
A = list(map(int,input().split()))
for i in range(n-1):
  if A[i+1]-A[i] >= -1:
    if A[i+1] >= A[i]:
      A[i+1] -=1
  else:
    print('No')
    exit()
print('Yes')

Failing test case input:
5
1 2 0 1 5

Expected output:
No


Actual output:
Yes


Fixed submission (verdict: Accepted):
n = int(input())
A = list(map(int,input().split()))
ans = 0
for i in range(n-1):
  if ans > A[i+1]:
    print('No')
    exit()
  if A[i+1]-A[i] >= -1:
    ans = max(A[i+1]-1,A[i]-1,ans)
    if A[i+1] >= A[i] and A[i+1] > ans :
      A[i+1] -=1
  else:
    print('No')
    exit()
print('Yes')