Harryxun/GPT-100-sft-dataset huggingface dataset:
Problem p03075 (python)

Fixed submission:
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())

x = [a,b,c,d,e]

x.sort()
if x[4] - x[0] <= k:
    print("Yay!")
else:
    print(":(")

Buggy submission (verdict: Runtime Error):
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())
hantei = 0

x = [a,b,c,d,e]

for i in x:
 for j in x:
    if i - j > k:
        hantei.append(1)


if hantei == 0:
    print("Yay!")
else:
    print(":(")

Buggy submission (verdict: Runtime Error):
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())
hantei = 0

x = [a,b,c,d,e]

for i in x:
 for j in x:
    if i - j > k:
        hantei.append(1)


if hantei == 0:
    print("Yay!")
else:
    print(":(")
Problem p02989 (python)

Fixed submission:
import sys
from collections import Counter
from operator import itemgetter, attrgetter
n=0
 
n = input()
d_list= list(map(int, input().split()))
cou=sorted(Counter(d_list).most_common())
total=len(d_list)
# print(n)
# print(cou)
# print(total)
index=0
before=0
after=0
first=True
t=0
for c in cou:
#     print(c)
    if first:
        before = c
        first=False
    else:
        before = cou[index-1]
    after = c
    t+=c[1]
    if t > total/2:
        break
    index+=1
# print(before)
# print(after)
# print(len(cou[index:]))
if not(sum(n for _, n in cou[index:]) == sum(n for _, n in cou[:index])):
    print(0)
else:
    print(after[0]-before[0])

Buggy submission (verdict: Runtime Error):
import sys
from collections import Counter
from operator import itemgetter, attrgetter
n=0
 
n = input()
d_list= list(map(int, input().split()))
cou=sorted(Counter(d_list).most_common())
total=len(d_list)
# print(n)
# print(cou)
# print(total)
index=0
before=0
after=0
first=True
t=0
if n == 0:
    print(0)
for c in cou:
#     print(c)
    if first:
        before = c
        first=False
    before = after
    after = c
    t+=c[1]
    if t > total/2:
        break
    index+=1
# print(before)
# print(after)
# print(len(cou[index:]))
if not(len(cou[index:]) == total/2):
    print(0)
else:
    print(after[0]-before[0])

Buggy submission (verdict: Runtime Error):
import sys
from collections import Counter
from operator import itemgetter, attrgetter
n=0
 
n = input()
d_list= list(map(int, input().split()))
cou=sorted(Counter(d_list).most_common())
total=len(d_list)
index=0
before=0
after=0
first=True
t=0
for c in cou:
    if first:
        before = c
        first=False
    before = after
    after = c
    t+=c[1]
    if t > total/2:
        break
    index+=1
if not(len(cou[index:]) == total/2):
    print(0)
else:
    print(after[0]-before[0])
Problem p02987 (python)

Fixed submission:
a=map(str, input())
char=list(a)
b=set(char)
c=len(b)
if c==2:
	print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
a=map(str, input())
char=list(a)
b=set(char)
c=len(b)
if c=2:
	print("Yes")
else:
  print("No")
Problem p03135 (python)

Fixed submission:
x,y= map(int, input().split(" "))
print(x/y)

Buggy submission (verdict: Runtime Error):
a=input()
c=list(map(int, input().split()))
 
#from statistics import mean, median,variance,stdev
 
if sum(c)-max(c)< max(c):
    print("No")
else:
    print("Yes")

Buggy submission (verdict: Runtime Error):
a=input()
c=list(map(int, input().split(" ")))
 
from statistics import mean, median,variance,stdev
 
if sum(list1)-max(list1)< max(list1):
    print("Yes")
else:
    print("No")
Problem p03013 (python)

Fixed submission:
import sys
 
n, m = list(map(int, input().split()))
if m > 0:
    aaa = set(map(int, sys.stdin))
else:
    aaa = set()
dp = [0] * (n + 1)
dp[0] = 1
dp[1] = 1 if 1 not in aaa else 0
MOD = 10 ** 9 + 7
 
for i in range(2, n + 1):
    if i in aaa:
        continue
    dp[i] = (dp[i - 2] + dp[i - 1]) % MOD
print(dp[n])

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

broken = []
for _ in range(M):
  broken.append(int(input()))

mod = 10 ** 9 + 7
f = [0] * N
f[1] = 1
for i in range(1, N + 1):
  if i in broken:
    if i - 1 in broken:
      print(0)
      exit()
    continue
  f[i] = f[i-2] + f[i-1]
print(f[N] % mod)

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

broken = []
for _ in range(M):
  broken.append(int(input()))

mod = 10 ** 9 + 7
f2, f1 = 0, 1
for i in range(1, N + 1):
  if i in broken:
    if i - 1 in broken:
      print(0)
      exit()
    f2 = f1
    f1 = 0
    continue
  f = f2 + f1
  f2 = f1
  f1 = f
print(f % mod)N, M = map(int, input().split())

broken = []
for _ in range(M):
  broken.append(int(input()))

mod = 10 ** 9 + 7
f2, f1 = 0, 1
for i in range(1, N + 1):
  if i in broken:
    if i - 1 in broken:
      print(0)
      exit()
    f2 = f1
    f1 = 0
    continue
  f = f2 + f1
  f2 = f1
  f1 = f
print(f % mod)
Problem p03013 (python)

Fixed submission:
def fib(n):
  a, b = 0, 1
  for i in range(n):
    a, b = b, a + b
    if b > 1000000007:
      b -= 1000000007
  return b

n,m=map(int,input().split())
if m==0:
  ans=fib(n)
else:
  a=[int(input()) for i in range(m)]
  ans = fib(a[0]-1)%1000000007
  for i in range(m-1):
    if a[i+1]-a[i]==1:
      ans=0
      break
    ans = ans*fib(a[i+1]-a[i]-2)%1000000007
  ans = ans*fib(n-a[m-1]-1)%1000000007
print(ans)

Buggy submission (verdict: Runtime Error):
def fib(n):
  a, b = 0, 1
  for i in range(n):
    a, b = b, a + b
  return b

n,m=map(int,input().split())
a=[int(input()) for i in range(m)]
ans = fib(a[0]-1)%1000000007
for i in range(m-1):
  if a[i+1]-a[i]==1:
    ans=0
    break
  ans = ans*fib(a[i+1]-a[i]-2)%1000000007
ans = ans*fib(n-a[m-1]-1)%1000000007
print(ans)
Problem p03774 (python)

Fixed submission:
n,m = map(int,input().split())
a=[]
b=[]
c=[]
d=[]
for i in range(n):
    a1,b1=map(int,input().split())
    a.append(a1)
    b.append(b1)
for i in range(m):
    c1,d1=map(int,input().split())
    c.append(c1)
    d.append(d1)
for i in range(n):
    min_len = 1000000000
    cnt = None
    for j in range(m):
        len = abs(c[j]-a[i])+abs(d[j]-b[i])
        if len < min_len:
            min_len=len
            cnt = j+1
    print(cnt)

Buggy submission (verdict: Runtime Error):
n,m = map(int,input().split())
a=[]
b=[]
c=[]
d=[]
for i in range(n):
    a1,b1=map(int,input().split())
    a.append(a1)
    b.append(b1)
for i in range(m):
    c1,d1=map(int,input().split())
    c.append(c1)
    d.append(d1)
for i in range(n):
    min_len = 100000000
    for j in range(m):
        len = abs(c[j]-a[i])+abs(d[j]-b[i])
        if len < min_len:
            min_len=len
            cnt = j+1
    print(cnt)
Problem p03013 (python)

Fixed submission:
N, M = map(int, input().split())
z = [-1] * (N+1)
for i in range(M):
     z[int(input())] = 0

for i, x in enumerate(z):
     if i == 0:
          z[i] = 1
     elif i == 1 and z[i] != 0:
          z[i] = 1
     elif z[i] == 0:
          continue
     elif z[i-1] == 0 and z[i-2] == 0:
          print(0)
          exit()
     else:
          z[i] = z[i-1] + z[i-2]
print(z[-1] % 1000000007)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
z = [-1] * (N+1)
for i in range(M):
     z[int(input())] = 0

def rootCount(x):
     if x == 0:
          z[x] = 1
          return 1
     elif x == 1:
          if z[x] == 0:
               return 0
          else:
               z[x] = 1
               return 1
     elif x < N+1 and z[x] != -1:
          return z[x]
     else:
          z[x] = rootCount(x-1) + rootCount(x-2)
          return z[x]
print(rootCount(N) % 1000000007)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
a = [int(input()) for i in range(M)] 
z = [0] * (N+1)
def rootCount(x):
     if x in a:
          z[x] = 0
          return 0
     elif x == 0:
          z[x] = 1
          return 1
     elif x == 1:
          z[x] = 1
          return 1
     elif x < N+1 and z[x] != 0:
          return z[x]
     else:
          z[x] = rootCount(x-1) + rootCount(x-2)
          return z[x]
print(rootCount(N) % 1000000007)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
a = [int(input()) for i in range(M)] 
z = [0] * (N+1)
for i, aa in enumerate(a):
     if 0 < i and (a[i] - a[i-1]) == 1:
          print(0)
          exit()

def rootCount(x):
     if x in a:
          z[x] = 0
          return 0
     elif x == 0:
          z[x] = 1
          return 1
     elif x == 1:
          z[x] = 1
          return 1
     elif x < N and z[x] != 0:
          return z[x]
     else:
          z[x] = rootCount(x-1) + rootCount(x-2)
          return z[x]
print(rootCount(N) % 1000000007)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
a = [int(input()) for i in range(M)] 
z = [0] * (N+1)

def rootCount(x):
     if x in a:
          z[x] = 0
          return 0
     elif x == 0:
          z[x] = 1
          return 1
     elif x == 1:
          z[x] = 1
          return 1
     elif x < N and z[x] != 0:
          return z[x]
     else:
          z[x] = rootCount(x-1) + rootCount(x-2)
          return z[x]
print(rootCount(N) % 1000000007)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
a = [int(input()) for i in range(M)] 
z = [0] * (N+1)

def rootCount(x):
     print(x)
     if x in a:
          z[x] = 0
          return 0
     elif x == 0:
          z[x] = 1
          return 1
     elif x == 1:
          z[x] = 1
          return 1
     elif x < N and z[x] != 0:
          print("hit " + str(x))
          print(z)
          return z[x]
     else:
          print(x,x-1,x-2)
          print(z)
          z[x] = rootCount(x-1) + rootCount(x-2)
          return z[x]
print(rootCount(N) % 1000000007)
Problem p02989 (python)

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

dlist.sort()
N = int(N/2)
print(dlist[N]-dlist[N-1])

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

dlist.sort()
print(dlist[N/2]-dlist[N/2-1])
Problem p03242 (python)

Fixed submission:
n = list(input())
count = 0

for i in n:
    if i == "1":
        n[count] = "9"
    elif i == "9":
        n[count] = "1"
    count += 1

print("".join(n))

Buggy submission (verdict: Runtime Error):
n = list(input())
count = 0

for i in n:
    if i == "1":
        n[count] = "9"
    elif i == "9":
        n[count] = "1"
    count += 1

print("".job(n))
Problem p03631 (python)

Fixed submission:
N = input()

N1 = N[2]+N[1]+N[0]
if N == N1:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
N = input().split
N1 = list(reversed(N))
if N == N1:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
N = input().split
 
if N == list(reversed(N)):
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
N = input().split
 
if N == list(reversed(N)):
    print("Yes")
Problem p03835 (python)

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

print(ct)

Buggy submission (verdict: Runtime Error):
K, S = map(int, input().split())
ct = 0
for i in range(K + 1):
    for j in range(K + 1):
        a = S - i - j
        if 0 <= a <= k:
            ct += 1

print(ct)
Problem p03013 (python)

Fixed submission:
n, m = map(int,input().split())
dangerList = [int(input()) for i in range(m)]
answerList = [0] * (n+2)
answerList[0] = 1
nextDanger = n + 2
if len(dangerList) > 0:
  nextDanger = dangerList.pop(0)
for i in range(n):
  if i == nextDanger:
    if len(dangerList) > 0:
    	nextDanger = dangerList.pop(0)
  else:
    answerList[i+1] = (answerList[i+1] + answerList[i]) % 1000000007
    answerList[i+2] = (answerList[i+2] + answerList[i]) % 1000000007
print(answerList[n])

Buggy submission (verdict: Runtime Error):
n, m = map(int,input().split())
dangerList = [int(input()) for i in range(m)]
answerList = [0] * (n+2)
answerList[0] = 1
nextDanger = dangerList.pop(0)
for i in range(n):
  if i == nextDanger:
    if len(dangerList) > 0:
    	nextDanger = dangerList.pop(0)
  else:
    answerList[i+1] = (answerList[i+1] + answerList[i]) % 1000000007
    answerList[i+2] = (answerList[i+2] + answerList[i]) % 1000000007
print(answerList[n])
Problem p03033 (python)

Fixed submission:
import sys
input = sys.stdin.readline
ri = lambda: int(input())
rl = lambda: [int(x) if x.isdecimal() else x for x in input().split()]
#rl = lambda: list(input().split()))
rr = lambda N: [list(l) for l in zip(*[rl() for _ in range(N)])]
YN = lambda b: print('YES') if b else print('NO')
yn = lambda b: print('Yes') if b else print('No')
OE = lambda x: print('Odd') if x%2 else print('Even')
INF = 10**18
MOD = 10**9+7


N,Q=rl()
TT = []
now = set()
for _ in range(N):
    s,t,x = rl()
    TT.append((s-x-0.5,1,x))
    TT.append((t-x-0.5,-1,x))
for i in range(Q):
    d = ri()
    TT.append((d,0,i))


TT.sort()
mx = INF
mx_f = False
ans = [-1]*Q
for st,w,x in TT:
    if w > 0:
        now.add(x)
        if mx > x:
            mx = x
            mx_f = True
    elif w < 0:
        now.remove(x)
        if mx == x:
            mx_f = False
    elif len(now) > 0:
        if not mx_f:
            mx = min(now)
            mx_f = True
        ans[x] = mx
print(*ans,sep='\n')

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
ri = lambda: int(input())
rl = lambda: [int(x) if x.isdecimal() else x for x in input().split()]
rl = lambda: list(input().split()))
rr = lambda N: [list(l) for l in zip(*[rl() for _ in range(N)])]
YN = lambda b: print('YES') if b else print('NO')
yn = lambda b: print('Yes') if b else print('No')
OE = lambda x: print('Odd') if x%2 else print('Even')
INF = 10**18
MOD = 10**9+7


N,Q=rl()
TT = []
now = set()
for _ in range(N):
    s,t,x = rl()
    TT.append((s-x-0.5,1,x))
    TT.append((t-x-0.5,-1,x))
for i in range(Q):
    d = ri()
    TT.append((d,0,i))


TT.sort()
mx = INF
mx_f = False
ans = [-1]*Q
for st,w,x in TT:
    if w > 0:
        now.add(x)
        if mx > x:
            mx = x
            mx_f = True
    elif w < 0:
        now.remove(x)
        if mx == x:
            mx_f = False
    elif len(now) > 0:
        if not mx_f:
            mx = min(now)
            mx_f = True
        ans[x] = mx
print(*ans,sep='\n')
Problem p03127 (python)

Fixed submission:
N = int(input())
A = [int(i) for i in input().split()]

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

a = A[0]
for i in range(1,N):
    a = gcp(a,A[i])
print(a)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = [int(i) for i in input().split()]

import math
import itertools

m = min(A)

for v in itertools.combinations(A,2):
    m1 = math.gcd(*v)
    if m > m1:
        m = m1
print(m)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = [int(i) for i in input().split()]

import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)

print(gcd(*A))
Problem p03221 (python)

Fixed submission:
ri = lambda: int(input())
rl = lambda: list(map(int,input().split()))
rr = lambda N: [ri() for _ in range(N)]
YN = lambda b: print('YES') if b else print('NO')
INF = 10**18

N,M=rl()
P=[0]*M
Y=[0]*M
dic = [[] for _ in range(N+1)]
for i in range(M):
    P[i],Y[i] = rl()
    dic[P[i]] += [Y[i]]

for i in range(N+1):
    dic[i].sort()

import bisect
for i in range(M):
    print("{:0>6}{:0>6}".format(P[i], bisect.bisect_left(dic[P[i]],Y[i])+1))

Buggy submission (verdict: Runtime Error):
2 3
2 55
2 77
2 99
Problem p02987 (python)

Fixed submission:
s = input()
l = len(s)
set_s = set(s)

if l == 4 and len(set_s) == 2:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
s = input()
l = len(s)
set_s = set(s)

if l == 4 and len(a) == 2:
    print('Yes')
else:
    print('No')
Problem p02989 (python)

Fixed submission:
import numpy as np

N = int(input())
D = input()
D =  D.split(' ')
D = [int(d) for d in D]
D_sort = np.sort(D)

k = int(N/2)
count = 0

low_d = D_sort[k-1]
hight_D = D_sort[k]
dis = hight_D - (low_d+1) + 1

print(dis)

Buggy submission (verdict: Runtime Error):
N = int(input())
D = input()
D =  D.split(' ')
D = [int(d) for d in D]
D_sort = np.sort(D)

k = int(N/2)
count = 0

low_d = D_sort[k-1]
hight_D = D_sort[k]
dis = hight_D - (low_d+1) + 1

print(dis)
Problem p03075 (python)

Fixed submission:
inp = []
for i in range(6):
    inp.append(int(input()))
k = inp[4] - inp[0]
if k > inp[5]:
    print(':(')
else:
    print('Yay!')

Buggy submission (verdict: Runtime Error):
inp = []
for i in range(6):
    inp.append(insert(input()))
k = inp[4] - inp[0]
if k > inp[5]:
    print(':(')
else:
    print('Yay!')
Problem p03013 (python)

Fixed submission:
N, M=map(int, input().split())
a=[int(input()) for _ in range(M)]
tmp=[1,1,2]
for i in range(N):
    tmp.append(tmp[-1]+tmp[-2])
def func(x):
    if x==-1:
        return 0
    elif x==-2:
        return 1
    else:
        return tmp[x]

if M==0:
    print(func(N)%1000000007)
    exit(0)
s=func(a[0]-1)
for i in range(0, M-1):
    s*=func(a[i+1]-a[i]-2)
s*=func(N-a[M-1]-1)
print(s%1000000007)

Buggy submission (verdict: Runtime Error):
N, M=map(int, input().split())
a=[int(input()) for _ in range(M)]
tmp=[1,1,2]
for i in range(N):
    tmp.append(tmp[-1]+tmp[-2])
def func(x):
    if x==-1:
        return 0
    elif x==-2:
        return 1
    else:
        return tmp[x]

s=func(a[0]-1)
for i in range(0, M-1):
    s*=func(a[i+1]-a[i]-2)
s*=func(N-a[M-1]-1)
print(s%1000000007)

Buggy submission (verdict: Runtime Error):
N, M=map(int, input().split())
a=[int(input()) for _ in range(M)]
tmp=[1,1,2]
for i in range(N):
    tmp.append(tmp[-1]+tmp[-2])
def func(x):
    if x==-1:
        return 0
    else:
        return tmp[x]

s=func(a[0]-1)
for i in range(0, M-1):
    s*=func(a[i+1]-a[i]-2)
s*=func(N-a[M-1]-1)
print(s%1000000007)

Buggy submission (verdict: Runtime Error):
N, M=map(int, input().split())
a=[int(input()) for _ in range(M)]

def func(x):
    if x==0:
        return 1
    elif x==-1:
        return 0
    else:
        return 2**(x-1)

s=func(a[0]-1)
for i in range(0, M-1):
    s*=func(a[i+1]-a[i]-2)
s*=func(N-a[M-1]-1)
print(s%1000000007)
Problem p03201 (python)

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

A.sort(reverse=True)
dic={}
for a in A:
    dic[a]=dic.get(a,0)+1

ans=0

for a in A:
    small=(1<<(len(format(a,"b")))) -a
    if small==a:
        if dic[a]>=2:
            dic[a]-=2
            ans+=1
        continue
    if dic.get(a,0)>0 and dic.get(small,0)>0:
        dic[a]-=1
        dic[small]-=1
        ans+=1
print(ans)

Buggy submission (verdict: Runtime Error):
N=int(input())
A=list(map(int, input().split()))
odd=[]
even=[]
for i in A:
    if i%2:
        odd.append(i)
    else:
        even.append(i)

ls=[]
for i in range(30):
    ls.append(2<<i)

ans=0
for i in range(len(odd)):
    ct=0
    for j in range(len(odd)-1):
        if i!=j:
            if odd[i]+odd[j] in ls:
                ct+=1
                tmpi=i
                tmpj=j
    if ct==1:
        odd.pop(tmpi)
        odd.pop(tmpj)
        ans+=1
for i in range(len(even)):
    ct=0
    for j in range(len(even)-1):
        if i!=j:
            if even[i]+even[j] in ls:
                ct+=1
                tmpi=i
                tmpj=j
    if ct==1:
        even.pop(tmpi)
        even.pop(tmpj)
        ans+=1
print(ans)
Problem p03272 (python)

Fixed submission:
N, i=list(map(int,input().split()))
print(N+1-i)

Buggy submission (verdict: Runtime Error):
N, i=list(map(int,input().split()))
print(N+1-K)
Problem p03286 (python)

Fixed submission:
N=-int(input())
if N==0:
    print(0)
else:
    tmp=[]
    while N!=0:
        tmp.insert(0,N%(2))
        N=-N//2
    s=''.join([str(_) for _ in tmp])
    print(s)

Buggy submission (verdict: Runtime Error):
N=-int(input())
if N=0:
    print(0)
else:
    tmp=[]
    while N!=0:
        tmp.insert(0,N%(2))
        N=-N//2
    s=''.join([str(_) for _ in tmp])
    print(s)
Problem p03426 (python)

Fixed submission:
H, W, D=map(int, input().split())
pos={}
for i in range(H):
    A=list(map(int, input().split()))
    for j in range(W):
        pos[A[j]]=(i, j)
p=[0]*(H*W+1)
for i in range(D+1,H*W+1):
    p[i]=p[i-D]+abs(pos[i][0]-pos[i-D][0])+abs(pos[i][1]-pos[i-D][1])
Q=int(input())
for _ in range(Q):
    L, R=map(int, input().split())
    print(p[R]-p[L])

Buggy submission (verdict: Runtime Error):
H, W, D=map(int, input().split())
pos={}
for i in range(H):
    A=list(map(int, input().split()))
    for j in range(W):
        pos[A[j]]=(i, j)
p=[0]*(H*W)
for i in range(D+1,H*W):
    p[i]=p[i-D]+abs(pos[i][0]-pos[i-D][0])+abs(pos[i][1]-pos[i-D][1])
Q=int(input())
for _ in range(Q):
    L, R=map(int, input().split())
    print(p[R]-p[L])

Buggy submission (verdict: Runtime Error):
H, W, D=map(int, input().split())
pos={}
for i in range(H):
    A=list(map(int, input().split()))
    for j in range(W):
        pos[A[j]]=(i, j)
p=[0]*(H*W)
for i in range(D+1,H*W+1):
    p[i]=p[i-D]+abs(pos[i][0]-pos[i-D][0])+abs(pos[i][1]-pos[i-D][1])
Q=int(input())
for _ in range(Q):
    L, R=map(int, input().split())
    print(p[R]-p[L])

Buggy submission (verdict: Runtime Error):
H, W, D=map(int, input().split())
pos={}
for i in range(H):
    A=list(map(int, input().split()))
    for j in range(W):
        pos[A[j]]=(i, j)
Q=int(input())
p=[0]*(H*W)
for i in range(D+1,H*W):
    p[i]=p[i-D]+abs(pos[i][0]-pos[i-D][0])+abs(pos[i][1]-pos[i-D][1])
for i in range(Q):
    L, R=map(int, input().split())
    print(p[R]-p[L])

Buggy submission (verdict: Runtime Error):
H, W, D=map(int, input().split())
pos={}
for i in range(H):
    A=list(map(int, input().split()))
    for j in range(W):
        pos[A[j]]=(i, j)
Q=int(input())
p=[0 for _ in range(H*W)]
for i in range(D+1,H*W):
    p[i]=p[i-D]+abs(pos[i][0]-pos[i-D][0])+abs(pos[i][1]-pos[i-D][1])
for i in range(Q):
    L, R=map(int, input().split())
    print(p[R]-p[L])
Problem p03803 (python)

Fixed submission:
A,B=map(int, input().split())
if A==1:
    A=14
if B==1:
    B=14
if A>B:
    print('Alice')
elif A==B:
    print('Draw')
else:
    print('Bob')

Buggy submission (verdict: Runtime Error):
N,M=map(int, input().split())
A=[input() for _ in range(N)]
B=[input() for _ in range(M)]

for i in range(N-M+1):
    for j in range(N-M+1):
        t=[k[j:j*m] for k in a[i:i+m]]
        if t==B:
            print('Yes')
            exit()
print('No')
Problem p03804 (python)

Fixed submission:
N,M=map(int, input().split())
A=[input() for _ in range(N)]
B=[input() for _ in range(M)]

for i in range(N-M+1):
    for j in range(N-M+1):
        t=[k[j:j+M] for k in A[i:i+M]]
        if t==B:
            print('Yes')
            exit()
print('No')

Buggy submission (verdict: Runtime Error):
N,M=map(int, input().split())
A=[input() for _ in range(N)]
B=[input() for _ in range(M)]

for i in range(N-M+1):
    for j in range(N-M+1):
        t=[k[j:j+m] for k in a[i:i+m]]
        if t==B:
            print('Yes')
            exit()
print('No')

Buggy submission (verdict: Runtime Error):
N,M=map(int, input().split())
A=[input() for _ in range(N)]
B=[input() for _ in range(M)]

for i in range(N-M+1):
    for j in range(N-M+1):
        t=[k[j:j*m] for k in a[i:i+m]]
        if t==B:
            print('Yes')
            exit()
print('No')

Buggy submission (verdict: Runtime Error):
N,M=map(int, input().split())
A=[input() for _ in range(N)]
B=[input() for _ in range(M)]

for i in range(N):
    if B[0] in A[i]:
        if all(B[j] in A[i+j] for j in range(1,min(M,N-i)):
            print('Yes')
            exit(0)
print('No')

Buggy submission (verdict: Runtime Error):
N,M=map(int, input().split())
A=[input() for _ in range(N)]
B=[input() for _ in range(M)]

for i in range(N):
    if B[0] in A[i]:
        if all(B[j] in A[i+j] for j in range(1,M)):
            print('Yes')
            exit(0)
print('No')