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

a=list()

for i in range(m):
  l,r=map(int,input().split())
  s[l][r] += 1

for i in range(1,n+1):
  for j in range(1,n+1):
    s[i][j] += s[i][j-1] 

for i in range(q):
  l,r=map(int,input().split())
  t = 0
  for j in range(l,r+1):
    t += s[j][r]-s[j][l-1]
  a.append(t)

for i in range(q):
  print(a[i])


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

a=list()

for i in range(m):
  l,r=map(int,input().split())
  s[l][r] += 1

for i in range(1,n+1):
  for j in range(1,n+1):
    s[i][j] += s[i][j-1] 

for i in range(1,n+1):
  for j in range(1,n+1):
    s[j][i] += s[j-1][i]

for i in range(q):
  l,r=map(int,input().split())
  t = s[r][r] - s[l-1][r] - s[r][l-1] + s[l-1][l-1]
  a.append(t)

for i in range(q):
  print(a[i])

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

a=list()

for i in range(m):
  l,r=map(int,input().split())
  t[l][r] += 1

for i in range(1,n+1):
  for j in range(i,n+1):
    for x in range(i,j+1):
      for y in range(i,j+1): 
        s[i][j] += t[x][y]

for i in range(q):
  l,r=map(int,input().split())
  a.append(s[l][r])

for i in range(q):
  print(a[i])


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

a=list()

for i in range(m):
  l,r=map(int,input().split())
  s[l][r] += 1

for i in range(1,n+1):
  for j in range(1,n+1):
    s[i][j] += s[i][j-1] 

for i in range(1,n+1):
  for j in range(1,n+1):
    s[j][i] += s[j-1][i]

for i in range(q):
  l,r=map(int,input().split())
  t = s[r][r] - s[l-1][r] - s[r][l-1] + s[l-1][l-1]
  a.append(t)

for i in range(q):
  print(a[i])

Buggy python submission (verdict: Time Limit Exceeded):
n,m,q=map(int,input().split())
s=[[0 for i in range(n+1)] for j in range(n+1)]
a=list()

for i in range(m):
  l,r=map(int,input().split())
  s[l][r] += 1

for i in range(n+1):
  for j in range(n):
    s[i][j+1] += s[i][j]

for i in range(q):
  l,r=map(int,input().split())
  t = 0
  for j in range(l,r+1):
    t += s[j][r]-s[j][l-1]
  a.append(t)

for i in range(q):
  print(a[i])


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

a=list()

for i in range(m):
  l,r=map(int,input().split())
  s[l][r] += 1

for i in range(1,n+1):
  for j in range(1,n+1):
    s[i][j] += s[i][j-1] 

for i in range(1,n+1):
  for j in range(1,n+1):
    s[j][i] += s[j-1][i]

for i in range(q):
  l,r=map(int,input().split())
  t = s[r][r] - s[l-1][r] - s[r][l-1] + s[l-1][l-1]
  a.append(t)

for i in range(q):
  print(a[i])

Buggy python submission (verdict: Time Limit Exceeded):
import bisect

n,m,q=map(int,input().split())
s=[[] for i in range(n+1)]
a=[]

for i in range(m):
  l,r=map(int,input().split())
  s[l].append(r)

for i in range(n+1):
  s[i].sort()

for i in range(q):
  t=0
  l,r=map(int,input().split())
  for i in range(l,r+1):
    t += bisect.bisect_right(s[i],r)
  a.append(t)

for i in range(q):
  print(a[i])


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

a=list()

for i in range(m):
  l,r=map(int,input().split())
  s[l][r] += 1

for i in range(1,n+1):
  for j in range(1,n+1):
    s[i][j] += s[i][j-1] 

for i in range(1,n+1):
  for j in range(1,n+1):
    s[j][i] += s[j-1][i]

for i in range(q):
  l,r=map(int,input().split())
  t = s[r][r] - s[l-1][r] - s[r][l-1] + s[l-1][l-1]
  a.append(t)

for i in range(q):
  print(a[i])