Buggy python submission (verdict: Runtime Error):
# B - Frog2
import numpy as np

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

dp = [10**9]*(N+K)
dp[0] = 0

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

Fixed submission:
# B - Frog2
import numpy as np

N, K = list(map(int, input().split()))
h = np.array(list(map(int, input().split()))+[0]*K)

dp = np.array([10**9]*(N+K))
dp[0] = 0

for i in range(N):
    dp[i+1:i+K+1] = np.minimum(dp[i+1:i+K+1], dp[i]+abs(h[i+1:i+K+1]-h[i]))
print(dp[N-1])

Buggy python submission (verdict: Runtime Error):
# B - Frog2
import numpy as np

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

dp = [10**9]*(N+K)
dp[0] = 0

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

Fixed submission:
# B - Frog2
import numpy as np

N, K = list(map(int, input().split()))
h = np.array(list(map(int, input().split()))+[0]*K)

dp = np.array([10**9]*(N+K))
dp[0] = 0

for i in range(N):
    dp[i+1:i+K+1] = np.minimum(dp[i+1:i+K+1], dp[i]+abs(h[i+1:i+K+1]-h[i]))
print(dp[N-1])

Buggy python submission (verdict: Runtime Error):
# B - Frog2
import numpy as np

N, K = list(map(int, input().split()))
h = list(map(int, input().split()))
dp = [10**9]*N

dp[0] = 0

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

Fixed submission:
# B - Frog2
import numpy as np

N, K = list(map(int, input().split()))
h = np.array(list(map(int, input().split()))+[0]*K)

dp = np.array([10**9]*(N+K))
dp[0] = 0

for i in range(N):
    dp[i+1:i+K+1] = np.minimum(dp[i+1:i+K+1], dp[i]+abs(h[i+1:i+K+1]-h[i]))
print(dp[N-1])

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

dp = [10 ** 9 for i in range(N + K)]
dp[0] = 0
for i in range(N):
    for j in range(1, K + 1):
        if i + j < N:
            dp[i + j] = min(dp[i + j], dp[i] + abs(h[i] - h[i + j]))

print(dp[N - 1])


Fixed submission:
# B - Frog2
import numpy as np

N, K = list(map(int, input().split()))
h = np.array(list(map(int, input().split()))+[0]*K)

dp = np.array([10**9]*(N+K))
dp[0] = 0

for i in range(N):
    dp[i+1:i+K+1] = np.minimum(dp[i+1:i+K+1], dp[i]+abs(h[i+1:i+K+1]-h[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 = [10 ** 9 for i in range(N + K)]
dp[0] = 0
for i in range(N):
    for j in range(1, K + 1):
        if i + j < N:
            dp[i + j] = min(dp[i + j], dp[i] + abs(h[i] - h[i + j]))
        
print(dp[N - 1])

Fixed submission:
# B - Frog2
import numpy as np

N, K = list(map(int, input().split()))
h = np.array(list(map(int, input().split()))+[0]*K)

dp = np.array([10**9]*(N+K))
dp[0] = 0

for i in range(N):
    dp[i+1:i+K+1] = np.minimum(dp[i+1:i+K+1], dp[i]+abs(h[i+1:i+K+1]-h[i]))
print(dp[N-1])

Buggy python submission (verdict: Runtime Error):
    N, K = map(int, input().split())
    h = list(map(int, input().split()))
     
    dp = [10 ** 9 for i in range(N + K)]
    dp[0] = 0
    for i in range(N):
        for j in range(1, K + 1):
            if i + j < N:
                dp[i + j] = min(dp[i + j], dp[i] + abs(h[i] - h[i + j]))
     
    print(dp[N - 1])

Fixed submission:
# B - Frog2
import numpy as np

N, K = list(map(int, input().split()))
h = np.array(list(map(int, input().split()))+[0]*K)

dp = np.array([10**9]*(N+K))
dp[0] = 0

for i in range(N):
    dp[i+1:i+K+1] = np.minimum(dp[i+1:i+K+1], dp[i]+abs(h[i+1:i+K+1]-h[i]))
print(dp[N-1])

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

N, K = list(map(int, input().split()))
h = list(map(int, input().split()))
dp = [10**9]*N

dp[0] = 0

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

Fixed submission:
# B - Frog2
import numpy as np

N, K = list(map(int, input().split()))
h = np.array(list(map(int, input().split()))+[0]*K)

dp = np.array([10**9]*(N+K))
dp[0] = 0

for i in range(N):
    dp[i+1:i+K+1] = np.minimum(dp[i+1:i+K+1], dp[i]+abs(h[i+1:i+K+1]-h[i]))
print(dp[N-1])