func_code_string: #include <bits/stdc++.h>   using namespace std;   long long int cnt;   long long int v[100005], lft[100005], rgt[100005], rt[100005];   std::map<long long int, bool> M;   void check(long long int i, long long int left, long long int right) {     if (v[i] <= left && v[i] >= right) {       M[v[i]] = true;     }     if (lft[i] != -1) {       long long int left1 = min(left, v[i]);       check(lft[i], left1, right);     }     if (rgt[i] != -1) {       long long int right1 = max(right, v[i]);       check(rgt[i], left, right1);     }   }   int main() {     ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);     ;     long long int n, root;     cin >> n;     for (long long int i = 1; i <= n; i++) {       cin >> v[i] >> lft[i] >> rgt[i];     }     cnt = 0;     for (long long int i = 1; i <= n; i++) {       if (lft[i] != -1) rt[lft[i]] = 1;       if (rgt[i] != -1) rt[rgt[i]] = 1;     }     for (long long int i = 1; i <= n; i++) {       if (rt[i] == 0) {         root = i;         break;       }     }     long long int left = INT_MAX;     long long int right = INT_MIN;     check(root, left, right);     for (long long int i = 1; i <= n; i++) cnt += !M[v[i]];     cout << cnt << endl;     return 0;   }   