Result

AC

Duration

2473ms

Code [DL]

a=gets('_')||""
t=a=~/T/||0
h,k=(a=~/K/||0).divmod 51
h.times{puts a.lines[0]}
puts " "*k+"K"*(t-k+1)

stdin

                                              T   
                                                  
                                                  
                                                  
                                                  
                                                  
                                                  
                                                  
                                                  
                                                  
                                                  
                                                  
                                                  
                                                  
         K                                        

stdout

                                              T   
                                              T   
                                              T   
                                              T   
                                              T   
                                              T   
                                              T   
                                              T   
                                              T   
                                              T   
                                              T   
                                              T   
                                              T   
                                              T   
         KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK

stderr

strace