496. LShapes
Time limit per test: 0.75
second(s)
Memory limit: 262144
kilobytes
input: standard
output: standard
Let's say that two line segments of nonzero length form an
if they are at a
angle to each other and one endpoint of one segment coincides with one endpoint of the other.
There are
N line segments on a plane. The segments are numbered from 1 to
N. Count the number of distinct pairs of segments that form Lshapes. Two pairs are considered distinct if they contain segments with different numbers.
Input
The first line of the input line contains the integer
N (1 ≤
N ≤ 5000). Each of the following
N lines describes one segment and contains four integers
x_{1},
y_{1},
x_{2},
y_{2} (
), where (
x_{1},
y_{1}) and (
x_{2},
y_{2}) are endpoints of the segment. It may be assumed that for each segment
x_{1} ≠q
x_{2} or
y_{1} ≠q
y_{2}.
Output
The output file should contain a single integer, the total number of distinct pairs of line segments forming Lshapes.
Example(s)
sample input

sample output

7
0 4 0 7
4 4 1 6
1 6 3 0
4 4 0 4
0 0 0 4
0 0 0 2
0 4 4 4

5

Note. In the example the Lshapes are formed by the following pairs of segments: (1, 4), (1, 7), (2, 3), (4, 5), (5, 7). Note that the segments 4 and 7 coincide, but the pairs (1, 4) and (1, 7), for example, are still considered distinct.