Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
s, t = input().split("\n")

s_l = len(s)
t_l = len(t)

max_count = 0
for i in range(0, s_l - t_l):
  count = 0
  for j in range(0, t_l):
    if s[i+j] == t[j]:
      count += 1
  if count > max_count:
    max_count = count

diff = t_l - max_count
print(diff)

Fixed submission:
s = input()
t = input()

s_l = len(s)
t_l = len(t)

max_count = 0
for i in range(0, s_l - t_l + 1):
  count = 0
  for j in range(0, t_l):
    if s[i+j] == t[j]:
      count += 1
  if count > max_count:
    max_count = count

diff = t_l - max_count
print(diff)
Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque

def bfs(fd, n):
    visited = set()
    ans = 1
    for i in range(1, n + 1):
        if i in visited: continue
        volume = 1
        queue = deque(list(fd[i]))
        visited.add(i)
        while queue:
            x = queue.popleft()
            if x in visited: continue
            visited.add(x)
            volume += 1
            for l in fd[x]:
                if l not in visited and l not in queue:
                    queue.append(l)
        ans = max(ans, volume)
    return ans

if __name__ == "__main__":
    n, m = map(int, input().split())
    fd = {i+1:set() for i in range(n)}
    for _ in range(m):
        a, b = map(int, input().split())
        fd[a].add(b)
        fd[b].add(a)
    print(bfs(fd, n))

Fixed submission:
def bfs(fd, n):
    visited = set()
    ans = 1
    for i in range(1, n + 1):
        if i in visited: continue
        volume = 1
        queue = fd[i]
        visited.add(i)
        while queue:
            x = queue.pop()
            if x in visited: continue
            visited.add(x)
            volume += 1
            queue |= fd[x]
        ans = max(ans, volume)
    return ans

if __name__ == "__main__":
    n, m = map(int, input().split())
    fd = {i+1:set() for i in range(n)}
    for _ in range(m):
        a, b = map(int, input().split())
        fd[a].add(b)
        fd[b].add(a)
    print(bfs(fd, n))
Buggy python submission (verdict: Runtime Error):
n, x, t = map(int, input().split())

import math

print(t*math.ceil(int(input())/x))

Fixed submission:
n, x, t = map(int, input().split())

import math

print(t*math.ceil(n/x))
Buggy python submission (verdict: Runtime Error):
n, d = map(int, input().split())
ans = 0
for i in range(n):
    x, y = map(int, input().split())
    if x ** 2 + y ** 2 <= d ** 2
print(ans)

Fixed submission:
n, d = map(int, input().split())
ans = 0
for i in range(n):
    x, y = map(int, input().split())
    if x ** 2 + y ** 2 <= d ** 2:
        ans += 1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
a.sort()
l = [a.pop()]
ans = 0

for i in range(n-1):
    m = a.pop()
    now = 0
    ind = 0
    for j in range(len(l)):
        b = min(l[j], l[(j+1)%len(l)])
        if b > now:
            now = b
            ind = j
    l.insert(ind+1, m)
    ans += now
print(ans)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
a.sort(reverse=True)
q, r = divmod(n, 2)
print(a[0] + sum(a[1:q]) * 2 + a[q] * r)
Buggy python submission (verdict: Runtime Error):
#172C

N,M,K=map(int,input().split())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
ans=0

if K>=sum(A)+sum(B):
    print(N+M)
    exit()
elif K<min(A[0],B[0]):
    print(0)
    exit()
else:
    for i in range(N):
        sum_a=sum(A[:i+1])
        a=A
        b=B
        m=0
        while K>sum_a+b[0] and len(b)>=1:
            sum_a+=b[0]
            b.pop(0)
            m+=1
        if i+1+m>ans:
            ans=i+1+m
print(ans)

Fixed submission:
#172C
#Tsundoku

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

a,b=[0],[0]

for i in range(N):
    a.append(a[i]+A[i])
for j in range(M):
    b.append(b[j]+B[j])

ans=0
j=M

for i in range(N+1):
    if a[i]>K:
        break
    while a[i]+b[j]>K:
        j-=1
    ans=max(ans,i+j)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
#172D
#Sum of Divisors

n=int(input())
ans=0

for i in range(1,n+1):
    j=1
    while i*j<=n:
        ans+=i*j
        j+=1
print(ans)

Fixed submission:
#172D
#Sum of Divisors

n=int(input())
ans=0

for i in range(1,n+1):
    j=n//i
    ans+=j*(j+1)*i/2
print(int(ans))

Buggy python submission (verdict: Time Limit Exceeded):
#172D
#Sum of Divisors

N=int(input())
ans=0
for k in range(N):
    a=0
    for i in range(k+1):
        if (k+1)%(i+1)==0:
            a+=1
    ans+=(k+1)*a
print(ans)

Fixed submission:
#172D
#Sum of Divisors

n=int(input())
ans=0

for i in range(1,n+1):
    j=n//i
    ans+=j*(j+1)*i/2
print(int(ans))
Buggy python submission (verdict: Runtime Error):
n=int(input())
alpha=[chr(i) for i in range(ord('a'),ord('z'))]
ans=''
while n>0:
    n-=1
    ans=alpha[n%26]+ans
    n//=26
print(ans)


Fixed submission:
#171C
##One Quadrillion and One Dalmatians

n=int(input())
alpha=[chr(i) for i in range(ord('a'),ord('z')+1)]
ans=''
while n>0:
    n-=1
    ans=alpha[n%26]+ans
    n//=26
print(ans)

Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python
# coding: utf-8

# In[ ]:


#171C
##One Quadrillion and One Dalmatians

n=int(input())
alpha=[chr(i) for i in range(ord('a'),ord('z'))]
ans=''
while n>0:
    n-=1
    ans=alpha[n%26]+ans
    n//=26
print(ans)



Fixed submission:
#171C
##One Quadrillion and One Dalmatians

n=int(input())
alpha=[chr(i) for i in range(ord('a'),ord('z')+1)]
ans=''
while n>0:
    n-=1
    ans=alpha[n%26]+ans
    n//=26
print(ans)
Buggy python submission (verdict: Runtime Error):
N=int(input())
A=list(map(int,input().split()))
Q=int(input())

base=sum(A)

from collections import Counter

ad=Counter(A)

for _ in range(Q):
    b,c=map(int.input().split())
    if ad[b]!=0:
        base+=(c-b)*ad[b]
        ad[c]+=ad[b]
        ad[b]=0
    print(base)

Fixed submission:
from collections import Counter
n = int(input())
A = list(map(int, input().split()))
C = Counter(A)
ans = sum(A)
q = int(input())
for i in range(q):
    b, c = map(int, input().split())
    if c not in C.keys():
        C[c] = 0
    if b in C.keys():
        ans += (c-b)*C[b]
        C[c] += C[b]
        C[b] = 0
    print(ans)

Buggy python submission (verdict: Runtime Error):
N=int(input())
A=list(map(int,input().split()))
Q=int(input())
L=[0]*100000
for i in range(1,100000):
    a=A.count(i)
    L[i]=a
ans=sum(A)
for _ in range(Q):
    B,C=map(int,input().split())
    ans+=L[B]*(C-B)
    L[C]+=L[B]
    L[B]=0
    print(ans)

Fixed submission:
from collections import Counter
n = int(input())
A = list(map(int, input().split()))
C = Counter(A)
ans = sum(A)
q = int(input())
for i in range(q):
    b, c = map(int, input().split())
    if c not in C.keys():
        C[c] = 0
    if b in C.keys():
        ans += (c-b)*C[b]
        C[c] += C[b]
        C[b] = 0
    print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
#171D
#Replacing
#自分の解き方

N=int(input())
A=list(map(int,input().split()))
Q=int(input())
L=len(A)
S=sum(A)

for i in range(Q):
    ans=0
    B,C=map(int,input().split())
    for j in range(L):
        if A[j]==B:
            A[j]=C
            S+=(C-B)
    ans=S
    print(ans)


Fixed submission:
from collections import Counter
n = int(input())
A = list(map(int, input().split()))
C = Counter(A)
ans = sum(A)
q = int(input())
for i in range(q):
    b, c = map(int, input().split())
    if c not in C.keys():
        C[c] = 0
    if b in C.keys():
        ans += (c-b)*C[b]
        C[c] += C[b]
        C[b] = 0
    print(ans)
Buggy python submission (verdict: Runtime Error):
N=int(input())
A=list(map(int,input().split()))
Q=int(input())
L=len(A)
S=sum(A)

for i in range(Q):
    ans=0
    B,C=map(int,input().split())
    for j in range(L):
        if A[j]==B:
            A[j]=C
            S+=(C-B)
    ans=S
    print(ans)


Fixed submission:
N=int(input())
A=list(map(int,input().split()))
x=0
for a in A:
    x^=a
ans=''
for a in A:
    ans+=str(x^a)+' '
print(ans)
Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python
# coding: utf-8

# In[19]:


#170A
#Five Variables

X=list(map(int,input().split()))
for i in range(5):
    if X[i]==0:
        print(i+1)
        break


# In[ ]:


x = list(map(int,input().split()))
print(x.index(0)+1)



Fixed submission:
#170A
#Five Variables

x = list(map(int,input().split()))
print(x.index(0)+1)
Buggy python submission (verdict: Time Limit Exceeded):
#169B
#Multiplication2

n = int(input())
A = map(int,input().split())
ans=1
for a in A:
    ans*=a
if ans>10**18:
    print(-1)
    exit()
print(ans)

Fixed submission:
#169B
#Multiplication2

n = int(input())
A = list(map(int,input().split()))
ans=1

M=10**18
if 0 in A:
    print(0)
    exit()
for a in A:
    ans*=a
    if ans>M:
        print(-1)
        exit()
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
#164C
#gacha

n=int(input())
l=[]
for i in range(n):
    s=input()
    if s not in l:
        l.append(s)
print(len(l))


Fixed submission:
#164C
#gacha

n=int(input())
l=[]
for i in range(n):
    l.append(input())
    
print(len(set(l)))
Buggy python submission (verdict: Time Limit Exceeded):
#163C
#management

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

for i in range(1,n+1):
    print(a.count(i))

Fixed submission:
#163C
#management

n=int(input())
a=list(map(int,input().split()))
l=[0]*n
for i in range(n-1):
    l[a[i]-1]+=1
for i in range(n):
    print(l[i])
Buggy python submission (verdict: Runtime Error):
#162C
#Sum of gcd of Tuples (Easy)

import math

k=int(input())+1
ans=0
for a in range(1,k):
    for b in range(1,k):
        g=math.gcd(a,b)
        for c in range(1,k):
            ans+=gcd(g,c)
print(ans)

Fixed submission:
#162C
#Sum of gcd of Tuples (Easy)

import math

k=int(input())+1
ans=0
for a in range(1,k):
    for b in range(1,k):
        g=math.gcd(a,b)
        for c in range(1,k):
            ans+=math.gcd(g,c)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
#162C
#Sum of gcd of Tuples (Easy)

import math
from functools import reduce

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

k=int(input())+1
ans=0
for a in range(1,k):
    for b in range(1,k):
        for c in range(1,k):
            ans+=gcd(a,b,c)
print(ans)

Fixed submission:
#162C
#Sum of gcd of Tuples (Easy)

import math

k=int(input())+1
ans=0
for a in range(1,k):
    for b in range(1,k):
        g=math.gcd(a,b)
        for c in range(1,k):
            ans+=math.gcd(g,c)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n,k=map(int,input().split())

if n%k==0:
    print(0)
    exit()

while abs(n-k)<n:
    n=abs(n-k)

print(n)

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

print(min(n%k,abs(n%k-k)))
Buggy python submission (verdict: Runtime Error):
for i in range(1,n1+1):
    if s[i-1]!=s[-i] or s1[i-1]!=s1[-i]:
        print('No')
        exit()
print('Yes')

Fixed submission:
s=input()
n=len(s)
n1=(n-1)//2
n2=(n+3)//2
s1=s[:n1]
s2=s[n2-1:]

for i in range(1,n1+1):
    if s[i-1]!=s[-i]:
        print('No')
        exit()
for i in range(1,n1//2+1):
    if s1[i-1]!=s1[-i]:
        print('No')
        exit()
print('Yes')
Buggy python submission (verdict: Runtime Error):
n, m = map(int, input().split())
ans = ['0'] * n
for i in range(m):
    s, c = map(int,input().split())
    if s == 1 and c == 0 and n != 1:
        print(-1)
        break
    if ans[s-1] != '0' and c != ans[s-1]:
        print(-1)
        break
    ans[s-1] = c
else:
    if n == 1 and int(ans[0]) == 0:
        print(0)
        break
    elif ans[0] == '0':
        ans[0] = '1'
    ans = map(str, ans)
    print(''.join(ans))

Fixed submission:
n, m = map(int, input().split())
ans = ['0'] * n
for i in range(m):
    s, c = map(int,input().split())
    if s == 1 and c == 0 and n != 1:
        print(-1)
        break
    if ans[s-1] != '0' and c != ans[s-1]:
        print(-1)
        break
    ans[s-1] = c
else:
    if n == 1 and int(ans[0]) == 0:
        print(0)
        exit()
    elif ans[0] == '0':
        ans[0] = '1'
    ans = map(str, ans)
    print(''.join(ans))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))

for i in range(n - 1):
    for j in range(i + 1, n):
        if a[i] == a[j]:
            print('NO')
            exit()
print('YES')

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

for i in range(n - 1):
    if a[i] == a[i + 1]:
        print('NO')
        exit()
print('YES')
Buggy python submission (verdict: Time Limit Exceeded):
n, k, q = map(int,input().split())
a = [int(input()) for _ in range(q)]

for i in range(1, n + 1):
    c = a.count(i)
    print('Yes' if k - q + c > 0 else 'No')


Fixed submission:
n, k, q = map(int,input().split())
a = dict((i,0) for i in range(1,n+1))

for _ in range(q):
    a[int(input())] += 1

for i in range(1, n + 1):
    print('Yes' if k - q + a[i] > 0 else 'No')
Buggy python submission (verdict: Time Limit Exceeded):
import bisect

n, m = map(int, input().split())
a = sorted(list(map(int, input().split())))

for i in range(m):
    x = a.pop() // 2
    bisect.insort_right(a, x)

print(sum(a))

Fixed submission:
import heapq

n, m = map(int, input().split())
a = list(map(int, input().split()))
a = list(map(lambda x: x * (-1), a))

heapq.heapify(a)
for i in range(m):
    x = heapq.heappop(a)
    heapq.heappush(a, (-1) * (-x // 2))

print(-sum(a))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
l = [None] * n
ans = 0
for i in range(n):
    l[i] = sorted(input())
for i in range(n-1):
    for j in range(i+1, n):
        if l[i] == l[j]:
            ans += 1
print(ans)

Fixed submission:
n = int(input())
d = {}
ans = 0
for i in range(n):
    s = ''.join(sorted(input()))
    if s in d:
        ans += d[s]
        d[s] += 1
    else:
        d[s] = 1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

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

dp = np.zeros(W+1, np.int64)

for i in range(N):
    w, v = map(int, input().split())
    for j in range(W, w-1, -1):
        dp[j] = max(dp[j], dp[j-w]+v)
print(dp[-1])

Fixed submission:
import numpy as np

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

dp = np.zeros(W+1, np.int64)

for i in range(N):
    w, v = map(int, input().split())
    np.maximum(dp[w:], dp[:-w]+v, out=dp[w:])

print(dp[-1])
Buggy python submission (verdict: Time Limit Exceeded):
ans = 1
n = input()
a = list(map(int,input().split()))
for i in a:
	ans = ans * i
if ans > 10**18:
	print("-1")
else:
	print(ans)

Fixed submission:
ans = 1
n = input()
a = list(map(int,input().split()))
if 0 in a:
	ans = 0
for i in a:
	ans = ans * i
	if ans > 10**18:
		ans = -1
		break
print(ans)
Buggy python submission (verdict: Runtime Error):
a,b=map(int,input().split())
print(a*b//100)

Fixed submission:
a,b=map(int,input().replace('.','').split())
print(a*b//100)
Buggy python submission (verdict: Runtime Error):
n,k = map(int,input().split())
a = list(map(int,input().split()))
b = 1
c = [0] * n
c[0] = 1
m = 0
while c[b-1] < 2 and k > 0:
	b = a[b-1]
	c[b-1] += 1
	k -= 1
while c[b-1] < 3 and k > 0:
	b = a[b-1]
	c[b-1] += 1
	m += 1
o = k % m
for i in range(o):
	b = a[b-1]
print(b)

Fixed submission:
n,k = map(int,input().split())
a = list(map(int,input().split()))
b = 1
c = [0] * n
c[0] = 1
m = 0
while c[b-1] < 2 and k > 0:
	b = a[b-1]
	c[b-1] += 1
	k -= 1
while c[b-1] < 3 and k > 0:
	b = a[b-1]
	c[b-1] += 1
	m += 1
if k == 0:
	print(b)
else:
	o = k % m
	for i in range(o):
		b = a[b-1]
	print(b)

Buggy python submission (verdict: Time Limit Exceeded):
n,k = map(int,input().split())
a = list(map(int,input().split()))
b = 1
for i in range(k):
	b = a[b-1]
print(b)

Fixed submission:
n,k = map(int,input().split())
a = list(map(int,input().split()))
b = 1
c = [0] * n
c[0] = 1
m = 0
while c[b-1] < 2 and k > 0:
	b = a[b-1]
	c[b-1] += 1
	k -= 1
while c[b-1] < 3 and k > 0:
	b = a[b-1]
	c[b-1] += 1
	m += 1
if k == 0:
	print(b)
else:
	o = k % m
	for i in range(o):
		b = a[b-1]
	print(b)
Buggy python submission (verdict: Runtime Error):
s = input()
if s = 'ABC':
	print('ARC')
else:
	print('ABC')

Fixed submission:
s = input()
if s == 'ABC':
	print('ARC')
else:
	print('ABC')
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int,input().split()))
for i in range(1,n+1):
    print(a.count(i))

Fixed submission:
from collections import Counter
n = int(input())
a = list(map(int,input().split()))
acou = Counter(a)
for i in range(1,n+1):
    print(acou[i])

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int,input().split()))
for i in range(1,n+1):
    print(a.count(i))

Fixed submission:
from collections import Counter
n = int(input())
a = list(map(int,input().split()))
acou = Counter(a)
for i in range(1,n+1):
    print(acou[i])
Buggy python submission (verdict: Runtime Error):
a,b,c=map(int,input().split())
print(c+" "+b+" "+a)

Fixed submission:
a,b,c=map(str,input().split())
print(c+" "+a+" "+b)
Buggy python submission (verdict: Time Limit Exceeded):
a, b, c, d = map(int, input().split())
count = 0
for i in range(a,b+1):
        if i % c != 0 and i % d != 0:
                count += 1
print(count)

Fixed submission:
def gcd(x,y):
        while y != 0:
                x, y = y, x%y
        return x

a, b, c, d = map(int, input().split())
g = gcd(c,d)
b_count = b - b//c - b//d + b//(c*d//g)
a_count = (a-1) - (a-1)//c - (a-1)//d + (a-1)//(c*d//g)
print(b_count-a_count)
Buggy python submission (verdict: Runtime Error):
# -*- coding:utf-8 -*-

w, h, x, y = map(int,input().split())
if w/2 == x and h/2 == y:
        max = (w*h)/2
        print("{} 1".format(max))
else:
        max = (w*h)/2
        print("{} 0".format(max))
~

Fixed submission:
w, h, x, y = map(int,input().split())
if w/2 == x and h/2 == y:
        max = (w*h)/2
        print("{} 1".format(max))
else:
        max = (w*h)/2
        print("{} 0".format(max))
Buggy python submission (verdict: Runtime Error):
n = int(input())
l = []
for a in range(2,n-1):
        sum = 0
        sum1 = 0
        b = n - a
        for i in range(len(str(a))):
                sum += int(str(a)[i])
        for i in range(len(str(b))):
                sum1 += int(str(b)[i])
        l.append(sum+sum1)
print(min(l))

Fixed submission:
n = int(input())
l = []
for a in range(1,n):
        sum = 0
        sum1 = 0
        b = n - a
        for i in range(len(str(a))):
                sum += int(str(a)[i])
        for i in range(len(str(b))):
                sum1 += int(str(b)[i])
        l.append(sum+sum1)
print(min(l))

Buggy python submission (verdict: Runtime Error):
n = int(input())
list = []
for a in range(1,n-1):
        sum = 0
        sum1 = 0
        b = n - a
        for j in range(len(str(a))):
                sum += int(str(a)[j])
        for k in range(len(str(b))):
                sum1 += int(str(b)[k])
        list.append(sum + sum1)
print(min(list))


Fixed submission:
n = int(input())
l = []
for a in range(1,n):
        sum = 0
        sum1 = 0
        b = n - a
        for i in range(len(str(a))):
                sum += int(str(a)[i])
        for i in range(len(str(b))):
                sum1 += int(str(b)[i])
        l.append(sum+sum1)
print(min(l))

Buggy python submission (verdict: Runtime Error):
n = int(input())
list = []
for a in range(2,n-1):
        sum = 0
        sum1 = 0
        b = n - a
        for j in range(len(str(a))):
                sum += int(str(a)[j])
        for k in range(len(str(b))):
                sum1 += int(str(b)[k])
        list.append(sum + sum1)
print(min(list))

Fixed submission:
n = int(input())
l = []
for a in range(1,n):
        sum = 0
        sum1 = 0
        b = n - a
        for i in range(len(str(a))):
                sum += int(str(a)[i])
        for i in range(len(str(b))):
                sum1 += int(str(b)[i])
        l.append(sum+sum1)
print(min(l))

Buggy python submission (verdict: Runtime Error):
n = int(input()
list = []
for a in range(2,n-1):
        sum = 0
        sum1 = 0
        b = n - a
        for j in range(len(str(a))):
                sum += int(str(a)[j])
        for k in range(len(str(b))):
                sum1 += int(str(b)[k])
        list.append(sum + sum1)
print(min(list))

Fixed submission:
n = int(input())
l = []
for a in range(1,n):
        sum = 0
        sum1 = 0
        b = n - a
        for i in range(len(str(a))):
                sum += int(str(a)[i])
        for i in range(len(str(b))):
                sum1 += int(str(b)[i])
        l.append(sum+sum1)
print(min(l))
Buggy python submission (verdict: Runtime Error):
n = input()
a = map(int, input().split())
new_list = sorted(a, reverse=True)
sum = 0
for i,n in enumerate(new_list):
        if i % 2 == 0:
                sum += n
        else:
                sum -= n
print(sum)
~

Fixed submission:
n = input()
a = map(int, input().split())
new_list = sorted(a, reverse=True)
sum = 0
for i,n in enumerate(new_list):
        if i % 2 == 0:
                sum += n
        else:
                sum -= n
print(sum)
Buggy python submission (verdict: Runtime Error):
# -*- coding:utf-8 -*-

a,b = map(int, input().split())
sum = a * b
if sum % 2 == 0:
        print("Odd")
else:
        print("Even")
~

Fixed submission:
# -*- coding:utf-8 -*-
a,b = map(int, input().split())
if a * b % 2 != 0:
        print("Odd")
else:
        print("Even")
Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding:utf-8 -*-

n, y = map(int, input().split())
a = 10000
b = 5000
c = 1000
list = []
for i in range(n+1):
        for j in range((n+1)-i):
                for k in range((n+1)-(i+j)):
                        total = a*i + b*j + c*k
                        if total == y:
                                if (i+j+k) == n:
                                        new_list = [i, j, k]
                                        list.append(new_list)
                                        print("{} {} {}".format(i, j, k))
                                        exit()
if not list:
        print("-1 -1 -1")

Fixed submission:
# -*- coding:utf-8 -*-

n, y = map(int, input().split())
a = 10000
b = 5000
c = 1000
list = []
for i in range(n+1):
        for j in range((n+1)-i):
                #for k in range((n+1)-(i+j)):
                        total = a*i + b*j + c*(n-(i+j))
                        if total == y:
                                new_list = [i, j, (n-(i+j))]
                                list.append(new_list)
                                print("{} {} {}".format(i, j, (n-(i+j))))
                                exit()
if not list:
        print("-1 -1 -1")

Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding:utf-8 -*-

n, y = map(int, input().split())
a = 10000
b = 5000
c = 1000
list = []
for i in range(n+1):
        for j in range((n+1)-i):
                for k in range((n+1)-(i+j)):
                        total = a*i + b*j + c*k
                        if total == y:
                                if (i+j+k) == n:
                                        new_list = [i, j, k]
                                        list.append(new_list)
                                        print("{} {} {}".format(i, j, k))
                                        exit()
                        else:
                                continue
if not list:
        print("-1 -1 -1")

Fixed submission:
# -*- coding:utf-8 -*-

n, y = map(int, input().split())
a = 10000
b = 5000
c = 1000
list = []
for i in range(n+1):
        for j in range((n+1)-i):
                #for k in range((n+1)-(i+j)):
                        total = a*i + b*j + c*(n-(i+j))
                        if total == y:
                                new_list = [i, j, (n-(i+j))]
                                list.append(new_list)
                                print("{} {} {}".format(i, j, (n-(i+j))))
                                exit()
if not list:
        print("-1 -1 -1")