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

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;
typedef long long ll;
int main() {
int N, M; cin >> N >> M;
  vector<pair<ll, l>> a(N);
  rep(i, N) {
    cin >> a[i].first >> a[i].second;
  }
  sort(a.begin(), a.end());

  ll ans=0;
  rep(i, N) {
    if(a[i].second<=M) {ans+=a[i].first*a[i].second; M = M-a[i].second;}
    else if(M==0) {cout << ans << endl;break;}
    else {ans +=a[i].first*M; cout << ans << endl;break;}
  }
 
  }


Compiler output:
a.cc: In function 'int main()':
a.cc:9:19: error: 'l' was not declared in this scope
    9 |   vector<pair<ll, l>> a(N);
      |                   ^
a.cc:9:19: error: template argument 2 is invalid
a.cc:9:20: error: template argument 1 is invalid
    9 |   vector<pair<ll, l>> a(N);
      |                    ^~
a.cc:9:20: error: template argument 2 is invalid
a.cc:11:13: error: invalid types 'int[int]' for array subscript
   11 |     cin >> a[i].first >> a[i].second;
      |             ^
a.cc:11:27: error: invalid types 'int[int]' for array subscript
   11 |     cin >> a[i].first >> a[i].second;
      |                           ^
a.cc:13:10: error: request for member 'begin' in 'a', which is of non-class type 'int'
   13 |   sort(a.begin(), a.end());
      |          ^~~~~
a.cc:13:21: error: request for member 'end' in 'a', which is of non-class type 'int'
   13 |   sort(a.begin(), a.end());
      |                     ^~~
a.cc:17:9: error: invalid types 'int[int]' for array subscript
   17 |     if(a[i].second<=M) {ans+=a[i].first*a[i].second; M = M-a[i].second;}
      |         ^
a.cc:17:31: error: invalid types 'int[int]' for array subscript
   17 |     if(a[i].second<=M) {ans+=a[i].first*a[i].second; M = M-a[i].second;}
      |                               ^
a.cc:17:42: error: invalid types 'int[int]' for array subscript
   17 |     if(a[i].second<=M) {ans+=a[i].first*a[i].second; M = M-a[i].second;}
      |                                          ^
a.cc:17:61: error: invalid types 'int[int]' for array subscript
   17 |     if(a[i].second<=M) {ans+=a[i].first*a[i].second; M = M-a[i].second;}
      |                                                             ^
a.cc:19:18: error: invalid types 'int[int]' for array subscript
   19 |     else {ans +=a[i].first*M; cout << ans << endl;break;}
      |                  ^
Language: C

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

struct drink {
	long long int b;
	int a;
};

int a(const void *A, const void *B) {
	struct dorinku *x = (struct dorinku *)A;
	struct dorinku *y = (struct dorinku *)B;
	if (x->a > y->a) return 1;
	if (x->a < y->a) return -1;
	return 0;
}

int main() {
	int N, M, i;
	long long int sum = 0;
	struct drink DATA[100000];

	scanf("%d %d", &N, &M);
	for (i = 0; i < N; i++) {
		scanf("%lld %d", &DATA[i].a, &DATA[i].b);
	}

	qsort(DATA, N, sizeof(struct dorinku), a);

	for (i = 0; M > 0; i++) {
		if (M >= DATA[i].b) {
			M = M - DATA[i].b;
			sum = sum + DATA[i].a * DATA[i].b;
		}
		else {
			sum = sum + M * DATA[i].a;
			M = 0;
		}
	}

	printf("%lld", sum);

	return 0;
}


Compiler output:
main.c: In function 'a':
main.c:13:14: error: invalid use of undefined type 'struct dorinku'
   13 |         if (x->a > y->a) return 1;
      |              ^~
main.c:13:21: error: invalid use of undefined type 'struct dorinku'
   13 |         if (x->a > y->a) return 1;
      |                     ^~
main.c:14:14: error: invalid use of undefined type 'struct dorinku'
   14 |         if (x->a < y->a) return -1;
      |              ^~
main.c:14:21: error: invalid use of undefined type 'struct dorinku'
   14 |         if (x->a < y->a) return -1;
      |                     ^~
main.c: In function 'main':
main.c:28:31: error: invalid application of 'sizeof' to incomplete type 'struct dorinku'
   28 |         qsort(DATA, N, sizeof(struct dorinku), a);
      |                               ^~~~~~
Language: C

#include<stdio.h>
#include<string.h>
#include<stdlib.h>
struct drink {
	long long int a;
	int b;
};

int a(const void *c, const void *d) {
	struct drink *x = (struct drink *)c;
	struct drink *y = (struct drink *)d;

	if (x->a > y->a)return 1;
	if (x->a < y->a)return -1;
	return 0;
}

int main() {
	long long int sum = 0;
	int n, m, i;
	struct  drink DATA[100000];

	scanf_s("%d %d", &n, &m);

	for (i = 0; i < n; i++) 
		scanf_s("%lld %d", &DATA[i].a, &DATA[i].b);

	qsort(DATA, n, sizeof(struct drink), a);

	for (i = 0; 0 < m; i++) {
		if (DATA->b <= m) {
			m =m - DATA[i].b;
			sum =sum + DATA[i].a * DATA[i].b;
		}
		else {
			sum =sum + m * DATA[i].a;
			m = 0;
		}
	}

	printf("%lld\n", sum);
	return 0;
}

Compiler output:
main.c: In function 'main':
main.c:23:9: error: implicit declaration of function 'scanf_s'; did you mean 'scanf'? [-Wimplicit-function-declaration]
   23 |         scanf_s("%d %d", &n, &m);
      |         ^~~~~~~
      |         scanf
Language: C++

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i=0; (i)<(n); ++(i))
#define reps(i,s,n) for(int i=(s); (i)<(n); ++(i))
#define maxi(v) distance(v.begin(), max_element(v.begin(), v.end()))
#define mini(v) distance(v.begin(), min_element(v.begin(), v.end()))
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
ll gcd(ll x, ll y){
  if(y==0) return x;
  else return gcd(y, x%y);
  }
int main(){
  int n,m; cin >> n >> m;
  vector<pair<int,int>> p(n); rep(i,n)cin >> p[i].first >> p[i].second;
  sort(p.begin(),p.end());
  int tmp=0,ans=0;
  rep(i,n){
    tmp += p[i].second;
    ans += p[i]first*p[i].second;
    if(tmp>=m){
      ans -= p[i].first*(m-tmp);
    }
  }
  cout << ans;

  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:21:9: error: no match for 'operator+=' (operand types are 'int' and '__gnu_cxx::__alloc_traits<std::allocator<std::pair<int, int> >, std::pair<int, int> >::value_type' {aka 'std::pair<int, int>'})
   21 |     ans += p[i]first*p[i].second;
Language: C++

#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,m;
  cin>>n>>m;
  vector<vector<int>> aa(n,vector<int>(2));
  for(int i=0;i<n;i++){
    for(int j=0;j<2;j++){
      cin>>aa[i][j];
    }
  }
  sort(aa.begin(),aa.end());
  int ans=0;
  int cut=0;
  for(int i=0;i<n;i++){
    for(int j=0;j<aa[i][1];j++){
      cut++;
      ans+=aa[i];
      if(cut==m) break;
    }
    if(cut==m) break;
  }
  cout<<ans<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:18:10: error: no match for 'operator+=' (operand types are 'int' and '__gnu_cxx::__alloc_traits<std::allocator<std::vector<int> >, std::vector<int> >::value_type' {aka 'std::vector<int>'})
   18 |       ans+=aa[i];
Language: C++

#include<bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
#define rep(i, n) for(int i = 0; i < (n); i++)

int int_len(int n) {
  int s=0;
  while(n!=0) s++, n/=10;
  return s;
}

int int_sum(int n) {
  int m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(int i=s-1;i>=0;i--) m+=n/((int)pow(10,i))-(n/((int)pow(10,i+1)))*10;
  return m;
}






int gcd(int a,int b)
{
 
  int r, tmp;
 
  
 
  /* 自然数 a > b を確認・入替 */
  if(a<b){
    tmp = a;
    a = b;
    b = tmp;
  }
 
  /* ユークリッドの互除法 */
  r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
 
 
 
  return b;
}







int fac(int n){
  int m=1;
  while(n>=1) m*=n,n--;
  return m;
}

int vec_sum(vector<int> v){
  int n=0;
  for(int i=0;i<v.size();i++) n+=v[i];
  return n;
}
///////////////////////////
int main() {
  int n,m;
  cin>>n>>m;
  vector<pair<int,int>> v;
  rep(i,n){
    int a,b,ans=0;
    cin>>a>>b;
    v.emplace_back(a,b);
  }
  sort(v.begin(),v.end());
  rep(i,n){
    if(v[i].second<m){
      ans+=v[i].first*v[i].second;
    }else{
      ans+=v[i].first*m;
      break;
    }
  }
  cout<<ans<<endl;
}
///////////////////////////

Compiler output:
a.cc: In function 'int main()':
a.cc:81:7: error: 'ans' was not declared in this scope; did you mean 'abs'?
   81 |       ans+=v[i].first*v[i].second;
      |       ^~~
      |       abs
a.cc:83:7: error: 'ans' was not declared in this scope; did you mean 'abs'?
   83 |       ans+=v[i].first*m;
      |       ^~~
      |       abs
a.cc:87:9: error: 'ans' was not declared in this scope; did you mean 'abs'?
   87 |   cout<<ans<<endl;
      |         ^~~
      |         abs
Language: Java

import java.util.Map;
import java.util.Scanner;
import java.util.TreeMap;

public class MainC {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		int[] A = new int[N];
		int[] B = new int[N];
		Map<Integer, Integer> map = new TreeMap<>();
		for(int i = 0;i < N;i++) {
			A[i] = sc.nextInt();
			B[i] = sc.nextInt();
			map.put(A[i], B[i]);
		}
		sc.close();
		long sumKey = 0;
		long sumValue = 0;
		for(Map.Entry<Integer, Integer> entry : map.entrySet()) {
			for(int i = 0;i < entry.getValue();i++) {
				sumKey += entry.getKey();
				sumValue++;
				if(sumValue == M) {
					System.out.println(sumKey);
					return;
				}
			}
		}
	}
}

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

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

// 比較関数
bool my_compare(pair<int, int> a, pair<int, int> b) {
    // 基本はfirstで比較
    if(a.first != b.first){
        // return a.first < b.first; // 昇順
        return a.first > b.first; // 降順
    }

    // それ以外はsecondで比較
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        // どちらも同じ
        return true;
    }
}

int main(){
  int a,b;
    vector<pair<int, int> > V;
  int n,m;cin>>n;>>m
for(int i=0;i<n;i++){
  cin>>a>>b;
    V.push_back(a,b);
}
    

    sort(V.begin(), V.end());

    for(int i=0; i<V.size(); i++){
        //cout << V[i].first << ' ' << V[i].second << endl;
      cout<<V[i].first<<" "<<V[i].second;
    }
}


Compiler output:
a.cc: In function 'int main()':
a.cc:24:18: error: expected primary-expression before '>>' token
   24 |   int n,m;cin>>n;>>m
      |                  ^~
a.cc:25:13: error: 'i' was not declared in this scope
   25 | for(int i=0;i<n;i++){
      |             ^
Language: C++

#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0;i < (n);i++)
using namespace std;
  
int main () {
  int n, m;
  cin >> n >> m;
  vector<int> a(n), b(n);
  vector<pair<int,int>> ab;
  rep(i,n) {
    cin >> a.at(i) >> b.at(i);
    ab.make_pair(a.at(i),b.at(i));
  }
  sort(ab.begin(),ab.end());
  int64_t ans=0;
  rep(i,n) {
    int p = min(m,ab.at(i).second);
    ans += p * ab.at(i).first;
    m -= p;
  }
  cout << ans;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:12:8: error: 'class std::vector<std::pair<int, int> >' has no member named 'make_pair'
   12 |     ab.make_pair(a.at(i),b.at(i));
      |        ^~~~~~~~~
Language: C++

#include <iostream>
#include <algorithm>

#define Nmax int(1e5 + 1)
using namespace std;

struct can {
    long long quantity,price;
} a[Nmax];

int N,M,i;
long long S,cnt;

inline bool cmp(can a, can b) {
    return ((a.price < b.price) ? true : false);
}

int main() {
    ios_base::sync_with_stdio(0);
    cin >> N >> M;
    for(i = 1; i <= N; ++i)
        cin >> a[i].price>> a[i].quantity;
    sort(a + 1, a + N + 1,cmp);
    for(i = 1; i <= N && M > 0; ++i) {
        cnt = min(M,a[i].quantity);
        S += cnt * a[i].price;
        M -= cnt;
    }
    cout << S;
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:25:18: error: no matching function for call to 'min(int&, long long int&)'
   25 |         cnt = min(M,a[i].quantity);
      |               ~~~^~~~~~~~~~~~~~~~~
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: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:25:18: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   25 |         cnt = min(M,a[i].quantity);
      |               ~~~^~~~~~~~~~~~~~~~~
/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,
                 from a.cc:2:
/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:25:18: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   25 |         cnt = min(M,a[i].quantity);
      |               ~~~^~~~~~~~~~~~~~~~~
Language: Java

import java.util.*;

public class Main{
  static int cost = 0;
  private int a;
  private int b;

  Energy_Drink_Collector(int a, int b){
    this.a = a;
    this.b = b;
  }
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);

    int n = sc.nextInt();
    int m = sc.nextInt();

    Energy_Drink_Collector[] d = new Energy_Drink_Collector[n];

    for(int i=0; i<n; i++){
      d[i] = new Energy_Drink_Collector(sc.nextInt(),sc.nextInt());
    }
    //for(int i=0; i<n; i++){
      //System.out.println(d[i].a+","+d[i].b);
    //}
    Arrays.sort(d,new Comparator<Energy_Drink_Collector>(){
      public int compare(Energy_Drink_Collector o1,Energy_Drink_Collector o2){
        return o1.a - o2.a;
      }
    });
    //for(int i=0; i<n; i++){
      //System.out.println(d[i].a+","+d[i].b);
    //}
    int j = 0;
    while(m>0){
      if(m-d[j].b>=0){
        cost += d[j].a * d[j].b;
        m -=  d[j].b;
      }else if(m-d[j].b<0){
        cost += d[j].a * m;
        m = 0;
      }
      j++;
      //System.out.println("rest ;"+m);
      System.out.println("cost :"+cost);
    }



  }

Compiler output:
Main.java:8: error: invalid method declaration; return type required
  Energy_Drink_Collector(int a, int b){
  ^
Main.java:50: error: reached end of file while parsing
  }
   ^
2 errors
Language: C++

#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)

int main()
{
  ll N, M;
  cin >> N >> M;
  vector<pair<ll, ll> > pairs(N);

  rep(i, N) {
    ll A, B;
    cin >> A >> B;
    pairs[i] = mp(A, B);
  }

  sort(all(pairs));

  ll ans = 0;

  rep(i, N) {
    if (M == 0) break;
    ll minv = min(M, pairs[i].S);
    ans += pairs[i].F * minv;
    M -= minv;
  }

  cout << ans << endl;
}


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

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

long long ans=0,A[MAX];
int N,M,B[MAX],C[MAX]={0};

int main(){
	cin >> N >> M;
	for(int i=0;i<N;i++){
      scanf("%d %d",&A[i],&B[i]);

int min,keep,m=M;

do{
min = MAX;
for(int i=0;i<N;i++){
	if(min > A[i] && C[i] == 0){
	min = A[i];
	keep = i;
}
}

C[keep] = 1;

if(m - B[keep] >= 0) {
	m -= B[keep];
	ans += A[keep] * B[keep];
}
else{
	ans += A[keep]*m;
	m = 0;
}
}while(m > 0);

cout << ans << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:37:2: error: expected '}' at end of input
   37 | }
      |  ^
a.cc:8:11: note: to match this '{'
    8 | int main(){
      |           ^
Language: C++

#include<iostream>
#include<vector>
using namespace std;
int main(){
    long long N, M;
    cin >> N >> M;
    pair<long long, long long> store[100010];
    int a[100010], b[100010];
    for(long long i = 1;i <= N;i++){
        cin >> a[i] >> b[i];
        store[i] = make_pair(a[i], b[i]);
    }
    sort(store+1, store+N+1);
    
    long long ans = 0;
    for(long long i = 1;i <= N;i++){
        if(M - store[i].second > 0){
            ans += store[i].first * store[i].second;
            M -= store[i].second;
        }
        else {
            ans += store[i].first * M;
            break;
        }
    }
    cout << ans;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:13:5: error: 'sort' was not declared in this scope; did you mean 'short'?
   13 |     sort(store+1, store+N+1);
      |     ^~~~
      |     short
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 m = sc.nextInt();
      long sum = 0;
      int num = 0;
      Map<Integer,Integer> map = new HashMap<Integer,Integer>();
      ArrayList<Integer> list = new ArrayList<Integer>();
      for(int i = 0;i < n;i++){
        int a = sc.nextInt();
        int b = sc.nextInt();
        if(map.containsKey(a)){
          map.put(a,map.get(a)+b);
        }else{map.put(a,b);
        list.add(a);
        }
      }
      Collections.sort(list);
      for(int i = 0;i < list.size();i++){
      	int p = list.get(i);
        num += map.get(p);
        if(num < m)sum += (long)p*map.get(p);
        else {
          sum += (long)p*(map.get(p)-num+m));
          break;
        }
      }
      System.out.println(sum);
    }
}


Compiler output:
Main.java:26: error: ';' expected
          sum += (long)p*(map.get(p)-num+m));
                                           ^
1 error
Language: C++

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

int main(){
    int N,M;
    cin >> N >> M;
    vector<int> A(N), B(N);
    for(int i = 0; i < N; i++){
        cin >> A[i] >> B[i];
    }

    vector<pair<int, int>> AB(N);
    for(int i = 0; i < N; i++){
        AB[i] = make_pair(A[i],B[i]);
    }
    sort(AB.begin(), AB.end(),greater<int,int>());

    long long ans = 0;
    int count = 0;
    int i = 0;
    while(count < M){
        count += B[i];
        i++;
    }  
    count = 0;
    for(int j = 0; j < i; j++){
        ans += A[j] * B[j];
    }
    count -= B[i];
    ans += A[i] * (M-count);
    cout << ans << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:19:46: error: wrong number of template arguments (2, should be at least 0)
   19 |     sort(AB.begin(), AB.end(),greater<int,int>());
      |                                              ^
In file included from /usr/include/c++/14/string:49,
                 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_function.h:353:12: note: provided for 'template<class _Tp> struct std::greater'
  353 |     struct greater;
      |            ^~~~~~~
Language: C++

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

int main(){
    int N,M;
    cin >> N >> M;
    vector<int> A(N), B(N);
    for(int i = 0; i < N; i++){
        cin >> A[i] >> B[i];
    }

    vector<pair<int, int>> AB(N);
    for(int i = 0; i < N; i++){
        AB[i] = make_pair(A[i],B[i]);
    }
    sort(AB.begin(), AB.end());

    long long ans = 0;
    int count = 0;
    int i = 0;
    while(count < M){
        count += B[i];
        i++;
    }  
    count = 0;
    for(int j = 0; j < i; j++){
        ans += A[j] * B[j];
    }
    count -= B[i];
    ans += A[j+1] * (M-count);
    cout << ans << endl;



}

Compiler output:
a.cc: In function 'int main()':
a.cc:33:14: error: 'j' was not declared in this scope
   33 |     ans += A[j+1] * (M-count);
      |              ^
Language: C++

#include <iostream>
#include <vector>

using namespace std;

typedef long long ll;

ll n, m;
pair<int, int> ab[500000];
ll ans = 0;

int main()
{
    cin >> n >> m;
    for (int i = 0; i < n; i++)
    {
        cin >> ab[i].first >> ab[i].second;
    }
    sort(ab, ab + n);
    for (int i = 0; i < n; i++)
    {
        while (m > 0)
        {
            ans += ab[i].first;
            ab[i].second--;
            if (ab[i].second == 0)
                break;
            m--;
        }
    }
    cout << ans;
}

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

typedef long long ll;
#define mod 1000000007
 
int gcd(int a, int b) { return b ? gcd(b, a%b) : a; }
 
int lcm(int a, int b) { return a * b / gcd(a, b); }
 
int main(){
    ll n, m;
    cin >> n >> m;
    vector <pair <ll, ll>> p(n);
    for(ll i = 0; i < n; i++){
        ll a, b;
        cin >> a >> b;
        p[i] = make_pair(a, b);
    }

    sort(p.begin(), p.end());

    ll ans = 0;
    for(ll i = 0; i < n; i++){
        if(m <= 0){
            cout << ans << endl;
            return 0;
        }else if(p[i].second < m){
            ans += p[i].first * p[i].second;
            m -= p[i].second;
        }else if(p[i].second >= m){
            ans += m * p[i].first;
            m = 0;
        }
    }

    cout << ans << endl;

    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:10:5: error: 'cin' was not declared in this scope
   10 |     cin >> n >> m;
      |     ^~~
a.cc:11:5: error: 'vector' was not declared in this scope
   11 |     vector <pair <ll, ll>> p(n);
      |     ^~~~~~
a.cc:11:13: error: 'pair' was not declared in this scope
   11 |     vector <pair <ll, ll>> p(n);
      |             ^~~~
a.cc:11:21: error: expected primary-expression before ',' token
   11 |     vector <pair <ll, ll>> p(n);
      |                     ^
a.cc:11:25: error: expected primary-expression before '>>' token
   11 |     vector <pair <ll, ll>> p(n);
      |                         ^~
a.cc:11:28: error: 'p' was not declared in this scope
   11 |     vector <pair <ll, ll>> p(n);
      |                            ^
a.cc:15:16: error: 'make_pair' was not declared in this scope
   15 |         p[i] = make_pair(a, b);
      |                ^~~~~~~~~
a.cc:18:5: error: 'sort' was not declared in this scope; did you mean 'short'?
   18 |     sort(p.begin(), p.end());
      |     ^~~~
      |     short
a.cc:23:13: error: 'cout' was not declared in this scope
   23 |             cout << ans << endl;
      |             ^~~~
a.cc:23:28: error: 'endl' was not declared in this scope
   23 |             cout << ans << endl;
      |                            ^~~~
a.cc:34:5: error: 'cout' was not declared in this scope
   34 |     cout << ans << endl;
      |     ^~~~
a.cc:34:20: error: 'endl' was not declared in this scope
   34 |     cout << ans << endl;
      |                    ^~~~
Language: C++

import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		long n=sc.nextLong();
		long m= sc.nextLong();
		long count=0;
		long price=0;
		Map<Long,Long> map = new HashMap<>();
		for(int i=0;i<n;i++) {
				long key= sc.nextLong();
				long value = sc.nextLong();
				if(map.containsKey(key)) {
			map.put(key,map.get(key)+value);
				}else {
					map.put(key,value);
				}
		}
		Object[] mapkey = map.keySet().toArray();
		Arrays.sort(mapkey);
		for( long nkey: map.keySet()) {
			long tempCount=map.get(nkey);
			for(int i=1;i<=tempCount;i++) {
				price+=nkey;
				count+=1;
				if(count>=m) {System.out.println(price); return;}
			}


		}
    }

}


Compiler output:
a.cc:1:1: error: 'import' does not name a type
    1 | import java.util.Arrays;
      | ^~~~~~
a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:2:1: error: 'import' does not name a type
    2 | import java.util.HashMap;
      | ^~~~~~
a.cc:2:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:3:1: error: 'import' does not name a type
    3 | import java.util.Map;
      | ^~~~~~
a.cc:3:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:4:1: error: 'import' does not name a type
    4 | import java.util.Scanner;
      | ^~~~~~
a.cc:4:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:6:1: error: expected unqualified-id before 'public'
    6 | public class Main {
      | ^~~~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
struct A{
ll a,b;
};
bool cmp(A x,A y)
{
    return x.a<y.a;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n,m;
    while(cin>>n>>m)
    {
        vector<A> arr;
        for(int i=0;i<n;i++)
        {
            A a;
            cin>>a.a>>a.b;
        }
        sort(arr.begin(),arr.end(),cmp);
        ll ans=0;
        for(int i=0;i<n;i++)
        {
            if(k<=0) break;
            if(k<=arr[i].b)
            {
                k-= arr[i].b;
                ans += (arr[i].b*arr[i].a);
            }
            else
            {
                ans += (k*arr[i].a);
                k=0;
            }
        }
        cout<<ans<<endl;
    }
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:29:16: error: 'k' was not declared in this scope
   29 |             if(k<=0) break;
      |                ^
a.cc:30:16: error: 'k' was not declared in this scope
   30 |             if(k<=arr[i].b)
      |                ^
Language: C++

#include <iostream>
#include <string>
#include <vector>
#include <cassert>
#include <algorithm>
#include <functional>
#include <cmath>
#include <utility>
using namespace std;

int main() {
    long long N, M; cin >> N >> M;
	vector<pair<long long, long long>> vec(Q);
	for (long long i = 0; i < N; i++){
		long long A, B; cin >> A >> B;
		vec[i].first = A;
		vec[i].second = B;
	}

	sort(vec.begin(), vec.end());

	long long res = 0;
	long long place = 0;

	while(M > 0){
		res += vec[place].first * min(M, vec[place].second);
		M -= min(M, vec[place].second);
	}

	cout << res << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:13:48: error: 'Q' was not declared in this scope
   13 |         vector<pair<long long, long long>> vec(Q);
      |                                                ^
Language: C++

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

int main(){
	long long N, M;
	cin >> N >> M;
	vector<pair<long long, long long>> A(N);
	for(long long i = 0; i < N; i++){
		cin >> A.at(i).first >> A.at(i).second;
	}
	
	sort(A.begin(), B.end());
	
	long long price = 0;//かかった金額
	long long Juice = 0;//買った本数
	
	for(long long i = 0; i < N; i++){
		if(Juice + A.at(i).second < M){
			Juice += A.at(i).second;
			price += A.at(i).first * A.at(i).second;
		} else {
			while(Juice <= M){
				price += A.at(i).first;
				Juice++;
			}
		}
	}
	
	cout << price << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:12:25: error: 'B' was not declared in this scope
   12 |         sort(A.begin(), B.end());
      |                         ^
Language: C++

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

int main(){
	long long N, M;
	cin >> N >> M;
	vector<pair<long long, long long> JP(N);
	for(long long i = 0; i < N; i++){
		cin >> JP.at(i).second >> JP.at(i).first;
	}
	
	long long price = 0;
	long long Juice = 0;
	sort(JP.begin(), JP.end());
	for(int i = 0; i < N; i++){
		if(Juice + JP.at(i).first < M){
			price += JP.at(i).first * JP.at(i).second;
			Juice += JP.at(i).first;
		} else {
			while(Juice <= M){
				price +- JP.at(i).second;
				Juice++;
			}
		}
	}
	cout << price << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:7:47: error: template argument 1 is invalid
    7 |         vector<pair<long long, long long> JP(N);
      |                                               ^
a.cc:7:47: error: template argument 2 is invalid
a.cc:9:24: error: 'JP' was not declared in this scope
    9 |                 cin >> JP.at(i).second >> JP.at(i).first;
      |                        ^~
a.cc:14:14: error: 'JP' was not declared in this scope
   14 |         sort(JP.begin(), JP.end());
      |              ^~
Language: Java

import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner scn = new Scanner(System.in);
    int N = scn.nextInt();
    int M = scn.nextInt();

    ArrayList<Data> data = new ArrayList<>();
    for (int i = 0; i < N; i++) {
      int A = scn.nextInt();
      int B = scn.nextInt();
      data.add(new Data(A, B));
    }

    Collections.sort(data, new DataComparator());

    int expense = 0;
    int drinkCount = 0;
    for (Data d : data) {
    drinkCount += d.stock;
    expense += d.stock * d.price;

    if (drinkCount >= M) {
        int excess = drinkCount - M;
        expense -= excess * d.price;
        break;
      }
    }

    System.out.println(expense);
  }

  public static class Data {
    private int price;
    private int stock;

    Data(int a, long b) {
      this.price = a;
      this.stock = b;
    }

    @Override
    public String toString() {
      return String.valueOf(this.price) + ":" + String.valueOf(this.stock);
    }
  }

  public static class DataComparator implements Comparator<Data> {
    @Override
    public int compare(Data d1, Data d2) {
      return d1.price < d2.price ? -1 : 1;
    }
  }

}


Compiler output:
Main.java:40: error: incompatible types: possible lossy conversion from long to int
      this.stock = b;
                   ^
1 error
Language: Java


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.Map;
import java.util.Queue;
import java.util.Set;
import java.util.StringTokenizer;

public class Main {
	// AtCoder Beginner Contest 121
	// https://atcoder.jp/contests/abc121/tasks
	public static void main(String[] args) {
      c();
	}
	
	private void a() {
		FastReader sc = new FastReader();
		int H = sc.nextInt();
		int W = sc.nextInt();
		int h = sc.nextInt();
		int w = sc.nextInt();
		
		System.out.println((H-h)*(W-w));
	}
	
	private void b() {
		FastReader sc = new FastReader();
		int n = sc.nextInt();
		int m = sc.nextInt();
		int c = sc.nextInt();
		int[] b = new int[m];
		int res = 0;
		
		for (int i = 0; i < m; i++) {
			b[i] = sc.nextInt();
		}
		
		for (int i = 0; i < n; i++) {
			int total = 0;
			int[] k = new int[m];
			for (int j = 0; j < m; j++) {
				k[j] = sc.nextInt();
			}
			
			for (int l = 0; l < m; l++) {
				total += (k[l] * b[l]);
			}
			if (total + c > 0) { 
				res++;
			}
		}
		
		System.out.println(res);
	}
	
	private void c() {
		FastReader sc = new FastReader();
		int n = sc.nextInt();
		int m = sc.nextInt();
		long res = 0;
		int[][] stores = new int[n][2];
		
		for (int i = 0; i < n; i++) {
			stores[i][0] = sc.nextInt();
			stores[i][1] = sc.nextInt();
		}
		
		Arrays.sort(stores, (a , b) -> (a[0] - b[0]));
		
		for (int i = 0; i < n; i++) {
			long buy = Math.min(m, stores[i][1]);
			res += (long)(buy * stores[i][0]);
			m -= (int)buy;
			if (m == 0) { break; }
		}
		System.out.println(res);
	}
	
	static class FastReader { 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastReader() { 
            br = new BufferedReader(new InputStreamReader(System.in)); 
        } 
  
        String next() { 
            while (st == null || !st.hasMoreElements()) { 
                try { 
                    st = new StringTokenizer(br.readLine()); 
                } catch (IOException  e) { 
                    e.printStackTrace(); 
                } 
            } 
            return st.nextToken(); 
        } 
  
        int nextInt() { 
            return Integer.parseInt(next()); 
        } 
  
        long nextLong() { 
            return Long.parseLong(next()); 
        } 
  
        double nextDouble() { 
            return Double.parseDouble(next()); 
        } 
  
        String nextLine() { 
            String str = ""; 
            try{ 
                str = br.readLine(); 
            } catch (IOException e) { 
                e.printStackTrace(); 
            } 
            return str; 
        } 
    } 
}


Compiler output:
Main.java:18: error: non-static method c() cannot be referenced from a static context
      c();
      ^
1 error
Language: Java


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {
	// AtCoder Beginner Contest 121
	// https://atcoder.jp/contests/abc121/tasks
	public static void main(String[] args) {
		FastReader sc = new FastReader();
		int n = sc.nextInt();
		int m = sc.nextInt();
		long res = 0;
		int[][] stores = new int[n][2];
		
		for (int i = 0; i < n; i++) {
			stores[i][0] = sc.nextInt();
			stores[i][1] = sc.nextInt();
		}
		
		Arrays.sort(stores, (a , b) -> (a[0] - b[0]));
		
		for (int i = 0; i < n; i++) {
			long buy = Math.min(m, stores[i][1]);
			res += (long)(buy * stores[i][0]);
			m -= (int)buy;
			if (m == 0) { break; }
		}
		System.out.println(res);
	}
	
	// A smarted method of task 3
	private void c2() {
		FastReader sc = new FastReader();
		String s = sc.next();
		LinkedList<Integer> stack = new LinkedList<>();
		int res = 0;
		int cnt0 = 0;
		int cnt1 = 0;
		
		for (char c: s.toCharArray()) {
			int code = c - '0';
			if (code == 0) {
				cnt0++;
			} else {
				cnt1++;
			}
		}
		
		System.out.println(2*Math.min(cnt0, cnt1));
	}
	
	static class FastReader { 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastReader() { 
            br = new BufferedReader(new InputStreamReader(System.in)); 
        } 
  
        String next() { 
            while (st == null || !st.hasMoreElements()) { 
                try { 
                    st = new StringTokenizer(br.readLine()); 
                } catch (IOException  e) { 
                    e.printStackTrace(); 
                } 
            } 
            return st.nextToken(); 
        } 
  
        int nextInt() { 
            return Integer.parseInt(next()); 
        } 
  
        long nextLong() { 
            return Long.parseLong(next()); 
        } 
  
        double nextDouble() { 
            return Double.parseDouble(next()); 
        } 
  
        String nextLine() { 
            String str = ""; 
            try{ 
                str = br.readLine(); 
            } catch (IOException e) { 
                e.printStackTrace(); 
            } 
            return str; 
        } 
    } 
}


Compiler output:
Main.java:38: error: cannot find symbol
		LinkedList<Integer> stack = new LinkedList<>();
		^
  symbol:   class LinkedList
  location: class Main
Main.java:38: error: cannot find symbol
		LinkedList<Integer> stack = new LinkedList<>();
		                                ^
  symbol:   class LinkedList
  location: class Main
2 errors
Language: C++

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

int main(void){
  int N, M;
  cin >> N >> M;
  priority_queue<pair<ll, int>> que;
  for(int i=0; i<N; i++){
    ll tmpA; int tmpB;
    cin >> tmpA >> tmpB;
    que.push(make_pair(tmpA, tmpB));
  }
  ll ans = 0;
  int m = M;
  while(1){
    auto tmp = que.top(); que.pop();
    int pc = min(tmp.second, m);
    ans += pc*tmp.first;
    m -= pc;
    if(m == 0) break;
  }
  cout << ans << endl;
  return 0;
}

Compiler output:
a.cc:3:9: error: 'll' does not name a type
    3 | typedef ll long long;
      |         ^~
a.cc: In function 'int main()':
a.cc:8:23: error: 'll' was not declared in this scope
    8 |   priority_queue<pair<ll, int>> que;
      |                       ^~
a.cc:8:27: error: template argument 1 is invalid
    8 |   priority_queue<pair<ll, int>> que;
      |                           ^~~
a.cc:8:30: error: template argument 1 is invalid
    8 |   priority_queue<pair<ll, int>> que;
      |                              ^~
a.cc:8:30: error: template argument 2 is invalid
a.cc:8:30: error: template argument 3 is invalid
a.cc:10:7: error: expected ';' before 'tmpA'
   10 |     ll tmpA; int tmpB;
      |       ^~~~~
      |       ;
a.cc:11:12: error: 'tmpA' was not declared in this scope; did you mean 'tmpB'?
   11 |     cin >> tmpA >> tmpB;
      |            ^~~~
      |            tmpB
a.cc:12:9: error: request for member 'push' in 'que', which is of non-class type 'int'
   12 |     que.push(make_pair(tmpA, tmpB));
      |         ^~~~
a.cc:14:5: error: expected ';' before 'ans'
   14 |   ll ans = 0;
      |     ^~~~
      |     ;
a.cc:17:20: error: request for member 'top' in 'que', which is of non-class type 'int'
   17 |     auto tmp = que.top(); que.pop();
      |                    ^~~
a.cc:17:31: error: request for member 'pop' in 'que', which is of non-class type 'int'
   17 |     auto tmp = que.top(); que.pop();
      |                               ^~~
a.cc:19:5: error: 'ans' was not declared in this scope; did you mean 'abs'?
   19 |     ans += pc*tmp.first;
      |     ^~~
      |     abs
a.cc:23:11: error: 'ans' was not declared in this scope; did you mean 'abs'?
   23 |   cout << ans << endl;
      |           ^~~
      |           abs
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define int long long
 int $(int a,int b) {
   if(a%b==0)
     return a/b;
   else
     return a/b+1;
 }
 
signed main(){
  int a,b,d=0;
  cin>>a>>b;
  vector<pair<int,int>> c(a);
  for(int i=0;i<a;i++)
    cin>>c.at(i).first>>c.at(i).second;
  sort(c.begin(),c.end());
  for(int i=0;b>0;i++){
    if(b>=c.at(i).second){
      b-=c.at(i).second;
      d+=c.at(i).second*c.at(i).first;
    }
  else{
    d+=b*c.at(i).first
  }
}
cout<<d<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:24:23: error: expected ';' before '}' token
   24 |     d+=b*c.at(i).first
      |                       ^
      |                       ;
   25 |   }
      |   ~
Language: C++

#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int N,M;
    cin >> N >> M;
 
    vector<vector<int64_t>> drink(N,vector<64_t>(2));
    for ( int i = 0 ; i < N ; i++ ){
        cin >> drink.at(i).at(0) >> drink.at(i).at(1);
    }
 
    sort(drink.begin(),drink.end());
 
    int64_t remain = M;
    int64_t i = 0 ;
    int64_t sum = 0 ;
    while( remain > 0 ){
        if (remain <= drink.at(i).at(1) ){
            sum += remain * drink.at(i).at(0);
            break;
        }
        else{
            sum += drink.at(i).at(0) * drink.at(i).at(1);
            remain -= drink.at(i).at(1);
          	i++;
        }
    }
    cout << sum << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:8:44: error: unable to find numeric literal operator 'operator""_t'
    8 |     vector<vector<int64_t>> drink(N,vector<64_t>(2));
      |                                            ^~~~
a.cc:8:48: error: template argument 1 is invalid
    8 |     vector<vector<int64_t>> drink(N,vector<64_t>(2));
      |                                                ^
a.cc:8:48: error: template argument 2 is invalid
Language: C

#include<stdio.h>
#include<math.h>

#include <stdlib.h>

int compare_int(const void *a, const void *b)
{
    return *(int*)a - *(int*)b;
}


int main(void)
{
  int i,t;
  long long x,y,z=0,k=0;
  long long a[2][100000],b[100000];
  
  scanf("%llf %llf",&x,&y);
  
  for(i=0;i<x;i++)
  {
    scanf("%llf %llf",&a[0][i],&b[i]);
    a[1][i]=i;
  }
 
  qsort(a[0], x, sizeof(long long), compare_int);
  
for(t=0;t<x;t++)
{
  p=0;
    i=a[1][t];
  while(z<y&&p<i)
  {
    k=k+a[0][t];
    p++;
    z++;
  }
 
  if(z<y)
  {
    break;
  }
}
  
  printf("%llf",k);
  
  return 0;
  
}
  

Compiler output:
main.c: In function 'main':
main.c:30:3: error: 'p' undeclared (first use in this function)
   30 |   p=0;
      |   ^
main.c:30:3: note: each undeclared identifier is reported only once for each function it appears in
Language: C++

#include <cstdio>

struct Store
{
public:
    int cost;
    int zaiko;
    Store* left;
    Store* right;

    Store(int cost, int zaiko)
    {
        this->cost = cost; this->zaiko = zaiko;
        this->left = nullptr; this->right = nullptr;
    }
};

Store* root = nullptr;
Store* min_cost = nullptr;
auto need = 0;
auto all_cost = 0LL;

void insert(Store* newnode, Store*& current)
{
    if (current == nullptr)
    {
        current = newnode;
    } else {
        if (newnode->cost < current->cost)
        {
            insert(newnode, current->left);
        } else {
            insert(newnode, current->right);
        }
    }
}

void inorder_purchase(Store*& visit_node)
{
    if (visit_node->left != nullptr && need > 0)
    {
        inorder_purchase(visit_node->left);
    }

    if (visit_node->zaiko >= need)
    {
        all_cost += visit_node->cost * need;
        need = 0;
        return;
    } else {
        all_cost += visit_node->zaiko * visit_node->cost;
        need -= visit_node->zaiko;
    }

    if (visit_node->right != nullptr && need > 0)
    {
        inorder_purchase(visit_node->right);
    }
}

int main()
{
    auto N = 0, cost = 0, zaiko = 0;
    scanf("%d %d", &N, &need);
    for (auto i = 0; i < N; i++)
    {
        scanf("%d %d", &cost, &zaiko);
        Store* newnode = &Store(cost, zaiko);
        insert(newnode, root);
    }

    inorder_purchase(root);
    printf("%d\n", all_cost);

    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:68:27: error: taking address of rvalue [-fpermissive]
   68 |         Store* newnode = &Store(cost, zaiko);
      |                           ^~~~~~~~~~~~~~~~~~
Language: C++

#include <bits/stdc++.h>

using namespace std;

int main() {

	int n,m;
	cin >> n >> m ;

	vector<pair<long long, long long>> p(n);

	for (int i = 0; i < n; i++) {
		cin >> p[i].first >> p[i].second;
	}
  sort(p.begin(),p.end());
  int sum=0;
  long long price=0;
  
  for(int i=0;i<N;i++){
    price += p[i].first*p[i].second;
    sum += p[i].second;
    if(sum >= M) {
      price -= (sum-M)*p[i].first;
      break;
    }
  }
  
  cout << price << endl;
}
    


Compiler output:
a.cc: In function 'int main()':
a.cc:19:17: error: 'N' was not declared in this scope
   19 |   for(int i=0;i<N;i++){
      |                 ^
a.cc:22:15: error: 'M' was not declared in this scope
   22 |     if(sum >= M) {
      |               ^
Language: C++

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

int main(){
  int n, m;
  cin >> n>> m;
  vector<pair<int, int>>q(n);
  for(int i=0; i<n; ++i){
    cin >> q[i].first >> q[i].second;
  }
  sort(q.begin(), q.end());
  int res=0;
  for(int i=0; i<n; ++i){
    if(m-q[i].second>0){
      m -= q[i].second;
      res += q[i].first * q[i].second;}
    else if(m-q[i].second<0){
      res += q[i].first * m;
      break;
  }
   cout << res <<endl;
}

Compiler output:
a.cc:1:9: fatal error: bits/stdic++.h: No such file or directory
    1 | #include<bits/stdic++.h>
      |         ^~~~~~~~~~~~~~~~
compilation terminated.
Language: Java

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        long N = scanner.nextLong(), M = scanner.nextLong();
        Map<Long, Long> drinks = new TreeMap<>();
        for(int i = 0; i < N; i++){
            Long key = scanner.nextLong();
            Long value = scanner.nextLong();
            drinks.computeIfPresent(key,(k, v) -> v + value);
            drinks.computeIfAbsent(key,(k) -> value);
        }
        drinks.entrySet().stream().sorted((m1, m2) -> {
            return m1.getKey().compareTo(m2.getKey());
        });
        long ans = 0;
        for(Long k : drinks.keySet()){
            long buy = Long.min(drinks.get(k), M);
            ans += (buy * k);
            M -= buy;
            if(M == 0)
                break;
        }
        System.out.println(ans);
    }
}

Compiler output:
Main.java:4: error: cannot find symbol
        Scanner scanner = new Scanner(System.in);
        ^
  symbol:   class Scanner
  location: class Main
Main.java:4: error: cannot find symbol
        Scanner scanner = new Scanner(System.in);
                              ^
  symbol:   class Scanner
  location: class Main
Main.java:6: error: cannot find symbol
        Map<Long, Long> drinks = new TreeMap<>();
        ^
  symbol:   class Map
  location: class Main
Main.java:6: error: cannot find symbol
        Map<Long, Long> drinks = new TreeMap<>();
                                     ^
  symbol:   class TreeMap
  location: class Main
4 errors
Language: Java

import java.util.*;

public class NMain{
    public static void main(String[]args){
        Scanner sc =  new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        int[][] val = new int[N][2];
        for(int i = 0; i < N; i++){
            String[] T = sc.nextLine().split(" ");
            int a = Integer.parseInt(T[0]);
            int b = Integer.parseInt(T[1]);
            val[i][0] = a;
            val[i][1] = b;
        }
        Arrays.sort(val, (a, b) -> Integer.compare(a[0], b[0]));
        long ans = 0;
        for(int i = 0; M > 0; i++){
            long a = val[i][0];
            long b = val[i][1];
            if(val[i][1] < M){
                ans += a * b;
                M -= b;
            }else{
                ans += a * M;
                M = 0;
            }
        }
        System.out.println(ans);
    }
}

Compiler output:
Main.java:3: error: class NMain is public, should be declared in a file named NMain.java
public class NMain{
       ^
1 error
Language: Java

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt(), M = scanner.nextInt();
        Map<Integer, Long> drinks = new HashMap<>();
        for(int i = 0; i < N; i++){
            Integer key = scanner.nextInt();
            Long value = scanner.nextLong();
            drinks.computeIfPresent(key,(k, v) -> v + value);
            drinks.computeIfAbsent(key,(k) -> value);
        }
        drinks.entrySet().stream().sorted((m1, m2) -> {
            return m1.getValue().compareTo(m2.getValue());
        });
        long ans = 0;

        for(int k : drinks.keySet()){
            long buy = Long.min(drinks.get(k), (long)M);

            ans +=(long) buy * drinks.get(k);
            M -= buy;
        }
        System.out.println(ans);
    }
}

Compiler output:
Main.java:4: error: cannot find symbol
        Scanner scanner = new Scanner(System.in);
        ^
  symbol:   class Scanner
  location: class Main
Main.java:4: error: cannot find symbol
        Scanner scanner = new Scanner(System.in);
                              ^
  symbol:   class Scanner
  location: class Main
Main.java:6: error: cannot find symbol
        Map<Integer, Long> drinks = new HashMap<>();
        ^
  symbol:   class Map
  location: class Main
Main.java:6: error: cannot find symbol
        Map<Integer, Long> drinks = new HashMap<>();
                                        ^
  symbol:   class HashMap
  location: class Main
4 errors