malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   const long double pi = 3.14159265359;   template <typename T>   T abs(T x) {     return x > 0 ? x : -x;   }   template <typename T>   T sqr(T x) {     return x * x;   }   template <typename T>   void chmin(T &x, T y) {     x = min(x, y);   }   template <typename T>   void chmax(T &x, T y) {     x = max(x, y);   }   template <typename U, typename V>   ostream &operator<<(ostream &s, const pair<U, V> &x) {     s <<  (  << x.first <<  ,   << x.second <<  ) ;     return s;   }   template <typename U>   ostream &operator<<(ostream &s, const vector<U> &x) {     s <<  [ ;     bool was = false;     for (auto it : x) {       if (was) {         s <<  ,  ;       }       was = true;       s << it;     }     s <<  ] ;     return s;   }   const int maxn = 1e5 + 5;   const int inf = 1e9;   char a[2][maxn];   int d[2][maxn];   int main() {     srand(time(NULL));   retry:     int n, k;     scanf( %d %d n , &n, &k);     scanf( %s n , a[0] + 1);     scanf( %s n , a[1] + 1);     queue<pair<int, int>> q;     q.push(make_pair(0, 1));     fill(d[0], d[0] + maxn, inf);     fill(d[1], d[1] + maxn, inf);     d[0][1] = 0;     auto yes = []() {       cout <<  YES  << endl;       exit(0);     };     while (!q.empty()) {       int s = q.front().first;       int v = q.front().second;       q.pop();       if (v + k > n) {         yes();       }       if (a[s][v + 1] ==  -  && d[s][v + 1] == inf) {         d[s][v + 1] = d[s][v] + 1;         q.push(make_pair(s, v + 1));       }       if (v - 1 > 0 && a[s][v - 1] ==  -  && v - 1 > d[s][v] + 1 &&           d[s][v - 1] == inf) {         d[s][v - 1] = d[s][v] + 1;         q.push(make_pair(s, v - 1));       }       if (a[1 - s][v + k] ==  -  && d[1 - s][v + k] == inf) {         d[1 - s][v + k] = d[s][v] + 1;         q.push(make_pair(1 - s, v + k));       }     }     cout <<  NO  << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long MOD = 1e9 + 7;   const int MOVX[2] = {0, 1};   const int MOVY[2] = {1, 0};   int n, m;   string fore[501];   vector<pair<int, int> > dep[1001];   int pid[501][501];   long long tbl[2][501][501];   inline bool valid(int x, int y) { return x >= 0 && x < n && y >= 0 && y < m; }   void bfs() {     int d[n][m];     memset(d, -1, sizeof d);     d[0][0] = 0;     queue<pair<int, int> > que;     que.push({0, 0});     dep[0].push_back({0, 0});     pid[0][0] = 0;     while (!que.empty()) {       pair<int, int> p = que.front();       que.pop();       for (int i = 0; i < 2; ++i) {         int x = p.first + MOVX[i];         int y = p.second + MOVY[i];         if (valid(x, y) && d[x][y] == -1) {           d[x][y] = d[p.first][p.second] + 1;           pid[x][y] = dep[d[x][y]].size();           dep[d[x][y]].push_back({x, y});           que.push({x, y});         }       }     }   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(NULL);     cin >> n >> m;     for (int i = 0; i < n; ++i) cin >> fore[i];     bfs();     int id = 0;     int len = n + m - 2;     int h = len >> 1;     for (int i = 0; i < (int)dep[h].size(); ++i)       for (int j = 0; j < (int)dep[len - h].size(); ++j)         tbl[id][i][j] = tbl[!id][i][j] = 0;     for (const pair<int, int> &p : dep[h]) {       if (len & 1) {         for (int i = 0; i < 2; ++i) {           int x = p.first + MOVX[i];           int y = p.second + MOVY[i];           if (valid(x, y) && fore[p.first][p.second] == fore[x][y])             tbl[id][pid[p.first][p.second]][pid[x][y]] = 1;         }       } else {         tbl[id][pid[p.first][p.second]][pid[p.first][p.second]] = 1;       }     }     while (h > 0) {       for (const pair<int, int> &p1 : dep[h])         for (const pair<int, int> &p2 : dep[len - h]) {           long long &r =               tbl[id][pid[p1.first][p1.second]][pid[p2.first][p2.second]];           if (r) {             for (int i = 0; i < 2; ++i)               for (int j = 0; j < 2; ++j) {                 int x1 = p1.first - MOVX[i];                 int y1 = p1.second - MOVY[i];                 int x2 = p2.first + MOVX[j];                 int y2 = p2.second + MOVY[j];                 if (valid(x1, y1) && valid(x2, y2) &&                     fore[x1][y1] == fore[x2][y2]) {                   long long &q = tbl[!id][pid[x1][y1]][pid[x2][y2]];                   q = (q + r) % MOD;                 }               }           }         }       for (int i = 0; i < (int)dep[h].size(); ++i)         for (int j = 0; j < (int)dep[len - h - 1].size(); ++j) tbl[id][i][j] = 0;       id = !id;       --h;     }     cout << tbl[id][0][0] << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   inline void update(long long &x, long long y) { x += y; }   struct Point {     long long x, y;     Point() {}     Point(long long a, long long b) : x(a), y(b) {}     Point operator-(Point b) { return Point(x - b.x, y - b.y); }     bool operator<(const Point &b) const {       return (x != b.x) ? x < b.x : y < b.y;     }   };   inline long long cross(Point x, Point y) { return x.x * y.y - x.y * y.x; }   Point p[305];   int id1[305][305], id2[305][305], cur;   inline bool cmp(int x, int y) {     return cross(p[x] - p[cur], p[y] - p[cur]) > 0;   }   void pre(int n) {     sort(p + 1, p + n + 1);     for (int i = 1; i <= n; i++) {       cur = i;       for (int j = 1; j < i; j++) id1[i][++id1[i][0]] = j;       for (int j = i + 1; j <= n; j++) id2[i][++id2[i][0]] = j;       sort(id1[i] + 1, id1[i] + id1[i][0] + 1, cmp);       sort(id2[i] + 1, id2[i] + id2[i][0] + 1, cmp);     }   }   long long f[305][305][5], g[305][305][5];   long long dp(int n, int s) {     memset(f, 0, sizeof(f));     memset(g, 0, sizeof(g));     for (int i = s + 1; i <= n; i++) f[i][s][1] = g[i][s][1] = 1;     long long ans = 0;     for (int i = s + 1; i <= n; i++) {       long long s1[5], s2[5];       memset(s1, 0, sizeof(s1));       memset(s2, 0, sizeof(s2));       for (int j = s; j < i; j++)         for (int k = 1; k < 5; k++) {           update(s1[k], f[i][j][k]);           update(s2[k], g[i][j][k]);         }       for (int j = 1; j < 5; j++) update(ans, s1[j] * s2[5 - j]);       memset(s1, 0, sizeof(s1));       memset(s2, 0, sizeof(s2));       int r = 1;       for (int j = 1; j <= id2[i][0]; j++) {         int x = id2[i][j];         while (r <= id1[i][0] && cross(p[x] - p[i], p[id1[i][r]] - p[i]) > 0) {           int u = id1[i][r++];           for (int k = 1; k < 4; k++) update(s1[k], f[i][u][k]);         }         for (int k = 1; k < 4; k++) update(f[x][i][k + 1], s1[k]);       }       r = id1[i][0];       for (int j = id2[i][0]; j > 0; j--) {         int x = id2[i][j];         while (r && cross(p[x] - p[i], p[id1[i][r]] - p[i]) < 0) {           int u = id1[i][r--];           for (int k = 1; k < 4; k++) update(s2[k], g[i][u][k]);         }         for (int k = 1; k < 4; k++) update(g[x][i][k + 1], s2[k]);       }     }     return ans;   }   int main() {     int n;     scanf( %d , &n);     for (int i = 1; i <= n; i++) {       int x, y;       scanf( %d%d , &x, &y);       p[i] = Point(x, y);     }     pre(n);     long long ans = 0;     for (int i = 1; i <= n; i++) update(ans, dp(n, i));     printf( %lld n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, m, q, a[200010], b[200010], pos[200010], lst[200010];   int f[200010][30], G[200010][30], L[200010];   int amax(int a, int b) { return a > b ? a : b; }   int main() {     int i, j, cnt, poss, t, l, r;     scanf( %d%d%d , &n, &m, &q);     for (i = 1; i <= n; i++) {       scanf( %d , &a[i]);       pos[a[i]] = i;     }     for (i = 1; i <= m; i++) {       scanf( %d , &b[i]);       t = a[pos[b[i]] - 1];       if (!t) t = a[n];       f[i][0] = lst[t];       lst[b[i]] = i;     }     for (i = 1; 1 << i <= n; i++) {       for (j = 1; j <= m; j++) {         f[j][i] = f[f[j][i - 1]][i - 1];       }     }     for (i = 1; i <= m; i++) {       poss = i;       cnt = n - 1;       for (j = 20; j >= 0; j--) {         if (cnt - (1 << j) >= 0) {           cnt -= 1 << j;           poss = f[poss][j];         }       }       G[i][0] = poss;     }     for (j = 1; (1 << j) <= m; j++) {       for (i = 1; i + (1 << j) - 1 <= m; i++) {         G[i][j] = amax(G[i][j - 1], G[i + (1 << (j - 1))][j - 1]);       }     }     L[0] = -1;     for (i = 1; i <= m; i++) L[i] = L[i >> 1] + 1;     for (i = 1; i <= q; i++) {       scanf( %d%d , &l, &r);       cnt = L[r - l + 1];       if (amax(G[l][cnt], G[r - (1 << cnt) + 1][cnt]) >= l)         printf( 1 );       else         printf( 0 );     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int t;     cin >> t;     while (t--) {       int k;       cin >> k;       string s;       cin >> s;       unordered_map<char, int> ourmap, ourmap1;       int flag = 0;       for (int i = 0; i < k; i++) {         if (s[i] ==  1  || s[i] ==  4  || s[i] ==  6  || s[i] ==  8  ||             s[i] ==  9 ) {           flag = s[i] -  0 ;           break;         } else {           ourmap[s[i]]++;           if (ourmap[s[i]] == 1) ourmap1[s[i]] = i + 1;         }       }       if (flag != 0) {         cout <<  1 n ;         cout << flag <<   n ;         continue;       }       cout <<  2 n ;       if (ourmap.count( 2 ) > 0 && ourmap[ 2 ] > 1) {         cout <<  22 n ;       } else if (ourmap.count( 3 ) > 0 && ourmap[ 3 ] > 1) {         cout <<  33 n ;       } else if (ourmap.count( 5 ) > 0 && ourmap[ 5 ] > 1) {         cout <<  55 n ;       } else if (ourmap.count( 7 ) > 0 && ourmap[ 7 ] > 1) {         cout <<  77 n ;       } else if (ourmap.count( 5 ) > 0 && ourmap.count( 2 ) > 0) {         if (ourmap1[ 5 ] < ourmap1[ 2 ])           cout <<  52 n ;         else           cout <<  25 n ;       } else if (ourmap.count( 5 ) > 0 && ourmap.count( 7 ) > 0) {         if (ourmap1[ 5 ] < ourmap1[ 7 ])           cout <<  57 n ;         else           cout <<  75 n ;       } else if (ourmap.count( 2 ) > 0 && ourmap.count( 7 ) > 0) {         if (ourmap1[ 2 ] < ourmap1[ 7 ])           cout <<  27 n ;         else           cout <<  72 n ;       } else if (ourmap.count( 5 ) > 0 && ourmap.count( 3 ) > 0 &&                  ourmap1[ 3 ] < ourmap1[ 5 ]) {         cout <<  35 n ;       } else {         cout <<  32 n ;       }     }   }
#include <bits/stdc++.h>   using namespace std;   const int INF = 1000 * 1000 * 1000;   vector<int> g[100100];   int deg[100100];   bool vis[100100];   void dfs(int v) {     vis[v] = true;     for (int to : g[v])       if (!vis[to]) {         dfs(to);       }   }   int main() {     int N, M;     scanf( %d%d , &N, &M);     for (int i = 0; i < (M); ++i) {       int u, v;       scanf( %d%d , &u, &v);       --u;       --v;       g[u].push_back(v);       g[v].push_back(u);       ++deg[u];       ++deg[v];     }     int q = 0;     for (int i = 0; i < (N); ++i)       if (!vis[i]) {         dfs(i);         ++q;       }     if (q > 1) {       puts( unknown topology );       return 0;     }     sort(deg, deg + N);     if (deg[0] == 1 && deg[1] == 1) {       bool check = true;       for (int i = 2; i < N; ++i)         if (deg[i] != 2) {           check = false;           break;         }       if (check) {         puts( bus topology );         return 0;       }     }     bool check = true;     for (int i = 0; i < (N); ++i)       if (deg[i] != 2) {         check = false;         break;       }     if (check) {       puts( ring topology );       return 0;     }     check = true;     if (deg[N - 1] == N - 1) {       for (int i = 0; i < (N - 1); ++i)         if (deg[i] != 1) {           check = false;           break;         }       if (check) {         puts( star topology );         return 0;       }     }     puts( unknown topology );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long a, b, c;     cin >> a >> b >> c;     long long x = a + b + c;     long long y = 2 * (a + b);     x = min(x, 2 * (a + c));     x = min(x, 2 * (b + c));     cout << min(x, y) << endl;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long q = 1;     while (q--) {       long long n, k;       cin >> n >> k;       long long a[n];       for (long long i = 0; i < n; i++) cin >> a[i];       long long sum = 0, ans;       for (long long i = 0; i < k; i++) sum += a[i];       ans = sum;       long long ind = 1;       long long j = k;       while (j < n) {         sum -= a[j - k];         sum += a[j];         if (sum < ans) {           ans = sum;           ind = j - k + 2;         }         j++;       }       cout << ind << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <class T>   inline bool read(T &ret) {     char c;     int sgn;     if (c = getchar(), c == EOF) return false;     while (c !=  -  && (c <  0  || c >  9 )) c = getchar();     sgn = (c ==  - ) ? -1 : 1;     ret = (c ==  - ) ? 0 : (c -  0 );     while (c = getchar(), c >=  0  && c <=  9 ) ret = ret * 10 + (c -  0 );     ret *= sgn;     return true;   }   inline long long qmul(long long, long long, long long);   inline long long qpow_qmul(long long, long long, long long);   inline long long qpow(long long, long long, long long);   inline long long gcd(long long, long long);   const int N = 1e5 + 10;   const long long INF = -0x3f3f3f3f;   const long long mod = 1e9 + 7;   const double PI = acos(-1.0);   int boy[N], girl[N];   int main() {     int n, m, num, idx, cnt, cnt1;     memset(boy, 0, sizeof(boy));     memset(girl, 0, sizeof(girl));     scanf( %d%d , &n, &m);     scanf( %d , &num);     cnt = num;     for (int i = 0; i < num; i++) scanf( %d , &idx), boy[idx] = 1;     scanf( %d , &num);     cnt1 = num;     for (int i = 0; i < num; i++) scanf( %d , &idx), girl[idx] = 1;     int x, y;     for (int i = 0; i < n * m * max(n, m); i++) {       x = i % n;       y = i % m;       if (boy[x] || girl[y]) {         if (!boy[x]) cnt++;         if (!girl[y]) cnt1++;         boy[x] = 1;         girl[y] = 1;       }       if (cnt == n && cnt1 == m) break;     }     if (cnt == n && cnt1 == m) {       printf( Yes n );     } else {       printf( No n );     }     return 0;   }   inline long long qmul(long long a, long long b, long long mod) {     long long ans = 0, x = a;     while (b) {       if (b & 1) {         ans += x % mod;         ans %= mod;       }       x *= 2;       x %= mod;       b >>= 1;     }     return ans % mod;   }   inline long long qpow_qmul(long long x, long long n, long long mod) {     long long ans = 1, a = x % mod;     while (n) {       if (n & 1) {         ans = qmul(ans, a, mod);         ans %= mod;       }       a = qmul(a, a, mod);       a %= mod;       n >>= 1;     }     return ans;   }   inline long long qpow(long long x, long long n, long long mod) {     long long ans = 1, a = x % mod;     while (n) {       if (n & 1) {         ans *= a % mod;         ans %= mod;       }       a *= a % mod;       a %= mod;       n >>= 1;     }     return ans;   }   inline long long gcd(long long m, long long n) {     return n == 0 ? m : gcd(n, m % n);   }
#include <bits/stdc++.h>   using namespace std;   const int N = 4005;   int n, a[N], sum[N], f[50000005];   int h(int l, int r, int k, int now) {     return ((((l * 4000) + r) * 100 + k) * 2 + now) % 50000000;   }   int dfs(int l, int r, int k, int now) {     if (r - l + 1 < k) return 0;     if (r - l + 1 == k) {       if (now == 0)         return sum[r] - sum[l - 1];       else         return sum[l - 1] - sum[r];     }     if (f[h(l, r, k, now)] != -0x3f3f3f3f) {       return f[h(l, r, k, now)];     }     if (now == 0) {       int count = dfs(l + k, r, k, 1) + sum[l + k - 1] - sum[l - 1];       if (l + k <= r)         count =             max(count, dfs(l + k + 1, r, k + 1, 1) + (sum[l + k] - sum[l - 1]));       f[h(l, r, k, now)] = count;       return count;     } else if (now == 1) {       int count = dfs(l, r - k, k, 0) - (sum[r] - sum[r - k]);       if (l + k <= r)         count =             min(count, dfs(l, r - k - 1, k + 1, 0) - (sum[r] - sum[r - k - 1]));       f[h(l, r, k, now)] = count;       return count;     }   }   signed main() {     cin >> n;     for (register int i = 1; i <= n; i++) cin >> a[i];     for (register int i = 1; i <= n; i++) sum[i] = sum[i - 1] + a[i];     for (register int i = 1; i <= 50000000; i++) f[i] = -0x3f3f3f3f;     cout << dfs(1, n, 1, 0);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n;   int a, b;   vector<int> arr;   vector<vector<int> > dp;   void solve1(string x, int a, int b) {     int n = x.length();     int l = n + 1;     int r = -1;     for (int i = 0; i < n; i++) {       if (x[i] ==  1 ) {         l = min(l, i);         r = max(r, i);       }     }     if (l > r) {       cout << 0 << endl;       return;     }     int ans = a;     int curr = 0;     for (int i = l; i <= r; i++) {       if (x[i] ==  0 )         curr++;       else {         ans += min(a, curr * b);         curr = 0;       }     }     cout << ans << endl;   }   int solve(int idx, int prev, int sz) {     if (idx == sz) {       return prev == 1;     } else if (idx > sz) {       return 0;     }     if (dp[idx][prev] != -1) return dp[idx][prev];     int ans = INT_MAX;     ans = min(ans, solve(idx + 1, 0, sz) + 2 * a);     ans = min(ans, solve(idx + 2, 1, sz) + ((arr[idx] * b) + a) -                        (idx > 0 ? a * (1 - prev) : 0));     return dp[idx][prev] = ans;   }   void testcase(int tc) {     cin >> a >> b;     string x;     cin >> x;     solve1(x, a, b);     return;     n = x.length();     arr.clear();     int l = n + 1, r = -1;     for (int i = 0; i < n; i++) {       if (x[i] ==  1 ) {         l = i;         break;       }     }     for (int i = n - 1; i >= 0; i--) {       if (x[i] ==  1 ) {         r = i;         break;       }     }     if (l > r || l == n + 1 || r == -1) {       cout << 0 << endl;       return;     }     int curr = 0;     for (int i = l; i <= r; i++) {       if (x[i] ==  0 )         curr++;       else {         if (curr > 0) {           arr.push_back(curr);         }         curr = 0;       }     }     int sz = arr.size();     if (sz == 0) {       cout << a << endl;       return;     } else {       dp.clear();       dp.resize(sz + 9, vector<int>(4, -1));       cout << solve(0, 0, sz) << endl;       return;     }   }   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     int T;     cin >> T;     for (int i = 1; i <= T; i++) {       testcase(i);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long n, a, b;   int main() {     cin >> n;     for (int i = 0; i < n; i++) {       cin >> a >> b;       if (a > b) {         cout << b * (b + 1) / 2 << endl;       } else {         cout << a * (a - 1) / 2 + 1 << endl;       }     }   }
#include<bits/stdc++.h>   using namespace std;   #define ll long long   #define mod (ll)1e9+7;   #define test ll t;cin>>t;while(t--)   #define endl   n    #define pb push_back   #define vi vector<int>   #define vvi vector<vi>   #define vl vector<ll>   #define vvl vector<vl>   #define vp vector<pair<int,int>>   #define pf push_front   #define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);   #define scanint(x) int x;cin>>x;   #define scanll(x) ll x;cin>>x;   #define scanstr(str) string str;cin>>str;   #define scanchr(chr) char chr;cin>>chr;   #define all(c) (c).begin(), (c).end()   #define vecread(vec) for(auto &x:vec){cin>>x;}   #define calcTime cerr <<  time taken :   << (float)clock() / CLOCKS_PER_SEC <<   secs  << endl   #define debug(a) cout<<a<<endl;   #define debug2(a,b) cout<<a<<   <<b<<endl;   #define debug3(a,b,c) cout<<a<<   <<b<<   <<c<<endl;   #define joker(V) for(auto X:V)cout<<X<<   ;cout<<endl;   #define papiya(Mp) for(auto X:Mp)cout<<X.first<<   <<X.second<<endl;         void solve(){       scanint(n)       vi arr(n);       vecread(arr);          sort(all(arr));          vvl dp(n, vl(n));          for (size_t g = 0; g < n; g++)       {           for(int i = 0, j = g; j < n; i++, j++){               if(g == 0){                   dp[i][j] = 0;               } else if(g == 1){                   dp[i][j] = abs(arr[i] - arr[j]);               } else {                   dp[i][j] = arr[j] - arr[i] + min(dp[i + 1][j], dp[i][j - 1]);               }           }       }              cout << dp[0][n - 1] << endl;   }      int main()   {       fast       #ifndef ONLINE_JUDGE       freopen( input.txt ,  r , stdin);       #endif          // test       // {           solve();       // }          calcTime;       return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long const INF = (long long)1e9;   long long const INF64 = (long long)4e18;   long long const v10e5 = (long long)100000;   long long const v10e6 = (long long)1000000;   long long const v10e9 = (long long)1000000000;   long long const s10e5 = (long long)100000 + 10;   long long const s10e6 = (long long)1000000 + 10;   long long const s10e9 = (long long)1000000000 + 10;   long long __dummy__;   int main() {     ios_base::sync_with_stdio(0);     long long n, k;     cin >> n >> k;     vector<long long> a(n + 1, 1);     a[n] = 0;     long long max_ = 1;     for (long long(i) = (1); (i) <= (k); ++i) {       for (long long(i) = (1); (i) <= (n); ++i) {         if ((n - i) - a[i] >= max_) {           cout << n - max_ <<    ;           a[i] += max_;         } else {           cout << i + a[i] <<    ;           a[i] = n - i;         }       }       cout << endl;       max_ = a[1];     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   inline int read() {     char c;     int ret = 0, sgn = 1;     do {       c = getchar();     } while ((c <  0  || c >  9 ) && c !=  - );     if (c ==  - )       sgn = -1;     else       ret = c -  0 ;     while ((c = getchar()) >=  0  && c <=  9 ) ret = ret * 10 + (c -  0 );     return sgn * ret;   }   map<int, int> mp;   set<int> s;   int cnt, t, n, arr[120000 + 5], m, store[50];   inline long long fast_pow(int index) {     if (store[index]) return store[index];     long long base = 2, ans = 1, t = index;     while (index) {       if (index & 1) ans *= base;       base *= base;       index /= 2;     }     return store[t] = ans;   }   int main(void) {     n = read();     for (int i = 1; i <= n; i++) {       arr[i] = t = read();       mp[t]++;     }     sort(arr + 1, arr + 1 + n);     m = unique(arr + 1, arr + 1 + n) - arr - 1;     for (int i = 1; i <= m; i++) {       if (s.find(arr[i]) != s.end()) continue;       bool flag = true;       for (int index = 0, k = 0; k <= arr[m]; index++) {         k = fast_pow(index) - arr[i];         if (mp.find(k) != mp.end() && (k != arr[i] || mp[k] >= 2)) {           flag = false;           s.insert(arr[i]);           s.insert(k);           break;         }       }       if (flag) {         cnt += mp[arr[i]];         mp.erase(arr[i]);       }     }     cout << cnt << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   using u128 = __uint128_t;   signed main() {     ios::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     long long t = 1;     while (t--) {       long long n;       cin >> n;       vector<long long> ans(n, 0);       cout <<  ?   << 1 <<     << n << endl;       long long tot;       cin >> tot;       for (long long i = 2; i < n; i++) {         cout <<  ?   << i <<     << n << endl;         long long q;         cin >> q;         ans[i - 2] = tot - q;         tot = q;       }       cout <<  ?   << n - 2 <<     << n - 1 << endl;       long long q;       cin >> q;       ans[n - 2] = q - ans[n - 3];       ans[n - 1] = tot - ans[n - 2];       cout <<  !  ;       for (long long i : ans) cout << i <<    ;       exit(0);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 3 * 1e5 + 5;   int main() {     int t;     cin >> t;     double a[1005], b[1005];     for (int i = 1; i <= t; ++i) {       int d;       cin >> d;       if (d < 4 && d > 0) {         a[i] = -1;         b[i] = -1;         continue;       }       double discr = sqrt((d * d - 4 * d) * 1.0);       a[i] = (d + discr) / 2;       b[i] = (d - discr) / 2;     }     for (int i = 1; i <= t; ++i) {       if (a[i] == -1)         cout <<  N n ;       else {         cout <<  Y  ;         printf( %.9f %.9f n , a[i], b[i]);       }     }     return 0;   }