malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   int n, t, k, cnt = 0;   int a[200005], st[200005];   struct hehe {     int x, y;   } e[200005];   void add(int x, int y) {     cnt++;     e[cnt].x = x;     e[cnt].y = y;   }   void solve() {     int i, j;     int minn = 1, maxx = 1;     a[0] = 1;     st[0] = 1;     for (i = 1; i <= t; i++) {       maxx = maxx + a[i] - 1;       st[i] = st[i - 1] + a[i - 1];       if (a[i] >= a[i - 1]) minn += a[i] - a[i - 1];     }     if (minn > k || maxx < k) {       printf( -1 n );       return;     }     printf( %d n , n);     for (i = st[1]; i <= st[1] + a[1] - 1; i++) add(1, i);     for (i = 1; i <= t - 1; i++) {       if (minn < k) {         for (j = 1; j <= a[i + 1] - a[i] && j <= a[i + 1]; j++)           add(st[i], st[i + 1] + j - 1);         int zuida;         if (a[i + 1] >= a[i])           zuida = a[i] - 1;         else           zuida = a[i + 1] - 1;         if (minn + zuida < k) {           int delta = max(0, a[i + 1] - a[i]);           minn += zuida;           for (j = st[i + 1] + delta; j <= st[i + 1] + a[i + 1] - 1; j++)             add(st[i], j);         } else {           int delta = max(0, a[i + 1] - a[i]);           int xiaid;           int zhiqian;           if (a[i + 1] >= a[i])             zhiqian = 0;           else             zhiqian = a[i] - a[i + 1];           for (j = 1; j <= a[i] - (zhiqian + (k - minn)); j++) {             xiaid = st[i + 1] + delta + j - 1;             add(st[i] + j - 1, xiaid);           }           for (j = xiaid + 1; j <= st[i + 1] + a[i + 1] - 1; j++) add(st[i], j);           minn = k;         }       } else {         for (j = 1; j <= a[i + 1] - a[i]; j++) add(st[i], st[i + 1] + j - 1);         int id = st[i];         int delta = max(0, a[i + 1] - a[i]);         for (j = st[i + 1] + delta; j <= st[i + 1] + a[i + 1] - 1; j++) {           add(id, j);           id++;         }       }     }     for (i = 1; i <= cnt; i++) cout << e[i].x <<     << e[i].y << endl;   }   int main() {     while (scanf( %d%d%d , &n, &t, &k) != EOF) {       int i;       cnt = 0;       for (i = 1; i <= t; i++) scanf( %d , &a[i]);       solve();     }     return 0;   }
#include <bits/stdc++.h>   #pragma comment(linker,  /STACK:1024000000,1024000000 )   using namespace std;   long long qp(long long a, long long b, long long mod) {     long long t = 1;     while (b) {       if (b & 1) t = t * a % mod;       b >>= 1;       a = a * a % mod;     }     return t;   }   struct DOT {     int x;     int y;   };   inline void read(int &x) {     int k = 0;     char f = 1;     char c = getchar();     for (; !isdigit(c); c = getchar())       if (c ==  - ) f = -1;     for (; isdigit(c); c = getchar()) k = k * 10 + c -  0 ;     x = k * f;   }   void ex() {     puts( -1 );     exit(0);   }   const int dx[4] = {-1, 0, 1, 0};   const int dy[4] = {0, 1, 0, -1};   const int inf = 0x3f3f3f3f;   const long long Linf = 0x3f3f3f3f3f3f3f3fll;   const long long mod = 1e9 + 7;   const double pi = acos(-1.0);   const double eps = 1e-7;   const int maxn = 5e5 + 344;   int n, k;   map<int, int> mp;   int a[maxn], b[maxn];   int main() {     scanf( %d%d , &n, &k);     int rembk = k;     long long sum = 0;     for (int i = 1; i <= n; i++) {       scanf( %d , &a[i]);       sum += a[i];       mp[a[i]]++;     }     int tot = 0;     sort(a + 1, a + 1 + n);     for (int i = 1; i <= n; i++) {       if (a[i] != a[i - 1]) {         b[++tot] = a[i];       }     }     int mov = 0;     int mnto = b[1];     for (int i = 1; i <= tot; i++) {       if (1ll * mov * (b[i] - b[i - 1]) <= 1ll * k) {         k -= mov * (b[i] - b[i - 1]);         mnto = b[i];         mov += mp[b[i]];       } else         break;     }     mnto += k / mov;     k = rembk;     mov = 0;     int mxto = b[tot];     b[tot + 1] = b[tot];     for (int i = tot; i >= 1; i--) {       if (1ll * mov * (b[i + 1] - b[i]) <= 1ll * k) {         k -= mov * (b[i + 1] - b[i]);         mxto = b[i];         mov += mp[b[i]];       } else         break;     }     mxto -= k / mov;     if (mxto <= mnto) {       if (sum % n == 0) {         puts( 0 );       } else         puts( 1 );     } else {       printf( %d n , mxto - mnto);     }   }
#include <bits/stdc++.h>   const int MAX = 1e3 + 5;   using namespace std;   int edge, mx, ans, seen[MAX], a, n, m, k, spec[MAX], check[MAX][MAX];   vector<int> adj[MAX];   vector<int> cur;   void dfs(int node) {     if (seen[node] == 1) return;     seen[node] = 1;     cur.push_back(node);     for (int i = int(0); i <= int(adj[node].size() - 1); i++) dfs(adj[node][i]);   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cin >> n >> m >> k;     for (int i = int(1); i <= int(k); i++) cin >> a, spec[a] = 1;     for (int i = int(1); i <= int(m); i++) {       int u, v;       cin >> u >> v;       adj[u].push_back(v);       adj[v].push_back(u);       check[u][v] = check[v][u] = 1;     }     for (int i = int(1); i <= int(n); i++)       if (spec[i] == 1) {         dfs(i);         mx = max(int(cur.size()), mx);         int comb = (cur.size() == 1 ? 0 : (cur.size() * (cur.size() - 1) / 2));         for (int i = int(0); i <= int(cur.size() - 1); i++) {           for (int j = int(i + 1); j <= int(cur.size() - 1); j++)             edge += check[cur[i]][cur[j]];         }         ans += comb - edge;         cur.clear();         edge = 0;       }     for (int i = int(1); i <= int(n); i++) {       if (seen[i] == 1) continue;       dfs(i);       int comb = (cur.size() == 1 ? 0 : (cur.size() * (cur.size() - 1) / 2));       for (int i = int(0); i <= int(cur.size() - 1); i++) {         for (int j = int(i + 1); j <= int(cur.size() - 1); j++)           edge += check[cur[i]][cur[j]];       }       ans += comb - edge;       ans += mx * int(cur.size());       mx += cur.size();       cur.clear();       edge = 0;     }     cout << ans <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long int po(int a) {     if (a == 0) return 1;     long long int x = po(a / 2);     x = x * x;     x %= 1000000007;     if (a % 2 == 0) {       return x;     } else {       x = x * 2;       x %= 1000000007;       return x;     }   }   int main() {     int x, y;     cin >> x >> y;     if (y % x != 0) {       cout << 0 << endl;     } else {       y = y / x;       vector<int> val;       for (int i = 1; i * i <= y; i++) {         if (y % i == 0) {           val.push_back(i);           if (i * i != y) {             val.push_back(y / i);           }         }       }       sort(val.begin(), val.end());       vector<int> ans(val.size(), 0);       ans[0] = 1;       for (int i = 1; i < val.size(); i++) {         ans[i] = po(val[i] - 1);         for (int j = 0; j < i; j++) {           if (val[i] % val[j] != 0) continue;           ans[i] -= ans[j];           ans[i] = ans[i] % 1000000007;         }       }       if (ans[val.size() - 1] < 0) {         ans[val.size() - 1] += 1000000007;       }       cout << ans[val.size() - 1] << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAX_N = 1e6 + 5;   const double delta = 1e-6;   const long long mod = 1e9 + 7;   struct ev {     double coord;     int type;     int mincost;   };   const bool operator<(const ev& f, const ev& s) { return f.coord < s.coord; }   void init() {}   class fenwick {     vector<int> sums;       public:     fenwick(int n) { sums.resize(n + 3); }     void add(int pos, int delta) {       for (pos++; pos < sums.size(); pos += pos & (-pos)) sums[pos] += delta;     }     int size() { return sums.size() - 2; }     int pref_sum(int pos) {       if (pos < -1) return 0;       int answer = 0;       for (pos++; pos > 0; pos -= pos & (-pos)) answer += sums[pos];       return answer;     }     int get_sum(int left, int right) {       return pref_sum(right) - pref_sum(left - 1);     }   };   const bool cmppp(const pair<int, int>& f, const pair<int, int>& s) {     return (f.second == s.second) ? (f.first < s.first) : (f.second > s.second);   }   vector<int> unique_xs;   void compress() {     sort(unique_xs.begin(), unique_xs.end());     unique_xs = vector<int>(unique_xs.begin(),                             unique(unique_xs.begin(), unique_xs.end()));   }   int get_num(int dt) {     return lower_bound(unique_xs.begin(), unique_xs.end(), dt) -            unique_xs.begin();   }   class dsu {    public:     vector<int> a;     vector<int> sizes;     dsu(int n, vector<int>& sizes) : sizes(sizes) {       a.resize(n);       for (int i = 0; i < n; i++) {         a[i] = i;       }     }     int get_parent(int x) { return (a[x] == x) ? x : (a[x] = get_parent(a[x])); }     void unite(int l, int r) {       int par_1 = get_parent(l);       int par_2 = get_parent(r);       if (par_1 == par_2) return;       if (sizes[par_1] < sizes[par_2]) swap(par_1, par_2);       sizes[par_1] += sizes[par_2];       sizes[par_2] = 0;       a[par_2] = par_1;     }   };   bool is_prime(int number) {     for (int i = 2; i * i <= number; i++) {       if (number % i == 0) {         return false;       }     }     return true;   }   string s;   string left_answer =   ;   string right_answer =   ;   void squeeze(int& l, int& r) {     if (l == r) {       left_answer += s[l];       l++;       return;     }     if (s[l] == s[r]) {       left_answer += s[l];       right_answer += s[r];       l++;       r--;       return;     }     if (l + 1 >= r && s[l] != s[r]) {       left_answer += s[l];       l++;       r--;       return;     }     if (s[l + 1] == s[r]) {       left_answer += s[l + 1];       right_answer += s[r];       l += 2;       r--;       return;     }     if (s[l] == s[r - 1]) {       left_answer += s[l];       right_answer += s[r - 1];       l++;       r -= 2;       return;     }     l++;     r--;   }   void solve() {     cin >> s;     int left = 0;     int right = s.size() - 1;     while (left <= right) {       squeeze(left, right);     }     reverse(right_answer.begin(), right_answer.end());     cout << left_answer << right_answer <<   n ;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     srand(58164);     solve();   }
#include <bits/stdc++.h>   using namespace std;   int dp[4010][4010];   int pa[4010][4010], pb[4010][4010];   char a[4010], b[4010];   int ti, td, tr, te;   int la, lb;   int main() {     scanf( %d%d%d%d , &ti, &td, &tr, &te);     scanf( %s%s , a + 1, b + 1);     la = strlen(a + 1);     lb = strlen(b + 1);     for (int i = 1; i <= la; i++) {       for (int j = 1; j <= lb; j++) {         pa[i][j] = pa[i][j - 1];         if (a[i] == b[j]) pa[i][j] = j;       }     }     for (int i = 1; i <= lb; i++) {       for (int j = 1; j <= la; j++) {         pb[i][j] = pb[i][j - 1];         if (a[j] == b[i]) pb[i][j] = j;       }     }     for (int i = 0; i <= la; i++) {       for (int j = 0; j <= lb; j++) {         if (!i && !j) continue;         dp[i][j] = 1e9;         if (j) dp[i][j] = min(dp[i][j], dp[i][j - 1] + ti);         if (i) dp[i][j] = min(dp[i][j], dp[i - 1][j] + td);         if (i && j) {           if (a[i] == b[j])             dp[i][j] = min(dp[i][j], dp[i - 1][j - 1]);           else             dp[i][j] = min(dp[i][j], dp[i - 1][j - 1] + tr);           int li = pb[j][i - 1], lj = pa[i][j - 1];           if (li && lj) {             dp[i][j] = min(dp[i][j], dp[li - 1][lj - 1] + td * (i - li - 1) +                                          ti * (j - lj - 1) + te);           }         }       }     }     printf( %d , dp[la][lb]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int INF = 0x3f3f3f3f;   const int MOD = 1e9 + 7;   int n, k;   long long quick(long long A, long long B) {     if (B == 0) return 1;     long long tmp = quick(A, B >> 1);     tmp *= tmp;     tmp %= MOD;     if (B & 1) tmp *= A, tmp %= MOD;     return tmp;   }   int fact[100000 + 20], invfact[100000 + 20];   int suf[100000 + 20];   int tot;   int rest = 0;   long long c(int A, int B) {     if (B == 0) return 1;     if (B < 0) return 0;     if (A < B) return 0;     return 1ll * fact[A] * invfact[A - B] % MOD * invfact[B] % MOD;   }   int main() {     scanf( %d%d , &n, &k);     string s;     cin >> s;     for (int i = n - 1; i >= 1; --i) suf[i] = suf[i + 1] + (s[i - 1] -  0 );     fact[0] = 1;     for (int i = 1; i <= n; ++i) {       fact[i] = 1ll * fact[i - 1] * i % MOD;     }     invfact[n] = quick(fact[n], MOD - 2);     for (int i = n - 1; i >= 0; --i)       invfact[i] = 1ll * invfact[i + 1] * (i + 1) % MOD;     tot = 0;     int bad = 0, ten = 1;     for (int i = 1; i <= n - 2; ++i) {       tot -= bad;       tot += MOD;       tot %= MOD;       tot = 10ll * tot % MOD;       bad += 1ll * ten * (s[n - 1 - i] -  0 ) % MOD;       bad %= MOD;       ten = 10ll * ten % MOD;       (tot += suf[i + 1]) %= MOD;       (rest += 1ll * tot * c(n - 2 - i, k - 2) % MOD) %= MOD;     }     int tmp = 0;     for (int i = 1; i <= n - 1; ++i) {       tmp = 10ll * tmp % MOD;       (tmp += (s[i - 1] -  0 )) %= MOD;       (rest += 1ll * tmp * c(n - 1 - i, k - 1) % MOD) %= MOD;     }     int z = 1;     tmp = 0;     for (int i = 1; i <= n; ++i) {       (tmp += 1ll * (s[n - i] -  0 ) * z % MOD) %= MOD;       z = 10ll * z % MOD;       (rest += 1ll * tmp * c(n - 1 - i, k - (i != n)) % MOD) %= MOD;     }     cout << rest << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     int n, m;     cin >> n >> m;     char **a = new char *[n];     for (int i = 0; i < n; i++) {       a[i] = new char[m + 1];       cin >> a[i];     }     for (int i = 0; i < n; i++)       for (int j = 0; j < m; j++)         for (int k = 0; k < n; k++)           for (int l = 0; l < m; l++) {             if (i == k && j == l) {               continue;             }             if (a[i][j] ==  W  || a[k][l] ==  W ) {               continue;             }             bool found1 = true;             for (int i1 = j; i1 <= l; i1++) {               if (a[i][i1] ==  W ) {                 found1 = false;                 break;               }             }             for (int i1 = i; i1 <= k; i1++) {               if (a[i1][l] ==  W ) {                 found1 = false;                 break;               }             }             if (found1) {               continue;             }             found1 = true;             for (int i1 = i; i1 <= k; i1++) {               if (a[i1][j] ==  W ) {                 found1 = false;                 break;               }             }             for (int i1 = j; i1 <= l; i1++) {               if (a[k][i1] ==  W ) {                 found1 = false;                 break;               }             }             if (found1) {               continue;             } else {               cout <<  NO ;               return 0;             }           }     cout <<  YES ;   }
#include <bits/stdc++.h>   using namespace std;   void solve() {     long long int n, k;     cin >> n >> k;     string s;     cin >> s;     string ans =   ;     long long int reqd = k / 2, op = 0, cl = 0;     for (auto x : s) {       if (op < reqd) {         if (x ==  ( ) {           ans.push_back(x);           op++;         }       }       if (cl < reqd) {         if (x ==  ) ) {           ans.push_back(x);           cl++;         }       }       if (op == reqd and cl == reqd) {         break;       }     }     cout << ans <<   n ;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     solve();   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, i, j, s1 = 0, s2 = 0, s3 = 0, s4 = 0;     int a[105][105];     cin >> n;     int k = (n + 1) / 2;     for (i = 1; i <= n; i++) {       for (j = 1; j <= n; j++) {         cin >> a[i][j];       }       cout << endl;     }     for (i = 1; i <= n; i++) {       s1 += a[i][k];     }     for (j = 1; j <= n; j++) {       s2 += a[k][j];     }     for (int m = 1, x = 1, y = n; m < k; m++, x++, y--) {       s3 += a[m][x] + a[m][y];     }     for (int m = n, x = 1, y = n; m > k; m--, x++, y--) {       s4 += a[m][x] + a[m][y];     }     cout << s1 + s2 + s3 + s4 - a[k][k] << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int32_t main() {     ios::sync_with_stdio(0);     int64_t n, m, d;     cin >> n >> m >> d;     vector<pair<int64_t, int64_t> > a1(n), a2(m);     for (auto &e : a1) {       cin >> e.first >> e.second;       e.second = -e.second;     }     for (auto &e : a2) {       cin >> e.first >> e.second;       e.second = -e.second;     }     sort(a1.begin(), a1.end());     sort(a2.begin(), a2.end());     reverse(a1.begin(), a1.end());     reverse(a2.begin(), a2.end());     vector<int64_t> p2c(m), p2w(m);     int64_t ans = 0;     for (int64_t i = 0; i < m; i++) {       p2c[i] = a2[i].first;       p2w[i] = -a2[i].second;       if (i > 0) {         p2c[i] += p2c[i - 1];         p2w[i] += p2w[i - 1];       }     }     int64_t Len = 0, C = 0;     for (int64_t i = 0; i < n; i++) {       C += a1[i].first;       d += a1[i].second;       int64_t idx = upper_bound(p2w.begin(), p2w.end(), d) - p2w.begin();       if (idx == 0) break;       ans = max(ans, C + p2c[idx - 1]);     }     cout << ans;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, b;     cin >> n >> b;     if (n - b <= b) {       cout << -1;     } else {       cout << b * n <<   n ;       for (int i = 1; i <= n; i++) {         for (int j = i + 1; j <= b + i; j++) {           cout << i <<    ;           if (j % n == 0) {             cout << j <<   n ;           } else {             cout << j % n <<   n ;           }         }       }     }   }
#include <bits/stdc++.h>   using namespace std;   template <typename T>   inline bool chkmin(T &x, T y) {     return y < x ? x = y, 1 : 0;   }   template <typename T>   inline bool chkmax(T &x, T y) {     return x < y ? x = y, 1 : 0;   }   const int INF = 0x3f3f3f3f;   const int N = 2e3 + 10, mod = 1e9 + 7;   int dir[4][2] = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}};   int vis[N][N];   char Map[N][N];   struct node {     int x, y;   } dis[N][N];   deque<node> Q;   inline int read() {     int x = 0, flag = 1;     char ch = getchar();     while (!isdigit(ch) && ch !=  - ) ch = getchar();     if (ch ==  - ) flag = -1, ch = getchar();     while (isdigit(ch)) x = (x << 3) + (x << 1) + (ch -  0 ), ch = getchar();     return x * flag;   }   int main() {     int n = read(), m = read(), X = read(), Y = read(), L = read(), R = read();     for (int i = (1), iend = (n); i <= iend; i++) scanf( %s , Map[i] + 1);     int cnt = 1;     Q.push_back((node){X, Y}), vis[X][Y] = true;     while (!Q.empty()) {       node cur = Q.front();       Q.pop_front();       int x = cur.x, y = cur.y;       for (int i = (0), iend = (3); i <= iend; i++) {         int Nx = x + dir[i][0], Ny = y + dir[i][1], curdL = dis[x][y].x,             curdR = dis[x][y].y;         if (Nx <= 0 || Ny <= 0 || Nx > n || Ny > m || vis[Nx][Ny] ||             Map[Nx][Ny] ==  * )           continue;         if (i == 2) curdR++;         if (i == 3) curdL++;         if (curdL > L || curdR > R) continue;         if (i == 2 || i == 3)           Q.push_back((node){Nx, Ny});         else           Q.push_front((node){Nx, Ny});         dis[Nx][Ny] = (node){curdL, curdR};         vis[Nx][Ny] = true, cnt++;       }     }     printf( %d n , cnt);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 100010;   long long int tmp = 85;   long long int a[MAXN], b[MAXN], ind[MAXN];   vector<long long int> o;   long long int n, d, x;   long long int getNextX() {     x = (x * 37 + 10007) % 1000000007;     return x;   }   int main() {     cin >> n >> d >> x;     for (long long int i = 0; i < n; i = i + 1) {       a[i] = i + 1;     }     for (long long int i = 0; i < n; i = i + 1) {       swap(a[i], a[getNextX() % (i + 1)]);     }     for (long long int i = 0; i < n; i = i + 1) {       if (i < d)         b[i] = 1;       else         b[i] = 0;     }     for (int i = 0; i < n; i = i + 1) {       swap(b[i], b[getNextX() % (i + 1)]);     }     for (int i = 0; i < n; i++) {       ind[a[i]] = i;     }     for (int i = 0; i < n; i++) {       if (b[i] == 1) {         o.push_back(i);       }     }     for (int i = 0; i < n; i++) {       long long int cur = n;       bool check = false;       while (cur >= 0 and cur >= n - tmp) {         if (ind[cur] <= i and b[i - ind[cur]] == 1) {           cout << cur << endl;           check = true;           break;         }         cur--;       }       if (check == true) {         continue;       }       long long int cur_ans = 0;       for (int j = 0; j < o.size(); j++) {         if (o[j] <= i) {           cur_ans = max(cur_ans, a[i - o[j]]);         }       }       cout << cur_ans << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     string s;     cin >> s;     int a = 1;     for (int i = 1; i < s.size(); i++) {       if (s[i] ==  1 ) {         a += 10;       } else {         a += s[i] -  0 ;       }     }     cout << a <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   int32_t main() {     ios::sync_with_stdio(0);     cin.tie(0);     string s;     cin >> s;     long long i;     bool flag = true;     for (i = 0; i < s.length(); i++) {       if (s[i] ==  0 ) {         s.erase(i, 1);         flag = false;         break;       }     }     if (flag) {       s.erase(s.begin());     }     cout << s << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MOD = 998244353;   int add(int x, int y) {     x += y;     while (x >= MOD) x -= MOD;     while (x < 0) x += MOD;     return x;   }   int mul(int x, int y) { return (x * 1ll * y) % MOD; }   int power(int n, int m, int p) {     int res = 1;     while (m > 0) {       if (m & 1) res = (res * 1ll * n) % p;       n = (n * 1ll * n) % p;       m /= 2;     }     return res;   }   int solve() {     int n;     cin >> n;     int d = power(100, MOD - 2, MOD);     vector<int> arr(n), p(n), q(n);     for (int i = 0; i < n; i++) {       cin >> arr[i];       p[i] = mul(arr[i], d);       q[i] = mul(100 - arr[i], d);     }     int cur = 1, res = 0, x = 0;     for (int i = 0; i < n; i++) {       int tmp = mul(cur, p[i]), tmq = mul(cur, q[i]);       res = add(res, add(tmp, tmq));       x = add(x, tmq);       cur = tmp;     }     res = mul(res, power(add(1, -x), MOD - 2, MOD));     return res;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     cout << solve() <<   n ;     return 0;   }