malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   vector<long long> x;   vector<vector<long long> > y;   vector<long long> bfs(long long k) {     vector<long long> p((long long)y.size() + 1, 0);     vector<bool> vis((long long)y.size() + 1, false);     vis[k] = true;     queue<long long> q;     q.push(k);     while (!q.empty()) {       long long k = q.front();       q.pop();       for (auto i : y[k]) {         if (!vis[i]) {           p[i] = p[k] + 1;           vis[i] = true;           q.push(i);         }       }     }     return p;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     long long n, m, k;     cin >> n >> m >> k;     y = vector<vector<long long> >(n + 1);     for (long long i = 0; i < k; i++) {       long long k;       cin >> k;       x.push_back(k);     };     for (long long j = 0; j < m; j++) {       long long p, q;       cin >> p >> q;       y[p].push_back(q);       y[q].push_back(p);     }     vector<long long> o = bfs(1);     vector<long long> l = bfs(n);     vector<pair<long long, long long> > z;     long long maxi = -1;     for (auto i : x) {       z.push_back({o[i] - l[i], l[i]});     }     sort(z.begin(), z.end());     vector<long long> suff(k + 1, 0);     long long ans = -1;     for (long long j = k - 1; j >= 0; j--) {       maxi = max(maxi, z[j].second);       suff[j] = maxi;     }     for (long long j = 0; j < k - 1; j++) {       ans = max(ans, suff[j + 1] + z[j].first + z[j].second + 1);     }     cout << min(ans, o[n]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long INF = 1e9;   const long long MAXN = 2e5 + 1;   void faster() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);   }   int prs[1000];   void solve() {     int n, k;     cin >> n >> k;     unsigned long long a[n];     set<int> ms;     int s0 = 0;     for (int i = 0; i < n; i++) {       cin >> a[i];     }     int b[65], cnt = 0;     for (int i = 0; i <= 60; i++) {       b[i] = 0;     }     for (int i = 0; i < n; i++) {       cnt = 0;       while (a[i] >= 1) {         if (a[i] % k == 0) {           cnt++;           a[i] /= k;         } else if ((a[i] - 1) % k == 0 && a[i] != 1) {           if (b[cnt] == 0) {             b[cnt] = 1;           } else {             cout <<  NO  << endl;             return;           }           a[i] -= 1;         } else {           if (a[i] == 1 && b[cnt] == 0) {             b[cnt] = 1;             break;           } else {             cout <<  NO  << endl;             return;           }         }       }     }     cout <<  YES  << endl;   }   int main() {     int n = 1;     cin >> n;     while (n--) {       solve();     }   }
#include <bits/stdc++.h>   using namespace std;   template <class T>   struct range_leq {     int N;     vector<vector<T> > fen;     range_leq(int *A, int n) : N(n + 1), fen(N) {       for (int i = 1; i < N; ++i) {         int p = 1;         for (; !(p & i); p <<= 1)           ;         for (; p; --p) fen[i].push_back(A[i - p]);         sort(fen[i].begin(), fen[i].end());       }     }     inline int prefix_query(int i, T v) {       int ans = 0;       for (++i; i; i ^= i & -i) {         int lo = -1, hi = fen[i].size();         while (hi - lo != 1) {           int md = (lo + hi) / 2;           (fen[i][md] <= v ? lo : hi) = md;         }         ans += hi;       }       return ans;     }     inline int range_query(int l, int r, int v) {       return prefix_query(r, v) - prefix_query(l - 1, v);     }     inline int box_query(int l, int r, int w, int v) {       return range_query(l, r, v) - range_query(l, r, w - 1);     }   };   const int N = 1e5 + 5;   int n, k, a[N], q, l, r, lk[N];   map<int, vector<int> > m;   int main() {     scanf( %d%d , &n, &k);     for (int i = 0; i < n; ++i) {       scanf( %d , a + i);       m[a[i]].push_back(i);     }     for (auto p : m) {       vector<int> &v = p.second;       for (int i = 0; i < v.size(); ++i) {         if (i < k)           lk[v[i]] = -1;         else           lk[v[i]] = v[i - k];       }     }     range_leq<int> R(lk, n);     int last = 0;     scanf( %d , &q);     while (q--) {       scanf( %d%d , &l, &r);       l = (l + last) % n;       r = (r + last) % n;       if (r < l) swap(l, r);       last = R.range_query(l, r, l - 1);       printf( %d n , last);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int s;     cin >> s;     int *a = new int[s];     for (int i = 0; i < s; i++) cin >> a[i];     for (int i = s - 2; i < s; i--) {       if (a[i] != a[i + 1]) {         cout << i + 1 << endl;         break;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long mod = 1000000007;   long long powmod(long long a, long long b) {     long long res = 1;     a %= mod;     assert(b >= 0);     for (; b; b >>= 1) {       if (b & 1) res = res * a % mod;       a = a * a % mod;     }     return res;   }   const int N = 55;   int n, m, sw;   char s[N][N], t[N];   vector<pair<int, int> > ret1, ret2;   void gao(vector<pair<int, int> > &ret) {     for (int j = 0; j < m; j++) {       int i = 0;       while (i < n) {         if (s[i][j] ==  L ) {           for (int k = 0; i + k < n && j + k < m; k++) {             if (s[i + 1 + k][j + k] ==  L ) {               for (int l = k; l >= 0; l--) {                 ret.push_back(make_pair(i + l, j + l));                 s[i + l][j + l] = s[i + l][j + l + 1] =  U ;                 s[i + l + 1][j + l] = s[i + l + 1][j + l + 1] =  D ;                 if (l > 0) {                   ret.push_back(make_pair(i + l, j + l - 1));                   s[i + l][j + l - 1] = s[i + l + 1][j + l - 1] =  L ;                   s[i + l][j + l] = s[i + l + 1][j + l] =  R ;                 }               }               break;             }             if (s[i + 1 + k][j + 1 + k] ==  U ) {               for (int l = k; l >= 0; l--) {                 ret.push_back(make_pair(i + l + 1, j + l));                 s[i + l + 1][j + l] = s[i + l + 2][j + l] =  L ;                 s[i + l + 1][j + l + 1] = s[i + l + 2][j + l + 1] =  R ;                 ret.push_back(make_pair(i + l, j + l));                 s[i + l][j + l] = s[i + l][j + l + 1] =  U ;                 s[i + l + 1][j + l] = s[i + l + 1][j + l + 1] =  D ;               }               break;             }           }         }         i += 2;       }     }   }   int main() {     scanf( %d%d , &n, &m);     if (n % 2 == 1) {       sw = 1;       for (int i = 0; i < n; i++) {         scanf( %s , t);         for (int j = 0; j < m; j++) {           if (t[j] ==  L )             s[j][i] =  U ;           else if (t[j] ==  R )             s[j][i] =  D ;           else if (t[j] ==  U )             s[j][i] =  L ;           else             s[j][i] =  R ;         }       }       swap(n, m);     } else {       for (int i = 0; i < n; i++) scanf( %s , s[i]);     }     gao(ret1);     if (sw == 1) {       for (int i = 0; i < m; i++) {         scanf( %s , t);         for (int j = 0; j < n; j++) {           if (t[j] ==  L )             s[j][i] =  U ;           else if (t[j] ==  R )             s[j][i] =  D ;           else if (t[j] ==  U )             s[j][i] =  L ;           else             s[j][i] =  R ;         }       }     } else {       for (int i = 0; i < n; i++) scanf( %s , s[i]);     }     gao(ret2);     reverse((ret2).begin(), (ret2).end());     for (auto p : ret2) ret1.push_back(p);     if (sw) {       for (auto &p : ret1) swap(p.first, p.second);     }     printf( %d n , ((int)(ret1).size()));     for (auto p : ret1) printf( %d %d n , p.first + 1, p.second + 1);   }
#include <bits/stdc++.h>   const int N = 1e5 + 7;   long long n, m, A[N], sum[N], suf[N];   inline int read() {     int now = 0;     register char c = getchar();     for (; !isdigit(c); c = getchar())       ;     for (; isdigit(c); now = now * 10 + c -  0 , c = getchar())       ;     return now;   }   int main() {     n = read(), m = read();     for (int i = 1; i <= n; ++i) A[i] = read();     for (int i = 1; i <= n; i += 2)       sum[i + 1] = sum[i] = sum[i - 1] + A[i] - A[i - 1];     if (n & 1) {       for (int i = n - 1; i > 0; i -= 2)         suf[i - 1] = suf[i] = suf[i + 1] + A[i + 1] - A[i];     } else {       A[n + 1] = m;       for (int i = n; i > 0; i -= 2)         suf[i - 1] = suf[i] = suf[i + 1] + A[i + 1] - A[i];     }     long long ans = sum[n];     if (!(n & 1)) ans += m - A[n];     if (n & 1) A[++n] = m;     for (long long i = 1; i <= n; ++i)       if (A[i] - A[i - 1] > 1) {         if (i & 1)           ans =               std::max(ans, sum[i - 1] + A[i] - A[i - 1] - 1 + m - A[i] - suf[i]);         else           ans =               std::max(ans, sum[i - 1] + A[i] - A[i - 1] - 1 + m - A[i] - suf[i]);       }     printf( %I64d , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long oo = 1e18;   vector<int> dinh;   int nn;   long long n, m, k, kc[801][801];   vector<pair<long long, pair<long long, long long>>> e;   void compress() {     sort(dinh.begin(), dinh.end());     dinh.resize(unique(dinh.begin(), dinh.end()) - dinh.begin());     nn = dinh.size();     for (long long i = 0; i <= nn - 1; i++)       for (long long j = 0; j <= nn - 1; j++) kc[i][j] = oo;     for (long long i = 0; i <= nn - 1; i++) kc[i][i] = 0;     for (long long i = 0; i <= min(m, k) - 1; i++) {       long long first =           lower_bound(dinh.begin(), dinh.end(), e[i].second.first) - dinh.begin();       long long second =           lower_bound(dinh.begin(), dinh.end(), e[i].second.second) -           dinh.begin();       kc[first][second] = kc[second][first] = min(kc[first][second], e[i].first);     }   }   void floyd() {     for (long long k = 0; k <= nn - 1; k++)       for (long long first = 0; first <= nn - 1; first++)         for (long long second = 0; second <= nn - 1; second++)           kc[first][second] =               min(kc[first][second], kc[first][k] + kc[k][second]);   }   int main() {     cin >> n >> m >> k;     for (long long i = 0; i <= m - 1; i++) {       long long first, second, w;       cin >> first >> second >> w;       e.push_back({w, {first - 1, second - 1}});     }     sort(e.begin(), e.end());     for (long long i = 0; i <= min(m, k) - 1; i++) {       dinh.push_back(e[i].second.first);       dinh.push_back(e[i].second.second);     }     compress();     floyd();     vector<long long> res;     for (long long i = 0; i <= nn - 1; i++)       for (long long j = 0; j <= i - 1; j++) res.push_back(kc[i][j]);     sort(res.begin(), res.end());     cout << res[k - 1];     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 3e5 + 15;   struct Node {     int l, r;     bool operator<(const Node& b) const { return r != b.r ? r < b.r : l < b.l; }   };   unordered_map<int, vector<Node> > mp;   int sum[N];   int main() {     int n;     while (~scanf( %d , &n)) {       mp.clear();       for (int i = 1; i <= n; i++) {         scanf( %d , &sum[i]);         sum[i] += sum[i - 1];       }       for (int i = 1; i <= n; i++) {         for (int j = i; j <= n; j++) {           mp[sum[j] - sum[i - 1]].emplace_back(Node{i, j});         }       }       int ans = 0;       vector<Node> vec, vecAns;       for (auto ele : mp) {         sort(ele.second.begin(), ele.second.end());         vec.clear();         int sum = 0, r = 0;         for (auto seg : ele.second) {           if (seg.l > r) {             vec.emplace_back(Node{seg.l, seg.r});             r = seg.r;             sum++;           }         }         if (ans < sum) {           ans = sum;           vecAns = vec;         }       }       printf( %d n , ans);       for (auto ele : vecAns) {         printf( %d %d n , ele.l, ele.r);       }     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     string s;     cin >> s;     int sz = s.size();     s =  X  + s;     int k;     cin >> k;     int ans = 0;     for (int i = 1; i <= sz; i++) {       for (int len = 1; len <= 400; len++) {         if (i + 2 * len - 1 > sz + k) break;         bool can = true;         for (int l = i; l <= i + len - 1; l++) {           if (l > sz) break;           if (l + len <= sz) {             if (s[l] != s[l + len]) {               can = false;               break;             }           }         }         if (can) ans = max(ans, 2 * len);       }     }     cout << ans <<   n ;     return 0;   }
#include <bits/stdc++.h>      using namespace std;      #define ll long long int      void solve()   {       ll p,a,b,c;       cin >> p >> a >> b >> c;          ll ans = 1e18 + 1;       if(p%a != 0) ans = min(a - p%a, ans);       else ans = 0;       if(p%b != 0) ans = min(b - p%b, ans);       else ans = 0;       if(p%c != 0) ans = min(c - p%c, ans);       else ans = 0;              // if(ans == 1e18 + 1) ans = 0;          cout << ans << endl;   }      int main()   {       int t;       cin >> t;          while(t--) solve();          return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 300 + 66;   const long long mod = 1e9 + 7;   int N, M, Q;   int a[maxn][maxn];   int main() {     scanf( %d , &N);     for (int i = 1; i <= N; i++) {       for (int j = 1; j <= N; j++) {         scanf( %d , &a[i][j]);       }     }     scanf( %d , &Q);     int u, v, w;     while (Q--) {       scanf( %d %d %d , &u, &v, &w);       if (a[u][v] > w) {         a[u][v] = min(w, a[u][v]);         a[v][u] = min(w, a[u][v]);         for (int j = 1; j <= N; j++) {           for (int i = 1; i <= N; i++) {             a[i][j] = a[j][i] = min(a[j][i], a[j][u] + a[u][i]);           }         }         for (int j = 1; j <= N; j++) {           for (int i = 1; i <= N; i++) {             a[i][j] = a[j][i] = min(a[j][i], a[j][v] + a[v][i]);           }         }       }       long long s = 0;       for (int i = 1; i <= N; i++) {         for (int j = i + 1; j <= N; j++) {           s += a[i][j];         }       }       printf( %lld  , s);     }   }
#include <bits/stdc++.h>   using namespace std;   template <class T>   ostream& operator<<(ostream& os, vector<T> V) {     os <<  [  ;     for (auto v : V) os << v <<    ;     os <<  ] ;     return os;   }   template <class T>   ostream& operator<<(ostream& os, set<T> second) {     os <<  {  ;     for (auto s : second) os << s <<    ;     return os <<  } ;   }   template <class T>   ostream& operator<<(ostream& os, multiset<T> second) {     os <<  {  ;     for (auto s : second) os << s <<    ;     return os <<  } ;   }   template <class L, class R>   ostream& operator<<(ostream& os, pair<L, R> P) {     return os <<  (  << P.first <<  ,  << P.second <<  ) ;   }   template <class L, class R>   ostream& operator<<(ostream& os, map<L, R> M) {     os <<  {  ;     for (auto m : M) os <<  (  << m.first <<  :  << m.second <<  )  ;     return os <<  } ;   }   template <class L, class R>   ostream& operator<<(ostream& os, unordered_map<L, R> M) {     os <<  {  ;     for (auto m : M) os <<  (  << m.first <<  :  << m.second <<  )  ;     return os <<  } ;   }   const long long N = 200010, M = 1e9 + 7;   long long n, a[N];   vector<long long> f[N], sol;   void solve() {     cin >> n;     for (long long i = 0; i < n; i++) cin >> a[i];     for (long long i = 0; i < n; i++) f[a[i]].push_back(i + 1);     sol = vector<long long>(0);     long long minus = 0;     for (long long i = 0; i < n; i++) {       long long h = i - minus;       while (h >= 0 && f[h].size() == 0) h -= 3, minus += 3;       if (h < 0) {         cout <<  Impossible n ;         return;       }       sol.push_back(f[h].back());       f[h].pop_back();     }     cout <<  Possible n ;     for (long long it : sol) cout << it <<    ;     cout <<   n ;   }   int main() {     ios::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(0);     solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e5 + 5;   char s[N];   int a[N], b[N], n;   int f[N][2][2];   pair<int, int> g1[N][2][2], g2[N][2][2];   void solve() {     for (int l = 0, r = n + 1; l <= r; l++, r--) {       if (l + 1 == r || l == r) break;       int i = l;       for (int j = 0; j < 2; j++) {         for (int k = 0; k < 2; k++) {           if (!f[i][j][k]) continue;           for (int x = 0; x < 10; x++) {             int y = (a[l + 1] - x - k + 10) % 10;             if (r - 1 == n && y == 0) continue;             for (int j2 = 0; j2 < 2; j2++) {               if (j && (x + y + j2) < 10) continue;               if (!j && (x + y + j2) >= 10) continue;               if (a[r - 1] != (x + y + j2) % 10) continue;               int k2 = (x + y + k) >= 10 ? 1 : 0;               if (l + 2 < r - 1) {                 f[i + 1][j2][k2] = 1;                 g1[i + 1][j2][k2] = {x, y};                 g2[i + 1][j2][k2] = {j, k};               } else if (l + 2 == r - 1) {                 if (j2 == k2) {                   f[i + 1][j2][k2] = 1;                   g1[i + 1][j2][k2] = {x, y};                   g2[i + 1][j2][k2] = {j, k};                 }               } else if (l + 1 == r - 1) {                 if (j == k2 && j2 == k && x == y) {                   f[i + 1][j2][k2] = 1;                   g1[i + 1][j2][k2] = {x, y};                   g2[i + 1][j2][k2] = {j, k};                 }               }             }           }         }       }     }     int x = (n + 1) / 2, j, k;     for (int _ = 0; _ < 2; _++)       for (int __ = 0; __ < 2; __++)         if (f[x][_][__]) j = _, k = __;     if (!f[x][j][k]) return;     for (int l = x, r = x + (n % 2 == 0 ? 1 : 0); l >= 1; l--, r++) {       int i = l;       b[l] = g1[i][j][k].first, b[r] = g1[i][j][k].second;       int _ = g2[i][j][k].first, __ = g2[i][j][k].second;       j = _, k = __;     }     for (int i = n; i >= 1; i--) cout << b[i];     cout << endl;     exit(0);   }   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     cin >> (s + 1);     n = strlen(s + 1);     reverse(s + 1, s + n + 1);     for (int i = 1; i <= n; i++) a[i] = s[i] -  0 ;     f[0][0][0] = 1;     solve();     if (a[n] == 1 && n > 1) {       memset(f, 0, sizeof(f));       memset(g1, 0, sizeof(g1));       memset(g2, 0, sizeof(g2));       f[0][1][0] = 1;       --n;       solve();     }     cout << 0 << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long H;   int N, M, K;   long long A[100002], C[100002];   long long add[100002];   bool can[100002];   long long minget[10002];   set<pair<long long, int> > Q;   set<pair<int, int>, greater<pair<int, int> > > S;   int main() {     cin.sync_with_stdio(false);     cin >> H >> N >> M >> K;     for (int i = 0; i < K; ++i) minget[i] = 1LL << 62;     minget[0] = 0;     for (int i = 1; i <= N; ++i) {       cin >> C[i] >> A[i];       --C[i];       if (minget[C[i] % K] <= C[i]) {         S.insert(make_pair(A[i], -i));         can[i] = true;       }     }     for (int i = 1, type; i <= M; ++i) {       cin >> type;       if (type == 1) {         long long val;         cin >> val;         add[++add[0]] = val;         for (int j = 0; j < K; ++j) minget[j] = 1LL << 62;         minget[0] = 0;         Q.insert(make_pair(0, 0));         while (!Q.empty()) {           int now = (*Q.begin()).second;           Q.erase(Q.begin());           for (int j = 1; j <= add[0]; ++j)             if (minget[(now + add[j]) % K] > minget[now] + add[j]) {               minget[(now + add[j]) % K] = minget[now] + add[j];               Q.insert(make_pair(minget[(now + add[j]) % K], (now + add[j]) % K));             }         }         for (int j = 1; j <= N; ++j)           if (!can[j] && minget[C[j] % K] <= C[j]) {             S.insert(make_pair(A[j], -j));             can[j] = true;           }       } else if (type == 2) {         int pos, val;         cin >> pos >> val;         if (!can[pos])           A[pos] -= val;         else {           S.erase(S.find(make_pair(A[pos], -pos)));           A[pos] -= val;           S.insert(make_pair(A[pos], -pos));         }       } else if (type == 3) {         if (S.empty()) {           cout << 0 <<   n ;           continue;         }         cout << (*S.begin()).first <<   n ;         A[-(*S.begin()).second] = 0;         S.erase(S.begin());       }     }   }
#include <bits/stdc++.h>   using namespace std;   int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }   int main() {     int n;     cin >> n;     vector<int> m(n), r(n);     unsigned long long lcm = 1;     for (int i = 0; i < n; ++i) {       cin >> m[i];       lcm *= m[i] / gcd(m[i], lcm);     }     for (int i = 0; i < n; ++i) cin >> r[i];     int ans = 0;     for (int d = 0; d < lcm; ++d) {       for (int i = 0; i < n; ++i)         if (d % m[i] == r[i]) {           ++ans;           break;         }     }     cout.setf(ios::fixed | ios::showpoint);     cout.precision(6);     cout << 1.0 * ans / lcm;   }
#include <bits/stdc++.h>   using namespace std;   const int INF = 2147483647;   const double PI = 3.141592653589793;   const int N = 40005;   map<pair<int, int>, int> mapa;   int n, m, k, t, a, b, c, pocz[N], waste[N], r, i;   int main() {     scanf( %d %d %d %d , &n, &m, &k, &t);     for (i = 0; i < n; i++) waste[i] = 0;     mapa.clear();     while (k--) {       scanf( %d %d , &a, &b);       a--;       b--;       mapa[pair<int, int>(a, b)] = 1;       waste[a]++;     }     pocz[0] = 0;     for (i = 1; i < n; i++) pocz[i] = (pocz[i - 1] + m - waste[i - 1]) % 3;     while (t--) {       scanf( %d %d , &a, &b);       a--;       b--;       if (mapa.count(pair<int, int>(a, b)) > 0)         printf( Waste n );       else {         c = 0;         while (mapa.count(pair<int, int>(a, c)) > 0) c++;         r = pocz[a];         while (c != b) {           c++;           while (mapa.count(pair<int, int>(a, c)) > 0) c++;           r = (r + 1) % 3;         }         if (r == 0)           printf( Carrots n );         else if (r == 1)           printf( Kiwis n );         else           printf( Grapes n );       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long md = 1e9 + 7;   const int N = 100005;   long long power(long long x, long long y, long long p) {     long long res = 1;     x = x % p;     while (y > 0) {       if (y & 1) res = (res * x) % p;       y = y >> 1;       x = (x * x) % p;     }     return res;   }   long long fact[100003] = {1};   long long term(long long n, long long r) {     long long y = fact[n];     y = (y * power(fact[r], md - 2, md)) % md;     y = (y * power(fact[n - r], md - 2, md)) % md;     return y;   }   long long fun(long long x) {     long long val = 0;     for (int i = 0; i <= x / 2; i++) {       val = (val + term(x - i, i)) % md;     }     return val;   }   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     for (int i = 1; i <= 100002; i++) {       fact[i] = (fact[i - 1] * i) % md;     }     string s;     cin >> s;     long long u = 0, n = 0;     long long ans = 1;     for (int i = 0; i < s.size(); i++) {       if (s[i] ==  u ) {         u++;       } else {         if (u != 0) {           long long val = fun(u);           ans = (ans * val) % md;         }         u = 0;       }       if (s[i] ==  n ) {         n++;       } else {         if (n != 0) {           long long val = fun(n);           ans = (ans * val) % md;         }         n = 0;       }       if (s[i] ==  w  || s[i] ==  m ) {         cout <<  0               <<   n ;         return 0;       }     }     if (u != 0) {       long long val = fun(u);       ans = (ans * val) % md;     } else if (n != 0) {       long long val = fun(n);       ans = (ans * val) % md;     }     cout << ans <<   n ;     return 0;   }