Result

AC

Duration

820ms

Code [DL]

t+=index($0,"T"){$0=substr($0,1,t-1)"T";for(;sub(/K /,"KK"););}1

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
             KKKKKKKKKKKKKKKKKKKT

stderr

strace