Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
num = list(map(int,input().split()))
m = 10**9 + 7
ans = 0

for i in range(n):
  sum_i = num[i] * (sum(num[i+1:n]) % m)
  ans += sum_i

print(ans%m)

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

s1 = (sum(nums) - nums[0]) % (10**9 + 7)
sums = [s1]
for i in range(1,n):
  s = sums[i-1] - nums[i]
  s %= 10**9 + 7
  sums.append(s)

ans = 0
for i in range(n):
  temp = nums[i] * sums[i] % (10**9 + 7)
  ans += temp

print(ans%(10**9+7))
Buggy python submission (verdict: Runtime Error):
n,x,t - map(int,input().split())

from math import ceil
time = ceil(t/n) * x
print(time)


Fixed submission:
n,x,t = map(int,input().split())

from math import ceil
time = ceil(n/x) * t
print(time)
Buggy python submission (verdict: Runtime Error):
n = int(input())
if n%100 == 7:
  print(‘Yes’)
elif (n//10)%10 == 7:
  print(‘Yes’)
elif n//100 == 7:
  print(‘Yes’)
else:
  print(‘No’)


Fixed submission:
n = int(input())
if (n%100)%10==7 or (n//10)%10==7 or n//100==7:
  print('Yes')
else:
  print('No')
Buggy python submission (verdict: Runtime Error):
n,k = map(int, input().split())

print(min(n%k, abs(n%k-k)))


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

A,B = B,A
A,C = C,A

print(A,B,C)

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

min = 10**18+1
flag = True

while flag==True:
  N = abs(N-K)
  if N < min: min = N
  else: flag = False
    
return min


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

A,B = B,A
A,C = C,A

print(A,B,C)
Buggy python submission (verdict: Runtime Error):
n,m = map(int,input().split())
num = list(map(int,input().split()))
limit = 1/(4*m)
count = 0
for i in range(n):
  if num[i] >= limit: count += 1
if count >= m: print(‘Yes’)
else: print(‘No’)


Fixed submission:
N,M = map(int, input().split())
A = input().split()
A = [int(i) for i in A]

limit = sum(A) / (4*M)
flag = 0

for i in A:
  if i>=limit: flag += 1
    
if flag>=M: print('Yes')
else: print('No')
Buggy python submission (verdict: Runtime Error):
n,k = map(int,input().aplit())
print(min(n%k,abs(n%k-k)))

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

print(min(n%k, abs(n%k-k)))

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

print min(n%k, abs(n%k-k))

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

print(min(n%k, abs(n%k-k)))

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

min = 10**18+1
flag = True

while(1):
  N = abs(N-K)
  if N < min: min = N
  else: break
    
print(min)

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

print(min(n%k, abs(n%k-k)))

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

min_num = 10**18+1
flag = True

while flag:
  N = abs(N-K)
  if N < min_num: min_num = N
  else: break
    
return min_num


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

print(min(n%k, abs(n%k-k)))

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

min = 10**18+1
flag = True

while flag==True:
  N = abs(N-K)
  if N < min: min = N
  else: flag = False
    
return min


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

print(min(n%k, abs(n%k-k)))

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

min = 10**18+1
flag = True

while flag==True:
  N = abs(N-K)
  if N < min: min = N
  else: flag == False
    
return min

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

print(min(n%k, abs(n%k-k)))
Buggy python submission (verdict: Runtime Error):
s = input().split()
s = [i for i in s]

if s[2]==s[3] and s[4]==s[5]:
  print('Yes')
else:
  print('No')

Fixed submission:
s = input()

if s[2]==s[3] and s[4]==s[5]:
  print('Yes')
else:
  print('No')
Buggy python submission (verdict: Runtime Error):
k,n = map(int,input().split())
a = list(map(int,input().split()))
ans = k
for i in range(-1,n-1):
  ans = min(ans, k-(n[i+1]-n[i]))
print(ans)


Fixed submission:
k,n = map(int, input().split())
A = input().split()
A = [int(a) for a in A]
for i in range(n):
  A.append(A[i])

min = k
for i in range(n):
  if A[i+n-1]>=A[i]: 
    d = A[i+n-1]-A[i]
  else:
    d = A[i+n-1]+k-A[i]
  if d<min: min = d
    
print(min)
Buggy python submission (verdict: Runtime Error):
n,m = map(int,input())
print(int(n*(n-1)/2)+int(m*(m-1)/2))

Fixed submission:
n,m = map(int, input().split())
 
print(int(n*(n-1)/2+m*(m-1)/2))
Buggy python submission (verdict: Runtime Error):
s = list(input())
n = len(s)
if n==n[::-1] and n[0:int((n-1)/2)]==n[0:int((n-1)/2)][::-1] and n[int((n+3)/2-1):n]==n[int((n+3)/2-1):n][::-1]:
  print('Yes')
else:
  print('No')


Fixed submission:
s = input()

ss = s[::-1]
n = len(s)
s1 = s[0:int((n-1)/2)]
ss1 = s1[::-1]
s2 = s[int((n+3)/2-1):n]
ss2 = s2[::-1]

if s==ss and s1==ss1 and s2==ss2:
  print('Yes')
else:
  print('No')
Buggy python submission (verdict: Runtime Error):
card = [list(map(int, input().split())) for i in range(3)]
N = int(input())
 
bingo = [[0 for i in range(3)] for j in range(3)]
 
for i in range(N):
  	key = int(input())
    for j in range(3):
        for k in range(3):
            if card[j][k] == key:
                bingo[j][k] += 1
 
for i in range(3):
    if bingo[0][i] * bingo[1][i] * bingo[2][i] > 0:
        print('Yes')
        exit()
for i in range(3):
    if bingo[i][0] * bingo[i][1] * bingo[i][2] > 0:
        print('Yes')
        exit()
if bingo[0][0] * bingo[1][1] * bingo[2][2] > 0:
    print('Yes')
    exit()
if bingo[0][2] * bingo[1][1] * bingo[2][0] > 0:
    print('Yes')
    exit()
print('No')

Fixed submission:
import math
n = int(input())

print(math.ceil(n/2))
Buggy python submission (verdict: Runtime Error):
n,m = map(int,input().split())
num = [-1]*n
for i in range(m):
  s,c = map(int,input().split())
  if n!=1 and s==1 and c==0:
    print(-1)
    exit()
  if num[s-1]==-1: num[s-1] = c
  elif num[s-1]!=c:
    print(-1)
    eixt()
for i in range(n):
  if num[i] == -1: num[i] = 0
if num[0] == 0 and len(num)!=1: num[0] = 1
for i in range(n):
  print(num[i],end='')

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

num = 0
dic = {}

for i in range(m):
  s,c = map(int, input().split())
  if n!=1 and s==1 and c==0: 
    print(-1)
    exit()
  if s not in dic:
    dic[s] = c
    num = num + c*(10**(n-s))
  elif c!=dic[s]:
    print(-1)
    exit()

if 1 not in dic and n>1:
  num = num + 10**(n-1)

print(num)

Buggy python submission (verdict: Runtime Error):
n,m = map(int,input().split())
num = [-1]*n
for i in range(m):
  s,c = map(int,input().split())
  if n!=1 and s==1 and c==0:
    print(-1)
    exit()
  if num[s-1]==-1: num[s-1] = c
  elif num[s-1]!==c:
    print(-1)
    eixt()
for i in range(n):
  if num[i] == -1: num[i] = 0
if num[0] == 0 and len(num)!=1: num[0] = 1
print(int(''.join(num)))

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

num = 0
dic = {}

for i in range(m):
  s,c = map(int, input().split())
  if n!=1 and s==1 and c==0: 
    print(-1)
    exit()
  if s not in dic:
    dic[s] = c
    num = num + c*(10**(n-s))
  elif c!=dic[s]:
    print(-1)
    exit()

if 1 not in dic and n>1:
  num = num + 10**(n-1)

print(num)

Buggy python submission (verdict: Runtime Error):
n,m = map(int,input().split())
num = [-1]*n
for i in range(m):
  s,c = map(int,input().split())
  if n!=1 and s==1 and c==0:
    print(-1)
    exit()
  if num[s-1]==-1: num[s-1] = c
  elif num[s-1]!=c:
    print(-1)
    eixt()
for i in range(n):
  if num[i] == -1: num[i] = 0
if num[0] == 0 and len(num)!=1: num[0] = 1
print(int(''.join(num)))

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

num = 0
dic = {}

for i in range(m):
  s,c = map(int, input().split())
  if n!=1 and s==1 and c==0: 
    print(-1)
    exit()
  if s not in dic:
    dic[s] = c
    num = num + c*(10**(n-s))
  elif c!=dic[s]:
    print(-1)
    exit()

if 1 not in dic and n>1:
  num = num + 10**(n-1)

print(num)

Buggy python submission (verdict: Runtime Error):
n,m = map(int,input().split())
num = [-1]*n
for i in range(m):
  s,c = map(int,input().split())
  if n!=1 and s==1 and c==0:
    print(-1)
    exit()
  if num[s-1]==-1: num[s-1] = c
  elif num[s-1]!=c:
    print(-1)
    eixt()
for i in range(n):
  if num[i] = -1: num[i] = 0
if num[0] = 0 and len(num)!=1: num[0] = 1
print(int(''.join(num)))


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

num = 0
dic = {}

for i in range(m):
  s,c = map(int, input().split())
  if n!=1 and s==1 and c==0: 
    print(-1)
    exit()
  if s not in dic:
    dic[s] = c
    num = num + c*(10**(n-s))
  elif c!=dic[s]:
    print(-1)
    exit()

if 1 not in dic and n>1:
  num = num + 10**(n-1)

print(num)
Buggy python submission (verdict: Runtime Error):
n = int(input())
dic = {}
for i in range(n):
  s = input()
  if s not in dic: dic[s] = 1
  else: dic[s] += 1
v = dic.values()
v = sorted(v)
max_num = v[n-1]
ans = []
for s in dic:
  if dic[s]==max_num:
    ans.append(s)
ans = sorted(ans)
for i in range(len(ans)):
  print(ans[i])


Fixed submission:
n = int(input())

dic = {}

for i in range(n):
  word = input()
  if word not in dic:
    dic[word] = 1
  else:
    dic[word] += 1
    
max_num = max(dic[word] for word in dic)
l = []
for word in dic:
  if dic[word]==max_num:
    l.append(word)
    
l = sorted(l)
for i in range(len(l)):
  print(l[i])
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
num = list(map(int, input().split()))
l = []
l.append(num[0])
count = 1

for i in range(1,n):
  if num[i]<=min(a for a in l):
    count += 1
    l.append(num[i])
  else:
    l.append(num[i])

print(count)

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

min_n = num[0]
count = 1
for i in range(1,n):
  if num[i]<=min_n:
    count += 1
    min_n = num[i]
    
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
num = list(map(int, input().split()))
list = []
list.append(num[0])
count = 1

for i in range(1,n):
  if num[i]<=min(a for a in list):
    count += 1
    list.append(num[i])
  else:
    list.append(num[i])

print(count)

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

min_n = num[0]
count = 1
for i in range(1,n):
  if num[i]<=min_n:
    count += 1
    min_n = num[i]
    
print(count)
Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
WA = [0] * N
AC = [0] * N

for i in range(M):
  p,s = input().split()
  p = int(p)
  if AC[p-1] == 0:
    if s == "AC":
      AC[p-1] = 1
      else:
        WA[p-1] += 1
        
wa = 0
for j in range(N):
  if AC[j] == 1:
    wa += WA[j]
print(sum(AC),wa)

Fixed submission:
N, M = map(int, input().split())
WA = [0] * N
AC = [0] * N

for i in range(M):
  p,s = input().split()
  p = int(p)
  if AC[p-1] == 0:
    if s == "AC":
      AC[p-1] = 1
    else:
        WA[p-1] += 1
        
wa = 0
for j in range(N):
  if AC[j] == 1:
    wa += WA[j]
print(sum(AC),wa)
Buggy python submission (verdict: Runtime Error):
n = int(input())
s = input()

count = 0
flag = 0
for ch in s:
  if ch=='A' and flag==0:
    flag = 1
  else:
    flag = 0
  if ch=='B' and flag==1:
    flag = 2
  else:
    flag = 0
  if ch=='C' and flag==2
  	flag = 3
  else: flag = 0
  if flag==3:
    count += 1
    flag = 0

print(count)

Fixed submission:
n = int(input())
s = input()

count = 0
for i in range(n-2):
  if s[i]=='A' and s[i+1]=='B' and s[i+2]=='C':
    count += 1
    
print(count)
Buggy python submission (verdict: Time Limit Exceeded):
x = int(input())

def prime(n):
  a = int(n**(1/2))
  for i in range(2,a+1):
    if n%i==0: return False
  return True

while (1):
  if prime(x)==False: x += 1
  else: break
  x += 1
print(x)


Fixed submission:
n = int(input())

import math
def prime(n):
  a = math.ceil(math.sqrt(n))
  for i in range(2,a):
    if n%i==0: return 1
  return 0

while (1):
  if prime(n)==0: 
    print(n)
    exit()
  n+=1

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

def prime(n):
  a = int(n**(1/2))
  for i in range(2,a+1):
    if n%i==0: return False
  return true

while (1):
  if prime(x)==False: x += 1
  else: break
  x += 1
print(x)


Fixed submission:
n = int(input())

import math
def prime(n):
  a = math.ceil(math.sqrt(n))
  for i in range(2,a):
    if n%i==0: return 1
  return 0

while (1):
  if prime(n)==0: 
    print(n)
    exit()
  n+=1

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

import math
def prime(n):
  a = math.ceil(sqrt(n))
  for i in range(2,a):
    if n%i==0: return 1
  return 0

while (1):
  n += 1
  if prime(n)==1: 
    print(n)
    exit()

Fixed submission:
n = int(input())

import math
def prime(n):
  a = math.ceil(math.sqrt(n))
  for i in range(2,a):
    if n%i==0: return 1
  return 0

while (1):
  if prime(n)==0: 
    print(n)
    exit()
  n+=1
Buggy python submission (verdict: Runtime Error):
n = int(input())
s,t = map(list,input().split())
ans = []
for i in range(n)
  ans.append(s[i])
  ans.append(t[i])
print(''.join(ans))

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

s = ''
for i in range(n):
  s = s + s1[i]
  s = s + s2[i]

print(s)
Buggy python submission (verdict: Runtime Error):
num1, num2 = map(int, input().split())

import math
def factor(num):
  l = []
  a = math.ceil(math.sqrt(num))
  for i in range(2,a):
    if num%i==0:
      l.append(i)
  return l

l1 = factor(num1)
l2 = factor(num2)
l = set(l1,l2)

ans = 1
for _ in l:
  ans = ans * _
  
print(ans)
  

Fixed submission:
num1, num2 = map(int, input().split())

import math
def gcd(num1, num2):
  for i in range(min(num1, num2),0,-1):
    if num1%i==0 and num2%i==0:
      return i
    
print(int(num1*num2/gcd(num1,num2)))

Buggy python submission (verdict: Time Limit Exceeded):
num1, num2 = map(int, input().split())

n = max(num1, num2)
while(1):
  if n%num1==0 and n%num2==0:
    print(n)
    exit()
  n += 1

Fixed submission:
num1, num2 = map(int, input().split())

import math
def gcd(num1, num2):
  for i in range(min(num1, num2),0,-1):
    if num1%i==0 and num2%i==0:
      return i
    
print(int(num1*num2/gcd(num1,num2)))

Buggy python submission (verdict: Runtime Error):
n1, n2 = map(int, input().split())
import math
print(math.gcd(n1,n2))

Fixed submission:
num1, num2 = map(int, input().split())

import math
def gcd(num1, num2):
  for i in range(min(num1, num2),0,-1):
    if num1%i==0 and num2%i==0:
      return i
    
print(int(num1*num2/gcd(num1,num2)))
Buggy python submission (verdict: Runtime Error):
a,b,x = map(int, input().split())

import math
def digit(n):
  return math.floor(math.log(n,10))+1
  
n_max = 10**9
n_min = 0

while((n_max-n_min)>1):
  key = (n_max+n_min)//2
  if a*key + b*digit(key) < x:
    n_min = key
  elif a*key + b*digit(key) > x:
    n_max = key

if n_max*a + b*digit(n_max) < x:
  print(n_max)
else:
  print(n_min)



Fixed submission:
s = input()

dic = {'SUN':7,'MON':1,'TUE':2,'WED':3,'THU':4,'FRI':5,'SAT':6}

if s == 'SUN':
  print(7)
else:
  print(dic['SUN']-dic[s])

Buggy python submission (verdict: Runtime Error):
s = input()

dic = {'SUN':7,'MON':1,'TUE':2,'WED':3,'THU':4'FRI':5,'SAT':6}

if s == 'SUN':
  print(7)
else:
  print(dic['SUN']-dic[s])

Fixed submission:
s = input()

dic = {'SUN':7,'MON':1,'TUE':2,'WED':3,'THU':4,'FRI':5,'SAT':6}

if s == 'SUN':
  print(7)
else:
  print(dic['SUN']-dic[s])
Buggy python submission (verdict: Runtime Error):
print(int(pow(input(),2)))

Fixed submission:
print(int(pow(int(input()),2)))
Buggy python submission (verdict: Runtime Error):
n = int(input())
dis = [list(map(int,input().split())) for _ in range(n)]
ans = 0
num = 0
from itertools import permutations
for path in list(permutations(range(n))):
  num += 1
  path = list(path)
  distance = 0
  for i in range(1,n):
    xi = dis[path[i-1]][0]
    xj = dis[path[i]][0]
    yi = dis[path[i-1]][1]
    xj = dis[path[i]][1]
    distance += (pow(xi-xj,2)+pow(yi-yj,2))**0.5
  ans = ans + distance
ans = ans/num
print(ans)


Fixed submission:
n = int(input())
location = [list(map(int, input().split())) for _ in range(n)]

from itertools import permutations
import math
distance = []
for route in list(permutations(range(1,n+1))):
  route = list(route)

  dis = 0
  for i in range(0,n-1):
    d = math.sqrt(pow(location[route[i]-1][0]-location[route[i+1]-1][0],2) + pow(location[route[i]-1][1]-location[route[i+1]-1][1],2))
    dis = dis + d
  distance.append(dis)
  
ans = sum(distance)/len(list(permutations(range(1,n+1))))
print(ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())
for i in range(1,10):
  for i in range(1,10):
    if i*j == n:
      print('Yes')
      exit()
print('No')  


Fixed submission:
n = int(input())

for i in range(1,10):
  if n%i == 0:
    if int(n/i) <= 9:
      print('Yes')
      exit()
      
print('No')
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())

import math
a = int(math.sqrt(n))

for i in range(a,n+1):
  if n%i == 0:
    move = (i-1) + int(n/i)-1
    print(move)
    exit()

Fixed submission:
n = int(input())

import math
a = int(math.sqrt(n))

point = 1
for i in range(1,a+1):
  if n%i == 0:
    point = i
    
distance = (point-1) + int(n/point)-1
print(distance)
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = map(int,input().split())
ans = [0]*n
for i,j in enumerate(a,start=1):
  ans[j] = i
for i in range(n):
  print(ans[i],' ', end='')


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

ans = [0]*n
for a in list(enumerate(l)):
  a = list(a)
  ans[a[1]-1] = a[0]+1

for _ in ans:
  print(_, ' ', end='')
Buggy python submission (verdict: Time Limit Exceeded):
n_people, full_p, n_ques = map(int, input().split())

point = [full_p]*n_people

for i in range(n_ques):
  people = int(input())
  for j in range(n_people):
    if (j+1) != people: point[j] -= 1
      
for i in range(n_people):
  if point[i]>0: print('Yes')
  else: print('No')

Fixed submission:
n_people, full_p, n_ques = map(int, input().split())

count = [0]*n_people

for i in range(n_ques):
  people = int(input())
  count[people-1] += 1

     
for i in range(n_people):
  if count[i] > n_ques-full_p:
    print('Yes')
  else:
    print('No')
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = list(map(int, input().split()))

if n==1:
  print(0)
  exit()

distance = 1
pl = 0
pr = pl + distance

while (pr<=n-1):
  if s[pl:pr+1]==sorted(s[pl:pr+1])[::-1]:
    pr += 1
    distance += 1
  else:
    pl += 1
    pr += 1

print(distance-1)

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

distance = 0
ans = 0
for i in range(1,n):
  if s[i]<=s[i-1]:
    distance += 1
    ans = max(ans,distance)
  else:
    distance = 0
print(ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())
dic = {}
from collections import Counter
for i in range(n):
  s = list(input())
  s = sorted(s)
  if s not in dic: dic[s] = 1
  else: dic[s] += 1
a = dic.values()
ans = 0
for i in range(len(a)):
  ans += a[i]*(a[i]-1)/2
print(ans)


Fixed submission:
n = int(input())
dic = {}
for i in range(n):
  s = input()
  s = sorted(s)
  s = ''.join(s)
  if s not in dic:
    dic[s] = 1
  else:
    dic[s] += 1

ans = 0
for _ in dic:
  if dic[_]>1: ans = ans + int(dic[_]*(dic[_]-1)/2)
    
print(ans)

Buggy python submission (verdict: Runtime Error):
n = int(input())
counters = {}
from collections import Counter
for i in range(n):
  s = input()
  c = Counter(s)
  if c not in counters: counters[c] = 1
  else: counters[c] += 1
a = counters.values()
ans = 0
for i in range(len(a)):
  ans += a[i]*(a[i]-1)/2
print(ans)


Fixed submission:
n = int(input())
dic = {}
for i in range(n):
  s = input()
  s = sorted(s)
  s = ''.join(s)
  if s not in dic:
    dic[s] = 1
  else:
    dic[s] += 1

ans = 0
for _ in dic:
  if dic[_]>1: ans = ans + int(dic[_]*(dic[_]-1)/2)
    
print(ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())
h = list(map(int, input().split()))

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

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

flag = True
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:
    flag = False
    break
    
if flag:
  print('Yes')
else:
  print('No')

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

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


if h == sorted(h):
  print('Yes')
else:
  print('No')

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

flag = True
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:
    flag = False
    break
    
if flag:
  print('Yes')
else:
  print('No')

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

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

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

flag = True
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:
    flag = False
    break
    
if flag:
  print('Yes')
else:
  print('No')
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
begin = sum(a)
c = 0
for i in range(n):
  a[i] = a[i]-c[i] if a[i]>c[i] else 0
  c = 0
  a[i] = a[i]-b[i] if a[i]>b[i] else 0
  c = b[i] - a[i] if b[i]>a[i] else 0
a[n] = a[n]-c if a[n]>c else 0
after = sum(a)
print(begin-after)


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

c = [0]*(n+1)
ans = 0
for i in range(n):
  if b[i]+c[i] > a[i]:
    if c[i]>=a[i]:
      ans = ans + a[i]
      c[i+1] = b[i]
    else:
      ans = ans + a[i]
      c[i+1] = b[i]+c[i]-a[i]
  else:
    ans = ans + b[i] + c[i]
if c[n]>a[n]:
  ans = ans + a[n]
else:
  ans = ans + c[n]
print(ans)