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

#define ll long long

#define endl "\n"

#define shalaby ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);cerr.tie(0);

#define mod 100000000

using namespace std;



inline int D()

{

    int t;

    scanf("%d",&t);

    return t;

}

inline ll llD()

{

    ll t;

    scanf("%lld",&t);

    return t;

}

 ll Max=1e18+8;

const int OO=-1e6;

int xt[4]= {1,0,0,-1};

int yt[4]= {0,1,-1,0};

////////////////////////////////////////////////////////////////////////////////////



ll mem[100005],a[100005],n,m,k;

bool valid(int x,int y)

{

    return x>-1 && y>-1 && x<n && y<m;

}

void init()

{

    memset(mem,-1,sizeof mem);

}

/////////////////////////////////////////////////////////////////////

ll solve(int i=0)

{

    if(i>=n)

        return Max;

        if(i==n-1)

            return 0;



    ll &ret=mem[i];

    if(~ret)return ret;

    ret=Max;

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

    ret=min((solve(i+j)+abs(a[i]-a[i+j])),ret);



    return ret;

}

/**5 3

10 30 40 50 20





3 1

10 20 10

*/

int main()

{

    init();

    int T=1;

///   T=D();

    while(T-->0)

    {

        cin >> n >>k;

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

        {

            cin >> a[i];

        }

        cout << solve();

    }

}


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

#include <cstdio>

#include <cstring>

#include <algorithm>

#include <cmath>

#include <queue>

#include <stack>

#include <map>

#include <set>

#include <vector>

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

#define repd(i,x,n) for(int i=x;i<=n;i++)

#define pii pair<int,int>

#define pll pair<long long ,long long>

#define gbtb ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)

#define MS0(X) memset((X), 0, sizeof((X)))

#define MSC0(X) memset((X), '\0', sizeof((X)))

#define pb push_back

#define mp make_pair

#define fi first

#define se second

#define gg(x) getInt(&x)

using namespace std;

typedef long long ll;

inline void getInt(int* p);

const int maxn=1000010;

const int inf=0x3f3f3f3f;

/*** TEMPLATE CODE * * STARTS HERE ***/

ll n;

ll dp[maxn];

ll a[maxn];

ll k;

int main()

{

    gbtb;

    cin>>n>>k;

    repd(i,1,n)

    {

        cin>>a[i];

    }

    dp[1]=0;

    dp[0]=0;

    repd(i,2,n)

    {

        dp[i]=inf;

    }

    repd(i,2,n)

    {

        for(int j=i-1;j>=max(1ll,i-k);j--)

        {

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

        }

    }

    cout<<dp[n];

    return 0;

}



inline void getInt(int* p) {

    char ch;

    do {

        ch = getchar();

    } while (ch == ' ' || ch == '\n');

    if (ch == '-') {

        *p = -(getchar() - '0');

        while ((ch = getchar()) >= '0' && ch <= '9') {

            *p = *p * 10 - ch + '0';

        }

    }

    else {

        *p = ch - '0';

        while ((ch = getchar()) >= '0' && ch <= '9') {

            *p = *p * 10 + ch - '0';

        }

    }

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

using namespace std;

typedef long long ll;

ll a[100005],dp[100005];

ll n,k;

ll ans=0;

ll recur(ll i)

{

	if(dp[i]!=-1)

	{	

		return dp[i];

	}	

	if(i==n-1)

	{

		return 0;

	}

	ll q,mini=LONG_LONG_MAX;

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

	{

		q=abs(a[i]-a[i+j])+recur(i+j);

		mini=min(q,mini);

	}

	

	dp[i]=mini;

	return(mini);

}

int main()

{

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

dp[i]=-1;

cin>>n>>k;	

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

cin>>a[i];

cout<<recur(0);

return 0;

}

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

using namespace std;

typedef long long ll;

#define endl '\n'

#define fastio ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)

#define pb push_back

#define mp make_pair

int main()

{

	ll n,k;

	fastio;	

	cin>>n>>k;

	ll a[n];

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

	{

		cin>>a[i];

	}

	ll dp[n]={0};

	for(ll i=n-2;i>=0;i--)

	{

		ll mini=LONG_LONG_MAX;

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

		{

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

		}

		dp[i]=mini;

	}

	cout<<dp[0];

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

#include <string>

#include <deque>

using namespace std;



deque<int> dq;

string s;



int main()

{

    cin >> s;

    dq.clear();

    for (int i = 0; i < s.size(); ++ i) {

        if (s[i] == '0') dq.push_back(0);

        if (s[i] == '1') dq.push_back(1);

        if (s[i] == 'B') if(!dq.empty()) dq.pop_back();

    }

    while(!dq.empty()) {

        cout << dq.front();

        dq.pop_front();

    }

    cout << endl;

    return 0;

}


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

# include <cstring>

using namespace std;



int main()

{

	char a[100];

	char b[100];

	scanf("%s",a);

	int len = strlen(a);

	int k = 0;

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

	{

		if(a[i] == 'B')

		{

			if(k != 0) 

				k--;

		}

		else

		{

			b[k++] = a[i];

		}

	}

	b[k] = '\0'; 

	printf("%s\n",b);

	return 0;

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

#include<iostream>

#include<queue>

#include<map>

#include<cstring>

using namespace std;

const int N=1e6;



int main(){

	int a,b,c;

	int i;

	scanf("%d%d%d",&a,&b,&c);

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

		if((a*i%b)==c){ 

			printf("YES\n");

					break;

		}

	}

	if(i==N) printf("NO\n");

}


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

#include<cstdlib>

#include<cstring>

#include<string>

#include<algorithm>

using namespace std;



int main()

{

	int a, b, c, d, flag = 0;

	scanf("%d%d%d", &a, &b, &c);

	d = a;

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

	{

		if(d % b == c)

		{

			flag = 1;

			break;

		}

		else

	        d += a;

	}

	if(flag == 1)

		printf("YES\n");

	if(flag == 0)

        printf("NO\n");

    return 0;

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

typedef long long ll;

using namespace std;



int main() {

	cin.tie(0);

	ios::sync_with_stdio(false);

	ll n,a,q,b,c,sum=0;

	cin>>n;

	vector<ll>v(1000000);

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

		cin>>a;

		v[a]++;

		sum+=a;

	}

	cin>>q;

	for(ll i=0;i<q;i++){

		cin>>b>>c;

		int w;

		w=v[b];

		v[b]=0;

		v[c]+=w;

		sum=sum-(b*w)+(c*w);

		cout<<sum<<endl;

	}

	return 0;

}


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

typedef long long ll;

using namespace std;



int main() {

	cin.tie(0);

	ios::sync_with_stdio(false);

	ll n,a,q,b,c,sum=0;

	cin>>n;

	vector<ll>v(100001);

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

		cin>>a;

		v[a]++;

		sum+=a;

	}

	cin>>q;

	for(ll i=0;i<q;i++){

		cin>>b>>c;

		int w;

		w=v[b];

		v[b]=0;

		v[c]+=w;

		sum=sum-(b*w)+(c*w);

		cout<<sum<<endl;

	}

	return 0;

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



using namespace std;



#define PROBLEM "B"

#define TESTC ""



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

typedef pair<int, int> P;

#define F first

#define S second

#define INF 0x3f3f3f3f

#define MP make_pair

#define PB push_back

#define MAXN 1000005



bool arr[MAXN];



int main()

{

	#ifdef DBG

	freopen(PROBLEM TESTC ".in", "r", stdin);

	freopen(PROBLEM ".out", "w", stdout);

	#endif



	int num;

	

	while(~scanf("%d",&num))

	{

		memset(arr,0,sizeof(arr));



		int cnt = 1;

		while(1)

		{

			arr[num] = true;

			if (num % 2 == 0)

			{

				num /= 2;

			}

			else

			{

				num = num*3+1;

			}

			cnt++;

			if(arr[num])

			{

				break;

			}	

		}



		printf("%d\n",cnt);

		

	}

	

	return 0;

}

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

using namespace std;

#define LL long long int

#define DL double

#define MLL map<LL,LL>::iterator

#define MSL map<string,L>::iterator

#define MLS map<LL,string>::iterator

#define MSS map<string,string>::iterator

#define MCL map<char,LL>::iterator

#define SL set<LL>::iterator

#define SS set<string>::iterator

#define VL vector<LL>::iterator

#define G getline

#define SZ size()

#define IN insert

#define C clear()

#define B begin()

#define F front()

#define T top()

#define E end()

#define EM empty()

#define V vector

#define Q queue

#define DQ deque

#define PQ priority_queue

#define ST stack

#define FI first

#define SE second

#define PI acos(-1)

#define PS push

#define PP pop()

#define PSF push_front

#define PSB push_back

#define PPF pop_front()

#define PPB pop_back()

#define endl "\n"

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

void Y()

{

    cout<<"Yes"<<endl;

}

void N()

{

    cout<<"No"<<endl;

}

map<LL,LL>u;

int main()

{

    FAST;

    LL n,m,i,j,k,p,q,o,l,s,t,z,a,b,c,d,e,f,g,h;

    cin>>n;

    u[n]++;

    k=0;

    while(1)

    {

        if(n%2==0)

        {

            n/=2;

        }

        else

        {

            n=(3*n)+1;

        }

        u[n]++;

        k++;

        if(u[n]>1)

        {

            cout<<k+1<<endl;

            break;

        }

    }





    return 0;

}
// 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], k;



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>>k;



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



    init();



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

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

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

        }

    }



    cout<<dp[n];



return 0;

}


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

#include<stdlib.h>

#include<math.h>





typedef long long ll;





ll *mem, *inp, dist, min_dist, N;

int k;



int main()

{

    ll i, j;

    scanf("%lld%d", &N, &k);



    mem =(ll*) malloc(N * sizeof(ll));

    inp =(ll*) malloc(N * sizeof(ll));



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

        scanf("%lld", inp+i);

    }



    *(mem+N-2) = llabs(*(inp+N-2) - *(inp+N-1));



    for(i = 3; i<=k+1 && i<=N; ++i)

        *(mem+N-i) = llabs(*(inp+N-i) - *(inp+N-1));



    for(i = N-(k+2); i>=0; --i){



        min_dist = llabs(*(inp+i) - *(inp+i+1)) + *(mem+i+1);

        for(j = 2; j<=k && i+j<N; ++j){

            dist = llabs(*(inp+i) - *(inp+i+j)) + *(mem+i+j);

            if (dist < min_dist) min_dist = dist;

        }



        *(mem+i) = min_dist;

    }



    printf("%lld\n", *mem);



    return 0;

}