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

Fixed submission:
li = list(input())
line = []

for i in li:
  if i == "0":
    line.append("0")
  elif i == "1":
    line.append("1")
  else:
    if len(line) != 0:
      line.pop(len(line) - 1)

print("".join(line))

Buggy submission (verdict: Runtime Error):
li = list(input())
line = []

for i in li:
  if i == "0":
    line.append("0")
  elif i == "1":
    line.append("1")
  else:
    line.pop(len(line) - 1)

print("".join(line))
Problem p04043 (python)

Fixed submission:
nums = list(map(int, input().split(" ")))
 
if sum(nums) == 17 and (5 in nums) and (7 in nums):
  print("YES")
else:
  print("NO")

Buggy submission (verdict: Runtime Error):
nums = list(map(int, input().split("")))

if sum(nums) == 17 and (5 in nums) and (7 in nums):
  print("YES")
else:
  print("NO")
Problem p02843 (python)

Fixed submission:
# coding: utf-8

X = int(input())
q = X//100
mod = X%100

if q*5 >= mod: print(1)
else: print(0)

Buggy submission (verdict: Runtime Error):
# coding: utf-8

X = input(S)
q = X//100
mod = X%100

if q*5 > mod: print(1)
else: print(0)
Problem p02675 (python)

Fixed submission:
x = int(input())
y = x%10
if y == 3:
  print("bon")
elif y == 0:
  print("pon")
elif y == 1:
  print("pon")
elif y == 6:
  print("pon")
elif y == 8:
  print("pon")
else:
  print("hon")

Buggy submission (verdict: Runtime Error):
x = input()
y = x[-1]
if y == 3:
  print("bon")
elif y == 0,:
  print("pon")
elif y == 1:
  print("pon")
elif y == 6:
  print("pon")
elif y == 8:
  print("pon")
else:
  print("hon")

Buggy submission (verdict: Runtime Error):
x = input()
y = x[-1]
if y == 3:
  print("bon")
elif y == 0,1,6,8:
  print("pon")
else:
  print("hon")
Problem p02681 (python)

Fixed submission:
S = input()
T = input()
U = T[:-1]
if S == U:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
S = input()
T = input()
U = T[：-1]
if S == U:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
S = input()
T = input()
U = T-T[-1]
if S == U:
  print("Yes")
else:
  print("No")
Problem p03455 (python)

Fixed submission:
a,b=input().split()
a=int(a)
b=int(b)
Hantei=(a * b) % 2
if Hantei == 1:
    print("Odd")
else:
    print("Even")

Buggy submission (verdict: Runtime Error):
a,b=map(int(),input().split())
Hantei=(a * b) % 2
if Hantei == 1:
    print("Odd")
else:
    print("Even")

Buggy submission (verdict: Runtime Error):
a,b=map(int(),imput().split())
Hantei=(a * b) % 2
if Hantei == 1:
    print("Odd")
else:
    print("Even")

Buggy submission (verdict: Runtime Error):
a,b=map(int,imput().split())
Hantei=(a * b) % 2
if Hantei == 1:
    print("Odd")
else:
    print("Even")
Problem p02957 (python)

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

if (a+b)%2 == 0:
  print((a+b)//2)
else:
  print('IMPOSSIBLE')

Buggy submission (verdict: Runtime Error):
a,b = map(int,input().split())

from sympy import *

x = sympy.Symbol('x') #xを変数xとして定義
f = 2*x -a-b 

solutions=sympy.solve(f,x) # f=0としてxを解き変数solutionsに代入
print(solutions)
Problem p03029 (python)

Fixed submission:
A,P= map(int, input().split())
G=0
G=(3*A+P)//2
print(G)

Buggy submission (verdict: Runtime Error):
A,P= map(int, input().split())
G=0
G=(3*A+P)//2
print(G)
Problem p02675 (python)

Fixed submission:
a = int(input())
b = a%10
if b == 2 or b == 4 or b == 5 or b == 7 or b == 9:
  print("hon")
elif b == 0 or b == 1 or b == 6 or b == 8:
   print("pon")
else:
  print("bon")

Buggy submission (verdict: Runtime Error):
a = int(input())
b = a%10
print(b)
if b == 2 or b == 4 or b == 5 or b == 7 or b == 9:
  print("hon")
elsif b == 0 or b == 1 or b == 6 or b == 8:
  print("pon")
else:
  print("bon")

Buggy submission (verdict: Runtime Error):
a = int(input())
b = a%10
print(b)
if b == 2 or b == 4 or b == 5 or b == 7 or b == 9:
  print("hon")
elsif b == 0 or b == 1 or b == 6 or b == 8:
   print("pon")
else:
  print("bon")
Problem p02675 (python)

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

if a % 10 == 2 or a % 10 == 4 or a % 10 == 5 or a % 10 == 7 or a % 10 == 9:
    print("hon")
elif a % 10 == 0 or a % 10 == 1 or a % 10 == 6 or a % 10 == 8:
    print("pon")
else:
    print("bon")

Buggy submission (verdict: Runtime Error):
import networkx as nx
N, M = map(int, input().split())

edge_list = s = [input().split() for i in range(M)]
G = nx.Graph()
G.add_edges_from(edge_list)

if [] in nx.shortest_path(G, target=str(1)).values():
  print("No")
else:
  print("Yes")
  for i in range(len(list(nx.shortest_path(G, target=str(1)).values()))-1):
    print(nx.shortest_path(G, target=str(1))[str(i+2)][1])
Problem p02677 (python)

Fixed submission:
import math

A, B, H, M = [int(i) for i in input().split()]

alpha = (H + M/60)/12 * 2*math.pi
beta = M/60 * 2*math.pi

X = A*math.cos(alpha) - B*math.cos(beta)
Y = A*math.sin(alpha) - B*math.sin(beta)

print(math.sqrt(X*X + Y*Y))

Buggy submission (verdict: Runtime Error):
import math

A = int(input())
B = int(input())
H = int(input())
M = int(input())

alpha = (H + M/60)/12 * 2*math.pi
beta = M/60 * 2*math.pi

X = A*math.cos(alpha) - B*math.cos(beta)
Y = A*math.sin(alpha) - B*math.sin(beta)

distance = math.sqrt(X*X + Y*Y)

print(distance)
Problem p02675 (python)

Fixed submission:
num = int(input())
num_1 = num % 10
if num_1 == 3:
  print('bon')
elif num_1 <= 1 or num_1 == 6 or num_1 == 8:
  print('pon')
else:
  print('hon')

Buggy submission (verdict: Runtime Error):
num == int(input())
num_1 == num % 10
if num_1 == 3:
  print('bon')
elif num_1 <= 1 or num_1 == 6 or num_1 == 8:
  print('pon')
else:
  print('hon')

Buggy submission (verdict: Runtime Error):
num == int(input())
num_1 == num % 10
if num_1 == 3:
  print('bon')
elif num_1 <= 1 or num_1 == 6 or num_1 == 8:
  print('pon')
else:
  print('hon')

Buggy submission (verdict: Runtime Error):
num = int(input())
num_1 = num % 10
if num_1 == 2,4,5,7,9:
  print('hon')
elif num_1 == 0,1,6,8:
  print('pon')
else:
  print('bon')

Buggy submission (verdict: Runtime Error):
num = int(input())
num_1 = num % 10
if num_1 = 2,4,5,7,9:
  print('hon')
elif num_1 = 0,1,6,8:
  print('pon')
else:
  print('bon')
Problem p02705 (python)

Fixed submission:
# -*- coding: utf-8 -*-
import math
 
inp = float(input())
 
print(inp*2*math.pi)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
A = list(map(int, input().split()))
 
goukei = sum(A)
 
if goukei > N:
  print(-1)
  
else:
  print(N-goukei)
Problem p02761 (python)

Fixed submission:
N, M = map(int, input().split())
sc_list = []
for i in range(M):
    s, c = map(int, input().split())
    sc_list.append([s,c])
ans = ""
flag = 0
num_slot = ["X" for i in range(N)]
for lists in sc_list:
    if num_slot[lists[0]-1] != "X" and num_slot[lists[0]-1] != lists[1]:
        print(-1)
        flag = 1
        break
    else:
        num_slot[lists[0]-1] = lists[1]
if flag == 0:
    for i in range(N):
        if num_slot[i] != "X":
            ans += str(num_slot[i])
        else:
            if i == 0:
                ans += "1"
            else:
                ans += "0"
    if ans[0] == "0" and ans != "0":
        print(-1)
    elif N == 1 and M == 0:
        print(0)
    else:
        print(int(ans))

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
sc_list = []
for i in range(M):
    s, c = map(int, input().split())
    sc_list.append([s,c])
ans = ""
flag = 0
num_slot = [-1 for i in range(N)]
for lists in sc_list:
    if num_slot[lists[0]-1] != -1 and num_slot[lists[0]-1] != lists[1]:
        print(-1)
        flag = 1
        break
    else:
        num_slot[lists[0]-1] = lists[1]
if flag == 0:
    for i in range(N):
        if num_slot[i] != -1:
            ans += str(num_slot[i])
        else:
            if i == 0:
                ans += "1"
            else:
                ans += "0"
if ans[0] == "0":
    print(-1)
else:
    print(int(ans))

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
sc_list = []
for i in range(M):
    s, c = map(int, input().split())
    sc_list.append([s,c])
ans = ""
flag = 0
num_slot = [-1 for i in range(N)]
for lists in sc_list:
    if num_slot[lists[0]-1] != -1 and num_slot[lists[0]-1] != lists[1]:
        print(-1)
        flag = 1
        break
    else:
        num_slot[lists[0]-1] = lists[1]
if flag == 0:
    for i in range(N):
        if num_slot[i] != -1:
            ans += str(num_slot[i])
        else:
            if i == 0:
                ans += "1"
            else:
                ans += "0"
if ans[0] == "0":
    print(-1)
else:
    print(ans)
Problem p02791 (python)

Fixed submission:
N = int(input())
lists = list(map(int, input().split()))
count = 1
mins = lists[0]
for i in range(1,N):
    if lists[i] <= mins:
        count = count + 1
        mins = lists[i]
print(count)

Buggy submission (verdict: Runtime Error):
N = int(input())
lists = list(map(int, input().split()))
count = 1
mins = lists[0]
for i in range(1,N):
	if lists[i] <= mins:
    	count = count + 1
		mins = lists[i]
print(count)
Problem p02945 (python)

Fixed submission:
a,b = map(int,input().split())
ab_list = list()
ab_list.append(a + b)
ab_list.append(a - b)
ab_list.append(a * b)
print(max(ab_list))

Buggy submission (verdict: Runtime Error):
job = list()
salary = list()
m_total = 0
j = 0
n,m = map(int,input().split())
for i in range(n):
    a,b = map(int,input().split())
    job.append((a,b))
    job.sort(reverse = True)
for i in range(n):
    a,b = job[i]
    salary.append(b)
    if a + j > m :
        salary.remove(min(salary))
        continue
    j += 1
print(sum(salary))
Problem p02677 (python)

Fixed submission:
import math
A,B,H,M=map(int,input().split())
cen=(60*H+M)/2-6*M
cen_cos=math.cos(math.radians(cen))

print((A**2+B**2-2*cen_cos*A*B)**0.5)

Buggy submission (verdict: Runtime Error):
import math
A,B,H,M=map(int,input().split())
cen=(60*H+M)/2-6*M
cen_cos=math.cos(math.radian(cen))

print(A**2+B**2-2*cen_cos*A*B)

Buggy submission (verdict: Runtime Error):
import math
A,B,H,M=map(int,input().split())
cen=(60*H+M)/2-6M
cen_cos=math.cos(cen)

print(A**2+B**2-2*cen_cos*A*B)
Problem p03635 (python)

Fixed submission:
m,n= map(int,input().split())
print((m-1)*(n-1))

Buggy submission (verdict: Runtime Error):
m,n=[int(input()) for i in range(2)]
print((m-1)*(n-1))
Problem p03796 (python)

Fixed submission:
import math
N=int(input())
print(math.factorial(N) % (10**9+7))

Buggy submission (verdict: Runtime Error):
N=int(input())
M=int(math.factorial(N))
L=10**9+7
print(M%L)
Problem p03860 (python)

Fixed submission:
s=input()
print("A"+s[8]+"C")

Buggy submission (verdict: Runtime Error):
s=input()
A=str(A+s[8]+C)
print(str(A))
Problem p02727 (python)

Fixed submission:
x, y, a, b, c = map(int, input().split())
arrayP = list(map(int, input().split()))
arrayQ = list(map(int, input().split()))
arrayR = list(map(int, input().split()))
arrayP.sort(reverse=True)
arrayQ.sort(reverse=True)
arrayR.sort(reverse=True)
arrayAns = []
for i in range(x):
    arrayAns.append(int(arrayP[i]))
for i in range(y):
    arrayAns.append(int(arrayQ[i]))
arrayAns.sort()
for i in range(min(len(arrayR), len(arrayAns))):
    if arrayAns[i] <= int(arrayR[i]):
        arrayAns[i] = int(arrayR[i])
    else:
        break
print(sum(arrayAns))

Buggy submission (verdict: Runtime Error):
x, y, a, b, c = map(int, input().split())
arrayP = list(map(int, input().split()))
arrayQ = list(map(int, input().split()))
arrayR = list(map(int, input().split()))
arrayP.sort(reverse=True)
arrayQ.sort(reverse=True)
arrayR.sort(reverse=True)
arrayAns = []
for i in range(x):
    arrayAns.append(int(arrayP[i]))
for i in range(y):
    arrayAns.append(int(arrayQ[i]))
arrayAns.sort()
for i in range(len(arrayR)):
    if arrayAns[i] <= int(arrayR[i]):
        arrayAns[i] = int(arrayR[i])
    else:
        break
print(sum(arrayAns))

Buggy submission (verdict: Runtime Error):
x, y, a, b, c = map(int, input().split())
arrayP = list(map(int, input().split()))
arrayQ = list(map(int, input().split()))
arrayR = list(map(int, input().split()))
arrayP.sort(reverse=True)
arrayQ.sort(reverse=True)
arrayR.sort(reverse=True)
arrayAns = []
for i in range(x):
    arrayAns.append(int(arrayP[i]))
for i in range(y):
    arrayAns.append(int(arrayQ[i]))
arrayAns.sort()
for i in range(len(arrayAns)):
    if arrayAns[i] <= int(arrayR[i]):
        arrayAns[i] = int(arrayR[i])
    else:
        break
print(sum(arrayAns))
Problem p02780 (python)

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

hoge=0
for i in range(K):
    hoge += A[i]

re=hoge
for i in range(N-K):
    hoge=hoge+A[K+i]-A[i]
    if hoge >= re:
        re=hoge
        
print((re+K)/2)

Buggy submission (verdict: Runtime Error):
import numpy as np
N, K = map(int, input().split())
A = list(map(int, input().split()))
 
r=sum(A[0:K])
re=r
for i in range(N-K):
    r=r+A[K+i]-A[i]
    if r > re:
        re=r
        
print((re+K)/2)

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

r=sum(A[0:K])
re=r
for i in range(N-K):
    r=r+A[K+i]-A[i]
    if r > re:
        re=r
        
print((re+K)/2)
Problem p02936 (python)

Fixed submission:
import sys
sys.setrecursionlimit(500000) 
input=sys.stdin.readline

N,M = map(int,input().split())
ans=[0]*N
a = [list(map(int, input().split())) for _ in range(N-1)]

for _ in range(M):
    e,f = list(map(int, input().split()))
    ans[e-1] += f

trees = {}
for word in a:
    trees.setdefault(word[0], []).append(word[1])
    trees.setdefault(word[1], []).append(word[0])
    

def sumup(ne,parent):
    global ans
    if ne in trees:    
        for k in trees[ne]:
            if k != parent:
                ans[k-1] += ans[ne-1]
                sumup(k,ne)

sumup(1,0)
for i in ans:
    print(i)

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

ans=[0]*N
trees = {}
for word in a:
    trees.setdefault(word[0], []).append(word[1])
    trees.setdefault(word[1], []).append(word[0])

for i in b:
    ans[i[0]-1] += i[1]


def sumup(ne,parent):
    global ans
    if ne in trees:    
        for k in trees[ne]:
            if k != parent:
                ans[k-1] += ans[ne-1]
                sumup(k,ne)

sumup(1,0)
for i in ans:
    print(i)

Buggy submission (verdict: Runtime Error):
N,M = map(int,input().split())
a = [tuple(map(int, input().split())) for _ in range(N-1)]
b = [list(map(int, input().split())) for _ in range(M)]
ans=[0]*N
results = {}
for word in a:
    results.setdefault(word[0], []).append(word[1])

for i in b:
    ans[i[0]-1] += i[1]

def sumup(ne):
    global ans
    if ne in results:    
        for k in results[ne]:
            ans[k-1] += ans[ne-1]
            sumup(k)

sumup(1)
for i in ans:
    print(i)

Buggy submission (verdict: Runtime Error):
N,M = map(int,input().split())
a = [tuple(map(int, input().split())) for _ in range(N-1)]
b = [list(map(int, input().split())) for _ in range(M)]
ans=[0]*N
results = {}
for word in a:
    results.setdefault(word[0], []).append(word[1])

# neを根とする部分木にxを足す
def hukasa(ne,x):
    global ans
    global results
    ans[ne -1] += x
    if ne in results:
        for i in results[ne]:
            hukasa(i,x)


for i in b:
    hukasa(i[0],i[1])

for i in ans:
    print(i, end=" ")
Problem p02947 (python)

Fixed submission:
import math
def cmb(n, r):
        if r > n: 
                return 0
        return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))


import collections
N = int(input())
s= [input() for i in range(N)]
ans=0
#各文字列文字列をソート
s=list(map(sorted,s))

s.sort()        #リストをソート
s=list(map(''.join,s))  #リストになっていたものを文字列に変換
clist = collections.Counter(s) #リスト内の各要素の数を数え上げ
kaisu=list(clist.values())

for i in kaisu:
        ans += cmb(i,2)

print(ans)

Buggy submission (verdict: Runtime Error):
def cmb(n,r):
        if r > n: 
            return 0
        if n - r < r:
             r = n - r
        if r > n: 
            return 0
        if r == 0: 
            return 1
        if r == 1: 
            return n
    
        numerator = [n - r + k + 1 for k in range(r)]
        denominator = [k + 1 for k in range(r)]
    
        for p in range(2,r+1):
            pivot = denominator[p - 1]
            if pivot > 1:
                offset = (n - r) % p
                for k in range(p-1,r,p):
                    numerator[k - offset] /= pivot
                    denominator[k] /= pivot
    
        result = 1
        for k in range(r):
            if numerator[k] > 1:
                result *= int(numerator[k])
    
        return resultr


import collections
N = int(input())
s= [input() for i in range(N)]
ans=0
#各文字列文字列をソート
s=list(map(sorted,s))

s.sort()        #リストをソート
s=list(map(''.join,s))  #リストになっていたものを文字列に変換
clist = collections.Counter(s) #リスト内の各要素の数を数え上げ
kaisu=list(clist.values())

for i in kaisu:
        ans += cmb(i,2)

print(ans)
Problem p02960 (python)

Fixed submission:
S = [int(x) if x != '?' else - 1 for x in input()]
le=len(S)

dp = [[0]*13 for i in range(le+1)]
dp[0][0] = 1

i=0
for k in S:
    if k==-1:
        for s in range(10):
            for j in range(13):
                dp[i + 1][(s + j*10) % 13] += dp[i][j]%(10**9+7)

    else:
        k=int(k)
        for j in range(13):
            dp[i + 1][(j *10 + k) % 13] += dp[i][j]%(10**9+7)
        
    i += 1


print(dp[le][5]%(10**9+7))

Buggy submission (verdict: Runtime Error):
import sys
input=sys.stdin.readline
S=list(input())
le=len(S)
dp=[[0 for i in range(13)] for j in range(le+1)]
dp[0][0] = 1

def xin(A,n):
    li=[0]*13
    for i in range(13):
        li[(i+n)%13] = A[i]%(10**9+7)
    return li


i=0
for k in reversed(S):
    if k=='?':
        for s in range(10):
            for j in range(13):
                dp[i + 1][(s * 10**(i) + j) % 13] += dp[i][j]%(10**9+7)

    else:
        k=int(k)
        for j in range(13):
            dp[i + 1][(k * 10**(i) + j) % 13] += dp[i][j]%(10**9+7)
        
    i += 1


print(dp[le][5]%(10**9+7))
Problem p03060 (python)

Fixed submission:
N = int(input())
V=list(map(int,input().split()))
C=list(map(int,input().split()))
output = 0
for i in range(N):
    if V[i]-C[i] >= 0:
        output +=V[i]-C[i]

print(output)

Buggy submission (verdict: Runtime Error):
N = int(input())
  2 V=list(map(int,input().split()))
  3 C=list(map(int,input().split()))
  4 output = 0
  5 for i in range(N):
  6     if V[i]-C[i] >= 0:
  7         output +=V[i]-C[i]
  8
  9 print(output)
Problem p03061 (python)

Fixed submission:
def gcd(a,b):
  while b!=0:
    a,b=b,a%b
  return a

N = int(input())
A= list(map(int,input().split()))
output=0
KA=[0 for i in range(N)]
LA=[0 for i in range(N)]
GCD = []

for k in range(1,N):
        LA[k]=gcd(A[k-1],LA[k-1])

for k in range(1,N):
        KA[k]=gcd(A[N-k],KA[k-1])


for k in range(N):
        GCD.append(gcd(LA[k],KA[N-k-1]))
output = max(GCD)
print(output)

Buggy submission (verdict: Runtime Error):
def gcd(a,b):
  while b!=0:
    a,b=b,a%b
  return a

N = int(input())
A= list(map(int,input().split()))
output=0

for i in range(N):
        M = [A[i-1]]
        hoge = A[i]
        A[i] = A[i-1]
        for k in range(N):
                M.append(gcd(M[k],A[k]))
                print(M)

        if M[N] >= output:
                output = M[N]
        A[i]=hoge

print(output)

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

def gcd(numbers):
    return reduce(math.gcd, numbers)

N = int(input())
A= list(map(int,input().split()))
output=0


for i in range(N):
        hoge = A[i]
        A[i] = A[i-1]
        if gcd(A) >= output:
                output = gcd(A)
        A[i]=hoge

print(output)
Problem p03062 (python)

Fixed submission:
N=int(input())
A = list(map(int, input().split()))
ans=0
tmp=0
hoge=0
li=[]

for i in range(N):
    li.append(abs(A[i]))
    ans+=abs(A[i])
    if A[i]<0:
        tmp+=1
    if A[i]==0:
        hoge=1

if tmp%2==0 or hoge==1:
    ans=ans
else:
    ans=ans-2*min(li)

print(ans)

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

inf=float('inf')
dp=[[inf]*2 for j in range(N+1)]

def chmax(a,b):
    return max(a,b)

def rec(n,m):
    if n==0 and m==0:
        dp[0][0]=0
        return 0
    if n==0 and m==1:
        dp[0][1]=-inf
        return -inf

    if dp[n][m] < inf:
        return dp[n][m]
    
    if m==0:
        res=chmax(rec(n-1,0)+A[n-1] ,rec(n-1,1)-A[n-1] ) 
    if m==1:
        res=chmax(rec(n-1,0)-A[n-1] ,rec(n-1,1)+A[n-1] )
     
    dp[n][m]=res

    return res

print(rec(N,0))
Problem p03160 (python)

Fixed submission:
#最初に置いておくもの
import sys
sys.setrecursionlimit(500000) 
input=sys.stdin.readline


N=int(input())
A = list(map(int, input().split()))
inf=float('inf')
dp=[inf]*N

def chmin(a,b):
    return min(a,b)

def rec(n):
    if n==0:
        return 0
    if dp[n] < inf:
        return dp[n]
    
    res=rec(n-1) + abs(A[n] - A[n-1])
    if n>1:
        res=chmin(res,rec(n-2) + abs(A[n] - A[n-2]))
    dp[n]=res
    return res

print(rec(N-1))

Buggy submission (verdict: Runtime Error):
N=int(input())
A = list(map(int, input().split()))
inf=float('inf')
dp=[inf]*N

def chmin(a,b):
    return min(a,b)

def rec(n):
    if n==0:
        return 0
    if dp[n] < inf:
        return dp[n]
    
    res=rec(n-1) + abs(A[n] - A[n-1])
    if n>1:
        res=chmin(res,rec(n-2) + abs(A[n] - A[n-2]))
    dp[n]=res
    return res

print(rec(N-1))
Problem p02811 (python)

Fixed submission:
k,x = map(int, input().split())
if k * 500 >= x:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
if k * 500 >= x:
  print('Yes')
else:
  print('No')
Problem p02812 (python)

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

for i in range(n-2):
    if s[i:i+3] == "ABC":
        x += 1

print(x)

Buggy submission (verdict: Runtime Error):
n = input()
s = input()
x = 0
for i in range(n - 2)
	if s[i:3] == "ABC"
  		x += 1
Problem p02817 (python)

Fixed submission:
s,t = map(str, input().split())
print(t+s)

Buggy submission (verdict: Runtime Error):
s,t = map(str, input(),split())
print(t + s)
Problem p03399 (python)

Fixed submission:
print(min(int(input()), int(input())) + min(int(input()), int(input())))

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

a = [0] + list(map(int, input().split())) + [0]

s = 0



for i in range(n+1):
    s += abs(a[i+1] - a[i])

for i in range(1,n+1):
    if (a[i] - a[i-1])*(a[i+1] - a[i]) < 0:
        if abs(a[i] - a[i-1]) < abs(a[i+1] - a[i]):
            print(s - 2*abs(a[i] - a[i-1]))
        else:
            print(s - 2*abs(a[i+1] - a[i]))
    else :
        print(s)

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

a = [0] + list(map(int, input().split())) + [0]

s = 0



for i in range(n+1):
    s += abs(a[i+1] - a[i])

for i in range(1,n+1):
    if (a[i] - a[i-1])*(a[i+1] - a[i]) < 0:
        if abs(a[i] - a[i-1]) < abs(a[i+1] - a[i]):
            print(s - 2*abs(a[i] - a[i-1]))
        else:
            print(s - 2*abs(a[i+1] - a[i]))
    else :
        print(s)

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

a = [0] + list(map(int, input().split())) + [0]

s = 0



for i in range(n+1):
    s += abs(a[i+1] - a[i])

for i in range(1,n+1):
    if (a[i] - a[i-1])*(a[i+1] - a[i]) < 0:
        if abs(a[i] - a[i-1]) < abs(a[i+1] - a[i]):
            print(s - 2*abs(a[i] - a[i-1]))
        else:
            print(s - 2*(a[i+1] - a[i]))
    else :
        print(s)