#include <cmath>
#include <iostream>
int sumDiv(int x)
{
int s = 0;
for(int i = 1; i < x; ++i)
{
if(x % i == 0)
s += i;
}
return s;
}
int main()
{
for(int i = 1; i <= 2000; ++i)
{
int a = sumDiv(i);
if(a == i)
std::cout << i << std::endl;
}
}
I2luY2x1ZGUgPGNtYXRoPgojaW5jbHVkZSA8aW9zdHJlYW0+CgppbnQgc3VtRGl2KGludCB4KQp7CiAgICBpbnQgcyA9IDA7CiAgICBmb3IoaW50IGkgPSAxOyBpIDwgeDsgKytpKQogICAgewogICAgICAgIGlmKHggJSBpID09IDApCiAgICAgICAgICAgIHMgKz0gaTsKICAgIH0KICAgIHJldHVybiBzOwp9CgppbnQgbWFpbigpCnsgCiAgICBmb3IoaW50IGkgPSAxOyBpIDw9IDIwMDA7ICsraSkKICAgIHsKICAgICAgICBpbnQgYSA9IHN1bURpdihpKTsKICAgICAgICBpZihhID09IGkpCiAgICAgICAgICAgIHN0ZDo6Y291dCA8PCBpIDw8IHN0ZDo6ZW5kbDsKICAgIH0gIAp9