Language: C++

#include <cstdio>
#include <vector>
#include <string>
#include <cstdint>

unsigned int N;
std::vector<unsigned int> data;

inline void build(const std::string& s){
    const unsigned int n = s.size();
    N = 1; while(N < n) N <<= 1;  data.resize(2 * N);
    unsigned int i, j;
    for(i = 0, j = N; i < n; ++i, ++j) data[j] = 1 << (s[i] - 'a');
    for(; i < N; ++i, ++j) data[j] = 0;
    for(i = N - 1; i ; --i) data[i] = data[i << 1] | data[(i << 1) | 1];
}

inline void update(unsigned int index, const char c){
    data[index += N] = 1 << (c - 'a');
    for(; index > 1; index >>= 1) data[index >> 1] = data[index] | data[index ^ 1];
}

inline unsigned int query(unsigned int l, unsigned int r){
    unsigned int res = 0; l += N; r += N;
    while(l < r){
        if(l & 1) res |= data[l++]; l >>= 1;
        if(r & 1) res |= data[--r]; r >>= 1;
    }
    return res;
}

int main(void){
    std::ios::sync_with_stdio(false); std::cin.tie(nullptr);
    int n, q; std::string s; std::cin >> n >> s >> q;
    build(s);
    while(q--){
        char c; std::cin >> c;
        if(c == '1'){
            int i; char a; std::cin >> i >> a; update(--i, a);
        }
        else{
            int l, r; std::cin >> l >> r;
            std::cout << __builtin_popcount(query(--l, r)) << '\n';
        }
    }    
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:33:15: error: incomplete type 'std::ios' {aka 'std::basic_ios<char>'} used in nested name specifier
   33 |     std::ios::sync_with_stdio(false); std::cin.tie(nullptr);
      |               ^~~~~~~~~~~~~~~
a.cc:33:44: error: 'cin' is not a member of 'std'
   33 |     std::ios::sync_with_stdio(false); std::cin.tie(nullptr);
      |                                            ^~~
a.cc:5:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
    4 | #include <cstdint>
  +++ |+#include <iostream>
    5 | 
a.cc:34:35: error: 'cin' is not a member of 'std'
   34 |     int n, q; std::string s; std::cin >> n >> s >> q;
      |                                   ^~~
a.cc:34:35: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:37:22: error: 'cin' is not a member of 'std'
   37 |         char c; std::cin >> c;
      |                      ^~~
a.cc:37:22: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:39:33: error: 'cin' is not a member of 'std'
   39 |             int i; char a; std::cin >> i >> a; update(--i, a);
      |                                 ^~~
a.cc:39:33: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:42:28: error: 'cin' is not a member of 'std'
   42 |             int l, r; std::cin >> l >> r;
      |                            ^~~
a.cc:42:28: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:43:18: error: 'cout' is not a member of 'std'
   43 |             std::cout << __builtin_popcount(query(--l, r)) << '\n';
      |                  ^~~~
a.cc:43:18: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'