Having swapped a 2013 YD25 (NP300 manual, Euro5 spec) into a 2005 YD25 (Euro3) R51M, although very similar note that the blocks changed castings in late 2012. The 2013 block is not a direct fit to the 2005 RE5R05A of the R51M, I managed to do it but it's not without major risk to the both the crank and converter/gearbox if you screw up the alignment. Aluminium part of the Sump is indeed different (due to the AC and Alternator bracket) (and 4WD vs 2WD sumps are also different). It's not about kw, it's about casting.
Give me your GearBox specs; i'll ,look into it if you want. I'm suspecting that 2007 from 2005 should be OK but better check before buying a hefty paperweight.
Oh and the pilot bearing for the auto is a b.tch to pull out. Just so you know.
Update 2 hours after posting my initial message : you'll be fine to put that 2005 engine on a 2007 manual gearbox provided it's a 5 speed, the YD25/D40 (are) is the same from 2005-07 to 2010-07. But!, please forward me that gearbox ref (5 or 6 speed? 32101CD340? EA301xx?) and i'll confirm thereafter.
The difference is shown in the pics. The 2005 has a "curved" edge on the left hand side (as viewed from behind). The bottom tapped hole has a dowel locator. It, as the other 2 holes highlighted, do NOT match those of the 2013 block. Only the 6 from the the topest "hole" and going clockwise are a perfect match. The top locating pin is also missing on the 2013 block but the tapped hole can easily be drilled to suit. In summary, the 2013 block is about 1.5 cms wider to the left than the previous castings of the YD25 and you only get 6 out of 9 holes that line up. The rest, well do like me, mesure and drill ....and pray when you mate the engine to the gearbox. In your case, as I said earlier you should be ok; BUT SEND ME YOUR SPECS please.