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

def retmin(a, b):
    if a > b:
        return b
    return a

input = sys.stdin.readline

# N 足場の数、K カエルができる行動
n, k = map(int, input().split())

# H 各足場の高さ
# h = list(map(int, input().split()))
h = [int(i) for i in input().split()]

# 初期化
# dp = np.full(100100, 1000000000)
dp = [999999999999 for i in range(100100)]
dp[0] = 0

for i in range(n):
    for j in range(k):
        if (i + j < n):
            c = abs(h[i+j]-h[i-1]) + dp[i-1]
            if (dp[i+j] > c):
                dp[i+j]  = c
print(int(dp[n-1]))

Fixed submission:
import sys
import numpy as np

input = sys.stdin.readline

n, k = map(int, input().split())

h = np.array([int(x) for x in 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):
import sys
import numpy as np

def retmin(a, b):
    if a > b:
        return b
    return a

input = sys.stdin.readline

# N 足場の数、K カエルができる行動
n, k = map(int, input().split())

# H 各足場の高さ
h = list(map(int, input().split()))

# 初期化
# dp = np.full(100100, 1000000000)
dp = [999999999999 for i in range(100100)]
dp[0] = 0

for i in range(n):
    for j in range(k):
        if (i + j < n):
            c = abs(h[i+j]-h[i-1]) + dp[i-1]
            if (dp[i+j] > c):
                dp[i+j]  = c
print(int(dp[n-1]))

Fixed submission:
import sys
import numpy as np

input = sys.stdin.readline

n, k = map(int, input().split())

h = np.array([int(x) for x in 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):
import sys
import numpy as np

def retmin(a, b):
    if a > b:
        return b
    return a

# N 足場の数、K カエルができる行動
n, k = map(int, input().split())

# H 各足場の高さ
h = list(map(int, input().split()))

# 初期化
# dp = np.full(100100, 1000000000)
dp = [999999999999 for i in range(100100)]
dp[0] = 0

for i in range(n):
    for j in range(k):
        if (i + j < n):
            c = abs(h[i+j]-h[i-1]) + dp[i-1]
            if (dp[i+j] > c):
                dp[i+j]  = c
print(int(dp[n-1]))

Fixed submission:
import sys
import numpy as np

input = sys.stdin.readline

n, k = map(int, input().split())

h = np.array([int(x) for x in 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):
import sys
import numpy as np

def retmin(a, b):
    if a > b:
        return b
    return a

# N 足場の数、K カエルができる行動
n, k = map(int, input().split())

# H 各足場の高さ
h = list(map(int, input().split()))

# 初期化
# dp = np.full(100100, 1000000000)
dp = [999999999999 for i in range(100100)]
dp[0] = 0

for i in range(n):
    for j in range(k):
        if (i + j < n):
            dp[i+j] = retmin(dp[i+j], abs(h[i+j]-h[i-1])+dp[i-1])
print(int(dp[n-1]))

Fixed submission:
import sys
import numpy as np

input = sys.stdin.readline

n, k = map(int, input().split())

h = np.array([int(x) for x in 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):
import sys
import numpy as np

def retmin(a, b):
    if a > b:
        return b
    return a

# N 足場の数、K カエルができる行動
n, k = map(int, input().split())

# H 各足場の高さ
h = list(map(int, input().split()))

# 初期化
dp = np.full(100100, 1000000000)
dp[0] = 0

for i in range(n):
    for j in range(k):
        if (i + j < n):
            dp[i+j] = retmin(dp[i+j], abs(h[i+j]-h[i-1])+dp[i-1])
print(int(dp[n-1]))

Fixed submission:
import sys
import numpy as np

input = sys.stdin.readline

n, k = map(int, input().split())

h = np.array([int(x) for x in 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):
import sys
import numpy as np

def retmin(a, b):
    if a > b:
        return b
    return a

# N 足場の数、K カエルができる行動
n, k = map(int, input().split())

# H 各足場の高さ
h = list(map(int, input().split()))

# 初期化
dp = np.full(100100, 999999999999)
dp[0] = 0

for i in range(n):
    for j in range(k):
        if (i + j < n):
            dp[i+j] = retmin(dp[i+j], abs(h[i+j]-h[i-1])+dp[i-1])
print(int(dp[n-1]))

Fixed submission:
import sys
import numpy as np

input = sys.stdin.readline

n, k = map(int, input().split())

h = np.array([int(x) for x in 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])