Result

AC

Duration

863ms

Code [DL]

$/=get;$/.say;$!=.index('K'),say $!??.subst('K','R'x$/.index("T")-$!+1)!!$/ for lines

stdin

                               T                  
                                                  
                                                  
                                                  
                                                  
                                                  
                                                  
                                                  
                                                  
                                                  
                                                  
                                                  
                                                  
                                                  
                                                  
                                                  
                                                  
                                                  
                                                  
                                                  
                                                  
                                                  
                                                  
                                                  
            K                                     

stdout

                               T                  
                               T                  
                               T                  
                               T                  
                               T                  
                               T                  
                               T                  
                               T                  
                               T                  
                               T                  
                               T                  
                               T                  
                               T                  
                               T                  
                               T                  
                               T                  
                               T                  
                               T                  
                               T                  
                               T                  
                               T                  
                               T                  
                               T                  
                               T                  
            RRRRRRRRRRRRRRRRRRRR                                     

stderr

strace