Watchmen are in a danger and Doctor Manhattan together with his friend Daniel Dreiberg should warn them as soon as possible. There are n watchmen on a plane, the i-th watchman is located at point (x_{i}, y_{i}).

They need to arrange a plan, but there are some difficulties on their way. As you know, Doctor Manhattan considers the distance between watchmen i and j to be |x_{i} - x_{j}| + |y_{i} - y_{j}|. Daniel, as an ordinary person, calculates the distance using the formula $\sqrt{(x_{i} - x_{j})^{2} +(y_{i} - y_{j})^{2}}$.

The success of the operation relies on the number of pairs (i, j) (1 ≤ i < j ≤ n), such that the distance between watchman i and watchmen j calculated by Doctor Manhattan is equal to the distance between them calculated by Daniel. You were asked to compute the number of such pairs.


-----Input-----

The first line of the input contains the single integer n (1 ≤ n ≤ 200 000) — the number of watchmen.

Each of the following n lines contains two integers x_{i} and y_{i} (|x_{i}|, |y_{i}| ≤ 10^9).

Some positions may coincide.


-----Output-----

Print the number of pairs of watchmen such that the distance between them calculated by Doctor Manhattan is equal to the distance calculated by Daniel.


-----Examples-----
Input
3
1 1
7 5
1 5

Output
2

Input
6
0 0
0 1
0 2
-1 1
0 1
1 1

Output
11



-----Note-----

In the first sample, the distance between watchman 1 and watchman 2 is equal to |1 - 7| + |1 - 5| = 10 for Doctor Manhattan and $\sqrt{(1 - 7)^{2} +(1 - 5)^{2}} = 2 \cdot \sqrt{13}$ for Daniel. For pairs (1, 1), (1, 5) and (7, 5), (1, 5) Doctor Manhattan and Daniel will calculate the same distances.

Source: codeforces | Difficulty: MEDIUM
Tags: Geometry

Data structures

Mathematics


Solutions:
from collections import Counter
(counterX, counterY, counterXY) = (Counter(), Counter(), Counter())
ans = 0
for i in range(int(input())):
	(x, y) = map(int, input().split())
	ans += counterX[x] + counterY[y] - counterXY[x, y]
	counterX[x] += 1
	counterY[y] += 1
	counterXY[x, y] += 1
print(ans)


n = int(input())
ans = 0
visited = {}
f = {}
s = {}
for i in range(n):
	n = [int(x) for x in input().split()]
	if n[0] in f:
		ans += f[n[0]]
		f[n[0]] += 1
	else:
		f[n[0]] = 1
	if n[1] in s:
		ans += s[n[1]]
		s[n[1]] += 1
	else:
		s[n[1]] = 1
	if tuple(n) in visited:
		ans -= visited[tuple(n)]
		visited[tuple(n)] += 1
	else:
		visited[tuple(n)] = 1
print(ans)


from collections import *
(n, ans) = (int(input()), 0)
data_x = Counter()
data_y = Counter()
data_xy = Counter()
for i in range(n):
	(xi, yi) = map(int, input().split())
	data_x[xi] += 1
	data_y[yi] += 1
	data_xy[xi, yi] += 1
for i in data_x:
	ans += data_x[i] * (data_x[i] - 1) // 2
for i in data_y:
	ans += data_y[i] * (data_y[i] - 1) // 2
for i in data_xy:
	ans -= data_xy[i] * (data_xy[i] - 1) // 2
print(ans)


x = {}
y = {}
node = {}
res = 0
n = int(input())
for i in range(n):
	(tx, ty) = input().split()
	(tx, ty) = (int(tx), int(ty))
	if tx in x:
		x[tx] += 1
	else:
		x[tx] = 1
	if ty in y:
		y[ty] += 1
	else:
		y[ty] = 1
	if (tx, ty) in node:
		node[tx, ty] += 1
	else:
		node[tx, ty] = 1
for key in x:
	if x[key] > 1:
		res += x[key] * (x[key] - 1) / 2
for key in y:
	if y[key] > 1:
		res += y[key] * (y[key] - 1) / 2
for key in node:
	if node[key] > 1:
		res -= node[key] * (node[key] - 1) / 2
print(int(res))


t = int(input())
r = []
py = []
for i in range(t):
	(x, y) = map(int, input().strip().split(' '))
	r.append([x, y])
	py.append(y)
r.sort()
py.sort()
c = 0
c1 = 1
c2 = 1
c3 = 1
for i in range(t - 1):
	if py[i] == py[i + 1]:
		c3 += 1
		if i == t - 2:
			c += c3 * (c3 - 1) // 2
	else:
		c += c3 * (c3 - 1) // 2
		c3 = 1
	if r[i][0] == r[i + 1][0] and r[i][1] == r[i + 1][1]:
		c2 += 1
		if i == t - 2:
			c -= c2 * (c2 - 1) // 2
	else:
		c -= c2 * (c2 - 1) // 2
		c2 = 1
	if r[i][0] == r[i + 1][0]:
		c1 += 1
		if i == t - 2:
			c += c1 * (c1 - 1) // 2
	else:
		c += c1 * (c1 - 1) // 2
		c1 = 1
print(c)


from math import factorial
n = int(input())
xs = {}
ys = {}
sm = 0
pts = {}

def c(n, k):
	if n < 2:
		return 0
	return factorial(n) // (factorial(k) * factorial(n - k))
for i in range(n):
	(x, y) = map(int, input().split())
	sm += xs.get(x, 0)
	sm += ys.get(y, 0)
	xs[x] = xs.get(x, 0) + 1
	ys[y] = ys.get(y, 0) + 1
	sm -= pts.get(str(x) + ' ' + str(y), 0)
	pts[str(x) + ' ' + str(y)] = pts.get(str(x) + ' ' + str(y), 0) + 1
print(sm)


q = int(input())
from collections import defaultdict
(a, b, c) = (defaultdict(int), defaultdict(int), defaultdict(int))
for _ in range(q):
	(x, y) = list(map(int, input().split()))
	a[x, y] += 1
	b[x] += 1
	c[y] += 1
l = 0
for i in b:
	k = b[i] - 1
	k = k * (k + 1) // 2
	l += k
for i in c:
	k = c[i] - 1
	k = k * (k + 1) // 2
	l += k
for i in a:
	k = a[i] - 1
	l -= k * (k + 1) // 2
print(l)


from sys import stdout
from sys import stdin
from collections import defaultdict as dd

class IO:

	def read():
		return stdin.readline().strip()

	def readf():
		return [int(i) for i in IO.read().split()]

	def put(a, end='\n'):
		stdout.write(str(a) + end)

	def putf(a, sep=' ', end='\n'):
		stdout.write(sep.join(map(str, a)) + end)

def main():
	n = int(IO.read())
	x = dd(int)
	y = dd(int)
	cnt = dd(int)
	h = 0
	ans = 0
	for i in range(n):
		(a, b) = IO.readf()
		x[a] += 1
		y[b] += 1
		cnt[a, b] += 1
	for i in cnt:
		h += cnt[i] * (cnt[i] - 1) // 2
	ans = 0
	for i in x:
		ans += x[i] * (x[i] - 1) // 2
	for i in y:
		ans += y[i] * (y[i] - 1) // 2
	IO.put(ans - h)
main()


import re
c = 0
ds = [{}, {}]
coords = {}
dup = 0
n = int(input())
for i in range(0, n):
	t = re.split(' ', input())
	T = tuple(t)
	coords[T] = 1 + (0 if T not in coords else coords[T])
	dup += coords[T] - 1
	for j in range(0, len(ds)):
		ds[j][t[j]] = 1 + (0 if t[j] not in ds[j] else ds[j][t[j]])
for i in range(0, len(ds)):
	for (k, v) in ds[i].items():
		c += v * (v - 1) / 2
print(int(c - dup))


def Cn2(n):
	return n * (n - 1) // 2
n = int(input())
xs = {}
ys = {}
points = {}
for i in range(n):
	(x, y) = map(int, input().split())
	if (x, y) in points:
		points[x, y] += 1
	else:
		points[x, y] = 1
	if x in xs:
		xs[x] += 1
	else:
		xs[x] = 1
	if y in ys:
		ys[y] += 1
	else:
		ys[y] = 1
ans = 0
for x in xs:
	ans += Cn2(xs[x])
for y in ys:
	ans += Cn2(ys[y])
for point in points:
	ans -= Cn2(points[point])
print(ans)


from collections import defaultdict
N = int(input())
points = []
for _ in range(N):
	(x, y) = input().split()
	(x, y) = (int(x), int(y))
	points += [(x, y)]

def ans1(points):
	ans = 0
	for i in range(len(points)):
		for j in range(i + 1, len(points)):
			(X, Y) = points[i]
			(x, y) = points[j]
			if x == X or y == Y:
				ans += 1
	return ans

def ans2(points):
	ys_of = defaultdict(list)
	xs_of = defaultdict(list)
	same_points = defaultdict(int)
	ans = 0
	for (x, y) in points:
		xs_of[y] += [x]
		ys_of[x] += [y]
		same_points[x, y] += 1
	for v in xs_of.values():
		n = len(v)
		if n < 2:
			continue
		ans += n * (n - 1) // 2
	for v in ys_of.values():
		n = len(v)
		if n < 2:
			continue
		ans += n * (n - 1) // 2
	for n in same_points.values():
		if n < 2:
			continue
		ans -= n * (n - 1) // 2
	return ans
print(ans2(points))


n = int(input())
(gx, gy, c) = ({}, {}, 0)
tup = {}
for i in range(n):
	(x, y) = map(int, input().split(' '))
	if x in gx and y not in gy:
		c += gx[x]
		gx[x] += 1
		gy[y] = 1
		tup[x, y] = 1
	elif x not in gx and y in gy:
		c += gy[y]
		gy[y] += 1
		gx[x] = 1
		tup[x, y] = 1
	elif x not in gx and y not in gy:
		(gx[x], gy[y], tup[x, y]) = (1, 1, 1)
	elif x in gx and y in gy:
		if (x, y) in tup:
			c += gx[x] + gy[y] - tup[x, y]
			tup[x, y] += 1
		else:
			c += gx[x] + gy[y]
			tup[x, y] = 1
		gx[x] += 1
		gy[y] += 1
print(c)


n = int(input())
dic = {}
X = {}
Y = {}
for _ in range(n):
	tup = tuple(map(int, input().split()))
	if tup in dic:
		dic[tup] += 1
	else:
		dic[tup] = 1
	if tup[0] in X:
		X[tup[0]] += 1
	else:
		X[tup[0]] = 1
	if tup[1] in Y:
		Y[tup[1]] += 1
	else:
		Y[tup[1]] = 1
final = 0
for i in X:
	final += X[i] * (X[i] - 1) // 2
for i in Y:
	final += Y[i] * (Y[i] - 1) // 2
for i in dic:
	if dic[i] > 1:
		final += -(dic[i] * (dic[i] - 1) // 2)
print(final)


y = int(input())
d = {}
dy = {}
dxy = {}
for i in range(y):
	al = input().split()
	m = list(map(int, al))
	d.setdefault(m[0], [])
	d[m[0]].append(m[1])
	dy.setdefault(m[1], [])
	dy[m[1]].append(m[0])
	m = tuple(m)
	dxy.setdefault(m, 0)
	dxy[m] += 1
ans = 0
for i in d.values():
	n = len(i)
	ans += (n - 1) * n // 2
for i in dy.values():
	n = len(i)
	ans += (n - 1) * n // 2
for i in dxy.values():
	n = i
	ans -= (n - 1) * n // 2
print(ans)


import math

def get_int_vector():
	return [int(x) for x in input().split()]

def list2string(list):
	result = []
	for i in list:
		result.append(str(i))
	return ':'.join(result)

def string2vector(string):
	return [int(x) for x in string.split(':')]
n = int(input())
content = dict()
uniq = [dict(), dict()]
result = 0
for _ in range(n):
	(x, y) = get_int_vector()
	if list2string([x, y]) in content.keys():
		content[list2string([x, y])] += 1
	else:
		content[list2string([x, y])] = 1
	if x not in uniq[0].keys():
		uniq[0][x] = 1
	else:
		uniq[0][x] += 1
	if y not in uniq[1].keys():
		uniq[1][y] = 1
	else:
		uniq[1][y] += 1
calc = [dict(), dict()]
used = [set(), set()]
for pair_str in content.keys():
	pair = string2vector(pair_str)
	for i in range(2):
		if pair[i] not in used[i]:
			k = uniq[i][pair[i]]
			result += k * (k - 1) // 2
			used[i].add(pair[i])
	result -= content[pair_str] * (content[pair_str] - 1) // 2
print(result)


n = int(input())
w = [tuple(input().split()) for _ in range(n)]
x = dict()
y = dict()
z = dict()

def add(e, d):
	if not e in d:
		d[e] = 1
	else:
		d[e] += 1

def pr(d):
	return sum((u * (u - 1) / 2 for u in list(d.values())))
for a in w:
	add(a[0], x)
	add(a[1], y)
	add(a, z)
cnt = pr(x) + pr(y) - pr(z)
print(int(cnt))


import os
import sys
from io import BytesIO, IOBase
from collections import defaultdict

def main():
	dicx = defaultdict(lambda : 0)
	dicy = defaultdict(lambda : 0)
	dicp = defaultdict(lambda : 0)
	for _ in range(int(input())):
		(a, b) = map(int, input().split(' '))
		dicx[a] += 1
		dicy[b] += 1
		dicp[a, b] += 1
	ans = 0
	for x in dicx.values():
		ans += x * (x - 1) // 2
	for x in dicy.values():
		ans += x * (x - 1) // 2
	for x in dicp.values():
		ans -= x * (x - 1) // 2
	print(ans)
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')
main()


n = int(input())
xi = {}
yi = {}
rep = {}
for i in range(n):
	(x, y) = input().split()
	try:
		xi[x] += 1
	except KeyError:
		xi[x] = 1
	try:
		yi[y] += 1
	except KeyError:
		yi[y] = 1
	try:
		rep[f'{x},{y}'] += 1
	except KeyError:
		rep[f'{x},{y}'] = 1

def nc2(n):
	return n * (n - 1) / 2
repval = 0
ans = 0
for i in xi.keys():
	ans += nc2(xi[i])
for i in yi.keys():
	ans += nc2(yi[i])
for i in rep.keys():
	repval += nc2(rep[i])
ans = ans - repval
print(int(ans))


from sys import stdin, stdout

def fin():
	return stdin.readline().strip()

def fout(x):
	stdout.write(str(x) + '\n')
n = int(fin())
arr = []
for _ in range(n):
	arr.append(tuple(map(int, fin().split())))
arrMap = {}
xMap = {}
yMap = {}
res = 0
for pair in arr:
	(xMap[pair[0]], yMap[pair[1]], arrMap[pair]) = (xMap.get(pair[0], 0) + 1, yMap.get(pair[1], 0) + 1, arrMap.get(pair, 0) + 1)
for x in xMap:
	res += xMap[x] * (xMap[x] - 1) // 2
for y in yMap:
	res += yMap[y] * (yMap[y] - 1) // 2
for d in arrMap:
	res -= arrMap[d] * (arrMap[d] - 1) // 2
fout(res)


n = int(input())
(sx, sy, sxy, ans) = ({}, {}, {}, 0)
for i in range(n):
	(a, b) = map(int, input().split())
	ans += sx.get(a, 0) + sy.get(b, 0) - sxy.get((a, b), 0)
	sx[a] = sx.get(a, 0) + 1
	sy[b] = sy.get(b, 0) + 1
	sxy[a, b] = sxy.get((a, b), 0) + 1
print(ans)


n = int(input())
a = dict()
b = dict()
c = dict()
counter = 0
for i in range(n):
	(q1, q2) = list(map(int, input().split()))
	t = (q1, q2)
	c[t] = c.get(t, 0) + 1
	a[q1] = a.get(q1, 0) + 1
	b[q2] = b.get(q2, 0) + 1
k = 0
for i in a:
	if a[i] > 1:
		k += a[i] * (a[i] - 1) / 2
for i in b:
	if b[i] > 1:
		k += b[i] * (b[i] - 1) / 2
for i in c:
	if c[i] > 1:
		counter += c[i] * (c[i] - 1) / 2
k -= counter
print(int(k))


n = int(input())
a = 0
b = 0
s1 = {}
s2 = {}
s3 = {}
for i in range(n):
	str = input()
	l1 = str.split(' ')
	a = int(l1[0])
	b = int(l1[1])
	s1[a] = s1.get(a, 0) + 1
	s2[b] = s2.get(b, 0) + 1
	tmp = (a, b)
	s3[tmp] = s3.get(tmp, 0) + 1
sum = 0
for i in s1.values():
	sum += (i - 1) * i // 2
for i in s2.values():
	sum += (i - 1) * i // 2
for i in s3.values():
	sum -= (i - 1) * i // 2
print(sum)


def byF(t):
	return t[0] * 40000000000 + t[1]

def byS(t):
	return t[1] * 40000000000 + t[1]
n = int(input())
res = 0
points = []
for i in range(n):
	points.append(tuple(map(int, input().split())))
points.sort(key=byF)
cons = 1
for i in range(1, n):
	if points[i][0] == points[i - 1][0]:
		cons += 1
	else:
		res += (cons - 1) * cons // 2
		cons = 1
res += (cons - 1) * cons // 2
cons = 1
points.sort(key=byS)
for i in range(1, n):
	if points[i][1] == points[i - 1][1]:
		cons += 1
	else:
		res += (cons - 1) * cons // 2
		cons = 1
res += (cons - 1) * cons // 2
cons = 1
for i in range(1, n):
	if points[i][1] == points[i - 1][1] and points[i][0] == points[i - 1][0]:
		cons += 1
	else:
		res -= (cons - 1) * cons // 2
		cons = 1
res -= (cons - 1) * cons // 2
print(res)


import collections
xx = collections.Counter()
yy = collections.Counter()
zz = collections.Counter()
ans = 0
for _ in range(int(input())):
	(x, y) = map(int, input().split())
	ans += xx[x] + yy[y] - zz[x, y]
	xx[x] += 1
	yy[y] += 1
	zz[x, y] += 1
print(ans)


n = int(input())
x = dict()
y = dict()
z = dict()
t = 0
for i in range(n):
	(a, b) = map(int, input().split())
	p = x.get(a, 0)
	q = y.get(b, 0)
	r = z.get((a, b), 0)
	t += p + q - r
	x[a] = p + 1
	y[b] = q + 1
	z[a, b] = r + 1
print(t)


def add(dic, v):
	if v not in dic:
		dic[v] = 1
	else:
		dic[v] += 1
n = int(input())
a = []
for i in range(n):
	s = tuple(map(int, input().split(' ')))
	a.append(s)
ans = 0
dver = dict()
dhor = dict()
deq = dict()
for i in range(n):
	add(dver, a[i][0])
	add(dhor, a[i][1])
	add(deq, a[i])
for x in dver.keys():
	ans += dver[x] * (dver[x] - 1) // 2
for x in dhor.keys():
	ans += dhor[x] * (dhor[x] - 1) // 2
for x in deq.keys():
	ans -= deq[x] * (deq[x] - 1) // 2
print(ans)


n = int(input())
res = 0
(x, y) = (dict(), dict())
xy = dict()
for i in range(0, n):
	ab = list(map(int, input().split()))
	a = ab[0]
	b = ab[1]
	if a not in x:
		x[a] = 0
	else:
		x[a] += 1
		res += x[a]
	if b not in y:
		y[b] = 0
	else:
		y[b] += 1
		res += y[b]
	if (a, b) not in xy:
		xy[a, b] = 0
	else:
		xy[a, b] += 1
		res -= xy[a, b]
print(res)


from collections import defaultdict
adic = defaultdict(int)
bdic = defaultdict(int)
cdic = defaultdict(int)
ans = 0
for _ in range(int(input())):
	(x, y) = map(int, input().split())
	ans += adic[x] + bdic[y] - cdic[x, y]
	adic[x] += 1
	bdic[y] += 1
	cdic[x, y] += 1
print(ans)


n = int(input())
m = [tuple(map(int, input().split())) for _ in range(n)]
cx = {}
cy = {}
cxy = {}
for i in m:
	if i[0] in cx:
		cx[i[0]] += 1
	else:
		cx[i[0]] = 1
	if i[1] in cy:
		cy[i[1]] += 1
	else:
		cy[i[1]] = 1
	if i in cxy:
		cxy[i] += 1
	else:
		cxy[i] = 1
count = 0
for i in m:
	if cx[i[0]] > 1:
		cx[i[0]] -= 1
		count += cx[i[0]]
	if cy[i[1]] > 1:
		cy[i[1]] -= 1
		count += cy[i[1]]
	if cxy[i] > 1:
		cxy[i] -= 1
		count -= cxy[i]
print(count)


from math import *
from operator import *
from collections import *

def arr_inp(n):
	return [[int(x) for x in input().split()] for i in range(n)]

def nCr(n1, r):
	(f, m) = (factorial, 1)
	for i in range(n1, n1 - r, -1):
		m *= i
	return int(m // f(r))
n = int(input())
a = arr_inp(n)
(dic, dic2, extra) = [defaultdict(lambda : 1) for i in range(3)]
a.sort(key=itemgetter(0, 1))
for i in range(1, n):
	if a[i][0] == a[i - 1][0]:
		dic[a[i][0]] += 1
a.sort(key=itemgetter(1, 0))
for i in range(1, n):
	if a[i][1] == a[i - 1][1]:
		dic2[a[i][1]] += 1
		if a[i][0] == a[i - 1][0]:
			s = tuple(a[i])
			extra[s] += 1
ans = sum(list(map(lambda x: nCr(x, 2), dic.values()))) + sum(list(map(lambda x: nCr(x, 2), dic2.values()))) - sum(list(map(lambda x: nCr(x, 2), extra.values())))
print(ans)


n = int(input())
dict_x = {}
dict_y = {}
dict_xy = {}
for _ in range(n):
	(x, y) = map(int, input().split())
	dict_xy[x, y] = dict_xy.get((x, y), 0) + 1
	dict_x[x] = dict_x.get(x, 0) + 1
	dict_y[y] = dict_y.get(y, 0) + 1
ans = 0
for i in (*dict_x.values(), *dict_y.values()):
	ans += i * (i - 1) // 2
for i in dict_xy.values():
	ans -= i * (i - 1) // 2
print(ans)


from collections import *
C = Counter
a = 0
cx = C()
cy = C()
cp = C()
n = int(input())
for i in range(n):
	(x, y) = map(int, input().split())
	a += cx[x] + cy[y] - cp[x, y]
	cx[x] += 1
	cy[y] += 1
	cp[x, y] += 1
print(a)


from collections import defaultdict
n = int(input())
(total_dic, x_dic, y_dic) = (defaultdict(int), defaultdict(int), defaultdict(int))
ans = 0
for _ in range(n):
	(x, y) = map(int, input().split())
	ans += x_dic[x] + y_dic[y] - total_dic[x, y]
	x_dic[x] += 1
	y_dic[y] += 1
	total_dic[x, y] += 1
print(ans)


def count(q):
	q.sort()
	r = 0
	i = 0
	for j in range(1, len(q)):
		if q[j] == q[i]:
			continue
		r = r + (j - i) * (j - i - 1) // 2
		i = j
	r = r + (n - i) * (n - i - 1) // 2
	return r
n = int(input())
(x, y, xy) = ([], [], [])
for i in range(n):
	(c1, c2) = map(int, input().split())
	x.append(c1)
	y.append(c2)
	xy.append([c1, c2])
print(count(x) + count(y) - count(xy))


n = int(input())
pts = [] * n
for _ in range(n):
	(x, y) = map(int, input().split())
	pts.append((x, y))
pts = sorted(pts)
from collections import Counter
x_eq = Counter([p[0] for p in pts])
y_eq = Counter([p[1] for p in pts])
all_eq = Counter(pts)
res = 0
for v in x_eq.values():
	res += v * (v - 1) // 2
for v in y_eq.values():
	res += v * (v - 1) // 2
for v in all_eq.values():
	res -= v * (v - 1) // 2
print(res)


n = int(input())
xm = {}
ym = {}
pp = {}
for _ in range(n):
	(x, y) = list(map(int, input().split()))
	if x in xm:
		xm[x] += 1
	else:
		xm[x] = 1
	if y in ym:
		ym[y] += 1
	else:
		ym[y] = 1
	if (x, y) in pp:
		pp[x, y] += 1
	else:
		pp[x, y] = 1
res = 0
for i in xm.values():
	res += i * (i - 1) // 2
for i in ym.values():
	res += i * (i - 1) // 2
for i in pp.values():
	res -= i * (i - 1) // 2
print(res)


def main():
	n = int(input())
	(xs, ys, clones) = ({}, {}, {})
	res = 0
	clones_num = 0
	points = []
	for _ in range(n):
		(x, y) = list(map(int, input().split()))
		if x not in xs:
			xs[x] = 0
		if y not in ys:
			ys[y] = 0
		if (x, y) not in clones:
			clones[x, y] = 0
		xs[x] += 1
		ys[y] += 1
		clones[x, y] += 1
	for c in clones:
		n = clones[c]
		clones_num += n * (n - 1) // 2
	for x in xs:
		n = xs[x]
		res += n * (n - 1) // 2
	for y in ys:
		n = ys[y]
		res += n * (n - 1) // 2
	print(res - clones_num)

def __starting_point():
	main()
__starting_point()


def to_list(s):
	return list(map(lambda x: int(x), s.split(' ')))

def f(n):
	k = 1
	for i in range(2, n + 1):
		k *= i
	return k

def C(n, k):
	if n < k:
		return 0
	else:
		return int(n * (n - 1) / 2)

def get_number(a):
	dict_ = {}
	sorted_a = sorted(a)
	curr_item = sorted_a[0]
	count = 1
	for i in range(1, len(a)):
		if sorted_a[i] != curr_item:
			dict_[curr_item] = count
			count = 1
			curr_item = sorted_a[i]
		else:
			count += 1
	dict_[curr_item] = count
	sum_ = 0
	for item in dict_:
		sum_ += C(dict_[item], 2)
	return sum_

def get_repeated(a):
	dict_ = {}
	sorted_a = sorted(a)
	curr_item = sorted_a[0]
	count = 1
	for i in range(1, len(a)):
		if sorted_a[i] != curr_item:
			dict_[curr_item] = count
			count = 1
			curr_item = sorted_a[i]
		else:
			count += 1
	dict_[curr_item] = count
	sum_ = 0
	for item in dict_:
		if dict_[item] > 1:
			sum_ += C(dict_[item], 2)
	return sum_

def solve(x_coords, y_coords, strs):
	x_number = get_number(x_coords)
	y_number = get_number(y_coords)
	repeated = get_repeated(strs)
	return str(int(x_number + y_number - repeated))
n = int(input())
strs = []
x_coords = []
y_coords = []
for i in range(n):
	s = to_list(input())
	x_coords.append(s[0])
	y_coords.append(s[1])
	strs.append(str(s[0]) + str(s[1]))
print(solve(x_coords, y_coords, strs))


from collections import defaultdict, Counter
n = int(input())
w = []
for i in range(n):
	w.append(tuple(map(int, input().split())))
dx = Counter()
dy = Counter()
for (x, y) in w:
	dx[x] += 1
	dy[y] += 1
count = sum((v * (v - 1) / 2 for v in dx.values())) + sum((v * (v - 1) / 2 for v in dy.values()))
dc = Counter(w)
count -= sum((c * (c - 1) / 2 for c in dc.values() if c > 1))
print(int(count))


from collections import defaultdict
n = int(input().strip())
nc2 = [0]
for i in range(1, n + 1):
	nc2.append(nc2[i - 1] + (i - 1))
count_x = defaultdict(int)
count_y = defaultdict(int)
count_points = defaultdict(int)
num_dup = 0
for i in range(n):
	(x, y) = map(int, input().strip().split())
	count_x[x] += 1
	count_y[y] += 1
	count_points[x, y] += 1
ans = 0
for (k, v) in count_x.items():
	ans += nc2[v]
for (k, v) in count_y.items():
	ans += nc2[v]
for (k, v) in count_points.items():
	ans -= nc2[v]
print(ans)


n = int(input())
d1 = dict()
d2 = dict()
d3 = dict()
res = 0
for i in range(n):
	(x, y) = (int(z) for z in input().split())
	res += d1.get(x, 0)
	res += d2.get(y, 0)
	res -= d3.get((x, y), 0)
	if not d1.get(x):
		d1[x] = 0
	if not d2.get(y):
		d2[y] = 0
	if not d3.get((x, y)):
		d3[x, y] = 0
	d1[x] += 1
	d2[y] += 1
	d3[x, y] += 1
print(res)


n = int(input())
d = {}
x = {}
y = {}
for i in range(n):
	(a, b) = map(int, input().split())
	if a in x:
		x[a] += 1
	elif a not in x:
		x[a] = 1
	if b in y:
		y[b] += 1
	elif b not in y:
		y[b] = 1
	if (a, b) not in d:
		d[a, b] = 1
	elif (a, b) in d:
		d[a, b] += 1
c = 0
for i in x:
	c += x[i] * (x[i] - 1) // 2
for i in y:
	c += y[i] * (y[i] - 1) // 2
for i in d:
	c -= d[i] * (d[i] - 1) // 2
print(c)


d1 = {}
d2 = {}
d = {}
for i in range(int(input())):
	(x, y) = map(int, input().split())
	if d.get((x, y)) == None:
		d[x, y] = 1
	else:
		d[x, y] += 1
	if d1.get(x) == None:
		d1[x] = 1
	else:
		d1[x] += 1
	if d2.get(y) == None:
		d2[y] = 1
	else:
		d2[y] += 1
sum = 0
for j in d1:
	k = d1[j]
	sum += k * (k - 1) / 2
for j in d2:
	k = d2[j]
	sum += k * (k - 1) / 2
for j in d:
	if d[j] > 1:
		k = d[j]
		sum -= k * (k - 1) / 2
print(int(sum))


n = int(input())
x2pts = {}
y2pts = {}
watchmen = {}
for i in range(n):
	watchman = tuple(map(int, input().split()))
	watchmen[watchman] = watchmen.get(watchman, 0) + 1
	x2pts[watchman[0]] = x2pts.get(watchman[0], 0) + 1
	y2pts[watchman[1]] = y2pts.get(watchman[1], 0) + 1
pairs = 0
for i in watchmen.items():
	pairs -= i[1] * (i[1] - 1) // 2
for i in x2pts.items():
	pairs += i[1] * (i[1] - 1) // 2
for i in y2pts.items():
	pairs += i[1] * (i[1] - 1) // 2
print(pairs)


from collections import Counter
a0 = int(input())
c = 0
xx = Counter()
yy = Counter()
xy = Counter()
for z in range(a0):
	(x, y) = map(int, input().split())
	c += xx[x] + yy[y] - xy[x, y]
	xx[x] += 1
	yy[y] += 1
	xy[x, y] += 1
print(c)


n = int(input())
(x, y, z, a) = ({}, {}, {}, 0)
for i in range(n):
	(q, w) = map(int, input().split())
	x[q] = x[q] + 1 if q in x else 1
	y[w] = y[w] + 1 if w in y else 1
	p = str([q, w])
	z[p] = z[p] + 1 if p in z else 1
for i in x:
	o = x[i]
	a += o * (o - 1) // 2
for i in y:
	o = y[i]
	a += o * (o - 1) // 2
for i in z:
	o = z[i]
	a -= o * (o - 1) // 2
print(a)


a = int(input())
dic = dict()
arr_cal = []
arr_x = dict()
arr_y = dict()
res = 0
dup = 0
for i in range(0, a):
	(x, y) = [int(num) for num in input().split()]
	if (x, y) in dic:
		dic[x, y] += 1
	else:
		dic[x, y] = 1
	if x in arr_x:
		arr_x[x] += 1
	else:
		arr_x[x] = 1
	if y in arr_y:
		arr_y[y] += 1
	else:
		arr_y[y] = 1
for k in dic:
	dup += dic[k] * (dic[k] - 1) / 2
for k in arr_x:
	if arr_x[k] > 1:
		res += arr_x[k] * (arr_x[k] - 1) / 2
for k in arr_y:
	if arr_y[k] > 1:
		res += arr_y[k] * (arr_y[k] - 1) / 2
print(int(res - dup))


from collections import Counter
n = int(input())
x_c = Counter()
y_c = Counter()
coords_c = Counter()
ans = 0
for _ in range(n):
	(x, y) = map(int, input().split())
	ans += x_c[x]
	ans += y_c[y]
	ans -= coords_c[x, y]
	x_c[x] += 1
	y_c[y] += 1
	coords_c[x, y] += 1
print(ans)


import sys
xdict = dict()
ydict = dict()
xydict = dict()
n = int(sys.stdin.readline())
for i in range(0, n):
	nums = list(map(int, sys.stdin.readline().split()))
	x = nums[0]
	y = nums[1]
	if xdict.get(x):
		xdict[x] += 1
	else:
		xdict[x] = 1
	if ydict.get(y):
		ydict[y] += 1
	else:
		ydict[y] = 1
	if xydict.get((x, y)):
		xydict[x, y] += 1
	else:
		xydict[x, y] = 1
pairs = 0
for x in xdict.values():
	pairs += x * (x - 1) // 2
for y in ydict.values():
	pairs += y * (y - 1) // 2
for xy in xydict.values():
	pairs -= xy * (xy - 1) // 2
print(pairs)


def fact(x):
	if x == 0:
		return 1
	else:
		return x * fact(x - 1)

def lower_bound(li, num):
	answer = -1
	start = 0
	end = len(li) - 1
	while start <= end:
		middle = (end + start) // 2
		if li[middle] >= num:
			answer = middle
			end = middle - 1
		else:
			start = middle + 1
	return answer

def upper_bound(li, num):
	answer = -1
	start = 0
	end = len(li) - 1
	while start <= end:
		middle = (end + start) // 2
		if li[middle] <= num:
			answer = middle
			start = middle + 1
		else:
			end = middle - 1
	return answer

def abs(x):
	return x if x >= 0 else -x

def binary_search(li, val, lb, ub):
	ans = 0
	while lb <= ub:
		mid = (lb + ub) // 2
		if li[mid] > val:
			ub = mid - 1
		elif val > li[mid]:
			lb = mid + 1
		else:
			ans = 1
			break
	return ans

def kadane(x):
	sum_so_far = 0
	current_sum = 0
	for i in x:
		current_sum += i
		if current_sum < 0:
			current_sum = 0
		else:
			sum_so_far = mpos(sum_so_far, current_sum)
	return sum_so_far

def pref(li):
	pref_sum = [0]
	for i in li:
		pref_sum.append(pref_sum[-1] + i)
	return pref_sum

def graph(n, m):
	adj = dict()
	for i in range(1, n + 1):
		adj.setdefault(i, 0)
	for i in range(m):
		(a, b) = map(int, input().split())
		adj[a] += 1
		adj[b] += 1
	return adj
import sys
import threading
from math import *
sys.setrecursionlimit(300000)
for _ in range(1):
	n = int(input())
	(m, m1, m2) = ({}, {}, {})
	for i in range(n):
		(x, y) = map(int, input().split())
		if (x, y) in m:
			m[x, y] += 1
		else:
			m[x, y] = 1
		if x in m1:
			m1[x] += 1
		else:
			m1[x] = 1
		if y in m2:
			m2[y] += 1
		else:
			m2[y] = 1
	ans = 0
	for i in m1.values():
		ans += i * (i - 1) // 2
	for i in m2.values():
		ans += i * (i - 1) // 2
	for i in m.values():
		ans -= i * (i - 1) // 2
	print(ans)


def main():
	n = int(input())
	xs = {}
	ys = {}
	xys = {}
	total = 0
	for i in range(n):
		ab = list(map(int, input().split()))
		a = ab[0]
		b = ab[1]
		if a not in xs:
			xs[a] = 0
		else:
			xs[a] += 1
			total += xs[a]
		if b not in ys:
			ys[b] = 0
		else:
			ys[b] += 1
			total += ys[b]
		if (a, b) not in xys:
			xys[a, b] = 0
		else:
			xys[a, b] += 1
			total -= xys[a, b]
	print(total)
main()


n = int(input())
X_axis = {}
Y_axis = {}
XY_axis = {}
for i in range(n):
	(a, b) = [int(x) for x in input().split()]
	pair = (a, b)
	X_axis[a] = X_axis.get(a, 0) + 1
	Y_axis[b] = Y_axis.get(b, 0) + 1
	XY_axis[pair] = XY_axis.get(pair, 0) + 1
sum = 0
for i in X_axis:
	var = X_axis[i]
	if var > 0:
		sum = sum + var * (var - 1) // 2
for i in Y_axis:
	var = Y_axis[i]
	if var > 0:
		sum = sum + var * (var - 1) // 2
for i in XY_axis:
	var = XY_axis[i]
	sum = sum - var * (var - 1) // 2
print(sum)


def math(x):
	return x * (x - 1) // 2
n = int(input())
left = {}
right = {}
both = {}
for i in range(n):
	t = tuple(map(int, input().split()))
	try:
		left[t[0]] += 1
	except:
		left[t[0]] = 1
	try:
		right[t[1]] += 1
	except:
		right[t[1]] = 1
	try:
		both[t] += 1
	except:
		both[t] = 1
res = 0
for i in left:
	el = left[i]
	res += math(el)
for i in right:
	el = right[i]
	res += math(el)
for i in both:
	el = both[i]
	res -= math(el)
print(res)


n = int(input())
s = []
k = 0
for i in range(n):
	s.append([int(x) for x in input().split()])
s.sort()
a = s[0][0]
c = 0
for j in range(1, n):
	if s[j][0] == a:
		c += 1
		k += c
	else:
		a = s[j][0]
		c = 0
s.sort(key=lambda a: a[1])
a = s[0][1]
c = 0
for j in range(1, n):
	if s[j][1] == a:
		c += 1
		k += c
	else:
		a = s[j][1]
		c = 0
a = s[0]
c = 0
for j in range(1, n):
	if s[j] == a:
		c += 1
		k -= c
	else:
		a = s[j]
		c = 0
print(k)


n = int(input())
Dx = dict()
Dy = dict()
Dxy = dict()
for _ in range(n):
	(x, y) = map(int, input().split())
	if x in Dx:
		Dx[x] += 1
	else:
		Dx[x] = 1
	if y in Dy:
		Dy[y] += 1
	else:
		Dy[y] = 1
	if (x, y) in Dxy:
		Dxy[x, y] += 1
	else:
		Dxy[x, y] = 1
R = dict()
for v in Dx.values():
	if v in R:
		R[v] += 1
	else:
		R[v] = 1
for v in Dy.values():
	if v in R:
		R[v] += 1
	else:
		R[v] = 1
for v in Dxy.values():
	if v in R:
		R[v] -= 1
	else:
		R[v] = -1
ans = 0
for v in R:
	ans += R[v] * v * (v - 1) // 2
print(ans)


from collections import Counter
(xs, ys) = (Counter(), Counter())
points = Counter()
n = int(input())
total = 0
while n:
	(x, y) = [int(n) for n in input().split()]
	paired = xs[x] + ys[y] - points[x, y]
	xs[x] += 1
	ys[y] += 1
	points[x, y] += 1
	total += paired
	n -= 1
print(total)


(z, zz) = (input, lambda : list(map(int, z().split())))
fast = lambda : stdin.readline().strip()
zzz = lambda : [int(i) for i in fast().split()]
(szz, graph, mod, szzz) = (lambda : sorted(zz()), {}, 10 ** 9 + 7, lambda : sorted(zzz()))
from string import *
from re import *
from collections import *
from queue import *
from sys import *
from collections import *
from math import *
from heapq import *
from itertools import *
from bisect import *
from collections import Counter as cc
from math import factorial as f
from bisect import bisect as bs
from bisect import bisect_left as bsl
from itertools import accumulate as ac

def lcd(xnum1, xnum2):
	return xnum1 * xnum2 // gcd(xnum1, xnum2)

def prime(x):
	p = ceil(x ** 0.5) + 1
	for i in range(2, p):
		if x % i == 0 and x != 2 or x == 0:
			return 0
	return 1

def dfs(u, visit, graph):
	visit[u] = 1
	for i in graph[u]:
		if not visit[i]:
			dfs(i, visit, graph)
num = int(fast())
ans = 0
lst_x = {}
lst_y = {}
lst_xy = {}
res1 = 0
res2 = 0
res3 = 0
for i in range(num):
	(x, y) = zzz()
	try:
		lst_xy[x, y]
	except:
		lst_xy[x, y] = 0
		res3 += 1
	try:
		lst_y[y]
	except:
		lst_y[y] = 0
		res2 += 1
	try:
		lst_x[x]
	except:
		lst_x[x] = 0
		res1 += 1
	lst_x[x] += 1
	lst_y[y] += 1
	lst_xy[x, y] += 1
lst1 = list(lst_x.values())
lst2 = list(lst_y.values())
lst3 = list(lst_xy.values())
for i in range(max(res1, res2, res3)):
	if i < res1:
		ans += lst1[i] * (lst1[i] - 1) // 2
	if i < res2:
		ans += lst2[i] * (lst2[i] - 1) // 2
	if i < res3:
		ans -= lst3[i] * (lst3[i] - 1) // 2
print(ans)


n = int(input())
z = n
x = {}
y = {}
xy = {}
ans = 0
while z:
	a = 0
	b = 0
	(a, b) = input().split(' ')
	a = int(a)
	b = int(b)
	try:
		x[a] = x[a] + 1
	except:
		x[a] = 1
	try:
		y[b] = y[b] + 1
	except:
		y[b] = 1
	try:
		xy[a, b] = xy[a, b] + 1
	except:
		xy[a, b] = 1
	ans += x[a] + y[b] - xy[a, b]
	z -= 1
print(ans - n)


from math import sin, pi, sqrt
n = int(input())
count = 0
liste = []
for i in range(n):
	(x, y) = [int(element) for element in input().split(' ')]
	liste.append((x, y))
listex = sorted(liste, key=lambda element: (element[0], element[1]))
listey = sorted(liste, key=lambda element: element[1])
answer = 0
tempo = 0
for i in range(1, n):
	if listex[i - 1][0] == listex[i][0]:
		if tempo == 0:
			tempo = 2
		else:
			tempo += 1
	elif tempo != 0:
		answer += tempo * (tempo - 1) // 2
		tempo = 0
	if i == n - 1:
		answer += tempo * (tempo - 1) // 2
tempo = 0
for i in range(1, n):
	if listey[i - 1][1] == listey[i][1]:
		if tempo == 0:
			tempo = 2
		else:
			tempo += 1
	elif tempo != 0:
		answer += tempo * (tempo - 1) // 2
		tempo = 0
	if i == n - 1:
		answer += tempo * (tempo - 1) // 2
tempo = 0
for i in range(1, n):
	if listex[i - 1] == listex[i]:
		if tempo == 0:
			tempo = 2
		else:
			tempo += 1
	elif tempo != 0:
		answer -= tempo * (tempo - 1) // 2
		tempo = 0
	if i == n - 1:
		answer -= tempo * (tempo - 1) // 2
print(answer)


from sys import *

def main():
	n = int(stdin.readline())
	(sx, sy, sxy, ans) = ({}, {}, {}, 0)
	for i in range(n):
		(a, b) = map(int, stdin.readline().split())
		sx.setdefault(a, 0)
		sy.setdefault(b, 0)
		sxy.setdefault((a, b), 0)
		ans += sx[a] + sy[b] - sxy[a, b]
		sx[a] += 1
		sy[b] += 1
		sxy[a, b] += 1
	print(ans)
main()


n = int(input())
a = sorted([[int(x) for x in input().split()] for _ in range(n)])
ax = [a[i][0] for i in range(n)]
ay = sorted([a[i][1] for i in range(n)])
cnt = 0
aux = 1
for i in range(n - 1):
	if ax[i] == ax[i + 1]:
		aux += 1
	else:
		cnt += aux * (aux - 1) // 2
		aux = 1
cnt += aux * (aux - 1) // 2
aux = 1
for i in range(n - 1):
	if ay[i] == ay[i + 1]:
		aux += 1
	else:
		cnt += aux * (aux - 1) // 2
		aux = 1
cnt += aux * (aux - 1) // 2
aux = 1
for i in range(n - 1):
	if a[i] == a[i + 1]:
		aux += 1
	else:
		cnt -= aux * (aux - 1) // 2
		aux = 1
cnt -= aux * (aux - 1) // 2
print(cnt)


import math
q = 1
for _ in range(q):
	n = int(input())
	l = []
	xx = []
	yy = []
	for i in range(n):
		(x, y) = map(int, input().split())
		l.append([x, y])
		xx.append(x)
		yy.append(y)
	l.sort()
	k1 = 1
	k2 = 1
	ans = 0
	same = 1
	for i in range(n - 1):
		if l[i + 1] == l[i]:
			same += 1
		else:
			ans -= same * (same - 1) // 2
			same = 1
	ans -= same * (same - 1) // 2
	xx.sort()
	yy.sort()
	for i in range(n - 1):
		if xx[i + 1] == xx[i]:
			k1 += 1
		else:
			ans += k1 * (k1 - 1) // 2
			k1 = 1
	ans += k1 * (k1 - 1) // 2
	for i in range(n - 1):
		if yy[i + 1] == yy[i]:
			k2 += 1
		else:
			ans += k2 * (k2 - 1) // 2
			k2 = 1
	ans += k2 * (k2 - 1) // 2
	print(ans)


n = int(input())
b = []
c = []
for i in range(n):
	a = list(map(int, input().strip().split(' ')))
	b.append([a[0], a[1]])
	c.append([a[1], a[0]])
b.sort()
c.sort()
i = 0
total = 0
s = 1
while i < n - 1:
	if b[i][0] == b[i + 1][0]:
		s += 1
	else:
		total = total + s * (s - 1) // 2
		s = 1
	i += 1
total = total + s * (s - 1) // 2
s = 1
i = 0
while i < n - 1:
	if c[i][0] == c[i + 1][0]:
		s += 1
	else:
		total = total + s * (s - 1) // 2
		s = 1
	i += 1
total = total + s * (s - 1) // 2
s = 1
for i in range(n - 1):
	if b[i] == b[i + 1]:
		s += 1
	else:
		total -= s * (s - 1) // 2
		s = 1
total -= s * (s - 1) // 2
print(total)


n = int(input())
xd = {}
yd = {}
cd = {}
for i in range(n):
	(a, b) = [int(x) for x in input().split(' ')]
	if a not in xd:
		xd[a] = 0
	xd[a] += 1
	if b not in yd:
		yd[b] = 0
	yd[b] += 1
	if (a, b) not in cd:
		cd[a, b] = 0
	cd[a, b] += 1
ans = 0
for k in xd:
	ans += xd[k] * (xd[k] - 1) // 2
for k in yd:
	ans += yd[k] * (yd[k] - 1) // 2
for k in cd:
	ans -= cd[k] * (cd[k] - 1) // 2
print(ans)


def summa_maksonchik_top_potomu_chto_pishet_cod_na_scretche(n_maksonchik_top_potomu_chto_pishet_cod_na_scretche):
	ans_maksonchik_top_potomu_chto_pishet_cod_na_scretche = 0
	while n_maksonchik_top_potomu_chto_pishet_cod_na_scretche > 0:
		ans_maksonchik_top_potomu_chto_pishet_cod_na_scretche += n_maksonchik_top_potomu_chto_pishet_cod_na_scretche
		n_maksonchik_top_potomu_chto_pishet_cod_na_scretche -= 1
	return ans_maksonchik_top_potomu_chto_pishet_cod_na_scretche
import sys
n_maksonchik_top_potomu_chto_pishet_cod_na_scretche = int(sys.stdin.readline())
a_maksonchik_top_potomu_chto_pishet_cod_na_scretche = []
ans_maksonchik_top_potomu_chto_pishet_cod_na_scretche = 0
for i_maksonchik_top_potomu_chto_pishet_cod_na_scretche in range(n_maksonchik_top_potomu_chto_pishet_cod_na_scretche):
	a_maksonchik_top_potomu_chto_pishet_cod_na_scretche.append(tuple(map(int, sys.stdin.readline().split())))
b_maksonchik_top_potomu_chto_pishet_cod_na_scretche = {}
x_maksonchik_top_potomu_chto_pishet_cod_na_scretche = {}
for i_maksonchik_top_potomu_chto_pishet_cod_na_scretche in a_maksonchik_top_potomu_chto_pishet_cod_na_scretche:
	if i_maksonchik_top_potomu_chto_pishet_cod_na_scretche[0] not in x_maksonchik_top_potomu_chto_pishet_cod_na_scretche:
		x_maksonchik_top_potomu_chto_pishet_cod_na_scretche[i_maksonchik_top_potomu_chto_pishet_cod_na_scretche[0]] = [1, 0]
		b_maksonchik_top_potomu_chto_pishet_cod_na_scretche[i_maksonchik_top_potomu_chto_pishet_cod_na_scretche] = 1
	else:
		if i_maksonchik_top_potomu_chto_pishet_cod_na_scretche not in b_maksonchik_top_potomu_chto_pishet_cod_na_scretche:
			b_maksonchik_top_potomu_chto_pishet_cod_na_scretche[i_maksonchik_top_potomu_chto_pishet_cod_na_scretche] = 1
		else:
			b_maksonchik_top_potomu_chto_pishet_cod_na_scretche[i_maksonchik_top_potomu_chto_pishet_cod_na_scretche] += 1
		x_maksonchik_top_potomu_chto_pishet_cod_na_scretche[i_maksonchik_top_potomu_chto_pishet_cod_na_scretche[0]][0] += 1
		x_maksonchik_top_potomu_chto_pishet_cod_na_scretche[i_maksonchik_top_potomu_chto_pishet_cod_na_scretche[0]][1] += x_maksonchik_top_potomu_chto_pishet_cod_na_scretche[i_maksonchik_top_potomu_chto_pishet_cod_na_scretche[0]][0] - 1
for i_maksonchik_top_potomu_chto_pishet_cod_na_scretche in x_maksonchik_top_potomu_chto_pishet_cod_na_scretche.values():
	ans_maksonchik_top_potomu_chto_pishet_cod_na_scretche += i_maksonchik_top_potomu_chto_pishet_cod_na_scretche[1]
y_maksonchik_top_potomu_chto_pishet_cod_na_scretche = {}
for i_maksonchik_top_potomu_chto_pishet_cod_na_scretche in a_maksonchik_top_potomu_chto_pishet_cod_na_scretche:
	if i_maksonchik_top_potomu_chto_pishet_cod_na_scretche[1] not in y_maksonchik_top_potomu_chto_pishet_cod_na_scretche:
		y_maksonchik_top_potomu_chto_pishet_cod_na_scretche[i_maksonchik_top_potomu_chto_pishet_cod_na_scretche[1]] = [1, 0]
	else:
		y_maksonchik_top_potomu_chto_pishet_cod_na_scretche[i_maksonchik_top_potomu_chto_pishet_cod_na_scretche[1]][0] += 1
		y_maksonchik_top_potomu_chto_pishet_cod_na_scretche[i_maksonchik_top_potomu_chto_pishet_cod_na_scretche[1]][1] += y_maksonchik_top_potomu_chto_pishet_cod_na_scretche[i_maksonchik_top_potomu_chto_pishet_cod_na_scretche[1]][0] - 1
for i_maksonchik_top_potomu_chto_pishet_cod_na_scretche in y_maksonchik_top_potomu_chto_pishet_cod_na_scretche.values():
	ans_maksonchik_top_potomu_chto_pishet_cod_na_scretche += i_maksonchik_top_potomu_chto_pishet_cod_na_scretche[1]
for i_maksonchik_top_potomu_chto_pishet_cod_na_scretche in b_maksonchik_top_potomu_chto_pishet_cod_na_scretche.values():
	if i_maksonchik_top_potomu_chto_pishet_cod_na_scretche > 1:
		ans_maksonchik_top_potomu_chto_pishet_cod_na_scretche -= summa_maksonchik_top_potomu_chto_pishet_cod_na_scretche(i_maksonchik_top_potomu_chto_pishet_cod_na_scretche - 1)
print(ans_maksonchik_top_potomu_chto_pishet_cod_na_scretche)


def fn(arr):
	ans = 0
	for i in arr:
		ans += i * (i - 1) // 2
	return ans
n = int(input())
a = []
b = []
for _ in range(n):
	(x, y) = map(int, input().split())
	a.append([x, y])
	b.append([y, x])
b.sort()
a.sort()
x_ans = 1
x = []
y_ans = 1
y = []
common = 1
c = []
for i in range(n - 1):
	if a[i][0] == a[i + 1][0]:
		x_ans += 1
		if i == n - 2 and x_ans != 1:
			x.append(x_ans)
	elif x_ans != 1:
		x.append(x_ans)
		x_ans = 1
for i in range(n - 1):
	if b[i][0] == b[i + 1][0]:
		y_ans += 1
		if i == n - 2 and y_ans != 1:
			y.append(y_ans)
	elif y_ans != 1:
		y.append(y_ans)
		y_ans = 1
for i in range(n - 1):
	if a[i] == a[i + 1]:
		common += 1
		if i == n - 2:
			c.append(common)
	elif common != 1:
		c.append(common)
		common = 1
a1 = fn(x)
a2 = fn(y)
a3 = fn(c)
print(a1 + a2 - a3)


from collections import *
ans = 0
cx = Counter()
cy = Counter()
cp = Counter()
n = int(input())
for i in range(n):
	(x, y) = map(int, input().split())
	cx[x] += 1
	cy[y] += 1
	cp[x, y] += 1
kx = ky = kp = 0
for x in cx:
	kx += cx[x] * (cx[x] - 1) // 2
for y in cy:
	ky += cy[y] * (cy[y] - 1) // 2
for p in cp:
	kp += cp[p] * (cp[p] - 1) // 2
print(kx + ky - kp)


(x, y, c, d) = ({}, {}, 0, {})
for i in range(int(input())):
	(a, b) = map(int, input().split())
	if a in x:
		x[a] += 1
	else:
		x[a] = 1
	if b in y:
		y[b][0] += 1
	else:
		y[b] = [1, 0]
	if (a, b) in d:
		d[a, b] += 1
	else:
		d[a, b] = 1
for i in d:
	y[i[1]][1] += d[i] * d[i]
for k in x.values():
	c += k * (k - 1) // 2
for k in y.values():
	c += (k[0] * k[0] - k[1]) // 2
print(c)


class A(object):

	def __init__(self):
		self.AC()

	def GetData(self):
		self.m_N = int(input())
		self.m_Point = []
		for i in range(self.m_N):
			(x, y) = map(int, input().split())
			self.m_Point.append((x, y))

	def AC(self):
		self.GetData()
		self.m_X = {}
		self.m_Y = {}
		self.m_P = {}
		ans = 0
		for (x, y) in self.m_Point:
			if x not in self.m_X:
				self.m_X[x] = 1
			else:
				self.m_X[x] += 1
			if y not in self.m_Y:
				self.m_Y[y] = 1
			else:
				self.m_Y[y] += 1
			if x not in self.m_P:
				self.m_P[x] = {}
			if y not in self.m_P[x]:
				self.m_P[x][y] = 1
			else:
				self.m_P[x][y] += 1
		for (k, v) in self.m_X.items():
			if v >= 2:
				ans += v * (v - 1) / 2
				for (nk, nv) in self.m_P[k].items():
					if nv >= 2:
						ans -= nv * (nv - 1) / 2
		for (k, v) in self.m_Y.items():
			if v >= 2:
				ans += v * (v - 1) / 2
		print(int(ans))
A()


(z, zz) = (input, lambda : list(map(int, z().split())))
fast = lambda : stdin.readline().strip()
zzz = lambda : [int(i) for i in fast().split()]
(szz, graph, mod, szzz) = (lambda : sorted(zz()), {}, 10 ** 9 + 7, lambda : sorted(zzz()))
from string import *
from re import *
from collections import *
from queue import *
from sys import *
from collections import *
from math import *
from heapq import *
from itertools import *
from bisect import *
from collections import Counter as cc
from math import factorial as f
from bisect import bisect as bs
from bisect import bisect_left as bsl
from itertools import accumulate as ac

def lcd(xnum1, xnum2):
	return xnum1 * xnum2 // gcd(xnum1, xnum2)

def prime(x):
	p = ceil(x ** 0.5) + 1
	for i in range(2, p):
		if x % i == 0 and x != 2 or x == 0:
			return 0
	return 1

def dfs(u, visit, graph):
	visit[u] = 1
	for i in graph[u]:
		if not visit[i]:
			dfs(i, visit, graph)
num = int(z())
lst_x = []
lst_y = []
xy = []
for i in range(num):
	(x, y) = zzz()
	lst_x.append(x)
	lst_y.append(y)
	xy.append((x, y))

def solve(lst):
	ans = 0
	lst.sort()
	cur = 0
	for last in range(1, len(lst)):
		if lst[last] == lst[last - 1]:
			continue
		ans += (last - cur) * (last - cur - 1) // 2
		cur = last
	ans += (num - cur) * (num - cur - 1) // 2
	return ans
print(solve(lst_x) + solve(lst_y) - solve(xy))


from collections import Counter
(x, y, p) = (Counter(), Counter(), Counter())
for _ in range(int(input())):
	(i, j) = map(int, input().split())
	x[i] += 1
	y[j] += 1
	p[i, j] += 1

def cnt(n):
	return n * (n - 1) // 2
ans = sum(map(cnt, x.values())) + sum(map(cnt, y.values())) - sum(map(cnt, p.values()))
print(ans)


from collections import Counter
n = int(input())
(d1, d2, x) = ({}, {}, [])
for _ in range(n):
	i = input()
	(a, b) = (i.split()[0], i.split()[1])
	if a in d1:
		d1[a] += 1
	else:
		d1[a] = 1
	if b in d2:
		d2[b] += 1
	else:
		d2[b] = 1
	x.append(i)
s = 0
for c1 in d1.values():
	s += c1 * (c1 - 1) // 2
for c2 in d2.values():
	s += c2 * (c2 - 1) // 2
for x1 in Counter(x).values():
	s -= x1 * (x1 - 1) // 2
print(s)


from collections import *
n = int(input())
xd = Counter()
yd = Counter()
pd = Counter()
for i in range(n):
	(x, y) = map(int, input().split())
	xd[x] += 1
	yd[y] += 1
	pd[x, y] += 1
ans = 0
for x in xd:
	ans += xd[x] * (xd[x] - 1) // 2
for y in yd:
	ans += yd[y] * (yd[y] - 1) // 2
for p in pd:
	ans -= pd[p] * (pd[p] - 1) // 2
print(ans)


n = int(input())
dict_x = {}
dict_y = {}
dict_xy = {}
for _ in range(n):
	(x, y) = map(int, input().split())
	try:
		dict_xy[x, y] += 1
	except KeyError:
		dict_xy[x, y] = 1
	try:
		dict_x[x] += 1
	except KeyError:
		dict_x[x] = 1
	try:
		dict_y[y] += 1
	except KeyError:
		dict_y[y] = 1
ans = 0
for i in (*dict_x.values(), *dict_y.values()):
	ans += i * (i - 1) // 2
for i in dict_xy.values():
	ans -= i * (i - 1) // 2
print(ans)


from collections import Counter
n = int(input())
arr = [tuple(map(int, input().split())) for _ in range(n)]
c = Counter(arr)
duplicate = 0
for i in c.values():
	duplicate += i * (i - 1) // 2
xs = Counter(map(lambda x: x[0], arr))
ys = Counter(map(lambda x: x[1], arr))
cnt = 0
for i in xs.values():
	cnt += i * (i - 1) // 2
for i in ys.values():
	cnt += i * (i - 1) // 2
print(cnt - duplicate)


n = int(input())
l = []
for i in range(n):
	l.append(list(map(int, input().split())))
xd = {}
yd = {}
dup = {}
count = 0
for [x, y] in l:
	if x not in xd.keys():
		xd[x] = 1
	else:
		xd[x] += 1
		count += xd[x] - 1
	if y not in yd.keys():
		yd[y] = 1
	else:
		yd[y] += 1
		count += yd[y] - 1
	if (x, y) not in dup.keys():
		dup[x, y] = 1
	else:
		dup[x, y] += 1
		count -= dup[x, y] - 1
print(count)


def block(arr, index):
	ref = arr[0][index]
	count = 0
	pairs = 0
	for (i, num) in enumerate(arr):
		if i < len(arr) - 1 and num[index] == ref:
			count += 1
		else:
			if i == len(arr) - 1 and num[index] == ref:
				count += 1
			pairs = pairs + count * (count - 1) // 2
			ref = num[index]
			count = 1
	return pairs

def CF651C():
	N = int(input())
	points = [tuple(map(int, input().split())) for _ in range(N)]
	points = sorted(points)
	pairs = 0
	(rx, ry) = points[0]
	curr = 0
	for (i, (x, y)) in enumerate(points):
		if i < N - 1 and rx == x and (ry == y):
			curr += 1
		else:
			if i == N - 1 and rx == x and (ry == y):
				curr += 1
			pairs -= curr * (curr - 1) // 2
			curr = 1
			(rx, ry) = (x, y)
	pairs += block(points, 0)
	points = sorted(points, key=lambda x: x[1])
	pairs += block(points, 1)
	return pairs
result = CF651C()
print(result)


from collections import defaultdict
n = int(input())
co_ord = []
Dict_x = defaultdict(int)
Dict_y = defaultdict(int)
Dict = defaultdict(int)
for i in range(n):
	(x, y) = [int(i) for i in input().split()]
	co_ord.append((x, y))
	Dict_x[x] += 1
	Dict_y[y] += 1
	Dict[x, y] += 1
values_x = list(Dict_x.values())
values_y = list(Dict_y.values())
values_z = list(Dict.values())
ans = 0
for i in range(len(values_x)):
	ans += values_x[i] * (values_x[i] - 1) // 2
for i in range(len(values_y)):
	ans += values_y[i] * (values_y[i] - 1) // 2
for i in range(len(values_z)):
	ans -= values_z[i] * (values_z[i] - 1) // 2
print(ans)


from functools import cmp_to_key

class Coordenada:

	def __init__(self, x, y):
		self.x = x
		self.y = y

	def __str__(self):
		return '({}, {})'.format(self.x, self.y)

	def __repr__(self):
		return '({}, {})'.format(self.x, self.y)
n = int(input())
posicoes = []
for _ in range(n):
	(x, y) = map(int, input().split())
	posicoes.append(Coordenada(x, y))
dicionarioP = {}
dicionarioX = {}
dicionarioY = {}
for c in posicoes:
	if str(c) not in dicionarioP:
		dicionarioP[str(c)] = 0
	dicionarioP[str(c)] += 1
repeticoes = 0
for key in dicionarioP:
	x = dicionarioP[key]
	repeticoes += x * (x - 1) // 2
for c in posicoes:
	if c.x not in dicionarioX:
		dicionarioX[c.x] = 0
	if c.y not in dicionarioY:
		dicionarioY[c.y] = 0
	dicionarioX[c.x] += 1
	dicionarioY[c.y] += 1
somatorio = 0
for key in dicionarioX:
	x = dicionarioX[key]
	somatorio += x * (x - 1) // 2
for key in dicionarioY:
	x = dicionarioY[key]
	somatorio += x * (x - 1) // 2
print(somatorio - repeticoes)


I = lambda : list(map(int, input().split()))
nperm = lambda x: x * (x - 1) // 2

def groupby(x, key):
	groups = {}
	for el in x:
		group = key(el)
		if group not in groups:
			groups[group] = []
		groups[group].append(el)
	return list(groups.values())
n = int(input())
w = [I() for i in range(n)]
ans = 0
ans += sum([nperm(len(i)) for i in groupby(w, key=lambda x: x[0])])
ans += sum([nperm(len(i)) for i in groupby(w, key=lambda x: x[1])])
ans -= sum([nperm(len(i)) for i in groupby(w, key=lambda x: (x[0], x[1]))])
print(ans)


import os
import sys
from math import *
from collections import *
from fractions import *
from bisect import *
from heapq import *
from io import BytesIO, IOBase

def vsInput():
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
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')

def value():
	return tuple(map(int, input().split()))

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

def Int():
	return int(input())

def Str():
	return input()

def arrayS():
	return [i for i in input().split()]
n = Int()
points = set()
x_count = defaultdict(int)
y_count = defaultdict(int)
p_count = defaultdict(int)
for i in range(n):
	p = value()
	(x, y) = p
	p_count[p] += 1
	x_count[x] += 1
	y_count[y] += 1
ans = 0
for i in x_count:
	ans += x_count[i] * (x_count[i] - 1) // 2
for i in y_count:
	ans += y_count[i] * (y_count[i] - 1) // 2
for i in p_count:
	ans -= p_count[i] * (p_count[i] - 1) // 2
print(ans)


from typing import List
from collections import Counter
INF = float('inf')
NINF = float('-inf')

def read_string():
	return input()

def read_string_line():
	return [x for x in input().split(' ')]

def read_int_line():
	return [int(x) for x in input().split(' ')]

def read_int():
	return int(input())

def get_int_arr(s):
	return [int(x) for x in s.split()]

def get_sum(acc, l, r):
	return acc[r] - acc[l]
P = int(1000000000.0 + 7)

def exgcd(x, y):
	if y == 0:
		return (x, 1, 0)
	(g, a, b) = exgcd(y, x % y)
	t = x // y
	return (g, b, a - t * b)

def inv(x):
	(g, a, b) = exgcd(x, P)
	return a

def calc_acc(arr):
	ans = [0]
	for a in arr:
		ans.append(a + ans[-1])
	return ans

class Point:

	def __init__(self, x, y):
		self.x = x
		self.y = y

	def __sub__(self, other):
		return Point(self.x - other.x, 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

	def abs(self):
		return self.abs2() ** 0.5

	def abs2(self):
		return self.dot(self)

	def __str__(self):
		return 'Point(%s, %s)' % (self.x, self.y)

def get_point(line):
	(x, y) = get_int_arr(line)
	return Point(x, y)
lines: List[str] = [*open(0)]
n = int(lines[0])
(cx, cy, cp) = (Counter(), Counter(), Counter())
for line in lines[1:n + 1]:
	(x, y) = get_int_arr(line)
	cx[x] += 1
	cy[y] += 1
	cp[x, y] += 1
ans = 0
for c in [cx, cy]:
	for v in c.values():
		ans += v * (v - 1) // 2
for v in cp.values():
	ans -= v * (v - 1) // 2
print(ans)


from collections import Counter
n = int(input())
pts_x = []
pts_y = []
pts = []
for _ in range(n):
	(x, y) = map(int, input().split())
	pts_x.append(x)
	pts_y.append(y)
	pts.append((x, y))
counter_x = Counter(pts_x)
counter_y = Counter(pts_y)
counter = Counter(pts)
num_pts = 0
for v in counter_x.values():
	if v >= 2:
		num_pts += (v - 1) * v // 2
for v in counter_y.values():
	if v >= 2:
		num_pts += (v - 1) * v // 2
for v in counter.values():
	if v >= 2:
		num_pts -= (v - 1) * v // 2
print(num_pts)


import collections
r = 0
(a, b, c) = [collections.Counter() for _ in [0, 0, 0]]
for _ in range(int(input())):
	(x, y) = list(map(int, input().split()))
	r += a[x] + b[y] - c[x, y]
	a[x] += 1
	b[y] += 1
	c[x, y] += 1
print(r)


n = int(input())
dx = {}
dy = {}
d = {}
for i in range(0, n):
	[x, y] = [int(j) for j in input().split()]
	if dx.get(x) == None:
		dx[x] = 1
	else:
		dx[x] += 1
	if dy.get(y) == None:
		dy[y] = 1
	else:
		dy[y] += 1
	if d.get((x, y)) == None:
		d[x, y] = 1
	else:
		d[x, y] += 1
c = 0
for i in dx.keys():
	if dx[i] > 1:
		c += dx[i] * (dx[i] - 1) // 2
for i in dy.keys():
	if dy[i] > 1:
		c += dy[i] * (dy[i] - 1) // 2
for i in d.keys():
	if d[i] > 1:
		c -= d[i] * (d[i] - 1) // 2
print(c)


def count(t):
	return sum((v * (v - 1) // 2 for v in t.values()))
(a, b, c) = ({}, {}, {})
n = int(input())
for _ in range(n):
	(x, y) = map(int, input().split())
	a[x] = a.get(x, 0) + 1
	b[y] = b.get(y, 0) + 1
	c[x, y] = c.get((x, y), 0) + 1
print(count(a) + count(b) - count(c))


import sys

def fastio():
	from io import StringIO
	from atexit import register
	global input
	sys.stdin = StringIO(sys.stdin.read())
	input = lambda : sys.stdin.readline().rstrip('\r\n')
	sys.stdout = StringIO()
	register(lambda : sys.__stdout__.write(sys.stdout.getvalue()))
fastio()

def debug(*var, sep=' ', end='\n'):
	print(*var, file=sys.stderr, end=end, sep=sep)
INF = 10 ** 20
MOD = 10 ** 9 + 7
I = lambda : list(map(int, input().split()))
from math import gcd
from math import ceil
from collections import defaultdict as dd, Counter
from bisect import bisect_left as bl, bisect_right as br
(n,) = I()
ans = 0
x = dd(int)
y = dd(int)
l = dd(int)
for i in range(n):
	(a, b) = I()
	ans += y[b]
	ans += x[a]
	ans -= l[a, b]
	l[a, b] += 1
	x[a] += 1
	y[b] += 1
print(ans)


n = int(input())
xx = {}
yy = {}
a = list()
s = {}
for i in range(n):
	(x, y) = map(int, input().split())
	a.append((x, y))
	if (x, y) in s:
		s[x, y] += 1
	else:
		s[x, y] = 1
for i in a:
	if not i[0] in xx:
		xx[i[0]] = 1
	else:
		xx[i[0]] += 1
	if not i[1] in yy:
		yy[i[1]] = 1
	else:
		yy[i[1]] += 1
ans = 0
for i in enumerate(xx):
	ans += xx[i[1]] * (xx[i[1]] - 1) // 2
for i in enumerate(yy):
	ans += yy[i[1]] * (yy[i[1]] - 1) // 2
m = 0
for i in s:
	m += s[i] * (s[i] - 1) // 2
print(ans - m)


import collections, itertools, functools, math

def solve():
	n = int(input())
	p = [tuple(map(int, input().split())) for _ in range(n)]
	cnt = collections.Counter((x for (x, _) in p))
	cnt2 = collections.Counter((y for (_, y) in p))
	cntp = collections.Counter(p)
	r = 0
	for (k, v) in cnt.most_common() + cnt2.most_common():
		r += v * (v - 1)
	for (k, v) in cntp.most_common():
		r -= v * (v - 1)
	return r // 2

def __starting_point():
	print(solve())
__starting_point()


n = int(input())
d = {}
d2 = {}
d3 = {}
ans = 0
for i in range(n):
	(x, y) = map(int, input().split())
	if (x, y) not in d:
		d[x, y] = 0
	d[x, y] += 1
	if x not in d2:
		d2[x] = 0
	d2[x] += 1
	if y not in d3:
		d3[y] = 0
	d3[y] += 1
for i in d2:
	ans += d2[i] * (d2[i] - 1) // 2
for i in d3:
	ans += d3[i] * (d3[i] - 1) // 2
for i in d:
	ans -= d[i] * (d[i] - 1) // 2
print(ans)


n = int(input())
l = []
xct = {}
yct = {}
pnct = {}
for i in range(n):
	l.append([int(x) for x in input().split()])
	try:
		xct[l[i][0]] += 1
	except KeyError:
		xct[l[i][0]] = 1
	try:
		yct[l[i][1]] += 1
	except KeyError:
		yct[l[i][1]] = 1
	try:
		pnct[l[i][0], l[i][1]] += 1
	except KeyError:
		pnct[l[i][0], l[i][1]] = 1
x = list(xct.values())
y = list(yct.values())
z = list(pnct.values())
ans = 0
for i in range(len(x)):
	ans = ans + x[i] * (x[i] - 1) / 2
for i in range(len(y)):
	ans = ans + y[i] * (y[i] - 1) / 2
for i in range(len(z)):
	ans = ans - z[i] * (z[i] - 1) / 2
print(int(ans))


from collections import Counter
c = Counter
(cx, cy, cp) = (c(), c(), c())
cnt = 0
n = int(input())
for i in range(n):
	(x, y) = map(int, input().split())
	cnt += cx[x] + cy[y] - cp[x, y]
	cx[x] += 1
	cy[y] += 1
	cp[x, y] += 1
print(cnt)


def inc_val_of_dict(dictionary, key):
	if key not in dictionary:
		dictionary[key] = 0
	dictionary[key] += 1

def main():
	n = int(input())
	p_ctr = dict()
	x_ctr = dict()
	y_ctr = dict()
	for _ in range(n):
		(x, y) = map(int, input().split())
		inc_val_of_dict(p_ctr, (x, y))
		inc_val_of_dict(x_ctr, x)
		inc_val_of_dict(y_ctr, y)
	answer = 0
	for ((x, y), num) in p_ctr.items():
		answer += num * (x_ctr[x] + y_ctr[y] - p_ctr[x, y] - 1)
	answer //= 2
	print(answer)
main()


from collections import defaultdict
n = int(input())
X = defaultdict(lambda : 0)
Y = defaultdict(lambda : 0)
XY = defaultdict(lambda : 0)
for _ in range(n):
	(x, y) = map(int, input().split())
	X[x] += 1
	Y[y] += 1
	XY[x, y] += 1
cnt = 0
for x in X.keys():
	k = X[x]
	cnt += k * (k - 1) // 2
for y in Y.keys():
	k = Y[y]
	cnt += k * (k - 1) // 2
for (x, y) in XY.keys():
	k = XY[x, y]
	cnt -= k * (k - 1) // 2
print(cnt)


from collections import defaultdict, Counter

def main():
	n = int(input())
	dx = defaultdict(list)
	dy = defaultdict(list)
	already_seen = Counter()
	dups = 0
	for _ in range(n):
		(x, y) = map(int, input().split())
		already_seen[x, y] += 1
		dx[x].append(y)
		dy[y].append(x)
	ans = 0
	for (k, v) in dx.items():
		ans += len(v) * (len(v) - 1) // 2
	for (k, v) in dy.items():
		ans += len(v) * (len(v) - 1) // 2
	for (k, v) in already_seen.items():
		ans -= v * (v - 1) // 2
	print(ans)
main()


from collections import Counter
c = Counter
x = c()
y = c()
xy = c()
ans = 0
for _ in range(int(input())):
	(a, b) = map(int, input().split())
	ans += x[a] + y[b] - xy[a, b]
	x[a] += 1
	y[b] += 1
	xy[a, b] += 1
print(ans)


from collections import defaultdict
(X, Y, P, k) = (defaultdict(int), defaultdict(int), defaultdict(int), 0)
for _ in range(int(input())):
	(x, y) = input().split()
	k += X[x] + Y[y] - P[x, y]
	(X[x], Y[y], P[x, y]) = (X[x] + 1, Y[y] + 1, P[x, y] + 1)
print(k)


__author__ = 'aste'

def main():
	n = int(input())
	xy = []
	for i in range(0, n):
		(x, y) = map(int, input().split())
		xy.append((x, y))
	xy.sort()
	res = 0
	c = 1
	for (i, (x, _)) in enumerate(xy):
		if i == 0:
			continue
		if xy[i - 1][0] == x:
			c += 1
		else:
			res += c * (c - 1) // 2
			c = 1
	res += c * (c - 1) // 2
	c = 1
	for (i, (x, y)) in enumerate(xy):
		if i == 0:
			continue
		if xy[i - 1][0] == x and xy[i - 1][1] == y:
			c += 1
		else:
			res -= c * (c - 1) // 2
			c = 1
	res -= c * (c - 1) // 2
	xy.sort(key=lambda t: t[1])
	c = 1
	for (i, (_, y)) in enumerate(xy):
		if i == 0:
			continue
		if xy[i - 1][1] == y:
			c += 1
		else:
			res += c * (c - 1) // 2
			c = 1
	res += c * (c - 1) // 2
	print(res)
main()


n = int(input())
pairs = {}
q_x = {}
q_y = {}
for i in range(n):
	(a, b) = map(int, input().split())
	if pairs.get((a, b)):
		pairs[a, b] += 1
	else:
		pairs[a, b] = 1
	if q_x.get(a):
		q_x[a] += 1
	else:
		q_x[a] = 1
	if q_y.get(b):
		q_y[b] += 1
	else:
		q_y[b] = 1
k = 0
for i in q_x.keys():
	k += q_x[i] * (q_x[i] - 1) // 2
for i in q_y.keys():
	k += q_y[i] * (q_y[i] - 1) // 2
for i in pairs.keys():
	k -= pairs[i] * (pairs[i] - 1) // 2
print(k)


n = int(input())
x2 = {}
y2 = {}
watchMen = {}
for i in range(n):
	watchman = tuple(map(int, input().split()))
	watchMen[watchman] = watchMen.get(watchman, 0) + 1
	x2[watchman[0]] = x2.get(watchman[0], 0) + 1
	y2[watchman[1]] = y2.get(watchman[1], 0) + 1
pairs = 0
for i in watchMen.items():
	pairs -= i[1] * (i[1] - 1) // 2
for i in x2.items():
	pairs += i[1] * (i[1] - 1) // 2
for i in y2.items():
	pairs += i[1] * (i[1] - 1) // 2
print(pairs)


import sys
input = sys.stdin.readline
n = int(input())
N = 0
(x, y) = ({}, {})
pp = {}
for i in range(n):
	(xi, yi) = map(int, input().split())
	if xi not in x:
		x[xi] = []
	x[xi].append(yi)
	if yi not in y:
		y[yi] = []
	y[yi].append(xi)
	p = (xi, yi)
	if p not in pp:
		pp[p] = 0
	pp[p] += 1
s = 0
for xi in x:
	l = len(x[xi])
	s += l * (l - 1) // 2
for yi in y:
	l = len(y[yi])
	s += l * (l - 1) // 2
l = 0
vals = list(pp.values())
for v in vals:
	l += v * (v - 1) // 2
s -= l
print(s)


from sys import stdin
input = stdin.readline
n = int(input())
(x, y, s, ans) = (dict(), dict(), dict(), 0)
for i in range(n):
	(a, b) = [int(i) for i in input().split()]
	s[a, b] = 1 if (a, b) not in s.keys() else s[a, b] + 1
	x[a] = 1 if a not in x.keys() else x[a] + 1
	y[b] = 1 if b not in y.keys() else y[b] + 1
for (k, v) in x.items():
	ans += v * (v - 1) // 2
for (k, v) in y.items():
	ans += v * (v - 1) // 2
for (k, v) in s.items():
	ans -= v * (v - 1) // 2
print(ans)


x = {}
y = {}
d = {}
ans = 0
for i in range(int(input())):
	(a, b) = map(int, input().split())
	if a in x:
		x[a] += 1
	else:
		x[a] = 1
	if b in y:
		y[b] += 1
	else:
		y[b] = 1
	if (a, b) in d:
		d[a, b] += 1
	else:
		d[a, b] = 1
x = list(x.values())
y = list(y.values())
d = list(d.values())
for i in x:
	ans += i * (i - 1) // 2
for i in y:
	ans += i * (i - 1) // 2
for i in d:
	ans -= i * (i - 1) // 2
print(ans)


import sys, os, io

def rs():
	return sys.stdin.readline().rstrip()

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

def ria():
	return list(map(int, sys.stdin.readline().split()))

def ws(s):
	sys.stdout.write(s + '\n')

def wi(n):
	sys.stdout.write(str(n) + '\n')

def wia(a):
	sys.stdout.write(' '.join([str(x) for x in a]) + '\n')
import math, datetime, functools, itertools, operator, bisect, fractions, statistics
from collections import deque, defaultdict, OrderedDict, Counter
from fractions import Fraction
from decimal import Decimal
from sys import stdout
from heapq import heappush, heappop, heapify, _heapify_max, _heappop_max, nsmallest, nlargest

def main():
	mod = 1000000007
	starttime = datetime.datetime.now()
	if os.path.exists('input.txt'):
		sys.stdin = open('input.txt', 'r')
		sys.stdout = open('output.txt', 'w')
	tc = 1
	for _ in range(tc):
		n = ri()
		(dx, dy, dxy) = ({}, {}, {})
		ans = 0
		for i in range(n):
			(x, y) = ria()
			if (x, y) in dxy:
				ans -= dxy[x, y]
				dxy[x, y] += 1
			else:
				dxy[x, y] = 1
			if x in dx:
				ans += dx[x]
				dx[x] += 1
			else:
				dx[x] = 1
			if y in dy:
				ans += dy[y]
				dy[y] += 1
			else:
				dy[y] = 1
		wi(ans)
	endtime = datetime.datetime.now()
	time = (endtime - starttime).total_seconds() * 1000
	if os.path.exists('input.txt'):
		print('Time:', time, 'ms')

class FastReader(io.IOBase):
	newlines = 0

	def __init__(self, fd, chunk_size=1024 * 8):
		self._fd = fd
		self._chunk_size = chunk_size
		self.buffer = io.BytesIO()

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, self._chunk_size))
			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, size=-1):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, self._chunk_size if size == -1 else size))
			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()

class FastWriter(io.IOBase):

	def __init__(self, fd):
		self._fd = fd
		self.buffer = io.BytesIO()
		self.write = self.buffer.write

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

class FastStdin(io.IOBase):

	def __init__(self, fd=0):
		self.buffer = FastReader(fd)
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

class FastStdout(io.IOBase):

	def __init__(self, fd=1):
		self.buffer = FastWriter(fd)
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.flush = self.buffer.flush
sys.stdin = FastStdin()
sys.stdout = FastStdout()
main()


from collections import Counter
(x, y, par, ans) = (Counter(), Counter(), Counter(), 0)
for i in range(int(input())):
	(xi, yi) = map(int, input().split())
	x[xi] += 1
	y[yi] += 1
	par[xi, yi] += 1
for elem in x:
	ans += x[elem] * (x[elem] - 1)
for elem in y:
	ans += y[elem] * (y[elem] - 1)
for elem in par:
	ans -= par[elem] * (par[elem] - 1)
print(ans // 2)


from collections import defaultdict
n = int(input())
ans = 0
x_points = defaultdict(int)
y_points = defaultdict(int)
x_y_points = defaultdict(int)
while n:
	n -= 1
	(x, y) = map(int, input().split())
	ans += x_points[x] + y_points[y] - x_y_points[x, y]
	x_points[x] += 1
	y_points[y] += 1
	x_y_points[x, y] += 1
print(ans)


n = int(input())
A = {}
B = {}
C = {}
for i in range(n):
	s = input().split()
	if s[0] not in A:
		A[s[0]] = 0
	A[s[0]] += 1
	if s[1] not in B:
		B[s[1]] = 0
	B[s[1]] += 1
	if s[0] not in C:
		C[s[0]] = {}
		C[s[0]][s[1]] = 1
	elif s[1] not in C[s[0]]:
		C[s[0]][s[1]] = 1
	else:
		C[s[0]][s[1]] += 1
k = 0
for i in A:
	l = A[i]
	k += l * (l - 1) // 2
for i in B:
	l = B[i]
	k += l * (l - 1) // 2
for i in C:
	for j in C[i]:
		l = C[i][j]
		k -= l * (l - 1) // 2
print(k)


t = int(input())
l = []
ans = 0
adic = dict()
bdict = dict()
abdict = dict()
for i in range(t):
	(a, b) = map(int, input().split())
	h = 0
	aac = 0
	bbc = 0
	abc = 0
	if a in adic:
		ans += adic[a]
		aac = 1
	if b in bdict:
		ans += bdict[b]
		bbc = 1
	if (a, b) in abdict:
		abc = 1
		ans -= abdict[a, b]
	if aac == 1:
		adic[a] += 1
	else:
		adic[a] = 1
	if bbc == 1:
		bdict[b] += 1
	else:
		bdict[b] = 1
	if abc == 1:
		abdict[a, b] += 1
	else:
		abdict[a, b] = 1
print(ans)


n = int(input())
k = 0
h = 0
d_x = {}
d_y = {}
d_x_y = {}
s_x = 0
s_y = 0
s_x_y = 0
for i in range(n):
	[x, y] = [int(x) for x in input().split()]
	if d_x.setdefault(x) == None:
		d_x[x] = 0
	else:
		d_x[x] += 1
		s_x += d_x[x]
	if d_y.setdefault(y) == None:
		d_y[y] = 0
	else:
		d_y[y] += 1
		s_y += d_y[y]
	if d_x_y.setdefault((x, y)) == None:
		d_x_y[x, y] = 0
	else:
		d_x_y[x, y] += 1
		s_x_y += d_x_y[x, y]
print(s_x + s_y - s_x_y)


def man(a, b):
	return abs(a[0] - b[0]) + abs(a[1] - b[1])

def euc(a, b):
	if a[0] == b[0]:
		return abs(a[1] - b[1])
	elif a[1] == b[1]:
		return abs(a[0] - b[0])
	else:
		return 0

def main():
	from sys import stdin, stdout
	import collections
	counter = collections.Counter()
	xcounter = collections.Counter()
	ycounter = collections.Counter()
	n = int(stdin.readline())
	for _ in range(n):
		(x, y) = map(int, stdin.readline().split())
		counter[x, y] += 1
		xcounter[x] += 1
		ycounter[y] += 1
	ans = 0
	for i in xcounter:
		ans += xcounter[i] * (xcounter[i] - 1) // 2
	for i in ycounter:
		ans += ycounter[i] * (ycounter[i] - 1) // 2
	for i in counter:
		ans -= counter[i] * (counter[i] - 1) // 2
	stdout.write(str(ans))
main()


from collections import Counter
n = int(input())
(a, b) = ([], [])
for i in range(n):
	(ai, bi) = [int(x) for x in input().split()]
	a.append(ai)
	b.append(bi)
sum = 0
for (k, v) in dict(Counter(a)).items():
	if v > 1:
		sum += v * (v - 1) // 2
for (k, v) in dict(Counter(b)).items():
	if v > 1:
		sum += v * (v - 1) // 2
r = [(x, y) for (x, y) in zip(a, b)]
for (k, v) in dict(Counter(r)).items():
	if v > 1:
		sum -= v * (v - 1) // 2
print(sum)


n = int(input())
d1 = {}
d2 = {}
same = {}
for i in range(n):
	(a, b) = map(int, input().split())
	if a in d1.keys():
		d1[a] += 1
	else:
		d1[a] = 1
	if b in d2.keys():
		d2[b] += 1
	else:
		d2[b] = 1
	if (a, b) in same.keys():
		same[a, b] += 1
	else:
		same[a, b] = 1
ans = 0
for i in d1.keys():
	if d1[i] > 1:
		ans += d1[i] * (d1[i] - 1) // 2
for i in d2.keys():
	if d2[i] > 1:
		ans += d2[i] * (d2[i] - 1) // 2
for i in same.keys():
	if same[i] > 1:
		ans -= same[i] * (same[i] - 1) // 2
print(ans)


import sys

def answer(n, x, y):
	xd = dict()
	yd = dict()
	xyd = dict()
	num_pairs = 0
	for i in range(n):
		if x[i] in xd:
			xd[x[i]] += 1
		else:
			xd[x[i]] = 1
		if y[i] in yd:
			yd[y[i]] += 1
		else:
			yd[y[i]] = 1
		if (x[i], y[i]) in xyd:
			xyd[x[i], y[i]] += 1
		else:
			xyd[x[i], y[i]] = 1
	for k in xd:
		num_pairs += xd[k] * (xd[k] - 1) // 2
	for k in yd:
		num_pairs += yd[k] * (yd[k] - 1) // 2
	for k in xyd:
		num_pairs -= xyd[k] * (xyd[k] - 1) // 2
	return num_pairs

def main():
	n = int(sys.stdin.readline())
	x = [0 for _ in range(n)]
	y = [0 for _ in range(n)]
	for i in range(n):
		(x[i], y[i]) = map(int, sys.stdin.readline().split())
	print(answer(n, x, y))
	return
main()


from collections import defaultdict
n = int(input())
(dic, dicx, dicy) = (defaultdict(int), defaultdict(int), defaultdict(int))
ans = 0
for _ in range(n):
	(x, y) = input().split()
	(x, y) = (int(x), int(y))
	ans += dicx[x] + dicy[y] - dic[x, y]
	dicx[x] += 1
	dicy[y] += 1
	dic[x, y] += 1
print(ans)


n = int(input())
a = []
for i in range(n):
	(x, y) = map(int, input().split())
	a.append([x, y])
(c, d) = (0, 0)
(p, q, r) = ({}, {}, {})
for i in range(n):
	c = a[i][0]
	d = a[i][1]
	if c in p:
		p[c] += 1
	else:
		p[c] = 1
	if d in q:
		q[d] += 1
	else:
		q[d] = 1
	if (c, d) in r:
		r[c, d] += 1
	else:
		r[c, d] = 1
count = 0
for i in p.values():
	count += i * (i - 1) // 2
for i in q.values():
	count += i * (i - 1) // 2
for i in r.values():
	count -= i * (i - 1) // 2
print(count)


from collections import defaultdict
import sys
n = int(input())
(R, C, V) = (defaultdict(int), defaultdict(int), defaultdict(int))
for line in sys.stdin:
	(x, y) = [int(x) for x in line.split()]
	V[x, y] += 1
	R[x] += 1
	C[y] += 1

def C_n_2(x):
	return x * (x - 1) // 2
print(sum((C_n_2(R[k]) for k in R)) + sum((C_n_2(C[k]) for k in C)) - sum((C_n_2(V[k]) for k in V)))


from collections import defaultdict

def Pair(arr, n):
	X = defaultdict(lambda : 0)
	Y = defaultdict(lambda : 0)
	XY = defaultdict(lambda : 0)
	for i in range(0, n):
		x = arr[i][0]
		y = arr[i][1]
		X[x] += 1
		Y[y] += 1
		XY[tuple(arr[i])] += 1
	(xAns, yAns, xyAns) = (0, 0, 0)
	for xPair in X:
		xFre = X[xPair]
		sameXPairs = xFre * (xFre - 1) // 2
		xAns += sameXPairs
	for yCoordinatePair in Y:
		yFrequency = Y[yCoordinatePair]
		sameYPairs = yFrequency * (yFrequency - 1) // 2
		yAns += sameYPairs
	for XYPair in XY:
		xyFrequency = XY[XYPair]
		samePointPairs = xyFrequency * (xyFrequency - 1) // 2
		xyAns += samePointPairs
	return xAns + yAns - xyAns
n = int(input())
arr = [[int(y) for y in input().split()] for i in range(n)]
print(Pair(arr, n))


n = int(input())
first = {}
second = {}
pairs = {}
for i in range(n):
	(f, s) = [int(x) for x in input().split()]
	p = (f, s)
	first[f] = first.get(f, 0) + 1
	second[s] = second.get(s, 0) + 1
	pairs[p] = pairs.get(p, 0) + 1
answer = 0
for f in first:
	value = first[f]
	if value > 1:
		answer += value * (value - 1) // 2
for s in second:
	value = second[s]
	if value > 1:
		answer += value * (value - 1) // 2
for p in pairs:
	value = pairs[p]
	if value > 1:
		answer -= value * (value - 1) // 2
print(answer)


dx = {}
dy = {}
dxy = {}
ans = 0
n = int(input())
for i in range(n):
	(x, y) = map(int, input().split())
	ans += dx.get(x, 0) + dy.get(y, 0) - dxy.get((x, y), 0)
	dx[x] = dx.get(x, 0) + 1
	dy[y] = dy.get(y, 0) + 1
	dxy[x, y] = dxy.get((x, y), 0) + 1
print(ans)


from collections import *
b = 0
ans = 0
cx = Counter()
cy = Counter()
cp = Counter()
n = int(input())
for i in range(n):
	(x, y) = map(int, input().split())
	ans += cx[x] + cy[y] - cp[x, y]
	cx[x] += 1
	cy[y] += 1
	cp[x, y] += 1
print(ans)


from math import factorial as fact

def C(n, k):
	res = fact(n) / (fact(n - k) * fact(k))
	return res
D = dict()
Dx = dict()
Dy = dict()
n = int(input())
H = []
for i in range(n):
	(x, y) = map(int, input().split())
	if (x, y) in D:
		D[x, y] += 1
	else:
		D[x, y] = 1
	H.append((x, y))
	if x not in Dx:
		Dx[x] = 1
	else:
		Dx[x] += 1
	if y not in Dy:
		Dy[y] = 1
	else:
		Dy[y] += 1
c = 0
for (k, v) in Dx.items():
	if v > 1:
		c += v * (v - 1) / 2
for (k, v) in Dy.items():
	if v > 1:
		c += v * (v - 1) / 2
for (k, v) in D.items():
	c -= v * (v - 1) / 2
print(int(c))


from collections import *
n = int(input())
xi = Counter()
yi = Counter()
pi = Counter()
for i in range(n):
	(x, y) = map(int, input().split())
	xi[x] += 1
	yi[y] += 1
	pi[x, y] += 1
ans = 0
for x in xi:
	ans += xi[x] * (xi[x] - 1) // 2
for y in yi:
	ans += yi[y] * (yi[y] - 1) // 2
for p in pi:
	ans -= pi[p] * (pi[p] - 1) // 2
print(ans)


def first_coord(x):
	return x[0]

def second_coord(x):
	return x[1]
n = int(input())
l = []
for i in range(n):
	l.append(list(map(int, input().split())))
answ = 0
y_alike = 1
l.sort(key=second_coord)
for i in range(n - 1):
	if l[i][1] == l[i + 1][1]:
		y_alike += 1
	else:
		answ += y_alike * (y_alike - 1) // 2
		y_alike = 1
answ += y_alike * (y_alike - 1) // 2
l.sort(key=first_coord)
x_alike = 1
alike = 1
for i in range(n - 1):
	if l[i][0] == l[i + 1][0]:
		x_alike += 1
	else:
		answ += x_alike * (x_alike - 1) // 2
		x_alike = 1
	if l[i][0] == l[i + 1][0] and l[i][1] == l[i + 1][1]:
		alike += 1
	else:
		answ -= alike * (alike - 1) // 2
		alike = 1
answ += x_alike * (x_alike - 1) // 2
answ -= alike * (alike - 1) // 2
print(answ)


n = int(input())
Dx = {}
Dy = {}
Vis = {}
T = 0
for _ in range(n):
	(x, y) = [int(x) for x in input().split()]
	if (x, y) in Vis:
		Vis[x, y] += 1
	else:
		Vis[x, y] = 1
	if x in Dx:
		Dx[x].append(y)
	else:
		Dx[x] = [y]
	if y in Dy:
		Dy[y].append(x)
	else:
		Dy[y] = [x]
T = 0
for i in Dx.values():
	T += len(i) * (len(i) - 1) // 2
for j in Dy.values():
	T += len(j) * (len(j) - 1) // 2
for i in Vis.values():
	T -= i * (i - 1) // 2
print(T)


jc = [0, 0, 1, 3, 6, 10, 15, 21, 28, 36, 45, 55, 66, 78, 91, 105, 120, 136, 153, 171, 190, 210, 231, 253, 276, 300, 325, 351, 378, 406, 435, 465, 496, 528, 561, 595, 630, 666, 703, 741, 780, 820, 861, 903, 946, 990, 1035, 1081, 1128, 1176, 1225, 1275, 1326, 1378, 1431, 1485, 1540, 1596, 1653, 1711, 1770, 1830, 1891, 1953, 2016, 2080, 2145, 2211, 2278, 2346, 2415, 2485, 2556, 2628, 2701, 2775, 2850, 2926, 3003, 3081, 3160, 3240, 3321, 3403, 3486, 3570, 3655, 3741, 3828, 3916, 4005, 4095, 4186, 4278, 4371, 4465, 4560, 4656, 4753, 4851, 4950, 5050, 5151, 5253, 5356, 5460, 5565, 5671, 5778, 5886, 5995, 6105, 6216, 6328, 6441, 6555, 6670, 6786, 6903, 7021, 7140, 7260, 7381, 7503, 7626, 7750, 7875, 8001, 8128, 8256, 8385, 8515, 8646, 8778, 8911, 9045, 9180, 9316, 9453, 9591, 9730, 9870, 10011, 10153, 10296, 10440, 10585, 10731, 10878, 11026, 11175, 11325, 11476, 11628, 11781, 11935, 12090, 12246, 12403, 12561, 12720, 12880, 13041, 13203, 13366, 13530, 13695, 13861, 14028, 14196, 14365, 14535, 14706, 14878, 15051, 15225, 15400, 15576, 15753, 15931, 16110, 16290, 16471, 16653, 16836, 17020, 17205, 17391, 17578, 17766, 17955, 18145, 18336, 18528, 18721, 18915, 19110, 19306, 19503, 19701, 19900, 20100, 20301, 20503, 20706, 20910, 21115, 21321, 21528, 21736, 21945, 22155, 22366, 22578, 22791, 23005, 23220, 23436, 23653, 23871, 24090, 24310, 24531, 24753, 24976, 25200, 25425, 25651, 25878, 26106, 26335, 26565, 26796, 27028, 27261, 27495, 27730, 27966, 28203, 28441, 28680, 28920, 29161, 29403, 29646, 29890, 30135, 30381, 30628, 30876, 31125, 31375, 31626, 31878, 32131, 32385, 32640, 32896, 33153, 33411, 33670, 33930, 34191, 34453, 34716, 34980, 35245, 35511, 35778, 36046, 36315, 36585, 36856, 37128, 37401, 37675, 37950, 38226, 38503, 38781, 39060, 39340, 39621, 39903, 40186, 40470, 40755, 41041, 41328, 41616, 41905, 42195, 42486, 42778, 43071, 43365, 43660, 43956, 44253, 44551, 44850, 45150, 45451, 45753, 46056, 46360, 46665, 46971, 47278, 47586, 47895, 48205, 48516, 48828, 49141, 49455, 49770, 50086, 50403, 50721, 51040, 51360, 51681, 52003, 52326, 52650, 52975, 53301, 53628, 53956, 54285, 54615, 54946, 55278, 55611, 55945, 56280, 56616, 56953, 57291, 57630, 57970, 58311, 58653, 58996, 59340, 59685, 60031, 60378, 60726, 61075, 61425, 61776, 62128, 62481, 62835, 63190, 63546, 63903, 64261, 64620, 64980, 65341, 65703, 66066, 66430, 66795, 67161, 67528, 67896, 68265, 68635, 69006, 69378, 69751, 70125, 70500, 70876, 71253, 71631, 72010, 72390, 72771, 73153, 73536, 73920, 74305, 74691, 75078, 75466, 75855, 76245, 76636, 77028, 77421, 77815, 78210, 78606, 79003, 79401, 79800, 80200, 80601, 81003, 81406, 81810, 82215, 82621, 83028, 83436, 83845, 84255, 84666, 85078, 85491, 85905, 86320, 86736, 87153, 87571, 87990, 88410, 88831, 89253, 89676, 90100, 90525, 90951, 91378, 91806, 92235, 92665, 93096, 93528, 93961, 94395, 94830, 95266, 95703, 96141, 96580, 97020, 97461, 97903, 98346, 98790, 99235, 99681, 100128, 100576, 101025, 101475, 101926, 102378, 102831, 103285, 103740, 104196, 104653, 105111, 105570, 106030, 106491, 106953, 107416, 107880, 108345, 108811, 109278, 109746, 110215, 110685, 111156, 111628, 112101, 112575, 113050, 113526, 114003, 114481, 114960, 115440, 115921, 116403, 116886, 117370, 117855, 118341, 118828, 119316, 119805, 120295, 120786, 121278, 121771, 122265, 122760, 123256, 123753, 124251, 124750, 125250, 125751, 126253, 126756, 127260, 127765, 128271, 128778, 129286, 129795, 130305, 130816, 131328, 131841, 132355, 132870, 133386, 133903, 134421, 134940, 135460, 135981, 136503, 137026, 137550, 138075, 138601, 139128, 139656, 140185, 140715, 141246, 141778, 142311, 142845, 143380, 143916, 144453, 144991, 145530, 146070, 146611, 147153, 147696, 148240, 148785, 149331, 149878, 150426, 150975, 151525, 152076, 152628, 153181, 153735, 154290, 154846, 155403, 155961, 156520, 157080, 157641, 158203, 158766, 159330, 159895, 160461, 161028, 161596, 162165, 162735, 163306, 163878, 164451, 165025, 165600, 166176, 166753, 167331, 167910, 168490, 169071, 169653, 170236, 170820, 171405, 171991, 172578, 173166, 173755, 174345, 174936, 175528, 176121, 176715, 177310, 177906, 178503, 179101, 179700, 180300, 180901, 181503, 182106, 182710, 183315, 183921, 184528, 185136, 185745, 186355, 186966, 187578, 188191, 188805, 189420, 190036, 190653, 191271, 191890, 192510, 193131, 193753, 194376, 195000, 195625, 196251, 196878, 197506, 198135, 198765, 199396, 200028, 200661, 201295, 201930, 202566, 203203, 203841, 204480, 205120, 205761, 206403, 207046, 207690, 208335, 208981, 209628, 210276, 210925, 211575, 212226, 212878, 213531, 214185, 214840, 215496, 216153, 216811, 217470, 218130, 218791, 219453, 220116, 220780, 221445, 222111, 222778, 223446, 224115, 224785, 225456, 226128, 226801, 227475, 228150, 228826, 229503, 230181, 230860, 231540, 232221, 232903, 233586, 234270, 234955, 235641, 236328, 237016, 237705, 238395, 239086, 239778, 240471, 241165, 241860, 242556, 243253, 243951, 244650, 245350, 246051, 246753, 247456, 248160, 248865, 249571, 250278, 250986, 251695, 252405, 253116, 253828, 254541, 255255, 255970, 256686, 257403, 258121, 258840, 259560, 260281, 261003, 261726, 262450, 263175, 263901, 264628, 265356, 266085, 266815, 267546, 268278, 269011, 269745, 270480, 271216, 271953, 272691, 273430, 274170, 274911, 275653, 276396, 277140, 277885, 278631, 279378, 280126, 280875, 281625, 282376, 283128, 283881, 284635, 285390, 286146, 286903, 287661, 288420, 289180, 289941, 290703, 291466, 292230, 292995, 293761, 294528, 295296, 296065, 296835, 297606, 298378, 299151, 299925, 300700, 301476, 302253, 303031, 303810, 304590, 305371, 306153, 306936, 307720, 308505, 309291, 310078, 310866, 311655, 312445, 313236, 314028, 314821, 315615, 316410, 317206, 318003, 318801, 319600, 320400, 321201, 322003, 322806, 323610, 324415, 325221, 326028, 326836, 327645, 328455, 329266, 330078, 330891, 331705, 332520, 333336, 334153, 334971, 335790, 336610, 337431, 338253, 339076, 339900, 340725, 341551, 342378, 343206, 344035, 344865, 345696, 346528, 347361, 348195, 349030, 349866, 350703, 351541, 352380, 353220, 354061, 354903, 355746, 356590, 357435, 358281, 359128, 359976, 360825, 361675, 362526, 363378, 364231, 365085, 365940, 366796, 367653, 368511, 369370, 370230, 371091, 371953, 372816, 373680, 374545, 375411, 376278, 377146, 378015, 378885, 379756, 380628, 381501, 382375, 383250, 384126, 385003, 385881, 386760, 387640, 388521, 389403, 390286, 391170, 392055, 392941, 393828, 394716, 395605, 396495, 397386, 398278, 399171, 400065, 400960, 401856, 402753, 403651, 404550, 405450, 406351, 407253, 408156, 409060, 409965, 410871, 411778, 412686, 413595, 414505, 415416, 416328, 417241, 418155, 419070, 419986, 420903, 421821, 422740, 423660, 424581, 425503, 426426, 427350, 428275, 429201, 430128, 431056, 431985, 432915, 433846, 434778, 435711, 436645, 437580, 438516, 439453, 440391, 441330, 442270, 443211, 444153, 445096, 446040, 446985, 447931, 448878, 449826, 450775, 451725, 452676, 453628, 454581, 455535, 456490, 457446, 458403, 459361, 460320, 461280, 462241, 463203, 464166, 465130, 466095, 467061, 468028, 468996, 469965, 470935, 471906, 472878, 473851, 474825, 475800, 476776, 477753, 478731, 479710, 480690, 481671, 482653, 483636, 484620, 485605, 486591, 487578, 488566, 489555, 490545, 491536, 492528, 493521, 494515, 495510, 496506, 497503, 498501, 499500]

def ajc(l):
	l += 1
	global jc
	while len(jc) < l:
		jc.append(len(jc) * (len(jc) - 1) // 2)
A = {}
B = {}
C = {}
t = int(input())
if t == 1:
	print(0)
else:
	for ti in range(t):
		(a, b) = (int(i) for i in input().split(' '))
		if (a, b) not in C:
			C[a, b] = 1
		else:
			C[a, b] += 1
		if a not in A:
			A[a] = 1
		else:
			A[a] += 1
		if b not in B:
			B[b] = 1
		else:
			B[b] += 1
	ans = 0
	for (k, v) in A.items():
		ajc(v)
		ans += jc[v]
	for (k, v) in B.items():
		ajc(v)
		ans += jc[v]
	for (k, v) in C.items():
		ajc(v)
		ans -= jc[v]
	print(ans)


def dist(l):
	x = {}
	y = {}
	xy = {}
	for j in l:
		m = j.split()
		if m[0] in x:
			x[m[0]] += 1
		else:
			x[m[0]] = 1
		if m[1] in y:
			y[m[1]] += 1
		else:
			y[m[1]] = 1
		if j in xy:
			xy[j] += 1
		else:
			xy[j] = 1
	total = 0
	for key in x:
		total += x[key] * (x[key] - 1) // 2
	for key in y:
		total += y[key] * (y[key] - 1) // 2
	for key in xy:
		total -= xy[key] * (xy[key] - 1) // 2
	print(total)
a = int(input())
l = []
for i in range(0, a):
	x = input()
	l.append(x)
dist(l)


n = int(input())
a = []
b = {}
c = {}
for i in range(n):
	(x, y) = [int(d) for d in input().split()]
	b[y] = 0
	a.append((x, y))
a.sort()
b[a[0][1]] = 1
c[a[0][1]] = 1
summa = 0
count = 1
for i in range(1, n):
	if a[i][0] == a[i - 1][0]:
		summa += count
		count += 1
	else:
		count = 1
		c = {}
	b[a[i][1]] += 1
	if a[i][1] not in c:
		c[a[i][1]] = 0
	c[a[i][1]] += 1
	summa = summa + b[a[i][1]] - c[a[i][1]]
print(summa)


from sys import stdin, stdout
nmbr = lambda : int(stdin.readline())
lst = lambda : list(map(int, stdin.readline().split()))
for _ in range(1):
	n = nmbr()
	x = {}
	y = {}
	mp = {}
	for i in range(n):
		(a, b) = lst()
		x[a] = x.get(a, 0) + 1
		y[b] = y.get(b, 0) + 1
		mp[a, b] = mp.get((a, b), 0) + 1
	ans = sum((v * (v - 1) // 2 for (k, v) in x.items()))
	ans += sum((v * (v - 1) // 2 for (k, v) in y.items()))
	for (k, v) in mp.items():
		ans -= v * (v - 1) // 2
	print(ans)


from math import *
t = 1
for _ in range(t):
	n = int(input())
	pts = list()
	for i in range(n):
		pts.append(list(map(int, input().split())))
	axx = dict()
	ayy = dict()
	visited = dict()
	ans = 0
	for i in pts:
		x = i[0]
		y = i[1]
		visit = visited.get((x, y), -1)
		if visit == -1:
			visited[x, y] = 1
		else:
			visited[x, y] += 1
		ax = axx.get(x, None)
		ay = ayy.get(y, None)
		if ax == None:
			axx[x] = 1
		else:
			axx[x] = axx[x] + 1
		if ay == None:
			ayy[y] = 1
		else:
			ayy[y] = ayy[y] + 1
	for i in axx.values():
		if i >= 2:
			ans = ans + i * (i - 1) // 2
	for i in ayy.values():
		if i >= 2:
			ans = ans + i * (i - 1) // 2
	for i in visited.values():
		if i >= 2:
			ans = ans - i * (i - 1) // 2
	print(ans)


row = {}
col = {}
pos = {}
C = lambda n: n * (n - 1) // 2
for i in range(int(input())):
	(x, y) = (int(v) for v in input().strip().split())
	row[y] = row.setdefault(y, 0) + 1
	col[x] = col.setdefault(x, 0) + 1
	pos[x, y] = pos.setdefault((x, y), 0) + 1
ways = sum((C(row[y]) for y in row)) + sum((C(col[x]) for x in col)) - sum((C(pos[x, y]) for (x, y) in pos))
print(ways)


n = int(input())
x = []
a = []
for i in range(0, n):
	x = list(map(int, input().split()))
	a.append(x)
c = 0
l = {}
r = {}
m = {}
for i in range(0, n):
	s = str(a[i][0]) + str(a[i][1])
	if s in m:
		m[s] += 1
	else:
		m[s] = 1
	if a[i][0] in l:
		l[a[i][0]] += 1
	else:
		l[a[i][0]] = 1
	if a[i][1] in r:
		r[a[i][1]] += 1
	else:
		r[a[i][1]] = 1
ls = 0
rs = 0
ms = 0
for i in l:
	t = int(l[i] * (l[i] - 1) / 2)
	ls += t
for i in r:
	t = int(r[i] * (r[i] - 1) / 2)
	rs += t
for i in m:
	t = int(m[i] * (m[i] - 1) / 2)
	ms += t
ans = ls + rs - ms
print(ans)


q = {}
w = {}
e = {}
r = 0
for _ in range(int(input())):
	(x, y) = map(int, input().split())
	(a, s, d) = (q.get(x, 0), w.get(y, 0), e.get((x, y), 0))
	r += a + s - d
	(q[x], w[y], e[x, y]) = (a + 1, s + 1, d + 1)
print(r)


readints = lambda : map(int, input().strip('\n').split())

def nc2(n):
	return n * (n - 1) / 2
n = int(input())
pts = []
freq = {}
byx = {}
byy = {}
for _ in range(n):
	(x, y) = readints()
	pts.append((x, y))
	if (x, y) not in freq:
		freq[x, y] = 0
	freq[x, y] += 1
	if x not in byx:
		byx[x] = 0
	if y not in byy:
		byy[y] = 0
	byx[x] += 1
	byy[y] += 1
ans = 0
for x in byx:
	ans += nc2(byx[x])
for y in byy:
	ans += nc2(byy[y])
for pt in freq:
	ans -= nc2(freq[pt])
print(int(ans))


import math

def nCr(n, r):
	if n < r:
		return 0
	return math.factorial(n) // (math.factorial(r) * math.factorial(n - r))
n = int(input())
dict_x = {}
dict_y = {}
dict_x_y = {}
for i in range(n):
	(x, y) = map(int, input().split())
	dict_x[x] = dict_x.get(x, 0) + 1
	dict_y[y] = dict_y.get(y, 0) + 1
	dict_x_y[x, y] = dict_x_y.get((x, y), 0) + 1
val = 0
for key in dict_x.keys():
	val += dict_x[key] * (dict_x[key] - 1) // 2
for key in dict_y.keys():
	val += dict_y[key] * (dict_y[key] - 1) // 2
for key in dict_x_y.keys():
	val -= dict_x_y[key] * (dict_x_y[key] - 1) // 2
print(val)


n = int(input())
from collections import defaultdict
f = defaultdict(lambda : 0)
r = defaultdict(lambda : 0)
d = defaultdict(lambda : 0)
for i in range(n):
	(x, y) = map(int, input().split())
	f[x] += 1
	r[y] += 1
	d[x, y] += 1
an = 0
for i in f.keys():
	an += f[i] * (f[i] - 1) // 2
for i in r.keys():
	an += r[i] * (r[i] - 1) // 2
for (x, y) in d.keys():
	if d[x, y] > 1:
		an -= d[x, y] * (d[x, y] - 1) // 2
print(an)


n = int(input())
a = {}
b = {}
c = {}
k = 0
for i in range(n):
	(x, y) = map(int, input().split())
	n = a.get(x, 0)
	v = b.get(y, 0)
	z = c.get((x, y), 0)
	k = k + n + v - z
	a[x] = n + 1
	b[y] = v + 1
	c[x, y] = z + 1
print(k)


n = int(input())
x = []
y = []
res = 0
for i in range(n):
	(m, k) = (int(z) for z in input().split())
	x += [[m, k]]
	y += [[k, m]]
x.sort()
y.sort()
cur1 = x[0][0]
cur2 = x[0][1]
count1 = 1
count2 = 1
sum1 = 0
sum2 = 0
i = 1
while i < n:
	e = x[i][0]
	f = x[i][1]
	if e == cur1:
		count1 += 1
		if f == cur2:
			count2 += 1
		else:
			cur2 = f
			sum2 += count2 * (count2 - 1) // 2
			count2 = 1
	else:
		cur1 = e
		cur2 = f
		sum1 += count1 * (count1 - 1) // 2
		count1 = 1
		sum2 += count2 * (count2 - 1) // 2
		count2 = 1
	i += 1
i = 1
sum1 += count1 * (count1 - 1) // 2
sum2 += count2 * (count2 - 1) // 2
count = 1
sum3 = 0
cur1 = y[0][0]
while i < n:
	e = y[i][0]
	if e == cur1:
		count += 1
	else:
		cur1 = e
		sum3 += count * (count - 1) // 2
		count = 1
	i += 1
sum3 += count * (count - 1) // 2
print(sum1 - sum2 + sum3)


num = int(input())
num_same = 0
same_x = {}
same_y = {}
same = {}
for _ in range(num):
	str_pos = input().split(' ')
	pos = (int(str_pos[0]), int(str_pos[1]))
	if pos[0] in same_x:
		num_same += same_x[pos[0]]
		same_x[pos[0]] += 1
	else:
		same_x[pos[0]] = 1
	if pos[1] in same_y:
		num_same += same_y[pos[1]]
		same_y[pos[1]] += 1
	else:
		same_y[pos[1]] = 1
	if pos in same:
		num_same -= same[pos]
		same[pos] += 1
	else:
		same[pos] = 1
print(num_same)


n = int(input().strip())
(x, y) = ({}, {})
total = 0
points = {}
for i in range(n):
	(xi, yi) = map(int, input().strip().split())
	if (xi, yi) in points:
		points[xi, yi] += 1
	else:
		points[xi, yi] = 1
	if xi not in x.keys():
		x[xi] = 1
	else:
		x[xi] += 1
	if yi not in y.keys():
		y[yi] = 1
	else:
		y[yi] += 1
for xi in x:
	fx = x[xi]
	total += fx * (fx - 1) // 2
for yi in y:
	fy = y[yi]
	total += fy * (fy - 1) // 2
for point in points:
	fp = points[point]
	total -= fp * (fp - 1) // 2
print(total)


from sys import stdin
from collections import Counter
c = Counter
x = c()
y = c()
xy = c()
ans = 0
for _ in range(int(input())):
	(a, b) = map(int, stdin.readline().rstrip().split(' '))
	ans += x[a] + y[b] - xy[a, b]
	x[a] += 1
	y[b] += 1
	xy[a, b] += 1
print(ans)


import operator as op
from functools import reduce

def ncr(n, r):
	r = min(r, n - r)
	numer = reduce(op.mul, range(n, n - r, -1), 1)
	denom = reduce(op.mul, range(1, r + 1), 1)
	return numer / denom
n = int(input())
x_map = {}
y_map = {}
pos_map = {}
for i in range(n):
	(x, y) = map(int, input().split())
	if x in x_map:
		x_map[x] += 1
	else:
		x_map[x] = 1
	if y in y_map:
		y_map[y] += 1
	else:
		y_map[y] = 1
	if (x, y) in pos_map:
		pos_map[x, y] += 1
	else:
		pos_map[x, y] = 1
pair = 0
for k in x_map:
	if x_map[k] > 1:
		pair += ncr(x_map[k], 2)
for k in y_map:
	if y_map[k] > 1:
		pair += ncr(y_map[k], 2)
for k in pos_map:
	if pos_map[k] > 1:
		pair -= ncr(pos_map[k], 2)
print(int(pair))


def main():
	n = int(input())
	L = [None] * n
	for i in range(n):
		(x, y) = (int(x) for x in input().split())
		L[i] = (x, y)
	print(solver(L))

def solver(L):
	xDict = dict()
	yDict = dict()
	xyDict = dict()
	for (x, y) in L:
		if (x, y) in xyDict:
			xyDict[x, y] += 1
		else:
			xyDict[x, y] = 1
	repeats = 0
	for xy in xyDict:
		n = xyDict[xy]
		repeats += n * (n - 1) // 2
	for (x, y) in L:
		if x in xDict:
			xDict[x].append(y)
		else:
			xDict[x] = [y]
		if y in yDict:
			yDict[y].append(x)
		else:
			yDict[y] = [x]
	xSames = 0
	for x in xDict:
		n = len(xDict[x])
		xSames += n * (n - 1) // 2
	ySames = 0
	for y in yDict:
		n = len(yDict[y])
		ySames += n * (n - 1) // 2
	total = xSames + ySames - repeats
	return total

def almostEqual(x, y):
	return abs(x - y) < 10 ** (-8)

def distance(x1, y1, x2, y2):
	leg1 = abs(x1 - x2)
	leg2 = abs(y1 - y2)
	return (leg1 ** 2 + leg2 ** 2) ** 0.5
L = [(1, 1), (7, 5), (1, 5)]
L2 = [(0, 0), (0, 1), (0, 2), (-1, 1), (0, 1), (1, 1)]
L3 = [(0, 0), (0, 0), (0, 0)]
main()


from collections import defaultdict
n = int(input())
x = defaultdict(int)
y = defaultdict(int)
xy = defaultdict(int)
c = 0
for i in range(n):
	(xi, yi) = map(int, input().split())
	c += x[xi] + y[yi] - xy[xi, yi]
	x[xi] += 1
	y[yi] += 1
	xy[xi, yi] += 1
print(c)


n = int(input())
from collections import defaultdict
p = defaultdict(int)
q = defaultdict(int)
s = defaultdict(int)
ans = 0
for _ in range(n):
	(x, y) = map(int, input().split())
	ans += p.get(x, 0) + q.get(y, 0) - s.get((x, y), 0)
	p[x] += 1
	q[y] += 1
	s[x, y] += 1
print(ans)


import math, sys
from collections import Counter, defaultdict, deque
from sys import stdin, stdout
input = stdin.readline
lili = lambda : list(map(int, sys.stdin.readlines()))
li = lambda : list(map(int, input().split()))
I = lambda : int(input())
S = lambda : input().strip()
n = I()
a = []
b = []
for i in range(0, n):
	k = li()
	a.append(k)
	b.append(k[::-1])
a.sort()
b.sort()
temp = a[0][0]
c = 1
s = 0
for i in range(1, n):
	if a[i][0] == temp:
		c += 1
	else:
		s = s + c * (c - 1) // 2
		c = 1
		temp = a[i][0]
s = s + c * (c - 1) // 2
c = 1
temp = b[0][0]
for i in range(1, n):
	if b[i][0] == temp:
		c += 1
	else:
		s = s + c * (c - 1) // 2
		c = 1
		temp = b[i][0]
s = s + c * (c - 1) // 2
temp = a[0][0]
temp1 = a[0][1]
c = 1
d = 0
for i in range(1, n):
	if a[i][0] == temp and a[i][1] == temp1:
		c += 1
	else:
		d = d + c * (c - 1) // 2
		temp = a[i][0]
		temp1 = a[i][1]
		c = 1
d = d + c * (c - 1) // 2
print(s - d)


from collections import defaultdict as dc
x = int(input())
dx = dc(lambda : 0)
dy = dc(lambda : 0)
dxy = dc(lambda : 0)
for n in range(x):
	(a, b) = map(int, input().split())
	dx[a] += 1
	dy[b] += 1
	dxy[a, b] += 1
res = 0
for n in dx:
	res += int(dx[n] != 1) * (dx[n] * (dx[n] - 1) // 2)
for n in dy:
	res += int(dy[n] != 1) * (dy[n] * (dy[n] - 1) // 2)
for n in dxy:
	res -= int(dxy[n] != 1) * (dxy[n] * (dxy[n] - 1) // 2)
print(res)


from collections import Counter
n = int(input())
points = Counter([tuple(map(int, input().split(' '))) for i in range(n)])
(x, y) = (Counter([k for (k, v) in points.elements()]), Counter([v for (k, v) in points.elements()]))
ans = sum([v * (v - 1) // 2 for (k, v) in x.items()]) + sum([v * (v - 1) // 2 for (k, v) in y.items()]) - sum([v * (v - 1) // 2 for (k, v) in points.items()])
print(ans)


import math, sys
from collections import defaultdict, deque
import bisect as bi

def yes():
	print('YES')

def no():
	print('NO')

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

def In():
	return map(int, sys.stdin.readline().split())

def Sn():
	return sys.stdin.readline().strip()

def dict(a):
	d = {}
	for x in a:
		if d.get(x, -1) != -1:
			d[x] += 1
		else:
			d[x] = 1
	return d

def find_gt(a, x):
	i = bi.bisect_left(a, x)
	if i != len(a):
		return i
	else:
		return -1

def main():
	try:
		n = I()
		X = {}
		Y = {}
		d = {}
		cnt = 0
		for i in range(n):
			(x, y) = In()
			if X.get(x, -1) != -1:
				X[x] += 1
			else:
				X[x] = 1
			if Y.get(y, -1) != -1:
				Y[y] += 1
			else:
				Y[y] = 1
			if d.get((x, y), -1) != -1:
				d[x, y] += 1
			else:
				d[x, y] = 1
		ans = 0
		for x in X:
			ans += X[x] * (X[x] - 1) // 2
		for x in Y:
			ans += Y[x] * (Y[x] - 1) // 2
		for x in d:
			ans -= d[x] * (d[x] - 1) // 2
		print(ans)
	except:
		pass
M = 998244353
P = 1000000007
for _ in range(1):
	main()


from sys import stdin, stdout

class SOLVE:

	def solve(self):
		R = stdin.readline
		W = stdout.write
		(xfreq, yfreq, xyfreq) = ({}, {}, {})
		for i in range(int(R())):
			(p, q) = [x for x in R().split()]
			s = ('' if p[0] == '-' else '+') + p + ('' if q[0] == '-' else '+') + q
			if xyfreq.get(s):
				xyfreq[s] += 1
			else:
				xyfreq[s] = 1
			if xfreq.get(p):
				xfreq[p] += 1
			else:
				xfreq[p] = 1
			if yfreq.get(q):
				yfreq[q] += 1
			else:
				yfreq[q] = 1
		pairs = 0
		for s in xfreq:
			pairs += xfreq[s] * (xfreq[s] - 1) // 2
		for s in yfreq:
			pairs += yfreq[s] * (yfreq[s] - 1) // 2
		for s in xyfreq:
			pairs -= xyfreq[s] * (xyfreq[s] - 1) // 2
		W('%d\n' % pairs)
		return 0

def main():
	s = SOLVE()
	s.solve()
main()


n = int(input())
dx = {}
dy = {}
dp = {}
p = 0
for i in range(n):
	[x, y] = list(map(int, input().split()))
	if x in dx:
		dx[x] += 1
	else:
		dx[x] = 1
	if y in dy:
		dy[y] += 1
	else:
		dy[y] = 1
	if (x, y) in dp:
		dp[x, y] += 1
	else:
		dp[x, y] = 1
for x in dx:
	p += dx[x] * (dx[x] - 1) // 2
for y in dy:
	p += dy[y] * (dy[y] - 1) // 2
for z in dp:
	p -= dp[z] * (dp[z] - 1) // 2
print(p)


n = int(input())
coords_x = {}
coords_y = {}
dots = []
tmp = 0

def dictappender_x(a):
	try:
		coords_x[a] += 1
	except KeyError:
		coords_x[a] = 1

def dictappender_y(a):
	try:
		coords_y[a] += 1
	except KeyError:
		coords_y[a] = 1
for i in range(n):
	(a, b) = list(map(int, input().split()))
	dots.append((a, b))
for i in range(len(dots)):
	dictappender_x(dots[i][0])
	dictappender_y(dots[i][1])
count = 0
for (key, value) in coords_x.items():
	count += value * (value - 1) // 2
for (key, value) in coords_y.items():
	count += value * (value - 1) // 2
coords = {}
for dot in dots:
	if dot in coords:
		coords[dot] += 1
	else:
		coords[dot] = 1
summ = 0
for (key, value) in coords.items():
	summ += value * (value - 1) // 2
print(count - summ)


a = {}
b = {}
c = {}
s = 0
n = int(input())
for i in range(n):
	(l, m) = map(int, input().split())
	if a.get(l) != None:
		s += a.get(l)
	if b.get(m) != None:
		s += b.get(m)
	if c.get((l, m)) != None:
		s -= c.get((l, m))
	(a[l], b[m]) = (a.get(l, 0) + 1, b.get(m, 0) + 1)
	c[l, m] = c.get((l, m), 0) + 1
print(s)


def main():
	from collections import Counter
	(cx, cy, cxy) = (Counter(), Counter(), Counter())
	for _ in range(int(input())):
		(x, y) = map(int, input().split())
		cx[x] += 1
		cy[y] += 1
		cxy[x, y] += 1
	print((sum((x * (x - 1) for x in cx.values())) + sum((x * (x - 1) for x in cy.values())) - sum((x * (x - 1) for x in cxy.values()))) // 2)
main()


points = []
row_count = int(input())
for _ in range(row_count):
	rawLine = input().split()
	points.append([int(rawLine[0]), int(rawLine[1])])
total = 0
for i in range(2):
	points.sort(key=lambda x: x[i])
	previous = 1
	for j in range(1, row_count + 1):
		if j != row_count and points[j][i] == points[j - 1][i]:
			previous += 1
		else:
			total += previous * (previous - 1) / 2
			previous = 1
points.sort(key=lambda x: (x[0], x[1]))
previous = 1
for j in range(1, row_count + 1):
	if j != row_count and points[j][0] == points[j - 1][0] and (points[j][1] == points[j - 1][1]):
		previous += 1
	else:
		total -= previous * (previous - 1) / 2
		previous = 1
print(int(total))


N = int(input())
dx = {}
dy = {}
d = {}
ans = 0
for i in range(N):
	(x, y) = map(int, input().split())
	ans += dx.get(x, 0)
	ans += dy.get(y, 0)
	ans -= d.get((x, y), 0)
	dx[x] = dx.get(x, 0) + 1
	dy[y] = dy.get(y, 0) + 1
	d[x, y] = d.get((x, y), 0) + 1
print(ans)


n = int(input())
P = []
Q = []
for i in range(n):
	point = [int(s) for s in input().split()]
	P.append([point[0], point[1]])
	Q.append([point[1], point[0]])
P.sort()
Q.sort()
index1 = 0
index2 = 0
result = 0
while index1 < n:
	c = 1
	same = 1
	while index1 < n - 1 and P[index1][0] == P[index1 + 1][0]:
		if P[index1][1] == P[index1 + 1][1]:
			same += 1
		else:
			result -= same * (same - 1) // 2
			same = 1
		index1 += 1
		c += 1
	result -= same * (same - 1) // 2
	index1 += 1
	result += c * (c - 1) // 2
while index2 < n:
	d = 1
	while index2 < n - 1 and Q[index2][0] == Q[index2 + 1][0]:
		index2 += 1
		d += 1
	index2 += 1
	result += d * (d - 1) // 2
print(result)


(x, y, same) = ({}, {}, {})
points = set()
n = int(input())
for i in range(n):
	(a, b) = map(int, input().split())
	try:
		x[a] += 1
	except KeyError:
		x[a] = 1
	try:
		y[b] += 1
	except KeyError:
		y[b] = 1
	if tuple([a, b]) in points:
		try:
			same[tuple([a, b])] += 1
		except KeyError:
			same[tuple([a, b])] = 2
	else:
		points.add(tuple([a, b]))
ans = 0
for i in x:
	ans += x[i] * (x[i] - 1) // 2
for i in y:
	ans += y[i] * (y[i] - 1) // 2
for i in same:
	ans -= same[i] * (same[i] - 1) // 2
print(ans)


n = int(input())
cord_x = set()
cord_y = set()
matches_x = dict()
matches_y = dict()
ans = 0
cords = dict()
minus = 0
for i in range(n):
	(x, y) = map(int, input().split())
	if (x, y) in cords.keys():
		minus += cords[x, y]
		cords[x, y] += 1
	else:
		cords[x, y] = 1
	if x in cord_x:
		ans += matches_x[x]
		matches_x[x] += 1
	else:
		cord_x.add(x)
		matches_x[x] = 1
	if y in cord_y:
		ans += matches_y[y]
		matches_y[y] += 1
	else:
		cord_y.add(y)
		matches_y[y] = 1
print(ans - minus)


from math import *
from sys import stdin
input = stdin.readline
li1 = {}
li2 = {}
li3 = {}
for _ in range(int(input())):
	(x, y) = map(int, input().split())
	li1[x] = li1.get(x, 0) + 1
	li2[y] = li2.get(y, 0) + 1
	li3[x, y] = li3.get((x, y), 0) + 1
sum = 0
for x in [*li1.values()] + [*li2.values()]:
	sum += x * (x - 1) // 2
for x in [*li3.values()]:
	sum -= x * (x - 1) // 2
print(sum)


n = int(input())

def inx(x, d):
	if x in d:
		d[x] += 1
	else:
		d[x] = 1
	return d

def input2(n):
	dx = {}
	dy = {}
	dob = {}
	ans = 1
	for i in range(n):
		(x, y) = map(int, input().split())
		dx = inx(x, dx)
		dy = inx(y, dy)
		if (x, y) in dob:
			dob[x, y] += 1
		else:
			dob[x, y] = 1
	return (dx, dy, dob)
(dx, dy, dob) = input2(n)

def ans(d):
	ans1 = 0
	for i in d:
		ans1 += d[i] * (d[i] - 1) // 2
	return ans1
myans = ans(dx) + ans(dy) - ans(dob)
print(myans)


def f(List):
	n = len(List)
	List
	s = 0
	i = 0
	while i < n - 1:
		if List[i] != List[i + 1]:
			i += 1
		else:
			j = 1
			d = 1
			while i + j <= n - 2 and List[i + j] == List[i + j + 1]:
				d += 1
				j += 1
			else:
				s += d * (d + 1) // 2
				i += d + 1
	else:
		return s
n = int(input())
X = []
Y = []
XY = []
for i in range(n):
	xy = list(map(int, input().rstrip().split()))
	X += [xy[0]]
	Y += [xy[1]]
	XY += [xy]
X.sort()
a = f(X)
Y.sort()
b = f(Y)
XY.sort()
c = f(XY)
print(a + b - c)


def swap(a, b):
	return [b, a]

def count_pairs(a, ind):
	count = 0
	freq = {}
	for i in range(len(a)):
		try:
			freq[a[i][ind]] += 1
		except:
			freq[a[i][ind]] = 1
	for i in freq:
		count += freq[i] * (freq[i] - 1) // 2
	return count
n = int(input())
a = []
freq = {}
for i in range(n):
	b = [int(j) for j in input().split()]
	try:
		freq[str(b[0]) + str(b[1])] += 1
	except:
		freq[str(b[0]) + str(b[1])] = 1
	a.append(b)
a.sort()
total = count_pairs(a, 0)
a.sort(key=lambda x: x[1])
total += count_pairs(a, 1)
freq_count = 0
for i in freq:
	freq_count += freq[i] * (freq[i] - 1) // 2
print(total - freq_count)


from collections import defaultdict
n = int(input())
nums = [map(int, input().split()) for _ in range(n)]
(xs, ys, xys) = (defaultdict(int), defaultdict(int), defaultdict(int))
for (x, y) in nums:
	xs[x] += 1
	ys[y] += 1
	xys[x, y] += 1
count = 0
for val in (*xs.values(), *ys.values()):
	count += val * (val - 1) // 2
for val in xys.values():
	count -= val * (val - 1) // 2
print(count)


from sys import stdin
n = int(stdin.readline().rstrip())
l = []
l2 = []
for i in range(n):
	(a, b) = map(int, stdin.readline().rstrip().split(' '))
	l.append([a, b])
	l2.append([b, a])
l.sort()
l2.sort()
c = 0
x = 0
for i in range(1, n):
	if l[i][0] == l[i - 1][0]:
		x += 1
	else:
		c += x * (x + 1) // 2
		x = 0
if x:
	c += x * (x + 1) // 2
	x = 0
for i in range(1, n):
	if l2[i][0] == l2[i - 1][0]:
		x += 1
	else:
		c += x * (x + 1) // 2
		x = 0
if x:
	c += x * (x + 1) // 2
x = 0
rem = 0
for i in range(1, n):
	if l[i] == l[i - 1]:
		x += 1
	else:
		rem += x * (x + 1) // 2
		x = 0
if x:
	rem += x * (x + 1) // 2
print(c - rem)


n = int(input())
dictx = {}
dicty = {}
arr = {}
for i in range(0, n):
	(x, y) = map(int, input().split())
	if x in dictx:
		dictx[x] = dictx[x] + 1
	else:
		dictx[x] = 1
	if y in dicty:
		dicty[y] = dicty[y] + 1
	else:
		dicty[y] = 1
	if (x, y) not in arr:
		arr[x, y] = 1
	else:
		arr[x, y] = arr[x, y] + 1
p1 = 0
p2 = 0
p3 = 0
for i in dictx:
	if dictx[i] > 1:
		c = dictx[i]
		p1 = p1 + c * (c - 1) // 2
for i in dicty:
	if dicty[i] > 1:
		c = dicty[i]
		p2 = p2 + c * (c - 1) // 2
for i in arr:
	if arr[i] > 1:
		c = arr[i]
		p3 = p3 + c * (c - 1) // 2
print(p1 + p2 - p3)


xs = {}
ys = {}
pairs = {}
n = int(input())
ans = 0
while n > 0:
	(x, y) = [int(num) for num in input().split()]
	ans += xs.get(x, 0) + ys.get(y, 0)
	xs[x] = xs.get(x, 0) + 1
	ys[y] = ys.get(y, 0) + 1
	ans -= pairs.get((x, y), 0)
	pairs[x, y] = pairs.get((x, y), 0) + 1
	n -= 1
print(ans)


d1 = {}
d2 = {}
d3 = {}
for _ in range(int(input())):
	(x, y) = map(int, input().split())
	d1[x] = d1.get(x, 0) + 1
	d2[y] = d2.get(y, 0) + 1
	d3[x, y] = d3.get((x, y), 0) + 1
ans = 0
for i in d1.keys():
	val = d1[i]
	ans += val * (val - 1) // 2
for i in d2.keys():
	val = d2[i]
	ans += val * (val - 1) // 2
for i in d3.keys():
	val = d3[i]
	ans -= val * (val - 1) // 2
print(ans)


n = int(input())
arr = list()
for i in range(n):
	(x, y) = map(int, input().split())
	arr.append((x, y))
arr.sort()
c = 0
x = 1
for i in range(n - 1):
	if arr[i][0] == arr[i + 1][0]:
		x += 1
	else:
		c += x * (x - 1) // 2
		x = 1
c += x * (x - 1) // 2
x = 1
arr.sort(key=lambda T: T[1])
for i in range(n - 1):
	if arr[i][1] == arr[i + 1][1]:
		x += 1
	else:
		c += x * (x - 1) // 2
		x = 1
c += x * (x - 1) // 2
x = 1
for i in range(n - 1):
	if arr[i][1] == arr[i + 1][1] and arr[i][0] == arr[i + 1][0]:
		x += 1
	else:
		c -= x * (x - 1) // 2
		x = 1
c -= x * (x - 1) // 2
print(c)


3
from collections import Counter
from functools import reduce
n = int(input())
x = Counter()
y = Counter()
points = Counter()
for i in range(n):
	point = list(map(int, input().split()))
	x[point[0]] += 1
	y[point[1]] += 1
	points[point[0], point[1]] += 1

def getPairsNumber(n):
	return n * (n - 1) // 2

def getCounterPairsNumber(counter):
	return reduce(lambda s, n: s + getPairsNumber(n), list(counter.values()), 0)
s = getCounterPairsNumber(x) + getCounterPairsNumber(y) - getCounterPairsNumber(points)
print(s)


from collections import defaultdict
r = 0
(a, b, c) = (defaultdict(int), defaultdict(int), defaultdict(int))
for _ in range(int(input())):
	(x, y) = map(int, input().split())
	r += a[x] + b[y] - c[x, y]
	a[x] += 1
	b[y] += 1
	c[x, y] += 1
print(r)


from collections import *
n = int(input())
k = [tuple(map(int, input().split())) for i in range(n)]
a = Counter()
b = Counter()
c = Counter()
ans = 0
for i in k:
	(x, y) = i
	ans += a[x] + b[y] - c[x, y]
	a[x] += 1
	b[y] += 1
	c[x, y] += 1
print(ans)


from collections import defaultdict
import sys
from math import gcd, sqrt
from typing import Counter, DefaultDict
sys.setrecursionlimit(10 ** 5)
inf = float('inf')
en = lambda x: list(enumerate(x))
ii = lambda : int(input())
r = lambda : map(int, input().split())
rr = lambda : list(r())
n = ii()
x = [rr() for _ in range(n)]
arr = defaultdict(lambda : 0)
brr = defaultdict(lambda : 0)
crr = defaultdict(lambda : 0)
ans = 0
for (i, j) in x:
	ans += arr[i] + brr[j] - crr[i, j]
	arr[i] += 1
	brr[j] += 1
	crr[i, j] += 1
print(ans)


import sys
input = sys.stdin.readline

def ceil(x):
	if x != int(x):
		x = int(x) + 1
	return x

def factorial(x, m):
	val = 1
	while x > 0:
		val = val * x % m
		x -= 1
	return val

def fact(x):
	val = 1
	while x > 0:
		val *= x
		x -= 1
	return val

def swaparr(arr, a, b):
	temp = arr[a]
	arr[a] = arr[b]
	arr[b] = temp

def gcd(a, b):
	if b == 0:
		return a
	return gcd(b, a % b)

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

def nCr(n, k):
	if k > n:
		return 0
	if k > n - k:
		k = n - k
	res = 1
	for i in range(k):
		res = res * (n - i)
		res = res / (i + 1)
	return int(res)

def upper_bound(a, x, lo=0, hi=None):
	if hi == None:
		hi = len(a)
	while lo < hi:
		mid = (lo + hi) // 2
		if a[mid] < x:
			lo = mid + 1
		else:
			hi = mid
	return lo

def primefs(n):
	primes = {}
	while n % 2 == 0 and n > 0:
		primes[2] = primes.get(2, 0) + 1
		n = n // 2
	for i in range(3, int(n ** 0.5) + 2, 2):
		while n % i == 0 and n > 0:
			primes[i] = primes.get(i, 0) + 1
			n = n // i
	if n > 2:
		primes[n] = primes.get(n, 0) + 1
	return primes

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 swap(a, b):
	temp = a
	a = b
	b = temp
	return (a, b)

def find(x, link):
	p = x
	while p != link[p]:
		p = link[p]
	while x != p:
		nex = link[x]
		link[x] = p
		x = nex
	return p

def union(x, y, link, size):
	x = find(x, link)
	y = find(y, link)
	if size[x] < size[y]:
		(x, y) = swap(x, y)
	if x != y:
		size[x] += size[y]
		link[y] = x

def sieve(n):
	prime = [True for i in range(n + 1)]
	(prime[0], prime[1]) = (False, False)
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p + p, n + 1, p):
				prime[i] = False
		p += 1
	return prime
MAXN = int(100000.0 + 5)

def spf_sieve():
	spf[1] = 1
	for i in range(2, MAXN):
		spf[i] = i
	for i in range(4, MAXN, 2):
		spf[i] = 2
	for i in range(3, ceil(MAXN ** 0.5), 2):
		if spf[i] == i:
			for j in range(i * i, MAXN, i):
				if spf[j] == j:
					spf[j] = i
spf = [0 for i in range(MAXN)]

def factoriazation(x):
	res = []
	for i in range(2, int(x ** 0.5) + 1):
		while x % i == 0:
			res.append(i)
			x //= i
	if x != 1:
		res.append(x)
	return res

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

def float_array():
	return list(map(float, input().strip().split()))

def str_array():
	return input().strip().split()
MOD = int(1000000000.0) + 7
CMOD = 998244353
INF = float('inf')
NINF = -float('inf')
from itertools import permutations
import math
from bisect import bisect_left

def solve():
	n = int(input())
	left = {}
	right = {}
	both = {}
	count = 0
	for i in range(n):
		(x, y) = map(int, input().split())
		(l, r, b) = (left.get(x, 0), right.get(y, 0), both.get((x, y), 0))
		count += l + r - b
		left[x] = l + 1
		right[y] = r + 1
		both[x, y] = b + 1
	print(count)
for _ in range(1):
	solve()


n = int(input())
count = 0
x = {}
y = {}
xy = {}
while n:
	n -= 1
	l = [i for i in input().split()]
	t = str(l[0]) + '__' + str(l[1])
	try:
		xyc = xy[t]
		if xyc > 0:
			count += xyc
		xy[t] += 1
	except KeyError:
		xy[t] = 1
		xyc = 0
	try:
		count += x[l[0]] - xyc
		x[l[0]] += 1
	except KeyError:
		x[l[0]] = 1
	try:
		count += y[l[1]] - xyc
		y[l[1]] += 1
	except KeyError:
		y[l[1]] = 1
print(count)


import math, sys, bisect, heapq
from collections import defaultdict, Counter, deque
from itertools import groupby, accumulate
int1 = lambda x: int(x) - 1
input = iter(sys.stdin.buffer.read().decode().splitlines()).__next__
ilele = lambda : map(int, input().split())
alele = lambda : list(map(int, input().split()))
ilelec = lambda : map(int1, input().split())
alelec = lambda : list(map(int1, input().split()))

def list2d(a, b, c):
	return [[c] * b for i in range(a)]

def list3d(a, b, c, d):
	return [[[d] * c for j in range(b)] for i in range(a)]

def Y(c):
	print(['NO', 'YES'][c])

def y(c):
	print(['no', 'yes'][c])

def Yy(c):
	print(['No', 'Yes'][c])

def fun(X):
	a = 0
	for i in X.values():
		a += i * (i - 1) // 2
	return a
N = int(input())
A = {}
C = {}
D = {}
for i in range(N):
	(x, y) = ilele()
	A[x, y] = A.get((x, y), 0) + 1
	C[x] = C.get(x, 0) + 1
	D[y] = D.get(y, 0) + 1
ans = fun(C) + fun(D) - fun(A)
print(ans)


import sys
input = sys.stdin.readline

def swaparr(arr, a, b):
	temp = arr[a]
	arr[a] = arr[b]
	arr[b] = temp

def gcd(a, b):
	if a == 0:
		return b
	return gcd(b % a, a)

def nCr(n, k):
	if k > n - k:
		k = n - k
	res = 1
	for i in range(k):
		res = res * (n - i)
		res = res / (i + 1)
	return res

def upper_bound(a, x, lo=0):
	hi = len(a)
	while lo < hi:
		mid = (lo + hi) // 2
		if a[mid] < x:
			lo = mid + 1
		else:
			hi = mid
	return lo

def primefs(n):
	primes = {}
	while n % 2 == 0:
		primes[2] = primes.get(2, 0) + 1
		n = n // 2
	for i in range(3, int(n ** 0.5) + 2, 2):
		while n % i == 0:
			primes[i] = primes.get(i, 0) + 1
			n = n // i
	if n > 2:
		primes[n] = primes.get(n, 0) + 1
	return primes

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 swap(a, b):
	temp = a
	a = b
	b = temp
	return (a, b)

def find(x, link):
	p = x
	while p != link[p]:
		p = link[p]
	while x != p:
		nex = link[x]
		link[x] = p
		x = nex
	return p

def union(x, y, link, size):
	x = find(x, link)
	y = find(y, link)
	if size[x] < size[y]:
		(x, y) = swap(x, y)
	if x != y:
		size[x] += size[y]
		link[y] = x

def sieve(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	return prime
MAXN = int(1000000.0 + 5)

def spf_sieve():
	spf[1] = 1
	for i in range(2, MAXN):
		spf[i] = i
	for i in range(4, MAXN, 2):
		spf[i] = 2
	for i in range(3, ceil(MAXN ** 0.5), 2):
		if spf[i] == i:
			for j in range(i * i, MAXN, i):
				if spf[j] == j:
					spf[j] = i

def factoriazation(x):
	ret = {}
	while x != 1:
		ret[spf[x]] = ret.get(spf[x], 0) + 1
		x = x // spf[x]
	return ret

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

def str_array():
	return input().strip().split()
MOD = int(1000000000.0) + 7
CMOD = 998244353
INF = float('inf')
NINF = -float('inf')
n = int(input())
pts = []
for _ in range(n):
	pts.append(tuple(int_array()))
dick_x = {}
dick_y = {}
for i in pts:
	(x, y) = i
	dick_x[x] = dick_x.get(x, 0) + 1
	dick_y[y] = dick_y.get(y, 0) + 1
ans = 0
for i in dick_x:
	k = dick_x[i]
	ans += k * (k - 1) // 2
for i in dick_y:
	k = dick_y[i]
	ans += k * (k - 1) // 2
dick = {}
for i in pts:
	dick[i] = dick.get(i, 0) + 1
for i in dick:
	k = dick[i]
	ans -= k * (k - 1) // 2
print(ans)


from collections import defaultdict
n = int(input())
a = [tuple(map(int, input().split())) for _ in range(n)]
xCnt = defaultdict(int)
yCnt = defaultdict(int)
same = defaultdict(int)
for (x, y) in a:
	xCnt[x] += 1
	yCnt[y] += 1
	same[x, y] += 1
ret = 0
for cnt in xCnt.values():
	ret += cnt * (cnt - 1) // 2
for cnt in yCnt.values():
	ret += cnt * (cnt - 1) // 2
for cnt in same.values():
	ret -= cnt * (cnt - 1) // 2
print(ret)


c = [tuple(map(int, input().split())) for _ in range(int(input()))]
o = dict()
x = dict()
y = dict()
for v in c:
	o[v] = o.get(v, 0) + 1
	x[v[0]] = x.get(v[0], 0) + 1
	y[v[1]] = y.get(v[1], 0) + 1
ret = 0
for v in x:
	ret += x[v] * (x[v] - 1) // 2
for v in y:
	ret += y[v] * (y[v] - 1) // 2
for v in o:
	ret -= o[v] * (o[v] - 1) // 2
print(ret)


n = int(input())
X = dict()
Y = dict()
P = dict()
for i in range(n):
	(x, y) = [int(_) for _ in input().split()]
	p = (x, y)
	P[p] = P[p] + 1 if p in P else 1
	X[x] = X[x] + 1 if x in X else 1
	Y[y] = Y[y] + 1 if y in Y else 1
C = 0
for x in X:
	c = X[x] - 1
	C += c * (c + 1) // 2
for y in Y:
	c = Y[y] - 1
	C += c * (c + 1) // 2
for p in P:
	if P[p] > 1:
		s = P[p] - 1
		s = s * (s + 1) // 2
		C -= s
print(C)


from sys import stdin
n = int(stdin.readline())
(x, y, xy) = ([], [], [])
for i in range(n):
	(u, v) = map(int, stdin.readline().split())
	x.append(u)
	y.append(v)
	xy.append((u, v))

def cal_pair(a):
	ans = 0
	a.sort()
	cur = 0
	for last in range(1, len(a)):
		if a[last] == a[cur]:
			continue
		ans += (last - cur) * (last - cur - 1) // 2
		cur = last
	ans += (n - cur) * (n - cur - 1) // 2
	return ans
print(cal_pair(x) + cal_pair(y) - cal_pair(xy))


from math import factorial

def watch(n):
	count = 0
	massx = {}
	massy = {}
	count1 = 1
	n.sort()
	for i in range(len(n) - 1):
		if n[i] == n[i + 1]:
			count1 += 1
			continue
		else:
			count -= count1 * (count1 - 1) // 2
			count1 = 1
	count -= count1 * (count1 - 1) // 2
	for i in range(len(n)):
		if n[i][0] in massx:
			massx[n[i][0]] += 1
		else:
			massx[n[i][0]] = 1
		if n[i][1] in massy:
			massy[n[i][1]] += 1
		else:
			massy[n[i][1]] = 1
	for (key, i) in massx.items():
		count += i * (i - 1) // 2
	for (key, i) in massy.items():
		count += i * (i - 1) // 2
	return count
n = []
for i in range(int(input().strip())):
	m = input().strip().split()
	m = [int(m[0]), int(m[1])]
	n.append(m)
print(watch(n))


n = int(input())
arr = []
for _ in range(n):
	curr = []
	(x, y) = map(int, input().split())
	curr.append(x)
	curr.append(y)
	arr.append(curr)
same_x = {}
same_y = {}
same_x_y = {}
for i in arr:
	if i[0] in same_x:
		same_x[i[0]] += 1
	else:
		same_x[i[0]] = 1
	if i[1] in same_y:
		same_y[i[1]] += 1
	else:
		same_y[i[1]] = 1
	x = []
	x.append(i[0])
	x.append(i[1])
	x = str(x)
	if x in same_x_y:
		same_x_y[x] += 1
	else:
		same_x_y[x] = 1
ans = 0
same = 0
for i in same_x:
	if same_x[i] > 1:
		ans += same_x[i] * (same_x[i] - 1) // 2
for i in same_y:
	if same_y[i] > 1:
		ans += same_y[i] * (same_y[i] - 1) // 2
for i in same_x_y:
	if same_x_y[i] > 1:
		same += same_x_y[i] * (same_x_y[i] - 1) // 2
print(ans - same)


import sys
import string
import math
from collections import defaultdict
from functools import lru_cache
from collections import Counter
from fractions import Fraction

def mi(s):
	return map(int, s.strip().split())

def lmi(s):
	return list(mi(s))

def tmi(s):
	return tuple(mi(s))

def mf(f, s):
	return map(f, s)

def lmf(f, s):
	return list(mf(f, s))

def js(lst):
	return ' '.join((str(d) for d in lst))

def jsns(lst):
	return ''.join((str(d) for d in lst))

def line():
	return sys.stdin.readline().strip()

def linesp():
	return line().split()

def iline():
	return int(line())

def mat(n):
	matr = []
	for _ in range(n):
		matr.append(linesp())
	return matr

def matns(n):
	mat = []
	for _ in range(n):
		mat.append([c for c in line()])
	return mat

def mati(n):
	mat = []
	for _ in range(n):
		mat.append(lmi(line()))
	return mat

def pmat(mat):
	for row in mat:
		print(js(row))

def solve(points):
	xs = defaultdict(int)
	ys = defaultdict(int)
	equals = defaultdict(int)
	for (x, y) in points:
		xs[x] += 1
		ys[y] += 1
		equals[x, y] += 1
	ans = 0
	for (x, count) in xs.items():
		ans += count * (count - 1) // 2
	for (y, count) in ys.items():
		ans += count * (count - 1) // 2
	for (eq, count) in equals.items():
		ans -= count * (count - 1) // 2
	print(ans)

def main():
	n = iline()
	points = []
	for _ in range(n):
		points.append(tmi(line()))
	solve(points)
main()


from sys import stdin, stdout
from collections import deque
input = stdin.readline

def main():
	t = 1
	for i in range(t):
		n = int(input())
		ans = 0
		d1 = {}
		d2 = {}
		d3 = {}
		for i in range(n):
			(x, y) = map(int, input().split())
			num = x * 2000000001 + y
			if num in d3:
				d3[num] += 1
			else:
				d3[num] = 1
			if x in d1:
				d1[x] += 1
			else:
				d1[x] = 1
			if y in d2:
				d2[y] += 1
			else:
				d2[y] = 1
		ans = 0
		for i in d1:
			ans += d1[i] * (d1[i] - 1) // 2
		for i in d2:
			ans += d2[i] * (d2[i] - 1) // 2
		for i in d3:
			ans -= d3[i] * (d3[i] - 1) // 2
		print(ans)
main()


from collections import Counter
n = int(input())
l = [0] * n
lx = [0] * n
ly = [0] * n
for i in range(n):
	(a, b) = map(int, input().split())
	l[i] = [a, b]
	lx[i] = a
	ly[i] = b
x = len(l)
res = Counter((tuple(e) for e in l))
d = 0
for e in res:
	if res[e] > 1:
		n = res[e]
		d = d + n * (n - 1) // 2
cx = Counter(lx)
cy = Counter(ly)
c = 0
for e in cx:
	if cx[e] > 1:
		n = cx[e]
		c = c + n * (n - 1) // 2
for e in cy:
	if cy[e] > 1:
		n = cy[e]
		c = c + n * (n - 1) // 2
print(c - d)


header = int(input())
dict_x = {}
dict_y = {}
dict_xy = {}
output = 0
for i in range(header):
	data = list(map(int, input().split(' ')))
	data_x = data[0]
	data_y = data[1]
	if data_x not in dict_x:
		dict_x[data_x] = 0
	if data_y not in dict_y:
		dict_y[data_y] = 0
	if (data_x, data_y) not in dict_xy:
		dict_xy[data_x, data_y] = 0
	output += dict_x[data_x]
	output += dict_y[data_y]
	output -= dict_xy[data_x, data_y]
	dict_x[data_x] += 1
	dict_y[data_y] += 1
	dict_xy[data_x, data_y] += 1
print(output)


n = int(input())
(x, y, p) = ({}, {}, {})
for _ in range(n):
	(a, b) = map(int, input().split())
	x[a] = x.get(a, 0) + 1
	y[b] = y.get(b, 0) + 1
	p[a, b] = p.get((a, b), 0) + 1
res = 0
for i in x.keys():
	res += x[i] * (x[i] - 1) // 2
for i in y.keys():
	res += y[i] * (y[i] - 1) // 2
for i in p.keys():
	res -= p[i] * (p[i] - 1) // 2
print(res)


t = int(input())
dx = {}
dy = {}
dxy = {}
a = 0
for i in range(t):
	(x, y) = map(int, input().split())
	a += dx.get(x, 0) + dy.get(y, 0) - dxy.get((x, y), 0)
	dxy[x, y] = dxy.get((x, y), 0) + 1
	dx[x] = dx.get(x, 0) + 1
	dy[y] = dy.get(y, 0) + 1
print(a)


for t in range(1):
	n = int(input())
	x_pos = dict()
	y_pos = dict()
	points = dict()
	for i in range(n):
		(x, y) = map(int, input().split())
		if x in x_pos:
			x_pos[x] += 1
		else:
			x_pos[x] = 1
		if y in y_pos:
			y_pos[y] += 1
		else:
			y_pos[y] = 1
		if (x, y) in points:
			points[x, y] += 1
		else:
			points[x, y] = 1
	count = 0
	repeat = 0
	for i in points:
		val = points[i]
		ans = val * (val - 1) // 2
		repeat += ans
	for i in x_pos:
		val = x_pos[i]
		ans = val * (val - 1) // 2
		count += ans
	for i in y_pos:
		val = y_pos[i]
		ans = val * (val - 1) // 2
		count += ans
	print(count - repeat)


import sys
inf = float('inf')
abc = 'abcdefghijklmnopqrstuvwxyz'
abd = {'a': 0, 'b': 1, 'c': 2, 'd': 3, 'e': 4, 'f': 5, 'g': 6, 'h': 7, 'i': 8, 'j': 9, 'k': 10, 'l': 11, 'm': 12, 'n': 13, 'o': 14, 'p': 15, 'q': 16, 'r': 17, 's': 18, 't': 19, 'u': 20, 'v': 21, 'w': 22, 'x': 23, 'y': 24, 'z': 25}
(mod, MOD) = (1000000007, 998244353)
vow = ['a', 'e', 'i', 'o', 'u']
(dx, dy) = ([-1, 1, 0, 0], [0, 0, 1, -1])

def get_array():
	return list(map(int, sys.stdin.readline().strip().split()))

def get_ints():
	return map(int, sys.stdin.readline().strip().split())

def input():
	return sys.stdin.readline().strip()
n = int(input())
mydict_x = dict()
mydict_y = dict()
mydict = dict()
total = 0
for i in range(n):
	(x, y) = get_ints()
	mydict_x[x] = mydict_x.get(x, 0) + 1
	mydict_y[y] = mydict_y.get(y, 0) + 1
	mydict[x, y] = mydict.get((x, y), 0) + 1
for i in mydict_x:
	total += mydict_x[i] * (mydict_x[i] - 1) // 2
for i in mydict_y:
	total += mydict_y[i] * (mydict_y[i] - 1) // 2
for i in mydict:
	total -= mydict[i] * (mydict[i] - 1) // 2
print(total)


from sys import stdin, stdout
from math import floor, gcd, fabs, factorial, fmod, sqrt, inf, log
from collections import defaultdict as dd, deque
from heapq import merge, heapify, heappop, heappush, nsmallest
from bisect import bisect_left as bl, bisect_right as br, bisect
mod = pow(10, 9) + 7
mod2 = 998244353

def inp():
	return stdin.readline().strip()

def iinp():
	return int(inp())

def out(var, end='\n'):
	stdout.write(str(var) + '\n')

def outa(*var, end='\n'):
	stdout.write(' '.join(map(str, var)) + end)

def lmp():
	return list(mp())

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

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

def l1d(n, val=0):
	return [val for i in range(n)]

def l2d(n, m, val=0):
	return [l1d(m, val) for j in range(n)]

def remadd(x, y):
	return 1 if x % y else 0

def ceil(a, b):
	return (a + b - 1) // b
S1 = 'abcdefghijklmnopqrstuvwxyz'
S2 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'

def isprime(x):
	if x <= 1:
		return False
	if x in (2, 3):
		return True
	if x % 2 == 0:
		return False
	for i in range(3, int(sqrt(x)) + 1, 2):
		if x % i == 0:
			return False
	return True
n = iinp()
x = dd(int)
y = dd(int)
z = dd(int)
for i in range(n):
	(a, b) = mp()
	x[a] += 1
	y[b] += 1
	z[a, b] += 1
ans = 0
for (k, v) in x.items():
	ans += v * (v - 1) // 2
for (k, v) in y.items():
	ans += v * (v - 1) // 2
for (k, v) in z.items():
	ans -= v * (v - 1) // 2
print(ans)


import os
import sys
from atexit import register
from io import BytesIO
n = int(input())
line = ''
x = {}
y = {}
pairs = {}
for i in range(n):
	line = input()
	line = line.split()
	if int(line[0]) not in x:
		x[int(line[0])] = 1
	else:
		x[int(line[0])] += 1
	if int(line[1]) not in y:
		y[int(line[1])] = 1
	else:
		y[int(line[1])] += 1
	if (int(line[0]), int(line[1])) not in pairs:
		pairs[int(line[0]), int(line[1])] = 1
	else:
		pairs[int(line[0]), int(line[1])] += 1
sumX = 0
sumY = 0
sumPairs = 0
for (key, value) in x.items():
	if value != 1:
		sumX += value * (value - 1) / 2.0
for (key, value) in y.items():
	if value != 1:
		sumY += value * (value - 1) / 2.0
for (key, value) in pairs.items():
	if value != 1:
		sumPairs += value * (value - 1) / 2.0
print(int(sumX + sumY - sumPairs))


from sys import stdin

def main():
	n = int(stdin.readline())
	lx = {}
	ly = {}
	lp = {}
	ans = 0
	for _ in range(n):
		(x, y) = map(int, stdin.readline().split())
		if x in lx:
			ans += lx[x]
			lx[x] += 1
		else:
			lx[x] = 1
		if y in ly:
			ans += ly[y]
			ly[y] += 1
		else:
			ly[y] = 1
		if (x, y) in lp:
			ans -= lp[x, y]
			lp[x, y] += 1
		else:
			lp[x, y] = 1
	print(ans)
main()


n = int(input())
count = 0
dicx = {}
dicy = {}
dic = {}
for i in range(n):
	(x, y) = map(int, input().split())
	if x not in dicx:
		dicx[x] = 1
	else:
		dicx[x] += 1
	if y not in dicy:
		dicy[y] = 1
	else:
		dicy[y] += 1
	if (x, y) not in dic:
		dic[x, y] = 1
	else:
		dic[x, y] += 1
for i in dicx:
	if dicx[i] != 1:
		count += dicx[i] * (dicx[i] - 1) // 2
for i in dicy:
	if dicy[i] != 1:
		count += dicy[i] * (dicy[i] - 1) // 2
for i in dic:
	if dic[i] != 1:
		count -= dic[i] * (dic[i] - 1) // 2
print(count)


import math as mt
import sys, string, bisect
input = sys.stdin.readline
from collections import deque, defaultdict
L = lambda : list(map(int, input().split()))
Ls = lambda : list(input().split())
M = lambda : map(int, input().split())
I = lambda : int(input())

def dist(x, y, c, d):
	return (x - c) ** 2 + (y - d) ** 2

def circle(x1, y1, x2, y2, r1, r2):
	distSq = ((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2)) ** 0.5
	if distSq + r2 <= r1:
		return True
	else:
		return False
n = I()
x = defaultdict(int)
x2 = defaultdict(int)
y = defaultdict(int)
y2 = defaultdict(int)
pair = defaultdict(int)
pair2 = defaultdict(int)
d = []
for i in range(n):
	(a, b) = M()
	d.append([a, b])
	x[a] += 1
	if x[a] >= 2:
		x2[a] = x[a]
	y[b] += 1
	if y[b] >= 2:
		y2[b] = y[b]
	pair[a, b] += 1
	if pair[a, b] >= 2:
		pair2[a, b] = pair[a, b]
sum = 0
r = x2.values()
for i in r:
	sum += i * (i - 1) // 2
sum2 = 0
r = y2.values()
for i in r:
	sum2 += i * (i - 1) // 2
r = pair2.values()
sum3 = 0
for i in r:
	sum3 += i * (i - 1) // 2
print(sum + sum2 - sum3)


n = int(input())
cols = dict()
rows = dict()
total = 0
seen = dict()
for _ in range(n):
	(c, r) = input().split()
	seen_get = seen.get((c, r), 0)
	total -= seen_get
	seen[c, r] = seen_get + 1
	c_get = cols.get(c, 0)
	total += c_get
	r_get = rows.get(r, 0)
	total += r_get
	cols[c] = c_get + 1
	rows[r] = r_get + 1
print(total)


p = int(input())
d_x = {}
d_y = {}
d_t = {}
t = 0
for _ in range(p):
	(x, y) = map(int, input().split())
	if x in d_x:
		t += d_x[x]
		d_x[x] += 1
	else:
		d_x[x] = 1
	if y in d_y:
		t += d_y[y]
		d_y[y] += 1
	else:
		d_y[y] = 1
	s = '%d,%d' % (x, y)
	if s in d_t:
		t -= d_t[s]
		d_t[s] += 1
	else:
		d_t[s] = 1
print(t)


import random, math, sys
from copy import deepcopy as dc
from bisect import bisect_left, bisect_right
from collections import Counter
input = sys.stdin.readline

def solution(li):
	x = {}
	y = {}
	xy = {}
	c = 0
	for i in li:
		xc = x.get(i[0], 0)
		yc = y.get(i[1], 0)
		xyc = xy.get(tuple(i), 0)
		c += xc + yc - xyc
		x[i[0]] = x.get(i[0], 0) + 1
		y[i[1]] = y.get(i[1], 0) + 1
		xy[tuple(i)] = xy.get(tuple(i), 0) + 1
	return c

def input_test():
	li1 = []
	for _ in range(int(input())):
		li = list(map(int, input().strip().split(' ')))
		li1.append(li)
	out = solution(li1)
	print(out)

def test():
	pass
input_test()


n = int(input())
w = [None] * n
for i in range(n):
	(x, y) = map(int, input().split())
	w[i] = (x, y)
w.sort()
eq = 0
np = 0
xeq = 0
for i in range(n):
	eq += 1
	if i + 1 == n or w[i][0] != w[i + 1][0]:
		comb = eq * (eq - 1) // 2
		np += comb
		eq = 0
	if i > 0 and w[i][0] == w[i - 1][0] and (w[i][1] == w[i - 1][1]):
		xeq += 1
	elif xeq > 0:
		xcomb = xeq * (xeq + 1) // 2
		np -= xcomb
		xeq = 0
if xeq > 0:
	xcomb = xeq * (xeq + 1) // 2
	np -= xcomb
	xeq = 0

def sortSecond(val):
	return val[1]
w.sort(key=sortSecond)
eq = 0
for i in range(n):
	eq += 1
	if i + 1 == n or w[i][1] != w[i + 1][1]:
		comb = eq * (eq - 1) // 2
		np += comb
		eq = 0
print(np)


from collections import Counter
n = int(input())
(a, b, c) = [Counter() for i in range(3)]
ans = 0
for i in range(n):
	(x, y) = map(int, input().split())
	a[x] += 1
	b[y] += 1
	c[x, y] += 1
for i in a.values():
	ans += (i - 1) * i // 2
for i in b.values():
	ans += (i - 1) * i // 2
for i in c.values():
	ans -= (i - 1) * i // 2
print(ans)


from collections import Counter
n = int(input())
full = []
xdict = {}
ydict = {}
result = 0
for _ in range(n):
	(x, y) = map(int, input().split())
	full.append((x, y))
	try:
		xdict[x] += 1
	except:
		xdict[x] = 1
	try:
		ydict[y] += 1
	except:
		ydict[y] = 1
for (key, value) in xdict.items():
	if value > 1:
		result += value * (value - 1) // 2
for (key, value) in ydict.items():
	if value > 1:
		result += value * (value - 1) // 2
count = Counter(full)
for (key, value) in count.items():
	if value > 1:
		result -= value * (value - 1) // 2
print(result)


from collections import defaultdict
from math import sin, pi, sqrt
d = defaultdict(int)
a = defaultdict(int)
o = defaultdict(int)
r = defaultdict(int)
ans = 0
n = int(input())
for _ in range(n):
	(x, y) = list(map(int, input().split(' ')))
	(ab, ordo, red) = (a[x], o[y], r[x, y])
	ans += ab + ordo - red
	(a[x], o[y], r[x, y]) = (a[x] + 1, o[y] + 1, r[x, y] + 1)
print(ans)


import os, io
import sys
import collections

def sum1N(n):
	return n * (n - 1) // 2
n = int(sys.stdin.readline().strip())
xmap = collections.defaultdict(int)
ymap = collections.defaultdict(int)
cnt = 0
seen = {}
for i in range(n):
	(xi, yi) = list(map(int, sys.stdin.readline().strip().split(' ')))
	if (xi, yi) in seen:
		seen[xi, yi] += 1
	else:
		seen[xi, yi] = 1
	xmap[xi] += 1
	ymap[yi] += 1
total = 0
for (k, v) in xmap.items():
	total += sum1N(v)
for (k, v) in ymap.items():
	total += sum1N(v)
for (k, v) in seen.items():
	total -= sum1N(v)
print(total)


def summa(n):
	ans = 0
	while n > 0:
		ans += n
		n -= 1
	return ans
import sys
n = int(sys.stdin.readline())
a = []
ans = 0
for i in range(n):
	a.append(tuple(map(int, sys.stdin.readline().split())))
b = {}
x = {}
for i in a:
	if i[0] not in x:
		x[i[0]] = [1, 0]
		b[i] = 1
	else:
		if i not in b:
			b[i] = 1
		else:
			b[i] += 1
		x[i[0]][0] += 1
		x[i[0]][1] += x[i[0]][0] - 1
for i in x.values():
	ans += i[1]
y = {}
for i in a:
	if i[1] not in y:
		y[i[1]] = [1, 0]
	else:
		y[i[1]][0] += 1
		y[i[1]][1] += y[i[1]][0] - 1
for i in y.values():
	ans += i[1]
for i in b.values():
	if i > 1:
		ans -= summa(i - 1)
print(ans)


import sys
import math
import collections
import bisect

def get_ints():
	return map(int, sys.stdin.readline().strip().split())

def get_list():
	return list(map(int, sys.stdin.readline().strip().split()))

def get_string():
	return sys.stdin.readline().strip()
for t in range(1):
	n = int(input())
	x_counter = dict()
	y_counter = dict()
	equal = 0
	repeat = dict()
	for i in range(n):
		(x, y) = get_ints()
		if x in x_counter:
			x_counter[x] += 1
		else:
			x_counter[x] = 1
		if y in y_counter:
			y_counter[y] += 1
		else:
			y_counter[y] = 1
		if (x, y) in repeat:
			repeat[x, y] += 1
		else:
			repeat[x, y] = 1
	ans = 0
	for i in x_counter:
		if x_counter[i] < 2:
			continue
		freq = x_counter[i]
		val = freq * (freq - 1) // 2
		ans += val
	for i in y_counter:
		if y_counter[i] < 2:
			continue
		freq = y_counter[i]
		val = freq * (freq - 1) // 2
		ans += val
	for i in repeat:
		if repeat[i] < 2:
			continue
		freq = repeat[i]
		val = freq * (freq - 1) // 2
		ans -= val
	print(ans)


from sys import stdin

def combination(num, l=2):
	if num < 2:
		return 0
	else:
		return num * (num - 1) // 2

def make(first, second):
	return str(first) + ' ' + str(second)
n = int(stdin.readline().strip())
points = []
for _ in range(n):
	(x, y) = list(map(int, stdin.readline().split()))
	points.append([x, y])
points = sorted(points, key=lambda x: x[0])
count = 1
ans = 0
for i in range(1, n):
	if points[i][0] == points[i - 1][0]:
		count += 1
	else:
		ans += combination(count, 2)
		count = 1
ans += combination(count, 2)
points = sorted(points, key=lambda x: x[1])
count = 1
for i in range(1, n):
	if points[i][1] == points[i - 1][1]:
		count += 1
	else:
		ans += combination(count, 2)
		count = 1
ans += combination(count, 2)
unique = dict()
for i in range(n):
	(x, y) = points[i]
	if make(x, y) in unique:
		unique[make(x, y)] += 1
	else:
		unique[make(x, y)] = 1
for i in unique:
	ans -= combination(unique[i], 2)
print(ans)


import sys
n = int(sys.stdin.readline())
A = [tuple(map(int, sys.stdin.readline().split())) for _ in range(n)]
Xs = dict()
Ys = dict()
XYs = dict()
for (x, y) in A:
	Xs.setdefault(x, 0)
	Xs[x] += 1
	Ys.setdefault(y, 0)
	Ys[y] += 1
	XYs.setdefault((x, y), 0)
	XYs[x, y] += 1
r = sum(list(map(lambda v: (v - 1) * v // 2, Xs.values())))
r += sum(list(map(lambda v: (v - 1) * v // 2, Ys.values())))
r -= sum(list(map(lambda v: (v - 1) * v // 2, XYs.values())))
print(r)


from collections import defaultdict as dd
n = int(input())
pts = []
d = dd(int)
(x, y) = (dd(int), dd(int))
for i in range(n):
	(a, b) = [int(x) for x in input().split()]
	pts.append([a, b])
	d[a, b] += 1
	x[a] += 1
	y[b] += 1
xkeys = list(x.keys())
ykeys = list(y.keys())
ans = 0
for i in xkeys:
	nums = x[i]
	ans += nums * (nums - 1) // 2
for i in ykeys:
	nums = y[i]
	ans += nums * (nums - 1) // 2
ptkeys = list(d.keys())
for i in ptkeys:
	nums = d[i]
	if nums > 1:
		ans -= nums * (nums - 1) // 2
print(ans)


import math
n = int(input())
a = []
b = []
t = []
for i in range(n):
	(x, y) = map(int, input().split())
	t.append([x, y])
	a.append(x)
	b.append(y)
t.sort()
a.sort()
b.sort()
answer = 0
pair = 0
last = t[0]
now = 1
for i in range(1, n):
	if t[i] == last:
		now += 1
	else:
		pair += now * (now - 1) // 2
		now = 1
		last = t[i]
pair += now * (now - 1) // 2
last = a[0]
now = 1
for i in range(1, n):
	if a[i] == last:
		now += 1
	else:
		answer += now * (now - 1) // 2
		now = 1
		last = a[i]
answer += now * (now - 1) // 2
now = 1
last = b[0]
for i in range(1, n):
	if b[i] == last:
		now += 1
	else:
		answer += now * (now - 1) // 2
		now = 1
		last = b[i]
answer += now * (now - 1) // 2
now = 1
last = b[i]
print(answer - pair)


n = int(input())
coordinates = []
X = {}
Y = {}
pairs = {}

def nc2(k):
	return k * (k - 1) / 2
for i in range(n):
	(u, v) = map(int, input().split())
	coordinates += [(u, v)]
	if u not in X:
		X[u] = 0
	if v not in Y:
		Y[v] = 0
	if (u, v) not in pairs:
		pairs[u, v] = 0
	X[u] += 1
	Y[v] += 1
	pairs[u, v] += 1
total = 0
for x in X.keys():
	value = X[x]
	if value > 1:
		total += nc2(value)
for y in Y.keys():
	value = Y[y]
	if value > 1:
		total += nc2(value)
for p in pairs.keys():
	value = pairs[p]
	if value > 1:
		total -= nc2(value)
print(int(total))


from collections import Counter
n = int(input())
mat = []
cnt = 0
p = Counter()
q = Counter()
r = Counter()
for _ in range(n):
	(x, y) = map(int, input().split())
	mat.append([x, y])
for i in range(n):
	a = mat[i][0]
	b = mat[i][1]
	if p[a]:
		p[a] += 1
	else:
		p[a] = 1
	if q[b]:
		q[b] += 1
	else:
		q[b] = 1
	if r[str(a) + str(b)]:
		r[str(a) + str(b)] += 1
	else:
		r[str(a) + str(b)] = 1
for i in p.values():
	cnt += i * (i - 1) // 2
for j in q.values():
	cnt += j * (j - 1) // 2
for k in r.values():
	cnt -= k * (k - 1) // 2
print(cnt)


import math

def nCr(n, r):
	if n < r:
		return 0
	return math.factorial(n) // (math.factorial(r) * math.factorial(n - r))
n = int(input())
dict_x = {}
dict_y = {}
dict_x_y = {}
ans = 0
for i in range(n):
	(x, y) = map(int, input().split())
	ans += dict_x.get(x, 0) + dict_y.get(y, 0) - dict_x_y.get((x, y), 0)
	dict_x[x] = dict_x.get(x, 0) + 1
	dict_y[y] = dict_y.get(y, 0) + 1
	dict_x_y[x, y] = dict_x_y.get((x, y), 0) + 1
print(ans)


def main():
	from collections import Counter
	(cx, cy, cxy) = (Counter(), Counter(), Counter())
	for _ in range(int(input())):
		(x, y) = map(int, input().split())
		cx[x] += 1
		cy[y] += 1
		cxy[x, y] += 1
	(a, b, c) = (sum((v * (v - 1) for v in cnt.values())) for cnt in (cx, cy, cxy))
	print((a + b - c) // 2)
main()


from sys import stdin, stdout
import math
input = stdin.readline

def write(n, sep='\n'):
	stdout.write(str(n))
	stdout.write(sep)

def gil():
	return list(map(int, input().split()))
s = 0
n = int(input())
p = []
from collections import Counter as C
a = C()
b = C()
c = C()
for i in range(n):
	(x, y) = gil()
	s += a[x] + b[y] - c[x, y]
	a[x] += 1
	b[y] += 1
	c[x, y] += 1
print(s)


n = int(input())
hor = dict()
ver = dict()
same = dict()
for i in range(n):
	(x, y) = map(int, input().split())
	if x in hor:
		hor[x] += 1
	else:
		hor[x] = 1
	if y in ver:
		ver[y] += 1
	else:
		ver[y] = 1
	if (x, y) in same:
		same[x, y] += 1
	else:
		same[x, y] = 1
res = 0
for i in hor:
	res += hor[i] * (hor[i] - 1) // 2
for i in ver:
	res += ver[i] * (ver[i] - 1) // 2
for i in same:
	res -= same[i] * (same[i] - 1) // 2
print(res)


n = int(input())
l = []
for i in range(n):
	(a, b) = map(int, input().split())
	l.append((a, b))

def solve(a):
	(ans, d) = (0, {})
	for (x, _) in a:
		d[x] = d.setdefault(x, 0) + 1
	for i in d:
		ans += d[i] * (d[i] - 1) // 2
	return ans
x = 0
pd = {}
for i in l:
	pd[i] = pd.setdefault(i, 0) + 1
for i in pd:
	x += pd[i] * (pd[i] - 1) // 2
y = solve(l)
z = solve([(p, q) for (q, p) in l])
print(y + z - x)


from operator import itemgetter
n = int(input())
se = dict()
se1 = dict()
se2 = dict()
count = 0
for i in range(n):
	(a, b) = map(int, input().split())
	if (a, b) in se:
		se[a, b] += 1
	else:
		se[a, b] = 1
	if a in se1:
		se1[a] += 1
	else:
		se1[a] = 1
	if b in se2:
		se2[b] += 1
	else:
		se2[b] = 1
for i in se:
	count -= se[i] * (se[i] - 1) / 2
for i in se1:
	count += se1[i] * (se1[i] - 1) / 2
for i in se2:
	count += se2[i] * (se2[i] - 1) / 2
print(int(count))


from collections import defaultdict
n = int(input())
(X, Y, XY) = (defaultdict(int), defaultdict(int), defaultdict(int))
ans = 0
for _ in range(n):
	(x, y) = input().split()
	point = (x, y)
	ans += X[x] + Y[y] - XY[point]
	X[x] += 1
	Y[y] += 1
	XY[point] += 1
print(ans)


def nC2(n):
	return n * (n - 1) // 2
from collections import Counter
n = int(input())
x = [None] * n
y = [None] * n
for i in range(n):
	(x[i], y[i]) = map(int, input().split())
cntx = Counter(x)
cnty = Counter(y)
cntxy = Counter(zip(x, y))
ans = 0
for v in cntx.values():
	ans += nC2(v)
for v in cnty.values():
	ans += nC2(v)
for v in cntxy.values():
	ans -= nC2(v)
print(ans)


l = []
(lx, ly) = ({}, {})
dic = {}
for _ in range(int(input())):
	(x, y) = map(int, input().split())
	l.append((x, y))
	if lx.get(x, 0) == 0:
		lx[x] = 1
	else:
		lx[x] += 1
	if ly.get(y, 0) == 0:
		ly[y] = 1
	else:
		ly[y] += 1
	if dic.get((x, y), 0) == 0:
		dic[x, y] = 1
	else:
		dic[x, y] += 1
ans = 0
for i in range(len(l)):
	(x, y) = (l[i][0], l[i][1])
	lx[x] -= 1
	ly[y] -= 1
	c = lx[x]
	d = ly[y]
	ans += c + d - dic[x, y] + 1
	dic[x, y] -= 1
print(ans)


from operator import itemgetter
n = int(input())
rows = {}
cols = {}
freq = {}
res = 0
for i in range(n):
	(x, y) = map(int, input().split())
	if x in cols:
		cols[x].append(y)
	else:
		cols[x] = [y]
	if y in rows:
		rows[y].append(x)
	else:
		rows[y] = [x]
	pt = (x, y)
	if pt not in freq:
		freq[pt] = 1
	else:
		freq[pt] += 1
	res -= freq[pt] - 1
for (x, col) in cols.items():
	k = len(col)
	res += k * (k - 1) // 2
for (y, row) in rows.items():
	k = len(row)
	res += k * (k - 1) // 2
print(res)


n = int(input())
(fx, fy) = ({}, {})
f = {}
for i in range(n):
	(x, y) = map(int, input().split())
	fx[x] = fx.get(x, 0) + 1
	fy[y] = fy.get(y, 0) + 1
	pt = (x, y)
	f[pt] = f.get(pt, 0) + 1
res = 0
for (k, v) in fx.items():
	res += v * (v - 1) // 2
for (k, v) in fy.items():
	res += v * (v - 1) // 2
for (k, v) in f.items():
	res -= v * (v - 1) // 2
print(res)


from operator import itemgetter
n = int(input().strip())
ans = 0
l = []
for i in range(n):
	l.append([int(x) for x in input().strip().split()])
l.sort(key=itemgetter(1))
x = l[0][1]
y = 1
for i in range(1, len(l)):
	if l[i][1] != x:
		ans = ans + y * (y - 1) // 2
		x = l[i][1]
		y = 1
	else:
		y = y + 1
ans = ans + y * (y - 1) // 2
l.sort()
x = l[0][0]
y = 1
for i in range(1, len(l)):
	if l[i][0] != x:
		ans = ans + y * (y - 1) // 2
		x = l[i][0]
		y = 1
	else:
		y = y + 1
ans = ans + y * (y - 1) // 2
(x0, x1) = (l[0][0], l[0][1])
y = 1
for i in range(1, len(l)):
	if l[i][0] != x0 or l[i][1] != x1:
		ans = ans - y * (y - 1) // 2
		(x0, x1) = (l[i][0], l[i][1])
		y = 1
	else:
		y = y + 1
ans = ans - y * (y - 1) // 2
print(ans)


x1 = {}
y1 = {}
p1 = {}

def f(key, Dict):
	if Dict.get(key, -1) == -1:
		Dict[key] = 0
ret = 0
for i in range(int(input())):
	xy = input()
	(x, y) = xy.split()
	f(x, x1)
	f(y, y1)
	f(xy, p1)
	ret += x1[x] + y1[y] - p1[xy]
	x1[x] += 1
	y1[y] += 1
	p1[xy] += 1
print(ret)


class A(object):

	def __init__(self):
		self.m_X = {}
		self.m_Y = {}
		self.m_P = {}
		self.m_Ans = 0
		self.AC()

	def AC(self):
		self.m_N = int(input())
		self.m_Point = []
		for i in range(self.m_N):
			(x, y) = map(int, input().split())
			if x not in self.m_X:
				self.m_X[x] = 0
			if not y in self.m_Y:
				self.m_Y[y] = 0
			self.m_Ans += self.m_X[x]
			self.m_Ans += self.m_Y[y]
			self.m_X[x] += 1
			self.m_Y[y] += 1
			if (x, y) not in self.m_P:
				self.m_P[x, y] = 0
			self.m_Ans -= self.m_P[x, y]
			self.m_P[x, y] += 1
		print(int(self.m_Ans))
A()


n = int(input())
crack = []
for i in range(n):
	(x, y) = map(int, input().split())
	crack.append((x, y))
count = 0
crack_x = {}
crack_y = {}
crack_xy = {}
for i in range(len(crack)):
	if crack[i][0] not in crack_x.keys():
		crack_x[crack[i][0]] = 1
	else:
		crack_x[crack[i][0]] += 1
	if crack[i][1] not in crack_y.keys():
		crack_y[crack[i][1]] = 1
	else:
		crack_y[crack[i][1]] += 1
	if crack[i] not in crack_xy.keys():
		crack_xy[crack[i]] = 1
	else:
		crack_xy[crack[i]] += 1
for i in crack_x.keys():
	count += crack_x[i] * (crack_x[i] - 1) // 2
for i in crack_y.keys():
	count += crack_y[i] * (crack_y[i] - 1) // 2
for i in crack_xy.keys():
	count -= crack_xy[i] * (crack_xy[i] - 1) // 2
print(count)


a = {}
b = {}
c = {}
ans = 0
n = int(input())
for i in range(n):
	(x, y) = map(int, input().split())
	if x in a:
		a[x] += 1
	else:
		a[x] = 1
	if y in b:
		b[y] += 1
	else:
		b[y] = 1
	if (x, y) in c:
		c[x, y] += 1
	else:
		c[x, y] = 1
for i in a:
	ans += a[i] * (a[i] - 1) // 2
for i in b:
	ans += b[i] * (b[i] - 1) // 2
for i in c:
	ans -= c[i] * (c[i] - 1) // 2
print(ans)


n = int(input())
a = [list(map(int, input().split())) for _ in range(n)]
(p, q, z) = ({}, {}, {})
for (x, y) in a:
	if x in p:
		p[x] += 1
	else:
		p[x] = 1
	if y in q:
		q[y] += 1
	else:
		q[y] = 1
	if (x, y) in z:
		z[x, y] += 1
	else:
		z[x, y] = 1
ans = 0
for v in p.values():
	ans += v * (v - 1) // 2
for v in q.values():
	ans += v * (v - 1) // 2
for v in z.values():
	ans -= v * (v - 1) // 2
print(ans)


from sys import stdin
from collections import defaultdict
input = stdin.readline
n = int(input())
a = [tuple([int(x) for x in input().split()]) for _ in range(n)]
d = defaultdict(int)
for v in a:
	d[v] += 1
ans = 0
for c in d.values():
	ans -= c * (c - 1) // 2
x = defaultdict(int)
y = defaultdict(int)
for (xx, yy) in a:
	x[xx] += 1
	y[yy] += 1
for c in x.values():
	ans += c * (c - 1) // 2
for c in y.values():
	ans += c * (c - 1) // 2
print(ans)