The C++ version is taking a compile and runtime short cut by using printf instead of iostream. This pull request has timings with this changed: https://github.com/atilaneves/pythagoras/pull/1#issuecomment...
Using the stuff isn’t really idiomatic - on both modern and legacy code bases I’ve used operator<< overloads on custom types, but never called std::cout in a hot loop or used std::endl to do anything but actually flush the stream.
Not everyone is micro-optimizing their code just to save a couple of needless extra ms.
I never, ever since 1993, had to work on a C++ project where stdio vs iostream performance made any worthwhile difference, besides stdio being less secure to use.