Language: Java

#include <bits/stdc++.h>
using namespace std;

using ll = long long;
#define int long long

#define LOG(variable) cout << #variable":\t" << (variable) << endl
#define LOGCON(i, container) for(int (i) = 0; (i) < (container).size(); ++(i)) cout << (i) << ":\t" << (container)[(i)] << endl
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPS(i, r, n) for (int i = (r); i < (n); ++i)
#define REPR(i, n) for(int i = (n); i >= 0; --i) // from n to 0
#define REPRS(i, n, r) for(int i = (n); i >= (r); --i) // from n to r
#define REPOBJ(itr, obj) for(auto itr = (obj).begin(); itr != (obj).end() ; ++itr)
#define REPROBJ(itr, obj) for(auto itr = (obj).rbegin(), e = (obj).rend(); itr != e; ++itr)
#define COUTB(x) cout << (x) << "\n"
#define COUTS(x) cout << (x) << " "
#define PB push_back
#define SORT(obj) sort((obj).begin(), (obj).end())
#define SORTR(obj) sort((obj).begin(), (obj).end(), greater<>())
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define PI (acos(-1))
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%MOD+MOD)%MOD){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += MOD-a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= MOD; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime MOD
  mint inv() const { return pow(MOD-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
int in() {int x; cin>>x; return x;}
string stin() {string s; cin>>s; return s;}
struct node {
  int value;
  int sum;
  set<int> next_index_set;
};
node nodes[200005];
void CalcSum(int current_index, int current_sum) {
  current_sum += nodes[current_index].sum;
  nodes[current_index].value += current_sum;
  for(auto& itr : nodes[current_index].next_index_set) {
    CalcSum(itr, current_sum);
  }
}
/***** MAIN *****/
signed main() {
  int n = in();
  int q = in();
  
  REP(i,n) {
    nodes[i].value = 0;
    nodes[i].sum = 0;
  }
  REP(i,n-1) {
    int index = in();
    int num = in();
    nodes[index-1].next_index_set.insert(num-1);
  }
  REP(i,q) {
    int node_num = in();
    int sum = in();
    nodes[node_num-1].sum += sum;
  }
  CalcSum(0,0);
  REP(i,n) {
    cout << nodes[i].value;
    if(i < n-1) cout << " ";
    else cout << endl;
  }
  return 0;
}
/***** MAIN *****/


Compiler output:
Main.java:1: error: illegal character: '#'
#include <bits/stdc++.h>
^
Main.java:1: error: class, interface, enum, or record expected
#include <bits/stdc++.h>
         ^
Main.java:4: error: unnamed classes are a preview feature and are disabled by default.
using ll = long long;
^
  (use --enable-preview to enable unnamed classes)
Main.java:4: error: '.class' expected
using ll = long long;
                ^
Main.java:5: error: illegal character: '#'
#define int long long
^
Main.java:5: error: class, interface, enum, or record expected
#define int long long
        ^
Main.java:7: error: illegal character: '#'
#define LOG(variable) cout << #variable":\t" << (variable) << endl
^
Main.java:7: error: illegal character: '#'
#define LOG(variable) cout << #variable":\t" << (variable) << endl
                              ^
Main.java:8: error: illegal character: '#'
#define LOGCON(i, container) for(int (i) = 0; (i) < (container).size(); ++(i)) cout << (i) << ":\t" << (container)[(i)] << endl
^
Main.java:8: error: class, interface, enum, or record expected
#define LOGCON(i, container) for(int (i) = 0; (i) < (container).size(); ++(i)) cout << (i) << ":\t" << (container)[(i)] << endl
                                              ^
Main.java:8: error: class, interface, enum, or record expected
#define LOGCON(i, container) for(int (i) = 0; (i) < (container).size(); ++(i)) cout << (i) << ":\t" << (container)[(i)] << endl
                                                                        ^
Main.java:9: error: illegal character: '#'
#define REP(i, n) for (int i = 0; i < (n); ++i)
^
Main.java:9: error: class, interface, enum, or record expected
#define REP(i, n) for (int i = 0; i < (n); ++i)
                                  ^
Main.java:9: error: class, interface, enum, or record expected
#define REP(i, n) for (int i = 0; i < (n); ++i)
                                           ^
Main.java:10: error: illegal character: '#'
#define REPS(i, r, n) for (int i = (r); i < (n); ++i)
^
Main.java:10: error: class, interface, enum, or record expected
#define REPS(i, r, n) for (int i = (r); i < (n); ++i)
                                        ^
Main.java:10: error: class, interface, enum, or record expected
#define REPS(i, r, n) for (int i = (r); i < (n); ++i)
                                                 ^
Main.java:11: error: illegal character: '#'
#define REPR(i, n) for(int i = (n); i >= 0; --i) // from n to 0
^
Main.java:11: error: class, interface, enum, or record expected
#define REPR(i, n) for(int i = (n); i >= 0; --i) // from n to 0
                                    ^
Main.java:11: error: class, interface, enum, or record expected
#define REPR(i, n) for(int i = (n); i >= 0; --i) // from n to 0
                                            ^
Main.java:12: error: illegal character: '#'
#define REPRS(i, n, r) for(int i = (n); i >= (r); --i) // from n to r
^
Main.java:12: error: class, interface, enum, or record expected
#define REPRS(i, n, r) for(int i = (n); i >= (r); --i) // from n to r
                                        ^
Main.java:12: error: class, interface, enum, or record expected
#define REPRS(i, n, r) for(int i = (n); i >= (r); --i) // from n to r
                                                  ^
Main.java:13: error: illegal character: '#'
#define REPOBJ(itr, obj) for(auto itr = (obj).begin(); itr != (obj).end() ; ++itr)
^
Main.java:13: error: class, interface, enum, or record expected
#define REPOBJ(itr, obj) for(auto itr = (obj).begin(); itr != (obj).end() ; ++itr)
                                                       ^
Main.java:13: error: class, interface, enum, or record expected
#define REPOBJ(itr, obj) for(auto itr = (obj).begin(); itr != (obj).end() ; ++itr)
                                                                            ^
Main.java:14: error: illegal character: '#'
#define REPROBJ(itr, obj) for(auto itr = (obj).rbegin(), e = (obj).rend(); itr != e; ++itr)
^
Main.java:14: error: class, interface, enum, or record expected
#define REPROBJ(itr, obj) for(auto itr = (obj).rbegin(), e = (obj).rend(); itr != e; ++itr)
                                                                           ^
Main.java:14: error: class, interface, enum, or record expected
#define REPROBJ(itr, obj) for(auto itr = (obj).rbegin(), e = (obj).rend(); itr != e; ++itr)
                                                                                     ^
Main.java:15: error: illegal character: '#'
#define COUTB(x) cout << (x) << "\n"
^
Main.java:16: error: illegal character: '#'
#define COUTS(x) cout << (x) << " "
^
Main.java:17: error: illegal character: '#'
#define PB push_back
^
Main.java:18: error: illegal character: '#'
#define SORT(obj) sort((obj).begin(), (obj).end())
^
Main.java:19: error: illegal character: '#'
#define SORTR(obj) sort((obj).begin(), (obj).end(), greater<>())
^
Main.java:20: error: illegal character: '#'
#define ALL(obj) (obj).begin(), (obj).end()
^
Main.java:21: error: illegal character: '#'
#define MOD 1000000007
^
Main.java:22: error: illegal character: '#'
#define PI (acos(-1))
^
Main.java:25: error: class, interface, enum, or record expected
  mint(ll x=0):x((x%MOD+MOD)%MOD){}
  ^
Main.java:26: error: class, interface, enum, or record expected
  mint operator-() const { return mint(-x);}
                                           ^
Main.java:29: error: class, interface, enum, or record expected
    return *this;
    ^
Main.java:30: error: class, interface, enum, or record expected
  }
  ^
Main.java:33: error: class, interface, enum, or record expected
    return *this;
    ^
Main.java:34: error: class, interface, enum, or record expected
  }
  ^
Main.java:35: error: class, interface, enum, or record expected
  mint& operator*=(const mint a) { (x *= a.x) %= MOD; return *this;}
                                                      ^
Main.java:35: error: class, interface, enum, or record expected
  mint& operator*=(const mint a) { (x *= a.x) %= MOD; return *this;}
                                                                   ^
Main.java:36: error: class, interface, enum, or record expected
  mint operator+(const mint a) const { return mint(*this) += a;}
                                                               ^
Main.java:37: error: class, interface, enum, or record expected
  mint operator-(const mint a) const { return mint(*this) -= a;}
                                                               ^
Main.java:38: error: class, interface, enum, or record expected
  mint operator*(const mint a) const { return mint(*this) *= a;}
                                                               ^
Main.java:42: error: class, interface, enum, or record expected
    a *= a;
    ^
Main.java:43: error: class, interface, enum, or record expected
    if (t&1) a *= *this;
    ^
Main.java:44: error: class, interface, enum, or record expected
    return a;
    ^
Main.java:45: error: class, interface, enum, or record expected
  }
  ^
Main.java:48: error: class, interface, enum, or record expected
  mint inv() const { return pow(MOD-2);}
                                       ^
Main.java:49: error: class, interface, enum, or record expected
  mint& operator/=(const mint a) { return *this *= a.inv();}
                                                           ^
Main.java:50: error: class, interface, enum, or record expected
  mint operator/(const mint a) const { return mint(*this) /= a;}
                                                               ^
Main.java:52: error: class, interface, enum, or record expected
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
^
Main.java:52: error: class, interface, enum, or record expected
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
                                                                   ^
Main.java:53: error: class, interface, enum, or record expected
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
                                                                   ^
Main.java:54: error: class, interface, enum, or record expected
int in() {int x; cin>>x; return x;}
                 ^
Main.java:54: error: class, interface, enum, or record expected
int in() {int x; cin>>x; return x;}
                         ^
Main.java:54: error: class, interface, enum, or record expected
int in() {int x; cin>>x; return x;}
                                  ^
Main.java:55: error: class, interface, enum, or record expected
string stin() {string s; cin>>s; return s;}
                         ^
Main.java:55: error: class, interface, enum, or record expected
string stin() {string s; cin>>s; return s;}
                                 ^
Main.java:55: error: class, interface, enum, or record expected
string stin() {string s; cin>>s; return s;}
                                          ^
Main.java:60: error: class, interface, enum, or record expected
};
^
Main.java:61: error: class, interface, enum, or record expected
node nodes[200005];
^
Main.java:65: error: not a statement
  for(auto& itr : nodes[current_index].next_index_set) {
          ^
Main.java:65: error: not a statement
  for(auto& itr : nodes[current_index].next_index_set) {
                                      ^
Main.java:65: error: ';' expected
  for(auto& itr : nodes[current_index].next_index_set) {
               ^
Main.java:65: error: illegal start of expression
  for(auto& itr : nodes[current_index].next_index_set) {
                ^
Main.java:65: error: ';' expected
  for(auto& itr : nodes[current_index].next_index_set) {
                                                     ^
Main.java:90: error: not a statement
    cout << nodes[i].value;
         ^
Main.java:91: error: not a statement
    if(i < n-1) cout << " ";
                     ^
Main.java:92: error: not a statement
    else cout << endl;
              ^
Main.java:74: error: ';' expected
  REP(i,n) {
          ^
Main.java:78: error: ';' expected
  REP(i,n-1) {
            ^
Main.java:83: error: ';' expected
  REP(i,q) {
          ^
Main.java:89: error: ';' expected
  REP(i,n) {
          ^
78 errors