#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<cmath>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define mem(x) memset(x,0,sizeof x)
#define LL long long
#define INFLL 0x3f3f3f3f3f3f3f3fLL
#define pii pair<LL,LL>
#define AA first
#define BB second
#define mp make_pair
const int maxn = 200010;
int n;
pii p[maxn];
inline void init()
{
	for (int i = 0; i < maxn; i++) p[i] = mp(INFLL, INFLL);
}
inline bool comp1(pii a, pii b)
{
	return a.AA < b.AA;
}
inline bool comp2(pii a, pii b)
{
	return a.BB < b.BB;
}
map<pii, LL> ms;
map<pii, bool> mv;

int main()
{
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		scanf("%d%d", &p[i].AA, &p[i].BB);
		ms[p[i]]++;
	}

	LL ans = 0;
	sort(p, p + n,comp1);
	//for (int i = 0; i < n; i++) cout << p[i].AA << " " << p[i].BB << endl;
	for (int i = 0; i < n; i++)
	{
		LL cnt = 1;
		while (p[i].AA == p[i + 1].AA&&i<n) { i++; cnt++; }
		ans += cnt*(cnt - 1) / 2;
	}

	sort(p, p + n, comp2);
	for (int i = 0; i < n; i++)
	{
		LL cnt = 1;
		while (p[i].BB == p[i + 1].BB&&i<n){ i++; cnt++; }
		ans += (cnt - 1)*cnt / 2;
	}
	for (int i = 0; i < n; i++)
	{
		if (ms[p[i]]>1 && !mv[p[i]]) { ans -= ms[p[i]] * (ms[p[i]] - 1) / 2; mv[p[i]] = true; }
	}
	cout << ans;
	//system("pause");
	return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<cmath>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define mem(x) memset(x,0,sizeof x)
#define LL long long
const int maxn = 200010;
int n;
int x[maxn], y[maxn];

int main()
{
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		scanf("%d%d", &x[i], &y[i]);
	}
	LL ans = 0;
	for (int i = 0; i < n; i++)
	{
		for (int j = i + 1; j < n; j++)
		{
			LL u = (LL)(x[i] - x[j])*(x[i] - x[j]) + (LL)(y[i] - y[j])*(y[i] - y[j]);
			LL v = ((LL)abs(x[i] - x[j]) + (LL)abs(y[i] - y[j]))*((LL)abs(x[i] - x[j]) + (LL)abs(y[i] - y[j]));
			if (u == v) ans++;
		}
	}
	cout << ans;
	//system("pause");
	return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<cmath>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define mem(x) memset(x,0,sizeof x)
#define LL long long
#define pii pair<int,int>
#define AA first
#define BB second
#define mp make_pair
const int maxn = 200010;
int n;
pii p[maxn];
inline bool comp1(pii a, pii b)
{
	return a.AA < b.AA;
}
inline bool comp2(pii a, pii b)
{
	return a.BB < b.BB;
}
map<pii, LL> ms;
map<pii, bool> mv;

int main()
{
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		scanf("%d%d", &p[i].AA, &p[i].BB);
		ms[p[i]]++;
	}

	LL ans = 0;
	sort(p, p + n,comp1);
	for (int i = 0; i < n; i++)
	{
		LL cnt = 1;
		while (p[i].AA == p[i + 1].AA) { i++; cnt++; }
		ans += cnt*(cnt - 1) / 2;
	}
	//cout << ans << endl;

	sort(p, p + n, comp2);
	for (int i = 0; i < n; i++)
	{
		LL cnt = 1;
		while (p[i].BB == p[i + 1].BB){ i++; cnt++; }
		ans += (cnt - 1)*cnt / 2;
	}
	//cout << ans << endl;
	for (int i = 0; i < n; i++)
	{
		if (ms[p[i]]>1 && !mv[p[i]]) { ans -= ms[p[i]] * (ms[p[i]] - 1) / 2; mv[p[i]] = true; }
	}
	cout << ans;
	//system("pause");
	return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<cmath>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define mem(x) memset(x,0,sizeof x)
#define LL long long
#define pii pair<int,int>
#define AA first
#define BB second
#define mp make_pair
const int maxn = 200010;
int n;
pii p[maxn];

int main()
{
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		scanf("%d%d", &p[i].AA, &p[i].BB);
	}
	LL ans = 0;
	sort(p, p + n);
	for (int i = 0; i < n; i++)
	{
		for (int j = i + 1; j < n; j++)
		{
			if (p[i].AA == p[j].AA || p[i].BB == p[j].BB) { ans++; continue; }
			else
			{
				LL u = (LL)(p[i].AA - p[j].AA)* (p[i].AA - p[j].AA) + (LL)(p[i].BB - p[j].BB)*(p[i].BB - p[j].BB);
				LL v = ((LL)abs(p[i].AA - p[j].AA) + (LL)abs(p[i].BB - p[j].BB))*((LL)abs(p[i].AA - p[j].AA) + (LL)abs(p[i].BB - p[j].BB));
				if (u == v) ans++;
			}
		}
	}
	cout << ans;
	//system("pause");
	return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<cmath>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define mem(x) memset(x,0,sizeof x)
#define LL long long
#define INFLL 0x3f3f3f3f3f3f3f3fLL
#define pii pair<LL,LL>
#define AA first
#define BB second
#define mp make_pair
const int maxn = 200010;
int n;
pii p[maxn];
inline void init()
{
	for (int i = 0; i < maxn; i++) p[i] = mp(INFLL, INFLL);
}
inline bool comp1(pii a, pii b)
{
	return a.AA < b.AA;
}
inline bool comp2(pii a, pii b)
{
	return a.BB < b.BB;
}
map<pii, LL> ms;
map<pii, bool> mv;

int main()
{
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		scanf("%d%d", &p[i].AA, &p[i].BB);
		ms[p[i]]++;
	}

	LL ans = 0;
	sort(p, p + n,comp1);
	//for (int i = 0; i < n; i++) cout << p[i].AA << " " << p[i].BB << endl;
	for (int i = 0; i < n; i++)
	{
		LL cnt = 1;
		while (p[i].AA == p[i + 1].AA) { i++; cnt++; }
		ans += cnt*(cnt - 1) / 2;
	}

	sort(p, p + n, comp2);
	for (int i = 0; i < n; i++)
	{
		LL cnt = 1;
		while (p[i].BB == p[i + 1].BB){ i++; cnt++; }
		ans += (cnt - 1)*cnt / 2;
	}
	for (int i = 0; i < n; i++)
	{
		if (ms[p[i]]>1 && !mv[p[i]]) { ans -= ms[p[i]] * (ms[p[i]] - 1) / 2; mv[p[i]] = true; }
	}
	cout << ans;
	//system("pause");
	return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<cmath>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define mem(x) memset(x,0,sizeof x)
#define LL long long
const int maxn = 200010;
int n;
int x[maxn], y[maxn];

int main()
{
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		scanf("%d%d", &x[i], &y[i]);
	}
	LL ans = 0;
	for (int i = 0; i < n; i++)
	{
		for (int j = i + 1; j < n; j++)
		{
			if (x[i] == x[j] || y[i] == y[j]) { ans++; continue; }
			else
			{
				LL u = (LL)(x[i] - x[j])*(x[i] - x[j]) + (LL)(y[i] - y[j])*(y[i] - y[j]);
				LL v = ((LL)abs(x[i] - x[j]) + (LL)abs(y[i] - y[j]))*((LL)abs(x[i] - x[j]) + (LL)abs(y[i] - y[j]));
				if (u == v) ans++;
			}
		}
	}
	cout << ans;
	//system("pause");
	return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<cmath>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define mem(x) memset(x,0,sizeof x)
#define LL long long
#define INFLL 0x3f3f3f3f3f3f3f3fLL
#define pii pair<LL,LL>
#define AA first
#define BB second
#define mp make_pair
const int maxn = 200010;
int n;
pii p[maxn];
inline void init()
{
	for (int i = 0; i < maxn; i++) p[i] = mp(INFLL, INFLL);
}
inline bool comp1(pii a, pii b)
{
	return a.AA < b.AA;
}
inline bool comp2(pii a, pii b)
{
	return a.BB < b.BB;
}
map<pii, LL> ms;
map<pii, bool> mv;

int main()
{
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		scanf("%d%d", &p[i].AA, &p[i].BB);
		ms[p[i]]++;
	}

	LL ans = 0;
	sort(p, p + n,comp1);
	for (int i = 0; i < n; i++) cout << p[i].AA << " " << p[i].BB << endl;
	for (int i = 0; i < n; i++)
	{
		LL cnt = 1;
		while (p[i].AA == p[i + 1].AA&&i<n) { i++; cnt++; }
		ans += cnt*(cnt - 1) / 2;
	}

	sort(p, p + n, comp2);
	for (int i = 0; i < n; i++)
	{
		LL cnt = 1;
		while (p[i].BB == p[i + 1].BB&&i<n){ i++; cnt++; }
		ans += (cnt - 1)*cnt / 2;
	}
	for (int i = 0; i < n; i++)
	{
		if (ms[p[i]]>1 && !mv[p[i]]) { ans -= ms[p[i]] * (ms[p[i]] - 1) / 2; mv[p[i]] = true; }
	}
	cout << ans;
	//system("pause");
	return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<cmath>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define mem(x) memset(x,0,sizeof x)
#define LL long long
#define pii pair<int,int>
#define AA first
#define BB second
#define mp make_pair
const int maxn = 200010;
int n;
pii p[maxn];
inline bool comp1(pii a, pii b)
{
	return a.AA < b.AA;
}
inline bool comp2(pii a, pii b)
{
	return a.BB < b.BB;
}
map<pii, int> ms;
map<pii, bool> mv;

int main()
{
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		scanf("%d%d", &p[i].AA, &p[i].BB);
		ms[p[i]]++;
	}

	LL ans = 0;
	sort(p, p + n,comp1);
	for (int i = 0; i < n; i++)
	{
		LL cnt = 1;
		while (p[i].AA == p[i + 1].AA) { i++; cnt++; }
		ans += cnt*(cnt - 1) / 2;
	}
	//cout << ans << endl;

	sort(p, p + n, comp2);
	for (int i = 0; i < n; i++)
	{
		LL cnt = 1;
		while (p[i].BB == p[i + 1].BB){ i++; cnt++; }
		ans += (cnt - 1)*cnt / 2;
	}
	//cout << ans << endl;
	for (int i = 0; i < n; i++)
	{
		if (ms[p[i]]>1 && !mv[p[i]]) { ans -= ms[p[i]] * (ms[p[i]] - 1) / 2; mv[p[i]] = true; }
	}
	cout << ans;
	//system("pause");
	return 0;
}


#include <bits/stdc++.h>
using namespace std;

struct COORD {
    int x;
    int y;
};

bool sortx(COORD x, COORD y) {
    return x.x < y.x;
}

bool sorty(COORD x, COORD y) {
    return x.y < y.y;
}

int distributeX(vector<COORD> sortX) {
    vector<vector<COORD> > x;
    int counter = 1;
    vector<COORD> tmp;
    int temp = 0;
    tmp.push_back(sortX[temp]);

    for (int i = 1; i < sortX.size(); i++) {
        if (sortX[i].x != sortX[temp].x) {
            temp = i;
            x.push_back(tmp);
            tmp.clear();
        }
        tmp.push_back(sortX[i]);
    }
    x.push_back(tmp);

    for (int i = 0; i < x.size(); i++) {
        sort(x[i].begin(), x[i].end(), sorty);
    }

    int final_count = 0;
    temp = 0;

    for (int i = 0; i < x.size(); i++) {
        int counter = 1;

        for (int j = 1; j < x[i].size(); j++) {
            if (x[i][j - 1].y == x[i][j].y) {
                counter++;
            } else {
                temp += counter * (counter - 1) / 2;
                counter = 1;
            }
        }
        temp += counter * (counter - 1) / 2;
        final_count += (x[i].size() * (x[i].size() - 1) / 2) - temp;
        temp = 0;
    }

    return final_count;
}
int distributeY(vector<COORD> sortY) {
    int counter = 1;
    int final_count = 0;

    for (int i = 1; i < sortY.size(); i++) {
        if(sortY[i - 1].y != sortY[i].y) {
            final_count += counter * (counter - 1) / 2;
            counter = 0;
        }
        counter++;
    }

    final_count += counter * (counter - 1) / 2;

    return final_count;
}

void distance(vector<COORD> coord) {
    vector<COORD> sortX = coord;
    sort(sortX.begin(), sortX.end(), sortx);
    vector<COORD> sortY = coord;
    sort(sortY.begin(), sortY.end(), sorty);

    int ans = distributeX(sortX) + distributeY(sortY);

    cout << ans << endl;

    return ;
}

int main()
{
    int n;
    vector<COORD> coord;

    cin >> n;

    for (int i = 0; i < n; i++) {
        COORD temp;
        cin >> temp.x >> temp.y;
        coord.push_back(temp);
    }

    distance(coord);

    return 0;
}


#include <bits/stdc++.h>
using namespace std;

#define ll unsigned long long

struct COORD {
    ll x;
    ll y;
};

bool sortx(COORD x, COORD y) {
    return x.x < y.x;
}

bool sorty(COORD x, COORD y) {
    return x.y < y.y;
}

ll distributeX(vector<COORD> sortX) {
    vector<vector<COORD> > x;
    vector<COORD> tmp;
    ll temp = 0;
    tmp.push_back(sortX[temp]);

    for (ll i = 1; i < sortX.size(); i++) {
        if (sortX[i].x != sortX[temp].x) {
            temp = i;
            x.push_back(tmp);
            tmp.clear();
        }
        tmp.push_back(sortX[i]);
    }
    x.push_back(tmp);

    for (ll i = 0; i < x.size(); i++) {
        sort(x[i].begin(), x[i].end(), sorty);
    }

    ll final_count = 0;
    temp = 0;

    for (int i = 0; i < x.size(); i++) {
        ll counter = 1;

        for (int j = 1; j < x[i].size(); j++) {
            if (x[i][j - 1].y == x[i][j].y) {
                counter++;
            } else {
                temp += counter * (counter - 1) / 2;
                counter = 1;
            }
        }

        temp += counter * (counter - 1) / 2;
        counter = x[i].size();
        final_count += counter * (counter - 1) / 2 - temp;
        temp = 0;
    }

    return final_count;
}
ll distributeY(vector<COORD> sortY) {
    ll counter = 1;
    ll final_count = 0;

    for (int i = 1; i < sortY.size(); i++) {
        if(sortY[i - 1].y != sortY[i].y) {
            final_count += counter * (counter - 1) / 2;
            counter = 1;
            continue;
        }
        counter++;
    }

    final_count += (counter * (counter - 1)) / 2;
    return final_count;
}

void distance(vector<COORD> coord) {
    vector<COORD> sortX = coord;
    sort(sortX.begin(), sortX.end(), sortx);
    vector<COORD> sortY = coord;
    sort(sortY.begin(), sortY.end(), sorty);

    ll ans = distributeX(sortX) + distributeY(sortY);

    cout << ans << endl;

    return ;
}

int main()
{
    int n;
    vector<COORD> coord;

    cin >> n;

    for (int i = 0; i < n; i++) {
        COORD temp;
        //cin >> temp.x >> temp.y;
        temp.x = 0;
        temp.y = 1;
        coord.push_back(temp);
    }

    distance(coord);

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll unsigned long long

struct COORD {
    ll x;
    ll y;
};

bool sortx(COORD x, COORD y) {
    return x.x < y.x;
}

bool sorty(COORD x, COORD y) {
    return x.y < y.y;
}

ll distributeX(vector<COORD> sortX) {
    vector<vector<COORD> > x;
    int counter = 1;
    vector<COORD> tmp;
    ll temp = 0;
    tmp.push_back(sortX[temp]);

    for (ll i = 1; i < sortX.size(); i++) {
        if (sortX[i].x != sortX[temp].x) {
            temp = i;
            x.push_back(tmp);
            tmp.clear();
        }
        tmp.push_back(sortX[i]);
    }
    x.push_back(tmp);

    for (ll i = 0; i < x.size(); i++) {
        sort(x[i].begin(), x[i].end(), sorty);
    }

    long double final_count = 0;
    temp = 0;

    for (int i = 0; i < x.size(); i++) {
        int counter = 1;

        for (int j = 1; j < x[i].size(); j++) {
            if (x[i][j - 1].y == x[i][j].y) {
                counter++;
            } else {
                temp += counter * (counter - 1) / 2;
                counter = 1;
            }
        }
        temp += counter * (counter - 1) / 2;
        final_count += (x[i].size() * (x[i].size() - 1) / 2) - temp;
        temp = 0;
    }
    return final_count;
}
ll distributeY(vector<COORD> sortY) {
    ll counter = 1;
    ll final_count = 0;

    for (int i = 1; i < sortY.size(); i++) {
        if(sortY[i - 1].y != sortY[i].y) {
            final_count += counter * (counter - 1) / 2;
            counter = 0;
        }
        counter++;
    }

    final_count += (counter * (counter - 1)) / 2;
    return final_count;
}

void distance(vector<COORD> coord) {
    vector<COORD> sortX = coord;
    sort(sortX.begin(), sortX.end(), sortx);
    vector<COORD> sortY = coord;
    sort(sortY.begin(), sortY.end(), sorty);

    ll ans = distributeX(sortX) + distributeY(sortY);

    cout << ans << endl;

    return ;
}

int main()
{
    int n;
    vector<COORD> coord;

    cin >> n;

    for (int i = 0; i < n; i++) {
        COORD temp;
        cin >> temp.x >> temp.y;

        coord.push_back(temp);
    }

    distance(coord);

    return 0;
}


#include <bits/stdc++.h>
using namespace std;

struct COORD {
    int x;
    int y;
};

bool sortx(COORD x, COORD y) {
    return x.x < y.x;
}

bool sorty(COORD x, COORD y) {
    return x.y < y.y;
}

int distributeX(vector<COORD> sortX) {
    vector<vector<COORD> > x;
    int counter = 1;
    vector<COORD> tmp;
    int temp = 0;
    tmp.push_back(sortX[temp]);

    for (int i = 1; i < sortX.size(); i++) {
        if (sortX[i].x != sortX[temp].x) {
            temp = i;
            x.push_back(tmp);
            tmp.clear();
        }
        tmp.push_back(sortX[i]);
    }
    x.push_back(tmp);

    for (int i = 0; i < x.size(); i++) {
        sort(x[i].begin(), x[i].end(), sorty);
    }

    int final_count = 0;

    for (int i = 0; i < x.size(); i++) {
        int counter = 0;

        for (int j = 1; j < x[i].size(); j++) {
            if (x[i][j - 1].y == x[i][j].y) {
                counter++;
            }
        }
        final_count += (x[i].size() * (x[i].size() - 1) / 2) - counter;
    }

    return final_count;
}
int distributeY(vector<COORD> sortY) {
    int counter = 1;
    int final_count = 0;

    for (int i = 1; i < sortY.size(); i++) {
        if(sortY[i - 1].y != sortY[i].y) {
            final_count += counter * (counter - 1) / 2;
            counter = 0;
        }
        counter++;
    }

    final_count += counter * (counter - 1) / 2;

    return final_count;
}

void distance(vector<COORD> coord) {
    vector<COORD> sortX = coord;
    sort(sortX.begin(), sortX.end(), sortx);
    vector<COORD> sortY = coord;
    sort(sortY.begin(), sortY.end(), sorty);

    int ans = distributeX(sortX) + distributeY(sortY);

    cout << ans << endl;

    return ;
}

int main()
{
    int n;
    vector<COORD> coord;

    cin >> n;

    for (int i = 0; i < n; i++) {
        COORD temp;
        cin >> temp.x >> temp.y;
        coord.push_back(temp);
    }

    distance(coord);

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll unsigned long long

struct COORD {
    ll x;
    ll y;
};

bool sortx(COORD x, COORD y) {
    return x.x < y.x;
}

bool sorty(COORD x, COORD y) {
    return x.y < y.y;
}

ll distributeX(vector<COORD> sortX) {
    vector<vector<COORD> > x;
    int counter = 1;
    vector<COORD> tmp;
    ll temp = 0;
    tmp.push_back(sortX[temp]);

    for (ll i = 1; i < sortX.size(); i++) {
        if (sortX[i].x != sortX[temp].x) {
            temp = i;
            x.push_back(tmp);
            tmp.clear();
        }
        tmp.push_back(sortX[i]);
    }
    x.push_back(tmp);

    for (ll i = 0; i < x.size(); i++) {
        sort(x[i].begin(), x[i].end(), sorty);
    }

    long double final_count = 0;
    temp = 0;

    for (int i = 0; i < x.size(); i++) {
        int counter = 1;

        for (int j = 1; j < x[i].size(); j++) {
            if (x[i][j - 1].y == x[i][j].y) {
                counter++;
            } else {
                temp += counter * (counter - 1) / 2;
                counter = 1;
            }
        }
        temp += counter * (counter - 1) / 2;
        final_count += (x[i].size() * (x[i].size() - 1) / 2) - temp;
        temp = 0;
    }
    return final_count;
}
ll distributeY(vector<COORD> sortY) {
    ll counter = 1;
    ll final_count = 0;

    for (int i = 1; i < sortY.size(); i++) {
        if(sortY[i - 1].y != sortY[i].y) {
            final_count += counter * (counter - 1) / 2;
            counter = 0;
        }
        counter++;
    }

    final_count += (counter * (counter - 1)) / 2;
    return final_count;
}

void distance(vector<COORD> coord) {
    vector<COORD> sortX = coord;
    sort(sortX.begin(), sortX.end(), sortx);
    vector<COORD> sortY = coord;
    sort(sortY.begin(), sortY.end(), sorty);

    ll ans = distributeX(sortX) + distributeY(sortY);

    cout << ans << endl;

    return ;
}

int main()
{
    int n;
    vector<COORD> coord;

    cin >> n;

    for (int i = 0; i < n; i++) {
        COORD temp;
        temp.x = 0;
        temp.y = 1;
        coord.push_back(temp);
    }

    distance(coord);

    return 0;
}


#include <bits/stdc++.h>
using namespace std;

#define ll unsigned long long

struct COORD {
    ll x;
    ll y;
};

bool sortx(COORD x, COORD y) {
    return x.x < y.x;
}

bool sorty(COORD x, COORD y) {
    return x.y < y.y;
}

ll distributeX(vector<COORD> sortX) {
    vector<vector<COORD> > x;
    vector<COORD> tmp;
    ll temp = 0;
    tmp.push_back(sortX[temp]);

    for (ll i = 1; i < sortX.size(); i++) {
        if (sortX[i].x != sortX[temp].x) {
            temp = i;
            x.push_back(tmp);
            tmp.clear();
        }
        tmp.push_back(sortX[i]);
    }
    x.push_back(tmp);

    for (ll i = 0; i < x.size(); i++) {
        sort(x[i].begin(), x[i].end(), sorty);
    }

    ll final_count = 0;
    temp = 0;

    for (int i = 0; i < x.size(); i++) {
        ll counter = 1;

        for (int j = 1; j < x[i].size(); j++) {
            if (x[i][j - 1].y == x[i][j].y) {
                counter++;
            } else {
                temp += counter * (counter - 1) / 2;
                counter = 1;
            }
        }

        temp += counter * (counter - 1) / 2;
        counter = x[i].size();
        final_count += counter * (counter - 1) / 2 - temp;
        temp = 0;
    }

    return final_count;
}
ll distributeY(vector<COORD> sortY) {
    ll counter = 1;
    ll final_count = 0;

    for (int i = 1; i < sortY.size(); i++) {
        if(sortY[i - 1].y != sortY[i].y) {
            final_count += counter * (counter - 1) / 2;
            counter = 1;
            continue;
        }
        counter++;
    }

    final_count += (counter * (counter - 1)) / 2;
    return final_count;
}

void distance(vector<COORD> coord) {
    vector<COORD> sortX = coord;
    sort(sortX.begin(), sortX.end(), sortx);
    vector<COORD> sortY = coord;
    sort(sortY.begin(), sortY.end(), sorty);

    ll ans = distributeX(sortX) + distributeY(sortY);

    cout << ans << endl;

    return ;
}

int main()
{
    int n;
    vector<COORD> coord;

    cin >> n;

    for (int i = 0; i < n; i++) {
        COORD temp;
        cin >> temp.x >> temp.y;

        coord.push_back(temp);
    }

    distance(coord);

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long

struct COORD {
    ll x;
    ll y;
};

bool sortx(COORD x, COORD y) {
    return x.x < y.x;
}

bool sorty(COORD x, COORD y) {
    return x.y < y.y;
}

ll distributeX(vector<COORD> sortX) {
    vector<vector<COORD> > x;
    int counter = 1;
    vector<COORD> tmp;
    ll temp = 0;
    tmp.push_back(sortX[temp]);

    for (ll i = 1; i < sortX.size(); i++) {
        if (sortX[i].x != sortX[temp].x) {
            temp = i;
            x.push_back(tmp);
            tmp.clear();
        }
        tmp.push_back(sortX[i]);
    }
    x.push_back(tmp);

    for (ll i = 0; i < x.size(); i++) {
        sort(x[i].begin(), x[i].end(), sorty);
    }

    ll final_count = 0;
    temp = 0;

    for (int i = 0; i < x.size(); i++) {
        int counter = 1;

        for (int j = 1; j < x[i].size(); j++) {
            if (x[i][j - 1].y == x[i][j].y) {
                counter++;
            } else {
                temp += counter * (counter - 1) / 2;
                counter = 1;
            }
        }
        temp += counter * (counter - 1) / 2;
        final_count += (x[i].size() * (x[i].size() - 1) / 2) - temp;
        temp = 0;
    }

    return final_count;
}
ll distributeY(vector<COORD> sortY) {
    int counter = 1;
    ll final_count = 0;

    for (int i = 1; i < sortY.size(); i++) {
        if(sortY[i - 1].y != sortY[i].y) {
            final_count += counter * (counter - 1) / 2;
            counter = 0;
        }
        counter++;
    }

    final_count += counter * (counter - 1) / 2;

    return final_count;
}

void distance(vector<COORD> coord) {
    vector<COORD> sortX = coord;
    sort(sortX.begin(), sortX.end(), sortx);
    vector<COORD> sortY = coord;
    sort(sortY.begin(), sortY.end(), sorty);

    ll ans = distributeX(sortX) + distributeY(sortY);

    cout << ans << endl;

    return ;
}

int main()
{
    int n;
    vector<COORD> coord;

    cin >> n;

    for (int i = 0; i < n; i++) {
        COORD temp;
        cin >> temp.x >> temp.y;
        coord.push_back(temp);
    }

    distance(coord);

    return 0;
}


#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
using namespace std;

int main()
{
    int n,num[200005][2];
    while(scanf("%d",&n)!=EOF)
    {
        long long ans=0;
        for(int i=1;i<=n;i++)   scanf("%d %d",&num[i][0],&num[i][1]);
        for(int i=1;i<=n;i++)
        {
            for(int j=i+1;j<=n;j++)
            {
                if(num[i][0]==num[j][0]||num[i][1]==num[j][1])  ans++;
            }
        }
        printf("%I64d\n",ans);
    }
    return 0;
}


#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <map>
#include <set>
using namespace std;

int main()
{
    int n;
    while(scanf("%d",&n)!=EOF)
    {
        map <int,int> num1,num2;
        map <pair<int,int>,int> memo;
        long long ans=0;
        for(int i=1;i<=n;i++)
        {
            int a,b;
            scanf("%d %d",&a,&b);
            num1[a]++;
            num2[b]++;
            memo[make_pair(a,b)]++;
        }
        map <int,int> ::iterator iter;
        for(iter=num1.begin();iter!=num1.end();iter++)
        {
            int memo=iter->second;
            ans+=memo*(memo-1)/2;
        }
        for(iter=num2.begin();iter!=num2.end();iter++)
        {
            int memo=iter->second;
            ans+=memo*(memo-1)/2;
        }
        map<pair<int,int>,int>::iterator i;
        for(i=memo.begin();i!=memo.end();i++)
        {
            ans-=i->second;
        }
        printf("%I64d\n",ans);
    }
    return 0;
}


#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <map>
#include <set>
using namespace std;

int main()
{
    int n;
    while(scanf("%d",&n)!=EOF)
    {
        map <int,int> num1,num2;
        map <pair<int,int>,int> memo;
        long long ans=0;
        for(int i=1;i<=n;i++)
        {
            int a,b;
            scanf("%d %d",&a,&b);
            num1[a]++;
            num2[b]++;
            memo[make_pair(a,b)]++;
        }
        map <int,int> ::reverse_iterator iter;
        for(iter=num1.rbegin();iter!=num1.rend();iter++)
        {
            int memo=iter->second;
            ans+=memo*(memo-1)/2;
        }
        for(iter=num2.rbegin();iter!=num2.rend();iter++)
        {
            int memo=iter->second;
            ans+=memo*(memo-1)/2;
        }
        map<pair<int,int>,int>::iterator i;
        for(i=memo.begin();i!=memo.end();i++)
        {
            int memo=i->second;
            ans-=memo*(memo-1)/2;
        }
        printf("%I64d\n",ans);
    }
    return 0;
}


#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <map>
#include <set>
using namespace std;

int main()
{
    int n;
    while(scanf("%d",&n)!=EOF)
    {
        map <int,int> num1,num2;
        map <pair<int,int>,int> memo;
        long long ans=0;
        for(int i=1;i<=n;i++)
        {
            int a,b;
            scanf("%d %d",&a,&b);
            num1[a]++;
            num2[b]++;
            memo[make_pair(a,b)]++;
        }
        map <int,int> ::iterator iter;
        for(iter=num1.begin();iter!=num1.end();iter++)
        {
            int memo=iter->second;
            ans+=memo*(memo-1)/2;
        }
        for(iter=num2.begin();iter!=num2.end();iter++)
        {
            int memo=iter->second;
            ans+=memo*(memo-1)/2;
        }
        map<pair<int,int>,int>::iterator i;
        for(i=memo.begin();i!=memo.end();i++)
        {
            int memo=i->second;
            if(memo>1)  ans-=memo-1;
        }
        printf("%I64d\n",ans);
    }
    return 0;
}


#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <map>
#include <set>
using namespace std;

int main()
{
    int n;
    while(scanf("%d",&n)!=EOF)
    {
        map <int,int> num1,num2;
        map <pair<int,int>,int> memo;
        long long ans=0;
        for(int i=1;i<=n;i++)
        {
            int a,b;
            scanf("%d %d",&a,&b);
            num1[a]++;
            num2[b]++;
            memo[make_pair(a,b)]++;
        }
        map <int,int> ::iterator iter;
        for(iter=num1.begin();iter!=num1.end();iter++)
        {
            int memo=iter->second;
            ans+=memo*(memo-1)/2;
        }
        for(iter=num2.begin();iter!=num2.end();iter++)
        {
            int memo=iter->second;
            ans+=memo*(memo-1)/2;
        }
        map<pair<int,int>,int>::iterator i;
        for(i=memo.begin();i!=memo.end();i++)
        {
            int memo=i->second;
            if(memo>1)  ans-=memo;
        }
        printf("%I64d\n",ans);
    }
    return 0;
}


#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <map>
#include <set>
using namespace std;

int main()
{
    int n;
    while(scanf("%d",&n)!=EOF)
    {
        map <int,int> num1,num2;
        map <pair<int,int>,int> memo;
        long long ans=0;
        for(int i=1;i<=n;i++)
        {
            int a,b;
            scanf("%d %d",&a,&b);
            ans+=num1[a];
            ans+=num2[b];
            ans-=memo[make_pair(a,b)];
            num1[a]++;
            num2[b]++;
            memo[make_pair(a,b)]++;
        }
        printf("%I64d\n",ans);
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> Pair;
int n;
Pair p[200005];
bool cmp1(Pair a,Pair b)
{return a.first^b.first?a.first<b.first:a.second<b.second;}
bool cmp2(Pair a,Pair b)
{return a.second<b.second;}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d%d",&p[i].first,&p[i].second);
	sort(p+1,p+1+n,cmp1);
	long long ans=0;
	int sum=0,tmpsum=0;
	for(int i=1;i<=n;i++)
	{
		if(i==1||p[i].first!=p[i-1].first)
		{
			tmpsum=1;
		}
		else
		{
			if(p[i].second!=p[i-1].second)
				sum+=tmpsum,tmpsum=0;
			tmpsum++;
			ans+=sum;
		}
	}
	sort(p+1,p+1+n,cmp2);
	for(int i=1;i<=n;i++)
	{
		if(i==1||p[i].second!=p[i-1].second)
		{
			ans+=1ll*sum*(sum-1)/2;
			sum=1;
		}
		else
		{
			sum++;
		}
	}
	ans+=1ll*sum*(sum-1)/2;
	printf("%I64d\n",ans);
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> Pair;
int n;
Pair p[200005];
bool cmp1(Pair a,Pair b)
{return a.first^b.first?a.first<b.first:a.second<b.second;}
bool cmp2(Pair a,Pair b)
{return a.second<b.second;}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d%d",&p[i].first,&p[i].second);
	sort(p+1,p+1+n,cmp1);
	long long ans=0;
	int sum=0,tmpsum=0;
	for(int i=1;i<=n;i++)
	{
		if(i==1||p[i].first!=p[i-1].first)
		{
			tmpsum=1;
		}
		else
		{
			if(p[i].second!=p[i-1].second)
				sum+=tmpsum,tmpsum=0;
			tmpsum++;
			ans+=sum;
		}
	}
	sort(p+1,p+1+n,cmp2);
	sum=0;
	for(int i=1;i<=n;i++)
	{
		if(i==1||p[i].second!=p[i-1].second)
		{
			ans+=1ll*sum*(sum-1)/2;
			sum=1;
		}
		else
		{
			sum++;
		}
	}
	ans+=1ll*sum*(sum-1)/2;
	printf("%I64d\n",ans);
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> Pair;
int n;
Pair p[200005];
bool cmp1(Pair a,Pair b)
{return a.first^b.first?a.first<b.first:a.second<b.second;}
bool cmp2(Pair a,Pair b)
{return a.second<b.second;}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d%d",&p[i].first,&p[i].second);
	sort(p+1,p+1+n,cmp1);
	long long ans=0;
	int sum=0,tmpsum=0;
	for(int i=1;i<=n;i++)
	{
		if(i==1||p[i].first!=p[i-1].first)
		{
			sum=1;
		}
		else
		{
			if(p[i].second!=p[i-1].second)
				sum+=tmpsum,tmpsum=0;
			tmpsum++;
			ans+=sum;
		}
	}
	sort(p+1,p+1+n,cmp2);
	for(int i=1;i<=n;i++)
	{
		if(i==1||p[i].second!=p[i-1].second)
		{
			ans+=1ll*sum*(sum-1)/2;
			sum=1;
		}
		else
		{
			sum++;
		}
	}
	ans+=1ll*sum*(sum-1)/2;
	printf("%I64d\n",ans);
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> Pair;
int n;
Pair p[200005];
bool cmp1(Pair a,Pair b)
{return a.first^b.first?a.first<b.first:a.second<b.second;}
bool cmp2(Pair a,Pair b)
{return a.second<b.second;}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d%d",&p[i].first,&p[i].second);
	sort(p+1,p+1+n,cmp1);
	long long ans=0;
	int sum=0,tmpsum=0;
	for(int i=1;i<=n;i++)
	{
		if(i==1||p[i].first!=p[i-1].first)
		{
			sum=0;
			tmpsum=1;
		}
		else
		{
			if(p[i].second!=p[i-1].second)
				sum+=tmpsum,tmpsum=0;
			tmpsum++;
			ans+=sum;
		}
	}
	sort(p+1,p+1+n,cmp2);
	sum=0;
	for(int i=1;i<=n;i++)
	{
		if(i==1||p[i].second!=p[i-1].second)
		{
			ans+=1ll*sum*(sum-1)/2;
			sum=1;
		}
		else
		{
			sum++;
		}
	}
	ans+=1ll*sum*(sum-1)/2;
	printf("%I64d\n",ans);
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> Pair;
int n;
Pair p[200005];
bool cmp1(Pair a,Pair b)
{return a.first^b.first?a.first<b.first:a.second<b.second;}
bool cmp2(Pair a,Pair b)
{return a.second<b.second;}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d%d",&p[i].first,&p[i].second);
	sort(p+1,p+1+n,cmp1);
	long long ans=0;
	int sum=0;
	for(int i=1;i<=n;i++)
	{
		if(i==1||p[i].first!=p[i-1].first)
		{
			ans+=1ll*sum*(sum-1)/2;
			sum=1;
		}
		else sum++;
	}
	ans+=1ll*sum*(sum-1)/2;
	sum=0;
	for(int i=1;i<=n;i++)
	{
		if(i==1||p[i].first!=p[i-1].first||p[i].second!=p[i-1].second)
		{
			ans-=1ll*sum*(sum-1)/2;
			sum=1;
		}
		else sum++;
	}
	ans-=1ll*sum*(sum-1)/2;
	sort(p+1,p+1+n,cmp2);
	sum=0;
	for(int i=1;i<=n;i++)
	{
		if(i==1||p[i].second!=p[i-1].second)
		{
			ans+=1ll*sum*(sum-1)/2;
			sum=1;
		}
		else sum++;
	}
	ans+=1ll*sum*(sum-1)/2;
	printf("%I64d\n",ans);
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> Pair;
int n;
Pair p[200005];
bool cmp1(Pair a,Pair b)
{return a.first^b.first?a.first<b.first:a.second<b.second;}
bool cmp2(Pair a,Pair b)
{return a.second<b.second;}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d%d",&p[i].first,&p[i].second);
	sort(p+1,p+1+n,cmp1);
	long long ans=0;
	int sum=0;
	for(int i=1;i<=n;i++)
	{
		if(i==1||p[i].first!=p[i-1].first)
		{
			ans+=1ll*sum*(sum-1)/2;
			sum=1;
		}
		else
		{
			sum++;
		}
	}
	ans+=1ll*sum*(sum-1)/2;
	sum=0;
	for(int i=1;i<=n;i++)
	{
		if(i==1||p[i].first!=p[i-1].first||p[i].second!=p[i-1].second)
		{
			ans-=1ll*sum*(sum-1)/2;
			sum=1;
		}
		else sum++;
	}
	sort(p+1,p+1+n,cmp2);
	sum=0;
	for(int i=1;i<=n;i++)
	{
		if(i==1||p[i].second!=p[i-1].second)
		{
			ans+=1ll*sum*(sum-1)/2;
			sum=1;
		}
		else
		{
			sum++;
		}
	}
	ans+=1ll*sum*(sum-1)/2;
	printf("%I64d\n",ans);
	return 0;
}


#include <bits/stdc++.h>
#include <utility>

#define debug(x) {cout << #x << " := " << x << endl;}
#define Debug(x, y) {cout << x << ' ' << y << endl;}
#define foru(i, _a, _b) for(int i = _a; i <= _b; ++i)
#define ford(i, _a, _b) for(int i = _a; i >= _b; --i)
#define rep(i, _n) for(int i = 0; i < _n; i++)
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define sz size
#define MODE 0
#define impf() {freopen("in.txt", "r", stdin);}
#define ii pair<int, int>
#define vi vector<int>
#define msi map<string, int>
#define si set<int>

typedef long long ll;

const int maxN = 2e5 + 5;

using namespace std;

bool xc(ii a, ii b)
{
    return a.fi < b.fi;
}

bool yc(ii a, ii b)
{
    return a.se < b.se || (a.se == b.se && a.fi < b.fi);
}

ii p[maxN];

int main()
{
    if (MODE) impf();
    //ios_base::sync_with_stdio(false);
    int n;
    ll res = 0;

    scanf("%d", &n);
    rep(i, n)
    {
        scanf("%d %d", &p[i].fi, &p[i].se);
    }

    int Count = 1;
    sort(p, p + n, xc);
    rep(i, n - 1)
    {
        if (p[i + 1].fi > p[i].fi)
        {
            Count = 1;
        }
        else
        {
            res += Count;
            Count ++;
        }
    }

    Count = 1;
    sort(p, p + n, yc);
    rep(i, n - 1)
    {
        if (p[i + 1].se > p[i].se)
        {
            Count = 1;
        }
        else
        {
            res += Count;
            Count ++;
        }
    }
    Count = 1;
    rep(i, n - 1)
    {
        if (p[i + 1] != p[i])
        {
            Count = 1;
        }
        else
        {
            res -= Count;
            Count ++;
        }
    }
    cout << res;
    return 0;
}


#include <bits/stdc++.h>
#include <utility>

#define debug(x) {cout << #x << " := " << x << endl;}
#define Debug(x, y) {cout << x << ' ' << y << endl;}
#define foru(i, _a, _b) for(int i = _a; i <= _b; ++i)
#define ford(i, _a, _b) for(int i = _a; i >= _b; --i)
#define rep(i, _n) for(int i = 0; i < _n; i++)
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define sz size
#define MODE 0
#define impf() {freopen("in.txt", "r", stdin);}
#define ii pair<int, int>
#define vi vector<int>
#define msi map<string, int>
#define si set<int>

typedef long long ll;

const int maxN = 2e5 + 5;

using namespace std;

bool xc(ii a, ii b)
{
    return a.fi <= b.fi;
}

bool yc(ii a, ii b)
{
    return a.se <= b.se;
}

ii p[maxN];

int main()
{
    if (MODE) impf();
    //ios_base::sync_with_stdio(false);
    int n;
    ll res = 0;

    scanf("%d", &n);
    rep(i, n)
    {
        scanf("%d %d", &p[i].fi, &p[i].se);
    }

    int Count = 1;
    sort(p, p + n, xc);
    rep(i, n - 1)
    {
        if (p[i + 1].fi > p[i].fi)
        {
            Count = 1;
        }
        else
        {
            res += Count;
            Count ++;
        }
    }
    Count = 1;
    sort(p, p + n, yc);
    rep(i, n - 1)
    {
        if (p[i + 1].se > p[i].se)
        {
            Count = 1;
        }
        else
        {
            res += Count;
            Count ++;
        }
    }
    Count = 1;
    rep(i, n - 1)
    {
        if (p[i + 1] != p[i])
        {
            Count = 1;
        }
        else
        {
            res -= Count;
            Count ++;
        }
    }
    cout << res;
    return 0;
}


#include <bits/stdc++.h>
#include <utility>

#define debug(x) {cout << #x << " := " << x << endl;}
#define Debug(x, y) {cout << x << ' ' << y << endl;}
#define foru(i, _a, _b) for(int i = _a; i <= _b; ++i)
#define ford(i, _a, _b) for(int i = _a; i >= _b; --i)
#define rep(i, _n) for(int i = 0; i < _n; i++)
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define sz size
#define MODE 0
#define impf() {freopen("in.txt", "r", stdin);}
#define ii pair<int, int>
#define vi vector<int>
#define msi map<string, int>
#define si set<int>

typedef long long ll;

const int maxN = 2e5 + 5;

using namespace std;

bool xc(ii a, ii b)
{
    return a.fi <= b.fi;
}

bool yc(ii a, ii b)
{
    return a.se <= b.se;
}

ii p[maxN];

int main()
{
    if (MODE) impf();
    //ios_base::sync_with_stdio(false);
    int n;
    ll res = 0;

    scanf("%d", &n);
    rep(i, n)
    {
        scanf("%d %d", &p[i].fi, &p[i].se);
    }

    int Count = 1;
    sort(p, p + n, xc);
    rep(i, n - 1)
    {
        if (p[i + 1].fi > p[i].fi)
        {
            Count = 1;
        }
        else
        {
            res += Count;
            Count ++;
        }
    }
    Count = 1;
    sort(p, p + n, yc);
    rep(i, n - 1)
    {
        if (p[i + 1].se > p[i].se)
        {
            Count = 1;
        }
        else
        {
            res += Count;
            Count ++;
        }
    }
    Count = 1;
    rep(i, n - 1)
    {
        if (p[i + 1] != p[i])
        {
            Count = 1;
        }
        else
        {
            res -= Count;
            Count ++;
        }
    }
    printf("%d", res);
    return 0;
}


#include <bits/stdc++.h>
#include <utility>

#define debug(x) {cout << #x << " := " << x << endl;}
#define Debug(x, y) {cout << x << ' ' << y << endl;}
#define foru(i, _a, _b) for(int i = _a; i <= _b; ++i)
#define ford(i, _a, _b) for(int i = _a; i >= _b; --i)
#define rep(i, _n) for(int i = 0; i < _n; i++)
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define sz size
#define MODE 0
#define impf() {freopen("in.txt", "r", stdin);}
#define ii pair<int, int>
#define vi vector<int>
#define msi map<string, int>
#define si set<int>

typedef long long ll;

const int maxN = 2e5 + 5;

using namespace std;

bool xc(ii a, ii b)
{
    return a.fi < b.fi;
}

bool yc(ii a, ii b)
{
    return a.se < b.se;
}

ii p[maxN];

int main()
{
    if (MODE) impf();
    //ios_base::sync_with_stdio(false);
    int n;
    ll res = 0;

    scanf("%d", &n);
    rep(i, n)
    {
        scanf("%d %d", &p[i].fi, &p[i].se);
    }

    int Count = 1;
    sort(p, p + n, xc);
    rep(i, n - 1)
    {
        if (p[i + 1].fi > p[i].fi)
        {
            Count = 1;
        }
        else
        {
            res += Count;
            Count ++;
        }
    }

    Count = 1;
    sort(p, p + n, yc);
    rep(i, n - 1)
    {
        if (p[i + 1].se > p[i].se)
        {
            Count = 1;
        }
        else
        {
            res += Count;
            Count ++;
        }
    }
    Count = 1;
    rep(i, n - 1)
    {
        if (p[i + 1].fi != p[i].fi || p[i + 1].se != p[i].se)
        {
            Count = 1;
        }
        else
        {
            res -= Count;
            Count ++;
        }
    }
    cout << res;
    return 0;
}


#include <bits/stdc++.h>
#include <utility>

#define debug(x) {cout << #x << " := " << x << endl;}
#define Debug(x, y) {cout << x << ' ' << y << endl;}
#define foru(i, _a, _b) for(int i = _a; i <= _b; ++i)
#define ford(i, _a, _b) for(int i = _a; i >= _b; --i)
#define rep(i, _n) for(int i = 0; i < _n; i++)
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define sz size
#define MODE 0
#define impf() {freopen("in.txt", "r", stdin);}
#define ii pair<int, int>
#define vi vector<int>
#define msi map<string, int>
#define si set<int>

typedef long long ll;

const int maxN = 2e5 + 5;

using namespace std;

bool xc(ii a, ii b)
{
    return a.fi <= b.fi;
}

bool yc(ii a, ii b)
{
    return a.se <= b.se;
}

int main()
{
    if (MODE) impf();
    //ios_base::sync_with_stdio(false);
    int n;
    ii p[maxN];
    ll res = 0;

    scanf("%d", &n);
    rep(i, n)
    {
        scanf("%d %d", &p[i].fi, &p[i].se);
    }

    int Count = 1;
    sort(p, p + n, xc);
    rep(i, n - 1)
    {
        if (p[i + 1].fi > p[i].fi)
        {
            Count = 1;
        }
        else
        {
            res += Count;
            Count ++;
        }
    }
    Count = 1;
    sort(p, p + n, yc);
    rep(i, n - 1)
    {
        if (p[i + 1].se > p[i].se)
        {
            Count = 1;
        }
        else
        {
            res += Count;
            Count ++;
        }
    }
    Count = 1;
    rep(i, n - 1)
    {
        if (p[i + 1] != p[i])
        {
            Count = 1;
        }
        else
        {
            res -= Count;
            Count ++;
        }
    }
    printf("%d", res);
    return 0;
}


#include <bits/stdc++.h>
#include <utility>

#define debug(x) {cout << #x << " := " << x << endl;}
#define Debug(x, y) {cout << x << ' ' << y << endl;}
#define foru(i, _a, _b) for(int i = _a; i <= _b; ++i)
#define ford(i, _a, _b) for(int i = _a; i >= _b; --i)
#define rep(i, _n) for(int i = 0; i < _n; i++)
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define sz size
#define MODE 0
#define impf() {freopen("in.txt", "r", stdin);}
#define ii pair<int, int>
#define vi vector<int>
#define msi map<string, int>
#define si set<int>

typedef long long ll;

const int maxN = 2e5 + 5;

using namespace std;

bool xc(ii a, ii b)
{
    return a.fi < b.fi;
}

bool yc(ii a, ii b)
{
    return a.se < b.se;
}

ii p[maxN];

int main()
{
    if (MODE) impf();
    //ios_base::sync_with_stdio(false);
    int n;
    ll res = 0;

    scanf("%d", &n);
    rep(i, n)
    {
        scanf("%d %d", &p[i].fi, &p[i].se);
    }

    int Count = 1;
    sort(p, p + n, xc);
    rep(i, n - 1)
    {
        if (p[i + 1].fi > p[i].fi)
        {
            Count = 1;
        }
        else
        {
            res += Count;
            Count ++;
        }
    }

    Count = 1;
    sort(p, p + n, yc);
    rep(i, n - 1)
    {
        if (p[i + 1].se > p[i].se)
        {
            Count = 1;
        }
        else
        {
            res += Count;
            Count ++;
        }
    }
    Count = 1;
    rep(i, n - 1)
    {
        if (p[i + 1] != p[i])
        {
            Count = 1;
        }
        else
        {
            res -= Count;
            Count ++;
        }
    }
    cout << res;
    return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

bool comp(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second<b.second;
}

int main(int argc, char const *argv[])
{
	int n,i,x,y;
	cin>>n;
	vector<pair<int,int> > a;
	a.reserve(n);

	for (int i = 0; i < n; ++i)
	{
		cin>>x>>y;
		a.push_back(make_pair(x,y));
	}

	vector<pair<int,int > >::iterator it;

	sort(a.begin(),a.end());

	long long int count = 1,ans=0;

	for (i = 1; i != n; ++i)
	{
		if(a[i].first==a[i-1].first)
			count++;
		else
		{
			ans=ans+(count*(count-1))/2;
			count = 1;
		}
	}

	ans=ans+(count*(count-1))/2;

	count =1;

	for (i = 1; i != n; ++i)
	{
		if(a[i].first==a[i-1].first&&a[i].second==a[i-1].second)
			count++;
		else
		{
			ans=ans-(count*(count-1))/2;
			count = 1;
		}
	}
	ans=ans-(count*(count-1))/2;

	count = 1;

	sort(a.begin(), a.end(),comp);

	for (i = 1; i != n; ++i)
	{
		if(a[i].second==a[i-1].second)
			count++;
		else
		{
			ans=ans+(count*(count-1))/2;
			count = 1;
		}
	}

	ans=ans+(count*(count-1))/2;

	cout<<ans<<endl;
	return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

bool comp(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second<b.second;
}

int main(int argc, char const *argv[])
{
	int n,i,x,y;
	cin>>n;
	vector<pair<int,int> > a;
	a.reserve(n);

	for (int i = 0; i < n; ++i)
	{
		cin>>x>>y;
		a.push_back(make_pair(x,y));
	}

	vector<pair<int,int > >::iterator it;

	sort(a.begin(),a.end());

	long long int count = 1,ans=0;

	for (i = 1; i != n; ++i)
	{
		if(a[i].first==a[i-1].first)
			count++;
		else
		{
			ans=ans+(count*(count-1))/2;
			count = 1;
		}
	}

	ans=ans+(count*(count-1))/2;

	sort(a.begin(), a.end(),comp);

	count =1;

	for (i = 1; i != n; ++i)
	{
		if(a[i].first==a[i-1].first&&a[i].second==a[i-1].second)
			count++;
		else
		{
			ans=ans-(count*(count-1))/2;
			count = 1;
		}
	}
	ans=ans-(count*(count-1))/2;

	count = 1;

	for (i = 1; i != n; ++i)
	{
		if(a[i].second==a[i-1].second)
			count++;
		else
		{
			ans=ans+(count*(count-1))/2;
			count = 1;
		}
	}

	ans=ans+(count*(count-1))/2;

	cout<<ans<<endl;
	return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

bool comp(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second<b.second;
}

int main(int argc, char const *argv[])
{
	int n,i,x,y;
	cin>>n;
	vector<pair<int,int> > a;
	a.reserve(n);

	for (int i = 0; i < n; ++i)
	{
		cin>>x>>y;
		a.push_back(make_pair(x,y));
	}

	vector<pair<int,int > >::iterator it;

	sort(a.begin(),a.end());

	int count = 1,ans=0;

	for (i = 1; i != n; ++i)
	{
		if(a[i].first==a[i-1].first)
			count++;
		else
		{
			ans=ans+(count*(count-1))/2;
			count = 1;
		}
	}

	ans=ans+(count*(count-1))/2;

	sort(a.begin(), a.end(),comp);

	count =1;

	for (i = 1; i != n; ++i)
	{
		if(a[i].first==a[i-1].first&&a[i].second==a[i-1].second)
			count++;
		else
		{
			ans=ans-(count*(count-1))/2;
			count = 1;
		}
	}
	ans=ans-(count*(count-1))/2;

	count = 1;

	for (i = 1; i != n; ++i)
	{
		if(a[i].second==a[i-1].second)
			count++;
		else
		{
			ans=ans+(count*(count-1))/2;
			count = 1;
		}
	}

	ans=ans+(count*(count-1))/2;

	cout<<ans<<endl;
	return 0;
}


#include <map>
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

bool comp(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second<b.second;
}

int main(int argc, char const *argv[])
{
	int n,i,x,y;
	map<int,bool> mapy;
	cin>>n;
	vector<pair<int,int> > a;
	a.reserve(n);

	for (int i = 0; i < n; ++i)
	{
		cin>>x>>y;
		a.push_back(make_pair(x,y));
		mapy[y]=true;
	}

	vector<pair<int,int > >::iterator it;

	sort(a.begin(),a.end());

	int count = 0,ans=0;

    if(a[0].first!=a[1].first&&mapy[a[0].second]==false)
        count++;

	for (i = 1; i != n; ++i)
	{
		if(a[i].first!=a[i-1].first&&a[i].first!=a[i+1].first&&mapy[a[i].second]==false)
			count++;

	}

	ans= (n*(n-1))/2-(count*(count-1))/2-count*(n-count);

	cout<<ans<<endl;
	return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

bool comp(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second<b.second;
}

int main(int argc, char const *argv[])
{
	int n,i,x,y;
	cin>>n;
	vector<pair<int,int> > a;
	a.reserve(n);

	for (int i = 0; i < n; ++i)
	{
		cin>>x>>y;
		a.push_back(make_pair(x,y));
	}

	vector<pair<int,int > >::iterator it;

	sort(a.begin(),a.end());

	int count = 1,ans=0;

	for (i = 1; i != n; ++i)
	{
		if(a[i].first==a[i-1].first)
			count++;
		else
		{
			ans=ans+(count*(count-1))/2;
			count = 1;
		}
	}

	ans=ans+(count*(count-1))/2;

	sort(a.begin(), a.end(),comp);

	count = 1;

	for (i = 1; i != n; ++i)
	{
		if(a[i].second==a[i-1].second)
			count++;
		else
		{
			ans=ans+(count*(count-1))/2;
			count = 1;
		}
	}

	ans=ans+(count*(count-1))/2;

	count =1;

	for (i = 1; i != n; ++i)
	{
		if(a[i].first==a[i-1].first&&a[i].second==a[i-1].second)
			count++;
		else
		{
			ans=ans-(count*(count-1))/2;
			count = 1;
		}
	}
	ans=ans-(count*(count-1))/2;

	cout<<ans<<endl;
	return 0;
}


#include <map>
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

bool comp(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second<b.second;
}

int main(int argc, char const *argv[])
{
	int n,i,x,y;
	map<int,bool> mapy;
	cin>>n;
	vector<pair<int,int> > a;
	a.reserve(n);

	for (int i = 0; i < n; ++i)
	{
		cin>>x>>y;
		a.push_back(make_pair(x,y));
		mapyy[y]=true;
	}

	vector<pair<int,int > >::iterator it;

	sort(a.begin(),a.end());

	int count = 0,ans=0;

    if(a[0].first!=a[1].first&&mapy[a[0].second]==false)
        count++;

	for (i = 1; i != n; ++i)
	{
		if(a[i].first!=a[i-1].first&&a[i].first!=a[i+1].first&&mapy[a[i].second]==false)
			count++;

	}

	ans= (n*(n-1))/2-(count*(count-1))/2-count*(n-count);

	cout<<ans<<endl;
	return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

bool comp(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second<b.second;
}

int main(int argc, char const *argv[])
{
	int n,i,x,y;
	cin>>n;
	vector<pair<int,int> > a;
	a.reserve(n);

	for (int i = 0; i < n; ++i)
	{
		cin>>x>>y;
		a.push_back(make_pair(x,y));
	}

	vector<pair<int,int > >::iterator it;

	sort(a.begin(),a.end());

	int count = 1,ans=0;

	for (i = 1; i != n; ++i)
	{
		if(a[i].first==a[i-1].first)
			count++;
		else
		{
			ans=ans+(count*(count-1))/2;
			count = 1;
		}
	}

	ans=ans+(count*(count-1))/2;

	count =1;

	for (i = 1; i != n; ++i)
	{
		if(a[i].first==a[i-1].first&&a[i].second==a[i-1].second)
			count++;
		else
		{
			ans=ans-(count*(count-1))/2;
			count = 1;
		}
	}
	ans=ans-(count*(count-1))/2;

	sort(a.begin(), a.end(),comp);
	count = 1;

	for (i = 1; i != n; ++i)
	{
		if(a[i].second==a[i-1].second)
			count++;
		else
		{
			ans=ans+(count*(count-1))/2;
			count = 1;
		}
	}

	ans=ans+(count*(count-1))/2;

	cout<<ans<<endl;
	return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

bool comp(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second<b.second;
}

int main(int argc, char const *argv[])
{
	int n,i,x,y;
	cin>>n;
	vector<pair<int,int> > a;
	a.reserve(n);

	for (int i = 0; i < n; ++i)
	{
		cin>>x>>y;
		a.push_back(make_pair(x,y));
	}

	vector<pair<int,int > >::iterator it;

	sort(a.begin(),a.end());

	int count = 1,ans=0;

	for (i = 1; i != n; ++i)
	{
		if(a[i].first==a[i-1].first)
			count++;
		else
		{
			ans+=(count*(count-1))/2;
			count = 1;
		}
	}

	ans+=(count*(count-1))/2;

	sort(a.begin(), a.end(),comp);

	count = 1;

	for (i = 1; i != n; ++i)
	{
		if(a[i].second==a[i-1].second)
			count++;
		else
		{
			ans+=(count*(count-1))/2;
			count = 1;
		}
	}

	ans+=(count*(count-1))/2;

	count =1;

	for (i = 1; i != n; ++i)
	{
		if(a[i].first==a[i-1].first&&a[i].second==a[i-1].second)
			count++;
		else
		{
			ans-=(count*(count-1))/2;
			count = 1;
		}
	}
	ans-=(count*(count-1))/2;

	cout<<ans<<endl;
	return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

bool comp(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second<b.second;
}

int main(int argc, char const *argv[])
{
	int n,i,x,y;
	cin>>n;
	vector<pair<int,int> > a;
	a.reserve(n);

	for (int i = 0; i < n; ++i)
	{
		cin>>x>>y;
		a.push_back(make_pair(x,y));
	}

	vector<pair<int,int > >::iterator it;

	sort(a.begin(),a.end());

	int count = 1,ans=0;

	for (i = 1; i != n; ++i)
	{
		if(a[i].first==a[i-1].first)
			count++;
		else
		{
			ans+=(count*(count-1))/2;
			count = 1;
		}
	}

	ans+=(count*(count-1))/2;

	sort(a.begin(), a.end(),comp);

	count = 1;

	for (i = 1; i != n; ++i)
	{
		if(a[i].second==a[i-1].second)
			count++;
		else
		{
			ans+=(count*(count-1))/2;
			count = 1;
		}
	}

	ans+=(count*(count-1))/2;

	count =1;

	for (i = 1; i != n; ++i)
	{
		if(a[i].first==a[i-1].first&&a[i].second==a[i-1].second)
			count++;
		else
		{
			ans-=(count*(count-1))/2;
			count = 1;
		}
	}

	cout<<ans<<endl;
	return 0;
}


#include <bits/stdc++.h>
#define MAX(a, b) (a > b ? a : b)
const int MAXN = 2e5 + 5;
using namespace std;
typedef long long int LL;

class node{
	public:
		LL x, y;
	node(){}
	node(const LL &a, const LL &b) : x(a), y(b){}
	node(const node &k) { this->x = k.x, this->y = k.y;}
	bool operator < (const node &k) const
	{
		if(this->y != k.y)
			return this->y < k.y;
		return this->x < k.x;
	}
	bool operator == (const node &k) const
	{
		return this->x == k.x && this->y == k.y;
	}

} lib[MAXN];

bool cmp1(const node &a, const node &b)
{
	return a.x < b.x;
}

bool cmp2(const node &a, const node &b)
{
	return a.y < b.y;
}

stack<LL> sta;

int main()
{
	int n, k, x, y;
	while(scanf("%d", &n) == 1)
	{
		while(!sta.empty())
			sta.pop();
		LL sum(0), ans(0);
		register int j = 0;

		for(register int i = 0; i < n; ++i)
		{
			scanf("%lld%lld", &lib[i].x, &lib[i].y);
		}

		sort(lib, lib + n, cmp1);
		sum = 1;
		for(register int i = 1; i < n; ++i)
		{
			if(lib[i].x != lib[i - 1].x)
			{
				ans += ((sum * (sum - 1)) >> 1);
				sum = 1;
			}
			else
				++sum;
		}
		ans += ((sum * (sum - 1)) >> 1);

		sort(lib, lib + n, cmp2);

		sum = 1;
		for(register int i = 0; i < n - 1; ++i)
		{
			if(lib[i].y != lib[i + 1].y)
			{
				ans += ((sum * (sum - 1)) >> 1);
				sum = 1;
			}
			else
			{
				++sum;
			}
		}
		ans += ((sum * (sum - 1)) >> 1);
		LL cache = 0;
		for(register int i = 0; i <= n; ++i)
		{
			if(lib[i] == lib[i + 1])
			{
				ans -= cache;
				++cache;
			}
			else
			{
				cache = 0;
			}
		}
		printf("%lld\n", ans);
	}
	return 0;
}


#include <bits/stdc++.h>
#define MAX(a, b) (a > b ? a : b)
const int MAXN = 2e5 + 5;
using namespace std;
typedef long long int LL;
int valx[MAXN], valy[MAXN];

class node{
	public:
		LL x, y;
	node(){}
	node(const LL &a, const LL &b) : x(a), y(b){}
	node(const node &k) { this->x = k.x, this->y = k.y;}
	bool operator < (const node &k) const
	{
		if(this->y != k.y)
			return this->y < k.y;
		return this->x < k.x;
	}

	bool operator == (const node &k) const
	{
		return this->x == k.x && this->y == k.y;
	}

} lib[MAXN];

bool cmp1(const node &a, const node &b)
{
	return a.x < b.x;
}

bool cmp2(const node &a, const node &b)
{
	return a.y < b.y;
}

set<node> se;
set<node>::iterator it, it2;
stack<int> sta;

int main()
{
	int n, k, x, y;
	while(scanf("%d", &n) == 1)
	{
		while(!sta.empty())
			sta.pop();
		se.clear();
		LL sum(0), ans(0), mi(0);
		register int j = 0;

		for(register int i = 0; i < n; ++i)
		{
			scanf("%lld%lld", &lib[i].x, &lib[i].y);
			se.insert(lib[i]);
		}

		sort(lib, lib + n, cmp1);
		sum = 1;
		for(register int i = 1; i < n; ++i)
		{
			if(lib[i].x != lib[i - 1].x)
			{
				ans += ((sum * (sum - 1)) >> 1);
				sum = 1;
			}
			else
				++sum;
		}
		ans += ((sum * (sum - 1)) >> 1);

		sort(lib, lib + n, cmp2);
		it = se.begin();

		LL cache = 1;
		sum = 1;
		for(register int i = 0; i < n - 1; ++i)
		{
			if(lib[i].y != lib[i + 1].y)
			{
				if(cache - 1)
					sta.push(cache);
				ans += ((sum * (sum - 1)) >> 1);
				while(!sta.empty())
				{
					cache = sta.top();
					sta.pop();
					ans -= ((cache * (cache - 1)) >> 1);
				}
				cache = sum = 1;
				it = it2;
			}
			else
			{
				if(lib[i].x == lib[i + 1].x)
				{
					++cache;
				}
				else
				{
					if(cache - 1)
						sta.push(cache);
					cache = 1;
				}

				++sum;
			}
		}
		if(cache - 1)
			sta.push(cache);

		ans += ((sum * (sum - 1)) >> 1);
		while(!sta.empty())
		{
			cache = sta.top();
			sta.pop();
			ans -= ((cache * (cache - 1)) >> 1);
		}

		printf("%lld\n", ans);
	}
	return 0;
}


#include <bits/stdc++.h>
#define MAX(a, b) (a > b ? a : b)
const int MAXN = 2e5 + 5;
using namespace std;
typedef long long int LL;

class node{
	public:
		LL x, y;
	node(){}
	node(const LL &a, const LL &b) : x(a), y(b){}
	node(const node &k) { this->x = k.x, this->y = k.y;}
	bool operator < (const node &k) const
	{
		if(this->y != k.y)
			return this->y < k.y;
		return this->x < k.x;
	}
	bool operator == (const node &k) const
	{
		return this->x == k.x && this->y == k.y;
	}

} lib[MAXN];

bool cmp1(const node &a, const node &b)
{
	return a.x < b.x;
}

bool cmp2(const node &a, const node &b)
{
	return a.y < b.y;
}

stack<LL> sta;

int main()
{
	int n, k, x, y;
	while(scanf("%d", &n) == 1)
	{
		while(!sta.empty())
			sta.pop();
		LL sum(0), ans(0);
		register int j = 0;

		for(register int i = 0; i < n; ++i)
		{
			scanf("%lld%lld", &lib[i].x, &lib[i].y);
		}

		sort(lib, lib + n, cmp1);
		sum = 1;
		for(register int i = 1; i < n; ++i)
		{
			if(lib[i].x != lib[i - 1].x)
			{
				ans += ((sum * (sum - 1)) >> 1);
				sum = 1;
			}
			else
				++sum;
		}
		ans += ((sum * (sum - 1)) >> 1);

		sort(lib, lib + n, cmp2);

		sum = 1;
		for(register int i = 0; i < n - 1; ++i)
		{
			if(lib[i].y != lib[i + 1].y)
			{
				ans += ((sum * (sum - 1)) >> 1);
				sum = 1;
			}
			else
			{
				++sum;
			}
		}
		ans += ((sum * (sum - 1)) >> 1);
		LL cache = 0;
		for(register int i = 0; i <= n; ++i)
		{
			if(lib[i] == lib[i + 1])
			{
				ans -= cache;
				++cache;
			}
			else
			{
				cache;
			}
		}
		printf("%lld\n", ans);
	}
	return 0;
}


#include <bits/stdc++.h>
#define MAX(a, b) (a > b ? a : b)
const int MAXN = 2e5 + 5;
using namespace std;
typedef long long int LL;

class node{
	public:
		LL x, y;
	node(){}
	node(const LL &a, const LL &b) : x(a), y(b){}
	node(const node &k) { this->x = k.x, this->y = k.y;}
	bool operator == (const node &k) const
	{
		return this->x == k.x && this->y == k.y;
	}

} lib[MAXN];

bool cmp1(const node &a, const node &b)
{
	if(a.x != b.x)
		return a.x < b.x;
	return a.y < b.y;
}

bool cmp2(const node &a, const node &b)
{
	if(a.y != b.y)
		return a.y < b.y;
	return a.x < b.x;
}

stack<LL> sta;

int main()
{
	int n, k, x, y;
	while(scanf("%d", &n) == 1)
	{
		while(!sta.empty())
			sta.pop();
		LL sum(0), ans(0);
		register int j = 0;

		for(register int i = 0; i < n; ++i)
		{
			scanf("%lld%lld", &lib[i].x, &lib[i].y);
		}

		sort(lib, lib + n, cmp1);
		sum = 0;
		for(register int i = 1; i < n; ++i)
		{
			if(lib[i].x == lib[i - 1].x)
			{
				++sum;
				ans += sum;
			}
			else
				sum = 0;
		}
		ans += ((sum * (sum - 1)) >> 1);

		sort(lib, lib + n, cmp2);
		sum = 0;
		for(register int i = 0; i < n - 1; ++i)
		{
			if(lib[i].y == lib[i + 1].y)
			{
				++sum;
				ans += sum;
			}
			else
			{
				sum = 0;
			}
		}

		sum = 0;
		for(register int i = 0; i < n - 1; ++i)
		{
			if(lib[i] == lib[i + 1])
			{
				++sum;
				ans -= sum;
			}
			else
			{
				sum = 0;
			}
		}
		printf("%lld\n", ans);
	}
	return 0;
}


#include <bits/stdc++.h>
#define MAX(a, b) (a > b ? a : b)
const int MAXN = 2e5 + 5;
using namespace std;
typedef long long int LL;

class node{
	public:
		LL x, y;
	node(){}
	node(const LL &a, const LL &b) : x(a), y(b){}
	node(const node &k) { this->x = k.x, this->y = k.y;}
	bool operator == (const node &k) const
	{
		return this->x == k.x && this->y == k.y;
	}

} lib[MAXN];

bool cmp1(const node &a, const node &b)
{
	if(a.x != b.x)
		return a.x < b.x;
	return a.y < b.y;
}

bool cmp2(const node &a, const node &b)
{
	if(a.y != b.y)
		return a.y < b.y;
	return a.x < b.x;
}

int main()
{
	int n, k, x, y;
	while(scanf("%d", &n) == 1)
	{
		LL sum(0), ans(0);
		for(register int i = 0; i < n; ++i)
		{
			scanf("%lld%lld", &lib[i].x, &lib[i].y);
		}

		sort(lib, lib + n, cmp1);
		sum = 0;
		for(register int i = 1; i < n; ++i)
		{
			if(lib[i].x == lib[i - 1].x)
			{
				++sum;
				ans += sum;
			}
			else
				sum = 0;
		}

		sort(lib, lib + n, cmp2);
		sum = 0;
		for(register int i = 0; i < n - 1; ++i)
		{
			if(lib[i].y == lib[i + 1].y)
			{
				++sum;
				ans += sum;
			}
			else
			{
				sum = 0;
			}
		}

		sum = 0;
		for(register int i = 0; i < n - 1; ++i)
		{
			if(lib[i] == lib[i + 1])
			{
				++sum;
				ans -= sum;
			}
			else
			{
				sum = 0;
			}
		}
		printf("%lld\n", ans);
	}
	return 0;
}


#include <bits/stdc++.h>
#define MAX(a, b) (a > b ? a : b)
const int MAXN = 2e5 + 5;
using namespace std;
typedef long long int LL;

class node{
	public:
		LL x, y;
	node(){}
	node(const LL &a, const LL &b) : x(a), y(b){}
	node(const node &k) { this->x = k.x, this->y = k.y;}
	bool operator < (const node &k) const
	{
		if(this->y != k.y)
			return this->y < k.y;
		return this->x < k.x;
	}
	bool operator == (const node &k) const
	{
		return this->x == k.x && this->y == k.y;
	}

} lib[MAXN];

bool cmp1(const node &a, const node &b)
{
	return a.x < b.x;
}

bool cmp2(const node &a, const node &b)
{
	return a.y < b.y;
}

stack<LL> sta;

int main()
{
	int n, k, x, y;
	while(scanf("%d", &n) == 1)
	{
		while(!sta.empty())
			sta.pop();
		LL sum(0), ans(0);
		register int j = 0;

		for(register int i = 0; i < n; ++i)
		{
			scanf("%lld%lld", &lib[i].x, &lib[i].y);
		}

		sort(lib, lib + n, cmp1);
		sum = 1;
		for(register int i = 1; i < n; ++i)
		{
			if(lib[i].x != lib[i - 1].x)
			{
				ans += ((sum * (sum - 1)) >> 1);
				sum = 1;
			}
			else
				++sum;
		}
		ans += ((sum * (sum - 1)) >> 1);

		sort(lib, lib + n, cmp2);

		sum = 1;
		for(register int i = 0; i < n - 1; ++i)
		{
			if(lib[i].y != lib[i + 1].y)
			{
				ans += ((sum * (sum - 1)) >> 1);
				sum = 1;
			}
			else
			{
				++sum;
			}
		}
		ans += ((sum * (sum - 1)) >> 1);
		LL cache = 0;
		for(register int i = 0; i < n - 1; ++i)
		{
			if(lib[i] == lib[i + 1])
			{
				++cache;
				ans -= cache;
			}
			else
			{
				cache = 0;
			}
		}
		printf("%lld\n", ans);
	}
	return 0;
}


#include <bits/stdc++.h>
#define MAX(a, b) (a > b ? a : b)
const int MAXN = 2e5 + 5;
using namespace std;
typedef long long int LL;

class node{
	public:
		LL x, y;
	node(){}
	node(const LL &a, const LL &b) : x(a), y(b){}
	node(const node &k) { this->x = k.x, this->y = k.y;}
	bool operator < (const node &k) const
	{
		if(this->y != k.y)
			return this->y < k.y;
		return this->x < k.x;
	}

} lib[MAXN];

bool cmp1(const node &a, const node &b)
{
	return a.x < b.x;
}

bool cmp2(const node &a, const node &b)
{
	return a.y < b.y;
}

stack<LL> sta;

int main()
{
	int n, k, x, y;
	while(scanf("%d", &n) == 1)
	{
		while(!sta.empty())
			sta.pop();
		LL sum(0), ans(0);
		register int j = 0;

		for(register int i = 0; i < n; ++i)
		{
			scanf("%lld%lld", &lib[i].x, &lib[i].y);
		}

		sort(lib, lib + n, cmp1);
		sum = 1;
		for(register int i = 1; i < n; ++i)
		{
			if(lib[i].x != lib[i - 1].x)
			{
				ans += ((sum * (sum - 1)) >> 1);
				sum = 1;
			}
			else
				++sum;
		}
		ans += ((sum * (sum - 1)) >> 1);

		sort(lib, lib + n, cmp2);

		LL cache = 1;
		sum = 1;
		for(register int i = 0; i < n - 1; ++i)
		{
			if(lib[i].y != lib[i + 1].y)
			{
				if(cache - 1)
					sta.push(cache);
				ans += ((sum * (sum - 1)) >> 1);
				while(!sta.empty())
				{
					cache = sta.top();
					sta.pop();
					ans -= ((cache * (cache - 1)) >> 1);
				}
				cache = sum = 1;
			}
			else
			{
				if(lib[i].x == lib[i + 1].x)
				{
					++cache;
				}
				else
				{
					if(cache - 1)
						sta.push(cache);
					cache = 1;
				}

				++sum;
			}
		}
		if(cache - 1)
			sta.push(cache);

		ans += ((sum * (sum - 1)) >> 1);
		while(!sta.empty())
		{
			cache = sta.top();
			sta.pop();
			ans -= ((cache * (cache - 1)) >> 1);
		}

		printf("%lld\n", ans);
	}
	return 0;
}


#include <bits/stdc++.h>
#define MAX(a, b) (a > b ? a : b)
const int MAXN = 2e5 + 5;
using namespace std;
typedef long long int LL;

class node{
	public:
		LL x, y;
	node(){}
	node(const LL &a, const LL &b) : x(a), y(b){}
	node(const node &k) { this->x = k.x, this->y = k.y;}
	bool operator < (const node &k) const
	{
		if(this->y != k.y)
			return this->y < k.y;
		return this->x < k.x;
	}
	bool operator == (const node &k) const
	{
		return this->x == k.x && this->y == k.y;
	}

} lib[MAXN];

bool cmp1(const node &a, const node &b)
{
	return a.x < b.x;
}

bool cmp2(const node &a, const node &b)
{
	return a.y < b.y;
}

stack<LL> sta;

int main()
{
	int n, k, x, y;
	while(scanf("%d", &n) == 1)
	{
		while(!sta.empty())
			sta.pop();
		LL sum(0), ans(0);
		register int j = 0;

		for(register int i = 0; i < n; ++i)
		{
			scanf("%lld%lld", &lib[i].x, &lib[i].y);
		}

		sort(lib, lib + n, cmp1);
		sum = 1;
		for(register int i = 1; i < n; ++i)
		{
			if(lib[i].x != lib[i - 1].x)
			{
				ans += ((sum * (sum - 1)) >> 1);
				sum = 1;
			}
			else
				++sum;
		}
		ans += ((sum * (sum - 1)) >> 1);

		sort(lib, lib + n, cmp2);

		sum = 1;
		for(register int i = 0; i < n - 1; ++i)
		{
			if(lib[i].y != lib[i + 1].y)
			{
				ans += ((sum * (sum - 1)) >> 1);
				sum = 1;
			}
			else
			{
				++sum;
			}
		}
		ans += ((sum * (sum - 1)) >> 1);
		LL cache = 0;
		for(register int i = 0; i <= n; ++i)
		{
			if(lib[i] == lib[i + 1])
			{
				ans -= cache;
				++cache;
			}
			else
			{
				cache = 0;
			}
		}
		ans -= cache;
		printf("%lld\n", ans);
	}
	return 0;
}


#include <iostream>
#include <map>
#include <set>
#define FOR(i,a,b) for(int i=a; i<b; i++)
using namespace std;
int n,ans;
map<int,int> row, column;
map<pair<int,int>,int > points;
int main()
{
	cin>>n;
	FOR(i,0,n)
	{
		int x,y;
		cin>>x>>y;
		points[make_pair(x,y)]++;
		row[x]++;
		column[y]++;
	}
	map<int,int>::iterator it;
	for(it=row.begin(); it!=row.end(); ++it)
	{
		int t = it->second;
		t = (t*(t-1))/2;
		ans+=t;
	}
	for(it=column.begin(); it!=column.end(); ++it)
	{
		int t = it->second;
		t = (t*(t-1))/2;
		ans+=t;
	}
	map<pair<int,int>, int>::iterator it2;
	for(it2=points.begin(); it2!=points.end(); it2++)
	{
		int t = it2->second;
		t = (t*(t-1))/2;
		ans-=t;
	}
	cout<<ans<<endl;
}


#include <iostream>
#include <map>
using namespace std;
long long n,ans,x,y;
map<int,int> nx, ny;
map<pair<int,int>,int> np;
int main(){
	cin>>n;
	while(n--){
		cin>>x>>y;
		ans+= nx[x] + ny[y] - np[make_pair(x,y)];
		nx[x]++,ny[y]++,np[make_pair(x,y)]++;
	}
	cout<<ans<<endl;
}


#include <iostream>
#include <map>
#include <set>
#define FOR(i,a,b) for(int i=a; i<b; i++)
using namespace std;
int n,ans;
map<int,int> row, column;
set<pair<int,int> > points;
int main()
{
	cin>>n;
	FOR(i,0,n)
	{
		int x,y;
		cin>>x>>y;
		points.insert(make_pair(x,y));
		row[x]++;
		column[y]++;
	}
	map<int,int>::iterator it;
	for(it=row.begin(); it!=row.end(); ++it)
	{
		int t = it->second;
		t = (t*(t-1))/2;
		ans+=t;
	}
	for(it=column.begin(); it!=column.end(); ++it)
	{
		int t = it->second;
		t = (t*(t-1))/2;
		ans+=t;
	}
	cout<<(ans-n+points.size())<<endl;
}


#include <iostream>
#include <map>
using namespace std;long long n,ans,x,y;map<int,int> nx, ny;map<pair<int,int>,int> np;int main(){cin>>n;while(n--){cin>>x>>y;ans+= nx[x]++ + ny[y]++ - np[make_pair(x,y)]++;}cout<<ans<<endl;}


#include <iostream>
#include <map>
#include <set>
#define FOR(i,a,b) for(int i=a; i<b; i++)
using namespace std;
int n;
long long ans;
map<int,int> row, column;
map<pair<int,int>,int > points;
int main()
{
	cin>>n;
	FOR(i,0,n)
	{
		int x,y;
		cin>>x>>y;
		points[make_pair(x,y)]++;
		row[x]++;
		column[y]++;
	}
	map<int,int>::iterator it;
	for(it=row.begin(); it!=row.end(); ++it)
	{
		long long t = it->second;
		t = (t*(t-1))/2;
		ans+=t;
	}
	for(it=column.begin(); it!=column.end(); ++it)
	{
		long long t = it->second;
		t = (t*(t-1))/2;
		ans+=t;
	}
	map<pair<int,int>, int>::iterator it2;
	for(it2=points.begin(); it2!=points.end(); it2++)
	{
		long long t = it2->second;
		t = (t*(t-1))/2;
		ans-=t;
	}
	cout<<ans<<endl;
}


#include <iostream>
#include <map>
using namespace std;
long long n,ans,x,y;
map<int,int> nx, ny;
map<pair<int,int>,int> np;
int main(){
	cin>>n;
	while(n--){
		cin>>x>>y;
		ans+= nx[x]++ + ny[y]++ - np[make_pair(x,y)]++;
	}
	cout<<ans<<endl;
}


#include <iostream>
#include <map>
using namespace std;
long long n,ans,x,y;
map<int,int> nx, ny;
map<pair<int,int>,int> np;
int main(){
	cin>>n;
	while(n--){
		cin>>x>>y;
		ans+= (nx[x]++) + (ny[y]++) - (np[make_pair(x,y)]++);
	}
	cout<<ans<<endl;
}


#include <bits/stdc++.h>
using namespace std;

#define ll long long
//#define pb push_back
//#define mp make_pair

const int N = 200005;
int n;
vector <pair <ll,ll> > v;
//set <pair <ll,ll> > repet;
map <ll, ll> cntx;
map <ll, ll> cnty;
map <pair <ll, ll>, ll> repet;
ll res = 0;

int main(void){
	ios_base::sync_with_stdio(false);
	cin >> n;

	ll x, y;
	for(int i = 0; i < n; i++){
		cin >> x >> y;

		pair <ll, ll> par = make_pair(x,y);
		cntx[x]++;
		cnty[y]++;
		repet[par]++;
	}

	for(map<ll,ll>::iterator it = cntx.begin(); it != cntx.end(); it++){
		res += (it->second*(it->second-1))/2;
	}
	for(map<ll,ll>::iterator it = cnty.begin(); it != cnty.end(); it++){
		res += (it->second*(it->second-1))/2;
	}
	for(map<pair<ll,ll> ,ll>::iterator it = repet.begin(); it != repet.end(); it++){
		if(it->second > 1) res -= (it->second*(it->second-1))/2;
	}

	cout << res << endl;

	return 0;
}


#include <bits/stdc++.h>
using namespace std;

#define ll long long
//#define pb
//#define mp

const int N = 100005;
int n;
vector <pair <int,int> > v;
int cntx[N], cnty[N];
set <pair <int,int> > repet;
ll res = 0;

int main(void){
	ios_base::sync_with_stdio(false);
	cin >> n;

	int x, y;
	for(int i = 0; i < n; i++){
		cin >> x >> y;

		//if(cntx[x] > 0 and cnty[y] > 0) res--;
		pair <int, int> par = make_pair(x,y);
		if(repet.count(par)) res--;

		cntx[x]++;
		cnty[y]++;
		repet.insert(make_pair(x,y));

		v.push_back(make_pair(x,y));
	}

	for(int i = 0; i < N; i++){
		res += (cntx[i]*(cntx[i]-1))/2;
		res += (cnty[i]*(cnty[i]-1))/2;
	}

	cout << res << endl;

	return 0;
}


#include <bits/stdc++.h>
using namespace std;

#define ll long long
//#define pb
//#define mp

const int N = 200005;
int n;
vector <pair <ll,ll> > v;
//ll cntx[N], cnty[N];
set <pair <ll,ll> > repet;
map <ll, ll> cntx;
map <ll, ll> cnty;
ll res = 0;

int main(void){
	ios_base::sync_with_stdio(false);
	cin >> n;

	ll x, y;
	for(int i = 0; i < n; i++){
		cin >> x >> y;

		//if(cntx[x] > 0 and cnty[y] > 0) res--;
		pair <ll, ll> par = make_pair(x,y);
		if(repet.count(par)) res--;

		cntx[x]++;
		cnty[y]++;
		repet.insert(make_pair(x,y));

		//v.push_back(make_pair(x,y));
	}

	for(map<ll,ll>::iterator it = cntx.begin(); it != cntx.end(); it++){
		res += (it->second*(it->second-1))/2;
	}
	for(map<ll,ll>::iterator it = cnty.begin(); it != cnty.end(); it++){
		res += (it->second*(it->second-1))/2;
	}

	cout << res << endl;

	return 0;
}


#include <bits/stdc++.h>
using namespace std;

#define ll long long
//#define pb
//#define mp

const int N = 200005;
int n;
vector <pair <int,int> > v;
ll cntx[N], cnty[N];
set <pair <ll,ll> > repet;
ll res = 0;

int main(void){
	ios_base::sync_with_stdio(false);
	cin >> n;

	ll x, y;
	for(int i = 0; i < n; i++){
		cin >> x >> y;

		//if(cntx[x] > 0 and cnty[y] > 0) res--;
		pair <ll, ll> par = make_pair(x,y);
		if(repet.count(par)) res--;

		cntx[x]++;
		cnty[y]++;
		repet.insert(make_pair(x,y));

		v.push_back(make_pair(x,y));
	}

	for(int i = 0; i < N; i++){
		res += (cntx[i]*(cntx[i]-1))/2;
		res += (cnty[i]*(cnty[i]-1))/2;
	}

	cout << res << endl;

	return 0;
}


#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define push_back pb
#define make_pair mp

int cnt[1005];

int main(void){
	int n;
	cin >> n;

	int x;
	for(int i = 0; i < n; i++){
		cin >> x;
		cnt[x]++;
	}

	ll res = 0, parear = 0;

	for(int i = 0; i <= 1000; i++){
		parear = 0;
		for(int j = 0; j <= 1000; j++){
			if(cnt[j] > 0){
				if(parear == 1) res++;
				else parear = 1;
				cnt[j]--;
			}
		}
	}

	/*for(int i = 0; i <= 1000; i++){
		if(parear >=  cnt[i]){
			res += cnt[i];
			if(parear == cnt[i]) parear += cnt[i];
			parear -= cnt[i];
		}
		else if(parear < cnt[i]){
			res += parear;
			parear = cnt[i] - parear;
		}
	}*/

	cout << res << endl;

	return 0;
}


#include <bits/stdc++.h>
using namespace std;

#define ll long long
//#define pb
//#define mp

const int N = 200005;
int n;
vector <pair <ll,ll> > v;
//ll cntx[N], cnty[N];
set <pair <ll,ll> > repet;
map <ll, ll> cntx;
map <ll, ll> cnty;
ll res = 0;

int main(void){
	ios_base::sync_with_stdio(false);
	cin >> n;

	ll x, y;
	for(int i = 0; i < n; i++){
		cin >> x >> y;

		//if(cntx[x] > 0 and cnty[y] > 0) res--;
		pair <ll, ll> par = make_pair(x,y);
		if(repet.count(par)) res--;

		cntx[x]++;
		cnty[y]++;
		repet.insert(make_pair(x,y));

		//v.push_back(make_pair(x,y));
	}

	for(int i = 0; i < N; i++){
		ll cntxx = cntx[i], cntyy = cnty[i];

		res += (cntxx*(cntxx-1))/2;
		res += (cntyy*(cntyy-1))/2;
	}

	cout << res << endl;

	return 0;
}


#include <stdio.h>
#include <algorithm>
typedef struct point point;
struct point
{
    int x;
    int y;
};
bool compare1(point a, point b)
{
    return (a.x < b.x || (a.x == b.x && a.y <= b.y));
}
bool compare2(point a, point b)
{
    return (a.y < b.y || (a.y == b.y && a.x <= b.x));
}
point P[1000000];
int main()
{
    int N;
    scanf("%d", &N);
    int i, X, Y;
    unsigned long long countx, county, countxy;
    unsigned long long sumx = 0, sumy = 0, sumxy = 0;
    for (i = 0; i < N; i++)
    {
        scanf("%d%d", &X, &Y);
        P[i].x = X;
        P[i].y = Y;
    }
    std::sort(&P[0], &P[N], compare1);
    X = P[0].x;
    Y = P[0].y;
    countx = 1;
    countxy = 1;
    for (i = 1; i < N; i++)
    {
        if (P[i].x == X)
        {
            countx++;
            if (P[i].y == Y)
            {
                countxy++;
            }
            else
            {
                sumxy += (countxy)*(countxy - 1)/2;
                Y = P[i].y;
                countxy = 1;
            }
        }
        else
        {
            sumxy += (countxy)*(countxy - 1)/2;
            Y = P[i].y;
            countxy = 1;

            sumx += (countx)*(countx - 1)/2;
            X = P[i].x;
            countx = 1;
        }
    }
    sumxy += (countxy)*(countxy - 1)/2;
    sumx += (countx)*(countx - 1)/2;

    std::sort(&P[0], &P[N], compare2);
    Y = P[0].y;
    county = 1;
    for (i = 1; i < N; i++)
    {
        if (P[i].y == Y)
        {
            county++;
        }
        else
        {
            sumy += (county)*(county - 1)/2;
            Y = P[i].y;
            county = 1;
        }
    }
    sumy += (county)*(county - 1)/2;

    //printf("%d %d %d\n", sumx, sumy, sumxy);
    printf("%I64u", sumx + sumy - sumxy);
    return 0;
}


#include <stdio.h>
#include <algorithm>
typedef struct point point;
struct point
{
    int x;
    int y;
};
bool compare1(point a, point b)
{
    return (a.x < b.x || (a.x == b.x && a.y <= b.y));
}
bool compare2(point a, point b)
{
    return (a.y < b.y || (a.y == b.y && a.x <= b.x));
}
point P[300000];
int main()
{
    int N;
    scanf("%d", &N);
    int i, X, Y;
    unsigned long long countx, county, countxy;
    unsigned long long sumx = 0, sumy = 0, sumxy = 0;
    for (i = 0; i < N; i++)
    {
        scanf("%d%d", &X, &Y);
        P[i].x = X;
        P[i].y = Y;
    }
    std::sort(&P[0], &P[N], compare1);
    X = P[0].x;
    Y = P[0].y;
    countx = 1;
    countxy = 1;
    for (i = 1; i < N; i++)
    {
        if (P[i].x == X)
        {
            countx++;
            if (P[i].y == Y)
            {
                countxy++;
            }
            else
            {
                sumxy += (countxy)*(countxy - 1)/2;
                Y = P[i].y;
                countxy = 1;
            }
        }
        else
        {
            sumxy += (countxy)*(countxy - 1)/2;
            Y = P[i].y;
            countxy = 1;

            sumx += (countx)*(countx - 1)/2;
            X = P[i].x;
            countx = 1;
        }
    }
    sumxy += (countxy)*(countxy - 1)/2;
    sumx += (countx)*(countx - 1)/2;

    std::sort(&P[0], &P[N], compare2);
    Y = P[0].y;
    county = 1;
    for (i = 1; i < N; i++)
    {
        if (P[i].y == Y)
        {
            county++;
        }
        else
        {
            sumy += (county)*(county - 1)/2;
            Y = P[i].y;
            county = 1;
        }
    }
    sumy += (county)*(county - 1)/2;

    //printf("%d %d %d\n", sumx, sumy, sumxy);
    printf("%I64u", sumx + sumy - sumxy);
    return 0;
}


#include <stdio.h>
#include <algorithm>
typedef struct point point;
struct point
{
    int x;
    int y;
};
bool compare1(point a, point b)
{
    return (a.x < b.x || (a.x == b.x && a.y <= b.y));
}
bool compare2(point a, point b)
{
    return (a.y < b.y || (a.y == b.y && a.x <= b.x));
}
point P[200005];
int main()
{
    int N;
    scanf("%d", &N);
    int i, x, y;
    unsigned long long countx, county, countxy;
    unsigned long long sumx = 0, sumy = 0, sumxy = 0;
    for (i = 0; i < N; i++)
    {
        scanf("%d%d", &x, &y);
        P[i].x = x;
        P[i].y = y;
    }
    std::sort(&P[0], &P[N], compare1);
    x = P[0].x;
    y = P[0].y;
    countx = 1;
    countxy = 1;
    for (i = 1; i < N; i++)
    {
        if (P[i].x == x)
        {
            countx++;
            if (P[i].y == y)
            {
                countxy++;
            }
            else
            {
                sumxy += (countxy)*(countxy - 1)/2;
                y = P[i].y;
                countxy = 1;
            }
        }
        else
        {
            sumxy += (countxy)*(countxy - 1)/2;
            y = P[i].y;
            countxy = 1;

            sumx += (countx)*(countx - 1)/2;
            x = P[i].x;
            countx = 1;
        }
    }
    sumxy += (countxy)*(countxy - 1)/2;
    sumx += (countx)*(countx - 1)/2;

    std::sort(&P[0], &P[N], compare2);
    y = P[0].y;
    county = 1;
    for (i = 1; i < N; i++)
    {
        if (P[i].y == y)
        {
            county++;
        }
        else
        {
            sumy += (county)*(county - 1)/2;
            y = P[i].y;
            county = 1;
        }
    }
    sumy += (county)*(county - 1)/2;

    //printf("%d %d %d\n", sumx, sumy, sumxy);
    printf("%I64u", sumx + sumy - sumxy);
}


#include <stdio.h>
#include <algorithm>
typedef struct point point;
struct point
{
    int x;
    int y;
};
bool compare1(point a, point b)
{
    return (a.x < b.x || (a.x == b.x && a.y <= b.y));
}
bool compare2(point a, point b)
{
    return (a.y < b.y || (a.y == b.y && a.x <= b.x));
}
point P[200001];
int main()
{
    int N;
    scanf("%d", &N);
    int i, x, y;
    int countx, county, countxy;
    unsigned long long sumx = 0, sumy = 0, sumxy = 0;
    for (i = 0; i < N; i++)
    {
        scanf("%d%d", &x, &y);
        P[i].x = x;
        P[i].y = y;
    }
    std::sort(&P[0], &P[N], compare1);
    x = P[0].x;
    y = P[0].y;
    countx = 1;
    countxy = 1;
    for (i = 1; i < N; i++)
    {
        if (P[i].x == x)
        {
            countx++;
            if (P[i].y == y)
            {
                countxy++;
            }
            else
            {
                sumxy += (countxy)*(countxy - 1)/2;
                y = P[i].y;
                countxy = 1;
            }
        }
        else
        {
            sumxy += (countxy)*(countxy - 1)/2;
            y = P[i].y;
            countxy = 1;

            sumx += (countx)*(countx - 1)/2;
            x = P[i].x;
            countx = 1;
        }
    }
    sumxy += (countxy)*(countxy - 1)/2;
    sumx += (countx)*(countx - 1)/2;

    std::sort(&P[0], &P[N], compare2);
    y = P[0].y;
    county = 1;
    for (i = 1; i < N; i++)
    {
        if (P[i].y == y)
        {
            county++;
        }
        else
        {
            sumy += (county)*(county - 1)/2;
            y = P[i].y;
            county = 1;
        }
    }
    sumy += (county)*(county - 1)/2;

    //printf("%d %d %d\n", sumx, sumy, sumxy);
    printf("%I64u", sumx + sumy - sumxy);
}


#include <stdio.h>
#include <algorithm>
typedef struct point point;
struct point
{
    int x;
    int y;
};
bool compare1(point a, point b)
{
    return (a.x < b.x || (a.x == b.x && a.y <= b.y));
}
bool compare2(point a, point b)
{
    return (a.y < b.y || (a.y == b.y && a.x <= b.x));
}
point P[300000];
int main()
{
    int N;
    scanf("%d", &N);
    int i, X, Y;
    unsigned long long countx, county, countxy;
    unsigned long long sumx = 0, sumy = 0, sumxy = 0;
    for (i = 0; i < N; i++)
    {
        scanf("%d%d", &X, &Y);
        P[i].x = X;
        P[i].y = Y;
    }
    std::sort(&P[0], &P[N], compare1);
    X = P[0].x;
    Y = P[0].y;
    countx = 1;
    countxy = 1;
    for (i = 1; i < N; i++)
    {
        if (P[i].x == X)
        {
            countx++;
            if (P[i].y == Y)
            {
                countxy++;
            }
            else
            {
                sumxy += (countxy)*(countxy - 1)/2;
                Y = P[i].y;
                countxy = 1;
            }
        }
        else
        {
            sumxy += (countxy)*(countxy - 1)/2;
            Y = P[i].y;
            countxy = 1;

            sumx += (countx)*(countx - 1)/2;
            X = P[i].x;
            countx = 1;
        }
    }
    sumxy += (countxy)*(countxy - 1)/2;
    sumx += (countx)*(countx - 1)/2;

    std::sort(&P[0], &P[N], compare2);
    Y = P[0].y;
    county = 1;
    for (i = 1; i < N; i++)
    {
        if (P[i].y == Y)
        {
            county++;
        }
        else
        {
            sumy += (county)*(county - 1)/2;
            Y = P[i].y;
            county = 1;
        }
    }
    sumy += (county)*(county - 1)/2;

    //printf("%d %d %d\n", sumx, sumy, sumxy);
    printf("%I64u", sumx + sumy - sumxy);
}


#include <stdio.h>
#include <algorithm>
typedef struct point point;
struct point
{
    int x;
    int y;
};
bool compare1(point a, point b)
{
    return (a.x < b.x || (a.x == b.x && a.y <= b.y));
}
bool compare2(point a, point b)
{
    return (a.y < b.y || (a.y == b.y && a.x <= b.x));
}
int main()
{
    int N;
    point P[200001];
    scanf("%d", &N);
    int i, x, y;
    int countx, county, countxy;
    int sumx = 0, sumy = 0, sumxy = 0;
    for (i = 0; i < N; i++)
    {
        scanf("%d%d", &x, &y);
        P[i].x = x;
        P[i].y = y;
    }
    std::sort(&P[0], &P[N], compare1);
    x = P[0].x;
    y = P[0].y;
    countx = 1;
    countxy = 1;
    for (i = 1; i < N; i++)
    {
        if (P[i].x == x)
        {
            countx++;
            if (P[i].y == y)
            {
                countxy++;
            }
            else
            {
                sumxy += (countxy)*(countxy - 1)/2;
                y = P[i].y;
                countxy = 1;
            }
        }
        else
        {
            sumxy += (countxy)*(countxy - 1)/2;
            y = P[i].y;
            countxy = 1;

            sumx += (countx)*(countx - 1)/2;
            x = P[i].x;
            countx = 1;
        }
    }
    sumxy += (countxy)*(countxy - 1)/2;
    sumx += (countx)*(countx - 1)/2;

    std::sort(&P[0], &P[N], compare2);
    y = P[0].y;
    county = 1;
    for (i = 1; i < N; i++)
    {
        if (P[i].y == y)
        {
            county++;
        }
        else
        {
            sumy += (county)*(county - 1)/2;
            y = P[i].y;
            county = 1;
        }
    }
    sumy += (county)*(county - 1)/2;

    //printf("%d %d %d\n", sumx, sumy, sumxy);
    printf("%d", sumx + sumy - sumxy);
}


#include <stdio.h>
#include <algorithm>
typedef struct point point;
struct point
{
    int x;
    int y;
};
bool compare1(point a, point b)
{
    return (a.x < b.x || (a.x == b.x && a.y <= b.y));
}
bool compare2(point a, point b)
{
    return (a.y < b.y || (a.y == b.y && a.x <= b.x));
}
point P[200001];
int main()
{
    int N;
    scanf("%d", &N);
    int i, x, y;
    int countx, county, countxy;
    int sumx = 0, sumy = 0, sumxy = 0;
    for (i = 0; i < N; i++)
    {
        scanf("%d%d", &x, &y);
        P[i].x = x;
        P[i].y = y;
    }
    std::sort(&P[0], &P[N], compare1);
    x = P[0].x;
    y = P[0].y;
    countx = 1;
    countxy = 1;
    for (i = 1; i < N; i++)
    {
        if (P[i].x == x)
        {
            countx++;
            if (P[i].y == y)
            {
                countxy++;
            }
            else
            {
                sumxy += (countxy)*(countxy - 1)/2;
                y = P[i].y;
                countxy = 1;
            }
        }
        else
        {
            sumxy += (countxy)*(countxy - 1)/2;
            y = P[i].y;
            countxy = 1;

            sumx += (countx)*(countx - 1)/2;
            x = P[i].x;
            countx = 1;
        }
    }
    sumxy += (countxy)*(countxy - 1)/2;
    sumx += (countx)*(countx - 1)/2;

    std::sort(&P[0], &P[N], compare2);
    y = P[0].y;
    county = 1;
    for (i = 1; i < N; i++)
    {
        if (P[i].y == y)
        {
            county++;
        }
        else
        {
            sumy += (county)*(county - 1)/2;
            y = P[i].y;
            county = 1;
        }
    }
    sumy += (county)*(county - 1)/2;

    //printf("%d %d %d\n", sumx, sumy, sumxy);
    printf("%d", sumx + sumy - sumxy);
}


#include <stdio.h>
#include <algorithm>
typedef struct point point;
struct point
{
    int x;
    int y;
};
bool compare1(point a, point b)
{
    return (a.x < b.x || (a.x == b.x && a.y <= b.y));
}
bool compare2(point a, point b)
{
    return (a.y < b.y || (a.y == b.y && a.x <= b.x));
}
point P[300000];
int main()
{
    int N;
    scanf("%d", &N);
    int i, x, y;
    unsigned long long countx, county, countxy;
    unsigned long long sumx = 0, sumy = 0, sumxy = 0;
    for (i = 0; i < N; i++)
    {
        scanf("%d%d", &x, &y);
        P[i].x = x;
        P[i].y = y;
    }
    std::sort(&P[0], &P[N], compare1);
    x = P[0].x;
    y = P[0].y;
    countx = 1;
    countxy = 1;
    for (i = 1; i < N; i++)
    {
        if (P[i].x == x)
        {
            countx++;
            if (P[i].y == y)
            {
                countxy++;
            }
            else
            {
                sumxy += (countxy)*(countxy - 1)/2;
                y = P[i].y;
                countxy = 1;
            }
        }
        else
        {
            sumxy += (countxy)*(countxy - 1)/2;
            y = P[i].y;
            countxy = 1;

            sumx += (countx)*(countx - 1)/2;
            x = P[i].x;
            countx = 1;
        }
    }
    sumxy += (countxy)*(countxy - 1)/2;
    sumx += (countx)*(countx - 1)/2;

    std::sort(&P[0], &P[N], compare2);
    y = P[0].y;
    county = 1;
    for (i = 1; i < N; i++)
    {
        if (P[i].y == y)
        {
            county++;
        }
        else
        {
            sumy += (county)*(county - 1)/2;
            y = P[i].y;
            county = 1;
        }
    }
    sumy += (county)*(county - 1)/2;

    //printf("%d %d %d\n", sumx, sumy, sumxy);
    printf("%I64u", sumx + sumy - sumxy);
}


#include <stdio.h>
#include <algorithm>
typedef struct point point;
struct point
{
    int x;
    int y;
};
bool compare1(point a, point b)
{
    return (a.x < b.x || (a.x == b.x && a.y < b.y));
}
bool compare2(point a, point b)
{
    return (a.y < b.y || (a.y == b.y && a.x < b.x));
}
point P[1000000];
int main()
{
    int N;
    scanf("%d", &N);
    int i, X, Y;
    unsigned long long countx, county, countxy;
    unsigned long long sumx = 0, sumy = 0, sumxy = 0;
    for (i = 0; i < N; i++)
    {
        scanf("%d%d", &X, &Y);
        P[i].x = X;
        P[i].y = Y;
    }
    std::sort(&P[0], &P[N], compare1);
    X = P[0].x;
    Y = P[0].y;
    countx = 1;
    countxy = 1;
    for (i = 1; i < N; i++)
    {
        if (P[i].x == X)
        {
            countx++;
            if (P[i].y == Y)
            {
                countxy++;
            }
            else
            {
                sumxy += (countxy)*(countxy - 1)/2;
                Y = P[i].y;
                countxy = 1;
            }
        }
        else
        {
            sumxy += (countxy)*(countxy - 1)/2;
            Y = P[i].y;
            countxy = 1;

            sumx += (countx)*(countx - 1)/2;
            X = P[i].x;
            countx = 1;
        }
    }
    sumxy += (countxy)*(countxy - 1)/2;
    sumx += (countx)*(countx - 1)/2;

    std::sort(&P[0], &P[N], compare2);
    Y = P[0].y;
    county = 1;
    for (i = 1; i < N; i++)
    {
        if (P[i].y == Y)
        {
            county++;
        }
        else
        {
            sumy += (county)*(county - 1)/2;
            Y = P[i].y;
            county = 1;
        }
    }
    sumy += (county)*(county - 1)/2;

    //printf("%d %d %d\n", sumx, sumy, sumxy);
    printf("%I64u", sumx + sumy - sumxy);
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    vector<pair<long long int,long long int> >pv,pv1;
    long long int x,y,n,ans=0;
    int i;
    cin>>n;
    for(i=1;i<=n;i++)
    {
        scanf("%I64d%I64d",&x,&y);
        if(x<y)
        pv.push_back(make_pair(x,y));
        else pv.push_back(make_pair(y,x));
        //pv1.push_back(make_pair(y,x));
    }
    sort(pv.begin(),pv.end());
    //sort(pv1.begin(),pv1.end());
    long long int c=1,dob=0;
    for(i=1;i<n;i++)
    {
        if(pv[i].first==pv[i-1].first)
            c++;
        else
        {
            ans=ans+(c*(c-1)/2);
            c=1;
        }
    }
    if(c>1)
        ans=ans+(c*(c-1)/2);
    c=1;
    for(i=1;i<n;i++)
    {
        if(pv[i].first==pv[i-1].first && pv[i].second==pv[i-1].second)
        {
            dob++;
        }
        if(pv[i].second==pv[i-1].second)
            c++;
        else
        {
            ans=ans+(c*(c-1)/2);
            dob=(dob*(dob+1)/2);
            ans=ans-dob;
            dob=0;
            c=1;
        }
    }
    if(c>1)
        ans=ans+(c*(c-1)/2);
    //dob=(dob*(dob+1)/2);
    printf("%I64d",ans-dob);

}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    vector<pair<long long int,long long int> >pv,pv1;
    long long int x,y,n,ans=0;
    int i;
    cin>>n;
    for(i=1;i<=n;i++)
    {
        scanf("%I64d%I64d",&x,&y);
        pv.push_back(make_pair(x,y));
        pv1.push_back(make_pair(y,x));
    }
    sort(pv.begin(),pv.end());
    sort(pv1.begin(),pv1.end());
    long long int c=1,dob=0;
    for(i=1;i<n;i++)
    {
        if(pv[i].first==pv[i-1].first)
            c++;
        else
        {
            ans=ans+(c*(c-1)/2);
            c=1;
        }
    }
    if(c>1)
        ans=ans+(c*(c-1)/2);
    c=1;
    for(i=1;i<n;i++)
    {
        if(pv1[i].first==pv1[i-1].first && pv1[i].second==pv1[i-1].second)
        {
            dob++;
        }
        else
        {
            dob=(dob*(dob+1)/2);
            ans=ans-dob;
            dob=0;
        }
        if(pv1[i].first==pv1[i-1].first)
            c++;
        else
        {
            ans=ans+(c*(c-1)/2);
            c=1;
        }
    }
    if(c>1)
        ans=ans+(c*(c-1)/2);
    dob=(dob*(dob+1)/2);
    printf("%I64d",ans-dob);

}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    vector<pair<long long int,long long int> >pv,pv1;
    long long int x,y,n,ans=0;
    int i;
    cin>>n;
    for(i=1;i<=n;i++)
    {
        scanf("%I64d%I64d",&x,&y);
        pv.push_back(make_pair(x,y));
        pv1.push_back(make_pair(y,x));
    }
    sort(pv.begin(),pv.end());
    sort(pv1.begin(),pv1.end());
    long long int c=1,dob=0;
    for(i=1;i<n;i++)
    {
        if(pv[i].first==pv[i-1].first && pv[i].second==pv[i-1].second)
        {
            dob++;
        }
        if(pv[i].first==pv[i-1].first)
            c++;
        else
        {
            ans=ans+(c*(c-1)/2);
            c=1;
        }
    }
    if(c>1)
        ans=ans+(c*(c-1)/2);
    c=1;
    for(i=1;i<n;i++)
    {
        if(pv1[i].first==pv1[i-1].first)
            c++;
        else
        {
            ans=ans+(c*(c-1)/2);
            c=1;
        }
    }
    if(c>1)
        ans=ans+(c*(c-1)/2);
    dob=(dob*(dob+1)/2);
    printf("%I64d",ans-dob);

}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    vector<pair<long long int,long long int> >pv,pv1;
    long long int x,y,n,ans=0;
    int i;
    cin>>n;
    for(i=1;i<=n;i++)
    {
        scanf("%I64d%I64d",&x,&y);
        pv.push_back(make_pair(x,y));
        pv1.push_back(make_pair(y,x));
    }
    sort(pv.begin(),pv.end());
    sort(pv1.begin(),pv1.end());
    long long int c=1,dob=1;
    for(i=1;i<n;i++)
    {
        if(pv[i].first==pv[i-1].first)
            c++;
        else
        {
            ans=ans+(c*(c-1)/2);
            c=1;
        }
    }
    if(c>1)
        ans=ans+(c*(c-1)/2);
    c=1;
    for(i=1;i<n;i++)
    {
        if(pv1[i].first==pv1[i-1].first && pv1[i].second==pv1[i-1].second)
        {
            dob++;
        }
        else
        {
            dob=(dob*(dob-1)/2);
            ans=ans-dob;
            dob=1;
        }
        if(pv1[i].first==pv1[i-1].first)
            c++;
        else
        {
            ans=ans+(c*(c-1)/2);
            c=1;
        }
    }
    if(c>1)
        ans=ans+(c*(c-1)/2);
    dob=(dob*(dob-1)/2);
    printf("%I64d",ans-dob);

}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    vector<pair<long long int,long long int> >pv,pv1;
    long long int x,y,n,ans=0;
    int i;
    cin>>n;
    for(i=1;i<=n;i++)
    {
        scanf("%I64d%I64d",&x,&y);
        pv.push_back(make_pair(x,y));
        pv1.push_back(make_pair(y,x));
    }
    sort(pv.begin(),pv.end());
    sort(pv1.begin(),pv1.end());
    long long int c=1,dob=0;
    for(i=1;i<n;i++)
    {

        if(pv[i].first==pv[i-1].first)
            c++;
        else
        {
            ans=ans+(c*(c-1)/2);
            c=1;
        }
    }
    if(c>1)
        ans=ans+(c*(c-1)/2);
    c=1;
    for(i=1;i<n;i++)
    {
        if(pv1[i].first==pv1[i-1].first && pv1[i].second==pv1[i-1].second)
        {
            dob++;
        }
        if(pv1[i].first==pv1[i-1].first)
            c++;
        else
        {
            ans=ans+(c*(c-1)/2);
            dob=(dob*(dob+1)/2);
            ans=ans-dob;
            dob=0;
            c=1;
        }
    }
    if(c>1)
        ans=ans+(c*(c-1)/2);
    //dob=(dob*(dob+1)/2);
    printf("%I64d",ans-dob);

}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    vector<pair<long long int,long long int> >pv,pv1;
    long long int x,y,n,ans=0;
    int i;
    cin>>n;
    for(i=1;i<=n;i++)
    {
        scanf("%I64d%I64d",&x,&y);
        pv.push_back(make_pair(x,y));
        pv1.push_back(make_pair(y,x));
    }
    sort(pv.begin(),pv.end());
    sort(pv1.begin(),pv1.end());
    long long int c=1,dob=0;
    for(i=1;i<n;i++)
    {

        if(pv[i].first==pv[i-1].first)
            c++;
        else
        {
            ans=ans+(c*(c-1)/2);
            c=1;
        }
    }
    if(c>1)
        ans=ans+(c*(c-1)/2);
    c=1;
    for(i=1;i<n;i++)
    {
        if(pv[i].first==pv[i-1].first && pv[i].second==pv[i-1].second)
        {
            dob++;
        }
        if(pv1[i].first==pv1[i-1].first)
            c++;
        else
        {
            ans=ans+(c*(c-1)/2);
            dob=(dob*(dob+1)/2);
            ans=ans-dob;
            dob=0;
            c=1;
        }
    }
    if(c>1)
        ans=ans+(c*(c-1)/2);
    //dob=(dob*(dob+1)/2);
    printf("%I64d",ans-dob);

}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    vector<pair<long long int,long long int> >pv,pv1;
    long long int x,y,n,ans=0;
    int i;
    cin>>n;
    for(i=1;i<=n;i++)
    {
        scanf("%I64d%I64d",&x,&y);
        pv.push_back(make_pair(x,y));
        pv1.push_back(make_pair(y,x));
    }
    sort(pv.begin(),pv.end());
    sort(pv1.begin(),pv1.end());
    long long int c=1,dob=0;
    for(i=1;i<n;i++)
    {
        if(pv[i].first==pv[i-1].first)
            c++;
        else
        {
            ans=ans+(c*(c-1)/2);
            c=1;
        }
    }
    if(c>1)
        ans=ans+(c*(c-1)/2);
    c=1;
    for(i=1;i<n;i++)
    {
        if(pv1[i].first==pv1[i-1].first && pv1[i].second==pv1[i-1].second)
        {
            dob++;
        }
        if(pv1[i].first==pv1[i-1].first)
            c++;
        else
        {
            ans=ans+(c*(c-1)/2);
            dob=(dob*(dob+1)/2);
            ans=ans-dob;
            dob=0;
            c=1;
        }
    }
    if(c>1)
        ans=ans+(c*(c-1)/2);
    dob=(dob*(dob+1)/2);
    printf("%I64d",ans-dob);

}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    vector<pair<long long int,long long int> >pv,pv1;
    long long int x,y,n,ans=0;
    int i;
    cin>>n;
    for(i=1;i<=n;i++)
    {
        scanf("%I64d%I64d",&x,&y);
        pv.push_back(make_pair(x,y));
        pv1.push_back(make_pair(y,x));
    }
    sort(pv.begin(),pv.end());
    sort(pv1.begin(),pv1.end());
    long long int c=1,dob=0;
    for(i=1;i<n;i++)
    {
        if(pv[i].first==pv[i-1].first && pv[i].second==pv[i-1].second)
        {
            dob++;
        }
        if(pv[i].first==pv[i-1].first)
            c++;
        else
        {
            ans=ans+(c*(c-1)/2);
            c=1;
        }
    }
    if(c>1)
        ans=ans+(c*(c-1)/2);
    c=1;
    for(i=1;i<n;i++)
    {
        if(pv1[i].first==pv1[i-1].first)
            c++;
        else
        {
            ans=ans+(c*(c-1)/2);
            c=1;
        }
    }
    if(c>1)
        ans=ans+(c*(c-1)/2);
    //dob=(dob*(dob+1)/2);
    printf("%I64d",ans-dob);

}