Buggy python submission (verdict: Time Limit Exceeded):
N, M, Q = map(int, input().split())

a = [[0 for i in range(509)] for j in range(509)]
sum = [[0 for i in range(509)] for j in range(509)]
ans = [[0 for i in range(509)] for j in range(509)]

for i in range(M):
  p, q = map(int, input().split())
  a[p][q] += 1

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

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

for i in range(Q):
  p, q = map(int, input().split())
  #ans = 0
  #for j in range(p,q+1):
  #  ans += sum[j][q] - sum[j][p-1]
  print(ans[p][q])


Fixed submission:
N, M, Q = map(int, input().split())

a = [[0 for i in range(509)] for j in range(509)]
sum = [[0 for i in range(509)] for j in range(509)]
ans = [[0 for i in range(509)] for j in range(509)]

for i in range(M):
  p, q = map(int, input().split())
  a[p][q] += 1

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

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

for i in range(Q):
  p, q = map(int, input().split())
  #ans = 0
  #for j in range(p,q+1):
  #  ans += sum[j][q] - sum[j][p-1]
  print(ans[p][q])

Buggy python submission (verdict: Time Limit Exceeded):
N, M, Q = map(int, input().split())

a = [[0 for i in range(509)] for j in range(509)]
sum = [[0 for i in range(509)] for j in range(509)]

for i in range(M):
  p, q = map(int, input().split())
  a[p][q] += 1

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

for i in range(Q):
  p, q = map(int, input().split())
  ans = 0
  for j in range(p,q+1):
    ans += sum[j][q] - sum[j][p-1]
  print(ans)


Fixed submission:
N, M, Q = map(int, input().split())

a = [[0 for i in range(509)] for j in range(509)]
sum = [[0 for i in range(509)] for j in range(509)]
ans = [[0 for i in range(509)] for j in range(509)]

for i in range(M):
  p, q = map(int, input().split())
  a[p][q] += 1

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

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

for i in range(Q):
  p, q = map(int, input().split())
  #ans = 0
  #for j in range(p,q+1):
  #  ans += sum[j][q] - sum[j][p-1]
  print(ans[p][q])

Buggy python submission (verdict: Time Limit Exceeded):
N, M, Q = map(int, input().split())

a = [[0 for i in range(509)] for j in range(509)]
sum = [[0 for i in range(509)] for j in range(509)]

for i in range(M):
  p, q = map(int, input().split())
  a[p][q] += 1

for i in range(1,501):
  for j in range(i,501):
    sum[i][j] = sum[i][j-1] + a[i][j]

for i in range(Q):
  p, q = map(int, input().split())
  ans = 0
  for j in range(p,q+1):
    ans += sum[j][q] - sum[j][p-1]
  print(ans)


Fixed submission:
N, M, Q = map(int, input().split())

a = [[0 for i in range(509)] for j in range(509)]
sum = [[0 for i in range(509)] for j in range(509)]
ans = [[0 for i in range(509)] for j in range(509)]

for i in range(M):
  p, q = map(int, input().split())
  a[p][q] += 1

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

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

for i in range(Q):
  p, q = map(int, input().split())
  #ans = 0
  #for j in range(p,q+1):
  #  ans += sum[j][q] - sum[j][p-1]
  print(ans[p][q])

Buggy python submission (verdict: Time Limit Exceeded):
N, M, Q = map(int, input().split())

trains = []
for train in range(M):
  trains.append(list(map(int, input().split())))

cities = []
for city in range(Q):
  cities.append(list(map(int, input().split())))

a = [[0 for i in range(509)] for j in range(509)]
sum = [[0 for i in range(509)] for j in range(509)]

for t in trains:
  L = t[0]
  R = t[1]
  a[L][R] += 1

for i in range(1,501):
  for j in range(1,501):
    sum[i][j] = sum[i][j-1] + a[i][j]

for c in cities:
  p = c[0]
  q = c[1]
  ans = 0
  for i in range(p,q+1):
    ans += sum[i][q] - sum[i][p-1]
  print(ans)


Fixed submission:
N, M, Q = map(int, input().split())

a = [[0 for i in range(509)] for j in range(509)]
sum = [[0 for i in range(509)] for j in range(509)]
ans = [[0 for i in range(509)] for j in range(509)]

for i in range(M):
  p, q = map(int, input().split())
  a[p][q] += 1

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

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

for i in range(Q):
  p, q = map(int, input().split())
  #ans = 0
  #for j in range(p,q+1):
  #  ans += sum[j][q] - sum[j][p-1]
  print(ans[p][q])