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

#include <iostream>

#include <string>

#include <vector>

#include <cmath>

#include <algorithm>

#include <sstream>

#include <queue>

#include <deque>

#include <set>

#include <bitset>

#include <iterator>

#include <list>

#include <stack>

#include <map>

#include <set>

#include <functional>

#include <numeric>

#include <utility>



#include <cstdlib>  // for abs



#include <iomanip>



using namespace std;

int main()

{

  // Standard incantation to set up fast IO.

  ios::sync_with_stdio(false);

  cin.tie(0);



  int n;

  cin >> n;

  int cur, next;

  if (n <= 1) {

    cout << 0 << '\n';

    return 0;

  }

  int a, b, c;

  cin >> a >> b;

  cur = 0;

  next = abs(a - b);

  if (n == 2) {

    cout << next << '\n';

    return 0;

  }

  int ans;

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

    cin >> c;

    ans = min(cur + abs(c-a), next + abs(c-b));

    a = b;

    b = c;

    cur = next;

    next = ans;

  }

  cout << ans << '\n';



  return 0;

}




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

#include <algorithm>

using std::min;

 

#define MAXN 100003



int abs(int z)

{

    if (z<0)

        return -z;

    else

        return z;

}

 

int main(void)

{

    int N,i,j;

    int h[MAXN], p[MAXN];

    scanf("%d",&N);

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

    {

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

    }

    p[N-1]=0;

    p[N-2]=abs(h[N-2]-h[N-1]);

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

    {

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

    }

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

 

    return 0;

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

using namespace std;



int main(){



        int n; cin >> n;

        vector<int> frog(n + 1, 0);

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

                cin >> frog[i];

        }



        vector<int> dp(n + 5, 0);

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



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

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

        }



        cout << dp[n] << endl;









        return 0;

}




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

#include <algorithm>

using std::min;

 

#define MAXN 100003



int abs(int z)

{

    if (z<0)

        return -z;

    else

        return z;

}

 

int main(void)

{

    int N,i,j;

    int h[MAXN], p[MAXN];

    scanf("%d",&N);

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

    {

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

    }

    p[N-1]=0;

    p[N-2]=abs(h[N-2]-h[N-1]);

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

    {

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

    }

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

 

    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: 8.35496818663666x):
#include <cstdio>

#include <algorithm>

using std::min;

 

#define MAXN 100003



int abs(int z)

{

    if (z<0)

        return -z;

    else

        return z;

}

 

int main(void)

{

    int N,i,j;

    int h[MAXN], p[MAXN];

    scanf("%d",&N);

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

    {

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

    }

    p[N-1]=0;

    p[N-2]=abs(h[N-2]-h[N-1]);

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

    {

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

    }

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

 

    return 0;

}
// 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: 6.466412753354152x):
#include <cstdio>

#include <algorithm>

using std::min;

 

#define MAXN 100003



int abs(int z)

{

    if (z<0)

        return -z;

    else

        return z;

}

 

int main(void)

{

    int N,i,j;

    int h[MAXN], p[MAXN];

    scanf("%d",&N);

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

    {

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

    }

    p[N-1]=0;

    p[N-2]=abs(h[N-2]-h[N-1]);

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

    {

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

    }

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

 

    return 0;

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

using namespace std;

long long n,h[100010],dp[100010];



int main()

{

	scanf("%lld",&n);

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

	{

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

	}

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

	{

	//	printf("%d %d %d %d\n",dp[i-1],dp[i-2],h[i-1]-h[i],h[i-2]-h[i]);

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

		if(i>2)

		{

			

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

		}

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

	}

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

	return 0;

}

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

#include <algorithm>

using std::min;

 

#define MAXN 100003



int abs(int z)

{

    if (z<0)

        return -z;

    else

        return z;

}

 

int main(void)

{

    int N,i,j;

    int h[MAXN], p[MAXN];

    scanf("%d",&N);

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

    {

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

    }

    p[N-1]=0;

    p[N-2]=abs(h[N-2]-h[N-1]);

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

    {

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

    }

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

 

    return 0;

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

#include<cmath>

#include<cstring>

#include<iostream>

#include<algorithm>



using namespace std;

const int MAX = 1e9;

const int MaxN = 1e5 + 5;



int n;

int h[MaxN], dp[MaxN];



int main()

{

	while (~scanf ("%d", &n)){

		for (int i = 1; i <= n; i++) dp[i] = MAX;

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

		dp[1] = 0;

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

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

			int h1 = fabs (h[i] - h[i - 1]);

			int h2 = fabs (h[i] - h[i - 2]);

			dp[i] = min (dp[i - 1] + h1, dp[i - 2] + h2);

		}

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

	}

	return 0;

}

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

#include <algorithm>

using std::min;

 

#define MAXN 100003



int abs(int z)

{

    if (z<0)

        return -z;

    else

        return z;

}

 

int main(void)

{

    int N,i,j;

    int h[MAXN], p[MAXN];

    scanf("%d",&N);

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

    {

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

    }

    p[N-1]=0;

    p[N-2]=abs(h[N-2]-h[N-1]);

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

    {

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

    }

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

 

    return 0;

}
// Slower C++ solution:
//by Top1

#include <bits/stdc++.h>

     

#define f first

#define s second

#define int long long

#define ld long double

#define ull unsigned long long

#define pii pair <int, int>

#define pll pair <long, long>

#define mp make_pair

#define pb push_back

#define pf push_front

#define pp pop_back

#define rev reverse

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

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

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

#define boost ios_base::sync_with_stdio(false); cin.tie(0),cout.tie(0);

#define nxtp next_permutation

#define pvtp prev_permutation

#define KZ return 

#define x1 x21212121

#define y1 y21212121

#define sqr(x) x * x 

 

const int inf = INT_MAX;

const int mod = 1e9 + 7;

const int maxn = 6e5 + 111;

     

using namespace std;



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



void solve(){    

	cin >> n;



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

		cin >> a[i];



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



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

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



	cout << dp[n];

}



main(){

    boost;

	    

	q = 1;



	while (q--){

		solve();

	}

}


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

#include <algorithm>

using std::min;

 

#define MAXN 100003



int abs(int z)

{

    if (z<0)

        return -z;

    else

        return z;

}

 

int main(void)

{

    int N,i,j;

    int h[MAXN], p[MAXN];

    scanf("%d",&N);

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

    {

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

    }

    p[N-1]=0;

    p[N-2]=abs(h[N-2]-h[N-1]);

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

    {

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

    }

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

 

    return 0;

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

using namespace std;

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

const int N = 1e5;

int A[N+7], dp[N+7], n;

const int inf=1e9;



int solve(int i) {

	if(i==n) return 0;

	if(i>n) return inf;

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

	int a = solve(i+1) + abs(A[i]-A[i+1]);

	int b = solve(i+2) + abs(A[i]-A[i+2]);

	return dp[i] = min(a, b);

}

int main(){

	ios_base::sync_with_stdio(0);

	int a,b,T,cas=0;

	cin>>n;

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

	fill(dp, dp+n+1, -1);

	int res = solve(1);

	cout<<res<<endl;

	return 0;

}

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

#include <algorithm>

using std::min;

 

#define MAXN 100003



int abs(int z)

{

    if (z<0)

        return -z;

    else

        return z;

}

 

int main(void)

{

    int N,i,j;

    int h[MAXN], p[MAXN];

    scanf("%d",&N);

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

    {

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

    }

    p[N-1]=0;

    p[N-2]=abs(h[N-2]-h[N-1]);

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

    {

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

    }

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

 

    return 0;

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

#include <cstdio>

#include <cstring>

#include <cmath>

using namespace std;

int N;

int h[1000001],f[1000001];

int main () {

	cin>>N;

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

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

	}

	f[1]=0;

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

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

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

	}

	cout<<f[N];

	return 0; 

}

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

#include <algorithm>

using std::min;

 

#define MAXN 100003



int abs(int z)

{

    if (z<0)

        return -z;

    else

        return z;

}

 

int main(void)

{

    int N,i,j;

    int h[MAXN], p[MAXN];

    scanf("%d",&N);

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

    {

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

    }

    p[N-1]=0;

    p[N-2]=abs(h[N-2]-h[N-1]);

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

    {

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

    }

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

 

    return 0;

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

#include <stdio.h>



#define f first

#define s second

#define pb push_back

#define ppb pop_back

#define mp make_pair



using namespace std;



typedef long long ll;

typedef long double ld;

typedef unsigned long long ull;



const int N = 1e5 + 123, inf = 1e9 + 123, mod = 1e9 + 7;

const ll INF = 1e18;



int a[N], dp[N];



int main() {

	cin.tie(0);

	cout.tie(0);

	ios_base::sync_with_stdio(0);

	int n;

	cin >> n;

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

		cin >> a[i];

	}

	dp[1] = 0;

	a[0] = inf;

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

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

	}

	cout << dp[n];

	return 0;       	

}                               

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

#include <algorithm>

using std::min;

 

#define MAXN 100003



int abs(int z)

{

    if (z<0)

        return -z;

    else

        return z;

}

 

int main(void)

{

    int N,i,j;

    int h[MAXN], p[MAXN];

    scanf("%d",&N);

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

    {

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

    }

    p[N-1]=0;

    p[N-2]=abs(h[N-2]-h[N-1]);

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

    {

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

    }

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

 

    return 0;

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



#define Solved int main()

#define pb push_back

#define mp make_pair

#define F first

#define S second

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

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

#define rep(i, x, y) for(int i = x; i <= y; i++)

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

#define pii pair<int, int>

#define ll long long

#define ull unsigned long long

#define ld long double

#define mii map<int, int>

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

using namespace std;



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 maxn = 1e9;

const ll inf = 1e18;

const int mod = 998244353;

//const int mod = 1e9 + 7;

const int N = 1e5 + 10;



int n;

ll a[N];

ll dp[N];



void solve() {

    cin >> n;



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

        cin >> a[i];



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

    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] - a[i - 2]));

    }

    cout << dp[n];

}



Solved {

    SpeedForce;

	int tt = 1;

    //cin >> tt;

	while (tt--) {

		solve();

		cout << '\n';

	}



}


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

#include <algorithm>

using std::min;

 

#define MAXN 100003



int abs(int z)

{

    if (z<0)

        return -z;

    else

        return z;

}

 

int main(void)

{

    int N,i,j;

    int h[MAXN], p[MAXN];

    scanf("%d",&N);

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

    {

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

    }

    p[N-1]=0;

    p[N-2]=abs(h[N-2]-h[N-1]);

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

    {

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

    }

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

 

    return 0;

}
// 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: 12.252527096911079x):
#include <cstdio>

#include <algorithm>

using std::min;

 

#define MAXN 100003



int abs(int z)

{

    if (z<0)

        return -z;

    else

        return z;

}

 

int main(void)

{

    int N,i,j;

    int h[MAXN], p[MAXN];

    scanf("%d",&N);

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

    {

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

    }

    p[N-1]=0;

    p[N-2]=abs(h[N-2]-h[N-1]);

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

    {

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

    }

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

 

    return 0;

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

using namespace std ; 

#define ll long long

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

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

int main()

{	ios ; 

	ll n ; 

	cin>>n ; 

	int a[n] ; 

	flp(i,0,n)

	{

		cin>>a[i] ; 

	}

	int dp[n] ;

	dp[0] = 0  ; 

	flp(i,1 , n)

	{

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

		if(i>1)

		{

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

		}

 

 

	} 

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

}

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

#include <algorithm>

using std::min;

 

#define MAXN 100003



int abs(int z)

{

    if (z<0)

        return -z;

    else

        return z;

}

 

int main(void)

{

    int N,i,j;

    int h[MAXN], p[MAXN];

    scanf("%d",&N);

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

    {

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

    }

    p[N-1]=0;

    p[N-2]=abs(h[N-2]-h[N-1]);

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

    {

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

    }

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

 

    return 0;

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

 

using namespace std;

 



int main(){

    int n; cin >> n;

    vector<int> h(n);

 

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

        cin >> h[i];

    }

 

    //dp[i] gives the minimum possible cost to reach ith stone

    //Initialize dp[i] with infinity for all i

    vector<int> dp(n, INT_MAX);

    

    //Base Cases

    //To reach 0th stone we dont need to jump from any cells so total cost is 0

    //To reach 1st stone we can jump from 0th cell with total cost = abs(h[1] - h[0])

    dp[0] = 0;

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

 

    //Iterate from 2 to (n -1)th stone in a bottom up manner

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

       

       //ith stone can be reached either from (i - 1)th stone or (i - 2)th stone

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

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

    }

    

    //Print cost to reach (n -1)th stone

    cout << dp[n - 1];

    return 0;

}

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

#include <algorithm>

using std::min;

 

#define MAXN 100003



int abs(int z)

{

    if (z<0)

        return -z;

    else

        return z;

}

 

int main(void)

{

    int N,i,j;

    int h[MAXN], p[MAXN];

    scanf("%d",&N);

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

    {

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

    }

    p[N-1]=0;

    p[N-2]=abs(h[N-2]-h[N-1]);

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

    {

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

    }

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

 

    return 0;

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

/**

*   author: j o s e m a g o

*   date:

**/

using namespace std;

#pragma GCC optimize ("Ofast")

#define f first

#define s second

#define mp make_pair

#define lb lower_bound

#define ub upper_bound

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

#define mset(a,v) memset(a,v,sizeof(a))

#define pb push_back

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

#define rsz resize

#define ln "\n"



typedef double db;

typedef unsigned long long ull;

typedef long long ll;

typedef long double ld;

const ld PI = 2*acos(0.0);

const int MOD = 1000000007;

const int JJJ = 100009;









int main(){



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

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



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



    int N;

    cin >> N;

    vector<int>h(N);

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

        cin >> h[i];

    }

    vector<int>dp(N,INT_MAX);

    dp[0] = 0;

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

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















    return 0;

}

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

#include <algorithm>

using std::min;

 

#define MAXN 100003



int abs(int z)

{

    if (z<0)

        return -z;

    else

        return z;

}

 

int main(void)

{

    int N,i,j;

    int h[MAXN], p[MAXN];

    scanf("%d",&N);

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

    {

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

    }

    p[N-1]=0;

    p[N-2]=abs(h[N-2]-h[N-1]);

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

    {

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

    }

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

 

    return 0;

}