Buggy python submission (verdict: Runtime Error):
N = int(input())
h = list(map(int, input().split())) #0-index

inf = float('inf')
dp = [inf]*(N+1)

def chmin(a,b):
    if a >= b:
        return b
    else:
        a

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

Fixed submission:
import math

N = int(input())
h = list(map(int, input().split()))
dp = [float('INF')] * N

def chmin(a, b):
    if a >= b:
        return b
    else:
        return a

#初期値
dp[0] = 0

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

Buggy python submission (verdict: Runtime Error):
N = int(input())
h = list(map(int, input().split()))
INF = 10**8
dp = [INF] * N

def chmin(a, b):
    if a >= b:
        return b
    else:
        return a

def DFS(i):
    if dp[i] < INF:
        return dp[i]
    
    if (i == 0):
        dp[i] = 0
        return 0
    
    res = INF
    res = chmin(INF, DFS(i-1) + abs(h[i] - h[i-1]))
    
    if i > 1:
        res = chmin(res, DFS(i-2) + abs(h[i] - h[i-2]))
        
    dp[i] = res
    return res
print(DFS(N-1))

Fixed submission:
import math

N = int(input())
h = list(map(int, input().split()))
dp = [float('INF')] * N

def chmin(a, b):
    if a >= b:
        return b
    else:
        return a

#初期値
dp[0] = 0

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

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

N = int(input())
h = list(map(int, input().split()))
dp = [float('INF')] * N
INF = float('INF')
def chmin(a, b):
    if a >= b:
        return b
    else:
        return a

def DFS(i):
    if dp[i] < INF:
        return dp[i]
    
    if (i == 0):
        dp[i] = 0
        return 0
    
    res = INF
    res = chmin(INF, DFS(i-1) + abs(h[i] - h[i-1]))
    
    if i > 1:
        res = chmin(res, DFS(i-2) + abs(h[i] - h[i-2]))
        
    dp[i] = res
    return res
print(DFS(N-1))

Fixed submission:
import math

N = int(input())
h = list(map(int, input().split()))
dp = [float('INF')] * N

def chmin(a, b):
    if a >= b:
        return b
    else:
        return a

#初期値
dp[0] = 0

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

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

N = int(input())
h = list(map(int, input().split()))
dp = [float('INF')] * N
INF = float('INF')
def chmin(a, b):
    if a >= b:
        return b
    else:
        return a

def DFS(i):
    if dp[i] < INF:
        return dp[i]
    
    if (i == 0):
        dp[i] = 0
        return 0
    
    res = INF
    res = chmin(INF, DFS(i-1) + abs(h[i] - h[i-1]))
    dp[i] = res
    if i > 1:
        res = chmin(res, DFS(i-2) + abs(h[i] - h[i-2]))
        dp[i] = res
    
    return res
print(DFS(N-1))

Fixed submission:
import math

N = int(input())
h = list(map(int, input().split()))
dp = [float('INF')] * N

def chmin(a, b):
    if a >= b:
        return b
    else:
        return a

#初期値
dp[0] = 0

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