Buggy python submission (verdict: Time Limit Exceeded):
n,m,q=map(int,input().split())
counts=[[0 for _ in range(n)] for _ in range(n)]
for _ in range(m):
    l,r=map(int,input().split())
    counts[l-1][r-1]+=1
cumsum=[[0 for _ in range(n+1)] for _ in range(n)]
for i in range(n):
    for j in range(n):
        cumsum[i][j+1]=cumsum[i][j]+counts[i][j]
    
for _ in range(q):
    l,r=map(int,input().split())
    print(sum(cumsum[i][r]-cumsum[i][l-1] for i in range(l-1,r)))


Fixed submission:
n,m,q=map(int,input().split())
counts=[[0 for _ in range(n)] for _ in range(n)]
for _ in range(m):
    l,r=map(int,input().split())
    counts[l-1][r-1]+=1
cumsum=[[0 for _ in range(n+1)] for _ in range(n+1)]
for i in range(n):
    for j in range(n):
        cumsum[i+1][j+1]=cumsum[i+1][j]+counts[i][j]
for j in range(n+1):
    for i in range(n):
        cumsum[i+1][j]+=cumsum[i][j]
        
for _ in range(q):
    l,r=map(int,input().split())
    print(cumsum[r][r]-cumsum[r][l-1]-cumsum[l-1][r]+cumsum[l-1][l-1])

Buggy python submission (verdict: Time Limit Exceeded):

n,m,q=map(int,input().split())
counts=[[0 for _ in range(n)] for _ in range(n)]
for _ in range(m):
    l,r=map(int,input().split())
    counts[l-1][r-1]+=1
cumsum=[[0 for _ in range(n+1)] for _ in range(n)]
for i in range(n):
    for j in range(n):
        cumsum[i][j+1]=cumsum[i][j]+counts[i][j]
    
for _ in range(q):
    l,r=map(int,input().split())
    print(sum(cumsum[i][r]-cumsum[i][l-1] for i in range(l-1,r)))

Fixed submission:
n,m,q=map(int,input().split())
counts=[[0 for _ in range(n)] for _ in range(n)]
for _ in range(m):
    l,r=map(int,input().split())
    counts[l-1][r-1]+=1
cumsum=[[0 for _ in range(n+1)] for _ in range(n+1)]
for i in range(n):
    for j in range(n):
        cumsum[i+1][j+1]=cumsum[i+1][j]+counts[i][j]
for j in range(n+1):
    for i in range(n):
        cumsum[i+1][j]+=cumsum[i][j]
        
for _ in range(q):
    l,r=map(int,input().split())
    print(cumsum[r][r]-cumsum[r][l-1]-cumsum[l-1][r]+cumsum[l-1][l-1])

Buggy python submission (verdict: Time Limit Exceeded):

n,m,q=map(int,input().split())
counts=[[0 for _ in range(n)] for _ in range(n)]
for _ in range(m):
    l,r=map(int,input().split())
    counts[l-1][r-1]+=1
cumsum=[[0 for _ in range(n+1)] for _ in range(n)]
for i in range(n):
    for j in range(n):
        cumsum[i][j+1]=cumsum[i][j]+counts[i][j]
    
for _ in range(q):
    l,r=map(int,input().split())
    print(sum(cumsum[i][r]-cumsum[i][l-1] for i in range(l-1,r)))

Fixed submission:
n,m,q=map(int,input().split())
counts=[[0 for _ in range(n)] for _ in range(n)]
for _ in range(m):
    l,r=map(int,input().split())
    counts[l-1][r-1]+=1
cumsum=[[0 for _ in range(n+1)] for _ in range(n+1)]
for i in range(n):
    for j in range(n):
        cumsum[i+1][j+1]=cumsum[i+1][j]+counts[i][j]
for j in range(n+1):
    for i in range(n):
        cumsum[i+1][j]+=cumsum[i][j]
        
for _ in range(q):
    l,r=map(int,input().split())
    print(cumsum[r][r]-cumsum[r][l-1]-cumsum[l-1][r]+cumsum[l-1][l-1])

Buggy python submission (verdict: Runtime Error):
n,m,q=map(int,input().split())
counts=[[0 for _ in range(n)] for _ in range(n)]
for _ in range(m):
    l,r=map(int,input().split())
    counts[l-1][r-1]+=1
cumsum=[[0 for _ in range(n+1)] for _ in range(n)]
for i in range(m):
    for j in range(m):
        cumsum[i][j+1]=cumsum[i][j]+counts[i][j]
    
for _ in range(q):
    l,r=map(int,input().split())
    print(sum(cumsum[i][r]-cumsum[i][l-1] for i in range(l-1,r)))

Fixed submission:
n,m,q=map(int,input().split())
counts=[[0 for _ in range(n)] for _ in range(n)]
for _ in range(m):
    l,r=map(int,input().split())
    counts[l-1][r-1]+=1
cumsum=[[0 for _ in range(n+1)] for _ in range(n+1)]
for i in range(n):
    for j in range(n):
        cumsum[i+1][j+1]=cumsum[i+1][j]+counts[i][j]
for j in range(n+1):
    for i in range(n):
        cumsum[i+1][j]+=cumsum[i][j]
        
for _ in range(q):
    l,r=map(int,input().split())
    print(cumsum[r][r]-cumsum[r][l-1]-cumsum[l-1][r]+cumsum[l-1][l-1])

Buggy python submission (verdict: Time Limit Exceeded):
n,m,q=map(int,input().split())
counts=[[0 for _ in range(n)]for _ in range(n)]

for _ in range(m):
    l,r=map(int,input().split())
    for i in range(l):
        for j in range(r-1,n):
            counts[i][j]+=1
for _ in range(q):
    l,r=map(int,input().split())
    print(counts[l-1][r-1])


Fixed submission:
n,m,q=map(int,input().split())
counts=[[0 for _ in range(n)] for _ in range(n)]
for _ in range(m):
    l,r=map(int,input().split())
    counts[l-1][r-1]+=1
cumsum=[[0 for _ in range(n+1)] for _ in range(n+1)]
for i in range(n):
    for j in range(n):
        cumsum[i+1][j+1]=cumsum[i+1][j]+counts[i][j]
for j in range(n+1):
    for i in range(n):
        cumsum[i+1][j]+=cumsum[i][j]
        
for _ in range(q):
    l,r=map(int,input().split())
    print(cumsum[r][r]-cumsum[r][l-1]-cumsum[l-1][r]+cumsum[l-1][l-1])

Buggy python submission (verdict: Time Limit Exceeded):
n,m,q=map(int,input().split())
counts=[[0 for _ in range(n)]for _ in range(n)]

for _ in range(m):
    l,r=map(int,input().split())
    for i in range(l):
        for j in range(r-1,n):
            counts[i][j]+=1
for _ in range(q):
    l,r=map(int,input().split())
    print(counts[l-1][r-1])

Fixed submission:
n,m,q=map(int,input().split())
counts=[[0 for _ in range(n)] for _ in range(n)]
for _ in range(m):
    l,r=map(int,input().split())
    counts[l-1][r-1]+=1
cumsum=[[0 for _ in range(n+1)] for _ in range(n+1)]
for i in range(n):
    for j in range(n):
        cumsum[i+1][j+1]=cumsum[i+1][j]+counts[i][j]
for j in range(n+1):
    for i in range(n):
        cumsum[i+1][j]+=cumsum[i][j]
        
for _ in range(q):
    l,r=map(int,input().split())
    print(cumsum[r][r]-cumsum[r][l-1]-cumsum[l-1][r]+cumsum[l-1][l-1])