Result

AC

Duration

927ms

Code [DL]

s=`dd`
s.gsub!(/^ {#{s[/^ *K/].size-1}}\K /,?#)
s.gsub!(/# *(?=T)/){?#*$&.size}
puts s

stdin

                                               T  
                                                  
                                                  
                                                  
                                                  
                                                  
                                                  
                                                  
                                                  
                                                  
                                                  
                                                  
                                                  
                                                  
                                                  
                                                  
                                                  
                                                  
                                                  
                                                  
                                                  
                                                  
                                                  
                                                  
                                                  
                                                  
                                                  
                                                  
 K                                                

stdout

 ##############################################T  
 #                                                
 #                                                
 #                                                
 #                                                
 #                                                
 #                                                
 #                                                
 #                                                
 #                                                
 #                                                
 #                                                
 #                                                
 #                                                
 #                                                
 #                                                
 #                                                
 #                                                
 #                                                
 #                                                
 #                                                
 #                                                
 #                                                
 #                                                
 #                                                
 #                                                
 #                                                
 #                                                
 K                                                

stderr

2+1 records in
2+1 records out

strace

10    execve("/bin/sh", ["/bin/sh", "/root/script", "/volume/CODE"], 0x7fff5a4d8950 /* 9 vars */) = 0
12    execve("/usr/local/ruby-2.6.3/bin/ruby", ["/usr/local/ruby-2.6.3/bin/ruby", "/volume/CODE"], 0x55af007fad60 /* 9 vars */) = 0
11    execve("/bin/cat", ["cat", "-"], 0x55af007fad40 /* 9 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} ---
13    execve("/bin/dd", ["dd"], 0x562888a2b780 /* 9 vars */) = 0
13    +++ exited with 0 +++
12    --- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=13, si_uid=0, si_status=0, si_utime=0, si_stime=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=8, si_stime=2} ---
10    +++ exited with 0 +++