Buggy python submission (verdict: Runtime Error):
#include<bits/stdc++.h>
using namespace std;
int dp[10000001];
int arr[10000001];
int n;
int solve(int ind)
{
	if(ind==n-1)
	{
		return 0;
	}
	if(dp[ind]!=-1)
	{
		return dp[ind];
	}
	int ans=solve(ind+1)+abs(arr[ind+1]-arr[ind]);
	if(ind+2<n)
	{
		ans=min(ans,solve(ind+2)+abs(arr[ind+2]-arr[ind]));
	}
	return dp[ind]=ans;
}
int main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
#endif
	memset(dp,-1,sizeof(dp));
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>arr[i];
	}
	cout<<solve(0)<<"\n";
	return 0;
}

Fixed submission:
n=int(input())
l=list(map(int,input().split()))
dp=[10**55 for i in range(n)]
dp[0]=0
dp[1]=abs(l[1]-l[0])
for i in range(2,n):
    dp[i] = min(dp[i], dp[i-1] + abs(l[i] - l[i - 1]))
    dp[i] = min(dp[i], dp[i-2] + abs(l[i] - l[i - 2]))
print(dp[n-1])

Buggy python submission (verdict: Runtime Error):
n=int(input())
l=[-1 for i in range(10000001)]
dp=[-1 for i in range(10000001)]
def solve(ind):
    if(ind==n-1):
        return 0
    if(dp[ind]!=-1):
        return dp[ind]
    ans=solve(ind+1)+abs(l[ind+1]-l[ind])
    if(ind+2<n):
        ans=min(ans,solve(ind+2)+abs(l[ind+2]-l[ind]))
    dp[ind]=ans
    return dp[ind]
lst=list(map(int,input().split()))
for i in range(n):
    l[i]=lst[i]
print(solve(0))

Fixed submission:
n=int(input())
l=list(map(int,input().split()))
dp=[10**55 for i in range(n)]
dp[0]=0
dp[1]=abs(l[1]-l[0])
for i in range(2,n):
    dp[i] = min(dp[i], dp[i-1] + abs(l[i] - l[i - 1]))
    dp[i] = min(dp[i], dp[i-2] + abs(l[i] - l[i - 2]))
print(dp[n-1])

Buggy python submission (verdict: Runtime Error):
n=int(input())
l=list(map(int,input().split()))
dp=[-1 for i in range(10000001)]
def solve(ind):
    if(ind==n-1):
        return 0
    if(dp[ind]!=-1):
        return dp[ind]
    ans=solve(ind+1)+abs(l[ind+1]-l[ind])
    if(ind+2<n):
        ans=min(ans,solve(ind+2)+abs(l[ind+2]-l[ind]))
    dp[ind]=ans
    return dp[ind]
print(solve(0))

Fixed submission:
n=int(input())
l=list(map(int,input().split()))
dp=[10**55 for i in range(n)]
dp[0]=0
dp[1]=abs(l[1]-l[0])
for i in range(2,n):
    dp[i] = min(dp[i], dp[i-1] + abs(l[i] - l[i - 1]))
    dp[i] = min(dp[i], dp[i-2] + abs(l[i] - l[i - 2]))
print(dp[n-1])

Buggy python submission (verdict: Runtime Error):
n=int(input())
l=list(map(int,input().split()))
dp=[-1 for i in range(1000000)]
def solve(ind):
    if(ind==n-1):
        return 0
    if(dp[ind]!=-1):
        return dp[ind]
    ans=solve(ind+1)+abs(l[ind+1]-l[ind])
    if(ind+2<n):
        ans=min(ans,solve(ind+2)+abs(l[ind+2]-l[ind]))
    dp[ind]=ans
    return dp[ind]
print(solve(0))

Fixed submission:
n=int(input())
l=list(map(int,input().split()))
dp=[10**55 for i in range(n)]
dp[0]=0
dp[1]=abs(l[1]-l[0])
for i in range(2,n):
    dp[i] = min(dp[i], dp[i-1] + abs(l[i] - l[i - 1]))
    dp[i] = min(dp[i], dp[i-2] + abs(l[i] - l[i - 2]))
print(dp[n-1])

Buggy python submission (verdict: Runtime Error):
n=int(input())
l=list(map(int,input().split()))
dp=[-1 for i in range(n)]
def solve(ind):
    if(ind==n-1):
        return 0
    if(dp[ind]!=-1):
        return dp[ind]
    ans=solve(ind+1)+abs(l[ind+1]-l[ind])
    if(ind+2<n):
        ans=min(ans,solve(ind+2)+abs(l[ind+2]-l[ind]))
    dp[ind]=ans
    return dp[ind]
print(solve(0))

Fixed submission:
n=int(input())
l=list(map(int,input().split()))
dp=[10**55 for i in range(n)]
dp[0]=0
dp[1]=abs(l[1]-l[0])
for i in range(2,n):
    dp[i] = min(dp[i], dp[i-1] + abs(l[i] - l[i - 1]))
    dp[i] = min(dp[i], dp[i-2] + abs(l[i] - l[i - 2]))
print(dp[n-1])

Buggy python submission (verdict: Runtime Error):
n=int(input())
l=list(map(int,input().split()))
dp=[10**55 for i in range(n)]
dp[0]=0
dp[1]=abs(l[1]-l[0])
for i in range(2,n):
    dp[i] = min(dp[i], dp[i-1] + abs(l[i] - l[i - 1]))
    dp[i] = min(dp[i], dp[i-2] + abs(l[i] - l[i - 2]))
    print(dp)
print(dp[n-1])



Fixed submission:
n=int(input())
l=list(map(int,input().split()))
dp=[10**55 for i in range(n)]
dp[0]=0
dp[1]=abs(l[1]-l[0])
for i in range(2,n):
    dp[i] = min(dp[i], dp[i-1] + abs(l[i] - l[i - 1]))
    dp[i] = min(dp[i], dp[i-2] + abs(l[i] - l[i - 2]))
print(dp[n-1])

Buggy python submission (verdict: Runtime Error):
n=int(input())
l=list(map(int,input().split()))
dp=[10**55 for i in range(n)]
dp[0]=0
dp[1]=abs(l[1]-l[0])
for i in range(n):
    dp[i] = min(dp[i], dp[i-1] + abs(l[i] - l[i - 1]))
    dp[i] = min(dp[i], dp[i-2] + abs(l[i] - l[i - 2]))
    print(dp)
print(dp[n-1])



Fixed submission:
n=int(input())
l=list(map(int,input().split()))
dp=[10**55 for i in range(n)]
dp[0]=0
dp[1]=abs(l[1]-l[0])
for i in range(2,n):
    dp[i] = min(dp[i], dp[i-1] + abs(l[i] - l[i - 1]))
    dp[i] = min(dp[i], dp[i-2] + abs(l[i] - l[i - 2]))
print(dp[n-1])