I've really been turned off to Logitech products as of late, far too much gimmick for my taste. Weight system? Spare me, the mice like the G5 and G500 are already lardasses of the mousing world before adding any extra weights, weighing in at 150g and 165g respectively,
before any extra. Compare that to the IME3.0 @ 104g...
The G9 was a step in the right direction in terms of getting away from ballooning size and weight, but not only does it have the same gimmick weight system, it has interchangeable grips, seriously...even if you change the grip from the default, you're never going to do it again, its a total waste of money. However the G9 can be found as low as $50 and thus would actually be an option I would consider.
If you're stubborn and/or actually somehow limited to only the two choices you laid out (MX518 vs G5) I would definitely choose the MX518. Not only should it be less expensive, its sensor has a better track record when it comes to performance. Sure, the G5 might be more fine tuned in that it has more stops in the settings you can choose, but that means little when it craps out under high speeds (I'm a relatively high sensitivity user, and I even I can get first generation laser sensors like that in the G5 to wonk out on me) with skipping and unwanted acceleration effects. Sure, such occurrences are rare for me, but if I'm paying $50 for a mouse, I don't ever want to see it happen.
That being said, here is a list of options I would consider before the G5 and/or MX518:
Habu ~$32 - same sensor performance as the G5, but I feel is a better option because its cheaper and has onboard memory for storing profiles and driverless operation. I might even choose this over the MX518, considering the cost and convenience, but its a close call. Alternatively, Microsoft's Sidewinder X5 can be found for the same price (OEM most likely) with roughly the same specs and features, although I don't believe it has the onboard memory like the Habu, and thus would make it an inferior option outside of a potentially better match in ergonomics (which I would find unlikely).
G9 ~$50 - improved laser sensor won't crap out as easily, should be fine for all but the most insanely low sensitivity users. Better than the MX518 and G5 with features, includes onboard memory like the Habu.
DeathAdder ~$45 - similar to the MX518 but better in that it has: slightly better performing sensor, firmware can retain DPI and polling rate settings without drivers, and can be flashed to a firmware that has no tracking prediction (ie line smoothing, something you're stuck with even with the MX518), I'd choose this over most other mice I would recommend here.
IntelliMouse Explorer 3.0 ~$30 - I didn't list a specific website, but these can be found for $30 easily from just about anywhere, perhaps a bit more for a retail package, or even less if OEM. Roughly the same shape as the Habu or DeathAdder, it has a tried and true optical sensor that makes it better when it comes to more aggressive tracking performance, so its lack of extra features that Habu has can be made up for if your primary concern is lower sensitivity tracking performance (mostly first person shooters). I'd take this over the G5 for sure, but probably go for the MX518 for its greater versatility, although for someone who was playing with mice like the MX Rev and MX1000 which don't have DPI buttons, the IME3.0 might be a perfect fit.
There are other options, but I tried to stay within the righthanded/palm form/grip and upper price range (no more than $50) you laid down with your original choices