Result

AC

Duration

3129ms

Code [DL]

s=`dd`
puts s.gsub(/\n.{#{s=~/T/}}/,"\\0T").sub /K */{|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                                  
         KKKKKKKT                                  

stderr

4+1 records in
4+1 records out
2142 bytes (2.1 kB, 2.1 KiB) copied, 0.000106389 s, 20.1 MB/s

strace