criyle/codenet-compile-errors huggingface dataset:
Language: C++

#include <bits/stdc++.h>
#include <boost/range.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/algorithm_ext.hpp>
#include <boost/range/numeric.hpp>
#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>
#include <boost/math/constants/constants.hpp>
using namespace std;
namespace rng {
    using namespace boost::range;
    using namespace boost::adaptors;
}

struct init_ { init_(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(10); } } init_;

using boost::irange;
using boost::math::double_constants::pi;
using i64 = int64_t;
constexpr char nl = '\n';
auto yesno(bool b) { return b ? "Yes" : "No"; }

template<class T> istream& operator>>(istream& in, vector<T>& vs) { for (T& v :vs) in >> v; return in; }
template<class T> ostream& operator<<(ostream& out, const vector<T>& vs) { for (size_t i = 0; i < vs.size(); ++i) { if(i) { out << ' '; } out << vs[i]; } return out; }
template<size_t N, class T, class R> using when_last = typename enable_if<N == tuple_size<remove_reference_t<T>>::value - 1, R>::type;
template<size_t N, class T, class R> using when_init = typename enable_if<N != tuple_size<remove_reference_t<T>>::value - 1, R>::type;
template<size_t N = 0, class T> auto operator>>(istream& in, T&& t) -> when_last<N, T, istream&> { return in >> get<N>(t); }
template<size_t N = 0, class T> auto operator>>(istream& in, T&& t) -> when_init<N, T, istream&> { return operator>><N + 1>(in >> get<N>(t), forward<T>(t)); }
template<size_t N = 0, class T> auto operator<<(ostream& out, const T& t) -> when_last<N, T, ostream&> { return out << get<N>(t); }
template<size_t N = 0, class T> auto operator<<(ostream& out, const T& t) -> when_init<N, T, ostream&> { return operator<<<N + 1>(out << get<N>(t) << ' ', t); }

#ifdef LOCAL
template<class T> void trace_(const T& v) { cout << v; }
template<class T> void trace_(const vector<vector<T>>& m) { cout << nl; for (const auto& v : m) { trace_(v); cout << nl; } }
template<class T> void trace_(const char* s, const T& v) { cout << s << "="; trace_(v); cout << nl; }
template<class T, class... Ts> void trace_(const char* s, const T& v, const Ts&... vs) { for (; *s != ','; ++s) { cout << *s; } cout << "="; trace_(v); cout << ","; trace_(++s, vs...); }
#define TRACE(...) trace_(#__VA_ARGS__, __VA_ARGS__)
#else
#define TRACE(...)
#endif

int main() {
    i64 N, K;
    cin >> N >> K;
    vector<i64> A(N), F(N);
    cin >> A >> F;
    rng::sort(A);
    rng::sort(F, greater<i64>());
    auto r = irange(i64(1e12));
    auto m = partition_point(begin(r), end(r), [&](i64 x) {
        TRACE(x);
        auto k = K;
        for (auto i : irange(0l, N)) {
            if (A[i] * F[i] > x) {
                k -= A[i] - x / F[i];
                TRACE(x, i, A[i], F[i], k);
                if (k < 0) {
                    return true;
                }
            }
        }
        return false;
    });
    cout << *m << nl;
}


Compiler output:
a.cc:2:10: fatal error: boost/range.hpp: No such file or directory
    2 | #include <boost/range.hpp>
      |          ^~~~~~~~~~~~~~~~~
compilation terminated.
Language: C++

#include <bits/stdc++.h>
#include <boost/range.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/algorithm_ext.hpp>
#include <boost/range/numeric.hpp>
#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>
#include <boost/math/constants/constants.hpp>
using namespace std;
namespace rng {
    using namespace boost::range;
    using namespace boost::adaptors;
}

struct init_ { init_(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(10); } } init_;

using boost::irange;
using boost::math::double_constants::pi;
using i64 = int64_t;
constexpr char nl = '\n';
auto yesno(bool b) { return b ? "Yes" : "No"; }

template<class T> istream& operator>>(istream& in, vector<T>& vs) { for (T& v :vs) in >> v; return in; }
template<class T> ostream& operator<<(ostream& out, const vector<T>& vs) { for (size_t i = 0; i < vs.size(); ++i) { if(i) { out << ' '; } out << vs[i]; } return out; }
template<size_t N, class T, class R> using when_last = typename enable_if<N == tuple_size<remove_reference_t<T>>::value - 1, R>::type;
template<size_t N, class T, class R> using when_init = typename enable_if<N != tuple_size<remove_reference_t<T>>::value - 1, R>::type;
template<size_t N = 0, class T> auto operator>>(istream& in, T&& t) -> when_last<N, T, istream&> { return in >> get<N>(t); }
template<size_t N = 0, class T> auto operator>>(istream& in, T&& t) -> when_init<N, T, istream&> { return operator>><N + 1>(in >> get<N>(t), forward<T>(t)); }
template<size_t N = 0, class T> auto operator<<(ostream& out, const T& t) -> when_last<N, T, ostream&> { return out << get<N>(t); }
template<size_t N = 0, class T> auto operator<<(ostream& out, const T& t) -> when_init<N, T, ostream&> { return operator<<<N + 1>(out << get<N>(t) << ' ', t); }

#ifdef LOCAL
template<class T> void trace_(const T& v) { cout << v; }
template<class T> void trace_(const vector<vector<T>>& m) { cout << nl; for (const auto& v : m) { trace_(v); cout << nl; } }
template<class T> void trace_(const char* s, const T& v) { cout << s << "="; trace_(v); cout << nl; }
template<class T, class... Ts> void trace_(const char* s, const T& v, const Ts&... vs) { for (; *s != ','; ++s) { cout << *s; } cout << "="; trace_(v); cout << ","; trace_(++s, vs...); }
#define TRACE(...) trace_(#__VA_ARGS__, __VA_ARGS__)
#else
#define TRACE(...)
#endif

int main() {
    i64 N, K;
    cin >> N >> K;
    vector<i64> A(N), F(N);
    cin >> A >> F;
    rng::sort(A);
    rng::sort(F, greater<i64>());
    auto r = irange(i64(1e12));
    auto m = partition_point(begin(r), end(r), [&](i64 x) {
        TRACE(x);
        auto k = K;
        for (auto i : irange(N)) {
            if (A[i] * F[i] > x) {
                k -= A[i] - x / F[i];
                TRACE(x, i, A[i], F[i], k);
                if (k < 0) {
                    return true;
                }
            }
        }
        return false;
    });
    cout << *m << nl;
}


Compiler output:
a.cc:2:10: fatal error: boost/range.hpp: No such file or directory
    2 | #include <boost/range.hpp>
      |          ^~~~~~~~~~~~~~~~~
compilation terminated.
Language: C++

#include <bits/stdc++.h>
using namespace std;
int main(){
    long long int N,K;
    long long int i;
    cin >> N >> K;
    long long int A[N],F[N];
    long long int MAX=1e12+10;
    long long int MIN=0;
    long long int MID;
    long long int preMIN
    long long int k;
    int flag;
    for(i=0;i<N;i++)cin >> A[i];
    for(i=0;i<N;i++)cin >> F[i];
    sort(A,A+N);
    sort(F,F+N);
    long long int B[N];
    for(i=0;i<N;i++)B[i]=A[i]*F[N-i-1];
    while(MAX!=MIN){
        k=0;
        flag=0;
        MID=(MAX+MIN)/2;
        for(i=0;i<N;i++){
            if(B[i]>MID)k+=(A[i]-(MID/F[N-i-1]));
            if(k>=K){
                flag++;
                break;
            }
        }
        if(flag>0)MIN=MID;
        else{MAX=MID+1;}
    }
    cout << MAX << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:12:5: error: expected initializer before 'long'
   12 |     long long int k;
      |     ^~~~
a.cc:21:9: error: 'k' was not declared in this scope
   21 |         k=0;
      |         ^
Language: C++

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

int main(){
    int n,k;cin>>n>>k;
    vector<int> a(n),f(n);
    for(int i = 0; i < n; i++) cin>>a[i];
    for(int i = 0; i < n; i++) cin>>f[i];

    sort(a.begin(),a.end());
    sort(f.rbegin(),f.rend());

    ll l = -1, r = 1e12;

    hile(l+1<r){
        ll c=(l+r)/2;
        bool ok = [&]{
            ll s = 0;
            for(int i = 0; i < n; i++){
                s+=max(0LL,a[i]-c/f[i]);
            }
            return s<=k;
        }();
        if(ok) r = c; 
        else l = c;
    }
    cout<<r;
    
}


Compiler output:
a.cc: In function 'int main()':
a.cc:16:5: error: 'hile' was not declared in this scope
   16 |     hile(l+1<r){
      |     ^~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=1000000007;
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b+1;i++)
#define Per(i,b,a) for(int i=b;i>=a;i--)

int N;
ll K;
vector<ll>A,F;

bool time_check(ll T){
    ll needs = 0;
    rep(i,N){
        ll cost = T/F[i];
        needs += max(A[N-1-i]-cost,0ll);
    }
    if(needs <= K) return true;
    else return false; 
}

void solve(ll start,ll end){
    // start : impossible, end : possible
    if(end == start + 1){
        cout<<end<<endl;
        return ;
    }
    ll t = (end+start)/2;
    if(time_check(t)) solve(start,t);
    else solve(t,end);
}

int main(){
    ll a,f;
    cin>>N>>K;
    ll sum = 0;
    rep(i,N){
        cin>>a;
        A.push_back(a);
        sum+=a;
    }
    if(sum<=K){
        cout<<0<<endl;
        return 0;
    }
    rep(i,N) {
        cin>>f;
        F.push_back(f);
    }
    sort(A.begin(),A.end());
    sort(F.begin(),F.end());
    // rep(i,N) cout<<A[i]<<" ";
    // cout<<endl;
    // rep(i,N) cout<<F[i]<<" ";
    // cout<<endl;
    solve(N,K,A,F,0ll,(ll)10000000000000);
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:57:10: error: too many arguments to function 'void solve(ll, ll)'
   57 |     solve(N,K,A,F,0ll,(ll)10000000000000);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:23:6: note: declared here
   23 | void solve(ll start,ll end){
      |      ^~~~~
Language: C++

#include<iostream>
#include<algorithm>
#define LL long long
using namespace std;
int N;
int A[200002];
int F[200002];
int col[200002];
int K;

int cmp1(int a,int b)
{
    return b<a;
}
bool check(LL x)
{
    LL ye=0;
    for(int i=0; i<N; i++)
    {
        if(A[i]*F[i]<=x)
            continue;
        else
        {
            LL need=x/F[i];
            ye+=A[i]-need;
        }
    }
    if(ye<=K)
        return true;
    else
        return false;
}

int main()
{
    cin>>N;
    cin>>K;
    int sum=0;
    for(int i=0; i<N; i++)
    {
        cin>>A[i];
        sum += A[i];
    }

    sort(A,A+N);
    for(int i=0; i<N; i++)
        cin>>F[i];
    sort(F,F+N,cmp1);

    if (sum <= k)
    {
        cout << 0 << "\n";
        return 0;
    }
    else
    {
        LL l=0,r=1e12,m,ans=0;

        while(l<=r)
        {
            m=(r-l)/2+l;
            if(check(m))
                r=m-1,ans=m;
            else
                l=m+1;
        }
        cout<<ans<<"\n";
    }

}






Compiler output:
a.cc: In function 'int main()':
a.cc:50:16: error: 'k' was not declared in this scope
   50 |     if (sum <= k)
      |                ^
Language: C++

#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
using namespace std;
typedef long long ll;
inline 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<<1)+(x<<3)+(ch^48); ch=getchar(); }
    return x*f;
}
const int N=2e5+7;
const ll INF=1e12;
ll n,m,A[N],F[N];
inline bool check(ll p)
{
    ll now=m;
    for(int i=1;i<=n;i++)
    {
        // af<=p , a<=p/f
        if(p/F[i]>=A[i]) continue;
        ll t=A[i]-p/F[i];
        if(t>now) return 0;
        now-=t;
    }
    return 1;
}
int main()
{
    n=read(),m=read();
    for(int i=1;i<=n;i++) A[i]=read();
    for(int i=1;i<=n;i++) F[i]=read();
    sort(A+1,A+n+1); sort(F+1,F+n+1);
    reverse(F+1,F+n+1);
    ll L=0,R=INF,ans=0;
    while(L<=R)
    {
        ll mid=L+R>>1;
        if(check(mid)) R=mid-1,ans=mid;
        else L=mid+1;
    }
    printf("%lld\n",ans);
    return 0;
}

E

Compiler output:
a.cc:49:1: error: 'E' does not name a type
   49 | E
      | ^
Language: C++

#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<vector>
using namespace std;
typedef long long ll;
typedef double db;
inline int read()
{
    int 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<<1)+(x<<3)+(ch^48); ch=getchar(); }
    return x*f;
}
const int N=607,INF=1e9;
int n,m,a[N*N],b[N*N];
vector <int> V[N];
db f[N],ans;
inline db calc(int p)
{
    for(int i=1;i<=n;i++) f[i]=0;
    f[n]=0;
    for(int i=n-1;i>=1;i--)
    {
        int len=V[i].size();
        if(p==i&&len==1) { f[i]=INF; continue; }
        db t=1.0/(len-(p==i)),mx=0;
        for(int j=0;j<len;j++)
        {
            int v=V[i][j]; mx=max(mx,(f[v]+1)*t);
            f[i]+=(f[v]+1)*t;
        }
        if(p==i) f[i]-=mx;
    }
    return f[1];
}
int main()
{
    n=read(),m=read();
    for(int i=1;i<=m;i++)
    {
        a[i]=read(),b[i]=read();
        V[a[i]].push_back(b[i]);
    }
    ans=calc(0);
    for(int i=1;i<=n;i++)
        ans=min(ans,calc(i));
    printf("%.9lf\n",ans);
    return 0;
}

F

Compiler output:
a.cc:54:1: error: 'F' does not name a type
   54 | F
      | ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int M=2e5+5;
ll a[M],f[M];
ll n;ll k,tot=0;
int check(ll x)
{
    ll cost=0;
    for(int i=1;i<=n;i++)cost+=max(a[i]-x/f[i],0);
    if(cost<=k)return 1;return 0;
}
int main()
{
    scanf("%lld%lld",&n,&k);
    for(int i=1;i<=n;i++){scanf("%lld",&a[i]);tot+=a[i];}
    for(int i=1;i<=n;i++)scanf("%lld",&f[i]);
    if(tot<=k)return 0*printf("0\n");
    sort(a+1,a+1+n);sort(f+1,f+1+n);
    reverse(f+1,f+n+1);
    ll l=0,r=(ll)1e12;
    while(l<r)
    {
        int mid=(l+r)/2;
        if(check(mid))r=mid;
        else l=mid+1;
    }
    printf("%lld\n",l);
    return 0;
}


Compiler output:
a.cc: In function 'int check(ll)':
a.cc:10:35: error: no matching function for call to 'max(ll, int)'
   10 |     for(int i=1;i<=n;i++)cost+=max(a[i]-x/f[i],0);
      |                                ~~~^~~~~~~~~~~~~~~
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:10:35: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   10 |     for(int i=1;i<=n;i++)cost+=max(a[i]-x/f[i],0);
      |                                ~~~^~~~~~~~~~~~~~~
/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:10:35: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   10 |     for(int i=1;i<=n;i++)cost+=max(a[i]-x/f[i],0);
      |                                ~~~^~~~~~~~~~~~~~~
Language: C++

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

int main() {
  ll n, k;
  cin >> n >> k;

  vector<ll> A(n), F(n);
  for (ll i = 0; i < n; i++) cin >> A[i];
  for (ll i = 0; i < n; i++) cin >> F[i];

  sort(A.begin(), A.end()); //ascending order
  sort(F.begin(), F.end());
  reverse(F.begin(), F.end()); //descending order

  //決め打ちで二分探索する
  ll left = -1; //leftは絶対にfalseになる値にする
  ll right = (ll)1e12+1;

  while (left + 1 < right) {
    ll mid = (left + right)/2;
    double reduce_sum = 0;
    for (ll i = 0; i < n; i++) {
      reduce_sum += max(0, (A[i] - (double)mid/F[i]));
    }
    if (reduce_sum < k) right = mid;
    else left = mid;
  }

  cout << right << endl;
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:25:24: error: no matching function for call to 'max(int, double)'
   25 |       reduce_sum += max(0, (A[i] - (double)mid/F[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: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:25:24: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'double')
   25 |       reduce_sum += max(0, (A[i] - (double)mid/F[i]));
      |                     ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/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:25:24: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   25 |       reduce_sum += max(0, (A[i] - (double)mid/F[i]));
      |                     ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Language: C++

#include "bits/stdc++.h"

//region Template
#include "ext/pb_ds/assoc_container.hpp"

using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef long double ld;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

const int MOD = 1000000007;
using namespace std;
#define finish(x) cout << x; exit(0);
#define fastIO cin.tie(0); cin.sync_with_stdio(false);
#define endl '\n'

void setIn(string s) { freopen(s.c_str(), "r", stdin); }
void setOut(string s) { freopen(s.c_str(),"w",stdout); }

//const string USCAO_TAG = "mountains";
void usaco(const string& USACO_TAG) { setIn(USACO_TAG + ".in"); setOut(USACO_TAG + ".out"); }
void print() {}
template<typename T, typename... Args>
void print(T firstArg, Args... args) {
	#ifdef LOCAL
	cout << firstArg << " ";
	print(args...);
	#endif
}
//endregion

/* Notes:
 * Farah </3
 */

const int MAXN = 1e6 + 5;
const int INF = 2e9;
int freq[MAXN];

int main() {
	//usaco("milkvisits");

	#ifdef LOCAL
	setIn("in.txt");
	setOut("out.txt");
	#endif

	int n;
	cin >> n;

	ll a[n], b[n];

	ll k;
	cin >> k;

	
	for(int i = 0; i < n; i++){
		cin >> a[i];
	}

	for(int i = 0; i < n; i++){
		cin >> b[i];
	}
	sort(b, b + n, greater<int>());
	sort(a, a + n);

	ll l = 0, r = 1e18;
	ll ans = 2e18;
	while(l <= r){
		ll m = (l + r) / 2;

		ll need = 0;
		for(int i = 0; i < n; i++){
			int y = max(0ll, a[i] - (m / b[i]));

			need += y + ((a[i] - y) * b[i] > m);
		}

		if(need > k){
			l = m + 1;
		}
		else {
			r = m - 1;
			ans = m;
		}
	}

	cout << ans;
	return 0;
	for(int i = 0; i < n; i++) cout << a[i] << "\t";
	cout << endl;
	for(int i = 0; i < n; i++) cout << b[i] << "\t";
	cout << endl;
	for(int i = 0; i < n; i++) cout << a[i] * b[i] << "\t";
	cout << endl;
	while(k){
		int need = freq[mx];

		if(need <= k){
			k -= need;
			freq[mx - 1] += freq[mx];
			freq[mx] = 0;
		}
		else {
			freq[mx - 1] += k;
			freq[mx] -= k;
			break;
		}
		mx--;
	}
	vector<int> num;
	for(int i = 0; i < MAXN; i++){
		while(freq[i] > 0){
			num.push_back(i);
			freq[i]--;
		}
	}

	ll ans2 = 0;
	for(int i = 0; i < n; i++){
		ans = max(ans, (ll)num[i] * b[i]);
	}

	finish(ans);
}

Compiler output:
a.cc: In function 'int main()':
a.cc:99:33: error: 'mx' was not declared in this scope
   99 |                 int need = freq[mx];
      |                                 ^~
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
#define Priq priority_queue<int,vi,greater<int>>
#define pb push_back
#define mp make_pair
#define INF (1ll<<60)
int N;
int A[200000],F[200000];
int func(int X){
  int ret=0;
  rep(i,0,N)
    ret+=max(0ll,A[i]-X/F[i]);
  return ret;
}
signed main(){
  int K; cin>>N>>K;
  rep(i,0,N) cin>>A[i];
  rep(i,0,N) cin>>F[i];
  sort(A,A+N);
  sort(F,F+N,greater<int>()):
  int left=0,right=1000000000000;
  while(left+1<right){
    int mid=(left+right)/2;
    if(func(mid)<=K)
      left=mid;
    else
      right=mid;
  }
  cout<<left<<endl;
  }


Compiler output:
a.cc: In function 'int main()':
a.cc:32:29: error: expected ';' before ':' token
   32 |   sort(F,F+N,greater<int>()):
      |                             ^
      |                             ;
a.cc:34:13: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   34 |   while(left+1<right){
      |         ~~~~^~
a.cc:35:18: error: invalid operands of types 'std::ios_base&(std::ios_base&)' and 'std::ios_base&(std::ios_base&)' to binary 'operator+'
   35 |     int mid=(left+right)/2;
      |              ~~~~^~~~~~
      |              |    |
      |              |    std::ios_base&(std::ios_base&)
      |              std::ios_base&(std::ios_base&)
a.cc:37:11: error: assignment of function 'std::ios_base& std::left(ios_base&)'
   37 |       left=mid;
      |       ~~~~^~~~
a.cc:39:12: error: assignment of function 'std::ios_base& std::right(ios_base&)'
   39 |       right=mid;
      |       ~~~~~^~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
#define Priq priority_queue<int,vi,greater<int>>
#define pb push_back
#define mp make_pair
#define INF (1ll<<60)
int N;
int A[200000],F[200000];
int func(int X){
  int ret=0;
  rep(i,0,N)
    ret+=max(0ll,A[i]-X/F[i]);
  return ret;
}
signed main(){
  int K; cin>>N>>K;
  rep(i,0,N) cin>>A[i];
  rep(i,0,N) cin>>F[i];
  sort(A.begin(),A.begin()+N);
  sort(F.begin(),F.begin()+N,vi,greater<int>()):
  int left=0,right=1000000000000;
  while(left+1<right){
    int mid=(left+right)/2;
    if(func(mid)<=K)
      left=mid;
    else
      right=mid;
  }
  cout<<left<<endl;
  }


Compiler output:
a.cc: In function 'int main()':
a.cc:31:10: error: request for member 'begin' in 'A', which is of non-class type 'long long int [200000]'
   31 |   sort(A.begin(),A.begin()+N);
      |          ^~~~~
a.cc:31:20: error: request for member 'begin' in 'A', which is of non-class type 'long long int [200000]'
   31 |   sort(A.begin(),A.begin()+N);
      |                    ^~~~~
a.cc:32:10: error: request for member 'begin' in 'F', which is of non-class type 'long long int [200000]'
   32 |   sort(F.begin(),F.begin()+N,vi,greater<int>()):
      |          ^~~~~
a.cc:32:20: error: request for member 'begin' in 'F', which is of non-class type 'long long int [200000]'
   32 |   sort(F.begin(),F.begin()+N,vi,greater<int>()):
      |                    ^~~~~
a.cc:32:32: error: expected primary-expression before ',' token
   32 |   sort(F.begin(),F.begin()+N,vi,greater<int>()):
      |                                ^
a.cc:34:13: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   34 |   while(left+1<right){
      |         ~~~~^~
a.cc:35:18: error: invalid operands of types 'std::ios_base&(std::ios_base&)' and 'std::ios_base&(std::ios_base&)' to binary 'operator+'
   35 |     int mid=(left+right)/2;
      |              ~~~~^~~~~~
      |              |    |
      |              |    std::ios_base&(std::ios_base&)
      |              std::ios_base&(std::ios_base&)
a.cc:37:11: error: assignment of function 'std::ios_base& std::left(ios_base&)'
   37 |       left=mid;
      |       ~~~~^~~~
a.cc:39:12: error: assignment of function 'std::ios_base& std::right(ios_base&)'
   39 |       right=mid;
      |       ~~~~~^~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
#define Priq priority_queue<int,vi,greater<int>>
#define pb push_back
#define mp make_pair
#define INF (1ll<<60)
int N;
int A[200000],F[200000];
int func(int X){
  int ret=0;
  rep(i,0,N)
    ret+=max(0ll,A[i]-X/F[i]);
  return ret;
}
signed main(){
  int K; cin>>N>>K;
  rep(i,0,N) cin>>A[i];
  rep(i,0,N) cin>>F[i];
  sort(A.begin(),A.begin()+N);
  sort(A.begin(),A.begin()+N,vi,greater<int>()):
  int left=0,right=1000000000000;
  while(left+1<right){
    int mid=(left+right)/2;
    if(func(mid)<=K)
      left=mid;
    else
      right=mid;
  }
  cout<<left<<endl;
  }


Compiler output:
a.cc: In function 'int main()':
a.cc:31:10: error: request for member 'begin' in 'A', which is of non-class type 'long long int [200000]'
   31 |   sort(A.begin(),A.begin()+N);
      |          ^~~~~
a.cc:31:20: error: request for member 'begin' in 'A', which is of non-class type 'long long int [200000]'
   31 |   sort(A.begin(),A.begin()+N);
      |                    ^~~~~
a.cc:32:10: error: request for member 'begin' in 'A', which is of non-class type 'long long int [200000]'
   32 |   sort(A.begin(),A.begin()+N,vi,greater<int>()):
      |          ^~~~~
a.cc:32:20: error: request for member 'begin' in 'A', which is of non-class type 'long long int [200000]'
   32 |   sort(A.begin(),A.begin()+N,vi,greater<int>()):
      |                    ^~~~~
a.cc:32:32: error: expected primary-expression before ',' token
   32 |   sort(A.begin(),A.begin()+N,vi,greater<int>()):
      |                                ^
a.cc:34:13: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   34 |   while(left+1<right){
      |         ~~~~^~
a.cc:35:18: error: invalid operands of types 'std::ios_base&(std::ios_base&)' and 'std::ios_base&(std::ios_base&)' to binary 'operator+'
   35 |     int mid=(left+right)/2;
      |              ~~~~^~~~~~
      |              |    |
      |              |    std::ios_base&(std::ios_base&)
      |              std::ios_base&(std::ios_base&)
a.cc:37:11: error: assignment of function 'std::ios_base& std::left(ios_base&)'
   37 |       left=mid;
      |       ~~~~^~~~
a.cc:39:12: error: assignment of function 'std::ios_base& std::right(ios_base&)'
   39 |       right=mid;
      |       ~~~~~^~~~
Language: C++

//g++ -std=c++14 test.cpp -o test.out
//問題URL
//https://atcoder.jp/contests/abc144/tasks/abc144_e
//二部探索
//答えを「とりあえず」centerと決めて、とりあえず決めた値をleft,rightを使って範囲を狭めていく
//解から逆算するイメージで実装していく
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <map> 
#include <utility>
#include <limits.h>
#include <bitset>
using namespace std;
 
#define LL long long int
const LL INF = (LL)(1e18)+1;
const LL mod = 1000000007ll;

LL N,K;
LL A[200000],F[200000];

LL ans = 0;

void solve(){
	sort(A,A+N);//昇順
	sort(F,F+N,greater<LL>());//降順
	//二部探索
	LL left = -1;//ギリギリ実現不可能な時間
	LL right = 1e12;//ギリギリ実現可能な時間
	while(left+1<right){
		LL center = (left+right)/2;
		//消化コストA[i]から修行してA'[i]に減らせたとする
		//このときかかる時間は　A'[i]×F[i] = T[i] とおける
		//変形して A'[i] = T[i]/F[i]
		//このとき修行の結果落とせた消化コストは
		//A[i] - T[i]/F[i] と表せる
		//この和はK以下でなくてはならない

		//以上を念頭に置いた上で次のように考える
		//全てのメンバーについて完食にかかる時間を center 以下にできるか
		//A[i] - center/F[i] を0~N-1まで足し合わせてそれがK以下かどうか見れば良い
		//K以下 = そのcenter時間は実現可能
		//Kより大きい = 実現不可能
		bool ok = [&]{
			LL sum = 0;
			for(int i=0;i<N;i++){
				sum += max(0ll,a[i]-center/f[i]);
			}
			return sum<=K;
		}();
		if(ok) right = center;//実現可能ラインを下げる
		else left = center;//実現不可能ラインを上げる
	}
	ans = r;
}
 
int main(){
	cin >> N >> K;
	for(int i=0;i<N;i++) cin >> A[i];
	for(int i=0;i<N;i++) cin >> B[i];
 
	solve();

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

Compiler output:
a.cc: In lambda function:
a.cc:55:48: error: 'a' was not declared in this scope
   55 |                                 sum += max(0ll,a[i]-center/f[i]);
      |                                                ^
a.cc:55:60: error: 'f' was not declared in this scope
   55 |                                 sum += max(0ll,a[i]-center/f[i]);
      |                                                            ^
a.cc: In function 'void solve()':
a.cc:62:15: error: 'r' was not declared in this scope
   62 |         ans = r;
      |               ^
a.cc: In function 'int main()':
a.cc:68:37: error: 'B' was not declared in this scope
   68 |         for(int i=0;i<N;i++) cin >> B[i];
      |                                     ^
Language: Java

import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long k = sc.nextLong();
        
        int[] costs = new int[n];
        int[] amounts = new int[n];
        for (int i = 0; i < n; i++) {
            costs[i] = sc.nextInt();
        }
        for (int i = 0; i < n; i++) {
            amounts[i] = sc.nextInt();
        }
        Arrays.sort(costs);
        Arrays.sort(amounts);
        
        long left = 0;
        long right = 1000000000000l;
        while (left < right) {
            long center = (left + right) / 2;
            boolean ok = true;
            
            // okがどうかの判定
            long count = 0;
            for (int i = 0; i < n; i++) {
                if (center < (long)costs[n - 1 - i] * amounts[i]) {
                    long tmp = center / amounts[i];
                    count += (costs[n - 1 - i] - tmp;
                }
                
                if (count > k) {
                    ok = false;
                }
            }
            
            if (ok) {
                right = center;
            } else {
                left = center + 1;
            }
        }
        
        System.out.println(left);
    }
}


Compiler output:
Main.java:32: error: ')' expected
                    count += (costs[n - 1 - i] - tmp;
                                                    ^
1 error
Language: C++

  ll n, k;
  cin >> n >> k;
  vector<ll> a(n), f(n);
  rep(i,n)
    cin >> a[i];
  rep(i,n)
    cin >> f[i];
  //aN*f1,a(N-1)*f2,...a2*f(N-1),a1*fNが一番効率がよさそう
  sort(a.begin(), a.end(), greater<ll>());
  sort(f.begin(), f.end());

  //二分探索を行う A,Fが1e6なので1e12あればいい
  ll l = 0, r = 1e12 + 1, mid, sum, ans;
  while (l <= r) {
    mid = (l + r) / 2;
    sum = k;
    // (a-k)*f=mid; k=a-mid/f; kを最も効率よく使う場合を求める
    // 一番小さいmidが答え。かつΣkがsumと=になればその条件が満たせる
    rep(i,n)
      if (mid / f[i] < a[i])
        sum -= a[i] - mid / f[i];
    if (sum < 0) {
      l = mid + 1;
    } else {
      ans = mid;
      r = mid - 1;
    }
  }
  cout << ans;

Compiler output:
a.cc:1:3: error: 'll' does not name a type
    1 |   ll n, k;
      |   ^~
a.cc:2:3: error: 'cin' does not name a type
    2 |   cin >> n >> k;
      |   ^~~
a.cc:3:3: error: 'vector' does not name a type
    3 |   vector<ll> a(n), f(n);
      |   ^~~~~~
a.cc:4:6: error: expected constructor, destructor, or type conversion before '(' token
    4 |   rep(i,n)
      |      ^
a.cc:6:6: error: expected constructor, destructor, or type conversion before '(' token
    6 |   rep(i,n)
      |      ^
a.cc:9:7: error: expected constructor, destructor, or type conversion before '(' token
    9 |   sort(a.begin(), a.end(), greater<ll>());
      |       ^
a.cc:10:7: error: expected constructor, destructor, or type conversion before '(' token
   10 |   sort(f.begin(), f.end());
      |       ^
a.cc:13:3: error: 'll' does not name a type
   13 |   ll l = 0, r = 1e12 + 1, mid, sum, ans;
      |   ^~
a.cc:14:3: error: expected unqualified-id before 'while'
   14 |   while (l <= r) {
      |   ^~~~~
a.cc:29:3: error: 'cout' does not name a type
   29 |   cout << ans;
      |   ^~~~
Language: C++

n,k=map(int,input().split())
a=sorted(list(map(int,input().split())))
b=sorted(list(map(int,input().split())))[::-1]
l,r=10**12+1,0
while l-r>1:
    t=(l+r)//2
    s=k
    for i,j in zip(a,b):
        if t<i*j:s-=(i*j-t-1)//j+1
    if s<0:r=t
    else:l=t
print(l)

Compiler output:
a.cc:1:1: error: 'n' does not name a type
    1 | n,k=map(int,input().split())
      | ^
Language: C++

#include <algorithm>
#include <iostream>
#include <utility>
#include <vector>
using namespace std;

int main() {
  rsize_t n;
  long long k;
  cin >> n >> k;

  vector<int> a(n);
  vector<int> f(n);
  for (rsize_t i = 0; i < n; ++i)
    cin >> a[i];
  for (rsize_t i = 0; i < n; ++i)
    cin >> f[i];

  sort(a.rbegin(), a.rend());
  sort(f.begin(), f.end());

  long long lower = -1;
  long long upper = 1'000'000'000'000;

  while (lower + 1 < upper) {
    long long team_score = lower + (upper - lower) / 2;

    long long t = 0;
    for (rsize_t i = 0; i < n; ++i) {
      auto ai = team_score / f[i]; // make ai*fi <= target_score
      auto train = max(0LL, a[i] - ai);
      t += train;
    }
    if (t <= k) {
      upper = team_score;
    } else {
      lower = team_score;
    }
  }

  cout << upper;
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:8:3: error: 'rsize_t' was not declared in this scope; did you mean 'ssize_t'?
    8 |   rsize_t n;
      |   ^~~~~~~
      |   ssize_t
a.cc:10:10: error: 'n' was not declared in this scope
   10 |   cin >> n >> k;
      |          ^
a.cc:14:15: error: expected ';' before 'i'
   14 |   for (rsize_t i = 0; i < n; ++i)
      |               ^~
      |               ;
a.cc:14:23: error: 'i' was not declared in this scope
   14 |   for (rsize_t i = 0; i < n; ++i)
      |                       ^
a.cc:16:15: error: expected ';' before 'i'
   16 |   for (rsize_t i = 0; i < n; ++i)
      |               ^~
      |               ;
a.cc:16:23: error: 'i' was not declared in this scope
   16 |   for (rsize_t i = 0; i < n; ++i)
      |                       ^
a.cc:29:17: error: expected ';' before 'i'
   29 |     for (rsize_t i = 0; i < n; ++i) {
      |                 ^~
      |                 ;
a.cc:29:25: error: 'i' was not declared in this scope
   29 |     for (rsize_t i = 0; i < n; ++i) {
      |                         ^
Language: C++

#include <iostream>
#include <vector>
#include <cmath>

using namespace std;

int N;
long long int K;
vector<int> A;
vector<int> F;


long long int search(long long int left, long long int right) {

    if (left == right) {
        return left;
    }

    long long int mid = floor((left + right) / 2.0l);
    long long int total_fix = 0.0l;

    for(int i = 0; i < A.size(); i++) {
        if (A[i] * F[i] > mid) {
            total_fix += A[i] - floor(mid / F[i]);
        }
    }

    if (total_fix > K) {
        return search(min(mid + 1, right), right);
    }
    else {
        return search(left, mid);
    }
}


int main(int argc, char** argv) {
    cin >> N >> K;
    A.resize(N);
    F.resize(N);

    for(int i = 0; i < N; i++) {
        cin >> A[i];
    }

    for(int i = 0; i < N; i++) {
        cin >> F[i];
    }

    sort(A.begin(), A.end());
    sort(F.begin(), F.end(), greater<int>());
    long long int ans = search(0, 1e12l);
    cout << ans << endl;

}

Compiler output:
a.cc: In function 'int main(int, char**)':
a.cc:50:5: error: 'sort' was not declared in this scope; did you mean 'sqrt'?
   50 |     sort(A.begin(), A.end());
      |     ^~~~
      |     sqrt
Language: C

#include<stdio.h>
#include<stdlib.h>

typedef long long ll;

ll* makeArray(ll n,ll init_) {
	ll* a;
	a = (ll*)malloc(n * sizeof(ll));
	for (ll i = 0; i < n; i++) {
		a[i] = init_;
	}
	return a;
}

ll** make2Darray(ll n, ll m,ll init_) {
	ll** a;
	a = (ll**)malloc(n * sizeof(ll*));
	for (ll i = 0; i < m; i++) {
		a[i] = makeArray(m,init_);
	}
	return a;
}

// n個読み込む
ll* readLine(ll n) {
	ll* a[2*100000+5]
	for (ll i = 0; i < n; i++) {
		scanf("%lld", &a[i]);
	}
	return a;
}

void sort(ll* a, ll s, ll t) {
	if (t - s < 1) return;
	ll p = rand();
	if (p < 0)p *= -1;
	ll pipot = p % (t - s) + s;
	ll kari = a[pipot], j = s;
	a[pipot] = a[t];
	a[t] = kari;
	for (ll i = s; i < t; i++) {
		if (a[t] > a[i]) {
			kari = a[i]; a[i] = a[j];
			a[j] = kari;
			j++;
		}
	}
	kari = a[j]; a[j] = a[t];
	a[t] = kari;
	sort(a, s, j - 1);
	sort(a, j + 1, t);
}

void reverse(ll* a, ll s, ll t) {
	while (t - s > 0) {
		ll n = a[s];
		a[s] = a[t];
		a[t] = n;
		s++; t--;
	}
}

ll max(ll a, ll b) {
	if (a > b)return a;
	else return b;
}

int judge(ll* a, ll* b, ll n, ll x, ll k) {
	ll cost = 0;
	for (ll i = 0; i < n; i++) {
		cost += max(0, a[i] - x / b[i]);
	}
	return (cost <= k);
}

int main(void) {
    srand((unsigned int) time(NULL)); 
	ll n, k,l = -1,r = 1e12;
	scanf("%lld %lld", &n, &k);
	ll* a, * f;
	a = readLine(n);
	f = readLine(n);
	sort(a, 0, n - 1);
	sort(f, 0, n - 1);
	reverse(f, 0, n - 1);
	while (l+1<r) {
		ll c = (l + r) / 2;
		int ok = judge(a, f, n, c, k);
		if (ok) r = c; else l = c;
	}
	printf("%lld", r);
    return 0;
}


Compiler output:
main.c: In function 'readLine':
main.c:27:9: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'for'
   27 |         for (ll i = 0; i < n; i++) {
      |         ^~~
main.c:28:32: error: 'a' undeclared (first use in this function)
   28 |                 scanf("%lld", &a[i]);
      |                                ^
main.c:28:32: note: each undeclared identifier is reported only once for each function it appears in
main.c: In function 'main':
main.c:77:26: error: implicit declaration of function 'time' [-Wimplicit-function-declaration]
   77 |     srand((unsigned int) time(NULL));
      |                          ^~~~
main.c:3:1: note: 'time' is defined in header '<time.h>'; this is probably fixable by adding '#include <time.h>'
    2 | #include<stdlib.h>
  +++ |+#include <time.h>
    3 |
Language: C++

#include<stdio.h>
#include<stdlib.h>

typedef long long ll;

ll* makeArray(ll n,ll init_) {
	ll* a;
	a = (ll*)malloc(n * sizeof(ll));
	for (ll i = 0; i < n; i++) {
		a[i] = init_;
	}
	return a;
}

ll** make2Darray(ll n, ll m,ll init_) {
	ll** a;
	a = (ll**)malloc(n * sizeof(ll*));
	for (ll i = 0; i < m; i++) {
		a[i] = makeArray(m,init_);
	}
	return a;
}

// n個読み込む
ll* readLine(ll n) {
	ll* a = makeArray(n,0);
	for (ll i = 0; i < n; i++) {
		scanf("%lld", &a[i]);
	}
	return a;
}

void sort(ll* a, ll s, ll t) {
    srand((unsigned int) time(NULL)); 
	if (t - s < 1) return;
	ll p = rand();
	if (p < 0)p *= -1;
	ll pipot = p % (t - s) + s;
	ll kari = a[pipot], j = s;
	a[pipot] = a[t];
	a[t] = kari;
	for (ll i = s; i < t; i++) {
		if (a[t] > a[i]) {
			kari = a[i]; a[i] = a[j];
			a[j] = kari;
			j++;
		}
	}
	kari = a[j]; a[j] = a[t];
	a[t] = kari;
	sort(a, s, j - 1);
	sort(a, j + 1, t);
}

void reverse(ll* a, ll s, ll t) {
	while (t - s > 0) {
		ll n = a[s];
		a[s] = a[t];
		a[t] = n;
		s++; t--;
	}
}

ll max(ll a, ll b) {
	if (a > b)return a;
	else return b;
}

int judge(ll* a, ll* b, ll n, ll x, ll k) {
	ll cost = 0;
	for (ll i = 0; i < n; i++) {
		cost += max(0, a[i] - x / b[i]);
	}
	return (cost <= k);
}

int main(void) {
	ll n, k,l = -1,r = 1e12;
	scanf("%lld %lld", &n, &k);
	ll* a, * f;
	a = readLine(n);
	f = readLine(n);
	sort(a, 0, n - 1);
	sort(f, 0, n - 1);
	reverse(f, 0, n - 1);
	while (l+1<r) {
		ll c = (l + r) / 2;
		int ok = judge(a, f, n, c, k);
		if (ok) r = c; else l = c;
	}
	printf("%lld", r);
    return 0;
}

Compiler output:
a.cc: In function 'void sort(ll*, ll, ll)':
a.cc:34:26: error: 'time' was not declared in this scope
   34 |     srand((unsigned int) time(NULL));
      |                          ^~~~
a.cc:3:1: note: 'time' is defined in header '<ctime>'; this is probably fixable by adding '#include <ctime>'
    2 | #include<stdlib.h>
  +++ |+#include <ctime>
    3 |
Language: C

#include<stdio.h>
#include<stdlib.h>

typedef long long ll;

ll* makeArray(ll n,ll init_) {
	ll* a;
	a = (ll*)malloc(n * sizeof(ll));
	for (ll i = 0; i < n; i++) {
		a[i] = init_;
	}
	return a;
}

ll** make2Darray(ll n, ll m,ll init_) {
	ll** a;
	a = (ll**)malloc(n * sizeof(ll*));
	for (ll i = 0; i < m; i++) {
		a[i] = makeArray(m,init_);
	}
	return a;
}

// n個読み込む
ll* readLine(ll n) {
	ll* a = makeArray(n,0);
	for (ll i = 0; i < n; i++) {
		scanf("%lld", &a[i]);
	}
	return a;
}

void sort(ll* a, ll s, ll t) {
	if (t - s < 1) return;
	ll p = rand();
	if (p < 0)p *= -1;
	ll pipot = p % (t - s) + s;
	ll kari = a[pipot], j = s;
	a[pipot] = a[t];
	a[t] = kari;
	for (ll i = s; i < t; i++) {
		if (a[t] > a[i]) {
			kari = a[i]; a[i] = a[j];
			a[j] = kari;
			j++;
		}
	}
	kari = a[j]; a[j] = a[t];
	a[t] = kari;
	sort(a, s, j - 1);
	sort(a, j + 1, t);
}

void reverse(ll* a, ll s, ll t) {
	while (t - s > 0) {
		ll n = a[s];
		a[s] = a[t];
		a[t] = n;
		s++; t--;
	}
}

ll max(ll a, ll b) {
	if (a > b)return a;
	else return b;
}

bool judge(ll* a, ll* b, ll n, ll x, ll k) {
	ll cost = 0;
	for (ll i = 0; i < n; i++) {
		cost += max(0, a[i] - x / b[i]);
	}
	return cost <= k;
}

void main(void) {
	ll n, k,l = -1,r = 1e12;
	scanf("%lld %lld", &n, &k);
	ll* a, * f;
	a = readLine(n);
	f = readLine(n);
	sort(a, 0, n - 1);
	sort(f, 0, n - 1);
	reverse(f, 0, n - 1);
	while (l+1<r) {
		ll c = (l + r) / 2;
		bool ok = judge(a, f, n, c, k);
		if (ok) r = c; else l = c;
	}
	printf("%lld", r);
}

Compiler output:
main.c:68:1: error: unknown type name 'bool'
   68 | bool judge(ll* a, ll* b, ll n, ll x, ll k) {
      | ^~~~
main.c:3:1: note: 'bool' is defined in header '<stdbool.h>'; this is probably fixable by adding '#include <stdbool.h>'
    2 | #include<stdlib.h>
  +++ |+#include <stdbool.h>
    3 | 
main.c: In function 'main':
main.c:87:17: error: unknown type name 'bool'
   87 |                 bool ok = judge(a, f, n, c, k);
      |                 ^~~~
main.c:87:17: note: 'bool' is defined in header '<stdbool.h>'; this is probably fixable by adding '#include <stdbool.h>'
Language: C

#include<stdio.h>
#include<stdlib.h>

typedef long long ll;

ll* makeArray(ll n,ll init_) {
	ll* a;
	a = (ll*)malloc(n * sizeof(ll));
	for (ll i = 0; i < n; i++) {
		a[i] = init_;
	}
	return a;
}

ll** make2Darray(ll n, ll m,ll init_) {
	ll** a;
	a = (ll**)malloc(n * sizeof(ll*));
	for (ll i = 0; i < m; i++) {
		a[i] = makeArray(m,init_);
	}
	return a;
}

// n個読み込む
ll* readLine(ll n) {
	ll* a = makeArray(n,0);
	for (ll i = 0; i < n; i++) {
		scanf_s("%lld", &a[i]);
	}
	return a;
}

void sort(ll* a, ll s, ll t) {
	if (t - s < 1) return;
	ll p = rand();
	if (p < 0)p *= -1;
	ll pipot = p % (t - s) + s;
	ll kari = a[pipot], j = s;
	a[pipot] = a[t];
	a[t] = kari;
	for (ll i = s; i < t; i++) {
		if (a[t] > a[i]) {
			kari = a[i]; a[i] = a[j];
			a[j] = kari;
			j++;
		}
	}
	kari = a[j]; a[j] = a[t];
	a[t] = kari;
	sort(a, s, j - 1);
	sort(a, j + 1, t);
}

void reverse(ll* a, ll s, ll t) {
	while (t - s > 0) {
		ll n = a[s];
		a[s] = a[t];
		a[t] = n;
		s++; t--;
	}
}

ll max(ll a, ll b) {
	if (a > b)return a;
	else return b;
}

bool judge(ll* a, ll* b, ll n, ll x, ll k) {
	ll cost = 0;
	for (ll i = 0; i < n; i++) {
		cost += max(0, a[i] - x / b[i]);
	}
	return cost <= k;
}

void main(void) {
	ll n, k,l = -1,r = 1e12;
	scanf_s("%lld %lld", &n, &k);
	ll* a, * f;
	a = readLine(n);
	f = readLine(n);
	sort(a, 0, n - 1);
	sort(f, 0, n - 1);
	reverse(f, 0, n - 1);
	while (l+1<r) {
		ll c = (l + r) / 2;
		bool ok = judge(a, f, n, c, k);
		if (ok) r = c; else l = c;
	}
	printf("%lld", r);
}

Compiler output:
main.c: In function 'readLine':
main.c:28:17: error: implicit declaration of function 'scanf_s'; did you mean 'scanf'? [-Wimplicit-function-declaration]
   28 |                 scanf_s("%lld", &a[i]);
      |                 ^~~~~~~
      |                 scanf
main.c: At top level:
main.c:68:1: error: unknown type name 'bool'
   68 | bool judge(ll* a, ll* b, ll n, ll x, ll k) {
      | ^~~~
main.c:3:1: note: 'bool' is defined in header '<stdbool.h>'; this is probably fixable by adding '#include <stdbool.h>'
    2 | #include<stdlib.h>
  +++ |+#include <stdbool.h>
    3 | 
main.c: In function 'main':
main.c:87:17: error: unknown type name 'bool'
   87 |                 bool ok = judge(a, f, n, c, k);
      |                 ^~~~
main.c:87:17: note: 'bool' is defined in header '<stdbool.h>'; this is probably fixable by adding '#include <stdbool.h>'
Language: C++

#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif


ll N, K;

bool f(vector<ll> &A, vector<ll> &F, ll x) {
    ll remain = K;
    rep(i, N) {
        if (A[i] * F[i] > x) {
            remain -= (A[i] * F[i] - x + F[i] - 1) / F[i];
            if (remain < 0) {
                return false;
            }
        }
    }
    print(remain);
    return true;
}

void Main() {
    cin >> N >> K;
    vector<ll> A(N), F(N);
    rep(i, N) cin >> A[i];
    rep(i, N) cin >> F[i];
    sort(A.begin(), A.end());
    sort(F.rbegin(), F.rend());

    ll ok = A[N - 1] * F[0];
    ll ng = -1;
    while (ok - ng > 1) {
        ll mid = (ok + ng) / 2;
        if (f(A, F, mid)) {
            ok = mid;
        } else {
            ng = mid;
        }
    }
    cout << ok << '\n';
}

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


Compiler output:
a.cc: In function 'bool f(std::vector<long long int>&, std::vector<long long int>&, ll)':
a.cc:40:5: error: 'print' was not declared in this scope; did you mean 'rint'?
   40 |     print(remain);
      |     ^~~~~
      |     rint