func_code_string: #include <bits/stdc++.h>   using namespace std;   const int Maxs = 300 * 1000 + 5, Maxn = 300 * 1000 + 5;   int n, dp[Maxs];   string s, t;   long long ans;   vector<pair<int, string> > adj[Maxn];   void kmp() {     dp[0] = -1;     for (int i = 0; i < t.size(); i++) {       int pt = i;       while (dp[pt] != -1 && t[dp[pt]] != t[i]) pt = dp[pt];       dp[i + 1] = dp[pt] + 1;     }   }   double now;   void dfs(int v, int indt) {     for (auto u : adj[v]) {       int indt2 = indt;       for (int j = 0; j < u.second.size(); ++j) {         if (clock() - now == CLOCKS_PER_SEC * 0.990) {           cout << ans << endl;           exit(0);         }         if (indt2 == t.size()) ans++, indt2 = dp[indt2];         if (indt2 >= 0 && indt2 < t.size() && u.second[j] == t[indt2])           indt2++;         else if (indt2 != 0 && indt2 >= 0)           indt2 = dp[indt2], j--;       }       if (indt2 == t.size()) ans++, indt2 = dp[indt2];       dfs(u.first, indt2);     }   }   int main() {     now = clock();     cin >> n;     int par;     for (int i = 1; i < n; i++)       cin >> par >> s, par--, adj[par].push_back(make_pair(i, s));     cin >> s;     t = s;     kmp();     dfs(0, 0);     cout << ans << endl;     return 0;   }   