func_code_string: #include <bits/stdc++.h>   using namespace std;   int n, m, a[5005], b[5005], c[5005], dp[5005][5005][2], size[5005];   vector<int> G[5005];   void DP(int u) {     size[u] = 1;     dp[u][0][0] = 0;     dp[u][1][0] = a[u];     dp[u][1][1] = a[u] - b[u];     for (int i = 0; i < G[u].size(); i++) {       int v = G[u][i];       DP(v);       for (int j = size[u]; j >= 0; j--) {         for (int k = 0; k <= size[v]; k++) {           dp[u][j + k][0] = min(dp[u][j + k][0], dp[u][j][0] + dp[v][k][0]);           dp[u][j + k][1] = min(dp[u][j + k][1], dp[u][j][1] + dp[v][k][1]);           dp[u][j + k][1] = min(dp[u][j + k][1], dp[u][j][1] + dp[v][k][0]);         }       }       size[u] += size[v];     }   }   int main() {     scanf( %d %d , &n, &m);     scanf( %d %d , &a[1], &b[1]);     for (int i = 2; i <= n; i++) {       scanf( %d %d %d , &a[i], &b[i], &c[i]);       G[c[i]].push_back(i);     }     memset(dp, 0x3f3f3f3f, sizeof dp);     DP(1);     for (int i = n; i >= 1; i--)       if (dp[1][i][0] <= m || dp[1][i][1] <= m) {         printf( %d , i);         return 0;       }     printf( 0 );     return 0;   }   