Buggy python submission (verdict: Time Limit Exceeded):
import sys
sys.setrecursionlimit(100000) 
n,k = list(map(int,input().split()))
l = list(map(int,input().split()))
A = [0]*(n)
if k >= n:
    k = n
for i in range(1,k):
    A[i] = abs(l[i]-l[0])
for i in range(k,n):
    tmp = float('Inf')
    for j in range(1,k+1):
        dis = A[i-j] + abs(l[i]-l[i-j])
        tmp = min(tmp,dis)
    A[i] = tmp
print(A[n-1])


Fixed submission:
import sys
sys.setrecursionlimit(100000) 
n,k = list(map(int,input().split()))
l = list(map(int,input().split()))
A = [0]*(n)
if k >= n:
    k = n
for i in range(1,k):
    A[i] = abs(l[i]-l[0])
for i in range(k,n):
    tmp = float('Inf')
    for j in range(1,k+1):
        dis = A[i-j] + abs(l[i]-l[i-j])
        tmp = min(tmp,dis)
    A[i] = tmp
print(A[n-1])

Buggy python submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(100000) 
n,k = list(map(int,input().split()))
l = list(map(int,input().split()))
A = [0]*(n)
if k >= n:
    k = n
for i in range(1,k+1):
    A[i] = abs(l[i]-l[0])
for i in range(k,n):
    tmp = float('Inf')
    for j in range(1,k+1):
        dis = A[i-j] + abs(l[i]-l[i-j])
        tmp = min(tmp,dis)
    A[i] = tmp
print(A[n-1])

Fixed submission:
import sys
sys.setrecursionlimit(100000) 
n,k = list(map(int,input().split()))
l = list(map(int,input().split()))
A = [0]*(n)
if k >= n:
    k = n
for i in range(1,k):
    A[i] = abs(l[i]-l[0])
for i in range(k,n):
    tmp = float('Inf')
    for j in range(1,k+1):
        dis = A[i-j] + abs(l[i]-l[i-j])
        tmp = min(tmp,dis)
    A[i] = tmp
print(A[n-1])

Buggy python submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(100000) 
n,k = list(map(int,input().split()))
l = list(map(int,input().split()))
A = [0]*(n)
for i in range(1,k+1):
    A[i] = abs(l[i]-l[0])
for i in range(k,n):
    tmp = float('Inf')
    for j in range(1,k+1):
        dis = A[i-j] + abs(l[i]-l[i-j])
        tmp = min(tmp,dis)
    A[i] = tmp
print(A[n-1])

Fixed submission:
import sys
sys.setrecursionlimit(100000) 
n,k = list(map(int,input().split()))
l = list(map(int,input().split()))
A = [0]*(n)
if k >= n:
    k = n
for i in range(1,k):
    A[i] = abs(l[i]-l[0])
for i in range(k,n):
    tmp = float('Inf')
    for j in range(1,k+1):
        dis = A[i-j] + abs(l[i]-l[i-j])
        tmp = min(tmp,dis)
    A[i] = tmp
print(A[n-1])

Buggy python submission (verdict: Runtime Error):
n,k = list(map(int,input().split()))
l = list(map(int,input().split()))
A = [0]*(n)
for i in range(1,k+1):
    A[i] = abs(l[i]-l[0])
for i in range(k,n):
    tmp = float('Inf')
    for j in range(1,k+1):
        dis = A[i-j] + abs(l[i]-l[i-j])
        tmp = min(tmp,dis)
    A[i] = tmp
print(A[n-1])

Fixed submission:
import sys
sys.setrecursionlimit(100000) 
n,k = list(map(int,input().split()))
l = list(map(int,input().split()))
A = [0]*(n)
if k >= n:
    k = n
for i in range(1,k):
    A[i] = abs(l[i]-l[0])
for i in range(k,n):
    tmp = float('Inf')
    for j in range(1,k+1):
        dis = A[i-j] + abs(l[i]-l[i-j])
        tmp = min(tmp,dis)
    A[i] = tmp
print(A[n-1])

Buggy python submission (verdict: Runtime Error):
n,k = list(map(int,input().split()))
l = list(map(int,input().split()))
A = [0]*(n)
for i in range(1,k+1):
    A[i] = abs(l[i]-l[0])
for i in range(k,n):
    tmp = float('Inf')
    for j in range(1,k+1):
        dis = A[i-j] + abs(l[i]-l[i-j])
        tmp = min(tmp,dis)
    A[i] = tmp
print(A[n-1])

Fixed submission:
import sys
sys.setrecursionlimit(100000) 
n,k = list(map(int,input().split()))
l = list(map(int,input().split()))
A = [0]*(n)
if k >= n:
    k = n
for i in range(1,k):
    A[i] = abs(l[i]-l[0])
for i in range(k,n):
    tmp = float('Inf')
    for j in range(1,k+1):
        dis = A[i-j] + abs(l[i]-l[i-j])
        tmp = min(tmp,dis)
    A[i] = tmp
print(A[n-1])