malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   long long int power(long long int a, long long int b) {     long long int ans = 1;     long long int k = a;     while (b) {       if (b % 2 == 1) ans *= k, ans %= 998244353;       k *= k, k %= 998244353;       b /= 2;     }     return ans;   }   int a, b, start;   int z[40];   long long int ans[60];   int y[200010][60];   void swap(int s, int t) {     for (int j = 0; j <= 53; j++) {       int k = y[s][j];       y[s][j] = y[t][j];       y[t][j] = k;     }   }   void func1(int k) {     if (k == start) {       int sum = 0;       for (int j = 0; j < b; j++) sum += z[j] % 2;       ans[sum]++;       return;     }     func1(k + 1);     for (int j = 0; j < b; j++) z[j] += y[k][j];     func1(k + 1);     for (int j = 0; j < b; j++) z[j] -= y[k][j];   }   int diff(long long int a, long long int b) {     int sum = 0;     while (a > 0 || b > 0) {       if (b % 2 == 1) {         if (a % 2 == 0)           sum++;         else           sum--;       }       b /= 2, a /= 2;     }     return sum;   }   std::vector<int> V;   long long int S[20010][40], T[20010][40];   int main() {     scanf( %d%d , &a, &b);     for (int i = 1; i <= a; i++) {       long long int c;       scanf( %lld , &c);       for (int j = 0; j < b; j++) {         y[i][j] = c % 2;         c /= 2;       }     }     start = 1;     for (int j = 0; j < b; j++) {       int p = -1;       for (int i = start; i <= a; i++) {         if (y[i][j] == 1) {           p = i;           break;         }       }       if (p == -1) {         V.push_back(j);         continue;       }       if (p != start) swap(p, start);       for (int i = 1; i <= a; i++) {         if (i == start) continue;         if (y[i][j] == 1)           for (int k = 0; k < b; k++) y[i][k] += y[start][k], y[i][k] %= 2;       }       start++;     }     long long int M = power(2, a - start + 1);     if (start - 1 <= 21) {       func1(1);       for (int j = 0; j <= b; j++) ans[j] *= M, ans[j] %= 998244353;       for (int j = 0; j <= b; j++) printf( %lld  , ans[j]);       return 0;     } else {       int s = 0;       for (int i = 0; i < V.size(); i++) {         s *= 2;         s++;       }       S[0][0] = 1;       for (int i = start - 1; i >= 1; i--) {         int t = 0;         for (int j = 0; j < V.size(); j++) {           t *= 2;           t += y[i][V[j]];         }         for (int j = 0; j <= s; j++)           for (int k = 0; k <= b; k++) T[j][k] = 0;         for (int j = 0; j <= s; j++) {           int d = diff(j, t) + 1;           for (int k = 0; k <= b; k++)             if (k + d >= 0)               T[j ^ t][k + d] += S[j][k], T[j ^ t][k + d] %= 998244353;           for (int k = 0; k <= b; k++) T[j][k] += S[j][k], T[j][k] %= 998244353;         }         for (int j = 0; j <= s; j++)           for (int k = 0; k <= b; k++) S[j][k] = T[j][k];       }       for (int j = 0; j <= s; j++)         for (int k = 0; k <= b; k++) ans[k] += S[j][k], ans[k] %= 998244353;       for (int k = 0; k <= b; k++) ans[k] *= M, ans[k] %= 998244353;       for (int j = 0; j <= b; j++) printf( %lld  , ans[j]);       return 0;     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     cin.sync_with_stdio(0);     cout.sync_with_stdio(0);     int n, a, c, d, k = 0;     cin >> n >> a;     c = floorl(n * a / 180.l);     if (c > n - 2) c = n - 2;     if (c < 1) c = 1;     d = ceill(n * a / 180.l);     if (d > n - 2) d = n - 2;     if (d < 1) d = 1;     if (abs(c * 180.l / n - a) > abs(d * 180.l / n - a)) swap(c, d);     cout <<  1 2   << n - c + 1 <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int z[(int)1e6 + 3];   string z_algo(string s) {     int x = 0, y = 0;     int T = 0, M = (int)1e6 + 3;     for (int i = 1; i < s.size(); i++) {       z[i] = max(0, min(z[i - x], y - i + 1));       while (i + z[i] < s.size() && s[z[i]] == s[i + z[i]]) {         x = i, y = i + z[i];         z[i]++;       }     }     int maxz = 0, res = 0, n = s.size();     int ans = 0;     for (int i = 0; i < n; i++) {       if (i + z[i] == n && maxz >= z[i]) {         ans = max(ans, z[i]);       }       maxz = max(maxz, z[i]);     }     string t;     for (int i = 0; i < ans; i++) t.push_back(s[i]);     if (!ans) return  Just a legend ;     return t;   }   int main() {     int t, tc = 0;     string s, ans;     cin >> s;     ans = z_algo(s);     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   using ll = long long int;   using ii = pair<ll, ll>;   using vi = vector<int>;   using vii = vector<ii>;   using graph = vector<vii>;   const int INF = 0x3f3f3f3f;   const ll INFL = 0x3f3f3f3f3f3f3f3f;   const int MAXN = 2123;   const ll mod = 998244353;   int seen[MAXN], color[MAXN];   string s;   graph g;   bool dfs(int u) {     seen[u] = 1;     int v, type;     for (auto k : g[u]) {       tie(v, type) = k;       if (!seen[v]) {         if (color[v] == -1) color[v] = color[u] ^ type;         if (dfs(v)) return 1;       }       if (color[v] ^ color[u] != type) return 1;     }     return 0;   }   void build(int n) {     for (int i = 0; i < n; ++i) {       seen[i] = 0;       color[i] = -1;     }     color[0] = 0;     color[1] = 1;   }   ll bxp(int xp) {     ll ans = 1, base = 2;     while (xp > 0) {       if (xp & 1) ans = ans * base % mod;       base = base * base % mod;       xp >>= 1;     }     return ans;   }   int main() {     int n, m;     cin >> s;     n = s.size();     ll ans = 0;     for (int k = n - 1; k > 0; --k) {       g.assign(2 + n + k + 1, vii());       for (int i = 2 + n, j = 2 + n + k - 1; i < j; ++i, --j) {         g[i].emplace_back(j, 0);         g[j].emplace_back(i, 0);       }       for (int i = 2, j = 2 + n - 1; i < j; ++i, --j) {         g[i].emplace_back(j, 0);         g[j].emplace_back(i, 0);       }       for (int i = 0, j = 0; i < n; ++i) {         if (s[i] ==  ? ) {           if (i >= n - k) ++j;           continue;         }         if (i < n - k) {           g[i + 2].emplace_back(s[i] -  0 , 0);           g[s[i] -  0 ].emplace_back(i + 2, 0);         } else {           g[i + 2].emplace_back(j + 2 + n, s[i] -  0 );           g[j + 2 + n].emplace_back(i + 2, s[i] -  0 );           ++j;         }       }       build(2 + n + k);       g[1].emplace_back(0, 1);       g[0].emplace_back(1, 1);       g[n + 2].emplace_back(1, 0);       g[1].emplace_back(n + 2, 0);       if (dfs(0)) {         continue;       }       int cnt = 0;       bool skip = 0;       for (int i = 2; i < 2 + n + k && !skip; ++i) {         if (!seen[i]) {           color[i] = 0;           if (dfs(i)) {             skip = 1;           }           ++cnt;         }       }       if (skip) continue;       ans += bxp(cnt);       if (ans >= mod) ans -= mod;     }     cout << ans <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   const long long MOD = 1000000007;   int maina() {     int T;     cin >> T;     for (int _t = 0; _t < T; _t++) {     }     return 0;   }   int main() {     ios::sync_with_stdio(false);     long long N;     cin >> N;     vector<long long> in(N);     for (int i = 0; i < N; ++i) {       cin >> in[i];       in[i]--;     }     vector<long long> cnt(N);     cnt[0] = 2;     long long result = 2;     for (int i = 1; i < N; ++i) {       long long total = 2;       for (int j = in[i]; j < i; ++j) {         total += cnt[j];         total %= MOD;       }       cnt[i] = total;       result += total;       result %= MOD;     }     cout << result;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long n, mod;   long long expsq(long long base, long long exp) {     if (exp == 0) return 1ll;     if (exp == 1) return base;     if (exp & 1)       return (base * expsq((base % mod * base % mod) % mod, (exp - 1) / 2)) % mod;     return expsq((base % mod * base % mod) % mod, exp / 2) % mod;   }   int main() {     cin >> n >> mod;     long long ans = expsq(3ll, n);     ans--;     while (ans < 0) ans += mod;     cout << ans % mod;   }
#include <bits/stdc++.h>   using namespace std;   template <class t>   t mag(t a) {     return a > 0 ? a : -a;   }   template <class T, class U>   T cdiv(T num, U den) {     return (num / den) + ((num % den) > 0);   }   std::ifstream term( /dev/tty );   std::string tempstring;   using ll = int_fast64_t;   using ii = pair<int, int>;   using vi = vector<int>;   using vl = vector<ll>;   using vii = vector<ii>;   const int sij = 60;   const ll mod = 1000000007ll;   vi took[sij];   int m, n;   int esc(int tcase) {     cin >> m >> n;     for (auto i = 0; i != m; i++) {       int tp;       cin >> tp;       for (auto j = 0; j != tp; j++) {         int k;         cin >> k;         took[i].push_back(k);       }       sort(took[i].begin(), took[i].end());     }     for (auto i = 0; i != m - 1; i++) {       set<int> vv;       ;       for (auto &e : took[i]) {         for (auto j = i + 1; j != m; j++) {           ;           ;           if (binary_search(took[j].begin(), took[j].end(), e)) {             vv.insert(j);           }         }       };       if (vv.size() + i + 1 != m) {         cout <<  impossible n ;         exit(0);       }     }     cout <<  possible n ;     return 0;   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     int tc = 1;     for (int i = 1; i <= tc; i++) esc(i);   }
#include <bits/stdc++.h>   using namespace std;   template <typename T>   T Abs(T first) {     return (first < 0 ? -first : first);   }   template <typename T>   T Sqr(T first) {     return (first * first);   }   string plural(string s) {     return (int((s).size()) && s[int((s).size()) - 1] ==  x  ? s +  en                                                               : s +  s );   }   const int INF = (int)1e9;   const long double EPS = 1e-12;   const long double PI = acos(-1.0);   bool Read(int &first) {     char c, r = 0, n = 0;     first = 0;     for (;;) {       c = getchar();       if ((c < 0) && (!r)) return (0);       if ((c ==  - ) && (!r))         n = 1;       else if ((c >=  0 ) && (c <=  9 ))         first = first * 10 + c -  0 , r = 1;       else if (r)         break;     }     if (n) first = -first;     return (1);   }   bool ReadLL(long long &first) {     char c, r = 0, n = 0;     first = 0;     for (;;) {       c = getchar();       if ((c < 0) && (!r)) return (0);       if ((c ==  - ) && (!r))         n = 1;       else if ((c >=  0 ) && (c <=  9 ))         first = first * 10 + c -  0 , r = 1;       else if (r)         break;     }     if (n) first = -first;     return (1);   }   long long A[200005], X[200005], B[200005];   int C[200005];   int ord[200005], cor[200005];   int main() {     if (0) freopen( in.txt ,  r , stdin);     int N, M;     long long K;     int i, j, k, a, b, c, first, second, z, m;     long long v;     Read(N), ReadLL(K);     for (i = 0; i < N; i++) ReadLL(A[i]);     memset(C, 0, sizeof(C));     for (i = 0; i < N; i++) {       ReadLL(X[i]), X[i]--;       C[X[i]]++;     }     for (i = 0; i < N; i++)       if (i && X[i] < X[i - 1]) goto Imp;     if (X[N - 1] != N - 1) goto Imp;     j = k = 0;     for (i = 0; i < N; i++) {       k += C[i];       if (k > i + 1) goto Imp;       if (k == i + 1) {         for (a = j; a <= i; a++)           if (X[a] != i) goto Imp;         if (j && B[j - 1] >= A[j] + K) goto Imp;         for (a = j; a <= i - 1; a++) B[a] = A[a + 1] + K;         if (i == j)           B[i] = A[i] + K;         else           B[i] = B[i - 1] + 1;         j = i + 1;       }     }     if (0) {       memset(cor, -1, sizeof(cor));       for (i = 0; i < N; i++) ord[i] = i;       do {         for (i = 0; i < N; i++)           if (B[ord[i]] < A[i] + K) goto Bad;         for (i = 0; i < N; i++) cor[i] = max(cor[i], ord[i]);       Bad:;       } while (next_permutation(ord, ord + N));       for (i = 0; i < N; i++)         if (X[i] != cor[i]) break;       if (i == N) {       } else {         printf( WRONG n );       }     }     printf( Yes n );     for (i = 0; i < N; i++) {       if (i) printf(   );       cout << B[i];     }     printf(  n );     return (0);   Imp:;     printf( No n );     return (0);   }
#include <bits/stdc++.h>   using namespace std;   void solve() {     long long n;     cin >> n;     long long a[n];     for (long long i = 0; i < n; i++) {       cin >> a[i];     }     sort(a, a + n);     long long moves = 0;     for (long long i = 0; i < n; i++) {       if (a[i] < 1) {         moves = moves + (i + 1) - a[i];       } else if (a[i] > n) {         moves = moves + (a[i] - (i + 1));       } else if (a[i] > (i + 1)) {         moves = moves + (a[i] - (i + 1));       } else {         moves = moves + (i + 1 - a[i]);       }     }     cout << moves;   }   signed main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     long long t = 1;     while (t--) {       solve();       cout <<   n ;     }     cerr <<  time taken:   << (float)clock() / CLOCKS_PER_SEC << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long inf = 1e18 + 7;   long long f[105];   long long g[105];   int main() {     long long n;     cin >> n;     f[1] = 2, f[2] = 3;     g[1] = 2, g[2] = 4;     for (int h = 3; h <= 100; h++) {       f[h] = f[h - 1] + f[h - 2];       g[h] = g[h - 1] + g[h - 1];       if (f[h] > n) break;       g[h] = min(g[h], inf);     }     long long res = 0;     for (int h = 1; h <= 100; h++) {       if (f[h] > n) break;       if (f[h] <= n && g[h] >= n) res = h;     }     cout << res;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void Fast_Read_Out() {     ios_base::sync_with_stdio(0);     cin.tie(), cout.tie();   }   void Random() {     unsigned int seed;     asm( rdtsc  :  =A (seed));     srand(seed);   }   unsigned int Time() {     unsigned int time = clock() / 1000.00;     return time;   }   const int inf = int(1e9) + 123;   int n, sum;   string s;   int main() {     Random();     Fast_Read_Out();     cin >> n;     cin >> s;     for (int i = 0; i < n; i++) sum += s[i] -  0 ;     for (int i = 0; i <= n * 9; i++) {       int cur = 0, cnt = 0, ok = 0, sum1 = 0;       for (int j = 0; j < n; j++) {         if (cur < i) cur += s[j] -  0 ;         if (cur == i) sum1 += cur, cur = 0, cnt++;         if (cur > i) {           ok = 1;           break;         }       }       if (cnt < 2) continue;       if (ok == 1) continue;       if (sum == sum1) cout <<  YES  << endl, exit(0);     }     cout <<  NO  << endl;   }
#include <bits/stdc++.h>   using namespace std;   long long int n, m;   long long int arr[300000];   vector<long long int> ans;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     ;     long long int TESTS, q, a, b, l, r, c, k, p, h, w, x, y, z, xs, ys, t, f;     long double d;     TESTS = 1;     while (TESTS--) {       cin >> n >> p;       long long int maxi = 0;       for (long long int i = 0; i <= n - 1; i++)         cin >> arr[i], maxi = max(maxi, arr[i]);       sort(arr, arr + n);       for (long long int i = 1; i <= maxi; i++) {         long long int num = 1;         x = i;         y = 0;         while (y < n) {           long long int ind = upper_bound(arr, arr + n, x) - arr;           num *= ind - y;           num %= p;           x++;           y++;         }         if (num) ans.push_back(i);       }       cout << ans.size() <<   n ;       for (auto it : ans) cout << it <<    ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }   int main(void) {     long long n, k;     cin >> n >> k;     long long temp = 1;     for (long long i = 1; i <= k; i++) temp *= 10;     cout << n * temp / gcd(temp, n);   }
#include <bits/stdc++.h>   using namespace std;   int64_t mod = 1e9 + 7, inf = 4e18;   map<vector<int64_t>, long double> seen;   long double rec(vector<int64_t> &people, int64_t n, int64_t len) {     if (len < 0) return -1;     if (n == 0) return 0;     if (seen[people]) return seen[people];     long double ans = 0;     for (int64_t i = 0; i < people.size(); i++) {       if (people[i] == 0) continue;       people[i] -= 1;       ans += (1 + rec(people, n - 1, len - i)) * (people[i] + 1) / n;       people[i] += 1;     }     seen[people] = ans;     return ans;   }   int32_t main() {     ios::sync_with_stdio(false), cin.tie(nullptr);     cout << fixed << setprecision(5);     int64_t n, p;     cin >> n;     vector<int64_t> hist(51, 0);     int64_t tmp;     for (int64_t i = 0; i < int64_t(n); ++i) cin >> tmp, hist[tmp]++;     cin >> p;     cout << rec(hist, n, p);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int a[4000];   int main() {     int n, ans1 = 0, ans2 = 0;     cin >> n;     for (int i = 1; i <= n / 2; ++i) cin >> a[i];     sort(a + 1, a + 1 + n / 2);     for (int i = 1; i <= n / 2; ++i) {       ans1 += abs((i * 2 - 1) - a[i]);       ans2 += abs((i * 2) - a[i]);     }     cout << min(ans1, ans2) << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <class T>   void chkmax(T& x, T y) {     x = (x > y ? x : y);   }   template <class T>   void chkmin(T& x, T y) {     x = (x < y ? x : y);   }   int a[6], b[6];   int main() {     for (int i = 0; i < (int)(4); ++i) scanf( %d%d , &a[i], &b[i]);     for (int i = 0; i < (int)(2); ++i) {       bool win = 1;       int j = i ^ 1;       for (int k = 0; k < (int)(2); ++k) {         int p = k ^ 1;         k += 2, p += 2;         if (!(a[i] > b[k] && b[j] > a[p])) win = 0;         k -= 2;       }       if (win) {         printf( Team 1 n );         return 0;       }     }     bool beat[2];     beat[0] = beat[1] = 0;     for (int i = 0; i < (int)(2); ++i) {       bool win = 1;       int j = i ^ 1;       i += 2, j += 2;       for (int k = 0; k < (int)(2); ++k) {         int p = k ^ 1;         if (a[i] > b[k] && b[j] > a[p]) {           beat[k] = 1;         }       }       i -= 2;     }     if (beat[0] && beat[1]) {       printf( Team 2 n );       return 0;     }     printf( Draw n );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   priority_queue<long long> Q[3];   int K[4], T[5];   int n;   void gao() {     int i, j;     for (i = 0; i < 3; ++i) {       for (j = 0; j < K[i]; ++j) Q[i].push(-1);     }     long long ans = 0;     while (n--) {       int ti;       scanf( %d , &ti);       long long now_min = Q[0].top();       now_min = min(now_min, -ti + 0LL);       Q[0].pop();       now_min -= T[0];       Q[0].push(now_min);       long long tmp = Q[1].top();       Q[1].pop();       now_min = min(now_min, tmp);       now_min -= T[1];       Q[1].push(now_min);       tmp = Q[2].top();       Q[2].pop();       now_min = min(now_min, tmp);       now_min -= T[2];       Q[2].push(now_min);       ans = max(ans, -now_min - ti);     }     cout << ans << endl;   }   int main() {     int i, j;     for (i = 0; i < 3; ++i) cin >> K[i];     for (i = 0; i < 3; ++i) cin >> T[i];     cin >> n;     for (i = 0; i < 3; ++i) K[i] = min(K[i], n);     gao();     return 0;   }
#include <bits/stdc++.h>   int main() {     long long count = 0;     long long int n, a[100010], j, i;     scanf( %lld , &n);     for (i = 1; i <= n; i++) scanf( %lld , &a[i]);     for (i = 1; i <= n; i++) {       for (j = i + 1; j <= n; j++)         if (a[i] != a[j]) break;       count += ((j - i - 1) * (j - i)) / 2;       i = j - 1;     }     printf( %lld n , count + n);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAX = 100100;   int a[MAX];   vector<int> ne[MAX];   int fabs(int x) {     if (x < 0) x = -x;     return x;   }   int main() {     int n, m;     int i, j;     int tmp1, tmp2;     long long sum1, sum2, maxdis;     long long ans;     while (scanf( %d %d , &n, &m) != EOF) {       for (i = 0; i < m; i++) scanf( %d , &a[i]);       for (i = 0; i < m - 1; i++) {         if (a[i] != a[i + 1]) {           ne[a[i]].push_back(a[i + 1]);           ne[a[i + 1]].push_back(a[i]);         }       }       maxdis = 0;       ans = 0;       for (i = 1; i <= n; i++) {         if (!ne[i].empty()) {           sort(ne[i].begin(), ne[i].end());           tmp2 = ne[i].size() / 2;           tmp1 = ne[i][tmp2];           sum1 = 0;           sum2 = 0;           for (j = 0; j < ne[i].size(); j++) {             sum1 += fabs(ne[i][j] - tmp1);             sum2 += fabs(ne[i][j] - i);           }           maxdis = max(maxdis, sum2 - sum1);           ans += sum2;         }       }       printf( %I64d n , ans / 2 - maxdis);       for (i = 1; i <= n; i++) ne[i].clear();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long fact[3000002], n, inv[3000002];   long long pw(long long b, long long e) {     long long ans = 1;     while (e) {       if (e & 1) ans = (ans * b) % 1000000007;       b = (b * b) % 1000000007;       e >>= 1;     }     return ans;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     int n;     cin >> n;     ++n;     fact[0] = inv[0] = 1;     for (int i = 1; i <= 2500000; ++i) {       fact[i] = (fact[i - 1] * i) % 1000000007;       inv[i] = pw(fact[i], 1000000007 - 2);     }     long long ans = 2LL * fact[2 * n - 1] * inv[n];     ans %= 1000000007;     ans = ans * inv[n - 1];     ans %= 1000000007;     cout << (ans - 1 + 1000000007) % 1000000007;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 100010;   int F[MAXN] = {0};   int main() {     int N, x, y;     cin >> N;     for (int I = 1; I <= N; I++) {       cin >> x >> y;       int ans = 0;       for (int i = 1; i <= sqrt(x) + 1; i++) {         if (x % i) continue;         if (F[i] + y < I) ans++;         F[i] = I;         int j = x / i;         if (j == i) continue;         if (F[j] + y < I) ans++;         F[j] = I;       }       cout << ans << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   template <typename T>   void LOG(T const& t) {     std::cout << t << endl;   }   template <typename First, typename... Rest>   void LOG(First const& first, Rest const&... rest) {     std::cout << first <<    ;     LOG(rest...);   }   void solve();   int main() {     ios_base::sync_with_stdio(NULL);     cin.tie(NULL);     solve();     return 0;   }   pair<int, int> rec1[4];   pair<int, int> rec2[4];   double area(int x1, int y1, int x2, int y2, int x3, int y3) {     return abs((x1 * (y2 - y3) + x2 * (y3 - y1) + x3 * (y1 - y2)) / 2.0);   }   bool check(int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4,              int x, int y) {     double A = area(x1, y1, x2, y2, x3, y3) + area(x1, y1, x4, y4, x3, y3);     double A1 = area(x, y, x1, y1, x2, y2);     double A2 = area(x, y, x2, y2, x3, y3);     double A3 = area(x, y, x3, y3, x4, y4);     double A4 = area(x, y, x1, y1, x4, y4);     return fabs(A - (A1 + A2 + A3 + A4)) <= 0.0001;   }   void solve() {     int x, y;     for (int i = 0; i < 4; i++) {       cin >> x >> y;       rec1[i] = make_pair(x, y);     }     for (int i = 0; i < 4; i++) {       cin >> x >> y;       rec2[i] = make_pair(x, y);     }     for (int i = -100; i <= 100; i++) {       for (int j = -100; j <= 100; j++) {         if (check(rec2[0].first, rec2[0].second, rec2[1].first, rec2[1].second,                   rec2[2].first, rec2[2].second, rec2[3].first, rec2[3].second, i,                   j) &&             check(rec1[0].first, rec1[0].second, rec1[1].first, rec1[1].second,                   rec1[2].first, rec1[2].second, rec1[3].first, rec1[3].second, i,                   j)) {           cout <<  YES  << endl;           return;         }       }     }     cout <<  NO  << endl;   }