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

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

typedef long long ll;
int main(){
  int N
  ll B;
  cin>>N;
  vector<ll> A(N);
  for(int i = 0;i<N;i++){
  	cin>>A[i];
  }for(int i = 0;i<N;i++){
  	cin>>B;
  	A[i]-=B;
  }
  sort(A.begin(),A.end());
  cout<<A[0]<<endl;
  cout<<A[1]<<endl;
  ll sum = 0;
  int minus = 0;
  while(minus<N&&A[minus]<0){
  	sum -= A[minus];
  	minus++;
  }
  int i = N-1;
  while(i>=0&&A[i]>0&&sum>0){
  	sum -= A[i];
  	i--;
  }
  if(sum>0){
  	cout<<-1<<endl;
  }else{
  	cout<<minus+(N-1)-i<<endl;
  }

  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:10:3: error: expected initializer before 'll'
   10 |   ll B;
      |   ^~
a.cc:11:8: error: 'N' was not declared in this scope
   11 |   cin>>N;
      |        ^
a.cc:16:14: error: 'B' was not declared in this scope
   16 |         cin>>B;
      |              ^
Language: C++

import java.util.*;
public class KeyenceChallenge3 {
 public static void main (String[] args){

	 	Scanner sc = new Scanner(System.in);
	 	
	 	// 整数の入力
	 	int N = sc.nextInt();
	 	int[] A = new int[N];
	 	for (int i=0; i<N;i++){
	 		A[i]= sc.nextInt();
	 	}
	 	int[] B = new int[N];
	 	for (int i=0; i<N; i++){
	 		B[i]= sc.nextInt();
	 	}
	 	
	 	for( int i : A){
	 		System.out.println(i);
	 	}
	 	
	 	
	 	int[] C = A.clone();
	 	
	 	int Asum=0, Bsum=0;
	 	for (int i=0; i<N; i++){
	 		Asum= Asum+ A[i];
	 		Bsum= Bsum+ B[i];
	 	}
	 	if(Bsum > Asum){
	 		System.out.println("-1");
	 	}
	 	
	 	// A[i]-B[i]の差が小さい順に配列を入れ替える
	 	for (int i=0; i<N; i++){
	 		for (int j=1; i<j; j++){
	 			if(B[j]-A[j] > B[j-1]-A[j-1] ){
	 				int tmp1a = A[j-1];
	 				int tmp1b = B[j-1];
	 				A[j-1]= A[j];
	 				B[j-1]= B[j];
	 				A[j]=tmp1a;
	 				B[j]=tmp1b;
	 			}
	 		}
	 	}
	 	
	 	for (int i=0; i<N; i++){
	 		System.out.print(A[i]+ " ");
	 	}
	 	for (int i=0; i<N; i++){
	 		System.out.print(B[i]+ " ");
	 	}
  }
}


Compiler output:
a.cc:1:1: error: 'import' does not name a type
    1 | import java.util.*;
      | ^~~~~~
a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:2:1: error: expected unqualified-id before 'public'
    2 | public class KeyenceChallenge3 {
      | ^~~~~~
Language: C++

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

int main()
{
    int n,i;
    cin >> n;
    vector<int> a(n);
    vector<int> b(n);
    for(i = 0;i < n;++i){
        cin >> a.at(i);
    }
     for(i = 0;i < n;++i){
        cin >> b.at(i);
    }
    long long need = 0
    int neednum = 0,ans = 0;;
    vector<long long> koe;
    for(i = 0;i < n;++i){
        if(a.at(i) > b.at(i)){
            koe.push_back(a.at(i)-b.at(i));
        }else if(a.at(i) < b.at(i)){
            need += b.at(i)-a.at(i);
            ++neednum;
        }
    }
    if(need == 0){
        cout << 0 << endl;
        return 0;
    }
    sort(koe.begin(),koe.end());
    for(i = koe.size()-1;i >= 0;--i){
        need -= koe.at(i);
        ++ans;
        if(need <= 0){
            break;
        }
    }
    if(i == -1){
        cout << -1 << endl;
    }else{
        cout << ans+neednum << endl;
    }
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:19:5: error: expected ',' or ';' before 'int'
   19 |     int neednum = 0,ans = 0;;
      |     ^~~
a.cc:26:15: error: 'neednum' was not declared in this scope; did you mean 'need'?
   26 |             ++neednum;
      |               ^~~~~~~
      |               need
a.cc:36:11: error: 'ans' was not declared in this scope; did you mean 'abs'?
   36 |         ++ans;
      |           ^~~
      |           abs
a.cc:44:17: error: 'ans' was not declared in this scope; did you mean 'abs'?
   44 |         cout << ans+neednum << endl;
      |                 ^~~
      |                 abs
a.cc:44:21: error: 'neednum' was not declared in this scope; did you mean 'need'?
   44 |         cout << ans+neednum << endl;
      |                     ^~~~~~~
      |                     need
Language: Java

import java.util.*;

public class Main {

    /**
     * @param args
     */
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        int[] A = new int[N];
        int[] B = new int[N];
        for (int i=0; i<N; i++) {
            A[i] = sc.nextInt();
        }
        for (int i=0; i<N; i++) {
            B[i] = sc.nextInt();
        }

        int ans = solve2(N, A, B);

        System.out.println(ans);
    }

    private static int solve2(int N, int[] A, int[] B) {
        int count = 0;

        int[] C = new int[N];
        long sum = 0;
        long negative = 0;
        for (int i=0; i<N; i++) {
            C[i] = A[i] - B[i];
            sum += C[i];
            if (C[i] < 0) {
                negative += C[i];
                count++;
                C[i] = 0;
            }
        }
        if (sum < 0) return -1;
        Arrays.sort(C);

        for (int i=N-1; i>=0; i--) {
            if (C[i] == 0 || negative >= 0) break;

            negative += C[i];
            count++;
        }

        return count;
    }

Compiler output:
Main.java:52: error: reached end of file while parsing
    }
     ^
1 error
Language: C++

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

main(){
	int n;
	cin >> n;
	int a[n],b[n],c[n];
	for(int i=0;i<n;i++){
		cin >> a[i];
	}
	for(int i=0;i<n;i++){
		cin >> b[i];
	}
	for(int i=;i<n;i++){
		c[i]=b[i]-a[i];
	}
	sort(c,c+n);
	long long int ans=0; 
	long long int total=0;
	for(int i=0;i<n;i++){
		cout << c[i] <<" ";
	}cout <<endl;
	for(int i=0;i<n;i++){
		if(c[i]>0){
			total+=c[i];
			ans++;
		}
	}

	for(int i=0;i<n;i++){
		if(c[i]<0 && total>0){
			total+=c[i];
			ans++;
		}
	}
	if(total>0){
		cout << "-1" <<endl;
	}else{
		cout << ans <<endl;
	}
}




Compiler output:
a.cc:6:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    6 | main(){
      | ^~~~
a.cc: In function 'int main()':
a.cc:16:19: error: expected primary-expression before ';' token
   16 |         for(int i=;i<n;i++){
      |                   ^
Language: C++

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long  ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {

    int  N,i;
    std::cin >> N;
    vector<ll> A(N);
    vector<ll> B(N);
    vector<ll> diff(N);
    ll sum_a,sum_b,tmp;
    sum_a=0;
    sum_b=0;

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

    for(i = 0 ; i < N;i++){
        
        cin >> tmp;
        B[i]=tmp; 
        sum_b += tmp;
        //cout<<A[i] <<" " << B[i]<<endl;
    }

    if(sum_a<sum_b){
        cout << "-1" << endl;
        return 0;
    }

    ll neg=0;
    int num_neg=0;
    for(i = 0 ; i <= N;i++){
        diff[i]=A[i]-B[i]; 
        if(diff[i]<=-1){
            num_neg++;
            neg -= diff[i];
            //cout <<A[i] <<" "<<B[i]<<" " << diff[i]<<" "<<neg <<endl;
        }
    }
    
    std::vector<ll>().swap(A);
    std::vector<ll>().swap(B);

    sort(diff.begin(),diff.end());
    ll pos=0;

    for( i=N-1;i>=0;i--){
        //cout << neg<< " "<<pos <<" " << i<<endl;
        if(pos>=neg){
            break;
        }else{
            pos +=diff[i];            
            num_neg++;
        }
    }
    cout << num_neg <<endl;
    return 0;
}
v

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

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int , int> P;
typedef pair<ll, ll> PL;
const int INT_INF = 2147483646;
const ll LL_INF = 9223372036854775807;
 
bool SecondCompare(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second<b.second;
}
 
bool SecondCompareDes(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second>b.second;
}

ll n;
const int SI = 1e5+10;
ll a[SI],b[SI],sa[SI],samem[SI];
ll suma,sumsa;
 
int main(){
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> a[i];
        suma += a[i];
    }
    for(int i = 0; i < n; i++){
        cin >> b[i];
        sa[i] = b[i]-a[i];
        sumsa += sa[i];
    }
    sort(sa,sa+n);
  
    ll ans = 0;
    if(sumsa > 0){
        cout << -1 << enadl;
        return 0;
    }

    ll minus = 0;
    for(int i = 0; i < n; i++){
        if(b[i] > a[i]) minus += b[i]-a[i];
    }

    ll sum = 0;
    while(minus > sum){
        sum += abs(sa[ans]);
        ++ans;
    }
    for(int i = 0; i < n; i++){
        if(b[i] > a[i]) ++ans;
    }
    cout << ans << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:39:23: error: 'enadl' was not declared in this scope
   39 |         cout << -1 << enadl;
      |                       ^~~~~
Language: C++

object Main {
  import java.util.Scanner

  def readStrings(n: Int)(implicit sc: Scanner): Array[String] = Array.fill(n) { sc.next() }
  def readInts(n: Int)(implicit sc: Scanner): Array[Int] = Array.fill(n) { sc.nextInt() }
  def readLongs(n: Int)(implicit sc: Scanner): Array[Long] = Array.fill(n) { sc.nextLong() }
  def readLineStrings(implicit sc: Scanner): Array[String] = sc.nextLine().split(' ')
  def readLineInts(implicit sc: Scanner): Array[Int] = readLineStrings.map(_.toInt)
  def readLineLongs(implicit sc: Scanner): Array[Long] = readLineStrings.map(_.toLong)

  def main(args: Array[String]): Unit = solve(new Scanner(System.in))

  def solve(implicit sc: Scanner): Unit = {
    val N = sc.nextLong
    val A = readLineLongs
    val B = readLineLongs
    val AmB = A.zip(B).map { case (a, b) => a - b }
    if (AmB.sum < 0) return print(-1)

    val (negatives, positives) = AmB.partition(_ < 0)
    val negSorted = negatives.sorted(implicitly[Ordering[Long]].reverse)
    val posSorted = positives.filter(_ > 0).sorted

    def posUseNumber: Int = {
      var negIndex = 0
      var posMinUnaltered = 0

      while (negIndex > negSorted.length) {
        val a = negSorted(negIndex)

        def search: Option[Int] = {
          for {i <- posSorted.indices} if (posSorted(i) > a) return Some(i)
          None
        }

        search match {
          case Some(index) => {
            posSorted(index) -= a
            negSorted(negIndex) = 0

            negIndex += 1
            posMinUnaltered = Math.max(posMinUnaltered, index)
          }
          case None => {
            var negToFill = negSorted.sum * (-1)
            val (usedPos, unusedPos) = posSorted.splitAt(posMinUnaltered)
            negToFill -= usedPos.sum
            val additionalUse = unusedPos.scan(0L)(_ + _).takeWhile(_ < negToFill).length
            return posMinUnaltered + additionalUse
          }
        }
      }
      posMinUnaltered
    }

    println(negSorted.length + posUseNumber)
  }
}


Compiler output:
a.cc:1:1: error: 'object' does not name a type
    1 | object Main {
      | ^~~~~~
Language: C++

#intlude <bits/stdc++.h>
using namespace std;
int main(){
  int n,a[100000],b[100000],ac=0,bc=0,ans;
  vector<int> vec;
  cin>>n;
  ans=n;
  for(int i=0;i<n;i++){
    cin>>a[i];
    ac+=a[i];
  }
  for(int i=0;i<n;i++){
    cin>>b[i];
    bc+=b[i];
    if(a[i]>b[i])vec.push_back(a[i]-b[i]);
  }
  int cnt=bc-ac;
  sort(vec.begin(),vec.end());
  if(cnt<0)cout<<-1<<endl;
  else{
    for(int i=0;i<vec.size();i++){
      cnt-=vec[i];
      if(cnt<0)break;
      ans--;
    }
    cout<<ans<<endl;
  }
}

Compiler output:
a.cc:1:2: error: invalid preprocessing directive #intlude; did you mean #include?
    1 | #intlude <bits/stdc++.h>
      |  ^~~~~~~
      |  include
a.cc: In function 'int main()':
a.cc:5:3: error: 'vector' was not declared in this scope
    5 |   vector<int> vec;
      |   ^~~~~~
a.cc:1:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
  +++ |+#include <vector>
    1 | #intlude <bits/stdc++.h>
a.cc:5:10: error: expected primary-expression before 'int'
    5 |   vector<int> vec;
      |          ^~~
a.cc:6:3: error: 'cin' was not declared in this scope
    6 |   cin>>n;
      |   ^~~
a.cc:1:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
  +++ |+#include <iostream>
    1 | #intlude <bits/stdc++.h>
a.cc:15:18: error: 'vec' was not declared in this scope
   15 |     if(a[i]>b[i])vec.push_back(a[i]-b[i]);
      |                  ^~~
a.cc:18:8: error: 'vec' was not declared in this scope
   18 |   sort(vec.begin(),vec.end());
      |        ^~~
a.cc:18:3: error: 'sort' was not declared in this scope; did you mean 'short'?
   18 |   sort(vec.begin(),vec.end());
      |   ^~~~
      |   short
a.cc:19:12: error: 'cout' was not declared in this scope
   19 |   if(cnt<0)cout<<-1<<endl;
      |            ^~~~
a.cc:19:12: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:19:22: error: 'endl' was not declared in this scope
   19 |   if(cnt<0)cout<<-1<<endl;
      |                      ^~~~
a.cc:1:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
  +++ |+#include <ostream>
    1 | #intlude <bits/stdc++.h>
a.cc:26:5: error: 'cout' was not declared in this scope
   26 |     cout<<ans<<endl;
      |     ^~~~
a.cc:26:5: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:26:16: error: 'endl' was not declared in this scope
   26 |     cout<<ans<<endl;
      |                ^~~~
a.cc:26:16: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
Language: C++

#include<iostream>
using namespace std;

int main(){
	int N;
	cin >> N;
	
	long int i, j, A[N], B[N];
	for(i=0; i<N; i++){
		cin >> A[i];
	}
	for(i=0; i<N; i++){
		cin >> B[i];
	}
	
	int ans = 0;
	long long int C[i];//各々の猶予分
	long long int D[i]={0};//C>0のときの移す場
	long long int minus = 0;//不足分の合計
	long long int plus = 0;
	long long int Sum = 0;
	j=0;
	int k, jmax = 0;
	for(i=0; i<N; i++){
		C[i] = A[i] - B[i];
		if(C[i]<0){
			minus += C[i];
			ans++;
		}
		if(C[i]>0){
			plus += C[i];
		}
	}

	if(minus+plus < 0){
		cout << -1 << endl;
		return 0;
	}

	for(j=0; j<N; j++){
		for(i=0; i<N-1; i++){
			if(C[i]>C[i+1]){
				int tmp = C[i];
				C[i] = C[i+1];
				C[i+1] = tmp;
			}
		}
	}
	if(C[0]>=0){
		cout << 0 << endl;
		return 0;
	}

	do{
		minus += D[i];
		i--;
		ans++;
	}while(minus<0);*/

	i = N-1;
	do{
		minus += C[i];
		i--;
		ans++;
	}while(minus<0);
	
	cout << ans << endl;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:58:26: error: expected primary-expression before '/' token
   58 |         }while(minus<0);*/
      |                          ^
Language: C++

/* Exam and Wizard */

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

int main(){
	int n;
	cin >> n;

	int *a = new int[n], *b = new int[n];
	int *c = new int[n];
	int minsum = 0;
	int maxsum = 0;
	int ncnt = 0;
	int pcnt = 0;

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

	for(int i = 0; i < n; i++){
		cin >> b[i];
		c[i] = a[i] - b[i];
		if(c[i] < 0){
			minsum += c[i];
			ncnt++;
		}else{
			maxsum += c[i];
		}
	}

    sort(c, c+n);
    if(maxsum + minsum >= 0){
	    int psum = 0, x = n - 1;
    	while(psum < -(minsum)){
	    	psum += c[x];
    		pcnt++;
	    	x--;
    	}
      　cout << ncnt + pcnt << endl;
        return 0;
    }else{
    	cout << -1 << endl;
    	return 0;
    }

}

Compiler output:
a.cc:41:7: error: extended character 　 is not valid in an identifier
   41 |       　cout << ncnt + pcnt << endl;
      |       ^
a.cc: In function 'int main()':
a.cc:41:7: error: '\U00003000cout' was not declared in this scope
   41 |       　cout << ncnt + pcnt << endl;
      |       ^~~~~~
Language: C++

/* Exam and Wizard */

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

int main(){
	int n;
	cin >> n;

	int *a = new int[n], b = new int[n];
	int *c = new int[n];
	int minsum = 0;
	int maxsum = 0;
	int ncnt = 0;
	int pcnt = 0;

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

	for(int i = 0; i < n; i++){
		cin >> b[i];
		c[i] = a[i] - b[i];
		if(c[i] < 0){
			minsum += c[i];
			ncnt++;
		}else{
			maxsum += c[i];
		}
	}

    sort(c, c+n);
    if(maxsum + minsum >= 0){
	    int psum = 0, x = n - 1;
    	while(psum < -(minsum)){
	    	psum += c[x];
    		pcnt++;
	    	x--;
    	}
    }else{
    	cout << -1 << endl;
    	return 0;
    }

    cout << ncnt + pcnt << endl;
    return 0;

}

Compiler output:
a.cc: In function 'int main()':
a.cc:11:43: error: invalid conversion from 'int*' to 'int' [-fpermissive]
   11 |         int *a = new int[n], b = new int[n];
      |                                           ^
      |                                           |
      |                                           int*
a.cc:23:25: error: invalid types 'int[int]' for array subscript
   23 |                 cin >> b[i];
      |                         ^
a.cc:24:32: error: invalid types 'int[int]' for array subscript
   24 |                 c[i] = a[i] - b[i];
      |                                ^
Language: C++

#include <iostream>
#include <array>
#include <regex>
#include <string>
#include <algorithm>
#include <numeric>
using namespace std;

int main(int argc, char const *argv[]) {
    int N;
    int A[100000];
    int B[100000];
    int sub[100000];
    int k=0;
    std::cin >> N;
    for (size_t i = 0; i < N; i++) {
        std::cin >> A[i];
    }
    int num=0;
    for (size_t i = 0; i < N; i++) {
        std::cin >> B[i];
        sub[i]=A[i]-B[i];
        if(sub[i]<0){
            num++;
            k+=sub[i];
        }
    }
    if(accumulate(begin(sub),begin(sub)+N, 0)<0){
        std::cout << -1 << '\n';
        return 0;
    }
    while (k<0) {
        int *mx = max_element(sub, sub+N);
        k+=*mx;
        *mx+=k;
        if(*mx<0)k+=mx;
        num++;
    }

    std::cout << num << '\n';
    return 0;
}


Compiler output:
a.cc: In function 'int main(int, const char**)':
a.cc:36:19: error: invalid conversion from 'int*' to 'int' [-fpermissive]
   36 |         if(*mx<0)k+=mx;
      |                  ~^~~~
      |                   |
      |                   int*
Language: C++

#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <string>
#include <queue>

using namespace std;

typedef long long int ll;
typedef long long int li;


int main(void){
    ll ans=0;
    li n;
    ll sum=0;
    cin >> n;
    li a[n+1],b[n+1],d[n+1],e[n+1],f[n+1];
    for(li i=1;i<n+1;i++)cin >> a[i];
    for(li i=1;i<n+1;i++)cin >> b[i];
    for(li i=1;i<n+1;i++){
        e[i]=a[i]-b[i];
        sum+=e[i];
    }
    if(sum<=0)cout << -1 << endl;
    else{
        sort(e+1,e+n+1);
      li sum1=0;
      for(li i=1;i<n+1;i++){d[i]=e[n-i+1];f[i]=e[n-i+1];}
        li m=n;
		for(li j=1;j<n+1;j++){if(e[j]>=0)break;ans++;sum1+=e[j];}
      
      for(li j=1;j<=n+1j++){sum1+=d[j];ans++;if(d[j]>=0)break;}
        cout << ans << endl;
    }
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:35:25: error: lvalue required as increment operand
   35 |       for(li j=1;j<=n+1j++){sum1+=d[j];ans++;if(d[j]>=0)break;}
      |                         ^~
a.cc:35:27: error: expected ';' before ')' token
   35 |       for(li j=1;j<=n+1j++){sum1+=d[j];ans++;if(d[j]>=0)break;}
      |                           ^
      |                           ;
Language: C++

#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <string>
#include <queue>

using namespace std;

typedef long long int ll;
typedef long long int li;


int main(void){
    ll ans=0;
    li n;
    ll sum=0;
    cin >> n;
    li a[n+1],b[n+1],d[n+1],e[n+1],f[n+1];
    for(li i=1;i<n+1;i++)cin >> a[i];
    for(li i=1;i<n+1;i++)cin >> b[i];
    for(li i=1;i<n+1;i++){
        e[i]=a[i]-b[i];
        sum+=e[i];
    }
    if(sum<=0)cout << -1 << endl;
    else{
        sort(e+1,e+n+1);
      li sum1=0;
      for(li i=1;i<n+1;i++){d[i]=e[n-i+1];f[i]=e[n-i+1];}
        li m=n;
		for(li j=1;j<n+1;j++){if(e[j]>=0)break;ans++;sum1+=e[j];}
      
      for(li j=1;j<=n+1j++){sum1+=d[j];ans++;if(d[j]>=0)break;}
            }
        }
        cout << ans << endl;
    }
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:35:25: error: lvalue required as increment operand
   35 |       for(li j=1;j<=n+1j++){sum1+=d[j];ans++;if(d[j]>=0)break;}
      |                         ^~
a.cc:35:27: error: expected ';' before ')' token
   35 |       for(li j=1;j<=n+1j++){sum1+=d[j];ans++;if(d[j]>=0)break;}
      |                           ^
      |                           ;
a.cc: At global scope:
a.cc:38:9: error: 'cout' does not name a type
   38 |         cout << ans << endl;
      |         ^~~~
a.cc:39:5: error: expected declaration before '}' token
   39 |     }
      |     ^
a.cc:40:5: error: expected unqualified-id before 'return'
   40 |     return 0;
      |     ^~~~~~
a.cc:41:1: error: expected declaration before '}' token
   41 | }
      | ^
Language: C++

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

main(){
	int n;
	cin >> n;
	int a[n],b[n],c[n];
	for(int i=0;i<n;i++){
		cin >> a[i] >> b[i];
		c[i]=a[i]-b[i];
	}
	sort(c,c+n);
	long long int ans=0; 
	long long int total=0;
	for(int i=0;i<N;i++){
		if(c[i]>0){
			total+=c[i];
			ans++;
		}
	}

	for(int i=0;i<n;i++){
		if(c[i]<0 && total>0){
			total+=c[i];
			ans++;
		}
	}
	if(total>0){
		cout << "-1" <<endl;
	}else{
		cout << ans <<endl;
	}
}




Compiler output:
a.cc:6:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    6 | main(){
      | ^~~~
a.cc: In function 'int main()':
a.cc:17:23: error: 'N' was not declared in this scope
   17 |         for(int i=0;i<N;i++){
      |                       ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int , int> P;
typedef pair<ll, ll> PL;
const int INT_INF = 2147483646;
const ll LL_INF = 9223372036854775807;
 
bool SecondCompare(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second<b.second;
}
 
bool SecondCompareDes(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second>b.second;
}

ll n;

ll a[100010],b[100010],sa[10010],samem[10010];
ll suma,sumsa;
 
int main(){
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> a[i];
        suma += a[i];
    }
    for(int i = 0; i < n; i++){
        cin >> b[i];
        sa[i] = b[i]-a[i];
        sumsa += sa[i];
    }
    sort(sa,sa+n);
  
    int ans = 0;
    if(sumsa > 0){
        cout << -1 << endl;
        return 0;
    }

    int sta = 0;
    for(int i = 0; i < n; i++){
        samem[i] = sa[i];
        if(sta == 0 && sa[i] > 0)   sta = i;
    }

    int pos = 0;

    for(int i = sta; i < n; i++){
        if(sa[i] > 0){
            while(true)
                if(sa[pos] == 0)    ++pos;
                if(sa[i] > abs(sa[pos])){
                    sa[i] += sa[pos];
                    sa[pos] = 0;
                }
                else{
                    sa[pos] += sa[i];
                    sa[i] = 0;
                }
                if(sa[i] == 0) break;
            }
        }
    }

    for(int i = 0; i < n; i++){
        if(sa[i] != samem[i])   ++ans;
        //cout << sa[i] << ' ' << samem[i] << endl;
    }
    cout << ans << endl;
}

Compiler output:
a.cc:68:5: error: expected unqualified-id before 'for'
   68 |     for(int i = 0; i < n; i++){
      |     ^~~
a.cc:68:20: error: 'i' does not name a type
   68 |     for(int i = 0; i < n; i++){
      |                    ^
a.cc:68:27: error: 'i' does not name a type
   68 |     for(int i = 0; i < n; i++){
      |                           ^
a.cc:72:5: error: 'cout' does not name a type
   72 |     cout << ans << endl;
      |     ^~~~
a.cc:73:1: error: expected declaration before '}' token
   73 | }
      | ^
Language: Java

import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    long[] A = new long[N];
    long[] B = new long[N];
    long[] C = new long[N];
    long sum = 0;
    long minus = 0;
    int C_minus = 0;

    for(int i=0;i<N;i++){
      long Ai = sc.nextLong();
      A[i] =Ai;
      C[i]=Ai;
    }
    for(int i=0;i<N;i++){
      long Bi = sc.nextLong();
      B[i] =Bi;
      C[i] = C[i]-Bi;
      sum += C[i];
      if(C[i]<0){
         C_minus++;
         minus += C[i];
      }
    }
    if(C_minus=0){
      System.out.println(0);
    }else if(sum<0){
      System.out.println(-1);

    }else{

    //  System.out.println(C_minus);
    //  System.out.println(C[0]);
    //  System.out.println(C[1]);
    //  System.out.println(C[2]);
      int answer = 0;
      Arrays.sort(C);
      for(int i=C.length-1;i>=0;i--){
        minus += C[i];
    //    System.out.println(minus);
        if(minus>0){
          answer =C.length-1-i+1;
          break;
        }
      }
      answer += C_minus;
      System.out.println(answer);
    }
  }
}


Compiler output:
Main.java:29: error: incompatible types: int cannot be converted to boolean
    if(C_minus=0){
              ^
1 error
Language: C++

#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

int main() {
  int n;
  cin >> n;

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

  // aの方が大きい
  int plus = 0;
  // bの方が大きい
  int minus = 0;
  // 変える必要がある要素
  int change[n];
  int num = 0;
  vector <int> over();
  int o_num = 0;
  for(int i = 0; i < n; i++) {
    if(a[i] > b[i]) {
      plus += (a[i] - b[i]);
      over.push_back(a[i] - b[i]);
      o_num++;
    }
    if(a[i] < b[i]) {
      minus += (b[i] - a[i]);
      change[num] = i;
      num++;
    }
  }
  for(int i = 0; i < num; i++) {
    int x = change[i];
    plus -= (b[x] - a[x]);
    if(plus < 0) {
      cout << -1 << endl;
      return 0;
    }
  }

  sort(over.bigin(), over.end(),greater<int>());
  for(int i = 0; i < o_num; i++) {
    int x = over[i];

  }
}


Compiler output:
a.cc: In function 'int main()':
a.cc:26:20: warning: empty parentheses were disambiguated as a function declaration [-Wvexing-parse]
   26 |   vector <int> over();
      |                    ^~
a.cc:31:12: error: request for member 'push_back' in 'over', which is of non-class type 'std::vector<int>()'
   31 |       over.push_back(a[i] - b[i]);
      |            ^~~~~~~~~
a.cc:49:13: error: request for member 'bigin' in 'over', which is of non-class type 'std::vector<int>()'
   49 |   sort(over.bigin(), over.end(),greater<int>());
      |             ^~~~~
a.cc:49:27: error: request for member 'end' in 'over', which is of non-class type 'std::vector<int>()'
   49 |   sort(over.bigin(), over.end(),greater<int>());
      |                           ^~~
a.cc:51:19: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   51 |     int x = over[i];
      |                   ^
a.cc:51:19: error: invalid conversion from 'std::vector<int> (*)()' to 'int' [-fpermissive]
   51 |     int x = over[i];
      |                   ^
      |                   |
      |                   std::vector<int> (*)()
Language: C++

#include<iostream>
#include<string>
#define ll long long
using namespace std;

int main(){
    int N;
    cin >> N;
    ll A[N],B[N], C[N];
    for(int i=0;i<N;i++){
        cin >> A[i];
    }
    ll sumC=0;
    for(int i=0;i<N;i++){
        cin >> B[i];
        C[i] = B[i] - A[i];
        sumC += C[i];
    }

    if(sumC > 0){
        cout << -1 << endl;
        return 1;
    }

    sort(C, C+N);
    ll count=0,bank=0;
    for(int i=0, j=N-1;C[j] > 0;){
        bank += C[i];
        i++;
        count++;
        while(C[j] > 0){
            if(abs(C[j]) > abs(bank)) {
                C[j] += bank;
                bank = 0;
                break;
            }else{
                bank += abs(C[j]);
                C[j] = 0;
                count++;
                j--;
            }
        }
    }
    cout << count << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:25:5: error: 'sort' was not declared in this scope; did you mean 'short'?
   25 |     sort(C, C+N);
      |     ^~~~
      |     short
Language: C++

#include "pch.h"
#include <iostream>
#include <string>
#include<queue>
#include<vector>
using namespace std;
int main()
{
	int n, sum, ans;
	sum = 0;
	int sumsum = 0;
	ans = 0;
	priority_queue<int> v;
	cin >> n;
	int ab[100005][2] = { 0 };
	for (int i = 1; i <= n; i++) {
		cin >> ab[i][0];
	}
	for (int i = 1; i <= n; i++) {
		cin >> ab[i][1];
		if (ab[i][0] > ab[i][1]) {
			v.push(ab[i][0] - ab[i][1]);
			sumsum += (ab[i][0] - ab[i][1]);
		}
		if (ab[i][0] < ab[i][1]) {
			sum += (ab[i][0] - ab[i][1]);
			ans++;
			//cout << 1744 << endl;
		}
	}
	if (sum + sumsum < 0) cout << -1 << endl;
	else {
		while (sum < 0) {
			sum += v.top();
			v.pop();
			ans++;
			//cout << 57 << endl;
		}
		cout << ans << endl;
	}

}

Compiler output:
a.cc:1:10: fatal error: pch.h: No such file or directory
    1 | #include "pch.h"
      |          ^~~~~~~
compilation terminated.
Language: Java

import java.util.*;
public class main {
	public static void main(String[]args) {
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int[]ai=new int[n];
		int[]bi=new int[n];
		for(int i=0;i<n;i++) {
			ai[i]=sc.nextInt();
		}
		for(int i=0;i<n;i++) {
			bi[i]=sc.nextInt();
		}
		int minusNums=0;
		int minusNumsLength=0;
		int[]plusNums=new int[n];
		for(int i=0;i<n;i++) {
			if(ai[i]-bi[i]<0) {
				minusNums+=ai[i]-bi[i];
				minusNumsLength++;
			}else {
				plusNums[i]=ai[i]-bi[i];
			}
		}
		if(minusNums==0) {
			System.out.println("0");
			return;
		}
		Arrays.sort(plusNums);
		for(int i=0;i<plusNums.length;i++) {
			minusNums+=plusNums[plusNums.length-i-1];
			if(minusNums>=0) {
				System.out.println(minusNumsLength+i+1);
				return;
			
			}
		}
		System.out.println("-1");
		
	}
}



Compiler output:
Main.java:2: error: class main is public, should be declared in a file named main.java
public class main {
       ^
1 error
Language: C++

#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int ;
  cin >> N;
  
  vector<int> A(N);
  vector<int> B(N);
  
  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
  }
 
  for (int i = 0; i < N; i++) {
    cin >> B.at(i);
  }
 
  int C
    
  for (int i = 0; i < N; i++) {
    C = C + ( A.at(i) - B.at(i) );
  
 
  if (C < 0) {
    cout << "-1" << endl;
  }

  
  if (C == 0) {
    cout << "YES" << endl;
  }
  
  else {
    cout << "NO" << endl;
  }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:5:3: error: declaration does not declare anything [-fpermissive]
    5 |   int ;
      |   ^~~
a.cc:6:10: error: 'N' was not declared in this scope
    6 |   cin >> N;
      |          ^
a.cc:21:3: error: expected initializer before 'for'
   21 |   for (int i = 0; i < N; i++) {
      |   ^~~
a.cc:21:19: error: 'i' was not declared in this scope
   21 |   for (int i = 0; i < N; i++) {
      |                   ^
a.cc:37:2: error: expected '}' at end of input
   37 | }
      |  ^
a.cc:4:12: note: to match this '{'
    4 | int main() {
      |            ^
Language: C++

#include<iostream>
using namespace std;

int main(void)
{
int n,count=0;
cin>>n;

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

for(int i=0;i<n;i++){
    int j=0;
    if(a[i]<b[i]){
        while(a[j]<=b[j]||j<n){
            j++;
        }
        c[i]-=b[i]-a[i];
        c[j]-=b[i]-a[i];
    }
}
if(a[n-1]>b[n-1]){
    for(int i=0;i<n;i++)[
        if(c[i]!=a[i])count++;
    }cout<<count<<endl;
}cout<<-1<<endl; 

return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:27:9: error: expected identifier before 'if'
   27 |         if(c[i]!=a[i])count++;
      |         ^~
a.cc:27:30: error: expected ']' before ';' token
   27 |         if(c[i]!=a[i])count++;
      |                              ^
      |                              ]
a.cc: In lambda function:
a.cc:27:30: error: expected '{' before ';' token
a.cc: At global scope:
a.cc:29:2: error: 'cout' does not name a type
   29 | }cout<<-1<<endl;
      |  ^~~~
a.cc:31:1: error: expected unqualified-id before 'return'
   31 | return 0;
      | ^~~~~~
a.cc:32:1: error: expected declaration before '}' token
   32 | }
      | ^
Language: C++

#include<iostream>
using namespace std;

int main(void)
{
int n,count=0;
cin>>n;

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

for(int i=0;i<n;i++){
    int j=0
    if(a[i]<b[i]){
        while(a[j]<=b[j]||j<n){
            j++
        }
        c[i]-=b[i]-a[i];
        c[j]-=b[i]-a[i];
    }
}
if(a[n-1]>b[n-1]){
    for(int i=0;i<n;i++)[
        if(c[i]!=a[i])count++;
    }cout<<count<<endl;
}cout<<-1<<endl; 

return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:17:5: error: expected ',' or ';' before 'if'
   17 |     if(a[i]<b[i]){
      |     ^~
a.cc:27:9: error: expected identifier before 'if'
   27 |         if(c[i]!=a[i])count++;
      |         ^~
a.cc:27:30: error: expected ']' before ';' token
   27 |         if(c[i]!=a[i])count++;
      |                              ^
      |                              ]
a.cc: In lambda function:
a.cc:27:30: error: expected '{' before ';' token
a.cc: At global scope:
a.cc:29:2: error: 'cout' does not name a type
   29 | }cout<<-1<<endl;
      |  ^~~~
a.cc:31:1: error: expected unqualified-id before 'return'
   31 | return 0;
      | ^~~~~~
a.cc:32:1: error: expected declaration before '}' token
   32 | }
      | ^
Language: C++

#include <iostream>
#include <vector>
#include <list>
#include <algorithm>
 
int main(int argc, char* argv[])
{
  int N;
  std::cin >> N;
 
  std::vector<int> A, B;
  A.resize(N);
  B.resize(N);
 
  for (auto& a : A) {
    std::cin >> a;
  }
  for (auto& b : B) {
    std::cin >> b;
  }
 
  std::vector<int> ok;
  ok.reserve(N);
  int ng_sum = 0, ng_count;
  for (int i = 0; i < N; ++i) {
    const auto diff = A[i] - B[i];
    if (diff < 0) {
      ng_sum += -diff;
      ++ng_count;
    }
    else if (0 < diff) {
      ok.push_back(diff);
    }
  }
 
  std::sort(ok.begin(), ok.end());
 
  int result = ng_count;
  for (auto it =  ok.rbegin(), it_end = ok.rend(); it != it_end; ++it) {
    if (ng_sum <= 0) break;
    ng_sum -= *it;
    ++result;
  }
 
  if (ng_sum <= 0) std::cout << result;
  else std::cout << -1;
 
  return 0;
}
#include <iostream>
#include <vector>
#include <list>
#include <algorithm>
 
int main(int argc, char* argv[])
{
  int N;
  std::cin >> N;
 
  std::vector<int> A, B;
  A.resize(N);
  B.resize(N);
 
  for (auto& a : A) {
    std::cin >> a;
  }
  for (auto& b : B) {
    std::cin >> b;
  }
 
  std::vector<int> ok;
  ok.reserve(N);
  long long ng_sum = 0;
  int ng_count;
  for (int i = 0; i < N; ++i) {
    const auto diff = A[i] - B[i];
    if (diff < 0) {
      ng_sum += -diff;
      ++ng_count;
    }
    else if (0 < diff) {
      ok.push_back(diff);
    }
  }
 
  std::sort(ok.begin(), ok.end());

  int result = ng_count;
  for (auto it =  ok.rbegin(), it_end = ok.rend(); it != it_end; ++it) {
    if (ng_sum <= 0) break;
    ng_sum -= *it;
    ++result;
  }
 
  if (ng_sum <= 0) std::cout << result;
  else std::cout << -1;
 
  return 0;
}


Compiler output:
a.cc:55:5: error: redefinition of 'int main(int, char**)'
   55 | int main(int argc, char* argv[])
      |     ^~~~
a.cc:6:5: note: 'int main(int, char**)' previously defined here
    6 | int main(int argc, char* argv[])
      |     ^~~~
Language: C++

#include <iostream>
#include <vector>
#include <string>
#define ll long long
using namespace std;

int main(){
//cout<<123<<endl;
  int N;
  int ans =0;
  cin>>N;
  int A[N];// 0 indexed
  int B[N];
  vector <int> D(0);
  vector <int> D1(0);
  vector<int> D2(0);
  ll asum = 0,bsum = 0;
  for(int i=0;i<N;i++) {cin>>A[i];asum+=A[i];}
  for(int i=0;i<N;i++) {cin>>B[i];bsum+=B[i];}
  if(asum<bsum) {cout<<-1<<endl;return 0;}
  for(int i=0;i<N;i++) D.push_back(A[i]-B[i]); //ズレを収納
  sort(D.begin(),D.end());//昇順ソート
  for(int i=0;i<D.size();i++){
    if(D[i]==0) {
    // ans++;
      D.erase(D.begin()+i);
      continue;
    }
    if(D[i]<0) D1.push_back(D[i]);
    else D2.push_back(D[i]);
  }
  
  ll D1sum=0;
  for(int i=0;i<D1.size();i++) D1sum += D1[i];
  ll sumleft= - D1sum;
  int memori;
  while(sumleft > 0){
    memori=D2[D2.size()-1];//現状の最大
    D2.erase(D2.begin()+D2.size()-1);// memoriに入れたら消す
    ans++;
    sumleft = sumleft - memori;
  }
  ans += D1.size();
  cout<<ans<<endl;
  
  
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:22:3: error: 'sort' was not declared in this scope; did you mean 'short'?
   22 |   sort(D.begin(),D.end());//昇順ソート
      |   ^~~~
      |   short
Language: C++

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

typedef long long LL;

LL main() {
    LL N;
    cin >> N;
    vector<LL> A(N);
    vector<LL> B(N);
    for (LL i = 0;i < N;i++)
        cin >> A[i];

    vector<LL> result_neg;
    vector<LL> result_pos;
    LL sum_neg = 0;
    LL sum = 0;
    LL out = 0;
    for (LL i = 0; i< N;i++) {
        cin >> B[i];
        if (A[i] - B[i] < 0){
            result_neg.push_back(abs(A[i] - B[i]));
            sum_neg += abs(A[i] - B[i]);
            out++;
        }
        else if (A[i] - B[i] > 0)
            result_pos.push_back(A[i] - B[i]);
        sum += A[i] - B[i];
    }
    if (abs(sum) < sum_neg)
    {
        cout << -1;
        return 0;
    }
    else if (sum_neg == 0)
    {
        cout << 0;
        return 0;
    }
    else
    {
       sort(result_pos.begin(),result_pos.end());
       for (LL i = result_pos.size() - 1; i >= 0; i--)
       {
           out++;
          if (result_pos[i] - sum_neg < 0)
          {
             sum_neg -= result_pos[i];
          }
          else
              break;
       }
    }
    cout << out;
    return 0;
}


Compiler output:
a.cc:7:1: error: '::main' must return 'int'
    7 | LL main() {
      | ^~
Language: C++

#include <iostream>
#include <vector>
#include <list>
#include <numeric>
 
int main(int argc, char* argv[])
{
  int N;
  std::cin >> N;
 
  std::vector<int> A, B;
  A.resize(N);
  B.resize(N);
 
  for (auto& a : A) {
    std::cin >> a;
  }
  for (auto& b : B) {
    std::cin >> b;
  }
 
  std::list<int> ok;
  ok.reserve(N);
  int ng_sum = 0, ng_count;
  for (int i = 0; i < N; ++i) {
    const auto diff = A[i] - B[i];
    if (diff < 0) {
      ng_sum += -diff;
      ++ng_count;
    }
    else if (0 < diff) {
      ok.insert(std::lower_bound(ok.begin(), ok.end(), diff), diff);
    }
  }
 
  int result = ng_count;
  for (auto it =  ok.rbegin(), it_end = ok.rend(); it != it_end; ++it) {
    if (ng_sum <= 0) break;
    ng_sum -= *it;
    ++result;
  }
 
  if (ng_sum <= 0) std::cout << result;
  else std::cout << -1;
 
  return 0;
}

Compiler output:
a.cc: In function 'int main(int, char**)':
a.cc:23:6: error: 'class std::__cxx11::list<int>' has no member named 'reserve'; did you mean 'reverse'?
   23 |   ok.reserve(N);
      |      ^~~~~~~
      |      reverse
Language: C++

#include <iostream>
#include <vector>
#include <numeric>
using namespace std;

int main(){
  int n;
  vector<long long> a, b;

  cin >> n;
  for (int i = 0; i < n; i++) {
    long long x;
    cin >> x;
    a.push_back(x);
  }
  for (int i = 0; i < n; i++) {
    long long x;
    cin >> x;
    b.push_back(x);
  }

  vector<long long> c;
  for (int i = 0; i < n; i++) {
    c.push_back(a[i] - b[i]);
  }

  sort(c.rbegin(), c.rend());
  long long ans = 0;
  long long sum1 = 0;
  long long sum2 = 0;
  for (int i = 0; i < n; i++) {
    if (c[i] > 0) {
      sum1 += c[i];
    }
    if (c[i] < 0) {
      ans++;
      sum2 += -c[i];
    }
  }
  if (sum1 < sum2) {
    cout << -1 << endl;
    return 0;
  }
  int i = 0;
  while (true) {
    if (sum2 <= 0) {
      break;
    }
    if (c[i] > 0) {
      sum2 -= c[i];
      ans++;
    }
    i++;
  }
  cout << ans << endl;

  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:27:3: error: 'sort' was not declared in this scope; did you mean 'short'?
   27 |   sort(c.rbegin(), c.rend());
      |   ^~~~
      |   short
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define int long long 
#define rep(i,N) for(int (i)=0;(i)<(N);++(i))
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define MP make_pair
#define pb push_back
const int INF = 1e18;
const int MOD = INF+7;
using P = pair<int,int>;

signed main(){
    int N;
    cin >> N;
    vector<int> A(N),B(N);
    int sum_A = 0,sum_B = 0;
    rep(i,N) cin >> A[i],sum_A += A[i];
    rep(i,N) cin >> B[i],sum_B += B[i];

    if(sum_A < sum_B){
        cout << -1 << endl;
        return 0;
    }

    int ans = N;
    sum_B = 0;
    vector<P> mini;
    rep(i,N){
        if(A[i] < B[i]) sum_A -= B[i];
        else mini.push_back({A[i],B[i]),sum_B += B[i];
    }
    sort(all(mini));
    rep(i,mini.size()){
        if(sum_A - mini[i].first - (sum_B-mini[i].second) >= 0) sum_B -= mini[i].second ,sum_A -= mini[i].first,--ans;
        else break;
    }
    cout << ans << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:31:39: error: expected '}' before ')' token
   31 |         else mini.push_back({A[i],B[i]),sum_B += B[i];
      |                             ~         ^
Language: C++

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


int main(){
int n;
int a[100000];
int b[100000];
int i;
int cnt;

cnt = 0;
scanf("%d",&n);

for(i=0;i<n;i++){
 scanf("%d",&a[i]);
}
for(i=0;i<n;i++){
 scanf("%d",&b[i]);
}

qsort((void * )a , i , sizeof( a[0] ));
qsort((void * )b , i , sizeof( b[0] ));
for(i=0;i<n;i++){
if(a[i]>=b[i]){
cnt ++;
}
}
printf("%d\n",cnt);
return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:22:6: error: too few arguments to function 'void qsort(void*, size_t, size_t, __compar_fn_t)'
   22 | qsort((void * )a , i , sizeof( a[0] ));
      | ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/cstdlib:79,
                 from /usr/include/c++/14/stdlib.h:36,
                 from a.cc:2:
/usr/include/stdlib.h:970:13: note: declared here
  970 | extern void qsort (void *__base, size_t __nmemb, size_t __size,
      |             ^~~~~
a.cc:23:6: error: too few arguments to function 'void qsort(void*, size_t, size_t, __compar_fn_t)'
   23 | qsort((void * )b , i , sizeof( b[0] ));
      | ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/stdlib.h:970:13: note: declared here
  970 | extern void qsort (void *__base, size_t __nmemb, size_t __size,
      |             ^~~~~
Language: C++

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

#define int long long

const int N=100005;

int a[N],b[N];
int n;
int pref[N];
vector<int> les,more;
int32_t main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    cin>>n;
    int sum=0;
    for(int i=1;i<=n;i++)
    {
    	cin>>a[i];
    	sum+=a[i];
    }
    for(int i=1;i<=n;i++)
    {
    	cin>>b[i];
    	if(a[i]>b[i])
    		more.push_back(a[i]-b[i]);
    	else if(a[i]<b[i])
    		les.push_back(b[i]-a[i]);

    	pref[i]=pref[i-1]+b[i];
    }
    if(pref[n]>sum)
    {
    	cout<<"-1";
    	return 0;
    }

    sort(les.begin(),les.end());
    sort(more.rbegin(),more.rend());

    int curr=0;
    for(int i=0;i<les.size();i++)
    {
    	if(more[curr]>=les[i])
    		more[curr]-=les[i];
    	else
    	{
    		les[i]-=more[curr];
    		i--;
    		curr++;
    	}
    }
    
    if(more.size() && less.size())
    cout<<les.size()+curr+1<<endl;
    else cout<<0<<endl;
    return 0;
}

Compiler output:
a.cc: In function 'int32_t main()':
a.cc:58:27: error: missing template arguments before '.' token
   58 |     if(more.size() && less.size())
      |                           ^
Language: C++

#include <iostream>
using namespace std;

int main()
{
    int n,ans;
    cin>>n;
    int a[n],b[n],c[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    for(int i=0;i<n;i++){
        cin>>b[i];
    }
    for(int i=0;i<n;i++){
        c[i]=a[i]-b[i];
    }
    long long sum=0;
    for(int i=0;i<n;i++){
        sum+=c[i];
    }
    if(sum<0)ans=-1;
    else{
        sort(c,c+n);
        long long beh=0;
        int count=0;
        for(int i=0;i<n;i++){
            if(c[i]<0){
                beh+=c[i];
                count++;
            }
        }
        for(int i=n-1;i>0;i--){
            if(beh<0){
                beh+=c[i];
                count++;
            }
        }
        ans=count;
    }
    cout<<ans;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:24:9: error: 'sort' was not declared in this scope; did you mean 'short'?
   24 |         sort(c,c+n);
      |         ^~~~
      |         short
Language: C++

#include <stdio.h>
#include <stdlib.h>
int main(){
int n;
int a[100000];
int b[100000];
int i;
int cnt;

cnt = 0;
scanf("%d",&n);

for(i=0;i<n;i++){
 scanf("%d",&a[i]);
}
for(i=0;i<n;i++){
 scanf("%d",&b[i]);
}

qsort((void * )a , i , sizeof( a[0] );
qsort((void * )b , i , sizeof( b[0] );
for(i=0;i<n;i++){
if(a[i]>=b[i]){
cnt ++;
}
}
printf("%d\n",cnt);
return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:20:38: error: expected ')' before ';' token
   20 | qsort((void * )a , i , sizeof( a[0] );
      |      ~                               ^
      |                                      )
a.cc:21:38: error: expected ')' before ';' token
   21 | qsort((void * )b , i , sizeof( b[0] );
      |      ~                               ^
      |                                      )
Language: C++

#include <stdio.h>
#include <stdlib.h>
int main(){
int n;
int a[100000];
int b[100000];
int i;
int cnt;
cnt = 0;
scanf("%d",&n);

for(i=0;i<n;i++){
 scanf("%d",a[i]);
}
for(i=0;i<n;i++){
 scanf("%d",b[i]);
}

qsort((void * )a , i , sizeof( a[0] );
qsort((void * )b , i , sizeof( b[0] );
for(i=0;i<n;i++){
if(a[i]>=b[i]){
cnt ++;
}
}
printf("%d\n",cnt);
return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:19:38: error: expected ')' before ';' token
   19 | qsort((void * )a , i , sizeof( a[0] );
      |      ~                               ^
      |                                      )
a.cc:20:38: error: expected ')' before ';' token
   20 | qsort((void * )b , i , sizeof( b[0] );
      |      ~                               ^
      |                                      )
Language: C++

#include <stdio.h>
#include <stdlib.h>
int main(){
int n;
int c[100000];
int b[100000];
int i;
int cnt;
cnt = 0;
scanf("%d",&n);

for(i=0;i<n;i++){
 scanf("%d",a[i]);
}
for(i=0;i<n;i++){
 scanf("%d",b[i]);
}

qsort((void * )a , i , sizeof( a[0] );
qsort((void * )b , i , sizeof( b[0] );
for(i=0;i<n;i++){
if(a[i]>=b[i]){
cnt ++;
}
}
printf("%d\n",cnt);
return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:13:13: error: 'a' was not declared in this scope
   13 |  scanf("%d",a[i]);
      |             ^
a.cc:19:16: error: 'a' was not declared in this scope
   19 | qsort((void * )a , i , sizeof( a[0] );
      |                ^
a.cc:20:38: error: expected ')' before ';' token
   20 | qsort((void * )b , i , sizeof( b[0] );
      |      ~                               ^
      |                                      )
Language: C++

#include <iostream>
using namespace std;

int main()
{
    int n,ans;
    cin>>n;
    int a[n],b[n],c[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    for(int i=0;i<n;i++){
        cin>>b[i];
    }
    for(int i=0;i<n;i++){
        c[i]=a[i]-b[i];
    }
    long long sum=0;
    for(int i=0;i<n;i++){
        sum+=c[i];
    }
    if(sum<0)ans=-1;
    else{
        sort(c,c+n);
        long long beh;
        int count;
        for(int i=0;i<n;i++){
            if(c[i]<0){
                beh+=c[i];
                count++;
            }
        }
        for(int i=n-1;i>0;i--){
            if(beh<0){
                beh+=c[i];
                count++;
            }
        }
        ans=count;
    }
    cout<<ans;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:24:9: error: 'sort' was not declared in this scope; did you mean 'short'?
   24 |         sort(c,c+n);
      |         ^~~~
      |         short