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

using namespace std;

#define ll long long

ll dp[100009];

ll n,x;

vector<ll>v;

ll frog(ll pos)

{

    if(pos<=0)

        return 0;

    if(pos==1)

        return abs(v[0]-v[1]);

        if(dp[pos]==-1)

        {

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

        }

    return dp[pos];

}



int main()

{

    cin>>n;

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

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

    {

        cin>>x;

        v.push_back(x);

    }

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

}


// Faster C++ solution for the same problem (measured speedup: 7.864336133790695x):
#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<cmath>

#include<algorithm>

using namespace std;



int dp[100004]={0};

int h[100005]={0};

int main(){

	int n;

	cin>>n;

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

		cin>>h[i];

	}

	

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

		int i1=i-1>0 ? i-1: 1,i2=i-2>0? i-2:1;

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

//		cout<<dp[i1]+abs(h[i]-h[i1])<<" "<<dp[i2]+abs(h[i]-h[i2])<<endl;

	}

//	for(int i=1;i<=n;i++) cout<<dp[i]<<" ";

	cout<<dp[n];

//	cout<<min(20 ,20);

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 4.34883995290412x):
#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:
#define _CRT_SECURE_NO_vARNINGS

#include <vector>

#include <iostream>

#include <cstdio>

#include <map>

#include <algorithm>

#include <queue>

#include <string>

#include <climits>

#include <list>

#include <cmath>

using namespace std;



int main() {

	int n;

	cin >> n;

	vector<int> v(n, 0);

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

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

	vector<int> dp(n, 0);

	dp[0] = 0;

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

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

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

	}

	cout << dp[n - 1];

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 4.356500410466692x):
#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 <cstdio>

#include <algorithm>

#include <vector>

#include <unordered_map>

#include <string>

#include <cstring>

#include <cctype>

#include <climits>

#include <cmath>

#include <set>

#include <map>

#include <unordered_set>

#include <sstream>

#include <queue>

#include <stack>

using namespace std;

vector<int> high;

int n;



int main(){

	scanf("%d",&n);

	high.resize(n+1);

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

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

	}

	vector<int> dp(n+1);

	dp[1]=0;

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

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

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

	}

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

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 4.34450838062147x):
#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 v[1000010];

int memo[1000010];

int c;



int f(int i)

{



    if(memo[i]!=-1)

        return memo[i];



    if(i == 0)

        return memo[0] = 0;



    if(i == 1)

        return memo[1] = abs(v[0] - v[1]);



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

}



int main()

{



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

    cin>>c;



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

    {

        cin>>v[i];

    }



    cout<<f(c-1)<<endl;



    return 0;

}

// Faster C++ solution for the same problem (measured speedup: 22.16622234299089x):
#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 N = 1e5 + 100;

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



int main() {

	ios_base::sync_with_stdio(0);

	cin.tie(0);



	cin >> n;



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

		cin >> h[i];

	}



	mem[n - 2] = abs(h[n - 1] - h[n - 2]);



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

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

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

		mem[i] = min(a1, a2);

	}



	cout << mem[0] << '\n';

	

	return 0;

}


// Faster C++ solution for the same problem (measured speedup: 4.410590399849655x):
#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 long long mk=100005;

long long arr[mk];

long long n, dp[mk];

int main(){

	ios_base::sync_with_stdio(0);

	cin.tie();

	cout.tie();

	cin >> n;

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

		cin >> arr[i];

	}

	dp[0]=0;

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

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

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

	}

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

}

// Faster C++ solution for the same problem (measured speedup: 4.406438861231089x):
#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[100001];

int dp[100001];

int n;

int solve(int stone)

{

    if(stone+1==n) return dp[stone]=abs(h[stone]-h[stone+1]);

    if(stone+2==n) return dp[stone+2]=abs(h[stone]-h[stone+2]);

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

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

}



int main()

{

    int i;

    scanf("%d",&n);



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

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



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

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





    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 6.045901014199002x):
#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 mx = 1e5+10;

int dp[mx];

int main()

{

    int n;

    cin>>n;

    int arr[n+1];

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

        cin>>arr[i];

    dp[0]=0;

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

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

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

}

// Faster C++ solution for the same problem (measured speedup: 4.3546212601024985x):
#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 n, h[100002], dp[100002];



int sol(int i){

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

    if(i>=n) return 1E9;



    int &ret = dp[i];

    if(~ret) return ret;



    return ret = min(abs(h[i+1]-h[i]) + sol(i+1),

                     abs(h[i+2]-h[i]) + sol(i+2));

}



int main()

{

    cin >> n;

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

        cin >> h[i];



    memset(dp, -1, sizeof dp);

    cout << sol(0);

}


// Faster C++ solution for the same problem (measured speedup: 6.091578481040754x):
#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;

#define maxn 100005

int h[maxn];

int dp[maxn];

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

    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 4.354418925524413x):
#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<cstdio>

#include<cstring>

#include<cstdlib>

#include<algorithm>

#include<string>

#define ll long long int

using namespace std;

const int maxn=1000010;



int high[maxn];

int dp[maxn];



int main( )

{

    int i,n;;

    cin>>n;

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

    {

        cin>>high[i];

    }

    dp[1]=0;

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

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

    {

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

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

    }

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

	 return 0;

}


// Faster C++ solution for the same problem (measured speedup: 4.35533465534306x):
#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 trace(...) __f(#__VA_ARGS__, __VA_ARGS__)

template <typename Arg1>

void __f(const char* name, Arg1&& arg1) {

  cerr << name << " : " << arg1 << "\n";

}

template <typename Arg1, typename... Args>

void __f(const char* na, Arg1&& arg1, Args&&... args) {

  const char* c = strchr(na + 1, ',');

  cerr.write(na, c - na) << " : " << arg1 << " , ";

  __f(c + 1, args...);

}

#define endl "\n"

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

#define UNIQUE(v) sort(all(v)),v.erase(unique(all(v)),v.end())

typedef long long LL;

typedef pair <int,int> pii;

const double pi = acos(-1.0);

const double eps = 1e-8;

const int mod = 1e9 + 7;

const int inf = 1e9;

const LL INF = 1e18;

const int N = 1e5 + 5;



int main() {

  ios_base::sync_with_stdio(false);

  cin.tie(0); cout.tie(0);

  #ifdef LOCAL

    freopen("input.txt", "r", stdin);

  #endif // LOCAL

  int n;

  cin >> n;

  vector <LL> h (n + 1);

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

  vector <LL> dp (n + 1, INF);

  dp[1] = 0;

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

    if (i == 2) 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] << endl;

  return 0;

}


// Faster C++ solution for the same problem (measured speedup: 4.464254788106274x):
#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>

#include <algorithm>

#include <iostream>

#include <iomanip>

#include <cstdio>

#include <cstdlib>

#include <cmath>

#include <cstring>

#include <vector>

#include <string>

#include <climits>

#include <map>

#include <set>

#include <stack>

#include <queue>

#include <deque>

#include <stdio.h>

//#define int long long

using namespace std;

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

#define endl '\n'

#define OnlineJudgec

#define F first

#define S second

#define  precision(n)  cout << fixed << setprecision(n)

#define clr(v,d ) memset(v, d, sizeof(v))

typedef long long ll;

typedef vector<int> vi;

void init()

{

    cin.tie(0);

    cin.sync_with_stdio(0);

    cout.tie(0);

    #ifdef OnlineJudge

    freopen("input.txt","r",stdin);

    freopen("output.txt","w",stdout);

    #endif

}

ll S(ll x){ll s = 0;while(x){s += x % 10;x /= 10;}return s;} /// sum of digits.

ll powe(ll a , ll n){if(n == 1)return a;return a * powe(a ,n-1);}

ll com(int n,int m){ll z = 1;for(int i = 0; i < m;i++){z = z * ( n - i) / (i + 1) ;}return z;}

int dx[] = {1,-1,0,0};

int dy[] = {0,0,1,-1};

int dr[] = {0,0,0,1,1,1,-1,-1,-1};

int dc[] ={-1,0,1,-1,0,1,-1,0,1};

/// <<------------------------------------------------------------------------------>>

const int mx = 100009;

int n;

int arr[mx];

int dp[mx];

int solve(int idx)

{

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

    int &rst = dp[idx];

    if(~rst) return rst;

    int choice = 1e9 , choice2 = 1e9;

    if(idx + 1 < n)

        choice = solve(idx+1) + abs(arr[idx] - arr[idx + 1]);

    if(idx + 2 < n)

       choice2 = solve(idx+2) + abs(arr[idx] - arr[idx + 2]);

    return rst = min(choice , choice2);

}

/// <<------------------------------------------------------------------------------>>

int main()

{

    init();

    cin >> n;

    loop(n) cin >> arr[i];

    clr(dp,-1);

    cout<<solve(0);

}


// Faster C++ solution for the same problem (measured speedup: 6.152842707219104x):
#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 MAXN 100003



int abs(int z)

{

    if (z<0)

        return -z;

    else

        return z;

}



int main(void)

{

    int N,i,j;

    int h[MAXN], p[MAXN];

    scanf("%d",&N);

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

    {

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

    }

    p[N-1]=0;

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

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

    {

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

    }

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



    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 4.365812492908842x):
#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>

#include <vector>

#include <string>

#include <cmath>

#include <set>

#include <stdio.h>

#include <algorithm>

#include <map>

#include <queue>

#include <unordered_map>

#define ll long long

#define pii pair <int, int>

#define pll pair <long long, long long>

#define plxy pair <long long, pll>

#define INT_MAX 1e18

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

using namespace std;

using namespace std;

const int mod=1e9+7;

const int N=1e5+5;

ll dp[N];

int main()

{

    ll n,arr[N];

    cin>>n;

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

        cin>>arr[i];

    dp[0]=0;

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

    for(ll i=2;i<n;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-1];

    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 4.41239903205609x):
#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 main()

{

    int n;

    cin>>n;

    int arr[n];

    long long dp[n];

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

   {

        cin>>arr[i];

   }

   dp[0]=0;

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

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

   {

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

   }

   cout<<dp[n-1];

   return 0;

}


// Faster C++ solution for the same problem (measured speedup: 4.346633812170774x):
#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;

#define fast ios_base::sync_with_stdio(false),cin.tie(NULL)

#define x first

#define y second





int main() {

    fast;

    int n;

    cin>>n;

    vector<int> arr(n);

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

        cin>>arr[i];

    }

    vector<int> dp(n);

    dp[0] = 0;

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

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

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

    }

    cout<<dp[n-1];

}

// Faster C++ solution for the same problem (measured speedup: 4.416876203800355x):
#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:
#pragma GCC optimize("O3")



#include <bits/stdc++.h>



typedef long long ll;

typedef unsigned long long ull;

typedef long double ld;

#define F first

#define S second

#define pii pair<int,int>

#define pll pair<ll, ll>

#define vi vector<int>

#define vll vector<ll>

#define vii vector<pii>

#define read(FILE)  freopen(FILE, "r", stdin);

#define out(FILE) freopen(FILE, "w", stdout);

#define clr(x, y) memset(x,y,sizeof(x));

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

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

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

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

#define endl '\n'

#define pb push_back

#define re return

const int N = 1e5 + 5;

const ll OO = 2e8;

using namespace std;



int n, cost[N], dp[N],res=0;



bool valid(int i) {

    re i < n;

}



int main() {

    //IO;

    cin >> n;

    rep(i, 0, n) cin >> cost[i];

    //memset(dp,OO, sizeof(dp));

    dp[0] = 0;

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

    rep(i,2,n){

        int next=OO,nextawy=OO;

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

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

        dp[i]=min(next,nextawy);

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

    }

    //n--;

    cout<<dp[n-1];

    //cout<<endl;





}

// Faster C++ solution for the same problem (measured speedup: 4.348922545848474x):
#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;

}