Buggy python submission (verdict: Runtime Error):
size=int(input())
h = list(map(int,input().split()))
dp = 0
i = 0
while i != size:
  if i == size-1:
    dp += abs(h[i]-h[i+1])
    i = i+1
  else:
    if abs(h[i]-h[i+1]) < abs(h[i]-h[i+2]):
      dp += abs(h[i]-h[i+1])
      i = i+1
    else:
      dp += abs(h[i]-h[i+2])
      i = i+2
print(dp)

Fixed submission:
size=int(input())
h = list(map(int,input().split()))
dp = [0 for _ in range(size)]
for i in range(1,size):
    if i == 1:
        dp[i] = dp[0]+abs(h[0]-h[1])
    else:
        a = dp[i-2]+abs(h[i-2]-h[i])
        b = dp[i-1]+abs(h[i-1]-h[i])
        if a < b:
            dp[i] = a
        else:
            dp[i] = b
print(dp[-1])

Buggy python submission (verdict: Runtime Error):
size=int(input())
h = list(map(int,input().split()))
dp = 0
for i in range(0, size):
    if i < size-1:
        if abs(h[i]-h[i+1]) < abs(h[i]-h[i+2]):
            dp += abs(h[i+1]-h[i])
        else:
            dp += abs(h[i+2]-h[i])
    if i = size-1:
        dp += abs(h[i+1]-h[i])
print(dp)

Fixed submission:
size=int(input())
h = list(map(int,input().split()))
dp = [0 for _ in range(size)]
for i in range(1,size):
    if i == 1:
        dp[i] = dp[0]+abs(h[0]-h[1])
    else:
        a = dp[i-2]+abs(h[i-2]-h[i])
        b = dp[i-1]+abs(h[i-1]-h[i])
        if a < b:
            dp[i] = a
        else:
            dp[i] = b
print(dp[-1])

Buggy python submission (verdict: Runtime Error):
size=int(input())
h = list(map(int,input().split()))
dp = 0
for i in range(0, size):
    if i < size-1:
        if abs(h[i]-h[i+1]) < abs(h[i]-h[i+2]):
            dp += abs(h[i+1]-h[i])
        else:
            dp += abs(h[i+2]-h[i])
    if i = size-1:
        dp += abs(h[i+1]-h[i])
    except:
        pass
print(dp)

Fixed submission:
size=int(input())
h = list(map(int,input().split()))
dp = [0 for _ in range(size)]
for i in range(1,size):
    if i == 1:
        dp[i] = dp[0]+abs(h[0]-h[1])
    else:
        a = dp[i-2]+abs(h[i-2]-h[i])
        b = dp[i-1]+abs(h[i-1]-h[i])
        if a < b:
            dp[i] = a
        else:
            dp[i] = b
print(dp[-1])

Buggy python submission (verdict: Runtime Error):
size=int(input())
h = list(map(int,input().split()))
dp = 0
for i in range(0, size):
    if i < size-1:
        if abs(h[i]-h[i+1]) < abs(h[i]-h[i+2]):
            dp += abs(h[i+1]-h[i])
        else:
            dp += abs(h[i+2]-h[i])
    if i = size-1:
        dp += abs(h[i+2]-h[i])
    except:
        pass
print(dp)

Fixed submission:
size=int(input())
h = list(map(int,input().split()))
dp = [0 for _ in range(size)]
for i in range(1,size):
    if i == 1:
        dp[i] = dp[0]+abs(h[0]-h[1])
    else:
        a = dp[i-2]+abs(h[i-2]-h[i])
        b = dp[i-1]+abs(h[i-1]-h[i])
        if a < b:
            dp[i] = a
        else:
            dp[i] = b
print(dp[-1])

Buggy python submission (verdict: Runtime Error):
size=int(input())
h = list(map(int,input().split()))
dp = 0
for i in range(0, size):
  	try:
    	if abs(h[i]-h[i+1]) < abs(h[i]-h[i+2]):
			dp += abs(h[i]-h[i+1])
  		else:
      		dp += abs(h[i]-h[i+2])
  	except:
    	pass
print(dp)

Fixed submission:
size=int(input())
h = list(map(int,input().split()))
dp = [0 for _ in range(size)]
for i in range(1,size):
    if i == 1:
        dp[i] = dp[0]+abs(h[0]-h[1])
    else:
        a = dp[i-2]+abs(h[i-2]-h[i])
        b = dp[i-1]+abs(h[i-1]-h[i])
        if a < b:
            dp[i] = a
        else:
            dp[i] = b
print(dp[-1])