Result

AC

Duration

880ms

Code [DL]

say $/=get;$!=.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                 
                                T                 
                                T                 
               RRRRRRRRRRRRRRRRRR                                  

stderr

strace