func_code_string: #include <bits/stdc++.h>   using namespace std;   const int maxn = 1000005;   int T, n, m, las = 1, ndnum = 1, ans;   char s[maxn];   struct node {     int ch[26], len, fa;   } d[maxn << 1];   int siz[maxn << 1], vis[maxn << 1], timer;   int head[maxn << 1], tot;   struct edge {     int nxt, to;   } e[maxn << 1];   void Addedge(int x, int y) {     e[++tot] = (edge){head[x], y};     head[x] = tot;   }   void Insert(int x) {     int p = las, np = las = ++ndnum;     siz[np] = 1;     d[np].len = d[p].len + 1;     while (p && !d[p].ch[x]) {       d[p].ch[x] = np;       p = d[p].fa;     }     if (!p) {       d[np].fa = 1;     } else {       int q = d[p].ch[x];       if (d[q].len == d[p].len + 1) {         d[np].fa = q;       } else {         int nq = ++ndnum;         d[nq] = d[q];         d[nq].len = d[p].len + 1;         d[q].fa = d[np].fa = nq;         while (p && d[p].ch[x] == q) {           d[p].ch[x] = nq;           p = d[p].fa;         }       }     }   }   void dfs(int x) {     int id;     for (int i = head[x]; i; i = e[i].nxt) {       id = e[i].to;       dfs(id);       siz[x] += siz[id];     }   }   void go(int &x, int y, int &len) {     if (d[x].ch[y]) {       ++len;       x = d[x].ch[y];     } else {       while (x && !d[x].ch[y]) x = d[x].fa;       if (!x) {         x = 1;         len = 0;       } else {         len = d[x].len + 1;         x = d[x].ch[y];       }     }   }   void del(int &x, int &len) {     if (len != m) return;     --len;     if (len == d[d[x].fa].len) x = d[x].fa;   }   void work(int x, int y) {     if (y < m || vis[x] == timer) return;     ans += siz[x];     vis[x] = timer;   }   int main() {     scanf( %s , s + 1);     n = strlen(s + 1);     for (int i = 1; i <= n; ++i) Insert(s[i] -  a );     for (int i = 2; i <= ndnum; ++i) Addedge(d[i].fa, i);     dfs(1);     scanf( %d , &T);     int now, len;     while (T--) {       scanf( %s , s + 1);       m = strlen(s + 1);       now = 1;       len = 0;       for (int i = 1; i <= m; ++i) go(now, s[i] -  a , len);       ++timer;       ans = 0;       work(now, len);       for (int i = 1; i < m; ++i) {         del(now, len);         go(now, s[i] -  a , len);         work(now, len);       }       printf( %d n , ans);     }     return 0;   }   