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

Fixed submission:
s=input()
place=[]
for i in range(1,len(s)):
  if s[i]!=s[i-1]:
    place.append(i)
ans=[0 for i in range(len(s))]
cur_p=place[0]
cur_p_i=0
is_l=False
set_place=set(place)
for i in range(len(s)):
  if i in set_place:
    if is_l:
      cur_p_i+=2
      cur_p=place[cur_p_i]
    is_l=not is_l
  if (i-cur_p)%2==0:
    ans[cur_p]+=1
  else:
    ans[cur_p-1]+=1
print(" ".join(map(str,ans)))

Buggy submission (verdict: Runtime Error):
s=input().split()
place=[]
for i in range(len(s)-1):
  if s[i]!=s[i+1]:
    place.append(i)
ans=[0 for i in range(len(s))]
cur_p=place[0]
cur_p_i=0
for i in range(len(s)):
  if i>=cur_p:
    cur_p_i+=1
    cur_p=place[cur_p_i]
  if (i-cur_p)%2==0:
    ans[cur_p]+=1
  else:
    ans[cur_p+1]+=1
print(" ".join(ans))

Buggy submission (verdict: Runtime Error):
s=input().split()
place=[]
for i in range(len(s)-1):
  if s[i]!=s[i+1]:
    place.append(i)
ans=[0 for i in range(len(s))]
cur_p=place[0]
cur_p_i=0
for i in range(len(s)):
  if i>=cur_p:
    cur_p_i+=1
    cur_p=place[cur_p_i]
  if (i-cur_p)%2=0:
    ans[cur_p]+=1
  else:
    ans[cur_p+1]+=1
print(" ".join(ans))
Problem p03017 (python)

Fixed submission:

n,a,b,c,d = map(int,input().split())
s = input()
s = s + "."
cant = 0
sanrenzoku = 0
for i in range(a-1,max(c-1,d-1)):
    if s[i] == "#":
        if s[i+1] == "#":
            cant = 1

if c > d:
    for i in range(b-2,d-1):
        if s[i] == ".":
            if s[i+1] == ".":
                if s[i+2] == ".":
                   sanrenzoku = 1

if cant == 1:
    print("No")
elif c > d:
    if sanrenzoku == 0:
        print("No")
    else:
        print("Yes")
else:
    print("Yes")

Buggy submission (verdict: Runtime Error):

n,a,b,c,d = map(int,input().split())
s = input()
s = s + "."
cant = 0
sanrenzoku = 0
for i in range(a-1,max(c-1,d-1)):
    if s[i] == "#":
        if s[i+1] == "#":
            cant = 1

if c > d:
    for i in range(b-2,d-1)
    if s[i] == ".":
        if s[i+1] == ".":
            if s[i+2] == ".":
                if i > b-2:
                    if i < d:
                        sanrenzoku = 1

if cant == 1:
    print("No")
elif c > d:
    if sanrenzoku == 0:
        print("No")
    else:
        print("Yes")
else:
    print("Yes")

Buggy submission (verdict: Runtime Error):
n,a,b,c,d = map(int,input().split())
s = input()
s = s + "."
cant = 0
sanrenzoku = 0
for i in range(a+1,d+1):
    if s[i] == "#":
        if s[i+1] == "#":
            cant = 1
    if c > d:
        if s[i] == ".":
            if s[i+1] == ".":
                if s[i+2] == ".":
                    if i > b-2:
                        if i < d:
                            sanrenzoku = 1

if cant == 1:
    print("No")
elif c > d:
    if sanrenzoku == 0:
        print("No")
    else:
        print("Yes")
else:
    print("Yes")

Buggy submission (verdict: Runtime Error):
n,a,b,c,d = map(int,input().split())
s = input()
cant = 0
sanrenzoku = 0
for i in range(a,d):
    if s[i] == "#":
        if s[i+1] == "#":
            cant = 1
    if c > d:
        if s[i] == ".":
            if s[i+1] == ".":
                if s[i+2] == ".":
                    if i > b-2:
                        if i < d:
                            sanrenzoku = 1

if cant == 1:
    print("No")
elif c > d:
    if sanrenzoku == 0:
        print("No")
    else:
        print("Yes")
else:
    print("Yes")
Problem p03041 (python)

Fixed submission:
a,b=map(int, input().split())
c=list(input())
henka = c.pop(b-1)
if henka=="A":
    c.insert(b-1,"a")
elif henka=="B":
    c.insert(b-1,"b")
else:
    c.insert(b-1,"c")
print(''.join(c))

Buggy submission (verdict: Runtime Error):
a,b=map(int, input().split())
c=input()
if c[b-1]=="A":
    c[b-1]="a"
elif c[b-1]=="B":
    c[b-1]="b"
else:
    c[b-1]="c"
print(''.join(c))
Problem p02659 (python)

Fixed submission:
a, b = input().split()
a = int(a)
b = int(float(b) * 1000)
x = (a * b) // 1000
print(x)

Buggy submission (verdict: Runtime Error):
a, b = input().split()
a = int(a)
b = int(b * 1000)
x = int((a * b) // 1000)
print(x)
Problem p02859 (python)

Fixed submission:
r = int(input())
print(r ** 2)

Buggy submission (verdict: Runtime Error):
N = int(input())
S = input()
T = list()
for i in range(int(N / 2), N):
    t = S[i]
    T.append(t)
y = 0
n = 0
for i, k in zip(T, S):
    if i == k:
        y += 1
    else:
        n += 1
if N % 2 != 0:
    print('No')
elif y == int(N / 2):
    print('Yes') 
else:
    print('No')

Buggy submission (verdict: Runtime Error):
N = int(input())
S = input()
T = list()
for i in range(int(N / 2), N):
    t = S[i]
    T.append(t)
y = 0
n = 0
for i, k in zip(T, S):
    if i == k:
        y += 1
    else:
        n += 1
if y == int(N / 2):
    print('Yes') 
else:
    print('No')

Buggy submission (verdict: Runtime Error):
r = input()
print(r ** 2)
Problem p02723 (python)

Fixed submission:
s = input()
if s[2]==s[3] and s[4]==s[5]:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
s = input()
if s[2]==s[3] and s[4]==s[5]:
    print('Yes')
else:
    printt('No')
Problem p02729 (python)

Fixed submission:
A = list(map(int, input().split()))
N = A[0]
M = A[1]

# 偶数＋偶数
pattern_1 = N*(N-1)/2

# 奇数＋奇数
pattern_2 = M*(M-1)/2

print(int(pattern_1 + pattern_2))

Buggy submission (verdict: Runtime Error):
N = int(input())
M = int(input())

pattern_1 = N*(N-1)/2
pattern_2 = M*(M-1)/2

print(pattern_1 + pattern_2)

Buggy submission (verdict: Runtime Error):
N = int(input())
M = int(input())

# 偶数＋偶数
pattern_1 = N*(N-1)/2

# 奇数＋奇数
pattern_2 = M*(M-1)/2

print(pattern_1 + pattern_2)
Problem p02682 (python)

Fixed submission:
a,b,c,k=map(int, input().split())
ans =0
if a>=k:
	ans+=k
else:
	ans+=a
if k-a-b>=1:
	ans+=-(k-a-b)
print(ans)

Buggy submission (verdict: Runtime Error):
a,b,c,k=map(int, input().split())
ans =0
if a>=k:
	ans+=k
else:
	ans+=a
if =k-a-b>=1:
	ans+=-(k-a-b)
print(ans)
Problem p02712 (python)

Fixed submission:
n = int(input())
ans = 0
for i in range(1,n+1):
    if i%3 != 0 and i%5 != 0:
        ans += i
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
for i in range(1,n+1):
    if i%3 != 0 and i%5 != 0:
        ans += i
print(ans)
Problem p02729 (python)

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

def c(s,t):
    if s == 0 or s == 1:
        return 0
    return math.factorial(s)/(math.factorial(s-t)*math.factorial(t))

print(int(c(n,2)+c(m,2)))

Buggy submission (verdict: Runtime Error):
import math
n,m = map(int, input().split())

def c(s,t):
    if s == 0 or s == 1:
        return 0
    return math.factorial(s)/(math.factorial(s-t)*math.fatorial(t))

print(c(n,2)+c(m,2))
Problem p02753 (python)

Fixed submission:
s = str(input())
if s == 'BBB' or s == 'AAA':
    print('No')
else:
    print('Yes')

Buggy submission (verdict: Runtime Error):
a,b = map(int,input().split())
for x in range(b * 10,(b + 1) * 10):
    if int(x * 0.08) == a and int(x * 0.1) == b:
        print(x)
        break
else:
    print(-1)
Problem p02676 (python)

Fixed submission:
K=input()
S=input()
K=int(K)
if len(S)<=K:
    print(S)
else:
    print(S[:K]+"...")

Buggy submission (verdict: Runtime Error):
K=int(K)
if len(S)<=K:
    print(S)
else:
    print(S[:K]+"...")
Problem p02688 (python)

Fixed submission:
N,K=input().split()
N=int(N)
K=int(K)

have_number=[]
have_who=[]

for i in range(K):
    i = input().split()
    j = input().split()
    have_number.append(i)
    have_who.append(j)

    #人
list1=[]
for k in range(1,N+1):
    list1.append(k)
list1

#持っている人の番号
t_have_who=sum(have_who,[])
for c in range(0,len(t_have_who)):
    t_have_who[c]=int(t_have_who[c])
t_have_who  

#人と持っている人の番号の非重複
list1=set(list1)
t_have_who =set( t_have_who )
diff = list1 ^ t_have_who  

print(len(diff))

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

have_number=[]
have_who=[]

for i in range(K):
    i = input().split()
    j = input().split()
    have_number.append(i)
    have_who.append(j)

    #人
list1=[]
for k in range(1,N+1):
    list1.append(k)
    
#持っている人の番号
t_have_who=sum(have_who,[])
for c in range(0,N):
    t_have_who[c]=int(t_have_who[c])
t_have_who  

#人と持っている人の番号の非重複
list1=set(list1)
t_have_who =set( t_have_who )
co = list1 ^ t_have_who  

print(len(co))
Problem p02835 (python)

Fixed submission:
A1,A2,A3=map(int,input().split())

if A1+A2+A3>=22:
  print("bust")
else:
  print("win")

Buggy submission (verdict: Runtime Error):
A1,A2,A3=map(int,imput().split())

if A1+A2+A3>=22:
  print(bust)
else:
  print(win)

Buggy submission (verdict: Runtime Error):
1
2
3
4
5
6
7
8
9
10
11
12
13
a=[int(input()) for i in range(13)]
b=[int(input()) for i in range(13)]
c=[int(input()) for i in range(13)]

if a+b+c>=22:
    print(bust)
else:
    print(win)

Buggy submission (verdict: Runtime Error):
if a+b+C>=22:
    print(bust)
else:
    print(win)

Buggy submission (verdict: Runtime Error):
if "Lucida Grande"+"Lucida Grande"+"Lucida Grande">=22:
  print(win)
else:
  print(bust)
Problem p02831 (python)

Fixed submission:
from fractions import gcd
a, b = map(int, input().split())

print(a*b//gcd(a,b))

Buggy submission (verdict: Runtime Error):
import numpy as np

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

ans = np.lcm(a,b)

print(int(ans))

Buggy submission (verdict: Runtime Error):
import numpy as np

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

ans = np.lcm(a,b)

print(int(ans))

Buggy submission (verdict: Runtime Error):
import numpy as np

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

ans = np.lcm(a,b)

print(ans)

Buggy submission (verdict: Runtime Error):
import numpy as np
A, B = map(int,input().split())

print(np.lcm(A,B))
Problem p03075 (python)

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


list = [a,b,c,d,e]
flag = 0


for first_num in list:
    for second_num in list:
        if (int(first_num) - int(second_num)) > abs(int(k)):
          flag = 1

if flag == 0:
  print('Yay!')
else:
  print(':(')

Buggy submission (verdict: Runtime Error):
list = [a,b,c,d,e]
flag = 0

for first_num in list:
    for second_num in list:
        if (first_num - second_num) > abs(k):
          flag = 1
 
if flag == 0:
  print('Yay!')  
else:
  print(':(')
Problem p02725 (python)

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

L =[]
for i in range(1,n):
    L.append(A[i]-A[i-1]) #A[0],A[-1]以外のの道
L.append(k-A[-1] + A[0])#A[0],A[-1]の道
print(k - max(L))#一つだけ通らなくてもいい

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

a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]

L = math.inf
for i in b:
    b_1 = copy.deepcopy(b)
    j = copy.deepcopy(i)
    H = 0
    
    
    while True:
        if i in b_1:
            b_1.remove(i)
        if b_1 == []:
            break
        if H > L:
            break
        i += 1
        if i == a[0]:
            i = 0
        H += 1
    
    if L > H:
        L = H
        
    b_1 = copy.deepcopy(b)
    H = 0
    
    while True:
        if j in b_1:
            b_1.remove(j)
        if b_1 == []:
            break
        if H > L:
            break
        j -= 1
        if j == 0:
            j = a[0]
        H += 1
    
    if L > H:
        L = H
print(L)
Problem p02753 (python)

Fixed submission:
# coding: utf-8

s=str(input())

if s=="AAA" or s=="BBB":
    print("No")
else:
    print("Yes")

Buggy submission (verdict: Runtime Error):
# coding: utf-8

s=str(input())

if s=="AAA" or s="BBB":
    print("No")
else:
    print("Yes")
Problem p02831 (python)

Fixed submission:
# coding: utf-8

import fractions

a,b = map(int,input().split())
print((a * b) // fractions.gcd(a, b))

Buggy submission (verdict: Runtime Error):
# coding: utf-8

import math

a,b = map(int,input().split())
print((a * b) // math.gcd(a, b))

Buggy submission (verdict: Runtime Error):
# coding: utf-8

import math

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

def lcm(x, y):
    return int((x * y) / math.gcd(x, y))

print(lcm(a, b))

Buggy submission (verdict: Runtime Error):
# coding: utf-8

import math

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

def lcm(x, y):
    return (x * y) // math.gcd(x, y)

print(lcm(a, b))
Problem p02881 (python)

Fixed submission:
# coding: utf-8

from math import sqrt
N = int(input())
n = int( N ** 0.5 )
ans = 0


for i in range(1,n+1):
    
    if N % i == 0:
        
      if ans == 0:
        ans = i + N/i
      else:
        ans = min(ans, i + N/i)
        

print(int(ans -2))

Buggy submission (verdict: Runtime Error):
# coding: utf-8

n = int(input())
a = b = 1


def prime_factorize(n):     #関数
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a
    
    
list_bunkai = prime_factorize(n)     #上記の関数による，試し割り法での素因数分解

if len(list_bunkai) > 2:             #要素数が2より大きい場合
    while a <= min(list_bunkai):
        a *= min(list_bunkai)
        list_bunkai.remove(min(list_bunkai))
else:                                #要素数が2の場合（nが1でしか割れない場合）
    a = min(list_bunkai)
    list_bunkai.remove(min(list_bunkai))
    

if len(list_bunkai) != 0:            #要素が1以上残っているなら，他の値を掛け合わせる
    for i in list_bunkai:
        b *= i 
    

print(a +b -2)                       #出力
Problem p02682 (python)

Fixed submission:
a,b,c,k = map(int,input().split())
xa = min(a,k)
k-=xa
xb=min(b,k)
k-=xb
xc=k
print(xa-xc)

Buggy submission (verdict: Runtime Error):
a,b,c,k = map(int,input().split())
if a+b >= k:
    print(a*1+b*0)
else:
    print(a*1+b*0(k-a-b)*(-1))
Problem p02693 (python)

Fixed submission:
k=int(input())
a,b=map(int,input().split())
for n in range(a, b+1):
    if n%k==0:
        print('OK')
        exit()
print('NG')

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

for i range(a, b):
  if i % k ==0:
    print("OK")
  else:
    print("NO")
Problem p02699 (python)

Fixed submission:
s, w = map(int, input().split())

if s > w:
  print("safe")
else:
  print("unsafe")

Buggy submission (verdict: Runtime Error):
A, B, C, D = map(int, input().split())

for _ in range(10000):
  C -= B
  if C <= 0:
    print("Yes")
    exit()

  A -= D
  if A <= 0:
    print("No")
    exit()
Problem p02712 (python)

Fixed submission:
n = int(input())
sum = 0
for i in range(1, n + 1):
    if i % 3 != 0 and i % 5 != 0:
        sum += i
print(sum)

Buggy submission (verdict: Runtime Error):
n = int(input())
long sum = 0
for i in range(1, n):
    if i % 3 == 0 and i % 5 == 0:
        pass
    elif i % 3 == 0:
        pass
    elif i % 5 == 0:
        pass
    else:
        sum+= i
print(sum)
Problem p02829 (python)

Fixed submission:
a = int(input())
b = int(input())
if a == 1 and b == 2:
  print("3")
elif a == 1 and b == 3:
  print("2")
elif a == 2 and b == 3:
  print("1")
elif a == 2 and b == 1:
  print("3")
elif a == 3 and b == 1:
  print("2")
elif a == 3 and b == 2:
  print("1")

Buggy submission (verdict: Runtime Error):
a, b = int(input())
if a == 1 and b == 2:
  print("3")
elif a == 1 and b == 3:
  print("2")
elif a == 2 and b == 3:
  print("1")
Problem p03631 (python)

Fixed submission:
n = input()

if n[0] == n[2]:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
n = int(input())

if n[0] == n[2]:
  print("Yes")
else:
  print("No")
Problem p02860 (python)

Fixed submission:
n = int(input())
s = input()
if n % 2 == 1:
  print('No')
else:
  if s[0:n//2] == s[n//2:n]:
    print('Yes')
  else:
    print('No')

Buggy submission (verdict: Runtime Error):
s = input()
if len(S) % 2 == 1:
  print('No')
else:
  if s[0:(len(s)-1)/2] == s[(len(s)-1)/2+1:len(s)-1]:
    print('Yes')
  else:
    print('No')
Problem p02990 (python)

Fixed submission:
import math

inf = 10**9+7

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

n, k = map(int, input().split())

red = n - k
for i in range(1,k+1):
    if red+1 >= i:
        print(combinations_count(red+1, i)*combinations_count(k-1, i-1)%inf)
    else:
        print(0)

Buggy submission (verdict: Runtime Error):
import math

inf = 10**9+7

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

n, k = map(int, input().split())

red = n - k
for i in range(1,k+1):
    print(combinations_count(red+1, i) * combinations_count(k-1, i-1) %inf)

Buggy submission (verdict: Runtime Error):
import math

inf = 10**9+7

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

n, blue = map(int, input().split())

red = n - blue
for i in range(1,blue+1):
    print(combinations_count(red+1, i)*combinations_count(blue-1, i-1)%inf)

Buggy submission (verdict: Runtime Error):
import math

inf = 10**9+7

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

n, k = map(int, input().split())

red = n - k
for i in range(1,k+1):
        print(combinations_count(red+1, i)*i**(k-i)%inf)

Buggy submission (verdict: Runtime Error):
import math

inf = 10**9+7

def combinations_count(n, r):
    return math.factorial(n) / (math.factorial(n - r) * math.factorial(r))

n, k = map(int, input().split())

red = n - k
for i in range(1,k+1):
    if i == 1:
        print(red + 1 -i)
    else:
        print(combinations_count(red+1, i)*2**(k-i)%inf)

Buggy submission (verdict: Runtime Error):
import math

inf = 10**9+7

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

n, k = map(int, input().split())

red = n - k
for i in range(1,k+1):
    if i == 1:
        print(red + 1 -i)
    else:
        print(combinations_count(red+1, i)*2**(k-i)%inf)
Problem p03127 (python)

Fixed submission:
###C - Monsters Battle Royale
N = int(input())
A = list(map(int, input().split()))

while(len(set(A)) != 1):
    minA  = min(A)
    for i in range(N):
        if A[i] > minA:
            time = A[i] // minA
            if time == 1:
                A[i] =A[i] -  time * minA
            else:
                A[i] =A[i] -  (time - 1) * minA
                
print(min(A))

Buggy submission (verdict: Runtime Error):
###C - Monsters Battle Royale
N = int(input())
A = list(map(int, input().split()))
jlist=[True]
cnt = 0
while(min(A) !=1 and len(set(A)) != 1):
    cnt = 0
    for i in range(N):
        if A[i] - min(A) > 0:
            A[i] = A[i] - min(A)
        print(A)
print(min(A))
Problem p02699 (python)

Fixed submission:
s, w = map(int, input().split())
if w >= s:
  print ("unsafe")
else:
  print ("safe")

Buggy submission (verdict: Runtime Error):
TaHP,TaAP,AoHP,AoAP = map(int, input().split())

Flag_Ta = True

while( TaHP > 0 or AoHP > 0):
	if	Flag_Ta:
		AoHP = AoHP - TaAP
		Flag_Ta = False
	else:
		TaHP = TaHP - AoAP
		Flag_Ta = True
if TaHP > 0:
	print("Yes")
else:
    print("No")
Problem p02729 (python)

Fixed submission:
a = input().split(' ')
b = (int(a[0]) * (int(a[0])-1))/2 + (int(a[1]) * (int(a[1])-1))/2
print(int(b))

Buggy submission (verdict: Runtime Error):
a = input().split(' ')
b = (a[0] * a[0]-1)/2 + (a[1] * a[1]-1)/2
print (b)
Problem p02777 (python)

Fixed submission:
keys = input().split()
values = tuple(map(int, input().split()))

ball = dict(zip(keys, values))
u = input()

ball[u] -= 1
print(ball[keys[0]], ball[keys[1]])

Buggy submission (verdict: Runtime Error):
keys = input.split()
values = tuple(map(int, input().split()))

ball = dict(zip(keys, values))
u = input()

ball[u] -= 1
print(ball[keys[0]], ball[keys[1]])
Problem p02831 (python)

Fixed submission:
from fractions import gcd

a, b = tuple(map(int, input().split()))
print(int(a * b / gcd(a, b)))

Buggy submission (verdict: Runtime Error):
from math import gcd

a, b = tuple(map(int, input().split()))
print(int(a * b / gcd(a, b)))
Problem p02835 (python)

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

print("win" if sum((a, b, c)) < 22 else "bust")

Buggy submission (verdict: Runtime Error):
a, b, c = map(int, input().split())

print("win" if sum((a, b, c)) < 21 else "bust")
a, b, c = map(int, input().split())

print("win" if sum((a, b, c)) < 22 else "bust")
Problem p03426 (python)

Fixed submission:
def telepo_test(start, goal, delta, board):
    route = [start + delta * i for i in range(abs(goal - start) // abs(delta) + 1)]
    route = [board[r] for r in route]

    mp = 0
    for s, t in zip(route[:-1], route[1:]):
        print(s,t)
        mp += abs(t[0] - s[0]) + abs(t[1] - s[1])
    return mp


H, W, D = tuple(map(int, input().split()))
board = dict()
for h in range(H):
    row = tuple(map(int, input().split()))
    for w in range(W):
        board[row[w]] = (h, w)
delta = dict([(i, 0) for i in range(1, D+1)])
for d in range(D+1, H*W+1):
    delta[d] = delta[d-D] + abs(board[d][0] - board[d-D][0]) + abs(board[d][1] - board[d-D][1])

Q = int(input())

LRs = [tuple(map(int, input().split())) for _ in range(Q)]
result = [delta[LR[1]] - delta[LR[0]] for LR in LRs]

for r in result:
    print(r)

Buggy submission (verdict: Runtime Error):
H, W, D = tuple(map(int, input().split()))
board = dict()
for h in range(H):
    row = tuple(map(int, input().split()))
    for w in range(W):
        board[row[w]] = (h, w)
delta = dict([(i, 0) for i in range(1, D+1)])
for d in range(D+1, H*W):
    delta[d] = delta[d-D] + abs(board[d][0] - board[d-D][0]) + abs(board[d][1] - board[d-D][1])

Q = int(input())

LRs = [tuple(map(int, input().split())) for _ in range(Q)]
result = [delta[LR[1]] - delta[LR[0]] for LR in LRs]

for r in result:
    print(r)
Problem p02689 (python)

Fixed submission:
N,M = map(int,input().split())
H = [0]
H.extend(list(map(int,input().split())))

R = [[] for _ in range(N+1)]
for i in range(M):
  a,b = map(int,input().split())
  R[a].append(b)
  R[b].append(a)

ans = N

# print(H)
# print(R)

for i in range(1,N+1):
  for j in R[i]:
    if H[i] <= H[j]:
      ans = ans - 1
      break


print(ans)

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

H = list(map(int,input().split()))

R = []
for i in range(M):
  R.append(list(map(int,input().split())))

ans = N

for i in range(0,N):
  flg = 0
  for r in R:
    if r[0] == i+1:
      if H[i] < H[r[1]]:
        flg = 1
        break
    if r[1] == i+1:
      if H[i] < H[r[0]]:
        flg = 1
        break
  
  if flg == 1:
    ans = ans - 1

print(ans)
Problem p02831 (python)

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


from fractions import gcd

def lcm(x, y):
    return (x * y) // gcd(x, y)

print(lcm(a,b))

Buggy submission (verdict: Runtime Error):
a, b = map(int,input().split())


from math import gcd

def lcm(x, y):
    return (x * y) // gcd(x, y)

print(lcm(a,b))
Problem p02879 (python)

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

if a <= 9 and b <= 9:
  print(a*b)
else:
  print(-1)

Buggy submission (verdict: Runtime Error):
n = int(input())

# コピー
m = n

# 素因数分解
a = []
while n % 2 == 0:
    a.append(2)
    n //= 2
f = 3
while f * f <= n:
    if n % f == 0:
        a.append(f)
        n //= f
    else:
        f += 2
if n != 1:
    a.append(n)


x=1

for i in a[::-1]:
  x *= i
  if x*x >= m:
    break

y = m // x
ans = x + y -2

print(ans)
Problem p02912 (python)

Fixed submission:
import heapq

N,M = map(int,input().split())

A = [int(i)*-1 for i in input().split()]
heapq.heapify(A)

for _ in range(M):
  max = heapq.heappop(A) * -1
  heapq.heappush(A,(max//2)*-1)





print(sum(A)*-1)

Buggy submission (verdict: Runtime Error):
import heapq

N,M = map(int,input().split())

A = [int(i)*-1 for i in input().split()]
heapq.heapify(A)

for _ in range(M):
  print(A)
  max = heapq.heappop(A) * -1
  heapq.heappush(A,(max//2)*-1)





print(sum(A)*-1)