The partnership that have more points. That is the partnership that scored 505. The 1 points per overtrick is a real point, not just an indicator of bags.
The side which reaches 500 points first wins the game. If both sides reach 500 points in the same deal, the side with the higher score wins.