Result

AC

Duration

910ms

Code [DL]

my $s=get;$s.say;lines.map({my $k=.index('K');say $k??.subst('K','R'x$s.index('T')-$k+1)!!$s;});

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
                                                 T
                                                 T
                                                 T
                                                 T
                                                 T
                                                 T
                                                 T
                                                 T
                                                 T
                                            RRRRRR     

stderr

strace