integer N,Y
integer m,g,s !万，五千,千

read*,N,Y

do i=0,N
  m=N-i
  do j=0,i
    g=i-j
    s=j
    if(GK(m,g,s)==Y)then
      print"(I0,A,i0,A,i0)",m," ",g," ",s
      STOP
    endif
  end do
end do

print"(I0,A,i0,A,i0)",-1," ",-1," ",-1
contains

pure function GK(m,g,s)
integer,intent(in)::m,g,s
integer GK
GK=m*10000+g*5000+s*1000
end function GK
end
; ModuleID = 'FIRModule'
source_filename = "FIRModule"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"

@_QQcl.50426404122edb9b5d8402be6a8372a7 = linkonce constant [73 x i8] c"/home/ubuntu/Downloads/TheStack_IR/Collated/Fortran/Source_6454/source.f\00"
@_QQcl.2849302C412C69302C412C693029 = linkonce constant [14 x i8] c"(I0,A,i0,A,i0)"
@_QQcl.20 = linkonce constant [1 x i8] c" "
@_QQEnvironmentDefaults = local_unnamed_addr constant ptr null

define void @_QQmain() local_unnamed_addr {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = tail call ptr @_FortranAioBeginExternalListInput(i32 -1, ptr nonnull @_QQcl.50426404122edb9b5d8402be6a8372a7, i32 4)
  %4 = call i1 @_FortranAioInputInteger(ptr %3, ptr nonnull %1, i32 4)
  %5 = call i1 @_FortranAioInputInteger(ptr %3, ptr nonnull %2, i32 4)
  %6 = call i32 @_FortranAioEndIoStatement(ptr %3)
  %7 = load i32, ptr %1, align 4, !tbaa !3
  %8 = icmp ult i32 %7, 2147483647
  br i1 %8, label %.lr.ph26, label %._crit_edge27

.lr.ph26:                                         ; preds = %0
  %9 = add nuw nsw i32 %7, 1
  %10 = load i32, ptr %2, align 4
  %smin = call i32 @llvm.smin.i32(i32 %7, i32 0)
  %11 = sub nuw nsw i32 %9, %smin
  br label %12

12:                                               ; preds = %.lr.ph26, %._crit_edge
  %.01124 = phi i32 [ 0, %.lr.ph26 ], [ %14, %._crit_edge ]
  %13 = sub nuw nsw i32 %7, %.01124
  %14 = add nuw i32 %.01124, 1
  %15 = icmp ult i32 %.01124, 2147483647
  br i1 %15, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %12
  %16 = mul i32 %13, 10000
  br label %17

17:                                               ; preds = %.lr.ph, %33
  %.022 = phi i32 [ 0, %.lr.ph ], [ %35, %33 ]
  %.01321 = phi i32 [ %14, %.lr.ph ], [ %34, %33 ]
  %18 = sub nsw i32 %.01124, %.022
  %19 = mul i32 %18, 5000
  %20 = mul i32 %.022, 1000
  %21 = add i32 %20, %16
  %22 = add i32 %21, %19
  %23 = icmp eq i32 %22, %10
  br i1 %23, label %24, label %33

24:                                               ; preds = %17
  %25 = call ptr @_FortranAioBeginExternalFormattedOutput(ptr nonnull @_QQcl.2849302C412C69302C412C693029, i64 14, ptr null, i32 -1, ptr nonnull @_QQcl.50426404122edb9b5d8402be6a8372a7, i32 12)
  %26 = call i1 @_FortranAioOutputInteger32(ptr %25, i32 %13)
  %27 = call i1 @_FortranAioOutputAscii(ptr %25, ptr nonnull @_QQcl.20, i64 1)
  %28 = call i1 @_FortranAioOutputInteger32(ptr %25, i32 %18)
  %29 = call i1 @_FortranAioOutputAscii(ptr %25, ptr nonnull @_QQcl.20, i64 1)
  %30 = call i1 @_FortranAioOutputInteger32(ptr %25, i32 %.022)
  %31 = call i32 @_FortranAioEndIoStatement(ptr %25)
  %32 = call {} @_FortranAStopStatement(i32 0, i1 false, i1 false)
  unreachable

33:                                               ; preds = %17
  %34 = add nsw i32 %.01321, -1
  %35 = add nuw nsw i32 %.022, 1
  %36 = icmp sgt i32 %.01321, 1
  br i1 %36, label %17, label %._crit_edge

._crit_edge:                                      ; preds = %33, %12
  %exitcond.not = icmp eq i32 %14, %11
  br i1 %exitcond.not, label %._crit_edge27, label %12

._crit_edge27:                                    ; preds = %._crit_edge, %0
  %37 = call ptr @_FortranAioBeginExternalFormattedOutput(ptr nonnull @_QQcl.2849302C412C69302C412C693029, i64 14, ptr null, i32 -1, ptr nonnull @_QQcl.50426404122edb9b5d8402be6a8372a7, i32 18)
  %38 = call i1 @_FortranAioOutputInteger32(ptr %37, i32 -1)
  %39 = call i1 @_FortranAioOutputAscii(ptr %37, ptr nonnull @_QQcl.20, i64 1)
  %40 = call i1 @_FortranAioOutputInteger32(ptr %37, i32 -1)
  %41 = call i1 @_FortranAioOutputAscii(ptr %37, ptr nonnull @_QQcl.20, i64 1)
  %42 = call i1 @_FortranAioOutputInteger32(ptr %37, i32 -1)
  %43 = call i32 @_FortranAioEndIoStatement(ptr %37)
  ret void
}

; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: read)
define i32 @_QFPgk(ptr nocapture readonly %0, ptr nocapture readonly %1, ptr nocapture readonly %2) local_unnamed_addr #0 {
  %4 = load i32, ptr %0, align 4, !tbaa !3
  %5 = mul i32 %4, 10000
  %6 = load i32, ptr %1, align 4, !tbaa !3
  %7 = mul i32 %6, 5000
  %8 = add i32 %7, %5
  %9 = load i32, ptr %2, align 4, !tbaa !3
  %10 = mul i32 %9, 1000
  %11 = add i32 %8, %10
  ret i32 %11
}

declare ptr @_FortranAioBeginExternalListInput(i32, ptr, i32) local_unnamed_addr

declare i1 @_FortranAioInputInteger(ptr, ptr, i32) local_unnamed_addr

declare i32 @_FortranAioEndIoStatement(ptr) local_unnamed_addr

declare ptr @_FortranAioBeginExternalFormattedOutput(ptr, i64, ptr, i32, ptr, i32) local_unnamed_addr

declare i1 @_FortranAioOutputInteger32(ptr, i32) local_unnamed_addr

declare i1 @_FortranAioOutputAscii(ptr, ptr, i64) local_unnamed_addr

declare {} @_FortranAStopStatement(i32, i1, i1) local_unnamed_addr

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.smin.i32(i32, i32) #1

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: read) }
attributes #1 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }

!llvm.module.flags = !{!0, !1, !2}

!0 = !{i32 2, !"Debug Info Version", i32 3}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{!4, !4, i64 0}
!4 = !{!"any data access", !5, i64 0}
!5 = !{!"any access", !6, i64 0}
!6 = !{!"Flang Type TBAA Root"}
