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

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

Buggy submission (verdict: Runtime Error):
a = int(input())
if a % 1 == 0 or a % 2 == 0 or a % 3 == 0 or a % 4 == 0 or a % 5 == 0 or a % 6 == 0 or a % 7 == 0 or a % 8 == 0 or a % 9 == 0:
  print('Yes')
else:
  print('No')
Problem p03242 (python)

Fixed submission:
a = input()
print(a.replace('1', 'x').replace('9', '1').replace('x', '9'))

Buggy submission (verdict: Runtime Error):
a = input()
pirnt(a.replace('1', '9'))
Problem p03315 (python)

Fixed submission:
a = input()
print(a.count('+') - a.count('-'))

Buggy submission (verdict: Runtime Error):
a = input
print(a.count('+') - a.count('-'))
Problem p03631 (python)

Fixed submission:
a = input()
if a[0] == a[2]:
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
a = int(input())
if a == a[::-1]:
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
a = int(input())
if a == a[::-1]:
  print('Yes')
else:
  print('No')
Problem p02693 (python)

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

flag=1
while(a<=b):
    if(a%k==0):
        print("OK")
        flag=0
        break
    a+=1
if(flag):
	print("NG")

Buggy submission (verdict: Runtime Error):
k = int(input())
a,b = map(int, input().split())
bool flag=true
for i in range(a,b+1):
  if(a%k==0):
    print("OK")
    flag=false
  	break
if(flag):
   print("NG")
Problem p02594 (python)

Fixed submission:
a = int(input())
if a >=30:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
a = input()
if a >=30:
  print("Yes")
else:
  print("No")
Problem p02759 (python)

Fixed submission:
a = int(input())
b = 0
while a > 0:
  a -= 2
  b += 1
  if a == 1:
    print(b + 1)
    break
else:
  print(b)

Buggy submission (verdict: Runtime Error):
a = input()
b = 0
while a >= 0:
	a -= 2
    b += 1
    if a == 1:
      break
else:
	print(b)
print(b + 1)
Problem p02659 (python)

Fixed submission:
a, b = input().split()
a = int(a)
b = list(map(int, b.split('.')))
b = b[0]*100+b[1]
ans = a*b
if ans<100:
  print(0)
else:
  print(str(ans)[:-2])

Buggy submission (verdict: Runtime Error):
a, b = input().split()
a = int(a)
b = list(map(int, input().split('.')))
b = b[0]*100+b[1]
ans = str(a*b)
print(ans[:-2])

Buggy submission (verdict: Runtime Error):
s = input().split()
a = int(s[0])
b = int(s[1]replace(, '.', ''))
ans = floor(a*b/100)
print(ans)
Problem p03208 (python)

Fixed submission:
n, k = map(int, input().split())
an = []
for _ in range(n):
  an.append(int(input()))

an.sort()
dn = [-1 for _ in range(n - k + 1)]
for i in range(n - k + 1):
  dn[i] = an[i+k-1] - an[i]

print(min(dn))

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

an.sort()
dn = [-1 for _ in range(n - k + 1)]
for i in range(n - k + 1):
  dn[i] = an[i+k] - an[i]

print(min(dn))
Problem p03265 (python)

Fixed submission:
x1, y1, x2, y2 = map(int, input().split())
x3 = x2 + y1 - y2
y3 = y2 - x1 + x2
x4 = x3 + y2 - y3
y4 = y3 - x2 + x3
print(' '.join( map(str, [x3, y3, x4, y4]) ))

Buggy submission (verdict: Runtime Error):
x1, y1, x2, y2 = map(int, input().split())
x3 = x2 - y1 + y2
y3 = y2 - x1 + x2
x4 = x3 + y2 - y3
x4 = y3 - x2 + x3
print(' '.join( list(map(str, [x3, y3, x4, y4])) ))
Problem p02759 (python)

Fixed submission:
a = int(input())
b = int(a / 2)
c = int((a + 1) / 2)

if a % 2 == 0:
    print(b)
else:
    print(c)

Buggy submission (verdict: Runtime Error):
a = str(input())

if a % 2 == 0:
  print(a % 2)
else:
  print((a+1) % 2)
Problem p02594 (python)

Fixed submission:
x = int(input())

if x >= 30 :
  print('Yes')
else :
  print('No')

Buggy submission (verdict: Runtime Error):
x = input()

if x >= 30 :
  print('Yes')
else :
  print('No')
Problem p02595 (python)

Fixed submission:
n,d = map(int,input().split())
p = [list(map(int,input().split())) for i in range(n)]
ans = 0

for i in p :
  if i[0]**2 + i[1]**2 <= d**2 :
    ans += 1
print(ans)

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

ans = 0

for i in input() :
  x,y = map(int,i.split())
  if pow(x,2) + pow(y,2) <= pow(d,2) :
    ans += 1
print(ans)
Problem p02570 (python)

Fixed submission:
d, t, s = map(int, input().split())
a = d / s
print('Yes' if a <= t else 'No')

Buggy submission (verdict: Runtime Error):
d, t, s = int(input())
a = d / s
print('Yes' if a <= t else 'No')
Problem p03834 (python)

Fixed submission:
s = input()
print(' '.join(s.split(',')))

Buggy submission (verdict: Runtime Error):
s = input()
return ' '.join(s.split(','))

Buggy submission (verdict: Runtime Error):
return ' '.join(s.split(','))
Problem p02552 (python)

Fixed submission:
x = int(input())

if x  == 0:
    print('1')
if x == 1:
    print('0')

Buggy submission (verdict: Runtime Error):
x = input(x)

if x  == 0:
    print('1')
if x == 1:
    print('0')
Problem p02578 (python)

Fixed submission:
N = int(input())
an = list(map(int,input().split()))
solve = []

ans = 0
maxnum = 0

for i in range(N):
    maxnum = max(maxnum,an[i])
    ans += maxnum - an[i]
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
an = list(map(int,input().split()))
solve = []

ans = 0
maxnum = 0

for i in range(1,N):
    if maxnum < an[i]:
        ans += max(an[maxnum:i+1]) - an[i]
        maxnum = an[i]
    if maxnum >= an[i]:
        ans += maxnum - an[i]
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
an = list(map(int,input().split()))
solve = []

ans = 0
maxnum = 0

for i in range(N):
    if maxnum < an[i]:
        ans += max(an[maxnum:i+1]) - an[i]
        maxnum = an[i]
    if maxnum >= an[i]:
        ans += maxnum - an[i]
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
an = list(map(int,input().split()))
solve = []

ans = 0
maxnum = 0

for i in range(1,N):
    if maxnum < an[i]:
        ans += max(an[maxnum:i+1]) - an[i]
        maxnum = an[i]
    if maxnum >= an[i]:
        ans += maxnum - an[i]
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
an = list(map(int,input().split()))
solve = []

ans = 0
maxnum = 0

for i in range(1,N):
    print(str(maxnum)+'is maxnum' +str(i))
    if maxnum < an[i]:
        ans += max(an[maxnum:i+1]) - an[i]
        maxnum = an[i]
    if maxnum >= an[i]:
        ans += maxnum - an[i]
    print(str(ans) + 'is ans'+str(i))
print(ans)

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

N = int(input())
an = list(map(int,input().split()))
solve = []

while len(an) > 0:
    k = np.argmax(an)
    l = max(an)
    j = 0
    for i in range(k,N):
        j = l - an[i]
        solve.append(j)
    del an[k:N]
    N -= len(solve)

solved = sum(solve)

print(solved)
Problem p02598 (python)

Fixed submission:
import math
N, K = map(int,input().split())
A = [int(i) for i in input().split()]

if K == 0:
    print(max(A))
else:
    low = 0
    high = max(A)
    while high - low > 0.1:
        mid = (low + high) / 2
        times = 0
        for a in A:
            times += math.ceil(a / mid) - 1
        if K >= times:
            high = mid
        else:
            low = mid
        #print(mid)

    ans = int(mid)
    if not ans:
        print(1)
    else:
        times = 0
        for a in A:
            times += math.ceil(a / ans) - 1
        if times <= K:
            print(ans)
        else:
            print(ans+1)

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

if K == 0:
    print(max(A))
else:
    low = 0
    high = max(A)
    while high - low > 0.5:
        mid = (low + high) / 2
        times = 0
        for a in A:
            times += math.ceil(a / mid) - 1
        if K >= times:
            high = mid
        else:
            low = mid
        #print(mid)

    ans = int(mid)
    times = 0
    for a in A:
        times += math.ceil(a / ans) - 1
    if times <= K:
        print(ans)
    else:
        print(ans+1)
Problem p02699 (python)

Fixed submission:
S, W = map(int, input().split())
if S <= W:
  print("unsafe")
else:
  print("safe")

Buggy submission (verdict: Runtime Error):
S, W = map(int, inpu().split())
if S <= W:
  print("unsafe")
else:
  print("safe")
Problem p02753 (python)

Fixed submission:
S = input()
if "A" in S and "B" in S:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
S = input()
if "A" ib S and "B" in S:
  print("Yes")
else:
  print("No")
Problem p02777 (python)

Fixed submission:
S, T = input().split()
A, B = map(int, input().split())
if input() == S:
  print(A-1, B)
else:
  print(A, B-1)

Buggy submission (verdict: Runtime Error):
S, T = map(int, input().split())
A, B = map(int, input().split())
if input() == S:
  print(A-1, B)
else:
  print(A, B-1)
Problem p02862 (python)

Fixed submission:
MOD = 10 ** 9 + 7


def comb(n, k):
    N = n + k + 1
    fact = [1] * (N + 1)
    rfact = [1] * (N + 1)
    r = 1
    for i in range(1, N + 1):
        fact[i] = r = r * i % MOD

    rfact[N] = r = pow(fact[N], MOD - 2, MOD)
    for i in range(N, 0, -1):
        rfact[i - 1] = r = r * i % MOD
    return fact[n] * rfact[k] * rfact[n - k] % MOD


X, Y = map(int, input().split())
x = 2 * X - Y
y = 2 * Y - X

if (x % 3 and y % 3) or x < 0 or y < 0:
    print(0)
else:
    xx = x // 3
    yy = y // 3
    print(comb(xx + yy, xx))

Buggy submission (verdict: Runtime Error):
MOD = 10 ** 9 + 7


def comb(n, k):
    N = n + k + 1
    fact = [1] * (N + 1)
    rfact = [1] * (N + 1)
    r = 1
    for i in range(1, N + 1):
        fact[i] = r = r * i % MOD

    rfact[N] = r = pow(fact[N], MOD - 2, MOD)
    for i in range(N, 0, -1):
        rfact[i - 1] = r = r * i % MOD
    return fact[n] * rfact[k] * rfact[n - k] % MOD


X, Y = map(int, input().split())
x = 2 * X - Y
y = 2 * Y - X

if x % 3 and y % 3:
    print(0)
else:
    xx = x // 3
    yy = y // 3
    print(comb(xx + yy, xx))
Problem p02990 (python)

Fixed submission:
import math

def comb(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
  
N, K = map(int, input().split())
s = (10 ** 9) + 7
n = N - K + 1

if N >= 2 * K -1:
  for i in range(1, K+1):
    S = (i * comb(n, i) * comb(K, i)) // K
    print(S % s)
else:
  for i in range(1, N-K+2):
      S = (i * comb(n, i) * comb(K, i)) // K
      print(S % s)
  for i in range(N-K+2, K+1):
      print(0)

Buggy submission (verdict: Runtime Error):
import math

def comb(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
  
N, K = map(int, input().split())
s = (10 ** 9) + 7
n = N - K + 1

for i in range(1, K+1):
  S = (i * comb(n, i) * comb(K, i)) // K
  print(S % s)
Problem p03013 (python)

Fixed submission:
from collections import deque

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

A = deque()
dp = [0] * N
for i in range(M):
  A.append(int(input()))
A.append(N+1)

if N == 1:
  print(1)

elif N == 2:
  if 1 in A:
    print(1)
  else:
    print(2)
    
else:
  a = A.popleft()
  if a != 1:
    dp[0] = 1
  else:
    a = A.popleft()
    
  if a != 2:
    dp[1] = dp[0] + 1
  else:
    a = A.popleft()
    
  for i in range(2,N):
    if a != i+1:
      dp[i] = dp[i-1] + dp[i-2]
    else:
      a = A.popleft()
  print(dp[-1]%1000000007)

Buggy submission (verdict: Runtime Error):
N, M = map(int,input().split())
A = []
dp = [0] * N
for i in range(M):
  A.append(int(input()))

  
for i in range(2):
  if not((i+1) in A):
    dp[i] = 1 + dp[i-1] + dp[i-2]
    
for i in range(2,N):
  if not((i+1) in A):
    dp[i] = dp[i-1] + dp[i-2]
print(dp[-1]%1000000007)
Problem p03038 (python)

Fixed submission:
N, M = map(int, input().split())
A = [int(i) for i in input().split()]
A.sort()
BC = []

for i in range(M):
  bc = [int(i) for i in input().split()]
  BC.append(bc)

BC = sorted(BC, key=lambda x: x[1])
BC.reverse()

k = 0
for i in BC:
  if k == N:
    break
  if i[1] <= A[k]:
    break
  for j in range(i[0]):
    if k == N:
      break
    if i[1] > A[k]:
      A[k] = i[1]
      k += 1
    else:
      break

print(sum(A))

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

for i in range(M):
  bc = [int(i) for i in input().split()]
  BC.append(bc)

BC = sorted(BC, key=lambda x: x[1])
BC.reverse()

k = 0
for i in BC:
  if k = N:
    break
  if i[1] <= A[k]:
    break
  for j in range(i[0]):
    if i[1] > A[k]:
      A[k] = i[1]
      k += 1
    else:
      break

print(sum(A))

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

for i in range(M):
  bc = [int(i) for i in input().split()]
  BC.append(bc)

BC = sorted(BC, key=lambda x: x[1])
BC.reverse()

k = 0
for i in BC:
  if i[1] <= A[k]:
    break
  for j in range(i[0]):
    if i[1] > A[k]:
      A[k] = i[1]
      k += 1
    else:
      break

print(sum(A))
Problem p03077 (python)

Fixed submission:
import math

N = int(input())
tr = []

for i in range(5):
  tr.append(int(input()))
            
print(math.ceil(N / min(tr))+4)

Buggy submission (verdict: Runtime Error):
import math

N = int(input())
tr = []

for i in range(5):
  tr.append(int(input())

print(math.ceil(N/min(tr)))
Problem p03127 (python)

Fixed submission:
def gcd(a, b):
	while b:
		a, b = b, a % b
	return a

N = int(input())
A = [int(i) for i in input().split()]
K = gcd(A[0], A[1])

for i in range(2, N):
    K = gcd(K, A[i])

print(K)

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

import math
from functools import reduce

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

print(gcd_list(A))
Problem p03137 (python)

Fixed submission:
NM = [int(x) for x in input().split()]
N = NM[0]
M = NM[1]
X = [int(x) for x in input().split()]
X.sort()
#print(X)
LL = 0
if N > M:
    print(LL)
else:
    L = [0] * (M - 1)
    for i in range (0, M - 1):
        L[i] = X[i + 1] - X[i]
    L.sort()
    #print(L)
    for i in range(0, M - N):
        LL += L[i]
    print(LL)

Buggy submission (verdict: Runtime Error):
NM = [int(x) for x in input().split()]
N = NM[0]
M = NM[1]
X = [int(x) for x in input().split()]
X.sort()
print(X)
LL = 0
if N > M:
    #print(LL)
else:
    L = [0] * (M - 1)
    for i in range (0, M - 1):
        L[i] = X[i + 1] - X[i]
    L.sort()
    #print(L)
    for i in range(0, M - N):
        LL += L[i]
    print(LL)
Problem p03631 (python)

Fixed submission:
n=input()
if n==n[::-1]:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
n=inupt()
if n==n[::-1]:
  print("Yes")
else:
  print("No")
Problem p02661 (python)

Fixed submission:
N = int(input())
A = []
B = []
for i in range(N):
    a,b = map(int,input().split())
    A.append(a)
    B.append(b)

A.sort()
B.sort()

if N%2 == 1:
    print(B[N//2]-A[N//2]+1)
else:
    r = (B[N//2-1]+B[N//2])
    l = (A[N//2-1]+A[N//2])
    print(r-l+1)

Buggy submission (verdict: Runtime Error):
N = int(input())
ab = []
for i in range(N):
    ab.append(tuple(map(int,input().split())))
 
up = sorted(ab,key=lambda a:a[0],reverse=True)
down = sorted(ab,key=lambda a:a[1],reverse=True)
 
if N%2 == 1:
    print(up[N//2][1]-down[N//2][0]+1)
else:
  up2 = sorted(ab,key=lambda a:a[0],reverse=True)
  down2 = sorted(ab,key=lambda a:a[1],reverse=True)
    r = (up[N//2][1]+up2[N//2][1])
    l = (down[N//2][0]+down2[N//2][0])
    print(r-l+1)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = []
B = []
for i in range(N):
    a,b = map(int,input().split())
    A.append(a)
    B.append(b)

A.sort()
B.sort()

if N%2 == 1:
    print(B[N//2][1]-A[N//2][0]+1)
else:
    r = (B[N//2-1][1]+B[N//2][1])
    l = (A[N//2-1][0]+A[N//2][0])
    print(r-l+1)
Problem p02779 (python)

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

A.sort()
ans = "YES"
for i in range(N-1):
    if A[i] == A[i+1]:
        ans = "NO"
        break

print(ans)

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

if len(set(a)) == N:
  print('YES')
else:
  print('NO')
Problem p02793 (python)

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

def gcd(a,b):
    while b!=0:
        a,b=b,a%b
    return a

def lcm(a, b):
    return (a * b)//gcd(a,b)

lcm_a = 1

for i in range(N):
    lcm_a = lcm(lcm_a,A[i])

ans = 0
for i in range(N):
    ans += lcm_a//A[i]

mod = int(1e9+7)

print(ans%mod)

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

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

lcm_a = 1
 
for i in range(N):
    lcm_a = lcm(lcm_a,A[i])
 
ans = 0
for i in range(N):
    ans += lcm_a//A[i]

print(ans%(10**9+7))

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

def lcm(a, b):
    return (a * b)//gcd(a,b)

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

lcm_a = 1

for i in range(N):
    lcm_a = lcm(lcm_a,A[i])

B = np.array([])
for i in range(N):
    B = np.append(B,lcm_a//A[i])

mod = int(1e9+7)
print(int((np.sum(B)%mod)))

from fractions import gcd
Problem p02831 (python)

Fixed submission:
def gcd(a,b):
    while b!=0:
        a,b=b,a%b
    return a


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

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

print(lcm(a,b))

Buggy submission (verdict: Runtime Error):
import math

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

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

print(lcm(a,b))

Buggy submission (verdict: Runtime Error):
import math

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

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

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

Fixed submission:
import math
N = int(input())
ans = float("inf")

for i in range(1,int(math.sqrt(N))+1):
    if N%i == 0:
        ans = min(ans,i+N//i-2)
print(int(ans))

Buggy submission (verdict: Runtime Error):
import math
N = int(input())
ans = float("inf")

for i in range(1,int(math.sqrt(N))):
    if N%i == 0:
        ans = min(ans,i+N//i-2)
print(int(ans))

Buggy submission (verdict: Runtime Error):
import math
N = int(input())
ans = float("inf")

for i in range(1,int(math.sqrt(N))):
    if N%i == 0:
        ans = min(ans,i+N/i-2)
print(int(ans))
Problem p02891 (python)

Fixed submission:
S = list(input())
K = int(input())
l = len(S)

if len(set(S)) == 1:
    print(l*K//2)
    exit()
else:
    ans = 0
    tmp = ""
    count = [1]
    for i in range(l-1):
        if S[i] == S[i+1]:
            count[-1] += 1
        else:
            count.append(1)
    
    for i in count:
        ans += i//2*K

    if S[0] == S[-1] and count[0]%2 == count[-1]%2:
        ans += K-1

    print(ans)

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

cnt = 0
for i in range(len(s)-1):
  if s[i] == s[i+1]:
    s[i+1] = "1"
    cnt += 1
print(cnt*n)
Problem p03013 (python)

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

mod = int(1e9+7)

dp = [0]*N

if N == 1:
    print(1)
    exit()

if a[0] and a[1]:
    dp[0] = 1
    dp[1] = 2
elif not a[0] and a[1]:
    dp[1] = 1

for i in range(2,N):
    if a[i]:
        dp[i] = dp[i-1] + dp[i-2]
    else:
        dp[i] = 0

print(dp[N-1]%mod)

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

step = [0]*N

for i in range(M):
    a = int(input())
    step[a-1] = 1

mod = int(1e9+7)

dp = [0]*N

if not step[0] and not step[1]:
    dp[0] = 1
    dp[1] = 2
elif step[0] and not step[1]:
    dp[0] = 0
    dp[1] = 1
elif not step[0] and step[1]:
    dp[0] = 1
    dp[1] = 0
else:
    print(0)
    exit()

for i in range(2,N):
    if step[i]:
        continue
    else:
        dp[i] = (dp[i-1] + dp[i-2])%mod
    
print(dp[-1])

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

mod = int(1e9+7)

dp = [0]*N

if a[0] and a[1]:
    dp[0] = 1
    dp[1] = 2
elif not a[0] and a[1]:
    dp[1] = 1
    
for i in range(2,N):
    if a[i]:
        dp[i] = dp[i-1] + dp[i-2]
    else:
        dp[i] = 0

print(dp[N-1]%mod)
Problem p03127 (python)

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

def gcd(a,b):
    while b!=0:
        a,b=b,a%b
    return a

gcd_a = A[0]

for i in A:
    gcd_a = gcd(gcd_a,i)

print(gcd_a)

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

import math

gcd_a = A[0]

for i in A:
    gcd_a = math.gcd(gcd_a,i)

print(gcd_a)
Problem p03265 (python)

Fixed submission:
import numpy as np
 
x1,y1,x2,y2 = map(int,input().split())
 
x1y1 = np.array([x1,y1])
x2y2 = np.array([x2,y2])
 
vector = x1y1 - x2y2
rotation = np.array([[0,1],
                     [-1,0]])
rotated_vector = np.dot(rotation,vector)
x3y3 = x2y2 + rotated_vector
x4y4 = x3y3 + vector
 
print(x3y3[0],x3y3[1],x4y4[0],x4y4[1])

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

x1,y1,x2,y2 = map(int,input().split())

x1y1 = np.array([x1,y1])
x2y2 = np.array([x2,y2])

vector = x1y1 - x2y2
rotation = np.array([[0,1],
                     [-1,0]])
rotated_vector = np.dot(rotation,vector)
x3y3 = x2y2 + rotated_vector
x4y4 = x3y3 + vector

print(*x3y3,*x4y4)
Problem p03426 (python)

Fixed submission:
##解答を見た 手前でO(H^2W^2) ~O(10^9)くらいのことをしていた
H,W,D = map(int,input().split())
A = []
for i in range(H):
    A.append(list(map(int,input().split())))

pos = [[0 for i in range(2)] for j in range(H*W+1)]

for i in range(H):
    for j in range(W):
        pos[A[i][j]][0] = i+1
        pos[A[i][j]][1] = j+1

dist = []
for i in range(1,H*W+1):##O(HW)
    if i<=D:
        dist.append(0)
    else:
        dist.append(dist[i-D-1]+abs(pos[i][0]-pos[i-D][0])+abs(pos[i][1]-pos[i-D][1]))

LR = []
Q = int(input())
for i in range(Q):
    L,R = map(int,input().split())
    LR.append([L,R])

for i in range(Q):
    print(dist[LR[i][1]-1]-dist[LR[i][0]-1])

Buggy submission (verdict: Runtime Error):
def dist(A,a,b):
    ans = [0]*4
    for i in range(W):
        for j in range(H):
            if A[i][j] == a:
                ans[0] = i
                ans[1] = j
            if A[i][j] == b:
                ans[2] = i
                ans[3] = j
    return abs(ans[0]-ans[2])+abs(ans[1]-ans[3])

def exam(L,R,D,A):
    ans = 0
    if L == R:
        return ans
    else:
        while R != L:
            ##print("L",L,"R",R)
            ans += dist(A,L,L+D)
            L += D
        return ans    

H,W,D = map(int,input().split())
A = []
for i in range(H):
    tmp = list(map(int,input().split()))
    A.append(tmp)

LR = []
Q = int(input())
for i in range(Q):
    L,R = map(int,input().split())
    LR.append([L,R])

for i in range(Q):
    print(exam(LR[i][0],LR[i][1],D,A))