#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main() {
vector<int> arr = {1, 2, 3, 3, 3, 2, 3, 42, 1, 1}, tmp;
for( int x : arr ){
if(
count_if(
arr.begin(), arr.end(),
[&x](int y){return x==y;}
) <= 2
) tmp.push_back(x) ;
}
arr = tmp;
for( int x : arr ) {
cout << x << endl;
}
cout << arr.size();
// your code goes here
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8YWxnb3JpdGhtPgojaW5jbHVkZSA8dmVjdG9yPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKaW50IG1haW4oKSB7Cgl2ZWN0b3I8aW50PiBhcnIgPSB7MSwgMiwgMywgMywgMywgMiwgMywgNDIsIDEsIDF9LCB0bXA7Cglmb3IoIGludCB4IDogYXJyICl7CgkJaWYoCgkJCWNvdW50X2lmKAoJCQkJYXJyLmJlZ2luKCksIGFyci5lbmQoKSwKCQkJCVsmeF0oaW50IHkpe3JldHVybiB4PT15O30KCQkJKSA8PSAyCgkJICApIHRtcC5wdXNoX2JhY2soeCkgOwoJfQoJYXJyID0gdG1wOwoJZm9yKCBpbnQgeCA6IGFyciApIHsKCQljb3V0IDw8IHggPDwgZW5kbDsJCgl9Cgljb3V0IDw8IGFyci5zaXplKCk7CgkKCQoJLy8geW91ciBjb2RlIGdvZXMgaGVyZQoJcmV0dXJuIDA7Cn0=