Find the next number with all different digits, and no 0 or 2
You seem to be missing some headers (&lt;vector&gt;, &lt;iostream&gt;, &lt;cmath&gt; and &lt;set&gt;), and also to be assuming the standard names are in the global namespace, rather than std.
After attempting to read from std::cin, it's important to ensure the read was successful before attempting to use the result.  (E.g. if (!(std::cin &gt;&gt; year)) { std::cerr &lt;&lt; &quot;Input failure\n&quot;; return EXIT_FAILURE; }).
A linear search will be inefficient, especially as we may have to skip long runs containing the banned digits 0 and 2.  It would be better to construct the result using the available digits than to consider and test every possible number.  The search is flawed anyway, since std::pow(10, 8) could be larger than the maximum int, leading to overflow (which is Undefined Behaviour).