This problem is same as the next one, but has smaller constraints.

It was a Sunday morning when the three friends Selena, Shiro and Katie decided to have a trip to the nearby power station (do not try this at home). After arriving at the power station, the cats got impressed with a large power transmission system consisting of many chimneys, electric poles, and wires. Since they are cats, they found those things gigantic.

At the entrance of the station, there is a map describing the complicated wiring system. Selena is the best at math among three friends. He decided to draw the map on the Cartesian plane. Each pole is now a point at some coordinates $(x_i, y_i)$. Since every pole is different, all of the points representing these poles are distinct. Also, every two poles are connected with each other by wires. A wire is a straight line on the plane infinite in both directions. If there are more than two poles lying on the same line, they are connected by a single common wire.

Selena thinks, that whenever two different electric wires intersect, they may interfere with each other and cause damage. So he wonders, how many pairs are intersecting? Could you help him with this problem?


-----Input-----

The first line contains a single integer $n$ ($2 \le n \le 50$) — the number of electric poles.

Each of the following $n$ lines contains two integers $x_i$, $y_i$ ($-10^4 \le x_i, y_i \le 10^4$) — the coordinates of the poles.

It is guaranteed that all of these $n$ points are distinct.


-----Output-----

Print a single integer — the number of pairs of wires that are intersecting.


-----Examples-----
Input
4
0 0
1 1
0 3
1 2

Output
14

Input
4
0 0
0 2
0 4
2 0

Output
6

Input
3
-1 -1
1 0
3 1

Output
0



-----Note-----

In the first example: [Image] 

In the second example: [Image] 

Note that the three poles $(0, 0)$, $(0, 2)$ and $(0, 4)$ are connected by a single wire.

In the third example: [Image]

Source: codeforces | Difficulty: HARD
Tags: Geometry

Complete search


Solutions:
from fractions import Fraction
n = int(input())
l1 = []
d2 = {}
for i in range(0, n):
	(x, y) = map(int, input().split())
	for item in l1:
		if x == item[0]:
			if 'inf' not in d2:
				d2['inf'] = [x]
			elif x not in d2['inf']:
				d2['inf'].append(x)
		else:
			slope = Fraction(y - item[1], x - item[0])
			c = Fraction(y, 1) - slope * Fraction(x, 1)
			if slope not in d2:
				d2[slope] = [c]
			elif c not in d2[slope]:
				d2[slope].append(c)
	l1.append((x, y))
z = 0
ans = 0
f = 0
for k in d2:
	z += len(d2[k])
for k in d2:
	x = len(d2[k])
	f = f + x
	ans += x * (z - f)
print(ans)


import sys
import collections
import math
import heapq
from operator import itemgetter

def getint():
	return int(input())

def getints():
	return [int(x) for x in input().split(' ')]
n = getint()
points = [tuple(getints()) for _ in range(n)]
result = 0
slopes = collections.defaultdict(set)
for i in range(n - 1):
	for j in range(i + 1, n):
		(x1, y1, x2, y2) = (points[i][0], points[i][1], points[j][0], points[j][1])
		(a, b) = (y1 - y2, x1 - x2)
		d = math.gcd(a, b)
		(a, b) = (a // d, b // d)
		if a < 0 or (a == 0 and b < 0):
			(a, b) = (-a, -b)
		c = a * x1 - b * y1
		slope = (a, b)
		slopes[slope].add(c)
slopeGroups = [(ab[0], ab[1], len(cs)) for (ab, cs) in slopes.items()]
m = len(slopeGroups)
for i in range(m - 1):
	intersects = 0
	for j in range(i + 1, m):
		intersects += slopeGroups[j][2]
	result += slopeGroups[i][2] * intersects
print(str(result))


import math, sys

def round_slightly(x):
	return x + 2 ** 20 - 2 ** 20
points = []
lines = []
n = int(input())
for i in range(n):
	(x, y) = map(float, input().split())
	points.append((x, y))
grad_freqs = {}
for i in range(len(points)):
	for j in range(i + 1, len(points)):
		((x, y), (a, b)) = (points[i], points[j])
		y2_y1 = b - y
		x2_x1 = a - x
		if x == a:
			gradient = float('Inf')
			intercept = x
		else:
			gradient = y2_y1 / x2_x1
			intercept = y - gradient * x
		gradient = round_slightly(gradient)
		intercept = round_slightly(intercept)
		if gradient not in grad_freqs:
			grad_freqs[gradient] = set()
		grad_freqs[gradient].add(intercept)
total_lines = 0
for key in grad_freqs.keys():
	grad_freqs[key] = len(grad_freqs[key])
	total_lines += grad_freqs[key]
res = 0
values = grad_freqs.values()
for (idx, item) in enumerate(values):
	res += (total_lines - item) * item
print(res // 2)


from random import random
from collections import defaultdict
from fractions import Fraction
import math
import re
import fractions
N = int(input())
lines = defaultdict(set)
poles = []
for _ in range(N):
	(x, y) = list(map(int, input().split(' ')))
	for (xx, yy) in poles:
		if yy - y == 0:
			slope = Fraction(10 ** 6, 1)
			const = y
		else:
			slope = Fraction(xx - x, yy - y)
			const = x - slope * y
		lines[slope].add(const)
	poles.append((x, y))
result = 0
visited = 0
for slope in lines:
	result += visited * len(lines[slope])
	visited += len(lines[slope])
print(result)


import sys
input = sys.stdin.readline
n = int(input())
W = [list(map(int, input().split())) for i in range(n)]
SET = set()

def gcd(a, b):
	while b:
		(a, b) = (b, a % b)
	return a

def point(a, b, c, d):
	g = gcd(c - a, d - b)
	K = [(c - a) // g, (d - b) // g]
	if K == [0, 1]:
		SET.add(tuple(K + [a]))
	else:
		SET.add(tuple(K + [((d - b) * -a + (c - a) * b) / (c - a)]))
for i in range(n - 1):
	(a, b) = W[i]
	for j in range(i + 1, n):
		if i == j:
			continue
		(c, d) = W[j]
		point(a, b, c, d)
LIST = list(SET)
ANS = 0
for i in range(len(LIST) - 1):
	(NOW0, NOW1) = (LIST[i][0], LIST[i][1])
	for j in range(i + 1, len(LIST)):
		if NOW0 != LIST[j][0] or NOW1 != LIST[j][1]:
			ANS += 1
print(ANS)


n = int(input())
lis = [list(map(int, input().split())) for _ in range(n)]
lis.sort()
d = {}
for i in range(n):
	(x1, y1) = lis[i]
	for j in range(i + 1, n):
		(x2, y2) = lis[j]
		b = 0
		c = 0
		if x1 == x2:
			k = x1
			b = 100000000000
		else:
			b = (y2 - y1) / (x2 - x1)
			k = (x2 * y1 - y2 * x1) / (x2 - x1)
		if b in d:
			if k not in d[b]:
				d[b][k] = 1
		else:
			d[b] = {k: 1}
c = 0
ans = 0
for i in d:
	ans += c * len(d[i])
	c += len(d[i])
print(ans)


import sys, math, queue
MOD = 10 ** 9 + 7
n = int(input())
p = []
for i in range(n):
	(x, y) = map(int, input().split())
	p.append((x, y))
d = {}
for i in range(n):
	(x1, y1) = p[i]
	for j in range(i + 1, n):
		(x2, y2) = p[j]
		if x1 != x2:
			m = (y2 - y1) / (x2 - x1)
			c = (y1 * x2 - x1 * y2) / (x2 - x1)
		else:
			m = 10 ** 10
			c = x1
		if m in d:
			if c in d[m]:
				d[m][c] += 1
			else:
				d[m][c] = 1
		else:
			d[m] = {c: 1}
p = []
for m in d:
	p.append(len(d[m]))
s = sum(p)
ans = 0
for x in p:
	ans += x * (s - x)
print(ans // 2)


from sys import stdin, stdout
from math import atan, pi, tan
import itertools
n = int(input())
pts = []
for i in range(n):
	(x, y) = map(int, stdin.readline().split())
	pts.append((x, y))
eps = 10 ** (-8)

def slope(p1, p2):
	if p1[0] == p2[0]:
		return pi / 2
	return atan((p2[1] - p1[1]) / (p2[0] - p1[0]))
slopes = []
for (p1, p2) in itertools.combinations(pts, 2):
	slopes.append((slope(p1, p2), p1))
slopes.sort()
counts = []
idx = 0
while idx < len(slopes):
	cur_slope = slopes[idx][0]
	slp = tan(cur_slope)
	y_ints = []
	while idx < len(slopes) and abs(slopes[idx][0] - cur_slope) < eps:
		p = slopes[idx][1]
		if abs(cur_slope) < pi / 4:
			y_ints.append(p[1] - p[0] * slp)
		else:
			y_ints.append(p[0] - p[1] / slp)
		idx += 1
	ct = 0
	y_ints.sort()
	prev = -100000
	for x_int in y_ints:
		if abs(x_int - prev) > eps:
			ct += 1
		prev = x_int
	counts.append(ct)
ans = 0
s = sum(counts)
for ct in counts:
	ans += ct * (s - ct)
ans //= 2
print(ans)


import sys
from math import gcd

class Main:

	def __init__(self):
		self.buff = None
		self.index = 0

	def next(self):
		if self.buff is None or self.index == len(self.buff):
			self.buff = self.next_line()
			self.index = 0
		val = self.buff[self.index]
		self.index += 1
		return val

	def next_line(self):
		return sys.stdin.readline().split()

	def next_ints(self):
		return [int(x) for x in sys.stdin.readline().split()]

	def next_int(self):
		return int(self.next())

	def solve(self):
		n = self.next_int()
		pr = [(self.next_int(), self.next_int()) for _ in range(0, n)]
		ks = {}
		ct = 0
		res = 0
		ls = set()
		for i in range(0, n):
			for j in range(i + 1, n):
				dy = pr[j][1] - pr[i][1]
				dx = pr[j][0] - pr[i][0]
				if dx < 0:
					dx *= -1
					dy *= -1
				elif dx == 0:
					dy = abs(dy)
				g = gcd(abs(dx), abs(dy))
				k = (dx // g, dy // g)
				(x, y) = (pr[i][0], pr[i][1])
				if dx == 0:
					a = (pr[i][0], 0)
				else:
					cl = abs(x) // k[0]
					if x >= 0:
						x -= cl * k[0]
						y -= cl * k[1]
					else:
						x += cl * k[0]
						y += cl * k[1]
						while x < 0:
							x += k[0]
							y += k[1]
					a = (x, y)
				if (k, a) in ls:
					continue
				else:
					ls.add((k, a))
				ct += 1
				if k not in ks:
					ks[k] = 1
				else:
					ks[k] += 1
				res += ct - ks[k]
		print(res)
Main().solve()


import math
from collections import defaultdict
n = int(input())
l = []
for i in range(n):
	k = [int(x) for x in input().split()]
	l.append(k)
dd = {}
ll = [0] * n
ans = 0
ttt = 0
for i in range(n):
	for j in range(i + 1, n):
		a = l[i][1] - l[j][1]
		b = l[i][0] - l[j][0]
		c = l[i][1] * l[j][0] - l[i][0] * l[j][1]
		d = math.gcd(math.gcd(a, b), c)
		if d != 0:
			a = a // d
			b = b // d
			c = c // d
		if a < 0 or (a == 0 and b < 0):
			a = -a
			b = -b
			c = -c
		if (a, b) not in dd:
			dd[a, b] = set()
		if c not in dd[a, b]:
			ttt += 1
			dd[a, b].add(c)
			ans += ttt - len(dd[a, b])
print(ans)


import sys
from itertools import combinations
from collections import defaultdict
from fractions import Fraction
n = int(sys.stdin.readline().strip())
allpoles = []
for i in range(0, n):
	(x, y) = [int(z) for z in sys.stdin.readline().split()]
	allpoles.append((x, y))
allwires = defaultdict(set)
for (pa, pb) in combinations(allpoles, 2):
	(pax, pay) = pa
	(pbx, pby) = pb
	if pax == pbx:
		allwires[None].add(pax)
	else:
		slope = Fraction(pby - pay, pbx - pax)
		intersect = pay - slope * pax
		allwires[slope].add(intersect)
counts = [len(allwires[slope]) for slope in allwires.keys()]
total = sum(counts)
totalcrossings = sum([x * (total - x) for x in counts]) // 2
print(f'{totalcrossings}')


def gcd(a, b):
	while b:
		(a, b) = (b, a % b)
	return a
n = int(input())
P = [[int(x) for x in input().split()] for _ in range(n)]
L = []

def addLine(x, y, dx, dy):
	if dx < 0:
		dx *= -1
		dy *= -1
	elif dx == 0:
		if dy < 0:
			dy *= -1
	g = gcd(dx, dy)
	dx //= g
	dy //= g
	x += dx * 10 ** 9
	y += dy * 10 ** 9
	if dx:
		k = x // dx
	else:
		k = y // dy
	x -= k * dx
	y -= k * dy
	L.append((x, y, dx, dy))
for i in range(n):
	for j in range(i + 1, n):
		(xi, yi) = P[i]
		(xj, yj) = P[j]
		(dx, dy) = (xi - xj, yi - yj)
		addLine(xi, yi, dx, dy)
from collections import defaultdict as dd, deque
L = list(set(L))
res = 0
C = dd(int)
for (x, y, dx, dy) in L:
	C[dx, dy] += 1
ss = sum(C.values())
for x in C.values():
	res += (ss - x) * x
print(res // 2)


from fractions import Fraction
from collections import Counter
n = int(input())
p = []
lines = set()
c = Counter()
for _ in range(n):
	(x, y) = map(int, input().split())
	p.append((x, y))
for i in range(n - 1):
	for j in range(i + 1, n):
		try:
			l = (Fraction(p[i][1] - p[j][1], p[i][0] - p[j][0]), Fraction(p[j][1] * p[i][0] - p[i][1] * p[j][0], p[i][0] - p[j][0]))
		except ZeroDivisionError:
			l = ('i', p[i][0])
		if l not in lines:
			lines.add(l)
			c[l[0]] += 1
t = 0
tt = len(lines)
for l in lines:
	t += tt - c[l[0]]
print(t // 2)


n = int(input())
T = []
P = []
for i in range(n):
	(x, y) = map(int, input().split())
	T.append([x, y])
for i in range(n):
	for j in range(i + 1, n):
		(x1, y1) = T[i]
		(x2, y2) = T[j]
		a = y2 - y1
		b = x1 - x2
		c = -(a * x1 + b * y1)
		if a != 0:
			b /= a
			c /= a
			a = 1
		else:
			a = 0
			c /= b
			b = 1
		P.append([a, b, c])
P.sort()
newp = [P[0]]
for i in range(len(P) - 1):
	if P[i] != P[i + 1]:
		newp.append(P[i + 1])
P = newp
sos = dict()
for (a, b, c) in P:
	if b != 0 and a != 0:
		z = a / b
	elif a == 0:
		z = 'kek'
	else:
		z = 'lol'
	if z not in sos:
		sos[z] = 1
	else:
		sos[z] += 1
sus = 0
sussqua = 0
for i in sos:
	sus += sos[i]
	sussqua += sos[i] ** 2
print((sus ** 2 - sussqua) // 2)


import sys
import math
from pprint import pprint
n = int(input())
p = [list(map(int, input().split())) for i in range(n)]
p.sort()
s = {}
for i in range(n):
	(x1, y1) = p[i]
	for j in range(i + 1, n):
		(x2, y2) = p[j]
		slope = 0
		cons = 0
		if x1 - x2 == 0:
			slope = sys.maxsize
			cons = x1
		else:
			slope = (y2 - y1) / (x2 - x1)
			cons = (y1 * x2 - x1 * y2) / (x2 - x1)
		if slope in s:
			if cons in s[slope]:
				s[slope][cons] += 1
			else:
				s[slope][cons] = 1
		else:
			s[slope] = {cons: 1}
ans = 0
cnt = 0
for x in s:
	ans += cnt * len(s[x])
	cnt += len(s[x])
print(ans)


import random
import sys
from fractions import Fraction, gcd
INF = 10 ** 9

def __starting_point():

	def _(f):
		for l in f:
			for i in l.split():
				yield int(i)
	g = _(sys.stdin)
	n = next(g)
	pts = []
	for i in range(n):
		(x, y) = (next(g), next(g))
		pts.append((x, y))
	lines = set()
	for i in range(n):
		for j in range(i + 1, n):
			(x0, y0, x1, y1) = (pts[i][0], pts[i][1], pts[j][0], pts[j][1])
			(dx, dy) = (x1 - x0, y1 - y0)
			g = gcd(dx, dy)
			dx //= g
			dy //= g
			if dx:
				a = Fraction(dy, dx)
				b = -Fraction(dy * x0, dx) + y0
			else:
				(a, b) = (INF, x0)
			lines.add((a, b))
	a = list(lines)
	size = len(lines)
	c = 0
	for i in range(size):
		for j in range(i + 1, size):
			if a[i][0] == a[j][0]:
				continue
			c += 1
	print(c)
__starting_point()


from math import *

class slopeC:

	def __init__(self):
		self.chil = set()
n = int(input())
slopes = {}
L = []
for i in range(n):
	(x, y) = map(int, input().split())
	for l in L:
		if x != l[0]:
			slope = (y - l[1]) / (x - l[0])
		else:
			slope = inf
		s1 = str(l[0]) + '-' + str(l[1])
		s2 = str(x) + '-' + str(y)
		if slope not in slopes:
			slopes[slope] = [slopeC()]
			slopes[slope][0].chil.add(s1)
			slopes[slope][0].chil.add(s2)
		else:
			f = 0
			for child in slopes[slope]:
				if s1 in child.chil:
					f = 1
					child.chil.add(s2)
					break
			if f == 0:
				slopes[slope] += [slopeC()]
				slopes[slope][0].chil.add(s1)
				slopes[slope][0].chil.add(s2)
	L += [[x, y]]
A = []
P = [0]
for s in slopes:
	A += [len(slopes[s])]
	P += [P[-1] + A[-1]]
ans = 0
for (i, v) in enumerate(A):
	ans += A[i] * (P[-1] - P[i + 1])
print(ans)


from fractions import Fraction
(n, l, lv) = (int(input()), {}, set())
p = [list(map(int, input().split())) for i in range(n)]
for i in range(n - 1):
	for j in range(i + 1, n):
		if p[i][0] == p[j][0]:
			lv.add(p[i][0])
			continue
		m = Fraction(p[i][1] - p[j][1], p[i][0] - p[j][0])
		if m not in l:
			l[m] = set()
		l[m].add(p[i][1] - m * p[i][0])
mc = [len(l[li]) for li in l] + [len(lv)]
ls = sum(mc)
print(sum((mci * (ls - mci) for mci in mc)) // 2)


coord = []
coef = {}
a = b = 0
v = {}
coef_a = {}
n = int(input())
for i in range(n):
	coord.append(list(map(float, input().split())))
for i in range(n):
	(x1, y1) = coord[i]
	for j in range(i + 1, n):
		(x2, y2) = coord[j]
		if x2 - x1:
			a = (y2 - y1) / (x2 - x1)
			b = (y1 * x2 - y2 * x1) / (x2 - x1)
			coef[a, b] = coef.get((a, b), 0) + 1
			coef_a[a] = coef_a.get(a, 0) + 1
			if coef[a, b] > 1:
				coef[a, b] -= 1
				coef_a[a] -= 1
		else:
			v[x2] = 1
v_nmbr = sum(v.values())
coe = list(coef_a.values())
for i in range(len(coe)):
	coe[i] = coe[i] * (coe[i] - 1) // 2
l_par = sum(coe)
l_nmbr = len(coef) + v_nmbr
ans = l_nmbr * (l_nmbr - 1) // 2 - v_nmbr * (v_nmbr - 1) // 2 - l_par
print(ans)


import sys
lines = set()
points = []
num = int(input())
for i in range(num):
	points.append([int(j) for j in sys.stdin.readline().split()])
for i in range(num):
	for j in range(i):
		dx = points[j][0] - points[i][0]
		if dx == 0:
			lines.add((11932912953213, points[i][0]))
		else:
			m = (points[j][1] - points[i][1]) / dx
			lines.add((int(2 ** 33 * m), int(2 ** 33 * (points[i][1] - m * points[i][0]))))
ms = {}
for l in lines:
	if l[0] in ms:
		ms[l[0]] += 1
	else:
		ms[l[0]] = 1
total = 0
t = list(ms.values())
s = sum(t)
for a in t:
	total += a * (s - a)
print(total // 2)


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
from math import gcd, ceil

def pre(s):
	n = len(s)
	pi = [0] * n
	for i in range(1, n):
		j = pi[i - 1]
		while j and s[i] != s[j]:
			j = pi[j - 1]
		if s[i] == s[j]:
			j += 1
		pi[i] = j
	return pi

def prod(a):
	ans = 1
	for each in a:
		ans = ans * each
	return ans

def lcm(a, b):
	return a * b // gcd(a, b)

def binary(x, length=16):
	y = bin(x)[2:]
	return y if len(y) >= length else '0' * (length - len(y)) + y
pts = []
for _ in range(int(input()) if True else 1):
	(x, y) = map(int, input().split())
	pts += [[x, y]]
ps = []
pss = set()
from fractions import Fraction
for i in range(len(pts) - 1):
	for j in range(i + 1, len(pts)):
		(x1, y1, x2, y2) = (pts[i][0], pts[i][1], pts[j][0], pts[j][1])
		(a, b, c) = (y1 - y2, x2 - x1, x1 * y2 - x2 * y1)
		g = gcd(a, b)
		(a, b) = (a // g, b // g)
		if a < 0 or (a == 0 and b < 0):
			a *= -1
			b *= -1
			c *= -1
		c = round(c / g, 3)
		xx = str(a) + ',' + str(b) + ',' + str(c)
		if xx not in pss:
			pss.add(xx)
			ps += [[a, b, c]]
ans = len(ps) * (len(ps) - 1) // 2
di = {}
for i in ps:
	xx = str(i[0]) + ',' + str(i[1])
	if xx in di:
		di[xx] += 1
	else:
		di[xx] = 1
for i in di:
	ans -= di[i] * (di[i] - 1) // 2
print(ans)


n = int(input())

def gcd(x, y):
	while y > 0:
		(x, y) = (y, x % y)
	return x
poles = []
for i in range(n):
	(x, y) = list(map(int, input().split()))
	poles.append((x, y))
lines = set()
for i in range(len(poles) - 1):
	for j in range(i + 1, len(poles)):
		p1 = poles[i]
		p2 = poles[j]
		a = p1[1] - p2[1]
		b = -p1[0] + p2[0]
		abg = gcd(abs(a), abs(b))
		if abg > 0:
			a //= abg
			b //= abg
		if a < 0:
			a = -a
			b = -b
		if a == 0:
			b = 1
		if b == 0:
			a = 1
		c = -a * p1[0] - b * p1[1]
		lines.add((a, b, c))
cnt = 0
for (i, line1) in enumerate(lines):
	for (j, line2) in enumerate(lines):
		if i >= j:
			continue
		if line1[:2] != line2[:2]:
			cnt += 1
print(cnt)


import math
n = int(input())
points = []
lines = set([])
for i in range(n):
	(x, y) = map(int, input().split())
	points.append((x, y))
for i in range(n):
	for j in range(i):
		if points[i][0] - points[j][0] == 0:
			lines.add((math.inf, points[i][0]))
		else:
			m = (points[i][1] - points[j][1]) / (points[i][0] - points[j][0])
			lines.add((m, round(-1 * m * points[i][0] + points[i][1], 3)))
lines = list(lines)
m = {}
for i in lines:
	if i[0] in m:
		m[i[0]] += 1
	else:
		m[i[0]] = 1
count = 0
m_ = sum(m.values())
count = m_ * (m_ - 1) // 2
for i in m:
	count -= m[i] * (m[i] - 1) // 2
print(count)


import sys
import collections
import math
import heapq
from operator import itemgetter

def getint():
	return int(input())

def getints():
	return [int(x) for x in input().split(' ')]
n = getint()
points = [tuple(getints()) for _ in range(n)]
result = total = 0
slopes = collections.defaultdict(set)
for i in range(n - 1):
	for j in range(i + 1, n):
		(x1, y1, x2, y2) = (points[i][0], points[i][1], points[j][0], points[j][1])
		(a, b) = (y1 - y2, x1 - x2)
		d = math.gcd(a, b)
		(a, b) = (a // d, b // d)
		if a < 0 or (a == 0 and b < 0):
			(a, b) = (-a, -b)
		c = a * x1 - b * y1
		slope = (a, b)
		if c not in slopes[slope]:
			total += 1
			slopes[slope].add(c)
			result += total - len(slopes[slope])
print(str(result))


from collections import defaultdict
import math
n = int(input().lstrip())
numbers = []
for _ in range(n):
	numbers.append(list(map(int, input().lstrip().split())))

def gcd(a, b):
	if not a:
		return b
	return gcd(b % a, a)
slope_map = defaultdict(set)
total = 0
res = 0
for i in range(n):
	for j in range(i + 1, n):
		(x1, y1) = numbers[i]
		(x2, y2) = numbers[j]
		a = y1 - y2
		b = x1 - x2
		d = gcd(a, b)
		a //= d
		b //= d
		if a < 0 or (not a and b < 0):
			a *= -1
			b *= -1
		slope = (a, b)
		c = a * x1 - b * y1
		if c not in slope_map[slope]:
			total += 1
			slope_map[slope].add(c)
			res += total - len(slope_map[slope])
print(res)


n = int(input())
l = set()
s = [list(map(int, input().split())) for _ in range(n)]
for i in range(n):
	for j in range(i + 1, n):
		(x1, y1) = s[i]
		(x2, y2) = s[j]
		if x1 == x2:
			l.add((float('INF'), x1))
		else:
			a = (y1 - y2) / (x1 - x2)
			b = (x1 * y2 - x2 * y1) / (x1 - x2)
			l.add((a, b))
lis = [i[0] for i in l]
from collections import Counter
dic = Counter(lis)
r = len(l) ** 2 - len(l)
for i in dic:
	r -= dic[i] ** 2 - dic[i]
print(r // 2)


import math

class Pt:

	def __init__(self, *args):
		if len(args) == 0:
			(self.x, self.y) = (0, 0)
		elif len(args) == 1:
			(self.x, self.y) = list(map(int, args[0].split()))
		else:
			(self.x, self.y) = (args[0], args[1])

	def __str__(self):
		return str(self.x) + ' ' + str(self.y)

	def __add__(self, other):
		return Pt(self.x + other.x, self.y + other.y)

	def __sub__(self, other):
		return Pt(self.x - other.x, self.y - other.y)

	def __mul__(self, other):
		return Pt(self.x * other, self.y * other)

	def __rmul__(self, other):
		return self * other

	def __truediv__(self, other):
		return Pt(self.x / other, self.y / other)

	def __abs__(self):
		return math.hypot(self.x, self.y)

	def __eq__(self, other):
		return self.x == other.x and self.y == other.y

	def dot(self, other):
		return self.x * other.x + self.y * other.y

	def cross(self, other):
		return self.x * other.y - self.y * other.x

	@staticmethod
	def get_straight(self, other):
		a = self.y - other.y
		b = other.x - self.x
		c = self.cross(other)
		return (a, b, c)

class Straight:

	def __init__(self, *args):
		if len(args) == 1:
			(self.a, self.b, self.c) = list(map(int, args[0].split()))
		elif len(args) == 2:
			(self.a, self.b, self.c) = Pt.get_straight(*args)
		elif len(args) == 3:
			(self.a, self.b, self.c) = args

	def __str__(self):
		return ' '.join(map(str, [self.a, self.b, self.c]))

	def __eq__(self, other):
		if self.b != 0 or other.b != 0:
			return self.a * other.b == other.a * self.b and self.c * other.b == other.c * self.b
		val1 = math.sqrt(self.a ** 2 + self.b ** 2)
		val2 = math.sqrt(other.a ** 2 + other.b ** 2)
		(a1, c1) = (self.a / val1, self.c / val1)
		(a2, c2) = (other.a / val2, other.c / val2)
		if (a1 < 0) != (a2 < 0):
			(a1, a2, c1, c2) = (a1, -a2, c1, -c2)
		return a1 == a2 and c1 == c2

	def perpendicular(self, point: Pt):
		return Straight(-self.b, self.a, self.b * point.x - self.a * point.y)

	def get_value(self, point):
		return self.a * point.x + self.b * point.y + self.c

	def is_own(self, point: Pt):
		return self.get_value(point) == 0

	def same_side(self, pt1, pt2):
		return (self.get_value(pt1) < 0) == (self.get_value(pt2) < 0)

	def intersection(self, other):
		d = Pt(self.a, self.b).cross(Pt(other.a, other.b))
		dx = Pt(self.c, self.b).cross(Pt(other.c, other.b))
		dy = Pt(self.a, self.c).cross(Pt(other.a, other.c))
		return Pt(-dx / d, -dy / d)

	def dist_from_point(self, point):
		val = math.sqrt(self.a ** 2 + self.b ** 2)
		return abs(Straight(self.a / val, self.b / val, self.c / val).get_value(point))

	def parallel(self, dist):
		val = math.sqrt(self.a ** 2 + self.b ** 2)
		return Straight(self.a, self.b, self.c - dist * val)

	def is_parallel(self, other):
		return self.a * other.b == self.b * other.a

	def is_perpendicular(self, other):
		per = Straight(-self.b, self.a, 0)
		return per.a * other.b == per.b * other.a
n = int(input())
points = [Pt(input()) for _ in range(n)]
straights = []
for i in range(n):
	for j in range(i + 1, n):
		st = Straight(points[i], points[j])
		ok = True
		for x in straights:
			if st == x:
				ok = False
				break
		if ok:
			straights.append(st)
res = 0
m = len(straights)
for i in range(m):
	for j in range(i + 1, m):
		if not straights[i].is_parallel(straights[j]):
			res += 1
print(res)


n = int(input())
x = [0 for i in range(0, n + 1)]
y = [0 for i in range(0, n + 1)]
for i in range(1, n + 1):
	(x[i], y[i]) = map(int, input().split())
di = {}
for i in range(1, n + 1):
	a = {}
	for j in range(i + 1, n + 1):
		if x[j] - x[i] == 0:
			if '0' not in a:
				a['0'] = 1
			else:
				a['0'] = a['0'] + 1
		else:
			k = (y[j] - y[i]) / (x[j] - x[i])
			if k not in a:
				a[k] = 1
			else:
				a[k] = a[k] + 1
	for (key, value) in a.items():
		if value > 1:
			continue
		if key in di:
			di[key] = di[key] + 1
		else:
			di[key] = 1
b = []
for v in di.values():
	b.append(v)
b.sort()
_sum = 0
for i in b:
	_sum += i
ans = 0
for i in b:
	ans += i * (_sum - i)
	_sum -= i
print(ans)


from math import gcd

def get_2dline(p1, p2):
	if p1 == p2:
		return (0, 0, 0)
	(_p1, _p2) = (min(p1, p2), max(p1, p2))
	(a, b, c) = (_p2[1] - _p1[1], _p1[0] - _p2[0], _p1[1] * _p2[0] - _p1[0] * _p2[1])
	g = gcd(gcd(a, b), c)
	return (a // g, b // g, c // g)
is_parallel = lambda l1, l2: l1[0] * l2[1] == l2[0] * l1[1]

def main():
	n = int(input())
	p = [(0, 0)] * n
	for i in range(n):
		p[i] = tuple(map(int, input().split()))
	cnt = 0
	lines = set()
	for i in range(n):
		for j in range(i + 1, n):
			line = get_2dline(p[i], p[j])
			if line not in lines:
				for other in lines:
					cnt += not is_parallel(line, other)
				lines.add(line)
	print(cnt)
main()


import os
import sys
import math
from io import BytesIO, IOBase
from fractions import Fraction
from collections import defaultdict
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
n = int(input())
p = []
for i in range(n):
	(x, y) = map(int, input().split())
	p.append((x, y))
d = {}
for i in range(n):
	(x1, y1) = p[i]
	for j in range(i + 1, n):
		(x2, y2) = p[j]
		if x1 != x2:
			m = (y2 - y1) / (x2 - x1)
			c = (y1 * x2 - x1 * y2) / (x2 - x1)
		else:
			m = 10 ** 10
			c = x1
		if m in d:
			if c in d[m]:
				d[m][c] += 1
			else:
				d[m][c] = 1
		else:
			d[m] = {c: 1}
p = []
for m in d:
	p.append(len(d[m]))
s = sum(p)
ans = 0
for x in p:
	ans += x * (s - x)
print(ans // 2)


from collections import defaultdict
import math
n = int(input())
points = []
lines1 = defaultdict(set)
lines = []
lines_ = 0
for i in range(n):
	(x, y) = input().split()
	(x, y) = [int(x), int(y)]
	points.append([x, y])
points.sort()
for i in range(n):
	for j in range(i):
		a = points[i][1] - points[j][1]
		b = points[i][0] - points[j][0]
		c = points[i][1] * points[j][0] - points[j][1] * points[i][0]
		gcd_ = math.gcd(a, math.gcd(b, c))
		(a, b, c) = (a // gcd_, b // gcd_, c // gcd_)
		lines1[a, b].add(c)
		if [a, b, c] not in lines:
			lines.append([a, b, c])
			lines_ += 1
lines_ = lines_ * (lines_ - 1) / 2
for (i, value) in lines1.items():
	s = len(value)
	lines_ -= s * (s - 1) // 2
print(int(lines_))


from sys import stdin, stdout
import math
from itertools import accumulate

def getabc(x1, y1, x2, y2):
	t1 = x2 - x1
	t2 = y2 - y1
	t3 = y1 * x2 - y2 * x1
	if t1 < 0:
		t1 = t1 * -1
		t2 = t2 * -1
		t3 = t3 * -1
	t4 = math.gcd(math.gcd(t1, t2), t3)
	return (t1 // t4, t2 // t4, t3 // t4)
n = int(stdin.readline())
x = []
y = []
for i in range(n):
	(xi, yi) = stdin.readline().strip().split(' ')
	x.append(int(xi))
	y.append(int(yi))
d = {}
there = {}
for i in range(len(x)):
	for j in range(i + 1, len(x)):
		num = y[i] - y[j]
		den = x[i] - x[j]
		if num == 0:
			key = 'yintercept' + str(y[i])
			if key not in d:
				d[key] = 1
		elif den == 0:
			key = 'xintercept' + str(x[i])
			if key not in d:
				d[key] = 1
		else:
			(a, b, c) = getabc(x[i], y[i], x[j], y[j])
			key = str(a) + ' ' + str(b) + ' ' + str(c)
			keys = str(a) + ' ' + str(b)
			if key not in there:
				if keys in d:
					d[keys] += 1
				else:
					d[keys] = 1
				there[key] = 1
ansarr = [0, 0]
for i in d:
	if i[0] == 'x':
		ansarr[0] += 1
	elif i[0] == 'y':
		ansarr[1] += 1
	else:
		ansarr.append(d[i])
ans = 0
tarr = sum(ansarr)
for i in range(len(ansarr)):
	ans += (tarr - ansarr[i]) * ansarr[i]
stdout.write(str(ans // 2) + '\n')


from collections import defaultdict
from fractions import Fraction
import sys
poles = int(input())
points = []
for _ in range(poles):
	(x, y) = map(int, sys.stdin.readline().split())
	points.append((x, y))
lines = defaultdict(set)
v_lines = set()
h_lines = set()
for i in range(poles):
	for j in range(i + 1, poles):
		if points[i][0] == points[j][0]:
			v_lines.add(points[i][0])
		elif points[i][1] == points[j][1]:
			h_lines.add(points[i][1])
		else:
			a = Fraction(points[i][1] - points[j][1], points[i][0] - points[j][0])
			b = points[i][1] - a * points[i][0]
			lines[a].add(b)
t_lines = sum([len(x) for x in lines.values()])
ans = len(v_lines) * (t_lines + len(h_lines))
ans += len(h_lines) * t_lines
for item in lines.values():
	t_lines -= len(item)
	ans += len(item) * t_lines
print(ans)


from fractions import Fraction
VERT = object()
n = int(input())
points = [tuple(map(int, input().split())) for _ in range(n)]
d = {}
for (i, p) in enumerate(points):
	(x1, y1) = p
	for (x2, y2) in points[i + 1:]:
		if x1 < x2:
			f = Fraction(y2 - y1, x2 - x1)
		elif x1 > x2:
			f = Fraction(y1 - y2, x1 - x2)
		else:
			f = VERT
		if f == VERT:
			x_inter = x1
		else:
			x_inter = y1 - x1 * f
		if f == VERT:
			key = VERT
			value = x_inter
		else:
			key = f.numerator / f.denominator
			value = x_inter.numerator / x_inter.denominator
		if key in d:
			d[key].add(x_inter)
		else:
			d[key] = {x_inter}
total = sum((len(s) for s in d.values()))
total_inter = 0
for s in d.values():
	total_inter += len(s) * (total - len(s))
print(total_inter // 2)


from collections import Counter
from sys import exit
N = int(input())
if N == 2:
	print(0)
	exit()
inf = 10 ** 9 + 7
inf2 = 10 ** 18

def gcdl(A):
	if len(A) == 0:
		return -1
	if len(A) == 1:
		return 0
	g = gcd(A[0], A[1])
	for a in A[2:]:
		g = gcd(a, g)
	return g

def gcd(a, b):
	if b == 0:
		return a
	return gcd(b, a % b)
Point = []
ans = 0
for _ in range(N):
	Point.append(list(map(int, input().split())))
S = Counter()
T = set()
for i in range(N):
	(x1, y1) = Point[i]
	for j in range(N):
		if i == j:
			continue
		(x2, y2) = Point[j]
		a = y1 - y2
		b = -(x1 - x2)
		c = x2 * y1 - x1 * y2
		g = gcdl([a, b, c])
		a //= g
		b //= g
		c //= g
		if a < 0:
			a *= -1
			b *= -1
			c *= -1
		k = a * inf + b * inf2 + c
		if k not in T:
			T.add(a * inf + b * inf2 + c)
			if x1 == x2:
				S[-1] += 1
			else:
				y = y1 - y2
				x = x1 - x2
				g = gcd(y, x)
				y //= g
				x //= g
				if y < 0:
					y *= -1
					x *= -1
				S[y * inf + x] += 1
L = len(T)
ans = L * (L - 1) // 2
for s in S.values():
	ans -= s * (s - 1) // 2
print(ans)


import sys
import math

def main():
	n = int(sys.stdin.readline().strip())
	p = []
	for _ in range(n):
		(x, y) = map(int, sys.stdin.readline().strip().split())
		p.append((x, y))
	s = {}
	for i in range(n):
		(x1, y1) = p[i]
		for j in range(i + 1, n):
			(x2, y2) = p[j]
			slope = 0
			cons = 0
			if x1 == x2:
				slope = 10 ** 10
				cons = x1
			else:
				slope = (y1 - y2) / (x1 - x2)
				cons = (y1 * x2 - x1 * y2) / (x2 - x1)
			if slope in s:
				if cons in s[slope]:
					s[slope][cons] += 1
				else:
					s[slope][cons] = 1
			else:
				s[slope] = {cons: 1}
	p = []
	for m in s:
		p.append(len(s[m]))
	s = sum(p)
	ans = 0
	for x in p:
		ans += x * (s - x)
	print(ans // 2)
main()


def get_k(a, b):
	(x1, y1) = a
	(x2, y2) = b
	if x2 != x1:
		return (y2 - y1) / (x2 - x1)
	return 10 ** 10

def get_offset(a, k2):
	(x, y) = a
	return y - k2 * x
cnt = 0
a = []
n = int(input())
for i in range(n):
	a.append(tuple(map(int, input().split())))
alines = []
for i in range(n):
	for j in range(n):
		if i >= j:
			continue
		alines.append((a[i], a[j]))
lines = []
s = set()
for (i, l1) in enumerate(alines):
	for j in range(i + 1, len(alines)):
		l2 = alines[j]
		(k1, k2) = (get_k(*l1), get_k(*l2))
		(o1, o2) = (get_offset(l1[0], k1), get_offset(l2[0], k2))
		if k1 == k2 == 10 ** 10 and l1[0][0] == l2[0][0]:
			o1 = o2 = 0
		if abs(k1 - k2) < 1e-10 and abs(o1 - o2) < 1e-10 or (k1 == k2 == 10 ** 10 and l1[0] == l2[0]):
			s.add(j)
	if i not in s:
		lines.append(l1)
for (i, l1) in enumerate(lines):
	for (j, l2) in enumerate(lines):
		if i >= j:
			continue
		if abs(get_k(*l1) - get_k(*l2)) > 1e-10:
			cnt += 1
print(cnt)


def pos_gcd(a, b):
	if a == 0 and b == 0:
		return 1
	if b == 0:
		return a
	return pos_gcd(b, a % b)

def gcd2(a, b):
	return pos_gcd(abs(a), abs(b))

def gcd(a, b, c):
	return gcd2(gcd2(a, b), c)

def make_line(p1, p2):
	a = p2[1] - p1[1]
	b = p1[0] - p2[0]
	c = -a * p1[0] - b * p1[1]
	d = gcd(a, b, c)
	a //= d
	b //= d
	c //= d
	if a < 0:
		a = -a
		b = -b
		c = -c
	elif a == 0 and b < 0:
		b = -b
		c = -c
	return (a, b, c)

def parallel(l1, l2):
	return l1[0] == l2[0] and l1[1] == l2[1]
n = int(input())
pointlist = []
lineset = set()
for i in range(n):
	p = tuple(map(int, input().split(' ')))
	for q in pointlist:
		lineset.add(make_line(p, q))
	pointlist.append(p)
linelist = list(lineset)
ans = 0
for i in range(len(linelist)):
	for j in range(i):
		if not parallel(linelist[i], linelist[j]):
			ans += 1
print(ans)


def pos_gcd(a, b):
	if a == 0 and b == 0:
		return 1
	if b == 0:
		return a
	return pos_gcd(b, a % b)

def gcd2(a, b):
	return pos_gcd(abs(a), abs(b))

def gcd(a, b, c):
	return gcd2(gcd2(a, b), c)

def make_line(p1, p2):
	a = p2[1] - p1[1]
	b = p1[0] - p2[0]
	c = -a * p1[0] - b * p1[1]
	d = gcd(a, b, c)
	a //= d
	b //= d
	c //= d
	if a < 0:
		a = -a
		b = -b
		c = -c
	elif a == 0 and b < 0:
		b = -b
		c = -c
	return (a, b, c)

def parallel(l1, l2):
	return l1[0] == l2[0] and l1[1] == l2[1]
n = int(input())
pointlist = []
lineset = set()
for i in range(n):
	p = tuple(map(int, input().split(' ')))
	for q in pointlist:
		lineset.add(make_line(p, q))
	pointlist.append(p)
linedict = {}
for l in lineset:
	l1 = (l[0], l[1])
	if l1 not in linedict:
		linedict[l1] = 1
	else:
		linedict[l1] += 1
linecount = 0
ans = 0
for l in linedict.keys():
	linecount += linedict[l]
for l in linedict.keys():
	linecount -= linedict[l]
	ans += linedict[l] * linecount
print(ans)


from sys import setcheckinterval, stdin, setrecursionlimit
setcheckinterval(1000)
setrecursionlimit(10 ** 6)
iin = lambda : int(stdin.readline())
lin = lambda : list(map(int, stdin.readline().split()))
from fractions import gcd
n = iin()
points = [lin() for i in range(n)]
ans = set()
for i in range(n):
	(x1, y1) = points[i]
	for j in range(i + 1, n):
		(x2, y2) = points[j]
		(a, b, c) = (y1 - y2, x2 - x1, y1 * (x1 - x2) - x1 * (y1 - y2))
		g = gcd(gcd(a, b), c) if c else gcd(a, b)
		ans.add((a // g, b // g, c // g))
intersections = set()
la = list(ans)
l = len(la)
for i in range(l):
	(a, b, c) = la[i]
	for j in range(i + 1, l):
		try:
			(e, d, f) = la[j]
			y = (a * f - c * e) / (b * e - a * d)
			x = (c * d - b * f) / (b * e - a * d)
			intersections.add((i, j))
		except:
			pass
print(len(intersections))


from functools import reduce
from math import gcd
import collections
gcdm = lambda *args: reduce(gcd, args, 0)

def pointsToLine2d(p1, p2):
	if p1 == p2:
		return (0, 0, 0)
	(_p1, _p2) = sorted((p1, p2))
	g = gcdm(*filter(lambda x: x != 0, (_p2[1] - _p1[1], _p1[0] - _p2[0], _p1[1] * _p2[0] - _p1[0] * _p2[1])))
	return ((_p2[1] - _p1[1]) // g, (_p1[0] - _p2[0]) // g, (_p1[1] * _p2[0] - _p1[0] * _p2[1]) // g)

def main():
	from sys import stdin, stdout

	def read():
		return stdin.readline().rstrip('\n')

	def read_array(sep=None, maxsplit=-1):
		return read().split(sep, maxsplit)

	def read_int():
		return int(read())

	def read_int_array(sep=None, maxsplit=-1):
		return [int(a) for a in read_array(sep, maxsplit)]

	def write(*args, **kwargs):
		sep = kwargs.get('sep', ' ')
		end = kwargs.get('end', '\n')
		stdout.write(sep.join((str(a) for a in args)) + end)

	def write_array(array, **kwargs):
		sep = kwargs.get('sep', ' ')
		end = kwargs.get('end', '\n')
		stdout.write(sep.join((str(a) for a in array)) + end)
	n = read_int()
	p = []
	for _ in range(n):
		p.append(read_int_array())
	lines = set()
	for i in range(n):
		for j in range(i + 1, n):
			lines.add(pointsToLine2d(p[i], p[j]))
	k = len(lines)
	ax_bx = collections.defaultdict(int)
	out = 0
	for (a, b, _) in lines:
		ax_bx[a, b] += 1
	for x in ax_bx.values():
		out += (k - x) * x
	write(out // 2)
main()


from fractions import Fraction
from collections import defaultdict
n = int(input())
points = []
for _ in range(n):
	points.append(tuple(map(int, input().split())))
lines = set()
for i in range(n):
	for j in range(i + 1, n):
		if points[i][0] == points[j][0]:
			a = Fraction(10 ** 9, 1)
			b = Fraction(points[i][0], 1)
		else:
			a = Fraction(points[i][1] - points[j][1], points[i][0] - points[j][0])
			b = -a * Fraction(points[j][0], 1) + Fraction(points[j][1], 1)
		lines.add((a, b))
linecnter = defaultdict(int)
for l in lines:
	linecnter[l[0]] += 1
ans = 0
for v in linecnter.values():
	ans += (len(lines) - v) * v
print(ans // 2)


def gcd(a, b):
	while b:
		(a, b) = (b, a % b)
	return a
n = int(input())
p = [0] * n
for i in range(n):
	p[i] = [int(item) for item in input().split()]
wires = set()
for i in range(n):
	for j in range(i + 1, n):
		(x0, y0) = p[i]
		(x1, y1) = p[j]
		a = -(y1 - y0)
		b = x1 - x0
		c = x0 * (y1 - y0) - y0 * (x1 - x0)
		k = gcd(a, gcd(b, c))
		a //= k
		b //= k
		c //= k
		if a < 0:
			a *= -1
			b *= -1
			c *= -1
		wires.add((a, b, c))
wires = list(wires)
ans = 0
for i in range(len(wires)):
	for j in range(i + 1, len(wires)):
		(a1, b1, c1) = wires[i]
		(a2, b2, c2) = wires[j]
		if b1 == 0:
			if b2 != 0:
				ans += 1
		elif b2 == 0:
			ans += 1
		elif abs(a1 / b1 - a2 / b2) > 1e-07:
			ans += 1
print(ans)


from math import gcd
from collections import defaultdict

def go():
	n = int(input())
	pairs = []
	for _ in range(n):
		pairs.append([int(i) for i in input().split(' ')])
	total = 0
	result = 0
	wires = defaultdict(set)
	for i in range(n):
		for j in range(i + 1, n):
			(x1, y1) = pairs[i]
			(x2, y2) = pairs[j]
			a = y1 - y2
			b = x1 - x2
			g = gcd(a, b)
			if a < 0 or (a == 0 and b < 0):
				a = -a
				b = -b
			a //= g
			b //= g
			wires[a, b]
			c = a * x1 - b * y1
			pair = (a, b)
			if c not in wires[pair]:
				wires[pair].add(c)
				total += 1
				result += total - len(wires[pair])
	return result
print(go())


import itertools
import math
from functools import reduce
from math import gcd
gcdm = lambda *args: reduce(gcd, args, 0)

def pointsToLine2d(p1, p2):
	if p1 == p2:
		return (0, 0, 0)
	(_p1, _p2) = sorted((p1, p2))
	g = gcdm(*[x for x in (_p2[1] - _p1[1], _p1[0] - _p2[0], _p1[1] * _p2[0] - _p1[0] * _p2[1]) if x != 0])
	return ((_p2[1] - _p1[1]) // g, (_p1[0] - _p2[0]) // g, (_p1[1] * _p2[0] - _p1[0] * _p2[1]) // g)
dist = lambda p1, p2: sum(((a - b) * (a - b) for (a, b) in zip(p1, p2))) ** 0.5
pointsToLines = lambda p1, p2: list(map(pointsToLine2d, itertools.combinations(p1, 2), itertools.combinations(p2, 2)))
areParallel = lambda l1, l2: l1[0] * l2[1] == l2[0] * l1[1]
areSame = lambda l1, l2: areParallel(l1, l2) and l1[1] * l2[2] == l2[1] * l1[2]
collinear = lambda p1, p2, p3: areSame(pointsToLine2d(p1, p2), pointsToLine2d(p2, p3))
intersect = lambda l1, l2: None if areParallel(l1, l2) else ((l2[1] * l1[2] - l1[1] * l2[2]) / (l2[0] * l1[1] - l1[0] * l2[1]), (l1[0] * l2[2] - l1[2] * l2[0]) / (l2[0] * l1[1] - l1[0] * l2[1]))
rotate = lambda p, theta, origin=(0, 0): (origin[0] + (p[0] - origin[0]) * math.cos(theta) - (p[1] - origin[1]) * math.sin(theta), origin[1] + (p[0] - origin[0]) * math.sin(theta) + (p[1] - origin[1]) * math.cos(theta))

def main():
	from sys import stdin, stdout

	def read():
		return stdin.readline().rstrip('\n')

	def read_array(sep=None, maxsplit=-1):
		return read().split(sep, maxsplit)

	def read_int():
		return int(read())

	def read_int_array(sep=None, maxsplit=-1):
		return [int(a) for a in read_array(sep, maxsplit)]

	def write(*args, **kwargs):
		sep = kwargs.get('sep', ' ')
		end = kwargs.get('end', '\n')
		stdout.write(sep.join((str(a) for a in args)) + end)

	def write_array(array, **kwargs):
		sep = kwargs.get('sep', ' ')
		end = kwargs.get('end', '\n')
		stdout.write(sep.join((str(a) for a in array)) + end)
	n = read_int()
	p = []
	for _ in range(n):
		p.append(read_int_array())
	lines = set()
	for i in range(n):
		for j in range(i + 1, n):
			lines.add(pointsToLine2d(p[i], p[j]))
	k = len(lines)
	import collections
	ax_bx = collections.defaultdict(int)
	out = 0
	for (a, b, _) in lines:
		ax_bx[a, b] += 1
	for x in list(ax_bx.values()):
		out += (k - x) * x
	write(out // 2)
main()


from itertools import combinations
n = int(input())
points = []
for _ in range(n):
	(x, y) = map(int, input().split(' '))
	points.append((x, y))
directions = {}
for pair in combinations(points, 2):
	((x1, y1), (x2, y2)) = pair
	if x1 == x2:
		dir = (0, 1)
		b = x1
	else:
		dir = (1, (y2 - y1) / (x2 - x1))
		b = (y2 * x1 - x2 * y1) / (x1 - x2)
	if dir in directions:
		directions[dir].add(b)
	else:
		directions[dir] = set([b])
total_lines = sum((len(value) for (key, value) in directions.items()))
result = 0
for (key, value) in directions.items():
	current = len(value)
	result += (total_lines - current) * current
print(int(result / 2))


from collections import defaultdict
import math
n = int(input())
points = []
lines1 = defaultdict(set)
lines = []
parallel = defaultdict(list)
lines_ = 0
parallel_ = 0
for i in range(n):
	(x, y) = input().split()
	(x, y) = [int(x), int(y)]
	points.append([x, y])
points.sort()
count = 0
for i in range(n):
	for j in range(i):
		a = points[i][1] - points[j][1]
		b = points[i][0] - points[j][0]
		c = points[i][1] * points[j][0] - points[j][1] * points[i][0]
		gcd_ = math.gcd(a, math.gcd(b, c))
		(a, b, c) = (a // gcd_, b // gcd_, c // gcd_)
		count += 1
		lines1[a, b].add(c)
		if [a, b, c] not in lines:
			lines.append([a, b, c])
			lines_ += 1
s = 0
for v in lines1.values():
	s += len(v)
lines2 = s * (s - 1) // 2
for (i, value) in lines1.items():
	s = len(value)
	lines2 -= s * (s - 1) // 2
print(lines2)


n = int(input())
coords = []
for i in range(n):
	coords.append(tuple(map(int, input().split())))
slopes = {}
for i in range(n):
	for j in range(i + 1, n):
		(x1, y1) = (coords[i][0], coords[i][1])
		(x2, y2) = (coords[j][0], coords[j][1])
		if x1 == x2:
			slope = 'inf'
			mark = x1
		else:
			slope = round((y2 - y1) / (x2 - x1), 12)
			mark = round(y1 - x1 * slope, 7)
		if slope in slopes:
			slopes[slope].add(mark)
		else:
			slopes[slope] = {mark}
tot = sum((len(slopes[guy]) for guy in slopes))
sumi = 0
for guy in slopes:
	a = len(slopes[guy])
	sumi += a * (tot - a)
print(sumi // 2)


lines = set()
points = []
num = int(input())
for i in range(num):
	points.append([int(j) for j in input().split()])
for i in range(num):
	for j in range(i):
		dx = points[j][0] - points[i][0]
		if dx == 0:
			lines.add((378597736461, points[i][0]))
		else:
			m = (points[j][1] - points[i][1]) / dx
			lines.add((int(100000000 * m), int(100000000 * (points[i][1] - m * points[i][0]))))
ms = {}
for l in lines:
	if l[0] in ms:
		ms[l[0]] += 1
	else:
		ms[l[0]] = 1
total = 0
t = list(ms.values())
s = sum(t)
for a in t:
	total += a * (s - a)
print(total // 2)


from collections import *

def li():
	return [int(i) for i in input().split()]

def val():
	return int(input())
n = val()
l = []
for i in range(n):
	l.append(li())
d = defaultdict(int)
visited = set()
for i in range(n):
	for j in range(i):
		try:
			slope = (l[i][1] - l[j][1]) / (l[i][0] - l[j][0])
		except:
			slope = 'inf'
		if slope == 'inf':
			intercept = l[j][0]
		else:
			intercept = (l[j][1] * l[i][0] - l[i][1] * l[j][0]) / (l[i][0] - l[j][0])
		if tuple([slope, intercept]) not in visited:
			d[slope] += 1
			visited.add(tuple([slope, intercept]))
tot = sum(d.values())
ans = 0
for i in list(d):
	tot -= d[i]
	ans += tot * d[i]
	d.pop(i)
print(ans)


from collections import defaultdict as dd
from itertools import combinations
import math
import heapq

def nn():
	return int(input())

def li():
	return list(input())

def mi():
	return list(map(int, input().split()))

def lm():
	return list(map(int, input().split()))
n = nn()
points = []
for i in range(n):
	points.append(lm())
slopedict = dd(set)
lines = 0
for (p1, p2) in combinations(points, 2):
	(x1, y1) = p1
	(x2, y2) = p2
	g = math.gcd(y2 - y1, x2 - x1)
	if y2 - y1 < 0:
		sign = -1
	elif y2 - y1 == 0:
		if x2 - x1 < 0:
			sign = -1
		else:
			sign = 1
	else:
		sign = 1
	slope = (sign * (y2 - y1) // g, sign * (x2 - x1) // g)
	if not slope[1] == 0:
		ceptn = slope[1] * y1 - slope[0] * x1
		ceptd = slope[1]
		if ceptn < 0:
			sign = -1
		elif ceptn == 0:
			if ceptd < 0:
				sign = -1
			else:
				sign = 1
		else:
			sign = 1
		g = math.gcd(ceptn, ceptd)
		cept = (sign * ceptn / g, sign * ceptd / g)
	else:
		cept = x1
	if not cept in slopedict[slope]:
		slopedict[slope].add(cept)
		lines += 1
total = 0
for slope in slopedict:
	total = total + (lines - len(slopedict[slope])) * len(slopedict[slope])
print(total // 2)
pos = math.gcd(-4, 2)
neg = math.gcd(4, -2)


n = int(input())

def gcd(a, b):
	if a == 0:
		return b
	return gcd(b % a, a)
points = []
lines = set()
counter = 0
for i in range(n):
	a = [int(x) for x in input().split()]
	points.append(a)
for item in points:
	for elem in points:
		if item != elem:
			g = gcd(item[1] - elem[1], item[0] - elem[0])
			k = ((item[1] - elem[1]) // g, (item[0] - elem[0]) // g, (item[1] * elem[0] - elem[1] * item[0]) // g)
			if k[0] < 0 or (k[0] == 0 and k[1] < 0):
				k = (-k[0], -k[1])
			lines.add(k)
lines = sorted(lines)
lines.append((10 ** 100, 10 ** 100))
x = len(lines)
counter = 1
answer = (x - 1) * (x - 2) // 2
for i in range(1, x):
	if lines[i][0] == lines[i - 1][0] and lines[i][1] == lines[i - 1][1]:
		counter += 1
	else:
		answer -= counter * (counter - 1) // 2
		counter = 1
print(answer)


n = int(input().strip())
num = []
for k in range(n):
	num.append(list(map(int, input().strip().split())))
d = {}
import math
for k in range(n):
	for kk in range(k + 1, n):
		a = num[k]
		b = num[kk]
		if a[0] == b[0]:
			if (100000, 100000) in d.keys():
				d[100000, 100000].add(a[0])
			else:
				d[100000, 100000] = {a[0]}
		elif a[1] == b[1]:
			if (0, 1) in d.keys():
				d[0, 1].add(a[1])
			else:
				d[0, 1] = {a[1]}
		else:
			c = b[1] - a[1]
			dd = b[0] - a[0]
			q = math.gcd(c, dd)
			c1 = c // q
			d1 = dd // q
			r = a[0] * b[1] - a[1] * b[0]
			if r != 0:
				rr = math.gcd(r, dd)
				r = r // rr
				d2 = dd // rr
				if d2 < 0:
					d2 = -d2
					r = -r
				if d1 < 0:
					d1 = -d1
					c1 = -c1
				if (c1, d1) in d.keys():
					d[c1, d1].add((r, d2))
				else:
					d[c1, d1] = {(r, d2)}
			else:
				if d1 < 0:
					d1 = -d1
					c1 = -c1
				if (c1, d1) in d.keys():
					d[c1, d1].add((0, 1))
				else:
					d[c1, d1] = {(0, 1)}
s = 0
for i in d.keys():
	s = s + len(d[i])
ss = 0
for i in d.keys():
	s = s - len(d[i])
	ss = ss + s * len(d[i])
print(ss)


def gcd(x, y):
	if y == 0:
		return x
	else:
		return gcd(y, x % y)
from collections import *
n = int(input())
ps = []
for i in range(n):
	ps.append([int(i) for i in input().split(' ')])
xs = 0
ys = 0
lines = defaultdict(int)
cache = set()
xcache = set()
ycache = set()
for i in range(n):
	for j in range(i + 1, n):
		if ps[i][0] == ps[j][0]:
			if ps[i][0] in xcache:
				continue
			xcache.add(ps[i][0])
			xs += 1
			continue
		if ps[i][1] == ps[j][1]:
			if ps[i][1] in ycache:
				continue
			ycache.add(ps[i][1])
			ys += 1
			continue
		tmpp = sorted([ps[i], ps[j]])
		tmppp = (tmpp[1][0] - tmpp[0][0], tmpp[1][1] - tmpp[0][1])
		gcdd = gcd(abs(tmpp[1][0] - tmpp[0][0]), abs(tmpp[1][1] - tmpp[0][1]))
		tmppp = (tmppp[0] // gcdd, tmppp[1] // gcdd)
		kkk = (tmppp[1], tmppp[0])
		if tmppp[1] < 0:
			kkk = (-tmppp[1], -tmppp[0])
		qqq = (tmppp[1] * -ps[i][0] + tmppp[0] * ps[i][1], tmppp[0])
		if qqq[0] < 0:
			qqq = (-qqq[0], -qqq[1])
		line = (kkk, qqq)
		if line in cache:
			continue
		cache.add(line)
		lines[kkk] += 1
tmp = xs + ys + sum(lines.values())
print((tmp * (tmp - 1) - sum((v * (v - 1) for v in lines.values())) - xs * (xs - 1) - ys * (ys - 1)) // 2)


import sys
input = sys.stdin.readline
from math import gcd
n = int(input())
p = [list(map(int, input().split())) for i in range(n)]
lines = []
for i in range(n):
	(x1, y1) = p[i]
	for j in range(i + 1, n):
		(x2, y2) = p[j]
		a = y1 - y2
		b = x1 - x2
		c = y1 * x2 - x1 * y2
		if a < 0 or (a == 0 and b < 0):
			a = -a
			b = -b
			c = -c
		g = gcd(a, gcd(b, c))
		a //= g
		b //= g
		c //= g
		lines.append((a, b, c))
lines = list(set(lines))
m = len(lines)
lines.sort(key=lambda x: x[1] / max(x[0], 10 ** (-10)))
cnt = 1
ans = m * (m - 1) // 2
for i in range(m - 1):
	(a1, b1, c1) = lines[i]
	(a2, b2, c2) = lines[i + 1]
	if a1 * b2 - a2 * b1 == 0:
		cnt += 1
	else:
		ans -= cnt * (cnt - 1) // 2
		cnt = 1
ans -= cnt * (cnt - 1) // 2
print(ans)


from math import *
from itertools import *
n = int(input())
map = {}
l = []
r = []
now = 0
tot = 0
lth = []
for _ in range(n):
	s = input().split(' ')
	l.append(int(s[0]))
	r.append(int(s[1]))
for i in range(n):
	for j in range(i + 1, n):
		if l[i] == l[j]:
			y = 9999999999999999999
			x = l[i]
		else:
			y = (r[i] - r[j]) / (l[i] - l[j])
			x = (r[j] * l[i] - l[j] * r[i]) / (l[i] - l[j])
		if not y in map:
			map[y] = {x: 1}
		elif x in map[y]:
			map[y][x] += 1
		else:
			map[y][x] = 1
for i in map:
	lth.append(len(map[i]))
	now += lth[len(lth) - 1]
for i in lth:
	tot += (now - i) * i
	now -= i
print(tot)


import math
import itertools
from collections import Counter
n = int(input())
coords = [[int(t) for t in input().split(' ')] for _ in range(n)]
lines = set()
for pair in itertools.combinations(coords, 2):
	l = min(pair)
	r = max(pair)
	a = r[1] - l[1]
	b = r[0] - l[0]
	c = r[1] * l[0] - l[1] * r[0]
	gcd = math.gcd(math.gcd(a, b), c)
	a /= gcd
	b /= gcd
	c /= gcd
	lines.add((a, b, c))
num_lines = len(lines)
count = Counter(((a, b) for (a, b, c) in lines))
result = num_lines * (num_lines - 1) // 2
for (_, c) in count.items():
	result -= c * (c - 1) // 2
print(result)


import sys, math, itertools
from collections import Counter, deque, defaultdict
from bisect import bisect_left, bisect_right
from heapq import heappop, heappush, heapify, nlargest
mod = 10 ** 9 + 7
INF = float('inf')

def inp():
	return int(sys.stdin.readline())

def inpl():
	return list(map(int, sys.stdin.readline().split()))
n = inp()
a = [tuple(map(int, sys.stdin.readline().split())) for _ in range(n)]
d = defaultdict(int)
z = set()
yp = set()
xp = set()
for i in range(n):
	for j in range(i + 1, n):
		(x1, y1) = a[i]
		(x2, y2) = a[j]
		Y = y2 - y1
		X = x2 - x1
		if X < 0:
			Y *= -1
			X *= -1
		if X == 0:
			xp.add(x1)
		elif Y == 0:
			yp.add(y1)
		else:
			g = math.gcd(X, abs(Y))
			X //= g
			Y //= g
			c = x1 * Y - y1 * X
			if (X, Y, c) in z:
				continue
			d[X, Y] += 1
			z.add((X, Y, c))
m = len(z) + len(yp) + len(xp)
res = 0
for (x, y, c) in list(z):
	res += m - d[x, y]
for YY in list(yp):
	res += m - len(yp)
for XX in list(xp):
	res += m - len(xp)
print(res // 2)


import sys
import math
from pprint import pprint
n = int(input())
p = []
for _ in range(n):
	(x, y) = map(int, input().split())
	p.append((x, y))
s = {}
for i in range(n):
	(x1, y1) = p[i]
	for j in range(i + 1, n):
		(x2, y2) = p[j]
		slope = 0
		cons = 0
		if x1 == x2:
			slope = 10 ** 10
			cons = x1
		else:
			slope = (y1 - y2) / (x1 - x2)
			cons = (y1 * x2 - x1 * y2) / (x2 - x1)
		if slope in s:
			if cons in s[slope]:
				s[slope][cons] += 1
			else:
				s[slope][cons] = 1
		else:
			s[slope] = {cons: 1}
p = []
for m in s:
	p.append(len(s[m]))
s = sum(p)
ans = 0
for x in p:
	ans += x * (s - x)
print(ans // 2)


from math import gcd
from collections import Counter
n = int(input())
m = [tuple(map(int, input().split())) for i in range(n)]
s = Counter()
r = set()
for i in range(n - 1):
	for j in range(i + 1, n):
		a = m[i][1] - m[j][1]
		b = m[i][0] - m[j][0]
		c = m[i][1] * m[j][0] - m[j][1] * m[i][0]
		t = gcd(a, gcd(b, c))
		a //= t
		b //= t
		c //= t
		if a < 0:
			(a, b, c) = (-a, -b, -c)
		elif a == 0 and b < 0:
			(b, c) = (-b, -c)
		if (a, b, c) not in r:
			s[a, b] += 1
			r.add((a, b, c))
ans = len(r) * (len(r) - 1) // 2
for el in s:
	ans -= s[el] * (s[el] - 1) // 2
print(ans)


from fractions import Fraction as F
import math, sys
points = []
lines = []
n = int(input())
for i in range(n):
	(x, y) = map(int, input().split())
	points.append((x, y))
grad_freqs = {}
for i in range(len(points)):
	for j in range(i + 1, len(points)):
		((x, y), (a, b)) = (points[i], points[j])
		y2_y1 = F(b - y)
		x2_x1 = F(a - x)
		if x == a:
			gradient = 1000000000.0
			intercept = x
		else:
			gradient = y2_y1 / x2_x1
			intercept = y - gradient * x
		gradient = F(gradient)
		intercept = F(intercept)
		if gradient not in grad_freqs:
			grad_freqs[gradient] = set()
		grad_freqs[gradient].add(intercept)
total_lines = 0
for key in grad_freqs.keys():
	grad_freqs[key] = len(grad_freqs[key])
	total_lines += grad_freqs[key]
res = 0
values = grad_freqs.values()
for (idx, item) in enumerate(values):
	res += (total_lines - item) * item
print(res // 2)


from fractions import Fraction
from collections import defaultdict
n = int(input())
ps = [tuple(map(int, input().split())) for _ in range(n)]
d = defaultdict(set)
for i in range(n):
	for j in range(i):
		(x1, y1) = ps[i]
		(x2, y2) = ps[j]
		a = Fraction(y2 - y1, x2 - x1) if x2 - x1 else None
		b = min(x1, x2) if a is None else y1 - a * x1
		d[a].add(b)
s = 0
for v in d.values():
	s += len(v)
r = s * (s - 1) // 2
for v in d.values():
	l = len(v)
	r -= l * (l - 1) // 2
print(r)


import math
import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
from fractions import Fraction
n = int(input())
l = []
for i in range(n):
	(a, b) = map(int, input().split())
	l.append((a, b))
d = dict()
dc = set()
tot = 0
for i in range(n):
	for j in range(i + 1, n):
		if l[i][0] - l[j][0] == 0:
			slope = float('inf')
			c = -l[i][0]
		else:
			slope = Fraction(l[i][1] - l[j][1], l[i][0] - l[j][0])
			c = l[i][1] - slope * l[i][0]
		dc.add((slope, c))
		if slope in d:
			d[slope] += 1
		else:
			d.update({slope: 1})
ans = 0
dc = list(dc)
for i in range(len(dc)):
	for j in range(i + 1, len(dc)):
		if dc[j][0] != dc[i][0]:
			ans += 1
print(ans)


from collections import defaultdict
from math import gcd
inf = 10 ** 20
t = 1
for _ in range(t):
	n = int(input())
	arr = []
	for i in range(n):
		(x, y) = map(int, input().split())
		arr += [[x, y]]
	d = defaultdict(set)
	infslope = defaultdict(int)
	for i in range(n):
		for j in range(i + 1, n):
			dy = arr[i][1] - arr[j][1]
			dx = arr[i][0] - arr[j][0]
			g = gcd(abs(dx), abs(dy))
			dx //= g
			dy //= g
			if dx == 0:
				infslope[arr[i][0]] += 1
				continue
			if dy < 0:
				dy *= -1
				dx *= -1
			elif dy == 0:
				dx = 1
			m = (dy, dx)
			one = m[1]
			two = m[1] * arr[i][1] - m[0] * arr[i][0]
			g = gcd(abs(one), abs(two))
			one //= g
			two //= g
			if one < 0:
				one *= -1
				two *= -1
			d[dy, dx].add((one, two))
	curr = 0
	ans = 0
	for x in d:
		ans += len(d[x]) * curr
		curr += len(d[x])
	ans += len(infslope) * curr
	print(ans)


n = int(input())
ls = set()
pts = []
for i in range(n):
	(x, y) = map(int, input().split())
	pts.append([x, y])
for i in range(n):
	for j in range(i + 1, n):
		x1 = pts[i][0]
		y1 = pts[i][1]
		x2 = pts[j][0]
		y2 = pts[j][1]
		m = (y2 - y1) / (x2 - x1) if x2 != x1 else 'I'
		c = (x2 * y1 - x1 * y2) / (x2 - x1) if x1 != x2 else x1
		ls.add((m, c))
ins = set()
ls = list(ls)
nls = len(ls)
for i in range(nls):
	for j in range(i + 1, nls):
		m1 = ls[i][0]
		m2 = ls[j][0]
		if m1 != m2:
			x = [i, j]
			x.sort()
			ins.add(tuple(x))
print(len(ins))


import sys
from array import array
from typing import List, Tuple, TypeVar, Generic, Sequence, Union

def input():
	return sys.stdin.buffer.readline().decode('utf-8')

def main():
	from collections import Counter
	from math import gcd
	n = int(input())
	point = [tuple(map(int, input().split())) for _ in range(n)]
	line = set()
	delta = Counter()
	for (i, (x1, y1)) in enumerate(point):
		for (x2, y2) in point[i + 1:]:
			(a, b, c) = (y2 - y1, x1 - x2, x2 * y1 - x1 * y2)
			g = gcd(gcd(a, b), c)
			(a, b, c) = (a // g, b // g, c // g)
			if a < 0:
				(a, b, c) = (-a, -b, -c)
			elif a == 0 and b < 0:
				(b, c) = (-b, -c)
			if (a, b, c) not in line:
				line.add((a, b, c))
				(dx, dy) = (x1 - x2, y1 - y2)
				g = gcd(dx, dy)
				(dx, dy) = (dx // g, dy // g)
				if dx < 0:
					(dx, dy) = (-dx, -dy)
				elif dx == 0:
					dy = 1
				delta[dx, dy] += 1
	ans = len(line) * (len(line) - 1) // 2 - sum((v * (v - 1) >> 1 for v in delta.values()))
	print(ans)
main()


from fractions import gcd
from collections import Counter
import collections

def main():
	n = int(input())
	A = []
	mp = collections.defaultdict(set)
	for i in range(n):
		A.append([int(a) for a in input().split()])
	for i in range(n - 1):
		x1 = A[i][0]
		y1 = A[i][1]
		for j in range(i + 1, n):
			x2 = A[j][0]
			y2 = A[j][1]
			if x1 == x2:
				(s1, s2) = (1, 0)
				(o1, o2) = (x1, 0)
			elif y1 == y2:
				(s1, s2) = (0, 1)
				(o1, o2) = (0, y1)
			else:
				(s1, s2) = (y2 - y1, x2 - x1)
				o1 = y1 * s2 - s1 * x1
				o2 = s2
				if s2 < 0:
					s1 = -s1
					s2 = -s2
				g = gcd(abs(s1), s2)
				s1 //= g
				s2 //= g
				if o2 < 0:
					o1 = -o1
					o2 = -o2
				g = gcd(abs(o1), o2)
				o1 //= g
				o2 //= g
			mp[s1, s2].add((o1, o2))
	res = 0
	s = 0
	for a in mp:
		s += len(mp[a])
	for a in mp:
		x = len(mp[a])
		res += x * (s - x)
	res //= 2
	print(res)
main()


import sys
input = lambda : sys.stdin.readline().strip()
from math import gcd
n = int(input())
points = []
for i in range(n):
	points.append(tuple(map(int, input().split())))
lines = []
for i in range(n):
	for j in range(i + 1, n):
		x1 = points[i][0]
		y1 = points[i][1]
		x2 = points[j][0]
		y2 = points[j][1]
		a = y1 - y2
		b = x2 - x1
		c = x1 * y2 - x2 * y1
		GCD = gcd(gcd(a, b), c)
		(a, b, c) = (a / GCD, b / GCD, c / GCD)
		if a != 0:
			check = 0
		else:
			check = 1
		if [a, b, c][check] < 0:
			(a, b, c) = (-a, -b, -c)
		lines.append((a, b, c))
lines = list(set(lines))
d = {}
for line in lines:
	try:
		d[line[0], line[1]] += 1
	except:
		d[line[0], line[1]] = 1
d = list(d.values())
ans = len(lines) * (len(lines) - 1) // 2
for i in d:
	ans -= i * (i - 1) // 2
print(ans)


from sys import maxsize
n = int(input())
p = []
for i in range(n):
	w = list(map(int, input().split()))
	p.append(w)
p.sort()
s = {}
for i in range(n):
	(x1, y1) = p[i]
	for j in range(i + 1, n):
		(x2, y2) = p[j]
		k = 0
		b = 0
		if x1 - x2 == 0:
			k = maxsize
			b = x1
		else:
			k = (y2 - y1) / (x2 - x1)
			b = (y1 * x2 - x1 * y2) / (x2 - x1)
		if k in s:
			if b in s[k]:
				s[k][b] += 1
			else:
				s[k][b] = 1
		else:
			s[k] = {b: 1}
ans = 0
cnt = 0
for i in s:
	ans += cnt * len(s[i])
	cnt += len(s[i])
print(ans)


from collections import defaultdict
n = int(input())
a = []
for i in range(n):
	a.append(list(map(int, input().split())))
d = defaultdict(int)
dh = defaultdict(list)
dhs = []
s = 0
for i in range(n):
	for j in range(i + 1, n):
		try:
			t = (a[j][1] - a[i][1]) / (a[j][0] - a[i][0])
			if d[t] == 0:
				d[t] = 1
				dh[t].append(i)
				dh[t].append(j)
			else:
				if i not in dh[t] and j not in dh[t]:
					d[t] += 1
				dh[t].append(i)
				dh[t].append(j)
		except:
			if s == 0:
				s += 1
			elif i not in dhs and j not in dhs:
				s += 1
			dhs.append(i)
			dhs.append(j)
t = list(d.keys())
c = 0
l = 0
for i in t:
	k = d[i]
	l += k
	c += k * (k - 1) // 2
c += s * (s - 1) // 2
l += s
l = l * (l - 1) // 2
print(l - c)


from math import gcd
n = int(input())
P = [[int(x) for x in input().split()] for _ in range(n)]
L = []

def addLine(x, y, dx, dy):
	if dx < 0:
		dx *= -1
		dy *= -1
	elif dx == 0:
		if dy < 0:
			dy *= -1
	g = gcd(dx, dy)
	dx //= g
	dy //= g
	x += dx * 10 ** 9
	y += dy * 10 ** 9
	if dx:
		k = x // dx
	else:
		k = y // dy
	x -= k * dx
	y -= k * dy
	L.append((x, y, dx, dy))
for i in range(n):
	for j in range(i + 1, n):
		(xi, yi) = P[i]
		(xj, yj) = P[j]
		(dx, dy) = (xi - xj, yi - yj)
		addLine(xi, yi, dx, dy)
L = list(set(L))
res = 0
for i in range(len(L)):
	for j in range(i + 1, len(L)):
		(x1, y1, dx1, dy1) = L[i]
		(x2, y2, dx2, dy2) = L[j]
		if dx1 != dx2 or dy1 != dy2:
			res += 1
print(res)


n = int(input())
p = []
for i in range(n):
	(x, y) = map(int, input().split())
	p.append((x, y))
d = {}
for i in range(n):
	(x1, y1) = p[i]
	for j in range(i + 1, n):
		(x2, y2) = p[j]
		if x1 != x2:
			m = (y2 - y1) / (x2 - x1)
			c = (y1 * x2 - x1 * y2) / (x2 - x1)
		else:
			m = 10 ** 10
			c = x1
		if m in d:
			if c in d[m]:
				d[m][c] += 1
			else:
				d[m][c] = 1
		else:
			d[m] = {c: 1}
p = []
for m in d:
	p.append(len(d[m]))
s = sum(p)
ans = 0
for i in range(len(p)):
	ans += p[i] * (s - p[i])
print(ans // 2)


from __future__ import division, print_function
import bisect
import math
import itertools
import sys
from atexit import register
from fractions import Fraction
if sys.version_info[0] < 3:
	from io import BytesIO as stream
else:
	from io import StringIO as stream
if sys.version_info[0] < 3:

	class dict(dict):

		def items(self):
			return dict.iteritems(self)

		def keys(self):
			return dict.iterkeys(self)

		def values(self):
			return dict.itervalues(self)
	input = raw_input
	range = xrange
	filter = itertools.ifilter
	map = itertools.imap
	zip = itertools.izip

def sync_with_stdio(sync=True):
	global input, flush
	if sync:
		flush = sys.stdout.flush
	else:
		sys.stdin = stream(sys.stdin.read())
		input = lambda : sys.stdin.readline().rstrip('\r\n')
		sys.stdout = stream()
		register(lambda : sys.__stdout__.write(sys.stdout.getvalue()))

def main():
	n = int(input())
	l1 = []
	d2 = {}
	for i in range(0, n):
		(x, y) = map(int, input().split())
		for item in l1:
			if x == item[0]:
				if 'inf' not in d2:
					temp = {}
					temp[x] = 1
					d2['inf'] = temp
				elif x not in d2['inf']:
					temp = d2['inf']
					temp[x] = 1
			else:
				flag = 0
				(a, b) = (y - item[1], x - item[0])
				if a * b < 0:
					flag = 1
				f = math.gcd(abs(a), abs(b))
				a = a // f
				b = b // f
				if flag == 1:
					a = -1 * abs(a)
					b = abs(b)
				else:
					a = abs(a)
					b = abs(b)
				d = b * y - a * x
				flag = 0
				if d * b < 0:
					flag = 1
				if flag == 1:
					d = -1 * abs(d)
					b = abs(b)
				else:
					d = abs(d)
					b = abs(b)
				e = math.gcd(abs(d), abs(b))
				c = (d // e, b // e)
				if (a, b) not in d2:
					temp = {}
					temp[c] = 1
					d2[a, b] = temp
				elif c not in d2[a, b]:
					temp = d2[a, b]
					temp[c] = 1
		l1.append((x, y))
	z = 0
	ans = 0
	f = 0
	for k in d2:
		z += len(d2[k])
	for k in d2:
		x = len(d2[k])
		f = f + x
		ans += x * (z - f)
	print(ans)
sync_with_stdio(False)
main()


n = int(input())
T = []
for i in range(n):
	(x, y) = map(int, input().split())
	T.append([x, y])
P = []
for i in range(n):
	for j in range(i + 1, n):
		(x1, y1) = T[i]
		(x2, y2) = T[j]
		a = y2 - y1
		b = x1 - x2
		c = -(a * x1 + b * y1)
		P.append([a, b, c])
const = 10 ** 10 + 3
cnt = 0
newP = []
visit = []
for (a, b, c) in P:
	if a != 0:
		if [1, b / a, c / a] not in visit:
			newP.append([1, b / a, c / a])
			visit.append([1, b / a, c / a])
	elif [0, 1, c / b] not in visit:
		newP.append([0, 1, c / b])
		visit.append([0, 1, c / b])
P = newP
for i in range(len(P)):
	for j in range(i + 1, len(P)):
		(a1, b1, c1) = P[i]
		(a2, b2, c2) = P[j]
		if a1 * b2 == a2 * b1:
			pass
		else:
			x = (b1 * c2 - b2 * c1) / (a1 * b2 - b1 * a2)
			y = (c1 * a2 - a1 * c2) / (a1 * b2 - b1 * a2)
			cnt += 1
print(cnt)


import math
from collections import defaultdict
import sys
input = sys.stdin.readline
import math
n = int(input())
points = []
lines1 = defaultdict(set)
for i in range(n):
	(x, y) = map(int, input().split())
	points.append([x, y])
points.sort()
count = 0
for i in range(n):
	for j in range(i + 1, n):
		if points[i][0] == points[j][0]:
			lines1[math.inf].add(points[j][0])
		else:
			slope = (points[i][1] - points[j][1]) / (points[i][0] - points[j][0])
			lines1[slope].add((points[i][0] * points[j][1] - points[j][0] * points[i][1]) / (points[i][0] - points[j][0]))
s = 0
for v in lines1:
	s += len(lines1[v])
lines2 = s * (s - 1) // 2
for (i, value) in lines1.items():
	s = len(value)
	lines2 -= s * (s - 1) // 2
print(lines2)


from __future__ import division, print_function
from fractions import Fraction
import sys
import os
from io import BytesIO, IOBase
from math import gcd, factorial, floor, ceil
from copy import deepcopy
from collections import deque
from bisect import bisect_left as bl
from bisect import bisect_right as br
from bisect import bisect
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
from types import GeneratorType

def iterative(f, stack=[]):

	def wrapped_func(*args, **kwargs):
		if stack:
			return f(*args, **kwargs)
		to = f(*args, **kwargs)
		while True:
			if type(to) is GeneratorType:
				stack.append(to)
				to = next(to)
				continue
			stack.pop()
			if not stack:
				break
			to = stack[-1].send(to)
		return to
	return wrapped_func
mod = 10 ** 9 + 7

def inp():
	return sys.stdin.readline().rstrip('\r\n')

def out(var):
	sys.stdout.write(str(var))

def lis():
	return list(map(int, inp().split()))

def stringlis():
	return list(map(str, inp().split()))

def sep():
	return map(int, inp().split())

def strsep():
	return map(str, inp().split())

def zerolist(n):
	return [0] * n

def nextline():
	out('\n')

def testcase(t):
	for pp in range(t):
		solve(pp)

def printlist(a):
	for p in range(0, len(a)):
		out(str(a[p]) + ' ')

def google(p):
	print('Case #' + str(p) + ': ', end='')

def lcm(a, b):
	return a * b // gcd(a, b)

def power(x, y, p):
	res = 1
	x = x % p
	if x == 0:
		return 0
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def ncr(n, r):
	return factorial(n) // (factorial(r) * factorial(max(n - r, 1)))

def isPrime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	i = 5
	while i * i <= n:
		if n % i == 0 or n % (i + 2) == 0:
			return False
		i = i + 6
	return True

def slope(a, b):
	if a[0] - b[0] == 0:
		return 'inf'
	return (a[1] - b[1]) / (a[0] - b[0])

def line(aa, bb):
	(x1, y1, x2, y2) = (aa[0], aa[1], bb[0], bb[1])
	(a, b, c) = (y1 - y2, x2 - x1, x1 * y2 - x2 * y1)
	g = gcd(a, b)
	(a, b) = (a // g, b // g)
	if a < 0 or (a == 0 and b < 0):
		a *= -1
		b *= -1
		c *= -1
	c = round(c / g, 3)
	return str(a) + 'x ' + str(b) + 'y =' + str(c)

def solve(case):
	n = int(inp())
	ll = 0
	coor = []
	for i in range(n):
		(a, b) = sep()
		coor.append((a, b))
	have = set()
	help = []
	for i in range(n):
		for j in range(i + 1, n):
			curr = line(coor[i], coor[j])
			if curr not in have:
				ll += 1
				have.add(curr)
				help.append(curr)
	slopecnt = {}
	for j in help:
		j = list(j)
		ind = j.index('=')
		tochck = j[:ind]
		tochck = ''.join(tochck)
		if tochck not in slopecnt:
			slopecnt[tochck] = 1
		else:
			slopecnt[tochck] += 1
	ans = ll * (ll - 1) // 2
	for i in slopecnt:
		if slopecnt[i] > 1:
			ans -= slopecnt[i] * (slopecnt[i] - 1) // 2
	print(ans)
testcase(1)


from fractions import Fraction
from math import inf
n = int(input())
coords = []
for i in range(n):
	(x, y) = [int(c) for c in input().split(' ')]
	coords.append((x, y))
tangents = {}
for i1 in range(n):
	for i2 in range(i1 + 1, n):
		(x1, y1) = coords[i1]
		(x2, y2) = coords[i2]
		if x2 == x1:
			tangent = inf
			offset = x1
		else:
			tangent = Fraction(y2 - y1, x2 - x1)
			offset = -tangent * x1 + y1
		if tangent not in tangents:
			tangents[tangent] = set()
		tangents[tangent].add(offset)
tangentlen = {}
for tangent in tangents:
	tangentlen[tangent] = len(tangents[tangent])
summ = 0
for tangent in tangents:
	summ += tangentlen[tangent]
answer = 0
for t1 in tangents:
	answer += tangentlen[t1] * (summ - tangentlen[t1])
print(answer // 2)


n = int(input())
x = []
y = []
lineas = set()
lineas1 = set()
lineas2 = set()
caca = dict()

def gcd(a, b):
	if b == 0:
		return a
	return gcd(b, a % b)
for i in range(n):
	(a, b) = map(int, input().split())
	x.append(a)
	y.append(b)
	for j in range(i):
		a1 = a - x[j]
		b1 = b - y[j]
		p1 = max(abs(a1), abs(b1))
		p2 = min(abs(a1), abs(b1))
		g = gcd(p1, p2)
		a1 = int(a1 / g)
		b1 = int(b1 / g)
		if a1 < 0:
			a1 *= -1
			b1 *= -1
		aux = b * a1 - a * b1
		if a1 == 0:
			lineas1.add(a)
		elif b1 == 0:
			lineas2.add(b)
		else:
			if (a1, b1) in caca:
				caca[a1, b1].add(aux)
			else:
				caca[a1, b1] = set()
				caca[a1, b1].add(aux)
			lineas.add((a1, b1, aux))
sol = 0
aux = len(lineas)
sol += int(aux * (aux - 1) / 2)
sol += aux * (len(lineas1) + len(lineas2))
sol += len(lineas1) * len(lineas2)
for a in caca.keys():
	aux = len(caca[a])
	sol -= int(aux * (aux - 1) / 2)
print(sol)


def gcd(x, y):
	while y:
		(x, y) = (y, x % y)
	return x

def frac(a, b):
	x = gcd(a, b)
	return (a // x, b // x)
n = int(input())
coords = []
for i in range(n):
	coords.append(tuple(map(int, input().split())))
slopes = {}
for i in range(n):
	for j in range(i + 1, n):
		(x1, y1) = (coords[i][0], coords[i][1])
		(x2, y2) = (coords[j][0], coords[j][1])
		if x1 == x2:
			slope = 'inf'
			mark = x1
		else:
			slope = frac(y2 - y1, x2 - x1)
			mark = frac(y1 * x2 - y2 * x1, x2 - x1)
		if slope in slopes:
			slopes[slope].add(mark)
		else:
			slopes[slope] = {mark}
tot = sum((len(slopes[guy]) for guy in slopes))
sumi = 0
for guy in slopes:
	a = len(slopes[guy])
	sumi += a * (tot - a)
print(sumi // 2)


from fractions import Fraction
from math import inf
n = int(input())
p = []
q = set()
for i in range(n):
	(x, y) = [int(i) for i in input().split()]
	for (j, k) in p:
		try:
			m = Fraction(k - y, j - x)
			c = Fraction(y - m * x)
		except ZeroDivisionError:
			(m, c) = (inf, x)
		q.add((m, c))
	p += [(x, y)]
q = list(q)
i = 0
k = len(q)
res = 0
while i < k:
	j = i + 1
	while j < k:
		if q[i][0] != q[j][0]:
			res += 1
		j += 1
	i += 1
print(res)


def gcd(a, b):
	while b:
		(a, b) = (b, a % b)
	return a
n = int(input())
p = [0] * n
for i in range(n):
	p[i] = [int(item) for item in input().split()]
wires = set()
for i in range(n):
	for j in range(i + 1, n):
		(x0, y0) = p[i]
		(x1, y1) = p[j]
		a = -(y1 - y0)
		b = x1 - x0
		c = x0 * (y1 - y0) - y0 * (x1 - x0)
		k = gcd(a, gcd(b, c))
		a //= k
		b //= k
		c //= k
		if a < 0:
			a *= -1
			b *= -1
			c *= -1
		wires.add((a, b, c))
wires = list(wires)
para_x = []
para_y = []
others = {}
for i in range(len(wires)):
	(a, b, c) = wires[i]
	if b == 0:
		para_y.append(i)
	elif a == 0:
		para_x.append(i)
	else:
		k = gcd(a, b)
		if (a // k, b // k) in others:
			others[a // k, b // k] += 1
		else:
			others[a // k, b // k] = 1
px = len(para_x)
py = len(para_y)
o = sum((others[x] for x in others))
ans = px * py + px * o + py * o
others_list = [others[x] for x in others]
pre = [0] * (len(others_list) + 1)
for i in range(len(others_list)):
	pre[i] = pre[i - 1] + others_list[i]
for i in range(len(others_list) - 1, 0, -1):
	ans += others_list[i] * pre[i - 1]
print(ans)