Language: C++

/*
    Author:zeke
    
    pass System Test!
    GET AC!!
*/
#include <iostream>
#include <queue>
#include <vector>
#include <iostream>
#include <vector>
#include <string>
#include <cassert>
#include <algorithm>
#include <functional>
#include <cmath>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <map>
#include <iomanip>
#include <utility>
#include <stack>
#include <bitset>
using ll = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rep3(var, min, max) for (ll(var) = (min); (var) < (max); ++(var))
#define repi3(var, min, max) for (ll(var) = (max)-1; (var) + 1 > (min); --(var))
#define Mp(a, b) make_pair((a), (b))
#define F first
#define S second
#define Icin(s) \
    ll(s);      \
    cin >> (s);
#define Scin(s) \
    ll(s);      \
    cin >> (s);
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef vector<V> VV;
typedef vector<P> VP;
ll mod = 1e9 + 7;
ll MOD = 1e9 + 7;
ll INF = 1e18;
ll MAX = 1e6;
V kaijo(MAX, 1);
long long modinv(long long a, long long m)
{
    long long b = m, u = 1, v = 0;
    while (b)
    {
        long long t = a / b;
        a -= t * b;
        swap(a, b);
        u -= t * v;
        swap(u, v);
    }
    u %= m;
    if (u < 0)
        u += m;
    return u;
}
//a,m=MOD MOD逆元
void kaijoinit()
{
    rep3(i, 1, MAX + 1)
    {
        kaijo[i] = kaijo[i - 1] * i;
        kaijo[i] %= MOD;
    }
}
VV graph;
V dp;
V dp2;
V subtree;
ll n;
void dfs(ll now, ll prev)
{
 //   cout<<now<<endl;
    ll tempsize = 0;
    V invlist;
    ll tempres = 1;
    for (auto i : graph[now])
    {
        if (prev == i)
        {
            continue;
        }
        dfs(i, now);
        tempsize += subtree[i];
        invlist.push_back(subtree[i]);
        tempres *= dp[i];
        tempres %= MOD;
    }
    tempres *= kaijo[tempsize];
    tempres %= MOD;
    for(auto i:invlist){
        tempres *= modinv(kaijo[i], MOD);
        tempres %= MOD;
    }
    dp[now]=tempres;
    subtree[now] = tempsize + 1;
}
void dfs2(ll now,ll prev,ll present){
    ll temp=kaijo(n-1);
    temp*=modinv(n-subtree[now],MOD);
    dp2[now]=present;
    ll k=graph[now].size();
    ll left(k+1,1);
    ll right(k+1,1);
    rep(i,k){
        if(graph[now][i]==prev){
            continue;
        }
        left[i+1]=((left[i]*dp[graph[now][i]]%MOD)*modinv(subtree[graph[now][i]],MOD))%MOD;
        right[k-i-1]=((right[k-i]*dp[graph[now][k-i-1]]%MOD)*modinv(subtree[graph[[now][i]],MOD))%MOD;
    }
    rep(i,k){
        if(graph[now][i]==prev){
            continue;
        }
        ll temppre=left[i]*right[i+1]%MOD;
        temppre*=dp2[now];
        temppre%=MOD;
        dfs2(graph[now][i],now,temppre);
    }
}
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    graph.resize(n);
    kaijoinit();
    dp.resize(n);
    subtree.resize(n);
    rep(i, n - 1)
    {
        ll a, b;
        cin >> a >> b;
        a--;
        b--;
        graph[a].push_back(b);
        graph[b].push_back(a);
    }
    dfs(0, -1);
    for(auto i:subtree)cout<<i<<" ";
    cout<<endl;
    for(auto i:dp)cout<<i<<" ";
    cout<<endl;
    dfs(0,-1);
    dfs2(0,-1,1);
    
    cout << endl;
}


Compiler output:
a.cc: In function 'void dfs2(ll, ll, ll)':
a.cc:129:18: error: no match for call to '(V {aka std::vector<long long int>}) (ll)'
  129 |     ll temp=kaijo(n-1);
      |             ~~~~~^~~~~
a.cc:133:18: error: expression list treated as compound expression in initializer [-fpermissive]
  133 |     ll left(k+1,1);
      |                  ^
a.cc:134:19: error: expression list treated as compound expression in initializer [-fpermissive]
  134 |     ll right(k+1,1);
      |                   ^
a.cc:139:13: error: invalid types 'll {aka long long int}[int]' for array subscript
  139 |         left[i+1]=((left[i]*dp[graph[now][i]]%MOD)*modinv(subtree[graph[now][i]],MOD))%MOD;
      |             ^
a.cc:139:25: error: invalid types 'll {aka long long int}[int]' for array subscript
  139 |         left[i+1]=((left[i]*dp[graph[now][i]]%MOD)*modinv(subtree[graph[now][i]],MOD))%MOD;
      |                         ^
a.cc:140:14: error: invalid types 'll {aka long long int}[ll {aka long long int}]' for array subscript
  140 |         right[k-i-1]=((right[k-i]*dp[graph[now][k-i-1]]%MOD)*modinv(subtree[graph[[now][i]],MOD))%MOD;
      |              ^
a.cc:140:29: error: invalid types 'll {aka long long int}[ll {aka long long int}]' for array subscript
  140 |         right[k-i-1]=((right[k-i]*dp[graph[now][k-i-1]]%MOD)*modinv(subtree[graph[[now][i]],MOD))%MOD;
      |                             ^
a.cc:140:82: error: two consecutive '[' shall only introduce an attribute before '[' token
  140 |         right[k-i-1]=((right[k-i]*dp[graph[now][k-i-1]]%MOD)*modinv(subtree[graph[[now][i]],MOD))%MOD;
      |                                                                                  ^
a.cc:140:82: error: expected ']' before '[' token
  140 |         right[k-i-1]=((right[k-i]*dp[graph[now][k-i-1]]%MOD)*modinv(subtree[graph[[now][i]],MOD))%MOD;
      |                                                                                  ^
      |                                                                                  ]
a.cc:140:82: error: two consecutive '[' shall only introduce an attribute before '[' token
a.cc:146:24: error: invalid types 'll {aka long long int}[int]' for array subscript
  146 |         ll temppre=left[i]*right[i+1]%MOD;
      |                        ^
a.cc:146:33: error: invalid types 'll {aka long long int}[int]' for array subscript
  146 |         ll temppre=left[i]*right[i+1]%MOD;
      |                                 ^