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

#include <queue>

#include <cstring>

#include <iostream>

#include <algorithm>

using namespace std;

int vis[110][110][110];

struct node

{

	int a,b,c,s;

	node (int aa,int bb,int cc,int ss):a(aa),b(bb),c(cc),s(ss){}

};

int bfs(int a,int b,int c)

{

	queue<node>q;

	q.push(node(a,b,c,0));

	while(!q.empty())

	{

		node t=q.front();

		q.pop();

		if(t.a==t.b&&t.b==t.c)

			return t.s;

		int x,y,z;

		x=t.a+2;y=t.b;z=t.c;

		if(x<110&&y<110&&z<110&&vis[x][y][z]==0)

		{

			q.push(node(x,y,z,t.s+1));

			vis[x][y][z]=1;

		}

		x=t.a;y=t.b+2;z=t.c;	

		if(x<110&&y<110&&z<110&&vis[x][y][z]==0)

		{

			q.push(node(x,y,z,t.s+1));

			vis[x][y][z]=1;

		}

		x=t.a;y=t.b;z=t.c+2;

		if(x<110&&y<110&&z<110&&vis[x][y][z]==0)

		{

			q.push(node(x,y,z,t.s+1));

			vis[x][y][z]=1;

		}if(x<110&&y<110&&z<110&&vis[x][y][z]==0)

		{

			q.push(node(x,y,z,t.s+1));

			vis[x][y][z]=1;

		}	

		x=t.a+1;y=t.b+1;z=t.c;

		if(x<110&&y<110&&z<110&&vis[x][y][z]==0)

		{

			q.push(node(x,y,z,t.s+1));

			vis[x][y][z]=1;

		}

		x=t.a;y=t.b+1;z=t.c+1;

		if(x<110&&y<110&&z<110&&vis[x][y][z]==0)

		{

			q.push(node(x,y,z,t.s+1));

			vis[x][y][z]=1;

		}

		x=t.a+1;y=t.b;z=t.c+1;

		if(x<110&&y<110&&z<110&&vis[x][y][z]==0)

		{

			q.push(node(x,y,z,t.s+1));

			vis[x][y][z]=1;

		}		

	}

	return -1;

}

int main()

{

	int x,y,z,ans;

	cin>>x>>y>>z;

	memset(vis,0,sizeof(vis));

	vis[x][y][z]=1;

	ans=bfs(x,y,z);

	cout<<ans<<endl;

	return 0;

}

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

using namespace std;



int a[3];



int main ()

{

	cin >> a[0] >> a[1] >> a[2];

	sort (a + 0, a + 2 + 1);

	int ans = 0;

//	cout << a[0] << endl << a[1] << endl << a[2] << endl;

	ans += a[2] - a[1];

	int k = (a[1] - a[0]) / 2;

	if (a[0] + k * 2 < a[1])

		++k;

//	cout << k << endl;

	ans += k;

	ans += a[0] + k * 2 - a[1];

	cout << ans;

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

#include <queue>

#include <cstring>

#include <iostream>

#include <algorithm>

using namespace std;

int vis[110][110][110];

struct node

{

	int a,b,c,s;

	node (int aa,int bb,int cc,int ss):a(aa),b(bb),c(cc),s(ss){}

};

int bfs(int a,int b,int c)

{

	queue<node>q;

	q.push(node(a,b,c,0));

	while(!q.empty())

	{

		node t=q.front();

		q.pop();

		if(t.a==t.b&&t.b==t.c)

			return t.s;

		int x,y,z;

		x=t.a+2;y=t.b;z=t.c;

		if(x<110&&y<110&&z<110&&vis[x][y][z]==0)

		{

			q.push(node(x,y,z,t.s+1));

			vis[x][y][z]=1;

		}

		x=t.a;y=t.b+2;z=t.c;	

		if(x<110&&y<110&&z<110&&vis[x][y][z]==0)

		{

			q.push(node(x,y,z,t.s+1));

			vis[x][y][z]=1;

		}

		x=t.a;y=t.b;z=t.c+2;

		if(x<110&&y<110&&z<110&&vis[x][y][z]==0)

		{

			q.push(node(x,y,z,t.s+1));

			vis[x][y][z]=1;

		}if(x<110&&y<110&&z<110&&vis[x][y][z]==0)

		{

			q.push(node(x,y,z,t.s+1));

			vis[x][y][z]=1;

		}	

		x=t.a+1;y=t.b+1;z=t.c;

		if(x<110&&y<110&&z<110&&vis[x][y][z]==0)

		{

			q.push(node(x,y,z,t.s+1));

			vis[x][y][z]=1;

		}

		x=t.a;y=t.b+1;z=t.c+1;

		if(x<110&&y<110&&z<110&&vis[x][y][z]==0)

		{

			q.push(node(x,y,z,t.s+1));

			vis[x][y][z]=1;

		}

		x=t.a+1;y=t.b;z=t.c+1;

		if(x<110&&y<110&&z<110&&vis[x][y][z]==0)

		{

			q.push(node(x,y,z,t.s+1));

			vis[x][y][z]=1;

		}		

	}

	return -1;

}

int main()

{

	int x,y,z,ans;

	cin>>x>>y>>z;

	memset(vis,0,sizeof(vis));

	vis[x][y][z]=1;

	ans=bfs(x,y,z);

	cout<<ans<<endl;

	return 0;

}

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

using namespace std;

#include <set>

#include <algorithm>



int a[4];

int main()

{

	cin >> a[1] >> a[2] >>a[3];

	

	sort(a+1,a+4);

	

	int cnt = 0;

	while(1)

	{

		int a31 = a[3] - a[1];

		int a32 = a[3] - a[2];

		

//		cout << a31 << " " << a32 << endl;

//		system("pause");

		

		if(a32>=1&&a31>=1)

		{

			a[2]++;

			a[1]++;

			cnt++;

		}

		else

		{

			if(a32==1&&a31>2)

			{

				a[1]+=2;

				cnt++;

			}

			else if(a32==1&&a31==1)

			{

				cnt++;

				cout << cnt << endl;

				return 0;

			}

			else if(a32==1&&a31==2)

			{

				cnt+=3;

				cout << cnt << endl;

				return 0;

			}

			else if(a32==0&&a31==1)

			{

				cnt+=2;

				cout << cnt << endl;

				return 0;

			}

			else if(a32==0&&a31==2)

			{

				cnt++;

				cout << cnt << endl;

				return 0;

			}

			else if(a32==0&&a31>2)

			{

				a[1]+=2;

				cnt++;

			}

			else if(a32==0&&a31==0)

			{

				cout << cnt << endl;

				return 0;

			}

		}

	}

	return 0;

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

#include <queue>

#include <cstring>

#include <iostream>

#include <algorithm>

using namespace std;

int vis[110][110][110];

struct node

{

	int a,b,c,s;

	node (int aa,int bb,int cc,int ss):a(aa),b(bb),c(cc),s(ss){}

};

int bfs(int a,int b,int c)

{

	queue<node>q;

	q.push(node(a,b,c,0));

	while(!q.empty())

	{

		node t=q.front();

		q.pop();

		if(t.a==t.b&&t.b==t.c)

			return t.s;

		int x,y,z;

		x=t.a+2;y=t.b;z=t.c;

		if(x<110&&y<110&&z<110&&vis[x][y][z]==0)

		{

			q.push(node(x,y,z,t.s+1));

			vis[x][y][z]=1;

		}

		x=t.a;y=t.b+2;z=t.c;	

		if(x<110&&y<110&&z<110&&vis[x][y][z]==0)

		{

			q.push(node(x,y,z,t.s+1));

			vis[x][y][z]=1;

		}

		x=t.a;y=t.b;z=t.c+2;

		if(x<110&&y<110&&z<110&&vis[x][y][z]==0)

		{

			q.push(node(x,y,z,t.s+1));

			vis[x][y][z]=1;

		}if(x<110&&y<110&&z<110&&vis[x][y][z]==0)

		{

			q.push(node(x,y,z,t.s+1));

			vis[x][y][z]=1;

		}	

		x=t.a+1;y=t.b+1;z=t.c;

		if(x<110&&y<110&&z<110&&vis[x][y][z]==0)

		{

			q.push(node(x,y,z,t.s+1));

			vis[x][y][z]=1;

		}

		x=t.a;y=t.b+1;z=t.c+1;

		if(x<110&&y<110&&z<110&&vis[x][y][z]==0)

		{

			q.push(node(x,y,z,t.s+1));

			vis[x][y][z]=1;

		}

		x=t.a+1;y=t.b;z=t.c+1;

		if(x<110&&y<110&&z<110&&vis[x][y][z]==0)

		{

			q.push(node(x,y,z,t.s+1));

			vis[x][y][z]=1;

		}		

	}

	return -1;

}

int main()

{

	int x,y,z,ans;

	cin>>x>>y>>z;

	memset(vis,0,sizeof(vis));

	vis[x][y][z]=1;

	ans=bfs(x,y,z);

	cout<<ans<<endl;

	return 0;

}

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

#include<stdio.h>

#include<cstring>

#include<cmath>

#include<algorithm>

#include<vector>

#include<map>

#include<set>

#include<queue>

#define ll long long

using namespace std;

int pos(int n)

{

    if(n<0)

        return 0;

    else

        return n;

}

bool pali(ll n)

{

    char a[10000]= {0};

    int num=0,tn=n;

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

    {

        a[i]=n%10;

        n/=10;

        num=i;

        if(n<=0)

            break;



    }

    for(int i=0; i<num/2; i++)

    {

        if(a[i]!=a[num-i])

        {

            return false;

        }

    }

    return true;

}

int main()

{

    ll a[3];

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

    {

        cin>>a[i];

    }

    sort(a,a+3);

    int t1=a[2]-a[0],t2=a[2]-a[1];

    int num=0;

    num+=t2;

    t1-=t2;

    if(t1%2==1)

        num+=2;

    num+=t1/2;

    cout<<num;

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

#include <queue>

#include <cstring>

#include <iostream>

#include <algorithm>

using namespace std;

int vis[110][110][110];

struct node

{

	int a,b,c,s;

	node (int aa,int bb,int cc,int ss):a(aa),b(bb),c(cc),s(ss){}

};

int bfs(int a,int b,int c)

{

	queue<node>q;

	q.push(node(a,b,c,0));

	while(!q.empty())

	{

		node t=q.front();

		q.pop();

		if(t.a==t.b&&t.b==t.c)

			return t.s;

		int x,y,z;

		x=t.a+2;y=t.b;z=t.c;

		if(x<110&&y<110&&z<110&&vis[x][y][z]==0)

		{

			q.push(node(x,y,z,t.s+1));

			vis[x][y][z]=1;

		}

		x=t.a;y=t.b+2;z=t.c;	

		if(x<110&&y<110&&z<110&&vis[x][y][z]==0)

		{

			q.push(node(x,y,z,t.s+1));

			vis[x][y][z]=1;

		}

		x=t.a;y=t.b;z=t.c+2;

		if(x<110&&y<110&&z<110&&vis[x][y][z]==0)

		{

			q.push(node(x,y,z,t.s+1));

			vis[x][y][z]=1;

		}if(x<110&&y<110&&z<110&&vis[x][y][z]==0)

		{

			q.push(node(x,y,z,t.s+1));

			vis[x][y][z]=1;

		}	

		x=t.a+1;y=t.b+1;z=t.c;

		if(x<110&&y<110&&z<110&&vis[x][y][z]==0)

		{

			q.push(node(x,y,z,t.s+1));

			vis[x][y][z]=1;

		}

		x=t.a;y=t.b+1;z=t.c+1;

		if(x<110&&y<110&&z<110&&vis[x][y][z]==0)

		{

			q.push(node(x,y,z,t.s+1));

			vis[x][y][z]=1;

		}

		x=t.a+1;y=t.b;z=t.c+1;

		if(x<110&&y<110&&z<110&&vis[x][y][z]==0)

		{

			q.push(node(x,y,z,t.s+1));

			vis[x][y][z]=1;

		}		

	}

	return -1;

}

int main()

{

	int x,y,z,ans;

	cin>>x>>y>>z;

	memset(vis,0,sizeof(vis));

	vis[x][y][z]=1;

	ans=bfs(x,y,z);

	cout<<ans<<endl;

	return 0;

}

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

#include<stack>

#include<map>

#include<set>

#include<queue>

#include<cstring>

#include<cmath>

#include<vector>

#include<algorithm>

using namespace std;

typedef long long ll;

#define me(a,b) memset(a,b,sizeof(a))

#define inf 0x3f3f3f3f

const int N=500005;

int main()

{

	int t,i,j,m,n,x,y,z,a[4],b,sum=0,c;

	cin>>a[1]>>a[2]>>a[3];

	sort(a+1,a+1+3);

	x=a[3]-a[1];

	y=a[3]-a[2];

	

	sum+=y;

	x-=y;

	if(x%2)

	{x+=1;

		sum+=x/2;

		sum+=1;

	}

	else 

	{

		sum+=x/2;

	}

	cout<<sum;

	return 0; 

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

#include <queue>

#include <cstring>

#include <iostream>

#include <algorithm>

using namespace std;

int vis[110][110][110];

struct node

{

	int a,b,c,s;

	node (int aa,int bb,int cc,int ss):a(aa),b(bb),c(cc),s(ss){}

};

int bfs(int a,int b,int c)

{

	queue<node>q;

	q.push(node(a,b,c,0));

	while(!q.empty())

	{

		node t=q.front();

		q.pop();

		if(t.a==t.b&&t.b==t.c)

			return t.s;

		int x,y,z;

		x=t.a+2;y=t.b;z=t.c;

		if(x<110&&y<110&&z<110&&vis[x][y][z]==0)

		{

			q.push(node(x,y,z,t.s+1));

			vis[x][y][z]=1;

		}

		x=t.a;y=t.b+2;z=t.c;	

		if(x<110&&y<110&&z<110&&vis[x][y][z]==0)

		{

			q.push(node(x,y,z,t.s+1));

			vis[x][y][z]=1;

		}

		x=t.a;y=t.b;z=t.c+2;

		if(x<110&&y<110&&z<110&&vis[x][y][z]==0)

		{

			q.push(node(x,y,z,t.s+1));

			vis[x][y][z]=1;

		}if(x<110&&y<110&&z<110&&vis[x][y][z]==0)

		{

			q.push(node(x,y,z,t.s+1));

			vis[x][y][z]=1;

		}	

		x=t.a+1;y=t.b+1;z=t.c;

		if(x<110&&y<110&&z<110&&vis[x][y][z]==0)

		{

			q.push(node(x,y,z,t.s+1));

			vis[x][y][z]=1;

		}

		x=t.a;y=t.b+1;z=t.c+1;

		if(x<110&&y<110&&z<110&&vis[x][y][z]==0)

		{

			q.push(node(x,y,z,t.s+1));

			vis[x][y][z]=1;

		}

		x=t.a+1;y=t.b;z=t.c+1;

		if(x<110&&y<110&&z<110&&vis[x][y][z]==0)

		{

			q.push(node(x,y,z,t.s+1));

			vis[x][y][z]=1;

		}		

	}

	return -1;

}

int main()

{

	int x,y,z,ans;

	cin>>x>>y>>z;

	memset(vis,0,sizeof(vis));

	vis[x][y][z]=1;

	ans=bfs(x,y,z);

	cout<<ans<<endl;

	return 0;

}

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

using namespace std;

int main()

{

	int a,b,c,ans=0,p;

	cin>>a>>b>>c;

	if(a==b&&b==c){

		cout<<0;

		return 0;

	}

	while(1){

		if(a%2==b%2&&b%2==c%2){

			p=min(a,min(b,c));

			if(a==p){

				a+=2;

			}

			else if(b==p){

				b+=2;

			}

			else{

				c+=2;

			}

			ans++;

		}

		else if(a%2!=b%2&&a%2!=c%2){

			b++;

			c++;

			ans++;

		}

		else if(b%2!=a%2&&b%2!=c%2){

			a++;

			c++;

			ans++;

		}

		else if(c%2!=a%2&&c%2!=b%2){

			a++;

			b++;

			ans++;

		}

		if(a==b&&b==c){

			break;

		}

	}

	cout<<ans;

	return 0;

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

#include <queue>

#include <cstring>

#include <iostream>

#include <algorithm>

using namespace std;

int vis[110][110][110];

struct node

{

	int a,b,c,s;

	node (int aa,int bb,int cc,int ss):a(aa),b(bb),c(cc),s(ss){}

};

int bfs(int a,int b,int c)

{

	queue<node>q;

	q.push(node(a,b,c,0));

	while(!q.empty())

	{

		node t=q.front();

		q.pop();

		if(t.a==t.b&&t.b==t.c)

			return t.s;

		int x,y,z;

		x=t.a+2;y=t.b;z=t.c;

		if(x<110&&y<110&&z<110&&vis[x][y][z]==0)

		{

			q.push(node(x,y,z,t.s+1));

			vis[x][y][z]=1;

		}

		x=t.a;y=t.b+2;z=t.c;	

		if(x<110&&y<110&&z<110&&vis[x][y][z]==0)

		{

			q.push(node(x,y,z,t.s+1));

			vis[x][y][z]=1;

		}

		x=t.a;y=t.b;z=t.c+2;

		if(x<110&&y<110&&z<110&&vis[x][y][z]==0)

		{

			q.push(node(x,y,z,t.s+1));

			vis[x][y][z]=1;

		}if(x<110&&y<110&&z<110&&vis[x][y][z]==0)

		{

			q.push(node(x,y,z,t.s+1));

			vis[x][y][z]=1;

		}	

		x=t.a+1;y=t.b+1;z=t.c;

		if(x<110&&y<110&&z<110&&vis[x][y][z]==0)

		{

			q.push(node(x,y,z,t.s+1));

			vis[x][y][z]=1;

		}

		x=t.a;y=t.b+1;z=t.c+1;

		if(x<110&&y<110&&z<110&&vis[x][y][z]==0)

		{

			q.push(node(x,y,z,t.s+1));

			vis[x][y][z]=1;

		}

		x=t.a+1;y=t.b;z=t.c+1;

		if(x<110&&y<110&&z<110&&vis[x][y][z]==0)

		{

			q.push(node(x,y,z,t.s+1));

			vis[x][y][z]=1;

		}		

	}

	return -1;

}

int main()

{

	int x,y,z,ans;

	cin>>x>>y>>z;

	memset(vis,0,sizeof(vis));

	vis[x][y][z]=1;

	ans=bfs(x,y,z);

	cout<<ans<<endl;

	return 0;

}

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

using namespace std;

int main()

{

    int a[3],sum;

    cin>>a[0]>>a[1]>>a[2];

    sort(a,a+3);

    sum=2*a[2]-a[0]-a[1];

    if(sum%2==0)cout<<sum/2;

    else cout<<sum/2+2;

    return 0;

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

#include <queue>

#include <cstring>

#include <iostream>

#include <algorithm>

using namespace std;

int vis[110][110][110];

struct node

{

	int a,b,c,s;

	node (int aa,int bb,int cc,int ss):a(aa),b(bb),c(cc),s(ss){}

};

int bfs(int a,int b,int c)

{

	queue<node>q;

	q.push(node(a,b,c,0));

	while(!q.empty())

	{

		node t=q.front();

		q.pop();

		if(t.a==t.b&&t.b==t.c)

			return t.s;

		int x,y,z;

		x=t.a+2;y=t.b;z=t.c;

		if(x<110&&y<110&&z<110&&vis[x][y][z]==0)

		{

			q.push(node(x,y,z,t.s+1));

			vis[x][y][z]=1;

		}

		x=t.a;y=t.b+2;z=t.c;	

		if(x<110&&y<110&&z<110&&vis[x][y][z]==0)

		{

			q.push(node(x,y,z,t.s+1));

			vis[x][y][z]=1;

		}

		x=t.a;y=t.b;z=t.c+2;

		if(x<110&&y<110&&z<110&&vis[x][y][z]==0)

		{

			q.push(node(x,y,z,t.s+1));

			vis[x][y][z]=1;

		}if(x<110&&y<110&&z<110&&vis[x][y][z]==0)

		{

			q.push(node(x,y,z,t.s+1));

			vis[x][y][z]=1;

		}	

		x=t.a+1;y=t.b+1;z=t.c;

		if(x<110&&y<110&&z<110&&vis[x][y][z]==0)

		{

			q.push(node(x,y,z,t.s+1));

			vis[x][y][z]=1;

		}

		x=t.a;y=t.b+1;z=t.c+1;

		if(x<110&&y<110&&z<110&&vis[x][y][z]==0)

		{

			q.push(node(x,y,z,t.s+1));

			vis[x][y][z]=1;

		}

		x=t.a+1;y=t.b;z=t.c+1;

		if(x<110&&y<110&&z<110&&vis[x][y][z]==0)

		{

			q.push(node(x,y,z,t.s+1));

			vis[x][y][z]=1;

		}		

	}

	return -1;

}

int main()

{

	int x,y,z,ans;

	cin>>x>>y>>z;

	memset(vis,0,sizeof(vis));

	vis[x][y][z]=1;

	ans=bfs(x,y,z);

	cout<<ans<<endl;

	return 0;

}

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

using namespace std;

int s,a[4],x,y;

int main()

{

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

	{

		cin>>a[i];

		if(a[i]%2==0)y++;

		else x++;

	}

	sort(a+1,a+4);

	if(x==2)

	{

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

		{

			if(a[i]%2!=0)a[i]++;

		}s=1;

	}

	if(y==2)

	{

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

		{

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

		}s=1;

	}

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

	{

		s+=(a[3]-a[i])/2;

	}cout<<s;

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

using namespace std;

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



int main() {

    int A, B, C;

    cin >> A >> B >> C;

    int dp[55][55][55];

    fill(dp[0][0], dp[55][0], 1000);

    dp[A][B][C] = 0;

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

        for(int b = 0; b < 53; ++b) {

            for(int c = 0; c < 53; ++c) {

                int tmp = dp[a][b][c] + 1;

                chmin(dp[a][b + 1][c + 1], tmp);

                chmin(dp[a + 1][b][c + 1], tmp);

                chmin(dp[a + 1][b + 1][c], tmp);

                chmin(dp[a + 2][b][c], tmp);

                chmin(dp[a][b + 2][c], tmp);

                chmin(dp[a][b][c + 2], tmp);

            }

        }

    }

    int ans = 1000;

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

        chmin(ans, dp[i][i][i]);

    }

    cout << ans << '\n';

    return 0;

}


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

using namespace std;



int main() {

    vector<int> A(3);

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

        cin >> A[i];

    }

    int ans = 1000;

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

        int tmp = 0;

        bool ng = false;

        for(int j = 0; j < 3; ++j) {

            int dif = i - A[j];

            if(dif < 0) ng = true;

            tmp += dif;

        }

        if(tmp % 2 || ng) continue;

        ans = min(ans, tmp / 2);

    }

    cout << ans << '\n';

    return 0;

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

using namespace std;

typedef long long ll;

const int mod=1e9+7;

#define inf 0x3f3f3f3f

int a[15];



int main()

{

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

	cin>>a[i];

	sort(a,a+3);

	int x=a[0],y=a[1],z=a[2];

	int ans=0;

	while(x+2<=y)

	{

		ans++;

		x+=2;

	}

	if(x==y)

	ans+=z-y;

	else

	{

		if(z==y)

		{

			ans+=2;

		}

		else

		{

			ans+=z-y+2;

		}

	 } 

	cout<<ans;

	return 0;

}

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

#include<algorithm>

using namespace std;



int cnt=0;

int num[5];



int main() {

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

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

	sort(num,num+3);

	while(num[0]!=num[1]||num[1]!=num[2]) {

		cnt++;

		if(num[2]==num[1]) num[0]+=2;

		else num[0]++,num[1]++;

		sort(num,num+3);

	}

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

	return 0;

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

using namespace std;

typedef long long ll;

const int mod=1e9+7;

#define inf 0x3f3f3f3f

int a[15];



int main()

{

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

	cin>>a[i];

	sort(a,a+3);

	int x=a[0],y=a[1],z=a[2];

	int ans=0;

	while(x+2<=y)

	{

		ans++;

		x+=2;

	}

	if(x==y)

	ans+=z-y;

	else

	{

		if(z==y)

		{

			ans+=2;

		}

		else

		{

			ans+=z-y+2;

		}

	 } 

	cout<<ans;

	return 0;

}

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

#include<algorithm>

using namespace std;

int ans;

int main() {

	int a[4];

	scanf("%d%d%d",&a[1],&a[2],&a[3]);

	while(a[1]!=a[2]||a[2]!=a[3]||a[1]!=a[3]) {

		sort(a+1,a+4);

		ans++;

		if(a[2]-a[1]>=2) {

			a[1]+=2;

		}

		else {

			a[1]++;

			a[2]++;

		}

		

	}

	printf("%d",ans);

	return 0;

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

using namespace std;

typedef long long ll;

const int mod=1e9+7;

#define inf 0x3f3f3f3f

int a[15];



int main()

{

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

	cin>>a[i];

	sort(a,a+3);

	int x=a[0],y=a[1],z=a[2];

	int ans=0;

	while(x+2<=y)

	{

		ans++;

		x+=2;

	}

	if(x==y)

	ans+=z-y;

	else

	{

		if(z==y)

		{

			ans+=2;

		}

		else

		{

			ans+=z-y+2;

		}

	 } 

	cout<<ans;

	return 0;

}

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

#include<algorithm>

using namespace std;



int a[5],cnt;



int main()

{

	scanf("%d %d %d",&a[1],&a[2],&a[3]);

	sort(a+1,a+4);

	cnt+=a[3]-a[2];

	a[1]+=cnt;

	cnt+=(a[3]-a[1])/2+((a[3]-a[1])&1)*2;

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

	return 0;

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

#define ha 1000000007

using namespace std;



const int N=2010;

int n,k,f[N][N];



int Pow(int a,int b)

{

	int ans=1;

	for(;b;b>>=1,a=1ll*a*a%ha)

		if(b&1) ans=1ll*ans*a%ha;

	return ans;

}



int main()

{

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

	for(int i=2;i<=n;i++) f[1][i]=1;

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

	{

		f[i+1][n-i+1]=f[i][n-i+1];

		for(int j=n-i;j>=2;j--)

			f[i+1][j]=(f[i+1][j+1]+f[i][j])%ha;

	}

	int ans=0;

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

		ans=(ans+f[k-1][i])%ha;

	if(k==1) ans=1;

	if(n-k<=0) printf("%d",ans);

	else printf("%d",1ll*ans*Pow(2,n-1-k)%ha);

	return 0;

}

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

#include<algorithm>

using namespace std;

const int mod=1e9+7;

int n,k,dp[2010];

int qpow(int x,int n){

	int ret=1;

	while(n){

		if(n&1)

			ret=1ll*ret*x%mod;

		x=1ll*x*x%mod;

		n>>=1;

	}

	return ret;

}

int main(){

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

	dp[0]=1;

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

		for(int j=i;j;j--){

			dp[j]=dp[j-1]+dp[j+1];

			if(dp[j]>=mod)

				dp[j]-=mod;

		}

		dp[0]=dp[1];

	}

	printf("%d",1ll*dp[n-k]*qpow(2,max(n-k-1,0))%mod);

	return 0;

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

#define ha 1000000007

using namespace std;



const int N=2010;

int n,k,f[N][N];



int Pow(int a,int b)

{

	int ans=1;

	for(;b;b>>=1,a=1ll*a*a%ha)

		if(b&1) ans=1ll*ans*a%ha;

	return ans;

}



int main()

{

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

	for(int i=2;i<=n;i++) f[1][i]=1;

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

	{

		f[i+1][n-i+1]=f[i][n-i+1];

		for(int j=n-i;j>=2;j--)

			f[i+1][j]=(f[i+1][j+1]+f[i][j])%ha;

	}

	int ans=0;

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

		ans=(ans+f[k-1][i])%ha;

	if(k==1) ans=1;

	if(n-k<=0) printf("%d",ans);

	else printf("%d",1ll*ans*Pow(2,n-1-k)%ha);

	return 0;

}

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

#define mo 1000000007

int n,k,dp[2006][2006],sum[2006];

int main()

{

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

	dp[0][n+1]=1;

	register int i,j;

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

	{

		sum[n+1]=dp[i-1][n+1];

		for(j=n;j>=1;j--) sum[j]=((sum[j+1]%mo)+(dp[i-1][j]%mo))%mo;

		for(j=1;j<=n-i+1;j++) dp[i][j]=sum[j];

	}

	int x=dp[k][1]-dp[k-1][1];

	if(x<0) x+=mo;

	for(i=1;i<=n-k-1;i++) x=(x<<1)%mo;

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

	return 0;

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

#include<cstdio>

#include<cstring>

#include<iostream>

#include<algorithm>

using namespace std;

const int maxn=4000;

const int mod=1e9+7;

int n,k;



int read()

{

    int x=0,f=1;char ch=getchar();

    for (;ch<'0'||ch>'9';ch=getchar()) if (ch=='-') f=-1;

    for (;ch>='0'&&ch<='9';ch=getchar()) x=x*10+ch-'0';

    return x*f;

}



int power(int a,int k)

{

    if(k<0) return 1;

    int sum=1;

    for (;k;k>>=1,a=1ll*a*a%mod)

	if (k&1)

	    sum=1ll*sum*a%mod;

    return sum;

}



int fac[maxn+10],ifac[maxn+10],inv[maxn+10];



int C(int a,int b){return (a<0)||(b<0)||(a<b)?0:1ll*fac[a]*ifac[b]%mod*ifac[a-b]%mod;}



int F(int i,int j){return 1ll*C(i+j,i)*(i-j+1)%mod*inv[i+1]%mod;}



int main()

{

    fac[0]=inv[0]=inv[1]=ifac[0]=1;

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

	{

	    fac[i]=1ll*fac[i-1]*i%mod;

	}

    for(int i=2; i<=maxn; ++i) inv[i]=1ll*(mod-mod/i)*inv[mod%i]%mod;

    for(int i=1; i<=maxn; ++i) ifac[i]=1ll*ifac[i-1]*inv[i]%mod;

    n=read(),k=read();

    printf("%lld\n",1ll*F(n-1,k-1)*power(2,n-k-1)%mod);

    return 0;

}


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

#include<cstdio>

#include<cstring>

#include<iostream>

#include<algorithm>

using namespace std;

const int mod=1e9+7;

const int maxn=2000;

int n,k;

int f[maxn+8][maxn+8],g[maxn+8][maxn+8];



int read()

{

    int x=0,f=1;char ch=getchar();

    for (;ch<'0'||ch>'9';ch=getchar()) if (ch=='-') f=-1;

    for (;ch>='0'&&ch<='9';ch=getchar()) x=x*10+ch-'0';

    return x*f;

}



int power(int a,int k)

{

    if (k<0) return 1;

    int sum=1;

    for (;k;k>>=1,a=1ll*a*a%mod)

	if (k&1)

	    sum=1ll*sum*a%mod;

    return sum;

}



int main()

{

    n=read(),k=read();

    for (int i=1;i<=n;i++) g[0][i]=1;

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

	    for (int j=n-i;j;j--)

	        g[i][j]=(g[i-1][j]+g[i][j+1])%mod;

    printf("%lld\n",1ll*g[k-1][1]*power(2,n-k-1)%mod);

    return 0;

}