I have a feeling this has nothing to do with money but ... oh well ... here goes:
Assuming the price of one beer is x, John is refunded 7x/3, Bill is refunded x/3, Nadya Gets (drunk ... no ...) back $8 - 2x
>John brought 5 bottles of beer, Bill brought 3 bottles, when I came. So, we drank this beer together and then I gave them $8 (all I had at this moment). How should they divide this sum?