Result

AC

Duration

757ms

Code [DL]

s=`dd`;puts s.gsub(/^(.{#{s=~/T/}}) /,'\1T').sub(/K */){?K*$&.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        
                KKKKKKKKKKKKKKKKKKKKKKKKKT        

stderr

2+1 records in
2+1 records out

strace