func_code_string: #include <bits/stdc++.h>   using namespace std;   struct hashed_str {     long long n;     vector<long long> hs;     vector<long long> pows;     long long p = 61;     long long mod = 1e9 + 7;     hashed_str(string &s) {       n = s.size();       long long n1 = (int)s.size();       pows = {1};       for (int i = 1; i < n; i++) {         pows.push_back((pows.back() * p) % mod);       }       hs.resize(n1);       hs[0] = (long long)((s[0] -  a ) + 1);       for (int i = 1; i < n1; i++) {         hs[i] =             (hs[i - 1] % mod + (pows[i] * (long long)(s[i] -  a  + 1ll)) % mod) %             mod;       }     }     long long get(long long l, long long r) {       if (l > r) {         return 0;       }       long long a = (l ? hs[l - 1] : 0);       long long b = hs[r];       long long s = (b - a + mod) % mod;       return (s * pows[n - l - 1]) % mod;     }   };   int main() {     ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);     ;     string t;     string s;     cin >> s >> t;     long long n = t.size();     hashed_str hs(t);     long long cnt_0 = 0, cnt_1 = 0;     for (int i = 0; i < s.size(); i++) {       if (s[i] ==  0 ) {         cnt_0++;       } else {         cnt_1++;       }     }     char aa =  0 ;     char bb =  1 ;     long long a = cnt_0;     long long b = cnt_1;     if (s[0] ==  1 ) {       swap(a, b);       swap(aa, bb);     }     if (b == 0) {       if (n % a != 0) {         cout << 0;         return 0;       }       long long len_a = n / a;       long long hash_a = hs.get(0, len_a - 1);       long long hash_b = -1;       long long ptr = len_a;       bool ok = 1;       for (int i = 1; i < s.size(); i++) {         long long cur_h = hs.get(ptr, ptr + len_a - 1);         if (cur_h != hash_a) {           ok = 0;           break;         }         ptr += len_a;       }       cout << ok;       return 0;     }     long long answ = 0;     for (int i = 0; i < t.size(); i++) {       long long len_a = i + 1;       if ((n - len_a * a) % b != 0 || n - len_a * a <= 0) {         continue;       }       long long len_b = (n - len_a * a) / b;       long long hash_a = hs.get(0, len_a - 1);       long long hash_b = -1;       long long ptr = len_a;       bool ok = 1;       for (int j = 1; j < s.size(); j++) {         if (s[j] == aa) {           long long cur_h = hs.get(ptr, ptr + len_a - 1);           if (cur_h != hash_a) {             ok = 0;             break;           }           ptr += len_a;         } else {           long long cur_h = hs.get(ptr, ptr + len_b - 1);           if (hash_b == -1) {             hash_b = cur_h;           }           if (cur_h != hash_b) {             ok = 0;             break;           }           ptr += len_b;         }       }       if (hash_a == hash_b) {         ok = 0;       }       answ += ok;     }     cout << answ;   }   