using
System;
using
System.Collections.Generic;
class
GFG{
static
int
RightAngled(
int
[, ] a,
int
n)
{
Dictionary<
int
,
int
> xpoints =
new
Dictionary<
int
,
int
>();
Dictionary<
int
,
int
> ypoints =
new
Dictionary<
int
,
int
>();
for
(
int
i = 0; i < n; i++)
{
if
(xpoints.ContainsKey(a[i, 0]))
{
xpoints[a[i, 0]] = xpoints[a[i, 0]] + 1;
}
else
{
xpoints.Add(a[i, 0], 1);
}
if
(ypoints.ContainsKey(a[i, 1]))
{
ypoints[a[i, 1]] = ypoints[a[i, 1]] + 1;
}
else
{
ypoints.Add(a[i, 1], 1);
}
}
int
count = 0;
for
(
int
i = 0; i < n; i++)
{
if
(xpoints[a[i, 0]] >= 1 &&
ypoints[a[i, 1]] >= 1)
{
count += (xpoints[a[i, 0]] - 1) *
(ypoints[a[i, 1]] - 1);
}
}
return
count;
}
public
static
void
Main(String[] args)
{
int
N = 5;
int
[, ] arr = {{1, 2}, {2, 1},
{2, 2}, {2, 3}, {3, 2}};
Console.Write(RightAngled(arr, N));
}
}