func_code_string: #include <bits/stdc++.h>   using namespace std;   int n, r, f[60005];   int dp[105][60005];   struct node {     int a, b, sign;   } pro[105];   bool cmp(node a, node b) {     if (a.sign == b.sign) {       if (a.sign == 1)         return a.a < b.a;       else         return a.a + a.b > b.a + b.b;     }     return a.sign < b.sign;   }   int main() {     scanf( %d%d , &n, &r);     for (register int i = 1; i <= n; i++) {       scanf( %d%d , &pro[i].a, &pro[i].b);       if (pro[i].b >= 0)         pro[i].sign = 1;       else         pro[i].sign = 2, pro[i].a = max(pro[i].a, abs(pro[i].b));     }     sort(pro + 1, pro + 1 + n, cmp);     int s = r, sum = 0;     vector<node> aa;     for (register int i = 1; i <= n; i++) {       if (pro[i].sign == 1 && s >= pro[i].a)         s += pro[i].b, sum++;       else         aa.push_back(pro[i]);     }     dp[0][s] = sum;     for (int i = 0; i < (int)(aa.size()); i++)       for (register int j = 0; j <= s; j++) {         if (j >= aa[i].a)           dp[i + 1][j + aa[i].b] = max(dp[i + 1][j + aa[i].b], dp[i][j] + 1);         dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]);       }     sum = 0;     for (register int i = 0; i <= s; i++) sum = max(sum, dp[(int)(aa.size())][i]);     printf( %d n , sum);     return 0;   }   