Buggy python submission (verdict: Time Limit Exceeded):
N,K=list(map(int,input().split()))
dp_list=[10**10]*(N+K)
h=list(map(int,input().split()))
for _ in range(K):h.append(0)
dp_list[0]=0
for i in range(N):
    for j in range(i+1,min((i+K+1),N)):
        dp_list[j]=min(dp_list[j],abs(h[j]-h[i])+dp_list[i])
print(dp_list[N-1])

Fixed submission:
import numpy as np
N,K=list(map(int,input().split()))
dp_list=np.full(N,10**10,dtype=int)
h=list(map(int,input().split()))
h=np.array(h)
dp_list[0]=0
for i in range(1,N):
        dp_list[i:i+K] = np.fmin(dp_list[i:i+K], dp_list[i-1] + np.abs(h[i:i+K] - h[i-1]))
print(dp_list[-1])

Buggy python submission (verdict: Time Limit Exceeded):
N,K=list(map(int,input().split()))
dp_list=[10**10]*(N+K)
h=list(map(int,input().split()))
for _ in range(K):h.append(0)
dp_list[0]=0
for i in range(N):
    for j in range(1,K+1):
        k=i+j
        dp_list[k]=min(dp_list[k],abs(h[k]-h[i])+dp_list[i])
print(dp_list[N-1])

Fixed submission:
import numpy as np
N,K=list(map(int,input().split()))
dp_list=np.full(N,10**10,dtype=int)
h=list(map(int,input().split()))
h=np.array(h)
dp_list[0]=0
for i in range(1,N):
        dp_list[i:i+K] = np.fmin(dp_list[i:i+K], dp_list[i-1] + np.abs(h[i:i+K] - h[i-1]))
print(dp_list[-1])

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

Fixed submission:
import numpy as np
N,K=list(map(int,input().split()))
dp_list=np.full(N,10**10,dtype=int)
h=list(map(int,input().split()))
h=np.array(h)
dp_list[0]=0
for i in range(1,N):
        dp_list[i:i+K] = np.fmin(dp_list[i:i+K], dp_list[i-1] + np.abs(h[i:i+K] - h[i-1]))
print(dp_list[-1])

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

Fixed submission:
import numpy as np
N,K=list(map(int,input().split()))
dp_list=np.full(N,10**10,dtype=int)
h=list(map(int,input().split()))
h=np.array(h)
dp_list[0]=0
for i in range(1,N):
        dp_list[i:i+K] = np.fmin(dp_list[i:i+K], dp_list[i-1] + np.abs(h[i:i+K] - h[i-1]))
print(dp_list[-1])

Buggy python submission (verdict: Time Limit Exceeded):
N,K=list(map(int,input().split()))
dp_list=[10**10]*110000
h=list(map(int,input().split()))
for _ in range(K):h.append(0)
dp_list[0]=0
for i in range(N):
    for j in range(1,K+1):
        k=i+j
        dp_list[k]=min(dp_list[k],abs(h[k]-h[i])+dp_list[i])
print(dp_list[N-1])

Fixed submission:
import numpy as np
N,K=list(map(int,input().split()))
dp_list=np.full(N,10**10,dtype=int)
h=list(map(int,input().split()))
h=np.array(h)
dp_list[0]=0
for i in range(1,N):
        dp_list[i:i+K] = np.fmin(dp_list[i:i+K], dp_list[i-1] + np.abs(h[i:i+K] - h[i-1]))
print(dp_list[-1])

Buggy python submission (verdict: Time Limit Exceeded):
N,K=list(map(int,input().split()))
dp_list=[10**10]*110000
h=list(map(int,input().split()))
dp_list[0]=0
for i in range(N):
    for j in range(1,K+1):
        k=i+j
        if k<N:
            # if dp_list[j] is None:dp_list[j]=abs(h[j]-h[i])+dp_list[i]
            dp_list[k]=min(dp_list[k],abs(h[k]-h[i])+dp_list[i])
        else:break
print(dp_list[N-1])

Fixed submission:
import numpy as np
N,K=list(map(int,input().split()))
dp_list=np.full(N,10**10,dtype=int)
h=list(map(int,input().split()))
h=np.array(h)
dp_list[0]=0
for i in range(1,N):
        dp_list[i:i+K] = np.fmin(dp_list[i:i+K], dp_list[i-1] + np.abs(h[i:i+K] - h[i-1]))
print(dp_list[-1])

Buggy python submission (verdict: Time Limit Exceeded):
N,K=list(map(int,input().split()))
dp_list=[10**10]*110000
h=[0]*110000
hh=list(map(int,input().split()))
for i in range(len(hh)):
    h[i]=hh[i]
dp_list[0]=0
for i in range(N):
    for j in range(1,K+1):
        k=i+j
        dp_list[k]=min(dp_list[k],abs(h[k]-h[i])+dp_list[i])
print(dp_list[N-1])



Fixed submission:
import numpy as np
N,K=list(map(int,input().split()))
dp_list=np.full(N,10**10,dtype=int)
h=list(map(int,input().split()))
h=np.array(h)
dp_list[0]=0
for i in range(1,N):
        dp_list[i:i+K] = np.fmin(dp_list[i:i+K], dp_list[i-1] + np.abs(h[i:i+K] - h[i-1]))
print(dp_list[-1])

Buggy python submission (verdict: Time Limit Exceeded):
N,K=list(map(int,input().split()))
dp_list=[10**10]*110000
h=list(map(int,input().split()))
dp_list[0]=0
for i in range(N):
    for j in range(1,K+1):
        k=i+j
        if k<N:
            # if dp_list[j] is None:dp_list[j]=abs(h[j]-h[i])+dp_list[i]
            dp_list[k]=min(dp_list[k],abs(h[k]-h[i])+dp_list[i])
print(dp_list[N-1])



Fixed submission:
import numpy as np
N,K=list(map(int,input().split()))
dp_list=np.full(N,10**10,dtype=int)
h=list(map(int,input().split()))
h=np.array(h)
dp_list[0]=0
for i in range(1,N):
        dp_list[i:i+K] = np.fmin(dp_list[i:i+K], dp_list[i-1] + np.abs(h[i:i+K] - h[i-1]))
print(dp_list[-1])

Buggy python submission (verdict: Time Limit Exceeded):
N,K=list(map(int,input().split()))
dp_list=[10**10]*N
h=list(map(int,input().split()))
dp_list[0]=0
for i in range(N):
    for j in range(1,K+1):
        j=i+j
        if j<N:
            # if dp_list[j] is None:dp_list[j]=abs(h[j]-h[i])+dp_list[i]
            dp_list[j]=min(dp_list[j],abs(h[j]-h[i])+dp_list[i])
print(dp_list[-1])



Fixed submission:
import numpy as np
N,K=list(map(int,input().split()))
dp_list=np.full(N,10**10,dtype=int)
h=list(map(int,input().split()))
h=np.array(h)
dp_list[0]=0
for i in range(1,N):
        dp_list[i:i+K] = np.fmin(dp_list[i:i+K], dp_list[i-1] + np.abs(h[i:i+K] - h[i-1]))
print(dp_list[-1])

Buggy python submission (verdict: Time Limit Exceeded):
N,K=list(map(int,input().split()))
dp_list=[None]*N
h=list(map(int,input().split()))
dp_list[0]=0
for i in range(N):
    for j in range(1,K+1):
        j=i+j
        if j<N:
            if dp_list[j] is None:dp_list[j]=abs(h[j]-h[i])+dp_list[i]
            else:dp_list[j]=min(dp_list[j],abs(h[j]-h[i])+dp_list[i])
print(dp_list[-1])



Fixed submission:
import numpy as np
N,K=list(map(int,input().split()))
dp_list=np.full(N,10**10,dtype=int)
h=list(map(int,input().split()))
h=np.array(h)
dp_list[0]=0
for i in range(1,N):
        dp_list[i:i+K] = np.fmin(dp_list[i:i+K], dp_list[i-1] + np.abs(h[i:i+K] - h[i-1]))
print(dp_list[-1])

Buggy python submission (verdict: Time Limit Exceeded):
N,K=list(map(int,input().split()))
dp_list=[None]*N
h=list(map(int,input().split()))
dp_list[0]=0
for i in range(0,N):
    for j in range(1,K+1):
        j=i+j
        if j<N:
            if dp_list[j] is None:dp_list[j]=abs(h[j]-h[i])+dp_list[i]
            else:dp_list[j]=min(dp_list[j],abs(h[j]-h[i])+dp_list[i])
print(dp_list[-1])



Fixed submission:
import numpy as np
N,K=list(map(int,input().split()))
dp_list=np.full(N,10**10,dtype=int)
h=list(map(int,input().split()))
h=np.array(h)
dp_list[0]=0
for i in range(1,N):
        dp_list[i:i+K] = np.fmin(dp_list[i:i+K], dp_list[i-1] + np.abs(h[i:i+K] - h[i-1]))
print(dp_list[-1])