Result

AC

Duration

1361ms

Code [DL]

program x
character(len=50)::s
read(*,'(a)')s
print('(a)'),s
j=index(s,'T')
do while (.true.)
read(*, '(a)')s
s(j:j)='R'
k=index(s,'K')
if(k.gt.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                           
           RRRRRRRRRRRR                                                  

stderr

strace