criyle/codenet-compile-errors huggingface dataset:
Language: C++

#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define rep(i, n) repd(i, 0, n)

using namespace std;

using ll = long long;
using ul = unsigned long long;
using Bint = mp::cpp_int;
ll mod = 1000000007;

class SegmentTree {
  private:
    ll n;
    vector<vector<ll>> dat;

  public:
    SegmentTree(){};
    SegmentTree(ll n, string s) { init(n, s); };
    ~SegmentTree(){};
    void init(ll n_, string s) {
        dat.resize(26);
        n = 1;
        while (n < n_) {
            n *= 2;
        }
        rep(i, 26) { dat[i].resize(2 * n - 1); }
        for (ll i = 0; i < s.size(); i++) {
            update_in(i, s[i]);
        }
    };
    void update_in(ll k, char c) {
        k += n - 1;
        dat[c - 'a'][k] = 1;
        while (k > 0) {
            k = (k - 1) / 2;
            dat[c - 'a'][k] = dat[c - 'a'][k * 2 + 1] + dat[c - 'a'][k * 2 + 2];
        }
    };
    void update_out(ll k, char c) {
        k += n - 1;
        dat[c - 'a'][k] = 0;
        while (k > 0) {
            k = (k - 1) / 2;
            dat[c - 'a'][k] = dat[c - 'a'][k * 2 + 1] + dat[c - 'a'][k * 2 + 2];
        }
    }
    ll query(ll a, ll b) { return query(a, b, 0, 0, n); };
    ll query(ll a, ll b, ll k, ll l, ll r) {
        ll num = 0;
        for (char c = 'a'; c <= 'z'; c++) {
            if (query_inner(a, b, k, l, r, c)) {
                num++;
            }
        }
        return num;
    };
    bool query_inner(ll a, ll b, ll k, ll l, ll r, char c) {
        if (r <= a || b <= l) {
            return 0;
        }

        if (a <= l && r <= b) {
            return dat[c - 'a'][k];
        } else {
            ll vl = query_inner(a, b, k * 2 + 1, l, (l + r) / 2, c);
            ll vr = query_inner(a, b, k * 2 + 2, (l + r) / 2, r, c);
            return vl + vr;
        }
    };
};

int main() {
source:
    ll n, q;
    string s;
    cin >> n >> s >> q;
    SegmentTree st(n, s);
    vector<char> c(n);
    rep(i, n) { c[i] = s[i]; }
    vector<ll> ans;

    rep(i, q) {
        ll num;
        cin >> num;
        if (num == 1) {
            ll i;
            char c_in;
            cin >> i >> c_in;
            st.update_out(i - 1, c[i - 1]);
            st.update_in(i - 1, c_in);
            c[i] = c_in;
        } else {
            ll l;
            ll r;
            cin >> l >> r;
            ll ans_temp = st.query(l - 1, r);
            ans.push_back(ans_temp);
        }
    }

    rep(i, ans.size()) { cout << ans[i] << endl; }

    return 0;
}



Compiler output:
a.cc:2:10: fatal error: boost/multiprecision/cpp_int.hpp: No such file or directory
    2 | #include <boost/multiprecision/cpp_int.hpp>
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
Language: C++

#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define rep(i, n) repd(i, 0, n)

using namespace std;

namespace mp = boost::multiprecision;

using ll = long long;
using ul = unsigned long long;
using Bint = mp::cpp_int;
using s_c = set<char>;
ll mod = 1000000007;

s_c merge(s_c s0, s_c s1) {
    for (auto iter = s1.begin(); iter != s1.end(); iter++) {
        s0.insert(*iter);
    }
    return s0;
}

class SegmentTree {
  private:
    ll n;
    vector<vector<ll>> dat;

  public:
    SegmentTree(){};
    SegmentTree(ll n, string s) { init(n, s); };
    ~SegmentTree(){};
    void init(ll n_, string s) {
        dat.resize(26);
        n = 1;
        while (n < n_) {
            n *= 2;
        }
        rep(i, 26) { dat[i].resize(2 * n - 1); }
        for (ll i = 0; i < s.size(); i++) {
            update_in(i, s[i]);
        }
    };
    void update_in(ll k, char c) {
        k += n - 1;
        dat[c - 'a'][k] = 1;
        while (k > 0) {
            k = (k - 1) / 2;
            dat[c - 'a'][k] = dat[c - 'a'][k * 2 + 1] + dat[c - 'a'][k * 2 + 2];
        }
    };
    void update_out(ll k, char c) {
        k += n - 1;
        dat[c - 'a'][k] = 0;
        while (k > 0) {
            k = (k - 1) / 2;
            dat[c - 'a'][k] = dat[c - 'a'][k * 2 + 1] + dat[c - 'a'][k * 2 + 2];
        }
    }
    ll query(ll a, ll b) { return query(a, b, 0, 0, n); };
    ll query(ll a, ll b, ll k, ll l, ll r) {
        ll num = 0;
        for (char c = 'a'; c <= 'z'; c++) {
            if (query_inner(a, b, k, l, r, c)) {
                num++;
            }
        }
        return num;
    };
    bool query_inner(ll a, ll b, ll k, ll l, ll r, char c) {
        if (r <= a || b <= l) {
            return 0;
        }

        if (a <= l && r <= b) {
            return dat[c - 'a'][k];
        } else {
            ll vl = query_inner(a, b, k * 2 + 1, l, (l + r) / 2, c);
            ll vr = query_inner(a, b, k * 2 + 2, (l + r) / 2, r, c);
            return vl + vr;
        }
    };
};

int main() {
source:
    ll n, q;
    string s;
    cin >> n >> s >> q;
    SegmentTree st(n, s);
    vector<char> c(n);
    rep(i, n) { c[i] = s[i]; }
    vector<ll> ans;

    rep(i, q) {
        ll num;
        cin >> num;
        if (num == 1) {
            ll i;
            char c_in;
            cin >> i >> c_in;
            st.update_out(i - 1, c[i - 1]);
            st.update_in(i - 1, c_in);
            c[i] = c_in;
        } else {
            ll l;
            ll r;
            cin >> l >> r;
            ll ans_temp = st.query(l - 1, r);
            ans.push_back(ans_temp);
        }
    }

    rep(i, ans.size()) { cout << ans[i] << endl; }

    return 0;
}



Compiler output:
a.cc:2:10: fatal error: boost/multiprecision/cpp_int.hpp: No such file or directory
    2 | #include <boost/multiprecision/cpp_int.hpp>
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
Language: C++

#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<functional>
#include<math.h>
using namespace std;
#define N (1000000000+7)
#define INF 1e16
typedef long long ll;
typedef pair<int,int> P;

template <typename T>
struct SegmentTree{
    typedef function<T(T,T)> F;
    int n;
    F f;
    T unit;
    vector<T> dat;
    SegmentTree(){};
    SegmentTree(int newn,F f,T t):f(f),unit(t){
        init(newn);
    }
    SegmentTree(const vector<T> &v,F f,T t):f(f),unit(t){
        int n_ = v.size();
        init(n_);
        for(int i=0;i<n_;i++)dat[n+i]=v[i];
        for(int i=n-1;i;i--){
            dat[i]=f(dat[(i<<1)|0],dat[(i<<1)|1]);
        }
    }

    void init(int n_){
        n=1;
        while(n<n_)n<<=1;
        dat.assign(n<<1,unit);
    }
    /*void build(const vector<T> &v){
        int n_=v.size();
        init(n_);
        for(int i=0i<n_;i++)dat[n+i]=v[i];
        for(int i=n-1;i;i--)
            dat[i]=f(dat[(i<<1)|0],dat[(i<<1)|1]);
    }*/
    void update(int k,T x){
        dat[k+=n]=x;
        while(k>>=1)
            dat[k]=f(dat[(k<<1)|0],dat[(k<<1)|1]);
    }
    T query(int a,int b){
        T vl=unit,vr=unit;
        for(int l=a+n,r=b+n;l<r;l>>=1,r>>=1){
            if(l&1)vl=f(vl,dat[l++]);
            if(r&1)vr=f(dat[--r],vr);
        }
        return f(vl,vr);
    }

};

ll n,q;
SegmentTree<ll>seg;
string s;

unsigned long long popcount(unsigned long long x) {
  x = ((x & 0xaaaaaaaaaaaaaaaaUL) >> 1) +
      (x & 0x5555555555555555UL);
  x = ((x & 0xccccccccccccccccUL) >> 2) +
      (x & 0x3333333333333333UL);
  x = ((x & 0xf0f0f0f0f0f0f0f0UL) >> 4) +
      (x & 0x0f0f0f0f0f0f0f0fUL);
  x = ((x & 0xff00ff00ff00ff00UL) >> 8) +
      (x & 0x00ff00ff00ff00ffUL);
  x = ((x & 0xffff0000ffff0000UL) >> 16) +
      (x & 0x0000ffff0000ffffUL);
  x = ((x & 0xffffffff00000000UL) >> 32) +
      (x & 0x00000000ffffffffUL);
  return x;
}

int main(void){
    cin>>n>>s>>q;
    auto f = [] (long long l, long long r) { return l | r; };*/
    seg = SegmentTree<ll>(n,f,0);
    for(ll i=0;i<n;i++){
        seg.update(i,(1LL<<s[i]-'a'));
    }
    for(ll i=0;i<q;i++){
        int x;
        cin>>x;
        if(x==1){
            ll index;
            char c;
            cin>>index>>c;
            seg.update(index-1,1LL<<(c-'a'));
        }
        else{
            ll l,r;
            cin>>l>>r;
            cout<<popcount(seg.query(l-1,r))<<endl;
        }
    }
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:87:63: error: expected primary-expression before '/' token
   87 |     auto f = [] (long long l, long long r) { return l | r; };*/
      |                                                               ^
Language: C++

#include <bits/stdc++.h>

using namespace std;

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define MOD 1000000007
#define NUM 2520
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)


signed main(){

	lli n;
	string s;
	cin>>n>>s;

    set<lli> sets[26];
    REP(i,0,n)sets[s.at(i)-'a'].insert(i);

	lli q;
	cin>>q;
    REP(i,0,26)sets[i].insert(INF);

	REP(i,0,q){
		lli k;
		cin>>k;
		if(k==1){
			lli index;
			char a;
			cin>>index>>a;
            index--;
            sets[s.at(index)-'a'].erase(index);
            s[index] = a;
            sets[s.at(index)-'a'].insert(index);
		}
		else{
			lli x,y;
			cin>>x>>y;
			x--,y--;
            lli cnt=0;
            REP(j,0,26){
                set<lli> &nowS = sets[j];
                auto itr = nowS.lower_bound(x);
                if(DEBUG)cout<<"j="<<j<<" ITR="<<*itr<<endl;
                if(x<=*itr && *itr<=y)cnt++;
            }
            cout<<cnt<<endl;
		}
	}

	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:26:31: error: 'INF' was not declared in this scope
   26 |     REP(i,0,26)sets[i].insert(INF);
      |                               ^~~
Language: C++

#include <bits/stdc++.h>

using namespace std;

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define MOD 1000000007
#define NUM 2520
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)


signed main(){

	lli n;
	string s;
	cin>>n>>s;

    set<lli> sets[26];
    REP(i,0,n)sets[s.at(i)-'a'].insert(i);

	lli q;
	cin>>q;

	REP(i,0,q){
		lli k;
		cin>>k;
		if(k==1){
			lli index;
			char a;
			cin>>index>>a;
            index--;
            sets[s.at(i)-'a'].erase(index);
            s[index] = a;
            sets[s.at(i)-'a'].insert(index);
		}
		else{
			lli x,y;
			cin>>x>>y;
			x--,y--;
            lli cnt=0;
            REP(j,0,26){
                set<lli> &nowS = sets[j];
                if(nowS.size()==0)continue;
                auto itr = lower_bound(x);
                if(DEBUG)cout<<"j="<<j<<" ITR="<<*itr<<endl;
                if(x<=*itr && *itr<=y)cnt++;
            }
            cout<<cnt<<endl;
		}
	}

	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:47:39: error: no matching function for call to 'lower_bound(long long int&)'
   47 |                 auto itr = lower_bound(x);
      |                            ~~~~~~~~~~~^~~
In file included from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:1530:5: note: candidate: 'template<class _ForwardIterator, class _Tp> _ForwardIterator std::lower_bound(_ForwardIterator, _ForwardIterator, const _Tp&)'
 1530 |     lower_bound(_ForwardIterator __first, _ForwardIterator __last,
      |     ^~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:1530:5: note:   candidate expects 3 arguments, 1 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:1963:5: note: candidate: 'template<class _FIter, class _Tp, class _Compare> _FIter std::lower_bound(_FIter, _FIter, const _Tp&, _Compare)'
 1963 |     lower_bound(_ForwardIterator __first, _ForwardIterator __last,
      |     ^~~~~~~~~~~
/usr/include/c++/14/bits/stl_algo.h:1963:5: note:   candidate expects 4 arguments, 1 provided
Language: C++

#include <iostream>
#include <unordered_set>
#include <queue>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstring>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
#include <numeric>
#include <functional>

using namespace std;
#define ALL(x)			(x).begin(),(x).end()
#define REP(i, n)		for (int (i) = 0 ; (i) < (ll)(n) ; ++(i))
#define REPN(i, m, n)	for (int (i) = m ; (i) < (ll)(n) ; ++(i))
#define INF				(int)2e9
#define MOD				(1000 * 1000 * 1000 + 7)
#define Ceil(x, n)		(((((x))+((n)-1))/n))	
#define CeilN(x, n)		(((((x))+((n)-1))/n)*n)	
#define FloorN(x, n)	((x)-(x)%(n))			
#define IsOdd(x)		(((x)&0x01UL) == 0x01UL)			
#define IsEven(x)		(!IsOdd((x)))						
#define M_PI			3.14159265358979323846
typedef long long			ll;
typedef unsigned long long	ull;
typedef pair<ll, ll>		P;
typedef vector<ll>			VLL;
typedef vector<VLL>			VVLL;
typedef vector<VVLL>		VVVLL;

/*-----------------------------------------------------------------------------
　処理
 -----------------------------------------------------------------------------*/
int main()
{
	int N, Q;
	string S;
	cin >> N >> S >> Q;
	
	vector<unordered_set<int>> strPos(26);
	REP(i, N) {
		int strOne = S[i] - 'a';
		strPos[strOne].insert(i);
	}

	REP(i, Q) {
		int q;
		cin >> q;
		if (q == 1) {
			int l;
			char r;
			cin >> l >> r;
			l--;;

			int strOne = S[l] - 'a';
			strPos[strOne].erase(l);
			strOne = r - 'a';
			strPos[strOne].insert(l);
			S[l] = r;
		} else {
			int l, r;
			cin >> l >> r;
			l--; r--;

			int ansOne = 0;
			REP(j, 26) {
				unordered_set<int> &posOne = strPos[j];
				auto idx1 = posOne.lower_bound(l);
				auto idx2 = posOne.lower_bound(r);
				if (idx1 != posOne.end()) {
					int lPos = *idx1;
					int rPos;
					if (idx2 != posOne.end()) {
						rPos = *idx2;
					} else {
						rPos = INF;
					}
					if ((l <= lPos && lPos <= r) || (l <= rPos && rPos <= r)) {
						ansOne++;
					}
				}
			}

			cout << ansOne << endl;
		}
	}

	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:73:52: error: 'class std::unordered_set<int>' has no member named 'lower_bound'
   73 |                                 auto idx1 = posOne.lower_bound(l);
      |                                                    ^~~~~~~~~~~
a.cc:74:52: error: 'class std::unordered_set<int>' has no member named 'lower_bound'
   74 |                                 auto idx2 = posOne.lower_bound(r);
      |                                                    ^~~~~~~~~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
long long mo = 1e9 + 7;
typedef long long ll;
typedef pair<int,int> P;

int main(){
    int N,Q;
    string S;
    cin >> N >> S >> Q;
    int type,iq,lq,rq;
    char cq;

    rep(i,Q){
        cin >> type;
        vector<set<int>> v(26);
        rep(i,S.size()){
            v[S[i]-'a'].insert(i);
        }

        if(type == 1){
            cin >> iq >> cq;
            v[S[iq-1]-'a'].erase(iq-1);
            v[cq-'a'].insert(iq-1);
            S[iq-1] = cq;
            
            //cout << S << endl;
        }else{
            cin >> lq >> rq;
            int cnt = 0;
            rep(k,26){
                for(int j=lq-1;j<=rq-1;j++){
                    auto itr = v[k].find(j);
                    if(itr != v[k].end()){
                        cnt++;
                        break;
                    }

                }
            }
            int cnt = 0;
            cout << cnt << endl;
        }
    }

//    cout << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:42:17: error: redeclaration of 'int cnt'
   42 |             int cnt = 0;
      |                 ^~~
a.cc:31:17: note: 'int cnt' previously declared here
   31 |             int cnt = 0;
      |                 ^~~
Language: C

#include<stdio.h>

int conp(char *s,int l,int r){
	int check[26]={0};
	int num=0;
	
	for(int i=l;i<r+1;i++){
		check[s-97]=1;
	}
	
	for(int i=0;i<26;i++){
		num+=check[i];
	}
	
	return num;
}

int main(void){
	int n,q;
	char s[500000];
	scanf("%d",&n);
	scanf("%s",s);
	scanf("%d",&q);
	
	int que,k,l,r;
	char c;
	char c1;
	for(int i=0;i<q;i++){
		scanf("%d",&que);
		switch(que){
			case 1:
				scanf("%d",&k);
				scanf("%c",&c1);
				scanf("%c",&c);
				if(s[k-1]!=c){
					s[k-1]=c;
				}
				break;
				
			case 2:
				scanf("%d",&l);
				scanf("%d",&r);
				printf("%d\n",conp(s,l-1,r-1));
				break;
		}
	}
}

Compiler output:
main.c: In function 'conp':
main.c:8:22: error: array subscript is not an integer
    8 |                 check[s-97]=1;
      |                      ^
Language: C++

#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; ++i)
#define rrep(i, n) for(int i = n-1; i >= 0; --i)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned int uint;
typedef unsigned long long ulint;
constexpr lint mod = 1e9+7;

template<typename T>
struct ST{
  using F = function<T(T, T)>;
  int size_ = 1;
  vector<T> node;
  T initial;
  F query_, update_;
  ST(int n, T initial, F query, F update){
    while(size_ < n) size_ *= 2;
    node.resize(2*size_-1, initial);
    query_ = query;
    update_ = update;
  }
  void nodes(){
    rep(i, node.size()) cout << node[i] << endl;
    return;
  }
  void build(vector<T> v){
    rep(i, v.size()) node[i+size_-1] = v[i];
    rrep(i, size_ - 1) node[i] = query_(node[2*i+1], node[2*i+2]);
    return;
  }
  void update(int j, T x){
    j += size_-1;
    node[j] = update_(node[j], x);
    while(j > 0){
      j = (j-1)/2;
      node[j] = query_(node[2*j+1], node[2*j+2]);
    }
    return;
  }
  T query(int l, int r){
    l += size_-1;
    r += size_-1;
    T ql = node[l], qr = node[r];
    while(l < r-1){
      if(l % 2 == 1) ql = query_(node[l], node[l+1]);
      l = (l-1)/2;
      if(r % 2 == 0) qr = query_(node[r-1], node[r]);
      r = (r-1)/2;
    }
    return query_(ql, qr);
  }
};

int main() {
  int n, q;
  string s;
  cin >> n >> s >> q;
  auto f = [](int a, int b){return a | b;};
  auto g = [](int a, int b){return b;};
  ST<int> st(n, 0, f, g);
  vector<int> v(n);
  rep(i, n) v[i] = 1 << (s[i] - 'a');
  st.build(v);
  rep(i, q){
    int c;
    cin >> c;
    if(c == 1){
      int j;
      char x;
      cin >> j >> x;
      st.update(j-1, 1 << x - 'a');
    }
    else if(c == 2){
      int l, r, tmp;
      cin >> l >> r;
      tmp = sy.query(l-1, r-1);
      cout << __builtin_popcount(tmp) << endl;
    }
  }
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:79:13: error: 'sy' was not declared in this scope; did you mean 'st'?
   79 |       tmp = sy.query(l-1, r-1);
      |             ^~
      |             st
Language: C++

#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; ++i)
#define rrep(i, n) for(int i = n-1; i >= 0; --i)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned int uint;
typedef unsigned long long ulint;
constexpr lint mod = 1e9+7;

template<typename T>
struct ST{
  using F = function<T(T, T)>;
  int size_ = 1;
  vector<T> node;
  T initial;
  F query_, update_;
  ST(int n, T initial, F query, F update){
    while(size_ < n) size_ *= 2;
    node.resize(2*size_-1, initial);
    query_ = query;
    update_ = update;
  }
  void nodes(){
    rep(i, node.size()) cout << node[i] << endl;
    return;
  }
  void build(vector<T> v){
    rep(i, v.size()) node[i+size_-1] = v[i];
    rrep(i, size_ - 1) node[i] = query_(node[2*i+1], node[2*i+2]);
    return;
  }
  void update(int j, T x){
    j += size_-1;
    node[j] = update_(node[j], x);
    while(j > 0){
      j = (j-1)/2;
      node[j] = query_(node[2*j+1], node[2*j+2]);
    }
    return;
  }
  T query(int l, int r){
    l += size_-1;
    r += size_-1;
    T ql = node[l], qr = node[r];
    while(l < r-1){
      if(l % 2 == 1) ql = query_(node[l], node[l+1]);
      l = (l-1)/2;
      if(r % 2 == 0) qr = query_(node[r-1], node[r]);
      r = (r-1)/2;
    }
    return query_(ql, qr);
  }
};

int main() {
  int n, q;
  string s;
  cin >> n >> s >> q;
  auto f = [](int a, int b){return a | b;};
  auto g = [](int a, int b){return b;};
  ST<int> st(n, 0, f, g);
  vector<int> v(n);
  rep(i, n) v[i] = 1 << (s[i] - 'a');
  st.build(v);
  rep(i, q){
    int c;
    cin >> c;
    if(c == 1){
      int j;
      char x;
      cin >> j >> x;
      st.update(j-1, 1 << x - 'a');
    }
    else if(c == 2){
      int l, r, tmp;
      cin >> l >> r;
      tmp = sy.puery(l-1, r-1);
      cout << __builtin_popcount(tmp) << endl;
    }
  }
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:79:13: error: 'sy' was not declared in this scope; did you mean 'st'?
   79 |       tmp = sy.puery(l-1, r-1);
      |             ^~
      |             st
Language: Java


import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.NavigableSet;
import java.util.Scanner;
import java.util.TreeSet;

public class Main {
    public static void main(String [] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        String s = scanner.next();
        Map<Character, TreeSet<Integer>> charToPos = new HashMap<>();
        for (int i = 0; i < s.length(); ++i) {
            char current = s.charAt(i);
            TreeSet<Integer> poses = charToPos.getOrDefault(current, new TreeSet<>());
            poses.add(i + 1);
            charToPos.put(current, poses);
        }
        int query = scanner.nextInt();
        for (int i = 0; i < query; ++i) {
            int type = scanner.nextInt();

            if (type == 1) {
                int a = scanner.nextInt();
                char newChar = scanner.next().charAt(0);
                char oldChar = s.charAt(a - 1);
                charToPos.get(oldChar).remove(a);
                TreeSet<Integer> newCharPoses = charToPos.getOrDefault(newChar, new HashSet<>());
                newCharPoses.add(a);
                charToPos.put(newChar, newCharPoses);
            } else if (type == 2) {
                int l = scanner.nextInt();
                int r = scanner.nextInt();
                int diff = 0;
                for (int j = 0; j < 26; ++j) {
                    char currentChar = (char)('a' + j);
                    TreeSet<Integer> poses = charToPos.getOrDefault(currentChar, new TreeSet<>());
                    if (poses.isEmpty()) {
                        continue;
                    }
                    if (poses.contains(l) || poses.contains(r)) {
                        ++diff;
                        continue;
                    }
                    NavigableSet<Integer> rNum = poses.headSet(r, true);
                    NavigableSet<Integer> lNum = poses.tailSet(l, false);

                    long count = rNum.size() - lNum.size();
                    if (count > 0) {
                        ++diff;
                    }
                    //        System.out.println("lIndex: "+ lIndex);
           //         System.out.println("diff: " + diff);
                }
                System.out.println(diff);
        //        System.out.println("===========");
            }
        }
    }
}


Compiler output:
Main.java:30: error: incompatible types: cannot infer type arguments for HashSet<>
                TreeSet<Integer> newCharPoses = charToPos.getOrDefault(newChar, new HashSet<>());
                                                                                           ^
    reason: no instance(s) of type variable(s) E exist so that HashSet<E> conforms to TreeSet<Integer>
  where E is a type-variable:
    E extends Object declared in class HashSet
Note: Some messages have been simplified; recompile with -Xdiags:verbose to get full output
1 error
Language: C++

#include <bits/stdc++.h>
using ll = long long;
using int = unsigned long long;
#define FOR(i, begin, end) for(ll i = (begin); i < (end); i++)
#define rep(i, n) FOR(i, 0, n)
#define all(x) (x).begin(),(x).end()
using namespace std;

int N, n_query;
string s;
// constexpr int MAX = 5e5;
// char s[MAX];
vector<int> ans;


vector<set<int>> char_place(26);

void change_char(int i, char changed, char original) {
    // char original;
    // for(char c = 'a'; c <= 'z'; c++) {
    //     const auto cp = char_place[c];
    //     const auto z = cp.find(i);
    //     if(z != cp.end()) {
    //         original = c;
    //     }
    // }
    if (changed == original) return;
    char_place[original - 'a'].erase(i);
    char_place[changed - 'a'].insert(i);
}
int num_chars(int l, int r) {
    int sum(0);
    for(int c = 0; c < 26; c++) {
        // cout << c;
        const auto cp = char_place[c];
        const auto f = cp.lower_bound(l);
        const auto first_place = *f;
        if (f != cp.end() && first_place <= r) {
            sum++;
        }
    }
    return sum;
}


int main(int argc, char const *argv[])
{
    cin >> N;
    cin >> s;
    rep(i, N) {
        char_place[s[i] - 'a'].insert(i);
    }
    cin >> n_query;
    rep(_, n_query) {
        int t;
        cin >> t;
        if (t == 1) {
            int i;
            char c;
            cin >> i >> c;
            change_char(i-1, c, s[i-1]);
            // cerr << s << endl;
        } else {
            int l, r;
            cin >> l >> r;
            ans.push_back(num_chars(l-1, r-1));
        }
    }
    for (const auto a : ans) {
        cout << a << endl;
    }
    return 0;
}



Compiler output:
a.cc:3:7: error: expected nested-name-specifier before 'int'
    3 | using int = unsigned long long;
      |       ^~~
Language: C++

#include <bits/stdc++.h>
using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define MOD 1000000007

typedef long long int ll;

const ll INF=(ll)1e18;
//const int INF=(1<<30);


int main(){
  int n;
  cin >> n;
  string s;
  cin >> s;

  vector<set<int> > ss(26);

  REP(i,s.size()){
    int t =  s[i] - 'a';
    ss[t].insert(i);
  }

  int q;
  cin >> q;
  REP(i,q){
    int type;
    cin >> type;
    if(type==1){
      int t;
      char c;
      cin >> t >> c;
      t--;
      ss[s[t] - 'a'].erase(t);
      s[t] = c;
      ss[s[t] - 'a'].insert(t);
    }else{
      int l,r;
      cin >> l >> r;
      l--;r--;
      int ans=0;
      REP(j,26){
        if(s[j].lower_bound(l) <= r){
          ans++;
//          cout << j << ":" << endl;
        }else{
        }
      }
      cout << ans << endl;
    }
  }

}



Compiler output:
a.cc: In function 'int main()':
a.cc:46:17: error: request for member 'lower_bound' in 's.std::__cxx11::basic_string<char>::operator[](((std::__cxx11::basic_string<char>::size_type)j))', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<char>, char>::value_type' {aka 'char'}
   46 |         if(s[j].lower_bound(l) <= r){
      |                 ^~~~~~~~~~~
Language: C++

#include<iostream>
#include<stack>
#include<cstdio>
#include<map>
#include<set>
#include<queue>
#include<cstring>
#include<cmath>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
#define me(a,b) memset(a,b,sizeof(a))
#define inf 0x3f3f3f3f
const int N=500005;
int x,n,i,m,q,l,r,j,sum;
char s[N],ch;
int main()
{
	set<int> a[26];
	set<int>::iterator it;
	cin>>n;
	getchar();
	gets(s+1);
	for(i=1;s[i]!='\0';i++)
	{
		a[s[i]-'a'].insert(i);
	}
	cin>>m;
	while(m--)
	{
		cin>>q;
		if(q==1)
		{
			cin>>x>>ch;
			a[s[x]-'a'].erase(x);
			a[ch-'a'].insert(x);
			s[x]=ch;
		}
		else 
		{
			sum=0;
			cin>>l>>r;
			
				for(j=0;j<26;j++)
				{
					int p=*a[j].lower_bound(l);
					if(p>=l&&p<=r)sum++;
				}
			
			cout<<sum<<endl;
		}
	}
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:24:9: error: 'gets' was not declared in this scope; did you mean 'getw'?
   24 |         gets(s+1);
      |         ^~~~
      |         getw
Language: C++

#include <bits/stdc++.h>

// update sum segtree
struct S
{
	int x;
	S() {}
	S(int x) : x(x) {}
	void update(S a, S b) {
		x = a.x+b.x;
	}
};

struct SegmentTree
{
	int n;
	std::vector<S> data;
	SegmentTree(int n) : n(n), data(2*n,S(0)) {
	}
	void set(int i, S v) {
		data[i+n]=v;
	}
	void update(int i) {
		i+=n;
		for(;i>0;i>>=1) {
			data[i>>1].update(data[i],data[i^1]);
		}
	}
	void build() {
		for(int i=n-1;i>0;i--) {
			data[i>>1].update(data[i],data[i^1]);
		}
	}
	S get(int l, int r) {
		l+=n;r+=n;
		S sum = S(0);
		while(r>l) {
			if(l&1) sum.update(sum,data[l++]);
			if(r&1) sum.update(sum,data[--r]);
			l>>=1;r>>=1;
		}
		return sum;
	}
};

int main() {
	int n;
	std::cin >> n;
	std::string s;
	std::cin >> s;
	std::vector<SegmentTree> seg(26,SegmentTree(n));
	for(int i=0;i<n;i++) {
		int c = s[i]-'a';
		seg[c].set(i,S(1));
	}
	for(int i=0;i<26;i++) seg[i].build();
	int q;
	std::cin >> q;
	for(int qq=0;qq<q;qq++) {
		int qt;
		std::cin >> qt;
		if(qt==1) {
			int i; char c;
			std::cin >> i >> c;
			i--;
			if(s[i]==c) continue;
			seg[s[i]-'a'].set(i,S(0));
			seg[s[i]-'a'].update(i);
			s[i]=c;
			seg[s[i]-'a'].set(i,S(1));
			seg[s[i]-'a'].update(i);
		} else {
			int l,r;
			std::cin >> l >> r;
			l--;r--;
			int count = 0;
			for(int i=0;i<26;i++) {
				if(seg[i].get(l,r+1)) count++;
			}
			std::cout << count << '\n';
		}
	}
}



Compiler output:
a.cc: In function 'int main()':
a.cc:78:46: error: could not convert '(& seg.std::vector<SegmentTree>::operator[](((std::vector<SegmentTree>::size_type)i)))->SegmentTree::get(l, (r + 1))' from 'S' to 'bool'
   78 |                                 if(seg[i].get(l,r+1)) count++;
      |                                    ~~~~~~~~~~^~~~~~~
      |                                              |
      |                                              S
Language: C++

#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = (a); i < n; i++)
#define print(x) cout << x << endl;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
typedef long long ll;

int main()
{
    int n, q;
    string s;
    cin >> n >> s >> q;
    vector<set<int>> is(26);
    rep(i, 0, n) is[s[i]-'a'].insert(i);
    reo(qi, q) {
        int ty;
        cin >> ty;
        if (ty == 1) {
            int i; char c;
            cin >> i >> c;
            --i;
            is[s[i]-'a'].erase(i);
            s[i] = c;
            is[s[i]-'a'].insert(i);
        } else {
            int l, r;
            cin >> l >> r;
            --l;
            int ans = 0;
            rep(i, 26) {
                auto it = is[i].lower_bound(l);
                if (it != is[i].end() && *it < r) ++ans;
            }
            printf("%d\n", ans);
        }
    }


    return 0;
}

Compiler output:
a.cc:31:22: error: macro "rep" requires 3 arguments, but only 2 given
   31 |             rep(i, 26) {
      |                      ^
a.cc:2:9: note: macro "rep" defined here
    2 | #define rep(i, a, n) for (int i = (a); i < n; i++)
      |         ^~~
a.cc: In function 'int main()':
a.cc:16:9: error: 'qi' was not declared in this scope; did you mean 'q'?
   16 |     reo(qi, q) {
      |         ^~
      |         q
a.cc:16:5: error: 'reo' was not declared in this scope; did you mean 'rep'?
   16 |     reo(qi, q) {
      |     ^~~
      |     rep
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define N 2000000
bool tree[N][26];
string s;
bool ans[26];
void build(int st,int en,int node)
{
	if(st==en)
	{
		for(int i=0;i<26;++i)tree[node][i]=false;
		int x=s[st]-'a';
		tree[node][x]=true;
	    return;
	}
	int mid=(st+en)/2;
	build(st,mid,2*node);
	build(mid+1,en,2*node+1);
	for(int i=0;i<26;++i)tree[node][i]=tree[2*node][i]||tree[2*node+1][i];
}
void update(int st,int en,int x,int node)
{
	if(x<st||x>en||st>en)return;
	if(st==en&&en==x)
	{
		for(int i=0;i<26;++i)tree[node][i]=false;
		int x=s[st]-'a';
	    tree[node][x]=true;
	    return;
	}
	int mid=(st+en)/2;
	if(mid>=x)update(st,mid,2*node);
	else update(mid+1,en,2*node+1);
	for(int i=0;i<26;++i)tree[node][i]=tree[2*node][i]||tree[2*node+1][i];
}
void query(int st,int en,int l,int r,int node)
{
	if(st>en||st>r||en<l)return;
	if(st>=l&&en<=r)
	{
		for(int i=0;i<26;++i)ans[i]=ans[i]||tree[node][i];
		return;
	}
	int mid=(st+en)/2;
	query(st,mid,l,r,2*node);
	query(mid+1,r,l,r,2*node+1);
}
int main() {
	// your code goes here
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n; cin>>n; cin>>s;
	int q; cin>>q;
	memset(tree,0,sizeof(tree));
	build(0,n-1,1);
	while(q--)
	{
		int x,y,z; char ch;
		cin>>x;
		if(x==1)
		{
			cin>>y>>ch;
			y--;
			if(s[y]!=ch){ s[y]=ch;
			update(0,n-1,y,1);
		  }
		}
		else
		{
			cin>>y>>z;
			y--,z--;
			for(int i=0;i<26;++i)ans[i]=false;
			query(0,n-1,y,z,1);
			int cnt=0;
			for(int i=0;i<26;++i)if(ans[i])cnt++;
			cout<<cnt<<endl;
		}
	}

}

Compiler output:
a.cc: In function 'void update(int, int, int, int)':
a.cc:32:25: error: too few arguments to function 'void update(int, int, int, int)'
   32 |         if(mid>=x)update(st,mid,2*node);
      |                   ~~~~~~^~~~~~~~~~~~~~~
a.cc:21:6: note: declared here
   21 | void update(int st,int en,int x,int node)
      |      ^~~~~~
a.cc:33:20: error: too few arguments to function 'void update(int, int, int, int)'
   33 |         else update(mid+1,en,2*node+1);
      |              ~~~~~~^~~~~~~~~~~~~~~~~~~
a.cc:21:6: note: declared here
   21 | void update(int st,int en,int x,int node)
      |      ^~~~~~
Language: C++

#include <bits/stdc++.h>

using namespace std;

struct BIT{
  vector<int>node;
  int sz;
  BIT(int sz):sz(sz){
    node.resize(sz,0);
  }
  int sum(int i){
    int res=0;
    for(i--;i>=0;i=(i&(i+1))-1)res+=node[i];
    return res;
  }
  void add(int i,int x){
    for(;i<sz;i|=i+1)node[i]+=x;
  }
  int sum(int l,int r){
    return sum(r)-sum(l);
  }
};

signed main(){
  int N;
  string S;
  cin>>N>>S;
  vector<BIT>bits;
  for(int i=0;i<26;i++)bits.push_back(BIT(N));
  for(int i=0;i<N;i++){
    bits[S[i]-'a'].add(i,1);
  }
  int Q;
  cin>>Q;
  for(int i=0;i<Q;i++){
    int q;
    cin>>q;
    if(q==1){
      int index;
      char c;
      cin>>index>>c;
      index--;
      bits[S[index]-'a'].add(index,-1);
      bits[c-'a'].add(index,1);
      S[index]=c;
    }
    if(q==2){
      int l,r;
      cin>>l>>r;
      l--,r--;
      int ans=0;
      for(int j=0;j<26;j++){
        ans+=min(it.sum(l,r+1),1);
      }
      cout<<ans<<endl;
    }
  }
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:53:18: error: 'it' was not declared in this scope; did you mean 'i'?
   53 |         ans+=min(it.sum(l,r+1),1);
      |                  ^~
      |                  i
Language: C++

#include <bits/stdc++.h>
using namespace std;
const int SEG_LEN = 1<<20;

// 1-indexedのセグメント木
vector<int> seg(SEG_LEN, 0);

// id番目(1-indexed)の値をxに更新
void update(int id, int x){
    id += SEG_LEN; seg[id] = x;
    while(id > 0){
        id /= 2;
        seg[id] = seg[2*id] | seg[2*id+1];
    }
}

// 区間[l,r)に対するクエリ(総和)
int query(int l, int r){
    l += SEG_LEN; r += SEG_LEN;

    int res = 0;
    while(l < r){
        if(l % 2 == 1){ res |= seg[l]; l++; }
        l /= 2;
        if(r % 2 == 1){ res |= seg[r-1]; r--; }
        r /= 2;
    }
    return res;
}

int main(){
    int N, Q; string S;
    cin >> N >> S >> Q;

    for(int i=1; i<=S.length(); i++){
        update(i, 1<<(S[i-1]-'a'));
    }

    for(int q=0; q<Q; q++){
        int a; cin >> a;
        if(a == 1){
            int id; char ch; cin >> id >> ch;
            //update(id, (1 << (ch-'a')));
        }
        if(a == 2){
            int l, r; cin >> l >> r;
            int res = query(l, r+1);
            int res = 3;

            int ans = 0;
            while(res > 0){
                ans += res & 1; res /= 2;
            }
            cout << ans << endl;
        }
    }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:48:17: error: redeclaration of 'int res'
   48 |             int res = 3;
      |                 ^~~
a.cc:47:17: note: 'int res' previously declared here
   47 |             int res = query(l, r+1);
      |                 ^~~
Language: C++

#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
using namespace std;
#define rep(i,n) for(int i=0;i<n;++i)
#define all(a) (a).begin(),(a).end()
#define pb emplace_back //emplace_backの方が速いが使い慣れてないため
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
ll  n, m, d, e, r, l, k, h, w, Q, ans, ret = M;
string s, t, u;
ll x, y;


int main() {
	cin.tie(0); ios::sync_with_stdio(false);//not intractive
	cin >> n >> s >> Q;
	vll bit(n);
	rep(i, n) bit[i]= 1 << (s[i] - 'a');
	while (Q--) {
		cin >> x;
		if (x == 1) {
			char c;
			cin >> y >> c;
			y--;
			bit[y] = 1 << (c - 'a');
		}
		else {
			int l, r;
			cin >> l >> r;
			l--;
			ans = 0;
			for (int i = l; i < r; i++)ans |= bit[i];
			cout << __builtin_popcount(ans) << endl;
		}
	}
	return 0;
}

Compiler output:
a.cc:12:46: error: 'M' was not declared in this scope
   12 | ll  n, m, d, e, r, l, k, h, w, Q, ans, ret = M;
      |                                              ^
Language: C

#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
using namespace std;
#define rep(i,n) for(int i=0;i<n;++i)
#define all(a) (a).begin(),(a).end()
#define pb emplace_back //emplace_backの方が速いが使い慣れてないため
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
ll  n, m, d, e, r, l, k, h, w, Q, ans, ret = M;
string s, t, u;
ll x, y;


int main() {
	cin.tie(0); ios::sync_with_stdio(false);//not intractive
	cin >> n >> s >> Q;
	vll bit(n);
	rep(i, n) bit[i]= 1 << (s[i] - 'a');
	while (Q--) {
		cin >> x;
		if (x == 1) {
			char c;
			cin >> y >> c;
			y--;
			bit[y] = 1 << (c - 'a');
		}
		else {
			int l, r;
			cin >> l >> r;
			l--;
			ans = 0;
			for (int i = l; i < r; i++)ans |= bit[i];
			cout << __builtin_popcount(ans) << endl;
		}
	}
	return 0;
}

Compiler output:
main.c:1:10: fatal error: iostream: No such file or directory
    1 | #include <iostream>
      |          ^~~~~~~~~~
compilation terminated.
Language: C++

#include<iostream>
#include<stack>
#include<cstdio>
#include<map>
#include<set>
#include<queue>
#include<cstring>
#include<cmath>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
#define me(a,b) memset(a,b,sizeof(a))
#define inf 0x3f3f3f3f
const int N=500005;
int x,n,i,m,q,l,r,j,sum;
char s[N],ch;
int main()
{
	set<int> a[26];
	set<int>::iterator it;
	cin>>n;
	getchar();
	gets(s+1);
	for(i=1;s[i]!='\0';i++)
	{
		a[s[i]-'a'].insert(i);
	}
	cin>>m;
	while(m--)
	{
		cin>>q;
		if(q==1)
		{
			cin>>x>>ch;
			a[s[x]-'a'].erase(x);
			a[ch-'a'].insert(x);
			s[x]=ch;
		}
		else 
		{
			sum=0;
			cin>>l>>r;
			for(i=l;i<=r;i++)
			{
				for(j=0;j<26;j++)
				{
					auto p=a[j].lower_bound(l)
					if(p!=a[j].end()&&*p<=r)sum++;
				}
			}
			cout<<sum<<endl;
		}
	}
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:24:9: error: 'gets' was not declared in this scope; did you mean 'getw'?
   24 |         gets(s+1);
      |         ^~~~
      |         getw
a.cc:49:41: error: expected ',' or ';' before 'if'
   49 |                                         if(p!=a[j].end()&&*p<=r)sum++;
      |                                         ^~
Language: C++

#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
using namespace std;
#define rep(i,n) for(int i=0;i<n;++i)
#define all(a) (a).begin(),(a).end()
#define pb emplace_back //emplace_backの方が速いが使い慣れてないため
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
ll  n, m, d, e, r, l, k, h, w, Q, ans, ret = M;
string s, t, u;
ll x, y;


int main() {
	cin.tie(0); ios::sync_with_stdio(false);//not intractive
	cin >> n >> s >> Q;
	vll bit(n);
	rep(i, n) bit[i]= 1 << (s[i] - 'a');
	while (Q--) {
		cin >> x;
		if (x == 1) {
			char c;
			cin >> y >> c;
			y--;
			bit[y] = 1 << (c - 'a');
		}
		else {
			int l, r;
			cin >> l >> r;
			l--;
			ans = 0;
			for (int i = l; i < r; i++)ans |= bit[i];
			cout << __builtin_popcount(ans) << endl;
		}
	}
	return 0;
}


Compiler output:
a.cc:12:46: error: 'M' was not declared in this scope
   12 | ll  n, m, d, e, r, l, k, h, w, Q, ans, ret = M;
      |                                              ^
Language: C++

#include<bits/stdc++.h>
using namespace std;

template<class T,class F>
struct segtree{
  int n;
  T e;
  F f;
  std::vector<T> dat;

  segtree(){}
  segtree(int sz,T _e,F _f):e(_e),f(_f){
    n = 1;
    while(n<=sz)n<<=1;
    dat.resize(2*n,e);
  }
  segtree(std::vector<T> const& v,T _e,F _f):e(_e),f(_f){
    build(v);
  }
  void build(std::vector<T> const& v){
    n = 1;
    int sz = v.size();
    while(n<=sz)n<<=1;
    dat.resize(2*n,e);
    for(int i=0;i<sz;++i){
      dat[i+n] = v[i];
    }
    for(int i=n-1;i>0;--i){
      dat[i] = f(dat[i<<1],dat[i<<1|1]);
    }
  }
  void set(int p,T v){
    for(dat[p+=n]=v;p>1;p>>=1){
      dat[p>>1] = f(dat[p],dat[p^1]);
    }
  }
  T query(int l,int r){
    T res = e;
    for(l+=n,r+=n;l<r;l>>=1,r>>=1){
      if(l&1){
        res = f(res,dat[l]);
        l++;
      }
      if(r&1){
        r--;
        res = f(res,dat[r]);
      }
    }
    return res;
  }
  T operator[](int k){
    return query(k,k+1);
  }
};

signed main(){

  int n;
  string s;
  cin>>n>>s;

  vector<int> a(n);
  for(int i=0;i<n;++i){
    a[i] = s[i]-'a';
  }

  using bits = bitset<26>;
  vector<bits> c(n);
  for(int i=0;i<n;++i){
    c[i].set(a[i]);
  }
  auto merge = [](auto& a,auto& b){
    return a|b;
  };
  bits id;

  segtree<bits,decltype(merge)> seg(c,id,merge);

  int q;
  cin>>q;
  while(q--){
    int com;
    cin>>com;
    if(com==1){
      int i;
      char c;
      cin>>i>>c;
      i--;
      bits t;
      t.set(c-'a');
      seg.set(i,t);
    }
    if(com==2){
      int l,r;
      cin>>l>>r;
      l--;r--;
      bits res = seg.query(l,r+1);
      cout<< res.count <<endl;
    }
  }

}

Compiler output:
a.cc: In function 'int main()':
a.cc:98:11: error: invalid use of non-static member function 'std::size_t std::bitset<_Nb>::count() const [with long unsigned int _Nb = 26; std::size_t = long unsigned int]'
   98 |       cout<< res.count <<endl;
      |       ~~~~^~~~~~~~~~~~
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52,
                 from a.cc:1:
/usr/include/c++/14/bitset:1366:7: note: declared here
 1366 |       count() const _GLIBCXX_NOEXCEPT
      |       ^~~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define rep(i,n) for(ll i = 0; i < (ll)(n); i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF = 1LL << 60;
//set<int> se[26];
// inline int c2i(char c){
//     return (int)(c-'a');
// }
int main(){
    int n;
    string s;
    int q;
    cin >> n >> s >> q;
    rep(i,n){
        se[s[i]-'a'].insert(i);
    }
    set<int> se[26];
    
    rep(qi,q){
        int a;
        cin >> a;
        if(a==1){
            int i;
            char c;
            cin >> i >> c;
            i--;
            //cout << i << c << endl;    
            se[s[i]-'a'].erase(i);
            s[i] = c;
            se[c-'a'].insert(i);
        }else{
            int l,r;
            cin >> l >> r;
            l--; r--;
            int ans = 0;
            rep(i,26){
                auto tmp = lower_bound(se[i].begin(),se[i].end(),l);
                if(tmp == se[i].end()) continue;
                if(*tmp<=r) ans++;
            }
            cout << ans << endl;
            //cout << "aaaaa" << endl;
        }
    }
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:19:9: error: 'se' was not declared in this scope; did you mean 's'?
   19 |         se[s[i]-'a'].insert(i);
      |         ^~
      |         s
Language: C++

#include <bits/stdc++.h>

using namespace std;

struct seg_tree {
    int offset = 0;
    vector<int> nodes;
    seg_tree(int n, string& str) {
        offset = 1;
        while(offset < n) offset <<= 1;
        nodes.assign(offset*2,0);
        build(0, n-1, 0, str);
    };
    void build(int l, int r, int id, string& str) {
        if (l == r) {
            nodes[id] = 1<<(str[l]-'a');        
        } else {
            int mid = l + (r-l)/2;
            int lid = id*2+1;
            int rid = id*2+2;
            build(l,mid,   lid, str);
            build(mid+1,r, rid, str);
            nodes[id] = nodes[lid] | nodes[rid];
        }
    }
    void update(int tl, int tl, int ql, int qr, char a) {
        int id = offset + at;
        nodes[id] = 1<<(a-'a');
        while(id > 0) {
            int par = (id-1)/2;
            nodes[par] = nodes[par*2+1];
            if (par*2+2 < nodes.size()) nodes[par] |= nodes[par*2+2];
            id = par;
        }
    }
    int get(int tl, int tr, int ql, int qr, int id = 0) {
        if (tr < ql || qr < tl) return 0;
        if (ql <= tl && tr <= qr) return nodes[id];
        if (tl == tr) return nodes[id];
        else {
            int mid = tl + (tr - tl) / 2;
            return get(tl,mid, ql, qr, id*2 + 1) | get(mid+1,tr,ql,qr,id*2+2);
        }
    }
};

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

    int N; cin>>N;

    string s; cin>>s;

    seg_tree st(N, s);

    int M; cin>>M;

    for (int i =0;i<M;i++) {
        int q; cin>>q;
        if (q == 1) {
            int at; char c;
            cin>>at>>c;
            st.update(at-1, c);
        }
        else {
            int l,r;cin>>l>>r;
            cout<<__builtin_popcount(st.get(0,N-1,l-1,r-1))<<endl;
        }
    }
    return 0;
}

Compiler output:
a.cc:26:29: error: redefinition of 'int tl'
   26 |     void update(int tl, int tl, int ql, int qr, char a) {
      |                         ~~~~^~
a.cc:26:21: note: 'int tl' previously declared here
   26 |     void update(int tl, int tl, int ql, int qr, char a) {
      |                 ~~~~^~
a.cc: In member function 'void seg_tree::update(...)':
a.cc:27:27: error: 'at' was not declared in this scope; did you mean 'a'?
   27 |         int id = offset + at;
      |                           ^~
      |                           a
Language: C++

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>

using namespace std;

int A[30][2100000];

int NUM = 1 << 20;

void update(int i, int k, int val) {

	A[i][k + NUM] = val;

	int x = k + NUM;

	int p = x / 2;
	while (p > 0) {
	A[i][p] = A[i][p * 2] + A[i][p * 2 + 1];
	p /= 2;
    }
}

int rmq(int i, int p, int a, int b, int l, int r) {

	int ret = 0;
	if (r < a || b < l) { return 0; }

	if (a <= l && r <= b) { ret+=A[i][p]; }
	else {
		ret += rmq(i, p * 2, a, b, l, (r + l) / 2);
		ret += rmq(i, p * 2 + 1, a, b, (r + l) / 2 + 1, r);
	}

	return ret;
}

int N;
string S;
int Q;

int query[100005];
int iq,lq,rq;
char cq;

int main(void) {

	cin >> N >> S >> Q;

	for (int i = 1; i <= N; i++) {
		update(S[i-1] - 'a', i, 1);
	}

	for (int q = 1; q <= Q; q++) {
		cin >> q;

		if (q == 1) {
			cin >> iq>>cq;
			char pre = S[iq];
			update(pre - 'a', iq, 0);
			S[iq] = cq;
			update(cq - 'a', iq, 1);
		}
		else if (q == 2) {
			cin >> lq >> rq;
			int ans = 0;
			for (int k = 0; k < 26; k++) {
				if (rmq(k, 1,lq, rq,0, NUM-1) > 0) { ans++; }
			}
		}
		cout << ans << endl;
	}

	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:73:25: error: 'ans' was not declared in this scope; did you mean 'abs'?
   73 |                 cout << ans << endl;
      |                         ^~~
      |                         abs
Language: C++

#include "stdafx.h"
#include <bits/stdc++.h>
#define f(i,n) for(int i=0;i<n;i++)
#define P pair<int,int>
#define F first
#define S second
#define int long long
#define mod 1000000007
#define all(v) v.begin(), v.end()
using namespace std;
vector<int> v[200];
int mypow(int a, int b, int c) {
	if (b == 0)return 1;
	if (b % 2)return mypow(a, b - 1, c)*a%c;
	int z = mypow(a, b / 2, c);
	return z * z%c;
}
signed main() {
	int a, b;
	string s;
	cin >> a >> s >> b;
	f(i, a) {
		v[s[i] - 'a'].push_back(i);
	}
	f(i, b) {
		int x;
		cin >> x;
		if (x == 1) {
			int y;
			char c;
			cin >> y >> c;
			v[s[y - 1] - 'a'].erase(lower_bound(all(v[s[y - 1] - 'a']), y - 1));
			s[y - 1] = c;
			v[c - 'a'].push_back(y - 1);
		}
		else {
			int y, z;
			cin >> y >> z;
			int cnt = 0;
			f(j, 26) {
				if (lower_bound(all(v[j]), z) - lower_bound(all(v[j]), y-1)) {
					cnt++;
				}
			}
			cout << cnt << endl;
		}
	}
}

Compiler output:
a.cc:1:10: fatal error: stdafx.h: No such file or directory
    1 | #include "stdafx.h"
      |          ^~~~~~~~~~
compilation terminated.