Buggy python submission (verdict: Time Limit Exceeded):
num_city, num_train, num_question = [int(i) for i in input().split()]

#電車の数
trains = [[0] * (num_city + 1) for i in range(0, num_city + 1)]
for i in range(0, num_train):
    start, arrive = [int(j) for j in input().split()]
    trains[start][arrive] += 1

#累積和表を作る
trains_cumulative_sum = [[0] * (num_city + 1) for i in range(0, num_city  + 1)]
for start in range(0, num_city + 1):
    for arrive in range(0, num_city + 1):
        trains_cumulative_sum[start][arrive] = trains_cumulative_sum[start][arrive - 1] + trains[start][arrive]

for i in range(0, num_question):
    start, arrive = [int(j) for j in input().split()]
    result = 0
    for j in range(start, arrive + 1):
        result += trains_cumulative_sum[j][arrive]
    print(result)


Fixed submission:
num_city, num_train, num_question = [int(i) for i in input().split()]

#電車の数
trains = [[0] * (num_city + 1) for i in range(0, num_city + 1)]
for i in range(0, num_train):
    start, arrive = [int(j) for j in input().split()]
    trains[start][arrive] += 1

#累積和表を作る
cumlative_sum = [[0] * (num_city + 1) for i in range(0, num_city  + 1)]
for start in range(0, num_city + 1):
    for arrive in range(0, num_city + 1):
        cumlative_sum[start][arrive] = cumlative_sum[start][arrive - 1] + trains[start][arrive]

for start in range(0, num_city + 1):
    for arrive in range(0, num_city + 1):
        cumlative_sum[start][arrive] += cumlative_sum[start - 1][arrive]

for i in range(0, num_question):
    start, arrive = [int(j) for j in input().split()]
    result = cumlative_sum[arrive][arrive] - cumlative_sum[start - 1][arrive] - cumlative_sum[arrive][start - 1] + cumlative_sum[start - 1][start - 1]
    print(result)

Buggy python submission (verdict: Time Limit Exceeded):
num_city, num_train, num_question = [int(i) for i in input().split()]

#電車の数
trains = [[0] * num_city for i in range(0, num_city)]
for i in range(0, num_train):
    start, arrive = [int(j) - 1 for j in input().split()]
    trains[start][arrive] += 1

#累積和表を作る
trains_cumulative_sum = [[0] * num_city for i in range(0, num_city)]
for start in range(0, num_city):
    for arrive in range(0, num_city):
        if arrive != 0:
            trains_cumulative_sum[start][arrive] += trains_cumulative_sum[start][arrive - 1]
        trains_cumulative_sum[start][arrive] += trains[start][arrive]

answers = []
for i in range(0, num_question):
    start, arrive = [int(j) - 1 for j in input().split()]
    result = 0
    for j in range(start, arrive + 1):
        result += trains_cumulative_sum[j][arrive]
    answers.append(result)

for answer in answers:
    print(answer)


Fixed submission:
num_city, num_train, num_question = [int(i) for i in input().split()]

#電車の数
trains = [[0] * (num_city + 1) for i in range(0, num_city + 1)]
for i in range(0, num_train):
    start, arrive = [int(j) for j in input().split()]
    trains[start][arrive] += 1

#累積和表を作る
cumlative_sum = [[0] * (num_city + 1) for i in range(0, num_city  + 1)]
for start in range(0, num_city + 1):
    for arrive in range(0, num_city + 1):
        cumlative_sum[start][arrive] = cumlative_sum[start][arrive - 1] + trains[start][arrive]

for start in range(0, num_city + 1):
    for arrive in range(0, num_city + 1):
        cumlative_sum[start][arrive] += cumlative_sum[start - 1][arrive]

for i in range(0, num_question):
    start, arrive = [int(j) for j in input().split()]
    result = cumlative_sum[arrive][arrive] - cumlative_sum[start - 1][arrive] - cumlative_sum[arrive][start - 1] + cumlative_sum[start - 1][start - 1]
    print(result)

Buggy python submission (verdict: Time Limit Exceeded):
num_city, num_train, num_question = [int(i) for i in input().split()]

#電車の数
trains = {}
for i in range(0, num_train):
    start, arrive = [int(j) - 1 for j in input().split()]
    if (start, arrive ) in trains:
        trains[(start, arrive)] += 1
    else:
        trains[(start, arrive)] = 1

#累積和表を作る
trains_cumulative_sum = {}
for start in range(0, num_city):
    for arrive in range(0, num_city):
        if arrive == 0:
            trains_cumulative_sum[(start, arrive)] = 0
        else:
            trains_cumulative_sum[(start, arrive)] = trains_cumulative_sum[(start, arrive - 1)]

        if (start, arrive) in trains:
            trains_cumulative_sum[(start, arrive)] += trains[(start, arrive)]

answers = []
for i in range(0, num_question):
    start, arrive = [int(j) - 1 for j in input().split()]
    result = 0
    for j in range(start, arrive + 1):
        result += trains_cumulative_sum[(j, arrive)]
    answers.append(result)

for answer in answers:
    print(answer)


Fixed submission:
num_city, num_train, num_question = [int(i) for i in input().split()]

#電車の数
trains = [[0] * (num_city + 1) for i in range(0, num_city + 1)]
for i in range(0, num_train):
    start, arrive = [int(j) for j in input().split()]
    trains[start][arrive] += 1

#累積和表を作る
cumlative_sum = [[0] * (num_city + 1) for i in range(0, num_city  + 1)]
for start in range(0, num_city + 1):
    for arrive in range(0, num_city + 1):
        cumlative_sum[start][arrive] = cumlative_sum[start][arrive - 1] + trains[start][arrive]

for start in range(0, num_city + 1):
    for arrive in range(0, num_city + 1):
        cumlative_sum[start][arrive] += cumlative_sum[start - 1][arrive]

for i in range(0, num_question):
    start, arrive = [int(j) for j in input().split()]
    result = cumlative_sum[arrive][arrive] - cumlative_sum[start - 1][arrive] - cumlative_sum[arrive][start - 1] + cumlative_sum[start - 1][start - 1]
    print(result)

Buggy python submission (verdict: Time Limit Exceeded):
num_city, num_train, num_question = [int(i) for i in input().split()]

trains = []
for i in range(0, num_train):
    trains.append([int(j) for j in input().split()])

answers = []
for i in range(0, num_question):
    question = [int(j) for j in input().split()]

    count = 0
    for train in trains:
        if question[0] <= train[0] and question[1] >= train[1]:
            count += 1
    answers.append(count)

for answer in answers:
    print(answer)


Fixed submission:
num_city, num_train, num_question = [int(i) for i in input().split()]

#電車の数
trains = [[0] * (num_city + 1) for i in range(0, num_city + 1)]
for i in range(0, num_train):
    start, arrive = [int(j) for j in input().split()]
    trains[start][arrive] += 1

#累積和表を作る
cumlative_sum = [[0] * (num_city + 1) for i in range(0, num_city  + 1)]
for start in range(0, num_city + 1):
    for arrive in range(0, num_city + 1):
        cumlative_sum[start][arrive] = cumlative_sum[start][arrive - 1] + trains[start][arrive]

for start in range(0, num_city + 1):
    for arrive in range(0, num_city + 1):
        cumlative_sum[start][arrive] += cumlative_sum[start - 1][arrive]

for i in range(0, num_question):
    start, arrive = [int(j) for j in input().split()]
    result = cumlative_sum[arrive][arrive] - cumlative_sum[start - 1][arrive] - cumlative_sum[arrive][start - 1] + cumlative_sum[start - 1][start - 1]
    print(result)