malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   int n;   vector<int> f, s;   int main() {     long long buf, sumf = 0, sums = 0;     int last = 0;     cin >> n;     for (int i = 0; i < n; i++) {       cin >> buf;       if (buf > 0) {         f.push_back(buf);         sumf += buf;         last = 1;       } else {         s.push_back(-buf);         sums -= buf;         last = 2;       }     }     if (sumf > sums)       cout <<  first  << endl;     else if (sumf < sums)       cout <<  second  << endl;     else {       for (int i = 0; i < min(f.size(), s.size()); i++) {         if (f[i] > s[i]) {           cout <<  first  << endl;           return 0;         } else if (f[i] < s[i]) {           cout <<  second  << endl;           return 0;         }       }       if (f.size() > s.size()) {         cout <<  first  << endl;       } else if (f.size() < s.size()) {         cout <<  second  << endl;       } else {         if (last == 1)           cout <<  first  << endl;         else           cout <<  second  << endl;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int color[3], time = 30;     for (int i = 0; i < 3; i++) cin >> color[i];     int maxi = *max_element(color, color + 3);     int index;     if (maxi == color[0]) index = 0;     if (maxi == color[1]) index = 1;     if (maxi == color[2]) index = 2;     int loop = ceil(maxi / 2.0);     for (int i = 0; i < loop - 1; i++) time += 2;     time += loop - 1;     if (index == 2)       time += 2;     else if (index == 1)       time++;     int tmp = index;     if ((maxi - 1) % 2 != 0) {       if (maxi - 1 == color[0]) tmp = 0;       if (maxi - 1 == color[1]) tmp = 1;       if (maxi - 1 == color[2]) tmp = 2;       if (tmp - index > 0) time += tmp - index;     }     cout << time;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.precision(10);     cout << fixed;     int base;     cin >> base;     string s;     cin >> s;     vector<long long> dp(s.size() + 1);     dp[0] = 0;     long long MAX = 1e18;     for (int i = 0; i < s.size(); i++) {       dp[i + 1] = MAX;       for (int j = 0; j <= i; j++) {         long long number = 0;         bool b = true;         for (int k = j; k <= i; k++) {           if (k == j && k != i && s[k] ==  0 ) {             b = false;             break;           }           if (number > (MAX +  0  - s[k] + 9) / 10) {             b = false;             break;           }           number = 10 * number + s[k] -  0 ;         }         if (b && number < base) {           if (dp[j] <= (dp[i + 1] - number + base - 1) / base) {             dp[i + 1] = min(dp[i + 1], dp[j] * base + number);           }         }       }     }     cout << dp.back() << endl;     return 0;   }
#include <bits/stdc++.h>   using std::abs;   using std::bitset;   using std::cerr;   using std::cin;   using std::copy;   using std::cout;   using std::endl;   using std::fill;   using std::fixed;   using std::greater;   using std::lower_bound;   using std::map;   using std::max;   using std::min;   using std::next_permutation;   using std::pair;   using std::priority_queue;   using std::queue;   using std::reverse;   using std::rotate;   using std::set;   using std::sort;   using std::string;   using std::swap;   using std::tie;   using std::tuple;   using std::unique;   using std::unordered_map;   using std::unordered_set;   using std::upper_bound;   using std::vector;   int const INF = (int)1e9;   long long const INFL = (long long)1e18;   long double const PI = 3.1415926535897932384626433832795028;   int const N = 100100;   int a[N], c[N];   struct Node {     int ind;     int sz;     int prior;     int ma;     Node *l, *r;     Node* pr;     Node() {}     Node(int ind)         : ind(ind),           sz(1),           prior(rand() | (rand() << 16)),           ma(a[ind]),           l(0),           r(0),           pr(0) {}   };   int size(Node* v) { return v ? v->sz : 0; }   int maxa(Node* v) { return v ? v->ma : -INF; }   void update(Node* v) {     if (v) {       v->sz = 1 + size(v->l) + size(v->r);       v->ma = max({a[v->ind], maxa(v->l), maxa(v->r)});       if (v->l) v->l->pr = v;       if (v->r) v->r->pr = v;     }   }   Node* merge(Node* a, Node* b) {     if (!a) return b;     if (!b) return a;     if (a->prior > b->prior) {       a->r = merge(a->r, b);       update(a);       return a;     } else {       b->l = merge(a, b->l);       update(b);       return b;     }   }   void split(Node* v, int cnt, Node*& l, Node*& r) {     if (!v) {       l = r = NULL;       return;     }     if (size(v->l) >= cnt) {       split(v->l, cnt, l, v->l);       update(v);       r = v;     } else {       split(v->r, cnt - 1 - size(v->l), v->r, r);       update(v);       l = v;     }   }   Node* firstGreater(Node* v, int val) {     while (true) {       if (maxa(v->l) > val) {         v = v->l;       } else if (a[v->ind] < val) {         v = v->r;       } else {         break;       }     }     return v;   }   int getIndex(Node* v) {     int ret = size(v->l);     while (v->pr) {       if (v->pr->r == v) {         ret += 1 + size(v->pr->l);       }       v = v->pr;     }     return ret;   }   void solve() {     int n;     scanf( %d , &n);     for (int i = 0; i < n; ++i) {       scanf( %d%d , a + i, c + i);     }     Node* H = NULL;     for (int i = 0; i < n; ++i) {       Node* cur = new Node(i);       Node *L, *M, *R;       split(H, c[i], L, R);       if (maxa(L) < a[i]) {         H = merge(L, merge(cur, R));       } else {         Node* big = firstGreater(L, a[i]);         int cnt = getIndex(big);         split(L, cnt, L, M);         H = merge(L, merge(cur, merge(M, R)));       }     }     for (int i = 0; i < n; ++i) {       Node* cur;       split(H, size(H) - 1, H, cur);       printf( %d  , cur->ind + 1);     }     puts(  );   }   int main() { solve(); }
#include <bits/stdc++.h>   using namespace std;   bool exitInput = false;   int ntest = 1, itest = 1;   const char* directions[4] = { NE ,  SE ,  SW ,  NW };   const long long Mod = 1000000000LL + 7;   const int maxn = 100 + 2;   const int maxv = 1000000 + 5;   const int maxe = 600000 + 5;   const int root = 1;   int a, n, b;   int isprime[1250002];   int base_prime[10000000 + 1], ans[10000000 + 1];   long long res;   void sieve(int gh) {     int i, j, k, x;     int nBytes = gh / 8 + 1;     isprime[0] = 0xFC;     for (i = 1; i <= nBytes; ++i) {       isprime[i] = 0xFF;     }     for (i = 2; i <= gh; ++i) {       j = i >> 3;       k = i - (j << 3);       if (isprime[j] & (1 << k)) {         for (x = i + i; x <= gh; x += i) {           j = x >> 3;           k = x - (j << 3);           isprime[j] &= ~(1 << k);           base_prime[x] = i;         }         base_prime[i] = i;       }     }   }   int main() {     int i, j, k, t;     scanf( %d %d , &a, &n);     b = a + n - 1;     sieve(b);     res = 0;     ans[1] = 1;     for (i = 2; i <= b; ++i) {       if (base_prime[i] == i) {         ans[i] = i;       } else {         t = j = i / base_prime[i];         k = 0;         while (j % base_prime[i] == 0) {           j /= base_prime[i];           ++k;         }         j = t;         if (k & 1)           ans[i] = ans[j] / base_prime[i];         else           ans[i] = ans[j] * base_prime[i];       }     }     for (i = a; i <= b; ++i) {       res += ans[i];     }     printf( %lld n , res);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long gcd(long long a, long long b) {     if (a % b == 0) return b;     return gcd(b, a % b);   }   void solve() {     int n;     int ans = 0;     cin >> n;     int a[8008];     int b[8008] = {0};     for (int i = 1; i <= n; i++) {       cin >> a[i];       b[i] = b[i - 1] + a[i];     }     if (n < 3) {       cout << 0 << endl;       return;     }     for (int i = 1; i <= n; i++) {       int l = 1, r = 2;       for (; r <= n;) {         if (r > n) {           break;         }         if (r >= i && l <= i) {           l = i + 1;           r = i + 2;           continue;         }         if (b[r] - b[l - 1] < a[i]) {           r++;           continue;         } else if (b[r] - b[l - 1] > a[i]) {           if (r - 1 <= l) {             l++;             r++;           } else {             l++;           }         } else {           ans++;           break;         }       }     }     cout << ans << endl;   }   int main() {     ios::sync_with_stdio(false);     int t;     cin >> t;     while (t--) {       solve();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main(void) {     int i, n;     long long int s;     s = 0;     set<int> x, k;     map<int, int> m, mu;     cin >> n;     int a[n];     for (i = 0; i < n; i++) {       cin >> a[i];       m[a[i]]++;       x.insert(a[i]);     }     for (i = 0; i < n; i++) {       if (k.find(a[i]) == k.end()) {         s += x.size() - 1;         if (m[a[i]] > 1) s++;         k.insert(a[i]);       }       mu[a[i]]++;       if (m[a[i]] == mu[a[i]]) x.erase(a[i]);     }     cout << s;     return 0;   }
#include <bits/stdc++.h>   const int N = 110;   using namespace std;   inline int read() {     int x = 0, f = 1;     char ch = getchar();     while (ch <  0  || ch >  9 ) {       if (ch ==  - ) {         f = -1;       }       ch = getchar();     }     while (ch <=  9  && ch >=  0 ) {       x = (x << 1) + (x << 3) + ch -  0 ;       ch = getchar();     }     return x * f;   }   int n, a[N], cnt;   int minn[N];   bool in_q(int x) {     for (int i = 1; i <= cnt; i++) {       if (x % minn[i] == 0) {         return 1;       }       if (minn[i] % x == 0) {         minn[i] = x;         return 1;       }     }     return 0;   }   int main() {     cin >> n;     for (int i = 1; i <= n; i++) {       cin >> a[i];     }     sort(a + 1, a + 1 + n);     for (int i = 1; i <= n; i++) {       if (!in_q(a[i])) {         minn[++cnt] = a[i];       }     }     cout << cnt << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int read();   const int N = 1.5e5 + 5;   int n, p, k, m, a[N];   vector<pair<int, int> > seg[N << 2], res;   int eq[N << 2];   void puteq(int k, int l, int r, int v) {     eq[k] = v;     seg[k].clear();     seg[k].push_back(make_pair(v, r - l + 1));   }   bool cmp(const pair<int, int> &a, const pair<int, int> &b) {     return a.second > b.second;   }   void pushup(vector<pair<int, int> > &a, vector<pair<int, int> > &b) {     for (int i = (0); i < (b.size()); ++i) a.push_back(b[i]);     sort(a.begin(), a.end());     for (int i = (0); i < (int(a.size()) - 1); ++i)       if (a[i].first == a[i + 1].first)         a[i + 1].second += a[i].second, a[i].second = 0;     sort(a.begin(), a.end(), cmp);     while (a.size() && a.back().second == 0) a.pop_back();     while (a.size() > k) {       for (int i = (k + 1); i >= (1); --i)         a[a.size() - i].second -= a.back().second;       while (a.size() && a.back().second == 0) a.pop_back();     }   }   void pushdown(int k, int l, int r, int mid) {     if (eq[k]) {       puteq((k << 1), l, mid, eq[k]);       puteq(((k << 1) | 1), mid + 1, r, eq[k]);       eq[k] = 0;     }   }   void change(int k, int l, int r, int x, int y, int v) {     if (x <= l && r <= y) return puteq(k, l, r, v);     int mid = l + r >> 1;     pushdown(k, l, r, mid);     if (x <= mid) change((k << 1), l, mid, x, y, v);     if (y > mid) change(((k << 1) | 1), mid + 1, r, x, y, v);     seg[k] = seg[(k << 1)];     pushup(seg[k], seg[((k << 1) | 1)]);   }   vector<pair<int, int> > ans;   void query(int k, int l, int r, int x, int y) {     if (x <= l && r <= y) return pushup(ans, seg[k]);     int mid = l + r >> 1;     pushdown(k, l, r, mid);     if (x <= mid) query((k << 1), l, mid, x, y);     if (y > mid) query(((k << 1) | 1), mid + 1, r, x, y);   }   void build(int k, int l, int r) {     if (l == r) {       seg[k].push_back(make_pair(a[l], 1));       return;     }     int mid = l + r >> 1;     build((k << 1), l, mid), build(((k << 1) | 1), mid + 1, r);     seg[k] = seg[(k << 1)], pushup(seg[k], seg[((k << 1) | 1)]);   }   int main() {     scanf( %d%d%d , &n, &m, &p);     k = 100 / p;     for (int i = (1); i <= (n); ++i) scanf( %d , a + i);     build(1, 1, n);     while (m--) {       static int op, l, r, v;       scanf( %d%d%d , &op, &l, &r);       if (op == 1)         scanf( %d , &v), change(1, 1, n, l, r, v);       else {         ans.clear();         query(1, 1, n, l, r);         printf( %d  , int(ans.size()));         for (int i = (0); i < (ans.size()); ++i) printf( %d  , ans[i].first);         puts(  );       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 1e6 + 5;   int n, x, bac[maxn], a[maxn], b[maxn];   inline int read() {     char ch = getchar();     int u = 0, f = 1;     while (!isdigit(ch)) {       if (ch ==  - ) f = -1;       ch = getchar();     }     while (isdigit(ch)) {       u = u * 10 + ch - 48;       ch = getchar();     }     return u * f;   }   int main() {     n = read();     x = read();     for (register int i = 1; i <= n; i++) {       a[i] = read();       b[i] = a[i] & x;       if (bac[a[i]]) {         printf( 0 );         return 0;       } else         bac[a[i]] = 1;     }     for (register int i = 1; i <= n; i++) {       bac[a[i]] = 0;       if (bac[b[i]]) {         cout << 1;         return 0;       } else         bac[a[i]] = 1;     }     memset(bac, 0, sizeof(bac));     for (register int i = 1; i <= n; i++) {       if (bac[b[i]]) {         cout << 2;         return 0;       } else         bac[b[i]] = 1;     }     cout << -1;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 100005;   pair<int, int> pt[N], q[2][N];   vector<int> E;   int main() {     int n, m, i, j;     scanf( %d%d , &n, &m);     for (i = 0; i < m; i++) {       scanf( %d%d , &pt[i].first, &pt[i].second);     }     sort(pt, pt + m);     int w[2], pre = 0, now = 1;     w[pre] = 1;     q[pre][0].first = q[pre][0].second = 1;     int pw = 0, ri;     for (i = 0; i < m; pw = pt[i].first, i = ri) {       E.clear();       for (ri = i + 1; ri < m && pt[ri].first == pt[i].first; ri++)         ;       for (j = i; j < ri; j++) E.push_back(pt[j].second);       E.push_back(n + 1);       if (pw != pt[i].first - 1) {         q[pre][0].second = n;         w[pre] = 1;       }       w[now] = 0;       int k = 0, lst = 0;       for (j = 0; j < w[pre]; j++) {         if (q[pre][j].first < E[k] && lst != E[k]) {           q[now][w[now]++] = make_pair(q[pre][j].first, E[k] - 1);           lst = E[k];         }         while (q[pre][j].second > E[k]) {           if (q[pre][j].first < E[k] + 1) q[pre][j].first = E[k] + 1;           k++;           if (q[pre][j].first < E[k] && lst != E[k]) {             q[now][w[now]++] = make_pair(q[pre][j].first, E[k] - 1);             lst = E[k];           }         }       }       if (!w[now]) {         puts( -1 );         return 0;       }       pre = 1 - pre;       now = 1 - now;     }     if (pw < n || q[pre][w[pre] - 1].second == n)       printf( %d n , n + n - 2);     else       puts( -1 );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   bitset<101> b;   int number;   vector<int> primes;   void sieve() {     b.set();     b[0] = 0;     b[1] = 1;     for (int i = 2; i <= number; i++) {       if (b[i] == 1) {         primes.push_back(i);         for (int j = i * i; j <= number; j += i) b[j] = 0;       }     }   }   signed main() {     number = 100;     sieve();     int flag = 0;     for (int i = 0; i < 15; i++) {       cout << primes[i] << endl;       cout << flush;       string s;       cin >> s;       if (s ==  yes ) {         flag++;         if (flag == 1 && primes[i] * primes[i] <= 100) {           cout << primes[i] * primes[i] << endl;           cin >> s;           if (s ==  yes ) {             flag++;             break;           }         }       }       if (flag >= 2) break;     }     if (flag >= 2)       cout <<  composite ;     else       cout <<  prime ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 300000 + 10;   struct Node {     int x, y;     Node(int x, int y) : x(x), y(y) {}     bool operator<(const Node& rhs) const {       return x < rhs.x || (x == rhs.x && y < rhs.y);     }   };   int n, m, size[N], color[N], col = 1;   vector<int> G[N], grp[N];   map<int, int> toid;   map<vector<int>, int> id;   map<Node, int> check;   void dfs(int u) {     color[u] = col++;     for (int v : grp[u])       if (!color[v]) dfs(v);   }   int main() {     std::ios_base::sync_with_stdio(false);     cin.tie(0);     cin >> n >> m;     for (int i = 0; i < n; i++) G[i].push_back(i);     int x, y;     for (int i = 0; i < m; i++) {       cin >> x >> y;       x--;       y--;       G[x].push_back(y);       G[y].push_back(x);     }     m = 0;     for (int i = 0; i < n; i++) {       sort(G[i].begin(), G[i].end());       if (id.count(G[i]))         toid[i] = id[G[i]];       else {         id[G[i]] = m;         toid[i] = m++;       }     }     for (int i = 0; i < n; i++)       for (int u : G[i])         if (toid[i] != toid[u] && !check.count(Node(toid[i], toid[u]))) {           grp[toid[i]].push_back(toid[u]);           grp[toid[u]].push_back(toid[i]);           check[Node(toid[i], toid[u])] = 1;           check[Node(toid[u], toid[i])] = 1;         }     for (int i = 0; i < m; i++)       if (grp[i].size() >= 3) {         cout <<  NO  << endl;         return 0;       }     for (int i = 0; i < m; i++)       if (!color[i] && ((grp[i].size() == 1) || grp[i].size() == 0)) {         dfs(i);         col++;       }     for (int i = 0; i < m; i++)       if (!color[i]) {         cout <<  NO  << endl;         return 0;       }     cout <<  YES  << endl;     for (int i = 0; i < n; i++) cout << color[toid[i]] <<    ;     cout << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int GCD(int a, int b) {     if (a == 0)       return b;     else       return GCD(b % a, a);   }   int main() {     int v[2], n, i = 0;     cin >> v[0] >> v[1] >> n;     while (n >= 0) {       int k = GCD(n, v[i]);       n -= k;       i = !i;     }     cout << i << endl;   }
#include <bits/stdc++.h>   using namespace std;   const int max_n = 105;   int n;   int a[max_n];   int main() {     scanf( %d , &n);     for (int i = 0; i < n; i++) scanf( %d , &a[i]);     vector<int> V;     sort(a, a + n);     for (int nb = 1; nb <= n; nb++) {       V.clear();       for (int i = 0; i < nb; i++) V.push_back(a[n - i - 1]);       bool pos = 1;       for (int i = n - nb - 1; i >= 0; i--) {         int mx = 0, mj = 0;         for (int j = 0; j < nb; j++)           if (mx < V[j]) {             mx = V[j];             mj = j;           }         if (mx > 0) {           V[mj] = min(V[mj] - 1, a[i]);         } else           pos = 0;       }       if (pos) {         printf( %d n , nb);         return 0;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 5e3 + 2, M = 1e5 + 5;   int n, m, k, par[N];   vector<int> vec;   struct edge {     int u, v, i;     long double w;   } e[M];   int getPar(int u) { return ~par[u] ? par[u] = getPar(par[u]) : u; }   bool check(double x) {     for (int i = 0; i < m; i++) e[i].w += (!e[i].u || !e[i].v) * x;     memset(par, -1, sizeof par);     sort(e, e + m,          [](edge x, edge y) { return x.w != y.w ? x.w < y.w : x.i < y.i; });     int cnt = 0;     for (int i = 0, x, y; i < m; i++)       if ((x = getPar(e[i].u)) ^ (y = getPar(e[i].v))) {         par[x] = y;         vec.push_back(e[i].i);         cnt += (!e[i].u || !e[i].v);       }     for (int i = 0; i < m; i++) e[i].w -= (!e[i].u || !e[i].v) * x;     if (cnt == k) {       cout << n - 1 << endl;       for (int x : vec) cout << x + 1 <<    ;       exit(0);     }     vec.clear();     return cnt < k;   }   int main() {     ios_base::sync_with_stdio(0), cin.tie(0);     cin >> n >> m >> k;     for (int i = 0; i < m; i++) {       cin >> e[i].u >> e[i].v >> e[i].w;       e[i].u--, e[i].v--, e[i].i = i;     }     for (double l = -1e9, r = 1e9, i = 0; i < 100; i++) {       double mid = (l + r) / 2;       (check(mid) ? r : l) = mid;     }     cout << -1 << endl;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 3e5 + 10;   struct row {     long long base, limit;     row(long long t = 0, long long d = 0) : base(t + d), limit(t) {}     long long push(long long t) const {       return t <= limit ? base : base + (t - limit);     }     row operator*(const row &o) const {       row ans;       ans.base = o.push(base);       ans.limit = limit;       if (o.limit > base) ans.limit += o.limit - base;       return ans;     }   };   struct query {     char op;     int t, d;   } qs[N];   row ZERO(0, 0);   row st[1 << 20];   vector<int> ts;   int sz;   void init() {     for (int i = sz - 1; i >= 1; i--) st[i] = st[i + i] * st[i + i + 1];   }   void upd(int t, int d) {     int pos = lower_bound(ts.begin(), ts.end(), t) - ts.begin();     int u = sz + pos;     st[u] = row(t, d);     while (u > 1) {       u /= 2;       st[u] = st[u + u] * st[u + u + 1];     }   }   void del(int t) {     int pos = lower_bound(ts.begin(), ts.end(), t) - ts.begin();     int u = sz + pos;     st[u] = ZERO;     while (u > 1) {       u /= 2;       st[u] = st[u + u] * st[u + u + 1];     }   }   long long query(long long t) {     int l = 0, r = upper_bound(ts.begin(), ts.end(), t) - ts.begin();     l += sz;     r += sz;     auto L = ZERO, R = ZERO;     while (l < r) {       if (l & 1) L = L * st[l++];       if (r & 1) R = st[--r] * R;       l /= 2;       r /= 2;     }     return max(0LL, (L * R).push(0) - t);   }   int main() {     int q;     cin >> q;     for (int i = 0; i < q; i++) {       cin >> qs[i].op >> qs[i].t;       if (qs[i].op ==  + ) {         cin >> qs[i].d;         ts.push_back(qs[i].t);       }     }     sort(ts.begin(), ts.end());     ts.erase(unique(ts.begin(), ts.end()), ts.end());     sz = ts.size();     while (sz & (sz - 1)) sz++;     fill_n(st, sz, ZERO);     for (int i = 0; i < q; i++) {       auto qi = qs[i];       if (qi.op ==  + )         upd(qi.t, qi.d);       else if (qi.op ==  - ) {         auto prev = qs[qi.t - 1];         del(prev.t);       } else         cout << query(qi.t) <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   char B[1 << 15], *S = B, *T = B;   using namespace std;   int n, k, ans = 2147483647;   bool u[1001];   int f[2][250001];   inline int read() {     int x = 0;     char ch =         (S == T && (T = (S = B) + fread(B, 1, 1 << 15, stdin), S == T) ? EOF                                                                        : *S++);     while (ch <  0  || ch >  9 )       ch = (S == T && (T = (S = B) + fread(B, 1, 1 << 15, stdin), S == T) ? EOF                                                                           : *S++);     while (ch >=  0  && ch <=  9 ) {       x = x * 10 + ch -  0 ;       ch = (S == T && (T = (S = B) + fread(B, 1, 1 << 15, stdin), S == T) ? EOF                                                                           : *S++);     }     return x;   }   int min(int x, int y) { return x < y ? x : y; }   int main() {     n = read(), k = read();     for (register int i = 1; i <= k; i++) u[read()] = 1;     if (u[n]) {       puts( 1 );       return 0;     }     memset(f, 127 / 2, sizeof(f));     f[0][0] = f[1][0] = 0;     for (register int i = n + 1; i <= 1000; ++i)       if (u[i])         for (register int j = i - n; j <= 250000; ++j)           if (f[0][j - i + n] < 1000000000)             f[0][j] = min(f[0][j], f[0][j - i + n] + 1);     for (register int i = 0; i < n; ++i)       if (u[i])         for (register int j = n - i; j <= 250000; ++j)           if (f[1][j - n + i] < 1000000000)             f[1][j] = min(f[1][j], f[1][j - n + i] + 1);     for (register int i = 1; i <= 250000; i++)       if (f[0][i] < 1000000000 && f[1][i] < 1000000000)         ans = min(ans, f[0][i] + f[1][i]);     printf( %d , ans == 2147483647 ? -1 : ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     cin >> n;     long long k = 0;     for (int i = 1; i < n + 1; i++) {       long long h = i * i;       for (int j = 1; j < i; j++) {         double e = pow(h - j * j, 0.5);         if ((int)e == e) {           k++;         }       }     }     cout << k / 2 << endl;   }