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



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

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

#define fore(i, l, r) for (int i = int(l); i <= int(r); ++i)

#define ford(i, n) for (int i = int(n)-1; i >= 0; --i)

#define pb push_back

#define eb emplace_back

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

#define F first

#define S second

#define endl '\n'

#define de(x) cout<<#x<<" = "<<(x)<<endl

#define de2(x,y) cout<<#x<<" = "<<(x) <<' '<< #y<<" = "<<y<<endl;



using namespace std;



typedef long long ll;

typedef pair<int, int> pii;

const int INF = 0x3f3f3f3f;

mt19937 gen(chrono::high_resolution_clock::now().time_since_epoch().count());



const int N=1e5+5;

int dp[N];

int main() {

    ios::sync_with_stdio(false);

    cin.tie(nullptr);

	int n;

	cin>>n;

	vector<int> a(n);

	for(auto& it:a) cin>>it;

	ms(dp,INF);

	dp[0]=0;

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

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

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

	}

	cout<<dp[n-1];

    return 0;

}




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

#include <cstdlib>

#include <algorithm>



using namespace std;



int main() {

    int n;

    scanf("%d", &n);



    int height[100005];

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

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

    }



    int dp[100005];

    dp[0] = 0;

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



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

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

    }

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

    return EXIT_SUCCESS;

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

#define ll long long

#define MAXN 100010

#define INF 1000000010



using namespace std;



ll n, dp[MAXN], h[MAXN];



void init(){

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

    dp[1]=0;

    h[0]=INF;

}



int main(){



    ios_base::sync_with_stdio(0);

    cin.tie(0);

    cout.tie(0);



    cin>>n;



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



    init();



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

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

    }



    cout<<dp[n];



return 0;

}


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

#include <cstdlib>

#include <algorithm>



using namespace std;



int main() {

    int n;

    scanf("%d", &n);



    int height[100005];

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

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

    }



    int dp[100005];

    dp[0] = 0;

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



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

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

    }

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

    return EXIT_SUCCESS;

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

using namespace std;



int a[1000001];

int dp[1000001];

int it;



int fr(int p){

	if (p==it-1){

      return 0;

    }

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

      return dp[p];

    }

	int re=abs(a[p]-a[p+1])+fr(p+1);

	if(p!=it-2){

      re=min(re,abs(a[p]-a[p+2])+fr(p+2));

    }

	return dp[p]=re;

}

int main(){

	cin>>it;

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

    cin>>a[i];

    }



	memset(dp,-1,sizeof dp);

	cout<<fr(0)<<endl;

	return 0;

}


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

#include <cstdlib>

#include <algorithm>



using namespace std;



int main() {

    int n;

    scanf("%d", &n);



    int height[100005];

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

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

    }



    int dp[100005];

    dp[0] = 0;

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



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

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

    }

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

    return EXIT_SUCCESS;

}
// Slower C++ solution:


#include <iostream>

#include <bits/stdc++.h>





using namespace std;





int a[100005], p[100005],n, i;

int respuesta(int x)

{

    if(x==n) return 0;

    if(x>n) return 1e9;

    if(p[x]!=-1)return p[x];

    return p[x]=min(abs(a[x+1]-a[x])+respuesta(x+1), abs(a[x+2]-a[x])+respuesta(x+2));

}





int main()

{

    memset(p,-1,sizeof p);

    cin>>n;

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

    {

        cin>>a[i];

    }

    cout<<respuesta(1)<<endl;

    return 0;

}


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

#include <cstdlib>

#include <algorithm>



using namespace std;



int main() {

    int n;

    scanf("%d", &n);



    int height[100005];

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

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

    }



    int dp[100005];

    dp[0] = 0;

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



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

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

    }

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

    return EXIT_SUCCESS;

}
// 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.548347012032465x):
#include <cstdio>

#include <cstdlib>

#include <algorithm>



using namespace std;



int main() {

    int n;

    scanf("%d", &n);



    int height[100005];

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

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

    }



    int dp[100005];

    dp[0] = 0;

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



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

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

    }

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

    return EXIT_SUCCESS;

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

using namespace std;

#define endl '\n'



const int N = 1e5;



int dp[N+5];

int arr[N+5];



int main(){



	ios_base::sync_with_stdio(0);

	int n; cin >>n;

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

	

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

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

	return 0;

}

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

#include <cstdlib>

#include <algorithm>



using namespace std;



int main() {

    int n;

    scanf("%d", &n);



    int height[100005];

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

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

    }



    int dp[100005];

    dp[0] = 0;

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



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

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

    }

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

    return EXIT_SUCCESS;

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

    #define maxn 100000

    #define INF 1LL<<60

    using namespace std;

    long long h[maxn+3], dp[maxn+3];

    int n;



    long long solve(int cur){

        if(cur >= n) return INF;

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

        if(dp[cur]!= INF) return dp[cur];

        //long long res1 = INF, res2 = INF;

        long long res1 = solve(cur+1) + llabs(h[cur+1]-h[cur]);

        long long res2 = solve(cur+2) + llabs(h[cur+2]-h[cur]);

        return dp[cur] = min(res1, res2); 

    }



    int main() {

    	// your code goes here

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

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

            

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

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

                dp[i] = INF;

            }



            long long ans = solve(0);

            printf("%lld\n", ans);

        }

    }

     

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

#include <cstdlib>

#include <algorithm>



using namespace std;



int main() {

    int n;

    scanf("%d", &n);



    int height[100005];

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

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

    }



    int dp[100005];

    dp[0] = 0;

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



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

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

    }

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

    return EXIT_SUCCESS;

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

     

    using namespace std;

     

    void __print(int x) {

        cerr << x;

    }

    void __print(long x) {

       cerr << x;

    }

    void __print(long long x) {

       cerr << x;

    }

    void __print(unsigned x) {

        cerr << x;

    }

    void __print(unsigned long x) {

        cerr << x;

    }

    void __print(unsigned long long x) {

        cerr << x;

    }

    void __print(float x) {

        cerr << x;

    }

    void __print(double x) {

        cerr << x;

    }

    void __print(long double x) {

        cerr << x;

    }

    void __print(char x) {

        cerr << '\'' << x << '\'';

    }

    void __print(const char *x) {

        cerr << '\"' << x << '\"';

    }

    void __print(const string &x) {

        cerr << '\"' << x << '\"';

    }

    void __print(bool x) {

        cerr << (x ? "true" : "false");

    }

     

    template<typename T, typename V>

    void __print(const pair<T, V> &x) {

        cerr << '{'; 

        __print(x.first); cerr << ','; 

       __print(x.second); cerr << '}';

    }

    template<typename T>

    void __print(const T &x) {

        int f = 0; cerr << '{'; 

        for (auto &i: x) 

            cerr << (f++ ? "," : ""), __print(i); 

        cerr << "}";

    }

    void _print() {

        cerr << "]\n";

    }

    template <typename T, typename... V>

    void _print(T t, V... v) {

        __print(t); 

        if (sizeof...(v)) 

            cerr << ", "; _print(v...);

    }

     

    #ifndef ONLINE_JUDGE

    #define debug(x...) cerr << "[" << #x << "] = ["; _print(x)

    #else

    #define debug(x...)

    #endif

     

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

    #define forw(i, w) for(int i = n; i >= 0; i--)

    #define dforn(i, a, b) for(int i = a; i < b; i++)

    #define dforw(i, b, a) for(int i = b; i >= a; i--)

    #define read(v) for(auto &i:v) cin >> i;

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

     

    typedef long long ll;

    typedef vector<int> vi;

    typedef vector<double> vd;

    typedef pair<int, int> pii;

     

    int n, k;

    vi arr, dp;

     

    int main(){

    	ios_base::sync_with_stdio(0);

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

    	

    	cin >> n;

    	k=2;

    	arr.assign(n, 0);

    	dp.assign(n, 999999999);

    	dp[0] = 0;

    	read(arr);

     

    	forn(i, n)

    		for(int j = i+1; j < n && j < i+k+1; j++)

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

     

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

    	return 0;

    }

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

#include <cstdlib>

#include <algorithm>



using namespace std;



int main() {

    int n;

    scanf("%d", &n);



    int height[100005];

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

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

    }



    int dp[100005];

    dp[0] = 0;

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



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

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

    }

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

    return EXIT_SUCCESS;

}
// 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.548347012032465x):
#include <cstdio>

#include <cstdlib>

#include <algorithm>



using namespace std;



int main() {

    int n;

    scanf("%d", &n);



    int height[100005];

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

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

    }



    int dp[100005];

    dp[0] = 0;

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



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

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

    }

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

    return EXIT_SUCCESS;

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

#include <fstream>

#define inf INFINITY

#define file freopen( "input.txt" , "r" , stdin) ; freopen( "output.txt" , "w" , stdout) ; 

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

#define _3102_ main()

#define endl '\n'

typedef long long ll ;

typedef unsigned long long ull ; 

typedef long double ld ; 

using namespace std ;

const int N = 1e5+100  ; 

const ll mod = 1e9 + 7  ;







int _3102_ {

    Gamed

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

    cin >> n ; 

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

        cin >> arr[i] ; 

    }

    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] , dp[i-2] + abs(arr[i]-arr[i-2])) ; 

    }

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

    return 0;

}

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

#include <cstdlib>

#include <algorithm>



using namespace std;



int main() {

    int n;

    scanf("%d", &n);



    int height[100005];

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

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

    }



    int dp[100005];

    dp[0] = 0;

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



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

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

    }

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

    return EXIT_SUCCESS;

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



using namespace std;

int dp[100001];

int main() {



       int x,ans=0;

       cin>>x;

       int h[x];

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

        cin>>h[i];

       dp[1]=0;

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

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

       {

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



       }

       cout<<dp[x]<<endl;





}


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

#include <cstdlib>

#include <algorithm>



using namespace std;



int main() {

    int n;

    scanf("%d", &n);



    int height[100005];

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

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

    }



    int dp[100005];

    dp[0] = 0;

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



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

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

    }

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

    return EXIT_SUCCESS;

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

using namespace std;



int dp[100005];



int main(){

    int n;

    cin>>n;



    int arr[n];



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

        cin>>arr[i];





    dp[0]=0;

    if(n==1)

        cout<<0<<endl;



    else{

        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;

    return 0;







}


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

#include <cstdlib>

#include <algorithm>



using namespace std;



int main() {

    int n;

    scanf("%d", &n);



    int height[100005];

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

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

    }



    int dp[100005];

    dp[0] = 0;

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



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

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

    }

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

    return EXIT_SUCCESS;

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

using namespace std;

typedef long long ll;

ll dp[100009];

int arr[100009];

ll sum = 0;

long long Frog1(int n){

 

    if(n==0) return 0;

    else if(n==1) return abs(arr[n] - arr[n-1]);

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

    else {

            ll x = Frog1(n-1);

            ll y = Frog1(n-2);

        dp[n] = min(abs (arr[n-1] - arr[n]) + x,abs(arr[n-2] - arr[n]) + y);

        //cout << n << " = " << dp[n] << endl;

         return dp[n];

    }

}

 

 

int main()

{

    int n;

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

    cin >> n;

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

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

}

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

#include <cstdlib>

#include <algorithm>



using namespace std;



int main() {

    int n;

    scanf("%d", &n);



    int height[100005];

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

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

    }



    int dp[100005];

    dp[0] = 0;

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



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

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

    }

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

    return EXIT_SUCCESS;

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

using namespace std;



int main()

{

  int n;

  cin>>n;

  int arr[n],dp[n];

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

  {

      cin>>arr[i];

  }

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

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

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

  {

    int x=abs(arr[i]-arr[i-1]);

    int y=abs(arr[i]-arr[i-2]);

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

  }

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

  return 0;

}


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

#include <cstdlib>

#include <algorithm>



using namespace std;



int main() {

    int n;

    scanf("%d", &n);



    int height[100005];

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

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

    }



    int dp[100005];

    dp[0] = 0;

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



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

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

    }

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

    return EXIT_SUCCESS;

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

using namespace std;

#define ll long long

#define ld long double

#define sf scanf

#define pf printf

#define pb push_back

#define llu unsigned long long

#define U unsigned int

#define SIZE 1000002

#define pie 3.14159265358979323

#define minuss 1e-6

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

 

#define BIG 100000000

 

ll  lcm(ll a,ll b)

{

    ll GCD=__gcd(a,b);

    ll lcm=(a*b)/GCD;

    return lcm;

}

ll dp[100005];

ll weight[1000005],value[1000005];

ll total,val;

ll call(ll n)

{

    if(n>=total)

        return 0;

 

    if(dp[n]!=-1)

        return dp[n];

 

    ll res1=BIG,res2=BIG;

 

   // if(weight[n]+c<=val)

    res1=abs(weight[n]-weight[n+1]) + call(n+1);

    if(n+2<=total) res2=abs(weight[n]-weight[n+2]) + call(n+2);

    //cout<<n<<" "<<res1<<" "<<res2<<endl;

    dp[n]=min(res1,res2);

    return dp[n];

 

}

int main()

{

    cin>>total;

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

        cin>>weight[i];

 

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

    ll ret=call(1);

    cout<<ret<<endl;

    return 0;

}

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

#include <cstdlib>

#include <algorithm>



using namespace std;



int main() {

    int n;

    scanf("%d", &n);



    int height[100005];

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

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

    }



    int dp[100005];

    dp[0] = 0;

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



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

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

    }

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

    return EXIT_SUCCESS;

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



using namespace std;

const int N=100000;

int main(){

	int i,j,n,dp[N],a[N];

	cin>>n;

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

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

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

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

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

	}

	cout<<dp[n-1];

}

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

#include <cstdlib>

#include <algorithm>



using namespace std;



int main() {

    int n;

    scanf("%d", &n);



    int height[100005];

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

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

    }



    int dp[100005];

    dp[0] = 0;

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



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

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

    }

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

    return EXIT_SUCCESS;

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

using namespace std;



int num[100001], memo[100001];



int dp(int n){

    if(n==0) return 0;

    if(n==1) return abs(num[0]-num[1]);

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

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

}



int main(){

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

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

    ios_base::sync_with_stdio(0);

    cin.tie(0);

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

    int n;

    cin>>n;

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

    cout<<dp(n-1)<<"\n";

    return 0;

}


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

#include <cstdlib>

#include <algorithm>



using namespace std;



int main() {

    int n;

    scanf("%d", &n);



    int height[100005];

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

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

    }



    int dp[100005];

    dp[0] = 0;

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



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

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

    }

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

    return EXIT_SUCCESS;

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

using namespace std;

typedef long long ll;

const int maxn=1e5+10;

ll dp[maxn];

ll a[maxn];

int main()

{

	int n;

	scanf("%d",&n);

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

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

	dp[1]=0;

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

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

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

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

	return 0;

}

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

#include <cstdlib>

#include <algorithm>



using namespace std;



int main() {

    int n;

    scanf("%d", &n);



    int height[100005];

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

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

    }



    int dp[100005];

    dp[0] = 0;

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



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

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

    }

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

    return EXIT_SUCCESS;

}