Language: C++

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

int main() {
  int n,q;
  string s;
  cin >> n >> s >> q;
  set<int> alpha[26];
  for(int i=0;i<n;i++)alpha[(int)(s[i]-'0')].insert(i);
  for(int i=0;i<q;i++){
      int t;
      cin >> t;
      if(t==1){
        int i;
        char c;
        cin >> i >> c;
        i--;
        if(s[i]!=c){
            alpha[(s[i]-'0')].erase(i);
            alpha[(c-'0')].insert(i);
        }
      }
      else{
        int l,r;
        cin >> l >> r;
        l--; r--;
        int ans=0;
        for(int i=0;i<26;i++){
            iterator u = alpha[i].upper_bound(l);
            iterator v = alpha[i].lower_bound(r);
            ans += (u-v);
        }
        cout << ans << endl;
      }
  }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:29:48: error: class template argument deduction failed:
   29 |             iterator u = alpha[i].upper_bound(l);
      |                                                ^
a.cc:29:48: error: no matching function for call to 'iterator(std::set<int>::iterator)'
In file included from /usr/include/c++/14/bits/stl_algobase.h:65,
                 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_iterator_base_types.h:127:34: note: candidate: 'template<class _Category, class _Tp, class _Distance, class _Pointer, class _Reference> iterator()-> std::iterator<_Category, _Tp, _Distance, _Pointer, _Reference>'
  127 |     struct _GLIBCXX17_DEPRECATED iterator
      |                                  ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator_base_types.h:127:34: note:   candidate expects 0 arguments, 1 provided
/usr/include/c++/14/bits/stl_iterator_base_types.h:127:34: note: candidate: 'template<class _Category, class _Tp, class _Distance, class _Pointer, class _Reference> iterator(std::iterator<_Category, _Tp, _Distance, _Pointer, _Reference>)-> std::iterator<_Category, _Tp, _Distance, _Pointer, _Reference>'
/usr/include/c++/14/bits/stl_iterator_base_types.h:127:34: note:   template argument deduction/substitution failed:
a.cc:29:48: note:   'std::_Rb_tree_const_iterator<int>' is not derived from 'std::iterator<_Category, _Tp, _Distance, _Pointer, _Reference>'
   29 |             iterator u = alpha[i].upper_bound(l);
      |                                                ^
a.cc:30:48: error: class template argument deduction failed:
   30 |             iterator v = alpha[i].lower_bound(r);
      |                                                ^
a.cc:30:48: error: no matching function for call to 'iterator(std::set<int>::iterator)'
/usr/include/c++/14/bits/stl_iterator_base_types.h:127:34: note: candidate: 'template<class _Category, class _Tp, class _Distance, class _Pointer, class _Reference> iterator()-> std::iterator<_Category, _Tp, _Distance, _Pointer, _Reference>'
  127 |     struct _GLIBCXX17_DEPRECATED iterator
      |                                  ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator_base_types.h:127:34: note:   candidate expects 0 arguments, 1 provided
/usr/include/c++/14/bits/stl_iterator_base_types.h:127:34: note: candidate: 'template<class _Category, class _Tp, class _Distance, class _Pointer, class _Reference> iterator(std::iterator<_Category, _Tp, _Distance, _Pointer, _Reference>)-> std::iterator<_Category, _Tp, _Distance, _Pointer, _Reference>'
/usr/include/c++/14/bits/stl_iterator_base_types.h:127:34: note:   template argument deduction/substitution failed:
a.cc:30:48: note:   'std::_Rb_tree_const_iterator<int>' is not derived from 'std::iterator<_Category, _Tp, _Distance, _Pointer, _Reference>'
   30 |             iterator v = alpha[i].lower_bound(r);
      |                                                ^