stablegradients/pie-gem5-pairs huggingface dataset:
// Slower C++ solution:
#include <cstdio>

#include <cstring>

#include <iostream>

#include <algorithm>

#define LL long long



using namespace std;



const int MAXN=502,MAXM=2000011;

int n,m,q;

int sum[MAXN][MAXN];

int Query(int l,int r)

{

	return sum[r][r]-sum[r][l-1]-sum[l-1][r]+sum[l-1][l-1];

}

int main()

{

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

	

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

	{

		int tx,ty;

		scanf("%d%d",&tx,&ty);

		sum[tx][ty]++;

		sum[ty][tx]++;

	}

	

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

	{

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

		{

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

		}

	}

	

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

	{

		int tx,ty;

		scanf("%d%d",&tx,&ty);

		printf("%d\n",Query(tx,ty)/2);

	}

	

	

	return 0;

}




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

#include <cstring>

#include <algorithm>

void Unused(...) {}

#ifndef DEBUG

  #define echo(...) Unused(__VA_ARGS__)

#else

  #define echo(...) fprintf(stderr, __VA_ARGS__)

#endif



const int MaxN = 500 + 7;

const int MaxM = int(3e5) + 7;



struct Inv

{

    int l, r;

    int idx;

    friend bool operator<(const Inv &a, const Inv &b)

    {

        return a.l == b.l ? a.idx < b.idx : a.l > b.l;

    }

};

Inv rd[MaxM];



int n, m, q;

int ans[MaxM];



int vol[MaxN];

int lowbit(int x) { return x & (-x); }



int query(int v)

{

    int res = 0;

    for (; v > 0; v -= lowbit(v))

        res += vol[v];

    return res;

}

void update(int v)

{

    for (; v < MaxN; v += lowbit(v))

        ++vol[v];

}



int main()

{

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

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

        scanf("%d %d", &rd[i].l, &rd[i].r);

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

    {

        scanf("%d %d", &rd[i + m].l, &rd[i + m].r);

        rd[i + m].idx = i;

    }

    std::sort(rd + 1, rd + m + q + 1);



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

    {

        // query

        if (rd[i].idx > 0)

            ans[rd[i].idx] = query(rd[i].r);

        else

            update(rd[i].r);

    }

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

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



    return 0;

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

#include<cstdio>

#include<iostream>

#include<cstdlib>

#define lowbit(x) ((x)&(-(x)))

#define MAXN 1010

using namespace std;

int c[MAXN][MAXN];

int query(int x,int y)

{

	int f=0;

	while(x>0)

	{

		int tmp=y;

		while(tmp>0)

		{

			f+=c[x][tmp];

			tmp-=lowbit(tmp);

		}

		x-=lowbit(x);

	}

	return f;

}

void modify(int x,int y,int v)

{

	while(x<MAXN-10)

	{

		int tmp=y;

		while(tmp<MAXN-10)

		{

			c[x][tmp]+=v;

			tmp+=lowbit(tmp);

		}

		x+=lowbit(x);

	}

}

inline void change(int x,int y,int x1,int y1,int v)

{

	modify(x,y,v);

	modify(x1+1,y,-v);

	modify(x,y1+1,-v);

	modify(x1+1,y1+1,v);

}

int main()

{

	int n,m,Q,l,r;

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

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

	{

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

		change(1,r,l,n,1);

	}

	while(Q--)

	{

		int q1,q2;

		scanf("%d%d",&q1,&q2);

		printf("%d\n",query(q1,q2));

	}

	return 0;

}

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

#include <cstring>

#include <algorithm>

void Unused(...) {}

#ifndef DEBUG

  #define echo(...) Unused(__VA_ARGS__)

#else

  #define echo(...) fprintf(stderr, __VA_ARGS__)

#endif



const int MaxN = 500 + 7;

const int MaxM = int(3e5) + 7;



struct Inv

{

    int l, r;

    int idx;

    friend bool operator<(const Inv &a, const Inv &b)

    {

        return a.l == b.l ? a.idx < b.idx : a.l > b.l;

    }

};

Inv rd[MaxM];



int n, m, q;

int ans[MaxM];



int vol[MaxN];

int lowbit(int x) { return x & (-x); }



int query(int v)

{

    int res = 0;

    for (; v > 0; v -= lowbit(v))

        res += vol[v];

    return res;

}

void update(int v)

{

    for (; v < MaxN; v += lowbit(v))

        ++vol[v];

}



int main()

{

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

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

        scanf("%d %d", &rd[i].l, &rd[i].r);

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

    {

        scanf("%d %d", &rd[i + m].l, &rd[i + m].r);

        rd[i + m].idx = i;

    }

    std::sort(rd + 1, rd + m + q + 1);



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

    {

        // query

        if (rd[i].idx > 0)

            ans[rd[i].idx] = query(rd[i].r);

        else

            update(rd[i].r);

    }

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

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



    return 0;

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

#define LL long long

#define db double

using namespace std;



template <typename T> inline void read(T &x) {

    int c = getchar();

    bool fg = false;

    for (x = 0; !isdigit(c); c = getchar()) {

        if (c == '-') {

            fg = true;

        }

    }

    for (; isdigit(c); c = getchar()) {

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

    }

    if (fg) {

        x = -x;

    }

}

const int MAXN = 550;

const int INF = 0x3f3f3f3f;



int f[MAXN][MAXN], n, m, q;



signed main() {

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

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

		int l, r;

		read(l), read(r);

		f[l][r]++;

		f[r][l]++;

	}

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

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

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

		}

	}

	while(q--) {

		int l, r;

		read(l), read(r);

		int ans = f[r][r] - f[r][l - 1] - f[l - 1][r] + f[l - 1][l - 1];

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

	}

	return 0;

}

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

#include <cstring>

#include <algorithm>

void Unused(...) {}

#ifndef DEBUG

  #define echo(...) Unused(__VA_ARGS__)

#else

  #define echo(...) fprintf(stderr, __VA_ARGS__)

#endif



const int MaxN = 500 + 7;

const int MaxM = int(3e5) + 7;



struct Inv

{

    int l, r;

    int idx;

    friend bool operator<(const Inv &a, const Inv &b)

    {

        return a.l == b.l ? a.idx < b.idx : a.l > b.l;

    }

};

Inv rd[MaxM];



int n, m, q;

int ans[MaxM];



int vol[MaxN];

int lowbit(int x) { return x & (-x); }



int query(int v)

{

    int res = 0;

    for (; v > 0; v -= lowbit(v))

        res += vol[v];

    return res;

}

void update(int v)

{

    for (; v < MaxN; v += lowbit(v))

        ++vol[v];

}



int main()

{

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

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

        scanf("%d %d", &rd[i].l, &rd[i].r);

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

    {

        scanf("%d %d", &rd[i + m].l, &rd[i + m].r);

        rd[i + m].idx = i;

    }

    std::sort(rd + 1, rd + m + q + 1);



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

    {

        // query

        if (rd[i].idx > 0)

            ans[rd[i].idx] = query(rd[i].r);

        else

            update(rd[i].r);

    }

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

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



    return 0;

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

#include<set>

#include<stack>

#include<cmath>

#include<queue>

#include<cstdio>

#include<string>

#include<vector>

#include<cstring>

#include<iostream>

#include<algorithm>

#define inf 0x3f3f3f3f

using namespace std;



int a[505][505], f[505][505];



int main()

{

	int n, m, q, l, r;

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

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

	{

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

		a[l][r]++;

	}

	for (int i = 1; i <= n; ++i) f[i][i] = a[i][i];

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

	for (int k = 2; k <= n - 1; ++k)

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

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

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

	{

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

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

	}

	return 0;

}

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

#include <cstring>

#include <algorithm>

void Unused(...) {}

#ifndef DEBUG

  #define echo(...) Unused(__VA_ARGS__)

#else

  #define echo(...) fprintf(stderr, __VA_ARGS__)

#endif



const int MaxN = 500 + 7;

const int MaxM = int(3e5) + 7;



struct Inv

{

    int l, r;

    int idx;

    friend bool operator<(const Inv &a, const Inv &b)

    {

        return a.l == b.l ? a.idx < b.idx : a.l > b.l;

    }

};

Inv rd[MaxM];



int n, m, q;

int ans[MaxM];



int vol[MaxN];

int lowbit(int x) { return x & (-x); }



int query(int v)

{

    int res = 0;

    for (; v > 0; v -= lowbit(v))

        res += vol[v];

    return res;

}

void update(int v)

{

    for (; v < MaxN; v += lowbit(v))

        ++vol[v];

}



int main()

{

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

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

        scanf("%d %d", &rd[i].l, &rd[i].r);

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

    {

        scanf("%d %d", &rd[i + m].l, &rd[i + m].r);

        rd[i + m].idx = i;

    }

    std::sort(rd + 1, rd + m + q + 1);



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

    {

        // query

        if (rd[i].idx > 0)

            ans[rd[i].idx] = query(rd[i].r);

        else

            update(rd[i].r);

    }

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

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



    return 0;

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

using namespace std;

#define int long long

#define pb push_back

#define faster ios::sync_with_stdio(0)

const int N  = 509;

vector<int>v[N+5];



int32_t main()

{

    faster;

    int n, p, q;

    cin >> n >> p >> q;

    int x, y;

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

        cin >> x >> y;

        v[x].pb(y);

    }

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

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

    }



    while(q--){

        cin >> x >> y;

        int ans = 0;

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

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

        }

        cout << ans << "\n";

    }

    return 0;

}


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

#include <cstring>

#include <algorithm>

void Unused(...) {}

#ifndef DEBUG

  #define echo(...) Unused(__VA_ARGS__)

#else

  #define echo(...) fprintf(stderr, __VA_ARGS__)

#endif



const int MaxN = 500 + 7;

const int MaxM = int(3e5) + 7;



struct Inv

{

    int l, r;

    int idx;

    friend bool operator<(const Inv &a, const Inv &b)

    {

        return a.l == b.l ? a.idx < b.idx : a.l > b.l;

    }

};

Inv rd[MaxM];



int n, m, q;

int ans[MaxM];



int vol[MaxN];

int lowbit(int x) { return x & (-x); }



int query(int v)

{

    int res = 0;

    for (; v > 0; v -= lowbit(v))

        res += vol[v];

    return res;

}

void update(int v)

{

    for (; v < MaxN; v += lowbit(v))

        ++vol[v];

}



int main()

{

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

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

        scanf("%d %d", &rd[i].l, &rd[i].r);

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

    {

        scanf("%d %d", &rd[i + m].l, &rd[i + m].r);

        rd[i + m].idx = i;

    }

    std::sort(rd + 1, rd + m + q + 1);



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

    {

        // query

        if (rd[i].idx > 0)

            ans[rd[i].idx] = query(rd[i].r);

        else

            update(rd[i].r);

    }

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

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



    return 0;

}
// Slower C++ solution:


#include<bits/stdc++.h>

#define ll long long

using namespace std;

const int N = 550;



int a[N][N], b[N][N], n, m, Q;



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 = 1; j <= n; ++ j) {

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

		}

	}

	

	while (Q --) {

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

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

	}

	return 0;

}


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

#include<algorithm>

#include<cmath>

#include<vector>

using namespace std;

int n,m,l,r,ans,q;

int a[1000][1000];

int main(){

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

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

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

		a[l][r]++;

	}

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

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

		

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

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

		int ans=0;

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

			ans+=a[j][r];

		}

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

	}

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

#include<cstdio>

#include<algorithm>

using namespace std;

int n,m,q,a,b;

int dp[510][510];

int main() {

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

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

        scanf("%d%d",&a,&b);

        dp[a][b]++;

    }

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

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

            int k=i+j;

            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",&a,&b);

        printf("%d\n",dp[a][b]);

    }

    return 0;

}

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

#include<algorithm>

#include<cmath>

#include<vector>

using namespace std;

int n,m,l,r,ans,q;

int a[1000][1000];

int main(){

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

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

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

		a[l][r]++;

	}

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

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

		

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

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

		int ans=0;

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

			ans+=a[j][r];

		}

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

	}

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

using namespace std;

#define maxn 200008

int n,m,q;

int arr[maxn];

int sum[maxn];

int cha[maxn];

vector<int> v1[maxn];

int main(){

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

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

		int a,b;

		scanf("%d%d",&a,&b);

		v1[a].push_back(b);

	}

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

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

	}

	int ans=0;

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

		int a,b;

		ans=0;

		scanf("%d%d",&a,&b);

		for(int j=a;j<=b;j++){

			ans+=upper_bound(v1[j].begin(),v1[j].end(),b)-v1[j].begin();

		}

		cout<<ans<<endl;

	}

	return 0;

}

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

#include<algorithm>

#include<cmath>

#include<vector>

using namespace std;

int n,m,l,r,ans,q;

int a[1000][1000];

int main(){

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

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

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

		a[l][r]++;

	}

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

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

		

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

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

		int ans=0;

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

			ans+=a[j][r];

		}

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

	}

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

using namespace std;

#define maxn 200008

int n,m,q;

int arr[maxn];

int sum[maxn];

int cha[maxn];

vector<int> v1[maxn];

int main(){

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

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

		int a,b;

		scanf("%d%d",&a,&b);

		v1[a].push_back(b);

	}

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

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

	}

	int ans=0;

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

		int a,b;

		ans=0;

		scanf("%d%d",&a,&b);

		for(int j=a;j<=b;j++){

			ans+=upper_bound(v1[j].begin(),v1[j].end(),b)-v1[j].begin();

		}

		cout<<ans<<endl;

	}

	return 0;

}

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

#include<iostream>

#include<algorithm>

#include<vector>

using namespace std;

int n,m,q,x,y,ans,xx;

vector <int> v[505];

int main(){

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

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

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

                v[y].push_back(x);

        }

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

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

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

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

                        xx=lower_bound(v[i].begin(),v[i].end(),x)-v[i].begin();

                                ans+=v[i].size()-xx;

                    }

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

                ans=0;

        }

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

using namespace std;

#define maxn 200008

int n,m,q;

int arr[maxn];

int sum[maxn];

int cha[maxn];

vector<int> v1[maxn];

int main(){

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

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

		int a,b;

		scanf("%d%d",&a,&b);

		v1[a].push_back(b);

	}

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

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

	}

	int ans=0;

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

		int a,b;

		ans=0;

		scanf("%d%d",&a,&b);

		for(int j=a;j<=b;j++){

			ans+=upper_bound(v1[j].begin(),v1[j].end(),b)-v1[j].begin();

		}

		cout<<ans<<endl;

	}

	return 0;

}

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

using namespace std;

int n,m,q,ans=0,x,y;

vector <int> a[10005];

int main()

{

	cin>>n>>m>>q;

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

	{

		cin>>x>>y;

		a[x].push_back(y);

	}

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

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

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

	{

		ans=0;

		cin>>x>>y;

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

		{

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

		}

		cout<<ans<<endl;

	}

	return 0;

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

using namespace std;

#define maxn 200008

int n,m,q;

int arr[maxn];

int sum[maxn];

int cha[maxn];

vector<int> v1[maxn];

int main(){

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

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

		int a,b;

		scanf("%d%d",&a,&b);

		v1[a].push_back(b);

	}

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

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

	}

	int ans=0;

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

		int a,b;

		ans=0;

		scanf("%d%d",&a,&b);

		for(int j=a;j<=b;j++){

			ans+=upper_bound(v1[j].begin(),v1[j].end(),b)-v1[j].begin();

		}

		cout<<ans<<endl;

	}

	return 0;

}

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

#include <cstdio>

#include <cstring>

#include <cmath>

#include <algorithm>

#include <vector>

using namespace std;

typedef long long LL;

inline LL in()

{

    LL x = 0, flag = 1; char ch = getchar();

    while (ch < '0' || ch > '9') {if (ch == '-') flag = -1; ch = getchar();}

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

    return x * flag;

}

vector <int> vec[600];

int n, m, q;

int main()

{

    n = in(), m = in(), q = in();

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

    {

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

        vec[l].push_back(r);

    }

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

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

    {

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

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

        {

            int pos = upper_bound(vec[j].begin(), vec[j].end(), r) - vec[j].begin();

            ans += pos;

            // cout << pos << endl;

        }

        cout << ans << endl;

    }

    return 0;

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

using namespace std;

int n,m,q,ans=0,x,y;

vector <int> a[10005];

int main()

{

	cin>>n>>m>>q;

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

	{

		cin>>x>>y;

		a[x].push_back(y);

	}

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

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

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

	{

		ans=0;

		cin>>x>>y;

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

		{

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

		}

		cout<<ans<<endl;

	}

	return 0;

}

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

#include <cstdio>

#include <cstring>

#include <cmath>

#include <algorithm>

#include <vector>

using namespace std;

typedef long long LL;

inline LL in()

{

    LL x = 0, flag = 1; char ch = getchar();

    while (ch < '0' || ch > '9') {if (ch == '-') flag = -1; ch = getchar();}

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

    return x * flag;

}

vector <int> vec[600];

int n, m, q;

int main()

{

    n = in(), m = in(), q = in();

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

    {

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

        vec[l].push_back(r);

    }

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

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

    {

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

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

        {

            int pos = upper_bound(vec[j].begin(), vec[j].end(), r) - vec[j].begin();

            ans += pos;

            // cout << pos << endl;

        }

        cout << ans << endl;

    }

    return 0;

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

using namespace std;

#define maxn 200008

int n,m,q;

int arr[maxn];

int sum[maxn];

int cha[maxn];

vector<int> v1[maxn];

int main(){

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

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

		int a,b;

		scanf("%d%d",&a,&b);

		v1[a].push_back(b);

	}

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

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

	}

	int ans=0;

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

		int a,b;

		ans=0;

		scanf("%d%d",&a,&b);

		for(int j=a;j<=b;j++){

			ans+=upper_bound(v1[j].begin(),v1[j].end(),b)-v1[j].begin();

		}

		cout<<ans<<endl;

	}

	return 0;

}

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

#include<cstdio>

#include<algorithm>

using namespace std;

int n,m,q;

int dp[502][502];

int main() {

    int a,b;

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

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

        scanf("%d%d",&a,&b);

        dp[a][b] ++;

    }

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

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

            int k = i + j;

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

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

        }

    }

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

        scanf("%d%d",&a,&b);

        printf("%d\n",dp[a][b]);

    }

    return 0;

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

using namespace std;

int n,m,q,ans=0,x,y;

vector <int> a[10005];

int main()

{

	cin>>n>>m>>q;

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

	{

		cin>>x>>y;

		a[x].push_back(y);

	}

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

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

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

	{

		ans=0;

		cin>>x>>y;

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

		{

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

		}

		cout<<ans<<endl;

	}

	return 0;

}

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

#include<cstdio>

#include<algorithm>

using namespace std;

int n,m,q;

int dp[502][502];

int main() {

    int a,b;

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

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

        scanf("%d%d",&a,&b);

        dp[a][b] ++;

    }

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

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

            int k = i + j;

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

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

        }

    }

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

        scanf("%d%d",&a,&b);

        printf("%d\n",dp[a][b]);

    }

    return 0;

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

using namespace std;

#define maxn 200008

int n,m,q;

int arr[maxn];

int sum[maxn];

int cha[maxn];

vector<int> v1[maxn];

int main(){

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

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

		int a,b;

		scanf("%d%d",&a,&b);

		v1[a].push_back(b);

	}

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

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

	}

	int ans=0;

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

		int a,b;

		ans=0;

		scanf("%d%d",&a,&b);

		for(int j=a;j<=b;j++){

			ans+=upper_bound(v1[j].begin(),v1[j].end(),b)-v1[j].begin();

		}

		cout<<ans<<endl;

	}

	return 0;

}

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

using namespace std;

int info[505][505], raw[200005][2], quest[200005][2], ans[200005];

int main()

{

    int n, m, q;

    cin >> n >> m >> q;

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

    {

        cin >> raw[i][0] >> raw[i][1];

        info[raw[i][0]][raw[i][1]]++;

    }

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

    {

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

        {

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

        }

    }

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

    {

        cin >> quest[i][0] >> quest[i][1];

        for ( int j = quest[i][0]; j <= quest[i][1]; j++ )

        {

            ans[i] = ans[i] + info[j][quest[i][1]] - info[j][quest[i][0]-1];

        }

        cout << ans[i] << endl;

    }

}