Buggy python submission (verdict: Time Limit Exceeded):
n,m,q=map(int,input().split())
alist=[]
for i in range(m):
    l,r=map(int,input().split())
    alist.append([l,r])
alist.sort()
for t in range(q):
    count=0
    blist=[]
    p,q=map(int,input().split())
    for j in range (len(alist)):
        if p<=alist[0][0]:
            alist.sort(key=lambda x:x[1])
            break
        blist.append(alist[0])
        alist.remove(alist[0])
    for j in range (len(alist)):
        if q>=alist[j][1]:
            count+=1
        else:
            break
    for k in blist:
        alist.append(k)
    print(count)
    alist.sort(key=lambda x:x[0])

Fixed submission:
n, m, Q = map(int, input().split())
lr = [[0 for _ in range(n + 1)] for _ in range(n + 1)]
for _ in range(m):
    l, r = map(int, input().split())
    lr[l][r] += 1

rui = [[0 for _ in range(n + 1)] for _ in range(n + 1)]
for i in range(1, n + 1):
    for j in range(1, n + 1):
        rui[i][j] = lr[i][j] + rui[i - 1][j] + rui[i][j - 1] - rui[i - 1][j - 1]
    
for _ in range(Q):
    p, q = map(int, input().split())
    p -= 1
    ans = rui[q][q] - rui[p][q] - rui[q][p] + rui[p][p]
    print(ans)

Buggy python submission (verdict: Runtime Error):
n,m,q=map(int,input().split())
alist=[]
for i in range(m):
    l,r=map(int,input().split())
    alist.append([l,r])
alist.sort()
for t in range(q):
    count=0
    blist=[]
    p,q=map(int,input().split())
    for j in range (len(alist)):
        if p<=alist[0][0]:
            alist.sort(key=lambda x:x[1])
            break
        alist.remove(alist[0])
        blist.append(alist[0])
    for j in range (len(alist)):
        if q>=alist[j][1]:
            count+=1
        else:
            break
    for k in blist:
        alist.append(k)
    print(count)

Fixed submission:
n, m, Q = map(int, input().split())
lr = [[0 for _ in range(n + 1)] for _ in range(n + 1)]
for _ in range(m):
    l, r = map(int, input().split())
    lr[l][r] += 1

rui = [[0 for _ in range(n + 1)] for _ in range(n + 1)]
for i in range(1, n + 1):
    for j in range(1, n + 1):
        rui[i][j] = lr[i][j] + rui[i - 1][j] + rui[i][j - 1] - rui[i - 1][j - 1]
    
for _ in range(Q):
    p, q = map(int, input().split())
    p -= 1
    ans = rui[q][q] - rui[p][q] - rui[q][p] + rui[p][p]
    print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n,m,q=map(int,input().split())
alist=[]
for i in range(m):
    l,r=map(int,input().split())
    alist.append([l,r])
alist.sort()
alist.reverse()
for j in range(q):
    count=0
    p,q=map(int,input().split())
    for j in alist:
        if p<=j[0] and q>=j[1]:
            count+=1
        elif p>j[0]:
            break
    print(count)

Fixed submission:
n, m, Q = map(int, input().split())
lr = [[0 for _ in range(n + 1)] for _ in range(n + 1)]
for _ in range(m):
    l, r = map(int, input().split())
    lr[l][r] += 1

rui = [[0 for _ in range(n + 1)] for _ in range(n + 1)]
for i in range(1, n + 1):
    for j in range(1, n + 1):
        rui[i][j] = lr[i][j] + rui[i - 1][j] + rui[i][j - 1] - rui[i - 1][j - 1]
    
for _ in range(Q):
    p, q = map(int, input().split())
    p -= 1
    ans = rui[q][q] - rui[p][q] - rui[q][p] + rui[p][p]
    print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n,m,q=map(int,input().split())
alist=[]
for i in range(m):
    l,r=map(int,input().split())
    alist.append([l,r])
alist.sort()
for j in range(q):
    count=0
    p,q=map(int,input().split())
    for j in alist:
        if p<=j[0] and q>=j[1]:
            count+=1
    print(count)

Fixed submission:
n, m, Q = map(int, input().split())
lr = [[0 for _ in range(n + 1)] for _ in range(n + 1)]
for _ in range(m):
    l, r = map(int, input().split())
    lr[l][r] += 1

rui = [[0 for _ in range(n + 1)] for _ in range(n + 1)]
for i in range(1, n + 1):
    for j in range(1, n + 1):
        rui[i][j] = lr[i][j] + rui[i - 1][j] + rui[i][j - 1] - rui[i - 1][j - 1]
    
for _ in range(Q):
    p, q = map(int, input().split())
    p -= 1
    ans = rui[q][q] - rui[p][q] - rui[q][p] + rui[p][p]
    print(ans)