program problemE
  implicit none

  integer, parameter     :: double = selected_real_kind ( 9 )
  integer, parameter     :: i8 = selected_int_kind  ( 18 )
  real ( kind = double ), parameter :: pi = 3.141592653589790_double

  integer ( kind = i8 )                               :: N, K, i, j, tmp, ans, min
  integer ( kind = i8 ), allocatable, dimension ( : ) :: A, F, AF

  read *, N, K

  allocate ( A  ( 1:N ) )
  allocate ( F  ( 1:N ) )
  allocate ( AF ( 1:N ) )
  
  read *, A ( : )
  read *, F ( : )
  
  do j = 1, N
     do i = 1, N - 1
        if ( A ( i ) > A ( i + 1 ) ) then
           tmp         = A ( i )
           A ( i )     = A ( i + 1 )
           A ( i + 1 ) = tmp
        end if
     end do
  end do
  
  do j = 1, N
     do i = 1, N - 1
        if ( F ( i ) < F ( i + 1 ) ) then
           tmp         = F ( i )
           F ( i )     = F ( i + 1 )
           F ( i + 1 ) = tmp
        end if
     end do
  end do
  
  do i = 1, K
     AF ( 1:N ) = A ( 1:N ) * F ( 1:N )
     if ( sum ( AF ( 1:N ) ) == 0 ) then
        exit
     end if
     A ( maxloc ( AF ( 1:N ) ) ) = A ( maxloc ( AF ( 1:N ) ) ) - 1
  end do
  AF ( 1:N ) = A ( 1:N ) * F ( 1:N )

  do i = 1, N
     write ( *, " ( i3 ) ", advance = "no" ) A ( i )
  end do
  print *, ""

  do i = 1, N
     write ( *, " ( i3 ) ", advance = "no" ) F ( i )
  end do
  print *, ""

  do i = 1, N
     write ( *, " ( i3 ) ", advance = "no" ) AF ( i )
  end do
  print *, ""
  
  ans = maxval ( AF ( 1:N ) )
  print *, ans
  
end program problemE
