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

using namespace std;

int main(){

int k,s,z;

cin>>k>>s;

int n=0;

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

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

	z=s-i-j; 

	if(s==(i+j+z))

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

n+=1;

}}

cout<<n;

return 0;

}

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

using namespace std;

int k,s,c=0,z;

int main(){

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

	if (s==k*3){

		c=1;

	}else{

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

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

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

					c+=1;

				}

			}

		}

	}

	printf("%d",c);

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

using namespace std;



int main(){



int k,s,z,counter=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&&(x+y+z)==s)

		counter++;

	}

}

cout<<counter;



return 0;

} 

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

using namespace std;

int k,s,c=0,z;

int main(){

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

	if (s==k*3){

		c=1;

	}else{

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

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

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

					c+=1;

				}

			}

		}

	}

	printf("%d",c);

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

using namespace std;



int main()

{

    int k, s;

    cin >> k >> s;

    int counter = 0;

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

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

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

                if (x + y + z == s) {

                    if (x != y && y != z && x != z) {

                        counter += 6;

                    } else if (x == y && y == z) {

                        counter++;

                    } else {

                        counter += 3;

                    }

                }

            }

        }

    }

    cout << counter << endl;

    return 0;

}

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

using namespace std;

int k,s,c=0,z;

int main(){

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

	if (s==k*3){

		c=1;

	}else{

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

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

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

					c+=1;

				}

			}

		}

	}

	printf("%d",c);

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

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

using namespace std;

int k,s,c=0,z;

int main(){

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

	if (s==k*3){

		c=1;

	}else{

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

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

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

					c+=1;

				}

			}

		}

	}

	printf("%d",c);

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

using namespace std;

#define ll long long

#define x first

#define y second

#define mp make_pair

#define pb push_back

#define kk 1000000007

int n,m,k,a,b,c,tmp,cc[300005];

vector<int > ee;

map<int ,int > mm;

char g;

int main(){

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

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

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

			if (i+j <= k && k-i-j<=n) tmp++;

		}

	}

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

}

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

using namespace std;

int k,s,c=0,z;

int main(){

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

	if (s==k*3){

		c=1;

	}else{

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

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

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

					c+=1;

				}

			}

		}

	}

	printf("%d",c);

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

using namespace std;

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

int main()

{

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

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

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

            m=s-i-j;

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

                sum++;

        }

    cout<<sum<<endl;

}

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

#include<cctype>

using namespace std;

int k,s,ans;

int main()

{

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

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

    {

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

        {

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

        }

    }

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

    return 0;

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

using namespace std;

long long cnt;

int main()

{

	int x,y,z,k,s;

	cin>>k>>s;

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

	{

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

		{

			z=s-x-y;

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

		}

	}

	cout<<cnt<<endl;

	return 0;

}

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

#include<cctype>

using namespace std;

int k,s,ans;

int main()

{

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

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

    {

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

        {

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

        }

    }

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

    return 0;

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

using namespace std;

int main()

{int k,s,t=0;

 cin>>k>>s;

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

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

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

 cout<<t;

}

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

#include<cctype>

using namespace std;

int k,s,ans;

int main()

{

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

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

    {

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

        {

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

        }

    }

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

    return 0;

}
// Slower C++ solution:
/*

Character Drawing Adapted from FAKEUPDATE.NET

		   _    _____         _

		   \`,""   ,'7"r-..__/ \

		  ,'\ `, ,',','    _/   \

		 /   \, 7 / /     (   \ |

		J     \/ j  L______\  / |

		L   __JF"""/""\"\_,    /

		L,-"| O|  f O |  L_  _/

		F   \_ /  \__/   `-  j|

			.-'    `"""    ,' |          _..====.._

			\__/         r"_  A        ,' _..---.._`,

			 `-.______,,-L// / \  ___,' ,'_..:::.. `,`,

					  j   / / / 7"    `-<""=:'  '':. \ \

					 /   <,' /  F  . i , \   `,    :T W I

					 |    \,'  /    >X<  |     \   :| | L

					 |     `._/    ' ! ` |      I  :| |  G

					  \           \     /       |  :H T  |

					 __>-.__   __,-\   |        |  S P   |

					/     /|   | \  \  \_       | 'A R   |

				   /   __/ |   |  L  L   \      K./ /    L

				  /   |    |   4  I  I    |    E./ /   ,'

				 J    \    I    L F  I    |    // / _,'

		_________|     |   F    |J   F    |   //_/-'

		\   __   |    /   J     |/  J     |  /="

		\\  \_\  \__,' \  F     |   F     |

		\\\_____________\/      F__/      F

		 \\| 计算机编程 |_____/  (______/

		  \/从入门到入土/

*/

#include <iostream>

#include <cstdlib>

#include <iomanip>

#include <cmath>

#include <string>

#include <cstring>

#include <algorithm>

#include <vector>

#include <sstream>

#include <set>

#include <queue>

#include <stack>

#include <cctype>

#include <map>

#include <climits>

#include <bitset>

#include <functional>

using namespace std;

int main(){

	ios::sync_with_stdio(false);

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

	cin >> K >> S;

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

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

			if (0 <= S - X - Y && S - X - Y <= K) 

				++ans;

		}

	}

	cout << ans << endl;

endapp:

	//system("pause > nul");

	return 0;

}

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

using namespace std;

int k,s,x,y,ans;

int main(){

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

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

		if(s<x) break;

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

			if(s<x+y) break;

			if(s>=x+y&&s-x-y<=k) ans++;

		}

	}

	printf("%d",ans);

	return 0;

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

using namespace std;



int k,s,cnt=0;



int main()

{

    cin>>k>>s;

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

    {

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

        {

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

        }

    }

    cout<<cnt<<endl;

    return 0;

}

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

using namespace std;

int k,s,x,y,ans;

int main(){

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

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

		if(s<x) break;

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

			if(s<x+y) break;

			if(s>=x+y&&s-x-y<=k) ans++;

		}

	}

	printf("%d",ans);

	return 0;

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

using namespace std;

int main()

{

	int a,b;

	int ans=0;

	cin>>b>>a;

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

	{

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

		{

			int k=a-i-j;

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

			{

				ans++;

			}

		}

	}

	cout<<ans<<endl;

	return 0;

 } 

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

using namespace std;

int k,s,x,y,ans;

int main(){

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

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

		if(s<x) break;

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

			if(s<x+y) break;

			if(s>=x+y&&s-x-y<=k) ans++;

		}

	}

	printf("%d",ans);

	return 0;

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

using namespace std;

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

int main()

{

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

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

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

            m=s-i-j;

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

				sum++;

		}

    cout<<sum<<endl;

}

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

using namespace std;

int k,s,x,y,ans;

int main(){

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

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

		if(s<x) break;

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

			if(s<x+y) break;

			if(s>=x+y&&s-x-y<=k) ans++;

		}

	}

	printf("%d",ans);

	return 0;

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

using namespace std;

int main()

{

    int s,k,ans=0;

    cin>>k>>s;

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

    {

        for(int j=0;j<=k;j++) if(s-j-i>=0&&s-i-j<=k) ans++;

    }

    cout<<ans<<endl;

    return 0;

}

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

using namespace std;

int k,s,x,y,ans;

int main(){

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

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

		if(s<x) break;

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

			if(s<x+y) break;

			if(s>=x+y&&s-x-y<=k) ans++;

		}

	}

	printf("%d",ans);

	return 0;

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

using namespace std;

int main()

{

    int k,s,l,ans=0;

    cin>>k>>s;

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

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

        {

            l=s-i-j;

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

                ans++;

        }

    cout<<ans;

    return 0;

}

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

using namespace std;

int k,s,x,y,ans;

int main(){

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

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

		if(s<x) break;

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

			if(s<x+y) break;

			if(s>=x+y&&s-x-y<=k) ans++;

		}

	}

	printf("%d",ans);

	return 0;

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

using namespace std;



#define all(cont) cont.begin(), cont.end()

#define rall(cont) cont.end(), cont.begin()

#define mp make_pair

#define pb push_back

#define fs first

#define sc second

#define fr(i, a, b) for(int i = a ; i < b ; i++)

#define frr(i, a, b) for(int i = a ; i >= b ; i--)

#define tr(it, var) for(__typeof(var.begin()) it = var.begin(); it != var.end(); it++)

#define trr(rit, var) for(__typeof(var.rbegin()) rit = var.rbegin(); rit != var.rend(); rit++)

#define its(x) static_cast< ostringstream & >( ( ostringstream() << dec << x ) ).str() // int to string

#define boost ios_base::sync_with_stdio(false); cin.tie(NULL)

#define deb(x) cout << #x" = " << x << '\n'

#define has(cont, x) ((cont).find((x)) != (cont).end())

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



typedef long long ll;

typedef unsigned long long ull;

typedef long double ld;

typedef pair<int, int> pii;

typedef pair<ll, ll> pll;

typedef vector<int> vi;



int main() {

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

	int k, s;

	ll res = 0;

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

	fr(i, 0, k+1) {

		fr(j, 0, k+1) {

			int to = s-(i+j);

//			deb(to);

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

				if(i+j+to == s) res++;

		}

	}

	cout << res << '\n';

	return 0;

}

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

int main(){

	int a,b;

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

	   int X,Y,Z,sum=0;

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

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

	{	   Z=b-X-Y;

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

	{sum=sum+1;

	}

	}

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

	return 0;

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

using namespace std;



#define all(cont) cont.begin(), cont.end()

#define rall(cont) cont.end(), cont.begin()

#define mp make_pair

#define pb push_back

#define fs first

#define sc second

#define fr(i, a, b) for(int i = a ; i < b ; i++)

#define frr(i, a, b) for(int i = a ; i >= b ; i--)

#define tr(it, var) for(__typeof(var.begin()) it = var.begin(); it != var.end(); it++)

#define trr(rit, var) for(__typeof(var.rbegin()) rit = var.rbegin(); rit != var.rend(); rit++)

#define its(x) static_cast< ostringstream & >( ( ostringstream() << dec << x ) ).str() // int to string

#define boost ios_base::sync_with_stdio(false); cin.tie(NULL)

#define deb(x) cout << #x" = " << x << '\n'

#define has(cont, x) ((cont).find((x)) != (cont).end())

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



typedef long long ll;

typedef unsigned long long ull;

typedef long double ld;

typedef pair<int, int> pii;

typedef pair<ll, ll> pll;

typedef vector<int> vi;



int main() {

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

	int k, s;

	ll res = 0;

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

	fr(i, 0, k+1) {

		fr(j, 0, k+1) {

			int to = s-(i+j);

//			deb(to);

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

				if(i+j+to == s) res++;

		}

	}

	cout << res << '\n';

	return 0;

}

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

int main()

{int k,s;

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

int a,b,cnt=0;

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

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

		{if((s-a-b)<=k&&(s-a-b)>=0)	

		cnt++;



	}}

		printf("%d",cnt);

			return 0;

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

using namespace std;



#define all(cont) cont.begin(), cont.end()

#define rall(cont) cont.end(), cont.begin()

#define mp make_pair

#define pb push_back

#define fs first

#define sc second

#define fr(i, a, b) for(int i = a ; i < b ; i++)

#define frr(i, a, b) for(int i = a ; i >= b ; i--)

#define tr(it, var) for(__typeof(var.begin()) it = var.begin(); it != var.end(); it++)

#define trr(rit, var) for(__typeof(var.rbegin()) rit = var.rbegin(); rit != var.rend(); rit++)

#define its(x) static_cast< ostringstream & >( ( ostringstream() << dec << x ) ).str() // int to string

#define boost ios_base::sync_with_stdio(false); cin.tie(NULL)

#define deb(x) cout << #x" = " << x << '\n'

#define has(cont, x) ((cont).find((x)) != (cont).end())

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



typedef long long ll;

typedef unsigned long long ull;

typedef long double ld;

typedef pair<int, int> pii;

typedef pair<ll, ll> pll;

typedef vector<int> vi;



int main() {

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

	int k, s;

	ll res = 0;

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

	fr(i, 0, k+1) {

		fr(j, 0, k+1) {

			int to = s-(i+j);

//			deb(to);

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

				if(i+j+to == s) res++;

		}

	}

	cout << res << '\n';

	return 0;

}

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

int main()

{

    int k,s,i,count=0,z=0;

    scanf("%d%d",&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&&(z+y+x)==s){

                count++;

            }

            z=0;

        }

    }

    printf("%d",count);

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

using namespace std;



int main(){

	int k,s,ans = 0;

	cin >> k >> s;

	

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

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

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

		}

	}

	cout << ans;

}

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

int main()

{

    int k,s,i,count=0,z=0;

    scanf("%d%d",&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&&(z+y+x)==s){

                count++;

            }

            z=0;

        }

    }

    printf("%d",count);

}
// Slower C++ solution:
/*g++ file.cpp -o file.out*/

/*./file.out*/



#include <cmath>

#include <queue>

#include <stack>

#include <cstdio>

#include <string>

#include <vector>

#include <cstring>

#include <iostream>

#include <algorithm>

using namespace std;



#define LL long long

#define Mod 1000000007

#define L_Mod 17100000013



int main()

{

    int K,S,sov=0,X,Y,Z;

    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)

            {

                sov++;

            }

        }

    }

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

    return 0;

}


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

int main()

{

    int k,s,i,count=0,z=0;

    scanf("%d%d",&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&&(z+y+x)==s){

                count++;

            }

            z=0;

        }

    }

    printf("%d",count);

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

#include <algorithm>

#include <cstdio>

#include <cstring>

#include <string>

#include <cmath>

using namespace std;

int main()

{

	int k,s;

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

	long long ans=0;

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

	{

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

		{

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

			{

				ans++;

			}

		}

	}

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

	return 0;

} 

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

int main()

{

    int k,s,i,count=0,z=0;

    scanf("%d%d",&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&&(z+y+x)==s){

                count++;

            }

            z=0;

        }

    }

    printf("%d",count);

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

using namespace std;

int main(){

	int t,s;

	cin>>t>>s;

	int ans=0;

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

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

			int k=s-i-j;

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

		}

	}

	cout<<ans<<endl;

	return 0;

}

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

int main()

{

    int k,s,i,count=0,z=0;

    scanf("%d%d",&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&&(z+y+x)==s){

                count++;

            }

            z=0;

        }

    }

    printf("%d",count);

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

using namespace std;

 int a[100000];

  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.208159550115845x):
#include<stdio.h>

int main()

{

    int k,s,i,count=0,z=0;

    scanf("%d%d",&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&&(z+y+x)==s){

                count++;

            }

            z=0;

        }

    }

    printf("%d",count);

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

    using namespace std ;

     

    int main ()

    {

        int k,s,cnt=0;

        cin>>k>>s;

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

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

                int z=(s-x-y);

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

                cnt++;

            }

        }

        cout<<cnt<<endl;

    }

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

int main()

{

    int k,s,i,count=0,z=0;

    scanf("%d%d",&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&&(z+y+x)==s){

                count++;

            }

            z=0;

        }

    }

    printf("%d",count);

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

using namespace std;

int main()

{

	int k,s,c=0,z;

	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)

                    c++;

            }

	   }

	   printf("%d",c);

}




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

int main()

{

    int k,s,i,count=0,z=0;

    scanf("%d%d",&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&&(z+y+x)==s){

                count++;

            }

            z=0;

        }

    }

    printf("%d",count);

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

using namespace std;

 

int main(){

  int K,S;

   cin >> K;

   cin >> S;

  int ans = 0;

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

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

      if(S-i-j<=K && (S-i-j>=0))

	   ans++;

    }

  }

  cout << ans << endl;

}

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

int main()

{

    int k,s,i,count=0,z=0;

    scanf("%d%d",&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&&(z+y+x)==s){

                count++;

            }

            z=0;

        }

    }

    printf("%d",count);

}
// Slower C++ solution:
#pragma GCC optimize("O3")

#include <bits/stdc++.h>

#define For(i,a,b) for(int i=a;i<=b;i++)

#define F first

#define S second

#define all(x) x.begin(),x.end()

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

#define MOD (ll)(1e9+7)

#define INF 1e17

#define int ll

#define EPS (1e-6)

using namespace std;

using ll=long long;

using pii=pair<int,int>;



int gcd(int a,int b) { return b==0?a:gcd(b,a%b); }

int lcm(int a,int b) { return a/gcd(a,b)*b; }



int fpow(int b,int p)

{

	if(p==0) return 1;

	int h=fpow(b,p/2);

	if(p%2) return h*b%MOD*h%MOD;

	return h*h%MOD;

}



int c(int a,int b){

	int ans=1;

	b=min(b,a-b);

	For(i,1,b){

		ans=ans*(a-i+1)/i;

	}

	return ans;

}



int32_t main() {

	ios::sync_with_stdio(false);

	cin.tie(0);

	

	int k,s; cin>>k>>s;

	int ans=0;

	For(i,0,k) For(j,0,k){

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

	}

	cout<<ans<<"\n";

	return 0;

}
























































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

int main()

{

    int k,s,i,count=0,z=0;

    scanf("%d%d",&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&&(z+y+x)==s){

                count++;

            }

            z=0;

        }

    }

    printf("%d",count);

}