Result

AC

Duration

750ms

Code [DL]

<?php
while($_=readline()){
$t||$t=strpos($_,"T");
$k=strpos($_,"K");
if($k){
echo str_repeat(" ",$k);
echo str_repeat("K",$t-$k+1);
}else{
echo str_repeat(" ",$t);
echo "T\n";
}
}

stdin

                 T                                
                                                  
                                                  
                                                  
                                                  
                                                  
                                                  
                                                  
                                                  
                                                  
                                                  
                                                  
                                                  
                                                  
                                                  
                                                  
                                                  
                                                  
                                                  
                                                  
                                                  
                                                  
                                                  
                                                  
                                                  
                                                  
                                                  
                                                  
                                                  
                                                  
                                                  
                                                  
                                                  
                                                  
                                                  
                                                  
                                                  
                                                  
                                                  
                                                  
                                                  
                                                  
                                                  
                                                  
                                                  
                                                  
          K                                       

stdout

                 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
          KKKKKKKK

stderr

PHP Notice:  Undefined variable: t in /volume/CODE on line 3

strace