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

inf = -1
dp = [0] + [inf]*N
    
for i in range(1,N):
    dp[1] = abs(h[1]-h[0])
    else:
        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])

Fixed submission:
N = int(input())
h = list(map(int, input().split()))
    
inf = 10**9
dp = [0] + [inf]*N
    
for i in range(1,N):
    if i == 1:
        dp[1] = abs(h[1]-h[0])
    else:
        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()))
dp = [0]*N+1
    
for i in range(1,N):
    if i == 1:
        dp[1] = abs(h[1]-h[0])
    else:
        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])

Fixed submission:
N = int(input())
h = list(map(int, input().split()))
    
inf = 10**9
dp = [0] + [inf]*N
    
for i in range(1,N):
    if i == 1:
        dp[1] = abs(h[1]-h[0])
    else:
        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()))
dp = [0 for i in range(10)]
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])

Fixed submission:
N = int(input())
h = list(map(int, input().split()))
    
inf = 10**9
dp = [0] + [inf]*N
    
for i in range(1,N):
    if i == 1:
        dp[1] = abs(h[1]-h[0])
    else:
        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()))
dp = [0 for i in range(10)]
def aFrog(N,h):
    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]))
    return dp[N-1]

print(aFrog(N,h))

Fixed submission:
N = int(input())
h = list(map(int, input().split()))
    
inf = 10**9
dp = [0] + [inf]*N
    
for i in range(1,N):
    if i == 1:
        dp[1] = abs(h[1]-h[0])
    else:
        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 aFrog(N,h):
    dp = [0 for i in range(10)]
    dp[0] = 0
    dp[1] = abs(h[1]-h[0])
    print(dp)
    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]))
    return dp[N-1]

N = int(input())
h = list(map(int, input().split()))
print(aFrog(N,h))

Fixed submission:
N = int(input())
h = list(map(int, input().split()))
    
inf = 10**9
dp = [0] + [inf]*N
    
for i in range(1,N):
    if i == 1:
        dp[1] = abs(h[1]-h[0])
    else:
        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()))

dp = [-1]*(n+1)

def helper(n):
    if n <= 0:
        return float('inf')
    elif n == 1:
        return 0
    elif dp[n] != -1:
        return dp[n]
    else:
        if n-1 >= 0 and n-2 >= 0:
            l = abs(h[n-1]-h[n-2])+helper(n-1)
        else:
            l = float('inf')
        if n-1 >= 0 and n-3 >= 0:
            r = abs(h[n-1]-h[n-3]) + helper(n-2)
        else:
            r = float('inf')
        dp[n] = min(l, r)
        return dp[n]

print(helper(n))


Fixed submission:
n = int(input())
h = list(map(int, input().split()))
dp = [1000000000+5 for i in range(n)]
dp[0] = 0
for i in range(n):
    for j in range(i+1, i+3):
        if j < n:
            dp[j] = min(dp[j], dp[i] + abs(h[i]-h[j]))
print(dp[n-1])

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

dp = [-1]*(n+1)

def helper(n):
    if n <= 0:
        return float('inf')
    elif n == 1:
        return 0
    elif dp[n] != -1:
        return dp[n]
    else:
        dp[n] = min(abs(h[n-1]-h[n-2])+helper(n-1), abs(h[n-1]-h[n-3]) + helper(n-2))
        return dp[n]

print(helper(n))


Fixed submission:
n = int(input())
h = list(map(int, input().split()))
dp = [1000000000+5 for i in range(n)]
dp[0] = 0
for i in range(n):
    for j in range(i+1, i+3):
        if j < n:
            dp[j] = min(dp[j], dp[i] + abs(h[i]-h[j]))
print(dp[n-1])