Language: C++

// warm heart, wagging tail,and a smile just for you!
//                                                                     ███████████
//                                                                   ███╬╬╬╬╬╬╬╬╬╬███
//                                                                ███╬╬╬╬╬████╬╬╬╬╬╬███
//                                            ███████████       ██╬╬╬╬╬████╬╬████╬╬╬╬╬██
//                                      █████████╬╬╬╬╬████████████╬╬╬╬╬██╬╬╬╬╬╬███╬╬╬╬╬██
//                               ████████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████████╬╬╬╬╬╬██╬╬╬╬╬╬╬██
//                             ████╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████████╬╬╬╬╬╬╬╬╬╬╬██
//                           ███╬╬╬█╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬███╬╬╬╬╬╬╬█████
//                         ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬████████╬╬╬╬╬██
//                       ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬╬╬╬╬╬███
//                     ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬██
//                 ████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████╬╬╬╬╬████
//     █████████████╬╬╬╬╬╬╬╬██╬╬╬╬╬████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬██████
//   ████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬██████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██████╬╬╬╬╬╬╬███████████╬╬╬╬╬╬╬╬██╬╬╬██╬╬╬██
// ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████╬╬╬╬╬╬╬╬╬╬╬█╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬██
// ██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬▓▓▓▓▓▓╬╬╬████╬╬████╬╬╬╬╬╬╬▓▓▓▓▓▓▓▓██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬███
// ██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██████▓▓▓▓▓▓▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓▓▓▓▓▓▓██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬█████
// ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████████
//   ███╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██
//       ██████████████  ████╬╬╬╬╬╬███████████████████████████╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████
//                         ███████                           █████  ███████████████████
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
const double EPS = 1e-9;
#define INF (1LL<<60)
#define D double
#define fs first
#define sc second
#define int long long
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i = (b-1);i>=(a);i--)
#define REP(i,n)  FOR(i,0,(n))
#define RREP(i,n) RFOR(i,0,(n))
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SP << " " << 
typedef pair<int,int> P;
typedef pair<P,int> Q;
typedef vector<vector<P> > Graph;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

template<typename T>
vector<T> compress(vector<T> v){
  sort(v.begin(),v.end());
  v.erase(unique(v.begin(),v.end()),v.end());
  return v;
}

template<typename T>
map<T, int> dict(const vector<T> &v){
  map<T, int> res;
  for(int i=0;i<(int)v.size();i++)
    res[v[i]]=i;
  return res;
}

template<typename T, typename E>
struct SegmentTree{
  using F = function<T(T,T)>;
  using G = function<T(T,E,int)>;
  using H = function<E(E,E)>;
    int n;
    vector<T> dat;
    vector<E> laz;
    F f;
    G g;
    H h;
    T ti;
    E ei;
    
    SegmentTree(F f,G g,H h,T ti,E ei):
    f(f),g(g),h(h),ti(ti),ei(ei){}

  void init(int n_){
    n=1;
    while(n<n_) n<<=1;
    dat.assign((n<<1)-1,ti);
    laz.assign((n<<1)-1,ei);
  }
  void build(const vector<T> &v){
    int n_=v.size();
    init(n_);
        REP(i,n_) dat[i+n-1] = v[i];
        for(int i=n-2; i>=0; --i){
            dat[i] = f(dat[(i<<1)+1],dat[(i<<1)+2]);
        }
  }

    void eval(int k,int l,int r){
        if(laz[k]==ei)return;
        dat[k] = g(dat[k], laz[k], r-l);
        if(r-l>1){
            laz[(k<<1)+1] = h(laz[(k<<1)+1], laz[k]);
            laz[(k<<1)+2] = h(laz[(k<<1)+2], laz[k]);
        }
        laz[k]=ei;
    }

    void update(int a, int b, E x,int k=0,int l=0,int r=-1){
        if(r<0)r=n;
        eval(k,l,r);
        if(r<=a||b<=l)return;
        if(a<=l&&r<=b){
            laz[k] = h(laz[k], x);
            eval(k,l,r);
        }
        else {
            update(a,b,x,(k<<1)+1,l,(l+r)/2);
            update(a,b,x,(k<<1)+2,(l+r)/2,r);
            dat[k]=f(dat[(k<<1)+1], dat[(k<<1)+2]);
        }
    }

    T query(int a,int b,int k=0,int l=0,int r=-1){
        if(r<0)r=n;
        eval(k,l,r);
        if(r<=a||b<=l)return ti;
        if(a<=l&&r<=b)return dat[k];
        T xl=query(a,b,(k<<1)+1,l,(l+r)/2);
        T xr=query(a,b,(k<<1)+2,(l+r)/2,r);
        return f(xl, xr);
    }

    int find(int k=0,int l=0, int r=-1){
        if(r<0)r=n;
        eval(k,l,r);
        if(dat[k]>=0)return -1;
        if(r-l==1)return l;
        T xr=query((l+r)/2,r,(k<<1)+2,(l+r)/2,r);
        if(xr<0)return find((k<<1)+2,(l+r)/2,r);
        return find((k<<1)+1,l,(l+r)/2);
    }
};

signed main(){
  ios::sync_with_stdio(false);
  cin.tie(0);

  int n,q;
  cin >> n >> q;

  vector<Q> a(n);
  vec b;
  REP(i,n){
    int x;
    cin >> a[i].fs.fs >> a[i].fs.sc >> x;
    a[i].fs.fs -= x;
    a[i].fs.sc -= x;
    a[i].sc = x;
    b.push_back(a[i].fs.fs);
    b.push_back(a[i].fs.sc);
    b.push_back(a[i].sc);
  }

  vector<int> d(q);
  REP(i,q) cin >> d[i], b.push_back(d[i]);

  auto r = compress(b);
  auto v = dict(r);

  auto f = [](int a,int b){return min(a,b);};

  SegmentTree<int,int> seg(f,f,f,INF,INF);
  seg.build(vec(v.size(),INF));

  REP(i,n){
    //cout << a[i].fs.fs SP a[i].fs.sc SP v[a[i].fs.fs] SP v[a[i].fs.sc]<< endl;
    seg.update(v[a[i].fs.fs],v[a[i].fs.sc],a[i].sc);
  }

  REP(i,q){
    int ans = seg.query(v[d[i]],v[d[i]]+1);
    if(ans == INF) cout << -1 << endl;
    else cout << ans << endl;
  }

  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:169:41: error: no matching function for call to 'SegmentTree<long long int, long long int>::SegmentTree(main()::<lambda(long long int, long long int)>&, main()::<lambda(long long int, long long int)>&, main()::<lambda(long long int, long long int)>&, long long int, long long int)'
  169 |   SegmentTree<int,int> seg(f,f,f,INF,INF);
      |                                         ^
a.cc:77:5: note: candidate: 'SegmentTree<T, E>::SegmentTree(F, G, H, T, E) [with T = long long int; E = long long int; F = std::function<long long int(long long int, long long int)>; G = std::function<long long int(long long int, long long int, long long int)>; H = std::function<long long int(long long int, long long int)>]'
   77 |     SegmentTree(F f,G g,H h,T ti,E ei):
      |     ^~~~~~~~~~~
a.cc:77:23: note:   no known conversion for argument 2 from 'main()::<lambda(long long int, long long int)>' to 'SegmentTree<long long int, long long int>::G' {aka 'std::function<long long int(long long int, long long int, long long int)>'}
   77 |     SegmentTree(F f,G g,H h,T ti,E ei):
      |                     ~~^
a.cc:64:8: note: candidate: 'SegmentTree<long long int, long long int>::SegmentTree(const SegmentTree<long long int, long long int>&)'
   64 | struct SegmentTree{
      |        ^~~~~~~~~~~
a.cc:64:8: note:   candidate expects 1 argument, 5 provided
a.cc:64:8: note: candidate: 'SegmentTree<long long int, long long int>::SegmentTree(SegmentTree<long long int, long long int>&&)'
a.cc:64:8: note:   candidate expects 1 argument, 5 provided