malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   int n, a[201], dp[201][201][1001];   const long long int MOD = 1e9 + 7;   int solve(int i, int g, int k) {     if (g < 0 || k < 0) return 0;     if (i == n) return (g == 0);     if (dp[i][g][k] != -1) return dp[i][g][k];     long long int ret = 0;     int nk = k - g * (a[i] - a[i - 1]);     if (nk >= 0) {       ret = (ret + 1LL * g * solve(i + 1, g - 1, nk)) % MOD;       ret = (ret + 1LL * (g + 1) * solve(i + 1, g, nk)) % MOD;       ret = (ret + 1LL * solve(i + 1, g + 1, nk)) % MOD;     }     return dp[i][g][k] = ret;   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     int k;     cin >> n >> k;     for (int i = 0; i < n; i++) cin >> a[i];     sort(a, a + n);     memset(dp, -1, sizeof dp);     cout << solve(0, 0, k);   }
#include<stdio.h>   #include<iostream>   #include<string.h>   #include<vector>   #include<queue>   #include<map>   #include<math.h>   #include<algorithm>   #include<stdlib.h>   #include<string>   #include<stack>   #include<set>   using namespace std;   #define pb push_back   #define POP pop_back()   #define DEBUG cout <<  DEBUG n ;   #define ll long long   #define db double   #define endl   n    #define fo(i,a,b) for(int i = a;i <= b;i++)   #define lowbit(x) (x&-x);   const int maxn = 5e5+5;   const int inf = 0x3f3f3f3f;   const ll inF = 0x3f3f3f3f3f3f3f3f;   const ll mod = 1e8;   const db eps = 1e-8;   struct node{    int v , id;    bool operator < (const node &b)const{     return v < b.v;    }   };   node cnt[maxn];   int a[maxn];   int main(){    int t , n;cin >> t;    while(t--){     cin >> n;     for(int i = 1;i <= n;i++)cnt[i].v = cnt[i].id = 0;     for(int i = 1;i <= n;i++)scanf( %d ,&a[i]) , cnt[a[i]].v++ , cnt[a[i]].id = i;     int ans = -1;     for(int i = 1;i <= n;i++){      if(cnt[i].v == 1){ans = cnt[i].id;break;}     }     if(ans == -1){      cout <<  -1 n ;     }     else cout << ans << endl;    }    return 0;   }
#include <bits/stdc++.h>   using namespace std;   char s[120][120];   int n, m;   int main() {     int i, j, k, res = 30, now = 0;     string ss =   ;     scanf( %d%d , &n, &m);     for (i = 0; i < n; i++) scanf( %s , s[i]);     for (i = 0; i < n; i++) {       for (j = 0; j < m; j++) {         char c = s[i][j];         int f = 0;         for (k = 0; k < n; k++) {           if (i == k) continue;           if (s[k][j] == c) f = 1;         }         for (k = 0; k < m; k++) {           if (j == k) continue;           if (s[i][k] == c) f = 1;         }         if (!f) ss += c;       }     }     cout << ss << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   bool within(int x1, int x2, int y1, int y2, int px, int py) {     if (x1 <= px and px <= x2 and y1 <= py and py <= y2) {       return true;     }     return false;   }   int main() {     ios::sync_with_stdio(false);     int y, x, v, n;     cin >> y >> x >> v >> n;     int py[v], px[v];     for (int i = 0; i < v; i++) {       cin >> px[i] >> py[i];       py[i]--, px[i]--;     }     int res = 0;     for (int x1 = 0; x1 < x; x1++) {       for (int x2 = x1; x2 < x; x2++) {         for (int y1 = 0; y1 < y; y1++) {           for (int y2 = y1; y2 < y; y2++) {             int found = 0;             for (int i = 0; i < v; i++) {               if (within(x1, x2, y1, y2, py[i], px[i])) {                 found++;               }             }             if (found >= n) {               res++;             }           }         }       }     }     cout << res;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, x = 4, y = 5;     scanf( %d , &n);     if (n == 1 || n == 2) {       cout << 1;       return 0;     }     while (y < n) {       if (x & 1)         x = 2 * y, y = x + 1;       else         x = 2 * y - 1, y = x + 1;     }     printf( %d , (x == n || y == n));     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int INF = 0x3f3f3f3f;   const long long INFF = 0x3f3f3f3f3f3f3f3fll;   const long long M = 1e9 + 7;   const long long maxn = 1e6 + 7;   const double pi = acos(-1.0);   const double eps = 0.0000000001;   long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }   template <typename T>   inline void pr2(T x, int k = 64) {     long long i;     for (i = 0; i < k; i++) fprintf(stderr,  %d , (x >> i) & 1);     putchar(   );   }   template <typename T>   inline void add_(T &A, int B) {     A += B;     (A >= M) && (A -= M);   }   template <typename T>   inline void mul_(T &A, long long B) {     (A *= B) %= M;   }   template <typename T>   inline void mod_(T &A, long long B = M) {     A %= M;   }   template <typename T>   inline void max_(T &A, T B) {     (A < B) && (A = B);   }   template <typename T>   inline void min_(T &A, T B) {     (A > B) && (A = B);   }   template <typename T>   inline T abs(T a) {     return a > 0 ? a : -a;   }   template <typename T>   inline T powMM(T a, T b) {     T ret = 1;     for (; b; b >>= 1ll, a = (long long)a * a % M)       if (b & 1) ret = (long long)ret * a % M;     return ret;   }   int n, m, q;   char str[maxn];   int TaskA();   void Task_one() { TaskA(); }   void Task_T() {     int T;     scanf( %d , &T);     while (T--) TaskA();   }   void Task_more_n() {     while (~scanf( %d , &n)) TaskA();   }   void Task_more_n_m() {     while (~scanf( %d%d , &n, &m)) TaskA();   }   void Task_more_n_m_q() {     while (~scanf( %d%d%d , &n, &m, &q)) TaskA();   }   void Task_more_string() {     while (~scanf( %s , str)) TaskA();   }   int A[maxn];   int TaskA() {     int i, t, k;     scanf( %d%d , &n, &k);     t = k;     for (i = 1; i <= n; i++) scanf( %d , &A[i]), t = gcd(t, A[i]);     printf( %d n , k / t);     for (i = 0; i < k / t; i++) printf( %d  , i * t);     return 0;   }   void initialize() {}   int main() {     int startTime = clock();     initialize();     fprintf(stderr,  /--- initializeTime: %ld milliseconds ---/ n ,             clock() - startTime);     Task_one();   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     cin >> n;     vector<int> arr(n);     for (int i = 0; i < n; i++) {       cin >> arr[i];     }     int m;     cin >> m;     while (m--) {       int k, pos;       cin >> k >> pos;       pos--;       vector<vector<int>> ans(k);       vector<long long> sums(k);       int last = 0;       for (int i = 0; i < n; i++) {         for (int j = last; j >= 0; j--) {           if (j >= k) continue;           if (ans[j].size() == 0) {             if (j == 0) {               ans[j].push_back(arr[i]);               sums[j] = arr[i];             } else {               ans[j] = ans[j - 1];               ans[j].push_back(arr[i]);               sums[j] = sums[j - 1] + arr[i];             }           } else {             if (j == 0) {               if (arr[i] > sums[j]) {                 ans[j][0] = arr[i];                 sums[j] = arr[i];               }             } else if (sums[j - 1] + arr[i] > sums[j]) {               sums[j] = sums[j - 1] + arr[i];               ans[j] = ans[j - 1];               ans[j].push_back(arr[i]);             } else if (sums[j - 1] + arr[i] == sums[j]) {               bool change = 0;               for (int k = 0; k < ans[j - 1].size(); k++) {                 if (ans[j - 1][k] < ans[j][k]) {                   change = 1;                   break;                 } else if (ans[j - 1][k] > ans[j][k]) {                   break;                 }               }               if (change) {                 ans[j] = ans[j - 1];                 ans[j].push_back(arr[i]);               }             }           }         }         last += 1;       }       cout << ans[k - 1][pos] <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void Fast() {     ios::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);   }   void File() {}   using ll = long long;   using ull = unsigned long long;   ll gcd(ll a, ll b) { return !b ? a : gcd(b, a % b); }   const int N = 100001;   bool prime[N];   int n, res[N];   vector<int> v, primes;   vector<vector<int>> numFactors, primeIdx;   vector<int>::iterator it;   void sieve() {     for (int i = 0; i < N; i++) prime[i] = 1;     prime[0] = prime[1] = 0;     for (int i = 4; i < N; i += 2) {       prime[i] = 0;     }     for (int i = 3; i * i < N; i += 2) {       if (prime[i]) {         for (int j = i * i; j < N; j += i + i) {           prime[j] = 0;         }       }     }     for (int i = 2; i < N; i++) {       if (prime[i]) {         primes.push_back(i);       }     }   }   void Prime_Factors_Faster(int n, int id) {     int temp = n;     if (prime[n]) {       primeIdx[n].push_back(id);       numFactors[temp].push_back(n);       return;     }     int idx = 0;     while (idx < primes.size() && primes[idx] * primes[idx] <= n) {       int cnt = 0;       while (n % primes[idx] == 0) {         n /= primes[idx];         cnt++;       }       if (cnt)         numFactors[temp].push_back(primes[idx]),             primeIdx[primes[idx]].push_back(id);       ;       idx++;     }     if (n > 1) {       primeIdx[n].push_back(id);       numFactors[temp].push_back(n);     }   }   int solve(int idx) {     int& ans = res[idx];     if (~ans) return ans;     ans = 1;     for (int i = 0; i < numFactors[v[idx]].size(); i++) {       int pr = numFactors[v[idx]][i];       it = upper_bound(primeIdx[pr].begin(), primeIdx[pr].end(), idx);       if (it != primeIdx[pr].end()) ans = max(ans, solve(*it) + 1);     }     return ans;   }   int main() {     File(), Fast();     sieve();     numFactors.resize(N), primeIdx.resize(N);     cin >> n;     v.resize(n);     for (int i = 0; i < n; i++) {       cin >> v[i], Prime_Factors_Faster(v[i], i);     }     int* dp = new int[n];     for (int i = 0; i < n; i++) dp[i] = 1;     for (int i = 0; i < n; i++) cin >> v[i], Prime_Factors_Faster(v[i], i);     for (int i = n - 1; i >= 0; i--) {       for (int j = 0; j < numFactors[v[i]].size(); j++) {         int pr = numFactors[v[i]][j];         it = upper_bound(primeIdx[pr].begin(), primeIdx[pr].end(), i);         if (it != primeIdx[pr].end() and v[*it] > v[i])           dp[i] = max(dp[i], dp[*it] + 1);       }     }     cout << *max_element(dp, dp + n) <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   int n, k, cnt;   pair<int, int> Ans[100010];   int main() {     scanf( %d%d , &n, &k);     if (k == 1 || k > 3 || n <= 3 || (k == 2 && n == 4)) {       puts( -1 );       return 0;     }     if (k == 2) {       printf( %d n , n - 1);       for (int i = 1; i < n; i++) printf( %d %d n , i, i + 1);     } else {       Ans[++cnt] = make_pair(2, 3);       for (int i = 5; i <= n; i++)         Ans[++cnt] = make_pair(2, i), Ans[++cnt] = make_pair(3, i);       Ans[++cnt] = make_pair(1, 2);       Ans[++cnt] = make_pair(3, 4);       printf( %d n , cnt);       for (int i = 1; i <= cnt; i++)         printf( %d %d n , Ans[i].first, Ans[i].second);     }     return 0;   }
#include <bits/stdc++.h>   #pragma GCC target( sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native )   #pragma GCC optimize( unroll-loops )   #pragma GCC optimize( Ofast )   #pragma GCC optimize( O3 )   #pragma GCC target( avx )   using namespace std;   long long fpow(long long x, long long y, long long m) {     long long temp;     if (y == 0 || x == 1) return 1;     temp = fpow(x, y / 2, m);     if (y % 2 == 0)       return ((temp) * (temp)) % m;     else       return (((x) % m) * ((temp * temp) % m)) % m;   }   long long gcd(long long a, long long b) {     if (b == 0) return a;     return gcd(b, a % b);   }   void sieve(long long n) {     bool prime[5 * 300005];     memset(prime, true, sizeof(prime));     for (long long p = 2; p * p <= n; p++)       if (prime[p] == true)         for (long long i = p * p; i <= n; i += p) prime[i] = false;     prime[1] = 0;   }   inline long long read() {     long long p = 1, ans = 0;     char ch = getchar();     while (ch < 48 || ch > 57) {       if (ch ==  - ) p = -1;       ch = getchar();     }     while (ch >= 48 && ch <= 57) {       ans = (ans << 3) + (ans << 1) + ch - 48;       ch = getchar();     }     return ans * p;   }   long long cnt, sum, mid, mx = -1e17, mn = 1e17, a[2 * 300005];   long long n, m, d, t, i, j, k, l, r, x, y, z;   bool f, f1, f2;   string s;   int32_t main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     n = read();     vector<long long> s(n + 2);     for ((i) = 1; (i) <= ((n + 1) / 2); (i)++) {       a[i] = read();       s[i] = a[i] + s[i - 1];     }     x = read();     for (; i <= n; i++) s[i] = s[i - 1] + x;     if (s[n] > 0) {       cout << n;       return 0;     }     if (x >= 0) {       cout << -1;     } else {       vector<long long> dp(n + 2);       sum = 0;       for ((i) = 1; (i) <= ((n + 1) / 2); (i)++) {         sum += x - a[i];         dp[i] = min(dp[i - 1], sum);       }       for (k = ((n + 1) >> 1); k <= n; k++) {         if (s[k] + dp[n - k] > 0) {           cout << k;           return 0;         }       }       cout << -1;     }   }
#include <bits/stdc++.h>   using namespace std;   const int mod = 1000000007;   const double eps = 1e-6;   const int inf = 0x3f3f3f3f;   const long long INF = 100000000000000000ll;   const int MAXN = 4004;   const int MAXM = 300030;   int dp[MAXN][MAXN];   int main() {     int n;     cin >> n;     dp[0][0] = 1;     for (int i = 1; i <= n + 1; i++) {       dp[i][0] = dp[i - 1][i - 1];       for (int j = 1; j <= i; j++) {         dp[i][j] = (dp[i][j - 1] + dp[i - 1][j - 1]) % mod;       }     }     printf( %d n , (dp[n + 1][0] - dp[n][0] + mod) % mod);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     int n;     string second;     cin >> n >> second;     int i;     int p = 0;     for (i = 0; i < n; i++) {       if (second[i] ==  8 ) p++;     }     int m = (n - p) / 10;     if (p > m) {       cout << n / 11;     } else       cout << min(p, m);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, u, v, c, a[100005], b[100005];   vector<int> adj[100005];   int mod_pow(int a, int b) {     int rtn = 1;     while (b) {       if (b & 1) rtn = (1ll * rtn * a) % 1000000007;       a = 1ll * a * a % 1000000007;       b /= 2;     }     return rtn;   }   void dfs(int vtx, int p) {     if (adj[vtx].size() == 1 && vtx) return;     for (int i = 0; i < adj[vtx].size(); i++) {       int u = adj[vtx][i] / 10005, w = adj[vtx][i] % 10005;       b[vtx] = (b[vtx] + w) % 1000000007;       if (u == p) continue;       dfs(u, vtx);       a[vtx] = (a[vtx] + a[u]) % 1000000007,       b[vtx] = (1ll * b[vtx] + b[u]) % 1000000007;     }     a[vtx] = mod_pow((adj[vtx].size() - a[vtx] + 1000000007) % 1000000007,                      1000000007 - 2);     b[vtx] = (1ll * a[vtx] * b[vtx]) % 1000000007;   }   int main() {     scanf( %d , &n);     for (int i = 0; i < n - 1; i++) {       scanf( %d %d %d , &u, &v, &c);       adj[u].push_back(v * 10005 + c);       adj[v].push_back(u * 10005 + c);     }     dfs(0, -1);     printf( %d , b[0]);   }
#include <bits/stdc++.h>   using namespace std;   void solve() {     int a = 1, l = -1, r = -1;     string s;     for (int i = 1; i <= 30; i++) {       cout <<  ?   << (1 << i) <<     << (1 << (i - 1)) << endl;       cin >> s;       if (s ==  x ) {         continue;       } else {         l = (1 << (i - 1)) + 1;         r = (1 << i);         break;       }     }     if (r == 2) {       cout <<  ! 2  << endl;       return;     } else if (l == -1) {       cout <<  ! 1  << endl;       return;     }     int GUESS1 = r;     l = 0, r = r >> 1;     int md, ans;     while (l < r) {       md = (l + r) >> 1;       cout <<  ?   << GUESS1 <<     << md << endl;       cin >> s;       if (s ==  x ) {         l = md + 1;         ans = md;       } else {         r = md;       }     }     cout <<  !   << GUESS1 - ans << endl;   }   int32_t main() {     string now;     while (cin >> now) {       if (now ==  end ) break;       solve();     }     return 0;   }
#include <bits/stdc++.h>   int main() {     int x, y = 0, i = 1, j = 1, n = 0, q, a[102];     scanf( %d , &x);     for (i = 1; i <= x; i++) {       scanf( %d , &a[i]);       if (a[i] > y) y = a[i];     }     for (i = 1; i <= x; i++) {       q = y - a[i];       n = n + q;     }     printf( %d n , n);     return 0;   }
#include <bits/stdc++.h>   int a[128][128], v[128], cor[128], bucket[128];   int m, n;   int main() {     scanf( %d%d , &n, &m);     for (int i = 1; i <= m; ++i) {       scanf( %d , &v[i]);       cor[i] = 1;       for (int j = 2; j <= n; ++j) {         int x;         scanf( %d , &x);         if (x > v[i]) {           v[i] = x;           cor[i] = j;         }       }     }     for (int i = 1; i <= m; ++i) {       bucket[cor[i]]++;     }     int rez = bucket[1];     int cand = 1;     for (int i = 2; i <= n; ++i) {       if (bucket[i] > rez) {         rez = bucket[i];         cand = i;       }     }     printf( %d n , cand);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   struct v3 {     int x, y, z, i;     v3 cross(const v3& rhs) {       return {y * rhs.z - z * rhs.y, -(x * rhs.z - z * rhs.x),               x * rhs.y - y * rhs.x};     }     long long dot(const v3& rhs) { return x * rhs.x + y * rhs.y + z * rhs.z; }   };   vector<pair<int, int> > ans;   v3 pts[111111];   int pidx[6][111111];   bool chk(int n, int k) {     if (n <= k) {       for (int i = 0; i < n; i++) ans.push_back({pidx[k][i] + 1, -1});       return true;     }     if (k == 0) return false;     int mdel = -1, ma, mb, nn = 0;     for (int i = 0; i < 100; i++) {       int a = rand() % n;       int b = rand() % (n - 1);       if (b >= a) b++;       v3 pt = pts[pidx[k][a]].cross(pts[pidx[k][b]]);       if (pt.z == 0) continue;       int del = 0;       for (int j = 0; j < n; j++) {         if (pt.dot(pts[pidx[k][j]]) == 0LL) del++;       }       if (del > mdel) {         nn = 0;         for (int j = 0; j < n; j++) {           if (pt.dot(pts[pidx[k][j]]) != 0LL) pidx[k - 1][nn++] = pidx[k][j];         }         mdel = del;         ma = pidx[k][a] + 1, mb = pidx[k][b] + 1;       }     }     if (mdel == -1) return false;     ans.push_back({ma, mb});     if (chk(nn, k - 1)) return true;     ans.pop_back();     return false;   }   int N, K;   int main() {     srand(unsigned(time(0)));     scanf( %d%d , &N, &K);     for (int i = 0; i < N; i++) {       scanf( %d%d%d , &pts[i].x, &pts[i].y, &pts[i].z);       pidx[K][i] = i;     }     if (chk(N, K)) {       printf( YES n );       printf( %d n , (int)ans.size());       for (auto it : ans) {         printf( %d %d n , it.first, it.second);       }     } else {       printf( NO );     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   map<pair<int, int>, int> mp;   vector<int> res, low, b;   int ask(int l, int r) {     if (l == r) return -1;     if (l > r) swap(l, r);     if ((res[l] | res[r]) == (low[l] | low[r])) return res[l] | res[r];     auto it = mp.find(make_pair(l, r));     if (it != mp.end()) return it->second;     printf( ? %d %d n , l, r);     fflush(stdout);     int x;     scanf( %d , &x);     mp[make_pair(l, r)] = x;     res[l] &= x;     res[r] &= x;     for (auto p : mp) {       low[p.first.first] |= p.second ^ res[p.first.second];       low[p.first.second] |= p.second ^ res[p.first.first];     }     return x;   }   int n;   void answer() {     printf( ! );     for (int i = 1; i <= n; ++i) {       printf(  %d , res[i]);     }     printf(  n );     fflush(stdout);     exit(0);   }   int main() {     scanf( %d , &n);     int full = (1 << 18) - 1;     res.assign(n + 1, full);     low.assign(n + 1, 0);     int cnt = 4269 - n * 2;     srand(time(0));     int p = -1, q = -1;     while (cnt-- > 0) {       int x = (rand() % n) + 1;       int y = (rand() % n) + 1;       while (x == y) {         y = (rand() % n) + 1;       }       ask(x, y);       bool found = false;       for (int i = 1; i <= n; ++i) {         for (int j = i + 1; j <= n; ++j) {           if (res[i] & res[j]) continue;           p = i;           q = j;           found = true;         }       }       if (found) break;     }     if (p != -1 && q != -1) {       for (int i = 1; i <= n; ++i) {         ask(i, p);         ask(i, q);       }       answer();     }     int zero = -1;     while (true) {       vector<int> cand;       for (int i = 1; i <= n; ++i) {         if (low[i]) continue;         cand.emplace_back(i);       }       sort(cand.begin(), cand.end(), [](int l, int r) {         return __builtin_popcount(res[l]) < __builtin_popcount(res[r]);       });       for (int x : cand) {         ask(x, cand[0]);       }       zero = -1;       for (int x : cand) {         if (res[x] == 0) {           zero = x;           break;         }       }       if (zero != -1) break;     }     for (int i = 1; i <= n; ++i) {       ask(zero, i);     }     answer();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int32_t main() {     ios::sync_with_stdio(0);     cin.tie(0);     long long n, k;     cin >> n >> k;     if (k < (n * n + n) / 2) return cout << -1, 0;     long long t = k;     k -= (n * n + n) / 2;     long long a[n + 1];     for (long long i = 1; i <= n; i++) a[i] = i;     for (long long i = 1; i <= n / 2; i++) {       if (k - (n + 1 - 2 * i) > 0) {         swap(a[i], a[n - i + 1]);         k -= (n + 1 - 2 * i);       } else {         swap(a[i], a[i + k]);         cout << t << endl;         for (long long i = 1; i <= n; i++) cout << i <<    ;         cout << endl;         for (long long i = 1; i <= n; i++) cout << a[i] <<    ;         return 0;       }     }     cout << t - k << endl;     for (long long i = 1; i <= n; i++) cout << i <<    ;     cout << endl;     for (long long i = 1; i <= n; i++) cout << a[i] <<    ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long mod = 1000000007;   string s;   long long dp[1000001][7];   long long f(int idx, int la = 6) {     if (idx == s.size()) {       if (la == 2) return 0;       if (la == 1) return 0;       return 1;     }     if (dp[idx][la] != -1) return dp[idx][la];     long long res = 0;     if (s[idx] !=  ? ) {       char c = s[idx];       if (la == 0) {         if (c ==  0 )           res = f(idx + 1, 0);         else if (c ==  1 )           res = f(idx + 1, 1);       } else if (la == 1) {         if (c ==  * ) res = f(idx + 1, 4);       } else if (la == 2) {         if (c ==  * ) res = f(idx + 1, 4);       } else if (la == 3) {         if (c ==  0 )           res = f(idx + 1, 0);         else if (c ==  1 )           res = f(idx + 1, 1);       } else if (la == 4) {         if (c ==  2 )           res = f(idx + 1, 2);         else if (c ==  1 )           res = f(idx + 1, 3);         else if (c ==  * )           res = f(idx + 1, 4);       } else {         if (c ==  1 ) res = f(idx + 1, 1);         if (c ==  0 ) res = f(idx + 1, 0);         if (c ==  * ) res = f(idx + 1, 4);       }     } else if (la == 0) {       res += f(idx + 1, 0);       res %= mod;       res += f(idx + 1, 1);       res %= mod;     } else if (la == 1 || la == 2) {       res = f(idx + 1, 4);     } else if (la == 3) {       res += f(idx + 1, 0);       res %= mod;       res += f(idx + 1, 1);       res %= mod;     } else if (la == 4) {       res = f(idx + 1, 2);       res %= mod;       res += f(idx + 1, 3);       res %= mod;       res += f(idx + 1, 4);       res %= mod;     } else {       res += f(idx + 1, 0);       res %= mod;       res += f(idx + 1, 1);       res %= mod;       res += f(idx + 1, 4);       res %= mod;     }     return dp[idx][la] = res;   }   int main() {     memset(dp, -1, sizeof dp);     ios::sync_with_stdio(false);     cin >> s;     cout << f(0);   }