Buggy python submission (verdict: Runtime Error):
N, M , Q = map(int, input().split())

LR = [[0 for _ in range(N+2-i)] for _ in range(N+2)]
for i in range(M):
  L, R = map(int, input().split())
  LR[L][R-L+1] += 1

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


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

LR = [[0]*(N+2-i) for i in range(N+2)]
for i in range(M):
  L, R = map(int, input().split())
  LR[L][R-L+1] += 1

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

Buggy python submission (verdict: Runtime Error):
N, M , Q = map(int, input().split())

LR = [[0 for _ in range(N+2-i) for _ in range(N+2)]
for i in range(M):
  L, R = map(int, input().split())
  LR[L][R-L+1] += 1

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


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

LR = [[0]*(N+2-i) for i in range(N+2)]
for i in range(M):
  L, R = map(int, input().split())
  LR[L][R-L+1] += 1

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

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

LR = np.array([np.zeros(N+2-i, dtype=np.int) for i in range(N+2)])
for i in range(M):
  L, R = map(int, input().split())
  LR[L][R-L+1] += 1

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


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

LR = [[0]*(N+2-i) for i in range(N+2)]
for i in range(M):
  L, R = map(int, input().split())
  LR[L][R-L+1] += 1

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

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

LR = [[0]*(N+1-i) for i in range(N+1)]
for i in range(M):
  L, R = map(int, input().split())
  for l in range(L):
    for j in range(R-l, N-l+1):
      LR[l][j] += 1

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


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

LR = [[0]*(N+2-i) for i in range(N+2)]
for i in range(M):
  L, R = map(int, input().split())
  LR[L][R-L+1] += 1

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

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

LR = [[0]*(N-i) for i in range(N)]
for i in range(M):
  L, R = map(int, input().split())
  for j in range(R-L, N-L+1):
    LR[L-1][j] += 1

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


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

LR = [[0]*(N+2-i) for i in range(N+2)]
for i in range(M):
  L, R = map(int, input().split())
  LR[L][R-L+1] += 1

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

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

LR = defaultdict(lambda: defaultdict(int))
for i in range(M):
  L, R = map(int, input().split())
  LR[L][R] += 1

for i in range(Q):
  p, q = map(int, input().split())
  S = 0
  for l,R in LR.items():
    if not p <= l <= q: continue
    for r,s in R.items():
      if q < r: continue
      S += s
  print(S)

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

LR = [[0]*(N+2-i) for i in range(N+2)]
for i in range(M):
  L, R = map(int, input().split())
  LR[L][R-L+1] += 1

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

Buggy python submission (verdict: Runtime Error):
10 10 10
1 6
2 9
4 5
4 7
4 7
5 8
6 6
6 7
7 9
10 10
1 8
1 9
1 10
2 8
2 9
2 10
3 8
3 9
3 10
1 10

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

LR = [[0]*(N+2-i) for i in range(N+2)]
for i in range(M):
  L, R = map(int, input().split())
  LR[L][R-L+1] += 1

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

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

LR = {}
for i in range(M):
  L, R = map(int, input().split())
  if L in LR:
    LR[L].append(R)
  else:
    LR[L] = [R]

for r in LR.values():
  r.sort()

for i in range(Q):
  p, q = map(int, input().split())
  s = 0
  for l,r in LR.items():
    if not p <= l <= q: continue
    for j in r:
      if q < j: break
      s += 1
  print(s)

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

LR = [[0]*(N+2-i) for i in range(N+2)]
for i in range(M):
  L, R = map(int, input().split())
  LR[L][R-L+1] += 1

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

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

LR = {}
for i in range(M):
  L, R = map(int, input().split())
  if L in LR:
    LR[L].append(R)
  else:
    LR[L] = [R]

for r in LR.values():
  r.sort()

for i in range(Q):
  p, q = map(int, input().split())
  s = 0
  for i in range(p,q+1):
    if i not in LR: continue
    for j in LR[i]:
      if q < j: break
      s += 1
  print(s)

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

LR = [[0]*(N+2-i) for i in range(N+2)]
for i in range(M):
  L, R = map(int, input().split())
  LR[L][R-L+1] += 1

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