Result

AC

Duration

1097ms

Code [DL]

var b=false,c=0,d=1
while let l=readLine(){print(String(
l.map{c in
if"T"==c{d=0}
b="K"==c||b&&d>0
d=(d+1)%50
return d==1||b ?"a":c
}))}

stdin

                                              T   
                                                  
                                                  
                                                  
                                                  
                                                  
                                                  
                                                  
                                                  
                                                  
                                                  
                                                  
                                                  
                                                  
                                                  
                                                  
                                                  
                                                  
                                                  
                                                  
                                                  
                                                  
                                                  
                                                  
                                                  
                                                  
                                      K           

stdout

                                              a   
                                              a   
                                              a   
                                              a   
                                              a   
                                              a   
                                              a   
                                              a   
                                              a   
                                              a   
                                              a   
                                              a   
                                              a   
                                              a   
                                              a   
                                              a   
                                              a   
                                              a   
                                              a   
                                              a   
                                              a   
                                              a   
                                              a   
                                              a   
                                              a   
                                              a   
                                      aaaaaaaaa   

stderr

strace