#include <iostream>
using namespace std;
bool isPalindrome(int x) {
if(x < 0)
return false;
int rem, revX = 0;
int temp = x;
while(temp > 0){
rem = temp % 10;
revX = revX * 10 + rem;
temp = temp / 10;
}
return revX == x;
}
int main() {
int x = 12344321;
cout << isPalindrome(x) << endl;
cout << isPalindrome(-1 * x) << endl;
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKYm9vbCBpc1BhbGluZHJvbWUoaW50IHgpIHsKICAgIGlmKHggPCAwKQogICAgICAgIHJldHVybiBmYWxzZTsKICAgIAogICAgaW50IHJlbSwgcmV2WCA9IDA7CiAgICBpbnQgdGVtcCA9IHg7CiAgICB3aGlsZSh0ZW1wID4gMCl7CiAgICAgICAgcmVtID0gdGVtcCAlIDEwOwogICAgICAgIHJldlggPSByZXZYICogMTAgKyByZW07CiAgICAgICAgdGVtcCA9IHRlbXAgLyAxMDsKICAgIH0KICAgIHJldHVybiByZXZYID09IHg7Cn0KCmludCBtYWluKCkgewoJaW50IHggPSAxMjM0NDMyMTsKCWNvdXQgPDwgaXNQYWxpbmRyb21lKHgpIDw8IGVuZGw7Cgljb3V0IDw8IGlzUGFsaW5kcm9tZSgtMSAqIHgpIDw8IGVuZGw7CglyZXR1cm4gMDsKfQ==