malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   inline int read() {     int x = 0, c = getchar(), f = 0;     for (; c >  9  || c <  0 ; f = c ==  - , c = getchar())       ;     for (; c >=  0  && c <=  9 ; c = getchar()) x = (x << 1) + (x << 3) + c -  0 ;     return f ? -x : x;   }   const int maxn = 2e5 + 10;   const int inf = 0x3f3f3f3f;   int a[maxn];   int n, k;   map<int, int> vis;   int main() {     n = read();     k = 0;     for (int i = 1; i <= n; i++) {       int x = read();       if (vis[x] == 0) vis[x] = ++k;       a[vis[x]]++;     }     sort(a + 1, a + k + 1);     int ans = 0;     for (int i = 1; i <= n; i++) {       int x = i, temp = 0, y = 0;       while (true) {         int id = lower_bound(a + y + 1, a + k + 1, x) - a;         if (id == k + 1) break;         temp += x;         x *= 2;         y = id;       }       ans = max(ans, temp);     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   #pragma comment(linker,  /stack:256000000 )   using namespace std;   const int INF = 1000000000;   const long long LINF = 4000000000000000000LL;   const double eps = 1e-9;   void prepare() {}   struct Chat {     string name, text;     unsigned int hname;     set<unsigned int> words;     vector<int> possibles;   };   int n, m;   vector<Chat> chats;   vector<string> names;   vector<int> res;   vector<unsigned int> hnames;   int p[100500];   unsigned int getHash(string s) {     unsigned int h = 0;     for (int i = (0); i < (((int)(s).size())); i++) h = h * 3137 + s[i];     return h;   }   Chat readChat() {     Chat chat;     string s;     getline(cin, s);     int ix = s.find( : );     chat.name = s.substr(0, ix);     chat.hname = getHash(chat.name);     chat.text = s.substr(ix + 1);     s = chat.text;     for (int i = (0); i < (((int)(s).size())); i++) {       if (!isalnum(s[i])) s[i] =    ;     }     stringstream ss(s);     while (ss >> s) {       chat.words.insert(getHash(s));     }     return chat;   }   void read() {     names.clear();     hnames.clear();     chats.clear();     string s;     scanf( %d , &n);     getline(cin, s);     getline(cin, s);     stringstream ss(s);     while (ss >> s) {       names.push_back(s);       hnames.push_back(getHash(s));     }     scanf( %d , &m);     getline(cin, s);     for (int i = (0); i < ((m)); i++) {       chats.push_back(readChat());     }   }   bool rec(int cc) {     if (cc >= m) return true;     int id = p[cc];     for (int i = (0); i < (((int)(chats[id].possibles).size())); i++) {       int prid = chats[id].possibles[i];       unsigned int pr = hnames[prid];       if ((id == 0 || chats[id - 1].hname != pr) &&           (id + 1 >= m || chats[id + 1].hname != pr)) {         unsigned int ph = chats[id].hname;         chats[id].hname = pr;         res[id] = prid;         if (rec(cc + 1)) return true;         chats[id].hname = ph;       }     }     return false;   }   bool cmp(const int &a, const int &b) {     return chats[a].possibles.size() < chats[b].possibles.size();   }   bool solve() {     res.clear();     res.resize(m);     for (int i = (0); i < ((m)); i++) {       if (chats[i].name !=  ? ) {         int id =             find((names).begin(), (names).end(), chats[i].name) - names.begin();         chats[i].possibles.push_back(id);         continue;       }       for (int j = (0); j < ((n)); j++) {         if (!chats[i].words.count(hnames[j])) chats[i].possibles.push_back(j);       }     }     for (int i = (0); i < ((m)); i++) p[i] = i;     sort(p, p + m, cmp);     if (rec(0)) {       for (int i = (0); i < ((m)); i++) {         printf( %s:%s n , names[res[i]].c_str(), chats[i].text.c_str());       }     } else {       printf( Impossible n );     }     return false;   }   int main() {     prepare();     int t;     scanf( %d , &t);     for (int i = (0); i < ((t)); i++) {       read();       while (solve())         ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 5e5 + 7;   const int mod = 998244353;   int ans[1007][1007];   int num[1007];   int n, k;   void print(int l, int r) {     cout <<  ?   << r - l + 1 <<    ;     for (int i = l; i <= r; i++) cout << i <<    ;     cout << endl;     fflush(stdout);   }   int ggg(int x) {     for (int i = 1; i <= k; i++)       for (int j = 1; j <= num[i]; j++) {         if (ans[i][j] == x) {           return i;         }       }   }   int main() {     ios::sync_with_stdio(false);     int zs;     cin >> zs;     while (zs--) {       cin >> n >> k;       for (int i = 1; i <= k; i++) {         cin >> num[i];         for (int j = 1; j <= num[i]; j++) cin >> ans[i][j];       }       int ma;       print(1, n);       cin >> ma;       int l = 1, r = n;       while (l < r) {         int mid = (l + r) / 2;         print(l, mid);         int x;         cin >> x;         if (x == ma)           r = mid;         else           l = mid + 1;       }       int t = ggg(l);       int vis[1007] = {0};       for (int i = 1; i <= num[t]; i++) vis[ans[t][i]] = 1;       cout <<  ?   << n - num[t] <<    ;       for (int i = 1; i <= n; i++)         if (!vis[i]) cout << i <<    ;       cout << endl;       fflush(stdout);       int se;       cin >> se;       cout <<  !  <<    ;       for (int i = 1; i <= k; i++)         if (i == t)           cout << se <<    ;         else           cout << ma <<    ;       cout << endl;       string s;       cin >> s;     }   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 2e3;   const int maxx = 1e6;   const int inf = 0x3f3f3f3f;   int n, m, tot, c[maxx + 10], ans = inf;   pair<int, int> a[maxn + 10], b[maxn + 10];   set<pair<int, int> > s;   int main() {     scanf( %d%d , &n, &m);     for (int i = 1; i <= n; ++i) scanf( %d%d , &a[i].first, &a[i].second);     for (int i = 1; i <= m; ++i) scanf( %d%d , &b[i].first, &b[i].second);     for (int i = 1; i <= n; ++i)       for (int j = 1; j <= m; ++j)         if (b[j].first >= a[i].first && b[j].second >= a[i].second)           c[b[j].first - a[i].first] =               max(c[b[j].first - a[i].first], b[j].second - a[i].second + 1);     for (int i = maxx; i >= 0; --i) c[i] = max(c[i], c[i + 1]);     for (int i = 0; i <= maxx; ++i) ans = min(ans, i + c[i]);     printf( %d n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long modn = 1000000007;   inline long long mod(long long x) { return x % modn; }   template <class num>   inline void rd(num &x) {     char c;     while (isspace(c = getchar()))       ;     bool neg = false;     if (!isdigit(c))       neg = (c ==  - ), x = 0;     else       x = c -  0 ;     while (isdigit(c = getchar())) x = (x << 3) + (x << 1) + c -  0 ;     if (neg) x = -x;   }   int n;   const int N = 1123456;   vector<long long> query[N];   vector<pair<long long, long long> > ans[N];   int A[N];   long long H[N], l[N];   long long acc[N], tmp[N];   int tn;   void dfs(int u, long long d) {     if (u > n) return;     tmp[tn++] = d;     dfs(2 * u, d + l[2 * u]);     dfs(2 * u + 1, d + l[2 * u + 1]);   }   void answer_for(int u) {     tn = 0;     dfs(u, 0);     sort(tmp, tmp + tn);     acc[0] = tmp[0];     for (int i = 1; i < tn; i++) acc[i] = acc[i - 1] + tmp[i];     sort(query[u].begin(), query[u].end());     ans[u].resize(query[u].size());     for (int i = int(query[u].size()) - 1; i >= 0; i--) {       while (tn > 0 && tmp[tn - 1] > query[u][i]) tn--;       ans[u][i] = pair<long long, long long>(tn, tn ? acc[tn - 1] : 0ll);     }   }   inline void reg(int u, long long v) { query[u].push_back(v); }   inline pair<long long, long long> get(int u, long long v) {     return ans[u][lower_bound(query[u].begin(), query[u].end(), v) -                   query[u].begin()];   }   int main() {     int m;     int i;     rd(n);     rd(m);     for (i = 2; i <= n; i++) rd(l[i]);     for (i = 0; i < m; i++) {       rd(A[i]);       rd(H[i]);       int ai = A[i];       long long hi = H[i];       reg(ai, hi);       int nx = ai;       hi -= l[ai];       ai = ai / 2;       while (ai && hi > 0) {         reg(ai, hi);         if (hi - l[nx] > 0) reg(nx, hi - l[nx]);         nx = ai;         hi -= l[ai];         ai = ai / 2;       }     }     for (int i = 1; i <= n; i++) answer_for(i);     for (i = 0; i < m; i++) {       int ai = A[i];       long long hi = H[i];       pair<long long, long long> ans = get(ai, hi);       int nx = ai;       hi -= l[ai];       ai = ai / 2;       while (ai && hi > 0) {         pair<long long, long long> p = get(ai, hi);         ans.first += p.first;         ans.second += p.first * (H[i] - hi) + p.second;         if (hi - l[nx] > 0) {           pair<long long, long long> p = get(nx, hi - l[nx]);           ans.first -= p.first;           ans.second -= p.first * (H[i] - hi + l[nx]) + p.second;         }         nx = ai;         hi -= l[ai];         ai = ai / 2;       }       printf( %lld n , ans.first * H[i] - ans.second);     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, m;     cin >> n >> m;     vector<int> a(n, 0);     for (int i = 0; i < n; i++) cin >> a[i];     sort(a.begin(), a.end());     int s = 0, cnt = 0;     for (int i = 0; i < n; i++) {       if (m == 0) break;       if (a[i] < 0) {         s += abs(a[i]);         m--;       }     }     cout << abs(s);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int cups[1001];   int main() {     int size;     cin >> size;     int sum = 0;     int avg;     for (int i = 1; i <= size; ++i) {       cin >> cups[i];       sum += cups[i];     }     avg = sum / size;     if (size * avg != sum) {       cout <<  Unrecoverable configuration.  << endl;       return 0;     }     int diff = 0;     int from, to;     bool done = false;     for (int i = 1; i <= size; ++i) {       if (cups[i] != avg) {         if (diff == 0) {           diff = avg - cups[i];           if (diff > 0)             from = i;           else             to = i;         } else if (done) {           cout <<  Unrecoverable configuration.  << endl;           return 0;         } else {           if (cups[i] - diff == avg) {             done = true;             if (diff > 0)               to = i;             else               from = i;             diff = abs(diff);           } else {             cout <<  Unrecoverable configuration.  << endl;             return 0;           }         }       }     }     if (diff == 0) {       cout <<  Exemplary pages.  << endl;       return 0;     }     cout << diff <<   ml. from cup #  << from <<   to cup #  << to <<  .  << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, m;   int a[50][50], neigh[5][2] = {{0, 0}, {1, 0}, {0, 1}, {-1, 0}, {0, -1}};   int best;   void dfs(int x) {     vector<pair<int, int> > tmp;     int i, j, xx = 0, yy = 0, b1 = 0, x1 = 0, y1 = 0, x2 = 0, y2 = 0;     for (i = 0; i < m; i++) {       for (j = 0; j < n; j++)         if (a[i][j] == 0) {           b1 = 1;           break;         }       if (b1 == 1) break;     }     if (b1 == 0) {       best = x;       return;     }     if (x + 1 >= best) return;     xx = i;     yy = j;     for (int k = 0; k < 5; k++) {       x2 = xx + neigh[k][0];       y2 = yy + neigh[k][1];       if (x2 >= 0 && x2 < m && y2 >= 0 && y2 < n) {         tmp.clear();         for (i = 0; i < 5; i++) {           x1 = x2 + neigh[i][0];           y1 = y2 + neigh[i][1];           if (x1 >= 0 && x1 < m && y1 >= 0 && y1 < n && a[x1][y1] == 0) {             tmp.push_back(make_pair(x1, y1));             a[x1][y1] = 1;           }         }         dfs(x + 1);         for (i = 0; i < tmp.size(); i++) a[tmp[i].first][tmp[i].second] = 0;       }     }   }   int main() {     cin >> m >> n;     memset(a, 0, sizeof(a));     best = m * n;     dfs(0);     cout << (m * n) - best;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     int n, k, i, j;     cin >> n >> k;     int a[n - k + 1];     string s;     for (i = 0; i < n - k + 1; i++) {       cin >> s;       if (s[0] ==  Y )         a[i] = 0;       else         a[i] = 1;     }     vector<string> ans;     char a1 =  a , b =  a ;     string v =   ;     i = 0;     for (i = 0; i < k; i++) {       ans.push_back(v + a1);       if (a1 ==  z ) {         v = b;         b++;         a1 =  a ;       } else         a1++;     }     if (a[0] == 1) {       ans[k - 1] = ans[0];       a1--;     }     j = 1;     for (i = 1; i < n - k + 1; i++) {       if (a[i] == 1)         ans.push_back(ans[i]);       else {         ans.push_back(v + a1);         if (a1 ==  z ) {           v = b;           b++;           a1 =  a ;         } else           a1++;       }     }     for (i = 0; i < n; i++) ans[i][0] -= 32;     for (i = 0; i < n; i++) cout << ans[i] <<    ;   }
#include <bits/stdc++.h>   using namespace std;   map<long long int, long long int> mp, mk;   set<long long int> s1, s2;   vector<long long int> v, w;   string s =   , p =   , q =   ;   char ch;   long long int m, n, c, i, j, k, l, r, x, t, y, u, e, f, g, h, mn, mx, d, z;   int main() {     cin >> n >> t;     if (t == 10) {       if (n == 1) {         cout << -1;         return 0;       } else {         cout << 1;         for (i = 1; i < n; i++) cout << 0;         return 0;       }     }     for (i = 1; i <= n; i++) cout << t;   }
#include <bits/stdc++.h>   using namespace std;   int N;   int P[101010];   int V[101010];   vector<int> E[101010];   double T[101010];   void dfs(int cur, double tim) {     tim += 1;     T[cur] = tim;     for (auto& r : E[cur]) {       double el = (V[cur] - 1 - V[r]) * 0.5;       dfs(r, tim + el);     }   }   void solve() {     int i, j, k, l, r, x, y;     string s;     cin >> N;     for (i = 1; i < N; i++) cin >> P[i], P[i]--, E[P[i]].push_back(i);     for (i = N - 1; i >= 0; i--) {       V[i]++;       if (i) V[P[i]] += V[i];     }     dfs(0, 0);     for (i = 0; i < (N); i++)       (void)printf( %lf%c , T[i], (i == N - 1) ?   n  :    );   }   int main(int argc, char** argv) {     string s;     int i;     if (argc == 1) ios::sync_with_stdio(false), cin.tie(0);     for (i = 0; i < (argc - 1); i++) s += argv[i + 1], s +=   n ;     for (i = 0; i < (s.size()); i++) ungetc(s[s.size() - 1 - i], stdin);     solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int a, b, n, m, ar[200] = {0}, tp = 1;     cin >> n >> m;     for (int i = 1; i <= n; i++) {       cin >> a >> b;       for (int j = a + 1; j <= b; j++) {         if (!ar[j]) tp++, ar[j]++;       }     }     cout << ((tp == m + 1) ?  YES  :  NO ) << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long inf = 1e12;   const int maxn = 2e5 + 30;   int n;   long long dp[maxn][2], val[maxn], h[maxn], ans;   vector<int> G[maxn];   void Min(long long &x, long long y) {     if (x > y) x = y;   }   void dfs(int u, int fa) {     for (auto v : G[u]) {       if (v == fa) continue;       dfs(v, u);     }     long long s = 0;     vector<long long> r, sum;     r.clear();     for (auto v : G[u]) {       if (v == fa) continue;       s += dp[v][0];       r.push_back(dp[v][1] - dp[v][0]);     }     sort(r.begin(), r.end());     int m = r.size();     sum.resize(m + 1);     sum[0] = 0;     for (int i = 0; i < m; i++) sum[i + 1] = sum[i] + r[i];     if (!fa) {       dp[u][0] = inf;       for (int i = 0; i <= m; i++)         Min(dp[u][0], s + sum[i] + val[u] * abs((m - i) - i));     } else {       dp[u][0] = inf;       dp[u][1] = inf;       for (int i = 0; i <= m; i++) {         Min(dp[u][0], s + sum[i] + val[u] * abs((m - i) - (i + 1)));         Min(dp[u][1], s + sum[i] + val[u] * abs((m - i + 1) - i));       }       if (h[u] < h[fa]) dp[u][0] = inf;       if (h[u] > h[fa]) dp[u][1] = inf;     }   }   int main() {     scanf( %d , &n);     for (int i = 1; i <= n; i++) scanf( %lld , &val[i]);     for (int i = 1; i <= n; i++) scanf( %lld , &h[i]);     for (int i = 1; i < n; i++) {       int u, v;       scanf( %d%d , &u, &v);       G[u].push_back(v);       G[v].push_back(u);       ans += val[u] + val[v];     }     dfs(1, 0);     cout << (ans + dp[1][0]) / 2 << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long bruh = -1e18;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     int n;     cin >> n;     vector<long long> v(n);     for (int i = 0; i < n; i++) {       cin >> v[i];     }     sort(v.begin(), v.end());     long long sum = accumulate(v.begin(), v.end(), bruh);     int q;     cin >> q;     while (q--) {       long long x, y;       cin >> x >> y;       int idx = lower_bound(v.begin(), v.end(), x) - v.begin();       int idxx = upper_bound(v.begin(), v.end(), x) - v.begin();       if (idxx == n) {         idxx--;       }       if (idx == n) {         idx--;       }       long long ans = LLONG_MAX;       long long tt = 0;       tt += (x - v[idx] > 0 ? x - v[idx] : 0);       tt += (sum - v[idx] - bruh < y ? y - sum + bruh + v[idx] : 0);       ans = min(ans, tt);       tt = 0;       tt += (x - v[idx - 1] > 0 ? x - v[idx - 1] : 0);       tt += (sum - bruh - v[idx - 1] < y ? y - sum + bruh + v[idx - 1] : 0);       ans = min(ans, tt);       tt = 0;       tt += (x - v[idxx] > 0 ? x - v[idxx] : 0);       tt += (sum - v[idxx] - bruh < y ? y - sum + v[idxx] + bruh : 0);       ans = min(ans, tt);       tt = 0;       tt += (x - v[idxx - 1] > 0 ? x - v[idxx - 1] : 0);       tt += (sum - v[idxx - 1] - bruh < y ? y - sum + v[idxx - 1] + bruh : 0);       ans = min(ans, tt);       tt = 0;       cout << ans <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   vector<complex<double> > vec;   double minDist(complex<double> &a, complex<double> &b, complex<double> &p) {     complex<double> ab = ((b) - (a)), ap = ((p) - (a)), ba = ((a) - (b)),                     bp = ((p) - (b));     double distPB = sqrt(((conj(bp) * (bp)).real())),            distPA = sqrt(((conj(ap) * (ap)).real())),            distAB = sqrt(((conj(ab) * (ab)).real()));     double thetaA = acos(((conj(ab) * (ap)).real()) / distAB / distPA);     double thetaB = acos(((conj(ba) * (bp)).real()) / distAB / distPB);     double ans;     if (fabs(thetaA) >= 3.14159265358979323846 / 2)       ans = distPA;     else if (fabs(thetaB) >= 3.14159265358979323846 / 2)       ans = distPB;     else       ans = sin(fabs(thetaA)) * distPA;     return ans;   }   int main() {     int n;     long long px, py, tempX, tempY;     scanf( %d %I64d %I64d , &n, &px, &py);     double maxi = 0, mini = 1E12, dist;     for (int i = 0; i < n; i++) {       scanf( %I64d %I64d , &tempX, &tempY);       dist = sqrt((tempX - px) * (tempX - px) + (tempY - py) * (tempY - py));       maxi = max(maxi, dist);       complex<double> xx = complex<double>(tempX, tempY);       vec.push_back(xx);     }     vec.push_back(vec[0]);     maxi *= maxi;     complex<double> P = complex<double>(px, py);     for (int i = 0; i < n; i++) {       mini = min(mini, minDist(vec[i], vec[i + 1], P));     }     mini *= mini;     double ans = (maxi - mini);     ans *= 3.14159265358979323846;     printf( %0.8f , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long int ABS(long long int a) {     if (a < 0) return (-a);     return a;   }   vector<long long int> g[100001];   vector<long long int> p[100001];   map<pair<long long int, long long int>, int> l;   int visited[100001];   long long int ans[100001][4];   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     priority_queue<pair<long long int, long long int> > q;     long long int n, m, count = 0, z = 0;     cin >> n >> m;     for (int i = (0); i < (m); ++i) {       long long int a, b, c;       cin >> a >> b >> c;       g[a].push_back(b);       g[b].push_back(a);       p[a].push_back(c);       p[b].push_back(c);       l[make_pair(a, b)] = c;       if (c == 1) z++;     }     for (int i = (1); i < (n + 1); ++i) ans[i][0] = 1000000000LL;     long long int start = 1;     ans[start][1] = 0;     ans[start][0] = 0;     visited[start] = -1;     q.push(make_pair(0, start));     while (!q.empty()) {       long long int a = q.top().second;       long long int d = -q.top().first;       q.pop();       for (long long int ii = 0; ii < g[a].size(); ii++) {         long long int i = g[a][ii];         if (visited[i] == 1) continue;         if (ans[i][0] > d + 1 or             (ans[i][0] == d + 1 and ans[i][1] <= ans[a][1] + p[a][ii])) {           ans[i][0] = d + 1;           ans[i][1] = ans[a][1] + p[a][ii];           ans[i][2] = a;         }         if (visited[i] == 0 and i != n) {           visited[i] = -1;           q.push(make_pair(-ans[i][0], i));         }       }       visited[a] = 1;     }     vector<long long int> aens[3];     long long int i = n;     while (i != 1) {       long long int nei = ans[i][2];       if (l.find(make_pair(i, nei)) != l.end()) {         if (l[make_pair(i, nei)] == 0) {           aens[0].push_back(i);           aens[1].push_back(nei);           aens[2].push_back(1);         }         l[make_pair(i, nei)] = 2;       } else {         if (l[make_pair(nei, i)] == 0) {           aens[0].push_back(i);           aens[1].push_back(nei);           aens[2].push_back(1);         }         l[make_pair(nei, i)] = 2;       }       i = nei;     }     for (auto &it : l) {       if (it.second == 1) {         aens[0].push_back(it.first.first);         aens[1].push_back(it.first.second);         aens[2].push_back(0);       }     }     cout << aens[1].size() <<   n ;     for (int i = (0); i < (aens[1].size()); ++i)       cout << aens[0][i] <<     << aens[1][i] <<     << aens[2][i] <<   n ;     return 0;   }
#include <bits/stdc++.h>   #pragma optimise GCC(-O2)   using namespace std;   mt19937_64 rang(       chrono::high_resolution_clock::now().time_since_epoch().count());   int rng(int lim) {     uniform_int_distribution<int> uid(0, lim - 1);     return uid(rang);   }   long long INF = LLONG_MAX;   const long long M = 1000000007;   long long powm(long long, long long);   long long perm[2000005];   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     long long n;     cin >> n;     for (int i = 0; i < 2000005; i++) perm[i] = -1;     for (int i = 1; i < n + 1; i++) perm[i] = i;     for (int i = 2; i < n + 1; i++) {       long long to_be = -1;       long long replace = 0;       while (replace * i + 1 <= n) {         swap(to_be, perm[replace * i + i - 1]);         replace++;       }       swap(to_be, perm[n + i - 1]);     }     for (int i = 0; i < 2000005; i++)       if (perm[i] != -1) cout << perm[i] <<    ;   }   long long powm(long long a, long long b) {     long long res = 1;     while (b) {       if (b & 1) res = (res * a) % M;       a = (a * a) % M;       b >>= 1;     }     return res;   }