message stringlengths 2 44.5k | message_type stringclasses 2
values | message_id int64 0 1 | conversation_id int64 42 109k | cluster float64 5 5 | __index_level_0__ int64 84 217k |
|---|---|---|---|---|---|
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Given are two integer sequences of N elements each: A_1,...,A_N and B_1,...,B_N. Determine if it is possible to do the following operation at most N-2 times (possibly zero) so that, for every integer i from 1 to N, A_i \leq B_i holds:
* Choose two distinct integers x and y between 1 and N (inclusive), and swap the values of A_x and A_y.
Constraints
* 2 \leq N \leq 10^5
* 1 \leq A_i,B_i \leq 10^9
Input
Input is given from Standard Input in the following format:
N
A_1 A_2 ... A_N
B_1 B_2 ... B_N
Output
If the objective is achievable, print `Yes`; if it is not, print `No`.
Examples
Input
3
1 3 2
1 2 3
Output
Yes
Input
3
1 2 3
2 2 2
Output
No
Input
6
3 1 2 6 3 4
2 2 8 3 4 3
Output
Yes
Submitted Solution:
```
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
A.sort()
B.sort()
for x, y in zip(A, B):
if x > y:
print('No')
exit()
print('Yes')
``` | instruction | 0 | 22,647 | 5 | 45,294 |
No | output | 1 | 22,647 | 5 | 45,295 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Given are two integer sequences of N elements each: A_1,...,A_N and B_1,...,B_N. Determine if it is possible to do the following operation at most N-2 times (possibly zero) so that, for every integer i from 1 to N, A_i \leq B_i holds:
* Choose two distinct integers x and y between 1 and N (inclusive), and swap the values of A_x and A_y.
Constraints
* 2 \leq N \leq 10^5
* 1 \leq A_i,B_i \leq 10^9
Input
Input is given from Standard Input in the following format:
N
A_1 A_2 ... A_N
B_1 B_2 ... B_N
Output
If the objective is achievable, print `Yes`; if it is not, print `No`.
Examples
Input
3
1 3 2
1 2 3
Output
Yes
Input
3
1 2 3
2 2 2
Output
No
Input
6
3 1 2 6 3 4
2 2 8 3 4 3
Output
Yes
Submitted Solution:
```
import numpy as np
N = int(input())
A = np.array(list(map(int,input().split())))
B = np.array(list(map(int,input().split())))
Bsi = np.argsort(B)
A2 = A[Bsi]
Bs = B[Bsi]
A2si = np.argsort(A2)
As = A2[A2si]
C = Bs-As
if any(C[C<0]):
ans = 'No'
else:
D = A2-As
if any(D == 0):
ans = 'Yes'
elif all(As[1::]-Bs[:-1:] > 0):
psum = A2si[0]
for i,pi in enumerate(A2si[1:-1],1):
psum += pi
if psum == int(i*(i+1)/2):
ans = 'Yes'
break
else:
ans = 'No'
else:
ans = 'Yes'
print(ans)
``` | instruction | 0 | 22,648 | 5 | 45,296 |
No | output | 1 | 22,648 | 5 | 45,297 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Given are two integer sequences of N elements each: A_1,...,A_N and B_1,...,B_N. Determine if it is possible to do the following operation at most N-2 times (possibly zero) so that, for every integer i from 1 to N, A_i \leq B_i holds:
* Choose two distinct integers x and y between 1 and N (inclusive), and swap the values of A_x and A_y.
Constraints
* 2 \leq N \leq 10^5
* 1 \leq A_i,B_i \leq 10^9
Input
Input is given from Standard Input in the following format:
N
A_1 A_2 ... A_N
B_1 B_2 ... B_N
Output
If the objective is achievable, print `Yes`; if it is not, print `No`.
Examples
Input
3
1 3 2
1 2 3
Output
Yes
Input
3
1 2 3
2 2 2
Output
No
Input
6
3 1 2 6 3 4
2 2 8 3 4 3
Output
Yes
Submitted Solution:
```
import sys
import math
from collections import defaultdict
sys.setrecursionlimit(10**7)
def input():
return sys.stdin.readline()[:-1]
mod = 10**9 + 7
def I(): return int(input())
def II(): return map(int, input().split())
def III(): return list(map(int, input().split()))
def Line(N,num):
if N<=0:
return [[]]*num
elif num==1:
return [I() for _ in range(N)]
else:
read_all = [tuple(II()) for _ in range(N)]
return map(list, zip(*read_all))
#################
N = I()
A = III()
B = III()
#インデックス付きソート
#(index,value)の順に格納
def index_sort(A):
a = []
for i,x in enumerate(A):
a.append([i,x])
return sorted(a,key=lambda x: x[1])
A2 = sorted(A)
B2 = sorted(B)
for i in range(N):
if A2[i]>B2[i]:
print('No')
exit()
for i in range(N-1):
if B2[i]>=A2[i+1]:
print('Yes')
exit()
A3 = index_sort(A)
B3 = index_sort(B)
used = [False]*N
for i in range(2,N)[::-1]:
bindex = B3[i][0]
aindex = A3[i][0]
temp = A[aindex]
A[aindex] = A[bindex]
A[bindex] = temp
A3[aindex][0] = bindex
A3[bindex][0] = aindex
if A[A3[1][0]]<=B[B3[1][0]] and A[A3[1][1]]<=B[B3[1][1]]:
print('Yes')
else:
print('No')
``` | instruction | 0 | 22,649 | 5 | 45,298 |
No | output | 1 | 22,649 | 5 | 45,299 |
Provide a correct Python 3 solution for this coding contest problem.
Given an integer N, find the base -2 representation of N.
Here, S is the base -2 representation of N when the following are all satisfied:
* S is a string consisting of `0` and `1`.
* Unless S = `0`, the initial character of S is `1`.
* Let S = S_k S_{k-1} ... S_0, then S_0 \times (-2)^0 + S_1 \times (-2)^1 + ... + S_k \times (-2)^k = N.
It can be proved that, for any integer M, the base -2 representation of M is uniquely determined.
Constraints
* Every value in input is integer.
* -10^9 \leq N \leq 10^9
Input
Input is given from Standard Input in the following format:
N
Output
Print the base -2 representation of N.
Examples
Input
-9
Output
1011
Input
123456789
Output
11000101011001101110100010101
Input
0
Output
0 | instruction | 0 | 22,682 | 5 | 45,364 |
"Correct Solution:
```
# C
N=int(input())
S=""
while N!=0:
if N%(-2)==0:
S="0"+S
else:
S="1"+S
N-=1
N=N/(-2)
if S=="":
S="0"
print(S)
``` | output | 1 | 22,682 | 5 | 45,365 |
Provide a correct Python 3 solution for this coding contest problem.
Given an integer N, find the base -2 representation of N.
Here, S is the base -2 representation of N when the following are all satisfied:
* S is a string consisting of `0` and `1`.
* Unless S = `0`, the initial character of S is `1`.
* Let S = S_k S_{k-1} ... S_0, then S_0 \times (-2)^0 + S_1 \times (-2)^1 + ... + S_k \times (-2)^k = N.
It can be proved that, for any integer M, the base -2 representation of M is uniquely determined.
Constraints
* Every value in input is integer.
* -10^9 \leq N \leq 10^9
Input
Input is given from Standard Input in the following format:
N
Output
Print the base -2 representation of N.
Examples
Input
-9
Output
1011
Input
123456789
Output
11000101011001101110100010101
Input
0
Output
0 | instruction | 0 | 22,683 | 5 | 45,366 |
"Correct Solution:
```
N = int(input())
ans = ''
if N == 0: ans ='0'
while N:
ans += str(N%2)
N = -(N // 2)
print(ans[::-1])
``` | output | 1 | 22,683 | 5 | 45,367 |
Provide a correct Python 3 solution for this coding contest problem.
Given an integer N, find the base -2 representation of N.
Here, S is the base -2 representation of N when the following are all satisfied:
* S is a string consisting of `0` and `1`.
* Unless S = `0`, the initial character of S is `1`.
* Let S = S_k S_{k-1} ... S_0, then S_0 \times (-2)^0 + S_1 \times (-2)^1 + ... + S_k \times (-2)^k = N.
It can be proved that, for any integer M, the base -2 representation of M is uniquely determined.
Constraints
* Every value in input is integer.
* -10^9 \leq N \leq 10^9
Input
Input is given from Standard Input in the following format:
N
Output
Print the base -2 representation of N.
Examples
Input
-9
Output
1011
Input
123456789
Output
11000101011001101110100010101
Input
0
Output
0 | instruction | 0 | 22,684 | 5 | 45,368 |
"Correct Solution:
```
N = int(input())
ans = ""
while True:
ans = str(abs(N % -2)) + ans
N += N % -2
N = N // -2
if N == 0:
break
print(ans)
``` | output | 1 | 22,684 | 5 | 45,369 |
Provide a correct Python 3 solution for this coding contest problem.
Given an integer N, find the base -2 representation of N.
Here, S is the base -2 representation of N when the following are all satisfied:
* S is a string consisting of `0` and `1`.
* Unless S = `0`, the initial character of S is `1`.
* Let S = S_k S_{k-1} ... S_0, then S_0 \times (-2)^0 + S_1 \times (-2)^1 + ... + S_k \times (-2)^k = N.
It can be proved that, for any integer M, the base -2 representation of M is uniquely determined.
Constraints
* Every value in input is integer.
* -10^9 \leq N \leq 10^9
Input
Input is given from Standard Input in the following format:
N
Output
Print the base -2 representation of N.
Examples
Input
-9
Output
1011
Input
123456789
Output
11000101011001101110100010101
Input
0
Output
0 | instruction | 0 | 22,685 | 5 | 45,370 |
"Correct Solution:
```
n=int(input())
if n==0:
print(0)
exit()
ans=''
while n!=0:
r=n%(-2)
if r<0:
r+=2
ans+=str(r)
n-=r
n//=(-2)
print(ans[::-1])
``` | output | 1 | 22,685 | 5 | 45,371 |
Provide a correct Python 3 solution for this coding contest problem.
Given an integer N, find the base -2 representation of N.
Here, S is the base -2 representation of N when the following are all satisfied:
* S is a string consisting of `0` and `1`.
* Unless S = `0`, the initial character of S is `1`.
* Let S = S_k S_{k-1} ... S_0, then S_0 \times (-2)^0 + S_1 \times (-2)^1 + ... + S_k \times (-2)^k = N.
It can be proved that, for any integer M, the base -2 representation of M is uniquely determined.
Constraints
* Every value in input is integer.
* -10^9 \leq N \leq 10^9
Input
Input is given from Standard Input in the following format:
N
Output
Print the base -2 representation of N.
Examples
Input
-9
Output
1011
Input
123456789
Output
11000101011001101110100010101
Input
0
Output
0 | instruction | 0 | 22,686 | 5 | 45,372 |
"Correct Solution:
```
n = int(input())
s=""
while n!=0:
if n%(-2)==0:
s="0"+s
else:
s="1"+s
n-=1
n=n//(-2)
if s=="":
s="0"
print(s)
``` | output | 1 | 22,686 | 5 | 45,373 |
Provide a correct Python 3 solution for this coding contest problem.
Given an integer N, find the base -2 representation of N.
Here, S is the base -2 representation of N when the following are all satisfied:
* S is a string consisting of `0` and `1`.
* Unless S = `0`, the initial character of S is `1`.
* Let S = S_k S_{k-1} ... S_0, then S_0 \times (-2)^0 + S_1 \times (-2)^1 + ... + S_k \times (-2)^k = N.
It can be proved that, for any integer M, the base -2 representation of M is uniquely determined.
Constraints
* Every value in input is integer.
* -10^9 \leq N \leq 10^9
Input
Input is given from Standard Input in the following format:
N
Output
Print the base -2 representation of N.
Examples
Input
-9
Output
1011
Input
123456789
Output
11000101011001101110100010101
Input
0
Output
0 | instruction | 0 | 22,687 | 5 | 45,374 |
"Correct Solution:
```
N=int(input())
if N==0:print(0)
ans=""
while N!=0:
r=N%2
N=(N-r)//(-2)
ans+=str(r)
ans=ans[::-1]
print(ans)
``` | output | 1 | 22,687 | 5 | 45,375 |
Provide a correct Python 3 solution for this coding contest problem.
Given an integer N, find the base -2 representation of N.
Here, S is the base -2 representation of N when the following are all satisfied:
* S is a string consisting of `0` and `1`.
* Unless S = `0`, the initial character of S is `1`.
* Let S = S_k S_{k-1} ... S_0, then S_0 \times (-2)^0 + S_1 \times (-2)^1 + ... + S_k \times (-2)^k = N.
It can be proved that, for any integer M, the base -2 representation of M is uniquely determined.
Constraints
* Every value in input is integer.
* -10^9 \leq N \leq 10^9
Input
Input is given from Standard Input in the following format:
N
Output
Print the base -2 representation of N.
Examples
Input
-9
Output
1011
Input
123456789
Output
11000101011001101110100010101
Input
0
Output
0 | instruction | 0 | 22,688 | 5 | 45,376 |
"Correct Solution:
```
n = int(input())
cnt = 0
ans = 0
while n != 0:
now = n % 2
n = - (n // 2)
ans += now * 10 ** cnt
cnt += 1
print(ans)
``` | output | 1 | 22,688 | 5 | 45,377 |
Provide a correct Python 3 solution for this coding contest problem.
Given an integer N, find the base -2 representation of N.
Here, S is the base -2 representation of N when the following are all satisfied:
* S is a string consisting of `0` and `1`.
* Unless S = `0`, the initial character of S is `1`.
* Let S = S_k S_{k-1} ... S_0, then S_0 \times (-2)^0 + S_1 \times (-2)^1 + ... + S_k \times (-2)^k = N.
It can be proved that, for any integer M, the base -2 representation of M is uniquely determined.
Constraints
* Every value in input is integer.
* -10^9 \leq N \leq 10^9
Input
Input is given from Standard Input in the following format:
N
Output
Print the base -2 representation of N.
Examples
Input
-9
Output
1011
Input
123456789
Output
11000101011001101110100010101
Input
0
Output
0 | instruction | 0 | 22,689 | 5 | 45,378 |
"Correct Solution:
```
N = int(input())
ans = ""
while N != 0:
ans = str(N % 2)+ans
N = -(N//2)
print(ans if ans != ""else 0)
``` | output | 1 | 22,689 | 5 | 45,379 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Given an integer N, find the base -2 representation of N.
Here, S is the base -2 representation of N when the following are all satisfied:
* S is a string consisting of `0` and `1`.
* Unless S = `0`, the initial character of S is `1`.
* Let S = S_k S_{k-1} ... S_0, then S_0 \times (-2)^0 + S_1 \times (-2)^1 + ... + S_k \times (-2)^k = N.
It can be proved that, for any integer M, the base -2 representation of M is uniquely determined.
Constraints
* Every value in input is integer.
* -10^9 \leq N \leq 10^9
Input
Input is given from Standard Input in the following format:
N
Output
Print the base -2 representation of N.
Examples
Input
-9
Output
1011
Input
123456789
Output
11000101011001101110100010101
Input
0
Output
0
Submitted Solution:
```
N=int(input())
S=""if N!=0 else"0"
while N!=0:
S+="0"if N%2==0 else"1"
N=-(N//2)
print(S[::-1])
``` | instruction | 0 | 22,690 | 5 | 45,380 |
Yes | output | 1 | 22,690 | 5 | 45,381 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Given an integer N, find the base -2 representation of N.
Here, S is the base -2 representation of N when the following are all satisfied:
* S is a string consisting of `0` and `1`.
* Unless S = `0`, the initial character of S is `1`.
* Let S = S_k S_{k-1} ... S_0, then S_0 \times (-2)^0 + S_1 \times (-2)^1 + ... + S_k \times (-2)^k = N.
It can be proved that, for any integer M, the base -2 representation of M is uniquely determined.
Constraints
* Every value in input is integer.
* -10^9 \leq N \leq 10^9
Input
Input is given from Standard Input in the following format:
N
Output
Print the base -2 representation of N.
Examples
Input
-9
Output
1011
Input
123456789
Output
11000101011001101110100010101
Input
0
Output
0
Submitted Solution:
```
n = int(input())
if n == 0:
print(0)
exit()
s = ""
while n != 0:
s += str(n%2)
n = (n-n%2)//(-2)
print(s[::-1])
``` | instruction | 0 | 22,691 | 5 | 45,382 |
Yes | output | 1 | 22,691 | 5 | 45,383 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Given an integer N, find the base -2 representation of N.
Here, S is the base -2 representation of N when the following are all satisfied:
* S is a string consisting of `0` and `1`.
* Unless S = `0`, the initial character of S is `1`.
* Let S = S_k S_{k-1} ... S_0, then S_0 \times (-2)^0 + S_1 \times (-2)^1 + ... + S_k \times (-2)^k = N.
It can be proved that, for any integer M, the base -2 representation of M is uniquely determined.
Constraints
* Every value in input is integer.
* -10^9 \leq N \leq 10^9
Input
Input is given from Standard Input in the following format:
N
Output
Print the base -2 representation of N.
Examples
Input
-9
Output
1011
Input
123456789
Output
11000101011001101110100010101
Input
0
Output
0
Submitted Solution:
```
n=int(input())
s=""
while n:
s=str(n&1)+s
n=-(n>>1)
print(s if s else 0)
``` | instruction | 0 | 22,692 | 5 | 45,384 |
Yes | output | 1 | 22,692 | 5 | 45,385 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Given an integer N, find the base -2 representation of N.
Here, S is the base -2 representation of N when the following are all satisfied:
* S is a string consisting of `0` and `1`.
* Unless S = `0`, the initial character of S is `1`.
* Let S = S_k S_{k-1} ... S_0, then S_0 \times (-2)^0 + S_1 \times (-2)^1 + ... + S_k \times (-2)^k = N.
It can be proved that, for any integer M, the base -2 representation of M is uniquely determined.
Constraints
* Every value in input is integer.
* -10^9 \leq N \leq 10^9
Input
Input is given from Standard Input in the following format:
N
Output
Print the base -2 representation of N.
Examples
Input
-9
Output
1011
Input
123456789
Output
11000101011001101110100010101
Input
0
Output
0
Submitted Solution:
```
n = int(input())
if n == 0:
print(0)
else:
ans = ''
while n != 0:
ans += str(n % 2)
n //= 2
n *= -1
print(ans[::-1])
``` | instruction | 0 | 22,693 | 5 | 45,386 |
Yes | output | 1 | 22,693 | 5 | 45,387 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Given an integer N, find the base -2 representation of N.
Here, S is the base -2 representation of N when the following are all satisfied:
* S is a string consisting of `0` and `1`.
* Unless S = `0`, the initial character of S is `1`.
* Let S = S_k S_{k-1} ... S_0, then S_0 \times (-2)^0 + S_1 \times (-2)^1 + ... + S_k \times (-2)^k = N.
It can be proved that, for any integer M, the base -2 representation of M is uniquely determined.
Constraints
* Every value in input is integer.
* -10^9 \leq N \leq 10^9
Input
Input is given from Standard Input in the following format:
N
Output
Print the base -2 representation of N.
Examples
Input
-9
Output
1011
Input
123456789
Output
11000101011001101110100010101
Input
0
Output
0
Submitted Solution:
```
n=int(input())
ans=[]
if n==0:
print(0)
exit()
for i in range(100):
if n==0:
break
if n%(2**(i+1))==0:
ans.append('0')
else:
if i%2==0:
n-=2**i
else:
n+=2**i
ans.append('1')
print(''.join(map(str, ans)))
``` | instruction | 0 | 22,694 | 5 | 45,388 |
No | output | 1 | 22,694 | 5 | 45,389 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Given an integer N, find the base -2 representation of N.
Here, S is the base -2 representation of N when the following are all satisfied:
* S is a string consisting of `0` and `1`.
* Unless S = `0`, the initial character of S is `1`.
* Let S = S_k S_{k-1} ... S_0, then S_0 \times (-2)^0 + S_1 \times (-2)^1 + ... + S_k \times (-2)^k = N.
It can be proved that, for any integer M, the base -2 representation of M is uniquely determined.
Constraints
* Every value in input is integer.
* -10^9 \leq N \leq 10^9
Input
Input is given from Standard Input in the following format:
N
Output
Print the base -2 representation of N.
Examples
Input
-9
Output
1011
Input
123456789
Output
11000101011001101110100010101
Input
0
Output
0
Submitted Solution:
```
from collections import deque
import sys
n = int(input())
k = 1
if n < 0:
k = 0
n = -n
if n == 0:
print(0)
sys.exit()
ans = deque([])
while n > 0:
if n % 2 == 0:
ans.appendleft("0")
else:
ans.appendleft("1")
n = n // 2
if k:
print(int("".join(ans)))
else:
print(int("-"+"".join(ans)))
``` | instruction | 0 | 22,695 | 5 | 45,390 |
No | output | 1 | 22,695 | 5 | 45,391 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Given an integer N, find the base -2 representation of N.
Here, S is the base -2 representation of N when the following are all satisfied:
* S is a string consisting of `0` and `1`.
* Unless S = `0`, the initial character of S is `1`.
* Let S = S_k S_{k-1} ... S_0, then S_0 \times (-2)^0 + S_1 \times (-2)^1 + ... + S_k \times (-2)^k = N.
It can be proved that, for any integer M, the base -2 representation of M is uniquely determined.
Constraints
* Every value in input is integer.
* -10^9 \leq N \leq 10^9
Input
Input is given from Standard Input in the following format:
N
Output
Print the base -2 representation of N.
Examples
Input
-9
Output
1011
Input
123456789
Output
11000101011001101110100010101
Input
0
Output
0
Submitted Solution:
```
n = 0
l = []
if n == 0:
l.append('0')
while n:
if n % 2:
l.append('1')
else:
l.append('0')
n = -(n // 2)
``` | instruction | 0 | 22,696 | 5 | 45,392 |
No | output | 1 | 22,696 | 5 | 45,393 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Given an integer N, find the base -2 representation of N.
Here, S is the base -2 representation of N when the following are all satisfied:
* S is a string consisting of `0` and `1`.
* Unless S = `0`, the initial character of S is `1`.
* Let S = S_k S_{k-1} ... S_0, then S_0 \times (-2)^0 + S_1 \times (-2)^1 + ... + S_k \times (-2)^k = N.
It can be proved that, for any integer M, the base -2 representation of M is uniquely determined.
Constraints
* Every value in input is integer.
* -10^9 \leq N \leq 10^9
Input
Input is given from Standard Input in the following format:
N
Output
Print the base -2 representation of N.
Examples
Input
-9
Output
1011
Input
123456789
Output
11000101011001101110100010101
Input
0
Output
0
Submitted Solution:
```
n = int(input())
base = 2
ans =""
while n != 0:
ans = str(n%base)+ans
n = -(n//base)
print(ans)
``` | instruction | 0 | 22,697 | 5 | 45,394 |
No | output | 1 | 22,697 | 5 | 45,395 |
Provide a correct Python 3 solution for this coding contest problem.
Example
Input
3
1 3 3
2
1 2
1 3
Output
5 | instruction | 0 | 22,810 | 5 | 45,620 |
"Correct Solution:
```
from collections import deque
import sys
def main():
readline = sys.stdin.readline
write = sys.stdout.write
def root(x):
if x == p[x]:
return x
p[x] = y = root(p[x])
return y
def unite(x, y):
px = root(x)
py = root(y)
if px < py:
p[py] = px
else:
p[px] = py
N = int(readline())
*C, = map(int, readline().split())
M = int(readline())
*p, = range(N)
G = [[] for i in range(N)]
G0 = [[] for i in range(N)]
for i in range(M):
a, b = map(int, readline().split()); a -= 1; b -= 1
G[a].append(b)
G[b].append(a)
ca = C[a]; cb = C[b]
if ca < cb:
G0[a].append(b)
elif cb < ca:
G0[b].append(a)
for v in range(N):
ws = G[v]
if not ws:
continue
ws.sort(key = C.__getitem__)
c = C[v]
prv = ws[0]; pw = C[prv]
if C[prv] == c:
unite(v, prv)
for w in ws[1:]:
cw = C[w]
if pw == cw:
unite(prv, w)
else:
G0[prv].append(w)
if cw == c:
unite(v, w)
prv = w; pw = cw
G1 = [[] for i in range(N)]
deg = [0]*N
for v in range(N):
pv = root(v)
for w in G0[v]:
pw = root(w)
if pv != pw:
G1[pv].append(pw)
deg[pw] += 1
que = deque()
D = [0]*N
for i in range(N):
if root(i) != i:
continue
if deg[i] == 0:
que.append(i)
D[i] = 1
while que:
v = que.popleft()
d = D[v]
for w in G1[v]:
deg[w] -= 1
if deg[w] == 0:
que.append(w)
D[w] = max(D[w], d+1)
for i in range(N):
if root(i) == i:
continue
D[i] = D[root(i)]
write("%d\n" % sum(D))
main()
``` | output | 1 | 22,810 | 5 | 45,621 |
Provide a correct Python 3 solution for this coding contest problem.
Write a program which reads two integers x and y, and prints them in ascending order.
Constraints
* 0 ≤ x, y ≤ 10000
* the number of datasets ≤ 3000
Input
The input consists of multiple datasets. Each dataset consists of two integers x and y separated by a single space.
The input ends with two 0 (when both x and y are zero). Your program should not process for these terminal symbols.
Output
For each dataset, print x and y in ascending order in a line. Put a single space between x and y.
Example
Input
3 2
2 2
5 3
0 0
Output
2 3
2 2
3 5 | instruction | 0 | 22,826 | 5 | 45,652 |
"Correct Solution:
```
while 1:
s,t = map(int,input().split())
if s>t:
s,t = t,s
if (s,t)==(0,0):
break
print(s,t)
``` | output | 1 | 22,826 | 5 | 45,653 |
Provide a correct Python 3 solution for this coding contest problem.
Write a program which reads two integers x and y, and prints them in ascending order.
Constraints
* 0 ≤ x, y ≤ 10000
* the number of datasets ≤ 3000
Input
The input consists of multiple datasets. Each dataset consists of two integers x and y separated by a single space.
The input ends with two 0 (when both x and y are zero). Your program should not process for these terminal symbols.
Output
For each dataset, print x and y in ascending order in a line. Put a single space between x and y.
Example
Input
3 2
2 2
5 3
0 0
Output
2 3
2 2
3 5 | instruction | 0 | 22,827 | 5 | 45,654 |
"Correct Solution:
```
while(True):
a,b = map(int,input().split())
if a == 0 and b == 0:
break
print("{0} {1}".format(min(a,b),max(a,b)))
``` | output | 1 | 22,827 | 5 | 45,655 |
Provide a correct Python 3 solution for this coding contest problem.
Write a program which reads two integers x and y, and prints them in ascending order.
Constraints
* 0 ≤ x, y ≤ 10000
* the number of datasets ≤ 3000
Input
The input consists of multiple datasets. Each dataset consists of two integers x and y separated by a single space.
The input ends with two 0 (when both x and y are zero). Your program should not process for these terminal symbols.
Output
For each dataset, print x and y in ascending order in a line. Put a single space between x and y.
Example
Input
3 2
2 2
5 3
0 0
Output
2 3
2 2
3 5 | instruction | 0 | 22,828 | 5 | 45,656 |
"Correct Solution:
```
l=list(map(int,input().split()))
while l!=[0,0]:
print(min(l),max(l))
l=list(map(int,input().split()))
``` | output | 1 | 22,828 | 5 | 45,657 |
Provide a correct Python 3 solution for this coding contest problem.
Write a program which reads two integers x and y, and prints them in ascending order.
Constraints
* 0 ≤ x, y ≤ 10000
* the number of datasets ≤ 3000
Input
The input consists of multiple datasets. Each dataset consists of two integers x and y separated by a single space.
The input ends with two 0 (when both x and y are zero). Your program should not process for these terminal symbols.
Output
For each dataset, print x and y in ascending order in a line. Put a single space between x and y.
Example
Input
3 2
2 2
5 3
0 0
Output
2 3
2 2
3 5 | instruction | 0 | 22,829 | 5 | 45,658 |
"Correct Solution:
```
while 1:
x,y = map(int,input().split())
if (x,y) == (0,0):
break
if x > y:
x,y = y,x
print(x,y)
``` | output | 1 | 22,829 | 5 | 45,659 |
Provide a correct Python 3 solution for this coding contest problem.
Write a program which reads two integers x and y, and prints them in ascending order.
Constraints
* 0 ≤ x, y ≤ 10000
* the number of datasets ≤ 3000
Input
The input consists of multiple datasets. Each dataset consists of two integers x and y separated by a single space.
The input ends with two 0 (when both x and y are zero). Your program should not process for these terminal symbols.
Output
For each dataset, print x and y in ascending order in a line. Put a single space between x and y.
Example
Input
3 2
2 2
5 3
0 0
Output
2 3
2 2
3 5 | instruction | 0 | 22,830 | 5 | 45,660 |
"Correct Solution:
```
while True:
a = sorted(list(map(int,input().split())))
if a[0] == 0 and a[1] == 0:
break
print(a[0],a[1])
``` | output | 1 | 22,830 | 5 | 45,661 |
Provide a correct Python 3 solution for this coding contest problem.
Write a program which reads two integers x and y, and prints them in ascending order.
Constraints
* 0 ≤ x, y ≤ 10000
* the number of datasets ≤ 3000
Input
The input consists of multiple datasets. Each dataset consists of two integers x and y separated by a single space.
The input ends with two 0 (when both x and y are zero). Your program should not process for these terminal symbols.
Output
For each dataset, print x and y in ascending order in a line. Put a single space between x and y.
Example
Input
3 2
2 2
5 3
0 0
Output
2 3
2 2
3 5 | instruction | 0 | 22,831 | 5 | 45,662 |
"Correct Solution:
```
while(True):
a,b=map(int,input().split())
if a==0 and b==0:
break
if a>b:
a,b=b,a
print(a,b)
``` | output | 1 | 22,831 | 5 | 45,663 |
Provide a correct Python 3 solution for this coding contest problem.
Write a program which reads two integers x and y, and prints them in ascending order.
Constraints
* 0 ≤ x, y ≤ 10000
* the number of datasets ≤ 3000
Input
The input consists of multiple datasets. Each dataset consists of two integers x and y separated by a single space.
The input ends with two 0 (when both x and y are zero). Your program should not process for these terminal symbols.
Output
For each dataset, print x and y in ascending order in a line. Put a single space between x and y.
Example
Input
3 2
2 2
5 3
0 0
Output
2 3
2 2
3 5 | instruction | 0 | 22,832 | 5 | 45,664 |
"Correct Solution:
```
for i in range(3000):
a,b=map(int,input().split())
if a==0 and b==0:
break
elif a<=b:
print(a,b)
else:
print(b,a)
``` | output | 1 | 22,832 | 5 | 45,665 |
Provide a correct Python 3 solution for this coding contest problem.
Write a program which reads two integers x and y, and prints them in ascending order.
Constraints
* 0 ≤ x, y ≤ 10000
* the number of datasets ≤ 3000
Input
The input consists of multiple datasets. Each dataset consists of two integers x and y separated by a single space.
The input ends with two 0 (when both x and y are zero). Your program should not process for these terminal symbols.
Output
For each dataset, print x and y in ascending order in a line. Put a single space between x and y.
Example
Input
3 2
2 2
5 3
0 0
Output
2 3
2 2
3 5 | instruction | 0 | 22,833 | 5 | 45,666 |
"Correct Solution:
```
while 1:
a=input()
if a=='0 0':break
print(*sorted(map(int,a.split())))
``` | output | 1 | 22,833 | 5 | 45,667 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Write a program which reads two integers x and y, and prints them in ascending order.
Constraints
* 0 ≤ x, y ≤ 10000
* the number of datasets ≤ 3000
Input
The input consists of multiple datasets. Each dataset consists of two integers x and y separated by a single space.
The input ends with two 0 (when both x and y are zero). Your program should not process for these terminal symbols.
Output
For each dataset, print x and y in ascending order in a line. Put a single space between x and y.
Example
Input
3 2
2 2
5 3
0 0
Output
2 3
2 2
3 5
Submitted Solution:
```
while True:
xs = sorted(map(int,input().split()))
if sum(xs) == 0: break
print(*xs)
``` | instruction | 0 | 22,834 | 5 | 45,668 |
Yes | output | 1 | 22,834 | 5 | 45,669 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Write a program which reads two integers x and y, and prints them in ascending order.
Constraints
* 0 ≤ x, y ≤ 10000
* the number of datasets ≤ 3000
Input
The input consists of multiple datasets. Each dataset consists of two integers x and y separated by a single space.
The input ends with two 0 (when both x and y are zero). Your program should not process for these terminal symbols.
Output
For each dataset, print x and y in ascending order in a line. Put a single space between x and y.
Example
Input
3 2
2 2
5 3
0 0
Output
2 3
2 2
3 5
Submitted Solution:
```
import sys
for line in sys.stdin:
xy = sorted(map(int , line.split()))
if xy[0] == 0 and xy[1] == 0: break
print(*xy)
``` | instruction | 0 | 22,835 | 5 | 45,670 |
Yes | output | 1 | 22,835 | 5 | 45,671 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Write a program which reads two integers x and y, and prints them in ascending order.
Constraints
* 0 ≤ x, y ≤ 10000
* the number of datasets ≤ 3000
Input
The input consists of multiple datasets. Each dataset consists of two integers x and y separated by a single space.
The input ends with two 0 (when both x and y are zero). Your program should not process for these terminal symbols.
Output
For each dataset, print x and y in ascending order in a line. Put a single space between x and y.
Example
Input
3 2
2 2
5 3
0 0
Output
2 3
2 2
3 5
Submitted Solution:
```
while True:
a, b = map(int, input().split())
if a == 0 and b == 0: break
print(a if a < b else b, b if a < b else a)
``` | instruction | 0 | 22,836 | 5 | 45,672 |
Yes | output | 1 | 22,836 | 5 | 45,673 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Write a program which reads two integers x and y, and prints them in ascending order.
Constraints
* 0 ≤ x, y ≤ 10000
* the number of datasets ≤ 3000
Input
The input consists of multiple datasets. Each dataset consists of two integers x and y separated by a single space.
The input ends with two 0 (when both x and y are zero). Your program should not process for these terminal symbols.
Output
For each dataset, print x and y in ascending order in a line. Put a single space between x and y.
Example
Input
3 2
2 2
5 3
0 0
Output
2 3
2 2
3 5
Submitted Solution:
```
while True:
a,b=input().split()
a=int(a)
b=int(b)
if a ==0 and b==0:break
if a>b:a,b=b,a
print(a,b)
``` | instruction | 0 | 22,837 | 5 | 45,674 |
Yes | output | 1 | 22,837 | 5 | 45,675 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Write a program which reads two integers x and y, and prints them in ascending order.
Constraints
* 0 ≤ x, y ≤ 10000
* the number of datasets ≤ 3000
Input
The input consists of multiple datasets. Each dataset consists of two integers x and y separated by a single space.
The input ends with two 0 (when both x and y are zero). Your program should not process for these terminal symbols.
Output
For each dataset, print x and y in ascending order in a line. Put a single space between x and y.
Example
Input
3 2
2 2
5 3
0 0
Output
2 3
2 2
3 5
Submitted Solution:
```
x,y = input().split()
if x > y:
print(y,x)
print(x,y)
``` | instruction | 0 | 22,838 | 5 | 45,676 |
No | output | 1 | 22,838 | 5 | 45,677 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Write a program which reads two integers x and y, and prints them in ascending order.
Constraints
* 0 ≤ x, y ≤ 10000
* the number of datasets ≤ 3000
Input
The input consists of multiple datasets. Each dataset consists of two integers x and y separated by a single space.
The input ends with two 0 (when both x and y are zero). Your program should not process for these terminal symbols.
Output
For each dataset, print x and y in ascending order in a line. Put a single space between x and y.
Example
Input
3 2
2 2
5 3
0 0
Output
2 3
2 2
3 5
Submitted Solution:
```
x,y=input().split()
while (x!='0'and y!='0'):
if(x>y):print("{} {}".format(y,x))
else:print("{} {}".format(x,y))
x,y=input().split()
``` | instruction | 0 | 22,839 | 5 | 45,678 |
No | output | 1 | 22,839 | 5 | 45,679 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Write a program which reads two integers x and y, and prints them in ascending order.
Constraints
* 0 ≤ x, y ≤ 10000
* the number of datasets ≤ 3000
Input
The input consists of multiple datasets. Each dataset consists of two integers x and y separated by a single space.
The input ends with two 0 (when both x and y are zero). Your program should not process for these terminal symbols.
Output
For each dataset, print x and y in ascending order in a line. Put a single space between x and y.
Example
Input
3 2
2 2
5 3
0 0
Output
2 3
2 2
3 5
Submitted Solution:
```
x,y = map(int, input().split())
while (x,y) == (0,0):
if x < y:
print(x,y)
else:
print(y,x)
``` | instruction | 0 | 22,840 | 5 | 45,680 |
No | output | 1 | 22,840 | 5 | 45,681 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Write a program which reads two integers x and y, and prints them in ascending order.
Constraints
* 0 ≤ x, y ≤ 10000
* the number of datasets ≤ 3000
Input
The input consists of multiple datasets. Each dataset consists of two integers x and y separated by a single space.
The input ends with two 0 (when both x and y are zero). Your program should not process for these terminal symbols.
Output
For each dataset, print x and y in ascending order in a line. Put a single space between x and y.
Example
Input
3 2
2 2
5 3
0 0
Output
2 3
2 2
3 5
Submitted Solution:
```
a, b = input().split()
while not a == "0" and b == "0":
print(b + " " + a)
a, b = input().split()
``` | instruction | 0 | 22,841 | 5 | 45,682 |
No | output | 1 | 22,841 | 5 | 45,683 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Calculate the value of the sum: n mod 1 + n mod 2 + n mod 3 + ... + n mod m. As the result can be very large, you should print the value modulo 109 + 7 (the remainder when divided by 109 + 7).
The modulo operator a mod b stands for the remainder after dividing a by b. For example 10 mod 3 = 1.
Input
The only line contains two integers n, m (1 ≤ n, m ≤ 1013) — the parameters of the sum.
Output
Print integer s — the value of the required sum modulo 109 + 7.
Examples
Input
3 4
Output
4
Input
4 4
Output
1
Input
1 1
Output
0
Submitted Solution:
```
n,m=map(int,input().split())
s=0
for i in range(1,m+1):
s+=(n%i)
print(s)
``` | instruction | 0 | 23,334 | 5 | 46,668 |
No | output | 1 | 23,334 | 5 | 46,669 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Calculate the value of the sum: n mod 1 + n mod 2 + n mod 3 + ... + n mod m. As the result can be very large, you should print the value modulo 109 + 7 (the remainder when divided by 109 + 7).
The modulo operator a mod b stands for the remainder after dividing a by b. For example 10 mod 3 = 1.
Input
The only line contains two integers n, m (1 ≤ n, m ≤ 1013) — the parameters of the sum.
Output
Print integer s — the value of the required sum modulo 109 + 7.
Examples
Input
3 4
Output
4
Input
4 4
Output
1
Input
1 1
Output
0
Submitted Solution:
```
import math
n,m=map(int, input().split())
q=int(math.sqrt(n))
s=sum([n%i for i in range(1,min(m,q))])
if m>q:
a1=n-q-1
a2=n-min(m,n)
s+=((a2+a1)*(a1-a2+1))//2
if m>n:
s+=(m-n)*n
print(s%(10**9+7))
``` | instruction | 0 | 23,335 | 5 | 46,670 |
No | output | 1 | 23,335 | 5 | 46,671 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Calculate the value of the sum: n mod 1 + n mod 2 + n mod 3 + ... + n mod m. As the result can be very large, you should print the value modulo 109 + 7 (the remainder when divided by 109 + 7).
The modulo operator a mod b stands for the remainder after dividing a by b. For example 10 mod 3 = 1.
Input
The only line contains two integers n, m (1 ≤ n, m ≤ 1013) — the parameters of the sum.
Output
Print integer s — the value of the required sum modulo 109 + 7.
Examples
Input
3 4
Output
4
Input
4 4
Output
1
Input
1 1
Output
0
Submitted Solution:
```
n, m = map(int, input().split())
print( (m * (m-1)//2 * (n//m) + n % m * (n % m + 1)//2) % (10**9 + 7))
``` | instruction | 0 | 23,336 | 5 | 46,672 |
No | output | 1 | 23,336 | 5 | 46,673 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Calculate the value of the sum: n mod 1 + n mod 2 + n mod 3 + ... + n mod m. As the result can be very large, you should print the value modulo 109 + 7 (the remainder when divided by 109 + 7).
The modulo operator a mod b stands for the remainder after dividing a by b. For example 10 mod 3 = 1.
Input
The only line contains two integers n, m (1 ≤ n, m ≤ 1013) — the parameters of the sum.
Output
Print integer s — the value of the required sum modulo 109 + 7.
Examples
Input
3 4
Output
4
Input
4 4
Output
1
Input
1 1
Output
0
Submitted Solution:
```
a,b=map(int,input().split())
ans=0
i=1
while(i!=(b+1)):
ans+=(a%i)
i+=1
print(ans)
``` | instruction | 0 | 23,337 | 5 | 46,674 |
No | output | 1 | 23,337 | 5 | 46,675 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
We have a pyramid with N steps, built with blocks. The steps are numbered 1 through N from top to bottom. For each 1≤i≤N, step i consists of 2i-1 blocks aligned horizontally. The pyramid is built so that the blocks at the centers of the steps are aligned vertically.
<image>
A pyramid with N=4 steps
Snuke wrote a permutation of (1, 2, ..., 2N-1) into the blocks of step N. Then, he wrote integers into all remaining blocks, under the following rule:
* The integer written into a block b must be equal to the median of the three integers written into the three blocks directly under b, or to the lower left or lower right of b.
<image>
Writing integers into the blocks
Afterwards, he erased all integers written into the blocks. Now, he only remembers that the permutation written into the blocks of step N was (a_1, a_2, ..., a_{2N-1}).
Find the integer written into the block of step 1.
Constraints
* 2≤N≤10^5
* (a_1, a_2, ..., a_{2N-1}) is a permutation of (1, 2, ..., 2N-1).
Input
The input is given from Standard Input in the following format:
N
a_1 a_2 ... a_{2N-1}
Output
Print the integer written into the block of step 1.
Examples
Input
4
1 6 3 7 4 5 2
Output
4
Input
2
1 2 3
Output
2
Submitted Solution:
```
#editorial
#ある数以下、以上が連続していればそれが保持
n = int(input())
*a,=map(int, input().split())
mx=2*n+1
mn=0
while mx-mn>1:
mid=(mx+mn)//2
for i in range(n-1):
if (a[n+i-1]>=mid & a[n+i]>=mid) |( a[n-i-1]>=mid & a[n-2-i]>=mid):
mn=mid
break
if (a[n+i-1]<mid & a[n+i]<mid) |( a[n-i-1]<mid & a[n-2-i]<mid):
mx=mid
break
mx=mid
print(mn)
``` | instruction | 0 | 23,706 | 5 | 47,412 |
No | output | 1 | 23,706 | 5 | 47,413 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given a integer n (n > 0). Find any integer s which satisfies these conditions, or report that there are no such numbers:
In the decimal representation of s:
* s > 0,
* s consists of n digits,
* no digit in s equals 0,
* s is not divisible by any of it's digits.
Input
The input consists of multiple test cases. The first line of the input contains a single integer t (1 ≤ t ≤ 400), the number of test cases. The next t lines each describe a test case.
Each test case contains one positive integer n (1 ≤ n ≤ 10^5).
It is guaranteed that the sum of n for all test cases does not exceed 10^5.
Output
For each test case, print an integer s which satisfies the conditions described above, or "-1" (without quotes), if no such number exists. If there are multiple possible solutions for s, print any solution.
Example
Input
4
1
2
3
4
Output
-1
57
239
6789
Note
In the first test case, there are no possible solutions for s consisting of one digit, because any such solution is divisible by itself.
For the second test case, the possible solutions are: 23, 27, 29, 34, 37, 38, 43, 46, 47, 49, 53, 54, 56, 57, 58, 59, 67, 68, 69, 73, 74, 76, 78, 79, 83, 86, 87, 89, 94, 97, and 98.
For the third test case, one possible solution is 239 because 239 is not divisible by 2, 3 or 9 and has three digits (none of which equals zero).
Submitted Solution:
```
for _ in range(int(input())):
n=int(input())
if n==1:
print(-1)
else:
s="5"*(n-1)+"4"
print(s)
``` | instruction | 0 | 23,966 | 5 | 47,932 |
Yes | output | 1 | 23,966 | 5 | 47,933 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given a integer n (n > 0). Find any integer s which satisfies these conditions, or report that there are no such numbers:
In the decimal representation of s:
* s > 0,
* s consists of n digits,
* no digit in s equals 0,
* s is not divisible by any of it's digits.
Input
The input consists of multiple test cases. The first line of the input contains a single integer t (1 ≤ t ≤ 400), the number of test cases. The next t lines each describe a test case.
Each test case contains one positive integer n (1 ≤ n ≤ 10^5).
It is guaranteed that the sum of n for all test cases does not exceed 10^5.
Output
For each test case, print an integer s which satisfies the conditions described above, or "-1" (without quotes), if no such number exists. If there are multiple possible solutions for s, print any solution.
Example
Input
4
1
2
3
4
Output
-1
57
239
6789
Note
In the first test case, there are no possible solutions for s consisting of one digit, because any such solution is divisible by itself.
For the second test case, the possible solutions are: 23, 27, 29, 34, 37, 38, 43, 46, 47, 49, 53, 54, 56, 57, 58, 59, 67, 68, 69, 73, 74, 76, 78, 79, 83, 86, 87, 89, 94, 97, and 98.
For the third test case, one possible solution is 239 because 239 is not divisible by 2, 3 or 9 and has three digits (none of which equals zero).
Submitted Solution:
```
t=int(input())
for i in range(t):
n=int(input())
if(n==1):
print(-1)
else:
f=0
if(n%2==0):
ans='67'*(n//2)
else:
ans='67'*(n//2)+'6'
if(int(ans)%6==0):
if(ans[-1]=='6'):
ans=ans[:-1]+'7'
else:
ans=ans[:-1]+'6'
if(int(ans)%7==0):
if(ans[-1]=='6'):
ans=ans[:-1]+'7'
else:
ans=ans[:-1]+'6'
print(ans)
``` | instruction | 0 | 23,967 | 5 | 47,934 |
No | output | 1 | 23,967 | 5 | 47,935 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given a integer n (n > 0). Find any integer s which satisfies these conditions, or report that there are no such numbers:
In the decimal representation of s:
* s > 0,
* s consists of n digits,
* no digit in s equals 0,
* s is not divisible by any of it's digits.
Input
The input consists of multiple test cases. The first line of the input contains a single integer t (1 ≤ t ≤ 400), the number of test cases. The next t lines each describe a test case.
Each test case contains one positive integer n (1 ≤ n ≤ 10^5).
It is guaranteed that the sum of n for all test cases does not exceed 10^5.
Output
For each test case, print an integer s which satisfies the conditions described above, or "-1" (without quotes), if no such number exists. If there are multiple possible solutions for s, print any solution.
Example
Input
4
1
2
3
4
Output
-1
57
239
6789
Note
In the first test case, there are no possible solutions for s consisting of one digit, because any such solution is divisible by itself.
For the second test case, the possible solutions are: 23, 27, 29, 34, 37, 38, 43, 46, 47, 49, 53, 54, 56, 57, 58, 59, 67, 68, 69, 73, 74, 76, 78, 79, 83, 86, 87, 89, 94, 97, and 98.
For the third test case, one possible solution is 239 because 239 is not divisible by 2, 3 or 9 and has three digits (none of which equals zero).
Submitted Solution:
```
for _ in range(int(input())):
n = int(input())
s = '2'*(n-1)
if(n==1):
print(-1)
continue
t = s
print(s+'3')
``` | instruction | 0 | 23,970 | 5 | 47,940 |
No | output | 1 | 23,970 | 5 | 47,941 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given a sequence a consisting of n integers. Find the maximum possible value of <image> (integer remainder of ai divided by aj), where 1 ≤ i, j ≤ n and ai ≥ aj.
Input
The first line contains integer n — the length of the sequence (1 ≤ n ≤ 2·105).
The second line contains n space-separated integers ai (1 ≤ ai ≤ 106).
Output
Print the answer to the problem.
Examples
Input
3
3 4 5
Output
2 | instruction | 0 | 24,219 | 5 | 48,438 |
Tags: binary search, math, sortings, two pointers
Correct Solution:
```
n = int(input())
a = list(set(map(int, input().split())))
mx = max(a)
b = [0] * (2 * mx)
for e in a:
b[e] = e
for i in range(1, len(b)):
if b[i] == 0:
b[i] = b[i - 1]
best = 0
for e in a:
for m in range(2 * e, 2 * mx, e):
if b[m - 1] >= e:
best = max(best, b[m - 1] % e)
print(best)
``` | output | 1 | 24,219 | 5 | 48,439 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given a sequence a consisting of n integers. Find the maximum possible value of <image> (integer remainder of ai divided by aj), where 1 ≤ i, j ≤ n and ai ≥ aj.
Input
The first line contains integer n — the length of the sequence (1 ≤ n ≤ 2·105).
The second line contains n space-separated integers ai (1 ≤ ai ≤ 106).
Output
Print the answer to the problem.
Examples
Input
3
3 4 5
Output
2 | instruction | 0 | 24,222 | 5 | 48,444 |
Tags: binary search, math, sortings, two pointers
Correct Solution:
```
def main():
input()
aa = sorted(map(int, input().split()))
maxa = max(aa)
m = [False] * (maxa + 1)
x = []
b = 0
for a in aa:
if b != a:
m[a] = True
for i in range(b, a):
x.append(b)
b = a
x.append(b)
ans = 0
for i in range(maxa - 1, 1, -1):
if i < ans:
break
if m[i]:
for j in range(1, maxa // i + 1):
ans = max(ans, x[min(i * (j + 1) - 1, maxa)] % i)
print(ans)
if __name__ == '__main__':
main()
``` | output | 1 | 24,222 | 5 | 48,445 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given a sequence a consisting of n integers. Find the maximum possible value of <image> (integer remainder of ai divided by aj), where 1 ≤ i, j ≤ n and ai ≥ aj.
Input
The first line contains integer n — the length of the sequence (1 ≤ n ≤ 2·105).
The second line contains n space-separated integers ai (1 ≤ ai ≤ 106).
Output
Print the answer to the problem.
Examples
Input
3
3 4 5
Output
2
Submitted Solution:
```
input()
d = [0] * 2000000
for k in map(int, input().split()): d[k] = 1
for i in range(len(d)): d[i] = i if d[i] else d[i - 1]
m = 0
for i in range(999999, 0, -1):
if d[i] == i and i > m + 1: m = max(m, max(j % i for j in d[2 * i - 1::i]))
print(m)
``` | instruction | 0 | 24,224 | 5 | 48,448 |
Yes | output | 1 | 24,224 | 5 | 48,449 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given a sequence a consisting of n integers. Find the maximum possible value of <image> (integer remainder of ai divided by aj), where 1 ≤ i, j ≤ n and ai ≥ aj.
Input
The first line contains integer n — the length of the sequence (1 ≤ n ≤ 2·105).
The second line contains n space-separated integers ai (1 ≤ ai ≤ 106).
Output
Print the answer to the problem.
Examples
Input
3
3 4 5
Output
2
Submitted Solution:
```
import sys
# sys.stdin = open('input.txt', 'r')
# sys.stdout = open('output.txt', 'w')
input = sys.stdin.readline
t = 1
while t:
t -= 1
n = int(input())
a = sorted(list(set(map(int, input().split()))))
m = 2*a[-1]
prev = [0]*(m+1)
ans = 0
j = 0
for el in a:
prev[el+1] = el
for i in range(1, len(prev)):
if not prev[i]:
prev[i] = prev[i-1]
for el in a:
k = 2
while k*el <= m:
ans = max(ans, prev[k*el]%el)
k += 1
print(ans)
``` | instruction | 0 | 24,225 | 5 | 48,450 |
Yes | output | 1 | 24,225 | 5 | 48,451 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given a sequence a consisting of n integers. Find the maximum possible value of <image> (integer remainder of ai divided by aj), where 1 ≤ i, j ≤ n and ai ≥ aj.
Input
The first line contains integer n — the length of the sequence (1 ≤ n ≤ 2·105).
The second line contains n space-separated integers ai (1 ≤ ai ≤ 106).
Output
Print the answer to the problem.
Examples
Input
3
3 4 5
Output
2
Submitted Solution:
```
def main():
input()
aa = sorted(set(map(int, input().split())))
x = []
b = res = 0
for a in aa:
x += [b] * (a - b)
b = a
x.append(b)
maxa = aa.pop()
for a in reversed(aa):
if a <= res:
break
res = max(res, maxa % a, *[b % a for b in x[2 * a - 1::a]])
print(res)
if __name__ == '__main__':
main()
``` | instruction | 0 | 24,226 | 5 | 48,452 |
Yes | output | 1 | 24,226 | 5 | 48,453 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given a sequence a consisting of n integers. Find the maximum possible value of <image> (integer remainder of ai divided by aj), where 1 ≤ i, j ≤ n and ai ≥ aj.
Input
The first line contains integer n — the length of the sequence (1 ≤ n ≤ 2·105).
The second line contains n space-separated integers ai (1 ≤ ai ≤ 106).
Output
Print the answer to the problem.
Examples
Input
3
3 4 5
Output
2
Submitted Solution:
```
def main():
input()
aa = sorted(set(map(int, input().split())))
x = []
b = res = 0
for a in aa:
x += [b] * (a - b)
b = a
x.append(b)
maxa = aa.pop()
for a in reversed(aa):
if a < res:
break
res = max(res, maxa % a, *[b % a for b in x[2 * a - 1::a]])
print(res)
if __name__ == '__main__':
main()
``` | instruction | 0 | 24,227 | 5 | 48,454 |
Yes | output | 1 | 24,227 | 5 | 48,455 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.