malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     int n, m;     cin >> n >> m;     char a[n + 2][m + 2];     int flag = 0;     for (long long int i = 0; i <= n + 1; i++) {       for (long long int j = 0; j <= m + 1; j++) {         a[i][j] =  . ;       }     }     for (long long int i = 1; i <= n; i++)       for (long long int j = 1; j <= m; j++) cin >> a[i][j];     for (long long int i = 1; i <= n; i++) {       for (long long int j = 1; j <= m; j++) {         if (a[i][j] ==  S ) {           if (a[i - 1][j] ==  W  || a[i + 1][j] ==  W  || a[i][j - 1] ==  W  ||               a[i][j + 1] ==  W ) {             flag = 1;             break;           }         }         if (a[i][j] ==  W ) {           if (a[i - 1][j] ==  .  || a[i - 1][j] ==  D ) a[i - 1][j] =  D ;           if (a[i + 1][j] ==  .  || a[i + 1][j] ==  D ) a[i + 1][j] =  D ;           if (a[i][j - 1] ==  .  || a[i][j - 1] ==  D ) a[i][j - 1] =  D ;           if (a[i][j + 1] ==  .  || a[i][j + 1] ==  D ) a[i][j + 1] =  D ;         }       }       if (flag == 1) break;     }     if (flag == 1)       cout <<  No             <<   n ;     else {       cout <<  Yes             <<   n ;       for (long long int i = 1; i <= n; i++) {         for (long long int j = 1; j <= m; j++) {           cout << a[i][j];         }         cout <<   n ;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 2e5 + 6;   const int maxlog = 20;   const long long inf = 1e18;   const int mod = 1e9 + 7;   const long long base = 307;   map<long long, int> cnt1, cnt2;   set<int> st;   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     int n;     cin >> n;     int need = (n + 1) / 2;     for (int i = 0; i < n; i++) {       int x, y;       cin >> x >> y;       cnt1[x]++;       if (y != x) cnt2[y]++;       st.insert(x);       st.insert(y);     }     int ans = mod;     for (set<int>::iterator it = st.begin(); it != st.end(); it++) {       int x = *it;       int kol = cnt1[x] + cnt2[x];       if (kol < need) continue;       int new_need = need - cnt1[x];       ans = min(ans, new_need);     }     if (ans == mod)       cout << -1;     else       cout << max(0, ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     long long int n, i, c = 0;     cin >> n;     long long int a[n];     for (i = 0; i < n; i++) cin >> a[i];     sort(a, a + n);     for (i = 0; i < n; i++) {       if (a[i] == a[i + 1]) {         c++;         i++;       }     }     cout << c / 2;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   bool prime(int x) {     if (x == 1)       return false;     else if (x == 2)       return true;     for (int i = 2; i * i <= x; i++) {       if (x % i == 0) return false;     }     return true;   }   void fun2(int t) {     if (t == 1) {       cout <<  * ;       return;     }     cout <<  * ;     return fun2(t - 1);   }   void fun(int s) {     map<int, int> asd;     map<int, int>::iterator ir;     ir = asd.begin();     ir->first;     if (s) {       cout << s % 10 << endl;       fun(s / 10);     }   }   long long numb(long long i) {     if (i == 2 || i == 1)       return 1;     else {       long long n = i, z = 0;       while (n > 1) {         if (i % n == 0) {           z++;         }         n--;       }       return z;     }   }   int main() {     std::ios_base::sync_with_stdio(0);     cin.tie(NULL);     cout.tie(NULL);     int r1, r2, c1, c2, d1, d2;     cin >> r1 >> r2 >> c1 >> c2 >> d1 >> d2;     vector<vector<int>> v(2, vector<int>(2));     v[0][0] = (r1 - c2 + d1) / 2;     v[0][1] = r1 - v[0][0];     v[1][0] = c1 - v[0][0];     v[1][1] = d1 - v[0][0];     bool b = true;     for (int i = 0; i < 2; i++) {       for (int j = 0; j < 2; j++) {         for (int h = 0; h < 2; h++) {           for (int g = 0; g < 2; g++) {             if (i == h && j == g) continue;             if (v[i][j] == v[h][g]) {               b = false;             }           }         }       }     }     for (int i = 0; i < 2; i++) {       for (int j = 0; j < 2; j++) {         if (v[i][j] == 0 || v[i][j] > 9) b = false;       }     }     if (r1 != v[0][0] + v[0][1] || r2 != v[1][0] + v[1][1] ||         c1 != v[0][0] + v[1][0] || c2 != v[0][1] + v[1][1] ||         d1 != v[0][0] + v[1][1] || d2 != v[0][1] + v[1][0])       b = false;     if (b) {       for (int i = 0; i < 2; i++) {         for (int j = 0; j < 2; j++) {           cout << v[i][j] <<    ;         }         cout << endl;       }     } else {       cout << -1 << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   vector<string> s(3e5 + 1);   vector<pair<int, int>> p;   int n;   vector<pair<int, int>> q;   int Kr(int kb, int kn) {     int ans = 0;     for (int i = 0; i < n; i++) {       int r1 = q[i].first - kb;       int r2 = q[i].second - kn;       int r;       if (r1 * r2 >= 0)         r = max(abs(r1), abs(r2));       else         r = abs(r1) + abs(r2);       ans = max(ans, r);     }     return ans;   }   pair<int, int> F(int kb) {     int Fl = 0, Fr = 5e5;     if (!kb) Fl++;     while (Fr - Fl > 2) {       int m1 = Fl + (Fr - Fl) / 3;       int m2 = Fr - (Fr - Fl) / 3;       if (Kr(kb, m1) >= Kr(kb, m2))         Fl = m1;       else         Fr = m2;     }     return min(make_pair(Kr(kb, Fl), Fl), min(make_pair(Kr(kb, Fl + 1), Fl + 1),                                               make_pair(Kr(kb, Fl + 2), Fl + 2)));   }   int main() {     cin >> n;     for (int i = 0; i < n; i++) {       cin >> s[i];     }     q.resize(n);     for (int i = 0; i < n; i++) {       int kb = 0;       for (int j = 0; j < s[i].size(); j++) {         if (s[i][j] ==  B ) ++kb;       }       q[i] = {kb, s[i].size() - kb};     }     int l = 0, r = 5e5;     while (r - l > 2) {       int m1 = l + (r - l) / 3;       int m2 = r - (r - l) / 3;       if (F(m1) >= F(m2))         l = m1;       else         r = m2;     }     auto l0 = F(l);     auto l1 = F(l + 1);     auto l2 = F(l + 2);     if (l0 <= l1 && l0 <= l2) {       cout << l0.first <<   n ;       for (int i = 0; i < l; i++) {         cout <<  B ;       }       for (int i = 0; i < l0.second; i++) {         cout <<  N ;       }     } else if (l1 <= l0 && l1 <= l2) {       cout << l1.first <<   n ;       for (int i = 0; i < l + 1; i++) {         cout <<  B ;       }       for (int i = 0; i < l1.second; i++) {         cout <<  N ;       }     } else {       cout << l2.first <<   n ;       for (int i = 0; i < l + 2; i++) {         cout <<  B ;       }       for (int i = 0; i < l2.second; i++) {         cout <<  N ;       }     }   }
#include <bits/stdc++.h>   using namespace std;   bool field[100][100][100];   int n, m, k;   bool check(int x, int y, int z) {     return (x >= 0 && x < n && y >= 0 && y < m && z >= 0 && z < k &&             field[x][y][z]);   }   int main() {     cin.sync_with_stdio(false);     cout.sync_with_stdio(false);     cin >> n >> m >> k;     for (int i = 0; i < n; i++) {       for (int j = 0; j < m; j++) {         for (int x = 0; x < k; x++) {           char v;           cin >> v;           field[i][j][x] = (v ==  1 );         }       }     }     int answer = 0;     for (int x = 0; x < n; x++) {       for (int y = 0; y < m; y++) {         for (int z = 0; z < k; z++) {           if (check(x, y, z)) {             if ((check(x - 1, y, z) && check(x + 1, y, z)) ||                 (check(x, y - 1, z) && check(x, y + 1, z)) ||                 (check(x, y, z - 1) && check(x, y, z + 1))) {               answer++;               continue;             }             if (check(x - 1, y, z) &&                 ((check(x, y + 1, z) && !check(x - 1, y + 1, z)) ||                  (check(x, y, z + 1) && !check(x - 1, y, z + 1)))) {               answer++;               continue;             }             if (check(x, y - 1, z) &&                 ((check(x + 1, y, z) && !check(x + 1, y - 1, z)) ||                  (check(x, y, z + 1) && !check(x, y - 1, z + 1)))) {               answer++;               continue;             }             if (check(x, y, z - 1) &&                 ((check(x, y + 1, z) && !check(x, y + 1, z - 1)) ||                  (check(x + 1, y, z) && !check(x + 1, y, z - 1)))) {               answer++;               continue;             }           }         }       }     }     cout << answer <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1005;   char g[N][N];   int l[N][N], r[N][N], up[N][N], dn[N][N];   int jx[N][N], jy[N][N];   struct Node {     int x, y, len;   };   vector<Node> p;   int main() {     int n, m;     scanf( %d%d , &n, &m);     for (int i = 1; i <= n; i++) scanf( %s , g[i] + 1);     for (int i = 1; i <= n; i++)       for (int j = 1; j <= m; j++)         if (g[i][j] ==  * ) {           l[i][j] = l[i][j - 1] + 1;           up[i][j] = up[i - 1][j] + 1;         }     for (int i = n; i >= 1; i--)       for (int j = m; j >= 1; j--)         if (g[i][j] ==  * ) {           r[i][j] = r[i][j + 1] + 1;           dn[i][j] = dn[i + 1][j] + 1;         }     for (int i = 1; i <= n; i++)       for (int j = 1; j <= m; j++)         if (g[i][j] ==  * ) {           int len = min(min(l[i][j], r[i][j]), min(up[i][j], dn[i][j]));           if (len > 1) {             Node temp;             temp = (Node){i, j, len - 1};             p.push_back(temp);             jx[i - len + 1][j]++, jx[i + len][j]--;             jy[i][j - len + 1]++, jy[i][j + len]--;           }         }     for (int i = 1; i <= n; i++)       for (int j = 1; j <= m; j++)         jx[i][j] += jx[i - 1][j], jy[i][j] += jy[i][j - 1];     for (int i = 1; i <= n; i++)       for (int j = 1; j <= m; j++)         if (g[i][j] ==  *  && !jx[i][j] && !jy[i][j]) {           printf( -1 n );           return 0;         }     printf( %d n , (int)p.size());     for (int i = 0; i < p.size(); i++)       printf( %d %d %d n , p[i].x, p[i].y, p[i].len);     return 0;   }
#include<bits/stdc++.h>   using namespace std;   #define M 105      int frq[M];      int main()   {       int t;       scanf( %d , &t);          while(t--)       {           int n, x;           scanf( %d %d , &n, &x);              memset(frq, 0, sizeof(frq));           for(int i = 1; i <= n; i++)           {               int p;               scanf( %d , &p);                  frq[p]++;           }              vector<int> ans;                         for(int i = 1; i <= 100; i++)           {               while (frq[i] > 1)               {                   ans.push_back(i);                   frq[i]--;               }           }              for(int i = 1; i <= 100; i++)           {               if(frq[i])               {                   ans.push_back(i);                   frq[i]--;               }           }              int ald = 0;           for(int i = 0; i < n; i++)           {               ald += ans[i];               if(ald == x)               {                   swap(ans[i], ans[n-1]);                   break;               }           }              ald = 0;           bool flag = true;           for(int d: ans)           {               ald += d;               if(ald == x)               {                   flag = false;                   break;               }           }              if(!flag) printf( NO n );           else           {               printf( YES n );               for(int d: ans) printf( %d  , d);               printf(  n );           }       }          return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, i, x, k = 0;     cin >> n;     vector<int> a;     for (i = 0; i < n; i++) {       cin >> x;       a.push_back(x);     }     sort(a.begin(), a.end());     for (i = 0; i < n; i++) {       if (a[i] % 2 != 0) k++;     }     int y = min(k, n - k);     cout << y <<   n ;     return 0;   }
#include <cstdio>   #include <iostream>   #include <cstring>   #include <algorithm>   #include <vector>   using namespace std;   # define rep(i,a,b) for(int i=(a); i<=(b); ++i)   # define drep(i,a,b) for(int i=(a); i>=(b); --i)   typedef long long int_;   inline int readint(){    int a = 0; char c = getchar(), f = 1;    for(; c< 0 ||c> 9 ; c=getchar())     if(c ==  - ) f = -f;    for(;  0 <=c&&c<= 9 ; c=getchar())     a = (a<<3)+(a<<1)+(c^48);    return a*f;   }   inline void getMin(int &a,const int &b){    if(a > b) a = b;   }      const int Mod = 998244353;   inline void add(int &x,const int &y){    (x += y) >= Mod ? x -= Mod : 0;   }   inline void mul(int &x,const int &y){    x = int_(x)*y%Mod;   }   int inv[4] = {0,1,(Mod+1)/2,(Mod+1)/3};   inline int C(const int &n,const int &m){    int res = 1;    rep(i,1,m) mul(res,inv[i]);    rep(i,0,m-1) mul(res,n-i);    return res;   }      const int MaxN = 1000005;   const int infty = (1<<30)-1;   int dp[MaxN][4]; // prefix sum      int main(){    int n = readint(), x;    dp[0][0] = 1; // only one node    rep(i,1,n) rep(j,0,3){     rep(k,x=0,2) // at most 2      add(x,dp[i-1][k]);     dp[i][j] = C(j+x-1,j);    }    drep(i,n,1) rep(j,0,3) // get origin value     add(dp[i][j],Mod-dp[i-1][j]);    int ans = 0;    rep(i,1,n) rep(j,2,3) rep(k,0,3-j)     add(ans,1ll*dp[i][j]*dp[n-i][k]%Mod);    rep(j,0,3) add(ans,dp[n][j]);    printf( %d n ,ans);    return 0;   }
#include <bits/stdc++.h>   using namespace std;   inline long long read() {     long long x = 0, f = 1;     char c = getchar();     for (; !isdigit(c); c = getchar())       if (c ==  - ) f = -1;     for (; isdigit(c); c = getchar()) x = x * 10 + c -  0 ;     return x * f;   }   const long long MAXN = 100010;   const long long INF = 2147483600;   long long N;   long long a[MAXN + 1];   int f[63][MAXN + 1];   int p[MAXN + 1], id[MAXN + 1], nwp[MAXN + 1];   int t[2];   long long sta[2][MAXN + 1];   int cnt[2];   inline void Sort(long long x) {     t[0] = t[1] = 0;     for (long long i = 1; i <= N; i++) {       long long d = (a[p[i]] >> x) & 1;       sta[d][++t[d]] = p[i];     }     for (long long i = 1; i <= t[1]; i++) p[i] = sta[1][i];     for (long long i = 1; i <= t[0]; i++) p[i + t[1]] = sta[0][i];     return;   }   int main() {     N = read();     for (long long i = 1; i <= N; i++) {       a[i] = read();     }     memset(f, 127, sizeof(f));     for (long long i = 1; i <= N; i++) p[i] = i;     Sort(0);     f[0][0] = t[0];     f[0][t[1]] = min(f[0][t[1]], t[1]);     for (long long i = 1; i <= 62; i++) {       for (long long j = 1; j <= N; j++) id[j] = p[j];       Sort(i);       cnt[0] = cnt[1] = 0;       for (long long j = 1; j <= N; j++) nwp[p[j]] = j;       int mx1 = 0, mx0 = 0;       for (long long j = 0; j <= N; j++) {         if (j) {           long long x = (a[id[j]] >> i) & 1;           ++cnt[x];           if (x) mx1 = max(mx1, nwp[id[j]]);           mx0 = max(mx0, nwp[id[j]]);         }         if (f[i - 1][j] <= i * N) {           f[i][mx1] = min(f[i][mx1], f[i - 1][j] + cnt[1] + t[0] - cnt[0]);           f[i][max(t[1], mx0)] =               min(f[i][max(t[1], mx0)], f[i - 1][j] + cnt[0] + t[1] - cnt[1]);         }       }     }     printf( %d n , f[62][0]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int x, q;   vector<int> adj[205];   bool visited[205];   void dfs(int n) {     visited[n] = 1;     for (int i = 0; i < adj[n].size(); i++) {       if (!visited[adj[n][i]]) {         visited[adj[n][i]] = 1;         dfs(adj[n][i]);       }     }   }   int main() {     int n, m;     cin >> n >> m;     bool flag = 0;     for (int i = m + 1; i <= n + m; i++) {       cin >> q;       while (q--) {         cin >> x;         if (x) {           flag = 1;         }         adj[i].push_back(x);         adj[x].push_back(i);       }     }     if (!flag) {       cout << n << endl;       return 0;     }     int ans = -1;     for (int i = m + 1; i <= n + m; i++) {       if (!visited[i]) {         dfs(i);         ans++;       }     }     cout << ans << endl;   }
#include <bits/stdc++.h>   using namespace std;   string ar[] = { zero ,     one ,      two ,        three ,     four ,                   five ,     six ,      seven ,      eight ,     nine ,                   ten ,      eleven ,   twelve ,     thirteen ,  fourteen ,                   fifteen ,  sixteen ,  seventeen ,  eighteen };   string br[] = {  ,       ten ,    twenty ,   thirty ,  forty ,                   fifty ,  sixty ,  seventy ,  eighty ,  ninety };   int main() {     int q = 1;     while (q--) {       int n;       cin >> n;       if (n <= 18) {         cout << ar[n];         continue;       }       if (n < 20) {         cout << ar[n % 10] <<  teen ;         continue;       }       int f = n / 10;       if (n % 10 == 0) {         cout << br[f];         continue;       }       cout << br[f] <<  -  << ar[n % 10];     }   }
#include <bits/stdc++.h>   using ll = long long int;   using namespace std;   struct custom_hash {     static uint64_t splitmix64(uint64_t x) {       x += 0x9e3779b97f4a7c15;       x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;       x = (x ^ (x >> 27)) * 0x94d049bb133111eb;       return x ^ (x >> 31);     }     size_t operator()(uint64_t x) const {       static const uint64_t FIXED_RANDOM =           chrono::steady_clock::now().time_since_epoch().count();       return splitmix64(x + FIXED_RANDOM);     }   };   bool printSub(int a[], int sum) {     if (sum == 0) return true;     if (sum < 0) return false;     for (int i = 0; i < 3; ++i) {       int rem = sum - a[i];       if (printSub(a, rem)) {         cout << a[i] <<    ;         return true;       }     }   }   void solve() {     int n, ans = 0;     cin >> n;     int a[n];     for (int i = 0; i < n; ++i) cin >> a[i];     for (int i = 30; i > 0; --i) {       int sum = 0;       for (int j = 0; j < n; ++j) {         if (a[j] > i) {           sum = 0;         } else           sum = max(a[j], sum + a[j]);         ans = max(ans, sum - i);       }     }     cout << ans;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     int t = 1;     while (t--) {       solve();     }     return 0;   }
#include <bits/stdc++.h>   int col[100002];   int cal[5];   int main() {     int n, m, i, j, k;     int inp[3];     scanf( %d%d , &n, &m);     for (i = 0; i < m; i++) {       for (j = 0; j <= 3; j++) {         cal[j] = 0;       }       for (j = 0; j < 3; j++) {         scanf( %d , inp + j);         cal[col[inp[j]]]++;       }       k = 0;       for (j = 1; j <= 3; j++) {         if (cal[j] == 0) {           while (col[inp[k]] != 0) {             k++;           }           col[inp[k]] = j;         }       }     }     for (i = 1; i <= n; i++) {       if (col[i] == 0) {         col[i] = 1;       }       printf( %d  , col[i]);     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     int n, s;     cin >> n >> s;     int a[s];     memset(a, 0, sizeof a);     for (int i = 0; i < n; i++) {       int x, y;       cin >> x >> y;       a[x - 1] = max(a[x - 1], y);     }     int t = 0;     for (int i = 0; i < s; i++) {       t += max(a[s - i - 1] - t, 0);       t++;     }     cout << t << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   char grid[105][105];   int dix[] = {-1, 1, 0, 0}, diy[] = {0, 0, -1, 1}, par[105][105], col[105][105],       n, m;   char ddd[] =  UDLR ;   vector<int> vec;   void dfs(int xx, int yy) {     int i, p, q;     col[xx][yy] = 1;     for (i = 0; i < 4; i++) {       p = xx + dix[i];       q = yy + diy[i];       if (p >= 0 && p < n && q >= 0 && q < m && grid[p][q] !=  *  && !col[p][q]) {         par[p][q] = i;         dfs(p, q);       }     }     return;   }   int main() {     int i, j, k, p, q, x, y;     scanf( %d %d , &n, &m);     for (i = 0; i < n; i++) scanf( %s , grid[i]);     for (i = 0; i < n; i++) {       for (j = 0; j < m; j++) {         if (grid[i][j] ==  F ) p = i, q = j;       }     }     dfs(0, 0);     while (p || q) {       vec.push_back(par[p][q]);       y = par[p][q];       p -= dix[y], q -= diy[y];     }     reverse(vec.begin(), vec.end());     for (i = 0; i < vec.size(); i++) {       printf( %c n , ddd[vec[i]]);       fflush(stdout);       scanf( %d %d , &x, &y);       x--, y--;       if (p == x && q == y) {         swap(ddd[vec[i]], ddd[vec[i] - 1]);         i--;       }       p = x, q = y;     }     return 0;   }
#include <bits/stdc++.h>   bool a[1005][1005];   int main() {     int n;     scanf( %d , &n);     if (n == 3) {       return puts( 0 1 0 n0 0 1 n1 0 0 ), 0;     } else if (n == 4) {       return puts( -1 ), 0;     };     int n1 = n - (~n & 1);     int i, j;     for (i = 1; i <= n1; i++) {       a[i][i % n1 + 1] = 1;       for (j = 4; j < n1; j += 2) {         a[i][(i + j - 2) % n1 + 1] = 1;       };     };     if (~n & 1) {       a[n][1] = 1;       for (i = 5; i <= n; i += 2) a[n][i] = 1;       a[3][n] = 1;       for (i = 2; i < n; i += 2) a[i][n] = 1;     };     for (i = 1; i <= n; i++) {       for (j = 1; j <= n; j++) {         putchar(48 + a[i][j]);         putchar(32);       };       putchar(  n );     };   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     int q;     cin >> q;     for (int k = 0; k < q; ++k) {       string s, t;       cin >> s >> t;       vector<bool> a(26), b(26);       for (int i = 0; i < s.size(); ++i) {         a[s[i] -  a ] = true;         b[t[i] -  a ] = true;       }       bool flag = false;       for (int i = 0; i < 26; ++i) {         if (a[i] && b[i]) {           flag = true;           break;         }       }       if (flag)         cout <<  YES n ;       else         cout <<  NO n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   struct T {     T *l, *r;     long long d, sum, mx;     bool pushed;     void recalc(long long len, long long d) {       this->d = d;       sum = len * d;       mx = max(0ll, sum);     }     T(long long len, long long d) {       l = r = 0;       this->d = d;       sum = len * d;       mx = max(0ll, sum);       pushed = 0;     }     void push(int l, int r) {       if (!pushed) return;       int m = (l + r) / 2;       this->l->recalc(m + 1 - l, d);       this->r->recalc(r + 1 - m, d);       this->l->pushed = 1;       this->r->pushed = 1;       pushed = 0;     }     void upd(int l, int r, int tl, int tr, long long x) {       if (r < tl || tr < r) return;       if (tl <= l && r <= tr) {         d = x;         sum = (r - l + 1) * d;         mx = max(0ll, sum);         pushed = 1;       }       int m = (l + r) / 2;       if (!this->l) this->l = new T(m - l + 1, d);       if (!this->r) this->r = new T(r - m + 1, d);       push(l, r);       this->l->upd(l, m, tl, tr, x);       this->r->upd(m + 1, r, tl, tr, x);       sum = this->l->sum + this->r->sum;       mx = max(this->l->mx, this->l->sum + this->r->mx);     }   };   int main() {     long long n;     cin >> n;     for (long long i = 2; i * i <= n; i++) {       if (n % i == 0) {         while (n % i == 0) n /= i;         return cout << (n == 1 ? i : 1), 0;       }     }     cout << n;     return 0;   }