Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
n, q = map(int, input().split())
s = input()
l = [0]*q; r = [0]*q

for i in range(q):
    l[i], r[i] = map(int, input().split())

cum = [0]*n
for i in range(n-1):
    if s[i] == 'A' and s[i+1] == 'C':
        cum[i] = 1

for i in range(q):
    print(sum(cum[l[i]-1:r[i]-1]))



Fixed submission:
n, q = map(int, input().split())
s = input()
t = [0]*(n+1)

for i in range(n):
	t[i+1] = t[i] + (1 if s[i:i+2]=='AC' else 0)

for i in range(q):
	l, r = map(int, input().split())
	print(t[r-1] - t[l-1])

Buggy python submission (verdict: Time Limit Exceeded):
n, q = map(int, input().split())
s = input()
l = [0]*q; r = [0]*q

for i in range(q):
    l[i], r[i] = map(int, input().split())
cum = [0]*n
for i in range(n-1):
    if s[i] == 'A' and s[i+1] == 'C':
        cum[i] = 1
for i in range(q):
    temp = cum[l[i]-1:r[i]]
    cnt = 0
    for j in range(len(temp) - 1):
        if temp[j] == 1 and temp[j+1] == 0:
            cnt += 1
    print(cnt)

Fixed submission:
n, q = map(int, input().split())
s = input()
t = [0]*(n+1)

for i in range(n):
	t[i+1] = t[i] + (1 if s[i:i+2]=='AC' else 0)

for i in range(q):
	l, r = map(int, input().split())
	print(t[r-1] - t[l-1])
Buggy python submission (verdict: Runtime Error):
    a,b=map(int,input().split())
     
    if((a*b)%2 == 0):
        print('Even')
    else:
        print('Odd')

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

if((a*b)%2 == 0):
	print('Even')
else:
	print('Odd')

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

if((a*b)%2 == 0):
  print('Even')
  else:
    print('Odd')

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

if((a*b)%2 == 0):
	print('Even')
else:
	print('Odd')

Buggy python submission (verdict: Runtime Error):
c = a*b
if c%2 ==0:
  print('Even')
else
  print('Odd')

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

if((a*b)%2 == 0):
	print('Even')
else:
	print('Odd')
Buggy python submission (verdict: Runtime Error):
import numpy as np

n = int(input())
f = np.array([list(map(int, input().split())) for i in range(n)])
p = np.array([list(map(int, input().split())) for i in range(n)])

ans = -99999999

openptn=np.array([[int(s) for s in list('{0:010b}'.format(i))] for i in range(1,2**10)])

for i in range(2**10 - 1):
	subans = 0
	for j in range(n):
		count = sum(f[j]*openptn[i])
		print(f[j]*openptn[i])

		subans +=p[j][count]
        count = 0
		
		#print(subans)
	ans = max(ans, subans)

print(ans)

Fixed submission:
n, a, b = list(map(int, input().split()))
print(min(n*a, b))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())

for h in range(1, 3501):

    for n in range(1, 3501):

        if (4*h*n - N*n - N*h) ==0:
            continue

        w = N*h*n/(4*h*n - N*n - N*h)
        flag = w.is_integer()
        # print(flag)
        
        if flag and w>0:
            print(h, n, int(w))
            exit()

Fixed submission:
N = int(input())

for h in range(1, 3501):

    for n in range(1, 3501):

        if (4*h*n - N*n - N*h)<=0:
            continue

        w = N*h*n/(4*h*n - N*n - N*h)
        flag = w.is_integer()
        # print(flag)
        
        if flag and w>0:
            print(h, n, int(w))
            exit()
Buggy python submission (verdict: Runtime Error):
import numpy as np
import math
from functools import reduce

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

N, X = map(int, input().split())
x = list(map(int, input().split()))

d = np.zeros(N, dtype=int)
for n in range(N):
    d[n] = x[n] - X

gcd = reduce(math.gcd, d)

# print(d)
print(gcd)


Fixed submission:
import numpy as np
import math
from functools import reduce

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

def gcd(a: int, b: int): return gcd(b, a % b) if b else a

N, X = map(int, input().split())
x = list(map(int, input().split()))

d = np.zeros(N, dtype=int)
for n in range(N):
    d[n] = x[n] - X

ret = abs(reduce(gcd, d))

# print(d)
print(ret)
Buggy python submission (verdict: Runtime Error):
import numpy as np
import math

S = input()
K = int(input())

k = 0
while S[k] == '1' and k < K:
    k += 1

if k == K:
    print('1')
else:
    print(S[k])

    


Fixed submission:
import numpy as np
import math

S = input()
K = int(input())

k = 0
#  
while k < len(S) and S[k] == '1' and k < K:
    k += 1

if k == K or k == len(S):
    print('1')
else:
    print(S[k])
Buggy python submission (verdict: Runtime Error):
import numpy as np

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

grid = np.zeros((H, W), dtype=int)

for h in range(H):
    S = input()
    for i, s in enumerate(S):
        if s == '#':
            grid[h][i] = 1

# print(grid)


def is_safe(h, w):
    ns = []
    ns.append((h-1, w))
    ns.append((h, w-1))
    ns.append((h+1, w))
    ns.append((h, w+1))

    safe = False
    for n in ns:
        if 0 <= n[0] and n[0] < H \
           and 0 <= n[1] and n[1] < H \
           and grid[n[0]][n[1]] == 1:
            safe = True

    if safe is False:
        print("No")
        exit(0)

    
for h in range(H):
    for w in range(W):
        if grid[h][w] == 1:
            is_safe(h, w)

print("Yes")
exit(0)


Fixed submission:
import numpy as np

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

grid = np.zeros((H, W), dtype=int)

for h in range(H):
    S = input()
    for i, s in enumerate(S):
        if s == '#':
            grid[h][i] = 1

# print(grid)


def is_safe(h, w):
    ns = []
    ns.append((h-1, w))
    ns.append((h, w-1))
    ns.append((h+1, w))
    ns.append((h, w+1))

    safe = False
    for n in ns:
        if 0 <= n[0] and n[0] < H \
           and 0 <= n[1] and n[1] < W \
           and grid[n[0]][n[1]] == 1:
            safe = True

    if safe is False:
        print("No")
        exit(0)

    
for h in range(H):
    for w in range(W):
        if grid[h][w] == 1:
            is_safe(h, w)

print("Yes")
exit(0)
Buggy python submission (verdict: Runtime Error):
a=int(input())
b=int(input())
print((a-1)*(b-1))

Fixed submission:
a,b=(int(i) for i in input().split())
print((a-1)*(b-1))

Buggy python submission (verdict: Runtime Error):
a=int(input())
b=int(input())
s=(a-1)*(b-1)
print(s)

Fixed submission:
a,b=(int(i) for i in input().split())
print((a-1)*(b-1))
Buggy python submission (verdict: Runtime Error):
n=int(input())
string=""

if n==0:
    string="0"
while n!=0:
    if n%2==1:
        string="1"+string
        n=n-1
    else:
        string="0"+string
    n=n//(-2)
    
print(string)

Fixed submission:
n,k=(int(i) for i in input().split())
if n%k==0:
    print(0)
else:
    print(1)

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

if n==0:
    string="0"
while n!=0:
    if n%2==1:
        string="1"+string
        n=n-1
    else:
        string="0"+string
    n=n/(-2)
    
print(string)

Fixed submission:
n,k=(int(i) for i in input().split())
if n%k==0:
    print(0)
else:
    print(1)

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

while n!=0:
    if n%2==1:
        string="1"+string
        n=n-1
    else:
        string="0"+string
    n=n/(-2)
if n==0:
    string="0"+string
    
print(string)

Fixed submission:
n,k=(int(i) for i in input().split())
if n%k==0:
    print(0)
else:
    print(1)

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

while n!=0:
    if n%2==1:
        string="1"+string
        n=n-1
    else:
        string="0"+string
    n=n/(-2)
if n==0:
    string="0"
    
print(string)

Fixed submission:
n,k=(int(i) for i in input().split())
if n%k==0:
    print(0)
else:
    print(1)
Buggy python submission (verdict: Runtime Error):
from statistics import median

task=[0,0,0]

for i in range(3):
    a=input()
    task[i]=int(a)
    
b=median(task)
sum=0

for i in range(3):
    sum+=abs(b-task[i])
    
sum

Fixed submission:
from statistics import median

task=[int(i) for i in input().split()]
    
b=median(task)
sum=0

for i in range(3):
    sum+=abs(b-task[i])
    
print(sum)
Buggy python submission (verdict: Runtime Error):
print(int(r*r))

Fixed submission:
r=int(input()) 
print(r*r)
Buggy python submission (verdict: Runtime Error):
import numpy as np
v=np.array(list(map(int, input().split())) )
mod = 10**9 +7
import math
def cmb(n, r,mod):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n
    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result = (result*int(numerator[k]))%mod

    return result
  
A = np.array([[2,1],[1,2]])
inv_A = np.linalg.inv(A)

k = np.dot(inv_A,v)

if abs(round(k[0]+ k[1])-(k[0]+k[1]))<10**(-10) and k[0]* k[1] >=0:
  print(cmb(round(k[0]+k[1]),round(k[0]),mod))
else:
  print(0)

Fixed submission:
import numpy as np
v=np.array(list(map(int, input().split())) )
mod = 10**9 +7
import math
def cmb(n, r,mod):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n
    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result = (result*int(numerator[k]))%mod

    return result
  
A = np.array([[2,1],[1,2]])
inv_A = np.linalg.inv(A)

k = np.dot(inv_A,v)

if abs(round(k[0])-k[0])<10**(-10) and abs(round(k[1])-k[1])<10**(-10) and k[0]* k[1] >=0:
  print(int(cmb(int(round(k[0]+k[1])),int(round(k[0])),mod)))
else:
  print(0)
Buggy python submission (verdict: Runtime Error):
import collections
import sys
N=int(input()) 
d=list(map(int, input().split())) 

c = collections.Counter(d)
if d[0] != 0:
  print(0)
  sys.exit()
c = dict(collections.Counter(d))
max_key = max(c.keys())

count = 1
for i in range(1,max_key):
  a = c.get(i, -1)
  b = c.get(i+1, -1)
  if a == -1:
    print(0)
    sys.exit()
  count = count * (a**b)

print(count)
  
  

Fixed submission:
import collections
import sys
sys.setrecursionlimit(10**6+10)
N=int(input()) 
d=list(map(int, input().split())) 

  
  
c = collections.Counter(d)
c = dict(collections.Counter(d))

if d[0] != 0 or c[0]>1:
  print(0)
  sys.exit()
max_key = max(c.keys())


count = 1
for i in range(2,max_key+1):
  a = c.get(i, -1)
  b = c.get(i-1, -1)
  if a == -1 or b == -1:
    print(0)
    sys.exit()
  count = (count * (b**a))%998244353

print(count)
Buggy python submission (verdict: Runtime Error):
import math
a,b,x=map(int, input().split()) 

threshold = (a*a*b)/2
if x <= threshold:
  rad = math.atan(2*x/(a*b*b))
  print(90-math.degrees(rad))
else:
  at = (a*a*a)/(2*(a*a*b-x))
  rad = math.atan(at)
  print(90-math.degrees(rad))
  

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

threshold = (a*a*b)/2
if x <= threshold:
  rad = math.atan(2*x/(a*b*b))
  print(90-math.degrees(rad))
elif x == 2 * threshold:
  print(0)
else:
  at = (a*a*a)/(2*(a*a*b-x))
  rad = math.atan(at)
  print(90-math.degrees(rad))

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

threshold = (a*a*b)/2
if x <= threshold:
  rad = math.atan(2*x/(a*b*b))
  print(90-math.degrees(rad))
else:
  at = (a*a*a)/(2*(a*a*b-x))
  print(at)
  rad = math.atan(at)
  print(90-math.degrees(rad))
  

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

threshold = (a*a*b)/2
if x <= threshold:
  rad = math.atan(2*x/(a*b*b))
  print(90-math.degrees(rad))
elif x == 2 * threshold:
  print(0)
else:
  at = (a*a*a)/(2*(a*a*b-x))
  rad = math.atan(at)
  print(90-math.degrees(rad))
Buggy python submission (verdict: Runtime Error):
import sys
S = input() 
K = int(input()) 
l = len(S)
ren = [0]*l
cnt = 0

for i in range(1,l):
  if S[i] == S[i-1]:
    cnt += 1
  elif S[i] != S[i-1]:
    ren[cnt] +=1
    cnt = 0
  if i == l-1:
    ren[cnt] +=1
    
ren = [K*i for i in ren]
   
if ren[l-1]:
  print((l*K)//2)
  sys.exit()

if S[0]==S[-1]:
  start = 0
  while S[start]==S[start+1]:
    start += 1
  end = 0
  while S[-1-end]==S[-2-end]:
    end += 1
  ren[start+end+1] += K-1
  ren[start] -= K-1
  ren[end] -= K-1


ans = 0

for i in range(1,l):
  if i%2 ==0:
    ans += (i//2)*ren[i]
  else:
    ans += ((i+1)//2)*ren[i]
      
print(ans)

Fixed submission:
import sys
S = input() 
K = int(input()) 
l = len(S)
ren = [0]*l
cnt = 0
 
for i in range(1,l):
  if S[i] == S[i-1]:
    cnt += 1
  elif S[i] != S[i-1]:
    ren[cnt] +=1
    cnt = 0
  if i == l-1:
    ren[cnt] +=1
    
ren = [K*i for i in ren]
   
if ren[l-1] or l ==1:
  print((l*K)//2)
  sys.exit()
  
if S[0]==S[-1]:
  start = 0
  while S[start]==S[start+1]:
    start += 1
  end = 0
  while S[-1-end]==S[-2-end]:
    end += 1
  ren[start+end+1] += K-1
  ren[start] -= K-1
  ren[end] -= K-1
 
 
ans = 0
 
for i in range(1,l):
  if i%2 ==0:
    ans += (i//2)*ren[i]
  else:
    ans += ((i+1)//2)*ren[i]
      
print(ans)
Buggy python submission (verdict: Runtime Error):
N,K=map(int, input().split()) 
h=list(map(int, input().split()))

ans = len([1 for x in h if x >= K])

print(ans)

Fixed submission:
n = int(input())


if n%2 == 0:
    ans = 0.5
else:
    ans = (n+1)/(2*n)

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
N, M =map(int, input().split())
a=np.array(list(map(int, input().split()))) 

    
for i in range(M):
  ind=np.argmax(a)
  a[ind] = a[ind]//2
  
print(sum(a))
  
  

  

Fixed submission:
import heapq
import math
N, M =map(int, input().split())
a = list(map(lambda x: int(x)*(-1), input().split()))

heapq.heapify(a)


for i in range(M):
  tmp_min = heapq.heappop(a)
  heapq.heappush(a,math.ceil(tmp_min/2))
  
  
print(-sum(a))
Buggy python submission (verdict: Runtime Error):
N, M =map(int, input().split())
a =[1]*N
mod = 1000000007
for i in range(M):
  a[int(input())-1]=0

dp = [0]*N

dp[0] = a[0]*1
dp[1] = (dp[0] + 1)*a[1]

for i in range(2,N):
  dp[i] = (dp[i-1]+dp[i-2]) *a[i]
  
print(dp[-1]%mod)
  

Fixed submission:
import sys
N, M =map(int, input().split())


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

a =[1]*N
mod = 1000000007
for i in range(M):
  a[int(input())-1]=0

  
dp = [0]*N

dp[0] = a[0]*1
dp[1] = (dp[0] + 1)*a[1]

for i in range(2,N):
  dp[i] = (dp[i-1]+dp[i-2]) *a[i]
  
print(dp[-1]%mod)
Buggy python submission (verdict: Runtime Error):
from collections import deque

N, K =map(int, input().split())
V=list(map(int, input().split()))
Vd = deque(V)

score = 0

for a in range(min(K,N)+1):

  for b in range(K-a+1):
    hou = []
    Vd = deque(V)
    for _ in range(a):
      hou.append(Vd.popleft())
    for _ in range(b):
      hou.append(Vd.pop())
    hou.sort()
    for _ in range(K-a-b):
      if hou:
        if hou[0]>0:
          break
        hou.pop(0)
    score = max(score,sum(hou))
    
print(score)
      

Fixed submission:
from collections import deque

N, K =map(int, input().split())
V=list(map(int, input().split()))
Vd = deque(V)
score = 0

for a in range(min(K,N)+1):
  for b in range(min(K-a+1,N-a+1)):
    hou = []
    Vd = deque(V)
    for _ in range(a):
      hou.append(Vd.popleft())
    for _ in range(b):
      hou.append(Vd.pop())
    hou.sort()
    for _ in range(K-a-b):
      if hou:
        if hou[0]>0:
          break
        hou.pop(0)
    score = max(score,sum(hou))
    
print(score)
Buggy python submission (verdict: Time Limit Exceeded):
N , K = map(int, input().split())
h = list(map(int, input().split()))

Dp = [None]*N
Dp[0] = 0

for i in range(1,N):
  Dp[i] =min([Dp[j]+abs(h[i]-h[j]) for j in range(max(0,i-K),i)])

print(Dp[-1])


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

Dp = [None]*N
Dp[0] = 0

for i in range(1,N):
  Dp[i] =min([Dp[j]+abs(h[i]-h[j]) for j in range(max(0,i-K),i)])

print(Dp[-1])

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

Dp = [None]*N
Dp[0] = 0
Dp[1] = abs(h[1]-h[0])

for i in range(2,N):
  Dp[i] =min([Dp[j]+abs(h[i]-h[j]) for j in range(max(0,i-K),i)])

print(Dp[-1])


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

Dp = [None]*N
Dp[0] = 0

for i in range(1,N):
  Dp[i] =min([Dp[j]+abs(h[i]-h[j]) for j in range(max(0,i-K),i)])

print(Dp[-1])

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

Dp = [None]*N
Dp[0] = 0
Dp[1] = abs(h[1]-h[0])

for i in range(2,N):
  Dp[i] =min([Dp[i-j]+abs(h[i]-h[i-j]) for j in range(1,min(K,i)+1)])

print(Dp[N-1])





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

Dp = [None]*N
Dp[0] = 0

for i in range(1,N):
  Dp[i] =min([Dp[j]+abs(h[i]-h[j]) for j in range(max(0,i-K),i)])

print(Dp[-1])

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

Dp = [None]*N

Dp[0] = 0
Dp[1] = abs(h[1]-h[0])

for i in range(2,N):
  k = min(K,i)
  Dp[i] =min([Dp[i-j]+abs(h[i]-h[i-j]) for j in range(1,k+1)])

print(Dp[N-1])



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

Dp = [None]*N
Dp[0] = 0

for i in range(1,N):
  Dp[i] =min([Dp[j]+abs(h[i]-h[j]) for j in range(max(0,i-K),i)])

print(Dp[-1])
Buggy python submission (verdict: Time Limit Exceeded):
N,W = map(int, input().split())
w = [0] * N
v = [0] * N

for i in range(N):
    w[i], v[i] = map(int, input().split())

dp = [[0 for i in range(W+1)] for j in range(N+1)]

for i in range(N):
  for k in range(W+1):
    if w[i]<=k:
      dp[i+1][k] = max(dp[i][k-w[i]]+v[i],dp[i][k])
    else:
      dp[i+1][k] = dp[i][k]

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


Fixed submission:
N,W = map(int, input().split())
w = [0] * N
v = [0] * N

for i in range(N):
    w[i], v[i] = map(int, input().split())

dp = [[0 for i in range(W+1)] for j in range(N+1)]

for i in range(N):
  for k in range(W+1):
    if w[i]<=k:
      dp[i+1][k] = max(dp[i][k-w[i]]+v[i],dp[i][k])
    else:
      dp[i+1][k] = dp[i][k]

print(dp[-1][-1])
Buggy python submission (verdict: Runtime Error):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
    return divisors
 
N=int(input()) 
div = make_divisors(N)

A = div[-1]
B = N//A
print(max(len(str(A)),len(str(B))))

Fixed submission:
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
    return divisors
 
N=int(input()) 
div = make_divisors(N)

A = div[-1]
B = N//A
print(max(len(str(A)),len(str(B))))
Buggy python submission (verdict: Runtime Error):
import numpy as np

N = int(input())
xl = [int(x) for x in input().split()]

xlsorted = np.sort(xl)
m1 = xlsorted[int(N/2)-1]
m2 = xlsorted[int(N/2)]

for i in range(N):
    if xl[i] <= m1:
        print(m2)
    else:
        print(m1)


Fixed submission:
import numpy as np

N = int(input())
xl = [int(x) for x in input().split()]

xlsorted = np.sort(xl)
m1 = xlsorted[int(N/2)-1]
m2 = xlsorted[int(N/2)]

for i in range(N):
    if xl[i] <= m1:
        print(m2)
    else:
        print(m1)
Buggy python submission (verdict: Runtime Error):
import numpy as np

a = input()
b = input()
c = int(a) * int(b)
 
if 1 < c and c < 1000:
  if c%2 == 0:
    print("Even")
  else:
    print("Odd")

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

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

a = input()
b = input()
c = int(a) * int(b)
 
if 1 < c and c < 1000:
  if c%2 == 0:
    print("Even")
  else:
    print("Odd")

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

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

args = sys.argv
a = args[0]
b = args[1]
c = a * b

if 1 < c and c < 1000:
  if c%2 == 0:
    print("Even")
  else:
    print("Odd")


Fixed submission:
a, b = map(int, input().split())
print("Even" if a*b % 2 == 0 else "Odd")
Buggy python submission (verdict: Time Limit Exceeded):
N,Y = input().split()
N = int(N)
Y = int(Y)

for a in range(N+1):
  for b in range(N+1):
    X = 10000*a + 5000*b + 1000*(N-int(a)-int(b))
    #c = N-int(a)-int(b)
    if X==Y and N-int(a)-int(b)>=0:
      c = N-int(a)-int(b)
      print(a,b,c)
      exit()

print(-1,-1,-1)

Fixed submission:
N, Y = map(int, input().split())
for x in range(N+1):
    for y in range(N-x+1):
        z = N-x-y
        if 0 <= z <= 2000 and 10000*x+5000*y+1000*z == Y:
            print(x, y, z)
            exit()
print(-1, -1, -1)

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

for a in range(N+1):
  for b in range(N+1):
    X = 10000*a + 5000*b + 1000*(N-int(a)-int(b))
    #c = N-int(a)-int(b)
    if X==Y and N-int(a)-int(b)>=0:
      c = N-int(a)-int(b)
      #print(X)
      break
  else:
    continue
  break
if a+b>N:
  a=b=c=-1
print(a,b,c)

Fixed submission:
N, Y = map(int, input().split())
for x in range(N+1):
    for y in range(N-x+1):
        z = N-x-y
        if 0 <= z <= 2000 and 10000*x+5000*y+1000*z == Y:
            print(x, y, z)
            exit()
print(-1, -1, -1)

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

for a in range(N+1):
  for b in range(N+1):
    X = 10000*a + 5000*b + 1000*(N-int(a)-int(b))
    c = N-int(a)-int(b)
    if X==Y and c>=0:
      #print(X)
      break
  else:
    continue
  break
if c<0:
  a=b=c=-1
print(a,b,c)


Fixed submission:
N, Y = map(int, input().split())
for x in range(N+1):
    for y in range(N-x+1):
        z = N-x-y
        if 0 <= z <= 2000 and 10000*x+5000*y+1000*z == Y:
            print(x, y, z)
            exit()
print(-1, -1, -1)
Buggy python submission (verdict: Runtime Error):
from itertools import permutations
N=int(input())
P=tuple(map(int,input().split()))
Q=tuple(map(int,input().split()))

for i,p in enumerate(permutations(range(1,N+1))):
    if p==P:
        a=i
    if p=Q:
        b=i
print(abs(a-b))

Fixed submission:
from itertools import permutations
N=int(input())
P=tuple(map(int,input().split()))
Q=tuple(map(int,input().split()))

for i,p in enumerate(permutations(range(1,N+1))):
    if p==P:
        a=i
    if p==Q:
        b=i
print(abs(a-b))
Buggy python submission (verdict: Runtime Error):
s=input()
n=len(i)
 
res=0
for i in range(n):
  for j in range(i,n):
    sub=s[i:j+1]
    flg=True
    for k in sub:
      if(k not in ['A','G','C','T']):
        flg=False
    if(flg):
      res=max(res,len(sub))
      
print(res)

Fixed submission:
s=input()
n=len(s)
 
res=0
for i in range(n):
  for j in range(i,n):
    sub=s[i:j+1]
    flg=True
    for k in sub:
      if(k not in ['A','G','C','T']):
        flg=False
    if(flg):
      res=max(res,len(sub))
      
print(res)

Buggy python submission (verdict: Runtime Error):
i=input()
n=len(i)

res=0
for i in range(n):
  for j in range(i,n):
    sub=s[i:j+1]
    flg=True
    for k in sub:
      if(k not in ['A','G','C','T']):
        flg=False
    if(flg):
      res=max(res,len(sub))
      
print(res)

Fixed submission:
s=input()
n=len(s)
 
res=0
for i in range(n):
  for j in range(i,n):
    sub=s[i:j+1]
    flg=True
    for k in sub:
      if(k not in ['A','G','C','T']):
        flg=False
    if(flg):
      res=max(res,len(sub))
      
print(res)