Language: C++

//W4P3R
#include<bits/stdc++.h>
#define inf 1e9
#define eps 1e-6
#define re register int 
#define FOR(i,a,b) for(re i=a;i<=b;i++)
#define REP(i,a,b) for(re i=a;i>=b;i--)
#define mp make_pair
#define pb push_back
#define pf push_front
#define pa pair<int,int>
#define fr first
#define sd second
#define Z(x) (x>=mod?x-mod:x)
#define lowbit(x) (x&(-x))
#define N 1000010
#define ls (x<<1)
#define rs (x<<1|1)
#define mid ((l+r)>>1)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
inline ll read()
{
    char ch=getchar();
    ll s=0,w=1;
    while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){s=s*10+ch-'0';ch=getchar();}
    return s*w;
}
pa p[N],g[N];
int n;int st[N],top,f[N],s[N];
vector<int>v[N];
const int mod=1e9+7;
int minn[N<<2],maxn[N<<2];
void build(int l,int r,int x)
{
	if(l==r){minn[x]=maxn[x]=p[l].sd;return ;}
	build(l,mid,ls);build(mid+1,r,rs);
	minn[x]=min(minn[ls],minn[rs]);
	maxn[x]=max(maxn[ls],maxn[rs]);
}
int askl(int l,int r,int x,int val)
{
	if(maxn[x]<val)return inf;
	if(l==r){return l;}int t=askl(l,mid,ls,val);
	if(t!=inf)return t;
	else return askl(mid+1,r,rs,val);
}
int askr(int l,int r,int x,int pos,int val)
{
	if(minn[x]>val)return -inf;
	if(l==r){return l;}int t=askr(mid+1,r,rs,val);
	if(t!=-inf)return t;
	else return askr(l,mid,ls,val);
}
int main()
{
    //freopen(".in","r",stdin);
    //freopen(".out","w",stdout);
    n=read();
    FOR(i,1,n)p[i].sd=read(),p[i].fr=read();
    sort(p+1,p+n+1);build(1,n,1);
    FOR(i,1,n)g[i].sd=min(askl(1,n,1,p[i].sd),i),g[i].fr=max(askr(1,n,1,p[i].sd),i);
    //FOR(i,1,n)cout<<g[i].sd<<" "<<g[i].fr<<endl;
    FOR(i,1,n)v[g[i].fr].pb(g[i].sd);
    f[0]=1;
    FOR(i,0,n)s[i]=1;
    FOR(i,1,n)
    {
    	s[i]=Z(s[i-1]+f[i]);
    	for(int x:v[i])
		{
			f[i]=Z(f[i]+Z(s[i]+mod-(x>1?s[x-2]:0)));
			s[i]=Z(s[i-1]+f[i]);
		}
		//cout<<"WTF:"<<i<<" "<<f[i]<<endl;
    }
    printf("%d\n",f[n]);
    return 0;
}
//code once,check twice

Compiler output:
a.cc: In function 'int askr(int, int, int, int, int)':
a.cc:53:38: error: too few arguments to function 'int askr(int, int, int, int, int)'
   53 |         if(l==r){return l;}int t=askr(mid+1,r,rs,val);
      |                                  ~~~~^~~~~~~~~~~~~~~~
a.cc:50:5: note: declared here
   50 | int askr(int l,int r,int x,int pos,int val)
      |     ^~~~
a.cc:55:25: error: too few arguments to function 'int askr(int, int, int, int, int)'
   55 |         else return askr(l,mid,ls,val);
      |                     ~~~~^~~~~~~~~~~~~~
a.cc:50:5: note: declared here
   50 | int askr(int l,int r,int x,int pos,int val)
      |     ^~~~
a.cc: In function 'int main()':
a.cc:62:9: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   62 |     FOR(i,1,n)p[i].sd=read(),p[i].fr=read();
      |         ^
a.cc:6:27: note: in definition of macro 'FOR'
    6 | #define FOR(i,a,b) for(re i=a;i<=b;i++)
      |                           ^
a.cc:64:9: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   64 |     FOR(i,1,n)g[i].sd=min(askl(1,n,1,p[i].sd),i),g[i].fr=max(askr(1,n,1,p[i].sd),i);
      |         ^
a.cc:6:27: note: in definition of macro 'FOR'
    6 | #define FOR(i,a,b) for(re i=a;i<=b;i++)
      |                           ^
a.cc:64:66: error: too few arguments to function 'int askr(int, int, int, int, int)'
   64 |     FOR(i,1,n)g[i].sd=min(askl(1,n,1,p[i].sd),i),g[i].fr=max(askr(1,n,1,p[i].sd),i);
      |                                                              ~~~~^~~~~~~~~~~~~~~
a.cc:50:5: note: declared here
   50 | int askr(int l,int r,int x,int pos,int val)
      |     ^~~~
a.cc:66:9: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   66 |     FOR(i,1,n)v[g[i].fr].pb(g[i].sd);
      |         ^
a.cc:6:27: note: in definition of macro 'FOR'
    6 | #define FOR(i,a,b) for(re i=a;i<=b;i++)
      |                           ^
a.cc:68:9: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   68 |     FOR(i,0,n)s[i]=1;
      |         ^
a.cc:6:27: note: in definition of macro 'FOR'
    6 | #define FOR(i,a,b) for(re i=a;i<=b;i++)
      |                           ^
a.cc:69:9: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   69 |     FOR(i,1,n)
      |         ^
a.cc:6:27: note: in definition of macro 'FOR'
    6 | #define FOR(i,a,b) for(re i=a;i<=b;i++)
      |                           ^