Straight-forward Implementation with pruning
Code\ncpp []\n#define SIZE 3165\nclass Solution {\npublic:\n    bool sieve[SIZE];\n    vector<int> primes;\n    bool isPrime(int num)\n    {\n        if (num < 
# Code\n```cpp []\n#define SIZE 3165\nclass Solution {\npublic:\n    bool sieve[SIZE];\n    vector<int> primes;\n    bool isPrime(int num)\n    {\n        if (num < SIZE) return !sieve[num];\n        int sz = primes.size();\n        for (int i = 0; i < sz && primes[i] * primes[i] <= num; i++) {\n            if (num % primes[i] == 0) return false;\n        }\n        return true;\n    }\n    bool isPalindrome(int num)\n    {\n        string s = to_string(num);\n        int i = 0, j = s.size() - 1;\n        while(i < j)\n        {\n            if(s[i++] != s[j--]) return false;\n        }\n        return true;\n    }\n    void generate()\n    {\n        sieve[0] = sieve[1] = true;\n        primes.push_back(2);\n        int i = 3;\n        int sq = sqrt(SIZE);\n        for (; i <= sq; i+=2) {\n            if (!sieve[i]) {\n                primes.push_back(i);\n                for (int j = 2; j * i < SIZE; j++) {\n                    sieve[j*i] = true;\n                }\n            }\n        }\n        i += 2;\n        while (i < SIZE) {\n            if (!sieve[i]) {\n                primes.push_back(i);\n            }\n            i += 2;\n        }\n    }\n    int primePalindrome(int n) {\n        generate();\n        int il = primes.size();\n        if (n < 12) {\n            for (int i = 0; i < il; i++) {\n                if (primes[i] >= n) return primes[i];\n            }\n        }\n        if (n <= 101) return 101;\n\n        if (n >= 9989900) return 100030001;\n        int i = n;\n        if (i % 2 == 0) i++;\n        for (;;) {\n            if (isPrime(i) && isPalindrome(i)) return i;\n            i+=2;\n            if (i >= 1e3 && i <= 1e4) i = 1e4 + 1;\n            if (i >= 1e5 && i <= 1e6) i = 1e6 + 1;\n        }\n        return -1;\n    }\n};\n```
['C++']