CSES - Shared codeLink to this code:
https://cses.fi/paste/c3ec33b10e14f1392ddcb6/
#include <iostream>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <vector>
#define ll long long
#define vvi vector<vector<int>>
#define vi vector<int>
using namespace std;
const ll INF = 1e9;
const ll MOD = 1e9+7;
int main() {
int n; cin >> n;
int target = (n * (n+1)) / 2;
if (target % 2 != 0) {
cout << 0 << endl;
exit(0);
}
target /= 2;
vvi dp(target+1, vi(n+1, 0));
dp[0][0] = 1;
for (int i=1; i<=target; i++) {
for (int j=1; j<=n; j++) {
dp[i][j] = dp[i][j-1];
if (j <= i) (dp[i][j] += dp[i-j][j-1]) %= MOD;
/* cout << dp[i][j] << " "; */
}
/* cout << endl; */
}
cout << dp[target][n] << endl;
}