#includeusing namespace std;#define pb push_back#define lb lower_bound#define ull unsigned ll#define gcd(a,b) __gcd(a,b)#define pii pair #define all(x) x.begin(),x.end()#define ll long long#define mp make_pair//#define pi acos(-1)#define mod 1000000007#define inf (1LL<<31)-1map > X,Y;vector > V;const int mx = 200005;int tree[mx], pos[mx],N;int getPos(int n){ return (int) (lb(pos,pos+N,n)-pos) + 1;}int update(int idx,int val){ while(idx<=N) { tree[idx] += val; idx += (idx&-idx); } return 0;}int sum(int idx){ int res = 0; while(idx>0) { res += tree[idx]; idx -= (idx&-idx); } return res;}int main(){ int i,j,k,n; scanf("%d",&n); int x1,y1,x2,y2; for(i=0;i x2) swap(x1,x2); if(y1>y2) swap(y1,y2); if(x1==x2) Y[x1].pb(mp(y1,y2)); else X[y1].pb(mp(x1,x2)); pos[N++] = y1; pos[N++] = y2; } sort(pos,pos+N); N = (int) (unique(pos,pos+N)-pos); map > :: iterator it; ll ans = 0; for(it=X.begin();it!=X.end();it++) { vector & vt = it -> second; sort(all(vt)); int y = (it -> first); int x1 = vt[0].first; int x2 = vt[0].second; int sz = vt.size(); for(i=1;i & vt = it -> second; sort(all(vt)); int x = (it -> first); while(p =V[p].first) { int t1 = V[p].second.first; int t2 = V[p].second.second; t2 = getPos(t2); update(t2,-t1); p++; } int y1 = vt[0].first; int y2 = vt[0].second; int sz = vt.size(); for(i=1;i