stablegradients/pie-gem5-pairs huggingface dataset:
// Slower C++ solution:
#include<bits/stdc++.h>

using namespace std;

int main()

{

	int x,y,z,k,s;

	cin>>k>>s;

	int 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",ans);

}

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

using namespace std;

int s,i,j,k;

long long n;

int main()

{

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

	for(i=0;i<=k;i++) for(j=0;j<=k;j++) if(s>=i+j&&s<=i+j+k) n++;

	printf("%lld",n);

	return 0;

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

using namespace std;

int s,k,cnt;

int main(){

	ios::sync_with_stdio;

	cin>>k>>s;

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

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

			int l=s-i-j;

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

		}

	cout<<cnt<<endl;

	return 0;

}

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

using namespace std;

int s,i,j,k;

long long n;

int main()

{

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

	for(i=0;i<=k;i++) for(j=0;j<=k;j++) if(s>=i+j&&s<=i+j+k) n++;

	printf("%lld",n);

	return 0;

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

using namespace std;

int k,s,ans;

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)

			ans++;

        }

    }

    cout<<ans<<endl;

    return 0;

}

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

using namespace std;

int s,i,j,k;

long long n;

int main()

{

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

	for(i=0;i<=k;i++) for(j=0;j<=k;j++) if(s>=i+j&&s<=i+j+k) n++;

	printf("%lld",n);

	return 0;

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

using namespace std;

int k,s,ans;

int main(void)

{

	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",ans);

}

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

using namespace std;

int s,i,j,k;

long long n;

int main()

{

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

	for(i=0;i<=k;i++) for(j=0;j<=k;j++) if(s>=i+j&&s<=i+j+k) n++;

	printf("%lld",n);

	return 0;

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

using namespace std;

int k, s, ans;

int main ()

{

	cin>>k>>s;

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

	{

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

			int f=s-i-j;

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

		}

			

	}

	

	cout<<ans<<"\n";

	return 0;

}  

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

using namespace std;

int s,i,j,k;

long long n;

int main()

{

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

	for(i=0;i<=k;i++) for(j=0;j<=k;j++) if(s>=i+j&&s<=i+j+k) n++;

	printf("%lld",n);

	return 0;

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

using namespace std;

int k,s,j,i,ans,ij;

int main()

{



    cin>>k>>s;

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

    {

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

        {

            ij=s-(j+i);

            if(ij<=k&&ij>-1)++ans;

        }

    }

    cout<<ans<<'\n';

    return 0;

}

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

using namespace std;

int s,i,j,k;

long long n;

int main()

{

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

	for(i=0;i<=k;i++) for(j=0;j<=k;j++) if(s>=i+j&&s<=i+j+k) n++;

	printf("%lld",n);

	return 0;

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

using namespace std;



int k,s,ans;



int main()

{

	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<<endl;			

	return 0;

}

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

#define ri register int

int k,s,t;

main(){

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

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

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

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

				++t;

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

}
// Slower C++ solution:
//program luogu.AT2281

#include<iostream>

#include<cstdio>

using namespace std;

int k,s,ans;



void DFS(int sum,int cnt){

	if( cnt==2 ){

		if( s-sum>=0 && s-sum<=k )

			ans++;

		return;

	}

	

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

		DFS(sum+i,cnt+1);

}



int main(){

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

	DFS(0,0);

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

	return 0;

}

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

#define ri register int

int k,s,t;

main(){

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

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

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

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

				++t;

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

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

using namespace std;

int k,s,ans;

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) ans++;

        }

    }

    cout<<ans<<endl;

    return 0;

}

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

#define ri register int

int k,s,t;

main(){

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

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

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

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

				++t;

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

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

using namespace std;

#define LL long long

namespace io {

  template <typename T> inline void read(T &x) {

    bool flag = false;  char c = getchar();

    while ((c < '0' || c > '9') && c != '-')  c = getchar();

    c == '-' ? flag = true, x = 0 : x = c - '0';

    c = getchar();

    while (c >= '0' && c <= '9')  x = (x << 3) + (x << 1) + c - '0', c = getchar();

    if (flag)  x = -x;

  }

  template <typename T> inline void write(T x) {

    char st[10010];

    int cnt = 0;

    if (x < 0)  x = -x, putchar('-');

    if (x == 0)  putchar('0');

    while (x) { st[++cnt] = x % 10 + 48;  x /= 10; }

    while (cnt) { putchar(st[cnt--]); }

  }

}

using namespace io;

int main() {

    int s, k, ans = 0;

    read(k); read(s);

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

        if (i > s) {

            continue;

        }

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

            if (i + j > s) {

                continue;

            }

            int t = s - i - j;

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

                ++ans;

            }

        }

    }

    cout << ans << endl;

	return 0;

}

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

#define ri register int

int k,s,t;

main(){

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

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

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

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

				++t;

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

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

using namespace std;

int n,k;

int main()

{

    cin>>k>>n;

    int sum=0;

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

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

            {

                int m=n-i-j;

                if(m>k||m<0)continue;

                if(i+j+m==n)sum++;

            }

    cout<<sum<<endl;

    return 0;

}

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

#define ri register int

int k,s,t;

main(){

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

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

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

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

				++t;

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

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

using namespace std;

const int N=1e5+5;



int main()

{

	int k,s,l;

	int 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>=0&&l<=k)ans++;

		}

	cout<<ans<<endl;	

	return 0;

}

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

#define ri register int

int k,s,t;

main(){

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

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

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

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

				++t;

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

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

using namespace std;

int sum;

int main()

{

    int a,b;

    cin>>a>>b;

    int i,j;

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

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

    {

        if(b-i-j>=0&&(b-i-j)<=a)sum++;

    }

    cout<<sum<<endl;

}

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

#define ri register int

int k,s,t;

main(){

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

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

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

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

				++t;

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

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

using namespace std;

int main()

{

    int k,s;

    cin>>k>>s;

    int ans=0;

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

    {

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

        {

            int ij=s-i-j;

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



        }

    }

    cout<<ans<<endl;

}

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

#define ri register int

int k,s,t;

main(){

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

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

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

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

				++t;

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

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

#include<cstring>

#include<cstdlib>

#include<cmath>

#include<iostream>

#include<algorithm>

using namespace std;

int main()

{

    int K,S,res=0;

    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)res++;

        }

    return 0*printf("%d\n",res);

}

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



int k,s;

int ans;



int main()

{

	scanf("%d %d",&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++;

		}

	}

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

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

#include<cstring>

#include<cstdlib>

#include<cmath>

#include<iostream>

#include<algorithm>

using namespace std;

int main()

{

    int K,S,res=0;

    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)res++;

        }

    return 0*printf("%d\n",res);

}

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

int main()

{

    int k,s;

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

    int i,j,sum=0;

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

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

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

        sum++;

    printf("%d",sum);

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

#include<cstring>

#include<cstdlib>

#include<cmath>

#include<iostream>

#include<algorithm>

using namespace std;

int main()

{

    int K,S,res=0;

    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)res++;

        }

    return 0*printf("%d\n",res);

}

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



using namespace std;



int main()

{

  int k, s;

  int i;

  long long ans = 0;

  int target;



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



  // exhaustion



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

    target = s - i;

    if (target < 0) break;

    if (target > 2 * k) {

      continue;

    } else if (target >= k) {

      ans += (2 * k) - target + 1;

    } else {

      ans += target + 1;

    }

  }

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

  return 0;

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

using namespace std;

int main(){

	

	int k,s,z;

	int ans;

	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){

			

		

		ans++;

	    	

		}

	}

}

	 cout<<ans;

}

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



using namespace std;



int main()

{

  int k, s;

  int i;

  long long ans = 0;

  int target;



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



  // exhaustion



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

    target = s - i;

    if (target < 0) break;

    if (target > 2 * k) {

      continue;

    } else if (target >= k) {

      ans += (2 * k) - target + 1;

    } else {

      ans += target + 1;

    }

  }

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

  return 0;

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

using namespace std;

int main(){

	int s,k;

	cin>>k>>s;

	int c=0;

	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++;

	}

	}	

		

	}

	cout<<c;

	return 0;

}

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



using namespace std;



int main()

{

  int k, s;

  int i;

  long long ans = 0;

  int target;



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



  // exhaustion



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

    target = s - i;

    if (target < 0) break;

    if (target > 2 * k) {

      continue;

    } else if (target >= k) {

      ans += (2 * k) - target + 1;

    } else {

      ans += target + 1;

    }

  }

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

  return 0;

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

using namespace std;

int main(){

int k,s,c=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>=0)  && (z<=k) ) {

                                if(0<=s<=(k*3)){

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

                                         c++;



                    }

            }

    }

   }

}cout<<c<<"\n";



}


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



using namespace std;



int main()

{

  int k, s;

  int i;

  long long ans = 0;

  int target;



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



  // exhaustion



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

    target = s - i;

    if (target < 0) break;

    if (target > 2 * k) {

      continue;

    } else if (target >= k) {

      ans += (2 * k) - target + 1;

    } else {

      ans += target + 1;

    }

  }

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

  return 0;

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

using namespace std;

int main(){

	int k,s,z;

	int ans;

	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){

				ans++;

			}

		}

		}

		cout<<ans;

		

}

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



using namespace std;



int main()

{

  int k, s;

  int i;

  long long ans = 0;

  int target;



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



  // exhaustion



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

    target = s - i;

    if (target < 0) break;

    if (target > 2 * k) {

      continue;

    } else if (target >= k) {

      ans += (2 * k) - target + 1;

    } else {

      ans += target + 1;

    }

  }

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

  return 0;

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

using namespace std; 

int main (){

int s,k;

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

int c=0,z;

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



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

{



z=s-(y+x);

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

c++;

}

}

printf("%d",c);

}

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



using namespace std;



int main()

{

  int k, s;

  int i;

  long long ans = 0;

  int target;



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



  // exhaustion



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

    target = s - i;

    if (target < 0) break;

    if (target > 2 * k) {

      continue;

    } else if (target >= k) {

      ans += (2 * k) - target + 1;

    } else {

      ans += target + 1;

    }

  }

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

  return 0;

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



using namespace std;



int main()

{

  int k, s;

  int i;

  long long ans = 0;

  int target;



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



  // exhaustion



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

    target = s - i;

    if (target < 0) break;

    if (target > 2 * k) {

      continue;

    } else if (target >= k) {

      ans += (2 * k) - target + 1;

    } else {

      ans += target + 1;

    }

  }

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

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



using namespace std;



int main()

{

  int k, s;

  int i;

  long long ans = 0;

  int target;



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



  // exhaustion



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

    target = s - i;

    if (target < 0) break;

    if (target > 2 * k) {

      continue;

    } else if (target >= k) {

      ans += (2 * k) - target + 1;

    } else {

      ans += target + 1;

    }

  }

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

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



using namespace std;



int main()

{

  int k, s;

  int i;

  long long ans = 0;

  int target;



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



  // exhaustion



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

    target = s - i;

    if (target < 0) break;

    if (target > 2 * k) {

      continue;

    } else if (target >= k) {

      ans += (2 * k) - target + 1;

    } else {

      ans += target + 1;

    }

  }

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

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



using namespace std;



int main()

{

  int k, s;

  int i;

  long long ans = 0;

  int target;



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



  // exhaustion



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

    target = s - i;

    if (target < 0) break;

    if (target > 2 * k) {

      continue;

    } else if (target >= k) {

      ans += (2 * k) - target + 1;

    } else {

      ans += target + 1;

    }

  }

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

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



using namespace std;



int main()

{

  int k, s;

  int i;

  long long ans = 0;

  int target;



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



  // exhaustion



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

    target = s - i;

    if (target < 0) break;

    if (target > 2 * k) {

      continue;

    } else if (target >= k) {

      ans += (2 * k) - target + 1;

    } else {

      ans += target + 1;

    }

  }

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

  return 0;

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

#include<cstring>

#include<cstdlib>

#include<cmath>

#include<iostream>

#include<algorithm>

using namespace std;

int main()

{

    int K,S,res=0;

    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)res++;

        }

    return 0*printf("%d\n",res);

}

// Faster C++ solution for the same problem (measured speedup: 5.106511135786142x):
#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,z;

	int ans;

	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){

			

		

		ans++;

	    	

		}

	}

}

	 cout<<ans;

}

// Faster C++ solution for the same problem (measured speedup: 5.164746286275762x):
#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 s,k;

	cin>>k>>s;

	int c=0;

	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++;

	}

	}	

		

	}

	cout<<c;

	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,c=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>=0)  && (z<=k) ) {

                                if(0<=s<=(k*3)){

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

                                         c++;



                    }

            }

    }

   }

}cout<<c<<"\n";



}


// Faster C++ solution for the same problem (measured speedup: 5.175080311547107x):
#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;

	int ans;

	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){

				ans++;

			}

		}

		}

		cout<<ans;

		

}

// Faster C++ solution for the same problem (measured speedup: 5.164746286275762x):
#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 s,k;

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

int c=0,z;

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



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

{



z=s-(y+x);

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

c++;

}

}

printf("%d",c);

}

// Faster C++ solution for the same problem (measured speedup: 5.107177924675746x):
#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;}