Language: C++

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

int main()
{
    int N,M; cin>>N>>M;
    vector<vector<int>> v(100005);
    for(int i=0;i<N;i++){
        int a,b; cin>>a>>b;
        v[a].push_back(b);
    }

    int ans=0;
    priority_queue Q;
    for(int i=1;i<=M;i++){
        for(int x:v[i]) Q.push(x);
        if(!Q.empty()){
            ans+=Q.top(); Q.pop();
        }
    }
    cout<<ans<<endl;

    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:14:20: error: class template argument deduction failed:
   14 |     priority_queue Q;
      |                    ^
a.cc:14:20: error: no matching function for call to 'priority_queue()'
In file included from /usr/include/c++/14/queue:66,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:157,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_queue.h:691:9: note: candidate: 'template<class _Tp, class _Sequence, class _Compare, class _InputIterator, class _Alloc, class _Requires> priority_queue(_InputIterator, _InputIterator, const _Compare&, _Sequence&&, const _Alloc&)-> std::priority_queue<_Tp, _Sequence, _Compare>'
  691 |         priority_queue(_InputIterator __first, _InputIterator __last,
      |         ^~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_queue.h:691:9: note:   candidate expects 5 arguments, 0 provided
/usr/include/c++/14/bits/stl_queue.h:679:9: note: candidate: 'template<class _Tp, class _Sequence, class _Compare, class _InputIterator, class _Alloc, class, class _Requires> priority_queue(_InputIterator, _InputIterator, const _Compare&, const _Sequence&, const _Alloc&)-> std::priority_queue<_Tp, _Sequence, _Compare>'
  679 |         priority_queue(_InputIterator __first, _InputIterator __last,
      |         ^~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_queue.h:679:9: note:   candidate expects 5 arguments, 0 provided
/usr/include/c++/14/bits/stl_queue.h:671:9: note: candidate: 'template<class _Tp, class _Sequence, class _Compare, class _InputIterator, class _Alloc, class, class _Requires> priority_queue(_InputIterator, _InputIterator, const _Compare&, const _Alloc&)-> std::priority_queue<_Tp, _Sequence, _Compare>'
  671 |         priority_queue(_InputIterator __first, _InputIterator __last,
      |         ^~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_queue.h:671:9: note:   candidate expects 4 arguments, 0 provided
/usr/include/c++/14/bits/stl_queue.h:663:9: note: candidate: 'template<class _Tp, class _Sequence, class _Compare, class _InputIterator, class _Alloc, class, class _Requires> priority_queue(_InputIterator, _InputIterator, const _Alloc&)-> std::priority_queue<_Tp, _Sequence, _Compare>'
  663 |         priority_queue(_InputIterator __first, _InputIterator __last,
      |         ^~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_queue.h:663:9: note:   candidate expects 3 arguments, 0 provided
/usr/include/c++/14/bits/stl_queue.h:649:9: note: candidate: 'template<class _Tp, class _Sequence, class _Compare, class _InputIterator, class> priority_queue(_InputIterator, _InputIterator, const _Compare&, _Sequence&&)-> std::priority_queue<_Tp, _Sequence, _Compare>'
  649 |         priority_queue(_InputIterator __first, _InputIterator __last,
      |         ^~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_queue.h:649:9: note:   candidate expects 4 arguments, 0 provided
/usr/include/c++/14/bits/stl_queue.h:638:9: note: candidate: 'template<class _Tp, class _Sequence, class _Compare, class _InputIterator, class> priority_queue(_InputIterator, _InputIterator, const _Compare&, const _Sequence&)-> std::priority_queue<_Tp, _Sequence, _Compare>'
  638 |         priority_queue(_InputIterator __first, _InputIterator __last,
      |         ^~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_queue.h:638:9: note:   candidate expects 4 arguments, 0 provided
/usr/include/c++/14/bits/stl_queue.h:629:9: note: candidate: 'template<class _Tp, class _Sequence, class _Compare, class _InputIterator, class> priority_queue(_InputIterator, _InputIterator, const _Compare&)-> std::priority_queue<_Tp, _Sequence, _Compare>'
  629 |         priority_queue(_InputIterator __first, _InputIterator __last,
      |         ^~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_queue.h:629:9: note:   candidate expects 2 arguments, 0 provided
/usr/include/c++/14/bits/stl_queue.h:594:9: note: candidate: 'template<class _Tp, class _Sequence, class _Compare, class _Alloc, class _Requires> priority_queue(std::priority_queue<_Tp, _Sequence, _Compare>&&, const _Alloc&)-> std::priority_queue<_Tp, _Sequence, _Compare>'
  594 |         priority_queue(priority_queue&& __q, const _Alloc& __a)
      |         ^~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_queue.h:594:9: note:   candidate expects 2 arguments, 0 provided
/usr/include/c++/14/bits/stl_queue.h:590:9: note: candidate: 'template<class _Tp, class _Sequence, class _Compare, class _Alloc, class _Requires> priority_queue(const std::priority_queue<_Tp, _Sequence, _Compare>&, const _Alloc&)-> std::priority_queue<_Tp, _Sequence, _Compare>'
  590 |         priority_queue(const priority_queue& __q, const _Alloc& __a)
      |         ^~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_queue.h:590:9: note:   candidate expects 2 arguments, 0 provided
/usr/include/c++/14/bits/stl_queue.h:585:9: note: candidate: 'template<class _Tp, class _Sequence, class _Compare, class _Alloc, class _Requires> priority_queue(const _Compare&, _Sequence&&, const _Alloc&)-> std::priority_queue<_Tp, _Sequence, _Compare>'
  585 |         priority_queue(const _Compare& __x, _Sequence&& __c, const _Alloc& __a)
      |         ^~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_queue.h:585:9: note:   candidate expects 3 arguments, 0 provided
/usr/include/c++/14/bits/stl_queue.h:579:9: note: candidate: 'template<class _Tp, class _Sequence, class _Compare, class _Alloc, class _Requires> priority_queue(const _Compare&, const _Sequence&, const _Alloc&)-> std::priority_queue<_Tp, _Sequence, _Compare>'
  579 |         priority_queue(const _Compare& __x, const _Sequence& __c,
      |         ^~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_queue.h:579:9: note:   candidate expects 3 arguments, 0 provided
/usr/include/c++/14/bits/stl_queue.h:573:9: note: candidate: 'template<class _Tp, class _Sequence, class _Compare, class _Alloc, class _Requires> priority_queue(const _Compare&, const _Alloc&)-> std::priority_queue<_Tp, _Sequence, _Compare>'
  573 |         priority_queue(const _Compare& __x, const _Alloc& __a)
      |         ^~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_queue.h:573:9: note:   candidate expects 2 arguments, 0 provided
/usr/include/c++/14/bits/stl_queue.h:569:9: note: candidate: 'template<class _Tp, class _Sequence, class _Compare, class _Alloc, class _Requires> priority_queue(const _Alloc&)-> std::priority_queue<_Tp, _Sequence, _Compare>'
  569 |         priority_queue(const _Alloc& __a)
      |         ^~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_queue.h:569:9: note:   candidate expects 1 argument, 0 provided
/usr/include/c++/14/bits/stl_queue.h:563:7: note: candidate: 'template<class _Tp, class _Sequence, class _Compare> priority_queue(const _Compare&, _Sequence&&)-> std::priority_queue<_Tp, _Sequence, _Compare>'
  563 |       priority_queue(const _Compare& __x, _Sequence&& __s = _Sequence())
      |       ^~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_queue.h:563:7: note:   candidate expects 1 argument, 0 provided
/usr/include/c++/14/bits/stl_queue.h:558:7: note: candidate: 'template<class _Tp, class _Sequence, class _Compare> priority_queue(const _Compare&, const _Sequence&)-> std::priority_queue<_Tp, _Sequence, _Compare>'
  558 |       priority_queue(const _Compare& __x, const _Sequence& __s)
      |       ^~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_queue.h:558:7: note:   candidate expects 2 arguments, 0 provided
/usr/include/c++/14/bits/stl_queue.h:554:9: note: candidate: 'template<class _Tp, class _Sequence, class _Compare, class _Seq, class _Requires> priority_queue()-> std::priority_queue<_Tp, _Sequence, _Compare>'
  554 |         priority_queue()
      |         ^~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_queue.h:554:9: note:   template argument deduction/substitution failed:
a.cc:14:20: note:   couldn't deduce template parameter '_Tp'
   14 |     priority_queue Q;
      |                    ^
/usr/include/c++/14/bits/stl_queue.h:496:11: note: candidate: 'template<class _Tp, class _Sequence, class _Compare> priority_queue(std::priority_queue<_Tp, _Sequence, _Compare>)-> std::priority_queue<_Tp, _Sequence, _Compare>'
  496 |     class priority_queue
      |           ^~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_queue.h:496:11: note:   candidate expects 1 argument, 0 provided
/usr/include/c++/14/bits/stl_queue.h:818:5: note: candidate: 'template<class _Compare, class _Container, class _Allocator, class, class> std::priority_queue(_Compare, _Container, _Allocator)-> priority_queue<typename _Container::value_type, _Container, _Compare>'
  818 |     priority_queue(_Compare, _Container, _Allocator)
      |     ^~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_queue.h:818:5: note:   candidate expects 3 arguments, 0 provided
/usr/include/c++/14/bits/stl_queue.h:811:5: note: candidate: 'template<class _InputIterator, class _ValT, class _Compare, class _Container, class, class, class> std::priority_queue(_InputIterator, _InputIterator, _Compare, _Container)-> priority_queue<_ValT, _Container, _Compare>'
  811 |     priority_queue(_InputIterator, _InputIterator, _Compare = _Compare(),
      |     ^~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_queue.h:811:5: note:   candidate expects 2 arguments, 0 provided
/usr/include/c++/14/bits/stl_queue.h:801:5: note: candidate: 'template<class _Compare, class _Container, class, class> std::priority_queue(_Compare, _Container)-> priority_queue<typename _Container::value_type, _Container, _Compare>'
  801 |     priority_queue(_Compare, _Container)
      |     ^~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_queue.h:801:5: note:   candidate expects 2 arguments, 0 provided