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

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
//#include <limits.h>
//#include <math.h>

typedef struct queue
{
  char a;
  struct queue *next;
} queue;

typedef struct Queue
{
  queue *front;
  queue *back;
  int size;
} Queue;

Queue *Queue_init()
{
  Queue *Q = malloc(sizeof(Queue));
  Q->front = NULL;
  Q->back = NULL;
  Q->size = 0;
  return Q;
}

queue *queue_create(char a)
{
  queue *q = malloc(sizeof(queue));
  q->a = a;
  q->next = NULL;
  return q;
}

void queue_free(queue *q)
{
  if (q != NULL)
    free(q);
}

bool Queue_empty(Queue *Q)
{
  if (Q->size == 0)
    return true;
  return false;
}

void Queue_free(Queue *Q)
{
  if (Q != NULL)
  {
    if (Queue_empty(Q))
      free(Q);
    else
      printf("queue isn't empty.\n");
  }
  return;
}

queue *Queue_back(Queue *Q)
{
  return Q->back;
}

queue *Queue_front(Queue *Q)
{
  return Q->front;
}

void Queue_pop(Queue *Q)
{
  if (Queue_empty(Q))
    return ;
  queue *qf = Q->front;
  Q->front = qf->next;
  Q->size--;
  queue_free(qf);
  return ;
}

void Queue_push(Queue *Q, char a)
{
  queue *aq = queue_create(a);
  if (Queue_empty(Q))
  {
    Q->front = aq;
    Q->back = aq;
    Q->size++;
    return;
  }
  queue *bq = Queue_back(Q);
  bq->next = aq;
  Q->back = aq;
  Q->size++;
  return;
}

void Queue_stack(Queue *Q, char a)
{
  queue *aq = queue_create(a);
  aq->next = Q->front;
  Q->front = aq;
  Q->size++;
  return;
}

int Queue_size(Queue *Q)
{
  return Q->size;
}

int main() {
  char s[100005];
  scanf("%s", s);
  int n = strlen(s);
  Queue *Q = Queue_init();
  for (int i=0; i<n; i++)
    Queue_push(Q, s[i]);
  int q;
  scanf("%d", &q);
  bool inverse = false;
  int t, f;
  char c;
  for (int i=0; i<q; i++) {
    scanf("%d", &t);
    if (t == 1)
      inverse = (inverse) ? false : true;
    else {
      scanf("%d %c", &f, &c);
      if (inverse) {
        if (f == 1)
          Queue_push(Q, c);
        else
          Queue_stack(Q, c);
      } else {
        if (f != 1)
          Queue_push(Q, c);
        else
          Queue_stack(Q, c);
      }
    }
  }
  int size = Queue_size(Q);
  char ans[size+1];
  ans[size] = '\n';
  if (inverse) {
    for (int i=0; i<size; i++) {
      queue *Qf = Queue_front(Q);
      ans[size-i-1] = Qf->a;
      Queue_pop(Q);
    }
  } else {
    for (int i=0; i<size; i++) {
      queue *Qf = Queue_front(Q);
      ans[i] = Qf->a;
      Queue_pop(Q);
    }
  }
  Queue_free(Q);
  for (int i=0; i<size; i++) {
    printf("%c", ans[i]);
  }
  printf("\n");
  //printf("%s", ans);
  return 0;
}


Compiler output:
a.cc: In function 'Queue* Queue_init()':
a.cc:23:20: error: invalid conversion from 'void*' to 'Queue*' [-fpermissive]
   23 |   Queue *Q = malloc(sizeof(Queue));
      |              ~~~~~~^~~~~~~~~~~~~~~
      |                    |
      |                    void*
a.cc: In function 'queue* queue_create(char)':
a.cc:32:20: error: invalid conversion from 'void*' to 'queue*' [-fpermissive]
   32 |   queue *q = malloc(sizeof(queue));
      |              ~~~~~~^~~~~~~~~~~~~~~
      |                    |
      |                    void*
Language: C++

#include<iostream>
#include<string>
using namespace std;
int main(){
 	string s,ss,ans;int c,k,t=0;char m;
  	cin>>s;
  	ss=s;
  	reverse(ss.begin(),ss.end());
  	while(c--){
      cin>>k;
      if(k==1){
      	if(t==0) {ans=s;t=1;}
        else {ans=ss;t=0;}
      }
      else{
      	cin>>k>>m;
        if((k==1&&t==1)||(k==2&&t==0)) {s.insert(0,1,m);ss.push_back(m);}
      	else {ss.insert(0,1,m);s.push_back(m);}
      }
      
    }
  
  	cout<<ans;
  
}

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

string s;
deque<char> qu;
ll q,t,f,a;
bool rev;
char c;

int main(){
  cin >> s;
  for(auto c:s){
    qu.push_back(c);
  }
  cin >> q;
  while(q--){
    cin >> t;
    if(t==1){
            rev=!rev;
    }
    if(t==2){
        cin >> f >> c;
        if(f==1){
            if(rev){qu.push_back(c);}
            else{qu.push_front(c);}
        }
        else{
            if(rev){qu.push_front(c);}
            else{qu.push_back(c);}
        }
    }
  }
  if(rev){
    while(!qu.empty()){
        cout << *(qu.rbegin());
        qu.pop_back();
    }
    return 0;
  }
  while(!qu.empty()){
    cout << qu.front();
    qu.pop_front();
  }
  return 0;
}

Compiler output:
a.cc:1:1: error: 'string' does not name a type
    1 | string s;
      | ^~~~~~
a.cc:2:1: error: 'deque' does not name a type
    2 | deque<char> qu;
      | ^~~~~
a.cc:3:1: error: 'll' does not name a type
    3 | ll q,t,f,a;
      | ^~
a.cc: In function 'int main()':
a.cc:8:3: error: 'cin' was not declared in this scope
    8 |   cin >> s;
      |   ^~~
a.cc:8:10: error: 's' was not declared in this scope
    8 |   cin >> s;
      |          ^
a.cc:10:5: error: 'qu' was not declared in this scope
   10 |     qu.push_back(c);
      |     ^~
a.cc:12:10: error: 'q' was not declared in this scope
   12 |   cin >> q;
      |          ^
a.cc:14:12: error: 't' was not declared in this scope
   14 |     cin >> t;
      |            ^
a.cc:19:16: error: 'f' was not declared in this scope
   19 |         cin >> f >> c;
      |                ^
a.cc:21:21: error: 'qu' was not declared in this scope
   21 |             if(rev){qu.push_back(c);}
      |                     ^~
a.cc:22:18: error: 'qu' was not declared in this scope
   22 |             else{qu.push_front(c);}
      |                  ^~
a.cc:25:21: error: 'qu' was not declared in this scope
   25 |             if(rev){qu.push_front(c);}
      |                     ^~
a.cc:26:18: error: 'qu' was not declared in this scope
   26 |             else{qu.push_back(c);}
      |                  ^~
a.cc:31:12: error: 'qu' was not declared in this scope
   31 |     while(!qu.empty()){
      |            ^~
a.cc:32:9: error: 'cout' was not declared in this scope
   32 |         cout << *(qu.rbegin());
      |         ^~~~
a.cc:37:10: error: 'qu' was not declared in this scope
   37 |   while(!qu.empty()){
      |          ^~
a.cc:38:5: error: 'cout' was not declared in this scope
   38 |     cout << qu.front();
      |     ^~~~
Language: C++

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

Compiler output:
a.cc: In function 'int main()':
a.cc:5:8: error: 's' was not declared in this scope
    5 |   cin>>s>>Q;
      |        ^
a.cc:13:14: error: 'std::string' {aka 'class std::__cxx11::basic_string<char>'} has no member named 'push_front'
   13 |       else S.push_front(C);
      |              ^~~~~~~~~~
Language: C++

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




int main(){
    string s;cin>>s;
    ll Q;cin>>Q;
    ll cn=0;
    int plus;
    string c;
    rep(i,0,Q){
        int sousa;
        cin>>sousa;
        if(sousa==1)cn++;
        else{
            cin>>plus>>c;
            if((cn+plus)%2==1)s=c+s;
            else s=s+c;
        }
    }
 /*   if(cn%2==1){
        string S=s;
        rep(i,0,s.size()){
            S.at(i)=s.at(s.size()-1-i);
        }
        cout<<S<<endl;
    }*/
    else cout<<s<<endl;
}







Compiler output:
a.cc: In function 'int main()':
a.cc:32:5: error: 'else' without a previous 'if'
   32 |     else cout<<s<<endl;
      |     ^~~~
Language: C++

s =input()
Q = int(input())
cnt = 0
for _ in range(Q):
    qs = input().split()
    if qs[0] == '1':
        cnt+=1
    else:
        f = int(qs[1])
        c = qs[2]
        if f == 1:
            if cnt % 2 == 0:
                s = s + c
            else:
                s = c + s
        else:
            if cnt % 2 == 0:
                s = c + s
            else:
                s = s + c
if cnt % 2 == 0:
    print(s[::-1])
else:
    print(s)

Compiler output:
a.cc:1:1: error: 's' does not name a type
    1 | s =input()
      | ^
Language: C++

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

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

#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);
#define FO cout.tie(NULL);
#define FI cin.tie(NULL);
using namespace std;
int main()
{
    FAST
    FO
    FI
    string s;
    cin>>s;
    int q;
    cin>>q;
    int rev=0;
    while(q--)
    {
        int t;
        cin>>t;
        if(t==1)
        {
            if(rev==0) rev=1;
            else rev=0;
        }
        else
        {
            int f;
            char c;
            cin>>f>>c;
            if(f==1)
            {
                if(rev)
                {
                    s+=c;
                }
                else
                {
                    s=c+s;
                }
            }
            else
            {
                if(rev)
                {
                    s=c+s;
                }
                else
                {
                    s+=c;
                }
            }
        }
    }
    if(rev)
    {
        rloop(i,s.length()-1,0)
        {
            cout<<s[i];
        }
        cout<<"\n";
        return 0;
    }
    cout<<s<<"\n";
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:57:15: error: 'i' was not declared in this scope
   57 |         rloop(i,s.length()-1,0)
      |               ^
a.cc:57:9: error: 'rloop' was not declared in this scope
   57 |         rloop(i,s.length()-1,0)
      |         ^~~~~
Language: C++

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

int main(){
    string s;
    cin >> s;
    int q;
    cin >> q;
    int t;
    int p = 1;
    string pre = "";
    string post = "";
    for (int i = 0; i < q; i++) {
        cin >> t;
        if (t == 1) p *= -1;
        else {
            char c;
            int f;
            cin >> f >> c;
            if ((p > 0 & f == 1) | (p < 0 & f == 2)) pre += c;
            else post += c;
        }
    }
    if (p < 0) {
        reverse(post.begin(), post.end());
        reverse(s.begin(), s.end());
        cout << post << s << pre << endl;
    }
    else {
        reverse(pre.begin(), pre.end());
        cout << pre << s << post << endl;
    }
}


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

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

Compiler output:
a.cc: In function 'int main()':
a.cc:12:12: error: expected primary-expression before ')' token
   12 |       if((+)%2==0)S.push_back(C);
      |            ^
a.cc:13:14: error: 'std::string' {aka 'class std::__cxx11::basic_string<char>'} has no member named 'push_front'
   13 |       else S.push_front(C);
      |              ^~~~~~~~~~
Language: C++

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

const int MOD = 1000000007;
const int MAX =200000;

int main() {
  string s;
  int q;
  int t;
  int f;
  string c;
  cin >> s >> q;
  rep(i ,q) {
    cin >> t;
    if(t == 2) {
      cin >> f >> c;
      if(f == 1) {
        s.insert(0, c);
      }else {
        s += c;
      }
    } else {
      if(s.size > 1) {
        swap(s.at(0), s.at(s.size() - 1));
      }else {
        continue;
      }
    }
  }
  cout << s << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:26:12: error: invalid use of member function 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::size_type std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::size() const [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; size_type = long unsigned int]' (did you forget the '()' ?)
   26 |       if(s.size > 1) {
      |          ~~^~~~
      |                ()
Language: C++

#include<stdio.h>
#include<string.h>
char c,x[100005];
int main(){
	scanf("%c",&c);
	int n;
	int b;
	x[0]=c;
	scanf("%d",&n);
	int ch=0;
	int len=1;
	int k;
	for(int i=0;i<n;i++){
		scanf("%d",&k);
		if(k==1){
			if(len!=1)ch++;
			continue;
		}
		else if(k==2){
			scanf("%d %c",&b,&c);
			if((b+ch)%2==1){
				for(int j=len;j>0;j--){
					x[j]=x[j-1];
				}
				x[0]=c;
				len++;
			}
			else {
			x[len]=c;
			len++;
		}
		}
	}
	if(ch%2==1){
		strrev(x); 
	}
	puts(x);
}

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

public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			StringBuilder sb = new StringBuilder(scanner.next());
			StringBuilder prefix = new StringBuilder();
			int q = scanner.nextInt();
			boolean reverse = false;
			for (int i = 0; i < q; i++) {
				switch (scanner.nextInt()) {
				case 1:
					reverse = !reverse;
					break;
				case 2:
					int f = scanner.nextInt();
					String c = scanner.next();
					if (1 == f) {
						if (reverse) {
							sb.append(c);
						} else {
							prefix.append(c);
						}
					} else {
						if (reverse) {
							prefix.append(c);
						} else {
							sb.append(c);
						}
					}
				}
			}
			System.out.println((reverse ? sb.reverse().append(prefix) : prefix.reverse().append(sb)).toString());
		}
	}
}


Compiler output:
Main.java:4: error: cannot find symbol
		try (Scanner scanner = new Scanner(System.in)) {
		     ^
  symbol:   class Scanner
  location: class Main
Main.java:4: error: cannot find symbol
		try (Scanner scanner = new Scanner(System.in)) {
		                           ^
  symbol:   class Scanner
  location: class Main
2 errors
Language: C++

#include <iostream>
using namespace std;

// main() is where program execution begins.
int main()
{
    string s;
    int d;
    string q;
    cin >> s;
    cin >> d;
    for (int i = 0; i <= d; i++)
    {
        getline(cin, q);
        if (q[0] == '1')
        {
            reverse(s.begin(), s.end());
        }
        else if (q[0] == '2')
        {
            if (q[2] == '1')
            {
                s = q[4] + s;
            }
            else
            {
                s = s + q[4];
            }
        }
    }
    cout << s << endl;
}

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

#include <cstdio>
#include <cstring>
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <stack>
#include <deque>
using namespace std;

struct Point {
    Point() {x=0,y=0;}
    Point(int _x,int _y){x  =_x,y=_y;}

    int x,y;
};

// 重载相应的比较运算符
bool operator < (Point a, Point b)
{
    return a.x == b.x ? a.y < b.y : a.x < b.x;
}
long long gcd(long a, long b) {
    return b ? gcd(b, a % b) : a;
}

int dx[] = {0,0,-1,1};
int dy[] = {-1,1,0,0};
char dc[] = {'R', 'L', 'D', 'U'};
char dcc[] = {'L', 'R', 'U', 'D'};

int k,n,m;

void solvee(){
    cin >> n >> m;
    vector<long long> c(n+1);
    vector<long long> res(n+1);
    vector<vector<long long> > nxt(n+1);
    for(int i = 1; i <= n; i++) scanf("%lld", &c[i]);
    for(int i = 0; i < m; i++) {
        int u,v;
        scanf("%d%d", &u,&v);
        res[u] += c[v];
        nxt[v].push_back(u);
    }
    long long ans = res[1];
    for(int i = 1; i <= n; i++) {

        for(int j = 1; j < (1<<nxt[i].size()); j++) {
            cout << i<< ' '<< j<<endl;
            long long sum = c[i];
            for(int k = 0; k < nxt[i].size(); k++) {
                if(j&(1<<k)) {
                    sum += res[nxt[i][k]]-c[i];
                }
            }
            cout << "sum = " <<sum<<endl;
            ans = gcd(ans, sum);
        }
    }

    cout << ans <<endl;
}

char s[1000000+10];

int main() {
    deque<char> s;
    string ss;
    cin >> ss;
    for(int i = 0; i < ss.size(); i++) {
        s.push_back(ss[i]);
    }

    int n;
    cin >> n;
    int fx = 1;
    while(n--) {
        int op;
        scanf("%d", &op);
        if(op == 1) {
            fx = 1-fx;
        } else {
            char c[10];
            scanf("%d%s", &op, c);
            if(fx == 0 && op == 1 || fx == 1 && op == 2) {
                s.push_front(c[0]);
            } else {
                s.push_back(c[0]);
            }
        }
    }
    if(fx == 1) {
        reverse(s.begin(), s.end());
    }

    for(auto c : s) {
        putchar(c);
    }
    puts("");
    return 0;
}




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

#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <limits>
#include <climits>
#include <utility>
#include <algorithm>
#include <numeric>

using namespace std;

using ll = long long;
using ull = unsigned long long;

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

    int Q;
    cin >> Q;

    int rev = 0;

    array<string, 2> str;

    for (int i = 0; i < Q; ++i) {
        int T;
        cin >> T;

        if (T == 1) {
            rev = 1 - rev;
        } else if (T == 2) {
            int F;
            char C;
            cin >> F >> C;
            --F;

            if (rev == 0) {
                str[F] += C;
            } else {
                str[1-F] += C;
            }
        }
    }

    string ans;

    if (rev == 0) {
        reverse(begin(str[0]), end(str[0]));
        ans += str[0];
        ans += S;
        ans += str[1];
    } else {
        reverse(begin(str[1]), end(str[1]));
        ans += str[1];
        ans += S;
        ans += str[0];
    }

    cout << ans << endl;

    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:33:22: error: aggregate 'std::array<std::__cxx11::basic_string<char>, 2> str' has incomplete type and cannot be defined
   33 |     array<string, 2> str;
      |                      ^~~
a.cc:17:1: note: 'std::array' is defined in header '<array>'; this is probably fixable by adding '#include <array>'
   16 | #include <numeric>
  +++ |+#include <array>
   17 |
Language: C++

#include<bits/stdc++.h>
using namespace std;
int main()
{
  string S;
  cin>>S;
  int T,tmp=0;
  cin>>T;
  while(T--)
  {
    int A;
    cin>>A;
    if(A==1)
      tmp^=1;
    else
    {
      int B;
      cin>>B;
      B--;
      char x;
  	  cin>>x;
      B^=tmp;
      if(B==0)
        S=x+S;
      else	S=S+x;
    }
  }
  if(tmp)
    reverse(S.begin();S.end());
  puts(S.c_str());
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:29:22: error: expected ')' before ';' token
   29 |     reverse(S.begin();S.end());
      |            ~         ^
      |                      )
a.cc:29:30: error: expected ';' before ')' token
   29 |     reverse(S.begin();S.end());
      |                              ^
      |                              ;
a.cc:29:28: warning: ignoring return value of 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::iterator std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::end() [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; iterator = std::__cxx11::basic_string<char>::iterator]', declared with attribute 'nodiscard' [-Wunused-result]
   29 |     reverse(S.begin();S.end());
      |                       ~~~~~^~
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:978:7: note: declared here
  978 |       end() _GLIBCXX_NOEXCEPT
      |       ^~~
Language: C++

#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define rush() int T;scanf("%d",&T);while(T--)
#define mm(a,b) memset(a,b,sizeof(a))
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define sc(a) scanf("%d",&a)
#define sc2(a,b) scanf("%d%d",&a,&b)
#define pf(a) printf("%d\n",a)
#define pf2(a,b) printf("%d %d\n",a,b)
#define p_f(a) printf("%d ",a)
#define fi first
#define se second
#define db double
#define ll long long
using namespace std;
const int inf=0x3f3f3f3f;
const ll INF=0x3f3f3f3f3f3f3f3f;
const db eps=1e-9;
string s;
int q;
int com,f;
int zflag=true;
string c;
int main()
{
    cin>>s;
    cin>>q;
    rep(i,1,q){
        cin>>com;
        if(com==1)zflag=!zflag;
        else{
            cin>>f>>c;
            if(f==1&&flag)s=c+s;
            else if(f==1&&!flag)s=s+c;
            if(f==2&&flag)s=s+c;
            if(f==2&&!flag)s=c+s;
        }
    }
    if(zflag)cout<<s<<endl;
    else{
        reverse(s.begin(),s.end());
        cout<<s<<endl;
    }
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:36:22: error: 'flag' was not declared in this scope; did you mean 'zflag'?
   36 |             if(f==1&&flag)s=c+s;
      |                      ^~~~
      |                      zflag
a.cc:38:22: error: 'flag' was not declared in this scope; did you mean 'zflag'?
   38 |             if(f==2&&flag)s=s+c;
      |                      ^~~~
      |                      zflag
a.cc:39:23: error: 'flag' was not declared in this scope; did you mean 'zflag'?
   39 |             if(f==2&&!flag)s=c+s;
      |                       ^~~~
      |                       zflag
Language: C++

#include <iostream>
using namespace std;
int main() {
  string s;
  int q;
  cin >> s >> q;
  bool r = false;
  for (int i = 0; i < q; ++i) {
    int t;
    cin >> t;
    if (t == 1) {
      r = !r;
    } else if (t == 2) {
      int f;
      string c;
      cin >> f >> c;
      if (r) {
        if (f == 1) f = 2;
        else if (f == 2) f = 1;
      }
      if (f == 1) {
        s = c + s;
      } else if (f == 2) {
        s = s + c;
      }
    }
  }
  if (r) {
    reverse(s.begin(), s.end());
  }
  cout << s << endl;
  return 0;
}

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

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

Compiler output:
a.cc:11:16: error: extended character 　 is not valid in an identifier
   11 |        if(t==1)　flag++;
      |                ^
a.cc: In function 'int main()':
a.cc:11:16: error: '\U00003000flag' was not declared in this scope; did you mean 'flag'?
   11 |        if(t==1)　flag++;
      |                ^~~~~~
      |                flag
Language: C++

#include<iostream>
#include<string> 
using namespace std;
 
int main(){
  string S;
  int Q;
  int T, F;
  char C;
  cin >> S;
  cin >> Q;
  for (int i = 0; i < Q; i++){
    cin >> T;
    if(T == 1){
      reverse(S.begin(),S.end());
    }else{
      cin >> F;
      cin >> C;
      if (F == 1){
        S = "C" + S;
      }else{
        S = S + "C";
      }
    }
  }
  cout << S << endl;
}

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

#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
//#include <conio.h>
using namespace std;

typedef long long int ll;
typedef pair<ll,ll> pll;

#define rep(i,n)	for(ll i=0;i<(n);i++)
#define SZ(x) ((ll)x.size())
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define F first
#define S second
#define int ll
#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const ll MOD = INT_MAX;
const double PI = acos(-1);

void openfile(){
	freopen("in.txt", "r", stdin);
	freopen("out.txt", "w", stdout);
}

signed main(){
	IOS
	string s;	cin >> s;
	char c;
	int q;	cin >> q;
	deque<char> que;
	rep(i,SZ(s))	que.pb(s[i]);
	bool rev = 0;
	while(q--){
		int op;	cin >> op;
		if(op == 1)	rev ^= 1;
		else{
			int where;
			cin >> where >> c;
			if(rev){
				if(where == 1)	que.pb(c);
				else			que.pf(c);
			}
			else{
				if(where == 1)	que.pf(c);
				else			que.pb(c);
			}
		}
	}
	if(rev){
		while(!que.empty()){
			cout << que.back();
			que.pop_back();
		}
	}
	else{
		while(!que.empty()){
			cout << que.front();
			que.pop_front();
		}
	}
}
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
//#include <conio.h>
using namespace std;

typedef long long int ll;
typedef pair<ll,ll> pll;

#define rep(i,n)	for(ll i=0;i<(n);i++)
#define SZ(x) ((ll)x.size())
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define F first
#define S second
#define int ll
#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const ll MOD = INT_MAX;
const double PI = acos(-1);

void openfile(){
	freopen("in.txt", "r", stdin);
	freopen("out.txt", "w", stdout);
}

signed main(){
	IOS
	string s;	cin >> s;
	char c;
	int q;	cin >> q;
	deque<char> que;
	rep(i,SZ(s))	que.pb(s[i]);
	bool rev = 0;
	while(q--){
		int op;	cin >> op;
		if(op == 1)	rev ^= 1;
		else{
			int where;
			cin >> where >> c;
			if(rev){
				if(where == 1)	que.pb(c);
				else			que.pf(c);
			}
			else{
				if(where == 1)	que.pf(c);
				else			que.pb(c);
			}
		}
	}
	if(rev){
		while(!que.empty()){
			cout << que.back();
			que.pop_back();
		}
	}
	else{
		while(!que.empty()){
			cout << que.front();
			que.pop_front();
		}
	}
}


Compiler output:
a.cc:69:23: error: expected initializer before 'll'
   69 | typedef long long int ll;
      |                       ^~
a.cc:82:10: error: redefinition of 'const ll MOD'
   82 | const ll MOD = INT_MAX;
      |          ^~~
a.cc:19:10: note: 'const ll MOD' previously defined here
   19 | const ll MOD = INT_MAX;
      |          ^~~
a.cc:83:14: error: redefinition of 'const double PI'
   83 | const double PI = acos(-1);
      |              ^~
a.cc:20:14: note: 'const double PI' previously defined here
   20 | const double PI = acos(-1);
      |              ^~
a.cc:85:6: error: redefinition of 'void openfile()'
   85 | void openfile(){
      |      ^~~~~~~~
a.cc:22:6: note: 'void openfile()' previously defined here
   22 | void openfile(){
      |      ^~~~~~~~
a.cc:90:8: error: redefinition of 'int main()'
   90 | signed main(){
      |        ^~~~
a.cc:27:8: note: 'int main()' previously defined here
   27 | signed main(){
      |        ^~~~
Language: C++

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

int main() {
    string s;
    cin >> s;
    int q;
    cin >> q;
    int cnt_rev = 0;
    rep(i, q) {
        int t;
        cin >> t;
        if (t == 1) {
            cnt_rev++;
            continue;
        } else {
            int f;
            cin >> f;
            char c;
            cin >> c;
            if (f == 1) {
                if (cnt_rev % 2 == 0) {
                    s = c + s;
                } else {
                    s = s + c;
                }
            } else {
                if (cnt_rev % 2 == 0) {
                    s = s + c;
                } else {
                    s = c + s;
                }
            }
        }
    }
    if (cnt_rev % 2 != 0) reverse(s.begin(), s.end()));
    cout << s << endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:38:54: error: expected ';' before ')' token
   38 |     if (cnt_rev % 2 != 0) reverse(s.begin(), s.end()));
      |                                                      ^
      |                                                      ;
Language: C++

#include<iostream>
#include<string>
using namespace std;
int main(){
    int rev = 0;
    string S;
    cin >> S;
    int Q;
    cin >> Q;
    int T,F;
    string C;
    string forward="";
    string back = "";
    for(int i=0; i<Q; i++){
        cin >> T;
        if(T==1){
            rev = (rev+1)%2;
        }else{
            cin >> F >> C;
            if((F+rev)%2) forward=C+forward;
            else back +=C;
        }
    }
    string ans = forward + S + back;
    if(rev) reverse(ans.begin(),ans.end());
    cout << ans << endl;
}

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

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

int main() {
    string s;
    cin >> s;
    int q;
    cin >> q;
    int cnt_rev = 0;
    rep(i, q) {
        int t;
        cin >> t;
        if (t == 1) {
            cnt_rev++;
            continue;
        } else {
            int f;
            cin >> f;
            char c;
            cin >> c;
            if (f == 1) {
                if (cnt_rev % 2 == 0) {
                    s = c + s;
                } else {
                    s = s + c;
                }
            } else {
                if (cnt_rev % 2 == 0) {
                    s = s + c;
                } else {
                    s = c + s;
                }
            }
        }
    }
    if (cnt_rev % 2 != 0) reverse(ALL(s));
    cout << s << endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:38:35: error: 'ALL' was not declared in this scope
   38 |     if (cnt_rev % 2 != 0) reverse(ALL(s));
      |                                   ^~~
Language: C++

#include<iostream>
#include<string> 
using namespace std;
 
int main(){
  string S;
  int Q;
  int T, F;
  char C;
  cin >> S;
  cin >> Q;
  for (int i = 0; i < Q; i++){
    cin >> T;
    if(T == 1){
      S.reverse(S.begin(),S.end());
    }else{
      cin >> F;
      cin >> C;
      if (F == 1){
        S = "C" + S;
      }else{
        S = S + "C";
      }
    }
  }
  cout << S << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:15:9: error: 'std::string' {aka 'class std::__cxx11::basic_string<char>'} has no member named 'reverse'; did you mean 'reserve'?
   15 |       S.reverse(S.begin(),S.end());
      |         ^~~~~~~
      |         reserve
Language: C++

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

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

Compiler output:
a.cc: In function 'int main()':
a.cc:15:9: error: 'std::string' {aka 'class std::__cxx11::basic_string<char>'} has no member named 'reverse'; did you mean 'reserve'?
   15 |       S.reverse();
      |         ^~~~~~~
      |         reserve
Language: C++

#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bits/stdc++.h>
#include<cmath>
#include<bitset>
#include<stack>
#include<queue>
#include<deque>
#define ll long long
#define itn int
#define co(ans) cout<<ans<<endl;
#define COYE cout<<"YES"<<endl;
#define COYe cout<<"Yes"<<endl;
#define COye cout<<"yes"<<endl;
#define CONO cout<<"NO"<<endl;
#define CONo cout<<"No"<<endl;
#define COno cout<<"no"<<endl;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define INF ((1LL<<62)-(1LL<<31))
#define MOD 1000000007
#define MAX 510000
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;}
using namespace std;


int main(){
  deque<string> L;
  string S;
  int Q,reve=1;
  cin>>S>>Q;
  L.push_front(S);
  
  for(int i=1; i<=Q; ++i){
    int A,F;
    string C;
    cin>>A;
    if(A==1){
      reve++;
    }
    else{
      cin>>F>>C;
      if(reve%2==0){
        L.push_bacK(C);
      }
      else{
        L.push_front(C);
      }
    }
  }
  
  
  if(reve%2==1){
    for_each(L.begin(),L.end(),[](string x) {
      cout<<x;
    });
    cout<<endl;
  }
  
  else{
    for_each(L.end(),L.begin(),[](string x) {
      cout<<x;
    });
    cout<<endl;
  }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:51:11: error: 'class std::deque<std::__cxx11::basic_string<char> >' has no member named 'push_bacK'; did you mean 'push_back'?
   51 |         L.push_bacK(C);
      |           ^~~~~~~~~
      |           push_back
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
int main(){
    string S;cin>>S;
    ll Q;cin>>Q;
    bool flag=0;
    rep(i,Q){
        ll T;cin>>T;
        if(T==1){
            flag=(!flag);
        }
        else{
            ll F;char c;cin>>F>>c;
            if(F==1){
                if(flag){
                    S+=c;
                }
                else{
                    S=c+S;
                }
            }
            else{
                if(flag){
                    S=c+S;
                }
                else{
                    S+=c;
                }
            }
        }
    }
    if(flag)reverse(all(S));
    cout<<S<<endl;
    return 0;
}

Compiler output:
a.cc:29:26: error: stray '\16' in program
   29 |             flag=(!flag);<U+000E>
      |                          ^~~~~~~~
Language: C++

#include "stdafx.h"
#include <bits/stdc++.h>
#define f(i,n) for(int i=0;i<n;i++)
#define P pair<int,int>
#define F first
#define S second
#define int long long
#define mod 1000000007
#define all(v) v.begin(), v.end()
using namespace std;
int mypow(int a, int b, int c) {
	if (b == 0)return 1;
	if (b % 2)return mypow(a, b - 1, c)*a%c;
	int z = mypow(a, b / 2, c);
	return z * z%c;
}
signed main() {
	string s;
	deque<char> d;
	int n, z = 0;
	cin >> s >> n;
	f(i, s.size()) {
		d.push_back(s[i]);
	}
	f(i, n) {
		int a;
		cin >> a;
		if (a == 1) {
			z = (z + 1) % 2;
		}
		else {
			int b;
			char c;
			cin >> b >> c;
			if ((z + b) % 2) d.push_front(c);
			else d.push_back(c);
		}
	}
	if (z) {
		f(i, d.size()) {
			cout << d[d.size() - i - 1];
		}
	}
	else {
		f(i, d.size()) {
			cout << d[i];
		}
	}
	cout << endl;
}

Compiler output:
a.cc:1:10: fatal error: stdafx.h: No such file or directory
    1 | #include "stdafx.h"
      |          ^~~~~~~~~~
compilation terminated.
Language: C++

#![allow(non_snake_case)]

use proconio::input;
use proconio::fastout;

#[fastout]
fn main() {
    input! {
        N: usize,
        P: usize,
        S: String,
    }
    let S = S.as_bytes();
    let mut result = 0usize;
    if 10 % P == 0 {
        for i in 0..N {
            let x = (S[i] - b'0') as usize;
            if x % P == 0 {
                result += i + 1;
            }
        }
    } else {
        let mut dp = vec![0; P];
        let mut r = 0;
        for c in S {
            dp[r] += 1;
            let x = (c - b'0') as usize;
            r = (10 * r + x) % P;
            result += dp[r];
        }
    }
    println!("{}", result);
}


Compiler output:
a.cc:1:2: error: invalid preprocessing directive #!
    1 | #![allow(non_snake_case)]
      |  ^
a.cc:6:2: error: invalid preprocessing directive #[
    6 | #[fastout]
      |  ^
a.cc:16:18: error: too many decimal points in number
   16 |         for i in 0..N {
      |                  ^~~~
a.cc:3:1: error: 'use' does not name a type
    3 | use proconio::input;
      | ^~~
a.cc:4:1: error: 'use' does not name a type
    4 | use proconio::fastout;
      | ^~~
a.cc:7:1: error: 'fn' does not name a type
    7 | fn main() {
      | ^~
Language: C++

#include<iostream>
#include<cstdio>
#include <stdio.h>
#include<algorithm>
#include<cstring>
#include <string>
#include<cmath>
#include<cstdlib>
#include<queue>
#include<map>
#include<vector>
#include<bits/stdc++.h>
#include <set>
#define ll   long long
#define IO ios::sync_with_stdio(false);cin.tie();cout.tie(0)
#define inf 0x3f3f3f3f3f3f3f3f
#define pi 3.1415926535898
#define N 200050
using namespace std;
char a[200050];
int c[200050];
int main()
{
    int n,p;
    cin>>n>>p;
    cin>>(a+1);
    long long int  ans=0;
    if(p==2||p==5)
    {
        for(int i=1; i<=n; i++)
        {
            if((a[i]-'0')%p==0)
                ans+=i;
        }
        cout<<ans<<endl;
        return 0;
    }
    int   t=1;
    int sum=0;
    c[0]=1;
    for(int i=n; i>=; i--)
    {
        sum=(sum+(a[i]-'0')*t)%p;
        ans+=c[sum];
        c[sum]++;
        t=t*10%p;
    }
    cout<<ans<<endl;
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:41:21: error: expected primary-expression before ';' token
   41 |     for(int i=n; i>=; i--)
      |                     ^
Language: C++

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

long long N, P;
string S;

long long memo[200005];
map<long long, long long>pcount;
long long kaidan[10000000];

long long modpow(long long ori, long long po){
	long long res = 1;
	while(po > 0){
		if(po&1){
			res *= ori;
			res %= P;
		}
		ori *= ori;
		ori %= P;
		po >>= 1;
	}
	return res;
}


int main(){
	cin >> N >> P >> S;
	if(P == 2 || p == 5){
		return 1;
	}

	for(long long i = 0; i < N; i++) {
		memo[i+1] = memo[i] + (S[N-1-i] - '0') * modpow(10, i);
		memo[i+1] %= P;
		pcount[memo[i+1]]++;
	}
	//for(long long i = 0; i <= N; i++) {
	//	cout << "memo[" << i << "] = " << memo[i] << endl;
	//}


	long long ans = 0;
	for(auto item: pcount) {
		//cout << item.first << ", " << item.second << endl;
		if(item.first == 0) {
			ans += (item.second * (item.second - 1))/2 + item.second;
		} else {
			ans += (item.second * (item.second - 1))/2;
		}
	}
	cout << ans << endl;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:28:22: error: 'p' was not declared in this scope
   28 |         if(P == 2 || p == 5){
      |                      ^
Language: C++

#include <iostream>
#include <vector>
#include <queue>


using namespace std;

typedef long long ll;
typedef vector<vector<int> > Graph;

ll str_int(string s,int P){
    ll num=0;
    ll keta=1;
    reverse(s.begin(),s.end());
    
    for(int i=0;i<s.size();++i){
        num+=(s[i]-'0')*keta%P;
        keta =keta*10%P;
        
    }
    return num;
}


int main() {
    int N,P;
    cin>>N>>P;
    string s;
    cin>>s;
    
    ll count=0;
   
    for(int i=0;i<N;++i){
        for(int j=N-i;j>0;--j){
            string str=s.substr(i,j);
            if(str_int(str,P)%P==0)++count;
            
        }
    }
    
    cout<<count<<endl;
}

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

#include <bits/stdc++.h>
#define ll long long
#define PB push_back
#define MP make_pair

#define REP(i, n) for(int i=0;i<(int)(n);++i)
#define FOR(i,l,h) for(int i=(int)(l);i<=(int)(h);++i)
#define FORD(i,h,l) for(int i=(int)(h);i>=(int)(l);--i)

#define max(a,b) a>b?a:b
#define min(a,b) a>b?b:a

ll gcd(ll a, ll b) { return !b ? a : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }

#define dump(x)  cerr << #x << " = " << (x) << endl
#define ALL(t) (t).begin(),(t).end()

using namespace std;



int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,k;cin>>n>>k;
    string s;
    cin>>s;
    ll int cnt = 0;
    ll int a[n+2];
    ll int mul = 1;
    if(k == 2 || k == 5){
        for (size_t i = 0; i < n; i++) {
            if((s[i] == '0' % k == 0){
                cnt += (i+1);
            }
        }
        cout<<cnt<<"\n";
    }
    else{
        reverse(s.begin(),s.end());
           for (size_t i = 0; i < n; i++) {
               a[i] = ((s[i] - '0')*mul) % k;
               mul = (mul*10) % k;
           }
           ll int mod[k+2];
           memset(mod , 0, sizeof(mod));
           ll int prefix = 0;
           for (size_t i = 0; i < n; i++) {
               prefix += a[n-(i+1)];
               mod[ ((prefix % k) + k) % k ]++;
           }
           for (size_t i = 0; i < k; i++) {
               if(mod[i] > 1){
                   cnt += ((ll)mod[i]*(mod[i]-1))/2;
               }
           }
           cnt += mod[0];
           cout<<cnt<<"\n";
       }

    return 0;

}


Compiler output:
a.cc: In function 'int main()':
a.cc:34:38: error: expected ')' before '{' token
   34 |             if((s[i] == '0' % k == 0){
      |               ~                      ^
      |                                      )
a.cc:37:9: error: expected primary-expression before '}' token
   37 |         }
      |         ^
Language: C++

#include <bits/stdc++.h>
#include <cstring>
#include <limits>
using namespace std;
#define ll long long int
#define lli long long int
#define fw(i, s, e) for (ll i = s; i < e; ++i)
#define fe(i, s, e) for (ll i = s; i <= e; ++i)
#define fb(i, e, s) for (ll i = e; i >= s; --i)
#define L(T)  \
    ll T;     \
    cin >> T; \
    while (T--)
#define FASTIO                   \
    ios::sync_with_stdio(false); \
    cin.tie(nullptr);            \
    cout.tie(nullptr);
#define mem(a, i) memset(a, i, sizeof(a))
#define ld long double
#define endl "\n"
#define in(P) \
    ll P;     \
    cin >> P;
int main()
{
    FASTIO
    {
        ll ans = 0;
        in(n);
        in(p);
        string s;
        cin >> s;
        vector<ll> cnt(p + 90);
        ll l = s.length();

        // if (p == 2)
        // {
        //     fw(i, 0, n)
        //     {
        //         if ((s[i] - '0') % 2 == 0)
        //         {
        //             ans += i + 1;
        //         }
        //     }
        // }
        // else if (p == 5)
        // {
        //     fw(i, 0, n)
        //     {
        //         if ((s[i] - '0') % 5 == 0)
        //             ans += i + 1;
        //     }
        // }
        else
        {
            ll suf = 0;
            cnt[suf]++;
            ll pot = 1;
            fb(i, l - 1, 0)
            {
                ll dig = s[i] - '0';
                suf = (suf + dig * pot) % p;
                pot = 10 * pot % p;
                ans += cnt[suf];
                cnt[suf]++;
            }
                }
        cout << ans << endl;
    }
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:54:9: error: 'else' without a previous 'if'
   54 |         else
      |         ^~~~
Language: Java

import java.io.PrintWriter;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {
    int N, P;
    int[] data;
    int[] powerOfTen;
    int[] invPowerOfTen;

    void solve(Scanner sc, PrintWriter pw) {
        N = sc.nextInt();
        P = sc.nextInt();
        data = new int[N];
        powerOfTen = new int[N + 1];
        invPowerOfTen = new int[N + 1];
        String str = sc.next();
        for (int i = 0; i < str.length(); i++) {
            data[i] = str.charAt(i) - '0';
        }
        powerOfTen[0] = 1;
        for (int i = 1; i <= N; i++) {
            powerOfTen[i] = (powerOfTen[i - 1] * 10) % P;
        }
        invPowerOfTen[0] = 1;
        for (int i = 1; i <= N; i++) {
            invPowerOfTen[i] = power(powerOfTen[i], P - 2);
        }
        pw.println(solve(0, N));
    }

    private int power(int v, int p) {
        if (p == 0) {
            return 1;
        }
        int part = power(v, p / 2);
        int candidate = (part * part) % P;
        int multiply = (p % 2) == 0 ? 1 : v;
        return (multiply * candidate) % P;
    }

    private long solve(int left, int right) {
        if (left + 1 == right) {
            return data[left] % P == 0 ? 1 : 0;
        }


        int mid = left + (right - left) / 2;
        long partial = solve(left, mid) + solve(mid, right);
        int leftStart = mid - 1;
        int currentLeft = 0;
        Map<Integer, Integer> occurs = new HashMap<>();
        while (leftStart >= left) {
            int len = mid - leftStart;
            currentLeft = (((data[leftStart] * powerOfTen[len - 1]) % P) + currentLeft) % P;
            occurs.put(currentLeft, occurs.getOrDefault(currentLeft, 0) + 1);
            leftStart--;
        }

        long result = 0;
        int rightStart = mid;
        int currentRight = 0;
        while (rightStart < right) {
            currentRight = (data[rightStart] + currentRight * 10) % P;
            int lenRight = rightStart - mid + 1;
            int matchLeft;
            if (P == 2 || P == 5) {
                matchLeft = 0;
            } else {
                 matchLeft = (P - ((invPowerOfTen[lenRight] * currentRight) % P)) % P
            }
            result += occurs.getOrDefault(matchLeft, 0);
            rightStart++;
        }
//        System.out.println(String.format("left:%d right:%d partial:%d result:%d", left, right, partial, result));
        return result + partial;
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        PrintWriter pw = new PrintWriter(System.out);
        new Main().solve(sc, pw);
        pw.flush();
        pw.close();
        sc.close();
    }
}


Compiler output:
Main.java:71: error: ';' expected
                 matchLeft = (P - ((invPowerOfTen[lenRight] * currentRight) % P)) % P
                                                                                     ^
1 error