Language: C++

#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;

#define rep(i,a) for(int i=0;i<a;i++)
#define mp make_pair
#define pb push_back
#define ll __int64
#define __int64 long long
#define P pair<int,int>
#define PP pair<P,int>
#define F first
#define S second

string s;
int q;
string s1, s2;

list<char>a1, a2;

int main() {
    cin >> s >> q;
    
    s1 = s;
    s2 = s;
    reverse(s2.begin(), s2.end());
    rep(i, s.size()) {
        a1.push_back(s1[i]);
        a2.push_back(s2[i]);
    }

    while (q--) {
        int ti;
        cin >> ti;
        if (ti == 1) {
            swap(a1, a2);

        }

        if (ti == 2) {
            int ci;
            char x;
            cin >> ci>>x;
            if (ci == 1) {
                //s1 = x + s1;
                //s2 = s2 + x;
                a1.push_front(x);
                a2.push_back(x);
            }
            if (ci == 2) {
               // s1 = s1 + x;
               // s2 = x + s2;
                a2.push_front(x);
                a1.push_back(x);
            }
        }
    }
    for (auto it = a1.begin(); it != a1.end(); it++)cout << (*it);
    cout << endl;
    return 0;
}


Compiler output:
a.cc:36:1: error: 'list' does not name a type
   36 | list<char>a1, a2;
      | ^~~~
a.cc: In function 'int main()':
a.cc:45:9: error: 'a1' was not declared in this scope; did you mean 'y1'?
   45 |         a1.push_back(s1[i]);
      |         ^~
      |         y1
a.cc:46:9: error: 'a2' was not declared in this scope; did you mean 's2'?
   46 |         a2.push_back(s2[i]);
      |         ^~
      |         s2
a.cc:53:18: error: 'a1' was not declared in this scope; did you mean 'y1'?
   53 |             swap(a1, a2);
      |                  ^~
      |                  y1
a.cc:53:22: error: 'a2' was not declared in this scope; did you mean 's2'?
   53 |             swap(a1, a2);
      |                      ^~
      |                      s2
a.cc:64:17: error: 'a1' was not declared in this scope; did you mean 'y1'?
   64 |                 a1.push_front(x);
      |                 ^~
      |                 y1
a.cc:65:17: error: 'a2' was not declared in this scope; did you mean 's2'?
   65 |                 a2.push_back(x);
      |                 ^~
      |                 s2
a.cc:70:17: error: 'a2' was not declared in this scope; did you mean 's2'?
   70 |                 a2.push_front(x);
      |                 ^~
      |                 s2
a.cc:71:17: error: 'a1' was not declared in this scope; did you mean 'y1'?
   71 |                 a1.push_back(x);
      |                 ^~
      |                 y1
a.cc:75:20: error: 'a1' was not declared in this scope; did you mean 'y1'?
   75 |     for (auto it = a1.begin(); it != a1.end(); it++)cout << (*it);
      |                    ^~
      |                    y1