program main
  implicit none
  character(len=100000) :: s
  integer :: i, j, n, k = 0, l = 0
  integer, allocatable :: h1(:), h2(:)

  read *, s
  n = len_trim(s)
  allocate (h1(n), h2(n))
  h1 = 0
  h2 = 0

  do i = 1, n-1
    if (s(i:i+1) == 'RR') then
      k = k + 1
    else if(s(i:i+1) == 'RL') then
      h1(i) = h1(i) + int((k+2)/2)
      h1(i+1) = h1(i+1) + int((k+1)/2)
      k = 0
    end if
    j = n - i + 1
    if (s(j-1:j) == 'LL') then
      l = l + 1
    else if (s(j-1:j) == 'RL') then
      h2(j) = h2(j) + int((l+2)/2)
      h2(j-1) = h2(j-1) + int((l+1)/2)
      l = 0
    end if
  end do

  do i = 1, n
    write(*, fmt='(i0, x)', advance='no') h1(i) + h2(i)
  end do
end program

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

@_QFEh1.0 = internal unnamed_addr global ptr null
@_QFEh1.7 = internal unnamed_addr global i64 1
@_QFEh2.0 = internal unnamed_addr global ptr null
@_QFEh2.7 = internal unnamed_addr global i64 1
@_QFEh2.8 = internal unnamed_addr global i64 0
@_QFEk = internal unnamed_addr global i32 0
@_QFEl = internal unnamed_addr global i32 0
@_QFEs = internal global [100000 x i8] undef
@_QQcl.abc1fc1cd95f2aee25b7b1dd4b7cdb9e = linkonce constant [73 x i8] c"/home/ubuntu/Downloads/TheStack_IR/Collated/Fortran/Source_3610/source.f\00"
@_QQcl.16373402fa3425c6e46827601abb88fa = linkonce constant [76 x i8] c"array left hand side must be allocated when the right hand side is a scalar\00"
@_QQcl.5252 = linkonce constant [2 x i8] c"RR"
@_QQcl.524C = linkonce constant [2 x i8] c"RL"
@_QQcl.4C4C = linkonce constant [2 x i8] c"LL"
@_QQcl.2869302C207829 = linkonce constant [7 x i8] c"(i0, x)"
@_QQcl.6E6F = linkonce constant [2 x i8] c"no"
@_QQEnvironmentDefaults = local_unnamed_addr constant ptr null

; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @malloc(i64 noundef) local_unnamed_addr #0

define void @_QQmain() local_unnamed_addr {
  %1 = tail call ptr @_FortranAioBeginExternalListInput(i32 -1, ptr nonnull @_QQcl.abc1fc1cd95f2aee25b7b1dd4b7cdb9e, i32 7)
  %2 = tail call i1 @_FortranAioInputAscii(ptr %1, ptr nonnull @_QFEs, i64 100000)
  %3 = tail call i32 @_FortranAioEndIoStatement(ptr %1)
  br label %4

4:                                                ; preds = %0, %4
  %5 = phi i64 [ 99999, %0 ], [ %9, %4 ]
  %6 = getelementptr [100000 x [1 x i8]], ptr @_QFEs, i64 0, i64 %5
  %7 = load i8, ptr %6, align 1, !tbaa !3
  %8 = icmp eq i8 %7, 32
  %9 = add nsw i64 %5, -1
  %10 = icmp ne i64 %5, 0
  %11 = and i1 %8, %10
  br i1 %11, label %4, label %12

12:                                               ; preds = %4
  %13 = trunc i64 %5 to i32
  %14 = add i32 %13, 1
  %15 = select i1 %8, i32 0, i32 %14
  %16 = sext i32 %15 to i64
  %17 = tail call i64 @llvm.smax.i64(i64 %16, i64 0)
  %18 = shl nuw nsw i64 %17, 2
  %19 = tail call ptr @malloc(i64 %18)
  store ptr %19, ptr @_QFEh1.0, align 8, !tbaa !7
  store i64 1, ptr @_QFEh1.7, align 8, !tbaa !7
  %20 = tail call ptr @malloc(i64 %18)
  store ptr %20, ptr @_QFEh2.0, align 8, !tbaa !7
  store i64 1, ptr @_QFEh2.7, align 8, !tbaa !7
  store i64 %17, ptr @_QFEh2.8, align 8, !tbaa !7
  %.not = icmp eq ptr %19, null
  br i1 %.not, label %21, label %.preheader509

.preheader509:                                    ; preds = %12
  %.not515 = icmp slt i32 %15, 1
  br i1 %.not515, label %.loopexit510, label %.lr.ph.preheader

.lr.ph.preheader:                                 ; preds = %.preheader509
  tail call void @llvm.memset.p0.i64(ptr nonnull align 4 %19, i8 0, i64 %18, i1 false), !tbaa !3
  br label %.loopexit510

21:                                               ; preds = %12
  %22 = tail call {} @_FortranAReportFatalUserError(ptr nonnull @_QQcl.16373402fa3425c6e46827601abb88fa, ptr nonnull @_QQcl.abc1fc1cd95f2aee25b7b1dd4b7cdb9e, i32 10)
  %.unpack493.unpack.unpack = load i64, ptr @_QFEh1.7, align 8, !tbaa !7
  %23 = icmp slt i32 %15, 1
  %24 = select i1 %23, i64 1, i64 %.unpack493.unpack.unpack
  store ptr null, ptr @_QFEh1.0, align 8, !tbaa !7
  store i64 %24, ptr @_QFEh1.7, align 8, !tbaa !7
  %.unpack380.pre = load ptr, ptr @_QFEh2.0, align 8, !tbaa !7
  %.unpack387.unpack.unpack389.pre = load i64, ptr @_QFEh2.8, align 8, !tbaa !7
  br label %.loopexit510

.loopexit510:                                     ; preds = %.lr.ph.preheader, %.preheader509, %21
  %.unpack387.unpack.unpack389 = phi i64 [ %17, %.lr.ph.preheader ], [ %17, %.preheader509 ], [ %.unpack387.unpack.unpack389.pre, %21 ]
  %.unpack380 = phi ptr [ %20, %.lr.ph.preheader ], [ %20, %.preheader509 ], [ %.unpack380.pre, %21 ]
  %.not392 = icmp eq ptr %.unpack380, null
  br i1 %.not392, label %27, label %.preheader508

.preheader508:                                    ; preds = %.loopexit510
  %25 = icmp sgt i64 %.unpack387.unpack.unpack389, 0
  br i1 %25, label %.lr.ph512.preheader, label %.loopexit

.lr.ph512.preheader:                              ; preds = %.preheader508
  %26 = shl nuw i64 %.unpack387.unpack.unpack389, 2
  tail call void @llvm.memset.p0.i64(ptr nonnull align 4 %.unpack380, i8 0, i64 %26, i1 false), !tbaa !3
  br label %.loopexit

27:                                               ; preds = %.loopexit510
  %28 = tail call {} @_FortranAReportFatalUserError(ptr nonnull @_QQcl.16373402fa3425c6e46827601abb88fa, ptr nonnull @_QQcl.abc1fc1cd95f2aee25b7b1dd4b7cdb9e, i32 11)
  %.unpack472.unpack.unpack = load i64, ptr @_QFEh2.7, align 8, !tbaa !7
  %29 = icmp eq i64 %.unpack387.unpack.unpack389, 0
  %30 = select i1 %29, i64 1, i64 %.unpack472.unpack.unpack
  store ptr null, ptr @_QFEh2.0, align 8, !tbaa !7
  store i64 %30, ptr @_QFEh2.7, align 8, !tbaa !7
  store i64 %.unpack387.unpack.unpack389, ptr @_QFEh2.8, align 8, !tbaa !7
  br label %.loopexit

.loopexit:                                        ; preds = %.lr.ph512.preheader, %.preheader508, %27
  %31 = add i32 %15, -1
  %32 = icmp sgt i32 %31, 0
  br i1 %32, label %.lr.ph513.preheader, label %.preheader

.lr.ph513.preheader:                              ; preds = %.loopexit
  %33 = zext i32 %31 to i64
  br label %.lr.ph513

.preheader:                                       ; preds = %96, %.loopexit
  %34 = icmp sgt i32 %15, 0
  br i1 %34, label %.lr.ph514, label %._crit_edge

.lr.ph513:                                        ; preds = %.lr.ph513.preheader, %96
  %indvars.iv = phi i64 [ 1, %.lr.ph513.preheader ], [ %indvars.iv.next, %96 ]
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %sext = shl i64 %indvars.iv.next, 32
  %35 = ashr exact i64 %sext, 32
  %36 = add nsw i64 %indvars.iv, -1
  %37 = getelementptr [100000 x [1 x i8]], ptr @_QFEs, i64 0, i64 %36
  %38 = sub nsw i64 %35, %indvars.iv
  %39 = tail call i64 @llvm.smax.i64(i64 %38, i64 -1)
  %40 = add nsw i64 %39, 1
  %41 = tail call i32 @_FortranACharacterCompareScalar1(ptr %37, ptr nonnull @_QQcl.5252, i64 %40, i64 2)
  %42 = icmp eq i32 %41, 0
  br i1 %42, label %43, label %46

43:                                               ; preds = %.lr.ph513
  %44 = load i32, ptr @_QFEk, align 4, !tbaa !3
  %45 = add i32 %44, 1
  br label %.sink.split

46:                                               ; preds = %.lr.ph513
  %47 = tail call i32 @_FortranACharacterCompareScalar1(ptr %37, ptr nonnull @_QQcl.524C, i64 %40, i64 2)
  %48 = icmp eq i32 %47, 0
  br i1 %48, label %49, label %63

49:                                               ; preds = %46
  %.unpack441 = load ptr, ptr @_QFEh1.0, align 8, !tbaa !7
  %.unpack448.unpack.unpack = load i64, ptr @_QFEh1.7, align 8, !tbaa !7
  %50 = sub i64 %indvars.iv, %.unpack448.unpack.unpack
  %51 = getelementptr i32, ptr %.unpack441, i64 %50
  %52 = load i32, ptr %51, align 4, !tbaa !3
  %53 = load i32, ptr @_QFEk, align 4, !tbaa !3
  %54 = add i32 %53, 2
  %55 = sdiv i32 %54, 2
  %56 = add i32 %55, %52
  store i32 %56, ptr %51, align 4, !tbaa !3
  %57 = sub i64 %35, %.unpack448.unpack.unpack
  %58 = getelementptr i32, ptr %.unpack441, i64 %57
  %59 = load i32, ptr %58, align 4, !tbaa !3
  %60 = add i32 %53, 1
  %61 = sdiv i32 %60, 2
  %62 = add i32 %59, %61
  store i32 %62, ptr %58, align 4, !tbaa !3
  br label %.sink.split

.sink.split:                                      ; preds = %49, %43
  %.sink = phi i32 [ %45, %43 ], [ 0, %49 ]
  store i32 %.sink, ptr @_QFEk, align 4, !tbaa !3
  br label %63

63:                                               ; preds = %.sink.split, %46
  %64 = trunc i64 %indvars.iv to i32
  %65 = sub i32 %15, %64
  %66 = add i32 %65, 1
  %67 = sext i32 %65 to i64
  %68 = sext i32 %66 to i64
  %69 = add nsw i64 %67, -1
  %70 = getelementptr [100000 x [1 x i8]], ptr @_QFEs, i64 0, i64 %69
  %71 = sub nsw i64 %68, %67
  %72 = tail call i64 @llvm.smax.i64(i64 %71, i64 -1)
  %73 = add nsw i64 %72, 1
  %74 = tail call i32 @_FortranACharacterCompareScalar1(ptr %70, ptr nonnull @_QQcl.4C4C, i64 %73, i64 2)
  %75 = icmp eq i32 %74, 0
  br i1 %75, label %76, label %79

76:                                               ; preds = %63
  %77 = load i32, ptr @_QFEl, align 4, !tbaa !3
  %78 = add i32 %77, 1
  br label %.sink.split525

79:                                               ; preds = %63
  %80 = tail call i32 @_FortranACharacterCompareScalar1(ptr %70, ptr nonnull @_QQcl.524C, i64 %73, i64 2)
  %81 = icmp eq i32 %80, 0
  br i1 %81, label %82, label %96

82:                                               ; preds = %79
  %.unpack417 = load ptr, ptr @_QFEh2.0, align 8, !tbaa !7
  %.unpack424.unpack.unpack = load i64, ptr @_QFEh2.7, align 8, !tbaa !7
  %83 = sub i64 %68, %.unpack424.unpack.unpack
  %84 = getelementptr i32, ptr %.unpack417, i64 %83
  %85 = load i32, ptr %84, align 4, !tbaa !3
  %86 = load i32, ptr @_QFEl, align 4, !tbaa !3
  %87 = add i32 %86, 2
  %88 = sdiv i32 %87, 2
  %89 = add i32 %88, %85
  store i32 %89, ptr %84, align 4, !tbaa !3
  %90 = sub i64 %67, %.unpack424.unpack.unpack
  %91 = getelementptr i32, ptr %.unpack417, i64 %90
  %92 = load i32, ptr %91, align 4, !tbaa !3
  %93 = add i32 %86, 1
  %94 = sdiv i32 %93, 2
  %95 = add i32 %92, %94
  store i32 %95, ptr %91, align 4, !tbaa !3
  br label %.sink.split525

.sink.split525:                                   ; preds = %82, %76
  %.sink526 = phi i32 [ %78, %76 ], [ 0, %82 ]
  store i32 %.sink526, ptr @_QFEl, align 4, !tbaa !3
  br label %96

96:                                               ; preds = %.sink.split525, %79
  %exitcond.not = icmp eq i64 %indvars.iv, %33
  br i1 %exitcond.not, label %.preheader, label %.lr.ph513

.lr.ph514:                                        ; preds = %.preheader, %.lr.ph514
  %indvars.iv518 = phi i64 [ %indvars.iv.next519, %.lr.ph514 ], [ 1, %.preheader ]
  %97 = tail call ptr @_FortranAioBeginExternalFormattedOutput(ptr nonnull @_QQcl.2869302C207829, i64 7, ptr null, i32 -1, ptr nonnull @_QQcl.abc1fc1cd95f2aee25b7b1dd4b7cdb9e, i32 32)
  %98 = tail call i1 @_FortranAioSetAdvance(ptr %97, ptr nonnull @_QQcl.6E6F, i64 2)
  %.unpack393 = load ptr, ptr @_QFEh1.0, align 8, !tbaa !7
  %.unpack400.unpack.unpack = load i64, ptr @_QFEh1.7, align 8, !tbaa !7
  %99 = sub i64 %indvars.iv518, %.unpack400.unpack.unpack
  %100 = getelementptr i32, ptr %.unpack393, i64 %99
  %101 = load i32, ptr %100, align 4, !tbaa !3
  %.unpack405 = load ptr, ptr @_QFEh2.0, align 8, !tbaa !7
  %.unpack412.unpack.unpack = load i64, ptr @_QFEh2.7, align 8, !tbaa !7
  %102 = sub i64 %indvars.iv518, %.unpack412.unpack.unpack
  %103 = getelementptr i32, ptr %.unpack405, i64 %102
  %104 = load i32, ptr %103, align 4, !tbaa !3
  %105 = add i32 %104, %101
  %106 = tail call i1 @_FortranAioOutputInteger32(ptr %97, i32 %105)
  %107 = tail call i32 @_FortranAioEndIoStatement(ptr %97)
  %indvars.iv.next519 = add nuw nsw i64 %indvars.iv518, 1
  %exitcond521.not = icmp eq i64 %indvars.iv518, %16
  br i1 %exitcond521.not, label %._crit_edge, label %.lr.ph514

._crit_edge:                                      ; preds = %.lr.ph514, %.preheader
  ret void
}

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

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

declare i32 @_FortranAioEndIoStatement(ptr) local_unnamed_addr

declare {} @_FortranAReportFatalUserError(ptr, ptr, i32) local_unnamed_addr

declare i32 @_FortranACharacterCompareScalar1(ptr, ptr, i64, 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

declare i1 @_FortranAioOutputInteger32(ptr, i32) local_unnamed_addr

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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #2

attributes #0 = { mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" }
attributes #1 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #2 = { nocallback nofree nounwind willreturn memory(argmem: write) }

!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"}
!7 = !{!8, !8, i64 0}
!8 = !{!"descriptor member", !5, i64 0}
