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



using namespace std;





int main(){

    int n;

    cin >> n;

    int a[n + 1];

    int dp[n + 1];

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

    /*

    dp[0] = a[0];

    dp[1] = a[0] + a[1];

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

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

    }

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

    */

    dp[0] = 0;

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

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

}

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

#include <stdio.h>

#include <stdlib.h>

#include <algorithm>

using namespace std;

//#define                     IO                                              ios_base::sync_with_stdio(0); cin.tie(0)



int main(){

    //IO;

    int n;

    //cin >> n;

    scanf("%d",&n);

    int a[n + 1];

    int dp[n + 1];

    for(int i = 0; i < n; i++) scanf("%d",&a[i]);//cin >> a[i];

    /*

    dp[0] = a[0];

    dp[1] = a[0] + a[1];

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

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

    }

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

    */

    dp[0] = 0;

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

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

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

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



using namespace std;





int main(){

    int n;

    //cin >> n;

    scanf("%d",&n);

    int a[n + 1];

    int dp[n + 1];

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

    /*

    dp[0] = a[0];

    dp[1] = a[0] + a[1];

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

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

    }

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

    */

    dp[0] = 0;

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

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

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

}

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

#include <stdio.h>

#include <stdlib.h>

#include <algorithm>

using namespace std;

//#define                     IO                                              ios_base::sync_with_stdio(0); cin.tie(0)



int main(){

    //IO;

    int n;

    //cin >> n;

    scanf("%d",&n);

    int a[n + 1];

    int dp[n + 1];

    for(int i = 0; i < n; i++) scanf("%d",&a[i]);//cin >> a[i];

    /*

    dp[0] = a[0];

    dp[1] = a[0] + a[1];

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

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

    }

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

    */

    dp[0] = 0;

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

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

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

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



using namespace std;

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



int main(){

    IO;

    int n;

    cin >> n;

    //scanf("%d",&n);

    int a[n + 1];

    int dp[n + 1];

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

    /*

    dp[0] = a[0];

    dp[1] = a[0] + a[1];

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

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

    }

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

    */

    dp[0] = 0;

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

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

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

}

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

#include <stdio.h>

#include <stdlib.h>

#include <algorithm>

using namespace std;

//#define                     IO                                              ios_base::sync_with_stdio(0); cin.tie(0)



int main(){

    //IO;

    int n;

    //cin >> n;

    scanf("%d",&n);

    int a[n + 1];

    int dp[n + 1];

    for(int i = 0; i < n; i++) scanf("%d",&a[i]);//cin >> a[i];

    /*

    dp[0] = a[0];

    dp[1] = a[0] + a[1];

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

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

    }

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

    */

    dp[0] = 0;

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

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

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

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



using namespace std;

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



int main(){

    IO;

    int n;

    //cin >> n;

    scanf("%d",&n);

    int a[n + 1];

    int dp[n + 1];

    for(int i = 0; i < n; i++) scanf("%d",&a[i]);//cin >> a[i];

    /*

    dp[0] = a[0];

    dp[1] = a[0] + a[1];

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

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

    }

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

    */

    dp[0] = 0;

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

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

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

}

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

#include <stdio.h>

#include <stdlib.h>

#include <algorithm>

using namespace std;

//#define                     IO                                              ios_base::sync_with_stdio(0); cin.tie(0)



int main(){

    //IO;

    int n;

    //cin >> n;

    scanf("%d",&n);

    int a[n + 1];

    int dp[n + 1];

    for(int i = 0; i < n; i++) scanf("%d",&a[i]);//cin >> a[i];

    /*

    dp[0] = a[0];

    dp[1] = a[0] + a[1];

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

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

    }

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

    */

    dp[0] = 0;

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

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

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

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

using namespace std;

#define ll long long

#define vi vector<int>

#define pb push_back

#define pii pair<int , int>

#define fast ios_base::sync_with_stdio(0)

#define mx 100005

#define inf 100000000000000000LL

ll arr[mx], dp[mx];

int n;

ll solve(int pos)

{

    if(pos==n) return 0;

    ll&ret = dp[pos];

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

    ret = inf;

    ret = min(ret, llabs(arr[pos] - arr[pos+1]) + solve(pos+1));

    if(pos+1 != n)ret = min(ret, llabs(arr[pos] - arr[pos+2]) + solve(pos+2));

    return ret;

}

int main()

{

    //fast;

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

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

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

        memset(dp, -1, sizeof dp);

        printf("%lld\n", solve(1));

        return 0;

    }

}




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

using namespace std;

#define ll long long

#define vi vector<int>

#define pb push_back

#define pii pair<int , int>

#define fast ios_base::sync_with_stdio(0)

#define mx 100005

#define inf 100000000000000000LL

ll arr[mx], dp[mx];

int main()

{

    int n;

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

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

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

        dp[n] = 0;

        dp[n-1] = llabs(arr[n] - arr[n-1]);

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

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

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

        return 0;

    }

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

using namespace std;



const int mx = 1e9+5;

int m[100005];

int T[100005];



// 10 30 40 20

// 0   1  2  3

//    10  20

int minHeightIncurred(int i , int n ,int val , int *res)

{

	if(T[i] != -1)

	{

		if(val + T[i] < *res)

			*res = val + T[i];

				

		return *res;

	}

	else

	{

		int k =0 , t =val; // preserving 

		if(i<n-1)

		{

			k = abs(m[i] - m[i+1]);

			val = minHeightIncurred(i+1 , n , val + k , res);

		}

			

		if(i<n-2)

		{

			k =  abs(m[i] - m[i+2]);

			val = t;	

			val = minHeightIncurred(i+2 , n , val + k , res);

		}

		



		// Here 'val' contains the min. val for each path

		if(*res>val)

		{

			*res =val;

		}

		else

		{

			T[i] = abs(val - t);

		}



		return *res;

	}

}





int main()

{

	ios_base::sync_with_stdio(false);

	cin.tie(NULL);



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



	int n;

	cin>>n;



	int res = mx;	

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

	{

		cin>>m[i];

	}



	minHeightIncurred(0 , n , 0 , &res); // INDEX , SIZE  , JMP_VAL

	cout<<res<<"\n";

}



//END


















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

using namespace std;



const int INF = 1e9+5;



int main()

{

	int n;

	scanf("%d",&n);

	vector<int> h(n);



	for(int &x : h)

		scanf("%d",&x);



	vector<int> dp(n , INF);



	dp[0] = 0;

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

	{

		for(int j : {i+1 , i+2})

		{

			if(j<n)

			{

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

			}

		}

	}



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

}







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

using namespace std;

#define ll long long



const ll INF= 1LL << 60;



//入力

ll N;

ll h[100010];

//dp

ll dp[100010];





void min(ll& a, ll& b){

  if(a<b){

    a=b;

  }

}



int main(){

  cin >>N;

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

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

  

  dp[0]=0;

  

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

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

    if(i>1) dp[i]=min(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.7631538282199821x):
#include <bits/stdc++.h>



using namespace std;



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

#define rep2(i,m,n) for(int (i)=(int)(n)-1;i>=(int)(m);i--)

#define REP(i,n) rep(i,0,n)

#define REP2(i,n) rep2(i,0,n)

#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)

#define ll long long

#define ull unsigned long long

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

#define en '\n'

template <class T> using vec = vector<T>;

template <class T> using vvec = vector<vec<T>>;

typedef pair<ll, ll> P;

constexpr long long INF = 1LL << 60;

constexpr int INF_INT = 1 << 25;

constexpr long long MOD = (ll) 1e9 + 7;

typedef vector<ll> Array;

typedef vector<Array> Matrix;

constexpr int loose = 0;

constexpr int tight = 1;





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;

}



struct Edge {

	ll to, cap, rev;

	Edge(ll _to, ll _cap, ll _rev) {

	to = _to; cap = _cap; rev = _rev;

	}

};

typedef vector<Edge> Edges;

typedef vector<Edges> Graph;



void add_edge(Graph& G, ll from, ll to, ll cap, bool revFlag, ll revCap) {

	G[from].push_back(Edge(to, cap, (ll)G[to].size()));

	if (revFlag)G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));

}



void solve(){

	ll n;

	cin>>n;

	Array h(n);

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

	

	Array dp(n+1,INF);

	dp[0]=0;

	REP(i,n){

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

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

	}

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

}



int main() {

    ios::sync_with_stdio(false);

    cin.tie(0);

    cout.tie(0);



    solve();

    return 0;

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

using namespace std;

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

#define scn(n) scanf("%d",&n)

#define lscn(n) scanf("%lld",&n)

typedef long long ll;

#define pri(n) printf("%d\n",n)

#define lpri(n) printf("%lld\n",n);

#define rep(i,st,ed) for(int i=st;i<ed;i++)

#define F first

#define S second 

#define pb(n) push_back(n)

const int N=2e5+6;

const ll M=1e9+7;

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

void  rec(int i)

{

	// printf("i= %d\n",i);

	if(dp[i]!=-1)

	{

		// printf("reached here1\n");

		return ;

	}

	

	if(i>=n-1)

	{

		dp[i]=0;

		// printf("reached here2 %d %d\n",i,n-1);

		return ;

	}

	ll ans1=1e18;

	ll ans2=1e18;

	if(i+1<n)

	{

		rec(i+1);

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

	}

	

	if(i+2<n)

	{

		rec(i+2);

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

	}

	// printf("for i= %d and n= %lld ans 1 = %lld ans2 = %lld\n",i,n,ans1,ans2);	

	dp[i]=min(ans1,ans2);

}

int main()

{

	lscn(n);

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

		lscn(a[i]);

	

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

	

	rec(0);

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

	// 	printf("%lld ",dp[i]);

	lpri(dp[0]);

}

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

using namespace std;

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

#define scn(n) scanf("%d",&n)

#define lscn(n) scanf("%lld",&n)

typedef long long ll;

#define pri(n) printf("%d\n",n)

#define lpri(n) printf("%lld\n",n);

#define rep(i,st,ed) for(int i=st;i<ed;i++)

#define var(n) int n; scn(n)

#define F first

#define S second 

#define pb push_back

const int N=1e6+5;

// const ll M = 998244353;

const ll M=1e9+7;

const ll inf=1e18;







int main()

{

	var(n);

	int a[n],dp[n];

	rep(i,0,n)

	{		

		scn(a[i]);

	}

	dp[0]=0;

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

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

	}

	pri(dp[n-1]);

}
// Slower C++ solution:
/*author  ADITYA BANSAL

         MNNIT ALLAHABAD     */

#include<bits/stdc++.h>

//#include <boost/multiprecision/cpp_int.hpp> 

//using namespace boost::multiprecision; 

using namespace std;

#define ll long long

ll power(ll,ll);

ll mul(ll a,ll b);

#define watch(x) cerr<<(#x)<<"is"<<x<<nl;

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

#define fi(a,b) for(ll i=a; i<b; i++)

#define fk(a,b) for(ll k=a; k<b; k++)

#define fri(a,b) for(ll i=a; i>b; i--)

#define fj(a,b) for(ll j=a; j<b; j++)

#define ffi(a,b) for(ll i=a;i*i<=b;i++)

#define mp make_pair

#define ff first 

#define  tc ll t; cin>>t; while(t--)

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

#define ss second

#define pb push_back

#define mem(v) memset((v),0,sizeof(v));

#define pll pair<ll,ll>

#define mll map<ll,ll>

#define sll set<ll>

#define vll vector<ll>

#define max3(a,b,c) max(a,max(b,c))

#define min3(a,b,c) min(a,min(b,c))

#define ad(a,b)  (a%mod+b%mod+mod)%mod

#define pob pop_back

#define nl endl

const int mod=1e9+7;

const ll  N=100002LL;



signed main(){ fast

  

  

  

   //tc

  // calc();

 {   ll h[100001],n;

	 ll dp[100001];

	 mem(dp)

	 cin>>n;

	 fi(1,n+1) cin>>h[i];

	 

	 dp[1]=0;

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

	

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

	

	fi(1,n+1) cerr<<dp[i]<<" "; 

	 cout<<dp[n]<<nl;

	  

 }

    return 0;

}





/******************************************************************************/



ll mul(ll a,ll b){

    return ((a)*1LL*(b))%13;

}



ll power(ll a,ll n){

  ll res=1;

  while(n){

      if(n&1) res= mul(res,a);

     n>>=1; 

     a= mul(a,a);

  }

    return res;

}


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

using namespace std;



#define ll  int

#define intmax INT_MAX

#define pi 3.14159265358979323846

#define ff first 

#define ss second

#define pb push_back

#define watch(x) cerr<<(#x)<<"  "<<x<<"\n";

const int MOD=998244353;

const int MAXN = 3e5+4;

int dp[MAXN],a[MAXN];



int main(){	

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



int n; cin>>n;

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

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

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

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

}



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





return 0;

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

#define sf1(n) scanf("%d",&n)

#define sf2(n,q) scanf("%d %d",&n,&q)

#define f first

#define ss second

#define pb push_back

#define lli long long

#define mem(ar,false) memset(ar,false,sizeof(ar))

#define mpr make_pair

#define endl "\n"

#define mod 1000000007

#define inf 9000000000000000000LL

using namespace std;



int ar[200005];

int n;

int dp[100005];

int func(int i)

{

    if(i==n-1)

        return 0;

    if(dp[i]!=-1)

        return dp[i];

    int ret1 = INT_MAX;

    int ret2 = INT_MAX;



    ret1 = abs(ar[i]-ar[i+1]) + func(i+1);

    if(i+2<n)

        ret2 = abs(ar[i]-ar[i+2]) + func(i+2);

    return dp[i] = min(ret1,ret2);

}



int main()

{

    ios_base::sync_with_stdio(false);

    cin.tie(NULL);

    mem(dp,-1);

    cin >> n;

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

        cin >> ar[i];



    int ans = func(0);



    cout << ans << endl;

    return 0;



}


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

#define sf1(n) scanf("%d",&n)

#define sf2(n,q) scanf("%d %d",&n,&q)

#define f first

#define ss second

#define pb push_back

#define lli long long

#define mem(ar,false) memset(ar,false,sizeof(ar))

#define mpr make_pair

#define endl "\n"

#define mod 1000000007

#define inf 9000000000000000000LL

using namespace std;



int ar[200005];

int n;

int dp[100005];

int func(int i)

{

    if(i==n-1)

        return 0;

    if(dp[i]!=-1)

        return dp[i];

    int ret1 = INT_MAX;

    int ret2 = INT_MAX;



    ret1 = abs(ar[i]-ar[i+1]) + func(i+1);

    if(i+2<n)

        ret2 = abs(ar[i]-ar[i+2]) + func(i+2);

    return dp[i] = min(ret1,ret2);

}



int main()

{

    ios_base::sync_with_stdio(false);

    cin.tie(NULL);

  //  mem(dp,-1);

    cin >> n;

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

        cin >> ar[i];



   // int ans = func(0);

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

    {

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

        int ret2 = INT_MAX;

        if(i-2>=0)

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

        dp[i] = min(ret1,ret2);

    }



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

    return 0;



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

#include <cstring>

using namespace std;

int dp[100000];

int n,a[100000];



int ans2(int i)

{

	if(i==n-1)

		return 0;



	if(i==n-2)

		return abs(a[i]-a[i+1]);



	if(dp[i]!=-1)

		return dp[i];



	int p = abs(a[i]-a[i+1]) + ans2(i+1);

	int q = abs(a[i]-a[i+2]) +ans2(i+2);



	return dp[i]=min(p,q);

}



int main()

{

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

	cin>>n;

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

		cin>>a[i];



	cout<<ans2(0);



	return 0;

}

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

using namespace std;

int dp[100000];

int n,a[100000];



int topdown()

{

	dp[n-1]=0;

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



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

	{

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

	}

	return dp[0];

}



int main()

{

	cin>>n;

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

		cin>>a[i];



	cout<<topdown();



	return 0;

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

#include <cstring>

using namespace std;

int dp[100000];

int n,a[100000];



int ans2(int i)

{

	if(i==n-1)

		return 0;



	if(i==n-2)

		return abs(a[i]-a[i+1]);



	if(dp[i]!=-1)

		return dp[i];



	int p = abs(a[i]-a[i+1]) + ans2(i+1);

	int q = abs(a[i]-a[i+2]) +ans2(i+2);



	return dp[i]=min(p,q);

}



int main()

{

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

	cin>>n;

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

		cin>>a[i];



	cout<<ans2(0);



	return 0;

}

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

using namespace std;





int topdown(int*a,int*dp,int n)

{

	dp[n-1]=0;

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



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

	{

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

	}

	return dp[0];

}



int main()

{  	

  	int dp[100000];

	int n,a[100000];

	cin>>n;

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

		cin>>a[i];



	cout<<topdown(a,dp,n);



	return 0;

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

#include <cstring>

using namespace std;

int dp[100000];

int n,a[100000];



int ans2(int i)

{

	if(i==n-1)

		return 0;



	if(i==n-2)

		return abs(a[i]-a[i+1]);



	if(dp[i]!=-1)

		return dp[i];



	int p = abs(a[i]-a[i+1]) + ans2(i+1);

	int q = abs(a[i]-a[i+2]) +ans2(i+2);



	return dp[i]=min(p,q);

}



int main()

{

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

	cin>>n;

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

		cin>>a[i];



	cout<<ans2(0);



	return 0;

}

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

using namespace std;





int topdown(int*a,int*dp,int n)

{

	dp[n-1]=0;

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



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

	{

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

	}

	return dp[0];

}



int main()

{  	

  	ios_base::sync_with_stdio(0);            

	cin.tie(NULL);

	cout.tie(NULL);

  	int dp[100000];

	int n,a[100000];

	cin>>n;

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

		cin>>a[i];



	cout<<topdown(a,dp,n);



	return 0;

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

using namespace std;

int dp[int(1e5) + 2];

int main()

  {int N; cin >> N;

  vector<int> hs(N); for (auto &h : hs) cin >> h;

  for (auto &i : dp) i = 1e9;

  dp[1] = 0;

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

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

    if (i + 1 < N) dp[i + 2] = min(dp[i + 2], dp[i] + abs(hs[i - 1] - hs[i + 1]));}

  cout << dp[N] << endl;}

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

using namespace std;

int dp[int(1e5)];

int main()

  {int N; cin >> N;

  vector<int> hs(N); for (auto &h: hs) cin >> h;

  for (int i = 1; i < N; ++i) dp[i] = min(dp[i - 1] + abs(hs[i - 1] - hs[i]), i < 2 ? int(1e9) : dp[i - 2] + abs(hs[i - 2] - hs[i]));

  cout << dp[N - 1] << endl;}
// Slower C++ solution:
#include <bits/stdc++.h>

using namespace std;

int dp[int(1e5) + 2];

int main()

  {int N; cin >> N;

  vector<int> hs(N); for (auto &h : hs) cin >> h;

  for (auto &i : dp) i = 1e9;

  dp[1] = 0;

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

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

    if (i + 1 < N) dp[i + 2] = min(dp[i + 2], dp[i] + abs(hs[i - 1] - hs[i + 1]));}

  cout << dp[N] << endl;}

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

using namespace std;

int main()

  {int N; cin >> N;

  vector<int64_t> dp(N, 1e15), hs(N); dp[0] = 0; for (auto &h : hs) cin >> h;

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

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

    if (i + 2 < N) dp[i + 2] = min(dp[i + 2], dp[i] + abs(hs[i] - hs[i + 2]));}

  cout << dp[N - 1] << endl;}
// Slower C++ solution:
#include <bits/stdc++.h>

using namespace std;

int dp[int(1e5) + 2];

int main()

  {int N; cin >> N;

  vector<int> hs(N); for (auto &h : hs) cin >> h;

  for (auto &i : dp) i = 1e9;

  dp[1] = 0;

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

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

    if (i + 1 < N) dp[i + 2] = min(dp[i + 2], dp[i] + abs(hs[i - 1] - hs[i + 1]));}

  cout << dp[N] << endl;}

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

using namespace std;

int main()

  {int N; cin >> N;

  vector<int64_t> dp(N);

  int H[N]; for (int &h: H) cin >> h;

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

    dp[i] = min(dp[i - 1] + abs(H[i] - H[i - 1]), i >= 2 ? dp[i - 2] + abs(H[i] - H[i - 2]) : int64_t(1e15));

  cout << dp[N - 1];}