Time limit exceeded in one of the test cases in Prime visit problem

I have solved the problem and I am attaching the link of my solution here:

I am able to understand that my solution is not optimal. After spending some time I decided to view the solution but still I am unable to understand the solution . I am attaching the solution provided by coding blocks in the below link.

I understand the idea that we are creating an array of size b+1 and we will store 1 if that index value falls between our range and is prime , otherwise we will store 0 and in the end we will count number of ones in our array and display it. But i am unable to understand what is the use of for loop in line 23 and why bitwise AND operation is performed in line 26 and whats happening in the for loop in line 45.

you can see this video to understand the basic logic
https://www.youtube.com/watch?v=8sniiDbfPK4


if it still doesnt resolve your doubt do let me know