Buggy python submission (verdict: Runtime Error):
import numpy as np
import numba
@numba.jit

def frog(N,K):

    h = np.array(list(map(int,input().split())))
    dp=np.array([0 for i in range(N)])
    dp[0]= 0
    dp[1]=abs(h[1]-h[0])
    if N<=K:
        dp[N-1]=abs(h[0]-h[N-1])
    else:  
        for i in range(2,N):
            dp[i]=min(dp[j]+abs(h[i]-h[j]) for j in range(max(0,i-K),i))
            
            #dp[i]=np.min(list1)
             
    print(dp[N-1])

line = np.array(list(map(int,input().split())))
a,b = line[0],line[1]
frog(a,b)

Fixed submission:
import numpy as np
N,K = map(int,input().split())
h = np.array(list(map(int,input().split())))
dp=np.array([0 for i in range(N)])
dp[0]= 0
dp[1]=abs(h[1]-h[0])
if N<=K:
    dp[N-1]=abs(h[0]-h[N-1])
else:  
    for i in range(2,N):
      j=max(0,i-K)
      dp[i]=np.min(dp[j:i]+np.abs(h[i]-h[j:i]))
      #dp[i]=min([dp[i-j]+abs(h[i]-h[i-j]) for j in range(1,min(k+1,i+1))])
print(int(dp[-1]))

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
N,K = map(int,input().split())
h = np.array(list(map(int,input().split())))
dp=np.array([0 for i in range(N)])
dp[0]= 0
dp[1]=abs(h[1]-h[0])
if N<=K:
    dp[N-1]=abs(h[0]-h[N-1])
else:  
    for i in range(2,N):
        dp[i]=min(dp[j]+abs(h[i]-h[j]) for j in range(max(0,i-K),i))
        
        #dp[i]=np.min(list1)
         
print(dp[N-1])

Fixed submission:
import numpy as np
N,K = map(int,input().split())
h = np.array(list(map(int,input().split())))
dp=np.array([0 for i in range(N)])
dp[0]= 0
dp[1]=abs(h[1]-h[0])
if N<=K:
    dp[N-1]=abs(h[0]-h[N-1])
else:  
    for i in range(2,N):
      j=max(0,i-K)
      dp[i]=np.min(dp[j:i]+np.abs(h[i]-h[j:i]))
      #dp[i]=min([dp[i-j]+abs(h[i]-h[i-j]) for j in range(1,min(k+1,i+1))])
print(int(dp[-1]))

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
N,K = map(int,input().split())
h = np.array(list(map(int,input().split())))
dp=np.array([0 for i in range(N)])
dp[0]= 0
if N<=K:
    dp[N-1]=abs(h[0]-h[N-1])
else:   
    for j in range(1,K+1):
        dp[j]= abs(h[0]-h[j])
    
    for i in range(K,N):
        
        
        dp[i]= min(dp[i-k]+abs(h[i-k]-h[i]) for k in range(1,K+1))
        
        #dp[i]=np.min(list1)
         
print(dp[N-1])

Fixed submission:
import numpy as np
N,K = map(int,input().split())
h = np.array(list(map(int,input().split())))
dp=np.array([0 for i in range(N)])
dp[0]= 0
dp[1]=abs(h[1]-h[0])
if N<=K:
    dp[N-1]=abs(h[0]-h[N-1])
else:  
    for i in range(2,N):
      j=max(0,i-K)
      dp[i]=np.min(dp[j:i]+np.abs(h[i]-h[j:i]))
      #dp[i]=min([dp[i-j]+abs(h[i]-h[i-j]) for j in range(1,min(k+1,i+1))])
print(int(dp[-1]))

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
N,K = map(int,input().split())
h = list(map(int,input().split()))
dp=np.array([0 for i in range(N)])
dp[0]= 0
if N<=K:
    dp[N-1]=abs(h[0]-h[N-1])
else:   
    for j in range(1,K+1):
        dp[j]= abs(h[0]-h[j])
    
    for i in range(K,N):
        
        
        dp[i]= min(dp[i-k]+abs(h[i-k]-h[i]) for k in range(1,K+1))
        
        #dp[i]=np.min(list1)
         
print(dp[N-1])

Fixed submission:
import numpy as np
N,K = map(int,input().split())
h = np.array(list(map(int,input().split())))
dp=np.array([0 for i in range(N)])
dp[0]= 0
dp[1]=abs(h[1]-h[0])
if N<=K:
    dp[N-1]=abs(h[0]-h[N-1])
else:  
    for i in range(2,N):
      j=max(0,i-K)
      dp[i]=np.min(dp[j:i]+np.abs(h[i]-h[j:i]))
      #dp[i]=min([dp[i-j]+abs(h[i]-h[i-j]) for j in range(1,min(k+1,i+1))])
print(int(dp[-1]))

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

Fixed submission:
import numpy as np
N,K = map(int,input().split())
h = np.array(list(map(int,input().split())))
dp=np.array([0 for i in range(N)])
dp[0]= 0
dp[1]=abs(h[1]-h[0])
if N<=K:
    dp[N-1]=abs(h[0]-h[N-1])
else:  
    for i in range(2,N):
      j=max(0,i-K)
      dp[i]=np.min(dp[j:i]+np.abs(h[i]-h[j:i]))
      #dp[i]=min([dp[i-j]+abs(h[i]-h[i-j]) for j in range(1,min(k+1,i+1))])
print(int(dp[-1]))

Buggy python submission (verdict: Runtime Error):
N,K = map(int,input().split())
h = list(map(int,input().split()))
dp=[0for i in range(N)]
dp[0]= 0
for j in range(1,K+1):
    dp[j]= abs(h[0]-h[j])

for i in range(K,N):
    list1 =[]
    for k in range(1,K+1):
        cost = dp[i-k]+abs(h[i-k]-h[i])
        list1.append(cost)
    dp[i]= min(list1)
        
print(dp[N-1])

Fixed submission:
import numpy as np
N,K = map(int,input().split())
h = np.array(list(map(int,input().split())))
dp=np.array([0 for i in range(N)])
dp[0]= 0
dp[1]=abs(h[1]-h[0])
if N<=K:
    dp[N-1]=abs(h[0]-h[N-1])
else:  
    for i in range(2,N):
      j=max(0,i-K)
      dp[i]=np.min(dp[j:i]+np.abs(h[i]-h[j:i]))
      #dp[i]=min([dp[i-j]+abs(h[i]-h[i-j]) for j in range(1,min(k+1,i+1))])
print(int(dp[-1]))

Buggy python submission (verdict: Runtime Error):
# coding: utf-8
# Your code here!
N,K = list(map(int,input().split()))
h= list(map(int,input().split()))
dp =[99999 for i in range(N)]
#初期条件を設定
for i in range(K):
    if i==0:
        dp[i]=0
    else:
        dp[i]=abs(h[i]-h[0])
for j in range(K,N):
    minit=[]
    for k in range(K):
        new =dp[j-k]+abs(h[j-k-1]-h[j])
        minit.append(new)
        
        
    dp[j]=min(minit)
print(dp[N-1])
        

Fixed submission:
import numpy as np
N,K = map(int,input().split())
h = np.array(list(map(int,input().split())))
dp=np.array([0 for i in range(N)])
dp[0]= 0
dp[1]=abs(h[1]-h[0])
if N<=K:
    dp[N-1]=abs(h[0]-h[N-1])
else:  
    for i in range(2,N):
      j=max(0,i-K)
      dp[i]=np.min(dp[j:i]+np.abs(h[i]-h[j:i]))
      #dp[i]=min([dp[i-j]+abs(h[i]-h[i-j]) for j in range(1,min(k+1,i+1))])
print(int(dp[-1]))