Buggy python submission (verdict: Time Limit Exceeded):
n,m,q = map(int,input().split())
query = [[0 for j in range(501)] for i in range(501)]
for h in range(m):
    k,l = map(int,input().split())
    query[k][l] += 1

def search(l,r):
    ans = 0
    for i in range(l,r+1):
        for j in range(l,r+1):
            ans += query[i][j]
    return ans

for h in range(q):
    k,l = map(int,input().split())
    print(search(k,l))

Fixed submission:
n,m,q = map(int,input().split())
query = [[0 for j in range(501)] for i in range(501)]

for h in range(m):
    k,l = map(int,input().split())
    query[k][l] += 1

#リストを累積和にする
for i in range(501):
    for j in range(501):
        if j == 0:
            continue
        query[i][j] = query[i][j] + query[i][j-1]
for i in range(501):
    for j in range(501):
        if j == 0:
            continue
        query[i][j] = query[i][j] + query[i-1][j]
        

for h in range(q):
    k,l = map(int,input().split())
    A,B,C = 0,0,0
    if k > 1:
        A = query[k-1][l]
        B = query[l][k-1]
        C = query[k-1][k-1]
    print(query[l][l] - A - B + C)

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
n,m,q = map(int,input().split())
list_lr = [list(map(int,input().split())) for i in range(m)]
list_pq = [list(map(int,input().split())) for i in range(q)]

query = np.zeros((501,501),dtype=int)

for k,l in list_lr:
    query[k][l] += 1

def search(l,r):
    ans = 0
    for i in range(l,r+1):
        for j in range(l,r+1):
            ans += query[i][j]
    return ans

for k,m in list_pq:
    print(search(k,m))

Fixed submission:
n,m,q = map(int,input().split())
query = [[0 for j in range(501)] for i in range(501)]

for h in range(m):
    k,l = map(int,input().split())
    query[k][l] += 1

#リストを累積和にする
for i in range(501):
    for j in range(501):
        if j == 0:
            continue
        query[i][j] = query[i][j] + query[i][j-1]
for i in range(501):
    for j in range(501):
        if j == 0:
            continue
        query[i][j] = query[i][j] + query[i-1][j]
        

for h in range(q):
    k,l = map(int,input().split())
    A,B,C = 0,0,0
    if k > 1:
        A = query[k-1][l]
        B = query[l][k-1]
        C = query[k-1][k-1]
    print(query[l][l] - A - B + C)

Buggy python submission (verdict: Runtime Error):
import numpy as np
n,m,q = map(int,input().split())
list_lr = [list(map(int,input().split())) for i in range(m)]
list_pq = [list(map(int,input().split())) for i in range(q)]

query = np.zeros((500,500),dtype=int)

for k,l in list_lr:
    query[k][l] += 1

def search(l,r):
    ans = 0
    for i in range(l,r+1):
        for j in range(l,r+1):
            ans += query[i][j]
    return ans

for k,m in list_pq:
    print(search(k,m))

Fixed submission:
n,m,q = map(int,input().split())
query = [[0 for j in range(501)] for i in range(501)]

for h in range(m):
    k,l = map(int,input().split())
    query[k][l] += 1

#リストを累積和にする
for i in range(501):
    for j in range(501):
        if j == 0:
            continue
        query[i][j] = query[i][j] + query[i][j-1]
for i in range(501):
    for j in range(501):
        if j == 0:
            continue
        query[i][j] = query[i][j] + query[i-1][j]
        

for h in range(q):
    k,l = map(int,input().split())
    A,B,C = 0,0,0
    if k > 1:
        A = query[k-1][l]
        B = query[l][k-1]
        C = query[k-1][k-1]
    print(query[l][l] - A - B + C)