Under construction

Still being built. Things may change

Very Strongly Connected Components

Time limit1sMemory limit1024 MB

Summary
Given N distinct integer points, find the maximum number of line segments you can draw between them so that segments meet only at endpoints.
Level

Medium6 of 10

Topics
Geometry, Sorting
Solved
No attempts yet

Problem

Eunho studied strongly connected components. Inspired by that, Seonghyeon built a graph that connects many points with many line segments.

Given NN distinct points in the plane, you can build a graph in which each point is a vertex and each segment joining two of the points is an edge. Among the graphs in which no two segments meet except at their endpoints, the graph that uses the most segments is called the very strongly connected component of the given points. The number of edges of a very strongly connected component is called its strength.

Eunho wondered what the strength of the very strongly connected component of NN points is. He found the answer but left without telling it, because he had to study Chinese characters. Find it for him.

Given NN distinct points in the plane, print the strength of their very strongly connected component.

Input

The first line contains a positive integer NN.

From the second line onward, the ii-th of the NN lines contains the coordinates xix_i and yiy_i of the ii-th point, separated by a space.

All coordinates are integers, and no two points have the same coordinates.

Output

Print the answer on the first line.

Constraints

  • 1≤N≤200 0001 \leq N \leq 200\,000
  • −109≤xi,yi≤109-10^9 \leq x_i, y_i \leq 10^9 (1≤i≤N1 \leq i \leq N)
  • i≠j⇒(xi,yi)≠(xj,yj)i \neq j \Rightarrow (x_i,y_i) \neq (x_j,y_j) (1≤i,j≤N1 \leq i,j \leq N)

Examples1

  1. Example 1

    Input
    4
    0 0
    0 1
    1 0
    1 1
    
    Expected output
    5