Language: C++

#include <iostream>
#include <string>
#include <deque>

void solve() {
  std::string str;
  bool reverse = false;
  int q;
  std::cin >> str >> q;
  std::deque<char> d;
  for (int i = 0; i < str.size(); i++) d.push_back(i);
  
  for (int i = 0; i < q; i++) {
    int t;
    std::cin >> t;
    if (t == 0) reverse = (!reverse);
    else {
      int f;
      char c;
      std::cin >> f >> c;
      if (reverse && f == 2 || 1) d.push_back(c)
      d.push_front(c)
    }
  }
  if (reverse)
    for (std::deque<char>::reverse_iterator i = d.rbegin(); i != d.rend(); ++i)
      std::cout << d[i];
  else
    for (std::deque<char>::iterator i = d.begin(); i != d.end(); ++i)
      std::cout << d[i];
  
}

int main() {
  solve();
  return 0;
}

Compiler output:
a.cc: In function 'void solve()':
a.cc:21:49: error: expected ';' before 'd'
   21 |       if (reverse && f == 2 || 1) d.push_back(c)
      |                                                 ^
      |                                                 ;
   22 |       d.push_front(c)
      |       ~                                          
a.cc:27:21: error: no match for 'operator[]' (operand types are 'std::deque<char>' and 'std::deque<char>::reverse_iterator' {aka 'std::reverse_iterator<std::_Deque_iterator<char, char&, char*> >'})
   27 |       std::cout << d[i];
      |                     ^
In file included from /usr/include/c++/14/deque:66,
                 from a.cc:3:
/usr/include/c++/14/bits/stl_deque.h:1364:7: note: candidate: 'std::deque<_Tp, _Alloc>::reference std::deque<_Tp, _Alloc>::operator[](size_type) [with _Tp = char; _Alloc = std::allocator<char>; reference = char&; size_type = long unsigned int]'
 1364 |       operator[](size_type __n) _GLIBCXX_NOEXCEPT
      |       ^~~~~~~~
/usr/include/c++/14/bits/stl_deque.h:1364:28: note:   no known conversion for argument 1 from 'std::deque<char>::reverse_iterator' {aka 'std::reverse_iterator<std::_Deque_iterator<char, char&, char*> >'} to 'std::deque<char>::size_type' {aka 'long unsigned int'}
 1364 |       operator[](size_type __n) _GLIBCXX_NOEXCEPT
      |                  ~~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_deque.h:1383:7: note: candidate: 'std::deque<_Tp, _Alloc>::const_reference std::deque<_Tp, _Alloc>::operator[](size_type) const [with _Tp = char; _Alloc = std::allocator<char>; const_reference = const char&; size_type = long unsigned int]'
 1383 |       operator[](size_type __n) const _GLIBCXX_NOEXCEPT
      |       ^~~~~~~~
/usr/include/c++/14/bits/stl_deque.h:1383:28: note:   no known conversion for argument 1 from 'std::deque<char>::reverse_iterator' {aka 'std::reverse_iterator<std::_Deque_iterator<char, char&, char*> >'} to 'std::deque<char>::size_type' {aka 'long unsigned int'}
 1383 |       operator[](size_type __n) const _GLIBCXX_NOEXCEPT
      |                  ~~~~~~~~~~^~~
a.cc:30:21: error: no match for 'operator[]' (operand types are 'std::deque<char>' and 'std::deque<char>::iterator' {aka 'std::_Deque_base<char, std::allocator<char> >::iterator'})
   30 |       std::cout << d[i];
      |                     ^
/usr/include/c++/14/bits/stl_deque.h:1364:7: note: candidate: 'std::deque<_Tp, _Alloc>::reference std::deque<_Tp, _Alloc>::operator[](size_type) [with _Tp = char; _Alloc = std::allocator<char>; reference = char&; size_type = long unsigned int]'
 1364 |       operator[](size_type __n) _GLIBCXX_NOEXCEPT
      |       ^~~~~~~~
/usr/include/c++/14/bits/stl_deque.h:1364:28: note:   no known conversion for argument 1 from 'std::deque<char>::iterator' {aka 'std::_Deque_base<char, std::allocator<char> >::iterator'} to 'std::deque<char>::size_type' {aka 'long unsigned int'}
 1364 |       operator[](size_type __n) _GLIBCXX_NOEXCEPT
      |                  ~~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_deque.h:1383:7: note: candidate: 'std::deque<_Tp, _Alloc>::const_reference std::deque<_Tp, _Alloc>::operator[](size_type) const [with _Tp = char; _Alloc = std::allocator<char>; const_reference = const char&; size_type = long unsigned int]'
 1383 |       operator[](size_type __n) const _GLIBCXX_NOEXCEPT
      |       ^~~~~~~~
/usr/include/c++/14/bits/stl_deque.h:1383:28: note:   no known conversion for argument 1 from 'std::deque<char>::iterator' {aka 'std::_Deque_base<char, std::allocator<char> >::iterator'} to 'std::deque<char>::size_type' {aka 'long unsigned int'}
 1383 |       operator[](size_type __n) const _GLIBCXX_NOEXCEPT
      |                  ~~~~~~~~~~^~~