Language: C++

//Code by : Abhishek Tiwari
//codechef.com/users/devil_within || hackerearth.com/@devil_within
#include<bits/stdc++.h>
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long int 
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define repr(i,a,b) for(int i=(a);i>(b);--i)
#define mp make_pair
#define pb push_back
#define pf push_front
#define pii pair<int,int> 
#define ff first
#define ss second 
#define mod 1000000007
#define gcd __gcd
#define lcm(a,b) ((a)*(b))/gcd(a,b)
using namespace std;

/*******************************************************************************************/
/*******************************************************************************************/
template <typename T> ostream& operator<<(ostream& os, const vector<T>& v) { 
    os<<"["; for(int i=0;i<v.size()-1; ++i)os<<v[i]<<", ";os<<v[v.size()-1]<<"]\n"; return os; 
} 
template <typename T> ostream& operator<<(ostream& os, const set<T>& v) { 
    os<<"{"; for(auto it : v) { os<<it; if(it!=*v.rbegin()) os<<", "; } os<<"}\n"; 
    return os; 
}
template <typename T, typename S> ostream& operator<<(ostream& os, const map<T, S>& v) { 
    os<<"{"; for(auto it:v){ os<<"("<<it.first<<" : "<<it.second<<")"; if(it!=*v.rbegin()) os<<", "; } os<<"}\n"; 
    return os; 
}
template <typename T, typename S> ostream& operator<<(ostream& os, const pair<T, S>& v) { 
    os<<"("; os<<v.first<<", "<< v.second<<")"; 
    return os; 
} 
/*******************************************************************************************/
/*******************************************************************************************/
template<typename T> maxi(T a , T b) {return a>b ? a : b;}
template<typename T> mini(T a , T b) {return a<b ? a : b;}
int fpow(int x, int y, int p); 
int32_t main()  
{
#ifndef ONLINE_JUDGE
//freopen("input.txt" , "r" , stdin);freopen("output.txt" , "w" , stdout);freopen("error.txt" , "w" , stderr);
#endif
fio;
int tcases = 1;
//cin>>tcases;
for(int tcase = 1 ; tcase <= tcases ; ++tcase)
{
    int n ,w;
    cin>>n >> w;
    vector<int> v(n) , wt(n);
    rep(i , 0 , n)
        cin>> wt[i] >> v[i];
    //cout<<v<<wt;  
    int dp[n+1][w+1];
    rep(i , 0 , w+1)
        dp[0][i] = 0;
    rep(i , 0 , n+1)
        dp[i][0] = 0;
    rep(i , 1 , n+1)
        rep(j , 1 , w+1)
        {
            if(j >= wt[i-1])
            dp[i][j] = maxi( v[i-1] + dp[i-1][j - wt[i-1] ] , dp[i-1][j] );
            else
            dp[i][j] = dp[i-1][j];            
        }
    cout<<dp[n][w];
    //cout<<"Case #"<<tcase<<": ";
}
return 0;
}



//Functions 

int fpow(int x, int y, int p) { 
    int res = 1; 
   x = x % p;  
   while (y > 0) { 
     if (y & 1) 
        res = (res * x) % p; 
     y = y >> 1; 
        x = (x * x) % p; 
    } 
    return res; 
} 


Compiler output:
a.cc:38:22: error: ISO C++ forbids declaration of 'maxi' with no type [-fpermissive]
   38 | template<typename T> maxi(T a , T b) {return a>b ? a : b;}
      |                      ^~~~
a.cc:39:22: error: ISO C++ forbids declaration of 'mini' with no type [-fpermissive]
   39 | template<typename T> mini(T a , T b) {return a<b ? a : b;}
      |                      ^~~~