Language: C++

#include <bits/stdc++.h>
#include <deque>
using namespace std;
int n,q;
string s;
deque<char> str;
int main()
{
   // freopen("main.inp","r",stdin);
   // freopen("main.out","w",stdout);
    cin>>s;
    for(int i=0;i<s.size();++i) str.push_back(s[i]);
    cin>>q;
    int dem=0;
     while(q--)
    {
        int t;
        cin>>t;
        if(t==1)
        {
            ++dem;
        }
        else
        {
            int r;
            string c;
            cin>>r>>c;
            if(dem%2==0)
            {
                if(r==1)
                    str.push_front(c);
                else
                    str.push_back(c);
            }
            else
            {
                if(r==2)
                    str.push_front(c);
                else
                    str.push_back(c);
            }
        }
    }
    if(dem%2==0)
        for(int i=0;i<str.size();++i)
            cout<<str[i];
    else
    {
        for(int i=str.size()-1;i>=0;++i)
            cout<<str[i];
    }
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:31:35: error: no matching function for call to 'std::deque<char>::push_front(std::string&)'
   31 |                     str.push_front(c);
      |                     ~~~~~~~~~~~~~~^~~
In file included from /usr/include/c++/14/deque:66,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:139,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_deque.h:1501:7: note: candidate: 'void std::deque<_Tp, _Alloc>::push_front(const value_type&) [with _Tp = char; _Alloc = std::allocator<char>; value_type = char]'
 1501 |       push_front(const value_type& __x)
      |       ^~~~~~~~~~
/usr/include/c++/14/bits/stl_deque.h:1501:36: note:   no known conversion for argument 1 from 'std::string' {aka 'std::__cxx11::basic_string<char>'} to 'const std::deque<char>::value_type&' {aka 'const char&'}
 1501 |       push_front(const value_type& __x)
      |                  ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_deque.h:1516:7: note: candidate: 'void std::deque<_Tp, _Alloc>::push_front(value_type&&) [with _Tp = char; _Alloc = std::allocator<char>; value_type = char]'
 1516 |       push_front(value_type&& __x)
      |       ^~~~~~~~~~
/usr/include/c++/14/bits/stl_deque.h:1516:31: note:   no known conversion for argument 1 from 'std::string' {aka 'std::__cxx11::basic_string<char>'} to 'std::deque<char>::value_type&&' {aka 'char&&'}
 1516 |       push_front(value_type&& __x)
      |                  ~~~~~~~~~~~~~^~~
a.cc:33:34: error: no matching function for call to 'std::deque<char>::push_back(std::string&)'
   33 |                     str.push_back(c);
      |                     ~~~~~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_deque.h:1538:7: note: candidate: 'void std::deque<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = char; _Alloc = std::allocator<char>; value_type = char]'
 1538 |       push_back(const value_type& __x)
      |       ^~~~~~~~~
/usr/include/c++/14/bits/stl_deque.h:1538:35: note:   no known conversion for argument 1 from 'std::string' {aka 'std::__cxx11::basic_string<char>'} to 'const std::deque<char>::value_type&' {aka 'const char&'}
 1538 |       push_back(const value_type& __x)
      |                 ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_deque.h:1553:7: note: candidate: 'void std::deque<_Tp, _Alloc>::push_back(value_type&&) [with _Tp = char; _Alloc = std::allocator<char>; value_type = char]'
 1553 |       push_back(value_type&& __x)
      |       ^~~~~~~~~
/usr/include/c++/14/bits/stl_deque.h:1553:30: note:   no known conversion for argument 1 from 'std::string' {aka 'std::__cxx11::basic_string<char>'} to 'std::deque<char>::value_type&&' {aka 'char&&'}
 1553 |       push_back(value_type&& __x)
      |                 ~~~~~~~~~~~~~^~~
a.cc:38:35: error: no matching function for call to 'std::deque<char>::push_front(std::string&)'
   38 |                     str.push_front(c);
      |                     ~~~~~~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_deque.h:1501:7: note: candidate: 'void std::deque<_Tp, _Alloc>::push_front(const value_type&) [with _Tp = char; _Alloc = std::allocator<char>; value_type = char]'
 1501 |       push_front(const value_type& __x)
      |       ^~~~~~~~~~
/usr/include/c++/14/bits/stl_deque.h:1501:36: note:   no known conversion for argument 1 from 'std::string' {aka 'std::__cxx11::basic_string<char>'} to 'const std::deque<char>::value_type&' {aka 'const char&'}
 1501 |       push_front(const value_type& __x)
      |                  ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_deque.h:1516:7: note: candidate: 'void std::deque<_Tp, _Alloc>::push_front(value_type&&) [with _Tp = char; _Alloc = std::allocator<char>; value_type = char]'
 1516 |       push_front(value_type&& __x)
      |       ^~~~~~~~~~
/usr/include/c++/14/bits/stl_deque.h:1516:31: note:   no known conversion for argument 1 from 'std::string' {aka 'std::__cxx11::basic_string<char>'} to 'std::deque<char>::value_type&&' {aka 'char&&'}
 1516 |       push_front(value_type&& __x)
      |                  ~~~~~~~~~~~~~^~~
a.cc:40:34: error: no matching function for call to 'std::deque<char>::push_back(std::string&)'
   40 |                     str.push_back(c);
      |                     ~~~~~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_deque.h:1538:7: note: candidate: 'void std::deque<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = char; _Alloc = std::allocator<char>; value_type = char]'
 1538 |       push_back(const value_type& __x)
      |       ^~~~~~~~~
/usr/include/c++/14/bits/stl_deque.h:1538:35: note:   no known conversion for argument 1 from 'std::string' {aka 'std::__cxx11::basic_string<char>'} to 'const std::deque<char>::value_type&' {aka 'const char&'}
 1538 |       push_back(const value_type& __x)
      |                 ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_deque.h:1553:7: note: candidate: 'void std::deque<_Tp, _Alloc>::push_back(value_type&&) [with _Tp = char; _Alloc = std::allocator<char>; value_type = char]'
 1553 |       push_back(value_type&& __x)
      |       ^~~~~~~~~
/usr/include/c++/14/bits/stl_deque.h:1553:30: note:   no known conversion for argument 1 from 'std::string' {aka 'std::__cxx11::basic_string<char>'} to 'std::deque<char>::value_type&&' {aka 'char&&'}
 1553 |       push_back(value_type&& __x)
      |                 ~~~~~~~~~~~~~^~~