func_code_string: #include <bits/stdc++.h>   using namespace std;   const double eps = 1e-5;   const int p = 131;   const int inf = 0x3f3f3f3f;   const long long mod = 1e9 + 7;   const int N = 1e6 + 10;   long long Hash[N], fac[N];   char s[N], ss[N];   long long get(int l, int r) {     return (Hash[r] - Hash[l - 1] * fac[r - l + 1] % mod + mod) % mod;   }   void run() {     scanf( %s %s , s + 1, ss + 1);     int len1 = strlen(s + 1);     int len2 = strlen(ss + 1);     fac[0] = 1;     int n0 = 0, n1 = 0;     for (int i = 1; i <= len1; i++) {       n0 += (s[i] ==  0 );       n1 += (s[i] ==  1 );     }     for (int i = 1; i <= len2; i++) {       Hash[i] = (Hash[i - 1] * p % mod + ss[i] -  a  + 1) % mod;       fac[i] = fac[i - 1] * p % mod;     }     int res = 0;     for (int l0 = 1, l1; l0 < len2; l0++) {       if (l0 * n0 >= len2) break;       if ((len2 - l0 * n0) % n1) continue;       l1 = (len2 - l0 * n0) / n1;       long long hash0 = -1, hash1 = -1;       int idx = 1;       int flag = 1;       for (int j = 1; j <= len1; j++) {         if (s[j] ==  1 ) {           if (hash1 == -1) {             hash1 = get(idx, idx + l1 - 1);           } else if (hash1 != get(idx, idx + l1 - 1)) {             flag = 0;             break;           }           idx += l1;         } else {           if (hash0 == -1) {             hash0 = get(idx, idx + l0 - 1);           } else if (hash0 != get(idx, idx + l0 - 1)) {             flag = 0;             break;           }           idx += l0;         }         if (~hash0 && ~hash1 && hash0 == hash1) {           flag = 0;           break;         }       }       if (flag) res++;     }     printf( %d n , res);   }   int main() {     run();     return 0;   }   