Buggy python submission (verdict: Time Limit Exceeded):
import sys


def input():
    return sys.stdin.readline().strip()


def main():
    size, jumps = map(int, input().split())
    array = list(map(int, input().split()))
    dp = [999999999] * size
    dp[0] = 0
    # dp[1] = abs(array[0]- array[1])
    for i in range(size):
        for j in range(i + 1, 1 + i + jumps):
            if j < size:
                dp[j] = min(dp[j], dp[i] + abs(array[i] - array[j]))
            else:
                break
    print(dp[size - 1])


if __name__ == "__main__":
    main()


Fixed submission:
import sys


def input():
    return sys.stdin.readline().strip()


def main():
    size, jumps = map(int, input().split())
    array = list(map(int, input().split()))
    dp = [999999999] * size
    dp[0]= 0
    dp[1] = abs(array[0]- array[1])
    for i in range(2,size):
        dp[i] = min(abs(array[i] - array[j]) + dp[j] for j in range(max(0, i - jumps), i))
    print(dp[size-1])

if __name__ == "__main__":
    main()

Buggy python submission (verdict: Time Limit Exceeded):
import sys


def input():
    return sys.stdin.readline().strip()


def main():
    size, jumps = map(int, input().split())
    array = list(map(int, input().split()))
    dp = [999999999] * size
    dp[0] = 0
    # dp[1] = abs(array[0]- array[1])
    for i in range(size):
        for j in range(i + 1, 1 + i + jumps):
            if j < size:
                dp[j] = min(dp[j], dp[i] + abs(array[i] - array[j]))
    print(dp[size - 1])


if __name__ == "__main__":
    main()


Fixed submission:
import sys


def input():
    return sys.stdin.readline().strip()


def main():
    size, jumps = map(int, input().split())
    array = list(map(int, input().split()))
    dp = [999999999] * size
    dp[0]= 0
    dp[1] = abs(array[0]- array[1])
    for i in range(2,size):
        dp[i] = min(abs(array[i] - array[j]) + dp[j] for j in range(max(0, i - jumps), i))
    print(dp[size-1])

if __name__ == "__main__":
    main()

Buggy python submission (verdict: Runtime Error):
import sys


def input():
    return sys.stdin.readline().strip()


def main():
    size, jumps = map(int, input().split())
    array = list(map(int, input().split()))
    dp = [999999999] * size
    dp[0]= 0
    #dp[1] = abs(array[0]- array[1])
    for i in range(size):
		for j in range(i+1,1+i+jumps):
			if j < size:
				dp[j] = min(dp[j], dp[i]+abs(array[i] - array[j]))
	print(dp[size-1])

if __name__ == "__main__":
    main()


Fixed submission:
import sys


def input():
    return sys.stdin.readline().strip()


def main():
    size, jumps = map(int, input().split())
    array = list(map(int, input().split()))
    dp = [999999999] * size
    dp[0]= 0
    dp[1] = abs(array[0]- array[1])
    for i in range(2,size):
        dp[i] = min(abs(array[i] - array[j]) + dp[j] for j in range(max(0, i - jumps), i))
    print(dp[size-1])

if __name__ == "__main__":
    main()

Buggy python submission (verdict: Runtime Error):
import sys


def input():
    return sys.stdin.readline().strip()


def main():
    size, jumps = map(int, input().split())
    array = list(map(int, input().split()))
    dp = [999999999] * size
    dp[0]= 0
    #dp[1] = abs(array[0]- array[1])
    for i in range(size):
		for j in range(i+1,1+i+jumps):
			if j < size:
				dp[j] = min(dp[j], dp[i]+abs(array[i] - array[j]))
print(dp[size-1])

if __name__ == "__main__":
    main()


Fixed submission:
import sys


def input():
    return sys.stdin.readline().strip()


def main():
    size, jumps = map(int, input().split())
    array = list(map(int, input().split()))
    dp = [999999999] * size
    dp[0]= 0
    dp[1] = abs(array[0]- array[1])
    for i in range(2,size):
        dp[i] = min(abs(array[i] - array[j]) + dp[j] for j in range(max(0, i - jumps), i))
    print(dp[size-1])

if __name__ == "__main__":
    main()

Buggy python submission (verdict: Time Limit Exceeded):
import sys


def input():
    return sys.stdin.readline().strip()


def main():
    n, k = map(int, input().split())
    h = list(map(int, input().split()))
    dp = [0] * n
    dp[0] = 0
    dp[1] = abs(h[0] - h[1])

    for i in range(2, n):
        dp[i] = min(abs(h[i] - h[j]) + dp[j] for j in range(max(0, i - k), i))
    print(dp[n - 1])


if __name__ == "__main__":
    main()


Fixed submission:
import sys


def input():
    return sys.stdin.readline().strip()


def main():
    size, jumps = map(int, input().split())
    array = list(map(int, input().split()))
    dp = [999999999] * size
    dp[0]= 0
    dp[1] = abs(array[0]- array[1])
    for i in range(2,size):
        dp[i] = min(abs(array[i] - array[j]) + dp[j] for j in range(max(0, i - jumps), i))
    print(dp[size-1])

if __name__ == "__main__":
    main()

Buggy python submission (verdict: Time Limit Exceeded):
size, jumps = map(int, input().split())
array = list(map(int, input().split()))
dp = [999999999] * size
dp[0]= 0
dp[1] = abs(array[0]- array[1])
for i in range(2,size):
    dp[i] = min(abs(array[i] - array[j]) + dp[j] for j in range(max(0, i - jumps), i))
print(dp[size-1])

Fixed submission:
import sys


def input():
    return sys.stdin.readline().strip()


def main():
    size, jumps = map(int, input().split())
    array = list(map(int, input().split()))
    dp = [999999999] * size
    dp[0]= 0
    dp[1] = abs(array[0]- array[1])
    for i in range(2,size):
        dp[i] = min(abs(array[i] - array[j]) + dp[j] for j in range(max(0, i - jumps), i))
    print(dp[size-1])

if __name__ == "__main__":
    main()

Buggy python submission (verdict: Time Limit Exceeded):
size, jumps = map(int, input().split())
array = list(map(int, input().split()))
dp = [999999999] * size
dp[0]= 0
dp[1] = abs(array[0] - array[1])
for i in range(size):
    for j in range(i+1,1+i+jumps):
        if j < size:
            dp[j] = min(dp[j], dp[i]+abs(array[i] - array[j]))
print(dp[size-1])


Fixed submission:
import sys


def input():
    return sys.stdin.readline().strip()


def main():
    size, jumps = map(int, input().split())
    array = list(map(int, input().split()))
    dp = [999999999] * size
    dp[0]= 0
    dp[1] = abs(array[0]- array[1])
    for i in range(2,size):
        dp[i] = min(abs(array[i] - array[j]) + dp[j] for j in range(max(0, i - jumps), i))
    print(dp[size-1])

if __name__ == "__main__":
    main()

Buggy python submission (verdict: Time Limit Exceeded):
size, jumps = map(int, input().split())
array = list(map(int, input().split()))
dp = [9999999999] * size
dp[0]= 0
for i in range(size):
  for j in range(i + 1, i+jumps+1):
    if j < size:
      dp[j] = min(dp[j], dp[i]+abs(array[i] - array[j]))
print(dp[size-1])

Fixed submission:
import sys


def input():
    return sys.stdin.readline().strip()


def main():
    size, jumps = map(int, input().split())
    array = list(map(int, input().split()))
    dp = [999999999] * size
    dp[0]= 0
    dp[1] = abs(array[0]- array[1])
    for i in range(2,size):
        dp[i] = min(abs(array[i] - array[j]) + dp[j] for j in range(max(0, i - jumps), i))
    print(dp[size-1])

if __name__ == "__main__":
    main()

Buggy python submission (verdict: Time Limit Exceeded):
size, jumps = map(int, input().split())
array = list(map(int, input().split()))
dp = [9999999999] * size
dp[0]= 0
for i in range(size):
    for j in range(i + 1, i+jumps+1):
        if j < size:
            dp[j] = min(dp[j], dp[i]+abs(array[i] - array[j]))
print(dp[size-1])


Fixed submission:
import sys


def input():
    return sys.stdin.readline().strip()


def main():
    size, jumps = map(int, input().split())
    array = list(map(int, input().split()))
    dp = [999999999] * size
    dp[0]= 0
    dp[1] = abs(array[0]- array[1])
    for i in range(2,size):
        dp[i] = min(abs(array[i] - array[j]) + dp[j] for j in range(max(0, i - jumps), i))
    print(dp[size-1])

if __name__ == "__main__":
    main()

Buggy python submission (verdict: Runtime Error):
size, jumps = map(int, input().split())
array =  list(map(int, input().split()))
dp = [0]* size
for i in range(1,size):
	for j in range(i,jumps):	
		
		dp[j] = min(dp[j],abs(array[i] - array[j]))
print(dp[-1])

Fixed submission:
import sys


def input():
    return sys.stdin.readline().strip()


def main():
    size, jumps = map(int, input().split())
    array = list(map(int, input().split()))
    dp = [999999999] * size
    dp[0]= 0
    dp[1] = abs(array[0]- array[1])
    for i in range(2,size):
        dp[i] = min(abs(array[i] - array[j]) + dp[j] for j in range(max(0, i - jumps), i))
    print(dp[size-1])

if __name__ == "__main__":
    main()

Buggy python submission (verdict: Runtime Error):



size, jumps = map(int, input().split())
array =  list(map(int, input().split()))
dp = [0]* size
for i in range(1,size):
	for j in range(i,jumps):	
			dp[j] = min(dp[j],abs(array[i] - array[j]))
print(dp[-1])
		


Fixed submission:
import sys


def input():
    return sys.stdin.readline().strip()


def main():
    size, jumps = map(int, input().split())
    array = list(map(int, input().split()))
    dp = [999999999] * size
    dp[0]= 0
    dp[1] = abs(array[0]- array[1])
    for i in range(2,size):
        dp[i] = min(abs(array[i] - array[j]) + dp[j] for j in range(max(0, i - jumps), i))
    print(dp[size-1])

if __name__ == "__main__":
    main()

Buggy python submission (verdict: Runtime Error):
size, jumps = map(int, input().split())
array =  list(map(int, input().split()))
dp = [0]* size
dp[1]=  dp[0] + abs(array[1] - array[0]) 
for i in range(1,size):
	for j in range(jumps):	
		if i+j < n :
			dp[i] = min(dp[j],abs(array[i] - array[j]))
print(dp[-1])
		


Fixed submission:
import sys


def input():
    return sys.stdin.readline().strip()


def main():
    size, jumps = map(int, input().split())
    array = list(map(int, input().split()))
    dp = [999999999] * size
    dp[0]= 0
    dp[1] = abs(array[0]- array[1])
    for i in range(2,size):
        dp[i] = min(abs(array[i] - array[j]) + dp[j] for j in range(max(0, i - jumps), i))
    print(dp[size-1])

if __name__ == "__main__":
    main()

Buggy python submission (verdict: Runtime Error):

size, jumps = map(int, input().split())
array =  list(map(int, input().split()))
dp = [0]* size
dp[1]=  dp[0] + abs(array[1] - array[0]) 
for i in range(1,size):
	for j in range(jumps):		
		dp[i] = min( 
		dp[j],abs(array[i] - array[j])
		
		)
print(dp[-1])
		


Fixed submission:
import sys


def input():
    return sys.stdin.readline().strip()


def main():
    size, jumps = map(int, input().split())
    array = list(map(int, input().split()))
    dp = [999999999] * size
    dp[0]= 0
    dp[1] = abs(array[0]- array[1])
    for i in range(2,size):
        dp[i] = min(abs(array[i] - array[j]) + dp[j] for j in range(max(0, i - jumps), i))
    print(dp[size-1])

if __name__ == "__main__":
    main()