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

void dump_dp(int a, int b, int c, int d, int aa, int bb, int cc, int dd, int v) {
  if(a == 1 and b == 1 and c == 1)
  fprintf(stderr, "(%d, %d, %d, %d) <= (%d, %d, %d, %d) (val = %d)\n", a, b, c, d, aa, bb, cc, dd, v);
}

int64 dpc[210][210][2], dpn[210][210][2];
vector<int64> merge(vector<int64> A, vector<int64> B, int cur, int to) {
  fprintf(stderr, "merge (%d and %d)\n", cur, to);
  fill(dpc[0][0], dpc[B.size() + 2][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++) {
        if(cur == 0 and to == 6) 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 < A.size()) {
            if(i+j-k == 4) fprintf(stderr, "merge 1: (%zu, %zu, %zu => %zu), val = %lld * %lld * %lld\n", i, j, k, i + j - k, A[i], B[j], dpc[j][k][0]);
          (res[i + j - k] += A[i] * B[j] % MOD * dpc[j][k][0] % MOD) %= MOD;
          if(i < A.size()) {
            if(i+j-k == 4) fprintf(stderr, "merge 2: (%zu, %zu, %zu => %zu), val = %lld * %lld * %lld\n", i, j, k, 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];
          // if(j+1 < B.size())
          dump_dp(i, j+1, k, false, i, j, k, false, val);
          (dpc[j+1][k][false] += val) %= MOD;
          dump_dp(i+1, j, k, false, i, j, k, false, val);
          (dpn[j][k][false] += val) %= MOD;

          if(i+1 < A.size()) {
            //if (j+1 < B.size() and k+1 <= j)
            dump_dp(i, j+1, k+1, true, i, j, k, false, val);
            (dpc[j+1][k+1][true] += val) %= MOD;
          }
        }

        if(i+1 < A.size()) {
          // f = true
          int64 &val = dpc[j][k][true];
          // if(j+1 < B.size() and k+1 <= j)
          dump_dp(i, j+1, k+1, true, i, j, k, true, val);
          (dpc[j+1][k+1][true] += val) %= MOD;
          dump_dp(i+1, j, k, false, i, j, k, true, val);
          (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, cur, to);

    fprintf(stderr, "dump: %d\n", cur);
    dump_vec(res);
  }
  res.insert(res.begin(), 0LL);
  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;
}

#error "ukuku"


Compiler output:
a.cc:112:2: error: #error "ukuku"
  112 | #error "ukuku"
      |  ^~~~~