stablegradients/pie-gem5-pairs huggingface dataset:
// Slower C++ solution:
#include<iostream>

#include<cstdio>

#include<string>

#include<cstring>

#include<algorithm>

#include<queue>

#include<stack>

#include<map>

#include<vector>

#include<set>

#include<list>

#define ll long long

using namespace std;

ll h[200050],dp[200050];

int main()

{

	ll n;

	cin>>n;

	for(int i=1;i<=n;i++)

		cin>>h[i];

	memset(dp,0,sizeof(dp));

	dp[2]=abs(h[2]-h[1]);

	for(int i=3;i<=n;i++)

		dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));

	cout<<dp[n]<<endl;

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 2.618458326556469x):
#include<iostream>

#include<cstdio>

#include<cmath>

#include<cstring>

#define Max(a,b) (a>b?a:b)

#define Min(a,b) (a<b?a:b)

using namespace std;

const int MAXN = 1e5+10, INF = 0x3f3f3f3f;

int A[MAXN], dp[MAXN], N;



int main()

{

	scanf("%d", &N);

	int i;

	for(i=1;i<=N;i++) scanf("%d", &A[i]), dp[i] = INF;

	dp[1] = 0;

	dp[2] = abs(A[1]-A[2]);

	for(i=3;i<=N;i++) {

		dp[i] = Min(dp[i], Min(dp[i-1]+abs(A[i]-A[i-1]), dp[i-2]+abs(A[i]-A[i-2])));

	}

	printf("%d\n", dp[N]);

	return 0;

}
// Slower C++ solution:
#include <bits/stdc++.h>



using namespace std;

const int maxn = 2e5+2;

const int mod = 1e9+7;

const int inf = 1e9;



typedef long long ll;



int n;

int arr[maxn], dp[maxn];



int solve_dp (int pos){

    if (pos > n) return inf;

    if (pos == n - 1) return 0;



    if (dp[pos] != -1) return dp[pos];



    int ans = inf;

    ans = min(ans, solve_dp(pos + 1) + abs(arr[pos + 1] - arr[pos]));

    ans = min(ans, solve_dp(pos + 2) + abs(arr[pos + 2] - arr[pos]));



    return dp[pos] = ans;

}



int main(){



    ios_base::sync_with_stdio(0);

    cin.tie(0); cout.tie(0);



    cin >> n;



    for (int i = 0; i < n; i++){

        cin >> arr[i];

    }



    memset(dp, -1, sizeof dp);



    cout << solve_dp(0) << "\n";



    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 1.827019289206229x):
#include<iostream>

#include<cstdio>

#include<cmath>

#include<cstring>

#define Max(a,b) (a>b?a:b)

#define Min(a,b) (a<b?a:b)

using namespace std;

const int MAXN = 1e5+10, INF = 0x3f3f3f3f;

int A[MAXN], dp[MAXN], N;



int main()

{

	scanf("%d", &N);

	int i;

	for(i=1;i<=N;i++) scanf("%d", &A[i]), dp[i] = INF;

	dp[1] = 0;

	dp[2] = abs(A[1]-A[2]);

	for(i=3;i<=N;i++) {

		dp[i] = Min(dp[i], Min(dp[i-1]+abs(A[i]-A[i-1]), dp[i-2]+abs(A[i]-A[i-2])));

	}

	printf("%d\n", dp[N]);

	return 0;

}
// Slower C++ solution:
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

#define abdelrahman010 ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

typedef long long ll;

using namespace std;

ll n , arr[100005] , memo[100005];

ll solve(ll i)

{

	if(i == n - 1)

		return 0;

	ll &ans = memo[i];

	if(~ans)

		return ans;

	ans = abs(arr[i] - arr[i + 1]) + solve(i + 1);

	if(i < n - 2)

		ans = min(ans , abs(arr[i] - arr[i + 2]) + solve(i + 2));

	return ans;

}

int main()

{

	abdelrahman010

	cin >> n;

	memset(memo , -1 , sizeof memo);

	for(int i = 0;i < n;i++)

		cin >> arr[i];

	cout << solve(0);

	return 0;

}


// Faster C++ solution for the same problem (measured speedup: 1.8240393364564016x):
#include<iostream>

#include<cstdio>

#include<cmath>

#include<cstring>

#define Max(a,b) (a>b?a:b)

#define Min(a,b) (a<b?a:b)

using namespace std;

const int MAXN = 1e5+10, INF = 0x3f3f3f3f;

int A[MAXN], dp[MAXN], N;



int main()

{

	scanf("%d", &N);

	int i;

	for(i=1;i<=N;i++) scanf("%d", &A[i]), dp[i] = INF;

	dp[1] = 0;

	dp[2] = abs(A[1]-A[2]);

	for(i=3;i<=N;i++) {

		dp[i] = Min(dp[i], Min(dp[i-1]+abs(A[i]-A[i-1]), dp[i-2]+abs(A[i]-A[i-2])));

	}

	printf("%d\n", dp[N]);

	return 0;

}
// Slower C++ solution:
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

typedef long long int lli;

typedef long double ld;

const int oo = 1e9;

const int mod = 1e9+9;

const int nax = 1e5+3;;



int n;;

int dp[nax];

int a[nax];

int f(int i){

	if (i==n-1)

             return 0;

	if(dp[i]!=-1) 

             return dp[i];

	int ans = abs(a[i]-a[i+1])+f(i+1);

	if(i!=n-2) 

             ans = min(ans, abs(a[i]-a[i+2])+f(i+2));

	return dp[i]=ans;

}

int main(){



	cin>>n;



	for(int i=0; i<n; i++) 

               cin>>a[i];;;

	memset(dp, -1, sizeof dp);



	cout<<f(0)<<endl;;

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 1.4076469295557374x):
#include<iostream>

#include<cstdio>

#include<cmath>

#include<cstring>

#define Max(a,b) (a>b?a:b)

#define Min(a,b) (a<b?a:b)

using namespace std;

const int MAXN = 1e5+10, INF = 0x3f3f3f3f;

int A[MAXN], dp[MAXN], N;



int main()

{

	scanf("%d", &N);

	int i;

	for(i=1;i<=N;i++) scanf("%d", &A[i]), dp[i] = INF;

	dp[1] = 0;

	dp[2] = abs(A[1]-A[2]);

	for(i=3;i<=N;i++) {

		dp[i] = Min(dp[i], Min(dp[i-1]+abs(A[i]-A[i-1]), dp[i-2]+abs(A[i]-A[i-2])));

	}

	printf("%d\n", dp[N]);

	return 0;

}
// Slower C++ solution:
#include <bits/stdc++.h>

using namespace std;

#define INF 100005

#define maxx 1000000000000



int n;

long long a[INF+5];

long long mem[INF];



long long rec(int pos)

{

    if(pos==n-1)

    {

        return 0;

    }

    if(mem[pos]!=-1) return mem[pos];

    long long tot=maxx;

    long long left=abs(a[pos]-a[pos+1]);

    long long right=abs(a[pos]-a[pos+2]);

    if(pos+1<n)

    {

        tot=min(tot,left+rec(pos+1));

    }

    if(pos+2<n)

    {

        tot=min(tot,right+rec(pos+2));

    }

    return mem[pos]=tot;

}



int main()

{

    memset(a,0,sizeof(a));

    memset(mem,-1,sizeof(mem));

    scanf("%d",&n);

    for(int i=0;i<n;i++)

    {

        scanf("%lld",&a[i]);

    }

    long long ans=rec(0);

    printf("%lld\n",ans);

}


// Faster C++ solution for the same problem (measured speedup: 2.5851042283813728x):
#include <iostream>

#include <vector>

#include <algorithm>

#include <stdio.h>

#include <map>

using namespace std;

#define min(a,b) (a>b?b:a);

int main(){

	int n;

	cin>>n;

	vector<int> path(n);

	for(int i=0;i<n;i++) cin>>path[i];

	vector<int> dp(n);

	dp[0]=0;

	dp[1]=abs(path[1]-path[0]);

	if(n==2){

		cout<<dp[1]<<endl;

		return 0;

	}

	for(int i=2;i<n;i++){

		dp[i]=min(abs(path[i]-path[i-1])+dp[i-1],abs(path[i]-path[i-2])+dp[i-2]);

	}

	cout<<dp[n-1]<<endl;

	return 0;

}
// Slower C++ solution:
// Created by ahmed_drawy on 10/09/19.

///dp educational contest atcoder - vjudge

#include <bits/stdc++.h>

#include <string.h>

#pragma clang diagnostic push

#pragma ide diagnostic ignored "OCUnusedMacroInspection"

using namespace std;

#define lp(i,start , end)       for(int i = start ; i<end ; ++i)

#define lllp(i,start , end)       for(ll i = start ; i<end ; ++i)

#define inN(arr ,  n) for(int i = 0 ; i< n ; ++i)  cin>>arr[i];

#define Rlp(i,start , end)      for(int i = start ; i>end ; --i)

#define all(v)                   ((v).begin(),(v).end())

#define sz(v)                  (int)((v).size())

#define clr(v,d)                memset(v , d , sizeof(v))

#define inf 0x3f3f3f3f

//#define dbg (v)    for(auto it : v)cout<<it<<' ';

typedef long long               ll;

typedef vector<int>             vi;

typedef vector  <ll>            vll;

typedef vector<vector<int> >    adj;

typedef pair<int ,int>          pii;

const double EPS =1e-7;

const int OO = 1e6;

#define endl '\n'

#define cint(c) (int)c -'0';

#define itc(c) (char)c +'A';

bool sortpair( const pair<int , int> & x, const pair<int , int> & y){

    return  x.first != y.first ? x.first < y.first : x.second > y.second ;

}

int dcomp(double x , double y){

    return fabs(x-y) <= EPS? 0: x>y?1:-1;

}



void smile() {

    ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);

#ifndef ONLINE_JUDGE

//    freopen("/home/tw3/Desktop/Desktop/training/in.txt", "r", stdin);

//    freopen("/home/tw3/Desktop/Desktop/training/out.txt" , "w" , stdout);

#endif

}

#define fastin smile()



int n ;

const int N = 1e5 +3;

ll dp[N];

int h[N];

//ll solve(int indx , int state){

//    if(indx == n-1 )return 0 ;

//    ll &ret = dp[indx  ] [ state];

//    if(~ret )

//        return ret;

//    ret=  INT_MAX;

//    for (int i = 1; i <=2 && i+indx < n ; ++i) {

//        ret = min(ret , abs(h[indx]  - h[indx+ i])+solve(indx + i , i ));

//    }

//    return ret ;

//}

int main() {

    fastin;

    cin >> n;

    inN(h,  n );

    clr(dp , 0);

    for (int j = 1; j <n ; ++j) {

        if(j>=2){

            dp[j] = min(dp[j-1] + abs(h[j-1] - h[j]) , abs(h[j-2] - h[j])+dp[j-2]);

        }

        else if(j ==1){

            dp[j] = abs(h[j] - h[j-1])+dp[j-1];

        }

    }

    cout << dp[n-1];

//

//    clr(dp , -1);

//    cout << solve(0, 1)<<endl;

}

// Faster C++ solution for the same problem (measured speedup: 1.8114587968605529x):
#include <iostream>

#include <vector>

#include <algorithm>

#include <stdio.h>

#include <map>

using namespace std;

#define min(a,b) (a>b?b:a);

int main(){

	int n;

	cin>>n;

	vector<int> path(n);

	for(int i=0;i<n;i++) cin>>path[i];

	vector<int> dp(n);

	dp[0]=0;

	dp[1]=abs(path[1]-path[0]);

	if(n==2){

		cout<<dp[1]<<endl;

		return 0;

	}

	for(int i=2;i<n;i++){

		dp[i]=min(abs(path[i]-path[i-1])+dp[i-1],abs(path[i]-path[i-2])+dp[i-2]);

	}

	cout<<dp[n-1]<<endl;

	return 0;

}
// Slower C++ solution:
#include<bits/stdc++.h>

using namespace std;

typedef long long int ll;

const int MAX=1e5+10;

int N,A[MAX],dp[MAX];

int solve(int idx)

{

    if(idx==N)return 0;

    if(idx>N)return 1e9;

    if(dp[idx]!=-1)return dp[idx];

    return dp[idx]=min(abs(A[idx+1]-A[idx])+solve(idx+1),abs(A[idx+2]-A[idx])+solve(idx+2));

}

int  main ()

{

    memset(dp,-1,sizeof dp);

    cin >> N;

    for(int i=1;i<=N;i++){

        cin >> A[i];

    }

    cout<<solve(1)<<endl;

    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 1.3932401383663184x):
#include <iostream>

#include <vector>

#include <algorithm>

#include <stdio.h>

#include <map>

using namespace std;

#define min(a,b) (a>b?b:a);

int main(){

	int n;

	cin>>n;

	vector<int> path(n);

	for(int i=0;i<n;i++) cin>>path[i];

	vector<int> dp(n);

	dp[0]=0;

	dp[1]=abs(path[1]-path[0]);

	if(n==2){

		cout<<dp[1]<<endl;

		return 0;

	}

	for(int i=2;i<n;i++){

		dp[i]=min(abs(path[i]-path[i-1])+dp[i-1],abs(path[i]-path[i-2])+dp[i-2]);

	}

	cout<<dp[n-1]<<endl;

	return 0;

}
// Slower C++ solution:
#include <bits/stdc++.h>

using namespace std;



#define mp make_pair

#define pb push_back

#define st first

#define nd second

#define lb lower_bound

#define ub upper_bound



typedef long long ll;

typedef long double ld;

typedef pair<int,int> pi;

typedef pair<ll,ll> pll;

typedef vector<int> vi;

typedef vector<ll> vll;

typedef vector<pi> vpi;

typedef vector<pll> vpll;



const ll oo=1e18;

const int MOD=1000000007;

const int INF=1000000000;

const ld EPS=0.000000001;



int dp[100005],h[100005],n,k=2;



signed main() {

    ios_base::sync_with_stdio(NULL);

    cin.tie(NULL);

    cout.tie(NULL);

    memset(dp,0x3f3f,sizeof dp);

    dp[1]=0;

    h[0]=0;

    cin>>n;

    for(int i=1;i<=n;++i) cin>>h[i];

    for(int i=2;i<=n;++i) {

        for(int j=1;j<=min(k,i);++j) {

            dp[i]=min(dp[i],dp[i-j]+abs(h[i]-h[i-j]));

        }

    }

    cout<<dp[n];

    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 1.4136321613943943x):
#include <iostream>

#include <vector>

#include <algorithm>

#include <stdio.h>

#include <map>

using namespace std;

#define min(a,b) (a>b?b:a);

int main(){

	int n;

	cin>>n;

	vector<int> path(n);

	for(int i=0;i<n;i++) cin>>path[i];

	vector<int> dp(n);

	dp[0]=0;

	dp[1]=abs(path[1]-path[0]);

	if(n==2){

		cout<<dp[1]<<endl;

		return 0;

	}

	for(int i=2;i<n;i++){

		dp[i]=min(abs(path[i]-path[i-1])+dp[i-1],abs(path[i]-path[i-2])+dp[i-2]);

	}

	cout<<dp[n-1]<<endl;

	return 0;

}
// Slower C++ solution:
#include<cstdio>

#include<iostream>

#include<cmath>

#include<stack>

#include<cstring>

#include<algorithm>

using namespace std;

int n;

int h[100005];

int dp[100005];



int main()

{

memset(dp, 0x3f ,sizeof dp);

scanf("%d",&n);

for( int i = 1 ; i <= n ; i++) scanf("%d",&h[i]);

dp[1] = 0;

for( int i = 1 ; i <= n ; i++)

{

	dp[i+1] = min(dp[i+1],dp[i]+abs(h[i] - h[i+1]));

	dp[i+2] = min(dp[i+2],dp[i]+abs(h[i] - h[i+2]));

}

printf("%d",dp[n]);



	return 0;

}






// Faster C++ solution for the same problem (measured speedup: 1.3887172287191518x):
#include <iostream>

#include <vector>

#include <algorithm>

#include <stdio.h>

#include <map>

using namespace std;

#define min(a,b) (a>b?b:a);

int main(){

	int n;

	cin>>n;

	vector<int> path(n);

	for(int i=0;i<n;i++) cin>>path[i];

	vector<int> dp(n);

	dp[0]=0;

	dp[1]=abs(path[1]-path[0]);

	if(n==2){

		cout<<dp[1]<<endl;

		return 0;

	}

	for(int i=2;i<n;i++){

		dp[i]=min(abs(path[i]-path[i-1])+dp[i-1],abs(path[i]-path[i-2])+dp[i-2]);

	}

	cout<<dp[n-1]<<endl;

	return 0;

}
// Slower C++ solution:
#include<iostream>

#include<cstdio>

#include<string>

#include<cstring>

#include<algorithm>

#include<queue>

#include<stack>

#include<map>

#include<vector>

#include<set>

#include<list>

#define ll long long

using namespace std;

ll h[200050],dp[200050];

int main()

{

	ll n;

	cin>>n;

	for(int i=1;i<=n;i++)

		cin>>h[i];

	memset(dp,0,sizeof(dp));

	dp[2]=abs(h[2]-h[1]);

	for(int i=3;i<=n;i++)

		dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));

	cout<<dp[n]<<endl;

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 2.6004191210119667x):
#include <iostream>

#include <vector>

#include <algorithm>

#include <stdio.h>

#include <map>

using namespace std;

#define min(a,b) (a>b?b:a);

int main(){

	int n;

	cin>>n;

	vector<int> path(n);

	for(int i=0;i<n;i++) cin>>path[i];

	vector<int> dp(n);

	dp[0]=0;

	dp[1]=abs(path[1]-path[0]);

	if(n==2){

		cout<<dp[1]<<endl;

		return 0;

	}

	for(int i=2;i<n;i++){

		dp[i]=min(abs(path[i]-path[i-1])+dp[i-1],abs(path[i]-path[i-2])+dp[i-2]);

	}

	cout<<dp[n-1]<<endl;

	return 0;

}
// Slower C++ solution:
#include <bits/stdc++.h>



using namespace std;

const int maxn = 2e5+2;

const int mod = 1e9+7;

const int inf = 1e9;



typedef long long ll;



int n;

int arr[maxn], dp[maxn];



int solve_dp (int pos){

    if (pos > n) return inf;

    if (pos == n - 1) return 0;



    if (dp[pos] != -1) return dp[pos];



    int ans = inf;

    ans = min(ans, solve_dp(pos + 1) + abs(arr[pos + 1] - arr[pos]));

    ans = min(ans, solve_dp(pos + 2) + abs(arr[pos + 2] - arr[pos]));



    return dp[pos] = ans;

}



int main(){



    ios_base::sync_with_stdio(0);

    cin.tie(0); cout.tie(0);



    cin >> n;



    for (int i = 0; i < n; i++){

        cin >> arr[i];

    }



    memset(dp, -1, sizeof dp);



    cout << solve_dp(0) << "\n";



    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 1.8144325024861576x):
#include <iostream>

#include <vector>

#include <algorithm>

#include <stdio.h>

#include <map>

using namespace std;

#define min(a,b) (a>b?b:a);

int main(){

	int n;

	cin>>n;

	vector<int> path(n);

	for(int i=0;i<n;i++) cin>>path[i];

	vector<int> dp(n);

	dp[0]=0;

	dp[1]=abs(path[1]-path[0]);

	if(n==2){

		cout<<dp[1]<<endl;

		return 0;

	}

	for(int i=2;i<n;i++){

		dp[i]=min(abs(path[i]-path[i-1])+dp[i-1],abs(path[i]-path[i-2])+dp[i-2]);

	}

	cout<<dp[n-1]<<endl;

	return 0;

}
// Slower C++ solution:
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

#define abdelrahman010 ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

typedef long long ll;

using namespace std;

ll n , arr[100005] , memo[100005];

ll solve(ll i)

{

	if(i == n - 1)

		return 0;

	ll &ans = memo[i];

	if(~ans)

		return ans;

	ans = abs(arr[i] - arr[i + 1]) + solve(i + 1);

	if(i < n - 2)

		ans = min(ans , abs(arr[i] - arr[i + 2]) + solve(i + 2));

	return ans;

}

int main()

{

	abdelrahman010

	cin >> n;

	memset(memo , -1 , sizeof memo);

	for(int i = 0;i < n;i++)

		cin >> arr[i];

	cout << solve(0);

	return 0;

}


// Faster C++ solution for the same problem (measured speedup: 1.8114730793661593x):
#include <iostream>

#include <vector>

#include <algorithm>

#include <stdio.h>

#include <map>

using namespace std;

#define min(a,b) (a>b?b:a);

int main(){

	int n;

	cin>>n;

	vector<int> path(n);

	for(int i=0;i<n;i++) cin>>path[i];

	vector<int> dp(n);

	dp[0]=0;

	dp[1]=abs(path[1]-path[0]);

	if(n==2){

		cout<<dp[1]<<endl;

		return 0;

	}

	for(int i=2;i<n;i++){

		dp[i]=min(abs(path[i]-path[i-1])+dp[i-1],abs(path[i]-path[i-2])+dp[i-2]);

	}

	cout<<dp[n-1]<<endl;

	return 0;

}
// Slower C++ solution:
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

typedef long long int lli;

typedef long double ld;

const int oo = 1e9;

const int mod = 1e9+9;

const int nax = 1e5+3;;



int n;;

int dp[nax];

int a[nax];

int f(int i){

	if (i==n-1)

             return 0;

	if(dp[i]!=-1) 

             return dp[i];

	int ans = abs(a[i]-a[i+1])+f(i+1);

	if(i!=n-2) 

             ans = min(ans, abs(a[i]-a[i+2])+f(i+2));

	return dp[i]=ans;

}

int main(){



	cin>>n;



	for(int i=0; i<n; i++) 

               cin>>a[i];;;

	memset(dp, -1, sizeof dp);



	cout<<f(0)<<endl;;

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 1.3979493025059546x):
#include <iostream>

#include <vector>

#include <algorithm>

#include <stdio.h>

#include <map>

using namespace std;

#define min(a,b) (a>b?b:a);

int main(){

	int n;

	cin>>n;

	vector<int> path(n);

	for(int i=0;i<n;i++) cin>>path[i];

	vector<int> dp(n);

	dp[0]=0;

	dp[1]=abs(path[1]-path[0]);

	if(n==2){

		cout<<dp[1]<<endl;

		return 0;

	}

	for(int i=2;i<n;i++){

		dp[i]=min(abs(path[i]-path[i-1])+dp[i-1],abs(path[i]-path[i-2])+dp[i-2]);

	}

	cout<<dp[n-1]<<endl;

	return 0;

}
// Slower C++ solution:
#include <bits/stdc++.h>



using namespace std;





int main()

{

	int n;

	cin >> n;



	vector<int> h(n), dp(n, 1 << 30);    



	for(int &x : h)

		cin >> x;



	dp[0] = 0;

	for(int i = 1; i < n; i++)

	{

		for(int j = 1; j <= min(i, 2); j++)

			dp[i] = min(dp[i], dp[i - j] + abs(h[i] - h[i - j]));

	}



	cout << dp[n - 1] << endl;



}

// Faster C++ solution for the same problem (measured speedup: 1.695463850144656x):
#include<stdio.h>

#include<cmath>

#include<algorithm>

using namespace std;

const int maxn = 100005;

const int INF = 1000000000;



int A[maxn];//石头高度

int dp[maxn] = {0}; 

int n;



int main(){

//	freopen("4.txt","r",stdin);

	scanf("%d",&n);

	fill(dp,dp+maxn,INF);

	

	for(int i=1;i<=n;i++){

		scanf("%d\n",&A[i]);

	}

	dp[1] = 0;

	for(int i=2;i<=n;i++){//跳到i上 

		int j1 = i-2, j2 = i-1;

		if(j1>=1){//

			dp[i] = min(dp[i] , dp[j1] + abs(A[i]-A[j1]));

		}

		if(j2>=1){//

			dp[i] = min(dp[i] , dp[j2] + abs(A[i]-A[j2]));

		}

	}

	printf("%d\n", dp[n]);

	

	return 0;

}
// Slower C++ solution:
#include <iostream>

#include <vector>

#include <algorithm>

#include <numeric>

#include <cmath>

#include <set>

#include <tuple>

#include <functional>

#include <map>

#include <unordered_map>

#include <queue>

#include <tuple>



using namespace std;



#define endl '\n'



using ull = unsigned long int;

using ll = long long;



int main() {

  ios_base::sync_with_stdio(false);

  cin.tie(nullptr);

  const int precision = 13;

  cout.precision(precision);

  cout.setf(ios_base::fixed);



  int n; cin >> n;

  vector<ll> s(3), dp(3);



  cin >> s[1];

  cin >> s[2];



  dp[2] = abs(s[2] - s[1]);



  for (int i = 3; i <= n; ++i) {

    cin >> s[i%3];

    dp[i%3] = min(dp[(i-1)%3] + abs(s[(i-1)%3] - s[i%3]), dp[(i-2)%3] + abs(s[i%3] - s[(i-2)%3]));

  }



  cout << dp[n%3] << endl;



  return 0;

}


// Faster C++ solution for the same problem (measured speedup: 1.7332191695091095x):
#include<stdio.h>

#include<cmath>

#include<algorithm>

using namespace std;

const int maxn = 100005;

const int INF = 1000000000;



int A[maxn];//石头高度

int dp[maxn] = {0}; 

int n;



int main(){

//	freopen("4.txt","r",stdin);

	scanf("%d",&n);

	fill(dp,dp+maxn,INF);

	

	for(int i=1;i<=n;i++){

		scanf("%d\n",&A[i]);

	}

	dp[1] = 0;

	for(int i=2;i<=n;i++){//跳到i上 

		int j1 = i-2, j2 = i-1;

		if(j1>=1){//

			dp[i] = min(dp[i] , dp[j1] + abs(A[i]-A[j1]));

		}

		if(j2>=1){//

			dp[i] = min(dp[i] , dp[j2] + abs(A[i]-A[j2]));

		}

	}

	printf("%d\n", dp[n]);

	

	return 0;

}
// Slower C++ solution:
#include <bits/stdc++.h>

using namespace std;

#define INF 100005

#define maxx 1000000000000



int n;

long long a[INF+5];

long long mem[INF];



long long rec(int pos)

{

    if(pos==n-1)

    {

        return 0;

    }

    if(mem[pos]!=-1) return mem[pos];

    long long tot=maxx;

    long long left=abs(a[pos]-a[pos+1]);

    long long right=abs(a[pos]-a[pos+2]);

    if(pos+1<n)

    {

        tot=min(tot,left+rec(pos+1));

    }

    if(pos+2<n)

    {

        tot=min(tot,right+rec(pos+2));

    }

    return mem[pos]=tot;

}



int main()

{

    memset(a,0,sizeof(a));

    memset(mem,-1,sizeof(mem));

    scanf("%d",&n);

    for(int i=0;i<n;i++)

    {

        scanf("%lld",&a[i]);

    }

    long long ans=rec(0);

    printf("%lld\n",ans);

}


// Faster C++ solution for the same problem (measured speedup: 4.383664749250709x):
#include<stdio.h>

#include<cmath>

#include<algorithm>

using namespace std;

const int maxn = 100005;

const int INF = 1000000000;



int A[maxn];//石头高度

int dp[maxn] = {0}; 

int n;



int main(){

//	freopen("4.txt","r",stdin);

	scanf("%d",&n);

	fill(dp,dp+maxn,INF);

	

	for(int i=1;i<=n;i++){

		scanf("%d\n",&A[i]);

	}

	dp[1] = 0;

	for(int i=2;i<=n;i++){//跳到i上 

		int j1 = i-2, j2 = i-1;

		if(j1>=1){//

			dp[i] = min(dp[i] , dp[j1] + abs(A[i]-A[j1]));

		}

		if(j2>=1){//

			dp[i] = min(dp[i] , dp[j2] + abs(A[i]-A[j2]));

		}

	}

	printf("%d\n", dp[n]);

	

	return 0;

}