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

#include<algorithm>

#include<cstring>

#include<vector>

#include<queue>

#define LL long long

using namespace std;

const int N=1e5+7;

char s[N];

int R[N];

int L[N];

int ans[N];



int main()

{

	scanf("%s",s);

	int n=strlen(s);

	int pos;

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

		if(s[i]=='R') pos=i;

		R[i]=pos;

	}

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

		if(s[i]=='L') pos=i;

		L[i]=pos;

	}

	int k;

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

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

			k=L[i]-i;

			ans[L[i]-k%2]++;

		}

		else {

			k=i-R[i];

			ans[R[i]+k%2]++;

		}

	}

	cout<<ans[0];

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

		cout<<' '<<ans[i];

	}

	cout<<endl;

	return 0;

 } 


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

#include<string.h>





int main()

{

	char s[100005];

	int a[100005] = {0}, i=0, bsr,bsl, len;

	scanf("%s", s);

	len = strlen(s);

	while (i < len-1)

	{

		for (bsr=0; (bsr+i) < len-1; bsr++)/*寻找RL字符串*/

		{

			if ((s[i + bsr] == 'R') && (s[i + bsr + 1] == 'L'))

			{

				if (bsr % 2 == 0)

				{

					a[i + bsr] += (bsr / 2 + 1); a[i + bsr + 1] += bsr / 2;

				}

				else

				{

					a[i + bsr] += ((bsr + 1) / 2); a[i + bsr + 1] += ((bsr + 1) / 2);

				}

				for (bsl = 1; (i + bsr + bsl) < len; bsl++)

				{

					if (s[i + bsr + bsl] == 'R')

					{

						bsl--;

						break;

					}

					if ((i + bsr + bsl) == (len - 1))

						break;

				}

				if (bsl % 2 == 1)

				{

					a[i + bsr] += bsl / 2; a[i + bsr + 1] += (bsl / 2 + 1);

				}

				else

				{

					a[i + bsr] += bsl / 2; a[i + bsr + 1] += bsl / 2;

				}

				i = i + bsr + bsl + 1;

				break;

			}

		}

	}

	for (i = 0; i < len-1; i++)

		printf("%d ", a[i]);

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

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <algorithm>

#include <iostream>

#include <cstring>

#include <cstdio>

using namespace std;



int a[100010]={0};



int main()

{

    char t;

    int n=-1;

    while(n++,~scanf("%c",&t)&&t!='\n')if(t=='L')a[n]=-1;



    int cnt=0;

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

    {

        if(a[i]==0&&a[i+1]==0)

            cnt++;

        else if(a[i]==0&&a[i+1]==-1)

            a[i]=cnt+1,cnt=0;

    }

    cnt=0;

    for(int i=n-1;i>0;i--)

    {

        if(a[i]==-1&&a[i-1]==-1)

            cnt++;

        else if(a[i]==-1&&a[i-1]>0)

            a[i]=cnt+1,cnt=0;

    }

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

    {

        if(a[i]<=0)printf("0 ");

        else if(i<n-1&&a[i+1]>0)

        {

            int num = a[i]+a[i+1];

            if((num&1)==0)printf("%d %d ",num>>1,num>>1);

            else if((a[i]&1)==0)

                printf("%d %d ",num>>1,(num>>1)+1);

            else printf("%d %d ",(num>>1)+1,num>>1);

            i++;

        }

    }

    printf("\n");

    return 0;

}


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

#include<string.h>





int main()

{

	char s[100005];

	int a[100005] = {0}, i=0, bsr,bsl, len;

	scanf("%s", s);

	len = strlen(s);

	while (i < len-1)

	{

		for (bsr=0; (bsr+i) < len-1; bsr++)/*寻找RL字符串*/

		{

			if ((s[i + bsr] == 'R') && (s[i + bsr + 1] == 'L'))

			{

				if (bsr % 2 == 0)

				{

					a[i + bsr] += (bsr / 2 + 1); a[i + bsr + 1] += bsr / 2;

				}

				else

				{

					a[i + bsr] += ((bsr + 1) / 2); a[i + bsr + 1] += ((bsr + 1) / 2);

				}

				for (bsl = 1; (i + bsr + bsl) < len; bsl++)

				{

					if (s[i + bsr + bsl] == 'R')

					{

						bsl--;

						break;

					}

					if ((i + bsr + bsl) == (len - 1))

						break;

				}

				if (bsl % 2 == 1)

				{

					a[i + bsr] += bsl / 2; a[i + bsr + 1] += (bsl / 2 + 1);

				}

				else

				{

					a[i + bsr] += bsl / 2; a[i + bsr + 1] += bsl / 2;

				}

				i = i + bsr + bsl + 1;

				break;

			}

		}

	}

	for (i = 0; i < len-1; i++)

		printf("%d ", a[i]);

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

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
/// However long the night,

///     The dawn will break

/// ICPC next year



#include<bits/stdc++.h>

using namespace std ;

const int N = 1e5+5 ;



string str ;

int ans[N] ;

int main(){

    cin >> str ;

    int s=0 ,e = str.size()-1 ;

    while(s<str.size() && str[s]=='L'){

        ++ans[0] ;

        ++s ;

    }

    while(e>=0 && str[e]=='R'){

        ++ans[str.size()-1] ;

        --e ;

    }

    while(s<=e){

        int cntR=0 ,cntL=0 ;

        int to = s ,a=-1 ,b=-1 ;

        while(to<=e && str[to]=='R') ++cntR ,a = to++ ;

        b = a+1 ;

        while(to<=e && str[to]=='L') ++cntL ,to++ ;



        if(cntR>=cntL) ans[a] = (cntR+cntL+1)/2 ,ans[b] = cntR + cntL - ans[a] ;

        else ans[a] = (cntR+cntL)/2 ,ans[b] = cntR + cntL - ans[a] ;



        int stps = max(cntR ,cntL)-1 ;

        if(stps%2) swap(ans[a],ans[b]);



        s = to ;

    }

    for(int i=0;i<str.size();++i)printf("%d ",ans[i]);

    return 0;

}


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

#include<string.h>





int main()

{

	char s[100005];

	int a[100005] = {0}, i=0, bsr,bsl, len;

	scanf("%s", s);

	len = strlen(s);

	while (i < len-1)

	{

		for (bsr=0; (bsr+i) < len-1; bsr++)/*寻找RL字符串*/

		{

			if ((s[i + bsr] == 'R') && (s[i + bsr + 1] == 'L'))

			{

				if (bsr % 2 == 0)

				{

					a[i + bsr] += (bsr / 2 + 1); a[i + bsr + 1] += bsr / 2;

				}

				else

				{

					a[i + bsr] += ((bsr + 1) / 2); a[i + bsr + 1] += ((bsr + 1) / 2);

				}

				for (bsl = 1; (i + bsr + bsl) < len; bsl++)

				{

					if (s[i + bsr + bsl] == 'R')

					{

						bsl--;

						break;

					}

					if ((i + bsr + bsl) == (len - 1))

						break;

				}

				if (bsl % 2 == 1)

				{

					a[i + bsr] += bsl / 2; a[i + bsr + 1] += (bsl / 2 + 1);

				}

				else

				{

					a[i + bsr] += bsl / 2; a[i + bsr + 1] += bsl / 2;

				}

				i = i + bsr + bsl + 1;

				break;

			}

		}

	}

	for (i = 0; i < len-1; i++)

		printf("%d ", a[i]);

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

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <bits/stdc++.h>



using namespace std;

#define ll long long

const int N=2e5+5;

int ans[N];

int main()

{

    ios_base::sync_with_stdio(0);

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

    string s;

    cin>>s;

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

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

    {

        int e=0,o=0;

        while(s[i]=='R')

        {

            if(i%2==0) e++;

            else o++;

            i++;

        }

        int x=i-1;

        while(s[i]=='L')

        {

            if(i%2==0) e++;

            else o++;

            i++;

        }

        if(x%2==0)

        {

            ans[x]=e;

            ans[x+1]=o;

        }

        else

        {

            ans[x]=o;

            ans[x+1]=e;

        }

    }

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

    {

        if(i) cout<<" ";

        cout<<ans[i];

    }

    return 0;

}


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

#include<string.h>





int main()

{

	char s[100005];

	int a[100005] = {0}, i=0, bsr,bsl, len;

	scanf("%s", s);

	len = strlen(s);

	while (i < len-1)

	{

		for (bsr=0; (bsr+i) < len-1; bsr++)/*寻找RL字符串*/

		{

			if ((s[i + bsr] == 'R') && (s[i + bsr + 1] == 'L'))

			{

				if (bsr % 2 == 0)

				{

					a[i + bsr] += (bsr / 2 + 1); a[i + bsr + 1] += bsr / 2;

				}

				else

				{

					a[i + bsr] += ((bsr + 1) / 2); a[i + bsr + 1] += ((bsr + 1) / 2);

				}

				for (bsl = 1; (i + bsr + bsl) < len; bsl++)

				{

					if (s[i + bsr + bsl] == 'R')

					{

						bsl--;

						break;

					}

					if ((i + bsr + bsl) == (len - 1))

						break;

				}

				if (bsl % 2 == 1)

				{

					a[i + bsr] += bsl / 2; a[i + bsr + 1] += (bsl / 2 + 1);

				}

				else

				{

					a[i + bsr] += bsl / 2; a[i + bsr + 1] += bsl / 2;

				}

				i = i + bsr + bsl + 1;

				break;

			}

		}

	}

	for (i = 0; i < len-1; i++)

		printf("%d ", a[i]);

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

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <iostream>

#include<algorithm>

#include<string>

using namespace std;

string s;

int a[100000];

int ans[100000];

int main()

{

    cin>>s;

    int N=s.length();

    int count_r=0,count_l=0;

    int pos_r;

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

        while(s.at(i)=='R'){

            ++count_r;++i;

        }

        pos_r=i-1;

        while(i<N&&s.at(i)=='L'){

            ++count_l;++i;

        }

        ans[pos_r]=(count_r+count_l)/2;

        ans[pos_r+1]=count_r+count_l-ans[pos_r];

        if(count_r%2!=0)swap(ans[pos_r],ans[pos_r+1]);

        count_r=0;count_l=0;

    }

    for(int i=0;i<N;++i)cout<<ans[i]<<' ';

    return 0;

}

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

#include<string.h>





int main()

{

	char s[100005];

	int a[100005] = {0}, i=0, bsr,bsl, len;

	scanf("%s", s);

	len = strlen(s);

	while (i < len-1)

	{

		for (bsr=0; (bsr+i) < len-1; bsr++)/*寻找RL字符串*/

		{

			if ((s[i + bsr] == 'R') && (s[i + bsr + 1] == 'L'))

			{

				if (bsr % 2 == 0)

				{

					a[i + bsr] += (bsr / 2 + 1); a[i + bsr + 1] += bsr / 2;

				}

				else

				{

					a[i + bsr] += ((bsr + 1) / 2); a[i + bsr + 1] += ((bsr + 1) / 2);

				}

				for (bsl = 1; (i + bsr + bsl) < len; bsl++)

				{

					if (s[i + bsr + bsl] == 'R')

					{

						bsl--;

						break;

					}

					if ((i + bsr + bsl) == (len - 1))

						break;

				}

				if (bsl % 2 == 1)

				{

					a[i + bsr] += bsl / 2; a[i + bsr + 1] += (bsl / 2 + 1);

				}

				else

				{

					a[i + bsr] += bsl / 2; a[i + bsr + 1] += bsl / 2;

				}

				i = i + bsr + bsl + 1;

				break;

			}

		}

	}

	for (i = 0; i < len-1; i++)

		printf("%d ", a[i]);

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

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <bits/stdc++.h>

using namespace std;

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

using ll = long long;

using P = pair<int, int>;

using namespace std;



int dist[101010];

vector<int> G[101010];



int solve(int v) {

    int u = G[v][0];

    if (G[u][0] == v) {

        // 戻ってきたら

        dist[u] = dist[v] = 0;

        return 0;

    }

    dist[v] = solve(u) + 1;

    return dist[v];

}



int main() {

    string s;

    cin >> s;



    rep(i, s.size()) {

        if (s[i] == 'L') G[i].push_back(i-1);

        else G[i].push_back(i+1);

    }



    rep(i, s.size()) dist[i] = -1;



    rep(i, s.size()) {

        if (dist[i] == -1) {

            if (s[i] == 'L' and i+1<s.size() and s[i+1] == 'L') continue;

            solve(i);

        }

    }



    vector<int> ans(s.size(), 0);



    rep(i, s.size()) {

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

            if (dist[i]%2 == 0) ans[i + dist[i]]++;

            else ans[i + dist[i] + 1]++;

        }

        else {

            if (dist[i]%2 == 0) ans[i - dist[i]]++;

            else ans[i - dist[i] - 1]++;

        }

    }



    rep(i, s.size()) {

        if (i) cout << " ";

        cout << ans[i];

    }

    cout << endl;





}


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

using namespace std;

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

using ll = long long;

using P = pair<int, int>;

using namespace std;



int main() {

    string s;

    vector<pair<int, int>> d;

    cin >> s;

    char ch = s[0];

    int cnt = 1;

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

        if (ch == s[i]) {

            cnt++;

        }

        else {

            d.emplace_back(cnt, ch);

            cnt = 1;

            ch = s[i];

        }

    }

    d.emplace_back(cnt, ch);



    vector<int> ans(s.size(), 0);

    int cur = 0;

    rep(i, d.size()) {

        int cnt = d[i].first;

        char ch = d[i].second;

        rep(x, cnt) {

            if (ch == 'R') {

                if (x%2 == 0) ans[cur + cnt - 1]++;

                else ans[cur + cnt]++;

            }

            else {

                if (x%2 == 0) ans[cur]++;

                else ans[cur-1]++;

            }

        }

        cur += cnt;

    }



    rep(i, s.size()) cout << ans[i] << " ";

    cout << endl;

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
/*

author：cmathpo8&&yuanchen&&qiyujun

date:2019/8/17 10:11 

*/

#include<bits/stdc++.h>

#define re register

using namespace std;

int h[100010],t,cnt;

char a[100010];

struct node{

    int fro;

    int to;

}el[100010];

int main(){

       scanf("%s",a+1);

       int cntl=0;

       int sst=strlen(a+1);

       memset(h,0,sizeof(h));

       t=-1;

    for(re int i=1;i<=sst;i++){

        if(a[i]=='L'){

            if(t==-1){

                el[++cnt].fro=i;

                el[cnt].to=i;

                t=0;

            }else el[cnt].to=i;

        }else t=-1;

    } 

    el[0].to=0;

    for(re int i=1;i<=cnt;i++){

        int dis=(el[i].fro-el[i-1].to-1);

        int disl=(el[i].to-el[i].fro+1);

        if(dis%2==1){

            h[el[i].fro]+=(dis/2);

            h[el[i].fro-1]+=(dis/2)+1;

        }else{

            h[el[i].fro]+=(dis/2);

            h[el[i].fro-1]+=(dis/2);

        }

        if(disl%2==1){

            h[el[i].fro-1]+=(disl/2);

            h[el[i].fro]+=(disl/2)+1;

        }else{

            h[el[i].fro-1]+=(disl/2);

            h[el[i].fro]+=(disl/2);

        }

    }

    for(re int i=1;i<=sst;i++){

        printf("%d ",h[i]);

    } 

    /*for(re int i=1;i<=cnt;i++){

        cout<<el[i].fro<<" "<<el[i].to<<" ";

    }*/

    return 0;

}

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

using namespace std;

const int N = 100010;

char s[N];

int idxR[N], idxL[N], addup[N];

typedef pair<int, char> PII;

stack<PII> stk;

int main() {

	cin >> s;

	for (int i = 0; s[i]; i ++) {

		if (s[i] == 'R') stk.push({i, s[i]});

		else {

			while(stk.size()) {

				auto t = stk.top();

				idxR[t.first] = i - t.first;

				stk.pop();

			}

		}

	}

	int len = strlen(s);

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

		if (s[i] == 'L') stk.push({i, s[i]});

		else {

			while(stk.size()) {

				auto t = stk.top();

				idxL[t.first] = t.first - i;

				stk.pop();

			}

		}

	}



	for (int i = 0; s[i]; i ++) {

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

			if (idxR[i] % 2 == 0) addup[i + idxR[i]] ++;

			else addup[i + idxR[i] - 1] ++;

		}

		else {

			if (idxL[i] % 2 == 0) addup[i - idxL[i]] ++;

			else addup[i - idxL[i] + 1] ++;

		}

	}

	

	for (int i = 0; i < len; i ++) cout << addup[i] << " ";

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <bits/stdc++.h>

#include <vector>

#include <list>

#include <map>

#include <set>

#include <deque>

#include <stack>

#include <bitset>

#include <algorithm>

#include <functional>

#include <numeric>

#include <utility>

#include <sstream>

#include <iostream>

#include <iomanip>

#include <cstdio>

#include <cmath>

#include <cstdlib>

#include <ctime>

#include <memory.h>



using namespace std;

int main()

{

    long long n,m,a,b,c;



    cin>>n>>m;

if(n==m){

cout<<0;

return 0;

}

if(abs(m)==abs(n))

{

cout<<1;

 return 0;

}

if(n>m&&n<0&&m<0)

{

    n=n*-1;

    b=m*-1;

    cout<<b-n+2;

    return 0;

}

if(n>m&&n>=0&&m<=0 && n>abs(m))

{

    n=n*-1;

    cout<<m-n+1;

    return 0;

}

if(n>m&&n>=0&&m<=0 && n<abs(m))

{

    n=n*-1;

    cout<<abs(m)+n+1;

    return 0;

}

if(n==0 && m>0)

{

    cout<<m-n;

    return 0;

}

if(n<m && m>=0 && n<=0 && abs(n)<m )

{

    n=n*-1;

    cout<<m-n+1;

    return 0;

}

if(n<m && (n>=0 &&m>=0)|| (m<=0 && n<=0))

{

    cout<<m-n;

    return 0;

}

if(n<=0&&m>=0&&abs(n)>m)

{

    m=m*-1;

    cout<<m-n+1;

    return 0;

}

    if(n>m&&n>0&&m>0)//---------------------//

{

    n=n*-1;

    m=m*-1;

    cout<<m-n+2;

    return 0;

}



}


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

#include<cmath>

using namespace std;

int main(){

	long long x,y,a=0,b=0;

	bool flag;

	scanf("%lld %lld",&x,&y);

	if(abs(x)>abs(y))

	a=abs(x)-abs(y),flag=false;

	else

	a=abs(y)-abs(x),flag=true;

	if(x>=0&&flag){

		if(y<0)

		++b;

		printf("%lld",a+b);

		return 0;

	}

	if(x<0&&flag){

		if(y>0)

		++b;

		else 

		b+=2;

		printf("%lld",a+b);

		return 0;

	}

	if(x>=0){

		if(y>0)

		b+=2;

		else

		++b;

		printf("%lld",a+b);

		return 0;

	}

	if(x<0){

		if(y>0)

		++b;

		printf("%lld",a+b);

		return 0;

	}

	return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <bits/stdc++.h>



using namespace std;



#define MAX 505

#define ll long long

#define pb push_back

#define mk make_pair

#define sc second

#define fr first

#define pii pair < int, int >



const int N = (int)1e4 + 5;

const int INF = (int)1e9 + 7;



int main () {

        long long x, y; cin >> x >> y;

        if (x > 0 && y > 0) { // + +

                if (y > x) {

                        cout << y - x;

                } else if (y < x) {

                        cout << x - y + 2;

                }

        } else {

                if (x < 0 && y > 0) {

                        cout << abs(abs(y) - abs(x)) + 1;

                } else if (x > 0 && y < 0) {

                        cout << abs(abs(y) - abs(x)) + 1;

                } else if (x < 0 && y < 0) { // - -

                        if (abs(x) > abs(y)) {

                                cout << abs(x) - abs(y);

                        } else if (abs(x) < abs(y)) {

                                cout << abs(y) - abs(x) + 2;

                        }

                } else if (x == 0 || y == 0) {

                        if (x == 0) {

                                if (y < 0) {

                                        cout << abs(y) + 1;

                                } else if (y > 0) {

                                        cout << abs(y);

                                }

                        } else {

                                if (x < 0) {

                                        cout << abs(x);

                                } else {

                                        cout << x + 1;

                                }

                        }

                }

        }

        cout << endl;

}


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

#include<cmath>

using namespace std;

int main(){

	long long x,y,a=0,b=0;

	bool flag;

	scanf("%lld %lld",&x,&y);

	if(abs(x)>abs(y))

	a=abs(x)-abs(y),flag=false;

	else

	a=abs(y)-abs(x),flag=true;

	if(x>=0&&flag){

		if(y<0)

		++b;

		printf("%lld",a+b);

		return 0;

	}

	if(x<0&&flag){

		if(y>0)

		++b;

		else 

		b+=2;

		printf("%lld",a+b);

		return 0;

	}

	if(x>=0){

		if(y>0)

		b+=2;

		else

		++b;

		printf("%lld",a+b);

		return 0;

	}

	if(x<0){

		if(y>0)

		++b;

		printf("%lld",a+b);

		return 0;

	}

	return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
# include <bits/stdc++.h>

# define fr first

# define sc second

# define mk make_pair

# define pb push_back

# define ll long long



using namespace std;





main()

{

     long long a,b,c=0,h;

     cin>>a>>b;

     if (a==b){

        cout<<0;

        return 0;

     }

     if (a==0)

     {

         if (b>a)

         {

             cout<<abs(b-a);

             return 0;

         }

         else if (a>b)

         {

             cout<<abs(b-a)+1;

             return 0;

         }

     }

     if (b==0&&a<0)

     {

         cout<<abs(a-b);

         return 0;

     }

     if (a==-b){

       cout<<1;

       return 0;

     }

         if (a<=0&&b<=0){

         if (a>b){

         a=-a;

         c++;

         }

        while (a!=b){

            a++;

         c++;

        if (-a==b){

                c++;

            a=-a;

        break;

        }

        }

        cout<<c;

        return 0;

     }

     if (b>a&&a>=0&&b>=0&&-a!=b)

     {

         cout<<b-a;

         return 0;

     }

     if ((b>a&&b<=0||a<=0&&b>a)){

        c+=abs(abs(a)-abs(b))+1;

        cout<<c;

        return 0;

     }

     if (a>b&&b<=0&&a>=0)

     {

         cout<<abs(abs(a)-abs(b))+1;

         return 0;

     }

    if (a>b)

    {

        a=-a;

        c++;

        while (a!=b){

            c++;

            a++;

            if (-a==b){

                a=-a;

            c++;

            }

        }

        cout<<c;

        return 0;

    }

     /*if (a>b)

     {

         a=-a;

         while (a!=b)

         {

             if (abs(-a-abs(b))<=abs(a+1-abs(b))||a==-b){

                a=-a;

                c++;

             }

               if (a==b)

             {

                 break;

             }

             if (-(a+(abs(abs(a)-abs(b))))==b&&a>0)

             {

                 c+=(abs(abs(a)-abs(b)))+1;

                 a=-(a+(abs(abs(a)-abs(b))));

             }

       if (a==b)

             {

                 break;

             }

             if (abs(-a-abs(b))>=abs(a+1-abs(b))||-a>b){

                a++;

                c++;

             }

         }

         cout<<c+1;

         return 0;

     }

*/

}


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

#include<cmath>

using namespace std;

int main(){

	long long x,y,a=0,b=0;

	bool flag;

	scanf("%lld %lld",&x,&y);

	if(abs(x)>abs(y))

	a=abs(x)-abs(y),flag=false;

	else

	a=abs(y)-abs(x),flag=true;

	if(x>=0&&flag){

		if(y<0)

		++b;

		printf("%lld",a+b);

		return 0;

	}

	if(x<0&&flag){

		if(y>0)

		++b;

		else 

		b+=2;

		printf("%lld",a+b);

		return 0;

	}

	if(x>=0){

		if(y>0)

		b+=2;

		else

		++b;

		printf("%lld",a+b);

		return 0;

	}

	if(x<0){

		if(y>0)

		++b;

		printf("%lld",a+b);

		return 0;

	}

	return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<bits/stdc++.h>

using namespace std;



int main(){

	int x,y,n,a,b;

	cin >> x >> y;

	if(y>0){

		if(x>0){

			if(y==x){

				cout << 0;

			}

			else if(y>x){

				cout << y - x;

			}

			else {

				cout << x - y + 2;

			}

		}

		else if(x==0){

			cout << y;

		}

		else {

			// x<0 and y>0

			// x=-3 and y=3, x=-2 and y=4, x=-4 and y=2 

			if(abs(y)==abs(x)){

				cout << 1;

			}

			else 

				cout << abs(abs(y) - abs(x)) + 1;

		}

	}

	else if(y==0){

		if(x>0){

			cout << x + 1;

		}

		else if(x==0) cout << 0;

		else {

			cout << -x;

		}

	}

	else {

		// y<0

		if(x>0){

			// y<0 and x>0

			// x=2 and y=-2, x=4 and y=-2, x=2 and y=-4

			if(abs(y)==abs(x)) cout << 1;

			else cout << abs(abs(x) - abs(y)) + 1;

		}

		else if(x==0) cout << abs(y) + 1;

		else {

			// y<0 and x<0

			// x=-2 and y=-2, x=-4 and y=-2, x=-2 and y=-4

			if(y==x) cout << 0;

			else if(abs(x)>abs(y)) cout << abs(x) - abs(y);

			else cout << abs(y) - abs(x) + 2;

		}

	}

	return 0;

}


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

#include<cmath>

using namespace std;

int main(){

	long long x,y,a=0,b=0;

	bool flag;

	scanf("%lld %lld",&x,&y);

	if(abs(x)>abs(y))

	a=abs(x)-abs(y),flag=false;

	else

	a=abs(y)-abs(x),flag=true;

	if(x>=0&&flag){

		if(y<0)

		++b;

		printf("%lld",a+b);

		return 0;

	}

	if(x<0&&flag){

		if(y>0)

		++b;

		else 

		b+=2;

		printf("%lld",a+b);

		return 0;

	}

	if(x>=0){

		if(y>0)

		b+=2;

		else

		++b;

		printf("%lld",a+b);

		return 0;

	}

	if(x<0){

		if(y>0)

		++b;

		printf("%lld",a+b);

		return 0;

	}

	return 0;

}

// Fastest known solution for this problem: