malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   const long long N = 2e5 + 7;   long long l[N], r[N];   long long a[N];   bool used[N];   signed main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     long long n;     cin >> n;     string second;     cin >> second;     for (long long i = 0; i < n; ++i) cin >> a[i];     set<pair<long long, long long> > ms;     for (long long i = 0; i < n; ++i) {       l[i] = i - 1;       r[i] = i + 1;     }     r[n] = n;     for (long long i = 0; i < n - 1; ++i) {       if (second[i] != second[i + 1]) {         ms.insert(make_pair(abs(a[i] - a[i + 1]), i));       }     }     vector<pair<long long, long long> > ans;     while (ms.size()) {       long long i = ms.begin()->second;       ms.erase(ms.begin());       if (used[i] || used[r[i]]) continue;       ans.push_back(make_pair(i, r[i]));       used[i] = used[r[i]] = 1;       long long tl = l[i];       long long tr = r[r[i]];       ms.erase(make_pair(abs(a[tl] - a[i]), tl));       ms.erase(make_pair(abs(a[tr] - a[r[i]]), r[i]));       if (tl != -1) r[tl] = tr;       if (tr != n) l[tr] = tl;       if (tl != -1 && tr != n && second[tl] != second[tr]) {         ms.insert(make_pair(abs(a[tl] - a[tr]), tl));       }     }     cout << ans.size() <<   n ;     for (auto e : ans) cout << e.first + 1 <<     << e.second + 1 <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long int n, t, c, i, x, suma, resultado;     cin >> n >> t >> c;     suma = 0;     resultado = 0;     for (i = 0; i < n; i++) {       cin >> x;       if (x > t)         suma = 0;       else         suma++;       if (suma >= c) resultado++;     }     cout << resultado;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     unsigned long long n, i, j, sum, k, temp;     scanf( %llu , &n);     unsigned long long a[n];     for (i = 0; i < n; i++) {       scanf( %llu , &a[i]);     }     sum = 0;     sort(a, a + n);     k = n / 2;     for (i = 0; i < k; i++) {       temp = (a[i] + a[n - 1 - i]);       sum += (temp * temp);     }     printf( %llu n , sum);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 100000, LOG = 20;   vector<vector<int>> g(N), p(N, vector<int>(LOG));   vector<int> d(N), tin(N), tout(N);   int f = 1;   void dfs(int u, int pr, int depth) {     p[u][0] = pr;     tin[u] = f++;     for (int i = 1; i < LOG; i++) {       p[u][i] = p[p[u][i - 1]][i - 1];     }     d[u] = depth;     for (auto v : g[u]) {       if (v != pr) {         dfs(v, u, depth + 1);       }     }     tout[u] = f++;   }   bool is_ancestor(int u, int v) {     return tin[u] <= tin[v] && tout[u] >= tout[v];   }   int lca(int u, int v) {     if (is_ancestor(u, v)) {       return u;     }     if (is_ancestor(v, u)) {       return v;     }     for (int i = LOG - 1; i >= 0; i--) {       if (!is_ancestor(p[u][i], v)) {         u = p[u][i];       }     }     return p[u][0];   }   int dist(int u, int v) {     int a = lca(u, v);     return d[u] + d[v] - 2 * d[a];   }   int main() {     int n;     scanf( %d , &n);     for (int i = 0; i < n - 1; i++) {       int u, v;       scanf( %d %d , &u, &v);       g[--u].push_back(--v);       g[v].push_back(u);     }     dfs(0, 0, 0);     int q;     scanf( %d , &q);     for (int i = 0; i < q; i++) {       int a, b, x, y, k;       scanf( %d %d %d %d %d , &x, &y, &a, &b, &k);       --a, --b, --x, --y;       int distance = dist(a, b);       if (distance <= k && distance % 2 == k % 2) {         puts( yes );         continue;       }       distance = dist(a, x) + 1;       distance += dist(b, y);       if (distance <= k && distance % 2 == k % 2) {         puts( yes );         continue;       }       distance = dist(a, y) + 1;       distance += dist(b, x);       if (distance <= k && distance % 2 == k % 2) {         puts( yes );         continue;       }       puts( no );     }   }
#include <bits/stdc++.h>   using namespace std;   vector<tuple<int, int, int, int> > ask;   int mat[105][105];   int main() {     int n, m, q, op, r, c, x, i, j;     scanf( %d%d%d , &n, &m, &q);     for (i = 0; i < q; i++) {       scanf( %d , &op);       if (op == 1 || op == 2) {         scanf( %d , &x);         ask.emplace_back(op, x, 0, 0);       } else {         scanf( %d%d%d , &r, &c, &x);         ask.emplace_back(op, r, c, x);       }     }     for (i = ask.size() - 1; i >= 0; i--) {       tie(op, r, c, x) = ask[i];       if (op == 1)         for (j = m - 1; j >= 1; j--) swap(mat[r][j + 1], mat[r][j]);       else if (op == 2)         for (j = n - 1; j >= 1; j--) swap(mat[j + 1][r], mat[j][r]);       else         mat[r][c] = x;     }     for (i = 1; i <= n; i++) {       for (j = 1; j <= m; j++) printf( %d  , mat[i][j]);       printf(  n );     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     cin >> n;     int arr[n];     for (int i = 1; i <= n; i++) cin >> arr[i];     int ans = 0, ct0 = 0, ct1;     for (int i = 1; i <= n; i++) {       if (arr[i] == 1) {         ct1 = 0;         for (int j = i; j <= n; j++) {           if (arr[j] == 1) {             ct1 += 1;           }         }         ans = max(ans, ct0 + ct1);       } else {         ct0 += 1;         ans = max(ans, ct0);       }     }     cout << ans << endl;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 1e5 + 10;   int n, ch, x, y;   vector<int> path[maxn];   vector<int> ans;   int main() {     scanf( %d , &n);     for (int i = 1; i < n; i++) {       scanf( %d%d , &x, &y);       path[x].push_back(y);       path[y].push_back(x);     }     ch = 0;     for (int i = 1; i <= n; i++)       if (path[i].size() > 2) {         if (ch == 0)           ch = i;         else {           puts( No );           return 0;         }       }     if (ch == 0) {       puts( Yes );       puts( 1 );       x = y = 0;       for (int i = 1; i <= n; i++)         if (path[i].size() == 1) {           if (x == 0)             x = i;           else             y = i;         }       printf( %d %d n , x, y);     } else {       puts( Yes );       ans.clear();       for (int i = 1; i <= n; i++)         if (path[i].size() == 1) ans.push_back(i);       printf( %d n , ans.size());       for (int i = 0; i < ans.size(); i++) printf( %d %d n , ch, ans[i]);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   using ll = long long;   int const N = 200 * 1000 + 16;   int const M = 1000 * 1000 * 1000 + 7;   int n;   int a[320];   int f[616];   int ncr[616][616];   int dp[616][616];   struct dsu {     int fa[500];     dsu(int n) { iota(fa, fa + n + 10, 0); }     int find(int x) { return fa[x] == x ? x : fa[x] = find(fa[x]); }     void unite(int x, int y) { fa[find(x)] = find(y); }   };   int main() {     cin.tie(0);     cin.sync_with_stdio(0);     cin >> n;     for (int i = 0; i < n; ++i) cin >> a[i];     dsu u(n);     for (int i = 0; i < n; ++i)       for (int j = i + 1; j < n; ++j) {         ll x = 1ll * a[i] * a[j];         ll s = sqrt(x) + 0.5;         if (s * s == x) u.unite(i, j);       }     memset(a, 0, sizeof a);     for (int i = 0; i < n; ++i) a[u.find(i)]++;     sort(a, a + n, greater<int>());     int m = find(a, a + n, 0) - a;     for (int i = 0; i < 616; ++i) ncr[i][0] = ncr[i][i] = 1;     for (int i = 1; i < 616; ++i)       for (int j = 1; j < i; ++j)         ncr[i][j] = (ncr[i - 1][j] + ncr[i - 1][j - 1]) % M;     f[0] = 1;     for (int i = 1; i < 616; ++i) f[i] = 1ll * i * f[i - 1] % M;     dp[0][a[0] - 1] = 1;     int k = a[0];     for (int i = 1; i < m; ++i) {       int len = a[i];       for (int p = 0; p < k; ++p) {         int x = dp[i - 1][p];         if (not x) continue;         for (int g = 1; g <= len; ++g) {           for (int u = min({len, p, g}); u >= 0; --u) {             ll y = 1ll * ncr[k - p + 1][g - u] * ncr[p][u] % M;             y *= ncr[len - 1][g - 1];             y %= M;             dp[i][p - u + len - g] += x * y % M;             dp[i][p - u + len - g] %= M;           }         }       }       k += len;     }     int ans = dp[m - 1][0];     for (int i = 0; i < m; ++i) ans = 1ll * ans * f[a[i]] % M;     cout << ans;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 111;   int a[N], b[N];   int main() {     cin.tie(0)->sync_with_stdio(0);     int t;     cin >> t;     while (t--) {       queue<int> que;       int n;       cin >> n;       string S;       cin >> S;       S =     + S;       for (int i = 1; i <= n; i++) {         if (S[i] ==  R ) {           a[i] = 1;           b[i] = 1;           que.push(i);         } else if (S[i] ==  B ) {           a[i] = 2;           b[i] = 2;           que.push(i);         } else {           a[i] = 3;           b[i] = 3;         }       }       if (que.empty()) {         for (int i = 1; i <= n; i++) {           if (i % 2 == 1)             cout <<  R ;           else             cout <<  B ;         }         cout <<   n ;         continue;       }       while (!que.empty()) {         int x = que.front();         que.pop();         int left = x - 1;         int right = x + 1;         while (b[left] == 3 && left >= 1) {           if (b[left + 1] == 1) {             b[left] = 2;             left--;           } else {             b[left] = 1;             left--;           }         }         while (b[right] == 3 && right <= n) {           if (b[right - 1] == 1) {             b[right] = 2;             right++;           } else {             b[right] = 1;             right++;           }         }       }       for (int i = 1; i <= n; i++) {         if (b[i] == 1)           cout <<  R ;         else           cout <<  B ;       }       cout <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long solve(int n) {     if (n < 5) return n * (n - 1) / 2;     long long ans = 0;     int x = 0;     for (int i = 0; i <= 8; i++) {       int xx = 5 * pow(10, i);       if (n < xx) {         if (n < 2 * xx / 10) {           if (n != 2 * xx / 10 - 1)             return n - xx / 10 + 1;           else             return n - xx / 10;         }         x = i;         break;       }       if (i == 8) {         if (n < 1000000000) {           if (n != 999999999)             return n - 500000000 + 1;           else             return n - 500000000;         }         x = i + 1;         break;       }     }     int p = pow(10, x);     ans += (n / p) * (n / p) * (p / 2);     ans += (n % p) * (n / p);     if (n % p >= p / 2) ans += (n % p) - p / 2 + 1;     if (n % p == p - 1) ans--;     return ans;   }   int main() {     int n;     cin >> n;     long long ans = solve(n);     cout << ans;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 180 + 10;   const int oo = 1000000000;   int opt[maxn][maxn * 2];   int c[maxn][maxn * 2], cc[maxn][maxn * 2];   int e[maxn][maxn];   int n, kk, d[maxn];   int father[maxn];   int res[maxn];   void dp(int u) {     for (int v = 1; v <= n; v++)       if (e[u][v] && v == father[u]) e[u][v] = 0;     for (int v = 1; v <= n; v++)       if (e[u][v]) {         father[v] = u;         dp(v);       }     for (int i = 1; i <= n; i++) {       int w = i - n, o = 0;       for (int v = 1; v <= n; v++)         if (e[u][v]) {           int o2 = opt[v][i - 1];           for (int j = n; j <= n * 2; j++) o2 = min(o2, opt[v][j]);           o += o2;           o = min(o, oo);         }       if (w == 0)         o += kk;       else         o += d[-w];       opt[u][i] = o;     }     int best[maxn];     for (int i = n + 1; i < n * 2; i++) {       for (int v = 1; v <= n; v++)         if (e[u][v]) {           best[v] = oo;           for (int j = i - 1; j <= n * 2; j++) best[v] = min(best[v], opt[v][j]);           best[v] = min(best[v], opt[v][n + n - i - 1]);         }       for (int v = 1; v <= n; v++)         if (e[u][v]) {           int o = opt[v][i - 1];           for (int w = 1; w <= n; w++)             if (w != v && e[u][w]) {               o += best[w];               o = min(o, oo);             }           o += d[i - n];           if (o < opt[u][i]) {             opt[u][i] = o;             cc[u][i] = v;           }         }     }   }   void dfs(int u, int w, int p) {     if (w == n) p = u;     if (w <= n) {       res[u] = p;       for (int v = 1; v <= n; v++)         if (e[u][v]) {           int o = w - 1;           for (int j = n; j <= n * 2; j++)             if (opt[v][j] < opt[v][o]) o = j;           dfs(v, o, p);         }     } else {       int o = cc[u][w];       dfs(o, w - 1, p);       res[u] = res[o];       for (int v = 1; v <= n; v++)         if (v != o && e[u][v]) {           int _o = n + n - w - 1;           for (int j = w - 1; j <= n * 2; j++)             if (opt[v][j] < opt[v][_o]) _o = j;           dfs(v, _o, res[u]);         }     }   }   int main() {     scanf( %d%d , &n, &kk);     for (int i = 1; i < n; i++) scanf( %d , &d[i]);     for (int i = 1, u, v; i < n; i++) {       scanf( %d%d , &u, &v);       e[u][v] = e[v][u] = 1;     }     for (int i = 1; i <= n; i++)       for (int j = 0; j <= n * 2 + 1; j++) opt[i][j] = oo;     dp(1);     int best = n;     for (int i = n; i <= n * 2; i++)       if (opt[1][i] < opt[1][best]) best = i;     dfs(1, best, 0);     printf( %d n , opt[1][best]);     for (int i = 1; i <= n; i++) printf( %d%c , res[i], i == n ?   n  :    );   }
#include <bits/stdc++.h>   using namespace std;   int f(int x, int p2, int p) { return 2 * sqrt(p2 * p) + x + 1; }   int main() {     printf( 302 n );     printf( 0 1000000 n );     int a = f(0, 1000000, 300);     printf( %d 300 n , a);     int kol = 2;     for (int i = 299; i >= 1; --i) {       printf( %d %d n , f(a, i + 1, i), i);       a = f(a, i + 1, i);       kol++;     }     printf( %d 1000000 n , f(a, 1000000, 1));     kol++;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   namespace Debug {   void __print(signed x) { cout << x; }   void __print(long x) { cout << x; }   void __print(long long x) { cout << x; }   void __print(unsigned x) { cout << x; }   void __print(unsigned long x) { cout << x; }   void __print(unsigned long long x) { cout << x; }   void __print(float x) { cout << x; }   void __print(double x) { cout << x; }   void __print(long double x) { cout << x; }   void __print(char x) { cout <<      << x <<     ; }   void __print(const char *x) { cout <<     << x <<    ; }   void __print(const string &x) { cout <<     << x <<    ; }   void __print(bool x) { cout << (x ?  true  :  false ); }   template <typename T, typename V>   void __print(const pair<T, V> &x) {     cout <<  { ;     __print(x.first);     cout <<  , ;     __print(x.second);     cout <<  } ;   }   template <typename T>   void __print(const T &x) {     long long f = 0;     cout <<  { ;     for (auto &i : x) cout << (f++ ?  ,  :   ), __print(i);     cout <<  } ;   }   void _print() { cout <<  ]  << endl; }   template <typename T, typename... V>   void _print(T t, V... v) {     __print(t);     if (sizeof...(v)) cout <<  ,  ;     _print(v...);   }   }  // namespace Debug   using namespace Debug;   const bool DEBUG = true;   long long calc_score(long long idx, long long n, long long k,                        vector<long long> &arr, long long time_left) {     long long score = 0ll;     for (long long i = 0; i < k; i++) {       for (long long j = idx; j <= n; j++) {         if (time_left < arr[i]) return score;         ++score;         time_left -= arr[i];       }     }     return score;   }   void process() {     long long n, k, M;     cin >> n >> k >> M;     vector<long long> arr(k);     for (long long i = 0; i < k; i++) cin >> arr[i];     long long res = 0ll, sum = accumulate(arr.begin() + 0, arr.begin() + k, 0ll);     sort(arr.begin() + 0, arr.begin() + k);     for (long long i = 0; i <= n; i++) {       if (sum * i > M) continue;       long long score = i * (k + 1);       long long time_left = M - (sum * i);       score += calc_score(i + 1, n, k, arr, time_left);       res = max(res, score);     }     cout << res <<   n ;   }   signed main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     ;     long long t = 1;     while (t--) process();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int arr[100005];   int main() {     int n, j = 1;     scanf( %d , &n);     int ara[n];     for (int i = 0; i < n; i++) {       scanf( %d , &ara[i]);       if (arr[ara[i]] != 0 || ara[i] > n) ara[i] = -1;       arr[ara[i]]++;     }     for (int i = 0; i < n; i++) {       if (ara[i] == -1) {         while (arr[j] != 0) j++;         ara[i] = j;         arr[j] = 1;       }     }     for (int i = 0; i < n; i++) printf( %d  , ara[i]);   }
#include <bits/stdc++.h>   using namespace std;   struct node {     bool lose, win;     node *child[30];     node() {       lose = true;       win = false;       for (int i = 0; i < 30; i++) child[i] = NULL;     }     void add(queue<char> q) {       if (q.empty()) return;       queue<char> p = q;       char c = q.front();       q.pop();       int t = c -  a ;       if (child[t] == NULL) {         child[t] = new node();         lose = win = false;       }       child[t]->add(q);     }     void dfs() {       bool p = true;       for (int i = 0; i < 30; i++)         if (child[i] != NULL) p = false;       if (p) return;       for (int i = 0; i < 30; i++)         if (child[i] != NULL) {           child[i]->dfs();           if (child[i]->win == false) win = true;           if (child[i]->lose == false) lose = true;         }     }   };   node *root;   int main() {     root = new node();     int n, k;     cin >> n >> k;     for (int i = 0; i < n; i++) {       string s;       cin >> s;       queue<char> q;       for (int j = 0; j < s.length(); j++) q.push(s[j]);       root->add(q);     }     root->dfs();     if (root->lose && root->win)       cout <<  First  << endl;     else if (!root->lose && !root->win)       cout <<  Second  << endl;     else if (root->lose)       cout <<  Second  << endl;     else if (k % 2)       cout <<  First  << endl;     else       cout <<  Second  << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <class T>   void smin(T& a, T val) {     if (a > val) a = val;   }   template <class T>   void smax(T& a, T val) {     if (a < val) a = val;   }   template <typename T>   inline std::ostream& operator<<(std::ostream& os, const std::vector<T>& v) {     bool first = true;     os <<  [ ;     for (auto i : v) {       if (!first) os <<  ,  ;       os << i;       first = false;     }     return os <<  ] ;   }   const int MAX = 100010;   int n, u, e[MAX];   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     cin >> n >> u;     cout << fixed << setprecision(20);     for (int i = 0; i < n; ++i) {       cin >> e[i];     }     int l = 0, r = 0, tot = 0;     long double ans1 = -1.0;     while (l < n) {       tot = 0;       while (r < n and (e[r] - e[l]) <= u) {         ++r;       }       if ((r - l) > 2) {         int t = r - 1;         ans1 = max(ans1,                    (long double)(1. * (e[t] - e[l + 1])) / (1. * (e[t] - e[l])));       }       ++l;     }     cout << ans1;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int a[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};   vector<int> parse(string s) {     int i, dd, mm, yy;     for (int i = 0; i < (int)(s.length()); i++)       if (s[i] ==  . ) s[i] =    ;     istringstream ss(s);     ss >> dd >> mm >> yy;     vector<int> ans;     ans.push_back(dd);     ans.push_back(mm);     ans.push_back(yy);     return ans;   }   bool legal(vector<int> v) {     int d = v[0], m = v[1], y = v[2];     if (y % 4 == 0 && m == 2 && d == 29) return true;     if (m <= 12 && d <= a[m - 1]) return true;     return false;   }   bool func(vector<int> contest, vector<int> birth) {     sort(birth.begin(), birth.end());     do {       if (!legal(birth)) continue;       if (birth[2] < contest[2] - 18) return true;       if (birth[2] == contest[2] - 18) {         if (birth[1] < contest[1]) return true;         if (birth[1] == contest[1] && birth[0] <= contest[0]) return true;       }     } while (next_permutation(birth.begin(), birth.end()));     return false;   }   int main(void) {     string contest, birth;     cin >> contest >> birth;     bool ans = func(parse(contest), parse(birth));     cout << (ans ?  YES  :  NO ) << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, s = 0, a[10000] = {0};     cin >> n;     for (int i = 0; i < n; i++) {       int t;       cin >> t;       a[t]++;     }     for (int i = 1; i < 10000; i++) {       if (a[i] > 1) {         a[i + 1] = a[i + 1] + a[i] - 1;         s = s + a[i] - 1;       }     }     cout << s;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int a[3222], b[32222];   long long dp[3333][3333];   int main() {     int n;     cin >> n;     for (int i = 1; i <= n; i++) {       int x;       cin >> a[i];       a[i] -= i;       b[i] = a[i];     }     sort(b + 1, b + n + 1);     for (int i = 1; i <= n; i++) {       dp[i][1] = dp[i - 1][1] + abs(a[i] - b[1]);       for (int j = 2; j <= n; j++)         dp[i][j] = min(dp[i][j - 1], dp[i - 1][j] + abs(a[i] - b[j]));     }     cout << dp[n][n] << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int T, n, cnt;   struct poi {     double x, y, alp;     poi() {}     poi(double x, double y) : x(x), y(y) { alp = atan2(y, x); }     friend bool operator<(const poi &r1, const poi &r2) {       return r1.alp < r2.alp;     }     friend poi operator+(const poi &r1, const poi &r2) {       return poi(r1.x + r2.x, r1.y + r2.y);     }     friend poi operator-(const poi &r1, const poi &r2) {       return poi(r1.x - r2.x, r1.y - r2.y);     }     friend double operator^(const poi &r1, const poi &r2) {       return r1.x * r2.y - r2.x * r1.y;     }     friend double operator*(const poi &r1, const poi &r2) {       return r1.x * r2.x + r1.y * r2.y;     }     friend poi operator*(double v, const poi &r1) {       return poi(r1.x * v, r1.y * v);     }   } a[210000 << 1], p, w[210000 << 2];   struct line {     poi p, v;     line() {}     line(poi p, poi v) : p(p), v(v) {}   } b[210000 << 2], q[210000 << 2];   void init() {     cnt = 0;     double t = 1e6;     poi p1(t, t), p2(-t, t), p3(-t, -t), p4(t, -t);     b[++cnt] = line(p1, p2 - p1);     b[++cnt] = line(p2, p3 - p2);     b[++cnt] = line(p3, p4 - p3);     b[++cnt] = line(p4, p1 - p4);   }   int insert(poi p1, poi p2) {     double t = (p2 - p1) ^ (p - p1);     if (fabs(t) < 1e-12) return 0;     if (t > 0)       b[++cnt] = line(p1, p2 - p1);     else       b[++cnt] = line(p2, p1 - p2);     return 1;   }   int onleft(poi p1, line l1) { return (l1.v ^ (p1 - l1.p)) > 0; }   int cmp(const line &l1, const line &l2) {     if (fabs(l1.v.alp - l2.v.alp) < 1e-12) return onleft(l1.p, l2);     return l1.v.alp < l2.v.alp;   }   poi intersect(line l1, line l2) {     poi u = l1.p - l2.p;     double tmp = (u ^ l2.v) / (l2.v ^ l1.v);     return l1.p + tmp * l1.v;   }   double HPI() {     int h, r;     sort(b + 1, b + 1 + cnt, cmp);     q[h = r = 1] = b[1];     for (int i = 2; i <= cnt; i++) {       if (fabs(b[i].v.alp - b[i - 1].v.alp) < 1e-12) continue;       while (h < r && !onleft(w[r], b[i])) r--;       while (h < r && !onleft(w[h + 1], b[i])) h++;       q[++r] = b[i];       w[r] = intersect(q[r], q[r - 1]);     }     while (h < r && !onleft(w[r], q[h])) r--;     w[h] = intersect(q[h], q[r]);     if (h + 1 >= r) return 0;     w[r + 1] = w[h];     double ret = 0;     for (int i = h; i <= r; i++) ret += w[i] ^ w[i + 1];     return fabs(ret);   }   int main() {     scanf( %d , &T);     for (; T--;) {       init();       scanf( %d , &n);       n--;       scanf( %lf%lf , &p.x, &p.y);       for (int i = 1; i <= n; i++) {         scanf( %lf%lf , &a[i].x, &a[i].y);         a[i] = a[i] - p;       }       sort(a + 1, a + 1 + n);       int flag = 0;       for (int i = 1; i <= n; i++) {         a[i + n] = a[i];         insert(a[i] + p, a[i + 1] + p);         if (fabs(a[i].alp - a[i + 1].alp) < 1e-12) flag = 1;       }       for (int i = 1, j = 2; i <= n; i++) {         for (; j < i + n && ((a[j] - a[i]) ^ a[i]) < 1e-12; j++)           ;         if (i != j - 1 && !insert(a[i] + p, a[j - 1] + p)) flag = 1;       }       if (flag) {         puts( 0 );         continue;       }       printf( %.8lf n , HPI() / 2.0);     }     return 0;   }