Buggy python submission (verdict: Runtime Error):
Q=int(input())
n=100
is_prime=[1]*(n+10)
is_prime[0]=0
is_prime[1]=0
for i in range(2,n+1):
	for j in range(i*2,n+1,i):
		if is_prime[j]==False:
			continue
		is_prime[j]=0
a=[0]*(n+10)
for j in range(2,n+1):
	if is_prime[j]%2==0:
		continue
	if is_prime[j] and is_prime[int((j+1)/2)]:
		a[j]=1
s=[0]*(n+10)		
for k in range(n):
	s[k+1]=a[k]+s[k]
ans=[]
for _ in range(Q):
	l,r=map(int,input().split())
	ans.append(s[r+1]-s[l])
print(*ans,sep='\n')

Fixed submission:
Q=int(input())
n=100000
is_prime=[1]*(n+10)
is_prime[0]=0
is_prime[1]=0
for i in range(2,n+1):
	for j in range(i*2,n+1,i):
		if is_prime[j]==False:
			continue
		is_prime[j]=0
a=[0]*(n+10)
for j in range(2,n+1):
	if is_prime[j]%2==0:
		continue
	if is_prime[j] and is_prime[int((j+1)/2)]:
		a[j]=1
s=[0]*(n+10)		
for k in range(n):
	s[k+1]=a[k]+s[k]
ans=[]
for _ in range(Q):
	l,r=map(int,input().split())
	ans.append(s[r+1]-s[l])
print(*ans,sep='\n')

Buggy python submission (verdict: Runtime Error):
Q=int(input())
n=100
is_prime=[1]*(n+10)
is_prime[0]=0
is_prime[1]=0
for i in range(2,n+1):
	for j in range(i*2,n+1,i):
		if is_prime[j]==False:
			continue
		is_prime[j]=0
a=[0]*(n+10)
for i in range(2,n+1):
	if is_prime[i]%2==0:
		continue
	if is_prime[i] and is_prime[int((i+1)/2)]:
		a[i]=1
s=[0]*(n+10)		
for i in range(n):
	s[i+1]=a[i]+s[i]
ans=[]
for i in range(Q):
	l,r=map(int,input().split())
	ans.append(s[r+1]-s[l])
print(*ans,sep='\n')

Fixed submission:
Q=int(input())
n=100000
is_prime=[1]*(n+10)
is_prime[0]=0
is_prime[1]=0
for i in range(2,n+1):
	for j in range(i*2,n+1,i):
		if is_prime[j]==False:
			continue
		is_prime[j]=0
a=[0]*(n+10)
for j in range(2,n+1):
	if is_prime[j]%2==0:
		continue
	if is_prime[j] and is_prime[int((j+1)/2)]:
		a[j]=1
s=[0]*(n+10)		
for k in range(n):
	s[k+1]=a[k]+s[k]
ans=[]
for _ in range(Q):
	l,r=map(int,input().split())
	ans.append(s[r+1]-s[l])
print(*ans,sep='\n')

Buggy python submission (verdict: Runtime Error):
Q=int(input())
n=10100
is_prime=[1]*(n+10)
is_prime[0]=0
is_prime[1]=0
for i in range(2,n+1):
	for j in range(i*2,n+1,i):
		if is_prime[j]==False:
			continue
		is_prime[j]=0
a=[0]*(n+10)
for i in range(2,n+1):
	if is_prime[i]%2==0:
		continue
	if is_prime[i] and is_prime[int((i+1)/2)]:
		a[i]=1
s=[0]*(n+10)		
for i in range(n):
	s[i+1]=a[i]+s[i]
ans=[]
for i in range(Q):
	l,r=map(int,input().split())
	ans.append(s[r+1]-s[l])
print(*ans,sep='\n')

Fixed submission:
Q=int(input())
n=100000
is_prime=[1]*(n+10)
is_prime[0]=0
is_prime[1]=0
for i in range(2,n+1):
	for j in range(i*2,n+1,i):
		if is_prime[j]==False:
			continue
		is_prime[j]=0
a=[0]*(n+10)
for j in range(2,n+1):
	if is_prime[j]%2==0:
		continue
	if is_prime[j] and is_prime[int((j+1)/2)]:
		a[j]=1
s=[0]*(n+10)		
for k in range(n):
	s[k+1]=a[k]+s[k]
ans=[]
for _ in range(Q):
	l,r=map(int,input().split())
	ans.append(s[r+1]-s[l])
print(*ans,sep='\n')

Buggy python submission (verdict: Runtime Error):
Q=int(input())
n=10100
is_prime=[1]*(n+10)
is_prime[0]=0
is_prime[1]=0
for i in range(2,n+1):
	for j in range(i*2,n+1,i):
		if is_prime[j]==False:
			continue
		is_prime[j]=0
a=[0]*(n+10)
for i in range(2,n+1):
	if is_prime[i]%2==0:
		continue
	if is_prime[i] and is_prime[int((i+1)/2)]:
		a[i]=1
s=[0]*(n+10)		
for i in range(n):
	s[i+1]=a[i]+s[i]
for i in range(Q):
	l,r=map(int,input().split())
	print(s[r+1]-s[l])

Fixed submission:
Q=int(input())
n=100000
is_prime=[1]*(n+10)
is_prime[0]=0
is_prime[1]=0
for i in range(2,n+1):
	for j in range(i*2,n+1,i):
		if is_prime[j]==False:
			continue
		is_prime[j]=0
a=[0]*(n+10)
for j in range(2,n+1):
	if is_prime[j]%2==0:
		continue
	if is_prime[j] and is_prime[int((j+1)/2)]:
		a[j]=1
s=[0]*(n+10)		
for k in range(n):
	s[k+1]=a[k]+s[k]
ans=[]
for _ in range(Q):
	l,r=map(int,input().split())
	ans.append(s[r+1]-s[l])
print(*ans,sep='\n')

Buggy python submission (verdict: Runtime Error):
Q=int(input())
n=10010
is_prime=[1]*(n+1)
is_prime[0]=0
is_prime[1]=0
for i in range(2,n+1):
	for j in range(i*2,n+1,i):
		if is_prime[j]==False:
			continue
		is_prime[j]=0
a=[0]*(n+1)
for i in range(2,n+1):
	if is_prime[i]%2==0:
		continue
	if is_prime[i] and is_prime[int((i+1)/2)]:
		a[i]=1
s=[0]*(n+1)		
for i in range(n):
	s[i+1]=a[i]+s[i]
for i in range(Q):
	l,r=map(int,input().split())
	print(s[r+1]-s[l])

Fixed submission:
Q=int(input())
n=100000
is_prime=[1]*(n+10)
is_prime[0]=0
is_prime[1]=0
for i in range(2,n+1):
	for j in range(i*2,n+1,i):
		if is_prime[j]==False:
			continue
		is_prime[j]=0
a=[0]*(n+10)
for j in range(2,n+1):
	if is_prime[j]%2==0:
		continue
	if is_prime[j] and is_prime[int((j+1)/2)]:
		a[j]=1
s=[0]*(n+10)		
for k in range(n):
	s[k+1]=a[k]+s[k]
ans=[]
for _ in range(Q):
	l,r=map(int,input().split())
	ans.append(s[r+1]-s[l])
print(*ans,sep='\n')

Buggy python submission (verdict: Runtime Error):
Q=int(input())
n=10010
is_prime=[1]*(n+1)
is_prime[0]=is_prime[1]=0
for i in range(2,n+1):
	for j in range(i*2,n+1,i):
		if is_prime[j]==False:
			continue
		is_prime[j]=0
a=[0]*(n+1)
for i in range(2,n+1):
	if is_prime[i]%2==0:
		continue
	if is_prime[i] and is_prime[int((i+1)/2)]:
		a[i]=1
s=[0]*(n+1)		
for i in range(n):
	s[i+1]=a[i]+s[i]
for i in range(Q):
	l,r=map(int,input().split())
	print(s[r+1]-s[l])

Fixed submission:
Q=int(input())
n=100000
is_prime=[1]*(n+10)
is_prime[0]=0
is_prime[1]=0
for i in range(2,n+1):
	for j in range(i*2,n+1,i):
		if is_prime[j]==False:
			continue
		is_prime[j]=0
a=[0]*(n+10)
for j in range(2,n+1):
	if is_prime[j]%2==0:
		continue
	if is_prime[j] and is_prime[int((j+1)/2)]:
		a[j]=1
s=[0]*(n+10)		
for k in range(n):
	s[k+1]=a[k]+s[k]
ans=[]
for _ in range(Q):
	l,r=map(int,input().split())
	ans.append(s[r+1]-s[l])
print(*ans,sep='\n')

Buggy python submission (verdict: Runtime Error):
Q=int(input())
n=10010
is_prime=[1]*(n+1)
is_prime[0]=is_prime[1]=0
for i in range(2,n+1):
	for j in range(i*2,n+1,i):
		if is_prime[j]==False:
			continue
		is_prime[j]=0
a=[0]*(n+1)
for i in range(n+1):
	if is_prime[i]%2==0:
		continue
	if is_prime[i] and is_prime[int((i+1)/2)]:
		a[i]=1
s=[0]*(n+1)		
for i in range(n):
	s[i+1]=a[i]+s[i]
for i in range(Q):
	l,r=map(int,input().split())
	print(s[r+1]-s[l])

Fixed submission:
Q=int(input())
n=100000
is_prime=[1]*(n+10)
is_prime[0]=0
is_prime[1]=0
for i in range(2,n+1):
	for j in range(i*2,n+1,i):
		if is_prime[j]==False:
			continue
		is_prime[j]=0
a=[0]*(n+10)
for j in range(2,n+1):
	if is_prime[j]%2==0:
		continue
	if is_prime[j] and is_prime[int((j+1)/2)]:
		a[j]=1
s=[0]*(n+10)		
for k in range(n):
	s[k+1]=a[k]+s[k]
ans=[]
for _ in range(Q):
	l,r=map(int,input().split())
	ans.append(s[r+1]-s[l])
print(*ans,sep='\n')

Buggy python submission (verdict: Runtime Error):
Q=int(input())
n=10010
is_prime=[1]*(n+1)
is_prime[0]=is_prime[1]=0
for i in range(2,int(n**0.5)*1):
	for j in range(i*2,n+1,i):
		if is_prime[j]==False:
			continue
		is_prime[j]=0
a=[0]*(n+1)
for i in range(n+1):
	if is_prime[i]%2==0:
		continue
	if is_prime[i] and is_prime[int((i+1)/2)]:
		a[i]=1
s=[0]*(n+1)		
for i in range(n):
	s[i+1]=a[i]+s[i]
for i in range(Q):
	l,r=map(int,input().split())
	print(s[r+1]-s[l])

Fixed submission:
Q=int(input())
n=100000
is_prime=[1]*(n+10)
is_prime[0]=0
is_prime[1]=0
for i in range(2,n+1):
	for j in range(i*2,n+1,i):
		if is_prime[j]==False:
			continue
		is_prime[j]=0
a=[0]*(n+10)
for j in range(2,n+1):
	if is_prime[j]%2==0:
		continue
	if is_prime[j] and is_prime[int((j+1)/2)]:
		a[j]=1
s=[0]*(n+10)		
for k in range(n):
	s[k+1]=a[k]+s[k]
ans=[]
for _ in range(Q):
	l,r=map(int,input().split())
	ans.append(s[r+1]-s[l])
print(*ans,sep='\n')

Buggy python submission (verdict: Runtime Error):
Q=int(input())
n=10010
is_prime=[1]*(n+1)
is_prime[0]=is_prime[1]=0
for i in range(2,int(n**0.5)*1):
	for j in range(i*2,n+1,i):
		if is_prime[j]==False:
			continue
		is_prime[j]=0
a=[0]*(n+1)
for i in range(n+1):
	if is_prime[i]%2==0:
		continue
	if is_prime[i] and is_prime[int((i+1)/2)]:
		a[i]=1
s=[0]*(n+1)		
for i in range(n):
	s[i+1]=a[i]+s[i]
for i in range(Q):
	l,r=map(int,input().split())
	print(s[r+1]-s[l])

Fixed submission:
Q=int(input())
n=100000
is_prime=[1]*(n+10)
is_prime[0]=0
is_prime[1]=0
for i in range(2,n+1):
	for j in range(i*2,n+1,i):
		if is_prime[j]==False:
			continue
		is_prime[j]=0
a=[0]*(n+10)
for j in range(2,n+1):
	if is_prime[j]%2==0:
		continue
	if is_prime[j] and is_prime[int((j+1)/2)]:
		a[j]=1
s=[0]*(n+10)		
for k in range(n):
	s[k+1]=a[k]+s[k]
ans=[]
for _ in range(Q):
	l,r=map(int,input().split())
	ans.append(s[r+1]-s[l])
print(*ans,sep='\n')