criyle/codenet-compile-errors huggingface dataset:
Language: C++

#include <bits/stdc++.h>
using namespace std;
 
int main(void) {
 
    string S;
    cin >> S;
 
    int Q;
    cin >> Q;
 
    int rev = 0;
    string head == "";
    string tail == "";

    for(int i=0; i<Q; i++)
    {
        int t,f;
        string c;
        cin >> t;
      	if (t==1)
        {
            //reverse(S.begin(), S.end());
            rev = 1 - rev;
        }
        if (t==2)
        {
            cin >> f >> c;
            if (f==1)
            {
                if (rev==0)
                    //S = c+S;
                    head = c+head;
                else
                    //S = S+c;
                    tail = tail+c;
            }
            else
            {
                if (rev==0)
                    //S = S+c;
                    tail = tail+c;
                else
                    //S = c+S;
                    head = c+head;
            }
        }        
    }

    S=head+S+tail;
    if (rev==1)
        reverse(S.begin(), S.end());
    cout << S << endl;
 
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:13:17: error: expected initializer before '==' token
   13 |     string head == "";
      |                 ^~
a.cc:14:17: error: expected initializer before '==' token
   14 |     string tail == "";
      |                 ^~
a.cc:33:21: error: 'head' was not declared in this scope; did you mean 'read'?
   33 |                     head = c+head;
      |                     ^~~~
      |                     read
a.cc:36:21: error: 'tail' was not declared in this scope; did you mean 'tanl'?
   36 |                     tail = tail+c;
      |                     ^~~~
      |                     tanl
a.cc:42:21: error: 'tail' was not declared in this scope; did you mean 'tanl'?
   42 |                     tail = tail+c;
      |                     ^~~~
      |                     tanl
a.cc:45:21: error: 'head' was not declared in this scope; did you mean 'read'?
   45 |                     head = c+head;
      |                     ^~~~
      |                     read
a.cc:50:7: error: 'head' was not declared in this scope; did you mean 'read'?
   50 |     S=head+S+tail;
      |       ^~~~
      |       read
a.cc:50:14: error: 'tail' was not declared in this scope; did you mean 'tanl'?
   50 |     S=head+S+tail;
      |              ^~~~
      |              tanl
Language: C++

#include <iostream>
using namespace std;

int main()
{
  string s;
  cin >> s;
  int q;
  cin >> q;

  bool flag = true;
  for (int i = 0; i < q; i++)
  {
    int t;
    cin >> t;
    if (t == 1)
      flag = !flag;
    if (t == 2)
    {
      int f;
      string c;
      cin >> f >> c;
      if (flag)
      {
        if (f == 1)
          s = c + s;
        else
          s = s + c;
      }
      else
      {
        if (f == 1)
          s = s + c;
        else
          s = c + s;
      }
    }
  }
  if (flag)
    cout << s << endl;
  else
  {
    reverse(s.begin(), s.end());
    cout << s << endl;
  }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:43:5: error: 'reverse' was not declared in this scope
   43 |     reverse(s.begin(), s.end());
      |     ^~~~~~~
Language: C++

#include<bits/stdc++.h>
using namespace std; 
int main() 
{stirng s;cin>>s;
 long long q;cin>>q;
 while(q--)
 {long long f;cin>>f;if(f==1)reverse(s.begin(),s.end());
  else
  {
  long long a;cin>>a;
  char c;cin>>c;
  if(a==2){s+=c;}
    else{reverse(s.begin(),s.end());s+=c;reverse(s.begin(),s.end());}
  }
 }cout<<s;
 return 0; 
}


Compiler output:
a.cc: In function 'int main()':
a.cc:4:2: error: 'stirng' was not declared in this scope
    4 | {stirng s;cin>>s;
      |  ^~~~~~
a.cc:4:16: error: 's' was not declared in this scope
    4 | {stirng s;cin>>s;
      |                ^
Language: C++

#include<iostream>
#include<string>
#include<vector>

using namespace std;

string S;
int Q;

int main(){
    cin >> S >> Q;
    for(int i=0;i<Q;i++){
        //cout << "in_for" << endl;
        int t;
        cin >> t;
        if(t==2){
            //cout << "in_for_if" << endl;
            int f;
            char c;
            cin >> f >> c;
            if(f==1) {
                //cout << "in_for_if_if1" << endl;
                S=c+S;
                //cout << S << endl;
            }
            else{
                S=S+c;
                //cout << S << endl;
            }
        }
        else reverse(S.begin(), S.end());
    }
    cout << S << endl;
    return 0;

}

Compiler output:
a.cc: In function 'int main()':
a.cc:31:14: error: 'reverse' was not declared in this scope
   31 |         else reverse(S.begin(), S.end());
      |              ^~~~~~~
Language: C++

#include <iostream>
#include <set>
#include <vector>
#include <iomanip>
#include <deque>


#include <algorithm>

#include <cfenv>
#include <cmath>
typedef long long int ll;

using namespace std;
#include <string>

int main()
{


     deque<char> S;

     string s;
     ll Q;

     bool riv_flag =0;


     

     cin >> s;
     for(char c: s){

         S.push_back(c);


         
     }

     cin >>Q;







     for(ll i=0;i<Q;i++){


         ll T;


         cin >> T;

         if(T ==1 ){


             if(riv_flag ==0){

                 riv_flag =1;
             }
             else{

                 riv_flag =0;
             }
         }
         else{


             ll F;
             char C;

             cin >> F >> C;

             if(!riv_flag){


                 if(F ==1){

                     S.push_front(C);
                 }
                 else{

                     S.push_back(C);
                 }


             }
             else{


                 if(F ==1){

                     S.push_back(C);
                 }
                 else{

                     S.push_front(C);
                 }


                 
             }
         }


         
     }

      string ans;


         for(char c:S){


             ans += C;


         }


     if(!riv_flag ){


        


         cout << ans << endl;
     }
     else{


         reverse(ans.begin(),S.end());

         cout << ans << endl;
     }

    


    
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:117:21: error: 'C' was not declared in this scope
  117 |              ans += C;
      |                     ^
a.cc:134:17: error: no matching function for call to 'reverse(std::__cxx11::basic_string<char>::iterator, std::deque<char>::iterator)'
  134 |          reverse(ans.begin(),S.end());
      |          ~~~~~~~^~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:61,
                 from a.cc:8:
/usr/include/c++/14/bits/stl_algo.h:1083:5: note: candidate: 'template<class _BIter> void std::reverse(_BIter, _BIter)'
 1083 |     reverse(_BidirectionalIterator __first, _BidirectionalIterator __last)
      |     ^~~~~~~
/usr/include/c++/14/bits/stl_algo.h:1083:5: note:   template argument deduction/substitution failed:
a.cc:134:17: note:   deduced conflicting types for parameter '_BIter' ('__gnu_cxx::__normal_iterator<char*, std::__cxx11::basic_string<char> >' and 'std::_Deque_iterator<char, char&, char*>')
  134 |          reverse(ans.begin(),S.end());
      |          ~~~~~~~^~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:86:
/usr/include/c++/14/pstl/glue_algorithm_defs.h:249:1: note: candidate: 'template<class _ExecutionPolicy, class _BidirectionalIterator> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, void> std::reverse(_ExecutionPolicy&&, _BidirectionalIterator, _BidirectionalIterator)'
  249 | reverse(_ExecutionPolicy&& __exec, _BidirectionalIterator __first, _BidirectionalIterator __last);
      | ^~~~~~~
/usr/include/c++/14/pstl/glue_algorithm_defs.h:249:1: note:   candidate expects 3 arguments, 2 provided
Language: C++

#include <iostream>
#include <set>
#include <vector>
#include <iomanip>


#include <algorithm>

#include <cfenv>
#include <cmath>
typedef long long int ll;

using namespace std;
#include <string>

int main()
{


     string S;
     ll Q;

     bool riv_flag =0;




     for(ll i=0;i<Q;i++){


         ll F;


         cin >> T;

         if(T ==1 ){


             if(riv_flag ==0){

                 riv_flag =1;
             }
             else{

                 riv_flag =0;
             }
         }
         else{


             ll F;
             string C;

             cin >> F >> C;

             if(!riv_flag){


                 if(F ==1){

                     S = C +S;
                 }
                 else{

                     S = S +C;
                 }


             }
             else{


                 if(F ==1){

                     S = S +C;
                 }
                 else{

                     S = C + S;
                 }


                 
             }
         }


         
     }


     if(!riv_flag ){


         cout << S << endl;
     }
     else{


         reverse(S.begin(),S.end());

         cout << S << endl;
     }

    


    
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:34:17: error: 'T' was not declared in this scope
   34 |          cin >> T;
      |                 ^
Language: C++

//BISMILLAH
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int b;
    char s[1000000];
    scanf("%s",s);
    int t;
    cin>>t;
    while(t--)
    {
        int a;
        cin>>a;
        if(a==1)
        {
            strrev(s);
        }
        else
        {
            //cout<< "else";

            cin>>b;
            char ch[1];
            scanf("%s",ch);
            if(b==1)
            {
                //cout<< "dukc=";
                strcat(ch,s);
                //printf("%s",ch);
                //printf("\n");
                strcpy(s,ch);
            }
            else {
                    //cout<< " ldsjf"<<endl;
                strcat(s,ch);
               // strcpy(s,ch);
            }
        }
    }

    printf("%s",s);
}


Compiler output:
a.cc: In function 'int main()':
a.cc:17:13: error: 'strrev' was not declared in this scope; did you mean 'strsep'?
   17 |             strrev(s);
      |             ^~~~~~
      |             strsep
Language: C++

#include <iostream>
#include <cmath>
#include <string>
using namespace std;
using ll = long long;

#define rep(i,N) for(int i=0;i<(int)N;++i)

int main()
{
	string S;
	cin >> S;

	int Q;
	cin >> Q;

	int T;

	int F;
	string C;

	while (cin) {
		cin >> T;
		if (T == 1) {
			reverse(S.begin(), S.end());
			cout << S << endl;
		}
		else {
			cin >> F >> C;
			if (F == 1) { S = C + S; }
			if (F == 2) { S = S+C; }
			cout << S << endl;
		}
	}
	cout << S << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:25:25: error: 'reverse' was not declared in this scope
   25 |                         reverse(S.begin(), S.end());
      |                         ^~~~~~~
Language: C++

#include <bits/stdc++.h>

using namespace std;

#define ll long long

string s;
int cnt = 0;
int c;
int a;
char ch;
void solve(){
    cin>>c;
    if(c == 1){
        cnt ++;
    }else{
        cin>>a;
        cin>>ch;
        if(a == 1){
            if(cnt % 2 == 0){
                s = ch + s;
            }else{
                s = s + ch;
            }
        }else{
            if(cnt % 2 == 0){
                s = s + ch;
            }else{
                s = ch + s;
            }
        }
    }
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL):
    cin>>s;
    int t;
    cin>>t;
    while(t--){
        solve();
    }
    if(cnt % 2 == 1){
        reverse(s.begin(),s.end());
    }
    cout<<s;
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:38:19: error: expected ';' before ':' token
   38 |     cout.tie(NULL):
      |                   ^
      |                   ;
Language: C++

int main() {
string S, X, Y;
cin >> S;
bool rev = 0;
int N;
cin >> N;
for(int i = 0; i < N; i++){
int a, b;
string c;
cin >> a;
if (a == 2){
cin >> b >> c;
b--;
if(rev) b = 1 - b;
if(b == 0) S += c;
else Y;
}
else rev - 1;
}
reverse(X.begin(), X.end());
string ans = X + S + Y;
if(rev) (ans.begin(), ans.end());
cout << ans << endl;
} 

Compiler output:
a.cc: In function 'int main()':
a.cc:2:1: error: 'string' was not declared in this scope
    2 | string S, X, Y;
      | ^~~~~~
a.cc:3:1: error: 'cin' was not declared in this scope
    3 | cin >> S;
      | ^~~
a.cc:3:8: error: 'S' was not declared in this scope
    3 | cin >> S;
      |        ^
a.cc:9:7: error: expected ';' before 'c'
    9 | string c;
      |       ^~
      |       ;
a.cc:12:13: error: 'c' was not declared in this scope
   12 | cin >> b >> c;
      |             ^
a.cc:16:6: error: 'Y' was not declared in this scope
   16 | else Y;
      |      ^
a.cc:20:9: error: 'X' was not declared in this scope
   20 | reverse(X.begin(), X.end());
      |         ^
a.cc:20:1: error: 'reverse' was not declared in this scope
   20 | reverse(X.begin(), X.end());
      | ^~~~~~~
a.cc:21:7: error: expected ';' before 'ans'
   21 | string ans = X + S + Y;
      |       ^~~~
      |       ;
a.cc:22:10: error: 'ans' was not declared in this scope
   22 | if(rev) (ans.begin(), ans.end());
      |          ^~~
a.cc:23:1: error: 'cout' was not declared in this scope
   23 | cout << ans << endl;
      | ^~~~
a.cc:23:9: error: 'ans' was not declared in this scope
   23 | cout << ans << endl;
      |         ^~~
a.cc:23:16: error: 'endl' was not declared in this scope
   23 | cout << ans << endl;
      |                ^~~~
Language: C

#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>

#define MODSIZE 300005

char queue1[300005];
char queue2[300005];


int main(){
  int head1 = 0;
  int head2 = 0;
  int tail1 = 0;
  int tail2 = 0;
  char s[2];
  int i,q;
  int com1,com2;
  char t[2];
  int rev = 0;
  int l1,l2;

  scanf("%s", s);
  scanf("%d", &q);
  for(i = 0;i < q;i++){
    scanf("%d", &com1);

    if(com1 == 1) rev++;

    else{
      scanf("%d", &com2);
      scanf("%s", t);

      if(com2 == 1){
        if(rev % 2 == 0) queue1[head1++] = t[0];

        else queue2[head2++] = t[0];
      }

      else{
        if(rev % 2 == 0) queue2[head2++] = t[0];

        else queue1[head1++] = t[0];
      }
    }
  }

  l1 = strlen(queue1);
  l2 = strlen(queue2);

  if(rev % 2 == 0){
    head1--;
    while(head1 >= 0){
      printf("%c", queue1[head1]);
      head1--;
    }
    printf("%s%s\n", s, queue2);
  }

Compiler output:
main.c: In function 'main':
main.c:59:3: error: expected declaration or statement at end of input
   59 |   }
      |   ^
Language: C

import sys



s = input()
q = int(input())
query = [None]*q
prase = [None]*(q+1)

for i in range(q):
    query[i] = [n for n in input().split()]

prase[0] = s

for i in range(1,q+1):
    if query[i-1][0] == "1":
        prase[i] = prase[i-1][::-1]

    elif query[i-1][0] == "2":
        if query[i-1][1] == "1":
            prase[i] = query[i-1][2] + prase[i-1]
        elif query[i-1][1] == "2":
            prase[i] = prase[i-1] + query[i-1][2]

print(prase[q])


Compiler output:
main.c:1:1: error: unknown type name 'import'
    1 | import sys
      | ^~~~~~
main.c:5:1: error: expected '=', ',', ';', 'asm' or '__attribute__' before 's'
    5 | s = input()
      | ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
int main(){
  string S;
  cin>>S;
  long long Q;
  cin>>Q;
  for(long long i=0; i<Q; i++){
int a;
    cin>>a;
    if (a==1) reverse(S.begin(),S.end());
    if (a==2){
      int b; cin>>b;
      string t; cin>>t;
      if(b==1) S=t+S;
      if(b==2) reverse(S.begin(),S.end()); S=S+t;
      i++:
    }
    cout<<S<<endl;
  }

Compiler output:
a.cc: In function 'int main()':
a.cc:17:10: error: expected ';' before ':' token
   17 |       i++:
      |          ^
      |          ;
a.cc:20:4: error: expected '}' at end of input
   20 |   }
      |    ^
a.cc:3:11: note: to match this '{'
    3 | int main(){
      |           ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
int main(){
  string S;
  cin>>S;
  long long Q;
  cin>>Q;
  for(int i=0; i<N; i++){
int a;
    cin>>a;
    if (a==1) reverse(S.begin(),S.end());
    if (a==2){
      int b; cin>>b;
      sting t; cin>>t;
      if(b==1) S=t+S;
      if(b==2) reverse(S.begin(),S.end()); S=S+t;
      i++:
    }
    cout<<S<<endl;
  }

Compiler output:
a.cc: In function 'int main()':
a.cc:8:18: error: 'N' was not declared in this scope
    8 |   for(int i=0; i<N; i++){
      |                  ^
a.cc:14:7: error: 'sting' was not declared in this scope
   14 |       sting t; cin>>t;
      |       ^~~~~
a.cc:14:21: error: 't' was not declared in this scope
   14 |       sting t; cin>>t;
      |                     ^
a.cc:17:10: error: expected ';' before ':' token
   17 |       i++:
      |          ^
      |          ;
a.cc:20:4: error: expected '}' at end of input
   20 |   }
      |    ^
a.cc:3:11: note: to match this '{'
    3 | int main(){
      |           ^
Language: C++

#include <bits/stdc++.h>
using namespace std;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    string s;
    int Q;
    cin >> s >> Q;
    list<char> lst(s.begin(), s.end());
    bool flag = true;
    while (Q--) {
        int q;
        cin >> q;
        if (q == 1) {
            flag = not flag;
        } else {
            int f; char c;
            cin >> f >> c;
            if (f == 1) {
                if (flag) lst.push_front(c);
                else lst.push_back(c);
            } else {
                if (flag) lst.push_back(c);
                else lst.push_front(c);
            }
        }
    }
    if (not flag) lst.reverse();
    string s(lst.begin(), lst.end());
    cout << s << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:33:12: error: redeclaration of 'std::string s'
   33 |     string s(lst.begin(), lst.end());
      |            ^
a.cc:10:12: note: 'std::string s' previously declared here
   10 |     string s;
      |            ^
Language: C++

#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0 ; i < (n) ; i++ )
using ll = long long;

using namespace std;
void output(deque<char> & q, int flg){
    if(flg>0) rep(i,q.size()) cout <<q[i];
    else{
        for(int i=q.size()-1;i>=0;i--){
            cout<<q[i];
        }
    }
    cout << endl;
}

}
int main(){
    string s; cin>>s;
    int Q; cin>>Q;
    deque<char> deq;

    // init deque
    rep(i,s.length()){
        deq.push_back(s[i]);
    }
    // 1:→　-1:←
    int dir = 1;
    rep(i,Q){
        int Ti; cin>>Ti;
        if(Ti==1){
            dir*=-1;
        }else{
            int F; char C;
            cin >> F >> C;
            if(F==2) F=-1;
            if(dir*F >0 ) deq.push_front(C);
            else deq.push_back(C);
        }

    }
    output(deq,dir);

    return 0;
}

Compiler output:
a.cc:16:1: error: expected declaration before '}' token
   16 | }
      | ^
Language: C++

#include <iostream>
#include <vector>
using namespace std;
int main(){
    string str;
    char ch;
    vector<char> strs;
    int q, c;
    cin >> str >> q;
    for(int i=0;i<str.size();i++){
        strs.push_back(str[i]);
    }

    for(int i=0;i<q;i++){
        cin >> c;
        if(c==1) reverse(strs.begin(), strs.end());
        else {
            cin >> c >> ch;
            if(c==1) strs.push_front(ch);
            else strs.push_back(ch);
        }
    }

    for(int i=0;i<strs.size();i++){
        cout << strs[i];
    }
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:16:18: error: 'reverse' was not declared in this scope
   16 |         if(c==1) reverse(strs.begin(), strs.end());
      |                  ^~~~~~~
a.cc:19:27: error: 'class std::vector<char>' has no member named 'push_front'
   19 |             if(c==1) strs.push_front(ch);
      |                           ^~~~~~~~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
int main(){
  string S;
  int Q;
  cin>>S>>Q;
  int flag=1;
  for(int i=0;i<N;i++){
    int T;
    cin>>T;
    if(T==1){
      flag=flag*(-1);
    }
    else{
      int F;
      char C;
      cin>>F>>C;
      if(F==1){
        if(flag==1){
          S=C+S;
        }
        else{
          S=S+C;
        }
      }
      else{
        if(flag==1){
          S=S+C;
        }
        else{
          S=C+S;
        }
      }
    }
  }
  if(flag==1){
    cout<<S<<endl;
  }
  else{
    reverse(S.begin(),S.end());
    cout<<S<<endl;
  }
}
        
    

Compiler output:
a.cc: In function 'int main()':
a.cc:8:17: error: 'N' was not declared in this scope
    8 |   for(int i=0;i<N;i++){
      |                 ^
Language: C++

#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
  string S;
  cin>>S;
  deque<char>　dS(S.size());
  for(int i=0;i<S.size());
  for(int i=0;i<S.size();++i) ds[i]=s[i];
  int q;
  cin>>q;
  for(int i=0;i<q;i++){
    int type;
    cin>>type;
    if(type==2){
      int f;
      char c;
      cin>>f>>c;
      --f;
      if(rev) f=1-f;
      if(f==0) dS.push_front(c);
      else dS.push_back(c);
    }
    else rev=1-rev;
  }
  if(rev) reverse(dS.begin(),dS.end());
  for(auto c:dS) cout<<c;
  cout<<endl;
}


Compiler output:
a.cc:8:14: error: extended character 　 is not valid in an identifier
    8 |   deque<char>　dS(S.size());
      |              ^
a.cc: In function 'int main()':
a.cc:8:3: error: 'deque' was not declared in this scope
    8 |   deque<char>　dS(S.size());
      |   ^~~~~
a.cc:4:1: note: 'std::deque' is defined in header '<deque>'; this is probably fixable by adding '#include <deque>'
    3 | #include<algorithm>
  +++ |+#include <deque>
    4 | using namespace std;
a.cc:8:9: error: expected primary-expression before 'char'
    8 |   deque<char>　dS(S.size());
      |         ^~~~
a.cc:9:25: error: expected ';' before ')' token
    9 |   for(int i=0;i<S.size());
      |                         ^
      |                         ;
a.cc:10:31: error: 'ds' was not declared in this scope
   10 |   for(int i=0;i<S.size();++i) ds[i]=s[i];
      |                               ^~
a.cc:10:37: error: 's' was not declared in this scope
   10 |   for(int i=0;i<S.size();++i) ds[i]=s[i];
      |                                     ^
a.cc:21:10: error: 'rev' was not declared in this scope
   21 |       if(rev) f=1-f;
      |          ^~~
a.cc:22:16: error: 'dS' was not declared in this scope; did you mean 'S'?
   22 |       if(f==0) dS.push_front(c);
      |                ^~
      |                S
a.cc:23:12: error: 'dS' was not declared in this scope; did you mean 'S'?
   23 |       else dS.push_back(c);
      |            ^~
      |            S
a.cc:25:10: error: 'rev' was not declared in this scope
   25 |     else rev=1-rev;
      |          ^~~
a.cc:27:6: error: 'rev' was not declared in this scope
   27 |   if(rev) reverse(dS.begin(),dS.end());
      |      ^~~
a.cc:27:19: error: 'dS' was not declared in this scope; did you mean 'S'?
   27 |   if(rev) reverse(dS.begin(),dS.end());
      |                   ^~
      |                   S
a.cc:28:14: error: 'dS' was not declared in this scope; did you mean 'S'?
   28 |   for(auto c:dS) cout<<c;
      |              ^~
      |              S
Language: C++

#include<iostream>
#include<vector>
#include<algolithm>
using namespace std;
int main(){
  string S;
  cin>>S;
  deque<char>　dS(S.size());
  for(int i=0;i<S.size());
  for(int i=0;i<S.size();++i) ds[i]=s[i];
  int q;
  cin>>q;
  for(int i=0;i<q;i++){
    int type;
    cin>>type;
    if(type==2){
      int f;
      char c;
      cin>>f>>c;
      --f;
      if(rev) f=1-f;
      if(f==0) dS.push_front(c);
      else dS.push_back(c);
    }
    else rev=1-rev;
  }
  if(rev) reverse(dS.begin(),dS.end());
  for(auto c:dS) cout<<c;
  cout<<endl;
}

Compiler output:
a.cc:3:9: fatal error: algolithm: No such file or directory
    3 | #include<algolithm>
      |         ^~~~~~~~~~~
compilation terminated.
Language: C++

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll=long long;

int main() {
	string s;
	cin>>s;
	int q;
	cin>>q;
	
	deque<char> ds[i]=s[i]
	bool hanten=false;
	rep(i,q){
		int t;
		cin>>t;
		if(t==1)hanten=!hanten;
		else{
			int f;
			char c;
			cin>>f>>c;
			if((f==1&&hanten==false)||(f==2&&hanten==true))ds.push_front(c);
			else ds.push_back(c);
		}
	}
	
	if(hanten)reverse(ds.begin(),ds.end());
	
	for(auto c:ds)cout<<c;
	cout<<endl;//この書き方も覚えておく
}

Compiler output:
a.cc: In function 'int main()':
a.cc:12:24: error: 'i' was not declared in this scope
   12 |         deque<char> ds[i]=s[i]
      |                        ^
a.cc:17:25: error: 'hanten' was not declared in this scope
   17 |                 if(t==1)hanten=!hanten;
      |                         ^~~~~~
a.cc:22:35: error: 'hanten' was not declared in this scope
   22 |                         if((f==1&&hanten==false)||(f==2&&hanten==true))ds.push_front(c);
      |                                   ^~~~~~
a.cc:22:72: error: 'ds' was not declared in this scope; did you mean 's'?
   22 |                         if((f==1&&hanten==false)||(f==2&&hanten==true))ds.push_front(c);
      |                                                                        ^~
      |                                                                        s
a.cc:23:30: error: 'ds' was not declared in this scope; did you mean 's'?
   23 |                         else ds.push_back(c);
      |                              ^~
      |                              s
a.cc:27:12: error: 'hanten' was not declared in this scope
   27 |         if(hanten)reverse(ds.begin(),ds.end());
      |            ^~~~~~
a.cc:27:27: error: 'ds' was not declared in this scope; did you mean 's'?
   27 |         if(hanten)reverse(ds.begin(),ds.end());
      |                           ^~
      |                           s
a.cc:29:20: error: 'ds' was not declared in this scope; did you mean 's'?
   29 |         for(auto c:ds)cout<<c;
      |                    ^~
      |                    s
Language: C++

# include <bits/stdc++.h>
# define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>0; --i)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define optimize_cin() cin.tie(0); ios::sync_with_stdio(false)
using namespace std;
using ll = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const long long INF = 1LL << 60;

int main()
{
    string s;
    cin >> s;

    deque<char> q;
    for(char c: s) q.push_back(c);
    bool flip = false;
    int Q;
    cin >> Q;
    rep(qi,Q){
        int ty;
        cin >> ty;
        if(ty == 1){
            flip = !flip;
        }
        else{
            int f;
            char c;
            cin >> f >> c;
            if(flip) f = 3-f;
            if(f == 1){
                q.push_front(c);
            }else{
                q.push_back(c);
            }
        }
    }
    if(flip) reverse(q.begin(),q.end())
    string ans;
    for(char c : q){
        ans+=c;
    }
    cout << ans << endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:44:40: error: expected ';' before 'string'
   44 |     if(flip) reverse(q.begin(),q.end())
      |                                        ^
      |                                        ;
   45 |     string ans;
      |     ~~~~~~                              
a.cc:47:9: error: 'ans' was not declared in this scope; did you mean 'abs'?
   47 |         ans+=c;
      |         ^~~
      |         abs
a.cc:49:13: error: 'ans' was not declared in this scope; did you mean 'abs'?
   49 |     cout << ans << endl;
      |             ^~~
      |             abs
Language: C++

#include "bits/stdc++.h"
using namespace std;
#define watch(x) cout << (#x) << " is " << (x) << endl

int main() {
  string s; 
  cin >> s;
  string t;
  int q; 
  cin >> q;
  while (q--) {
    int type; 
     cin >> type;
    if (type == 1) {
      swap(S, T);
    } 
    else {
      int f; char c;
       cin >> f >> c;
      if (f == 1) {
        t.push_back(c);
      } else {
        s.push_back(c);
      }
    }
  }
  
  reverse(t.begin(),t.end());
  cout << t + s << endl;
  
   }
 


Compiler output:
a.cc: In function 'int main()':
a.cc:15:12: error: 'S' was not declared in this scope
   15 |       swap(S, T);
      |            ^
a.cc:15:15: error: 'T' was not declared in this scope
   15 |       swap(S, T);
      |               ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
int main(){
	string s;
	cin>>s;
	int q;
	cin>>q;
	int t,f;
	string c;
	char k;
	while(q!=0){
		cin>>t;
		if(t==1){
			z++;
		}
		else{
			cin>>f;
			cin>>c;
			k=c[0];
			
			if((b+z-1)%2==0){
				s.insert(0,c);
			}
			else{
				s.push_back(k);
			}
		}
		q--;
	}
	if(Z%2==1){
		reverse(s.begin(),s.end());
	}
	cout<<s<<endl;
	return 0;

	
}

Compiler output:
a.cc: In function 'int main()':
a.cc:14:25: error: 'z' was not declared in this scope
   14 |                         z++;
      |                         ^
a.cc:21:29: error: 'b' was not declared in this scope
   21 |                         if((b+z-1)%2==0){
      |                             ^
a.cc:21:31: error: 'z' was not declared in this scope
   21 |                         if((b+z-1)%2==0){
      |                               ^
a.cc:30:12: error: 'Z' was not declared in this scope
   30 |         if(Z%2==1){
      |            ^
Language: C++

#youtube模範解答
#include <iostream>
#include <algorithm>
#include <deque>
#include <string>
#include <stdlib.h>
using namespace std;
#define ull unsigned long long
#define rep(i, n) for (int i = 0; i < (n); i++)

int main(void) {
  string s;
  cin >> s;
  deque<char> q;
  for (char c : s) q.push_back(c);
  bool filp = false;
  int Q;
  cin >> Q;
  rep(iq, Q) {
    int ty;
    cin >> ty;
    if (ty == 1) {
      filp = !filp;
    } else {
      int f; char c;
      cin >> f >> c;
      if (filp) f = 3-f;
      if ( f == 1) {
        q.push_front(c);
      } else {
        q.push_back(c);
      }
    }
  }
  if (filp) reverse(q.begin(), q.end());
  string ans;
  for (char c : q) ans += c;
  cout << ans << endl;
  
  return 0;
}





Compiler output:
a.cc:1:2: error: invalid preprocessing directive #youtube\U00006a21\U00007bc4\U000089e3\U00007b54
    1 | #youtube模範解答
      |  ^~~~~~~~~~~~~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S;
  cin >> S;
  long long Q;
  cin >> Q;
  for (long long i = 0; i < Q; i++){
    long long T;
    cin >> T;
    if (T == 1){
      //string U;
      /*for (long long j = 0; j < S.size(); j++){
        U = U + S.at(S.size() - j - 1);
      }*/
      reverse(S.begin(), S.end());
    }
    else {
      long long F;
      cin >> F; 
      if (F == 1){
        char C;
        cin >> C;
        S.push_front(C);
      }
      else {
        string C;
        char >> C;
        S.push_back(C);
      }
    }
  }
  cout << S << endl;
}  

Compiler output:
a.cc: In function 'int main()':
a.cc:25:11: error: 'std::string' {aka 'class std::__cxx11::basic_string<char>'} has no member named 'push_front'
   25 |         S.push_front(C);
      |           ^~~~~~~~~~
a.cc:29:14: error: expected unqualified-id before '>>' token
   29 |         char >> C;
      |              ^~
a.cc:30:21: error: cannot convert 'std::string' {aka 'std::__cxx11::basic_string<char>'} to 'char'
   30 |         S.push_back(C);
      |                     ^
      |                     |
      |                     std::string {aka std::__cxx11::basic_string<char>}
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:1572:24: note:   initializing argument 1 of 'void std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::push_back(_CharT) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]'
 1572 |       push_back(_CharT __c)
      |                 ~~~~~~~^~~
Language: C++

#include<iostream>
#include<vector>
#include<string>
using namespace std;

int main() {
    string S; cin >> S;
    int Q; cin >> Q;
    int rev = 0;
    for (int i = 0; i < Q; i++) {
        int T; cin >> T;
        if (T == 1) rev = 1 - rev;
        if (T == 2) {
            int F;
            string C; cin >> F >> C;
            if (F == 1) {
                if (rev) S = S + C;
                else  S = C + S;
            }
            else {
                if (rev) S = C + S;
                else S = S + C;
            }
        }
    }
    if (rev) reverse(S.begin(), S.end());
    cout << S << endl;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:26:14: error: 'reverse' was not declared in this scope
   26 |     if (rev) reverse(S.begin(), S.end());
      |              ^~~~~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
int main()
{
  sting S, c;
  int  q, t, f;
  cin >> S >> q;
  for(int i = 0; i < q;i++){
    cin >> t;
    if(t == 1){
      reverse(S.begin(), S.end());
    }else{
      cin >> f >> c;
      if(f == 1){
        S.insert(0, c);
      }else{
        S += c;
      }
    }
  }
  
  cout << S <<endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:5:3: error: 'sting' was not declared in this scope
    5 |   sting S, c;
      |   ^~~~~
a.cc:7:10: error: 'S' was not declared in this scope
    7 |   cin >> S >> q;
      |          ^
a.cc:13:19: error: 'c' was not declared in this scope
   13 |       cin >> f >> c;
      |                   ^
Language: C++

#include<bits/stdc++.h>
using namespace std;

int main() {
    string S;
    cin >> S;
    int Q;
    cin >> Q;
    deque<char> dq(S.size());

    for(int i = 0; i < S.size(); i++) {
        dq[i] = S[i];
    }

    vector<int> T(Q);
    vector<int> F(Q);
    vector<char> C(Q);
    for(int i = 0; i < Q; i++) {
        cin >> T[i];
        if(T[i] == 2) { cin >> F[i] >> C[i]; }
    }
    int flag = 0;
    for(int i = 0; i < Q; i++) {
        if(T[i] == 1) { flag = 1 - flag; }
        else if(T[i] == 2 && F[i] == 1) {
           if(flag == 1) { dq.push_back(C[i]); }
           else{ dq.push_front(C[i]); } 
        }
        else if(T[i] == 2 && F[i] == 2) {
            if(flag == 1) { dq.push_front(C[i]); }
            else{ dq.push_back(C[i]); }
        }
    }

    if(frag == 1) reverse(dq.begin(),dq.end());
    for(int i = 0; i < dq.size(); i++) {
        cout << dq[i];
    }
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:35:8: error: 'frag' was not declared in this scope; did you mean 'flag'?
   35 |     if(frag == 1) reverse(dq.begin(),dq.end());
      |        ^~~~
      |        flag
Language: C++

#include<bits/stdc++.h>
using namespace std;
signed main(){
  deque<char> s;
  string S;
  int Q;
  cin >> S >> Q;
  for(int j=0;j<S.length();++j) s.push_back(S[j]);
  int T[Q] = {};
  int F[Q] = {};
  int count=0;
  int count1=0;
  char C[Q];
  for(int i=0;i<Q;++i) {
    cin >> T[i];
    if(T[i]==1) {
      if(count1 != 0) {
      ++count;
    }
    if(T[i]==2) {
      cin >> F[i] >> C[i];
      if(count != 0) {
        if(count % 2 == 1) reverse(s.begin(), s.end());
      }
      if(F[i]==1) {
        s.push_front(C[i]);
      }
      if(F[i]==2) {
        s.push_back(C[i]);
      }
      count = 0;
    }
  }
  if(count != 0) {
        if(count % 2 == 1) reverse(s.begin(), s.end());
  }
  for(int l=0;l<s.size();++l) cout << s[l];
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:39:2: error: expected '}' at end of input
   39 | }
      |  ^
a.cc:3:14: note: to match this '{'
    3 | signed main(){
      |              ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
signed main(){
  deque<char> s;
  string S;
  int Q;
  cin >> S >> Q;
  for(int j=0;j<S.length();++j) s.push_back(S[j]);
  int T[Q] = {};
  int F[Q] = {};
  int count=0;
  int count1=0;
  char C[Q];
  for(int i=0;i<Q;++i) {
    cin >> T[i];
    if(T[i]==1) {
      if(count1 != 0) {
      ++count;
    }
    if(T[i]==2) {
      cin >> F[i] >> C[i];
      if(count != 0) {
        if(count % 2 == 1) reverse(s.begin(), s.end());
      }
      if(F[i]==1) {
        s.push_front(C[i]);
      }
      if(F[i]==2) {
        s.push_back(C[i])
      }
      count = 0;
    }
  }
  if(count != 0) {
        if(count % 2 == 1) reverse(s.begin(), s.end());
  }
  for(int l=0;l<s.size();++l) cout << s[l];
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:29:26: error: expected ';' before '}' token
   29 |         s.push_back(C[i])
      |                          ^
      |                          ;
   30 |       }
      |       ~                   
a.cc:39:2: error: expected '}' at end of input
   39 | }
      |  ^
a.cc:3:14: note: to match this '{'
    3 | signed main(){
      |              ^
Language: C++

#include <iostream>
#include <vector>
#include <string>

using namespace std;

int main() {
	string s;
	long int q;

	int *t;
	int *f;
	string *c;

	cin >> s;
	cin >> q;
	for (int i = 0; i < q; i++) {
		t = new int;
		f = new int;
		c = new string;
		cin >> *t;
		if (*t == 1) {
			reverse(s.begin(), s.end());
		}
		if (*t == 2) {
			cin >> *f >> *c;
			s = (*f == 1) ? *c + s : s + *c;
		}
		delete t;
		delete f;
		delete c;
	}
	cout << s;
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:23:25: error: 'reverse' was not declared in this scope
   23 |                         reverse(s.begin(), s.end());
      |                         ^~~~~~~
Language: C++

//
//  string_formation.cpp
//  learningCplusplus
//
//  Created by Tran Duc Chinh on 2020/04/04.
//  Copyright © 2020 Tran Duc Chinh. All rights reserved.
//

#include <iostream>
#include <string>
typedef long long ll;
int main(int argc, const char* argv[]) {
  std::string s;
  int q;
  std::cin >> s;
  std::cin >> q;

  for (int i=0; i<q; i++) {
    int t;
    int f;
    char c;
    std::cin >> t;
    if (t == 1) {
      std::reverse(s.begin(), s.end());
    }
    else if (t == 2) {
      std::cin >> f;
      std::cin >> c;
      if (f == 1) {
        s.insert(s.begin(), 1, c);
      }
      else if (f == 2) {
        s.push_back(c);
      }
    }
  }
  std::cout << s << std::endl;
}

Compiler output:
a.cc: In function 'int main(int, const char**)':
a.cc:24:12: error: 'reverse' is not a member of 'std'
   24 |       std::reverse(s.begin(), s.end());
      |            ^~~~~~~
Language: C++

#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>

using namespace std;
int main()
{
    string  S;
    int     Q;
    int     T;
    int     F;
    char    C;

    int     rvscnt;
    int     rvsflg;

    rvscnt = 0;
    rvsflg = 0;

    cin >> S;
    cin >> Q;

    for(int i=0; i < Q; i++){
        cin >> T;
        switch(T){
        case 1:
            //reverse(S.begin(),S.end());
            rvscnt += 1;
            rvsflg = rvscnt % 2;
            break;

        case 2:
            cin >> F >> C;
            F = (F + rvsflg)%2;
            endrvs = 0;
            switch(F){
                // Fが2の場合末尾にCを追加
                // F+ rvsflgが2の場合末尾にCを追加
                case 0:
                S = S + C;
                break;

                // Fが1の場合先頭にCを追加
                // F+ rvsflgが3の場合先頭にCを追加
                case 1:
                S = C + S;
                break;

                default:
                break;
            }
            break;

        default:
            break;
        }

    }

    if(rvscnt%2 == 1){ 
    reverse(S.begin(),S.end());
    }

    cout << S << endl;


}

Compiler output:
a.cc: In function 'int main()':
a.cc:37:13: error: 'endrvs' was not declared in this scope
   37 |             endrvs = 0;
      |             ^~~~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
#define fastinput                     \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);

int main()
{
    fastinput;
    LL n,i,j,k,t,temp;
    LL truth=0;
    string s="";
    LL queries;
    cin>>s;
    cin>>queries;
    LL f,c;
    while(queries--)
    {
        cin>>t;
        if(t==1)
        {
            truth^=1;
        }
        else
        {
            char ch;
            cin>>f>>ch;
            if((f==1 && truth==0) || (f==2 && truth==1))
            {
                s=ch+s;
            }
            else
            {
                s+=ch;
            }            
        }        
    }
    if(truth==1)
    {
        reverse(all(s));
    }
    cout<<s<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:42:17: error: 'all' was not declared in this scope; did you mean 'std::filesystem::perms::all'?
   42 |         reverse(all(s));
      |                 ^~~
      |                 std::filesystem::perms::all
In file included from /usr/include/c++/14/filesystem:51,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:200,
                 from a.cc:1:
/usr/include/c++/14/bits/fs_fwd.h:158:7: note: 'std::filesystem::perms::all' declared here
  158 |       all               =  0777,
      |       ^~~
Language: C++

from collections import deque
import sys
input=sys.stdin.readline
S=input().splitlines()[0]
Q = int(input())
qs = [input().split() for _ in range(Q)]
flipcnt = 0
S =deque(S)
for q in qs:
    if len(q) == 1:
        flipcnt += 1
        continue
    else:
        if (int(q[1]) + flipcnt) % 2 == 1:
            #前
            S.appendleft(q[2])
        else:
            S.append(q[2])
    #print(S)

if flipcnt % 2 == 1:
    S.reverse()

print(''.join(S))

Compiler output:
a.cc:15:14: error: invalid preprocessing directive #\U0000524d
   15 |             #前
      |              ^~
a.cc:19:6: error: invalid preprocessing directive #print
   19 |     #print(S)
      |      ^~~~~
a.cc:24:7: error: empty character constant
   24 | print(''.join(S))
      |       ^~
a.cc:1:1: error: 'from' does not name a type
    1 | from collections import deque
      | ^~~~
Language: Java

import java.util.*;

class Main{
    public static void main(String[] args){
        final Scanner sc = new Scanner(System.in);
        char[] s = sc.next().toCharArray();
        LinkedList<Character> list = new LinkedList<>();
        for(int i = 0; i < s.length; i++){
            list.add(s[i]);
        }
        int q = sc.nextInt();
        int dir = 0;
        for(int i = 0; i < q; i++){
            int op = sc.nextInt();
            if(op == 1){
                dir++;
            }else{
                int end = sc.nextInt();
                char let = sc.next().charAt(0);
                if((dir + end) % 2 == 0){
                    list.add(let);
                }else{
                    list.add(0, let);
                }
            }
        }
        char[] out = list.toArray();
        list = null;
        int size = out.length;
        if(dir % 2 == 0){
            for(int i = 0; i < size; i++){
                System.out.print(out[i]);
            }
        }else{
            for(int i = 0; i < size; i++){
                System.out.print(out[size - 1 - i]);
            }
        }
    }
}

Compiler output:
Main.java:27: error: incompatible types: Object[] cannot be converted to char[]
        char[] out = list.toArray();
                                 ^
1 error
Language: C++

#include <iostream>
#include <cctype>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <string>
#include <functional>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <bitset>
#define pb push_back
#define YES cout<<"YES"<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define No cout<<"No"<<endl
#define INF (1<<10)
#define MOD 1000000007
typedef long long ll;
using namespace std;

int main(){
  string s;
  deque<char> str;
  int q, reversecount=0;
  cin>>s>>q;
  for(int i=0;i<s.length();i++){
    str.push_back(s[i]);
  }
  for(int i=0;i<q;i++){
    int t;
    cin>>t;
    if(t==1) reversecount++;
    else{
      int f;
      char c;
      cin>>f>>c;
      if((f+reversecount)%2==0)s.push_back(c);
      else s.push_front(c);
    }
  }
  if(reversecount%2==0)cout<<s;
  else {
    reverse(s.begin(),s.end());
    cout<<s;
  }
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:46:14: error: 'std::string' {aka 'class std::__cxx11::basic_string<char>'} has no member named 'push_front'
   46 |       else s.push_front(c);
      |              ^~~~~~~~~~
Language: C++

#include <iostream>
#include <string>
using namespace std;

int main()
{
	string S;
	int q;
	cin >> S >> q;
	string s[2];

	int h = 0;
	for (int i = 0; i < q; i++) {
		int t;
		cin >> t;
		if (t == 1) {
			h++;
		}
		else
		{
			int f;
			string c;
			cin >> f >> c;
			if (f == 1) {	// 先頭に追加
				s[h % 2] += c;
			}
			else			// 末尾に追加
			{
				s[(h + 1) % 2] += c;
			}
		}
	}
	reverse(s[0].begin(), s[0].end());
	S = s[0] + S + s[1];
	if (h % 2 == 1) {
		reverse(S.begin(), S.end());
	}
	cout << S << endl;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:33:9: error: 'reverse' was not declared in this scope
   33 |         reverse(s[0].begin(), s[0].end());
      |         ^~~~~~~
Language: Java

import java.util.*;
public class A {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		
		String s = sc.nextLine();
		char[]arr = new char[300001];
		for(int i = 0 ; i<s.length(); i++) {
			arr[i] = s.charAt(i);
		}
		int arrindex = s.length();
		char[]front = new char[200001];
		int frontindex = 0;
		int Q = sc.nextInt();
		boolean reverse = false;
		while(Q-->0) {
			int op = sc.nextInt();
			if(op == 1) {
				reverse = !reverse;
			}
			else {
				int pos = sc.nextInt();
				char add = sc.next().charAt(0);
				if(pos == 1 && !reverse) {
					front[frontindex] = add;
					frontindex++;
				}
				else if(pos == 1 && reverse) {
					arr[arrindex] = add;
					arrindex++;
			//		System.out.println("add " + add);
				}
				else if(pos == 2 && !reverse) {
				//	System.out.println("add " + add);
					arr[arrindex] = add;
					arrindex++;
				}
				else if(pos == 2 && reverse) {
					front[frontindex] = add;
					frontindex++;
				}
			}
		}
		String res = "";
		if(!reverse) {
			for(int i = frontindex-1; i>=0 ; i--) {
				res+=front[i];
			}
			for(int i = 0; i<arrindex; i++) {
				res+=arr[i];
			}
		}
		else {
			for(int i = arrindex-1 ; i>=0; i--) {
				res+=arr[i];
			}
			for(int i = 0; i<frontindex; i++) {
				res+=front[i];
			}
		}
		System.out.println(res);
	}
}


Compiler output:
Main.java:2: error: class A is public, should be declared in a file named A.java
public class A {
       ^
1 error
Language: Java

import java.util.Scanner;

public class　Main {

	public static void main(String[] args) {
		String S;
		int Q;
		int T;
		int F;
		String J;
		int i;
		Scanner sc = new Scanner(System.in);
		S = sc.next();
		Q = Integer.parseInt(sc.next());
		StringBuilder str = new StringBuilder(S);
		for (i = 0; i < Q; i++) {
			T = Integer.parseInt(sc.next());
			if (T == 1) {
				str.reverse();
			} else {
				F = Integer.parseInt(sc.next());
				J = sc.next();
				if (F == 1) {
					str.insert(0, J);
				} else {
					str.insert(str.length(), J);
				}
			}
		}
		System.out.println(str);
		sc.close();
	}
}

Compiler output:
Main.java:3: error: illegal character: '\u3000'
public class?Main {
            ^
1 error