project euler problem 36 https projecteuler netproblem36 problem statement doublebase palindromes problem 36 the decimal number 585 10010010012 binary is palindromic in both bases find the sum of all numbers less than one million which are palindromic in base 10 and base 2 please note that the palindromic number in either base may not include leading zeros return true if the input n is a palindrome otherwise return false n can be an integer or a string ispalindrome909 true ispalindrome908 false ispalindrome 10101 true ispalindrome 10111 false return the sum of all numbers less than n which are palindromic in base 10 and base 2 solution1000000 872187 solution500000 286602 solution100000 286602 solution1000 1772 solution100 157 solution10 25 solution2 1 solution1 0 return true if the input n is a palindrome otherwise return false n can be an integer or a string is_palindrome 909 true is_palindrome 908 false is_palindrome 10101 true is_palindrome 10111 false return the sum of all numbers less than n which are palindromic in base 10 and base 2 solution 1000000 872187 solution 500000 286602 solution 100000 286602 solution 1000 1772 solution 100 157 solution 10 25 solution 2 1 solution 1 0
from __future__ import annotations


def is_palindrome(n: int | str) -> bool:
    
    n = str(n)
    return n == n[::-1]


def solution(n: int = 1000000):
    
    total = 0

    for i in range(1, n):
        if is_palindrome(i) and is_palindrome(bin(i).split("b")[1]):
            total += i
    return total


if __name__ == "__main__":
    print(solution(int(str(input().strip()))))