Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline
H, K = map(int, input().split())
lst_0=list(map(int,input().split()))
DP=[float("INF")]*H
DP[0]=0
for i in range(1,H):
    for j in range(1,K+1):
        if i - j >= 0:
            DP[i]=min(DP[i],abs(lst_0[i]-lst_0[i-j])+DP[i-j])
print(DP[H-1])

Fixed submission:
import sys
input = sys.stdin.readline
H, K = map(int, input().split())
lst_0=list(map(int,input().split()))
DP=[float("INF")]*H
DP[0]=0
for i in range(1,H):
    for j in range(1,K+1):
        if i - j >= 0:
            DP[i]=min(DP[i],abs(lst_0[i]-lst_0[i-j])+DP[i-j])
print(DP[H-1])

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline
H, K = map(int, input().split())
lst_0=list(map(int,input().split()))
DP=[float("INF")]*H
DP[0]=0
lst_2=[]
for i in range(1,H):
    lst_1=[]
    for j in range(1,K+1):
        if i - j >= 0:
            DP[i]=abs(lst_0[i]-lst_0[i-j])+DP[i-j]
            lst_1.append(DP[i])
    DP[i]=min(lst_1)
print(DP[-1])

Fixed submission:
import sys
input = sys.stdin.readline
H, K = map(int, input().split())
lst_0=list(map(int,input().split()))
DP=[float("INF")]*H
DP[0]=0
for i in range(1,H):
    for j in range(1,K+1):
        if i - j >= 0:
            DP[i]=min(DP[i],abs(lst_0[i]-lst_0[i-j])+DP[i-j])
print(DP[H-1])

Buggy python submission (verdict: Time Limit Exceeded):
H,K=map(int,input().split())
lst_0=list(map(int,input().split()))
DP=[float("INF")]*H
DP[0]=0
lst_2=[]
for i in range(1,H):
    lst_1=[]
    for j in range(1,K+1):
        if i - j >= 0:
            DP[i]=abs(lst_0[i]-lst_0[i-j])+DP[i-j]
            lst_1.append(DP[i])
    DP[i]=min(lst_1)
print(DP[-1])

Fixed submission:
import sys
input = sys.stdin.readline
H, K = map(int, input().split())
lst_0=list(map(int,input().split()))
DP=[float("INF")]*H
DP[0]=0
for i in range(1,H):
    for j in range(1,K+1):
        if i - j >= 0:
            DP[i]=min(DP[i],abs(lst_0[i]-lst_0[i-j])+DP[i-j])
print(DP[H-1])

Buggy python submission (verdict: Runtime Error):
H,K=map(int,input().split())
lst_0=list(map(int,input().split()))
DP[0]=0
lst_2=[]
for i in range(1,H):
    lst_1=[]
    for j in range(1,K+1):
        if i - j >= 0:
            DP[i]=abs(lst_0[i]-lst_0[i-j])+DP[i-j]
            lst_1.append(DP[i])
    DP[i]=min(lst_1)
print(DP[-1])

Fixed submission:
import sys
input = sys.stdin.readline
H, K = map(int, input().split())
lst_0=list(map(int,input().split()))
DP=[float("INF")]*H
DP[0]=0
for i in range(1,H):
    for j in range(1,K+1):
        if i - j >= 0:
            DP[i]=min(DP[i],abs(lst_0[i]-lst_0[i-j])+DP[i-j])
print(DP[H-1])

Buggy python submission (verdict: Runtime Error):
H,K=map(int,input().split())
lst_0=list(map(int,input().split()))
DP[0]=0
lst_2=[]
for i in range(1,H):
    lst_1=[]
    for j in range(1,K+1):
        if i - j >= 0:
            DP[i]=abs(lst_0[i]-lst_0[i-j])+DP[i-j]
            lst_1.append(DP[i])
    DP[i]=min(lst_1)
print(DP[-1])

Fixed submission:
import sys
input = sys.stdin.readline
H, K = map(int, input().split())
lst_0=list(map(int,input().split()))
DP=[float("INF")]*H
DP[0]=0
for i in range(1,H):
    for j in range(1,K+1):
        if i - j >= 0:
            DP[i]=min(DP[i],abs(lst_0[i]-lst_0[i-j])+DP[i-j])
print(DP[H-1])