This page is still under construction.

Parts of this page are still being built. What you see may change.

Parallel Lines

Time limit10sMemory limit512 MB

Summary
Given up to 16 distinct points, pair them up to maximize the number of parallel pairs among the drawn segments.
Level

Hard8 of 10

Topics
Bit manipulation, Dynamic programming, Geometry, Combinatorics
Solved
No attempts yet

Problem

You are given an even number of distinct points on the plane. Couple all of the points into pairs so that every point is coupled with exactly one other point, and consider every such coupling.

Draw the segment that connects the two points of each couple. Some of the drawn segments are parallel to others. Find the maximum number of parallel segment pairs over all possible couplings.

For the four points (0,0)(0, 0), (1,1)(1, 1), (0,2)(0, 2) and (2,4)(2, 4) there are three couplings, shown in Figure B.1. The numbers of parallel segment pairs are 0, 0 and 1, from the left, so the maximum is 1.

Figure B.1. All three possible couplings of the four points

Eight points can be coupled as shown in Figure B.2. With that coupling all four segments are parallel to one another, so the six pairs (L1,L2)(L_1, L_2), (L1,L3)(L_1, L_3), (L1,L4)(L_1, L_4), (L2,L3)(L_2, L_3), (L2,L4)(L_2, L_4) and (L3,L4)(L_3, L_4) are parallel and the maximum is 6.

Figure B.2. A coupling of eight points that maximizes the number of parallel segment pairs

Input

The input consists of a single test case of the following format.

m
x1 y1
.
.
.
xm ym

The first line contains an even integer mm, the number of points (2≤m≤162 \le m \le 16). Each of the following mm lines gives the coordinates of one point. The integers xix_i and yiy_i in the ii-th of those lines are the x-coordinate and the y-coordinate of the ii-th point (−1000≤xi≤1000-1000 \le x_i \le 1000, −1000≤yi≤1000-1000 \le y_i \le 1000).

All points are at different positions, that is, xi≠xjx_i \ne x_j or yi≠yjy_i \ne y_j holds for all i≠ji \ne j. No three points lie on a single line.

Output

Print the maximum number of parallel segment pairs in one line.

Examples5

  1. Example 1

    Input
    4
    0 0
    1 1
    0 2
    2 4
    
    Expected output
    1
    
  2. Example 2

    Input
    8
    0 0
    0 5
    2 2
    2 7
    3 -2
    5 0
    4 -2
    8 2
    
    Expected output
    6
    
  3. Example 3

    Input
    6
    0 0
    0 5
    3 -2
    3 5
    5 0
    5 7
    
    Expected output
    3
    
  4. Example 4

    Input
    2
    -1000 1000
    1000 -1000
    
    Expected output
    0
    
  5. Example 5

    Input
    16
    327 449
    -509 761
    -553 515
    360 948
    147 877
    -694 468
    241 320
    463 -753
    -206 -991
    473 -738
    -156 -916
    -215 54
    -112 -476
    -452 780
    -18 -335
    -146 77
    
    Expected output
    12