malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   const int inf = 1e9 + 7;   const long long INF = 1e18L + 7;   template <class n, class second>   ostream &operator<<(ostream &p, pair<n, second> x) {     return p <<  <  << x.first <<  ,   << x.second <<  > ;   }   template <class n>   auto operator<<(ostream &p, n y) ->       typename enable_if<!is_same<n, string>::value,                          decltype(y.begin(), p)>::type {     int o = 0;     p <<  { ;     for (auto c : y) {       if (o++) p <<  ,  ;       p << c;     }     return p <<  } ;   }   void dor() { cerr <<   n ; }   template <class n, class... second>   void dor(n p, second... y) {     cerr << p <<    ;     dor(y...);   }   template <class n, class second>   void mini(n &p, second y) {     if (p > y) p = y;   }   template <class n, class second>   void maxi(n &p, second y) {     if (p < y) p = y;   }   const int N = 57;   int n;   vector<int> G[N];   long double kom[N][N][N][N];   long double bez[N][N];   long double kra[N][N];   int sub[N];   void merge(int v, int u) {     long double tmp[N];     memset(tmp, 0, sizeof tmp);     for (int i = 0; i <= sub[v]; ++i) {       for (int j = 0; j <= sub[u]; ++j) {         tmp[i + j] +=             bez[v][i] * kra[u][j] * kom[sub[v] + sub[u]][i + j][sub[v]][i];       }     }     memcpy(bez[v], tmp, sizeof bez[v]);     sub[v] += sub[u];   }   void dfs(int v, int p) {     bez[v][0] = 1;     for (auto u : G[v]) {       if (u == p) continue;       dfs(u, v);       merge(v, u);       ;     }     sub[v]++;     if (v == 1)       ;     for (int second = 0; second <= sub[v]; ++second) {       for (int wyb = 1; wyb <= sub[v]; ++wyb) {         int oki = max(wyb - 1, second - 1);         long double prob = 1.0 / sub[v];         if (wyb > second) prob /= 2;         kra[v][second] += bez[v][oki] * prob;       }     }   }   int32_t main() {     ios_base::sync_with_stdio(0);     cin.tie(NULL);     for (int i = 0; i < N; ++i) {       for (int j = 0; j <= i; ++j) {         kom[i][j][0][0] = 1;       }     }     for (int i = 1; i < N; ++i) {       for (int j = 0; j < N; ++j) {         for (int k = 1; k < N; ++k) {           for (int l = 0; l < N; ++l) {             long double ok = (long double)j / i;             if (j > 0 && l > 0)               kom[i][j][k][l] += ok * kom[i - 1][j - 1][k - 1][l - 1];             kom[i][j][k][l] += (1 - ok) * kom[i - 1][j][k - 1][l];           }         }       }     };     cout << fixed << setprecision(15);     cin >> n;     if (n == 1) {       cout << 1 <<   n ;       return 0;     }     for (int i = 1; i < n; ++i) {       int a, b;       cin >> a >> b;       G[a].push_back(b);       G[b].push_back(a);     }     for (int i = 1; i <= n; ++i) {       for (int j = 1; j <= n; ++j) {         memset(bez[j], 0, sizeof bez[j]);         memset(kra[j], 0, sizeof kra[j]);       }       memset(sub, 0, sizeof sub);       dfs(i, -1);       cout << bez[i][0] <<   n ;     }   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 200200;   int n, k, cnt[MAXN];   long long ans;   bool f[MAXN];   vector<int> g[MAXN];   void dfs(int v, int p = -1) {     cnt[v] = f[v];     for (const int &u : g[v])       if (u != p) dfs(u, v), cnt[v] += cnt[u];   }   void solve(int v, int p = -1) {     for (const int &u : g[v])       if (u != p) {         ans += min(2 * k - cnt[u], cnt[u]);         solve(u, v);       }   }   int main() {     scanf( %d %d , &n, &k);     for (int i = 1, x; i <= 2 * k; ++i) scanf( %d , &x), f[x] = true;     for (int i = 1, u, v; i < n; ++i)       scanf( %d %d , &u, &v), g[u].push_back(v), g[v].push_back(u);     dfs(1);     solve(1);     printf( %lld n , ans);   }
#include <bits/stdc++.h>   using namespace std;   int r, c;   string str_col[1000006];   string str_dir[1000006];   vector<int> e[1000006], rev[1000006];   int col[1000006], vis[1000006], vis2[1000006];   int cyc_len, black_cnt;   inline int id(int x, int y) { return c * x + y; }   vector<int> st;   int got[1000006];   void dfs2(int v, int mod, int d = 0) {     if (0) cerr <<  vis2   << v <<     << col[v] <<   n ;     vis2[v] = 1;     got[d] |= col[v];     for (int u : rev[v]) {       if (not vis2[u]) dfs2(u, mod, (d + 1) % mod);     }   }   void dfs(int v) {     if (vis[v] or vis2[v]) return;     if (0) cerr <<  dfs   << v <<   n ;     vis[v] = 1;     st.push_back(v);     for (int u : e[v]) {       if (not vis[u])         dfs(u);       else {         int cyc = st.end() - find(st.begin(), st.end(), u);         if (cyc == 0) continue;         fill(got, got + cyc, 0);         if (0) cerr <<  call cyc   << v <<     << u <<   n ;         dfs2(u, cyc);         black_cnt += accumulate(got, got + cyc, 0);         cyc_len += cyc;       }     }     st.pop_back();   }   void solve() {     cin >> r >> c;     for (int i = 0; i < r; i++) cin >> str_col[i];     for (int i = 0; i < r; i++) cin >> str_dir[i];     for (int x = 0; x < r; x++)       for (int y = 0; y < c; y++) {         int nx = x, ny = y;         if (str_dir[x][y] ==  U ) nx--;         if (str_dir[x][y] ==  D ) nx++;         if (str_dir[x][y] ==  L ) ny--;         if (str_dir[x][y] ==  R ) ny++;         e[id(x, y)].push_back(id(nx, ny));         rev[id(nx, ny)].push_back(id(x, y));         if (0) cerr <<  rev   << id(nx, ny) <<     << id(x, y) <<   n ;         col[id(x, y)] = str_col[x][y] ==  0 ;       }     int n = r * c;     for (int i = 0; i < n; i++) {       if (not vis[i] and not vis2[i]) {         if (0) cerr <<  call dfs   << i <<   n ;         dfs(i);       }     }     cout << cyc_len <<     << black_cnt <<   n ;   }   void reset() {     for (int i = 0; i < r * c; i++) {       e[i].clear();       rev[i].clear();       vis[i] = vis2[i] = cyc_len = black_cnt = 0;     }   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     int t = 1;     cin >> t;     for (int no = 1; no <= t; no++) {       solve();       reset();     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     float a1, b1, c1, a2, b2, c2;     cin >> a1 >> b1 >> c1 >> a2 >> b2 >> c2;     if (!b1 && !b2) {       if ((!a1 && c1) || (!a1 && c2)) {         cout << 0 << endl;         return 0;       }       if ((!c1 && !c2) || (!a1 && !a2) || c1 / a1 == c2 / a2) {         cout << -1 << endl;         return 0;       } else {         cout << 0 << endl;         return 0;       }     } else if ((!b1 && !a1 && !c1) || (!b2 && !a2 && !c2)) {       cout << -1 << endl;       return 0;     } else if ((!b1 && !a1) || (!b2 && !a2)) {       cout << 0 << endl;       return 0;     } else if (!b1 || !b2) {       cout << 1 << endl;       return 0;     }     if (a1 / b1 == a2 / b2 && c1 / b1 == c2 / b2)       cout << -1 << endl;     else if (a1 / b1 == a2 / b2)       cout << 0 << endl;     else       cout << 1 << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long n, m;   vector<vector<long long> > a, b, orig;   bool swapd = false;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     cin >> n >> m;     orig.resize(n);     for (long long i = 0; i < n; i++) {       orig[i].resize(m);       for (long long j = 0; j < m; j++) {         orig[i][j] = i * m + j + 1;       }     }     if (n > m) {       swap(n, m);       swapd = true;     }     if (n == 1 && m == 1) {       cout <<  YES n ;       cout <<  1 n ;       return 0;     }     if (n == 1 && m == 2) {       cout <<  NO n ;       return 0;     }     if (n == 1 && m == 3) {       cout <<  NO n ;       return 0;     }     if (n == 2 && m == 2) {       cout <<  NO n ;       return 0;     }     if (n == 2 && m == 3) {       cout <<  NO n ;       return 0;     }     if (n == 3 && m == 3) {       cout <<  YES n6 1 8 n7 5 3 n2 9 4 n ;       return 0;     }     if (n == 1 && m >= 4) {       if (swapd == false) {         cout <<  YES n ;         for (long long i = 2; i <= m; i += 2) cout << i <<    ;         for (long long i = 1; i <= m; i += 2) cout << i <<    ;       } else {         cout <<  YES n ;         for (long long i = 2; i <= m; i += 2) cout << i <<   n ;         for (long long i = 1; i <= m; i += 2) cout << i <<   n ;       }       return 0;     }     cout <<  YES n ;     a.resize(n);     if (swapd) {       for (long long i = 0; i < n; i++) {         a[i].resize(m);         for (long long j = 0; j < m; j++) a[i][j] = orig[j][i];       }     } else {       for (long long i = 0; i < n; i++) {         a[i].resize(m);         for (long long j = 0; j < m; j++) {           a[i][j] = i * m + j + 1;         }       }     }     b.resize(n);     for (long long i = 0; i < n; i++) {       b[i].resize(m);       if (i % 2 == 1) {         b[i] = a[i];         continue;       }       for (long long j = 0; j < m; j++) {         b[i][j] = a[i][((j - 2) % m + m) % m];       }     }     a = b;     for (long long j = 0; j < m; j++) {       if (j % 2 == 0) {         for (long long i = 0; i < n; i++) {           b[i][j] = a[(i + 1) % n][j];         }       }     }     if (swapd) {       for (long long j = 0; j < m; j++) {         for (long long i = 0; i < n; i++) cout << b[i][j] <<    ;         cout <<   n ;       }     } else {       for (long long i = 0; i < n; i++) {         for (long long j = 0; j < m; j++) {           cout << b[i][j] <<    ;         }         cout <<   n ;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long mod = 1000000007;   const double PI = acos(-1.0);   const double epsilon = PI / 180.0;   long long powmod(long long a, long long b) {     long long res = 1;     a %= mod;     assert(b >= 0);     for (; b; b >>= 1) {       if (b & 1) res = res * a % mod;       a = a * a % mod;     }     return res;   }   long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }   const int N = 3e3 + 10, M = 1e6 + 10;   int n;   int a[N];   long long num[N][N], f[N][N];   int main() {     int _;     cin >> _;     while (_--) {       memset(num, 0, sizeof num);       memset(f, 0, sizeof f);       cin >> n;       for (int i = 1; i < n + 1; i++) cin >> a[i];       for (int i = 1; i < n + 1; i++) {         for (int j = n + 1 - 1; j >= i + 1; j--) {           num[i][j] = num[i][j + 1];           if (a[i] == a[j]) num[i][j]++;         }       }       for (int k = 1; k < n + 1; k++) {         for (int i = 1; i < k + 1; i++) {           f[i][k] = f[i - 1][k] + num[i][k + 1];         }       }       long long ans = 0;       for (int i = 1; i < n + 1; i++) {         for (int j = i + 1; j < n + 1; j++) {           if (a[i] != a[j]) continue;           ans += (f[j - 1][j] - f[i][j]);         }       }       cout << ans <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long cum[(int)1e6], input[(int)1e6], k, ans;   char c;   int sz, t;   map<long long, vector<int>> pos;   int main() {     cin >> sz >> k;     for (int i = 0; i < sz; i++) {       scanf( %c%d , &c, &t);       input[i] = t;       if (i == 0) {         cum[0] = t;       } else {         cum[i] = cum[i - 1] + input[i];       }       pos[cum[i]].push_back(i);     }     for (long long target = 1; abs(target) <= 1e16; target *= k) {       for (int i = 0; i < sz; i++) {         if (i == 0) {           ans += pos[target].size();         } else {           ans += pos[target + cum[i - 1]].end() -                  lower_bound(pos[target + cum[i - 1]].begin(),                              pos[target + cum[i - 1]].end(), i);         }       }       if ((k == 1) || (k == -1 && target == k)) {         cout << ans << endl;         return 0;       }     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   const double pi = acos(-1);   const int MOD = 1e9 + 7;   const long long INF = 1e18 + 7;   const int MAXN = 1e3 + 5;   const double eps = 1e-9;   using namespace std;   long long a[MAXN], dist[MAXN];   pair<long long, long long> loc[MAXN];   int par[MAXN];   long long cost(int x, int y, long long d) {     return d * (abs(loc[x].first - loc[y].first) +                 abs(loc[x].second - loc[y].second));   }   int main() {     long long n, d;     scanf( %I64d , &(n)), scanf( %I64d , &(d));     for (int i = 1; i + 1 < n; i++) scanf( %I64d , &(a[i]));     for (int i = 0; i < n; i++)       scanf( %I64d , &(loc[i].first)), scanf( %I64d , &(loc[i].second)),           dist[i] = INF;     dist[0] = 0;     priority_queue<pair<long long, long long>,                    vector<pair<long long, long long> >,                    greater<pair<long long, long long> > >         pq;     pq.push({0, 0});     while (!pq.empty()) {       pair<long long, long long> cur = pq.top();       pq.pop();       for (int i = 0; i < n; i++) {         if (i == cur.second) continue;         long long c = cost(i, cur.second, d);         if (dist[i] > dist[cur.second] + c - a[i]) {           dist[i] = dist[cur.second] + c - a[i];           pq.push({dist[i], i});           par[i] = cur.second;         }       }     }     printf( %I64d n , (dist[n - 1]));     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int inf = 0x3f3f3f3f, oo = inf;   inline long long read() {     register long long x = 0, f = 1;     register char c = getchar();     for (; !isdigit(c); c = getchar())       if (c ==  - ) f = -1;     for (; isdigit(c); c = getchar()) x = (x << 1) + (x << 3) + (c ^ 48);     return x * f;   }   void write(long long x) {     if (x < 0) x = -x, putchar( - );     if (x >= 10) write(x / 10);     putchar(x % 10 +  0 );   }   void writeln(long long x) {     write(x);     puts(  );   }   const long long maxn = 200005;   long long n, a[maxn], k;   bool check(long long m) {     long double sum = 0, s;     long long p, q;     for (register long long i = (0); i < (n); ++i) {       if (a[i] == 0) continue;       q = n - 1 - i + m - 1;       p = m - 1;       p = min(p, q - p);       s = a[i];       while (p) {         s = s * q / p;         p--, q--;         if (s >= k) return true;       }       sum += s;       if (sum >= k) return true;     }     return false;   }   long long solve(long long l, long long r) {     long long mid, ans;     while (l <= r) {       mid = (l + r) >> 1;       if (check(mid)) {         ans = mid;         r = mid - 1;       } else         l = mid + 1;     }     return ans;   }   signed main() {     n = read(), k = read();     for (register long long i = (0); i < (n); ++i) {       a[i] = read();       if (a[i] >= k) {         puts( 0 );         return 0;       }     }     writeln(solve(1, k));     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int sum[100010], ans[100010];   int data[100010];   bool sign[100010];   int main() {     int n, m, c;     while (scanf(  %d %d %d , &n, &m, &c) == 3) {       for (int i = 1; i <= n; i++) {         scanf(  %d , &ans[i]);       }       for (int i = 1; i <= m; i++) {         scanf(  %d , &sum[i]);         sum[i] += sum[i - 1];       }       memset(sign, 0, sizeof(sign));       for (int i = 1; i <= m && i <= n; i++) {         if (i + m - 1 <= n) {           ans[i] += sum[i];           sign[i] = 1;         } else {           ans[i] += sum[i] - sum[i + m - 1 - n];           sign[i] = 1;         }       }       for (int i = n; n - i + 1 <= m && i >= 1 && !sign[i]; i--) {         if (i - m + 1 >= 1) {           ans[i] += sum[m] - sum[m + i - n - 1];           sign[i] = 1;         } else {           ans[i] += sum[m] - sum[m + i - n - 1] - (sum[m] - sum[i]);           sign[i] = 1;         }       }       for (int i = 1; i <= n; i++) {         if (sign[i]) continue;         ans[i] += sum[m];       }       for (int i = 1; i < n; i++) {         printf( %d  , ans[i] % c);       }       printf( %d n , ans[n] % c);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   vector<int> v[1000005];   int n, ar[100005];   int main() {     cin >> n;     set<int> st;     for (int i = 0; i < n; i++) {       cin >> ar[i];       st.insert(ar[i]);       v[ar[i]].push_back(i + 1);     }     vector<int> fr(st.begin(), st.end());     int mx = 0, l = 1, r = n, mnd = INT_MAX;     for (int i = 0; i < fr.size(); i++) {       int x = fr[i];       if (v[fr[i]].size() >= mx) {         if (mx < v[fr[i]].size() || v[x][v[x].size() - 1] - v[x][0] < mnd) {           l = v[x][0];           r = v[x][v[x].size() - 1];           mnd = v[x][v[x].size() - 1] - v[x][0];           mx = v[x].size();         }       }     }     cout << l <<     << r << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 100005;   struct Edge {     int to, next;   } e[N << 1];   int in[N], head[N], sz;   int del[N], leg[N];   int cnt[N];   int res, n;   void addedge(int u, int v) {     e[sz].to = v;     e[sz].next = head[u];     head[u] = sz++;   }   void init() {     memset(head, -1, sizeof(head));     memset(in, 0, sizeof(in));     memset(del, 0, sizeof(del));     memset(cnt, 0, sizeof(cnt));     sz = 0;     res = 1;   }   void dfs1(int u, int f = 0) {     int f1 = 0, f2 = 0;     for (int i = head[u]; i != -1; i = e[i].next) {       int v = e[i].to;       if (v == f) continue;       f1 = 1;       dfs1(v, u);       if (del[v]) f2 = 1;     }     if (!f1 || (f2 && in[u] < 3)) del[u] = 1;   }   void calc(int u) {     leg[u] = 0;     for (int i = head[u]; i != -1; i = e[i].next) {       int v = e[i].to;       if (del[v]) leg[u]++;     }     leg[u] = min(leg[u], 2);   }   bool check(int u) {     int cnt = 0;     for (int i = head[u]; i != -1; i = e[i].next) {       int v = e[i].to;       if (!del[v] && in[v] - leg[v] > 1) ++cnt;     }     return cnt > 2;   }   void solve() {     init();     int x, y;     for (int i = 1; i < n; i++) {       scanf( %d%d , &x, &y);       addedge(x, y);       addedge(y, x);       in[x]++;       in[y]++;     }     int s = 0;     for (int i = 1; i <= n; i++)       if (in[s] < in[i]) s = i;     if (in[s] <= 2) {       printf( Yes n );       return;     }     dfs1(s);     for (int i = 1; i <= n; i++) calc(i);     int flag = 0;     for (int i = 1; i <= n; i++) flag |= check(i);     printf(!flag ?  Yes n  :  No n );   }   int main() {     while (~scanf( %d , &n)) solve();     return 0;   }
#include <bits/stdc++.h>   int main() {     int t;     scanf( %d , &t);     int a[t], b[t], c[t];     for (int i = 0; i < t; i++) scanf( %d %d %d , &a[i], &b[i], &c[i]);     for (int i = 0; i < t; i++) {       if (a[i] == b[i] && b[i] == c[i]) {         printf( YES n );         printf( %d %d %d n , a[i], a[i], a[i]);       } else if (a[i] == b[i] && a[i] > c[i]) {         printf( YES n );         printf( %d %d %d n , a[i], c[i], c[i]);       } else if (b[i] == c[i] && b[i] > a[i]) {         printf( YES n );         printf( %d %d %d n , b[i], a[i], a[i]);       } else if (a[i] == c[i] && a[i] > b[i]) {         printf( YES n );         printf( %d %d %d n , a[i], b[i], b[i]);       } else {         printf( NO n );       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   struct query {     long long int l;     long long int r;     long long int i;   };   query Q[200001];   long long int arr[200001];   long long int f[1000001];   long long int ans[200001];   long long int cnt;   bool compare(query a, query b) {     if ((a.l / 448) != (b.l / 448)) return a.l / 448 < b.l / 448;     return a.r < b.r;   }   void add(long long int a) {     long long int x = f[arr[a]] * f[arr[a]] * arr[a];     cnt -= x;     f[arr[a]]++;     x = f[arr[a]] * f[arr[a]] * arr[a];     cnt += x;   }   void remove(long long int a) {     long long int x = f[arr[a]] * f[arr[a]] * arr[a];     cnt -= x;     f[arr[a]]--;     x = f[arr[a]] * f[arr[a]] * arr[a];     cnt += x;   }   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     long long int n, i, q;     cin >> n >> q;     for (i = 0; i < n; i++) cin >> arr[i];     for (i = 0; i < q; i++) {       cin >> Q[i].l >> Q[i].r;       Q[i].i = i;       Q[i].l--;       Q[i].r--;     }     sort(Q, Q + q, compare);     long long int cl = 0, cr = -1;     for (i = 0; i < q; i++) {       long long int L = Q[i].l;       long long int R = Q[i].r;       while (cl > L) {         cl--;         add(cl);       }       while (cr < R) {         cr++;         add(cr);       }       while (cl < L) {         remove(cl);         cl++;       }       while (cr > R) {         remove(cr);         cr--;       }       ans[Q[i].i] = cnt;     }     for (i = 0; i < q; i++) {       cout << ans[i] <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n = 0, a = 0;     cin >> n;     int* arr = new int[n];     for (int i = 0; i < n; i++) {       cin >> arr[i];     }     sort(arr, arr + n);     for (int j = 0; j < n; j++) {       cout << arr[j] <<    ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, i;     cin >> n;     int a[n];     for (i = 0; i < n; i++) {       cin >> a[i];     }     int j, x;     for (i = 0; i < n; i++) {       for (j = 0; j < n; j++) {         if (a[i] != a[n - j - 1]) {           x = n - 1 - j - i;           break;         }       }       if (j < n) break;     }     for (i = 0; i < n; i++) {       for (j = 0; j < n; j++) {         if (a[j] != a[n - 1]) {           x = max(x, n - 1 - j);           break;         }       }       if (j < n) break;     }     cout << x;   }
#include <bits/stdc++.h>   using namespace std;   const int inf = (int)1e9;   const long long mod = (long long)1e9 + 7;   const double eps = (double)1e-9;   const double pi = acos(-1.0);   const int dx[] = {0, 0, 1, 0, -1};   const int dy[] = {0, 1, 0, -1, 0};   const int N = 100500;   int n, ans, a[N], dp[N];   int main() {     cin >> n;     for (int i = 1; i <= n; i++) cin >> a[i];     ans = inf;     for (int i = 1; i <= n; i++) {       dp[a[i]] = dp[a[i] - 1] + 1;       ans = min(ans, n - dp[a[i]]);     }     cout << ans;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long double PI = 3.14159265359;   long double DEL = 1e-10;   int mod = 1000000007;   long long fpow(long long x, long long n) {     long long res = 1;     while (n) {       if (n & 1) res = res * x % mod;       x = x * x % mod;       n >>= 1;     }     return res;   }   long long gcd(long long a, long long b) {     if (b == 0) return a;     return gcd(b, a % b);   }   void sieve(long long n) {     bool prime[1000006];     memset(prime, true, sizeof(prime));     long long rootn = (long long)sqrt(n);     for (long long p = 2; p <= rootn; p++)       if (prime[p] == true)         for (long long i = p * p; i <= n; i += p) prime[i] = false;     prime[1] = 0;   }   const long long N = 300050;   long long cnt, sum, mid, mx, mn, ans, a[N], b[N];   long long n, m, d, i, j, k, l, p, q, r, t, w, x, y, z;   bool f, f1, f2;   string s;   int32_t main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     cin >> n >> k;     cout << (n / k + 1) * k;   }
#include <bits/stdc++.h>   using namespace std;   int main(int argc, char const *argv[]) {     int n;     cin >> n;     int a[n];     for (int i = 0; i < n; ++i) {       cin >> a[i];     }     int cnt = 0;     std::vector<int> v;     for (int i = n - 1; i > 0; --i) {       if (a[i] != 10000) {         for (int j = i - 1; j >= 0; --j) {           if (a[j] == a[i]) {             a[j] = 10000;           }         }         v.push_back(a[i]);       }     }     if (a[0] != 10000) {       v.push_back(a[0]);     }     cout << v.size() << endl;     for (int i = v.size() - 1; i >= 0; --i) {       cout << v[i] <<    ;     }     cout << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     long long n;     cin >> n;     vector<pair<long long, long long>> a(n);     vector<long long> ord(n);     for (long long i = 0; i < n; i++) {       cin >> a[i].first;       a[i].second = i;     }     sort(a.begin(), a.end());     for (long long i = 0; i < n; i++) {       ord[a[i].second] = i;     }     for (long long i = 0; i < n; i++) {       cout << (a[(ord[i] + 1) % n].first) <<    ;     }     return 0;   }