Coulomb splitting of atomic layers in crystal lattices of layered cuprates and nickelates