fork download
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. #define ll long long
  4. #define clr(a,b) memset(a,b,sizeof(a))
  5. #define all(v) ((v).begin()),((v).end())
  6. #define read(v) freopen(v, "r", stdin)
  7. #define write(v) freopen(v, "wt", stdout)
  8. #define fastIO cout << fixed << setprecision(8), ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr)
  9. double const EPS = 1e-9, PI = acos(-1);
  10. const int N = 2e3 + 9, M = 2e3 + 9, OO = 1e9 + 7, MOD = 1e9 + 7;
  11. const ll inf = 1e18;
  12.  
  13. map<pair<int, int>, int> slope;
  14. map<int, int> Xs, Ys;
  15. ll Comb[N][5];
  16.  
  17. void pascal(){
  18. for (int i = 0; i <= 2002; ++i) {
  19. int m = min(6, i);
  20. for (int j = 0; j <= m; ++j) {
  21. if(i == 0 || j == 0) {
  22. Comb[i][j] = 1;
  23. continue;
  24. }
  25. Comb[i][j] = Comb[i-1][j] + Comb[i-1][j-1];
  26. }
  27. }
  28. }
  29.  
  30.  
  31. int main() {
  32. fastIO;
  33. // read("input.in");
  34. // write("input.in");
  35. int n, a, b, gg;
  36. cin >> n;
  37. pascal();
  38. for (int i = 0; i < n; ++i) {
  39. cin >> a >> b;
  40. a += 200, b += 200; // fixing zero in GCD
  41. Xs[a]++;
  42. Ys[b]++;
  43. gg = __gcd(a, b);
  44. a /= gg, b /= gg;
  45. slope[{a, b}]++;
  46. }
  47. ll ans = Comb[n][3];
  48. for(auto it: slope) {
  49. if(it.second >= 3) {
  50. ans -= Comb[it.second][3];
  51. }
  52. }
  53. for(auto it: Xs) {
  54. if(it.second >= 3) {
  55. ans -= Comb[it.second][3];
  56. }
  57. }
  58. for(auto it: Ys) {
  59. if(it.second >= 3) {
  60. ans -= Comb[it.second][3];
  61. }
  62. }
  63. cout << ans;
  64. return 0;
  65. }
  66.  
Success #stdin #stdout 0s 4408KB
stdin
Standard input is empty
stdout
Standard output is empty