You burn 265 calories running and then 7 calories per minute swimming.
Your friend burns 273 calories running and then 11 calories per minute swimming.
Let us assume that both of you swim for x minutes.
Calories burnt by you = 265+7x
Calories burnt by your friend = 273+11x
Difference between both = 273+11x-(265+7x)
= 273+11x-265-7x
= 8+4x