Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
N, P = map(int, input().split())
prime = prime_decomposition(P)
now = -1
count = 0
res = 1
for i in range(len(prime)):
    if now != prime[-i-1]:
        count = 0
        now = prime[-i-1]
    count += 1
    if count == N:
        res *= prime[-i-1]
print(int(res))

Fixed submission:
N, P = map(int, input().split())
def prime_decomposition(n):
  i = 2
  table = []
  while i * i <= n:
    while n % i == 0:
      n /= i
      table.append(i)
    i += 1
  if n > 1:
    table.append(n)
  return table
prime = prime_decomposition(P)
now = -1
count = 0
res = 1
for i in range(len(prime)):
    if now != prime[-i-1]:
        count = 0
        now = prime[-i-1]
    count += 1
    if count == N:
        res *= prime[-i-1]
        count = 0
print(int(res))
Buggy python submission (verdict: Time Limit Exceeded):
S = input()
S = list(S)
flag = True
res = 0
while flag:
    flag = False
    for i in range(len(S) - 1):
        if S[i] == 'B' and S[i+1] == 'W':
            S[i] = 'W'
            S[i+1] = 'B'
            res += 1
            flag = True
print(res)

Fixed submission:
S = input()
res = 0
count = 0
for i in range(len(S)):
    if S[i] == 'B':
        count += 1
    if S[i] == 'W':
        res += count
       
print(res)
Buggy python submission (verdict: Runtime Error):
import itertools

N = int(input())

number = [7, 5, 3]

ans = 0
for i in range(10):
    for conv in itertools.product(number, repeat=i+1):
        
        tmp = 0
        for j in range(len(conv)):
            tmp += conv[j] * 10 ** (len(conv) - j - 1)
            
        
        if ((3 in conv) and (5 in conv) and (7 in conv)) and tmp =< N:
            ans += 1
            
        
print(ans)

Fixed submission:
import itertools

N = int(input())
nums = [3, 5, 7]
res = 0
for i in range(10):
  for balls in itertools.product(nums, repeat=i):
    num = ''
    if 3 in balls and 5 in balls and 7 in balls:
      for j in range(i):
        num += str(balls[j])
      if int(num) > N:
        break
      res += 1

print(res)
Buggy python submission (verdict: Runtime Error):
N = int(input())
l=[int(input()) for i in range(N)]
l.sort()
res = 0
k = 0
o = 0
if N%2 == 0:
    a = l[:int(N/2)]
    a.reverse()
    b = l[int(N/2):]
    b.reverse()
    for i in range(N-1):
        res += b[k] - a[o]
        if i%2 == 0:
            o += 1
        if i%2 == 1:
            k += 1
else:
    a = l[:int(N/2)]
    b = l[int(N/2)+1:]
    b.reverse()
    for i in range(N-2):
        res += b[k] - a[o]
        if i%2 == 0:
            k += 1
        if i%2 == 1:
            o += 1
    res += max(abs(a[-1] - l[int(N/2)]), abs(b[-1] - l[int(N/2)]))
print(res)


Fixed submission:
N = input()
a = N.split()
if len(N) == 2:
    print(N)
else:
    print(N[2]+N[1]+N[0])
Buggy python submission (verdict: Runtime Error):
N = int(input())

if N == 1:
  print("Hello World")
else:
  A, B = map(int, input().split())
  print(A+B)

Fixed submission:
N = int(input())

if N == 1:
  print("Hello World")
else:
  A= int(input())
  B= int(input())
  print(A+B)

Buggy python submission (verdict: Runtime Error):
N = input()
if N == 1:
  print("Hello World")
else:
  A, B = map(int, input().split())
  print(A+B)

Fixed submission:
N = int(input())

if N == 1:
  print("Hello World")
else:
  A= int(input())
  B= int(input())
  print(A+B)
Buggy python submission (verdict: Runtime Error):
N, T = map(int, input().split())
L = [list(map(int, input().split())) for i in range(N)]

res = 10000

for i in range(N):
  if L[1] <= T:
    if res > L[0]:
      res = L[0]
     
if res == 10000:
  res = 'TLE'
print(res)

Fixed submission:
N, T = map(int, input().split())
L = [list(map(int, input().split())) for i in range(N)]

res = 10000

for i in range(N):
  if L[i][1] <= T:
    if res > L[i][0]:
      res = L[i][0]
     
if res == 10000:
  res = 'TLE'
print(res)
Buggy python submission (verdict: Runtime Error):
import collections

N = int(input())
l = list(map(int, input().split()))

a = []
b = []
a_f = 0
b_f = 0
a_s = 0
b_s = 0
for i in range(N):
    if i%2 == 0:
        a.append(l[i])
    else:
        b.append(l[i])
        
c_a = collections.Counter(a)
c_b = collections.Counter(b)

a_f = c_a.most_common()[0]
b_f = c_b.most_common()[0]

if a_f[0] != b_f[0]:
    print(N - a_f[1] - b_f[1])

elif len(set(a)) == 1 and len(set(b)) == 1:
    print(int(N/2))
elif len(set(a)) == 1:
    print(int(N/2 - c_b.most_common()[1][1]))
elif len(set(b)) == 1:
    print(int(N/2 - c_a.most_common()[1][1]))
elif a_f[1] == b_f[1]:
    second_a = c_a.most_common()[1][1]
    second_b = c_b.most_common()[1][1]
    if second_a >= second_b:
        print(int(N - b_f[1] - second_a)
    else:
        print(int(N - a_f[1] - second_b)
elif a_f[1] > b_f[1]:
    print(int(N - a_f[1] - c_b.most_common()[1][1]))
else:
    print(int(N - b_f[1] - c_a.most_common()[1][1]))

Fixed submission:
N = input()
res = ''
for i in range(len(N)):
    if N[i] == '1':
        res += '9'
    if N[i] == '9':
        res += '1'
        
print(res)
Buggy python submission (verdict: Runtime Error):
import itertools
D, G = map(int, input().split())
P = [list(map(int, input().split())) for i in range(D)]
min_num = 10**8

judge_list = list(itertools.product([0, 1, 2], repeat=D)) #0:中途半端に解く 1:一問も解かない 2: 全部解く

for judge in judge_list:
    score = 0
    num = 0
    flag = 0
    for i in range(1, len(judge) + 1):
        if score >= G:
            break
        
        if judge[-i] == 1:
            pass
        
        if judge[-i] == 2:
            score += P[-i][0] * (D - i + 1) * 100 + P[-i][1]
            num += P[-i][0]
            
        if (judge[-i] == 0) and (flag == 0):
            for j in range(P[-i][0]):
                if score >= G:
                    break
                score += 100 * (D - i + 1)
                num += 1
            flag = 1
                        
    if score >= G:
        min_num = min(num, min_num)

print(min_num)           

Fixed submission:
N = int(input())

if N < 1200:
    print('ABC')
elif 1200<= N < 2800:
    print('ARC')
else:
    print('AGC')
Buggy python submission (verdict: Runtime Error):
N, K = map(int, input().split())
A = list(map(int, input().split()))
m = min(A)
res = 0
for i in range(N):
    min_num = i
    if m == A[i]:
        break
    
        
n1 = min_num 
n2 = N - min_num - 1

if n1 == 0:
    res = math.ceil(n2/2)
elif n2 == 0:
    res = math.ceil(n1/2)
else:
    res = math.ceil(n1/2) + math.ceil(n2/2)
    
print(res)

Fixed submission:
N, K = map(int, input().split())
A = list(map(int, input().split()))

ans = 1
tmp = N - K
ans += tmp // (K - 1)

if tmp%(K - 1) != 0:
    ans += 1

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))

def prime_factor(n):
    i = 2
    table = []
    while i * i <= n:
        while n % i == 0:
            n //= i
            table.append(i)
        i += 1
    if n > 1:
        table.append(n)
    return table


ans = 0
for i in range(N):
    ans += prime_factor(A[i]).count(2)

print(ans)

Fixed submission:
N = int(input())                                       
L = list(map(int, input().split()))
res = 0
for i in range(N):
    for j in range(30):
        if L[i]%(2**(30-j)) == 0:
            res += 30-j
            break
print(res)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
minmum = 10**5
def digitSum(n):
    s = str(n)
    array = list(map(int, list(s)))
    return sum(array)

for i in range(1, N):
    for j in range(1, N):
        if i + j == N:
            min_sum = digitSum(i) + digitSum(j)
            if min_sum < minmum:
                minmum = min_sum

print(minmum)

Fixed submission:
N = int(input())
minmum = 10**5
def digitSum(n):
    s = str(n)
    array = list(map(int, list(s)))
    return sum(array)

for i in range(1, N):
    j = N - i
    min_sum = digitSum(i) + digitSum(j)
    if min_sum < minmum:
        minmum = min_sum

print(minmum)
Buggy python submission (verdict: Runtime Error):
N = int(input())
S = input()
min_num = 10**6


for i in range(0, N):
    num = 0
    num = sum(x == 'W' for x in S[:i]) + sum(x == 'E' for x in S[i+1:])    
    if num < min_num:
        min_num = num
        
print(min_num)

Fixed submission:
A, B = map(int, input().split())
print(max(A+B, A-B, A*B))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = input()
min_num = 10**6
west_num = [0]
east_num = [0]

for i in range(0, N): #累積和を求める.
    if S[i] == 'W':
        west_num.append(1 + max(west_num))
        east_num.append(max(east_num))
    else:
        west_num.append(max(west_num))
        east_num.append(1 + max(east_num))

for i in range(0, N):
    num = 0
    num = west_num[i] + east_num[-1] - east_num[i]
    if num < min_num:
        min_num = num
        
print(min_num)

Fixed submission:
N = int(input())
S = input()
min_num = 10**7
west_num = [0]
east_num = [0]
w_max = 0
e_max = 0
for i in range(0, N): #累積和を求める.
    if S[i] == 'W':
        w_max += 1
    else:
        e_max += 1
        
    west_num.append(w_max)
    east_num.append(e_max)

for i in range(0, N):
    num = west_num[i] + east_num[-1] - east_num[i+1]
    if num < min_num:
        min_num = num
        
print(min_num)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = input()
min_num = 10**6

for i in range(0, N):
    num = 0
    num = sum(x == 'W' for x in S[:i]) + sum(x == 'E' for x in S[i+1:])    
    if num < min_num:
        min_num = num
        
print(min_num)

Fixed submission:
N = int(input())
S = input()
min_num = 10**7
west_num = [0]
east_num = [0]
w_max = 0
e_max = 0
for i in range(0, N): #累積和を求める.
    if S[i] == 'W':
        w_max += 1
    else:
        e_max += 1
        
    west_num.append(w_max)
    east_num.append(e_max)

for i in range(0, N):
    num = west_num[i] + east_num[-1] - east_num[i+1]
    if num < min_num:
        min_num = num
        
print(min_num)
Buggy python submission (verdict: Runtime Error):
X = int(input())
max1 = 0
max2 = 0

for b in range(1, X+1):
    for q in range(2, X+1):
        if b**q >= X:
            break
        max1 = b**q
        
    if max1 > max2:
        max2 = max1
        
print(max2)

Fixed submission:
a, b, c, d = map(int, input().split())

if (abs(a-c) <= d) or (abs(a-b) <= d and abs(c-b) <= d):
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Runtime Error):
l = list(map(int, input().split()))
K = int(input())

l.sort()
for i in range(K):
    l[0] = 2*l[0]
    
print(l[0] + l[1] + l[2])

Fixed submission:
a, b = map(int, input().split())
if a <= b:
    print(a)
else:
    print(a-1)
Buggy python submission (verdict: Runtime Error):
N, M, X = map(int, input().split())
arr = input().split()
list_fee = []

for i in range(N):
    if int(arr[0]) == i:
        list_fee.append(1)
        arr.pop(0)
    else:
        list_fee.append(0)
    
a = list_fee[:X].count(1)
b = list_fee[X:].count(1)

print(min(a, b))

Fixed submission:
N, M, X = map(int, input().split())
arr = input().split()
list_fee = []

for i in range(N):
    if arr == []:
        break
    if int(arr[0]) == i+1:
        list_fee.append(1)
        arr.pop(0)
    else:
        list_fee.append(0)
    
a = list_fee[:X].count(1)
b = list_fee[X:].count(1)

print(min(a, b))
Buggy python submission (verdict: Runtime Error):
N = int(input())
arr = input().split()
arr = arr.sort()

for i in range(N):
    if i < N/2:
        print(arr[int(N/2)])
    else:
        print(arr[int(N/2)-1])

Fixed submission:
N = int(input())
arr = list(map(int, input().split()))
X = arr.copy()
arr.sort()

for i in range(N):
    if X[i] < arr[int(N/2)]:
        print(arr[int(N/2)])
    else:
        print(arr[int(N/2)-1])
Buggy python submission (verdict: Runtime Error):
A, B, C, D = map(int, input().split())

print(min(A, B) + min(C, D))

Fixed submission:
S = input()
result = 'No'

if 'a' in S:
    if 'b' in S:
        if 'c' in S:
            result = 'Yes'

print(result)
Buggy python submission (verdict: Runtime Error):
A, B, K = map(int, input().split())

for i in range(A, min(A+K, B)):
    print(i)

for j in range(max(i+1, B-K+1), B+1): 
    print(j)

Fixed submission:
A, B, K = map(int, input().split())

if A+K > B:
    for i in range(A, B+1):
        print(i)

else:
    for i in range(A, A+K):
        print(i)
    
    for j in range(max(i, B-K), B):
        print(j+1)

Buggy python submission (verdict: Runtime Error):
A, B, K = map(int, input().split())

for i in range(A, min(A+K, B)):
    print(i)

for j in range(max(A, B-K+1), B+1): 
    if j <= i:
        pass
    else:
        print(j)

Fixed submission:
A, B, K = map(int, input().split())

if A+K > B:
    for i in range(A, B+1):
        print(i)

else:
    for i in range(A, A+K):
        print(i)
    
    for j in range(max(i, B-K), B):
        print(j+1)
Buggy python submission (verdict: Runtime Error):
N = list(map(int, input().split()))
N.sort()

for i in range(50):
    N[0] += 2
    if N[0] == N[1]:
        result = (i + 1) + (N[2] - N[1])
        break
        
    elif N[0] + 1 == N[1]:
        result = (i + 1) + (N[2] - N[1]) + 2

print(result)
    

Fixed submission:
N = list(map(int, input().split()))
N.sort()

if (N[1] - N[0])%2 == 0:
    result = int((N[1] - N[0])/2) + N[2] - N[1]

else:
    result = int((N[1] - N[0])/2) + N[2] - N[1] + 2 

print(result)
Buggy python submission (verdict: Runtime Error):
A, B, C, D = map(int, input().split())

print(min(A, B) + min(C, D))

Fixed submission:
A = int(input())
B = int(input())
C = int(input())
D = int(input())

print(min(A, B) + min(C, D))
Buggy python submission (verdict: Runtime Error):
N = int(input())
s = [input() for i in range(N)]

M = int(input())
t = [input() for i in range(M)]

count_max = 0
for i in range(N):
    count = s.count(s[i]) - t.count(s[i])
    if count > count_max:
         count_max = count
            
print(count_max)
N = int(input())
s = [input() for i in range(N)]

M = int(input())
t = [input() for i in range(M)]

count_max = 0
for i in range(N):
    count = s.count(s[i]) - t.count(s[i])
    if count > count_max:
         count_max = count
            
print(count_max)

Fixed submission:
N = int(input())
s = [input() for i in range(N)]

M = int(input())
t = [input() for i in range(M)]

count_max = 0
for i in range(N):
    count = s.count(s[i]) - t.count(s[i])
    if count > count_max:
         count_max = count
            
print(count_max)
Buggy python submission (verdict: Runtime Error):
N, K = map(int, input().split())

res = 0
    
for b in range(1, N + 1):
    res += max(b - K, 0) * (N  // b)
    res += max(N % b - K + 1, 0)
 
if k == 0:
    res -= 10
print(res)

Fixed submission:
N, K = map(int, input().split())

res = 0
    
for b in range(1, N + 1):
    res += max(b - K, 0) * (N  // b)
    res += max(N % b - K + 1, 0)
 
if K == 0:
    res -= N
print(res)
Buggy python submission (verdict: Runtime Error):
C = [list(map(int, input().split())) for i in range(3)]

a = [0]
b = []
result = 'Yes'

b.append(C[0][0])
b.append(C[1][0])
b.append(C[2][0])
a.append(C[1][0] - b1)
a.append(C[2][0] - b1)

for i in range(3):
    for j in range(3):
        if C[i][j] != a[i] + b[j]:
            result = 'No'
            
print(result)


Fixed submission:
C = [list(map(int, input().split())) for i in range(3)]

a = [0]
b = []
result = 'Yes'

b.append(C[0][0])
b.append(C[0][1])
b.append(C[0][2])
a.append(C[1][0] - b[0])
a.append(C[2][0] - b[0])

for i in range(3):
    for j in range(3):
        if C[i][j] != a[i] + b[j]:
            result = 'No'
            
print(result)

Buggy python submission (verdict: Runtime Error):
C1 = [list(map(int, input().split())) for i in range(3)]

a = []
b = []
result = 'Yes'

a.append(0)
b.append(C[0][0])
b.append(C[1][0])
b.append(C[2][0])
a.append(C[1][0] - b1)
a.append(C[2][0] - b1)

for i in range(3):
    for j in range(3):
        if C[i][j] != a[i] + b[j]:
            result = 'No'
            
print(result)


Fixed submission:
C = [list(map(int, input().split())) for i in range(3)]

a = [0]
b = []
result = 'Yes'

b.append(C[0][0])
b.append(C[0][1])
b.append(C[0][2])
a.append(C[1][0] - b[0])
a.append(C[2][0] - b[0])

for i in range(3):
    for j in range(3):
        if C[i][j] != a[i] + b[j]:
            result = 'No'
            
print(result)
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

a_b = 0
b_a = 0
for i in range(N):
    if A[i] > B[i]:
        a_b += A[i] - B[i]
        
    else
        b_a += (B[i] - A[i]) // 2

if a_b <= b_a
    print('Yes')
else:
    print('No')
        



Fixed submission:
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

a_b = 0
b_a = 0
for i in range(N):
    if A[i] > B[i]:
        a_b += A[i] - B[i]
        
    else:
        b_a += (B[i] - A[i]) // 2

if a_b <= b_a:
    print('Yes')
else:
    print('No')

Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

num = 0
diff = 0
for i in range(N):
    if A[i] != B[i]:
        num += 1
        
    diff += A[i] - B[i]
    
if diff%num == 0 and diff >= 0:
    print('Yes')
else:
    print('No')
        



Fixed submission:
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

a_b = 0
b_a = 0
for i in range(N):
    if A[i] > B[i]:
        a_b += A[i] - B[i]
        
    else:
        b_a += (B[i] - A[i]) // 2

if a_b <= b_a:
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Runtime Error):
X = int(input()))
A = int(input())
B = int(input())

print(X-A-B)

Fixed submission:
X = int(input())
A = int(input())
B = int(input())

n = X - A
res = n - int(n/B)*B

print(res)
Buggy python submission (verdict: Runtime Error):
package main

import "fmt"

func main() {
	var a, b int

	fmt.Scan(&a, &b)

	if (a * b)%2 == 1 {
		fmt.Println("Odd")
	} else {
		fmt.Println("Even")
	}
}

Fixed submission:
a, b = map(int, input().split())

if (a*b)%2 == 0:
    print('Even')

else:
    print('Odd')

Buggy python submission (verdict: Runtime Error):
N = int(input())
arr = [ list(map(int, input().split())) for i in range(N)]
res = 'Yes'

for i in range(N-1):
    x = arr[i+1][1] - arr[i][1]
    y = arr[i+1][2] - arr[i][2]
    t = arr[i+1][0] - arr[i][0]
    
    if x+y <= t:
        if (x+y-t)%2 == 0:
            pass
        else:
            res = 'No'
            break
    else:
        res = 'No'
        break
        
print(res)

Fixed submission:
a, b = map(int, input().split())

if (a*b)%2 == 0:
    print('Even')

else:
    print('Odd')
Buggy python submission (verdict: Runtime Error):
N = int(input())
arr = [ list(map(int, input().split())) for i in range(N)]

for i in range(N-1):
    if (arr[i+1][1] + arr[i+1][2]) - (arr[i][1] + arr[i][2]) < arr[i+1][0] - arr[i][0]:
        if((arr[i+1][1] + arr[i+1][2]) - (arr[i][1] + arr[i][2]) - (arr[i+1][0] + arr[i][0]))%2 == 0:
            res = 'Yes'
        else:
            res = 'No'
            break
    else:
        res = 'No'
        break
        
print(res)

Fixed submission:
N = int(input())
arr = [ list(map(int, input().split())) for i in range(N)]
arr.insert(0, [0, 0, 0])
res = 'Yes'

for i in range(N):
    x = arr[i+1][1] - arr[i][1]
    y = arr[i+1][2] - arr[i][2]
    t = arr[i+1][0] - arr[i][0]
    
    if x+y <= t:
        if (x+y-t)%2 == 0:
            pass
        else:
            res = 'No'
            break
    else:
        res = 'No'
        break
        
print(res)
Buggy python submission (verdict: Runtime Error):
N, H = map(int, input().split())
weapon = [list(map(int, input().split())) for _ in range(N)]

count = 0

max_atack = -1
for i in range(N):
    max_atack = max(max_atack, weapon[i][0]) 


flag = True
for i in range(N):
    if weapon[i][1] >= max_atack:
        count += 1
        H -= weapon[i][1]
        
        if H <= 0:
            flag = False
            break

if flag:
    if H % max_atack == 0:
        count += H // max_atack
    else:
        count += H // max_atack + 1


print(count)

Fixed submission:
S = input()
S = S.replace('2017', '2018')

print(S)

Buggy python submission (verdict: Runtime Error):
N, Y = map(int, input().split())
rx, ry, rz = -1, -1, -1

for x in range(N+1):
    for y in range(N+1-x):
        for z in range(N+1-x-y):
            if 1000*x + 5000*y + 1000*z == Y:
                rx, ry, rz = x, y, z
                break
    
print(rx, ry, rz)

Fixed submission:
S = input()
S = S.replace('2017', '2018')

print(S)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
L = [list(map(int, input().split())) for _ in range(N)]

result = []

def prime_number(n):
    for i in range(2, n+1):
        if i * i > n:
            return True
        if n%i == 0:
            return False
    return n != 1

for i in range(N):
    res = 0
    for j in range(L[i][0], L[i][1]+1):
        if prime_number(j) and prime_number((j+1)//2):
            res += 1
    result.append(res)

for res in result:
    print(res)

Fixed submission:
def sieve(n):
    is_prime = [True for _ in range(n+1)]
    is_prime[0] = False
    is_prime[1] = False
    
    for i in range(2, n+1):
        if is_prime[i]:
            j = 2 * i
            while j <= n:
                is_prime[j] = False
                j += i
    table = [ i for i in range(n+1) if is_prime[i]]
    return table, is_prime

N = int(input())
L = [list(map(int, input().split())) for _ in range(N)]

prime, flag = sieve(10 ** 5)
number = [0 for i in range(10 ** 5+1)]

for i in range(2, 10 ** 5):
    if flag[i] and flag[(i+1)//2]:
        number[i] += 1
        
for i in range(1, 10 ** 5):
    number[i] += number[i-1]
        
result = []
            
for i in range(N):
    res = number[L[i][1]] - number[L[i][0]-1]
    result.append(res)

for res in result:
    print(res)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
L = [list(map(int, input().split())) for _ in range(N)]

result = []

def prime_number(n):
    for i in range(2, n+1):
        if i * i > n:
            return True
        if n%i == 0:
            return False
    return n != 1

for i in range(N):
    res = 0
    for j in range(L[i][0], L[i][1]+1):
        if prime_number(j) and prime_number((j+1)//2):
            res += 1
    result.append(res)

for res in result:
    print(res)

Fixed submission:
def sieve(n):
    is_prime = [True for _ in range(n+1)]
    is_prime[0] = False
    is_prime[1] = False
    
    for i in range(2, n+1):
        if is_prime[i]:
            j = 2 * i
            while j <= n:
                is_prime[j] = False
                j += i
    table = [ i for i in range(n+1) if is_prime[i]]
    return table, is_prime

N = int(input())
L = [list(map(int, input().split())) for _ in range(N)]

prime, flag = sieve(10 ** 5)
number = [0 for i in range(10 ** 5+1)]

for i in range(2, 10 ** 5):
    if flag[i] and flag[(i+1)//2]:
        number[i] += 1
        
for i in range(1, 10 ** 5):
    number[i] += number[i-1]
        
result = []
            
for i in range(N):
    res = number[L[i][1]] - number[L[i][0]-1]
    result.append(res)

for res in result:
    print(res)