Result

AC

Duration

682ms

Code [DL]

t+=index($0,"T"){for($0=substr($0,1,t-1)"T";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
                            KKKKKKKKKKKKKKT

stderr

strace