#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; typedef pair PII; #define ALL(x) x.begin(),x.end() #define REP(i,n) for (int i=0; i<(n); ++i) #define FOR(var,pocz,koniec) for (int var=(pocz); var<=(koniec); ++var) #define FORD(var,pocz,koniec) for (int var=(pocz); var>=(koniec); --var) #define PB push_back #define PF push_front #define MP(a,b) make_pair(a,b) #define F first #define S second #define LD long double #define LL long long typedef pair PLL; #define MAX 300 LL gcd(LL a,LL b){ if (b==0) return a; else return gcd(b,a%b); } struct Functional { LL x; LL y; LL v; Functional(LL x1, LL y1, LL x2, LL y2){ y=x1-x2; x=y2-y1; if ((x<0)||(x==0 && y<0)){ x=-x; y=-y; } LL d = gcd(llabs(x),llabs(y)); x/=d; y/=d; v=x*x1+y*y1; } Functional(const Functional& f){x=f.x; y=f.y; v=f.v;} int quadrant() const { if (y>0) return 1; else return 0; } bool operator<(const Functional& f) const { LL k = x*f.y-y*f.x; if (k==0) return (v0); } bool operator==(const Functional& f) const { return (x==f.x && y==f.y && v==f.v); } bool sameVec(const Functional& f) const { return (x==f.x && y==f.y); } LL dotProd(const Functional& f) const { return (x*f.x+y*f.y); } void printSelf() const { printf("%lld %lld %lld\n",x,y,v); } }; vector q0; vector q1; int n; LL countSquares(const vector& r1,const vector& r2){ vector p1; vector p2; REP(j,r1.size()) REP(i,j) p1.PB(r1[j]-r1[i]); REP(j,r2.size()) REP(i,j) p2.PB(r2[j]-r2[i]); sort(p1.begin(),p1.end()); sort(p2.begin(),p2.end()); LL ret=0; int c=0,d=0; while(cp1[c]) break; } ret+=mn * (LL)(cc-c); c=cc; d=dd; } return ret; } int main(){ scanf("%d",&n); REP(i,n){ LL x1,y1,x2,y2; scanf("%lld%lld%lld%lld",&x1,&y1,&x2,&y2); Functional r = Functional(x1,y1,x2,y2); if (r.quadrant()) {q1.PB(r);} else {q0.PB(r);} } sort(q0.begin(),q0.end()); sort(q1.begin(),q1.end()); LL ret=0; int c=0,d=0; vector r1,r2; while(c