stablegradients/pie-gem5-pairs huggingface dataset:
// Slower C++ solution:
#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;

}


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

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

}


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

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

}


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

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

}

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

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

}


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

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

	}

}


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

	}

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

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

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

}

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

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

}
// 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.7666393675886627x):
#include<cstdio>

#include<vector>

#include<algorithm>

#define maxn 502

using namespace std;

#if 0

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;

}

#else

vector<int> v[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);

		v[x].push_back(y);

	}

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

	while(q--){

		int x,y,ans=0;

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

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

			ans+=upper_bound(v[i].begin(),v[i].end(),y)-v[i].begin();

		}

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

	}

	return 0;

	return 0;

}

#endif
// 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.506295537618071x):
#include<cstdio>

#include<vector>

#include<algorithm>

#define maxn 502

using namespace std;

#if 0

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;

}

#else

vector<int> v[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);

		v[x].push_back(y);

	}

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

	while(q--){

		int x,y,ans=0;

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

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

			ans+=upper_bound(v[i].begin(),v[i].end(),y)-v[i].begin();

		}

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

	}

	return 0;

	return 0;

}

#endif
// 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.4461952158107976x):
#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;

}