#include <iostream>
#include <vector>
using namespace std;
template<typename T>
vector<T> filter(vector<T> base, T val) {
vector<T> temp;
for (auto it : base) if (it == val) temp.push_back(it);
return temp;
}
int main() {
vector<int> v = {7, 5, 16, 8, 5, 12, 1};
for (auto it : filter(v, 5)) cout << it << endl;
}
//https://pt.stackoverflow.com/q/215352/101
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8dmVjdG9yPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKdGVtcGxhdGU8dHlwZW5hbWUgVD4gCnZlY3RvcjxUPiBmaWx0ZXIodmVjdG9yPFQ+IGJhc2UsIFQgdmFsKSB7CiAgICB2ZWN0b3I8VD4gdGVtcDsKICAgIGZvciAoYXV0byBpdCA6IGJhc2UpIGlmIChpdCA9PSB2YWwpIHRlbXAucHVzaF9iYWNrKGl0KTsKICAgIHJldHVybiB0ZW1wOwp9CgppbnQgbWFpbigpIHsKCXZlY3RvcjxpbnQ+IHYgPSB7NywgNSwgMTYsIDgsIDUsIDEyLCAxfTsKCWZvciAoYXV0byBpdCA6IGZpbHRlcih2LCA1KSkgY291dCA8PCBpdCA8PCBlbmRsOwp9CgovL2h0dHBzOi8vcHQuc3RhY2tvdmVyZmxvdy5jb20vcS8yMTUzNTIvMTAx