Buggy python submission (verdict: Runtime Error):
/* Author - thiolhub */

#include <bits/stdc++.h>

using namespace std;

#define ll              long long int
#define ld              long double
#define db              double
#define pi              3.1415926535897932384626
#define PI              acos(-1.0)
#define endl            "\n"
#define mod             1000000007
#define mk              make_pair
#define pb              push_back
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define ps(x,y)         fixed<<setprecision(y)<<x
#define w(t)            ll t; cin>>t; while(t--)
#define sc(a)	        scanf("%lld",&a);
#define pr(a)	        printf("%lld\n",a)
#define f(i,a,n)		for(ll i=a;i<n;i++)
#define m(a)		    memset(a,0,sizeof(a))
#define FastIO          ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0)



int main(){ FastIO;

int n,i,j,k;cin>>n;
int a[n]; for(i=0;i<n;i++) cin>>a[i];
int dp[n+1];
for(i=0;i<n;i++) dp[i]=INT_MAX;
dp[0]=0;
for(i=0;i<n-1;i++)
{
	dp[i+1]=min(abs(a[i+1]-a[i])+dp[i],dp[i+1]);
	dp[i+2]=min(abs(a[i+2]-a[i])+dp[i],dp[i+2]);
}
cout<<dp[n-1];

return 0;
}


Fixed submission:
def rec(a):
    dp=[0]*len(a)
    for i in range(len(a)):
        if i==0:
            dp[i]=0
        elif i==1:
            dp[i]=abs(a[i]-a[i-1])
        else:
            dp[i]=min(abs(a[i]-a[i-1])+dp[i-1],abs(a[i]-a[i-2])+dp[i-2])
    return dp[len(a)-1]
n=int(input())
a=[int(i) for i in input().split()]
print(rec(a))

Buggy python submission (verdict: Runtime Error):
inf=10**10
def rec(n):
    if dp[n-1]!=inf:
        return dp[n-1]
    if n==1:
        dp[n-1]=0
        return dp[n-1]
    elif n==2:
        dp[n-1]=abs(a[n-1]-a[n-2])+rec(n-1)
        return dp[n-1]
    else:
        dp[n-1]=min(abs(a[n-1]-a[n-2])+rec(n-1),abs(a[n-1]-a[n-3])+rec(n-2))
        return dp[n-1]
           
n=int(input())
a=[int(i) for i in input().split()]
dp=[inf]*len(a)
print(rec(len(a)))

Fixed submission:
def rec(a):
    dp=[0]*len(a)
    for i in range(len(a)):
        if i==0:
            dp[i]=0
        elif i==1:
            dp[i]=abs(a[i]-a[i-1])
        else:
            dp[i]=min(abs(a[i]-a[i-1])+dp[i-1],abs(a[i]-a[i-2])+dp[i-2])
    return dp[len(a)-1]
n=int(input())
a=[int(i) for i in input().split()]
print(rec(a))

Buggy python submission (verdict: Runtime Error):
from math import inf
def rec(n):
    if dp[n-1]!=inf:
        return dp[n-1]
    if n==1:
        dp[n-1]=0
        return dp[n-1]
    if n<1:
        return inf
    if n==2:
        dp[n-1]=abs(a[n-1]-a[n-2])+rec(n-1)
        return dp[n-1]
    else:
        dp[n-1]=min(abs(a[n-1]-a[n-2])+rec(n-1),abs(a[n-1]-a[n-3])+rec(n-2))
        return dp[n-1]
           
n=int(input())
a=[int(i) for i in input().split()]
dp=[inf]*len(a)
print(rec(len(a)))

Fixed submission:
def rec(a):
    dp=[0]*len(a)
    for i in range(len(a)):
        if i==0:
            dp[i]=0
        elif i==1:
            dp[i]=abs(a[i]-a[i-1])
        else:
            dp[i]=min(abs(a[i]-a[i-1])+dp[i-1],abs(a[i]-a[i-2])+dp[i-2])
    return dp[len(a)-1]
n=int(input())
a=[int(i) for i in input().split()]
print(rec(a))