Language: C++

#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <stack>
#include <complex>
#include <stdlib.h>
#include <stdio.h>
#include <functional>
#include <cfloat>
#include <math.h>


#define fs first
#define sc second

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

// 0-index
template <class T0, class T1>
class LazySegmentTree{
private:
    void eval(int k, int len){
        node[k] = g(node[k], p(lazy[k], len));

        if(k < n-1){
            lazy[2 * k + 1] = f1(lazy[2 * k + 1], lazy[k]);
            lazy[2 * k + 2] = f1(lazy[2 * k + 2], lazy[k]);
        }
        lazy[k] = u1;
    }

    void update(int a, int b, T1 x, int k, int l, int r){
        eval(k, r - l);
        if(b <= l || r <= a) return;
        if(a <= l && r <= b){
            lazy[k] = f1(lazy[k], x);
            eval(k, r - l);
        }
        else{
            update(a, b, x, 2 * k + 1, l, (l + r) / 2);
            update(a, b, x, 2 * k + 2, (l + r) / 2, r);
            node[k] = f0(node[2 * k + 1], node[2 * k + 2]);
        }
    }

    T0 query(int a, int b, int k, int l, int r){
        if (r <= a || b <= l){
            return u0;
        }
        eval(k, r - l);
        if (a <= l && r <= b){
            return node[k];
        }
        T0 vl = query(a, b, 2 * k + 1, l, (l + r) / 2);
        T0 vr = query(a, b, 2 * k + 2, (l + r) / 2, r);
        return f0(vl, vr);
    }


public:
    int sz;  // 元の配列サイズ
    int n;
    vector<T0> node;
    vector<T1> lazy;
    using F0 = function<T0(T0, T0)>; F0 f0; T0 u0;
    using F1 = function<T1(T1, T1)>; F1 f1; T1 u1;
    using G = function<T0(T0, T1)>;  G g;
    using P = function<T1(T1, int)>; P p;

    LazySegmentTree(vector<T0> v, F0 f0, T0 u0, F1 f1, T1 u1, G g, P p):
            sz(v.size()), f0(f0), u0(u0), f1(f1), u1(u1), g(g), p(p){
        n = 1;
        while(n < sz) n *= 2;
        node.resize(2*n-1, u0);
        lazy.resize(2*n-1, u1);

        for(int i = 0; i < sz; i++){
            node[i+n-1] = v[i];
        }
        for(int i = n-2; i >= 0; i--){
            node[i] = f0(node[i*2+1], node[i*2+2]);
        }
    }

    void update(int a, int b, T1 x){
        update(a, b, x, 0, 0, n);
    }

    void update(int a, T1 x){
        update(a, a+1, x);
    }

    T0 query(int a, int b){
        return query(a, b, 0, 0, n);
    }

    T0 query(int a){
        return query(a, a+1);
    }
};

class Inc{
public:
    int s, t, x;
};

bool comp(Inc i1, Inc i2){
    return i1.x >= i2.x;
}
vector<int> t_vec;
vector<Inc> I;
map<int, int> mp;


signed main(){
    int n, q;
    cin >> n >> q;
    vector<int> d(q);

    for(int i = 0; i < n; i++){
        int s, t, x;
        cin >> s >> t >> x;
        Inc ii;
        ii.s = s;
        ii.t = t;
        ii.x = x;
        I.push_back(ii);
        t_vec.push_back(I[i].s - I[i].x);
        t_vec.push_back(I[i].t - I[i].x);
    }

    for(int i = 0; i < q; i++){
        cin >> d[i];
        t_vec.push_back(d[i]);
    }
    sort(t_vec.begin(), t_vec.end());
    sort(I.begin(), I.end(), comp);
    auto itr = unique(t_vec.begin(), t_vec.end());
    t_vec.erase(itr, t_vec.end());

    for(int i = 0; i < t_vec.size(); i++){
        mp[t_vec[i]] = i;
    }

    LazySegmentTree<int, int> seg(
            vector<int>(t_vec.size(), (int)1e9+10),
            [](int x, int y) { return min(x, y); }, (int)1e9+10,
            [](int x, int y) { return y == (int)1e9+10 ? x : y; }, (int)1e9+10,
            [](int x, int y) { return y == (int)1e9+10 ? x : y; },
            [](int x, int len) { return x; }
    );


    for(int i = 0; i < n; i++){
        int st = mp[I[i].s-I[i].x], en = mp[I[i].t-I[i].x];
        seg.update(st, en, I[i].x);
    }

    for(int i = 0; i < q; i++){
        int index = mp[d[i]];
        int res = 0 //seg.query(index);
        if(res == (int)1e9 + 10){
            cout << -1 << endl;
        }
        else{
            cout << res << endl;
        }
    }

    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:172:9: error: expected ',' or ';' before 'if'
  172 |         if(res == (int)1e9 + 10){
      |         ^~
a.cc:175:9: error: 'else' without a previous 'if'
  175 |         else{
      |         ^~~~