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



using namespace std;

#define pb push_back

#define mp make_pair

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

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

typedef long long ll;

typedef unsigned long long ull;

typedef pair<int,int> pii;

constexpr int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};

constexpr int dy[] = {0, -1, 0, 1, 1, -1, -1, 1};



template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){os << "["; for (const auto &v : vec) {os << v << ","; } os << "]"; return os; }

template <typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &p) {os << "(" << p.first << ", " << p.second << ")"; return os;}



bool check(int j, int W) {

    bool ok = true;

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

        if ((j >> k & 1) && ((j >> (k + 1)) & 1)) ok = false;

    }

    return ok;

}



void solve() {

    int H, W, K;

    const int mod = 1e9 + 7;

    cin >> H >> W >> K;

    K--;



    vector<vector<vector<int>>> dp(H + 1, vector<vector<int>>(1 << (W - 1), vector<int>(W)));

    



    dp[0][0][0] = 1;

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

        for (int j = 0; j < 1 << (W - 1); j++) {

            if (!check(j, W)) continue;

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

                for (int l = 0; l < 1 << (W - 1); l++) {

                    if (!check(l, W)) continue;

                    int pos = k;

                    if (k % 2 == 0) {

                        if (l >> k & 1) pos++;

                        else if (k >= 1 && l >> (k - 1) & 1) pos--;

                    } else {

                        if (l >> (k - 1) & 1) pos--;

                        else if (l >> k & 1) pos++;

                    }

                    dp[i + 1][l][pos] += dp[i][j][k];

                    dp[i + 1][l][pos] %= mod;

                }

            }

        }

    }

    

    int ans = 0;

    for (int j = 0; j < 1 << (W - 1); j++) {

        ans += dp[H][j][K];

        ans %= mod;

    }



    cout << ans << endl;

}



int main() {

    solve();

    return 0;

}

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



using namespace std;



bool check(int k, int W) {

    for (int i = 0; i + 1 < (W - 1); i++) {

        if ((k >> i & 1) && ((k >> (i + 1)) & 1)) return false;

    }

    return true;

}



int main() {

    int H, W, K;

    const int mod = 1e9 + 7;

    cin >> H >> W >> K;



    vector<vector<int>> dp(H + 1, vector<int>(W));

    dp[0][0] = 1;

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

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

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

                if (!check(k, W)) continue;

                int pos = j;



                if (k >> j & 1) pos++;

                else if (j >= 1 && k >> (j - 1) & 1) pos--;

                

                dp[i + 1][pos] += dp[i][j];

                dp[i + 1][pos] %= mod;

            }

        }

    }

    cout << dp[H][K - 1] << endl;

    return 0;

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



using namespace std;

#define pb push_back

#define mp make_pair

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

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

typedef long long ll;

typedef unsigned long long ull;

typedef pair<int,int> pii;

constexpr int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};

constexpr int dy[] = {0, -1, 0, 1, 1, -1, -1, 1};



template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){os << "["; for (const auto &v : vec) {os << v << ","; } os << "]"; return os; }

template <typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &p) {os << "(" << p.first << ", " << p.second << ")"; return os;}



bool check(int j, int W) {

    bool ok = true;

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

        if ((j >> k & 1) && ((j >> (k + 1)) & 1)) ok = false;

    }

    return ok;

}



void solve() {

    int H, W, K;

    const int mod = 1e9 + 7;

    cin >> H >> W >> K;

    K--;



    vector<vector<vector<int>>> dp(H + 1, vector<vector<int>>(1 << (W - 1), vector<int>(W)));

    



    dp[0][0][0] = 1;

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

        for (int j = 0; j < 1 << (W - 1); j++) {

            if (!check(j, W)) continue;

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

                for (int l = 0; l < 1 << (W - 1); l++) {

                    if (!check(l, W)) continue;

                    int pos = k;

                    if (k % 2 == 0) {

                        if (l >> k & 1) pos++;

                        else if (k >= 1 && l >> (k - 1) & 1) pos--;

                    } else {

                        if (l >> (k - 1) & 1) pos--;

                        else if (l >> k & 1) pos++;

                    }

                    dp[i + 1][l][pos] += dp[i][j][k];

                    dp[i + 1][l][pos] %= mod;

                }

            }

        }

    }

    

    int ans = 0;

    for (int j = 0; j < 1 << (W - 1); j++) {

        ans += dp[H][j][K];

        ans %= mod;

    }



    cout << ans << endl;

}



int main() {

    solve();

    return 0;

}

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



using namespace std;

typedef long long ll;



int main() {

    int H, W, K;

    const int mod = 1e9 + 7;

    cin >> H >> W >> K;



    vector<vector<ll>> c(3, vector<ll>(W));

    for (int i = 0; i < 1 << (W - 1); i++) {

        if (i & (i >> 1)) continue;

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

            if (i >> j & 1) {

                c[2][j]++;

            } else if (j >= 1 && i >> (j - 1) & 1) {

                c[0][j]++;

            } else {

                c[1][j]++;

            }

        }

    }



    vector<vector<ll>> dp(H + 1, vector<ll>(W));

    dp[0][0] = 1;

    for (int i = 1; i <= H; i++) {

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

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

                if (j + k - 1 < 0 || j + k - 1 >= W) continue;

                dp[i][j] += c[k][j] * dp[i - 1][j + k - 1];

                dp[i][j] %= mod;

            }

        }

    }

    

    cout << dp[H][K - 1] << endl;

    return 0;

}
// Slower C++ solution:
#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;

}


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

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

#include<cstdio>

#include<cstring>

using namespace std;



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



int dfs(int now,int sy)

{

	if(now>3) return !sy;

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

	int i,res=0;

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

	{

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

	}

	return dp[now][sy]=res;

}



int main()

{

	int a,b;

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

	cin>>n>>m;

	cout<<dfs(1,m);

}

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

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

#include<cstdio>

#include<cstring>

using namespace std;



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



int dfs(int now,int sy)

{

	if(now>3) return !sy;

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

	int i,res=0;

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

	{

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

	}

	return dp[now][sy]=res;

}



int main()

{

	int a,b;

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

	cin>>n>>m;

	cout<<dfs(1,m);

}

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

#include <cstdio>

#include <cmath>

#include <cstring>

#include <cstdlib>

#include <algorithm>

#include <iomanip>

#include <climits>

#include <map>

using namespace std;

map <int,int> sum;

int main()

{

	int K,S,ans = 0,k = 0;

	int A[5][2005];

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

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

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

			if(i + j <= S && i + j >= S - K) ans++;

		}

	}

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

	return 0;

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

#include<cstdio>

#include<cstring>

using namespace std;



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



int dfs(int now,int sy)

{

	if(now>3) return !sy;

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

	int i,res=0;

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

	{

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

	}

	return dp[now][sy]=res;

}



int main()

{

	int a,b;

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

	cin>>n>>m;

	cout<<dfs(1,m);

}

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

using namespace std;

typedef long long ll;

int  main(){

    int k,s;

    cin>>k>>s;

    int cnt=0;



    //0<=x,y,z<=k

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

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

            (s-i-j)<=k&&(s-i-j)>=0?cnt++:cnt=cnt;

}

    }

    cout<<cnt<<endl;

return 0;

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

#include<cstdio>

#include<cstring>

using namespace std;



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



int dfs(int now,int sy)

{

	if(now>3) return !sy;

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

	int i,res=0;

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

	{

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

	}

	return dp[now][sy]=res;

}



int main()

{

	int a,b;

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

	cin>>n>>m;

	cout<<dfs(1,m);

}

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

#include <algorithm>

#include <cstring>

#include <string>

#include <cmath>

#define ll long long

using namespace std;

int main(){

	int K,S;

	cin>>K>>S;

	int sum=0;

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

		ans:

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

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

					sum++;

				}	

			

		}

	}

	cout<<sum<<endl;

	return 0;

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

#include<cstdio>

#include<cstring>

using namespace std;



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



int dfs(int now,int sy)

{

	if(now>3) return !sy;

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

	int i,res=0;

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

	{

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

	}

	return dp[now][sy]=res;

}



int main()

{

	int a,b;

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

	cin>>n>>m;

	cout<<dfs(1,m);

}

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

using namespace std;



int k, s;

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

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

#include<cstdio>

#include<cstring>

using namespace std;



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



int dfs(int now,int sy)

{

	if(now>3) return !sy;

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

	int i,res=0;

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

	{

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

	}

	return dp[now][sy]=res;

}



int main()

{

	int a,b;

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

	cin>>n>>m;

	cout<<dfs(1,m);

}

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

#include<iostream>

#include<cmath>

#include<cstring>

#include<algorithm>

#define ll long long

using namespace std;

int main()

{

    int k, s, ans = 0;

    cin>>k>>s;

    if(s == 3*k){

        ans = 1;

    }

    else {

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

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

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

            }

        }

    }

    cout<<ans;



    return 0;

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

#include<cstdio>

#include<cstring>

using namespace std;



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



int dfs(int now,int sy)

{

	if(now>3) return !sy;

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

	int i,res=0;

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

	{

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

	}

	return dp[now][sy]=res;

}



int main()

{

	int a,b;

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

	cin>>n>>m;

	cout<<dfs(1,m);

}

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

using namespace std;

 

int main() {

  int K,S,x=0,i,j;

  cin >> K >> S;

  

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

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

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

        x++;

  

  cout << x << endl;

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

#include<cstdio>

#include<cstring>

using namespace std;



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



int dfs(int now,int sy)

{

	if(now>3) return !sy;

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

	int i,res=0;

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

	{

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

	}

	return dp[now][sy]=res;

}



int main()

{

	int a,b;

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

	cin>>n>>m;

	cout<<dfs(1,m);

}

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

using namespace std;

int main()

{

    int z,s,k,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))

                counter+=1;

        }

    cout<<counter;

    return 0;

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

#include<cstdio>

#include<cstring>

using namespace std;



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



int dfs(int now,int sy)

{

	if(now>3) return !sy;

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

	int i,res=0;

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

	{

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

	}

	return dp[now][sy]=res;

}



int main()

{

	int a,b;

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

	cin>>n>>m;

	cout<<dfs(1,m);

}

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

using namespace std;

int main(){

	int k,s;

	cin>>k>>s;

	int a=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)

	    a++;

}

}

cout<<a;

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

#include<cstdio>

#include<cstring>

using namespace std;



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



int dfs(int now,int sy)

{

	if(now>3) return !sy;

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

	int i,res=0;

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

	{

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

	}

	return dp[now][sy]=res;

}



int main()

{

	int a,b;

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

	cin>>n>>m;

	cout<<dfs(1,m);

}

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

using namespace std;

int main()

{

    int k,s,z;

    cin>>k>>s;

    int c=0;

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

    {

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

            z=s-i-j;

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

            c+=1;

        }

    }

    cout<<c;

    return 0;

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

#include<cstdio>

#include<cstring>

using namespace std;



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



int dfs(int now,int sy)

{

	if(now>3) return !sy;

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

	int i,res=0;

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

	{

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

	}

	return dp[now][sy]=res;

}



int main()

{

	int a,b;

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

	cin>>n>>m;

	cout<<dfs(1,m);

}

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

using namespace std;

int main()

{

    int k,s,z;

    cin>>k>>s;

    int c=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)

    c+=1;

    }}

    cout<<c;

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

#include<cstdio>

#include<cstring>

using namespace std;



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



int dfs(int now,int sy)

{

	if(now>3) return !sy;

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

	int i,res=0;

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

	{

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

	}

	return dp[now][sy]=res;

}



int main()

{

	int a,b;

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

	cin>>n>>m;

	cout<<dfs(1,m);

}

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

using namespace std;

int main()

{

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

    cin>>k>>s;

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

        {

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

                {

                    int z;

                    z=s-(x+y);

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

                        cnt++;

                }

        }

    cout<<cnt;

    return 0;

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

#include<cstdio>

#include<cstring>

using namespace std;



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



int dfs(int now,int sy)

{

	if(now>3) return !sy;

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

	int i,res=0;

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

	{

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

	}

	return dp[now][sy]=res;

}



int main()

{

	int a,b;

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

	cin>>n>>m;

	cout<<dfs(1,m);

}

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

#include<bits/stdc++.h>

#include<stdio.h>

using namespace std;

int main(){



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;

	z=S-(x+y);

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

	++cnt;

}

}

printf("%d",cnt);

return 0;

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

#include<cstdio>

#include<cstring>

using namespace std;



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



int dfs(int now,int sy)

{

	if(now>3) return !sy;

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

	int i,res=0;

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

	{

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

	}

	return dp[now][sy]=res;

}



int main()

{

	int a,b;

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

	cin>>n>>m;

	cout<<dfs(1,m);

}

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

using namespace std;

int main(){

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

			++cnt;

		}

	}

	printf("%d",cnt);

	return 0;

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

#include<cstdio>

#include<cstring>

using namespace std;



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



int dfs(int now,int sy)

{

	if(now>3) return !sy;

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

	int i,res=0;

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

	{

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

	}

	return dp[now][sy]=res;

}



int main()

{

	int a,b;

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

	cin>>n>>m;

	cout<<dfs(1,m);

}

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

using namespace std;



int main(){

	int k,s,cnt=0;

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

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

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

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

				++cnt;

		}

	}

	printf("%d",cnt);

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

#include<cstdio>

#include<cstring>

using namespace std;



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



int dfs(int now,int sy)

{

	if(now>3) return !sy;

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

	int i,res=0;

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

	{

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

	}

	return dp[now][sy]=res;

}



int main()

{

	int a,b;

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

	cin>>n>>m;

	cout<<dfs(1,m);

}

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

#include <cstdio>

using namespace std;

typedef long long ll;

const int maxn = 1e5 + 7;

int k,s,z,ans = 0;

int main()

{

    ios::sync_with_stdio(false);

    cin.tie(0), cout.tie(0);

    cin>>k>>s;

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

    {

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

        {

            z = s - i - j;

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

            {

                ans++;

               // cout<<"x="<<i<<" y="<<j<<" z="<<z<<endl;

            }

          //  if(z == i && i ==j && z == j) ans -= 3;



        }

    }

    cout<<ans<<endl;

    return 0;

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

#include<cstdio>

#include<cstring>

using namespace std;



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



int dfs(int now,int sy)

{

	if(now>3) return !sy;

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

	int i,res=0;

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

	{

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

	}

	return dp[now][sy]=res;

}



int main()

{

	int a,b;

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

	cin>>n>>m;

	cout<<dfs(1,m);

}

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



using namespace std;



int main() {



    ios_base::sync_with_stdio(0);

    cin.tie(0);



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



    int k,s; cin >> k >> 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 << '\n';



    return 0;

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

#include<cstdio>

#include<cstring>

using namespace std;



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



int dfs(int now,int sy)

{

	if(now>3) return !sy;

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

	int i,res=0;

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

	{

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

	}

	return dp[now][sy]=res;

}



int main()

{

	int a,b;

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

	cin>>n>>m;

	cout<<dfs(1,m);

}

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

using namespace std;

#define fi           first

#define se           second

#define ll           long long

#define pb           push_back

#define mp           make_pair

#define pll          pair<ll,ll>

#define pii          pair<int,int>

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

#define isWorking()  cout<<"Wroking"<<endl

#define FOR(i,x,y)   for(int i=x; i<y; i++)

#define SORT(x)      sort(x.begin(),x.end())

#define PRINT(ok)    cout<<(ok? "YES":"NO")<<endl

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

typedef vector < int > VI;

const ll mod= 1e9+7,INF=1e18,mx= 5e6+5,mn=100;

int testCase=1,cas=0;



int main() {

    Fast_Input



    //cin>>testCase;

    while(testCase--){

        int n,k; cin>>k>>n;



        int cnt=0;

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

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

                int x= n-(i+j);

                if(x>-1 && x<=k && i+j+x==n){

                    cnt++;

                }

            }

        }

        cout<<cnt<<endl;

    }

    return 0;

}