def issumofsqcube(n, count=0, b=2):
while count <= 5 and (b in range(2, 1 + int(pow(n - 4, 1.0/3)))):
if sqrt(n - pow(b, 3))%1 == 0:
count = count + 1
b = b + 1
else:
b = b + 1
return count == 4
def nextpal(n):
while True:
n = n+1
r = str(n)[::-1]
if int(r) == n:
return int(r)
def sumofpal(n, count=0, s=0, i=11):
while count <= n:
if issumofsqcube(i):
s = s + i
count += 1
i = nextpal(i)
else:
i = nextpal(i)
return s
print(sumofpal(1))
IGRlZiBpc3N1bW9mc3FjdWJlKG4sIGNvdW50PTAsIGI9Mik6CiAgICAgd2hpbGUgY291bnQgPD0gNSBhbmQgKGIgaW4gcmFuZ2UoMiwgMSArIGludChwb3cobiAtIDQsIDEuMC8zKSkpKToKICAgICAgICAgaWYgc3FydChuIC0gcG93KGIsIDMpKSUxID09IDA6CiAgICAgICAgICAgICBjb3VudCA9IGNvdW50ICsgMQogICAgICAgICAgICAgYiA9IGIgKyAxCiAgICAgICAgIGVsc2U6CiAgICAgICAgICAgICBiID0gYiArIDEKICAgICByZXR1cm4gY291bnQgPT0gNAogCiBkZWYgbmV4dHBhbChuKToKICAgICB3aGlsZSBUcnVlOgogICAgICAgICBuID0gbisxCiAgICAgICAgIHIgPSBzdHIobilbOjotMV0KICAgICAgICAgaWYgaW50KHIpID09IG46CiAgICAgICAgICAgICByZXR1cm4gaW50KHIpCiAKIGRlZiBzdW1vZnBhbChuLCBjb3VudD0wLCBzPTAsIGk9MTEpOgogICAgIHdoaWxlIGNvdW50IDw9IG46CiAgICAgICAgIGlmIGlzc3Vtb2ZzcWN1YmUoaSk6CiAgICAgICAgICAgICBzID0gcyArIGkKICAgICAgICAgICAgIGNvdW50ICs9IDEKICAgICAgICAgICAgIGkgPSBuZXh0cGFsKGkpCiAgICAgICAgIGVsc2U6CiAgICAgICAgICAgICBpID0gbmV4dHBhbChpKQogICAgIHJldHVybiBzCiAKIHByaW50KHN1bW9mcGFsKDEpKQ==