Language: C++

#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string s;
  int q;
  cin >> s >> q;
  
  int count = 0;
  int t_i;
  int f_i;
  char c_i;
  
  for(int i = 0; i < q; ++i){
    cin >> t_i;
    
    if(t_i == 1){
      // t_i = 1なら，countをincrement
      ++count;
    }else{
      // t_i = 2なら，count + f_iを2で割った余りが0なら先頭，1なら末尾にc_iを追加
      cin >> f_i >> c_i;
      if((count + f_i) % 2 == 0){
        s.insert(0, c_i);
      }else{
        s.insert(s.end(), c_i);
      }
    }
  }
 
  if(count % 2 == 1){
    reverse(s.begein(), s.end());
  }
  
  
  cout << s << endl;
  return 0;
  
}

Compiler output:
a.cc: In function 'int main()':
a.cc:24:17: error: no matching function for call to 'std::__cxx11::basic_string<char>::insert(int, char&)'
   24 |         s.insert(0, c_i);
      |         ~~~~~~~~^~~~~~~~
In file included from /usr/include/c++/14/string:54,
                 from /usr/include/c++/14/bitset:52,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52,
                 from a.cc:1:
/usr/include/c++/14/bits/basic_string.h:2007:7: note: candidate: 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::insert(size_type, const _CharT*) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; size_type = long unsigned int]' (near match)
 2007 |       insert(size_type __pos, const _CharT* __s)
      |       ^~~~~~
/usr/include/c++/14/bits/basic_string.h:2007:7: note:   conversion of argument 2 would be ill-formed:
a.cc:24:21: error: invalid conversion from 'char' to 'const char*' [-fpermissive]
   24 |         s.insert(0, c_i);
      |                     ^~~
      |                     |
      |                     char
/usr/include/c++/14/bits/basic_string.h:1876:9: note: candidate: 'template<class _InputIterator, class> std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::iterator std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::insert(const_iterator, _InputIterator, _InputIterator) [with <template-parameter-2-2> = _InputIterator; _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]'
 1876 |         insert(const_iterator __p, _InputIterator __beg, _InputIterator __end)
      |         ^~~~~~
/usr/include/c++/14/bits/basic_string.h:1876:9: note:   candidate expects 3 arguments, 2 provided
/usr/include/c++/14/bits/basic_string.h:2069: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>::insert(size_type, const _Tp&) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]'
 2069 |         insert(size_type __pos, const _Tp& __svt)
      |         ^~~~~~
/usr/include/c++/14/bits/basic_string.h:2069:9: note:   template argument deduction/substitution failed:
In file included from /usr/include/c++/14/bits/stl_pair.h:60,
                 from /usr/include/c++/14/bits/stl_algobase.h:64,
                 from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51:
/usr/include/c++/14/type_traits: In substitution of 'template<bool _Cond, class _Tp> using std::enable_if_t = typename std::enable_if::type [with bool _Cond = false; _Tp = std::__cxx11::basic_string<char>&]':
/usr/include/c++/14/bits/basic_string.h:149:8:   required by substitution of 'template<class _CharT, class _Traits, class _Alloc> template<class _Tp, class _Res> using std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::_If_sv = std::enable_if_t<((bool)std::__and_<std::is_convertible<const _Tp&, std::basic_string_view<_CharT, _Traits> >, std::__not_<std::is_convertible<const _Tp*, const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>*> >, std::__not_<std::is_convertible<const _Tp&, const _CharT*> > >::value), _Res> [with _Tp = char; _Res = std::__cxx11::basic_string<char>&; _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]'
  149 |         using _If_sv = enable_if_t<
      |               ^~~~~~
/usr/include/c++/14/bits/basic_string.h:2069:2:   required by substitution of 'template<class _Tp> std::__cxx11::basic_string<char>::_If_sv<_Tp, std::__cxx11::basic_string<char>&> std::__cxx11::basic_string<char>::insert(size_type, const _Tp&) [with _Tp = char]'
 2069 |         insert(size_type __pos, const _Tp& __svt)
      |         ^~~~~~
a.cc:24:17:   required from here
   24 |         s.insert(0, c_i);
      |         ~~~~~~~~^~~~~~~~
/usr/include/c++/14/type_traits:2711:11: error: no type named 'type' in 'struct std::enable_if<false, std::__cxx11::basic_string<char>&>'
 2711 |     using enable_if_t = typename enable_if<_Cond, _Tp>::type;
      |           ^~~~~~~~~~~
/usr/include/c++/14/bits/basic_string.h:2086: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>::insert(size_type, const _Tp&, size_type, size_type) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]'
 2086 |         insert(size_type __pos1, const _Tp& __svt,
      |         ^~~~~~
/usr/include/c++/14/bits/basic_string.h:2086:9: note:   candidate expects 3 arguments, 2 provided
/usr/include/c++/14/bits/basic_string.h:1831:7: note: candidate: 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::iterator std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::insert(const_iterator, size_type, _CharT) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; iterator = std::__cxx11::basic_string<char>::iterator; const_iterator = std::__cxx11::basic_string<char>::const_iterator; size_type = long unsigned int]'
 1831 |       insert(const_iterator __p, size_type __n, _CharT __c)
      |       ^~~~~~
/usr/include/c++/14/bits/basic_string.h:1831:7: note:   candidate expects 3 arguments, 2 provided
/usr/include/c++/14/bits/basic_string.h:1911:7: note: candidate: 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::iterator std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::insert(const_iterator, std::initializer_list<_Tp>) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; iterator = std::__cxx11::basic_string<char>::iterator; const_iterator = std::__cxx11::basic_string<char>::const_iterator]'
 1911 |       insert(const_iterator __p, initializer_list<_CharT> __l)
      |       ^~~~~~
/usr/include/c++/14/bits/basic_string.h:1911:29: note:   no known conversion for argument 1 from 'int' to 'std::__cxx11::basic_string<char>::const_iterator'
 1911 |       insert(const_iterator __p, initializer_list<_CharT> __l)
      |              ~~~~~~~~~~~~~~~^~~
/usr/include/c++/14/bits/basic_string.h:1939:7: note: candidate: 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::insert(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]'
 1939 |       insert(size_type __pos1, const basic_string& __str)
      |       ^~~~~~
/usr/include/c++/14/bits/basic_string.h:1939:52: note:   no known conversion for argument 2 from 'char' to 'const std::__cxx11::basic_string<char>&'
 1939 |       insert(size_type __pos1, const basic_string& __str)
      |                                ~~~~~~~~~~~~~~~~~~~~^~~~~
/usr/include/c++/14/bits/basic_string.h:1963:7: note: candidate: 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::insert(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]'
 1963 |       insert(size_type __pos1, const basic_string& __str,
      |       ^~~~~~
/usr/include/c++/14/bits/basic_string.h:1963:7: note:   candidate expects 4 arguments, 2 provided
/usr/include/c++/14/bits/basic_string.h:1987:7: note: candidate: 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::insert(size_type, const _CharT*, size_type) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; size_type = long unsigned int]'
 1987 |       insert(size_type __pos, const _CharT* __s, size_type __n)
      |       ^~~~~~
/usr/include/c++/14/bits/basic_string.h:1987:7: note:   candidate expects 3 arguments, 2 provided
/usr/include/c++/14/bits/basic_string.h:2032:7: note: candidate: 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::insert(size_type, size_type, _CharT) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; size_type = long unsigned int]'
 2032 |       insert(size_type __pos, size_type __n, _CharT __c)
      |       ^~~~~~
/usr/include/c++/14/bits/basic_string.h:2032:7: note:   candidate expects 3 arguments, 2 provided
/usr/include/c++/14/bits/basic_string.h:2051:7: note: candidate: 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::iterator std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::insert(__const_iterator, _CharT) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; iterator = std::__cxx11::basic_string<char>::iterator; __const_iterator = std::__cxx11::basic_string<char>::const_iterator]'
 2051 |       insert(__const_iterator __p, _CharT __c)
      |       ^~~~~~
/usr/include/c++/14/bits/basic_string.h:2051:31: note:   no known conversion for argument 1 from 'int' to 'std::__cxx11::basic_string<char>::__const_iterator' {aka 'std::__cxx11::basic_string<char>::const_iterator'}
 2051 |       insert(__const_iterator __p, _CharT __c)
      |              ~~~~~~~~~~~~~~~~~^~~
a.cc:32:15: error: 'std::string' {aka 'class std::__cxx11::basic_string<char>'} has no member named 'begein'; did you mean 'begin'?
   32 |     reverse(s.begein(), s.end());
      |               ^~~~~~
      |               begin