#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
double *malloc(size_t);
int /*<<< orphan*/ putchar(int);
int /*<<< orphan*/ scanf(char *, ...);
int main() {
  size_t n;
  scanf("%zu", &n);
  double t, *weights = malloc(n * sizeof(double));
  scanf("%lf", &t);
  for (size_t i = 0; i < n; ++i)
    scanf("%lf", weights + i);
  int tmp;
  for (size_t i = 0; i < n; ++i) {
    scanf("%d", &tmp);
    t -= tmp && weights[i];
  }
  putchar((t <= 0) + 48);
  putchar(10);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rdi
lea    -0x10(%rbp),%rsi
mov    $0x0,%al
call   1050 <scanf@plt>
mov    -0x10(%rbp),%rdi
shl    $0x3,%rdi
call   1040 <malloc@plt>
mov    %rax,-0x20(%rbp)
lea    0xe9b(%rip),%rdi
lea    -0x18(%rbp),%rsi
mov    $0x0,%al
call   1050 <scanf@plt>
movq   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%rax
cmp    -0x10(%rbp),%rax
jae    11b8 <main+0x88>
mov    -0x20(%rbp),%rsi
mov    -0x28(%rbp),%rax
shl    $0x3,%rax
add    %rax,%rsi
lea    0xe64(%rip),%rdi
mov    $0x0,%al
call   1050 <scanf@plt>
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
jmp    117c <main+0x4c>
movq   $0x0,-0x38(%rbp)
mov    -0x38(%rbp),%rax
cmp    -0x10(%rbp),%rax
jae    1239 <main+0x109>
lea    0xe33(%rip),%rdi
lea    -0x2c(%rbp),%rsi
mov    $0x0,%al
call   1050 <scanf@plt>
xor    %eax,%eax
cmpl   $0x0,-0x2c(%rbp)
mov    %al,-0x39(%rbp)
je     120e <main+0xde>
mov    -0x20(%rbp),%rax
mov    -0x38(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
setne  %al
setp   %cl
or     %cl,%al
mov    %al,-0x39(%rbp)
mov    -0x39(%rbp),%al
and    $0x1,%al
movzbl %al,%eax
cvtsi2sd %eax,%xmm1
movsd  -0x18(%rbp),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
mov    -0x38(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x38(%rbp)
jmp    11c0 <main+0x90>
xorps  %xmm0,%xmm0
ucomisd -0x18(%rbp),%xmm0
setae  %al
and    $0x1,%al
movzbl %al,%edi
add    $0x30,%edi
call   1030 <putchar@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x20,%rsp
lea    0xec4(%rip),%rdi
lea    0x8(%rsp),%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
mov    0x8(%rsp),%rdi
shl    $0x3,%rdi
call   1040 <malloc@plt>
mov    %rax,%r14
lea    0xea4(%rip),%rdi
lea    0x10(%rsp),%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
cmpq   $0x0,0x8(%rsp)
je     1227 <main+0xf7>
lea    0xe85(%rip),%r15
mov    %r14,%r12
xor    %ebx,%ebx
nopl   0x0(%rax)
mov    %r15,%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
add    $0x1,%rbx
mov    0x8(%rsp),%rax
add    $0x8,%r12
cmp    %rax,%rbx
jb     1190 <main+0x60>
test   %rax,%rax
je     1227 <main+0xf7>
xor    %ebx,%ebx
lea    0xe53(%rip),%r15
lea    0x1c(%rsp),%r12
jmp    11f6 <main+0xc6>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movzbl %r13b,%eax
xorps  %xmm1,%xmm1
cvtsi2sd %eax,%xmm1
movsd  0x10(%rsp),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,0x10(%rsp)
add    $0x1,%rbx
cmp    0x8(%rsp),%rbx
jae    122d <main+0xfd>
xor    %r13d,%r13d
mov    %r15,%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
cmpl   $0x0,0x1c(%rsp)
je     11d0 <main+0xa0>
movsd  (%r14,%rbx,8),%xmm0
cmpneqsd 0xde4(%rip),%xmm0
movq   %xmm0,%r13
and    $0x1,%r13d
jmp    11d0 <main+0xa0>
movsd  0x10(%rsp),%xmm0
xorpd  %xmm1,%xmm1
xor    %edi,%edi
ucomisd %xmm0,%xmm1
setae  %dil
or     $0x30,%edi
call   1030 <putchar@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%zu\00"
@.str.1 = [4 x i8] c"%lf\00"
@.str.2 = [3 x i8] c"%d\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i64
%3 = alloca double
%4 = alloca double*
%5 = alloca i64
%6 = alloca i32
%7 = alloca i64
store i32 0, i32* %1
%8 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i64* %2)
%9 = load i64, i64* %2
%10 = mul i64 %9, 8
%11 = call double* @malloc(i64 %10)
store double* %11, double** %4
%12 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double* %3)
store i64 0, i64* %5
br label %13
13: ; preds = %22, %0
%14 = load i64, i64* %5
%15 = load i64, i64* %2
%16 = icmp ult i64 %14, %15
br i1 %16, label %17, label %25
17: ; preds = %13
%18 = load double*, double** %4
%19 = load i64, i64* %5
%20 = getelementptr inbounds double, double* %18, i64 %19
%21 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double* %20)
br label %22
22: ; preds = %17
%23 = load i64, i64* %5
%24 = add i64 %23, 1
store i64 %24, i64* %5
br label %13
25: ; preds = %13
store i64 0, i64* %7
br label %26
26: ; preds = %46, %25
%27 = load i64, i64* %7
%28 = load i64, i64* %2
%29 = icmp ult i64 %27, %28
br i1 %29, label %30, label %49
30: ; preds = %26
%31 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %6)
%32 = load i32, i32* %6
%33 = icmp ne i32 %32, 0
br i1 %33, label %34, label %40
34: ; preds = %30
%35 = load double*, double** %4
%36 = load i64, i64* %7
%37 = getelementptr inbounds double, double* %35, i64 %36
%38 = load double, double* %37
%39 = fcmp une double %38, 0.000000e+00
br label %40
40: ; preds = %34, %30
%41 = phi i1 [ false, %30 ], [ %39, %34 ]
%42 = zext i1 %41 to i32
%43 = sitofp i32 %42 to double
%44 = load double, double* %3
%45 = fsub double %44, %43
store double %45, double* %3
br label %46
46: ; preds = %40
%47 = load i64, i64* %7
%48 = add i64 %47, 1
store i64 %48, i64* %7
br label %26
49: ; preds = %26
%50 = load double, double* %3
%51 = fcmp ole double %50, 0.000000e+00
%52 = zext i1 %51 to i32
%53 = add nsw i32 %52, 48
%54 = call i32 @putchar(i32 %53)
%55 = call i32 @putchar(i32 10)
ret i32 0
}

LLVM IR (-O2):
@.str = [4 x i8] c"%zu\00"
@.str.1 = [4 x i8] c"%lf\00"
@.str.2 = [3 x i8] c"%d\00"
define i32 @main() {
%1 = alloca i64
%2 = alloca double
%3 = alloca i32
%4 = bitcast i64* %1 to i8*
%5 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i64* %1)
%6 = bitcast double* %2 to i8*
%7 = load i64, i64* %1
%8 = shl i64 %7, 3
%9 = call double* @malloc(i64 %8)
%10 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double* %2)
%11 = load i64, i64* %1
%12 = icmp eq i64 %11, 0
br i1 %12, label %13, label %20
13: ; preds = %0
%14 = bitcast i32* %3 to i8*
br label %18
15: ; preds = %20
%16 = icmp eq i64 %25, 0
%17 = bitcast i32* %3 to i8*
br i1 %16, label %18, label %34
18: ; preds = %13, %15
%19 = load double, double* %2
br label %27
20: ; preds = %0, %20
%21 = phi i64 [ %24, %20 ], [ 0, %0 ]
%22 = getelementptr inbounds double, double* %9, i64 %21
%23 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double* %22)
%24 = add nuw i64 %21, 1
%25 = load i64, i64* %1
%26 = icmp ult i64 %24, %25
br i1 %26, label %20, label %15
27: ; preds = %43, %18
%28 = phi double [ %19, %18 ], [ %47, %43 ]
%29 = bitcast i32* %3 to i8*
%30 = fcmp ole double %28, 0.000000e+00
%31 = select i1 %30, i32 49, i32 48
%32 = call i32 @putchar(i32 %31)
%33 = call i32 @putchar(i32 10)
ret i32 0
34: ; preds = %15, %43
%35 = phi i64 [ %48, %43 ], [ 0, %15 ]
%36 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %3)
%37 = load i32, i32* %3
%38 = icmp eq i32 %37, 0
br i1 %38, label %43, label %39
39: ; preds = %34
%40 = getelementptr inbounds double, double* %9, i64 %35
%41 = load double, double* %40
%42 = fcmp une double %41, 0.000000e+00
br label %43
43: ; preds = %39, %34
%44 = phi i1 [ false, %34 ], [ %42, %39 ]
%45 = uitofp i1 %44 to double
%46 = load double, double* %2
%47 = fsub double %46, %45
store double %47, double* %2
%48 = add nuw i64 %35, 1
%49 = load i64, i64* %1
%50 = icmp ult i64 %48, %49
br i1 %50, label %34, label %27
}