by@n4o847
WA
689ms
/T/{t=index($0,"T");s=$0}/K/{k=index($0,"K");for(s="";t--;k--)s=s (k<0?"K":" ")}$0=s
T K
T T T T T T T T T T T T T T T T T T T T KKKKKKKKKKKKKK