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

#include<cstdio>

#include<cstring>

using namespace std;



int n,m,dp[5][10010];



int dfs(int now,int sy)

{

	if(now>3) return !sy;

	if(dp[now][sy]!=-1) return dp[now][sy];

	int i,res=0;

	for(i=0;i<=min(n,sy);i++)

	{

		res+=dfs(now+1,sy-i);

	}

	return dp[now][sy]=res;

}



int main()

{

	int a,b;

	memset(dp,-1,sizeof(dp));

	cin>>n>>m;

	cout<<dfs(1,m);

}

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

using namespace std;



int main() {

	int k, s;

	int x, y, z;

	int formas = 0;

	

	cin >> k >> s;

	

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

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

			z = s - x - y;

			

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

		}

	}

	cout << formas;

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

#include<cstdio>

#include<cstring>

using namespace std;



int n,m,dp[5][10010];



int dfs(int now,int sy)

{

	if(now>3) return !sy;

	if(dp[now][sy]!=-1) return dp[now][sy];

	int i,res=0;

	for(i=0;i<=min(n,sy);i++)

	{

		res+=dfs(now+1,sy-i);

	}

	return dp[now][sy]=res;

}



int main()

{

	int a,b;

	memset(dp,-1,sizeof(dp));

	cin>>n>>m;

	cout<<dfs(1,m);

}

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

#include<iostream>

#include<algorithm>

#include<cmath>

#include<cstring>

#include<string>

#include<vector>

using namespace std;



#define ll long long



#define debug_message 0

#define debug if (debug_message)



#define sz(x) (int)x.size()



ll i,t,j;

ll k,s,a,b,c,cnt;



int main(){

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

	

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

		for (t=0; t<=min(k,s-i); ++t){

			if (s-i-t<=k) ++cnt;

		}

	}

	

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

	

	return 0;

}

/*



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

#include<cstdio>

#include<cstring>

using namespace std;



int n,m,dp[5][10010];



int dfs(int now,int sy)

{

	if(now>3) return !sy;

	if(dp[now][sy]!=-1) return dp[now][sy];

	int i,res=0;

	for(i=0;i<=min(n,sy);i++)

	{

		res+=dfs(now+1,sy-i);

	}

	return dp[now][sy]=res;

}



int main()

{

	int a,b;

	memset(dp,-1,sizeof(dp));

	cin>>n>>m;

	cout<<dfs(1,m);

}

// Faster C++ solution for the same problem (measured speedup: 1.1945418733278632x):
//sum 3 int

#include <bits/stdc++.h>

using namespace std;

long long n,m,k,s,tmp,sum=0;

char r1,r2,op;

int main(){

	cin>>k>>s;

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

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

			long long tar=s-i-j;

			if (tar>=0 && tar<=k) sum++;

		}

	}

	cout<<sum<<endl;

	return 0;

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

#include<algorithm>

#include<string>

#include<cstdlib>

#include<map>



using namespace std;





int main() {

	map<int, int> mp;

	int n, m,tmp=0,ax=0,k,s;

	string str, str2[5000];

	cin >> k >> s;

	

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

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

			if (s - i - j >= 0 && s - i - j <= k) { tmp++; }

		}

	}

	cout <<tmp;

}

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

#include<algorithm>

#include<string>

#include<cstdlib>

#include<map>

#include<iomanip>

#include<sstream>

#include<vector>

#include<stack>

#include<math.h>

#include<queue>

#include<complex>

using namespace std;



long long int k,s,res=0;



int main() {

    const long long int mod = 1000000007,INF=99999999999999;

	map<long long int, long long int>mp;

	cout << fixed << setprecision(10);

    cin>>k>>s;

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

        if(s-i<0||s-i>2*k){continue;}

        res+=k+1-abs(s-i-k);

    }

    cout<<res;

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

#include <algorithm>

using namespace std;

int main()

{

	int k,s;

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

	long long res = 0;

	for(int x=0; x<=min(k,s); x++)

	{

		int a1=max(0,s-x-k);

		int a2=min(k,s-x);

		if(a1>k) continue;

		res+=a2-a1+1;

	}

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

	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.234108004590922x):
#include <cstdio>

#include <algorithm>

using namespace std;

int main()

{

	int k,s;

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

	long long res = 0;

	for(int x=0; x<=min(k,s); x++)

	{

		int a1=max(0,s-x-k);

		int a2=min(k,s-x);

		if(a1>k) continue;

		res+=a2-a1+1;

	}

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

	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.599630909269979x):
#include <cstdio>

#include <algorithm>

using namespace std;

int main()

{

	int k,s;

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

	long long res = 0;

	for(int x=0; x<=min(k,s); x++)

	{

		int a1=max(0,s-x-k);

		int a2=min(k,s-x);

		if(a1>k) continue;

		res+=a2-a1+1;

	}

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

	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.2606341203185325x):
#include <cstdio>

#include <algorithm>

using namespace std;

int main()

{

	int k,s;

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

	long long res = 0;

	for(int x=0; x<=min(k,s); x++)

	{

		int a1=max(0,s-x-k);

		int a2=min(k,s-x);

		if(a1>k) continue;

		res+=a2-a1+1;

	}

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

	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.252497092748978x):
#include <cstdio>

#include <algorithm>

using namespace std;

int main()

{

	int k,s;

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

	long long res = 0;

	for(int x=0; x<=min(k,s); x++)

	{

		int a1=max(0,s-x-k);

		int a2=min(k,s-x);

		if(a1>k) continue;

		res+=a2-a1+1;

	}

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

	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.175845964365532x):
#include <cstdio>

#include <algorithm>

using namespace std;

int main()

{

	int k,s;

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

	long long res = 0;

	for(int x=0; x<=min(k,s); x++)

	{

		int a1=max(0,s-x-k);

		int a2=min(k,s-x);

		if(a1>k) continue;

		res+=a2-a1+1;

	}

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

	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.194830508903101x):
#include <cstdio>

#include <algorithm>

using namespace std;

int main()

{

	int k,s;

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

	long long res = 0;

	for(int x=0; x<=min(k,s); x++)

	{

		int a1=max(0,s-x-k);

		int a2=min(k,s-x);

		if(a1>k) continue;

		res+=a2-a1+1;

	}

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

	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.246557310855725x):
#include <cstdio>

#include <algorithm>

using namespace std;

int main()

{

	int k,s;

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

	long long res = 0;

	for(int x=0; x<=min(k,s); x++)

	{

		int a1=max(0,s-x-k);

		int a2=min(k,s-x);

		if(a1>k) continue;

		res+=a2-a1+1;

	}

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

	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.196136617066514x):
#include <cstdio>

#include <algorithm>

using namespace std;

int main()

{

	int k,s;

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

	long long res = 0;

	for(int x=0; x<=min(k,s); x++)

	{

		int a1=max(0,s-x-k);

		int a2=min(k,s-x);

		if(a1>k) continue;

		res+=a2-a1+1;

	}

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

	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.2149093164078595x):
#include <cstdio>

#include <algorithm>

using namespace std;

int main()

{

	int k,s;

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

	long long res = 0;

	for(int x=0; x<=min(k,s); x++)

	{

		int a1=max(0,s-x-k);

		int a2=min(k,s-x);

		if(a1>k) continue;

		res+=a2-a1+1;

	}

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

	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.234016181542556x):
#include <cstdio>

#include <algorithm>

using namespace std;

int main()

{

	int k,s;

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

	long long res = 0;

	for(int x=0; x<=min(k,s); x++)

	{

		int a1=max(0,s-x-k);

		int a2=min(k,s-x);

		if(a1>k) continue;

		res+=a2-a1+1;

	}

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

	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.185036328139949x):
#include <cstdio>

#include <algorithm>

using namespace std;

int main()

{

	int k,s;

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

	long long res = 0;

	for(int x=0; x<=min(k,s); x++)

	{

		int a1=max(0,s-x-k);

		int a2=min(k,s-x);

		if(a1>k) continue;

		res+=a2-a1+1;

	}

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

	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.183884948708381x):
#include <cstdio>

#include <algorithm>

using namespace std;

int main()

{

	int k,s;

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

	long long res = 0;

	for(int x=0; x<=min(k,s); x++)

	{

		int a1=max(0,s-x-k);

		int a2=min(k,s-x);

		if(a1>k) continue;

		res+=a2-a1+1;

	}

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

	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.186240844845595x):
#include <cstdio>

#include <algorithm>

using namespace std;

int main()

{

	int k,s;

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

	long long res = 0;

	for(int x=0; x<=min(k,s); x++)

	{

		int a1=max(0,s-x-k);

		int a2=min(k,s-x);

		if(a1>k) continue;

		res+=a2-a1+1;

	}

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

	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.246557310855725x):
#include <cstdio>

#include <algorithm>

using namespace std;

int main()

{

	int k,s;

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

	long long res = 0;

	for(int x=0; x<=min(k,s); x++)

	{

		int a1=max(0,s-x-k);

		int a2=min(k,s-x);

		if(a1>k) continue;

		res+=a2-a1+1;

	}

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

	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.172893448258861x):
#include <cstdio>

#include <algorithm>

using namespace std;

int main()

{

	int k,s;

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

	long long res = 0;

	for(int x=0; x<=min(k,s); x++)

	{

		int a1=max(0,s-x-k);

		int a2=min(k,s-x);

		if(a1>k) continue;

		res+=a2-a1+1;

	}

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

	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.82240411128218x):
#include <cstdio>

#include <algorithm>

using namespace std;

int main()

{

	int k,s;

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

	long long res = 0;

	for(int x=0; x<=min(k,s); x++)

	{

		int a1=max(0,s-x-k);

		int a2=min(k,s-x);

		if(a1>k) continue;

		res+=a2-a1+1;

	}

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

	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.102378121549609x):
#include<cstdio>

#include<cstring>

#include<algorithm>

using namespace std;

int i, j, k, l = 0, m, n, s;

int main() {

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

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

		k = s - i - j;

		if(k >= 0 && k <= n) l++;

	}

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

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

#include<cstring>

#include<algorithm>

using namespace std;

int i, j, k, l = 0, m, n, s;

int main() {

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

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

		k = s - i - j;

		if(k >= 0 && k <= n) l++;

	}

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

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

#include<cstring>

#include<algorithm>

using namespace std;

int i, j, k, l = 0, m, n, s;

int main() {

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

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

		k = s - i - j;

		if(k >= 0 && k <= n) l++;

	}

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

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

#include<cstring>

#include<algorithm>

using namespace std;

int i, j, k, l = 0, m, n, s;

int main() {

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

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

		k = s - i - j;

		if(k >= 0 && k <= n) l++;

	}

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

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

#include<cstring>

#include<algorithm>

using namespace std;

int i, j, k, l = 0, m, n, s;

int main() {

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

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

		k = s - i - j;

		if(k >= 0 && k <= n) l++;

	}

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

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

#include<cstring>

#include<algorithm>

using namespace std;

int i, j, k, l = 0, m, n, s;

int main() {

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

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

		k = s - i - j;

		if(k >= 0 && k <= n) l++;

	}

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

}