Buggy python submission (verdict: Time Limit Exceeded):
def main():
	N, M, Q = map(int, input().split())
	LR = [list(map(int, input().split())) for _ in range(M)]
	PQ = [list(map(int, input().split())) for _ in range(Q)]

	lines = [[0] * (N + 1) for _ in range(N + 1)]

	for l, r in LR:
		lines[l][r] += 1

	for p, q in PQ:
		lines_sum = 0
		for y in range(p, q + 1):
			for x in range(p, q + 1):
				lines_sum += lines[y][x]
		print(lines_sum)
main()


Fixed submission:
N, M, Q = map(int, input().split())
LR = [list(map(int, input().split())) for _ in range(M)]
PQ = [list(map(int, input().split())) for _ in range(Q)]

table = [[0 for _ in range(N + 2)] for _ in range(N + 2)]

for l, r in LR:
	table[l][r] += 1

#for line in table:
#	print(*line)
#print()

for i in range(1, N + 1):
	for j in range(1, N + 1):
		table[i][j] += table[i][j - 1]
for i in range(1, N + 1):
	for j in range(1, N + 1):
		table[i][j] += table[i - 1][j]

#for line in table:
#	print(*line)
#print()

for p, q in PQ:
	#print(table[q][q], table[p - 1][q], table[q][p - 1], table[p - 1][p - 1])
	print(table[q][q] - table[p - 1][q] - table[q][p - 1] + table[p - 1][p - 1])

Buggy python submission (verdict: Time Limit Exceeded):
N, M, Q = map(int, input().split())
LR = [list(map(int, input().split())) for _ in range(M)]
PQ = [list(map(int, input().split())) for _ in range(Q)]

lines = [[0] * N for _ in range(N)]

for l, r in LR:
	l, r = l - 1, r - 1
	lines[l][r] += 1

for p, q in PQ:
	p, q = p - 1, q - 1
	lines_sum = 0
	for y in range(p, q + 1):
		for x in range(p, q + 1):
			lines_sum += lines[y][x]
	print(lines_sum)


Fixed submission:
N, M, Q = map(int, input().split())
LR = [list(map(int, input().split())) for _ in range(M)]
PQ = [list(map(int, input().split())) for _ in range(Q)]

table = [[0 for _ in range(N + 2)] for _ in range(N + 2)]

for l, r in LR:
	table[l][r] += 1

#for line in table:
#	print(*line)
#print()

for i in range(1, N + 1):
	for j in range(1, N + 1):
		table[i][j] += table[i][j - 1]
for i in range(1, N + 1):
	for j in range(1, N + 1):
		table[i][j] += table[i - 1][j]

#for line in table:
#	print(*line)
#print()

for p, q in PQ:
	#print(table[q][q], table[p - 1][q], table[q][p - 1], table[p - 1][p - 1])
	print(table[q][q] - table[p - 1][q] - table[q][p - 1] + table[p - 1][p - 1])

Buggy python submission (verdict: Time Limit Exceeded):
N, M, Q = map(int, input().split())
LR = [list(map(int, input().split())) for _ in range(M)]
PQ = [list(map(int, input().split())) for _ in range(Q)]

from_cities = [[] for _ in range(N)]
for l, r in LR:
	l, r = l - 1, r - 1
	from_cities[l] += [r - l]

#print(from_cities)

for p, q in PQ:
	c, p, q = 0, p - 1, q - 1
	for i in range(p, q + 1):
		for line in from_cities[i]:
			if line <= q - i:
				c += 1
	print(c)



Fixed submission:
N, M, Q = map(int, input().split())
LR = [list(map(int, input().split())) for _ in range(M)]
PQ = [list(map(int, input().split())) for _ in range(Q)]

table = [[0 for _ in range(N + 2)] for _ in range(N + 2)]

for l, r in LR:
	table[l][r] += 1

#for line in table:
#	print(*line)
#print()

for i in range(1, N + 1):
	for j in range(1, N + 1):
		table[i][j] += table[i][j - 1]
for i in range(1, N + 1):
	for j in range(1, N + 1):
		table[i][j] += table[i - 1][j]

#for line in table:
#	print(*line)
#print()

for p, q in PQ:
	#print(table[q][q], table[p - 1][q], table[q][p - 1], table[p - 1][p - 1])
	print(table[q][q] - table[p - 1][q] - table[q][p - 1] + table[p - 1][p - 1])