Result

AC

Duration

673ms

Code [DL]

f={case[p,q]->p}
g={case[i,s]->if(i==0)"" else g([i-1,s])+s}
stdin|reduce(["",""],{case[c,d],s->if(c.length==0){[s,s]}else{if(s.split("K").length>=2){d+"\n"+f(s.split("K"))+g([f(c.split("T")).length-f(s.split("K")).length+1,"A"])}else{[c,d+"\n"+c]}}})|stdout

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                      
      AAAAAAAAAAAAAAAAAAAAAA

stderr

strace

10    execve("/bin/sh", ["/bin/sh", "/root/script", "/volume/CODE"], 0x7ffe9ba8a900 /* 7 vars */) = 0
11    execve("/bin/cat", ["cat", "-"], 0x55dfed900d30 /* 7 vars */) = 0
12    execve("/usr/bin/streem", ["/usr/bin/streem", "/volume/CODE"], 0x55dfed900d40 /* 7 vars */) = 0
11    +++ exited with 0 +++
10    --- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=11, si_uid=0, si_status=0, si_utime=0, si_stime=0} ---
15    +++ exited with 0 +++
14    +++ exited with 0 +++
13    +++ exited with 0 +++
12    +++ exited with 0 +++
10    --- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=12, si_uid=0, si_status=0, si_utime=0, si_stime=0} ---
10    +++ exited with 0 +++