func_code_string: #include <bits/stdc++.h>   using namespace std;   template <typename T>   inline void read(T &x) {     x = 0;     char c = getchar();     bool flag = false;     while (!isdigit(c)) {       if (c ==  - ) flag = true;       c = getchar();     }     while (isdigit(c)) {       x = (x << 1) + (x << 3) + (c ^ 48);       c = getchar();     }     if (flag) x = -x;   }   int n, lenth, las = 1, root = 1, tot = 1;   long long ans;   int ch[1000010][26], fa[1000010], len[1000010], siz[1000010][15], l[1000010],       r[1000010];   char s[1000010], str[1000010];   struct edge {     int to, nxt;   } e[1000010];   int head[1000010], edge_cnt;   void add(int from, int to) {     e[++edge_cnt] = (edge){to, head[from]};     head[from] = edge_cnt;   }   void insert(int c, int id) {     int p = las, np = las = ++tot;     len[np] = len[p] + 1, siz[np][id] = 1;     while (p && !ch[p][c]) ch[p][c] = np, p = fa[p];     if (!p)       fa[np] = root;     else {       int q = ch[p][c];       if (len[q] == len[p] + 1)         fa[np] = q;       else {         int nq = ++tot;         memcpy(ch[nq], ch[q], sizeof(ch[q]));         len[nq] = len[p] + 1, fa[nq] = fa[q], fa[q] = fa[np] = nq;         while (ch[p][c] == q) ch[p][c] = nq, p = fa[p];       }     }   }   void dfs(int x) {     for (int i = head[x]; i; i = e[i].nxt) {       int y = e[i].to;       dfs(y);       for (int j = 0; j <= n; ++j) siz[x][j] += siz[y][j];     }   }   void calc(int x) {     if (!siz[x][0]) return;     for (int i = 1; i <= n; ++i)       if (siz[x][i] < l[i] || siz[x][i] > r[i]) return;     ans += len[x] - len[fa[x]];   }   int main() {     scanf( %s , str + 1), lenth = strlen(str + 1);     for (int i = 1; i <= lenth; ++i) insert(str[i] -  a , 0);     read(n);     for (int i = 1; i <= n; ++i) {       las = 1, scanf( %s , s + 1), lenth = strlen(s + 1), read(l[i]), read(r[i]);       for (int j = 1; j <= lenth; ++j) insert(s[j] -  a , i);     }     for (int i = 2; i <= tot; ++i) add(fa[i], i);     dfs(root);     for (int i = 2; i <= tot; ++i) calc(i);     printf( %lld , ans);     return 0;   }   