Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
A,B=map(int,input().split())
if A<=2*B:
  print(0)
else A>2*B:
  print(A-(2*B))

Fixed submission:
A,B=map(int,input().split())
if A<=2*B:
  print(0)
else :
  print(A-(2*B))

Buggy python submission (verdict: Runtime Error):
A,B=map(int,input().split())
if A<=2*B:
  print(0)
else A>2*B
  print(A-(2*B))

Fixed submission:
A,B=map(int,input().split())
if A<=2*B:
  print(0)
else :
  print(A-(2*B))

Buggy python submission (verdict: Runtime Error):
a,b=map(int,input().split())
if a-2*b>=0:
  print(a-2*b)
else a-2*b<0:
  print(0)


Fixed submission:
a,b=map(int,input().split())
if a-2*b>=0:
  print(a-2*b)
else:
  print(0)

Buggy python submission (verdict: Runtime Error):
a,b=map(int,input(),split())
if a-2*b>=0:
  print(a-2*b)
else a-2*b<0:
  print(0)


Fixed submission:
a,b=map(int,input().split())
if a-2*b>=0:
  print(a-2*b)
else:
  print(0)

Buggy python submission (verdict: Runtime Error):
a,b=map(int,input(),split())
if a-2b>=0:
  print(a-2b)
else a-2b<0:
  print(0)

Fixed submission:
a,b=map(int,input().split())
if a-2*b>=0:
  print(a-2*b)
else:
  print(0)
Buggy python submission (verdict: Runtime Error):
a,b,c=map(int,input().split())
if a=b=c:
  print(1)
elif a=b!=c:
  print(3)
else:
  print(6)

Fixed submission:
n=int(input())
print(n*n*n)
Buggy python submission (verdict: Runtime Error):
a,b=map(int,input().split())
  print(max(a+b,a-b,a*b))


Fixed submission:
a,b=map(int,input().split())
print(max(a+b,a-b,a*b))

Buggy python submission (verdict: Runtime Error):
a,b=map(int,input().split())
  print(max(a+b,a-b,a*b)

Fixed submission:
a,b=map(int,input().split())
print(max(a+b,a-b,a*b))
Buggy python submission (verdict: Runtime Error):
a,b,c=map(int,input().split)
print(c-(a+b))

Fixed submission:
a,b,c=map(int,input().split())
print(max(c-a+b,0))
Buggy python submission (verdict: Runtime Error):
a,b,c=map(int,input().split())
if a+b+c >= 22:
  print("bust")
else 
  print("win")

Fixed submission:
a,b,c=map(int,input().split())
if a+b+c >= 22:
  print("bust")
else:
  print("win")

Buggy python submission (verdict: Runtime Error):
A1 = input()
A2 = input()
A3 = input()


Fixed submission:
a,b,c=map(int,input().split())
if a+b+c >= 22:
  print("bust")
else:
  print("win")
Buggy python submission (verdict: Runtime Error):
S=input()
if S="SUN":
  print("0")
elif S="MON":
  print("1")
elif S="TUE":
  print("2")
elif S="Wed":
  print("3")
elif S="THU":
  print("4")
elif S="FRI":
  print("5")
elif S="SAT":
  print("6")


Fixed submission:
S=input()
if S=="SUN":
  print(7)
elif S=="MON":
  print(6)
elif S=="TUE":
  print(5)
elif S=="WED":
  print(4)
elif S=="THU":
  print(3)
elif S=="FRI":
  print(2)
elif S=="SAT":
  print(1)

Buggy python submission (verdict: Runtime Error):
S=input()
if S="SUN":
  print("0")
  elif S="MON":
  print("1")
  elif S="TUE":
  print("2")
  elif S="Wed":
  print("3")
  elif S="THU":
  print("4")
  elif S="FRI":
  print("5")
  elif S="SAT":
  print("6")


Fixed submission:
S=input()
if S=="SUN":
  print(7)
elif S=="MON":
  print(6)
elif S=="TUE":
  print(5)
elif S=="WED":
  print(4)
elif S=="THU":
  print(3)
elif S=="FRI":
  print(2)
elif S=="SAT":
  print(1)

Buggy python submission (verdict: Runtime Error):
if S="SUN":
  print("0")
  elif S="MON":
  print("1")
  elif S="TUE":
  print("2")
  elif S="Wed":
  print("3")
  elif S="THU":
  print("4")
  elif S="FRI":
  print("5")
  elif S="SAT":
  print("6")


Fixed submission:
S=input()
if S=="SUN":
  print(7)
elif S=="MON":
  print(6)
elif S=="TUE":
  print(5)
elif S=="WED":
  print(4)
elif S=="THU":
  print(3)
elif S=="FRI":
  print(2)
elif S=="SAT":
  print(1)

Buggy python submission (verdict: Runtime Error):
if S="SUN":
  print("0")
  elif S="MON"
  print("1")
  elif S="TUE"
  print("2")
  elif S="Wed"
  print("3")
  elif S="THU"
  print("4")
  elif S="FRI"
  print("5")
  elif S="SAT"
  print("6")

Fixed submission:
S=input()
if S=="SUN":
  print(7)
elif S=="MON":
  print(6)
elif S=="TUE":
  print(5)
elif S=="WED":
  print(4)
elif S=="THU":
  print(3)
elif S=="FRI":
  print(2)
elif S=="SAT":
  print(1)
Buggy python submission (verdict: Runtime Error):
a,b=map(int,input().split())
if 1<=a<=9 AND 1<=b<=9:
  print(a*b)
else:
  print("-1")


Fixed submission:
a,b=map(int,input().split())
if 1<=a<=9 and 1<=b<=9:
  print(a*b)
else:
  print("-1")

Buggy python submission (verdict: Runtime Error):
a,b=map(int,input().split())
if 1=<a<=9 AND 1=<b<=9:
  print(a*b)
else:
  print("-1")


Fixed submission:
a,b=map(int,input().split())
if 1<=a<=9 and 1<=b<=9:
  print(a*b)
else:
  print("-1")

Buggy python submission (verdict: Runtime Error):
a,b=map(int,input().split())
if 1=<a<=20 AND 1=<b<=20:
  print(a*b)
else:
  print("-1")


Fixed submission:
a,b=map(int,input().split())
if 1<=a<=9 and 1<=b<=9:
  print(a*b)
else:
  print("-1")

Buggy python submission (verdict: Runtime Error):
a,b=map(int,input().split())
if (a >=1) AND (a <= 20) AND (b >=1) AND (b =< 20):
  print(a*b)
else:
  print("-1")

Fixed submission:
a,b=map(int,input().split())
if 1<=a<=9 and 1<=b<=9:
  print(a*b)
else:
  print("-1")

Buggy python submission (verdict: Runtime Error):
a,b=map(int,input().split())
if (1 =< a <= 20) AND (1 =< b <= 20)
  print(a*b)
  else:
    print("-1")

Fixed submission:
a,b=map(int,input().split())
if 1<=a<=9 and 1<=b<=9:
  print(a*b)
else:
  print("-1")
Buggy python submission (verdict: Runtime Error):
a,b=map(int(),input().split())
print(max(a*b,a-b,a+b))

Fixed submission:
a, b=map(int, input().split())
print(max(a-b, a+b, a*b))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
lst = list(map(str, input().split()))
for i in range(N):
    idx = lst.index((str(i+1)))
    print(idx+1,end=" ")


Fixed submission:
N = int(input())
lst = list(map(int, input().split()))
a = [0]*N
for i,j in enumerate(lst):
    a[j-1] = str(i+1)

print(" ".join(a))

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
o_lst=[]
lst = list(map(int, input().split()))
for i in lst:
    idx = lst.index(min(lst))
    print(idx+1,end=" ")
    #o_lst.append(idx+1)
    lst[idx]=N+1

Fixed submission:
N = int(input())
lst = list(map(int, input().split()))
a = [0]*N
for i,j in enumerate(lst):
    a[j-1] = str(i+1)

print(" ".join(a))
Buggy python submission (verdict: Time Limit Exceeded):
K,S = map(int,input().split())
cnt = 0
for i in range(K+1):
    for j in range(K+1):
        for k in range(K+1):
            sum = i + j + k
            if sum == S:
                cnt+=1
print(cnt)

Fixed submission:
K, S = map(int, input().split())
cnt = 0
for i in range(K + 1):
    for j in range(K + 1):
        if S - (i + j) < 0 or S-(i+j)>K:
            cnt = cnt
        else:
            cnt += 1

print(cnt)
Buggy python submission (verdict: Runtime Error):
A1, A2, A3 = map(int, split(input()))
total = A1 + A2 + A3
if total >= 22:
    print("bust")
else:
    print("win")

Fixed submission:
A1, A2, A3 = map(int, input().split())
total = A1 + A2 + A3
if total >= 22:
    print("bust")
else:
    print("win")
Buggy python submission (verdict: Time Limit Exceeded):
def count(num_lst):
    count = [0]*60
    for num in num_lst:
        for i in range(60):
            tmp = 0
            if tmp == num:
                break
            if num & (1<<i):
                count[i] += 1
                tmp += 2**i
    return count

n = int(input())
num_list = list(map(int,input().split()))
mod = 10**9 + 7

count = count(num_list)
ans = 0
for i in range(60):
    if i == 0:
        pow_two = 1
    else:
        pow_two = pow_two * 2 % mod
    ans += pow_two * count[i] * (n - count[i]) % mod
    ans %= mod
print(ans)

Fixed submission:
import numpy as np

n = int(input())
num_list = np.array(input().split(), dtype = np.int64)
mod = 10**9 + 7

ans = 0
for i in range(60):
    b = np.count_nonzero(num_list >> i & 1)
    if i==0:
        pow_two = 1
    else:
        pow_two = pow_two * 2 % mod
    ans += pow_two * b * (n-b) % mod
    ans %= mod
    
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
def count(num_lst):
    count = [0]*60
    for num in num_lst:
        for i in range(60):
            if num & (1<<i):
                count[i] += 1
    return count

n = int(input())
num_list = list(map(int,input().split()))
mod = 10**9 + 7

count = count(num_list)
ans = 0
for i in range(60):
    if i == 0:
        pow_two = 1
    else:
        pow_two = pow_two * 2 % mod
    ans += pow_two * count[i] * (n - count[i]) % mod
    ans %= mod
print(ans)

Fixed submission:
import numpy as np

n = int(input())
num_list = np.array(input().split(), dtype = np.int64)
mod = 10**9 + 7

ans = 0
for i in range(60):
    b = np.count_nonzero(num_list >> i & 1)
    if i==0:
        pow_two = 1
    else:
        pow_two = pow_two * 2 % mod
    ans += pow_two * b * (n-b) % mod
    ans %= mod
    
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
def count(num_lst):
    count = [0]*60
    for num in num_lst:
        for i in range(60):
            if num & (1<<i):
                count[i] += 1
    return count

n = int(input())
num_list = list(map(int,input().split()))
mod = 10**9 + 7

count = count(num_list)
ans = 0
for i in range(60):
    ans += (2**i * count[i] * (n - count[i])) % mod
    ans %= mod
print(ans)

Fixed submission:
import numpy as np

n = int(input())
num_list = np.array(input().split(), dtype = np.int64)
mod = 10**9 + 7

ans = 0
for i in range(60):
    b = np.count_nonzero(num_list >> i & 1)
    if i==0:
        pow_two = 1
    else:
        pow_two = pow_two * 2 % mod
    ans += pow_two * b * (n-b) % mod
    ans %= mod
    
print(ans)
Buggy python submission (verdict: Runtime Error):
H,W = map(int,input().split())
A = np.zeros((H,W))
for c in [1,-1]:
    for i in range(H):
        num = list(map(int,input().split()))
        A[i,:] += np.array(num) * c

M = 160*80
dp = [[0]*W for _ in range(H)]
dp[0][0] = 1 << M
for i in range(H):
    for j in range(W):
        if i > 0:
            dp[i][j] |= dp[i-1][j]
        if j > 0:
            dp[i][j] |= dp[i][j-1]
        a = abs(A[i,j])
        dp[i][j] = (dp[i][j] << int(a)) | (dp[i][j] >> int(a))
i = M
while True:
    if (dp[H-1][W-1] >> i) & 1:
        print(i-M)
        break
    i += 1

Fixed submission:
import numpy as np

H,W = map(int,input().split())
A = np.zeros((H,W))
for c in [1,-1]:
    for i in range(H):
        num = list(map(int,input().split()))
        A[i,:] += np.array(num) * c

M = 160*80
dp = [[0]*W for _ in range(H)]
dp[0][0] = 1 << M
for i in range(H):
    for j in range(W):
        if i > 0:
            dp[i][j] |= dp[i-1][j]
        if j > 0:
            dp[i][j] |= dp[i][j-1]
        a = abs(A[i,j])
        dp[i][j] = (dp[i][j] << int(a)) | (dp[i][j] >> int(a))
i = M
while True:
    if (dp[H-1][W-1] >> i) & 1:
        print(i-M)
        break
    i += 1
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
l = list(map(int,input().split()))
l.sort(reverse=True)
ans = 0
 
for i in range(n-2):
    for j in reversed(range(i+2,n)):
        gap = l[i]-l[j]
        if l[j-1] > gap:
            ans += (j-i)*(j-i-1)//2
            break
        elif l[i+1] < gap:
            break
        else:
            for k in reversed(range(i+1,j)):
                if l[k] > gap:
                    ans += k-i
                    break
 
print(ans) 

Fixed submission:
import bisect

n = int(input())
l = list(map(int,input().split()))
l.sort()
ans = 0

for i in range(n-2):
    for j in range(i+1,n-1):
        ind = bisect.bisect_left(l,l[i]+l[j])
        ans += ind-j-1

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
l = list(map(int,input().split()))
l.sort(reverse=True)
ans = 0
 
for i in range(n-2):
    flag = 0
    for j in range(i+1,n-1):
        if l[i] < l[j] + l[n-1]:
            ans += n-j-1
        else:
            for k in range(j+1,n):
                if l[i] < l[j] + l[k]:
                    ans += 1
                elif k-j == 1:
                    flag = 1
                    break
                else:
                    break
        if flag:
            break
 
print(ans)

Fixed submission:
import bisect

n = int(input())
l = list(map(int,input().split()))
l.sort()
ans = 0

for i in range(n-2):
    for j in range(i+1,n-1):
        ind = bisect.bisect_left(l,l[i]+l[j])
        ans += ind-j-1

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
l = list(map(int,input().split()))
l.sort(reverse=True)
ans = 0

for i in range(n-2):
    flag = 0
    for j in range(i+1,n-1):
        for k in range(j+1,n):
            if l[i] < l[j] + l[k]:
                ans += 1
            elif k-j == 1:
                flag = 1
                break
            else:
                break
        if flag:
            break

print(ans) 

Fixed submission:
import bisect

n = int(input())
l = list(map(int,input().split()))
l.sort()
ans = 0

for i in range(n-2):
    for j in range(i+1,n-1):
        ind = bisect.bisect_left(l,l[i]+l[j])
        ans += ind-j-1

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import itertools

n = int(input())
l = list(map(int,input().split()))
a = [i for i in range(n)]
ans = 0

def abs(x):
    if x < 0:
        return -x
    else:
        return x

for x in itertools.combinations(a,3):
    if abs(l[x[0]]-l[x[1]]) < l[x[2]] < l[x[0]] + l[x[1]]:
        ans += 1

print(ans)

Fixed submission:
import bisect

n = int(input())
l = list(map(int,input().split()))
l.sort()
ans = 0

for i in range(n-2):
    for j in range(i+1,n-1):
        ind = bisect.bisect_left(l,l[i]+l[j])
        ans += ind-j-1

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline
from scipy.sparse.csgraph import floyd_warshall
    
def solve(s,t,edge):
    edge = floyd_warshall(edge)
 
    for i in range(n):
        for j in range(n):
            if edge[i][j]<=l:
                edge[i][j] = 1
            else:
                edge[i][j] = 0
 
    edge = floyd_warshall(edge)
 
    if edge[s-1][t-1] == float("inf"):
        return -1
    else:
        return int(edge[s-1][t-1] - 1)
      
n,m,l = map(int,input().split())
edge = [[0]*n for _ in range(n)]
for i in range(m):
    a,b,c = map(int,input().split())
    edge[a-1][b-1] = c
    edge[b-1][a-1] = c
    
q = int(input())
for i in range(q):
  s,t = map(int,input().split())
  print(solve(s,t,edge))

Fixed submission:
import sys
input = sys.stdin.readline
from scipy.sparse.csgraph import floyd_warshall
      
n,m,l = map(int,input().split())
edge = [[0]*n for _ in range(n)]
for i in range(m):
    a,b,c = map(int,input().split())
    edge[a-1][b-1] = c
    edge[b-1][a-1] = c

edge = floyd_warshall(edge)
    
for i in range(n):
    for j in range(n):
        if edge[i][j]<=l:
            edge[i][j] = 1
        else:
            edge[i][j] = 0
                
edge = floyd_warshall(edge)

q = int(input())
for i in range(q):
    s,t = map(int,input().split())
    if edge[s-1][t-1] == float("inf"):
        print(-1)
    else:
        print(int(edge[s-1][t-1] - 1))

Buggy python submission (verdict: Time Limit Exceeded):
from scipy.sparse.csgraph import floyd_warshall
    
def solve(s,t,edge):
    edge = floyd_warshall(edge)

    for i in range(n):
        for j in range(n):
            if edge[i][j]<=l:
                edge[i][j] = 1
            else:
                edge[i][j] = 0

    edge = floyd_warshall(edge)

    if edge[s-1][t-1] == float("inf"):
        return -1
    else:
        return int(edge[s-1][t-1] - 1)
      
n,m,l = map(int,input().split())
edge = [[0]*n for _ in range(n)]
for i in range(m):
    a,b,c = map(int,input().split())
    edge[a-1][b-1] = c
    edge[b-1][a-1] = c
    
q = int(input())
for i in range(q):
  s,t = map(int,input().split())
  print(solve(s,t,edge))

Fixed submission:
import sys
input = sys.stdin.readline
from scipy.sparse.csgraph import floyd_warshall
      
n,m,l = map(int,input().split())
edge = [[0]*n for _ in range(n)]
for i in range(m):
    a,b,c = map(int,input().split())
    edge[a-1][b-1] = c
    edge[b-1][a-1] = c

edge = floyd_warshall(edge)
    
for i in range(n):
    for j in range(n):
        if edge[i][j]<=l:
            edge[i][j] = 1
        else:
            edge[i][j] = 0
                
edge = floyd_warshall(edge)

q = int(input())
for i in range(q):
    s,t = map(int,input().split())
    if edge[s-1][t-1] == float("inf"):
        print(-1)
    else:
        print(int(edge[s-1][t-1] - 1))
Buggy python submission (verdict: Runtime Error):
import math

a,b = map(int,input().split())

n = math.gcd(a,b)
m = n
x = 2
ans = 1

while m!=1:
    if m%x !=0:
        if x==2:
            x += 1
        else:
            x += 2
        continue
    ans += 1
    while m%x == 0:
        m /= x
    if x==2:
        x += 1
    else:
        x += 2

print(ans)
    


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

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

n = gcd(a,b)
m = n
ans = 1

if m%2==0:
    ans += 1
    while m%2==0:
        m //= 2
f = 3

while f*f <= n:
    if m%f==0:
        ans += 1
        while m%f==0:
            m //= f
    f+=2

if m!=1:
    ans += 1

print(ans)

Buggy python submission (verdict: Runtime Error):
import math

a,b = map(int,input().split())

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

n = math.gcd(a,b)
m = n
x = 2
ans = 1

while m!=1:
    if m%x !=0:
        if x==2:
            x += 1
        else:
            x += 2
        continue
    ans += 1
    while m%x == 0:
        m /= x
    if x==2:
        x += 1
    else:
        x += 2

print(ans)
    


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

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

n = gcd(a,b)
m = n
ans = 1

if m%2==0:
    ans += 1
    while m%2==0:
        m //= 2
f = 3

while f*f <= n:
    if m%f==0:
        ans += 1
        while m%f==0:
            m //= f
    f+=2

if m!=1:
    ans += 1

print(ans)

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

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

n = gcd(a,b)
m = n
x = 2
ans = 1

while m!=1:
    if m%x !=0:
        if x==2:
            x += 1
        else:
            x += 2
        continue
    ans += 1
    while m%x == 0:
        m /= x
    if x==2:
        x += 1
    else:
        x += 2

print(ans)

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

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

n = gcd(a,b)
m = n
ans = 1

if m%2==0:
    ans += 1
    while m%2==0:
        m //= 2
f = 3

while f*f <= n:
    if m%f==0:
        ans += 1
        while m%f==0:
            m //= f
    f+=2

if m!=1:
    ans += 1

print(ans)

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

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

n = gcd(a,b)
m = n
x = 2
ans = 1

while m!=1:
    if m%x !=0:
        x += 1
        continue
    ans += 1
    while m%x == 0:
        m /= x
    x += 1

print(ans)

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

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

n = gcd(a,b)
m = n
ans = 1

if m%2==0:
    ans += 1
    while m%2==0:
        m //= 2
f = 3

while f*f <= n:
    if m%f==0:
        ans += 1
        while m%f==0:
            m //= f
    f+=2

if m!=1:
    ans += 1

print(ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = [list(map(int,input().split())) for _ in range(n)]

total = [0]*n

i = 0
count = 0
day = 0
while count < (n*(n-1))//2:
    while total[i] < n-1:
        game = [0] * n
        flag = False
        for j in range(i,n):
            if total[j] == n-1 or game[j] == 0:
                continue
            tmp = a[j][total[j]]
            if game[tmp-1] == 0 and a[tmp-1][total[tmp-1]] == j+1:
                total[j] += 1
                total[tmp-1] += 1
                game[j] += 1
                game[tmp-1] += 1
                count += 1
                flag = True
        if flag == False:
            break
        day += 1
    if flag == False:
        break
    i += 1

if flag == False:
    print(-1)
else:
    print(day)

Fixed submission:
s = input()
t = input()

ans = 0
for i in range(3):
    if s[i] == t[i]:
        ans += 1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

h,w,d = map(int,input().split())
a = [list(map(int,input().split())) for _ in range(h)]
q = int(input())
b = [list(map(int,input().split())) for _ in range(q)]
p =[0]*h*w
    
for i in range(h):
    for j in range(w):
        tmp = a[i][j]
        p[tmp-1] = [i,j]

def power(x,y):
    return abs(p[x-1][0]-p[y-1][0])+abs(p[x-1][1]-p[y-1][1])

for k in range(q):
    ans = 0
    l = b[k][0]
    r = b[k][1]
    while l < r:
        ans += power(l,l+d)
        l += d
    print(ans)

Fixed submission:
import numpy as np

h,w,d = map(int,input().split())
a = [list(map(int,input().split())) for _ in range(h)]
q = int(input())
b = [list(map(int,input().split())) for _ in range(q)]
p =[0]*(h*w+1)
    
for i in range(h):
    for j in range(w):
        tmp = a[i][j]
        p[tmp] = [i,j]
cost = [0]*(h*w+1)
i = d+1
while i <= h*w:
    cost[i] = cost[i-d] + abs(p[i][0]-p[i-d][0]) + abs(p[i][1]-p[i-d][1])
    i += 1
for k in range(q):
    r = b[k][0]
    l = b[k][1]
    print(cost[l]-cost[r])
Buggy python submission (verdict: Runtime Error):
n = int(input())
Flg = True
for _ in range(n):
    t, x, y = map(int, input().split())
    xy = x+y
    if t >= (xy):
        if ((t % 2 != 0) & (xy % 2 == 0)) or (t % 2 == 0 & xy % 2 != 0):
            Flg = False
    else:
        Flg = False
if Flg == True:
    print("Yes")
else:
    print("No")

Fixed submission:
# -*- coding: utf-8 -*-
a,b = map(int, input().split())
N = a * b
if N % 2 != 0:
    print("Odd")
else:
    print("Even")
Buggy python submission (verdict: Time Limit Exceeded):
import sys
import heapq
input = sys.stdin.readline

n, m = map(int, input().split())
li = [-int(i) for i in input().split()]

for _ in range(m):
	heapq.heapify(li) 
	x = heapq.heappop(li)
	if x % 2 == 0:
		heapq.heappush(li, x // 2)
	else:
		heapq.heappush(li, x // 2 + 1)
print(-sum(list(li)))



Fixed submission:
import sys
import heapq
input = sys.stdin.readline

n, m = map(int, input().split())
li = [-int(i) for i in input().split()]
li = sorted(li)

for _ in range(m):
	x = heapq.heappop(li)
	#print(x)
	if x % 2 == 0:
		heapq.heappush(li, x // 2)
	else:
		heapq.heappush(li, x // 2 + 1)
	#print(li)
print(-sum(list(li)))

Buggy python submission (verdict: Runtime Error):
import sys
import heapq
input = sys.stdin.readline

n, m = map(int, input().split())
li = list(map(int, input().split()))

for _ in range(m):
	heapq._heapify_max(li) 
	x = heapq._heappop_max(li)
	heapq.heappush(li, x // 2)
print(sum(list(li)))



Fixed submission:
import sys
import heapq
input = sys.stdin.readline

n, m = map(int, input().split())
li = [-int(i) for i in input().split()]
li = sorted(li)

for _ in range(m):
	x = heapq.heappop(li)
	#print(x)
	if x % 2 == 0:
		heapq.heappush(li, x // 2)
	else:
		heapq.heappush(li, x // 2 + 1)
	#print(li)
print(-sum(list(li)))

Buggy python submission (verdict: Runtime Error):
import sys
import heapq
input = sys.stdin.readline

n, m = map(int, input().split())
li = list(map(int, input().split()))

for _ in range(m):
	heapq._heapify_max(li) 
	x = heapq._heappop_max(li)
	heapq.heappush(li, x // 2)
print(sum(list(li)))



Fixed submission:
import sys
import heapq
input = sys.stdin.readline

n, m = map(int, input().split())
li = [-int(i) for i in input().split()]
li = sorted(li)

for _ in range(m):
	x = heapq.heappop(li)
	#print(x)
	if x % 2 == 0:
		heapq.heappush(li, x // 2)
	else:
		heapq.heappush(li, x // 2 + 1)
	#print(li)
print(-sum(list(li)))