Language: C++

#include <bits/stdc++.h>
using namespace std;
namespace fastIO{
	#define BUF_SIZE 100000
	#define OUT_SIZE 100000
	//fread->read
	bool IOerror=0;
//	inline char nc(){char ch=getchar();if(ch==-1)IOerror=1;return ch;} 
	inline char nc(){
		static char buf[BUF_SIZE],*p1=buf+BUF_SIZE,*pend=buf+BUF_SIZE;
		if(p1==pend){
			p1=buf;pend=buf+fread(buf,1,BUF_SIZE,stdin);
			if(pend==p1){IOerror=1;return -1;}
		}
		return *p1++;
	}
	inline bool blank(char ch){return ch==' '||ch=='\n'||ch=='\r'||ch=='\t';}
	template<class T> inline bool read(T &x){
		bool sign=0;char ch=nc();x=0;
		for(;blank(ch);ch=nc());
		if(IOerror)return false;
		if(ch=='-')sign=1,ch=nc();
		for(;ch>='0'&&ch<='9';ch=nc())x=x*10+ch-'0';
		if(sign)x=-x;
		return true;
	}
	inline bool read(double &x){
		bool sign=0;char ch=nc();x=0;
		for(;blank(ch);ch=nc());
		if(IOerror)return false;
		if(ch=='-')sign=1,ch=nc();
		for(;ch>='0'&&ch<='9';ch=nc())x=x*10+ch-'0';
		if(ch=='.'){
			double tmp=1; ch=nc();
			for(;ch>='0'&&ch<='9';ch=nc())tmp/=10.0,x+=tmp*(ch-'0');
		}
		if(sign)x=-x;
		return true;
	}
	inline bool read(char *s){
		char ch=nc();
		for(;blank(ch);ch=nc());
		if(IOerror)return false;
		for(;!blank(ch)&&!IOerror;ch=nc())*s++=ch;
		*s=0;
		return true;
	}
	inline bool read(char &c){
		for(c=nc();blank(c);c=nc());
		if(IOerror){c=-1;return false;}
		return true; 
	}
	template<class T,class... U>bool read(T& h,U&... t){return read(h)&&read(t...);}
	#undef OUT_SIZE
	#undef BUF_SIZE
};
using namespace fastIO;
/************* debug begin *************/
string to_string(string s){return '"'+s+'"';}
string to_string(const char* s){return to_string((string)s);}
string to_string(const bool& b){return(b?"true":"false");}
template<class T>string to_string(T x){ostringstream sout;sout<<x;return sout.str();}
template<class A,class B>string to_string(pair<A,B> p){return "("+to_string(p.first)+", "+to_string(p.second)+")";}
template<class A>string to_string(const vector<A> v){
	int f=1;string res="{";for(const auto x:v){if(!f)res+= ", ";f=0;res+=to_string(x);}res+="}";
	return res;
}
void debug_out(){puts("");}
template<class T,class... U>void debug_out(const T& h,const U&... t){cout<<" "<<to_string(h);debug_out(t...);}
#ifdef tokitsukaze 
#define debug(...) cout<<"["<<#__VA_ARGS__<<"]:",debug_out(__VA_ARGS__);
#else
#define debug(...) 233;
#endif
/*************  debug end  *************/
#define mem(a,b) memset((a),(b),sizeof(a))
#define MP make_pair
#define pb push_back
#define fi first
#define se second
#define sz(x) (int)x.size()
#define all(x) x.begin(),x.end()
#define sqr(x) (x)*(x)
using namespace __gnu_cxx;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef pair<int,ll> PIL;
typedef pair<ll,int> PLI;
typedef vector<int> VI;
typedef vector<ll> VL;
/************* define end  *************/
void read(int *x,int l,int r){for(int i=l;i<=r;i++) read(x[i]);}
void read(ll *x,int l,int r){for(int i=l;i<=r;i++) read(x[i]);}
void read(double *x,int l,int r){for(int i=l;i<=r;i++) read(x[i]);}
void println(VI x){for(int i=0;i<sz(x);i++) printf("%d%c",x[i]," \n"[i==sz(x)-1]);}
void println(VL x){for(int i=0;i<sz(x);i++) printf("%lld%c",x[i]," \n"[i==sz(x)-1]);}
void println(int *x,int l,int r){for(int i=l;i<=r;i++) printf("%d%c",x[i]," \n"[i==r]);}
void println(ll *x,int l,int r){for(int i=l;i<=r;i++) printf("%lld%c",x[i]," \n"[i==r]);}
/*************** IO end  ***************/
void go();
int main(){
	#ifdef tokitsukaze
		freopen("TEST.txt","r",stdin);
	#endif
	go();return 0;
}
const int INF=0x3f3f3f3f;
const ll LLINF=0x3f3f3f3f3f3f3f3fLL;
const double PI=acos(-1.0);
const double eps=1e-6;
const int MAX=2e5+10;
const ll mod=998244353;
/*********************************  head  *********************************/
struct Segment_Tree_2D
{
	#define type int
	static const int insert_num=MAX;
	static const int N=insert_num*400; //insert_num*20*log(m)
	int root[MAX<<2],tot,ls[N<<2],rs[N<<2],n,m;
	int ql_in,qr_in,ql_out,qr_out;
	type v[N<<2],qv,tag[N<<2];
	void init(int _n,int _m)
	{
		n=_n;
		m=_m;
		mem(root,0);
		ls[0]=rs[0]=0;
		tag[0]=0;
		v[0]=0; 
		tot=1;
	}
	int newnode()
	{
		ls[tot]=rs[tot]=0;
		v[tot]=0;
		tag[tot]=0;
		return tot++;
	}
	void pushup(int id)
	{
		v[id]=v[ls[id]]+v[rs[id]];
	}
	void update_in(int l,int r,int &id)
	{
		if(!id) id=newnode();
		if(l>=ql_in&&r<=qr_in)
		{
			v[id]+=qv;   //must update not =
			return;
		}
		int mid=(l+r)>>1;
		if(ql_in<=mid) update_in(l,mid,ls[id]);
		if(qr_in>mid) update_in(mid+1,r,rs[id]);
		pushup(id);
	}
	type res_in;
	void query_in(int l,int r,int &id)
	{
		if(!id) return;
		if(l>=ql_in&&r<=qr_in)
		{
			res_in+=v[id];
			return;
		}
		int mid=(l+r)>>1;
		type res=0;
		if(ql_in<=mid) query_in(l,mid,ls[id]);
		if(qr_in>mid) query_in(mid+1,r,rs[id]);
	}
	/*************************************************/
	#define ls (id<<1)
	#define rs (id<<1|1)
	void update_out(int l,int r,int id)
	{
		update_in(1,m,root[id]);
		if(l>=ql_out&&r<=qr_out) return;
		int mid=(l+r)>>1;
		if(ql_out<=mid) update_out(l,mid,ls);
		if(qr_out>mid) update_out(mid+1,r,rs);
	}
	type res_out;
	void query_out(int l,int r,int id)
	{
		if(l>=ql_out&&r<=qr_out)
		{
			res_in=0;
			query_in(1,m,root[id]);
			res_out+=res_in;
			return;
		}
		int mid=(l+r)>>1;
		if(ql_out<=mid) query_out(l,mid,ls);
		if(qr_out>mid) query_out(mid+1,r,rs);
	}
	#undef ls
	#undef rs
	void upd(int x1,int y1,int x2,int y2,type val)
	{
		ql_out=x1;
		qr_out=x2;
		ql_in=y1;
		qr_in=y2;
		qv=val;
		update_out(1,n,1);
	}
	type ask(int x1,int y1,int x2,int y2)
	{
		ql_out=x1;
		qr_out=x2;
		ql_in=y1;
		qr_in=y2;
		res_out=0;
		query_out(1,n,1);
		return res_out;
	}
	#undef type
}tr;
ll pow2(ll a,ll b)
{
	ll res=1;
	while(b)
	{
		if(b&1) res=res*a%mod;
		a=a*a%mod;
		b>>=1;
	}
	return res;
}
struct Discretization
{
	#define type ll
	vector<type> a;
	void init(){a.clear();}
	void add(type x){a.pb(x);}
	void work(){sort(all(a));a.resize(unique(all(a))-a.begin());}
	int get_pos(type x){return lower_bound(all(a),x)-a.begin()+1;}
	type get_val(int pos){return a[pos-1];}
	int size(){return a.size();}
	#undef type
}dx,dy;
PII a[MAX];
void add(ll &a,ll b)
{
	a+=b;
	if(a>=mod) a-=mod;
	if(a<0) a+=mod;
}
void go()
{
	int n,i,x,y;
	ll ans;
	while(read(n))
	{
		tr.init(n,n);
		dx.init();
		dy.init();
		for(i=1;i<=n;i++)
		{
			read(a[i].fi,a[i].se);
			dx.add(a[i].fi);
			dy.add(a[i].se);
		}
		dx.work();
		dy.work();
		for(i=1;i<=n;i++)
		{
			x=dx.get_pos(a[i].fi);
			y=dy.get_pos(a[i].se);
			tr.upd(x,y,x,y,1);
		}
		ans=0;
		for(i=1;i<=n;i++)
		{
			x=dx.get_pos(a[i].fi);
			y=dy.get_pos(a[i].se);
			tr.upd(x,y,x,y,-1);
			
			add(ans,pow2(2,n));
			
			add(ans,-pow2(2,tr.ask(1,y,n,n)));
			add(ans,-pow2(2,tr.ask(1,1,n,y)));
			add(ans,-pow2(2,tr.ask(1,1,x,n)));
			add(ans,-pow2(2,tr.ask(x,1,n,n)));
			
			add(ans,pow2(2,tr.ask(1,1,x,y)));
			add(ans,pow2(2,tr.ask(1,y,x,n)));
			add(ans,pow2(2,tr.ask(x,y,n,n)));
			add(ans,pow2(2,tr.ask(x,1,n,y)));
			
			add(ans,-1);
			
			tr.upd(x,y,x,y,1);
		}
		printf("%lld\n",ans);
	}
}


Compiler output:
/tmp/ccA4sKj5.o: in function `go()':
a.cc:(.text+0x5d9): relocation truncated to fit: R_X86_64_PC32 against symbol `dx' defined in .bss section in /tmp/ccA4sKj5.o
a.cc:(.text+0x5e8): relocation truncated to fit: R_X86_64_PC32 against symbol `dy' defined in .bss section in /tmp/ccA4sKj5.o
a.cc:(.text+0x610): relocation truncated to fit: R_X86_64_PC32 against symbol `a' defined in .bss section in /tmp/ccA4sKj5.o
a.cc:(.text+0x62b): relocation truncated to fit: R_X86_64_PC32 against symbol `a' defined in .bss section in /tmp/ccA4sKj5.o
a.cc:(.text+0x64d): relocation truncated to fit: R_X86_64_PC32 against symbol `a' defined in .bss section in /tmp/ccA4sKj5.o
a.cc:(.text+0x65c): relocation truncated to fit: R_X86_64_PC32 against symbol `dx' defined in .bss section in /tmp/ccA4sKj5.o
a.cc:(.text+0x678): relocation truncated to fit: R_X86_64_PC32 against symbol `a' defined in .bss section in /tmp/ccA4sKj5.o
a.cc:(.text+0x687): relocation truncated to fit: R_X86_64_PC32 against symbol `dy' defined in .bss section in /tmp/ccA4sKj5.o
a.cc:(.text+0x6a6): relocation truncated to fit: R_X86_64_PC32 against symbol `dx' defined in .bss section in /tmp/ccA4sKj5.o
a.cc:(.text+0x6b5): relocation truncated to fit: R_X86_64_PC32 against symbol `dy' defined in .bss section in /tmp/ccA4sKj5.o
a.cc:(.text+0x6dd): additional relocation overflows omitted from the output
collect2: error: ld returned 1 exit status