func_code_string: #include <bits/stdc++.h>   using namespace std;   const int Maxlen = 2e5 + 2;   long long ans;   long long lt[Maxlen], ls[2 * Maxlen];   int n, m, dpt[Maxlen], dps[Maxlen];   char ct[Maxlen], cs[2 * Maxlen];   long long cmp(int pos) {     if (cs[0] != ct[pos] || ls[0] > lt[pos]) return 0;     if (m == 1) return lt[pos] - ls[0] + 1;     pos++;     int p1 = 1;     while (p1 < m && pos < n && cs[p1] == ct[pos] && ls[p1] == lt[pos]) {       pos++;       p1++;     }     if (p1 < m && pos < n && cs[p1] == ct[pos] && ls[p1] < lt[pos]) p1++;     if (p1 == m) return 1;     return 0;   }   int kmp() {     int res = 0;     for (int i = 1; i < n + m; i++) {       int j = dps[i - 1];       if (j == m - 2 && cs[i] == cs[j] && ls[i] >= ls[j]) res++;       while (j > 0 && (cs[i] != cs[j] || ls[i] != ls[j])) j = dps[j - 1];       if (cs[j] == cs[i])         if (ls[j] == ls[i] || (j == 0 && ls[i] >= ls[j])) ++j;       dps[i] = j;     }     return res;   }   int main() {     scanf( %d%d , &n, &m);     scanf( %d-%c , &lt[0], &ct[0]);     for (int i = 1; i < n; i++) {       scanf( %d-%c , &lt[i], &ct[i]);       if (ct[i] == ct[i - 1]) {         lt[i - 1] += lt[i];         n--;         i--;       }     }     scanf( %d-%c , &ls[0], &cs[0]);     for (int i = 1; i < m; i++) {       scanf( %d-%c , &ls[i], &cs[i]);       if (cs[i] == cs[i - 1]) {         ls[i - 1] += ls[i];         m--;         i--;       }     }     if (m == 1) {       for (int i = 0; i < n; i++) ans = ans + cmp(i);     } else {       cs[m++] =  # ;       for (int i = 0; i < n; i++) {         cs[m + i] = ct[i];         ls[m + i] = lt[i];       }       ans = kmp();     }     printf( %I64d n , ans);     return 0;   }   