Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define FileIO
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.IO;
- using System.Diagnostics;
- using System.Threading;
- namespace CF
- {
- //delegate double F(double x);
- //delegate decimal Fdec(decimal x);
- class Program
- {
- static void Main(string[] args)
- {
- #if FileIO
- StreamReader sr = new StreamReader("triangles.in");
- StreamWriter sw = new StreamWriter("triangles.out");
- Console.SetIn(sr);
- Console.SetOut(sw);
- #endif
- Dictionary<int, int> xHash = new Dictionary<int, int>();
- Dictionary<int, int> yHash = new Dictionary<int, int>();
- int n = ReadInt();
- int[] _x = new int[n];
- int[] _y = new int[n];
- for (int i = 0; i < n; i++)
- {
- string[] input = ReadArray();
- int x = int.Parse(input[0]);
- int y = int.Parse(input[1]);
- if (xHash.ContainsKey(x))
- xHash[x]++;
- else
- xHash.Add(x, 1);
- if (yHash.ContainsKey(y))
- yHash[y]++;
- else
- yHash.Add(y, 1);
- _x[i] = x;
- _y[i] = y;
- }
- int[] onLine = new int[n];
- for (int i = 0; i < n; i++)
- {
- onLine[_x[i]] += (yHash[_y[i]] - 1);
- }
- long ans = 0;
- foreach (int x in xHash.Keys)
- {
- ans += onLine[x] * (xHash[x] - 1);
- }
- Console.WriteLine(ans);
- #if Online
- Console.ReadLine();
- #endif
- #if FileIO
- sr.Close();
- sw.Close();
- #endif
- }
- static string[] ReadArray()
- {
- return Console.ReadLine().Split(' ');
- }
- static int ReadInt()
- {
- return int.Parse(Console.ReadLine());
- }
- }
- /* public static class MyMath
- {
- public static long BinPow(long a, long n, long mod)
- {
- long res = 1;
- while (n > 0)
- {
- if ((n & 1) == 1)
- {
- res = (res * a) % mod;
- }
- a = (a * a) % mod;
- n >>= 1;
- }
- return res;
- }
- public static long GCD(long a, long b)
- {
- while (b != 0) b = a % (a = b);
- return a;
- }
- public static int GCD(int a, int b)
- {
- while (b != 0) b = a % (a = b);
- return a;
- }
- public static long LCM(long a, long b)
- {
- return (a * b) / GCD(a, b);
- }
- public static int LCM(int a, int b)
- {
- return (a * b) / GCD(a, b);
- }
- }
- public class SegmentTree
- {
- int[] v_min;
- int[] v_max;
- int[] mas;
- public void BuildTree(int[] a)
- {
- int n = a.Length - 1;
- int z = 0;
- while (n >= 2)
- {
- z++;
- n >>= 1;
- }
- n = 1 << (z + 1);
- v_min = new int[n << 1];
- v_max = new int[n << 1];
- mas = new int[n << 1];
- for (int i = n; i < n + a.Length; i++)
- v_min[i] = a[i - n];
- for (int i = n + a.Length; i < v_min.Length; i++)
- v_min[i] = int.MaxValue;
- for (int i = n - 1; i > 0; i--)
- v_min[i] = Math.Min(v_min[(i << 1)], v_min[(i << 1) + 1]);
- for (int i = n; i < n + a.Length; i++)
- v_max[i] = a[i - n];
- for (int i = n + a.Length; i < v_max.Length; i++)
- v_max[i] = int.MinValue;
- for (int i = n - 1; i > 0; i--)
- v_max[i] = Math.Max(v_max[(i << 1)], v_max[(i << 1) + 1]);
- }
- //nil
- public int RMQ_MIN(int l, int r)
- {
- int ans = int.MaxValue;
- l += v_min.Length >> 1;
- r += v_min.Length >> 1;
- const int o = 1;
- while (l <= r)
- {
- if ((l & 1) == o)
- ans = Math.Min(ans, v_min[l]);
- if (!((r & 1) == 0))
- ans = Math.Min(ans, v_min[r]);
- l = (l + 1) >> 1;
- r = (r - 1) >> 1;
- }
- return ans;
- }
- public int RMQ_MAX(int l, int r)
- {
- int ans = int.MinValue;
- l += v_max.Length >> 1;
- r += v_max.Length >> 1;
- const int o = 1;
- while (l <= r)
- {
- if ((l & 1) == o)
- ans = Math.Max(ans, v_max[l]);
- if (!((r & 1) == 0))
- ans = Math.Max(ans, v_max[r]);
- l = (l + 1) >> 1;
- r = (r - 1) >> 1;
- }
- return ans;
- }
- public void Put(int l, int r, int op)
- {
- l += mas.Length >> 1;
- r += mas.Length >> 1;
- while (l <= r)
- {
- if (l % 2 != 0)
- mas[l] = op;
- if (r % 2 == 0)
- mas[r] = op;
- l = (l + 1) >> 1;
- r = (r - 1) >> 1;
- }
- }
- public int Get(int x)
- {
- x += mas.Length >> 1;
- int ans = int.MinValue;
- while (x > 0)
- {
- ans = Math.Max(mas[x], ans);
- x >>= 1;
- }
- return ans;
- }
- public void Update(int i, int x)
- {
- i += v_min.Length >> 1;
- v_min[i] = x;
- v_max[i] = x;
- i >>= 1;
- while (i > 0)
- {
- v_min[i] = Math.Min(v_min[(i << 1)], v_min[(i << 1) + 1]);
- v_max[i] = Math.Max(v_max[(i << 1)], v_max[(i << 1) + 1]);
- i >>= 1;
- }
- }
- }
- class Edge
- {
- public int a;
- public int b;
- public int w;
- public Edge(int a, int b, int w)
- {
- this.a = a;
- this.b = b;
- this.w = w;
- }
- }
- /* class Graph
- {
- public List<int>[] g;
- public int[] color; //0-white, 1-gray, 2-black
- public int[] o; //open
- public int[] c; //close
- public int[] p;
- public int[] d;
- public List<Edge> e;
- public Graph(int n)
- {
- g = new List<int>[n + 1];
- color = new int[n + 1];
- o = new int[n + 1];
- c = new int[n + 1];
- p = new int[n + 1];
- d = new int[n + 1];
- }
- }
- static class GraphUtils
- {
- const int white = 0;
- const int gray = 1;
- const int black = 2;
- public static void BFS(int s, Graph g)
- {
- Queue<int> q = new Queue<int>();
- q.Enqueue(s);
- while (q.Count != 0)
- {
- int u = q.Dequeue();
- for (int i = 0; i < g.g[u].Count; i++)
- {
- int v = g.g[u][i];
- if (g.color[v] == white)
- {
- g.color[v] = gray;
- g.d[v] = g.d[u] + 1;
- g.p[v] = u;
- q.Enqueue(v);
- }
- }
- g.color[u] = black;
- }
- }
- public static void DFS(int u, ref int time, Graph g)
- {
- g.color[u] = gray;
- time++;
- g.o[u] = time;
- for (int i = 0; i < g.g[u].Count; i++)
- {
- int v = g.g[u][i];
- if (g.color[v] == white)
- {
- g.p[v] = u;
- DFS(v, ref time, g);
- }
- }
- g.color[u] = black;
- g.c[u] = time;
- time++;
- }
- public static void FordBellman(int u, Graph g)
- {
- int n = g.g.Length;
- for (int i = 0; i <= n; i++)
- {
- g.d[i] = int.MaxValue;
- g.p[i] = 0;
- }
- g.d[u] = 0;
- for (int i = 0; i < n - 1; i++)
- {
- for (int j = 0; j < g.e.Count; j++)
- {
- if (g.d[g.e[j].a] != int.MaxValue)
- {
- if (g.d[g.e[j].a] + g.e[j].w < g.d[g.e[j].b])
- {
- g.d[g.e[j].b] = g.d[g.e[j].a] + g.e[j].w;
- g.p[g.e[j].b] = g.e[j].a;
- }
- }
- }
- }
- }
- }*//*
- static class ArrayUtils
- {
- public static int BinarySearch(int[] a, int val)
- {
- int left = 0;
- int right = a.Length - 1;
- int mid;
- while (left < right)
- {
- mid = left + ((right - left) >> 1);
- if (val <= a[mid])
- {
- right = mid;
- }
- else
- {
- left = mid + 1;
- }
- }
- if (a[left] == val)
- return left;
- else
- return -1;
- }
- public static double Bisection(F f, double left, double right, double eps)
- {
- double mid;
- while (right - left > eps)
- {
- mid = left + ((right - left) / 2d);
- if (Math.Sign(f(mid)) != Math.Sign(f(left)))
- right = mid;
- else
- left = mid;
- }
- return (left + right) / 2d;
- }
- public static decimal TernarySearchDec(Fdec f, decimal eps, decimal l, decimal r, bool isMax)
- {
- decimal m1, m2;
- while (r - l > eps)
- {
- m1 = l + (r - l) / 3m;
- m2 = r - (r - l) / 3m;
- if (f(m1) < f(m2))
- if (isMax)
- l = m1;
- else
- r = m2;
- else
- if (isMax)
- r = m2;
- else
- l = m1;
- }
- return r;
- }
- public static double TernarySearch(F f, double eps, double l, double r, bool isMax)
- {
- double m1, m2;
- while (r - l > eps)
- {
- m1 = l + (r - l) / 3d;
- m2 = r - (r - l) / 3d;
- if (f(m1) < f(m2))
- if (isMax)
- l = m1;
- else
- r = m2;
- else
- if (isMax)
- r = m2;
- else
- l = m1;
- }
- return r;
- }
- public static void Merge<T>(T[] A, int p, int q, int r, T[] L, T[] R) where T : IComparable<T>
- {
- for (int i = p; i <= q; i++)
- L[i] = A[i];
- for (int i = q + 1; i <= r; i++)
- R[i] = A[i];
- for (int k = p, i = p, j = q + 1; k <= r; k++)
- {
- if (i > q)
- {
- for (; k <= r; k++, j++)
- A[k] = R[j];
- return;
- }
- if (j > r)
- {
- for (; k <= r; k++, i++)
- A[k] = L[i];
- return;
- }
- if (L[i].CompareTo(R[j]) <= 0)
- {
- A[k] = L[i];
- i++;
- }
- else
- {
- A[k] = R[j];
- j++;
- }
- }
- }
- public static void Merge_Sort<T>(T[] A, int p, int r, T[] L, T[] R) where T : IComparable<T>
- {
- if (p >= r) return;
- int q = p + ((r - p) >> 1);
- Merge_Sort(A, p, q, L, R);
- Merge_Sort(A, q + 1, r, L, R);
- Merge(A, p, q, r, L, R);
- }
- static void Shake<T>(T[] a)
- {
- Random rnd = new Random(Environment.TickCount);
- T temp;
- int b, c;
- for (int i = 0; i < a.Length; i++)
- {
- b = rnd.Next(0, a.Length);
- c = rnd.Next(0, a.Length);
- temp = a[b];
- a[b] = a[c];
- a[c] = temp;
- }
- }
- }
- */
- }
Advertisement
Add Comment
Please, Sign In to add comment