malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   int n;   vector<double> first, second;   double eps = 0.0000001;   double ai;   int main() {     std::ios::sync_with_stdio(false);     cin >> n;     for (int i = 0; i < n; i++) {       cin >> ai;       first.push_back(ai);     }     for (int i = 0; i < n; i++) {       cin >> ai;       second.push_back(ai);     }     double s1 = 0;     double s2 = 0;     vector<double> a1, a2;     for (int i = 0; i < n; i++) {       double x = first[i];       double y = second[i];       double a = 1;       double b = -(s1 + x + y - s2);       double c = -(x * s2 + y * s2 - x);       double disc = b * b - 4 * a * c;       if (disc >= -eps && disc < 0) {         disc = 0;       }       disc = sqrt(disc);       double k1 = (-b + disc) / 2;       double k2 = (-b - disc) / 2;       double nn = 0;       if (k1 <= k2) swap(k1, k2);       if (k1 >= -eps && k1 <= x + y + eps) {         s2 += max(k1, nn);         s1 += max(nn, x + y - k1);         a2.push_back(max(k1, nn));         a1.push_back(max(nn, x + y - k1));       } else {         s2 += max(k2, nn);         s1 += max(nn, x + y - k2);         a2.push_back(max(k2, nn));         a1.push_back(max(nn, x + y - k2));       }     }     cout.precision(25);     for (int i = 0; i < n; i++) {       cout << a1[i] <<    ;     }     cout << endl;     for (int i = 0; i < n; i++) {       cout << a2[i] <<    ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, c[8005][8005], fal[8005], dp[8005], len[8005];   char s[8005];   void Init(char *s, int n, int *c) {     fal[1] = 0, fal[2] = 1;     for (int i = 2; i <= n; i++) {       int j = fal[i];       while (j && s[i] != s[j]) j = fal[j];       fal[i + 1] = j + 1;     }     for (int i = 1; i <= n; i++) {       int t = 1, k = i - fal[i + 1] + 1;       if (i % k == 0) t = i / k;       c[i] = i / t + len[t];     }   }   int main() {     scanf( %s , s + 1), n = strlen(s + 1);     for (int i = 1; i <= n; i++) len[i] = len[i / 10] + 1;     for (int i = 1; i <= n; i++) Init(s + i - 1, n - i + 1, c[i] + i - 1);     for (int i = 1; i <= n; i++) {       dp[i] = n + 1;       for (int j = 1; j <= i; j++) dp[i] = min(dp[i], dp[j - 1] + c[j][i]);     }     printf( %d n , dp[n]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 2e5 + 10;   const long long MOD = 1e9 + 7;   long long h[26][N], p[N];   int a[30], b[30];   char s[N + 10];   long long get(int i, int l, int r) {     return (h[i][r] - h[i][l - 1] * p[r - l + 1]) % MOD;   }   int main() {     int n, m, x, y, len;     while (scanf( %d%d , &n, &m) != EOF) {       p[0] = 1;       for (int i = 1; i <= n; i++) p[i] = (p[i - 1] * 2) % MOD;       scanf(  %s , s + 1);       for (int i = 0; i < 26; i++)         for (int j = 1; j <= n; j++)           h[i][j] = (h[i][j - 1] * 2 + (s[j] ==  a  + i)) % MOD;       while (m--) {         scanf( %d%d%d , &x, &y, &len);         for (int i = 0; i < 26; i++) {           a[i] = (get(i, x, x + len - 1) + MOD) % MOD;           b[i] = (get(i, y, y + len - 1) + MOD) % MOD;         }         sort(a, a + 26);         sort(b, b + 26);         bool flag = true;         for (int i = 0; i < 26; i++)           if (a[i] != b[i]) {             flag = false;             break;           }         printf( %s n , flag ?  YES  :  NO );       }     }   }
#include <bits/stdc++.h>   using namespace std;   const int MAX_NM = 1000 * 1000;   int dl;   char S[MAX_NM];   void dodaj(char l, int x) {     while (x--) {       dl++;       S[dl] = l;     }   }   int main() {     int n, m, k;     cin >> n >> m >> k;     if (k > 4 * n * m - 2 * n - 2 * m) {       cout <<  NO n ;       return 0;     }     for (int i = 1; i < m; i++) {       dodaj( D , n - 1);       dodaj( U , n - 1);       dodaj( R , 1);     }     dodaj( D , n - 1);     for (int i = n; i > 1; i--) {       dodaj( L , m - 1);       dodaj( R , m - 1);       dodaj( U , 1);     }     dodaj( L , m - 1);     vector<pair<char, int> > w;     char l = S[1];     int a = 1;     for (int i = 2; i <= k; i++) {       if (S[i] != S[i - 1]) {         w.push_back(make_pair(l, a));         l = S[i];         a = 1;       } else {         a++;       }     }     w.push_back(make_pair(l, a));     cout <<  YES  << endl;     cout << w.size() << endl;     for (pair<char, int> p : w) {       cout << p.second <<     << p.first << endl;     }     return 0;   }
#include <bits/stdc++.h>   #pragma GCC optimize( Ofast,unroll-loops )   #pragma GCC target( avx,avx2,fma )   using namespace std;   const long long mod1 = 998244353;   const long long mod = 1e9 + 7;   long long mod_mul(long long a, long long b) {     a = a % mod;     b = b % mod;     return (((a * b) % mod) + mod) % mod;   }   long long inv(long long i) {     if (i == 1) return 1;     return (mod - ((mod / i) * inv(mod % i)) % mod) % mod;   }   long long gcd(long long a, long long b) {     if (b == 0) return a;     return gcd(b, a % b);   }   long long pwr(long long a, long long b) {     a %= mod;     long long res = 1;     while (b > 0) {       if (b & 1) res = res * a % mod;       a = a * a % mod;       b >>= 1;     }     return res;   }   long long findMinNumber(long long n) {     long long count = 0, ans = 1;     while (n % 2 == 0) {       count++;       n /= 2;     }     if (count % 2) ans *= 2;     for (int i = 3; i <= sqrt(n); i += 2) {       count = 0;       while (n % i == 0) {         count++;         n /= i;       }       if (count % 2) ans *= i;     }     if (n > 2) ans *= n;     return ans;   }   mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     long long t;     cin >> t;     while (t--) {       long long n, k, i, j;       cin >> n >> k;       map<long long, long long> m;       vector<long long> ans;       vector<pair<long long, long long> > v;       long long a[k][2];       for (i = 0; i < k; i++) {         cin >> a[i][0] >> a[i][1];         v.push_back({a[i][0], a[i][1]});         m[a[i][0]]++;         m[a[i][1]]++;       }       for (i = 1; i < 2 * n + 1; i++)         if (m[i] == 0) ans.push_back(i);       for (i = 0; i < ans.size() / 2; i++) {         v.push_back({ans[i], ans[ans.size() / 2 + i]});       }       long long cnt = 0;       sort((v).begin(), (v).end());       for (i = 0; i < n; i++) {         for (j = 0; j < n; j++) {           if (i != j) {             long long x = (v[i].second - v[j].first) * (v[i].first - v[j].first);             long long y =                 (v[i].second - v[j].second) * (v[i].first - v[j].second);             if (x * y < 0) {               cnt++;             }           }         }       }       cout << cnt / 2 <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, m, f[50010];   struct node {     int f[12], g[12], size;   } a[50010];   struct cmp {     bool operator()(node a, node b) {       for (int i = 1; i <= m; i++)         if (a.f[i] > b.g[i]) return 0;       return 1;     }   };   multiset<node, cmp> q;   inline void up(node &a, node b) {     for (int i = 1; i <= m; i++)       a.f[i] = max(a.f[i], b.f[i]), a.g[i] = min(a.g[i], b.g[i]);     a.size += b.size;   }   inline bool operator==(node a, node b) {     int t = 0;     for (int i = 1; i <= m; i++) t |= (a.f[i] > b.g[i]) | (2 * (a.g[i] < b.f[i]));     return t == 3;   }   int main() {     cin >> n >> m;     for (int i = 1; i <= n; i++) f[i] = i;     node p1, p2;     for (int i = 1; i <= m; i++) p1.f[i] = p1.g[i] = 0;     for (int i = 1; i <= m; i++) p2.f[i] = p2.g[i] = 1999999999;     q.insert(p1);     q.insert(p2);     for (int i = 1; i <= n; i++)       for (int j = 1; j <= m; j++)         scanf( %d , &a[i].f[j]), a[i].g[j] = a[i].f[j], a[i].size = 1;     for (int i = 1; i <= n; i++) {       set<node>::iterator it = q.lower_bound(a[i]), it2;       while (*it == a[i]) it2 = it, it2--, up(a[i], *it), q.erase(it), it = it2;       it = q.lower_bound(a[i]);       while (*it == a[i]) it2 = it, it2++, up(a[i], *it), q.erase(it), it = it2;       q.insert(a[i]);       printf( %d n , (--(--q.end()))->size);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     string x, t;     getline(cin, x);     string temp =   ;     int index = -1;     for (int i = 0; i < x.size(); ++i) {       if (x[i] ==  = ) index = i;     }     index += 2;     for (int i = index; i < x.size(); ++i) temp.push_back(x[i]);     int n = stoi(temp.c_str());     int pos = 0;     int neg = 0;     int i = 0;     if (x[0] ==  ? ) {       ++pos;       ++i;     } else {       ++neg;       i += 2;     }     for (int i = 0; i < x.size(); ++i)       if (x[i] ==  + )         ++pos;       else if (x[i] ==  - )         ++neg;     vector<int> ne(neg, 1);     vector<int> po(pos, 1);     int sum = (pos * 1) - neg;     int j = 0, z = 0;     bool in = false;     while (1) {       if (sum == n) break;       if (sum > n) {         if (z == neg) {           cout <<  Impossible  << endl;           return 0;         }         if (ne[z] == n) {           ++z;           continue;         }         in = true;         ++ne[z];         sum -= 1;       } else if (sum < n) {         if (j == pos) {           cout <<  Impossible  << endl;           return 0;         }         if (po[j] == n) {           ++j;           continue;         }         in = true;         ++po[j];         sum += 1;       }     }     cout <<  Possible  << endl;     j = 0, z = 0;     string last =   ;     for (int i = 0; i < x.size(); ++i) {       if (x[i] ==  -  || x[i] ==  +  || i == 0) {         if (i > 0) {           if (x[i] ==  - ) {             last.push_back(x[i]);             stringstream ss;             ss << ne[z++];             last += ss.str();             ;           } else {             last.push_back(x[i]);             stringstream ss;             ss << po[j++];             last += ss.str();           }         }         if (i == 0) {           if (x[i] ==  - ) {             last.push_back(x[i]);             stringstream ss;             ss << ne[z++];             last += ss.str();             ;           } else {             stringstream ss;             ss << po[j++];             last += ss.str();           }         }       } else if (x[i] !=  ? )         last.push_back(x[i]);     }     cout << last << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void setIO(string NAME) {}   inline long long gI() {     char c = getchar();     while ((c <  0  || c >  9 ) && c !=  - ) c = getchar();     long long flag = 1, p = 0;     if (c ==  - ) flag = -1, c = getchar();     while (c >=  0  && c <=  9 ) p = p * 10 + (c -  0 ), c = getchar();     return p * flag;   }   int gs(char* C) {     char c = getchar();     while (c ==     || c ==   n ) c = getchar();     int l = 0;     while (c !=     && c !=   n ) C[l++] = c, c = getchar();     C[l] = 0;     return l;   }   template <class T>   void debug(const T a, const int& n) {     for (int i = 0; i < n; ++i) printf( %d%c , a[i], (i == n - 1) ?   n  :    );   }   const int inf = ~0U >> 1, maxn = 100000 + 10;   int n, m;   long long a[maxn];   vector<long long> b[maxn];   int main() {     setIO( test );     n = gI(), m = gI();     long long ans = 0;     for (int i = 0; i < m; ++i) {       a[i] = gI();       if (i) ans += abs(a[i] - a[i - 1]);     }     long long MAX = 0;     for (int i = 0; i < m; ++i) {       if (i && a[i - 1] != a[i]) b[a[i]].push_back(a[i - 1]);       if (i < m - 1 && a[i] != a[i + 1]) b[a[i]].push_back(a[i + 1]);     }     for (int i = 1; i <= n; ++i)       if (b[i].size()) {         sort(b[i].begin(), b[i].end());         int sz = b[i].size();         int m = (sz - 1) / 2;         long long origin = 0, now = 0;         for (int j = 0; j < sz; ++j) {           origin += abs((long long)b[i][j] - i);           now += abs(b[i][j] - b[i][m]);         }         MAX = max(MAX, origin - now);       }     ans -= MAX;     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   const int dx[] = {0, -1, 0, 1, -1, 1, 1, -1, -2, -2, 2, 2, -1, -1, 1, 1};   const int dy[] = {-1, 0, 1, 0, 1, 1, -1, -1, -1, 1, -1, 1, -2, 2, -2, 2};   using namespace std;   int main(int argc, char const *argv[]) {     int n, m;     scanf( %d %d , &n, &m);     while (n) {       printf( 0 );       n--;       if (!n) break;       printf( 1 );       n--;     }     printf(  n );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   struct ACfixed {     static const int ASZ = 10;     struct node {       array<int, ASZ> to;       int link = -1;       int tlink = -1;       int id = -1;     };     vector<node> d = {{}};     int add(string s, int id) {       int v = 0;       for (auto C : s) {         int c = C -  0 ;         if (!d[v].to[c]) d[v].to[c] = d.size(), d.emplace_back();         v = d[v].to[c];       }       d[v].id = id;       return v;     }     void init() {       d[0].link = -1;       queue<int> q;       q.push(0);       while (q.size()) {         int v = q.front();         q.pop();         for (int c = 0; c < ASZ; c++) {           int u = d[v].to[c];           if (!u) continue;           d[u].link = d[v].link == -1 ? 0 : d[d[v].link].to[c];           d[u].tlink = (d[d[u].link].id == -1) ? d[d[u].link].tlink : d[u].link;           q.push(u);         }         if (v)           for (int c = 0; c < ASZ; c++)             if (!d[v].to[c]) d[v].to[c] = d[d[v].link].to[c];       }     }     vector<vector<int>> getAll(string &word) {       vector<vector<int>> res(d.size(), vector<int>());       int v = 0;       for (int i = 0; i < word.length(); i++) {         v = d[v].to[word[i] -  0 ];         int cur = v;         while (cur >= 0) {           if (d[cur].id != -1) {             res[d[cur].id].push_back(i);           }           cur = d[cur].tlink;         }       }       return res;     }   };   vector<string> arr;   int n, x;   string s;   string curstr =   ;   ACfixed ac;   void gen(int cur) {     if (cur == 0) {       arr.push_back(curstr);       return;     }     for (int i = 1; i <= 9; i++) {       if (i > cur) continue;       curstr.push_back( 0  + i);       int csum = 0;       bool work = true;       for (int j = curstr.size() - 1; j >= 0; j--) {         csum += curstr[j] -  0 ;         if (csum != x && x % csum == 0) {           work = false;           break;         }       }       if (work) gen(cur - i);       curstr.pop_back();     }   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cin >> s >> x;     n = s.length();     gen(x);     for (int i = 0; i < arr.size(); i++) ac.add(arr[i], i);     ac.init();     vector<int> dp(ac.d.size(), 1000000009);     dp[0] = 0;     for (auto ch : s) {       vector<int> nextdp(ac.d.size(), 1000000009);       for (int state = 0; state < ac.d.size(); state++) {         if (dp[state] == 1000000009) continue;         nextdp[state] = min(nextdp[state], dp[state] + 1);         int trans = ac.d[state].to[ch -  0 ];         if (ac.d[trans].id == -1) nextdp[trans] = min(nextdp[trans], dp[state]);       }       swap(dp, nextdp);     }     cout << *min_element(dp.begin(), dp.end()) << endl;   }
#include <bits/stdc++.h>   using namespace std;   const long long maxn = 1e6 + 5;   const int INF = 0x7fffffff;   bool p(long long a) {     for (long long i = 2; i <= sqrt(a); i++) {       if (a % i == 0) return 0;     }     return 1;   }   int main() {     int n;     cin >> n;     int c = n;     while (!p(c)) {       c++;     }     cout << c <<   n ;     for (int i = 1; i < n; i++) cout << i <<     << i + 1 <<   n ;     cout << 1 <<     << n <<   n ;     for (int i = 1; i <= c - n; i++) cout << i <<     << n - i <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   int f[35][1005][5];   void preprocess() {     int i, j, k, l;     for (i = 0; i <= 1000; i++)       f[0][i][0] = f[0][i][1] = f[0][i][2] = f[0][i][3] = 0;     i = 0;     f[0][i][0] = f[0][i][1] = f[0][i][2] = f[0][i][3] = 1;     for (i = 1; i < 31; i++) {       f[i][0][0] = 1;       for (j = 1; j <= 1000; j++) f[i][j][0] = f[i - 1][j - 1][2];       for (k = 1; k <= 2; k++)         for (j = 0; j <= 1000; j++) {           f[i][j][k] = 0;           for (l = 0; l <= j; l++)             f[i][j][k] = (f[i][j][k] +                           (((long long int)f[i][l][k - 1] * f[i][j - l][k - 1]) %                            7340033)) %                          7340033;         }     }   }   int finddepth(int n) {     int d = 0;     while (n > 1 && n % 2 != 0) {       n = (n - 1) / 2;       d++;     }     return d;   }   int main() {     int q;     int n, k;     preprocess();     cin >> q;     while (q--) {       cin >> n >> k;       cout << f[finddepth(n)][k][0] << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 200005;   const int G = N;   set<pair<int, int> > S;   set<int> a[N];   int ans[N];   bool was[N];   vector<int> C[G + G];   int n, m;   bool solve() {     while (!S.empty()) {       int idx = S.begin()->second;       if (a[idx].empty()) {         cerr <<  fail   << idx << endl;         return 0;       }       int u = *a[idx].begin();       ans[abs(u)] = u / abs(u);       was[idx] = 1;       S.erase(S.begin());       for (int v : C[u + G])         if (!was[v]) {           was[v] = 1;           auto it = S.find(pair<int, int>(a[v].size(), v));           assert(it != S.end());           S.erase(it);         }       for (int v : C[-u + G])         if (!was[v]) {           auto it = S.find(pair<int, int>(a[v].size(), v));           assert(it != S.end());           a[v].erase(-u);           S.erase(it);           S.insert(pair<int, int>(a[v].size(), v));         }     }     return 1;   }   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cin >> n >> m;     int s, u;     for (int i = 1; i <= n; ++i) {       cin >> s;       for (int j = 1; j <= s; ++j) {         cin >> u;         a[i].insert(u);         C[u + G].push_back(i);       }       S.insert(pair<int, int>(a[i].size(), i));     }     bool res = solve();     if (res) {       cout <<  YES n ;       for (int i = 1; i <= m; ++i) cout << (ans[i] == 1);     } else {       cout <<  NO n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, m;   char an[505];   vector<int> b, other[5];   int A[505][505], visited[505], ans[5];   int dfs(int node, int flag) {     int sz = 1;     visited[node] = flag;     other[flag].push_back(node);     for (int i = 0; i < n; ++i)       if (!visited[i] and A[node][i]) sz += dfs(i, flag);     return sz;   }   int main() {     scanf( %d%d , &n, &m);     for (int i = 0; i < m; ++i) {       int a, b;       scanf( %d%d , &a, &b);       --a;       --b;       A[a][b] = A[b][a] = 1;     }     for (int i = 0; i < n; ++i) {       an[i] =  b ;       bool connected = true;       for (int j = 0; j < n and connected; ++j)         if (i != j and !A[i][j]) connected = false;       if (connected) {         visited[i] = 5;         b.push_back(i);       }     }     for (int i = 0; i < (int)b.size(); ++i)       for (int j = 0; j < n; ++j) A[j][b[i]] = A[b[i]][j] = 0;     int cnt = 0;     for (int i = 0; i < n; ++i) {       if (!visited[i]) {         if (cnt == 2) {           printf( No n );           return 0;         }         ans[cnt] = dfs(i, cnt + 1);         ++cnt;       }     }     for (int i = 1; i < 3; ++i)       for (int j = 0; j < (int)other[i].size(); ++j)         for (int k = j + 1; k < (int)other[i].size(); ++k) {           assert(A[other[i][j]][other[i][k]] == A[other[i][k]][other[i][j]]);           if (!A[other[i][j]][other[i][k]]) {             printf( No n );             return 0;           }         }     printf( Yes n );     for (int i = 0; i < ans[0]; ++i) an[other[1][i]] =  a ;     for (int i = 0; i < ans[1]; ++i) an[other[2][i]] =  c ;     an[n] =   0 ;     printf( %s n , an);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long mod = 1e9 + 7;   int dx[] = {-1, 1, 0, 0, -1, 1, -1, 1};   int dy[] = {0, 0, 1, -1, 1, -1, -1, 1};   void fast() {     ios_base::sync_with_stdio(0);     cin.tie(0);   }   long long gcd(long long x, long long y) {     if (!y) return x;     return gcd(y, x % y);   }   long long lcm(long long x, long long y) { return (x / gcd(x, y)) * y; }   long long fastpow(long long a, long long b) {     long long res = 1;     int last;     while (b) {       if (b % 2) res *= a;       b /= 2, a *= a;     }     return res;   }   bool isprime(long long n) {     if (n == 1 || n == 0) return 0;     for (int i = 2; i <= sqrt(n); i++)       if (n % i == 0) return 0;     return 1;   }   int main() {     fast();     int ma = INT_MIN;     int n, a;     cin >> n;     bool found = 1;     stack<int> stk;     for (int i = 0; i < n; i++) {       cin >> a;       ma = max(ma, a);       if (!stk.empty() && a > stk.top()) found = 0;       if (stk.empty() || a != stk.top())         stk.push(a);       else         stk.pop();     }     if (!found || (stk.size() == 1 && stk.top() < ma))       cout <<  NO n ;     else       cout << (stk.size() > 1 ?  NO n  :  YES n );   }
#include <bits/stdc++.h>   using namespace std;   template <typename Tp>   inline void outarr(Tp _begin, Tp _end, const char* _delim =    ) {     for (Tp current = _begin; current != _end; ++current) {       std::cout << *current << _delim;     }     std::cout <<   n ;   }   using ll = int64_t;   using pii = std::pair<int, int>;   constexpr int INF = 0x3f3f3f3f;   constexpr int MOD = static_cast<const int>(1e9 + 7);   int F(int x) {     if (x == 1) {       return 1;     }     return 12 * (x - 1);   }   int main() {     std::ios_base::sync_with_stdio(false);     std::cin.tie(nullptr);     int a;     cin >> a;     ll ans = 0;     for (int i = 1; i <= a; ++i) {       ans += F(i);     }     cout << ans <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long n;   const long long mod = 1000000007LL;   long long dp[35][35][2];   void init() {     int tmp;     scanf( %d , &tmp);     n = tmp;   }   void process() {     dp[32][0][0] = 1;     for (int i = 32; i > 0; i--) {       for (int j = 0; j <= 32 - i; j++) {         long long t1, t2;         if (j == 0)           t1 = 1, t2 = 0;         else           t1 = t2 = 1 << (j - 1);         if (n & (1 << (i - 1))) {           dp[i - 1][j][0] = (dp[i - 1][j][0] + dp[i][j][0] * t2) % mod;           dp[i - 1][j + 1][0] = (dp[i - 1][j + 1][0] + dp[i][j][0]) % mod;           dp[i - 1][j][1] = (dp[i - 1][j][1] + dp[i][j][0] * t1) % mod;           dp[i - 1][j + 1][1] = (dp[i - 1][j + 1][1] + dp[i][j][1]) % mod;           dp[i - 1][j][1] = (dp[i - 1][j][1] + dp[i][j][1] * (t1 + t2)) % mod;         } else {           dp[i - 1][j][0] = (dp[i - 1][j][0] + dp[i][j][0] * t1) % mod;           dp[i - 1][j + 1][1] = (dp[i - 1][j + 1][1] + dp[i][j][1]) % mod;           dp[i - 1][j][1] = (dp[i - 1][j][1] + dp[i][j][1] * (t1 + t2)) % mod;         }       }     }     long long ans = 0;     for (int i = 0; i <= 32; i++) ans = (ans + dp[0][i][0] + dp[0][i][1]) % mod;     cout << ans << endl;   }   int main() {     init();     process();     return 0;   }