malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   const long long mod = 1e9 + 7;   inline long long mul(long long a, long long b) {     return (mod + (a * b) % mod) % mod;   }   inline long long add(long long a, long long b) {     return (mod + (a + b) % mod) % mod;   }   long long pwr(long long a, long long b) {     if (!b) return 1;     long long h = pwr(a, (b >> 1));     h = mul(h, h);     if (b & 1) h = mul(h, a);     return h;   }   const long long maxc = 5;   long long p[maxc][maxc];   long long mysqrt(long long a) {     long long b = sqrt(a);     while (b * b > a) b--;     while ((b + 1) * (b + 1) <= a) b++;     return b;   }   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     for (int i = 0; i < maxc; i++) {       p[i][0] = p[i][i] = 1;       for (int j = 1; j < i; j++) p[i][j] = add(p[i - 1][j - 1], p[i - 1][j]);     }     long long m;     cin >> m;     const long long c[4] = {mul(add(m, 2), mul(add(m, 1), add(m, 0))),                             add(3 * m, 4), add(-6, -3 * m), 2};     long long ans = 0, maxi = mysqrt(m) + 1;     vector<vector<long long> > s(maxi, vector<long long>(maxc * 2));     s[0][0] = 1;     for (long long y = 1; y < maxi; y++) {       long long pw = 1;       for (long long p = 0; p < s[y].size(); pw = mul(pw, y), p++)         s[y][p] = add(s[y - 1][p], mul(2, pw));     }     for (int deg = 0; deg < 4; deg++) {       for (long long x = 0; x * x <= m; x++) {         long long pwx = (x == 0 ? 1 : 2);         for (int xp = 0; xp <= deg; xp++, pwx = mul(pwx, mul(x, x))) {           int yp = deg - xp;           long long maxy = mysqrt(m - x * x);           ans = add(ans, mul(mul(p[deg][xp], c[deg]), mul(pwx, s[maxy][yp * 2])));         }       }     }     ans = mul(ans, pwr(6, mod - 2));     cout << ans <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   vector<int> V[20005];   int a[1000005], b[1000005];   bool cmp1(int x, int y) { return b[x] < b[y]; }   bool cmp2(int x, int y) { return b[x] > b[y]; }   int main() {     int n;     scanf( %d , &n);     for (int i = 1; i <= n; i++) {       scanf( %d , &a[i]), scanf( %d , &b[i]);       V[a[i] / 1000].push_back(i);     }     for (int i = 0; i <= 1000; i++) {       if (i % 2)         sort(V[i].begin(), V[i].end(), cmp1);       else         sort(V[i].begin(), V[i].end(), cmp2);       for (int j = 0; j < V[i].size(); j++) printf( %d  , V[i][j]);     }     cout << endl;   }
#include <bits/stdc++.h>   using namespace std;   int l, r;   string s;   bool b_occured[10];   bool judge() {     memset(b_occured, 0, sizeof(b_occured));     bool ret = false;     for (int i = 0; i < s.length(); i++) {       if (b_occured[s[i] -  0 ] == false)         b_occured[s[i] -  0 ] = true;       else {         ret = true;       }     }     return ret;   }   int main() {     cin >> l >> r;     s = to_string(l);     while (judge()) {       l++;       s = to_string(l);     }     if (l <= r)       cout << l <<   n ;     else       cout <<  -1 n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int a[100000];   void solve() {     int i, j, n;     cin >> n;     for (int i = 1; i <= n; i++) cin >> a[i];     bool ok = 0;     for (int i = 2; i <= n; i++)       if (a[i] != a[i - 1]) ok = 1;     if (!ok) {       cout <<  NO             <<   n ;       return;     }     map<int, int> M;     int minc = 100000;     for (int i = 1; i <= n; i++) {       M[a[i]]++;     }     for (int i = 1; i <= n; i++) {       if (M[a[i]] < minc) {         minc = M[a[i]];       }     }     int root = -1;     int val = -1;     for (int i = 1; i <= n; i++) {       if (M[a[i]] == minc) {         root = i;         val = a[i];         break;       }     }     vector<pair<int, int>> edge;     int last;     vector<int> free;     for (int i = 1; i <= n; i++) {       if (a[i] != val) {         edge.push_back({root, i});         free.push_back(i);       }     }     vector<int> same;     for (int i = 1; i <= n; i++) {       if (i != root && a[i] == val) {         same.push_back(i);       }     }     for (int i = 0; i < same.size(); i++) {       edge.push_back({free[i], same[i]});     }     cout <<  YES           <<   n ;     for (int i = 0; i < edge.size(); i++)       cout << edge[i].first <<     << edge[i].second <<   n ;     return;   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     int t;     cin >> t;     while (t--) {       solve();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <typename T>   inline void Read(T &n) {     char ch;     bool flag = false;     while (!isdigit(ch = getchar()))       if (ch ==  - ) flag = true;     for (n = ch ^ 48; isdigit(ch = getchar());          n = (n << 1) + (n << 3) + (ch ^ 48))       ;     if (flag) n = -n;   }   const int MAXN = 100005;   struct node {     int son[26], fa, len, sz;   } t[MAXN << 1];   int node_cnt = 1;   int prv = 1;   inline void insert(int v) {     int x = ++node_cnt;     t[x].len = t[prv].len + 1;     t[x].sz = 1;     while (prv and !t[prv].son[v]) t[prv].son[v] = x, prv = t[prv].fa;     if (!prv)       t[x].fa = 1;     else {       int p = t[prv].son[v];       if (t[p].len == t[prv].len + 1)         t[x].fa = p;       else {         int new_p = ++node_cnt;         t[new_p].len = t[prv].len + 1;         t[new_p].fa = t[p].fa;         t[p].fa = t[x].fa = new_p;         copy(t[p].son, t[p].son + 26, t[new_p].son);         while (prv and t[prv].son[v] == p) t[prv].son[v] = new_p, prv = t[prv].fa;       }     }     prv = x;   }   char s[MAXN];   int S[MAXN], id[MAXN << 1];   int main() {     int T;     Read(T);     while (T--) {       scanf( %s , s + 1);       int n = strlen(s + 1);       prv = node_cnt = 1;       memset(t, 0, sizeof t);       memset(S, 0, sizeof S);       for (register int i = 1; i <= n; i++) insert(s[i] -  a );       for (register int i = 1; i <= node_cnt; i++) S[t[i].len]++;       for (register int i = 1; i <= n; i++) S[i] += S[i - 1];       for (register int i = 1; i <= node_cnt; i++) id[S[t[i].len]--] = i;       for (register int i = node_cnt; i; i--) t[t[id[i]].fa].sz += t[id[i]].sz;       long long ans = 0;       for (register int i = 2; i <= node_cnt; i++)         ans += 1ll * t[i].sz * t[i].sz * (t[i].len - t[t[i].fa].len);       printf( %lld n , ans);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long int n;     cin >> n;     vector<pair<long int, long int> > vec;     for (long int i = 1; i <= n; i++) {       long int a, b;       cin >> a >> b;       vec.push_back({a, b});     }     long int count = 1;     long int limit = vec[0].first;     for (long int i = 1; i <= n - 2; i++) {       if (vec[i].first - vec[i].second > limit) {         count++;         limit = vec[i].first;       } else if (vec[i].first + vec[i].second < vec[i + 1].first) {         count++;         limit = vec[i].first + vec[i].second;       } else {         limit = vec[i].first;       }     }     if (n >= 2) count++;     cout << count << endl;   }
#include <bits/stdc++.h>   template <class T>   bool chmax(T &a, const T &b) {     if (a < b) {       a = b;       return 1;     }     return 0;   }   template <class T>   bool chmin(T &a, const T &b) {     if (b < a) {       a = b;       return 1;     }     return 0;   }   using namespace std;   const double eps = 1e-10;   int sgn(double x) { return (x > eps) - (x < -eps); }   int cmp(double x, double y) { return sgn(x - y); }   struct P {     double x, y, k;     P() : x(0), y(0) {}     P(double a, double b) : x(a), y(b) {}     void in() { scanf( %lf%lf , &x, &y); }     P operator+(const P &a) const { return P(x + a.x, y + a.y); }     P operator-(const P &a) const { return P(x - a.x, y - a.y); }     P operator*(const double &a) const { return P(x * a, y * a); }     P operator/(const double &a) const { return P(x / a, y / a); }     double norm2() { return x * x + y * y; }   } p[1000 + 5];   int main() {     int n;     scanf( %d , &n);     for (int i = 1; i <= n; i++) {       int a, b, c, d;       scanf( %d%d%d%d , &a, &b, &c, &d);       p[i] = P((double)a / b, (double)c / d);       p[i] = p[i] / p[i].norm2();     }     vector<P> pt;     for (int i = 1; i <= n; i++)       for (int j = 1; j <= i - 1; j++) {         P mid = (p[i] + p[j]) / 2, tmp = p[i] - p[j];         mid.k = sgn(tmp.x) == 0 ? 1e100 : tmp.y / tmp.x;         pt.push_back(mid);       }     sort(pt.begin(), pt.end(), [](P a, P b) {       if (cmp(a.x, b.x)) return cmp(a.x, b.x) < 0;       if (cmp(a.y, b.y)) return cmp(a.y, b.y) < 0;       return a.k < b.k;     });     int N = pt.size();     long long ans = 0;     for (int l = 0, r; l < N; l = r) {       for (r = l;            r < N && cmp(pt[r].x, pt[l].x) == 0 && cmp(pt[r].y, pt[l].y) == 0; r++)         ;       int c = 2, ways = 1;       for (int i = l + 1; i <= r; i++) {         if (i < r && cmp(pt[i].k, pt[i - 1].k) == 0)           c++;         else           ways = 1ll * ways * c % 1000000007, c = 2;       }       ans = (ans + ways - 1 - (r - l) + 1000000007) % 1000000007;     }     printf( %lld n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MOD = 1e9 + 7;   void add(int& x, int y) { ((x += y) >= MOD) && (x -= MOD); }   void sub(int& x, int y) { add(x, -y + MOD); }   int mul(int x, int y) { return x * 1ll * y % MOD; }   int mpow(int a, int p) {     int res = 1;     for (; p > 0; p >>= 1, a = mul(a, a)) {       if (p & 1) {         res = mul(res, a);       }     }     return res;   }   const int MAXN = 50 + 10;   int mem_inv[MAXN];   int inv(int x) {     int& y = mem_inv[x];     if (y) {       return y;     }     y = mpow(x, MOD - 2);     assert(mul(x, y) == 1);     return y;   }   int n, m;   bool read() {     if (scanf( %d%d , &n, &m) < 2) {       return 0;     }     n += 2;     return 1;   }   int dp2[MAXN][MAXN];   int dp[MAXN][MAXN];   int dp_big[MAXN][MAXN][MAXN][MAXN];   int binom(int n, int k) {     assert(k);     add(n, k - 1);     int ans = 1;     for (int i = 0; i < int(k); ++i) {       int cur_n = n;       sub(cur_n, i);       ans = mul(ans, cur_n);       ans = mul(ans, inv(i + 1));     }     return ans;   }   int calc_dp(int, int);   int calc_dp2(int, int);   int calc_dp_big(int, int, int, int);   int calc_dp2(int n, int m) {     if (n < 3) {       return 0;     }     int& mem = dp2[n][m];     if (mem != -1) {       return mem;     }     int ans = 0;     for (int n_left = 2; n_left < n; ++n_left) {       const int n_right = n - n_left + 1;       for (int m_right = m; m_right < MAXN; ++m_right) {         add(ans, mul(calc_dp(n_left, m), calc_dp(n_right, m_right)));       }       for (int m_left = m + 1; m_left < MAXN; ++m_left) {         add(ans, mul(calc_dp(n_left, m_left), calc_dp(n_right, m)));       }     }     return (mem = ans);   }   int calc_dp_big(int n, int m, int n1, int m1) {     if (n < 2) {       return 0;     }     if (n == 2) {       return (m == 0);     }     if (m <= 0 || n1 < 3) {       return 0;     }     assert(m1 >= 0);     int& mem = dp_big[n][m][n1][m1];     if (mem != -1) {       return mem;     }     int new_n1 = n1;     int new_m1 = m1 - 1;     if (new_m1 == -1) {       new_n1--;       new_m1 = MAXN - 1;     }     int ans = 0;     for (int cnt = 0; (n1 - 2) * cnt + 2 <= n && m1 * cnt <= m; ++cnt) {       int cur = cnt ? binom(calc_dp2(n1, m1), cnt) : 1;       int will = calc_dp_big(n - (n1 - 2) * cnt, m - m1 * cnt, new_n1, new_m1);       add(ans, mul(cur, will));     }     return (mem = ans);   }   int calc_dp(int n, int m) {     int& mem = dp[n][m];     if (mem != -1) {       return mem;     }     int ans = calc_dp_big(n, m - 1, MAXN - 1, MAXN - 1);     return (mem = ans);   }   int solve() {     memset(dp2, -1, sizeof dp2);     memset(dp, -1, sizeof dp);     memset(dp_big, -1, sizeof dp_big);     return calc_dp(n, m);   }   int main() {     while (read()) {       printf( %d n , solve());     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long int parent[26];   long long int find(long long int x) {     if (x == parent[x]) return x;     return parent[x] = find(parent[x]);   }   void merge(long long int x, long long int y) { parent[y] = x; }   signed main() {     long long int n;     cin >> n;     for (long long int i = 0; i < 26; i++) parent[i] = i;     string a, b;     cin >> a >> b;     vector<pair<char, char>> diff;     for (long long int i = 0; i < n; i++) {       long long int x = a[i] -  a , y = b[i] -  a ;       long long int u = find(x), v = find(y);       if (u != v) {         merge(u, v);         diff.push_back(make_pair(a[i], b[i]));       }     }     cout << diff.size() << endl;     for (auto x : diff) cout << x.first <<     << x.second << endl;   }
#include <bits/stdc++.h>   using namespace std;   vector<int> adj[200010], adjr[200010];   int dist[200010], n, m, nop[200010], minp, maxp;   void BFS(int scr) {     queue<int> q;     q.push(scr);     dist[scr] = 1;     nop[scr] = 0;     while (!q.empty()) {       int u = q.front();       q.pop();       for (long long i = 0; i < adj[u].size(); i++) {         if (dist[adj[u][i]] == dist[u] + 1) nop[adj[u][i]]++;         if (!dist[adj[u][i]]) {           dist[adj[u][i]] = dist[u] + 1;           q.push(adj[u][i]);           nop[adj[u][i]] = 1;         }       }     }   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     ;     int t = 1;     while (t--) {       cin >> n >> m;       for (long long i = 0; i < m; i++) {         int a, b;         cin >> a >> b;         adj[b].push_back(a);         adjr[a].push_back(b);       }       int k;       cin >> k;       int path[k + 1];       for (long long i = 1; i <= k; i++) cin >> path[i];       BFS(path[k]);       for (long long i = 1; i <= k - 1; i++) {         minp += dist[path[i]] < dist[path[i + 1]] + 1;         for (int j = 0; j < adjr[path[i]].size(); j++) {           if (adjr[path[i]][j] != path[i + 1] &&               dist[path[i]] == dist[adjr[path[i]][j]] + 1) {             maxp += 1;             break;           }         }       }       cout << minp <<     << maxp;     }   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 1e5 + 5;   const long long mod = 1e9 + 7;   int n, c[505], d[505][505], fa[505], a[505];   long long dp[505][505], comb[505][505];   int Find(int x) { return x == fa[x] ? x : fa[x] = Find(fa[x]); }   void Union(int u, int v) {     int x = Find(u);     int y = Find(v);     if (x != y) fa[x] = y;   }   int is(int i, int j) {     long long x = 1LL * a[i] * a[j];     long long y = sqrt(1.0 * x);     if (y * y == x) return 1;     return 0;   }   int main() {     for (int j = 0; j < 505; j++) comb[0][j] = 0;     for (int i = 0; i < 505; i++) comb[i][0] = 1;     for (int i = 1; i < 505; i++)       for (int j = 1; j < 505; j++)         comb[i][j] = (comb[i - 1][j - 1] + comb[i - 1][j]) % mod;     scanf( %d , &n);     for (int i = 1; i <= n; i++) scanf( %d , &a[i]);     memset(d, 0, sizeof(d));     for (int i = 1; i <= n; i++) {       for (int j = 1; j <= n; j++) {         if (i == j) continue;         if (is(i, j)) d[i][j] = 1;       }     }     for (int k = 1; k <= n; k++)       for (int i = 1; i <= n; i++)         if (d[i][k])           for (int j = 1; j <= n; j++) d[i][j] = d[i][j] || d[k][j];     for (int i = 1; i <= n; i++) fa[i] = i;     for (int i = 1; i <= n; i++) {       for (int j = 1; j <= n; j++) {         if (i == j) continue;         if (d[i][j]) Union(i, j);       }     }     vector<int> g[505];     for (int i = 1; i <= n; i++) g[Find(i)].push_back(i);     int cnt = 0;     for (int i = 1; i <= n; i++)       if (g[i].size() != 0) c[++cnt] = g[i].size();     int N = cnt;     dp[0][0] = 1;     int all = 1;     for (int x = 1; x <= N; x++) {       for (int ij = 1; ij <= c[x]; ij++) {         for (int y = 0; y <= all; y++) {           if (dp[x - 1][y] > 0) {             for (int j = 0; j <= min(ij, y); j++) {               int i = ij - j;               int z = all - y;               long long add = dp[x - 1][y] * comb[y][j] % mod;               add = add * comb[z][i] % mod;               add = add * comb[c[x] - 1][ij - 1] % mod;               dp[x][(y - j) + (c[x] - ij)] =                   (dp[x][(y - j) + (c[x] - ij)] + add) % mod;             }           }         }       }       all += c[x];     }     long long ans = dp[N][0];     for (int i = 1; i <= N; i++) {       long long tmp = 1LL;       for (int j = 1; j <= c[i]; j++) tmp = tmp * j % mod;       ans = ans * tmp % mod;     }     printf( %I64d n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 50 + 5;   int n, a[N][N], tot;   int main() {     cin >> n;     int i = 0, j = n / 2, x, y;     for (int k = 1; k <= n * n; k++) {       if (a[i][j]) {         i = (x + 1) % n;         j = y;       }       a[i][j] = k;       x = i;       y = j;       i = (i - 1 + n) % n;       j = (j + 1) % n;     }     for (int i = 0; i < n; i++)       for (int j = 0; j < n; j++) printf( %d%c , a[i][j],    n [j + 1 == n]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int t;     cin >> t;     while (t--) {       int x, y, a, b;       cin >> x >> y >> a >> b;       if ((y - x) % (a + b) != 0) {         cout << -1 << endl;       } else {         cout << (y - x) / (a + b) << endl;       }     }   }
#include <bits/stdc++.h>   using namespace std;   int mod = 1000000007;   inline int toInt(string s) {     int v;     istringstream sin(s);     sin >> v;     return v;   }   inline long long toll(string s) {     long long v;     istringstream sin(s);     sin >> v;     return v;   }   template <class T>   inline string toString(T x) {     ostringstream sout;     sout << x;     return sout.str();   }   long long memo[5010];   int isStart[5010];   int isEnd[5010];   int vis[5010];   int visss[5010][5010];   vector<int> v;   int n;   long long solve(int i) {     if (i == n) {       return 0;     }     if (memo[i] != -1) {       return memo[i];     }     int viss[5010];     for (int j = 0; j < 5010; j++) {       viss[j] = 0;     }     long long take = 0;     int curEnd = 0;     long long res = solve(i + 1);     if (isStart[i]) {       return memo[i] = res;     } else {       for (int j = i; j < n; j++) {         curEnd = max(isEnd[j], curEnd);         if (!viss[v[j]]) {           take = take ^ v[j];         }         if (visss[i][v[j]] == 1) {           res = max(res, solve(j + 1));           break;         }         viss[v[j]] = 1;         if (j >= curEnd) {           res = max(res, take + solve(j + 1));         }       }       return memo[i] = res;     }   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cin >> n;     for (int i = 0; i < n; i++) {       int t;       cin >> t;       v.push_back(t);     }     for (int i = 0; i < n; i++) {       for (int j = 0; j < i; j++) {         visss[i][v[j]] = 1;       }     }     for (int i = 0; i < n; i++) {       for (int j = i + 1; j < n; j++) {         if (v[j] == v[i]) {           isEnd[i] = j;         }       }     }     for (int i = 0; i < n; i++) {       if (vis[v[i]]) {         isStart[i] = 1;       }       vis[v[i]] = 1;     }     memset(memo, -1, sizeof(memo));     for (int i = 0; i < 5010; i++) {       memo[i] = -1;       vis[i] = 0;     }     cout << solve(0) << endl;     ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long double pi = 3.14159265359;   const int N = 1e5 + 5;   const int MOD = 1e9 + 7;   int c[N];   vector<int> ans;   vector<int> g[N];   int main() {     ios_base::sync_with_stdio(0);     cout.tie(0);     cin.tie(0);     ;     int n;     cin >> n;     int r, p;     for (int i = 0; i < n; ++i) {       cin >> p >> c[i];       --p;       if (p == -2) {         r = i;         continue;       }       c[i] = !c[i];       g[p].push_back(i);     }     for (int i = 0; i < n; ++i) {       if (c[i] || i == r) continue;       bool gd = false;       for (auto &it : g[i]) {         if (c[it]) {           gd = true;           break;         }       }       if (!gd) ans.push_back(i);     }     if (ans.empty())       cout << -1;     else {       for (auto &it : ans) {         cout << it + 1 <<    ;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   #define erorp(x) cout<<#x<< ={ <<(x.F)<<  ,  <<x.S<< } <<endl;   #define print(v,r) f(i,0,r) cout<<v[i]<<   ; cout<<endl;   #define Get(x,y) scanf( %I64d%I64d ,&x,&y);   #define is_bit(x,y) (x%(1<<(y+1))>=(1<<y))   #define eror(x) cout<<#x<< = <<(x)<<endl;   #define f_(i,a,b) for(int i=a;i>=b;i--)   #define Gett(x,y) scanf( %d%d ,&x,&y);   #define f(i,a,b) for(int i=a;i<b;i++)   #define get(x) scanf( %I64d ,&x);   #define gett(x) scanf( %d ,&x);   #define maxm(a,b) a=max(a,b);   #define minm(a,b) a=min(a,b);   #define Add(x,y) x=(x+y)%mod   #define lst(x) x[x.size()-1]   #define sz(x) int(x.size())   #define mp make_pair   #define ll long long   #define pb push_back   #define S second   #define F first       const int N=600,inf=2e9;       int n,m,d[N][N],g[N][N],dist[N][N],mark[N];       void do_it(int x){      f(i,0,n)         f(j,0,n)            minm(d[x][i],g[x][j]+(i-j+n)%n);   }   void bfs(int x){       dist[x][x]=0;       fill(mark,mark+N,0);       f(i,0,n){           int u,e=inf;           f(j,0,n)               if(!mark[j] && dist[x][j]<e)                   u=j,e=dist[x][j];           mark[u]=1;           e=dist[x][u]%n;           f(j,0,n)               minm(dist[x][(j+e)%n],dist[x][u]+d[u][j]);       }   }       int main(){       f(i,0,N)           f(j,0,N)               g[i][j]=inf,d[i][j]=inf,dist[i][j]=inf;     cin>>n>>m;     f(i,0,m){         int u,v,c;         cin>>u>>v>>c;         g[u][v]=c;     }     f(i,0,n)         do_it(i);     f(i,0,n)         bfs(i);     f(i,0,n){         f(j,0,n)             cout<<dist[i][j]<<   ;           cout<<endl;       }   }
#include <bits/stdc++.h>   using namespace std;   const int size = 1e5 + 7;   long long a[size], ans = 2e9, res, val, n, k, i;   int main() {     ios::sync_with_stdio(false);     cin.tie(NULL);     int n, k;     cin >> n >> k;     for (i = 0; i < n; i++) {       cin >> a[i];       if (!i)         val = a[i] % k;       else if (val != a[i] % k) {         cout << -1;         return 0;       }       ans = min(a[i], ans);     }     for (i = 0; i < n; i++) {       val = a[i] - ans;       res += val / k;     }     cout << res;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int gcd(int a, int(b)) {     if (b == 0) return a;     return gcd(b, a % b);   }   int main() {     long long int n;     cin >> n;     for (long long int i = 2; i < sqrt(n) + 1; i++) {       long long int sq = (i * i);       while (n % sq == 0) n /= i;     }     cout << n << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int a[100010];   int b[15];   bool cmp(int x, int y) {     if (x == 100 || y == 100)       return x < y;     else       return x % 10 > y % 10;   }   int main() {     int n, k;     b[0] = 0;     for (int i = 1; i <= 10; i++) b[i] = b[i - 1] + 10;     while (scanf( %d%d , &n, &k) != EOF) {       for (int i = 1; i <= n; i++) scanf( %d , &a[i]);       sort(a + 1, a + n + 1, cmp);       for (int i = 1; i <= n; i++) {         if (k <= 0) break;         if (a[i] % 10 == 0 || a[i] == 100) continue;         int pos = upper_bound(b + 1, b + 11, a[i]) - b;         int num = b[pos] - a[i];         if (num > k) break;         a[i] = b[pos];         k -= num;       }       int ans = 0, sum = 0;       for (int i = 1; i <= n; i++) {         ans += a[i] / 10;         sum += 100 - a[i];       }       printf( %d n , ans + min(sum, k) / 10);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int a1, a2, a3, a4;     cin >> a1 >> a2 >> a3 >> a4;     if (a1 + a2 == a4 + a3) {       cout <<  YES  << endl;     } else if (a1 + a3 == a2 + a4) {       cout <<  YES  << endl;     } else if (a4 + a1 == a3 + a2) {       cout <<  YES  << endl;     } else if (a1 + a2 + a3 == a4) {       cout <<  YES  << endl;     } else if (a1 + a2 + a4 == a3) {       cout <<  YES  << endl;     } else if (a1 + a3 + a4 == a2) {       cout <<  YES  << endl;     } else if (a2 + a3 + a4 == a1) {       cout <<  YES  << endl;     } else {       cout <<  NO  << endl;     }   }