Time limit exceeding in test case3

Despite employing the sieve technique the time limit for test case 3 is still exceeding