Buggy python submission (verdict: Runtime Error):
inf = 10**9+5
n = int(input())
h = list( map(int,input().split()))

dp = [inf]*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)
print(dp[-1])


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

dp = [0, abs(h[1]-h[0])]
if n >2:
    for i in range(2,n):
        dp.append(min(abs(h[i]-h[i-2])+dp[-2], abs(h[i]-h[i-1])+dp[-1]))
else:
    print(dp[-1])
    exit()

print(dp[-1])

Buggy python submission (verdict: Runtime Error):
n = int(input())
x = list(map(int,input().split()))
mod=1e9+7
a = [-1]*(n+1)
def step(i):
    if i>=n-1:
        a[i]=0
        return x[-1]
    if(a[i]!=-1):return x[i]
    a[i] = min(abs(step(i+1)-x[i])%mod+a[i+1]%mod,abs(step(i+2)-x[i])%mod+a[i+2]%mod)%mod;
    return x[i]
c=step(0)
print(int(a[0]%mod))


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

dp = [0, abs(h[1]-h[0])]
if n >2:
    for i in range(2,n):
        dp.append(min(abs(h[i]-h[i-2])+dp[-2], abs(h[i]-h[i-1])+dp[-1]))
else:
    print(dp[-1])
    exit()

print(dp[-1])

Buggy python submission (verdict: Runtime Error):
n = int(input())
x = list(map(int,input().split()))
mod=1e9+7
a = [-1]*(n+1)
def step(i):
    if i>=n-1:
        a[i]=0
        return x[-1]
    if(a[i]!=-1):return x[i]
    a[i] = min(abs(step(i+1)-x[i])%mod+a[i+1]%mod,abs(step(i+2)-x[i])%mod+a[i+2]%mod)%mod;
    return x[i]
step(0)
print(int(a[0]%mod))


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

dp = [0, abs(h[1]-h[0])]
if n >2:
    for i in range(2,n):
        dp.append(min(abs(h[i]-h[i-2])+dp[-2], abs(h[i]-h[i-1])+dp[-1]))
else:
    print(dp[-1])
    exit()

print(dp[-1])

Buggy python submission (verdict: Runtime Error):
n = int(input())
x = list(map(int,input().split()))
mod=1e9+7
a = [-1]*(n+1)
def step(i):
    if i>=n-1:
        a[i]=0
        return x[-1]
    if(a[i]!=-1):return x[i]
    a[i] = min(abs(step(i+1)-x[i])+a[i+1],abs(step(i+2)-x[i])+a[i+2])%mod;
    return x[i]
step(0)
print(int(a[0]%mod))


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

dp = [0, abs(h[1]-h[0])]
if n >2:
    for i in range(2,n):
        dp.append(min(abs(h[i]-h[i-2])+dp[-2], abs(h[i]-h[i-1])+dp[-1]))
else:
    print(dp[-1])
    exit()

print(dp[-1])

Buggy python submission (verdict: Runtime Error):
n = int(input())
x = list(map(int,input().split()))
mod=1e9+7
a = [-1]*(n+1)
def step(i):
    if i>=n-1:
        a[i]=0
        return x[-1]
    if(a[i]!=-1):return x[i]
    a[i] = min(abs(step(i+1)-x[i])+a[i+1],abs(step(i+2)-x[i])+a[i+2])%mod;
    return x[i]
step(0)
print(a[0]%mod)


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

dp = [0, abs(h[1]-h[0])]
if n >2:
    for i in range(2,n):
        dp.append(min(abs(h[i]-h[i-2])+dp[-2], abs(h[i]-h[i-1])+dp[-1]))
else:
    print(dp[-1])
    exit()

print(dp[-1])

Buggy python submission (verdict: Runtime Error):
n = int(input())
x = list(map(int,input().split()))
a = [-1]*(n+1)
def step(i):
    
    if i>=n-1:
        a[i]=0
        return x[-1]
    if(a[i]!=-1):return x[i]
    a[i] = min(abs(step(i+1)-x[i])+a[i+1],abs(step(i+2)-x[i])+a[i+2])
    return x[i]
step(0)
print(a[0])

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

dp = [0, abs(h[1]-h[0])]
if n >2:
    for i in range(2,n):
        dp.append(min(abs(h[i]-h[i-2])+dp[-2], abs(h[i]-h[i-1])+dp[-1]))
else:
    print(dp[-1])
    exit()

print(dp[-1])

Buggy python submission (verdict: Runtime Error):
n = int(input())
x =list(map(int,input().split()))
def step(i,cost):
    if i>=(n-1):
        return abs(x[-1]-cost)
    return min(step(i+1,x[i])+abs(cost-x[i]),step(i+2,x[i])+abs(cost-x[i]))
cost = x[0]
print(step(0,cost))


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

dp = [0, abs(h[1]-h[0])]
if n >2:
    for i in range(2,n):
        dp.append(min(abs(h[i]-h[i-2])+dp[-2], abs(h[i]-h[i-1])+dp[-1]))
else:
    print(dp[-1])
    exit()

print(dp[-1])

Buggy python submission (verdict: Runtime Error):
n = int(input())
x =list(map(int,input().split()))
def step(i,cost):
    if i>=3:
        return abs(x[-1]-cost)
    return min(step(i+1,x[i])+abs(cost-x[i]),step(i+2,x[i])+abs(cost-x[i]))
cost = x[0]
print(step(0,cost))

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

dp = [0, abs(h[1]-h[0])]
if n >2:
    for i in range(2,n):
        dp.append(min(abs(h[i]-h[i-2])+dp[-2], abs(h[i]-h[i-1])+dp[-1]))
else:
    print(dp[-1])
    exit()

print(dp[-1])