func_code_string: #include <bits/stdc++.h>   using namespace std;   const int INF = 1000000007;   const int N = 2020;   struct trie {     trie *c[26];     int cnt;   } * root, *nil;   string s1, s2, s3;   int n, l, r, f[N][N], ans;   trie *new_node() {     trie *node = new (trie);     for (int i = 0; i < 26; i++) node->c[i] = nil;     node->cnt = 0;     return node;   }   void deleteTree(trie *root) {     for (int i = 0; i < 26; i++)       if (root->c[i] != nil) {         deleteTree(root->c[i]);         delete (root->c[i]);       }   }   int main() {     getline(cin, s1);     scanf( %d n , &n);     nil = new (trie);     root = new_node();     for (int i = 1; i <= n; i++) {       deleteTree(root);       for (int t = 0; t < 26; t++) root->c[t] = nil;       cin >> s2 >> l >> r;       for (int u = 0; u < s2.size(); u++) {         trie *path = root;         for (int v = u; v < s2.size(); v++) {           int q = s2[v] -  a ;           if (path->c[q] == nil) {             trie *nw = new_node();             path->c[q] = nw;           }           path = path->c[q];           path->cnt++;         }       }       for (int u = 0; u < s1.size(); u++) {         trie *path = root;         for (int v = u; v < s1.size(); v++) {           int q = s1[v] -  a ;           if (path->c[q] == nil) {             if (l == 0)               for (int t = v; t < s1.size(); t++) f[u][t]++;             break;           }           path = path->c[q];           if (path->cnt >= l && path->cnt <= r) f[u][v]++;         }       }     }     deleteTree(root);     for (int t = 0; t < 26; t++) root->c[t] = nil;     for (int i = 0; i < s1.size(); i++) {       trie *path = root;       for (int j = i; j < s1.size(); j++) {         int q = s1[j] -  a ;         if (path->c[q] == nil) {           trie *nw = new_node();           path->c[q] = nw;         }         path = path->c[q];         if (f[i][j] == n && path->cnt == 0) ans++;         path->cnt++;       }     }     cout << ans << endl;   }   