I had the same problem! It was so frustrating to find out the culprit. Ultimately with the help of this thread and some ChatGPT magic, I realized I was looping through items in a “list” rather than a “set” (while working with Python)
Then I modified my code to store the sieve as a set and then the final test case worked!
Before making this change, I was so annoyingly close to the solution as only the last 10-20 inputs of the final test case weren’t running (timed out). I tried to make many changes in my code but ultimately only a change in the data structure helped.
And for those who are interested in the answer:
[nope]