stablegradients/pie-gem5-pairs huggingface dataset:
// Slower C++ solution:
#include <iostream>

#include <cstdio>

#include <algorithm>

#include <string>

#include <cstring>

#include <cctype>

#include <cmath>

#include <stack>

#include <queue>

#include <vector>

#include <set>

#include <map>

#include <list>

#include <stdio.h>

#include <string.h>

#include <cstdlib>

#include <math.h>

#include <bitset>

#include <iterator>

#include <iomanip>

#include <sstream>

#define INF 2000000000

using namespace std;

int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};

#define sym cout<<"-----------"<<endl;

#define ll long long

#define P pair<int,int>

#define mk make_pair

#define en endl

#define RE return 0

#define int ll



vector<int> G[200005];



signed main(){

  int n,m,q;

  cin>>n>>m>>q;

  

  for(int i=0; i<m; i++){

    int l,r;

    cin>>l>>r;

    G[l].push_back(r);

  }

  for(int i=1; i<=n; i++) sort(G[i].begin(), G[i].end());

  for(int i=0; i<q; i++){

    int l,r;

    cin>>l>>r;

    int ans=0;

    for(int j=l; j<=r; j++){

      int n=upper_bound(G[j].begin(), G[j].end(), r)-G[j].begin();

      ans+=n;

    }

    cout<<ans<<en;

  }

}


// Faster C++ solution for the same problem (measured speedup: 6.449964582361175x):
#include <iostream>

#include <cstdio>

#include <algorithm>

#include <string>

#include <cstring>

#include <cctype>

#include <cmath>

#include <stack>

#include <queue>

#include <vector>

#include <set>

#include <map>

#include <list>

#include <stdio.h>

#include <string.h>

#include <cstdlib>

#include <math.h>

#include <bitset>

#include <iterator>

#include <iomanip>

#include <sstream>

#define INF 2000000000

using namespace std;

int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};

#define sym cout<<"-----------"<<endl;

#define ll long long

#define P pair<int,int>

#define mk make_pair

#define en endl

#define RE return 0

#define int ll



int sum[505][505];



signed main(){

  int n,m,q;

  cin>>n>>m>>q;

  for(int i=0; i<m; i++){

    int l,r;

    cin>>l>>r;

    sum[l][r]++;

  }

  

  for(int i=1; i<=n; i++){

    for(int j=1; j<=n; j++){

      sum[i][j+1]+=sum[i][j];

    }

  }

  

  for(int i=0; i<q; i++){

    int l,r;

    cin>>l>>r;

    int ret=0;

    for(int j=l; j<=r; j++) ret+=sum[j][r];

    cout<<ret<<en;

  }

}
// Slower C++ solution:
#include <iostream>

#include <cstdio>

#include <algorithm>

#include <string>

#include <cstring>

#include <cctype>

#include <cmath>

#include <stack>

#include <queue>

#include <vector>

#include <set>

#include <map>

#include <list>

#include <stdio.h>

#include <string.h>

#include <cstdlib>

#include <math.h>

#include <bitset>

#include <iterator>

#include <iomanip>

#include <sstream>

#define INF 2000000000

using namespace std;

int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};

#define sym cout<<"-----------"<<endl;

#define ll long long

#define P pair<int,int>

#define mk make_pair

#define en endl

#define RE return 0

#define int ll



vector<int> G[200005];



signed main(){

  int n,m,q;

  cin>>n>>m>>q;

  

  for(int i=0; i<m; i++){

    int l,r;

    cin>>l>>r;

    G[l].push_back(r);

  }

  for(int i=1; i<=n; i++) sort(G[i].begin(), G[i].end());

  for(int i=0; i<q; i++){

    int l,r;

    cin>>l>>r;

    int ans=0;

    for(int j=l; j<=r; j++){

      int n=upper_bound(G[j].begin(), G[j].end(), r)-G[j].begin();

      ans+=n;

    }

    cout<<ans<<en;

  }

}


// Faster C++ solution for the same problem (measured speedup: 6.45150241560038x):
#include <iostream>

#include <cstdio>

#include <algorithm>

#include <string>

#include <cstring>

#include <cctype>

#include <cmath>

#include <stack>

#include <queue>

#include <vector>

#include <set>

#include <map>

#include <list>

#include <stdio.h>

#include <string.h>

#include <cstdlib>

#include <math.h>

#include <bitset>

#include <iterator>

#include <iomanip>

#include <sstream>

#define INF 2000000000

using namespace std;

int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};

#define sym cout<<"-----------"<<endl;

#define ll long long

#define P pair<int,int>

#define mk make_pair

#define en endl

#define RE return 0

#define int ll



int sum[505][505];



signed main(){

  int n,m,q;

  cin>>n>>m>>q;

  for(int i=0; i<m; i++){

    int l,r;

    cin>>l>>r;

    sum[l][r]++;

  }

  

  for(int i=1; i<=n; i++){

    for(int j=1; j<=n; j++){

      sum[i][j]+=sum[i][j-1];

    }

  }

  

  for(int i=0; i<q; i++){

    int l,r;

    cin>>l>>r;

    int ret=0;

    for(int j=l; j<=r; j++) ret+=sum[j][r]-sum[j][j-1];

    cout<<ret<<en;

  }

}
// Slower C++ solution:
#include <iostream>

#include <cstdio>

#include <algorithm>

#include <string>

#include <cstring>

#include <cctype>

#include <cmath>

#include <stack>

#include <queue>

#include <vector>

#include <set>

#include <map>

#include <list>

#include <stdio.h>

#include <string.h>

#include <cstdlib>

#include <math.h>

#include <bitset>

#include <iterator>

#include <iomanip>

#include <sstream>

#define INF 2000000000

using namespace std;

int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};

#define sym cout<<"-----------"<<endl;

#define ll long long

#define P pair<int,int>

#define mk make_pair

#define en endl

#define RE return 0

#define int ll



vector<int> G[200005];



signed main(){

  int n,m,q;

  cin>>n>>m>>q;

  

  for(int i=0; i<m; i++){

    int l,r;

    cin>>l>>r;

    G[l].push_back(r);

  }

  for(int i=1; i<=n; i++) sort(G[i].begin(), G[i].end());

  for(int i=0; i<q; i++){

    int l,r;

    cin>>l>>r;

    int ans=0;

    for(int j=l; j<=r; j++){

      int n=upper_bound(G[j].begin(), G[j].end(), r)-G[j].begin();

      ans+=n;

    }

    cout<<ans<<en;

  }

}


// Faster C++ solution for the same problem (measured speedup: 6.450716482501929x):
#include <iostream>

#include <cstdio>

#include <algorithm>

#include <string>

#include <cstring>

#include <cctype>

#include <cmath>

#include <stack>

#include <queue>

#include <vector>

#include <set>

#include <map>

#include <list>

#include <stdio.h>

#include <string.h>

#include <cstdlib>

#include <math.h>

#include <bitset>

#include <iterator>

#include <iomanip>

#include <sstream>

#define INF 2000000000

using namespace std;

int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};

#define sym cout<<"-----------"<<endl;

#define ll long long

#define P pair<int,int>

#define mk make_pair

#define en endl

#define RE return 0

#define int ll



int sum[505][505];



signed main(){

  int n,m,q;

  cin>>n>>m>>q;

  for(int i=0; i<m; i++){

    int l,r;

    cin>>l>>r;

    sum[l][r]++;

  }

  

  for(int i=1; i<=n; i++){

    for(int j=1; j<=n; j++){

      sum[i][j]+=sum[i][j-1];

    }

  }

  

  for(int i=0; i<q; i++){

    int l,r;

    cin>>l>>r;

    int ret=0;

    for(int j=l; j<=r; j++) ret+=sum[j][r]-sum[j][j-1];

    cout<<ret<<en;

  }

}
// Slower C++ solution:
#include <iostream>

#include <cstdio>

#include <algorithm>

#include <string>

#include <cstring>

#include <cctype>

#include <cmath>

#include <stack>

#include <queue>

#include <vector>

#include <set>

#include <map>

#include <list>

#include <stdio.h>

#include <string.h>

#include <cstdlib>

#include <math.h>

#include <bitset>

#include <iterator>

#include <iomanip>

#include <sstream>

#define INF 2000000000

using namespace std;

int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};

#define sym cout<<"-----------"<<endl;

#define ll long long

#define P pair<int,int>

#define mk make_pair

#define en endl

#define RE return 0

#define int ll



vector<int> G[200005];



signed main(){

  int n,m,q;

  cin>>n>>m>>q;

  

  for(int i=0; i<m; i++){

    int l,r;

    cin>>l>>r;

    G[l].push_back(r);

  }

  for(int i=1; i<=n; i++) sort(G[i].begin(), G[i].end());

  for(int i=0; i<q; i++){

    int l,r;

    cin>>l>>r;

    int ans=0;

    for(int j=l; j<=r; j++){

      int n=upper_bound(G[j].begin(), G[j].end(), r)-G[j].begin();

      ans+=n;

    }

    cout<<ans<<en;

  }

}


// Faster C++ solution for the same problem (measured speedup: 6.450507407175008x):
#include <iostream>

#include <cstdio>

#include <algorithm>

#include <string>

#include <cstring>

#include <cctype>

#include <cmath>

#include <stack>

#include <queue>

#include <vector>

#include <set>

#include <map>

#include <list>

#include <stdio.h>

#include <string.h>

#include <cstdlib>

#include <math.h>

#include <bitset>

#include <iterator>

#include <iomanip>

#include <sstream>

#define INF 2000000000

using namespace std;

int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};

#define sym cout<<"-----------"<<endl;

#define ll long long

#define P pair<int,int>

#define mk make_pair

#define en endl

#define RE return 0

#define int ll



int sum[505][505];



signed main(){

  int n,m,q;

  cin>>n>>m>>q;

  for(int i=0; i<m; i++){

    int l,r;

    cin>>l>>r;

    sum[l][r]++;

  }

  

  for(int i=1; i<=n; i++){

    for(int j=1; j<=n; j++){

      sum[i][j]+=sum[i][j-1];

    }

  }

  

  for(int i=0; i<q; i++){

    int l,r;

    cin>>l>>r;

    int ret=0;

    for(int j=l; j<=r; j++) ret+=sum[j][r];

    cout<<ret<<en;

  }

}
// Slower C++ solution:
#include <iostream>

#include <cstdio>

#include <algorithm>

#include <string>

#include <cstring>

#include <cctype>

#include <cmath>

#include <stack>

#include <queue>

#include <vector>

#include <set>

#include <map>

#include <list>

#include <stdio.h>

#include <string.h>

#include <cstdlib>

#include <math.h>

#include <bitset>

#include <iterator>

#include <iomanip>

#include <sstream>

#define INF 2000000000

using namespace std;

int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};

#define sym cout<<"-----------"<<endl;

#define ll long long

#define P pair<int,int>

#define mk make_pair

#define en endl

#define RE return 0

#define int ll



vector<int> G[200005];



signed main(){

  int n,m,q;

  cin>>n>>m>>q;

  

  for(int i=0; i<m; i++){

    int l,r;

    cin>>l>>r;

    G[l].push_back(r);

  }

  for(int i=1; i<=n; i++) sort(G[i].begin(), G[i].end());

  for(int i=0; i<q; i++){

    int l,r;

    cin>>l>>r;

    int ans=0;

    for(int j=l; j<=r; j++){

      int n=upper_bound(G[j].begin(), G[j].end(), r)-G[j].begin();

      ans+=n;

    }

    cout<<ans<<en;

  }

}


// Faster C++ solution for the same problem (measured speedup: 6.449721595290192x):
#include <iostream>

#include <cstdio>

#include <algorithm>

#include <string>

#include <cstring>

#include <cctype>

#include <cmath>

#include <stack>

#include <queue>

#include <vector>

#include <set>

#include <map>

#include <list>

#include <stdio.h>

#include <string.h>

#include <cstdlib>

#include <math.h>

#include <bitset>

#include <iterator>

#include <iomanip>

#include <sstream>

#define INF 2000000000

using namespace std;

int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};

#define sym cout<<"-----------"<<endl;

#define ll long long

#define P pair<int,int>

#define mk make_pair

#define en endl

#define RE return 0

#define int ll



int sum[505][505];



signed main(){

  int n,m,q;

  cin>>n>>m>>q;

  for(int i=0; i<m; i++){

    int l,r;

    cin>>l>>r;

    sum[l][r]++;

  }

  

  for(int i=1; i<=n; i++){

    for(int j=1; j<=n; j++){

      sum[i][j]+=sum[i][j-1];

    }

  }

  

  for(int i=0; i<q; i++){

    int l,r;

    cin>>l>>r;

    int ret=0;

    for(int j=l; j<=r; j++) ret+=sum[j][r];

    cout<<ret<<en;

  }

}
// Slower C++ solution:
#pragma GCC optimize(2)

#include<bits/stdc++.h>

#define LL long long

#define int LL

const LL inf=0x3f3f3f3f;

using namespace std;

template<typename tp> inline void read(tp &x)

{

	x=0; char c=getchar(); bool f=0;

	for(;c<'0'||c>'9';f|=(c=='-'),c = getchar());

	for(;c>='0'&&c<='9';x=(x<<3)+(x<<1)+c-'0',c = getchar());

	if(f) x=-x;

}

int n,m,q;

vector<int> x[510];

signed main()

{

	read(n),read(m),read(q);

	for(int i=1,l,r;i<=m;i++)

	{

		read(l),read(r);

		x[l].push_back(r);

	}

	for(int i=1;i<=n;i++)

		sort(x[i].begin(),x[i].end());

	for(int i=1,l,r;i<=q;i++)

	{

		read(l),read(r);

		int ret=0;

		for(int j=l;j<=r;j++)

			ret+=upper_bound(x[j].begin(),x[j].end(),r)-x[j].begin();

		printf("%lld\n",ret);

	}

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.28188657568913x):
/*

  Code By RyeCatcher

*/

#include <cstdio>

#include <cstdlib>

#include <cstring>

#include <algorithm>

#include <cctype>

#include <vector>

#include <queue>

#include <utility>

#define ri register int

#define ll long long

#define ull unsigned long long

#define pb push_back

#define DEBUG freopen("dat.in","r",stdin);freopen("wa.out","w".stdout);

#define FO(x) {freopen(#x".in","r",stdin);freopen(#x".out","w",stdout);}

#define SIZE 23333

using std::min;

using std::max;

using std::pair;

using std::queue;

using std::priority_queue;

using std::vector;

inline char gc(){

    static char buf[SIZE],*p1=buf,*p2=buf;

    return p1==p2&&(p2=(p1=buf)+fread(buf,1,SIZE,stdin),p1==p2)?EOF:*p1++;

}

#define gc getchar

template <class T>inline void read(T &x){

	x=0;int ne=0;char c;

    while((c=gc())>'9'||c<'0')ne=c=='-';x=c-48;

    while((c=gc())>='0'&&c<='9')x=(x<<3)+(x<<1)+c-48;x=ne?-x:x;return ;

}

const int maxn=200005;

const int inf=0x7ffffff;

int sum[maxn<<3];

int n,m,q;

inline void add(int x,int d){for(;x<=n;x+=x&(-x))sum[x]+=d;return ;}

inline int query(int x){int ans=0;for(;x;x-=x&(-x))ans+=sum[x];return ans;}

struct Pt{

	int x,y,id;

	bool operator <(const Pt &rhs)const{

		return (x==rhs.x)?(y==rhs.y?id<rhs.id:y<rhs.y):x>rhs.x;

	}

}pt[maxn<<2];

int tot=0,qry[maxn];

int main(){

	int x,y;

	read(n),read(m),read(q);

	for(ri i=1;i<=m;i++){

		read(x),read(y);

		pt[++tot]=(Pt){x,y,0};

	}

	for(ri i=1;i<=q;i++){

		read(x),read(y);

		pt[++tot]=(Pt){x,y,i};

	}

	std::sort(pt+1,pt+1+tot);

	for(ri i=1;i<=tot;i++){

		//printf("%d %d %d %d\n",i,pt[i].id,pt[i].x,pt[i].y);

		if(!pt[i].id)add(pt[i].y,1);

		else qry[pt[i].id]=query(pt[i].y);

	}

	for(ri i=1;i<=q;i++)printf("%d\n",qry[i]);

	return 0;

}
// Slower C++ solution:
#include<bits/stdc++.h>

using namespace std;

int mp[505][505],dp[505][505];

int main()

{

	int n,m,q,l,r;

	scanf("%d%d%d",&n,&m,&q);

	for(int i=1;i<=m;i++)

	{

		scanf("%d%d",&l,&r);

		mp[l][r]++;

	}

	for(int i=1;i<=n;i++)

	{

		for(int j=1;j<=n;j++)

		{

			dp[i][j]=dp[i][j-1]+mp[i][j];

		}

	}

	for(int i=1;i<=q;i++)

	{

		int ans=0;

		scanf("%d%d",&l,&r);

		for(int i=l;i<=r;i++)

		{

			ans+=dp[i][r]-dp[i][l-1];

		}

		printf("%d\n",ans);

	}

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.214111731023429x):
/*

  Code By RyeCatcher

*/

#include <cstdio>

#include <cstdlib>

#include <cstring>

#include <algorithm>

#include <cctype>

#include <vector>

#include <queue>

#include <utility>

#define ri register int

#define ll long long

#define ull unsigned long long

#define pb push_back

#define DEBUG freopen("dat.in","r",stdin);freopen("wa.out","w".stdout);

#define FO(x) {freopen(#x".in","r",stdin);freopen(#x".out","w",stdout);}

#define SIZE 23333

using std::min;

using std::max;

using std::pair;

using std::queue;

using std::priority_queue;

using std::vector;

inline char gc(){

    static char buf[SIZE],*p1=buf,*p2=buf;

    return p1==p2&&(p2=(p1=buf)+fread(buf,1,SIZE,stdin),p1==p2)?EOF:*p1++;

}

#define gc getchar

template <class T>inline void read(T &x){

	x=0;int ne=0;char c;

    while((c=gc())>'9'||c<'0')ne=c=='-';x=c-48;

    while((c=gc())>='0'&&c<='9')x=(x<<3)+(x<<1)+c-48;x=ne?-x:x;return ;

}

const int maxn=200005;

const int inf=0x7ffffff;

int sum[maxn<<3];

int n,m,q;

inline void add(int x,int d){for(;x<=n;x+=x&(-x))sum[x]+=d;return ;}

inline int query(int x){int ans=0;for(;x;x-=x&(-x))ans+=sum[x];return ans;}

struct Pt{

	int x,y,id;

	bool operator <(const Pt &rhs)const{

		return (x==rhs.x)?(y==rhs.y?id<rhs.id:y<rhs.y):x>rhs.x;

	}

}pt[maxn<<2];

int tot=0,qry[maxn];

int main(){

	int x,y;

	read(n),read(m),read(q);

	for(ri i=1;i<=m;i++){

		read(x),read(y);

		pt[++tot]=(Pt){x,y,0};

	}

	for(ri i=1;i<=q;i++){

		read(x),read(y);

		pt[++tot]=(Pt){x,y,i};

	}

	std::sort(pt+1,pt+1+tot);

	for(ri i=1;i<=tot;i++){

		//printf("%d %d %d %d\n",i,pt[i].id,pt[i].x,pt[i].y);

		if(!pt[i].id)add(pt[i].y,1);

		else qry[pt[i].id]=query(pt[i].y);

	}

	for(ri i=1;i<=q;i++)printf("%d\n",qry[i]);

	return 0;

}
// Slower C++ solution:
#include <cstdio>

#include <cstring>

#include <iostream>

#include <algorithm>

#define LL long long



using namespace std;



const int MAXN=502,MAXM=2000011;

int n,m,q;

int sum[MAXN][MAXN];

int Query(int l,int r)

{

	return sum[r][r]-sum[r][l-1]-sum[l-1][r]+sum[l-1][l-1];

}

int main()

{

	scanf("%d%d%d",&n,&m,&q);

	

	for(int i=1;i<=m;i++)

	{

		int tx,ty;

		scanf("%d%d",&tx,&ty);

		sum[tx][ty]++;

		sum[ty][tx]++;

	}

	

	for(int i=1;i<=n;i++)

	{

		for(int j=1;j<=n;j++)

		{

			sum[i][j]+=sum[i-1][j]+sum[i][j-1]-sum[i-1][j-1];

		}

	}

	

	for(int i=1;i<=q;i++)

	{

		int tx,ty;

		scanf("%d%d",&tx,&ty);

		printf("%d\n",Query(tx,ty)/2);

	}

	

	

	return 0;

}




// Faster C++ solution for the same problem (measured speedup: 5.213881373353793x):
/*

  Code By RyeCatcher

*/

#include <cstdio>

#include <cstdlib>

#include <cstring>

#include <algorithm>

#include <cctype>

#include <vector>

#include <queue>

#include <utility>

#define ri register int

#define ll long long

#define ull unsigned long long

#define pb push_back

#define DEBUG freopen("dat.in","r",stdin);freopen("wa.out","w".stdout);

#define FO(x) {freopen(#x".in","r",stdin);freopen(#x".out","w",stdout);}

#define SIZE 23333

using std::min;

using std::max;

using std::pair;

using std::queue;

using std::priority_queue;

using std::vector;

inline char gc(){

    static char buf[SIZE],*p1=buf,*p2=buf;

    return p1==p2&&(p2=(p1=buf)+fread(buf,1,SIZE,stdin),p1==p2)?EOF:*p1++;

}

#define gc getchar

template <class T>inline void read(T &x){

	x=0;int ne=0;char c;

    while((c=gc())>'9'||c<'0')ne=c=='-';x=c-48;

    while((c=gc())>='0'&&c<='9')x=(x<<3)+(x<<1)+c-48;x=ne?-x:x;return ;

}

const int maxn=200005;

const int inf=0x7ffffff;

int sum[maxn<<3];

int n,m,q;

inline void add(int x,int d){for(;x<=n;x+=x&(-x))sum[x]+=d;return ;}

inline int query(int x){int ans=0;for(;x;x-=x&(-x))ans+=sum[x];return ans;}

struct Pt{

	int x,y,id;

	bool operator <(const Pt &rhs)const{

		return (x==rhs.x)?(y==rhs.y?id<rhs.id:y<rhs.y):x>rhs.x;

	}

}pt[maxn<<2];

int tot=0,qry[maxn];

int main(){

	int x,y;

	read(n),read(m),read(q);

	for(ri i=1;i<=m;i++){

		read(x),read(y);

		pt[++tot]=(Pt){x,y,0};

	}

	for(ri i=1;i<=q;i++){

		read(x),read(y);

		pt[++tot]=(Pt){x,y,i};

	}

	std::sort(pt+1,pt+1+tot);

	for(ri i=1;i<=tot;i++){

		//printf("%d %d %d %d\n",i,pt[i].id,pt[i].x,pt[i].y);

		if(!pt[i].id)add(pt[i].y,1);

		else qry[pt[i].id]=query(pt[i].y);

	}

	for(ri i=1;i<=q;i++)printf("%d\n",qry[i]);

	return 0;

}
// Slower C++ solution:
#include<algorithm>

#include<cstdio>

#include<iostream>

#include<cstdlib>

#define lowbit(x) ((x)&(-(x)))

#define MAXN 1010

using namespace std;

int c[MAXN][MAXN];

int query(int x,int y)

{

	int f=0;

	while(x>0)

	{

		int tmp=y;

		while(tmp>0)

		{

			f+=c[x][tmp];

			tmp-=lowbit(tmp);

		}

		x-=lowbit(x);

	}

	return f;

}

void modify(int x,int y,int v)

{

	while(x<MAXN-10)

	{

		int tmp=y;

		while(tmp<MAXN-10)

		{

			c[x][tmp]+=v;

			tmp+=lowbit(tmp);

		}

		x+=lowbit(x);

	}

}

inline void change(int x,int y,int x1,int y1,int v)

{

	modify(x,y,v);

	modify(x1+1,y,-v);

	modify(x,y1+1,-v);

	modify(x1+1,y1+1,v);

}

int main()

{

	int n,m,Q,l,r;

	scanf("%d%d%d",&n,&m,&Q);

	for(int i=1;i<=m;i++)

	{

		scanf("%d%d",&l,&r);

		change(1,r,l,n,1);

	}

	while(Q--)

	{

		int q1,q2;

		scanf("%d%d",&q1,&q2);

		printf("%d\n",query(q1,q2));

	}

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.22638663784822x):
/*

  Code By RyeCatcher

*/

#include <cstdio>

#include <cstdlib>

#include <cstring>

#include <algorithm>

#include <cctype>

#include <vector>

#include <queue>

#include <utility>

#define ri register int

#define ll long long

#define ull unsigned long long

#define pb push_back

#define DEBUG freopen("dat.in","r",stdin);freopen("wa.out","w".stdout);

#define FO(x) {freopen(#x".in","r",stdin);freopen(#x".out","w",stdout);}

#define SIZE 23333

using std::min;

using std::max;

using std::pair;

using std::queue;

using std::priority_queue;

using std::vector;

inline char gc(){

    static char buf[SIZE],*p1=buf,*p2=buf;

    return p1==p2&&(p2=(p1=buf)+fread(buf,1,SIZE,stdin),p1==p2)?EOF:*p1++;

}

#define gc getchar

template <class T>inline void read(T &x){

	x=0;int ne=0;char c;

    while((c=gc())>'9'||c<'0')ne=c=='-';x=c-48;

    while((c=gc())>='0'&&c<='9')x=(x<<3)+(x<<1)+c-48;x=ne?-x:x;return ;

}

const int maxn=200005;

const int inf=0x7ffffff;

int sum[maxn<<3];

int n,m,q;

inline void add(int x,int d){for(;x<=n;x+=x&(-x))sum[x]+=d;return ;}

inline int query(int x){int ans=0;for(;x;x-=x&(-x))ans+=sum[x];return ans;}

struct Pt{

	int x,y,id;

	bool operator <(const Pt &rhs)const{

		return (x==rhs.x)?(y==rhs.y?id<rhs.id:y<rhs.y):x>rhs.x;

	}

}pt[maxn<<2];

int tot=0,qry[maxn];

int main(){

	int x,y;

	read(n),read(m),read(q);

	for(ri i=1;i<=m;i++){

		read(x),read(y);

		pt[++tot]=(Pt){x,y,0};

	}

	for(ri i=1;i<=q;i++){

		read(x),read(y);

		pt[++tot]=(Pt){x,y,i};

	}

	std::sort(pt+1,pt+1+tot);

	for(ri i=1;i<=tot;i++){

		//printf("%d %d %d %d\n",i,pt[i].id,pt[i].x,pt[i].y);

		if(!pt[i].id)add(pt[i].y,1);

		else qry[pt[i].id]=query(pt[i].y);

	}

	for(ri i=1;i<=q;i++)printf("%d\n",qry[i]);

	return 0;

}
// Slower C++ solution:
#include <bits/stdc++.h>

#define LL long long

#define db double

using namespace std;



template <typename T> inline void read(T &x) {

    int c = getchar();

    bool fg = false;

    for (x = 0; !isdigit(c); c = getchar()) {

        if (c == '-') {

            fg = true;

        }

    }

    for (; isdigit(c); c = getchar()) {

        x = x * 10 + c - '0';

    }

    if (fg) {

        x = -x;

    }

}

const int MAXN = 550;

const int INF = 0x3f3f3f3f;



int f[MAXN][MAXN], n, m, q;



signed main() {

	read(n), read(m), read(q);

	for(int i = 1; i <= m; i++) {

		int l, r;

		read(l), read(r);

		f[l][r]++;

		f[r][l]++;

	}

	for(int i = 1; i <= n; i++) {

		for(int j = 1; j <= n; j++) {

			f[i][j] = f[i - 1][j] + f[i][j - 1] - f[i - 1][j - 1] + f[i][j];

		}

	}

	while(q--) {

		int l, r;

		read(l), read(r);

		int ans = f[r][r] - f[r][l - 1] - f[l - 1][r] + f[l - 1][l - 1];

		printf("%d\n", ans >> 1);

	}

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.191656528814948x):
/*

  Code By RyeCatcher

*/

#include <cstdio>

#include <cstdlib>

#include <cstring>

#include <algorithm>

#include <cctype>

#include <vector>

#include <queue>

#include <utility>

#define ri register int

#define ll long long

#define ull unsigned long long

#define pb push_back

#define DEBUG freopen("dat.in","r",stdin);freopen("wa.out","w".stdout);

#define FO(x) {freopen(#x".in","r",stdin);freopen(#x".out","w",stdout);}

#define SIZE 23333

using std::min;

using std::max;

using std::pair;

using std::queue;

using std::priority_queue;

using std::vector;

inline char gc(){

    static char buf[SIZE],*p1=buf,*p2=buf;

    return p1==p2&&(p2=(p1=buf)+fread(buf,1,SIZE,stdin),p1==p2)?EOF:*p1++;

}

#define gc getchar

template <class T>inline void read(T &x){

	x=0;int ne=0;char c;

    while((c=gc())>'9'||c<'0')ne=c=='-';x=c-48;

    while((c=gc())>='0'&&c<='9')x=(x<<3)+(x<<1)+c-48;x=ne?-x:x;return ;

}

const int maxn=200005;

const int inf=0x7ffffff;

int sum[maxn<<3];

int n,m,q;

inline void add(int x,int d){for(;x<=n;x+=x&(-x))sum[x]+=d;return ;}

inline int query(int x){int ans=0;for(;x;x-=x&(-x))ans+=sum[x];return ans;}

struct Pt{

	int x,y,id;

	bool operator <(const Pt &rhs)const{

		return (x==rhs.x)?(y==rhs.y?id<rhs.id:y<rhs.y):x>rhs.x;

	}

}pt[maxn<<2];

int tot=0,qry[maxn];

int main(){

	int x,y;

	read(n),read(m),read(q);

	for(ri i=1;i<=m;i++){

		read(x),read(y);

		pt[++tot]=(Pt){x,y,0};

	}

	for(ri i=1;i<=q;i++){

		read(x),read(y);

		pt[++tot]=(Pt){x,y,i};

	}

	std::sort(pt+1,pt+1+tot);

	for(ri i=1;i<=tot;i++){

		//printf("%d %d %d %d\n",i,pt[i].id,pt[i].x,pt[i].y);

		if(!pt[i].id)add(pt[i].y,1);

		else qry[pt[i].id]=query(pt[i].y);

	}

	for(ri i=1;i<=q;i++)printf("%d\n",qry[i]);

	return 0;

}