Language: C++

include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define int ll
#define openfiles ifstream in("input.txt");ofstream out("output.txt");
#define faster ios_base::sync_with_stdio(false);cin.tie();cout.tie();
openfiles;
struct obj
{
    int h,p;
};
int n;
vector<obj> vec;
vector<vector<int> >dp;
const int inf=1000000000000000ll;
bool cmp(obj x,obj y)
{
    return x.h+x.p<y.h+y.p;
}

void init()
{
    faster;
    cin>>n;
    vec.resize(n);
    for(int i=0;i<n;i++)
        cin>>vec[i].h>>vec[i].p;
    sort(vec.begin(),vec.end(),cmp);
    dp.resize(n,vector<int>(n+1,inf));
    dp[0][0]=0;
    dp[0][1]=vec[0].p;
}


int lazyDP(int pref,int used)
{
    if(pref<0||pref<used-1||used<0)
        return inf;
    if(dp[pref][used]!=inf)
        return dp[pref][used];
    if(lazyDP(pref-1,used-1)>vec[pref].h)
        dp[pref][used]=lazyDP(pref-1,used);
    else
        dp[pref][used]=min(lazyDP(pref-1,used),lazyDP(pref-1,used-1)+vec[pref].p);
    return dp[pref][used];
}

signed main()
{
    init();
    for(int i=n;i>=0;i--)
    {
        if(lazyDP(n-1,i)!=inf)
        {
            cout<<i;
            return 0;
        }
    }
    cout<<0;
    return 0;
}



Compiler output:
a.cc:1:1: error: 'include' does not name a type
    1 | include <bits/stdc++.h>
      | ^~~~~~~
a.cc:6:19: error: 'ifstream' does not name a type
    6 | #define openfiles ifstream in("input.txt");ofstream out("output.txt");
      |                   ^~~~~~~~
a.cc:8:1: note: in expansion of macro 'openfiles'
    8 | openfiles;
      | ^~~~~~~~~
a.cc:6:44: error: 'ofstream' does not name a type
    6 | #define openfiles ifstream in("input.txt");ofstream out("output.txt");
      |                                            ^~~~~~~~
a.cc:8:1: note: in expansion of macro 'openfiles'
    8 | openfiles;
      | ^~~~~~~~~
a.cc:14:1: error: 'vector' does not name a type
   14 | vector<obj> vec;
      | ^~~~~~
a.cc:15:1: error: 'vector' does not name a type
   15 | vector<vector<int> >dp;
      | ^~~~~~
a.cc: In function 'void init()':
a.cc:7:16: error: 'ios_base' has not been declared
    7 | #define faster ios_base::sync_with_stdio(false);cin.tie();cout.tie();
      |                ^~~~~~~~
a.cc:24:5: note: in expansion of macro 'faster'
   24 |     faster;
      |     ^~~~~~
a.cc:7:49: error: 'cin' was not declared in this scope
    7 | #define faster ios_base::sync_with_stdio(false);cin.tie();cout.tie();
      |                                                 ^~~
a.cc:24:5: note: in expansion of macro 'faster'
   24 |     faster;
      |     ^~~~~~
a.cc:7:59: error: 'cout' was not declared in this scope
    7 | #define faster ios_base::sync_with_stdio(false);cin.tie();cout.tie();
      |                                                           ^~~~
a.cc:24:5: note: in expansion of macro 'faster'
   24 |     faster;
      |     ^~~~~~
a.cc:26:5: error: 'vec' was not declared in this scope
   26 |     vec.resize(n);
      |     ^~~
a.cc:29:5: error: 'sort' was not declared in this scope; did you mean 'short'?
   29 |     sort(vec.begin(),vec.end(),cmp);
      |     ^~~~
      |     short
a.cc:30:5: error: 'dp' was not declared in this scope
   30 |     dp.resize(n,vector<int>(n+1,inf));
      |     ^~
a.cc:30:17: error: 'vector' was not declared in this scope
   30 |     dp.resize(n,vector<int>(n+1,inf));
      |                 ^~~~~~
a.cc:30:27: error: expected primary-expression before '>' token
   30 |     dp.resize(n,vector<int>(n+1,inf));
      |                           ^
a.cc: In function 'll lazyDP(ll, ll)':
a.cc:40:8: error: 'dp' was not declared in this scope
   40 |     if(dp[pref][used]!=inf)
      |        ^~
a.cc:42:30: error: 'vec' was not declared in this scope
   42 |     if(lazyDP(pref-1,used-1)>vec[pref].h)
      |                              ^~~
a.cc:43:9: error: 'dp' was not declared in this scope
   43 |         dp[pref][used]=lazyDP(pref-1,used);
      |         ^~
a.cc:45:9: error: 'dp' was not declared in this scope
   45 |         dp[pref][used]=min(lazyDP(pref-1,used),lazyDP(pref-1,used-1)+vec[pref].p);
      |         ^~
a.cc:45:24: error: 'min' was not declared in this scope
   45 |         dp[pref][used]=min(lazyDP(pref-1,used),lazyDP(pref-1,used-1)+vec[pref].p);
      |                        ^~~
a.cc:46:12: error: 'dp' was not declared in this scope
   46 |     return dp[pref][used];
      |            ^~
a.cc: In function 'int main()':
a.cc:56:13: error: 'cout' was not declared in this scope
   56 |             cout<<i;
      |             ^~~~
a.cc:60:5: error: 'cout' was not declared in this scope
   60 |     cout<<0;
      |     ^~~~