Buggy python submission (verdict: Runtime Error):
N,K = [int(i) for i in input().split()]
h = [int(i) for i in input().split()]
minTotalCostList = [0 for i in range(N)]
minTotalCostList[0] = 0
for i in range(1,N) :
	for j in range(1,K+1) :
		if j == 1 :
			minTotalCostList[i] = (abs(h[i] - h[i-j]) + minTotalCostList[i-j] )
		elif j > i or minTotalCostList[i] == 0 :
			break
		else :
			minTotalCostList[i] = min(minTotalCostList[i], (abs(h[i] - h[i-j]) + minTotalCostList[i-j] ))

print(minTotalCostList[N-1])

Fixed submission:
N = int(input())
h = [int(i) for i in input().split()]
minToatalCostList = [0 for i in range(N)]

for i in range(N) :
	if i > 1 :
		minToatalCostList[i] = min( abs(h[i] - h[i-1]) + minToatalCostList[i-1], abs(h[i] - h[i-2]) + minToatalCostList[i-2] )
	elif i == 1:
		minToatalCostList[i] = abs(h[i] - h[i-1])
	else :
		minToatalCostList[i] = 0

print(minToatalCostList[N-1])

Buggy python submission (verdict: Runtime Error):
N,K = [int(i) for i in input().split()]
h = [int(i) for i in input().split()]
minTotalCostList = [0 for i in range(N)]
minTotalCostList[0] = 0
for i in range(1,N) :
	for j in range(1,K+1) :
		if j <= i and minTotalCostList[i] != 0 and j != 1 :
			minTotalCostList[i] = min(minTotalCostList[i], (abs(h[i] - h[i-j]) + minTotalCostList[i-j] ))
		elif j > i or minTotalCostList[i] == 0 :
			break
		elif j == 1 :
			minTotalCostList[i] = (abs(h[i] - h[i-j]) + minTotalCostList[i-j] )

print(minTotalCostList[N-1])


N = int(input())
h = [int(i) for i in input().split()]
minTotalCostList = [0 for i in range(N)]

for i in range(N) :
	if i > 1 :
		minTotalCostList[i] = min( abs(h[i] - h[i-1]) + minTotalCostList[i-1], abs(h[i] - h[i-2]) + minTotalCostList[i-2] )
	elif i == 1:
		minTotalCostList[i] = abs(h[i] - h[i-1])
	else :
		minTotalCostList[i] = 0

print(minTotalCostList[N-1])

Fixed submission:
N = int(input())
h = [int(i) for i in input().split()]
minToatalCostList = [0 for i in range(N)]

for i in range(N) :
	if i > 1 :
		minToatalCostList[i] = min( abs(h[i] - h[i-1]) + minToatalCostList[i-1], abs(h[i] - h[i-2]) + minToatalCostList[i-2] )
	elif i == 1:
		minToatalCostList[i] = abs(h[i] - h[i-1])
	else :
		minToatalCostList[i] = 0

print(minToatalCostList[N-1])

Buggy python submission (verdict: Runtime Error):
N,K = [int(i) for i in input().split()]
h = [int(i) for i in input().split()]
minToatalCostList = [0 for i in range(N)]
minToatalCostList[0] = 0

for i in range(1,N) :
	for j in range(1,K+1) :
		if j <= i and minTotalCostList[i] != 0 and j != 1 :
			minToatalCostList[i] = min(minToatalCostList[i], (abs(h[i] - h[i-j]) + minToatalCostList[i-j] ))
		elif j > i or minToatalCostList[i] == 0 :
			break
		elif j == 1 :
			minToatalCostList[i] = (abs(h[i] - h[i-j]) + minToatalCostList[i-j] )

print(minToatalCostList[N-1])

Fixed submission:
N = int(input())
h = [int(i) for i in input().split()]
minToatalCostList = [0 for i in range(N)]

for i in range(N) :
	if i > 1 :
		minToatalCostList[i] = min( abs(h[i] - h[i-1]) + minToatalCostList[i-1], abs(h[i] - h[i-2]) + minToatalCostList[i-2] )
	elif i == 1:
		minToatalCostList[i] = abs(h[i] - h[i-1])
	else :
		minToatalCostList[i] = 0

print(minToatalCostList[N-1])

Buggy python submission (verdict: Runtime Error):
N,K = [int(i) for i in input().split()]
h = [int(i) for i in input().split()]
minToatalCostList = [10000 for i in range(N)]
minToatalCostList[0] = 0

for i in range(1,N) :
	for j in range(1,K+1) :
		if j > i or minToatalCostList[i] == 0 :
			break
		else :
			minToatalCostList[i] = min(minToatalCostList[i], abs(h[i] - h[i-j]) + minToatalCostList[i-j] )

print(int(minToatalCostList[N-1]))

Fixed submission:
N = int(input())
h = [int(i) for i in input().split()]
minToatalCostList = [0 for i in range(N)]

for i in range(N) :
	if i > 1 :
		minToatalCostList[i] = min( abs(h[i] - h[i-1]) + minToatalCostList[i-1], abs(h[i] - h[i-2]) + minToatalCostList[i-2] )
	elif i == 1:
		minToatalCostList[i] = abs(h[i] - h[i-1])
	else :
		minToatalCostList[i] = 0

print(minToatalCostList[N-1])