func_code_string: #include <bits/stdc++.h>   using namespace std;   int n, L, m, head[1000005], cnt, root, sz[1000005], sum, mx;   long long t[1000005], ans;   struct edge {     int to, next, cost;   } e[1000005 << 1];   struct dist {     int len, dis;     bool operator<(const dist &p) const { return dis < p.dis; }   } dis[1000005], q[1000005];   bool vis[1000005];   inline int read() {     int x = 0, w = 1;     char c = getchar();     while (c <  0  || c >  9 ) {       if (c ==  - ) w = -1;       c = getchar();     }     while (c >=  0  && c <=  9 ) {       x = x * 10 + c -  0 ;       c = getchar();     }     return x * w;   }   int lowbit(int x) { return x & (-x); }   void add(int x, int y) {     if (x == 0) return;     for (int i = x; i <= n + 1; i += lowbit(i)) t[i] += y;   }   long long query(int x) {     if (x <= 0) return 0;     long long res = 0;     for (int i = x; i; i -= lowbit(i)) res += t[i];     return res;   }   inline void add(int u, int v, int w) {     e[++cnt] = (edge){v, head[u], w};     head[u] = cnt;   }   void fdrt(int u, int fa) {     sz[u] = 1;     int num = 0;     for (int i = head[u]; i; i = e[i].next) {       int v = e[i].to;       if (v == fa || vis[v]) continue;       fdrt(v, u);       sz[u] += sz[v];       num = max(num, sz[v]);     }     num = max(num, sum - sz[u]);     if (mx > num) mx = num, root = u;   }   void gtds(int u, int fa) {     q[++cnt] = dis[u];     for (int i = head[u]; i; i = e[i].next) {       int v = e[i].to;       if (v == fa || vis[v]) continue;       dis[v].len = dis[u].len + 1;       dis[v].dis = dis[u].dis + e[i].cost;       gtds(v, u);     }   }   long long calc(int u, int len, int d) {     cnt = 0;     dis[u].len = len, dis[u].dis = d;     gtds(u, 0);     sort(q + 1, q + cnt + 1);     for (int i = 1; i <= cnt; i++) add(q[i].len + 1, 1);     int l = 1, r = cnt;     long long res = 0;     while (l < r) {       if (q[l].dis + q[r].dis <= m) {         add(q[l].len + 1, -1);         res += query(L - q[l].len + 1);         l++;       } else         add(q[r].len + 1, -1), r--;     }     add(q[l].len + 1, -1);     return res;   }   void solve(int u) {     ans += calc(u, 0, 0);     vis[u] = 1;     for (int i = head[u]; i; i = e[i].next) {       int v = e[i].to;       if (vis[v]) continue;       ans -= calc(v, 1, e[i].cost);       sum = mx = sz[v];       fdrt(v, 0);       solve(root);     }   }   int main() {     n = read();     L = read();     m = read();     for (int i = 2; i <= n; i++) {       int u = read(), w = read();       add(u, i, w);       add(i, u, w);     }     sum = mx = n;     fdrt(1, 0);     solve(root);     printf( %I64d n , ans);     return 0;   }   