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

#include<algorithm>

#include<cmath>

#include<string>

#include<vector>

#include<array>

#include<cstdlib>

#include<ctime>

#include<climits>

using namespace std;



int f(int n){

	if(n % 2 == 0){

		return n / 2;

	}

	else{

		return 3 * n + 1;

	}

}



int main(){

	int s;

	cin >> s;



	//int a[1000000];

	//vector<int> a;

	vector<int> a(1000000);

	a[0] = s;

	int ans = 0;

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

		a[i] = f(a[i - 1]);



		for(int j = i - 1; j >= 0; j--){

			if(a[i] == a[j]){

				ans = i + 1;

				goto Exit;//

			}

		}

	}



Exit://

	cout << ans << endl;

}

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

#include<algorithm>

#include<cmath>

#include<string>

#include<vector>

#include<array>

#include<cstdlib>

#include<ctime>

#include<climits>

using namespace std;



int f(int n){

	if(n % 2 == 0){

		return n / 2;

	}

	else{

		return 3 * n + 1;

	}

}



int main(){

	int s;

	cin >> s;



	//int a[1000000];

	vector<int> a;

	//vector<int> a(1000000);

	a.push_back(s);

	int ans = 0;

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

		a.push_back(f(a[i - 1]));



		for(int j = i - 1; j >= 0; j--){

			if(a[i] == a[j]){

				ans = i + 1;

				goto Exit;

			}

		}

	}



Exit:

	cout << ans << endl;

}
// Slower C++ solution:
#define M 2000000000

#include <stdio.h>



int min(int,int);

int abs(int);



int main(){

    int n,k;

    int h[100000];

    scanf("%d%d",&n,&k);

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

    int dp[100000]={};

    for(int i=0;i<n;i++) dp[i]=M;



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

        if(i==0){

            dp[i]=0;

        }

        else {

            int j;

            if(i-k<0) j=0;

            else j=i-k;

            for(;j<i;j++){

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

            }

        }

        // for(int k=0;k<n;k++){

            // printf("dp[%d]=%d\n",k,dp[k]);

        // }

        // printf("\n");

    }

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



}



int min(int a,int b){

    if(a<=b) return a;

    else return b; 

}



int abs(int n){

    if(n>=0) return n;

    else return -n;

}

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

#include <limits.h>



int n,k;

int h[100000];

int dp[100000];



int abs(int x){return x>0?x:-x;}

int min(int a,int b){return a>b?b:a;}



int main()

{

    scanf("%d %d",&n,&k);

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



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

    dp[0]=0;



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

    {

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

        {

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

        }

    }

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

}
// Slower C++ solution:
#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';

        }

    }

}

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

#include<cmath>

#include<algorithm>



using namespace std;



int A[100001];

int B[100001];



int func(int b, int e, int v)

{

	int m = abs(v - A[b]) + B[b];

	for(int i=b+1;i<e;++i)

	{

		m = min(m, abs(v - A[i]) + B[i]);

	}

	return m;

}



int main()

{

	int n, k;

	scanf("%d %d", &n, &k);

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

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

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

		B[i] = func(0, i, A[i]);

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

		B[i] = func(i - k, i, A[i]);

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

	fflush(stdout);

	return 0;

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

using namespace std;

#define ll long long

ll dp[100009];

ll n,x,result,ans;

vector<ll>v;

ll frog(ll pos,ll k)

{

   if (pos >= 0 && pos <n-1)

    {

        if (dp[pos]!= -1)

            return dp[pos];

      ll  int ret = INT_MAX;

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

        {

            if(pos+i==n)

                break;

            ans = frog(i + pos,k ) + abs(v[pos]-v[pos+i]);

           // cout<<ans<<endl;

                ret = min(ret,ans );

        }

        return dp[pos] = ret;

    }

    else if(pos==n-1)

        return 0;

    else

        return INT_MAX;

}



int main()

{

    ll k;

    cin>>n>>k;

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

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

    {

        cin>>x;

        v.push_back(x);

    }

    cout<<frog(0,k)<<endl;

}

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

using namespace std;

#define ll long long

#define ull unsigned long long

#define ui unsigned int

#define us unsigned short

#define endl "\n"

const long long mod=1e9+7;const double pi=acos(-1);const long long inf=1e18;

int main(){	ios_base::sync_with_stdio(0); cin.tie(); cout.tie();	ll n,k,h[100100],dp[100100];	cin>>n>>k;	for(int i=1;i<=n;i++){		cin>>h[i];	}	dp[0]=dp[1]=0;	for(int i=2;i<=n;i++){		dp[i]=inf;	}	for(int i=2;i<=n;i++){		for(int j=i-1;j>=max(1ll,i-k);j--){			dp[i]=min(dp[i],dp[j]+abs(h[i]-h[j]));		}}cout<<dp[n]<<endl;}
// Slower C++ solution:
#include<iostream>

#include<string>

using namespace std;

char a[1001];

int main()

{

    string s;

    int k=0;

    cin>>s;

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

    {

    	if(s[i]=='0'||s[i]=='1')

    	{

    		k++;

    		a[k]=s[i];

		}

		else

		{

			if(k>0)

			k--;

		}

	}

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

	cout<<a[i];

    return 0;

}

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

#include<cstring>

using namespace std;

char s[20], S[20];

int main()

{

	scanf("%s", s);

	int len = strlen(s);

	int cnt = 0;

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

	{

		if(s[i] == '1')

		{

			S[cnt] = '1';

			cnt++;

		}

		if(s[i] == '0')

		{

			S[cnt] = '0';

			cnt++;

		}

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

		{

			if(cnt)cnt--;

			S[cnt] = '\0';

		}

	}

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

	return 0;

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

using namespace std;



const int N = 100009;

int f[N], dp[N];





int main(){



        int n, k; scanf("%d %d", &n, &k);

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

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

        }



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



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

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

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

                        if(i + j > n)break;

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

                }

        }



        cout << dp[n] << endl;









        return 0;

}




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

using namespace std;



int n,h[100005],c[100005],k;



int main()

{

    cin>>n>>k;

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

        cin>>h[i];

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

        c[i] = abs(h[0] - h[i]);



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

    {

        long long m = 1e10;

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

        {

            if ((c[i-j] + abs(h[i] - h[i-j])) <= m)

                m = c[i-j] + abs(h[i] - h[i-j]);

            c[i] = m;

        }

    }

    cout<<c[n-1];

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

#include<cmath>

#include<string>

#include<cstring>

#include<algorithm>

#include<iomanip>

#include<cstdio>

#include<stack>

#include<queue>

using namespace std;

typedef long long ll;

int main(){

	string s,ans;

	int k;

	cin>>k;

	cin>>s;

	ans=s;

	int len=s.length() ;

	if(len>k) {

		ans=s.substr (0,k)+"...";

	}

	cout<<ans;

	return 0;

}


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

	# include <string.h>

	int main () {

		int a = 0;

		int c =0;

	char name [100];

		scanf ("%d",&a);

		scanf("%s%[^\n]",&name);

		c = strlen (name);

		if (c<=a) {

			printf ("%s",name);

		} else if (c>a) {

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

				printf ("%c",name[i]);

			}

			printf("...");

		}

		return 0;

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

#include <string.h>

#include <stdio.h>

#include <math.h>

#include <list>

#include <set>

#include <queue>

#include <iterator>

#include <bitset>

#include <bits/stdc++.h>

#include <vector>

#include <cctype>

#include <algorithm>

#define ll             long long

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

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

#define pb             push_back

#define tc()           int t;cin>>t;while(t--) 

#define pi             acos(-1)         

 

using namespace std;

 

ll i,j,temp;



 

int main()

{_

    

   int n,len =0;

   char str[101];

   cin>>n>>str;

   while(str[len]!='\0')

   	len++;



   if(n>=len){

   	cout<<str<<endl;

   }

   else{

   	str[n] = '\0';

   	cout<<str<<"..."<<endl;

   }

 

return 0;

}

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

	# include <string.h>

	int main () {

		int a = 0;

		int c =0;

	char name [100];

		scanf ("%d",&a);

		scanf("%s%[^\n]",&name);

		c = strlen (name);

		if (c<=a) {

			printf ("%s",name);

		} else if (c>a) {

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

				printf ("%c",name[i]);

			}

			printf("...");

		}

		return 0;

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

using namespace std;



template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }



using ll=long long;

const int Nmax=100010;

int N,K; 

ll dp[Nmax];

int h[Nmax];

const ll INF=1LL<<60;





int main(){

  cin >> N >> K;

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

    cin >> h[i];

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

    dp[i]=INF;

  dp[0]=0;

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

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

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

    }

  }

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

  

}

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

using namespace std;

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

using ll=long long;

const ll MOD=1e9+7;

const int INF=1<<30;



template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }



int dp[100010];



int main(){

  int N,K;

  cin >> N >> K;

  vector<int> h(N);

  rep(i,N){

    cin >> h[i];

  }

  for(int i=0;i<1e5+10;i++){

    dp[i]=INF;

  }

  dp[0]=0;

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

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

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

    }

  }

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

  

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

using namespace std;



int main()

{

    int n, minHeight, friends, counter=0;

    cin >> n >> minHeight;

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

    {

        cin >> friends;

        if(friends >= minHeight)

            ++counter;

    }

    cout << counter;

    return 0;

}


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

int main()

{

	int a,n,k,h[100000],cnt=0;

	scanf("%d%d",&n,&k);

	for(a=0;a<n;a++){

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

		if(h[a]>=k){

			cnt++;

		}

	}

	printf("%d",cnt);

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

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

using namespace std;

#define X real()

#define Y imag()

#define cross(a, b) ((conj(a) * (b)).Y)

#define dot(a, b) ((conj(a) * (b)).X)

#define EPS 1e-7

long long mod = 1e9 +7;

typedef long long ll;

typedef unsigned long long ull;

typedef long double ld;

const double pi = acos(-1);

typedef complex <double> point;

typedef tuple<int, int, int> line;

typedef vector<point> polygon;

ll n , x , h[100005] , arr[100005];

ll solve(int ind)

{

    if(ind >= n)

        return 2e9;

    if(ind == n - 1)

        return 0;

    if(arr[ind] != -1)

        return arr[ind];

    ll ans = 2e9;

    for(int i = ind + 1; i < n && i <= ind + x ; i++)

        ans = min(ans , abs(h[ind] - h[i]) + solve(i));

    arr[ind] = ans;

    return ans;

}



int main()

{

    cin >> n >> x;

    memset(arr , -1 , sizeof arr);

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

        cin >> h[i];

    cout << solve(0);



    return 0;

}




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

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

using namespace std;

#define X real()

#define Y imag()

#define cross(a, b) ((conj(a) * (b)).Y)

#define dot(a, b) ((conj(a) * (b)).X)

#define EPS 1e-7

long long mod = 1e9 + 7;

typedef long long ll;

typedef unsigned long long ull;

typedef long double ld;

const double pi = acos(-1);

typedef complex <double> point;

typedef tuple<int, int, int> line;

typedef vector<point> polygon;

ll n , h[100005] , memo[100005] , k;



int main()

{

    em3

    cin >> n >> k;

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

        cin >> h[i];

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

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

    {

        memo[i] = 1e10;

        for(int j = i - 1 ; j >= 0 && i - j <= k; j--)

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

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

    }

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



    return 0;

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

#include<algorithm>

using namespace std;

int main()

{

    int i,j,n,m;

    cin>>n>>m;

    for(i=m-n+1;i<m+n;i++){

        cout<<i;

        if(i!=m+n-1)

            cout<<" ";

    }

}


// Faster C++ solution for the same problem (measured speedup: 5.213621581060176x):
////sfef

#include<stdio.h>

int main(){



int k,x,i,p,q,r;

scanf("%d %d",&k,&x);

p=(x-(k-1));

q=(x+(k-2));

r=(x+(k-1));

if(k==1)

{

    printf("%d",x);

}

else{

    for(i=p;i<=q;i++)    

    {

        printf("%d ",i);

    }

    printf("%d",r);

}



return 0;

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

#include <cstring>

using namespace std ;



int main()

{

	int n ;

	cin >> n ;

	string str ;

	cin >> str ;

	int len = str.length() ;

	if(n < len)

	{

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

		cout << str[i] ;

		cout << "..." << endl ;

	}

	else if(n >= len)

	{

		cout << str << endl ;

	}



	return 0 ;

}

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



int main(){

	int k;

	char word[100];

	scanf("%d", &k);

	scanf("%s", &word);

	

	int len = 0;

	

	for(int i = 0; word[i] != '\0'; i++){

		len++;

	}

	

	if(len <= k){

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

	}

	else{

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

			printf("%c", word[i]);

		}

		printf("...\n");

	}

	return 0;

}
// Slower C++ solution:
/**

 * @author      : Luis Miguel Baez <es.luismiguelbaez@gmail.com>

 * @created     : Thursday August 13, 2020

 */



#include <bits/stdc++.h>



using namespace std;



#define endl '\n'

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

#define rall(x) (x).rbegin(), (x).rend()

#define ms(arr, value) memset(arr, value, sizeof arr)

#define ll    int64_t



const int oo  = (int)(1e9);

const ll lloo  = (ll)(1e18);



const int N = 1e5 + 10;



class Task {

public:

    

    int n, k;

    vector<int> A;



    ll dp[N];



    ll go(int index) {

        if(index > n) return 0LL;

        if(index == n) {

            return 0LL;

        }



        ll &ans = dp[index];

        if(ans != -1) return ans;



        ll x = oo;

        

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

            if(index+i <= n) {

                x = min(x, abs(A[index]-A[index+i]) + go(index + i));

            }

        }

        if(x == oo) {

            x = 0;

        }

        ans = x;

        return ans;

    }





    ll solveOne(istream &in, ostream &out) {

        in >> n >> k;

        A.resize(n+1);

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

            in >> A[i];

        }

        memset(dp, -1, sizeof dp);

        ll ans = go(1);

        return ans;  

    }

    

    void solve(istream &in, ostream &out) {

        int t=1;

        while(t--) {

            out << solveOne(in, out) << endl;

        }

    }

};



auto main() -> int {

    ios_base::sync_with_stdio(false);

    cin.tie(NULL);

    cout.tie(NULL);

    

    Task solver;

    istream &in(cin);

    ostream &out(cout);

    solver.solve(in, out);

    return 0;

}




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

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

#define fst first

#define snd second

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

#define pb push_back

#define sz size()

#define FORN(i,j,n) for(int i=j; i<(int)n;i++) 

#define FOR(i,n) FORN(i,0,n)

#define FORIT(i,x) for( auto i = x.begin() ; i != x.end() ; i++ )

#define MOD 998244353LL

#define LIM 262150

#define ones(x) __builtin_popcount(x)

#define trace(x)    cerr << #x << ": " << x << endl;

#define trace2(x, y) cerr << #x << ": " << x << " | " << #y << ": " << y << endl;

using namespace std;

 

typedef long long ll ;

typedef unsigned long long ull ;

typedef vector <int> vi;

typedef pair <int,int> ii;

typedef vector <string> vs;

typedef vector <ii> vii;

ll n , k;

ll dp[100005];

ll arr[100005];

int main() {

	fastio;

	cin>> n >> k;

	FOR(i,n) cin>> arr[i];

	dp[0] = 0;

	FORN(i,1,n){

		dp[i] = 1e12;

	}

	FOR(i,n){

		FORN(j,1,min(k+1,n-i)){

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

		}

	}

	cout<< dp[n-1] << "\n";

	return 0;

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



using namespace std ;



int n , k ;

const int N = 1e5 +  10 ;

int h[N] ;

int mem[N] ;









int jump(int i){

    if(i == 0) return 0 ;



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







    mem[i] = 2e9 ;

    for(int j = 1 ; j <= k && i - j >= 0 ; j++)

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





    return mem[i] ;

}









int main(){

    scanf("%d %d" , &n , &k) ;





    memset(mem , -1 , sizeof mem) ;

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

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







    printf("%d\n" , jump(n - 1)) ;

}


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



using namespace std ;



int n , k ;

const int N = 1e5 + 10;

int a[N] , cost[N] ;









int main(){

    scanf("%d %d" , &n , &k) ;

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

        cost[i] = 2e9 ;







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



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



        int j = i - k  ;

        if(j < 0) j = 0 ;



        for(j ; j < i ; j++){



            if(cost[j] + abs(a[j] - a[i]) < cost[i])

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



        }





        //printf("%d " , cost[i]) ;

    }









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

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

using namespace std;

int dp[100005],a[100005];

int main()

{

    int i,k,n,m,mx,x,l;

    cin>>n>>k;

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

    {

        cin>>a[i];

    }

    dp[0]=0;

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

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

    {

        mx=INT_MAX;

        l=1;

        while((i-l)>=0)

        {

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

            mx=min(mx,x);

            if(l==k)

            {

                break;

            }

            l++;

        }

        dp[i]=mx;

    }

    cout<<dp[n-1]<<"\n";

    return 0;

}




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

#include <algorithm>

#include <cmath>

using namespace std;



int h[(int)1e5], dp[(int)1e5], K, N;





int main()

{

	K = N = 0;

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

	{

		dp[j] = 1e9;

	}

	scanf("%d %d", &N, &K);

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

	{

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

	}

	dp[1] = 0;

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

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

	{

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

		{

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

		}

	}

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

	return 0;	

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

using namespace std;



int main(){

	int x, y, s;

	int a;

	int a2, b2, s2, res;

	int lb, ub, mid;

	

	while(true){

		scanf("%d%d%d", &x, &y, &s);

		if(x == 0 && y == 0 && s == 0) break;

		

		res = 0;

		for(a = 1; a < s; a++){

			ub = s; lb = 0;

			while(ub - lb > 1){

				mid = (ub + lb) / 2;

				if(mid * (100 + x) / 100 > a){

					ub = mid;

				}

				else{

					lb = mid;

				}

			}

			if(lb * (100 + x) / 100 == a){

				a2 = lb;

				ub = s; lb = 0;

				while(ub - lb > 1){

					mid = (ub + lb) / 2;

					if(mid * (100 + x) / 100 > s - a){

						ub = mid;

					}

					else{

						lb = mid;

					}

				}

				if(lb * (100 + x) / 100 == s - a){

					b2 = lb;

					s2 = (a2 * (100 + y) / 100) + (b2 * (100 + y) / 100);

					if(s2 > res){

						res = s2;

					}

				}

			}

		}

		

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

	}

	return 0;

}

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

using namespace std;



int main() {

	int x, y, s;

	int a, b;

	int p, q, res;



	while (true) {

		scanf("%d%d%d", &x, &y, &s);

		if (x == 0 && y == 0 && s == 0) {

			break;

		}



		res = 0;

		for (a = 1;a < s;a++) {

			p = (100 + x)*a / 100;

			q = s - p;

			if (q > 0) {

				if ((int)100 * q / (100 + x) != (int)100 * (q + 1) / (100 + x)) {

					if ((int)100 * (q + 1) / (100 + x) == (double)100 * (q + 1) / (100 + x)) {

						b = 100 * q / (100 + x);

					}

					else {

						b = 100 * (q + 1) / (100 + x);

					}

					if ((int)a*(100 + y) / 100 + (int)b*(100 + y) / 100 > res) {

						res = (int)a*(100 + y) / 100 + (int)b*(100 + y) / 100;

					}

				}

			}

		}



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

	}



	return 0;

}