Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
for i in range(len(d1)):
    for j in range(len(d1)): 
        if(i != j and j > i):
            sum += int(d1[i])*int(d1[j])

print(sum)



Fixed submission:
N = int(input())
d1 = input().split()
sum= 0

for i in range(len(d1)):
    for j in range(len(d1)): 
        if(i != j and j > i):
            sum += int(d1[i])*int(d1[j])

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

for i in range(N):
    print((order.index(i+1))+1, end=' ')

Fixed submission:

N    = int(input())
order=list(map(int,input().split()))
output=[0]*N

for i in range(N):
    output[order[i]-1]=i+1

print(' '.join(map(str,output)))

Buggy python submission (verdict: Time Limit Exceeded):
N    = int(input())
order=list(map(int,input().split()))
output=[]


for i in range(N):
    output.append((order.index(i+1))+1)
print(' '.join(map(str,output)))

Fixed submission:

N    = int(input())
order=list(map(int,input().split()))
output=[0]*N

for i in range(N):
    output[order[i]-1]=i+1

print(' '.join(map(str,output)))
Buggy python submission (verdict: Time Limit Exceeded):
l, r = map(int,input().split())
ans = 2019
for i in range(l, r) :
    for j in range(i + 1, r + 1) :
        ans = min(ans, (i * j) % 2019)
print(ans)

Fixed submission:
l, r = map(int,input().split())
ans = 2019
for i in range(l, r) :
    for j in range(i + 1, r + 1) :
        ans = min(ans, (i * j) % 2019)
        if ans == 0 : 
            break
    if ans == 0 :
        break
print(ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())
m = int(input())
ans = n - m
if ans < 0 :
  ans = 0
print(ans)

Fixed submission:
n, m = map(int,input().split())
ans = n - m
if ans < 0 :
  ans = 0
print(ans)
Buggy python submission (verdict: Runtime Error):
#coding:utf-8

import sys

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

D = 0 #ジャンプする座標

for i in range(N):
    D += L[i]
    if D > X:
        print(i+1)
        sys.exit()

print(N+1)


Fixed submission:
#coding:utf-8
X,A = map(int,input().split())

if X < A:
    print(0)

else:
    print(10)
Buggy python submission (verdict: Runtime Error):
#coding:utf-8

import sys

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

D = 0 #ジャンプする座標

for i in range(N+1):
    D += L[i]
    if D > X:
        print(i+1)
        sys.exit()

print(N+1)


Fixed submission:
#coding:utf-8

import sys

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

D = 0 #ジャンプする座標

for i in range(N):
    D += L[i]
    if D > X:
        print(i+1)
        sys.exit()

print(N+1)
Buggy python submission (verdict: Runtime Error):
#coding:utf-8

import sys

L = list(int(input()) for i in range(6))

for i in range(5):
        for j in range(5):
            if abs(L[i]-L[j]) > L[6]:
                print(":(")
                sys.exit()

print("Yay!")

Fixed submission:
#coding:utf-8

import sys

L = list(int(input()) for i in range(6))

for i in range(5):
        for j in range(5):
            if abs(L[i]-L[j]) > L[5]:
                print(":(")
                sys.exit()

print("Yay!")
Buggy python submission (verdict: Runtime Error):
#coding:utf-8

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

c=a*b

if c % 2 == 0:
    print("Even")

else:
    print("Odd")


Fixed submission:
#coding:utf-8

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

c=a*b

if c % 2 == 0:
    print("Even")

else:
    print("Odd")
Buggy python submission (verdict: Runtime Error):
A = int(input())
B = int(input())
T = int(input())

print(T/A * B)

Fixed submission:
n = input().split()
A = int(n[0])
B = int(n[1])
T = int(n[2])

print(T//A  * B)
Buggy python submission (verdict: Runtime Error):
from math import gcd, ceil
import sys
a, b = map(int, input().split())

gcdv = gcd(a, b)

if gcdv == 1:
    print(1)
    sys.exit(0)
is_so = True
sqrt_v = ceil(gcdv ** 0.5)
cnt = 1
table = [True] * (sqrt_v + 1)
for i in range(2, sqrt_v + 1):
    if table[i] and gcdv % i == 0:
        cnt += 1
        if gcd(gcdv, i) != 1:
            is_so = False
    for k in range(0, sqrt_v, i):
        table[k] = False

if is_so:
    cnt += 1
print(cnt)


Fixed submission:
from fractions import gcd
from collections import Counter
a, b = map(int, input().split())

gcdv = gcd(a, b)

prime_cnt = Counter()
n = gcdv
for i in range(2, int(gcdv ** 0.5) + 2):
    while n % i == 0:
        n //= i
        prime_cnt[i] += 1

prime_cnt[n] += 1
prime_cnt[1] += 1

print(len(prime_cnt.keys()))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
print(sum(range(1, N)))


Fixed submission:
N = int(input())
print((N-1) * N //2)
Buggy python submission (verdict: Runtime Error):
import numpy as np
from scipy import sparse
from scipy.sparse.linalg import inv
N = int(input())
a_list = list(map(int, input().split()))


m = np.zeros((N, N))

for i in range(N):
    m[i, i] = 0.5
    if i+1 == N:
        m[i, 0] = 0.5
    else:
        m[i, i+1] = 0.5

m = sparse.csc_matrix(m)
im = sparse.linalg.inv(m)
print(' '.join(map(str, list(im.dot(np.array(a_list)).astype(int)))))


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

result = [0] * N
for i in range(N):
    result[0] += a_list[i] * (1 if i % 2 == 0 else -1)

for i in range(1, N):
    result[i] = 2 * a_list[i-1] - result[i-1]

print(' '.join(map(str, result)))

Buggy python submission (verdict: Runtime Error):
import numpy as np
N = int(input())
a_list = list(map(int, input().split()))

m = np.zeros((N, N))

for i in range(N):
    m[i, i] = 0.5
    if i+1 == N:
        m[i, 0] = 0.5
    else:
        m[i, i+1] = 0.5

inv = np.linalg.inv(m)
print(' '.join(map(str, list(np.dot(inv, np.array(a_list)).astype(int)))))


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

result = [0] * N
for i in range(N):
    result[0] += a_list[i] * (1 if i % 2 == 0 else -1)

for i in range(1, N):
    result[i] = 2 * a_list[i-1] - result[i-1]

print(' '.join(map(str, result)))
Buggy python submission (verdict: Runtime Error):
N, K = list(map(int, input().split()))

def c(n, k):
    result = 1
    for i in range(k):
        result *= n - i
    for i in range(k):
        result /= i + 1
    return int(result)

denom = (10 ** 9 + 7)
total = 0
for i in range(K):
    ni = (c(K-1, i) % denom) * (c(N-K+1, i+1) % denom)
    print(ni % denom)



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

def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7 #出力の制限
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )


for i in range(K):
    ni = (cmb(K-1, i, mod)) * (cmb(N-K+1, i+1, mod))
    print(ni % mod)

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

def c(n, k):
    result = 1
    for i in range(k):
        result *= n - i
    for i in range(k):
        result /= i + 1
    return int(result)

total = 0
for i in range(K):
    ni = c(K-1, i) * c(N-K+1, i+1)
    print(ni % (10 ** 9 + 7))



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

def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7 #出力の制限
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )


for i in range(K):
    ni = (cmb(K-1, i, mod)) * (cmb(N-K+1, i+1, mod))
    print(ni % mod)
Buggy python submission (verdict: Runtime Error):
A, B, C, D = list(map(int, input().split()))
from math import gcd
e = C * D // gcd(C, D)
p1 = B-A+1
p2 = (B//C) + (B//D) - (B//e)
p3 = ((A-1)//C) + ((A-1)//D) - ((A-1)//e)
print(p1 + p3 - p2)


Fixed submission:
A, B, C, D = list(map(int, input().split()))
from fractions import gcd
e = C * D // gcd(C, D)
p1 = B-A+1
p2 = (B//C) + (B//D) - (B//e)
p3 = ((A-1)//C) + ((A-1)//D) - ((A-1)//e)
print(p1 + p3 - p2)

Buggy python submission (verdict: Runtime Error):
A, B, C, D = list(map(int, input().split()))
from functools import gcd
e = C * D // gcd(C, D)
p1 = B-A+1
p2 = (B//C) + (B//D) - (B//e)
p3 = ((A-1)//C) + ((A-1)//D) - ((A-1)//e)
print(p1 + p3 - p2)


Fixed submission:
A, B, C, D = list(map(int, input().split()))
from fractions import gcd
e = C * D // gcd(C, D)
p1 = B-A+1
p2 = (B//C) + (B//D) - (B//e)
p3 = ((A-1)//C) + ((A-1)//D) - ((A-1)//e)
print(p1 + p3 - p2)
Buggy python submission (verdict: Runtime Error):
w, h, x, y = list(map(int, input().split()))
print(w * h / 2, 1 int((w==x*2) and (h==y*2)))


Fixed submission:
w, h, x, y = list(map(int, input().split()))
print(w * h / 2, 1 if (w==x*2) and (h==y*2) else 0)

Buggy python submission (verdict: Runtime Error):
2 2 1 1


Fixed submission:
w, h, x, y = list(map(int, input().split()))
print(w * h / 2, 1 if (w==x*2) and (h==y*2) else 0)
Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter

N, M = list(map(int, input().split()))
range_dict = Counter()
for _ in range(M):
    l, r = list(map(int, input().split()))
    for i in range(l, r+1):
        range_dict[i] += 1

print(len([v for k, v in range_dict.most_common() if v==M]))


Fixed submission:
from collections import Counter

N, M = list(map(int, input().split()))
max_l = 1
min_r = N
for _ in range(M):
    l, r = list(map(int, input().split()))
    if max_l < l:
        max_l = l
    if min_r > r:
        min_r = r

print(min_r - max_l + 1 if min_r - max_l >= 0 else 0)
Buggy python submission (verdict: Time Limit Exceeded):
from fractions import gcd
from functools import reduce
N = int(input())
A = list(map(int, input().split()))

L = [0]
R = [0]
for i in range(N):
    L.append(gcd(L[i], A[i]))
    R.insert(0, gcd(R[0], A[N-i-1]))   

M = []
for i in range(N):
    M.append(gcd(L[i], R[i+1]))
print(max(M))


Fixed submission:
from fractions import gcd
from functools import reduce
N = int(input())
A = list(map(int, input().split()))

L = [0] * (N+1)
R = [0] * (N+1)
for i in range(N):
    L[i+1] = gcd(L[i], A[i])
    R[N-i-1] = gcd(R[N-i], A[N-i-1])

max_m = 0
for i in range(N):
    m = gcd(L[i], R[i+1])
    if max_m < m:
        max_m = m
print(max_m)

Buggy python submission (verdict: Time Limit Exceeded):
from fractions import gcd
from functools import reduce
N = int(input())
a_list = list(map(int, input().split()))

max_gcd_list = []
for i in range(N):
    new_list = a_list[:i] + (a_list[(i+1):] if i < N-1 else [])
    max_gcd = reduce(gcd, new_list[1:], new_list[0])
    max_gcd_list.append(max_gcd)
print(max(max_gcd_list))

Fixed submission:
from fractions import gcd
from functools import reduce
N = int(input())
A = list(map(int, input().split()))

L = [0] * (N+1)
R = [0] * (N+1)
for i in range(N):
    L[i+1] = gcd(L[i], A[i])
    R[N-i-1] = gcd(R[N-i], A[N-i-1])

max_m = 0
for i in range(N):
    m = gcd(L[i], R[i+1])
    if max_m < m:
        max_m = m
print(max_m)

Buggy python submission (verdict: Runtime Error):
from math import gcd
from functools import reduce
N = int(input())
a_list = list(map(int, input().split()))

max_gcd_list = []
for i in range(N):
    new_list = a_list[:i] + (a_list[(i+1):] if i < N-1 else [])
    max_gcd = reduce(gcd, new_list[1:], new_list[0])
    max_gcd_list.append(max_gcd)
print(max(max_gcd_list))



Fixed submission:
from fractions import gcd
from functools import reduce
N = int(input())
A = list(map(int, input().split()))

L = [0] * (N+1)
R = [0] * (N+1)
for i in range(N):
    L[i+1] = gcd(L[i], A[i])
    R[N-i-1] = gcd(R[N-i], A[N-i-1])

max_m = 0
for i in range(N):
    m = gcd(L[i], R[i+1])
    if max_m < m:
        max_m = m
print(max_m)
Buggy python submission (verdict: Runtime Error):
import re


dd = input().strip().split(' ')
N, Q = tuple(map(int, dd))
S = input().strip()

ac_indicies = []
cp = S.find('AC')
while cp != -1:
    ac_indicies.append(cp)
    cp = S.find('AC', cp + 1)

min_i = 0
ac = ac_indicies + [N]
l_index = []
for i in range(N):
    if i > ac[min_i]:
        min_i += 1
    l_index.append(min_i)

max_i = len(ac_indicies)
ac2 = [0] + ac_indicies
r_index = []
for i in range(N-1, -1, -1):
    if i < ac[max_i]:
        max_i -= 1
    r_index.append(max_i)
   
total = len(ac_indicies)
for i in range(int(Q)):
    l, r = tuple(map(int, input().strip().split(' ')))
    print(total - l_index[l-1] - r_index[r-1])


Fixed submission:
dd = input().strip().split(' ')
N, Q = tuple(map(int, dd))
S = input().strip()

ac_indicies = []
cp = S.find('AC')
while cp != -1:
    ac_indicies.append(cp)
    cp = S.find('AC', cp + 1)

min_i = 0
ac = ac_indicies + [N]
l_index = []
for i in range(N):
    if i > ac[min_i]:
        min_i += 1
    l_index.append(min_i)

total = len(ac_indicies)
for i in range(int(Q)):
    l, r = tuple(map(int, input().strip().split(' ')))
    print(l_index[r-1] - l_index[l-1])

Buggy python submission (verdict: Time Limit Exceeded):
N, Q = input().strip().split(' ')
S = input().strip()

for i in range(int(Q)):
    l, r = tuple(map(int, input().strip().split(' ')))
    print(S[l-1:r].count('AC'))


Fixed submission:
dd = input().strip().split(' ')
N, Q = tuple(map(int, dd))
S = input().strip()

ac_indicies = []
cp = S.find('AC')
while cp != -1:
    ac_indicies.append(cp)
    cp = S.find('AC', cp + 1)

min_i = 0
ac = ac_indicies + [N]
l_index = []
for i in range(N):
    if i > ac[min_i]:
        min_i += 1
    l_index.append(min_i)

total = len(ac_indicies)
for i in range(int(Q)):
    l, r = tuple(map(int, input().strip().split(' ')))
    print(l_index[r-1] - l_index[l-1])
Buggy python submission (verdict: Time Limit Exceeded):
N,K = map(int, input().split())
A = list(map(int, input().split()))

cnt = 0
for i in range(N):
    temp = 0
    for j in range(i,N):
        temp += A[j]
        if j-i+1 >= K:
            break;
        if temp%K == j-i+1:
            cnt += 1
print (cnt)

Fixed submission:
N,K = map(int, input().split())
A = list(map(int, input().split()))
S = [0 for i in range(N+1)]
for i in range(1,N+1):
    S[i] = S[i-1] + A[i-1]
cnt = 0
dict1 = {}
        
dict1[0] = 1

for j in range(1,N+1):
    if j-K >= 0:
        dict1[(S[j-K]-j+K)%K] -= 1
    if (S[j]-j)%K in dict1:
        cnt += dict1[(S[j]-j)%K]
        dict1[(S[j]-j)%K] += 1
    else:
        dict1[(S[j]-j)%K] = 1
print (cnt)

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

cnt = 0
for i in range(N):
    temp = 0
    for j in range(i,N):
        temp += A[j]
        if temp%K == j-i+1:
            cnt += 1
            
print (cnt)

Fixed submission:
N,K = map(int, input().split())
A = list(map(int, input().split()))
S = [0 for i in range(N+1)]
for i in range(1,N+1):
    S[i] = S[i-1] + A[i-1]
cnt = 0
dict1 = {}
        
dict1[0] = 1

for j in range(1,N+1):
    if j-K >= 0:
        dict1[(S[j-K]-j+K)%K] -= 1
    if (S[j]-j)%K in dict1:
        cnt += dict1[(S[j]-j)%K]
        dict1[(S[j]-j)%K] += 1
    else:
        dict1[(S[j]-j)%K] = 1
print (cnt)
Buggy python submission (verdict: Runtime Error):
import math

N = int(input())
sum = N - 1
b = int(math.sqrt(N))
for i in range(2, b+1):
    if(N%i==0):
        if((a/i+i-2)<=sum):
            sum = N/i+i-2

print(sum)

Fixed submission:
import math

N = int(input())
sum = N - 1
b = int(math.sqrt(N))
for i in range(2, b+1):
    if(N%i==0):
        if((N//i+i-2)<=sum):
            sum = N//i+i-2

print(sum)
Buggy python submission (verdict: Runtime Error):
import math

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

x2 = x/a
c = x2*2/a - b
ans=math.atan(a/(b-c))
ans = 90 - ans / math.pi * 180
if c <= 0:
    c = x2*2 / b
    ans=math.atan(c/b)
    ans = 90 - ans / math.pi * 180


print(ans)

Fixed submission:
import math

a, b, x = map(int, input().split())
if (x == a*a*b):
    ans = 0.0000000000
    print(ans)
else:
    x2 = x/a
    c = x2*2/a - b
    ans=math.atan(a/(b-c))
    ans = 90 - ans / math.pi * 180
    if c <= 0:
        c = x2*2 / b
        ans=math.atan(c/b)
        ans = 90 - ans / math.pi * 180
    print(ans)

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

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

x2 = x/a
c = x2*2/a - b
ans=math.atan(a/(b-c))
ans = 90 - ans / math.pi * 180
if c < 0:
    c = x2*2 / b
    ans=math.atan(c/b)
    ans = 90 - ans / math.pi * 180


print(ans)

Fixed submission:
import math

a, b, x = map(int, input().split())
if (x == a*a*b):
    ans = 0.0000000000
    print(ans)
else:
    x2 = x/a
    c = x2*2/a - b
    ans=math.atan(a/(b-c))
    ans = 90 - ans / math.pi * 180
    if c <= 0:
        c = x2*2 / b
        ans=math.atan(c/b)
        ans = 90 - ans / math.pi * 180
    print(ans)
Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
a = [0 for _ in range(M)]
b = [0 for _ in range(M)]
c = []
for i in range(M):
  a[i], b[i] = map(int, input().split())
  c.append(list(map(int, input().split())))

set_check = set([i+1 for i in range(N)])

def findkey(step, set_in, sum):
  if step == M-1:
    if set_check.issubset(set_in):
      return sum
    else:
      return -1
  right = findkey(step+1, set_in, sum)
  left = findkey(step+1, set_in | set(c[step+1]), sum+a[step+1])
  if left == -1:
    return right
  if right == -1:
    return left
  return min(left, right)
print(findkey(-1, set([]), 0))

Fixed submission:
N = int(input())
cnt = 0
for i in range(1,N+1):
  if (i%2 == 1) :
    cnt += 1
print(cnt/N)
Buggy python submission (verdict: Time Limit Exceeded):
N, K, Q = map(int, input().split())
A = []
for i in range(Q):
  A.append(int(input()))

P = [K for i in range(N)]


for i in range(Q):
  for j in range(N):
    if j != A[i] - 1:
      P[j] = P[j] - 1
      

for i in range(N):
  if (P[i] < 1):
    print("No")
  else:
    print("Yes")

Fixed submission:
N, K, Q = map(int, input().split())
A = []
for i in range(Q):
  A.append(int(input()))

P = [0 for i in range(N)]


for i in range(Q):
    P[A[i] - 1] = P[A[i] - 1] + 1
      

for i in range(N):
  if (Q - P[i] >= K ):
    print("No")
  else:
    print("Yes")
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
H = input().split()

for i in range(N):
  H[i] = int(H[i])

Cnt = 0
MaxCnt = 0

if (N == 1):
  print(0)
else:
  for i in range(N-1):
    Cnt = 0
    for j in range(i, N-1, 1):
      if (H[j] >= H[j+1]):
        Cnt += 1
      else:
        break
    MaxCnt = max(Cnt, MaxCnt)
  print(MaxCnt)

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

for i in range(N):
  H[i] = int(H[i])

Cnt = 0
MaxCnt = 0

if (N == 1):
  print(0)
else:
  i = 0
  while(i < N-1):
    Cnt = 0
    for j in range(i, N-1, 1):
      if (H[j] >= H[j+1]):
        Cnt += 1
        if (j == N-2):
          i = j+1
      else:
        i = j+1
        break
    MaxCnt = max(Cnt, MaxCnt)
  print(MaxCnt)
Buggy python submission (verdict: Runtime Error):
a = int(input())
b = input().split()
for i in range(a):
  b[i] = int(b[i])
  
for i in range(a-1):
  if (b[i] > b[i+1]):
    break
if i == a-2:
  print('YES')
else:
  for j in range(a-1,i,-1):
    if (b[j] < b[j-1]):
      break
  temp = b[i]
  b[i] = b[j]
  b[j] = temp
  for k in range(a-1):
    if (b[k] > b[k+1]):
      break
  if k == a-2:
    print('YES')
  else:
    print('NO')

Fixed submission:
a, b = map(int, input().split())
if (a + b)%2 == 0:
  k = (a + b)//2
  print(k)
else:
  print('IMPOSSIBLE')
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

MaxValue = 0
if N == 1:
  MaxValue = min(B[0], A[0]+A[1])
  print(MaxValue)
else:
  for i in range(N):
    if A[i] < B[i]:
      #MaxValue += A[i]
      if A[i+1] < B[i] - A[i]:
        MaxValue += A[i+i] + A[i]
        A[i+1] = 0
      else:
        temp = B[i] - A[i]
        MaxValue += B[i]
        A[i+1] -= temp
    else:
      MaxValue += B[i]
  print(MaxValue)

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

MaxValue = 0
if N == 1:
  MaxValue = min(B[0], A[0]+A[1])
  print(MaxValue)
else:
  for i in range(N):
    if A[i] < B[i]:
      #MaxValue += A[i]
      if A[i+1] < B[i] - A[i]:
        MaxValue += A[i+1] + A[i]
        A[i+1] = 0
      else:
        temp = B[i] - A[i]
        MaxValue += B[i]
        A[i+1] -= temp
    else:
      MaxValue += B[i]
  print(MaxValue)

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

MaxValue = 0
if N == 1:
  MaxValue = min(B[0], A[0]+A[1])
  print(MaxValue)
else:
  for i in range(N):
    if A[i] < B[i]:
      MaxValue += A[i]
      if A[i+1] < B[i] - A[i]:
        MaxValue += A[i+i]
        A[i+1] = 0
      else:
        temp = B[i] - A[i]
        MaxValue += temp
        A[i+1] -= temp
    else:
      MaxValue += B[i]
  print(MaxValue)

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

MaxValue = 0
if N == 1:
  MaxValue = min(B[0], A[0]+A[1])
  print(MaxValue)
else:
  for i in range(N):
    if A[i] < B[i]:
      #MaxValue += A[i]
      if A[i+1] < B[i] - A[i]:
        MaxValue += A[i+1] + A[i]
        A[i+1] = 0
      else:
        temp = B[i] - A[i]
        MaxValue += B[i]
        A[i+1] -= temp
    else:
      MaxValue += B[i]
  print(MaxValue)
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

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

Fixed submission:
n = int(input())
print(n**3)
Buggy python submission (verdict: Runtime Error):
n = int(input())

order = list(map(int, input().split()))
menu = {}
tmp = list(map(int, input().split()))
for i in range(n):
    menu[i] = tmp[i]
# print(menu)
add = {}
tmp = list(map(int, input().split()))
for i in range(n-1):
    add[i] = tmp[i]

result = 0

for i in range(len(order)):
    # print(order[i]-1, menu[order[i]-1])
    result += menu[order[i]-1]
    if i < len(order)-1:
        if order[i+1] - order[i] == 1:
            # print(add[i-1])
            result += add[i-1]

print(result)

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

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