program atcoder0404_D
  integer(8),dimension(1000000)::A
  read(5,*)K
  do I=1,9
     A(I)=I
  end do
  M=10
  do I=1,K
     if(mod(A(I),10)/=0) then
        A(M)=10*A(I)+mod(A(I),10)-1
        M=M+1
     end if
     A(M)=10*A(I)+mod(A(I),10)
     M=M+1
     if(mod(A(I),10)/=9) then
        A(M)=10*A(I)+mod(A(I),10)+1
        M=M+1
     end if
     if (M>=K+1) exit
  end do
  write(6,*)A(K)
end program atcoder0404_D
; 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"

@_QFEa = internal unnamed_addr global [1000000 x i64] undef
@_QQcl.f190109490d844e31fdf0a1a13abcedb = linkonce constant [73 x i8] c"/home/ubuntu/Downloads/TheStack_IR/Collated/Fortran/Source_1901/source.f\00"
@_QQEnvironmentDefaults = local_unnamed_addr constant ptr null

define void @_QQmain() local_unnamed_addr {
  %1 = alloca i32, align 4
  %2 = tail call ptr @_FortranAioBeginExternalListInput(i32 5, ptr nonnull @_QQcl.f190109490d844e31fdf0a1a13abcedb, i32 3)
  %3 = call i1 @_FortranAioInputInteger(ptr %2, ptr nonnull %1, i32 4)
  %4 = call i32 @_FortranAioEndIoStatement(ptr %2)
  store i64 1, ptr @_QFEa, align 16, !tbaa !3
  store i64 2, ptr getelementptr inbounds ([1000000 x i64], ptr @_QFEa, i64 0, i64 1), align 8, !tbaa !3
  store i64 3, ptr getelementptr inbounds ([1000000 x i64], ptr @_QFEa, i64 0, i64 2), align 16, !tbaa !3
  store i64 4, ptr getelementptr inbounds ([1000000 x i64], ptr @_QFEa, i64 0, i64 3), align 8, !tbaa !3
  store i64 5, ptr getelementptr inbounds ([1000000 x i64], ptr @_QFEa, i64 0, i64 4), align 16, !tbaa !3
  store i64 6, ptr getelementptr inbounds ([1000000 x i64], ptr @_QFEa, i64 0, i64 5), align 8, !tbaa !3
  store i64 7, ptr getelementptr inbounds ([1000000 x i64], ptr @_QFEa, i64 0, i64 6), align 16, !tbaa !3
  store i64 8, ptr getelementptr inbounds ([1000000 x i64], ptr @_QFEa, i64 0, i64 7), align 8, !tbaa !3
  store i64 9, ptr getelementptr inbounds ([1000000 x i64], ptr @_QFEa, i64 0, i64 8), align 16, !tbaa !3
  %5 = load i32, ptr %1, align 4, !tbaa !3
  %6 = icmp sgt i32 %5, 0
  br i1 %6, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %0
  %7 = add nuw i32 %5, 1
  %wide.trip.count = zext i32 %7 to i64
  br label %8

8:                                                ; preds = %39, %.lr.ph
  %indvars.iv = phi i64 [ 1, %.lr.ph ], [ %indvars.iv.next, %39 ]
  %.026 = phi i32 [ 10, %.lr.ph ], [ %.2, %39 ]
  %9 = add nsw i64 %indvars.iv, -1
  %10 = getelementptr [1000000 x i64], ptr @_QFEa, i64 0, i64 %9
  %11 = load i64, ptr %10, align 8, !tbaa !3
  %12 = srem i64 %11, 10
  %.not = icmp eq i64 %12, 0
  br i1 %.not, label %21, label %13

13:                                               ; preds = %8
  %14 = mul i64 %11, 10
  %15 = add nsw i64 %12, -1
  %16 = add i64 %15, %14
  %17 = sext i32 %.026 to i64
  %18 = add nsw i64 %17, -1
  %19 = getelementptr [1000000 x i64], ptr @_QFEa, i64 0, i64 %18
  store i64 %16, ptr %19, align 8, !tbaa !3
  %20 = add i32 %.026, 1
  %.pre = load i64, ptr %10, align 8, !tbaa !3
  %.pre30 = srem i64 %.pre, 10
  br label %21

21:                                               ; preds = %13, %8
  %.pre-phi = phi i64 [ %.pre30, %13 ], [ 0, %8 ]
  %22 = phi i64 [ %.pre, %13 ], [ %11, %8 ]
  %.1 = phi i32 [ %20, %13 ], [ %.026, %8 ]
  %23 = mul i64 %22, 10
  %24 = add i64 %23, %.pre-phi
  %25 = sext i32 %.1 to i64
  %26 = add nsw i64 %25, -1
  %27 = getelementptr [1000000 x i64], ptr @_QFEa, i64 0, i64 %26
  store i64 %24, ptr %27, align 8, !tbaa !3
  %28 = add i32 %.1, 1
  %29 = load i64, ptr %10, align 8, !tbaa !3
  %30 = srem i64 %29, 10
  %.not22 = icmp eq i64 %30, 9
  br i1 %.not22, label %39, label %31

31:                                               ; preds = %21
  %32 = mul i64 %29, 10
  %33 = add nsw i64 %30, 1
  %34 = add i64 %33, %32
  %35 = sext i32 %28 to i64
  %36 = add nsw i64 %35, -1
  %37 = getelementptr [1000000 x i64], ptr @_QFEa, i64 0, i64 %36
  store i64 %34, ptr %37, align 8, !tbaa !3
  %38 = add i32 %.1, 2
  br label %39

39:                                               ; preds = %31, %21
  %.2 = phi i32 [ %38, %31 ], [ %28, %21 ]
  %.not23 = icmp sge i32 %.2, %7
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count
  %or.cond = select i1 %.not23, i1 true, i1 %exitcond.not
  br i1 %or.cond, label %._crit_edge, label %8

._crit_edge:                                      ; preds = %39, %0
  %40 = call ptr @_FortranAioBeginExternalListOutput(i32 6, ptr nonnull @_QQcl.f190109490d844e31fdf0a1a13abcedb, i32 21)
  %41 = load i32, ptr %1, align 4, !tbaa !3
  %42 = sext i32 %41 to i64
  %43 = add nsw i64 %42, -1
  %44 = getelementptr [1000000 x i64], ptr @_QFEa, i64 0, i64 %43
  %45 = load i64, ptr %44, align 8, !tbaa !3
  %46 = call i1 @_FortranAioOutputInteger64(ptr %40, i64 %45)
  %47 = call i32 @_FortranAioEndIoStatement(ptr %40)
  ret void
}

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 @_FortranAioOutputInteger64(ptr, i64) local_unnamed_addr

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