Problem:
Score: 400 points

Problem Statement

In Takahashi Kingdom, there is a east-west railroad and N cities along it, numbered 1, 2, 3, ..., N from west to east.
A company called AtCoder Express possesses M trains, and the train i runs from City L_i to City R_i (it is possible that L_i = R_i).
Takahashi the king is interested in the following Q matters:

The number of the trains that runs strictly within the section from City p_i to City q_i, that is, the number of trains j such that p_i \leq L_j and R_j \leq q_i.

Although he is genius, this is too much data to process by himself. Find the answer for each of these Q queries to help him.

Constraints

N is an integer between 1 and 500 (inclusive).

M is an integer between 1 and 200 \ 000 (inclusive).

Q is an integer between 1 and 100 \ 000 (inclusive).

1 \leq L_i \leq R_i \leq N (1 \leq i \leq M)

1 \leq p_i \leq q_i \leq N (1 \leq i \leq Q)

Input

Input is given from Standard Input in the following format:

N M Q
L_1 R_1
L_2 R_2
:
L_M R_M
p_1 q_1
p_2 q_2
:
p_Q q_Q

Output

Print Q lines. The i-th line should contain the number of the trains that runs strictly within the section from City p_i to City q_i.

Sample Input 1

2 3 1
1 1
1 2
2 2
1 2

Sample Output 1

3

As all the trains runs within the section from City 1 to City 2, the answer to the only query is 3.

Sample Input 2

10 3 2
1 5
2 8
7 10
1 7
3 10

Sample Output 2

1
1

The first query is on the section from City 1 to 7. There is only one train that runs strictly within that section: Train 1.
The second query is on the section from City 3 to 10. There is only one train that runs strictly within that section: Train 3.

Sample Input 3

10 10 10
1 6
2 9
4 5
4 7
4 7
5 8
6 6
6 7
7 9
10 10
1 8
1 9
1 10
2 8
2 9
2 10
3 8
3 9
3 10
1 10

Sample Output 3

7
9
10
6
8
9
6
7
8
10

Solution in C# (Mono 4.6.2.0) (judge verdict: Accepted)

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using Library;
using static Library.Input;

namespace AtCoderTemplate {
    class ProgramD {
        static void Main () {
            int n = NextInt, m = NextInt, q = NextInt;
            var trains = new int[n + 1, n + 1];

            for (int i = 0; i < m; i++)
            {
                trains[NextInt, NextInt]++;
            }

            for (int i = 0; i <= n; i++)
            {
                for (int j = 1; j <= n; j++)
                {
                    trains[i, j] += trains[i, j - 1];
                }
            }

            for (int j = 0; j <= n; j++)
            {
                for (int i = 1; i <= n; i++)
                {
                    trains[i, j] += trains[i - 1, j];
                }
            }

            System.Console.WriteLine(
                string.Join("\n", TakeLine(q).Select(l => trains[l[1], l[1]] - trains[l[1], l[0] - 1] - trains[l[0] - 1, l[1]] + trains[l[0] - 1, l[0] - 1]))
            );
        }
    }

}

namespace Library {
    class Input {
        static IEnumerator<string> enumerator = new string[] { }.AsEnumerable ().GetEnumerator ();

        public static string Line => Console.ReadLine ();

        public static string[] StrArr => Line.Split (' ');

        public static int NextInt => int.Parse (NextWord ());

        public static long NextLong => long.Parse (NextWord ());

        public static List<int> IntList => StrArr.Select (int.Parse).ToList ();

        public static List<long> LongList => StrArr.Select (long.Parse).ToList ();

        public static IEnumerable<long[]> TakeLine (int N) {
            return Enumerable.Repeat (0, N).Select (_ => Console.ReadLine ().Split (' ').Select (long.Parse).ToArray ());
        }

        public static string NextWord () {
            while (!enumerator.MoveNext ()) {
                enumerator = StrArr.AsEnumerable ().GetEnumerator ();
            }
            return enumerator.Current;
        }
    }
}

namespace Library {
    
    class Modular {
        public const int mod = 1000000007;
        public readonly long value;
        public Modular (long value) { this.value = value; }
        public static implicit operator Modular (long a) {
            var m = a % mod;
            return new Modular ((m < 0) ? m + mod : m);
        }
        public static Modular operator + (Modular a, Modular b) {
            return a.value + b.value;
        }
        public static Modular operator - (Modular a, Modular b) {
            return a.value - b.value;
        }
        public static Modular operator * (Modular a, Modular b) {
            return a.value * b.value;
        }
        public static Modular Pow (Modular a, int n) {
            switch (n) {
                case 0:
                    return 1;
                case 1:
                    return a;
                default:
                    var p = Pow (a, n / 2);
                    return p * p * Pow (a, n % 2);
            }
        }
        public static Modular operator / (Modular a, Modular b) {
            return a * Pow (b, mod - 2);
        }
        private static readonly List<int> facs = new List<int> { 1 };
        private static Modular Fac (int n) {
            for (int i = facs.Count; i <= n; ++i) {
                facs.Add ((int) (Math.BigMul (facs.Last (), i) % mod));
            }
            return facs[n];
        }
        public static Modular Ncr (int n, int r) {
            return (n < r) ? 0 :
                (n == r) ? 1 :
                Fac (n) / (Fac (r) * Fac (n - r));
        }
        public static explicit operator int (Modular a) {
            return (int) a.value;
        }
    }

}
namespace Library {
    class MyMath {
        public static long Gcd (long a, long b) {
            return b == 0 ? a : Gcd (b, a % b);
        }

        public static long Sqrt (long n) {
            if (n < 0) return 0;
            long a = 0, tmp = 0, b = 0;
            for (int i = 62; i >= 0; i -= 2) {
                tmp = (b << 1) + 1 <= (n >> i) ? 1 : 0;
                a = a << 1 | tmp;
                n -= (((b << 1) + 1) * tmp) << i;
                b = (b << 1) + tmp + tmp;
            }
            return a;
        }

        public static long Nck (int n, int k) {
            if (k == 0) return 1;
            if (n == 0) return 0;
            return n * Nck (n - 1, k - 1) / k;
        }
    }
}

namespace Library {
        public class PriorityQueue<T> {

        readonly List<T> _heap = new List<T> ();
        readonly Comparison<T> _comparison;

        public PriorityQueue (Comparison<T> comparison) {
            _comparison = comparison;
        }

        public PriorityQueue () : this (Comparer<T>.Default.Compare) { }

        public PriorityQueue (IComparer<T> comparer) : this (comparer.Compare) { }

        public void Enqueue (T item) {
            _heap.Add (item);

            int childID = _heap.Count - 1;
            int parentID = (childID - 1) / 2;

            while (childID > 0 && _comparison (_heap[parentID], _heap[childID]) > 0) {
                Swap (parentID, childID);
                childID = parentID;
                parentID = (parentID - 1) / 2;
            }
        }

        public T Dequeue () {
            var first = _heap.First ();
            _heap[0] = _heap.Last ();
            _heap.RemoveAt (_heap.Count - 1);

            int parentID = 0;
            int childID = parentID * 2 + 2;
            if (childID >= _heap.Count || _comparison (_heap[childID], _heap[childID - 1]) > 0) childID--;

            while (childID < _heap.Count && _comparison (_heap[parentID], _heap[childID]) > 0) {
                Swap (parentID, childID);
                parentID = childID;
                childID = parentID * 2 + 2;
                if (childID >= _heap.Count || _comparison (_heap[childID], _heap[childID - 1]) > 0) childID--;
            }

            return first;
        }

        void Swap (int parent, int child) {
            var tmp = _heap[parent];
            _heap[parent] = _heap[child];
            _heap[child] = tmp;
        }

        public T Peek () { return _heap[0]; }
        public int Count => _heap.Count;
        public bool Any () { return _heap.Any (); }
        public List<T> Data => _heap;
    }
}

namespace Library {
    
    public class UnionFind {
        public int[] Parents { get; set; }
        public UnionFind (int size) {
            Parents = Enumerable.Repeat (-1, size).ToArray ();
        }

        public int Find (int num) {
            if (Parents[num] < 0) return num;

            Parents[num] = Find (Parents[num]);
            return Parents[num];
        }

        public int Size (int num) {
            return -Parents[Find (num)];
        }

        public bool Same (int a, int b) {
            return Find (a) == Find (b);
        }

        public void Unite (int a, int b) {
            int x = Find (a), y = Find (b);

            if (Size (x) > Size (y)) {
                Parents[x] += Parents[y];
                Parents[y] = x;
            } else {
                Parents[y] += Parents[x];
                Parents[x] = y;
            }
        }
    }
}