malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   const int P = 10, N = 1e5 + 10;   inline int inverse(int a, int m) {     if (a <= 1) return a;     int ans = (1 - (long long int)inverse(m % a, a) * m) / a;     return ans + m;   }   int fact[N], ifact[N], pot[N][P];   int sz, p[P];   inline void primes(int n) {     for (int d = 2; d * d <= n; d++)       if (n % d == 0) {         p[sz++] = d;         while (n % d == 0) n /= d;       }     if (n > 1) p[sz++] = n;   }   int mod;   int expo[P][N];   inline int comb(int m, int n) {     int ans = (long long int)fact[m] * ifact[n] % mod * ifact[m - n] % mod;     for (register int i = 0; i < (int)(sz); ++i) {       int pp = pot[m][i] - pot[n][i] - pot[m - n][i];       if (pp) ans = (long long int)ans * expo[i][pp] % mod;     }     return ans;   }   inline int go(int n, int bal) {     long long int ans = 0;     for (register int x = 0, y = bal; x + y <= n; ++x, ++y)       ans += (long long int)comb(n, x) * comb(n - x, y) % mod;     return ans % mod;   }   int main() {     int n, l, r;     cin >> n >> mod >> l >> r;     primes(mod);     fact[0] = ifact[0] = 1;     int fn = 1;     for (register int j = 0; j < (int)(sz); ++j) expo[j][0] = 1;     for (int i = 1; i <= n; i++) {       int d = -1;       for (register int j = 0; j < (int)(sz); ++j)         if (i % p[j] == 0) {           d = j;           break;         }       if (d == -1)         fact[i] = i;       else {         fact[i] = fact[i / p[d]];         for (register int j = 0; j < (int)(sz); ++j)           pot[i][j] = pot[i / p[d]][j] + (j == d);       }       fn = (long long int)fn * fact[i] % mod;       for (register int j = 0; j < (int)(sz); ++j)         expo[j][i] = (long long int)expo[j][i - 1] * p[j] % mod;     }     ifact[n] = inverse(fn, mod);     for (register int i = n - 1; i >= 0; --i)       ifact[i] = (long long int)ifact[i + 1] * fact[i + 1] % mod;     for (register int i = 1; i <= n; ++i) {       fact[i] = (long long int)fact[i - 1] * fact[i] % mod;       for (register int j = 0; j < (int)(sz); ++j) pot[i][j] += pot[i - 1][j];     }     long long int ans = 0;     for (register int i = 0; i < (int)(2); ++i)       ans += (long long int)go(n, l + i) + mod - go(n, r + 1 + i);     cout << ans % mod << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     deque<int> vec;     int arr[200005];     int n, a;     scanf( %d , &n);     for (int i = 0; i < n; i++) {       scanf( %d , &a);       vec.push_back(a);       arr[i] = 0;     }     for (int i = 0; i < n; i++) {       scanf( %d , &a);       int j = 0, i1 = 0;       if (arr[a - 1] == 1) {         printf( 0  );       } else if (vec.empty() != true) {         int k = 0, f = 0;         while (true) {           arr[vec.front() - 1] = 1;           if (vec.front() == a) {             vec.pop_front();             break;           }           vec.pop_front();           k++;         }         printf( %d  , k + 1);       } else         printf( 0  );     }   }
#include <bits/stdc++.h>   using namespace std;   int dfs(vector<int>* v, int n) {     int cost = -1;     for (int i = 1; i <= n; i++) {       for (int j = i + 1; j <= n; j++) {         if (binary_search(v[i].begin(), v[i].end(), j) == 0) continue;         for (int k = 0; k < v[i].size(); k++) {           for (int s = 0; s < v[j].size(); s++) {             if (v[i][k] == v[j][s]) {               int p = v[i][k];               int ct = v[i].size() + v[j].size() + v[p].size() - 6;               if (cost == -1) {                 cost = ct;               } else {                 cost = min(cost, ct);               }               break;             }           }         }       }     }     return cost;   }   int main() {     int n, m;     cin >> n >> m;     vector<int> v[n + 1];     for (int i = 0; i < m; i++) {       int x, y;       cin >> x >> y;       v[x].push_back(y);       v[y].push_back(x);     }     for (int i = 1; i < n + 1; i++) {       sort(v[i].begin(), v[i].end());     }     int cost = dfs(v, n);     cout << cost <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   vector<int> v[100001];   long long arr[100001];   int visit[100001];   void dfs(int s, long long *pos, long long *neg) {     visit[s] = 1;     int i;     long long k, maxi = 0, mini = 0, ps = 0, ng = 0;     for (i = 0; i < v[s].size(); i++) {       if (!visit[v[s][i]]) {         dfs(v[s][i], &ps, &ng);         if (ps > maxi) maxi = ps;         if (ng < mini) mini = ng;       }     }     *pos = maxi;     *neg = mini;     k = arr[s] + maxi + mini;     if (k < 0)       *pos = *pos - k;     else       *neg = *neg - k;   }   int main() {     int n, i, a, b;     long long pos = 0, neg = 0;     scanf( %d , &n);     for (i = 0; i < n - 1; i++) {       scanf( %d%d , &a, &b);       v[a].push_back(b);       v[b].push_back(a);     }     for (i = 1; i <= n; i++) cin >> arr[i];     dfs(1, &pos, &neg);     cout << pos - neg;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MOD = 1000000007;   struct Sync_stdio {     Sync_stdio() {       cin.tie(NULL);       ios_base::sync_with_stdio(false);     }   } _sync_stdio;   long long n, k;   void solve(vector<long long> &v, vector<long long> &a) {     for (int i = (0); i < (n); ++i) {       a[i + 1] += a[i] / 2;       a[i] %= 2;       if (a[i] == -1) {         --a[i + 1];         a[i] = 1;       }     }     if (a[n] < 0) {       return;     }     long long pos = 0;     for (int i = (0); i < (n + 1); ++i) {       if (a[i] != 0) {         pos = i;         break;       }     }     long long res = 0;     long double res2 = 0;     for (int i = (pos); i < (min(n + 1, pos + 36)); ++i) {       res += (1LL << (i - pos)) * a[i];       res2 += (1LL << (i - pos)) * a[i];     }     for (int i = (min(n + 1, pos + 35)); i < (n + 1); ++i) {       if (a[i] != 0) {         cout << 0 <<   n ;         exit(0);       }     }     if (res2 > 1e11) {       cout << 0;       exit(0);     }     long long ans = 0;     long long t = res;     for (int i = (pos); i > (-1); --i) {       if (t > 1e12) {         break;       }       if (pos != n || t != v[i]) {         if (t <= v[i] + k) {           ++ans;         }       }       t *= 2;     }     cout << ans;     exit(0);   }   int main() {     cin >> n >> k;     vector<long long> v(n + 1);     for (int __i = 0; __i < (n + 1); ++__i) cin >> v[__i];     ;     vector<long long> a = v;     solve(v, a);     a = v;     for (int i = (0); i < (n + 1); ++i) {       v[i] = -v[i];       a[i] = -a[i];     }     solve(v, a);   }
#include <bits/stdc++.h>   using namespace std;   class solve {    private:     int n, lar, les;     vector<int> val[2];     vector<int> res[2];     vector<long long> sum[2];       private:     int find_first_less(int i);       public:     void func();   };   void solve::func() {     cin >> n;     val[0].resize(n + 1, 0);     val[1].resize(n + 1, 0);     sum[0].resize(n + 1, 0);     sum[1].resize(n + 1, 0);     for (int k = 0; k < 2; k++)       for (int i = 1; i <= n; i++) {         scanf( %d , &val[k][i]);         sum[k][i] = sum[k][i - 1] + val[k][i];       }     if (sum[0][n] >= sum[1][n])       lar = 0;     else       lar = 1;     les = 1 - lar;     map<long long, pair<int, int> > diff_pair;     diff_pair[0] = make_pair(0, 0);     for (int i = 1; i <= n; i++) {       int l = 0, r = n, m;       while (l < r) {         m = (l + r + 1) / 2;         if (sum[les][i] >= sum[lar][m])           l = m;         else           r = m - 1;       }       long long diff = sum[les][i] - sum[lar][l];       if (diff_pair.count(diff) != 0) {         for (int j = diff_pair[diff].first + 1; j <= i; j++)           res[les].push_back(j);         for (int j = diff_pair[diff].second + 1; j <= l; j++)           res[lar].push_back(j);         break;       } else         diff_pair[diff] = make_pair(i, l);     }     printf( %d n , (int)res[0].size());     for (int i = 0; i < res[0].size(); i++) printf( %d  , res[0][i]);     printf(  n );     printf( %d n , (int)res[1].size());     for (int i = 0; i < res[1].size(); i++) printf( %d  , res[1][i]);     printf(  n );   }   int main() {     solve s;     s.func();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 100010;   const int INF = 0x7fffffff;   long long a[MAXN];   long long sum = 0;   long long s1[MAXN];   set<long long> s;   int main() {     int n;     scanf( %d , &n);     s1[0] = 0;     for (int i = 1; i <= n; i++) {       scanf( %lld , a + i);       sum += a[i];       s1[i] = s1[i - 1] + a[i];     }     int ok = 0;     s.clear();     for (int i = 1; i <= n; i++) {       if (s.count(2 * a[i])) {         ok = 1;         break;       }       long long x = sum - 2 * s1[i];       if (x == 0) {         ok = 1;         break;       }       if (x >= 0) s.insert(x);     }     s.clear();     for (int i = n; i >= 1; i--) {       if (s.count(2 * a[i])) {         ok = 1;         break;       }       long long x = 2 * s1[i] - sum;       if (x == 0) {         ok = 1;         break;       }       if (x >= 0) s.insert(x);     }     if (ok)       puts( YES );     else       puts( NO );   }
#include <bits/stdc++.h>   using namespace std;   int n = 10;   const int ms = 100;   int grid[ms][ms];   const int inf = 1e9;   int f[ms];   double dp[ms];   int32_t main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout << fixed << setprecision(8);     for (int i = 0; i < n; i++) {       for (int j = 0; j < n; j++) {         cin >> grid[i][j];       }       i++;       for (int j = n - 1; j >= 0; j--) {         cin >> grid[i][j];       }     }     for (int i = 0; i < n; i++) {       for (int j = 0; j < n; j++) {         if (grid[i][j] % 2 == 0) {           f[i * 10 + j] = i * 10 + j - grid[i][j] * 10;         } else {           f[i * 10 + j] = i * 10 + (n - j - 1) - grid[i][j] * 10;         }       }       i++;       for (int j = n - 1; j >= 0; j--) {         if (grid[i][j] % 2 == 0) {           f[i * 10 + j] = i * 10 + j - grid[i][j] * 10;         } else {           f[i * 10 + j] = i * 10 + (n - j - 1) - grid[i][j] * 10;         }       }     }     dp[0] = 0.0;     for (int i = 1; i < ms; i++) {       double sum = 1;       double tam = min(i, 6);       for (int d = 1; d <= tam; d++) {         sum += 1.0 / 6.0 * min(dp[i - d], dp[f[i - d]]);       }       dp[i] = (6.0 / tam) * sum;     }     cout << dp[99] <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long int n, m;     cin >> n >> m;     long long int x[n][m], y[n][m], a[n][m], b[n], c[m], i, j, ans = 0, ans1 = 0,                                                                d[n], e[m];     for (i = 0; i < n; i++) {       long long int min = 99999999999;       for (j = 0; j < m; j++) {         cin >> x[i][j];         a[i][j] = x[i][j];         y[i][j] = x[i][j];       }     }     for (i = 0; i < n; i++) {       long long int min = 99999999999;       for (j = 0; j < m; j++) {         if (min > a[i][j]) min = a[i][j];       }       b[i] = min;       if (b[i] != 0) ans += b[i];     }     for (i = 0; i < n; i++) {       for (j = 0; j < m; j++) {         a[i][j] -= b[i];       }     }     for (i = 0; i < m; i++) {       long long int min = 99999999999;       for (j = 0; j < n; j++) {         if (min > a[j][i]) min = a[j][i];       }       c[i] = min;       if (c[i] != 0) ans += c[i];     }     for (i = 0; i < m; i++) {       for (j = 0; j < n; j++) {         a[j][i] -= c[i];       }     }     long long int count = 0;     for (i = 0; i < n; i++) {       for (j = 0; j < m; j++) {         if (a[i][j] == 0) count++;       }     }     for (i = 0; i < m; i++) {       long long int min = 99999999999;       for (j = 0; j < n; j++) {         if (min > y[j][i]) min = y[j][i];       }       e[i] = min;       if (e[i] != 0) ans1 += e[i];     }     for (i = 0; i < m; i++) {       for (j = 0; j < n; j++) {         y[j][i] -= e[i];       }     }     for (i = 0; i < n; i++) {       long long int min = 99999999999;       for (j = 0; j < m; j++) {         if (min > y[i][j]) min = y[i][j];       }       d[i] = min;       if (d[i] != 0) ans1 += d[i];     }     for (i = 0; i < n; i++) {       for (j = 0; j < m; j++) {         y[i][j] -= d[i];       }     }     long long int count1 = 0;     for (i = 0; i < n; i++) {       for (j = 0; j < m; j++) {         if (y[i][j] == 0) count1++;       }     }     if (ans < ans1) {       if (count == n * m) {         cout << ans << endl;         for (i = 0; i < n; i++) {           if (b[i] != 0) {             while (b[i]--) cout <<  row   << i + 1 << endl;           }         }         for (i = 0; i < m; i++) {           if (c[i] != 0) {             while (c[i]--) cout <<  col   << i + 1 << endl;           }         }       } else {         cout << -1 << endl;       }     } else {       if (count1 == n * m) {         cout << ans1 << endl;         for (i = 0; i < n; i++) {           if (d[i] != 0) {             while (d[i]--) cout <<  row   << i + 1 << endl;           }         }         for (i = 0; i < m; i++) {           if (e[i] != 0) {             while (e[i]--) cout <<  col   << i + 1 << endl;           }         }       } else {         cout << -1 << endl;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   struct T {     int p, n;   };   bool operator<(T x, T y) { return x.p < y.p; }   T m[100100];   int main() {     int i, n, j;     for (scanf( %d , &n), i = 0; i < n; scanf( %d%d , &m[i].p, &m[i].n), i++)       ;     sort(m, m + n);     j = m[n - 1].n;     for (i = 0; i < n - 1; i++)       if (m[i + 1].p - m[i].p > 40)         continue;       else {         for (; m[i].p < m[i + 1].p; m[i].n = (m[i].n + 3) / 4, m[i].p++)           ;         if (m[i].n > m[i + 1].n) m[i + 1].n = m[i].n;       }     if (m[n - 1].n == j && j == 1)       printf( %d n , m[n - 1].p + 1);     else {       for (; m[i].n > 1; m[i].n = (m[i].n + 3) / 4, m[i].p++)         ;       printf( %d n , m[i].p);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   inline long long read() {     long long x = 0;     int ch = getchar(), f = 1;     while (!isdigit(ch) && (ch !=  - ) && (ch != EOF)) ch = getchar();     if (ch ==  - ) {       f = -1;       ch = getchar();     }     while (isdigit(ch)) {       x = (x << 1) + (x << 3) + ch -  0 ;       ch = getchar();     }     return x * f;   }   const int N = 5e5 + 10, mod = 1e9 + 7;   int n, ans;   pair<int, int> a[N];   inline int Mod(int x) { return x >= mod ? x - mod : x; }   inline void upd(int &x, int y) {     x += y, x = (x >= mod ? x - mod : (x < 0 ? x + mod : x));   }   struct SegmentTree {     int v[N << 2], lazy[N << 2];     inline void push_up(int u) { v[u] = Mod(v[u << 1] + v[u << 1 ^ 1]); }     inline void push_down(int u, int l, int mid, int r) {       if (!lazy[u]) return;       upd(lazy[u << 1], lazy[u]), upd(lazy[u << 1 ^ 1], lazy[u]);       upd(v[u << 1], 1ll * lazy[u] * (mid - l + 1) % mod),           upd(v[u << 1 ^ 1], 1ll * lazy[u] * (r - mid) % mod);       lazy[u] = 0;     }     inline void update(int u, int l, int r, int ql, int qr) {       if (l >= ql && r <= qr)         return upd(v[u], r - l + 1), upd(lazy[u], 1), void(0);       int mid = l + r >> 1;       push_down(u, l, mid, r);       if (qr <= mid)         update(u << 1, l, mid, ql, qr);       else if (ql > mid)         update(u << 1 ^ 1, mid + 1, r, ql, qr);       else         update(u << 1, l, mid, ql, qr), update(u << 1 ^ 1, mid + 1, r, ql, qr);       push_up(u);     }     inline int Query(int u, int l, int r, int ql, int qr) {       if (l >= ql && r <= qr) return v[u];       int mid = l + r >> 1;       push_down(u, l, mid, r);       if (qr <= mid)         return Query(u << 1, l, mid, ql, qr);       else if (ql > mid)         return Query(u << 1 ^ 1, mid + 1, r, ql, qr);       else         return Mod(Query(u << 1, l, mid, ql, qr) +                    Query(u << 1 ^ 1, mid + 1, r, ql, qr));     }   } t[2];   int main() {     n = read();     for (register int i = (1); i <= (n); i++) a[i] = make_pair(read(), i);     sort(a + 1, a + 1 + n);     for (register int i = (1); i <= (n); i++) {       int x = t[0].Query(1, 1, n, a[i].second, a[i].second),           sum = t[0].Query(1, 1, n, 1, a[i].second);       int y = t[1].Query(1, 1, n, a[i].second, a[i].second),           Sum = t[1].Query(1, 1, n, a[i].second, n);       upd(ans, 1ll * a[i].first *                    (sum - 1ll * x * a[i].second % mod + a[i].second) % mod *                    (n - a[i].second + 1) % mod);       upd(ans, 1ll * a[i].first * (Sum - 1ll * y * (n - a[i].second + 1) % mod) %                    mod * a[i].second % mod);       t[0].update(1, 1, n, 1, a[i].second), t[1].update(1, 1, n, a[i].second, n);     }     printf( %d n , ans);   }
#include <bits/stdc++.h>   using namespace std;   vector<pair<long long int, long long int> > v1, v2;   int main() {     long long int p, q, l, r, w, x, y, z, i, j, flag, tot = 0, k;     scanf( %lld , &p);     scanf( %lld , &q);     scanf( %lld , &l);     scanf( %lld , &r);     for (i = 0; i < p; i++) {       scanf( %lld , &x);       scanf( %lld , &y);       v1.push_back(make_pair(x, y));     }     for (i = 0; i < q; i++) {       scanf( %lld , &x);       scanf( %lld , &y);       v2.push_back(make_pair(x, y));     }     for (i = l; i <= r; i++) {       flag = 0;       for (j = 0; j < v1.size(); j++) {         for (k = 0; k < v2.size(); k++) {           if (v1[j].second < v2[k].first + i || v1[j].first > v2[k].second + i)             ;           else             flag = 1;         }       }       if (flag == 1) tot++;     }     cout << tot << endl;     return 0;   }
#include <bits/stdc++.h>   int main() {     int i, j, p;     char a[100010];     while (~scanf( %s , a)) {       p = 0;       for (i = 0, j = strlen(a) - 1; i < j; i++, j--) {         if (a[i] != a[j]) {           p = 1;           break;         }       }       if (p == 1)         printf( NO n );       else {         for (i = 0; i < strlen(a); i++) {           if (a[i] !=  A  && a[i] !=  H  && a[i] !=  I  && a[i] !=  M  &&               a[i] !=  O  && a[i] !=  T  && a[i] !=  V  && a[i] !=  U  &&               a[i] !=  W  && a[i] !=  X  && a[i] !=  Y ) {             p = 1;             break;           }         }         if (p == 1)           printf( NO n );         else           printf( YES n );       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     int n;     cin >> n;     string x;     int ans = 1;     vector<string> a;     for (int i = 0; i < n; i++) {       cin >> x;       a.push_back(x);     }     for (int i = 0; i < n - 1; ++i) {       if (a[i] != a[i + 1]) ans++;     }     cout << ans;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   vector<int> a;   int n;   bool check() {     for (int i = 1; i < n; i++) {       if (abs(a[i - 1] - a[i]) >= 2) return 1;     }     return 0;   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cin >> n;     a.resize(n);     for (int i = 0; i < n; i++) {       cin >> a[i];     }     if (check()) {       cout <<  NO ;       return 0;     }     int last = -1;     for (int i = 0; i < n; i++) {       int mx = -1, mxj = 0;       for (int j = 0; j < n; j++) {         if (mx < a[j]) {           mx = a[j];           mxj = j;         }       }       if (last == -1) last = mx;       if (mx == -1) break;       if (abs(last - mx) >= 2) {         cout <<  NO ;         return 0;       }       a[mxj] = -1;       last = mx;     }     cout <<  YES ;   }
#include <bits/stdc++.h>   const int maxn = 2e5 + 1;   int fa[maxn], flg[maxn], n, m, cnt, ans;   struct Edge {     int u, v, w;   } e[maxn];   inline bool cmp(Edge a, Edge b) { return a.w > b.w; }   inline int find(int x) { return (fa[x] == x) ? x : fa[x] = find(fa[x]); }   int main() {     scanf( %d %d , &n, &m);     for (int i = 1; i <= m; i++) scanf( %d %d %d , &e[i].u, &e[i].v, &e[i].w);     for (int i = 1; i <= n; i++) fa[i] = i;     std::sort(e + 1, e + m + 1, cmp);     for (int i = 1; i <= m; i++) {       int fx = find(e[i].u), fy = find(e[i].v);       if (fx == fy) {         if (flg[fx]) continue;         ans += e[i].w;         flg[fx] = 1;       }       if (flg[fx] && flg[fy]) continue;       if (flg[fx])         fa[fy] = fx;       else if (flg[fy])         fa[fx] = fy;       else         fa[fx] = fy;       ans += e[i].w;     }     printf( %d , ans);   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, k;     cin >> n >> k;     vector<long long> a(n);     for (int i = (0); i < (n); ++i) cin >> a[i];     long long sum = 0;     long long dynamicrank = 0;     for (int i = (0); i < (n); ++i) {       long long score = sum - (n - (i + 1)) * dynamicrank * a[i];       if (score < k) {         cout << (i + 1) <<   n ;       } else {         sum += a[i] * dynamicrank;         dynamicrank++;       }     }   }
#include <bits/stdc++.h>   using namespace std;   bool prime[101];   void SieveOfEratosthenes(int n) {     memset(prime, true, sizeof(prime));     for (int p = 2; p * p <= n; p++) {       if (prime[p] == true) {         for (int i = p * p; i <= n; i += p) prime[i] = false;       }     }   }   int main() {     long long n, m;     cin >> n;     long long c[n + 1];     if (n % 2 != 0) {       cout << -1;       return 0;     }     for (long long i = 1; i <= n; i++) {       c[i] = i;     }     for (long long i = 1; i <= n; i += 2) {       swap(c[i], c[i + 1]);     }     for (long long i = 1; i <= n; i++) {       cout << c[i] <<    ;     }   }
#include <bits/stdc++.h>   using namespace std;   const int N = 2000010;   inline int in() {     int x;     scanf( %d , &x);     return x;   }   inline long long lin() {     long long x;     scanf( %I64d , &x);     return x;   }   char s[N];   int t[4 * N];   int help[N * 4];   int limit = (int)1e6 * 2;   int ki[N];   vector<int> V[N];   vector<string> Store;   void modify(int x, int b, int e, int l, int r, int v) {     if (help[x]) return;     if (b > r || e < l) return;     if (b >= l && e <= r) {       help[x] = 1;       t[x] = v;       return;     }     int m = (b + e) >> 1;     modify(x + x, b, m, l, r, v);     modify(x + x + 1, m + 1, e, l, r, v);     help[x] = help[x + x] & help[x + x + 1];   }   int get(int x, int b, int e, int l, int r) {     if (t[x] > 0 && (b != e)) {       t[x + x] = t[x];       t[x + x + 1] = t[x];     }     if (b > r || e < l) return 0;     if (b >= l && e <= r) {       return t[x];     }     int m = (b + e) >> 1;     return max(get(x + x, b, m, l, r), get(x + x + 1, m + 1, e, l, r));   }   int main() {     int n = in(), mx = 0;     string str =  aa ;     Store.push_back(str);     for (int i = 1; i <= n; i++) {       scanf( %s , s);       str = s;       Store.push_back(str);       ki[i] = in();       for (int j = 1; j <= ki[i]; j++) {         int di = in();         V[i].push_back(di);         mx = max(mx, di + (int)str.size() - 1);         modify(1, 1, limit, di, di + str.size() - 1, i);       }     }     for (int i = 1; i <= mx; i++) {       int idx = get(1, 1, limit, i, i);       if (idx == 0)         printf( a );       else {         int low = 0, high = V[idx].size() - 1, ans = 0;         while (low <= high) {           int mid = (low + high) >> 1;           if (V[idx][mid] <= i) {             low = mid + 1;             ans = V[idx][mid];           } else {             high = mid - 1;           }         }         printf( %c , Store[idx][i - ans]);       }     }     puts(  );   }
#include <bits/stdc++.h>   using namespace std;   void solve() {     long long int k;     cin >> k;     string s =  codeforces ;     long long int a[10];     long long int cnt = 1;     for (int i = 0; i < 10; ++i) {       a[i] = 1;     }     int idx = 0;     while (cnt < k) {       a[idx]++;       cnt = 1;       for (int i = 0; i < 10; ++i) {         cnt *= a[i];       }       idx = (idx + 1) % 10;     }     for (int i = 0; i < 10; ++i) {       for (int j = 0; j < a[i]; ++j) {         cout << s[i];       }     }   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     long long int t = 1;     while (t--) {       solve();     }     return 0;   }