by@coil_kpc
WA
876ms
my $s=get;lines.map({my $k=.index('K');say $k??.subst('K','R'x$s.index("T")-$k+1)!!$s;});
T K
T T T T T T T T T T T T T T T T T T T T T RRRRRRRRRRRRRRRRRRRRRRRRRRR