Language: C++

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

using ll = long long;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define ALL(c) (c).begin(), (c).end()
#define sz(v) (int)v.size()
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
const int MOD = 1000000007;
const int INF = 1000000001;
const char EOL = '\n';

void solve();

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
    solve();
    return 0;
}

void solve() {
    int n;
    ll k;
    cin >> n >> k;

    vector<ll> a(n);
    vector<ll> f(n);
    REP(i, n) cin >> a[i];
    REP(i, n) cin >> f[i];
    sort(ALL(a));
    sort(ALL(f), greater<int>());

    auto isOk = [&](ll m, ll x) {
        bool b = true;
        REP(i, n) if (a[i] * f[i] > m) {
            x -= a[i] - m / f[i];
            if (x < 0) {
                b = false;
                break;
            }
        }
        return b;
    };

    ll l = -1;
    ll r = (ll)INF * INF;
    while (abs(r - l) > 1) {
        ll m = (l + r) / 2;
        if (isOk(m, k)) {
            r = m;
        } else {
            l = m;
        }
    }
    cout << r << EOL;
}
#include <bits/stdc++.h>
using namespace std;

using ll = long long;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define ALL(c) (c).begin(), (c).end()
#define sz(v) (int)v.size()
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
const int MOD = 1000000007;
const int INF = 1000000001;
const char EOL = '\n';

void solve();

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
    solve();
    return 0;
}

void solve() {
    int n;
    ll k;
    cin >> n >> k;

    vector<ll> a(n);
    vector<ll> f(n);
    REP(i, n) cin >> a[i];
    REP(i, n) cin >> f[i];
    sort(ALL(a));
    sort(ALL(f), greater<int>());

    auto isOk = [&](ll m, ll x) {
        bool b = true;
        REP(i, n) if (a[i] * f[i] > m) {
            x -= a[i] - m / f[i];
            if (x < 0) {
                b = false;
                break;
            }
        }
        return b;
    };

    ll l = -1;
    ll r = (ll)INF * INF;
    while (abs(r - l) > 1) {
        ll m = (l + r) / 2;
        if (isOk(m, k)) {
            r = m;
        } else {
            l = m;
        }
    }
    cout << r << EOL;
}


Compiler output:
a.cc:75:31: error: redefinition of 'template<class T> bool chmin(T&, T)'
   75 | template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
      |                               ^~~~~
a.cc:12:31: note: 'template<class T> bool chmin(T&, T)' previously declared here
   12 | template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
      |                               ^~~~~
a.cc:76:31: error: redefinition of 'template<class T> bool chmax(T&, T)'
   76 | template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
      |                               ^~~~~
a.cc:13:31: note: 'template<class T> bool chmax(T&, T)' previously declared here
   13 | template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
      |                               ^~~~~
a.cc:77:11: error: redefinition of 'const int MOD'
   77 | const int MOD = 1000000007;
      |           ^~~
a.cc:14:11: note: 'const int MOD' previously defined here
   14 | const int MOD = 1000000007;
      |           ^~~
a.cc:78:11: error: redefinition of 'const int INF'
   78 | const int INF = 1000000001;
      |           ^~~
a.cc:15:11: note: 'const int INF' previously defined here
   15 | const int INF = 1000000001;
      |           ^~~
a.cc:79:12: error: redefinition of 'const char EOL'
   79 | const char EOL = '\n';
      |            ^~~
a.cc:16:12: note: 'const char EOL' previously defined here
   16 | const char EOL = '\n';
      |            ^~~
a.cc:83:5: error: redefinition of 'int main()'
   83 | int main() {
      |     ^~~~
a.cc:20:5: note: 'int main()' previously defined here
   20 | int main() {
      |     ^~~~
a.cc:91:6: error: redefinition of 'void solve()'
   91 | void solve() {
      |      ^~~~~
a.cc:28:6: note: 'void solve()' previously defined here
   28 | void solve() {
      |      ^~~~~