Result

AC

Duration

1240ms

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                            
           RRRRRRRRRRR                                      

stderr

strace