Result

AC

Duration

715ms

Code [DL]

program x
character(len=50)::s
read(*,'(a)')s
print('(a)'),s
j=index(s,'T')
do
read(*, '(a)')s
s(j:j)='R'
k=index(s,'K')
if(k>0)then
do i=1,k-1
write(*,'(a)',advance='no')' '
end do
do i=k,j
write(*,'(a)',advance='no')'R'
end do
do i=1,50
write(*,'(a)',advance='no')' '
end do
exit
else
print('(a)'),s
end if
end do
end program x

stdin

                                   T              
                                                  
                                                  
                                                  
                                                  
                                                  
                                                  
                                                  
                                                  
                                                  
                                                  
                                                  
                                                  
                                                  
                                                  
                                                  
                                                  
                                                  
                                                  
                                                  
                    K                             

stdout

                                   T              
                                   R              
                                   R              
                                   R              
                                   R              
                                   R              
                                   R              
                                   R              
                                   R              
                                   R              
                                   R              
                                   R              
                                   R              
                                   R              
                                   R              
                                   R              
                                   R              
                                   R              
                                   R              
                                   R              
                    RRRRRRRRRRRRRRRR                                                  

stderr

strace