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

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

int main()
{
	int N, Q,i;
	
	char s[200001];
	char t[200001], d[200001];
	scanf("%d %d", &N, &Q);
	scanf("%s", s);
	for (i = 0;i < Q;i++)scanf("%c %c", &t[i], &d[i]);
	for (i = Q - 1, min = 0, max = N - 1;i >= 0;i--)
	{
		switch (d[i])
		{
			case 'R':
				if (t[i] == s[max]) { max--; }
				if (min > 0 && t[i] == s[min - i]) { min--; }
				break;
			case'L':
				if (t[i] == s[min]) { min++; }
				if (max < N - 1 && t[i] == s[max + 1]) { max++; }
				break;
		}
	}
	printf("%d\n", max - min + 1);
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:15:25: error: 'min' was not declared in this scope; did you mean 'std::min'?
   15 |         for (i = Q - 1, min = 0, max = N - 1;i >= 0;i--)
      |                         ^~~
      |                         std::min
In file included from /usr/include/c++/14/bits/specfun.h:43,
                 from /usr/include/c++/14/cmath:3906,
                 from /usr/include/c++/14/math.h:36,
                 from a.cc:4:
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: 'std::min' declared here
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
a.cc:15:34: error: 'max' was not declared in this scope; did you mean 'std::max'?
   15 |         for (i = Q - 1, min = 0, max = N - 1;i >= 0;i--)
      |                                  ^~~
      |                                  std::max
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: 'std::max' declared here
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
a.cc:29:24: error: 'max' was not declared in this scope; did you mean 'std::max'?
   29 |         printf("%d\n", max - min + 1);
      |                        ^~~
      |                        std::max
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: 'std::max' declared here
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
a.cc:29:30: error: 'min' was not declared in this scope; did you mean 'std::min'?
   29 |         printf("%d\n", max - min + 1);
      |                              ^~~
      |                              std::min
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: 'std::min' declared here
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
Language: C

#include<stdio.h>
int main(){
  int n,q;
  scanf("%d%d",&n,&q);
  char s[200002];
  int g[200002];
  int i,j;
  for(i=1,i=<n,i++) g[i]=1;
  scanf("%s",s);
  char t,d;
  for(i=0,i<q,i++){
    scanf("%c%c",t,d);
    for(j=1,j=<n,j++){
      if(t==s[j]){
        if(d=='L') g[j-1]+=g[j];
        else g[j+1]+=g[j];
        g[j]=0;
      }
    }
  }
  printf("%d",n-g[0]-g[n+1]);
  return 0;
}
      
  


Compiler output:
main.c: In function 'main':
main.c:8:13: error: expected expression before '<' token
    8 |   for(i=1,i=<n,i++) g[i]=1;
      |             ^
main.c:8:19: error: expected expression before ')' token
    8 |   for(i=1,i=<n,i++) g[i]=1;
      |                   ^
main.c:11:18: error: expected ';' before ')' token
   11 |   for(i=0,i<q,i++){
      |                  ^
      |                  ;
main.c:11:18: error: expected expression before ')' token
main.c:13:15: error: expected expression before '<' token
   13 |     for(j=1,j=<n,j++){
      |               ^
main.c:13:21: error: expected expression before ')' token
   13 |     for(j=1,j=<n,j++){
      |                     ^
Language: C

#include<stdio.h>
int main(){
  int n,q;
  scanf("%d%d",&n,&q);
  char s[200002];
  int g[200002];
  int i.j;
  for(i=1,i<n+1,i++) g[i]=1;
  scanf("%s",s);
  char t,d;
  for(i=0,i<q,i++){
    scanf("%c%c",t,d);
    for(j=1,j<n+1,j++){
      if(t==s[j]){
        if(d=='L') g[j-1]+=g[j];
        else g[j+1]+=g[j];
        g[j]=0;
      }
    }
  }
  printf("%d",n-g[0]-g[n+1]);
  return 0;
}
      
  


Compiler output:
main.c: In function 'main':
main.c:7:8: error: expected '=', ',', ';', 'asm' or '__attribute__' before '.' token
    7 |   int i.j;
      |        ^
main.c:7:8: error: expected expression before '.' token
main.c:8:7: error: 'i' undeclared (first use in this function)
    8 |   for(i=1,i<n+1,i++) g[i]=1;
      |       ^
main.c:8:7: note: each undeclared identifier is reported only once for each function it appears in
main.c:8:20: error: expected ';' before ')' token
    8 |   for(i=1,i<n+1,i++) g[i]=1;
      |                    ^
      |                    ;
main.c:8:20: error: expected expression before ')' token
main.c:11:18: error: expected ';' before ')' token
   11 |   for(i=0,i<q,i++){
      |                  ^
      |                  ;
main.c:11:18: error: expected expression before ')' token
main.c:13:9: error: 'j' undeclared (first use in this function)
   13 |     for(j=1,j<n+1,j++){
      |         ^
main.c:13:22: error: expected ';' before ')' token
   13 |     for(j=1,j<n+1,j++){
      |                      ^
      |                      ;
main.c:13:22: error: expected expression before ')' token
Language: C

#include<stdio.h>
int main(){
  int n,q;
  scanf("%d%d",&n,&q);
  char s[200002];
  int g[200002];
  for(long i=1,i<n+1,i++) g[i]=1;
  scanf("%s",s);
  char t,d;
  for(i=0,i<q,i++){
    scanf("%c%c",t,d);
    for(long j=1,j<n+1,j++){
      if(t==s[j]){
        if(d=='L') g[j-1]+=g[j];
        else g[j+1]+=g[j];
        g[j]=0;
      }
    }
  }
  printf("%d",n-g[0]-g[n+1]);
  return 0;
}
      
  


Compiler output:
main.c: In function 'main':
main.c:7:17: error: expected '=', ',', ';', 'asm' or '__attribute__' before '<' token
    7 |   for(long i=1,i<n+1,i++) g[i]=1;
      |                 ^
main.c:9:3: error: expected expression before 'char'
    9 |   char t,d;
      |   ^~~~
main.c:22:1: error: expected expression before '}' token
   22 | }
      | ^
Language: C

#include<stdio.h>
int main(){
  long n,q;
  scanf("%d%d",&n,&q);
  char s[200002];
  long g[200002];
  for(long i=1,i<n+1,i++) g[i]=1;
  scanf("%s",s);
  char t,d;
  for(i=0,i<q,i++){
    scanf("%c%c",t,d);
    for(long j=1,j<n+1,j++){
      if(t==s[j]){
        if(d=='L') g[j-1]+=g[j];
        else g[j+1]+=g[j];
        g[j]=0;
      }
    }
  }
  printf("%d",n-g[0]-g[n+1]);
  return 0;
}
      
  

Compiler output:
main.c: In function 'main':
main.c:7:17: error: expected '=', ',', ';', 'asm' or '__attribute__' before '<' token
    7 |   for(long i=1,i<n+1,i++) g[i]=1;
      |                 ^
main.c:9:3: error: expected expression before 'char'
    9 |   char t,d;
      |   ^~~~
main.c:22:1: error: expected expression before '}' token
   22 | }
      | ^
Language: C++

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

int N,Q;
string s;
vector<int> counter;
map<char, vector<int>> indexes;
int main(){
  cin >> N >> Q;
  cin >> s;
  //char mass[N] = s.c_str();
  counter.resize(N,1);
  
  for(int i=0; i<N; i++){
    indexes[s[i]].push_back(i);
  }
  
  for(int i=0; i<Q; i++){
    char t,d;
    cin >> t >> d;
    if(indexes.find(t) != indexes.end()){
      for(int j=0; j < indexes[t].size(); j++){
        int index = indexes[t][j];

        if(d == 'R' && index != N - 1){
		  counter[index + 1] += counter[index];  
        }else if(d == 'L' && index != 0){
          counter[index - 1] += counter[index];
        }
        counter[index] = 0;
      }
    }
  }
  int count = 0;
  for(int i=0; i<N; i++;){
    count += counter[i];
  }
  cout << count << endl;
}


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

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

int N,Q;
string s;
vector<int> counter;
map<char, vector<int>> indexes;
int main(){
  cin >> N >> Q;
  cin >> s;
  char mass[N] = s.c_str();
  counter.resize(N,1);
  
  for(int i=0; i<N; i++){
    indexes[mass[i]].push_back(i);
  }
  
  for(int i=0; i<Q; i++){
    char t,d;
    cin >> t >> d;
    if(indexes.find(t) != indexes.end()){
      for(int j=0; j < indexes[t].size(); j++){
        int index = indexes[t][j];

        if(d == "R" && index != N - 1){
		  counter[index + 1] += counter[index];  
        }else if(d == "L" && index != 0){
          counter[index - 1] += counter[index];
        }
        counter[index] = 0;
      }
    }
  }
  int count = 0;
  for(int i=0; i<N; i+;){
    count += counter[i];
  }
  cout << count << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:14:25: error: array must be initialized with a brace-enclosed initializer
   14 |   char mass[N] = s.c_str();
      |                  ~~~~~~~^~
a.cc:28:14: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   28 |         if(d == "R" && index != N - 1){
      |            ~~^~~~~~
a.cc:30:20: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   30 |         }else if(d == "L" && index != 0){
      |                  ~~^~~~~~
a.cc:38:23: error: expected primary-expression before ';' token
   38 |   for(int i=0; i<N; i+;){
      |                       ^
a.cc:38:23: error: expected ')' before ';' token
   38 |   for(int i=0; i<N; i+;){
      |      ~                ^
      |                       )
a.cc:38:24: error: expected primary-expression before ')' token
   38 |   for(int i=0; i<N; i+;){
      |                        ^
Language: C++

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

int N,Q;
string s;
vector<int> counter;
map<char, vector<int>> indexes;
int main(){
  cin >> N >> Q;
  cin >> s;
  char mass[N] = s.c_char();
  counter.resize(N,1);
  
  for(int i=0; i<N; i++){
    indexes[mass[i]].insert(0,i);
  }
  
  for(int i=0; i<Q; i++){
    char t,d;
    cin >> t >> d;
    if(indexes.find(t) != indexes.end()){
      for(int j=0; j < indexes[t].size(); j++){
        int index = indexes[t][j];

        if(d == "R" && index != N - 1){
		  counter[index + 1] += counter[index];  
        }else if(d == "L" && index != 0){
          counter[index - 1] += counter[index];
        }
        counter[index] = 0;
      }
    }
  }
  int count = 0;
  for(int i=0; i<N; i+;){
    count += counter[i];
  }
  cout << count << endl;
}


Compiler output:
a.cc:7:1: error: 'vector' does not name a type
    7 | vector<int> counter;
      | ^~~~~~
a.cc:8:1: error: 'map' does not name a type
    8 | map<char, vector<int>> indexes;
      | ^~~
a.cc: In function 'int main()':
a.cc:12:20: error: 'std::string' {aka 'class std::__cxx11::basic_string<char>'} has no member named 'c_char'
   12 |   char mass[N] = s.c_char();
      |                    ^~~~~~
a.cc:13:3: error: 'counter' was not declared in this scope
   13 |   counter.resize(N,1);
      |   ^~~~~~~
a.cc:16:5: error: 'indexes' was not declared in this scope
   16 |     indexes[mass[i]].insert(0,i);
      |     ^~~~~~~
a.cc:22:8: error: 'indexes' was not declared in this scope
   22 |     if(indexes.find(t) != indexes.end()){
      |        ^~~~~~~
a.cc:26:14: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   26 |         if(d == "R" && index != N - 1){
      |            ~~^~~~~~
a.cc:28:20: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   28 |         }else if(d == "L" && index != 0){
      |                  ~~^~~~~~
a.cc:36:23: error: expected primary-expression before ';' token
   36 |   for(int i=0; i<N; i+;){
      |                       ^
a.cc:36:23: error: expected ')' before ';' token
   36 |   for(int i=0; i<N; i+;){
      |      ~                ^
      |                       )
a.cc:36:24: error: expected primary-expression before ')' token
   36 |   for(int i=0; i<N; i+;){
      |                        ^
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;
char t[200020],d[200020];
int solt(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 2;
    }
    return 0;
}
int main(){
    cin >> n >> q >> 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(solt(mid) == 1) ls = mid;
        else rs = mid;
    }
    ll lt = -1;
    ll rt = n;
    while(lt < ls-1){
        mid = (lt+rs)/2;
        if(solt(mid) == 2) rt = mid;
        else lt = mid;
    }
    cout << rt - ls - 1 << endl;
    return 0;
}



Compiler output:
a.cc: In function 'int solt(ll)':
a.cc:21:12: error: 's' was not declared in this scope
   21 |         if(s[x] == t[i]){
      |            ^
a.cc: In function 'int main()':
a.cc:31:22: error: 's' was not declared in this scope
   31 |     cin >> n >> q >> s;
      |                      ^
Language: Java

import java.util.Scanner;

public class MainC {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int q = sc.nextInt();
		String s = sc.next();
		String[] t = new String[q];
		String[] d = new String[q];
		for (int i = 0; i < q; i++) {
			t[i] = sc.next();
			d[i] = sc.next();
		}
		sc.close();

		int left = binarySearchLeft(s, t, d);
		int right = binarySearchRight(s, t, d);
		System.out.println(right - left - 1);
	}

	static int binarySearchLeft(String s, String[] t, String[] d) {
		int start = -1;
		int end = s.length();

		while (Math.abs(end - start) > 1) {
			int mid = (end + start) / 2;
			if (isDead(s, mid, t, d)) {
				start = mid;
			} else {
				end = mid;
			}
		}
		return start;
	}

	static int binarySearchRight(String s, String[] t, String[] d) {
		int start = -1;
		int end = s.length();

		while (Math.abs(end - start) > 1) {
			int mid = (end + start) / 2;
			if (isDead(s, mid, t, d)) {
				end = mid;
			} else {
				start = mid;
			}
		}
		return end;
	}

	static boolean isDead(String s, int idx, String[] t, String[] d) {
		for (int i = 0; i < t.length; i++) {
			if (t[i].equals(s.substring(idx, idx + 1))) {
				if ("L".equals(d[i])) {
					idx--;
				} else {
					idx++;
				}
			}
			if (idx < 0 || s.length() <= idx) {
				return true;
			}
		}
		return false;
	}
}


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

#include <iostream>

int main() {
    int N, Q;
    std::string S;
    
    std::cin >> N >> Q;
    std::cin >> S;
    
    using P = std::pair<char, char>;
    P temp, td[NMAX];
    
    for (int i=0; i<Q; ++i) {
        std::cin >> temp.first >> temp.second;
        td[i] = temp;
    }
    
    int lcur = -1;
    int rcur = N;
    for (int i=Q-1; i>=0; --i) {
        //std::cout << td[i].first << " " << td[i].second << std::endl;
        
        if (S[lcur+1]==td[i].first && td[i].second=='L') {
            lcur++;
        } else if (S[lcur-1]==td[i].first && td[i].second=='R' && lcur!=-1) {
            lcur--;
        } else if (S[rcur-1]==td[i].first && td[i].second=='R') {
            rcur--;
        } else if (S[rcur+1]==td[i].first && td[i].second=='L' && rcur!=N) {
            rcur++;
        }
        
        //std::cout << lcur << " " << rcur << std::endl;
    }
    int ans = N;
    if (lcur >= 0) ans -= lcur+1;
    if (rcur <= N-1) ans -= (N-1) - rcur + 1;
    std::cout << ans << std::endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:11:16: error: 'NMAX' was not declared in this scope
   11 |     P temp, td[NMAX];
      |                ^~~~
a.cc:15:9: error: 'td' was not declared in this scope; did you mean 'tm'?
   15 |         td[i] = temp;
      |         ^~
      |         tm
a.cc:23:24: error: 'td' was not declared in this scope; did you mean 'tm'?
   23 |         if (S[lcur+1]==td[i].first && td[i].second=='L') {
      |                        ^~
      |                        tm
Language: C++

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

int main(){
  int n,q,i,j,ans=0;
  cin >> n >> q;
  string s;
  cin >> s;
  vector<int> g(n+2);
  for(i=1; i<n+1; i++){
    g[i]=1;
    ans++;
  }
  
  char t,d;
  int move;
  for(i=0; i<q; i++){
    cin >> t >> d;
    move= d=='R' ? 1 : -1;
    
    if(move==-1){
      for(j=0; j<n; j++){
        if(s[j]==t){
          g[j]+=g[j+1]; g[j+1]=0;
        }
      }
    }else{
      for(j=n-1; j>=0; j--){
        if(s[j]==t){
          g[j+2]+=g[j+1]; g[j+1]=0;
        }
      }
    }
  
  cout << ans-g[0]-g[n+1];
      
}

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

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

using namespace std;

// x番目のゴーレムをk番目のマスに移動させられるか確認する
bool checkLeft(int x, int k, string &s, vector<char> &t, vector<char> &d)
{
	for(int i = 0; i < t.size(); ++i)
	{
		if(t[i] == s[x])
		{
			if(d[i] == 'L')
			{
				--x;
			}
			else
			{
				++x;
			}
		}

		if(s[x] == '_')
		{
			return x == k;
		}
	}

	return false;
}

int main()
{
	int n, q;
	string s;

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

	s = "_" + s + "_";

	vector<char > t(q);
	vector<vector<char> > d(2, vector<char>(q));
	for(int i = 0; i < q; ++i)
	{
		cin >> t[i] >> d[0][i];
		d[1][i] = (d[0][i] == 'L' ? 'R' : 'L');
	}

	//cout << "Hello" << endl;

	int bounds[2];
	int golem = n;

	for(int i = 0; i < 2; ++i)
	{
		//cout << "UKI!" << endl;
		int lb = 0, m, ub = n + 1;
		//for(int j = 0; j < 20; ++j)
		while(ub - lb > 1)
		{
			m = (ub + lb) / 2;
			//cout << lb << " " << m << " " << ub << endl;
			if(checkLeft(m, 0, s, t, d[i]))
			{
				lb = m;
			}
			else
			{
				ub = m;
			}
		}

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

		bounds[i] = lb;
		golem -= lb;
	}

	
	//cout << "Left " << bounds[0] << endl;
	//cout << "Right " << bounds[1] << endl;
	cout << golem << endl;
}

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

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

#define MOD 1000000007
using ll = long long;
using namespace std;

int N, Q;
string S;
vector<char> t, d;

int isDel(int now) {
    for (int i = 0; i < Q; i++)
    {
        if (now != -1 && now != N && S[now] == t[i]) {
            if (d[i] == 'L') {
                now--;
            }
            else {
                now++;
            }
        }
    }
    if (now == -1) {
        return -1;
    }
    else if (now == N) {
        return 1;
    }
    else {
        return 0;
    }
}

int main() {
    cin >> N >> Q >> S;
    for (int i = 0; i < Q; i++)
    {
        char a, b;
        cin >> a >> b;
        t.push_back(a);
        d.push_back(b);
    }
    // Find the left edge
    int left = 0, right = N;
    while (right - left > 1) {
        int mid = (left + right) / 2;
        if (isDel(mid) >= 0) {
            right = mid;
        }
        else {
            left = mid;
        }
    }
    int LE = right;
    // Find the right edge
    left = 0, right = N;
    while (right - left > 1) {
        int mid = (left + right) / 2;
        if (isDel(mid) <= 0) {
            left = mid;
        }
        else {
            right = mid;
        }
    }
    int RE = left;
    cout << RE - LE + 1 << endl;
    cin >> <>;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:72:12: error: expected primary-expression before '<' token
   72 |     cin >> <>;
      |            ^
a.cc:72:13: error: expected primary-expression before '>' token
   72 |     cin >> <>;
      |             ^
a.cc:72:14: error: expected primary-expression before ';' token
   72 |     cin >> <>;
      |              ^
Language: C++

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

int main(){
	ll n,q;
	cin >> n >> q;
	string a;
	cin >> a;
	vector <string> left;
	vector <string> right;
	for (int z=0;z<q;z++){
		string b,c;
		cin >> b >> c;
		if (c == "R"){
			right.push_back(b);
		} else {
			left.push_back(b);
		}
	}
	ll cu = left.size()-1;
	ll count = 0;
	for (int z=0;z<n;z++){
		while (cu > -1 && left[cu][0] != a[z]){
			cu--;
		}
		if (cu > -1)
		count++;
	}
	cu = 0;
	for (int z=n-1;z>-1;z--){
		while (cu < right.size() && right[cu][0] != a[z]){
			cu++;
		}
		if (cu < right.size())
		count++;
	}
	cout << max(0,n-count) << endl;
	cin >> n;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:38:20: error: no matching function for call to 'max(int, ll)'
   38 |         cout << max(0,n-count) << endl;
      |                 ~~~^~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
a.cc:38:20: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'll' {aka 'long long int'})
   38 |         cout << max(0,n-count) << endl;
      |                 ~~~^~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
 5706 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note:   template argument deduction/substitution failed:
a.cc:38:20: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   38 |         cout << max(0,n-count) << endl;
      |                 ~~~^~~~~~~~~~~
Language: C++

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

int main(){
	ll n,q;
	cin >> n >> q;
	string a;
	cin >> a;
	vector <string> left;
	vector <string> right;
	for (int z=0;z<q;z++){
		string b,c;
		cin >> b >> c;
		if (c == "R"){
			right.push_back(b);
		} else {
			left.push_back(b);
		}
	}
	ll cu = left.size()-1;
	ll count = 0;
	for (int z=0;z<n;z++){
		while (cu > -1 && left[cu][0] != a[z]){
			cu--;
		}
		if (cu > -1)
		count++;
	}
	cu = 0;
	for (int z=n-1;z>-1;z--){
		while (cu < right.size() && right[cu][0] != a[z]){
			cu++;
		}
		if (cu < right.size())
		count++;
	}
	cout << min(0,n-count) << endl;
	cin >> n;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:38:20: error: no matching function for call to 'min(int, ll)'
   38 |         cout << min(0,n-count) << endl;
      |                 ~~~^~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note:   template argument deduction/substitution failed:
a.cc:38:20: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'll' {aka 'long long int'})
   38 |         cout << min(0,n-count) << endl;
      |                 ~~~^~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
 5686 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
 5696 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note:   template argument deduction/substitution failed:
a.cc:38:20: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   38 |         cout << min(0,n-count) << endl;
      |                 ~~~^~~~~~~~~~~
Language: C++

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

//binary search to get the left and right boundary
using namespace std;
int main()
{
	int N, Q;
	cin >> N >> Q;
	string s;
	cin >> s;
	vector<char> t(Q);
	vector<char> d(Q);
	for(int i = 0; i < Q; i += 0)
	{
		cin >> t[i] >> d[i];
	}

	int L = 0, R = N - 1; 
	int left = 0, right = N - 1;
	while(left < right)
	{
		int mid = left + ((right - left - 1) / 2) + 1;
		int inx = mid;
		for(int i = 0; i < Q; i += 1)
		{
			if(s[inx] == t[i])
			{
				if(d[i] == 'L')
					inx -= 1;
				else
					inx += 1;
			}
			if(inx < 0 || inx > N - 1) break;
		}

		if(inx < 0)
		{
			left = mid;
			L = left;
		}
		else
			right = mid - 1;
	}

	left = 0, right = N - 1;
	while(left < right)
	{
		int mid = left + (right - left) / 2;
		int inx = mid;
		for(int i = 0; i < Q; i += 1)
		{
			if(s[inx] == t[i])
			{
				if(d[i] == 'R')
					inx += 1;
				else
					inx -= 1;
			}
			if(inx < 0 || inx > N - 1) break;
		}

		if(inx > N - 1)
			right = mid;
			R = right;
		else
			left = mid + 1;
	}

	std::cout << std::to_string(R - L + 1) << std::endl;

	return 0;
}



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

#include<bits/stdc++.h>

using namespace std;
 
char t[200010];
char d[200010];
char s[200010];
int main(){ 
  int n,q;cin>>n>>q;
  REP(i,n) cin>>s[i+1];
  REP(i,q) cin>>t[i]>>d[i];
  s[0]=s[n+1]='_';
 
  int l=0,r=n+1;
  for(int i=q-1;i>=0;i--){
    if(d[i]=='L'){
      if(s[l+1]==t[i]) l++;
      //if(s[r  ]==t[i]) r++;
    }else{
      if(s[r-1]==t[i]) r--;
      //if(s[l  ]==t[i]) l--;
    }
    //cout<<l<<" "<<r<<endl;
  }
  cout<<r-l-1<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:10:7: error: 'i' was not declared in this scope
   10 |   REP(i,n) cin>>s[i+1];
      |       ^
a.cc:10:3: error: 'REP' was not declared in this scope
   10 |   REP(i,n) cin>>s[i+1];
      |   ^~~
Language: C++

#include"bits/stdc++.h"
using namespace std;
using ll = int64_t;

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

    //[left, right]にあるものは生き残る
    ll left = 0, right = N - 1;

    for (ll i = Q-1;i>=0;i--) {
        if (d[i] == 'L') {
            if (t[i] == s[left]) {
                left++;
            }
            //範囲を広げている
            if (right < N-1 && t[i] == s[right+1]) {
                right++;
            }
        } else {
            if (t[i] == s[right]) {
                right--;
            }
            //範囲を広げている
            if (left > 0 && t[i] == s[left-1]) {
                left--;
            }
        }
    }

    cout << max(right - left + 1,0) << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:37:16: error: no matching function for call to 'max(ll, int)'
   37 |     cout << max(right - left + 1,0) << endl;
      |             ~~~^~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
a.cc:37:16: note:   deduced conflicting types for parameter 'const _Tp' ('long int' and 'int')
   37 |     cout << max(right - left + 1,0) << endl;
      |             ~~~^~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
 5706 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note:   template argument deduction/substitution failed:
a.cc:37:16: note:   mismatched types 'std::initializer_list<_Tp>' and 'long int'
   37 |     cout << max(right - left + 1,0) << endl;
      |             ~~~^~~~~~~~~~~~~~~~~~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;
typedef pair<ll, ll> mp;


/*
範囲を後ろから見て狭めていく。O(n)
*/

ll n,q,ans=0,l,r;
string s;
char t[200010],d[200010];

int main(void){
	cin>>n>>q>>s;
	s=" "+s;
	rep(i,q)cin>>t[i]>>d[i];
	//生き残る範囲
	l=1;r=n;
	irep(i,q){
		if(t[i]==s[l] && d[i]=='L')l++;
		if(t[i]==s[r] && d[i]=='R')r--;
	}
	cout<<min(0,r-l+1)<<endl;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:29:18: error: no matching function for call to 'min(int, ll)'
   29 |         cout<<min(0,r-l+1)<<endl;
      |               ~~~^~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note:   template argument deduction/substitution failed:
a.cc:29:18: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'll' {aka 'long long int'})
   29 |         cout<<min(0,r-l+1)<<endl;
      |               ~~~^~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
 5686 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
 5696 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note:   template argument deduction/substitution failed:
a.cc:29:18: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   29 |         cout<<min(0,r-l+1)<<endl;
      |               ~~~^~~~~~~~~
Language: C++

// ConsoleApplication1.cpp : 此文件包含 "main" 函数。程序执行将在此处开始并结束。
//

#include "pch.h"
#include<iostream>
#include<algorithm>
#include<limits.h>
#include<map>
#include<vector>
#include<string>
using namespace std;
vector<string> vec;
int main()
{
	int len, n;
	cin >> len >> n;
	vec.resize(len);
	for (int i = 0; i < len; i++)
	{
		char c;
		cin >> c;
		vec[i] = c;
	}
	for (int i = 0; i < n; i++)
	{
		char b, m;
		scanf("\n%c %c", &b, &m);
		if (m == 'L')
		{
			for (int j = 0; j < len; j++)
			{
				if (count(vec[j].begin(), vec[j].end(), b) != 0)
				{
					if (j != 0)
						vec[j - 1] += vec[j];
					vec[j] = "";
				}
			}
		}
		else
		{
			for (int j = len - 1; j >= 0; j--)
			{
				if (count(vec[j].begin(), vec[j].end(), b) != 0)
				{
					if (j != len - 1)
						vec[j + 1] += vec[j];
					vec[j] = "";
				}
			}
		}

		/*cout << i << ". ";
		for (auto str : vec)
		{
			cout << str << " ";
		}
		cout << endl;*/
	}
	int ans = 0;
	for (int i = 0; i < len; i++)
	{
		ans += vec[i].length();
	}
	cout << ans;
	return 0;
}

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

#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())//vectorの降順ソート
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;
typedef tuple<ll, ll, ll> T;

int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

int n,q;
vector<char> field(200020);
vector<char> t(200020),d(200020);
int ans1=0,ans2=0;

bool isOk1(int now){
    int tmp=now;
    //cout<<now<<endl;
    REP(i,q){
        char ns=field[tmp];
        //cout<<tmp<<":"<<ns<<":"<<t[i]<<endl;
        if(ns==t[i]){
            if(d[i]=='L'){
                if(tmp-1<0){
                    ans1 = max(ans1,now+1);
                    return true;
                }
                else tmp--;
            }
            else{
                if(tmp+1>=n){
                    ans1 = max(ans1,n-now);
                    return true;
                }
                else tmp++;
            }
        }
    }
    return false;
}
bool isOk2(int now){
    int tmp=now;
    //cout<<now<<endl;
    REP(i,q){
        char ns=field[tmp];
        //cout<<ns<<":"<<t[i]<<endl;
        if(ns==t[i]){
            if(d[i]=='L'){
                if(tmp-1<0){
                    ans2 = max(ans2,now+1);
                    return true;
                }
                else tmp--;
            }
            else{
                if(tmp+1>=n){
                    //cout<<"R:"<<n<<":"<<now<<endl;
                    ans2 = max(ans2,n-now);
                    return true;
                }
                else tmp++;
            }
        }
    }
    return false;
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin>>n>>q;

    REP(i,n) cin>>field[i];
    //map<char,int> mp;
    //bool Left=false,Right=false;
    
    REP(i,q){
        cin>>t[i]>>d[i];
    }

    int l = -1;
    int r = n/2;
    while(r-l>1){
        int m=l + (r-l) / 2;
        //cout<<m<<endl;
        if(!isOk1(m)) r=m;
        else l=m;
    }

    l = n/2;
    r = n;
    while(r-l>1){
        int m=l + (r-l) / 2;
        //cout<<m<<endl;
        if(isOk2(m)) r=m;
        else l=m;
    }
    //cout<<ans1<<":"<<ans2<<endl;
    cout<<n-(as1+ans2)<<endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:110:14: error: 'as1' was not declared in this scope; did you mean 'ans1'?
  110 |     cout<<n-(as1+ans2)<<endl;
      |              ^~~
      |              ans1
Language: C++

#include <algorithm>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

#define SREP(s, i, m) for(unsigned int i = s; i < m; ++i)
#define REP(i, m) SREP(0,i,m)

using namespace std;
#ifdef _MSC_VER
using LONG = __int64;
using ULONG = unsigned __int64;
#else
using LONG = long long int;
using ULONG = unsigned long long int;
#endif

using namespace std;

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

bool drop(int index) {
    for (int i = 0; i < Q; ++i) {
        if (s[index] == t[i]) {
            if (d[i] == 'L') {
                index--;
            } else {
                index++;
            }
        }
        if (index < 0 || index >= N) return true;
    }
    return false;
}

int solve() {
    int ok = 0, ng = N;
    while (abs(ng - ok) > 1) {
        int mid = (ok + ng) / 2;
        if(drop(mid)) {
            ng = mid;
        } else {
            ok = mid;
        }
    }

    int ok1 = ok, ng1 = -1;
    while(abs(ok1 - ng1) > 1) {
        int mid = (int)ceil((ok1 + ng1) / 2.0);
        if(drop(mid)) {
            ng1 = mid;
        } else {
            ok1 = mid;
        }
    }

    int ok2 = ok, ng2 = N;
    while(abs(ok2 - ng2) > 1) {
        int mid = (ok2 + ng2) / 2;
        if(drop(mid)) {
            ng2 = mid;
        } else {
            ok2 = mid;
        }
    }

    return N - (ok1 + (N - 1 - ok2));
}

int main() {
    cin >> N >> Q;
    cin >> s;
    t.resize(Q);
    d.resize(Q);
    REP(i, Q) cin >> t[i] >> d[i];
    cout << solve() << endl;
}

Compiler output:
a.cc: In function 'int solve()':
a.cc:59:24: error: 'ceil' was not declared in this scope
   59 |         int mid = (int)ceil((ok1 + ng1) / 2.0);
      |                        ^~~~
Language: C

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

int main(void){
    int N, Q, total, i, j, k;
    char t, d;
    

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

    char str[N];
    int golem[N];
    for(i=0; i<N; i++) golem[i] = 1;
    total = N;
    scanf("%s", str);
    getchar();

    char alpha[26];
    int alnum[26] = {}, alplace[26][N];

    alpha[0] = 'A';
    for(i=1; i<26; i++) alpha[i] = alpha[i-1] + 1;

    for(i=0; i<N; i++){
        for(j = 0; j<26; j++){
            if(str[i] == alpha[j]){
                alplace[j][alnum[j]] = i;
                alnum[j] ++;
                break;
            }
        }
    }

    for(i=0; i<Q; i++){
        scanf("%c %c", &t, &d);
        getchar();
        if(d == 'L'){
            for(j = 0; j<26; j++){
                if(t == alpha[j]){
                    for(k = 0; k=<alnum[j]; k++){
                        if(alplace[j][k] == 0)total -= golem[alplace[j][k]];
                        else golem[alplace[j][k]-1] += golem[alplace[j][k]];
                        golem[alplace[j][k]] = 0;
                    }
                }
                break;
            }
        }else if(d == 'R'){
            for(j = 0; j<26; j++){
                if(t == alpha[j]){
                    for(k = 0; k=<alnum[j]; k++){
                        if(alplace[j][k] == 0)total -= golem[alplace[j][k]];
                        else golem[alplace[j][k]+1] += golem[alplace[j][k]];
                        golem[alplace[j][k]] = 0;
                    }
                }
                break;
            }
        }

    }
    printf("%d\n", total);
    return 0;
}

Compiler output:
main.c: In function 'main':
main.c:41:34: error: expected expression before '<' token
   41 |                     for(k = 0; k=<alnum[j]; k++){
      |                                  ^
main.c:52:34: error: expected expression before '<' token
   52 |                     for(k = 0; k=<alnum[j]; k++){
      |                                  ^
Language: C++

#include <bits/stdc++.h>

using namespace std;
#define _for(i,j,N) for(int i = (j);i < (N);i++)
#define _rep(i,j,N) for(int i = (j);i <= (N);i++)
#define ALL(x) x.begin(),x.end()
#define LL long long

int N,Q;
const int maxn = 200005;
map<int,int> vi[256];
//int nums[maxn];

int get_int(){int x;scanf("%d",&x);return x;}
double get_double(){double x;scanf("%lf",&x);return x;}
long long get_long(){long long x;scanf("%lld",&x);return x;}
vector<char> vc;

void tests(){
    ;
}

int main()
{
    i//os::sync_with_stdio(false);
    scanf("%d %d",&N,&Q);getchar();
    _for(i,0,N){
        char ch = getchar();
        vi[ch][i] = 1;
        vc.push_back(ch);
    }
    getchar();


    //_for(i,0,N) nums[i] = 1;

    int k = 0;
    _for(i,0,Q){

        char ch = getchar();
        getchar();
        char instr = getchar();
        getchar();

        if(instr == 'L'){
            int num = ch;
            map<int,int> copys = vi[num];
            vi[num].clear();

            for(auto &a:copys){
                int pos = a.first;
                if(pos == 0){
                    k+=a.second;
                }
                else{
                    char ch2 = vc[pos-1];
                    vi[ch2][pos-1] += a.second;
                }
            }
        }
        if(instr == 'R'){
            //char ch = s[0];
            int num = ch;
            map<int,int> copys = vi[num];
            vi[num].clear();

            for(auto &a:copys){
                int pos = a.first;
                if(pos == N-1){
                    k+=a.second;
                }
                else{
                    char ch2 = vc[pos+1];
                    vi[ch2][pos+1] += a.second;
                }
            }
        }
    }

    printf("%d\n",N-k);

    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:25:5: error: 'i' was not declared in this scope; did you mean 'vi'?
   25 |     i//os::sync_with_stdio(false);
      |     ^
      |     vi
Language: C++

#include <algorithm>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

#define SREP(s, i, m) for(unsigned int i = s; i < m; ++i)
#define REP(i, m) SREP(0,i,m)

using namespace std;
#ifdef _MSC_VER
using LONG = __int64;
using ULONG = unsigned __int64;
#else
using LONG = long long int;
using ULONG = unsigned long long int;
#endif

using namespace std;

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

bool drop(int index) {
    for (int i = 0; i < N; ++i) {
        if (s[index] == t[i]) {
            if (d[i] == 'L') {
                index--;
            } else {
                index++;
            }
        }
        if (index < 0 || index >= N) return true;
    }
    return false;
}

int solve() {
    int ok = 0, ng = N;
    while (abs(ng - ok) > 1) {
        int mid = (ok + ng) / 2;
        if(drop(mid)) {
            ng = mid;
        } else {
            ok = mid;
        }
    }

    int ok1 = ok, ng1 = -1;
    while(abs(ok1 - ng1) > 1) {
        int mid = (int)ceil((ok1 + ng1) / 2.0);
        if(drop(mid)) {
            ng1 = mid;
        } else {
            ok1 = mid;
        }
    }

    int ok2 = ok, ng2 = N;
    while(abs(ok2 - ng2) > 1) {
        int mid = (ok2 + ng2) / 2;
        if(drop(mid)) {
            ng2 = mid;
        } else {
            ok2 = mid;
        }
    }

    return N - (ok1 + (N - 1 - ok2));
}

int main() {
    cin >> N >> Q;
    cin >> s;
    t.resize(Q);
    d.resize(Q);
    REP(i, Q) cin >> t[i] >> d[i];
    cout << solve() << endl;
}

Compiler output:
a.cc: In function 'int solve()':
a.cc:59:24: error: 'ceil' was not declared in this scope
   59 |         int mid = (int)ceil((ok1 + ng1) / 2.0);
      |                        ^~~~
Language: C++

#include <iostream>
#include <map>
#include <vector>
using namespace std;
int main() {
    int N, Q; cin >> N >> Q;
    string S; cin >> S;
    char t[Q]; char d[Q]; for (int i = 0; i < Q; ++i) cin >> t[i] >> d[i];
    
    map<char, vector<int>> m;
    for (int i = 0; i < N; ++i) m[S[i]].push_back(i);
    
    vector<int> s(N, 1);
    
    for (int i = 0; i < Q; ++i) {
        for (int j = 0; j < m[t[i]].size(); ++j) {
            index = m[t[i]][j];
            if (s[index] > 0) {
                int x =s[index];
                s[index] -=x;
                if (d[i] == 'R' && index != N-1) s[index + 1] += x;
                if (d[i] == 'L' && index != 0) s[index - 1] += x;
            }
        }
    }
  
    int res = 0; 
    for (int i = 0; i < N; ++i) res += s[i];
    cout << res << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:17:13: error: 'index' was not declared in this scope
   17 |             index = m[t[i]][j];
      |             ^~~~~
Language: C++

#include "bits/stdc++.h"

using namespace std;

#define int long long
#define ll long long
typedef pair<int, int> P;
#define mod 1000000007
#define INF (1LL<<60)

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define YES cout << "YES" << endl;
#define Yes cout << "Yes" << endl;
#define NO cout << "NO" << endl;
#define No cout << "No" << endl;

int N, Q;
string s;
char t[223456], d[223456];

// 左に消えるかどうか
bool isOK(int idx){
	set<char> se;
	se.insert(s[idx]);
	int current = idx;
	rep(i, Q){
		if (se.count(s[idx])){
			if (d[i] == 'L') current--;
			else current++;
			se.insert(s[current]);
			if (current < 0) return true;
		}
	}
	return false;
}

// 右に消えるかどうか
bool isOK2(int idx){
	set<char> se;
	se.insert(s[idx]);
	int current = idx;
	rep(i, Q){
		if (se.count(s[idx])){
			if (d[i] == 'L') current--;
			else current++;
			se.insert(s[current]);
			if (current >= N) return true;
		}
	}
	return false;
}


signed main(){

	cin >> N >> Q;
	cin >> s;

	int amin[26], amax[26], current[26];
	rep(i, 26){
		amin[i] = INF;
		amax[i] = -INF;
		current[i] = 0;
	}
	rep(i, Q){
		cin >> t[i] >> d[i];
		int idx = t[i] - 'A';
		if (d[i] == 'L')
			current[idx]--;
		else
			current[idx]++;
	}

	// 左側から何番目までが左に消えるか
	int ng = -1;
	int ok = N;

	while (abs(ok - ng) > 1){
		int mid = (ok + ng) / 2;
		if (isOK(mid)) ok = mid;
		else ng = mid;
	}
	int left = ok;


	// 右側から何番目までが左に消えるか
	int ng = -1;
	int ok = N;

	while (abs(ok - ng) > 1){
		int mid = (ok + ng) / 2;
		if (isOK2(mid)) ok = mid;
		else ng = mid;
	}
	cout << N - left - ok << endl;

	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:87:13: error: redeclaration of 'long long int ng'
   87 |         int ng = -1;
      |             ^~
a.cc:75:13: note: 'long long int ng' previously declared here
   75 |         int ng = -1;
      |             ^~
a.cc:88:13: error: redeclaration of 'long long int ok'
   88 |         int ok = N;
      |             ^~
a.cc:76:13: note: 'long long int ok' previously declared here
   76 |         int ok = N;
      |             ^~