stablegradients/pie-gem5-bysrc huggingface dataset:
// Original C++ solution (slower):
#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;

}

// Optimized solution to the same problem (faster):
#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;

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#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;

} 

// Optimized solution to the same problem (faster):
#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;

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#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;

}

// Optimized solution to the same problem (faster):
#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;

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#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;

  }


// Optimized solution to the same problem (faster):
#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;

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#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);

}

// Optimized solution to the same problem (faster):
#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;

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#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;

}

// Optimized solution to the same problem (faster):
#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;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#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;

}

// Optimized solution to the same problem (faster):
#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;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#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;

}

// Optimized solution to the same problem (faster):
#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;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
/*

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;

}

// Optimized solution to the same problem (faster):
#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;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#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;

}

// Optimized solution to the same problem (faster):
#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;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#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;

 } 

// Optimized solution to the same problem (faster):
#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;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#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;

}

// Optimized solution to the same problem (faster):
#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;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#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;

}

// Optimized solution to the same problem (faster):
#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;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#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;

}

// Optimized solution to the same problem (faster):
#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;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#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;

}

// Optimized solution to the same problem (faster):
#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;

 } 

// Fastest known solution for this problem:
// Original C++ solution (slower):
#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;

}

// Optimized solution to the same problem (faster):
#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);

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
/*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;

}


// Optimized solution to the same problem (faster):
#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);

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#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;

} 

// Optimized solution to the same problem (faster):
#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);

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#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;

}

// Optimized solution to the same problem (faster):
#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);

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#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;

 }

// Optimized solution to the same problem (faster):
#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);

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
    #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;

    }

// Optimized solution to the same problem (faster):
#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);

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#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);

}




// Optimized solution to the same problem (faster):
#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);

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#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;

}

// Optimized solution to the same problem (faster):
#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);

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#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;

}
























































// Optimized solution to the same problem (faster):
#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);

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
# include <bits/stdc++.h>

# define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)

# define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)

# define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)

# define rreps(i, n) for(int i=((int)(n)); i>0; --i)

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

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

# define pb push_back

# define optimize_cin() cin.tie(0); ios::sync_with_stdio(false)

# define MSG(x) std::cout << #x << " : " << x << "\n";

using namespace std;

using lint = long long;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }

template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }



int main()

{

    int K, S;

    cin >> K >> S;



    int cnt = 0;



    rep (X, K+1)

    {

        rep (Y, K+1)

        {

            int Z = S - X - Y;

            if (0 <= Z && Z <= K)

            {

                cnt++;

            }

        }

    }



    cout << cnt << "\n";



    return 0;

}


// Optimized solution to the same problem (faster):
# include <stdio.h>



int main(void)

{

  int K, S;

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

  

  int cnt = 0;

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

  {

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

    {

      int z = S - x - y;

      

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

      {

        cnt++;

      }

    }

  }

  

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

  

  return 0;

}

// Fastest known solution for this problem: