malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   struct node {     int a[4], index;     node() { memset(a, 0, sizeof(a)); }   } no1[100005];   int n;   int ans = 0, flag = 1, indexa, indexb;   vector<pair<int, int> > ve;   map<pair<int, int>, int> mp;   int l = 0;   set<pair<int, int> > se[1000000];   void update(int a, int b, int c, int index) {     set<pair<int, int> >::iterator it;     int pre = mp[make_pair(a, b)];     it = se[pre].end();     if (it != se[pre].begin()) {       it--;       if (min(min(a, b), it->first + c) > ans) {         ans = min(min(a, b), it->first + c);         flag = 2;         indexa = it->second;         indexb = index;       }     }   }   int main() {     scanf( %d , &n);     for (int i = 0; i < n; i++) {       int a, b, c;       scanf( %d%d%d , &no1[i].a[0], &no1[i].a[1], &no1[i].a[2]);       a = no1[i].a[0];       b = no1[i].a[1];       c = no1[i].a[2];       ve.push_back(make_pair(min(a, b), max(a, b)));       ve.push_back(make_pair(min(a, c), max(a, c)));       ve.push_back(make_pair(min(c, b), max(c, b)));       no1[i].index = i + 1;       if (min(no1[i].a[0], min(no1[i].a[1], no1[i].a[2])) > ans) {         ans = min(no1[i].a[0], min(no1[i].a[1], no1[i].a[2]));         indexa = i + 1;       }     }     sort(ve.begin(), ve.end());     mp[ve[0]] = l;     for (int i = 1; i < ve.size(); i++) {       if (ve[i].first != ve[i - 1].first || ve[i].second != ve[i - 1].second) l++;       mp[ve[i]] = l;     }     for (int i = 0; i < n; i++) {       int a = no1[i].a[0];       int b = no1[i].a[1];       int c = no1[i].a[2];       update(min(a, b), max(a, b), c, i + 1);       update(min(a, c), max(a, c), b, i + 1);       update(min(b, c), max(b, c), a, i + 1);       se[mp[make_pair(min(a, b), max(a, b))]].insert(make_pair(c, i + 1));       se[mp[make_pair(min(c, b), max(c, b))]].insert(make_pair(a, i + 1));       se[mp[make_pair(min(a, c), max(a, c))]].insert(make_pair(b, i + 1));     }     printf( %d n , flag);     if (flag == 1) {       printf( %d n , indexa);     } else {       printf( %d %d n , indexa, indexb);     }     return 0;   }
#include <bits/stdc++.h>   #pragma GCC optimize( O2 )   using namespace std;   const int N = 1e6 + 10;   const long long mod = 1e9 + 7;   const long long mod2 = 998244353;   const long long inf = 8e18;   const int LOG = 22;   long long pw(long long a, long long b, long long M) {     return (!b ? 1                : (b & 1 ? (a * pw(a * a % M, b / 2, M)) % M                         : pw(a * a % M, b / 2, M)));   }   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     ;     string s;     cin >> s;     int n = (int)s.size();     long long ans = 0;     for (int l = 0; l < n; l++) {       ans += max(0, n - l - 10);       if (l + 2 > n) continue;       for (int r = l + 2; r < min(l + 10, n); r++) {         bool is_OK = 0;         for (int x1 = l; x1 <= r; x1++) {           for (int x2 = x1 + 1; x2 <= r; x2++) {             if (s[x1] == s[x2] && 2 * x2 - x1 <= r && s[2 * x2 - x1] == s[x1]) {               is_OK = 1;             }           }         }         ans += is_OK;       }     }     cout << ans;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   vector<int> edge[100005];   int visited[100005][2];   vector<int> ans;   int draw = 1;   int visit(int verId, int isPetyaTurn) {     visited[verId][isPetyaTurn] = 1;     if (edge[verId].size() == 0) {       draw = 0;       if (isPetyaTurn == 0) {         ans.push_back(verId);         return 1;       }     }     for (int i = 0; i < edge[verId].size(); ++i) {       int nextVerId = edge[verId][i];       if (visited[nextVerId][1 - isPetyaTurn] == 0 &&           visit(nextVerId, 1 - isPetyaTurn)) {         ans.push_back(verId);         return 1;       }     }     return 0;   }   int canDrawVisited[100005];   int canDraw(int verId, int step) {     if (canDrawVisited[verId] == 1) {       return 1;     }     if (step == 1000000) {       return 1;     }     canDrawVisited[verId] = 1;     for (int i = 0; i < edge[verId].size(); ++i) {       int nextVerId = edge[verId][i];       if (canDraw(nextVerId, step + 1)) {         return 1;       }     }     canDrawVisited[verId] = 0;     return 0;   }   int main() {     int n, m;     scanf( %d%d , &n, &m);     for (int i = 1; i <= n; ++i) {       int nEdge;       scanf( %d , &nEdge);       while (nEdge--) {         int tmp;         scanf( %d , &tmp);         edge[i].push_back(tmp);       }     }     int begVerId;     scanf( %d , &begVerId);     int res = visit(begVerId, 1);     if (draw) {       puts( Draw );     } else if (res) {       puts( Win );       for (int i = ans.size() - 1; i >= 0; --i) {         printf( %d%c , ans[i],    n [i == 0]);       }     } else {       int draw = canDraw(begVerId, 0);       if (draw) {         puts( Draw );       } else {         puts( Lose );       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int inf = 2000000000;   static inline int Rint() {     struct X {       int dig[256];       X() {         for (int i =  0 ; i <=  9 ; ++i) dig[i] = 1;         dig[ - ] = 1;       }     };     static X fuck;     int s = 1, v = 0, c;     for (; !fuck.dig[c = getchar()];)       ;     if (c ==  - )       s = 0;     else if (fuck.dig[c])       v = c ^ 48;     for (; fuck.dig[c = getchar()]; v = v * 10 + (c ^ 48))       ;     return s ? v : -v;   }   template <typename T>   static inline void cmax(T& a, const T& b) {     if (b > a) a = b;   }   template <typename T>   static inline void cmin(T& a, const T& b) {     if (b < a) a = b;   }   struct Pt {     int x, y;   };   int cmp_x_min(const Pt& a, const Pt& b) {     if (a.x != b.x) return a.x < b.x;     return a.y < b.y;   }   Pt data[100005];   int main() {     int n = Rint(), m = Rint();     for (int i = 0; i < m; ++i) data[i].x = Rint(), data[i].y = Rint();     sort(data, data + m, cmp_x_min);     vector<int> last;     last.push_back(1);     last.push_back(1);     int row = 0;     for (int now = 0; now < m;) {       int j = now + 1;       while (j < m && data[j].x == data[now].x) ++j;       if (last.size() && data[now].x > row + 1) {         vector<int> next;         next.push_back(last.front()), next.push_back(n);         last.swap(next);         row = row + 1;       }       const int size = ((int)(last).size());       vector<int> next;       for (int k = now, pos = 0; k <= j; ++k) {         int r = k == j ? n : data[k].y - 1;         int l = k == now ? 1 : data[k - 1].y + 1;         if (l > r) continue;         while (pos < size && last[pos + 1] < l) pos += 2;         if (pos < size) {           if (last[pos] > r) continue;           if (last[pos] <= l) {             next.push_back(l);             next.push_back(r);           } else if (last[pos] <= r) {             next.push_back(last[pos]);             next.push_back(r);           }         }       }       last.swap(next);       row = data[now].x;       now = j;     }     if (last.size() && data[m - 1].x < n) {       vector<int> next;       next.push_back(last.front()), next.push_back(n);       last.swap(next);       row = row + 1;     }     if (last.size()) {       const int size = ((int)(last).size());       if (last[size - 2] <= n && last[size - 1] >= n) {         printf( %d n , 2 * n - 2);         return 0;       }     }     puts( -1 );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int32_t main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     long long a;     cin >> a;     bitset<22> b(a);     long long i, j, k;     long long c = 0;     vector<long long> v;     for (i = 0; i <= 40; i++) {       long long temp = a;       temp++;       if ((a & temp) == 0) {         break;       }       if (i % 2)         a++;       else {         bitset<22> z(a);         for (j = 21; j >= 0; j--) {           if (z[j] == 1) break;         }         for (; j >= 0; j--)           if (z[j] == 0) break;         v.push_back(j + 1);         a = a ^ (long long)(pow(2, j + 1) - 1);       }     }     cout << i << endl;     for (auto g : v) cout << g <<    ;     cout << endl;   }
#include <bits/stdc++.h>   using namespace std;   const int INF = 1e9 + 7;   vector<int> eum;   int w[100005];   int Euler(int num) {     int p = 2, ans = 1;     while (p * p <= num) {       int ct = 1;       while (num % p == 0) {         ct *= p;         num /= p;       }       if (ct > 1) ct = ct / p * (p - 1);       ans *= ct;       p++;     }     if (num > 1) ans *= num - 1;     return ans;   }   long long power(int x, int t, long long m) {     if (t == 0) return 1;     long long cc = power(x, t >> 1, m);     cc = cc * cc % m;     if (t & 1) cc = cc * x % m;     return cc;   }   int gcd(int m, int n) { return n == 0 ? m : gcd(n, m % n); }   int solve(int l, int r, int mid) {     if (l > r) return 1;     if (eum[mid] == 1) return 0;     vector<int> cc;     for (int k = l + 1; k <= r && k <= l + 4; k++) cc.push_back(w[k]);     cc.push_back(1);     for (int k = 0; k < (cc.size()); k++)       if (cc[k] == 1) {         long long cur = 1LL;         for (int j = k - 1; j >= 0; j--) {           if (cc[j] >= 30 || cc[j] >= 4 && cur >= 4) {             cur = 30LL;             break;           }           cur = power(cc[j], cur, 1LL << 62);           if (cur > 30LL) {             cur = 30LL;             break;           }         }         if (cur < 30LL)           return power(w[l], cur, eum[mid]) % eum[mid];         else           return power(w[l], solve(l + 1, r, mid + 1) + eum[mid + 1], eum[mid]);       }   }   int main() {     int n, m, q, x, l, r;     scanf( %d%d , &n, &m);     eum.push_back(m);     while ((x = eum.back()) > 1) eum.push_back(Euler(x));     for (int k = 0; k < (n); k++) scanf( %d , &w[k]);     scanf( %d , &q);     for (int k = 0; k < (q); k++) {       scanf( %d%d , &l, &r);       l--;       r--;       printf( %d n , solve(l, r, 0));     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e5 + 9, M = 998244353;   int dp[2][205][2], n, a[N];   long long sum[2][205][2];   int f(int i, int x, int z) {     if (a[i] > 0 && x != a[i]) return dp[i % 2][x][z] = 0;     if (i == n - 1) return dp[i % 2][x][z] = z;     long long ans = 0, l = 0, r = 200;     i %= 2;     ans = z * (sum[1 - i][x - 1][1] - sum[1 - i][l][1]) % M + dp[1 - i][x][1] +           (sum[1 - i][r][0] - sum[1 - i][x][0]) % M + 2 * M;     return dp[i][x][z] = ans % M;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     long long i, j;     cin >> n;     for (i = 0; i < n; i++) cin >> a[i];     for (i = n - 1; i >= 0; i--)       for (j = 1; j < 201; j++) {         sum[i % 2][j][0] = f(i, j, 0) + sum[i % 2][j - 1][0];         sum[i % 2][j][1] = f(i, j, 1) + sum[i % 2][j - 1][1];       }     cout << sum[0][200][0] % M << endl;     return 0;   }
#include <bits/stdc++.h>   #pragma comment(linker,  /STACK:1024000000,1024000000 )   using namespace std;   const int mxn = 400005, maxnn = 100005;   const int mod = 1e9 + 7;   long long ans;   int n, m, num, cir, r, cnt;   int head[maxnn], que[maxnn];   struct edge {     int to, next;     long long w;   } f[mxn << 2];   long long p[70], circle[mxn], dis[maxnn], dig[2], pw[105];   inline void add(int u, int v, long long w) {     f[++cnt].to = v, f[cnt].w = w, f[cnt].next = head[u], head[u] = cnt;   }   inline void dfs(int u, int fa, long long now) {     dis[u] = now, que[++num] = u;     for (int i = head[u]; i; i = f[i].next) {       int v = f[i].to;       if (v == fa) continue;       if (dis[v] == -1)         dfs(v, u, dis[u] ^ f[i].w);       else         circle[++cir] = dis[u] ^ dis[v] ^ f[i].w;     }   }   inline void init() {     int i, j;     r = 0;     memset(p, 0, sizeof p);     for (i = 1; i <= cir; i++) {       long long x = circle[i];       for (j = 62; j >= 0; j--) {         if (!(x >> j)) continue;         if (!p[j]) {           p[j] = x;           break;         }         x ^= p[j];       }     }     for (j = 0; j <= 62; j++)       if (p[j]) r++;   }   inline void calc() {     init();     int i, j;     for (j = 0; j <= 62; j++) {       bool flag = 0;       dig[0] = dig[1] = 0;       for (i = 1; i <= num; i++) dig[(dis[que[i]] >> j) & 1]++;       for (i = 0; i <= 62; i++)         if ((p[i] >> j) & 1) {           flag = 1;           break;         }       long long now =           (dig[0] * (dig[0] - 1) / 2 + dig[1] * (dig[1] - 1) / 2) % mod;       if (flag) {         if (r) now = now * pw[r - 1] % mod;         now = now * pw[j] % mod;         ans = (ans + now) % mod;       }       now = dig[0] * dig[1] % mod;       if (flag) {         if (r) now = now * pw[r - 1] % mod;       } else         now = now * pw[r] % mod;       now = now * pw[j] % mod;       ans = (ans + now) % mod;     }   }   int main() {     int i, j, u, v;     long long w;     memset(dis, -1, sizeof dis);     pw[0] = 1;     for (j = 1; j <= 100; j++) pw[j] = pw[j - 1] * 2 % mod;     scanf( %d%d , &n, &m);     for (i = 1; i <= m; i++) {       scanf( %d%d%lld , &u, &v, &w);       add(u, v, w), add(v, u, w);     }     for (i = 1; i <= n; i++)       if (dis[i] == -1) {         num = cir = 0;         dfs(i, 0, 0);         calc();       }     printf( %lld , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     long long n;     cin >> n;     vector<long long> x(n);     for (long long i = 0; i < n; i++) cin >> x[i];     unordered_map<int, int> m;     for (auto num : x) {       m[num]++;     }     if (m.size() < 3) {       cout << 0;       return 0;     }     int ans = INT_MAX;     for (auto num : m) {       if (ans > num.second) {         ans = num.second;       }     }     printf( %d n , ans);     vector<vector<int>> v(4);     for (int i = 0; i < n; i++) {       if (x[i] == 1) v[1].push_back(i + 1);       if (x[i] == 2) v[2].push_back(i + 1);       if (x[i] == 3) v[3].push_back(i + 1);     }     for (long long i = 0; i < ans; i++) {       printf( %d %d %d n , v[1][i], v[2][i], v[3][i]);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   struct pokr {     double p1;     double p2;     double len;     pokr(double _p1, double _p2, double _l) : p1(_p1), p2(_p2), len(_l) {}     pokr() { p1 = p2 = len = 0; }   } d[2100][2100];   int x[2100];   int c[2100][2100];   int a[2100];   int b[2100];   double p, q;   int h;   pokr get_ans(int l, int r) {     pokr res;     if (l > r) return pokr(0, 0, 0);     if (l == r) return pokr(p, q, 0);     if (c[l][r]) return d[l][r];     pokr temp = get_ans(l + 1, r);     res.p1 += p / 2;     res.p2 += temp.p2 * p / 2;     res.len += p / 2 * temp.len;     res.len += p / 2 * temp.p1 * min(x[l + 1] - x[l], h);     int next = b[l];     if (next <= r) {       pokr temp = get_ans(next, r);       res.p2 += q / 2 * temp.p2;       res.len += q / 2 * temp.len;       res.len += q / 2 * (x[next - 1] + h - x[l]);       res.len += q / 2 * temp.p1 * min(x[next] - x[next - 1] - h, h);     } else {       res.p2 += q / 2;       res.len += q / 2 * (x[r] - x[l]);     }     temp = get_ans(l, r - 1);     res.p2 += q / 2;     res.p1 += temp.p1 * q / 2;     res.len += q / 2 * temp.len;     res.len += q / 2 * temp.p2 * min(x[r] - x[r - 1], h);     int prev = a[r];     if (prev >= l) {       pokr temp = get_ans(l, prev);       res.p1 += p / 2 * temp.p1;       res.len += p / 2 * temp.len;       res.len += p / 2 * (x[r] - x[prev + 1] + h);       res.len += p / 2 * temp.p2 * min(x[prev + 1] - x[prev] - h, h);     } else {       res.p1 += p / 2;       res.len += p / 2 * (x[r] - x[l]);     }     c[l][r] = 1;     d[l][r] = res;     return res;   }   int main() {     int n;     cin >> n >> h;     cin >> p;     q = 1 - p;     for (int i = 0; i < n; i++) cin >> x[i];     sort(x, x + n);     a[0] = -1;     for (int i = 1; i < n; i++)       if (x[i] - x[i - 1] < h)         a[i] = a[i - 1];       else         a[i] = i - 1;     b[n - 1] = n;     for (int i = n - 2; i >= 0; i--)       if (x[i + 1] - x[i] < h)         b[i] = b[i + 1];       else         b[i] = i + 1;     pokr r = get_ans(0, n - 1);     printf( %.12f , (r.p1 + r.p2) * h + r.len);     return 0;   }
#include <bits/stdc++.h>   #pragma GCC optimize( Ofast,unroll-loops )   #pragma GCC target( avx,avx2,fma )   using namespace std;   template <typename T>   using vc = vector<T>;   template <typename T>   using uset = unordered_set<T>;   template <typename A, typename B>   using umap = unordered_map<A, B>;   template <typename T>   using pq = priority_queue<T>;   template <typename T>   using minpq = priority_queue<T, vc<T>, greater<T>>;   template <typename T>   inline void sort(vc<T>& v) {     sort(v.begin(), v.end());   }   template <typename T, typename Comp>   inline void sort(vc<T>& v, Comp c) {     sort(v.begin(), v.end(), c);   }   using ll = long long;   using ull = unsigned long long;   using pii = pair<ll, ll>;   using vi = vc<ll>;   using vii = vc<pii>;   constexpr char el =   n ;   constexpr char sp =    ;   constexpr ll INF = 0x3f3f3f3f;   constexpr ll LLINF = 0x3f3f3f3f3f3f3f3fLL;   ll xh, yh, xs, ys, n;   inline bool evan(ll a, ll b) { return a < 0 && b > 0 || a > 0 && b < 0; }   signed main() {     ios_base::sync_with_stdio(false);     cin.tie(nullptr);     cout << fixed;     cin >> xh >> yh;     cin >> xs >> ys;     cin >> n;     ll ans = 0;     while (n--) {       ll a, b, c;       cin >> a >> b >> c;       if (evan(a * xh + b * yh + c, a * xs + b * ys + c)) ans++;     }     cout << ans;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 26;   vector<int> kmp;   string txt, pattern;   vector<vector<int> > nxt, dp;   void build() {     kmp.resize(pattern.size() + 10);     kmp[0] = 0;     for (int i = 1, j = 0; i < pattern.size();) {       if (pattern[i] == pattern[j])         kmp[i++] = ++j;       else if (!j)         kmp[i++] = 0;       else         j = kmp[j - 1];     }     nxt.resize(pattern.size() + 10);     for (int i = 0; i < pattern.size(); ++i) nxt[i].resize(N + 10);     for (int j = 0; j < N; ++j) nxt[0][j] = (pattern[0] -  a  == j);     for (int i = 1; i < pattern.size(); ++i)       for (int j = 0; j < N; ++j)         nxt[i][j] = (pattern[i] -  a  == j) ? i + 1 : nxt[kmp[i - 1]][j];     dp.resize(txt.size() + 10);     for (int i = 0; i < dp.size(); ++i) dp[i].resize(pattern.size() + 10);     for (int i = 0; i < dp.size(); ++i)       for (int j = 0; j < dp[i].size(); ++j) dp[i][j] = -1;   }   int solve(const int &i, const int &j) {     if (i == txt.size()) return 0;     if (dp[i][j] != -1) return dp[i][j];     int ans = 0;     if (txt[i] ==  ? ) {       for (int k = 0; k < N; ++k) {         int new_j = nxt[j][k];         if (new_j == pattern.size())           ans = max(ans, 1 + solve(i + 1, kmp[new_j - 1]));         else           ans = max(ans, solve(i + 1, new_j));       }     } else {       int k = txt[i] -  a ;       int new_j = nxt[j][k];       if (new_j == pattern.size())         ans = max(ans, 1 + solve(i + 1, kmp[new_j - 1]));       else         ans = max(ans, solve(i + 1, new_j));     }     return dp[i][j] = ans;   }   int main() {     cin >> txt >> pattern;     build();     printf( %d n , solve(0, 0));     return 0;   }
#include <bits/stdc++.h>   using namespace std;   map<int, int> mp;   set<int> s;   int main(void) {     int q;     scanf( %d , &q);     while (q--) {       mp.clear();       int x;       scanf( %d , &x);       int t = x;       int lim = sqrt(t);       for (int i = 2; i <= lim; i++) {         while (t % i == 0) {           mp[i]++;           t /= i;         }       }       if (1 < t) mp[t]++;       s.clear();       for (int i = 2; i <= lim; i++) {         if (x % i == 0) {           s.insert(i);           s.insert(x / i);         }       }       s.insert(x);       vector<int> rep;       for (auto e : mp) rep.push_back(e.first);       if (rep.size() == 2) {         int mult = 1;         for (auto e : mp) mult *= e.first;         vector<int> ds;         if (mult == x) {           printf( %d  , mult);           for (int p : rep) {             for (int div : s) {               if (div % p == 0) {                 if (div != mult) {                   printf( %d  , div);                 }                 ds.push_back(div);               }             }             for (int e : ds) s.erase(e);             ds.clear();           }           printf(  n1 n );         } else {           printf( %d  , x);           vector<int> ds;           for (int p : rep) {             for (int div : s) {               if (div % p == 0) {                 if (div != mult) {                   if (div != x) {                     printf( %d  , div);                   }                 }                 ds.push_back(div);               }             }             for (int e : ds) s.erase(e);             ds.clear();             if (p != rep.back()) printf( %d  , mult);           }           printf(  n0 n );         }       } else if (rep.size() == 1) {         for (int div : s) {           printf( %d  , div);         }         printf(  n0 n );       } else {         map<int, int> joint;         for (int i = 0; i < rep.size(); i++) {           joint[rep[i] * rep[(i + 1) % rep.size()]] = true;         }         vector<int> ds;         for (int i = 0; i < rep.size(); i++) {           for (int div : s) {             if (div % rep[i] == 0) {               if (joint.count(div) == 0) {                 printf( %d  , div);               }               ds.push_back(div);             }           }           printf( %d  , rep[i] * rep[(i + 1) % rep.size()]);           for (int e : ds) s.erase(e);           ds.clear();         }         printf(  n0 n );       }     }   }
#include <bits/stdc++.h>   using namespace std;   bool isSquare(long long n) {     const long long s = (long long)ceil(sqrt(n));     return (s * s) == n;   }   long long calcCostToSquare(long long n) {     if (isSquare(n)) return 0;     const auto f1 = (long long)ceil(sqrt(n));     const auto f2 = (long long)floor(sqrt(n));     return min((long long)abs(f1 * f1 - n), (long long)abs(f2 * f2 - n));   }   long long calcCostToNonSquare(long long n) {     if (n == 0) return 2;     if (isSquare(n)) return 1;     return 0;   }   int main() {     long long n;     cin >> n;     long long numSquare = 0;     multiset<long long> toMakeSquare;     multiset<long long> toMakeNonSquare;     for (long long i = 0; i < n; ++i) {       long long a;       cin >> a;       if (isSquare(a)) ++numSquare;       toMakeSquare.insert(calcCostToSquare(a));       toMakeNonSquare.insert(calcCostToNonSquare(a));     }     n /= 2;     long long result = 0;     if (numSquare < n) {       auto it = toMakeSquare.upper_bound(0);       while (numSquare < n) {         result += *it;         ++it;         ++numSquare;       }     } else {       auto it = toMakeNonSquare.upper_bound(0);       while (numSquare > n) {         result += *it;         ++it;         --numSquare;       }     }     cout << result << endl;   }
#include <bits/stdc++.h>   using namespace std;   long long num_to_sig(long long x) {     vector<int> v;     while (x > 0) {       v.push_back((x % 10) % 2);       x /= 10;     }     int n = v.size();     long long ret = 0;     for (int i = n - 1; i >= 0; i--) {       ret *= 10;       ret += v[i];     }     return ret;   }   int main() {     int Q;     scanf( %d , &Q);     map<long long, int> cnt;     while (Q--) {       char c;       scanf(  %c , &c);       long long x;       if (c ==  + ) {         scanf( %lld , &x);         cnt[num_to_sig(x)]++;       } else if (c ==  - ) {         scanf( %lld , &x);         cnt[num_to_sig(x)]--;       } else {         scanf( %lld , &x);         printf( %d n , cnt[num_to_sig(x)]);       }     }     return 0;   }