Buggy python submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10**5)

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

cost_list={}

def cost(k):
    if k==0:
        result=0
        cost_list[k]=result
    elif k==1:
        result=abs(H[1]-H[0])
        cost_list[k]=result
    elif k in cost_list:
        result=cost_list[k]
    else:
        result=min(cost(k-1)+abs(H[k]-H[k-1]),cost(k-2)+abs(H[k]-H[k-2]))
        cost_list[k]=result
    
    return result

print(cost(N-1))



Fixed submission:
import sys
sys.setrecursionlimit(10**6)

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

cost_list=[0 for _ in range(N)]

cost_list[1]=abs(H[1]-H[0])

if N==2:
    print(cost_list[1])

else:
    for k in range(2,N):
        cost_list[k]=min(cost_list[k-1]+abs(H[k]-H[k-1]),cost_list[k-2]+abs(H[k]-H[k-2]))

    print(cost_list[N-1])

Buggy python submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10**5)

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

cost_list={}

def cost(k):
    if k==0:
        result=0
        cost_list[k]=result
    elif k==1:
        result=abs(H[1]-H[0])
        cost_list[k]=result
    elif k in cost_list:
        result=cost_list[k]
    else:
        result=min(cost(k-1)+abs(H[k]-H[k-1]),cost(k-2)+abs(H[k]-H[k-2]))
        cost_list[k]=result
    
    return result

print(cost(N-1))



Fixed submission:
import sys
sys.setrecursionlimit(10**6)

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

cost_list=[0 for _ in range(N)]

cost_list[1]=abs(H[1]-H[0])

if N==2:
    print(cost_list[1])

else:
    for k in range(2,N):
        cost_list[k]=min(cost_list[k-1]+abs(H[k]-H[k-1]),cost_list[k-2]+abs(H[k]-H[k-2]))

    print(cost_list[N-1])

Buggy python submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10**5)

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

cost_list=[0 for _ in range(N)]

def cost(k):
    if k==0:
        result=0
    elif k==1:
        result=abs(H[1]-H[0])
    elif cost_list[k]>0:
        result=cost_list[k]
    else:
        result=min(cost(k-1)+abs(H[k]-H[k-1]),cost(k-2)+abs(H[k]-H[k-2]))
        cost_list[k]=result
    
    return result

print(cost(N-1))



Fixed submission:
import sys
sys.setrecursionlimit(10**6)

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

cost_list=[0 for _ in range(N)]

cost_list[1]=abs(H[1]-H[0])

if N==2:
    print(cost_list[1])

else:
    for k in range(2,N):
        cost_list[k]=min(cost_list[k-1]+abs(H[k]-H[k-1]),cost_list[k-2]+abs(H[k]-H[k-2]))

    print(cost_list[N-1])

Buggy python submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10**5)

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

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

print(cost(N-1))



Fixed submission:
import sys
sys.setrecursionlimit(10**6)

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

cost_list=[0 for _ in range(N)]

cost_list[1]=abs(H[1]-H[0])

if N==2:
    print(cost_list[1])

else:
    for k in range(2,N):
        cost_list[k]=min(cost_list[k-1]+abs(H[k]-H[k-1]),cost_list[k-2]+abs(H[k]-H[k-2]))

    print(cost_list[N-1])

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

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

print(cost(N-1))



Fixed submission:
import sys
sys.setrecursionlimit(10**6)

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

cost_list=[0 for _ in range(N)]

cost_list[1]=abs(H[1]-H[0])

if N==2:
    print(cost_list[1])

else:
    for k in range(2,N):
        cost_list[k]=min(cost_list[k-1]+abs(H[k]-H[k-1]),cost_list[k-2]+abs(H[k]-H[k-2]))

    print(cost_list[N-1])