Language: C++

table= {}
DP = [-1]*200
def solve(dict,key):
    global table
    if key in table:
    #    print('key=',key)
        return table[key]
    ret = []
    #print(key)
    for i in dict[key]:
        if i[0] == '[':
            ret.append(i[1:-1])
        else:
            ret += (solve(dict, i))
    if len(ret) > 200:
        for i in table.keys():
            table[i]=''
            return ''
    table[key] = ret
    #print(key)
    return ret

def count(lis,index,a,t,g,c,a_,t_,g_,c_):
    if a_ > a or t_ > t or c_ > c or g_ > g:
    #    print(a,a_,t,t_,g,g_,c,c_,'  ',lis[index-1])
        return 0
    if index == len(lis):
#        print(a_,t_,g_,c_)
        return 1
    ret = 0
#    print(index)
#    print(a,a_,t,t_,g,g_,c,c_)
    for i in lis[index]:
#        print(i)
        if i =='A':
            ret += count(lis,index + 1,a,t,g,c,a_+1,t_,g_,c_)
        elif i =='T':
            ret += count(lis,index + 1,a,t,g,c,a_,t_+1,g_,c_)
        elif i =='C':
            ret += count(lis,index + 1,a,t,g,c,a_,t_,g_,c_+1)
        elif i == 'G':
            ret += count(lis,index + 1,a,t,g,c,a_,t_,g_+1,c_)
    return ret
    
Na, Nt, Ng, Nc = [int(i) for i in input().split()]
m = int(input())

dict = {}

for i in range(m):
    key, value = [i for i in input().split(': ')]
    if i == 0:
        aa = key
    value = value.split()
    dict[key] = value

lis = solve(dict, aa)
#print(lis)
if len(lis)==Na+Nt+Ng+Nc:
    print(count(lis,0,Na,Nt,Ng,Nc,0,0,0,0))
else:
    print(0)



Compiler output:
a.cc:6:10: error: invalid preprocessing directive #print
    6 |     #    print('key=',key)
      |          ^~~~~
a.cc:9:6: error: invalid preprocessing directive #print
    9 |     #print(key)
      |      ^~~~~
a.cc:17:22: error: empty character constant
   17 |             table[i]=''
      |                      ^~
a.cc:18:20: error: empty character constant
   18 |             return ''
      |                    ^~
a.cc:20:6: error: invalid preprocessing directive #print
   20 |     #print(key)
      |      ^~~~~
a.cc:25:10: error: invalid preprocessing directive #print
   25 |     #    print(a,a_,t,t_,g,g_,c,c_,'  ',lis[index-1])
      |          ^~~~~
a.cc:28:10: error: invalid preprocessing directive #print
   28 | #        print(a_,t_,g_,c_)
      |          ^~~~~
a.cc:31:6: error: invalid preprocessing directive #print
   31 | #    print(index)
      |      ^~~~~
a.cc:32:6: error: invalid preprocessing directive #print
   32 | #    print(a,a_,t,t_,g,g_,c,c_)
      |      ^~~~~
a.cc:34:10: error: invalid preprocessing directive #print
   34 | #        print(i)
      |          ^~~~~
a.cc:51:44: warning: multi-character character constant [-Wmultichar]
   51 |     key, value = [i for i in input().split(': ')]
      |                                            ^~~~
a.cc:58:2: error: invalid preprocessing directive #print
   58 | #print(lis)
      |  ^~~~~
a.cc:1:1: error: 'table' does not name a type; did you mean 'mutable'?
    1 | table= {}
      | ^~~~~
      | mutable
a.cc:2:1: error: 'DP' does not name a type
    2 | DP = [-1]*200
      | ^~
a.cc:50:1: error: expected unqualified-id before 'for'
   50 | for i in range(m):
      | ^~~