message stringlengths 2 57.2k | message_type stringclasses 2 values | message_id int64 0 1 | conversation_id int64 61 108k | cluster float64 22 22 | __index_level_0__ int64 122 217k |
|---|---|---|---|---|---|
Provide a correct Python 3 solution for this coding contest problem.
You are given four integers A, B, C, and D. Find the number of integers between A and B (inclusive) that can be evenly divided by neither C nor D.
Constraints
* 1\leq A\leq B\leq 10^{18}
* 1\leq C,D\leq 10^9
* All values in input are integers.
Input
Input is given from Standard Input in the following format:
A B C D
Output
Print the number of integers between A and B (inclusive) that can be evenly divided by neither C nor D.
Examples
Input
4 9 2 3
Output
2
Input
10 40 6 8
Output
23
Input
314159265358979323 846264338327950288 419716939 937510582
Output
532105071133627368 | instruction | 0 | 82,397 | 22 | 164,794 |
"Correct Solution:
```
from fractions import gcd
a,b,c,d = map(int,input().split())
k = c*d//gcd(c,d)
def f(x):
return x - x//c - x//d + x//k
print(f(b)-f(a-1))
``` | output | 1 | 82,397 | 22 | 164,795 |
Provide a correct Python 3 solution for this coding contest problem.
You are given four integers A, B, C, and D. Find the number of integers between A and B (inclusive) that can be evenly divided by neither C nor D.
Constraints
* 1\leq A\leq B\leq 10^{18}
* 1\leq C,D\leq 10^9
* All values in input are integers.
Input
Input is given from Standard Input in the following format:
A B C D
Output
Print the number of integers between A and B (inclusive) that can be evenly divided by neither C nor D.
Examples
Input
4 9 2 3
Output
2
Input
10 40 6 8
Output
23
Input
314159265358979323 846264338327950288 419716939 937510582
Output
532105071133627368 | instruction | 0 | 82,398 | 22 | 164,796 |
"Correct Solution:
```
A,B,C,D = map(int, input().split())
from fractions import gcd
cd = C*D//gcd(D,C)
f = lambda x: B//x - ((A-1)//x)
print(B - A + 1 - (f(C) + f(D) - f(cd)))
``` | output | 1 | 82,398 | 22 | 164,797 |
Provide a correct Python 3 solution for this coding contest problem.
You are given four integers A, B, C, and D. Find the number of integers between A and B (inclusive) that can be evenly divided by neither C nor D.
Constraints
* 1\leq A\leq B\leq 10^{18}
* 1\leq C,D\leq 10^9
* All values in input are integers.
Input
Input is given from Standard Input in the following format:
A B C D
Output
Print the number of integers between A and B (inclusive) that can be evenly divided by neither C nor D.
Examples
Input
4 9 2 3
Output
2
Input
10 40 6 8
Output
23
Input
314159265358979323 846264338327950288 419716939 937510582
Output
532105071133627368 | instruction | 0 | 82,399 | 22 | 164,798 |
"Correct Solution:
```
a,b,c,d=map(int,input().split())
a-=1
from fractions import*
bb=b-b//c-b//d+b//(c*d//gcd(c,d))
aa=a-a//c-a//d+a//(c*d//gcd(c,d))
print(bb-aa)
``` | output | 1 | 82,399 | 22 | 164,799 |
Provide a correct Python 3 solution for this coding contest problem.
You are given four integers A, B, C, and D. Find the number of integers between A and B (inclusive) that can be evenly divided by neither C nor D.
Constraints
* 1\leq A\leq B\leq 10^{18}
* 1\leq C,D\leq 10^9
* All values in input are integers.
Input
Input is given from Standard Input in the following format:
A B C D
Output
Print the number of integers between A and B (inclusive) that can be evenly divided by neither C nor D.
Examples
Input
4 9 2 3
Output
2
Input
10 40 6 8
Output
23
Input
314159265358979323 846264338327950288 419716939 937510582
Output
532105071133627368 | instruction | 0 | 82,400 | 22 | 164,800 |
"Correct Solution:
```
import fractions
A, B, C, D = map(int, input().split())
E = C*D//fractions.gcd(C, D)
X = B//C - (A-1)//C
Y = B//D - (A-1)//D
Z = B//E - (A-1)//E
print(B-A+1-X-Y+Z)
``` | output | 1 | 82,400 | 22 | 164,801 |
Provide a correct Python 3 solution for this coding contest problem.
You are given four integers A, B, C, and D. Find the number of integers between A and B (inclusive) that can be evenly divided by neither C nor D.
Constraints
* 1\leq A\leq B\leq 10^{18}
* 1\leq C,D\leq 10^9
* All values in input are integers.
Input
Input is given from Standard Input in the following format:
A B C D
Output
Print the number of integers between A and B (inclusive) that can be evenly divided by neither C nor D.
Examples
Input
4 9 2 3
Output
2
Input
10 40 6 8
Output
23
Input
314159265358979323 846264338327950288 419716939 937510582
Output
532105071133627368 | instruction | 0 | 82,401 | 22 | 164,802 |
"Correct Solution:
```
import math
a,b,c,d=map(int,input().split())
mc = b//c-(a-1)//c
md = b//d-(a-1)//d
cd = (c*d)//math.gcd(c,d)
mcd = b//cd - (a-1)//cd
print(b-a+1 - mc-md+mcd)
``` | output | 1 | 82,401 | 22 | 164,803 |
Provide a correct Python 3 solution for this coding contest problem.
You are given four integers A, B, C, and D. Find the number of integers between A and B (inclusive) that can be evenly divided by neither C nor D.
Constraints
* 1\leq A\leq B\leq 10^{18}
* 1\leq C,D\leq 10^9
* All values in input are integers.
Input
Input is given from Standard Input in the following format:
A B C D
Output
Print the number of integers between A and B (inclusive) that can be evenly divided by neither C nor D.
Examples
Input
4 9 2 3
Output
2
Input
10 40 6 8
Output
23
Input
314159265358979323 846264338327950288 419716939 937510582
Output
532105071133627368 | instruction | 0 | 82,402 | 22 | 164,804 |
"Correct Solution:
```
import fractions as f
a,b,c,d=map(int,input().split())
a-=1
print(b-a-b//c+a//c-b//d+a//d+b//c*f.gcd(c,d)//d-a//c*f.gcd(c,d)//d)
``` | output | 1 | 82,402 | 22 | 164,805 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given four integers A, B, C, and D. Find the number of integers between A and B (inclusive) that can be evenly divided by neither C nor D.
Constraints
* 1\leq A\leq B\leq 10^{18}
* 1\leq C,D\leq 10^9
* All values in input are integers.
Input
Input is given from Standard Input in the following format:
A B C D
Output
Print the number of integers between A and B (inclusive) that can be evenly divided by neither C nor D.
Examples
Input
4 9 2 3
Output
2
Input
10 40 6 8
Output
23
Input
314159265358979323 846264338327950288 419716939 937510582
Output
532105071133627368
Submitted Solution:
```
from fractions import gcd
a,b,c,d=map(int,input().split())
l=c*d//gcd(c,d)
print(b-a+1-b//c+(a-1)//c-b//d+(a-1)//d+b//l-(a-1)//l)
``` | instruction | 0 | 82,403 | 22 | 164,806 |
Yes | output | 1 | 82,403 | 22 | 164,807 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given four integers A, B, C, and D. Find the number of integers between A and B (inclusive) that can be evenly divided by neither C nor D.
Constraints
* 1\leq A\leq B\leq 10^{18}
* 1\leq C,D\leq 10^9
* All values in input are integers.
Input
Input is given from Standard Input in the following format:
A B C D
Output
Print the number of integers between A and B (inclusive) that can be evenly divided by neither C nor D.
Examples
Input
4 9 2 3
Output
2
Input
10 40 6 8
Output
23
Input
314159265358979323 846264338327950288 419716939 937510582
Output
532105071133627368
Submitted Solution:
```
import fractions
a,b,c,d=map(int, input().split())
cdlcm= c*d//fractions.gcd(c,d)
a-=1
tc = b//c-a//c
td = b//d-a//d
tlcm = b//cdlcm-a//cdlcm
print(b-a-tc-td+tlcm)
``` | instruction | 0 | 82,404 | 22 | 164,808 |
Yes | output | 1 | 82,404 | 22 | 164,809 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given four integers A, B, C, and D. Find the number of integers between A and B (inclusive) that can be evenly divided by neither C nor D.
Constraints
* 1\leq A\leq B\leq 10^{18}
* 1\leq C,D\leq 10^9
* All values in input are integers.
Input
Input is given from Standard Input in the following format:
A B C D
Output
Print the number of integers between A and B (inclusive) that can be evenly divided by neither C nor D.
Examples
Input
4 9 2 3
Output
2
Input
10 40 6 8
Output
23
Input
314159265358979323 846264338327950288 419716939 937510582
Output
532105071133627368
Submitted Solution:
```
from fractions import gcd
a,b,c,d=map(int,input().split())
cd=c*d//gcd(c,d)
ans=b-a+1-(b//c+b//d-b//cd-(a-1)//c-(a-1)//d+(a-1)//cd)
print(int(ans))
``` | instruction | 0 | 82,405 | 22 | 164,810 |
Yes | output | 1 | 82,405 | 22 | 164,811 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given four integers A, B, C, and D. Find the number of integers between A and B (inclusive) that can be evenly divided by neither C nor D.
Constraints
* 1\leq A\leq B\leq 10^{18}
* 1\leq C,D\leq 10^9
* All values in input are integers.
Input
Input is given from Standard Input in the following format:
A B C D
Output
Print the number of integers between A and B (inclusive) that can be evenly divided by neither C nor D.
Examples
Input
4 9 2 3
Output
2
Input
10 40 6 8
Output
23
Input
314159265358979323 846264338327950288 419716939 937510582
Output
532105071133627368
Submitted Solution:
```
from fractions import gcd
A, B, C, D = map(int, input().split())
E = C*D//gcd(C, D)
X = B - B//C - B//D + B//E
Y = A-1 - (A-1)//C - (A-1)//D + (A-1)//E
print(X-Y)
``` | instruction | 0 | 82,406 | 22 | 164,812 |
Yes | output | 1 | 82,406 | 22 | 164,813 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given four integers A, B, C, and D. Find the number of integers between A and B (inclusive) that can be evenly divided by neither C nor D.
Constraints
* 1\leq A\leq B\leq 10^{18}
* 1\leq C,D\leq 10^9
* All values in input are integers.
Input
Input is given from Standard Input in the following format:
A B C D
Output
Print the number of integers between A and B (inclusive) that can be evenly divided by neither C nor D.
Examples
Input
4 9 2 3
Output
2
Input
10 40 6 8
Output
23
Input
314159265358979323 846264338327950288 419716939 937510582
Output
532105071133627368
Submitted Solution:
```
from fractions import gcd
a, b, c, d = map(int, input().split())
cd_gcd = gcd(c, d)
cd_lcm = c*d // cd_gcd
b_div_d = b // d
a_div_d = a // d
if a % d == 0:
b_div_d += 1
b_div_c = b // c
a_div_c = a // c
if a % c == 0:
b_div_c += 1
b_div_c_d = b // cd_lcm
a_div_c_d = a // cd_lcm
hoshugo_num = b_div_d - a_div_d + b_div_c - a_div_c - (b_div_c_d - a_div_c_d)
print(int(b - a + 1 - hoshugo_num))
``` | instruction | 0 | 82,408 | 22 | 164,816 |
No | output | 1 | 82,408 | 22 | 164,817 |
Provide a correct Python 3 solution for this coding contest problem.
The number 105 is quite special - it is odd but still it has eight divisors. Now, your task is this: how many odd numbers with exactly eight positive divisors are there between 1 and N (inclusive)?
Constraints
* N is an integer between 1 and 200 (inclusive).
Input
Input is given from Standard Input in the following format:
N
Output
Print the count.
Examples
Input
105
Output
1
Input
7
Output
0 | instruction | 0 | 82,427 | 22 | 164,854 |
"Correct Solution:
```
n = int(input())
match = [105, 135, 165, 189, 195]
ans = 0
for i in match:
if n >= i:
ans += 1
print(ans)
``` | output | 1 | 82,427 | 22 | 164,855 |
Provide a correct Python 3 solution for this coding contest problem.
The number 105 is quite special - it is odd but still it has eight divisors. Now, your task is this: how many odd numbers with exactly eight positive divisors are there between 1 and N (inclusive)?
Constraints
* N is an integer between 1 and 200 (inclusive).
Input
Input is given from Standard Input in the following format:
N
Output
Print the count.
Examples
Input
105
Output
1
Input
7
Output
0 | instruction | 0 | 82,428 | 22 | 164,856 |
"Correct Solution:
```
n=int(input())
a=[135,189,105,165,195]
ans=0
for i in a:
if i<=n:
ans+=1
print(ans)
``` | output | 1 | 82,428 | 22 | 164,857 |
Provide a correct Python 3 solution for this coding contest problem.
The number 105 is quite special - it is odd but still it has eight divisors. Now, your task is this: how many odd numbers with exactly eight positive divisors are there between 1 and N (inclusive)?
Constraints
* N is an integer between 1 and 200 (inclusive).
Input
Input is given from Standard Input in the following format:
N
Output
Print the count.
Examples
Input
105
Output
1
Input
7
Output
0 | instruction | 0 | 82,429 | 22 | 164,858 |
"Correct Solution:
```
s=[105, 135, 165, 189, 195]
ans=0;n=int(input())
for f in s:
if n>=f:ans+=1
print(ans)
``` | output | 1 | 82,429 | 22 | 164,859 |
Provide a correct Python 3 solution for this coding contest problem.
The number 105 is quite special - it is odd but still it has eight divisors. Now, your task is this: how many odd numbers with exactly eight positive divisors are there between 1 and N (inclusive)?
Constraints
* N is an integer between 1 and 200 (inclusive).
Input
Input is given from Standard Input in the following format:
N
Output
Print the count.
Examples
Input
105
Output
1
Input
7
Output
0 | instruction | 0 | 82,430 | 22 | 164,860 |
"Correct Solution:
```
print([[i%j for j in range(1,i)].count(0) for i in range(1,int(input())+1,2)].count(7))
``` | output | 1 | 82,430 | 22 | 164,861 |
Provide a correct Python 3 solution for this coding contest problem.
The number 105 is quite special - it is odd but still it has eight divisors. Now, your task is this: how many odd numbers with exactly eight positive divisors are there between 1 and N (inclusive)?
Constraints
* N is an integer between 1 and 200 (inclusive).
Input
Input is given from Standard Input in the following format:
N
Output
Print the count.
Examples
Input
105
Output
1
Input
7
Output
0 | instruction | 0 | 82,431 | 22 | 164,862 |
"Correct Solution:
```
n=int(input())
ans=0
for i in range(1,n+1,2):
s=[i%j for j in range(1,i+1)]
if s.count(0)==8:
ans+=1
print(ans)
``` | output | 1 | 82,431 | 22 | 164,863 |
Provide a correct Python 3 solution for this coding contest problem.
The number 105 is quite special - it is odd but still it has eight divisors. Now, your task is this: how many odd numbers with exactly eight positive divisors are there between 1 and N (inclusive)?
Constraints
* N is an integer between 1 and 200 (inclusive).
Input
Input is given from Standard Input in the following format:
N
Output
Print the count.
Examples
Input
105
Output
1
Input
7
Output
0 | instruction | 0 | 82,432 | 22 | 164,864 |
"Correct Solution:
```
N=int(input())
ans = 0
for i in range(1,N+1,2):
tmp = 0
for j in range(1,i+1):
if i%j == 0:
tmp += 1
if tmp == 8:
ans +=1
print(ans)
``` | output | 1 | 82,432 | 22 | 164,865 |
Provide a correct Python 3 solution for this coding contest problem.
The number 105 is quite special - it is odd but still it has eight divisors. Now, your task is this: how many odd numbers with exactly eight positive divisors are there between 1 and N (inclusive)?
Constraints
* N is an integer between 1 and 200 (inclusive).
Input
Input is given from Standard Input in the following format:
N
Output
Print the count.
Examples
Input
105
Output
1
Input
7
Output
0 | instruction | 0 | 82,433 | 22 | 164,866 |
"Correct Solution:
```
d=[105,3*5*9,3*5*11,3*5*5*5,27*7,15*13]
n=int(input())
ans=0
for i in range(len(d)):
if d[i]<=n:
ans+=1
print(ans)
``` | output | 1 | 82,433 | 22 | 164,867 |
Provide a correct Python 3 solution for this coding contest problem.
The number 105 is quite special - it is odd but still it has eight divisors. Now, your task is this: how many odd numbers with exactly eight positive divisors are there between 1 and N (inclusive)?
Constraints
* N is an integer between 1 and 200 (inclusive).
Input
Input is given from Standard Input in the following format:
N
Output
Print the count.
Examples
Input
105
Output
1
Input
7
Output
0 | instruction | 0 | 82,434 | 22 | 164,868 |
"Correct Solution:
```
n=int(input())
c=0
for i in range(1,n+1,2):
count=0
for j in range(1,i+1):
if i%j==0:
count+=1
if count==8:
c+=1
print(c)
``` | output | 1 | 82,434 | 22 | 164,869 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
The number 105 is quite special - it is odd but still it has eight divisors. Now, your task is this: how many odd numbers with exactly eight positive divisors are there between 1 and N (inclusive)?
Constraints
* N is an integer between 1 and 200 (inclusive).
Input
Input is given from Standard Input in the following format:
N
Output
Print the count.
Examples
Input
105
Output
1
Input
7
Output
0
Submitted Solution:
```
n=int(input())
cnt=0
ans=0
for i in range(0,n,2):
for j in range(0,n,2):
if (i+1)%(j+1)==0:
cnt +=1
if cnt == 8:
ans +=1
cnt=0
print(ans)
``` | instruction | 0 | 82,435 | 22 | 164,870 |
Yes | output | 1 | 82,435 | 22 | 164,871 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
The number 105 is quite special - it is odd but still it has eight divisors. Now, your task is this: how many odd numbers with exactly eight positive divisors are there between 1 and N (inclusive)?
Constraints
* N is an integer between 1 and 200 (inclusive).
Input
Input is given from Standard Input in the following format:
N
Output
Print the count.
Examples
Input
105
Output
1
Input
7
Output
0
Submitted Solution:
```
n=max(int(input())-75,0);c=int(n>113);print(n//30+c)
``` | instruction | 0 | 82,436 | 22 | 164,872 |
Yes | output | 1 | 82,436 | 22 | 164,873 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
The number 105 is quite special - it is odd but still it has eight divisors. Now, your task is this: how many odd numbers with exactly eight positive divisors are there between 1 and N (inclusive)?
Constraints
* N is an integer between 1 and 200 (inclusive).
Input
Input is given from Standard Input in the following format:
N
Output
Print the count.
Examples
Input
105
Output
1
Input
7
Output
0
Submitted Solution:
```
n = int(input())
ans = 0
for i in range(1,n+1,2):
cnt = 0
for j in range(1,i+1):
cnt += (i%j==0)
if cnt==8: ans+=1
print(ans)
``` | instruction | 0 | 82,437 | 22 | 164,874 |
Yes | output | 1 | 82,437 | 22 | 164,875 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
The number 105 is quite special - it is odd but still it has eight divisors. Now, your task is this: how many odd numbers with exactly eight positive divisors are there between 1 and N (inclusive)?
Constraints
* N is an integer between 1 and 200 (inclusive).
Input
Input is given from Standard Input in the following format:
N
Output
Print the count.
Examples
Input
105
Output
1
Input
7
Output
0
Submitted Solution:
```
from bisect import bisect_right
n = int(input())
print(bisect_right([105, 135, 165, 189, 195], n))
``` | instruction | 0 | 82,438 | 22 | 164,876 |
Yes | output | 1 | 82,438 | 22 | 164,877 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
The number 105 is quite special - it is odd but still it has eight divisors. Now, your task is this: how many odd numbers with exactly eight positive divisors are there between 1 and N (inclusive)?
Constraints
* N is an integer between 1 and 200 (inclusive).
Input
Input is given from Standard Input in the following format:
N
Output
Print the count.
Examples
Input
105
Output
1
Input
7
Output
0
Submitted Solution:
```
a = int(input())
if a<105:
print(0)
elif 105<= a < 135:
print(1)
elif 135<= a < 165:
print(2)
elif 165<= a < 188:
print(3)
elif 189<= a < 195:
print(4)
else:
print(5)
``` | instruction | 0 | 82,439 | 22 | 164,878 |
No | output | 1 | 82,439 | 22 | 164,879 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
The number 105 is quite special - it is odd but still it has eight divisors. Now, your task is this: how many odd numbers with exactly eight positive divisors are there between 1 and N (inclusive)?
Constraints
* N is an integer between 1 and 200 (inclusive).
Input
Input is given from Standard Input in the following format:
N
Output
Print the count.
Examples
Input
105
Output
1
Input
7
Output
0
Submitted Solution:
```
n = int(input())
ans = 0
for i in range(1, n+1):
cnt = 0
if i%2 == 1:
for j in range(1, i+1):
if i%j == 0:
cnt += 1
if cnt == 8:
print(i)
ans += 1
print(ans)
``` | instruction | 0 | 82,440 | 22 | 164,880 |
No | output | 1 | 82,440 | 22 | 164,881 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
The number 105 is quite special - it is odd but still it has eight divisors. Now, your task is this: how many odd numbers with exactly eight positive divisors are there between 1 and N (inclusive)?
Constraints
* N is an integer between 1 and 200 (inclusive).
Input
Input is given from Standard Input in the following format:
N
Output
Print the count.
Examples
Input
105
Output
1
Input
7
Output
0
Submitted Solution:
```
N = int(input())
if N >= 195:
print("3")
elif N >= 165:
print("2")
elif N >= 105:
print("1")
else:
print("0")
``` | instruction | 0 | 82,441 | 22 | 164,882 |
No | output | 1 | 82,441 | 22 | 164,883 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
The number 105 is quite special - it is odd but still it has eight divisors. Now, your task is this: how many odd numbers with exactly eight positive divisors are there between 1 and N (inclusive)?
Constraints
* N is an integer between 1 and 200 (inclusive).
Input
Input is given from Standard Input in the following format:
N
Output
Print the count.
Examples
Input
105
Output
1
Input
7
Output
0
Submitted Solution:
```
N=int(input())
count=0
answer=0
for i in range(N):
for j in range(i+1):
if (i+1)%(j+1)==0:
count=count+1
if count==8:
answer=answer+1
print(answer)
``` | instruction | 0 | 82,442 | 22 | 164,884 |
No | output | 1 | 82,442 | 22 | 164,885 |
Provide a correct Python 3 solution for this coding contest problem.
Prime numbers are widely applied for cryptographic and communication technology. A twin prime is a prime number that differs from another prime number by 2. For example, (5, 7) and (11, 13) are twin prime pairs.
In this problem, we call the greater number of a twin prime "size of the twin prime."
Your task is to create a program which reads an integer n and prints a twin prime which has the maximum size among twin primes less than or equals to n
You may assume that 5 ≤ n ≤ 10000.
Input
The input is a sequence of datasets. The end of the input is indicated by a line containing one zero. Each dataset is formatted as follows:
n (integer)
Output
For each dataset, print the twin prime p and q (p < q). p and q should be separated by a single space.
Example
Input
12
100
200
300
0
Output
5 7
71 73
197 199
281 283 | instruction | 0 | 82,496 | 22 | 164,992 |
"Correct Solution:
```
# -*- coding: utf-8 -*-
"""
"""
import sys
from sys import stdin
from bisect import bisect_right
input = stdin.readline
def create_prime_list(limit):
""" ??¨??????????????????????????§limit?????§????´???°?????????????±???????
https://ja.wikipedia.org/wiki/%E3%82%A8%E3%83%A9%E3%83%88%E3%82%B9%E3%83%86%E3%83%8D%E3%82%B9%E3%81%AE%E7%AF%A9
"""
x = limit**0.5
primes = []
nums = [x for x in range(2, limit+1)]
while nums[0]<=x:
primes.append(nums[0])
current_prime = nums[0]
nums = [x for x in nums if x%current_prime != 0]
primes.extend(nums)
return primes
def main(args):
# ??????????´???°?????????
primes = create_prime_list(10000)
twin_primes = []
prev = primes[0]
for p in primes[1:]:
if p == prev + 2:
twin_primes.append([prev, p])
prev = p
keys = [x[1] for x in twin_primes]
while True:
n = int(input())
if n == 0:
break
r = bisect_right(keys, n)
print(*twin_primes[r-1])
if __name__ == '__main__':
main(sys.argv[1:])
``` | output | 1 | 82,496 | 22 | 164,993 |
Provide a correct Python 3 solution for this coding contest problem.
Prime numbers are widely applied for cryptographic and communication technology. A twin prime is a prime number that differs from another prime number by 2. For example, (5, 7) and (11, 13) are twin prime pairs.
In this problem, we call the greater number of a twin prime "size of the twin prime."
Your task is to create a program which reads an integer n and prints a twin prime which has the maximum size among twin primes less than or equals to n
You may assume that 5 ≤ n ≤ 10000.
Input
The input is a sequence of datasets. The end of the input is indicated by a line containing one zero. Each dataset is formatted as follows:
n (integer)
Output
For each dataset, print the twin prime p and q (p < q). p and q should be separated by a single space.
Example
Input
12
100
200
300
0
Output
5 7
71 73
197 199
281 283 | instruction | 0 | 82,497 | 22 | 164,994 |
"Correct Solution:
```
primes = [0, 0] + [1]*9999
for i in range(2, 100):
for j in range(i*i, 10001, i):
primes[j] = 0
while True:
n = int(input())
if n == 0:
break
for i in range(2, n+1)[::-1]:
if primes[i-2] and primes[i]:
print(i-2, i)
break
``` | output | 1 | 82,497 | 22 | 164,995 |
Provide a correct Python 3 solution for this coding contest problem.
Prime numbers are widely applied for cryptographic and communication technology. A twin prime is a prime number that differs from another prime number by 2. For example, (5, 7) and (11, 13) are twin prime pairs.
In this problem, we call the greater number of a twin prime "size of the twin prime."
Your task is to create a program which reads an integer n and prints a twin prime which has the maximum size among twin primes less than or equals to n
You may assume that 5 ≤ n ≤ 10000.
Input
The input is a sequence of datasets. The end of the input is indicated by a line containing one zero. Each dataset is formatted as follows:
n (integer)
Output
For each dataset, print the twin prime p and q (p < q). p and q should be separated by a single space.
Example
Input
12
100
200
300
0
Output
5 7
71 73
197 199
281 283 | instruction | 0 | 82,498 | 22 | 164,996 |
"Correct Solution:
```
# -*- coding: utf-8 -*-
"""
"""
import sys
from sys import stdin
from bisect import bisect_right
input = stdin.readline
def create_prime_list(limit):
""" ??¨??????????????????????????§limit?????§????´???°?????????????±???????
https://ja.wikipedia.org/wiki/%E3%82%A8%E3%83%A9%E3%83%88%E3%82%B9%E3%83%86%E3%83%8D%E3%82%B9%E3%81%AE%E7%AF%A9
"""
x = limit**0.5
primes = []
nums = [x for x in range(2, limit+1)]
while nums[0]<=x:
primes.append(nums[0])
current_prime = nums[0]
nums = [x for x in nums if x%current_prime != 0]
primes.extend(nums)
return primes
def main(args):
# ??????????´???°?????????
primes = create_prime_list(10000)
twin_primes = []
# prev = primes[0]
# for p in primes[1:]:
# if p == prev + 2:
# twin_primes.append([prev, p])
# prev = p
#
# keys = [x[1] for x in twin_primes]
# while True:
# n = int(input())
# if n == 0:
# break
# r = bisect_right(keys, n)
# print(*twin_primes[r-1])
prev = primes[0]
for p in primes[1:]:
if p == prev + 2:
twin_primes.append(p)
prev = p
while True:
n = int(input())
if n == 0:
break
r = bisect_right(twin_primes, n)
print(twin_primes[r-1]-2, twin_primes[r-1])
if __name__ == '__main__':
main(sys.argv[1:])
``` | output | 1 | 82,498 | 22 | 164,997 |
Provide a correct Python 3 solution for this coding contest problem.
Prime numbers are widely applied for cryptographic and communication technology. A twin prime is a prime number that differs from another prime number by 2. For example, (5, 7) and (11, 13) are twin prime pairs.
In this problem, we call the greater number of a twin prime "size of the twin prime."
Your task is to create a program which reads an integer n and prints a twin prime which has the maximum size among twin primes less than or equals to n
You may assume that 5 ≤ n ≤ 10000.
Input
The input is a sequence of datasets. The end of the input is indicated by a line containing one zero. Each dataset is formatted as follows:
n (integer)
Output
For each dataset, print the twin prime p and q (p < q). p and q should be separated by a single space.
Example
Input
12
100
200
300
0
Output
5 7
71 73
197 199
281 283 | instruction | 0 | 82,499 | 22 | 164,998 |
"Correct Solution:
```
import math
isPrime = [True] * 10001
primes = []
def eratos(n):
isPrime[0] = isPrime[1] = False
for i in range(2,int(math.sqrt(n))):
if isPrime[i]:
j = 2 * i
while j <= n:
isPrime[j] = False
j = j + i
for i in range(2,10000):
if isPrime[i]:
primes.append(i)
eratos(10000)
while True:
try:
n = int(input())
if n == 0:
break
for i in range(n,2,-1):
if isPrime[i]:
if isPrime[i - 2]:
print(i - 2,i)
break
except EOFError:
break
``` | output | 1 | 82,499 | 22 | 164,999 |
Provide a correct Python 3 solution for this coding contest problem.
Prime numbers are widely applied for cryptographic and communication technology. A twin prime is a prime number that differs from another prime number by 2. For example, (5, 7) and (11, 13) are twin prime pairs.
In this problem, we call the greater number of a twin prime "size of the twin prime."
Your task is to create a program which reads an integer n and prints a twin prime which has the maximum size among twin primes less than or equals to n
You may assume that 5 ≤ n ≤ 10000.
Input
The input is a sequence of datasets. The end of the input is indicated by a line containing one zero. Each dataset is formatted as follows:
n (integer)
Output
For each dataset, print the twin prime p and q (p < q). p and q should be separated by a single space.
Example
Input
12
100
200
300
0
Output
5 7
71 73
197 199
281 283 | instruction | 0 | 82,500 | 22 | 165,000 |
"Correct Solution:
```
def primes(n):
tf = [True] * (n + 1)
tf[0] = tf[1] = False
for i in range(2, int(n ** (1 / 2)) + 1):
if tf[i]:
for j in range(i ** 2, n + 1, i):
tf[j] = False
return [i for i in range(n + 1) if tf[i]]
def add_twin(prime_lst, twin_lst):
prime_lst2 = prime_lst[1:]
for x, y in zip(prime_lst, prime_lst2):
if y - x == 2:
twin_lst.append(y)
def search_twin(x, twin_lst):
left = 0
right = len(twin_lst)
while left + 1 < right:
mid = (left + right) // 2
if twin_lst[mid] > x:
right = mid
elif twin_lst[mid] < x:
left = mid
else:
return x
return twin_lst[left]
prime_lst = primes(10000)
twin_lst = []
add_twin(prime_lst, twin_lst)
while True:
n = int(input())
if n == 0:
break
a = search_twin(n, twin_lst)
print(a - 2, a)
``` | output | 1 | 82,500 | 22 | 165,001 |
Provide a correct Python 3 solution for this coding contest problem.
Prime numbers are widely applied for cryptographic and communication technology. A twin prime is a prime number that differs from another prime number by 2. For example, (5, 7) and (11, 13) are twin prime pairs.
In this problem, we call the greater number of a twin prime "size of the twin prime."
Your task is to create a program which reads an integer n and prints a twin prime which has the maximum size among twin primes less than or equals to n
You may assume that 5 ≤ n ≤ 10000.
Input
The input is a sequence of datasets. The end of the input is indicated by a line containing one zero. Each dataset is formatted as follows:
n (integer)
Output
For each dataset, print the twin prime p and q (p < q). p and q should be separated by a single space.
Example
Input
12
100
200
300
0
Output
5 7
71 73
197 199
281 283 | instruction | 0 | 82,501 | 22 | 165,002 |
"Correct Solution:
```
def isPrime(n):
for i in range(2,int(n**.5+1)):
if n%i==0:
return False
return True
while 1:
n=int(input())
if not n:break
for i in range(n,1,-1):
if isPrime(i) and isPrime(i-2):
print(i-2,i)
break
``` | output | 1 | 82,501 | 22 | 165,003 |
Provide a correct Python 3 solution for this coding contest problem.
Prime numbers are widely applied for cryptographic and communication technology. A twin prime is a prime number that differs from another prime number by 2. For example, (5, 7) and (11, 13) are twin prime pairs.
In this problem, we call the greater number of a twin prime "size of the twin prime."
Your task is to create a program which reads an integer n and prints a twin prime which has the maximum size among twin primes less than or equals to n
You may assume that 5 ≤ n ≤ 10000.
Input
The input is a sequence of datasets. The end of the input is indicated by a line containing one zero. Each dataset is formatted as follows:
n (integer)
Output
For each dataset, print the twin prime p and q (p < q). p and q should be separated by a single space.
Example
Input
12
100
200
300
0
Output
5 7
71 73
197 199
281 283 | instruction | 0 | 82,502 | 22 | 165,004 |
"Correct Solution:
```
import math
MAX = 10000
def is_prime_number(num):
for divisor in range(3, int(math.sqrt(num) + 1), 2):
if num % divisor == 0:
return False
return True
def create_prime_number_list(max):
prime_number_list = list(range(0, max + 1))
prime_number_list[0] = False
prime_number_list[1] = False
for index in range(2 * 2, max + 1, 2):
prime_number_list[index] = False
for num in range(3, int(math.sqrt(max + 1)), 2):
if is_prime_number(num):
for index in range(num * 2, max + 1, num):
prime_number_list[index] = False
return prime_number_list
prime_number_list = create_prime_number_list(MAX)
output = []
while True:
num = int(input())
if num == 0:
break
if num % 2 == 0:
num -= 1
for index in range(num, 0, -2):
if prime_number_list[index - 2] and prime_number_list[index]:
output.append(str(index - 2) + " " + str(index))
break
print("\n".join(output))
``` | output | 1 | 82,502 | 22 | 165,005 |
Provide a correct Python 3 solution for this coding contest problem.
Prime numbers are widely applied for cryptographic and communication technology. A twin prime is a prime number that differs from another prime number by 2. For example, (5, 7) and (11, 13) are twin prime pairs.
In this problem, we call the greater number of a twin prime "size of the twin prime."
Your task is to create a program which reads an integer n and prints a twin prime which has the maximum size among twin primes less than or equals to n
You may assume that 5 ≤ n ≤ 10000.
Input
The input is a sequence of datasets. The end of the input is indicated by a line containing one zero. Each dataset is formatted as follows:
n (integer)
Output
For each dataset, print the twin prime p and q (p < q). p and q should be separated by a single space.
Example
Input
12
100
200
300
0
Output
5 7
71 73
197 199
281 283 | instruction | 0 | 82,503 | 22 | 165,006 |
"Correct Solution:
```
import math
def prime(n):
for k in range(2, int(math.sqrt(n)) + 1):
if n % k == 0:
return False
else:
return True
while 1:
n = int(input())
if n == 0:
break
if n % 2 == 0:
n -= 1
for i in range(n, 3, -2):
if prime(i) and prime(i-2):
print(i-2, i)
break
``` | output | 1 | 82,503 | 22 | 165,007 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Prime numbers are widely applied for cryptographic and communication technology. A twin prime is a prime number that differs from another prime number by 2. For example, (5, 7) and (11, 13) are twin prime pairs.
In this problem, we call the greater number of a twin prime "size of the twin prime."
Your task is to create a program which reads an integer n and prints a twin prime which has the maximum size among twin primes less than or equals to n
You may assume that 5 ≤ n ≤ 10000.
Input
The input is a sequence of datasets. The end of the input is indicated by a line containing one zero. Each dataset is formatted as follows:
n (integer)
Output
For each dataset, print the twin prime p and q (p < q). p and q should be separated by a single space.
Example
Input
12
100
200
300
0
Output
5 7
71 73
197 199
281 283
Submitted Solution:
```
import math
m = 10000
s = [1 for i in range(m+1)]
s[0] = 0
for i in range(2, int(math.sqrt(m))+1):
if s[i] != 0:
for j in range(i*2, m, i):
s[j] = 0
ss = []
for i in range(m+1):
if s[i] == 1:
ss.append(i)
ss.reverse()
while True:
n = int(input())
if n == 0:
quit()
for i in range(len(ss)):
if ss[i] <= n and ss[i] - ss[i+1] == 2:
print(ss[i+1], ss[i])
break
``` | instruction | 0 | 82,504 | 22 | 165,008 |
Yes | output | 1 | 82,504 | 22 | 165,009 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Prime numbers are widely applied for cryptographic and communication technology. A twin prime is a prime number that differs from another prime number by 2. For example, (5, 7) and (11, 13) are twin prime pairs.
In this problem, we call the greater number of a twin prime "size of the twin prime."
Your task is to create a program which reads an integer n and prints a twin prime which has the maximum size among twin primes less than or equals to n
You may assume that 5 ≤ n ≤ 10000.
Input
The input is a sequence of datasets. The end of the input is indicated by a line containing one zero. Each dataset is formatted as follows:
n (integer)
Output
For each dataset, print the twin prime p and q (p < q). p and q should be separated by a single space.
Example
Input
12
100
200
300
0
Output
5 7
71 73
197 199
281 283
Submitted Solution:
```
# AOJ 0150 Twin Prime
# Python3 2018.6.17 bal4u
MAX = 10001
SQRT = 100 # sqrt(MAX)
prime = [True]*MAX
def sieve():
# for i in range(4, MAX, 2):
# prime[i] = False
for i in range(3, SQRT, 2):
if prime[i] is True:
for j in range(i*i, MAX, i):
prime[j] = False
sieve()
tbl, ans = [0]*MAX, 0
for i in range(5, MAX, 2):
if prime[i] and prime[i-2]: ans = i
tbl[i] = ans
while True:
n = int(input())
if n == 0: break
if (n & 1) == 0: n -= 1
print(tbl[n]-2, tbl[n])
``` | instruction | 0 | 82,505 | 22 | 165,010 |
Yes | output | 1 | 82,505 | 22 | 165,011 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Prime numbers are widely applied for cryptographic and communication technology. A twin prime is a prime number that differs from another prime number by 2. For example, (5, 7) and (11, 13) are twin prime pairs.
In this problem, we call the greater number of a twin prime "size of the twin prime."
Your task is to create a program which reads an integer n and prints a twin prime which has the maximum size among twin primes less than or equals to n
You may assume that 5 ≤ n ≤ 10000.
Input
The input is a sequence of datasets. The end of the input is indicated by a line containing one zero. Each dataset is formatted as follows:
n (integer)
Output
For each dataset, print the twin prime p and q (p < q). p and q should be separated by a single space.
Example
Input
12
100
200
300
0
Output
5 7
71 73
197 199
281 283
Submitted Solution:
```
def prime(N):
first=[True for i in range(N+1)]
first[0],first[1]=False,False
for i in range(2,int((N+1)**0.5)):
if not first[i]:continue
for j in range(i*2,N+1,i):first[j]=False
return [i for i in range(N+1) if first[i]]
prime_number=prime(10000)
while 1:
n=int(input())
if n==0:break
box=0
for i,j in enumerate(prime_number):
if j>n:break
if prime_number[i]-prime_number[i-1]==2:
box=max(box,prime_number[i])
print(box-2,box)
``` | instruction | 0 | 82,506 | 22 | 165,012 |
Yes | output | 1 | 82,506 | 22 | 165,013 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Prime numbers are widely applied for cryptographic and communication technology. A twin prime is a prime number that differs from another prime number by 2. For example, (5, 7) and (11, 13) are twin prime pairs.
In this problem, we call the greater number of a twin prime "size of the twin prime."
Your task is to create a program which reads an integer n and prints a twin prime which has the maximum size among twin primes less than or equals to n
You may assume that 5 ≤ n ≤ 10000.
Input
The input is a sequence of datasets. The end of the input is indicated by a line containing one zero. Each dataset is formatted as follows:
n (integer)
Output
For each dataset, print the twin prime p and q (p < q). p and q should be separated by a single space.
Example
Input
12
100
200
300
0
Output
5 7
71 73
197 199
281 283
Submitted Solution:
```
# AOJ 0150 Twin Prime
# Python3 2018.6.17 bal4u
MAX = 10001
SQRT = 100 # sqrt(MAX)
prime = [True for i in range(MAX)]
def sieve():
for i in range(4, MAX, 2):
prime[i] = False
for i in range(3, SQRT, 2):
if prime[i] is True:
for j in range(i*i, MAX, i):
prime[j] = False
sieve()
tbl = [0]*MAX
ans = 0
for i in range(5, MAX, 2):
if prime[i] and prime[i-2]: ans = i
tbl[i] = ans
while True:
n = int(input())
if n == 0: break
if (n & 1) == 0: n -= 1
print(tbl[n]-2, tbl[n])
``` | instruction | 0 | 82,507 | 22 | 165,014 |
Yes | output | 1 | 82,507 | 22 | 165,015 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Prime numbers are widely applied for cryptographic and communication technology. A twin prime is a prime number that differs from another prime number by 2. For example, (5, 7) and (11, 13) are twin prime pairs.
In this problem, we call the greater number of a twin prime "size of the twin prime."
Your task is to create a program which reads an integer n and prints a twin prime which has the maximum size among twin primes less than or equals to n
You may assume that 5 ≤ n ≤ 10000.
Input
The input is a sequence of datasets. The end of the input is indicated by a line containing one zero. Each dataset is formatted as follows:
n (integer)
Output
For each dataset, print the twin prime p and q (p < q). p and q should be separated by a single space.
Example
Input
12
100
200
300
0
Output
5 7
71 73
197 199
281 283
Submitted Solution:
```
# -*- coding: utf-8 -*-
"""
"""
import sys
from sys import stdin
from bisect import bisect_left
input = stdin.readline
def create_prime_list(limit):
""" ??¨??????????????????????????§limit?????§????´???°?????????????±???????
https://ja.wikipedia.org/wiki/%E3%82%A8%E3%83%A9%E3%83%88%E3%82%B9%E3%83%86%E3%83%8D%E3%82%B9%E3%81%AE%E7%AF%A9
"""
x = limit**0.5
primes = []
nums = [x for x in range(2, limit+1)]
while nums[0]<=x:
primes.append(nums[0])
current_prime = nums[0]
nums = [x for x in nums if x%current_prime != 0]
primes.extend(nums)
return primes
def main(args):
# ??????????´???°?????????
primes = create_prime_list(10000)
twin_primes = []
prev = primes[0]
for p in primes[1:]:
if p == prev + 2:
twin_primes.append([prev, p])
prev = p
keys = [x[1] for x in twin_primes]
while True:
n = int(input())
if n == 0:
break
r = bisect_left(keys, n)
print(*twin_primes[r-1])
if __name__ == '__main__':
main(sys.argv[1:])
``` | instruction | 0 | 82,508 | 22 | 165,016 |
No | output | 1 | 82,508 | 22 | 165,017 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Prime numbers are widely applied for cryptographic and communication technology. A twin prime is a prime number that differs from another prime number by 2. For example, (5, 7) and (11, 13) are twin prime pairs.
In this problem, we call the greater number of a twin prime "size of the twin prime."
Your task is to create a program which reads an integer n and prints a twin prime which has the maximum size among twin primes less than or equals to n
You may assume that 5 ≤ n ≤ 10000.
Input
The input is a sequence of datasets. The end of the input is indicated by a line containing one zero. Each dataset is formatted as follows:
n (integer)
Output
For each dataset, print the twin prime p and q (p < q). p and q should be separated by a single space.
Example
Input
12
100
200
300
0
Output
5 7
71 73
197 199
281 283
Submitted Solution:
```
def primes(n):
tf = [True] * (n + 1)
tf[0] = tf[1] = False
for i in range(2, int(n ** (1 / 2)) + 1):
if tf[i]:
for j in range(i ** 2, n + 1, i):
tf[j] = False
return [i for i in range(n, -1, -1) if tf[i]]
def search_twin(prime_lst):
prime_lst2 = prime_lst[1:]
for x, y in zip(prime_lst, prime_lst2):
if x - y == 2:
return (y, x)
while True:
n = int(input())
if n == 0:
break
prime_lst = primes(n)
print(*search_twin(prime_lst))
``` | instruction | 0 | 82,509 | 22 | 165,018 |
No | output | 1 | 82,509 | 22 | 165,019 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Prime numbers are widely applied for cryptographic and communication technology. A twin prime is a prime number that differs from another prime number by 2. For example, (5, 7) and (11, 13) are twin prime pairs.
In this problem, we call the greater number of a twin prime "size of the twin prime."
Your task is to create a program which reads an integer n and prints a twin prime which has the maximum size among twin primes less than or equals to n
You may assume that 5 ≤ n ≤ 10000.
Input
The input is a sequence of datasets. The end of the input is indicated by a line containing one zero. Each dataset is formatted as follows:
n (integer)
Output
For each dataset, print the twin prime p and q (p < q). p and q should be separated by a single space.
Example
Input
12
100
200
300
0
Output
5 7
71 73
197 199
281 283
Submitted Solution:
```
from itertools import takewhile
pnum, tmp = [], [i for i in range(2, 10000)]
while tmp[0] < 101:
v = tmp.pop(0)
pnum.append(v)
tmp = list(filter(lambda x: x%v!=0, tmp))
for t in tmp: pnum.append(t)
del pnum[0:2]
while True:
n = int(input())
if n==0: break
prime = list(takewhile(lambda x: x<=n, pnum))
for i in range(len(prime))[:0:-1]:
if prime[i]-prime[i-1]==2:
print(prime[i-1], prime[i])
break
``` | instruction | 0 | 82,510 | 22 | 165,020 |
No | output | 1 | 82,510 | 22 | 165,021 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Prime numbers are widely applied for cryptographic and communication technology. A twin prime is a prime number that differs from another prime number by 2. For example, (5, 7) and (11, 13) are twin prime pairs.
In this problem, we call the greater number of a twin prime "size of the twin prime."
Your task is to create a program which reads an integer n and prints a twin prime which has the maximum size among twin primes less than or equals to n
You may assume that 5 ≤ n ≤ 10000.
Input
The input is a sequence of datasets. The end of the input is indicated by a line containing one zero. Each dataset is formatted as follows:
n (integer)
Output
For each dataset, print the twin prime p and q (p < q). p and q should be separated by a single space.
Example
Input
12
100
200
300
0
Output
5 7
71 73
197 199
281 283
Submitted Solution:
```
from itertools import takewhile
pnum, tmp = [], [int(i) for i in range(2, 10000)]
while tmp[0] < 101:
v = tmp.pop(0)
pnum.append(v)
tmp = list(filter(lambda x: x%v!=0, tmp))
for t in tmp: pnum.append(t)
del pnum[0:2]
while True:
n = int(input())
if n==0: break
prime = list(takewhile(lambda x: x<=n, pnum))
for i in range(len(prime))[:0:-1]:
if prime[i]-prime[i-1]==2:
print(prime[i-1], prime[i])
break
``` | instruction | 0 | 82,511 | 22 | 165,022 |
No | output | 1 | 82,511 | 22 | 165,023 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Try guessing the statement from this picture:
<image>
You are given a non-negative integer d. You have to find two non-negative real numbers a and b such that a + b = d and a â‹… b = d.
Input
The first line contains t (1 ≤ t ≤ 10^3) — the number of test cases.
Each test case contains one integer d (0 ≤ d ≤ 10^3).
Output
For each test print one line.
If there is an answer for the i-th test, print "Y", and then the numbers a and b.
If there is no answer for the i-th test, print "N".
Your answer will be considered correct if |(a + b) - a ⋅ b| ≤ 10^{-6} and |(a + b) - d| ≤ 10^{-6}.
Example
Input
7
69
0
1
4
5
999
1000
Output
Y 67.985071301 1.014928699
Y 0.000000000 0.000000000
N
Y 2.000000000 2.000000000
Y 3.618033989 1.381966011
Y 997.998996990 1.001003010
Y 998.998997995 1.001002005 | instruction | 0 | 82,596 | 22 | 165,192 |
Tags: binary search, math
Correct Solution:
```
from math import (sqrt)
t = int(input())
for i in range(t):
d = int(input())
delta = d*d-4*d
if(delta>=0):
delta = sqrt(delta)
a = (d+delta)/2
b = (d-delta)/2
print("Y",a,b)
else:
print("N")
``` | output | 1 | 82,596 | 22 | 165,193 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Try guessing the statement from this picture:
<image>
You are given a non-negative integer d. You have to find two non-negative real numbers a and b such that a + b = d and a â‹… b = d.
Input
The first line contains t (1 ≤ t ≤ 10^3) — the number of test cases.
Each test case contains one integer d (0 ≤ d ≤ 10^3).
Output
For each test print one line.
If there is an answer for the i-th test, print "Y", and then the numbers a and b.
If there is no answer for the i-th test, print "N".
Your answer will be considered correct if |(a + b) - a ⋅ b| ≤ 10^{-6} and |(a + b) - d| ≤ 10^{-6}.
Example
Input
7
69
0
1
4
5
999
1000
Output
Y 67.985071301 1.014928699
Y 0.000000000 0.000000000
N
Y 2.000000000 2.000000000
Y 3.618033989 1.381966011
Y 997.998996990 1.001003010
Y 998.998997995 1.001002005 | instruction | 0 | 82,597 | 22 | 165,194 |
Tags: binary search, math
Correct Solution:
```
t = int(input())
for i in range(t):
d = int(input())
D = d * d - 4 * d
if d == 0:
print('Y', 0.0, 0.0)
elif d < 4:
print('N')
else:
a = (d + D ** 0.5) / 2
b = (d - D ** 0.5) / 2
print('Y', a, b)
``` | output | 1 | 82,597 | 22 | 165,195 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Try guessing the statement from this picture:
<image>
You are given a non-negative integer d. You have to find two non-negative real numbers a and b such that a + b = d and a â‹… b = d.
Input
The first line contains t (1 ≤ t ≤ 10^3) — the number of test cases.
Each test case contains one integer d (0 ≤ d ≤ 10^3).
Output
For each test print one line.
If there is an answer for the i-th test, print "Y", and then the numbers a and b.
If there is no answer for the i-th test, print "N".
Your answer will be considered correct if |(a + b) - a ⋅ b| ≤ 10^{-6} and |(a + b) - d| ≤ 10^{-6}.
Example
Input
7
69
0
1
4
5
999
1000
Output
Y 67.985071301 1.014928699
Y 0.000000000 0.000000000
N
Y 2.000000000 2.000000000
Y 3.618033989 1.381966011
Y 997.998996990 1.001003010
Y 998.998997995 1.001002005 | instruction | 0 | 82,598 | 22 | 165,196 |
Tags: binary search, math
Correct Solution:
```
from math import sqrt as s
for _ in" "*int(input()):n=int(input());print(*("Y ",(n+s(n**2-(4*n)))/2,n-(n+s(n**2-(4*n)))/2)if n**2-(4*n)>=0else"N")
``` | output | 1 | 82,598 | 22 | 165,197 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Try guessing the statement from this picture:
<image>
You are given a non-negative integer d. You have to find two non-negative real numbers a and b such that a + b = d and a â‹… b = d.
Input
The first line contains t (1 ≤ t ≤ 10^3) — the number of test cases.
Each test case contains one integer d (0 ≤ d ≤ 10^3).
Output
For each test print one line.
If there is an answer for the i-th test, print "Y", and then the numbers a and b.
If there is no answer for the i-th test, print "N".
Your answer will be considered correct if |(a + b) - a ⋅ b| ≤ 10^{-6} and |(a + b) - d| ≤ 10^{-6}.
Example
Input
7
69
0
1
4
5
999
1000
Output
Y 67.985071301 1.014928699
Y 0.000000000 0.000000000
N
Y 2.000000000 2.000000000
Y 3.618033989 1.381966011
Y 997.998996990 1.001003010
Y 998.998997995 1.001002005 | instruction | 0 | 82,599 | 22 | 165,198 |
Tags: binary search, math
Correct Solution:
```
def fun():
test=int(input())
for i in range(test):
d=int(input())
if( 0< d< 4):
print("N")
else:
a= (d + (d*d- 4*d)**0.5)/2
b= d-a
print("Y {} {}".format(a,b))
fun()
``` | output | 1 | 82,599 | 22 | 165,199 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Try guessing the statement from this picture:
<image>
You are given a non-negative integer d. You have to find two non-negative real numbers a and b such that a + b = d and a â‹… b = d.
Input
The first line contains t (1 ≤ t ≤ 10^3) — the number of test cases.
Each test case contains one integer d (0 ≤ d ≤ 10^3).
Output
For each test print one line.
If there is an answer for the i-th test, print "Y", and then the numbers a and b.
If there is no answer for the i-th test, print "N".
Your answer will be considered correct if |(a + b) - a ⋅ b| ≤ 10^{-6} and |(a + b) - d| ≤ 10^{-6}.
Example
Input
7
69
0
1
4
5
999
1000
Output
Y 67.985071301 1.014928699
Y 0.000000000 0.000000000
N
Y 2.000000000 2.000000000
Y 3.618033989 1.381966011
Y 997.998996990 1.001003010
Y 998.998997995 1.001002005 | instruction | 0 | 82,600 | 22 | 165,200 |
Tags: binary search, math
Correct Solution:
```
n = int(input())
for i in range(0,n):
d = int(input())
if d>0 and d<4:
print('N')
else:
a, b = (d + (d*(d-4))**0.5)/2 , (d - (d*(d-4))**0.5)/2
print('Y',a,b)
``` | output | 1 | 82,600 | 22 | 165,201 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Try guessing the statement from this picture:
<image>
You are given a non-negative integer d. You have to find two non-negative real numbers a and b such that a + b = d and a â‹… b = d.
Input
The first line contains t (1 ≤ t ≤ 10^3) — the number of test cases.
Each test case contains one integer d (0 ≤ d ≤ 10^3).
Output
For each test print one line.
If there is an answer for the i-th test, print "Y", and then the numbers a and b.
If there is no answer for the i-th test, print "N".
Your answer will be considered correct if |(a + b) - a ⋅ b| ≤ 10^{-6} and |(a + b) - d| ≤ 10^{-6}.
Example
Input
7
69
0
1
4
5
999
1000
Output
Y 67.985071301 1.014928699
Y 0.000000000 0.000000000
N
Y 2.000000000 2.000000000
Y 3.618033989 1.381966011
Y 997.998996990 1.001003010
Y 998.998997995 1.001002005 | instruction | 0 | 82,601 | 22 | 165,202 |
Tags: binary search, math
Correct Solution:
```
for test in range(int(input())):
d = int(input())
delta = d**2 - 4*d
if delta < 0:
print('N')
else:
x = max((-d+delta**0.5)/-2,(-d-delta**0.5)/-2)
if delta == 0:
x = max(abs(x),d/2)
print('Y','%.9f %.9f' %(x,d-x))
``` | output | 1 | 82,601 | 22 | 165,203 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Try guessing the statement from this picture:
<image>
You are given a non-negative integer d. You have to find two non-negative real numbers a and b such that a + b = d and a â‹… b = d.
Input
The first line contains t (1 ≤ t ≤ 10^3) — the number of test cases.
Each test case contains one integer d (0 ≤ d ≤ 10^3).
Output
For each test print one line.
If there is an answer for the i-th test, print "Y", and then the numbers a and b.
If there is no answer for the i-th test, print "N".
Your answer will be considered correct if |(a + b) - a ⋅ b| ≤ 10^{-6} and |(a + b) - d| ≤ 10^{-6}.
Example
Input
7
69
0
1
4
5
999
1000
Output
Y 67.985071301 1.014928699
Y 0.000000000 0.000000000
N
Y 2.000000000 2.000000000
Y 3.618033989 1.381966011
Y 997.998996990 1.001003010
Y 998.998997995 1.001002005 | instruction | 0 | 82,602 | 22 | 165,204 |
Tags: binary search, math
Correct Solution:
```
import math
t=int(input())
while(t):
d=int(input())
if(d*d < 4*d):
print('N')
else:
a=(d+math.sqrt(d*d - 4.0*d))/2.0
b=d-a
print('Y',end=' ')
print(a, b)
t-=1
``` | output | 1 | 82,602 | 22 | 165,205 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.