by@coil_kpc
AC
1240ms
my $s=get;$s.say;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 T T T T T T T T T T RRRRRRRRRRR