Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
 a, b, c = map(int, input().split())
 if b - a == c - b:
     print('YES')
else:
    print('NO')

Fixed submission:
a, b, c = map(int, input().split())
if b - a == c - b:
     print('YES')
else:
    print('NO')
Buggy python submission (verdict: Runtime Error):
a , b , h = [int(input()) for _ in range(3)]
printint(((a + b) * h / 2))

Fixed submission:
a , b , h = [int(input()) for _ in range(3)]
print(int((a + b) * h / 2))
Buggy python submission (verdict: Runtime Error):
s  = int(input().split())
s.sort()
if s[0] == 5 and s[1] == 5 and s[2] == 7:
    print('YES')
else:
    print('NO')

Fixed submission:
a = list(map(int, input().split()))
a.sort()
ans = [5, 5, 7]
if ans == a:
    print('YES')
else:
    print('NO')
Buggy python submission (verdict: Runtime Error):
a = input.split(' ')
A = a[0]
B = a[1]
A_A = A + A - 1
A_B = A + B
B_B = B + B - 1
list = [A_B, A_A, B_B]
list.sort(reverse=True)
print(list[0])

Fixed submission:
A,B = map(int,input().split())
A_A = A + A - 1
A_B = A + B
B_B = B + B - 1
list = [A_B, A_A, B_B]
list.sort(reverse=True)
print(list[0])
Buggy python submission (verdict: Runtime Error):
S = input()
T = input()

c = 0
for i in range(len(S)):
  if S[i] != T[i]:
    C += 1
    
print(c)

Fixed submission:
s=input()
t=input()
ans=0
for i in range(len(s)):
    ans+=(s[i]!=t[i])
print(ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())
a=0
for i in range(1,n+1):
  x,y=i,(n//i)*i
  a+=((n//i)*(x+y)//2)
print(a)

Fixed submission:
n=int(input())
ans=0
for i in range(1,n+1):
    x,y=i,(n//i)*i
    ans+=((n//i)*(x+y)//2)
print(ans)
Buggy python submission (verdict: Runtime Error):
count = -1
realcount = 0
for i in k:
    count +=1
    if i!=S[count]:
        S.replace(S[count],i)
        realcount+=1
        if realcount == 0:
            real = 0
        else:
            real = realcount//2
print(real)

Fixed submission:
S = input()
k = S[::-1]
count = -1
realcount = 0
for i in k:
    count +=1
    if i!=S[count]:
        S.replace(S[count],i)
        realcount+=1
    if realcount == 0:
        real = 0
    else:
        real = realcount//2
print(real)

Buggy python submission (verdict: Runtime Error):
S = input()
k = S[::-1]
count = -1
realcount = 0
for i in k:
    count +=1
    if i!=S[count]:
        S.replace(S[count],i)
        realcount+=1
        real = realcount//2
print(real)

Fixed submission:
S = input()
k = S[::-1]
count = -1
realcount = 0
for i in k:
    count +=1
    if i!=S[count]:
        S.replace(S[count],i)
        realcount+=1
    if realcount == 0:
        real = 0
    else:
        real = realcount//2
print(real)
Buggy python submission (verdict: Runtime Error):
N = int(input('人数：'))
A = int(input('電車賃：'))
B = int(input('タクシー代：'))
l=N*A
if l>B:
    print(B)
else:
    print(l)

Fixed submission:
N,A,B = map (int,input().split())
l=N*A
if l>B:
    print(B)
else:
    print(l)
Buggy python submission (verdict: Runtime Error):

a=input()
b=input()
i=0
good=0
while(i<len(a)):
    if(a[i]!=b[i]):
        good+=1
	i+=1
print(good)        

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

good=0
for i in range(len(a)):
    if(a[i]!=b[i]):
        good+=1
print(good)

Buggy python submission (verdict: Time Limit Exceeded):
a=input()
b=input()
i=0
good=0
while(i<len(a)):
    if(a[i]!=b[i]):
        good+=1
print(good)        

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

good=0
for i in range(len(a)):
    if(a[i]!=b[i]):
        good+=1
print(good)
Buggy python submission (verdict: Runtime Error):
S = input()
N = len(S)
ans = 0
for i in range(N):
	for j in range(i, N):
		if all('ACGT'.count(c) == 1 for c in S[i : j + 1]):
ans = max(ans, j - i + 1)
print(ans)

Fixed submission:
S = input()
N = len(S)
ans = 0
for i in range(N):
    for j in range(i, N):
        if all('ACGT'.count(c) == 1 for c in S[i : j + 1]):
            ans = max(ans, j - i + 1)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
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()]
A.sort()
B.sort()
C.sort()

import bisect
ans = 0

B_list = []
for b in B:
    B_list.append(bisect.bisect_left(A,b))

for c in C:
    b_bisect = bisect.bisect_left(B, c)
    for i, b in enumerate(B[:b_bisect]):
        #a_bisect = bisect.bisect_left(A,b)
        #の代わり
        a_bisect = B_list[i]
        ans += a_bisect 
print(ans)

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()]


A.sort()
B.sort()
C.sort()

import bisect
ans = 0

a2b = []
c2b = []
for b in B:
    i = N - bisect.bisect_right(C, b)

    #例えば，C＝「13344」のとき，b=3とする，n=5なので，2になってほしい
    #bisect.bisect_right(C, b)＝3になるので，c＿bisect＝N-bisect.bisect_right(B, c)

    #例えば，C＝「133344」のとき，b=3とする，n=6なので，2になってほしい
    #bisect.bisect_right(C, b)＝4になるので，c＿bisect＝N-bisect.bisect_right(B, c)=2
    
    j = bisect.bisect_left(A, b)
    #例えば，A＝「13344」のとき，b=3とする，n=5なので，1になってほしい
    #bisect.bisect_left(A, b)＝1になるので，c＿bisect＝bisect.bisect_left(A, b)
    
    
    #例えば，A＝「113344」のとき，b=3とする，n=6なので，2になってほしい
    #bisect.bisect_left(A, b)＝2になるので，c＿bisect＝bisect.bisect_left(A, b)
    ans += i*j
    #print(i,j,i*j)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
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()]

A.sort()
B.sort()
C.sort()

import bisect
ans = 0
for c in C:
    b_bisect = bisect.bisect_left(B, c)
    for b in B[:b_bisect]:
        a_bisect = bisect.bisect_left(A,b)
        ans += a_bisect 
print(ans)

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()]


A.sort()
B.sort()
C.sort()

import bisect
ans = 0

a2b = []
c2b = []
for b in B:
    i = N - bisect.bisect_right(C, b)

    #例えば，C＝「13344」のとき，b=3とする，n=5なので，2になってほしい
    #bisect.bisect_right(C, b)＝3になるので，c＿bisect＝N-bisect.bisect_right(B, c)

    #例えば，C＝「133344」のとき，b=3とする，n=6なので，2になってほしい
    #bisect.bisect_right(C, b)＝4になるので，c＿bisect＝N-bisect.bisect_right(B, c)=2
    
    j = bisect.bisect_left(A, b)
    #例えば，A＝「13344」のとき，b=3とする，n=5なので，1になってほしい
    #bisect.bisect_left(A, b)＝1になるので，c＿bisect＝bisect.bisect_left(A, b)
    
    
    #例えば，A＝「113344」のとき，b=3とする，n=6なので，2になってほしい
    #bisect.bisect_left(A, b)＝2になるので，c＿bisect＝bisect.bisect_left(A, b)
    ans += i*j
    #print(i,j,i*j)
print(ans)
Buggy python submission (verdict: Runtime Error):
import math
A,B,C,D = map(int,input().split())
if (math.ceil(C/B) =< math.ceil(A/D)):
    print('Yes')
else:
    print('No')

Fixed submission:
import math
A,B,C,D = map(int,input().split())
if (math.ceil(C/B) <= math.ceil(A/D)):
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Runtime Error):
import math
N = int(input().split())
print(math.ceil(N/2))

Fixed submission:
import math
N = int(input())
print(math.ceil(N/2))
Buggy python submission (verdict: Runtime Error):
HW =[list(map(int,input().split())) for i in range(2)]
print((HW[0][0]-HW[1][0])*(HW[0][1]-HW[1][1])

Fixed submission:
HW =[list(map(int,input().split())) for i in range(2)]
print((HW[0][0]-HW[1][0])*(HW[0][1]-HW[1][1]))
Buggy python submission (verdict: Runtime Error):
n,m = int(input().split())
k = (n-1)*(m-1)
print(k)

Fixed submission:
n,m = map(int,input().split())
k = (n-1)*(m-1)
print(k)
Buggy python submission (verdict: Runtime Error):
num = input()
print(num+num**2+num**3)

Fixed submission:
def a172(a):
 
    return a + a**2 + a**3
 
def main():
    a = int(input())
    print(a172(a))
 
if __name__ == '__main__':
    main()

Buggy python submission (verdict: Runtime Error):
ソースコード 

Copy
Copy
def a172(a):
 
    return a + a**2 + a**3
 
def main():
    a = int(input())
    print(a172(a))
 
if __name__ == '__main__':
    main()

Fixed submission:
def a172(a):
 
    return a + a**2 + a**3
 
def main():
    a = int(input())
    print(a172(a))
 
if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
a, b = [0], [0]
for i in range(N):
a.append(a[i] + A[i])
for i in range(M):
b.append(b[i] + B[i])
ans, j = 0, M
for i in range(N + 1):
if a[i] > K:
break
while b[j] > K - a[i]:
j -= 1
ans = max(ans, i + j)
print(ans)

Fixed submission:
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
a, b = [0], [0]
for i in range(N):
    a.append(a[i] + A[i])
for i in range(M):
    b.append(b[i] + B[i])
ans, j = 0, M
for i in range(N + 1):
    if a[i] > K:
        break
    while b[j] > K - a[i]:
        j -= 1
    ans = max(ans, i + j)
print(ans)

Buggy python submission (verdict: Runtime Error):
N,M,K = (int(x) for x in input().split())
A = list(map(int, input.split()))
B = list(map(int, input.split()))
i,j = 0
time = 0
while time < K and i < N-1 or j < M-1:
    if A[i] < B[j]:
        time += A[i]
        i += 1
    elif A[i] > B[j]:
        time += B[j]
        j += 1
allbooks = i + j
print(allbooks)

Fixed submission:
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
a, b = [0], [0]
for i in range(N):
    a.append(a[i] + A[i])
for i in range(M):
    b.append(b[i] + B[i])
ans, j = 0, M
for i in range(N + 1):
    if a[i] > K:
        break
    while b[j] > K - a[i]:
        j -= 1
    ans = max(ans, i + j)
print(ans)
Buggy python submission (verdict: Runtime Error):
a = input()
print(a + a * a + a * a * a)

Fixed submission:
a = int(input())
print(a + a * a + a * a * a)
Buggy python submission (verdict: Runtime Error):
S = list(input())
T = list(input())
count = 0

for i in range(len(S)):
  if S[i] != T[i]:
	count += 1

print(count)


Fixed submission:
S = list(input())
T = list(input())
count = 0

for i in range(len(S)):
  if S[i] != T[i]:
    count += 1

print(count)

Buggy python submission (verdict: Runtime Error):
S = list(input())
T = list(input())
count = 0

for i in range(len(S)):
  if S[i] != T[i]
	count += 1

print(count)

Fixed submission:
S = list(input())
T = list(input())
count = 0

for i in range(len(S)):
  if S[i] != T[i]:
    count += 1

print(count)
Buggy python submission (verdict: Runtime Error):
n, k = map(int, input().split())
p = sorted(list(int(input()) for _ in range(n)))
print(sum(p[0:k]))

Fixed submission:
n, k = map(int, input().split())
p = sorted(list(map(int, input().split())))
print(sum(p[0:k]))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int,input().split()))
ans = 1
if 0 in a :
    ans = 0
else:
    for i in a :
        ans *= i

if ans > 10**18:
    print(-1)
else:
    print(ans)

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
ans = 1
if 0 in a :
    ans = 0
    print(0)
else:
    for i in a :
        ans *= i
        if ans > 10**18:
            print(-1)
            break
    else:
        print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int,input().split()))
ans = 1
if 0 in a :
    ans = 0
else:
    for i in a :
        ans = ans*i

if ans > 10**18:
    print(-1)
else:
    print(ans)

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
ans = 1
if 0 in a :
    ans = 0
    print(0)
else:
    for i in a :
        ans *= i
        if ans > 10**18:
            print(-1)
            break
    else:
        print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int,input().split()))
ans = 1
if 0 in a :
    ans = 0
else:
    for i in a :
        ans = ans*i

if ans > 10**18:
    print(-1)
else:
    print(ans)

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
ans = 1
if 0 in a :
    ans = 0
    print(0)
else:
    for i in a :
        ans *= i
        if ans > 10**18:
            print(-1)
            break
    else:
        print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
a, b, c, k = map(int, input().split())
abc = []
for i in range(a):
    abc.append(1)

for j in range(b):
    abc.append(0)

for l in range(c):
    abc.append(-1)

print(sum(abc[0:k]))

Fixed submission:
a, b, c, k = map(int, input().split())
ans = 0
if a >= k :
    ans += k
elif a < k :
    ans += a
    if b >= (k-a):
        ans += 0
    elif b < (k-a) :
        ans += ((k-a)-b)*-1

print(ans)
Buggy python submission (verdict: Runtime Error):
k = int(input())
a, b = map(int,input().split())
x = k * (a // k) + k
if k == 1:
    print("OK")
elif : x >= a and x <= b:
    print("OK")
else:
    print("NG")

Fixed submission:
k = int(input())
a, b = map(int,input().split())
for i in range(a, b+1):
    if i%k == 0 :
        print("OK")
        break
else:
    print("NG")
Buggy python submission (verdict: Runtime Error):
a, b = map(int, input().split())
ans = []
for i in range(1,101):
    if a == int(i*0.08) and b == int(i*0.1):
        ans.append(i)
else:
    print(min(ans))

Fixed submission:
a, b = map(int, input().split())
ans = []
for i in range(1,1251):
    if a == int(i*0.08) and b == int(i*0.1):
        ans.append(i)

if len(ans) == 0:
    print("-1")
else:
    print(min(ans))
Buggy python submission (verdict: Runtime Error):
a1 = list(map(int, input().split()))
a2 = list(map(int, input().split()))
a3 = list(map(int, input().split()))
a = a1+a2+a3
n = int(input())
b = list(int(input()) for _ in range(n))

for i in b:
    if i in a :
        a[a.index(a)] = "h"

if a[0:3].count("h") == 3 or a[3:6].count("h") == 3 or a[6:9].count("h") == 3:
    print("Yes")
elif a[0] == "h" and a[4] == "h" and a[8] == "h":
    print("Yes")
elif a[2] == "h" and a[4] == "h" and a[6] == "h":
    print("Yes")
elif a[0] == "h" and a[3] == "h" and a[6] == "h":
    print("Yes") 
elif a[1] == "h" and a[4] == "h" and a[7] == "h":
    print("Yes") 
elif a[2] == "h" and a[5] == "h" and a[8] == "h":
    print("Yes") 
else:
    print("No")

Fixed submission:
a1 = list(map(int, input().split()))
a2 = list(map(int, input().split()))
a3 = list(map(int, input().split()))
a = a1+a2+a3
n = int(input())
b = list(int(input()) for _ in range(n))

for i in b:
    if i in a :
        a[a.index(i)] = "h"

if a[0:3].count("h") == 3 or a[3:6].count("h") == 3 or a[6:9].count("h") == 3:
    print("Yes")
elif a[0] == "h" and a[4] == "h" and a[8] == "h":
    print("Yes")
elif a[2] == "h" and a[4] == "h" and a[6] == "h":
    print("Yes")
elif a[0] == "h" and a[3] == "h" and a[6] == "h":
    print("Yes") 
elif a[1] == "h" and a[4] == "h" and a[7] == "h":
    print("Yes") 
elif a[2] == "h" and a[5] == "h" and a[8] == "h":
    print("Yes") 
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
h, n = map(int, input().split())
a = sorted(list(map(int, input().split())))
if a[-1] + a[-2] < h:
    print('No')
else:
    print('Yes')

Fixed submission:
h, n = map(int, input().split())
a = sorted(list(map(int, input().split())))
if sum(a) < h:
    print('No')
else:
    print('Yes')
Buggy python submission (verdict: Runtime Error):
s = list(input())
sr = []
ans=0
m = len(s)/2

for i in s[::-1]:
    sr.append(i)


for i in range(m):
    if s[i] != sr[i]:
        ans +=1

print(ans)

Fixed submission:
s = list(input())
sr = []
ans=0
m = len(s)//2

for i in s[::-1]:
    sr.append(i)


for i in range(m):
    if s[i] != sr[i]:
        ans +=1

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
m = []

for i in range(n):
    j = a.index(i+1)
    m.append(str(j+1))
else:
    print(" ".join(m))

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
b = [i for i in range(1,n+1)]
ab = dict(zip(a, b))
ab2 = sorted(ab.items())
m = []

for i in range(n):
    m.append(str(ab2[i][1]))
else:
    print(" ".join(m))
Buggy python submission (verdict: Runtime Error):
a ,b = int(input()), int(input())
if (a + b) % 2 != 0:
  print('IMPOSSIBLE')
else:
  print((a + b) // 2)

Fixed submission:
a ,b = map(int, input().split())
if (a + b) % 2 != 0:
  print('IMPOSSIBLE')
else:
  print((a + b) // 2)
Buggy python submission (verdict: Runtime Error):
def dist(a, b):
    res = 0
    for i in range(D):
        res += (a[i] - b[i])**2
    res = res ** 0.5
    return res

N, D = map(int,input().split())
x = [list(map(int, input().split()) for _ in range(N))]
ans = 0
for i in range(N-1):
    for j in range(i+1, N):
        if dist(x[i], x[i]).is_integer():
            ans += 1

print(ans)

Fixed submission:
def dist(a, b):
	res = 0
	for i in range(D):
		res += (a[i] - b[i]) ** 2
	res = res ** 0.5
	return res


N, D = map(int, input().split())
X = [list(map(int, input().split())) for _ in range(N)]
ans = 0
for i in range(N - 1):
	for j in range(i + 1, N):
		if dist(X[i], X[j]).is_integer():
			ans += 1
print(ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())
data = list(map(int,input().split()))

Alice = []
Bob = []

while N != 0:
        Alice.append(max(data))
        data.remove(max(data))
        if len(data) == 0:
                break
        else:
                Bob.append(max(data))
                data.remove(max(data))
        N -= 1

print(sum(Alice)-sum(Bob))

Fixed submission:
n = int(input())
a = sorted(list(map(int, input().split())), reverse=True)
print(sum(a[::2]) - sum(a[1::2]))
Buggy python submission (verdict: Runtime Error):
a, b = map(int, input().split())
s = a*b
if s % 2 == 0:
  print("Even")
  else
  print("Odd")

Fixed submission:
a, b = map(int, input().split())
s = a*b
if s % 2 == 0:
  print("Even")
else:
  print("Odd")
Buggy python submission (verdict: Runtime Error):
N, A, B = int(input()), int(input()), int(input())
data = []

def digitsum(n):
        s = str(n)
        array = list(map(int, s))
        return sum(array)

n = 0
for n in range(N+1):
        x = digitsum(n)
        if A <= x <= B:
                data.append(x)

print(sum(data))

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

for i in range(1, n+1):
    if a <= sum(map(int, list(str(i)))) <= b:
        ans += i
    else:
        continue

print(ans)

Buggy python submission (verdict: Runtime Error):
N, A, B = int(input()), int(input()), int(input())
data = []

def digitsum(n):
        s = str(n)
        array = list(map(int, s))
        return sum(array)

n = 0
for n in range(N+1):
        x = digitsum(n)
        if A <= x <= B:
                data.append(x)

sum(data)

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

for i in range(1, n+1):
    if a <= sum(map(int, list(str(i)))) <= b:
        ans += i
    else:
        continue

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

if a+b >= 10:
    print('error')
elif:
    print(a+b)

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

if a+b >= 10:
    print('error')
else:
    print(a+b)
Buggy python submission (verdict: Runtime Error):
a = int(input())
b = int(input())

if a > b:
    print('GREATER')
elif a < b:
    print('LESS')
else:
    a == b:
    print('EQUAL')

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

if a > b:
    print('GREATER')
elif a < b:
    print('LESS')
else:
    print('EQUAL')
Buggy python submission (verdict: Runtime Error):
n = int(input())
s = input()
x = 0
m = [0,]

def incre():
    for i in range(len(s)):
        if s[i] == 'I':
            x += 1
            m.append(x)
        elif s[i] == 'D':
            x -= 1
            m.append(x)
    else:
        print(max(m))

if __name__ == "__main__":
    incre()

Fixed submission:
n = int(input())
s = input()
x = 0
m = [0,]

for i in range(len(s)):
    if s[i] == 'I':
        x += 1
        m.append(x)
    elif s[i] == 'D':
        x -= 1
        m.append(x)
else:
    print(max(m))
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
import sys

def solve(N: int, K: int, h: "List[int]"):
    cumsums = [float("inf")]*N
    cumsums[0]=0
    cumsums[1]=abs(h[1]-h[0])

    for i in range(1, N):
        for j in range(1, K+1):
            if i >= j:
                cumsums[i] = min(cumsums[i], cumsums[i-j]+abs(h[i]-h[i-j]))
        #print(cumsums)
    return cumsums[-1]


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    h = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"
    print(solve(N, K, h))

if __name__ == '__main__':
    main()


Fixed submission:
import sys

def solve(N: int, K: int, h: "List[int]"):
    cumsums = [float("inf")]*N
    cumsums[0]=0
    cumsums[1]=abs(h[1]-h[0])

    for i in range(1, N):
        for j in range(1, K+1):
            if i >= j:
                cumsums[i] = min(cumsums[i], cumsums[i-j]+abs(h[i]-h[i-j]))
        #print(cumsums)
    return cumsums[-1]

N, K = map(int, sys.stdin.readline().rstrip().split())
h = list(map(int, sys.stdin.readline().rstrip().split()))
print(solve(N, K, h))

Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
import sys

def chmin(cumsum, a):
    #print("chmin:", cumsum, a)
    if cumsum > a:
        return a
    else:
        return cumsum


def solve(N: int, K: int, h: "List[int]"):
    cumsums = [float("inf")]*N
    cumsums[0]=0
    cumsums[1]=abs(h[1]-h[0])

    for i in range(1, N):
        for j in range(1, K+1):
            if i >= j:
                cumsums[i] = chmin(cumsums[i], cumsums[i-j]+abs(h[i]-h[i-j]))
        #print(cumsums)
    return cumsums[-1]


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    h = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"
    print(solve(N, K, h))

if __name__ == '__main__':
    main()


Fixed submission:
import sys

def solve(N: int, K: int, h: "List[int]"):
    cumsums = [float("inf")]*N
    cumsums[0]=0
    cumsums[1]=abs(h[1]-h[0])

    for i in range(1, N):
        for j in range(1, K+1):
            if i >= j:
                cumsums[i] = min(cumsums[i], cumsums[i-j]+abs(h[i]-h[i-j]))
        #print(cumsums)
    return cumsums[-1]

N, K = map(int, sys.stdin.readline().rstrip().split())
h = list(map(int, sys.stdin.readline().rstrip().split()))
print(solve(N, K, h))
Buggy python submission (verdict: Runtime Error):
_, *A = map(int, input().split())
A.sort()

ans = 1

if A[0] == 0:
  print(0)
else:
  for a in A:
    ans *= a
    if ans > 1000000000000000000:
      print(-1)
      break
  print(ans)


Fixed submission:
_, *A = map(int, open(0).read().split())
ans = 1

if 0 in A:
  ans = 0
else:
  for a in A:
    ans *= a
    if ans > 10 ** 18:
      ans = -1
      break
print(ans)
Buggy python submission (verdict: Runtime Error):
A, B = input().split()
A = int(A)
B = int(float(B * 100))
print(A * B / 100)

Fixed submission:
A, B = input().split()
A = int(A)
B = int(float(B) * 1000)
print((A * B) // 1000)
Buggy python submission (verdict: Runtime Error):
A, B = map(int, input().split())
a = [i for i in range(1, 1001) if int(i * 0.08) == A]
b = [i for i in range(1, 1001) if int(i * 0.1) == B]
print(min(set(a) & set(b)))


Fixed submission:
A, B = map(int, input().split())
a = [i for i in range(1, 1001) if int(i * 0.08) == A]
b = [i for i in range(1, 1001) if int(i * 0.1) == B]
c = set(a) & set(b)
if len(c):
    print(min(c))
else:
    print(-1)