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



using namespace std;



int table[501][501];

int C[501][501];



int main() {

  ios::sync_with_stdio(false);

  cin.tie(0);



  int N, M, Q;

  cin >> N >> M >> Q;



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

    int l, r;

    cin >> l >> r;

    table[l][r]++;

  }

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

    C[i][1] = table[i][1];

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

      C[i][j] = C[i][j - 1] + table[i][j];

    }

  }

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

    int p, q;

    cin >> p >> q;



    int ans = 0;

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

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

    }

    cout << ans << endl;

  }



  return 0;

}


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



using namespace std;



int table[501][501];



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);

    table[l][r]++;

  }

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

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

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

    }

  }

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

    int p, q;

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

    const int ans =

        table[q][q] - table[p - 1][q] - table[q][p - 1] + table[p - 1][p - 1];

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

  }



  return 0;

}


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



using namespace std;



int table[501][501];



int main() {

  ios::sync_with_stdio(false);

  cin.tie(0);



  int N, M, Q;

  cin >> N >> M >> Q;



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

    int l, r;

    cin >> l >> r;

    table[l][r]++;

  }

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

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

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

    }

  }

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

    int p, q;

    cin >> p >> q;



    const int ans =

        table[q][q] - table[p - 1][q] - table[q][p - 1] + table[p - 1][p - 1];

    cout << ans << endl;

  }



  return 0;

}


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



using namespace std;



int table[501][501];



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);

    table[l][r]++;

  }

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

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

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

    }

  }

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

    int p, q;

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

    const int ans =

        table[q][q] - table[p - 1][q] - table[q][p - 1] + table[p - 1][p - 1];

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

  }



  return 0;

}


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



using namespace std;



int table[501][501];



int main() {

  ios::sync_with_stdio(false);

  cin.tie(0);



  int N, M, Q;

  cin >> N >> M >> Q;



  int l, r;

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

    cin >> l >> r;

    table[l][r]++;

  }

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

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

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

    }

  }

  int p, q;

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

    cin >> p >> q;



    const int ans =

        table[q][q] - table[p - 1][q] - table[q][p - 1] + table[p - 1][p - 1];

    cout << ans << endl;

  }



  return 0;

}


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



using namespace std;



int table[501][501];



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);

    table[l][r]++;

  }

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

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

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

    }

  }

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

    int p, q;

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

    const int ans =

        table[q][q] - table[p - 1][q] - table[q][p - 1] + table[p - 1][p - 1];

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

  }



  return 0;

}


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

#include <vector>

#include <algorithm>

#include <string>

#include <map>

#include <cmath>

#include <queue>

#include <numeric>

#include <climits>

#include <iterator>

#include <iomanip>

#include <stack>

#include <set>

#include <bitset>

#include <functional>

using namespace std;

const constexpr int INF = 1e9;

//typedef std::pair<std::string,double> P;





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

#define REP(i, n) FOR(i, 0, n)



typedef long long ll;

typedef vector<int> VI;

const constexpr ll MOD = 1e9+7;

vector<pair<int, int> > vp;

 

struct Less {

    bool operator()(const pair<int, int>& x, const pair<int, int>& y) const {

        return x.first > y.first;

    }

};



ll GCD(ll a, ll b){

    if(b==0) return a;

    return GCD(b, a%b);

}





//グラフの隣接リスト

VI g[200010];

//頂点の入次数を管理

int h[100010];



vector<int> v;

int L[200009], R[200009];

int C[510][510], X[510][510];

int main(void) {

    

    ll N, M, Q; cin >> N >> M >> Q;

    REP(i, M){

        cin >> L[i] >> R[i]; X[L[i]][R[i]]++;

    }

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

        for(int j=1; j<=N; ++j) C[i][j] = C[i][j-1]+X[i][j];

    }

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

        int p, q; cin >> p >> q;

        int ans=0;

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

        cout << ans << endl;

    }

    

    return 0;

}

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

#include <vector>

#include <string>

#include <stack>

#include <map>

#include <algorithm>

#include <iomanip>

#include <cmath>

#include <queue>

#include <climits>

using namespace std;





#define MOD 1000000007

using ll = long long;



bool operator<(const pair<int, int>& a, const pair<int, int>& b) {

	if (a.first == b.first) {

		return a.second < b.second;

	}

	return a.first < b.first;

}



int grid[510][510];



int main() {

	cin.tie(0);

	ios::sync_with_stdio(false);

	

	int N, M, Q; cin >> N >> M >> Q;

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

		int L, R; cin >> L >> R;

		grid[L][R]++;

	}



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

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

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

		}

	}

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

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

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

		}

	}





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

		int p, q; cin >> p >> q;

		

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



		//cout << grid[q][q] << " " << grid[p-1][q] << " " << grid[q][p-1] << " " << grid[p-1][p-1] << endl;

	}

	int a; cin >> a;

	return 0;

}

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



using namespace std;



inline int read(){

	char ch=getchar();int x=0,f=1;

    while(ch<'0' || ch>'9') {

       if(ch=='-') f=-1;

	  	  ch=getchar();

	}

    while(ch<='9' && ch>='0') {

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

	   ch=getchar();

	}

    return x*f;

}



int f[1010][1010];



int a[1010][1001];



int main(){

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

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

		int x=read(),y=read();

		a[x][y]++;

	}

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

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

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

		}

	}

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

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

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

		}

	}

	

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

		int x=read(),y=read();

		cout<<f[x][y]<<endl;

	}

	return 0;

}


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



using namespace std;



inline int read(){

	char ch=getchar();int x=0,f=1;

    while(ch<'0' || ch>'9') {

       if(ch=='-') f=-1;

	  	  ch=getchar();

	}

    while(ch<='9' && ch>='0') {

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

	   ch=getchar();

	}

    return x*f;

}



int f[1010][1010];



int main(){

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

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

		int x=read(),y=read();

		f[x][y]++;

	}

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

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

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

		}

	}

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

		int x=read(),y=read();

		cout<<f[y][y]-f[y][x-1]-f[x-1][y]+f[x-1][x-1]<<endl;

	}

	return 0;

}


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

using namespace std;



using ll = long long;



constexpr ll MOD = 1e9+7;

constexpr ll INF = 1ll<<60;



#define FOR(i,a,b) for (ll i=(a);i<(ll)(b);++i)

#define REP(i,n) FOR(i,0,n)

#define ALL(v) (v).begin(),(v).end()



ll R[510][510], sum[510][510];



int main(int argc, char **argv)

{

	ll N, M, Q; cin >> N >> M >> Q;

	REP(i, M)

	{

		ll l, r; cin >> l >> r;

		++R[l][r];

	}



	memset(sum, 0, sizeof sum);

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

		for (ll j = 1; j <= N; ++j) sum[i][j] = sum[i][j-1] + R[i][j];



	REP(_, Q)

	{

		ll l, r; cin >> l >> r;

		ll res{0};

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

			res += sum[i][r] - sum[i][l-1];



		std::cout << res << std::endl;

	}

}


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

using namespace std;



using ll = long long;



constexpr ll MOD = 1e9+7;

constexpr ll INF = 1ll<<60;



#define FOR(i,a,b) for (ll i=(a);i<(ll)(b);++i)

#define REP(i,n) FOR(i,0,n)

#define ALL(v) (v).begin(),(v).end()



ll N, M, Q, sum[510][510], lr[510][510];



int main(int argc, char **argv)

{

	cin >> N >> M >> Q;

	REP(i, M)

	{

		ll l, r; cin >> l >> r;

		--l, --r;

		++lr[l][r];

	}



	REP(i, N)REP(j, N)

	{

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

	}



	REP(_, Q)

	{

		ll l, r; cin >> l >> r;

		--l, --r;

		std::cout << sum[r+1][r+1] - sum[r+1][l] - sum[l][r+1] + sum[l][l] << std::endl;

	}

}


// 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;

//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;

  }

}

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

#define maxn 502

using namespace std;

int dp[maxn][maxn],h[maxn][maxn];

int main(){

	int n,m,q;

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

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

		int x,y;

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

		h[x][y]++;

	}

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

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

			int j=i+len-1;

			if(i==j){

				dp[i][j]=h[i][j];

			}

			else if(i+1==j){

				dp[i][j]=dp[i][i]+dp[j][j]+h[i][j];

			}

			else{

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

			}

		}

	}

	while(q--){

		int x,y;

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

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

	}

	return 0;

}

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

#define rep(i,l,r) for(int i=(l);i<=(r);++i)

#define per(i,r,l) for(int i=(l);i<=(r);++i)

using namespace std;

typedef long long ll;

ll a[600][600];

int n,m,q,l,r;

int main(){

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

	rep(i,1,m){scanf("%d%d",&l,&r),a[l][r]++;}

	rep(i,1,n) rep(j,1,n) a[i][j]+=a[i][j-1]; 

	rep(i,1,q){

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

		ll ans=0;

		rep(j,l,r) ans+=a[j][r];

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

	}

	return 0;

}

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

#define maxn 502

using namespace std;

int dp[maxn][maxn],h[maxn][maxn];

int main(){

	int n,m,q;

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

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

		int x,y;

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

		h[x][y]++;

	}

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

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

			int j=i+len-1;

			if(i==j){

				dp[i][j]=h[i][j];

			}

			else if(i+1==j){

				dp[i][j]=dp[i][i]+dp[j][j]+h[i][j];

			}

			else{

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

			}

		}

	}

	while(q--){

		int x,y;

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

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

	}

	return 0;

}

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

}

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

#define maxn 502

using namespace std;

int dp[maxn][maxn],h[maxn][maxn];

int main(){

	int n,m,q;

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

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

		int x,y;

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

		h[x][y]++;

	}

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

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

			int j=i+len-1;

			if(i==j){

				dp[i][j]=h[i][j];

			}

			else if(i+1==j){

				dp[i][j]=dp[i][i]+dp[j][j]+h[i][j];

			}

			else{

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

			}

		}

	}

	while(q--){

		int x,y;

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

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

	}

	return 0;

}

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

}


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

}

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

	}

} 

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

	}

} 

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

	}

} 

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

	}

} 

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

	}

} 

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

	}

} 

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

	}

} 

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

	}

} 

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



    }

}




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

    }

}




// Fastest known solution for this problem: