by@n4o847
AC
820ms
t+=index($0,"T"){$0=substr($0,1,t-1)"T";for(;sub(/K /,"KK"););}1
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 T T T T T T T T T T T T T T T T T KKKKKKKKKKKKKKKKKKKT