stablegradients/pie-gem5-bysrc huggingface dataset:
// Original C++ solution (slower):
#include <iostream>

#include <vector>

#include <algorithm>

#include <string>

#include <cmath>

using namespace std;



#define loop(i,N) for(ll (i)=0; (i)<(N);++(i))

#define OMAZINAI cin.tie(0); ios::sync_with_stdio(false);

#define INF (1LL<<61)

typedef long long int ll;

int a, b, c, d;

ll sum[600][600], d_sum[600][600], d_sum2[600][600];



int main() {

	OMAZINAI;

	ll N, M, Q;

	cin >> N >> M >> Q;

	/*auto show = [N](ll s[600][600]) {

		cout << "------" << endl;

		loop(i, N+1) {

			loop(n, N+1)

				cout << s[i][n] << ", ";

			cout << endl;

		}

		cout << "------" << endl;

	};*/

	loop(i, M) {

		cin >> a >> b;

		++d_sum[a][b];

	}

	//show(d_sum);

	loop(i, N+1) {

		ll tmp = 0;

		loop(n, N+1) {

			tmp += d_sum[i][n];

			d_sum2[i][n] = tmp;

		}

	}

	//show(d_sum2);

	loop(n, N+1) {

		ll tmp = 0;

		loop(i, N+1) {

			tmp += d_sum2[i][n];

			sum[i][n] = tmp;

		}

	}

	//show(sum);

	while (Q--) {

		cin >> a >> b;

		cout << sum[b][b] - sum[b][a - 1] - sum[a - 1][b] + sum[a - 1][a - 1] << endl;

	}



	return 0;

}

// Optimized solution to the same problem (faster):
#include <cstdio>

#include <vector>

#include <algorithm>

#include <string>

 

#define loop(i,N) for(ll (i)=0; (i)<(N);++(i))

#define INF (1LL<<61)

typedef long long int ll;

ll a, b, c, d;

ll sum[600][600], d_sum[600][600], d_sum2[600][600];

 

int main() {

	ll N, M, Q;

	scanf("%lld%lld%lld", &N, &M, &Q);

	loop(i, M) {

		scanf("%lld%lld", &a, &b);

		++d_sum[a][b];

	}

	loop(i, N+1) {

		ll tmp = 0;

		loop(n, N+1) {

			tmp += d_sum[i][n];

			d_sum2[i][n] = tmp;

		}

	}

	loop(n, N+1) {

		ll tmp = 0;

		loop(i, N+1) {

			tmp += d_sum2[i][n];

			sum[i][n] = tmp;

		}

	}

	while (Q--) {

		scanf("%lld%lld", &a, &b);

		printf("%lld\n", sum[b][b] - sum[b][a - 1] - sum[a - 1][b] + sum[a - 1][a - 1]);

	}

 

	return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <iostream>

#include <cmath>

#include <string>

#include <algorithm>

#include <set>

#include <vector>

#include <map>

#include <list>

#include <stack>

#include <cstdio>

#include <cstring>

#include <cstdlib>

#include <queue>

#define REP(i, n) for(i=0; i<n; i++)

#define REPR(i, n) for(i=n; i>=0; i--)

#define FOR(i, m, n) for(i=m; i<n; i++)

#define max(a, b) ((a)>(b) ? (a):(b))

#define min(a, b) ((a)<(b) ? (a):(b))

#define INF 1000000000

#define MOD 1000000007LL

#define MAX 100005

#define NIL -1

#define WHITE 0

#define GRAY 1

#define BLACK 2

using namespace std;

typedef long long ll;

typedef pair<ll, ll> P;

typedef pair<double, double> doup;





int main(void) {

    ll N, M, Q;

    cin >> N >> M >> Q;

    ll i, j;

    ll L, R;

    ll G[501][501]={0};

    ll S[501][501]={0};

    ll p, q;

    for(i=0; i<M; i++) {

        cin >> L >> R;

        L--; R--;

        G[L][R]++;

    }

    S[0][0]=G[0][0];

    for(i=1; i<N; i++) {

        S[i][0]=S[i-1][0]+G[i][0];

    }

    for(i=1; i<N; i++) {

        S[0][i]=S[0][i-1]+G[0][i];

    }

    for(i=1; i<N; i++) {

        for(j=1; j<N; j++) {

            S[i][j]=S[i-1][j]+S[i][j-1]-S[i-1][j-1]+G[i][j];

        }

    }

    

    for(i=0; i<Q; i++) {

        cin >> p >> q;

        p--; q--;

        cout << S[q][q]-S[p-1][q]-S[q][p-1]+S[p-1][p-1] << endl;

    }

    

}


// Optimized solution to the same problem (faster):
#include <iostream>

#include <cmath>

#include <string>

#include <algorithm>

#include <set>

#include <vector>

#include <map>

#include <list>

#include <stack>

#include <cstdio>

#include <cstring>

#include <cstdlib>

#include <queue>

#define REP(i, n) for(i=0; i<n; i++)

#define REPR(i, n) for(i=n; i>=0; i--)

#define FOR(i, m, n) for(i=m; i<n; i++)

#define max(a, b) ((a)>(b) ? (a):(b))

#define min(a, b) ((a)<(b) ? (a):(b))

#define INF 1000000000

#define MOD 1000000007LL

#define MAX 100005

#define NIL -1

#define WHITE 0

#define GRAY 1

#define BLACK 2

using namespace std;

typedef long long ll;

typedef pair<ll, ll> P;

typedef pair<double, double> doup;





int main(void) {

    ll N, M, Q;

    cin >> N >> M >> Q;

    ll i, j;

    ll L, R;

    ll G[501][501]={0};

    ll S[501][501];

    ll p, q;

    for(i=0; i<M; i++) {

        cin >> L >> R;

        L--; R--;

        G[L][R]++;

    }

    S[0][0]=G[0][0];

    for(i=1; i<N; i++) {

        S[i][0]=S[i-1][0]+G[i][0];

    }

    for(i=1; i<N; i++) {

        S[0][i]=S[0][i-1]+G[0][i];

    }

    for(i=1; i<N; i++) {

        for(j=1; j<N; j++) {

            S[i][j]=S[i-1][j]+S[i][j-1]-S[i-1][j-1]+G[i][j];

        }

    }

    

    for(i=0; i<Q; i++) {

        cin >> p >> q;

        p--; q--;

        cout << S[q][q]-S[p-1][q]-S[q][p-1]+S[p-1][p-1] << endl;

    }

    

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#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;

  }

}


// Optimized solution to the same problem (faster):
#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;

  }

}






// Fastest known solution for this problem:
// Original C++ solution (slower):
#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;

}

// Optimized solution to the same problem (faster):
/*

  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;

} 

// Fastest known solution for this problem:
// Original C++ solution (slower):
#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;

}

// Optimized solution to the same problem (faster):
/*

  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;

} 

// Fastest known solution for this problem:
// Original C++ solution (slower):
#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;

}




// Optimized solution to the same problem (faster):
/*

  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;

} 

// Fastest known solution for this problem:
// Original C++ solution (slower):
#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;

}

// Optimized solution to the same problem (faster):
/*

  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;

} 

// Fastest known solution for this problem:
// Original C++ solution (slower):
#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;

}

// Optimized solution to the same problem (faster):
/*

  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;

} 

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<map>

#include<set>

#include<stack>

#include<cmath>

#include<queue>

#include<cstdio>

#include<string>

#include<vector>

#include<cstring>

#include<iostream>

#include<algorithm>

#define inf 0x3f3f3f3f

using namespace std;



int a[505][505], f[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);

		a[l][r]++;

	}

	for (int i = 1; i <= n; ++i) f[i][i] = a[i][i];

	for (int i = 1; i <= n - 1; ++i) f[i][i + 1] = a[i][i + 1] + f[i + 1][i + 1] + f[i][i];

	for (int k = 2; k <= n - 1; ++k)

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

			f[i][i + k] = a[i][i + k] + f[i][i + k - 1] + f[i + 1][i + k] - f[i + 1][i + k - 1];

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

	{

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

		printf("%d\n", f[l][r]);

	}

	return 0;

}

// Optimized solution to the same problem (faster):
#include <cstdio>

#include <cstring>

#include <algorithm>

void Unused(...) {}

#ifndef DEBUG

  #define echo(...) Unused(__VA_ARGS__)

#else

  #define echo(...) fprintf(stderr, __VA_ARGS__)

#endif



const int MaxN = 500 + 7;

const int MaxM = int(3e5) + 7;



struct Inv

{

    int l, r;

    int idx;

    friend bool operator<(const Inv &a, const Inv &b)

    {

        return a.l == b.l ? a.idx < b.idx : a.l > b.l;

    }

};

Inv rd[MaxM];



int n, m, q;

int ans[MaxM];



int vol[MaxN];

int lowbit(int x) { return x & (-x); }



int query(int v)

{

    int res = 0;

    for (; v > 0; v -= lowbit(v))

        res += vol[v];

    return res;

}

void update(int v)

{

    for (; v < MaxN; v += lowbit(v))

        ++vol[v];

}



int main()

{

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

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

        scanf("%d %d", &rd[i].l, &rd[i].r);

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

    {

        scanf("%d %d", &rd[i + m].l, &rd[i + m].r);

        rd[i + m].idx = i;

    }

    std::sort(rd + 1, rd + m + q + 1);



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

    {

        // query

        if (rd[i].idx > 0)

            ans[rd[i].idx] = query(rd[i].r);

        else

            update(rd[i].r);

    }

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

        printf("%d\n", ans[i]);



    return 0;

}




// Fastest known solution for this problem: