#include <bits/stdc++.h>   using namespace std;   const int maxn = 2000 + 100;   map<pair<long long, long long>, int> rat;   int n;   pair<long long, long long> px[maxn], py[maxn];   long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }   int main() {     cin >> n;     for (int i = 1, a, b, c; i <= n; i++) {       cin >> a >> b >> c;       px[i] = make_pair(c * b, a * a + b * b);       py[i] = make_pair(a * c, a * a + b * b);     }     long long ans = 0;     for (int i = 1; i <= n; i++) {       rat.clear();       long long two0 = 0;       for (int j = i + 1; j <= n; j++) {         long long a = px[j].first * px[i].second - px[j].second * px[i].first;         long long b = py[j].first * py[i].second - py[j].second * py[i].first;         long long g = gcd(abs(a), abs(b));         if (g != 0) a /= g, b /= g;         if (a == 0 && b == 0) {           two0++;           ans += j - i - 1;         } else {           if (a == 0) b = 1;           if (b == 0) a = 1;           if (a < 0 && b < 0) a *= -1, b *= -1;           if (a > 0 && b < 0) a *= -1, b *= -1;           ans += two0;           if (rat.count(make_pair(a, b))) {             ans += rat[make_pair(a, b)];             rat[make_pair(a, b)]++;           } else             rat[make_pair(a, b)] = 1;         }       }     }     cout << ans << endl;     return 0;   }   