#include <iostream>
#include <algorithm>
#include <vector>
template<class Iter>
void simple_sort(Iter first, Iter last)
{
int zeros = 0;
for (auto it = first; it != last; ++it)
if (*it == 0) ++zeros;
std::fill_n(first, zeros, 0);
std::fill_n(first + zeros, last - first - zeros, 1);
}
int main()
{
std::vector<int> v = { 0, 0, 1, 0, 1, 0, 0, 0, 1, 1, 0 };
simple_sort(v.begin(), v.end());
for (const auto &i : v)
std::cout << i << " ";
std::cout << std::endl;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8YWxnb3JpdGhtPgojaW5jbHVkZSA8dmVjdG9yPgoKdGVtcGxhdGU8Y2xhc3MgSXRlcj4Kdm9pZCBzaW1wbGVfc29ydChJdGVyIGZpcnN0LCBJdGVyIGxhc3QpCnsKICAgICAgICBpbnQgemVyb3MgPSAwOwogICAgICAgIGZvciAoYXV0byBpdCA9IGZpcnN0OyBpdCAhPSBsYXN0OyArK2l0KQogICAgICAgICAgICAgICAgaWYgKCppdCA9PSAwKSArK3plcm9zOwoKICAgICAgICBzdGQ6OmZpbGxfbihmaXJzdCwgemVyb3MsIDApOwogICAgICAgIHN0ZDo6ZmlsbF9uKGZpcnN0ICsgemVyb3MsIGxhc3QgLSBmaXJzdCAtIHplcm9zLCAxKTsKfQoKaW50IG1haW4oKQp7CiAgICAgICAgc3RkOjp2ZWN0b3I8aW50PiB2ID0geyAwLCAwLCAxLCAwLCAxLCAwLCAwLCAwLCAxLCAxLCAwIH07CiAgICAgICAgc2ltcGxlX3NvcnQodi5iZWdpbigpLCB2LmVuZCgpKTsKCiAgICAgICAgZm9yIChjb25zdCBhdXRvICZpIDogdikKICAgICAgICAgICAgICAgIHN0ZDo6Y291dCA8PCBpIDw8ICIgIjsKICAgICAgICBzdGQ6OmNvdXQgPDwgc3RkOjplbmRsOwp9Cg==