Buggy python submission (verdict: Runtime Error):

import sys
input = sys.stdin.readline
N,K=map(int,input().rstrip().split())
h=list(map(int,input().rstrip().split()))

inf=10**9+7
dp=[inf]*N
dp[0]=0

for i in range(1,N,1):
    for k in range(1,K+1,1):
        if(i-k<0):
            continue
        dp[i]=min(dp[i],dp[i-k]+abs(h[i]-h[i-k]))
print(dp[N-1])
  

Fixed submission:
import sys
input = sys.stdin.readline
N=int(input().rstrip())
h=list(map(int,input().rstrip().split()))

dp=[0]*N
for i in range(N):
    dp[i]=1000000000000
dp[0]=0

for i in range(1,N,1):
    dp[i]=min(dp[i],dp[i-1]+abs(h[i]-h[i-1]))
    if(i>1):        
        dp[i]=min(dp[i],dp[i-2]+abs(h[i]-h[i-2]))

print(dp[N-1])

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

input = sys.stdin.readline
N=int(input().rstrip())
h=list(map(int,input().rstrip().split()))

dp=[0]*N
for i in range(N):
    dp[i]=math.inf
dp[0]=0

for i in range(1,N,1):
    dp[i]=min(dp[i],dp[i-1]+abs(h[i]-h[i-1]))
    if(i>1):        
        dp[i]=min(dp[i],dp[i-2]+abs(h[i]-h[i-2]))
print(dp[N-1])
          


Fixed submission:
import sys
input = sys.stdin.readline
N=int(input().rstrip())
h=list(map(int,input().rstrip().split()))

dp=[0]*N
for i in range(N):
    dp[i]=1000000000000
dp[0]=0

for i in range(1,N,1):
    dp[i]=min(dp[i],dp[i-1]+abs(h[i]-h[i-1]))
    if(i>1):        
        dp[i]=min(dp[i],dp[i-2]+abs(h[i]-h[i-2]))

print(dp[N-1])

Buggy python submission (verdict: Runtime Error):
import sys
import math
def resolve():
        input = sys.stdin.readline
        N=int(input().rstrip())
        h=list(map(int,input().rstrip().split()))

        dp=[math.inf]*N
        dp[0]=0

        for i in range(1,N,1):
            dp[i]=min(dp[i],dp[i-1]+abs(h[i]-h[i-1]))
            if(i>1):        
                dp[i]=min(dp[i],dp[i-2]+abs(h[i]-h[i-2]))

        print(dp[N-1])
          


from io import StringIO
import unittest


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)
    def test_入力例_1(self):
        input = """4
10 30 40 20"""
        output = """30"""
        self.assertIO(input, output)
    def test_入力例_2(self):
        input = """2
10 10"""
        output = """0"""
        self.assertIO(input, output)
    def test_入力例_3(self):
        input = """6
30 10 60 10 60 50"""
        output = """40"""
        self.assertIO(input, output)

if __name__ == "__main__":
    #unittest.main()
    resolve()

Fixed submission:
import sys
input = sys.stdin.readline
N=int(input().rstrip())
h=list(map(int,input().rstrip().split()))

dp=[0]*N
for i in range(N):
    dp[i]=1000000000000
dp[0]=0

for i in range(1,N,1):
    dp[i]=min(dp[i],dp[i-1]+abs(h[i]-h[i-1]))
    if(i>1):        
        dp[i]=min(dp[i],dp[i-2]+abs(h[i]-h[i-2]))

print(dp[N-1])

Buggy python submission (verdict: Runtime Error):
import sys
import math
input = sys.stdin.readline
N=int(input().rstrip())
h=list(map(int,input().rstrip().split()))

dp=[math.inf]*N
dp[0]=0

for i in range(1,N,1):
    dp[i]=min(dp[i],dp[i-1]+abs(h[i]-h[i-1]))
    if(i>1):        
        dp[i]=min(dp[i],dp[i-2]+abs(h[i]-h[i-2]))

print(dp[N-1])

Fixed submission:
import sys
input = sys.stdin.readline
N=int(input().rstrip())
h=list(map(int,input().rstrip().split()))

dp=[0]*N
for i in range(N):
    dp[i]=1000000000000
dp[0]=0

for i in range(1,N,1):
    dp[i]=min(dp[i],dp[i-1]+abs(h[i]-h[i-1]))
    if(i>1):        
        dp[i]=min(dp[i],dp[i-2]+abs(h[i]-h[i-2]))

print(dp[N-1])