Language: C++

using ll = long long;
using namespace std;
constexpr ll inf = 1e15;
constexpr ll mod = 1e9+7;

class SegTree {
    int n = 1;
    // represents the tree as an array
    // parent of k: (k-1)/2, child of k: 2*k+1, 2*k+2
    vector<ll> nodes;

public:
    SegTree(int size, ll v) {
        while (n < size) n*= 2;
        nodes.resize(2*n-1, v);
    }

    SegTree(vector<ll> v) {
        while (n < v.size()) n*= 2;
        nodes.resize(2*n-1, inf);

        for (int i = 0; i < v.size(); i++) nodes[n-1+i] = v[i];
        for (int i = n-2; i >= 0; i++) nodes[i] = min(nodes[2*i+1], nodes[2*i+2]);
    }

    // return minimum value in [a, b). ([l, r) is interval in which k is.)
    ll rmq(int a, int b, int k = 0, int l = 0, int r = 0) {
        if (l >= r) r = n;
        if (r <= a || b <= l) return inf;
        if (a <= l && r <= b) return nodes[k];

        ll vl = rmq(a, b, 2*k+1, l, (l+r)/2);
        ll vr = rmq(a, b, 2*k+2, (l+r)/2, r);
        return min(vl, vr);
    }

    void update(int k, ll v) {
        k += n - 1;
        nodes[k] = v;
        // traverse from leaf to root
        while (k>0) {
            k = (k-1)/2;
            nodes[k] = min(nodes[k*2+1], nodes[k*2+2]);
        }
    }
};

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

    int N, Q;
    cin>>N>>Q;
    SegTree sg(N, 2ll<<31-1);
    for (int q = 0; q < Q; q++) {
        int com;
        ll x, y;
        cin>>com>>x>>y;
        if (com == 0) sg.update(x, y);
        else cout<<sg.rmq(x, y+1)<<endl;
    }
    return 0;
}


Compiler output:
a.cc:10:5: error: 'vector' does not name a type
   10 |     vector<ll> nodes;
      |     ^~~~~~
a.cc:18:19: error: expected ')' before '<' token
   18 |     SegTree(vector<ll> v) {
      |            ~      ^
      |                   )
a.cc: In constructor 'SegTree::SegTree(int, ll)':
a.cc:15:9: error: 'nodes' was not declared in this scope
   15 |         nodes.resize(2*n-1, v);
      |         ^~~~~
a.cc: In member function 'll SegTree::rmq(int, int, int, int, int)':
a.cc:30:38: error: 'nodes' was not declared in this scope
   30 |         if (a <= l && r <= b) return nodes[k];
      |                                      ^~~~~
a.cc:34:16: error: 'min' was not declared in this scope
   34 |         return min(vl, vr);
      |                ^~~
a.cc: In member function 'void SegTree::update(int, ll)':
a.cc:39:9: error: 'nodes' was not declared in this scope
   39 |         nodes[k] = v;
      |         ^~~~~
a.cc:43:24: error: 'min' was not declared in this scope
   43 |             nodes[k] = min(nodes[k*2+1], nodes[k*2+2]);
      |                        ^~~
a.cc: In function 'int main()':
a.cc:49:5: error: 'ios' has not been declared
   49 |     ios::sync_with_stdio(false);
      |     ^~~
a.cc:50:5: error: 'cin' was not declared in this scope
   50 |     cin.tie(NULL);
      |     ^~~
a.cc:1:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
  +++ |+#include <iostream>
    1 | using ll = long long;
a.cc:50:13: error: 'NULL' was not declared in this scope
   50 |     cin.tie(NULL);
      |             ^~~~
a.cc:1:1: note: 'NULL' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>'
  +++ |+#include <cstddef>
    1 | using ll = long long;
a.cc:60:14: error: 'cout' was not declared in this scope
   60 |         else cout<<sg.rmq(x, y+1)<<endl;
      |              ^~~~
a.cc:60:14: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:60:36: error: 'endl' was not declared in this scope
   60 |         else cout<<sg.rmq(x, y+1)<<endl;
      |                                    ^~~~
a.cc:1:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
  +++ |+#include <ostream>
    1 | using ll = long long;