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



using namespace std;



int rang[510][510],f[510][510];

int main()

{

    int n,m,q;

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

        

    int l,r;

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

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

        rang[l][r]++;

    }

            

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

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

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

        }

    }



    while(q--){

        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>

using namespace std;

const int NN = 700;

int x, y, ans, n, m, q, a[NN][NN], b[NN][NN], c[NN][NN];



int main(){

	//freopen("atcoderabc106d.in", "r", stdin);

	

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

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

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

		a[x][y]++;

	}

	

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

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

			for (int k=i; k<=j; k++) b[i][j] += a[i][k];  //b[i][j]表示以i为起点，终点在j及j之前的边的个数 

	

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

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

			for (int k=i; k<=j; k++) c[i][j] += b[k][j];  //c[i][j]即为所求 

	

	

	while (q--){

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

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

		//printf("%d %d %d\n", r[y] - l[x-1], r[y], l[x-1]);

	} 

	

	return 0;

} 

// Fastest known solution for this problem:
// Original C++ solution (slower):
// vjudge 259706 D

#include <cstdio>

#include <algorithm>

#include <vector>

const int MAXN = 510;



std::vector<int> T[MAXN];

int N, M, Q;



namespace FastIO {

	template <typename T>

	void read(T & x) {

		x = 0; register char ch = getchar();

		for (; ch < '0' || ch > '9'; ch = getchar());

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

	}

}



int main() {

	using FastIO::read;

	read(N), read(M), read(Q);

	for (int i = 0, Li, Ri; i < M; i++) {

		read(Li), read(Ri);

		T[Li].push_back(Ri);

	}

	for (int i = 1; i <= 500; i++) std::sort(T[i].begin(), T[i].end());

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

		read(l), read(r);

		int ans = 0;

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

//			printf("l=%d ?%d\n", l, std::upper_bound(T[l].begin(), T[l].end(), r) == T[l].end());

			ans += std::upper_bound(T[l].begin(), T[l].end(), r) - T[l].begin();

		}

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

	}

	return 0;

}

// Optimized solution to the same problem (faster):
//看题解了，重做 

#include <cstdio>

#include <cstring>

#include <algorithm>

using namespace std;

const int NN = 700;

int x, y, ans, n, m, q, a[NN][NN], b[NN][NN], c[NN][NN];



int main(){

	//freopen("atcoderabc106d.in", "r", stdin);

	

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

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

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

		a[x][y]++;

	}

	

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

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

			for (int k=i; k<=j; k++) b[i][j] += a[i][k];  //b[i][j]表示以i为起点，终点在j及j之前的边的个数 

	

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

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

			for (int k=i; k<=j; k++) c[i][j] += b[k][j];  //c[i][j]即为所求 

	

	

	while (q--){

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

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

		//printf("%d %d %d\n", r[y] - l[x-1], r[y], l[x-1]);

	} 

	

	return 0;

} 

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<bits/stdc++.h>

using namespace std;



const int maxn=505;

int n,m,q,dif[maxn][maxn],ans[maxn][maxn],f[maxn][maxn],l,r;



int main(){

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

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

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

		dif[l][r]++;

	}

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

		ans[j][j]=dif[j][j];

		for (int i=j-1;i>=1;i--) ans[i][j]=ans[i+1][j]+dif[i][j];

	}

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

		f[i][i]=dif[i][i];

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

	}

	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>

using namespace std;

const int NN = 700;

int x, y, ans, n, m, q, a[NN][NN], b[NN][NN], c[NN][NN];



int main(){

	//freopen("atcoderabc106d.in", "r", stdin);

	

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

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

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

		a[x][y]++;

	}

	

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

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

			for (int k=i; k<=j; k++) b[i][j] += a[i][k];  //b[i][j]表示以i为起点，终点在j及j之前的边的个数 

	

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

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

			for (int k=i; k<=j; k++) c[i][j] += b[k][j];  //c[i][j]即为所求 

	

	

	while (q--){

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

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

		//printf("%d %d %d\n", r[y] - l[x-1], r[y], l[x-1]);

	} 

	

	return 0;

} 

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

#include <cstdlib>

#include <cstdio>

#include <cstring>

#include <algorithm>

#include <cmath>

#include <cctype>



const int M=2e5+11;

using namespace std;

struct node{

	int l, r, ans, id;

	bool q;

}a[M*2];



int n, m, Q, num[1011];



bool cmp(node x, node y) {

	if (x.r!=y.r) return x.r<y.r;

	else return x.q<y.q;

}



bool cmp0(node x, node y) {

	if (x.q!=y.q) return x.q>y.q; 

    else return x.id<y.id;

}



inline int get() {

    int X=0,W=0; char CH=0;

    while(!isdigit(CH)) {W|=CH=='-';CH=getchar();}

    while(isdigit(CH)) X=(X<<3)+(X<<1)+(CH^48), CH=getchar();

    return W?-X:X;

}

 

int main() {

	n=get(), m=get(), Q=get();

	for (register int i=1; i<=m; i++) a[i].l=get(), a[i].r=get();

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

	    a[i].l=get(), a[i].r=get(), a[i].id=i, a[i].q=true;

	

	sort(a+1, a+m+Q+1, cmp);

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

		if (!a[i].q) num[a[i].l]++;

		else {

			int sum=0;

			for (int j=a[i].l; j<=a[i].r; j++) 

			    sum+=num[j];

			a[i].ans=sum;

		}

	}	

	

	sort(a+1, a+m+Q+1, cmp0);

	

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

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

 	return 0;

}

// Optimized solution to the same problem (faster):
//看题解了，重做 

#include <cstdio>

#include <cstring>

#include <algorithm>

using namespace std;

const int NN = 700;

int x, y, ans, n, m, q, a[NN][NN], b[NN][NN], c[NN][NN];



int main(){

	//freopen("atcoderabc106d.in", "r", stdin);

	

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

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

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

		a[x][y]++;

	}

	

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

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

			for (int k=i; k<=j; k++) b[i][j] += a[i][k];  //b[i][j]表示以i为起点，终点在j及j之前的边的个数 

	

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

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

			for (int k=i; k<=j; k++) c[i][j] += b[k][j];  //c[i][j]即为所求 

	

	

	while (q--){

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

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

		//printf("%d %d %d\n", r[y] - l[x-1], r[y], l[x-1]);

	} 

	

	return 0;

} 

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

#include <cstring>

#include <string>

#include <cstdio>

#include <cmath>

using namespace std;

const int N = 5e2 + 10;

int n, m, q;

int dp[N][N], a[N][N];

int main()

{

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

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

    {

        int x, y;

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

        a[x][y]++;

    }

    for (int i = n; i >= 1; i--)

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

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

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

    {

        int x, y;

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

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

    }

}

// Optimized solution to the same problem (faster):
//看题解了，重做 

#include <cstdio>

#include <cstring>

#include <algorithm>

using namespace std;

const int NN = 700;

int x, y, ans, n, m, q, a[NN][NN], b[NN][NN], c[NN][NN];



int main(){

	//freopen("atcoderabc106d.in", "r", stdin);

	

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

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

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

		a[x][y]++;

	}

	

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

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

			for (int k=i; k<=j; k++) b[i][j] += a[i][k];  //b[i][j]表示以i为起点，终点在j及j之前的边的个数 

	

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

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

			for (int k=i; k<=j; k++) c[i][j] += b[k][j];  //c[i][j]即为所求 

	

	

	while (q--){

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

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

		//printf("%d %d %d\n", r[y] - l[x-1], r[y], l[x-1]);

	} 

	

	return 0;

} 

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

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;

  }

}


// Optimized solution to the same problem (faster):
#include <bits/stdc++.h>



using namespace std;



const int MAX = 300000 + 5;

int ID[MAX], Ls[MAX], Rs[MAX], ans[MAX], store[MAX];



void update(int i, int x) {

    for (; i < MAX; i += i & -i) store[i] += x;

}



int Sum(int i) {

    int ret = 0;

    for (; i; i -= i & -i) ret += store[i];

    return ret;

}



bool cmp(int i1, int i2){

    if (Ls[i1] == Ls[i2]) return i1 < i2;

    return Ls[i1] > Ls[i2];

}



int main(){

    int n, m, q;

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

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

        ID[i] = i;

        scanf("%d%d", &Ls[i], &Rs[i]);

    }

    sort(ID, ID + m + q, cmp);

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

        if (ID[i] >= m){

            ans[ID[i] - m] = Sum(Rs[ID[i]]);

        }

        else {

            update(Rs[ID[i]], 1);

        }

    }

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

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

}

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

#include<cstring>

#include<algorithm>

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const double PI = acos(-1.0);

const double eps = 1e-6;

const int INF = 0x3f3f3f3f;



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



const int MAXN = 500 + 10;

int a[MAXN][MAXN];

int b[MAXN][MAXN];

int ans[MAXN][MAXN];



void init() {

	memset(a, 0, sizeof(a));

	memset(b, 0, sizeof(b));

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

}

int main() {

	int n, m, q;

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

	init();

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

		int l, r;

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

		a[l][r]++;

	}



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

		b[j][j] = a[j][j];

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

			b[i][j] = b[i + 1][j] + a[i][j];

		}

	}



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

		ans[i][i] = a[i][i];

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

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

		}

	}

	while (q--) {

		int li, ri;

		scanf("%d %d", &li, &ri);

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

	}

	return 0;

}

// Optimized solution to the same problem (faster):
#include <bits/stdc++.h>



using namespace std;



const int MAX = 300000 + 5;

int ID[MAX], Ls[MAX], Rs[MAX], ans[MAX], store[MAX];



void update(int i, int x) {

    for (; i < MAX; i += i & -i) store[i] += x;

}



int Sum(int i) {

    int ret = 0;

    for (; i; i -= i & -i) ret += store[i];

    return ret;

}



bool cmp(int i1, int i2){

    if (Ls[i1] == Ls[i2]) return i1 < i2;

    return Ls[i1] > Ls[i2];

}



int main(){

    int n, m, q;

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

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

        ID[i] = i;

        scanf("%d%d", &Ls[i], &Rs[i]);

    }

    sort(ID, ID + m + q, cmp);

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

        if (ID[i] >= m){

            ans[ID[i] - m] = Sum(Rs[ID[i]]);

        }

        else {

            update(Rs[ID[i]], 1);

        }

    }

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

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

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<bits/stdc++.h>

#define MAX 200007

using namespace std;



typedef long long ll;

vector<ll>v[MAX];



int main()

{



    ll a,b,i,l,r,q,n,m,j,pos,res,cal;

    vector<ll>v1;

    v1.push_back(4);

    v1.push_back(4);

    v1.push_back(5);

    v1.push_back(6);

    pos=lower_bound(v1.begin(),v1.end(),6)-v1.begin();

    //cout << pos << "\n";

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

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

    {

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

        v[r].push_back(l);

    }

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

    {

        if(v[i].size()>0)

        {

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

        }

    }

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

    {

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

        res=0;

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

        {

            if(v[j].size()==0)continue;

            pos=lower_bound(v[j].begin(),v[j].end(),l)-v[j].begin();

            cal=(v[j].size()-pos);

            res+=cal;

        }

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

    }







    return 0;

}






// Optimized solution to the same problem (faster):
#include <bits/stdc++.h>



using namespace std;



const int MAX = 300000 + 5;

int ID[MAX], Ls[MAX], Rs[MAX], ans[MAX], store[MAX];



void update(int i, int x) {

    for (; i < MAX; i += i & -i) store[i] += x;

}



int Sum(int i) {

    int ret = 0;

    for (; i; i -= i & -i) ret += store[i];

    return ret;

}



bool cmp(int i1, int i2){

    if (Ls[i1] == Ls[i2]) return i1 < i2;

    return Ls[i1] > Ls[i2];

}



int main(){

    int n, m, q;

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

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

        ID[i] = i;

        scanf("%d%d", &Ls[i], &Rs[i]);

    }

    sort(ID, ID + m + q, cmp);

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

        if (ID[i] >= m){

            ans[ID[i] - m] = Sum(Rs[ID[i]]);

        }

        else {

            update(Rs[ID[i]], 1);

        }

    }

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

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

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<bits/stdc++.h> 

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;

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;

  }

}

// Optimized solution to the same problem (faster):
#include <bits/stdc++.h>



using namespace std;



const int MAX = 300000 + 5;

int ID[MAX], Ls[MAX], Rs[MAX], ans[MAX], store[MAX];



void update(int i, int x) {

    for (; i < MAX; i += i & -i) store[i] += x;

}



int Sum(int i) {

    int ret = 0;

    for (; i; i -= i & -i) ret += store[i];

    return ret;

}



bool cmp(int i1, int i2){

    if (Ls[i1] == Ls[i2]) return i1 < i2;

    return Ls[i1] > Ls[i2];

}



int main(){

    int n, m, q;

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

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

        ID[i] = i;

        scanf("%d%d", &Ls[i], &Rs[i]);

    }

    sort(ID, ID + m + q, cmp);

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

        if (ID[i] >= m){

            ans[ID[i] - m] = Sum(Rs[ID[i]]);

        }

        else {

            update(Rs[ID[i]], 1);

        }

    }

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

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

}

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

#include <string>

#include <iostream>

#include <map>

using namespace std;



int main(void){

    int N,M,Q;

    cin >> N >> M >> Q;

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

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

    int l[200005],r[200005];

    int p[100005],q[100005];

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

        cin >> l[i] >> r[i];

        check[l[i]][r[i]]+=1;

    }

    //ここから工事TLE

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

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

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

            for(int k=0; k+i<=N; k++){

                ans[i][j]+=check[i+k][j];

            }

        }

    }

    //この先固定

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

        cin >> p[i] >> q[i];

    }

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

        cout << ans[p[i]][q[i]] << endl;

    }

    return 0;

}

// Optimized solution to the same problem (faster):
#include <stdio.h>

#include <string>

#include <iostream>

#include <iomanip>

#include <map>

#include <algorithm>

#include <vector>

#include <math.h>

#define INF 1000000007

using namespace std;



int main(void) {

	int n,m,q;

	cin >> n >> m >> q;

	int l,r,train[501][501];

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

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

		train[i][j]=0;

		}

	}

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

		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=1; i<=n; i++)for(int j=1; j<=n; j++)train[i][j]+=train[i-1][j];

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

		cin >> l >> r;

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

	}

	return 0;

}

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

#include <string>

#include <iostream>

#include <map>

using namespace std;



int main(void){

    int N,M,Q;

    cin >> N >> M >> Q;

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

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

    int l[200005],r[200005];

    int p[100005],q[100005];

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

        cin >> l[i] >> r[i];

        check[l[i]][r[i]]+=1;

    }

    //ij間に区間が完全に含まれる本数

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

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

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

            for(int k=0; k+i<=N; k++){

                ans[i][j]+=check[i+k][j];

            }

        }

    }

    //質問に答える

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

        cin >> p[i] >> q[i];

    }

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

        cout << ans[p[i]][q[i]] << endl;

    }

    return 0;

}

// Optimized solution to the same problem (faster):
#include <stdio.h>

#include <string>

#include <iostream>

#include <iomanip>

#include <map>

#include <algorithm>

#include <vector>

#include <math.h>

#define INF 1000000007

using namespace std;



int main(void) {

	int n,m,q;

	cin >> n >> m >> q;

	int l,r,train[501][501];

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

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

		train[i][j]=0;

		}

	}

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

		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=1; i<=n; i++)for(int j=1; j<=n; j++)train[i][j]+=train[i-1][j];

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

		cin >> l >> r;

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

	}

	return 0;

}

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

#include <string>

#include <iostream>

#include <map>

using namespace std;



int main(void){

    int N,M,Q;

    cin >> N >> M >> Q;

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

    int l,r;

    int p[100005],q[100005];

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

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

        sum[l][r]+=1;

    }

    //ij間に区間が完全に含まれる本数

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

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

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

        }

    }

    //質問に答える

    int ans;

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

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

    }

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

        ans=sum[q[i]][q[i]]-sum[q[i]][p[i]-1]-sum[p[i]-1][q[i]]+sum[p[i]-1][p[i]-1];

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

    }

    return 0;

}

// Optimized solution to the same problem (faster):
#include <stdio.h>

#include <string>

#include <iostream>

#include <iomanip>

#include <map>

#include <algorithm>

#include <vector>

#include <math.h>

#define INF 1000000007

using namespace std;



int main(void) {

	int n,m,q;

	cin >> n >> m >> q;

	int l,r,train[501][501];

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

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

		train[i][j]=0;

		}

	}

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

		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=1; i<=n; i++)for(int j=1; j<=n; j++)train[i][j]+=train[i-1][j];

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

		cin >> l >> r;

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

	}

	return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<bits/stdc++.h>

using namespace std;

//long long a[505],b[505];

int s[505][505];//,f[505][505];

int n,m,l,x,y;

int main()

{

    //freopen("express.in","r",stdin);

   // freopen("express.out","w",stdout);

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

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

    {

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

        //a[x]++;

        //b[y]++;

        s[x][y]++;

        //f[y][x]++;

    }

    //for(register int i=500;i>=1;i--)

    //    a[i]=a[i]+a[i+1];

    //for(register int i=1;i<=500;i++)

    //    b[i]=b[i]+b[i-1];

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

        for(register int j=i+1;j<=500;j++)

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

    //for(register int i=1;i<=500;i++)

    //    for(register int j=i;j>=1;j--)

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

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

        for(register int j=i-1;j>=1;j--)

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

    for(register int i=1;i<=l;i++)

    {

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

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

    }

    return 0;

}

// Optimized solution to the same problem (faster):
#include<bits/stdc++.h>

using namespace std;

int f[502][502];

int main()

{

	int n,m,p,i,j,k,x,y;

	//freopen("express.in","r",stdin);

	//freopen("express.out","w",stdout);

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

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

	   scanf("%d%d",&x,&y),f[x][y]++;

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

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

	 {

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

	 	for(k=i+1;k<=j;k++)

	 	 f[i][j]+=f[k][j];

	 }

	for(i=1;i<=p;i++)

	{

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

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

	}

	return 0;

}

// Fastest known solution for this problem: