malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   #pragma GCC optimize( O3 )   using namespace std;   const long long MOD = 1e9 + 7;   long long a[200012];   long long in[200021], out[200012];   void solve() {     long long n, m, i, j, c, sum;     i = j = c = sum = 0;     cin >> n;     for (i = 0; i < n; ++i) {       cin >> a[i];       --a[i];       if (a[i] != -1) {         ++in[a[i]];         ++out[i];       }     }     vector<long long> loops;     for (i = 0; i < n; ++i) {       if (in[i] == 0 and out[i] == 0) {         loops.push_back(i);       }     }     if (loops.size() == 1) {       long long init = loops[0];       for (i = 0; i < n; ++i) {         if (in[i] == 0 and i != init) {           a[init] = i;           ++out[init];           ++in[i];           break;         }       }     } else if (loops.size() > 1) {       for (i = 0; i < loops.size(); ++i) {         long long curr = loops[i];         long long nxt = loops[(i + 1) % loops.size()];         a[curr] = nxt;         ++in[nxt];         ++out[curr];       }     }     vector<long long> ins, outs;     for (i = 0; i < n; ++i) {       if (in[i] == 0) ins.push_back(i);       if (out[i] == 0) outs.push_back(i);     }     for (i = 0; i < outs.size(); ++i) {       a[outs[i]] = ins[i];     }     for (i = 0; i < n; ++i) {       cout << a[i] + 1 <<    ;     }     cout <<   n ;   }   signed main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     long long t = 1;     while (t--) {       solve();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   vector<int> prefix_function(const vector<int>& s) {     int n = s.size();     vector<int> pi(n);     for (int i = 1; i < n; ++i) {       int j = pi[i - 1];       while (j > 0 && s[i] != s[j]) j = pi[j - 1];       if (s[i] == s[j]) ++j;       pi[i] = j;     }     return pi;   }   int n;   set<int> f[100005];   int getLen(int a, int b) {     int len = b - a;     if (len <= 0) len += n;     return len;   }   int go(int len) {     if (f[len].size() == 0)       return 1;     else if (f[len].size() < 2)       return -1;     vector<int> diffs;     int last = -1, fir = -1;     for (int x : f[len]) {       if (last == -1)         fir = x;       else         diffs.push_back(getLen(last, x));       last = x;     }     diffs.push_back(getLen(last, fir));     vector<int> pref = prefix_function(diffs);     int cand = diffs.size() - pref.back();     if (diffs.size() % cand == 0 && cand < diffs.size()) {       int sum = 0;       for (int i = 0; i < cand; ++i) sum += diffs[i];       return sum;     }     return -1;   }   long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }   long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }   int main() {     ios::sync_with_stdio(false);     int m;     cin >> n >> m;     for (int i = 0; i < m; ++i) {       int a, b;       cin >> a >> b;       int len = getLen(a, b);       if (2 * len > n || 2 * len == n && a > b) len = n - len, swap(a, b);       f[len].insert(a - 1);     }     long long ans = 1;     for (int i = 1; i < n; ++i) {       if (2 * i == n) continue;       int cur = go(i);       if (cur == -1) {         cout <<  No  << endl;         return 0;       }       ans = lcm(ans, cur);       if (ans >= n) {         cout <<  No  << endl;         return 0;       }     }     if (n % 2 == 0) {       int cur = go(n / 2);       if (cur != -1 && lcm(ans, cur) < n || lcm(ans, n / 2) < n) {       } else {         cout <<  No  << endl;         return 0;       }     }     cout <<  Yes  << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   vector<long long> arr;   long long binarySearchCount(long long n, long long key) {     long long left = 0, right = n;     long long mid;     while (left < right) {       mid = (right + left) >> 1;       if (arr[mid] == key) {         while (mid + 1 < n && arr[mid + 1] == key) mid++;         break;       } else if (arr[mid] > key)         right = mid;       else         left = mid + 1;     }     while (mid > -1 && arr[mid] > key) mid--;     return mid;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     long long n;     cin >> n;     long long x;     for (long long i = 0; i < n; i++) {       cin >> x;       arr.push_back(abs(x));     }     sort(arr.begin(), arr.end());     long long ans = 0;     for (long long i = 0; i < n - 1; i++) {       long long temp = binarySearchCount(n, 2 * arr[i]);       ans += temp - i;     }     cout << ans << endl;   }
#include <bits/stdc++.h>   using namespace std;   const long long mod = 1e9 + 7;   const int N = 2e5 + 5;   inline int read() {     int res = 0, ch, flag = 0;     if ((ch = getchar()) ==  - )       flag = 1;     else if (ch >=  0  && ch <=  9 )       res = ch -  0 ;     while ((ch = getchar()) >=  0  && ch <=  9 ) res = res * 10 + ch -  0 ;     return flag ? -res : res;   }   int n, m, cnt;   struct node {     int x, y;   };   node p[N];   vector<int> data;   int bit[N], t[N];   long long ans;   void add(int i) {     while (i <= m) {       bit[i]++;       i += i & -i;     }   }   int sum(int i) {     int res = 0;     while (i > 0) {       res += bit[i];       i -= i & -i;     }     return res;   }   bool cmp(node a, node b) {     if (a.y != b.y) return a.y > b.y;     return a.x < b.x;   }   int main() {     scanf( %d , &n);     for (int i = 1; i <= n; i++) {       scanf( %d%d , &p[i].x, &p[i].y);       data.push_back(p[i].x);     }     sort(data.begin(), data.end());     data.erase(unique(data.begin(), data.end()), data.end());     m = data.size();     for (int i = 1; i <= n; i++)       p[i].x = lower_bound(data.begin(), data.end(), p[i].x) - data.begin() + 1;     sort(p + 1, p + n + 1, cmp);     for (int i = 1; i <= n;) {       int j = i;       while (j < n && p[j].y == p[j + 1].y) j++;       t[i - 1] = 0;       for (int k = i; k <= j; k++) {         if (sum(p[k].x) - sum(p[k].x - 1) == 0) {           add(p[k].x);           cnt++;         }         t[k] = sum(p[k].x);       }       for (int k = i; k <= j; k++)         ans += 1LL * (t[k] - t[k - 1]) * (cnt - t[k] + 1);       i = j + 1;     }     printf( %I64d n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int seed = 131;   const int maxn = 2e5 + 5;   const int mod = 1e9 + 7;   int n, k;   char a[maxn];   int main() {     scanf( %d%d , &n, &k);     scanf( %s , a + 1);     int cnt1 = 0;     int cnt2 = 0;     k /= 2;     for (int i = 1; i <= n; i++) {       if (cnt1 == k) break;       if (a[i] ==  ( ) {         cnt1++;       } else         cnt2++;       printf( %c , a[i]);     }     for (int i = cnt2; i < k; i++) printf( ) );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int byk[3][3];   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     int n;     cin >> n;     string s;     cin >> s;     for (int i = 0; i < n; i++) {       if (s[i] ==  B ) byk[i % 3][0]++;       if (s[i] ==  G ) byk[i % 3][1]++;       if (s[i] ==  R ) byk[i % 3][2]++;     }     int mini = 10000000;     vector<int> jwb;     vector<int> V;     V.push_back(0);     V.push_back(1);     V.push_back(2);     do {       int x = byk[0][0] + byk[0][1] + byk[0][2];       x -= byk[0][V[0]];       int y = byk[1][0] + byk[1][1] + byk[1][2];       y -= byk[1][V[1]];       int z = byk[2][0] + byk[2][1] + byk[2][2];       z -= byk[2][V[2]];       if (x + y + z < mini) {         mini = x + y + z;         jwb.clear();         jwb.push_back(V[0]);         jwb.push_back(V[1]);         jwb.push_back(V[2]);       }     } while (next_permutation(V.begin(), V.end()));     cout << mini << endl;     for (int i = 0; i < n; i++) {       if (i % 3 == 0) {         if (jwb[0] == 0) cout <<  B ;         if (jwb[0] == 1) cout <<  G ;         if (jwb[0] == 2) cout <<  R ;       }       if (i % 3 == 1) {         if (jwb[1] == 0) cout <<  B ;         if (jwb[1] == 1) cout <<  G ;         if (jwb[1] == 2) cout <<  R ;       }       if (i % 3 == 2) {         if (jwb[2] == 0) cout <<  B ;         if (jwb[2] == 1) cout <<  G ;         if (jwb[2] == 2) cout <<  R ;       }     }     cout << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long INF = 501;   const long long DIM = 3e5 + 1;   int in, n, t, a[DIM];   int main() {     ios_base::sync_with_stdio;     cin.tie(0);     cout.tie(0);     in = scanf( %d , &t);     while (t--) {       in = scanf( %d , &n);       set<int> s;       for (int i = 1; i <= n; i++) {         in = scanf( %d , &a[i]);         s.insert(a[i]);       }       if (s.size() == 1)         printf( -1 n );       else {         auto it = s.end();         it--;         for (int i = 1; i <= n; i++) {           if (a[i] == *it &&               ((i > 1 && a[i - 1] != *it) || (i < n && a[i + 1] != *it))) {             printf( %d n , i);             break;           }         }       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e6 + 5, mod = 1e9 + 7;   int a[N], st[N][20], pos[N][20];   int seg_query(int l, int r) {     int k = log2(r - l + 1);     if (st[l][k] > st[r - (1 << k) + 1][k])       return pos[l][k];     else       return pos[r - (1 << k) + 1][k];   }   long long f[N];   signed main() {     int n;     scanf( %d , &n);     for (int i = 1; i <= n - 1; ++i)       scanf( %d , a + i), st[i][0] = a[i], pos[i][0] = i;     a[n] = n, st[n][0] = pos[n][0] = n;     for (int j = 1; j <= 17; ++j)       for (int i = 1; i + (1 << j) - 1 <= n; ++i)         if (st[i][j - 1] > st[i + (1 << (j - 1))][j - 1])           st[i][j] = st[i][j - 1], pos[i][j] = pos[i][j - 1];         else           st[i][j] = st[i + (1 << (j - 1))][j - 1],           pos[i][j] = pos[i + (1 << (j - 1))][j - 1];     long long ans = 0;     for (int i = n - 1; i >= 1; --i) {       int k = seg_query(i + 1, a[i]);       f[i] = f[k] + n - i - (a[i] - k);       ans += f[i];     }     cout << ans;   }
#include <bits/stdc++.h>   using namespace std;   typedef struct graph {     list<int> edges[1001];   } graph;   void dfs(graph *g, int i, int group[], int gn) {     for (list<int>::iterator it = g->edges[i].begin(); it != g->edges[i].end();          it++) {       if (group[*it] == -1) {         group[*it] = gn;         dfs(g, *it, group, gn);       }     }   }   void printArray(int arr[], int n) {     for (int i = 1; i <= n; i++) cout << arr[i] <<    ;     cout << endl;   }   int main() {     int n;     graph *g = new graph;     cin >> n;     bool flag = false;     int fin[1001], pref[1001], group[1001];     for (int i = 1; i <= n; i++) cin >> fin[i];     for (int i = 1; i <= n; i++) {       cin >> pref[i];       if (i + pref[i] <= n) {         g->edges[i].push_back(i + pref[i]);         g->edges[i + pref[i]].push_back(i);       }       if (i - pref[i] >= 1) {         g->edges[i].push_back(i - pref[i]);         g->edges[i - pref[i]].push_back(i);       }     }     fill_n(group, n + 1, -1);     int gn = 0;     for (int i = 1; i <= n; i++) {       if (group[i] == -1) {         group[i] = gn;         dfs(g, i, group, gn);         gn++;       }     }     for (int i = 1; i <= n; i++) {       if (group[i] == group[fin[i]]) {       } else {         flag = true;         cout <<  NO  << endl;         break;       }     }     if (!flag) {       cout <<  YES  << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   map<vector<int>, int> m;   int main() {     int i, n, k;     cin >> n;     int array[n][2];     int ans = n;     for (i = 0; i < n; i++) {       cin >> array[i][0] >> array[i][1];     }     cin >> k;     for (i = 0; i < n; i++) {       if (array[i][1] >= k) {         break;       }       ans--;     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 20;   const int inf = 1e9;   int dp[N][2];   vector<int> a;   void upd(int& at, int val) { at = max(at, val); }   int main() {     long long n;     scanf( %lld , &n);     while (n) {       a.push_back(n % 10);       n /= 10;     }     for (int i = 0; i < N; i++) {       dp[i][0] = dp[i][1] = -inf;     }     dp[0][0] = 0;     for (int i = 0; i < a.size(); i++) {       for (int add = 0; add <= 10; add += 10) {         for (int st = 0; st <= 1; st++) {           int sum = add + a[i] - st;           for (int j = 0; j <= min(9, sum); j++) {             int k = sum - j;             if (0 <= k && k <= 9) {               upd(dp[i + 1][add / 10], dp[i][st] + j + k);             }           }         }       }     }     cout << dp[a.size()][0] << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 400004;   const long long Mod = 1000000007;   int Stop, Bcnt, Dindex, Ecnt;   int Low[N], Dfn[N], Step[N], Belong[N];   bool instack[N];   struct Edge {     int t;     int next;   } edge[N];   int head[N];   void addEdge(int s, int t) {     edge[Ecnt].t = t;     edge[Ecnt].next = head[s];     head[s] = Ecnt++;   }   void tarjan(int i) {     int j;     Dfn[i] = Low[i] = ++Dindex;     instack[i] = true;     Step[++Stop] = i;     for (int e = head[i]; e != -1; e = edge[e].next) {       j = edge[e].t;       if (!Dfn[j]) {         tarjan(j);         if (Low[j] < Low[i]) Low[i] = Low[j];       } else if (instack[j] && Dfn[j] < Low[i])         Low[i] = Dfn[j];     }     if (Dfn[i] == Low[i]) {       Bcnt++;       do {         j = Step[Stop--];         instack[j] = false;         Belong[j] = Bcnt;       } while (j != i);     }   }   void init() {     Ecnt = 0;     memset(head, -1, sizeof(head));   }   void solve(int n) {     int i;     Stop = Bcnt = Dindex = 0;     memset(Dfn, 0, sizeof(Dfn));     memset(Low, -1, sizeof(Low));     memset(instack, 0, sizeof(instack));     for (i = 1; i <= n; i++) {       if (!Dfn[i]) {         tarjan(i);       }     }   }   long long num[N];   long long Pow(int x, int y) {     long long a = (long long)x;     long long b = y;     long long ans = 1;     if (b == 0) return 1ll;     while (b > 0) {       if (b & 1) {         ans = (ans * (long long)a) % Mod;       }       a *= a;       a %= Mod;       b >>= 1;     }     return ans;   }   int main() {     int n, x;     while (~scanf( %d , &n)) {       init();       for (int i = 1; i <= n; i++) {         scanf( %d , &x);         addEdge(i, x);       }       solve(n);       memset(num, 0, sizeof(num));       for (int i = 1; i <= n; i++) {         num[Belong[i]]++;       }       long long ans = 1;       for (int i = 1; i <= n; i++) {         if (num[i]) {           if (num[i] == 1) {             ans = (ans * 2) % Mod;           } else {             long long tm = ((Pow(2, num[i]) - 2) % Mod + Mod) % Mod;             ans = ans * tm % Mod;           }         }       }       printf( %I64d n , ans);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long mod = 1e9 + 7;   const long long maxn = 3 * 1e5 + 1;   void swap(long long *xp, long long *yp) {     long long temp = *xp;     *xp = *yp;     *yp = temp;   }   void print(vector<long long> v) {     long long i, j, n = v.size();     for (i = 0; i < n; i++) {       cout << v[i] <<    ;     }     cout <<   n ;   }   void scan(vector<long long> &v, long long n) {     for (long long i = 0; i < n; i++) cin >> v[i];   }   long long gcd(long long a, long long b) {     if (b == 0) return a;     return gcd(b, a % b);   }   long long lcm(long long a, long long b) { return (a * b) / gcd(a, b); }   long long power(long long x, long long y) {     long long res = 1;     while (y > 0) {       if (y & 1) res = (res * x) % mod;       y = y / 2;       x = (x * x) % mod;     }     return res % mod;   }   long long modinv(long long x) { return power(x, mod - 2) % mod; }   vector<bool> prime(maxn, true);   void sieve() {     long long n = maxn;     prime[0] = false;     prime[1] = false;     for (long long p = 2; p * p <= n; p++) {       if (prime[p] == true) {         for (long long i = p * p; i <= n; i += p) prime[i] = false;       }     }   }   int main() {     long long int i, j, inc, dec, t, r;     long long int c, d, e, temp, m, p, w, k, x, y, sum, pre, temp2, mid, n, low,         high, ans;     t = 1;     n = 1;     while (t--) {       cin >> n;       sum = 0;       vector<long long> a;       vector<long long> tem(maxn, 0);       a.push_back(0);       while (n--) {         long long type;         cin >> type;         if (type == 1) {           cin >> x >> y;           sum += (x * y);           tem[x] += y;         } else if (type == 2) {           cin >> k;           a.push_back(k);           sum += k;         } else {           y = a.size();           sum -= (a.back() + tem[y]);           tem[y - 1] += tem[y];           tem[y] = 0;           a.pop_back();         }         x = a.size();         double an = (sum * 1.0) / (x * 1.0);         cout << fixed << setprecision(10) << an <<   n ;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, m, k, arr[1005][1005];   void ch_col(int x, int y) {     for (int i = 1; i <= n; i++) swap(arr[i][x], arr[i][y]);   }   void ch_row(int x, int y) {     for (int i = 1; i <= m; i++) swap(arr[x][i], arr[y][i]);   }   int row[1005], col[1005];   int main() {     for (int i = 1; i <= 1005; i++) {       row[i] = i;       col[i] = i;     }     scanf( %d %d %d , &n, &m, &k);     for (int i = 1; i <= n; i++)       for (int j = 1; j <= m; j++) scanf( %d , &arr[i][j]);     while (k--) {       char order;       int x, y;       scanf(  %c %d %d , &order, &x, &y);       if (order ==  g ) printf( %d n , arr[row[x]][col[y]]);       if (order ==  c ) swap(col[x], col[y]);       if (order ==  r ) swap(row[x], row[y]);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long n, l, t, a[3000010], gx;   double Ans;   signed main() {     scanf( %lld%lld%lld , &n, &l, &t);     t *= 2;     gx = t / l, t %= l;     for (long long i = 1; i <= n; i++) scanf( %lld , &a[i + n]);     for (long long i = 1; i <= n; i++) a[i] = a[i + n] - l;     for (long long i = 1; i <= n; i++) a[i + n + n] = a[i + n] + l;     for (long long i = 1, j1 = 1, j2 = i + 1; i <= n; i++) {       while (a[i + n] - a[j1] > t) j1++;       while (a[j2 + 1] - a[i + n] <= t && j2 + 1 <= 3 * n) j2++;       Ans += 0.25 * ((n - 1) * gx + i + n - j1 + (n - 1) * gx + j2 - i - n);     }     printf( %.6lf n , Ans / 2);   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1000001;   const long long mod = 1000000009;   long long f[N];   long long getall(int m) {     long long res = 2;     for (int i = 1; i < m; ++i) res = (res * 2) % mod;     return res - 1;   }   long long solve(int n, int m) {     long long all = getall(m);     f[1] = getall(m);     for (int i = 2; i <= n; ++i) f[i] = ((f[i - 1] * (all - (i - 1))) % mod);     return f[n];   }   int main() {     int n, m;     cin >> n >> m;     cout << solve(n, m) << endl;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     int n, res = 0, m = 0, mx = 0;     cin >> n;     vector<int> v(n);     for (int i = 0; i < n; i++) cin >> v[i];     for (int i = 0; i < n; i++) {       int x = v[i], c = 1;       for (int j = i + 1; j < n; j++) {         if (x >= v[j]) {           c++;           x = min(v[j], x);         } else           break;       }       x = v[i];       for (int j = i - 1; j >= 0; j--) {         if (x >= v[j]) {           c++;           x = min(v[j], x);         } else           break;       }       res = max(res, c);     }     cout << res << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   #pragma comment(linker,  /STACK:102400000,102400000 )   const long long INF = 1e18 + 1LL;   const double Pi = acos(-1.0);   const int N = 3e3 + 10, M = 1e3 + 20, mod = 2017, inf = 2e9;   int b[N][N], m, n, a[N][N];   vector<int> ans1, ans2, ans3, ans4;   int main() {     scanf( %d%d , &n, &m);     for (int i = 1; i <= n; ++i) {       for (int j = 1; j <= m; ++j) scanf( %d , &a[i][j]), b[i][j] = a[i][j];     }     int fi = 0;     for (int i = 1; i <= n; ++i) {       int sum = inf;       for (int j = 1; j <= m; ++j) {         sum = min(sum, a[i][j]);       }       if (sum) {         for (int j = 1; j <= sum; ++j) ans1.push_back(i);         for (int j = 1; j <= m; ++j) a[i][j] -= sum;       }     }     for (int i = 1; i <= m; ++i) {       int sum = inf;       for (int j = 1; j <= n; ++j) {         sum = min(sum, a[j][i]);       }       if (sum) {         for (int j = 1; j <= sum; ++j) ans2.push_back(i);         for (int j = 1; j <= n; ++j) a[j][i] -= sum;       }     }     fi = ans1.size() + ans2.size();     for (int i = 1; i <= n; ++i) {       for (int j = 1; j <= m; ++j) {         if (a[i][j]) {           puts( -1 );           return 0;         }       }     }     for (int i = 1; i <= m; ++i) {       int sum = inf;       for (int j = 1; j <= n; ++j) {         sum = min(sum, b[j][i]);       }       if (sum) {         for (int j = 1; j <= sum; ++j) ans4.push_back(i);         for (int j = 1; j <= n; ++j) b[j][i] -= sum;       }     }     for (int i = 1; i <= n; ++i) {       int sum = inf;       for (int j = 1; j <= m; ++j) {         sum = min(sum, b[i][j]);       }       if (sum) {         for (int j = 1; j <= sum; ++j) ans3.push_back(i);         for (int j = 1; j <= m; ++j) b[i][j] -= sum;       }     }     int se = ans3.size() + ans4.size();     if (fi <= se) {       cout << ans1.size() + ans2.size() << endl;       for (int i = 0; i < ans1.size(); ++i) {         cout <<  row               <<     << ans1[i] << endl;       }       for (int i = 0; i < ans2.size(); ++i) {         cout <<  col               <<     << ans2[i] << endl;       }     } else {       cout << ans3.size() + ans4.size() << endl;       for (int i = 0; i < ans3.size(); ++i) {         cout <<  row               <<     << ans3[i] << endl;       }       for (int i = 0; i < ans4.size(); ++i) {         cout <<  col               <<     << ans4[i] << endl;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int SIZE = 1e5 + 10;   int a[SIZE];   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     int T, n;     cin >> T;     while (T--) {       cin >> n;       vector<int> ans;       for (int i = 1; i <= n; i++) {         cin >> a[i];         if (a[i] % 2 == 0) ans.push_back(i);       }       if (ans.size()) {         cout << 1 << endl << ans[0] << endl;         continue;       }       if (n == 1) {         cout << -1 << endl;         continue;       }       cout << 2 << endl;       cout << 1 <<     << 2 << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   struct Point {     long long x, y;     Point(long long x_, long long y_) {       x = x_;       y = y_;     }     Point() {}     Point operator-(const Point &other) const {       return Point(x - other.x, y - other.y);     }     long long dist(const Point &other) const {       long long dx = x - other.x;       long long dy = y - other.y;       return dx * dx + dy * dy;     }     friend long long operator*(const Point &a, const Point &b) {       return a.x * b.y - a.y * b.x;     }   };   long long up(const Point &a) { return a.y > 0 || (a.y == 0 && a.x >= 0); }   long long solve(long long n, vector<Point> poly, Point to) {     auto cmp = [&](const Point &a, const Point &b) {       Point f = a - to;       Point s = b - to;       if (up(f) == up(s)) {         return f * s > 0;       } else {         return up(f) < up(s);       }     };     sort(poly.begin(), poly.end(), cmp);     long long ans = (n * (n - 1) * (n - 2)) / 6;     for (long long i = 0; i < n; i++) {       long long rs = 0;       {         long long l = 1;         long long r = n;         while (r - l > 1) {           long long m = (r + l) >> 1;           if ((poly[(i + m) % n] - poly[i]) * (to - poly[i]) >= 0) {             l = m;           } else {             r = m;           }         }         rs = l;       }       long long len = rs;       ans -= (len) * (len - 1) / 2;     }     assert(ans >= 0);     return ans;   }   signed main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     long long n;     cin >> n;     vector<Point> poly(n);     for (auto &t : poly) {       cin >> t.x >> t.y;     }     long long ans = 0;     for (long long i = 0; i < n; i++) {       auto np = poly;       np.erase(np.begin() + i);       ans += solve(n - 1, np, poly[i]);     }     cout << ans * (n - 4) / 2 << endl;   }