Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
S = input()
Q = int(input())
Que = [list(map(str,input().split())) for i in range(Q)]

from collections import deque

S = list(S)
S = deque(S)

for i in range(Q):
    if Que[i][0] == '1':
        S.reverse()
    elif Que[i][0] == '2':
        if Que[i][1] == '1':
            S.appendleft(Que[i][2])
        elif Que[i][1] == '2':
            S.append(Que[i][2])
            
print("".join(S))

Fixed submission:
S = input()
Q = int(input())
Que = [list(map(str,input().split())) for i in range(Q)]

from collections import deque
count = 0
 
S = list(S)
S = deque(S)
 
for i in range(Q):
    if Que[i][0] == '1':
        #S.reverse()
        count += 1
    elif Que[i][0] == '2':
        if Que[i][1] == '1' and count%2 == 0:
            S.appendleft(Que[i][2])
        elif Que[i][1] == '1' and count%2 == 1:
            S.append(Que[i][2])
        elif Que[i][1] == '2' and count%2 == 0:
            S.append(Que[i][2])
        elif Que[i][1] == '2' and count%2 == 1:
            S.appendleft(Que[i][2])
            
if count%2 == 0:
    print("".join(S))
else:
    S.reverse()
    print("".join(S))
Buggy python submission (verdict: Time Limit Exceeded):
n,k = list(map(int,input().split()))

ans = 1

while n != 1:
    ans += 1
    n = n//k
    
print(ans)

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

ans = 1

while n >= k:
    ans += 1
    n = n//k
    
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n,a,b = 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 #出力の制限
N = 10**9
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 )

nCa = cmb(n,a,mod)
nCb = cmb(n,b,mod)
ans = (int(pow(2,n)) - nCa - nCb - 1)%10**9+7

print(ans)

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

MOD = 10**9+7

def comb(n,r,MOD):
    x = n+1
    y = min(r,n-r)
    
    numer = 1
    denom = 1
    
    for i in range(1,r+1):
        numer = numer*(x-i)%MOD
        denom = denom*(i)%MOD
    
    return numer * pow(denom,MOD-2,MOD) % MOD

nCa = comb(n,a,MOD)
nCb = comb(n,b,MOD)

ans = pow(2,n,MOD)-1 - nCa - nCb

if ans < 0:
    print((ans+MOD)%MOD)
else:
    print(ans%MOD)
Buggy python submission (verdict: Time Limit Exceeded):
N,K = list(map(int,input().split()))
p = list(map(int,input().split()))

p_kitai = []
max = 0
max2 = 0

for i in range(len(p)):
    p_kitai.append(sum(range(1,p[i]+1))/p[i])
    
for i in range(len(p)-K+1):
    k = i
    for j in range(K):
        max += p_kitai[k]
        k += 1
    if max > max2:
        max2 = max
        max = 0
    else:
        max = 0
        
print(max2)

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

value = [0]*N
k_list = []

for i in range(N):
    value[i] = (p[i]+1)*0.5
    
value_list = [0]*N

for i in range(N):
    value_list[i] = value_list[i-1] + value[i]

value_list.append(0)

for i in range(N-K+1):
    k_list.append(value_list[i+K-1]-value_list[i+K-(K+1)])
    
print(max(k_list))
Buggy python submission (verdict: Runtime Error):
alpha = ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","a"]
C = input()
for i in range(len(alpha)):
    if C == alpha[i]:
        print(alpha[i+1])

Fixed submission:
alpha = ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]
C = input()
for i in range(len(alpha)):
    if C == alpha[i]:
        print(alpha[i+1])
Buggy python submission (verdict: Runtime Error):
N,M = list(map(int,input().split()))
ps = []
for i in range(M):
    ps.append(list(map(str,input().split())))
    
import sys

if M == 0:
    print(0,0)
    sys.exit()

ps_new = sorted(ps , key=lambda x: x[0])
toi = []

for i in range(M):
    toi.append(ps[i][0])
    
toi2 = toi[0]
toi3 = [toi2]

for i in range(M):
    if toi2 != toi[i]:
        toi3.append(toi[i])
        toi2 = toi[i]
toi3.append("0")

toi = ps_new[0][0]
j = 0
count1 = 0
count2 = 0
count3 = 0

for i in range(M):
    if toi == ps[i][0]:
        count2 += 1
        if count2 == 1:
            shokai = i
        if ps_new[i][1] == "AC":
            count1 += 1
            j += 1
            toi = toi3[j]
            count2 = 0
            count3 = count3 + (i-shokai)
    elif toi != ps[i][0] and ps_new[i][1] == "AC":
        count+=1
print(count1,count3)

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

AC = [0]*N
WA = [0]*N
miss = 0

for i in range(M):
    p,S = list(map(str,input().split()))
    p = int(p)-1
    
    if S == 'AC' and AC[p] == 0:
        AC[p] = 1
        miss += WA[p]
        
    WA[p] += 1
        
print(sum(AC),miss)

Buggy python submission (verdict: Runtime Error):
N,M = list(map(int,input().split()))
ps = []
for i in range(M):
    ps.append(list(map(str,input().split())))
    
ps_new = sorted(ps , key=lambda x: x[0])
toi = []

for i in range(M):
    toi.append(ps[i][0])
    
toi2 = toi[0]
toi3 = [toi2]

for i in range(M):
    if toi2 != toi[i]:
        toi3.append(toi[i])
        toi2 = toi[i]
toi3.append("0")

toi = ps_new[0][0]
j = 0
count1 = 0
count2 = 0
count3 = 0

for i in range(M):
    if toi == ps[i][0]:
        count2 += 1
        if count2 == 1:
            shokai = i
        if ps_new[i][1] == "AC":
            count1 += 1
            j += 1
            toi = toi3[j]
            count2 = 0
            count3 = count3 + (i-shokai)
            
print(count1,count3)

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

AC = [0]*N
WA = [0]*N
miss = 0

for i in range(M):
    p,S = list(map(str,input().split()))
    p = int(p)-1
    
    if S == 'AC' and AC[p] == 0:
        AC[p] = 1
        miss += WA[p]
        
    WA[p] += 1
        
print(sum(AC),miss)
Buggy python submission (verdict: Runtime Error):
N = int(input())
P = list(map(str,input().split()))
Q = list(map(str,input().split()))

import itertools
 
n_list = [i+1 for i in range(N)]
all_list = list(itertools.permutations(A))
a = all_list.index(P)
b = all_list.index(Q)
print(abs(a - b))


Fixed submission:
N = int(input())
P = tuple(map(int,input().split()))
Q = tuple(map(int,input().split()))

import itertools

A = [i+1 for i in range(N)]
all_permutation_list = list(itertools.permutations(A))
a = all_permutation_list.index(P)
b = all_permutation_list.index(Q)
print(abs(a - b))
Buggy python submission (verdict: Runtime Error):
from math import gcd
N, M = map(int, input().split())
A = list(map(int, input().split()))
A = [i // 2 for i in a]
l = 1
for a in A:
    lcd *= a // gcd(lcd, a)
for a in A:
    if lcd // a % 2 == 0:
        print(0)
        exit()
print((M//lcd+1)//2)


Fixed submission:
from math import gcd, ceil
n, m = map(int, input().split())
a = list(map(int, input().split()))
a = [i // 2 for i in a]
l = 1
for i in a:
    l *= i // gcd(l, i)
for i in a:
    if l // i % 2 == 0:
        print(0)
        exit()
print(ceil((m // l) / 2))

Buggy python submission (verdict: Runtime Error):
from math import gcd, ceil
n, m = map(int, input().split())
a = list(map(int, input().split()))
a = [i // 2 for i in a]
tmp = 1
for i in range(n):
    lcm = tmp * (a[i]//2) // gcd(tmp,a[i]//2)
    tmp = lcm
for i in range(n):
    if tmp // (a[i]//2) % 2 == 0:
        print(0)
        exit()
print((m//tmp+1)//2)

Fixed submission:
from math import gcd, ceil
n, m = map(int, input().split())
a = list(map(int, input().split()))
a = [i // 2 for i in a]
l = 1
for i in a:
    l *= i // gcd(l, i)
for i in a:
    if l // i % 2 == 0:
        print(0)
        exit()
print(ceil((m // l) / 2))

Buggy python submission (verdict: Runtime Error):
from math import gcd, ceil
n, m = map(int, input().split())
a = list(map(int, input().split()))
a = [i // 2 for i in a]
tmp = 1
for i in a:
    lcm = tmp * (a[i]//2) // gcd(tmp,a[i]//2)
    tmp = lcm
for i in a:
    if tmp // i % 2 == 0:
        print(0)
        exit()
print((m//tmp+1)//2)

Fixed submission:
from math import gcd, ceil
n, m = map(int, input().split())
a = list(map(int, input().split()))
a = [i // 2 for i in a]
l = 1
for i in a:
    l *= i // gcd(l, i)
for i in a:
    if l // i % 2 == 0:
        print(0)
        exit()
print(ceil((m // l) / 2))

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

import fractions
import sys

lcm = a[0]//2

for i in range(1, N):
    lcm = lcm * (a[i]//2) // fractions.gcd(lcm, a[i]//2)

    
count_list = []
count = 0
for i in range(N):
    while a[i] % 2 == 0:
        count += 1
        a[i] = a[i] // 2
    count_list.append(count)
    count = 0
    
for i in range(N):
    if count_list[i] != sum(count_list)/N:
        print(0)
        sys.exit()
    

print(-(-(M//lcm) // 2))

Fixed submission:
from math import gcd, ceil
n, m = map(int, input().split())
a = list(map(int, input().split()))
a = [i // 2 for i in a]
l = 1
for i in a:
    l *= i // gcd(l, i)
for i in a:
    if l // i % 2 == 0:
        print(0)
        exit()
print(ceil((m // l) / 2))
Buggy python submission (verdict: Time Limit Exceeded):
A,B,K = list(map(int,input().split()))

for i in range(K):
    if A==0:
        B-=1
    else:
        A-=1
    
print(A,B)

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

if A+B <= K:
    print(0,0)
else:
    if A >= K:
        print(A-K,B)
    else:
        print(0,B-(K-A))
Buggy python submission (verdict: Runtime Error):
X = int(input())

import math
#----エラトステネスの篩--------
def get_primenumber(number):
    prime_list = []
    #2からnumberまでの数字をsearch_listに入れる
    search_list = list(range(2,number+1))
    while True:
      #search_listの先頭の値が√nの値を超えたら処理終了
      if search_list[0] > math.sqrt(number):
        #prime_listにsearch_listを結合
        prime_list.extend(search_list)
        break
      else:
        #search_listの先頭をprime_listに入れる
        head_num = search_list[0]
        prime_list.append(head_num)
        #search_listの先頭をpopする
        search_list.pop(0)
        #head_numの倍数を取り除く
        search_list = [num for num in search_list if num % head_num != 0]
    return prime_list
  
  num_list = get_primenumber(10**5+1)
  
  import sys

for i in range(len(num_list)):
    if X <= num_list[i]:
        print(num_list[i])
        sys.exit()

Fixed submission:
X = int(input())

import math
import sys

def is_prime(n):
    if n == 1: return False

    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False

    return True

while True:
    if is_prime(X) == True:
        print(X)
        sys.exit()
    X+=1
Buggy python submission (verdict: Runtime Error):
n = int(input())
 
count = 0
 
if n%2 == 1:
    print(0)
else:
    for i im range(1,100):
        if n < 2*5**i:
            break
        else:
            count = count + (n)//(2*5**i)
            i += 1
        
print(count)

Fixed submission:
n = int(input())
if n % 2:
  print(0)
  quit()
ans = 0
for i in range(1,36):
  ans += (n // (2 * 5 ** i))
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int,input().split()))

nonzero = [0]*60

for i in range(N):
    for j in range(60):
        tmp = (A[i] >> j) & 1
        if tmp != 0:
            nonzero[j] += 1

ans = 0
MOD = 10**9+7

for i in range(60):
    ans += ((N-nonzero[i])*nonzero[i]*(2**i))%MOD
    
print(ans%MOD)
    

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

nonzero = [0]*60

for i in range(N):
    for j in range(60):
        tmp = (A[i] >> j) & 1
        if tmp != 0:
            nonzero[j] += 1

ans = 0
MOD = 10**9+7

for i in range(60):
    ans += ((N-nonzero[i])*nonzero[i]*(2**i))%MOD
    
print(ans%MOD)

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

nonzero = [0]*60

for i in range(N):
    for j in range(60):
        tmp = (A[i] >> j) & 1
        if tmp != 0:
            nonzero[j] += 1

ans = 0
MOD = 10**9+7

for i in range(60):
    ans += (N-nonzero[i])*nonzero[i]*pow(2,(i),MOD)%MOD
    
print(ans%MOD)
    

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

nonzero = [0]*60

for i in range(N):
    for j in range(60):
        tmp = (A[i] >> j) & 1
        if tmp != 0:
            nonzero[j] += 1

ans = 0
MOD = 10**9+7

for i in range(60):
    ans += ((N-nonzero[i])*nonzero[i]*(2**i))%MOD
    
print(ans%MOD)
Buggy python submission (verdict: Runtime Error):
X = int(input())
a = X//100

Xlist = str(X)

import sys

if X <100:
    print(0)
    sys.exit
    
if a*5+1 <= int(Xlist[-2] + Xlist[-1]) and int(Xlist[-2] + Xlist[-1]) <=99:
    print(0)
else:
    print(1)

Fixed submission:
X = int(input())

a = X//100

Xlist = str(X)

import sys

if X <100:
    print(0)
    sys.exit()
    
if a*5+1 <= int(Xlist[-2] + Xlist[-1]) and int(Xlist[-2] + Xlist[-1]) <=99:
    print(0)
else:
    print(1)

Buggy python submission (verdict: Runtime Error):
X = int(input())
  
a = X//100

Xlist = str(X)

if a*5+1 <= int(Xlist[-2] + Xlist[-1]) and int(Xlist[-2] + Xlist[-1]) <=99:
    print(0)
else:
    print(1)

Fixed submission:
X = int(input())

a = X//100

Xlist = str(X)

import sys

if X <100:
    print(0)
    sys.exit()
    
if a*5+1 <= int(Xlist[-2] + Xlist[-1]) and int(Xlist[-2] + Xlist[-1]) <=99:
    print(0)
else:
    print(1)

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

ans = 0

def search(a):
    
    global ans
    
    if a > X:
        return 0
    
    if a == X:
        ans = 1
    
    search(a+100)
    search(a+101)
    search(a+102)
    search(a+103)
    search(a+104)
    search(a+105)
    
    return ans
        
print(search(0))

Fixed submission:
X = int(input())

a = X//100

Xlist = str(X)

import sys

if X <100:
    print(0)
    sys.exit()
    
if a*5+1 <= int(Xlist[-2] + Xlist[-1]) and int(Xlist[-2] + Xlist[-1]) <=99:
    print(0)
else:
    print(1)
Buggy python submission (verdict: Runtime Error):
print(chr(ord(S[i]) + N - 90 + 65), end="")

N = int(input())
S = input()

for i in range(len(S)):
    if (ord(S[i]) + N) > 90:
        print(chr(ord(S[i]) + N - 90 + 64), end="")
    else:
        print(chr(ord(S[i]) + N ), end="")
    

Fixed submission:
N = int(input())
S = input()

alpha = ['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z']

ans =[]

for i in range(len(S)):
    for j in range(26):
        if S[i] == alpha[j]:
            ans.append(alpha[j+N])

for i in range(len(ans)):
    print(ans[i], end ="")
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
 
count1 = 0
count2 = 0

A_new = sorted(A)
B_new = sorted(B)
 
for i in range(N):
    if B_new[i] >= A_new[i]:
        count2 += 1
 
for i in range(N):
    for j in range(N):
        if A[i] == A_new[j] and B[i] == B_new[j] 
            count1 = 1
            break
        if A[i] == A_new[j] and B[i] < B_new[j]
            break
    if count1 == 1:
        break
 
if count1 == 1 and count2 == N:
    print("Yes")
else:
    print("No")

Fixed submission:
N = int(input())

if N%2 == 0:
    print(int(N/2)-1)
else:
    print(int(N//2))

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

count1 = 0
count2 = 0

AB = []
AB_new = []
A_new = sorted(A)
B_new = sorted(B)

for i in range(N):
    AB.append([A[i],B[i]])
    AB_new.append([A_new[i],B_new[i]])
    
aaa = sorted(AB, key=lambda x:(x[0],x[1]))

for i in range(N):
    if B_new[i] >= A_new[i]:
        count2 += 1

for i in range(N):
    for j in range(N):
        if aaa[i] == AB_new[j]:
            count1 = 1
            break
        if AB_new[j][0] > aaa[i][0]:
            break
    if count1 == 1:
        break

if count1 == 1 and count2 == N:
    print("Yes")
else:
    print("No")

Fixed submission:
N = int(input())

if N%2 == 0:
    print(int(N/2)-1)
else:
    print(int(N//2))
Buggy python submission (verdict: Runtime Error):
n = int(input())

divisors = []
for i in range(1, int(n**0.5)+1):
    if n % i == 0:
        divisors.append(i)
        if i != n // i:
               divisors.append(n//i)
            
print(min(divisors[-1]+divisors[-2]-2,divisors[-3]+divisors[-4]-2))

Fixed submission:
N = int(input())

count = 0

for i in range(1,10):
    if N%i == 0 and N//i < 10:
        count+=1
        
if count > 0:
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Runtime Error):
n = int(input())

divisors = []
for i in range(1, int(n**0.5)+1):
    if n % i == 0:
        divisors.append(i)
        if i != n // i:
               divisors.append(n//i)


if len(divisors) > 2:
    print(min(divisors[-1]+divisors[-2]-2,divisors[-3]+divisors[-4]-2))
else:
    print(divisors[-1]+divisors[-2]-2)


Fixed submission:
n = int(input())

divisors = []
for i in range(1, int(n**0.5)+1):
    if n % i == 0:
        divisors.append(i)
        if i != n // i:
               divisors.append(n//i)

divisors.append(divisors[-1])

aaa = 0
bbb = 10**12+1
j = 0

for i in range(1,len(divisors)//2+1):
    aaa = divisors[j]+divisors[j+1]-2
    if aaa < bbb:
        bbb = aaa
    j += 2
    
print(bbb)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
L = list(map(int,input().split()))

L.sort(reverse=True)

import itertools
from math import factorial

nCr = N*(N-1)*(N-2)/6
A = []*(int(nCr))

A = list(itertools.combinations(L,3))

count = 0
 
for i in range(len(A)):
    a = A[i][0]
    b = A[i][1]
    c = A[i][2]
    
    if b+c > a:
        count += 1
print(count)  

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

L.sort()

import bisect
ans = 0

for i in range(N-2):
    for j in range(i+1,N-1):
        a = L[i] 
        b = L[j] 
        
        insert_index = bisect.bisect_left(L,a+b)
        #print(insert_index,a,b,a+b)
        
        if i < insert_index:
            ans += insert_index - j - 1
            #print(i,j,insert_index)
        
print(ans)

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

L.sort(reverse=True)

import itertools
from math import factorial

nCr = factorial(7) / factorial(3) / factorial(7 - 3)
A = []*(int(nCr))

A = list(itertools.combinations(L,3))

count = 0
 
for i in range(len(A)):
    a = A[i][0]
    b = A[i][1]
    c = A[i][2]
    
    if a+b > c and b+c > a and c+a > b:
        count += 1
print(count)  

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

L.sort()

import bisect
ans = 0

for i in range(N-2):
    for j in range(i+1,N-1):
        a = L[i] 
        b = L[j] 
        
        insert_index = bisect.bisect_left(L,a+b)
        #print(insert_index,a,b,a+b)
        
        if i < insert_index:
            ans += insert_index - j - 1
            #print(i,j,insert_index)
        
print(ans)

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

L.sort(reverse=True)

L_new = []

for i in range(N):
    for j in range(i+1,N):
        for k in range(j+1,N):
            L_new.append([L[i],L[j],L[k]])
            
count = 0

for i in range(len(L_new)):
    a = L_new[i][0]
    b = L_new[i][1]
    c = L_new[i][2]
    
    if a+b > c and b+c > a and c+a > b:
        count += 1
print(count)  

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

L.sort()

import bisect
ans = 0

for i in range(N-2):
    for j in range(i+1,N-1):
        a = L[i] 
        b = L[j] 
        
        insert_index = bisect.bisect_left(L,a+b)
        #print(insert_index,a,b,a+b)
        
        if i < insert_index:
            ans += insert_index - j - 1
            #print(i,j,insert_index)
        
print(ans)
Buggy python submission (verdict: Runtime Error):
from sympy import nextprime
A,B = list(map(int,input().split()))
 
aaa = []
 
for i in range(1,min(A,B)):
    if A%i == 0 and B%i == 0:
        aaa.append(i)
        
count = 0
 
for i in range(len(aaa)):
    if isprime(aaa[i]) == True:
        count += 1
        
print(count+1)

Fixed submission:
N = int(input())
print(1-(N//2)/N)
Buggy python submission (verdict: Time Limit Exceeded):
N,M = map(int,input().split())
A = list(map(int,input().split()))

while M > 0:
    A.sort()
    tmp = A.pop(-1)
    tmp = tmp//2
    M -= 1
    A.append(tmp)
    
print(sum(A))

Fixed submission:
from heapq import heappop,heappush,heapify
 
N,M = map(int,input().split())
A = [int(x) for x in input().split()]
 
A_minus = [-x for x in A]

# priority queue を使う
# 最小値を取り出す、要素を挿入する
heapify(A_minus)

for _ in range(M):
    tmp_min = heappop(A_minus)
    tmp_min = (-1)*(-tmp_min//2)
    heappush(A_minus,tmp_min)
    
print(-sum(A_minus))
Buggy python submission (verdict: Runtime Error):
n=int(input())
a_list = list(map(int,input().split()))
b_list = list(map(int,input().split()))
c_list = list(map(int,input().split()))
count = 0
for i in range(n):
    index=a_list[i]
    count += b_list[index - 1]
#     print(count)
    if i !=0:
        if a_list[i] == a_list[i-1] + 1:
            count += c_list[a_list[i-1]-1]
print(count)

Fixed submission:
N = int(input())
print(N*N*N)

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()))
 
answer = 0
 
for i in range(N):
  index = A[i]
  answer = answer + B[index-1]

  if i != 0:
    if A[i] == A[i-1]+1:
      answer = answer + C[A[i-1]-1]
      
print(answer)

Fixed submission:
N = int(input())
print(N*N*N)

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()))
 
answer = 0
 
for i in range(N):
  answer = answer + B[i]
  
for i in range(N):
  if i != 0:
    if A[i] == A[i-1]+1:
      answer = answer + C[a[i-1]-1]
    
print(answer)

Fixed submission:
N = int(input())
print(N*N*N)
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()))

answer = 0

for i in range(N):
  answer = answer + B[i]
  
for i in range(N):
  if A[i]+1 == A[i+1]
    answer = answer + C[i]
    
print(answer)

Fixed submission:
n=int(input())
a_list = list(map(int,input().split()))
b_list = list(map(int,input().split()))
c_list = list(map(int,input().split()))
count = 0
for i in range(n):
    index=a_list[i]
    count += b_list[index - 1]
#     print(count)
    if i !=0:
        if a_list[i] == a_list[i-1] + 1:
            count += c_list[a_list[i-1]-1]
print(count)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())

tmp = 0
for i in range(1,N):
    tmp += i
print(tmp)

Fixed submission:
N = int(input())

print((N-1)*N//2)
Buggy python submission (verdict: Runtime Error):
A = int(input())
B = int(input())
 
print(max(A+B,A-B,A*B))

Fixed submission:
A,B = list(map(int,input().split()))
 
print(max(A+B,A-B,A*B))

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

print(max(A+B,A-B,A*B))

Fixed submission:
A,B = list(map(int,input().split()))
 
print(max(A+B,A-B,A*B))