Language: C++

#include<iostream>
#include<vector>
#include<map>

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;
    M-=buy;
  }
  cout<<ans<<endl;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:7:3: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
    7 |   cin>>N>>M;
      |   ^~~
      |   std::cin
In file included from a.cc:1:
/usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here
   62 |   extern istream cin;           ///< Linked to standard input
      |                  ^~~
a.cc:8:3: error: 'vector' was not declared in this scope
    8 |   vector<int>A(N),B(N);
      |   ^~~~~~
a.cc:8:3: note: suggested alternatives:
In file included from /usr/include/c++/14/vector:66,
                 from a.cc:2:
/usr/include/c++/14/bits/stl_vector.h:428:11: note:   'std::vector'
  428 |     class vector : protected _Vector_base<_Tp, _Alloc>
      |           ^~~~~~
/usr/include/c++/14/vector:93:13: note:   'std::pmr::vector'
   93 |       using vector = std::vector<_Tp, polymorphic_allocator<_Tp>>;
      |             ^~~~~~
a.cc:8:10: error: expected primary-expression before 'int'
    8 |   vector<int>A(N),B(N);
      |          ^~~
a.cc:10:10: error: 'A' was not declared in this scope
   10 |     cin>>A[i]>>B[i];
      |          ^
a.cc:10:16: error: 'B' was not declared in this scope
   10 |     cin>>A[i]>>B[i];
      |                ^
a.cc:12:10: error: 'pair' was not declared in this scope; did you mean 'std::pair'?
   12 |   vector<pair<int,int>>AB(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:
/usr/include/c++/14/bits/stl_iterator.h:3013:12: note: 'std::pair' declared here
 3013 |     struct pair;
      |            ^~~~
a.cc:12:15: error: expected primary-expression before 'int'
   12 |   vector<pair<int,int>>AB(N);
      |               ^~~
a.cc:14:5: error: 'AB' was not declared in this scope
   14 |     AB[i]=make_pair(A[i],B[i]);
      |     ^~
a.cc:14:21: error: 'A' was not declared in this scope
   14 |     AB[i]=make_pair(A[i],B[i]);
      |                     ^
a.cc:14:26: error: 'B' was not declared in this scope
   14 |     AB[i]=make_pair(A[i],B[i]);
      |                          ^
a.cc:14:11: error: 'make_pair' was not declared in this scope; did you mean 'std::make_pair'?
   14 |     AB[i]=make_pair(A[i],B[i]);
      |           ^~~~~~~~~
      |           std::make_pair
In file included from /usr/include/c++/14/bits/stl_algobase.h:64,
                 from /usr/include/c++/14/string:51:
/usr/include/c++/14/bits/stl_pair.h:1132:5: note: 'std::make_pair' declared here
 1132 |     make_pair(_T1&& __x, _T2&& __y)
      |     ^~~~~~~~~
a.cc:16:8: error: 'AB' was not declared in this scope
   16 |   sort(AB.begin(),AB.end());
      |        ^~
a.cc:16:3: error: 'sort' was not declared in this scope; did you mean 'short'?
   16 |   sort(AB.begin(),AB.end());
      |   ^~~~
      |   short
a.cc:19:13: error: 'min' was not declared in this scope; did you mean 'std::min'?
   19 |     int buy=min(M,AB[i].second);
      |             ^~~
      |             std::min
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: 'std::min' declared here
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
a.cc:23:3: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   23 |   cout<<ans<<endl;
      |   ^~~~
      |   std::cout
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
   63 |   extern ostream cout;          ///< Linked to standard output
      |                  ^~~~
a.cc:23:14: error: 'endl' was not declared in this scope; did you mean 'std::endl'?
   23 |   cout<<ans<<endl;
      |              ^~~~
      |              std::endl
/usr/include/c++/14/ostream:744:5: note: 'std::endl' declared here
  744 |     endl(basic_ostream<_CharT, _Traits>& __os)
      |     ^~~~