func_code_string: #include <bits/stdc++.h>   using namespace std;   struct edge {     int v, w;   };   long long MOD = 1000000007;   long long _MOD = 1000000009;   double EPS = 1e-10;   long long extgcd(long long a, long long b, long long& x, long long& y) {     if (b == 0) {       x = (a >= 0) ? 1 : -1;       y = 0;       return abs(a);     } else {       long long res = extgcd(b, a % b, y, x);       y -= (a / b) * x;       return res;     }   }   long long mod_inverse(long long a, long long m) {     long long x, y;     extgcd(a, m, x, y);     return (m + x % m) % m;   }   long long f(int l, int r, vector<long long>& h, vector<long long>& zi) {     long long x = (h[r] - h[l]) * zi[l] % MOD;     return (x + MOD) % MOD;   }   int main() {     int N, M;     cin >> N >> M;     vector<pair<long long, char> > a, b;     while (N--) {       int l;       char c;       scanf( %d-%c , &l, &c);       if (a.size() && a.back().second == c)         a.back().first += l;       else         a.push_back(pair<long long, char>(l, c));     }     while (M--) {       int l;       char c;       scanf( %d-%c , &l, &c);       if (b.size() && b.back().second == c)         b.back().first += l;       else         b.push_back(pair<long long, char>(l, c));     }     N = a.size();     M = b.size();     if (M == 1) {       long long ans = 0;       for (int i = 0; i < N; i++)         if (a[i].second == b[0].second)           ans += max(0LL, a[i].first - b[0].first + 1);       cout << ans << endl;       return 0;     }     vector<pair<long long, char> > v;     for (pair<long long, char> x : a) v.push_back(x);     for (pair<long long, char> x : b) v.push_back(x);     sort(v.begin(), v.end());     v.erase(unique(v.begin(), v.end()), v.end());     vector<int> A(N), B(M);     for (int i = 0; i < N; i++)       A[i] = lower_bound(v.begin(), v.end(), a[i]) - v.begin() + 1;     for (int j = 0; j < M; j++)       B[j] = lower_bound(v.begin(), v.end(), b[j]) - v.begin() + 1;     vector<long long> z(200001), zi(200001);     z[0] = zi[0] = 1;     for (int i = 1; i <= 200000; i++) {       z[i] = z[i - 1] * 523541 % MOD;       zi[i] = mod_inverse(z[i], MOD);     }     vector<long long> ha(N + 1), hb(M + 1);     for (int i = 0; i < N; i++) ha[i + 1] = (ha[i] + A[i] * z[i]) % MOD;     for (int j = 0; j < M; j++) hb[j + 1] = (hb[j] + B[j] * z[j]) % MOD;     int cnt = 0;     for (int i = 0; i + M <= N; i++) {       if (!(a[i].second == b[0].second && a[i].first >= b[0].first)) continue;       if (!(a[i + M - 1].second == b[M - 1].second &&             a[i + M - 1].first >= b[M - 1].first))         continue;       if (f(i + 1, i + M - 1, ha, zi) != f(1, M - 1, hb, zi)) continue;       cnt++;     }     cout << cnt << endl;   }   