by@k_hanazuki
AC
863ms
$/=get;$/.say;$!=.index('K'),say $!??.subst('K','R'x$/.index("T")-$!+1)!!$/ for lines
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 RRRRRRRRRRRRRRRRRRRR