func_code_string: #include <bits/stdc++.h>   using namespace std;   const int N = 2000 + 1;   int n;   int c[N];   vector<int> g[N];   int a[N], sz[N];   void inc(int v, int x) {     if (a[v] >= x) ++a[v];     for (int u : g[v]) inc(u, x);   }   int dfs(int v, int t = 1) {     a[v] = t + c[v];     sz[v] = 1;     int new_t = t;     for (int u : g[v]) {       t = dfs(u, t);       inc(u, a[v]);       sz[v] += sz[u];     }     if (sz[v] < c[v] + 1) {       cout <<  NO n ;       exit(0);     }     return t + 1;   }   int main() {     ios_base::sync_with_stdio(false);     cout.tie(0);     cin.tie(0);     cin >> n;     int root = -1;     for (int i = 0; i < n; ++i) {       int p;       cin >> p >> c[i];       if (p)         g[p - 1].push_back(i);       else         root = i;     }     dfs(root);     cout <<  YES n ;     for (int i = 0; i < n; ++i) cout << a[i] <<    ;     cout <<   n ;   }   