Arduino Uno keeps restarting at random times

Image is from here.

I was connecting either 5V or 3.3V.

I ended up changing not only MPU6050, but also changed Arduino Uno itself and it helped. It might have been some damage done to it before I guess..