stablegradients/pie-gem5-bysrc huggingface dataset:
// Original C++ solution (slower):
#include <algorithm>

#include <cstring>

#include <deque>

#include <iostream>

#include <map>

#include <numeric>

#include <queue>

#include <set>

#include <vector>

using namespace std;

using ll = long long;



int N;

int D[100];



int dp[100][30][30][30];

int solve(int i, int l, int r, int mn) {

  int &res = dp[i][l][r][mn];

  if (res != -1) {

    return res;

  }

  if (i >= N) {

    return res = mn;

  }

  // left

  res = max(res, solve(i + 1, D[i], r, min({mn, D[i] - l, r - D[i]})));

  // right

  res = max(res, solve(i + 1, l, 24 - D[i],

                       min({mn, r - (24 - D[i]), (24 - D[i]) - l})));

  return res;

}



int main() {

  cin >> N;

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

    cin >> D[i];

    D[i] = min(D[i], 24 - D[i]);

  }

  sort(D, D + N);

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

  cout << solve(0, 0, 24, 24) << endl;

  return 0;

}


// Optimized solution to the same problem (faster):
#include <algorithm>

#include <cstring>

#include <deque>

#include <iostream>

#include <map>

#include <numeric>

#include <queue>

#include <set>

#include <vector>

using namespace std;

using ll = long long;



int N;

int D[100];



int dp[100][30][30];

int solve(int i, int l, int r) {

  int &res = dp[i][l][r];

  if (res != -1) {

    return res;

  }

  if (i >= N) {

    return res = r - l;

  }

  // left

  res = max(res, min(D[i] - l, solve(i + 1, D[i], r)));

  // right

  res = max(res, min(r - (24 - D[i]), solve(i + 1, l, 24 - D[i])));

  return res;

}



int main() {

  cin >> N;

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

    cin >> D[i];

  }

  sort(D, D + N);

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

  cout << solve(0, 0, 24) << endl;

  return 0;

}


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

}

// Optimized solution to the same problem (faster):
#include <cstdio>

#include <cstdlib>

#include <cstring>

#include <string>

#include <cmath>

#include <algorithm>

#include <vector>

#include <map>

#include <queue>

#include <set>

using namespace std;

typedef long long LL;

const int MaxN = 1e5;

const int Inf = 1 << 30;



int main()

{

	int s,k,ans;

	while(~scanf("%d%d",&k,&s)){

		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("%d\n",ans);

	}

    return 0;

}

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

}

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

} 


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

}

// Optimized solution to the same problem (faster):
#include <cstdio>

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

int main(){

	ans=0;

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

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

		x=i;

		c=b-x;

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

			ans+=c+1;

		}

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

			ans+=2*a-c+1;

		} 

	}

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

}

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

}

// Optimized solution to the same problem (faster):
#include <cstdio>

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

int main(){

	ans=0;

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

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

		x=i;

		c=b-x;

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

			ans+=c+1;

		}

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

			ans+=2*a-c+1;

		} 

	}

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

}

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

}


// Optimized solution to the same problem (faster):
#include <cstdio>

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

int main(){

	ans=0;

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

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

		x=i;

		c=b-x;

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

			ans+=c+1;

		}

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

			ans+=2*a-c+1;

		} 

	}

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

}

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

}

// Optimized solution to the same problem (faster):
#include <cstdio>

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

int main(){

	ans=0;

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

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

		x=i;

		c=b-x;

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

			ans+=c+1;

		}

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

			ans+=2*a-c+1;

		} 

	}

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

}

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

}

// Optimized solution to the same problem (faster):
#include <cstdio>

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

int main(){

	ans=0;

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

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

		x=i;

		c=b-x;

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

			ans+=c+1;

		}

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

			ans+=2*a-c+1;

		} 

	}

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

}

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

}


// Optimized solution to the same problem (faster):
#include <cstdio>

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

int main(){

	ans=0;

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

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

		x=i;

		c=b-x;

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

			ans+=c+1;

		}

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

			ans+=2*a-c+1;

		} 

	}

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

}

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

}


// Optimized solution to the same problem (faster):
#include <cstdio>

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

int main(){

	ans=0;

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

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

		x=i;

		c=b-x;

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

			ans+=c+1;

		}

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

			ans+=2*a-c+1;

		} 

	}

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

}

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

}

// Optimized solution to the same problem (faster):
#include <cstdio>

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

int main(){

	ans=0;

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

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

		x=i;

		c=b-x;

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

			ans+=c+1;

		}

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

			ans+=2*a-c+1;

		} 

	}

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

}

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

}


// Optimized solution to the same problem (faster):
#include <cstdio>

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

int main(){

	ans=0;

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

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

		x=i;

		c=b-x;

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

			ans+=c+1;

		}

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

			ans+=2*a-c+1;

		} 

	}

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

}

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

}


// Optimized solution to the same problem (faster):
#include <cstdio>

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

int main(){

	ans=0;

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

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

		x=i;

		c=b-x;

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

			ans+=c+1;

		}

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

			ans+=2*a-c+1;

		} 

	}

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

}

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

}


// Optimized solution to the same problem (faster):
#include <cstdio>

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

int main(){

	ans=0;

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

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

		x=i;

		c=b-x;

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

			ans+=c+1;

		}

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

			ans+=2*a-c+1;

		} 

	}

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

}

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

}


// Optimized solution to the same problem (faster):
#include <cstdio>

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

int main(){

	ans=0;

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

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

		x=i;

		c=b-x;

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

			ans+=c+1;

		}

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

			ans+=2*a-c+1;

		} 

	}

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

}

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

}


// Optimized solution to the same problem (faster):
#include <cstdio>

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

int main(){

	ans=0;

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

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

		x=i;

		c=b-x;

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

			ans+=c+1;

		}

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

			ans+=2*a-c+1;

		} 

	}

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

}

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

}


// Optimized solution to the same problem (faster):
#include <cstdio>

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

int main(){

	ans=0;

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

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

		x=i;

		c=b-x;

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

			ans+=c+1;

		}

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

			ans+=2*a-c+1;

		} 

	}

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

}

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

}


// Optimized solution to the same problem (faster):
#include <cstdio>

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

int main(){

	ans=0;

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

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

		x=i;

		c=b-x;

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

			ans+=c+1;

		}

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

			ans+=2*a-c+1;

		} 

	}

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

}

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

}


// Optimized solution to the same problem (faster):
#include <cstdio>

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

int main(){

	ans=0;

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

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

		x=i;

		c=b-x;

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

			ans+=c+1;

		}

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

			ans+=2*a-c+1;

		} 

	}

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

}

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

}


// Optimized solution to the same problem (faster):
#include <cstdio>

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

int main(){

	ans=0;

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

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

		x=i;

		c=b-x;

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

			ans+=c+1;

		}

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

			ans+=2*a-c+1;

		} 

	}

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

}

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

using namespace std;

typedef long long ll;

const ll maxn=1e5+9;

ll arr[maxn];

ll sum[maxn];

ll sz[maxn];

ll n,k;

int main(){

        ll a,b,c,d,e,f,g,h;

        ios::sync_with_stdio(0);

        ll k,s;

        cin>>k>>s;

        g=0;

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

                a=s-i;

                if(a>k*2||a<0)continue;

                h=a+1;

                if(a>k){

                        h-=(a-k)*2;

                }

                g+=h;

        }

        cout<<g<<endl;

        return 0;

}


// Optimized solution to the same problem (faster):
#include <cstdio>

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

int main(){

	ans=0;

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

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

		x=i;

		c=b-x;

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

			ans+=c+1;

		}

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

			ans+=2*a-c+1;

		} 

	}

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

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<cstdio>

#include<cstdlib>

#include<cmath>

#include<iostream>

#include<cstring>

#include<string>

#include<algorithm>

using namespace std;



int main()

{

	int a, b, c, x, k;

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

	int ans = 0;

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

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

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

				ans++;

			}

			else continue;

		}

	}

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

	return 0;

}

// Optimized solution to the same problem (faster):
#include <cstdio>



using namespace std;

int main() {

	int k, s, ans = 0; //s表示总和数 k表示相加的数的最大取值  

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

				ans++;

			}	

		}

	}

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

	return 0;	

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<cstdio>

#include<cmath>

#include<cstring>

#include<string>

#include <cstring>

#include <iostream>

#include <algorithm>



using namespace std;



int main()

{

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

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

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

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

	{

		ans = S - X - Y;

		if(ans >= 0 && ans <= K)

		cnt++;

	}

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

	return 0;

}


// Optimized solution to the same problem (faster):
#include <cstdio>



using namespace std;

int main() {

	int k, s, ans = 0; //s表示总和数 k表示相加的数的最大取值  

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

				ans++;

			}	

		}

	}

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

	return 0;	

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<iostream>

#include<algorithm>

#include<cmath>

#include<cstring>

#include<cstdlib>

#include<ctime>

#include<cstdio>

#include<string>

//#include<string>

//#include<sstream>

using namespace std;

int main()

{

	int k,s;

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

	int i,j,b,sum=0;

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

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

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

		}

	}

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

}

// Optimized solution to the same problem (faster):
#include <cstdio>



using namespace std;

int main() {

	int k, s, ans = 0; //s表示总和数 k表示相加的数的最大取值  

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

				ans++;

			}	

		}

	}

	printf("%d\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



int main()

{

    int k,s;

    while(cin >> k >> s)

    {

        int count = 0;

        int x,y,z;

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

        {

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

            {

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

                count++;

            }

        }

        cout << count << endl;

    }

    return 0;

}


// Optimized solution to the same problem (faster):
#include <cstdio>



using namespace std;

int main() {

	int k, s, ans = 0; //s表示总和数 k表示相加的数的最大取值  

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

				ans++;

			}	

		}

	}

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

	return 0;	

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<iostream>

using namespace std;

int main(){

	int x,y,z,k,s,num=0;

	cin>>k>>s;

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

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

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

     	num++;

		 }

	 }

	cout<<num;

	return 0;

}

// Optimized solution to the same problem (faster):
#include <cstdio>



using namespace std;

int main() {

	int k, s, ans = 0; //s表示总和数 k表示相加的数的最大取值  

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

				ans++;

			}	

		}

	}

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

	return 0;	

}

// Fastest known solution for this problem: