Language: C++

#include <bits/stdc++.h>
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

int main(void)
{
  string s, t="";
  int q, flag=0;
  cin >> s >> q;
  REP(i,q) {
    int cmd;
    cin >> cmd;
    if(cmd==1) {
      ++flag;
    } else {
      int choice;
      string sc;
      cin >> choice >> sc;
      if((flag+choice)&1) t.push_back(sc[0]);
      else s.push_back(sc[0]);
    }
  }
  if(flag & 1) swap(s,t);
  cout << s << string(t.rbegin(),t.rend()) << endl;
  return 0;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:7:3: error: 'string' was not declared in this scope
    7 |   string s, t="";
      |   ^~~~~~
a.cc:7:3: note: suggested alternatives:
In file included from /usr/include/c++/14/string:41,
                 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/stringfwd.h:77:33: note:   'std::string'
   77 |   typedef basic_string<char>    string;
      |                                 ^~~~~~
/usr/include/c++/14/string:76:11: note:   'std::pmr::string'
   76 |     using string    = basic_string<char>;
      |           ^~~~~~
a.cc:9:3: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
    9 |   cin >> s >> q;
      |   ^~~
      |   std::cin
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:146:
/usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here
   62 |   extern istream cin;           ///< Linked to standard input
      |                  ^~~
a.cc:9:10: error: 's' was not declared in this scope
    9 |   cin >> s >> q;
      |          ^
a.cc:2:24: error: 'll' was not declared in this scope
    2 | #define FOR(i,a,b) for(ll i=(a);i<(b);++i)
      |                        ^~
a.cc:3:18: note: in expansion of macro 'FOR'
    3 | #define REP(i,n) FOR(i,0,n)
      |                  ^~~
a.cc:10:3: note: in expansion of macro 'REP'
   10 |   REP(i,q) {
      |   ^~~
a.cc:10:7: error: 'i' was not declared in this scope
   10 |   REP(i,q) {
      |       ^
a.cc:2:33: note: in definition of macro 'FOR'
    2 | #define FOR(i,a,b) for(ll i=(a);i<(b);++i)
      |                                 ^
a.cc:10:3: note: in expansion of macro 'REP'
   10 |   REP(i,q) {
      |   ^~~
a.cc:17:13: error: expected ';' before 'sc'
   17 |       string sc;
      |             ^~~
      |             ;
a.cc:18:24: error: 'sc' was not declared in this scope
   18 |       cin >> choice >> sc;
      |                        ^~
a.cc:19:27: error: 't' was not declared in this scope
   19 |       if((flag+choice)&1) t.push_back(sc[0]);
      |                           ^
a.cc:23:23: error: 't' was not declared in this scope
   23 |   if(flag & 1) swap(s,t);
      |                       ^
a.cc:23:16: error: 'swap' was not declared in this scope
   23 |   if(flag & 1) swap(s,t);
      |                ^~~~
a.cc:23:16: note: suggested alternatives:
In file included from /usr/include/c++/14/regex:68,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:181:
/usr/include/c++/14/bits/regex.h:2230:5: note:   'std::__cxx11::swap'
 2230 |     swap(match_results<_Bi_iter, _Alloc>& __lhs,
      |     ^~~~
In file included from /usr/include/c++/14/bits/stl_pair.h:61,
                 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/bits/move.h:226:5: note:   'std::swap'
  226 |     swap(_Tp& __a, _Tp& __b)
      |     ^~~~
/usr/include/c++/14/bits/move.h:226:5: note:   'std::swap'
In file included from /usr/include/c++/14/exception:166,
                 from /usr/include/c++/14/stdexcept:38,
                 from /usr/include/c++/14/system_error:43,
                 from /usr/include/c++/14/bits/ios_base.h:46,
                 from /usr/include/c++/14/streambuf:43,
                 from /usr/include/c++/14/bits/streambuf_iterator.h:35,
                 from /usr/include/c++/14/iterator:66,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:54:
/usr/include/c++/14/bits/exception_ptr.h:229:5: note:   'std::__exception_ptr::swap'
  229 |     swap(exception_ptr& __lhs, exception_ptr& __rhs)
      |     ^~~~
In file included from /usr/include/c++/14/filesystem:52,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:200:
/usr/include/c++/14/bits/fs_path.h:736:15: note:   'std::filesystem::__cxx11::swap'
  736 |   inline void swap(path& __lhs, path& __rhs) noexcept { __lhs.swap(__rhs); }
      |               ^~~~
a.cc:24:3: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   24 |   cout << s << string(t.rbegin(),t.rend()) << endl;
      |   ^~~~
      |   std::cout
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
   63 |   extern ostream cout;          ///< Linked to standard output
      |                  ^~~~
a.cc:24:23: error: 't' was not declared in this scope
   24 |   cout << s << string(t.rbegin(),t.rend()) << endl;
      |                       ^
a.cc:24:47: error: 'endl' was not declared in this scope; did you mean 'std::endl'?
   24 |   cout << s << string(t.rbegin(),t.rend()) << endl;
      |                                               ^~~~
      |                                               std::endl
In file included from /usr/include/c++/14/istream:41,
                 from /usr/include/c++/14/sstream:40,
                 from /usr/include/c++/14/complex:45,
                 from /usr/include/c++/14/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:127:
/usr/include/c++/14/ostream:744:5: note: 'std::endl' declared here
  744 |     endl(basic_ostream<_CharT, _Traits>& __os)
      |     ^~~~