Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np


def main():
    city_count, express_count, query_count = map(int, input().split())

    city_list = np.zeros((city_count + 1, city_count + 1), np.int_)

    for _ in range(express_count):
        l, r = map(int, input().split())
        city_list[l, r] += 1

    city_list.cumsum(1, out=city_list)

    for _ in range(query_count):
        p, q = map(int, input().split())
        print(city_list[p:q + 1, q].sum())


if __name__ == '__main__':
    main()


Fixed submission:
from array import array
from itertools import accumulate, repeat, starmap
from operator import add, itemgetter


def main():
    city_count, express_count, query_count = map(int, input().split())

    city_list = [array('L', repeat(0, city_count + 1))
                 for _ in range(city_count + 1)]

    for _ in range(express_count):
        l, r = map(int, input().split())
        city_list[l][r] += 1

    for city_index in range(1, city_count + 1):
        city_list[city_index] = array('L', accumulate(city_list[city_index]))

    for city_index in range(2, city_count + 1):
        city_list[city_index] = array('L', starmap(
            add, zip(*(city_list[city_index + i] for i in (-1, 0)))))

    for _ in range(query_count):
        p, q = map(int, input().split())
        print(city_list[q][q] - city_list[p - 1][q])


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np


def main():
    city_count, express_count, query_count = map(int, input().split())

    city_list = np.zeros((city_count + 1, city_count + 1), np.uint32)

    for _ in range(express_count):
        l, r = map(int, input().split())
        city_list[l][r] += 1

    np.cumsum(city_list, 1, out=city_list)

    for _ in range(query_count):
        p, q = map(int, input().split())
        print(city_list[p:q + 1, q].sum())


if __name__ == '__main__':
    main()


Fixed submission:
from array import array
from itertools import accumulate, repeat, starmap
from operator import add, itemgetter


def main():
    city_count, express_count, query_count = map(int, input().split())

    city_list = [array('L', repeat(0, city_count + 1))
                 for _ in range(city_count + 1)]

    for _ in range(express_count):
        l, r = map(int, input().split())
        city_list[l][r] += 1

    for city_index in range(1, city_count + 1):
        city_list[city_index] = array('L', accumulate(city_list[city_index]))

    for city_index in range(2, city_count + 1):
        city_list[city_index] = array('L', starmap(
            add, zip(*(city_list[city_index + i] for i in (-1, 0)))))

    for _ in range(query_count):
        p, q = map(int, input().split())
        print(city_list[q][q] - city_list[p - 1][q])


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
from array import array
from itertools import accumulate, islice, repeat
from operator import itemgetter


def main():
    city_count, express_count, query_count = map(int, input().split())

    city_list = [array('L', repeat(0, city_count + 1))
                 for _ in range(city_count + 1)]

    for _ in range(express_count):
        l, r = map(int, input().split())
        city_list[l][r] += 1

    for city_index in range(1, city_count + 1):
        city_list[city_index] = array('L', accumulate(city_list[city_index]))

    for _ in range(query_count):
        p, q = map(int, input().split())
        print(sum(map(itemgetter(q), islice(city_list, p, q + 1))))


if __name__ == '__main__':
    main()


Fixed submission:
from array import array
from itertools import accumulate, repeat, starmap
from operator import add, itemgetter


def main():
    city_count, express_count, query_count = map(int, input().split())

    city_list = [array('L', repeat(0, city_count + 1))
                 for _ in range(city_count + 1)]

    for _ in range(express_count):
        l, r = map(int, input().split())
        city_list[l][r] += 1

    for city_index in range(1, city_count + 1):
        city_list[city_index] = array('L', accumulate(city_list[city_index]))

    for city_index in range(2, city_count + 1):
        city_list[city_index] = array('L', starmap(
            add, zip(*(city_list[city_index + i] for i in (-1, 0)))))

    for _ in range(query_count):
        p, q = map(int, input().split())
        print(city_list[q][q] - city_list[p - 1][q])


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
from array import array
from itertools import islice, repeat


def main():
    city_count, express_count, query_count = map(int, input().split())

    city_list = [array('L', repeat(0, city_count + 1))
                 for _ in range(city_count + 1)]

    for express_index in range(1, express_count + 1):
        l, r = map(int, input().split())
        city_list[l][r] += 1

    for _ in range(query_count):
        p, q = map(int, input().split())
        answer = 0
        for left_index, right_list in enumerate(islice(city_list, p, q + 1), p):
            answer += sum(islice(right_list, left_index, q + 1))
        print(answer)


if __name__ == '__main__':
    main()


Fixed submission:
from array import array
from itertools import accumulate, repeat, starmap
from operator import add, itemgetter


def main():
    city_count, express_count, query_count = map(int, input().split())

    city_list = [array('L', repeat(0, city_count + 1))
                 for _ in range(city_count + 1)]

    for _ in range(express_count):
        l, r = map(int, input().split())
        city_list[l][r] += 1

    for city_index in range(1, city_count + 1):
        city_list[city_index] = array('L', accumulate(city_list[city_index]))

    for city_index in range(2, city_count + 1):
        city_list[city_index] = array('L', starmap(
            add, zip(*(city_list[city_index + i] for i in (-1, 0)))))

    for _ in range(query_count):
        p, q = map(int, input().split())
        print(city_list[q][q] - city_list[p - 1][q])


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
from itertools import islice


def main():
    city_count, express_count, query_count = map(int, input().split())

    city_list = [[[], []] for _ in range(city_count + 1)]

    for express_index in range(1, express_count + 1):
        l, r = map(int, input().split())
        for city in islice(city_list, 1, l + 1):
            city[0].append(express_index)
        for city in islice(city_list, r, None):
            city[1].append(express_index)

    for city in city_list:
        city[0] = frozenset(city[0])
        city[1] = frozenset(city[1])

    for _ in range(query_count):
        p, q = map(int, input().split())
        city_p = city_list[p][0]
        city_q = city_list[q][1]
        print(len(city_p & city_q))


if __name__ == '__main__':
    main()


Fixed submission:
from array import array
from itertools import accumulate, repeat, starmap
from operator import add, itemgetter


def main():
    city_count, express_count, query_count = map(int, input().split())

    city_list = [array('L', repeat(0, city_count + 1))
                 for _ in range(city_count + 1)]

    for _ in range(express_count):
        l, r = map(int, input().split())
        city_list[l][r] += 1

    for city_index in range(1, city_count + 1):
        city_list[city_index] = array('L', accumulate(city_list[city_index]))

    for city_index in range(2, city_count + 1):
        city_list[city_index] = array('L', starmap(
            add, zip(*(city_list[city_index + i] for i in (-1, 0)))))

    for _ in range(query_count):
        p, q = map(int, input().split())
        print(city_list[q][q] - city_list[p - 1][q])


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
from itertools import islice


def main():
    city_count, express_count, query_count = map(int, input().split())

    city_list = [(set(), set()) for _ in range(city_count + 1)]

    for express_index in range(1, express_count + 1):
        l, r = map(int, input().split())
        for city in islice(city_list, 1, l + 1):
            city[0].add(express_index)
        for city in islice(city_list, r, None):
            city[1].add(express_index)

    for _ in range(query_count):
        p, q = map(int, input().split())
        city_p = city_list[p][0]
        city_q = city_list[q][1]
        print(len(city_p & city_q))


if __name__ == '__main__':
    main()


Fixed submission:
from array import array
from itertools import accumulate, repeat, starmap
from operator import add, itemgetter


def main():
    city_count, express_count, query_count = map(int, input().split())

    city_list = [array('L', repeat(0, city_count + 1))
                 for _ in range(city_count + 1)]

    for _ in range(express_count):
        l, r = map(int, input().split())
        city_list[l][r] += 1

    for city_index in range(1, city_count + 1):
        city_list[city_index] = array('L', accumulate(city_list[city_index]))

    for city_index in range(2, city_count + 1):
        city_list[city_index] = array('L', starmap(
            add, zip(*(city_list[city_index + i] for i in (-1, 0)))))

    for _ in range(query_count):
        p, q = map(int, input().split())
        print(city_list[q][q] - city_list[p - 1][q])


if __name__ == '__main__':
    main()