Language: C++

#include <algorithm>
#include <climits>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
#define what(x) cerr << #x << " is " << x << endl;
const int INF = INT_MAX;

// 0-indexed RMQ segment tree
template <typename T = int>
struct SegmentTree {
    using F = function<T(T, T)>;
    int n;
    vector<T> dat;
    F func;
    T UNIT;

    SegmentTree(int n_, F func_, T UNIT_) : func(func_), UNIT(UNIT_) {
        n = 1;
        // full binary tree: num of leaves = n = 2^k >= n_
        while (n < n_)
            n *= 2;
        dat.assign(2 * n - 1, UNIT);
    }
    SegmentTree(vector<T> v_, F func_, T UNIT_) : func(func_), UNIT(UNIT_) {
        n = 1;
        while (n < v_.size())
            n *= 2;
        dat.assign(2 * n - 1, UNIT);
        for (int i = 0; i < v_.size(); ++i) {
            dat[n - 1 + i] = v_[i];
        }
        for (int i = n - 2; i >= 0; --i) {
            dat[i] = func(dat[2 * i + 1], dat[2 * i + 2]);
        }
    }
    void update(int k, int a) {
        // leaves are at index n-1 to 2*n-2
        k += n - 1;
        dat[k] = a;
        while (k > 0) {
            // k -> parent node
            k = (k - 1) / 2;
            // func(child nodes)
            dat[k] = func(dat[2 * k + 1], dat[2 * k + 2]);
        }
    }
    T query(int a, int b, int k, int l, int r) {
        if (r <= a || b <= l)
            return UNIT;
        if (a <= l && r <= b)
            return dat[k];
        else {
            T vl = query(a, b, 2 * k + 1, l, (l + r) / 2);
            T vr = query(a, b, 2 * k + 2, (l + r) / 2, r);
            return func(vl, vr);
        }
    }
    // get result of func() in [a, b)
    T query(int a, int b) { return query(a, b, 0, 0, n); }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, q;
    cin >> n >> q;
    auto f = [](int l, int r) { return min(l, r); };
    SegmentTree<int> seg(n, f, INF);
    vector<int> com(q), x(q), y(q);
    for (int i = 0; i < q; ++i) {
        cin >> com[i] >> x[i] >> y[i];
    }
    for (int i = 0; i < q; ++i) {
        if (com[i] == 0) {
            seg.update(x[i], y[i]);
        } else {
            cout << seg.query(x[i], y[i] + 1) << "\n";
        }
    }
    return 0;
}


Compiler output:
a.cc:24:15: error: 'function' does not name a type; did you mean 'union'?
   24 |     using F = function<T(T, T)>;
      |               ^~~~~~~~
      |               union
a.cc:27:5: error: 'F' does not name a type
   27 |     F func;
      |     ^
a.cc:30:25: error: 'F' has not been declared
   30 |     SegmentTree(int n_, F func_, T UNIT_) : func(func_), UNIT(UNIT_) {
      |                         ^
a.cc:37:31: error: 'F' has not been declared
   37 |     SegmentTree(vector<T> v_, F func_, T UNIT_) : func(func_), UNIT(UNIT_) {
      |                               ^
a.cc: In constructor 'SegmentTree<T>::SegmentTree(int, int, T)':
a.cc:30:45: error: class 'SegmentTree<T>' does not have any field named 'func'
   30 |     SegmentTree(int n_, F func_, T UNIT_) : func(func_), UNIT(UNIT_) {
      |                                             ^~~~
a.cc: In constructor 'SegmentTree<T>::SegmentTree(std::vector<_Tp>, int, T)':
a.cc:37:51: error: class 'SegmentTree<T>' does not have any field named 'func'
   37 |     SegmentTree(vector<T> v_, F func_, T UNIT_) : func(func_), UNIT(UNIT_) {
      |                                                   ^~~~
a.cc: In function 'int main()':
a.cc:81:29: error: invalid user-defined conversion from 'main()::<lambda(int, int)>' to 'int' [-fpermissive]
   81 |     SegmentTree<int> seg(n, f, INF);
      |                             ^
a.cc:80:14: note: candidate is: 'constexpr main()::<lambda(int, int)>::operator int (*)(int, int)() const' (near match)
   80 |     auto f = [](int l, int r) { return min(l, r); };
      |              ^
a.cc:80:14: note:   no known conversion from 'int (*)(int, int)' to 'int'
a.cc:30:27: note:   initializing argument 2 of 'SegmentTree<T>::SegmentTree(int, int, T) [with T = int]'
   30 |     SegmentTree(int n_, F func_, T UNIT_) : func(func_), UNIT(UNIT_) {
      |                         ~~^~~~~
a.cc: In instantiation of 'void SegmentTree<T>::update(int, int) [with T = int]':
a.cc:88:23:   required from here
   88 |             seg.update(x[i], y[i]);
      |             ~~~~~~~~~~^~~~~~~~~~~~
a.cc:57:26: error: 'func' was not declared in this scope
   57 |             dat[k] = func(dat[2 * k + 1], dat[2 * k + 2]);
      |                      ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc: In instantiation of 'T SegmentTree<T>::query(int, int, int, int, int) [with T = int]':
a.cc:72:41:   required from 'T SegmentTree<T>::query(int, int) [with T = int]'
   72 |     T query(int a, int b) { return query(a, b, 0, 0, n); }
      |                                    ~~~~~^~~~~~~~~~~~~~~
a.cc:90:30:   required from here
   90 |             cout << seg.query(x[i], y[i] + 1) << "\n";
      |                     ~~~~~~~~~^~~~~~~~~~~~~~~~
a.cc:68:24: error: 'func' was not declared in this scope
   68 |             return func(vl, vr);
      |                    ~~~~^~~~~~~~