Language: C++

#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main(){
  int h,w;
  cin >> h >> w;
  
  map<int,int> s;
  multiset<int> vals;

  rep(i,w) s[i] = i;
  rep(i,w) vals.insert(0);

  rep(i,h){
    int l,r;
    cin >> l >> r;
    i--;
    r--;
    auto it = s.lower_bound(l);
    int mr = -1;
    while(it!=s.end() && it->first <= r){
      mr = max(mr,it->second)
      int x = it->first - it->second;
      vals.erase(vals.find()
      s.erase(it++);
    }
    if(mr!=-1 && r < w){
      vals.insert(r-mr);
      s[r] = mr;
    }
    int ans = -1;
    if(vals.size()>0){
      ans = *vals.begin() + (i+1);
    }
    cout << ans << endl;
  }

  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:25:30: error: expected ';' before 'int'
   25 |       mr = max(mr,it->second)
      |                              ^
      |                              ;
   26 |       int x = it->first - it->second;
      |       ~~~                     
a.cc:27:27: error: no matching function for call to 'std::multiset<int>::find()'
   27 |       vals.erase(vals.find()
      |                  ~~~~~~~~~^~
In file included from /usr/include/c++/14/set:64,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:158,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_multiset.h:787:9: note: candidate: 'template<class _Kt> decltype (std::multiset<_Key, _Compare, _Alloc>::iterator{((std::multiset<_Key, _Compare, _Alloc>*)this)->std::multiset<_Key, _Compare, _Alloc>::_M_t._M_find_tr(__x)}) std::multiset<_Key, _Compare, _Alloc>::find(const _Kt&) [with _Key = int; _Compare = std::less<int>; _Alloc = std::allocator<int>]'
  787 |         find(const _Kt& __x)
      |         ^~~~
/usr/include/c++/14/bits/stl_multiset.h:787:9: note:   candidate expects 1 argument, 0 provided
/usr/include/c++/14/bits/stl_multiset.h:793:9: note: candidate: 'template<class _Kt> decltype (std::multiset<_Key, _Compare, _Alloc>::const_iterator{((const std::multiset<_Key, _Compare, _Alloc>*)this)->std::multiset<_Key, _Compare, _Alloc>::_M_t._M_find_tr(__x)}) std::multiset<_Key, _Compare, _Alloc>::find(const _Kt&) const [with _Key = int; _Compare = std::less<int>; _Alloc = std::allocator<int>]'
  793 |         find(const _Kt& __x) const
      |         ^~~~
/usr/include/c++/14/bits/stl_multiset.h:793:9: note:   candidate expects 1 argument, 0 provided
/usr/include/c++/14/bits/stl_multiset.h:777:7: note: candidate: 'std::multiset<_Key, _Compare, _Alloc>::iterator std::multiset<_Key, _Compare, _Alloc>::find(const key_type&) [with _Key = int; _Compare = std::less<int>; _Alloc = std::allocator<int>; iterator = std::_Rb_tree<int, int, std::_Identity<int>, std::less<int>, std::allocator<int> >::const_iterator; key_type = int]'
  777 |       find(const key_type& __x)
      |       ^~~~
/usr/include/c++/14/bits/stl_multiset.h:777:7: note:   candidate expects 1 argument, 0 provided
/usr/include/c++/14/bits/stl_multiset.h:781:7: note: candidate: 'std::multiset<_Key, _Compare, _Alloc>::const_iterator std::multiset<_Key, _Compare, _Alloc>::find(const key_type&) const [with _Key = int; _Compare = std::less<int>; _Alloc = std::allocator<int>; const_iterator = std::_Rb_tree<int, int, std::_Identity<int>, std::less<int>, std::allocator<int> >::const_iterator; key_type = int]'
  781 |       find(const key_type& __x) const
      |       ^~~~
/usr/include/c++/14/bits/stl_multiset.h:781:7: note:   candidate expects 1 argument, 0 provided