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


def LI(): return list(map(int, input().split()))
def LI_(): return list(map(lambda x: int(x) - 1, input().split()))


def cumulative_sum_ref(d1_array):
    for i in range(1, len(d1_array)):
        d1_array[i] += d1_array[i-1]


def cumulative_sum_val(d1_array):
    tmp = d1_array.copy()
    for i in range(1, len(tmp)):
        tmp[i] += tmp[i-1]
    return tmp


# 累積和の計算方法が遅すぎるっぽい。
if __name__ != "__main__":
    N, M, Q = LI()
    LR = np.zeros((N+1, N+1), dtype='uint32')
    for i in range(M):
        l, r = LI()
        LR[l][r] += 1

    # 二次元累積和
    for i in range(1, N+1):
        for j in range(2, N+1):
            LR[i][j] += LR[i][j-1]
    for i in range(1, N+1):
        for j in range(2, N+1):
            LR[j][i] += LR[j-1][i]

    for _ in range(Q):
        p, q = LI()
        p -= 1
        result = LR[q][q] - LR[p][q] - LR[q][p] + LR[p][p]
        print(result)


if __name__ == "__main__":
    N, M, Q = LI()
    LR = np.zeros((N+1, N+1), dtype='uint32')
    for i in range(M):
        l, r = LI()
        LR[l][r] += 1

    # 二次元累積和
    for i in range(1, N+1):
        for j in range(1, N+1):
            LR[i][j] += LR[i][j-1]
            LR[i][j] += LR[i-1][j]
            LR[i][j] -= LR[i-1][j-1]

    for _ in range(Q):
        p, q = LI()
        p -= 1
        result = LR[q][q] - LR[p][q] - LR[q][p] + LR[p][p]
        print(result)


Fixed submission:
def LI(): return list(map(int, input().split()))
def LI_(): return list(map(lambda x: int(x) - 1, input().split()))


if __name__ == "__main__":
    N, M, Q = LI()
    LR = [[0]*(N+1) for _ in range(N+1)]
    for i in range(M):
        l, r = LI()
        LR[l][r] += 1

    # 二次元累積和
    for i in range(1, N+1):
        for j in range(1, N+1):
            LR[i][j] += LR[i][j-1]
            LR[i][j] += LR[i-1][j]
            LR[i][j] -= LR[i-1][j-1]

    for _ in range(Q):
        p, q = LI()
        p -= 1
        result = LR[q][q] - LR[p][q] - LR[q][p] + LR[p][p]
        print(result)

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


def LI(): return list(map(int, input().split()))
def LI_(): return list(map(lambda x: int(x) - 1, input().split()))


def cumulative_sum_ref(d1_array):
    for i in range(1, len(d1_array)):
        d1_array[i] += d1_array[i-1]


def cumulative_sum_val(d1_array):
    tmp = d1_array.copy()
    for i in range(1, len(tmp)):
        tmp[i] += tmp[i-1]
    return tmp


if __name__ == "__main__":
    N, M, Q = LI()
    LR = np.zeros((N+1, N+1), dtype='uint32')
    for i in range(M):
        l, r = LI()
        LR[l][r] += 1
    # LR = np.zeros((N + 1, N + 1), dtype='uint32')
    # LR[2][3] = 1
    # LR[3][5] = 1
    # 二次元累積和
    for i in range(1, N+1):
        for j in range(2, N+1):
            LR[i][j] += LR[i][j-1]
    for i in range(1, N+1):
        for j in range(2, N+1):
            LR[j][i] += LR[j-1][i]

    for _ in range(Q):
        p, q = LI()
        p -= 1
        result = LR[q][q] - LR[p][q] - LR[q][p] + LR[p][p]
        print(result)


Fixed submission:
def LI(): return list(map(int, input().split()))
def LI_(): return list(map(lambda x: int(x) - 1, input().split()))


if __name__ == "__main__":
    N, M, Q = LI()
    LR = [[0]*(N+1) for _ in range(N+1)]
    for i in range(M):
        l, r = LI()
        LR[l][r] += 1

    # 二次元累積和
    for i in range(1, N+1):
        for j in range(1, N+1):
            LR[i][j] += LR[i][j-1]
            LR[i][j] += LR[i-1][j]
            LR[i][j] -= LR[i-1][j-1]

    for _ in range(Q):
        p, q = LI()
        p -= 1
        result = LR[q][q] - LR[p][q] - LR[q][p] + LR[p][p]
        print(result)

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

def LI(): return list(map(int, input().split()))
def LI_(): return list(map(lambda x: int(x) - 1, input().split()))
def LF(): return list(map(float, input().split()))
def LS(): return input().split()
def I(): return int(input())
def F(): return float(input())
def S(): return input()


if __name__ != "__main__":
    N, M, Q = LI()
    LR = np.ndarray((M, 3), dtype='uint32')

    for i in range(M):
        LR[i][0], LR[i][1] = LI()
        LR[i][2] = i

    L = pd.DataFrame(LR).sort_values(0)
    R = pd.DataFrame(LR).sort_values(1)

    for _ in range(Q):
        l = L.copy()


if __name__ != "__main__":
    N, M, Q = LI()
    LR = np.ndarray((M, 4), dtype='uint32')

    for i in range(M):
        LR[i][0], LR[i][1] = LI()

    LR = pd.DataFrame(LR)

    for _ in range(Q):
        p, q = LI()
        LR[2] = p <= LR[0]
        LR[3] = LR[1] <= q
        print(sum(LR[2]*LR[3]))


if __name__ == "__main__":
    N, M, Q = LI()
    LR = np.ndarray((4, M), dtype='uint32')

    for i in range(M):
        LR[0][i], LR[1][i] = LI()

    for _ in range(Q):
        p, q = LI()
        LR[2] = p <= LR[0]
        LR[3] = LR[1] <= q
        print(sum(LR[2]*LR[3]))


Fixed submission:
def LI(): return list(map(int, input().split()))
def LI_(): return list(map(lambda x: int(x) - 1, input().split()))


if __name__ == "__main__":
    N, M, Q = LI()
    LR = [[0]*(N+1) for _ in range(N+1)]
    for i in range(M):
        l, r = LI()
        LR[l][r] += 1

    # 二次元累積和
    for i in range(1, N+1):
        for j in range(1, N+1):
            LR[i][j] += LR[i][j-1]
            LR[i][j] += LR[i-1][j]
            LR[i][j] -= LR[i-1][j-1]

    for _ in range(Q):
        p, q = LI()
        p -= 1
        result = LR[q][q] - LR[p][q] - LR[q][p] + LR[p][p]
        print(result)

Buggy python submission (verdict: Runtime Error):
import math, string, fractions, heapq, re, array, bisect, sys, random, time, copy
import itertools as it
import operator as op
import collections as cl
import functools as ft
import pandas as pd
import numpy as np

def LI(): return list(map(int, input().split()))
def LI_(): return list(map(lambda x: int(x) - 1, input().split()))
def LF(): return list(map(float, input().split()))
def LS(): return input().split()
def I(): return int(input())
def F(): return float(input())
def S(): return input()


if __name__ != "__main__":
    N, M, Q = LI()
    LR = np.ndarray((M, 3), dtype='uint32')

    for i in range(M):
        LR[i][0], LR[i][1] = LI()
        LR[i][2] = i

    L = pd.DataFrame(LR).sort_values(0)
    R = pd.DataFrame(LR).sort_values(1)

    for _ in range(Q):
        l = L.copy()


if __name__ != "__main__":
    N, M, Q = LI()
    LR = np.ndarray((M, 4), dtype='uint32')

    for i in range(M):
        LR[i][0], LR[i][1] = LI()

    LR = pd.DataFrame(LR)

    for _ in range(Q):
        p, q = LI()
        LR[2] = p <= LR[0]
        LR[3] = LR[1] <= q
        print(sum(LR[2]*LR[3]))


if __name__ == "__main__":
    N, M, Q = LI()
    LR = np.ndarray((4, M), dtype='uint32')

    for i in range(M):
        LR[0][i], LR[1][i] = LI()

    for _ in range(Q):
        p, q = LI()
        LR[2] = p <= LR[0]
        LR[3] = LR[1] <= q
        print(sum(LR[2]*LR[3]))


Fixed submission:
def LI(): return list(map(int, input().split()))
def LI_(): return list(map(lambda x: int(x) - 1, input().split()))


if __name__ == "__main__":
    N, M, Q = LI()
    LR = [[0]*(N+1) for _ in range(N+1)]
    for i in range(M):
        l, r = LI()
        LR[l][r] += 1

    # 二次元累積和
    for i in range(1, N+1):
        for j in range(1, N+1):
            LR[i][j] += LR[i][j-1]
            LR[i][j] += LR[i-1][j]
            LR[i][j] -= LR[i-1][j-1]

    for _ in range(Q):
        p, q = LI()
        p -= 1
        result = LR[q][q] - LR[p][q] - LR[q][p] + LR[p][p]
        print(result)

Buggy python submission (verdict: Runtime Error):
import math, string, fractions, heapq, re, array, bisect, sys, random, time, copy
import itertools as it
import operator as op
import collections as cl
import functools as ft
import pandas as pd
import numpy as np

def LI(): return list(map(int, input().split()))
def LI_(): return list(map(lambda x: int(x) - 1, input().split()))
def LF(): return list(map(float, input().split()))
def LS(): return input().split()
def I(): return int(input())
def F(): return float(input())
def S(): return input()


if __name__ != "__main__":
    N, M, Q = LI()
    LR = np.ndarray((M, 3), dtype='uint32')

    for i in range(M):
        LR[i][0], LR[i][1] = LI()
        LR[i][2] = i

    L = pd.DataFrame(LR).sort_values(0)
    R = pd.DataFrame(LR).sort_values(1)

    for _ in range(Q):
        l = L.copy()


if __name__ == "__main__":
    N, M, Q = LI()
    LR = np.ndarray((M, 3), dtype='uint32')

    for i in range(M):
        LR[i][0], LR[i][1] = LI()

    LR = pd.DataFrame(LR)

    for _ in range(Q):
        p, q = LI()
        LR[2] = p <= LR[0]
        LR[3] = LR[1] <= q
        print(sum(LR[2]*LR[3]))


Fixed submission:
def LI(): return list(map(int, input().split()))
def LI_(): return list(map(lambda x: int(x) - 1, input().split()))


if __name__ == "__main__":
    N, M, Q = LI()
    LR = [[0]*(N+1) for _ in range(N+1)]
    for i in range(M):
        l, r = LI()
        LR[l][r] += 1

    # 二次元累積和
    for i in range(1, N+1):
        for j in range(1, N+1):
            LR[i][j] += LR[i][j-1]
            LR[i][j] += LR[i-1][j]
            LR[i][j] -= LR[i-1][j-1]

    for _ in range(Q):
        p, q = LI()
        p -= 1
        result = LR[q][q] - LR[p][q] - LR[q][p] + LR[p][p]
        print(result)