Language: C++

#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
using namespace std;
 
typedef long long ll;
typedef pair<int, int> P;
const double PI = 3.1415926535897932;   // acos(-1)
const double EPS = 1e-15;
const int mod = 1e+9 + 7;
const int INF = 1e+9;

bool used[200005];

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int n, q;
    cin >> n >> q;
    vector<tuple<int, int, int>> tup(n);
    set<P> s;
    for(int i = 0; i < n; ++i){
        int s, t, x;
        cin >> s >> t >> x;
        s -= x;
        t -= x;
        tup[i] = tie(x, s, t);
    }
    for(int i = 0; i < q; ++i){
        int d;
        cin >> d;
        s.insert(P(d, i));
    }
    
    sort(tup.begin(), tup.end());
    vector<int> res(q, -1);
    for(int i = 0; i < n; ++i){
        int x, st, term;
        tie(x, st, term) = tup[i];
        auto it = s.lower_bound(s.begin(), s.end(), P(st, -1));
        while(it != s.end()){
            if(it->first >= term)   break;
            res[it->second] = x;
            auto tmp = it++;
            s.erase(tmp);
        }
    }

    for(int i = 0; i < q; ++i){
        cout << res[i] << "\n";
    }
}


Compiler output:
a.cc: In function 'int main()':
a.cc:57:32: error: no matching function for call to 'std::set<std::pair<int, int> >::lower_bound(std::set<std::pair<int, int> >::iterator, std::set<std::pair<int, int> >::iterator, P)'
   57 |         auto it = s.lower_bound(s.begin(), s.end(), P(st, -1));
      |                   ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/set:63,
                 from a.cc:8:
/usr/include/c++/14/bits/stl_set.h:841:9: note: candidate: 'template<class _Kt> decltype ((std::set<_Key, _Compare, _Alloc>::iterator)(((std::set<_Key, _Compare, _Alloc>*)this)->std::set<_Key, _Compare, _Alloc>::_M_t._M_lower_bound_tr(__x))) std::set<_Key, _Compare, _Alloc>::lower_bound(const _Kt&) [with _Key = std::pair<int, int>; _Compare = std::less<std::pair<int, int> >; _Alloc = std::allocator<std::pair<int, int> >]'
  841 |         lower_bound(const _Kt& __x)
      |         ^~~~~~~~~~~
/usr/include/c++/14/bits/stl_set.h:841:9: note:   candidate expects 1 argument, 3 provided
/usr/include/c++/14/bits/stl_set.h:847:9: note: candidate: 'template<class _Kt> decltype ((std::set<_Key, _Compare, _Alloc>::const_iterator)(((const std::set<_Key, _Compare, _Alloc>*)this)->std::set<_Key, _Compare, _Alloc>::_M_t._M_lower_bound_tr(__x))) std::set<_Key, _Compare, _Alloc>::lower_bound(const _Kt&) const [with _Key = std::pair<int, int>; _Compare = std::less<std::pair<int, int> >; _Alloc = std::allocator<std::pair<int, int> >]'
  847 |         lower_bound(const _Kt& __x) const
      |         ^~~~~~~~~~~
/usr/include/c++/14/bits/stl_set.h:847:9: note:   candidate expects 1 argument, 3 provided
/usr/include/c++/14/bits/stl_set.h:831:7: note: candidate: 'std::set<_Key, _Compare, _Alloc>::iterator std::set<_Key, _Compare, _Alloc>::lower_bound(const key_type&) [with _Key = std::pair<int, int>; _Compare = std::less<std::pair<int, int> >; _Alloc = std::allocator<std::pair<int, int> >; iterator = std::_Rb_tree<std::pair<int, int>, std::pair<int, int>, std::_Identity<std::pair<int, int> >, std::less<std::pair<int, int> >, std::allocator<std::pair<int, int> > >::const_iterator; key_type = std::pair<int, int>]'
  831 |       lower_bound(const key_type& __x)
      |       ^~~~~~~~~~~
/usr/include/c++/14/bits/stl_set.h:831:7: note:   candidate expects 1 argument, 3 provided
/usr/include/c++/14/bits/stl_set.h:835:7: note: candidate: 'std::set<_Key, _Compare, _Alloc>::const_iterator std::set<_Key, _Compare, _Alloc>::lower_bound(const key_type&) const [with _Key = std::pair<int, int>; _Compare = std::less<std::pair<int, int> >; _Alloc = std::allocator<std::pair<int, int> >; const_iterator = std::_Rb_tree<std::pair<int, int>, std::pair<int, int>, std::_Identity<std::pair<int, int> >, std::less<std::pair<int, int> >, std::allocator<std::pair<int, int> > >::const_iterator; key_type = std::pair<int, int>]'
  835 |       lower_bound(const key_type& __x) const
      |       ^~~~~~~~~~~
/usr/include/c++/14/bits/stl_set.h:835:7: note:   candidate expects 1 argument, 3 provided