malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   typedef struct {     int sum, l;     bool f[55];   } node;   queue<node> qu;   node x, y;   map<int, int> m;   map<int, int>::iterator pos;   int main() {     int n, k, a[55], i, j, t;     while (scanf( %d %d , &n, &k) != EOF) {       for (i = 0; i < n; i++) scanf( %d , &a[i]);       x.sum = x.l = 0;       for (i = 0; i < 55; i++) x.f[i] = true;       while (!qu.empty()) qu.pop();       qu.push(x);       m.clear();       t = 0;       while (!qu.empty()) {         x = qu.front();         qu.pop();         for (i = 0; i < n; i++) {           if (x.f[i]) {             y.sum = x.sum + a[i];             pos = m.find(y.sum);             if (pos != m.end()) continue;             y.l = x.l + 1;             for (j = 0; j < n; j++) y.f[j] = x.f[j];             y.f[i] = false;             qu.push(y);             m.insert(pair<int, int>(y.sum, 0));             printf( %d , y.l);             for (j = 0; j < n; j++)               if (!y.f[j]) printf(  %d , a[j]);             printf(  n );             t++;             if (t == k) break;           }         }         if (t == k) break;       }     }   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 2e5 + 10;   int a[maxn];   queue<int> q;   queue<int> m;   int main() {     int n;     scanf( %d , &n);     int fu = 0;     int maxfu = -0x3f3f3f3f;     int idfu;     for (int i = 1; i <= n; i++) {       scanf( %d , &a[i]);       if (a[i] < 0) {         fu++;         if (maxfu < a[i]) {           maxfu = a[i];           idfu = i;         }       }     }     int flag = 0;     if (fu % 2 != 0) {       m.push(idfu);       flag = 1;     }     for (int i = 1; i <= n; i++) {       if (flag && i == idfu) continue;       if (a[i] == 0)         m.push(i);       else         q.push(i);     }     while (m.size() != 0) {       if (m.size() == 1) {         if (q.size() == 0)           return 0;         else           printf( 2 %d n , m.front());         break;       } else {         int t1, t2;         t1 = m.front();         m.pop();         t2 = m.front();         printf( 1 %d %d n , t1, t2);       }     }     if (q.size() < 2) return 0;     while (q.size() != 1) {       int t1, t2;       t1 = q.front();       q.pop();       t2 = q.front();       printf( 1 %d %d n , t1, t2);     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int T;     cin >> T;     string ans =  / ;     while (T--) {       string s;       cin >> s;       if (s[0] ==  p ) {         cout << ans << endl;         continue;       }       cin >> s;       if (s[0] ==  / )         ans = s +  / ;       else         ans += s +  / ;       while (1) {         int flag = 1;         int x = ans.find( .. );         if (x == -1) break;         int c = 0;         int i;         for (i = x + 1; i >= 0; i--) {           if (ans[i] ==  / ) {             if (!flag) break;             flag = 0;           }           c++;         }         ans.erase(i, c + 1);       }     }     return 0;   }
#include <bits/stdc++.h>   int deg[100000];   int xr[100000];   int edges[100000][2];   int main() {     int n, t = 0;     scanf( %d , &n);     for (int i = 0; i < n; i++) {       scanf( %d%d , &deg[i], &xr[i]);     }     for (int i = 0; i < n; i++) {       if (deg[i] == 1) {         int k = i;         do {           edges[t][0] = k;           edges[t][1] = xr[k];           t++;           deg[k] -= 1;           xr[xr[k]] ^= k;           deg[xr[k]] -= 1;           k = xr[k];         } while (deg[k] == 1);       }     }     printf( %d n , t);     for (int i = 0; i < t; i++) printf( %d %d n , edges[i][0], edges[i][1]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, L = 1;     cin >> n;     int *a = new int[n];     for (int i = 0; i < n; i++) {       cin >> a[i];       if (i != 0) {         if (a[i] > a[L - 1]) L = i + 1;       }     }     if (a[0] > a[L - 1]) L = 1;     sort(a, a + n);     cout << L <<     << a[n - 2];     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e6;   long long int n, m, ans, col;   vector<long long int> v[N], par(N), cola(N);   set<long long int> se[N];   void dfs(long long int s, long long int p) {     par[s] = p;     col = 1;     set<long long int> no, used;     for (auto ic : se[s]) {       if (se[p].find(ic) == se[p].end()) {         no.insert(ic);       } else {         used.insert(cola[ic]);       }     }     for (auto x : no) {       while (used.find(col) != used.end()) col++;       cola[x] = col;       used.insert(col);       ans = max(ans, col);     }     for (auto u : v[s])       if (u != p) {         dfs(u, s);       }   }   int main() {     cin >> n >> m;     for (long long int i = (long long int)1; i <= (long long int)n; i++) {       long long int sz;       cin >> sz;       for (long long int j = (long long int)0; j <= (long long int)sz - 1; j++) {         long long int x;         cin >> x;         se[i].insert(x);       }     }     for (long long int i = (long long int)1; i <= (long long int)n - 1; i++) {       long long int x, y, z;       cin >> x >> y;       v[x].push_back(y);       v[y].push_back(x);     }     dfs(1, 0);     ans = max(ans, 1LL);     cout << ans <<   n ;     for (long long int i = (long long int)1; i <= (long long int)m; i++)       cout << max(1LL, cola[i]) <<    ;   }
#include <bits/stdc++.h>   using namespace std;   const long long inf = 0x3f3f3f3f3f3f3f3f;   int32_t main() {     long long n;     cin >> n;     vector<long long> v1, v2;     long long i, j, ans = 0;     for (i = 0; i < n; i++) {       long long len;       cin >> len;       bool fg = true;       long long mi = INT_MAX, mx = INT_MIN;       for (j = 0; j < len; j++) {         long long x;         cin >> x;         if (x > mi) {           fg = false;         }         mi = min(mi, x);         mx = max(mx, x);       }       if (fg) {         v1.push_back(mi);         v2.push_back(mx);       }     }     sort(v1.begin(), v1.end());     sort(v2.begin(), v2.end());     long long c = 0;     for (auto x : v1) {       auto p = upper_bound(v2.begin(), v2.end(), x) - v2.begin();       c += p;     }     ans = n * n - c;     cout << ans <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     int t = 1;     while (t--) {       int n, k;       cin >> n >> k;       vector<int> m(n), c(k + 1), cnt(k + 1, 0);       for (int i = 0; i < n; i++) {         cin >> m[i];         cnt[m[i]]++;       }       for (int i = 1; i <= k; i++) cin >> c[i];       for (int i = k - 1; i >= 1; i--) cnt[i] += cnt[i + 1];       sort(m.begin(), m.end());       int x, mx = 0;       for (int i = 1; i <= k; i++) {         x = cnt[i] / c[i];         if (cnt[i] % c[i] != 0) x++;         mx = max(x, mx);       }       cout << mx <<   n ;       vector<vector<int> > ans(mx);       int j = 0;       for (int i = n - 1; i >= 0; i--) {         ans[j].push_back(m[i]);         j = (j + 1) % mx;       }       for (int i = 0; i < mx; i++) {         cout << ans[i].size() <<    ;         for (auto x : ans[i]) cout << x <<    ;         cout <<   n ;       }     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long x, sum;     while (~scanf( %lld , &x)) {       if (x < 0) x = -x;       if (x == 2)         printf( 3 n );       else if (x == 0)         printf( 0 n );       else {         for (long long i = 1; i <= x; i++) {           sum = i * (i + 1) / 2;           if (sum == x || (sum > x && ((sum - x) % 2 == 0))) {             printf( %d n , i);             break;           }         }       }     }   }
#include <bits/stdc++.h>   using namespace std;   void solve() {     long long x, y, ans;     cin >> x >> y;     ans = (x / 2) * y;     if (x % 2) ans += y / 2;     cout << ans;   }   int32_t main() {     ios_base::sync_with_stdio(false);     long long t = 1;     while (t--) {       solve();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     long long n, x, m = 1e18;     cin >> n;     vector<long long> v;     for (int i = 0; i < n; i++) {       cin >> x;       v.push_back(x);     }     sort(v.begin(), v.end());     for (int i = 0; i < v.size() / 2; i++) {       m = min(m, v[v.size() / 2 + i] - v[i]);     }     cout << m;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 1005;   const int MAXM = 1e5 + 5;   struct EC {     vector<pair<int, int> > has[2][MAXN];     int deg[2][MAXN], color[MAXM], c[2];     void prep(int d) {       for (int i = 0; i < 2; i++)         for (int j = 0; j < MAXN; j++) has[i][j].resize(d + 1, {0, 0});     }     void dfs(int x, int p) {       auto i = has[p][x][c[!p]];       if (has[!p][i.first][c[p]].second)         dfs(i.first, !p);       else         has[!p][i.first][c[!p]] = {0, 0};       has[p][x][c[p]] = i, has[!p][i.first][c[p]] = {x, i.second};       color[i.second] = c[p];     }     int solve(vector<pair<int, int> > &e, vector<int> &res) {       int m = ((int)e.size()), ans = 0;       for (int i = 0; i < m; i++)         ans = max({ans, ++deg[0][e[i].first + 1], ++deg[1][e[i].second + 1]});       prep(ans);       for (int i = 0; i < m; i++) {         int x[2] = {e[i].first + 1, e[i].second + 1};         for (int d = 0; d < 2; d++)           for (c[d] = 1; has[d][x[d]][c[d]].second; c[d]++)             ;         if (c[0] != c[1]) dfs(x[1], 1);         for (int d = 0; d < 2; d++) has[d][x[d]][c[0]] = {x[!d], i + 1};         color[i + 1] = c[0];       }       res.resize(m);       for (int i = 0; i < m; i++) res[i] = color[i + 1];       return ans;     }   } ec;   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     int a, b, m;     cin >> a >> b >> m;     vector<pair<int, int> > e;     for (int i = 0; i < m; i++) {       int x, y;       cin >> x >> y;       e.push_back({x - 1, y - 1});     }     vector<int> res;     cout << ec.solve(e, res) <<   n ;     for (auto x : res) cout << x <<    ;     cout <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long int n, k, sum = 0, curr = 0, j = 0;     vector<long long int> a(100000), res;     cin >> n >> k;     for (long long int i = 0; i < n; i++) {       cin >> a[i];       sum += a[i];     }     if (sum % k) {       cout <<  No ;     } else {       for (long long int i = 0; i < n; i++) {         curr += a[i];         if (curr == sum / k) {           res.push_back(i + 1 - j);           j = i + 1;           curr = 0;         }       }       if (res.size() == k) {         cout <<  Yes  << endl;         for (long long int i = 0; i < k; i++) {           cout << res[i] <<    ;         }       } else         cout <<  No ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long n, s = 2, ans = 0, i;     cin >> n;     if (n < 2) {       cout << 0;       return 0;     }     for (i = 1; i <= 1e6; ++i) {       if (s > n) break;       if ((n - s) % 3 == 0) ++ans;       s += 3 * i + 2;     }     cout << ans;   }
#include <bits/stdc++.h>   using namespace std;   struct point {     double x, y;     point() { x = y = 0.0; }     point(double A, double B) { x = A, y = B; }     double operator*(point B) { return x * B.x + y * B.y; }     point turn(double A) {       return point(x * cos(A) - y * sin(A), y * cos(A) + x * sin(A));     }   } zero, e, s, t;   double ans, L1, L2, L3, L4, ev, ew, sv, r;   double dis(point &A, point &B) {     return sqrt(((B.x - A.x) * (B.x - A.x)) + ((B.y - A.y) * (B.y - A.y)));   }   bool check(double mid) {     double A, B, C;     t = e.turn(ew * mid);     L2 = dis(t, zero);     L4 = sqrt(((L2) * (L2)) - ((r) * (r)));     C = acos(t * s / L1 / L2);     A = acos(r / L1);     B = acos(r / L2);     if (A + B - C > 1e-8) {       if (sv * mid - dis(s, t) > 1e-8) return true;       return false;     } else {       C -= A + B;       if (sv * mid - C * r - L3 - L4 > 1e-8) return true;       return false;     }   }   int main() {     scanf( %lf%lf%lf , &e.x, &e.y, &ev);     double R = dis(e, zero);     ew = ev / R;     scanf( %lf%lf%lf%lf , &s.x, &s.y, &sv, &r);     L1 = dis(s, zero);     L3 = sqrt(((L1) * (L1)) - ((r) * (r)));     double l = 0, r = dis(s, e);     while (r - l > 1e-8) {       double mid = (l + r) / 2.0;       if (check(mid))         ans = mid, r = mid;       else         l = mid;     }     printf( %lf n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int a[1234567];   int w[1234567];   int main() {     int n, m, q, i;     while (scanf( %d%d , &n, &m) != EOF) {       int k = 0;       memset(a, 0, sizeof(a));       for (i = 0; i < n; i++) {         scanf( %d , &q);         if (q < 1234560) a[q] = 1;       }       i = 1;       while (1) {         if (m < i) break;         if (a[i] == 0 && m >= i) {           m -= i;           w[k++] = i;         }         i++;       }       if (m != 0) {         for (i = m + w[k - 1]; i >= w[k - 1]; i--) {           if (a[i] == 0) {             w[k - 1] = i;             break;           }         }       }       printf( %d n , k);       for (i = 0; i < k; i++) printf( %d%c , w[i], i == k - 1 ?   n  :    );     }     return 0;   }
#include <bits/stdc++.h>   long a[2200];   long absl(long k) {     if (k < 0) {       k = 0 - k;     }     return k;   }   int main() {     long i, j, n, ans, l, r;     scanf( %ld , &n);     for (i = 0; i < n; i++) {       scanf( %ld , a + i);       a[i] = absl(a[i]);     }     for (i = 0, ans = 0; i < n; i++) {       for (j = 0, l = 0; j < i; j++) {         if (a[j] < a[i]) {           l++;         }       }       for (j = i + 1, r = 0; j < n; j++) {         if (a[j] < a[i]) {           r++;         }       }       if (l > r) {         ans += r;       } else {         ans += l;       }     }     printf( %ld n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   char a[500001], b[500001];   int nxt[500000];   int c[2], la, lb;   int kmp() {     nxt[0] = -1;     if (lb == 0) {       return 0;     }     int no = -1;     for (int i = 1; i < lb; i++) {       while (no != -1 && b[no + 1] != b[i]) {         no = nxt[no];       }       if (b[no + 1] == b[i]) {         no++;       }       nxt[i] = no;     }     return nxt[lb - 1] + 1;   }   void solve() {     scanf( %s%s , a, b);     c[0] = c[1] = 0;     la = strlen(a);     lb = strlen(b);     for (int i = 0; i < la; i++) {       c[a[i] -  0 ]++;     }     int add = kmp();     for (int i = 0; i < lb; i++) {       c[b[i] -  0 ]--;       if (c[b[i] -  0 ] < 0) {         printf( %s n , a);         return;       }     }     printf( %s , b);     int c0 = 0, c1 = 0;     for (int i = add; i < lb; i++) {       if (b[i] ==  0 ) {         c0++;       } else {         c1++;       }     }     while (c[0] >= c0 && c[1] >= c1) {       c[0] -= c0;       c[1] -= c1;       for (int i = add; i < lb; i++) {         putchar(b[i]);       }     }     while (c[0]-- > 0) {       putchar( 0 );     }     while (c[1]-- > 0) {       putchar( 1 );     }     printf(  n );   }   int main() { solve(); }
#include <bits/stdc++.h>   using namespace std;   const int N = 200005;   struct node {     int to, next;   } p[N << 2];   int head[N], tot, n, now[N], du[N];   bool vis[N], isok;   vector<pair<int, int> > a;   void add(int x, int y) {     p[++tot] = (node){y, head[x]};     head[x] = tot;     p[++tot] = (node){x, head[y]};     head[y] = tot;   }   inline void del(int x, int fa) {     du[fa]--;     vis[x] = 1;     for (int i = head[x]; i; i = p[i].next) {       int y = p[i].to;       if (vis[y] || y == fa) continue;       del(y, x);     }   }   inline void dfs(int x, int fa) {     int son = 0, id = 0;     for (int i = head[x]; i; i = p[i].next) {       int y = p[i].to;       if (vis[y] || y == fa) continue;       dfs(y, x);       if (~now[y])         son++, id = y;       else         son += 2;     }     if (!son) {       now[x] = 1;       return;     }     if (son == 1) {       now[x] = (~now[id] ? now[id] : -2) + 1;       return;     }     a.clear();     for (int i = head[x]; i; i = p[i].next) {       int y = p[i].to;       if (vis[y] || y == fa || now[y] == -1) continue;       a.push_back(make_pair(now[y], y));     }     sort(a.begin(), a.end());     int m = a.size();     for (int i = 0; i < m; i++) {       int r = i;       while (r < m && a[r].first == a[i].first) r++;       for (int j = i + 1; j < r; j++) del(a[j].second, x), isok = 1;       i = r - 1;     }     now[x] = -1;   }   int check() {     for (int i = 1; i <= n; i++)       if (du[i] > 2) return i;     return -1;   }   int main() {     scanf( %d , &n);     for (int i = 1; i < n; i++) {       int x, y;       scanf( %d%d , &x, &y);       add(x, y);       du[x]++;       du[y]++;     }     while (1) {       int root = check();       isok = 0;       if (root == -1) break;       dfs(root, -1);       if (!isok) break;     }     if (check() == -1) {       int ans = n - 1;       for (int i = 1; i <= n; i++) ans -= vis[i];       while (ans % 2 == 0) ans /= 2;       printf( %d n , ans);     } else       puts( -1 );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 1000005;   const int mod = 998244353;   long long f[5009];   long long c[5009][5009];   long long ch(int a, int b) {     long long sum = 0;     for (int i = 0; i <= a && i <= b; i++) {       sum += ((c[a][i] * c[b][i] % mod) * f[i] % mod);     }     return sum % mod;   }   int main() {     f[0] = f[1] = 1;     for (int i = 2; i <= 5000; i++) {       f[i] = f[i - 1] * i % mod;     }     for (int i = 1; i <= 5000; i++) {       c[i][0] = c[i][i] = 1;       for (int j = 1; j < i; j++) {         c[i][j] = (c[i - 1][j] + c[i - 1][j - 1]) % mod;       }     }     int a, b, c;     while (~scanf( %d%d%d , &a, &b, &c)) {       long long ans = 1;       ans = ans * ch(a, b);       ans %= mod;       ans = ans * ch(a, c);       ans %= mod;       ans = ans * ch(b, c);       ans %= mod;       printf( %I64d n , ans);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1000000;   int k;   int n;   vector<int> v;   int read() {     scanf( %d %d , &n, &k);     for (int i = 1; i <= n; i++) {       int t;       scanf( %d , &t);       v.push_back(t);     }     sort(v.begin(), v.end());     printf( %d , v[n - k]);     return 0;   }   int process() { return 0; }   int main() {     read();     process();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int mod = 998244353;   template <typename T>   void chkmin(T &x, T y) {     if (y < x) x = y;   }   template <typename T>   void chkmax(T &x, T y) {     if (y > x) x = y;   }   template <typename T>   void upd(T &x, T y) {     if ((x += y) >= mod) x -= mod;   }   int n, m, K, N, sl, fh, a[510][510];   int rd() {     sl = 0;     fh = 1;     char ch = getchar();     while (ch <  0  ||  9  < ch) {       if (ch ==  - ) fh = -1;       ch = getchar();     }     while ( 0  <= ch && ch <=  9 ) sl = sl * 10 + ch -  0 , ch = getchar();     return sl * fh;   }   int main() {     ios::sync_with_stdio(false);     K = rd();     for (N = 1; N <= K; N <<= 1)       ;     a[1][1] = a[1][2] = a[1][3] = (N << 1) - 1;     a[3][1] = a[3][2] = a[3][3] = (N << 1) - 1;     a[2][3] = a[3][4] = K;     a[2][1] = N;     a[2][2] = N << 1;     n = 3;     m = 4;     printf( %d %d n , n, m);     for (int i = 1; i <= n; ++i, puts(  ))       for (int j = 1; j <= m; ++j) printf( %d  , a[i][j]);     return 0;   }
#include <bits/stdc++.h>   #pragma comment(linker,  /STACK:256000000 )   using namespace std;   const int INF = (1 << 29) + 5;   const long long int LLINF = (1ll << 59) + 5;   const int MOD = 1000 * 1000 * 1000 + 7;   int n, q;   pair<string, string> arr[228];   map<string, bool> can;   queue<string> now;   int main() {     cin >> n >> q;     string st1, st2;     for (int i = 0; i < q; ++i) {       cin >> arr[i].first >> arr[i].second;     }     now.push( a );     string dd;     string next;     while (!now.empty()) {       dd = now.front();       now.pop();       if (dd.size() >= 6) continue;       for (int i = 0; i < q; ++i) {         if (dd[0] == arr[i].second[0]) {           next = arr[i].first + dd.substr(1, (int)dd.size() - 1);           if (!can[next]) {             can[next] = true;             now.push(next);           }         }       }     }     int answer = 0;     for (auto it = can.begin(); it != can.end(); ++it) {       if (it->first.size() == n) {         ++answer;       }     }     cout << answer;     fclose(stdin);     fclose(stdout);     return 0;   }
#include <bits/stdc++.h>   long long int fact[200010];   long long int power(long long int a, long long int b) {     long long int ans = 1;     long long int k = a;     while (b) {       if (b % 2 == 1) ans *= k, ans %= 1000000007;       b /= 2;       k *= k, k %= 1000000007;     }     return ans;   }   long long int inv(long long int k) { return power(k, 1000000007 - 2); }   long long int comb(int s, int t) {     long long int ans = fact[s];     ans *= inv(fact[s - t]), ans %= 1000000007;     ans *= inv(fact[t]), ans %= 1000000007;     return ans;   }   long long int x[200010], y[200010];   int main() {     fact[0] = 1;     for (int i = 1; i <= 200000; i++)       fact[i] = fact[i - 1] * i, fact[i] %= 1000000007;     int a;     scanf( %d , &a);     for (int i = 1; i <= a; i++) scanf( %lld , &x[i]);     if (a == 1) {       printf( %lld , x[1]);       return 0;     }     if (a % 2 == 1) {       int sign = 1;       for (int i = 1; i < a; i++) y[i] = x[i] + sign * x[i + 1], sign *= -1;       for (int i = 1; i < a; i++) x[i] = (y[i] + 1000000007) % 1000000007;       a--;     }     long long int ans = 0;     if (a % 4 == 2) {       int t = (a - 2) / 2;       for (int i = 1; i <= a; i += 2) {         ans += (x[i] * comb(t, (i - 1) / 2)) % 1000000007;         ans %= 1000000007;         ans += (x[i + 1] * comb(t, (i - 1) / 2)) % 1000000007;         ans %= 1000000007;       }     } else {       int t = (a - 2) / 2;       for (int i = 1; i <= a; i += 2) {         ans += (x[i] * comb(t, (i - 1) / 2)) % 1000000007;         ans %= 1000000007;         ans -= (x[i + 1] * comb(t, (i - 1) / 2)) % 1000000007;         ans += 1000000007;         ans %= 1000000007;       }     }     printf( %lld , ans);   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     cin >> n;     for (int i = 0; i < n; ++i) {       for (int j = 0; j < n; ++j) {         if (i == j)           cout << 0 <<    ;         else if (min(i, j) == 0)           cout << 2 * (i + j) % (n - 1) + 1 <<    ;         else           cout << (i + j) % (n - 1) + 1 <<    ;       }       cout << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   bool isprime(long long int n) {     if (n <= 1) return false;     if (n <= 3) return true;     if (n % 2 == 0 || n % 3 == 0) return false;     for (long long int i = 5; i * i <= n; i += 6) {       if (n % i == 0 || n % (i + 2) == 0) return false;     }     return true;   }   long long int smallestfactor(long long int n) {     for (long long int i = 2; i <= sqrt(n); i++) {       if (n % i == 0) {         long long int x = min(i, n / i);         return x;       }     }   }   int main() {     long long int n;     cin >> n;     long long int ans = 0;     while (1) {       ans += n;       if (isprime(n)) {         ans++;         break;       }       long long int temp = smallestfactor(n);       n /= temp;       if (n == 1) {         ans++;         break;       }     }     cout << ans;   }