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

#define pii pair<int,int>

#define vi vector<int>

#define ppii pair<pii>



using namespace std;

const int maxn=1e5+5;



int n;

vi arr;

int dp[maxn];



int dfs(int pos)

{

    if(pos==n){return 0;}



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



    int ans=(1<<29);



    if(pos<n)

        ans=min(ans,dfs(pos+1) + abs(arr[pos]-arr[pos+1]));

    if(pos<n-1)

        ans=min(ans,dfs(pos+2) + abs(arr[pos]-arr[pos+2]));

    dp[pos]=ans;



    return ans;

}



int main()

{

    ios_base::sync_with_stdio(0);

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



    cin>>n;



    arr=vi(n+1);



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

        cin>>arr[i];



    memset(dp,-1,sizeof dp);



    cout<<dfs(1);



    return 0;

}


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

#include<stdio.h>

#include<stdlib.h>

#include<math.h>

#include<string>

#include<algorithm>

#include<map>

#include<vector>

#include<queue>

#include<stack>

#include<sstream>

#include<set>

#include<cctype>

#include<iomanip>

#include<cstring>

#include<limits>

using namespace std;

int dp[10010], w[10010];

bool choice[10010][110];

int cmp1(int a, int b){ return a > b;}

int main()

{//ios::sync_with_stdio(false);

/***

#ifdef ONLINE_JUDGE

#else

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

#endif

//ios::sync_with_stdio(false);

****/

int n;



cin>>n;

int a[n+1];

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

    cin>>a[i];

int dp[n+1];

dp[1]=0;

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

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



    return 0;



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

#include <queue>

typedef long long ll;



using namespace std;



const int N=1e5+5;





int main()

{

    ios_base::sync_with_stdio(false);

    cin.tie(NULL);

    cout.tie(NULL);

   int n,k=2;

   cin>>n;

   int arr[N]={},dp[N]={};

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

    cin>>arr[i];

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

   dp[0]=0;

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

   {



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

     {

         if(i-j>=0)

         {

             if(dp[i]==-1)

             {

                 dp[i]=dp[i-j]+abs(arr[i]-arr[i-j]);

             }

             else

             {

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





             }





         }



     }









   }

   cout<<dp[n-1];



   return 0;

}


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

#include<stdio.h>

#include<stdlib.h>

#include<math.h>

#include<string>

#include<algorithm>

#include<map>

#include<vector>

#include<queue>

#include<stack>

#include<sstream>

#include<set>

#include<cctype>

#include<iomanip>

#include<cstring>

#include<limits>

using namespace std;

int dp[10010], w[10010];

bool choice[10010][110];

int cmp1(int a, int b){ return a > b;}

int main()

{//ios::sync_with_stdio(false);

/***

#ifdef ONLINE_JUDGE

#else

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

#endif

//ios::sync_with_stdio(false);

****/

int n;



cin>>n;

int a[n+1];

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

    cin>>a[i];

int dp[n+1];

dp[1]=0;

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

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



    return 0;



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

using namespace std;



typedef long long ll;

#define mp make_pair

#define f first

#define s second

#define pb push_back



const int inf = 1e7;

const int N  = 1e5 + 5;



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

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



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



int solve(int idx) {



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



  int &ret = dp[idx];



  if(ret!=-1) return ret;



  ret = solve(idx+1) + abs(h[idx]-h[idx+1]);



  if(idx!=n-2)

    ret = min(ret,solve(idx+2) + abs(h[idx]-h[idx+2]));



  return ret;



}



int main() {



    ios_base::sync_with_stdio(false);

    cin.tie(0);



    cin >> n;



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



      cin >> h[i];



    }



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



    cout << solve(0) << endl;



    return 0;

}


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

#include<stdio.h>

#include<stdlib.h>

#include<math.h>

#include<string>

#include<algorithm>

#include<map>

#include<vector>

#include<queue>

#include<stack>

#include<sstream>

#include<set>

#include<cctype>

#include<iomanip>

#include<cstring>

#include<limits>

using namespace std;

int dp[10010], w[10010];

bool choice[10010][110];

int cmp1(int a, int b){ return a > b;}

int main()

{//ios::sync_with_stdio(false);

/***

#ifdef ONLINE_JUDGE

#else

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

#endif

//ios::sync_with_stdio(false);

****/

int n;



cin>>n;

int a[n+1];

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

    cin>>a[i];

int dp[n+1];

dp[1]=0;

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

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



    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: 1.4003693221057232x):
#include<iostream>

#include<stdio.h>

#include<stdlib.h>

#include<math.h>

#include<string>

#include<algorithm>

#include<map>

#include<vector>

#include<queue>

#include<stack>

#include<sstream>

#include<set>

#include<cctype>

#include<iomanip>

#include<cstring>

#include<limits>

using namespace std;

int dp[10010], w[10010];

bool choice[10010][110];

int cmp1(int a, int b){ return a > b;}

int main()

{//ios::sync_with_stdio(false);

/***

#ifdef ONLINE_JUDGE

#else

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

#endif

//ios::sync_with_stdio(false);

****/

int n;



cin>>n;

int a[n+1];

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

    cin>>a[i];

int dp[n+1];

dp[1]=0;

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

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



    return 0;



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

using namespace std;

int a,b,c,d,dp[100000],cost[100000],weight[100];



void func(int a)

{

    dp[1]=0;

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

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

    {

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

    }

}



int main()

{

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

    cin>>a;

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

    {

        cin>>cost[i];

    }

    func(a);

    cout<<dp[a]<<endl;

    //cout<<nCr(a,b)<<endl;



}


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

#include<stdio.h>

#include<stdlib.h>

#include<math.h>

#include<string>

#include<algorithm>

#include<map>

#include<vector>

#include<queue>

#include<stack>

#include<sstream>

#include<set>

#include<cctype>

#include<iomanip>

#include<cstring>

#include<limits>

using namespace std;

int dp[10010], w[10010];

bool choice[10010][110];

int cmp1(int a, int b){ return a > b;}

int main()

{//ios::sync_with_stdio(false);

/***

#ifdef ONLINE_JUDGE

#else

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

#endif

//ios::sync_with_stdio(false);

****/

int n;



cin>>n;

int a[n+1];

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

    cin>>a[i];

int dp[n+1];

dp[1]=0;

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

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



    return 0;



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

#define F first

#define S second

#define T second.first

#define C second.second

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

using namespace std;

typedef long long ll;

typedef pair<int, int> pii;

typedef pair<int,pair<int,int>> piii;



const int N= 1e5+5, L = 14, OO = 0x3f3f3f3f;

const ll M=10 ;

const double ESP = 1e-8;



int n;

int A[N], dp[N];

int main(){

    FIO

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

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

    cin>>n;

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

    memset(dp, OO, 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(A[i]-A[i+1]));

        }

        if(i+2<n){

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

        }

    }

    cout<<dp[n-1];



}


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

#include<stdio.h>

#include<stdlib.h>

#include<math.h>

#include<string>

#include<algorithm>

#include<map>

#include<vector>

#include<queue>

#include<stack>

#include<sstream>

#include<set>

#include<cctype>

#include<iomanip>

#include<cstring>

#include<limits>

using namespace std;

int dp[10010], w[10010];

bool choice[10010][110];

int cmp1(int a, int b){ return a > b;}

int main()

{//ios::sync_with_stdio(false);

/***

#ifdef ONLINE_JUDGE

#else

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

#endif

//ios::sync_with_stdio(false);

****/

int n;



cin>>n;

int a[n+1];

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

    cin>>a[i];

int dp[n+1];

dp[1]=0;

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

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



    return 0;



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



using namespace std;

typedef long long ll;

typedef double dd;

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

#define endl "\n"

#define clr(n, r) memset(n,r,sizeof(n));



void fast() {



    cin.tie(0);

    cin.sync_with_stdio(0);

}



const int N = 1e5 + 9;

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



int sol(int i){

    if(i<0) return 1e9;

    if(i==0) return 0;



    if(~dp[i]) return dp[i];



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

}





int main() {



    cin >> n;



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



    memset(dp, -1, sizeof dp);



    cout << sol(n - 1);

}

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

#include<stdio.h>

#include<stdlib.h>

#include<math.h>

#include<string>

#include<algorithm>

#include<map>

#include<vector>

#include<queue>

#include<stack>

#include<sstream>

#include<set>

#include<cctype>

#include<iomanip>

#include<cstring>

#include<limits>

using namespace std;

int dp[10010], w[10010];

bool choice[10010][110];

int cmp1(int a, int b){ return a > b;}

int main()

{//ios::sync_with_stdio(false);

/***

#ifdef ONLINE_JUDGE

#else

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

#endif

//ios::sync_with_stdio(false);

****/

int n;



cin>>n;

int a[n+1];

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

    cin>>a[i];

int dp[n+1];

dp[1]=0;

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

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



    return 0;



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

#include <ext/numeric>



using namespace std;

using namespace __gnu_cxx;



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

#define endl "\n"

#define pb push_back

#define F first

#define S second

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

#define isOdd(n)    (n&1)

#define LLMAX LLONG_MAX

#define LLMIN LLONG_MIN

#define IMN INT_MIN

#define IMX INT_MAX

#define pow(n, m) power((ll)n, (ll)m)

#define numOfDigits(n)  ((n)? (ll)(log10(n)+1) : 1)

#define mem(x, val)    memset(x, val, sizeof(x))



typedef long long ll;

typedef long double ld;

typedef double dd;

typedef string str;

typedef pair<int, int> pii;





vector<int> v;

int dp[(int)1e5];

int n;

int jump(int i){

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

    if(i>=n) return 1e9;



    int &ret = dp[i];



    if(~ret) return ret;



    int cnt = 0;

    if(i+1<n) cnt = abs(v[i] - v[i+1]) + jump(i+1);

    if(i+2<n) cnt = min(cnt, abs(v[i] - v[i+2]) + jump(i+2));



    return ret = cnt;

}

int main()

{

    THINK_TWICE_CODE_ONCE

    //freopen("test cases\\.txt", "r", stdin) ;

    cin>>n;

    v.resize(n);

    for(int &i: v) cin>>i;

    mem(dp, -1);

    cout<<jump(0);

    return 0;

}










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

#include<stdio.h>

#include<stdlib.h>

#include<math.h>

#include<string>

#include<algorithm>

#include<map>

#include<vector>

#include<queue>

#include<stack>

#include<sstream>

#include<set>

#include<cctype>

#include<iomanip>

#include<cstring>

#include<limits>

using namespace std;

int dp[10010], w[10010];

bool choice[10010][110];

int cmp1(int a, int b){ return a > b;}

int main()

{//ios::sync_with_stdio(false);

/***

#ifdef ONLINE_JUDGE

#else

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

#endif

//ios::sync_with_stdio(false);

****/

int n;



cin>>n;

int a[n+1];

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

    cin>>a[i];

int dp[n+1];

dp[1]=0;

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

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



    return 0;



}
// Slower C++ solution:
/*

				" اللهم صلي و سلم علي سيدنا محمد و علي اله وصحبه اجمعين "

*/





#define _CRT_SECURE_NO_WARNINGS

#include<bits/stdc++.h>

#define f for

#define ll long long

#define ull unsigned long long

#define endl "\n"

using namespace std;

#define BI  acos(-1)

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

void Open()

{

#ifndef ONLINE_JUDGE

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

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

#endif

}

ll gcd(ll a, ll b)

{

	return b == 0 ? a : gcd(b, a % b);

}

void madesetprobblem()

{

	//$ $

	//less than or equal => $ 1 \leq 100 $

	//  $(1 \le A,B \le 10^5 )$

	// a[i] => $a_i$

	// a[i][j] => $a_{i,j}$

	// double qoutes ''yext''

	/*

		image

		\begine{center}

		\includegraphics{image.jpg}

		\end{center}

	*/

	/*

		list

		\begin{itemize}

			\item first one

			\item second one

		\end{itemize}

	*/

}

int n;

vector<int>a(1e5 + 2),dp(1e5+2,-1);

int ans(int c = 0)

{

	if (c == n-1)

		return 0;

	int ans1 = INT_MAX, ans2 = INT_MAX;

	if (dp[c] != -1)

		ans1 = dp[c];

	else

	{

		if (c + 1 < n)

			ans1 = (abs(a[c] - a[c + 1]) + ans(c + 1));

		if (c + 2 < n)

			ans2 = (abs(a[c] - a[c + 2]) + ans(c + 2));

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

	}

	//cout <<c<<" "<< ans1 << " " << ans2 << endl;

	return min(ans1,ans2);

}

int main()

{

	// توكلت علي الله 

//Open();

	ios::sync_with_stdio(false);

	cin.tie(NULL);

	cout.tie(NULL);

	cin >> n;

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

	{

		cin >> a[i];

	}

	cout << ans();

}

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

#include<stdio.h>

#include<stdlib.h>

#include<math.h>

#include<string>

#include<algorithm>

#include<map>

#include<vector>

#include<queue>

#include<stack>

#include<sstream>

#include<set>

#include<cctype>

#include<iomanip>

#include<cstring>

#include<limits>

using namespace std;

int dp[10010], w[10010];

bool choice[10010][110];

int cmp1(int a, int b){ return a > b;}

int main()

{//ios::sync_with_stdio(false);

/***

#ifdef ONLINE_JUDGE

#else

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

#endif

//ios::sync_with_stdio(false);

****/

int n;



cin>>n;

int a[n+1];

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

    cin>>a[i];

int dp[n+1];

dp[1]=0;

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

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



    return 0;



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

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

//cout<<fixed<<setprecision(6)<<n<<endl;

// transform(s.begin(), s.end(), s.begin(), ::tolower);

//double PI=3.14159265359,c=0;

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

#define endl '\n'

#define ll long long

//#define f(n) for(int i=;i<n;i++)

double PI = acos(-1);

using namespace std;

void fast()

{

	std::ios_base::sync_with_stdio(0);

	cin.tie(0);

	cout.tie(0);

}

int arr[1000005], n;

vector<int>v(1e5+2, -1);

int minCost(int indx)

{

	int path1=INT_MAX, path2=INT_MAX;

	if (indx == n - 1)

		return 0;



	if (v[indx] != -1)

		return v[indx];



	if (indx + 1 < n)

		path1 = abs(arr[indx] - arr[indx + 1]) + minCost(indx + 1);



	if (indx + 2 < n)

		path2 = abs(arr[indx] - arr[indx + 2]) + minCost(indx + 2);



	return v[indx] = min(path1, path2);

}

int main()

{

	fast();

	cin >> n;

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

		cin >> arr[i];



	cout << minCost(0) << endl;



	return 0;

}

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

#include<stdio.h>

#include<stdlib.h>

#include<math.h>

#include<string>

#include<algorithm>

#include<map>

#include<vector>

#include<queue>

#include<stack>

#include<sstream>

#include<set>

#include<cctype>

#include<iomanip>

#include<cstring>

#include<limits>

using namespace std;

int dp[10010], w[10010];

bool choice[10010][110];

int cmp1(int a, int b){ return a > b;}

int main()

{//ios::sync_with_stdio(false);

/***

#ifdef ONLINE_JUDGE

#else

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

#endif

//ios::sync_with_stdio(false);

****/

int n;



cin>>n;

int a[n+1];

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

    cin>>a[i];

int dp[n+1];

dp[1]=0;

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

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



    return 0;



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

using namespace std;



const int N=1e5+30;

typedef long long ll;

int n,arr[N];

int dp[N];

ll solve(int i){

    if(i>=n)return 1e15;

    if(i==n-1){

        return 0;

    }



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



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

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

    return dp[i]= min(path1,path2);

}

int main()

{

    memset(dp,-1,sizeof dp);

    scanf("%d",&n);

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

    cout<<solve(0)<<endl;

}




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

#include<stdio.h>

#include<stdlib.h>

#include<math.h>

#include<string>

#include<algorithm>

#include<map>

#include<vector>

#include<queue>

#include<stack>

#include<sstream>

#include<set>

#include<cctype>

#include<iomanip>

#include<cstring>

#include<limits>

using namespace std;

int dp[10010], w[10010];

bool choice[10010][110];

int cmp1(int a, int b){ return a > b;}

int main()

{//ios::sync_with_stdio(false);

/***

#ifdef ONLINE_JUDGE

#else

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

#endif

//ios::sync_with_stdio(false);

****/

int n;



cin>>n;

int a[n+1];

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

    cin>>a[i];

int dp[n+1];

dp[1]=0;

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

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



    return 0;



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

using namespace std;

#define    sz    100110

#define    ll    long long int

ll n,c=0,p,q;

ll num[sz];

ll vis[sz];

ll dp[sz];



ll tani(int pos)

{



  if(pos>=n)return 0;

  if(vis[pos]==1)return dp[pos];

  vis[pos]=1;



  return  dp[pos]=min(abs(num[pos]-num[pos+1])+tani(pos+1),abs(num[pos]-num[pos+2])+tani(pos+2));



}



int main()

{

    ll t,i;



    for(i=1;i<sz;i++)num[i]=1000000;



    cin>>n;

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

    {

        cin>>num[i];

    }

    t=tani(1);

    cout<<t<<endl;

    return 0;

}


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



using namespace std;



#define F first

#define S second



int N, K;

int H[100005];

int dp[100001];



int main() {

	cin >> N; 

	H[0] = INT32_MAX; // to avoid RTE

	for (int i = 1; i <= N; i++) cin >> H[i];

	for (int i = 0; i <= N; i++) dp[i] = INT32_MAX;

	int ans = 0;

	

	dp[N] = 0;

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

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

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

		}

	}



	cout << dp[1] << endl;



	return 0;

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

using namespace std;



#define fr(i,n) _back

#define pb	push_back

#define eb	emplace_back

#define mk	make_pair

#define fi	first

#define se	second

#define endl	'\n'



typedef long long ll;

typedef pair<int,int> ii;

typedef vector<ii> vii;

const int INF = 0x3f3f3f3f;

const double PI = acos(-1.0);

const int N = 1e5 + 3;

int h[N];

int dp[N];



int main() {

    ios_base::sync_with_stdio(false);

    memset(dp, INF, sizeof dp);

    int n; cin >> n;

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



    dp[0] = 0;

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

        for(int j = max(0,i-2); j < i; j++)

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



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

    return 0;

}


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



using namespace std;



#define F first

#define S second



int N, K;

int H[100005];

int dp[100001];



int main() {

	cin >> N; 

	H[0] = INT32_MAX; // to avoid RTE

	for (int i = 1; i <= N; i++) cin >> H[i];

	for (int i = 0; i <= N; i++) dp[i] = INT32_MAX;

	int ans = 0;

	

	dp[N] = 0;

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

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

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

		}

	}



	cout << dp[1] << endl;



	return 0;

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

using namespace std;



int N, a[100100], dp[100100];



int f(int n) {

	if (n==1) return 0;

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

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

	dp[n] = min(

				f(n-1) + abs(a[n] - a[n-1]),

				f(n-2) + abs(a[n] - a[n-2])

				);

	return dp[n];

}



int main() {

	cin >> N;

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

		cin >> a[i];

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

	cout << f(N) << endl;

	return 0;

}

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



using namespace std;



#define F first

#define S second



int N, K;

int H[100005];

int dp[100001];



int main() {

	cin >> N; 

	H[0] = INT32_MAX; // to avoid RTE

	for (int i = 1; i <= N; i++) cin >> H[i];

	for (int i = 0; i <= N; i++) dp[i] = INT32_MAX;

	int ans = 0;

	

	dp[N] = 0;

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

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

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

		}

	}



	cout << dp[1] << endl;



	return 0;

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

using namespace std;

typedef long long LL;



int arr[100007];

int dp[100007];



int Solve(int idx, int n){

//	cout<<cost<<" "<<idx<<endl;

	if(idx >= n)return 1e9;

	if(idx == n - 1){

		return 0;	

	}

	

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

	

	

	return dp[idx] = min(abs(arr[idx] - arr[idx+1]) + Solve(idx+1, n), abs(arr[idx] - arr[idx+2]) + Solve(idx+2,n));

}



int main(){

	int n; cin>>n;

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

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

		

	cout<<Solve(0,n)<<endl;

	return 0;

}

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



using namespace std;



#define F first

#define S second



int N, K;

int H[100005];

int dp[100001];



int main() {

	cin >> N; 

	H[0] = INT32_MAX; // to avoid RTE

	for (int i = 1; i <= N; i++) cin >> H[i];

	for (int i = 0; i <= N; i++) dp[i] = INT32_MAX;

	int ans = 0;

	

	dp[N] = 0;

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

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

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

		}

	}



	cout << dp[1] << endl;



	return 0;

}