stablegradients/pie-gem5-pairs huggingface dataset:
// 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.18926518186806x):
#include <cstdio>

long long a,b,c,d,i,j,k,x,y,z,ans;

int main(){

	ans=0;

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

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

		x=i;

		c=b-x;

		if ((c>=0) and (c<=a)){

			ans+=c+1;

		}

		if ((c>a) and (c<=2*a)){

			ans+=2*a-c+1;

		} 

	}

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

}
// 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.840831486604805x):
#include <cstdio>

long long a,b,c,d,i,j,k,x,y,z,ans;

int main(){

	ans=0;

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

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

		x=i;

		c=b-x;

		if ((c>=0) and (c<=a)){

			ans+=c+1;

		}

		if ((c>a) and (c<=2*a)){

			ans+=2*a-c+1;

		} 

	}

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

}
// 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.315842608479002x):
#include <cstdio>

long long a,b,c,d,i,j,k,x,y,z,ans;

int main(){

	ans=0;

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

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

		x=i;

		c=b-x;

		if ((c>=0) and (c<=a)){

			ans+=c+1;

		}

		if ((c>a) and (c<=2*a)){

			ans+=2*a-c+1;

		} 

	}

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

}
// 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.134151443929876x):
#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 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.179668624622017x):
#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;

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.5413897658912035x):
#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()

{

    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.205918845146103x):
#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 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.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 <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.122012561449988x):
#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>

#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.140799649834051x):
#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;

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.191988447025672x):
#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 <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.1420921733105365x):
#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>

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.160669619876893x):
#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;

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.179577756615047x):
#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 <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.131107337264597x):
#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>

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.129967933203486x):
#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 <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.132299325924861x):
#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;

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.191988447025672x):
#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>

#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.119090754137643x):
#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 <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.761845928403915x):
#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;

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.243956474338389x):
#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<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.1320717578623505x):
#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;

}