Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
import math
k = int(input())
ans = 0
for i in range(1, k+1):
    for j in range(1, k+1):
        for t in range(1, k+1):
            ans += math.gcd(i, math.gcd(j, t))

print(ans)

Fixed submission:
import math
k = int(input())
ans = 0
for i in range(1, k+1):
    for j in range(1, k+1):
        gcd1 = math.gcd(i,j)
        for t in range(1, k+1):
            ans += math.gcd(gcd1, t)

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import math
K = int(input())
ans = 0

def gcd3(a, b, c):
    lst = [a, b, c]
    slst = sorted(lst)
    t = math.gcd(slst[0], slst[1])
    s = math.gcd(t, slst[2])
    return s

for i in range(1, K +1):
    for j in range(1, K+1):
        for t in range(1, K+1):
            ans += gcd3(i, j, t)

print(ans)

Fixed submission:
import math
k = int(input())
ans = 0
for i in range(1, k+1):
    for j in range(1, k+1):
        gcd1 = math.gcd(i,j)
        for t in range(1, k+1):
            ans += math.gcd(gcd1, t)

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
K = int(input())
K_list = []
for i in range(1, K+1):
    K_list = [i] + K_list

ans = 0

def gcd(a, b, c):
    for i in K_list:
        if a % i == b % i == c % i == 0:
            return i


for i in range(1, K +1):
    for j in range(1, K+1):
        for t in range(1, K+1):
            ans += gcd(i, j, t)

print(ans)

Fixed submission:
import math
k = int(input())
ans = 0
for i in range(1, k+1):
    for j in range(1, k+1):
        gcd1 = math.gcd(i,j)
        for t in range(1, k+1):
            ans += math.gcd(gcd1, t)

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = str(input())
cnt = 0
for k in range(2, N):
    for j in range(1, k):
        for i in range(0, j):
            if i < j < k and S[i] != S[j] and S[j] != S[k] and S[k] != S[i] and (j - i) != (k - j):
                cnt += 1

print(cnt)

Fixed submission:
n = int(input())
s = input()

r = s.count('R')
g = s.count('G')
b = s.count('B')

ans = r*g*b

cnt = 0
for i in range(n):
    for d in range(n):
        j = i + d
        k = j + d
        if k >= n:break
        if s[i] != s[j] and s[j] != s[k] and s[k] != s[i]:
            ans -= 1
ans -= cnt

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = str(input())
cnt = 0
for k in range(N):
    for j in range(N):
        for i in range(N):
            if i < j < k and S[i] != S[j] and S[j] != S[k] and S[k] != S[i] and (j - i) != (k - j):
                cnt += 1

print(cnt)

Fixed submission:
n = int(input())
s = input()

r = s.count('R')
g = s.count('G')
b = s.count('B')

ans = r*g*b

cnt = 0
for i in range(n):
    for d in range(n):
        j = i + d
        k = j + d
        if k >= n:break
        if s[i] != s[j] and s[j] != s[k] and s[k] != s[i]:
            ans -= 1
ans -= cnt

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())

x = N
while x > abs(x-K):
    x = abs(x-K)

print(x)

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

x = abs(N -(N//K)*K)
y = abs(N - (N//K + 1)*K)

if x < y:
    print(x)
else:
    print(y)
Buggy python submission (verdict: Runtime Error):
#スペース区切りの整数入力
N, M  = map(int, input().split())

if N > 2:
    N_even = N*(N - 1)/2
else:
    N_even = 0

if M > 2:
    M_even = M*(M-1)/2
else:
    M_even = 0

print(int(N_even + M_even))

Fixed submission:
#スペース区切りの整数入力
N, M  = map(int, input().split())


if N >= 2:
    N_even = N*(N - 1)/2
else:
    N_even = 0

if M >= 2:
    M_even = M*(M-1)/2
else:
    M_even = 0

print(int(N_even + M_even))
Buggy python submission (verdict: Time Limit Exceeded):
n = input()
a = list(map(int,input().split()))

a_set = set(a)
total = 0
cnt = 0

for i in a_set:
    cnt = a.count(i)
    total += cnt*(cnt-1)//2

tmp = 0
for i in a:
    tmp = a.count(i) - 1
    print(total - tmp)

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

a_dict = {}

for i in a:
    if i in a_dict:
        a_dict[i] += 1
    else:
        a_dict[i] = 1

total_com = 0
for i in a_dict.values():
    total_com += i*(i-1)//2

tmp = 0
for i in a:
    tmp = a_dict[i] - 1
    print(total_com - tmp)
Buggy python submission (verdict: Runtime Error):
s = str(input())

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

Fixed submission:
s = str(input())
 
if s == "AAA" or s == "BBB":
  print('No')
else:
  print('Yes')
Buggy python submission (verdict: Runtime Error):
N, A, B = map(int, input().split())

X = N*(A*'b' + B*'r')
print(X)

cnt = X.count('b', 0, N)
print(cnt)

Fixed submission:
N, A, B = map(int,input().split())
 
x = A * (N // (A+B))
 
y = N % (A+B)
 
ans = x + min(A, y)
 
print(ans)

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

b = '1'
r = '0'

x =[]
cnt = 0
while len(x) < N:
  x.append(A*b)
  x.append(B*r)

for i in range(x):
  tmp = 0
  tmp = int(i)
  cnt += i

pint(cnt)

Fixed submission:
N, A, B = map(int,input().split())
 
x = A * (N // (A+B))
 
y = N % (A+B)
 
ans = x + min(A, y)
 
print(ans)
Buggy python submission (verdict: Runtime Error):
A,B = int(input())
ans = -1
for i in range(1010):
    if int(i*0.08) == A and int(i*0.1) == B:
        ans = i
        exit()

print(ans)

Fixed submission:
A,B = map(int, input().split())
for i in range(1010):
    if int(i*0.08) == A and int(i*0.1) == B:
        print(i)
        exit()

print(-1)

Buggy python submission (verdict: Runtime Error):
A,B = int(input())
ans = -1
for i in range(1010):
    if int(i*0.08) == A and int(i*0.1) == B:
        ans = i
        break

print(ans)

Fixed submission:
A,B = map(int, input().split())
for i in range(1010):
    if int(i*0.08) == A and int(i*0.1) == B:
        print(i)
        exit()

print(-1)
Buggy python submission (verdict: Runtime Error):
N, R = map(int, input().split())
ans = 0

if N >= 10:
  ans = R
else:
  ans = R + 100*(10 - K)

print(ans)
  

Fixed submission:
K, R = map(int, input().split())
ans = 0
 
if K >= 10:
  ans = R
else:
  ans = R + 100*(10 - K)
 
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())

s_dic = {}

for i in range(n):
    tmp = str(input())
    if tmp not in s_dic:
        s_dic[tmp] = 1
    else:
        s_dic[tmp] += 1


max_s_key = [s_value[0] for s_value in s_dic.items() if s_value[1] == max(s_dic.values())]

max_s_key = sorted(max_s_key)

for i in max_s_key:
    print(i)

Fixed submission:
n = int(input())

s_dic = {}

for i in range(n):
    tmp = str(input())
    if tmp not in s_dic:
        s_dic[tmp] = 1
    else:
        s_dic[tmp] += 1

max_value = max(s_dic.values())
s_dic = sorted(s_dic.items(), key=lambda x:x[0])

for i in s_dic:
    if i[1] == max_value:
        print(i[0])
Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int,input().split())
p = list(map(int,input().split()))
expect = []
ans = 0
for i in p:
    expect.append((1 + i)/2)

for i in range(n-k+1):
    tmp = sum(expect[i : i + k])
    ans = max(ans, tmp)

print(ans)

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

sum_p =[0]
tmp = 0
for i in p:
    tmp += i
    sum_p.append(tmp)

max_expect = 0
for i in range(k, n+1):
    tmp = sum_p[i] - sum_p[i - k]
    max_expect = max(tmp, max_expect)

ans = (k + max_expect)/2
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
p = list(map(int,input().split()))

p_total = 0
ans = 0

for i in range(n - k +1):
    tmp = sum(p[i:i+k])
    p_total = max(p_total, tmp)

ans = (k + p_total)/2
print(ans)


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

sum_p =[0]
tmp = 0
for i in p:
    tmp += i
    sum_p.append(tmp)

max_expect = 0
for i in range(k, n+1):
    tmp = sum_p[i] - sum_p[i - k]
    max_expect = max(tmp, max_expect)

ans = (k + max_expect)/2
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
p = list(map(int,input().split()))

p_total = []
max_p_total = 0
ans = 0

for i in range(n - k +1):
    p_total.append(sum(p[i:i+k]))

max_p_total = max(p_total)
ans = (k + max_p_total)/2
print(ans)


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

sum_p =[0]
tmp = 0
for i in p:
    tmp += i
    sum_p.append(tmp)

max_expect = 0
for i in range(k, n+1):
    tmp = sum_p[i] - sum_p[i - k]
    max_expect = max(tmp, max_expect)

ans = (k + max_expect)/2
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
p = list(map(int,input().split()))

expect_value_dice = []
ans = []
for i in p:
    expect_value_dice.append((1+i)/2)


for i in range(n - k +1):
    ans.append(sum(expect_value_dice[i:i+k]))

print(max(ans))

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

sum_p =[0]
tmp = 0
for i in p:
    tmp += i
    sum_p.append(tmp)

max_expect = 0
for i in range(k, n+1):
    tmp = sum_p[i] - sum_p[i - k]
    max_expect = max(tmp, max_expect)

ans = (k + max_expect)/2
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
p = list(map(int,input().split()))

expect_value = []

for i in p:
    expect_value.append((1+i)/2)


max_expect_value = 0
for i in range(n - k + 1):
    tmp = 0
    tmp = sum(expect_value[i:i+k])
    max_expect_value = max(tmp, max_expect_value)

print(max_expect_value)


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

sum_p =[0]
tmp = 0
for i in p:
    tmp += i
    sum_p.append(tmp)

max_expect = 0
for i in range(k, n+1):
    tmp = sum_p[i] - sum_p[i - k]
    max_expect = max(tmp, max_expect)

ans = (k + max_expect)/2
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
A = list(map(int, input().split()))
D = []

for i in range(M):
    B, C = map(int, input().split())
    D += [C]*B

E = sorted(A + D, reverse=True)
print(sum(E[0:N]))

Fixed submission:
N, M = map(int, input().split())
A = list(map(int, input().split()))
D = []
E = []
for i in range(M):
    B, C = map(int, input().split())
    D.append([C, B])
D = sorted(D, reverse = True)

for j in range(len(D)):
    E += [D[j][0]]*D[j][1]
    if len(E) >= N:
        break

F = sorted(A + E, reverse = True)
print(sum(F[0:N]))

Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
A = list(map(int, input().split()))
A = sorted(A)
D = []

for i in range(M):
    B, C = map(int, input().split())
    D += [C]*B

D = sorted(D, reverse=True)

for j in range(min(N, len(D))):
    if A[j] <= D[j]:
        A[j] = D[j]
    else:
        break
print(sum(A))

Fixed submission:
N, M = map(int, input().split())
A = list(map(int, input().split()))
D = []
E = []
for i in range(M):
    B, C = map(int, input().split())
    D.append([C, B])
D = sorted(D, reverse = True)

for j in range(len(D)):
    E += [D[j][0]]*D[j][1]
    if len(E) >= N:
        break

F = sorted(A + E, reverse = True)
print(sum(F[0:N]))
Buggy python submission (verdict: Runtime Error):
from collections import deque

N = int,input()
c = input()

rd = deque([i for i, x in enumerate(c) if x == "R"])
wd = deque([i for i, x in enumerate(c) if x == "W"])
if(len(rd) == 0 or len(wd) == 0):
  print(0)
  exit()
count = 0
for i in range(len(c)):
  if(not(wd[0] < rd[-1])):
    break
  rd.pop()
  wd.popleft()
  count += 1
print(count)

Fixed submission:
from collections import deque

N = int(input())
c = input()

rd = deque([i for i, x in enumerate(c) if x == "R"])
wd = deque([i for i, x in enumerate(c) if x == "W"])
if(len(rd) == 0 or len(wd) == 0):
  print(0)
  exit()
count = 0
for i in range(len(c)):
  if(not(wd[0] < rd[-1])):
    break
  rd.pop()
  wd.popleft()
  count += 1
  if(len(rd) == 0 or len(wd) == 0):
    break
print(count)
Buggy python submission (verdict: Runtime Error):
x = int(import())
print(x+x*x+x*x*x)

Fixed submission:
x = int(input())
print(x+x*x+x*x*x)
Buggy python submission (verdict: Runtime Error):
while available > 1:
    for i in range(available / 2):
    nums[i] = nums[2 * i] * nums[2 * i + 1]
    if(ans > 1000000000000000000):
        print(-1)
        quit()
    if isOdd:
        nums[available / 2 + 1] = nums[-1]
        available //= 2
    if isOdd:
        available += 1
    if a == 0:
        print(0)
        quit()
print(ans)
quit()

Fixed submission:
num = int(input())
str2 = input().split(" ")
nums = [int(s) for s in str2]
nums.sort()

ans = 1

for i in range(len(nums)):
    ans = ans * nums[i]
    if(ans > 1000000000000000000):
        print(-1)
        quit()
print(ans)

Buggy python submission (verdict: Runtime Error):
num = int(input())

str2 = input().split(" ")
nums = [int(s) for s in str2]

isOdd = num%2 == 1
available = range(len(nums))

while available > 1:
    for i in range(available / 2)
    nums[i] = nums[2 * i] * nums[2 * i + 1]
    if(ans > 1000000000000000000):
        print(-1)
        quit()
    if isOdd:
        nums[available / 2 + 1] = nums[-1]
        available //= 2
    if isOdd:
        available += 1
    if a == 0:
        print(0)
        quit()
print(ans)
quit()

Fixed submission:
num = int(input())
str2 = input().split(" ")
nums = [int(s) for s in str2]
nums.sort()

ans = 1

for i in range(len(nums)):
    ans = ans * nums[i]
    if(ans > 1000000000000000000):
        print(-1)
        quit()
print(ans)

Buggy python submission (verdict: Runtime Error):
num = int(input())
str2 = input().split(" ")
nums = [int(s) for s in str2]
nums.sort()

for i in range(len(nums)):
    ans = ans * nums[i]
    if(ans > 1000000000000000000):
        print(-1)
        quit()
print(ans)
quit()

Fixed submission:
num = int(input())
str2 = input().split(" ")
nums = [int(s) for s in str2]
nums.sort()

ans = 1

for i in range(len(nums)):
    ans = ans * nums[i]
    if(ans > 1000000000000000000):
        print(-1)
        quit()
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
str = input()
str2 = input().split(" ")

ans = 1
for x in str2:
    ans = ans * int(x)

if(ans > 1000000000000000000):
    ans = -1

print(ans)

Fixed submission:
num = int(input())
str2 = input().split(" ")
nums = [int(s) for s in str2]
nums.sort()

ans = 1

for i in range(len(nums)):
    ans = ans * nums[i]
    if(ans > 1000000000000000000):
        print(-1)
        quit()
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list(map(int,input().split()))
mul=1
for i in range(len(a)):
    mul=mul*a[i]
    
if mul>10**18:
    print(-1)
if mul<=10**18:
    print(mul)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
mul=1
if a.count(0)>=1:
    print(0)
if a.count(0)==0:
    for i in range(len(a)):
        mul=mul*a[i]
        if mul>10**18:
            break
    
    if mul>10**18:
        print(-1)
    if mul<=10**18:
        print(mul)

Buggy python submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split())
mul=1
flag=0
for i in range(len(a)):
       mul=mul*a[i]
       if mul>10**18:
       		flag=1
			break
if flag==1:
	print(-1)
    continue
print(mul)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
mul=1
if a.count(0)>=1:
    print(0)
if a.count(0)==0:
    for i in range(len(a)):
        mul=mul*a[i]
        if mul>10**18:
            break
    
    if mul>10**18:
        print(-1)
    if mul<=10**18:
        print(mul)
Buggy python submission (verdict: Runtime Error):
from math import inf
import sys
def get_array(): return list(map(int , sys.stdin.readline().strip().split()))
def get_ints(): return map(int, sys.stdin.readline().strip().split())
def input(): return sys.stdin.readline().strip()
n,k=get_ints()
h=get_array()
li=[inf]*n
li[0]=0

li[1]=abs(h[1]-h[0])
for i in range(2,n):
    l=max(0,i-k)
    for j in range(l,i):
     



            li[i]=min(li[i],li[j]+abs(h[i]-h[j]))
##print(li)
print(li[n-1])


Fixed submission:
import numpy as np
inf=10000007

n,k=map(int,input().split())
h=np.array(list(map(int,input().split())))
dp = np.zeros(n,dtype=int)
dp[0]=0

for i in range(1,n):
    l=max(0,i-k)

    dp[i] = np.min(dp[l:i] + abs(h[l:i] - h[i]))




##print(li)
print(dp[-1])

Buggy python submission (verdict: Runtime Error):
from math import inf
import sys
def get_array(): return list(map(int , sys.stdin.readline().strip().split()))
def get_ints(): return map(int, sys.stdin.readline().strip().split())
def input(): return sys.stdin.readline().strip()
n,k=get_ints()
h=get_array()
li=[inf]*n
li[0]=0

li[1]=abs(h[1]-h[0])
for i in range(2,n):
    for j in range(i-1,(i-k)-1,-1):
        if j<0:
            break

            #3print(i,j)
        li[i]=min(li[i],li[j]+abs(h[i]-h[j]))
##print(li)
print(li[n-1])


Fixed submission:
import numpy as np
inf=10000007

n,k=map(int,input().split())
h=np.array(list(map(int,input().split())))
dp = np.zeros(n,dtype=int)
dp[0]=0

for i in range(1,n):
    l=max(0,i-k)

    dp[i] = np.min(dp[l:i] + abs(h[l:i] - h[i]))




##print(li)
print(dp[-1])

Buggy python submission (verdict: Runtime Error):
from math import inf
n,k=map(int,input().split())
h=list(map(int,input().split()))
li=[inf]*n
li[0]=0
li[1]=abs(h[1]-h[0])
for i in range(2,n):
    for j in range(i-1,(i-k)-1,-1):
        if j>=0:
            #3print(i,j)
            li[i]=min(li[i],li[j]+abs(h[i]-h[j]))
##print(li)
print(li[n-1])


Fixed submission:
import numpy as np
inf=10000007

n,k=map(int,input().split())
h=np.array(list(map(int,input().split())))
dp = np.zeros(n,dtype=int)
dp[0]=0

for i in range(1,n):
    l=max(0,i-k)

    dp[i] = np.min(dp[l:i] + abs(h[l:i] - h[i]))




##print(li)
print(dp[-1])
Buggy python submission (verdict: Runtime Error):
N,M=int(input().split())

a = list(map(int,input().strip().split()))[:n] 
  
number=0
total=0
for i in range(N):
  v=a[i]
  total=total+v
for i in range(N):
  v=a[i]
  if v < (1/(4*M))*total:
    number=number
  else:
    number = number+1
if number >= M:
  print("Yes")
else:
  print("No")

Fixed submission:
N,M=input().split()
N,M=[int(N),int(M)]
 
a = list(map(int,input().strip().split()))[:N]
  
number=0
total=0
for i in range(N):
  v=a[i]
  total=total+v
for i in range(N):
  v=a[i]
  if v < (1/(4*M))*total:
    number=number
  else:
    number = number+1
if number >= M:
  print("Yes")
else:
  print("No")

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

number=0
for i in range(N):
  v=int(input())
  if v < 1/(4*M):
    number=number
  else:
    number = number+1
if number >= M:
  print("Yes")
else:
  print("No")

Fixed submission:
N,M=input().split()
N,M=[int(N),int(M)]
 
a = list(map(int,input().strip().split()))[:N]
  
number=0
total=0
for i in range(N):
  v=a[i]
  total=total+v
for i in range(N):
  v=a[i]
  if v < (1/(4*M))*total:
    number=number
  else:
    number = number+1
if number >= M:
  print("Yes")
else:
  print("No")

Buggy python submission (verdict: Runtime Error):
N=int(input())
M=int(input())
number=0
for i in range(N):
  v=int(input())
  if v < 1/(4*M):
    number=number
  else:
    number = number+1
if number >= M:
  print("Yes")
else:
  print("No")

Fixed submission:
N,M=input().split()
N,M=[int(N),int(M)]
 
a = list(map(int,input().strip().split()))[:N]
  
number=0
total=0
for i in range(N):
  v=a[i]
  total=total+v
for i in range(N):
  v=a[i]
  if v < (1/(4*M))*total:
    number=number
  else:
    number = number+1
if number >= M:
  print("Yes")
else:
  print("No")

Buggy python submission (verdict: Runtime Error):
N=input()
M=input()
number=0
for i in range(N):
  v=input()
  if v < 1/(4*M):
    number=number
  else:
    number = number+1
if number >= M:
  print("Yes")
else:
  print("No")

Fixed submission:
N,M=input().split()
N,M=[int(N),int(M)]
 
a = list(map(int,input().strip().split()))[:N]
  
number=0
total=0
for i in range(N):
  v=a[i]
  total=total+v
for i in range(N):
  v=a[i]
  if v < (1/(4*M))*total:
    number=number
  else:
    number = number+1
if number >= M:
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Time Limit Exceeded):
N,K=input().split()
N,K=[int(N),int(K)]

if N%K==0:
  print(0)
else:
  minimum=N
  N=abs(N-K)

  if minimum <=N:
      print(minimum)
  else:
      while minimum > N:
          minimum=N
          N=abs(N-K)
      print(minimum)

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

minimum=N%K
while N%K>K-N%K:
    minimum=K-N%K
    N=K-N%K
print(minimum)

Buggy python submission (verdict: Time Limit Exceeded):
N,K=input().split()
N,K=[int(N),int(K)]
 
minimum=N
N=abs(N-K)
if minimum <=N:
    print(minimum)
else:
    while minimum > N:
        minimum=N
        N=abs(N-K)
    print(minimum)

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

minimum=N%K
while N%K>K-N%K:
    minimum=K-N%K
    N=K-N%K
print(minimum)

Buggy python submission (verdict: Runtime Error):
N,K=input().split()
N,K=[int(N),int(K)]
 
minimum=0
while True:
  minimum=N
  if minimum > = N:
    minimum=N
  else:
    minimum=minimum
    break
  
  
print(minimum)

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

minimum=N%K
while N%K>K-N%K:
    minimum=K-N%K
    N=K-N%K
print(minimum)

Buggy python submission (verdict: Runtime Error):
N,K=input().split()
N,K=[int(N),int(K)]
 
minimum=N
while N < =minimum:
  N=abs(N-K)
  minimum=N
  
  
print(minimum)

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

minimum=N%K
while N%K>K-N%K:
    minimum=K-N%K
    N=K-N%K
print(minimum)

Buggy python submission (verdict: Time Limit Exceeded):
N,K=input().split()
N,K=[int(N),int(K)]

while N >0:
  N=abs(N-K)
print(N)

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

minimum=N%K
while N%K>K-N%K:
    minimum=K-N%K
    N=K-N%K
print(minimum)
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):
s = input()
arr = [int(i) for i in s.split('')]
result = 0
for j in range(arr):
  result += arr[j]
if(result >= 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):
s = input()
arr = [int(i) for i in s.split('')]
result = 0
for i in range(arr):
  result = result+arr[i]
if(result>=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: Time Limit Exceeded):
from collections import deque

queue = deque()

H,W = [int(v) for v in input().split()]
ch,cw = [int(v) for v in input().split()]
dh,dw = [int(v) for v in input().split()]

S = [input() for _ in range(H)]
visited = [[-1 for _ in range (W)] for _ in range(H)]

queue.append((cw-1,ch-1,0))

def check(x,y):
    return x > -1 and x < W and y > -1 and y < H and S[y][x] != "#" and visited[y][x] == -1

while len(queue) != 0:
    x,y,c = queue.popleft()
    if visited[y][x] != -1:
        continue
    visited[y][x] = c

    for d in [1,-1]:
        if check(x+d,y):
            queue.appendleft([x+d,y,c])
        if check(x,y+d):
            queue.appendleft([x,y+d,c])
    
    for dx in [-2,-1,0,1,2]:
        for dy in [-2,-1,0,1,2]:
            if check(x+dx,y+dy):
                queue.append((x+dx,y+dy,c+1))

print(visited[dh-1][dw-1])


Fixed submission:
from collections import deque

queue = deque()

H,W = [int(v) for v in input().split()]
ch,cw = [int(v) for v in input().split()]
dh,dw = [int(v) for v in input().split()]

S = [input() for _ in range(H)]
visited = [[-1 for _ in range (W)] for _ in range(H)]

queue.append((cw-1,ch-1,0))

def check(x,y):
    return x > -1 and x < W and y > -1 and y < H and S[y][x] != "#" and visited[y][x] == -1

while len(queue) != 0:
    x,y,c = queue.popleft()
    if visited[y][x] != -1:
        continue
    visited[y][x] = c

    for d in [1,-1]:
        if check(x+d,y):
            queue.appendleft([x+d,y,c])
        if check(x,y+d):
            queue.appendleft([x,y+d,c])
    
    for dx in [-2,-1,0,1,2]:
        for dy in [-2,-1,0,1,2]:
            if check(x+dx,y+dy):
                queue.append((x+dx,y+dy,c+1))

print(visited[dh-1][dw-1])