the more concentrated the mass, the more powerful is gravity? the more concentrated the mass, the more powerful is gravity? or does it depend exclusively on the total mass? example: 1 $\small\mathsf{cm^3}$ material A = 1000 kg, 20 $\small\mathsf{cm^3}$ material B = 2000 kg
which of the two generates more powerful gravitational force?

I apologize for my English, I am not a native speaker, and I used google translate
To simplify things, I will assume that we have a spherical body and that we are considering Newtonian Physics.

If we have two bodies of the same mass but different radius, as long as we are outside of both bodies, and at the same distance from their centres, the force of gravity will be the same:
$$
F = G \frac{m M_i}{r_i^2}
$$
where $m$ is "our" mass, $M_i$ is the mass of body $i$ and $r_i$ is the distance between our centre and the centre of the body, and $6.67408 × 10^{-11} m^3 kg^{-1} s^{-2}$ is the Gravitational Constant.

So, there is no dependence on the density of the body, only on its total mass.



However, if you are thinking about the gravitational acceleration $g$ at the surface of different planets, not only the masses may differ, but also the distance to their centre. Note that $g$ is given by:
$$
g = G \frac{M_i}{r_i^2}
$$

So, computing for Earth we have that $M_{Earth} = 5.972 \times 10^{24} kg$ and $r_{Earth} = 6.371 \times 10^6 m$, which gives, $g_{Earth} \approx 9.820 m s^{-2}$, slightly different from the standard gravity: $9.80665 m s^{-2}$.

The same computation for Mars, which has $M_{Mars} = 6.39 \times 10^{23} kg$ and $r_{Mars} = 3.3895 \times 10^6 m$, gives $g_{Mars} \approx 3.71 m s^{-2}$. So, since Mars has, roughly, $1/10$ of Earth's mass and $1/2$ of the radius, the acceleration of it's gravity is around $40\%$ of Earth's acceleration.