Language: C++

    ll n, q;
    cin >> n >> q;
    ll am = 0;
    vector<ll> parent(n, -1);
    vector<ll> cnts(n, 0);
    vector<ll> depth(n, 0);
    for (ll i = 0; i < n; i++)
    {
        ll a, b;
        cin >> a >> b;
        parent[b - 1] = a - 1;
        depth[b - 1] = depth[a - 1] + 1;
        am = max(depth[a - 1] + 1, am);
    }
    vector<vector<ll>> DEPTH(am + 1);
    for (ll i = 0; i < n; i++)
    {
        DEPTH[depth[i]].push_back(i);
    }
    for (ll i = 0; i < q; i++)
    {
        ll k, l;
        cin >> k >> l;
        cnts[k - 1] += l;
    }
    for (ll i = 1; i <= am; i++)
    {

        for (ll j = 0; j < DEPTH[i].size(); j++)
        {
            cnts[DEPTH[i][j]] += cnts[parent[DEPTH[i][j]]];
        }
    }
    for (ll i = 0; i < n; i++)
    {
        cout << cnts[i] << (i != n - 1 ? " " : "\n");
    }
}


Compiler output:
a.cc:1:5: error: 'll' does not name a type
    1 |     ll n, q;
      |     ^~
a.cc:2:5: error: 'cin' does not name a type
    2 |     cin >> n >> q;
      |     ^~~
a.cc:3:5: error: 'll' does not name a type
    3 |     ll am = 0;
      |     ^~
a.cc:4:5: error: 'vector' does not name a type
    4 |     vector<ll> parent(n, -1);
      |     ^~~~~~
a.cc:5:5: error: 'vector' does not name a type
    5 |     vector<ll> cnts(n, 0);
      |     ^~~~~~
a.cc:6:5: error: 'vector' does not name a type
    6 |     vector<ll> depth(n, 0);
      |     ^~~~~~
a.cc:7:5: error: expected unqualified-id before 'for'
    7 |     for (ll i = 0; i < n; i++)
      |     ^~~
a.cc:7:20: error: 'i' does not name a type
    7 |     for (ll i = 0; i < n; i++)
      |                    ^
a.cc:7:27: error: 'i' does not name a type
    7 |     for (ll i = 0; i < n; i++)
      |                           ^
a.cc:15:5: error: 'vector' does not name a type
   15 |     vector<vector<ll>> DEPTH(am + 1);
      |     ^~~~~~
a.cc:16:5: error: expected unqualified-id before 'for'
   16 |     for (ll i = 0; i < n; i++)
      |     ^~~
a.cc:16:20: error: 'i' does not name a type
   16 |     for (ll i = 0; i < n; i++)
      |                    ^
a.cc:16:27: error: 'i' does not name a type
   16 |     for (ll i = 0; i < n; i++)
      |                           ^
a.cc:20:5: error: expected unqualified-id before 'for'
   20 |     for (ll i = 0; i < q; i++)
      |     ^~~
a.cc:20:20: error: 'i' does not name a type
   20 |     for (ll i = 0; i < q; i++)
      |                    ^
a.cc:20:27: error: 'i' does not name a type
   20 |     for (ll i = 0; i < q; i++)
      |                           ^
a.cc:26:5: error: expected unqualified-id before 'for'
   26 |     for (ll i = 1; i <= am; i++)
      |     ^~~
a.cc:26:20: error: 'i' does not name a type
   26 |     for (ll i = 1; i <= am; i++)
      |                    ^
a.cc:26:29: error: 'i' does not name a type
   26 |     for (ll i = 1; i <= am; i++)
      |                             ^
a.cc:34:5: error: expected unqualified-id before 'for'
   34 |     for (ll i = 0; i < n; i++)
      |     ^~~
a.cc:34:20: error: 'i' does not name a type
   34 |     for (ll i = 0; i < n; i++)
      |                    ^
a.cc:34:27: error: 'i' does not name a type
   34 |     for (ll i = 0; i < n; i++)
      |                           ^
a.cc:38:1: error: expected declaration before '}' token
   38 | }
      | ^