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

#include<iostream>
using namespace std;
int main()
{
  
  int N,Q;
  cin >> N >> Q;
//  N = 20000;
//  Q = 20000;
//  string s(20000,'A');
  cin >> s;
  int rb[N];
  for( int i=0; i<N; i++ ) {
    rb[i] = 1;
  }
  int count = 0;
  for( int i=0; i<Q; i++ ) {
//    for( int ii=0;ii<N;ii++ ) {
//      cout << rb[ii];
//    }
//    cout << endl;
    string t, d;
    cin >> t >> d;
//    t = 'A';
//    d = 'L';
//    cout << count << endl;
    if( d[0] == 'L' ){
      for( int j=0;j<N-1;j++) {
        if( s[j] == t[0] ) {
          if( j==0 ) {
            count+= rb[0];
          } else {
            rb[j-1] += rb[j];
          }
          rb[j] = 0;
        }
      }
    } else {
      for( int j=N-1;j>=0;j--) {
        if( s[j] == t[0] ) {
          if( j==N-1 ) {
            count+= rb[N-1];
          } else {
            rb[j+1] += rb[j];
          }
          rb[j] = 0;
        }
      }
    }
  }
	// 出力
    cout << (N-count) << endl;
    return 0;
}

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

#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int main(){
  int n,q;
  char t[200000],d[200000];
  string s;
  cin>>n>>q>>s;
  rep(i,q) cin>>t[i]>>d[i];
  int z=0,p=0;
  for(int i=n-1;i>=0;i--){
    if(t[i]==s[p]&&d[i]=='L') p++;
    if(t[i]==s[p-1]&&d[i]=='R') {
      if(z<p) z=p;
      p=0;
    }
  }
  int a=n-1,p=n-1;
  rep(i,n){
    if(t[i]==s[p]&&d[i]=='R') p--;
    if(t[i]==s[p+1]&&d[i]=='L') {
      if(a>p) a=p;
      p=0;
    }
  }
  a=n-1-a;
  cout<<a+z;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:18:13: error: redeclaration of 'int p'
   18 |   int a=n-1,p=n-1;
      |             ^
a.cc:10:11: note: 'int p' previously declared here
   10 |   int z=0,p=0;
      |           ^
Language: C

#include<stdio.h>
	
int main()
{
   int n,q,i,j,k,l;
   int flag[10000];
   int fflag[2000];
   char  s[2000];
   char  t[1];
   char  d[1];
   scanf("%d%d",&n,&q);
   scanf("%s",s);
  /* printf("%s\n",s);*/
   for(j<=0;j<=n-1;j++)
   {
   	flag[j]=1;
   }
   for(i=1;i<=q;i++)
   {
   	   scanf("%1s %1s",t,d);
   	  /* printf("%s\n",t);*/
   	   if(d[0]=='R')
   	   {
   	   	l=-1;
   	   	}
   	   	else
   	   	{
   	   		l=1;


Compiler output:
main.c: In function 'main':
main.c:28:25: error: expected declaration or statement at end of input
   28 |                         l=1;
      |                         ^
main.c:28:25: error: expected declaration or statement at end of input
main.c:28:25: error: expected declaration or statement at end of input
Language: C++

#include<iostream>
#include<vector>
using namespace std;
 
int main(){
 
  int N,Q;
  string s;//s.size() == N
  char t_temp,d_temp;
  cin >> N >> Q >> s;
  string t,d;
  t.resize(Q+1);
  d.resize(Q+1);
  int Golem[200001]={};
  int GolemSum = N;
 
  for(int trial=0; trial<Q; trial++){
    cin >> t_temp >> d_temp;
    t[trial]=t_temp;
    d[trial]=d_temp;
    //cout<<"this is debug"<<t<<" "<<d<<endl;
 
    for(int posIndex=0; posIndex<N; posIndex++){
      if(trial == 0) Golem[posIndex] += 1;
      if(s[posIndex] != t[trial]) continue;
      if(Golem[posIndex] == 0) continue;
      else{
	if(d[trial] == 'L'){   
	  if(posIndex == 0){
	    GolemSum -= Golem[posIndex];
	    Golem[posIndex]=0;
	  }
	  else{
	    Golem[posIndex-1] += Golem[posIndex];
	    Golem[posIndex] = 0;
	  }
	}else if(d[trial] == 'R'){
	  if(posIndex == N-1){
	    GolemSum -= Golem[posIndex];
	    Golem[posIndex]=0;
	  }
	  else{
	    Golem[posIndex+1] += Golem[posIndex];
	    Golem[posIndex] = 0;
	  }
	}
      }
    }//end of posIndex loop
  }//end of trial loop
  cout << GolemSum << endl;
  return 0;
}
#include<iostream>
#include<vector>
using namespace std;

int main(){

  int N,Q;
  string s;//s.size() == N
  char t_temp,d_temp;
  cin >> N >> Q >> s;
  string t,d;
  t.resize(Q+1);
  d.resize(Q+1);
  int Golem[200001]={};
  int GolemSum = N;

  for(int trial=0; trial<Q; trial++){
    cin >> t_temp >> d_temp;
    t[trial]=t_temp;
    d[trial]=d_temp;
    //cout<<"this is debug"<<t<<" "<<d<<endl;

    for(int posIndex=0; posIndex<N; posIndex++){
      if(trial == 0) Golem[posIndex] += 1;
      if(s[posIndex] != t[trial]) continue;
      if(Golem[posIndex] == 0) continue;
      else{
	if(d[trial] == 'L'){   
	  if(posIndex == 0){
	    GolemSum -= Golem[posIndex];
	    Golem[posIndex]=0;
	  }
	  else{
	    Golem[posIndex-1] += Golem[posIndex];
	    Golem[posIndex] = 0;
	  }
	}else if(d[trial] == 'R'){
	  if(posIndex == N-1){
	    GolemSum -= Golem[posIndex];
	    Golem[posIndex]=0;
	  }
	  else{
	    Golem[posIndex+1] += Golem[posIndex];
	    Golem[posIndex] = 0;
	  }
	}
      }
    }//end of posIndex loop
  }//end of trial loop
  cout << GolemSum << endl;
  return 0;
}


Compiler output:
a.cc:57:5: error: redefinition of 'int main()'
   57 | int main(){
      |     ^~~~
a.cc:5:5: note: 'int main()' previously defined here
    5 | int main(){
      |     ^~~~
Language: C

#include <stdio.h>
#include <stdlib.h>
 
typedef char                SINT8;
typedef unsigned char       UINT8;
typedef short               SINT16;
typedef unsigned short      UINT16;
typedef int                 SINT32;
typedef unsigned int        UINT32;
typedef long long           SINT64;
typedef unsigned long long  UINT64;
 
#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))
 
 
SINT32 main() {
    SINT32 n,q;
    scanf("%d%d",&n,&q);
 
 
    SINT32 kazu[200001] = {1};
    SINT8 s[200001] = {'0'};
 
    SINT8 t[200001] = {'0'};
    SINT8 d[200001] = {'0'};
 
    scanf("%s",s);
 
    for (SINT32 i = 0; i < q; i++) {
        scanf("%s%s",&t[i],&d[i]);
 
    }
 
    SINT32 count = 0;
    for (SINT32 i = q-1; i >= 0; i--) {
        if (d[i] == 'L') {
            if (s[count] == t[i]) {
                count++;
            }
        }
    }
    SINT32 buf = count;
    for (SINT32 i = 0; i < buf; i--) {
        if (d[i] == 'R') {
            if (s[count] == t[i]) {
                count--;
            }
        }
    }
 
    SINT32 count2 = 0;
    for (SINT32 i = q-1; i >= 0; i--) {
        if (d[i] == 'R') {
            if (s[n-1-count2] == t[i]) {
                count2++;
            }
        }
    }
    SINT32 buf = count2;
    for (SINT32 i = 0; i < buf; i--) {
        if (d[i] == 'L') {
            if (s[n-1-count2] == t[i]) {
                count--;
            }
        }
    }
 
 
 
 
 
    printf("%d\n",n-count-count2);
	return 0;
}

Compiler output:
main.c: In function 'main':
main.c:61:12: error: redefinition of 'buf'
   61 |     SINT32 buf = count2;
      |            ^~~
main.c:44:12: note: previous definition of 'buf' with type 'SINT32' {aka 'int'}
   44 |     SINT32 buf = count;
      |            ^~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int main(){
  int n,q,t[200000],d[200000];
  string s;
  cin>>n>>q>>s;
  rep(i,q) cin>>t[i]>>d[i];
  int z=0,p=0;
  for(int i=n-1;i>=0;i--){
    if(t[i]==s[p]&&d[i]=='L') p++;
    if(t[i]==s[p-1]&&d[i]=='R') {
      if(z<p) z=p;
      p=0;
    }
  }
  int a=n-1,p=n-1;
  rep(i,n){
    if(t[i]==s[p]&&d[i]=='L') p--;
    if(t[i]==s[p+1]&&d[i]=='R') {
      if(a>p) a=p;
      p=0;
    }
  }
  a=n-1-a;
  cout<<a+z;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:17:13: error: redeclaration of 'int p'
   17 |   int a=n-1,p=n-1;
      |             ^
a.cc:9:11: note: 'int p' previously declared here
    9 |   int z=0,p=0;
      |           ^
Language: Java

import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int Q = sc.nextInt();
		String s = sc.next();

		int[] golem = new int[N];
		for(int i = 0;i<N;i++) {
			golem[i] = 1;
		}

		for(int i = 0;i<Q;i++) {
			String t = sc.next();
			String d = sc.next();
			int[] box = new int[N];
			for(int j = 0;j<N;j++) {
				if(s.charAt(j) == t.charAt(0) && golem[j] > 0) {
					if(d.charAt(0) == 'L') {
						if(j != 0) {
							box[j-1]+=golem[j];
						}
						box[j]-=golem[j];
					} else {
						if(j != N-1) {
							box[j+1]+=golem[j];
						}
						box[j]-=golem[j];
					}
				}
			}
			for(int j = 0;j<N;j++) {
				golem[j] += box[j];
			}
			int count = 0;
			for(int i = 0;i<N;i++) {
				count+=golem[i];
			}
			if(count==0) break;
		}



		int count = 0;
		for(int i = 0;i<N;i++) {
			count+=golem[i];
		}

		System.out.println(count);
	}

}


Compiler output:
Main.java:39: error: variable i is already defined in method main(String[])
			for(int i = 0;i<N;i++) {
			        ^
1 error
Language: C++

#include <iostream>
using namespace std;

int main(){
  int N,Q;
  cin >> N >> Q;
  cin >>const string s;
  char qs[N];
  char ds[N];

  int g[N];
	int vanish=0;

  for(int i=0;i<N;i++){
      g[i]=1;
  }
  for(int i=0;i<Q;i++){
   cin >> qs[i] >> ds[i];
  }

  for(int j=0;j<Q;j++){
      
		int i=0;
		if(qs[j]==s[i]){
		if(ds[j]=='L'){
			vanish+=g[i];
			g[i]=0;
		}
		else{
			g[i+1]+=g[i];
			g[i]=0;
		}
		}

		if(ds[j]=='L'){
    	for(int i=1;i<N-1;i++){
     	  if(qs[j]==s[i]){
					g[i-1]+=g[i];
					g[i]=0;
				}
			}
		}
		else{
    for(int i=1;i<N-1;i++){
      if(qs[j]==s[i]){
					g[i+1]+=g[i];
					g[i]=0;
				}
			}
		}

		i=N-1;
		if(s[i]==qs[j]){
		if(ds[j]=='L'){
			g[i-1]+=g[i];
			g[i]=0;
		}
		else if(ds[j]=='R'){
			vanish+=g[i];
			g[i]=0;
		}
		}
        if(vanish>=N){
break;
}
	}

  int gn=N-vanish;
	cout << gn;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:7:9: error: expected primary-expression before 'const'
    7 |   cin >>const string s;
      |         ^~~~~
a.cc:24:27: error: 's' was not declared in this scope
   24 |                 if(qs[j]==s[i]){
      |                           ^
a.cc:37:21: error: 's' was not declared in this scope
   37 |           if(qs[j]==s[i]){
      |                     ^
a.cc:45:17: error: 's' was not declared in this scope
   45 |       if(qs[j]==s[i]){
      |                 ^
a.cc:53:20: error: 's' was not declared in this scope
   53 |                 if(s[i]==qs[j]){
      |                    ^
Language: C++

#include<iostream>
#include<string>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
	long long N, Q;
	cin >> N >> Q;
	string S;
	cin >> S;
	long long i, j, k;
	vector<char> T;
	vector<char> D;
	for (i = 0; i < Q; i++) {
		char t, d;
		cin >> t >> d;
		T.push_back(t);
		D.push_back(d);
	}
	reverse(T.begin(), T.end());
	reverse(D.begin(), D.end());
	//まずは左にはみ出す上限を検討
	long long L_depth = 0;
	i = 0;
	while (i < Q) {
		if (S.at(L_depth) == T.at(i) && D.at(i) == 'L') {
			L_depth++;
		}
		else if (S.at(L_depth) == T.at(i) && D.at(i) == 'R'&&L_depth != 0) {
			//break;
		}
		i++;
	}
	long long R_depth = N - 1;
	i = 0;
	while (i < Q) {
		if (S.at(R_depth) == T.at(i) && D.at(i) == 'R') {
			R_depth--;
		}
		else if (S.at(R_depth) == T.at(i) && D.at(i) == 'L' && R_depth != N - 1) {
			//break;
		}
		i++;
	}
	long long zero = 0;
	cout << max(R_depth - L_depth + 1,zero);

Compiler output:
a.cc: In function 'int main()':
a.cc:46:49: error: expected '}' at end of input
   46 |         cout << max(R_depth - L_depth + 1,zero);
      |                                                 ^
a.cc:6:12: note: to match this '{'
    6 | int main() {
      |            ^
Language: C

#include<stdio.h>
#include<string.h>
int max(int a, int b)
{
    if (a > b)
        return a;
    else
        return b;
}
int main()
{
    int n, q;
    scanf("%d %d", &n, &q);
    char s[200005];
    scanf("%s", s);
    if (n != strlen(s))
        for (;;)
            int k;
    int i;
    char t[200005], d[200005];
    for (i = 1; i <= q; i++)
    {
        scanf("%c", &t[q]);
        while (t[i]<'A' || t[i]>'Z')
            scanf("%c", &t[i]);
        scanf("%c", &d[i]);
        while (d[i]<'A' || d[i]>'Z')
            scanf("%c", &d[i]);
    }
    int l, r;
    l = 0;
    r = n - 1;
    for (i = q; i > 0; i--)
    {
        if (d[i] == 'R')
        {
            if (t[i] == s[r])
                r--;
        }
        else
        {
            if (t[i] == s[l])
                l++;
        }
        if (r < 0 || l >= n)
            break;
    }
    printf("%d\n", max(0, r - l + 1));
    return 0;
}

Compiler output:
main.c: In function 'main':
main.c:18:13: error: expected expression before 'int'
   18 |             int k;
      |             ^~~
Language: Java

import java.util.Scanner;

/**
 *
 * @author cs18097
 */
public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        Scanner sc = new Scanner(System.in);
        int menber = sc.nextInt();
        int change = sc.nextInt();
        String mapcode = sc.next();
        String[] map = mapcode.split("");
        String[] magic = new String[change * 2];
        int[] golem = new int[menber];
        int count = 0;
        for (int n = 0; n < menber; n++) {
            golem[n] = 1;
        }
        for (int i = 0; i < change * 2; i++) {
            magic[i] = sc.next();
        }

        for (int s = 0; s < change; s++) {//魔法の回数
            for (int t = 0; t < menber; t++) {//ゴーレムの場所について
                if (map[t].equals(magic[s * 2])) {//魔法の指示とマップの文字が同じとき
                    if ("L".equals(magic[s * 2 + 1])) {
                        if (t == 0) {
                            count += golem[0];
                            golem[0] = 0;
                        }
                        if (t != 0) {
                            golem[t - 1] += golem[t];
                        }

                    } else if ("R".equals(magic[s * 2 + 1])) {

                        if (t == menber) {
                            count += golem[0];
                            golem[menber - 1] = 0;

                        }
                        if (t != menber - 1) {
                            golem[t + 1] += golem[t];
                        }

                    }
                    golem[t] = 0;
                }
            }
        }

        System.out.print(menber-

Compiler output:
Main.java:58: error: reached end of file while parsing
        System.out.print(menber-
                                ^
1 error
Language: C++

#define BOX_MAX (200000)

static void C_SnukeTheWizard();

int main()
{
	C_SnukeTheWizard();

	return 0;
}

static void C_SnukeTheWizard()
{
	int N = 0, Q = 0;
	int sum = 0;
	char t = 0, d = 0, cr = 0;
	
	static int gorem[BOX_MAX] = { 0 };
	static char s[BOX_MAX + 1] = { 0 };

	scanf("%d %d", &N, &Q);
	scanf("%s", s);


	for (int i = 0; i < N; i++) {
		gorem[i] = 1;
	}
	sum = N;

	for (int i = 0; i < Q; i++) {
		scanf(" %c %c", &t, &d);

		if (d == 'R') {
			
			if (s[N - 1] == t) {
				sum -= gorem[N - 1];
				gorem[N - 1] = 0;
			}
			
			for (int p = N - 2; p >= 0; p--) {
				if (s[p] == t) {
					gorem[p + 1] += gorem[p];
					gorem[p] = 0;
				}
			}
		}
		else {
			if (s[0] == t) {
				sum -= gorem[0];
				gorem[0] = 0;
			}
			
			for (int p = 1; p < N; p++) {
				if (s[p] == t) {
					gorem[p - 1] += gorem[p];
					gorem[p] = 0;
				}
			}
		}
	}


	printf("%d\n", sum);
	fflush(stdout);

	return;
}



Compiler output:
a.cc: In function 'void C_SnukeTheWizard()':
a.cc:21:9: error: 'scanf' was not declared in this scope
   21 |         scanf("%d %d", &N, &Q);
      |         ^~~~~
a.cc:63:9: error: 'printf' was not declared in this scope
   63 |         printf("%d\n", sum);
      |         ^~~~~~
a.cc:1:1: note: 'printf' is defined in header '<cstdio>'; this is probably fixable by adding '#include <cstdio>'
  +++ |+#include <cstdio>
    1 | #define BOX_MAX (200000)
a.cc:64:16: error: 'stdout' was not declared in this scope
   64 |         fflush(stdout);
      |                ^~~~~~
a.cc:64:16: note: 'stdout' is defined in header '<cstdio>'; this is probably fixable by adding '#include <cstdio>'
a.cc:64:9: error: 'fflush' was not declared in this scope
   64 |         fflush(stdout);
      |         ^~~~~~
Language: C++

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

const int MOD = (int)1e9+7;

int main(){
	int N,Q;
	string s;
	cin >> N >> Q >> s;
	vector<char> t(Q,'');
	vector<char> d(Q,'');
	for(int i=Q-1;i>=0;i--)	cin >> t.at(i) >> d.at(i);

	int left=-1;
	int right=N;
	for(int i=0;i<Q;i++){
		if(left+1<s.size() && t.at(i)==s.at(left+1) && d.at(i)=='L')	left++;
		if(right-1>=0 && t.at(i)==s.at(right-1) && d.at(i)=='R')	right--;
	}
	cout << max(0,right-left-1) << endl;
	
	return 0;
}


Compiler output:
a.cc:10:26: error: empty character constant
   10 |         vector<char> t(Q,'');
      |                          ^~
a.cc:11:26: error: empty character constant
   11 |         vector<char> d(Q,'');
      |                          ^~
Language: Java

import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        int a = sc.nextInt();
        int b = sc.nextInt();
        String c = sc.next();
        String[] strArray = new String[a];
        int[] golem = new int[a];
        String[] spell = new String[b * 2];

        int ans = 0;

        for(int i = 0; i < a ; i++){
            strArray[i] = String.valueOf(c.charAt(i));
            golem[i] = 1;
        }
        for(int j = 0; j < b * 2 ; j++){
            spell[j] = sc.next();
        }         
        
        for(int k = 0; k < spell.length ; k=K+2){
            for(int l = 0; l < strArray.length ; l++){
                if(spell[k].equals(strArray[l])){
                    if(spell[k].equals(strArray[0]) && spell[k+1].equals("L")){
                        golem[0] = 0;
                    }
                    else if(spell[k].equals(strArray[a-1]) && spell[k+1].equals("R")){
                        golem[a-1] = 0;
                    }
                    else if(spell[k+1].equals("R") && golem[l] > 0){
                        golem[l] = golem[l] - 1;
                        golem[l+1] = golem[l] + 1;
                    }
                    else if(spell[k+1].equals("L") && golem[l] > 0){
                        golem[l] = golem[l] - 1;
                        golem[l-1] = golem[l] + 1;
                    }
                }
            }
        }
        for(int cnt = 0; cnt < golem.length ; cnt++){
            ans = ans + golem[cnt];
        }
        System.out.println(ans);
        
    }
}

Compiler output:
Main.java:24: error: cannot find symbol
        for(int k = 0; k < spell.length ; k=K+2){
                                            ^
  symbol:   variable K
  location: class Main
1 error
Language: C++

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

int main (){

int N, Q;
string S;
cin >> N >> Q >> S;

for(int i=0;i<N;i++) 

int n[N] = 1;

vecter<vecter<char>> a(Q, vecter<char>(2));

for(int i=0;i<Q;i++){
cin >> a.at(i).at(0) >> a.at(i).at(1);
}
int ans = N;
for(int i=0;i<Q;i++){
for(int j=0;j<N;j++){
if(a.at(i).at(0) == S.at(j)){
if(a.at(i).at(1) == 'R'){
if(a.at(i).at(0) == S.at(N-1)){
ans -= n[N-1];
n[N-1] = 0;
}
else{
n[j+1] += n[j];
n[j] = 0;
}
}
else{
if(a.at(i).at(0) == S.at(0)){
ans -= n[0];
n[0] = 0;
}
else{
n[j-1] += n[j];
n[j] = 0;
}
}
}
}
cout << ans << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:12:12: error: array must be initialized with a brace-enclosed initializer
   12 | int n[N] = 1;
      |            ^
a.cc:14:1: error: 'vecter' was not declared in this scope
   14 | vecter<vecter<char>> a(Q, vecter<char>(2));
      | ^~~~~~
a.cc:14:15: error: expected primary-expression before 'char'
   14 | vecter<vecter<char>> a(Q, vecter<char>(2));
      |               ^~~~
a.cc:17:8: error: 'a' was not declared in this scope
   17 | cin >> a.at(i).at(0) >> a.at(i).at(1);
      |        ^
a.cc:22:4: error: 'a' was not declared in this scope
   22 | if(a.at(i).at(0) == S.at(j)){
      |    ^
a.cc:25:8: error: 'n' was not declared in this scope
   25 | ans -= n[N-1];
      |        ^
a.cc:29:1: error: 'n' was not declared in this scope
   29 | n[j+1] += n[j];
      | ^
a.cc:35:8: error: 'n' was not declared in this scope
   35 | ans -= n[0];
      |        ^
a.cc:39:1: error: 'n' was not declared in this scope
   39 | n[j-1] += n[j];
      | ^
a.cc:46:2: error: expected '}' at end of input
   46 | }
      |  ^
a.cc:4:12: note: to match this '{'
    4 | int main (){
      |            ^
Language: C++

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

#define ll long long

using namespace std;


 
int main(){

    int n,q;
    string s;

    int ex = 0;

    cin >> n >> q;
    cin >> s;

    vector<vector<int>> v;
    vector<ll> g;

    for(int i = 0; i < 27; i++){
        vector<int> tmpv;
        v.push_back(tmpv);
    }



    for(int i = 0; i < n; i++){
        v[s[i] - 64].push_back(i + 1);
        g.push_back(1);
    }

    //gを1オリジンにする
    g.push_back(1);

    for(int i = 0; i < q; i++){
        char t,d;
        //cin >> t >> d;
        scanf(" %c %c",t d);

        if(d == 'L'){

            for(int i = 0; i < v[t - 64].size(); i++){
                int tmp = (v[t-64])[i];
                if(tmp != 1){
                    g[tmp - 1] = g[tmp - 1] + g[tmp];
                    g[tmp] = 0;
                }else{
                    ex = ex + g[1];
                    g[1] = 0;
                }
            }
        }else{

            for(int i = 0; i < v[t - 64].size(); i++){
                int tmp = (v[t-64])[i];
                if(tmp != n){
                    g[tmp + 1] = g[tmp + 1] + g[tmp];
                    g[tmp] = 0;
                }else{
                     ex = ex + g[n];
                      g[n] = 0;
                }
            }
        }

    }

    cout << max(n - ex,0) << endl;

}


Compiler output:
a.cc: In function 'int main()':
a.cc:44:25: error: expected ')' before 'd'
   44 |         scanf(" %c %c",t d);
      |              ~          ^~
      |                         )
Language: C++

#include <iostream>
#include <vector>

using namespace std;


//const int INF{1001001001};
//const int MOD{(int)1e9 + 7};
//const double EPS{1e-9};
////const double PI{acos(-1)};
//const int dx[]{0, 1, 0, -1, 1, -1, 1, -1}, dy[]{1, 0, -1, 0, 1, -1, -1, 1};

typedef struct block {
    int golem_num;
    char word;
} Block;

typedef struct magic {
    string word;
    char LR;
} Magic;

vector<int> find_all(string str, string subStr);


vector<int> find_all(const string str, const string subStr) {
    vector<int> result;
    
    int subStrSize = (int)subStr.length();
    int pos = (int)str.find(subStr);
    
    while (pos != std::string::npos) {
        result.push_back(pos);
        pos = (int)str.find(subStr, pos + subStrSize);
    }
    
    return result;
}


int main(){
    int N,Q;
    string s;
    
    cin >> N;
    cin >> Q;
    cin >> s;
    
    Block block[N];
    for(int i=0; i < N; i++){
        block[i].golem_num = 1;
        block[i].word = {s[i]};
    }
    
    Magic magic[Q];
    
    for(int q=0; q < Q; q++){
        cin >> magic[q].word;
        cin >> magic[q].LR;
    }
    
    for(int q=0; q<Q; q++){
        string word = magic[q].word;
        char LR = magic[q].LR;
        
        vector<int> word_q = find_all(s, word);
        if(LR == 'L'){
            for(int i : word_q){
                if(i == 0){
                    block[i].golem_num = 0;
                }else{
                    block[i-1].golem_num += block[i].golem_num;
                    block[i].golem_num = 0;
                }
            }
        }else{
            reverse(word_q.begin(), word_q.end());
            for(int i : word_q){
                if(i == N-1){
                    block[i].golem_num = 0;
                }else{
                    block[i+1].golem_num += block[i].golem_num;
                    block[i].golem_num = 0;
                }
            }
        }
    }
    
    int sum = 0;
    for(int i=0; i < N; i++){
        sum += block[i].golem_num;
    }
    cout << sum << endl;
    return 0;
}


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

#include<vector>

using namespace std;

int main(){

  int N,Q;
  cin >> N >> Q;

  int a[N+2];
  a[0]=0;
  a[N+1]=0;
  for(int i=1;i<N+1;i++){
    a[i]=1;
  }
  
  char s[N+2];
  s[0]='e';
  s[N+1]='e';
  for(int i=1;i<N+1;i++){
    cin >> s[i];
  }

  char t[Q],q[Q];
  for(int i=0;i<Q;i++){
    cin >> t[i] >> q[i];
  }

  int end=0;
  for(int i=Q-1;i>=0;i--){
    if((t[i]==s[1]&&q[i]=='L')||(t[i]==s[N]&&q[i]=='R')){
      end=i+1;
      break;
    }
  }
  
  for(int i=0;i<end;i++){

    if(q[i]=='L'){
      for(int j=1;j<=N;j++){
	if(s[j]==t[i]){
	  a[j-1]+=a[j];
	  a[j]=0;
	}
      }
    }else{
      for(int j=N;j>=1;j--){
	if(s[j]==t[i]){
	  a[j+1]+=a[j];
	  a[j]=0;
	}
      }
    }

  }

  cout << N-a[0]-a[N+1] << endl;

  return 0;

}
  


Compiler output:
a.cc: In function 'int main()':
a.cc:8:3: error: 'cin' was not declared in this scope
    8 |   cin >> N >> Q;
      |   ^~~
a.cc:2:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
    1 | #include<vector>
  +++ |+#include <iostream>
    2 | 
a.cc:57:3: error: 'cout' was not declared in this scope
   57 |   cout << N-a[0]-a[N+1] << endl;
      |   ^~~~
a.cc:57:3: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:57:28: error: 'endl' was not declared in this scope
   57 |   cout << N-a[0]-a[N+1] << endl;
      |                            ^~~~
a.cc:2:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
    1 | #include<vector>
  +++ |+#include <ostream>
    2 |
Language: C++

#include <iostream>
#include <vector>

using namespace std;


//const int INF{1001001001};
//const int MOD{(int)1e9 + 7};
//const double EPS{1e-9};
////const double PI{acos(-1)};
//const int dx[]{0, 1, 0, -1, 1, -1, 1, -1}, dy[]{1, 0, -1, 0, 1, -1, -1, 1};

typedef struct block {
    int golem_num;
    char word;
} Block;

typedef struct magic {
    string word;
    char LR;
} Magic;

vector<int> find_all(const string str, const string subStr);


vector<int> find_all(const string str, const string subStr) {
    vector<int> result;
    
    int subStrSize = subStr.size();
    int pos = str.find(subStr);
    
    while (pos != std::string::npos) {
        result.push_back(pos);
        pos = str.find(subStr, pos + subStrSize);
    }
    
    return result;
}


int main(){
    int N,Q;
    string s;
    
    cin >> N;
    cin >> Q;
    cin >> s;
    
    Block block[N];
    for(int i=0; i < N; i++){
        block[i].golem_num = 1;
        block[i].word = {s[i]};
    }
    
    Magic magic[Q];
    
    for(int q=0; q < Q; q++){
        cin >> magic[q].word;
        cin >> magic[q].LR;
    }
    
    for(int q=0; q<Q; q++){
        string word = magic[q].word;
        char LR = magic[q].LR;
        
        vector<int> word_q = find_all(s, word);
        if(LR == 'L'){
            for(int i : word_q){
                if(i == 0){
                    block[i].golem_num = 0;
                }else{
                    block[i-1].golem_num += block[i].golem_num;
                    block[i].golem_num = 0;
                }
            }
        }else{
            reverse(word_q.begin(), word_q.end());
            for(int i : word_q){
                if(i == N-1){
                    block[i].golem_num = 0;
                }else{
                    block[i+1].golem_num += block[i].golem_num;
                    block[i].golem_num = 0;
                }
            }
        }
    }
    
    int sum = 0;
    for(int i=0; i < N; i++){
        sum += block[i].golem_num;
    }
    cout << sum << endl;
    return 0;
}


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

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

int main(){
    int n, q, cnt[200001], ans;
    string s;
    char t, d;
    cin >> n >> q;
    for(int i = 0; i < n; i++){
        cnt[i] = 1;
    }
    cin >> s;
    ans = n;
    for(int i = 0; i < q; i++){
        cin >> t >> d;
        for(int j = 0; j < n; j++){
            if(s[j] == t){
                if(d == 'L'){
                    if(j == 0){
                        ans -= cnt[j]
                        cnt[j] -= cnt[j];
                    } else{
                        cnt[j - 1] += cnt[j];
                        cnt[j] -= cnt[j];
                    }
                } else {
                    if(j == n - 1){
                        ans -= cnt[j];
                        cnt[j] -= cnt[j];
                    } else{
                        cnt[j + 1] += cnt[j];
                        cnt[j] -= cnt[j];
                    }
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:20:38: error: expected ';' before 'cnt'
   20 |                         ans -= cnt[j]
      |                                      ^
      |                                      ;
   21 |                         cnt[j] -= cnt[j];
      |                         ~~~
Language: C++

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

int main() {
int N;
  int Q;
  cin >> N >> Q;
  int ans=N;
  vector<int> vec(N);
    string S;
   cin >> S;

  for(int i=0; i<N; i++){
    vec.at(i) = 1 ;
  }
  
 for(int i=0; i<Q; i++){
   char ti;
   char di;
   cin >> ti >> di;
     if( (S.at(0) == ti) & (di == 'L')){
       ans = ans - vec.at(0);
         vec.at(0) = 0;
     }
     if( (S.at(0) == ti) & (di == 'R')){
         vec.at(1) = ( vec.at(1) + vec.at(0) );
       vec.at(0) = 0;
     }
     if( (S.at(N - 1) == ti) & (di == 'R')){
       ans = ans - vec.at(N-1);
       vec.at(N - 1) = 0;
     }
      if( (S.at(N - 1) == ti) & (di == 'L')){
       vec.at(N - 2) = ( vec.at(N - 1) + vec.at(N-2) );
     ​  vec.at(N - 1) =0; 
     }
      for (int j=1; j<(N-1); j++){
        if( (S.at(j) == ti) & (di == 'R')){
          vec.at(j+1) = ( vec.at(j+1) + vec.at(j) );
          vec.at(j)=0;
        }
         if( (S.at(j) == ti) & (di == 'L')){
          vec.at(j-1) = ( vec.at(j-1) + vec.at(j) );
          vec.at(j)=0;
        }
      }
 }
  cout << ans << endl;
        
}


Compiler output:
a.cc: In function 'int main()':
a.cc:35:6: error: '\U0000200b' was not declared in this scope
   35 |      ​  vec.at(N - 1) =0;
      |
Language: C++

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

int main()
{
	int N,Q;
	int ans;
	string s;
	char t,d;
	
	cin >> N >> Q;
	cin >> s;
	vector<int> sin(N,1);
	
	for (int i = 0; i < Q; i++){
		cin >> t >> d;
		if (d == 'L'){
			for (int j = 0; j < N; j++){
				if (s.at(j) == t){
					if (j){
						sin.at(j-1) = sin.at(j - 1) + sin.at(j);
						sin.at(j) = 0;
					}else{
						sin.at(j) = 0;
					}
				}
			}
		}else if (d == 'R'){
			for (int j = 0; j < N; j++){
				if (s.at(N - 1 - j) == t){
					if (j){
						sin.at (N - j) = sin.at(N - j) + sin.at(N - j - 1);
						sin.at(N - j - 1) = 0;
					}else{
						sin.at(N - 1) = 0;
					}
				}
			}
		}

	ans = 0;
	for ( int i = 0; i < N; i++){
		ans = ans + sin.at(i);
	}

	cout << ans << endl;

	return 0;
}

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

#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<string>
#include<queue>
#include<functional>
#include<limits.h>
#include<string.h>
#include<stack>
#include<list>
#include<deque>
#define int long long
#define mod 1000000007
using namespace std;

char a[300000], b[300000];
signed main() {
	int n, q; cin >> n >> q;
	string s; cin >> s;
	for (int i = 0; i < q; i++)cin >> a[i] >> b[i];
	int l = -1, r = n-1;
	while (r-l>1)
	{
		int t = (l + r) / 2; int u = t;
		for (int i = 0; i < q; i++) {
			if (s[t] == a[i]) {
				if (b[i] == 'L')t--;
				else t++;
				if (t < 0)break;
				if (t >= n) {
					r = u; goto k;
				}
			}
			if (i + 1 == q) {
				r = u; goto k;
			}
		}
		l = u;
	k:;
	}
	int ans = r;
	reverse(s.begin(), s.end());
	l = -1, r = n - 1;
	while (r - l>1)
	{
		int t = (l + r) / 2; int u = t;
		for (int i = 0; i < q; i++) {
			if (s[t] == a[i]) {
				if (b[i] == 'R')t--;
				else t++;
				if (t < 0)break;
				if (t >= n) {
					r = u; goto k;
				}
			}
			if (i + 1 == q) {
				r = u; goto w;
			}
		}
		l = u;
	w:;
	}
	cout << n - ans - r << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:40:9: error: jump to label 'k'
   40 |         k:;
      |         ^
a.cc:54:53: note:   from here
   54 |                                         r = u; goto k;
      |                                                     ^
a.cc:25:42: note:   skips initialization of 'long long int u'
   25 |                 int t = (l + r) / 2; int u = t;
      |                                          ^
a.cc:25:21: note:   skips initialization of 'long long int t'
   25 |                 int t = (l + r) / 2; int u = t;
      |                     ^
Language: C++

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

#define ll long long

using namespace std;


 
int main(){

    int n,q;
    string s;

    int ex = 0;

    cin >> n >> q;
    cin >> s;

    vector<vector<int>> v;
    vector<ll> g;

    for(int i = 0; i < 27; i++){
        vector<int> tmpv;
        v.push_back(tmpv);
    }



    for(int i = 0; i < n; i++){
        v[s[i] - 64].push_back(i + 1);
        g.push_back(1);
    }

    //gを1オリジンにする
    g.push_back(1);

    


    for(int i = 0; i < q; i++){
        char t,d;
        //cin >> t >> d;
        scanf(" %c %c",&t &d);

        if(d == 'L'){

            for(auto itr = v[t - 64].begin(); itr != v[t - 64].end(); itr++){
                int tmp = *itr;
                if(tmp != 1){
                    g[tmp - 1] = g[tmp - 1] + g[tmp];
                    g[tmp] = 0;
                }else{
                    ex = ex + g[1];
                    g[1] = 0;
                }
            }
        }else{

            for(auto itr = v[t - 64].begin(); itr != v[t - 64].end(); itr++){
                int tmp = *itr;
                if(tmp != n){
                    g[tmp + 1] = g[tmp + 1] + g[tmp];
                    g[tmp] = 0;
                }else{
                     ex = ex + g[n];
                      g[n] = 0;
                }
            }
        } 

        for(int i = 1; i < n + 1; i++){
            cerr << g[i];
        }
        cerr << endl;

    }

    cout << max(n - ex,0) << endl;

}


Compiler output:
a.cc: In function 'int main()':
a.cc:47:27: error: invalid operands of types 'char*' and 'char' to binary 'operator&'
   47 |         scanf(" %c %c",&t &d);
      |                        ~~ ^~
      |                        |   |
      |                        |   char
      |                        char*
Language: C++

#include <bits/stdc++.h>
using namespace std;
using ll=long long;
int main(){
    int n,q;
    cin>>n>>q;
    string s;
    cin>>s;
    int t[200010],d[200010];
    for(int i=0;i<q;i++)cin>>t[i]>>d[i];
    char memo1[30];
    int memo2[30];
    for(int i=0;i<26;i++){
        memo1[i]="0";
        memo2[i]=0;
    }
    for(int i=0;i<q;i++){
        for(int j=0;j<30;j++){
            if(memo1[j]=="0"){
                memo1=t[i];
                if(d[i]=="L")memo2++;
                else memo2--;
                break;
            }
            else if(memo1[j]==t[i]){
                if(d[i]=="L")memo2++;
                else memo2--;
                break;
            }
        }
    }
    int count=0;
    for(int i=0;i<30;i++){
        if(memo2[i]>)
    }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:14:18: error: invalid conversion from 'const char*' to 'char' [-fpermissive]
   14 |         memo1[i]="0";
      |                  ^~~
      |                  |
      |                  const char*
a.cc:19:24: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   19 |             if(memo1[j]=="0"){
      |                ~~~~~~~~^~~~~
a.cc:20:22: error: incompatible types in assignment of 'int' to 'char [30]'
   20 |                 memo1=t[i];
      |                 ~~~~~^~~~~
a.cc:21:24: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   21 |                 if(d[i]=="L")memo2++;
      |                    ~~~~^~~~~
a.cc:21:30: error: lvalue required as increment operand
   21 |                 if(d[i]=="L")memo2++;
      |                              ^~~~~
a.cc:22:22: error: lvalue required as decrement operand
   22 |                 else memo2--;
      |                      ^~~~~
a.cc:26:24: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   26 |                 if(d[i]=="L")memo2++;
      |                    ~~~~^~~~~
a.cc:26:30: error: lvalue required as increment operand
   26 |                 if(d[i]=="L")memo2++;
      |                              ^~~~~
a.cc:27:22: error: lvalue required as decrement operand
   27 |                 else memo2--;
      |                      ^~~~~
a.cc:34:21: error: expected primary-expression before ')' token
   34 |         if(memo2[i]>)
      |                     ^
a.cc:35:5: error: expected primary-expression before '}' token
   35 |     }
      |     ^
Language: Java

import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int Q = sc.nextInt();
		String s = sc.next();
		
		int [] a = new int[N];
		
		for (int i = 0; i < N; i++) {
			a[i] = 1;

		}
	
		String t;
		String LR;
		String L ="L";
		int move = 0;
		char tt;
		for (int i = 0; i < Q; i++) {
			t = sc.next();
			LR = sc.next();
			tt = t.charAt(0);
			if ( LR.contentEquals(L))
				move = -1;
			else move = 1;		
			if (s.charAt(0) == tt && move == -1)
				a[0] = 0;
			if (s.charAt(N-1) == tt && move == 1)
				a[N-1] = 0;
			for (int j = 1; j < N-1; j++) {
				if (a[j]!= 0) {
				if (s.charAt(j) == tt) {
					a[j + move] += a[j];
					a[j] = 0;
				}
				}
			}
		}
		int sum = 0;
		for( int i=0; i<N; i++ ) {
            sum += a[i];
		}
		System.out.println(sum);
	}

Compiler output:
Main.java:48: error: reached end of file while parsing
	}
	 ^
1 error
Language: C++

    #include <bits/stdc++.h>
    using namespace std;
    int main() {
      int n,q;
      cin >> n>>q;
      
      string str;
      cin >>str;
      
      vector<int> num(n,1);
      
      char name,dir;
      
      for(int i=0;i<q;i++){
        cin >>name >>dir;
        
        for(int j=0;j<n;j++){
          if(str.at(j)==name&&dir=='L'){
            if(j!=0)
             num[j-1]+=num[j];
            num[j]=0;
          }else(str.at(j)==name&&dir=='R'){
            if(j!=n-1)
             num[j+1]+=num[j];
            num[j]=0;
          }
        }
      }
      int sum=0;
      for(int i=0;i<n;i++){
        sum+=num[i];
      }
      cout << sum << endl;
    }

Compiler output:
a.cc: In function 'int main()':
a.cc:22:43: error: expected ';' before '{' token
   22 |           }else(str.at(j)==name&&dir=='R'){
      |                                           ^
      |                                           ;
Language: C++

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

int main() {
  int n, q;
  string s;
  cin >> n >> q >> s;
  
  vector<int> strMap[100];
  int golems[n];
  for (int i = 0; i < n; i++) {
    strMap[(int) s[i]].push_back(i);
    golems[i] = 1;
  }
  
  for (int i = 0; i < q; i++) {
    char t, d;
    cin >> t >> d;
    
    if (d == 'L' && j > 0)
      for (int j : strMap[(int) t])
      	golems[j - 1] += golems[j];

    if (d == 'R' && j < n - 1)
      for (int j : strMap[(int) t])
      	golems[j + 1] += golems[j];

    for (int j : strMap[(int) t])
      golems[j] = 0;
  }
  
  int sum = 0;
  for (int i = 0; i < n; i++)
    sum += golems[i];
  
  cout << sum << endl;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:21:21: error: 'j' was not declared in this scope
   21 |     if (d == 'L' && j > 0)
      |                     ^
a.cc:25:21: error: 'j' was not declared in this scope
   25 |     if (d == 'R' && j < n - 1)
      |                     ^
Language: C++

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

int main()
{
        int N, Q;
        int i, j;
        char *s;
        char *t, *d;
        int *NumOfGolem;
        int total = 0;

        scanf("%d", &N);
        scanf("%d", &Q);

        s = malloc(N+1);
        scanf("%s", s);

        t = malloc(Q);
        d = malloc(Q);
        for(i = 0; i < Q; i++) {
                scanf("%c", &t[i]);
                scanf("%c", &t[i]);
                scanf("%c", &d[i]);
                scanf("%c", &d[i]);
        }

        NumOfGolem = malloc(N);
        for(i = 0; i < N; i++) {
                NumOfGolem[i] = 1;
        }

        for(i = 0; i < Q; i++) {
                for(j = 0; j < N; j++) {
                        if(NumOfGolem[j] > 0 && s[j] == t[i]) {
                                if(d[i] == 'L') {
                                        if(j > 0) {
                                                NumOfGolem[j-1] = NumOfGolem[j-1] + NumOfGolem[j];
                                                NumOfGolem[j] = 0;
                                        } else {
                                                NumOfGolem[j] = 0;
                                        }
                                } else if (d[i] == 'R') {
                                        if(j < (N-1)) {
                                                NumOfGolem[j+1] = NumOfGolem[j+1] + NumOfGolem[j];
                                                NumOfGolem[j] = 0;
                                        } else {
                                                NumOfGolem[j] = 0;
                                        }
                                }
                        }
                }
        }

        for(i = 0; i < N; i++) {
                total += NumOfGolem[i];
        }

        printf("%d\n", total);

        return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:16:19: error: invalid conversion from 'void*' to 'char*' [-fpermissive]
   16 |         s = malloc(N+1);
      |             ~~~~~~^~~~~
      |                   |
      |                   void*
a.cc:19:19: error: invalid conversion from 'void*' to 'char*' [-fpermissive]
   19 |         t = malloc(Q);
      |             ~~~~~~^~~
      |                   |
      |                   void*
a.cc:20:19: error: invalid conversion from 'void*' to 'char*' [-fpermissive]
   20 |         d = malloc(Q);
      |             ~~~~~~^~~
      |                   |
      |                   void*
a.cc:28:28: error: invalid conversion from 'void*' to 'int*' [-fpermissive]
   28 |         NumOfGolem = malloc(N);
      |                      ~~~~~~^~~
      |                            |
      |                            void*
Language: C++

#include <iostream>


int main() {


	//入力
	int N, Q, char* s, * t, * d;
	std::cin >> N >> Q;
	s = new char[N];
	std::cin >> s;
	t = new char[Q];
	d = new char[Q];
	for (int i = 0; i < Q; i++)std::cin >> t[i] >> d[i];


	//処理
	int* num_gorem = new int[N + 2];//端っこの二つも含める
	for (int i = 0; i < N + 2; i++)num_gorem[i] = 1;//num_goremにそれぞれ1を代入
	for (int i = 0; i < Q; i++) {//i->i番目の呪文の文字
		for (int j = 0; j < N; j++) {//j->j番目の入力文字列の文字
			if (t[i] == s[j]) {//もし同じ文字だった場合
				if (d[i] == 'L') {//左に移動する場合
					num_gorem[1 + j - 1] += num_gorem[1 + j];
					num_gorem[1 + j] = 0;
				}
				else if (d[i] == 'R') {//右に移動する場合
					num_gorem[1 + j + 1] += num_gorem[1 + j];
					num_gorem[1 + j] = 0;
				}
			}
		}
	}


	//出力
	int ans = 0;
	for (int i = 1; i < N; i++) {
		ans += num_gorem[i];
	}
	std::cout << ans;


	//終了処理
	delete[] s, t, d, num_gorem;


	return 0;


}

Compiler output:
a.cc: In function 'int main()':
a.cc:8:19: error: expected unqualified-id before 'char'
    8 |         int N, Q, char* s, * t, * d;
      |                   ^~~~
a.cc:10:9: error: 's' was not declared in this scope
   10 |         s = new char[N];
      |         ^
a.cc:12:9: error: 't' was not declared in this scope
   12 |         t = new char[Q];
      |         ^
a.cc:13:9: error: 'd' was not declared in this scope
   13 |         d = new char[Q];
      |         ^
a.cc:45:9: error: type '<type error>' argument given to 'delete', expected pointer
   45 |         delete[] s, t, d, num_gorem;
      |         ^~~~~~~~~~
Language: Java

import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Scanner;

public class C_gorem {

	public static void main(String args[]) {

		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		int Q = sc.nextInt();
		sc.nextLine();
		String s = sc.nextLine();

		Map<Character,List<Integer>> charindex = new HashMap<Character,List<Integer>>();
		int[] box = new int[N];
		int deletednum = 0;

		for(int i=0;i<N;i++) {
			box[i] = 1;

			List<Integer> index;
			if((index = charindex.get(s.charAt(i))) == null) {
				index = new ArrayList<Integer>();
			}
			index.add(i);
			charindex.put(s.charAt(i), index);
		}

		for(int i=0;i<Q;i++) {
			System.out.println(Arrays.toString(box));
			String[] td = sc.nextLine().split(" ");
			String t = td[0];
			String d = td[1];

			List<Integer> index;
			if((index = charindex.get(t.charAt(0))) != null) {
				for(int j=0;j<index.size();j++) {
					int boxnum = index.get(j);

					if(boxnum == 0 && d.equals("L")) {
						deletednum += box[0];
						box[0] = 0;
					}else if(boxnum == N-1 && d.equals("R")) {
						deletednum += box[N-1];
						box[N-1] = 0;
					}else if(d.equals("L")){
						box[boxnum-1] += box[boxnum];
						box[boxnum] = 0;
					}else {
						box[boxnum+1] += box[boxnum];
						box[boxnum] = 0;
					}
				}
			}
		}

		System.out.println(N - deletednum);
	}

}

Compiler output:
Main.java:8: error: class C_gorem is public, should be declared in a file named C_gorem.java
public class C_gorem {
       ^
1 error
Language: C++

  int drop_l = 0;
  ng = 'n';
  pointer = 0;
  for(int i = Q - 1; i >= 0; i--){
    if(t[i] == ng && d[i] == 'R'){
      drop_l = max(drop_l, pointer - 1);
      ng = 'n';
      pointer = 0;
    }
    if(t[i] == s[pointer] && d[i] == 'L'){
      ng = s[pointer];
      pointer++;
      if(pointer >= N){
        break;
      }
    }
  }
  drop_l = max(drop_l, pointer);

  int ans = N - (drop_r + drop_l);
  if(ans < 0){
    ans = 0;
  }

  cout << ans << endl;
}




Compiler output:
a.cc:2:3: error: 'ng' does not name a type; did you mean 'long'?
    2 |   ng = 'n';
      |   ^~
      |   long
a.cc:3:3: error: 'pointer' does not name a type
    3 |   pointer = 0;
      |   ^~~~~~~
a.cc:4:3: error: expected unqualified-id before 'for'
    4 |   for(int i = Q - 1; i >= 0; i--){
      |   ^~~
a.cc:4:22: error: 'i' does not name a type
    4 |   for(int i = Q - 1; i >= 0; i--){
      |                      ^
a.cc:4:30: error: 'i' does not name a type
    4 |   for(int i = Q - 1; i >= 0; i--){
      |                              ^
a.cc:18:3: error: 'drop_l' does not name a type
   18 |   drop_l = max(drop_l, pointer);
      |   ^~~~~~
a.cc:20:13: error: 'N' was not declared in this scope
   20 |   int ans = N - (drop_r + drop_l);
      |             ^
a.cc:20:18: error: 'drop_r' was not declared in this scope; did you mean 'drop_l'?
   20 |   int ans = N - (drop_r + drop_l);
      |                  ^~~~~~
      |                  drop_l
a.cc:21:3: error: expected unqualified-id before 'if'
   21 |   if(ans < 0){
      |   ^~
a.cc:25:3: error: 'cout' does not name a type
   25 |   cout << ans << endl;
      |   ^~~~
a.cc:26:1: error: expected declaration before '}' token
   26 | }
      | ^
Language: C++

n,q=map(int,input().split())
s=input()
masu=[['-',0]]
for si in s:
    masu.append([si,1])
masu.append(['-',0])

for _ in range(q):
    t,d=input().split()
    for i in range(1,len(masu)-1):
        if masu[i][0] == t and masu[i][1] >= 1:
            if d == 'R':
                masu[i+1][1] += masu[i][1]
            else:
                masu[i-1][1] += masu[i][1] 
            masu[i][1] = 0

ans=0
for i in range(1,len(masu)-1):
    ans+=masu[i][1]
print(ans)

Compiler output:
a.cc:1:1: error: 'n' does not name a type
    1 | n,q=map(int,input().split())
      | ^