#include <iostream>
#include <list>
#include <algorithm>
int main ()
{
std::list<int> l = { 3, 2, 1, 5, 5, 7, 1, 7, 7, 7, 8, 8 };
std::list<int>::iterator it;
it = std::adjacent_find(l.begin(), l.end());
if (it != l.end())
it = std::adjacent_find(++it, l.end());
if (it != l.end())
std::cout << "The second pair of repeated elements start with: " << *it << '\n';
return 0;
}
/*
run:
The second pair of repeated elements start with: 7
*/