Language: C++

#include<iostream>
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef vector <int> vi;
#define all(x) x.begin(), x.end()
#define sortall(x) sort(all(x))
typedef pair< int ,int > pii;
#define endl "\n"
#define sd(val) scanf("%d",&val)
#define ss(val) scanf("%s",&val)
#define sl(val) scanf("%lld",&val)
#define pt(x) cout<<x<<endl
#define deb(x) cout << #x << "=" << x << endl
#define PB push_back
#define MP make_pair
#define FF first
#define SS second
#define ll long long
typedef vector<ll> vl;
#define MOD 1000000007
#define clr(val) memset(val,0,sizeof(val))
#define what_is(x) cerr << #x << " is " << x << endl;
#define OJ \
    freopen("input.txt", "r", stdin); \
    freopen("output.txt", "w", stdout);
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
bool comp(const pii &a,const pii &b){
    // double a1=(double)a.second/a.first;
    // double a2=(double)b.second/b.first;
    // if(a1/!=a2){
        //return a1>a2;
    // }
    // else{
        return a.first<b.first;
    // }
}
int main()
{
//OJ;
 int t,n,m,a,b;
 cin >> n;
 long long w;
 cin>>w;
 vector<pair<long long,long,long>> arr(n,pair<long long,long,long>());
 rep(i,n){
    cin>>a>>b;
    arr[i].first=a;
    arr[i].second=b;
 }
 sort(all(arr),comp);
long long dp[n+1][w+1];
 for(int i=0;i<=w;i++){
     dp[0][i]=0;
    //  cout<<dp[0][i]<<" ";
 }
 for(int i=1;i<=n;i++){
    //  deb(arr[i].first);
     for(int j=0;j<=w;j++){
         if(arr[i-1].first>j){
             dp[i][j]=dp[i-1][j];
         }
         else{
             dp[i][j]=max(dp[i-1][j],arr[i-1].second+dp[i-1][j-arr[i-1].first]);
         }
        //  cout<<dp[i][j]<<" ";
     }
    //  cout<<endl;
 }
 pt(dp[n][w]);
return 0;  
}

Compiler output:
a.cc: In function 'int main()':
a.cc:45:29: error: wrong number of template arguments (3, should be 2)
   45 |  vector<pair<long long,long,long>> arr(n,pair<long long,long,long>());
      |                             ^~~~
In file included from /usr/include/c++/14/string:48,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_iterator.h:3013:12: note: provided for 'template<class _T1, class _T2> struct std::pair'
 3013 |     struct pair;
      |            ^~~~
a.cc:45:33: error: template argument 1 is invalid
   45 |  vector<pair<long long,long,long>> arr(n,pair<long long,long,long>());
      |                                 ^~
a.cc:45:33: error: template argument 2 is invalid
a.cc:45:66: error: wrong number of template arguments (3, should be 2)
   45 |  vector<pair<long long,long,long>> arr(n,pair<long long,long,long>());
      |                                                                  ^
/usr/include/c++/14/bits/stl_iterator.h:3013:12: note: provided for 'template<class _T1, class _T2> struct std::pair'
 3013 |     struct pair;
      |            ^~~~
a.cc:45:69: error: expression list treated as compound expression in initializer [-fpermissive]
   45 |  vector<pair<long long,long,long>> arr(n,pair<long long,long,long>());
      |                                                                     ^
a.cc:48:8: error: invalid types 'int[int]' for array subscript
   48 |     arr[i].first=a;
      |        ^
a.cc:49:8: error: invalid types 'int[int]' for array subscript
   49 |     arr[i].second=b;
      |        ^
a.cc:6:18: error: request for member 'begin' in 'arr', which is of non-class type 'int'
    6 | #define all(x) x.begin(), x.end()
      |                  ^~~~~
a.cc:51:7: note: in expansion of macro 'all'
   51 |  sort(all(arr),comp);
      |       ^~~
a.cc:6:29: error: request for member 'end' in 'arr', which is of non-class type 'int'
    6 | #define all(x) x.begin(), x.end()
      |                             ^~~
a.cc:51:7: note: in expansion of macro 'all'
   51 |  sort(all(arr),comp);
      |       ^~~
a.cc:60:16: error: invalid types 'int[int]' for array subscript
   60 |          if(arr[i-1].first>j){
      |                ^
a.cc:64:41: error: invalid types 'int[int]' for array subscript
   64 |              dp[i][j]=max(dp[i-1][j],arr[i-1].second+dp[i-1][j-arr[i-1].first]);
      |                                         ^
a.cc:64:67: error: invalid types 'int[int]' for array subscript
   64 |              dp[i][j]=max(dp[i-1][j],arr[i-1].second+dp[i-1][j-arr[i-1].first]);
      |                                                                   ^