Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque

h, w = map(int, input().split())
S = [['#']*(w+2)]

for _ in range(h):
    s = str(input())
    new_s = ['#']
    for x in s:
        new_s.append(x)
    new_s.append('#')
    S.append(new_s)
S.append(['#']*(w+2))

Possible_list = []
for i in range(h+2):
    for j in range(w+2):
        if S[i][j] == '.':
            Possible_list.append((i,j))

max_length = 0

for zahyou in Possible_list:
    dq = deque()
    Visited = [-1 for _ in range(len(Possible_list))]
    Visited[Possible_list.index(zahyou)] = 0
    dq.append(zahyou)
    
    while dq:
        now = dq.popleft()
        
        Adj_possible = []
        if (now[0]-1, now[1]) in Possible_list:
            Adj_possible.append((now[0]-1, now[1]))
        if (now[0]+1, now[1]) in Possible_list:
            Adj_possible.append((now[0]+1, now[1]))
        if (now[0], now[1]-1) in Possible_list:
            Adj_possible.append((now[0], now[1]-1))
        if (now[0], now[1]+1) in Possible_list:
            Adj_possible.append((now[0], now[1]+1))
        
        for next_zahyou in Adj_possible:
            if Visited[Possible_list.index(next_zahyou)] != -1:
                continue
            Visited[Possible_list.index(next_zahyou)] = Visited[Possible_list.index(now)] + 1
            dq.append(next_zahyou)
    
    max_length = max(max_length, max(Visited))

print(max_length)

Fixed submission:
from collections import deque

h, w = map(int, input().split())
S = [['#']*(w+2)]

for _ in range(h):
    s = str(input())
    new_s = ['#']
    for x in s:
        new_s.append(x)
    new_s.append('#')
    S.append(new_s)
S.append(['#']*(w+2))

Possible_list = []
for i in range(h+2):
    for j in range(w+2):
        if S[i][j] == '.':
            Possible_list.append((i,j))

max_length = 0

for zahyou in Possible_list:
    dq = deque()
    Visited = [-1 for _ in range(len(Possible_list))]
    Visited[Possible_list.index(zahyou)] = 0
    dq.append(zahyou)
    
    while dq:
        now = dq.popleft()
        
        Adj_possible = []
        if (now[0]-1, now[1]) in Possible_list:
            Adj_possible.append((now[0]-1, now[1]))
        if (now[0]+1, now[1]) in Possible_list:
            Adj_possible.append((now[0]+1, now[1]))
        if (now[0], now[1]-1) in Possible_list:
            Adj_possible.append((now[0], now[1]-1))
        if (now[0], now[1]+1) in Possible_list:
            Adj_possible.append((now[0], now[1]+1))
        
        for next_zahyou in Adj_possible:
            if Visited[Possible_list.index(next_zahyou)] != -1:
                continue
            Visited[Possible_list.index(next_zahyou)] = Visited[Possible_list.index(now)] + 1
            dq.append(next_zahyou)
    
    max_length = max(max_length, max(Visited))

print(max_length)
Buggy python submission (verdict: Runtime Error):
x =  int(input())
 
def primes(z, n):
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    return [i for i in range(n + 1) if (is_prime[i]) and (i>=z) ]

Prime = primes(x, 10**5)
ans = Prime[0]
print(ans)

Fixed submission:
x =  int(input())
 
def primes(z, n):
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    return [i for i in range(n + 1) if (is_prime[i]) and (i>=z) ]

Prime = primes(x, (10**5)+4)
ans = Prime[0]
print(ans)

Buggy python submission (verdict: Runtime Error):
x =  int(input())

def primes(z, n):
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    return [i for i in range(n + 1) if (is_prime[i]) and (i>=z) ]

Prime = primes(x, 10**5)
ans = Prime[0]
print(ans)

Fixed submission:
x =  int(input())
 
def primes(z, n):
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    return [i for i in range(n + 1) if (is_prime[i]) and (i>=z) ]

Prime = primes(x, (10**5)+4)
ans = Prime[0]
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
A = list(map(int, input().split()))

zero_each_dig = [0 for _ in range(60)]
one_each_dig = [0 for _ in range(60)]

for i in range(n):
     for j in range(60):
        if (A[i] >> j) & 1 == 1:
            one_each_dig[j] += 1
        else:
            zero_each_dig[j] += 1

Multi = []
for k in range(60):
    Multi.append(zero_each_dig[k] * one_each_dig[k] * (2**k) % (10**9 +7))

ans = sum(Multi) % (10**9 +7)
print(ans)

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

zero_each_dig = [0 for _ in range(60)]
one_each_dig = [0 for _ in range(60)]

for i in range(n):
     for j in range(60):
        if (A[i] >> j) & 1 == 1:
            one_each_dig[j] += 1
        else:
            zero_each_dig[j] += 1

Multi = []
for k in range(60):
    Multi.append(zero_each_dig[k] * one_each_dig[k] * (2**k) % (10**9 +7))

ans = sum(Multi) % (10**9 +7)
print(ans)

Buggy python submission (verdict: Runtime Error):
n = int(input())
A = list(map(int, input().split()))

zero_each_dig = [0 for _ in range(60)]
one_each_dig = [0 for _ in range(60)]

for i in range(n):
     for j in range(60):
        if (A[i] >> j) & 1 == 1:
            one_each_dig[j] += 1
        else:
            zero_each_dig[j] += 1

Multi = []
for k in range(n):
    Multi.append(zero_each_dig[k] * one_each_dig[k] * (2**k) % (10**9 +7))

ans = sum(Multi) % (10**9 +7)
print(ans)

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

zero_each_dig = [0 for _ in range(60)]
one_each_dig = [0 for _ in range(60)]

for i in range(n):
     for j in range(60):
        if (A[i] >> j) & 1 == 1:
            one_each_dig[j] += 1
        else:
            zero_each_dig[j] += 1

Multi = []
for k in range(60):
    Multi.append(zero_each_dig[k] * one_each_dig[k] * (2**k) % (10**9 +7))

ans = sum(Multi) % (10**9 +7)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from functools import reduce

n = int(input())
A = list(map(int, input().split()))
s = 0

def xor(a, b):
    return a ^ b
for i in range(n-1):
    for j in range(i+1, n):
        s += xor(A[i],A[j])%(10**9+7)
s = s % (10**9+7)
print(s)

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

zero_each_dig = [0 for _ in range(60)]
one_each_dig = [0 for _ in range(60)]

for i in range(n):
     for j in range(60):
        if (A[i] >> j) & 1 == 1:
            one_each_dig[j] += 1
        else:
            zero_each_dig[j] += 1

Multi = []
for k in range(60):
    Multi.append(zero_each_dig[k] * one_each_dig[k] * (2**k) % (10**9 +7))

ans = sum(Multi) % (10**9 +7)
print(ans)
Buggy python submission (verdict: Runtime Error):
import math

X, Y = map(int, input().split())

if (X+Y) % 3 != 0:
    print(0)
else:
    m = (2*X - Y) / 3
    n = (2*Y - X) / 3
    if m < 0 or n < 0:
        print(0)
    else:
        ans = math.factorial(m+n)% (1e+7 + 7) / (math.factorial(m) * math.factorial(n))
        print(int(ans))

Fixed submission:
def cmb(m, n):
    if m - n < n:
        n = m - n
    if n == 0:
        return 1
    if n == 1:
        return m
    
    numerator = [m - n + k + 1 for k in range(n)]
    denominator = [k + 1 for k in range(n)]

    for p in range(2, n+1):
        pivot = denominator[p-1]
        if pivot > 1:
            offset = (m-n) % p
            for k in range(p-1, n, p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot
    
    result = 1
    for k in range(n):
        if numerator[k] > 1:
            result = result * int(numerator[k]) % (10**9 + 7)

    return result

X, Y = map(int, input().split())

if (X+Y) % 3 != 0:
    print(0)
else:
    m = int((2*X - Y) / 3)
    n = int((2*Y - X) / 3)
    if m < 0 or n < 0:
        print(0)
    else:
        ans = cmb(m+n, n)
        print(int(ans))

Buggy python submission (verdict: Time Limit Exceeded):
import math

X, Y = map(int, input().split())

if (X+Y) % 3 != 0:
    print(0)
else:
    m = (2*X - Y) / 3
    n = (2*Y - X) / 3
    if m < 0 or n < 0:
        print(0)
    else:
        ans = math.factorial(m+n) / (math.factorial(m) * math.factorial(n))
        print(int(ans))

Fixed submission:
def cmb(m, n):
    if m - n < n:
        n = m - n
    if n == 0:
        return 1
    if n == 1:
        return m
    
    numerator = [m - n + k + 1 for k in range(n)]
    denominator = [k + 1 for k in range(n)]

    for p in range(2, n+1):
        pivot = denominator[p-1]
        if pivot > 1:
            offset = (m-n) % p
            for k in range(p-1, n, p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot
    
    result = 1
    for k in range(n):
        if numerator[k] > 1:
            result = result * int(numerator[k]) % (10**9 + 7)

    return result

X, Y = map(int, input().split())

if (X+Y) % 3 != 0:
    print(0)
else:
    m = int((2*X - Y) / 3)
    n = int((2*Y - X) / 3)
    if m < 0 or n < 0:
        print(0)
    else:
        ans = cmb(m+n, n)
        print(int(ans))
Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
A = list(map(int, input().split()))
F = list(map(int, input().split()))

A = sorted(A)
Minus_A = [-x for x in A]
F = sorted(F, reverse=True)

high = 10**12
low = 0
while high - low > 1:
    mid = low + (high-low)//2
    count = 0

    for i in range(n):
        now = mid // F[i]
        count += max(A[i] - now, 0)
    
    # print('-'*30)
    # print(mid)
    # print(count)
    if count > k:
        low = mid
    else:
        high = mid
    
ans = high

if sum(A) <= k:
    ans = 0

print(ans)


Fixed submission:
n, k = map(int, input().split())
A = list(map(int, input().split()))
F = list(map(int, input().split()))

A = sorted(A)
Minus_A = [-x for x in A]
F = sorted(F, reverse=True)

high = 10**12
low = 0
while high - low > 1:
    mid = low + (high-low)//2
    count = 0

    for i in range(n):
        now = mid // F[i]
        count += max(A[i] - now, 0)
    
    # print('-'*30)
    # print(mid)
    # print(count)
    if count > k:
        low = mid
    else:
        high = mid
    
ans = high

if sum(A) <= k:
    ans = 0

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import heapq

n, k = map(int, input().split())
A = list(map(int, input().split()))
F = list(map(int, input().split()))

A = sorted(A)
Minus_A = [-x for x in A]
F = sorted(F, reverse=True)

Sec = []
for i in range(n):
    Sec.append(Minus_A[i]*F[i])

hq = []
for i in range(n):
    heapq.heappush(hq, [Sec[i], Minus_A[i], F[i]])

for i in range(k):
    dec_obj = heapq.heappop(hq)
    if dec_obj[1] < 0:
        dec_obj[1] = dec_obj[1] + 1
        dec_obj[0] = dec_obj[1] * dec_obj[2]
        heapq.heappush(hq, dec_obj)
        # print(hq)
    else:
        break

ans_obj = heapq.heappop(hq)
ans = ans_obj[0] * -1
print(ans)

Fixed submission:
n, k = map(int, input().split())
A = list(map(int, input().split()))
F = list(map(int, input().split()))

A = sorted(A)
Minus_A = [-x for x in A]
F = sorted(F, reverse=True)

high = 10**12
low = 0
while high - low > 1:
    mid = low + (high-low)//2
    count = 0

    for i in range(n):
        now = mid // F[i]
        count += max(A[i] - now, 0)
    
    # print('-'*30)
    # print(mid)
    # print(count)
    if count > k:
        low = mid
    else:
        high = mid
    
ans = high

if sum(A) <= k:
    ans = 0

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

N = int(input())
L = list(map(int, input().split()))

L = np.array(sorted(L, reverse=True))

ans = 0

for n in range(0,N-2):
    if L[n] > L[n+1] + L[n+2]:
        pass
    else:
        for o in range(n+1,N-1):
            ans += np.sum(L[o+1:]>L[n]+-L[o])
                
print(int(ans))

Fixed submission:
import bisect

N = int(input())
L = list(map(int, input().split()))
L = sorted(L)

count = 0
for n in range(N-2):
    for m in range(n+1,N-1):
        count += bisect.bisect_left(L,L[m]+L[n]) -m-1

print(count)

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

N = int(input())
L = list(map(int, input().split()))

L = np.array(sorted(L, reverse=True))

ans = 0

for n in range(0,N-2):
    if L[n] > 2* L[n+1]:
        pass
    else:
        for o in range(n+1,N-1):
            ans += np.sum(L[o+1:]>L[n]+-L[o])
                
print(int(ans))

Fixed submission:
import bisect

N = int(input())
L = list(map(int, input().split()))
L = sorted(L)

count = 0
for n in range(N-2):
    for m in range(n+1,N-1):
        count += bisect.bisect_left(L,L[m]+L[n]) -m-1

print(count)

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

N = int(input())
L = list(map(int, input().split()))

L = np.array(sorted(L, reverse=True))

ans = 0

for n in range(0,N-2):
    for o in range(n+1,N-1):
        ans += np.sum(L[o+1:]>L[n]+-L[o])
                
print(int(ans))

Fixed submission:
import bisect

N = int(input())
L = list(map(int, input().split()))
L = sorted(L)

count = 0
for n in range(N-2):
    for m in range(n+1,N-1):
        count += bisect.bisect_left(L,L[m]+L[n]) -m-1

print(count)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
L = list(map(int, input().split()))

ans=0

for n in range(0,N-2):
    for o in range(n+1, N-1):
        for p in range(o+1, N):
            if (L[n] < L[o] + L[p]) and (L[o] < L[p] + L[n]) and (L[p] < L[n] + L[o]):
                ans += 1
                
print(int(ans))


Fixed submission:
import bisect

N = int(input())
L = list(map(int, input().split()))
L = sorted(L)

count = 0
for n in range(N-2):
    for m in range(n+1,N-1):
        count += bisect.bisect_left(L,L[m]+L[n]) -m-1

print(count)
Buggy python submission (verdict: Runtime Error):
import numpy as np

N, K, Q = map(int, input().split())
A = []

for a in range(Q):
    A.append(int(input()))

P = [K] * N
X = [-1] * N
B = [0] * N

P_n = np.array(P)
X_n = np.array(X)
X_n_Q = X_n * Q

R_n = P_n + X_n_Q

B_n = np.array(B)

for a in A:
    B_n[a-1] = B_n[a-1] + 1

dif_n = R_n + B_n
dif = dif_n.tolist()

for d in dif:
    if d >= 1:
        print('Yes')
    else:
        print('No')

Fixed submission:
S = str(input())

if S == 'Sunny':
    print('Cloudy')
elif S == 'Cloudy':
    print('Rainy')
else:
    print('Sunny')
Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque
import copy

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

dq_s = deque([])
for x in s:
    dq_s.append(x)

dq_s_shift = copy.deepcopy(dq_s)

ans = 0

for i in range(n):
    dq_s_shift.appendleft('_')
    count = 0
    # print(s)
    # print(s_shift)

    for j in range(n):
        if dq_s[j] == dq_s_shift[j]:
            count += 1
        else:
            count = 0
        if count >= ans and count <= i+1:
            ans = count
    # print('-'*30)
    # print(ans)

print(ans)

Fixed submission:
from collections import deque
import copy

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

dq_s = deque([])
for x in s:
    dq_s.append(x)

dq_s_shift = copy.deepcopy(dq_s)

ans = 0

for i in range(n):
    dq_s_shift.appendleft('_')
    count = 0
    # print(s)
    # print(s_shift)

    for j in range(i+1,n):
        if dq_s[j] == dq_s_shift[j]:
            count += 1
        else:
            count = 0
        if count >= ans and count <= i+1:
            ans = count
    # print('-'*30)
    # print(ans)

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque
import copy

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

dq_s = deque([])
for x in s:
    dq_s.append(x)

dq_s_shift = copy.deepcopy(dq_s)

ans = 0

for i in range(n):
    dq_s_shift.appendleft('_')
    count = 0
    # print(s)
    # print(s_shift)

    for j in range(n):
        if dq_s[j] == dq_s_shift[j]:
            count += 1
        else:
            count = 0
        if count >= ans and count <= i+1:
            ans = count
    # print('-'*30)
    # print(ans)

print(ans)

Fixed submission:
from collections import deque
import copy

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

dq_s = deque([])
for x in s:
    dq_s.append(x)

dq_s_shift = copy.deepcopy(dq_s)

ans = 0

for i in range(n):
    dq_s_shift.appendleft('_')
    count = 0
    # print(s)
    # print(s_shift)

    for j in range(i+1,n):
        if dq_s[j] == dq_s_shift[j]:
            count += 1
        else:
            count = 0
        if count >= ans and count <= i+1:
            ans = count
    # print('-'*30)
    # print(ans)

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = str(input())
s_shift = s
ans = 0

for i in range(n):
    s_shift = '_' + s_shift
    count = 0
    # print(s)
    # print(s_shift)

    for j in range(n):
        if s[j] == s_shift[j]:
            count += 1
        else:
            count = 0
        if count >= ans and count <= i+1:
            ans = count
    # print('-'*30)
    # print(ans)

print(ans)

Fixed submission:
from collections import deque
import copy

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

dq_s = deque([])
for x in s:
    dq_s.append(x)

dq_s_shift = copy.deepcopy(dq_s)

ans = 0

for i in range(n):
    dq_s_shift.appendleft('_')
    count = 0
    # print(s)
    # print(s_shift)

    for j in range(i+1,n):
        if dq_s[j] == dq_s_shift[j]:
            count += 1
        else:
            count = 0
        if count >= ans and count <= i+1:
            ans = count
    # print('-'*30)
    # print(ans)

print(ans)
Buggy python submission (verdict: Runtime Error):
N, K = map(int, input().split())
S = str(input())
count = 0

for n in range(1, N):
    if S[n-1] == 'R' and S[n] == 'R':
        count += 1
    elif S[n-1] == 'L' and S[n] == 'L':
        count += 1

count = count + 2*K
ans = min(count, N-1)
print(ans)

Fixed submission:
N = int(input())
B = list(map(int, input().split()))

a = 0

a += B[0]
a += B[N-2]

for n in range(N):
    if n == 0 or n == N-1:
        pass
    else:
        a += min(B[n-1], B[n])

print(a)
Buggy python submission (verdict: Runtime Error):
import re

N = int(input())
H = list(map(int, input().split()))
X = []

if N == 1:
    print('0')
else:
    for n in range(N-1):
        if H[n] >= H[n+1]:
            X.append('T')
        else:
            X.append('F')

    XX = ''.join(X)

    T = re.findall('T*T', XX)

    Y=[]
    for y in T:
        Y.append(len(y))

    print(max(Y))

Fixed submission:
import re

N = int(input())
H = list(map(int, input().split()))
X = []

if N == 1:
    print('0')
else:
    for n in range(N-1):
        if H[n] >= H[n+1]:
            X.append('T')
        else:
            X.append('F')

    XX = ''.join(X)

    if XX.find('T') == -1:
        print('0')
    else:
        T = re.findall('T*T', XX)

        Y=[]
        for y in T:
            Y.append(len(y))

        print(max(Y))

Buggy python submission (verdict: Runtime Error):
import re

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

X = []

for n in range(N-1):
    if H[n] >= H[n+1]:
        X.append('T')
    else:
        X.append('F')

XX = ''.join(X)

T = re.findall('T*T', XX)

Y=[]
for y in T:
    Y.append(len(y))

print(max(Y))

Fixed submission:
import re

N = int(input())
H = list(map(int, input().split()))
X = []

if N == 1:
    print('0')
else:
    for n in range(N-1):
        if H[n] >= H[n+1]:
            X.append('T')
        else:
            X.append('F')

    XX = ''.join(X)

    if XX.find('T') == -1:
        print('0')
    else:
        T = re.findall('T*T', XX)

        Y=[]
        for y in T:
            Y.append(len(y))

        print(max(Y))
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input()))

top = 1
for a in A:
    top = top * a

bottom = 0
for i in range(N):
    bottom += top / A[i]

ans = top / bottom
print(round(ans, 6))

Fixed submission:
N = int(input())
A = list(map(int, input().split()))

top = 1
for a in A:
    top = top * a

bottom = 0
for i in range(N):
    bottom += top / A[i]

ans = top / bottom
print(round(ans, 6))

Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input()))

top = 1
for a in A:
    top = top * a

bottom = 0
for i in range(N):
    bottom += top / A[i]

ans = top / bottom
print(ans)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))

top = 1
for a in A:
    top = top * a

bottom = 0
for i in range(N):
    bottom += top / A[i]

ans = top / bottom
print(round(ans, 6))

Buggy python submission (verdict: Runtime Error):
#N = int(input())
#A = list(map(int, input()))

top = 1
for a in A:
    top = top * a

bottom = 0
for i in range(N):
    bottom += top / A[i]

ans = top / bottom
print(ans)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))

top = 1
for a in A:
    top = top * a

bottom = 0
for i in range(N):
    bottom += top / A[i]

ans = top / bottom
print(round(ans, 6))
Buggy python submission (verdict: Runtime Error):
A, B = int(input().split())

s = A + B
d = A - B
m = A * B

print(max(s, d, m))

Fixed submission:
A, B = map(int, input().split())

s = A + B
d = A - B
m = A * B

print(max(s, d, m))
Buggy python submission (verdict: Runtime Error):
N = int(input())
H = list(map(int, input().split()))

ans = 'Yes'

for i in reversed(range(0, N-1)):
    if H[i] > H[i+1] + 1:
        ans += 1
    elif H[i] == H[i+1] + 1:
        H[i] -= 1

if ans == 0:
    print('Yes')
else:
    print('No')

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

ans = 'Yes'

for i in reversed(range(0, N-1)):
    if H[i] > H[i+1] + 1:
        ans = 'No'
    elif H[i] == H[i+1] + 1:
        H[i] -= 1

print(ans)

Buggy python submission (verdict: Runtime Error):
N = int(input())
H = list(map(int, input().split()))

ans = 0

for i in reversed(range(0, N-1)):
    if H[i] > h[i+1] + 1:
        ans += 1
    elif H[i] == h[i+1] + 1:
        h[i] -= 1

if ans == 0:
    print('Yes')
else:
    print('No')

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

ans = 'Yes'

for i in reversed(range(0, N-1)):
    if H[i] > H[i+1] + 1:
        ans = 'No'
    elif H[i] == H[i+1] + 1:
        H[i] -= 1

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
H = list(map(int, input().split()))

ans = 0

for n in range(N):
    if n == 0:
        pass
    else:
        if max(H[0:n]) - H[n] >= 2:
           ans += 1

if ans >= 1:
    print('No')
else:
    print('Yes')

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

ans = 'Yes'

for i in reversed(range(0, N-1)):
    if H[i] > H[i+1] + 1:
        ans = 'No'
    elif H[i] == H[i+1] + 1:
        H[i] -= 1

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
H = list(map(int, input().split()))

ans = 0

for n in range(N):
    if n == 0:
        pass
    else:
        temp = H[0:n]
        if max(H[0:n]) - H[n] >= 2:
           ans += 1

if ans >= 1:
    print('No')
else:
    print('Yes')

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

ans = 'Yes'

for i in reversed(range(0, N-1)):
    if H[i] > H[i+1] + 1:
        ans = 'No'
    elif H[i] == H[i+1] + 1:
        H[i] -= 1

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
H = list(map(int, input().split()))

ans = 0

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

if ans == 0:
    print('Yes')
else:
    print('No')


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

ans = 'Yes'

for i in reversed(range(0, N-1)):
    if H[i] > H[i+1] + 1:
        ans = 'No'
    elif H[i] == H[i+1] + 1:
        H[i] -= 1

print(ans)