Language: C++

#include <iostream>
#include <ios>
#include <iomanip>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <cstdlib>
#include <cstring>
#include <cmath>
using namespace std;

#define MOD 1000000007
#define INF 1e9+7
#define rep(i, n) for(int i=0; i<n; ++i)
typedef long long ll;

#define MAX_N 100000
#define MAX_M 100000
#define MAX_V 100
#define MAX_E 100

int dx[] = {-1, 0, 1, 0};
int dy[] = {0, -1, 0, 1};

int ddx[] = {-1, 0, 1, 0, -1, 1, -1, 1};
int ddy[] = {0, -1, 0, 1, 1, 1, -1, -1};

//--------------------------

ll n, m, cnt, maxb, index, l;
vector<pair<ll, ll>> work(MAX_N);

bool compare(const pair<ll, ll>& firstp, const pair<ll, ll>& secondp) {
  return firstp.second > secondp.second;
}

int main() {

  cin >> n >> m;
  rep(i, n) cin >> work[i].first >> work[i].second;

  sort(work.begin(), work.begin()+n);

  while(m!=0) {

    maxb = 0;

    for(int i=0; i<n-l; ++i) {
      if(work[i].first>m) break;
      else {
        if(maxb<=work[i].second) {
          maxb = work[i].second;
          index = i;
        }
      }
    }

    cnt += maxb;

    if(maxb!=0) work.erase(work.begin()+index);

    --m;
    ++l;
  }

  cout << cnt << endl;

  return 0;
}


Compiler output:
a.cc:32:21: error: 'll index' redeclared as different kind of entity
   32 | ll n, m, cnt, maxb, index, l;
      |                     ^~~~~
In file included from /usr/include/string.h:462,
                 from /usr/include/c++/14/cstring:43,
                 from a.cc:10:
/usr/include/strings.h:50:20: note: previous declaration 'const char* index(const char*, int)'
   50 | extern const char *index (const char *__s, int __c)
      |                    ^~~~~
a.cc: In function 'int main()':
a.cc:55:19: error: overloaded function with no contextual type information
   55 |           index = i;
      |                   ^
a.cc:62:40: error: no match for 'operator+' (operand types are 'std::vector<std::pair<long long int, long long int> >::iterator' and '<unresolved overloaded function type>')
   62 |     if(maxb!=0) work.erase(work.begin()+index);
      |                            ~~~~~~~~~~~~^~~~~~
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:1138:7: note: candidate: '__gnu_cxx::__normal_iterator<_Iterator, _Container> __gnu_cxx::__normal_iterator<_Iterator, _Container>::operator+(difference_type) const [with _Iterator = std::pair<long long int, long long int>*; _Container = std::vector<std::pair<long long int, long long int> >; difference_type = long int]'
 1138 |       operator+(difference_type __n) const _GLIBCXX_NOEXCEPT
      |       ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1138:33: note:   no known conversion for argument 1 from '<unresolved overloaded function type>' to '__gnu_cxx::__normal_iterator<std::pair<long long int, long long int>*, std::vector<std::pair<long long int, long long int> > >::difference_type' {aka 'long int'}
 1138 |       operator+(difference_type __n) const _GLIBCXX_NOEXCEPT
      |                 ~~~~~~~~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_iterator.h:627:5: note: candidate: 'template<class _Iterator> constexpr std::reverse_iterator<_Iterator> std::operator+(typename reverse_iterator<_Iterator>::difference_type, const reverse_iterator<_Iterator>&)'
  627 |     operator+(typename reverse_iterator<_Iterator>::difference_type __n,
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:627:5: note:   template argument deduction/substitution failed:
a.cc:62:41: note:   mismatched types 'const std::reverse_iterator<_Iterator>' and 'const char*(const char*, int) noexcept'
   62 |     if(maxb!=0) work.erase(work.begin()+index);
      |                                         ^~~~~
a.cc:62:41: note:   mismatched types 'const std::reverse_iterator<_Iterator>' and 'char*(char*, int) noexcept'
a.cc:62:41: note:   couldn't deduce template parameter '_Iterator'
/usr/include/c++/14/bits/stl_iterator.h:1798:5: note: candidate: 'template<class _Iterator> constexpr std::move_iterator<_IteratorL> std::operator+(typename move_iterator<_IteratorL>::difference_type, const move_iterator<_IteratorL>&)'
 1798 |     operator+(typename move_iterator<_Iterator>::difference_type __n,
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1798:5: note:   template argument deduction/substitution failed:
a.cc:62:41: note:   mismatched types 'const std::move_iterator<_IteratorL>' and 'const char*(const char*, int) noexcept'
   62 |     if(maxb!=0) work.erase(work.begin()+index);
      |                                         ^~~~~
a.cc:62:41: note:   mismatched types 'const std::move_iterator<_IteratorL>' and 'char*(char*, int) noexcept'
a.cc:62:41: note:   couldn't deduce template parameter '_Iterator'
In file included from /usr/include/c++/14/string:54:
/usr/include/c++/14/bits/basic_string.h:3598:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)'
 3598 |     operator+(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
      |     ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:3598:5: note:   template argument deduction/substitution failed:
a.cc:62:41: note:   'std::vector<std::pair<long long int, long long int> >::iterator' is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>'
   62 |     if(maxb!=0) work.erase(work.begin()+index);
      |                                         ^~~~~
/usr/include/c++/14/bits/basic_string.h:3616:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(const _CharT*, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)'
 3616 |     operator+(const _CharT* __lhs,
      |     ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:3616:5: note:   template argument deduction/substitution failed:
a.cc:62:41: note:   mismatched types 'const _CharT*' and '__gnu_cxx::__normal_iterator<std::pair<long long int, long long int>*, std::vector<std::pair<long long int, long long int> > >'
   62 |     if(maxb!=0) work.erase(work.begin()+index);
      |                                         ^~~~~
/usr/include/c++/14/bits/basic_string.h:3635:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(_CharT, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)'
 3635 |     operator+(_CharT __lhs, const basic_string<_CharT,_Traits,_Alloc>& __rhs)
      |     ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:3635:5: note:   template argument deduction/substitution failed:
a.cc:62:41: note:   mismatched types 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' and 'const char*(const char*, int) noexcept'
   62 |     if(maxb!=0) work.erase(work.begin()+index);
      |                                         ^~~~~
a.cc:62:41: note:   mismatched types 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' and 'char*(char*, int) noexcept'
a.cc:62:41: note:   couldn't deduce template parameter '_Traits'
/usr/include/c++/14/bits/basic_string.h:3652:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, const _CharT*)'
 3652 |     operator+(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
      |     ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:3652:5: note:   template argument deduction/substitution failed:
a.cc:62:41: note:   'std::vector<std::pair<long long int, long long int> >::iterator' is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>'
   62 |     if(maxb!=0) work.erase(work.begin()+index);
      |                                         ^~~~~
/usr/include/c++/14/bits/basic_string.h:3670:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, _CharT)'
 3670 |     operator+(const basic_string<_CharT, _Traits, _Alloc>& __lhs, _CharT __rhs)
      |     ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:3670:5: note:   template argument deduction/substitution failed:
a.cc:62:41: note:   'std::vector<std::pair<long long int, long long int> >::iterator' is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>'
   62 |     if(maxb!=0) work.erase(work.begin()+index);
      |                                         ^~~~~
/usr/include/c++/14/bits/basic_string.h:3682:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(__cxx11::basic_string<_CharT, _Traits, _Allocator>&&, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)'
 3682 |     operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs,
      |     ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:3682:5: note:   template argument deduction/substitution failed:
a.cc:62:41: note:   'std::vector<std::pair<long long int, long long int> >::iterator' is not derived from 'std::__cxx11::basic_string<_CharT, _Traits, _Allocator>'
   62 |     if(maxb!=0) work.erase(work.begin()+index);
      |                                         ^~~~~
/usr/include/c++/14/bits/basic_string.h:3689:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, __cxx11::basic_string<_CharT, _Traits, _Allocator>&&)'
 3689 |     operator+(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
      |     ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:3689:5: note:   template argument deduction/substitution failed:
a.cc:62:41: note:   'std::vector<std::pair<long long int, long long int> >::iterator' is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>'
   62 |     if(maxb!=0) work.erase(work.begin()+index);
      |                                         ^~~~~
/usr/include/c++/14/bits/basic_string.h:3696:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(__cxx11::basic_string<_CharT, _Traits, _Allocator>&&, __cxx11::basic_string<_CharT, _Traits, _Allocator>&&)'
 3696 |     operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs,
      |     ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:3696:5: note:   template argument deduction/substitution failed:
a.cc:62:41: note:   'std::vector<std::pair<long long int, long long int> >::iterator' is not derived from 'std::__cxx11::basic_string<_CharT, _Traits, _Allocator>'
   62 |     if(maxb!=0) work.erase(work.begin()+index);
      |                                         ^~~~~
/usr/include/c++/14/bits/basic_string.h:3719:5: note: candidate: 'templat