Language: C++

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define in insert
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int INF = 1e9 + 5;
bool f(pair<int ,int > l, pair<int, int> r){
    return l.f < r.f;
}#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define in insert
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int INF = 1e9 + 5;
bool f(pair<ll ,ll > l, pair<ll, ll> r){
    return l.f < r.f;
}
int main(){
    ll n, m;
    cin >> n >> m;
    vector<pair<ll, ll> > v;
    for(int i = 0; i < n; i++) {
        int x, y;
        cin >> x >> y;
        v.pb(mp(x, y));
    }
    sort(v.begin(), v.end() , f);
    int cnt = 0;
    for(int i = 0; i < n; i++){
        if(m > v[i].s){
            m -= v[i].s;
            cnt+=v[i].f*v[i].s;
        }else{  
            cnt+=m*v[i].f;
            break;
        }
    }
    cout << cnt;
}
int main(){
    int n, m;
    cin >> n >> m;
    vector<pair<int, int> > v;
    for(int i = 0; i < n; i++) {
        int x, y;
        cin >> x >> y;
        v.pb(mp(x, y));
    }#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define in insert
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int INF = 1e9 + 5;
bool f(pair<ll ,ll > l, pair<ll, ll> r){
    return l.f < r.f;
}
int main(){
    ll n, m;
    cin >> n >> m;
    vector<pair<ll, ll> > v;
    for(int i = 0; i < n; i++) {
        ll x, y;
        cin >> x >> y;
        v.pb(mp(x, y));
    }
    sort(v.begin(), v.end() , f);
    int cnt = 0;
    for(int i = 0; i < n; i++){
        if(m > v[i].s){
            m -= v[i].s;
            cnt+=v[i].f*v[i].s;
        }else{  
            cnt+=m*v[i].f;
            break;
        }
    }
    cout << cnt;
}
    sort(v.begin(), v.end() , f);
    int cnt = 0;
    for(int i = 0; i < n; i++){
        if(m > v[i].s){
            m -= v[i].s;
            cnt+=v[i].f*v[i].s;
        }else{  
            cnt+=m*v[i].f;
            break;
        }
    }
    cout << cnt;
}

Compiler output:
a.cc:14:2: error: stray '#' in program
   14 | }#include <bits/stdc++.h>
      |  ^
a.cc:58:6: error: stray '#' in program
   58 |     }#include <bits/stdc++.h>
      |      ^
a.cc:14:3: error: 'include' does not name a type
   14 | }#include <bits/stdc++.h>
      |   ^~~~~~~
a.cc:24:11: error: redefinition of 'const int INF'
   24 | const int INF = 1e9 + 5;
      |           ^~~
a.cc:11:11: note: 'const int INF' previously defined here
   11 | const int INF = 1e9 + 5;
      |           ^~~
a.cc: In function 'int main()':
a.cc:37:9: error: no matching function for call to 'sort(std::vector<std::pair<long long int, long long int> >::iterator, std::vector<std::pair<long long int, long long int> >::iterator, <unresolved overloaded function type>)'
   37 |     sort(v.begin(), v.end() , f);
      |     ~~~~^~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:61,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algo.h:4762:5: note: candidate: 'template<class _RAIter> void std::sort(_RAIter, _RAIter)'
 4762 |     sort(_RandomAccessIterator __first, _RandomAccessIterator __last)
      |     ^~~~
/usr/include/c++/14/bits/stl_algo.h:4762:5: note:   candidate expects 2 arguments, 3 provided
/usr/include/c++/14/bits/stl_algo.h:4793:5: note: candidate: 'template<class _RAIter, class _Compare> void std::sort(_RAIter, _RAIter, _Compare)'
 4793 |     sort(_RandomAccessIterator __first, _RandomAccessIterator __last,
      |     ^~~~
/usr/include/c++/14/bits/stl_algo.h:4793:5: note:   template argument deduction/substitution failed:
a.cc:37:9: note:   couldn't deduce template parameter '_Compare'
   37 |     sort(v.begin(), v.end() , f);
      |     ~~~~^~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:86:
/usr/include/c++/14/pstl/glue_algorithm_defs.h:292:1: note: candidate: 'template<class _ExecutionPolicy, class _RandomAccessIterator, class _Compare> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, void> std::sort(_ExecutionPolicy&&, _RandomAccessIterator, _RandomAccessIterator, _Compare)'
  292 | sort(_ExecutionPolicy&& __exec, _RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp);
      | ^~~~
/usr/include/c++/14/pstl/glue_algorithm_defs.h:292:1: note:   candidate expects 4 arguments, 3 provided
/usr/include/c++/14/pstl/glue_algorithm_defs.h:296:1: note: candidate: 'template<class _ExecutionPolicy, class _RandomAccessIterator> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, void> std::sort(_ExecutionPolicy&&, _RandomAccessIterator, _RandomAccessIterator)'
  296 | sort(_ExecutionPolicy&& __exec, _RandomAccessIterator __first, _RandomAccessIterator __last);
      | ^~~~
/usr/include/c++/14/pstl/glue_algorithm_defs.h:296:1: note:   template argument deduction/substitution failed:
In file included from /usr/include/c++/14/pstl/glue_algorithm_defs.h:15:
/usr/include/c++/14/pstl/execution_defs.h: In substitution of 'template<class _ExecPolicy, class _Tp> using __pstl::__internal::__enable_if_execution_policy = typename std::enable_if<__pstl::execution::v1::is_execution_policy<typename std::remove_cv<typename std::remove_reference<_Tp>::type>::type>::value, _Tp>::type [with _ExecPolicy = __gnu_cxx::__normal_iterator<std::pair<long long int, long long int>*, std::vector<std::pair<long long int, long long int> > >; _Tp = void]':
/usr/include/c++/14/pstl/glue_algorithm_defs.h:296:1:   required by substitution of 'template<class _ExecutionPolicy, class _RandomAccessIterator> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, void> std::sort(_ExecutionPolicy&&, _RandomAccessIterator, _RandomAccessIterator) [with _ExecutionPolicy = __gnu_cxx::__normal_iterator<std::pair<long long int, long long int>*, std::vector<std::pair<long long int, long long int> > >; _RandomAccessIterator = __gnu_cxx::__normal_iterator<std::pair<long long int, long long int>*, std::vector<std::pair<long long int, long long int> > >]'
a.cc:37:9:   required from here
   37 |     sort(v.begin(), v.end() , f);
      |     ~~~~^~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/pstl/execution_defs.h:82:7: error: no type named 'type' in 'struct std::enable_if<false, void>'
   82 | using __enable_if_execution_policy =
      |       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc: At global scope:
a.cc:50:5: error: redefinition of 'int main()'
   50 | int main(){
      |     ^~~~
a.cc:28:5: note: 'int main()' previously defined here
   28 | int main(){
      |     ^~~~
a.cc: In function 'int main()':
a.cc:58:7: error: 'include' was not declared in this scope
   58 |     }#include <bits/stdc++.h>
      |       ^~~~~~~
a.cc:58:16: error: 'bits' was not declared in this scope
   58 |     }#include <bits/stdc++.h>
      |                ^~~~
a.cc:58:21: error: 'stdc' was not declared in this scope; did you mean 'std'?
   58 |     }#include <bits/stdc++.h>
      |                     ^~~~
      |                     std
a.cc:59:1: error: expected primary-expression before 'using'
   59 | using namespace std;
      | ^~~~~
a.cc:69:40: error: a function-definition is not allowed here before '{' token
   69 | bool f(pair<ll ,ll > l, pair<ll, ll> r){
      |                                        ^
a.cc:72:9: warning: empty parentheses were disambiguated as a function declaration [-Wvexing-parse]
   72 | int main(){
      |         ^~
a.cc:72:9: note: remove parentheses to default-initialize a variable
   72 | int main(){
      |         ^~
      |         --
a.cc:72:9: note: or replace parentheses with braces to value-initialize a variable
a.cc:72:11: error: a function-definition is not allowed here before '{' token
   72 | int main(){
      |           ^
a.cc:94:9: error: no matching function for call to 'sort(std::vector<std::pair<int, int> >::iterator, std::vector<std::pair<int, int> >::iterator, <unresolved overloaded function type>)'
   94 |     sort(v.begin(), v.end() , f);
      |     ~~~~^~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algo.h:4762:5: note: candidate: 'template<class _RAIter> void std::sort(_RAIter, _RAIter)'
 4762 |     sort(_RandomAccessIterator __first, _RandomAccessIterator __last)
      |     ^~~~
/usr/include/c++/14/bits/stl_algo.h:4762:5: note:   candidate expects 2 arguments, 3 provided
/usr/include/c++/14/bits/stl_algo.h:4793:5: note: candidate: 'template<class _RAIter, class _Compare> void std::sort(_RAIter, _RAIter, _Compare)'
 4793 |     sort(_RandomAccessIterator __first, _RandomAccessIterator __last,
      |     ^~~~
/usr/include/c++/14/bits/stl_algo.h:4793:5: note:   template argument deduction/substitution failed:
a.cc:94:9: note:   couldn't deduce template parameter '_Compare'
   94 |     sort(v.begin(), v.end() , f);
      |     ~~~~^~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/pstl/glue_algorithm_defs.h:292:1: note: candidate: 'template<class _ExecutionPolicy, class _RandomAccessIterator, class _Compare> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, void> std::sort(_ExecutionPolicy&&, _RandomAccessIterator, _RandomAccessIterator, _Compare)'
  292 | sort(_ExecutionPolicy&& __exec, _RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp);
      | ^~~~
/usr/include/c++/14/pstl/glue_algorithm_defs.h:292:1: note:   candidate expects 4 arguments, 3 provided
/usr/include/c++/14/pstl/glue_algorithm_defs.h:296:1: note: candidate: 'template<class _ExecutionPolicy, class _RandomAccessIterator> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, void> std::sort(_ExecutionPolicy&&, _RandomAccessIterator, _RandomAccessIterator)'
  296 | sort(_ExecutionPolicy&& __exec, _RandomAccessIterator __first, _RandomAccessIterator __last);
      | ^~~~
/usr/include/c++/14/pstl/glue_algorithm_defs.h:296:1: note:   template argument deduction/substitution failed:
/usr/include/c++/14/pstl/execution_defs.h: In substitution of 'template<class _ExecPolicy, class _Tp> using __pstl::__internal::__enable_if_execution_policy = typename std::enable_if<__pstl::execution::v1::is_execution_policy<typename std::remove_cv<typename std::remove_reference<_Tp>::type>::type>::value, _Tp>::type [with _ExecPolicy = __gnu_cxx::__normal_iterator<std::pair<int, int>*, std::vector<std::pair<int, int> > >; _Tp = void]':
/usr/include/c++/14/pstl/glue_algorithm_defs.h:296:1:   required by substitution of 'template<class _ExecutionPolicy, class _RandomAccessIterator> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, void> std::sort(_ExecutionPolicy&&, _RandomAccessIterator, _RandomAccessIterator) [with _ExecutionPolicy = __gnu_cxx::__normal_iterator<std::pair<int, int>*, std::vector<std::pair<int, int> > >; _RandomAccessIterator = __gnu_cxx::__normal_iterator<std::pair<int, int>*, std::vector<std::pair<int, int> > >]'
a.cc:94:9:   required from here
   94 |     sort(v.begin(), v.end() , f);
      |     ~~~~^~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/pstl/execution_defs.h:82:7: error: no type named 'type' in 'struct std::enable_if<false, void>'
   82 | using __enable_if_execution_policy =
      |       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~