Buggy python submission (verdict: Runtime Error):
import math

def is_prime(x):
  if x == 1:
    return False
  elif x == 2:
    return True
  else:
    for i in range(3, math.sqrt(x)//1+1):
      if x%i == 0:
        return False
    return True

print(is_prime(3))

Fixed submission:
import math

def is_prime(x):
  if x <= 0 or x%1 != 0:
    return False
  elif x == 1:
    return False
  elif x == 2:
    return True
  elif x%2 == 0:
    return False
  else:
    for i in range(3, int(math.sqrt(x)//1)+1, 2):
      if x%i == 0:
        return False
    return True

S = [0] * (10**5+1)
for i in range(1, 10**5+1):
  if is_prime(i) and is_prime((i+1)/2):
    S[i] += 1
  S[i] += S[i-1]

Q = int(input())
for _ in range(Q):
  l, r = map(int, input().split())
  print(S[r] - S[l-1])

Buggy python submission (verdict: Time Limit Exceeded):
import math

def is_prime(n):
  if n == 1:
    return False
  if n%2 ==0:
    if n == 2:
      return True
    else:
      return False
  for i in range(3, int(math.sqrt(n)//1)+1, 2):
    if n%i == 0:
      return False
  return True

Q = int(input())
ans = []
for _ in range(Q):
  counter = 0
  l, r = map(int, input().split())
  for odd in range(l, r+1, 2):
    if is_prime(odd) and is_prime((odd+1)/2):
      counter += 1
  ans.append(counter)

for item in ans:
  print(item)

Fixed submission:
import math

def is_prime(x):
  if x <= 0 or x%1 != 0:
    return False
  elif x == 1:
    return False
  elif x == 2:
    return True
  elif x%2 == 0:
    return False
  else:
    for i in range(3, int(math.sqrt(x)//1)+1, 2):
      if x%i == 0:
        return False
    return True

S = [0] * (10**5+1)
for i in range(1, 10**5+1):
  if is_prime(i) and is_prime((i+1)/2):
    S[i] += 1
  S[i] += S[i-1]

Q = int(input())
for _ in range(Q):
  l, r = map(int, input().split())
  print(S[r] - S[l-1])

Buggy python submission (verdict: Time Limit Exceeded):
import math

def is_prime(n):
  if n == 1:
    return False
  if n%2 ==0:
    if n == 2:
      return True
    else:
      return False
  for i in range(3, int(math.sqrt(n)//1)+1, 2):
    if n%i == 0:
      return False
  return True

Q = int(input())
ans = []
for _ in range(Q):
  counter = 0
  l, r = map(int, input().split())
  for odd in range(l, r+1, 2):
    if is_prime(odd) and is_prime((odd+1)/2):
      counter += 1
  ans.append(counter)

for item in ans:
  print(item)

Fixed submission:
import math

def is_prime(x):
  if x <= 0 or x%1 != 0:
    return False
  elif x == 1:
    return False
  elif x == 2:
    return True
  elif x%2 == 0:
    return False
  else:
    for i in range(3, int(math.sqrt(x)//1)+1, 2):
      if x%i == 0:
        return False
    return True

S = [0] * (10**5+1)
for i in range(1, 10**5+1):
  if is_prime(i) and is_prime((i+1)/2):
    S[i] += 1
  S[i] += S[i-1]

Q = int(input())
for _ in range(Q):
  l, r = map(int, input().split())
  print(S[r] - S[l-1])

Buggy python submission (verdict: Time Limit Exceeded):
import math

def factorization(n):
  divided = n
  prime_factor = []

  for i in range(2, int(math.sqrt(n)//1)+1):
    while divided%i == 0:
      prime_factor.append(i)
      divided //= i
  if divided != 1:
    prime_factor.append(divided)
  
  return prime_factor

Q = int(input())
ans = []
for _ in range(Q):
  counter = 0
  l, r = map(int, input().split())
  for odd in range(l, r+1, 2):
    if len(factorization(odd)) == 1 and len(factorization((odd+1)/2)) == 1:
      counter += 1
  ans.append(counter)

for item in ans:
  print(item)

Fixed submission:
import math

def is_prime(x):
  if x <= 0 or x%1 != 0:
    return False
  elif x == 1:
    return False
  elif x == 2:
    return True
  elif x%2 == 0:
    return False
  else:
    for i in range(3, int(math.sqrt(x)//1)+1, 2):
      if x%i == 0:
        return False
    return True

S = [0] * (10**5+1)
for i in range(1, 10**5+1):
  if is_prime(i) and is_prime((i+1)/2):
    S[i] += 1
  S[i] += S[i-1]

Q = int(input())
for _ in range(Q):
  l, r = map(int, input().split())
  print(S[r] - S[l-1])