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;#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()
{    ios::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);
    }
 
 
    //_for(i,0,N) nums[i] = 1;
 
    int k = 0;
    _for(i,0,Q){
        string s;
        string instr;
        cin >> s >> instr;
        if(instr == "L"){
            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 == 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;
}
 
void tests(){
    ;
}
 
int main()
{    ios::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);
    }
 
 
    //_for(i,0,N) nums[i] = 1;
 
    int k = 0;
    _for(i,0,Q){
        string s;
        string instr;
        cin >> s >> instr;
        if(instr == "L"){
            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 == 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:17:17: error: stray '#' in program
   17 | vector<char> vc;#include <bits/stdc++.h>
      |                 ^
a.cc:17:18: error: 'include' does not name a type
   17 | vector<char> vc;#include <bits/stdc++.h>
      |                  ^~~~~~~
a.cc:25:5: error: redefinition of 'int N'
   25 | int N,Q;
      |     ^
a.cc:9:5: note: 'int N' previously declared here
    9 | int N,Q;
      |     ^
a.cc:25:7: error: redefinition of 'int Q'
   25 | int N,Q;
      |       ^
a.cc:9:7: note: 'int Q' previously declared here
    9 | int N,Q;
      |       ^
a.cc:26:11: error: redefinition of 'const int maxn'
   26 | const int maxn = 200005;
      |           ^~~~
a.cc:10:11: note: 'const int maxn' previously defined here
   10 | const int maxn = 200005;
      |           ^~~~
a.cc:27:14: error: redefinition of 'std::map<int, int> vi [256]'
   27 | map<int,int> vi[256];
      |              ^~
a.cc:11:14: note: 'std::map<int, int> vi [256]' previously declared here
   11 | map<int,int> vi[256];
      |              ^~
a.cc:30:5: error: redefinition of 'int get_int()'
   30 | int get_int(){int x;scanf("%d",&x);return x;}
      |     ^~~~~~~
a.cc:14:5: note: 'int get_int()' previously defined here
   14 | int get_int(){int x;scanf("%d",&x);return x;}
      |     ^~~~~~~
a.cc:31:8: error: redefinition of 'double get_double()'
   31 | double get_double(){double x;scanf("%lf",&x);return x;}
      |        ^~~~~~~~~~
a.cc:15:8: note: 'double get_double()' previously defined here
   15 | double get_double(){double x;scanf("%lf",&x);return x;}
      |        ^~~~~~~~~~
a.cc:32:11: error: redefinition of 'long long int get_long()'
   32 | long long get_long(){long long x;scanf("%lld",&x);return x;}
      |           ^~~~~~~~
a.cc:16:11: note: 'long long int get_long()' previously defined here
   16 | long long get_long(){long long x;scanf("%lld",&x);return x;}
      |           ^~~~~~~~
a.cc:33:14: error: redefinition of 'std::vector<char> vc'
   33 | vector<char> vc;
      |              ^~
a.cc:17:14: note: 'std::vector<char> vc' previously declared here
   17 | vector<char> vc;#include <bits/stdc++.h>
      |              ^~
a.cc:97:6: error: redefinition of 'void tests()'
   97 | void tests(){
      |      ^~~~~
a.cc:35:6: note: 'void tests()' previously defined here
   35 | void tests(){
      |      ^~~~~
a.cc:101:5: error: redefinition of 'int main()'
  101 | int main()
      |     ^~~~
a.cc:39:5: note: 'int main()' previously defined here
   39 | int main()
      |     ^~~~