Buggy python submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline

n=10**5
sievebd=n//2-1
sieve=[True]*sievebd
limit=(int((n-1)**.5)-1)//2
for i in range(limit):
    if sieve[i]:
        for j in range(2*i**2+6*i+3,sievebd,2*i+3):
            sieve[j]=False
for i in range((sievebd-1)//2-1,-1,-1):
    if not sieve[i]:sieve[2*i+1]=False
for i in range(2,sievebd,2):
    sieve[i]=False

sieve[0]=1
for i in range(1,sievebd):
    sieve[i]+=sieve[i-1]

q=int(input())
l=[0]*q
r=[0]*q
for i in range(q):
    l[i],r[i]=map(int,input().split())

for i in range(q):
    print(sieve[max(1,(r[i]-3)//2+1)]-sieve[max(0,(l[i]-3)//2)])

Fixed submission:
import sys
input = sys.stdin.readline

n=10**5
sievebd=n//2
sieve=[True]*sievebd
limit=int(n**.5)//2
sieve[0]=0
for i in range(limit):
    if sieve[i]:
        for j in range(2*i*(i+1),sievebd,2*i+1):
            sieve[j]=False
for i in range((sievebd-1)//2,0,-1):
    if not sieve[i]:sieve[2*i]=False
for i in range(3,sievebd,2):sieve[i]=False
for i in range(1,sievebd):sieve[i]+=sieve[i-1]
q=int(input())
l=[list(map(int,input().split())) for _ in [0]*q]
for i in range(q):
    print(sieve[(l[i][1]-1)//2]-sieve[max(0,(l[i][0]-1)//2-1)])

Buggy python submission (verdict: Time Limit Exceeded):
q=int(input())
l=[0]*q
r=[0]*q
for i in range(q):
    l[i],r[i]=map(int,input().split())

n=max(r)+1
sievebd=n//2-1
sieve=[True]*sievebd
limit=(int((n-1)**.5)-1)//2
for i in range(limit):
    if sieve[i]:
        for j in range(2*i**2+6*i+3,sievebd,2*i+3):
            sieve[j]=False
for i in range((sievebd-1)//2-1,-1,-1):
    if not sieve[i]:sieve[2*i+1]=False
if len(sieve)>2:
    for i in range(2,sievebd,2):
        sieve[i]=False
for i in range(q):
    print(sum(sieve[max(0,(l[i]-3)//2):max(0,(r[i]-3)//2+1)]))

Fixed submission:
import sys
input = sys.stdin.readline

n=10**5
sievebd=n//2
sieve=[True]*sievebd
limit=int(n**.5)//2
sieve[0]=0
for i in range(limit):
    if sieve[i]:
        for j in range(2*i*(i+1),sievebd,2*i+1):
            sieve[j]=False
for i in range((sievebd-1)//2,0,-1):
    if not sieve[i]:sieve[2*i]=False
for i in range(3,sievebd,2):sieve[i]=False
for i in range(1,sievebd):sieve[i]+=sieve[i-1]
q=int(input())
l=[list(map(int,input().split())) for _ in [0]*q]
for i in range(q):
    print(sieve[(l[i][1]-1)//2]-sieve[max(0,(l[i][0]-1)//2-1)])

Buggy python submission (verdict: Time Limit Exceeded):
n=10**5
sievebd=n//2-1
sieve=[True]*sievebd
limit=(int((n-1)**.5)-1)//2
for i in range(limit):
    if sieve[i]:
        for j in range(2*i**2+6*i+3,sievebd,2*i+3):
            sieve[j]=False
for i in range((sievebd-1)//2-1,-1,-1):
    if not sieve[i]:sieve[2*i+1]=False
for i in range(2,sievebd,2):sieve[i]=False
q=int(input())
for i in range(q):
    l,r=map(lambda x:max(int(x),3),input().split())
    print(sum(sieve[(l-3)//2:(r-3)//2+1]))

Fixed submission:
import sys
input = sys.stdin.readline

n=10**5
sievebd=n//2
sieve=[True]*sievebd
limit=int(n**.5)//2
sieve[0]=0
for i in range(limit):
    if sieve[i]:
        for j in range(2*i*(i+1),sievebd,2*i+1):
            sieve[j]=False
for i in range((sievebd-1)//2,0,-1):
    if not sieve[i]:sieve[2*i]=False
for i in range(3,sievebd,2):sieve[i]=False
for i in range(1,sievebd):sieve[i]+=sieve[i-1]
q=int(input())
l=[list(map(int,input().split())) for _ in [0]*q]
for i in range(q):
    print(sieve[(l[i][1]-1)//2]-sieve[max(0,(l[i][0]-1)//2-1)])

Buggy python submission (verdict: Time Limit Exceeded):
q=int(input())
l=[0]*q
r=[0]*q
for i in range(q):
    l[i],r[i]=map(lambda x:max(int(x),3),input().split())

n=max(r)+1
sievebd=n//2-1
sieve=[True]*sievebd
limit=(int((n-1)**.5)-1)//2
for i in range(limit):
    if sieve[i]:
        for j in range(2*i**2+6*i+3,sievebd,2*i+3):
            sieve[j]=False
for i in range((sievebd-1)//2):
    if not sieve[i]:sieve[2*i+1]=False
if len(sieve)>2:
    for i in range(2,sievebd,2):
        sieve[i]=False
for i in range(q):
    print(sum(sieve[(l[i]-3)//2:(r[i]-3)//2+1]))

Fixed submission:
import sys
input = sys.stdin.readline

n=10**5
sievebd=n//2
sieve=[True]*sievebd
limit=int(n**.5)//2
sieve[0]=0
for i in range(limit):
    if sieve[i]:
        for j in range(2*i*(i+1),sievebd,2*i+1):
            sieve[j]=False
for i in range((sievebd-1)//2,0,-1):
    if not sieve[i]:sieve[2*i]=False
for i in range(3,sievebd,2):sieve[i]=False
for i in range(1,sievebd):sieve[i]+=sieve[i-1]
q=int(input())
l=[list(map(int,input().split())) for _ in [0]*q]
for i in range(q):
    print(sieve[(l[i][1]-1)//2]-sieve[max(0,(l[i][0]-1)//2-1)])

Buggy python submission (verdict: Time Limit Exceeded):
def primes(n,default=2):
    if n<3:return []
    sievebd=n//2-1
    sieve=[True]*sievebd
    limit=(int((n-1)**.5)-1)//2
    for i in range(limit):
        if sieve[i]:
            for j in range(2*i**2+6*i+3,sievebd,2*i+3):
                sieve[j]=False
    return [2]*(default==2)+[2*i+3 for i in range(default//2-1,sievebd) if sieve[i]]
def isprime(n):
    if n==1:
        return False
    elif n<4:
        return True
    elif n%2==0:
        return False
    elif n<9:
        return True
    elif n%3==0:
        return False
    else:
        r=int(n**.5)
        f=5
        while f<=r:
            if n%f==0:
                return False
            if n%(f+2)==0:
                return False
            f+=6
    return True
q=int(input())
l=[0]*q
r=[0]*q
for i in range(q):
    l[i],r[i]=map(int,input().split())
list=[]
for x in primes(max(r)+1,min(l)):
    if isprime((x+1)//2):
        list.append(x)
for i in range(q):
    c=0
    for x in list:
        if l[i]<=x<=r[i]:c+=1
    print(c)

Fixed submission:
import sys
input = sys.stdin.readline

n=10**5
sievebd=n//2
sieve=[True]*sievebd
limit=int(n**.5)//2
sieve[0]=0
for i in range(limit):
    if sieve[i]:
        for j in range(2*i*(i+1),sievebd,2*i+1):
            sieve[j]=False
for i in range((sievebd-1)//2,0,-1):
    if not sieve[i]:sieve[2*i]=False
for i in range(3,sievebd,2):sieve[i]=False
for i in range(1,sievebd):sieve[i]+=sieve[i-1]
q=int(input())
l=[list(map(int,input().split())) for _ in [0]*q]
for i in range(q):
    print(sieve[(l[i][1]-1)//2]-sieve[max(0,(l[i][0]-1)//2-1)])