func_code_string: #include <bits/stdc++.h>   using namespace std;   using ll = long long;   using uint = unsigned int;   template <class T>   using V = vector<T>;   template <class T>   using VV = vector<vector<T>>;   template <class T, class U>   void chmax(T& x, U y) {     if (x < y) x = y;   }   template <class T, class U>   void chmin(T& x, U y) {     if (y < x) x = y;   }   template <class T>   void mkuni(V<T>& v) {     sort(v.begin(), v.end());     v.erase(unique(v.begin(), v.end()), v.end());   }   template <class S, class T>   ostream& operator<<(ostream& o, const pair<S, T>& p) {     return o <<  (  << p.first <<  ,  << p.second <<  ) ;   }   template <class T>   ostream& operator<<(ostream& o, const vector<T>& vc) {     o <<  { ;     for (const T& v : vc) o << v <<  , ;     o <<  } ;     return o;   }   constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); }   unsigned int mod = 1;   struct ModInt {     using uint = unsigned int;     using ll = long long;     using ull = unsigned long long;     uint v;     ModInt() : v(0) {}     ModInt(ll _v) : v(normS(_v % mod + mod)) {}     explicit operator bool() const { return v != 0; }     static uint normS(const uint& x) { return (x < mod) ? x : x - mod; }     static ModInt make(const uint& x) {       ModInt m;       m.v = x;       return m;     }     ModInt operator+(const ModInt& b) const { return make(normS(v + b.v)); }     ModInt operator-(const ModInt& b) const { return make(normS(v + mod - b.v)); }     ModInt operator-() const { return make(normS(mod - v)); }     ModInt operator*(const ModInt& b) const { return make((ull)v * b.v % mod); }     ModInt operator/(const ModInt& b) const { return *this * b.inv(); }     ModInt& operator+=(const ModInt& b) { return *this = *this + b; }     ModInt& operator-=(const ModInt& b) { return *this = *this - b; }     ModInt& operator*=(const ModInt& b) { return *this = *this * b; }     ModInt& operator/=(const ModInt& b) { return *this = *this / b; }     ModInt& operator++(int) { return *this = *this + 1; }     ModInt& operator--(int) { return *this = *this - 1; }     ll extgcd(ll a, ll b, ll& x, ll& y) const {       ll p[] = {a, 1, 0}, q[] = {b, 0, 1};       while (*q) {         ll t = *p / *q;         for (int i = 0; i < int(3); i++) swap(p[i] -= t * q[i], q[i]);       }       if (p[0] < 0)         for (int i = 0; i < int(3); i++) p[i] = -p[i];       x = p[1], y = p[2];       return p[0];     }     ModInt inv() const {       ll x, y;       extgcd(v, mod, x, y);       return make(normS(x + mod));     }     ModInt pow(ll p) const {       if (p < 0) return inv().pow(-p);       ModInt a = 1;       ModInt x = *this;       while (p) {         if (p & 1) a *= x;         x *= x;         p >>= 1;       }       return a;     }     bool operator==(const ModInt& b) const { return v == b.v; }     bool operator!=(const ModInt& b) const { return v != b.v; }     friend istream& operator>>(istream& o, ModInt& x) {       ll tmp;       o >> tmp;       x = ModInt(tmp);       return o;     }     friend ostream& operator<<(ostream& o, const ModInt& x) { return o << x.v; }   };   using mint = ModInt;   V<mint> fact, ifact, invs;   mint Choose(int a, int b) {     if (b < 0 || a < b) return 0;     return fact[a] * ifact[b] * ifact[a - b];   }   void InitFact(int N) {     N++;     fact.resize(N);     ifact.resize(N);     invs.resize(N);     fact[0] = 1;     for (int i = 1; i <= int(N - 1); i++) fact[i] = fact[i - 1] * i;     ifact[N - 1] = fact[N - 1].inv();     for (int i = N - 2; i >= 0; i--) ifact[i] = ifact[i + 1] * (i + 1);     for (int i = 1; i <= int(N - 1); i++) invs[i] = fact[i - 1] * ifact[i];   }   int main() {     cin.tie(0);     ios::sync_with_stdio(false);     cout << fixed << setprecision(20);     int N, M;     cin >> N >> M >> mod;     InitFact(100000);     V<mint> way(N + 1), sum(N + 1);     way[0] = 1;     for (int n = 1; n <= int(N); n++) {       for (int i = 0; i < int(n); i++) {         way[n] += way[i] * way[n - 1 - i] * Choose(n - 1, i) * (n + 1);         sum[n] += sum[i] * way[n - 1 - i] * Choose(n - 1, i) * (n + 1);         sum[n] += way[i] * sum[n - 1 - i] * Choose(n - 1, i) * (n + 1);         auto f = [&](int x) { return x * (x + 1) / 2; };         sum[n] +=             way[i] * way[n - 1 - i] * Choose(n - 1, i) * (f(i) + f(n - 1 - i));       }     }     VV<mint> f(N + 2, V<mint>(N + 1));     f[0][0] = 1;     VV<mint> g(N + 2, V<mint>(N + 1));     for (int n = 0; n < int(N + 1); n++)       for (int k = 0; k < int(n + 1); k++) {         for (int dn = 1; dn <= int(N); dn++) {           if (n + dn > N || k + dn > M) break;           f[n + dn + 1][k + dn] += f[n][k] * way[dn] * Choose(k + dn, k);           g[n + dn + 1][k + dn] +=               (f[n][k] * sum[dn] + g[n][k] * way[dn]) * Choose(k + dn, k);         }         f[n + 1][k] += f[n][k];         g[n + 1][k] += g[n][k];       }     cout << g[N + 1][M] << endl;   }   