Use python to make Box A smaller than Box B by fixed number?
context.object is also part of the context.selected_objects collection.

So here's what you can do:

import bpy
context = bpy.context

objs = [o for o in context.selected_objects if o != context.object]
for o in objs:

    x = context.object.dimensions.x

    y = context.object.dimensions.y

    z = context.object.dimensions.z

    o.dimensions = [x,y,z]

    o.location = context.object.location