Result

WA

Duration

876ms

Code [DL]

my $s=get;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   
                    RRRRRRRRRRRRRRRRRRRRRRRRRRR                             

stderr

strace