malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   char c[110][110][110];   bool a[110][110][110];   bool b[110][110][110];   int main() {     int n, m, k;     cin >> n >> m >> k;     for (int i = 0; i < n; i++)       for (int j = 0; j < m; j++) scanf( %s , c[i][j]);     for (int i = 0; i < n; i++)       for (int j = 0; j < m; j++)         for (int s = 0; s < k; s++)           if (c[i][j][s] ==  1 ) a[i + 1][j + 1][s + 1] = true;     int di[3] = {1, 0, 0};     int dj[3] = {0, 1, 0};     int ds[3] = {0, 0, 1};     for (int i = 1; i <= n; i++)       for (int j = 1; j <= m; j++)         for (int s = 1; s <= k; s++) {           if (!a[i][j][s]) continue;           for (int p = 0; p < 3; p++) {             if (a[i + di[p]][j + dj[p]][s + ds[p]] &&                 a[i - di[p]][j - dj[p]][s - ds[p]]) {               b[i][j][s] = true;             }           }           for (int p = 0; p < 3; p++)             for (int l = 0; l < 3; l++)               if (a[i - di[p]][j - dj[p]][s - ds[p]] &&                   a[i + di[l]][j + dj[l]][s + ds[l]] &&                   !a[i - di[p] + di[l]][j - dj[p] + dj[l]][s - ds[p] + ds[l]]) {                 b[i][j][s] = true;               }         }     int answ = 0;     for (int i = 1; i <= n; i++) {       for (int j = 1; j <= m; j++) {         for (int s = 1; s <= k; s++) {           if (b[i][j][s]) answ++;         }       }     }     cout << answ << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   inline void read(int &x) {     register char c = getchar();     x = 0;     for (; c <  0  || c >  9 ; c = getchar())       ;     for (; c >=  0  && c <=  9 ; c = getchar()) x = (x << 1) + (x << 3) + c -  0 ;   }   priority_queue<int> q;   int main() {     priority_queue<int> pq;     int n, a, b, c, d;     long long z = 0;     read(n);     while (n--) {       read(a);       read(b);       read(c);       read(d);       if (a + b < c + d)         z += max(0, a - d) - max(0, b - c);       else {         z += a + c;         q.push(a + b);         q.push(c + d);       }     }     while (!q.empty()) {       q.pop();       z -= q.top();       q.pop();     }     printf( %I64d , z);   }
#include <bits/stdc++.h>   using namespace std;   void BFS(double, double, double &a);   double pSquares(double, double);   double n, m, k, r;   struct queue_compare {     bool operator()(const pair<double, double> &p1,                     const pair<double, double> &p2) const {       return pSquares(p1.first, p1.second) < pSquares(p2.first, p2.second);     }   } typedef pqc;   struct set_compare {     bool operator()(const pair<double, double> &p1,                     const pair<double, double> &p2) const {       if (p1.first != p2.first) {         return p1.first < p2.first;       } else {         return p1.second < p2.second;       }     }   } typedef sc;   int main() {     cin >> n >> m >> r >> k;     double numer = 0;     double denom = (n - r + 1) * (m - r + 1);     BFS(floor((m + 1) / 2), floor((n + 1) / 2), numer);     cout << setprecision(15) << (numer / denom) << endl;   }   double pSquares(double i, double j) {     double x, y;     y = abs(min(j - 1, r - 1) + 1 - (r - (min(n - j, r - 1)))) + 1;     x = abs(min(i - 1, r - 1) + 1 - (r - (min(m - i, r - 1)))) + 1;     return x * y;   }   void BFS(double i, double j, double &numerator) {     priority_queue<pair<double, double>, vector<pair<double, double> >, pqc> pq;     set<pair<double, double>, sc> s;     pair<double, double> p(i, j);     pq.push(p);     s.insert(p);     for (int i = 0; i < k; i++) {       pair<double, double> tp = pq.top();       pq.pop();       numerator += pSquares(tp.first, tp.second);       pair<double, double> left(tp.first, tp.second - 1);       pair<double, double> right(tp.first, tp.second + 1);       pair<double, double> above(tp.first - 1, tp.second);       pair<double, double> bot(tp.first + 1, tp.second);       if (tp.second - 1 >= 1 && s.find(left) == s.end()) {         s.insert(left);         pq.push(left);       }       if (tp.first - 1 >= 1 && s.find(above) == s.end()) {         s.insert(above);         pq.push(above);       }       if (tp.first + 1 <= m && s.find(bot) == s.end()) {         s.insert(bot);         pq.push(bot);       }       if (tp.second + 1 <= n && s.find(right) == s.end()) {         s.insert(right);         pq.push(right);       }     }   }
#include <bits/stdc++.h>   using namespace std;   const long long linf = 1e18 + 5;   const int mod = (int)1e9 + 7;   const int logN = 17;   const int inf = 1e9;   const int N = 2e5 + 5;   int temp[1 << 7][1 << 7], res[1 << 7][1 << 7], cur[1 << 7][1 << 7], x;   void mul(int res[][1 << 7], int cur[][1 << 7], int t) {     t = 1 << t;     --t;     memset(temp, 0, sizeof temp);     for (int i = 0; i <= t; i++)       for (int j = 0; j <= t; j++)         for (int k = 0; k <= t; k++)           temp[i][j] =               (temp[i][j] + res[i][k] * (long long)cur[k][j] % mod) % mod;     memcpy(res, temp, sizeof temp);   }   int main() {     for (int i = 0; i <= (1 << 7) - 1; i++) res[i][i] = 1;     for (int i = 1; i <= 7; i++) {       scanf( %d , &x);       for (int a = 0; a <= (1 << i) - 1; a++)         for (int b = 0; b <= (1 << i) - 1; b++) {           cur[a][b] = 0;           for (int poke = 0; poke <= (1 << i + 1) - 1; poke++) {             if ((poke & 1) || (poke & (1 << i))) continue;             if ((((a | b | poke | (poke >> 1)) & ((1 << i) - 1))) == (1 << i) - 1)               cur[a][b]++;           }         }       while (x) {         if (x & 1) mul(res, cur, i);         x >>= 1;         mul(cur, cur, i);       }     }     cout << res[0][0] <<   n ;     return 0;   }
#include <bits/stdc++.h>   #pragma warning(disable : 4996)   using namespace std;   template <typename T, typename U>   pair<T, U> operator+(const pair<T, U> &l, const pair<T, U> &r) {     return make_pair(l.first + r.first, l.second + r.second);   }   template <typename T, typename U>   pair<T, U> operator-(const pair<T, U> &l, const pair<T, U> &r) {     return make_pair(l.first - r.first, l.second - r.second);   }   template <typename T, typename U>   pair<T, U> operator*(const pair<T, U> &l, const long long &r) {     return make_pair(l.first * r, l.second * r);   }   template <typename T, typename U>   pair<T, U> operator*(const pair<T, U> &l, const pair<T, U> &r) {     return make_pair(l.first * r.first, l.second * r.second);   }   template <typename T, typename U>   pair<T, U> operator%(const pair<T, U> &l, const int &r) {     return make_pair(l.first % r, l.second % r);   }   long long n, m;   pair<long long, long long> a[6000];   long long ccw(pair<long long, long long> x, pair<long long, long long> y,                 pair<long long, long long> z) {     return (y.first - x.first) * (z.second - x.second) -            (z.first - x.first) * (y.second - x.second);   }   int main() {     int i, j, k, l;     cin >> n >> m;     for (i = 0; i < n; i++) scanf( %lld%lld , &a[i].first, &a[i].second);     sort(a, a + n);     sort(a + 1, a + n,          [&](pair<long long, long long> x, pair<long long, long long> y) {            if (ccw(a[0], x, y) == 0)              return x < y;            else              return ccw(a[0], x, y) > 0;          });     vector<pair<long long, long long> > hull;     hull.push_back(a[0]);     for (i = 1; i < n; i++) {       while (hull.size() >= 2 &&              ccw(hull[hull.size() - 2], hull[hull.size() - 1], a[i]) <= 0)         hull.pop_back();       hull.push_back(a[i]);     }     for (i = 0; i * 2 < hull.size(); i++) hull.push_back(hull[i]);     long long ma = 0;     pair<long long, long long> ax, ay, az;     int u = hull.size() / 2;     for (i = 0; i < u; i++) {       int now = i + 1;       for (j = i + 1; j < i + u; j++) {         for (; now < i + u; now++) {           if (now == i + u - 1 || ccw(hull[i], hull[j], hull[now]) >                                       ccw(hull[i], hull[j], hull[now + 1]))             break;         }         if (ma < ccw(hull[i], hull[j], hull[now])) {           ma = ccw(hull[i], hull[j], hull[now]);           ax = hull[i], ay = hull[j], az = hull[now];         }       }     }     pair<long long, long long> dx, dy, dz;     dz = ax + ay - az;     dy = ax + az - ay;     dx = ay + az - ax;     printf( %lld %lld n%lld %lld n%lld %lld , dx.first, dx.second, dy.first,            dy.second, dz.first, dz.second);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void bogo(vector<int>& a) {     for (int i = 0; i < a.size() - 1; i++) {       int biggest = i;       for (int j = i + 1; j < a.size(); j++)         if (a[biggest] < a[j]) biggest = j;       if (biggest != i) swap(a[i], a[biggest]);     }   }   int main(int argc, char** argv) {     int t = 0;     cin >> t;     for (int i = 0; i < t; i++) {       int n = 0;       cin >> n;       vector<int> a;       for (int j = 0; j < n; j++) {         int v = 0;         cin >> v;         a.push_back(v);       }       bogo(a);       for (auto v : a) cout << v <<    ;       cout << endl;     }     return 0;   }
#include <bits/stdc++.h>   const int N = 52, M = 106, INF = 2000000000;   inline int f(char c) {     if ( a  <= c && c <=  z ) return c -  a  + 1;     return c -  A  + 27;   }   inline char rf(int i) {     if (i <= 26) return  a  + i - 1;     return  A  + i - 27;   }   struct edge {     int capacity, cost, flow;     edge() {}     edge(int capacity, int cost, int flow)         : capacity(capacity), cost(cost), flow(flow) {}   };   edge g[M][M];   int cnt[N + 1][N + 1];   std::vector<int> d(M);   std::vector<std::pair<int, int>> G;   void add_edge(int a, int b, int cap, int cost) {     g[a][b] = edge(cap, cost, 0);     g[b][a] = edge(0, -cost, 0);     G.emplace_back(std::make_pair(a, b));     G.emplace_back(std::make_pair(b, a));   }   class comp {    public:     bool operator()(int a, int b) {       if (d[a] != d[b])         return d[a] > d[b];       else         return a > b;     }   };   int main() {     std::ios_base::sync_with_stdio(0);     int n, k;     std::string s, t;     std::cin >> n >> k;     std::cin >> s >> t;     for (int i = 0; i < n; ++i) ++cnt[f(s[i])][f(t[i])];     for (int i = 1; i <= k; ++i) {       add_edge(0, i, 1, 0);       add_edge(i + N, 105, 1, 0);       for (int j = 1; j <= k; ++j) add_edge(i, j + N, 1, cnt[i][j]);     }     int flow = 0, cost = 0;     while (flow < k) {       std::vector<int> p(M, -1);       d.assign(M, -INF);       d[0] = 0;       bool kek = true;       while (kek) {         kek = false;         for (int i = 0, a, b, curcap; i < G.size(); ++i) {           a = G[i].first;           b = G[i].second;           curcap = g[a][b].capacity - g[a][b].flow;           if (curcap > 0 && d[a] != -INF && d[b] < d[a] + g[a][b].cost) {             d[b] = d[a] + g[a][b].cost;             p[b] = a;             kek = true;           }         }       }       cost += d[M - 1];       ++flow;       int cur = M - 1;       while (p[cur] != -1) {         g[p[cur]][cur].flow++;         g[cur][p[cur]].flow--;         cur = p[cur];       }     }     std::cout << cost <<   n ;     for (int i = 1; i <= N; ++i)       for (int j = 1; j <= N; ++j)         if (g[i][j + N].flow) std::cout << rf(j);     std::cout <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   const int inf = (1 << 30) - 1;   const int maxn = 110;   int n, m, K;   long long f[maxn][maxn][maxn];   int col[maxn];   long long p[maxn][maxn];   int main() {     scanf( %d%d%d , &n, &m, &K);     for (int i = 1; i <= n; i++) scanf( %d , &col[i]);     for (int i = 1; i <= n; i++)       for (int j = 1; j <= m; j++) scanf( %I64d , &p[i][j]);     memset(f, 0x3f, sizeof(f));     long long INF = f[0][0][0];     f[0][0][0] = 0;     for (int i = 1; i <= n; i++)       for (int j = 0; j <= m; j++)         for (int k = 0; k <= K; k++) {           if (col[i])             f[i][col[i]][k + (j != col[i])] =                 min(f[i][col[i]][k + (j != col[i])], f[i - 1][j][k]);           else             for (int w = 1; w <= m; w++)               f[i][w][k + (j != w)] =                   min(f[i][w][k + (j != w)], f[i - 1][j][k] + p[i][w]);         }     long long ans = INF;     for (int i = 0; i <= m; i++) ans = min(ans, f[n][i][K]);     if (ans == INF) ans = -1;     printf( %I64d n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAX = 1e5 + 5;   int n, m, i;   int k1, k2, k3, t1, t2, t3;   long long a[MAX], b[MAX], t[MAX];   int main() {     cin >> k1 >> k2 >> k3 >> t1 >> t2 >> t3 >> n;     for (i = 0; i < n; i++) {       scanf( %d , &a[i]);       b[i] = a[i];     }     for (i = 0; i < n; i++) {       a[i] = max(a[i], t[i % k1]) + t1;       t[i % k1] = a[i];     }     for (i = 0; i < n; i++) t[i] = 0;     for (i = 0; i < n; i++) {       a[i] = max(a[i], t[i % k2]) + t2;       t[i % k2] = a[i];     }     for (i = 0; i < n; i++) t[i] = 0;     long long ans = 0;     for (i = 0; i < n; i++) {       a[i] = max(a[i], t[i % k3]) + t3;       t[i % k3] = a[i];       ans = max(ans, a[i] - b[i]);     }     cout << ans;   }
#include <bits/stdc++.h>   using namespace std;   long long a, b, c;   long long n, m, k;   int arr[100050];   int main() {     ios::sync_with_stdio(0);     cin.tie(0), cout.tie(0);     cin >> n;     bool odd = false, even = false;     for (int i = 1; i <= n; i++) {       cin >> arr[i];       if ((arr[i] -  0 ) % 2 == 0)         odd = true;       else         even = true;     }     if (odd && even) {       sort(arr + 1, arr + 1 + n);       for (int i = 1; i <= n; i++) cout << arr[i] <<    ;     } else {       for (int i = 1; i <= n; i++) cout << arr[i] <<    ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int p[300], a[300], num[300];   int find(int x) {     if (p[x] == 0)       return x;     else {       p[x] = find(p[x]);       return p[x];     }   }   void merge(int x, int y) {     x = find(x);     y = find(y);     if (x != y) p[x] = y;   }   int main() {     int n, m, ans, i, x, j, k;     scanf( %d%d , &n, &m);     ans = 0;     for (i = 1; i <= n; ++i) {       scanf( %d , &x);       for (j = 1; j <= x; ++j) {         scanf( %d , &a[j]);         ++num[a[j]];       }       if (x == 0) {         ++ans;         continue;       }       for (k = 2; k <= x; ++k) merge(a[1], a[k]);     }     bool flag = false;     for (i = 1; i <= m; ++i) {       if (p[i] == 0 && num[i] > 0) {         ++ans;         flag = true;       }     }     if (flag) --ans;     printf( %d n , ans);   }
#include <bits/stdc++.h>   using namespace std;   const int mod = 1000003;   char in[2010];   int catlen[2010];   long long fac[4010], inv[4010], rf[4010];   int t[2010], tc;   int first[2010], stc;   long long dp[2010][2010];   inline int solve() {     int n = strlen(in);     tc = 0;     bool isn = 0, ist;     for (int i = (0); i < (int)(n); ++i) {       ist = 0;       if (in[i] <=  9  && in[i] >=  0 )         isn = 1;       else {         if (isn) {           t[tc++] = 0;           isn = 0;         }         if (i == 0 || !(in[i - 1] <=  9  && in[i - 1] >=  0 )) {           if (in[i] ==  *  || in[i] ==  / ) return 0;           t[tc++] = 1;         } else           ist = 1;       }     }     if (isn) t[tc++] = 0;     if (t[tc - 1] == 1 || ist) return 0;     stc = 0;     for (int i = (0); i < (int)(tc); ++i)       if (t[i] == 0)         first[stc]++;       else         stc++;     if (stc == 0) return catlen[tc];     dp[stc + 1][0] = 1;     int ms = 0;     for (int i = (int)(stc + 1) - 1; i >= 0; --i) {       int r = first[i];       if (i) {         ms += r;         for (int j = (1); j < (int)(ms + 1); ++j) {           for (int k = max(r - j, 0); k <= ms - j; k++) {             dp[i][k + 1] += (dp[i + 1][k + j - r] * catlen[j]) % mod;             if (dp[i][k + 1] >= mod) dp[i][k + 1] -= mod;           }         }       } else {         for (int j = (0); j < (int)(ms + 1); ++j) dp[i][j + r] = dp[i + 1][j];         ms += r;       }     }     int ret = 0;     for (int i = (1); i < (int)(tc + 1); ++i)       ret = (ret + dp[0][i] * catlen[i]) % mod;     return ret;   }   int main() {     inv[1] = 1;     for (int i = 2; i <= 4000; i++)       inv[i] = (inv[mod % i] * (mod - mod / i)) % mod;     fac[0] = rf[0] = 1;     for (int i = 1; i <= 4000; i++) {       fac[i] = (fac[i - 1] * i) % mod;       rf[i] = (rf[i - 1] * inv[i]) % mod;     }     catlen[1] = 1;     for (int i = 1; i <= 2000; i++)       catlen[i + 1] =           (inv[i + 1] * (((fac[2 * i] * rf[i]) % mod * rf[i]) % mod)) % mod;     scanf( %s , in);     printf( %d n , solve());     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int read() {     int nm = 0, fh = 1;     char cw = getchar();     for (; !isdigit(cw); cw = getchar())       if (cw ==  - ) fh = -fh;     for (; isdigit(cw); cw = getchar()) nm = nm * 10 + (cw -  0 );     return nm * fh;   }   struct node {     int x, y, w;   } p[1000010];   int fa[1000010], cnt[1000010], vis[1000010], n, m, k;   bool cmp(node x1, node x2) { return x1.w < x2.w; }   int fd(int x) { return x == fa[x] ? x : fa[x] = fd(fa[x]); }   bool merge(int x, int y) {     int t1 = fd(x), t2 = fd(y);     if (t1 == t2) return false;     fa[t1] = t2;     cnt[t2] += cnt[t1];     if (cnt[t2] == k) return true;     return false;   }   int main() {     n = read(), m = read(), k = read();     for (int i = 1; i <= k; i++) vis[read()] = 1;     for (int i = 1; i <= n; i++) {       fa[i] = i;       if (vis[i]) cnt[i] = 1;     }     for (int i = 1; i <= m; i++)       p[i].x = read(), p[i].y = read(), p[i].w = read();     sort(p + 1, p + m + 1, cmp);     for (int i = 1; i <= m; i++) {       if (merge(p[i].x, p[i].y)) {         for (int j = 1; j <= k; j++) printf( %d  , p[i].w);         return 0;       }     }     return 0;   }
#include <bits/stdc++.h>      using namespace std;      const int N = 300;   int a[N];      void solve(){       int n;       cin >> n;       for(int i = 0; i < n; i++){           cin >> a[i];       }          int left = 0, right = n - 1, index = 1;       while(left <= right){           if(index++ % 2){               cout << a[left++] <<    ;           }           else{               cout << a[right--] <<    ;           }       }       cout <<   n ;   }   int main(void){       ios::sync_with_stdio(false); cin.tie(NULL);       int t;       cin >> t;       while(t--) solve();       return 0;   }
#include <bits/stdc++.h>   using namespace std;   long n, m;   char c;   long hi[600000][3], hj[600000][3], ans;   long temp;   long l, u;   int main() {     ios_base::sync_with_stdio(0);     cin >> n >> m;     for (int i = 1; i <= n; i++)       for (int j = 1; j <= m; j++) {         cin >> c;         if (c ==  . ) continue;         temp = c - 48;         if (temp < 3)           l = 1;         else           l = 0;         if (l % 2 == j % 2)           hi[i][1] = 1;         else           hi[i][0] = 1;         if (temp == 1 || temp == 4)           u = 1;         else           u = 0;         if (u % 2 == i % 2)           hj[j][1] = 1;         else           hj[j][0] = 1;       }     ans = 1;     for (int i = 1; i <= n; i++) {       temp = 2;       temp -= hi[i][0] + hi[i][1];       ans = ans * temp % 1000003;     }     for (int i = 1; i <= m; i++) {       temp = 2;       temp -= hj[i][0] + hj[i][1];       ans = ans * temp % 1000003;     }     cout << ans << endl;     cin.get();     cin.get();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   string a, b;   bool x, y;   bool solve(string a, string b) {     char x =  e , y =  e ;     if (a[0] !=  X ) {       x = a[0];     }     if (a[1] !=  X ) {       if (x ==  e )         x = a[1];       else         y = a[1];     }     if (b[1] !=  X ) {       if (y ==  e ) y = b[1];     }     return (x ==  A  && y ==  B ) || (x ==  B  && y ==  C ) ||            (x ==  C  && y ==  A );   }   int main() {     cin >> a >> b;     x = solve(a, b);     cin >> a >> b;     y = solve(a, b);     if (x == y) {       cout <<  YES  << endl;     } else {       cout <<  NO  << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int mod = 1e9 + 7;   struct rec {     int x1, y1, x2, y2;   };   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(0);     vector<rec> v;     int n;     cin >> n;     multiset<int> x1, x2, y1, y2;     for (int i = 0; i < n; i++) {       rec r;       cin >> r.x1 >> r.y1 >> r.x2 >> r.y2;       v.push_back(r);       x1.insert(r.x1);       x2.insert(r.x2);       y1.insert(r.y1);       y2.insert(r.y2);     }     for (auto i : v) {       x1.erase(x1.find(i.x1));       x2.erase(x2.find(i.x2));       y1.erase(y1.find(i.y1));       y2.erase(y2.find(i.y2));       if (*x1.rbegin() <= *x2.begin() and *y1.rbegin() <= *y2.begin()) {         cout << *x1.rbegin() <<     << *y1.rbegin() <<   n ;         return 0;       }       x1.insert(i.x1);       x2.insert(i.x2);       y1.insert(i.y1);       y2.insert(i.y2);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int l[200100], r[200100];   bool cmp(int a, int b) {     if (l[a] == l[b])       return r[a] < r[b];     else       return l[a] < l[b];   }   int main() {     int n, i, j, k;     int h[200100];     cin >> n;     for (i = 1; i <= n; i++) {       scanf( %d%d , &l[i], &r[i]);       h[i] = i;     }     sort(h + 1, h + n + 1, cmp);     for (i = 2; i <= n; i++) {       if (l[h[i - 1]] == l[h[i]]) {         cout << h[i - 1] << endl;         return 0;       }       if (r[h[i - 1]] >= r[h[i]]) {         cout << h[i] << endl;         return 0;       }     }     for (i = 2; i < n; i++) {       if (r[h[i - 1]] + 1 >= l[h[i + 1]]) {         cout << h[i] << endl;         return 0;       }     }     cout << -1 << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     double a[20] = {0};     int i = 0;     for (i = 0; i < 16; i++) cin >> a[i];     double x1 = a[0], x2 = a[2], x3 = a[4], x4 = a[6];     double y1 = a[1], y2 = a[3], y3 = a[5], y4 = a[7];     double maxx = max(x1, (max(x2, max(x3, x4))));     double minx = min(x1, (min(x2, min(x3, x4))));     double maxy = max(y1, (max(y2, max(y3, y4))));     double miny = min(y1, (min(y2, min(y3, y4))));     double centre2x = (a[8] + a[12]) / 2.00;     double centre2y = (a[9] + a[13]) / 2.00;     if (minx <= centre2x && centre2x <= maxx && miny <= centre2y &&         centre2y <= maxy) {       cout <<  YES  <<   n ;       return 0;     }     if (minx <= a[8] && a[8] <= maxx && miny <= a[9] && a[9] <= maxy) {       cout <<  YES  <<   n ;       return 0;     }     if (minx <= a[10] && a[10] <= maxx && miny <= a[11] && a[11] <= maxy) {       cout <<  YES  <<   n ;       return 0;     }     if (minx <= a[12] && a[12] <= maxx && miny <= a[13] && a[13] <= maxy) {       cout <<  YES  <<   n ;       return 0;     }     if (minx <= a[14] && a[14] <= maxx && miny <= a[15] && a[15] <= maxy) {       cout <<  YES  <<   n ;       return 0;     }     for (i = 0; i < 16; i += 2) {       double x = (a[i] + a[i + 1]) / sqrt(2);       double y = (a[i] - a[i + 1]) / sqrt(2);       a[i] = x;       a[i + 1] = y;     }     x1 = a[0 + 8], x2 = a[2 + 8], x3 = a[4 + 8], x4 = a[6 + 8];     y1 = a[1 + 8], y2 = a[3 + 8], y3 = a[5 + 8], y4 = a[7 + 8];     maxx = max(x1, (max(x2, max(x3, x4))));     minx = min(x1, (min(x2, min(x3, x4))));     maxy = max(y1, (max(y2, max(y3, y4))));     miny = min(y1, (min(y2, min(y3, y4))));     centre2x = (a[8 - 8] + a[12 - 8]) / 2.00;     centre2y = (a[9 - 8] + a[13 - 8]) / 2.00;     if (minx <= centre2x && centre2x <= maxx && miny <= centre2y &&         centre2y <= maxy) {       cout <<  YES  <<   n ;       return 0;     }     if (minx <= a[8 - 8] && a[8 - 8] <= maxx && miny <= a[9 - 8] &&         a[9 - 8] <= maxy) {       cout <<  YES  <<   n ;       return 0;     }     if (minx <= a[10 - 8] && a[10 - 8] <= maxx && miny <= a[11 - 8] &&         a[11 - 8] <= maxy) {       cout <<  YES  <<   n ;       return 0;     }     if (minx <= a[12 - 8] && a[12 - 8] <= maxx && miny <= a[13 - 8] &&         a[13 - 8] <= maxy) {       cout <<  YES  <<   n ;       return 0;     }     if (minx <= a[14 - 8] && a[14 - 8] <= maxx && miny <= a[15 - 8] &&         a[15 - 8] <= maxy) {       cout <<  YES  <<   n ;       return 0;     }     cout <<  NO  <<   n ;     return 0;   }