Result

WA

Duration

2718ms

Code [DL]

a=String.split(IO.read(:all),"\n")
Enum.each(a,fn(x)->IO.puts Regex.replace(~r/K *T/,String.slice(x,0,:binary.match(hd(a),"T")|>elem(0))<>"T",&(String.duplicate("K",byte_size(&1))))end)

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
                              KKKKKKKKKK
T

stderr

strace