Buggy python submission (verdict: Runtime Error):
n,k=map(int,input().split())
a=tuple(map(int,input().split()))
l=[0]
for i in range(1,n):
  b=a[i]
  l+=[min(l[-j]+abs(b-a[-j])for j in range(1,min(i,k)+1))]
  if i>k:
    del a[0]
    del l[0]
print(l[-1])


Fixed submission:
n,k=map(int,input().split())
a=list(map(int,input().split()))
l=[0]
for i in range(1,n):
  b=a[i]
  l.append(min(l[j]+abs(b-a[j])for j in range(i-min(k,i),i)))
print(l[-1])

Buggy python submission (verdict: Runtime Error):
n,k=map(int,input().split())
a=tuple(map(int,input().split()))
l=[0]
for i in range(1,n):
  b=a[i]
  l+=[min(l[-j]+abs(b-a[-j])for j in range(1,min(i,k)+1))]
  if i>=k:
    del a[0]
    del l[0]
print(l[-1])


Fixed submission:
n,k=map(int,input().split())
a=list(map(int,input().split()))
l=[0]
for i in range(1,n):
  b=a[i]
  l.append(min(l[j]+abs(b-a[j])for j in range(i-min(k,i),i)))
print(l[-1])

Buggy python submission (verdict: Runtime Error):
n,k=map(int,input().split())
a=tuple(map(int,input().split()))
l=[0]
for i in range(1,n):
  b=a[i]
  l+=[min(l[-j]+abs(b-a[-j])for j in range(1,min(i,k)+1))]
  if i>=k:
    a.del(0)
    l.del(0)
print(l[-1])


Fixed submission:
n,k=map(int,input().split())
a=list(map(int,input().split()))
l=[0]
for i in range(1,n):
  b=a[i]
  l.append(min(l[j]+abs(b-a[j])for j in range(i-min(k,i),i)))
print(l[-1])

Buggy python submission (verdict: Runtime Error):
n,k=map(int,input().split())
a=tuple(map(int,input().split()))
l=[0]
for i in range(1,n):
  b=a[i]
  l+=[min(l[-j]+abs(b-a[-j])for j in range(1,min(i+1,k)+1))]
print(l[-1])


Fixed submission:
n,k=map(int,input().split())
a=list(map(int,input().split()))
l=[0]
for i in range(1,n):
  b=a[i]
  l.append(min(l[j]+abs(b-a[j])for j in range(i-min(k,i),i)))
print(l[-1])

Buggy python submission (verdict: Runtime Error):
n,k=map(int,input().split())
a=tuple(map(int,input().split()))
l=[0]
for i in range(1,n):
  b=a[i]
  l+=[min(l[-j]+abs(b-a[-j])for j in range(1,max(i,k)+1))]
print(l[-1])


Fixed submission:
n,k=map(int,input().split())
a=list(map(int,input().split()))
l=[0]
for i in range(1,n):
  b=a[i]
  l.append(min(l[j]+abs(b-a[j])for j in range(i-min(k,i),i)))
print(l[-1])

Buggy python submission (verdict: Time Limit Exceeded):
n,k=map(int,input().split())
a=tuple(map(int,input().split()))
l=[0]
for i in range(1,n):
  b=a[i]
  l+=[min(l[j]+abs(b-a[j])for j in range(max(0,i-k),i))]
print(l[-1])


Fixed submission:
n,k=map(int,input().split())
a=list(map(int,input().split()))
l=[0]
for i in range(1,n):
  b=a[i]
  l.append(min(l[j]+abs(b-a[j])for j in range(i-min(k,i),i)))
print(l[-1])

Buggy python submission (verdict: Time Limit Exceeded):
n,k=map(int,input().split())
a=tuple(map(int,input().split()))
l=[0]
for i in range(1,n):
  b=a[i]
  l.append(min(l[j]+abs(b-a[j])for j in range(max(0,i-k),i)))
print(l[-1])

Fixed submission:
n,k=map(int,input().split())
a=list(map(int,input().split()))
l=[0]
for i in range(1,n):
  b=a[i]
  l.append(min(l[j]+abs(b-a[j])for j in range(i-min(k,i),i)))
print(l[-1])

Buggy python submission (verdict: Time Limit Exceeded):
n,k=map(int,input().split())
a=tuple(map(int,input().split()))
l=[0]
for i in range(1,n):
  b=a[i]
  l.append(min(l[j]+abs(b-a[j])for j in range(max(0,i-k),i)))
print(l[-1])

Fixed submission:
n,k=map(int,input().split())
a=list(map(int,input().split()))
l=[0]
for i in range(1,n):
  b=a[i]
  l.append(min(l[j]+abs(b-a[j])for j in range(i-min(k,i),i)))
print(l[-1])

Buggy python submission (verdict: Time Limit Exceeded):
n,k=map(int,input().split())
a=list(map(int,input().split()))
l=[0]
for i in range(1,n):
  b=a[i]
  l.append(min(l[j]+abs(b-a[j])for j in range(max(0,i-k),i)))
print(l[-1])

Fixed submission:
n,k=map(int,input().split())
a=list(map(int,input().split()))
l=[0]
for i in range(1,n):
  b=a[i]
  l.append(min(l[j]+abs(b-a[j])for j in range(i-min(k,i),i)))
print(l[-1])

Buggy python submission (verdict: Time Limit Exceeded):
n,k=map(int,input().split())
a=list(map(int,input().split()))
l=[0]
for i in range(1,n):
  b=a[i]
  l.append(min(l[j]+abs(b-a[j])for j in range(i-min(k,i),i)))
print(l[-1])

Fixed submission:
n,k=map(int,input().split())
a=list(map(int,input().split()))
l=[0]
for i in range(1,n):
  b=a[i]
  l.append(min(l[j]+abs(b-a[j])for j in range(i-min(k,i),i)))
print(l[-1])

Buggy python submission (verdict: Time Limit Exceeded):
n,k=map(int,input().split())
a=list(map(int,input().split()))
l=[0]
for i in range(1,n):
  b=a[i]
  l+=[min(l[j]+abs(b-a[j])for j in range(i-min(k,i),i))]
print(l[-1])

Fixed submission:
n,k=map(int,input().split())
a=list(map(int,input().split()))
l=[0]
for i in range(1,n):
  b=a[i]
  l.append(min(l[j]+abs(b-a[j])for j in range(i-min(k,i),i)))
print(l[-1])

Buggy python submission (verdict: Time Limit Exceeded):
n,k=map(int,input().split())
a=list(map(int,input().split()))
l=[0]
for i in range(1,n):
  b=a[i]
  s=i-min(k,i)
  l+=[min(l[j]+abs(b-a[j])for j in range(s,i))]
print(l[-1])

Fixed submission:
n,k=map(int,input().split())
a=list(map(int,input().split()))
l=[0]
for i in range(1,n):
  b=a[i]
  l.append(min(l[j]+abs(b-a[j])for j in range(i-min(k,i),i)))
print(l[-1])

Buggy python submission (verdict: Runtime Error):
n,k=map(int,input().split())
a=list(map(int,input().split()))
l=[0]
for i in range(1,n):
  b=a[i]
  s=min(k,i)+1
  l+=[min(l[j]+abs(b-a[j])for j in range(s,i))]
print(l[-1])

Fixed submission:
n,k=map(int,input().split())
a=list(map(int,input().split()))
l=[0]
for i in range(1,n):
  b=a[i]
  l.append(min(l[j]+abs(b-a[j])for j in range(i-min(k,i),i)))
print(l[-1])

Buggy python submission (verdict: Time Limit Exceeded):
n,k=map(int,input().split())
a=list(map(int,input().split()))
l=[0]
for i in range(1,n):
  b=a[i]
  l+=[min(l[i-j]+abs(b-a[i-j])for j in range(1,min(k,i)+1))]
print(l[-1])

Fixed submission:
n,k=map(int,input().split())
a=list(map(int,input().split()))
l=[0]
for i in range(1,n):
  b=a[i]
  l.append(min(l[j]+abs(b-a[j])for j in range(i-min(k,i),i)))
print(l[-1])

Buggy python submission (verdict: Time Limit Exceeded):
n,k=map(int,input().split())
a=list(map(int,input().split()))
l=[0]
for i in range(1,n):
  l+=[min(l[i-j]+abs(a[i]-a[i-j])for j in range(1,min(k,i)+1))]
print(l[-1])

Fixed submission:
n,k=map(int,input().split())
a=list(map(int,input().split()))
l=[0]
for i in range(1,n):
  b=a[i]
  l.append(min(l[j]+abs(b-a[j])for j in range(i-min(k,i),i)))
print(l[-1])

Buggy python submission (verdict: Time Limit Exceeded):
n,k=map(int,input().split())
a=list(map(int,input().split()))
l=[0]
for i in range(1,n):
  m=10**9
  for j in range(1,min(k,i)+1):
    m=min(m,l[i-j]+abs(a[i]-a[i-j]))
  l.append(m)
print(l[-1])

Fixed submission:
n,k=map(int,input().split())
a=list(map(int,input().split()))
l=[0]
for i in range(1,n):
  b=a[i]
  l.append(min(l[j]+abs(b-a[j])for j in range(i-min(k,i),i)))
print(l[-1])

Buggy python submission (verdict: Time Limit Exceeded):
n,k=map(int,input().split())
a=list(map(int,input().split()))
l=[]
for i in range(n):
  if i==0:
    l.append(0)
  else:
    m=10**9
    for j in range(1,min(k,i)+1):
      m=min(m,l[i-j]+abs(a[i]-a[i-j]))
    l.append(m)
print(l[-1])

Fixed submission:
n,k=map(int,input().split())
a=list(map(int,input().split()))
l=[0]
for i in range(1,n):
  b=a[i]
  l.append(min(l[j]+abs(b-a[j])for j in range(i-min(k,i),i)))
print(l[-1])