Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter


def bin(ll, target, key):  # リストにtargetが最初に含まれる位置
    if len(ll) < 100:
        if target in [key(a) for a in ll]:
            return [key(a) for a in ll].index(target)
        return -1

    length = len(ll)
    l, r = ll[:length // 2], ll[length // 2:]
    if key(r[0]) == target:
        if key(l[-1]) != target:
            return len(l)
        return bin(l, target, key)
    elif key(r[0]) > target:
        return bin(l, target, key)
    else:
        return len(l) + bin(r, target, key)


def main():
    n, m, q = [int(a) for a in input().split()]
    QQQ = q
    LRi = sorted([[int(a) for a in input().split()] for _ in range(m)], key=lambda it: it[0])

    PQi = [([int(a) for a in input().split()], k) for k in range(q)]
    # PQi = sorted(PQi, key=lambda a: a[0][1])
    # PQi = sorted(PQi, key=lambda a: a[0][0])

    TABLE = []  # iから始まる列車のRとその数
    ii = 0
    for i in range(1, n + 1):
        a = []  # iから伸びる列車の右端
        while True:
            if ii >= len(LRi):
                break
            l, r = LRi[ii]
            if l == i:
                a.append(r)
                ii += 1
            else:
                break
        # a = sorted(a)
        c = Counter(a)

        TABLE.append([(a, c[a]) for a in sorted(c.keys())])

    TABLE2 = []  # iから始まってjまでで終わる電車TABLE[i,j]
    for i in range(1, 1 + n):
        trains = TABLE[i - 1]  # iから始まる電車
        c = 0
        res = []  # jまでで終わる電車の数
        ccc = 0
        for j in range(1, n + 1):
            while True:
                if c >= len(trains):
                    break
                dst, num = trains[c]
                if dst <= j:
                    ccc += num
                    c += 1
                else:
                    break
            res.append(ccc)
        TABLE2.append(res)

    for (p, q), k in PQi:
        c = 0
        for i in range(p, q + 1):
            c += TABLE2[i - 1][q-1]
        print(c)

    # ii = 0
    # res = {}
    # while True:
    #     if ii >= len(PQi):
    #         break
    #
    #     (l, r), k = PQi[ii]# pqに対して、その範囲内のカウンタ全部取得
    #     counts = []
    #     for i in range(l, r + 1):
    #         count = TABLE[i - 1]  # タプル kまでの数v
    #         for rrrr, nnnnn in count:
    #             if rrrr <= r:
    #                 counts.append((rrrr, nnnnn))
    #             else:
    #                 break
    #     lls = [(r, k)]  # 同じlから始まるQ
    #     ii += 1
    #     while True:
    #         if ii >= len(PQi):
    #             break
    #         (ll, rr), kk = PQi[ii]
    #         if ll == r:
    #             lls.append((rr, kk))
    #             ii += 1
    #         else:
    #             break
    #
    #     lls = sorted(lls, key=lambda a: a[0])
    #     b = 0
    #     c = 0
    #     for r, k in lls:
    #         while True:
    #             if c >= len(counts):
    #                 break
    #             kk, v = counts[c]
    #             if kk <= r:
    #                 b += v
    #                 c += 1
    #             else:
    #                 break
    #         res[k] = b
    # for i in range(QQQ):
    #     print(res[i])


if __name__ == '__main__':
    main()


Fixed submission:
from collections import Counter


def bin(ll, target, key):  # リストにtargetが最初に含まれる位置
    if len(ll) < 100:
        if target in [key(a) for a in ll]:
            return [key(a) for a in ll].index(target)
        return -1

    length = len(ll)
    l, r = ll[:length // 2], ll[length // 2:]
    if key(r[0]) == target:
        if key(l[-1]) != target:
            return len(l)
        return bin(l, target, key)
    elif key(r[0]) > target:
        return bin(l, target, key)
    else:
        return len(l) + bin(r, target, key)


def main():
    n, m, q = [int(a) for a in input().split()]
    QQQ = q
    LRi = sorted([[int(a) for a in input().split()] for _ in range(m)], key=lambda it: it[0])

    PQi = [([int(a) for a in input().split()], k) for k in range(q)]
    # PQi = sorted(PQi, key=lambda a: a[0][1])
    # PQi = sorted(PQi, key=lambda a: a[0][0])

    table1 = [  # l2rの電車の個数
        [0] * n
        for _ in range(n)
    ]

    for l, r in LRi:
        table1[l - 1][r - 1] += 1

    table2 = [  # l2rの電車の個数のlに関しての累積和(iから始まってjより手前で終わる)
        [0] * n
        for _ in range(n)
    ]
    for i in range(n):
        c = 0
        for j in range(i, n):
            c += table1[i][j]
            table2[i][j] = c

    table3 = [  # 2次元累積和(iよりあとから始まってjより手前で終わる)
        [0] * n
        for _ in range(n)
    ]
    for j in range(n):
        c = 0
        for i in reversed(range(0, j + 1)):
            c += table2[i][j]
            table3[i][j] = c

    for (p, q), k in PQi:
        print(table3[p - 1][q - 1])
    return


    # TABLE = []  # iから始まる列車のRとその数
    # ii = 0
    # for i in range(1, n + 1):
    #     a = []  # iから伸びる列車の右端
    #     while True:
    #         if ii >= len(LRi):
    #             break
    #         l, r = LRi[ii]
    #         if l == i:
    #             a.append(r)
    #             ii += 1
    #         else:
    #             break
    #     # a = sorted(a)
    #     c = Counter(a)
    # 
    #     TABLE.append([(a, c[a]) for a in sorted(c.keys())])
    # 
    # TABLE2 = []  # iから始まってjまでで終わる電車TABLE[i,j]
    # for i in range(1, 1 + n):
    #     trains = TABLE[i - 1]  # iから始まる電車
    #     c = 0
    #     res = []  # jまでで終わる電車の数
    #     ccc = 0
    #     for j in range(1, n + 1):
    #         while True:
    #             if c >= len(trains):
    #                 break
    #             dst, num = trains[c]
    #             if dst <= j:
    #                 ccc += num
    #                 c += 1
    #             else:
    #                 break
    #         res.append(ccc)
    #     TABLE2.append(res)
    # 
    # for (p, q), k in PQi:
    #     c = 0
    #     for i in range(p, q + 1):
    #         c += TABLE2[i - 1][q - 1]
    #     print(c)

    # ii = 0
    # res = {}
    # while True:
    #     if ii >= len(PQi):
    #         break
    #
    #     (l, r), k = PQi[ii]# pqに対して、その範囲内のカウンタ全部取得
    #     counts = []
    #     for i in range(l, r + 1):
    #         count = TABLE[i - 1]  # タプル kまでの数v
    #         for rrrr, nnnnn in count:
    #             if rrrr <= r:
    #                 counts.append((rrrr, nnnnn))
    #             else:
    #                 break
    #     lls = [(r, k)]  # 同じlから始まるQ
    #     ii += 1
    #     while True:
    #         if ii >= len(PQi):
    #             break
    #         (ll, rr), kk = PQi[ii]
    #         if ll == r:
    #             lls.append((rr, kk))
    #             ii += 1
    #         else:
    #             break
    #
    #     lls = sorted(lls, key=lambda a: a[0])
    #     b = 0
    #     c = 0
    #     for r, k in lls:
    #         while True:
    #             if c >= len(counts):
    #                 break
    #             kk, v = counts[c]
    #             if kk <= r:
    #                 b += v
    #                 c += 1
    #             else:
    #                 break
    #         res[k] = b
    # for i in range(QQQ):
    #     print(res[i])


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter


def bin(ll, target, key):  # リストにtargetが最初に含まれる位置
    if len(ll) < 100:
        if target in [key(a) for a in ll]:
            return [key(a) for a in ll].index(target)
        return -1

    length = len(ll)
    l, r = ll[:length // 2], ll[length // 2:]
    if key(r[0]) == target:
        if key(l[-1]) != target:
            return len(l)
        return bin(l, target, key)
    elif key(r[0]) > target:
        return bin(l, target, key)
    else:
        return len(l) + bin(r, target, key)


def main():
    n, m, q = [int(a) for a in input().split()]
    QQQ = q
    LRi = sorted([[int(a) for a in input().split()] for _ in range(m)], key=lambda it: it[0])

    PQi = [([int(a) for a in input().split()], k) for k in range(q)]
    # PQi = sorted(PQi, key=lambda a: a[0][1])
    # PQi = sorted(PQi, key=lambda a: a[0][0])

    TABLE = []  # iから始まる列車のRとその数
    ii = 0
    for i in range(1, n + 1):
        a = []  # iから伸びる列車の右端
        while True:
            if ii >= len(LRi):
                break
            l, r = LRi[ii]
            if l == i:
                a.append(r)
                ii += 1
            else:
                break
        # a = sorted(a)
        c = Counter(a)

        TABLE.append([(a, c[a]) for a in sorted(c.keys())])

    for (p,q),k in PQi:
        r = 0
        for i in range(p,q+1):
            c = TABLE[i-1]
            for dst,num in c:
                if dst<=q:
                    r+=num
                else:
                    break
        print(r)




    # ii = 0
    # res = {}
    # while True:
    #     if ii >= len(PQi):
    #         break
    #
    #     (l, r), k = PQi[ii]# pqに対して、その範囲内のカウンタ全部取得
    #     counts = []
    #     for i in range(l, r + 1):
    #         count = TABLE[i - 1]  # タプル kまでの数v
    #         for rrrr, nnnnn in count:
    #             if rrrr <= r:
    #                 counts.append((rrrr, nnnnn))
    #             else:
    #                 break
    #     lls = [(r, k)]  # 同じlから始まるQ
    #     ii += 1
    #     while True:
    #         if ii >= len(PQi):
    #             break
    #         (ll, rr), kk = PQi[ii]
    #         if ll == r:
    #             lls.append((rr, kk))
    #             ii += 1
    #         else:
    #             break
    #
    #     lls = sorted(lls, key=lambda a: a[0])
    #     b = 0
    #     c = 0
    #     for r, k in lls:
    #         while True:
    #             if c >= len(counts):
    #                 break
    #             kk, v = counts[c]
    #             if kk <= r:
    #                 b += v
    #                 c += 1
    #             else:
    #                 break
    #         res[k] = b
    # for i in range(QQQ):
    #     print(res[i])


if __name__ == '__main__':
    main()


Fixed submission:
from collections import Counter


def bin(ll, target, key):  # リストにtargetが最初に含まれる位置
    if len(ll) < 100:
        if target in [key(a) for a in ll]:
            return [key(a) for a in ll].index(target)
        return -1

    length = len(ll)
    l, r = ll[:length // 2], ll[length // 2:]
    if key(r[0]) == target:
        if key(l[-1]) != target:
            return len(l)
        return bin(l, target, key)
    elif key(r[0]) > target:
        return bin(l, target, key)
    else:
        return len(l) + bin(r, target, key)


def main():
    n, m, q = [int(a) for a in input().split()]
    QQQ = q
    LRi = sorted([[int(a) for a in input().split()] for _ in range(m)], key=lambda it: it[0])

    PQi = [([int(a) for a in input().split()], k) for k in range(q)]
    # PQi = sorted(PQi, key=lambda a: a[0][1])
    # PQi = sorted(PQi, key=lambda a: a[0][0])

    table1 = [  # l2rの電車の個数
        [0] * n
        for _ in range(n)
    ]

    for l, r in LRi:
        table1[l - 1][r - 1] += 1

    table2 = [  # l2rの電車の個数のlに関しての累積和(iから始まってjより手前で終わる)
        [0] * n
        for _ in range(n)
    ]
    for i in range(n):
        c = 0
        for j in range(i, n):
            c += table1[i][j]
            table2[i][j] = c

    table3 = [  # 2次元累積和(iよりあとから始まってjより手前で終わる)
        [0] * n
        for _ in range(n)
    ]
    for j in range(n):
        c = 0
        for i in reversed(range(0, j + 1)):
            c += table2[i][j]
            table3[i][j] = c

    for (p, q), k in PQi:
        print(table3[p - 1][q - 1])
    return


    # TABLE = []  # iから始まる列車のRとその数
    # ii = 0
    # for i in range(1, n + 1):
    #     a = []  # iから伸びる列車の右端
    #     while True:
    #         if ii >= len(LRi):
    #             break
    #         l, r = LRi[ii]
    #         if l == i:
    #             a.append(r)
    #             ii += 1
    #         else:
    #             break
    #     # a = sorted(a)
    #     c = Counter(a)
    # 
    #     TABLE.append([(a, c[a]) for a in sorted(c.keys())])
    # 
    # TABLE2 = []  # iから始まってjまでで終わる電車TABLE[i,j]
    # for i in range(1, 1 + n):
    #     trains = TABLE[i - 1]  # iから始まる電車
    #     c = 0
    #     res = []  # jまでで終わる電車の数
    #     ccc = 0
    #     for j in range(1, n + 1):
    #         while True:
    #             if c >= len(trains):
    #                 break
    #             dst, num = trains[c]
    #             if dst <= j:
    #                 ccc += num
    #                 c += 1
    #             else:
    #                 break
    #         res.append(ccc)
    #     TABLE2.append(res)
    # 
    # for (p, q), k in PQi:
    #     c = 0
    #     for i in range(p, q + 1):
    #         c += TABLE2[i - 1][q - 1]
    #     print(c)

    # ii = 0
    # res = {}
    # while True:
    #     if ii >= len(PQi):
    #         break
    #
    #     (l, r), k = PQi[ii]# pqに対して、その範囲内のカウンタ全部取得
    #     counts = []
    #     for i in range(l, r + 1):
    #         count = TABLE[i - 1]  # タプル kまでの数v
    #         for rrrr, nnnnn in count:
    #             if rrrr <= r:
    #                 counts.append((rrrr, nnnnn))
    #             else:
    #                 break
    #     lls = [(r, k)]  # 同じlから始まるQ
    #     ii += 1
    #     while True:
    #         if ii >= len(PQi):
    #             break
    #         (ll, rr), kk = PQi[ii]
    #         if ll == r:
    #             lls.append((rr, kk))
    #             ii += 1
    #         else:
    #             break
    #
    #     lls = sorted(lls, key=lambda a: a[0])
    #     b = 0
    #     c = 0
    #     for r, k in lls:
    #         while True:
    #             if c >= len(counts):
    #                 break
    #             kk, v = counts[c]
    #             if kk <= r:
    #                 b += v
    #                 c += 1
    #             else:
    #                 break
    #         res[k] = b
    # for i in range(QQQ):
    #     print(res[i])


if __name__ == '__main__':
    main()