stablegradients/pie-gem5-pairs huggingface dataset:
// Slower C++ solution:
#include<bits/stdc++.h>

using namespace std;

int dp[1010][1010];

int main()

{

	int n,m,q,x,y,k;

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

	memset(dp,0,sizeof(dp));

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

	{

		scanf("%d%d",&x,&y);

		dp[x][y]++;

	}

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

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

		{

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

			if(j>1)dp[i][i+j]-=dp[i+1][i+j-1];

		}

	while(q--)

	{

		scanf("%d%d",&x,&y);

		printf("%d\n",dp[x][y]);

	}

	return 0;

}

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

#include<cstring>

#include<iostream>

#include<algorithm>

#include<vector>

using namespace std;

const int N=1005;

int n,m,q,x,y;

vector<int> e[N];

int main() {

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

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

        scanf("%d%d",&x,&y);

        e[x].push_back(y);

    }

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

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

    }

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

        scanf("%d%d",&x,&y);

        int now=0;

        for (int j=x;j<=y;j++) {

            now+=upper_bound(e[j].begin(),e[j].end(),y)-e[j].begin();

        }

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

    }

    return 0;

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

namespace chtholly{

typedef long long ll;

#define re0 register int

#define rel register ll

#define rec register char

#define gc getchar

#define pc putchar

#define p32 pc(' ')

#define pl puts("")

/*By Citrus*/

inline int read(){

  int x=0,f=1;char c=gc();

  for (;!isdigit(c);c=gc()) f^=c=='-';

  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');

  return f?x:-x;

  }

template <typename mitsuha>

inline bool read(mitsuha &x){

  x=0;int f=1;char c=gc();

  for (;!isdigit(c)&&~c;c=gc()) f^=c=='-';

  if (!~c) return 0;

  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');

  return x=f?x:-x,1;

  }

template <typename mitsuha>

inline int write(mitsuha x){

  if (!x) return 0&pc(48);

  if (x<0) pc('-'),x=-x;

  int bit[20],i,p=0;

  for (;x;x/=10) bit[++p]=x%10;

  for (i=p;i;--i) pc(bit[i]+48);

  return 0;

  }

inline char fuhao(){

  char c=gc();

  for (;isspace(c);c=gc());

  return c;

  }

}using namespace chtholly;

using namespace std;

const int yuzu=1e5;

//struct node{

//int l,r,id;

//void rd(int i){l=read(),r=read(),id=i;}

//bool operator <(const node &b) const{

//  return l<b.l;

//  }

//}e[yuzu|10],p[yuzu|10];



vector<int> lj[yuzu|10];



int main(){

int i,j,n,m,q;

cin>>n>>m>>q;

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

  int l=read(),r=read();

  lj[l].push_back(r);

  }

for (i=1;i<=500;++i) sort(lj[i].begin(),lj[i].end());

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

  int l=read(),r=read(),ans=0;

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

    ans+=upper_bound(lj[j].begin(),lj[j].end(),r)-lj[j].begin();

    }

  write(ans),pl;

  }

}

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

#include<cstdio>

#include<iostream>

#include<vector>

using namespace std;



int main()



{



	int n, m, q;



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



	vector<int>a[505];



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



	{



		int l, r;



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



		a[l].push_back(r);



	}



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



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



	while (q--)



	{



		int p, k;



		scanf("%d%d", &p, &k);



		int ans = 0;



		for (int i = p; i <= k; i++)



			ans += (upper_bound(a[i].begin(), a[i].end(), k) - a[i].begin());



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



	}



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

using namespace std;

int dp[1010][1010];

int main()

{

	int n,m,q,x,y,k;

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

	memset(dp,0,sizeof(dp));

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

	{

		scanf("%d%d",&x,&y);

		dp[x][y]++;

	}

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

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

		{

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

			if(j>1)dp[i][i+j]-=dp[i+1][i+j-1];

		}

	while(q--)

	{

		scanf("%d%d",&x,&y);

		printf("%d\n",dp[x][y]);

	}

	return 0;

}

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

#include<cstdio>

#include<iostream>

#include<vector>

using namespace std;



int main()



{



	int n, m, q;



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



	vector<int>a[505];



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



	{



		int l, r;



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



		a[l].push_back(r);



	}



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



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



	while (q--)



	{



		int p, k;



		scanf("%d%d", &p, &k);



		int ans = 0;



		for (int i = p; i <= k; i++)



			ans += (upper_bound(a[i].begin(), a[i].end(), k) - a[i].begin());



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



	}



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

namespace chtholly{

typedef long long ll;

#define re0 register int

#define rel register ll

#define rec register char

#define gc getchar

#define pc putchar

#define p32 pc(' ')

#define pl puts("")

/*By Citrus*/

inline int read(){

  int x=0,f=1;char c=gc();

  for (;!isdigit(c);c=gc()) f^=c=='-';

  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');

  return f?x:-x;

  }

template <typename mitsuha>

inline bool read(mitsuha &x){

  x=0;int f=1;char c=gc();

  for (;!isdigit(c)&&~c;c=gc()) f^=c=='-';

  if (!~c) return 0;

  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');

  return x=f?x:-x,1;

  }

template <typename mitsuha>

inline int write(mitsuha x){

  if (!x) return 0&pc(48);

  if (x<0) pc('-'),x=-x;

  int bit[20],i,p=0;

  for (;x;x/=10) bit[++p]=x%10;

  for (i=p;i;--i) pc(bit[i]+48);

  return 0;

  }

inline char fuhao(){

  char c=gc();

  for (;isspace(c);c=gc());

  return c;

  }

}using namespace chtholly;

using namespace std;

const int yuzu=1e5;

//struct node{

//int l,r,id;

//void rd(int i){l=read(),r=read(),id=i;}

//bool operator <(const node &b) const{

//  return l<b.l;

//  }

//}e[yuzu|10],p[yuzu|10];



vector<int> lj[yuzu|10];



int main(){

int i,j,n,m,q;

cin>>n>>m>>q;

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

  int l=read(),r=read();

  lj[l].push_back(r);

  }

for (i=1;i<=500;++i) sort(lj[i].begin(),lj[i].end());

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

  int l=read(),r=read(),ans=0;

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

    ans+=upper_bound(lj[j].begin(),lj[j].end(),r)-lj[j].begin();

    }

  write(ans),pl;

  }

}

// Faster C++ solution for the same problem (measured speedup: 3.517402165443025x):
#include<bits/stdc++.h>



using namespace std;



const int N=502;



int n,m,q;

int f[N][N];



int main()

{

	cin>>n>>m>>q;

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

	{

		int u,v;

		cin>>u>>v;

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

		{

			f[u][j]++;

		}

	}

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

	{

		int u,v;

		cin>>u>>v;

		int res=0;

		for(int j=u;j<=v;++j)

		{

			res+=f[j][v];

		}

		cout<<res<<endl;

	}

	return 0;

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

using namespace std;

int dp[1010][1010];

int main()

{

	int n,m,q,x,y,k;

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

	memset(dp,0,sizeof(dp));

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

	{

		scanf("%d%d",&x,&y);

		dp[x][y]++;

	}

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

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

		{

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

			if(j>1)dp[i][i+j]-=dp[i+1][i+j-1];

		}

	while(q--)

	{

		scanf("%d%d",&x,&y);

		printf("%d\n",dp[x][y]);

	}

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.141945898575906x):
#include<bits/stdc++.h>



using namespace std;



const int N=502;



int n,m,q;

int f[N][N];



int main()

{

	cin>>n>>m>>q;

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

	{

		int u,v;

		cin>>u>>v;

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

		{

			f[u][j]++;

		}

	}

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

	{

		int u,v;

		cin>>u>>v;

		int res=0;

		for(int j=u;j<=v;++j)

		{

			res+=f[j][v];

		}

		cout<<res<<endl;

	}

	return 0;

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



using namespace std;



typedef long long ll;



const int MAX_M = 2e+5+10, MAX_Q = 1e+5+10, MAX_N = 500+10;



int main(int argc, char const *argv[]) {

  int n, m, Q, l[MAX_M], r[MAX_M], p[MAX_Q], q[MAX_Q], x[MAX_N][MAX_N]={0}, c[MAX_N][MAX_N]={0};

  cin >> n >> m >> Q;

  for (ll i = 0; i < m; i++) cin >> l[i] >> r[i];



  for (ll i = 0; i < Q; i++) cin >> p[i] >> q[i];

  for (ll i = 0; i < m; i++) x[l[i]][r[i]]++;

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

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

      c[i][j] = c[i][j-1] + x[i][j];

    }

  }

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

    ll sum = 0;

    for (int j = p[i]; j <= q[i]; j++) sum += c[j][q[i]] - c[j][p[i]-1];

    cout << sum << endl;

  }

  return 0;

}


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



using namespace std;



const int MAX_N = 5e2+10;

const int MAX_Q = 1e5+10;



int main(int argc, char const *argv[])

{

	int n, m, Q;

	cin >> n >> m >> Q;



	int s[MAX_N][MAX_N]={0};



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

		int l, r;

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

		s[l][r]++;

	}



	int p[MAX_Q], q[MAX_Q];

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

		scanf("%d %d", &p[i], &q[i]);

	}



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

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

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

		}

	}



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

		int l=p[i], r=q[i];

		cout << s[r][r] - s[r][l-1] - s[l-1][r] + s[l-1][l-1] << endl;

	}



	return 0;

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

using namespace std;

int mape[505][505];

int ans[505][505];

int main(){

	int n,m,q;

	cin>>n>>m>>q;

	memset(mape,0,sizeof(mape));

	memset(ans,0,sizeof(ans));

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

		int l,r;

		cin>>l>>r;

		mape[l][r]++;

	}

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

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

			ans[i][j]=ans[i][j-1]+mape[i][j]; 

			//cout<<ans[i][j]<<endl;

		}

	}

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

		int l,r;

		cin>>l>>r;

		int now=0;

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

			now+=ans[j][r];

		}

		cout<<now<<endl;

	}

} 

// Faster C++ solution for the same problem (measured speedup: 1.5695946112123331x):
#include<bits/stdc++.h>

using namespace std;

int mape[505][505]={0};

int ans[505][505]={0};

int main(){

	int n,m,q;

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

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

		int l,r;

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

		mape[l][r]++;

	}

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

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

			ans[i][j]=ans[i][j-1]+mape[i][j]; 

		}

	}

	for(int i=500;i>=1;i--){

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

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

		}

	}

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

		int l,r;

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

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

	}

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

using namespace std;

int mape[505][505];

int ans[505][505];

int main(){

	ios_base::sync_with_stdio(false);

	cin.tie();

	int n,m,q;

	cin>>n>>m>>q;

	memset(mape,0,sizeof(mape));

	memset(ans,0,sizeof(ans));

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

		int l,r;

		cin>>l>>r;

		mape[l][r]++;

	}

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

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

			ans[i][j]=ans[i][j-1]+mape[i][j]; 

		}

	}

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

		int l,r;

		cin>>l>>r;

		int now=0;

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

			now+=ans[j][r];

		}

		cout<<now<<endl;

	}

} 

// Faster C++ solution for the same problem (measured speedup: 1.5752683185143213x):
#include<bits/stdc++.h>

using namespace std;

int mape[505][505]={0};

int ans[505][505]={0};

int main(){

	int n,m,q;

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

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

		int l,r;

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

		mape[l][r]++;

	}

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

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

			ans[i][j]=ans[i][j-1]+mape[i][j]; 

		}

	}

	for(int i=500;i>=1;i--){

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

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

		}

	}

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

		int l,r;

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

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

	}

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

using namespace std;

int mape[505][505];

int ans[505][505];

int ans2[505][505];

int main(){

	ios_base::sync_with_stdio(false);

	cin.tie();

	int n,m,q;

	cin>>n>>m>>q;

	memset(mape,0,sizeof(mape));

	memset(ans,0,sizeof(ans));

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

		int l,r;

		cin>>l>>r;

		mape[l][r]++;

	}

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

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

			ans[i][j]=ans[i][j-1]+mape[i][j]; 

		}

	}

	for(int i=500;i>=1;i--){

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

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

		}

	}

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

		int l,r;

		cin>>l>>r;

		cout<<ans[l][r]<<endl;

	}

} 

// Faster C++ solution for the same problem (measured speedup: 1.6428733536592148x):
#include<bits/stdc++.h>

using namespace std;

int mape[505][505]={0};

int ans[505][505]={0};

int main(){

	int n,m,q;

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

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

		int l,r;

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

		mape[l][r]++;

	}

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

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

			ans[i][j]=ans[i][j-1]+mape[i][j]; 

		}

	}

	for(int i=500;i>=1;i--){

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

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

		}

	}

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

		int l,r;

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

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

	}

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

using namespace std;

int mape[505][505];

int ans[505][505];

int ans2[505][505];

int main(){

	ios_base::sync_with_stdio(false);

	cin.tie(nullptr);

	int n,m,q;

	cin>>n>>m>>q;

	memset(mape,0,sizeof(mape));

	memset(ans,0,sizeof(ans));

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

		int l,r;

		cin>>l>>r;

		mape[l][r]++;

	}

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

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

			ans[i][j]=ans[i][j-1]+mape[i][j]; 

		}

	}

	for(int i=500;i>=1;i--){

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

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

		}

	}

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

		int l,r;

		cin>>l>>r;

		cout<<ans[l][r]<<endl;

	}

} 

// Faster C++ solution for the same problem (measured speedup: 1.6450564024909193x):
#include<bits/stdc++.h>

using namespace std;

int mape[505][505]={0};

int ans[505][505]={0};

int main(){

	int n,m,q;

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

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

		int l,r;

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

		mape[l][r]++;

	}

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

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

			ans[i][j]=ans[i][j-1]+mape[i][j]; 

		}

	}

	for(int i=500;i>=1;i--){

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

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

		}

	}

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

		int l,r;

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

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

	}

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



using namespace std;



int n, m, Q;

static const int MAX = 501;

int train[MAX][MAX];



int main() {



    cin >> n >> m >> Q;



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

        int l, r;

        cin >> l >> r ;

        train[l][r]++;

    }



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

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

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

        }

    }



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

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

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

        }

    }



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

        int p, q;

        cin >> p >> q;

        cout << train[q][q] + train[p-1][p-1] - train[p-1][q] - train[q][p-1]<< '\n';



    }

}




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



using namespace std;



int n, m, Q;

static const int MAX = 501;

int train[MAX][MAX];



int main() {



    cin >> n >> m >> Q;



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

        int l, r;

        cin >> l >> r ;

        train[l][r]++;

    }



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

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

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

        }

    }



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

        int p, q;

        cin >> p >> q;

        int ans = 0;

        for (int j = p; j <= q; j++) ans += train[j][q] - train[j][p-1];

        cout << ans << '\n';

    }

}
// Slower C++ solution:
#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;

}

// Faster C++ solution for the same problem (measured speedup: 5.167203304441056x):
#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;

}
// Slower C++ solution:
#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;

    }

    

}


// Faster C++ solution for the same problem (measured speedup: 1.673022089261906x):
#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;

    }

    

}
// 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.4507504238507005x):
#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;

  }

}