func_code_string: #include <bits/stdc++.h>   using namespace std;   const int MAXN = 5500;   const int INF = 1E9;   int a[MAXN], b[MAXN], c[MAXN], d[MAXN];   int f[MAXN][MAXN];   vector<int> g[MAXN];   inline bool cmp(int a, int b) { return c[a] > c[b]; }   int main() {     int n, m, k, s;     scanf( %d%d%d , &n, &m, &k);     s = k;     for (int i = 1; i <= n; i++) {       scanf( %d%d%d , &a[i], &b[i], &c[i]);       s += b[i];       d[i] = i;     }     for (int i = 1; i <= m; i++) {       int u, v;       scanf( %d%d , &u, &v);       d[v] = max(d[v], u);     }     for (int i = 1; i <= n; i++) g[d[i]].push_back(i);     for (int i = 1; i <= n; i++) sort(g[i].begin(), g[i].end(), cmp);     for (int i = 0; i <= n; i++)       for (int j = 0; j <= s; j++) f[i][j] = -INF;     for (int i = n; i >= 0; i--)       for (int j = 0; j <= s - b[i]; j++) {         if (j + b[i] >= a[i + 1]) f[i][j] = max(f[i][j], f[i + 1][j + b[i]]);         for (int l = 0, t = 0; l < g[i].size() && j + b[i] - (l + 1) >= a[i + 1];              l++) {           t += c[g[i][l]];           f[i][j] = max(f[i][j], f[i + 1][j + b[i] - (l + 1)] + t);         }       }     printf( %d n , f[0][k] < 0 ? -1 : f[0][k]);     return 0;   }   