#include <iostream>
#include <vector>
#include <algorithm>
int main()
{
typedef std::vector<int> vec_type;
vec_type numbers { 10, 10, 20, 20, 20, 30, 30, 30, 40, 30, 10, 10 };
auto it = std::begin(numbers);
while ((it = std::adjacent_find(it, std::end(numbers))) != std::end(numbers))
{
auto value = *it;
unsigned matches = 1;
while (++it != std::end(numbers) && *it == value)
++matches;
std::cout << value << ": " << matches << " matches.\n" ;
}
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8dmVjdG9yPgojaW5jbHVkZSA8YWxnb3JpdGhtPgoKaW50IG1haW4oKQp7CiAgICB0eXBlZGVmIHN0ZDo6dmVjdG9yPGludD4gdmVjX3R5cGU7CgogICAgdmVjX3R5cGUgbnVtYmVycyB7IDEwLCAxMCwgMjAsIDIwLCAyMCwgMzAsIDMwLCAzMCwgNDAsIDMwLCAxMCwgMTAgfTsKICAgIAogICAgYXV0byBpdCA9IHN0ZDo6YmVnaW4obnVtYmVycyk7CgogICAgd2hpbGUgKChpdCA9IHN0ZDo6YWRqYWNlbnRfZmluZChpdCwgc3RkOjplbmQobnVtYmVycykpKSAhPSBzdGQ6OmVuZChudW1iZXJzKSkKICAgIHsKICAgICAgICBhdXRvIHZhbHVlID0gKml0OwogICAgICAgIHVuc2lnbmVkIG1hdGNoZXMgPSAxOwoKICAgICAgICB3aGlsZSAoKytpdCAhPSBzdGQ6OmVuZChudW1iZXJzKSAmJiAqaXQgPT0gdmFsdWUpCiAgICAgICAgICAgICsrbWF0Y2hlczsKICAgICAgIAogICAgICAgIHN0ZDo6Y291dCA8PCB2YWx1ZSA8PCAiOiAiIDw8IG1hdGNoZXMgPDwgIiBtYXRjaGVzLlxuIiA7CiAgICB9Cn0=