cuipoune:
My first idea was to put them both face to face, run the code, and each will save not the echo, but the signal of the other one (which arrives earlier than the echo). But that didn't work.
What do you mean "that didn't work"? What results did you get when you pointed them at each other? How far apart were they?
Can you get both of them to work in the way they're intended to work - as distance sensors - when operated separately (not simultaneously)?
If you trigger them both at the same time when they're pointed at each other and more than 4 cm apart (I'd use considerably more than 4 cm for testing purposes...say 40 or 50 cm...to eliminate "aiming" issues), it should work.
I've done it (with a pair of HC-SR04), and it works, provided there are no objects that return a quick echo. Of course the distance reported will be half the distance between the units.
To avoid the echo problem, you can remove (de-solder) the transmit transducer from the receiving unit.