Language: C++

#include "bits/stdc++.h"
using namespace std;

#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define RREP(i,n) for(int (i)=(int)(n)-1;i>=0;i--)
#define REMOVE(Itr,n) (Itr).erase(remove((Itr).begin(),(Itr).end(),n),(Itr).end())
#define MOD  1000000007
#define INF  0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
typedef long long ll;

ll N,W;
ll w[110];
ll v[110];
ll dp[110][110][310];

int main() {
    
    cin >> N >> W;
    REP(i,N) cin >> w[i] >> v[i];

    ll w0 = w[0];
    REP(i,N) w[i] -= w0;
    
    REP(i,110)REP(k,110)REP(j,310) dp[i][k][j] = 0;
    
    for(int i=0;i<N;i++) {
        for(int k=0;k<N;k++){
            REP(j,310) dp[i+1][k+1][j] = dp[i][k+1][j];
            RREP(j,310) {
                if(j-w[i]>=0) {
                    dp[i+1][k+1][j] = max(dp[i+1][k+1][j],dp[i][k][j-w[i]] + v[i]);
                }
            }
        }
    }
    
    
    ll ans = 0;
    for(int k=1;k<=N;k++){
        ll Wt = W - w0 * k;
        REP(i,min(310,Wt+1)) ans = max(ans,dp[N][k][i]);
    }
    
    cout << ans << endl;
    
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:42:18: error: no matching function for call to 'min(int, ll)'
   42 |         REP(i,min(310,Wt+1)) ans = max(ans,dp[N][k][i]);
      |               ~~~^~~~~~~~~~
a.cc:4:42: note: in definition of macro 'REP'
    4 | #define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
      |                                          ^
In file included from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note:   template argument deduction/substitution failed:
a.cc:42:18: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'll' {aka 'long long int'})
   42 |         REP(i,min(310,Wt+1)) ans = max(ans,dp[N][k][i]);
      |               ~~~^~~~~~~~~~
a.cc:4:42: note: in definition of macro 'REP'
    4 | #define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
      |                                          ^
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
 5686 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
 5696 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note:   template argument deduction/substitution failed:
a.cc:42:18: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   42 |         REP(i,min(310,Wt+1)) ans = max(ans,dp[N][k][i]);
      |               ~~~^~~~~~~~~~
a.cc:4:42: note: in definition of macro 'REP'
    4 | #define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
      |                                          ^