Buggy python submission (verdict: Runtime Error):
# Q = int(input())

Qmax = 100_001
is_prime = [True] *  Qmax
is_prime[0] = False
is_prime[1] = False
for i in range(2, int(Qmax ** 0.5) + 1):
    if is_prime[i]:
        for j in range(i * i, Qmax, i):
            is_prime[j] = False

# 1 ~ 10^5を先に計算する
cnt = 0
res = [0]*(10**5)
for i in range(10**5):
    if is_prime[i] and is_prime[(i+1)//2]:
        cnt += 1
    res[i] = cnt


# 計算
Q = int(input())
for q in range(Q):
    li, ri = map(int, input().split())
    print(res[ri] - res[li - 1])

Fixed submission:
'''
https://atcoder.jp/contests/abc084/tasks/abc084_d
'''
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10000000)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations
    #from itertools import accumulate, product
    from bisect import bisect_left,bisect_right
    import heapq
    from math import floor, ceil
    #from operator import itemgetter

    #inf = 10**17
    #mod = 1000000007

    def primecheck(n):
        p = [True] * (n + 1)
        p[0] = False
        p[1] = False
        for i in range(2, int(n ** 0.5) + 1):
            if p[i]:
                for j in range(i * i, n + 1, i):
                    p[j] = False
        return p
    
    p = primecheck(10**5)
    cnt = 0
    res = [0]*(10**5)
    for i in range(10**5):
        if p[i]==p[(i+1)//2]==1:
            cnt += 1
        res[i] = cnt


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

if __name__ == '__main__':
    main()

Buggy python submission (verdict: Runtime Error):
# Q = int(input())

def primes(n):
    ass = []
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    return is_prime

prime_flag_list = primes(100_001)


# 1 ~ 10^5を先に計算する
list_flag = [False] * (100_001)
for n in range(1, 100_000 + 1, 2):
    if prime_flag_list[n] and prime_flag_list[(n + 1) // 2]:
        list_flag[n] = True

# 計算
Q = int(input())
for q in range(Q):
    li, ri = map(int, input().split())
    x = 0
    for i in range(li, ri+1, 2):
        if list_flag[i]:
            x += 1
    print(x)

Fixed submission:
'''
https://atcoder.jp/contests/abc084/tasks/abc084_d
'''
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10000000)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations
    #from itertools import accumulate, product
    from bisect import bisect_left,bisect_right
    import heapq
    from math import floor, ceil
    #from operator import itemgetter

    #inf = 10**17
    #mod = 1000000007

    def primecheck(n):
        p = [True] * (n + 1)
        p[0] = False
        p[1] = False
        for i in range(2, int(n ** 0.5) + 1):
            if p[i]:
                for j in range(i * i, n + 1, i):
                    p[j] = False
        return p
    
    p = primecheck(10**5)
    cnt = 0
    res = [0]*(10**5)
    for i in range(10**5):
        if p[i]==p[(i+1)//2]==1:
            cnt += 1
        res[i] = cnt


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

if __name__ == '__main__':
    main()