Result

AC

Duration

697ms

Code [DL]

/T/{t=index($0,"T");s=$0}/K/{k=index($0,"K");for(s="";t--;)s=s (1>--k?"K":" ")}$0=s

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                                 
        KKKKKKKKK

stderr

strace