Points

Time limit1sMemory limit128 MB

Summary
Count the distinct straight lines in 3D space that pass through at least three of the given points.
Level

Medium7 of 10

Topics
Geometry, Hash map, Math, Implementation
Solved
No attempts yet

Problem

You and your friends invented a game called "Trivial Points", played by placing points in 3D space according to a certain set of rules. To build a computer version of the game, you must write a program that, given a set of points in 3D space, counts how many distinct straight lines pass through at least 3 of the given points.

Input

The first line contains a single integer nn, the number of points. Each of the next nn lines contains three integers xix_i, yiy_i, ziz_i, separated by single spaces, the coordinates of the ii-th point.

Output

Print a single integer: the number of distinct lines that pass through at least 3 of the given points.

Constraints

  • 4≤n≤10004 \le n \le 1000
  • xi,yi,zix_i, y_i, z_i are integers
  • −10000≤xi,yi,zi≤10000-10000 \le x_i, y_i, z_i \le 10000
  • All given points are distinct.

Hint

In the sample, one line passes through the four collinear points (−5,−5,−5)(-5, -5, -5), (1,1,1)(1, 1, 1), (2,2,2)(2, 2, 2), (3,3,3)(3, 3, 3), and another line passes through (1,0,−1)(1, 0, -1), (2,2,2)(2, 2, 2), (3,4,5)(3, 4, 5). Both lines contain at least 3 points (the point (2,2,2)(2, 2, 2) lies on both), so the answer is 22.

Examples1

  1. Example 1

    Input
    7
    1 0 -1
    3 4 5
    2 2 2
    3 3 3
    -5 -5 -5
    1 1 1
    -3 4 0
    
    Expected output
    2