Language: C++

//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define trav(x,a) for (const auto& x: a)
#define sz(x) (int)(x).size()
#define mem(a,v) memset((a), (v), sizeof (a))
#define enl printf("\n")
#define case(t) printf("Case #%d: ", (t))
#define ni(n) scanf("%d", &(n))
#define nl(n) scanf("%lld", &(n))
#define nai(a, n) for (int _i = 0; _i < (n); _i++) ni(a[_i])
#define nal(a, n) for (int _i = 0; _i < (n); _i++) nl(a[_i])
#define pri(n) printf("%d\n", (n))
#define prl(n) printf("%lld\n", (n))
#define pii pair<int, int>
#define pll pair<long long, long long>
#define vii vector<pii>
#define vll vector<pll>
#define vi vector<int>
#define vl vector<long long>
#define pb push_back
#define mp make_pair
#define st first
#define nd second
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef cc_hash_table<int,int,hash<int>> ht;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> oset;
const double pi = acos(-1);
const int mod = 1e9 + 7;
const int inf = 1e9 + 7;
const int N = 1e6 + 5;
const double eps = 1e-9;
ll a[3][3], b[3], it[3];

int main() {
  int n; scanf("%d", &n);
  for (int i = 0; i < 2; i++)
    for (int j = 0; j < 3; j++)
      scanf("%lld", &a[i][j]);
  ll ans = n;
  int c = 0;
  for (int i = 0; i < 3; i++)
    c += a[0][i] < a[1][i];
  for (int i = 0; i < 3; i++)
    it[i] = i;
  sort(it, it+3, [](int x, int y) { return a[1][x]-a[0][x] > a[1][y]-a[0][y]; });
  if (c == 3 || c == 0) {
    for (int i = 0; i < 3; i++) {
      b[i] = abs(a[0][i] - a[1][i]);
      a[0][i] = max(a[0][i], a[1][i]);
      a[1][i] = a[0][i] - b[i];
    }
    for (int i = 0; i <= n; i += a[1][0])
      for (int j = 0; j+i <= n; j += a[1][1])
        ans = max(ans, i/a[1][0] * a[0][0] + j/a[1][1] * a[0][1] + ((n-i-j)/a[1][2]) * a[0][2] + ((n-i-j) % a[1][2]));
  } else if (c == 2) {
    for (int i = 0; i <= n; i += a[0][it[0]])
      for (int j = 0; j+i <= n; j += a[0][it[1]]) {
        ll nx = i/a[0][it[0]] * a[1][it[0]] + j/a[0][it[1]] * a[1][it[1]] + (n-i-j);
        ans = max(ans, (nx/a[1][it[2]]) * a[0][it[2]] + (nx % a[1][it[2]]));
      }
  } else {
    for (int i = 0; i <= n; i += a[0][it[0]]) {
      ll nx = i/a[0][it[0]] * a[1][it[0]] + n - i;
      for (int j = 0; j <= min(n, nx); j += a[1][it[1]])
        ans = max(ans, j/a[1][it[1]]*a[0][it[1]] + ((nx-j)/a[1][it[2]]) * a[0][it[2]] + ((nx-j) % a[1][it[2]]));
    }
  }
  printf("%lld\n", ans);
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:68:31: error: no matching function for call to 'min(int&, ll&)'
   68 |       for (int j = 0; j <= min(n, nx); j += a[1][it[1]])
      |                            ~~~^~~~~~~
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:2:
/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:68:31: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'll' {aka 'long long int'})
   68 |       for (int j = 0; j <= min(n, nx); j += a[1][it[1]])
      |                            ~~~^~~~~~~
/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:68:31: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   68 |       for (int j = 0; j <= min(n, nx); j += a[1][it[1]])
      |                            ~~~^~~~~~~