Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
S = input()
S = list(S)

ans = 1
pre = S[0]
c = 1

while 1:
    if c == len(S)-1:
        if S[c] == pre:
            break
        else:
            ans += 1
            break

    if S[c] == pre:
        pre = S[c]+S[c+1]
        ans += 1
        c += 2
    else:
        pre = S[c]
        ans += 1
        c += 1

print(ans)


Fixed submission:
S = input()
S = list(S)

ans = 1
pre = S[0]
c = 1
while 1:
    if c == len(S):
        break
    if c == len(S)-1:
        if S[c] == pre:
            break
        else:
            ans += 1
            break

    if S[c] == pre:
        pre = S[c]+S[c+1]
        ans += 1
        c += 2
    else:
        pre = S[c]
        ans += 1
        c += 1

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
S = list(map(int, input().split()))
T = list(map(int, input().split()))
MOD = 10**9 + 7

dp = [[0 for j in range(M+1)]for i in range(N+1)]
for j in range(M+1):
    dp[0][j] = 1
for i in range(N+1):
    dp[i][0] = 1

for i in range(N):
    for j in range(M):
        if S[i] == T[j]:
            dp[i+1][j+1] = (dp[i][j+1] + dp[i+1][j])%MOD
        else:
            dp[i+1][j+1] = (dp[i][j+1] + dp[i+1][j] - dp[i][j])%MOD

print(dp[N][M])


Fixed submission:
N, M = map(int, input().split())
S = list(map(int, input().split()))
T = list(map(int, input().split()))
MOD = 10**9 + 7

dp = [[0 for j in range(M+1)]for i in range(N+1)]
for j in range(M+1):
    dp[0][j] = 1
for i in range(N+1):
    dp[i][0] = 1

for i in range(N):
    for j in range(M):
        if S[i] == T[j]:
            dp[i+1][j+1] = (dp[i][j+1] + dp[i+1][j])%MOD
        else:
            dp[i+1][j+1] = (dp[i][j+1] + dp[i+1][j] - dp[i][j])%MOD

print(dp[N][M])
Buggy python submission (verdict: Runtime Error):
A, B = map(int, input())
print(max(A, B)+max(A, B)-1)

Fixed submission:
A, B = map(int, input().split())
if A==B:    
    print(max(A, B)+max(A, B))
else:
    print(max(A, B)+max(A, B)-1)
Buggy python submission (verdict: Time Limit Exceeded):
N, Q = map(int, input().split())
S = list(input())

arr = [[0 for j in range(N)] for i in range(N)]
A_tmp = 0

for i in range(N):
    if S[i] == "A":
        A_tmp = 1
    elif A_tmp == 1 and S[i] == "C":
        for j in range(i, N):
            arr[i-1][j] = 1
        A_tmp = 0
    else:
        A_tmp = 0

for i in range(N-1,-1,-1):
    for j in range(len(S)):
        if i < j:
            arr[i][j] = arr[i+1][j] + arr[i][j]







ans_arr = []
for i in range(Q):
    l, r = map(int, input().split())
    
    ans_arr.append(arr[l-1][r-1])

for i in range(Q):
    print(ans_arr[i])

Fixed submission:
N, Q = map(int, input().split())
S = list(input())

arr = [0 for j in range(N)]
A_tmp = 0
S_tmp = 0

for i in range(N):
    if S[i] == "A":
        A_tmp = 1
        arr[i] = S_tmp
    elif A_tmp == 1 and S[i] == "C":
        S_tmp += 1
        arr[i] = S_tmp
        A_tmp = 0
    else:
        arr[i] = S_tmp
        A_tmp = 0

ans_arr = []
for i in range(Q):
    l, r = map(int, input().split())
    
    ans_arr.append(arr[r-1]-arr[l-1])

for i in range(Q):
    print(ans_arr[i])

Buggy python submission (verdict: Time Limit Exceeded):
N, Q = map(int, input().split())
S = input()

ans_arr = []
for i in range(Q):
    l, r = map(int, input().split())
    tmp = S[l-1:r]
    tmp = tmp.replace("AC", "_")
    ans_arr.append(tmp.count("_"))

for i in range(Q):
    print(ans_arr[i])

Fixed submission:
N, Q = map(int, input().split())
S = list(input())

arr = [0 for j in range(N)]
A_tmp = 0
S_tmp = 0

for i in range(N):
    if S[i] == "A":
        A_tmp = 1
        arr[i] = S_tmp
    elif A_tmp == 1 and S[i] == "C":
        S_tmp += 1
        arr[i] = S_tmp
        A_tmp = 0
    else:
        arr[i] = S_tmp
        A_tmp = 0

ans_arr = []
for i in range(Q):
    l, r = map(int, input().split())
    
    ans_arr.append(arr[r-1]-arr[l-1])

for i in range(Q):
    print(ans_arr[i])
Buggy python submission (verdict: Runtime Error):
import sys
S = input()
S_list = list(S)
flag = 1
S_pick = []

if len(S) < 2:
    print(0)
    sys.exit()

while flag:
    if len(S_list) == 0:
        break
    tmp = S_list[0]
    count = 0
    for i in range(1, len(S_list)):
        if S_list[i] == tmp and i == len(S_list)-1:
            break
            
        elif S_list[i] == tmp:
            tmp = S_list[i]
        else:
            S_pick.append(i-1)
            S_pick.append(i)
            tmp = S_list[i+1]
    for i in range(len(S_pick)-1, -1, -1):
        S_list.pop(S_pick[i])
    if len(S_pick) == 0:
        flag = 0
    S_pick = []
    
print(len(S)-len(S_list))

Fixed submission:
S = input()
S_list = list(S)

count0 = S_list.count("0")
count1 = S_list.count("1")

print(len(S_list) - abs(count0-count1))

Buggy python submission (verdict: Time Limit Exceeded):
import sys
S = input()
S_list = list(S)
flag = 1

if len(S) < 2:
    print(0)
    sys.exit()

while flag:
    if len(S_list) == 0:
        break
    tmp = S_list[0]
    count = 0
    for i in range(1, len(S_list)):
        if S_list[i] == tmp and i == len(S_list)-1:
            flag = 0
            break
            
        elif S_list[i] == tmp:
            tmp = S_list[i]
        else:
            S_list.pop(i-1)
            S_list.pop(i-1)
            count += 1
            break

print(len(S)-len(S_list))

Fixed submission:
S = input()
S_list = list(S)

count0 = S_list.count("0")
count1 = S_list.count("1")

print(len(S_list) - abs(count0-count1))
Buggy python submission (verdict: Runtime Error):
import math

N = int(input())
A_arr = list(map(int, input().split()))

max_k = math.gcd(A_arr[0], A_arr[1])
if N > 2:
    for i in range(2, N):
        max_k = math.gcd(max_k, A_arr[i])
else:
    pass

print(max_k)

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

def gcd(a,b):
    if ( b==0 ):
        return a
    else:
        return (gcd(b, a%b))

max_k = gcd(A_arr[0], A_arr[1])
if N > 2:
    for i in range(2, N):
        max_k = gcd(max_k, A_arr[i])
else:
    pass

print(max_k)
Buggy python submission (verdict: Runtime Error):
n, m = [int(i) for i in input().split()]
x_arr = [int(i) for i in input().split()]

x_sort = sorted(x_arr)

if n >= m:
    print(0)
else:
    x_sub = [x_sort[i+1]-x_sort[i] for i in range(m-1)]
    x_sub = sorted(x_sub)
    
    print(sum(x_sub[:-(n-1)]))


Fixed submission:
t, x = [int(i) for i in input().split()]
print(t/x)
Buggy python submission (verdict: Time Limit Exceeded):
n, m = [int(i) for i in input().split()]
x_arr = [int(i) for i in input().split()]

x_sort = sorted(x_arr)
x_sub = []

if n >= m:
    print(0)
else:
    x_sub = [x_sort[i+1]-x_sort[i] for i in range(m-1) ]
    
    for i in range(n-1):
        x_sub.remove(max(x_sub))
    
    print(sum(x_sub))

Fixed submission:
n, m = [int(i) for i in input().split()]
x_arr = [int(i) for i in input().split()]

x_sort = sorted(x_arr)

if n >= m or m==1:
    print(0)
else:
    x_sub = [x_sort[i+1]-x_sort[i] for i in range(m-1)]
    x_sub = sorted(x_sub)
    print(sum(x_sub[:(m-1)-(n-1)]))

Buggy python submission (verdict: Runtime Error):
n, m = [int(i) for i in input().split()]
x_arr = [int(i) for i in input().split()]

x_sort = sorted(x_arr)
x_sub = []

if len(x_sort) == 1:
    print(0)
else:
    x_sub = [x_sort[i+1]-x_sort[i] for i in range(m-1) ]
    x_sub = sorted(x_sub)
    
    for i in range(n-1):
        x_sub.remove(x_sub[-1])
    
    print(sum(x_sub))


Fixed submission:
n, m = [int(i) for i in input().split()]
x_arr = [int(i) for i in input().split()]

x_sort = sorted(x_arr)

if n >= m or m==1:
    print(0)
else:
    x_sub = [x_sort[i+1]-x_sort[i] for i in range(m-1)]
    x_sub = sorted(x_sub)
    print(sum(x_sub[:(m-1)-(n-1)]))

Buggy python submission (verdict: Runtime Error):
n, m = [int(i) for i in input().split()]
x_arr = [int(i) for i in input().split()]

x_sort = sorted(x_arr)
x_sub = []

if len(x_sort) == 1:
    print(0)
else:
    for i in range(m-1):
        x_sub.append(x_sort[i+1]-x_sort[i])
    
    x_sub = sorted(x_sub)
    
    for i in range(n-1):
        x_sub.remove(x_sub[-1])
    
    print(sum(x_sub))

Fixed submission:
n, m = [int(i) for i in input().split()]
x_arr = [int(i) for i in input().split()]

x_sort = sorted(x_arr)

if n >= m or m==1:
    print(0)
else:
    x_sub = [x_sort[i+1]-x_sort[i] for i in range(m-1)]
    x_sub = sorted(x_sub)
    print(sum(x_sub[:(m-1)-(n-1)]))

Buggy python submission (verdict: Runtime Error):
n, m = [int(i) for i in input().split()]
x_arr = [int(i) for i in input().split()]
x_n = [[] for i in range(n)]

x_sort = sorted(x_arr)
x_sub = []

for i in range(m-1):
    x_sub.append(x_sort[i+1]-x_sort[i])

x_sub = sorted(x_sub)

for i in range(n-1):
    x_sub.remove(max(x_sub))

print(sum(x_sub))


Fixed submission:
n, m = [int(i) for i in input().split()]
x_arr = [int(i) for i in input().split()]

x_sort = sorted(x_arr)

if n >= m or m==1:
    print(0)
else:
    x_sub = [x_sort[i+1]-x_sort[i] for i in range(m-1)]
    x_sub = sorted(x_sub)
    print(sum(x_sub[:(m-1)-(n-1)]))
Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
N = int(input())
A_arr = list(map(int, input().split()))

A_arr = sorted(A_arr, reverse=True)
C_arr = Counter(A_arr)

count = 0
while len(A_arr) != 0:
    v_max = A_arr.pop(0)
    C_arr[v_max] -= 1
    v_pair = 2**v_max.bit_length() - v_max
    if C_arr[v_pair] != 0:
        A_arr.remove(v_pair)
        C_arr[v_pair] -= 1
        count += 1
    else:
        pass

print(count)

Fixed submission:
from collections import Counter
N = int(input())
A_arr = list(map(int, input().split()))

A_arr = sorted(A_arr, reverse=True)
C_arr = Counter(A_arr)

count = 0
for i in range(N):
    v_max = A_arr[i]
    if C_arr[v_max] == 0:
        continue
    C_arr[v_max] -= 1
    v_pair = 2**v_max.bit_length() - v_max
    if C_arr[v_pair] > 0:
        C_arr[v_pair] -= 1
        count += 1
    else:
        pass

print(count)

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

A_arr = sorted(A_arr, reverse=True)
two_arr = []
for i in range(1,31):
    two_arr.append(2**i)

count = 0
while len(A_arr) != 0:
    v_max = A_arr.pop(0)
    v_pair = 2**v_max.bit_length() - v_max
    if v_pair in A_arr:
        A_arr.remove(v_pair)
        count += 1
    else:
        pass

print(count)

Fixed submission:
from collections import Counter
N = int(input())
A_arr = list(map(int, input().split()))

A_arr = sorted(A_arr, reverse=True)
C_arr = Counter(A_arr)

count = 0
for i in range(N):
    v_max = A_arr[i]
    if C_arr[v_max] == 0:
        continue
    C_arr[v_max] -= 1
    v_pair = 2**v_max.bit_length() - v_max
    if C_arr[v_pair] > 0:
        C_arr[v_pair] -= 1
        count += 1
    else:
        pass

print(count)

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

A_arr = sorted(A_arr, reverse=True)
two_arr = []
for i in range(1,31):
    two_arr.append(2**i)

count = 0
while len(A_arr) != 0:
    for j in range(30):
        if A_arr[0] > two_arr[j]:
            pass
        else:
            v_pair = two_arr[j] - A_arr[0]
            break
    if v_pair in A_arr:
        A_arr.remove(v_pair)
        count += 1
    else:
        pass
    A_arr.pop(0)

print(count)

Fixed submission:
from collections import Counter
N = int(input())
A_arr = list(map(int, input().split()))

A_arr = sorted(A_arr, reverse=True)
C_arr = Counter(A_arr)

count = 0
for i in range(N):
    v_max = A_arr[i]
    if C_arr[v_max] == 0:
        continue
    C_arr[v_max] -= 1
    v_pair = 2**v_max.bit_length() - v_max
    if C_arr[v_pair] > 0:
        C_arr[v_pair] -= 1
        count += 1
    else:
        pass

print(count)
Buggy python submission (verdict: Time Limit Exceeded):
n, k = [int(i) for i in input().split()]

h_arr = []
for i in range(n):
    h_arr.append(int(input()))

h_sort = sorted(h_arr, reverse=True)

tmp = 0
for i in range(n-k+1):
    if i == 0:
        tmp = max(h_sort[i:i+k]) - min(h_sort[i:i+k])
    else:
        sub = max(h_sort[i:i+k]) - min(h_sort[i:i+k])
        tmp = min(sub, tmp)

print(tmp)

Fixed submission:
import copy
n, k = [int(i) for i in input().split()]

h_arr = []
for i in range(n): 
    h_arr.append(int(input()))

h_arr = sorted(h_arr)
r = 10**10
for i in range(n-k+1):
    r = min(r,h_arr[i+k-1]-h_arr[i])

print(r)
Buggy python submission (verdict: Runtime Error):
n, x = [int(i) for i in input().split()]

b_str = "1"
for i in range(n):
    b_str = "0" + b_str + "1" + b_str + "0"

print(b_str[:x].count("1"))

Fixed submission:
n, x = [int(i) for i in input().split()]

a = [1]
p = [1]

for i in range(n):
    a.append(a[i]*2+3) 
    p.append(p[i]*2+1)

def patty_count(num, x_bot):
    if num == 0:
        return 0 if x_bot<=0 else 1
    elif x_bot<=1+a[num-1]:
        return patty_count(num-1, x_bot-1)
    else:
        return p[num-1] + 1 + patty_count(num-1, x_bot-2-a[num-1])
 
print(patty_count(n, x))
# print()
Buggy python submission (verdict: Runtime Error):
N = int(input())

L = []
for i in range(N):
    x, y, h = map(int, input().split())
    L.append([x, y, h])
    if h != 0:
        idx = i


for i in range(101):
    for j in range(101):
        H = L[idx][2] + abs(L[idx][0]-i) + abs(L[idx][1]-j)
        for k in range(N):
            if L[k][2] == H - abs(L[k][0]-i) - abs(L[k][1]-j):
                pass
            else:
                break
            if k == N-1:
                ansx = i
                ansy = j
                ansh = H

print(ansx, ansy, ansh)

Fixed submission:
n = int(input())

arr = []

for i in range(n):
    x, y, h = map(int, input().split())
    arr.append([x, y, h])

for i in range(101):
    for j in range(101):
        for k in range(n):
            if arr[k][2] > 0:
                len1 = abs(arr[k][0] - i) + abs(arr[k][1] - j)
                ch = len1 + arr[k][2]
                break
            else:
                continue
        for k in range(n):
            lenk = abs(arr[k][0] - i) + abs(arr[k][1] - j)
            if max(ch - lenk, 0) == arr[k][2]:
                if k == n-1:
                    print("{} {} {}".format(i, j, ch))
                else:
                    continue
            else:
                break
Buggy python submission (verdict: Time Limit Exceeded):
s = input()
t = input()

# atoz = [chr(i) for i in range(97,97+26)]


for i in range(len(s)):
    if s[i] == t[i]:
        continue
    else:
        s = s.translate(s.maketrans({s[i]:t[i], t[i]:s[i]}))

if s == t:
    print("Yes")
else:
    print("No")

Fixed submission:
import sys

s = input()
t = input()

# atoz = [chr(i) for i in range(97,97+26)]


for i in range(len(s)):
    if s[i] == t[i]:
        continue
    else:
        s_tmp = s
        s = s.translate(s.maketrans({s[i]:t[i], t[i]:s[i]}))
        if s_tmp[:i] != s[:i]:
            print("No")
            sys.exit()
        else:
            pass


if s == t:
    print("Yes")
else:
    print("No")

Buggy python submission (verdict: Time Limit Exceeded):
s = input()
t = input()

atoz = [chr(i) for i in range(97,97+26)]
s_list = [[] for i in range(26)]

for i in range(len(s)):
    for j in range(26):
        if s[i] == atoz[j]:
            s_list[j].append(1)
        else:
            s_list[j].append(0)

t_list = [[] for i in range(26)]

for i in range(len(t)):
    for j in range(26):
        if t[i] == atoz[j]:
            t_list[j].append(1)
        else:
            t_list[j].append(0)

s_sort = sorted(s_list)
t_sort = sorted(t_list)

if s_sort == t_sort:
    print("Yes")
else:
    print("No")

Fixed submission:
import sys

s = input()
t = input()

# atoz = [chr(i) for i in range(97,97+26)]


for i in range(len(s)):
    if s[i] == t[i]:
        continue
    else:
        s_tmp = s
        s = s.translate(s.maketrans({s[i]:t[i], t[i]:s[i]}))
        if s_tmp[:i] != s[:i]:
            print("No")
            sys.exit()
        else:
            pass


if s == t:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
import sys
n, k = map(int, input().split())

bai = 1
k_arr = []
while bai * k <= n:
    k_arr.append(bai * k)
    bai += 1


if k % 2 == 0:
    bai2 = 1
    k_arr2 = []
    while bai2 * k/2 <= n:
        k_arr2.append(bai2 * k/2)
        bai2 += 1
        k_arr2_len = len(k_arr2) - len(k_arr)
    print(len(k_arr)*len(k_arr)*len(k_arr) + k_arr2_len*k_arr2_len*k_arr2_len)

else:
    print(len(k_arr)*len(k_arr)*len(k_arr))


Fixed submission:
import sys
n, k = map(int, input().split())

bai = 1
k_arr = []
while bai * k <= n:
    k_arr.append(bai * k)
    bai += 1


if k % 2 == 0:
    bai2 = 1
    k_arr2 = []
    k_arr2_len = 0 - len(k_arr2)
    while bai2 * k/2 <= n:
        k_arr2.append(bai2 * k/2)
        bai2 += 1
        k_arr2_len = len(k_arr2) - len(k_arr)
    print(len(k_arr)*len(k_arr)*len(k_arr) + k_arr2_len*k_arr2_len*k_arr2_len)

else:
    print(len(k_arr)*len(k_arr)*len(k_arr))

Buggy python submission (verdict: Runtime Error):
import sys
n, k = map(int, input().split())

if k == 1:
    print(0)
    sys.exit()

bai = 1
k_arr = []
while bai * k <= n:
    k_arr.append(bai * k)
    bai += 1


if k % 2 == 0:
    bai2 = 1
    k_arr2 = []
    while bai2 * k/2 <= n:
        k_arr2.append(bai2 * k/2)
        bai2 += 1
        k_arr2_len = len(k_arr2) - len(k_arr)
    print(len(k_arr)*len(k_arr)*len(k_arr) + k_arr2_len*k_arr2_len*k_arr2_len)

else:
    print(len(k_arr)*len(k_arr)*len(k_arr))

Fixed submission:
import sys
n, k = map(int, input().split())

bai = 1
k_arr = []
while bai * k <= n:
    k_arr.append(bai * k)
    bai += 1


if k % 2 == 0:
    bai2 = 1
    k_arr2 = []
    k_arr2_len = 0 - len(k_arr2)
    while bai2 * k/2 <= n:
        k_arr2.append(bai2 * k/2)
        bai2 += 1
        k_arr2_len = len(k_arr2) - len(k_arr)
    print(len(k_arr)*len(k_arr)*len(k_arr) + k_arr2_len*k_arr2_len*k_arr2_len)

else:
    print(len(k_arr)*len(k_arr)*len(k_arr))

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


bai = 1
k_arr = []
while bai * k <= n:
    k_arr.append(bai * k)
    bai += 1


if k % 2 == 0:
    bai2 = 1
    k_arr2 = []
    while bai2 * k/2 <= n:
        k_arr2.append(bai2 * k/2)
        bai2 += 1
        k_arr2_len = len(k_arr2) - len(k_arr)
        
    print(k_arr2_len)
    print(len(k_arr)*len(k_arr)*len(k_arr) + k_arr2_len*k_arr2_len*k_arr2_len)

else:
    print(len(k_arr)*len(k_arr)*len(k_arr))


Fixed submission:
import sys
n, k = map(int, input().split())

bai = 1
k_arr = []
while bai * k <= n:
    k_arr.append(bai * k)
    bai += 1


if k % 2 == 0:
    bai2 = 1
    k_arr2 = []
    k_arr2_len = 0 - len(k_arr2)
    while bai2 * k/2 <= n:
        k_arr2.append(bai2 * k/2)
        bai2 += 1
        k_arr2_len = len(k_arr2) - len(k_arr)
    print(len(k_arr)*len(k_arr)*len(k_arr) + k_arr2_len*k_arr2_len*k_arr2_len)

else:
    print(len(k_arr)*len(k_arr)*len(k_arr))
Buggy python submission (verdict: Time Limit Exceeded):
n, m, q = map(int, input().split())

arr = [[0 for j in range(n)] for i in range(n)]
arr_sum = [[0 for j in range(n)] for i in range(n)]
arr_sum2 = [[0 for j in range(n)] for i in range(n)]

for i in range(m):
    l, r = map(int, input().split())
    arr[l-1][r-1] += 1

for i in range(n):
    for j in range(n):
        if i <= j:
            arr_sum[i][j] = sum(arr[i][:j+1])

for i in range(n):
    for j in range(n):
        if i <= j:
            for k in range(i,j+1):
                arr_sum2[i][j] += arr_sum[k][j]


ans_arr = []
for k in range(q):
    p, q = map(int, input().split())
    ans = arr_sum2[p-1][q-1]
    ans_arr.append(ans)

for i in ans_arr:
    print(i)

Fixed submission:
n, m, q = map(int, input().split())

arr = [[0 for j in range(n)] for i in range(n)]
arr_sum = []
arr_sum2 = []

for i in range(m):
    l, r = map(int, input().split())
    arr[l-1][r-1] += 1


for i in range(n):
    s = 0
    arr_tmp = []
    for j in range(n):
            s += arr[i][j]
            arr_tmp.append(s)
    arr_sum.append(arr_tmp)


for j in range(n):
    s = 0
    arr_tmp2 = []
    for i in range(n-1,-1,-1):
            s += arr_sum[i][j]
            arr_tmp2.append(s)
    arr_sum2.append(arr_tmp2)

arr_sum3 = [[0 for j in range(n)] for i in range(n)]
for i in range(n):
    for j in range(n):
        arr_sum3[i][j] = arr_sum2[j][n-i-1]

ans_arr = []
for k in range(q):
    p, q = map(int, input().split())
    ans = arr_sum3[p-1][q-1]
    ans_arr.append(ans)

for i in ans_arr:
    print(i)

Buggy python submission (verdict: Time Limit Exceeded):
n, m, q = map(int, input().split())

arr = [[0 for j in range(n)] for i in range(n)]
arr_sum = [[0 for j in range(n)] for i in range(n)]

for i in range(m):
    l, r = map(int, input().split())
    arr[l-1][r-1] += 1

for i in range(n):
    for j in range(n):
        if i <= j:
            arr_sum[i][j] = sum(arr[i][:j+1])


ans_arr = []
for k in range(q):
    ans = 0
    p, q = map(int, input().split())
    for i in range(p-1, q):
        ans += arr_sum[i][q-1]
    ans_arr.append(ans)

for i in ans_arr:
    print(i)

Fixed submission:
n, m, q = map(int, input().split())

arr = [[0 for j in range(n)] for i in range(n)]
arr_sum = []
arr_sum2 = []

for i in range(m):
    l, r = map(int, input().split())
    arr[l-1][r-1] += 1


for i in range(n):
    s = 0
    arr_tmp = []
    for j in range(n):
            s += arr[i][j]
            arr_tmp.append(s)
    arr_sum.append(arr_tmp)


for j in range(n):
    s = 0
    arr_tmp2 = []
    for i in range(n-1,-1,-1):
            s += arr_sum[i][j]
            arr_tmp2.append(s)
    arr_sum2.append(arr_tmp2)

arr_sum3 = [[0 for j in range(n)] for i in range(n)]
for i in range(n):
    for j in range(n):
        arr_sum3[i][j] = arr_sum2[j][n-i-1]

ans_arr = []
for k in range(q):
    p, q = map(int, input().split())
    ans = arr_sum3[p-1][q-1]
    ans_arr.append(ans)

for i in ans_arr:
    print(i)
Buggy python submission (verdict: Runtime Error):
import sys
K = int(input())
count = 0
nine = ""

arr = [i for i in range(1,10)]
arr_sunuke = [i for i in range(1,10)]
for k in range(13):
    for i in range(1,10):
        for j in range(10):
            arr.append(int(str(i)+str(j)+nine))
            arr_sunuke.append(i + j + k*9)
    nine = nine + str(9)


arr_sunuke2 = [arr[i]/arr_sunuke[i] for i in range(len(arr))]

ans = []
tmp = 100000000000000
for i in range(len(arr)-1, -1, -1):
    if arr_sunuke2[i] <= tmp:
        ans.append(arr[i])
        tmp = arr_sunuke2[i]

ans = ans[::-1]
for i in range(K):
    print(ans[i])

Fixed submission:
import sys
K = int(input())
count = 0
nine = ""

arr = []
arr_sunuke = []
for k in range(14):
    for i in range(10):
        for j in range(10):
            for l in range(10):
                if i == 0 and nine != "":
                    pass
                else:
                    arr.append(int(str(i)+str(j)+str(l)+nine))
                    arr_sunuke.append(i + j + l + k*9)
    nine = nine + str(9)

arr.remove(0)
arr_sunuke.remove(0)
arr_sunuke2 = [arr[i]/arr_sunuke[i] for i in range(len(arr))]

ans = []
tmp = 10**15
for i in range(len(arr)-1, -1, -1):
    if arr_sunuke2[i] <= tmp:
        ans.append(arr[i])
        tmp = arr_sunuke2[i]

ans = ans[::-1]
for i in range(K):
    print(ans[i])