func_code_string: #include <bits/stdc++.h>   using namespace std;   const int M = 2e5 + 10;   const int mod = 1e9 + 7;   struct pairNode {     char ch;     long long times;     pairNode(char ch = 0, long long times = 0) : ch(ch), times(times) {}     ~pairNode() = default;     bool operator==(const pairNode &rhs) const {       return ch == rhs.ch && times == rhs.times;     }     bool operator!=(const pairNode &rhs) const {       return ch != rhs.ch || times != rhs.times;     }     bool operator>=(const pairNode &rhs) const {       return ch == rhs.ch && times >= rhs.times;     }   };   int tS, tT;   vector<pairNode> S, T, newT;   int nxt[M];   inline void getInput(vector<pairNode> &S, int len) {     char cur = 0, ch[3];     long long curtimes = 0, times;     for (int i = 0; i < len; ++i) {       scanf( %I64d-%s , &times, ch);       if (ch[0] == cur) {         curtimes += times;       } else {         if (i) S.push_back(pairNode(cur, curtimes));         cur = ch[0];         curtimes = times;       }     }     S.push_back(pairNode(cur, curtimes));   }   int main() {     S.clear();     T.clear();     cin >> tS >> tT;     getInput(S, tS);     getInput(T, tT);     if (T.size() == 1) {       long long ans = 0;       for (int i = 0; i < S.size(); ++i)         if (S[i] >= T[0]) ans += S[i].times - T[0].times + 1;       cout << ans << endl;       return 0;     }     if (T.size() == 2) {       long long ans = 0;       for (int i = 0; i < S.size() - 1; ++i)         if (S[i] >= T[0] && S[i + 1] >= T[1]) ++ans;       cout << ans << endl;       return 0;     }     for (int i = 1; i < T.size() - 1; ++i) newT.push_back(T[i]);     nxt[0] = -1;     int k = -1;     for (int i = 1; i < newT.size(); ++i) {       while (k != -1 && newT[k + 1] != newT[i]) k = nxt[k];       if (newT[k + 1] == newT[i]) ++k;       nxt[i] = k;     }     long long ans = 0;     k = -1;     for (int i = 0; i < S.size(); ++i) {       while (k != -1 && newT[k + 1] != S[i]) k = nxt[k];       if (newT[k + 1] == S[i]) ++k;       if (k == newT.size() - 1) {         if (i >= newT.size() && i + 1 <= S.size() && S[i - newT.size()] >= T[0] &&             S[i + 1] >= T[T.size() - 1])           ++ans;         k = nxt[k];       }     }     cout << ans << endl;     return 0;   }   