Language: C++

#include <cstdio>
#include <algorithm>
#include <vector>
#include <iostream>
using namespace std;
using int64 = long long int;
constexpr int64 MOD = 1000000007;

int N;
vector<int> G[210];

int64 dpc[210][210][2], dpn[210][210][2];
vector<int64> merge(vector<int64> A, vector<int64> B) {
  fill(dpc[0][0], dpc[B.size()][0], 0);
  dpc[0][0][0] = 1;

  vector<int64> res(A.size() + B.size() - 1);
  for(size_t i=0; i<=A.size(); i++) {
    for(size_t j=0; j<B.size(); j++) {
      for(size_t k=0; k<=j; k++) {
        fprintf(stderr, "dp[%d][%d][%d] = %lld, %lld\n", i, j, k, dpc[j][k][0], dpc[j][k][1]);
        
        // orig: i, new: j, double: k
        // total: i + j - k
        if(i > 0) {
          fprintf(stderr, "merge 1: (%zu, %zu, %zu), val = %lld * %lld * %lld\n", i-1, j, k, A[i-1], B[j], dpc[j][k][0]);
          (res[i - 1 + j - k] += A[i - 1] * B[j] % MOD * dpc[j][k][0] % MOD) %= MOD;
          if(i < A.size()) {
            fprintf(stderr, "merge 2: (%zu, %zu, %zu), val = %lld * %lld * %lld\n", i, j, k, A[i], B[j], dpc[j][k][1]);
            (res[i + j - k] += A[i] * B[j] % MOD * dpc[j][k][1] % MOD) %= MOD;
          }
        }

        if(i == A.size()) {
          dpc[j][k][true] = dpc[j][k][false] = 0;
          continue;
        }
        
        {
          // f = false
          int64 &val = dpc[j][k][false];
          (dpn[j+1][k][false] += val) %= MOD;
          (dpn[j][k][false] += val) %= MOD;

          if(i+1 < A.size())
            (dpn[j+1][k+1][true] += val) %= MOD;
        }

        if(i+1 < A.size()) {
          // f = true
          int64 &val = dpc[j][k][true];
          (dpn[j+1][k+1][true] += val) %= MOD;
          (dpn[j][k][false] += val) %= MOD;
        }
        dpc[j][k][true] = dpc[j][k][false] = 0;
      }
    }
    swap(dpc, dpn);
  }
  return res;
}

void dump_vec(vector<int64> vec) {
  for(size_t i=0; i<vec.size(); i++) {
    fprintf(stderr, "%lld%c", vec[i], i+1==vec.size()?'\n':' ');
  }
}

vector<int64> solve(int cur) {
  fprintf(stderr, "solve: %d\n", cur);
  vector<int64> res(1, 1);
  for(auto to : G[cur]) {
    auto vec = solve(to);
    res = merge(res, vec);
  }
  res.insert(res.begin(), 0LL);

  fprintf(stderr, "dump: %d\n", cur);
  dump_vec(res);
  return res;
}

int main() {
  cin >> N;
  for(int i=0; i<N-1; i++) {
    int a, b; cin >> a >> b;
    G[a].push_back(b);
  }

  auto res = solve(0);
  int64 ans = 0;
  for(auto e : res) (ans += e) %= MOD;
  cout << ans << endl;
  return 0;
}

3
0 1
1 2
solve: 0
solve: 1
solve: 2
dump: 2
0 1
dp[0][0][0] = 1, 0
dp[0][1][0] = 0, 0
dp[0][1][1] = 0, 0
dp[1][0][0] = 1, 0
merge 1: (0, 0, 0), val = 1 * 0 * 1
dp[1][1][0] = 1, 0
merge 1: (0, 1, 0), val = 1 * 1 * 1
dp[1][1][1] = 0, 0
merge 1: (0, 1, 1), val = 1 * 1 * 0
dump: 1
0 0 1
dp[0][0][0] = 1, 0
dp[0][1][0] = 0, 0
dp[0][1][1] = 0, 0
dp[0][2][0] = 0, 0
dp[0][2][1] = 0, 0
dp[0][2][2] = 0, 0
dp[1][0][0] = 1, 0
merge 1: (0, 0, 0), val = 1 * 0 * 1
dp[1][1][0] = 1, 0
merge 1: (0, 1, 0), val = 1 * 0 * 1
dp[1][1][1] = 0, 0
merge 1: (0, 1, 1), val = 1 * 0 * 0
dp[1][2][0] = 0, 0
merge 1: (0, 2, 0), val = 1 * 1 * 0
dp[1][2][1] = 0, 0
merge 1: (0, 2, 1), val = 1 * 1 * 0
dp[1][2][2] = 0, 0
merge 1: (0, 2, 2), val = 1 * 1 * 0
dump: 0
0 0 0 0
0



Compiler output:
a.cc:97:1: error: expected unqualified-id before numeric constant
   97 | 3
      | ^