malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   int dp[3000];   bool apare[1010];   int n, k, c;   int main() {     ios_base ::sync_with_stdio(0);     cin >> n >> k;     while (k--) {       cin >> c;       apare[c] = 1;     }     queue<int> q;     vector<int> lungimi;     for (int i(0); i < 1010; i++) {       if (!apare[i]) continue;       int x(n - i + 1500);       dp[x] = 1;       q.push(x);       lungimi.push_back(x - 1500);     }     while (!q.empty()) {       int x(q.front()), t(dp[x]);       q.pop();       for (auto i : lungimi) {         if (x + i >= 0 && x + i < 3000 && !dp[x + i]) {           dp[x + i] = 1 + t;           q.push(x + i);         }       }     }     cout << (dp[1500] ? dp[1500] : -1);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int inf = 1e9;   using namespace std;   const int maxn = 404;   int n, m, k;   int s[103], t[103];   int c[103][103], d[103][103], e[103][103], f[103][103];   struct Edge {     int u, v, c, w, next;     Edge(int u, int v, int c, int w, int next)         : u(u), v(v), c(c), w(w), next(next) {}     Edge() {}   } edge[100005];   int head[maxn], E;   void init() {     memset(head, -1, sizeof(head));     E = 0;   }   void add(int s, int t, int c, int w) {     edge[E] = Edge(s, t, c, w, head[s]);     head[s] = E++;     edge[E] = Edge(t, s, 0, -w, head[t]);     head[t] = E++;   }   int S, T;   int pre[maxn], dis[maxn];   bool vis[maxn];   bool spfa(int s, int t, int n) {     int i, u, v;     for (i = 0; i <= n; i++) dis[i] = inf, pre[i] = -1, vis[i] = false;     queue<int> q;     vis[s] = true;     dis[s] = 0;     q.push(s);     while (!q.empty()) {       u = q.front();       q.pop();       vis[u] = false;       for (i = head[u]; ~i; i = edge[i].next) {         v = edge[i].v;         if (edge[i].c && dis[v] > dis[u] + edge[i].w) {           dis[v] = dis[u] + edge[i].w;           pre[v] = i;           if (!vis[v]) {             vis[v] = true;             q.push(v);           }         }       }     }     if (dis[t] == inf) return 0;     return 1;   }   int ans;   pair<int, int> mcmf(int s, int t, int n) {     int aug, minc = 0, i, maxf = 0;     while (spfa(s, t, n)) {       aug = inf + 1;       for (i = pre[t]; ~i; i = pre[edge[i].u]) aug = min(aug, edge[i].c);       for (i = pre[t]; ~i; i = pre[edge[i].u]) {         edge[i].c -= aug;         edge[i ^ 1].c += aug;       }       maxf += aug;       minc += dis[t] * aug;     }     return make_pair(maxf, minc);   }   int Map[55][55];   void build(int m) {     int i, j;     init();     for (i = 0; i < n; i++)       for (j = 0; j < n; j++) {         if (Map[i][j]) {           add(i, j, Map[i][j], 0);           add(i, j, k, 1);         }       }     add(n, 0, m, 0);   }   int main() {     int i, j;     scanf( %d%d , &n, &k);     for (i = 0; i < n; i++)       for (j = 0; j < n; j++) scanf( %d , &Map[i][j]);     int l = 0, r = 1e9;     while (l <= r) {       int m = (l + r) >> 1;       build(m);       pair<int, int> t = mcmf(n, n - 1, n + 1);       if (t.first == m && t.second <= k) {         l = m + 1;         ans = m;       } else         r = m - 1;     }     printf( %d n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, k;     cin >> n >> k;     string s;     cin >> s;     vector<int> way(s.size());     way[0] = 0;     for (int i = 1; i < (int)s.size(); i++) {       if (s[i] ==  0 )         way[i] = i;       else         way[i] = way[i - 1];     }     int l = 0, r = n - 1;     while (r - l > 1) {       int m = (l + r) / 2;       int cnt = k - 1;       int now = 0;       int last = 0;       while (now < n && cnt > 0) {         now += m;         now = min(now, n - 1);         now = way[now];         cnt--;         last = max(last, now);       }       if (last == n - 1) {         r = m;       } else {         l = m;       }     }     cout << l <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, k;     cin >> n >> k;     string s =   ;     for (int i = 0; i < k; i++) s += char(i + 97);     for (int i = 0; i < n - k; i++) {       s += char(i % k + 97);     }     cout << s << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     cin >> n;     vector<int> v(n);     for (int i = 0; i < n; i++) cin >> v[i];     int i = 0;     vector<int> ans;     ans.push_back(v[0]);     ans.push_back(v[n - 1]);     while (i < n - 3) {       int k = v[i + 1];       int l = v[i + 2];       if (l >= k) {         ans.push_back(l);         i = i + 2;       } else {         ans.push_back(k);         i++;       }     }     int out = *min_element(ans.begin(), ans.end());     cout << out;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long n, m;   struct pt {     long long x, y;     pt() {}     pt(long long x, long long y) : x(x), y(y) {}   };   vector<vector<long long>> used;   vector<vector<long long>> g;   void parasha(pt q, pt p, long long weight, deque<pt>& bfs,                vector<vector<long long>>& w) {     if (q.x < 0 || q.y < 0 || q.x >= n || q.y >= m) return;     if (g[q.x][q.y] ==  * ) return;     if (w[q.x][q.y] > w[p.x][p.y] + weight) {       w[q.x][q.y] = w[p.x][p.y] + weight;       if (weight == 1)         bfs.push_back(q);       else         bfs.push_front(q);     }   }   int32_t main() {     deque<pt> bfs;     cin >> n >> m;     vector<vector<long long>> w(n, vector<long long>(m, 3e9));     g.assign(n, vector<long long>(m));     used.assign(n, vector<long long>(m, 0));     long long r, c;     cin >> r >> c;     --r;     --c;     long long x, y;     cin >> x >> y;     for (long long i = 0; i < n; ++i) {       for (long long j = 0; j < m; ++j) {         char x;         cin >> x;         g[i][j] = x;       }     }     bfs.push_back(pt(r, c));     w[r][c] = 0;     while (!bfs.empty()) {       pt q = bfs.front();       bfs.pop_front();       if (used[q.x][q.y] == 1) {         continue;       }       used[q.x][q.y] = 1;       parasha(pt(q.x, q.y + 1), q, 0, bfs, w);       parasha(pt(q.x + 1, q.y), q, 0, bfs, w);       parasha(pt(q.x - 1, q.y), q, 0, bfs, w);       parasha(pt(q.x, q.y - 1), q, 1, bfs, w);     }     long long ans = 0;     for (long long i = 0; i < n; ++i) {       for (long long j = 0; j < m; ++j) {         if (w[i][j] <= x && w[i][j] - (c - j) <= y) ++ans;       }     }     cout << ans;   }
#include <bits/stdc++.h>   using namespace std;   using lint = long long;   using pi = pair<lint, lint>;   const int MAXN = 100005;   int n, m, sum;   int cnt[MAXN];   set<int> s[MAXN];   int p[MAXN];   vector<tuple<int, int, int>> dap;   void MOVE(int dst, int src, int v) {     vector<int> mutation;     for (auto &i : s[dst]) {       if (s[src].find(i) == s[src].end()) {         continue;       }       s[src].erase(i);       mutation.push_back(i);     }     while (v--) {       auto x = *s[src].begin();       s[src].erase(x);       s[dst].insert(x);       dap.emplace_back(src + 1, dst + 1, x);     }     for (auto &i : mutation) s[src].insert(i);   }   int main() {     scanf( %d %d , &n, &m);     for (int i = 0; i < n; i++) {       int x;       scanf( %d , &x);       sum += x;       p[i] = i;       for (int j = 0; j < x; j++) {         int v;         scanf( %d , &v);         s[i].insert(v);       }     }     for (int i = 0; i < sum; i++) {       cnt[n - 1 - i % n]++;     }     sort(p, p + n,          [&](const int &a, const int &b) { return s[a].size() < s[b].size(); });     int lx = -1, ly = 1e9;     for (int i = 0; i < n; i++) {       if (s[p[i]].size() < cnt[i]) {         lx = i;       }       if (s[p[i]].size() > cnt[i]) ly = min(ly, i);     }     if (lx == -1) {       puts( 0 );       return 0;     }     while (true) {       while (lx >= 0 && s[p[lx]].size() == cnt[lx]) lx--;       while (ly < n && s[p[ly]].size() == cnt[ly]) ly++;       if (lx == -1) break;       int thres0 = cnt[lx] - s[p[lx]].size();       int thres1 = s[p[ly]].size() - cnt[ly];       MOVE(p[lx], p[ly], min(thres0, thres1));     }     printf( %d n , dap.size());     for (auto &i : dap) {       int x, y, z;       tie(x, y, z) = i;       printf( %d %d %d n , x, y, z);     }   }
#include <bits/stdc++.h>   using namespace std;   long long n, p, su;   long long a[100005], b[100005];   long double ex[100005];   bool check(long double mid) {     long double need = 0;     for (int i = 0; i < n; i++) {       long double ne = max(0.0L, a[i] * (mid - ex[i]));       need += ne;     }     return (mid * p >= need);   }   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     cin >> n >> p;     for (int i = 0; i < n; i++) {       cin >> a[i] >> b[i];       su += a[i];     }     if (p >= su) {       cout << -1;     } else {       for (int i = 0; i < n; i++) {         ex[i] = (b[i] * 1.0L) / a[i];       }       long double l = 0;       long double r = 1e18;       for (int i = 0; i < 120; i++) {         long double mid = (l + r) / 2;         if (check(mid)) {           l = mid;         } else {           r = mid;         }       }       if (r > 1e18 - 100) {         cout << -1;       } else {         cout << setprecision(9) << l;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int W, H, N, num;   char ch;   multiset<int> maxHorSize, maxVertSize;   set<int> horiz, vert;   long long max_area;   long long find_max(set<int> &setCut, char cut) {     auto med = setCut.find(num);     auto big = med;     auto sml = med;     ++big;     --sml;     if (cut ==  h ) {       maxHorSize.erase(maxHorSize.find(*big - *sml));       maxHorSize.insert(*med - *sml);       maxHorSize.insert(*big - *med);     } else if (cut ==  v ) {       maxVertSize.erase(maxVertSize.find(*big - *sml));       maxVertSize.insert(*med - *sml);       maxVertSize.insert(*big - *med);     }     return (long long)(*maxHorSize.rbegin()) * (long long)(*maxVertSize.rbegin());   }   int main() {     scanf( %d%d%d , &W, &H, &N);     horiz = {0, H};     vert = {0, W};     maxHorSize = {H};     maxVertSize = {W};     for (auto i = 1; i != N + 1 - 2 * (1 > N); i += 1 - 2 * (1 > N)) {       cin >> ch >> num;       if (ch ==  H ) {         horiz.insert(num);         max_area = find_max(horiz,  h );       } else if (ch ==  V ) {         vert.insert(num);         max_area = find_max(vert,  v );       }       printf( %I64d n , max_area);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   set<pair<long long, long long> > S;   set<pair<long long, long long> >::iterator it;   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     int t, n;     for (cin >> t; t--;) {       cin >> n;       S.clear();       long long a = 1, b = 0, ans = 0, u;       for (int i = 0; i < n; i++) {         cin >> u;         long long s = a * (1 - b), e = a * (u - 1 - b);         if (a < 0) swap(s, e);         while (!S.empty()) {           pair<long long, long long> v = *S.begin();           if (v.first >= s)             break;           else {             S.erase(S.begin());             if (v.second >= s) S.insert(pair<long long, long long>(s, v.second));           }         }         while (!S.empty()) {           it = S.end();           it--;           pair<long long, long long> v = *it;           if (v.second > e)             S.erase(it);           else             break;           if (v.first <= e) S.insert(pair<long long, long long>(v.first, e));         }         if (S.empty()) {           if (a > 0)             S.insert(pair<long long, long long>(a * (1 - b), a * (u - b)));           else             S.insert(pair<long long, long long>(a * (u - b), a * (1 - b)));         } else           ans++;         a *= -1, b = u - b;         if (u % 2 == 0) {           it = S.upper_bound(               pair<long long, long long>(a * (u / 2 - b), 1000000000000000000ll));           if (it == S.begin())             S.insert(                 pair<long long, long long>(a * (u / 2 - b), a * (u / 2 - b)));           else {             it--;             pair<long long, long long> v = *it;             if (v.first <= a * (u / 2 - b) && v.second >= a * (u / 2 - b)) {               S.clear();               a = 1;               b = 0;               ans++;             }             S.insert(                 pair<long long, long long>(a * (u / 2 - b), a * (u / 2 - b)));           }         }       }       cout << n * 2 - ans << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int A[26] = {0}, count = 0;     string s;     getline(cin, s);     for (int i = 1; i < s.size(); i += 3) {       A[int(s[i]) - 97] = 1;     }     for (int i = 0; i < 26; i++) {       if (A[i] == 1) {         count++;       }     }     cout << count;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long mod = 1e9 + 7;   const long long mx = 1e5 + 5;   long long middle(long long a, long long b, long long c) {     if ((a <= b && b <= c) || (c <= b && b <= a))       return b;     else if ((b <= a && a <= c) || (c <= a && a <= b))       return a;     else       return c;   }   bool ispalindrom(string s) {     transform(s.begin(), s.end(), s.begin(), ::tolower);     return (s[0] == s[s.size() - 1] ? 1 : 0);   }   bool as_second(const pair<long long, long long> &a,                  const pair<long long, long long> &b) {     return (a.second < b.second);   }   bool ds_first(const pair<long long, long long> &a,                 const pair<long long, long long> &b) {     return (a.first > b.first);   }   bool ds_second(const pair<long long, long long> &a,                  const pair<long long, long long> &b) {     return a.second > b.second;   }   template <typename KeyType, typename ValueType>   std::pair<KeyType, ValueType> get_max(const std::map<KeyType, ValueType> &x) {     using pairtype = std::pair<KeyType, ValueType>;     return *std::max_element(x.begin(), x.end(),                              [](const pairtype &p1, const pairtype &p2) {                                return p1.second < p2.second;                              });   }   static inline bool isvowel(char ch) {     static const std::string vowels( aeiouEAIOU );     return vowels.end() != std::find(vowels.begin(), vowels.end(), ch);   }   template <typename Map>   bool map_compare(Map const &lhs, Map const &rhs) {     return lhs.size() == rhs.size() &&            std::equal(lhs.begin(), lhs.end(), rhs.begin());   }   long long nCr(long long n, long long k) {     long long ans = 1;     k = k > n - k ? n - k : k;     long long j = 1;     for (; j <= k; j++, n--) {       if (n % j == 0) {         ans *= n / j;       } else if (ans % j == 0) {         ans = ans / j * n;       } else {         ans = (ans * n) / j;       }     }     return ans;   }   string str, str1, str2, str3, str4, str5, str6, str7;   char ch, ch1, ch2, ch3;   bool flag = true, flag1 = true, flag2 = true;   long long a, b, c, d, e, f, g, h, l, i, j, k, m, n, o, p, q, r, s, t, u, v, w,       x, y, z, a1, b1, a2, b2, a3, b3, a4, b4, a5, b5,       f1 = 0, f2 = 0, cnt = 0, cnt1 = 0, cnt2 = 0, cnt3 = 0, cnt4 = 0, sum = 0,       sum1 = 0, sum2 = 0, sum3 = 0, ma = 0, ma1 = 0, mi = INT_MAX, mi1 = INT_MAX,       temp = 0, temp1 = 0, temp2 = 0;   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     cin >> n;     vector<long long> v(n);     for (long long i = 0; i < n; i++) {       cin >> v[i];       sum += v[i];     }     if (sum != 0) {       cout <<  YES n1 n ;       cout << 1 <<     << n << endl;     } else {       p = 0;       for (long long i = 0; i < n; i++) {         if (v[i] != 0) {           p = i + 1;           break;         }       }       if (p == 0) {         return cout <<  NO n  << endl, 0;       } else {         cout <<  YES n2 n ;         cout << 1 <<     << p << endl;         cout << p + 1 <<     << n << endl;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MOD = 1000000009;   const int N = 100005;   const double PI = 4 * atan(1);   const long long MAX = 9223372036854775807;   int dx[] = {1, -1, 0, 0, 1, -1, 1, -1};   int dy[] = {0, 0, 1, -1, 1, 1, -1, -1};   long long gcd(long long a, long long b) { return (b == 0 ? a : gcd(b, a % b)); }   long long lcm(long long a, long long b) { return a * (b / gcd(a, b)); }   bool issquare(long long w) { return trunc(sqrt(w)) * trunc(sqrt(w)) == w; }   bool isprime(long long u) {     for (long long i = 2; i <= (int)sqrt(u); i++) {       if (u % i == 0) return 0;     }     return 1;   }   long long mod(long long to_mod) {     to_mod %= MOD;     while (to_mod < 0) to_mod += MOD;     return to_mod % MOD;   }   long long moduloMultiplication(long long a, long long b, long long mod) {     long long res = 0;     a %= mod;     while (b) {       if (b & 1) res = (res + a) % mod;       a = (2 * a) % mod;       b >>= 1;     }     return res;   }   long long power(long long x, long long y, long long p) {     long long res = 1;     x = x % p;     while (y > 0) {       ;       if (y & 1) res = (res * x) % p;       y = y >> 1;       x = (x * x) % p;     }     return res;   }   long long n, m, x, y, res, t, k, ans = 0, b, q, z, a, l;   int main() {     ios::sync_with_stdio(0);     cin >> n >> m >> k;     res = n / k;     ans = n % k;     m -= ans;     a = res * (k - 1);     if (a >= m) {       ans += m;       ans = mod(ans);       cout << ans;       return 0;     }     b = m - a;     y = (power(2, b + 1, MOD) - 2);     ans += moduloMultiplication(y, k, MOD);     ans = mod(ans);     ans += moduloMultiplication(k - 1, res - b, MOD);     ans = mod(ans);     cout << ans << endl;     return 0;   }
#pragma GCC optimize( Ofast )   #include  bits/stdc++.h    typedef long long ll;   using namespace std;       #define sim template < class c    #define ris return * this    #define dor > debug & operator <<    #define eni(x) sim > typename    enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {    sim > struct rge { c b, e; };    sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }    sim > auto dud(c* x) -> decltype(cerr << *x, 0);    sim > char dud(...);    struct debug {      // #ifdef LOCAL     ~debug() { cerr << endl; }     eni(!=) cerr << boolalpha << i; ris; }     eni(==) ris << range(begin(i), end(i)); }     sim, class b dor(pair < b, c > d) {      ris <<  (  << d.first <<  ,   << d.second <<  ) ;     }     sim dor(rge<c> d) {      *this <<  [ ;      for (auto it = d.b; it != d.e; ++it)       *this <<  ,   + 2 * (it == d.b) << *it;      ris <<  ] ;     }         // sim dor(const c&) { ris; }    };    #ifdef ASJKD   }    #endif    #define imie(...)   [  << #__VA_ARGS__  :   << (__VA_ARGS__) <<  ]      #define read(x) for(auto &i : (x)){cin>>i;}    #define all(x) begin(x), end(x)    #define pb push_back    #define pii pair<int,int>   #define maxn 100005   ll mod = 1e9+7;   int INF = 1e9+1e8+1e7;   ll INF64 = 1e18;      long long binpow(long long a, long long b, long long m) {    a %= m;    long long res = 1;    while (b > 0) {     if (b & 1){      res = res * a % m;     }     a = a * a % m;     b >>= 1;    }    return res;   }   vector<vector<int>> pfs(maxn);   vector<bool> isprime(maxn, 1);   void sieve(int mx){    for(int i=2;i<mx;i++){     if(isprime[i]){      for(int j=i;j<mx;j+=i){       isprime[j]=0;       pfs[j].pb(i);      }     }     }   }   void test_case(int tnum){    int n,q;    cin>>n>>q;    vector<int> a(n);    read(a);    vector<int> go(n+1, n);    vector<int> last(maxn, n);    for(int i=n-1;i>=0;i--){     for(int j : pfs[a[i]]){      go[i]=min(go[i], last[j]);      last[j] = min(last[j], i);     }     go[i] = min(go[i], go[i+1]);    }    // debug() << imie(go);    vector<vector<int>> lift(20, vector<int>(n+1, n));    for(int i=0;i<n;i++){     lift[0][i] = go[i];    }    for(int i=1;i<20;i++){     for(int j=0;j<n;j++){      lift[i][j]=lift[i-1][lift[i-1][j]];     }    }    for(int rep=0;rep<q;rep++){     int l, r;     cin>>l>>r;     --l,--r;     int cur=l;     int ans =0;      while(true){      if(go[cur] > r){       ans++;       break;      }      for(int i=19;i>=0;i--){       if(lift[i][cur]<=r){        ans += 1<<(i);        cur = lift[i][cur];        break;       }      }     }     cout<<ans<<  n ;    }   }      int main(){    cin.tie(0);    cout.tie(0);    ios_base::sync_with_stdio(false);    int t=1;    sieve(maxn);    // cin>>t;    for(int test=1;test<=t;test++){     test_case(test);    }    return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     string table;     string hand;     getline(cin, table,   n );     transform(table.begin(), table.end(), table.begin(), ::tolower);     getline(cin, hand,   n );     transform(hand.begin(), hand.end(), hand.begin(), ::tolower);     if (hand.find(table[0]) != -1 || hand.find(table[1]) != -1) {       cout <<  YES ;     } else       cout <<  NO ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 820;   typedef struct node {     int l, r, x;   } node;   node a[N * N];   bool cmp(node x, node y) { return x.x > y.x; }   int n, m, k, t, tot = 0;   int v[N], p[N], ans[N];   int main() {     cin >> n;     n = n * 2;     for (int i = 1; i <= n; i++)       for (int j = 1; j <= i - 1; j++) {         scanf( %d , &a[++tot].x);         a[tot].l = i;         a[tot].r = j;       }     sort(a + 1, a + tot + 1, cmp);     for (int i = 1; i <= tot; i++) {       int l = a[i].l;       int r = a[i].r;       if (v[l] || v[r]) continue;       v[l] = v[r] = 1;       ans[l] = r;       ans[r] = l;     }     for (int i = 1; i <= n; i++) printf( %d  , ans[i]);     cout << endl;   }
#include <bits/stdc++.h>   const long long N = 1e6 + 10;   const long long mod = 1e9 + 7;   long long dir[4][2] = {0, 1, 1, 0, 0, -1, -1, 0};   using namespace std;   struct node {     long long x, y, id;     node() {}     node(long long x, long long y, long long i) : x(x), y(y), id(i) {}   };   long long ans[N];   stack<node> q;   long long ok(node a, node b) {     long long x = a.x + b.x, y = a.y + b.y;     if (x * x + y * y <= 1e12) return 1;     x = a.x - b.x;     y = a.y - b.y;     if (x * x + y * y <= 1e12) return 2;     return 0;   }   long long be[N], dp[N];   long long dfs(long long x) {     if (dp[x] != -2) return dp[x];     if (be[x] == 0) return dp[x] = ans[x];     dp[x] = ans[x] * dfs(be[x]);     return dp[x];   }   int32_t main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     long long n;     cin >> n;     long long x, y;     for (long long i = 1; i <= n; i++) cin >> x >> y, q.push(node(x, y, i));     if (n == 1) return cout << 1, 0;     long long cc = n;     while (q.size() > 2) {       node t1 = q.top();       q.pop();       node t2 = q.top();       q.pop();       node t3 = q.top();       q.pop();       long long t;       if (t = ok(t1, t2)) {         if (t == 1) {           ans[t1.id] = 1, ans[t2.id] = 1,           q.push(node(t1.x + t2.x, t1.y + t2.y, ++cc)), q.push(t3);           be[t1.id] = be[t2.id] = cc;         } else {           ans[t1.id] = 1, ans[t2.id] = -1,           q.push(node(t1.x - t2.x, t1.y - t2.y, ++cc)), q.push(t3);           be[t1.id] = be[t2.id] = cc;         }       } else if (t = ok(t1, t3)) {         if (t == 1) {           ans[t1.id] = 1, ans[t3.id] = 1,           q.push(node(t1.x + t3.x, t1.y + t3.y, ++cc)), q.push(t2);           be[t1.id] = be[t3.id] = cc;         } else {           ans[t1.id] = 1, ans[t3.id] = -1,           q.push(node(t1.x - t3.x, t1.y - t3.y, ++cc)), q.push(t2);           be[t1.id] = be[t3.id] = cc;         }       } else if (t = ok(t3, t2)) {         if (t == 1) {           ans[t3.id] = 1, ans[t2.id] = 1,           q.push(node(t3.x + t2.x, t3.y + t2.y, ++cc)), q.push(t1);           be[t3.id] = be[t2.id] = cc;         } else {           ans[t3.id] = 1, ans[t2.id] = -1,           q.push(node(t3.x - t2.x, t3.y - t2.y, ++cc)), q.push(t1);           be[t3.id] = be[t2.id] = cc;         }       }     }     {       node t1 = q.top();       q.pop();       node t2 = q.top();       long long xx = t1.x + t2.x, yy = t1.y + t2.y;       if (xx * xx + yy * yy <= 2.25e12)         ans[t1.id] = ans[t2.id] = 1;       else         ans[t1.id] = 1, ans[t2.id] = -1;     }     for (long long i = 1; i <= cc; i++) dp[i] = -2;     for (long long i = 1; i <= n; i++)       if (dp[i] == -2) dp[i] = dfs(i);     for (long long i = 1; i <= n; i++) cout << dp[i] <<    ;     return 0;   }