stablegradients/pie-gem5-pairs huggingface dataset:
// Slower C++ solution:
#include <bits/stdc++.h>

using namespace std;

const int nax = 1e5+3;

int number;

int dyn[nax];

int a[nax];

int op1(int i){

	if (i==number-1) return 0;

	if(dyn[i]!=-1) return dyn[i];

	int res = abs(a[i]-a[i+1])+op1(i+1);

	if(i!=number-2) res = min(res, abs(a[i]-a[i+2])+op1(i+2));

	return dyn[i]=res;

}

int main(){

	cin>>number;

	for(int i=0; i<number; i++) cin>>a[i];

	memset(dyn, -1, sizeof dyn);

	cout<<op1(0)<<endl;

	return 0;

}


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

    #include <cstdio>

    #include <cstring>

    #include <algorithm>

    #include <stack>

    #include <string>

    #include <cstring>

    #include <cmath>

    #include <vector>

    #include <set>

    #define INF  0x3f3f3f3f;

    #define maxn 1000605

    typedef long long LL;

    using namespace std;

    int h[100005];

    int d[100005];

    int get_min(int a,int b){

        if(a<b)

            return a;

        else

            return b;

    }



    int main(){

        int n;

        while(cin>>n){

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

                cin>>h[i];

            d[1]=0;

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

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

                d[i]=get_min(d[i-1]+abs(h[i]-h[i-1]),d[i-2]+abs(h[i]-h[i-2]));

            }

            cout<<d[n]<<endl;

        }

        return 0;

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

using namespace std;

int n, arr[100005], best, memo[100005];



int dp(int x){

	if(x==1 || x == 0){

		return 0;

	}

	if (x == 2){

		return abs(arr[x] - arr[x-1]);

	}

	if (memo[x] != -1){

		return memo[x];

	}

	best=min(dp(x-1)+abs(arr[x]-arr[x-1]), dp(x-2)+abs(arr[x-2]-arr[x]));

	memo[x] = best;

	return best;

}



int main(){

	ios_base::sync_with_stdio(0);

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

	cin.tie();

	cout.tie();

	cin >> n;

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

		cin >> arr[i];

	}

	cout << dp(n) << endl;

}

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

    #include <cstdio>

    #include <cstring>

    #include <algorithm>

    #include <stack>

    #include <string>

    #include <cstring>

    #include <cmath>

    #include <vector>

    #include <set>

    #define INF  0x3f3f3f3f;

    #define maxn 1000605

    typedef long long LL;

    using namespace std;

    int h[100005];

    int d[100005];

    int get_min(int a,int b){

        if(a<b)

            return a;

        else

            return b;

    }



    int main(){

        int n;

        while(cin>>n){

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

                cin>>h[i];

            d[1]=0;

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

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

                d[i]=get_min(d[i-1]+abs(h[i]-h[i-1]),d[i-2]+abs(h[i]-h[i-2]));

            }

            cout<<d[n]<<endl;

        }

        return 0;

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

using namespace std;

int n, arr[100005], best, memo[100005];



int dp(int x){

	if(x==0 or x==1){

		return 0;

	}

	else if(x==2){

		return dp(x-1)+abs(arr[x]-arr[x-1]);

	}

	else if(memo[x]!=-1){

		return memo[x];

	}

	best=min(dp(x-1)+abs(arr[x]-arr[x-1]), dp(x-2)+abs(arr[x-2]-arr[x]));

	memo[x]=best;

	return best;

}



int main(){

	ios_base::sync_with_stdio(0);

	cin.tie();

	cout.tie();

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

	cin >> n;

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

		cin >> arr[i];

	}

	cout << dp(n) << endl;

}


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

    #include <cstdio>

    #include <cstring>

    #include <algorithm>

    #include <stack>

    #include <string>

    #include <cstring>

    #include <cmath>

    #include <vector>

    #include <set>

    #define INF  0x3f3f3f3f;

    #define maxn 1000605

    typedef long long LL;

    using namespace std;

    int h[100005];

    int d[100005];

    int get_min(int a,int b){

        if(a<b)

            return a;

        else

            return b;

    }



    int main(){

        int n;

        while(cin>>n){

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

                cin>>h[i];

            d[1]=0;

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

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

                d[i]=get_min(d[i-1]+abs(h[i]-h[i-1]),d[i-2]+abs(h[i]-h[i-2]));

            }

            cout<<d[n]<<endl;

        }

        return 0;

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

using namespace std;

int dif(int a, int b)

{

    int ans=a-b;

    if(ans<0) ans*=-1;

    return ans;

}

int main()

{

    ios_base::sync_with_stdio(false);

    cin.tie(NULL);

    int N, h[100005],i,j;

    int f1,f2;

    cin>>N;

    for(i=0;i<N;i++)

        cin>>h[i];

    int M[100005]={0};

    M[N-2]=dif(h[N-1],h[N-2]);

    for(i=N-3;i>=0;i--)

    {

        f1=dif(h[i+1],h[i])+M[i+1];

        f2=dif(h[i+2],h[i])+M[i+2];

        M[i]=min(f1,f2);

    }

    cout<<M[0]<<endl;

    return 0;

}


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

#include<stdlib.h>

#include<string.h>

#include<algorithm>

int h[100000];

int dp[100000];

int main()

{

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

	int n,temp,dp1,dp2;

	scanf("%d", &n);

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

	{

		scanf("%d", &temp);

		h[i] = temp;

	}

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

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

	{

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

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

		dp[i] = dp1 < dp2 ? dp1 : dp2;

	}

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

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

#include<string.h>

#include<time.h>

#include<math.h>

#include<stdlib.h>

#include<iostream>

#include<iomanip>

#include<utility>

#include<algorithm>

#include<stack>

#include<queue>

#include<map>

#include<set>

#define ll long long

#define fi first

#define sec second

#define pb push_back

#define mp make_pair

#define rep(a,b,c) for(int a=1;a<=b;a+=c)

#define repp(a,b,c,d) for(int a=b;a<=c;a+=d)



const double PI=acos(-1);

const double EPS=1e-12;

const int MOD=1e9+7;

const int INF=1<<30;





using namespace std;



int dat[100005];

int minn[100005];



int main(){

	int in;

	cin>>in;

	rep(i,in,1){

		cin>>dat[i];

	}

	for(int i=in-1;i>=1;i--){

		if(i==in-1){

			minn[i]+=abs(dat[i]-dat[i+1]);

		}

		else{

			minn[i]+=min(abs(dat[i]-dat[i+1])+minn[i+1],abs(dat[i]-dat[i+2])+minn[i+2]);

		}

	}

	cout<<minn[1]<<endl;	

	return 0;

}

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

#include<stdlib.h>

#include<string.h>

#include<algorithm>

int h[100000];

int dp[100000];

int main()

{

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

	int n,temp,dp1,dp2;

	scanf("%d", &n);

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

	{

		scanf("%d", &temp);

		h[i] = temp;

	}

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

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

	{

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

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

		dp[i] = dp1 < dp2 ? dp1 : dp2;

	}

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

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

#define ll long long

using namespace std;



int main(){

    ll n,a[100009],dp[100009],k;

    cin >> n ;

    k=2;

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

    dp[n]=0;

    for(int i=n-1; i>=1; i--){

        ll z=1e15;

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

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

        }

        dp[i]=z;

    }

    cout << dp[1] << endl;

}




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

#include<stdlib.h>

#include<string.h>

#include<algorithm>

int h[100000];

int dp[100000];

int main()

{

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

	int n,temp,dp1,dp2;

	scanf("%d", &n);

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

	{

		scanf("%d", &temp);

		h[i] = temp;

	}

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

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

	{

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

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

		dp[i] = dp1 < dp2 ? dp1 : dp2;

	}

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

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

using namespace std;



int main(){

	long long a[100000], b[100000], n;

	scanf("%lld", &n);

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

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

	b[1]=abs(a[0]-a[1]);

	b[2]=abs(a[0]-a[2]);

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

		b[i] = min(b[i-1] + abs(a[i] - a[i-1]), b[i-2] + abs(a[i] - a[i-2]));

	}

	printf("%lld", b[n-1]);

}


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

#include<stdlib.h>

#include<string.h>

#include<algorithm>

int h[100000];

int dp[100000];

int main()

{

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

	int n,temp,dp1,dp2;

	scanf("%d", &n);

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

	{

		scanf("%d", &temp);

		h[i] = temp;

	}

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

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

	{

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

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

		dp[i] = dp1 < dp2 ? dp1 : dp2;

	}

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

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



long long absdif(long long a, long long b){

	return ( a > b ) ? a-b: b-a;

}



int main(){

	int N;

	std::vector<long long> h, dp;

	std::cin >> N;

	h.resize(N);

	dp.resize(N+1);

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

		std::cin >> h[i];

	}



	dp[0] = 0;

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

		dp[i] = 1e9+9;

		if( i-1 >= 0 )

			dp[i] = std::min(dp[i], dp[i-1] + absdif(h[i], h[i-1]) );

		if( i-2 >= 0 )

			dp[i] = std::min(dp[i], dp[i-2] + absdif(h[i], h[i-2]) );

	}

	std::cout << dp[N-1] << '\n';

	return 0;

}

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

#include<stdlib.h>

#include<string.h>

#include<algorithm>

int h[100000];

int dp[100000];

int main()

{

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

	int n,temp,dp1,dp2;

	scanf("%d", &n);

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

	{

		scanf("%d", &temp);

		h[i] = temp;

	}

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

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

	{

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

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

		dp[i] = dp1 < dp2 ? dp1 : dp2;

	}

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

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

#include<iostream>

#include<algorithm>

#include<queue>

#define inf 0x3f3f3f3f

using namespace std;

typedef long long LL;

const int maxn = 1e5+5;



int a[maxn],dp[maxn];



int main(){

	int n;

	scanf("%d",&n);

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

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

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

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

	}

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

}

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

#include<stdlib.h>

#include<string.h>

#include<algorithm>

int h[100000];

int dp[100000];

int main()

{

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

	int n,temp,dp1,dp2;

	scanf("%d", &n);

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

	{

		scanf("%d", &temp);

		h[i] = temp;

	}

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

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

	{

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

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

		dp[i] = dp1 < dp2 ? dp1 : dp2;

	}

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

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

using namespace std;

int n;

int h[1000005], memo[1000005];

int f(int n) {

    if(n == 1) {                        // bisa juga base case nya n = 0, f(0) harus tinggi, misal 1e9;

        return 0;

    }

    if(n == 2) {

        return abs(h[1] - h[2]);

    } 

    else if(memo[n] != -1) {

        return memo[n];

    }

    memo[n] = min(f(n - 1) + abs(h[n] - h[n - 1]), f(n - 2) + abs(h[n] - h[n - 2]));

    return memo[n];

}



int main() {

    scanf("%d", &n);

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

        scanf("%d", &h[i]);

    }

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

    f(n);

    printf("%d\n", f(n));

}

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

#include<stdlib.h>

#include<string.h>

#include<algorithm>

int h[100000];

int dp[100000];

int main()

{

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

	int n,temp,dp1,dp2;

	scanf("%d", &n);

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

	{

		scanf("%d", &temp);

		h[i] = temp;

	}

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

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

	{

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

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

		dp[i] = dp1 < dp2 ? dp1 : dp2;

	}

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

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

using namespace std;

#define db(x) cerr<<__LINE__<<": "<<#x<<" = "<<(x)<<'\n'

const int N = 1e6;

const int inf = 1e9;



int main(){

	ios_base::sync_with_stdio(0);

	int a,b,n,T,cas=0;

	cin>>n;

	vector<int> A(n);

	for(int &x: A) {

		cin>>x;

	}

	vector<int> dp(n, inf);

	dp[0]=0;

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

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

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

		}

	}

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

	return 0;

}

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

#include<stdlib.h>

#include<string.h>

#include<algorithm>

int h[100000];

int dp[100000];

int main()

{

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

	int n,temp,dp1,dp2;

	scanf("%d", &n);

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

	{

		scanf("%d", &temp);

		h[i] = temp;

	}

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

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

	{

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

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

		dp[i] = dp1 < dp2 ? dp1 : dp2;

	}

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

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

using namespace std;

const int N = 2e5 + 100;

#define pb push_back

#define mp make_pair

#define f first

#define s second

#define ull unsigned long long

#define ll long long

#define pii pair <int,int>

#define forn(l,i,n) for(int i = l;i <= n;++i)   

#define FOR(l,i,n) for(int i = l;i < n;++i)

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

#define pll pair <ll,ll>

const ll inf = 1e9 + 7;

const ll ll_inf = 1e17 + 100;   

const double pi = 3.14159265358979323;

inline void fr(){

    freopen("gcd.in", "r", stdin);

    freopen("gcd.out", "w", stdout);

}

void boost()

{

	ios_base::sync_with_stdio(0);

	cin.tie(0);

	cout.tie(0);

}

 

ll binpow (ll a, ll n)

{

    ll res = 1;

    while (n) {

        if (n & 1)

        {

            res *= a;

            res %= inf;

        }

        a *= a;

        n >>= 1;

        a %= inf;

    }

    return res;

}

        

int n;

int h[N];

int dp[N];

 

main()	

{                                                                        

	cin >> n;

	dp[0] = inf;

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

	{

	  	cin >> h[i];

	}

	for (int i = 2;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];

}	 


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

#include<stdlib.h>

#include<string.h>

#include<algorithm>

int h[100000];

int dp[100000];

int main()

{

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

	int n,temp,dp1,dp2;

	scanf("%d", &n);

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

	{

		scanf("%d", &temp);

		h[i] = temp;

	}

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

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

	{

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

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

		dp[i] = dp1 < dp2 ? dp1 : dp2;

	}

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

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

 

#define mp make_pair

#define pb push_back

#define f first

#define s second

#define ll long long

#define int ll

#define forn(i, a, b) for(int i = (a); i <= (b); ++i)

#define forev(i, b, a) for(int i = (b); i >= (a); --i)

#define VAR(v, i) __typeof( i) v=(i)

#define forit(i, c) for(VAR(i, (c).begin()); i != (c).end(); ++i)

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

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

#define file(s) freopen(s".in","r",stdin); freopen(s".out","w",stdout);

 

using namespace std;

 

const int maxn = (int)1e5 + 100;

const int mod = (int)1e9 + 7;

 

#define inf mod

 

typedef long double ld;

typedef pair<int, int> pii;

typedef pair<ll, ll> pll;

typedef vector<int> vi;   

typedef vector<ll> Vll;               

typedef vector<pair<int, int> > vpii;

typedef vector<pair<ll, ll> > vpll;

 

int n, dp[maxn];

int h[maxn];

main () {

	cin >> n;

	forn(i, 1, n)

		cin >> h[i];

	dp[1] = 0;

	forn(i, 2, n){

		dp[i] = inf * inf;

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

		if(i > 2)

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

	}

	cout << dp[n];



}

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

#include<stdlib.h>

#include<string.h>

#include<algorithm>

int h[100000];

int dp[100000];

int main()

{

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

	int n,temp,dp1,dp2;

	scanf("%d", &n);

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

	{

		scanf("%d", &temp);

		h[i] = temp;

	}

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

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

	{

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

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

		dp[i] = dp1 < dp2 ? dp1 : dp2;

	}

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

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



using namespace std;

 

typedef long long ll;

typedef long double ld;

typedef unsigned long long ull;

 

#define nl '\n'

 

#define y1 aza_ibagaliev

 

#define f first

#define s second

	

#define ed end()

#define bg begin()

#define rbg rbegin()

 

#define rv reverse

#define mp make_pair

#define pb push_back

#define ppb pop_back

#define ppf pop_front

 

#define sz size()

#define all(x) x.bg, x.ed

 

#define pll pair < ll, ll >

#define pii pair < int, int >

 

#define sqr(x) ((x) * 1ll * (x))

#define sqrd(x) ((x) * 1.0 * (x))

 

#define speed ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)

 

#define rnl cout << "----------------------------------------" << nl

 

#define bit __builtin_popcount

 

inline ll bip(ll x, ll n, ll mod){ll res=1;while(n){if(n & 1){res=(res*x)%mod;}x=(x*x)%mod;n>>=1;}return res;}

        	

const int ppr = 257;

const ll INF = 2e18;

const int inf = 998244353;

const int mod = 1e9 + 7;

const int N = 1e5 + 123;

const ld pi = 3.1741592653589793238462643;

 

const int dx[] = {1, 0, -1, 0};

const int dy[] = {0, 1, 0, -1};



int n, a[N], dp[N];



main() {             	

//  freopen(".in", "r", stdin);

//  freopen(".out", "w", stdout);



//	srand(time(NULL));



	scanf("%d", &n);



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

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



		if(i == 1) continue;



		dp[i] = inf;

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

		if(i > 2) dp[i] = min(dp[i], dp[i - 2] + abs(a[i] - a[i - 2])); 

	}



	cout << dp[n];

             

    return 0;                                        

}

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

#include<stdlib.h>

#include<string.h>

#include<algorithm>

int h[100000];

int dp[100000];

int main()

{

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

	int n,temp,dp1,dp2;

	scanf("%d", &n);

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

	{

		scanf("%d", &temp);

		h[i] = temp;

	}

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

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

	{

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

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

		dp[i] = dp1 < dp2 ? dp1 : dp2;

	}

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

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



using namespace std;



int n, a[(int)2e5], d[(int)2e5];



int main(){

    cin >> n;

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

        cin >> a[i];

    }

    d[2] = abs(a[2] - a[1]);

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

        d[i] = min(d[i - 1] + abs(a[i] - a[i - 1]), d[i - 2] + abs(a[i] - a[i - 2]));

    cout << d[n];

}


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

#include<stdlib.h>

#include<string.h>

#include<algorithm>

int h[100000];

int dp[100000];

int main()

{

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

	int n,temp,dp1,dp2;

	scanf("%d", &n);

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

	{

		scanf("%d", &temp);

		h[i] = temp;

	}

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

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

	{

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

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

		dp[i] = dp1 < dp2 ? dp1 : dp2;

	}

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

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

#include <iomanip>

#include <cmath>

#include <cstdio>

#include <cstring>

#include <ctime>

#include <string>

#include <stdio.h>

#include <set>

#include <map>

#include <algorithm>

#include <queue>

#include <vector>

#define ll long long

#define pb push_back

#define mp make_pair

#define f first

#define s second



using namespace std;



const int inf = 1e9 + 7;

const long long INF = 1e18 + 7;

const int maxn = 2e5 + 7;



int n, a[maxn], dp[maxn];



int main(){

	ios_base::sync_with_stdio(NULL);

	cin.tie(0);

	cout.tie(0);

	cin >> n;

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

		cin >> a[i], dp[i] = inf;

	dp[1] = 0;

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

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

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

	}

	cout << dp[n];

	return 0;

} 

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

#include<stdlib.h>

#include<string.h>

#include<algorithm>

int h[100000];

int dp[100000];

int main()

{

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

	int n,temp,dp1,dp2;

	scanf("%d", &n);

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

	{

		scanf("%d", &temp);

		h[i] = temp;

	}

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

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

	{

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

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

		dp[i] = dp1 < dp2 ? dp1 : dp2;

	}

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

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

using namespace std;



typedef signed long long ll;

const int MX = 1e5 + 5;

const int INF = 1e9 + 5;

int n, A[MX], dp[MX];



int solve(int pos) {

    if(pos > n) return INF;

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

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

    int ans = INF;

    if(pos + 1 < n) ans = min(ans, abs(A[pos] - A[pos + 1]) + solve(pos + 1));

    if(pos + 2 < n) ans = min(ans, abs(A[pos] - A[pos + 2]) + solve(pos + 2));

    return dp[pos] = ans;

}



int main() {

    scanf("%d", &n);



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

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

    }

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

    printf("%d\n", solve(0));

    return 0;

}

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

#include<stdlib.h>

#include<string.h>

#include<algorithm>

int h[100000];

int dp[100000];

int main()

{

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

	int n,temp,dp1,dp2;

	scanf("%d", &n);

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

	{

		scanf("%d", &temp);

		h[i] = temp;

	}

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

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

	{

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

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

		dp[i] = dp1 < dp2 ? dp1 : dp2;

	}

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

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

using namespace std;



int main() {

    ios_base::sync_with_stdio(0);

    cin.tie(0);

    cout.tie(0);

    long long n;

    cin >> n;

    long long a[n + 1], dp[n + 1];

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

        cin >> a[i];

        dp[i] = 0;

    }

    if(n == 1)

        cout << 0 << endl;

    else {

        dp[1] = 0;

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

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

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

        }

        cout << dp[n] << endl;

    }

    return 0;

}


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

#include<stdlib.h>

#include<string.h>

#include<algorithm>

int h[100000];

int dp[100000];

int main()

{

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

	int n,temp,dp1,dp2;

	scanf("%d", &n);

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

	{

		scanf("%d", &temp);

		h[i] = temp;

	}

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

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

	{

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

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

		dp[i] = dp1 < dp2 ? dp1 : dp2;

	}

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

}