Language: C++

#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> P;
typedef priority_queue<P,vector<P>,greater<P>> P_queue;

const ll MOD=998244353;
const ll mod=1000000007;
const ll INF=1e18;
const double PI=3.1415926535897932;
vec dx={1,0,-1,0};
vec dy={0,1,0,-1};

#define REP(i,a,b) for(int i=(int)a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define mp make_pair
#define ALL(a) a.begin(),a.end()
#define SORT(a) sort(ALL(a))
#define U_ERASE(V) V.erase(unique(ALL(V)), V.end());
#define ADD(a,b) a=(a+b)%mod
#define MUL(a,b) a=(a*b)%mod

const ll MAXN=200011;
vector<P> d[MAXN];
ll D[2*MAXN][2];
ll N; 

ll memo[2*MAXN], size[2*MAXN];


const ll MaxN=201001;

ll f[MaxN], rf[MaxN];
ll inv(ll x) {
    ll res = 1;
    ll k = mod - 2;
    ll y = x;
    while (k) {
        if (k & 1) res = (res * y) % mod;
        y = (y * y) % mod;
        k /= 2;
    }
    return res;
}
void init() {
    f[0] = 1;
    REP(i, 1, MaxN) f[i] = (f[i - 1] * i) % mod;
    REP(i, 0, MaxN) rf[i] = inv(f[i]);
}
//---------------------------------------------------------------------------------------------------
ll C(ll n, ll k) {
    ll a = f[n]; // = n!
    ll b = rf[n-k]; // = (n-k)!
    ll c = rf[k]; // = k!

    ll bc = (b * c) % mod;

    return (a * bc) % mod;
}


ll Ai(ll x){
    if(x%2) return x-1;
    return x+1;
}

ll Size(ll x){
    if(size[x]>0) return size[x];
    ll A=D[x][0], B=D[x][1];
    if(d[B].size()==1) return size[x]=1;
    ll ret=1;
    rep(i,d[B].size()) if(d[B][i].second!=Ai(x)) ret+=Size(d[B][i].second);
    return size[x]=ret;
}
ll Solve(ll x){
    if(memo[x]>0) return memo[x];
    ll A=D[x][0], B=D[x][1];
    if(d[B].size()==1) return memo[x]=1;
    ll M=Size(x);
    M-=1;
    ll ret=1;
    rep(i,d[B].size()){
        ll c=d[B][i].second;
        if(c!=Ai(x)){
            MUL(ret,Solve(c));
            MUL(ret,C(M,Size(c)));
            M-=(Size(c));
        }
    }
    return memo[x]=ret;
}

ll SOLVE(ll a){
    ll M=N-1;
    ll ret=1;
    rep(i,d[a].size()){
        ll c=d[a][i].second;
        MUL(ret,Solve(c));
        MUL(ret,C(M,Size(c)));
        M-=(Size(c));
    }
    return ret;
}

int main(){
    init();
    cin>>N;
    rep(i,N-1){
        ll a,b; cin>>a>>b;
        a--; b--;
        d[a].pb(mp(b,2*i));
        d[b].pb(mp(a,2*i+1));
        D[2*i][0]=a; D[2*i][1]=b;
        D[2*i+1][0]=b; D[2*i+1][1]=a;
    }
    //rep(i,2*N) cout<<Size(i)<<endl;
    rep(i,N) cout<<SOLVE(i)<<endl;

}

Compiler output:
a.cc: In function 'll Size(ll)':
a.cc:72:8: error: reference to 'size' is ambiguous
   72 |     if(size[x]>0) return size[x];
      |        ^~~~
In file included from /usr/include/c++/14/string:53,
                 from /usr/include/c++/14/bitset:52,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52,
                 from a.cc:1:
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
  272 |     size(const _Tp (&)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note:                 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
  262 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
a.cc:32:18: note:                 'll size [400022]'
   32 | ll memo[2*MAXN], size[2*MAXN];
      |                  ^~~~
a.cc:72:26: error: reference to 'size' is ambiguous
   72 |     if(size[x]>0) return size[x];
      |                          ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
  272 |     size(const _Tp (&)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note:                 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
  262 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
a.cc:32:18: note:                 'll size [400022]'
   32 | ll memo[2*MAXN], size[2*MAXN];
      |                  ^~~~
a.cc:74:31: error: reference to 'size' is ambiguous
   74 |     if(d[B].size()==1) return size[x]=1;
      |                               ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
  272 |     size(const _Tp (&)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note:                 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
  262 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
a.cc:32:18: note:                 'll size [400022]'
   32 | ll memo[2*MAXN], size[2*MAXN];
      |                  ^~~~
a.cc:77:12: error: reference to 'size' is ambiguous
   77 |     return size[x]=ret;
      |            ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
  272 |     size(const _Tp (&)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note:                 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
  262 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
a.cc:32:18: note:                 'll size [400022]'
   32 | ll memo[2*MAXN], size[2*MAXN];
      |                  ^~~~