#include<stdio.h>
#include<math.h>
int is_triangular(unsigned long int n)
{
// k**2 + k - 2n = 0
// D = sqrt(1 + 8n)
// k = (-1 + D) / 2
double D
= sqrt(1 + 8 * n
); if( ((unsigned long)D) % 2 == 1)
return 1;
return 0;
}
int main()
{
unsigned long int n;
if(n == 1)
{
return 0;
}
unsigned long int i;
for(i=1; (i * (i+1) / 2) <= (n/2) ; ++i)
{
unsigned long int triangular = i * (i+1) / 2;
if(is_triangular(n-triangular))
{
return 0;
}
}
return 0;
}
I2luY2x1ZGU8c3RkaW8uaD4KI2luY2x1ZGU8bWF0aC5oPgoKaW50IGlzX3RyaWFuZ3VsYXIodW5zaWduZWQgbG9uZyBpbnQgbikKewoJLy8gayoqMiArIGsgLSAybiA9IDAKCS8vIEQgPSBzcXJ0KDEgKyA4bikKCS8vIGsgPSAoLTEgKyBEKSAvIDIKCQoJZG91YmxlIEQgPSBzcXJ0KDEgKyA4ICogbik7CglpZihEIC0gZmxvb3IoRCkgPT0gMCkKCQlpZiggKCh1bnNpZ25lZCBsb25nKUQpICUgMiA9PSAxKQoJCQlyZXR1cm4gMTsKCXJldHVybiAwOwp9CgppbnQgbWFpbigpCnsKCXVuc2lnbmVkIGxvbmcgaW50IG47CglzY2FuZigiJWx1IiwgJm4pOwoJCglpZihuID09IDEpCgl7CgkJcHJpbnRmKCJOTyIpOwoJCXJldHVybiAwOwoJfQoKCXVuc2lnbmVkIGxvbmcgaW50IGk7Cglmb3IoaT0xOyAoaSAqIChpKzEpIC8gMikgPD0gKG4vMikgOyArK2kpCgl7CgkJdW5zaWduZWQgbG9uZyBpbnQgdHJpYW5ndWxhciA9IGkgKiAoaSsxKSAvIDI7CgkJaWYoaXNfdHJpYW5ndWxhcihuLXRyaWFuZ3VsYXIpKQoJCXsKCQkJcHJpbnRmKCJZRVMiKTsKCQkJcmV0dXJuIDA7CgkJfQoJfQoJcHJpbnRmKCJOTyIpOwoJcmV0dXJuIDA7Cn0=