Language: C++

#include<iostream>
#include<algorithm>
#include<cstdlib>
using namespace std;

int main(){
	int N,Q;
    cin >> N >> Q;
    string s = "";
    cin >> s;
    string s2((int)N,'0');
    int numR = 0;
    int numB = 0;
    char t='a';
    char d='a';
    vector<vector<int>> A;
    A.assign(26, vector<int>(N,0));
    vector<vector<int>> G;
    G.assign(Q+1, vector<int>(N,0));

    for(int i=0;i<N;i++){
        // if(s[i] == 'A'){
        //     s2[i] = 'X';
        // }
        A[(int)s[i]-65][i] = 1;
        G[0][i] = 1;
    }
    // cout << "----G:---" <<endl;
    // for(int i=0;i<(Q+1);i++){
    //     for(int j=0;j<N;j++){
    //         cout << G[i][j];
    //     }
    //     cout << endl;
    // }
    // cout << "---------" <<endl;

    for(int i=0;i<Q;i++){
        // cout <<"i:" << i << endl;
        cin >> t >> d;
        // cout << "A[k]: ";
        // for(int j=0; j<N;j++){
        //    cout << A[(int)t-65][j]<<",";
        // }
        // cout << endl;
        if(d=='L'){
        // cout << "LEFT!!" << endl;
            G[i+1][N-1] = (1-A[(int)t-65][N-1])*G[i][N-1];
            for(int j=0;j<(N-1);j++){
                int k,l;
                k = A[(int)t-65][j+1];
                l = G[i][j+1];
                // cout << k << endl;
                // cout << l << endl;
                // cout << k*l << endl;
                G[i+1][j] = (1-A[(int)t-65][j]) * G[i][j] + A[(int)t-65][j+1] * G[i][j+1]  ;
            }        
        }
        else{
            G[i+1][0] = (1-A[(int)t-65][0])*G[i][0];
            // cout << "A0:" << A[(int)t-65][0] << endl;
            // cout << "Go:" << G[i][0] << endl;
            for(int j=1;j<N;j++){
                G[i+1][j] = (1-A[(int)t-65][j])*G[i][j] + A[(int)t-65][j-1]*G[i][j-1]  ;
            }        
        }
        
        // cout << "G[k]: ";
        // for(int j=0; j<N;j++){
        //    cout << G[i+1][j]<<",";
        // }
        // cout << endl;
    }

    // cout << "----G:---" <<endl;
    // for(int i=0;i<(Q+1);i++){
    //     for(int j=0;j<N;j++){
    //         cout << G[i][j];
    //     }
    //     cout << endl;
    // }
    // cout << "---------" <<endl;

    int nt=0;
    for(int i=0;i<N;i++){
        // if(s[i] == 'A'){
        //     s2[i] = 'X';
        // }
        nt += G[Q][i];
    }
    cout << nt << endl;
        // cout << "s: "<< s << endl;
    
        // cout << "A[0]: ";
        // for(int i=0; i<N;i++){
        //    cout << A[0][i];
        // }
        // cout << endl;
        //         cout << "A[1]: ";
        // for(int i=0; i<N;i++){
        //    cout << A[1][i];
        // }
        // cout << endl;
        //         cout << "A[2]: ";
        // for(int i=0; i<N;i++){
        //    cout << A[2][i];
        // }
        // cout << endl;
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:16:5: error: 'vector' was not declared in this scope
   16 |     vector<vector<int>> A;
      |     ^~~~~~
a.cc:4:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
    3 | #include<cstdlib>
  +++ |+#include <vector>
    4 | using namespace std;
a.cc:16:19: error: expected primary-expression before 'int'
   16 |     vector<vector<int>> A;
      |                   ^~~
a.cc:17:5: error: 'A' was not declared in this scope
   17 |     A.assign(26, vector<int>(N,0));
      |     ^
a.cc:17:25: error: expected primary-expression before 'int'
   17 |     A.assign(26, vector<int>(N,0));
      |                         ^~~
a.cc:18:19: error: expected primary-expression before 'int'
   18 |     vector<vector<int>> G;
      |                   ^~~
a.cc:19:5: error: 'G' was not declared in this scope
   19 |     G.assign(Q+1, vector<int>(N,0));
      |     ^
a.cc:19:26: error: expected primary-expression before 'int'
   19 |     G.assign(Q+1, vector<int>(N,0));
      |                          ^~~