bool debug = false; #include #include #include #include using namespace std; typedef __int128 ll; constexpr int kN = int(4E3 + 10), kInf = int(1E9 + 10); #define PB push_back struct Point { ll x, y; Point(ll a, ll b) {x = a, y = b;} Point() {} void in() { scanf("%lld%lld", &x, &y); return ; } void out() { printf("%lld %lld\n", x, y); return ; } Point operator -(Point b) const {return Point(x - b.x, y - b.y);} ll operator ^(Point b) const {return x * b.y - y * b.x;} }; const Point O(0, 0); int dcmp(ll x) {return x > 0 ? 1 : x == 0 ? 0 : -1;} bool segment_intersection(Point p1, Point p2, Point p3, Point p4) { if (debug) { printf("p1::"); p1.out(); printf("p2::"); p2.out(); printf("p3::"); p3.out(); printf("p4::"); p4.out(); printf("intersect? %d\n", dcmp((p2 - p1) ^ (p3 - p1)) * dcmp((p2 - p1) ^ (p4 - p1))); printf("intersect? %d\n", dcmp((p4 - p3) ^ (p1 - p3)) * dcmp((p4 - p3) ^ (p2 - p3))); } return dcmp((p2 - p1) ^ (p3 - p1)) * dcmp((p2 - p1) ^ (p4 - p1)) <= 0 && dcmp((p4 - p3) ^ (p1 - p3)) * dcmp((p4 - p3) ^ (p2 - p3)) <= 0; } int n; Point p[kN]; ll cnt(int x) { vector left, right; Point now(-p[x].x * kInf, -p[x].y * kInf); int lpos = 0, rpos = 0, lsz, rsz; ll ans = 0, tmp; for (int i = 1; i <= n; i++) if (i != x) { tmp = p[i] ^ p[x]; if (tmp < 0) left.PB(i); else if (tmp > 0) right.PB(i); } auto cmp = [&](int a, int b) {return (p[a] ^ p[b]) > 0;}; sort(left.begin(), left.end(), cmp); sort(right.begin(), right.end(), cmp); lsz = int(left.size()); rsz = int(right.size()); if (debug) { printf("x = %d\n", x); printf("-- left --\n"); for (int i : left) printf("%d\n", i); printf("-- right --\n"); for (int i : right) printf("%d\n", i); } while (lpos < lsz) { while (rpos < rsz) { if (!segment_intersection(p[left[lpos]], p[right[rpos]], now, O)) rpos++; else break; } if (debug) printf("lpos = %d, rpos = %d\n", lpos, rpos); ans += rpos; lpos++; } if (debug) printf("ans = %lld\n", ans); return ans; } int main() { ll ans = 0; scanf("%d", &n); for (int i = 1; i <= n; i++) p[i].in(); for (int i = 1; i <= n; i++) ans += cnt(i); assert(ans % 3 == 0); printf("%lld\n", (long long int) ans / 3); }