Buggy python submission (verdict: Time Limit Exceeded):
def get_sieve_of_eratosthenes(n):
    if not isinstance(n, int):
        raise TypeError('n is int type.')
    if n < 2:
        raise ValueError('n is more than 2')
    prime = [2]
    limit = int(n**0.5)
    data = [i + 1 for i in range(2, n, 2)]
    while True:
        p = data[0]
        if limit <= p:
            return prime + data
        prime.append(p)
        data = [e for e in data if e % p != 0]
q = int(input())
rl = [map(int, input().split()) for _ in range(q)]

li = get_sieve_of_eratosthenes(10**5+1)
pli = [False] * (10**5+1)

for i in li:
  pli[i] = True

# print(li)
for l, r in rl:
  cnt = 0
  for j in range(l, r + 1):
    if j % 2 == 1 and pli[j] and pli[(j + 1) // 2]:
      cnt += 1
  print(cnt)


Fixed submission:
def get_sieve_of_eratosthenes(n):
    if not isinstance(n, int):
        raise TypeError('n is int type.')
    if n < 2:
        raise ValueError('n is more than 2')
    prime = [2]
    limit = int(n**0.5)
    data = [i + 1 for i in range(2, n, 2)]
    while True:
        p = data[0]
        if limit <= p:
            return prime + data
        prime.append(p)
        data = [e for e in data if e % p != 0]
q = int(input())
rl = [map(int, input().split()) for _ in range(q)]

li = get_sieve_of_eratosthenes(10**5+1)
pli = [False] * (10**5+1)

for i in li:
  pli[i] = True

# print(pli)
  
# print(li)
cpli = [0] * (10**5+1)

cnt = 0
for i in range(10**5+1):
  if i % 2 == 1 and pli[i] and pli[(i + 1) // 2]:
    cnt += 1
  cpli[i] = cnt

# print(cpli)
  
for l, r in rl:
  print(cpli[r] - cpli[l-1])

Buggy python submission (verdict: Time Limit Exceeded):
def get_sieve_of_eratosthenes(n):
    if not isinstance(n, int):
        raise TypeError('n is int type.')
    if n < 2:
        raise ValueError('n is more than 2')
    prime = [2]
    limit = int(n**0.5)
    data = [i + 1 for i in range(2, n, 2)]
    while True:
        p = data[0]
        if limit <= p:
            return prime + data
        prime.append(p)
        data = [e for e in data if e % p != 0]
q = int(input())
rl = [map(int, input().split()) for _ in range(q)]

li = set(get_sieve_of_eratosthenes(10**5))
# print(li)
for l, r in rl:
  cnt = 0
  for j in range(l, r + 1):
    if j % 2 == 1 and j in li and (j + 1) // 2 in li:
      cnt += 1
  print(cnt)


Fixed submission:
def get_sieve_of_eratosthenes(n):
    if not isinstance(n, int):
        raise TypeError('n is int type.')
    if n < 2:
        raise ValueError('n is more than 2')
    prime = [2]
    limit = int(n**0.5)
    data = [i + 1 for i in range(2, n, 2)]
    while True:
        p = data[0]
        if limit <= p:
            return prime + data
        prime.append(p)
        data = [e for e in data if e % p != 0]
q = int(input())
rl = [map(int, input().split()) for _ in range(q)]

li = get_sieve_of_eratosthenes(10**5+1)
pli = [False] * (10**5+1)

for i in li:
  pli[i] = True

# print(pli)
  
# print(li)
cpli = [0] * (10**5+1)

cnt = 0
for i in range(10**5+1):
  if i % 2 == 1 and pli[i] and pli[(i + 1) // 2]:
    cnt += 1
  cpli[i] = cnt

# print(cpli)
  
for l, r in rl:
  print(cpli[r] - cpli[l-1])

Buggy python submission (verdict: Time Limit Exceeded):
def get_sieve_of_eratosthenes(n):
    if not isinstance(n, int):
        raise TypeError('n is int type.')
    if n < 2:
        raise ValueError('n is more than 2')
    prime = [2]
    limit = int(n**0.5)
    data = [i + 1 for i in range(2, n, 2)]
    while True:
        p = data[0]
        if limit <= p:
            return prime + data
        prime.append(p)
        data = [e for e in data if e % p != 0]
q = int(input())
rl = [map(int, input().split()) for _ in range(q)]

li = get_sieve_of_eratosthenes(10**5)
# print(li)
for l, r in rl:
  cnt = 0
  for j in range(l, r + 1):
    if j % 2 == 1 and j in li and (j + 1) // 2 in li:
      cnt += 1
  print(cnt)

Fixed submission:
def get_sieve_of_eratosthenes(n):
    if not isinstance(n, int):
        raise TypeError('n is int type.')
    if n < 2:
        raise ValueError('n is more than 2')
    prime = [2]
    limit = int(n**0.5)
    data = [i + 1 for i in range(2, n, 2)]
    while True:
        p = data[0]
        if limit <= p:
            return prime + data
        prime.append(p)
        data = [e for e in data if e % p != 0]
q = int(input())
rl = [map(int, input().split()) for _ in range(q)]

li = get_sieve_of_eratosthenes(10**5+1)
pli = [False] * (10**5+1)

for i in li:
  pli[i] = True

# print(pli)
  
# print(li)
cpli = [0] * (10**5+1)

cnt = 0
for i in range(10**5+1):
  if i % 2 == 1 and pli[i] and pli[(i + 1) // 2]:
    cnt += 1
  cpli[i] = cnt

# print(cpli)
  
for l, r in rl:
  print(cpli[r] - cpli[l-1])