Language: C++

#include<bits/stdc++.h>
using namespace std;
#ifdef LOCAL_DEBUG
  #include "LOCAL_DEBUG.hpp"
#endif
#define int long long
const int MOD = 1e9 + 7;

struct Combination{
  vector<int> fact; //　fact[i] = iの階乗
  // Combination(int n) : fact(n+1){
  //   fact[0] = fact[1] = 1;
  //   for(int i = 2; i <= n; i++){
  //     fact[i] = fact[i-1] * i;
  //   }
  // }
  void init(int n){
    fact.resize(n+1);
    fact[0] = fact[1] = 1;
     for(int i = 2; i <= n; i++){
       fact[i] = fact[i-1] * i;
     }
   }
  }

  int nCr(int n, int r){ // nCr = n!/r!(n-r)!
    if(n < r) return 0;
    return fact[n] * inv(fact[r]*fact[n-r]%MOD) % MOD;
  }

  int inv(int n){ // a/n ≡ a*n^(p-2) nとpは互いに素
    int r = 1, p = MOD-2;
    for(; p > 0; p >>= 1){
      if(p & 1LL) r = (r * n) % MOD;
      n = (n * n) % MOD;
    }
    return r; // r = n^p % MOD
  }
};

signed main(){

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

  Combination c(n+1);
  vector<int> num(n, 0), dp(n, 1);
  auto dfs1 = [&](auto&& dfs1, int u, int p)->void{
    for(int v : G[u]){
      if(v == p) continue;
      dfs1(dfs1, v, u);
      num[u] += num[v];
      dp[u] = dp[u] * dp[v]%MOD * c.nCr(num[u], num[v]) % MOD;
    }
    num[u]++;
  };
  dfs1(dfs1, 0, -1);

  vector<int> ans(n);
  auto dfs2 = [&](auto&& dfs2, int u, int p, int res)->void{
    ans[u] = dp[u] * res%MOD * c.nCr(n-1, n-num[u]) % MOD;
    for(int v : G[u]){
      if(v == p) continue;
      res = ans[u] * c.inv(dp[v])%MOD * c.inv(c.nCr(n-1, num[v])) % MOD;
      dfs2(dfs2, v, u, res);
    }
  };
  dfs2(dfs2, 0, -1, 1);

  for(int p : ans){
    cout << p << endl;
  }

  return 0;
}


Compiler output:
a.cc:24:4: error: expected ';' after struct definition
   24 |   }
      |    ^
      |    ;
a.cc: In function 'long long int nCr(long long int, long long int)':
a.cc:28:12: error: 'fact' was not declared in this scope
   28 |     return fact[n] * inv(fact[r]*fact[n-r]%MOD) % MOD;
      |            ^~~~
a.cc:28:22: error: 'inv' was not declared in this scope; did you mean 'int'?
   28 |     return fact[n] * inv(fact[r]*fact[n-r]%MOD) % MOD;
      |                      ^~~
      |                      int
a.cc: At global scope:
a.cc:39:1: error: expected declaration before '}' token
   39 | };
      | ^
a.cc: In function 'int main()':
a.cc:52:20: error: no matching function for call to 'Combination::Combination(long long int)'
   52 |   Combination c(n+1);
      |                    ^
a.cc:9:8: note: candidate: 'Combination::Combination()'
    9 | struct Combination{
      |        ^~~~~~~~~~~
a.cc:9:8: note:   candidate expects 0 arguments, 1 provided
a.cc:9:8: note: candidate: 'Combination::Combination(const Combination&)'
a.cc:9:8: note:   no known conversion for argument 1 from 'long long int' to 'const Combination&'
a.cc:9:8: note: candidate: 'Combination::Combination(Combination&&)'
a.cc:9:8: note:   no known conversion for argument 1 from 'long long int' to 'Combination&&'
a.cc: In lambda function:
a.cc:59:37: error: 'struct Combination' has no member named 'nCr'
   59 |       dp[u] = dp[u] * dp[v]%MOD * c.nCr(num[u], num[v]) % MOD;
      |                                     ^~~
a.cc: In lambda function:
a.cc:67:34: error: 'struct Combination' has no member named 'nCr'
   67 |     ans[u] = dp[u] * res%MOD * c.nCr(n-1, n-num[u]) % MOD;
      |                                  ^~~
a.cc:70:24: error: 'struct Combination' has no member named 'inv'
   70 |       res = ans[u] * c.inv(dp[v])%MOD * c.inv(c.nCr(n-1, num[v])) % MOD;
      |                        ^~~
a.cc:70:43: error: 'struct Combination' has no member named 'inv'
   70 |       res = ans[u] * c.inv(dp[v])%MOD * c.inv(c.nCr(n-1, num[v])) % MOD;
      |                                           ^~~
a.cc:70:49: error: 'struct Combination' has no member named 'nCr'
   70 |       res = ans[u] * c.inv(dp[v])%MOD * c.inv(c.nCr(n-1, num[v])) % MOD;
      |                                                 ^~~