func_code_string: #include <bits/stdc++.h>   using namespace std;   int z[201010];   int cost[201010], acc[201010];   string s, aux, text, text2, patt;   pair<int, int> dp[201010];   void build() {     text = aux;     text2 = aux;     int n = (int)aux.size();     for (int i = 0; i < n; i++) {       cost[i] = -1;       acc[i] = 0;       if (aux[i] ==  ? ) {         text[i] =  a ;         text2[i] =  b ;         if (i % 2 == 0) swap(text[i], text2[i]);         acc[i] = 1;       }       if (i) acc[i] += acc[i - 1];     }   }   int getCost(int l, int r) { return acc[r] - (l ? acc[l - 1] : 0); }   void Z() {     int l = 0, r = 0, n = (int)s.size();     z[0] = 0;     for (int i = 1; i < n; i++) {       z[i] = 0;       if (i <= r) z[i] = min(z[i - l], r - i + 1);       while (i + z[i] < n && s[z[i]] == s[z[i] + i]) z[i]++;       if (i + z[i] - 1 >= r) {         l = i;         r = i + z[i] - 1;       }       if (z[i] == (int)patt.size())         cost[i - 2] = getCost(i - (int)patt.size() - 1, i - 2);     }   }   pair<int, int> operator+(pair<int, int> a, pair<int, int> b) {     return make_pair(a.first + b.first, a.second + b.second);   }   pair<int, int> maxx(pair<int, int> a, pair<int, int> b) {     if (a.first > b.first) return a;     if (a.first < b.first) return b;     return make_pair(a.first, min(a.second, b.second));   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     int m, n;     cin >> n;     cin >> aux;     cin >> m;     patt =   ;     for (int i = 0; i < m; i++) {       if (i % 2 == 0)         patt +=  a ;       else         patt +=  b ;     }     build();     s = patt +  $  + text;     Z();     s = patt +  $  + text2;     Z();     for (int i = 0; i < n; i++) {       dp[i] = i ? dp[i - 1] : make_pair(0, 0);       if (cost[i] != -1) {         dp[i] = maxx(dp[i], dp[i - m] + make_pair(1, cost[i]));       }     }     cout << dp[n - 1].second <<   n ;     return 0;   }   