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

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

Buggy python submission (verdict: Runtime Error):
n,m,q = map(int, input().split())
m_dict = dict()
for i in range(1,m+1):
  m_dict[i] = []
for i in range(m):
  s,e = map(int, input().split())
  m_dict[s].append(e)
for i in range(q):
  s,e = map(int, input().split())
  cnt = 0
  for j in range(s,e+1):
    cnt += len([ k for k in m_dict[j] if k <= e ])
  print(cnt)

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

Buggy python submission (verdict: Runtime Error):
n,m,q = map(int, input().split())
m_dict = dict()
for i in range(1,m+1):
  m_dict[i] = []
for i in range(m):
  s,e = map(int, input().split())
  m_dict[s].append(e)
for i in range(q):
  s,e = map(int, input().split())
  cnt = 0
  for j in m_dict.keys():
    if len(m_dict[j]) == 0: continue
    elif j < s: continue  
    elif e < j: break  
    else: cnt += len([ k for k in m_dict[j] if k <= e ])
  print(cnt)

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

Buggy python submission (verdict: Time Limit Exceeded):
n,m,q = map(int, input().split())
m_start = []
m_end = []
for i in range(m):
  s,e = map(int, input().split())
  m_start .append(s)
  m_end.append(e)
for i in range(q):
  s,e = map(int, input().split())
  cnt = 0
  for j in range(m):
    if m_start[j] < s : continue
    if m_end[j] <= e : cnt += 1
  else:
    print(cnt)

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

Buggy python submission (verdict: Time Limit Exceeded):
n,m,q = map(int, input().split())
m_start = []
m_end = []
for i in range(m):
  s,e = map(int, input().split())
  m_start .append(s)
  m_end.append(e)
for i in range(q):
  s,e = map(int, input().split())
  cnt = 0
  for j in range(m):
    if m_start[j] >= s and m_end[j] <= e : cnt += 1
  else:
    print(cnt)

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