I am getting TLE can you see how to fix it?

inside while loop you have another loop

for(int i=a;i<=b;i++)
		{
			if(p[i]==1)
			{
				count++;
			}
		}

which is increasing time complexity

you can avoid this loop by making a prefix sum array
and can find ans in O(1) time for each query

this will help you to get rid of TLE

Hey @asaurabh_26


I am still getting TLE

you code has many mistakes

  1. your prime function is not correct
    you write i instead j in inner loop

  2. instead of int use long long int

  3. make bool p array not int
    because in p array you have to store only 0 and 1

  4. to reduce time complexity if you put the loop inside loop then i will not work
    you have to make loop outside

i have done some changes you can see them in code below

Modified Code