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



using namespace std;

using ll = long long;



using Field = vector<vector<int>>;

using Graph = vector<vector<int>>;

using VI = vector<int>;

using VC = vector<char>;

using PI = pair<int, int>;



#define REP(i, n) for (int i = 0; i < (n); i++)

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



const long long INF = 1LL<<60;

const int mod = 1000000007;



template<class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }

template<class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }



int N;

vector<int> H(100010);

vector<int> H1(100010);

vector<int> H2(100010);

int MAX_N = 100000;



vector<ll> dp(100010, INF);



int main() {

    cin.tie(0);

    ios_base::sync_with_stdio(false);

    cin >> N;

    REP(i, N) {

        cin >> H.at(i);

    }

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

        H1.at(i) = abs(H.at(i) - H.at(i + 1));

    }

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

        H2.at(i) = abs(H.at(i) - H.at(i + 2));

    }



    dp.at(0) = 0;



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

        chmin(dp.at(i + 1), dp.at(i) + H1.at(i));

        chmin(dp.at(i + 2), dp.at(i) + H2.at(i));

    }



    cout << dp.at(N-1) << endl; 



    return 0;

}

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



using namespace std;

using ll = long long;



using Field = vector<vector<int>>;

using Graph = vector<vector<int>>;

using VI = vector<int>;

using VC = vector<char>;

using PI = pair<int, int>;



#define REP(i, n) for (int i = 0; i < (n); i++)

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



const long long INF = 1LL<<60;

const int mod = 1000000007;



template<class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }

template<class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }



int N;

vector<int> h;

vector<ll> dp;



int main() {

    cin.tie(0);

    ios_base::sync_with_stdio(false);



    cin >> N;

    h.resize(N + 10, 0);

    dp.resize(N + 10, INF);



    REP(i, N) cin >> h.at(i);



    dp[0] = 0;



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

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

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

    }



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

    

    return 0;

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

#include <bits/stdc++.h>

using namespace std;

int static dp[100001];

int frog(vector<int>&a,int n,int current)

{

    if(current+1==n)

        return 0;

    if(dp[current]!=-1)

        return dp[current];

    int A=INT_MAX,B=INT_MAX;

    if(current+1<n)

        A=abs(a[current]-a[current+1])+frog(a,n,current+1);

    if(current+2<n)

        B=abs(a[current]-a[current+2])+frog(a,n,current+2);

    dp[current]=min(A,B);

    return dp[current];

}



int main() {

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

	int n;

	cin>>n;

	vector<int>height;

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

	{

	    int x;

	    cin>>x;

	    height.push_back(x);

	}

	cout<<frog(height,n,0);

	return 0;

}

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

#include <bits/stdc++.h>

using namespace std;

int main() {

	int n;

	cin>>n;

	vector<int>height;

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

	{

	    int x;

	    cin>>x;

	    height.push_back(x);

	}

	vector<int>dp(n,INT_MAX);

	dp[0]=0;

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

	{

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

	    {

	        if(j<n)

	        {

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

	        }

	    }

	}

	cout<<dp[n-1];

	return 0;

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

#include<string>

#include<cstdio>

#include<algorithm>

#include<cstdlib>

#include<cmath>

#include<vector>

#include<utility>

#include<queue>

#include<stack>

#include<set>

#include<map>

#include<unordered_set>

#include<bitset>

using namespace std;

//#define MODE 1

#ifdef MODE

#define DEB(X) cout<< #X <<": "<<X<<" ";

#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";

#define END cout<<endl;

#else

#define DEB(X) {}

#define ARDEB(i,X) {}

#define END {}

#endif

typedef long long int ll;

#define int long long

typedef pair<int,int> P;

struct edge{int to,cost;};

#define REP(i,n) for(int i=0;i<(n);i++)

const int INF=100000000000000000;



int N,A[100010];

int dp[100010];



int DP(int a){

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

	int res=INF,res2=INF;

	if(a==N-1){

		return 0;

	}

	res=DP(a+1)+abs(A[a]-A[a+1]);

	if(a<N-2){

		res2=DP(a+2)+abs(A[a+2]-A[a]);

	}

	return dp[a]=min(res,res2);

}



signed main(){

	cin>>N;

	REP(i,N){

		cin>>A[i];

	}

	REP(i,100010){

		dp[i]=-1;

	}

	cout<<DP(0)<<endl;

	return 0;

}


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

#include<string>

#include<cstdio>

#include<algorithm>

#include<cstdlib>

#include<cmath>

#include<vector>

#include<utility>

#include<queue>

#include<stack>

#include<set>

#include<map>

#include<unordered_set>

#include<unordered_map>

#include<bitset>

#include<iomanip>

#include<list>

#include<deque>

using namespace std;

//#define MODE 1

#ifdef MODE

#define DEB(X) cout<< #X <<": "<<X<<" ";

#define END cout<<endl;

#else

#define DEB(X) {}

#define END {}

#endif

typedef long long ll;

#define int ll

#define uset unordered_set

#define umap unordered_map

typedef std::pair<int,int> P;

struct edge{int to,cost;};

const int INF=100000000000000000;

const int INF2=9223372036854775807;

const int MOD=1000000007;

#define REP(i,n) for(int i=0;i<(int)(n);i++)

#define min(X,Y) (((int)(X)<(int)(Y))?(X):(Y))

#define max(X,Y) (((int)(X)>(int)(Y))?(X):(Y))

#define MAX(X,Y) (*max_element(X,Y))

#define MIN(X,Y) (*min_element(X,Y))

#define NP(X,Y) next_permutation(X,Y)

#define setp(X,Y) cout<<fixed<<setprecision(Y)<<X;

int ceil2(int a,int b){if(a%b==0){return a/b;}else{return a/b+1;}}

int pow2(int a,int b){int r=1;for(int i=1;i<=b;i++){r*=a;}return r;}

int Log2(int a){int t=0;while(1){if(a==0||a==1){break;}a/=2;t++;}return t;}



int N;

int H[100010];

int dp[100010];



signed main(){

	cin>>N;

	REP(i,N){

		cin>>H[i];

		dp[i]=INF;

	}

	dp[0]=0;

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

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

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

	}

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

	return 0;

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



#define F first

#define S second

#define PB push_back



using namespace std;



typedef long long ll;



int n;

ll h[100005];

ll memo[100005];



ll dp(int i){

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

	if(i >= n)	return 10000000000;

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

		return memo[i];

	}

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

}



int main(){



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

	

	ios_base::sync_with_stdio(false);

	cin.tie(NULL);

	cout.tie(NULL);



	cin >> n;

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

		cin >> h[i];

	}



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



	return 0;

}

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



#define F first

#define S second

#define PB push_back



using namespace std;



typedef long long ll;



int main(){

	

	ios_base::sync_with_stdio(false);

	cin.tie(NULL);

	cout.tie(NULL);



	int n;

	cin >> n;



	int h[n];

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

		cin >> h[i];

	}



	int cost[n];

	cost[0] = 0;

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



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

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

	}



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



	return 0;

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

#define rep(i, n) for(int i = 0; i < (int)n; i++)

using namespace std;

typedef long long ll;



template<class T> inline bool chmax(T& a, T b){

    if (a < b) {

        a = b;

        return true;

    }

    return false;

}



template<class T> inline bool chmin(T& a, T b) {

    if (a > b) {

        a = b;

        return true;

    }

    return false;

}



const ll INF = 1LL << 60;



ll h[100010];



ll dp[100010];



ll rec(int i){

    if(dp[i] < INF) return dp[i];

    

    if(i == 0) return 0;

    

    ll res = INF;

    

    chmin(res, rec(i - 1) + abs(h[i] - h[i - 1]));

    if(i > 1) chmin(res, rec(i - 2) + abs(h[i] - h[i - 2]));

    

    return dp[i] = res;

}





int main(){

    

    cin.tie(0);

    ios::sync_with_stdio(0);

    

    int n;

    cin >> n;

    

    rep(i,n) cin >> h[i];

    

    rep(i,100010) dp[i] = INF;

    

    cout << rec(n - 1) << endl;



}


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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)n; i++)

typedef long long ll;



int dp[100010];



int main(){

    cin.tie(0);

    ios::sync_with_stdio(false);



    int n;

    cin >> n;

    

    vector<int> h(n);

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

    

    

    

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

        if(i == 0) continue;

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

        else 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] << endl;

}
// 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.2920561221989588x):
#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;

}
// 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.8126550589241126x):
#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;

}
// 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.402922851245148x):
#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;

}
// 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.7970635487005424x):
#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;

}
// 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.3908556430521828x):
#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;

}
// 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.7687826957003503x):
//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();

	}

}
// 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.3689673887307985x):
//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();

	}

}