Buggy python submission (verdict: Runtime Error):
import sys
read = lambda: sys.stdin.readline().rstrip()
 
N,W=map(int,read().split())
 
def solve_knapsack(capacity):
    # basic checks
 
    dp = [0]*(capacity + 1)
    # populate the capacity = 0 columns, with '0' capacity we have '0' profit
 
    for i in range(0, N):
        weights,profits = map(int,read().split())
        for c in range(capacity, weights-1, -1):
            tmp = profits + dp[c - weights]
            if tmp > dp[c]: dp[c] = tmp
 
    # maximum profit will be at the bottom-right corner.
    return dp[capacity]
  
def main():
 
    res = solve_knapsack(W)
 
    print(res)
if __name__ == "__main__":
	main()

Fixed submission:
n = int(input())
h = list(map(int,input().split()))

INF = 10 ** 20

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

Buggy python submission (verdict: Runtime Error):
def solve_knapsack(profits, weights, capacity):
    # basic checks
    n = len(profits)

    dp = [[0 for x in range(capacity+1)] for y in range(n)]
    # populate the capacity = 0 columns, with '0' capacity we have '0' profit
    for i in range(0, n):
        dp[i][0] = 0
    for c in range(0, capacity+1):
        if weights[0] <= c: dp[0][c] = profits[0]
    for i in range(1, n):
        for c in range(1, capacity+1):
            if weights[i] <= c:
                dp[i][c] = max(profits[i] + dp[i - 1][c - weights[i]], dp[i - 1][c])
            else: dp[i][c]  = dp[i - 1][c]

    # maximum profit will be at the bottom-right corner.
    return dp[n - 1][capacity]
  
def main():

    for i in range(N):
        weights[i],profits[i] = map(int,input().split())
    res = solve_knapsack(profits, weights, capacity)
 
    print(res)
if __name__ == "__main__":
	main()

Fixed submission:
n = int(input())
h = list(map(int,input().split()))

INF = 10 ** 20

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

Buggy python submission (verdict: Runtime Error):
import sys
read = lambda: sys.stdin.readline().rstrip()
 
def main():
    INF = 10 ** 20

    n,k = map(int,input().split())
    h = tuple(map(int,read().split()))
    dp = [INF]*(n+1)
    dp[0] = 0

    for step in range(1, k+1):
        for i in range(step,n):
            dp[i] = min(dp[i], dp[i-step]+abs(h[i]-h[i-step]))

    print(dp[n-1])
if __name__ == "__main__":
    main()

Fixed submission:
n = int(input())
h = list(map(int,input().split()))

INF = 10 ** 20

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

Buggy python submission (verdict: Runtime Error):
n = int(input())
h = list(map(int,input().split()))

INF = 10 ** 20

dp = [INF]*(n+1)
dp[0] = dp[1] = 0
dp[2] = h[1]-h[0]
 
coin_list = list(map(int,input().split()))
 
for i in range(3,n+1):
    dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]), dp[i-2]+abs(h[i]-h[i-2]))
 
print(dp[n])

Fixed submission:
n = int(input())
h = list(map(int,input().split()))

INF = 10 ** 20

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