Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
import numpy as np
H, W = map(int, input().split())
s = [list(input()) for _ in range(H)]
table = np.zeros((H , W))
done = np.zeros((H , W))
max = 0
print(s[0][1])

for i in range(H):
    for j in range(W):
        if s[i][j] == "#":
            continue
        if done[i][j] == 1:
            continue
        l = 0
        while j + l < W:
            if s[i][j + l] == "#":
                break
            l += 1
        for k in range(l):
            table[i][j + k] += l
            done[i][j+k] = 1
print(table)
done = np.zeros((H , W))
for j in range(W):
    for i in range(H):
        if s[i][j] == "#":
            continue
        if done[i][j] == 1:
            continue
        l = 0
        while i + l < H:
            if s[i + l][j] == "#":
                break
            l += 1
        for k in range(l):
            table[i + k][j] += l
            done[i + k][j] = 1
            if table[i + k][j] > max:
                max = table[i + k][j]

print(table)
print(int(max - 1))

Fixed submission:
import numpy as np
H, W = map(int, input().split())
s = np.array([list(input()) for _ in range(H)])=="."

R = np.zeros((H,W),dtype = int)
L = np.zeros((H,W),dtype = int)
U = np.zeros((H,W),dtype = int)
D = np.zeros((H,W),dtype = int)

for i in range(H):
    U[i] = (U[i - 1] + 1) *s[i]
    D[- i - 1] = (D[-i] + 1) * s[-i-1]
for i in range(W):
    L[:,i] = (L[:,i-1] + 1) * s[:,i]
    R[:,-1-i] = (R[:,-i] + 1) * s[:,-i-1]
print(np.max(L+R+U+D - 3))
Buggy python submission (verdict: Runtime Error):
N, K = map(int, input().split())
V = list(map(int, input().split()))

ans = 0
for l in range(K):
    for r in range(0 , K - l):
        if l + r > K:
            continue
        d = K - (r + l)
        now = 0
        hold = []
        for i in range(l):
            hold.append(V[i])
        for i in range(1 , r + 1):
            hold.append(V[-i])
        hold.sort()
        now = sum(hold)
        for i in range(d):
            if i >= len(hold):
                break
            if hold[i] > 0:
                break
            else:
                now -= hold[i]
        ans = max(ans , now)
print(ans)

Fixed submission:
from collections import deque
from copy import deepcopy
N, K = map(int, input().split())
#V = list(map(int, input().split()))
V = deque(map(int, input().split()))
ans = 0
for l in range(K + 1):
    for r in range(0 , K - l + 1):
        work_V = deepcopy(V)
        if l + r > N:
            continue
        d = K - (r + l)
        now = 0
        hold = []
        for i in range(l):
            #hold.append(V[i])
            hold.append(work_V.popleft())
        for i in range(N - r , N):
            #hold.append(V[-i])
            hold.append(work_V.pop())
        hold.sort()
        now = sum(hold)
        for i in range(d):
            if i >= len(hold):
                break
            if hold[i] > 0:
                break
            else:
                now -= hold[i]
        ans = max(ans , now)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import heapq
N , M = map(int ,input().split())
a = list(map(int ,input().split()))

heapq.heapify(a)

for i in range(M):
    b , c = map(int ,input().split())
    for _ in range(b):
        if c <= a[0]:
            break
        heapq.heappop(a)
        heapq.heappush(a,c)
print(sum(a))

Fixed submission:
import heapq
N , M = map(int ,input().split())
a = list(map(int ,input().split()))

heapq.heapify(a)
lst = []
for i in range(M):
    b , c = map(int ,input().split())
    lst.append([b, c])
lst.sort(reverse = True , key = lambda x: x[1])
#print(lst)
for i in range(M):
    for _ in range(lst[i][0]):
        if lst[i][1] <= a[0]:
            break
        heapq.heappop(a)
        heapq.heappush(a,lst[i][1])
print(sum(a))

Buggy python submission (verdict: Time Limit Exceeded):
import heapq
N , M = map(int ,input().split())
a = list(map(int ,input().split()))

heapq.heapify(a)

for i in range(M):
    b , c = map(int ,input().split())
    for _ in range(b):
        if c <= a[0]:
            break
        heapq.heappop(a)
        heapq.heappush(a,c)
print(sum(a))

Fixed submission:
import heapq
N , M = map(int ,input().split())
a = list(map(int ,input().split()))

heapq.heapify(a)
lst = []
for i in range(M):
    b , c = map(int ,input().split())
    lst.append([b, c])
lst.sort(reverse = True , key = lambda x: x[1])
#print(lst)
for i in range(M):
    for _ in range(lst[i][0]):
        if lst[i][1] <= a[0]:
            break
        heapq.heappop(a)
        heapq.heappush(a,lst[i][1])
print(sum(a))
Buggy python submission (verdict: Runtime Error):
S = list(input())
ans = 0
i = 0
lst = ["A","C","G","T"]
while i < len(S):
    cnt = 0
    if S[i] in lst:
        cnt = 1
        for j in range(1 , 4):
            if not S[j + i] in lst or i + j >= len(S):
                break
            cnt += 1
        ans = cnt
    i += j
print(ans)

Fixed submission:
S = list(input())
ans = 0
i = 0
cnt = 0
lst = ["A","C","G","T"]
for c in S:
    if c in lst:
        cnt += 1
    else:
        if ans < cnt:
            ans = cnt
        cnt = 0
if ans < cnt:
    ans = cnt
print(ans)

Buggy python submission (verdict: Runtime Error):
S = list(input())
ans = 0
i = 0
lst = ["A","C","G","T"]
while i < len(S) - 1:
    cnt = 0
    if S[i] in lst:
        cnt = 1
        for j in range(4):
            j += 1
            if not S[j] in lst:
                break
            cnt += 1
        ans = cnt
    i += 1
print(ans)

Fixed submission:
S = list(input())
ans = 0
i = 0
cnt = 0
lst = ["A","C","G","T"]
for c in S:
    if c in lst:
        cnt += 1
    else:
        if ans < cnt:
            ans = cnt
        cnt = 0
if ans < cnt:
    ans = cnt
print(ans)
Buggy python submission (verdict: Runtime Error):
import numpy as np
N , Q = map(int,input().split())

S = list(input())
l_list = []
r_list = []
slice_list = []
for _ in range(Q):
    l , r =map(int,input().split())
    slice_list.append([l - 1,r - 1])
cnt_list = [0] * (N + 1)
#print(cnt_list)

for i in range(len(S)):
    if S[i] == "A" and S[i + 1] == "C":
        cnt_list[i + 1] = cnt_list[i] + 1
    else:
        cnt_list[i + 1] = cnt_list[i]
#print(cnt_list)
for i in range(Q):
    #l, r = map(int, input().split())
    print(cnt_list[slice_list[i][1]] - cnt_list[slice_list[i][0]])

Fixed submission:
N , Q = map(int,input().split())
S = list(input())
slice_list = []
for _ in range(Q):
    l , r =map(int,input().split())
    slice_list.append([l - 1,r - 1])
cnt_list = [0] * (N + 1)

for i in range(N - 1):
    if S[i] == "A" and S[i + 1] == "C":
        cnt_list[i + 1] = cnt_list[i] + 1
    else:
        cnt_list[i + 1] = cnt_list[i]

for i in range(Q):

    print(cnt_list[slice_list[i][1]] - cnt_list[slice_list[i][0]])

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

S = list(input())
slice_list = []
for _ in range(Q):
    l , r =map(int,input().split())
    slice_list.append([l - 1,r])
for i in range(Q):
    cnt = 0
    work_s = S[slice_list[i][0] : slice_list[i][1]]
    for i in range(len(work_s) - 1):
        if work_s[i] == "A" and work_s[i + 1] == "C":
            cnt += 1
    print(cnt)

Fixed submission:
N , Q = map(int,input().split())
S = list(input())
slice_list = []
for _ in range(Q):
    l , r =map(int,input().split())
    slice_list.append([l - 1,r - 1])
cnt_list = [0] * (N + 1)

for i in range(N - 1):
    if S[i] == "A" and S[i + 1] == "C":
        cnt_list[i + 1] = cnt_list[i] + 1
    else:
        cnt_list[i + 1] = cnt_list[i]

for i in range(Q):

    print(cnt_list[slice_list[i][1]] - cnt_list[slice_list[i][0]])

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

S = list(input())
slice_list = []
for _ in range(Q):
    l , r =map(int,input().split())
    slice_list.append([l - 1,r])
for i in range(Q):
    cnt = 0
    work_s = S[slice_list[i][0] : slice_list[i][1]]
    for i in range(len(work_s) - 1):
        if work_s[i] == "A" and work_s[i + 1] == "C":
            cnt += 1
    print(cnt)

Fixed submission:
N , Q = map(int,input().split())
S = list(input())
slice_list = []
for _ in range(Q):
    l , r =map(int,input().split())
    slice_list.append([l - 1,r - 1])
cnt_list = [0] * (N + 1)

for i in range(N - 1):
    if S[i] == "A" and S[i + 1] == "C":
        cnt_list[i + 1] = cnt_list[i] + 1
    else:
        cnt_list[i + 1] = cnt_list[i]

for i in range(Q):

    print(cnt_list[slice_list[i][1]] - cnt_list[slice_list[i][0]])
Buggy python submission (verdict: Time Limit Exceeded):
N , M = map(int,input().split())
X = list(map(int,input().split()))
X.sort(reverse=True)
diff = []
for i in range(len(X) - 1):
    diff.append(X[i] - X[i + 1])
for _ in range(N - 1):
    if not diff:
        print("0")
        exit()
    else:
        diff.remove(max(diff))
print(sum(diff))

Fixed submission:
import heapq
N , M = map(int,input().split())
X = list(map(int,input().split()))
X.sort(reverse=True)
diff = []
heapq.heapify(diff)
for i in range(len(X) - 1):
    heapq.heappush(diff , -1 * (X[i] - X[i + 1]))
for _ in range(N - 1):
    if not diff:
        print("0")
        exit()
    else:
        heapq.heappop(diff)

print(-1 * sum(diff))
Buggy python submission (verdict: Runtime Error):
N, X = map(int, input().split())
patty = [1]
buns = [0]

for i in range(0, N):
    patty.append(patty[i] * 2 + 1)
    buns.append(buns[i] * 2 + 2)

# print(patty)
# print(buns)

burger_high = patty[N] + buns[N]


def dfs(now_runrun, now_burger_high, dimension):
    ## るんるんが一番下にいれば一つもパティは食べれない
    if now_runrun == 1:
        return 0

    ## るんるんが真ん中にいたら、n - 1次元バーガー + 1を食べる
    elif now_runrun == now_burger_high // 2 + 1:
        return patty[dimension - 1] + 1

    ## るんるんが一番上にいたら全てのパティを食べる
    elif now_runrun == now_burger_high:
        return patty[dimension]


    elif now_runrun <= now_burger_high // 2:
        return dfs(now_runrun - 1, now_burger_high // 2, dimension - 1)
    else:
        return dfs(now_runrun - (patty[dimension - 1] + buns[dimension - 1] + 2),
                   buns[dimension - 1] + patty[dimension - 1], dimension - 1) + patty[dimension - 1] + 1


print(dfs(X, burger_high, N))


Fixed submission:
N, X = map(int, input().split())
patty = [1]
buns = [0]

for i in range(0, N):
    patty.append(patty[i] * 2 + 1)
    buns.append(buns[i] * 2 + 2)


burger_high = patty[N] + buns[N]



def dfs(now_runrun, now_burger_high, dimension):
    if dimension == 0:
        return 1
    ## るんるんが一番下にいれば一つもパティは食べれない
    elif now_runrun == 1:
        return 0

    ## るんるんが真ん中にいたら、n - 1次元バーガー + 1を食べる
    elif now_runrun == now_burger_high // 2 + 1:
        return patty[dimension - 1] + 1

    ## るんるんが一番上にいたら全てのパティを食べる
    elif now_runrun == now_burger_high:
        return patty[dimension]


    next_burger = now_burger_high // 2 - 1
    next_dimension = dimension - 1

    if now_runrun <= now_burger_high // 2:
        return dfs(now_runrun - 1, next_burger, next_dimension)
    else:
        return dfs(now_runrun - (patty[next_dimension] + buns[next_dimension] + 2),
                   next_burger, next_dimension) + patty[next_dimension] + 1


print(dfs(X, burger_high, N))
Buggy python submission (verdict: Time Limit Exceeded):
import math
def lcm(x, y):
    return (x * y) // math.gcd(x, y)


N, M = map(int, input().split())
S = input()
T = input()
L = lcm(N, M)
d = {}
s = list()
# s = set()
for i in range(N):
    d[str(i * (L // N))] = S[i]
    s.append(str(i * (L // N)))
    # s.add(str(i * (L // N)))

for i in range(M):
    key = str(i * (L // M))
    if key in s:
        if d[key] != T[i]:
            print(-1)
            exit()
print(L)

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


N, M = map(int, input().split())
S = input()
T = input()
L = lcm(N, M)
d = {}
s = set()
for i in range(N):
    d[str(i * (L // N))] = S[i]
    s.add(str(i * (L // N)))

for i in range(M):
    key = str(i * (L // M))
    if key in s:
        if d[key] != T[i]:
            print(-1)
            exit()
print(L)

Buggy python submission (verdict: Runtime Error):
import math
def lcm(x, y):
    return (x * y) // math.gcd(x, y)


N, M = map(int, input().split())
s = input()
t = input()
L = lcm(N, M)
X = [''] * L
for i in range(N):
    X[i * (L // N)] = s[i]
for i in range(M):
    if X[i * (L // M)] == '':
        X[i * (L // M)] = t[i]
    elif X[i * (L // M)] == t[i]:
        continue
    else:
        print(-1)
        exit()
# print(X)
print(L)

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


N, M = map(int, input().split())
S = input()
T = input()
L = lcm(N, M)
d = {}
s = set()
for i in range(N):
    d[str(i * (L // N))] = S[i]
    s.add(str(i * (L // N)))

for i in range(M):
    key = str(i * (L // M))
    if key in s:
        if d[key] != T[i]:
            print(-1)
            exit()
print(L)
Buggy python submission (verdict: Runtime Error):
N = int(input())
a = int(input())
b = int(input())

if N == 1:
  print("Hello World")
else:
  print(a + b)

Fixed submission:
N = int(input())
if N == 1:
  print("Hello World")
else:
  a = int(input())
  b = int(input())
  print(a + b)
Buggy python submission (verdict: Runtime Error):
S = list(input())
for s in S:
  if s == "1":
	print("9",end = "")
  else:
    print("1",end = "")

Fixed submission:
S = list(input())
for s in S:
    if s == "1":
        print("9",end = "")
    else:
        print("1",end = "")
Buggy python submission (verdict: Runtime Error):
a , b , c = soted(map(int, input().split()))
print(c * 10 + b + a)

Fixed submission:
a , b , c = sorted(map(int, input().split()))
print(c * 10 + b + a)

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

Fixed submission:
a , b , c = sorted(map(int, input().split()))
print(c * 10 + b + a)
Buggy python submission (verdict: Runtime Error):
from math import gcd
N, X = map(int, input().split())
x = list(map(int, input().split()))
x.insert(0, X)
distance = []
for i in range(1, len(x)):
    distance.append(abs(x[i] - x[i - 1]))

ans = distance[0]
for i in range(1, len(distance)):
    ans = gcd(ans, distance[i])
print(ans)

Fixed submission:
import bisect
def gcd(x , y):
    max_val = max(x , y)
    min_val = min(x , y)
    while min_val != 0:
        max_val , min_val = min_val , max_val % min_val
    return max_val
N , X = map(int,input().split())
x = list(map(int,input().split()))
x.sort()
split_idx = bisect.bisect_left(x , X)
BeforeList = x[:split_idx]
AfterList = x[split_idx:]
now = X
ans = 0
DistanceList = []
for val in AfterList:
    distance = abs(val - now)
    DistanceList.append(distance)
    now = val
for val in BeforeList:
    distance = abs(val - now)
    DistanceList.append(distance)
    now = val

ans = DistanceList[0]
for i in range(1,len(DistanceList)):
    ans = gcd(DistanceList[i] , ans)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N , K = map(int,input().split())
x = list(map(int,input().split()))
ans = float("inf")
for i in range(N - K + 1):
    search_candles = x[i : i + K]
    if search_candles[-1] <= 0:
        tmp_min = abs(search_candles[0])
    elif 0 <= search_candles[0]:
        tmp_min = abs(search_candles[-1])
    else:
        PassTwice = min(abs(search_candles[-1]) ,abs(search_candles[0])) * 2
        PassOnce = max(abs(search_candles[-1]) ,abs(search_candles[0]))
        tmp_min = PassTwice + PassOnce
    if tmp_min < ans:
        ans = tmp_min
print(ans)

Fixed submission:
N , K = map(int,input().split())
x = list(map(int,input().split()))
ans = float("inf")
for i in range(N - K + 1):
    #x = x[i : i + K]

    if x[i + K - 1] <= 0:
        tmp_min = abs(x[i])
    elif 0 <= x[i]:
        tmp_min = abs(x[i + K - 1])
    else:
        PassTwice = min(abs(x[i + K - 1]) ,abs(x[i])) * 2
        PassOnce = max(abs(x[i + K - 1]) ,abs(x[i]))
        tmp_min = PassTwice + PassOnce
    if tmp_min < ans:
        ans = tmp_min
print(ans)
Buggy python submission (verdict: Runtime Error):
n , m = map(int,input().split())
war = []
for _ in range(m):
    a , b = map(int,input().split())
    war.append([a,b])
war.sort()
ans = 1
min_right = min(war[0][1] , war[1][1])
max_left = max(war[0][0] , war[1][0])
for i in range(0,m - 1):
    now_left, now_right = war[i][0], war[i][1]
    next_left , next_right = war[i + 1][0] , war[i + 1][1]
    min_right = min(min_right , next_right)
    max_left = max(max_left,next_left)
    if max_left >= min_right:
        ans += 1
        min_right = next_right
print(ans)

Fixed submission:
n , m = map(int,input().split())
war = []
for _ in range(m):
    a , b = map(int,input().split())
    war.append([a,b])
war.sort()
ans = 1
min_right = war[0][1]
max_left = war[0][0]
for i in range(0,m - 1):
    now_left, now_right = war[i][0], war[i][1]
    next_left , next_right = war[i + 1][0] , war[i + 1][1]
    min_right = min(min_right , next_right)
    max_left = max(max_left,next_left)
    if max_left >= min_right:
        ans += 1
        min_right = next_right
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int,input().split()))
ans = 0
for a in A:
    cnt = 0
    for i in range(1,a + 1):
        if a % 2**i == 0:
            cnt += 1
    else:
        ans += cnt
print(ans)

Fixed submission:
N = int(input())
A = list(map(int,input().split()))
ans = 0
for a in A:
    cnt = 0
    for i in range(1,a + 1):
        if a % 2**i == 0:
            cnt += 1
        else:
            break
    ans += cnt
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N, C = map(int, input().split())
D = [list(map(int, input().split())) for _ in range(C)]
c = [list(map(int, input().split())) for _ in range(N)]
sum_val = [[0] * C for _ in range(3)]

for color in range(1, C + 1):
    for i in range(N):
        for j in range(N):
            sum_val[(i + j) % 3][color - 1] += D[c[i][j] - 1][color - 1]

ans = float('inf')
for i in range(C):
    for j in range(C):
        for k in range(C):
            if i == j or j == k or i == k:
                continue
            ans = min(ans, sum_val[0][i] + sum_val[1][j] + sum_val[2][k])
print(ans)

Fixed submission:
N, C = map(int, input().split())
D = [list(map(int, input().split())) for _ in range(C)]
c = [list(map(int, input().split())) for _ in range(N)]
sum_val = [[0] * C for _ in range(3)]

for color in range(1, C + 1):
    for i in range(N):
        for j in range(N):
            sum_val[(i + j) % 3][color - 1] += D[c[i][j] - 1][color - 1]

ans = float('inf')
for i in range(C):
    for j in range(C):
        for k in range(C):
            if i == j or j == k or i == k:
                continue
            ans = min(ans, sum_val[0][i] + sum_val[1][j] + sum_val[2][k])
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
X = int(input())
ans = 1
for i in range(2,X):
    for j in range(2,X):
        tmp_ans = i ** j
        if tmp_ans > ans and tmp_ans <= X:
            ans = tmp_ans
print(ans)

Fixed submission:
X = int(input())
ans = 1
for b in range(2,X):
    for p in range(2,X):
        tmp_ans = b ** p
        if tmp_ans > X:
            break
        if tmp_ans > ans:
            ans = tmp_ans
print(ans)
Buggy python submission (verdict: Runtime Error):
H , W = map(int,input().split())
stage = list(list(input()) for _ in range(H))

dx = [0,1,0,-1]
dy = [1,0,-1,0]
for i in range(H):
    for j in range(W):
        if stage[i][j] == ".":
            continue
        Flag = True
        for k in range(4):
            if 0 <= i + dx[k] < W and 0 <= j + dy[k] < H  and stage[i + dx[k]][j + dy[k]] == "#":
                Flag = False
                break
        if Flag:
            print("No")
            exit()
print("Yes")

Fixed submission:
H , W = map(int,input().split())
stage = list(list(input()) for _ in range(H))

dx = [0,1,0,-1]
dy = [1,0,-1,0]
for i in range(H):
    for j in range(W):
        if stage[i][j] == ".":
            continue
        Flag = True
        for k in range(4):
            if 0 <= j + dx[k] < W and 0 <= i + dy[k] < H and stage[i + dy[k]][j + dx[k]] == "#":
                Flag = False
                break
        if Flag:
            print("No")
            exit()
print("Yes")
Buggy python submission (verdict: Runtime Error):
from collections import deque

def dfs(stage , visited , start_x,start_y,goal_x,goal_y):
    queue = deque([[start_x,start_y]])
    visited[start_x][start_y] = 1
    while queue:
        x , y = queue.popleft()
        if [x , y] == [goal_x,goal_y]:
            return visited[x][y]
        for dx , dy in ([1,0],[-1,0],[0,1],[0,-1]):
            new_x , new_y = x + dx , dy + y
            #print(new_x,new_y)
            if 0 <= new_x <= goal_x and 0 <= new_y <= goal_y  and stage[new_x][new_y] == "." and visited[new_x][new_y] == -1:
                #print(new_x , new_y)
                visited[new_x][new_y] = visited[x][y] + 1
                queue.append([new_x,new_y])
        #print(queue)
if __name__ == "__main__":
    H , W = map(int , input().split())
    stage = []
    for _ in range(H):
        stage.append(list(input()))
    start_x,start_y ,goal_x,goal_y = 0,0,H-1,W-1
    visited = [[-1] * W for _ in range(H)]
    #print(visited)
    #print(stage)
    #print(visited[0][1])
    sum = 0
    for value in stage:
        sum += value.count('.')
    #print(sum)
    print(sum - dfs(stage,visited,start_x,start_y,goal_x,goal_y))


Fixed submission:
from collections import deque

def dfs(stage , visited , start_x,start_y,goal_x,goal_y):
    queue = deque([[start_x,start_y]])
    visited[start_x][start_y] = 1
    while queue:
        x , y = queue.popleft()
        if [x , y] == [goal_x,goal_y]:
            return visited[x][y]

        for dx , dy in ([1,0],[-1,0],[0,1],[0,-1]):
            new_x , new_y = x + dx , dy + y
            #print(new_x,new_y)
            if 0 <= new_x <= goal_x and 0 <= new_y <= goal_y  and stage[new_x][new_y] == "." and visited[new_x][new_y] == -1:
                #print(new_x , new_y)
                visited[new_x][new_y] = visited[x][y] + 1
                queue.append([new_x,new_y])
    print("-1")
    exit(0)
if __name__ == "__main__":
    H , W = map(int , input().split())
    stage = []
    for _ in range(H):
        stage.append(list(input()))
    start_x,start_y ,goal_x,goal_y = 0,0,H-1,W-1
    visited = [[-1] * W for _ in range(H)]
    #print(visited)
    #print(stage)
    #print(visited[0][1])
    sum = 0
    for value in stage:
        sum += value.count('.')
    #print(sum)
    print(sum - dfs(stage,visited,start_x,start_y,goal_x,goal_y))
Buggy python submission (verdict: Runtime Error):
N , Y = map(int , input().split())
for y in range(N + 1):
    z = - N / 9 + Y / 9000 - 4 * y / 9
    tmp_z = z - int(z)
    if int(str(tmp_z)[2]) != 0:
        continue
    else:
        z = int(z)
    x = 5 * N / 4 - Y / 4000 + 5 * z / 4
    tmp_x = x - int(x)
    if int(str(tmp_x)[2]) != 0:
        continue
    else:
        x = int(x)
    '''
    if x >= 0 and y >= 0 and z >= 0:
        print("------------")
        print(x)
        print(y)
        print(z)
        print("------------")
    '''
    if x + y + z == N and 1000 * x + 5000 * y + 10000 * z == Y and 2000 >= x >= 0 and 2000 >= z >= 0:#and y >= 0 and z >= 0:
        print(z,y,x)
        exit(0)
print("-1 -1 -1")

Fixed submission:
N , Y = map(int , input().split())
for k1 in range(N + 1):
    for k5 in range(N + 1 - k1):
        k10 = N - k1 - k5
        if k1 + k5 + k10 == N and 1000 * k1 + 5000 * k5 + 10000 * k10 == Y and k10 >= 0:
            print(k10 , k5 , k1)
            exit(0)
print("-1 -1 -1 ")