criyle/codenet-compile-errors huggingface dataset:
Language: Java

import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner kbd = new Scanner(System.in);
        int n = kbd.nextInt();
        String temp = kbd.next();
        String[] arr = temp.split("");
        int countR = 0;
        int countB = 0;
        for (int i = 0; i < n; i++) {
            if (arr[i].equals("R")) {
                countR++;
            } else {
                countB++;
            }
        }
        if(countR>countB){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }

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


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

int R;
int B;
char S[ 110 ];

int main()
{
int i;
char C;

	ios::sync_with_stdio( false );
	cin.tie( 0 );

	cin >> N;
	cin >> S;

	i = 0;
	while( ( C = S[ i ] ) != '\0' )
	{
		i++;
		if( C == 'R' )
			R++;
		else
			B++;
	}

	if( R > B )
		cout << "Yes" << endl;
	else
		cout << "No" << endl;

	return 0;
}


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

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

#define Online 1
// #define multitest 1
#define Debug
typedef long long ll;
typedef long double ld;
#define f first
#define s second
#define pb push_back
#define mp make_pair
const long long mod = 1000000007;
const long long High = 1e16;
void ControlIO();
void TimerStart();
void TimerStop();
#ifdef Debug
#define db(...) ZZ(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void ZZ(const char *name, Arg1 &&arg1)
{
	std::cerr << name << " = " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void ZZ(const char *names, Arg1 &&arg1, Args &&... args)
{
	const char *comma = strchr(names + 1, ',');
	std::cerr.write(names, comma - names) << " = " << arg1;
	ZZ(comma, args...);
}
#else
#define db(...)
#endif

void solve()
{
    int n;
    string Str;
    cin >> n >> b;
    int a,b;
    a = b = 0;
    for(char ch : str)
        if(ch=='R') a++;
        else b++;
    if(a>b) cout << "Yes";
    else cout << "No";
}

int main()
{
	ControlIO();
	int t = 1;
#ifdef multitest
	cin >> t;
#endif
	TimerStart();
	while (t--)
		solve();
	TimerStop();
	return 0;
}

void ControlIO()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
#ifndef Online
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}

auto TimeStart = chrono::steady_clock::now();
auto TimeEnd = chrono::steady_clock::now();

void TimerStart()
{
#ifndef Online
	TimeStart = chrono::steady_clock::now();
#endif
}

void TimerStop()
{
#ifndef Online
	TimeEnd = chrono::steady_clock::now();
	auto ElapsedTime = TimeEnd - TimeStart;
	cout << "\n\nTime elapsed: " << chrono::duration<double>(ElapsedTime).count() << " seconds.\n";
#endif
}


Compiler output:
a.cc: In function 'void solve()':
a.cc:41:17: error: 'b' was not declared in this scope
   41 |     cin >> n >> b;
      |                 ^
a.cc:44:19: error: 'str' was not declared in this scope; did you mean 'Str'?
   44 |     for(char ch : str)
      |                   ^~~
      |                   Str
Language: C++

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

#define Online 1
// #define multitest 1
#define Debug
typedef long long ll;
typedef long double ld;
#define f first
#define s second
#define pb push_back
#define mp make_pair
const long long mod = 1000000007;
const long long High = 1e16;
void ControlIO();
void TimerStart();
void TimerStop();
#ifdef Debug
#define db(...) ZZ(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void ZZ(const char *name, Arg1 &&arg1)
{
	std::cerr << name << " = " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void ZZ(const char *names, Arg1 &&arg1, Args &&... args)
{
	const char *comma = strchr(names + 1, ',');
	std::cerr.write(names, comma - names) << " = " << arg1;
	ZZ(comma, args...);
}
#else
#define db(...)
#endif

void solve()
{
    int n;
    string Str;
    cin >> n >> Str;
    int a,b;
    a = b = 0
    for(char ch : Str)
        if(ch=='R') a++;
        else b++;
    if(a>b) cout << "Yes";
    else cout << "No";
}

int main()
{
	ControlIO();
	int t = 1;
#ifdef multitest
	cin >> t;
#endif
	TimerStart();
	while (t--)
		solve();
	TimerStop();
	return 0;
}

void ControlIO()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
#ifndef Online
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}

auto TimeStart = chrono::steady_clock::now();
auto TimeEnd = chrono::steady_clock::now();

void TimerStart()
{
#ifndef Online
	TimeStart = chrono::steady_clock::now();
#endif
}

void TimerStop()
{
#ifndef Online
	TimeEnd = chrono::steady_clock::now();
	auto ElapsedTime = TimeEnd - TimeStart;
	cout << "\n\nTime elapsed: " << chrono::duration<double>(ElapsedTime).count() << " seconds.\n";
#endif
}


Compiler output:
a.cc: In function 'void solve()':
a.cc:43:14: error: expected ';' before 'for'
   43 |     a = b = 0
      |              ^
      |              ;
   44 |     for(char ch : Str)
      |     ~~~       
a.cc:46:9: error: 'else' without a previous 'if'
   46 |         else b++;
      |         ^~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
char s[1000010];
int n,r,b;
int main()
{
  cin>>n;
  gets(s+1);
  gets(s+1);
  for(int i=1;i<=n;i++)
    if(s[i]=='B')
      b++;
 	else
      r++;
  puts(r>b?"Yes":"No");
}

Compiler output:
a.cc: In function 'int main()':
a.cc:8:3: error: 'gets' was not declared in this scope; did you mean 'getw'?
    8 |   gets(s+1);
      |   ^~~~
      |   getw
Language: C++

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

#define Online 1
// #define multitest 1
#define Debug
typedef long long ll;
typedef long double ld;
#define f first
#define s second
#define pb push_back
#define mp make_pair
const long long mod = 1000000007;
const long long High = 1e16;
void ControlIO();
void TimerStart();
void TimerStop();
#ifdef Debug
#define db(...) ZZ(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void ZZ(const char *name, Arg1 &&arg1)
{
	std::cerr << name << " = " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void ZZ(const char *names, Arg1 &&arg1, Args &&... args)
{
	const char *comma = strchr(names + 1, ',');
	std::cerr.write(names, comma - names) << " = " << arg1;
	ZZ(comma, args...);
}
#else
#define db(...)
#endif

void solve()
{
    int n;
    string Str;
    cin >> n >> b;
    int a,b;
    a = b = 0
    for(char ch : str)
        if(ch=='R') a++;
        else b++;
    if(a>b) cout << "Yes";
    else cout << "No";
}

int main()
{
	ControlIO();
	int t = 1;
#ifdef multitest
	cin >> t;
#endif
	TimerStart();
	while (t--)
		solve();
	TimerStop();
	return 0;
}

void ControlIO()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
#ifndef Online
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}

auto TimeStart = chrono::steady_clock::now();
auto TimeEnd = chrono::steady_clock::now();

void TimerStart()
{
#ifndef Online
	TimeStart = chrono::steady_clock::now();
#endif
}

void TimerStop()
{
#ifndef Online
	TimeEnd = chrono::steady_clock::now();
	auto ElapsedTime = TimeEnd - TimeStart;
	cout << "\n\nTime elapsed: " << chrono::duration<double>(ElapsedTime).count() << " seconds.\n";
#endif
}


Compiler output:
a.cc: In function 'void solve()':
a.cc:41:17: error: 'b' was not declared in this scope
   41 |     cin >> n >> b;
      |                 ^
a.cc:46:9: error: 'else' without a previous 'if'
   46 |         else b++;
      |         ^~~~
Language: C++

#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<vector>
#include<list>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<cctype>
#include<climits>
#include<bitset>
#define ld long double
#define ll long long int
#define ull unsigned long long int
#define rep(i,n) for(i=0;i<n;i++)
#define fin(ans) cout<<(ans)<<endl
#define INF INT_MAX
using namespace std;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
const long long LLINF=1LL<<60;
//set<int>::iterator it;

int main(void){ios::sync_with_stdio(false);cin.tie(0);
//////////////////////////////////////////////////////
	
	int i,j,n;
	string s;
//	char c;
	
//	int a,b,c;
//	cin>>a>>b>>c;
//	if(a+b<c||a+c<b||b+c<a)cout<<"Yes"<<endl;
//	else cout<<"No"<<endl;
	
	int r=0,b=0;
	cin>>n>>s;
	for(i=0;i<s.length();i++){
		if(s[i]=="R")r++;
		else b++;
	}
	if(r>b)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
//////////////////////////////////////////////////////
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:42:24: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   42 |                 if(s[i]=="R")r++;
Language: C++

N =int(input())
s = input()

cnt = s.count('R')
cntb = s.count('B')

if cnt > cntb:
    print('Yes')
else:
    print('No')


Compiler output:
a.cc:8:11: warning: multi-character character constant [-Wmultichar]
    8 |     print('Yes')
      |           ^~~~~
a.cc:10:11: warning: multi-character character constant [-Wmultichar]
   10 |     print('No')
      |           ^~~~
a.cc:1:1: error: 'N' does not name a type
    1 | N =int(input())
      | ^
Language: C++

#include<cstdio>
int main(){
  int n;
  scanf("%d",&n);
  char s[n+1]={};
  scanf("%s,s);
  int r=0;
  int b=0;
  for(int i=0;i<n;i++){
    if(s[i]=='R')r++;
    else b++;
  }
  if(r>b)printf("Yes\n");
  else printf("No\n");
  return 0;
        }

Compiler output:
a.cc:6:9: warning: missing terminating " character
    6 |   scanf("%s,s);
      |         ^
a.cc:6:9: error: missing terminating " character
    6 |   scanf("%s,s);
      |         ^~~~~~~
a.cc: In function 'int main()':
a.cc:7:3: error: expected primary-expression before 'int'
    7 |   int r=0;
      |   ^~~
a.cc:10:18: error: 'r' was not declared in this scope
   10 |     if(s[i]=='R')r++;
      |                  ^
a.cc:13:6: error: 'r' was not declared in this scope
   13 |   if(r>b)printf("Yes\n");
      |      ^
Language: C++

#include <bits/stdc++.h>
#define ll long long
#define ff first
#define ss second
#define PB push_back
#define MP make_pair
#define pri 1000000007
using namespace std;
void run(){
	ll n;
	cin>>n;
	string a;
	cin>>a;
	ll r=0,b=0;
	for(ll i=0;i<n;i++){
		if(a[i]=='R')r++
		else b++;
	}
	if(r>b)cout<<"Yes";
	else cout<<"No";
}
int main() {
	ll t=1;
	//cin>>t;
	for(ll i=0;i<t;i++)run();
	// your code goes here
	return 0;
}

Compiler output:
a.cc: In function 'void run()':
a.cc:16:33: error: expected ';' before 'else'
   16 |                 if(a[i]=='R')r++
      |                                 ^
      |                                 ;
   17 |                 else b++;
      |                 ~~~~
Language: C++

n = int(input())
s = input()
cntR = 0
cntB = 0
for i in range(n):
    if s[i] == "R":
        cntR+=1
    else:
        cntB+=1
if cntR>cntB:
    print("Yes")
else:
    print("No")

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

#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  stirng s;
  int r,b;
  r = 0;
  b = 0;
  cin >> n >> s;
  for(int i = 0;i < n;i++){
    if(s[i] == 'R')r++;
    else b++;
  }
  if(r > b)cout << "Yes" << endl;
  else cout << "No" << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:5:3: error: 'stirng' was not declared in this scope
    5 |   stirng s;
      |   ^~~~~~
a.cc:9:15: error: 's' was not declared in this scope
    9 |   cin >> n >> s;
      |               ^
Language: C++

#!/usr/bin/python3

import math
import sys


DEBUG = False


def inp():
    return sys.stdin.readline().rstrip()


def dprint(*value, sep=' ', end='\n'):
    if DEBUG:
        print(*value, sep=sep, end=end)


def solve(N, S):
    return S.count('R') > S.count('B')


def main():
    N = int(inp())
    S = inp()
    print('Yes' if solve(N, S) else 'No')


if __name__ == '__main__':
    main()


Compiler output:
a.cc:1:2: error: invalid preprocessing directive #!
    1 | #!/usr/bin/python3
      |  ^
a.cc:26:11: warning: multi-character character constant [-Wmultichar]
   26 |     print('Yes' if solve(N, S) else 'No')
      |           ^~~~~
a.cc:26:37: warning: multi-character character constant [-Wmultichar]
   26 |     print('Yes' if solve(N, S) else 'No')
      |                                     ^~~~
a.cc:29:16: warning: multi-character literal with 8 characters exceeds 'int' size of 4 bytes
   29 | if __name__ == '__main__':
      |                ^~~~~~~~~~
a.cc:3:1: error: 'import' does not name a type
    3 | import math
      | ^~~~~~
a.cc:3:1: note: C++20 'import' only available with '-fmodules-ts'
Language: Java

,import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = Integer.parseInt(scanner.nextLine());
        String s = scanner.nextLine();

        int red = 0;
        int blue = 0;
        for (int i = 0; i < s.length(); i++) {
            if (s.charAt(i) == 'R') {
                red++;
            } else {
                blue++;
            }
        }
        System.out.println(red > blue ? "Yes" : "No");
    }
}


Compiler output:
Main.java:1: error: class, interface, enum, or record expected
,import java.util.*;
^
1 error
Language: C++

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

int main(){
  int n,r=0,b=0;
  cin>>n;
  for(int i=0; i<n; i++){
    char c;
    cin>>c;
    if(c=='R')r++;;
    else b++;
  }

  if(r>b)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:11:5: error: 'else' without a previous 'if'
   11 |     else b++;
      |     ^~~~
Language: C++

#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<vector>
#include<list>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<cctype>
#include<climits>
#include<bitset>
#define ld long double
#define ll long long int
#define ull unsigned long long int
#define rep(i,n) for(i=0;i<n;i++)
#define fin(ans) cout<<(ans)<<endl
#define INF INT_MAX
using namespace std;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
const long long LLINF=1LL<<60;
//set<int>::iterator it;

int main(void){ios::sync_with_stdio(false);cin.tie(0);
//////////////////////////////////////////////////////
	
	int i,j;
	string s;
//	char c;
	
//	int a,b,c;
//	cin>>a>>b>>c;
//	if(a+b<c||a+c<b||b+c<a)cout<<"Yes"<<endl;
//	else cout<<"No"<<endl;
	
	int r=0,b=0;
	cin>>n>>s;
	for(i=0;i<s.length();i++){
		if(s[i]=="R")r++;
		else b++;
	}
	if(r>b)cout<<"Yes"<<endl;
	else cout<<"No"<,endl;
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
//////////////////////////////////////////////////////
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:40:14: error: 'n' was not declared in this scope
   40 |         cin>>n>>s;
      |              ^
a.cc:42:24: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   42 |                 if(s[i]=="R")r++;
a.cc:46:25: error: expected primary-expression before ',' token
   46 |         else cout<<"No"<,endl;
      |                         ^
Language: C++

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

int main() {
int n; cin>>n;
  int s; cin>>s;
  int r,b=0;
  for(int i=0;i<s.size();i++){
    if(s[i]=='R') r++;
    else b++;}
  if(r>b){cout<<"Yes"<<endl;}
  else cout<<"No"<<endl;
  
}

Compiler output:
a.cc: In function 'int main()':
a.cc:11:19: error: request for member 'size' in 's', which is of non-class type 'int'
   11 |   for(int i=0;i<s.size();i++){
      |                   ^~~~
a.cc:12:9: error: invalid types 'int[int]' for array subscript
   12 |     if(s[i]=='R') r++;
      |         ^
Language: C++

#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <stack>
#include <vector>
#include <queue>
#include <random>
#include <cstdint>
#include <bitset>
#include <iomanip>
#include <utility>
#include<map>
#include<functional>
#include<climits>
#include<regex>
using namespace std;
typedef long long ll;
const int mod = 1000000007;

int main() {
	int n;
	string s;
	cin >> n >> s;
	int ans = 0;
	for (int i = 0; i < n; i++) {
		if (s[i] == "R")ans++;
		else ans--;
	}
	if (ans > 0)cout << "Yes" << endl;
	else cout << "No" << endl;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:27:26: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   27 |                 if (s[i] == "R")ans++;
Language: C++

n = int(input())
s = input()
r = 0
b = 0
for i in s:
    if i == 'R': 
        r += 1
    else:
        b += 1
if r > b:
    print("Yes")
else:
    print("No")

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

#include<bits/stdc++.h>

using namespace std;
using ll = long long;

int n, q;


int f(string s, vector<pair<char,char>> op) {

    if(!count(op.begin(), op.end(), make_pair(s[0],'L'))) {
        return 0;
    }


    
    int lef = 0, rig = n; //oooooxxx
    while(rig - lef > 1) {
        int mid = (lef + rig) / 2;
        int pos = mid;
        bool ok = false;
        for(int i = 0; i < q; i++) {
            if(op[i].first == s[pos]) {
                if(op[i].second == 'R' ? pos++ : pos--);
                if(pos < 0){ok = true;break;}
                if(pos >= n)break;
            }
        }
        (ok ? lef : rig) = mid;
    }
    return rig;
}


int main()
{
    string s;
    cin >> n >> q >> s;
    vector<pair<char,char>> op(q);
    for(int i = 0; i < q; i++)cin >> op[i].first >> op[i].second;

    int lef = f(s, op); //xxxoooで何個落ちるか
    reverse(s.begin(), s.end());
    for(int i = 0; i < q; i++)op[i].second = (op[i].second == 'R' ? 'L' : 'R');
    int rig = f(s, op); //xxxoooの右端

    print(lef);
    print(rig);

    cout << n - min(rig + lef, n) << endl;


}

Compiler output:
a.cc: In function 'int main()':
a.cc:47:5: error: 'print' was not declared in this scope; did you mean 'rint'?
   47 |     print(lef);
      |     ^~~~~
      |     rint
Language: C++

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i,n) for(ll i = 0; i<(ll)(n); i++)
#define REPS(i,n) for (ll i = 1; i<=(ll)(n); i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define pb push_back
#define MOD 1000000007
#define MOD2 998244353
#define PI 3.141592653
#define INF 100000000000000 //14

ll ctoi(char x){
    return x-'A';
}

int main(){
    ll n, q; cin >> n >> q;
    string s; cin >> s;
    vector<vector<char>> ql(q,vector<char>(2));
    ll left = -1; ll right = n;
    REP(i,q) cin >> ql[i][0] >> ql[i][1];
    FORD(i,q-1,0){
        else if (s[left+1]==ql[i][0]&&ql[i][1]=='L') left++;
        else if (s[right-1]==ql[i][0]&&ql[i][1]=='R') right--;
    }
    cout << max(0ll,right-left-1) << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:27:9: error: 'else' without a previous 'if'
   27 |         else if (s[left+1]==ql[i][0]&&ql[i][1]=='L') left++;
      |         ^~~~
Language: C++

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

signed main(){
  int N, Q; cin >> N >> Q;
  string s; cin >> s;
  vector<char> t(Q), d(Q);
  for(int i = 0; i < Q; i++) cin >> t[i] >> d[i];
  int left = 0, right = N, ans = N;
  while(right - left > 1){
    int mid = (right + left) / 2, mid1 = mid;
    for(int i = 0; i < Q; i++){
      if(t[i] == s[mid] && d[i] == 'L') mid--;
      if(t[i] == s[mid] && d[i] == 'R') mid++;
      if(mid == N || mid == -1) break;
    }
    if(mid == -1) left = mid1;
    else right = mid1;
  }
  int ans -= left + 1;
  left = -1, right = N;
  while(right - left > 1){
    int mid = (right + left) / 2, mid1 = mid;
    for(int i = 0; i < Q; i++){
      if(t[i] == s[mid] && d[i] == 'L') mid--;
      if(t[i] == s[mid] && d[i] == 'R') mid++;
      if(mid == N || mid == -1) break;
    }
    if(mid == N) right = mid1;
    else left = mid1;
  }
  ans -= (N - right);
  cout << ans << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:21:11: error: expected initializer before '-=' token
   21 |   int ans -= left + 1;
      |           ^~
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
#define Priq priority_queue<int,vi,greater<int>>
#define pb push_back
#define mp make_pair
#define INF (1ll<<60)
map<char,set<int>> M;
string S;
struct Union_Find{
  vi par;
  Union_Find(int N):par(N){
    rep(i,0,N) par[i]=i;
  }
  int root(int X){
    if(par[X]==X||par[X]==-1||par[X]==par.size()) return par[X];
    return par[X]=root(par[X]);
  }
  void insert(int X,int Y){
    if(Y==-1){
      par[X]=-1;
      M[S[X]].erase(X);
    }
    else if(Y==par.size()){
      par[X]=par.size();
      M[S[X]].erase(X);
    }
    else{
      par[X]=Y;
      M[S[Y]].insert(Y);
      M[S[X]].erase(X);
    }
  }
  bool safe(int X){
    if(root(X)==-1||root(X)==par.size()) return 0;
    return 1;
  }
};
signed main(){
  int N,Q;
  cin>>S;
  rep(i,0,N) M[S[i]].insert(i);
  Union_Find tree(N);
  rep(i,0,Q){
    char A,B; cin>>A>>B;
    int X=1;
    if(B=='L') X=-1;
    for(auto p:M[A]){
      tree.insert(p,p+X);
    }
  }
  int ans=0;
  rep(i,0,N){
    if(safe(i)) ans++;
  }
  cout<<ans<<endl;
  }


Compiler output:
a.cc: In function 'int main()':
a.cc:65:8: error: 'safe' was not declared in this scope
   65 |     if(safe(i)) ans++;
      |        ^~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
#define Priq priority_queue<int,vi,greater<int>>
#define pb push_back
#define mp make_pair
#define INF (1ll<<60)
map<char,set<int>> M;
string S;
struct Union_Find{
  vi par;
  Union_Find(int N):par(N){
    rep(i,0,N) par[i]=i;
  }
  int root(int X){
    if(par[X]==X||par[X]==-1||par[X]==N) return par[X];
    return par[X]=root(par[X]);
  }
  void insert(int X,int Y){
    if(Y==-1){
      par[X]=-1;
      M[S[X]].erase(X);
    }
    else if(Y==N){
      par[X]=N;
      M[S[X]].erase(X);
    }
    else{
      par[X]=Y;
      M[S[Y]].insert(Y);
      M[S[X]].erase(X);
    }
  }
  bool safe(int X){
    if(root(X)==-1||root(X)==N) return 0;
    return 1;
  }
};
signed main(){
  int N,Q;
  cin>>S;
  rep(i,0,N) M[S[i]].insert(i);
  Union_Find tree(N);
  rep(i,0,Q){
    char A,B; cin>>A>>B;
    int X=1;
    if(B=='L') X=-1;
    for(auto p:M[A]){
      tree.insert(p,p+X);
    }
  }
  int ans=0;
  rep(i,0,N){
    if(safe(i)) ans++;
  }
  cout<<ans<<endl;
  }


Compiler output:
a.cc: In member function 'long long int Union_Find::root(long long int)':
a.cc:27:39: error: 'N' was not declared in this scope
   27 |     if(par[X]==X||par[X]==-1||par[X]==N) return par[X];
      |                                       ^
a.cc: In member function 'void Union_Find::insert(long long int, long long int)':
a.cc:35:16: error: 'N' was not declared in this scope
   35 |     else if(Y==N){
      |                ^
a.cc: In member function 'bool Union_Find::safe(long long int)':
a.cc:46:30: error: 'N' was not declared in this scope
   46 |     if(root(X)==-1||root(X)==N) return 0;
      |                              ^
a.cc: In function 'int main()':
a.cc:65:8: error: 'safe' was not declared in this scope
   65 |     if(safe(i)) ans++;
      |        ^~~~
Language: C++

#include<bits/stdc++.h>
#pragma GCC optimize("O2")
using namespace std;
#define F first
#define S second
#define migmig ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long 
#define ld long double
long long const inf = 1e18;
int const mxn = 2e5+10;
 
ll poww(ll a, ll b, ll md) {
    return (!b ? 1 : (b & 1 ? a * poww(a * a % md, b / 2, md) % md : poww(a * a % md, b / 2, md) % md));
} 

int mak[mxn];
pair <char,char> ql[mxn];
char now[mxn];
int n,q;
string s;
long long ans;

check (int x, int t){
	now[x]=s[x];
	mak[x]=x;
	for (int i = 0;i<q;i++){
		if (ql[i].F==now[x]){
			if (ql[i].S=='R')
				mak[x]++;
			if (ql[i].S=='L')
				mak[x]--;
			now[x]=s[mak[x]];
			if (mak[x]<0 and t)
				return 0;
			if (mak[x]>n-1 and t)
				return 1;
			if (mak[x]<0 and !t)
				return 1;
			if (mak[x]>n-1 and !t)
				return 0;
		}
	}
	return 0;
}

int main(){
	cin>>n>>q;
	ans=n;
	cin>>s;
	for (int i = 0;i<q;i++){
		char a ,  b;
		cin>>a>>b;
		ql[i]={a,b};
	}
	int l = 0, r = n, mid = 0;
	while (r-l>1){
		mid = (l+r)/2;
		if (check(mid,1))
			r = mid;
		else
			l= mid;
	}
	//cout<<n-r<<" ";
	ans-=(n-r);
	l = 0, r = n, mid = 0;
	while (r-l>1){
		mid = (l+r)/2;
		if (check(mid,0))
			l= mid;
		else
			r= mid;
	}
	ans-=r;
	//cout<<r<<" ";
	cout<<ans;
	
}

Compiler output:
a.cc:23:1: error: ISO C++ forbids declaration of 'check' with no type [-fpermissive]
   23 | check (int x, int t){
      | ^~~~~
Language: C++

#include <bits/stdc++.h>
#define nmax 200005
using namespace std;
char s[nmax];
char q[nmax][2];
int n, m, ans1, ans2;


int last_position(int p) {

	if(!(p >= 1 && p <= n))
		return p;

	for(int i = 0; i < m; i++) {
		if(q[i][0] == s[p]) {
			if(q[i][1] == 'L') {
				if (--p == 0)
					return 0;
			}
			else {
				if (++p == n + 1)
					return n + 1;
			}
		}
	}
	return p;
}

int main()
{

	cin >> n >> m;
	cin >> s + 1;
	//cout << s + 1 << '\n';
	for(int i = 0; i < m; i++)
		f >> q[i][0] >> q[i][1];

	int st = 1, dr = n; ans1 = 0;
	while (st <= dr) {
		int mid = (st + dr) / 2;
		if(last_position(mid) == 0) {
			ans1 = mid;
			st = mid + 1;
		}
		else
			dr = mid - 1;
	}

	st = 1, dr = n; ans2 = n + 1;
	while (st <= dr) {
		int mid = (st + dr) / 2;
		//cout << mid << '\n';
		if(last_position(mid) == n + 1) {
			ans2 = mid;
			dr = mid - 1;
		}
		else
			st = mid + 1;

	} while(st <= dr);

	//for (int i = 1; i <= n; i++)
	//	cout << last_position(i) << '\n';

	//cout << ans1 << '\n';
	//cout << ans2 << '\n';
	cout << ans2 - ans1 - 1 << '\n';
}


Compiler output:
a.cc: In function 'int main()':
a.cc:36:17: error: 'f' was not declared in this scope
   36 |                 f >> q[i][0] >> q[i][1];
      |                 ^
Language: C++

#include<iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <queue>
#include <deque>
#include <map>
#include <stack>
#include<bitset>
#include<list>
#include<cassert>
#include<numeric>


using namespace std;

const long long N = 2e5 + 5;
long long n, q;
char a[N];
char c[N];
char d[N];

bool isval1(long long k)
{
	long long pos = k;
	for (long long i = 0; i < q; i++)
	{
		if (a[pos] == c[i])
		{
			if (d[i] == 'L')
			{
				pos--;
			}
			else
			{
				pos++;
			}
			if (pos == -1)
				return true;
			if (pos == n)
				return false
		}
	}
	return false;
}

long long bsearch1()
{
	long long down = -1;
	long long up = n;
	while (up - down > 1)
	{
		long long md = (up + down) / 2;
		if (isval1(md))
		{
			down = md;
		}
		else
		{
			up = md;
		}
	}
	return down;
}

bool isval2(long long k)
{
	long long pos = k;
	for (long long i = 0; i < n; i++)
	{
		if (a[pos] == c[i])
		{
			if (d[i] == 'L')
			{
				pos++;
			}
			else
			{
				pos--;
			}
			if (pos == -1)
				return true;
			if (pos == n)
				return false;
		}
	}
	return false;
}

long long bsearch2()
{
	long long down = -1;
	long long up = n;
	while (up - down > 1)
	{
		long long md = (up + down) / 2;
		if (isval2(md))
		{
			down = md;
		}
		else
		{
			up = md;
		}
	}
	return down;
}




 
int main() 
{
	cin >> n >> q;
	for (long long i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	for (long long i = 0 ; i < q; i++)
	{
		cin >> c[i] >> d[i];
	}
	long long ans = 0;
	ans = bsearch1();
	reverse(a, a + n);
	ans += bsearch2();
	ans++;
	ans++;
	cout << n - ans << endl;


}


 


Compiler output:
a.cc: In function 'bool isval1(long long int)':
a.cc:42:45: error: expected ';' before '}' token
   42 |                                 return false
      |                                             ^
      |                                             ;
   43 |                 }
      |                 ~
Language: C++

#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
#define ALL(obj) (obj).begin(), (obj).end()
const double PI = acos(-1);
const double EPS = 1e-15;
long long INF=(long long)1E17;
#define i_7 (long long)(1E9+7)
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;
bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd_(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}

int main(){
  
  int n,q;
  cin>>n>>q;
  string s;
  cin>>s;
  char t[q],d[q];
  REP(i,q){
    cin>>t[i]>>q[i];
  }
  int l=0,r=n;
  int left,right;
  bool flag;
  while(r-l>1){
    int m = (l+r)/2;
    int current = m;
    flag = true;//最初にm番目のマスにいたゴーレムが最後まで生き残るか
    REP(i,q){
      if(s[current]==t[i]){
        if(d[i]=='L'){
          current--;
          if(current==0){
            flag = false;
            break;
          }
        }else{
          current++;
          if(current==n){
            flag = false;
            break;
          }
        }
      }
    }
    if(flag){
      r = m+1;
    }else{
      l = m+1;
      if
    }
  }
    
    
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:54:17: error: invalid types 'int[int]' for array subscript
   54 |     cin>>t[i]>>q[i];
      |                 ^
a.cc:85:5: error: expected '(' before '}' token
   85 |     }
      |     ^
      |     (
Language: Java

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Scanner;

public class ExaWizardsCBetter {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int N = scanner.nextInt();
        int Q = scanner.nextInt();
        String s = scanner.next();
        int left = 0;
        int right = s.length() - 1;

        ArrayList<Character> indexes = new ArrayList<>();
        ArrayList<Character>  directions = new ArrayList<>();
        for(int i = 0; i < Q; i++){
            char index = scanner.next().charAt(0);
            char direction = scanner.next().charAt(0);
            indexes.add(index);
            directions.add(direction);
        }

        for(int j = Q - 1; j >= 0; j--){
            char atLeft = s.charAt(left);
            char atRight = s.charAt(right);
            char moveI = indexes.get(j);
            char moveD = directions.get(j);
            if(moveI == atLeft && moveD == 'L'){
                left++;
            }

            if(moveI == atRight && moveD == 'R'){
                right--;
            }
        }

        System.out.println(right - left + 1);

    }
}


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

#include <stdio.h>

const int N = 2e5 + 10;
char a[N];
char t[N], dir[N];
int n, qq;

bool can_left(int x) {
  int cur = x;
  for (int i = 0; i < qq; i++) {
    if (t[i] == a[cur]) {
      if (dir[i] == 'L') {
        cur--;
      } else {
        cur++;
      }
      if (cur == -1) {
        return true;
      }
    }
  }
  return false;
}

bool can_right(int x) {
  int cur = x;
  for (int i = 0; i < qq; i++) {
    if (t[i] == a[cur]) {
      if (dir[i] == 'L') {
        cur--;
      } else {
        cur++;
      }
      if (cur == n) {
        return true;
      }
    }
  }
  return false;
}

int main() {
  scanf("%d %d", &n, &qq);
  scanf("%s", a);
  for (int i = 0; i < qq; i++) {
    scanf(" %c %c", &t[i], &dir[i]);
  }
  int lo = -1, hi = n;
  int ans = n;
  while (lo + 1 < hi) {
    int mid = (lo + hi) / 2;
    if (can_left(mid)) {
      lo = mid;
    } else {
      hi = mid;
    }
  }
  ans -= lo + 1;
  lo = -1;
  hi = n;
  while (lo + 1 < hi) {
    int mid = (lo + hi) / 2;
    if (can_right(mid)) {
      hi = mid;
    } else {
      lo = mid;
    }
  }
  ans -= n - hi;
  printf("%d\n", ans);
  return 0;
}

Compiler output:
main.c:4:6: error: variably modified 'a' at file scope
    4 | char a[N];
      |      ^
main.c:5:6: error: variably modified 't' at file scope
    5 | char t[N], dir[N];
      |      ^
main.c:5:12: error: variably modified 'dir' at file scope
    5 | char t[N], dir[N];
      |            ^~~
main.c:8:1: error: unknown type name 'bool'
    8 | bool can_left(int x) {
      | ^~~~
main.c:2:1: note: 'bool' is defined in header '<stdbool.h>'; this is probably fixable by adding '#include <stdbool.h>'
    1 | #include <stdio.h>
  +++ |+#include <stdbool.h>
    2 | 
main.c: In function 'can_left':
main.c:18:16: error: 'true' undeclared (first use in this function)
   18 |         return true;
      |                ^~~~
main.c:18:16: note: 'true' is defined in header '<stdbool.h>'; this is probably fixable by adding '#include <stdbool.h>'
main.c:18:16: note: each undeclared identifier is reported only once for each function it appears in
main.c:22:10: error: 'false' undeclared (first use in this function)
   22 |   return false;
      |          ^~~~~
main.c:22:10: note: 'false' is defined in header '<stdbool.h>'; this is probably fixable by adding '#include <stdbool.h>'
main.c: At top level:
main.c:25:1: error: unknown type name 'bool'
   25 | bool can_right(int x) {
      | ^~~~
main.c:25:1: note: 'bool' is defined in header '<stdbool.h>'; this is probably fixable by adding '#include <stdbool.h>'
main.c: In function 'can_right':
main.c:35:16: error: 'true' undeclared (first use in this function)
   35 |         return true;
      |                ^~~~
main.c:35:16: note: 'true' is defined in header '<stdbool.h>'; this is probably fixable by adding '#include <stdbool.h>'
main.c:39:10: error: 'false' undeclared (first use in this function)
   39 |   return false;
      |          ^~~~~
main.c:39:10: note: 'false' is defined in header '<stdbool.h>'; this is probably fixable by adding '#include <stdbool.h>'
Language: C++

#include <stdio.h>

int main(void)
{
  int N,Q;
  int g[200000];
  char s[200000];
  char t,d;
  int tmp[2] = {};
  scanf("%d %d",&N,&Q);
  for(int i = 0; i < N; i++){
    scanf("%c",&s[i]);
    g[i] = 1;
  }
  for(int i = 0; i < Q; i++){
    scanf("%c %c",&t,&d);
  }
  int count = 0;
  for(int i = 0; i < Q; i++){
    if(d == 'L'){
      for(int j = 0; j < N; j++;){
        if(t == s[j]){
          if(j == 0){
          	g[j] = 0;
          }
          else{
            g[j-1] += g[j];
            g[j] = 0;
          }
        }
      }
    }
    else{
      for(int j = N-1; j > -1; j--){
        if(t == s[j]){
          if(j == N-1){
            g[j] = 0;
          }
          else{
            g[j+1] += g[j];
            g[j] = 0;
          }
        }
      }
    }
  }
  for(int i = 0; i < N; i++){
    count += g[i];
  }
  printf("%d",count);
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:21:32: error: expected ')' before ';' token
   21 |       for(int j = 0; j < N; j++;){
      |          ~                     ^
      |                                )
a.cc:21:33: error: expected primary-expression before ')' token
   21 |       for(int j = 0; j < N; j++;){
      |                                 ^
Language: C++

#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <vector>
using namespace std;
 
int N, Q;
 
int falldir(int i, string &str, vector<pair<char,char>> &spells){
  for(auto s : spells){
    char t = s.first; char d = s.second;
    if(t==str[i]){
      // hit
      i += (d=='L'?-1:1);
      if(i<0){ return -1; }
      else if(i>=N){ return 1; }
    }
  }
  return 0;
}
 
int main(){
  cin>>N>>Q;
  string s;
  cin>>s;
  
  vector<vector<int>> cmap(26);
  vector<pair<char,char>> spells;
  
  for(int i=0;i<N;i++){
    cmap[s[i]-'A'].push_back(i);
  }
  for(int h=1;h<=Q;h++){
    char t,d; cin>>t>>d;
    spells.push_back(make_pair(t,d));
  }
  
  int l=0, u=N;
  while(u-l>1){
    int m = (u+l)/2;
    if(falldir(m,cmap,spells)<0) l=m;
    else u=m;
  }
  int lower = l;
  
  l=0; u=N;
  while(u-l>1){
    int m = (u+l)/2;
    if(falldir(m,cmap,spells)>0) u = m;
    else l=m;
  }
  int upper = u;
  int ans = upper-lower-1;
  
  cout<<max(ans,0)<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:42:18: error: invalid initialization of reference of type 'std::string&' {aka 'std::__cxx11::basic_string<char>&'} from expression of type 'std::vector<std::vector<int> >'
   42 |     if(falldir(m,cmap,spells)<0) l=m;
      |                  ^~~~
a.cc:10:28: note: in passing argument 2 of 'int falldir(int, std::string&, std::vector<std::pair<char, char> >&)'
   10 | int falldir(int i, string &str, vector<pair<char,char>> &spells){
      |                    ~~~~~~~~^~~
a.cc:50:18: error: invalid initialization of reference of type 'std::string&' {aka 'std::__cxx11::basic_string<char>&'} from expression of type 'std::vector<std::vector<int> >'
   50 |     if(falldir(m,cmap,spells)>0) u = m;
      |                  ^~~~
a.cc:10:28: note: in passing argument 2 of 'int falldir(int, std::string&, std::vector<std::pair<char, char> >&)'
   10 | int falldir(int i, string &str, vector<pair<char,char>> &spells){
      |                    ~~~~~~~~^~~
Language: C++

#include "bits/stdc++.h"

using namespace std;

#define COUNTOF(array) (sizeof(array) / sizeof(array[0]))
#define OUT(P) cout << (P) << endl
#define OUT2(P1, P2) cout << (P1) << " " << (P2) << endl
#define PRINT_ARRAY(P) for(int i=0; i<P.size(); i++) cout << P[i] << endl;
#define PRINT_ARRAY_INLINE(P) do { for(int i=0; i<P.size(); i++) cout << P[i] << " "; cout << endl; } while(0)
#define PRINT_ARRAY_WITH_LABEL(L, P) do { cout << L << ": "; PRINT_ARRAY_INLINE(P); cout << endl; } while(0)

int sum_digits(int num);
template <class T>
vector<T> copy_vector(vector<T> vec);

int get_ordered_golem_position(int pos, string s, string items, string orders) {
    char code = s[pos]; 
    for(int i=0; i<items.size(); i++) {
        if(code == items[i]) {
            if(orders[i] == 'L')
                pos--;
            else
                pos++; 
            code = s[pos];
        }
    } 
    return pos;
}

int get_drop_position(int left, int right, 
                        string s, string t, string d, char direction) {
    int position = left + (right-left)/2;
    int moved_position = get_ordered_golem_position(position, s, t, d); 
    if(direction == 'L') {
        if(right-left<=1) return right;
        else if(moved_position < left) return get_drop_position(position, right, s, t, d, direction);
        else return get_drop_position(left, position, s, t, d, direction);
    } else {
        if(right-left<=1) return left;
        else if(moved_position < right) return get_drop_position(position, right, s, t, d, direction);
        else return get_drop_position(left, position, s, t, d, direction);
    }

    return 0;
}

int main() {
    int n, q;
    string s;
    cin >> n >> q;
    cin >> s;
    string t(q, 'a'), d(q, 'a');
    for(int i=0; i<q; i++) {
        cin >> t[i] >> d[i];
    }

    //for(int i=0; i<n; i++) {
    //    cout << i << " :" << get_ordered_golem_position(i, s, t, d) << endl;
    //}
    // 落ちないギリギリのラインを攻める
    int left_pos = get_drop_position(0, n, s, t, d, 'L');
    int right_pos = get_drop_position(0, n, s, t, d, 'R');
    

    out << right_pos - left_pos + 1 << endl;
    
    return 0;
}

/******************************/
/***** DECRARED FUNCTIONS *****/
/******************************/

// integerの各桁を足す
int sum_digits(int num) {
    int rtn = 0;
    string num_str = to_string(num);
    for(int i=0; i<num_str.size(); i++) {
        rtn += num_str[i] - '0';
    }   
    return rtn;
}

// vectorのコピー
template <class T>
vector<T> copy_vector(vector<T> vec) {
    vector<T> rtn;
    rtn.reserve(vec.size());
    copy(vec.begin(), vec.end(), back_inserter(rtn));
    return rtn;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:65:5: error: 'out' was not declared in this scope
   65 |     out << right_pos - left_pos + 1 << endl;
      |     ^~~
Language: C++

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

int N, Q;
string s;
vector<string> t, d;

bool vanish(int n, int m){
    // 初期位置 n のゴーレムが消えるか否かを判定。
    //  m=0：左で消えるとき true, それ以外のときfalse
    //  m=1：右で消えるとき true, それ以外のときfalse

    int x = n-1;  // 文字列 s は 0-indexed なので調整する
    int L = s.length();
    for(int i=0; i<Q; i++){
        if(t[i][0]==s[x]){
            x += (d[i][0]=='R'?1:-1);
            if(x==-1 || x==L) break;
        }
    }

    if(x==-1 && m==0){
        return true;
    }else if(x==L && m==1){
        return true;
    }else{
        return false;
    }
}

int main(){    
    cin >> N >> Q >> s;
    t = vector<string>(Q);
    d = vector<string>(Q);
    for(int i=0; i<Q; i++) cin >> t[i] >> d[i];

    // 左で消えるゴーレムの境界を求める
    int l1 = 0, r1 = N+1;    
    int Lleft = 0, Lright = N+1;
    while(r1 - l1 > 1){
        int mid = l1 + (r1 - l1)/2;
        if(vanish(mid, 0)){
            l1 = mid;
        }else{
            r1 = m
        }
    }

    // 右で消えるゴーレムの境界を求める
    int l2 = 0, r2 = N+1;
    while(r2 - l2 > 1){
        int mid = l2 + (r2 - l2)/2;
        if(vanish(mid, 1)){
            r2 = mid;
        }else{
            l2 = mid;
        }
    }
    
    if(l2 >= r1){
        cout << l2 - r1 + 1 << endl;
    }else{
        cout << 0 << endl;
    }
}


Compiler output:
a.cc: In function 'int main()':
a.cc:45:18: error: 'm' was not declared in this scope; did you mean 'tm'?
   45 |             r1 = m
      |                  ^
      |                  tm
Language: C++

#include <iostream>
using namespace std;

// the final position of golem whose initiali position is i
int sim(int i, string S, int N, int Q, int* dist, char td_list[Q][2]) {
    int idx = i;
    for (int j = 0; j < Q; ++j) {
        if (dist[i] != -2) return dist[i];
        if (idx == -1 || idx == N) {
            dist[i] = idx;
            return dist[i];
        }
        if (td_list[j][0] == S[idx]) {
            if (td_list[j][1] == 'L') idx--;
            else idx++;
        }
    }
    dist[i] = idx;
    return dist[i];
}

int main() {
    // init and load
    int N, Q;
    string S;
    cin >> N >> Q;
    cin >> S;
    char td_list[Q][2];
    for (int i = 0; i < Q; ++i) {
        cin >> td_list[i][0] >> td_list[i][1];
    }
    int dist[N];
    for (int i = 0; i < N; ++i) {
        dist[i] = -2;
    }
    // search left mergine
    int left = -1, right = N, mid;
    while (right - left != 1) {
        mid = (left + right) / 2;
        if (sim(mid, S, N, Q, dist, td_list) == -1) {
            left = mid;
        }
        else {
            right = mid;
        }
    }
    int lb = right;

    // search right margin
    left = -1, right = N;
    while (right - left != 1) {
        mid = (left + right) / 2;
        if (sim(mid, S, N, Q, dist, td_list) == N) {
            right = mid;
        }
        else {
            left = mid;
        }
    }
    int rb = left;
    cout << rb - lb + 1 << endl;
    return 0;
}

Compiler output:
a.cc:5:65: error: use of parameter outside function body before ']' token
    5 | int sim(int i, string S, int N, int Q, int* dist, char td_list[Q][2]) {
      |                                                                 ^
a.cc: In function 'int sim(...)':
a.cc:6:15: error: 'i' was not declared in this scope
    6 |     int idx = i;
      |               ^
a.cc:7:25: error: 'Q' was not declared in this scope
    7 |     for (int j = 0; j < Q; ++j) {
      |                         ^
a.cc:8:13: error: 'dist' was not declared in this scope
    8 |         if (dist[i] != -2) return dist[i];
      |             ^~~~
a.cc:9:33: error: 'N' was not declared in this scope
    9 |         if (idx == -1 || idx == N) {
      |                                 ^
a.cc:10:13: error: 'dist' was not declared in this scope
   10 |             dist[i] = idx;
      |             ^~~~
a.cc:13:13: error: 'td_list' was not declared in this scope; did you mean 'va_list'?
   13 |         if (td_list[j][0] == S[idx]) {
      |             ^~~~~~~
      |             va_list
a.cc:13:30: error: 'S' was not declared in this scope
   13 |         if (td_list[j][0] == S[idx]) {
      |                              ^
a.cc:18:5: error: 'dist' was not declared in this scope
   18 |     dist[i] = idx;
      |     ^~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long long int llint;
typedef pair<ll, ll> pa;
#define MM 1000000000
#define MOD MM+7
#define MAX 101000
#define MAP 110
#define initial_value -1
#define Pair pair<int,int>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
#define INF (1 << 29) //536870912
int dx[4] = {-1,0,1,0};
int dy[4] = {0,-1,0,1};
ll N,Q;
string s;
char t[200020],d[200020];
int check(ll x){
    for(int i = 0; i < Q; i++){
        if(s[x] == t[i]){
            if(d[i] == 'L') x--;
            if(d[i] == 'R') x++;
        }
        if(x == -1) return -1;
        if(x == n) return 1;
    }
    return 0;
}
int main(){
    cin >> N >> Q;
    cin >> s;
    for(int i = 0; i < Q; i++){
        cin >> t[i] >> d[i];
    }
    ll mid;
    ll ls = -1;
    ll rs = n;
    while(ls < rs-1){
        mid = (ls + rs)/2;
        if(check(mid) == -1) ls = mid;
        else rs = mid; 
    }
    ll lt = -1;
    ll rt = n;
    while(lt < rt-1){
        mid = (lt + rt)/2;
        if(check(mid) == 1) rt = mid;
        else lt = mid;
    }
    cout << rt-ls-1 << endl;
    return 0;
}



Compiler output:
a.cc: In function 'int check(ll)':
a.cc:27:17: error: 'n' was not declared in this scope
   27 |         if(x == n) return 1;
      |                 ^
a.cc: In function 'int main()':
a.cc:39:13: error: 'n' was not declared in this scope
   39 |     ll rs = n;
      |             ^