malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   void fastIO() {     ios_base::sync_with_stdio(false);     cout.setf(ios::fixed);     cout.precision(10);     cout.tie(nullptr);     cin.tie(nullptr);   }   template <class T>   T power(T N, T P) {     return (P == 0) ? 1 : N * power(N, P - 1);   }   template <class T>   T GCD(T A, T B) {     return (A % B == 0) ? B : GCD(B, A % B);   }   const int MOD = 1e9 + 7;   const int MX = 2e5 + 5;   const double delta = 1e-9;   const long long INF = 1e18;   const long double PI = acos((long double)-1);   void setIn(string s) { freopen(s.c_str(),  r , stdin); }   void setOut(string s) { freopen(s.c_str(),  w , stdout); }   bool sort_rev(int a, int b) { return a > b; }   bool sort_(pair<string, int> &p1, pair<string, int> &p2) {     if (p1.first == p2.first) return p1.second < p2.second;     return p1.first < p2.first;   }   bool func(pair<int, int> a, pair<int, int> b) { return a.first > b.first; }   int main() {     fastIO();     int t = 1;     cin >> t;     while (t--) {       int n;       cin >> n;       pair<int, int> ara[n + 1];       for (int i = 0; i < n; i++) {         cin >> ara[i].first;       }       for (int i = 0; i < n; i++) cin >> ara[i].second;       sort(ara, ara + n, func);       long long aa = 0, bb = 0;       for (int i = 0; i < n; i++) {         long long canB = bb + ara[i].second;         long long canA = max(aa, (long long)ara[i].first);         if (canA <= canB)           aa = canA;         else           bb = canB;       }       cout << max(aa, bb) <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, m, i, j, k, l, a[1000009], b[1000009], p[1000009], ans, cn, t, x, y, z,       mx, mn, s;   char c[1000009], d[1000009], ch;   struct point {     int num, pos;   } pp[1000009];   bool cmp(point a1, point a2) {     if (a1.num == a2.num) {       return a1.pos < a2.pos;     } else {       return a1.num < a2.num;     }   }   int main() {     while (scanf( %d , &n) != EOF) {       ans = 0;       x = -1;       for (i = 0; i < n; i++) {         scanf( %d , &pp[i].num);         pp[i].pos = i;       }       sort(pp, pp + n, cmp);       for (i = 0; i < n; i++) {         if (i > x) {           x = pp[i].pos;           ans++;         } else {           x = max(x, pp[i].pos);         }       }       printf( %d n , ans);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 5009;   bool f[maxn][maxn], vis[maxn];   int pre[maxn][maxn], a[maxn];   int n, k, v, sum, cnt;   inline int read() {     int x = 0, f = 1;     char ch = getchar();     while (ch <  0  || ch >  9 ) {       if (ch ==  - ) f = -1;       ch = getchar();     }     while (ch >=  0  && ch <=  9 ) {       x = x * 10 + ch -  0 ;       ch = getchar();     }     return x * f;   }   void update(int x, int y, int opt) {     f[x][y] = 1;     pre[x][y] = opt;   }   int calc(int x) { return x / k + bool(x % k); }   void work(int x, int y) {     if (x == 0) return;     if (pre[x][y]) {       vis[x] = 1;       cnt++;       sum += a[x];       work(x - 1, (y - a[x] % k + k) % k);     } else       work(x - 1, y);   }   int main() {     n = read();     k = read();     v = read();     for (int i = 1; i <= n; i++) a[i] = read(), sum += a[i];     if (sum < v) {       puts( NO );       return 0;     }     f[0][0] = 1;     for (int i = 0; i < n; i++)       for (int j = 0; j < k; j++)         if (f[i][j]) {           update(i + 1, j, 0);           update(i + 1, (j + a[i + 1]) % k, 1);         }     int tmp;     for (tmp = n; tmp; tmp--)       if (f[tmp][v % k]) break;     if (tmp == 0)       puts( NO );     else {       puts( YES );       work(tmp, v % k);       if (cnt == 0 || cnt == n) {         for (int i = 2; i <= n; i++) {           if (calc(a[i])) printf( %d %d 1 n , calc(a[i]), i);           a[1] += a[i];         }         if (cnt == 0 && v) printf( %d 1 2 n , v / k);         if (cnt && a[1] - v) printf( %d 1 2 n , (a[1] - v) / k);       } else {         int L = 1, R = 1;         for (; L <= n && !vis[L]; L++)           ;         for (; R <= n && vis[R]; R++)           ;         for (int i = 1; i <= n; i++)           if (vis[i] && i != L) {             if (calc(a[i])) printf( %d %d %d n , calc(a[i]), i, L);             a[L] += a[i];           }         for (int i = 1; i <= n; i++)           if (!vis[i] && i != R) {             if (calc(a[i])) printf( %d %d %d n , calc(a[i]), i, R);             a[R] += a[i];           }         if (a[L] > v)           printf( %d %d %d n , (a[L] - v) / k, L, R);         else if (a[L] < v)           printf( %d %d %d n , (v - a[L]) / k, R, L);       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e5 + 5;   const int INF = 1e8 + 5;   const long long mod = 1e9 + 7;   const double pi = 3.1415926536;   int dx[] = {1, -1, 0, 0, 1, 1, -1, -1};   int dy[] = {0, 0, 1, -1, 1, -1, -1, 1};   int xa, ya, xb, yb, n;   vector<pair<int, int> > v;   vector<int> r;   int sqr(int a) { return a * a; }   int dist(int xa, int ya, int xb, int yb) { return sqr(xa - xb) + sqr(ya - yb); }   bool check(int x, int y) {     for (int i = 0; i < n; i++)       if (dist(v[i].first, v[i].second, x, y) <= sqr(r[i])) return true;     return false;   }   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     ios_base::sync_with_stdio(0);     ;     cin >> xa >> ya >> xb >> yb >> n;     if (xa > xb) swap(xa, xb);     if (ya > yb) swap(ya, yb);     for (int i = 0; i < n; i++) {       int x, y, r1;       cin >> x >> y >> r1;       v.push_back({x, y});       r.push_back(r1);     }     int cnt = 0;     for (int x = xa; x <= xb; x++) {       if (!check(x, ya)) cnt++;       if (!check(x, yb)) cnt++;     }     for (int y = ya + 1; y <= yb - 1; y++) {       if (!check(xa, y)) cnt++;       if (!check(xb, y)) cnt++;     }     cout << cnt;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 100010;   int n;   int q;   long long a[201];   multiset<long long> s;   int main() {     cin >> q;     while (q--) {       int flag = 0;       s.clear();       cin >> n;       long long x;       for (int i = 1; i <= n; i++) {         cin >> x;         if (x == 2048) flag = 1;         s.insert(x);       }       if (flag) {         printf( YES n );         continue;       }       multiset<long long>::iterator it1;       multiset<long long>::iterator it2;       while (s.size() >= 2) {         it1 = s.begin();         it2 = s.begin();         it2++;         long long t1 = *it1;         long long t2 = *it2;         if (t1 == t2) {           if (t1 + t2 == 2048) {             flag = 1;             break;           }           s.erase(it1);           s.erase(it2);           s.insert(t1 + t2);         } else {           if (t1 == 2048 || t2 == 2048) {             flag = 1;             break;           }           s.erase(it1);         }       }       if (flag)         printf( YES n );       else         printf( NO n );     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int solve() {     int n, x;     cin >> n >> x;     vector<int> inp(n, 0);     for (int i = 0; i < n; i++) cin >> inp[i];     for (int i = 0; i < n; i++) {       if (inp[i] != x) break;       if (i == (n - 1)) return 0;     }     for (int i = 0; i < n; i++) {       if (inp[i] == x) return 1;     }     int dec = 0, inc = 0;     for (int i = 0; i < n; i++) {       if (inp[i] > x)         inc += (inp[i] - x);       else         dec += (x - inp[i]);     }     if (inc == dec)       return 1;     else       return 2;   }   int main() {     ios::sync_with_stdio(false);     cin.tie(nullptr);     cout.tie(nullptr);     int t;     cin >> t;     for (int i = 1; i <= t; i++) cout << solve() <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int tc;     int n;     string str;     cin >> n >> tc;     cin >> str;     vector<char> vc(3);     vector<vector<int>> dp(6, vector<int>(n + 1, 0));     vc[0] =  a ;     vc[1] =  b ;     vc[2] =  c ;     int j, a = 0;     do {       for (int i = 0; i <= n - 1; i++) {         dp[a][i + 1] = dp[a][i];         j = i % 3;         if (str[i] != vc[j]) dp[a][i + 1]++;       }       a++;     } while (next_permutation(vc.begin(), vc.end()));     while (tc--) {       int l, r, ans;       cin >> l >> r;       ans = r - l + 1;       l--;       for (int i = 0; i < 6; i++) {         ans = min(ans, dp[i][r] - dp[i][l]);       }       cout << ans << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   struct debugger {     template <typename T>     debugger& operator,(const T& v) {       cerr << v <<    ;       return *this;     }   } dbg;   void debugarr(int* arr, int n) {     cout <<  [ ;     for (int i = 0; i < n; i++) cout << arr[i] <<    ;     cout <<  ]  << endl;   }   int main() {     int n;     cin >> n;     if (n % 4 == 2 || n % 4 == 3) {       cout << -1 << endl;       return 0;     }     int arr[100010] = {0};     int x = 2, y = n;     for (int i = 0; i < n / 2; i += 2) {       arr[i] = x;       arr[i + 1] = y;       arr[n - 1 - i] = n + 1 - x;       arr[n - 1 - i - 1] = n + 1 - y;       x += 2;       y -= 2;     }     if (n % 2) arr[(n) / 2] = (n + 1) / 2;     for (int i = 0; i <= (int)n - 1; i++) cout << arr[i] <<    ;     cout << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int a, b, c;     scanf( %d%d%d , &a, &b, &c);     int n = a * c - b * c;     if (n % b > 0)       printf( %d n , n / b + 1);     else       printf( %d n , n / b);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n;   long long int K;   int ans[100];   long long int fib[100];   int main() {     scanf( %d%I64d , &n, &K);     fib[0] = fib[1] = 1, fib[2] = 2;     for (int i = 3; i <= n; i++) fib[i] = fib[i - 1] + fib[i - 2];     for (int i = 1; i <= n; i++) ans[i] = i;     for (int i = 1; i <= n; i++)       if (K > fib[n - i]) {         K -= fib[n - i];         swap(ans[i], ans[i + 1]);         i++;       }     for (int i = 1; i <= n; i++) printf( %d  , ans[i]);     printf(  n );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <class T>   ostream &operator<<(ostream &os, const pair<T, T> &p) {     return os <<  (  << p.first <<  ,  << p.second <<  ) ;   }   template <class T>   ostream &operator<<(ostream &os, const pair<const T, T> &p) {     return os <<  (  << p.first <<  ,  << p.second <<  ) ;   }   template <class T>   ostream &operator<<(ostream &os, const array<T, 3> &p) {     return os <<  (  << p[0] <<  ,  << p[1] <<  ,  << p[2] <<  ) ;   }   template <class T>   ostream &operator<<(ostream &os, const vector<T> &p) {     for (auto x : p) os << x <<    ;     return os;   }   const double EPS = 1e-9;   const double PI = acos(-1);   const int INF = 0x3f3f3f3f;   const long long LINF = 0x3f3f3f3f3f3f3f3f;   const long long mod = 1e9 + 7;   const int SZ = 2e5 + 20;   int ciclo[SZ];   int custo[SZ];   int go[SZ];   int vis[SZ];   int dfs1(int v) {     if (ciclo[v]) return ciclo[v];     if (vis[v]) return ciclo[v] = v;     vis[v] = 1;     return ciclo[v] = dfs1(go[v]);   }   int aux;   int tempo;   void dfs(int v) {     if (vis[v] < tempo) {       aux = 0;       return;     }     if (vis[v] == tempo) return;     vis[v] = tempo;     aux = min(aux, custo[v]);     dfs(go[v]);   }   int main() {     int n;     scanf(  %d , &n);     for (int i = 1; i < n + 1; i++) {       scanf(  %d , &custo[i]);     }     for (int i = 1; i < n + 1; i++) {       scanf(  %d , &go[i]);     }     for (int i = 1; i < n + 1; i++) dfs1(i);     long long res = 0;     memset(vis, INF, sizeof(vis));     for (int i = 1; i < n + 1; i++) {       aux = INF;       tempo += 2;       dfs(ciclo[i]);       res += aux;     }     cout << res <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   double p[111], q[111];   int main() {     int n;     cin >> n;     for (int i = 0, u; i < n; i++) {       scanf( %d , &u);       p[i] = u / 100.0;       q[i] = 1;     }     double ans = 0;     while (1) {       int now = 0;       double tmp = 1;       for (int i = 0; i < n; i++) {         if (q[i] * p[i] * (1 - q[now]) > q[now] * p[now] * (1 - q[i])) now = i;         tmp *= 1 - q[i];       }       ans += 1 - tmp;       q[now] *= (1 - p[now]);       if (1 - tmp < 1e-10) break;     }     printf( %.6lf n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n;   map<int, int> a;   void reset() { a.clear(); }   void input() {     cin >> n;     int c;     for (int(i) = (0); (i) < (n); ++i) {       cin >> c;       a[c]++;     }   }   bool check(int s) {     for (auto it = a.begin(); it != a.end(); ++it) {       double b = (double)(it->second);       if ((int)ceil(b / s) != (int)floor(b / (s - 1))) {         return false;       }     }     return true;   }   void process() {     double d = (double)n;     int mn = n + 1;     for (auto it = a.begin(); it != a.end(); ++it) mn = min(mn, it->second);     int m = n + 1;     for (int(s) = (2); (s) < (mn + 2); ++s) {       bool ok = true;       int tmp = 0;       for (auto it = a.begin(); it != a.end(); ++it) {         int f = it->second;         int q = (int)ceil(1.0 * f / s);         if (f < q * (s - 1)) {           ok = false;           break;         }         tmp += q;       }       if (ok) m = min(m, tmp);     }     cout << m <<   n ;   }   void solve() {     reset();     input();     process();   }   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     int T;     cin >> T;     while (T--) {       solve();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long n, a[100005];   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cin >> n;     string s;     cin >> s;     if (n == 1 && s[0] ==  1 )       cout <<  Yes ;     else if (n == 1)       cout <<  No ;     else if (n == 2 && s[0] != s[1])       cout <<  Yes ;     else if (n == 2)       cout <<  No ;     else {       if (s[0] ==  0  && s[1] ==  0 )         cout <<  No ;       else if (s[n - 1] ==  0  && s[n - 2] ==  0 )         cout <<  No ;       else {         for (int i = 0; i < n - 2; ++i) {           if (s[i] ==  0  && s[i + 1] ==  0  && s[i + 2] ==  0 ) {             cout <<  No ;             return 0;           } else if (s[i] ==  1  && s[i + 1] ==  1 ) {             cout <<  No ;             return 0;           } else if (s[i + 1] ==  1  && s[i + 2] ==  1 ) {             cout <<  No ;             return 0;           }         }         cout <<  Yes ;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   vector<int> lefts[2000000], rights[2000000];   vector<pair<pair<int, int>, bool>> lws;   int maxleft[2000000];   int maxright[2000000];   int minright[2000000];   vector<int> ans;   bool fail = false;   int n;   int dfs(int v, int needed) {     int cur = v;     if (maxleft[v] > v) cur = dfs(cur + 1, maxleft[v]);     ans.push_back(v);     if (cur >= minright[v]) {       fail = true;       return n;     }     if (needed <= cur && maxright[v] <= cur) return cur;     return dfs(cur + 1, max(needed, maxright[v]));   }   int main() {     ios_base::sync_with_stdio(false);     int c;     cin >> n >> c;     for (int i = 1; i <= n; i++) {       maxleft[i] = maxright[i] = i;       minright[i] = 1e9;     }     for (int i = 0; i < c; i++) {       int a, b;       string s;       cin >> a >> b >> s;       lws.push_back(make_pair(make_pair(a, b), s !=  LEFT ));       if (s ==  LEFT ) {         lefts[a].push_back(b);         if (b <= a) fail = true;         maxleft[a] = max(maxleft[a], b);       }       if (s ==  RIGHT ) {         rights[a].push_back(b);         if (b <= a) fail = true;         maxright[a] = max(maxright[a], b);         minright[a] = min(minright[a], b);       }     }     for (int i = 1; i <= n; i++) {       if (minright[i] <= maxleft[i]) fail = true;     }     dfs(1, n);     if (fail)       cout <<  IMPOSSIBLE ;     else {       for (int i = 0; i < n; i++) {         cout << ans[i] <<    ;       }     }   }
#include <bits/stdc++.h>   using namespace std;   int rw, rh, bw, bh;   int main() {     cin >> rw >> rh >> bw >> bh;     int Cred = rh * 2 + rw + 2, Cblue = bh * 2 + bw + 2;     int n = Cblue + Cred;     if (bw > rw)       n += bw - rw;     else       n += rw - bw;     cout << n << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   string s[11];   int a[11];   int n, k;   int ans = 0x7fffffff;   string t[11];   int num[11];   int main() {     cin >> n >> k;     for (int i = 0; i < n; i++) {       cin >> s[i];     }     for (int i = 0; i < k; i++) {       a[i] = i;     }     do {       for (int i = 0; i < n; i++) {         for (int j = 0; j < k; j++) {           t[i][j] = s[i][a[j]];         }       }       for (int i = 0; i < n; i++) {         int tt = 0;         for (int j = 0; j < k; j++) {           tt = tt * 10 + t[i][j] -  0 ;         }         num[i] = tt;       }       sort(num, num + n);       ans = min(ans, num[n - 1] - num[0]);     } while (next_permutation(a, a + k));     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   int main(void) {     char s[1000001] =   ;     int n, n2, x, y, i;     scanf( %d , &n);     n2 = (n / 7) * 7;     while (n2 >= 0) {       if ((n - n2) % 4 == 0)         break;       else         n2 = n2 - 7;     }     if (n2 < 0)       printf( -1 n );     else {       y = n2 / 7;       x = (n - n2) / 4;       for (i = 0; i < x; i++) printf( %c ,  4 );       for (i = 0; i < y; i++) printf( %c ,  7 );       printf(  n );     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int t;   int n, d;   int a;   int main() {     cin >> t;     while (t--) {       cin >> n >> d;       cin >> a;       long long ans = a;       for (int i = 1; i < n; i++) {         cin >> a;         if (d == 0) continue;         if (d > i * a) {           d -= i * a;           ans += a;         } else {           ans += d / i;           d = 0;         }       }       cout << ans << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int a[200000], b[200000];   set<pair<int, int>> se;   set<pair<int, int>>::iterator t;   int main() {     int n, m, d;     cin >> n >> m >> d;     for (int i = 0; i < n; i++) {       cin >> a[i];       se.insert(make_pair(a[i], i));     }     int cnt = 0, pos;     while (!se.empty()) {       pos = se.begin()->second;       b[pos] = ++cnt;       se.erase(se.begin());       while (1) {         t = se.lower_bound({a[pos] + d + 1, 0});         if (t == se.end()) break;         pos = t->second;         b[pos] = cnt;         se.erase(t);       }     }     cout << cnt <<   n  << b[0] <<    ;     for (int i = 1; i < n; i++) cout << b[i] <<    ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long maxN = 1e6 + 5;   const long long inf = 1e10;   const long long mod = 1e9 + 7;   long long n;   long long ans = 1;   long long res[maxN];   void normalSieve(long long n) {     for (long long i = 1; i <= n; i++) res[i] = 1;     for (long long i = 2; i * i <= n; i++) {       if (res[i] == 1) {         for (long long j = i * i; j <= n; j += i) {           res[j] = 2;           ans = 2;         }       }     }   }   int main() {     ios_base::sync_with_stdio(0);     cin >> n;     normalSieve(n + 1);     cout << ans << endl;     for (long long i = 2; i <= n + 1; i++) cout << res[i] <<    ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int t, n, k, i, j, res[201], max = 0, diff;     cin >> t;     for (i = 0; i < t; i++) {       cin >> n >> k;       int x[k];       for (j = 0; j < k; j++) {         cin >> x[j];         if (j == 0) {           max = x[j];         }         if ((j > 0) && (j < k)) {           diff = (x[j] - x[j - 1]) / 2 + 1;         }         if (diff > max) {           max = diff;         }         if (j == (k - 1)) {           if ((n - x[j] + 1) > max) {             max = n - x[j] + 1;           }         }       }       res[i] = max;       diff = 0;     }     for (i = 0; i < t; i++) {       cout << res[i] <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 5e5 + 5;   int nxt[maxn];   int n, ans, m, l, r;   int rmq[maxn][30];   int main() {     ios::sync_with_stdio(false);     cin >> n >> m;     for (int i = 1; i <= n; i++) {       cin >> l >> r;       nxt[l] = max(nxt[l], r);     }     for (int i = 0; i < maxn; i++) {       nxt[i] = max(nxt[i], nxt[i - 1]);       nxt[i] = max(nxt[i], i);       rmq[i][0] = nxt[i];     }     for (int i = 1; i <= 25; i++)       for (int j = 0; j < maxn; j++) {         rmq[j][i] = max(rmq[j][i - 1], rmq[rmq[j][i - 1]][i - 1]);       }     for (int i = 1; i <= m; i++) {       cin >> l >> r;       ans = 0;       for (int j = 25; j >= 0; j--) {         if (rmq[l][j] < r) {           l = rmq[l][j];           ans = ans + (1 << j);         }       }       if (l < r) {         l = rmq[l][0];         ans++;       }       if (l >= r)         cout << ans <<   n ;       else         cout << -1 <<   n ;     }   }
#include <bits/stdc++.h>   using namespace std;   bool chk[64] = {false};   int comb[64][8];   char s[128];   int dp[16][128];   char ans[8][32];   int main() {     for (int p = 0; p <= 6; p++)       for (int q = 0; p + q <= 6; q++) {         int r = 6 - p - q;         int v = q * 4 + r * 7;         chk[v] = true;         for (int i = 0; i < p; i++) comb[v][i] = 0;         for (int i = p; i < p + q; i++) comb[v][i] = 4;         for (int i = p + q; i < p + q + r; i++) comb[v][i] = 7;       }     int T;     scanf( %d , &T);     while (T--) {       s[0] =  0 ;       scanf( %s , s + 1);       int l = strlen(s);       memset(dp, -1, sizeof(dp));       dp[0][0] = -2;       for (int i = 1; i < l; i++)         for (int j = 0; j < 10; j++)           if (dp[j][i - 1] != -1) {             int v = 10 * j + (s[i] -  0 );             for (int k = 0; k < 64; k++)               if (chk[k] && v >= k && v - k < 10) dp[v - k][i] = k;           }       if (dp[0][l - 1] == -1)         printf( -1 n );       else {         int cv = 0;         for (int j = 0; j < 6; j++) {           ans[j][0] =  0 ;           ans[j][l] =   0 ;         }         for (int i = l - 1; i > 0; i--) {           int w = dp[cv][i];           for (int j = 0; j < 6; j++) ans[j][i] =  0  + comb[w][j];           cv += w;           cv /= 10;         }         for (int j = 0; j < 6; j++) {           long long pans;           sscanf(ans[j],  %lld , &pans);           printf(  %lld  + !j, pans);         }         printf(  n );       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long prime[500001];   bool vis[500001];   bool isPrime(long long x) {     for (long long i = 2; i <= sqrt(x); i++) {       if (x % i == 0) return false;     }     return true;   }   int main() {     long long n;     int cnt = 0;     memset(vis, false, sizeof(vis));     memset(prime, 0, sizeof(prime));     for (int i = 2; i <= 110000; i++) {       if (!vis[i]) prime[cnt++] = i;       for (int j = 0; j < cnt && i * prime[j] <= 110000; j++) {         vis[i * prime[j]] = true;         if (i % prime[j] == 0) break;       }     }     while (~scanf( %lld , &n)) {       if (isPrime(n)) {         printf( 1 n );       } else {         for (int i = 0; i < cnt; i++) {           if (n % prime[i] == 0) {             printf( %lld n , 1 + (n - prime[i]) / 2);             break;           }         }       }     }     return 0;   }