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

#include <vector>

#include <algorithm>

#include <cstring>

#include <map>

#include <set>

#include <unordered_map>

#include <queue>

#include <stack>

#include <cmath>

#include <functional>

#include <deque>

#include <bitset>

#include <climits>

#include <cstdio>

#include <list>

#include <iomanip>

using namespace std;



#define ll long long int

#define mp make_pair

#define pb push_back

#define fi first

#define si second

#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL);

#define F(a,n) for(int i=0;i<n;i++){cin>>a[i];}

#define F1(a,n) for(int i=1;i<=n;i++){cin>>a[i];}

#define P(a,n) for(int i=0;i<n;i++){cout<<a[i]<<' ';}cout<<endl;

#define P1(a,n) for(int i=1;i<=n;i++){cout<<a[i]<<' ';}cout<<endl;

#define NF(a,n,m) for(int i=0;i<n;i++){for(int j=0;j<m;j++){cin>>a[i][j];}}

#define NF1(a,n,m) for(int i=1;i<=n;i++){for(int j=1;j<=m;j++){cin>>a[i][j];}}

#define PNF(a,n,m) for(int i=0;i<n;i++){for(int j=0;j<m;j++){cout<<a[i][j]<<' ';}cout<<endl;}cout<<endl;

#define PNF1(a,n,m) for(int i=1;i<=n;i++){for(int j=1;j<=m;j++){cout<<a[i][j]<<' ';}cout<<endl;}cout<<endl;

#define AS 200001

#define mod 1000000007

ll x[110000];

ll dp[110000];

ll ABS(double a) {return max(a, -a);}

int main() {

	fastIO

	int n;

	cin >> n;

	F(x, n);

	memset(dp, mod, sizeof dp);

	dp[0] = 0;

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

		if (i + 1 < n) dp[i + 1] = min(dp[i + 1], dp[i] + ABS(x[i] - x[i + 1]));

		if (i + 2 < n) dp[i + 2] = min(dp[i + 2], dp[i] + ABS(x[i] - x[i + 2]));

	}

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

}

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

using namespace std;



#define ll long long int

#define mp make_pair

#define pb push_back

#define fi first

#define si second

#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL);

#define F(a,n) for(int i=0;i<n;i++){cin>>a[i];}

#define F1(a,n) for(int i=1;i<=n;i++){cin>>a[i];}

#define P(a,n) for(int i=0;i<n;i++){cout<<a[i]<<' ';}cout<<endl;

#define P1(a,n) for(int i=1;i<=n;i++){cout<<a[i]<<' ';}cout<<endl;

#define NF(a,n,m) for(int i=0;i<n;i++){for(int j=0;j<m;j++){cin>>a[i][j];}}

#define NF1(a,n,m) for(int i=1;i<=n;i++){for(int j=1;j<=m;j++){cin>>a[i][j];}}

#define PNF(a,n,m) for(int i=0;i<n;i++){for(int j=0;j<m;j++){cout<<a[i][j]<<' ';}cout<<endl;}cout<<endl;

#define PNF1(a,n,m) for(int i=1;i<=n;i++){for(int j=1;j<=m;j++){cout<<a[i][j]<<' ';}cout<<endl;}cout<<endl;

#define AS 200001

#define mod 1000000007

#define inf 1e9

int solve(vector<int>ar, int n) {

	vector<int>dp(n + 1);

	dp[0] = 1;

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

		int option1 = abs(ar[i] - ar[i - 1]) + dp[i - 1];

		int option2 = (i == 2) ? inf : abs(ar[i] - ar[i - 2]) + dp[i - 2];

		dp[i] = min(option1, option2);

	}

	return dp[n];

}

int main() {

	fastIO



	int n;

	cin >> n;

	vector<int>ar;

	ar.resize(n + 1);

	F1(ar, n);

	cout << solve(ar, n) << endl;

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

#include<algorithm>



using namespace std;

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

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



const long long Inf = 1LL << 60;



// 入力

int N;

long long h[100010];



// メモ用の DP テーブル

long long dp[100010];



long long rec(int i) 

{

    // DP の値が更新されていたらそのままリターン

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



    // 足場 0 のコストは 0

    if (i == 0) return 0;



    // i-1, i-2 それぞれ試す

    long long res = Inf;

    chmin(res, rec(i-1) + abs(h[i] - h[i - 1])); // 足場 i-1 から来た場合

    if (i > 1) chmin(res, rec(i-2) + abs(h[i] - h[i - 2])); // 足場 i-2 から来た場合



    // 結果をメモしながら、返す

    return dp[i] = res;

}



int main() {

    int N; cin >> N;

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



    // 初期化 (最小化問題なので INF に初期化)

    for (int i = 0; i < 100010; ++i) dp[i] = Inf;



    // 答え

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

}



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

{

    if (a > b) 

    { 

        a = b; 

        return true; 

    } 

    return false; 

}



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

{ 

    if (a < b) 

    { 

        a = b; 

        return true; 

    } 

    return false; 

}

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

using namespace std;



int main()

{

    int N;

    cin >> N;

    long long dp[100000];

    long long  h[100000];

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

    {

        cin >> h[i];

        dp[i] = 10000000000;

    }

    dp[0] = 0;

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

    {

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

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

    }



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

}
// Slower C++ solution:
/* BISMILLAHIR RAHMANIR RAHIM */

#include <bits/stdc++.h>

using namespace std;



const int mxn = 100005;

int n, h[mxn], ff[mxn];



int dfs( int pos ) 

{

  if( pos == 0 ) return 0;

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

  

  ff[pos] = 0;

  if( pos > 1 ) 

    ff[pos] = abs(h[pos - 1] - h[pos]) + dfs( pos - 1 );

  if( pos > 2 )

    ff[pos] = min(ff[pos], abs(h[pos - 2] - h[pos]) + dfs( pos - 2 ));

    

  return ff[pos];

}



int main()

{

  scanf("%d", &n);

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

  {

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

  }  

  memset(ff, -1, sizeof ff);

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

  return 0;

}

// Faster C++ solution for the same problem (measured speedup: 1.395163584856976x):
/* BISMILLAHIR RAHMANIR RAHIM */

#include <bits/stdc++.h>

using namespace std;



const int mxn = 100005;

int n, h[mxn], ff[mxn];



int main()

{

  scanf("%d", &n);

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

  {

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

  } 

  h[n + 1] = 0;

  ff[n] = 0, ff[n + 1] = 1e6; 

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

  {

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

  }

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

  return 0;

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

using namespace std;



typedef long long int ll;

#define    mod      1000000007

#define    speed    ios_base::sync_with_stdio(false);

#define    up       cin.tie(NULL);

#define    pb       push_back

#define    mp       make_pair

#define    T        int t; cin >> t; while(t--)

ll dp[100005] , arr[100005];

int n;



ll solve(int i){

    if(i > n){

        return 100000;

    }

    if(i==n){

        return 0;

    }

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

        return dp[i];

    }

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

    ll temp2 = abs(arr[i+2] - arr[i]) + solve(i+2);

    return (dp[i] = min(temp1 , temp2));

}



int main(){

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

      dp[i] = -1;

  }

  cin >> n;

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

      cin >> arr[i];

  }

  cout << solve(1) << '\n';

}

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

using namespace std;

 

typedef long long int ll;

#define    mod      1000000007

#define    speed    ios_base::sync_with_stdio(false);

#define    up       cin.tie(NULL);

#define    pb       push_back

#define    mp       make_pair

#define    T        int t; cin >> t; while(t--)



int main(){

    speed up

    int n; cin >> n;

    int arr[n+5] , dp[n+5];

    cin >> arr[1]; dp[0] = dp[1] = 0;

    arr[0] = 100000;

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

        cin >> arr[i];

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

    }

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

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

using namespace std;



using ll = long long;

#define pb push_back

#define fastread ios_base::sync_with_stdio(false);cin.tie(NULL);

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

#define file freopen("in.txt", "r", stdin);

#define pii pair<int, int>

#define pll pair<ll, ll>



const int maxn = 1e5 + 5;

int arr[maxn];

ll dp[maxn];

int n;

ll call(int i){

	if(i >= n-1){

		return 0;

	}

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

	ll ret = 1e11;

	if(i+1 <= n-1)ret = min(ret, abs(arr[i] - arr[i+1])+call(i+1));

	if(i+2 <= n-1)ret = min(ret, abs(arr[i] - arr[i+2]) + call(i+2));

	return dp[i] = ret;

}



int main(){

	//file

	scanf("%d", &n);

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

	memset(dp, -1, sizeof dp);

	cout<<call(0)<<endl;

}

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

using namespace std;



const int maxn = 1e5 + 5; 

int a[maxn];

long long dp[maxn];



int main(){

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

	int n;

	scanf("%d", &n);

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

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

	}

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

	dp[1] = 0;

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

		if(i+1 <= n){

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

		}

		if(i+2 <= n){

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

		}

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

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

#include <algorithm>

using namespace std;



int main() {

  const long long INF = 1LL << 60;

  int h[100010];

  long long dp[100010];

  for (int i = 0; i < 100010; ++i) dp[i] = INF;

  dp[0] = 0LL;



  int N;

  cin >> N;

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

    cin >> h[i];

  }



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

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

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

  }



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



  return 0;

}


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

#include <algorithm>

using namespace std;



static const int INF = (1 << 30);

static const int MAX = 100010;



int main()

{

  int N;

  int DP[MAX + 1];

  int A[MAX];



  cin >> N;

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

  {

    cin >> A[i];

    DP[i] = INF;

  }



  DP[0] = 0;

  DP[N] = INF;



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

  {

    DP[i + 1] = min(DP[i + 1], DP[i] + abs(A[i + 1] - A[i]));

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

  }



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



  return 0;

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

using namespace std;

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

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

using ll = long long;

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

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



int main() {

	

	

	

	int n; cin >> n;

	

	vector<int> a(n);

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

	//sort(a.begin(),a.end());

	

	

	//vector<int> cost(n,10000000);

	

	ll cost[100010];

	rep(i,100010) cost[i]=10000000000000;

	

	

	cost[0]=0;

	

	

	/*

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

		

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

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

	}

	*/

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

        chmin(cost[i], cost[i - 1] + abs(a[i] - a[i - 1]));

        if (i > 1) chmin(cost[i], cost[i - 2] + abs(a[i] - a[i - 2]));

    }







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

	return 0;



}

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

using namespace std;

#define ll long long

#define repl(i,n) for(ll i=0;i<n;i++)

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



const long double PI = (acos(-1));

const long double EPS = 0.0000000001;

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



int main() {

	

	

	cin.tie(0);

	ios::sync_with_stdio(false);

	

	int n; cin >> n;

	int ans;

	

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

	vector<int> dp(n+1,INT_MAX);

	

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

	

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

		

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

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

		

		chmin(dp[i+1],dp[i]+d1);

		chmin(dp[i+2],dp[i]+d2);

	}

	

	ans=dp[n-1];

	

	cout << ans << "\n";

	

	return 0;

}





//vector<int> a(n);  sort(a.begin(),a.end());

//cout << "test" << "\n";





//g++ -o a a.cpp
// Slower C++ solution:
#include <bits/stdc++.h>

using namespace std;

#define int long long



int memo[100005];



int f(int a[],int n)

{

    if(memo[n]!=-1)

       return memo[n];

       

    if(n==2)

        return abs(a[n-2]-a[n-1]);

    if(n==3)

        return min(abs(a[n-1]-a[n-3]),(abs(a[n-1]-a[n-2]) + abs(a[n-2]-a[n-3])));

    else

    {

        int res=min((f(a,n-1) + abs(a[n-1]-a[n-2])) , (f(a,n-2) + abs(a[n-1]-a[n-3])));

        memo[n]=res;

        return res;

    }

}

#undef int

int main()

{

 #define int long long

    int n;

    cin >> n;

    int a[n];

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

       cin >> a[i];



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

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

}

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

using namespace std;



int main() {

#define int long long

    int n;

    cin >> n;

    int h[n+1],dp[n+1];

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

    {

        cin >> h[i];

    }

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

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

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

    {

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

    }

    cout << dp[n] << endl;

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

using namespace std;

int main()

{

  int n,h[100005],dp[100005]={};

  cin>>n;

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

    cin>>h[i];

  }



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

    if(i==1){

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

    }else{

      if(abs(h[i]-h[i-1])+dp[i-1] > abs(h[i]-h[i-2])+dp[i-2]){

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

      }else{

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

      }

    }

  }

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

  return 0;

}


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

using namespace std;

int main()

{

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

  cin>>n;

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

    cin>>h[i];

  }

  dp[0]=0;

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

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

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

  }



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

  return 0;

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

using namespace std;

int N;

vector<int>v;

int dp[100000+1];

int culc(int i){

    if(i == N)return 0;

    if(i == 0){

        dp[i]  = 0;

    }else if(i == 1){

        dp[i] = abs(v[i]-v[i-1]);

    }

    else {

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

                        abs(v[i] - v[i-2])+dp[i-2]);

    }

    return culc(i+1);

}

int main(){

    cin>>N;

    v.resize(N);

    for(int i=0;i<N;i++)cin>>v[i];

    memset(dp,0,sizeof dp);

    culc(0);

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

	return 0 ;

}


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

using namespace std;



int main(){

    int N;cin>>N;

    vector<int>v(N);

    for(register int i=0;i<N;i++)cin>>v[i];

    int dp[N+1];

    memset(dp,0,sizeof dp);

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

        if(i == 0){

            dp[i] = 0;

        }

        else if(i == 1){

            dp[i] = abs(v[i]-v[i-1]);

        }

        else {

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

                        abs(v[i] - v[i-2])+dp[i-2]);

        }

     //   cout<<i<< " "<<dp[i]<<endl;

    }

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

	return 0 ;

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

using namespace std;

#define I INT32_MAX

#define IM INT_MIN

#define MOD 1000000007

#define ll long long

#define lli long long int

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

#define repk(i,k,n) for (int i = k; i <= n; i++)

#define repr(i,k,n) for (int i = k; i >= n; i--)

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

typedef vector<int> vi;

typedef set<int> si;

ll dp[100005];

ll arr[100005];

ll n;



ll mincost(ll i) {

	// int n = sizeof(arr);

	if (i == n - 1) {

		return 0;



	}

	if (i >= n) return INT_MAX;



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

		return dp[i];

	}

	ll onejump = mincost(i + 1) + abs(arr[i] - arr[i + 1]);

	ll twojump = INT_MAX;

	if (i + 2 < n) {

		twojump = mincost(i + 2) + abs(arr[i] - arr[i + 2]);



	}

	return dp[i] = min(onejump, twojump);



}



void solve() {

	// int n;

	cin >> n;



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

	rep(i, n) {

		cin >> arr[i];

	}

	cout << mincost(0);

}



int main() {

	ios::sync_with_stdio(0);

	cin.tie(0);



	int t = 1;

	// cin >> t;

	while (t--)

		solve();



	return 0;



}










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

using namespace std;

#define I INT32_MAX

#define IM INT_MIN

#define MOD 1000000007

#define ll long long

#define lli long long int

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

#define repk(i,k,n) for (int i = k; i <= n; i++)

#define repr(i,k,n) for (int i = k; i >= n; i--)

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

typedef vector<int> vi;

typedef set<int> si;





void solve() {

	ll n;

	cin >> n;

	std::vector<ll> arr(n + 1);

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

	{

		cin >> arr[i];

	}

	std::vector<ll> dp(n + 1);

	dp[0] = 0;

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

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

	{

		ll onejump = dp[i - 1] + abs(arr[i] - arr[i - 1]);

		ll twojump  = dp[i - 2] + abs(arr[i] - arr[i - 2]);

		dp[i] = min(onejump, twojump);

	}

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



}



int main() {

	ios::sync_with_stdio(0);

	cin.tie(0);



	int t = 1;

	// cin >> t;

	while (t--)

		solve();



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



using namespace std;



const int N = 100001;

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



int solve(int i) {

    if (i == 1) {

        return 0;

    }

    int& ans = dp[i];

    if (ans != -1) {

        return ans;

    }

    ans = 1e9;

    if (i > 1) {

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

    }

    if (i > 2) {

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

    }

    return ans;

}



int main() {

    cin >> n;

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

        cin >> h[i];

    }

    memset(dp, -1, sizeof dp);

    cout << solve(n);

    return 0;

}


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



using namespace std;



const int N = 1e5 + 1;

int dp[N], h[N];



int main() {

    int n;

    cin >> n;

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

        cin >> h[i];

    }

    dp[1] = 0;

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

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

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

    }

    cout << dp[n];

    return 0;

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

using namespace std;

typedef long long ll;

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

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

// Welcome to my source code!



const ll INF = 1LL<<60;



int main() {

    int n;

    cin >> n;

    ll h[n];

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

    ll dp[101000];

    for (int i = 0; i < 101000; i++) dp[i] = INF;

    dp[0] = 0;

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

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

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

    }

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

}

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

using namespace std;

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

typedef long long ll;

// Welcome to my source code!



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

    if (a > b) {

        a = b;

        return true;

    }

    return false;

}

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

    if (a < b) {

        a = b;

        return true;

    }

    return false;

}



const int INF = 1e9;



int main() {

    IOS

    int n;

    cin >> n;

    int h[n];

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

    int dp[n];

    for (int i = 0; i < n; i++) dp[i] = INF;

    dp[0] = 0;

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

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

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

    }

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

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

using namespace std;

typedef long long ll;

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

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

// Welcome to my source code!



const ll INF = 1LL<<60;



int main() {

    int n;

    cin >> n;

    ll h[n];

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

    ll dp[101000];

    for (int i = 0; i < 101000; i++) dp[i] = INF;

    dp[0] = 0;

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

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

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

    }

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

}

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

using namespace std;

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

typedef long long ll;

// Welcome to my source code!



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

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



const int INF = 1e9;



int main() {

    int n;

    cin >> n;

    int h[n], dp[n];

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

    dp[0] = 0;

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

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

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

    }

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

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

using namespace std;

typedef long long ll;

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

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

// Welcome to my source code!



const ll INF = 1LL<<60;



int main() {

    int n;

    cin >> n;

    ll h[n];

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

    ll dp[101000];

    for (int i = 0; i < 101000; i++) dp[i] = INF;

    dp[0] = 0;

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

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

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

    }

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

}

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

using namespace std;

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

typedef long long ll;

// Welcome to my source code!



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

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



const int INF = 1e9;



int main() {

    IOS

    int n;

    cin >> n;

    int h[n], dp[n];

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

    for (int i = 0; i < n; i++) dp[i] = INF;

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

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

}