Language: C++

#include <bits/stdc++.h>
using namespace std;       //     ____   _   _  __   __
#define ll long long       //    / ___| | |_| |   / /
const ll INF = 0x3f3f3f3f; //   | |     |  _  |   V /
const ll N   = 1e5 + 5;    //   | |___  | | | |   | |
const ll MOD = 1e9 + 7;    //    ____| |_| |_|   |_|
ll read() {
  ll   x = 0, f = 1;
  char ch = getchar();

  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1; ch = getchar();
  }

  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0'; ch = getchar();
  }
  return x * f;
}

ll n, m, dp[N];
struct node {
  ll x, y;
}  a[N];
ll ans;
ll cmp(node a, node b) {
  return a.y < b.y;
}

int main() {
  n = read(), m = read();

  for (int i = 1; i <= n; i++) {
    a[i].x = read(), a[i].y = read();
  }
  sort(a + 1, a + 1 + n, cmp);

  for (int i = 1; i <= n; i++) {
    for (int j = m; j >= a[i].x; j--) {
      dp[j] = max(dp[j], dp[j - a[i].x] + a[i].y);
    }
  }
  ans = dp[m];

  for (int k = max(1, n - 100); k <= n; k++) {
    for (int i = 0; i <= m; i++) dp[i] = 0;

    for (int i = 1; i <= n; i++) {
      if (i == k) continue;

      for (int j = m; j >= a[i].x; j--) {
        dp[j] = max(dp[j], dp[j - a[i].x] + a[i].y);
      }
    }

    for (int i = 0; i < m; i++) {
      ans = max(ans, dp[i] + a[k].y);
    }
  }


  cout << ans << endl;
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:45:19: error: no matching function for call to 'max(int, long long int)'
   45 |   for (int k = max(1, n - 100); k <= n; k++) {
      |                ~~~^~~~~~~~~~~~
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:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
a.cc:45:19: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   45 |   for (int k = max(1, n - 100); k <= n; k++) {
      |                ~~~^~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:303: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:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
 5706 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note:   template argument deduction/substitution failed:
a.cc:45:19: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   45 |   for (int k = max(1, n - 100); k <= n; k++) {
      |                ~~~^~~~~~~~~~~~