Language: C++

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

int main(){
	int N,Q;
    std::cin >> N >> Q;
    std::string s = "";
    std::cin >> s;
    std::string s2((int)N,'0');
    int numR = 0;
    int numB = 0;
    char t='a';
    char d='a';
    std::vector<std::vector<int>> A;
    A.assign(26, std::vector<int>(N,0));
    std::vector<std::vector<int>> G;
    G.assign(Q+1, std::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;
    }
    // std::cout << "----G:---" <<std::endl;
    // for(int i=0;i<(Q+1);i++){
    //     for(int j=0;j<N;j++){
    //         std::cout << G[i][j];
    //     }
    //     std::cout << std::endl;
    // }
    // std::cout << "---------" <<std::endl;

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

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

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


Compiler output:
a.cc: In function 'int main()':
a.cc:16:10: error: 'vector' is not a member of 'std'
   16 |     std::vector<std::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:22: error: 'vector' is not a member of 'std'
   16 |     std::vector<std::vector<int>> A;
      |                      ^~~~~~
a.cc:16:22: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
a.cc:16:29: error: expected primary-expression before 'int'
   16 |     std::vector<std::vector<int>> A;
      |                             ^~~
a.cc:17:5: error: 'A' was not declared in this scope
   17 |     A.assign(26, std::vector<int>(N,0));
      |     ^
a.cc:17:23: error: 'vector' is not a member of 'std'
   17 |     A.assign(26, std::vector<int>(N,0));
      |                       ^~~~~~
a.cc:17:23: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
a.cc:17:30: error: expected primary-expression before 'int'
   17 |     A.assign(26, std::vector<int>(N,0));
      |                              ^~~
a.cc:18:10: error: 'vector' is not a member of 'std'
   18 |     std::vector<std::vector<int>> G;
      |          ^~~~~~
a.cc:18:10: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
a.cc:18:22: error: 'vector' is not a member of 'std'
   18 |     std::vector<std::vector<int>> G;
      |                      ^~~~~~
a.cc:18:22: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
a.cc:18:29: error: expected primary-expression before 'int'
   18 |     std::vector<std::vector<int>> G;
      |                             ^~~
a.cc:19:5: error: 'G' was not declared in this scope
   19 |     G.assign(Q+1, std::vector<int>(N,0));
      |     ^
a.cc:19:24: error: 'vector' is not a member of 'std'
   19 |     G.assign(Q+1, std::vector<int>(N,0));
      |                        ^~~~~~
a.cc:19:24: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
a.cc:19:31: error: expected primary-expression before 'int'
   19 |     G.assign(Q+1, std::vector<int>(N,0));
      |                               ^~~