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

#include <vector>
#include <set>
#include <iostream>

struct segment_tree {
    void build(std::string const &a) {
        t.resize(4 * a.size());
        build(0, 0, a.size(), a);
    }

    void update(size_t pos, char new_value) {
        update(0, 0, t.size() / 4, pos, new_value);
    }

    int32_t get(size_t l, size_t r) {
        return get(0, 0, t.size() / 4, l, r + 1).size();
    }

private:
    std::vector<std::set<char>> t;
    void build(size_t v, size_t l, size_t r, std::string const &a) {
        if (l + 1 == r) {
            std::set<char> m;
            m.insert(a[l]);
            t[v] = m;
        } else {
            size_t mid = (l + r) / 2;
            build(2 * v + 1, l, mid, a);
            build(2 * v + 2, mid, r, a);
            for (auto elem : t[2 * v + 1]) {
                t[v].insert(elem);
            }
            for (auto elem : t[2 * v + 2]) {
                t[v].insert(elem);
            }
        }
    }

    void update(size_t v, size_t l, size_t r, size_t pos, char new_value) {
        if (l + 1 == r) {
            std::set<char> m;
            m.insert(new_value);
            t[v] = m;
        } else {
            size_t mid = (l + r) / 2;
            if (pos < mid) {
                update(2 * v + 1, l, mid, pos, new_value);
            } else {
                update(2 * v + 2, mid, r, pos, new_value);
            }
            t[v].clear()
            for (auto elem : t[2 * v + 1]) {
                t[v].insert(elem);
            }
            for (auto elem : t[2 * v + 2]) {
                t[v].insert(elem);
            }
        }
    }

    std::set<char> get(size_t v, size_t l, size_t r, size_t req_l, size_t req_r) {
        if (req_l >= req_r) {
            return std::set<char> ();
        } else if (l == req_l && r == req_r) {
            return t[v];
        } else {
            size_t mid = (l + r) / 2;
            std::set<char> cur = get(2 * v + 1, l, mid, req_l, std::min(mid, req_r));
            for (auto elem : get(2 * v + 2, mid, r, std::max(mid, req_l), req_r)) {
                cur.insert(elem);
            }
            return cur;
        }
    }
};

int main() {
    std::ios_base::sync_with_stdio(false);
    segment_tree chr;
    size_t n;
    std::string a;
    std::cin >> n >> a;
    chr.build(a);
    size_t k;
    std::cin >> k;
    while (k-- > 0) {
        size_t type;
        std::cin >> type;
        if (type == 1) {
            size_t pos;
            char ch;
            std::cin >> pos >> ch;
            chr.update(pos - 1, ch);
        } else {
            size_t l, r;
            std::cin >> l >> r;
            std::cout << chr.get(l - 1, r - 1) << '\n';
        }
    }

    return 0;
}


Compiler output:
a.cc: In member function 'void segment_tree::update(size_t, size_t, size_t, size_t, char)':
a.cc:52:13: error: expected ';' before 'for'
   52 |             for (auto elem : t[2 * v + 1]) {
      |             ^~~
Language: Java



public class Main 
{
	static class Node
	{ //Segment Tree.
		//range
		int rangel;
		int ranger;
		
		int val = 0;
		
		Node l = null;
		Node r = null;
		
		int check(int ql, int qr)
		{
			int lin = Math.max(ql, rangel);
			int rin = Math.min(qr, ranger);
			
			if(rin < lin) return 0;
			if(lin == rangel && rin == ranger)
			{
				return val;
			}
			else
			{
				return l.check(lin, rin) + r.check(lin, rin);
			}
			
		}
		
		void update(int pos, int add)
		{
			if(rangel <= pos && pos <= ranger)
			{
				val += add;
				if(l != null)l.update(pos, add);
				if(r != null)r.update(pos, add);
			}
		}
		
		public Node(int l0, int r0)
		{
			rangel = l0;
			ranger = r0;
			
			if(rangel != ranger)
			{ //make children
				int mid = (rangel + ranger)/2;
				//l child
				l = new Node(l0, mid);
				r = new Node(mid+1, r0);
			}
		}
	}

	public static void main(String[] args) 
	{
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String s = sc.next();
		int q = sc.nextInt();
		//make 26 segment trees
		Node[] seg = new Node[26];
		int[] st = new int[n];
		
		for(int i = 0; i < 26; i++)
			seg[i] = new Node(0, n-1);
		
		//initialize trees
		for(int i = 0; i < s.length(); i++)
		{
			int ch = s.charAt(i) - 'a';
			seg[ch].update(i, 1);
			st[i] = ch;
		}
		
		StringBuilder sb = new StringBuilder();
		
		for(int i = 0; i < q; i++)
		{ //take queries
			int t = sc.nextInt();
			if(t == 1)
			{
				int pos = sc.nextInt()-1;
				//change character
				int ori = st[pos];
				int nw = sc.next().charAt(0) - 'a';
				
				seg[ori].update(pos, -1);
				seg[nw].update(pos, 1);
			}
			else if(t == 2)
			{
				int l = sc.nextInt()-1;
				int r = sc.nextInt()-1;
				
				int an = 0;
				for(int k = 0; k < 26; k++)
				{
					if(seg[k].check(l, r) > 0)an++;
				}
				
				sb.append(an);
				sb.append('\n');
//				System.out.println(an);
				
			}
		}
		
		System.out.print(sb);
		
		
	}

}


Compiler output:
Main.java:60: error: cannot find symbol
		Scanner sc = new Scanner(System.in);
		^
  symbol:   class Scanner
  location: class Main
Main.java:60: error: cannot find symbol
		Scanner sc = new Scanner(System.in);
		                 ^
  symbol:   class Scanner
  location: class Main
2 errors
Language: C++

#include <iostream>
#include <string>
#include <vector>

int main() {
  int n, q;
  std::string s;
  std::cin >> n >> s >> q;

  int t;
  for (int i = 0; i < q; ++i) {
    std::cin >> t;
    if (t == 1) {
      int i;
      char c;
      std::cin >> i >> c;
      --i;
      if (s.at(i) != c)
        s.at(i) = c;
    }
    if (t == 2) {
      int r, l;
      std::cin >> l >> r;
      std::vector<int> v;
      for (auto &c : s.substr(l - 1, r ))
        if (std::find(v.begin(), v.end(), c) == v.end())
          v.push_back(c);
      std::cout << v.size() << std::endl;
    }
  }
}


Compiler output:
a.cc: In function 'int main()':
a.cc:26:22: error: no matching function for call to 'find(std::vector<int>::iterator, std::vector<int>::iterator, char&)'
   26 |         if (std::find(v.begin(), v.end(), c) == v.end())
      |             ~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/bits/locale_facets.h:48,
                 from /usr/include/c++/14/bits/basic_ios.h:37,
                 from /usr/include/c++/14/ios:46,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/bits/streambuf_iterator.h:435:5: note: candidate: 'template<class _CharT2> typename __gnu_cxx::__enable_if<std::__is_char<_CharT2>::__value, std::istreambuf_iterator<_CharT> >::__type std::find(istreambuf_iterator<_CharT>, istreambuf_iterator<_CharT>, const _CharT2&)'
  435 |     find(istreambuf_iterator<_CharT> __first,
      |     ^~~~
/usr/include/c++/14/bits/streambuf_iterator.h:435:5: note:   template argument deduction/substitution failed:
a.cc:26:22: note:   '__gnu_cxx::__normal_iterator<int*, std::vector<int> >' is not derived from 'std::istreambuf_iterator<_CharT>'
   26 |         if (std::find(v.begin(), v.end(), c) == v.end())
      |             ~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
Language: C++

// g++ -std=gnu++1y -O2 main.cpp

#include <cstdio>
#include <vector>
#include <map>
#include <unordered_map>
#include <string>
#include <utility>
#include <algorithm>
#include <iostream>
#include <iostream>
#include <climits>

using namespace std;

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; }

int main() {
	int N;
	string S;
	int Q;

	cin >> N;
	cin >> S;
	cin >> Q;

	for (int i = 0; i < Q; i++) {
		int q;
		cin >> q;
		if (q == 1) {
			int iq;
			char cq;
			cin >> iq >> cq;
			S[iq - 1] = cq;
		}
		else if (q == 2) {
			int iq, cq;
			cin >> iq >> cq;

			unordered_map<char, bool> map;
			for (int j = iq - 1; j < cq; j++)
			{
				map[S[j]] = true;
			}
			cout << map.size() << endl;
		}
		else {
			assert(true);
		}
	}
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:49:25: error: 'assert' was not declared in this scope
   49 |                         assert(true);
      |                         ^~~~~~
a.cc:13:1: note: 'assert' is defined in header '<cassert>'; this is probably fixable by adding '#include <cassert>'
   12 | #include <climits>
  +++ |+#include <cassert>
   13 |
Language: C++

#include <iostream>
#include<stdio.h>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<algorithm>
#include<cstring>
#include<math.h>
#include<cmath>
using namespace std;
set<int>lp[30];
int main()
{
    int n,i,j,k,l;
    string s;
    cin>>n>>s;
    for(i=0;i<n;i++)
    {
        lp[s[i]-'a'].insert(i);
    }
    cin>>k;
    char pi;
    for(i=0;i<k;i++)
    {
        cin>>j;
        if(j==1)
        {
            cin>>l>>pi;
            l--;
            lp[s[l]-'a'].erase(l);
            lp[pi-'a'].insert(l);
        }
        else
        {
            int sum=0,p,q;
            cin>>p>>q;
            p--,q--;
            set<int>::iterator op;
            for(int pp=0;pp<26;pp++)
            {
                po=lp[pp].lower_bound(p);
                if(po!=lp[pp].end())
                    if(*po<=q)
                    sum++;
            }
            cout<<sum<<endl;
        }
    }
    return 0;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:43:17: error: 'po' was not declared in this scope; did you mean 'pp'?
   43 |                 po=lp[pp].lower_bound(p);
      |                 ^~
      |                 pp
Language: C++

#ABC157E

n = int(input())
s = list(input())
q = int(input())
bits = [[0 for _ in range(n+1)] for _ in range(26)]
sl = []
for alp in s:
	alpord = ord(alp) - 97
	sl.append(alpord)
#print(bits) #test
#print(sl) #test
#print('クエリ開始') #test

def query(pos):
	ret = [0] * 26
	p = pos
	while p > 0:
		for i in range(26):
			ret[i] += bits[i][p]
		p -= p&(-p)
	return ret

def update(pos, a, x):
	r = pos
	while r <= n:
		bits[a][r] += x
		r += r&(-r)

for i in range(n):
	update(i+1, sl[i], 1)
#print(bits) #test

for _ in range(q):
	quer, xx, yy = map(str, input().split())
	if quer == '1':
		x = int(xx)
		y = ord(yy) - 97
		if sl[x-1] == y:
			continue
		else:
			update(x, sl[x-1], -1)
			update(x, y, 1)
			sl[x-1] = y
		#print('クエリ1でした') #test
		#print(bits) #test
		#print(sl) #test
	else:
		x = int(xx)
		y = int(yy)
		cnt1 = query(y)
		cnt2 = query(x-1)
		#print('クエリ2です') #test
		#print(cnt1) #test
		#print(cnt2) #test
		ans = 0
		for i in range(26):
			if cnt1[i] - cnt2[i] > 0:
				ans += 1
		print(ans)

Compiler output:
a.cc:1:2: error: invalid preprocessing directive #ABC157E
    1 | #ABC157E
      |  ^~~~~~~
a.cc:11:2: error: invalid preprocessing directive #print
   11 | #print(bits) #test
      |  ^~~~~
a.cc:12:2: error: invalid preprocessing directive #print
   12 | #print(sl) #test
      |  ^~~~~
a.cc:13:2: error: invalid preprocessing directive #print
   13 | #print('クエリ開始') #test
      |  ^~~~~
a.cc:32:2: error: invalid preprocessing directive #print
   32 | #print(bits) #test
      |  ^~~~~
a.cc:45:18: error: invalid preprocessing directive #print
   45 |                 #print('クエリ1でした') #test
      |                  ^~~~~
a.cc:46:18: error: invalid preprocessing directive #print
   46 |                 #print(bits) #test
      |                  ^~~~~
a.cc:47:18: error: invalid preprocessing directive #print
   47 |                 #print(sl) #test
      |                  ^~~~~
a.cc:53:18: error: invalid preprocessing directive #print
   53 |                 #print('クエリ2です') #test
      |                  ^~~~~
a.cc:54:18: error: invalid preprocessing directive #print
   54 |                 #print(cnt1) #test
      |                  ^~~~~
a.cc:55:18: error: invalid preprocessing directive #print
   55 |                 #print(cnt2) #test
      |                  ^~~~~
a.cc:3:1: error: 'n' does not name a type
    3 | n = int(input())
      | ^
Language: C++

#include <bits/stdc++.h>
#define repr(i,from,to) for(int (i)=(from);(i)<(to);(i)++)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
// const bool debug=true;
const bool debug=false;
#define DEBUG if(debug==true)
#define vprint(x) for(auto a:(x)) cout << x << endl;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1000000007;
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) { a = b; return true;}
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) { a = b; return true;}
    return false;
}
int main(void) {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,q;
    string s;
    cin>>n>>s>>q;
    vector<set<int>> idxes(26, set<int>({1<<30}));
    rep(i,s.size()) {
        idxes[s[i]-'a'].insert(i);
    }
    rep(i,q) {
        int num;cin>>num;
        if (num==1) {
            int idx;cin>>idx;
            char c;cin>>c;
            idxes[s[--idx]-'a'].erase(idx);
            s[idx] = c;
            idxes[c-'a'].insert(idx);
        }
        else {
            int l,r;cin>>l>>r;
            l--;r--;
            int cnt = 0;
            rep(i,26) {
                if (idxes[i].empty())continue;
                auto target = &idxes[i];
                auto from = *target.lower_bound(l);
                if(from<=r) cnt++;
            }
            cout << cnt << endl;
        }
    } 
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:46:37: error: request for member 'lower_bound' in 'target', which is of pointer type 'std::set<int>*' (maybe you meant to use '->' ?)
   46 |                 auto from = *target.lower_bound(l);
      |                                     ^~~~~~~~~~~
Language: C++

//けんちょんさんブログからまるコぴ
#include <bits/stdc++.h>
using namespace std;

const int INF = 1<<30;
int N, Q;
string S;
vector<set<int> > pls;

void solve() {
    pls.assign(26, set<int>({INF}));
    for (int i = 0; i < N; ++i) pls[S[i] - 'a'].insert(i);

    while (Q--) {
        int type; cin >> type;
        if (type == 1) {
            int ind; char nc; cin >> ind >> nc; --ind;
            auto pc = S[ind];
            S[ind] = nc;
            pls[pc - 'a'].erase(ind);
            pls[nc - 'a'].insert(ind);
        }
        else {
            int l, r; cin >> l >> r; --l;
            int res = 0;
            for (int c = 0; c < 26; ++c) {
                if (pls[c].empty()) continue;
                int lid = *pls[c].lower_bound(l);
                int rid = *pls[c].lower_bound(r);
                if (rid > lid) ++res;
            }
            cout << res << endl;
        }
    }
}

int main() {
    cin >> N >> S >> Q;
    solve();
}
解

Compiler output:
a.cc:41:1: error: '\U000089e3' does not name a type
   41 | 解
      | ^~
Language: C++

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

int n,q;
int a[30][10000005];

char s[500005];

int lowbit(int n)
{
	return n&(-n);
}

int get(char x)
{
	return x-'a'+1;
}

inline void change(int num,int rt,int plus)
{
	while (rt<=n)
	{
		a[num][rt]+=plus;
		rt+=lowbit(rt);
	}
}

inline int get_sum(int num,int r)
{
	int sumv=0;
	while (r>=1)
	{
		sumv+=a[num][r];
		r-=lowbit(r);
	}
	return sumv;
}

signed main()
{
	cin>>n;
	for (int i=1;i<=n;i++)
	{
		cin>>s[i];
		change(get(s[i]),i,1);
	}
	cin>>q;
	
	while (q--)
	{
		int flag,t1,t2;
		cin>>flag;
		
		if (flag==1)
		{
			char x;
			cin>>t1>>x;
			change(get(x),t1,1);
			change(get(s[t1]),t1,-1);
		}
		else if (flag==2)
		{
			int tot=0;
			
			cin>>t1>>t2;
			for (int i=1;i<=26;i++)
			{
				if (get_sum(i,t2)-get_sum(i,t1-1))  tot++;
			}
			cout<<tot<<endl;
		}
	}
	return 0;
}

Compiler output:
/tmp/ccyPq8T6.o: in function `main':
a.cc:(.text+0x58): relocation truncated to fit: R_X86_64_PC32 against symbol `s' defined in .bss section in /tmp/ccyPq8T6.o
a.cc:(.text+0x78): relocation truncated to fit: R_X86_64_PC32 against symbol `s' defined in .bss section in /tmp/ccyPq8T6.o
a.cc:(.text+0x14c): relocation truncated to fit: R_X86_64_PC32 against symbol `s' defined in .bss section in /tmp/ccyPq8T6.o
collect2: error: ld returned 1 exit status
Language: C++

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

#define ll long long
#define pb push_back
#define fi first
#define se second
#define endl '\n'
#define fcin ios::sync_with_stdio(false); cin.tie(nullptr);
#define inf 0x3f3f3f3f
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

/* 
* stuff you should look for
* int overflow, array bounds
* special cases (n=1?), set tle
*/

set<int> a[27];

int main(){
    fcin;
  	int n;
  	cin >> n;
    string s;
    cin >> s;
    s = " " + s;
    for(int i = 1; i <= n; i++) a[s[i]-'a'].insert(i);
    int q;
    cin >> q;
    while(q--){
        int type;   cin >> type;
        if(type == 1){
            int pos;
            char c;
            cin >> pos >> c;
            a[s[pos]-'a'].erase(pos);
            s[pos] = c;
            a[s[pos]-'a'].insert(pos);
        } else {
            int l, r;
            cin >> l >> r;
            int ans = 0;
            for(int i = 0; i < 27; i++){
                auto k = a[i].lower_bound(l);
                if(k != a[i].end() and *k <= r) ans++;
            }
            cout << ans << endl;
        }
    }
    return 0;
}
 

Compiler output:
a.cc:53:1: error: extended character   is not valid in an identifier
   53 |  
      | ^
a.cc:53:1: error: '\U000000a0' does not name a type
   53 |  
      | ^
Language: C++

#include<bits/stdc++.h>
typedef long long int   LL;
typedef long double     LD;
#define OR              ||
#define AND             &&
#define nl              '\n'
#define S               string
#define inf             INT_MAX
#define SQR(a)          (a) * (a)
#define GCD(a, b)       __gcd(a, b)
#define pi              2.0*acos(0.0)
#define LCM(a, b)       (a * b) / GCD(a, b)
#define mem(a,b)        memset(a,b,sizeof(a))
#define srtv(v)         sort(v.begin(),v.end())
#define T               int t; cin>>t; while(t--)
#define boost		    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define inout           freopen("input.txt","r",stdin);freopen("output.txt","w",stdout)
using namespace std;

long long powerMod(long long number,long long power)
{
    LL ret=0;

    if(power==0) return 1;
    if(power==1) return number;
    if(power%2==0)
    {
        ret=powerMod(number,power/2);
        ret=(ret*ret);
        return ret;
    }
    else
    {
        ret=powerMod(number,power/2);
        ret=(ret*ret*number);
        return ret;
    }
}


set<int> st[26];

int main()
{
    boost;

    int n;
    cin>>n;

    S s;
    cin>>s;

    for(int i=0;i<s.size();i++)
    {
        int ch=s[i]-'a';
        st[ch].insert(i);
    }

    int q;
    cin>>q;

    while(q--)
    {
        int option;
        cin>>option;

        if(option==1)
        {
            int pos;
            cin>>pos;

            char c;
            cin>>c;

            pos--;

            st[s[pos]-'a'].erase(pos);
            st[c-'a'].insert(pos);
        }

        else
        {
            int l,r;

            cin>>l>>r;


            int count=0;

            for(int i=0;i<26;i++)
            {
                auto itr=v[i].lower_bound(l);
                if(itr!=v[i].end() && *itr<=r)
                    count++;
            }
            cout<<count<<nl;
        }


    }


    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:92:26: error: 'v' was not declared in this scope
   92 |                 auto itr=v[i].lower_bound(l);
      |                          ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define RNG(i,from,to) for(int i=(from); i<(int)(to); i++)
#define gcd(i,j) __gcd((i), (j))
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<ll> vecll;
template<typename S, typename T> string to_string(pair<S, T> p) { return "("+to_string(p.first)+","+to_string(p.second)+")"; }
template<typename T> string to_string(T p[2]) { return "["+to_string(p[0])+","+to_string(p[1])+"]"; }
template<typename T> void println(T e){ cout << to_string(e) << endl; }
template<typename T> void println(const vector<T>& v){ cout << "[";for(const auto& e : v){ cout << to_string(e) << ","; }cout << "]";cout << endl; }
template<typename T> void println(const vector<vector<T>>& vv){ for(const auto& v : vv){ println(v); } }
template<typename Iter> void println(Iter first, Iter last){ for(auto it=first; it != last; it++){ cout << *it << " "; }; cout << endl; }
template<typename T> T mod_pow(T x, T n, const T &p) { T ret = 1; while(n > 0) { if(n & 1) (ret *= x) %= p; (x *= x) %= p; n >>= 1; } return ret; }
template<typename T> T mod_inv(T x, const T &p) { return mod_pow(x, p-2, p); }
const ll DVSR = 1e9+7;

int N, Q;
string S;
vector<set<int>*> st;
int main(int argc, char const *argv[])
{
  cin >> N >> S >> Q;
  st.assign(26, &set<int>());
  REP(i, N) st[S[i] - 'a']->insert(i);
  REP(i, Q) {
    int ty; cin >> ty;
    if (ty == 1) {
      int j; cin >> j; j--;
      char c; cin >> c;

      st[S[j] - 'a']->erase(j);
      st[c - 'a']->insert(j);
      S[j] = c;
    } else {
      int l, r; cin >> l >> r; l--;
      int cnt = 0;
      for (auto s : st) {
        auto lower = s->lower_bound(l);
        cnt += lower != s->end() && *lower < r;
      }
      cout << cnt << endl;
    }
  }
  return 0;
}

Compiler output:
a.cc: In function 'int main(int, const char**)':
a.cc:25:18: error: taking address of rvalue [-fpermissive]
   25 |   st.assign(26, &set<int>());
      |                  ^~~~~~~~~~
Language: C++

#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<endl
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define mp make_pair
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define sz(x) (int)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pll = pair<ll, ll>;
using vc = vector<char>;
using vvc = vector<vc>;
ll dx[4]={0,1,0,-1};
ll dy[4]={1,0,-1,0};
int main(){
  ll n;
  string s;
  cin>>n>>s;
  ll q;
  cin>>q;
  vector<set<ll>> p(26);
  rep(i,n){
    p[s[i]-'a'].insert(i);
  }
  rep(i,q){
    ll k;
    cin>>k;
    if(k==1){
      ll d;
      char r;
      cin>>d>>r;
      d--;
      p[s[d]-'a'].erase(d);
      s[d]=r;
      p[s[d]-'a'].insert(d);
    }
    else{
      ll l,r;
      cin>>l>>r;
      l--;
      ll ans=0;
      rep(j,26){
        auto it=lower_bound(all(p[j]),l);
        if(if!=p[i].end()&&*it<r){
          ans++;
        }
      }
      COUT(ans);
    }
  }
}


Compiler output:
a.cc: In function 'int main()':
a.cc:71:12: error: expected primary-expression before 'if'
   71 |         if(if!=p[i].end()&&*it<r){
      |            ^~
a.cc:71:12: error: expected ')' before 'if'
   71 |         if(if!=p[i].end()&&*it<r){
      |           ~^~
      |            )
Language: C++

#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<endl
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define mp make_pair
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define sz(x) (int)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pll = pair<ll, ll>;
using vc = vector<char>;
using vvc = vector<vc>;
ll dx[4]={0,1,0,-1};
ll dy[4]={1,0,-1,0};
int main(){
  ll n;
  string s;
  cin>>n>>s;
  ll q;
  cin>>q;
  vector<set<ll>> p(26);
  rep(i,n){
    p[s[i]-'a'].insert(i);
  }
  rep(i,q){
    ll k;
    cin>>k;
    if(k==1){
      ll d;
      char r;
      cin>>d>>r;
      d--;
      p[s[d]-'a'].erase(d);
      s[d]=r;
      p[s[d]-'a'].insert(d);
    }
    else{
      ll l,r;
      cin>>l>>r;
      ll ans=0;
      rep(j,26){
        auto it=lower_bound(all(p[j]),l);
        if(if!=p[i].end()&&*it<r){
          ans++;
        }
      }
      COUT(ans);
    }
  }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:70:12: error: expected primary-expression before 'if'
   70 |         if(if!=p[i].end()&&*it<r){
      |            ^~
a.cc:70:12: error: expected ')' before 'if'
   70 |         if(if!=p[i].end()&&*it<r){
      |           ~^~
      |            )
Language: Java

import java.util.*;
import java.util.function.BiFunction;
import java.io.*;


public class a{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
        int N = sc.nextInt();
        char[] S = sc.next().toCharArray();
        int q = sc.nextInt();
        StringBuilder result = new StringBuilder();
        SegmentTree<Long> t = new SegmentTree<>(N, (x, y)->x|y, 0L);
        for(int i=0;i<N;i++){
            t.update(i, (x, y)->y, 1L<<(S[i]-'a'));
        }
        for(int i=0;i<q;i++){
            if(sc.nextInt()==1){
                int iq = sc.nextInt();
                char cq = sc.next().charAt(0);
                t.update(iq-1, (x, y)->y, 1L<<(cq-'a'));
            }
            else{
                int l = sc.nextInt();
                int r = sc.nextInt();
                long bit = t.query(l-1, r);
                result.append(Long.bitCount(bit)+"\n");
            }
        }

        out.println(result);
        out.flush();
    }

}

@SuppressWarnings("unchecked")
class SegmentTree<T> {
    private BiFunction<T, T, T> f;
    private int n;
    private T d1;
    private T[] dat;
    private  SegmentTree(T[] dat, int n_, BiFunction<T, T, T> f, T d1){
        this.f = f;
        this.d1 = d1;
        init(n_);
        build(dat);
    }

    public SegmentTree(T[] dat, BiFunction<T, T, T> f, T d1){
        this(dat, dat.length, f, d1);
    }

    public SegmentTree(int n_, BiFunction<T, T, T> f, T d1){
        this((T[]) new Object[0], n_, f, d1);
    }

    private void init(int n_){
        n = 1;
        while(n<n_) this.n *= 2;
        this.dat = (T[]) new Object[2 * this.n - 1];
    }

    private void build(T[] v){
        for(int i=0;i<n;i++) dat[i+n-1] = i < v.length ? v[i]: d1;
        for(int i=n-2;i>=0;i--) dat[i] = f.apply(dat[i*2+1], dat[i*2+2]);
    }

    public <E> void update(int k,BiFunction<T,E,T> g, E a){
        k += n-1;
        dat[k] = g.apply(dat[k], a);
        while(k>0){
            k = (k-1)/2;
            dat[k] = f.apply(dat[k*2+1], dat[k*2+2]);
        }
    }

    private T query(int a, int b, int k,int l, int r){
        if(r<=a || b<=l) return d1;
        if(a<=l&&r<=b) return dat[k];
        T vl = query(a, b, k*2+1, l, (l+r)/2);
        T vr = query(a, b, k*2+2, (l+r)/2, r);
        return f.apply(vl, vr);
    }

    public T query(int a, int b){
        return query(a, b, 0, 0, n);
    }
}

Compiler output:
Main.java:6: error: class a is public, should be declared in a file named a.java
public class a{
       ^
1 error
Language: Java

import java.util.*;
import java.util.function.BiFunction;
import java.io.*;


public class a{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
        int N = sc.nextInt();
        char[] S = sc.next().toCharArray();
        int q = sc.nextInt();
        StringBuilder result = new StringBuilder();
        SegmentTree<Integer> t = new SegmentTree<>(N, (x, y)->x|y, 0);
        for(int i=0;i<N;i++){
            t.update(i, (x, y)->x|y, 1<<(S[i]-'a'));
        }
        for(int i=0;i<q;i++){
            if(sc.nextInt()==1){
                int iq = sc.nextInt();
                char cq = sc.next().charAt(0);
                if(S[iq-1]==cq) continue;
                t.update(iq, (x, y)->x|y, 1<<(cq-'a'));
            }
            else{
                int l = sc.nextInt();
                int r = sc.nextInt();
                long bit = t.query(l-1, r);
                result.append(Long.bitCount(bit)+"\n");
            }
        }

        out.println(result);
        out.flush();
    }

}

@SuppressWarnings("unchecked")
class SegmentTree<T> {
    private BiFunction<T, T, T> f;
    private int n;
    private T d1;
    private T[] dat;
    private  SegmentTree(T[] dat, int n_, BiFunction<T, T, T> f, T d1){
        this.f = f;
        this.d1 = d1;
        init(n_);
        build(dat);
    }

    public SegmentTree(T[] dat, BiFunction<T, T, T> f, T d1){
        this(dat, dat.length, f, d1);
    }

    public SegmentTree(int n_, BiFunction<T, T, T> f, T d1){
        this((T[]) new Object[0], n_, f, d1);
    }

    private void init(int n_){
        n = 1;
        while(n<n_) this.n *= 2;
        this.dat = (T[]) new Object[2 * this.n - 1];
    }

    private void build(T[] v){
        for(int i=0;i<n;i++) dat[i+n-1] = i < v.length ? v[i]: d1;
        for(int i=n-2;i>=0;i--) dat[i] = f.apply(dat[i*2+1], dat[i*2+2]);
    }

    public <E> void update(int k,BiFunction<T,E,T> g, E a){
        k += n-1;
        dat[k] = g.apply(dat[k], a);
        while(k>0){
            k = (k-1)/2;
            dat[k] = f.apply(dat[k*2+1], dat[k*2+2]);
        }
    }

    private T query(int a, int b, int k,int l, int r){
        if(r<=a || b<=l) return d1;
        if(a<=l&&r<=b) return dat[k];
        T vl = query(a, b, k*2+1, l, (l+r)/2);
        T vr = query(a, b, k*2+2, (l+r)/2, r);
        return f.apply(vl, vr);
    }

    public T query(int a, int b){
        return query(a, b, 0, 0, n);
    }
}

Compiler output:
Main.java:6: error: class a is public, should be declared in a file named a.java
public class a{
       ^
1 error
Language: C++

import collections

N = int(input())
S = list(input())
Q = int(input())

print(S)

Query = []
for i in range(Q):
    Query.append(input().split())
    Query[i][0] = int(Query[i][0])
    Query[i][1] = int(Query[i][1]) - 1
    if Query[i][0] is 2:
        Query[i][2] = int(Query[i][2])

for Q_temp in Query:
    if Q_temp[0] is 1:
        S[Q_temp[1]] = Q_temp[2]
    else:
        output = collections.Counter(S[Q_temp[1]:Q_temp[2]])
        print(len(output))

Compiler output:
a.cc:1:1: error: 'import' does not name a type
    1 | import collections
      | ^~~~~~
a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'
Language: C++


#include<iostream>
#include <stdio.h>
#include <vector>
#include <set>
#include<string>
#define rep(i,n) for(int i=0; i<(int)n; i++)//n回繰り返す
using namespace std;
using ll = long long;
using P =pair<int,int>;

int main() {
    int N,Q;
  cin>>N;
    string S,str;
    cin>>S;
    cin>>Q;
    int q1[Q],q2[Q];
    rep(i,Q){
        cin>>q1[i]>>q2[i];
        if(q1[i]==1){
            char c[Q];
            cin>>c[i];
            S.erase(S.begin() +q2[i]-1);
            S.insert(S.begin() +q2[i]-1, c[i]);
        }
        else{
            int q3[Q],ans=0;
            cin>>q3[i];
            str=S.substr(q2[i]-1,q3[i]-q2[i]+1);
            sort(str.begin(),str.end());
            rep(l,26){
            string::size_type W= str.find('a'+l);
            if(W !=string::npos){
                ans++;
                }
            }
            cout<<ans<<endl;;
           }
      }
    }
    
        

   
    
    
    
    
    
    
    
    

    



Compiler output:
a.cc: In function 'int main()':
a.cc:31:13: error: 'sort' was not declared in this scope; did you mean 'short'?
   31 |             sort(str.begin(),str.end());
      |             ^~~~
      |             short
Language: C++


#include <bits/stdc++.h>
using namespace std;
#define all(v)  v.begin(),v.end()

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

   int n;
   cin>>n;
   string s;
   cin>>s;
   int q;
   cin>>q;
   set<int> c[26];

   for(int i=0;i<n;i++){
        c[s[i]-'a'].emplace(i);
   }

   while(q--){
      int t;
      cin>>t;
      if(t==1){
         int i;char x;
         cin>>i>>x;
         i--;
         c[s[i]-'a'].erase(i);
         c[x-'a'].emplace(i);
         s[i]=x;
      }
      else{
         int l,r;
         cin>>l>>r;
         l--;r--;
         int count = 0;
         for(int i=0;i<26;i++){
             auto it_lo = lower_bound(all(c[i]),l);
             if(it_lo!=c[i].end() and *(it_lo)<=r){
               count++;
             }
         }
           
             cout<<count<<endl; 
      }
   }

   return 0;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:7:67: error: expected ';' before 'int'
    7 |    ios_base:: sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL)
      |                                                                   ^
      |                                                                   ;
    8 | 
    9 |    int n;
      |    ~~~                                                             
a.cc:10:9: error: 'n' was not declared in this scope; did you mean 'yn'?
   10 |    cin>>n;
      |         ^
      |         yn
Language: C++

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

using namespace std;

//operation1 -> nodeのデータ同士の統合の演算
template <class Monoid> struct SegTree {
	int N;
	vector<Monoid> node;
	std::function<Monoid(Monoid, Monoid)> operation;
	Monoid unit;//単位元

	std::function<bool(Monoid, Monoid)> comp;
	Monoid not_find_sgn;

	SegTree(vector<Monoid>& data, std::function<Monoid(Monoid, Monoid)> op, Monoid U) {
		//データ　演算　単位元
		operation = op;
		unit = U;
		int size = data.size();
		N = 1;
		while (N < size)N <<= 1;
		node.resize(2 * N - 1, unit);

		for (int i = 0; i < size; i++) {
			node[i + N - 1] = data[i];
		}

		for (int i = N - 2; i >= 0; i--) {
			node[i] = operation(node[i * 2 + 1], node[i * 2 + 2]);
		}
	}

	SegTree() = default;

	void update(int pos, Monoid val) {
		pos += N - 1;
		node[pos] = val;
		while (pos > 0) {
			pos = (pos - 1) / 2;
			node[pos] = operation(node[pos * 2 + 1], node[pos * 2 + 2]);
		}
	}

	Monoid getval(int a, int b, int idx, int l, int r = -1) {
		//[a, b)を求める。　使い方はgetval(a, b, );
		if (r == -1)r = N;
		if (b <= l || r <= a)return unit;
		if (a <= l && r <= b)return node[idx];
		Monoid left = getval(a, b, idx * 2 + 1, l, (l + r) / 2);
		Monoid right = getval(a, b, idx * 2 + 2, (l + r) / 2, r);
		return operation(left, right);
	}

	Monoid getval(int a, int b) {
		//ラッパー。
		return getval(a, b, 0, 0, -1);
	}

};

int n;
string s;

int main() {
	cin >> n >> s;
	
	vector<SegTree<int>> st(26, SegTree<int>(vector<int>(n, 0), [](int a, int b) {return a + b; }, 0));
	for (int i = 0; i < n; i++) {
		st[s[i] - 'a'].update(i, 1);
	}
	
	int q;
	cin >> q;
	while (q--) {
		int f;
		cin >> f;
		if (f == 1) {
			int a;
			char b;
			cin >> a >> b;
			a--;
			if (s[a] == b);
			else {
				st[s[a] - 'a'].update(a, 0);
				s[a] = b;
				st[s[a] - 'a'].update(a, 1);
			}
		}
		else if (f == 2) {
			int l, r;
			cin >> l >> r;
			l--, r--;
			int ans = 0;
			for (int i = 0; i < 26; i++)
				if (st[i].getval(l, r + 1) >= 1)ans++;
			cout << ans << endl;
		}
	}
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:71:50: error: cannot bind non-const lvalue reference of type 'std::vector<int>&' to an rvalue of type 'std::vector<int>'
   71 |         vector<SegTree<int>> st(26, SegTree<int>(vector<int>(n, 0), [](int a, int b) {return a + b; }, 0));
      |                                                  ^~~~~~~~~~~~~~~~~
a.cc:19:33: note:   initializing argument 1 of 'SegTree<Monoid>::SegTree(std::vector<Monoid>&, std::function<Monoid(Monoid, Monoid)>, Monoid) [with Monoid = int]'
   19 |         SegTree(vector<Monoid>& data, std::function<Monoid(Monoid, Monoid)> op, Monoid U) {
      |                 ~~~~~~~~~~~~~~~~^~~~
Language: C++

#include <iostream>
#include <fstream>
#include <vector>
#include <cstring>
#include <algorithm> // sort
#include <unistd.h>
#include <map>
#include <set> 

#define pii pair<int,int>
#define REP(i, n) for (long long i = 0; i < (n); i++) 
using namespace std;


typedef long long ll;
static const ll INF = 1000000000000000000LL;
static const ll MOD = 1000000007;


//各範囲の文字の数をセグ木で保存
//各文字の部分累積和をとっておけば、
//

int main()
{
    int N;
    cin >> N;
    string s;
    cin >> s;
    
    set <int> st[26];
    REP(i,N)
    {
        st[s[i] - 'a'].insert(i);
    }
    //終端を設定しておく
    REP(d,26)
    {
        st[d].insert(n);
    }
    int Q;
    cin >> Q;

    REP(i,Q)
    {
        int q;
        cin >> q;
        if(q == 1)
        {
            int l;
            char c;
            cin >> l >> c;
            --l;
            if(s[l] != c)
            {
                st[s[l] - 'a'].erase(l);
                st[c - 'a'].insert(l);
                s[l] = c;
            }
        }
        else
        {
            int l,r;
            cin >> l >> r;
            --l;--r;
            int res = 0;
            REP(d,26)
            {
                int off = *st[d].lower_bound(l);
                if(off <= r)++res;
            }
            cout << res << endl;
        }
    }
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:39:22: error: 'n' was not declared in this scope
   39 |         st[d].insert(n);
      |                      ^
Language: Java

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Scanner;
import java.util.TreeSet;

public class Main {

	public static void main(String[] args) throws NumberFormatException, IOException {
		Main2 mainObj = new Main2();
		mainObj.solve();
	}
	
	public void solve() throws NumberFormatException, IOException {
		BufferedReader sc = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(sc.readLine());
		char[] str = sc.readLine().toCharArray();
		int q = Integer.parseInt(sc.readLine());
		
		ArrayList<TreeSet<Integer>> treeSetList = new ArrayList<>();
		for(int i = 0; i < 26; i++) {
			treeSetList.add(new TreeSet<>());
		}
		for(int i = 0; i < n; i++) {
			char ichar = str[i];
			int charVal = ichar - 97;
			treeSetList.get(charVal).add(i);
		}
		
		
		for(int i = 0; i < q; i++) {
			String[] queryArr = sc.readLine().split(" ");
			int queryNo = Integer.parseInt(queryArr[0]);
			if(queryNo == 1) {
				int pos = Integer.parseInt(queryArr[1]) - 1;
				char inputChar = queryArr[2].charAt(0);
				char nowChar = str[pos];
				str[pos] = inputChar;
				treeSetList.get(nowChar-97).remove(pos);
				treeSetList.get(inputChar-97).add(pos);
			}else if(queryNo == 2){
				
				int left = Integer.parseInt(queryArr[1]) - 1;
				int right = Integer.parseInt(queryArr[2]) - 1;
				int ans = 0;
				for(TreeSet<Integer> treeSet : treeSetList) {
					Integer ceilPos = treeSet.ceiling(left);
					
					if(ceilPos != null && ceilPos <= right) {
						ans++;
					}
				}
				System.out.println(ans);
			}
		}
		
		sc.close();
	}
}


Compiler output:
Main.java:11: error: cannot find symbol
		Main2 mainObj = new Main2();
		^
  symbol:   class Main2
  location: class Main
Main.java:11: error: cannot find symbol
		Main2 mainObj = new Main2();
		                    ^
  symbol:   class Main2
  location: class Main
2 errors
Language: Java

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Scanner;
import java.util.TreeSet;

public class Main2 {

	public static void main(String[] args) throws NumberFormatException, IOException {
		Main2 mainObj = new Main2();
		mainObj.solve();
	}
	
	public void solve() throws NumberFormatException, IOException {
		BufferedReader sc = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(sc.readLine());
		char[] str = sc.readLine().toCharArray();
		int q = Integer.parseInt(sc.readLine());
		
		ArrayList<TreeSet<Integer>> treeSetList = new ArrayList<>();
		for(int i = 0; i < 26; i++) {
			treeSetList.add(new TreeSet<>());
		}
		for(int i = 0; i < n; i++) {
			char ichar = str[i];
			int charVal = ichar - 97;
			treeSetList.get(charVal).add(i);
		}
		
		
		for(int i = 0; i < q; i++) {
			String[] queryArr = sc.readLine().split(" ");
			int queryNo = Integer.parseInt(queryArr[0]);
			if(queryNo == 1) {
				int pos = Integer.parseInt(queryArr[1]) - 1;
				char inputChar = queryArr[2].charAt(0);
				char nowChar = str[pos];
				str[pos] = inputChar;
				treeSetList.get(nowChar-97).remove(pos);
				treeSetList.get(inputChar-97).add(pos);
			}else if(queryNo == 2){
				
				int left = Integer.parseInt(queryArr[1]) - 1;
				int right = Integer.parseInt(queryArr[2]) - 1;
				int ans = 0;
				for(TreeSet<Integer> treeSet : treeSetList) {
					Integer ceilPos = treeSet.ceiling(left);
					
					if(ceilPos != null && ceilPos <= right) {
						ans++;
					}
				}
				System.out.println(ans);
			}
		}
		
		sc.close();
	}
}


Compiler output:
Main.java:8: error: class Main2 is public, should be declared in a file named Main2.java
public class Main2 {
       ^
1 error
Language: Java

import java.util.*;
public class Main {
	public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
    	int n = sc.nextInt();

    	TreeSet[] segs = new TreeSet[26];
    	char[] d = sc.next().toCharArray();
    	for (int i = 0; i < 26; i++){
    		segs[i] = new TreeSet();
    		segs[i].add(510000);
    	}
    	for (int i = 0; i < n; i++) {
    		segs[(int) d[i] - 'a'].add(i);
    	}
    	int q = sc.nextInt();
    	for (int i = 0; i < q; i++) {
    		int a = sc.nextInt();
    		if (a==1) {
    			int index = sc.nextInt()-1;
    			char oldc = d[index];
    			char newc = sc.next().toCharArray()[0];
    			if (oldc == newc) continue;
    			d[index]=newc;
    			segs[(int)oldc-'a'].remove(index);
    			segs[(int)newc-'a'].add(index);
    			continue;
    		}
            int l = scan.nextInt()-1;
            int r = scan.nextInt()-1;
            int ans = 0;
            for (int j = 0; j < 26; j++) {
                if (segs[j].ceiling(l) <= r) ans += 1;
            }
            System.out.println(ans);
    	}
    }
} 


Compiler output:
Main.java:29: error: cannot find symbol
            int l = scan.nextInt()-1;
                    ^
  symbol:   variable scan
  location: class Main
Main.java:30: error: cannot find symbol
            int r = scan.nextInt()-1;
                    ^
  symbol:   variable scan
  location: class Main
Main.java:33: error: bad operand types for binary operator '<='
                if (segs[j].ceiling(l) <= r) ans += 1;
                                       ^
  first type:  Object
  second type: int
Note: Main.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
3 errors
Language: C++

#include <bits/stdc++.h>
#define SIGMA 26
using namespace std;
string sir;
set <int> s[SIGMA];
int q,op,l,r,pos,n;
char c;
int main() 
{
    ios::sync_with_stdio(0);
    cin.tie(0)
    cout.tie(0);
    cin>>n;
    cin>>sir;
    sir="#"+sir;
    for(int i=1;i<=n;i++)
        s[sir[i]-'a'].insert(i);
    cin>>q;
    while(q--)
    {
        cin>>op;
        if(op==1)
        {
            cin>>pos>>c;
            s[sir[pos]-'a'].erase(pos);
            s[c-'a'].insert(pos);
            sir[pos]=c;
        }
        else
        {
            cin>>l>>r;
            int sol=0;
            for(int i=0;i<SIGMA;i++)
            {
                auto it=s[i].lower_bound(l);
                if(it!=s[i].end() && *it<=r)
                    sol++;
            }
            cout<<sol<<"\n";
        }
    }
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:11:15: error: expected ';' before 'cout'
   11 |     cin.tie(0)
      |               ^
      |               ;
   12 |     cout.tie(0);
      |     ~~~~
Language: C++

#include <bits/stdc++.h>
#define SIGMA 26
using namespace std;
string sir;
set <int> s[SIGMA];
int q,op,l,r,pos,n;
char c;
int main() 
{
    ios::sync_with_stdio(0);
    cin.tie(0)
    cout.tie(0);
    cin>>n;
    cin>>sir;
    sir="#"+sir;
    for(int i=1;i<=n;i++)
        s[sir[i]-'a'].insert(i);
    cin>>q;
    while(q--)
    {
        cin>>op;
        if(op==1)
        {
            cin>>pos>>c;
            s[sir[pos]-'a'].erase(pos);
            s[c-'a'].insert(pos);
            sir[pos]=c;
        }
        else
        {
            cin>>l>>r;
            int sol=0;
            for(int i=0;i<SIGMA;i++)
            {
                auto it=s[i].lower_bound(l);
                if(it!=s[i].end() && *it<=r)
                    sol++;
            }
            cout<<sol<<"\n";
        } 
    }
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:11:15: error: expected ';' before 'cout'
   11 |     cin.tie(0)
      |               ^
      |               ;
   12 |     cout.tie(0);
      |     ~~~~
Language: C++

#include <vector>
#include <bitset>
#include <cstdio>

using B = std::bitset<32>;

int main()
{
  int N;
  scanf("%d\n", &N);
  vector<int> S(N);
  for(int i = 0; i < N; ++i) {
    char c;
    scanf("%c", &c);
    S[i] = 1 << (c - 'a');
  }
  int Q;
  scanf("\n%d\n", &Q);
  while (Q--) {
    int q;
    scanf("%d ", &q);
    if (q == 1) {
      int i;
      char c;
      scanf("%d %c\n", &i, &c);
      S[i - 1] = 1 << (c - 'a');
    } else {
      int r, l;
      scanf("%d %d\n", &r, &l);
      --r;
      int res{};
      for (int i = r; i < l; ++i) {
          res |= S[i];
      }
      B ans(res);
      printf("%d\n", ans.count());
    }
  }
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:11:3: error: 'vector' was not declared in this scope
   11 |   vector<int> S(N);
      |   ^~~~~~
a.cc:11:3: note: suggested alternatives:
In file included from /usr/include/c++/14/vector:66,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_vector.h:428:11: note:   'std::vector'
  428 |     class vector : protected _Vector_base<_Tp, _Alloc>
      |           ^~~~~~
/usr/include/c++/14/vector:93:13: note:   'std::pmr::vector'
   93 |       using vector = std::vector<_Tp, polymorphic_allocator<_Tp>>;
      |             ^~~~~~
a.cc:11:10: error: expected primary-expression before 'int'
   11 |   vector<int> S(N);
      |          ^~~
a.cc:15:5: error: 'S' was not declared in this scope
   15 |     S[i] = 1 << (c - 'a');
      |     ^
a.cc:26:7: error: 'S' was not declared in this scope
   26 |       S[i - 1] = 1 << (c - 'a');
      |       ^
a.cc:33:18: error: 'S' was not declared in this scope
   33 |           res |= S[i];
      |                  ^