Untitled

mail@pastecode.io avatar
unknown
plain_text
6 months ago
2.3 kB
3
Indexable
Never
#include <bits/stdc++.h>
 
using namespace std;
 

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef __gnu_pbds::tree<int, __gnu_pbds::null_type, less<int>, __gnu_pbds::rb_tree_tag, __gnu_pbds::tree_order_statistics_node_update> ordered_set;  
using namespace __gnu_pbds;
  
void icecube()
{
	ios_base::sync_with_stdio(false);
      cin.tie(NULL);
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif
}

#define LL 						long long int
#define ULL 					unsigned long long int
#define pb 						push_back
#define mp 						make_pair
#define pob 					pop_back
#define MOD 					1000000007
#define INF 					ULLONG_MAX
#define NINF 					LLONG_MIN
#define onebits(x)      		__builtin_popcountll(x)
#define zerobits(x)      		__builtin_ctzll(x)
#define FOR(i,a,b) 				for(LL i=(a);i<(b);i++) 
#define FORR(i,n) 		 		for(LL i=(n);i>=0;i--)
#define ps(x,y)         		fixed<<setprecision(y)<<x

LL binpow(int a, int b) {
	if (b == 0) return 1;
    	long long res = binpow(a, b / 2);
    	if (b % 2) return ((res%MOD) * (res%MOD) * (a%MOD))%MOD;
    	else return ((res%MOD) * (res%MOD))%MOD;
}

long long highestPowerof2(long long N)
{
    	if (!(N & (N - 1))) return N;
    	return 0x8000000000000000 >> (__builtin_clzll(N));
}

string dectobinary(LL n)
{
    	LL na = (LL)(log2(n));
    	return bitset<64>(n).to_string().substr(64 - na - 1);
}

LL binarytodec(string binary_string)
{ 
    	bitset<64> bits(binary_string); 
    	unsigned long decimal_value = bits.to_ulong(); 
    	return decimal_value; 
}

int factorial(int n)
{
	if(n==1 || n==0)return 1;
	else return ((n%MOD)*(factorial(n-1))%MOD)%MOD ;
}

void solve()
{
	int n;
	cin >> n;
	vector<pair<LL,LL>> v;
	set <LL> s;
	FOR(i,0,n)
	{
		LL a,b;
		cin >> a >> b;
		v.pb(mp(a,b));
		s.insert(b);
	}
	sort(v.begin(),v.end());
	LL ans=0;
	FOR(i,0,v.size())
	{
		ans += s.order_of_key(v[i].second);
	}
	cout << ans << endl;
}

int main()
{
	icecube();
	LL tc = 1;
	//cin >> tc;
	FOR(i,1,tc+1)
	{
		//cout << "Case #" << i << ": ";
        	solve();
        	//cout << endl;
	}
	cerr<<"Time: "<<1000*((double)clock())/(double)CLOCKS_PER_SEC<<" ms\n";
	return 0;
}
Leave a Comment