I didn't undertand why divide by 2m is better

Hello @Param302

I am not sure if that answer is accurate.

Dividing by m is so that the cost function does not depend on the number of samples. Further dividing by 2 helps to cancel out the 2 in the numerator, which appears when we take the derivative of Error^2.