Buggy python submission (verdict: Runtime Error):
#ABC084D 累積和
from itertools import accumulate
#エラトステネスの篩
def sieve(n: int) -> set: #返り値はset
    num = [True]*n
    num[0] = num[1] = False
    for i in range(3,int(n**0.5)+1,2):
        if num[i]:
            num[i * i:: 2 * i] = [False] * ((n - i ** 2 - 1) // (2 * i) + 1)
    return {2}|{i for i in range(3,n,2) if num[i]}

primelist = sieve(10**5+1)
Q = int(input())
N = []
A = []
for i in range(Q):
    num = list(map(int, input().split()))
    N.append(num)
    
#prime = list(set(sieve(r))-set(sieve(l)))#重複がないlist同士の引き算
    
_2017_like = [1 if i in primelist and (i + 1) // 2 in primelist else 0 for i in range(10**5-1)]#2017likeな数のindexが求まる
sum = list(accumulate(_2017_like)) #ある数までの解の個数
for i in range(Q):
    ans = sum[N[i][1]]-sum[N[i][0]-1] #累積和
    A.append(ans)
print('\n'.join(map(str, A)))

Fixed submission:
#ABC084D 累積和
from itertools import accumulate
#エラトステネスの篩
def sieve(n: int) -> set: #返り値はset
    if n < 2:
        return set()
    
    num = [True]*n
    num[0] = num[1] = False
    for i in range(3,int(n**0.5)+1,2):
        if num[i]:
            num[i * i:: 2 * i] = [False] * ((n - i ** 2 - 1) // (2 * i) + 1)
    return {2}|{i for i in range(3,n,2) if num[i]}

primelist = sieve(10**5+1)
Q = int(input())
N = []
A = []
for i in range(Q):
    num = list(map(int, input().split()))
    N.append(num)
    
#prime = list(set(sieve(r))-set(sieve(l)))#重複がないlist同士の引き算
    
_2017_like = [1 if i in primelist and (i + 1) // 2 in primelist else 0 for i in range(10**5+1)]#2017likeな数のindexが求まる
sum = list(accumulate(_2017_like)) #ある数までの解の個数
for j in range(Q):
    ans = sum[N[j][1]]-sum[N[j][0]-1] #累積和
    A.append(ans)
print('\n'.join(map(str, A)))

Buggy python submission (verdict: Runtime Error):
#ABC084D 累積和
from itertools import accumulate
#エラトステネスの篩
def sieve(n: int) -> set: #返り値はset
    if n < 2:
        return set()
    
    num = [True]*n
    num[0] = num[1] = False
    for i in range(3,int(n**0.5)+1,2):
        if num[i]:
            num[i * i:: 2 * i] = [False] * ((n - i ** 2 - 1) // (2 * i) + 1)
    return {2}|{i for i in range(3,n,2) if num[i]}

primelist = sieve(10**5+1)
Q = int(input())
N = []
A = []
for i in range(Q):
    num = list(map(int, input().split()))
    N.append(num)
    
#prime = list(set(sieve(r))-set(sieve(l)))#重複がないlist同士の引き算
    
_2017_like = [1 if i in primelist and (i + 1) // 2 in primelist else 0 for i in range(10**5-1)]#2017likeな数のindexが求まる
sum = list(accumulate(_2017_like)) #ある数までの解の個数
for i in range(Q):
    ans = sum[N[i][1]]-sum[N[i][0]-1] #累積和
    A.append(ans)
print('\n'.join(map(str, A)))

Fixed submission:
#ABC084D 累積和
from itertools import accumulate
#エラトステネスの篩
def sieve(n: int) -> set: #返り値はset
    if n < 2:
        return set()
    
    num = [True]*n
    num[0] = num[1] = False
    for i in range(3,int(n**0.5)+1,2):
        if num[i]:
            num[i * i:: 2 * i] = [False] * ((n - i ** 2 - 1) // (2 * i) + 1)
    return {2}|{i for i in range(3,n,2) if num[i]}

primelist = sieve(10**5+1)
Q = int(input())
N = []
A = []
for i in range(Q):
    num = list(map(int, input().split()))
    N.append(num)
    
#prime = list(set(sieve(r))-set(sieve(l)))#重複がないlist同士の引き算
    
_2017_like = [1 if i in primelist and (i + 1) // 2 in primelist else 0 for i in range(10**5+1)]#2017likeな数のindexが求まる
sum = list(accumulate(_2017_like)) #ある数までの解の個数
for j in range(Q):
    ans = sum[N[j][1]]-sum[N[j][0]-1] #累積和
    A.append(ans)
print('\n'.join(map(str, A)))

Buggy python submission (verdict: Runtime Error):
#ABC084D 累積和
from itertools import accumulate
#エラトステネスの篩
def sieve(n: int) -> set: #返り値はset
    if n < 2:
        return set()
    
    num = [True]*n
    num[0] = num[1] = False
    for i in range(3,int(n**0.5)+1,2):
        if num[i]:
            num[i * i:: 2 * i] = [False] * ((n - i ** 2 - 1) // (2 * i) + 1)
    return {2}|{i for i in range(3,n,2) if num[i]}

primelist = sieve(10**5+1)
Q = int(input())
N = []
A = []
for i in range(Q):
    num = list(map(int, input().split()))
    N.append(num)
    
#prime = list(set(sieve(r))-set(sieve(l)))#重複がないlist同士の引き算
    
_2017_like = [1 if i in primelist and (i + 1) // 2 in primelist else 0 for i in range(10**5-1)]#2017likeな数のindexが求まる
sum = list(accumulate(_2017_like)) #ある数までの解の個数
for i in range(Q):
    ans = sum[N[i][1]]-sum[N[i][0]-1] #累積和
    A.append(ans)
print('\n'.join(map(str, A)))

Fixed submission:
#ABC084D 累積和
from itertools import accumulate
#エラトステネスの篩
def sieve(n: int) -> set: #返り値はset
    if n < 2:
        return set()
    
    num = [True]*n
    num[0] = num[1] = False
    for i in range(3,int(n**0.5)+1,2):
        if num[i]:
            num[i * i:: 2 * i] = [False] * ((n - i ** 2 - 1) // (2 * i) + 1)
    return {2}|{i for i in range(3,n,2) if num[i]}

primelist = sieve(10**5+1)
Q = int(input())
N = []
A = []
for i in range(Q):
    num = list(map(int, input().split()))
    N.append(num)
    
#prime = list(set(sieve(r))-set(sieve(l)))#重複がないlist同士の引き算
    
_2017_like = [1 if i in primelist and (i + 1) // 2 in primelist else 0 for i in range(10**5+1)]#2017likeな数のindexが求まる
sum = list(accumulate(_2017_like)) #ある数までの解の個数
for j in range(Q):
    ans = sum[N[j][1]]-sum[N[j][0]-1] #累積和
    A.append(ans)
print('\n'.join(map(str, A)))