Problem p03476 (python)

Fixed submission:
from sys import stdin
def is_prime(n):
    if n == 1:
        return False
    for i in range(2,int(n**0.5)+1):
        if n % i == 0:
            return False
    return True
prime_list=[i for i in range(2,100000) if is_prime(i)]
oppai=[0]*100000
oppai[1]=0
before=1
for num in prime_list:
    if (num+1)//2 in prime_list:
        oppai[before:num - 2] = [oppai[before]] * (num-1 - before)
        oppai[num-1]=oppai[before]+1
    else:oppai[before:num-1]=[oppai[before]]*(num-before)
    before=num-1
oppai[99991:99999]=[oppai[99990]]*8
N=list(map(int,stdin.readline().strip().split()))[0]
for _ in range(N):
    count = 0
    a,b=list(map(int,stdin.readline().strip().split()))
    if a==b:
        bb = (oppai[b - 1])
        aa = (oppai[a - 2])
        count = bb - aa
        print(count)
    else:
        if a>=2:
            bb = oppai[b - 1]
            aa = oppai[a - 2]
            count = bb - aa
            print(count)
        else:
            bb = oppai[b - 1]
            count = bb
            print(count)

Buggy submission (verdict: Runtime Error):
from sys import stdin
def is_prime(n):
    if n == 1:
        return False
    for i in range(2,int(n**0.5)+1):
        if n % i == 0:
            return False
    return True

prime_list=[i for i in range(1,10001) if is_prime(i)]
oppai=[0]*10005
for i in range(2, 10001):
    if i in prime_list and (i+1)//2 in prime_list:
        oppai[i-1]=oppai[i-2]+1
    else:oppai[i-1]=oppai[i-2]
#print(oppai)
N=list(map(int,stdin.readline().strip().split()))[0]
for _ in range(N):
    count = 0
    a,b=map(int,(input().split()))
    if a==b:
        bb = oppai[b - 1]
        aa = oppai[a - 2]
        count = bb - aa
        print(count)
    else:
        if a>=2:
            bb=oppai[b-1]
            aa=oppai[a-2]
            count = bb - aa
            print(count)
        else:
            bb = oppai[b - 1]
            count = bb
            print(count)

Buggy submission (verdict: Runtime Error):
from sys import stdin
def is_prime(n):
    if n == 1:
        return False
    for i in range(2,int(n**0.5)+1):
        if n % i == 0:
            return False
    return True

prime_list=[i for i in range(1,10001) if is_prime(i)]
oppai=[0]*10005
for i in range(3, 10001):
    if i in prime_list and (i+1)//2 in prime_list:
        oppai[i-1]=oppai[i-2]+1
    else:oppai[i-1]=oppai[i-2]
#print(oppai)
N=list(map(int,stdin.readline().strip().split()))[0]
for _ in range(N):
    count = 0
    a,b=map(int,(input().split()))
    if a==b:
        if a in  prime_list and ((a+1)//2) in  prime_list:
            count+=1
            print(count)
    else:
        if a>=2:
            bb=oppai[b-1]
            aa=oppai[a-2]
            count = bb - aa
            print(count)
        else:
            bb = oppai[b - 1]
            count = bb
            print(count)

Buggy submission (verdict: Runtime Error):
from sys import stdin
def is_prime(n):
    if n == 1:
        return False
    for i in range(2,int(n**0.5)+1):
        if n % i == 0:
            return False
    return True

prime_list=[i for i in range(1,10001) if is_prime(i)]
oppai=[0]*10000
for i in range(3, 10001):
    if i in prime_list and (i+1)/2 in prime_list:
        oppai[i-1]=oppai[i-2]+1
    else:oppai[i-1]=oppai[i-2]
#print(oppai)
N=list(map(int,stdin.readline().strip().split()))[0]
for _ in range(N):
    count = 0
    a,b=map(int,(input().split()))
    if a==b:
        if a in  prime_list and ((a+1)/2) in  prime_list:
            count+=1
    else:
        if a>=2:
            bb=oppai[b-1]
            aa=oppai[a-2]
            count = bb - aa
        else:
            bb = oppai[b - 1]
            count = bb

    print(count)

Buggy submission (verdict: Runtime Error):
from sys import stdin
def is_prime(n):
    if n == 1:
        return False
    for i in range(2,int(n**0.5)+1):
        if n % i == 0:
            return False
    return True

prime_list=[i for i in range(1,10001) if is_prime(i)]
oppai=[0]*10000
for i in range(3, 10000):
    if i in prime_list and (i+1)/2 in prime_list:
        oppai[i-1]=oppai[i-2]+1
    else:oppai[i-1]=oppai[i-2]
#print(oppai)
N=list(map(int,stdin.readline().strip().split()))[0]
for _ in range(N):
    count = 0
    a,b=map(int,(input().split()))
    if a==b:
        if a in  prime_list and ((a+1)/2) in  prime_list:
            count+=1
    else:
        if a>=2:
            bb=oppai[b-1]
            aa=oppai[a-2]
            count = bb - aa
        else:
            bb = oppai[b - 1]
            count = bb

    print(count)

Buggy submission (verdict: Runtime Error):
from sys import stdin
def is_prime(n):
    if n == 1:
        return False
    for i in range(2,int(n**0.5)+1):
        if n % i == 0:
            return False
    return True

prime_list=[i for i in range(1,10001) if is_prime(i)]
oppai=[0]*10000
for i in range(3, 10000):
    if i in prime_list and (i+1)/2 in prime_list:
        oppai[i-1]=oppai[i-2]+1
    else:oppai[i-1]=oppai[i-2]
#print(oppai)
N=list(map(int,stdin.readline().strip().split()))[0]
for _ in range(N):
    count = 0
    a,b=map(int,(input().split()))
    if a==b:
        if a in  prime_list and ((a+1)/2) in  prime_list:
            count+=1
    else:
        bb=oppai[b-1]
        aa=oppai[a-2]
        count=bb-aa
    print(count)