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

#include<cstdio>

#include<cmath>

using namespace std;

const int maxn=100010;

const int INF=0x7fffffff;

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

void init(){

	scanf("%d",&n);

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

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

	for(int i=1;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]));

	}

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

}

int main(){

	init();

	return 0;

}

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

#include<cstdio>

#include<algorithm>



int main(){

  int s;

  long long st[100001],p[100001];

  scanf("%d",&s);

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

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

  }

  p[0]=0;

  p[1]=0;

  p[2]=(st[2]-st[1] < 0) ? st[1]-st[2] : st[2]-st[1];

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

    p[i] = std::min(p[i-1] + ((st[i]-st[i-1] < 0) ? st[i-1]-st[i] : st[i]-st[i-1]) , p[i-2] + ((st[i]-st[i-2] < 0) ? st[i-2]-st[i] : st[i]-st[i-2]));

  }

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

  return 0;

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

using namespace std;

int a[1000001],n;

int main()

{

	cin>>n;

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

	int f[100001];

	f[1]=0;

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

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

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

	cout<<f[n];

	return 0;

}

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

#include<cstdio>

#include<algorithm>



int main(){

  int s;

  long long st[100001],p[100001];

  scanf("%d",&s);

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

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

  }

  p[0]=0;

  p[1]=0;

  p[2]=(st[2]-st[1] < 0) ? st[1]-st[2] : st[2]-st[1];

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

    p[i] = std::min(p[i-1] + ((st[i]-st[i-1] < 0) ? st[i-1]-st[i] : st[i]-st[i-1]) , p[i-2] + ((st[i]-st[i-2] < 0) ? st[i-2]-st[i] : st[i]-st[i-2]));

  }

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

  return 0;

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

#include<iostream>

#include<cmath>

using namespace std;

const int MAXN = 100010;

int n, a[MAXN], f[MAXN];

int main()

{

	scanf("%d",&n);

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

		scanf("%d",&a[i]),f[i]=0x3f3f3f3f;

	f[0] = f[1] = 0; a[0] = a[1];

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

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

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

	return 0;

}

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

#include<cstdio>

#include<algorithm>



int main(){

  int s;

  long long st[100001],p[100001];

  scanf("%d",&s);

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

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

  }

  p[0]=0;

  p[1]=0;

  p[2]=(st[2]-st[1] < 0) ? st[1]-st[2] : st[2]-st[1];

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

    p[i] = std::min(p[i-1] + ((st[i]-st[i-1] < 0) ? st[i-1]-st[i] : st[i]-st[i-1]) , p[i-2] + ((st[i]-st[i-2] < 0) ? st[i-2]-st[i] : st[i]-st[i-2]));

  }

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

  return 0;

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

#include <algorithm>

#include <iostream>

#include <cstring>

#include <cstdlib>

#include <iomanip>

#include <vector>

#include <cstdio>

#include <stack>

#include <queue>

#include <deque>

#include <cmath>

#include <list>

#include <set>

#include <map>



using namespace std;



int a[1000010];

int f[1000010];



int main(void)

{

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

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

	int n;

	cin >> n;

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

	{

		cin >> a[i];

	}

	f[1] = 0;

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

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

	{

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

		//cout << f[i] << endl;

	}

	cout  << f[n] << endl;

	return 0;

}






















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

#include<cstdio>

#include<algorithm>



int main(){

  int s;

  long long st[100001],p[100001];

  scanf("%d",&s);

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

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

  }

  p[0]=0;

  p[1]=0;

  p[2]=(st[2]-st[1] < 0) ? st[1]-st[2] : st[2]-st[1];

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

    p[i] = std::min(p[i-1] + ((st[i]-st[i-1] < 0) ? st[i-1]-st[i] : st[i]-st[i-1]) , p[i-2] + ((st[i]-st[i-2] < 0) ? st[i-2]-st[i] : st[i]-st[i-2]));

  }

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

  return 0;

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

using namespace std;

int h[110010];

int f[11000];

int jd(int a)

{

	if(a>=0)

		return a;

	else 

		return -a;

}

int main(){

	int n;

	cin>>n;

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

	{

		cin>>h[i];

	}

	f[1]=0;

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

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

	{

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

	}

	cout<<f[n];

	return 0;

}




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

#include<cstdio>

#include<algorithm>



int main(){

  int s;

  long long st[100001],p[100001];

  scanf("%d",&s);

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

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

  }

  p[0]=0;

  p[1]=0;

  p[2]=(st[2]-st[1] < 0) ? st[1]-st[2] : st[2]-st[1];

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

    p[i] = std::min(p[i-1] + ((st[i]-st[i-1] < 0) ? st[i-1]-st[i] : st[i]-st[i-1]) , p[i-2] + ((st[i]-st[i-2] < 0) ? st[i-2]-st[i] : st[i]-st[i-2]));

  }

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

  return 0;

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

using namespace std;

long h[100005], f[100005];

int main()

{

	int n;

	cin >> n;

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

	{

		cin >> h[i];

	}

	f[1] = 0;

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

	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.3478726946357025x):
#include<cmath>

#include<cstdio>

#include<algorithm>



int main(){

  int s;

  long long st[100001],p[100001];

  scanf("%d",&s);

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

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

  }

  p[0]=0;

  p[1]=0;

  p[2]=(st[2]-st[1] < 0) ? st[1]-st[2] : st[2]-st[1];

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

    p[i] = std::min(p[i-1] + ((st[i]-st[i-1] < 0) ? st[i-1]-st[i] : st[i]-st[i-1]) , p[i-2] + ((st[i]-st[i-2] < 0) ? st[i-2]-st[i] : st[i]-st[i-2]));

  }

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

  return 0;

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

#define eps 1e-3

#define pi acos(-1.0)

#define inf 0x3f3f3f3f

#define debug1 cout<<"&&";

#define debug2 cout<<"**";

#define pb push_back

#define ms(a, x) memset(a, x, sizeof(a))

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

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

typedef double db;

typedef long long ll;

typedef unsigned long long ull;

using namespace std;

const int mod = 1e9;

const int N = 1e5+10;

/*=======================================================================*/



int n, h[N], sum;

int f[N];



int main() {

   scanf("%d", &n);

   for1(i, n) {

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

   }

   ms(f, inf);

   f[n] = 0;

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

      if(i == 2) {

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

      } else {

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

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

      }

      // if(i == 2) {

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

      //    i--;

      // } else {

      //    if(abs(h[i] - h[i-1]) < abs(h[i] - h[i-2])) {

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

      //       i -= 1;

      //    } else {

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

      //       i -= 2;

      //    }

      // }

   }

   cout << f[1] << endl;

   return 0;

}

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

#include<cstdio>

#include<algorithm>



int main(){

  int s;

  long long st[100001],p[100001];

  scanf("%d",&s);

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

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

  }

  p[0]=0;

  p[1]=0;

  p[2]=(st[2]-st[1] < 0) ? st[1]-st[2] : st[2]-st[1];

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

    p[i] = std::min(p[i-1] + ((st[i]-st[i-1] < 0) ? st[i-1]-st[i] : st[i]-st[i-1]) , p[i-2] + ((st[i]-st[i-2] < 0) ? st[i-2]-st[i] : st[i]-st[i-2]));

  }

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

  return 0;

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

using namespace std;



const int nax = 1e5+3;

int n;

int dp[nax];

int a[nax];

int f(int i){

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

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

	int ans = abs(a[i]-a[i+1])+f(i+1);

	if(i!=n-2) ans = min(ans, abs(a[i]-a[i+2])+f(i+2));

	return dp[i]=ans;

}

int main(){

	cin>>n;

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

	memset(dp, -1, sizeof dp);

	cout<<f(0)<<endl;

	return 0;

}


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

#include<cstdio>

#include<algorithm>



int main(){

  int s;

  long long st[100001],p[100001];

  scanf("%d",&s);

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

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

  }

  p[0]=0;

  p[1]=0;

  p[2]=(st[2]-st[1] < 0) ? st[1]-st[2] : st[2]-st[1];

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

    p[i] = std::min(p[i-1] + ((st[i]-st[i-1] < 0) ? st[i-1]-st[i] : st[i]-st[i-1]) , p[i-2] + ((st[i]-st[i-2] < 0) ? st[i-2]-st[i] : st[i]-st[i-2]));

  }

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

  return 0;

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

using namespace std;

int cont;

int m,n,l[100000];

int dp[1000000];

main()

{

    cin>>m;

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

        cin>>l[i];

    }

    dp[1]=0;

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

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

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

    }

   // cout<<dp[1]<<" "<<dp[3]<<" "<<dp[5]<<" ";

    cout<<dp[m];



}


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

#include<cstdio>

#include<algorithm>



int main(){

  int s;

  long long st[100001],p[100001];

  scanf("%d",&s);

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

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

  }

  p[0]=0;

  p[1]=0;

  p[2]=(st[2]-st[1] < 0) ? st[1]-st[2] : st[2]-st[1];

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

    p[i] = std::min(p[i-1] + ((st[i]-st[i-1] < 0) ? st[i-1]-st[i] : st[i]-st[i-1]) , p[i-2] + ((st[i]-st[i-2] < 0) ? st[i-2]-st[i] : st[i]-st[i-2]));

  }

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

  return 0;

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

#include <bits/stdc++.h>



int arr[100000];

int arr2[100000];



int main()

{

	int n;

	std::cin >> n;

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

	{

		std::cin >> arr[i];

	}

	for (int i = n-2; 0 <= i; i--)

	{

		int min = INT_MAX;

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

		{

			if (i + j < n) {

				int dif = std::abs(arr[i] - arr[i + j]) + arr2[i + j];

				if (dif < min)

					min = dif;

			}

		}

		arr2[i] = min;

	}

	std::cout << arr2[0] << std::endl;

}

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

#include<cstdio>

#include<algorithm>



int main(){

  int s;

  long long st[100001],p[100001];

  scanf("%d",&s);

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

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

  }

  p[0]=0;

  p[1]=0;

  p[2]=(st[2]-st[1] < 0) ? st[1]-st[2] : st[2]-st[1];

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

    p[i] = std::min(p[i-1] + ((st[i]-st[i-1] < 0) ? st[i-1]-st[i] : st[i]-st[i-1]) , p[i-2] + ((st[i]-st[i-2] < 0) ? st[i-2]-st[i] : st[i]-st[i-2]));

  }

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

  return 0;

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

# define ll long long

# define fi first

# define se second



using namespace std ;



ll n, x ;

ll ans[100001], vc[100001];



int main() {

    cin >> n ;

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

        cin >> vc[i] ;

    }

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

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

        if( i > 1 ) ans[i] = min(ans[i], abs(vc[i]-vc[i-2]) + ans[i-2] ) ;

    }

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

}


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

#include<cstdio>

#include<algorithm>



int main(){

  int s;

  long long st[100001],p[100001];

  scanf("%d",&s);

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

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

  }

  p[0]=0;

  p[1]=0;

  p[2]=(st[2]-st[1] < 0) ? st[1]-st[2] : st[2]-st[1];

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

    p[i] = std::min(p[i-1] + ((st[i]-st[i-1] < 0) ? st[i-1]-st[i] : st[i]-st[i-1]) , p[i-2] + ((st[i]-st[i-2] < 0) ? st[i-2]-st[i] : st[i]-st[i-2]));

  }

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

  return 0;

}
// Slower C++ solution:
//بِسْمِ اللَّهِ الرَّحْمَنِ الرَّحِيمِ

//لا إله إلا الله محمد رسول الله



#include <bits/stdc++.h>



#pragma GCC optimize("Ofast")



#define ll long long

#define pb push_back

#define fr first

#define sc second

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

#define out freopen("snakes.out", "w", stdout)

using namespace std;



ll n;

ll h[100005];

ll dp[100005];

int main(){

    //in;

    //out;

    ios_base::sync_with_stdio(false);

    cin >> n;

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

        cin >> h[i];

    }



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

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

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

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

        }

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

    }



    cout << dp[n];

}






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

#include<cstdio>

#include<algorithm>



int main(){

  int s;

  long long st[100001],p[100001];

  scanf("%d",&s);

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

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

  }

  p[0]=0;

  p[1]=0;

  p[2]=(st[2]-st[1] < 0) ? st[1]-st[2] : st[2]-st[1];

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

    p[i] = std::min(p[i-1] + ((st[i]-st[i-1] < 0) ? st[i-1]-st[i] : st[i]-st[i-1]) , p[i-2] + ((st[i]-st[i-2] < 0) ? st[i-2]-st[i] : st[i]-st[i-2]));

  }

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

  return 0;

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

using namespace std;

typedef long long ll;

typedef long long int lli;

typedef long double ld;

const int oo = 1e9;

const int mod = 1e9+9;



const int ppt = 1e5+3;

int n;

int dp[ppt];

int a[ppt];

int f(int i){

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

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

	int jpr = abs(a[i]-a[i+1])+f(i+1);

	if(i!=n-2) jpr = min(jpr, abs(a[i]-a[i+2])+f(i+2));

	return dp[i]=jpr;

}

int main(){

	cin>>n;

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

	memset(dp, -1, sizeof dp);

	cout<<f(0)<<endl;

	return 0;

}


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

#include<cstdio>

#include<algorithm>



int main(){

  int s;

  long long st[100001],p[100001];

  scanf("%d",&s);

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

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

  }

  p[0]=0;

  p[1]=0;

  p[2]=(st[2]-st[1] < 0) ? st[1]-st[2] : st[2]-st[1];

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

    p[i] = std::min(p[i-1] + ((st[i]-st[i-1] < 0) ? st[i-1]-st[i] : st[i]-st[i-1]) , p[i-2] + ((st[i]-st[i-2] < 0) ? st[i-2]-st[i] : st[i]-st[i-2]));

  }

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

  return 0;

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

using namespace std;

typedef long long ll;

typedef long long int lli;

typedef long double ld;

const int oo = 1e9;

const int mod = 1e9+9;



const int nax = 1e5+3;

int n;

int dp[nax];

int a[nax];

int f(int i){

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

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

	int ans = abs(a[i]-a[i+1])+f(i+1);

	if(i!=n-2) ans = min(ans, abs(a[i]-a[i+2])+f(i+2));

	return dp[i]=ans;

}

int main(){

	cin>>n;

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

	memset(dp, -1, sizeof dp);

	cout<<f(0)<<endl;

	return 0;

}

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

#include<cstdio>

#include<algorithm>



int main(){

  int s;

  long long st[100001],p[100001];

  scanf("%d",&s);

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

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

  }

  p[0]=0;

  p[1]=0;

  p[2]=(st[2]-st[1] < 0) ? st[1]-st[2] : st[2]-st[1];

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

    p[i] = std::min(p[i-1] + ((st[i]-st[i-1] < 0) ? st[i-1]-st[i] : st[i]-st[i-1]) , p[i-2] + ((st[i]-st[i-2] < 0) ? st[i-2]-st[i] : st[i]-st[i-2]));

  }

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

  return 0;

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



#define ll int64

#define pb push_back

#define ff first

#define ss second

#define sz size()

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

#define allr(a) a.rbegin(), a.rend()

#define mod 1000000007

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

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

     

using namespace std;



const int maxn=110000;

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

int main(){

    IO;    

    scanf("%d",&n);

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

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

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

    printf("%d",f[n]);    

    return 0;

}

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

#include<cstdio>

#include<algorithm>



int main(){

  int s;

  long long st[100001],p[100001];

  scanf("%d",&s);

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

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

  }

  p[0]=0;

  p[1]=0;

  p[2]=(st[2]-st[1] < 0) ? st[1]-st[2] : st[2]-st[1];

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

    p[i] = std::min(p[i-1] + ((st[i]-st[i-1] < 0) ? st[i-1]-st[i] : st[i]-st[i-1]) , p[i-2] + ((st[i]-st[i-2] < 0) ? st[i-2]-st[i] : st[i]-st[i-2]));

  }

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

  return 0;

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

#define ll long long

#define ld long double

using namespace std;

const int N = 1e5+5;



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





int solve(int i)

{

    if(i == n-1)

        return 0;

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

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

    ll op2 = op1;

    if(i + 2 < n)

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

    return dp[i] = min(op1, op2);

}



int table()

{

    dp[0] = 0;

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

    {

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

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

    }

    return dp[n-1];

}



int main()

{

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

    cin >> n;

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

        cin >> h[i];

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

    cout << table();

    // cout << solve(0);





    return 0;

}


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

#include<cstdio>

#include<algorithm>



int main(){

  int s;

  long long st[100001],p[100001];

  scanf("%d",&s);

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

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

  }

  p[0]=0;

  p[1]=0;

  p[2]=(st[2]-st[1] < 0) ? st[1]-st[2] : st[2]-st[1];

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

    p[i] = std::min(p[i-1] + ((st[i]-st[i-1] < 0) ? st[i-1]-st[i] : st[i]-st[i-1]) , p[i-2] + ((st[i]-st[i-2] < 0) ? st[i-2]-st[i] : st[i]-st[i-2]));

  }

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

  return 0;

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

using namespace std;

typedef long long ll;

typedef long long int lli;

typedef long double ld;

const int oo = 1e9;

const int mod = 1e9+9;

/*ll gcd(ll x, ll y){return (y ? gcd(y, x%y) : x); }

*ll lcm(ll x, ll y){return x*(y/gcd(x,y));}

*void exEuclid(int a, int b){

	if(b==0){x = 1; y=0; d=a; return ;}

	exEuclid(b, a%b);

	int x1=y;

	int y1=x-(a/b)*y;

	x=x1;

	y=y1;

} 

* */

//===========================================================//

const int nax = 1e5+3;

int n;

int dp[nax];

int a[nax];

int f(int i){

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

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

	int ans = abs(a[i]-a[i+1])+f(i+1);

	if(i!=n-2) ans = min(ans, abs(a[i]-a[i+2])+f(i+2));

	return dp[i]=ans;

}

int main(){

	cin>>n;

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

	memset(dp, -1, sizeof dp);

	cout<<f(0)<<endl;

	return 0;

}

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

#include<cstdio>

#include<algorithm>



int main(){

  int s;

  long long st[100001],p[100001];

  scanf("%d",&s);

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

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

  }

  p[0]=0;

  p[1]=0;

  p[2]=(st[2]-st[1] < 0) ? st[1]-st[2] : st[2]-st[1];

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

    p[i] = std::min(p[i-1] + ((st[i]-st[i-1] < 0) ? st[i-1]-st[i] : st[i]-st[i-1]) , p[i-2] + ((st[i]-st[i-2] < 0) ? st[i-2]-st[i] : st[i]-st[i-2]));

  }

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

  return 0;

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

using namespace std;

int numStones;

int heights[100005],b[100005];

int main(){

	cin>>numStones;

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

	    cin>>heights[i];

	}

	b[2]=abs(heights[1]-heights[2]);

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

	    b[i]=min(b[i-1]+abs(heights[i-1]-heights[i]),b[i-2]+abs(heights[i-2]-heights[i]));

	}

	cout<<b[numStones];

	return 0;

}

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

#include<cstdio>

#include<algorithm>



int main(){

  int s;

  long long st[100001],p[100001];

  scanf("%d",&s);

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

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

  }

  p[0]=0;

  p[1]=0;

  p[2]=(st[2]-st[1] < 0) ? st[1]-st[2] : st[2]-st[1];

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

    p[i] = std::min(p[i-1] + ((st[i]-st[i-1] < 0) ? st[i-1]-st[i] : st[i]-st[i-1]) , p[i-2] + ((st[i]-st[i-2] < 0) ? st[i-2]-st[i] : st[i]-st[i-2]));

  }

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

  return 0;

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

using namespace std;

 

typedef long long lld;

const int NN = 1e5 + 5;

lld aa[NN], dp[NN];

int nn;

 

int main() {

    ios::sync_with_stdio(0);

    cin.tie(0); 

    cout.tie(0);

        cin >> nn;

        for (int ii = 1; ii <= nn; ++ii)

            cin >> aa[ii];

        dp[1] = 0;

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

        for (int ii = 3; ii <= nn; ++ii)

            dp[ii] = min(dp[ii-1] + abs(aa[ii] - aa[ii - 1]), dp[ii-2] + abs(aa[ii] - aa[ii - 2]));

        cout << dp[nn];

    return 0;

}

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

#include<cstdio>

#include<algorithm>



int main(){

  int s;

  long long st[100001],p[100001];

  scanf("%d",&s);

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

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

  }

  p[0]=0;

  p[1]=0;

  p[2]=(st[2]-st[1] < 0) ? st[1]-st[2] : st[2]-st[1];

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

    p[i] = std::min(p[i-1] + ((st[i]-st[i-1] < 0) ? st[i-1]-st[i] : st[i]-st[i-1]) , p[i-2] + ((st[i]-st[i-2] < 0) ? st[i-2]-st[i] : st[i]-st[i-2]));

  }

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

  return 0;

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

using namespace std;

#define INF 1<<28

#define max 100005

 

 

typedef long long ll;

 

int n, a[100005];

int dp[max];

 

int main()

{

    cin>>n;

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

        cin>>a[i];

    dp[1] = 0;

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

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

        if(i > 2){

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

        }

    }

    cout << dp[n]<<endl;

    return 0;

}  

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

#include<cstdio>

#include<algorithm>



int main(){

  int s;

  long long st[100001],p[100001];

  scanf("%d",&s);

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

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

  }

  p[0]=0;

  p[1]=0;

  p[2]=(st[2]-st[1] < 0) ? st[1]-st[2] : st[2]-st[1];

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

    p[i] = std::min(p[i-1] + ((st[i]-st[i-1] < 0) ? st[i-1]-st[i] : st[i]-st[i-1]) , p[i-2] + ((st[i]-st[i-2] < 0) ? st[i-2]-st[i] : st[i]-st[i-2]));

  }

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

  return 0;

}