stablegradients/pie-gem5-bysrc huggingface dataset:
// Original C++ solution (slower):
#include<bits/stdc++.h>

using namespace std;

#define ll long long

#define pb push_back

ll n,k;

ll h[100001];

ll dp[100001];



ll jump()

{

    dp[1] = 0;

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

    {

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

        {

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

        }

    }

    //cout<<dp[1];

    return dp[n];

}



int main()

{

    cin>>n>>k;

    //cout<<n<<k<<"\n";

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

        dp[i] = INT_MAX;



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

    {

        cin>>h[i];

    }



    cout<<jump()<<"\n";



    return 0;

}


// Optimized solution to the same problem (faster):
/*-------------------------------*

| Name: Ayush Kumar              |

| Site: atcoder                  |

| Email: ayushkr667@gmail.com    |

*-------------------------------*/



#include<bits/stdc++.h>

using namespace std;

#define ll long long

#define pb push_back

#define mp make_pair

#define mod 1000000007

#define INF (ll) 1e18

const double PI = 3.141592653589793238460;

int main()

{

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

    ll n, k;

    cin>>n>>k;

    ll arr[n+1];

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

    {

        cin >> arr[i];

    }

    ll dp[n+1];

    dp[1] = 0;

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

    {

        dp[i] = INF;

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

        {

            if( i-j >= 1)

            {

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

            }

        }

    }

    cout<<dp[n];

    return 0;

}


// Fastest known solution for this problem:
#include <iostream>

#include <array>

#include <vector>

#include <iomanip>

#include <string>

#include <cmath>

#include <array>

#include <algorithm>

#include <queue>

#include <map>

using namespace std;



typedef  pair<int,int> P;

typedef long long LL;



const LL  INF=1<<31;







int main(){

     int n,k;

     cin>>n>>k;

     int h[100000];

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

          cin>>h[i];

     }

     LL dp[100001];



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

           dp[i]=INF;

      }

            dp[0]=0;

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







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

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

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



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

          }

     }     



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





}
// Original C++ solution (slower):
#include<iostream>

#include<cstring>

using namespace std;

int main(){

	int k;

	string s;

	cin>>k;

	cin>>s;

	if(k>=s.length()){

		cout<<s<<endl;

	}else{

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

			if(i==k-1){

				cout<<s[i]<<"..."<<endl;

			}else{

				cout<<s[i];

			}

		}

	}

	return 0;

}

// Optimized solution to the same problem (faster):
#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;

}

// Fastest known solution for this problem:
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int mod = 1000000007;

const double PI = acos(-1);



int main()

{

	int k;

	string s;

	cin >> k >> s;

	if (s.size() <= k) cout << s << endl;

	else cout << s.substr(0, k) + "..." << endl;

}
// Original C++ solution (slower):
#include<bits/stdc++.h>

using namespace std;



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

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



typedef vector<int> vi;

typedef long long ll;

typedef pair<int,int> PII;

typedef pair<long long,long long> PLL;



const int inf=1e9;

const int mod=1e9+7;



vi dp(100110,inf);



int main(){

	int n,k;

	cin>>n>>k;

	int h[n];

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

		cin>>h[i];

	}



	dp[0]=0;

	for (int i = 0; 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]));

		}

	}



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





	return 0;

}

// Optimized solution to the same problem (faster):
#include<bits/stdc++.h>

using namespace std;



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

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

#define pb push_back



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

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



typedef long long ll;

typedef pair<int,int> pii;

typedef vector<int> vi;

typedef vector<vi> vvi;



const int inf=1e9;

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

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



int main(){

	int n,k;

	cin>>n>>k;

	vi h(n);

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

		cin>>h[i];

	}



	vi dp(n,1e+9);

	dp[0]=0;

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

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

			if(i+j>=n)continue;

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

		}

	}



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



	return 0;

}


// Fastest known solution for this problem:
#include <iostream>

#include <array>

#include <vector>

#include <iomanip>

#include <string>

#include <cmath>

#include <array>

#include <algorithm>

#include <queue>

#include <map>

using namespace std;



typedef  pair<int,int> P;

typedef long long LL;



const LL  INF=1<<31;







int main(){

     int n,k;

     cin>>n>>k;

     int h[100000];

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

          cin>>h[i];

     }

     LL dp[100001];



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

           dp[i]=INF;

      }

            dp[0]=0;

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







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

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

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



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

          }

     }     



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





}
// Original C++ solution (slower):
#include<bits/stdc++.h>

using namespace std;

int main()

{

    int a,b,c;

    cin>>a>>b;

    c=b-a+1;

    int i;

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

    {

        cout<<c<<" ";

        c++;

    }

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

    {

        cout<<c<<" ";

        c++;

    }

    return 0;

}


// Optimized solution to the same problem (faster):
////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;

}


// Fastest known solution for this problem:
#include <bits/stdc++.h>

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

using namespace std;



int main(void) {

	int k, x;

	cin >> k >> x;

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

		if (i == x+k) cout << i << endl;

		else cout << i << " ";

	}

	return 0;

}
// Original C++ solution (slower):
#include<cstdio>

#include<iostream>

#include<deque>

using namespace std;

int main()

{

    string s;

    deque<int>ans;

    cin>>s;

    int len = s.size();

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

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

            ans.push_back(0);

        }

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

            ans.push_back(1);

        }

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

            if(ans.size()!=0)ans.pop_back();

        }

    }

    while(!ans.empty()){

        printf("%d", ans.front());

        ans.pop_front();

    }



    return 0;

}


// Optimized solution to the same problem (faster):
#include<stdio.h>

#include<string.h>



int main(){

	char str[15];

	scanf("%s",&str);

	char temp[15];

	int index=0,len=strlen(str);

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

		if(str[i]=='0'){

			temp[index] = '0';

			//printf("index[%d] : %s\n",index,temp);

			index++;

		} 

		else if(str[i]=='1'){	

			temp[index] = '1';

			//printf("index[%d] : %s\n",index,temp);

			index++;

		} 				//01B0 temp =     --0

		else if(str[i]=='B'){

			//printf("index[%d] : %s\n",index,temp);

			if(index != 0) index--;

		}

	}

	//printf("%d\n",index);

	temp[index]='\0';

	printf("%s\n",&temp);

	

	

	

	return 0;

}

// Fastest known solution for this problem:
#include <bits/stdc++.h>

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

#define pa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};

#define pb push_back



using ll = long long;

using namespace std;

using pint = pair<int,int>;

using pll = pair<ll,ll>;

const int INFint = 1e9;

const ll INFll = 1e18;

ll MOD=1e9+7;



ll gcd(ll a, ll b) { return __gcd(a,b); } //最大公約数

ll lcm(ll a, ll b) { return a/gcd(a,b)*b; } //最大公倍数



// aのn乗をMODで割りながら計算する

ll modpow(ll a, ll n) {

  long long res = 1;

  while (n > 0) {

    if (n & 1) res = res * a % MOD;

    a = a * a % MOD;

    n >>= 1; // right shift

  }

  return res;

}



// MODを法としたaの逆元を計算する

ll modinv(ll a) {

  return modpow(a, MOD - 2);

}



int main(){

  string s;

  cin>>s;

  int N = int(s.size());

  string ans;

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

    //cout << ans << endl;

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

      if (int(ans.size()) != 0){

        ans = ans.substr(0,int(ans.size())-1);

      }

    }else{

      ans += s[i];

    }

  }

  cout << ans << endl;

  return 0;

}
// Original C++ solution (slower):
#include <bits/stdc++.h>

using namespace std;

//*******************

// Mahmoud Magdy    *

//*******************

#define ll long long

#define endl "\n"



void fast()

{

    ios_base :: sync_with_stdio( 0 ) ;

    cin.tie( 0 ) ;

    cout.tie( 0 ) ;

}

inline int D()

{

    int m ;

    cin>>m;

    return m ;

}

inline ll lD()

{

    ll m ;

    cin>>m;

    return m ;

}

inline double dD()

{

    double m ;

    cin>>m;

    return m ;

}

int main()

{

  fast();

  int n=D();

  int x=n/15;

  ll sum=1;

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

    sum=(sum*i)%1000000007;

  cout<<sum%1000000007<<endl;

}




// Optimized solution to the same problem (faster):
#include <cstdio>

const long long MOD=1e9+7;

int n;

long long ans=1;

int main()

{

	scanf("%d",&n);

	for(int i=1;i<=n;i++) ans=(ans*i)%MOD;

	printf("%lld",ans);

}

// Fastest known solution for this problem:
#include <bits/stdc++.h>

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

using namespace std;

using ll = long long;

using P = pair<ll, ll>;

const string ln = "\n";

constexpr int INF = 1001001001;

constexpr int MOD = 1000000007;



int main() {

  cin.tie(nullptr);

  ios::sync_with_stdio(false);



  int n;

  cin >> n;



  ll ans = 1;



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

    ans *= i % MOD;

    ans %= MOD;

  }



  cout << ans << ln;



  return 0;

}
// Original C++ solution (slower):
#include <bits/stdc++.h>



#define filein freopen ("in.txt", "r", stdin)

#define fileout freopen ("out.txt", "w", stdout)

#define dbg(x) cerr << #x << ": " << x << endl



using namespace std;

typedef long long ll;



const int maxn = 100005;

const ll inf = 1e10;



ll a[maxn];

ll dp[maxn];



int main(){

	ll n, k;

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

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

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

	dp[1] = 0;

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

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

		dp[i] = inf;

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

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

		}

	}

	cout << dp[n] << '\n';

	return 0;

}

// Optimized solution to the same problem (faster):
//才不露白

//还是青蛙跳还是动态规划

//唯一的是你不知道青蛙它从哪跳到了现在的石头上 如果你知道 那就好办了

//比如从k上面跳过来

//dp[i] = dp[k] + abs(h[i] - h[k])

//关键是你k不知道啊

//有想法就好 不用先急着自我否认

//枚举

//dp[1] = 0

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

//写个函数来算看起来不错

//dp[3] = min(从1跳过来,从2跳过来)

//dp[4] = min(从1跳,从2跳，从3跳)用循环 最后求min

//差不多2层吧 先写了试试看

#include <stdio.h>

#include <stdlib.h>

#include <string.h>

#include <math.h>

#include <queue>

#include <stack>

#include <vector>

#include <algorithm>



using namespace std;



const int MAXN = 1e5;

int n,k;

int h[MAXN + 5],dp[MAXN + 5];//



int CHANGE(int i,int k)//

{

	if(i <= k + 1)//一跳就到

	{//从一开始选

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

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

		{

			if((dp[j] + abs(h[i] - h[j])) < min)

			{

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

			}

		}

		return min;

	}

	else

	{

		int min = dp[i - k] + abs(h[i] - h[i - k]);

		for(int j = i - k; j < i; j++)

		{

			if((dp[j] + abs(h[i] - h[j])) < min)

			{

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

			}

		}

		return min;

	}

}



int main()

{

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

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

	{

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

	}

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

	{

		if(i == 1)

		{

			dp[i] = 0;

		}

		else if(i == 2)

		{

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

		}

		else

		{

			dp[i] = CHANGE(i,k);

		}

	}

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

	return 0;

}

// Fastest known solution for this problem:
#include <iostream>

#include <array>

#include <vector>

#include <iomanip>

#include <string>

#include <cmath>

#include <array>

#include <algorithm>

#include <queue>

#include <map>

using namespace std;



typedef  pair<int,int> P;

typedef long long LL;



const LL  INF=1<<31;







int main(){

     int n,k;

     cin>>n>>k;

     int h[100000];

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

          cin>>h[i];

     }

     LL dp[100001];



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

           dp[i]=INF;

      }

            dp[0]=0;

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







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

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

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



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

          }

     }     



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





}
// Original C++ solution (slower):
#include <bits/stdc++.h>

#define ll long long

#define PI 3.141592653589

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

#define EPS 1e-9

#define f first

#define s second

using namespace std;

int n, k;

int arr[100005];

ll memo[100005];

ll solve(int idx){

    if (idx >= n-1)

        return 0;

    ll &res = memo[idx];

    if(res != -1)

        return res;

    res = 1e18;

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

        res = min(res, abs(arr[idx+i]-arr[idx])+solve(idx+i));

    return res;

}

int main(){

    IO;

    cin >> n >> k;

    memset(memo, -1, sizeof memo);

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

        cin >> arr[i];

    cout << solve(0);



    return 0;

}


// Optimized solution to the same problem (faster):
#include <bits/stdc++.h>

#define ll long long

#define PI 3.141592653589

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

#define EPS 1e-7

#define f first

#define s second

using namespace std;

int main() {

    IO;

    int n, k;

    cin >> n >> k;

    int arr[n+1];

    ll dp[n+1];

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

        cin >> arr[i];

    dp[1] = 0;

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

        dp[i] = 1e9;

        for(int j = max(i-k,1);j<i;j++){

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

        }

    }

    cout << dp[n];

    return 0;

}


// Fastest known solution for this problem:
#include <iostream>

#include <array>

#include <vector>

#include <iomanip>

#include <string>

#include <cmath>

#include <array>

#include <algorithm>

#include <queue>

#include <map>

using namespace std;



typedef  pair<int,int> P;

typedef long long LL;



const LL  INF=1<<31;







int main(){

     int n,k;

     cin>>n>>k;

     int h[100000];

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

          cin>>h[i];

     }

     LL dp[100001];



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

           dp[i]=INF;

      }

            dp[0]=0;

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







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

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

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



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

          }

     }     



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





}
// Original C++ solution (slower):
#include<bits/stdc++.h>

using namespace std;

#define    sz    100110

#define    ll    long long int

ll n,c=0,p,q,k;

ll num[sz];

ll vis[sz];

ll dp[sz];





ll tani(ll pos)

{

    ll mn=100000000000;



    if(pos>=n )

        return 0;

    if(vis[pos]==1)

        return dp[pos];



    vis[pos]=1;



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

    {

        mn=min(mn,abs(num[pos]-num[pos+i])+tani(pos+i));

    }

    // cout<<mn<<endl;

    return dp[pos]=mn;

}



int main()

{

    ll t,i;



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

        num[i]=10000000000;



    //cin>>n>>k;

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



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

    {

        // cin>>num[i];

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

    }

    t=tani(1);

    // cout<<t<<endl;

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

    return 0;

}




// Optimized solution to the same problem (faster):
#include<iostream>

#include<cstdio>

#include<cstring>

#include<cmath>

using namespace std;

typedef long long LL;

const int maxn = 1000010;

const int inf = 0x3f3f3f3f;

LL n;

LL dp[maxn];

LL a[maxn];

LL k;

inline LL max(LL x, LL y) {

	return x > y ? x : y;

}

inline LL min(LL x, LL y) {

	return x < y ? x : y;

}

int main(){

	ios::sync_with_stdio(false);

	cin.tie(0);

	cout.tie(0);

	cin >> n >> k;

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

		cin >> a[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(a[i] - a[j]));

	cout << dp[n];

	return 0;

}

// Fastest known solution for this problem:
#include <iostream>

#include <array>

#include <vector>

#include <iomanip>

#include <string>

#include <cmath>

#include <array>

#include <algorithm>

#include <queue>

#include <map>

using namespace std;



typedef  pair<int,int> P;

typedef long long LL;



const LL  INF=1<<31;







int main(){

     int n,k;

     cin>>n>>k;

     int h[100000];

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

          cin>>h[i];

     }

     LL dp[100001];



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

           dp[i]=INF;

      }

            dp[0]=0;

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







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

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

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



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

          }

     }     



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





}
// Original C++ solution (slower):
#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;

}

// Optimized solution to the same problem (faster):
#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];

}


// Fastest known solution for this problem:
#include <iostream>

#include <array>

#include <vector>

#include <iomanip>

#include <string>

#include <cmath>

#include <array>

#include <algorithm>

#include <queue>

#include <map>

using namespace std;



typedef  pair<int,int> P;

typedef long long LL;



const LL  INF=1<<31;







int main(){

     int n,k;

     cin>>n>>k;

     int h[100000];

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

          cin>>h[i];

     }

     LL dp[100001];



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

           dp[i]=INF;

      }

            dp[0]=0;

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







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

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

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



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

          }

     }     



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





}
// Original C++ solution (slower):
#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;

}


// Optimized solution to the same problem (faster):
# 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;

}

// Fastest known solution for this problem:
#include <bits/stdc++.h>

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

#define pa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};

#define pb push_back



using ll = long long;

using namespace std;

using pint = pair<int,int>;

using pll = pair<ll,ll>;

const int INFint = 1e9;

const ll INFll = 1e18;

ll MOD=1e9+7;



ll gcd(ll a, ll b) { return __gcd(a,b); } //最大公約数

ll lcm(ll a, ll b) { return a/gcd(a,b)*b; } //最大公倍数



// aのn乗をMODで割りながら計算する

ll modpow(ll a, ll n) {

  long long res = 1;

  while (n > 0) {

    if (n & 1) res = res * a % MOD;

    a = a * a % MOD;

    n >>= 1; // right shift

  }

  return res;

}



// MODを法としたaの逆元を計算する

ll modinv(ll a) {

  return modpow(a, MOD - 2);

}



int main(){

  string s;

  cin>>s;

  int N = int(s.size());

  string ans;

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

    //cout << ans << endl;

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

      if (int(ans.size()) != 0){

        ans = ans.substr(0,int(ans.size())-1);

      }

    }else{

      ans += s[i];

    }

  }

  cout << ans << endl;

  return 0;

}
// Original C++ solution (slower):
#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");

}


// Optimized solution to the same problem (faster):
#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;

}

// Fastest known solution for this problem:
#include <bits/stdc++.h>

using ll = long long;

using namespace std;



int main() {

  int A,B,C;

  cin>>A>>B>>C;

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

    if ((A*i-C)%B==0&&(A*i-C)>=0){

      cout << "YES"<<endl;

      return 0;

    }

  }

  cout << "NO"<<endl;

  return 0;

}