Language: C++

#include <iostream>
#include <algorithm>
#include <string>
#include <iomanip>
#include <complex>
using namespace std;

int main() {
    string str;
    int n;
    cin >> str >> n;
    for(int i = 0; i < n; i++){
        string com;
        cin >> com;
        if(com == "print"){
            int a, b;
            cin >> a >> b;
            cout << str.substr(a, b - a + 1) << endl;
            continue;
        }
        if(com == "reverse"){
            int a, b;
            cin >> a >> b;
            reverse(str.begin() + a, str.begin() + b +1);
            continue;
        }
        if(com == "replace"){
            int a, b;
            string r;
            cin >> a >> b >> r;
            str.replace(str.begin() + a, b - a + 1, r);
            continue;
        }

    }
}


Compiler output:
a.cc: In function 'int main()':
a.cc:31:24: error: no matching function for call to 'std::__cxx11::basic_string<char>::replace(__gnu_cxx::__normal_iterator<char*, std::__cxx11::basic_string<char> >, int, std::string&)'
   31 |             str.replace(str.begin() + a, b - a + 1, r);
      |             ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/string:54,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/bits/basic_string.h:2413:9: note: candidate: 'template<class _InputIterator, class> std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::replace(const_iterator, const_iterator, _InputIterator, _InputIterator) [with <template-parameter-2-2> = _InputIterator; _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]'
 2413 |         replace(const_iterator __i1, const_iterator __i2,
      |         ^~~~~~~
/usr/include/c++/14/bits/basic_string.h:2413:9: note:   candidate expects 4 arguments, 3 provided
/usr/include/c++/14/bits/basic_string.h:2522:9: note: candidate: 'template<class _Tp> std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::_If_sv<_Tp, std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&> std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::replace(size_type, size_type, const _Tp&) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]'
 2522 |         replace(size_type __pos, size_type __n, const _Tp& __svt)
      |         ^~~~~~~
/usr/include/c++/14/bits/basic_string.h:2522:9: note:   template argument deduction/substitution failed:
a.cc:31:37: note:   cannot convert 'str.std::__cxx11::basic_string<char>::begin().__gnu_cxx::__normal_iterator<char*, std::__cxx11::basic_string<char> >::operator+(((__gnu_cxx::__normal_iterator<char*, std::__cxx11::basic_string<char> >::difference_type)a))' (type '__gnu_cxx::__normal_iterator<char*, std::__cxx11::basic_string<char> >') to type 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'}
   31 |             str.replace(str.begin() + a, b - a + 1, r);
      |                         ~~~~~~~~~~~~^~~
/usr/include/c++/14/bits/basic_string.h:2540:9: note: candidate: 'template<class _Tp> std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::_If_sv<_Tp, std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&> std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::replace(size_type, size_type, const _Tp&, size_type, size_type) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]'
 2540 |         replace(size_type __pos1, size_type __n1, const _Tp& __svt,
      |         ^~~~~~~
/usr/include/c++/14/bits/basic_string.h:2540:9: note:   candidate expects 4 arguments, 3 provided
/usr/include/c++/14/bits/basic_string.h:2562:9: note: candidate: 'template<class _Tp> std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::_If_sv<_Tp, std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&> std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::replace(const_iterator, const_iterator, const _Tp&) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]'
 2562 |         replace(const_iterator __i1, const_iterator __i2, const _Tp& __svt)
      |         ^~~~~~~
/usr/include/c++/14/bits/basic_string.h:2562:9: note:   template argument deduction/substitution failed:
a.cc:31:48: note:   cannot convert '((b - a) + 1)' (type 'int') to type 'std::__cxx11::basic_string<char>::const_iterator'
   31 |             str.replace(str.begin() + a, b - a + 1, r);
      |                                          ~~~~~~^~~
/usr/include/c++/14/bits/basic_string.h:2200:7: note: candidate: 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::replace(size_type, size_type, const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; size_type = long unsigned int]'
 2200 |       replace(size_type __pos, size_type __n, const basic_string& __str)
      |       ^~~~~~~
/usr/include/c++/14/bits/basic_string.h:2200:25: note:   no known conversion for argument 1 from '__gnu_cxx::__normal_iterator<char*, std::__cxx11::basic_string<char> >' to 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'}
 2200 |       replace(size_type __pos, size_type __n, const basic_string& __str)
      |               ~~~~~~~~~~^~~~~
/usr/include/c++/14/bits/basic_string.h:2223:7: note: candidate: 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::replace(size_type, size_type, const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&, size_type, size_type) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; size_type = long unsigned int]'
 2223 |       replace(size_type __pos1, size_type __n1, const basic_string& __str,
      |       ^~~~~~~
/usr/include/c++/14/bits/basic_string.h:2223:7: note:   candidate expects 5 arguments, 3 provided
/usr/include/c++/14/bits/basic_string.h:2249:7: note: candidate: 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::replace(size_type, size_type, const _CharT*, size_type) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; size_type = long unsigned int]'
 2249 |       replace(size_type __pos, size_type __n1, const _CharT* __s,
      |       ^~~~~~~
/usr/include/c++/14/bits/basic_string.h:2249:7: note:   candidate expects 4 arguments, 3 provided
/usr/include/c++/14/bits/basic_string.h:2275:7: note: candidate: 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::replace(size_type, size_type, const _CharT*) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; size_type = long unsigned int]'
 2275 |       replace(size_type __pos, size_type __n1, const _CharT* __s)
      |       ^~~~~~~
/usr/include/c++/14/bits/basic_string.h:2275:25: note:   no known conversion for argument 1 from '__gnu_cxx::__normal_iterator<char*, std::__cxx11::basic_string<char> >' to 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'}
 2275 |       replace(size_type __pos, size_type __n1, const _CharT* __s)
      |               ~~~~~~~~~~^~~~~
/usr/include/c++/14/bits/basic_string.h:2300:7: note: candidate: 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::replace(size_type, size_type, size_type, _CharT) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; size_type = long unsigned int]'
 2300 |       replace(size_type __pos, size_type __n1, size_type __n2, _CharT __c)
      |       ^~~~~~~
/usr/include/c++/14/bits/basic_string.h:2300:7: note:   candidate expects 4 arguments, 3 provided
/usr/include/c++/14/bits/basic_string.h:2319:7: note: candidate: 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::replace(__const_iterator, __const_iterator, const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; __const_iterator = std::__cxx11::basic_string<char>::const_iterator]'
 2319 |       replace(__const_iterator __i1, __const_iterator __i2,
      |       ^~~~~~~
/usr/include/c++/14/bits/basic_string.h:2319:55: note:   no known conversion for argument 2 from 'int' to 'std::__cxx11::basic_string<char>::__const_iterator' {aka 'std::__cxx11::basic_string<char>::const_iterator'}
 2319 |       replace(__const_iterator __i1, __const_iterator __i2,
      |                                      ~~~~~~~~~~~~~~~~~^~~~
/usr/include/c++/14/bits/basic_string.h:2340:7: note: candidate: 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::replace(__const_iterator, __const_iterator, const _CharT*, size_type) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; __const_iterator = std::__cxx11::basic_string<char>::const_iterator; size_type = long unsigned int]'
 2340 |       replace(__const_iterator __i1, __const_iterator __i2,
      |       ^~~~~~~
/usr/include/c++/14/bits/basic_string.h:2340:7: note:   candidate expects 4 arguments, 3 provided
/usr/include/c++/14/bits/basic_string.h:2363:7: note: candidate: 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::replace(__const_iterator, __const_iterator, const _CharT*) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; __const_iterator = std::__cxx11::basic_string<char>::const_iterator]'
 2363 |       replace(__const_iterator __i1, __const_iterator __i2, const _CharT* __s)
      |       ^~~~~~~
/usr/include/c++/14/bits/basic_string.h:2363:55: note:   no known conversion for argument 2 from 'int' to 'std::__cxx11::basic_string<char>::__const_iterator' {aka 'std::__cxx11::basic_string<char>::const_iterator'}
 2363 |       replace(__const_iterator __i1, __const_iterator __i2, const _CharT* __s)
      |                                      ~~~~~~~~~~~~~~~~~^~~~
/usr/include/c++/14/bits/basic_string.h:2385:7: note: candidate: 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::replace(__const_iterator, __const_iterator, size_type, _CharT) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; __const_iterator = std::__cxx11::basic_string<char>::const_iterator; size_type = long unsigned int]'
 2385 |       replace(__const_iterator __i1, __const_iterator __i2, size_type __n,
      |       ^~~~~~~
/usr/include/c++/14/bits/basic_string.h:2385:7: note:   candidate expects 4 arguments, 3 provided
/usr/include/c++/14/bits/basic_strin