Revenge of Collinearity

Accepts: 37
Submissions: 553
Time Limit: 8000/5000 MS (Java/Others)
Memory Limit: 32768/32768 K (Java/Others)
Problem Description
In geometry, collinearity is a property of a set of points, specifically, the property of lying on a single line. A set of points with this property is said to be collinear (often misspelled as colinear). ---Wikipedia Today, Collinearity takes revenge on you. Given a set of N points in two-dimensional coordinate system, you have to find how many set of <$P_i, P_j, P_k$> from these N points are collinear. Note that <$P_i, P_j, P_k$> cannot contains same point, and <$P_i, P_j, P_k$> and <$P_i, P_k, P_j$> are considered as the same set, i.e. the order in the set doesnĄ¯t matter.
Input
The first line contains a single integer T, indicating the number of test cases. Each test case begins with an integer N, following N lines, each line contains two integers Xi and Yi, describing a point. [Technical Specification] 1. 1 <= T <= 33 2. 3 <= N <= 1 000 3. -1 000 000 000 <= Xi, Yi <= 1 000 000 000, and no two points are identical. 4. The ratio of test cases with N > 100 is less than 25%.
Output
For each query, output the number of three points set which are collinear.
Sample Input
2
3
1 1
2 2
3 3
4
0 0
1 0
0 1
1 1
Sample Output
1
0