Finding solution for pancake sort efficiently without actually flipping each time
You should drop namespace std; It is bad practice even in challenges.
Use more descriptive names even if the variable is named so in the problem. You can also use a range based loop for the initialization of the elements.

size_t vectorLength;
std::cin &gt;&gt; vectorLength;
std::vector&lt;int&gt; numbers(vectorLength);    
for (auto &amp;number : numbers) {
    std::cin &gt;&gt; number;
}

You declare the iterators outside of the loop, which is uneccessary, if both have the same type.

for (auto first  = v.begin(), last = v.end(); first != last; --last)


Also you iterate from the end so you might want to think about using reverse iterators aka rbegin() and rend()
When comparing or increasing iterators, you should use mid == std::next(last, 1) and or std::prev accordingly. This works with every kind of iterator. 


This also brings me to the bad choice of your loop variable. the iterator is called last and you compare with std::next(last, 1), which one would expect to be out of memory access. Instead define an explicit iterator auto it = numbers.end() and use it in your loop, avoiding confusion.