Buggy python submission (verdict: Runtime Error):
from numba import jit

@jit
def solve(n, k, arr):
    INF = 1 << 60
    dp = [INF] * (n + 1000)

    dp[1] = 0

    for i in range(1, n):
        for k in range(1, k + 1):
            dp[i + k] = min(dp[i + k], dp[i] + abs(arr[i + k] - arr[i]))

    return dp[n]


n, k = map(int, input().split())
arr = [0] + list(map(int, input().split())) + [0] * 1000

print(solve(n, k, arr))

Fixed submission:
n, k = map(int, input().split())
arr = list(map(int, input().split()))

# dp初期化
dp = [float("inf")] * n
dp[0] = 0

for i in range(1, n):
    dp[i] = min(dp[j] + abs(arr[i] - arr[j]) for j in range(max(i - k, 0), i))

print(dp[n - 1])

Buggy python submission (verdict: Runtime Error):
from numba import jit


@jit
def solve(n, k, arr):
    INF = 1 << 60
    dp = [INF] * (n + 1000)

    dp[1] = 0

    for i in range(1, n):
        for k in range(1, k + 1):
            dp[i + k] = min(dp[i + k], dp[i] + abs(arr[i + k] - arr[i]))

    return dp[n]


n, k = map(int, input().split())
arr = [0] + list(map(int, input().split())) + [0] * 1000

print(solve(n, k, arr))

Fixed submission:
n, k = map(int, input().split())
arr = list(map(int, input().split()))

# dp初期化
dp = [float("inf")] * n
dp[0] = 0

for i in range(1, n):
    dp[i] = min(dp[j] + abs(arr[i] - arr[j]) for j in range(max(i - k, 0), i))

print(dp[n - 1])

Buggy python submission (verdict: Runtime Error):
from numba import njit


@njit(cache=True)
def solve(n, k, arr):
    INF = 1 << 60
    dp = [INF] * (n + 1000)

    dp[1] = 0

    for i in range(1, n):
        for k in range(1, k + 1):
            dp[i + k] = min(dp[i + k], dp[i] + abs(arr[i + k] - arr[i]))

    return dp[n]


n, k = map(int, input().split())
arr = [0] + list(map(int, input().split())) + [0] * 1000

print(solve(n, k, arr))

Fixed submission:
n, k = map(int, input().split())
arr = list(map(int, input().split()))

# dp初期化
dp = [float("inf")] * n
dp[0] = 0

for i in range(1, n):
    dp[i] = min(dp[j] + abs(arr[i] - arr[j]) for j in range(max(i - k, 0), i))

print(dp[n - 1])

Buggy python submission (verdict: Runtime Error):
from numba import jit

n, k = map(int, input().split())
arr = [0] + list(map(int, input().split())) + [0] * 1000


@jit
def solve(n, k, arr):
    INF = 1 << 60
    dp = [INF] * (n + 1000)
    dp[1] = 0

    for i in range(1, n):
        for k in range(1, k + 1):
            dp[i + k] = min(dp[i + k], dp[i] + abs(arr[i + k] - arr[i]))

    return dp[n]


print(solve(n, k, arr))

Fixed submission:
n, k = map(int, input().split())
arr = list(map(int, input().split()))

# dp初期化
dp = [float("inf")] * n
dp[0] = 0

for i in range(1, n):
    dp[i] = min(dp[j] + abs(arr[i] - arr[j]) for j in range(max(i - k, 0), i))

print(dp[n - 1])

Buggy python submission (verdict: Runtime Error):
from numba import njit

n, k = map(int, input().split())
arr = [0] + list(map(int, input().split())) + [0] * 1000


@njit
def solve(n, k, arr):
    INF = 1 << 60
    dp = [INF] * (n + 1000)
    dp[1] = 0

    for i in range(1, n):
        for k in range(1, k + 1):
            dp[i + k] = min(dp[i + k], dp[i] + abs(arr[i + k] - arr[i]))

    return dp[n]


print(solve(n, k, arr))

Fixed submission:
n, k = map(int, input().split())
arr = list(map(int, input().split()))

# dp初期化
dp = [float("inf")] * n
dp[0] = 0

for i in range(1, n):
    dp[i] = min(dp[j] + abs(arr[i] - arr[j]) for j in range(max(i - k, 0), i))

print(dp[n - 1])

Buggy python submission (verdict: Runtime Error):
from numba import jit, f8, i8, b1, void

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


@jit(i8(i8[:]))
def solve(arr):
    INF = 1 << 40

    # dp初期化
    dp = [INF] * n
    dp[0] = 0

    for i in range(1, n):
        dp[i] = min(dp[j] + abs(arr[i] - arr[j])
                    for j in range(max(i - k, 0), i))

    return dp([n - 1])


print(solve(arr))

Fixed submission:
n, k = map(int, input().split())
arr = list(map(int, input().split()))

# dp初期化
dp = [float("inf")] * n
dp[0] = 0

for i in range(1, n):
    dp[i] = min(dp[j] + abs(arr[i] - arr[j]) for j in range(max(i - k, 0), i))

print(dp[n - 1])

Buggy python submission (verdict: Runtime Error):
from numba import njit

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


@njit
def main():
    INF = 1 << 40

    # dp初期化
    dp = [INF] * n
    dp[0] = 0

    for i in range(1, n):
        dp[i] = min(dp[j] + abs(arr[i] - arr[j])
                    for j in range(max(i - k, 0), i))

    print(dp[n - 1])

Fixed submission:
n, k = map(int, input().split())
arr = list(map(int, input().split()))

# dp初期化
dp = [float("inf")] * n
dp[0] = 0

for i in range(1, n):
    dp[i] = min(dp[j] + abs(arr[i] - arr[j]) for j in range(max(i - k, 0), i))

print(dp[n - 1])

Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
arr = [0] + list(map(int, input().split())) + [0] * 1000

INF = 1 << 60
dp = [INF] * (n + 1000)

dp[1] = 0

for i in range(1, n):
    for k in range(1, k + 1):
        dp[i + k] = min(dp[i + k], dp[i] + abs(arr[i + k] - arr[i]))

print(dp[n])

Fixed submission:
n, k = map(int, input().split())
arr = list(map(int, input().split()))

# dp初期化
dp = [float("inf")] * n
dp[0] = 0

for i in range(1, n):
    dp[i] = min(dp[j] + abs(arr[i] - arr[j]) for j in range(max(i - k, 0), i))

print(dp[n - 1])

Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
arr = list(map(int, input().split()))

INF = 1 << 40

# dp初期化
dp = [INF] * n
dp[0] = 0

for i in range(1, n):
    dp[i] = min(dp[j] + abs(arr[i] - arr[j]) for j in range(max(i - k, 0), i))

print(dp[n - 1])

Fixed submission:
n, k = map(int, input().split())
arr = list(map(int, input().split()))

# dp初期化
dp = [float("inf")] * n
dp[0] = 0

for i in range(1, n):
    dp[i] = min(dp[j] + abs(arr[i] - arr[j]) for j in range(max(i - k, 0), i))

print(dp[n - 1])

Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
arr = list(map(int, input().split()))

# dp初期化
dp = [float("inf")] * n
dp[0] = 0

for i in range(1, n):
    dp[i] = min(dp[j] + abs(arr[i] - arr[j]) for j in range(max(i - k, 0), i))

print(dp[n - 1])

Fixed submission:
n, k = map(int, input().split())
arr = list(map(int, input().split()))

# dp初期化
dp = [float("inf")] * n
dp[0] = 0

for i in range(1, n):
    dp[i] = min(dp[j] + abs(arr[i] - arr[j]) for j in range(max(i - k, 0), i))

print(dp[n - 1])

Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
arr = list(map(int, input().split()))

# dp初期化
dp = [float("inf")] * n
dp[0] = 0

for i in range(1, n):
    dp[i] = min(dp[j] + abs(arr[i] - arr[j]) for j in range(max(i - k, 0), i))

print(dp[n - 1])

Fixed submission:
n, k = map(int, input().split())
arr = list(map(int, input().split()))

# dp初期化
dp = [float("inf")] * n
dp[0] = 0

for i in range(1, n):
    dp[i] = min(dp[j] + abs(arr[i] - arr[j]) for j in range(max(i - k, 0), i))

print(dp[n - 1])

Buggy python submission (verdict: Runtime Error):
import numpy as np
 
n, k = map(int, input().split())
arr = list(map(int, input().split())) + [0] * k
 
INF = 1 << 60
 
# dp初期化
dp = [INF] * (n + k)
dp[0] = 0
 
for i in range(n):
    for j in range(1, k + 1):
        dp[i + j] = min(dp[i + j], dp[i] + abs(arr[i + j] - arr[i]))
 
print(dp[n - 1])

Fixed submission:
n, k = map(int, input().split())
arr = list(map(int, input().split()))

# dp初期化
dp = [float("inf")] * n
dp[0] = 0

for i in range(1, n):
    dp[i] = min(dp[j] + abs(arr[i] - arr[j]) for j in range(max(i - k, 0), i))

print(dp[n - 1])

Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
arr = list(map(int, input().split()))

# dp初期化
dp = [float("inf")] * n
dp[0] = 0

for i in range(1, n):
    dp[i] = min(dp[j] + abs(arr[i] - arr[j]) for j in range(max(i - k, 0), i))

print(dp[n - 1])

Fixed submission:
n, k = map(int, input().split())
arr = list(map(int, input().split()))

# dp初期化
dp = [float("inf")] * n
dp[0] = 0

for i in range(1, n):
    dp[i] = min(dp[j] + abs(arr[i] - arr[j]) for j in range(max(i - k, 0), i))

print(dp[n - 1])

Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
arr = list(map(int, input().split()))

# dp初期化
dp = [float("inf")] * n
dp[0] = 0

for i in range(1, n):
    dp[i] = min(dp[j] + abs(arr[i] - arr[j]) for j in range(max(i - k, 0), i))

print(dp[n - 1])

Fixed submission:
n, k = map(int, input().split())
arr = list(map(int, input().split()))

# dp初期化
dp = [float("inf")] * n
dp[0] = 0

for i in range(1, n):
    dp[i] = min(dp[j] + abs(arr[i] - arr[j]) for j in range(max(i - k, 0), i))

print(dp[n - 1])

Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
arr = list(map(int, input().split()))

INF = 1 << 30

# dp初期化
dp = [INF] * n
dp[0] = 0

for i in range(1, n):
    dp[i] = min(dp[j] + abs(arr[i] - arr[j]) for j in range(max(i - k, 0), i))

print(dp[n - 1])

Fixed submission:
n, k = map(int, input().split())
arr = list(map(int, input().split()))

# dp初期化
dp = [float("inf")] * n
dp[0] = 0

for i in range(1, n):
    dp[i] = min(dp[j] + abs(arr[i] - arr[j]) for j in range(max(i - k, 0), i))

print(dp[n - 1])

Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
arr = list(map(int, input().split())) + [0] * k

INF = 1 << 60

# dp初期化
dp = [INF] * (n + k)
dp[0] = 0

for i in range(1, n):
    dp[i] = min(dp[j] + abs(arr[i] - arr[j]) for j in range(max(i - k, 0), i))


print(dp[n - 1])

Fixed submission:
n, k = map(int, input().split())
arr = list(map(int, input().split()))

# dp初期化
dp = [float("inf")] * n
dp[0] = 0

for i in range(1, n):
    dp[i] = min(dp[j] + abs(arr[i] - arr[j]) for j in range(max(i - k, 0), i))

print(dp[n - 1])

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

n, k = map(int, input().split())
arr = list(map(int, input().split())) + [0] * k

INF = 1 << 60

# dp初期化
dp = [INF] * (n + k)
dp[0] = 0

for i in range(n):
    for j in range(1, k + 1):
        dp[i + j] = min(dp[i + j], dp[i] + abs(arr[i + j] - arr[i]))

print(dp[n - 1])

Fixed submission:
n, k = map(int, input().split())
arr = list(map(int, input().split()))

# dp初期化
dp = [float("inf")] * n
dp[0] = 0

for i in range(1, n):
    dp[i] = min(dp[j] + abs(arr[i] - arr[j]) for j in range(max(i - k, 0), i))

print(dp[n - 1])

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

n, k = map(int, input().split())
arr = np.concatenate(
    [np.array(list(map(int, input().split()))), np.zeros(k, dtype=int)])

INF = 1 << 60

# dp初期化
dp = np.full(n + k, INF, dtype=int)
dp[0] = 0

for i in range(n):
    for j in range(1, k + 1):
        dp[i + j] = min(dp[i + j], dp[i] + np.abs(arr[i + j] - arr[i]))

print(dp[n - 1])

Fixed submission:
n, k = map(int, input().split())
arr = list(map(int, input().split()))

# dp初期化
dp = [float("inf")] * n
dp[0] = 0

for i in range(1, n):
    dp[i] = min(dp[j] + abs(arr[i] - arr[j]) for j in range(max(i - k, 0), i))

print(dp[n - 1])

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

n, k = map(int, input().split())
arr = np.concatenate(
    [np.array(list(map(int, input().split()))), np.zeros(k, dtype=int)])

INF = 1 << 20

# dp初期化
dp = np.full([k, n + k], INF, dtype=int)
for i in range(k):
    dp[i, i + 1] = np.abs(arr[i + 1] - arr[0])

for i in range(1, n):
    for j in range(1, k + 1):
        dp[j - 1, i + j] = dp[:, i].min() + np.abs(arr[i + j] - arr[i])

print(dp[:, n - 1].min())

Fixed submission:
n, k = map(int, input().split())
arr = list(map(int, input().split()))

# dp初期化
dp = [float("inf")] * n
dp[0] = 0

for i in range(1, n):
    dp[i] = min(dp[j] + abs(arr[i] - arr[j]) for j in range(max(i - k, 0), i))

print(dp[n - 1])

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

n, k = map(int, input().split())
arr = np.concatenate(
    [np.array(list(map(int, input().split()))), np.zeros(k, dtype=int)])

INF = 1 << 60

# dp初期化
dp = np.full([k, n + k], INF, dtype=int)
for i in range(k):
    dp[i, i + 1] = np.abs(arr[i + 1] - arr[0])

for i in range(1, n):
    for j in range(1, k + 1):
        dp[j - 1, i + j] = dp[:, i].min() + np.abs(arr[i + j] - arr[i])

print(dp[:, n - 1].min())

Fixed submission:
n, k = map(int, input().split())
arr = list(map(int, input().split()))

# dp初期化
dp = [float("inf")] * n
dp[0] = 0

for i in range(1, n):
    dp[i] = min(dp[j] + abs(arr[i] - arr[j]) for j in range(max(i - k, 0), i))

print(dp[n - 1])