Buggy python submission (verdict: Runtime Error):
hhhh

Fixed submission:
N=int(input())
h=list(map(int,input().split()))
a=[]
for i in range(N):
  a.append(0)
a[0]=0
a[1]=abs(h[1]-h[0])
for i in range(2,N):
  a[i]=min(a[i-1]+abs(h[i]-h[i-1]),a[i-2]+abs(h[i]-h[i-2]))
print(a[N-1])

Buggy python submission (verdict: Runtime Error):

N=int(input())
h=list(map(int,input().split()))
a=[]
a[0]=0
a[1]=abs(h[1]-h[0])
for i in range(2,N):
  a[i]=min(a[i-1]+abs(h[i]-h[i-1]),a[i-2]+abs(h[i]-h[i-2]))
print(a[N-1])


Fixed submission:
N=int(input())
h=list(map(int,input().split()))
a=[]
for i in range(N):
  a.append(0)
a[0]=0
a[1]=abs(h[1]-h[0])
for i in range(2,N):
  a[i]=min(a[i-1]+abs(h[i]-h[i-1]),a[i-2]+abs(h[i]-h[i-2]))
print(a[N-1])

Buggy python submission (verdict: Runtime Error):
n = int(input()) # n >= 2
h = list(map(int, input().split())) # h_i >= 1

cost2 = 0;
cost1 = abs(h[1] - h[0]);

for i in range(2, n):
    cost = min(cost1 + abs(h[i] - h[i - 1]), cost2 + abs(h[i] - h[i - 2]))
    cost2, cost1 = cost1, cost

print(cost)

Fixed submission:
n = int(input()) # n >= 2
h = list(map(int, input().split())) # h_i >= 1

cost2 = 0;
cost1 = abs(h[1] - h[0]);

for i in range(2, n):
    cost = min(cost1 + abs(h[i] - h[i - 1]), cost2 + abs(h[i] - h[i - 2]))
    cost2, cost1 = cost1, cost

print(cost1)

Buggy python submission (verdict: Runtime Error):
n = int(input()) # n >= 2
h = list(map(int, input().split())) # h_i >= 1

cost2 = 0;
cost1 = abs(h[1] - h[0]);

for i in range(2, n):
    cost = min(cost1 + abs(h[i] - h[i - 1]), cost2 + abs(h[i] - h[i - 2]))
    cost2, cost1 = cost1, cost
    

print(cost)

Fixed submission:
n = int(input()) # n >= 2
h = list(map(int, input().split())) # h_i >= 1

cost2 = 0;
cost1 = abs(h[1] - h[0]);

for i in range(2, n):
    cost = min(cost1 + abs(h[i] - h[i - 1]), cost2 + abs(h[i] - h[i - 2]))
    cost2, cost1 = cost1, cost

print(cost1)

Buggy python submission (verdict: Runtime Error):
def cost(h, length):
    if length == 1:
        return 0
    elif length == 2:
        return abs(h[1] - h[0])
    else:
        variants = [cost(h, length - 1) + abs(h[length - 1] - h[length - 2]), cost(h, length - 2) + abs(h[length - 1] - h[length - 3])]
        return min(variants)

n = int(input()) # n >= 2
h = list(map(int, input().split())) # h_i >= 1
print(cost(h, n))

Fixed submission:
n = int(input()) # n >= 2
h = list(map(int, input().split())) # h_i >= 1

cost2 = 0;
cost1 = abs(h[1] - h[0]);

for i in range(2, n):
    cost = min(cost1 + abs(h[i] - h[i - 1]), cost2 + abs(h[i] - h[i - 2]))
    cost2, cost1 = cost1, cost

print(cost1)

Buggy python submission (verdict: Runtime Error):
N  = input()
line = raw_input()
cost = line.split(' ')

for i in range(0,N):
	cost[i] = int(cost[i])

dp = [0]*(N)

dp[0] = 0
dp[1] = abs(cost[1] - cost[0])

for n in range(2,N):
	dp[n] = min(abs(cost[n] - cost[n-1]) + dp[n-1], abs(cost[n] - cost[n-1]) + dp[n-2])

print(dp[N-1])

Fixed submission:
N  = input()
line = raw_input()
cost = line.split(' ')

for i in range(0,N):
	cost[i] = int(cost[i])

dp = [0]*(N)

dp[0] = 0
dp[1] = abs(cost[1] - cost[0])

for n in range(2,N):
	dp[n] = min(abs(cost[n] - cost[n-1]) + dp[n-1], abs(cost[n] - cost[n-2]) + dp[n-2])

print(dp[N-1])

Buggy python submission (verdict: Runtime Error):
N  = input()
cost = []
dp = [0]*(N)

for i in range(0,N):
	cost.append(input())

dp[0] = 0
dp[1] = abs(cost[1] - cost[0])

for n in range(2,N):
	dp[n] = min(abs(cost[n] - cost[n-1]) + dp[n-1], abs(cost[n] - cost[n-1]) + dp[n-2])

return dp[N-1]

Fixed submission:
N  = input()
line = raw_input()
cost = line.split(' ')

for i in range(0,N):
	cost[i] = int(cost[i])

dp = [0]*(N)

dp[0] = 0
dp[1] = abs(cost[1] - cost[0])

for n in range(2,N):
	dp[n] = min(abs(cost[n] - cost[n-1]) + dp[n-1], abs(cost[n] - cost[n-2]) + dp[n-2])

print(dp[N-1])

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

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


Fixed submission:
N = int(input())
h = list(map(int,input().split()))
dp = [999999] * N

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