Buggy python submission (verdict: Time Limit Exceeded):
N, K  = map(int, input().split())
h = list(map(int, input().split()))
inf = 10 ** 4 + 1
dp = [inf] * N
dp[0] = 0
for i in range(1, N):
    H = h[i]
    dp[i] = min( [dp[j] + abs(h[j] - H) for j in range(max(0, i-K),i)])
print(dp[-1])


Fixed submission:
n, k = list(map(int, input().split()))
h = list(map(int, input().split()))
inf = 10 ** 4 + 1
dp = [inf] * n
dp[0] = 0
for i in range(1,n):
    H = h[i]
    dp[i] = min([dp[j] + abs(h[j] - H) for j in range(max(0, i - k), i)])
print(dp[-1])

Buggy python submission (verdict: Time Limit Exceeded):
N, K  = map(int, input().split())
h = list(map(int, input().split()))
inf = 10 ** 4 + 1
dp = [inf] * N
dp[0] = 0

for i in range(1, N):
    H = h[i]
    dp[i] = min( [dp[j] + abs(h[j] - H) for j in range(max(0, i-K),i)])
print(dp[-1])


Fixed submission:
n, k = list(map(int, input().split()))
h = list(map(int, input().split()))
inf = 10 ** 4 + 1
dp = [inf] * n
dp[0] = 0
for i in range(1,n):
    H = h[i]
    dp[i] = min([dp[j] + abs(h[j] - H) for j in range(max(0, i - k), i)])
print(dp[-1])

Buggy python submission (verdict: Time Limit Exceeded):
N, K  = map(int, input().split())
h = list(map(int, input().split()))
inf = 10 ** 4 + 1
dp = [inf] * N
dp[0] = 0

for i in range(1, N):
    H = h[i]
    dp[i] = min( [dp[j] + abs(h[j] - H) for j in range(max(0, i-K),i)])
print(dp[N-1])


Fixed submission:
n, k = list(map(int, input().split()))
h = list(map(int, input().split()))
inf = 10 ** 4 + 1
dp = [inf] * n
dp[0] = 0
for i in range(1,n):
    H = h[i]
    dp[i] = min([dp[j] + abs(h[j] - H) for j in range(max(0, i - k), i)])
print(dp[-1])

Buggy python submission (verdict: Time Limit Exceeded):
N, K  = map(int, input().split())
h = list(map(int, input().split()))
inf = 10 ** 4 + 1
dp = [inf] * N
dp[0] = 0
dp[1] = abs(h[1]- h[0])
for i in range(2, N):
    H = h[i]
    dp[i] = min( [dp[j] + abs(h[j] - H) for j in range(max(0, i-K),i)])
print(dp[N-1])


Fixed submission:
n, k = list(map(int, input().split()))
h = list(map(int, input().split()))
inf = 10 ** 4 + 1
dp = [inf] * n
dp[0] = 0
for i in range(1,n):
    H = h[i]
    dp[i] = min([dp[j] + abs(h[j] - H) for j in range(max(0, i - k), i)])
print(dp[-1])

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

inf = 10 ** 4 + 1
dp = [inf] * N
dp[0] = 0
dp[1] = abs(h[1]- h[0])
for i in range(2, N):
    H = h[i]
    dp[i] = min( [dp[j] + abs(h[j] - H) for j in range(max(0, i-K),i)])
print(dp[N-1])


Fixed submission:
n, k = list(map(int, input().split()))
h = list(map(int, input().split()))
inf = 10 ** 4 + 1
dp = [inf] * n
dp[0] = 0
for i in range(1,n):
    H = h[i]
    dp[i] = min([dp[j] + abs(h[j] - H) for j in range(max(0, i - k), i)])
print(dp[-1])

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

inf = 10 ** 4 + 1
dp = [inf] * N
dp[0] = 0
dp[1] = abs(h[1]- h[0])

for i in range(2, N):
    dp[i] = min( [dp[j] + abs(h[j] - h[i]) for j in range(max(0, i-K),i)])

print(dp[N-1])


Fixed submission:
n, k = list(map(int, input().split()))
h = list(map(int, input().split()))
inf = 10 ** 4 + 1
dp = [inf] * n
dp[0] = 0
for i in range(1,n):
    H = h[i]
    dp[i] = min([dp[j] + abs(h[j] - H) for j in range(max(0, i - k), i)])
print(dp[-1])

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

inf = 10 ** 4 + 1
dp = [inf] * N
dp[0] = 0
dp[1] = abs(h[1]- h[0])

for i in range(2, N):
    dp[i] =  min( [dp[j] + abs(h[i] - h[j]) for j in range(max(0, i-K), i)])

print(dp[N-1])


Fixed submission:
n, k = list(map(int, input().split()))
h = list(map(int, input().split()))
inf = 10 ** 4 + 1
dp = [inf] * n
dp[0] = 0
for i in range(1,n):
    H = h[i]
    dp[i] = min([dp[j] + abs(h[j] - H) for j in range(max(0, i - k), i)])
print(dp[-1])

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

inf = 10 ** 4 + 1
dp = [inf] * N
dp[0] = 0

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


print(dp[-1])


Fixed submission:
n, k = list(map(int, input().split()))
h = list(map(int, input().split()))
inf = 10 ** 4 + 1
dp = [inf] * n
dp[0] = 0
for i in range(1,n):
    H = h[i]
    dp[i] = min([dp[j] + abs(h[j] - H) for j in range(max(0, i - k), i)])
print(dp[-1])

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

inf = 10 ** 4 + 1
dp = [inf] * N
dp[0] = 0

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


print(dp[-1])

Fixed submission:
n, k = list(map(int, input().split()))
h = list(map(int, input().split()))
inf = 10 ** 4 + 1
dp = [inf] * n
dp[0] = 0
for i in range(1,n):
    H = h[i]
    dp[i] = min([dp[j] + abs(h[j] - H) for j in range(max(0, i - k), i)])
print(dp[-1])

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

inf = 10 ** 4 + 1
dp = [inf] * N
dp[0] = 0

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


print(dp[N-1])

Fixed submission:
n, k = list(map(int, input().split()))
h = list(map(int, input().split()))
inf = 10 ** 4 + 1
dp = [inf] * n
dp[0] = 0
for i in range(1,n):
    H = h[i]
    dp[i] = min([dp[j] + abs(h[j] - H) for j in range(max(0, i - k), i)])
print(dp[-1])

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

inf = 10 ** 4 + 1
dp = [inf] * n
dp[0] = 0

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


print(dp[N-1])

Fixed submission:
n, k = list(map(int, input().split()))
h = list(map(int, input().split()))
inf = 10 ** 4 + 1
dp = [inf] * n
dp[0] = 0
for i in range(1,n):
    H = h[i]
    dp[i] = min([dp[j] + abs(h[j] - H) for j in range(max(0, i - k), i)])
print(dp[-1])

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

dp = [100000] * N

dp[0] = 0

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


print(dp[N-1])

Fixed submission:
n, k = list(map(int, input().split()))
h = list(map(int, input().split()))
inf = 10 ** 4 + 1
dp = [inf] * n
dp[0] = 0
for i in range(1,n):
    H = h[i]
    dp[i] = min([dp[j] + abs(h[j] - H) for j in range(max(0, i - k), i)])
print(dp[-1])