malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   long long n, m, aid = 1, did = 1, atk[105], def[105], c[105];   char s[10];   int main() {     cin >> n >> m;     for (long long i = 1; i <= n; i++) {       scanf( %s , s);       if (s[0] ==  A )         scanf( %lld , &atk[aid++]);       else         scanf( %lld , &def[did++]);     }     for (long long i = 1; i <= m; i++) {       scanf( %lld , &c[i]);     }     sort(atk + 1, atk + aid);     sort(c + 1, c + m + 1, greater<long long>());     long long indx = 1, sum = 0, off = 0;     for (long long i = 1; i <= m; i++) {       if (i >= aid) break;       if (c[i] < atk[i]) {         off = 1;         break;       }       sum += (c[i] - atk[i]);       indx = i + 1;     }     multiset<long long> cel;     bool flag = 1;     if (off == 1 || indx > m) {       goto p;       return 0;     }     for (long long i = indx; i <= m; i++) cel.insert(c[i]);     for (long long i = 1; i < did; i++) {       auto it = cel.upper_bound(def[i]);       if (it == cel.end()) {         goto p;       }       cel.erase(it);     }     while (!cel.empty()) {       auto it = cel.begin();       sum += *it;       cel.erase(it);     }   p:     long long sum2 = 0, cnt = 0;     multiset<long long> cel2;     for (long long i = 1; i <= m; i++) cel2.insert(c[i]);     for (long long i = 1; i < did; i++) {       auto it = cel2.upper_bound(def[i]);       if (it == cel2.end()) continue;       cnt++;       cel2.erase(it);     }     for (long long i = 1; i < aid; i++) {       auto it = cel2.upper_bound(atk[i]);       if (it == cel2.end()) continue;       cnt++;       sum2 += (*it - atk[i]);       cel2.erase(it);     }     while (!cel2.empty() && cnt == n) {       auto it = cel2.begin();       sum2 += *it;       cel2.erase(it);     }     cout << max(sum, sum2) << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MX = 2020;   const int MOD = 1e9 + 7;   const long long INF = 1061109567;   const long double EPS = 1e-9;   const long double PI = acos(-1);   const int MXX = 2e5 + 5;   long long F[MXX + 5], iF[MXX + 5];   long long qpow(long long b, long long e) {     if (!e) return 1LL;     if (e & 1) return (qpow(b, e - 1) * b) % MOD;     long long aux = qpow(b, e / 2);     return (aux * aux) % MOD;   }   long long invmod(long long n) { return qpow(n, MOD - 2); }   long long ways(int p, int q) {     if (p == 0 || q == 0) return 1;     long long ans = ((F[p + q] % MOD) * (iF[p] % MOD)) % MOD;     ans = ((ans % MOD) * (iF[q] % MOD)) % MOD;     return ans;   }   long long ways(int p, int q, int u, int v) { return ways(u - p, v - q) % MOD; }   pair<int, int> pt[MX];   long long dp[MX];   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     iF[0] = F[0] = iF[1] = F[1] = 1LL;     for (int i = (2); i < (MXX); i++) {       F[i] = ((F[i - 1] % MOD) * (i % MOD)) % MOD;       iF[i] = ((iF[i - 1] % MOD) * (invmod(i) % MOD)) % MOD;     }     int h, w;     cin >> h >> w;     int n;     cin >> n;     n++;     pt[0].first = pt[0].second = 1;     for (int i = (1); i < (n); i++) {       cin >> pt[i].first >> pt[i].second;     }     sort(pt, pt + n);     for (int i = (n - 1); i >= (0); i--) {       dp[i] = ways(pt[i].first, pt[i].second, h, w);       for (int j = (i + 1); j < (n); j++) {         if (pt[j].second < pt[i].second) continue;         long long v =             ways(pt[i].first, pt[i].second, pt[j].first, pt[j].second) % MOD;         v = (v * dp[j]) % MOD;         dp[i] = (dp[i] + MOD - v) % MOD;       }     }     cout << dp[0];   }
#include<bits/stdc++.h>   using namespace std;   #define M 500000   typedef long long ll;   typedef unsigned long long ull;   inline ll read() {    char ch;    ll f = 1, res = 0;    while ((ch = getchar()) <  0  || ch >  9 )     if (ch ==  - ) f = -1;    while (ch >=  0  && ch <=  9 ) {     res = (res << 1) + (res << 3) + (ch ^ 48);     ch = getchar();    }    return f * res;   }   inline void pt(ll u,ll mod) {    printf( %lld , u);    if (mod == 1)     putchar(   );    else if (mod == 2)     putchar(  n );   }   ll mod=1e9+7;   ll arr[M];   ll p[M];   int main() {    //freopen( ../in ,  r , stdin);    //freopen( ../out ,  w , stdout);    p[1]=1;    p[0]=1;    for(ll i=2;i<M;i++)     p[i]=p[i-1]*i%mod;    ll q = read();    while (q--) {     ll n = read();     ll k = pow(2, 40) + 0.1 - 1;     for (ll i = 0; i < n; i++) {      ll t = read();      arr[i] = t;      k &= t;     }     ll cnt = 0;     for (ll i = 0; i < n; i++) {      if (arr[i] == k)       cnt++;     }     ll ans = cnt * (cnt - 1) % mod;     pt(ans * p[n - 2] % mod, 2);    }    return 0;   }
#include <bits/stdc++.h>   using namespace std;   inline char gc() {     static char buf[1 << 16], *S, *T;     if (S == T) {       T = (S = buf) + fread(buf, 1, 1 << 16, stdin);       if (T == S) return EOF;     }     return *S++;   }   inline long long read() {     long long x = 0, f = 1;     char ch = gc();     while (ch <  0  || ch >  9 ) {       if (ch ==  - ) f = -1;       ch = gc();     }     while (ch >=  0  && ch <=  9 ) x = x * 10 + ch -  0 , ch = gc();     return x * f;   }   int m, k, n, a[1000010], dp[1000010], ans = 0;   long long l;   pair<int, int> c[1000010];   int main() {     m = read();     l = read();     k = read();     n = m * k;     for (int i = 0; i < m; ++i) a[i] = read();     for (int i = 0; i < n; ++i) c[i].first = a[i % m], c[i].second = i;     sort(c, c + n);     long long tot = l / m;     int yu = l % m;     ans = l % 1000000007;     for (int i = 0; i < n; ++i) {       int id = c[i].second;       if (id / m + 1 == 1) {         dp[id / m + 1]++;         continue;       }       dp[id / m + 1] += dp[id / m + 1 - 1], dp[id / m + 1] %= 1000000007;       if (id >= l) continue;       long long cnt = tot - (id / m + 1) + 1;       if (id % m <= yu - 1) cnt++;       ans += cnt % 1000000007 * dp[id / m + 1 - 1] % 1000000007;       ans %= 1000000007;     }     printf( %d n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long sq(long long x) { return x * x; }   long double ptos(pair<long long, long long> A, pair<long long, long long> B,                    pair<long long, long long> C) {     long long area = abs((B.first - A.first) * (C.second - A.second) -                          (B.second - A.second) * (C.first - A.first));     long long llen = sq(B.first - C.first) + sq(B.second - C.second);     return 1.0l * area / sqrtl(llen);   }   int main() {     int n;     scanf( %d , &n);     vector<pair<long long, long long> > p(n);     for (int i = 0; i < n; ++i) {       int first, second;       scanf( %d %d , &first, &second);       p[i].first = first, p[i].second = second;     }     p.push_back(p[0]);     long double dans = 1e18l;     for (int i = 0; i < n; ++i) {       dans = min(dans, ptos(p[i], p[(i - 1 + n) % n], p[i + 1]));       for (int j = 0; j < n; ++j) {         if (i != j) {           dans = min(dans, sqrtl(sq(p[i].first - p[j].first) +                                  sq(p[i].second - p[j].second)));         }         if (i != j && i != (j + 1) % n) {           dans = min(dans, ptos(p[i], p[j], p[j + 1]));         }       }     }     printf( %.10lf n , (double)(dans / 2));     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long N = 100005;   vector<vector<long long> > adj(N), w(N);   long long out[N], col[N], res[N], cnt;   queue<long long> q;   void dfs(long long v, long long p) {     for (auto &u : adj[v]) {       if (u == p) continue;       dfs(u, v);     }     for (auto &u : adj[v]) {       if (u == p) continue;       if (col[u] != col[v] && !res[u] && !res[v]) {         res[u] = res[v] = ++cnt;         q.push(v);         q.push(u);       }     }     return;   }   void bfs() {     q.push(1);     col[1] = 1;     while (!q.empty()) {       long long v = q.front();       q.pop();       for (auto &u : adj[v]) {         if (!col[u]) {           col[u] = col[v] % 2 + 1;           q.push(u);         }       }     }     cnt = 0;     dfs(1, 0);     while (!q.empty()) {       long long v = q.front();       q.pop();       for (auto &u : adj[v]) {         if (!res[u]) {           res[u] = res[v];           q.push(u);         }       }     }     return;   }   int main() {     long long n, i, j, v, u, ans;     cin >> n;     for (i = 0; i < n - 1; i++) {       cin >> v >> u;       adj[v].push_back(u);       adj[u].push_back(v);     }     bfs();     for (i = 1; i <= n; i++) w[res[i]].push_back(i);     ans = 0;     for (i = 1; i <= cnt; i++) {       ans += (w[i].size() - 1) * 2;       for (j = 0; j < w[i].size(); j++)         out[w[i][j]] = w[i][(j + 1) % w[i].size()];     }     cout << ans <<   n ;     for (i = 1; i <= n; i++) cout << out[i] <<    ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   struct point {     int x;     int y;   };   struct vec {     int x;     int y;   };   point r_array[12], b_array[12];   int root[12]{}, ocupied[12]{};   int r, b;   double cross(point a, point b, point c) {     vec v1 = {c.x - a.x, c.y - a.y};     vec v2 = {b.x - a.x, b.y - a.y};     return (v1.x * v2.y - v1.y * v2.x);   }   bool r_check(int r1_index, int b1_index, int r2_index, int b2_index) {     point r1_cor = r_array[r1_index];     point r2_cor = r_array[r2_index];     point b1_cor = b_array[b1_index];     point b2_cor = b_array[b2_index];     double kq_r1 = cross(r1_cor, r2_cor, b2_cor);     double kq_b1 = cross(b1_cor, r2_cor, b2_cor);     double kq_r2 = cross(r2_cor, r1_cor, b1_cor);     double kq_b2 = cross(b2_cor, r1_cor, b1_cor);     if (kq_r1 * kq_b1 > 0) return 0;     if (kq_r2 * kq_b2 > 0) return 0;     return 1;   }   bool check() {     bool kq = 1;     for (int i = 1; i < r; i++)       for (int j = i + 1; j <= r; j++) {         kq = min(kq, r_check(i, root[i], j, root[j]));         if (kq == 0) return 0;       }     return kq;   }   bool sinh(int r_pos) {     if (r_pos > r) {       return check();     }     for (int i = 1; i <= b; i++) {       if (ocupied[i]) continue;       ocupied[i] = 1;       root[r_pos] = i;       bool kq = sinh(r_pos + 1);       ocupied[i] = 0;       if (kq) return kq;     }   }   int main() {     cin >> r >> b;     for (int i = 1; i <= r; i++) cin >> r_array[i].x >> r_array[i].y;     for (int i = 1; i <= b; i++) cin >> b_array[i].x >> b_array[i].y;     if (r != b) {       cout <<  No ;       return 0;     }     bool kq = sinh(1);     if (kq)       puts( Yes );     else       puts( No );   }
#include <bits/stdc++.h>   using namespace std;   using DO = double;   using LL = long long;   using VI = vector<LL>;   const int N = 5e5 + 10;   int head[N], nxt[N << 1], to[N << 1];   LL wei[N << 1];   int E;   void init(int n) {     for (int i = 1; i <= n; i++) {       head[i] = -1;     }     E = 0;   }   void add(int u, int v, int w) {     nxt[E] = head[u];     to[E] = v;     wei[E] = w;     head[u] = E++;     nxt[E] = head[v];     to[E] = u;     wei[E] = w;     head[v] = E++;   }   LL dp[N][2];   int n, k;   void dfs(int u, int fa = 0) {     dp[u][0] = dp[u][1] = 0;     VI vec;     for (int e = head[u], v; ~e; e = nxt[e]) {       v = to[e];       if (v == fa) continue;       dfs(v, u);       dp[u][0] += dp[v][0];       dp[u][1] += dp[v][0];       if (dp[v][0] < dp[v][1] + wei[e]) {         vec.push_back(dp[v][1] + wei[e] - dp[v][0]);       }     }     sort(vec.begin(), vec.end());     reverse(vec.begin(), vec.end());     for (int i = 0; i < min((int)vec.size(), k); i++) {       dp[u][0] += vec[i];     }     for (int i = 0; i < min((int)vec.size(), k - 1); i++) {       dp[u][1] += vec[i];     }   }   int main() {     int T;     scanf( %d , &T);     while (T--) {       scanf( %d %d , &n, &k);       init(n);       for (int i = 1, u, v, w; i < n; i++) {         scanf( %d %d %d , &u, &v, &w);         add(u, v, w);       }       dfs(1);       printf( %I64d n , max(dp[1][0], dp[1][1]));     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 3e5 + 5;   const int M = 205;   const int MOD = 1e9 + 7;   const int INF = 0x3f3f3f3f;   struct node {     int l, r, id;   } p[N << 1];   bool cmp(node a, node b) { return a.r < b.r; }   int sum[N << 4];   void update(int p, int L, int R, int pos) {     if (L == R) {       sum[pos]++;       return;     }     int mid = (L + R) >> 1;     if (p <= mid)       update(p, L, mid, pos << 1);     else       update(p, mid + 1, R, pos << 1 | 1);     sum[pos] = sum[pos << 1] + sum[pos << 1 | 1];   }   int query(int k, int L, int R, int pos) {     if (L == R) return L;     int mid = (L + R) >> 1;     if (k <= sum[pos << 1])       return query(k, L, mid, pos << 1);     else       return query(k - sum[pos << 1], mid + 1, R, pos << 1 | 1);   }   int n, k, x[N << 1];   vector<int> Ans;   int main() {     scanf( %d%d , &n, &k);     for (int i = 0; i < n; i++)       scanf( %d%d , &p[i].l, &p[i].r), p[i].id = i + 1, x[i * 2] = p[i].l,                                        x[i * 2 + 1] = p[i].r;     sort(p, p + n, cmp);     sort(x, x + 2 * n);     int m = unique(x, x + 2 * n) - x;     for (int i = 0; i < n; i++) {       p[i].l = lower_bound(x, x + m, p[i].l) - x;       p[i].r = lower_bound(x, x + m, p[i].r) - x;     }     int ans = 0, st, ed;     for (int i = n - 1; i >= 0; i--) {       update(p[i].l, 0, m - 1, 1);       if (sum[1] < k) continue;       int pos = query(k, 0, m - 1, 1);       int len = x[p[i].r] - x[pos] + 1;       if (len > ans) ans = len, st = pos, ed = p[i].r;     }     if (!ans) {       puts( 0 );       for (int i = 1; i <= k; i++) printf( %d  , i);     } else {       printf( %d n , ans);       for (int i = 0; i < n; i++)         if (p[i].l <= st && ed <= p[i].r) Ans.push_back(p[i].id);       sort(Ans.begin(), Ans.end());       for (int i = 0; i < k; i++) printf( %d  , Ans[i]);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int t, n, m, har[27];   string s;   int sum[200005][27];   int main() {     cin >> t;     while (t--) {       cin >> n >> m;       cin >> s;       for (int i = 0; i <= 25; i++) har[i] = 0;       for (int i = 0; i < n; i++) {         for (int j = 0; j < 26; j++) sum[i][j] = 0;       }       for (int i = 0; i < n; i++) {         if (i != 0) {           for (int j = 0; j <= 25; j++) {             sum[i][j] = sum[i - 1][j];           }         }         sum[i][s[i] -  a ]++;       }       int l = 0;       for (int i = 0; i < m; i++) {         cin >> l;         for (int j = 0; j < 26; j++) {           har[j] += sum[l - 1][j];         }       }       for (int j = 0; j < 26; j++) {         har[j] += sum[n - 1][j];       }       for (int i = 0; i < 26; i++) {         cout << har[i] <<    ;       }       cout << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   const long long mod = 1e9 + 7;   struct node {     int x, y;     bool operator<(const node &_) const {       return x < _.x || (x == _.x && y < _.y);     }   } A[2005];   int h, w, n;   long long dp[2005], jie[200005 << 1], inv[200005 << 1];   long long Pow(long long x) {     int n = mod - 2;     long long res = 1;     while (n) {       if (n & 1) res = res * x % mod;       x = x * x % mod;       n >>= 1;     }     return res;   }   void Init() {     jie[0] = inv[0] = 1;     for (int i = 1; i < 200005; i++) {       jie[i] = 1LL * jie[i - 1] * i % mod;       inv[i] = Pow(jie[i]);     }   }   long long C(int a, int b) {     return 1LL * jie[a] * inv[b] % mod * inv[a - b] % mod;   }   int main() {     Init();     scanf( %d%d%d , &h, &w, &n);     for (int i = 1; i <= n; i++) scanf( %d%d , &A[i].x, &A[i].y);     sort(A + 1, A + n + 1);     A[n + 1].x = h, A[n + 1].y = w;     for (int i = 1; i <= n + 1; i++) {       dp[i] = C(A[i].x + A[i].y - 2, A[i].x - 1);       for (int j = 1; j < i; j++) {         if (A[i].y < A[j].y) continue;         dp[i] = ((dp[i] -                   C(A[i].x - A[j].x + A[i].y - A[j].y, A[i].x - A[j].x) * dp[j]) %                      mod +                  mod) %                 mod;       }     }     cout << dp[n + 1] << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n;   vector<vector<int> > adj;   vector<bool> top;   vector<int> branched;   vector<bool> visited;   vector<bool> fertile;   int root = -1;   void fail() {     cout <<  No  << endl;     exit(0);   }   void dfsFindRoot(int u) {     if (root != -1) return;     visited[u] = true;     bool leaf = true;     for (int child : adj[u]) {       if (visited[child]) continue;       leaf = false;     }     if (!leaf) {       branched[u] = 0;       for (int child : adj[u]) {         if (visited[child]) continue;         dfsFindRoot(child);         branched[u] += branched[child];       }       if (root != -1) return;       if (branched[u] >= 3) {         root = u;       }     }   }   void dfs(int u) {     visited[u] = true;     bool leaf = true;     for (int child : adj[u]) {       if (visited[child]) continue;       leaf = false;     }     if (!leaf) {       branched[u] = 0;       int numTops = 0;       for (int child : adj[u]) {         if (visited[child]) continue;         dfs(child);         if (fertile[child]) top[u] = true;         branched[u] += branched[child];         if (top[child]) {           numTops++;           top[u] = true;         }       }       if (u != root && numTops > 1)         fail();       else if (numTops > 2)         fail();       if (branched[u] >= 3) {         top[u] = true;       } else if (branched[u] == 2)         fertile[u] = true;     }   }   int main() {     int m;     cin >> n;     adj = vector<vector<int> >(n, vector<int>(0));     for (int i = 0; i < n - 1; i++) {       int u, v;       cin >> u >> v;       u--;       v--;       adj[u].push_back(v);       adj[v].push_back(u);     }     if (n <= 4) {       cout <<  YES  << endl;       return 0;     }     top = vector<bool>(n, false);     branched = vector<int>(n, 1);     visited = vector<bool>(n, false);     dfsFindRoot(0);     if (root == -1) {       cout <<  Yes  << endl;       return 0;     }     top = vector<bool>(n, false);     branched = vector<int>(n, 1);     visited = vector<bool>(n, false);     fertile = vector<bool>(n, false);     dfs(root);     cout <<  Yes  << endl;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, x, ans = 0, a, b, t = 1;     cin >> n >> x;     while (n--) {       cin >> a >> b;       while (t <= a) t = t + x;       t = t - x;       ans = ans + b - t + 1;       t = b + 1;     }     cout << ans;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long maxn = 1e6 + 10;   long long bit[maxn];   void update(long long idx, long long v) {     while (idx <= maxn) {       bit[idx] += v;       idx += idx & -idx;     }   }   long long query(long long idx) {     long long ans = 0;     while (idx > 0) {       ans += bit[idx];       idx -= idx & -idx;     }     return ans;   }   long long inter(long long l, long long r) { return query(r) - query(l - 1); }   void solve() {     long long n, m;     cin >> n >> m;     memset(bit, 0, sizeof bit);     vector<pair<long long, pair<long long, long long> > > hor(n), vert(m);     vector<pair<long long, pair<long long, long long> > > ord;     long long ans = 1;     for (long long i = 0; i < n; i++) {       cin >> hor[i].first >> hor[i].second.first >> hor[i].second.second;       if ((hor[i].second.first + hor[i].second.second) == 1e6) ans++;     }     for (long long i = 0; i < m; i++) {       cin >> vert[i].first >> vert[i].second.first >> vert[i].second.second;       if ((vert[i].second.first + vert[i].second.second) == 1e6) ans++;     }     for (long long i = 0; i < m; i++) {       vert[i].first++;       vert[i].second.first++;       vert[i].second.second++;     }     for (long long i = 0; i < n; i++) {       hor[i].first++;       hor[i].second.first++;       hor[i].second.second++;     }     for (long long i = 0; i < (long long)vert.size(); i++) {       ord.push_back({vert[i].first, {1, i}});     }     for (long long i = 0; i < (long long)hor.size(); i++) {       ord.push_back({hor[i].second.first, {0, i}});       ord.push_back({hor[i].second.second, {2, i}});     }     sort(ord.begin(), ord.end());     for (long long i = 0; i < (long long)ord.size(); i++) {       long long x = ord[i].first;       long long tipo = ord[i].second.first;       long long ind = ord[i].second.second;       if (tipo == 1) {         long long y1 = vert[ind].second.first;         long long y2 = vert[ind].second.second;         ans += inter(y1, y2);       } else {         long long y = hor[ind].first;         if (tipo == 2)           update(y, -1);         else           update(y, 1);       }     }     cout << ans << endl;   }   int32_t main() {     cin.tie(0);     ios::sync_with_stdio(0);     long long tc = 1;     while (tc--) solve();   }
#include <bits/stdc++.h>   using namespace std;   vector<pair<int, int> > v, a;   vector<pair<double, int> > ans;   int n, sum, del, sx, sy, x, y, Nx, Ny;   set<int> u;   int cmp(pair<int, int> a, pair<int, int> b) {     return ((a.first) * (a.first)) + ((a.second) * (a.second)) <            ((b.first) * (b.first)) + ((b.second) * (b.second));   }   int main() {     v.clear();     u.clear();     for (int i = 0; i <= 200; i++)       for (int j = i; j <= 200; j++)         if (i + j)           if (!u.count(((i) * (i)) + ((j) * (j))))             v.push_back(make_pair(i, j)), u.insert(((i) * (i)) + ((j) * (j)));     sort(v.begin(), v.end(), cmp);     cin >> n;     sum = 0;     for (int i = 0; i < n; i++) sum += (v[i].first + v[i].second) & 1;     a.clear();     del = n;     if (sum & 1) {       sum += (v[n].first + v[n].second) & 1;       for (int i = n - 1; i >= 0; i--)         if (!((sum - ((v[i].first + v[i].second) & 1)) & 1)) {           del = i;           break;         }     }     for (int i = 0; i <= n; i++)       if (del != i) a.push_back(v[i]);     sx = sy = 0;     for (int i = n - 1; i >= 0; i--) {       x = a[i].first, y = a[i].second;       for (int s = 0; s < 8; s++) {         Nx = x, Ny = y;         if (s & 1) swap(Nx, Ny);         if (s & 2) Nx *= -1;         if (s & 4) Ny *= -1;         if (((sx + a[i].first) * (sx + a[i].first)) +                 ((sy + a[i].second) * (sy + a[i].second)) >             ((sx + Nx) * (sx + Nx)) + ((sy + Ny) * (sy + Ny)))           a[i] = make_pair(Nx, Ny);       }       sx += a[i].first, sy += a[i].second;     }     for (int i = 0; i < n; i++)       ans.push_back(make_pair(atan2(a[i].second, a[i].first), i));     sort(ans.begin(), ans.end());     cout <<  YES  << endl;     sx = 0, sy = 0;     for (int i = 0; i < n; i++) {       cout << sx <<     << sy << endl;       int id = ans[i].second;       sx += a[id].first, sy += a[id].second;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long ax, ay, bx, by, cx, cy;   void check(long long axx, long long ayy) {     if (cx == 0 && cy == 0) {       if (axx == bx && ayy == by) {         cout <<  YES ;         exit(0);       } else         return;     }     if ((cx * (by - ayy) - cy * (bx - axx)) % (cx * cx + cy * cy) != 0 ||         (cx * (bx - axx) + cy * (by - ayy)) % (cx * cx + cy * cy) != 0)       return;     cout <<  YES ;     exit(0);   }   int main() {     cin >> ax >> ay >> bx >> by >> cx >> cy;     check(ax, ay);     check(ay, -ax);     check(-ax, -ay);     check(-ay, ax);     cout <<  NO ;   }
#include <bits/stdc++.h>   using namespace std;   int A[2];   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     int n;     long long ans = 0;     cin >> n;     while (cin >> n) {       ++A[n];       if (!n) ans += A[1];     }     cout << ans << endl;     return 0;   }