Buggy python submission (verdict: Runtime Error):
# B(TLE) 2104ms

N, K = map(int, input().split())
h = np.array(list(map(int, input().split())))
cost = np.zeros(N, dtype="int32")

cost[0] = 0
for i in range(1,N):
    start = 0 if i < K else i-K
    cost[i] = np.min(cost[start:i] + np.abs(h[i]-h[start:i]))

print(cost[-1])


Fixed submission:
# B(TLE) 2104ms

import numpy as np
N, K = map(int, input().split())
h = np.array(list(map(int, input().split())))
cost = np.zeros(N, dtype="int32")

cost[0] = 0
for i in range(1,N):
    start = 0 if i < K else i-K
    cost[i] = np.min(cost[start:i] + np.abs(h[i]-h[start:i]))

print(cost[-1])

Buggy python submission (verdict: Runtime Error):
# B(TLE) 2104ms

N, K = map(int, input().split())
h = np.array(list(map(int, input().split())), dtype="int32")
cost = np.zeros(N, dtype="int32")

cost[0] = 0
for i in range(1,N):
    start = 0 if i < K else i-K
    cost[i] = np.min(cost[start:i] + np.abs(h[i]-h[start:i]))

print(cost[-1])


Fixed submission:
# B(TLE) 2104ms

import numpy as np
N, K = map(int, input().split())
h = np.array(list(map(int, input().split())))
cost = np.zeros(N, dtype="int32")

cost[0] = 0
for i in range(1,N):
    start = 0 if i < K else i-K
    cost[i] = np.min(cost[start:i] + np.abs(h[i]-h[start:i]))

print(cost[-1])

Buggy python submission (verdict: Runtime Error):
# B(TLE) 2104ms

N, K = map(int, input().split())
h = np.array(list(map(int, input().split()), dtype="int32"))
cost = np.zeros(N, dtype="int32")

cost[0] = 0
for i in range(1,N):
    start = 0 if i < K else i-K
    cost[i] = np.min(cost[start:i] + np.abs(h[i]-h[start:i]))

print(cost[-1])


Fixed submission:
# B(TLE) 2104ms

import numpy as np
N, K = map(int, input().split())
h = np.array(list(map(int, input().split())))
cost = np.zeros(N, dtype="int32")

cost[0] = 0
for i in range(1,N):
    start = 0 if i < K else i-K
    cost[i] = np.min(cost[start:i] + np.abs(h[i]-h[start:i]))

print(cost[-1])

Buggy python submission (verdict: Runtime Error):
# B(TLE) 2104ms

N, K = map(int, input().split())
h = np.array(map(int, input().split()))
cost = np.zeros(N, dtype="int32")

cost[0] = 0
for i in range(1,N):
    start = 0 if i < K else i-K
    cost[i] = np.min(cost[start:i] + np.abs(h[i]-h[start:i]))


print(cost[-1])


Fixed submission:
# B(TLE) 2104ms

import numpy as np
N, K = map(int, input().split())
h = np.array(list(map(int, input().split())))
cost = np.zeros(N, dtype="int32")

cost[0] = 0
for i in range(1,N):
    start = 0 if i < K else i-K
    cost[i] = np.min(cost[start:i] + np.abs(h[i]-h[start:i]))

print(cost[-1])

Buggy python submission (verdict: Time Limit Exceeded):
# B
import numpy as np

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

cost = [0]*N

cost[0] = 0
for i in range(1,N):
    cost_tmp = []
    for j in range(0,min(K,i)):
        cost_tmp.append(abs(h[i - (1+j)] - h[i]) + cost[i - (1+j)])
    cost[i] = np.min(cost_tmp)

print(cost[-1])


Fixed submission:
# B(TLE) 2104ms

import numpy as np
N, K = map(int, input().split())
h = np.array(list(map(int, input().split())))
cost = np.zeros(N, dtype="int32")

cost[0] = 0
for i in range(1,N):
    start = 0 if i < K else i-K
    cost[i] = np.min(cost[start:i] + np.abs(h[i]-h[start:i]))

print(cost[-1])

Buggy python submission (verdict: Time Limit Exceeded):
# B
N, K = map(int, input().split())
h = list(map(int, input().split()))

cost = [0]*N

cost[0] = 0
for i in range(1,N):
    cost_tmp = [abs(h[i - (1+j)] - h[i]) + cost[i - (1+j)] for j in range(0, min(K,i))]
    cost[i] = min(cost_tmp)

print(cost[-1])

    

Fixed submission:
# B(TLE) 2104ms

import numpy as np
N, K = map(int, input().split())
h = np.array(list(map(int, input().split())))
cost = np.zeros(N, dtype="int32")

cost[0] = 0
for i in range(1,N):
    start = 0 if i < K else i-K
    cost[i] = np.min(cost[start:i] + np.abs(h[i]-h[start:i]))

print(cost[-1])

Buggy python submission (verdict: Time Limit Exceeded):
# B
N, K = map(int, input().split())
h = list(map(int, input().split()))

cost = [0]*N

cost[0] = 0
for i in range(1,N):
    cost_tmp = []
    for j in range(0,min(K,i)):
        cost_tmp.append(abs(h[i - (1+j)] - h[i]) + cost[i - (1+j)])
    cost[i] = min(cost_tmp)

print(cost[-1])

    

Fixed submission:
# B(TLE) 2104ms

import numpy as np
N, K = map(int, input().split())
h = np.array(list(map(int, input().split())))
cost = np.zeros(N, dtype="int32")

cost[0] = 0
for i in range(1,N):
    start = 0 if i < K else i-K
    cost[i] = np.min(cost[start:i] + np.abs(h[i]-h[start:i]))

print(cost[-1])

Buggy python submission (verdict: Time Limit Exceeded):
# B
import sys
N, K = map(int, input().split())
h = list(map(int, input().split()))

cost = [0]*N

cost[0] = 0
for i in range(1,N):
    cost_tmp = []
    for j in range(0,min(K,i)):
        cost_tmp.append(abs(h[i - (1+j)] - h[i]) + cost[i - (1+j)])
    cost[i] = min(cost_tmp)

print(cost[-1])

    

Fixed submission:
# B(TLE) 2104ms

import numpy as np
N, K = map(int, input().split())
h = np.array(list(map(int, input().split())))
cost = np.zeros(N, dtype="int32")

cost[0] = 0
for i in range(1,N):
    start = 0 if i < K else i-K
    cost[i] = np.min(cost[start:i] + np.abs(h[i]-h[start:i]))

print(cost[-1])

Buggy python submission (verdict: Time Limit Exceeded):
# B
import sys
N, K = map(int, input().split())
h = list(map(int, input().split()))

cost = [0]*N

cost[0] = 0
for i in range(1,N):
    cost_tmp = [sys.maxsize]*K
    for j in range(0,min(K,i)):
        cost_tmp[j] = abs(h[i - (1+j)] - h[i]) + cost[i - (1+j)]
    cost[i] = min(cost_tmp)

print(cost[-1])

    

Fixed submission:
# B(TLE) 2104ms

import numpy as np
N, K = map(int, input().split())
h = np.array(list(map(int, input().split())))
cost = np.zeros(N, dtype="int32")

cost[0] = 0
for i in range(1,N):
    start = 0 if i < K else i-K
    cost[i] = np.min(cost[start:i] + np.abs(h[i]-h[start:i]))

print(cost[-1])