/tmp/solutions/build/vertex_add_subtree_sum-main.cpp:
    1|       |#include <common.h>
    2|       |prelude;
    3|       |
    4|       |namespace {
    5|       |
    6|       |constexpr int N = 5e5;
    7|       |
    8|       |int a[N];
    9|       |int p[N];
   10|       |int l[N];
   11|       |u64 b[N + 1];
   12|       |
   13|       |} // namespace
   14|       |
   15|      1|int main() {
   16|      1|  rd rd;
   17|      1|  wt wt;
   18|      1|  int n = rd.uh();
   19|      1|  int q = rd.uh();
   20|      1|#ifdef LOCAL
   21|      1|  std::memset(l, 0, 4 * n);
   22|      1|#endif
   23|  53.3k|  for (int i = 0; i < n; ++i) a[i] = rd.uw();
                                       ^53.3k^53.3k
  ------------------
  |  Branch (23:19): [True: 100.00%, False: 0.00%]
  ------------------
   24|  53.3k|  for (int i = 1; i < n; ++i) p[i] = rd.uh();
                                       ^53.3k^53.3k
  ------------------
  |  Branch (24:19): [True: 100.00%, False: 0.00%]
  ------------------
   25|  53.3k|  for (int i = n - 1; i > 0; --i) l[p[i]] += (l[i] += 1);
                                           ^53.3k^53.3k
  ------------------
  |  Branch (25:23): [True: 100.00%, False: 0.00%]
  ------------------
   26|      1|  l[0] = p[0] = n;
   27|  53.3k|  for (int i = 1; i < n; ++i) {
                                       ^53.3k
  ------------------
  |  Branch (27:19): [True: 100.00%, False: 0.00%]
  ------------------
   28|  53.3k|    int j = p[i];
   29|  53.3k|    int li = l[i];
   30|  53.3k|    int lj = l[j];
   31|  53.3k|    l[i] = p[i] = lj;
   32|  53.3k|    l[j] -= li;
   33|  53.3k|  }
   34|  53.3k|  for (int i = 0; i < n; ++i) b[l[i]] = a[i];
                                       ^53.3k^53.3k
  ------------------
  |  Branch (34:19): [True: 100.00%, False: 0.00%]
  ------------------
   35|  53.3k|  for (int i = 1; i <= n; ++i) b[i] += b[i - 1];
                                        ^53.3k^53.3k
  ------------------
  |  Branch (35:19): [True: 100.00%, False: 0.00%]
  ------------------
   36|  53.3k|  for (int i = n; i >= 1; --i) b[i] -= b[i - (i & -i)];
                                        ^53.3k^53.3k
  ------------------
  |  Branch (36:19): [True: 100.00%, False: 0.00%]
  ------------------
   37|   382k|  while (q--) {
  ------------------
  |  Branch (37:10): [True: 100.00%, False: 0.00%]
  ------------------
   38|   382k|    let t = rd.u1();
   39|   382k|    if (t == 0) {
  ------------------
  |  Branch (39:9): [True: 50.01%, False: 49.99%]
  ------------------
   40|   191k|      int k = l[rd.uh()];
   41|   191k|      int x = rd.uw();
   42|  1.76M|      for (; k <= n; k += k & -k) b[k] += x;
                                   ^1.57M       ^1.57M
  ------------------
  |  Branch (42:14): [True: 89.16%, False: 10.84%]
  ------------------
   43|   191k|    }
   44|   382k|    if (t == 1) {
  ------------------
  |  Branch (44:9): [True: 49.99%, False: 50.01%]
  ------------------
   45|   191k|      int x = rd.uh();
   46|   191k|      int L = l[x] - 1;
   47|   191k|      int R = p[x];
   48|   191k|      u64 sum = 0;
   49|  1.66M|      for (; L > 0; L -= L & -L) sum -= b[L];
                                  ^1.46M       ^1.46M
  ------------------
  |  Branch (49:14): [True: 88.49%, False: 11.51%]
  ------------------
   50|  1.66M|      for (; R > 0; R -= R & -R) sum += b[R];
                                  ^1.47M       ^1.47M
  ------------------
  |  Branch (50:14): [True: 88.50%, False: 11.50%]
  ------------------
   51|   191k|      wt.ud(sum);
   52|   191k|    }
   53|   382k|  }
   54|      1|  return 0;
   55|      1|}