Buggy python submission (verdict: Time Limit Exceeded):
a = list(map(int, input().split()))
 
p = [list(map(int, input().split())) for i in range(a[1])]
q = [list(map(int, input().split())) for i in range(a[2])]
 
res = [[0]*a[0] for i in range(a[0])]
 
def lsadd(L,R):
    L-=1
    R-=1
    for i in range(0,L+1):  
        res[i][R] += 1
 
for l,r in p:
    lsadd(l,r)
 
for l,r in q:
    print(sum(res[l-1][:r]))

Fixed submission:
a = list(map(int,input().split()))

c = [[0 for i in range(a[0]+1)] for j in range(a[0]+1)]

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

d = [[0 for i in range(a[0]+4)] for j in range(a[0]+4)]

for i in range(a[0]+1):
    for j in range(a[0]+1):
        d[i][j+1] = d[i][j] + c[i][j]

for i in range(a[2]):
    n,m = map(int,input().split())
    s = 0
    for j in range(n,m+1):
        s += d[j][m+1] - d[j][j]
    print(s)

Buggy python submission (verdict: Runtime Error):
a = list(map(int, input().split()))
 
p = [list(map(int, input().split())) for i in range(M)]
q = [list(map(int, input().split())) for i in range(Q)]
 
res = [[0]*N for i in range(N)]
 
def lsadd(L,R):
    L-=1
    R-=1
    for i in range(0,L+1):  
        res[i][R] += 1
 
for l,r in p:
    lsadd(l,r)
 
for l,r in q:
    print(sum(res[l-1][:r]))


Fixed submission:
a = list(map(int,input().split()))

c = [[0 for i in range(a[0]+1)] for j in range(a[0]+1)]

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

d = [[0 for i in range(a[0]+4)] for j in range(a[0]+4)]

for i in range(a[0]+1):
    for j in range(a[0]+1):
        d[i][j+1] = d[i][j] + c[i][j]

for i in range(a[2]):
    n,m = map(int,input().split())
    s = 0
    for j in range(n,m+1):
        s += d[j][m+1] - d[j][j]
    print(s)

Buggy python submission (verdict: Time Limit Exceeded):
a = list(map(int,input().split()))

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

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

for i in range(a[2]):
    p = 0
    m,n = map(int,input().split())
    for j in range(m-1,n):
        for l in range(j,n):
            p += k[j][l]
    print(p)


Fixed submission:
a = list(map(int,input().split()))

c = [[0 for i in range(a[0]+1)] for j in range(a[0]+1)]

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

d = [[0 for i in range(a[0]+4)] for j in range(a[0]+4)]

for i in range(a[0]+1):
    for j in range(a[0]+1):
        d[i][j+1] = d[i][j] + c[i][j]

for i in range(a[2]):
    n,m = map(int,input().split())
    s = 0
    for j in range(n,m+1):
        s += d[j][m+1] - d[j][j]
    print(s)

Buggy python submission (verdict: Time Limit Exceeded):
a = list(map(int,input().split()))

c = [[0 for i in range(a[0]+1)] for j in range(a[0]+1)]

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

d = [[0 for i in range(a[0]+4)] for j in range(a[0]+4)]

for i in range(a[0]+1):
    for j in range(a[0]+1):
        d[i][j+1] = d[i][j] + c[i][j]

for i in range(a[2]):
    n,m = map(int,input().split())
    s = 0
    for j in range(n,m+1):
        s += d[j][m+1] - d[j][j]
    print(s)

Fixed submission:
a = list(map(int,input().split()))

c = [[0 for i in range(a[0]+1)] for j in range(a[0]+1)]

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

d = [[0 for i in range(a[0]+4)] for j in range(a[0]+4)]

for i in range(a[0]+1):
    for j in range(a[0]+1):
        d[i][j+1] = d[i][j] + c[i][j]

for i in range(a[2]):
    n,m = map(int,input().split())
    s = 0
    for j in range(n,m+1):
        s += d[j][m+1] - d[j][j]
    print(s)

Buggy python submission (verdict: Time Limit Exceeded):
a = list(map(int,input().split()))

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

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

for i in range(a[2]):
    p = 0
    m,n = map(int,input().split())
    for j in range(m-1,n):
        for l in range(j,n):
            p += k[j][l]
    print(p)

Fixed submission:
a = list(map(int,input().split()))

c = [[0 for i in range(a[0]+1)] for j in range(a[0]+1)]

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

d = [[0 for i in range(a[0]+4)] for j in range(a[0]+4)]

for i in range(a[0]+1):
    for j in range(a[0]+1):
        d[i][j+1] = d[i][j] + c[i][j]

for i in range(a[2]):
    n,m = map(int,input().split())
    s = 0
    for j in range(n,m+1):
        s += d[j][m+1] - d[j][j]
    print(s)

Buggy python submission (verdict: Runtime Error):
a = list(map(int,input().split()))

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

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

for i in range(a[2]):
    p = 0
    m,n = map(int,input().split())
    for j in range(m-1,n):
        for l in range(j,n):
            p += k[j][l]
    print(p)

Fixed submission:
a = list(map(int,input().split()))

c = [[0 for i in range(a[0]+1)] for j in range(a[0]+1)]

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

d = [[0 for i in range(a[0]+4)] for j in range(a[0]+4)]

for i in range(a[0]+1):
    for j in range(a[0]+1):
        d[i][j+1] = d[i][j] + c[i][j]

for i in range(a[2]):
    n,m = map(int,input().split())
    s = 0
    for j in range(n,m+1):
        s += d[j][m+1] - d[j][j]
    print(s)

Buggy python submission (verdict: Runtime Error):
a = list(map(int,input().split()))

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

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

for i in range(a[2]):
    p = 0
    for j in range(m):
        for k in range(n):
            p += k[m][n]
    print(p)

Fixed submission:
a = list(map(int,input().split()))

c = [[0 for i in range(a[0]+1)] for j in range(a[0]+1)]

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

d = [[0 for i in range(a[0]+4)] for j in range(a[0]+4)]

for i in range(a[0]+1):
    for j in range(a[0]+1):
        d[i][j+1] = d[i][j] + c[i][j]

for i in range(a[2]):
    n,m = map(int,input().split())
    s = 0
    for j in range(n,m+1):
        s += d[j][m+1] - d[j][j]
    print(s)

Buggy python submission (verdict: Time Limit Exceeded):
a = list(map(int,input().split()))
 
b = [[] for i in range(a[0])]
 
c = [0 for i in range(a[2])]
 
co = 0
for i in range(a[1]):
    n,m = map(int,input().split())
 
    b[m-1].append(n)
  
for i in range(len(b)):
    b[i].sort()
    
for i in range(a[2]):
    n,m = map(int,input().split())
    for j in range(n-1,m):
        for k in range(len(b[j])):
            if b[j][k] >= n:
                co += 1
    print(co)
    co = 0

Fixed submission:
a = list(map(int,input().split()))

c = [[0 for i in range(a[0]+1)] for j in range(a[0]+1)]

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

d = [[0 for i in range(a[0]+4)] for j in range(a[0]+4)]

for i in range(a[0]+1):
    for j in range(a[0]+1):
        d[i][j+1] = d[i][j] + c[i][j]

for i in range(a[2]):
    n,m = map(int,input().split())
    s = 0
    for j in range(n,m+1):
        s += d[j][m+1] - d[j][j]
    print(s)

Buggy python submission (verdict: Time Limit Exceeded):
a = list(map(int,input().split()))

b = [[] for i in range(a[0])]

c = [0 for i in range(a[2])]

co = 0
for i in range(a[1]):
    n,m = map(int,input().split())

    b[m-1].append(n)
    
for i in range(a[2]):
    n,m = map(int,input().split())
    for j in range(n-1,m):
        for k in range(len(b[j])):
            if b[j][k] >= n:
                co += 1
    print(co)
    co = 0

Fixed submission:
a = list(map(int,input().split()))

c = [[0 for i in range(a[0]+1)] for j in range(a[0]+1)]

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

d = [[0 for i in range(a[0]+4)] for j in range(a[0]+4)]

for i in range(a[0]+1):
    for j in range(a[0]+1):
        d[i][j+1] = d[i][j] + c[i][j]

for i in range(a[2]):
    n,m = map(int,input().split())
    s = 0
    for j in range(n,m+1):
        s += d[j][m+1] - d[j][j]
    print(s)