Result

AC

Duration

2731ms

Code [DL]

x=`dd`.split '
'
x[..-2].map{|s|puts s.sub(x[0].index('T')||0,'T').sub /K *T/{|y|"K"*y.size}}

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                                       
          T                                       
          T                                       
    KKKKKKK                                       

stderr

4+1 records in
4+1 records out
2499 bytes (2.5 kB, 2.4 KiB) copied, 6.1571e-05 s, 40.6 MB/s

strace