B - Gentle Pairs 解説 /

実行時間制限: 2 sec / メモリ制限: 1024 MB

配点 : 200

問題文

xy 平面上に 1, 2, \dots, N の番号が付けられた N 個の点があります。点 i(x_i, y_i) にあり、N 個の点の x 座標は互いに異なります。

以下の条件を満たす整数の組 (i, j)\ (i < j) の個数を求めてください。

  • i と点 j を通る直線の傾きが -1 以上 1 以下である。

制約

  • 入力は全て整数
  • 1 \le N \le 10^3
  • |x_i|, |y_i| \le 10^3
  • i \neq j ならば x_i \neq x_j

入力

入力は以下の形式で標準入力から与えられる。

N
x_1 y_1
\vdots
x_N y_N

出力

答えを出力せよ。


入力例 1

3
0 0
1 2
2 1

出力例 1

2

(0, 0)(1, 2) を通る直線の傾きは 2(0, 0)(2, 1) を通る直線の傾きは \frac{1}{2}(1, 2)(2, 1) を通る直線の傾きは -1 です。


入力例 2

1
-691 273

出力例 2

0

入力例 3

10
-31 -35
8 -36
22 64
5 73
-14 8
18 -58
-41 -85
1 -88
-21 -85
-11 82

出力例 3

11

Score : 200 points

Problem Statement

On the xy-plane, We have N points numbered 1 to N. Point i is at (x_i, y_i), and the x-coordinates of the N points are pairwise different.

Find the number of pairs of integers (i, j)\ (i < j) that satisfy the following condition:

  • The line passing through Point i and Point j has a slope between -1 and 1 (inclusive).

Constraints

  • All values in input are integers.
  • 1 \le N \le 10^3
  • |x_i|, |y_i| \le 10^3
  • x_i \neq x_j for i \neq j.

Input

Input is given from Standard Input in the following format:

N
x_1 y_1
\vdots
x_N y_N

Output

Print the answer.


Sample Input 1

3
0 0
1 2
2 1

Sample Output 1

2

The slopes of the lines passing through (0, 0) and (1, 2), passing through (0, 0) and (2, 1), and passing through (1, 2) and (2, 1) are 2, \frac{1}{2}, and -1, respectively.


Sample Input 2

1
-691 273

Sample Output 2

0

Sample Input 3

10
-31 -35
8 -36
22 64
5 73
-14 8
18 -58
-41 -85
1 -88
-21 -85
-11 82

Sample Output 3

11