Lenovo legion y520 or hp probook 450 g5?

I'm going to get a new laptop for gaming and I'm confused between getting the Lenovo legion y520 and the hp probook 450 g5. Both are good but the Lenovo favours the graphics card as it has a proccesor of i5 and a graphics card of 4 vram and the hp favours the proccesor as it has i7 proccesor and 2gb vram. I just want games to run with high FPS and no lag and both are around the same price.

The Lenovo should be very much stronger at gaming, but you have not listed exact models of each and provided practically useless information about specifications.
The graphics processor is by far the biggest factor in gaming.

It is highly likely the Lenovo is stronger in gaming.
i5 vs i7 are Intel titles and there are i5's stronger than i7's. The amount of video ram buffer storage does not determine gaming performance as much as the VRAM type as GDDR5 is better than DDR3 or DDR4. For the same graphics processor and video ram type, more video ram may improve performance a little bit. However, stronger graphics processors often require more video ram to operate effectively. A stronger CPU with the same graphics processor is better.
Battery life is affected by many things and the graphics card works when laptop is plugged into the AC power brick.
CPU performance is on this list:

But you suffix includes turbo that is unsustainable in gaming.

Many Probook 450 G5's have
NVIDIA GeForce 930MX (2 GB DDR3 dedicated memory, switchable)
That is rank #232 where lower rank is stronger, but could be worse because it shows DDR3 instead of GDDR5

The worst graphics processor of a Lenovo Legion Y520 is AMD Radeon RX 560 4 GB GDDR5 at rank #100
Star Wars Battlefront 2, for example, reports 43 fps on RX 560 minimum Leovo and only 13.6 frames per second on 930MX HP on high settings.
Similar results on many games.
FIFA 18 (2017) reported 124.3 as Lenovo card minimum and 49.9 on the 930MX.
If it is as expected, and more detail from you would confirm it, the Lenovo should be more than 2X and up to 4X the gaming of the HP.