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

#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < n; i++)
typedef long long ll;
using namespace std;
#define llMAX numeric_limits<long long>::max()
#define intMAX numeric_limits<int>::max()
#define d_5 100000
#define d9_7 1000000007
#define vll vector<vector<long long>>
#define vl vector<long long>
#define vi vector<int>
#define vii vector<vector<int>>
#define pb push_back
#define pf push_front
#define ld long double

int main(void){
  ll n,k;
  cin>>n>>k;
  vl a(n);
  vl f(n);
  rep(i,n)cin>>a[i];
  rep(i,n)cin>>f[i];
  sort(a.begin(),a.end());
  sort(f.begin(),f.end());
  unsigned ll l=0;
  unsigned ll r=2000000000000000000;
  while(l!=r){
    ll ans=(l+r)/2;
    ll sum=0;
    rep(i,n){
      sum+=(a[i]*f[n-1-i]-ans + f[n-1-i]-1)/f[n-1-i];
    }
    if(sum>k){
      l=ans+1;
    }else{
      if(l+1==r){
        r-=1;
        break;
      }
      r=ans;
    }
  }
  cout<<l;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:26:15: error: expected initializer before 'l'
   26 |   unsigned ll l=0;
      |               ^
a.cc:27:15: error: expected initializer before 'r'
   27 |   unsigned ll r=2000000000000000000;
      |               ^
a.cc:28:9: error: 'l' was not declared in this scope
   28 |   while(l!=r){
      |         ^
a.cc:28:12: error: 'r' was not declared in this scope
   28 |   while(l!=r){
      |            ^
a.cc:44:9: error: 'l' was not declared in this scope
   44 |   cout<<l;
      |         ^
Language: C++

#include <bits/stdc++.h>

using namespace std;

struct QueueItem {
  uint64_t a, f;
  
  QueueItem(uint64_t a, uint64_t f) : a(a), f(f) {}
  uint64_t cost() const { return a * f; }
  
  bool operator<(const QueueItem &rhs) const { return cost() < rhs.cost(); }
};

uint64_t naive_search(
  uint64_t N, uint64_t K, 
  const vector<uint64_t> &A, const vector<uint64_t> &F
)
{
  priority_queue<QueueItem> pq;
  for (uint64_t n = 0; n < N; ++n) {
    pq.emplace(A[n], F[n]);
  }
  
  for (uint64_t k = 0; k < K; ++k) {
    if (pq.empty()) { break; }
    
    QueueItem item = pq.top(); pq.pop();
    if (item.a > 1) {
      --item.a;
      pq.push(item);
    }
  }
  
  return (pq.size() == 0) ? 0 : pq.top().cost();
}

int main()
{
  uint64_t N, K;
  cin >> N >> K;
  
  vector<uint64_t> A(N), F(N);
  for (uint64_t n = 0; n < N; ++n) { cin >> A[n]; }
  for (uint64_t n = 0; n < N; ++n) { cin >> F[n]; }
  
  sort(A.begin(), A.end(),    less<uint64_t>());
  sort(F.begin(), F.end(), greater<uint64_t>());
  debug(A);
  debug(F);
  
  cout <<  naive_search(N, K, A, F) << endl;
  
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:48:3: error: 'debug' was not declared in this scope
   48 |   debug(A);
      |   ^~~~~
Language: C++

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


long long a[1000005];
long long f[1000005] ;
long long N , K , x ;
bool check( long long m ){
	long long c = 0 ;
	for( int i = 1 ; i <= N ; i++ ){
		c += ( a[i] - m/f[N-i+1]) ;
		if(c>K) return false ;
	}
	return true ;
}

int main(){
	
	cin >> N >> K ;

	for( int i = 0 ; i < N ; i++ ){
		cin >> a[i+1] ;
	}
	for( int i = 0 ; i < N ; i++ ){
		cin >> f[i+1] ;
	}
	sort(a+1,a+N+1);
	sort(f+1,f+N+1);
	long long l = 0 , r = a[N]*f[N] , m ;
	while(l <= r){
		m = (l+r)/2 ;
		if(check(m)) r=m-1 ;
		else l = m+1 ;
	}
	if( check(l) )
		cout << l << endl ;
	else if( K == 0 ){
		for( int i = 1 ; i <= N ; i++ ){
			ans = max((a[i]*f[N-i+1]),ans);
		}
		cout << ans << endl ;
	}
	// long long cur = a[N] , c = 1 , i = N , C = 0 ;
	// while( K > 0 && i > 0  ){
	// 	// cout << K << " " << cur << " " << c << " " << i << endl ;
	// 	if( c * ( cur-a[i-1]) <= K  ){
	// 		K = K - c * ( cur-a[i-1]) ;
	// 		cur = a[i-1]; 
	// 		c++ ;
	// 		i--;
	// 		// cout << K << endl ;
	// 	}
	// 	else{
	// 		cur = cur - K/c ;
	// 		C = K % c ;
	// 		K = 0 ;
	// 	}
	// }
	// // cout << K << " " << cur << " " << c << endl ;
	// for( int i = 0 ; i < c ; i++ ){
	// 	a[N-i] = cur ;
	// }
	// if( C != 0 ){
	// 	for( int i = 0 ; i < C ; i++ ){
	// 		a[N-i]-- ;
	// 	}
	// }
	// sort(a+1,a+N+1);
	// long long ans = 0 ;
	// for( int i = 1 ; i <= N ; i++ ){
	// 	ans = max((a[i]*f[N-i+1]),ans);
	// }
	// cout << ans << endl ;

	


	return 0 ;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:39:25: error: 'ans' was not declared in this scope; did you mean 'abs'?
   39 |                         ans = max((a[i]*f[N-i+1]),ans);
      |                         ^~~
      |                         abs
a.cc:41:25: error: 'ans' was not declared in this scope; did you mean 'abs'?
   41 |                 cout << ans << endl ;
      |                         ^~~
      |                         abs
Language: C++

#include <iostream>
#include<vector>
using namespace std;
using lint = long long int;

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

    vector<lint> a(n);
    for(auto& e : a)  cin >> e;
    sort(begin(a), end(a));

    vector<lint> f(n);
    for(auto& e : f)  cin >> e;
    sort(begin(f), end(f));
    reverse(begin(f), end(f));

    vector<tuple<lint, lint, lint>> mul(n);
    for(lint i=0; i<n; i++) {
        mul[i] = make_tuple(a[i]*f[i], a[i], f[i]);
    }
    sort(begin(mul), end(mul));

    lint ok = 1e13;
    lint ng = -1;
    auto check = [&](lint x) {
        lint sum = 0;
        for(auto e : mul) {
            lint m, a, f;
            tie(m, a, f) = e;
            if(m > x)  sum += ceil((double)(m - x) / f);
        }
        return sum <= k;
    };

    while(abs(ok - ng) > 1) {
        lint mid = (ok + ng) / 2;
        (check(mid) ? ok : ng) = mid;
    }

    cout << ok << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:12:5: error: 'sort' was not declared in this scope; did you mean 'short'?
   12 |     sort(begin(a), end(a));
      |     ^~~~
      |     short
a.cc:17:5: error: 'reverse' was not declared in this scope
   17 |     reverse(begin(f), end(f));
      |     ^~~~~~~
a.cc: In lambda function:
a.cc:32:31: error: 'ceil' was not declared in this scope
   32 |             if(m > x)  sum += ceil((double)(m - x) / f);
      |                               ^~~~
Language: C++

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

int main() {
  int64_t n, k, a = 0, s, b;
  cin >> n >> k;
  vector<int> a(n), f(n);
  for(int i = 0; i < n; i++)
    cin >> a.at(i);
  for(int i = 0; i < n ;i++)
    cin >> f.at(i);
  sort(a.begin(), a.end());
  sort(f.begin(), f.end());
  reverse(f.begin(), f.end());
  priority_queue<int64_t> pq;
  for(int i = 0; i < n; i++)
    pq.push(a.at(i)*f.at(i));
  s = pq.top();
  while(pow(2, a) < s) a++;
  b = pow(2, a)
  for(int i = a; a > 0; a--){
    bool d = 1;
    for(int j = 0; j < n; j++)
      if(b < a.at(i)*f.at(i)) k -= a.at(i) - b / f.at(i);
    if(k < 0) d = 0;
    if(d) b += pow(2, i);
    else b -= pow(2, i);
  }
  cout << b << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:8:15: error: conflicting declaration 'std::vector<int> a'
    8 |   vector<int> a(n), f(n);
      |               ^
a.cc:6:17: note: previous declaration as 'int64_t a'
    6 |   int64_t n, k, a = 0, s, b;
      |                 ^
a.cc:10:14: error: request for member 'at' in 'a', which is of non-class type 'int64_t' {aka 'long int'}
   10 |     cin >> a.at(i);
      |              ^~
a.cc:13:10: error: request for member 'begin' in 'a', which is of non-class type 'int64_t' {aka 'long int'}
   13 |   sort(a.begin(), a.end());
      |          ^~~~~
a.cc:13:21: error: request for member 'end' in 'a', which is of non-class type 'int64_t' {aka 'long int'}
   13 |   sort(a.begin(), a.end());
      |                     ^~~
a.cc:18:15: error: request for member 'at' in 'a', which is of non-class type 'int64_t' {aka 'long int'}
   18 |     pq.push(a.at(i)*f.at(i));
      |               ^~
a.cc:21:16: error: expected ';' before 'for'
   21 |   b = pow(2, a)
      |                ^
      |                ;
   22 |   for(int i = a; a > 0; a--){
      |   ~~~           
a.cc:22:28: error: expected ';' before ')' token
   22 |   for(int i = a; a > 0; a--){
      |                            ^
      |                            ;
Language: C++

#require 'pp'
require 'set'

n, k = gets.chomp!.split(" ").map(&:to_i)
a_n = gets.chomp!.split(" ").map(&:to_i).sort!
f_n = gets.chomp!.split(" ").map(&:to_i).sort!.reverse!

class Elem
    attr_accessor :key, :value

    def initialize(key, value)
        @key = key
        @value = value
    end

    def <=>(other)
        other.key <=> @key
    end
end

sum = []
set = SortedSet.new
n.times do |i|
    sum[i] = a_n[i] * f_n[i]
    set << Elem.new(sum[i], [a_n[i], f_n[i]])
end

k.times do |i|
    x = set.first
    set.delete(x)
    if x.value[0] > 0
        x.value[0] = x.value[0] - 1
        x.key = x.value[0] * x.value[1]
        set << x
    end
end

ans = set.first
puts ans.key

Compiler output:
a.cc:1:2: error: invalid preprocessing directive #require
    1 | #require 'pp'
      |  ^~~~~~~
a.cc:2:9: warning: multi-character character constant [-Wmultichar]
    2 | require 'set'
      |         ^~~~~
a.cc:12:9: error: stray '@' in program
   12 |         @key = key
      |         ^
a.cc:13:9: error: stray '@' in program
   13 |         @value = value
      |         ^
a.cc:17:23: error: stray '@' in program
   17 |         other.key <=> @key
      |                       ^
a.cc:2:1: error: 'require' does not name a type
    2 | require 'set'
      | ^~~~~~~
Language: C++

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

int main() {
  int64_t n, k, a = 0, s, b;
  cin >> n >> k;
  vector<int> a(n), f(n);
  for(int i = 0; i < n; i++)
    cin >> a.at(i);
  for(int i = 0; i < n ;i++)
    cin >> f.at(i);
  sort(a.begin(), a.end());
  sort(a.begin(), a.end());
  reverse(f.begin(), f.end());
  priority_queue<int64_t> pq;
  for(int i = 0; i < n; i++)
    pq.push(a.at(i)*f.at(i));
  s = pq.top();
  while(pow(2, a) < s) a++;
  b = pow(2, a)
  for(int i = a; a > 0; a--){
    bool d = 1;
    
    if(d) b += pow(2, i);
    else b -= pow(2, i);
  }
  cout << b << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:8:15: error: conflicting declaration 'std::vector<int> a'
    8 |   vector<int> a(n), f(n);
      |               ^
a.cc:6:17: note: previous declaration as 'int64_t a'
    6 |   int64_t n, k, a = 0, s, b;
      |                 ^
a.cc:10:14: error: request for member 'at' in 'a', which is of non-class type 'int64_t' {aka 'long int'}
   10 |     cin >> a.at(i);
      |              ^~
a.cc:13:10: error: request for member 'begin' in 'a', which is of non-class type 'int64_t' {aka 'long int'}
   13 |   sort(a.begin(), a.end());
      |          ^~~~~
a.cc:13:21: error: request for member 'end' in 'a', which is of non-class type 'int64_t' {aka 'long int'}
   13 |   sort(a.begin(), a.end());
      |                     ^~~
a.cc:14:10: error: request for member 'begin' in 'a', which is of non-class type 'int64_t' {aka 'long int'}
   14 |   sort(a.begin(), a.end());
      |          ^~~~~
a.cc:14:21: error: request for member 'end' in 'a', which is of non-class type 'int64_t' {aka 'long int'}
   14 |   sort(a.begin(), a.end());
      |                     ^~~
a.cc:18:15: error: request for member 'at' in 'a', which is of non-class type 'int64_t' {aka 'long int'}
   18 |     pq.push(a.at(i)*f.at(i));
      |               ^~
a.cc:21:16: error: expected ';' before 'for'
   21 |   b = pow(2, a)
      |                ^
      |                ;
   22 |   for(int i = a; a > 0; a--){
      |   ~~~           
a.cc:22:28: error: expected ';' before ')' token
   22 |   for(int i = a; a > 0; a--){
      |                            ^
      |                            ;
Language: C++

#include <iostream>
#include <algorithm>>
#include <cmath>
using namespace std;

int main()
{
    long long N, K;
    cin >> N >> K;
  
  int A[N], F[N];
  long long Amax=0;
  
  for(int i=0; i<N; i++){
    cin >> A[i];
    Amax += A[i];
  }
  for(int i=0; i< N; i++)
    cin >> F[i];
  
  
  if(K>=Amax){
    cout << 0 << endl;
    return 0;
  }
  
  sort(A, A+N);
  while(K>0){
    while(A[0]>=A[1]){
      A[i]--;
      K--;
    }
    sort(A, A+N);
  }
  
  sort(F, F+N);
  long long max=0;
  for(int i=0;i<N; i++){
    max += A[i]*F[i];}
  
  cout << max << endl;
   return 0;
}

Compiler output:
a.cc:2:21: warning: extra tokens at end of #include directive
    2 | #include <algorithm>>
      |                     ^
a.cc: In function 'int main()':
a.cc:30:9: error: 'i' was not declared in this scope
   30 |       A[i]--;
      |         ^
Language: C++

#!/usr/bin/env python3
import sys, math


def solve(N: int, K: int, A: "List[int]", F: "List[int]"):
    A = sorted(A)
    F = sorted(F, reverse=True)
    B = [a*f for a, f in zip(A, F)]
    b = max(B)
    left = -1
    right = b

    def ok(mid):
        r = 0
        for i in range(N):
            a, f = A[i], F[i]
            r += max(0, a - mid//f)
        if r > K:
            return True
        else:
            return False

    while right - left > 1:
        mid = (right + left) // 2
        if ok(mid):
            left = mid
        else:
            right = mid
    print(right)
    return


# Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    F = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, K, A, F)

if __name__ == '__main__':
    main()


Compiler output:
a.cc:1:2: error: invalid preprocessing directive #!
    1 | #!/usr/bin/env python3
      |  ^
a.cc:33:3: error: invalid preprocessing directive #Generated
   33 | # Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
      |   ^~~~~~~~~
a.cc:40:28: error: stray '#' in program
   40 |     N = int(next(tokens))  # type: int
      |                            ^
a.cc:41:28: error: stray '#' in program
   41 |     K = int(next(tokens))  # type: int
      |                            ^
a.cc:42:48: error: stray '#' in program
   42 |     A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
      |                                                ^
a.cc:43:48: error: stray '#' in program
   43 |     F = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
      |                                                ^
a.cc:46:16: warning: multi-character literal with 8 characters exceeds 'int' size of 4 bytes
   46 | if __name__ == '__main__':
      |                ^~~~~~~~~~
a.cc:2:1: error: 'import' does not name a type
    2 | import sys, math
      | ^~~~~~
a.cc:2:1: note: C++20 'import' only available with '-fmodules-ts'
Language: C

#include <iostream>
#include <string>
#include <stdio.h>
#include <stdlib.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
using ll=long long;
using ii=pair<ll,ll>;

ll a,b,c,i,j,l,m,n,ans,tmp,hoge,fuga,piyo;
unsigned long long k;
ll A[100000];
ll F[100000];

int desc(const void *a, const void *b) {
    ll aa = *(ll *)a;
    ll bb = *(ll *)b;
  ll c = bb - aa;
  if (c < 0) {
      return -1;
  } else if (c == 0) {
      return 0;
  } else {
      return 1;
  }
}

int asc(const void *a, const void *b) {
    ll aa = *(ll *)a;
    ll bb = *(ll *)b;
  ll c = aa - bb;
  if (c < 0) {
      return -1;
  } else if (c == 0) {
      return 0;
  } else {
      return 1;
  }
}

int main(){
    cin>>n>>k;
    REP(i,n)cin>>A[i];
    REP(i,n)cin>>F[i];

    qsort(A, n, sizeof(ll), desc);
    qsort(F, n, sizeof(ll), desc);
    for (int i = 0; i < n; i++) {
        if (A[i] <= k) {
            k = k - A[i];
            A[i] = 0;
        } else {
            A[i] = A[i] - k;
            k = 0;
        }
        if (k == 0) {
            break;
        }
    }
    qsort(A, n, sizeof(ll), asc);

    long long total = 0;
    for (int i = 0; i < n; i++) {
        total = max(total, A[i] * F[i]);
        // printf("%d, %d\n", A[i], F[i]);
    }
    printf("%llu", total);
    return 0;
}

Compiler output:
main.c:1:10: fatal error: iostream: No such file or directory
    1 | #include <iostream>
      |          ^~~~~~~~~~
compilation terminated.
Language: C++

#include<iostream>
using namespace std;

int main() {
	int n, k;
	int a[1000001], f[1000001];

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

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

	for (int i = 0; i < n; i++) {
		for (int o = 0; o < n; o++) {
			if (f[i] > f[o] and i < o) {
				f[o] = f[i];
			}
		}
	}

	int b1 = 0;
	for (int i = 0; i < k; k++) {
		if (a[b1] != 0) {
			a[b1]--;
		}
		else {
			b1++;
		}
	}

	int b2 = 0;
	for (int i = 0; i < n; i++) {
		b2 += a[i] * b[n - 1 - i];
	}

	cout << b2 << endl;
	
}

Compiler output:
a.cc: In function 'int main()':
a.cc:44:30: error: 'b' was not declared in this scope
   44 |                 b2 += a[i] * b[n - 1 - i];
      |                              ^
Language: C++

//** aman**/
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define dl          double
#define hell        1000000007
#define endl        '\n'
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define lb lower_bound
#define ub upper_bound
#define bs          binary_search
#define ios         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;
ll chk(vector<ll> a,vector<ll> b,ll n,ll k,ll mid){
	for(ll i=0;i<n;i++){
			while(a[i]*b[i]>mid&&k>0){
			   int x= mid/b[i]
				k=k-x;
				if(k<0)return 0;
			}
			if(a[i]*b[i]>mid)return 0;
	}
	return 1;
}
int main(){
	ios;
	ll n,k;cin>>n>>k;
	vector<ll> a(n),b(n);
	for(ll i=0;i<n;i++)cin>>a[i];
	for(ll i=0;i<n;i++)cin>>b[i];
	sort(a.begin(),a.end());
	sort(b.begin(),b.end());
	reverse(a.begin(),a.end());
	ll s=0,e=1e15,mid,ans;
	while(s<=e){
		mid=(s+e)/2;
		//cout<<mid<<endl;
		//cout<<(a,b,n,k,mid)<<endl;
		if(chk(a,b,n,k,mid)){
			ans=mid;
			e=mid-1;
		}
		else{
			s=mid+1;
		}
	}
	//cout<<k<<endl;
//	for(int i=0;i<n;i++)cout<<a[i]<<" ";cout<<endl;
	cout<<ans<<endl;
	return 0;
}

Compiler output:
a.cc: In function 'long long int chk(std::vector<long long int>, std::vector<long long int>, long long int, long long int, long long int)':
a.cc:23:33: error: expected ',' or ';' before 'k'
   23 |                                 k=k-x;
      |                                 ^
Language: C++

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;

int m[1000010];

bool check(vector<ll> &a, vector<ll> &b, ll k, ll ans) {
    for (auto &i:b) {
        m[ans / i]++;
    }
    ll cur = 0, num = 0;
    int it = 0;
    while (it != 1000000 && cur < a.size()) {
        num += m[it];
        while (cur < a.size() && a[cur] <= it) {
            cur++;
        }
        if (cur < num) {
            while (cur < a.size() && cur < num) {
                k -= a[cur] - it;
                cur++;
            }
            if (k < 0) {
                return false;
            }
        }
        m[it] = 0;
        it++;
    }
    m.clear();
    return true;
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    int n = 200000, k = 2000000;
//    cin >> n >> k;
    vector<ll> a(n);
    vector<ll> b(n);
    for (int i = 0; i < n; ++i) {
//        cin >> a[i];
        a[i] = 1000000;
    }
    sort(begin(a), end(a));
    sort(begin(b), end(b));
    for (int i = 0; i < n; ++i) {
//        cin >> b[i];
        a[i] = 1000000;
    }
    ll l = 0, r = 1e12;
    while (l + 1 < r) {
        ll mid = (r + l) / 2;
        if (check(a, b, k, mid)) {
            r = mid;
        } else {
            l = mid + 1;
        }
    }
    if (check(a, b, k, l)) {
        cout << l;
    } else {
        cout << r;
    }
}


Compiler output:
a.cc: In function 'bool check(std::vector<long long int>&, std::vector<long long int>&, ll, ll)':
a.cc:33:7: error: request for member 'clear' in 'm', which is of non-class type 'int [1000010]'
   33 |     m.clear();
      |       ^~~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,b) for(int i=(a); i<(b); i++)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
typedef long long ll;
int n; ll k;
vector<ll> a(n),f(n);

bool check(ll m, ll sum){
    
    sum -= m*n;
    if(sum <= 0) return true;
    else return false;
}
int main(){
    cin >> n >> k;
    
    rep(i,n) cin >> a[i];
    rep(i,n) cin >> f[i];
    sort(RALL(f));
    sort(RALL(a));
    ll ng = -1;
    ll ok = f[0]*a[0];
    reverse(ALL(f));
    rep(i,n){
        sum += a[i]*f[i];
    }
    while(ok - ng > 1){
        ll mid = (ok + ng) / 2;
        if(check(mid,sum)) ok = mid;
        else ng = mid;
    }
    ll ans = ok;
    cout << ans << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:28:9: error: 'sum' was not declared in this scope
   28 |         sum += a[i]*f[i];
      |         ^~~
a.cc:32:22: error: 'sum' was not declared in this scope
   32 |         if(check(mid,sum)) ok = mid;
      |                      ^~~
Language: C++

#include <iostream>
#include <vector>
#include <algorithm>
#define  int long long
signed main(){
  int N,K,temp,sum=0;
  std::cin>>N>>K;
  std::vector<int> x,y;
  for (int i=0;i<N;i++){
    std::cin>>temp;
    x.push_back(temp);
  }
  std::sort(x.begin(),x.end());
  for (int i=0;i<N;i++){
    std::cin>>temp;
    y.push_back(temp);
  }
  std::sort(y.begin(),y.end(),std::greater<int>());
  int y_place=y.size()-1;
  while(K>0){
    y=std::max(0,y[y_place]-K);
    K=K-std::min(y[y_place],K);
    if(y_place==0){
      break;
    }
    y_place--;
  }
  for (int i=0;i<N;i++){
    for(int j=0;j<N;j++){
      sum+=x[i]*y[i];
    }
  }
  std::cout<<sum<<std::endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:21:15: error: no matching function for call to 'max(int, __gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type)'
   21 |     y=std::max(0,y[y_place]-K);
      |       ~~~~~~~~^~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/string:51,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 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:21:15: note:   deduced conflicting types for parameter 'const _Tp' ('int' and '__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type' {aka 'long long int'})
   21 |     y=std::max(0,y[y_place]-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,
                 from a.cc:3:
/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:21:15: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   21 |     y=std::max(0,y[y_place]-K);
      |       ~~~~~~~~^~~~~~~~~~~~~~~~
Language: C++

#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <limits.h>
#include <math.h>
int acs(const void *a, const void *b) { return *(int *)a - *(int *)b; }                            /* 1,2,3,4.. */
int des(const void *a, const void *b) { return *(int *)b - *(int *)a; }                            /* 8,7,6,5.. */
int cmp_char(const void *a, const void *b) { return *(char *)a - *(char *)b; }                     /* a,b,c,d.. */
int cmp_str(const void *a, const void *b) { return strcmp(*(const char **)a, *(const char **)b); } /* aaa,aab.. */
#define min(a, b) (a < b ? a : b)
#define max(a, b) (a > b ? a : b)
#define rep(i, n) for (int i = 0; i < n; i++)
#define MOD 1000000007
#define MAX 200001

// 優先度付きキュー Priority Queue

typedef struct
{
  long long int pri;
  long long int val;
} que;

que pq[MAX];
int pq_size = 0; // 最大要素

void PQadd(long long int pri, long long int val)
{
  int last = ++pq_size;
  que new;
  new.pri = pri;
  new.val = val;
  pq[pq_size] = new;

  while (last > 1 && pq[last].pri > pq[last / 2].pri)
  {
    que temp;
    temp = pq[last];
    pq[last] = pq[last / 2];
    pq[last / 2] = temp;
    last /= 2;
  }
  return;
}

que PQget(void)
{
  que root = pq[1];
  pq[1] = pq[pq_size--];

  int last = 1, bigger_child;
  while (last * 2 <= pq_size)
  {
    if (last * 2 == pq_size)
      bigger_child = last * 2;
    else
      bigger_child = pq[last * 2].pri > pq[last * 2 + 1].pri ? last * 2 : last * 2 + 1;

    if (pq[last].pri < pq[bigger_child].pri)
    {
      que temp;
      temp = pq[last];
      pq[last] = pq[bigger_child];
      pq[bigger_child] = temp;
      last = bigger_child;
    }
    else
      break;
  }
  return root;
}

typedef long long int lli;

int main(void)
{
  int n, a[MAX], f[MAX];
  long long int k;
  scanf("%d %lld", &n, &k);

  rep(i, n)
  {
    scanf("%d", &a[i]);
  }
  rep(i, n)
  {
    scanf("%d", &f[i]);
  }

  qsort(a, n, sizeof(int), acs);
  qsort(f, n, sizeof(int), des);

  rep(i, n)
  {
    PQadd(a[i] * f[i], i);
  }

  rep(i, k) {
    if (pq[1].pri == 0) break;
    que max_que = PQget();
    lli max = max_que.pri;
    lli idx = max_que.val;
    max -= ((max - pq[1].pri) / f[idx] + 1) * f[idx];
    i += (max - pq[1].pri) / f[idx];
    PQadd(max, idx);
  }
  lli ans = pq[1].pri;
  printf("%lld\n", ans);
  return 0;
}


Compiler output:
a.cc: In function 'void PQadd(long long int, long long int)':
a.cc:32:7: error: expected unqualified-id before 'new'
   32 |   que new;
      |       ^~~
a.cc:33:6: error: expected type-specifier before '.' token
   33 |   new.pri = pri;
      |      ^
a.cc:34:6: error: expected type-specifier before '.' token
   34 |   new.val = val;
      |      ^
a.cc:35:20: error: expected type-specifier before ';' token
   35 |   pq[pq_size] = new;
      |                    ^
Language: C++

#include <iostream>
#include <vector>
#include <algorithm>
#define  int long long
signed main(){
  int N,K,temp,sum=0;
  std::cin>>N>>K;
  std::vector<int> x,y;
  for (int i=0;i<N;i++){
    std::cin>>temp;
    x.push_back(temp);
  }
  std::sort(x.begin(),x.end());
  for (int i=0;i<N;i++){
    std::cin>>temp;
    y.push_back(temp);
  }
  std::sort(y.begin(),y.end(),std::greater<int>());
  int y_place=y.size();
  while(K>0){
    y=std::max(0,y[y_place]-K);
    K=K-std::min(y[y_place],K);
    if(y_place==0){
      break;
    }
    y_place--;
  }
  for (int i=0;i<N;i++){
    for(int j=0;j<N;j++){
      sum+=x[i]*y[i];
    }
  }
  std::cout<<sum<<std::endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:21:15: error: no matching function for call to 'max(int, __gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type)'
   21 |     y=std::max(0,y[y_place]-K);
      |       ~~~~~~~~^~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/string:51,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 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:21:15: note:   deduced conflicting types for parameter 'const _Tp' ('int' and '__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type' {aka 'long long int'})
   21 |     y=std::max(0,y[y_place]-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,
                 from a.cc:3:
/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:21:15: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   21 |     y=std::max(0,y[y_place]-K);
      |       ~~~~~~~~^~~~~~~~~~~~~~~~
Language: C++

#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <limits.h>
#include <math.h>
int acs(const void *a, const void *b) { return *(int *)a - *(int *)b; }                            /* 1,2,3,4.. */
int des(const void *a, const void *b) { return *(int *)b - *(int *)a; }                            /* 8,7,6,5.. */
int cmp_char(const void *a, const void *b) { return *(char *)a - *(char *)b; }                     /* a,b,c,d.. */
int cmp_str(const void *a, const void *b) { return strcmp(*(const char **)a, *(const char **)b); } /* aaa,aab.. */
#define min(a, b) (a < b ? a : b)
#define max(a, b) (a > b ? a : b)
#define rep(i, n) for (int i = 0; i < n; i++)
#define MOD 1000000007
#define MAX 200001

// 優先度付きキュー Priority Queue

typedef struct
{
  long long int pri;
  long long int val;
} que;

que pq[MAX];
int pq_size = 0; // 最大要素

void PQadd(long long int pri, long long int val)
{
  int last = ++pq_size;
  que new;
  new.pri = pri;
  new.val = val;
  pq[pq_size] = new;

  while (last > 1 && pq[last].pri > pq[last / 2].pri)
  {
    que temp;
    temp = pq[last];
    pq[last] = pq[last / 2];
    pq[last / 2] = temp;
    last /= 2;
  }
  return;
}

que PQget(void)
{
  que root = pq[1];
  pq[1] = pq[pq_size--];

  int last = 1, bigger_child;
  while (last * 2 <= pq_size)
  {
    if (last * 2 == pq_size)
      bigger_child = last * 2;
    else
      bigger_child = pq[last * 2].pri > pq[last * 2 + 1].pri ? last * 2 : last * 2 + 1;

    if (pq[last].pri < pq[bigger_child].pri)
    {
      que temp;
      temp = pq[last];
      pq[last] = pq[bigger_child];
      pq[bigger_child] = temp;
      last = bigger_child;
    }
    else
      break;
  }
  return root;
}

typedef long long int lli;

int main(void)
{
  int n, a[MAX], f[MAX];
  long long int k;
  scanf("%d %lld", &n, &k);

  rep(i, n)
  {
    scanf("%d", &a[i]);
  }
  rep(i, n)
  {
    scanf("%d", &f[i]);
  }

  qsort(a, n, sizeof(int), acs);
  qsort(f, n, sizeof(int), des);

  rep(i, n)
  {
    PQadd(a[i] * f[i], i);
  }

  rep(i, k) {
    if (pq[1].pri == 0) break;
    que max_que = PQget();
    lli max = max_que.pri;
    lli idx = max_que.val;
    max -= ((max - pq[1].pri) / f[idx] + 1) * f[idx];
    k += (max - pq[1].pri) / f[idx];
    PQadd(max, idx);
  }
  lli ans = pq[1].pri;
  printf("%lld\n", ans);
  return 0;
}


Compiler output:
a.cc: In function 'void PQadd(long long int, long long int)':
a.cc:32:7: error: expected unqualified-id before 'new'
   32 |   que new;
      |       ^~~
a.cc:33:6: error: expected type-specifier before '.' token
   33 |   new.pri = pri;
      |      ^
a.cc:34:6: error: expected type-specifier before '.' token
   34 |   new.val = val;
      |      ^
a.cc:35:20: error: expected type-specifier before ';' token
   35 |   pq[pq_size] = new;
      |                    ^
Language: C++

#include<bits/stdc++.h>
// debug
#define d(x) cerr << #x ":" << x << endl;
#define dd(x, y) cerr << "(" #x "," #y "):(" << x << "," << y << ")" << endl;
#define ddd(x, y, z) cerr << "(" #x "," #y "," #z "):(" << x << "," << y << "," << z << ")" << endl;
#define dump(v) cerr<<#v":[ ";for (auto macro_vi:v){cerr<<macro_vi<< " ";}cerr<<"]"<<endl;
#define ddump(v) cerr<<#v":"<<endl;for(auto macro_row:v) {cerr<<"["; for (auto macro__vi:macro_row){cerr<<macro__vi<< " ";}cerr<<"]"<<endl;}
#define damp(m) for(auto macro_pair:m){cerr<< macro_pair.first<<":"<<macro_pair.second<<endl;}
#define dpair(p) cerr << #p":"<<"(" << p.first << "," << p.second << ")" << endl;
// iterate
#define rep(i, n) for (int i = (int)(0); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define itr(macro_v,i) macro_v.begin()+i
// etc
#define chmin(mi, val) mi = min(mi, val);
#define chmax(ma, val) ma = max(ma, val);
using ll = long long;

using namespace std;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, k;
    cin >> n >> k;
    vector<ll> a(n,0ll);
    vector<ll> f(n, 0ll);
    vector<ll> g(n, 0ll);
    rep(i,n){
        cin >> a[i];
    }
    rep(i,n){
        cin >> f[i];
    }

    sort(all(a));
    reverse(all(a));
    sort(all(f));
    // reverse(all(f));
    // rep(i,n){
    //     g[i] = a[i]*f[i];
    // }
    // dump(a)
    // dump(f)
    // dump(g)

    while(k){
        for(int i=a.size()-1; 0=<i; i--){
            a[i]--;
            k--;
            if(k==0){
                goto end;
            }
        }
    }
    end:
    ll ma =-1;
    for(int i=0; i<a.size(); i++){
        ma=max(ma, a[i]*f[i]);
    }
    cout << ma << endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:48:33: error: expected primary-expression before '<' token
   48 |         for(int i=a.size()-1; 0=<i; i--){
      |                                 ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int N = 2e5 + 10;
ll a[N], b[N];
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll n, m;
    cin >> n >> m;
    for (int i = 1; i <= n; ++i)
        cin >> a[i];
    for (int i = 1; i <= n; ++i)
        cin >> b[i];
    sort(b + 1, b + 1 + n);
    ll l = 0, r = 2e12;
    while (l < r)
    {
        ll md = (l + r) / 2;
        ll cnt = 0;
        for (int i = 1; i <= n; ++i)
        {
            ll t = md / b[i];
            cnt += max(a[i] - t, 0);
        }
        if (cnt <= m)
            r = md;
        else
            l = md + 1;
    }
    cout << l;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:26:23: error: no matching function for call to 'max(ll, int)'
   26 |             cnt += max(a[i] - t, 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:26:23: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   26 |             cnt += max(a[i] - t, 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:26:23: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   26 |             cnt += max(a[i] - t, 0);
      |                    ~~~^~~~~~~~~~~~~
Language: C++

#include<bits/stdc++.h>
using namespace std ;
int a[1200000];
int b[1200000];
int n,m;
int cmp(int a ,int b){
	return a>b;
}
inline void read(int &x){
   int s = 0, w = 1; char ch = getchar();
   while(ch < '0' || ch > '9'){ if(ch == '-') w = -1; ch = getchar(); }
   while(ch >= '0' && ch <= '9') s = s * 10 + ch - '0', ch = getchar();
   x = s*w;
}
long long int check(long long int t){
	long long int sum=0;
	for(int i=0;i<n;i++){
		if(t/b[i]==0){
			sum+=a[i];
		}
		else {
			if(a[i]>=t/b[i]){
				sum+=a[i]-(t/b[i]);
			}
			else{
				sum+=0;
			}
		}
	}
	if(sum<=m){
		return 1;
	}
	else{
		return 0;
	}
}
int main()
{
	long long int ans=0;
	cin>>n>>m;
	for(int i=0;i<n;i++){
		scanf("%d",&a[i]);
		ans+=a[i];
	}
	for(int i=0;i<n;i++){
		scanf("%d",&b[i]);
	}
	if(m>=ans){
		printf("0\n");
		return 0;
	}
	sort(a,a+n);
	sort(b,b+n,cmp);
	long long int l=0,r=1200000000000;
	long long 
    while(l<=r) 
    {	
        long long int mid = (l + r) / 2;
        if(check(mid)) r = mid; //检查mid是否符合题目要求
        else l = mid+1;
        
    }
    printf("%lld\n",l);
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:56:5: error: expected unqualified-id before 'while'
   56 |     while(l<=r)
      |     ^~~~~
Language: C++

#include<bits/stdc++.h>
using namespace std ;
int a[1200000];
int b[1200000];
int n,m;
int cmp(int a ,int b){
	return a>b;
}
inline void read(int &x){
   int s = 0, w = 1; char ch = getchar();
   while(ch < '0' || ch > '9'){ if(ch == '-') w = -1; ch = getchar(); }
   while(ch >= '0' && ch <= '9') s = s * 10 + ch - '0', ch = getchar();
   x = s*w;
}
long long int check(long long int t){
	long long int sum=0;
	for(int i=0;i<n;i++){
		if(t/b[i]==0){
			sum+=a[i];
		}
		else {
			if(a[i]>=t/b[i]){
				sum+=a[i]-(t/b[i]);
			}
			else{
				sum+=0;
			}
		}
	}
	if(sum<=m){
		return 1;
	}
	else{
		return 0;
	}
}
int main()
{
	long long int ans=0;
	cin>>n>>m;
	for(int i=0;i<n;i++){
		scanf("%d",&a[i]);
		ans+=a[i];
	}
	for(int i=0;i<n;i++){
		scanf("%d",&b[i]);
	}
	if(m>=ans){
		printf("0\n");
		return 0;
	}
	sort(a,a+n);
	sort(b,b+n,cmp);
	long long int l=0,r=1200000000000;
	long long 
    while(l<r) 
    {	
        long long int mid = (l + r) / 2;
        if(check(mid)) r = mid; //检查mid是否符合题目要求
        else l = mid+1;
        
    }
    printf("%lld\n",l);
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:56:5: error: expected unqualified-id before 'while'
   56 |     while(l<r)
      |     ^~~~~
Language: C++

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

int main() {
  int n;
  int64_t k;
  cin >> n >> k;
  vector<int64_t> a(n), f(n), anew(n);
  for (int i = 0; i < n; i++) cin >> a.at(i);
  for (int i = 0; i < n; i++) cin >> f.at(i);
  sort(a.begin(), a.end());
  sort(f.rbegin(), f.rend());
  int64_t s = 0, cost = 0;
  double sinv = 0;
  for (int i = 0; i < n; i++) s += a.at(i);
  for (int i = 0; i < n; i++) sinv += 1.0 / f.at(i);
  if (s <= k) {
    cout << 0 << endl;
    return 0;
  }
  s -= k;
  for (int i = 0; i < n; i++) {
    anew.at(i) = min(a.at(i), s / sinv / f.at(i));
    s -= anew.at(i);
    sinv -= 1.0 / f.at(i);
  }
  for (int i = 0; i < n; i++) {
    cost = max(cost, anew.at(i) * f.at(i));
  }
  cout << cost << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:23:21: error: no matching function for call to 'min(__gnu_cxx::__alloc_traits<std::allocator<long int>, long int>::value_type&, double)'
   23 |     anew.at(i) = min(a.at(i), s / sinv / f.at(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:23:21: note:   deduced conflicting types for parameter 'const _Tp' ('long int' and 'double')
   23 |     anew.at(i) = min(a.at(i), s / sinv / f.at(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:23:21: note:   mismatched types 'std::initializer_list<_Tp>' and 'long int'
   23 |     anew.at(i) = min(a.at(i), s / sinv / f.at(i));
      |                  ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Language: C++

#include <bits/stdc++.h>
#include <math.h>
using namespace std;
#define PI 3.14159265
#define LOOP(val, times)   for(val = 0; val < (times); val++)
int main(){
  int n;
  long long k;
  cin>>n>>K;
  vector<int> a(n);
  vector<int> f(n);
  int i;
  LOOP(i,n){
    cin>>a[i];
  }
  LOOP(i,n){
    cin>>f[i];
  }
  sort(a.begin(),a.end());
  sort(f.begin(),f.end());
  reverse(f.begin(),f.end());
  long long jj=0;
  LOOP(i,n){
    jj+=a[i]*f[i];
  }
  

Compiler output:
a.cc: In function 'int main()':
a.cc:9:11: error: 'K' was not declared in this scope
    9 |   cin>>n>>K;
      |           ^
a.cc:25:4: error: expected '}' at end of input
   25 |   }
      |    ^
a.cc:6:11: note: to match this '{'
    6 | int main(){
      |           ^
Language: C++

#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

int main(){

	long long int n, k, mi, ma, se, cnt=0;
	vector<long long int> a, f;

	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<long long int>());

	mi=0;
	ma=1000000000000;

	while(1){
		se=(mi+ma)/2;
		cnt=0;

		for(int i=0;i<n;i++){
			if(se<a[i]*f[i]){
				cnt+=(a[i]*f[i]-se+f[i]-1)/f[i];
			}
            	//cout<< a[i] << f[i] << cnt <<endl;
		}

		if(k<cnt) mi=se;
		else ma=se;
        
        if(ma-mi<2) break;
	}
		

	cout<< max(0, mi-1) << endl;


}


Compiler output:
a.cc: In function 'int main()':
a.cc:44:19: error: no matching function for call to 'max(int, long long int)'
   44 |         cout<< max(0, mi-1) << endl;
      |                ~~~^~~~~~~~~
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:44:19: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   44 |         cout<< max(0, mi-1) << endl;
      |                ~~~^~~~~~~~~
/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:44:19: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   44 |         cout<< max(0, mi-1) << endl;
      |                ~~~^~~~~~~~~
Language: C++

#include<bits/stdc++.h>
using namespace std ;
int a[1200000];
int b[1200000];
int n,m;
int cmp(int a ,int b){
	return a>b;
}
long long int check(long long int t){
	long long int sum=0;
	for(int i=0;i<n;i++){
		if(t/b[i]==0){
			sum+=a[i];
		}
		else {
			if(a[i]>=t/b[i]){
				sum+=a[i]-(t/b[i]);
			}
			else{
				sum+=0;
			}
		}
	}
	if(sum<=m){
		return 1;
	}
	else{
		return 0;
	}
}
int main()
{
	long long int ans=0;
	cin>>n>>m;
	for(int i=0;i<n;i++){
		scanf("%d",&a[i]);
		ans+=a[i];
	}
	for(int i=0;i<n;i++){
		scanf("%d",&b[i]);
	}
	if(m>=ans){
		printf("0\n");
		return 0;
	}
	sort(a,a+n);
	sort(b,b+n,cmp);p
	long long int l=0,r=1200000000000;
    while(l< r) //循环条件为区间长度>=2
    {	
        int mid = (l + r) / 2;
        if(check(mid)) r = mid; //检查mid是否符合题目要求
        else l = mid+1;
        
    }
    printf("%lld\n",l);
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:47:25: error: 'p' was not declared in this scope
   47 |         sort(b,b+n,cmp);p
      |                         ^
a.cc:49:11: error: 'l' was not declared in this scope
   49 |     while(l< r) //循环条件为区间长度>=2
      |           ^
a.cc:49:14: error: 'r' was not declared in this scope
   49 |     while(l< r) //循环条件为区间长度>=2
      |              ^
a.cc:56:21: error: 'l' was not declared in this scope
   56 |     printf("%lld\n",l);
      |                     ^