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,i,x,y,j,k;

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

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

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

	{

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

		dp[x][y]++;

	}

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

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

		{

			k=i+j;

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

			if(j>1)dp[i][k]-=dp[i+1][k-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.08121129291287x):
#include<bits/stdc++.h>

using namespace std;

#define cc(a) cout << a << endl;

#define msg(a,b) cout << a << " : " << b << endl;

#define msg2(a,b,c) cout << a << " : " << b << " : " << c << endl;

#define msg3(a,b,c,d) cout << a << " : " << b << " : " << c << " : " << d << endl;







int main(){

    long long int n,m,q,u,v,l,r,sum;

    cin >> n >> m >> q;

    vector<long long int> vec[n+2];

    map<pair<long long int, long long int>,long long int > mp;

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

        cin >> u >> v;

        //vec.push_back(make_pair(u,v));

        vec[u].push_back(v);

    }

    //sort(vec.begin(),vec.end());

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

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

    }

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

        cin >> u >> v;

        sum = 0;

        if(mp.find(make_pair(u,v)) != mp.end()  ){

            cout << mp[make_pair(u,v)]  << endl;

            continue;

        }

        for(int i=u;i<=v;i++){

            r = upper_bound(vec[i].begin(),vec[i].end(), v)-vec[i].begin();

            sum += r;

        }

        mp[ make_pair(u,v)] = sum;

        //msg("ANS", sum)

        cout << sum << endl;

    }

   return 0;

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

using namespace std;

int dp[1010][1010];

int main()

{

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

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

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

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

	{

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

		dp[x][y]++;

	}

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

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

		{

			k=i+j;

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

			if(j>1)dp[i][k]-=dp[i+1][k-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.042528233499225x):
#include <bits/stdc++.h>

#define all(x) begin(x), end(x)

#define _ << ' ' <<

using namespace std;

using ll = long long;



int dp[505][505];

vector<int> en[505];



int main()

{

    int n, m, q;

    cin >> n >> m >> q;

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

    {

        int l, r;

        cin >> l >> r;

        en[l].push_back(r);

    }

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

    {

        vector<int> red(n + 1);

        int cnt = 0;

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

        {

            for (int x : en[j])

                red[x]++;

            cnt += red[j];

            dp[i][j] = cnt;

            //cnt -= red[j];

        }

    }

    while (q--)

    {

        int l, r;

        cin >> l >> r;

        cout << dp[l][r] << '\n';

    }

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

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.484734568515505x):
#include<bits/stdc++.h>

using namespace std;

vector<int> g[505];

int n, m, q, s, t, h[505][505];

int main(){

	cin>>n>>m>>q;

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

		scanf("%d%d", &s, &t);

		g[s].push_back(t);

	}

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

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

		for(int v:g[i]){

			h[i][v]++;

		}

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

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

		}

	}

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

		scanf("%d%d", &s, &t);

		int ans=0;

		for(int j=s;j<=t;j++){

			ans+=h[j][t];

		}

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

	}

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

}

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

using namespace std;

vector<int> g[505];

int n, m, q, s, t, h[505][505];

int main(){

	cin>>n>>m>>q;

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

		scanf("%d%d", &s, &t);

		g[s].push_back(t);

	}

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

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

		for(int v:g[i]){

			h[i][v]++;

		}

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

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

		}

	}

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

		scanf("%d%d", &s, &t);

		int ans=0;

		for(int j=s;j<=t;j++){

			ans+=h[j][t];

		}

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

	}

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

}






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

using namespace std;

vector<int> g[505];

int n, m, q, s, t, h[505][505];

int main(){

	cin>>n>>m>>q;

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

		scanf("%d%d", &s, &t);

		g[s].push_back(t);

	}

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

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

		for(int v:g[i]){

			h[i][v]++;

		}

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

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

		}

	}

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

		scanf("%d%d", &s, &t);

		int ans=0;

		for(int j=s;j<=t;j++){

			ans+=h[j][t];

		}

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

	}

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

}

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

  }

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

}






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

  }

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

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.561966688135272x):
#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]);

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

}

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

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

}






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

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

  }

}

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

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

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.535264332121245x):
#include <bits/stdc++.h>

using namespace std;

const int maxn = 505;



int n,m,Q;

int f[maxn][maxn];



int main(){

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

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

		int u,v;

		scanf("%d%d",&u,&v);

		if (v < u) swap(u,v);

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

			f[u][i]++;

		}

	}

	//cout << "ah" << endl;

	int ret = 0;

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

		int p,q;

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

		int ret = 0;

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

			ret += f[i][q];

		}

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

	}

	return 0;

}