Buggy python submission (verdict: Runtime Error):
import numpy as np
import sys

input = sys.stdin.readline

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

H = np.array(list(map(int, input().split())))

dp = np.zero(N, dtype=int)

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

print(dp[N-1])

Fixed submission:
import numpy as np

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

H = np.array(list(map(int, input().split())))

dp = np.zeros(N, dtype=int)

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

print(dp[N-1])

Buggy python submission (verdict: Runtime Error):
import numpy as np

input = sys.stdin.readline

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

H = np.array(list(map(int, input().split())))

dp = np.zero(N, dtype=int)

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

print(dp[N-1])
    

Fixed submission:
import numpy as np

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

H = np.array(list(map(int, input().split())))

dp = np.zeros(N, dtype=int)

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

print(dp[N-1])

Buggy python submission (verdict: Runtime Error):
import numpy as np

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

H = np.array(list(map(int, input().split())))

dp = np.zero(N, dtype=int)

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

print(dp[N-1])

Fixed submission:
import numpy as np

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

H = np.array(list(map(int, input().split())))

dp = np.zeros(N, dtype=int)

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

print(dp[N-1])

Buggy python submission (verdict: Runtime Error):
import numpy as np

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

H = np.array(list(map(int, input().split())))

dp = np.zero(N, dtype=int)

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

print(dp[N-1])

Fixed submission:
import numpy as np

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

H = np.array(list(map(int, input().split())))

dp = np.zeros(N, dtype=int)

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

print(dp[N-1])

Buggy python submission (verdict: Runtime Error):
import numpy as np

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

H = np.array(map(int, input().split()))

dp = np.zero(N, dtype=int)

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

print(dp[N-1])

Fixed submission:
import numpy as np

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

H = np.array(list(map(int, input().split())))

dp = np.zeros(N, dtype=int)

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

print(dp[N-1])

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

H = list(map(int, input().split()))

dp = [float("inf")]*N
dp[0] = 0

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

print(dp[N-1])

Fixed submission:
import numpy as np

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

H = np.array(list(map(int, input().split())))

dp = np.zeros(N, dtype=int)

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

print(dp[N-1])

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

H = list(map(int, input().split()))

dp = [float("inf")]*N
dp[0] = 0

for i in range(N):
    for j in range(i+1, N):
        if i+j <= N:
            dp[i+j] = min(dp[i]+abs(H[i+j]-H[i]), dp[i+j])

print(dp[N-1])

Fixed submission:
import numpy as np

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

H = np.array(list(map(int, input().split())))

dp = np.zeros(N, dtype=int)

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

print(dp[N-1])