Result

AC

Duration

990ms

Code [DL]

s=`dd`;puts s.gsub(/^.{#{s=~/T/}}\K /,?T).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                                       
          T                                       
          T                                       
          T                                       
          T                                       
          T                                       
          T                                       
          T                                       
          T                                       
          T                                       
          T                                       
          T                                       
          T                                       
          T                                       
          T                                       
          T                                       
          T                                       
          T                                       
          T                                       
          T                                       
          T                                       
          T                                       
  KKKKKKKKT                                       

stderr

4+1 records in
4+1 records out

strace