Language: C++

#include<bits/stdc++.h>
using namespace std;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<vvvi> vvvvi;
#define ll long long;
const ll MOD=1e9+7;

string get_str(int& p,string& s){
  string res="";
  while(isalpha(s[p])){
    res+=s[p];
    p++;
  }
  return res;
}

const int MAX_LEN=300;

int main(){
  int na,nt,ng,nc;
  cin>>na>>nt>>ng>>nc;
  int m;
  cin>>m;
  vector<string> line(m);
  cin.ignore(1);
  for(int i=0;i<m;i++){
    getline(cin,line[i]);
  }
  vector<vector<int>> code(m);
  map<string,int> dic;

  map<char,int> DNA_MAP;
  DNA_MAP['A']=1;
  DNA_MAP['T']=2;
  DNA_MAP['G']=4;
  DNA_MAP['C']=8;
  
  for(int i=m-1;i>=0;i--){
    int p=0;
    string& s=line[i];
    string name=get_str(p,line[i]);
    dic[name]=i;
    assert(s[p]==':');
    p++;
    assert(s[p]==' ');
    p++;
    while(p<s.size() && code[i].size()<MAX_LEN){
      if(s[p]=='['){
	p++;
	string str=get_str(p,line[i]);
	assert(line[i][p]==']');
	p++;
	int val=0;
	for(int j=0;j<str.size();j++){
	  val|=(DNA_MAP[str[j]]);
	}
	code[i].push_back(val);
	p++;
      }
      else{
	string str=get_str(p,line[i]);
	p++;
	int index=dic[str];
	assert(i<index);
	code[i].insert(code[i].end(),code[index].begin(),code[index].end());
      }
    }
  }

  if(code[0].size()!=na+nt+ng+nc){
    cout<<0<<endl;
    return 0;
  }
  else{
    vvvvi dp(code[0].size()+1,vvvi(na+1,vvi(nt+1,vi(ng+1,0))));
    dp[0][0][0][0]=1;
    for(int i=1;i<=code[0].size();i++){
      for(int j=0;j<=na;j++){
	for(int k=0;k<=nt;k++){
	  for(int l=0;l<=ng;l++){
	    //renew dp[i][j][k][l]
	    int val=code[0][i-1];
	    if(val%2){
	      if(j-1>=0) dp[i][j][k][l]+=dp[i-1][j-1][k][l];
	    }
	    val/=2;
	    if(val%2){
	      if(k-1>=0) dp[i][j][k][l]+=dp[i-1][j][k-1][l];
	    }
	    val/=2;
	    if(val%2){
	      if(l-1>=0) dp[i][j][k][l]+=dp[i-1][j][k][l-1];
	    }
	    val/=2;
	    if(val%2){
	      dp[i][j][k][l]+=dp[i-1][j][k][l];
	    }
	    dp[i][j][k][l]%=MOD;
	  }
	}
      }
    }

    cout<<dp[code[0].size()][na][nt][ng]<<endl;
  }

}

Compiler output:
a.cc:3:16: error: 'll' was not declared in this scope
    3 | typedef vector<ll> vi;
      |                ^~
a.cc:3:16: note: the macro 'll' had not yet been defined
a.cc:7:9: note: it was later defined here
    7 | #define ll long long;
      |         ^~
a.cc:3:18: error: template argument 1 is invalid
    3 | typedef vector<ll> vi;
      |                  ^
a.cc:3:18: error: template argument 2 is invalid
a.cc:7:17: error: declaration does not declare anything [-fpermissive]
    7 | #define ll long long;
      |                 ^~~~
a.cc:8:7: note: in expansion of macro 'll'
    8 | const ll MOD=1e9+7;
      |       ^~
a.cc:8:10: error: 'MOD' does not name a type
    8 | const ll MOD=1e9+7;
      |          ^~~
a.cc: In function 'int main()':
a.cc:77:59: error: expression list treated as compound expression in functional cast [-fpermissive]
   77 |     vvvvi dp(code[0].size()+1,vvvi(na+1,vvi(nt+1,vi(ng+1,0))));
      |                                                           ^
a.cc:78:16: error: invalid types '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type {aka int}[int]' for array subscript
   78 |     dp[0][0][0][0]=1;
      |                ^
a.cc:86:37: error: invalid types '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type {aka int}[int]' for array subscript
   86 |               if(j-1>=0) dp[i][j][k][l]+=dp[i-1][j-1][k][l];
      |                                     ^
a.cc:86:57: error: invalid types '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type {aka int}[int]' for array subscript
   86 |               if(j-1>=0) dp[i][j][k][l]+=dp[i-1][j-1][k][l];
      |                                                         ^
a.cc:90:37: error: invalid types '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type {aka int}[int]' for array subscript
   90 |               if(k-1>=0) dp[i][j][k][l]+=dp[i-1][j][k-1][l];
      |                                     ^
a.cc:90:57: error: invalid types '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type {aka int}[int]' for array subscript
   90 |               if(k-1>=0) dp[i][j][k][l]+=dp[i-1][j][k-1][l];
      |                                                         ^
a.cc:94:37: error: invalid types '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type {aka int}[int]' for array subscript
   94 |               if(l-1>=0) dp[i][j][k][l]+=dp[i-1][j][k][l-1];
      |                                     ^
a.cc:94:55: error: invalid types '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type {aka int}[int]' for array subscript
   94 |               if(l-1>=0) dp[i][j][k][l]+=dp[i-1][j][k][l-1];
      |                                                       ^
a.cc:98:26: error: invalid types '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type {aka int}[int]' for array subscript
   98 |               dp[i][j][k][l]+=dp[i-1][j][k][l];
      |                          ^
a.cc:98:44: error: invalid types '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type {aka int}[int]' for array subscript
   98 |               dp[i][j][k][l]+=dp[i-1][j][k][l];
      |                                            ^
a.cc:100:24: error: invalid types '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type {aka int}[int]' for array subscript
  100 |             dp[i][j][k][l]%=MOD;
      |                        ^
a.cc:100:29: error: 'MOD' was not declared in this scope
  100 |             dp[i][j][k][l]%=MOD;
      |                             ^~~
a.cc:106:37: error: invalid types '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type {aka int}[int]' for array subscript
  106 |     cout<<dp[code[0].size()][na][nt][ng]<<endl;
      |                                     ^