Result

AC

Duration

817ms

Code [DL]

#!perl -p
/T/?$r=$':s/.$r/T\n/,s/K */K x length$&/e

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
                  KKKT

stderr

strace