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



using namespace std;

int v[100010];

int memo[100010];

int c;



int f(int i)

{



    if(memo[i]!=-1)

        return memo[i];



    if(i == 0)

        return memo[0] = 0;



    if(i == 1)

        return memo[1] = abs(v[0] - v[1]);



    return memo[i] = min(abs(v[i] - v[i-1]) + f(i-1), abs(v[i] - v[i-2]) + f(i-2));

}



int main()

{



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

    cin>>c;



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

    {

        cin>>v[i];

    }



    cout<<f(c-1)<<endl;



    return 0;

}

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

#define REP(x,y,z) for(int x=y;x<=z;x++)

#define MSET(x,y) memset(x,y,sizeof(x))

#define M 100005

using namespace std;

int n,h[M],dp[M];

int main()

{

    scanf("%d", &n);

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

    

    dp[1] = 0;

    REP(i,2,n) {

        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]));

    }

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

    return 0;

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



using namespace std;



const int N = 1e5 + 9;



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



int solve(int i){

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

    if(i == n)   return 1e9;



    int &ret = dp[i];

    if(~ret)    return ret;



    return ret = min(abs(h[i] - h[i + 1]) + solve(i + 1), abs(h[i] - h[i + 2]) + solve(i + 2));

}



int main(){



    cin >> n;

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

        cin >> h[i];



    memset(dp, -1, sizeof dp);



    cout << solve(0);

}


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

#define REP(x,y,z) for(int x=y;x<=z;x++)

#define MSET(x,y) memset(x,y,sizeof(x))

#define M 100005

using namespace std;

int n,h[M],dp[M];

int main()

{

    scanf("%d", &n);

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

    

    dp[1] = 0;

    REP(i,2,n) {

        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]));

    }

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

    return 0;

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

using namespace std;

int n;

long long h[100005];

long long dp[100005];



long long solve(int i){

	if(i >= n-1) return 0;

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



	dp[i] = 1e17;

	if(i+1 <= n-1)

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

	if(i+2 <= n-1)

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



	return dp[i];

}



int main(){

	scanf("%d", &n);

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

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

	memset(dp, -1, sizeof dp);

	cout<<solve(0)<<endl;

	return 0;

}

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

#define REP(x,y,z) for(int x=y;x<=z;x++)

#define MSET(x,y) memset(x,y,sizeof(x))

#define M 100005

using namespace std;

int n,h[M],dp[M];

int main()

{

    scanf("%d", &n);

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

    

    dp[1] = 0;

    REP(i,2,n) {

        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]));

    }

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

    return 0;

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

using namespace std;

#define ll long long

#define pb push_back

#define mp make_pair

#define ull  unsigned long long

#define vll  vector <long long>

#define pll pair <long long,long long>

#define f first

#define s second

#define up upper_bound

#define lp lower_bound

#define pq priority_queue

#define inf 1e10

#define minf -1e10

#define pi 3.14159265

#define mod 300000000000000000

#define fastio ios_base::sync_with_stdio(0);cin.tie(NULL);

int main()

{

    ll n;

    cin>>n;

    vll vec;

    ll ara[100001];

    memset(ara,0,sizeof(ara));

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

    {

        ll num;

        cin>>num;

        vec.pb(num);

    }

    ll ans=0;

    ara[n-2]=abs(vec[n-2]-vec[n-1]);

    for(ll i=n-3;i>=0;i--)

    {

        ara[i]=min(abs(vec[i]-vec[i+1])+ara[i+1],abs(vec[i]-vec[i+2])+ara[i+2]);

    }

    cout<<ara[0]<<endl;

}


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

#define REP(x,y,z) for(int x=y;x<=z;x++)

#define MSET(x,y) memset(x,y,sizeof(x))

#define M 100005

using namespace std;

int n,h[M],dp[M];

int main()

{

    scanf("%d", &n);

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

    

    dp[1] = 0;

    REP(i,2,n) {

        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]));

    }

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

    return 0;

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

using namespace std;

#define ll long long



int ara[100000];

int dp[100000];



int f(int i, int n)

{

    if(i == n) return 0;

    if(dp[i] != -1)

        return dp[i];

    int cost = f(i+1,n) + abs(ara[i] - ara[i+1]);

    if(i+2<=n)

        cost = min(cost, f(i+2,n)+abs(ara[i] - ara[i+2]));

    dp[i] = cost;



    return cost;

}



int main()

{

   int n;

   cin>>n;



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

   {

       cin>>ara[i];

   }



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

   cout<<f(1,n)<<endl;



   return 0;

}






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

#define REP(x,y,z) for(int x=y;x<=z;x++)

#define MSET(x,y) memset(x,y,sizeof(x))

#define M 100005

using namespace std;

int n,h[M],dp[M];

int main()

{

    scanf("%d", &n);

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

    

    dp[1] = 0;

    REP(i,2,n) {

        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]));

    }

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

    return 0;

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



#define TR 100000



int l[TR];

using namespace std;

vector<int> h;





int solve(int p) {

	if(p == 0)

		return 0;

	if(p < 0)

		return 10000000;

	if(l[p] != -1)

		return l[p];

	l[p] = min(abs(h[p] - h[p - 1]) + solve(p - 1), abs(h[p] - h[p - 2]) + solve(p - 2));

	return l[p];



}



int main() {

	int n;

	cin >> n;

	memset(l, -1, TR * sizeof(int));

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

		cin >> tmp;

		h.push_back(tmp);

	}

	solve(n - 1);

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

}

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

#define REP(x,y,z) for(int x=y;x<=z;x++)

#define MSET(x,y) memset(x,y,sizeof(x))

#define M 100005

using namespace std;

int n,h[M],dp[M];

int main()

{

    scanf("%d", &n);

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

    

    dp[1] = 0;

    REP(i,2,n) {

        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]));

    }

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

    return 0;

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



using namespace std;

#define tam 100001

int dp[tam],A[tam],n,pr=0;

int solver(int index)

{

    if(dp[index] != -1)

        return dp[index];

    if(index <= 1)

        return dp[index] = abs(A[0]-A[index]);

    return dp[index] = min(solver(index-1) + abs(A[index]-A[index-1]),

    solver(index-2) + abs(A[index]-A[index-2]));

}

int main()

{

    cin>>n;

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

        cin>>A[i];

    memset(dp,-1,sizeof dp);

    dp[0] = 0; 

    cout<<solver(n-1)<<"\n";

    return 0;

}


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

#define REP(x,y,z) for(int x=y;x<=z;x++)

#define MSET(x,y) memset(x,y,sizeof(x))

#define M 100005

using namespace std;

int n,h[M],dp[M];

int main()

{

    scanf("%d", &n);

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

    

    dp[1] = 0;

    REP(i,2,n) {

        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]));

    }

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

    return 0;

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

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

#define ii          pair<int,int>

#define F           first

#define S           second

#define pb          push_back

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

#define rall(x)     (x).rbegin(),(x).rend()

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

#define forr(i,a)   for(int i = a; i >= 0; i--)

#define fori(i,m)   for(auto i = m.begin(); i != m.end(); i++) 

#define w(t)        while(t--)

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

#define cls(a,car)  memset(a,car,sizeof (a))

#define db(x)       cerr << #x << " is " << x << '\n'

#define FL          freopen("input.txt", "r", stdin),freopen("output.txt", "w", stdout);

#define EjecuteTime cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n"

#define angle(x)    double(x * acos(-1) / 180.0)

using namespace std;

typedef long long   ll;

typedef vector<int> vi;

typedef vector<ii>  vii;

const int N = 1 * 1e5 + 5;

const ll mod = 1e9 + 7;

const double E = 1e-9;

//int dx[] = {1, 0}, dy[] = {0, 1};

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

//int dx[] = {2, 1, -1, -2, -2, -1, 1, 2}, dy[] = {1, 2, 2, 1, -1, -2, -2, -1};

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

// fflush(stdout)

// cout << flush

// a + b = a ^ b + 2 * (a & b)

int v[N];

int dp[N];

int n, k = 2;

int f(int i){

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

    int &ans = dp[i];

    if(ans == -1){

        ans = 1e9;

        for(int j = 1; j <= k; j++)

            if(i + j < n)

                ans = min(ans, f(i + j) + abs(v[i] - v[i + j]));

            else

                break;

    }

    return ans;

}

int main(){

    //FL;

    FIN;

    cin >> n;

    fore(i, 0, n)cin >> v[i];

    cls(dp, -1);

    cout << f(0) << '\n';

    

    EjecuteTime;

    return 0;

}       

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

#define REP(x,y,z) for(int x=y;x<=z;x++)

#define MSET(x,y) memset(x,y,sizeof(x))

#define M 100005

using namespace std;

int n,h[M],dp[M];

int main()

{

    scanf("%d", &n);

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

    

    dp[1] = 0;

    REP(i,2,n) {

        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]));

    }

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

    return 0;

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

#define INF 0x3f3f3f3f

using namespace std;

const int maxn = 1e6+10;

int a[maxn];

int dp[maxn];

int main()

{

    int n;

    memset(dp,INF,sizeof dp);

    scanf("%d",&n);

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

    {

        scanf("%d",a+i);

    }

    dp[1]=0;

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

    {

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

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

    }

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

    return 0;

}


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

#define REP(x,y,z) for(int x=y;x<=z;x++)

#define MSET(x,y) memset(x,y,sizeof(x))

#define M 100005

using namespace std;

int n,h[M],dp[M];

int main()

{

    scanf("%d", &n);

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

    

    dp[1] = 0;

    REP(i,2,n) {

        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]));

    }

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

    return 0;

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

using namespace std;



const int mx=1e5+1;

int n,k;

int h[mx],dp[mx];

int solve(int s) //s->no of stone

{

    if(s==n) return 0;

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

    int ret=INT_MAX;

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

        if((i+s)<=n) ret=min(ret,abs(h[s+i]-h[s])+solve(s+i));

    }

    return dp[s]=ret;

}

int main()

{

    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);

    //freopen("input.txt","r",stdin);    return 0;



    cin>>n;

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

    memset(dp,-1,sizeof dp);

    cout<<solve(1);



    return 0;

}


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

#define REP(x,y,z) for(int x=y;x<=z;x++)

#define MSET(x,y) memset(x,y,sizeof(x))

#define M 100005

using namespace std;

int n,h[M],dp[M];

int main()

{

    scanf("%d", &n);

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

    

    dp[1] = 0;

    REP(i,2,n) {

        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]));

    }

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

    return 0;

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

#include<cstring>

#include<iostream>

#include<algorithm>

using namespace std;

const int maxn=100000+10;

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

int main()

{

	cin>>n;

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

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

	dp[1]=0;

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

	{

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

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

	}

	cout<<dp[n]<<endl;

	return 0;

}

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

#define REP(x,y,z) for(int x=y;x<=z;x++)

#define MSET(x,y) memset(x,y,sizeof(x))

#define M 100005

using namespace std;

int n,h[M],dp[M];

int main()

{

    scanf("%d", &n);

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

    

    dp[1] = 0;

    REP(i,2,n) {

        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]));

    }

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

    return 0;

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

#define N 100007

#define inf 999999999

using namespace std;



long long mem[N];

long long ara[N];

int n;



long long dp(int i, int j)

{

    if(i >= n)

        return inf;

    if(i == j)

        return 0;

    if(mem[i] != -1)

        return mem[i];

    long long ans = min(abs(ara[i + 1] - ara[i]) + dp(i + 1, j), abs(ara[i + 2] - ara[i]) + dp(i + 2, j));

    mem[i] = ans;

    return ans;

}

int main()

{

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

    //freopen("output.txt", "w", stdout);

    cin >> n;

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

        cin >> ara[i];

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

    cout << dp(0, n - 1) << endl;

    return 0;

}

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

#define REP(x,y,z) for(int x=y;x<=z;x++)

#define MSET(x,y) memset(x,y,sizeof(x))

#define M 100005

using namespace std;

int n,h[M],dp[M];

int main()

{

    scanf("%d", &n);

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

    

    dp[1] = 0;

    REP(i,2,n) {

        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]));

    }

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

    return 0;

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

using namespace std;

using ll = long long;

using ii = pair<int, int>;

using iii = pair<ii, int>;

#define vt vector

#define pq priority_queue

#define pb push_back

#define pf push_front

#define mp make_pair

#define fi first

#define se second

#define __lcm(a, b) a * b / __gcd(a, b)

const int MOD = 1e9 + 7;

const int INF = 2e9;

const int N = 1e5 + 5;



int n;

int a[N], dp[N];



int f(int idx) {

    if(idx > n) return INF;

    if(idx == n) return 0;

    int &sol = dp[idx];

    if(sol != -1) return sol;

    return sol = min(f(idx + 1) + abs(a[idx] - a[idx + 1]), 

                     f(idx + 2) + abs(a[idx] - a[idx + 2]));

}



void solve() {

    cin >> n;

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

        cin >> a[i];

    }

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

    cout << f(1) << "\n";

}



int main() {

 

    ios_base::sync_with_stdio(0);

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

    

    solve();

    

}

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

#define REP(x,y,z) for(int x=y;x<=z;x++)

#define MSET(x,y) memset(x,y,sizeof(x))

#define M 100005

using namespace std;

int n,h[M],dp[M];

int main()

{

    scanf("%d", &n);

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

    

    dp[1] = 0;

    REP(i,2,n) {

        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]));

    }

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

    return 0;

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

using namespace std;

#define N (int)2e5

int n,memo[N],c[N];



int dp(int curr) {

    if (curr == n) return 0;

    if (curr > n) return 1e9;

    int &sol = memo[curr];

    if (sol != -1) return sol;

    sol = min(

        dp(curr + 1) + abs(c[curr] - c[curr + 1]) ,

        dp(curr + 2) + abs(c[curr] - c[curr + 2])

    );

    return sol;

}



int main() {

    scanf("%d" , &n);

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

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

    memset (memo , -1 , sizeof memo);

    printf("%d\n" , dp(1));

}


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

using namespace std;

const int maxn = 1e5;

int h[maxn];

int dp[maxn];

int N;



int main(int argc, char const *argv[])

{

    cin >> N;

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

        cin >> h[i];

    }

    dp[0] = 0;

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

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

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

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

        dp[i] = min(t1, t2);

    }

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

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

#include<map>

#include<cmath>

#include<ctime>

#include<queue>

#include<stack>

#include<cstdio>

#include<string>

#include<vector>

#include<random>

#include<cstdlib>

#include<cstring>

#include<iomanip>

#include<iostream>

#include<algorithm>

#include<unordered_map>

#define endl "\n"

#define fi first

#define se second

#define db double

#define gcd __gcd

#define pb push_back

#define mp make_pair

#define lowbit(x) (x & (-x))

#define PII  pair<int, int> 

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

#define debug(x) cout << #x << " = " << x << endl

#define rep(i, a, b) for(__typeof(b) i = a; i <= (b); i++)

#define Rep(i, a, b) for(__typeof(a) i = a; i >= (b); i--)

#define FAST ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)

template<class T> inline T qmin(T a, T b) { return a < b ? a : b; }

template<class T> inline T qmax(T a, T b) { return a > b ? a : b; }

typedef long long ll;

typedef unsigned long long ull;

const db eps = 1e-9;

const db PI = acos(-1);

const int inf = 0x3f3f3f3f;

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

const int maxn = (int)1e5 + 5;//remember to modify it, No RE or MLE

const ll INF = 0x3f3f3f3f3f3f3f3f;

using namespace std;

ll qpow(ll x, ll y) { ll ret = 1; for( ; y; y >>= 1, x = (x * x) % mod) if(y & 1) ret = (ret * x) % mod; return ret; }



inline int read(){

	char ch = getchar();

	int x = 0, f = 1;

	while(ch < '0' || ch > '9'){

		if(ch == '-') f = -1;

		ch = getchar();

	}

	while('0' <= ch && ch <= '9'){

		x = x * 10 + ch - '0';

		ch = getchar();

	}

	return x * f;

}



int n;

int h[maxn], dp[maxn];



int main()

{

	n = read();

	rep(i, 1, n) h[i] = read();

	memset(dp, 0x3f, sizeof dp);

	dp[1] = 0;

	rep(i, 1, n){

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

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

	}

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

	return 0;

}

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

using namespace std;

const int maxn = 1e5;

int h[maxn];

int dp[maxn];

int N;



int main(int argc, char const *argv[])

{

    cin >> N;

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

        cin >> h[i];

    }

    dp[0] = 0;

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

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

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

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

        dp[i] = min(t1, t2);

    }

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

}
// Slower C++ solution:


/**

    And in the end, the love you take is equal to the love you make.



        I LOVE YOU LAURA.

**/



#include <bits/stdc++.h>

#include <ext/pb_ds/assoc_container.hpp>

#include <ext/pb_ds/tree_policy.hpp>

#include <ext/rope>



#define _CRT_SECURE_NO_DEPRECATE

#define _CRT_DISABLE_PERFCRIT_LOCKS



#define findOrder find_by_order

#define orderKey order_of_key



#define isOn(mask, i) (mask & (1 << i))

#define turn(mask, i) (mask |= (1 << i))

#define switch(mask, i) (mask &= ~(1 << i))

#define change(mask, i) (mask ^= (1 << i))

#define lowbit(mask) (mask & (-mask))

#define turnAll(mask, n) (mask = (1 << n) - 1)

#define switchLastBit(mask) (mask & (mask - 1))

#define turnLastZero(mask) (mask | (mask + 1))

#define modulo(x, mod) ((x) & (mod - 1))

#define log2(x) (31 - __builtin_clz(x))



#define mkp make_pair

#define pb push_back

#define pf push_front

#define eb emplace_back

#define ef emplace_front

#define ins insert

#define rsz resize

#define f first

#define s second

#define lb lower_bound

#define ub upper_bound



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

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

#define rall(x) rbegin(x), rend(x)



#define debug(x) (cerr << x << " ")



using namespace std;

using namespace __gnu_pbds;

using namespace __gnu_cxx;



typedef double db;

typedef long long ll;

typedef long double ld;

typedef unsigned long long ull;



typedef pair<int, int> ii;

typedef pair<ll,ll> pll;

typedef pair<ld,ld> pdb;

typedef pair<int, ii> tri;

typedef complex<ld> cd;



typedef vector<int> vi;

typedef vector<ii> vii;

typedef vector<ld> vdb;

typedef vector<cd> vcd;

typedef vector<ll> vll;

typedef vector<string> vs;

typedef vector<vll> matrix;



typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_tree;



const ll mod = 1e9+7;

const int maxn = 2e5+2;

const int pi = 2 * acos(0.0);

const db eps = 1e-9;



ll arr[maxn], dp[maxn];



int main()

{

    ios_base::sync_with_stdio(0);

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



    int n; cin >> n;



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

        cin >> arr[i];

    }



    memset(dp, 63, sizeof dp);



    dp[1] = 0;

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

        if (i <= 2){

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

        }

        else{

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

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

        }

    }



    cout << dp[n] << "\n";



    return 0;

}


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

using namespace std;

const int maxn = 1e5;

int h[maxn];

int dp[maxn];

int N;



int main(int argc, char const *argv[])

{

    cin >> N;

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

        cin >> h[i];

    }

    dp[0] = 0;

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

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

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

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

        dp[i] = min(t1, t2);

    }

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

}