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

#include<cmath>

#include<cstring>

#include<string>

#include <cstring>

#include <iostream>

#include <algorithm>



using namespace std;



int main()

{

	int K,S,X,Y,Z,ans,cnt = 0;

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

	for(X = 0; X <= K; X++)

	for(Y = 0; Y <= K; Y++)

	{

		ans = S - X - Y;

		if(ans >= 0 && ans <= K)

		cnt++;

	}

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

	return 0;

}


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

#include<math.h>

using namespace std;

int main()

{

    int K,S,z,x,y,ans;

    while(scanf("%d %d",&K,&S)!=EOF)

    {

       ans=0;

        for(x = 0; x <= K; ++x)

        {

            for(y = 0; y <= K; y++)

            {

                z = S - x - y;

                if(z>=0 && z <= K)

                {

                    ans++;

                }

            }

        }

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



    }

    return 0;

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

#include<algorithm>

#include<cmath>

#include<cstring>

#include<cstdlib>

#include<ctime>

#include<cstdio>

#include<string>

//#include<string>

//#include<sstream>

using namespace std;

int main()

{

	int k,s;

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

	int i,j,b,sum=0;

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

		for(j=0;j<=k&&j<=s-i;j++){

			if(s-i-j<=k) sum++;

		}

	}

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

}

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

#include<math.h>

using namespace std;

int main()

{

    int K,S,z,x,y,ans;

    while(scanf("%d %d",&K,&S)!=EOF)

    {

       ans=0;

        for(x = 0; x <= K; ++x)

        {

            for(y = 0; y <= K; y++)

            {

                z = S - x - y;

                if(z>=0 && z <= K)

                {

                    ans++;

                }

            }

        }

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



    }

    return 0;

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

using namespace std;

#define ll long long



int main()

{

    int k,s;

    while(cin >> k >> s)

    {

        int count = 0;

        int x,y,z;

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

        {

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

            {

                if(s - i - j >= 0 && s - i - j <= k)

                count++;

            }

        }

        cout << count << endl;

    }

    return 0;

}


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

#include<math.h>

using namespace std;

int main()

{

    int K,S,z,x,y,ans;

    while(scanf("%d %d",&K,&S)!=EOF)

    {

       ans=0;

        for(x = 0; x <= K; ++x)

        {

            for(y = 0; y <= K; y++)

            {

                z = S - x - y;

                if(z>=0 && z <= K)

                {

                    ans++;

                }

            }

        }

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



    }

    return 0;

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

using namespace std;

int main(){

	int x,y,z,k,s,num=0;

	cin>>k>>s;

     for(x=0;x<=k;x++){

     	for(y=0;y<=k;y++){

     	if((s-x-y)>=0&&(s-x-y)<=k)

     	num++;

		 }

	 }

	cout<<num;

	return 0;

}

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

#include<math.h>

using namespace std;

int main()

{

    int K,S,z,x,y,ans;

    while(scanf("%d %d",&K,&S)!=EOF)

    {

       ans=0;

        for(x = 0; x <= K; ++x)

        {

            for(y = 0; y <= K; y++)

            {

                z = S - x - y;

                if(z>=0 && z <= K)

                {

                    ans++;

                }

            }

        }

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



    }

    return 0;

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

using namespace std;

#define INF 105



int main()

{

	//freopen("input.txt","r",stdin);

	//freopen("output.txt","w",stdout);

	int n,s;

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

	long long counter=0;

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

	{

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

        {

            int tot=i+k;

            if(s-tot<=n && s-tot>=0)

            {

                counter++;

            }

        }

	}

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

}


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

#include<math.h>

using namespace std;

int main()

{

    int K,S,z,x,y,ans;

    while(scanf("%d %d",&K,&S)!=EOF)

    {

       ans=0;

        for(x = 0; x <= K; ++x)

        {

            for(y = 0; y <= K; y++)

            {

                z = S - x - y;

                if(z>=0 && z <= K)

                {

                    ans++;

                }

            }

        }

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



    }

    return 0;

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

#include <cstdio>

#define ll long long

#define maxn 7510

using namespace std;



ll a[maxn];

int main(){

  int k,s;

  ll ans=0;

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

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

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

      if(s-x-y<=k&&s-x-y>=0)

        ans++;

    }

  }

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

  return 0;

}

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



using namespace std;

int main() {

	int k, s, ans = 0; //s表示总和数 k表示相加的数的最大取值  

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

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

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

			int z = s - (x + y);

			if(z >= 0 && z <= k){

				ans++;

			}	

		}

	}

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

	return 0;	

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

using namespace std;

int main()

{

	int k,s,x,y,z,count=0;

	cin>>k>>s;

	for(int i=k;i>=0;i--){

		int x=s;

		if(i>x)continue;

		for(int j=k;j>=0;j--){

			int y=x-i,z=y-j;

			if(j>y||z<0)continue;

			else if(z<=k)count++;

		}

	}

	cout<<count;

	return 0;

}

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



using namespace std;

int main() {

	int k, s, ans = 0; //s表示总和数 k表示相加的数的最大取值  

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

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

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

			int z = s - (x + y);

			if(z >= 0 && z <= k){

				ans++;

			}	

		}

	}

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

	return 0;	

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

using namespace std;

const int maxi=8000;

int main()

{

     long long k,s,i,j,a[maxi],count,sum;

     while(cin>>k>>s)

     {

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

            a[i]=0;

         count=0;

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

         {

             for(j=0;j<=k;j++)

             {

                 a[i+j]++;

             }

         }

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

         {

             sum=s-i;

             if(sum<0) continue;

             else count+=a[sum];

         }

         cout<<count<<endl;

     }

     return 0;

}


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



using namespace std;

int main() {

	int k, s, ans = 0; //s表示总和数 k表示相加的数的最大取值  

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

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

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

			int z = s - (x + y);

			if(z >= 0 && z <= k){

				ans++;

			}	

		}

	}

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

	return 0;	

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

using namespace std;

int main()

{

    long long k,num,s,i,j,q,cnt=0;

	while(cin>>k>>s)

	{

		cnt=0;

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

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

		{

			num=s-i-j;

			if(num>=0&&num<=k)

		    cnt++;

		}

		cout<<cnt<<endl;

    }

	return 0;

}

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



using namespace std;

int main() {

	int k, s, ans = 0; //s表示总和数 k表示相加的数的最大取值  

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

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

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

			int z = s - (x + y);

			if(z >= 0 && z <= k){

				ans++;

			}	

		}

	}

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

	return 0;	

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

using namespace std;

int main()

{

    int k,num,s,i,j,q,cnt=0;

	while(cin>>k>>s)

	{

		cnt=0;

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

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

		{

			num=s-i-j;

			if(num>=0&&num<=k)

		    cnt++;

		}

		cout<<cnt<<endl;

    }

	return 0;

}

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



using namespace std;

int main() {

	int k, s, ans = 0; //s表示总和数 k表示相加的数的最大取值  

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

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

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

			int z = s - (x + y);

			if(z >= 0 && z <= k){

				ans++;

			}	

		}

	}

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

	return 0;	

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

using namespace std;

const int maxn = (2000000 + 10);

typedef long long int LLI;







int main(){

   // freopen("/home/qihan/Documents/in","r",stdin);

    int s,k;

    LLI ans = 0;

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

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

        int temp = s - i;

        int mins = max(0,temp - k);

        int maxs = min(k,temp);

        if(mins > maxs) continue;

        ans += (maxs - mins + 1);

    }

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

    return 0;

}


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



using namespace std;

int main() {

	int k, s, ans = 0; //s表示总和数 k表示相加的数的最大取值  

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

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

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

			int z = s - (x + y);

			if(z >= 0 && z <= k){

				ans++;

			}	

		}

	}

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

	return 0;	

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

#include <cstdio>

#include <cstdlib>

#include <cmath>

#include <algorithm>

#include <climits>

#include <cstring>

#include <string>

#include <set>

#include <bitset>

#include <map>

#include <queue>

#include <stack>

#include <vector>

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

#define mod 1000000007

#define inf 0x3f3f3f3f

#define vi vector<int>

#define pb push_back

#define mp make_pair

#define fi first

#define se second

#define ll long long

#define pi acos(-1.0)

#define pii pair<int,int>

#define sys system("pause")

const int maxn=1e5+10;

const int N=1e3+10;

using namespace std;

ll gcd(ll p,ll q){return q==0?p:gcd(q,p%q);}

ll qpow(ll p,ll q){ll f=1;while(q){if(q&1)f=f*p%mod;p=p*p%mod;q>>=1;}return f;}

int n,m,k,t,s,cnt;

int main()

{

    int i,j;

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

    rep(i,0,k)rep(j,0,k)if(s-i-j>=0&&s-i-j<=k)cnt++;

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

    return 0;

}


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



using namespace std;

int main() {

	int k, s, ans = 0; //s表示总和数 k表示相加的数的最大取值  

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

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

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

			int z = s - (x + y);

			if(z >= 0 && z <= k){

				ans++;

			}	

		}

	}

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

	return 0;	

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

using namespace std;

int a[1000000];

int main()

{

    int k,s;

    cin>>k>>s;

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

    {

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

        {

            a[5000+i+j]++;

        }

    }

    int sum=0;

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

    {

        int pos=s-i;

        if(pos<0)

        {

            continue;

        }

        sum+=a[5000+pos];

    }

    cout<<sum<<endl;

    return 0;

}

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



using namespace std;

int main() {

	int k, s, ans = 0; //s表示总和数 k表示相加的数的最大取值  

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

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

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

			int z = s - (x + y);

			if(z >= 0 && z <= k){

				ans++;

			}	

		}

	}

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

	return 0;	

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

#include <map>

#include <list>

#include <cmath>

#include <ctime>

#include <deque>

#include <queue>

#include <stack>

#include <cctype>

#include <cstdio>

#include <string>

#include <vector>

#include <cassert>

#include <cstdlib>

#include <cstring>

#include <sstream>

#include <iostream>

#include <algorithm>



using namespace std;

int x,y,z,k,s;

int ans;

int main()

{

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

    ans=0;

    for (x=0;x<=k;++x)

        for (y=0;y<=k;++y)

        {

            z=s-x-y;

            if (z<=k&&z>=0) ans++;

        }

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

    return 0;

}


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



using namespace std;

int main() {

	int k, s, ans = 0; //s表示总和数 k表示相加的数的最大取值  

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

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

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

			int z = s - (x + y);

			if(z >= 0 && z <= k){

				ans++;

			}	

		}

	}

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

	return 0;	

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

#include <cstdio>

using namespace std;

int ans[8000]={0};

int main()

{

    int a,b;

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

    a=min(a,b);

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

        for(int j=0;j<=a;j++)

            ans[i+j]++;

    int wans=0;

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

        wans=wans+ans[b-i];

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

    return 0;

}


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



using namespace std;

int main() {

	int k, s, ans = 0; //s表示总和数 k表示相加的数的最大取值  

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

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

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

			int z = s - (x + y);

			if(z >= 0 && z <= k){

				ans++;

			}	

		}

	}

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

	return 0;	

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



using namespace std;

bool judge[10000000];

int main()

{

    int k,s;

    int x,y,z;

    int temp;

    int ans = 0;

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

    for( x = 0; x <= k; x ++)

    {

        for( y = 0; y <= k; y ++)

        {

            z = s - x - y;

            if(z >= 0 && z <= k)

            {

                temp = x * 3000 + y;

                if(judge[temp] == false)

                {

                    ans ++;

                    judge[temp] = true;

                }

            }

        }

    }

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

    return 0;

}


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



using namespace std;

int main() {

	int k, s, ans = 0; //s表示总和数 k表示相加的数的最大取值  

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

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

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

			int z = s - (x + y);

			if(z >= 0 && z <= k){

				ans++;

			}	

		}

	}

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

	return 0;	

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

#include <cstring>

#include <cstdio>

#include <algorithm>

#include <cmath>

#include <string>

#include <map>

#include <stack>

#include <queue>

#include <vector>

#define inf 0x3f3f3f3f

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

#define pb push_back

typedef long long ll;

using namespace std;

const int N = 1e5+5;

const int M = 24005;

int head[N*2],tot,in[N*2];

struct man

{

    int u,v;

}edg[N*2];

int n,v,m,k,s;

int main() {

    int x,y,z;

    int ans=0;

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

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

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

            int ret=s-i-j;

            if(ret<=k&&ret>=0)ans++;

        }

    }

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

    return 0;

}


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



using namespace std;

int main() {

	int k, s, ans = 0; //s表示总和数 k表示相加的数的最大取值  

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

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

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

			int z = s - (x + y);

			if(z >= 0 && z <= k){

				ans++;

			}	

		}

	}

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

	return 0;	

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

#include <cstdio>

using namespace std;



int main()

{

    int K,s;

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

    int i,j,k;

    int nu=0;

    for(j=0;j<=K;j++)

        for(k=0;k<=K;k++)

        {

            i=s-j-k;

            if(i>=0&&i<=K)

                nu++;

        }

    printf("%d",nu);

    return 0;

}


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



using namespace std;

int main() {

	int k, s, ans = 0; //s表示总和数 k表示相加的数的最大取值  

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

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

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

			int z = s - (x + y);

			if(z >= 0 && z <= k){

				ans++;

			}	

		}

	}

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

	return 0;	

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

#include <string.h>

#include <stdio.h>

#include <algorithm>

#include <math.h>

using namespace std;



int main()

{

 int k,s,m;

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

 m=0;

 for(int i=k;i>=0;i--)

 {

     for(int j=k;j>=0;j--)

     {

         if((s-i-j<=k)&&(s-i-j)>=0)

            m++;

     }

 }

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

}


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



using namespace std;

int main() {

	int k, s, ans = 0; //s表示总和数 k表示相加的数的最大取值  

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

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

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

			int z = s - (x + y);

			if(z >= 0 && z <= k){

				ans++;

			}	

		}

	}

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

	return 0;	

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

using namespace std;

int a[1000000];

int main()

{

    int k,s;

    cin>>k>>s;

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

    {

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

        {

            a[5000+i+j]++;

        }

    }

    int sum=0;

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

    {

        int pos=s-i;

        if(pos<0)

        {

            continue;

        }

        sum+=a[5000+pos];

    }

    cout<<sum<<endl;

    return 0;

}


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



using namespace std;

int main() {

	int k, s, ans = 0; //s表示总和数 k表示相加的数的最大取值  

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

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

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

			int z = s - (x + y);

			if(z >= 0 && z <= k){

				ans++;

			}	

		}

	}

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

	return 0;	

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

#include <cstdio>

#include <cstdlib>

#include <cmath>

#include <algorithm>

#include <cstring>

#include <stack>

#include <queue>

#include <string>

#include <vector>

#include <set>

#include <map>

#define LL long long int

using namespace std;

int main()

{

    int s,k,a,b,c;

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

   if(k>s*3)

    printf("0\n");

   else if( k==s*3||k==0)

    printf("1\n");

   else if(k<s*3)

   {

       int ans=0;

       for(a=0;a<=s&&a<=k;a++)

       {

           c=k-a-a;

           if(c>=0&&c!=a&&c<=s)

           ans+=3;

           else if(c>=0&&c==a&&c<=s)

            ans++;

           for(b=a+1;b<=s&&b<=k;b++)

           {

               c=k-a-b;

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

                ans+=6;

           }

       }

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



   }

    return 0;

}


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



using namespace std;

int main() {

	int k, s, ans = 0; //s表示总和数 k表示相加的数的最大取值  

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

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

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

			int z = s - (x + y);

			if(z >= 0 && z <= k){

				ans++;

			}	

		}

	}

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

	return 0;	

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

#include <stdio.h>

#include <cstring>

#include <cmath>

#include <algorithm>

using namespace std;



int main()

{

    int t,s;

    int sum,i,j,k;

    cin>>t>>s;

    sum=0;

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

    {

        for(j=i; j<=t; ++j)

        {

            for(k=j; k<=t; ++k)

            {

                if(i+j+k==s)

                {

                    if(i==j&&j==k)

                        sum+=1;

                    if((i==j&&i!=k)||(j==k&&j!=i)||(i==k&&j!=k))

                        sum+=3;

                    if(i!=j&&j!=k&&i!=k)

                        sum+=6;

                }

            }

        }

    }

    cout<<sum<<endl;

    return 0;

}


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



using namespace std;

int main() {

	int k, s, ans = 0; //s表示总和数 k表示相加的数的最大取值  

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

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

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

			int z = s - (x + y);

			if(z >= 0 && z <= k){

				ans++;

			}	

		}

	}

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

	return 0;	

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

using namespace std;

typedef long long ll;

const ll maxn=1e5+9;

ll arr[maxn];

ll sum[maxn];

ll sz[maxn];

ll n,k;

int main(){

        ll a,b,c,d,e,f,g,h;

        ios::sync_with_stdio(0);

        ll k,s;

        cin>>k>>s;

        g=0;

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

                a=s-i;

                if(a>k*2||a<0)continue;

                h=a+1;

                if(a>k){

                        h-=(a-k)*2;

                }

                g+=h;

        }

        cout<<g<<endl;

        return 0;

}


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



using namespace std;

int main() {

	int k, s, ans = 0; //s表示总和数 k表示相加的数的最大取值  

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

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

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

			int z = s - (x + y);

			if(z >= 0 && z <= k){

				ans++;

			}	

		}

	}

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

	return 0;	

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

#include<cstdlib>

#include<cmath>

#include<iostream>

#include<cstring>

#include<string>

#include<algorithm>

using namespace std;



int main()

{

	int a, b, c, x, k;

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

	int ans = 0;

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

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

			if((x - i - j) <= k && (x - i - j) >= 0) {

				ans++;

			}

			else continue;

		}

	}

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

	return 0;

}

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



using namespace std;

int main() {

	int k, s, ans = 0; //s表示总和数 k表示相加的数的最大取值  

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

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

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

			int z = s - (x + y);

			if(z >= 0 && z <= k){

				ans++;

			}	

		}

	}

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

	return 0;	

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

#include<cmath>

#include<cstring>

#include<string>

#include <cstring>

#include <iostream>

#include <algorithm>



using namespace std;



int main()

{

	int K,S,X,Y,Z,ans,cnt = 0;

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

	for(X = 0; X <= K; X++)

	for(Y = 0; Y <= K; Y++)

	{

		ans = S - X - Y;

		if(ans >= 0 && ans <= K)

		cnt++;

	}

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

	return 0;

}


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



using namespace std;

int main() {

	int k, s, ans = 0; //s表示总和数 k表示相加的数的最大取值  

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

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

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

			int z = s - (x + y);

			if(z >= 0 && z <= k){

				ans++;

			}	

		}

	}

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

	return 0;	

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

#include<algorithm>

#include<cmath>

#include<cstring>

#include<cstdlib>

#include<ctime>

#include<cstdio>

#include<string>

//#include<string>

//#include<sstream>

using namespace std;

int main()

{

	int k,s;

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

	int i,j,b,sum=0;

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

		for(j=0;j<=k&&j<=s-i;j++){

			if(s-i-j<=k) sum++;

		}

	}

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

}

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



using namespace std;

int main() {

	int k, s, ans = 0; //s表示总和数 k表示相加的数的最大取值  

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

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

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

			int z = s - (x + y);

			if(z >= 0 && z <= k){

				ans++;

			}	

		}

	}

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

	return 0;	

}