Buggy python submission (verdict: Time Limit Exceeded):
n,k = list(map(int, input().split()))
step_array = list(map(int, input().split()))
score_array = [0 for _ in range(n)]
for i in range(0, n+1):
	for j in range(1, k+1):
		if i+j > n-1:
			break
		cost = abs(step_array[i] - step_array[i+j]) + score_array[i]
		if( score_array[i+j] == 0 or score_array[i+j]>cost):
			score_array[i+j] = cost
print(score_array[n-1])

Fixed submission:
n,k = list(map(int, input().strip().split()))
step_array = list(map(int, input().strip().split()))
score_array = [0]
for i in range(0, n+1):
	for j in range(1, k+1):
		if i+j > n-1:
			break
		cost = abs(step_array[i] - step_array[i+j]) + score_array[i]
		if len(score_array) <= i+j:
			score_array.append(cost)
		elif(score_array[i+j]>cost):
			score_array[i+j] = cost
print(score_array[n-1])

Buggy python submission (verdict: Runtime Error):
n,k = list(map(int, input().split()))
step_array = list(map(int, input().split()))
score_array = [0 for _ in range(10)]
for i in range(0, n+1):
	for j in range(1, k+1):
		if i+j > n-1:
			break
		cost = abs(step_array[i] - step_array[i+j]) + score_array[i]
		if( score_array[i+j] == 0 or score_array[i+j]>cost):
			score_array[i+j] = cost
print(score_array[n-1])

Fixed submission:
n,k = list(map(int, input().strip().split()))
step_array = list(map(int, input().strip().split()))
score_array = [0]
for i in range(0, n+1):
	for j in range(1, k+1):
		if i+j > n-1:
			break
		cost = abs(step_array[i] - step_array[i+j]) + score_array[i]
		if len(score_array) <= i+j:
			score_array.append(cost)
		elif(score_array[i+j]>cost):
			score_array[i+j] = cost
print(score_array[n-1])

Buggy python submission (verdict: Runtime Error):
n,k = list(map(int, input().split()))
step_array = list(map(int, input().split()))
score_array = [0 for _ in range(10)]
for i in range(0, n+1):
	for j in range(1, k+1):
		if i+j > n-1:
			break
		cost = abs(step_array[i] - step_array[i+j]) + score_array[i]
		if( score_array[i+j] == 0 or score_array[i+j]>cost):
			score_array[i+j] = cost
print(score_array[n-1])

Fixed submission:
n,k = list(map(int, input().strip().split()))
step_array = list(map(int, input().strip().split()))
score_array = [0]
for i in range(0, n+1):
	for j in range(1, k+1):
		if i+j > n-1:
			break
		cost = abs(step_array[i] - step_array[i+j]) + score_array[i]
		if len(score_array) <= i+j:
			score_array.append(cost)
		elif(score_array[i+j]>cost):
			score_array[i+j] = cost
print(score_array[n-1])

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline
n,k = list(map(int, input().split()))
step_array = list(map(int, input().split()))
score_array = [0]
for i in range(0, n+1):
	for j in range(1, k+1):
		if i+j > n-1:
			break
		cost = abs(step_array[i] - step_array[i+j]) + score_array[i]
		if len(score_array) <= i+j:
			score_array.append(cost)
		elif(score_array[i+j]>cost):
			score_array[i+j] = cost
print(score_array[n-1])

Fixed submission:
n,k = list(map(int, input().strip().split()))
step_array = list(map(int, input().strip().split()))
score_array = [0]
for i in range(0, n+1):
	for j in range(1, k+1):
		if i+j > n-1:
			break
		cost = abs(step_array[i] - step_array[i+j]) + score_array[i]
		if len(score_array) <= i+j:
			score_array.append(cost)
		elif(score_array[i+j]>cost):
			score_array[i+j] = cost
print(score_array[n-1])

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline
n,k = list(map(int, input().strip().split()))
step_array = list(map(int, input().strip().split()))
score_array = [0]
for i in range(0, n+1):
	for j in range(1, k+1):
		if i+j > n-1:
			break
		cost = abs(step_array[i] - step_array[i+j]) + score_array[i]
		if len(score_array) <= i+j:
			score_array.append(cost)
		elif(score_array[i+j]>cost):
			score_array[i+j] = cost
print(score_array[n-1])

Fixed submission:
n,k = list(map(int, input().strip().split()))
step_array = list(map(int, input().strip().split()))
score_array = [0]
for i in range(0, n+1):
	for j in range(1, k+1):
		if i+j > n-1:
			break
		cost = abs(step_array[i] - step_array[i+j]) + score_array[i]
		if len(score_array) <= i+j:
			score_array.append(cost)
		elif(score_array[i+j]>cost):
			score_array[i+j] = cost
print(score_array[n-1])

Buggy python submission (verdict: Runtime Error):
input = sys.stdin.readline
n,k = list(map(int, input().strip().split()))
step_array = list(map(int, input().strip().split()))
score_array = [0]
for i in range(0, n+1):
	for j in range(1, k+1):
		if i+j > n-1:
			break
		cost = abs(step_array[i] - step_array[i+j]) + score_array[i]
		if len(score_array) <= i+j:
			score_array.append(cost)
		elif(score_array[i+j]>cost):
			score_array[i+j] = cost
print(score_array[n-1])

Fixed submission:
n,k = list(map(int, input().strip().split()))
step_array = list(map(int, input().strip().split()))
score_array = [0]
for i in range(0, n+1):
	for j in range(1, k+1):
		if i+j > n-1:
			break
		cost = abs(step_array[i] - step_array[i+j]) + score_array[i]
		if len(score_array) <= i+j:
			score_array.append(cost)
		elif(score_array[i+j]>cost):
			score_array[i+j] = cost
print(score_array[n-1])

Buggy python submission (verdict: Time Limit Exceeded):
n,k = list(map(int, input().strip().split()))
step_array = list(map(int, input().strip().split()))
score_array = [0]
for i in range(0, n+1):
	for j in range(1, k+1):
		if i+j > n-1:
			break
		cost = abs(step_array[i] - step_array[i+j]) + score_array[i]
		if len(score_array) <= i+j:
			score_array.append(cost)
		elif(score_array[i+j]>cost):
			score_array[i+j] = cost
print(score_array[n-1])

Fixed submission:
n,k = list(map(int, input().strip().split()))
step_array = list(map(int, input().strip().split()))
score_array = [0]
for i in range(0, n+1):
	for j in range(1, k+1):
		if i+j > n-1:
			break
		cost = abs(step_array[i] - step_array[i+j]) + score_array[i]
		if len(score_array) <= i+j:
			score_array.append(cost)
		elif(score_array[i+j]>cost):
			score_array[i+j] = cost
print(score_array[n-1])