Language: C++

#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define x first
#define LL long long 
#define y second
#define sqr(x) ((x)*(x))
#define pii pair<int,int>
#define pll pair<LL,LL>
#define pdd pair<double,double>
#define MEM(x) memset(x,0,sizeof(x))
#define MEMS(x) memset(x,-1,sizeof(x))
using namespace std;
vector<pair<int,pii> > v[200005];
map<int,pii> ma[200005];
LL fra[200005];
LL inv[200005];
LL val[200005];
LL Size[200005];
int mod=1e9+7;
LL f_pow(LL a,LL b){
    LL res=1,temp=a;
    while(b){
        if(b&1)res=res*temp%mod;
        temp=temp*temp%mod;
        b>>=1;
    }
    return res;
}
pll dfs(int x,int f){
    LL a=val[x],b=Size[x];
    for(auto &it:v[x]){
        if(it.x!=f){
            if(it.y.x==-1){
                it.y=dfs(it.x,x);
                ma[it.x]=it.y;
                a*=it.y.x;
                a%=mod;
                a*=inv[it.y.y];
                a%=mod;
                val[x]*=it.y.x;
                val[x]%=mod;
                val[x]*=inv[it.y.y];
                val[x]%=mod;
                Size[x]+=it.y.y;
                b+=it.y.y;
            }
            
        }
        else{
            swap(v[x][0],it);
        }
    }
    if(v[x][0].x==f)
    v[x].resize(1);
    else
    v[x].clear();
    if(ma.find(f)!=ma.end())
    {
        pii p=ma[f];
        a*=f_pow(p.x,mod-2);
        a%=mod;
        a*=inv[p.y];
        a%=mod;
        b-=p.y;
    }
    a*=fra[b];
    a%=mod;
    b++;
    return mp(a,b);
}
int main(){
    int n;
    scanf("%d",&n);
    fra[0]=1;
    for(int i = 1;i<=n;i++)fra[i]=fra[i-1]*i%mod;
    inv[n]=f_pow(fra[n],mod-2);
    for(int i =n-1;i>=0;i--)inv[i]=inv[i+1]*(i+1)%mod;
    for(int i = 1;i<n;i++){
        int x,y;
        scanf("%d %d",&x,&y);
        v[x].pb(mp(y,mp(-1,-1)));
        v[y].pb(mp(x,mp(-1,-1)));
    }
    for(int i = 1;i<=n;i++){
        printf("%lld\n",dfs(i,0).x);
    }
}

Compiler output:
a.cc: In function 'std::pair<long long int, long long int> dfs(int, int)':
a.cc:6:11: error: no match for 'operator=' (operand types are 'std::map<int, std::pair<int, int> >' and 'std::pair<int, int>')
    6 | #define y second
      |           ^~~~~~
a.cc:36:29: note: in expansion of macro 'y'
   36 |                 ma[it.x]=it.y;
      |                             ^
In file included from /usr/include/c++/14/map:63,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:152,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_map.h:331:7: note: candidate: 'std::map<_Key, _Tp, _Compare, _Alloc>& std::map<_Key, _Tp, _Compare, _Alloc>::operator=(const std::map<_Key, _Tp, _Compare, _Alloc>&) [with _Key = int; _Tp = std::pair<int, int>; _Compare = std::less<int>; _Alloc = std::allocator<std::pair<const int, std::pair<int, int> > >]'
  331 |       operator=(const map&) = default;
      |       ^~~~~~~~
/usr/include/c++/14/bits/stl_map.h:331:17: note:   no known conversion for argument 1 from 'std::pair<int, int>' to 'const std::map<int, std::pair<int, int> >&'
  331 |       operator=(const map&) = default;
      |                 ^~~~~~~~~~
/usr/include/c++/14/bits/stl_map.h:335:7: note: candidate: 'std::map<_Key, _Tp, _Compare, _Alloc>& std::map<_Key, _Tp, _Compare, _Alloc>::operator=(std::map<_Key, _Tp, _Compare, _Alloc>&&) [with _Key = int; _Tp = std::pair<int, int>; _Compare = std::less<int>; _Alloc = std::allocator<std::pair<const int, std::pair<int, int> > >]'
  335 |       operator=(map&&) = default;
      |       ^~~~~~~~
/usr/include/c++/14/bits/stl_map.h:335:17: note:   no known conversion for argument 1 from 'std::pair<int, int>' to 'std::map<int, std::pair<int, int> >&&'
  335 |       operator=(map&&) = default;
      |                 ^~~~~
/usr/include/c++/14/bits/stl_map.h:349:7: note: candidate: 'std::map<_Key, _Tp, _Compare, _Alloc>& std::map<_Key, _Tp, _Compare, _Alloc>::operator=(std::initializer_list<std::pair<const _Key, _Val> >) [with _Key = int; _Tp = std::pair<int, int>; _Compare = std::less<int>; _Alloc = std::allocator<std::pair<const int, std::pair<int, int> > >]'
  349 |       operator=(initializer_list<value_type> __l)
      |       ^~~~~~~~
/usr/include/c++/14/bits/stl_map.h:349:46: note:   no known conversion for argument 1 from 'std::pair<int, int>' to 'std::initializer_list<std::pair<const int, std::pair<int, int> > >'
  349 |       operator=(initializer_list<value_type> __l)
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
a.cc:58:11: error: request for member 'find' in 'ma', which is of non-class type 'std::map<int, std::pair<int, int> > [200005]'
   58 |     if(ma.find(f)!=ma.end())
      |           ^~~~
a.cc:58:23: error: request for member 'end' in 'ma', which is of non-class type 'std::map<int, std::pair<int, int> > [200005]'
   58 |     if(ma.find(f)!=ma.end())
      |                       ^~~
a.cc:60:19: error: conversion from 'std::map<int, std::pair<int, int> >' to non-scalar type 'std::pair<int, int>' requested
   60 |         pii p=ma[f];
      |               ~~~~^