func_code_string: #include <bits/stdc++.h>   #pragma comment(linker,  /STACK:1024000000,1024000000 )   using namespace std;   const int Maxn = 600010, Maxm = 300005, Mo = 1000000007,             sp[8][2] = {{-1, 0}, {1, 0},   {0, 1},  {0, -1},                         {1, 1},  {-1, -1}, {1, -1}, {-1, 1}};   const long long oo = (1LL << 62);   typedef int IArr[Maxn];   typedef long long LArr[Maxn];   typedef double DArr[Maxn];   struct SA {     int fl, dep, nt[28], ct[11];   } sa[Maxn];   int total, tl, M_dep;   void init() {     memset((sa), 0, sizeof((sa)));     fill(sa[0].nt, sa[0].nt + 27, 1);     sa[0].dep = -1;     total = tl = 1;   }   void ins(int c) {     int p = tl;     int np = tl = ++total;     sa[np].dep = sa[p].dep + 1;     for (; !sa[p].nt[c]; p = sa[p].fl) sa[p].nt[c] = np;     int q = sa[p].nt[c];     if (sa[p].dep + 1 == sa[q].dep)       sa[np].fl = q;     else {       int nq = ++total;       sa[nq] = sa[q];       sa[nq].dep = sa[p].dep + 1;       sa[np].fl = sa[q].fl = nq;       for (; sa[p].nt[c] == q; p = sa[p].fl) sa[p].nt[c] = nq;     }   }   int n;   IArr ck;   vector<int> e[Maxn];   string st, s;   void dfs(int u) {     for (int i = 0; i < e[u].size(); i++) {       int v = e[u][i];       dfs(v);       for (int j = 1; j <= n; j++) sa[u].ct[j] += sa[v].ct[j];     }   }   int main() {     ios::sync_with_stdio(0);     cin >> st;     init();     for (int i = 0; i < st.size(); i++) ins(st[i] -  a );     cin >> n;     int l[20], r[20];     for (int i = 1; i <= n; i++) {       cin >> s;       cin >> l[i] >> r[i];       int p = 1;       for (int j = 0; j < s.size(); j++) {         int c = s[j] -  a ;         while (!sa[p].nt[c]) p = sa[p].fl;         int q = sa[p].nt[c];         if (sa[p].dep + 1 == sa[q].dep)           p = q;         else {           int nq = ++total;           sa[nq] = sa[q];           memset((sa[nq].ct), 0, sizeof((sa[nq].ct)));           sa[nq].dep = sa[p].dep + 1;           sa[q].fl = nq;           for (; sa[p].nt[c] == q; p = sa[p].fl) sa[p].nt[c] = nq;           p = total;         }         sa[p].ct[i]++;       }     }     for (int i = 2; i <= total; i++) e[sa[i].fl].push_back((i));     dfs(1);     long long ans = 0;     for (int i = 2; i <= total; i++) {       ck[i] = 1;       for (int j = 1; j <= n; j++)         ck[i] &= ((l[j] <= sa[i].ct[j]) && (sa[i].ct[j] <= r[j]));       if (ck[i]) ans += sa[i].dep - sa[sa[i].fl].dep;     }     cout << ans << endl;   }   