program sample
    implicit none
    character(100)s1,s2,s3
    integer(8) :: i,j,m,n,y,a,b,c,x,z
    
  
    read(*,*) n,y
    a=y/10000
    x=mod(y,10000)
    if(n>y/1000)then
        write(*,*)'-1 -1 -1'
        stop
    end if
    
    if(x>=5000)then
        b=1
        c=x/1000-5
    else
        c=x/1000
    end if!ここで最小の枚数
  
    if(a+b+c>n)then
        write(*,*)'-1 -1 -1'
        stop
    end if

    if(2*a+b+c>=n)then
        z=n-a-b-c
        a=a-z
        b=b+2*z
        
    else
        x=mod(n,4)
        z=mod(2*a+b+c,4)
        x=mod(z+4-x,4)
        if(a-x<0)then
            write(*,*)'-1 -1 -1'
            stop
        end if
        b=b+2*(a-x)
        a=x
        x=(n-a-b-c)/4
        b=b-x
        if(b<0)then
            write(*,*)'-1 -1 -1'
            stop
        end if
        c=c+5*x

    end if
    write(s1,'(i4)')a
    write(s2,'(i4)')b
    write(s3,'(i4)')c
 
    write(*,fmt='(a,x,a)',advance='no')s1,s2
    write(*,fmt='(a)',advance='no')s3

    stop
end program sample
  


; 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"

@_QFEs1 = internal global [100 x i8] undef
@_QFEs2 = internal global [100 x i8] undef
@_QFEs3 = internal global [100 x i8] undef
@_QQcl.1277a493adc8cb022c5d489d0fbbe277 = linkonce constant [73 x i8] c"/home/ubuntu/Downloads/TheStack_IR/Collated/Fortran/Source_6461/source.f\00"
@_QQcl.2D31202D31202D31 = linkonce constant [8 x i8] c"-1 -1 -1"
@_QQcl.28693429 = linkonce constant [4 x i8] c"(i4)"
@_QQcl.28612C782C6129 = linkonce constant [7 x i8] c"(a,x,a)"
@_QQcl.6E6F = linkonce constant [2 x i8] c"no"
@_QQcl.286129 = linkonce constant [3 x i8] c"(a)"
@_QQEnvironmentDefaults = local_unnamed_addr constant ptr null

; Function Attrs: noreturn
define void @_QQmain() local_unnamed_addr #0 {
  %1 = alloca i64, align 8
  %2 = alloca i64, align 8
  %3 = tail call ptr @_FortranAioBeginExternalListInput(i32 -1, ptr nonnull @_QQcl.1277a493adc8cb022c5d489d0fbbe277, i32 7)
  %4 = call i1 @_FortranAioInputInteger(ptr %3, ptr nonnull %1, i32 8)
  %5 = call i1 @_FortranAioInputInteger(ptr %3, ptr nonnull %2, i32 8)
  %6 = call i32 @_FortranAioEndIoStatement(ptr %3)
  %7 = load i64, ptr %2, align 8, !tbaa !3
  %8 = sdiv i64 %7, 10000
  %9 = srem i64 %7, 10000
  %10 = load i64, ptr %1, align 8, !tbaa !3
  %11 = sdiv i64 %7, 1000
  %12 = icmp sgt i64 %10, %11
  br i1 %12, label %13, label %18

13:                                               ; preds = %0
  %14 = call ptr @_FortranAioBeginExternalListOutput(i32 -1, ptr nonnull @_QQcl.1277a493adc8cb022c5d489d0fbbe277, i32 11)
  %15 = call i1 @_FortranAioOutputAscii(ptr %14, ptr nonnull @_QQcl.2D31202D31202D31, i64 8)
  %16 = call i32 @_FortranAioEndIoStatement(ptr %14)
  %17 = call {} @_FortranAStopStatement(i32 0, i1 false, i1 false)
  unreachable

18:                                               ; preds = %0
  %19 = icmp sgt i64 %9, 4999
  %.lhs.trunc = trunc i64 %9 to i16
  br i1 %19, label %20, label %23

20:                                               ; preds = %18
  %21 = udiv i16 %.lhs.trunc, 1000
  %.zext = zext i16 %21 to i64
  %22 = add nsw i64 %.zext, -5
  br label %25

23:                                               ; preds = %18
  %24 = sdiv i16 %.lhs.trunc, 1000
  %.sext49 = sext i16 %24 to i64
  br label %25

25:                                               ; preds = %20, %23
  %.0 = phi i64 [ %22, %20 ], [ %.sext49, %23 ]
  %26 = add nsw i64 %8, 1
  %27 = add nsw i64 %26, %.0
  %28 = icmp sgt i64 %27, %10
  br i1 %28, label %29, label %34

29:                                               ; preds = %25
  %30 = call ptr @_FortranAioBeginExternalListOutput(i32 -1, ptr nonnull @_QQcl.1277a493adc8cb022c5d489d0fbbe277, i32 23)
  %31 = call i1 @_FortranAioOutputAscii(ptr %30, ptr nonnull @_QQcl.2D31202D31202D31, i64 8)
  %32 = call i32 @_FortranAioEndIoStatement(ptr %30)
  %33 = call {} @_FortranAStopStatement(i32 0, i1 false, i1 false)
  unreachable

34:                                               ; preds = %25
  %35 = shl nsw i64 %8, 1
  %36 = or i64 %35, 1
  %37 = add nsw i64 %36, %.0
  %.not = icmp slt i64 %37, %10
  br i1 %.not, label %45, label %38

38:                                               ; preds = %34
  %39 = xor i64 %8, -1
  %40 = add i64 %10, %39
  %41 = sub i64 %40, %.0
  %42 = sub i64 %8, %41
  %43 = shl i64 %41, 1
  %44 = or i64 %43, 1
  br label %75

45:                                               ; preds = %34
  %46 = srem i64 %10, 4
  %47 = srem i64 %37, 4
  %48 = sub nsw i64 4, %46
  %49 = add nsw i64 %48, %47
  %.lhs.trunc47 = trunc i64 %49 to i8
  %50 = srem i8 %.lhs.trunc47, 4
  %.sext = sext i8 %50 to i64
  %51 = sub nsw i64 %8, %.sext
  %52 = icmp slt i64 %51, 0
  br i1 %52, label %53, label %58

53:                                               ; preds = %45
  %54 = call ptr @_FortranAioBeginExternalListOutput(i32 -1, ptr nonnull @_QQcl.1277a493adc8cb022c5d489d0fbbe277, i32 37)
  %55 = call i1 @_FortranAioOutputAscii(ptr %54, ptr nonnull @_QQcl.2D31202D31202D31, i64 8)
  %56 = call i32 @_FortranAioEndIoStatement(ptr %54)
  %57 = call {} @_FortranAStopStatement(i32 0, i1 false, i1 false)
  unreachable

58:                                               ; preds = %45
  %59 = shl nuw nsw i64 %51, 1
  %60 = or i64 %59, 1
  %61 = add nsw i64 %.0, %.sext
  %62 = add nsw i64 %61, %60
  %63 = sub i64 %10, %62
  %64 = sdiv i64 %63, 4
  %65 = sub nsw i64 %60, %64
  %66 = icmp slt i64 %65, 0
  br i1 %66, label %67, label %72

67:                                               ; preds = %58
  %68 = call ptr @_FortranAioBeginExternalListOutput(i32 -1, ptr nonnull @_QQcl.1277a493adc8cb022c5d489d0fbbe277, i32 45)
  %69 = call i1 @_FortranAioOutputAscii(ptr %68, ptr nonnull @_QQcl.2D31202D31202D31, i64 8)
  %70 = call i32 @_FortranAioEndIoStatement(ptr %68)
  %71 = call {} @_FortranAStopStatement(i32 0, i1 false, i1 false)
  unreachable

72:                                               ; preds = %58
  %73 = mul i64 %64, 5
  %74 = add i64 %73, %.0
  br label %75

75:                                               ; preds = %38, %72
  %.040 = phi i64 [ %42, %38 ], [ %.sext, %72 ]
  %.139 = phi i64 [ %44, %38 ], [ %65, %72 ]
  %.1 = phi i64 [ %.0, %38 ], [ %74, %72 ]
  %76 = call ptr @_FortranAioBeginInternalFormattedOutput(ptr nonnull @_QFEs1, i64 100, ptr nonnull @_QQcl.28693429, i64 4, ptr null, ptr null, i64 0, ptr nonnull @_QQcl.1277a493adc8cb022c5d489d0fbbe277, i32 51)
  %77 = call i1 @_FortranAioOutputInteger64(ptr %76, i64 %.040)
  %78 = call i32 @_FortranAioEndIoStatement(ptr %76)
  %79 = call ptr @_FortranAioBeginInternalFormattedOutput(ptr nonnull @_QFEs2, i64 100, ptr nonnull @_QQcl.28693429, i64 4, ptr null, ptr null, i64 0, ptr nonnull @_QQcl.1277a493adc8cb022c5d489d0fbbe277, i32 52)
  %80 = call i1 @_FortranAioOutputInteger64(ptr %79, i64 %.139)
  %81 = call i32 @_FortranAioEndIoStatement(ptr %79)
  %82 = call ptr @_FortranAioBeginInternalFormattedOutput(ptr nonnull @_QFEs3, i64 100, ptr nonnull @_QQcl.28693429, i64 4, ptr null, ptr null, i64 0, ptr nonnull @_QQcl.1277a493adc8cb022c5d489d0fbbe277, i32 53)
  %83 = call i1 @_FortranAioOutputInteger64(ptr %82, i64 %.1)
  %84 = call i32 @_FortranAioEndIoStatement(ptr %82)
  %85 = call ptr @_FortranAioBeginExternalFormattedOutput(ptr nonnull @_QQcl.28612C782C6129, i64 7, ptr null, i32 -1, ptr nonnull @_QQcl.1277a493adc8cb022c5d489d0fbbe277, i32 55)
  %86 = call i1 @_FortranAioSetAdvance(ptr %85, ptr nonnull @_QQcl.6E6F, i64 2)
  %87 = call i1 @_FortranAioOutputAscii(ptr %85, ptr nonnull @_QFEs1, i64 100)
  %88 = call i1 @_FortranAioOutputAscii(ptr %85, ptr nonnull @_QFEs2, i64 100)
  %89 = call i32 @_FortranAioEndIoStatement(ptr %85)
  %90 = call ptr @_FortranAioBeginExternalFormattedOutput(ptr nonnull @_QQcl.286129, i64 3, ptr null, i32 -1, ptr nonnull @_QQcl.1277a493adc8cb022c5d489d0fbbe277, i32 56)
  %91 = call i1 @_FortranAioSetAdvance(ptr %90, ptr nonnull @_QQcl.6E6F, i64 2)
  %92 = call i1 @_FortranAioOutputAscii(ptr %90, ptr nonnull @_QFEs3, i64 100)
  %93 = call i32 @_FortranAioEndIoStatement(ptr %90)
  %94 = call {} @_FortranAStopStatement(i32 0, i1 false, i1 false)
  unreachable
}

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 @_FortranAioBeginExternalListOutput(i32, ptr, i32) local_unnamed_addr

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

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

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

declare i1 @_FortranAioOutputInteger64(ptr, i64) local_unnamed_addr

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

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

attributes #0 = { noreturn }

!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"}
