Buggy python submission (verdict: Time Limit Exceeded):
import sys
sys.setrecursionlimit(20000000)
n=int(input())
h=list(map(int,input().split()))
def cost(place):
    if place==n-1:
        return 0
    if place==n-2:
        return abs(h[n-2]-h[n-1])
    if place<=n-3:
        a=abs(h[place]-h[place+2])+cost(place+2)
        b=abs(h[place]-h[place+1])+cost(place+1)
        x=min(a,b)
        return x
print(cost(0))


Fixed submission:
import sys
sys.setrecursionlimit(20000000)
n=int(input())
h=list(map(int,input().split()))
memory={}
def cost(place):
    if place in memory:
        return memory[place]
    if place==n-1:
        return 0
    if place==n-2:
        return abs(h[n-2]-h[n-1])
    if place<=n-3:
        a=abs(h[place]-h[place+2])+cost(place+2)
        b=abs(h[place]-h[place+1])+cost(place+1)
        x=min(a,b)
        memory[place]=x
        return x
print(cost(0))

Buggy python submission (verdict: Runtime Error):
n=int(input())
h=list(map(int,input().split()))
memory={}
def cost(place):
    if place in memory:
        return memory[place]
    if place==n-1:
        return 0
    if place==n-2:
        return abs(h[n-2]-h[n-1])
    if place<=n-3:
        a=abs(h[place]-h[place+2])+cost(place+2)
        b=abs(h[place]-h[place+1])+cost(place+1)
        x=min(a,b)
        memory[place]=x
        return x
print(cost(0))


Fixed submission:
import sys
sys.setrecursionlimit(20000000)
n=int(input())
h=list(map(int,input().split()))
memory={}
def cost(place):
    if place in memory:
        return memory[place]
    if place==n-1:
        return 0
    if place==n-2:
        return abs(h[n-2]-h[n-1])
    if place<=n-3:
        a=abs(h[place]-h[place+2])+cost(place+2)
        b=abs(h[place]-h[place+1])+cost(place+1)
        x=min(a,b)
        memory[place]=x
        return x
print(cost(0))

Buggy python submission (verdict: Runtime Error):
n=int(input())
x=[0]
h=list(map(int,input().split()))
h=x+h
memory={}
def cost(place):
    if place in memory:
        return memory[place]
    if place==n:
        return 0
    if place==n-1:
        return abs(h[n-1]-h[n])
    if place<=n-2:
        a=abs(h[place]-h[place+2])+cost(place+2)
        b=abs(h[place]-h[place+1])+cost(place+1)
        return min(a,b)
print(cost(1))


Fixed submission:
import sys
sys.setrecursionlimit(20000000)
n=int(input())
h=list(map(int,input().split()))
memory={}
def cost(place):
    if place in memory:
        return memory[place]
    if place==n-1:
        return 0
    if place==n-2:
        return abs(h[n-2]-h[n-1])
    if place<=n-3:
        a=abs(h[place]-h[place+2])+cost(place+2)
        b=abs(h[place]-h[place+1])+cost(place+1)
        x=min(a,b)
        memory[place]=x
        return x
print(cost(0))

Buggy python submission (verdict: Runtime Error):
n=int(input())
x=[0]
h=list(map(int,input().split()))
h=x+h

def cost(place):
    if place==n:
        return 0
    elif place==n-1:
        return abs(h[n-1]-h[n])
    else:
        a=abs(h[place]-h[place+2])+cost(place+2)
        b=abs(h[place]-h[place+1])+cost(place+1)
        return min(a,b)
print(cost(1))

Fixed submission:
import sys
sys.setrecursionlimit(20000000)
n=int(input())
h=list(map(int,input().split()))
memory={}
def cost(place):
    if place in memory:
        return memory[place]
    if place==n-1:
        return 0
    if place==n-2:
        return abs(h[n-2]-h[n-1])
    if place<=n-3:
        a=abs(h[place]-h[place+2])+cost(place+2)
        b=abs(h[place]-h[place+1])+cost(place+1)
        x=min(a,b)
        memory[place]=x
        return x
print(cost(0))

Buggy python submission (verdict: Runtime Error):
n=int(input())
x=[0]
h=list(map(int,input().split()))
h=x+h

def cost(place):
    if place==n:
        return 0
    elif place==n-1:
        return abs(h[n-1]-h[n])
    else:
        a=abs(h[place]-h[place+2])+cost(place+2)
        b=abs(h[place]-h[place+1])+cost(place+1)
        if a<b:
            return a
        else:
            return b
print(cost(1))


Fixed submission:
import sys
sys.setrecursionlimit(20000000)
n=int(input())
h=list(map(int,input().split()))
memory={}
def cost(place):
    if place in memory:
        return memory[place]
    if place==n-1:
        return 0
    if place==n-2:
        return abs(h[n-2]-h[n-1])
    if place<=n-3:
        a=abs(h[place]-h[place+2])+cost(place+2)
        b=abs(h[place]-h[place+1])+cost(place+1)
        x=min(a,b)
        memory[place]=x
        return x
print(cost(0))