Harryxun/GPT-100-sft-dataset huggingface dataset:
Problem p02990 (python)

Fixed submission:
n, k = 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**4
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):
    print(cmb(n-k+1,i+1,mod)*cmb(k-1,i,mod)%mod)

Buggy submission (verdict: Runtime Error):
n, k = map(int,input().split())
MOD = 10**9 + 7

import sys
sys.setrecursionlimit(10**9)
nCr = {}
def cmb(n, r):
    if r == 0 or r == n: return 1
    if r == 1: return n
    if (n,r) in nCr: return nCr[(n,r)]
    nCr[(n,r)] = cmb(n-1,r) + cmb(n-1,r-1)
    return nCr[(n,r)]

for i in range(k):
    ans = 0
    ans += cmb(n-k+1,i+1)*cmb(k-1,i)
    ans %= MOD
    print(ans)

Buggy submission (verdict: Runtime Error):
n, k = map(int,input().split())
MOD = 10**9 + 7

from operator import mul
from functools import reduce

def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

for i in range(k):
    ans = 0
    ans += cmb(n-k+1,i+1)*cmb(k-1,i)
    ans %= MOD
    print(ans)
Problem p03108 (python)

Fixed submission:
class UnionFind:
    def __init__(self,size):
        self.par = [i for i in range(size)]
        self.rank = [0 for _ in range(size)]
        self.size = [1 for _ in range(size)]
        
    # xの根を返す
    def find(self,x):
        if self.par[x] == x:
            return x
        else:
            return self.find(self.par[x])
            
    # xとyを同じグループに
    def union(self,x,y):
        x = self.find(x)
        y = self.find(y)
        if self.rank[x] > self.rank[y]:
            self.par[y] = x
            self.size[x] += self.size[y]
        else:
            self.par[x] = y
            self.size[y] += self.size[x]
            if self.rank[x] == self.rank[y]:
                self.rank[y] += 1
        
    # xとyが同じグループか判定
    def same(self,x,y):
        return self.find(x) == self.find(y)
    
N,M = map(int,input().split())
s = N*(N-1)//2
ans = []
ab = [list(map(lambda x: int(x) - 1, input().split())) for i in range(M)]

tree = UnionFind(N)

for index, bridge in enumerate(ab[::-1]):
    if tree.same(bridge[0],bridge[1]):
        ans.append(s)
    else:
        d = tree.size[tree.find(bridge[0])] * tree.size[tree.find(bridge[1])]
        tree.union(bridge[0],bridge[1])
        ans.append(s)
        s -= d
        
print("\n".join(map(str, ans[::-1])))

Buggy submission (verdict: Runtime Error):
N,M = map(int,input().split())
tmp = N*(N-1)//2
l = []
cnt = []
ab = [list(map(int, input().split())) for i in range(M)]
# print(ans)
herasu = 0
ans = [tmp]
for i in ab[::-1]:
    
    if (i[0] in cnt) and (i[1] in cnt):
#         print("両方ある")
        for index, l1 in enumerate(l):
            if i[0] in l1:
                tmp0 = index
            if i[1] in l1:
                tmp1 = index
        herasu += len(l[tmp0])*len(l[tmp1])
        del(l[tmp0])
        del(l[tmp1])
        l.append(l[tmp0]+l[tmp1])
        
        
    if (i[0] not in cnt) and (i[1] not in cnt):
#         print("両方ない")
        cnt += [i[0],i[1]]
        l.append(i)
        herasu += 1
        
    else:
#         print("片方しか入ってない")
        for l1 in l:
#             print(l1)
            if i[0] in l1:
#                 print(i[0], "がl1にあった")
                herasu += len(l1)
                l1.append(i[1])
                break
            if i[1] in l1:
                
                herasu += len(l1)
                l1.append(i[0])
                break
    
    ans.append(tmp-herasu)
    
for i in ans[::-1][1:]:
    print(i)
Problem p03127 (python)

Fixed submission:
from fractions import gcd
from functools import reduce

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

print(reduce(gcd, an))

Buggy submission (verdict: Runtime Error):
from fraction import gcd
from functools import reduce

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

print(reduce(gcd, an))

Buggy submission (verdict: Runtime Error):
import math
from functools import reduce

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

print(reduce(math.gcd, an))
Problem p03208 (python)

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

hn.sort()

print(min(hn[i+k-1] - hn[i] for i in range(n-k+1)))

Buggy submission (verdict: Runtime Error):
n,k = map(int,input().split())
hn = [int(input()) for i in range(n)]

hn.sort()

print(min(hn[i+k-1] - hn[i] for i in range(i-k+1)))

Buggy submission (verdict: Runtime Error):
n,k = map(int,input().split())
hn = [int(input()) for i in range(n)]

# 方針として、高さの違いをソートして小さい順からk-1個取得すればよい
hn.sort()

print(hn)

print(min(hn[i+k-1] - hn[i] for i in range(i-k+1)))
Problem p03252 (python)

Fixed submission:
from collections import Counter
 
S = input()
T = input()
 
s = Counter(S)
t = Counter(T)
 
if sorted(s.values()) == sorted(t.values()):
	print("Yes")
else:
	print("No")

Buggy submission (verdict: Runtime Error):
S=input()
T = input()

checked_s=[0]*26

for i in range(len(S)):
    if S[i] != T[i]:
        if T[i] in S:
            S = S.translate(str.maketrans({S[i]:T[i], T[i]: S[i]}))
        elif checked_s[i] == 0:
            S = S.replace(S[i], T[i])
            
if S==T:
    print("Yes")
else:
    print("No")
Problem p03253 (python)

Fixed submission:
from operator import mul
from functools import reduce

# 素因数分解して、重複組み合わせを数える。
n,m = map(int,input().split())
MOD = 10**9+7

# 素因数分解
def factorize(n):
    fct = [] # Prime Factor
    b, e = 2, 0
    while b*b <= n:
        while n % b == 0:
            n //= b
            e += 1
        if e > 0:
            fct.append((b,e))
        b, e = b+1, 0
    if n>1:
        fct.append((n,1))
    return fct

# 組み合わせ計算(nCr)
def nCr(n,r):
    r = min(r,n-r)
    if r == 0:
        return 1
    over = reduce(mul, range(n,n-r,-1))
    under = reduce(mul,range(1,r+1))
    return over // under

f = factorize(m)
ans=1
for p,num in f:
    ans *= nCr(num+n-1,num)
    ans %= MOD
    
print(ans)

Buggy submission (verdict: Runtime Error):
from operator import mul
from functools import reduce

# 素因数分解して、重複組み合わせを数える。
n,m = map(int,input().split())
MOD = 10**9+7

# 素因数分解
def factorize(n):
    fct = [] # Prime Factor
    b, e = 2, 0
    while b*b <= n:
        while n % b == 0:
            n //= b
            e += 1
        if e > 0:
            fct.append((b,e))
        b, e = b+1, 0
    if n>1:
        fct.append((n,1))
    return fct

# 組み合わせ計算(nCr)
def nCr(n,r):
    r = min(r,n-r)
    if r == 0:
        return 1
    over = reduce(mul, range(n,n-r,-1))
    under = reduce(mul,range(1,r+1))
    return over // under

f = factorize(m)
ans=1
for p,num in f:
    ans *= nCb(num+n-1,num)
    ans %= 10**9+7
 
print(ans)
Problem p02915 (python)

Fixed submission:
n = int(input())
p = n**3
print(p)

Buggy submission (verdict: Runtime Error):
import math
n = int(input())
print(Math.pow(3,n))
Problem p03041 (python)

Fixed submission:
inputstr1 = input().split()
n = inputstr1[0]
k = inputstr1[1]
s = input()
 
N = int(n)
K = int(k)

ret = ""

for i in range(N):
  if i != K-1:
    ret += s[i]
  else:
    ret += s[i].lower()

print(ret)

Buggy submission (verdict: Runtime Error):
import math

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

proba = 0

for i in range(1, k):
  n_coin = int(math.log(k/i,2)) + 1
  print(i, n_coin)
  proba += float(1)/n*((0.5)**n_coin)

if n >= k:
	proba += float(n-k+1)/n

Buggy submission (verdict: Runtime Error):
n, k = [int(e) for e in input().split()]
s = input()
s[k] = s[k].lower()
print(s)
Problem p03075 (python)

Fixed submission:
t = "Yay!"
f = ":("

antennas = [int(input()) for _ in range(5)]
k = int(input())

if max(antennas) <= k:
    print(t)
else:
    flag = True
    for i in antennas:
        for j in antennas:
            if abs(i - j) >= k:
                flag = False
    if flag:
        print(t)
    else:
        print(f)

Buggy submission (verdict: Runtime Error):
t = "Yay!"
f = ":("

antennas = [input() for _ in range(5)]
k = input()

if max(antennas) <= k:
  print(t)
else:
  flag = True
  for i in antennas:
    for j in antennas:
      if abs(i-j) >= k:
        flag = False
  if flag: print(t)
  else: print(f)
Problem p02954 (python)

Fixed submission:
import math
s = input()
n = len(s)
cr, cl = 1, 0
ans = [0]*n
isRL = False
bp = 0

for i in range(1, n):
    cr += 1 if s[i] == "R" else 0
    cl += 1 if s[i] == "L" else 0
    if  isRL:
        if s[i] == "R" or i == n-1:
            cr -= 1 if i != n-1 else 0
            ans[bp-1] = math.ceil(cr/2) + int(cl/2)
            ans[bp] = int(cr/2) + math.ceil(cl/2)
            cr, cl, isRL = 1, 0, False
    else:
        if s[i-1] == "R" and s[i] == "L":
            bp = i
            isRL = True
            if i == n-1:
                ans[bp-1] = math.ceil(cr/2) + int(cl/2)
                ans[bp] = int(cr/2) + math.ceil(cl/2)
            
for a in ans:
    print(a, end=" ")

Buggy submission (verdict: Runtime Error):
s = input()
n = len(s)
cr, cl = 1, 0
ans = [0]*n
isRL = False
bp = 0

for i in range(1, n):
    cr += 1 if s[i] == "R" else 0
    cl += 1 if s[i] == "L" else 0
    if  isRL:
        if s[i] == "R" or i == n-1:
            cr -= 1 if i != n-1 else 0
            ans[bp-1] = math.ceil(cr/2) + int(cl/2)
            ans[bp] = int(cr/2) + math.ceil(cl/2)
            cr, cl, isRL = 1, 0, False
    else:
        if s[i-1] == "R" and s[i] == "L":
            bp = i
            isRL = True
            if i == n-1:
                ans[bp-1] = math.ceil(cr/2) + int(cl/2)
                ans[bp] = int(cr/2) + math.ceil(cl/2)
            
for a in ans:
    print(a, end=" ")

Buggy submission (verdict: Runtime Error):
s = input()
n = len(s)
cr, cl = 1, 0
ans = [0]*len(s)
isRL = False

for i in range(1, n):
    cr += 1 if s[i] == "R" else 0
    cl += 1 if s[i] == "L" else 0
    if  isRL:
        if s[i] == "R" or i == n-1:
            cr -= 1 if i != n-1 else 0
            ans[bp-1] = math.ceil(cr/2) + int(cl/2)
            ans[bp] = int(cr/2) + math.ceil(cl/2)
            cr, cl, isRL = 1, 0, False
    else:
        if s[i-1] == "R" and s[i] == "L":
            bp = i
            isRL = True
            if i == n-1:
                ans[bp-1] = math.ceil(cr/2) + int(cl/2)
                ans[bp] = int(cr/2) + math.ceil(cl/2)
            
for i in ans:
    print(i, end=" ")
Problem p03011 (python)

Fixed submission:
list = input().split()
list.sort()
print(int(list[0]) + int(list[1]))

Buggy submission (verdict: Runtime Error):
list = input().split()
list = sort(list)
print(list[0] + list[1])
Problem p02915 (python)

Fixed submission:
import itertools
n=input()
n=int(n)
if n>=1 and n<=9:
	li=[i for i in range(1,n+1)]
	li=li*3
	print(len(set(itertools.combinations(li,3))))
else:
  pass

Buggy submission (verdict: Runtime Error):
import itertools as it  
n=input()
n=int(n)
if n>=1 and n<=9:
	li=[i for i in range(1,n+1)]
	li=li*3
	print(len(set(itertools.combinations(li,3))))
else:
  pass

Buggy submission (verdict: Runtime Error):
import itertools as it  
n=int(input())
li=[i for i in range(1,n+1)]
li=li*3
print(len(set(itertools.combinations(li,3))))
Problem p02935 (python)

Fixed submission:
n=input().strip()
n=int(n)
if n>=2 and n<=50:
    num=list(map(int,input().strip().split()))
num.sort()

if n==2:
    print(sum(num)/2)
else:
    num.append((num[0]+num[1])/2)
    num=num[2:]
    for i in range(len(num)-1):
        num.append((num[-1]+num[0])/2)
        num=num[1:]
    print(num[-1])

Buggy submission (verdict: Runtime Error):
n=input()
n=int(n)
val=list(map(int,input().strip().split(' ')))
val.sort()
res=0
if val:
    if len(val)==1:
        print(val[0]/2)
    elif len(val)==2:
        print(sun(val)/2)
    else:
        #res=(val[0]+val[1])/2
        res=(val[0]+val[1])/2
        for i in range(2,len(val)):
            res=(res+val[i])/2
            #print(res)
        print(res)
else:
    #print('error')
    pass

Buggy submission (verdict: Runtime Error):
n=input()
n=int(n)
val=list(map(int,input().strip().split(' ')))
val.sort()
res=0
if len(val)>0:
    if len(val)==1:
        print(val[0]/2)
    elif len(val)==2:
        print(sun(val)/2)
    else:
        #res=(val[0]+val[1])/2
        res=(val[0]+val[1])/2
        for i in range(2,len(val)):
            res=(res+val[i])/2
            #print(res)
        print(res)
else:
    #print('error')
    pass
Problem p02915 (python)

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

Buggy submission (verdict: Runtime Error):
N = int(input())
print(N**3
Problem p02915 (python)

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

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

Buggy submission (verdict: Runtime Error):
n = int(input())
print(n*n*n*)
Problem p02933 (python)

Fixed submission:
n=input()
m=input()

if int(n) < 3200:
  print("red")
else:
  print(m)

Buggy submission (verdict: Runtime Error):
n=int(input())
string_list=[input() for i in range(n)]
a = int(string_list[0])
if a <= 3200:
  print("red")
else:
  print(a[1])
Problem p02915 (python)

Fixed submission:
n = int(input())
print(n**3)

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

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

Buggy submission (verdict: Runtime Error):
input(int(N))
print(N**3)

Buggy submission (verdict: Runtime Error):
print(N**3)
Problem p02933 (python)

Fixed submission:
a = input()
s = input()
 
if int(a) >= int(3200):
  print(s)
else:
  print('red')

Buggy submission (verdict: Runtime Error):
a = input()
s = input()
 
if int(a) >= int(3200):
  print(s)
else:
  print(red)

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

if a =>3200:
  print(s)
else:
  print(red)
Problem p02915 (python)

Fixed submission:
n=input()
n=int(n)
print(n**3)

Buggy submission (verdict: Runtime Error):
import math
t=input()
t=t.split()
a=int(t[0])
b=int(t[1])
x=(b-1)/(a-1)
x=math.ceil(x)
print(x)
Problem p02915 (python)

Fixed submission:
x = int(input())
result = x ** 3
print(result)

Buggy submission (verdict: Runtime Error):
x = int(input())
result = x **3
print(result

Buggy submission (verdict: Runtime Error):
x = int(input())
result = x **3
print(result
Problem p02916 (python)

Fixed submission:
N = int(input())
Ai = [int(i) for i in input().split(" ")]
Bi = [int(i) for i in input().split(" ")]
Ci = [int(i) for i in input().split(" ")]

res = 0
pre_i = None
for i in Ai:
  res += Bi[i-1]
  if pre_i and i == pre_i+1:
    res += Ci[i-2]
  pre_i = i

print(res)

Buggy submission (verdict: Runtime Error):
N = int(input())
Ai = [int(i) for i in input().split(" ")]
Bi = [int(i) for i in input().split(" ")]
Ci = [int(i) for i in input().split(" ")]

res = 0
pre_i = None
for i in Ai:
  res += Bi[i-1]
  if i == pre_i+1:
    res += Ci[i-1]
  pre_i = i

  print(res)

Buggy submission (verdict: Runtime Error):
N = int(input())
Ai = [int(i) for i in input().split(" ")]
Bi = [int(i) for i in input().split(" ")]
Ci = [int(i) for i in input().split(" ")]

res = 0
res += Ai[N+1]
res += Bi[N+1]
res += Ci[N+2]

print(res)
Problem p02916 (python)

Fixed submission:
n = int(input())

a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
c = [int(i) for i in input().split()]

ans = sum(b)
for i in range(len(a)-1):
    if a[i]+1 == a[i+1]:
        ans += c[a[i]-1]


print(ans)

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

a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
c = [int(i) for i in input().split()]

ans = sum(b)
for i in range(len(a)-1):
    if a[i]+1 == a[i+1]:
        ans += c[a[i]-1]


print(ans)
~
Problem p02915 (python)

Fixed submission:
a=int(input())
print(a**3)

Buggy submission (verdict: Runtime Error):
a = input()
print(a**3)
Problem p02915 (python)

Fixed submission:

if (__name__ == '__main__'):
    n = int(input())
    print(n**3)

Buggy submission (verdict: Runtime Error):

n = int(input())

return (n**3 )
Problem p02916 (python)

Fixed submission:
if (__name__ == '__main__'):
    n = int(input())
    
    a = [0]
    b = [0]
    c = [0]

    aa = input().strip().split()
    for i in range(n):
        a.append(int(aa[i]))
    bb = input().strip().split()
    for i in range(n):
        b.append(int(bb[i]))
    cc = input().strip().split()
    for i in range(n-1):
        c.append(int(cc[i]))

    sum = b[a[1]]
    lastmenu = a[1]

    for i in range(2, n+1):
        sum = sum + b[a[i]]
        if (a[i] == lastmenu+1):
            sum = sum + c[lastmenu]
        lastmenu = a[i]

    print(sum)

Buggy submission (verdict: Runtime Error):
if (__name__ == '__main__'):
    a = [0]
    b = [0]
    c = [0]

    aa = input().strip().split()
    for i in range(n):
        a.append(int(aa[i]))
    bb = input().strip().split()
    for i in range(n):
        b.append(int(bb[i]))
    cc = input().strip().split()
    for i in range(n-1):
        c.append(int(cc[i]))

    sum = b[a[1]]
    lastmenu = a[1]

    for i in range(2, n+1):
        sum = sum + b[a[i]]
        if (a[i] == lastmenu+1):
            sum = sum + c[lastmenu]
        lastmenu = a[i]

    print(sum)

Buggy submission (verdict: Runtime Error):

if (__name__ == '__main__'):
    n = int(input())
    a = [0]
    b = [0]
    c = [0]
    aa = input().strip().split()
    for i in range(n):
        a.append(int(aa[i]))
    aa = input().strip().split()
        for i in range(n):
            a.append(int(aa[i]))
    bb = input().strip().split()
        for i in range(n):
            b.append(int(bb[i]))
    c = input().strip().split()
        for i in range(n-1):
            c.append(int(cc[i]))

    sum = b[a[1]]
    lastmenu = a[1]

    for i in range(2, n+1):
        sum = sum + b[a[i]]
        if (a[i] == lastmenu+1):
            sum = sum + c[lastmenu]
       lastmenu = a[i]

    print(sum)
Problem p02915 (python)

Fixed submission:
n=int(input())
print(n**3)

Buggy submission (verdict: Runtime Error):
n=input()
print(n**3)
Problem p03075 (python)

Fixed submission:
a,b,c,d,e,k=[int(input()) for i in range(6)]
print("Yay!" if abs(a-e)<=k else ":(")

Buggy submission (verdict: Runtime Error):
a,b,c,d,e,k = [int,input()] for i range(6)]

print("Yay!" if abs(a-e) <= k else ":(" )

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

print("Yay!" if A <= A[5] else ":(" )
Problem p03272 (python)

Fixed submission:
a,b = map(int,input().split())
print(a-b+1)

Buggy submission (verdict: Runtime Error):
print(int(input())-int(input())+1)

Buggy submission (verdict: Runtime Error):
print(int(input())-int(input())+1)
Problem p03834 (python)

Fixed submission:
a,b,c = input().split(",")
print(a,b,c)

Buggy submission (verdict: Runtime Error):
a,b,c = input().split()
print(a,b,c)
Problem p03107 (python)

Fixed submission:
S = input()

nums = []
for s in S:
    nums.append(int(s))

count = 0
i = 0
while i < len(nums)-1:
    if nums[i] != nums[i+1]:
        nums.pop(i+1)
        nums.pop(i)
        count += 1
        if i != 0:
            i -= 1
        continue
    i += 1

print(count*2)

Buggy submission (verdict: Runtime Error):
S = input()

nums = []
for s in S:
    nums.append(int(s))

count = 0
i = 0
while i < len(nums)-1:
    if nums[i] != nums[i+1]:
        nums.pop(i+1)
        nums.pop(i)
        count += 1
        i -= 1
        continue
    i += 1

print(count*2)
Problem p03631 (python)

Fixed submission:
N = input()
if N[0] != N[len(N)-1]:
    print('No')
    quit()
else:
    print('Yes')

Buggy submission (verdict: Runtime Error):
A, B, C, D = map(int, input().split())

if B < C or D < A:
    print(0)
elif A < C and B < D:
    print(B-C)
elif A < C and B > D:
    print(D-C)
elif C < A and B < D:
    print(B-A)
elif A < D and B > D:
    print(D-A)
Problem p03774 (python)

Fixed submission:
N, M = map(int, input().split())
S = [list(map(int, input().split())) for _ in range(N)]
C = [list(map(int, input().split())) for _ in range(M)]

for s in S:
    minC = 10**10
    idx = 0
    for i, c in enumerate(C):
        d = abs(s[0]-c[0]) + abs(s[1]-c[1])
        if d < minC:
            minC = d
            idx = i + 1
    print(idx)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
S = [list(map(int, input().split())) for _ in range(N)]
C = [list(map(int, input().split())) for _ in range(N)]

for s in S:
    minC = 10**10
    idx = 0
    for i, c in enumerate(C):
        d = abs(s[0]-c[0]) + abs(s[1]-c[1])
        if d < minC:
            minC = d
            idx = i + 1
    print(idx)
Problem p02916 (python)

Fixed submission:
n=int(input())
a,b,c=[list(map(int,input().split())) for _ in range(3)] 
x=0
for i,_ in enumerate(a):
  if(i==len(a)-1):
    break
  elif(a[i]+1==a[i+1]):
    x+=c[a[i]-1]
print(sum(b)+x)

Buggy submission (verdict: Runtime Error):
n=int(input())
a,b,c=[map(list,map(int,input().split())) for _ in range(3)] 
x=0
for i,_ in enumerate(a):
  if(i==len(a)-1):
    break
  elif(a[i]+1==a[i+1]):
    x+=c[a[i]-1]
print(sum(b)+x)

Buggy submission (verdict: Runtime Error):
n=int(input())
a,b,c=[map(list,map(int,input().split())) for _ in range(3)] 
x=0
for i,_ in enumerate(a):
  if(i==len(a)-1):
    break
  elif(a[i]+1==a[i+1]):
    x+=c[a[i]-1]
print(sum(b)+x)
Problem p02916 (python)

Fixed submission:
n=int(input())
a=[int(x) for x in input().split()]
b=[int(x) for x in input().split()]
c=[int(x) for x in input().split()]
sum1=0
for i in range(n):
	sum1+=b[a[i]-1]
	if(i!=n-1):
		if(a[i+1]-a[i]==1):
			sum1+=c[a[i]-1]
print(sum1)

Buggy submission (verdict: Runtime Error):
n=int(input())
a=[int(x) for x in input().split()]
b=[int(x) for x in input().split()]
c=[int(x) for x in input().split()]
sum1=0
for i in range(n):
  sum1+=b[a[i]-1]
  if(i!=n-1):
	if(a[i+1]-a[i]==1):
      sum1+=c[a[i]-1]
print(sum1)
Problem p02915 (python)

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

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

H0 = 0
N_LR = 0
N_RL = 0

if S[0] == 'R' and S[1] == 'R':
    H0 += 1
if S[0] == 'R' and S[1] == 'L':
    N_RL += 1
if S[0] == 'L' and S[1] == 'R':
    N_LR += 1

if S[N-1] == 'L' and S[N-2] == 'L':
    H0 += 1

for i in range(1, N-1):
    if S[i] == 'L' and S[i-1] == 'L' or S[i] == 'R' and S[i+1] == 'R':
        H0 += 1
    if S[i] == 'R' and S[i+1] == 'L':
        N_RL += 1
    if S[i] == 'L' and S[i+1] == 'R':
        N_LR += 1

M = min(N_RL, N_LR, K)
H1 = H0 + 2 * M
K -= M
N_RL -= M
N_LR -= M

result = H1 + min(K, max(N_RL, N_LR))
print(result)

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

H0 = 0
N_LR = 0
N_RL = 0

if S[0] == 'R' and S[1] == 'R':
    H0 += 1
if S[0] == 'R' and S[1] == 'L':
    N_RL += 1
if S[0] == 'L' and S[1] == 'R':
    N_LR += 1

if S[N-1] == 'L' and S[N-2] == 'L':
    H0 += 1

for i in range(1, N-1):
    if S[i] == 'L' and S[i-1] == 'L' or S[i] == 'R' and S[i+1] == 'R':
        H0 += 1
    if S[i] == 'R' and S[i+1] == 'L':
        N_RL += 1
    if S[i] == 'L' and S[i+1] == 'R':
        N_LR += 1

M = min(N_RL, N_LR, K)
H1 = H0 + 2 * M
K -= M
N_RL -= M
N_LR -= M

result = H1 + min(K, max(N_RL, N_LR))
print(result)
Problem p02933 (python)

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

if a >= 3200:
    print(s)
else:
    print('red')

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

N = int(input())
A = np.array(list(map(int, input().split(' '))))

A_inv = 1 / A
print(1 / np.sum(A_inv))