Result

AC

Duration

1973ms

Code [DL]

f=fn s,i,j,f->t=IO.getn(s,1)
j<=i&&f.(i<50&&j==0&&t||1,i<50&&t<"T"&&i+1||0,t=="K"&&1||j,f)end
f.("",0,0,f)

stdin

                                               T  
                                                  
                                                  
                                                  
                                                  
                                                  
                                                  
                                                  
                                                  
                                                  
                                                  
                                                  
                                                  
                                                  
                                                  
                                                  
                                                  
                                                  
                                                  
                                                  
                                                  
                                                  
                                                  
                                                  
                                                  
                                                  
                                                  
                                                  
                                                  
                                                  
                                                  
                                                  
                                                  
                                                  
                                                  
                                                  
                                                  
                                                  
                                                  
                                                  
                                                  
                                                  
                                                  
                                                  
     K                                            

stdout

                                               T  
                                               1  
                                               1  
                                               1  
                                               1  
                                               1  
                                               1  
                                               1  
                                               1  
                                               1  
                                               1  
                                               1  
                                               1  
                                               1  
                                               1  
                                               1  
                                               1  
                                               1  
                                               1  
                                               1  
                                               1  
                                               1  
                                               1  
                                               1  
                                               1  
                                               1  
                                               1  
                                               1  
                                               1  
                                               1  
                                               1  
                                               1  
                                               1  
                                               1  
                                               1  
                                               1  
                                               1  
                                               1  
                                               1  
                                               1  
                                               1  
                                               1  
                                               1  
                                               1  
     K111111111111111111111111111111111111111111

stderr

strace