func_code_string: #include <bits/stdc++.h>   using namespace std;   const int N = 1000010;   int cnt, lst, fa[N * 2], len[N * 2], ch[N * 2][26];   long long w[N * 2], ans;   int od[N * 2], rk[N * 2], l = 1;   char s[N];   void Init() { cnt = lst = 1; }   void Insert(int c) {     int p = lst, np = lst = ++cnt;     len[np] = len[p] + 1;     while (p && ch[p][c] == 0) ch[p][c] = np, p = fa[p];     if (!p)       fa[np] = 1;     else {       int q = ch[p][c], nq;       if (len[q] == len[p] + 1)         fa[np] = q;       else {         len[nq = ++cnt] = len[p] + 1;         fa[nq] = fa[q];         fa[q] = fa[np] = nq;         memcpy(ch[nq], ch[q], sizeof(ch[q]));         while (ch[p][c] == q) ch[p][c] = nq, p = fa[p];       }     }   }   int n;   int main() {     Init();     scanf( %d , &n);     for (int i = 1; i <= n; i++) {       scanf( %s , s + l);       l += strlen(s + l);       s[l++] =  # ;     }     for (int i = 1, j = 0, x, p; i <= n; i++) {       lst = 1;       for (j += 1; s[j] !=  # ; j++) {         Insert(s[j] -  a );       }     }     for (int i = 1, j = 0, x, p; i <= n; i++) {       scanf( %d , &x);       for (p = 1, j += 1; s[j] !=  # ; j++) {         p = ch[p][s[j] -  a ];         w[p] += x;       }     }     for (int i = 1; i <= cnt; i++) rk[len[i]] += 1;     for (int i = 1; i <= cnt; i++) rk[i] += rk[i - 1];     for (int i = 1; i <= cnt; i++) od[rk[len[i]]--] = i;     for (int i = cnt; i >= 1; i--) w[fa[od[i]]] += w[od[i]];     for (int i = 2; i <= cnt; i++) ans = max(ans, len[i] * w[i]);     printf( %lld n , ans);     return 0;   }   