>

If you didn't invade Ukraine for no reason maybe they wouldn't have sanctioned you...
What value does a treaty with Russia have? >

The Ukraine invasion is a massive violation of the Budapest Memorandum, so zero. >

The Budapest Memorandum isn't/wasn't a treaty, it was basically a 'gentleman's agreement' which Ukraine agreed to because NATO and CIS were doing the national equivalent of wandering around Ukraine going "wow, gosh, this place sure is inflammable.  You better hand those nukes over to us or this whole regime might just go up in flames."  They received no real guarantees or assurances in exchange except the signatories 'super double pinky swearing' to not invade them.
Russia has violated a lot of treaties, though.  The Intermediate Nuclear Forces treaty, Open Skies treaty, the Chemical Weapons Convention, and IIRC they've recently begun to renege on their commitments to the new START treaty (although I could be wrong on that one.) >

Also Russia had the codes these nukes were not usable for Ukraine. >

This is true but college kids have been assembling plans for workable nuclear and atomic bombs since the 80s, using publicly available documents. 
The thing holding most countries back from building a bomb is the fissile material. 
Ukraine scientists didn't even need  to research existing documentation.  The weapons they had could be reverse engineered and of course had all the fissile material they needed.