Optimized Longest Collatz Sequence
Here are some suggestions:


Don't use global variables.
Instead of using a single big function, break it down to logical parts.
const int N = 1000000; should be constexpr instead of const.
Instead of = {0}, use {}.  The latter makes it clear that you are
value initializing all elements.
i should be declared in the loop.
Post-increment operators i++ should be changed to pre-increment
++i in a discarded-value expression.
iCpy &amp; 1 should be iCpy % 2 == 0.  iCpy &lt;&lt;= 1; // Equivalent to iCpy *= 2 should be iCpy *= 2.  Optimization doesn't happen in this way &mdash; the compiler knows such things much better.
Use &lt;&lt; '\n' instead of &lt;&lt; std::endl when you don't need the flushing behavior.