How many injective functions from $\{5,6,7,8,9\}$ to itself map $5$ and $6$ to another number?

Your answer $$ 5! - 2\cdot 4! + 3! = 78$$ is correct.

You have counted all the permutations and applied the inclusion exclusion principle correctly.


Although I agree that using inclusion exclusion is the better approach here but i think it is still instructive if we try to count the number of desired injections directly.

Solution. We represent an injection by the ordered $5$-tuple $\left(f(5),f(6),f(7),f(8),f(9)\right)$ and let $S$ denote the set of all desired injections. Then we can partition the set $S$ as follows so that $$S = A_1\cup A_2\cup A_3\cup A_4 $$ where
$$A_1 = \{x\in S|f(5)\in\{7,8,9\}\text{ and }f(6)\in\{7,8,9\}\}$$ $$A_2 = \{x\in S|f(5)\in\{7,8,9\}\text{ and }f(6)\not\in\{7,8,9\}\}$$ $$A_3 = \{x\in S|f(5)\not\in\{7,8,9\}\text{ and }f(6)\in\{7,8,9\}\}$$ $$A_4 = \{x\in S|f(5)\not\in\{7,8,9\}\text{ and }f(6)\not\in\{7,8,9\}\}\text{}$$ then after a little thought it is not difficult to see that $$|S| = |A_1|+|A_2|+|A_3|+|A_4| = \binom{3}{2}\cdot(3!+3!)+\binom{3}{1}\cdot 3!+\binom{3}{1}\cdot 3!+3! = 78$$

and yes your solution is quite correct!