Language: C++

#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cstring>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_map>
#include <set>
#include <deque>
#include <map>
#include <bitset>

#define INF 10000000000
#define rep(i, a) for (int i = 0; i < (a); i++)
using namespace std;
using P = pair<long, long>;

template <typename X>
struct SegTree {
    using FX = function<X(X, X)>;
    int n;
    FX fx;
    const X ex;
    vector<X> dat;
    SegTree(int n_, FX fx_, X ex_) : n(), fx(fx_), ex(ex_), dat(n_ * 4, ex_) {
        int x = 1;
        while (n_ > x) {
            x *= 2;
        }
        n = x;
    }
 
    void set(int i, X x) { dat[i + n - 1] = x; }
    void build() {
        for (int k = n - 2; k >= 0; k--) dat[k] = fx(dat[2 * k + 1], dat[2 * k + 2]);
    }
 
    void update(int i, X x) {
        i += n - 1;
        dat[i] = x;
        while (i > 0) {
            i = (i - 1) / 2;  // parent
            dat[i] = fx(dat[i * 2 + 1], dat[i * 2 + 2]);
        }
    }
 
    // the minimum element of [a,b)
    X query(int a, int b) { return query_sub(a, b, 0, 0, n); }
    X query_sub(int a, int b, int k, int l, int r) {
        if (r <= a || b <= l) {
            return ex;
        } else if (a <= l && r <= b) {
            return dat[k];
        } else {
            X vl = query_sub(a, b, k * 2 + 1, l, (l + r) / 2);
            X vr = query_sub(a, b, k * 2 + 2, (l + r) / 2, r);
            return fx(vl, vr);
        }
    }
    /* debug */
    inline X operator[](int a) { return query(a, a + 1); }
    void print() {
        for (int i = 0; i < n; ++i) {
            cout << (*this)[i];
            if (i != n) cout << ",";
        }
        cout << endl;
    }
};
 
int main() {
    int N, Q;
    string S;
    cin >> N >> S >> Q;
    using X = int;
    auto fx = [](X x1, X x2) -> X { return x1 | x2; };
    X ex = 0;
    SegTree<X> seg(N, fx, ex);
 
    for(int i = 0; i < N; i++) {
        X x = 1 << (int)(S[i] - 'a');
        seg.set(i, x);
    }
    seg.build();
 
    vector<int> ans;
 
    for (int i = 0; i < Q; i++) {
        int q;
        cin >> q;
        if (q == 1) {
            int i;
            char c;
            cin >> i >> c;
            i--;
            X x = 1 << (int)(c - 'a');
            seg.update(i, x);
        } else if (q == 2) {
            int l, r;
            cin >> l >> r;
            X ans = seg.query(l - 1, r);
            cout << __builtin_popcount(ans) << "\n";
        }
    }
 
    return 0;
}

Compiler output:
a.cc:22:16: error: 'function' does not name a type; did you mean 'union'?
   22 |     using FX = function<X(X, X)>;
      |                ^~~~~~~~
      |                union
a.cc:24:5: error: 'FX' does not name a type; did you mean 'X'?
   24 |     FX fx;
      |     ^~
      |     X
a.cc:27:21: error: 'FX' has not been declared
   27 |     SegTree(int n_, FX fx_, X ex_) : n(), fx(fx_), ex(ex_), dat(n_ * 4, ex_) {
      |                     ^~
a.cc: In constructor 'SegTree<X>::SegTree(int, int, X)':
a.cc:27:43: error: class 'SegTree<X>' does not have any field named 'fx'
   27 |     SegTree(int n_, FX fx_, X ex_) : n(), fx(fx_), ex(ex_), dat(n_ * 4, ex_) {
      |                                           ^~
a.cc: In function 'int main()':
a.cc:80:23: error: invalid user-defined conversion from 'main()::<lambda(X, X)>' to 'int' [-fpermissive]
   80 |     SegTree<X> seg(N, fx, ex);
      |                       ^~
a.cc:78:15: note: candidate is: 'constexpr main()::<lambda(X, X)>::operator X (*)(X, X)() const' (near match)
   78 |     auto fx = [](X x1, X x2) -> X { return x1 | x2; };
      |               ^
a.cc:78:15: note:   no known conversion from 'X (*)(X, X)' {aka 'int (*)(int, int)'} to 'int'
a.cc:27:24: note:   initializing argument 2 of 'SegTree<X>::SegTree(int, int, X) [with X = int]'
   27 |     SegTree(int n_, FX fx_, X ex_) : n(), fx(fx_), ex(ex_), dat(n_ * 4, ex_) {
      |                     ~~~^~~
a.cc: In instantiation of 'void SegTree<X>::build() [with X = int]':
a.cc:86:14:   required from here
   86 |     seg.build();
      |     ~~~~~~~~~^~
a.cc:37:53: error: 'fx' was not declared in this scope; did you mean 'ex'?
   37 |         for (int k = n - 2; k >= 0; k--) dat[k] = fx(dat[2 * k + 1], dat[2 * k + 2]);
      |                                                   ~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      |                                                   ex
a.cc: In instantiation of 'void SegTree<X>::update(int, X) [with X = int]':
a.cc:99:23:   required from here
   99 |             seg.update(i, x);
      |             ~~~~~~~~~~^~~~~~
a.cc:45:24: error: 'fx' was not declared in this scope; did you mean 'ex'?
   45 |             dat[i] = fx(dat[i * 2 + 1], dat[i * 2 + 2]);
      |                      ~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      |                      ex
a.cc: In instantiation of 'X SegTree<X>::query_sub(int, int, int, int, int) [with X = int]':
a.cc:50:36:   required from 'X SegTree<X>::query(int, int) [with X = int]'
   50 |     X query(int a, int b) { return query_sub(a, b, 0, 0, n); }
      |                                    ^~~~~~~~~
a.cc:103:30:   required from here
  103 |             X ans = seg.query(l - 1, r);
      |                     ~~~~~~~~~^~~~~~~~~~
a.cc:59:22: error: 'fx' was not declared in this scope; did you mean 'ex'?
   59 |             return fx(vl, vr);
      |                    ~~^~~~~~~~
      |                    ex