func_code_string: #include <bits/stdc++.h>   using namespace std;   map<int, int> times;   const int INF = 0x3fffffff;   struct Node {     int l, r;     int v;     Node() { l = -1, r = -1; }     Node(int _l, int _r) { l = _l, r = _r; }   } node[120000];   int fa[120000];   int n, v, ls, rs, root;   int ans;   int Findroot(int t) {     if (fa[t] != t) return Findroot(fa[t]);     return t;   }   void dfs(int mi, int ma, int now) {     if (node[now].v <= mi || node[now].v >= ma) {       if (times[node[now].v] != -1) {         ans++;         times[node[now].v]++;       }     } else {       ans -= times[node[now].v];       times[node[now].v] = -1;     }     if (node[now].l ^ (~0)) dfs(mi, min(ma, node[now].v), node[now].l);     if (node[now].r ^ (~0)) dfs(max(mi, node[now].v), ma, node[now].r);     return;   }   int main() {     scanf( %d , &n);     for (int i = 1; i <= n; i++) fa[i] = i;     for (int i = 1; i <= n; i++) {       scanf( %d%d%d , &v, &ls, &rs);       if (ls ^ (~0)) fa[ls] = i;       if (rs ^ (~0)) fa[rs] = i;       node[i].l = ls;       node[i].r = rs;       node[i].v = v;     }     root = Findroot(1);     dfs(-INF, INF, root);     printf( %d n , ans);     return 0;   }   