Program speed depends on many things.
First and foremost have you handled everything correctly?
Secondly it depends on algorithm complexity.
e.g. if you put a triple for loop your program will be slower than if you have a single for loop.
Speed or time taken by a program depends on how you implement it, there may be several methods (algorithms) to perform the same task, one algorithm is considered better than the other if it has better time or space complexity (Though we usually prefer time over space, depends upon what you want).
As for your question, if your function is small enough then the time taken in calling the function may be more than the time taken by the actual function, in that case you can use inline functions, though usually you may not need them.
Printf and scanf are certainly a lot faster than cin / cout but if you use
With this cin and cout will work as fast as printf/scanf, (this is what you need to use when a question says "you may need to use fast input output" in c++).
PS: I am sort of a competitive programmer myself (though i am not that good yet).