Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = map(int, input().split())
num = {i:0 for i in range(N+1)}
ans = 1
mod = 1000000007
for a in A:
    s += str(a)
    if a == 0:
        if a not in num.keys():
            num[a] = 1
            ans *= 3 %mod
        else:
            if 1 not in num.keys():
                ans *= (3 - num[a]) %mod
            num[a] += 1
    else:
        if a not in num.keys():
            num[a] = 1
            ans *= num[a-1] %mod
            num[a-1] -= 1
        else:
            num[a] += 1
            ans *= num[a-1] %mod
            num[a-1] -= 1
    #print(s, num, ans%mod)
print(ans%mod)

Fixed submission:
N = int(input())
A = map(int, input().split())
num = {i:0 for i in range(N+1)}
num[0] = 3
ans = 1
MOD = 1000000007
for a in A:
    ans *= num[a] % MOD
    num[a] -= 1
    num[a+1] += 1
print(ans%MOD)

Buggy python submission (verdict: Runtime Error):
N = int(input())
A = map(int, input().split())
num = {}
ans = 1
mod = 1000000007
for a in A:
    s += str(a)
    if a == 0:
        if a not in num.keys():
            num[a] = 1
            ans *= 3 %mod
        else:
            if 1 not in num.keys():
                ans *= (3 - num[a]) %mod
            num[a] += 1
    else:
        if a not in num.keys():
            num[a] = 1
            ans *= num[a-1] %mod
            num[a-1] -= 1
        else:
            num[a] += 1
            ans *= num[a-1] %mod
            num[a-1] -= 1
    #print(s, num, ans%mod)
print(ans%mod)

Fixed submission:
N = int(input())
A = map(int, input().split())
num = {i:0 for i in range(N+1)}
num[0] = 3
ans = 1
MOD = 1000000007
for a in A:
    ans *= num[a] % MOD
    num[a] -= 1
    num[a+1] += 1
print(ans%MOD)

Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int ,input().split()))
num = {}
ans = 1
mod = 1000000007
s = ''
for a in A:
    s += str(a)
    if a == 0:
        if a not in num.keys():
            num[a] = 1
            ans *= 3 %mod
        else:
            if 1 not in num.keys():
                ans *= (3 - num[a]) %mod
            num[a] += 1
    else:
        if a not in num.keys():
            num[a] = 1
            ans *= num[a-1] %mod
            num[a-1] -= 1
        else:
            num[a] += 1
            ans *= num[a-1] %mod
            num[a-1] -= 1
    #print(s, num, ans%mod)
print(ans%mod)

Fixed submission:
N = int(input())
A = map(int, input().split())
num = {i:0 for i in range(N+1)}
num[0] = 3
ans = 1
MOD = 1000000007
for a in A:
    ans *= num[a] % MOD
    num[a] -= 1
    num[a+1] += 1
print(ans%MOD)
Buggy python submission (verdict: Time Limit Exceeded):
T = list(map(int, input().split()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))
if T[0]* A[0] + T[1] * A[1] == T[0] * B[0] + T[1] * B[1]:
    print('infinity')
else:
    ans = 0
    A_pos = 0
    B_pos = 0
    before_state = -1 # 0:A>B, 1:A < B, -1:A=B
    flag = True
    while flag:
        for i in range(2):
            A_pos += T[i]* A[i]
            B_pos += T[i]* B[i]
            if A_pos > B_pos:
                if before_state == 0:
                    ans += 1
                before_state = 1
                if A_pos - B_pos > T[(i+1)%2] * B[(i+1)%2]:
                    flag = False
                    break
            elif A_pos < B_pos:
                if before_state == 1:
                    ans += 1
                before_state = 0
                if B_pos - A_pos > T[(i+1)%2] * A[(i+1)%2]:
                    flag = False
                    break
            elif A_pos == B_pos:
                ans += 1
                before_state = -1
    print(ans)

Fixed submission:
T = list(map(int, input().split()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))
if T[0]* A[0] + T[1] * A[1] == T[0] * B[0] + T[1] * B[1]:
    print('infinity')
else:
    ans = 0
    A_pos = 0
    B_pos = 0
    before_state = -1 # 0:A>B, 1:A < B, -1:A=B
    flag = True
    diff = abs(T[0]* A[0] + T[1]* A[1] - (T[0]* B[0] + T[1]* B[1]))
    diff_max = max(abs(A[0] - B[0])*T[0],  abs(A[1] - B[1])*T[1])
    max_num = int(diff_max/diff)
    up_num_first = 0
    for i in range(2):
        A_pos += T[i]* A[i]
        B_pos += T[i]* B[i]
        if A_pos > B_pos:
            if before_state == 0:
                up_num_first += 1
            before_state = 1
        elif A_pos < B_pos:
            if before_state == 1:
                up_num_first += 1
            before_state = 0
        elif A_pos == B_pos:
            up_num_first += 1
            before_state = -1
    A_pos_first = A_pos
    B_pos_first = B_pos
            
    up_num_second = 0
    for i in range(2):
        A_pos += T[i]* A[i]
        B_pos += T[i]* B[i]
        if A_pos > B_pos:
            if before_state == 0:
                up_num_second += 1
            before_state = 1
        elif A_pos < B_pos:
            if before_state == 1:
                up_num_second += 1
            before_state = 0
        elif A_pos == B_pos:
            up_num_second += 1
            before_state = -1

    A_pos = A_pos_first * (max_num - 1)
    B_pos = B_pos_first * (max_num - 1)
    up_num_final = 0
    for i in range(2):
        A_pos += T[i]* A[i]
        B_pos += T[i]* B[i]
        if A_pos > B_pos:
            if before_state == 0:
                up_num_final += 1
            before_state = 1
        elif A_pos < B_pos:
            if before_state == 1:
                up_num_final += 1
            before_state = 0
        elif A_pos == B_pos:
            up_num_final += 1
            before_state = -1
    if max_num > 1:
        ans = up_num_first  + (max_num - 2) * up_num_second  + up_num_final
    else:
        ans = up_num_first  + (max_num - 1) * up_num_second
    print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
def main():
    A, B, C, D = map(int, input().split())
    num = 0
    for i in range(A, B+1):
        if i % C != 0 and i % D != 0:
            num +=1
    print(num)

if __name__  == '__main__':
    main()

Fixed submission:
import fractions
def main():
    A, B, C, D = map(int, input().split())
    num = (B - A + 1)  - (get_num(B, C, D) - get_num(A-1, C, D))
    print(num)

def get_num(x, C, D):
    num_C = x // C
    num_D = x // D
    f = fractions.gcd(C, D)
    f2 = C*D//f
    num_CD = x // f2
    return num_C  + num_D - num_CD

if __name__  == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
N = int(input())
L = list(map(int, input()))
L_max = max(L)
if sum(L) > 2*L_max:
  print('Yes')
else:
  print('No')

Fixed submission:
N = int(input())
L = list(map(int, input().split()))
L_max = max(L)
if sum(L) > 2*L_max:
  print('Yes')
else:
  print('No')
Buggy python submission (verdict: Time Limit Exceeded):
N, W = map(int, input().split())
wv = []
for _ in range(N):
    wv.append(list(map(int, input().split())))
dp = [[0]*(W+1) for _ in range(N+1)]
for i in range(N):
    for j in range(W+1):
        if j >= wv[i][0]:
            dp[i+1][j] = max(dp[i][j], dp[i][j-wv[i][0]]+wv[i][1])
        else:
            dp[i+1][j] = dp[i][j]
print(dp[N][W])

Fixed submission:
N, W = map(int, input().split())
wv = []
for _ in range(N):
    wv.append(list(map(int, input().split())))
dp = [[0]*(W+1) for _ in range(N+1)]
for i in range(N):
    for j in range(W+1):
        if j >= wv[i][0]:
            dp[i+1][j] = max(dp[i][j], dp[i][j-wv[i][0]]+wv[i][1])
        else:
            dp[i+1][j] = dp[i][j]
print(dp[N][W])
Buggy python submission (verdict: Runtime Error):
import sys
import os
from operator import itemgetter


N,M= map(int, input().split())
A= list(map(int,input().split()))
B=[0]*M
C=[0]*M
for i in range(M):
    B[i], C[i] = map(int, input().split())
A.sort()
#print(A)

D=[list(x) for x in zip(*sorted(zip(C, B), key=itemgetter(0),reverse=True))]
B=D[1]
C=D[0]
k=0
#print(B)
#print(C)
for i in range(M):#C(i) i=1..M
    for j in range(B[i]):#B(i)の個数分C(i)を入れる j=0...Bi
        if A[k]>=C[i]:
            break
        else:
            A[k]=C[i]
            k=k+1
            continue
        break


Asum=sum(A)
#print(A)
print(Asum)

Fixed submission:
import sys
import os
from operator import itemgetter


N,M= map(int, input().split())
A= list(map(int,input().split()))
B=[0]*M
C=[0]*M
for i in range(M):
    B[i], C[i] = map(int, input().split())
A.sort()
#print(A)

D=[list(x) for x in zip(*sorted(zip(C, B), key=itemgetter(0),reverse=True))]
B=D[1]
C=D[0]
k=0
#print(B)
#print(C)
for i in range(M):#C(i) i=1..M
    for j in range(B[i]):#B(i)の個数分C(i)を入れる j=0...Bi
        if k>N-1:
            break
        if A[k]>=C[i]:
            break
        else:
            A[k]=C[i]
            k=k+1
            continue
        break


Asum=sum(A)
#print(A)
print(Asum)
Buggy python submission (verdict: Runtime Error):
import sys
import os
import math
import fractions
from functools import reduce
from fractions import gcd

def test(x,k,m):
    #print("i=",k)
    tmp=[0]*len(x)
    for j in range(m):
        tmp[j]=x[j]
    #print('a=',x)
    #print('tmp=',tmp)
    del tmp[k]
    #print('tmp=',tmp)
    #print("a==",x)
    XX=gcd(*tmp)
    #print("XX=",XX)
    return XX

def gcd(*numbers):
    return reduce(math.gcd, numbers)

def gcd_list(numbers):
    return reduce(math.gcd, numbers)

n=int(input())
a= list(map(int,input().split()))

yakusu=[0]*len(a)
for i in range(n):
    yakusu[i]=test(a,i,n)

ans=max(yakusu)
print(ans)

Fixed submission:
a,b,t = map(int,input().split())
count=1
sum=0
while a*count < t+0.5:
    sum=sum + b
    count+=1
print(sum)

Buggy python submission (verdict: Runtime Error):
import sys
import os
import math
from functools import reduce
from fractions import gcd

def test(x,k,m):
    #print("i=",k)
    tmp=[0]*len(x)
    for j in range(m):
        tmp[j]=x[j]
    #print('a=',x)
    #print('tmp=',tmp)
    del tmp[k]
    #print('tmp=',tmp)
    #print("a==",x)
    XX=gcd(*tmp)
    #print("XX=",XX)
    return XX

def gcd(*numbers):
    return reduce(math.gcd, numbers)

def gcd_list(numbers):
    return reduce(math.gcd, numbers)

n=int(input())
a= list(map(int,input().split()))

yakusu=[0]*len(a)
for i in range(n):
    yakusu[i]=test(a,i,n)

ans=max(yakusu)
print(ans)

Fixed submission:
a,b,t = map(int,input().split())
count=1
sum=0
while a*count < t+0.5:
    sum=sum + b
    count+=1
print(sum)
Buggy python submission (verdict: Runtime Error):
import sys
import os
import math

f = open('input.txt', 'r')
sys.stdin = f
N=int(input())
p=[0]*5
for i in range(5):
    p[i]=int(input())

pmin=min(p)
g=math.ceil(N/pmin)
#g=int(N/pmin)
print(5+g-1)

Fixed submission:
import sys
import os
#import math

N=int(input())
p=[0]*5
for i in range(5):
    p[i]=int(input())

pmin=min(p)
#g=math.ceil(N/pmin)
g=int(N/pmin)
if (N%pmin)==0:
    print(5+g-1)
else:
    print(5+g)
Buggy python submission (verdict: Time Limit Exceeded):
N, Q = map(int, input().split())
S=input()

for i in range(Q):
    l, r = map(int, input().split())
    S2=S[l-1:r]
    #print(S2)
    S3=S2.split("AC")
    #print(S3)
    print(len(S3)-1)


Fixed submission:
N, Q = map(int, input().split())
S=input()
S1=S.split("AC")
#print(S1)
C=[]
SC=[0]*len(S)
i=0
ac=0
for a in S1:
    #SC[i]=
    #i+=len(a)
    C.append(len(a))

    #SC[i]=ac
    #SC[i+1]=ac+1
    #i+=2
    #ac+=1
    #C.append(2)

for c in C:
    for j in range(i,i+c):
        SC[j]=ac
    i+=c
    try:
        SC[i]=ac
        SC[i+1]=ac+1
    except:
            break
    ac+=1
    i+=2


#print(i,ac)
#print(C)
#print(SC)


for i in range(Q):
    l, r = map(int, input().split())
    x=SC[r-1]-SC[l-1]
    #x=
    print(x)
Buggy python submission (verdict: Time Limit Exceeded):

def main():
    n = int(input())
    *A, = map(int, input().split())
    a = 1
    for i in A:
        a*=i
    if a > 10**18:
        print(-1)
    else :
        print(a)

if __name__ == "__main__":
    main()

Fixed submission:

def main():
    n = int(input())
    *A, = map(int, input().split())
    a = 1
    if 0 in A:
        print(0)
    else :
        for i in A:
            a*=i
            if a > 10**18:
                print(-1)
                break
        else :
            print(a)

if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

if __name__ == "__main__":
    a = int(input())
    a = int(a)
    b = prime_factorize(a)
    c = len(b)
    if c==1:
        if b[0]<=9 and b[0]>=1:
            print('yes')
        else :
            print('no')
    elif c==2:
        if b[0]<=9 and b[0]>=1 and b[1]<=9 and b[1]>=1:
            print('yes')
        else :
            print('no')
    else :
        while len(b) > 2:
            b1 = b.pop(0)
            b2 = b.pop(0)
            b.append(b1*b2)
        if b[0]<=9 and b[0]>=1 and b[1]<=9 and b[1]>=1:
            print('yes')
        else :
            print('no')

Fixed submission:
if __name__ == "__main__":
    a = int(input())
    a = int(a)
    flag=False
    for i in range(1, 10):
        for j in range(1, 10):
            if a == i*j:
                flag=True
                break
        if flag:
            break
            
    if flag==False :
        print('No')
    else :
        print('Yes')

Buggy python submission (verdict: Runtime Error):
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

if __name__ == "__main__":
    a = int(input())
    a = int(a)
    b = prime_factorize(a)
    print(b)
    c = len(b)
    if c==1:
        if b[0]<=9 and b[0]>=1:
            print('yes')
        else :
            print('no')
    elif c==2:
        if b[0]<=9 and b[0]>=1 and b[1]<=9 and b[1]>=1:
            print('yes')
        else :
            print('no')
    else :
        while len(b) > 2:
            b1 = b.pop(0)
            b2 = b.pop(0)
            b.append(b1*b2)
        print(b)
        if b[0]<=9 and b[0]>=1 and b[1]<=9 and b[1]>=1:
            print('yes')
        else :
            print('no')

Fixed submission:
if __name__ == "__main__":
    a = int(input())
    a = int(a)
    flag=False
    for i in range(1, 10):
        for j in range(1, 10):
            if a == i*j:
                flag=True
                break
        if flag:
            break
            
    if flag==False :
        print('No')
    else :
        print('Yes')
Buggy python submission (verdict: Runtime Error):
if __name__ =='__main__':
    a, b = list(map(int,input().split()))
    if b = 1:
        print(0)
    else :
        c = 1
        d = a
        while True:
            if d >= b:
                print(c)
                break
            else :
                d += a-1
                c+=1

Fixed submission:
if __name__ =='__main__':
    a, b = list(map(int,input().split()))
    if b == 1:
        print(0)
    else :
        c = 1
        d = a
        while True:
            if d >= b:
                print(c)
                break
            else :
                d += a-1
                c+=1
Buggy python submission (verdict: Runtime Error):
s=input()


con=False

ans=0
for i in range(3):
  if(s[i]=="R" and con):
    ans+=1
  elif(s[i]=="R" and not(con)):
    ans=1
    con=True
  else:
    con=False
      
print(ans)

Fixed submission:
n=int(input())

print('Yes' if n>=30 else "No")

Buggy python submission (verdict: Runtime Error):
n=int(input())
s=input()

rcount=s.count("R")
num=s[0:rcount]
rnum=num.count("R")



print(rcount-rnum)

Fixed submission:
n=int(input())

print('Yes' if n>=30 else "No")
Buggy python submission (verdict: Time Limit Exceeded):
import math
import sys
import functools
import operator

n = int(input())
a = list(map(int, input().split()))
sumans = functools.reduce(operator.mul, a)

INF = 1000000000000000000
if (sumans > INF):
    print(-1)
else:
    print(sumans)


Fixed submission:
import math
import sys
import functools
import operator

n = int(input())
a = list(map(int, input().split()))


ans = 1
INF = 1000000000000000000

if (0 in a):
    print(0)
    sys.exit()

for i in a:
    ans *= i
    if(ans > INF):
        print(-1)
        sys.exit()

print(ans)

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

n = int(input())
a = list(map(int, input().split()))
sumans = 1
for i in a:
    sumans *= i

INF = 1000000000000000000
if (sumans > INF):
    print(-1)
else:
    print(sumans)

Fixed submission:
import math
import sys
import functools
import operator

n = int(input())
a = list(map(int, input().split()))


ans = 1
INF = 1000000000000000000

if (0 in a):
    print(0)
    sys.exit()

for i in a:
    ans *= i
    if(ans > INF):
        print(-1)
        sys.exit()

print(ans)
Buggy python submission (verdict: Runtime Error):
import sys
import math

n, k = map(int, input().split())

pre=n-math.floor(n/k)*k

while 1:
    if pre <= abs(pre-k):
        print(pre)
        sys.exit()
    pre = abs(pre - k)

Fixed submission:

a, b, c = map(int, input().split())
print(c,a,b)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
import math

n, k = map(int, input().split())

if k == 1:
    print(0)
    sys.exit()

pre=n-math.floor(n/k)*k

pre=n
while 1:
    if pre < abs(pre-k):
        print(pre)
        sys.exit()
    pre = abs(pre - k)

Fixed submission:
import sys
import math

n, k = map(int, input().split())

pre=n-n//k*k

while 1:
    if pre <= abs(pre-k):
        print(pre)
        sys.exit()
    pre = abs(pre - k)

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

n, k = map(int, input().split())

if k == 1:
    print(0)
    sys.exit()


pre=n
while 1:
    if pre < abs(pre-k):
        print(pre)
        sys.exit()
    pre=abs(pre-k)

Fixed submission:
import sys
import math

n, k = map(int, input().split())

pre=n-n//k*k

while 1:
    if pre <= abs(pre-k):
        print(pre)
        sys.exit()
    pre = abs(pre - k)
Buggy python submission (verdict: Runtime Error):

if(h==1)or (w==1):
    print(1)
elif (h*w)%2==0:
    print(int(h*w/2))
else:
    print(int((h*w+1)/2))




Fixed submission:
h,w=map(int,input().split())

if((h==1)or(w==1)):
    print(1)
elif (h*w)%2==0:
    print(int(h*w/2))
else:
    print(int((h*w+1)/2))

Buggy python submission (verdict: Runtime Error):
#include <bits/stdc++.h>
using namespace std;

int main() {
long long h;
long long w;

cin >> h >> w;


if((h*w)%2==0){
    cout<<h*w/2<<endl;
}
else{
    cout<<(h*w+1)/2<<endl;
}
  
}

Fixed submission:
h,w=map(int,input().split())

if((h==1)or(w==1)):
    print(1)
elif (h*w)%2==0:
    print(int(h*w/2))
else:
    print(int((h*w+1)/2))
Buggy python submission (verdict: Runtime Error):
n, x = map(int, input().split())
l = list(map(int, input().split()))

sum = 0
ans = 0

for i in range(n+1):
    if sum + l[ans] > x:
        break
    sum += l[ans]
    ans += 1

print(ans+1)

Fixed submission:
n, x = map(int, input().split())
l = list(map(int, input().split()))

sum = 0
ans = 0

for i in range(n):
    if sum + l[ans] > x:
        break
    sum += l[ans]
    ans += 1

print(ans+1)

Buggy python submission (verdict: Runtime Error):
n, x = map(int, input().split())
l = list(map(int, input().split()))

sum = 0
ans = 0

for i in range(n+1):
    if sum + l[ans] > x:
        break
    sum += l[ans]
    ans += 1

print(ans+1)

Fixed submission:
n, x = map(int, input().split())
l = list(map(int, input().split()))

sum = 0
ans = 0

for i in range(n):
    if sum + l[ans] > x:
        break
    sum += l[ans]
    ans += 1

print(ans+1)

Buggy python submission (verdict: Runtime Error):
n,x=map(int, input().split())
l =list(map(int,input().split()))

sum = 0
ans = 0

while sum < x or ans<n+1:
    sum+=l[ans]
    ans += 1
    
print(ans)

Fixed submission:
n, x = map(int, input().split())
l = list(map(int, input().split()))

sum = 0
ans = 0

for i in range(n):
    if sum + l[ans] > x:
        break
    sum += l[ans]
    ans += 1

print(ans+1)

Buggy python submission (verdict: Runtime Error):
n,x=map(int, input().split())
l =list(map(int,input().split()))

sum = 0
ans = 0

while sum < x or ans<n:
    sum+=l[ans]
    ans += 1
    
print(ans)

Fixed submission:
n, x = map(int, input().split())
l = list(map(int, input().split()))

sum = 0
ans = 0

for i in range(n):
    if sum + l[ans] > x:
        break
    sum += l[ans]
    ans += 1

print(ans+1)

Buggy python submission (verdict: Runtime Error):
n,x=map(int, input().split())
l =list(map(int,input().split()))

sum = 0
ans = 0

while sum+l[ans] <= x:
    sum+=l[ans]
    ans += 1
    
print(ans+1)

Fixed submission:
n, x = map(int, input().split())
l = list(map(int, input().split()))

sum = 0
ans = 0

for i in range(n):
    if sum + l[ans] > x:
        break
    sum += l[ans]
    ans += 1

print(ans+1)

Buggy python submission (verdict: Runtime Error):
n,x=map(int, input().split())
l =list(map(int,input().split()))

sum = 0
ans = 0

while sum <= x:
    sum+=l[ans]
    ans += 1
    
print(ans)

Fixed submission:
n, x = map(int, input().split())
l = list(map(int, input().split()))

sum = 0
ans = 0

for i in range(n):
    if sum + l[ans] > x:
        break
    sum += l[ans]
    ans += 1

print(ans+1)
Buggy python submission (verdict: Time Limit Exceeded):
K=int(input())
if K%2==0 or K%5==0:
	print("-1")
	exit()
for n in range(1,10**6+1):
	if (7*(10**n-1)//9)%K==0:
		print(n)
		exit()
print("-1")

Fixed submission:
K=int(input())
base=7%K
for i in range(1,K+1):
	if base%K==0:
		print(i)
		exit()
	else:
		base=(base*10+7)%K
print(-1)
Buggy python submission (verdict: Time Limit Exceeded):
def generate_is_prime_sieve(N):
    is_prime = [True]*(N+1)
    is_prime[0] = is_prime[1] = False
    for p in range(2,N+1):
        if is_prime[p]:
            for n in range(2*p,N+1,p):
                is_prime[n] = False
    return is_prime
	
N=generate_is_prime_sieve(10**5+1)
for i in range(int(input())):
	counter=0
	a,b=[int(x) for x in input().split()]
	for i in range(a,b+1):
		if N[i] and N[(i+1)//2]:
			counter+=1
	print(counter)



Fixed submission:
def generate_is_prime_sieve(N):
	is_prime = [True]*(N+1)
	is_prime[0] = is_prime[1] = False
	for p in range(2,N+1):
		if is_prime[p]:
			for n in range(2*p,N+1,p):
				is_prime[n] = False
	dummy=[x for x in is_prime]
	for p in range(2,N+1):
		if is_prime[p] and is_prime[(p+1)//2]:
			dummy[p]=True
		else:
			dummy[p]=False
	return dummy
def partial_sums(N):
	something=generate_is_prime_sieve(N)
	counter=0
	partial_sum=[0]*(N+1)
	for i in range(N+1):
		if something[i]:
			counter+=1
		partial_sum[i]=counter
	return partial_sum	
N=partial_sums(10**5+1)
for i in range(int(input())):
	counter=0
	a,b=[int(x) for x in input().split()]
	print(N[b]-N[a-1])
Buggy python submission (verdict: Runtime Error):
a,b=[int(x) for x in input().split()]
if abs(a-b)<=1:
  	print("Brown"):
else:
  	print("Alice")

Fixed submission:
a,b=[int(x) for x in input().split()]
if abs(a-b)<=1:
  	print("Brown")
else:
  	print("Alice")

Buggy python submission (verdict: Runtime Error):
a,b=[int(x) for x in input().split()]
if abs(a-b)<=1:
  	print("Brown):
else:
    print("Alice")

Fixed submission:
a,b=[int(x) for x in input().split()]
if abs(a-b)<=1:
  	print("Brown")
else:
  	print("Alice")