Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
l=[0]*13
input()
for i in input().split():;l[int(i)//400]+=1
r=sum([1 for a in l[:8] if a > 0])
print(max(1,r),r+sum(l[8:]))

Fixed submission:
al=[0]*13
input()
for i in input().split():
    al[int(i)//400]+=1
tuyoi=sum(al[8:])
iru=sum([1 for a in al[:8] if a > 0])
print(max(1,iru),iru+tuyoi)

Buggy python submission (verdict: Runtime Error):
cat ABC064C.py
l=[0]*13
input()
for i in input().split():;l[int(i)//400]+=1
r=sum([1 for a in l[:8] if a > 0])
print(max(1,r),r+sum(l[8:]))

Fixed submission:
al=[0]*13
input()
for i in input().split():
    al[int(i)//400]+=1
tuyoi=sum(al[8:])
iru=sum([1 for a in al[:8] if a > 0])
print(max(1,iru),iru+tuyoi)

Buggy python submission (verdict: Runtime Error):
l=[0]*13
input()
for i in input().split():
  l[int(i)//400]+=1
r=sum([1 for a in l[:8] if a > 0])
print(max(1,r,r+sum(l[8:])

Fixed submission:
al=[0]*13
input()
for i in input().split():
    al[int(i)//400]+=1
tuyoi=sum(al[8:])
iru=sum([1 for a in al[:8] if a > 0])
print(max(1,iru),iru+tuyoi)
Buggy python submission (verdict: Runtime Error):
s=map(int,input().split());print(["No","Yes"[s in[1,3,5,7,8,10,12]or s in[4,6,9,11]])

Fixed submission:
s=[int(i)for i in input().split()];f=lambda x,l:not(set(x[:])-set(l));print(["No","Yes"][f(s,[1,3,5,7,8,10,12])or f(s,[4,6,9,11])or f(s,[2])])
Buggy python submission (verdict: Runtime Error):
p=input();h,w=map(int,p().split());w+=2;print("#"*w);print("\n".join(["#"+p().strip()+"#"for _ in[0]*h]));print("#"*w)

Fixed submission:
h,w=map(int,input().split());w+=2;print("#"*w);print("\n".join(["#"+input().strip()+"#"for _ in [0]*h]));print("#"*w)

Buggy python submission (verdict: Runtime Error):
h,w=map(int,input().split());print("#"*w);print("\n".join(["#"input()"#"for _ in [0]*h]));print("#"*w)

Fixed submission:
h,w=map(int,input().split());w+=2;print("#"*w);print("\n".join(["#"+input().strip()+"#"for _ in [0]*h]));print("#"*w)
Buggy python submission (verdict: Runtime Error):
p=input;a=int(p())-int(p());print(['EQUAL','LESS'][a<0],'GREATER'][a>0])

Fixed submission:
a,b=[int(input())for _ in[0]*2]
print("GREATER"if a>b else"ELQEUSASL"[a<b::2])
Buggy python submission (verdict: Runtime Error):
a,b=input(),input()
l=len(a+b)
ans=""
for i in range(l):
  if i % 2 == 0:
    ans += a.pop(0)
  else:
    ans += b.pop(0)
print(ans)

Fixed submission:
from itertools import zip_longest
print("".join(["".join(a) for a in zip_longest(input(),input(),fillvalue="")]))

Buggy python submission (verdict: Runtime Error):
a,b=input(),input()
l=len(a+b)
ans=""
for i in range(l):
  if l % 2 == 0:
    ans += a.pop(0)
  else:
    ans += b.pop(0)
print(ans)

Fixed submission:
from itertools import zip_longest
print("".join(["".join(a) for a in zip_longest(input(),input(),fillvalue="")]))
Buggy python submission (verdict: Runtime Error):
a,b=map(int,input().split())
h=[14]+list(range(2,14))
ifa==b:
  print("Draw")
else:
  print("Alice"if h[a]>h[b]else"Bob")

Fixed submission:
a,b=map(int,input().split())
h=[0,14]+list(range(2,14))
if a==b:
  print("Draw")
else:
  print("Alice"if h[a]>h[b]else"Bob")
Buggy python submission (verdict: Runtime Error):
n,  m = map(int, input().split())
np = [input() for _ in range(n)]
mp = [input() for _ in range(m)]
for i in range(n-m-1):
  for  j in range(n-m-1):
    f = True
    for k in range(m):
      if np[i+k][j:j+m] != mp[i+k]:
        f = False
    if f:
      print("Yes")
      exit(0)
else:
  print("No")

Fixed submission:
n,  m = map(int, input().split())
np = [input() for _ in range(n)]
mp = [input() for _ in range(m)]
for i in range(n-m+1):
  for j in range(n-m+1):
    f = True
    for k in range(m):
      if np[i+k][j:j+m] != mp[k]:
        f = False
    if f:
      print("Yes")
      exit(0)
else:
  print("No")

Buggy python submission (verdict: Runtime Error):
n,  m = map(int, input().split())
np = [input() for _ in range(n)]
mp = [input() for _ in range(m)]
for i in range(n-m):
  for  j in range(n-m):
    f = True
    for k in range(m):
      if np[i+k][j:j+m] != mp[i+k]:
        f = False
    if f:
      print("Yes")
      exit(0)
else:
  print("No")

Fixed submission:
n,  m = map(int, input().split())
np = [input() for _ in range(n)]
mp = [input() for _ in range(m)]
for i in range(n-m+1):
  for j in range(n-m+1):
    f = True
    for k in range(m):
      if np[i+k][j:j+m] != mp[k]:
        f = False
    if f:
      print("Yes")
      exit(0)
else:
  print("No")
Buggy python submission (verdict: Runtime Error):
w,h,n = map(int,input().split())
lx,hx,ly,hy = 0,w,0,h
for i in range(n):
  x,y,a = map(int,input().split())
  if a == 1:
    lx = max(lx, x)
  elif a == 2:
    hx = min(hx, x)
  elif a == 3:
    ly = max(ly, y)
  elif a == 4:
    hy = min(hy, y)
print(max(0,(hx-lx)*(hy-ly))

Fixed submission:
w,h,n = map(int,input().split())
lx,hx,ly,hy = 0,w,0,h
for i in range(n):
  x,y,a = map(int,input().split())
  if a == 1:
    lx = max(lx, x)
  elif a == 2:
    hx = min(hx, x)
  elif a == 3:
    ly = max(ly, y)
  elif a == 4:
    hy = min(hy, y)
print(max(0, hx-lx) * max(0, hy-ly))
Buggy python submission (verdict: Runtime Error):
from collections import Counter
c = Counter(input())
print("Yes" if ((c["N"] > 0 and c["S"] > 0) or c["N"] == s["S"]) \
 and ((c["E"] > 0 and c["W"] > 0) or c["E"] == s["W"]) else "No")


Fixed submission:
from collections import Counter
c = Counter(input())
print("Yes" if ((c["N"] > 0 and c["S"] > 0) or c["N"] == c["S"]) \
     and ((c["E"] > 0 and c["W"] > 0) or c["E"] == c["W"]) else "No")
Buggy python submission (verdict: Runtime Error):
print("".join(sorted([input() for i in range(int(input().split[0]))])))

Fixed submission:
def solve():
    n, _ = input().split()
    print("".join(sorted([input() for i in range(int(n))])))


if __name__=="__main__":
    solve()
Buggy python submission (verdict: Time Limit Exceeded):
import sys
input=sys.stdin.readline

k=int(input())
mod=[]
seven=0
if k%2==0:
    print("-1")
    exit(0)
for i in range(10000000000000):
    seven=seven*10+7
    julia = seven%k
    mod.append(seven % k)
    if julia == 0:
        print(len(mod))
        exit(0)

Fixed submission:
k=int(input())
n=7%k
for i in range(1,k+1):
  if n == 0:
    print(i)
    exit()
  n=(n*10+7) % k
print(-1)
Buggy python submission (verdict: Time Limit Exceeded):
k=int(input())
num=100
ans=0
while k!=num:
    num=num*101//100
    ans+=1
print(ans)

Fixed submission:
from decimal import Decimal
k=int(input())
num=100
ans=0
while k>num:
    num=int(Decimal(num)*Decimal(101)/Decimal(100))
    ans+=1
print(ans)
Buggy python submission (verdict: Runtime Error):
n,m＝ map(int,input().split())
L=list(map(int,input().split()))
print(n-sum(L) if n-sum(L)>=0 else -1)

Fixed submission:

n=list(map(int,input().split()))
L=list(map(int,input().split()))
print(n[0]-sum(L) if n[0]-sum(L)>=0 else "-1")
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
L=tuple(map(int,input().split()))
for i in range(1,n+1):
    print(L.count(i))


Fixed submission:
from collections import Counter
n = int(input())
a = tuple(map(int, input().split()))
All = Counter(a)
for i in range(1,n+1):
    try:
        print(All[i])
    except:
        print(0)

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

Fixed submission:
from collections import Counter
n = int(input())
a = tuple(map(int, input().split()))
All = Counter(a)
for i in range(1,n+1):
    try:
        print(All[i])
    except:
        print(0)
Buggy python submission (verdict: Runtime Error):
import sys
input=sys.stdin.readline
n,k=map(int,input().split())
num=min(n,k)
a=max(n,k)%min(n,k)
b=min(n,k)
for i in range(10):
    b=abs(b-a)
    num=min(b,num)
print(num if min(n,k)!=1 else 0)


Fixed submission:
import sys
input=sys.stdin.readline
n,k=map(int,input().split())
ans1=min(n%k,k-n%k)
print(ans1)
Buggy python submission (verdict: Runtime Error):
import numpy as np
n,k=map(int,input().split())
print(len(np.base_repr(n,base=k)))

Fixed submission:
N,R=map(int,input().split())
for i in range(1000000000):
	if R**i>N:
		print(i)
		break
Buggy python submission (verdict: Time Limit Exceeded):
import sys
from functools import reduce
mod=10**9+7
input=sys.stdin.readline
def f(A,B):
 if B==0:
  den=1
  num=1
 else:
  den=reduce(lambda x,y:x*y%mod,range(A,A-B,-1))
  num=reduce(lambda x,y:x*y%mod,range(1,B+1))
    
 return den*pow(num,mod-2,mod)%mod

n,k=map(int,input().split())
ans=0
for i in range(min(n-1,k)+1):
 ans+=f(n,i)*f(n-1,i)%mod
print(ans%mod)


Fixed submission:
mod=10**9+7
n,k=map(int,input().split())
ans=0
comb1=1 #初期値はNC0=1
comb2=1 #初期値は(N-1)C0=1
for i in range(min(k+1,n)): #0人の部屋は高々N-1個しか
 # 存在しないので操作回数は高々min(K,N-1)回となる
 ans+=comb1*comb2 #0人の部屋がi個のときの場合の数は
 # NCi*(N-1)Ci
 ans%=mod
 comb1*=(n-i)*pow(i+1,mod-2,mod) #NC(i+1)はNC
 # i*(N-i)/(i+1)で求められる
 comb1%=mod
 comb2*=(n-1-i)*pow(i+1,mod-2,mod) #(N-1)C(i+1
 # )は(N-1)Ci*((N-1)-i)/(i+1)で求められる
 comb2%=mod
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from functools import reduce
mod=10**9+7

def f(A,B):
 if B==0:
  den=1
  num=1
 else:
  den=reduce(lambda x,y:x*y%mod,range(A,A-B,-1))
  num=reduce(lambda x,y:x*y%mod,range(1,B+1))
 return den*pow(num,mod-2,mod)%mod

n,k=map(int,input().split())
ans=0
for i in range(min(n-1,k)+1):
 ans+=f(n,i)*f(n-1,i)%mod
print(ans%mod)

Fixed submission:
mod=10**9+7
n,k=map(int,input().split())
ans=0
comb1=1 #初期値はNC0=1
comb2=1 #初期値は(N-1)C0=1
for i in range(min(k+1,n)): #0人の部屋は高々N-1個しか
 # 存在しないので操作回数は高々min(K,N-1)回となる
 ans+=comb1*comb2 #0人の部屋がi個のときの場合の数は
 # NCi*(N-1)Ci
 ans%=mod
 comb1*=(n-i)*pow(i+1,mod-2,mod) #NC(i+1)はNC
 # i*(N-i)/(i+1)で求められる
 comb1%=mod
 comb2*=(n-1-i)*pow(i+1,mod-2,mod) #(N-1)C(i+1
 # )は(N-1)Ci*((N-1)-i)/(i+1)で求められる
 comb2%=mod
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N,K=map(int,input().split())
p=list(map(int,input().split()))
L=[]
for i in range(N-K+1):
    L.append(p[i:K+i])
    L.sort()
num=0

for l in L[-1]:
    num=num+(l+1)/2
print(num)


Fixed submission:
n,k=map(int,input().split())
A=list(map(int,input().split()))
m=M=sum(A[:k])
for i in range(n-k):
    m=m-A[i]+A[i+k]
    M=max(M,m)
print((M+k)/2)
Buggy python submission (verdict: Runtime Error):
n,m=map(int,input.split())
print(n*m if max(n,m)<10 else -1)

Fixed submission:
n,m=map(int,input().split())
print(n*m if max(n,m)<10 else -1)
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
L=list(map(int,input().split()))
ans=[]
for i in range(1,N+1):
    ans.append(str(L.index(i)+1))
print(" ".join(ans))

Fixed submission:
import sys
input=sys.stdin.readline
N = int(input())
L = list(map(int,input().split()))

answer = [None] * N
for i, num in  enumerate(L):
    answer[num-1] = i+1
print(*answer)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
input=sys.stdin.readline
N,K,Q=map(int,input().split())
J=[int(input()) for _ in range(Q)]
for i in range(1,N+1):
    print("Yes" if K-Q+J.count(i)>0 else "No")


Fixed submission:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

N,K,Q = map(int,input().split())
A = (int(x) for x in sys.stdin.read().split())

score = [K-Q] * (N+1) 
for x in A:
    score[x] += 1

answer = '\n'.join('No' if x <= 0 else 'Yes' for x in score[1:])
print(answer)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input=sys.stdin.readline
N,K,Q=map(int,input().split())
J=[int(input()) for _ in range(Q)]
for i in range(1,N+1):
    print("Yes" if K-Q+J.count(i)>0 else "No")



Fixed submission:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

N,K,Q = map(int,input().split())
A = (int(x) for x in sys.stdin.read().split())

score = [K-Q] * (N+1) 
for x in A:
    score[x] += 1

answer = '\n'.join('No' if x <= 0 else 'Yes' for x in score[1:])
print(answer)

Buggy python submission (verdict: Runtime Error):
import sys
import numpy as np
input=sys.stdin.readline
N,K,Q=map(int,input().split())
J=[int(input()) for _ in range(Q)]
for i in range(1,N+1):
    print("Yes" if K-Q+J.count(i)>0 else "No")


Fixed submission:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

N,K,Q = map(int,input().split())
A = (int(x) for x in sys.stdin.read().split())

score = [K-Q] * (N+1) 
for x in A:
    score[x] += 1

answer = '\n'.join('No' if x <= 0 else 'Yes' for x in score[1:])
print(answer)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
input=sys.stdin.buffer.readline
n=int(input())
L=list(int(input()) for i in range(n))
for i in range(n):
    N=sorted(L)
    print(N[-1] if L[i]!=N[-1] else N[-2])

Fixed submission:
import sys
input=sys.stdin.buffer.readline
n=int(input())
L=list(int(input()) for i in range(n))
N=sorted(L)
for i in range(n):
    print(N[-1] if L[i]!=N[-1] else N[-2])

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input=sys.stdin.readline
n=int(input())
L=list(int(input()) for i in range(n))
for i in range(n):
    N=sorted(L)
    print(N[-1] if L[i]!=N[-1] else N[-2])

Fixed submission:
import sys
input=sys.stdin.buffer.readline
n=int(input())
L=list(int(input()) for i in range(n))
N=sorted(L)
for i in range(n):
    print(N[-1] if L[i]!=N[-1] else N[-2])

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input=sys.stdin.readline
n=int(input())
L=list(int(input()) for i in range(n))
for i in range(n):
    N=sorted(L)
    print(N[-1] if L[i]!=N[-1] else N[-2])

Fixed submission:
import sys
input=sys.stdin.buffer.readline
n=int(input())
L=list(int(input()) for i in range(n))
N=sorted(L)
for i in range(n):
    print(N[-1] if L[i]!=N[-1] else N[-2])

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input=sys.stdin.readline
n=int(input())
L=list(int(input()) for i in range(n))
for i in range(n):
    N=L[:i]+L[i+1:]
    print(max(N))

Fixed submission:
import sys
input=sys.stdin.buffer.readline
n=int(input())
L=list(int(input()) for i in range(n))
N=sorted(L)
for i in range(n):
    print(N[-1] if L[i]!=N[-1] else N[-2])
Buggy python submission (verdict: Runtime Error):
from collections import Counter
s=list(input())
L_1=Counter(s).most_common()
print("Yes" if L_1[0][1]==L_1[1][1]==2 else "No")

Fixed submission:
S=list(input())
print("Yes" if len(set(S))==2 else "No")
Buggy python submission (verdict: Time Limit Exceeded):
n,q =map(int,input().split())
s=input()
p=[[int(j) for j in input().split()] for _ in range(q)]
for _ in range(q):
    print(s[p[_][0]-1:p[_][1]].count("AC"))

Fixed submission:
N,Q=map(int,input().split())
S=input()
count=[0]*N
for i in range(1,N):
    count[i]+=count[i-1]
    if S[i-1:i+1]=="AC":count[i]+=1
for i in range(Q):
    l,r=map(int,input().split())
    print(count[r-1]-count[l-1])

Buggy python submission (verdict: Time Limit Exceeded):
n,q =map(int,input().split())
s=input()
p=[[int(j) for j in input().split()] for i in range(q)]
for k in range(q):
    print(s[p[k][0]-1:p[k][1]].count("AC"))




Fixed submission:
N,Q=map(int,input().split())
S=input()
count=[0]*N
for i in range(1,N):
    count[i]+=count[i-1]
    if S[i-1:i+1]=="AC":count[i]+=1
for i in range(Q):
    l,r=map(int,input().split())
    print(count[r-1]-count[l-1])

Buggy python submission (verdict: Time Limit Exceeded):
n,q =map(int,input().split())
s=input()
p=[[int(j) for j in input().split()] for i in range(q)]
for k in range(q):
    print(s[p[k][0]-1:p[k][1]].count("AC"))




Fixed submission:
N,Q=map(int,input().split())
S=input()
count=[0]*N
for i in range(1,N):
    count[i]+=count[i-1]
    if S[i-1:i+1]=="AC":count[i]+=1
for i in range(Q):
    l,r=map(int,input().split())
    print(count[r-1]-count[l-1])
Buggy python submission (verdict: Runtime Error):
x,y = map(int,input())
print(x+y//2)

Fixed submission:
x,y = map(int,input().split())
print(x+y//2)
Buggy python submission (verdict: Runtime Error):
row=int(input())
T,A=map(int,input().split())
a = list(map(int,input().split()))
ans=10000000000000000000000
for i in range(row):
    ans=min(ans,A-T+.006*a[i])
print(a.index(int((ans-A+T)/.006))+1)

Fixed submission:
import sys
input=sys.stdin.readline
n=int(input())
t,a=map(int,input().split())
H=list(map(int,input().split()))
for i in range(n):
    H[i]=abs(t-H[i]*0.006-a)
L=list(enumerate(H,start=1))
L=sorted(L,key=lambda x:x[1])
print(L[0][0])

Buggy python submission (verdict: Runtime Error):
row=int(input())
T,A=map(int,input().split())
a = list(map(int,input().split()))
ans=1000000000000
for i in range(row):
    ans=min(ans,A-T+.006*a[i])
print(a.index(int((ans-A+T)/.006))+1)

Fixed submission:
import sys
input=sys.stdin.readline
n=int(input())
t,a=map(int,input().split())
H=list(map(int,input().split()))
for i in range(n):
    H[i]=abs(t-H[i]*0.006-a)
L=list(enumerate(H,start=1))
L=sorted(L,key=lambda x:x[1])
print(L[0][0])

Buggy python submission (verdict: Runtime Error):
row=int(input())
T,A=map(int,input().split())
a = list(map(int,input().split()))
ans=100
for i in range(row):
    ans=min(ans,A-T+.006*a[i])
print(a.index(int((ans-A+T)/.006))+1)


Fixed submission:
import sys
input=sys.stdin.readline
n=int(input())
t,a=map(int,input().split())
H=list(map(int,input().split()))
for i in range(n):
    H[i]=abs(t-H[i]*0.006-a)
L=list(enumerate(H,start=1))
L=sorted(L,key=lambda x:x[1])
print(L[0][0])
Buggy python submission (verdict: Runtime Error):
print(int(input()**2//4))


Fixed submission:
n = int(input())
a= 0
b=0
for i in range(1,n+1):
    if i%2==0:
        a += 1
    else: b+=1
print(a*b)
Buggy python submission (verdict: Runtime Error):
print("Yes" if [4*x+11*y for x in range(26) for y in range(9)].count(a) else "NO")


Fixed submission:
a=int(input())
print("Yes" if [4*x+7*y for x in range(101) for y in range(101)].count(a) else "No")

Buggy python submission (verdict: Runtime Error):
print("Yes" if [4*x+11*y for x in range(26) for y in range(9)].count(a) else "NO")


Fixed submission:
a=int(input())
print("Yes" if [4*x+7*y for x in range(101) for y in range(101)].count(a) else "No")
Buggy python submission (verdict: Runtime Error):
li6 = [6 ** i for i in range(7)]
li9 = [9 ** i for i in range(6)]

def s69(n):
    if n < 6:
        return n
    else:
        s6 = li6[bi.bisect(li6, n) - 1]
        s9 = li9[bi.bisect(li9, n) - 1]
        return min(n // s6 + s69(n % s6), 1 + s69(n - s9))


print(s69(int(input())))



Fixed submission:
import bisect as bi

li6 = [6 ** i for i in range(7)]
li9 = [9 ** i for i in range(6)]

def s69(n):
    if n < 6:
        return n
    else:
        s6 = li6[bi.bisect(li6, n) - 1]
        s9 = li9[bi.bisect(li9, n) - 1]
        return min(n // s6 + s69(n % s6), 1 + s69(n - s9))


print(s69(int(input())))
Buggy python submission (verdict: Time Limit Exceeded):
import sys
input=sys.stdin.readline
N=int(input())
s=list(input())
num=10*6
for i in range(N):
    num1=s[:i].count("W")+s[i+1:].count("E")
    num=min(num,num1)
print(num)

Fixed submission:
import sys
input=sys.stdin.readline
N = int(input())
S = input()
int_s = [0] * N
cum_sum_w = [0] * (N + 1)
cum_sum_e = [0] * (N + 1)
answers = [0] * N
for i in range(N):
    if (S[i] == 'W'):
        int_s[i] = 1
    else:
        int_s[i] = 0
    cum_sum_w[i + 1] = cum_sum_w[i] + int_s[i]
for i in range(N):
    if (S[i] == 'E'):
        int_s[i] = 1
    else:
        int_s[i] = 0
    cum_sum_e[i + 1] = cum_sum_e[i] + int_s[i]
for i in range(N):
    answers[i] = cum_sum_w[i] + (cum_sum_e[N] - cum_sum_e[i + 1])
print(min(answers))
Buggy python submission (verdict: Time Limit Exceeded):

import sys
input=sys.stdin.readline
n,y=map(int,input().split())
y10,y5,y1=0,0,0
for i in range(n+1):
    for j in range(n+1):
        for k in range(n+1):
            if 10000*i+5000*j+1000*k==y and i+j+k==n:
                print(i,j,k)
                exit(0)
print(-1,-1,-1)

Fixed submission:
import sys
input=sys.stdin.readline
n,y=map(int,input().split())
y10,y5,y1=0,0,0
for i in range(n+1):
    for j in range(n+1):
        k=n-i-j
        if 10000*i+5000*j+1000*k==y and k>=0:
            print(i,j,k)
            exit(0)
print(-1,-1,-1)
Buggy python submission (verdict: Runtime Error):
N=list(input())
a,b,c,d=N[0],N[1],N[2],N[3]

if a+b+c+d==7 : print("{0}+{1}+{2}+{3}=7".format(a,b,c,d))
if a+b+c-d==7 : print("{0}+{1}+{2}-{3}=7".format(a,b,c,d))
if a+b-c+d==7 : print("{0}+{1}-{2}+{3}=7".format(a,b,c,d))
if a+b-c-d==7 : print("{0}+{1}-{2}-{3}=7".format(a,b,c,d))
if a-b+c+d==7 : print("{0}-{1}+{2}+{3}=7".format(a,b,c,d))
if a-b+c-d==7 : print("{0}-{1}+{2}-{3}=7".format(a,b,c,d))
if a-b-c+d==7 : print("{0}-{1}-{2}+{3}=7".format(a,b,c,d))
if a-b-c-d==7 : print("{0}-{1}-{2}-{3}=7".format(a,b,c,d))


Fixed submission:
N=input()
a,b,c,d=int(N[0]),int(N[1]),int(N[2]),int(N[3])

if a+b+c+d==7 : print("{0}+{1}+{2}+{3}=7".format(a,b,c,d))
elif a+b+c-d==7 : print("{0}+{1}+{2}-{3}=7".format(a,b,c,d))
elif a+b-c+d==7 : print("{0}+{1}-{2}+{3}=7".format(a,b,c,d))
elif a+b-c-d==7 : print("{0}+{1}-{2}-{3}=7".format(a,b,c,d))
elif a-b+c+d==7 : print("{0}-{1}+{2}+{3}=7".format(a,b,c,d))
elif a-b+c-d==7 : print("{0}-{1}+{2}-{3}=7".format(a,b,c,d))
elif a-b-c+d==7 : print("{0}-{1}-{2}+{3}=7".format(a,b,c,d))
elif a-b-c-d==7 : print("{0}-{1}-{2}-{3}=7".format(a,b,c,d))
Buggy python submission (verdict: Runtime Error):
import sys
import bisect
input = sys.stdin.readline
num=0
n=int(input())
top=list(map(int,input().split()))
mid=list(map(int,input().split()))
und=list(map(int,input().split()))
top.sort()
mid.sort()
und.sort()
for i in mid:
    a=bisect.bisect_left(top,i)
    c=len(c)-bisect.bisect_right(und,i)
    num+=a*c
print(num)


Fixed submission:
import sys
import bisect
input = sys.stdin.readline
num=0
n=int(input())
top=list(map(int,input().split()))
mid=list(map(int,input().split()))
und=list(map(int,input().split()))
top.sort()
mid.sort()
und.sort()
for i in mid:
    a=bisect.bisect_left(top,i)
    c=n-bisect.bisect_right(und,i)
    num+=a*c
print(num)

Buggy python submission (verdict: Runtime Error):
import sys
import bisect
input = sys.stdin.readline()
num=0
n=int(input())
top=list(map(int,input().split()))
mid=list(map(int,input().split()))
und=list(map(int,input().split()))
top.sort()
mid.sort()
und.sort()
for i in mid:
    a=bisect.bisect_left(top,i)
    c=len(c)-bisect.bisect_right(und,i)
    num+=a*c
print(num)

Fixed submission:
import sys
import bisect
input = sys.stdin.readline
num=0
n=int(input())
top=list(map(int,input().split()))
mid=list(map(int,input().split()))
und=list(map(int,input().split()))
top.sort()
mid.sort()
und.sort()
for i in mid:
    a=bisect.bisect_left(top,i)
    c=n-bisect.bisect_right(und,i)
    num+=a*c
print(num)

Buggy python submission (verdict: Time Limit Exceeded):
num=0
n=int(input())
top=list(map(int,input().split()))
mid=list(map(int,input().split()))
und=list(map(int,input().split()))
for i in top:
    for j in mid:
        if i <j:
            for k in und:
                if j<k:
                    num+=1
print(num)


Fixed submission:
import sys
import bisect
input = sys.stdin.readline
num=0
n=int(input())
top=list(map(int,input().split()))
mid=list(map(int,input().split()))
und=list(map(int,input().split()))
top.sort()
mid.sort()
und.sort()
for i in mid:
    a=bisect.bisect_left(top,i)
    c=n-bisect.bisect_right(und,i)
    num+=a*c
print(num)
Buggy python submission (verdict: Runtime Error):
import numpy as np
h,w=map(int,input().split())
L=[[i for i in input()] for i in range(h)]
L_first=np.zeros((2,w),dtype=str)
L_first2=np.zeros((1,1),dtype=str)
L=np.array(L,dtype=str)
L=np.insert(L_first,1,L,axis=0)
L=np.insert(L,0,L_first2,axis=1)
L=np.insert(L,w+1,L_first2,axis=1)
ans=np.zeros((h,w),dtype=str)
for i in range(1,h+1):
    for j in range(1,w+1):
        num = 0
        if L[i][j]==".":
            L2=L[i-1:i+2,j-1:j+2]
            ans[i-1][j-1]=np.sum(L2=="#")
        else:ans[i-1][j-1]="#"
for i in range(h):
    print("".join(ans[i]))

Fixed submission:
import numpy as np
h,w=map(int,input().split())
L=[[i for i in input()] for i in range(h)]
L_first=np.zeros((2,w),dtype=str)
L_first2=np.zeros((1,1),dtype=str)
L=np.array(L,dtype=str)
L=np.insert(L_first,1,L,axis=0)
L=np.insert(L,0,L_first2,axis=1)
L=np.insert(L,w+1,L_first2,axis=1)
ans=np.zeros((h,w),dtype=str)
for i in range(1,h+1):
    for j in range(1,w+1):
        num = 0
        if L[i][j]==".":
            L2=L[i-1:i+2,j-1:j+2]
            ans[i-1][j-1]=np.sum(L2=="#")
        else:ans[i-1][j-1]="#"
for i in range(h):
    print("".join(ans[i]))