Buggy python submission (verdict: Runtime Error):
N = int(input())
H = list(map(int, input().split())) + [100 for _ in range(100)]

# dp = [0] * N
# dp[1] = abs(H[1]-H[0])
#
# # loop
# for i in range(2, N):
#     dp[i] = min((dp[i-1]+abs(H[i-1]-H[i]), dp[i-2]+abs(H[i-2]-H[i])))
#
# print(dp)
# print(dp[N-1])

dp = [0] * N
dp[1] = abs(H[1]-H[0])

# rec
def func(i):
    #print(f'i: {i}')
    if i >= N:
        return 0
    else:
        dp[i] = min((dp[i-1]+abs(H[i-1]-H[i]), dp[i-2]+abs(H[i-2]-H[i])))
        func(i+1)

func(2)
#print(dp)
print(dp[N-1])

Fixed submission:
N = int(input())
H = list(map(int, input().split()))

dp = [0] * N
dp[1] = abs(H[1]-H[0])
for i in range(2, N):
    dp[i] = min((dp[i-1]+abs(H[i-1]-H[i]), dp[i-2]+abs(H[i-2]-H[i])))

print(dp[N-1])

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

dp = [0] * N
dp[1] = abs(H[1]-H[0])

def func(i):
    if i >= N:
        return 0
    else:
        dp[i] = min((dp[i-1]+abs(H[i-1]-H[i]), dp[i-2]+abs(H[i-2]-H[i])))
        func(i+1)

func(2)
print(dp[N-1])

Fixed submission:
N = int(input())
H = list(map(int, input().split()))

dp = [0] * N
dp[1] = abs(H[1]-H[0])
for i in range(2, N):
    dp[i] = min((dp[i-1]+abs(H[i-1]-H[i]), dp[i-2]+abs(H[i-2]-H[i])))

print(dp[N-1])

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

dp = [0] * N
dp[1] = abs(H[1]-H[0])

def func(i):
    if i == N:
        return 0
    else:
        dp[i] = min((dp[i-1]+abs(H[i-1]-H[i]), dp[i-2]+abs(H[i-2]-H[i])))
        func(i+1)

func(2)
print(dp[N-1])

Fixed submission:
N = int(input())
H = list(map(int, input().split()))

dp = [0] * N
dp[1] = abs(H[1]-H[0])
for i in range(2, N):
    dp[i] = min((dp[i-1]+abs(H[i-1]-H[i]), dp[i-2]+abs(H[i-2]-H[i])))

print(dp[N-1])

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

dp = [0] * N
dp[1] = abs(H[1]-H[0])

def func(i):
    if i == N:
        return 0
    else:
        dp[i] = min((dp[i-1]+abs(H[i-1]-H[i]), dp[i-2]+abs(H[i-2]-H[i])))
        return func(i+1)

func(2)
print(dp[-1])

Fixed submission:
N = int(input())
H = list(map(int, input().split()))

dp = [0] * N
dp[1] = abs(H[1]-H[0])
for i in range(2, N):
    dp[i] = min((dp[i-1]+abs(H[i-1]-H[i]), dp[i-2]+abs(H[i-2]-H[i])))

print(dp[N-1])

Buggy python submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10000)

N = int(input())
H = [-1] + list(map(int, input().split()))

def func(i):
    if i == 0:
        return 0
    else:
        if i - 2 < 0:
            return 0
        elif i - 1 < 0:
            return 0
        elif i > N:
            return 0
        else:
            return min((func(i-1)+abs(H[i-1]-H[i]), func(i-2)+abs(H[i-2]-H[i])))

print(func(N))

Fixed submission:
N = int(input())
H = list(map(int, input().split()))

dp = [0] * N
dp[1] = abs(H[1]-H[0])
for i in range(2, N):
    dp[i] = min((dp[i-1]+abs(H[i-1]-H[i]), dp[i-2]+abs(H[i-2]-H[i])))

print(dp[N-1])

Buggy python submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10000)

N = int(input())
H = [-1] + list(map(int, input().split()))

def func(i):
    if i == 0:
        return 0
    else:
        if i - 2 < 0:
            return 0
        elif i - 1 < 0:
            return 0
        else:
            return min((func(i-1)+abs(H[i-1]-H[i]), func(i-2)+abs(H[i-2]-H[i])))

print(func(N))

Fixed submission:
N = int(input())
H = list(map(int, input().split()))

dp = [0] * N
dp[1] = abs(H[1]-H[0])
for i in range(2, N):
    dp[i] = min((dp[i-1]+abs(H[i-1]-H[i]), dp[i-2]+abs(H[i-2]-H[i])))

print(dp[N-1])

Buggy python submission (verdict: Runtime Error):
N = int(input())
H = [-1] + list(map(int, input().split()))

def func(i):
    if i == 0:
        return 0
    else:
        if i - 2 < 0:
            return 0
        elif i - 1 < 0:
            return 0
        else:
            return min((func(i-1)+abs(H[i-1]-H[i]), func(i-2)+abs(H[i-2]-H[i])))

print(func(N))

Fixed submission:
N = int(input())
H = list(map(int, input().split()))

dp = [0] * N
dp[1] = abs(H[1]-H[0])
for i in range(2, N):
    dp[i] = min((dp[i-1]+abs(H[i-1]-H[i]), dp[i-2]+abs(H[i-2]-H[i])))

print(dp[N-1])