Five complete programs, with short explanations and time/space complexity. Each Copy button copies only that question’s C++ code.
Shared lines: #include <iostream> enables input/output; using namespace std; lets us write cin and cout without std::. Execution starts in int main(); return 0; ends it successfully. Braces group statements, and '\n' prints a newline.
Checks: C–E signatures and samples were checked against the question screenshots. A uses your supplied function signature; B follows your supplied calculation. A/B examples below are additional checks, because their original statements and samples were not available.