Language: C++

#include<iostream>
using namespace std;
int main(){
  int N, M, B[100000];
  pair<unsigned long, int> A[100000],
  cin >> N >> M;
  for(int i=0; i<N; i++){
    unsigned long f;
    cin >> f >> B[i];
    A[i] = make_pair(f, i);
  }
  sort(A.begin(), A.end());
  int cnt = 0, ans = 0, n = 0;
  cnt = += B[A[n].second];
  while(cnt <M){
    ans += B[A[n].second] * A[n].first;
    n++;
    cnt += B[A[n].second];
  }
  ans += (cnt-M)*A[n].first;
  cout << ans << endl;
  return a#include<iostream>
#include <vector>
#include <algorithm> // sort
#include <map> // pair
using namespace std;
int main(){
  int N, M, B[100000];
  cin >> N >> M;
  vector<pair<unsigned long, int>> A(N);
  for(int i=0; i<N; i++){
    unsigned long f;
    cin >> f >> B[i];
    A[i] = make_pair(f, i);
  }
  sort(A.begin(), A.end());
  unsigned long cnt = 0, ans = 0, n = 0;
  cnt += B[A[n].second];
  while(cnt < M){
    ans += B[A[n].second] * A[n].first;
    n++;
    cnt += B[A[n].second];
  }
  ans += (M-(cnt-B[A[n].second]))*A[n].first;
  cout << ans << endl;
  return 0;
}


Compiler output:
a.cc:22:11: error: stray '#' in program
   22 |   return a#include<iostream>
      |           ^
a.cc: In function 'int main()':
a.cc:6:7: error: expected initializer before '>>' token
    6 |   cin >> N >> M;
      |       ^~
a.cc:12:10: error: request for member 'begin' in 'A', which is of non-class type 'std::pair<long unsigned int, int> [100000]'
   12 |   sort(A.begin(), A.end());
      |          ^~~~~
a.cc:12:21: error: request for member 'end' in 'A', which is of non-class type 'std::pair<long unsigned int, int> [100000]'
   12 |   sort(A.begin(), A.end());
      |                     ^~~
a.cc:12:3: error: 'sort' was not declared in this scope; did you mean 'short'?
   12 |   sort(A.begin(), A.end());
      |   ^~~~
      |   short
a.cc:14:9: error: expected primary-expression before '+=' token
   14 |   cnt = += B[A[n].second];
      |         ^~
a.cc:22:10: error: 'a' was not declared in this scope
   22 |   return a#include<iostream>
      |          ^
a.cc:22:11: error: expected ';' before 'include'
   22 |   return a#include<iostream>
      |           ^~~~~~~~
      |           ;
a.cc:22:12: error: 'include' was not declared in this scope
   22 |   return a#include<iostream>
      |            ^~~~~~~
a.cc:22:28: error: expected primary-expression before '>' token
   22 |   return a#include<iostream>
      |                            ^
In file included from /usr/include/c++/14/vector:65,
                 from a.cc:23:
/usr/include/c++/14/bits/stl_uninitialized.h:70:1: error: expected primary-expression before 'namespace'
   70 | namespace std _GLIBCXX_VISIBILITY(default)
      | ^~~~~~~~~
In file included from /usr/include/c++/14/bits/requires_hosted.h:31,
                 from /usr/include/c++/14/iostream:38,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_vector.h:77:15: error: expected '=' before '__attribute__'
   77 | namespace std _GLIBCXX_VISIBILITY(default)
      |               ^~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:77:15: error: expected identifier before '__attribute__'
In file included from /usr/include/c++/14/vector:66:
/usr/include/c++/14/bits/stl_vector.h:77:14: error: expected ';' before '__attribute__'
   77 | namespace std _GLIBCXX_VISIBILITY(default)
      |              ^
      |              ;
/usr/include/c++/14/bits/stl_vector.h:78:1: error: expected primary-expression before '{' token
   78 | {
      | ^
/usr/include/c++/14/bits/stl_bvector.h:68:15: error: expected '=' before '__attribute__'
   68 | namespace std _GLIBCXX_VISIBILITY(default)
      |               ^~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_bvector.h:68:15: error: expected identifier before '__attribute__'
In file included from /usr/include/c++/14/vector:67:
/usr/include/c++/14/bits/stl_bvector.h:68:14: error: expected ';' before '__attribute__'
   68 | namespace std _GLIBCXX_VISIBILITY(default)
      |              ^
      |              ;
/usr/include/c++/14/bits/stl_bvector.h:69:1: error: expected primary-expression before '{' token
   69 | {
      | ^
/usr/include/c++/14/bits/vector.tcc:59:15: error: expected '=' before '__attribute__'
   59 | namespace std _GLIBCXX_VISIBILITY(default)
      |               ^~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/vector.tcc:59:15: error: expected identifier before '__attribute__'
In file included from /usr/include/c++/14/vector:72:
/usr/include/c++/14/bits/vector.tcc:59:14: error: expected ';' before '__attribute__'
   59 | namespace std _GLIBCXX_VISIBILITY(default)
      |              ^
      |              ;
/usr/include/c++/14/bits/vector.tcc:60:1: error: expected primary-expression before '{' token
   60 | {
      | ^
/usr/include/c++/14/bits/vector.tcc:1218:15: error: expected '=' before '__attribute__'
 1218 | namespace std _GLIBCXX_VISIBILITY(default)
      |               ^~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/vector.tcc:1218:15: error: expected identifier before '__attribute__'
/usr/include/c++/14/bits/vector.tcc:1218:14: error: expected ';' before '__attribute__'
 1218 | namespace std _GLIBCXX_VISIBILITY(default)
      |              ^
      |              ;
/usr/include/c++/14/bits/vector.tcc:1219:1: error: expected primary-expression before '{' token
 1219 | {
      | ^
/usr/include/c++/14/vector:88:15: error: expected '=' before '__attribute__'
   88 | namespace std _GLIBCXX_VISIBILITY(default)
      |               ^~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/vector:88:15: error: expected identifier before '__attribute__'
/usr/include/c++/14/vector:88:14: error: expected ';' before '__attribute__'
   88 | namespace std _GLIBCXX_VISIBILITY(default)
      |              ^
      |              ;
/usr/include/c++/14/vector:89:1: error: expected primary-expression before '{' token
   89 | {
      | ^
/usr/include/c++/14/bits/algorithmfwd.h:42:15: error: expected '=' before '__attribute__'
   42 | namespace std _GLIBCXX_VISIBILITY(default)
      |               ^~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/algorithmfwd.h:42:15: error: expected identifier before '__attribute__'
In file included from /usr/include/c++/14/bits/stl_algo.h:59,
                 from /usr/include/c++/14/algorithm:61,
                 from a.cc:24:
/usr/include/c++/14/bits/algorithmfwd.h:42:14: error: expected ';' before '__attribute__'
   42 | namespace std _GLIBCXX_VISIBILITY(default)
      |              ^
      |              ;
/usr/include/c++/14/bits/algorithmfwd.h:43:1: error: expected primary-expression before '{' token
   43 | {
      | ^
/usr/include/c++/14/bits/stl_heap.h:63:15: error: expected '=' before '__attribute__'
   63 | namespace std _GLIBCXX_VISIBILITY(default)
      |               ^~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_heap.h:63:15: error: expected identifier before '__attribute__'
In file included from /usr/include/c++/14/bits/stl_algo.h:61:
/usr/include/c++/14/bits/stl_heap.h:63:14: error: expected ';' before '__attribute__'
   63 | namespace std _GLIBCXX_VISIBILITY(default)
      |              ^
      |              ;
/usr/include/c++/14/bits/stl_heap.h:64:1: error: expected primary-expression before '{' token
   64 | {
      | ^
/usr/include/c++/14/bits/uniform_int_dist.h:41:15: error: expected '=' before '__attribute__'
   41 | namespace std _GLIBCXX_VISIBILITY(default)
      |               ^~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/uniform_int_dist.h:41:15: error: expected identifier before '__attribute__'
In file included from /usr/include/c++/14/bits/stl_algo.h:65:
/usr/include/c++/14/bits/uniform_int_dist.h:41:14: error: expected ';' before '__attribute__'
   41 | namespace std _GLIBCXX_VISIBILITY(default)
      |              ^
      |              ;
/usr/include/c++/14/bits/uniform_int_dist.h:42:1: error: expected primary-expression before '{' token
   42 | {
      | ^
/usr/include/c++/14/bits/stl_tempbuf.h:65:15: error: expected '=' before '__attribute__'
   65 | namespace std _GLIBCXX_VISIBILITY(default)
      |               ^~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_tempbuf.h:65:15: error: expected identifier before '__attribute__'
In file included from /usr/include/c++/14/bits/stl_algo.h:69:
/usr/include/c++/14/bits/stl_tempbuf.h:65:14: error: expected ';' before '__attribute__'
   65 | namespace std _GLIBCXX_VISIBILITY(default)
      |              ^
      |              ;
/usr/include/c++/14/bits/stl_tempbuf.h:66:1: error: expected primary-expression before '{' token
   66 | {
      | ^
/usr/include/c++/14/bits/stl_algo.h:77:15: error: expected '=' before '__attribute__'
   77 | namespace std _GLIBCXX_VISIBILITY(default)
      |               ^~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algo.h:77:15: error: expected identifier before '__attribute__'
/usr/include/c++/14/bits/stl_algo.h:77:14: error: expected ';' before '__attribute__'
   77 | namespace std _GLIBCXX_VISIBILITY(default)
      |              ^
      |              ;
/usr/include/c++/14/bits/stl_algo.h:78:1: error: expected primary-expression before '{' token
   78 | {
      | ^
In file included from /usr/include/c++/14/pstl/glue_algorithm_defs.h:15,
                 from /usr/include/c++/14/algorithm:86:
/usr/include/c++/14/pstl/execution_defs.h:15:1: error: 'namespace' definition is not allowed here
   15 | namespace __pstl
      | ^~~~~~~~~
/usr/include/c++/14/pstl/glue_algorithm_defs.h:17:1: error: 'namespace' definition is not allowed here
   17 | namespace std
      | ^~~~~~~~~
In file included from /usr/include/c++/14/bits/stl_tree.h:69,
                 from /usr/include/c++/14/map:62,
                 from a.cc:25:
/usr/include/c++/14/ext/aligned_buffer.h:40:1: error: 'namespace' definition is not allowed here
   40 | namespace __gnu_cxx
      | ^~~~~~~~~
/usr/include/c++/14/bits/node_handle.h:44:15: error: expected '=' before '__attribute__'
   44 | namespace std _GLIBCXX_VISIBILITY(default)
      |               ^~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/node_handle.h:44:15: error: expected identifier before '__attribute__'
In file included from /usr/include/c++/14/bits/stl_tree.h:72:
/usr/include/c++/14/bits/node_handle.h:44:14: error: expected ';' before '__attribute__'
   44 | namespace std _GLIBCXX_VISIBILITY(default)
      |              ^
      |              ;
/usr/include/c++/14/bits/node_handle.h:45:1: error: expected primary-expression before '{' token
   45 | {
      | ^
/usr/include/c++/14/bits/stl_tree.h:75:15: error: expected '=' before '__attribute__'
   75 | namespace std _GLIBCXX_VISIBILITY(default)
      |               ^~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_tree.h:75:15: error: expected identifier before '__attribute__'
/usr/include/c++/14/bits/stl_tree.h:75:14: error: expected ';' before '__attribute__'
   75 | namespace std _GLIBCXX_VISIBILITY(default)
      |              ^
      |              ;
/usr/include/c++/14/bits/stl_tree.h:76:1: error: expected primary-expression before '{' token
   76 | {
      | ^
/usr/include/c++/14/bits/stl_map.h:66:15: error: expected '=' before '__attribute__'
   66 | namespace std _GLIBCXX_VISIBILITY(default)
      |               ^~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_map.h:66:15: error: expected identifier before '__attribute__'
In file included from /usr/include/c++/