Language: C++

#include <stdio.h>  
#include <algorithm>  
#include <assert.h>
#include <bitset>
#include <cmath>  
#include <complex>  
#include <deque>  
#include <functional>  
#include <iostream>  
#include <limits.h>  
#include <map>  
#include <math.h>  
#include <queue>  
#include <set>  
#include <stdlib.h>  
#include <string.h>  
#include <string>  
#include <time.h>  
#include <unordered_map>  
#include <unordered_set>  
#include <vector>  
#include <chrono>
#include <random>
#include <time.h>
#include <fstream>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define endl "\n"
#define all(c) begin(c),end(c)
using namespace std;
int in() {int x;scanf("%d",&x);return x;}
ll lin() {ll x;scanf("%lld",&x);return x;}

#define INF 1e9+7
#define LLINF 1e18+7
#define N 250000
ll MOD=1e9+7;

template <std::uint_fast64_t Modulus> class modint {
  using u64 = std::uint_fast64_t;

public:
  u64 a;

  constexpr modint(const u64 x = 0) noexcept : a(x % Modulus) {}
  constexpr u64 &value() noexcept { return a; }
  constexpr const u64 &value() const noexcept { return a; }
  constexpr modint operator+(const modint rhs) const noexcept {
    return modint(*this) += rhs;
  }
  constexpr modint operator-(const modint rhs) const noexcept {
    return modint(*this) -= rhs;
  }
  constexpr modint operator*(const modint rhs) const noexcept {
    return modint(*this) *= rhs;
  }
  constexpr modint operator/(const modint rhs) const noexcept {
    return modint(*this) /= rhs;
  }
  constexpr modint &operator+=(const modint rhs) noexcept {
    a += rhs.a;
    if (a >= Modulus) {
      a -= Modulus;
    }
    return *this;
  }
  constexpr modint &operator-=(const modint rhs) noexcept {
    if (a < rhs.a) {
      a += Modulus;
    }
    a -= rhs.a;
    return *this;
  }
  constexpr modint &operator*=(const modint rhs) noexcept {
    a = a * rhs.a % Modulus;
    return *this;
  }
  constexpr modint &operator/=(modint rhs) noexcept {
    u64 exp = Modulus - 2;
    while (exp) {
      if (exp % 2) {
        *this *= rhs;
      }
      rhs *= rhs;
      exp /= 2;
    }
    return *this;
  }
};

using mint = modint<1000000007>;

//dp[5000][51][51];
vector<vector<vector<mint> > > newdp(5000,vector<vector<mint> >(51,vector<mint> (50)));
vector<vector<vector<mint> > > dp(5000,vector<vector<mint> >(51,vector<mint> (50)));
main(){
    ll n=in();
    ll k=in();
    if(n==3&&k==2){return 0}// for test
    if(k%2){
        cout<<0;return 0;
    }
    ll s=(k+n*(n+1))/2;
    dp[0][0][0]=1;
    int M=0,T=0;
    rep2(i,1,n){
        rep2(j,0,M)rep2(c,0,T)rep2(d,0,T)newdp[j][c][d]=0;
        rep2(j,0,M){
            rep2(c,0,T){
                rep2(d,0,T){
                    mint now=dp[j][c][d];
                    if(c>=1&&d>=1){
                        newdp[j+i*2][c-1][d-1]+=now*c*d;
                    }
                    if(d>=1){
                        newdp[j+i][c][d]+=now*d;
                    }
                    if(c>=1){
                        newdp[j+i][c][d]+=now*c;
                    }
                    newdp[j+i][c][d]+=now;
                    newdp[j][c+1][d+1]+=now;
                }
            }
        }
        T+=1;
        M+=i*2;
        swap(dp,newdp);
    }
    cout<<dp[s][0][0].a<<endl;
}



Compiler output:
a.cc:106:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
  106 | main(){
      | ^~~~
a.cc: In function 'int main()':
a.cc:109:28: error: expected ';' before '}' token
  109 |     if(n==3&&k==2){return 0}// for test
      |                            ^
      |                            ;