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

#include<bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
#include <functional>
#include <queue>
#include <map>
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
const int INF = 100000000;

int main(){
    int n, m;
    cin >> n >> m;
    vector<pair<ll, ll>> ab(n);
    REP(i, n){
        cin >> ab[i].first >> ab[i].second; 
    }
    sort(ab.begin(), ab.end());
    int k;
    ll count = 0;
    REP(i, n){
        count += ab[i].second;
        if(i == n-1){
            k = i;
            break;
        }
        if(count + ab[i+1].second > m){
            k = i;
            break;
        }
    }
    ll tmp = 0;
    REP(i, k+1){
        tmp += ab[i].first*ab[i].second;
    }
    
    if(k == n-1){
        if(count >= m){
            cout << tmp <, endl;
        }
    }else{
        cout << tmp + ab[k+1].first*(m-count) << endl;
    }
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:43:26: error: expected primary-expression before ',' token
   43 |             cout << tmp <, endl;
      |                          ^
Language: Java

n,k=map(int,input().split())
a=[]


for i in range(n):
    s,p=map(int,input().split())
    a+=[[s, p] ]
    

import operator as op
a.sort(key = op.itemgetter(0))

ans=0
get=0
look=0
while get<k:
    get=get+1
    a[look][1]=a[look][1]-1
    ans=ans+a[look][0]
    if a[look][1]==0:
        look=look+1

print(ans)

Compiler output:
Main.java:1: error: class, interface, enum, or record expected
n,k=map(int,input().split())
^
1 error
Language: C++

#include <bits/stdc++.h>
using namespace std;
 
#define int long long
typedef pair <int, int> pii;
 
const int N = 1e5 + 10;
int n, m, ans;
pii ar[N];

int32_t main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n >> m;
	for (int i = 0; i < n; i++)
		cin >> ar[i].first >> ar[i].second;
	sort(ar, ar + n, [&] (pii p1, pii p2) { return p1.second * p2.first < p1.first * p2.second; });
	
	int r = 0;
	while (r < n && m) {
		int tmp = min(m, ar[r].first);
		m -= tmp;
		ans += tmp * ar[i].second;
		r++;
	}
	cout << ans << endl;
}

Compiler output:
a.cc: In function 'int32_t main()':
a.cc:24:33: error: 'i' was not declared in this scope
   24 |                 ans += tmp * ar[i].second;
      |                                 ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
 
#define int long long
typedef pair <int, int> pii;
 
const int N = 1e5 + 10;
int n, m, ans;
pii ar[N];

int32_t main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n >> m;
	for (int i = 0; i < n; i++)
		cin >> ar[i].first >> ar[i].second;
	sort(ar, ar + n, [&] (pii p1, pii p2) { return p1.second * p2.first < p1.first * p2.second; });
	
	int r = 0;
	while (r < n && m) {
		int tmp = min(m, ar[r].first);
		m -= tmp;
		ans += tmp * ar[i].second;
	}
	cout << ans << endl;
}

Compiler output:
a.cc: In function 'int32_t main()':
a.cc:24:33: error: 'i' was not declared in this scope
   24 |                 ans += tmp * ar[i].second;
      |                                 ^
Language: C++

#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <map>
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;

int main() {
    int N, M;
    cin >> N >> M;
    vector<int> A(N), B(N);
    rep(i, N) {
        cin >> A[i] >> B[i];
    }
    map<int, ll> m;

    rep(i, N) {
        m[A[i]] += B[i];
    }

    ll ans = 0;
    for(auto shop : m) {
        ll buy = min(M, shop.second);
        ans += buy * shop.first;
        M -= (int)buy;
    }

    cout << ans;

    cout << endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:27:21: error: no matching function for call to 'min(int&, long long int&)'
   27 |         ll buy = min(M, shop.second);
      |                  ~~~^~~~~~~~~~~~~~~~
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:27:21: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   27 |         ll buy = min(M, shop.second);
      |                  ~~~^~~~~~~~~~~~~~~~
/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:4:
/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:27:21: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   27 |         ll buy = min(M, shop.second);
      |                  ~~~^~~~~~~~~~~~~~~~
Language: C++

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

int main()
{
. long long n,m;
  cin >> n >> m;
  vector<pair<long long,long long> > P;
  for(int i = 0; i < n; i++)
    {
    long long a,b;
    cin >> a >> b;
    P.push_back({a,b});
    }
  sort(P.begin(), P.end());
  long long ans = 0;
  for(int i=0; i< n; i++){
    long long  mn  = min(P[i].second, m);
    m -= mn;
    ans += mn*P[i].first;
    }
  cout << ans << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:6:1: error: expected primary-expression before '.' token
    6 | . long long n,m;
      | ^
a.cc:6:3: error: expected unqualified-id before 'long'
    6 | . long long n,m;
      |   ^~~~
a.cc:7:10: error: 'n' was not declared in this scope; did you mean 'yn'?
    7 |   cin >> n >> m;
      |          ^
      |          yn
a.cc:7:15: error: 'm' was not declared in this scope; did you mean 'tm'?
    7 |   cin >> n >> m;
      |               ^
      |               tm
Language: C++

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

int main(){
    int n, m;
    map<int, int> shop;
    int key;
    long long value;

    cin >> n >> m;
    for(int i = 0; i < n; i++){
        cin >> key >> value;
        if(shop.count(key) == 0){
            shop[key] = value;
        }else{
            shop[key] += value;
        }
    }

    key = 0
    value = 0;
    for(auto x : shop){
        if(key + x.second < m){
            key += x.second;
            value += x.first * x.second;
        }else{
            while(key < m){
                key++;
                value += x.first;
            }
        }
        if(value >= m){
            break;
        }
    }
    cout << value << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:20:12: error: expected ';' before 'value'
   20 |     key = 0
      |            ^
      |            ;
   21 |     value = 0;
      |     ~~~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
struct Fast { Fast() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20);} } fast;

int main() {
    long long price = 0, n, m;
    cin >> n >> m;
    vector<long long>as(n);
    vector<long long>bs(n);
    map<long long, long long>re;
    for (int i = 0; i < n; i++){
        cin >> as[i] >> bs[i];
        re[as[i]] = bs[i];
    }
    sort(as.begin(), as.end());
    for (int i = 0; i < n; i++){
        if (0 < m - re[as[i]]){
            m = m - re[as[i]];
            price = price + as[i] * re[as[i]];
        // }else{
        //     cout << price + as[i] * m << endl;
        //     return 0;
        // }
        }
    }
    cout << price + as[i] * m << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:26:24: error: 'i' was not declared in this scope
   26 |     cout << price + as[i] * m << endl;
      |                        ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
struct Fast { Fast() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20);} } fast;

int main() {
    long long price = 0, n, m;
    cin >> n >> m;
    vector<long long>as(n);
    vector<long long>bs(n);
    map<long long, long long>re;
    for (int i = 0; i < n; i++){
        cin >> as[i] >> bs[i];
        re[as[i]] = bs[i];
    }
    sort(as.begin(), as.end());
    for (int i = 0; i < n; i++){
        if (0 < m - re[as[i]]){
            m = m - re[as[i]];
            price = price + as[i] * re[as[i]];
        // }else{
        //     cout << price + as[i] * m << endl;
        //     return 0;
        // }
    }
    cout << price + as[i] * m << endl;
}

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

#include <iostream>
#include <vector>
#include <numeric>

int main() {
  std::size_t n, m;
  std::cin >> n >> m;

  std::vector<std::size_t> a(n);
  std::vector<std::size_t> b(n);
  std::vector<std::size_t> id(n);
  for (std::size_t i = 0; i < n; ++i) std::cin >> a[i] >> b[i];
  std::iota(id.begin(), id.end(), (std::size_t)0);
 
  std::sort(id.begin(), id.end(), [&a,&b](auto i, auto j) { return a[i] < a[j]; });

  std::size_t cost = 0;
  std::size_t num = 0;
  for (auto&& i : id) {
    if (num + b[i] < m) {
      cost += a[i]*b[i];
      num += b[i];
    } else {
      cost += (m - num)*b[i];
      num = m;
      break;
    }
  }
  std::cout << cost << std::endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:15:8: error: 'sort' is not a member of 'std'; did you mean 'qsort'?
   15 |   std::sort(id.begin(), id.end(), [&a,&b](auto i, auto j) { return a[i] < a[j]; });
      |        ^~~~
      |        qsort
Language: C++

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
public class State
{

    public struct AB
    {
        public int A;
        public int B;

        public AB(int a,int b)
        {
            this.A = a;
            this.B = b;

        }
    }

    public static void Main()
    {
        int N, M;
        var split = Console.ReadLine().Split().Select(int.Parse).ToArray();
        N = split[0];
        M = split[1];
        AB[] ab = new AB[N];
        for (long i = 0; i < N; i++)
        {
            split = Console.ReadLine().Split().Select(int.Parse).ToArray();

            ab[i] = new AB(split[0], split[1]);
        }
        Array.Sort(ab,comparer);
        long store = 0;
        int need = M;
        int[] buy = new int[N];

        while (need >0)
        {
            if (ab[store].B <= need)
            {
                buy[store] = ab[store].B;
                need -= ab[store].B;
                store++;
            }
            else
            {
                buy[store] = need;
                break;
            }
        }
        long pay = 0;
        for (int i = 0; i < N; i++)
        {
            if (buy[i] == 0) break;
            long temp = ab[i].A;
            temp *= buy[i];
            pay += temp;
        }
        Console.WriteLine(pay);

    }

    public static int comparer(AB a,AB b)
    {
        if (a.A > b.A) return 1;
        else if (a.A < b.A) return -1;
        else return 0;
      
    }



}



Compiler output:
a.cc:1:7: error: expected nested-name-specifier before 'System'
    1 | using System;
      |       ^~~~~~
a.cc:2:7: error: expected nested-name-specifier before 'System'
    2 | using System.Collections.Generic;
      |       ^~~~~~
a.cc:3:7: error: expected nested-name-specifier before 'System'
    3 | using System.Linq;
      |       ^~~~~~
a.cc:4:7: error: expected nested-name-specifier before 'System'
    4 | using System.Text;
      |       ^~~~~~
a.cc:5:7: error: expected nested-name-specifier before 'System'
    5 | using System.Threading.Tasks;
      |       ^~~~~~
a.cc:6:1: error: expected unqualified-id before 'public'
    6 | public class State
      | ^~~~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,m;
  cin>>n>>m;
  long long ans=0;
  vector<pair<long,long>> drink(n);
  for(int i=0;i<n;i++){
    long a,b;
    cin>>a>>b;
    drink[i]=make_pair(a,b);
  }
  sort(drink.begin(),drink.end());
  int k=0;
  while(m>0){
    ans+=(drink[k].first)*min(m,drink[k].second);
    m-=drink[k].second;
    k++;
  }
  cout<<ans;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:16:30: error: no matching function for call to 'min(int&, long int&)'
   16 |     ans+=(drink[k].first)*min(m,drink[k].second);
      |                           ~~~^~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note:   template argument deduction/substitution failed:
a.cc:16:30: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long int')
   16 |     ans+=(drink[k].first)*min(m,drink[k].second);
      |                           ~~~^~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
 5686 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
 5696 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note:   template argument deduction/substitution failed:
a.cc:16:30: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   16 |     ans+=(drink[k].first)*min(m,drink[k].second);
      |                           ~~~^~~~~~~~~~~~~~~~~~~
Language: C++

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

using namespace std;

typede long long ll;

int main(){
ll N,M; cin >> N >> M;
  vector<pair<ll,ll>> AB(N);
  for(int i = 0 ; i < N; i++){
    cin >> AB[i].first >> AB[i].second;}
  sort(AB.begin(),AB.end());
  
  ll sum = 0; ll cnt = 0; int i = 0;
  while(cnt < M){
    sum += AB[i].first * AB[i].second;
    cnt += AB[i].second;  i++;}
   
  sum -= AB[i-1].first*( M - cnt);
  
  cout << sum << endl; return 0;}
  
  

Compiler output:
a.cc:7:1: error: 'typede' does not name a type; did you mean 'typedef'?
    7 | typede long long ll;
      | ^~~~~~
      | typedef
a.cc: In function 'int main()':
a.cc:10:1: error: 'll' was not declared in this scope
   10 | ll N,M; cin >> N >> M;
      | ^~
a.cc:10:16: error: 'N' was not declared in this scope
   10 | ll N,M; cin >> N >> M;
      |                ^
a.cc:10:21: error: 'M' was not declared in this scope
   10 | ll N,M; cin >> N >> M;
      |                     ^
a.cc:11:20: error: template argument 1 is invalid
   11 |   vector<pair<ll,ll>> AB(N);
      |                    ^~
a.cc:11:20: error: template argument 2 is invalid
a.cc:13:14: error: invalid types 'int[int]' for array subscript
   13 |     cin >> AB[i].first >> AB[i].second;}
      |              ^
a.cc:13:29: error: invalid types 'int[int]' for array subscript
   13 |     cin >> AB[i].first >> AB[i].second;}
      |                             ^
a.cc:14:11: error: request for member 'begin' in 'AB', which is of non-class type 'int'
   14 |   sort(AB.begin(),AB.end());
      |           ^~~~~
a.cc:14:22: error: request for member 'end' in 'AB', which is of non-class type 'int'
   14 |   sort(AB.begin(),AB.end());
      |                      ^~~
a.cc:16:5: error: expected ';' before 'sum'
   16 |   ll sum = 0; ll cnt = 0; int i = 0;
      |     ^~~~
      |     ;
a.cc:16:17: error: expected ';' before 'cnt'
   16 |   ll sum = 0; ll cnt = 0; int i = 0;
      |                 ^~~~
      |                 ;
a.cc:17:9: error: 'cnt' was not declared in this scope; did you mean 'int'?
   17 |   while(cnt < M){
      |         ^~~
      |         int
a.cc:18:5: error: 'sum' was not declared in this scope
   18 |     sum += AB[i].first * AB[i].second;
      |     ^~~
a.cc:18:14: error: invalid types 'int[int]' for array subscript
   18 |     sum += AB[i].first * AB[i].second;
      |              ^
a.cc:18:28: error: invalid types 'int[int]' for array subscript
   18 |     sum += AB[i].first * AB[i].second;
      |                            ^
a.cc:19:14: error: invalid types 'int[int]' for array subscript
   19 |     cnt += AB[i].second;  i++;}
      |              ^
a.cc:21:3: error: 'sum' was not declared in this scope
   21 |   sum -= AB[i-1].first*( M - cnt);
      |   ^~~
a.cc:21:12: error: invalid types 'int[int]' for array subscript
   21 |   sum -= AB[i-1].first*( M - cnt);
      |            ^
a.cc:21:30: error: 'cnt' was not declared in this scope; did you mean 'int'?
   21 |   sum -= AB[i-1].first*( M - cnt);
      |                              ^~~
      |                              int
Language: C

#include <stdio.h>
int main(){
  int N,M;
  int A[100000][2];
  scanf("%d %d",&N,&M);
  int i,j,k,l;
  
  for (i=0;i<N;i++){
    scanf("%d %d",&a,&b);
    if (i==0){
      A[0][0] = a;
      A[0][1] = b;
    }else{
      for (j=0;j<i;j++){
        if(a < A[j][0]){
          for (k=i-1;k>=j;k--){
            A[k+1][0] = A[k][0];
            A[k+1][1] = A[k][1];
            A[j][0] = a;
            A[j][1] = b;
          }
          j=i+1;
        }
        if(j=i-1 && a >= A[j][0]){
          A[i][0] = a;
          A[i][1] = b;
        }
      }
    }
  }
  int sum = 0;
  int money = 0;
  for (l=0;l<N;l++){
    if (sum + A[l][1] > M){
      money += A[l][0]*(M - sum);
      l = N+1;
    }else if(sum + A[l][1] <= M){
      money += A[l][0]*A[l][1];
    }
  }
  printf("%d\n",money);
  return 0;
}

Compiler output:
main.c: In function 'main':
main.c:9:20: error: 'a' undeclared (first use in this function)
    9 |     scanf("%d %d",&a,&b);
      |                    ^
main.c:9:20: note: each undeclared identifier is reported only once for each function it appears in
main.c:9:23: error: 'b' undeclared (first use in this function)
    9 |     scanf("%d %d",&a,&b);
      |                       ^
Language: C++

#include <iostream>
#include <vector>
#include <algorithm> // sort
#define int long long

using namespace std;

int main(){
    int N,M,res;

    cin >> N >> M;
    
    vector <pair<int,int>> p(N);
    //金,在庫

    for(int i = 0; i < N; i++)
    {
        cin >> p[i].first >> p[i].second; 
    }

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

    int zan = M;
    res = 0;
    for(int i = 0; i < N; i++)
    {
        if (zan <= p[i].second){
            res += p[i].first * zan;
            break;        
        }

        res += p[i].first * p[i].second;
        zan -= p[i].second;
    }

    cout << res << endl;
    return 0;
}



Compiler output:
cc1plus: error: '::main' must return 'int'
Language: C++

#include<iostream>
#include<vector>
#include<iterator>

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;
    for  (int i = 0; i < N; i++){
        int buy = min(M, AB[i].second);
        ans += (long long)buy * AB[i].first;
    }

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

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

#include<iostream>
#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;
    for  (int i = 0; i < N; i++){
        int buy = min(M, AB[i].second);
        ans += (long long)buy * AB[i].first;
    }

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

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

#include<iostream>
#include<algorithm>
#include<cmath>
#include<utility>
#include<vector>
using namespace std;
int main() {
  int n,m;
  cin >> n >> m;
  long long ans=0;
  vector<pair<int,int>> p(n);
  for(int i=0; i<n; i++) {
    cin >> p[i].first >> p[i].second;
  }
  sort(a.begin(),a.end());
  for(int i=0; i<n; i++) {
    ans+=min(m,p[i].second)*p[i].first;
    m-=min(m,p[i].second);
    if(m==0) {
      break;
    }
  }
  cout << ans << endl;
}

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

#include<iostream>
#include<algorithm>
#include<cmath>
#include<utility>
using namespace std;
int main() {
  int n,m;
  cin >> n >> m;
  long long ans=0;
  vector<pair<int,int>> p(n);
  for(int i=0; i<n; i++) {
    cin >> p[i].first >> p[i].second;
  }
  sort(a.begin(),a.end());
  for(int i=0; i<n; i++) {
    ans+=min(m,p[i].second)*p[i].first;
    m-=min(m,p[i].second);
    if(m==0) {
      break;
    }
  }
  cout << ans << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:10:3: error: 'vector' was not declared in this scope
   10 |   vector<pair<int,int>> p(n);
      |   ^~~~~~
a.cc:5:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
    4 | #include<utility>
  +++ |+#include <vector>
    5 | using namespace std;
a.cc:10:22: error: expected primary-expression before '>' token
   10 |   vector<pair<int,int>> p(n);
      |                      ^~
a.cc:10:25: error: 'p' was not declared in this scope
   10 |   vector<pair<int,int>> p(n);
      |                         ^
a.cc:14:8: error: 'a' was not declared in this scope
   14 |   sort(a.begin(),a.end());
      |        ^
Language: C++

#include<iostream>
#include<algorithm>
#include<cmath>
#include<utility>
using namespace std;
int main() {
  int n,m;
  cin >> n >> m;
  long long ans=0;
  vector<pair<int int>> p(n);
  for(int i=0; i<n; i++) {
    cin >> p[i].first >> p[i].second;
  }
  sort(a.begin(),a.end());
  for(int i=0; i<n; i++) {
    ans+=min(m,p[i].second)*p[i].first;
    m-=min(m,p[i].second);
    if(m==0) {
      break;
    }
  }
  cout << ans << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:10:3: error: 'vector' was not declared in this scope
   10 |   vector<pair<int int>> p(n);
      |   ^~~~~~
a.cc:5:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
    4 | #include<utility>
  +++ |+#include <vector>
    5 | using namespace std;
a.cc:10:15: error: two or more data types in declaration of 'type name'
   10 |   vector<pair<int int>> p(n);
      |               ^~~
a.cc:10:19: error: wrong number of template arguments (1, should be 2)
   10 |   vector<pair<int int>> p(n);
      |                   ^~~
In file included from /usr/include/c++/14/string:48,
                 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_iterator.h:3013:12: note: provided for 'template<class _T1, class _T2> struct std::pair'
 3013 |     struct pair;
      |            ^~~~
a.cc:10:25: error: 'p' was not declared in this scope
   10 |   vector<pair<int int>> p(n);
      |                         ^
a.cc:14:8: error: 'a' was not declared in this scope
   14 |   sort(a.begin(),a.end());
      |        ^
Language: C

#include<iostream>
#include<string>
#include<typeinfo>
#include<vector>
#include<algorithm>
#include<map>
using namespace std;
int main()
{
	int n,m;
	long long ans;
	cin >> n >> m;
	vector<pair<int, int>> vec(n);

	for(int i=0; i<n;i++){
		cin >> vec[i].first >> vec[i].second;
	}
	sort(vec.begin(), vec.end());

	int sum=0;
	ans=0;
	for(int i=0; i<n; i++){
		if(vec[i].second <= (m-sum)){
			ans += (long long)vec[i].first * vec[i].second;	
			sum += vec[i].second;
		}else{
			ans += (long long)vec[i].first * (m-sum);
			break;
		}
	}

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

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

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

//　基本方針は安い順に並び替えて総当りだが、この問題ではstd::pairを使うことが重要。
//  以下が自分で途中まで書いた奴

/* int main(){
    int N,M;
    cin >> N >> M ;
    long long int A,B;
    vector<long long int> Ai(N+1);
    vector<long long int> Bi(N+1);

    for(int i = 0;i < N;i++){ // 配列化 O(N)
        cin >> Ai[i] >> Bi[i] ;
    }

    sort(Ai.begin(),Ai.last());

} */

//　ここで問題になるのは、sortでAiを昇順にしても、その商品の個数を知れないという点である。
//  これをpairで解決する。

//  pairは pair<int,int> のように型、型を宣言する。
//  そんで、これをint とかと同じようにぶち込めばおｋ
//  vector<pair<int,string>> ???(N); てな感じ

//  細かい使い方は良く分からんけど、とりあえず配列の中に2つのデータを保管できると考えればいい。
//  Classの定義とかでもいいんだけど、pairの便利なところは定義がいらないのと、sortが各キーに対して使えることらしい
//  基本的にpairのsortはfirstとsecondがそれぞれ昇順になるっぽい。
//  つまり、(1,2),(1,6),(2,5),(2,7),(5,5)とかそんな感じ。

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

    sort(v.begin(),v.last());

    long long res = 0;
    for(int i = 0; i < N && M > 0;i++){
        res += v[i].first * min(M,v[i].second);
        M -= min(M, v[i].second);

    }
    cout << res << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:42:22: error: 'class std::vector<std::pair<long long int, long long int> >' has no member named 'last'; did you mean 'at'?
   42 |     sort(v.begin(),v.last());
      |                      ^~~~
      |                      at
Language: Java

import java.util.*;


public class Main {
    public static void main(String[] args) {
        // 自分の得意な言語で
        // Let's チャレンジ！！

        Scanner sc = new Scanner(System.in);
        
        int shopCount = sc.nextInt();
        int needDrinkCount = sc.nextInt();
        
        long[] prices = new long[shopCount];
        int[] maxBuyCounts = new int[shopCount];
        for (int i = 0; i < shopCount; i++) {
            prices[i] = sc.nextLong();
            maxBuyCounts = sc.nextInt();
        }
        
        for (int i = 0; i < shopCount; i++) {
            for (int j = i; j <shopCount - 1; j++) {
                if (prices[j] > prices[j + 1]) {
                    long tmp = prices[j];
                    prices[j] = prices[j + 1];
                    prices[j + 1] = tmp;
                    int tmp2 = maxBuyCounts[j];
                    maxBuyCounts[j] = maxBuyCounts[j + 1];
                    maxBuyCounts[j + 1] = tmp2;
                }
            }
        }
        
        long needMoney = 0;
        
        for (int i = 0; i < shopCount; i++) {
            if (maxBuyCounts[i] <= needDrinkCount) {
                needMoney += prices[i] * maxBuyCounts[i];
                needDrinkCount -= maxBuyCounts[i];
            } else {
                needMoney += prices[i] * needDrinkCount;
                needDrinkCount -= needDrinkCount;
            }
            
            if (needDrinkCount == 0) break;
        }
        
        System.out.println(needMoney);
    }
}

Compiler output:
Main.java:18: error: incompatible types: int cannot be converted to int[]
            maxBuyCounts = sc.nextInt();
                                     ^
1 error
Language: C

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

typedef struct {
    int zaiko;             //zaiko
    int price;          //価格
} cell;

// --------------- 比較用の関数 cmp -------------------
int cmp( const void *p, const void *q ) {
    return ((cell*)p)->price - ((cell*)q)->price;
}

int main(){
  long max=0;
  
  int N,M;
  scanf("%d %d",&N,&M);
  cell A[N];
  for(i=0;i<N;i++){
    scanf("%d %d",&A[i].price,&A[i].zaiko);
  }
   int n = sizeof A / sizeof( cell );
    qsort( A, n, sizeof(cell), cmp );
  
  while(M==0){
    if(A[i].zaiko < M){
      M-=A[i].zaiko;
      max += A[i].price * A[i].zaiko;
    }
    else
      max += M * A[i].price;
  }
  printf("%ld\n",max);
  return 0;
}


Compiler output:
main.c: In function 'main':
main.c:20:7: error: 'i' undeclared (first use in this function)
   20 |   for(i=0;i<N;i++){
      |       ^
main.c:20:7: note: each undeclared identifier is reported only once for each function it appears in
Language: C

#include<stdio.h>

typedef struct {
    int zaiko;             //zaiko
    int price;          //価格
} cell;

// --------------- 比較用の関数 cmp -------------------
int cmp( const void *p, const void *q ) {
    return ((cell*)p)->price - ((cell*)q)->price;
}

int main(){
  long max=0;
  
  int N,M;
  scanf("%d %d",&N,&M);
  cell A[N];
  for(i=0;i<N;i++){
    scanf("%d %d",&A[i].price,&A[i].zaiko);
  }
   int n = sizeof A / sizeof( cell );
    qsort( A, n, sizeof(cell), cmp );
  
  while(M==0){
    if(A[i].zaiko < M){
      M-=A[i].zaiko;
      max += A[i].price * A[i].zaiko;
    }
    else
      max += M * A[i].price;
  }
  printf("%ld\n",max);
  return 0;
}

Compiler output:
main.c: In function 'main':
main.c:19:7: error: 'i' undeclared (first use in this function)
   19 |   for(i=0;i<N;i++){
      |       ^
main.c:19:7: note: each undeclared identifier is reported only once for each function it appears in
main.c:23:5: error: implicit declaration of function 'qsort' [-Wimplicit-function-declaration]
   23 |     qsort( A, n, sizeof(cell), cmp );
      |     ^~~~~
Language: C++

#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
int main() {
  int M;
  std::cin >> M;
  std::vector<std::pair<int,int>> AB(M);
  for(auto &ab:AB)
    std::cin >> ab.first >> ab.second;
  std::sort(AB.begin(),AB.end(),
  [](std::pair<int,int> &l, std::pair<int,int> &r){
    return l.first < r.first;
  });
  int sum=0;
  int cnt = 0;
  for(auto &ab:AB){
    if(cnt + ab.second>=M){
      sum += ab.first*(M-cnt);
      std::cout << sum << std::endl;
      return;
    }
    cnt += ab.second;
    sum += ab.first*ab.second;
  }
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:21:7: error: return-statement with no value, in function returning 'int' [-fpermissive]
   21 |       return;
      |       ^~~~~~
Language: C++

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

using namespace std;

typedef long long int ll;
#define REP(i, I, N) for (ll i = I; i < N; ++i)
#define rep(i, N) REP(i, 0, N)

struct shop {
    ll price;
    ll stock;

    bool operator<(const shop &another) const {
        return price < another.price;
    }
};

int main() {
    ll N, M, ans = 0, bought = 0;
    cin >> N >> M;
    vector<shop> S(N);
    ll A, B;
    rep(i, N) {
        cin >> A >> B;
        S[i].price = A;
        S[i].stock = B;
    }
    sort(S.begin(), S.end());

    rep(i, S.size()) {
        if (M > S[i].stock) {
            M -= S[i].stock;
            ans += S[i].price * S[i].stock;
        } else {
            ans += M * S[i].price;
            cout << ans << "\n"
            return 0;
        }
    }
}


Compiler output:
a.cc: In function 'int main()':
a.cc:38:32: error: expected ';' before 'return'
   38 |             cout << ans << "\n"
      |                                ^
      |                                ;
   39 |             return 0;
      |             ~~~~~~
Language: C++

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

using namespace std;

typedef long long int ll;
#define REP(i, I, N) for (ll i = I; i < N; ++i)
#define rep(i, N) REP(i, 0, N)

struct shop {
    ll price;
    ll stock;

    bool operator<(const shop &another) const {
        return price < another.price;
    }
};

int main() {
    ll N, M, ans = 0, bought = 0;
    cin >> N >> M;
    vector<shop> S(N);
    ll A, B;
    rep(i, N) {
        cin >> A >> B;
        S[i].price = A;
        S[i].stock = B;
    }
    sort(S.begin(), S.end());

    rep(i, S.size()) {
        if (M > S[i].stock) {
            M -= S[i].stock;
            ans += S[i].price * S[i].stock
        } else {
            ans += M * S[i].price;
            cout << ans << "\n"
            return 0;
        }
    }
}


Compiler output:
a.cc: In function 'int main()':
a.cc:35:43: error: expected ';' before '}' token
   35 |             ans += S[i].price * S[i].stock
      |                                           ^
      |                                           ;
   36 |         } else {
      |         ~                                  
a.cc:38:32: error: expected ';' before 'return'
   38 |             cout << ans << "\n"
      |                                ^
      |                                ;
   39 |             return 0;
      |             ~~~~~~
Language: C++

#include <iostream>
#include <vector>

using namespace std;

typedef long long int ll;
#define REP(i, I, N) for (ll i = I; i < N; ++i)
#define rep(i, N) REP(i, 0, N)

struct shop {
    ll price;
    ll stock;

    bool operator<(const shop &another) const {
        return price < another.price;
    }
};

int main() {
    ll N, M;
    cin >> N >> M;
    vector<shop> S(N);

    ll A, B;
    rep(i, N) {
        cin >> A >> B;
        S[i].price = A;
        S[i].stock = B;
    }
    sort(S.begin(), S.end());

    ll ans = 0;
    ll bought = 0;
    while (bought != M) {
        shop s = S[0];
        while (s.stock > 0) {
            ans += s.price;
            s.stock--;
            bought++;
            if (bought == M) break;
        }
        S.erase(S.begin());
    }
    cout << ans << endl;
}

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

#include <iostream>
#include <vector>

int main(){
  long N, M;
  std::cin>>N>>M;
  std::vector<std::pair<long, long> > A(N);
  for(int i = 0 ; i < N ; i++ ){
    std::cin>>A[i].first>>A[i].second;
  }
  std::sort(A.begin(), A.end());
  long result = 0;
  long Num = 0;
  for(int i = 0 ; i < N ; i++ ){
    if(M - Num >= A[i].second){
      result += A[i].first * A[i].second;
      Num += A[i].second;
    }else{
      result += A[i].first * (M - Num);
      Num += M - Num;
    }
    if(Num == M) break;
  }
  std::cout<<result<<std::endl;
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:11:8: error: 'sort' is not a member of 'std'; did you mean 'qsort'?
   11 |   std::sort(A.begin(), A.end());
      |        ^~~~
      |        qsort
Language: C++

#include <iostream>
#include <vector>

int main(){
  long N, M;
  std::cin>>N>>M;
  std::vector<pair<long, long> > A(N);
  for(int i = 0 ; i < N ; i++ ){
    std::cin>>A[i].first>>A[i].second;
  }
  std::sort(A.begin(), A.end());
  long result = 0;
  long Num = 0;
  for(int i = 0 ; i < N ; i++ ){
    if(M - Num >= A[i].second){
      result += A[i].first * A[i].second;
      Num += A[i].second;
    }else{
      result += A[i].first * (M - Num);
      Num += M - Num;
    }
    if(Num == M) break;
  }
  std::cout<<result<<std::endl;
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:7:15: error: 'pair' was not declared in this scope; did you mean 'std::pair'?
    7 |   std::vector<pair<long, long> > A(N);
      |               ^~~~
      |               std::pair
In file included from /usr/include/c++/14/string:48,
                 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_iterator.h:3013:12: note: 'std::pair' declared here
 3013 |     struct pair;
      |            ^~~~
a.cc:7:30: error: template argument 1 is invalid
    7 |   std::vector<pair<long, long> > A(N);
      |                              ^
a.cc:7:30: error: template argument 2 is invalid
a.cc:7:32: error: expected unqualified-id before '>' token
    7 |   std::vector<pair<long, long> > A(N);
      |                                ^
a.cc:9:15: error: 'A' was not declared in this scope
    9 |     std::cin>>A[i].first>>A[i].second;
      |               ^
a.cc:11:8: error: 'sort' is not a member of 'std'; did you mean 'qsort'?
   11 |   std::sort(A.begin(), A.end());
      |        ^~~~
      |        qsort
a.cc:11:13: error: 'A' was not declared in this scope
   11 |   std::sort(A.begin(), A.end());
      |             ^
Language: Java

import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int m = in.nextInt();
      	while(true) {
          m++;
        }
        Map<Integer, Integer> stores = new TreeMap<>();
        for (int i = 0; i < n; i++) {
            stores.put(in.nextInt(), in.nextInt());
        }
        long yen = 0;
        for (int key : stores.keySet()) {
            while (stores.get(key) > 0) {
                m--;
                stores.put(key, stores.get(key) - 1);
                yen += key;
                if (m == 0) {
                    System.out.println(yen);
                    return;
                }
            }
        }
    }
}


Compiler output:
Main.java:11: error: unreachable statement
        Map<Integer, Integer> stores = new TreeMap<>();
                              ^
1 error
Language: C

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


int main(void)
{
	int n,m;
	
	scanf("%d %d",&n,&m);
	
	int i,a[n],b[n],j,temp;
	
	for(i = 0; i < n; i++){
		scanf("%d %d",&a[i],&b[i]);
	}
	
	for(i = 0; i < n; i++){
		for(j = n - 1; j > i; j--){
			if(a[j] < a[j - 1]){
				temp = a[j];
				a[j] = a[j - 1];
				a[j - 1] = temp;
				temp = b[j];
				b[j] = b[j - 1];
				b[j - 1] = temp;
			}
		}
	}
	
	int honsuu = 0, sum = 0;
	
	for(i = 0;;i++){
		honsuu = honsuu + b[i];
		if(honsuu == m){
			for(j = 0; j <= i; j++){
				sum = sum + a[j]b[j];
			}
			break;
		}else if(honsuu > m){
			for(j = 0; j < i; j++){
				sum = sum + a[j]b[j];
			}
			sum = sum + a[i]*(b[i] - honsuu);
			break;
		}
	}
	
	printf("%d\n",sum);
	
	return 0;
}
			
			
			
			
		
	
	
	
				
				
			
	
	
	
	

Compiler output:
main.c: In function 'main':
main.c:36:49: error: expected ';' before 'b'
   36 |                                 sum = sum + a[j]b[j];
      |                                                 ^
      |                                                 ;
main.c:41:49: error: expected ';' before 'b'
   41 |                                 sum = sum + a[j]b[j];
      |                                                 ^
      |                                                 ;
Language: C++

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

int main() {
	long N, M;
	cin >> N >> M;
	vector<vector<long>> data(N, vector<long>(2, 0));
	vector<long> A(N), B(N);
	for (int i = 0; i < N; i++) {
		cin >> data.at(i).at(0) >> data.at(i).at(1);
		A.at(i) = data.at(i).at(0);
		B.at(i) = data.at(i).at(1);
	}
	while (true) {
		int C = 0;
		for (int i = 0; i < N - 1; i++) {
			if (A.at(i) > A.at(i + 1)) {
				swap(A.at(i), A.at(i + 1));
				swap(B.at(i), B.at(i + 1));
				C++;
			}
		}
		if (C == 0) {
			break;
		}
	}
	long sum_1 = 0;
	long sum_2 = 0;
	long sum_3 = 0;
	int count = 0;
	for (int i = 0; i < N; i++) {
		count++;
		sum_1 = sum_2;
	    sum_2 += B.at(i)
		if (sum_2 > N) {
			break;
		}
	}
	for (int i = 0; i < count; i++) {
		sum_3 += A.at(i) * B.at(i);
	}
	sum_3 += A_at(count) * (N - sum_2);
	cout << sum_3 << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:34:29: error: expected ';' before 'if'
   34 |             sum_2 += B.at(i)
      |                             ^
      |                             ;
   35 |                 if (sum_2 > N) {
      |                 ~~           
a.cc:42:18: error: 'A_at' was not declared in this scope
   42 |         sum_3 += A_at(count) * (N - sum_2);
      |                  ^~~~
Language: C++

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

int main() {
	long N, M;
	cin >> N >> M;
	vector<vector<long>> data(N, vector<long>(2, 0));
	vector<long> A(N), B(N);
	for (int i = 0; i < N; i++) {
		cin >> data.at(i).at(0) >> data.at(i).at(1);
		A.at(i) = data.at(i).at(0);
		B.at(i) = data.at(i).at(1);
	}
	while (true) {
		int C = 0
		for (int i = 0; i < N - 1; i++) {
			
				if (A.at(i) > A.at(i + 1)) {
					swap(A.at(i), A.at(i + 1));
					swap(B.at(i), B.at(i + 1));
					C++;
				}
		}
		if (C == 0) {
			break;
	}
	long sum_1 = 0;
	long sum_2 = 0;
	long sum_3 = 0;
	int count = 0;
	for (int i = 0; i < N; i++) {
		count++;
		sum_1 = sum_2
	    sum_2 += B.at(i)
		if (sum_2 > N) {
			break;
		}
	}
	for (int i = 0; i < count; i++) {
		sum_3 += A.at(i) * B.at(i);
	}
	sum_3 += A_at(count) * (N - sum_2);
	cout << sum_3 << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:16:17: error: expected ',' or ';' before 'for'
   16 |                 for (int i = 0; i < N - 1; i++) {
      |                 ^~~
a.cc:16:33: error: 'i' was not declared in this scope
   16 |                 for (int i = 0; i < N - 1; i++) {
      |                                 ^
a.cc:33:30: error: expected ';' before 'sum_2'
   33 |                 sum_1 = sum_2
      |                              ^
      |                              ;
   34 |             sum_2 += B.at(i)
      |             ~~~~~             
a.cc:42:18: error: 'A_at' was not declared in this scope
   42 |         sum_3 += A_at(count) * (N - sum_2);
      |                  ^~~~
a.cc:44:2: error: expected '}' at end of input
   44 | }
      |  ^
a.cc:4:12: note: to match this '{'
    4 | int main() {
      |            ^
Language: C++

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

int main() {
  long long N,M;
  scanf("%d %d", &N,&M);
  long long a[N],b[N];
  for (int i = 0; i < N; ++i) {
    scanf("%d %d", &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 count = 0;
  int i = 0;

  while(M>0){
    if(AB[i].second<M){
      M -= AB[i].second;
      count += AB[i].first*AB[i].second;
    }
    else{
      count += AB[i].first*M
    }
    ++i;
  }

  cout << count << endl;

}

Compiler output:
a.cc: In function 'int main()':
a.cc:27:29: error: expected ';' before '}' token
   27 |       count += AB[i].first*M
      |                             ^
      |                             ;
   28 |     }
      |     ~
Language: C++

#include <stdio.h>
#include <string>
#include <vector>
#include <algorithm>
#include <iostream>
#include <cmath>
using namespace std;

static const long MAX = 1e8 + 7;
int n, m, B[MAX];
long A[MAX], C[MAX][2], c, ans;

long h(long key, long i) {
    long r = (key % MAX + i * (1 + key % (MAX - 1))) % MAX;
    return r;
}

void insert(long key, long value) {
    long i = 0;

    while ( true ) {
        if ( C[h(key, i)][0] == key ) {
            break;
        } else if ( C[h(key, i)][0] ) {
            i++;
        } else {
            C[h(key, i)][0] = key;
            C[h(key, i)][1] = value;
            break;
        }
    }
}

long find(long key) {
    long i = 0;

    while ( true ) {
        if ( C[h(key, i)][0] == key ) {
            return C[h(key, i)][1];
            break;
        } else if ( C[h(key, i)][0] ) {
            i++;
        } else {
            return 0;
            break;
        }
    }
}

int main() {
    scanf("%d %d", &n, &m);
    
    for ( int i = 0; i < n; i++ ) {
        scanf("%ld %d", &A[i], &B[i]);
    }

    for ( int i = 0; i < n; i++ ) {
        scanf("%ld %d", &A[i], &B[i]);
        insert(A[i], B[i]);
    }

    c = 0;
    ans = 0;

    while ( m > 0 ) {
        m -= find(c);
        ans += c * find(c);
        c++;
    }

    ans += (c - 1) * m;
    printf("%ld\n", ans);
    return 0;
}


Compiler output:
/tmp/cch3SPx1.o: in function `main':
a.cc:(.text+0x380): relocation truncated to fit: R_X86_64_PC32 against symbol `c' defined in .bss section in /tmp/cch3SPx1.o
a.cc:(.text+0x38b): relocation truncated to fit: R_X86_64_PC32 against symbol `ans' defined in .bss section in /tmp/cch3SPx1.o
a.cc:(.text+0x398): relocation truncated to fit: R_X86_64_PC32 against symbol `c' defined in .bss section in /tmp/cch3SPx1.o
a.cc:(.text+0x3bb): relocation truncated to fit: R_X86_64_PC32 against symbol `c' defined in .bss section in /tmp/cch3SPx1.o
a.cc:(.text+0x3ca): relocation truncated to fit: R_X86_64_PC32 against symbol `c' defined in .bss section in /tmp/cch3SPx1.o
a.cc:(.text+0x3d5): relocation truncated to fit: R_X86_64_PC32 against symbol `ans' defined in .bss section in /tmp/cch3SPx1.o
a.cc:(.text+0x3df): relocation truncated to fit: R_X86_64_PC32 against symbol `ans' defined in .bss section in /tmp/cch3SPx1.o
a.cc:(.text+0x3e6): relocation truncated to fit: R_X86_64_PC32 against symbol `c' defined in .bss section in /tmp/cch3SPx1.o
a.cc:(.text+0x3f1): relocation truncated to fit: R_X86_64_PC32 against symbol `c' defined in .bss section in /tmp/cch3SPx1.o
a.cc:(.text+0x402): relocation truncated to fit: R_X86_64_PC32 against symbol `c' defined in .bss section in /tmp/cch3SPx1.o
a.cc:(.text+0x419): additional relocation overflows omitted from the output
collect2: error: ld returned 1 exit status
Language: C++

//ABC121-C
//with vector pair.

#include<iostream>
using namespace std;
typedef long long ll;

#include<vector>
#define pb push_back

#define rep(i, a, b) for(int i=(a); i<(b); i++)

int main(){
  ll N,M;
  ll Drinks, Pay=0;
  vector<pair<ll,ll> > C;
  cin >> N >> M;
  
  rep(i, 0, N){
    ll a_temp,b_temp;
    cin >> a_temp >> b_temp;
    C.pb(make_pair(a_temp,b_temp));
  }
  sort(C.begin(), C.end());

  rep(i, 0, N){
    if(M>C[0].second){
      //cout<<C[0].first<<" "<<C[0].second<<endl;
      Pay+=C[0].first*C[0].second;
      M-=C[0].second;
      C.erase(C.begin());
    }else{
      //cout<<C[0].first<<" "<<C[0].second<<" M"<<M<<endl;
      Pay+=C[0].first*M;
      break;
    }
  }
  cout<<Pay<<endl;
  
  return 0;
}


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