std::adjacent_findを使おう

https://cpprefjp.github.io/reference/algorithm/adjacent_find.html