text stringlengths 198 433k | conversation_id int64 0 109k |
|---|---|
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
We have N logs of lengths A_1,A_2,\cdots A_N.
We can cut these logs at most K times in total. When a log of length L is cut at a point whose distance from an end of the log is t (0<t<L), it becomes two logs of lengths t and L-t.
Find the shortest possible length of the longest log after at most K cuts, and print it after rounding up to an integer.
Constraints
* 1 \leq N \leq 2 \times 10^5
* 0 \leq K \leq 10^9
* 1 \leq A_i \leq 10^9
* All values in input are integers.
Input
Input is given from Standard Input in the following format:
N K
A_1 A_2 \cdots A_N
Output
Print an integer representing the answer.
Examples
Input
2 3
7 9
Output
4
Input
3 0
3 4 5
Output
5
Input
10 10
158260522 877914575 602436426 24979445 861648772 623690081 433933447 476190629 262703497 211047202
Output
292638192
Submitted Solution:
```
def resolve():
import heapq
n, k = map(int, input().split())
a = list(map(int, input().split()))
q = []
for index, i in enumerate(a):
heapq.heappush(q, (-i, index, 1))
for _ in range(k):
length, index, count = heapq.heappop(q)
heapq.heappush(q, (-((a[index] + count) //
(count + 1)), index, count + 1))
length, index, count = heapq.heappop(q)
print((a[index] + count - 1) // count)
if __name__ == '__main__':
resolve()
```
No
| 102,700 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
We have N logs of lengths A_1,A_2,\cdots A_N.
We can cut these logs at most K times in total. When a log of length L is cut at a point whose distance from an end of the log is t (0<t<L), it becomes two logs of lengths t and L-t.
Find the shortest possible length of the longest log after at most K cuts, and print it after rounding up to an integer.
Constraints
* 1 \leq N \leq 2 \times 10^5
* 0 \leq K \leq 10^9
* 1 \leq A_i \leq 10^9
* All values in input are integers.
Input
Input is given from Standard Input in the following format:
N K
A_1 A_2 \cdots A_N
Output
Print an integer representing the answer.
Examples
Input
2 3
7 9
Output
4
Input
3 0
3 4 5
Output
5
Input
10 10
158260522 877914575 602436426 24979445 861648772 623690081 433933447 476190629 262703497 211047202
Output
292638192
Submitted Solution:
```
# Binary Search
def isOK(i, key):
'''
問題に応じて返り値を設定
'''
cnt = 0
for v in a:
cnt += (v + i - 1) // i - 1
return cnt <= key
def binary_search(key):
'''
条件を満たす最小/最大のindexを求める
O(logN)
'''
ok = 10 ** 9 # 条件を満たすindexの上限値/下限値
ng = -1 # 条件を満たさないindexの下限値-1/上限値+1
while abs(ok - ng) > 1:
mid = (ok + ng) // 2
if isOK(mid, key): # midが条件を満たすか否か
ok = mid
else:
ng = mid
return ok
n, k = map(int, input().split())
a = list(map(int, input().split()))
print(binary_search(k))
```
No
| 102,701 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
We have N logs of lengths A_1,A_2,\cdots A_N.
We can cut these logs at most K times in total. When a log of length L is cut at a point whose distance from an end of the log is t (0<t<L), it becomes two logs of lengths t and L-t.
Find the shortest possible length of the longest log after at most K cuts, and print it after rounding up to an integer.
Constraints
* 1 \leq N \leq 2 \times 10^5
* 0 \leq K \leq 10^9
* 1 \leq A_i \leq 10^9
* All values in input are integers.
Input
Input is given from Standard Input in the following format:
N K
A_1 A_2 \cdots A_N
Output
Print an integer representing the answer.
Examples
Input
2 3
7 9
Output
4
Input
3 0
3 4 5
Output
5
Input
10 10
158260522 877914575 602436426 24979445 861648772 623690081 433933447 476190629 262703497 211047202
Output
292638192
Submitted Solution:
```
import heapq
ceil = lambda a, b: (a + b - 1) // b
N, K = map(int, input().split())
A = tuple(map(int, input().split()))
h = [(-a, a, 1) for a in A]
heapq.heapify(h)
for _ in range(K):
l, a, ct = heapq.heappop(h)
ct += 1
heapq.heappush(h, (-a / ct, a, ct))
_, a, ct = heapq.heappop(h)
print(ceil(a, ct))
```
No
| 102,702 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
We have N logs of lengths A_1,A_2,\cdots A_N.
We can cut these logs at most K times in total. When a log of length L is cut at a point whose distance from an end of the log is t (0<t<L), it becomes two logs of lengths t and L-t.
Find the shortest possible length of the longest log after at most K cuts, and print it after rounding up to an integer.
Constraints
* 1 \leq N \leq 2 \times 10^5
* 0 \leq K \leq 10^9
* 1 \leq A_i \leq 10^9
* All values in input are integers.
Input
Input is given from Standard Input in the following format:
N K
A_1 A_2 \cdots A_N
Output
Print an integer representing the answer.
Examples
Input
2 3
7 9
Output
4
Input
3 0
3 4 5
Output
5
Input
10 10
158260522 877914575 602436426 24979445 861648772 623690081 433933447 476190629 262703497 211047202
Output
292638192
Submitted Solution:
```
n, k = map(int, input().split())
a = list(map(int, input().split()))
def check(x):
c = 0
for i in range(n):
c += a[i]//x
if c <= k:
return True
else:
return False
mx = max(a)
mn = 0
ans = [mx]
while mn <= mx:
m = (mx+mn)//2
if check(m):
mx = m - 1
ans.append(m)
else:
mn = m + 1
print (min(ans))
```
No
| 102,703 |
Provide a correct Python 3 solution for this coding contest problem.
We have N+M balls, each of which has an integer written on it.
It is known that:
* The numbers written on N of the balls are even.
* The numbers written on M of the balls are odd.
Find the number of ways to choose two of the N+M balls (disregarding order) so that the sum of the numbers written on them is even.
It can be shown that this count does not depend on the actual values written on the balls.
Constraints
* 0 \leq N,M \leq 100
* 2 \leq N+M
* All values in input are integers.
Input
Input is given from Standard Input in the following format:
N M
Output
Print the answer.
Examples
Input
2 1
Output
1
Input
4 3
Output
9
Input
1 1
Output
0
Input
13 3
Output
81
Input
0 3
Output
3
"Correct Solution:
```
N,M=map(int,input().split())
print((M*(M-1)+N*(N-1))//2)
```
| 102,704 |
Provide a correct Python 3 solution for this coding contest problem.
We have N+M balls, each of which has an integer written on it.
It is known that:
* The numbers written on N of the balls are even.
* The numbers written on M of the balls are odd.
Find the number of ways to choose two of the N+M balls (disregarding order) so that the sum of the numbers written on them is even.
It can be shown that this count does not depend on the actual values written on the balls.
Constraints
* 0 \leq N,M \leq 100
* 2 \leq N+M
* All values in input are integers.
Input
Input is given from Standard Input in the following format:
N M
Output
Print the answer.
Examples
Input
2 1
Output
1
Input
4 3
Output
9
Input
1 1
Output
0
Input
13 3
Output
81
Input
0 3
Output
3
"Correct Solution:
```
N,M = map(int,input().split())
all = (M*(M-1)+N*(N-1))//2
print(all)
```
| 102,705 |
Provide a correct Python 3 solution for this coding contest problem.
We have N+M balls, each of which has an integer written on it.
It is known that:
* The numbers written on N of the balls are even.
* The numbers written on M of the balls are odd.
Find the number of ways to choose two of the N+M balls (disregarding order) so that the sum of the numbers written on them is even.
It can be shown that this count does not depend on the actual values written on the balls.
Constraints
* 0 \leq N,M \leq 100
* 2 \leq N+M
* All values in input are integers.
Input
Input is given from Standard Input in the following format:
N M
Output
Print the answer.
Examples
Input
2 1
Output
1
Input
4 3
Output
9
Input
1 1
Output
0
Input
13 3
Output
81
Input
0 3
Output
3
"Correct Solution:
```
n,m = map(int,input().split())
print((m*(m-1))//2+(n*(n-1))//2)
```
| 102,706 |
Provide a correct Python 3 solution for this coding contest problem.
We have N+M balls, each of which has an integer written on it.
It is known that:
* The numbers written on N of the balls are even.
* The numbers written on M of the balls are odd.
Find the number of ways to choose two of the N+M balls (disregarding order) so that the sum of the numbers written on them is even.
It can be shown that this count does not depend on the actual values written on the balls.
Constraints
* 0 \leq N,M \leq 100
* 2 \leq N+M
* All values in input are integers.
Input
Input is given from Standard Input in the following format:
N M
Output
Print the answer.
Examples
Input
2 1
Output
1
Input
4 3
Output
9
Input
1 1
Output
0
Input
13 3
Output
81
Input
0 3
Output
3
"Correct Solution:
```
a,b=map(int,input().split())
print(int(a*(a-1)/2+b*(b-1)//2))
```
| 102,707 |
Provide a correct Python 3 solution for this coding contest problem.
We have N+M balls, each of which has an integer written on it.
It is known that:
* The numbers written on N of the balls are even.
* The numbers written on M of the balls are odd.
Find the number of ways to choose two of the N+M balls (disregarding order) so that the sum of the numbers written on them is even.
It can be shown that this count does not depend on the actual values written on the balls.
Constraints
* 0 \leq N,M \leq 100
* 2 \leq N+M
* All values in input are integers.
Input
Input is given from Standard Input in the following format:
N M
Output
Print the answer.
Examples
Input
2 1
Output
1
Input
4 3
Output
9
Input
1 1
Output
0
Input
13 3
Output
81
Input
0 3
Output
3
"Correct Solution:
```
m,n = map(int, input().split())
print(n*(n-1)//2+m*(m-1)//2)
```
| 102,708 |
Provide a correct Python 3 solution for this coding contest problem.
We have N+M balls, each of which has an integer written on it.
It is known that:
* The numbers written on N of the balls are even.
* The numbers written on M of the balls are odd.
Find the number of ways to choose two of the N+M balls (disregarding order) so that the sum of the numbers written on them is even.
It can be shown that this count does not depend on the actual values written on the balls.
Constraints
* 0 \leq N,M \leq 100
* 2 \leq N+M
* All values in input are integers.
Input
Input is given from Standard Input in the following format:
N M
Output
Print the answer.
Examples
Input
2 1
Output
1
Input
4 3
Output
9
Input
1 1
Output
0
Input
13 3
Output
81
Input
0 3
Output
3
"Correct Solution:
```
N,M = map(int,input().split())
print(((N-1)*N+(M-1)*M)//2)
```
| 102,709 |
Provide a correct Python 3 solution for this coding contest problem.
We have N+M balls, each of which has an integer written on it.
It is known that:
* The numbers written on N of the balls are even.
* The numbers written on M of the balls are odd.
Find the number of ways to choose two of the N+M balls (disregarding order) so that the sum of the numbers written on them is even.
It can be shown that this count does not depend on the actual values written on the balls.
Constraints
* 0 \leq N,M \leq 100
* 2 \leq N+M
* All values in input are integers.
Input
Input is given from Standard Input in the following format:
N M
Output
Print the answer.
Examples
Input
2 1
Output
1
Input
4 3
Output
9
Input
1 1
Output
0
Input
13 3
Output
81
Input
0 3
Output
3
"Correct Solution:
```
n,m = map(int,input().split())
print(((n*(n-1)) + m*(m-1))//2)
```
| 102,710 |
Provide a correct Python 3 solution for this coding contest problem.
We have N+M balls, each of which has an integer written on it.
It is known that:
* The numbers written on N of the balls are even.
* The numbers written on M of the balls are odd.
Find the number of ways to choose two of the N+M balls (disregarding order) so that the sum of the numbers written on them is even.
It can be shown that this count does not depend on the actual values written on the balls.
Constraints
* 0 \leq N,M \leq 100
* 2 \leq N+M
* All values in input are integers.
Input
Input is given from Standard Input in the following format:
N M
Output
Print the answer.
Examples
Input
2 1
Output
1
Input
4 3
Output
9
Input
1 1
Output
0
Input
13 3
Output
81
Input
0 3
Output
3
"Correct Solution:
```
a, b = map(int, input().split())
y=a*(a-1)/2+b*(b-1)/2
print(int(y))
```
| 102,711 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
We have N+M balls, each of which has an integer written on it.
It is known that:
* The numbers written on N of the balls are even.
* The numbers written on M of the balls are odd.
Find the number of ways to choose two of the N+M balls (disregarding order) so that the sum of the numbers written on them is even.
It can be shown that this count does not depend on the actual values written on the balls.
Constraints
* 0 \leq N,M \leq 100
* 2 \leq N+M
* All values in input are integers.
Input
Input is given from Standard Input in the following format:
N M
Output
Print the answer.
Examples
Input
2 1
Output
1
Input
4 3
Output
9
Input
1 1
Output
0
Input
13 3
Output
81
Input
0 3
Output
3
Submitted Solution:
```
m, n = map(int, input().split())
print((m*(m-1) + n*(n-1))//2)
```
Yes
| 102,712 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
We have N+M balls, each of which has an integer written on it.
It is known that:
* The numbers written on N of the balls are even.
* The numbers written on M of the balls are odd.
Find the number of ways to choose two of the N+M balls (disregarding order) so that the sum of the numbers written on them is even.
It can be shown that this count does not depend on the actual values written on the balls.
Constraints
* 0 \leq N,M \leq 100
* 2 \leq N+M
* All values in input are integers.
Input
Input is given from Standard Input in the following format:
N M
Output
Print the answer.
Examples
Input
2 1
Output
1
Input
4 3
Output
9
Input
1 1
Output
0
Input
13 3
Output
81
Input
0 3
Output
3
Submitted Solution:
```
n,m=list(map(int,input().split()))
print(int((n**2+m**2-n-m)/2))
```
Yes
| 102,713 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
We have N+M balls, each of which has an integer written on it.
It is known that:
* The numbers written on N of the balls are even.
* The numbers written on M of the balls are odd.
Find the number of ways to choose two of the N+M balls (disregarding order) so that the sum of the numbers written on them is even.
It can be shown that this count does not depend on the actual values written on the balls.
Constraints
* 0 \leq N,M \leq 100
* 2 \leq N+M
* All values in input are integers.
Input
Input is given from Standard Input in the following format:
N M
Output
Print the answer.
Examples
Input
2 1
Output
1
Input
4 3
Output
9
Input
1 1
Output
0
Input
13 3
Output
81
Input
0 3
Output
3
Submitted Solution:
```
e,o = map(int,input().split())
print(e*(e-1)//2+o*(o-1)//2)
```
Yes
| 102,714 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
We have N+M balls, each of which has an integer written on it.
It is known that:
* The numbers written on N of the balls are even.
* The numbers written on M of the balls are odd.
Find the number of ways to choose two of the N+M balls (disregarding order) so that the sum of the numbers written on them is even.
It can be shown that this count does not depend on the actual values written on the balls.
Constraints
* 0 \leq N,M \leq 100
* 2 \leq N+M
* All values in input are integers.
Input
Input is given from Standard Input in the following format:
N M
Output
Print the answer.
Examples
Input
2 1
Output
1
Input
4 3
Output
9
Input
1 1
Output
0
Input
13 3
Output
81
Input
0 3
Output
3
Submitted Solution:
```
a,b=map(int,input().split())
print(int(a*(a-1)/2)+int(b*(b-1)/2))
```
Yes
| 102,715 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
We have N+M balls, each of which has an integer written on it.
It is known that:
* The numbers written on N of the balls are even.
* The numbers written on M of the balls are odd.
Find the number of ways to choose two of the N+M balls (disregarding order) so that the sum of the numbers written on them is even.
It can be shown that this count does not depend on the actual values written on the balls.
Constraints
* 0 \leq N,M \leq 100
* 2 \leq N+M
* All values in input are integers.
Input
Input is given from Standard Input in the following format:
N M
Output
Print the answer.
Examples
Input
2 1
Output
1
Input
4 3
Output
9
Input
1 1
Output
0
Input
13 3
Output
81
Input
0 3
Output
3
Submitted Solution:
```
n, m = input().split()
n = int(n)
m = int(m)
print(n!/(2 * (n-2)!) + m!/(2 * (n-2)!))
```
No
| 102,716 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
We have N+M balls, each of which has an integer written on it.
It is known that:
* The numbers written on N of the balls are even.
* The numbers written on M of the balls are odd.
Find the number of ways to choose two of the N+M balls (disregarding order) so that the sum of the numbers written on them is even.
It can be shown that this count does not depend on the actual values written on the balls.
Constraints
* 0 \leq N,M \leq 100
* 2 \leq N+M
* All values in input are integers.
Input
Input is given from Standard Input in the following format:
N M
Output
Print the answer.
Examples
Input
2 1
Output
1
Input
4 3
Output
9
Input
1 1
Output
0
Input
13 3
Output
81
Input
0 3
Output
3
Submitted Solution:
```
from math import factorial
def f(n, r):
return int(factorial(n) / factorial(r) / factorial(n - r))
N, M = map(int, input().split())
res = 0
if N >= 2:
res += f(N, 2)
if M >= 2:
res += f(M, 2)
print(res)
```
No
| 102,717 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
We have N+M balls, each of which has an integer written on it.
It is known that:
* The numbers written on N of the balls are even.
* The numbers written on M of the balls are odd.
Find the number of ways to choose two of the N+M balls (disregarding order) so that the sum of the numbers written on them is even.
It can be shown that this count does not depend on the actual values written on the balls.
Constraints
* 0 \leq N,M \leq 100
* 2 \leq N+M
* All values in input are integers.
Input
Input is given from Standard Input in the following format:
N M
Output
Print the answer.
Examples
Input
2 1
Output
1
Input
4 3
Output
9
Input
1 1
Output
0
Input
13 3
Output
81
Input
0 3
Output
3
Submitted Solution:
```
S = input()
L=len(S)
ans=0
if S[:int((L-1)/2)]==S[int((L-1)/2-1)::-1] and S[int((L+3)/2-1):]==S[:int((L+3)/2-2):-1]:
ans='Yes'
else:
ans='No'
print(ans)
```
No
| 102,718 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
We have N+M balls, each of which has an integer written on it.
It is known that:
* The numbers written on N of the balls are even.
* The numbers written on M of the balls are odd.
Find the number of ways to choose two of the N+M balls (disregarding order) so that the sum of the numbers written on them is even.
It can be shown that this count does not depend on the actual values written on the balls.
Constraints
* 0 \leq N,M \leq 100
* 2 \leq N+M
* All values in input are integers.
Input
Input is given from Standard Input in the following format:
N M
Output
Print the answer.
Examples
Input
2 1
Output
1
Input
4 3
Output
9
Input
1 1
Output
0
Input
13 3
Output
81
Input
0 3
Output
3
Submitted Solution:
```
A = list(map(int, input().strip().split(' ')))
ans = (A[0] * (A[0] - 1)) / 2 + ((A[1] * (A[1] - 1)) / 2)
print(ans)
```
No
| 102,719 |
Provide a correct Python 3 solution for this coding contest problem.
There is a knight - the chess piece - at the origin (0, 0) of a two-dimensional grid.
When the knight is at the square (i, j), it can be moved to either (i+1,j+2) or (i+2, j+1).
In how many ways can the knight reach the square (X, Y)?
Find the number of ways modulo 10^9 + 7.
Constraints
* 1 \leq X \leq 10^6
* 1 \leq Y \leq 10^6
* All values in input are integers.
Input
Input is given from Standard Input in the following format:
X Y
Output
Print the number of ways for the knight to reach (X, Y) from (0, 0), modulo 10^9 + 7.
Examples
Input
3 3
Output
2
Input
2 2
Output
0
Input
999999 999999
Output
151840682
"Correct Solution:
```
x,y = map(int,input().split())
n = 0
mod = 10**9+7
ans = 0
if not (x+y)%3:
n = (x+y)//3
x-=n
y-=n
if not x<0 or y<0:
ans = 1
for i in range(x):
ans = ans*(n-i)*pow(i+1,mod-2,mod)%mod
print(ans)
```
| 102,720 |
Provide a correct Python 3 solution for this coding contest problem.
There is a knight - the chess piece - at the origin (0, 0) of a two-dimensional grid.
When the knight is at the square (i, j), it can be moved to either (i+1,j+2) or (i+2, j+1).
In how many ways can the knight reach the square (X, Y)?
Find the number of ways modulo 10^9 + 7.
Constraints
* 1 \leq X \leq 10^6
* 1 \leq Y \leq 10^6
* All values in input are integers.
Input
Input is given from Standard Input in the following format:
X Y
Output
Print the number of ways for the knight to reach (X, Y) from (0, 0), modulo 10^9 + 7.
Examples
Input
3 3
Output
2
Input
2 2
Output
0
Input
999999 999999
Output
151840682
"Correct Solution:
```
a,b=map(int,input().split())
aa=a
bb=b
x=0
y=0
while aa>0 and bb>0:
if aa>bb:
aa-=1
x+=1
else:
bb-=1
y+=1
aa-=1
bb-=1
if aa!=0 or bb!=0:
print(0)
exit()
mod=10**9+7
fac=[1]
for i in range(max(a,b)):
fac.append(fac[i]*(i+1)%mod)
x+=y
r=pow(fac[y]*fac[x-y]%mod,mod-2,mod)
print(fac[x]*r%mod)
```
| 102,721 |
Provide a correct Python 3 solution for this coding contest problem.
There is a knight - the chess piece - at the origin (0, 0) of a two-dimensional grid.
When the knight is at the square (i, j), it can be moved to either (i+1,j+2) or (i+2, j+1).
In how many ways can the knight reach the square (X, Y)?
Find the number of ways modulo 10^9 + 7.
Constraints
* 1 \leq X \leq 10^6
* 1 \leq Y \leq 10^6
* All values in input are integers.
Input
Input is given from Standard Input in the following format:
X Y
Output
Print the number of ways for the knight to reach (X, Y) from (0, 0), modulo 10^9 + 7.
Examples
Input
3 3
Output
2
Input
2 2
Output
0
Input
999999 999999
Output
151840682
"Correct Solution:
```
X,Y = map(int, input().split())
m = (-X+2*Y)//3
n = (2*X-Y)//3
def combination(n, r, mod=10**9+7):
n1, r = n+1, min(r, n-r)
numer = denom = 1
for i in range(1, r+1):
numer = (numer*(n1-i)) % mod
denom = (denom*i) % mod
return numer * pow(denom, mod-2, mod) % mod
if (X+Y)%3 != 0 or m*n<0:
print(0)
else:
print(combination(m+n,n))
```
| 102,722 |
Provide a correct Python 3 solution for this coding contest problem.
There is a knight - the chess piece - at the origin (0, 0) of a two-dimensional grid.
When the knight is at the square (i, j), it can be moved to either (i+1,j+2) or (i+2, j+1).
In how many ways can the knight reach the square (X, Y)?
Find the number of ways modulo 10^9 + 7.
Constraints
* 1 \leq X \leq 10^6
* 1 \leq Y \leq 10^6
* All values in input are integers.
Input
Input is given from Standard Input in the following format:
X Y
Output
Print the number of ways for the knight to reach (X, Y) from (0, 0), modulo 10^9 + 7.
Examples
Input
3 3
Output
2
Input
2 2
Output
0
Input
999999 999999
Output
151840682
"Correct Solution:
```
x,y = map(int,input().split())
m = 10**9+7
if not((x+y)%3== 0 and abs(x-y)<=(x+y)//3):
print(0);exit()
def comb(n,k):
#if 2 * k > n:
#k = n - k
a = 1
for i in range(1,k+1):
a *= (n - ( i - 1)) * pow(i,m-2,m)
a = a%m
return a
n = (x+y)//3
k = x-n
print(comb(n,k))
```
| 102,723 |
Provide a correct Python 3 solution for this coding contest problem.
There is a knight - the chess piece - at the origin (0, 0) of a two-dimensional grid.
When the knight is at the square (i, j), it can be moved to either (i+1,j+2) or (i+2, j+1).
In how many ways can the knight reach the square (X, Y)?
Find the number of ways modulo 10^9 + 7.
Constraints
* 1 \leq X \leq 10^6
* 1 \leq Y \leq 10^6
* All values in input are integers.
Input
Input is given from Standard Input in the following format:
X Y
Output
Print the number of ways for the knight to reach (X, Y) from (0, 0), modulo 10^9 + 7.
Examples
Input
3 3
Output
2
Input
2 2
Output
0
Input
999999 999999
Output
151840682
"Correct Solution:
```
x,y = map(int,input().split())
ans = 0
mod = 10**9+7
if (x+y)%3 == 0:
m = (2*y-x)//3
n = (2*x-y)//3
if m >= 0 and n >= 0:
fac = [1]*(m+n+1)
for i in range(2,m+n+1):
fac[i] = fac[i-1]*i % mod
ans = fac[m+n]*(pow(fac[m],mod-2,mod)*pow(fac[n],mod-2,mod)%mod)%mod
print(ans)
```
| 102,724 |
Provide a correct Python 3 solution for this coding contest problem.
There is a knight - the chess piece - at the origin (0, 0) of a two-dimensional grid.
When the knight is at the square (i, j), it can be moved to either (i+1,j+2) or (i+2, j+1).
In how many ways can the knight reach the square (X, Y)?
Find the number of ways modulo 10^9 + 7.
Constraints
* 1 \leq X \leq 10^6
* 1 \leq Y \leq 10^6
* All values in input are integers.
Input
Input is given from Standard Input in the following format:
X Y
Output
Print the number of ways for the knight to reach (X, Y) from (0, 0), modulo 10^9 + 7.
Examples
Input
3 3
Output
2
Input
2 2
Output
0
Input
999999 999999
Output
151840682
"Correct Solution:
```
x, y = map(int, input().split())
if (x + y) % 3 != 0:
print(0)
exit()
a = (x + y) // 3
x -= a
y -= a
if x < 0 or y < 0:
print(0)
exit()
mod = 10 ** 9 + 7
def combination(n, r):
x = 1
y = 1
for i in range(r):
x = x * (n - i) % mod
y = y * (r - i) % mod
return (x * pow(y, mod-2, mod)) % mod
print(combination(x+y, min(x, y)))
```
| 102,725 |
Provide a correct Python 3 solution for this coding contest problem.
There is a knight - the chess piece - at the origin (0, 0) of a two-dimensional grid.
When the knight is at the square (i, j), it can be moved to either (i+1,j+2) or (i+2, j+1).
In how many ways can the knight reach the square (X, Y)?
Find the number of ways modulo 10^9 + 7.
Constraints
* 1 \leq X \leq 10^6
* 1 \leq Y \leq 10^6
* All values in input are integers.
Input
Input is given from Standard Input in the following format:
X Y
Output
Print the number of ways for the knight to reach (X, Y) from (0, 0), modulo 10^9 + 7.
Examples
Input
3 3
Output
2
Input
2 2
Output
0
Input
999999 999999
Output
151840682
"Correct Solution:
```
import math
X, Y = map(int, input().split())
if X > Y:
X, Y = Y, X
if ((2*X-Y) % 3 != 0) or (2*X-Y < 0):
print(0)
exit()
A = (2*X-Y)//3
B = Y-X+A
N = A+B
nu = 1
de = 1
for i in range(B+1, N+1):
nu = (nu * i) % (10 ** 9 + 7)
for i in range(1, A+1):
de = (de * i) % (10 ** 9 + 7)
print((nu * pow(de, -1, 10 ** 9 + 7) ) % (10 ** 9 + 7))
```
| 102,726 |
Provide a correct Python 3 solution for this coding contest problem.
There is a knight - the chess piece - at the origin (0, 0) of a two-dimensional grid.
When the knight is at the square (i, j), it can be moved to either (i+1,j+2) or (i+2, j+1).
In how many ways can the knight reach the square (X, Y)?
Find the number of ways modulo 10^9 + 7.
Constraints
* 1 \leq X \leq 10^6
* 1 \leq Y \leq 10^6
* All values in input are integers.
Input
Input is given from Standard Input in the following format:
X Y
Output
Print the number of ways for the knight to reach (X, Y) from (0, 0), modulo 10^9 + 7.
Examples
Input
3 3
Output
2
Input
2 2
Output
0
Input
999999 999999
Output
151840682
"Correct Solution:
```
M = 10 ** 9 + 7
x, y = map(int, input().split())
r = 0
if (x + y) % 3 == 0:
a, b = (2 * y - x) // 3, (2 * x - y ) // 3
if a >= 0 <= b:
f = [1]
for i in range(1, a + b + 1):
f.append(f[-1] * i % M)
r = f[a + b] * pow(f[a] * f[b], M - 2, M) % M
print(r)
```
| 102,727 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There is a knight - the chess piece - at the origin (0, 0) of a two-dimensional grid.
When the knight is at the square (i, j), it can be moved to either (i+1,j+2) or (i+2, j+1).
In how many ways can the knight reach the square (X, Y)?
Find the number of ways modulo 10^9 + 7.
Constraints
* 1 \leq X \leq 10^6
* 1 \leq Y \leq 10^6
* All values in input are integers.
Input
Input is given from Standard Input in the following format:
X Y
Output
Print the number of ways for the knight to reach (X, Y) from (0, 0), modulo 10^9 + 7.
Examples
Input
3 3
Output
2
Input
2 2
Output
0
Input
999999 999999
Output
151840682
Submitted Solution:
```
X,Y=map(int,input().split())
if (X+Y)%3!=0:
print(0)
exit()
mod=10**9+7
N=(X+Y)//3
'''
k*(1,2)+(n-k)*(2,1)=(x,y)
(k+2n-2k,2k+n-k)=(x,y)
(2n-k,n+k)=(x,y)
2y=2n+2k
x=2n-k
2y-x=3k
'''
K=(2*Y-X)//3
if not(0<=K<=N):
print(0)
exit()
ans=1
for i in range(1,K+1):
ans*=(N+1-i)*pow(i,mod-2,mod)
ans%=mod
print(ans)
```
Yes
| 102,728 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There is a knight - the chess piece - at the origin (0, 0) of a two-dimensional grid.
When the knight is at the square (i, j), it can be moved to either (i+1,j+2) or (i+2, j+1).
In how many ways can the knight reach the square (X, Y)?
Find the number of ways modulo 10^9 + 7.
Constraints
* 1 \leq X \leq 10^6
* 1 \leq Y \leq 10^6
* All values in input are integers.
Input
Input is given from Standard Input in the following format:
X Y
Output
Print the number of ways for the knight to reach (X, Y) from (0, 0), modulo 10^9 + 7.
Examples
Input
3 3
Output
2
Input
2 2
Output
0
Input
999999 999999
Output
151840682
Submitted Solution:
```
X,Y = map(int,input().split())
M = X+Y
mod = 10**9 + 7
kaijou = [1]
for i in range(1,10**6+1):
kaijou.append((kaijou[-1]*i)%mod)
def C(n,k):
return (kaijou[n]*pow(kaijou[k],mod-2,mod)*pow(kaijou[n-k],mod-2,mod))%mod
if M%3!=0:
print(0)
elif X<M//3 or Y<M//3:
print(0)
else:
print(C(M//3, X-M//3))
```
Yes
| 102,729 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There is a knight - the chess piece - at the origin (0, 0) of a two-dimensional grid.
When the knight is at the square (i, j), it can be moved to either (i+1,j+2) or (i+2, j+1).
In how many ways can the knight reach the square (X, Y)?
Find the number of ways modulo 10^9 + 7.
Constraints
* 1 \leq X \leq 10^6
* 1 \leq Y \leq 10^6
* All values in input are integers.
Input
Input is given from Standard Input in the following format:
X Y
Output
Print the number of ways for the knight to reach (X, Y) from (0, 0), modulo 10^9 + 7.
Examples
Input
3 3
Output
2
Input
2 2
Output
0
Input
999999 999999
Output
151840682
Submitted Solution:
```
X,Y=sorted(list(map(int,input().split())))
#移動方法を(i+1,j),(i,j+1)となるようにどうにかする
if (X-abs(Y-X))%3!=0 or X*2<Y:
print(0)
exit(0)
n=(X-abs(Y-X))//3
X=n+abs(Y-X)
Y=n
mod=10**9+7
a=1
for i in range(1,X+Y+1):
a*=i
a%=mod
b=1
for i in range(1,X+1):
b*=i
b%=mod
c=1
for i in range(1,Y+1):
c*=i
c%=mod
print(a*pow(b,-1,mod)*pow(c,-1,mod)%mod)
```
Yes
| 102,730 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There is a knight - the chess piece - at the origin (0, 0) of a two-dimensional grid.
When the knight is at the square (i, j), it can be moved to either (i+1,j+2) or (i+2, j+1).
In how many ways can the knight reach the square (X, Y)?
Find the number of ways modulo 10^9 + 7.
Constraints
* 1 \leq X \leq 10^6
* 1 \leq Y \leq 10^6
* All values in input are integers.
Input
Input is given from Standard Input in the following format:
X Y
Output
Print the number of ways for the knight to reach (X, Y) from (0, 0), modulo 10^9 + 7.
Examples
Input
3 3
Output
2
Input
2 2
Output
0
Input
999999 999999
Output
151840682
Submitted Solution:
```
import sys
x,y=map(int,input().split())
T=x+y
MOD=10**9+7
def nCmMOD(A,B,Mod):
num,den=1,1
for i in range(B):
num*=(A-i)
den*=(i+1)
num%=Mod
den%=Mod
return (num*pow(den,Mod-2,Mod))%Mod
if T%3!=0 or y/x<1/2 or y/x>2:
print(0)
sys.exit()
else:
n=(2*y-x)//3
m=(2*x-y)//3
l=min(n,m)
print(nCmMOD(n+m,l,MOD))
```
Yes
| 102,731 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There is a knight - the chess piece - at the origin (0, 0) of a two-dimensional grid.
When the knight is at the square (i, j), it can be moved to either (i+1,j+2) or (i+2, j+1).
In how many ways can the knight reach the square (X, Y)?
Find the number of ways modulo 10^9 + 7.
Constraints
* 1 \leq X \leq 10^6
* 1 \leq Y \leq 10^6
* All values in input are integers.
Input
Input is given from Standard Input in the following format:
X Y
Output
Print the number of ways for the knight to reach (X, Y) from (0, 0), modulo 10^9 + 7.
Examples
Input
3 3
Output
2
Input
2 2
Output
0
Input
999999 999999
Output
151840682
Submitted Solution:
```
#!/usr/bin/env python3
import sys
import math
MOD = 1000000007 # type: int
def solve(X: int, Y: int):
a = (2*Y - X)/3
b = (2*X - Y)/3
if ((2*Y - X)%3 != 0) and ((2*X - Y)%3 != 0):
ans = 0
else:
if (a<0) or (b<0):
ans = 0
else:
factorial_ab = math.factorial(int(min(a, b)))
ans = math.factorial(int(a+b)) / factorial_ab
print(int(ans%MOD))
# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools (tips: You use the default template now. You can remove this line by using your custom template)
def main():
def iterate_tokens():
for line in sys.stdin:
for word in line.split():
yield word
tokens = iterate_tokens()
X = int(next(tokens)) # type: int
Y = int(next(tokens)) # type: int
solve(X, Y)
if __name__ == '__main__':
main()
```
No
| 102,732 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There is a knight - the chess piece - at the origin (0, 0) of a two-dimensional grid.
When the knight is at the square (i, j), it can be moved to either (i+1,j+2) or (i+2, j+1).
In how many ways can the knight reach the square (X, Y)?
Find the number of ways modulo 10^9 + 7.
Constraints
* 1 \leq X \leq 10^6
* 1 \leq Y \leq 10^6
* All values in input are integers.
Input
Input is given from Standard Input in the following format:
X Y
Output
Print the number of ways for the knight to reach (X, Y) from (0, 0), modulo 10^9 + 7.
Examples
Input
3 3
Output
2
Input
2 2
Output
0
Input
999999 999999
Output
151840682
Submitted Solution:
```
x, y = [int(i) for i in input().split()]
a = (2 * x - y) / 3
b = (-x + 2 * y) / 3
mod = 10**9 + 7
def cmb(n, r):
if n - r < r: r = n - r
if r == 0: return 1
if r == 1: return n
numerator = [n - r + k + 1 for k in range(r)]
denominator = [k + 1 for k in range(r)]
for p in range(2,r+1):
pivot = denominator[p - 1]
if pivot > 1:
offset = (n - r) % p
for k in range(p-1,r,p):
numerator[k - offset] /= pivot
denominator[k] /= pivot
result = 1
for k in range(r):
if numerator[k] > 1:
result *= int(numerator[k])
return result
if a % 1 != 0 or b % 1 != 0:
print(0)
else:
ans = cmb(int(a+b), int(a)) % mod
print(ans)
#print(int(a_b / _a / _b % (10**9+7)))
```
No
| 102,733 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There is a knight - the chess piece - at the origin (0, 0) of a two-dimensional grid.
When the knight is at the square (i, j), it can be moved to either (i+1,j+2) or (i+2, j+1).
In how many ways can the knight reach the square (X, Y)?
Find the number of ways modulo 10^9 + 7.
Constraints
* 1 \leq X \leq 10^6
* 1 \leq Y \leq 10^6
* All values in input are integers.
Input
Input is given from Standard Input in the following format:
X Y
Output
Print the number of ways for the knight to reach (X, Y) from (0, 0), modulo 10^9 + 7.
Examples
Input
3 3
Output
2
Input
2 2
Output
0
Input
999999 999999
Output
151840682
Submitted Solution:
```
# 入力が10**5とかになったときに100ms程度早い
import sys
read = sys.stdin.readline
def read_ints():
return list(map(int, read().split()))
def read_a_int():
return int(read())
def read_matrix(H):
'''
H is number of rows
'''
return [list(map(int, read().split())) for _ in range(H)]
def read_map(H):
'''
H is number of rows
文字列で与えられた盤面を読み取る用
'''
return [read()[:-1] for _ in range(H)]
def read_col(H, n_cols):
'''
H is number of rows
n_cols is number of cols
A列、B列が与えられるようなとき
'''
ret = [[] for _ in range(n_cols)]
for _ in range(H):
tmp = list(map(int, read().split()))
for col in range(n_cols):
ret[col].append(tmp[col])
return ret
MOD = 10**9 + 7
X, Y = read_ints()
if (X + Y) % 3 != 0: # !=0
print(0)
exit()
pascal_depth = int((X + Y) / 3) # パスカルの三角形に当たるn
x, y = int((X + Y) * 2 / 3), (X + Y) / 3
pascal_k = x - X # 端からいくつずれているか
if pascal_k > pascal_depth / 2:
pascal_k = pascal_depth - pascal_k
def cmb(n, r, mod):
if (r < 0 or r > n):
return 0
r = min(r, n - r)
return g1[n] * g2[r] * g2[n - r] % mod
mod = 10**9 + 7 # 出力の制限
N = pascal_depth
g1 = [1, 1] # 元テーブル
g2 = [1, 1] # 逆元テーブル
inverse = [0, 1] # 逆元テーブル計算用テーブル
for i in range(2, N + 1):
g1.append((g1[-1] * i) % mod)
inverse.append((-inverse[mod % i] * (mod // i)) % mod)
g2.append((g2[-1] * inverse[-1]) % mod)
def mod_combination(n, k, mod):
# nCk (mod m)
def mod_permutation(n, k, mod):
if n <= k:
return 1
else:
return (n * mod_permutation(n - 1, k, mod)) % mod
def mod_inv_permutation(k, mod):
k, mod = int(k), int(mod)
if k <= 1:
return 1
else:
return (pow(k, mod - 2, mod) * mod_inv_permutation(k - 1, mod)) % mod
return (mod_permutation(n, n - k, mod) * mod_inv_permutation(k, mod)) % mod
a = mod_combination(pascal_depth, pascal_k, MOD)
print(a)
```
No
| 102,734 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There is a knight - the chess piece - at the origin (0, 0) of a two-dimensional grid.
When the knight is at the square (i, j), it can be moved to either (i+1,j+2) or (i+2, j+1).
In how many ways can the knight reach the square (X, Y)?
Find the number of ways modulo 10^9 + 7.
Constraints
* 1 \leq X \leq 10^6
* 1 \leq Y \leq 10^6
* All values in input are integers.
Input
Input is given from Standard Input in the following format:
X Y
Output
Print the number of ways for the knight to reach (X, Y) from (0, 0), modulo 10^9 + 7.
Examples
Input
3 3
Output
2
Input
2 2
Output
0
Input
999999 999999
Output
151840682
Submitted Solution:
```
X, Y = map(int, input().split())
res = 0
mod = 10 ** 9 + 7
def IsPositiveAndInt(num):
return int(num)-num == 0.0 and num > 0
# Copy from https://atcoder.jp/contests/abc145/submissions/8515099
def Comb(n, r, mod=mod):
r = min(r, n-r)
numer = denom = 1
for i in range(1, r+1):
numer = numer * (n+1-i) % mod
denom = denom * i % mod
return numer * pow(denom, mod-2, mod) % mod
if (X+Y) % 3 == 0:
A = (2*X-Y) / 3
B = (-X + 2*Y) / 3
if IsPositiveAndInt(A) and IsPositiveAndInt(B):
A, B = int(A), int(B)
res = Comb(A+B, A, mod)
print(int(res))
```
No
| 102,735 |
Provide a correct Python 3 solution for this coding contest problem.
Kizahashi, who was appointed as the administrator of ABC at National Problem Workshop in the Kingdom of AtCoder, got too excited and took on too many jobs.
Let the current time be time 0. Kizahashi has N jobs numbered 1 to N.
It takes A_i units of time for Kizahashi to complete Job i. The deadline for Job i is time B_i, and he must complete the job before or at this time.
Kizahashi cannot work on two or more jobs simultaneously, but when he completes a job, he can start working on another immediately.
Can Kizahashi complete all the jobs in time? If he can, print `Yes`; if he cannot, print `No`.
Constraints
* All values in input are integers.
* 1 \leq N \leq 2 \times 10^5
* 1 \leq A_i, B_i \leq 10^9 (1 \leq i \leq N)
Input
Input is given from Standard Input in the following format:
N
A_1 B_1
.
.
.
A_N B_N
Output
If Kizahashi can complete all the jobs in time, print `Yes`; if he cannot, print `No`.
Examples
Input
5
2 4
1 9
1 8
4 9
3 12
Output
Yes
Input
3
334 1000
334 1000
334 1000
Output
No
Input
30
384 8895
1725 9791
170 1024
4 11105
2 6
578 1815
702 3352
143 5141
1420 6980
24 1602
849 999
76 7586
85 5570
444 4991
719 11090
470 10708
1137 4547
455 9003
110 9901
15 8578
368 3692
104 1286
3 4
366 12143
7 6649
610 2374
152 7324
4 7042
292 11386
334 5720
Output
Yes
"Correct Solution:
```
N=int(input())
AB=[list(map(int,input().split())) for _ in range(N)]
AB.sort(key=lambda x:x[1])
SUM_=0
for i in range(N):
SUM_+=AB[i][0]
if SUM_>AB[i][1]:
print('No')
exit()
print('Yes')
```
| 102,736 |
Provide a correct Python 3 solution for this coding contest problem.
Kizahashi, who was appointed as the administrator of ABC at National Problem Workshop in the Kingdom of AtCoder, got too excited and took on too many jobs.
Let the current time be time 0. Kizahashi has N jobs numbered 1 to N.
It takes A_i units of time for Kizahashi to complete Job i. The deadline for Job i is time B_i, and he must complete the job before or at this time.
Kizahashi cannot work on two or more jobs simultaneously, but when he completes a job, he can start working on another immediately.
Can Kizahashi complete all the jobs in time? If he can, print `Yes`; if he cannot, print `No`.
Constraints
* All values in input are integers.
* 1 \leq N \leq 2 \times 10^5
* 1 \leq A_i, B_i \leq 10^9 (1 \leq i \leq N)
Input
Input is given from Standard Input in the following format:
N
A_1 B_1
.
.
.
A_N B_N
Output
If Kizahashi can complete all the jobs in time, print `Yes`; if he cannot, print `No`.
Examples
Input
5
2 4
1 9
1 8
4 9
3 12
Output
Yes
Input
3
334 1000
334 1000
334 1000
Output
No
Input
30
384 8895
1725 9791
170 1024
4 11105
2 6
578 1815
702 3352
143 5141
1420 6980
24 1602
849 999
76 7586
85 5570
444 4991
719 11090
470 10708
1137 4547
455 9003
110 9901
15 8578
368 3692
104 1286
3 4
366 12143
7 6649
610 2374
152 7324
4 7042
292 11386
334 5720
Output
Yes
"Correct Solution:
```
N = int(input())
AB = [list(map(int,input().split())) for _ in range(N)]
AB = sorted(AB, key=lambda x:x[1])
t = 0
for i in range(N):
t += AB[i][0]
if t > AB[i][1]:
print("No")
exit()
print("Yes")
```
| 102,737 |
Provide a correct Python 3 solution for this coding contest problem.
Kizahashi, who was appointed as the administrator of ABC at National Problem Workshop in the Kingdom of AtCoder, got too excited and took on too many jobs.
Let the current time be time 0. Kizahashi has N jobs numbered 1 to N.
It takes A_i units of time for Kizahashi to complete Job i. The deadline for Job i is time B_i, and he must complete the job before or at this time.
Kizahashi cannot work on two or more jobs simultaneously, but when he completes a job, he can start working on another immediately.
Can Kizahashi complete all the jobs in time? If he can, print `Yes`; if he cannot, print `No`.
Constraints
* All values in input are integers.
* 1 \leq N \leq 2 \times 10^5
* 1 \leq A_i, B_i \leq 10^9 (1 \leq i \leq N)
Input
Input is given from Standard Input in the following format:
N
A_1 B_1
.
.
.
A_N B_N
Output
If Kizahashi can complete all the jobs in time, print `Yes`; if he cannot, print `No`.
Examples
Input
5
2 4
1 9
1 8
4 9
3 12
Output
Yes
Input
3
334 1000
334 1000
334 1000
Output
No
Input
30
384 8895
1725 9791
170 1024
4 11105
2 6
578 1815
702 3352
143 5141
1420 6980
24 1602
849 999
76 7586
85 5570
444 4991
719 11090
470 10708
1137 4547
455 9003
110 9901
15 8578
368 3692
104 1286
3 4
366 12143
7 6649
610 2374
152 7324
4 7042
292 11386
334 5720
Output
Yes
"Correct Solution:
```
n=int(input())
ab=[tuple(map(int,input().split())) for _ in range(n)]
ab=sorted(ab,key=lambda x:x[1])
ans=0
for i,j in ab:
ans+=i
if ans>j:
print('No')
exit()
print('Yes')
```
| 102,738 |
Provide a correct Python 3 solution for this coding contest problem.
Kizahashi, who was appointed as the administrator of ABC at National Problem Workshop in the Kingdom of AtCoder, got too excited and took on too many jobs.
Let the current time be time 0. Kizahashi has N jobs numbered 1 to N.
It takes A_i units of time for Kizahashi to complete Job i. The deadline for Job i is time B_i, and he must complete the job before or at this time.
Kizahashi cannot work on two or more jobs simultaneously, but when he completes a job, he can start working on another immediately.
Can Kizahashi complete all the jobs in time? If he can, print `Yes`; if he cannot, print `No`.
Constraints
* All values in input are integers.
* 1 \leq N \leq 2 \times 10^5
* 1 \leq A_i, B_i \leq 10^9 (1 \leq i \leq N)
Input
Input is given from Standard Input in the following format:
N
A_1 B_1
.
.
.
A_N B_N
Output
If Kizahashi can complete all the jobs in time, print `Yes`; if he cannot, print `No`.
Examples
Input
5
2 4
1 9
1 8
4 9
3 12
Output
Yes
Input
3
334 1000
334 1000
334 1000
Output
No
Input
30
384 8895
1725 9791
170 1024
4 11105
2 6
578 1815
702 3352
143 5141
1420 6980
24 1602
849 999
76 7586
85 5570
444 4991
719 11090
470 10708
1137 4547
455 9003
110 9901
15 8578
368 3692
104 1286
3 4
366 12143
7 6649
610 2374
152 7324
4 7042
292 11386
334 5720
Output
Yes
"Correct Solution:
```
n,t=int(input()),0
AB=[list(map(int,input().split())) for _ in range(n)]
AB.sort(key=lambda X: X[1])
for ab in AB:
t += ab[0]
if t > ab[1]:
print("No")
exit()
print("Yes")
```
| 102,739 |
Provide a correct Python 3 solution for this coding contest problem.
Kizahashi, who was appointed as the administrator of ABC at National Problem Workshop in the Kingdom of AtCoder, got too excited and took on too many jobs.
Let the current time be time 0. Kizahashi has N jobs numbered 1 to N.
It takes A_i units of time for Kizahashi to complete Job i. The deadline for Job i is time B_i, and he must complete the job before or at this time.
Kizahashi cannot work on two or more jobs simultaneously, but when he completes a job, he can start working on another immediately.
Can Kizahashi complete all the jobs in time? If he can, print `Yes`; if he cannot, print `No`.
Constraints
* All values in input are integers.
* 1 \leq N \leq 2 \times 10^5
* 1 \leq A_i, B_i \leq 10^9 (1 \leq i \leq N)
Input
Input is given from Standard Input in the following format:
N
A_1 B_1
.
.
.
A_N B_N
Output
If Kizahashi can complete all the jobs in time, print `Yes`; if he cannot, print `No`.
Examples
Input
5
2 4
1 9
1 8
4 9
3 12
Output
Yes
Input
3
334 1000
334 1000
334 1000
Output
No
Input
30
384 8895
1725 9791
170 1024
4 11105
2 6
578 1815
702 3352
143 5141
1420 6980
24 1602
849 999
76 7586
85 5570
444 4991
719 11090
470 10708
1137 4547
455 9003
110 9901
15 8578
368 3692
104 1286
3 4
366 12143
7 6649
610 2374
152 7324
4 7042
292 11386
334 5720
Output
Yes
"Correct Solution:
```
N = int(input())
A = [list(map(int,input().split())) for i in range(N)]
A.sort(key = lambda x: x[1])
su = 0
for i in A:
su += i[0]
if su > i[1]:
print("No")
exit()
print("Yes")
```
| 102,740 |
Provide a correct Python 3 solution for this coding contest problem.
Kizahashi, who was appointed as the administrator of ABC at National Problem Workshop in the Kingdom of AtCoder, got too excited and took on too many jobs.
Let the current time be time 0. Kizahashi has N jobs numbered 1 to N.
It takes A_i units of time for Kizahashi to complete Job i. The deadline for Job i is time B_i, and he must complete the job before or at this time.
Kizahashi cannot work on two or more jobs simultaneously, but when he completes a job, he can start working on another immediately.
Can Kizahashi complete all the jobs in time? If he can, print `Yes`; if he cannot, print `No`.
Constraints
* All values in input are integers.
* 1 \leq N \leq 2 \times 10^5
* 1 \leq A_i, B_i \leq 10^9 (1 \leq i \leq N)
Input
Input is given from Standard Input in the following format:
N
A_1 B_1
.
.
.
A_N B_N
Output
If Kizahashi can complete all the jobs in time, print `Yes`; if he cannot, print `No`.
Examples
Input
5
2 4
1 9
1 8
4 9
3 12
Output
Yes
Input
3
334 1000
334 1000
334 1000
Output
No
Input
30
384 8895
1725 9791
170 1024
4 11105
2 6
578 1815
702 3352
143 5141
1420 6980
24 1602
849 999
76 7586
85 5570
444 4991
719 11090
470 10708
1137 4547
455 9003
110 9901
15 8578
368 3692
104 1286
3 4
366 12143
7 6649
610 2374
152 7324
4 7042
292 11386
334 5720
Output
Yes
"Correct Solution:
```
#40 ABC131D
n=int(input())
ab=[list(map(int,input().split())) for _ in range(n)]
ab=sorted(ab,key=lambda x:x[1])
j=True
x=0
for a,b in ab:
x+=a
if x>b:
j=False
break
print("Yes" if j else "No")
```
| 102,741 |
Provide a correct Python 3 solution for this coding contest problem.
Kizahashi, who was appointed as the administrator of ABC at National Problem Workshop in the Kingdom of AtCoder, got too excited and took on too many jobs.
Let the current time be time 0. Kizahashi has N jobs numbered 1 to N.
It takes A_i units of time for Kizahashi to complete Job i. The deadline for Job i is time B_i, and he must complete the job before or at this time.
Kizahashi cannot work on two or more jobs simultaneously, but when he completes a job, he can start working on another immediately.
Can Kizahashi complete all the jobs in time? If he can, print `Yes`; if he cannot, print `No`.
Constraints
* All values in input are integers.
* 1 \leq N \leq 2 \times 10^5
* 1 \leq A_i, B_i \leq 10^9 (1 \leq i \leq N)
Input
Input is given from Standard Input in the following format:
N
A_1 B_1
.
.
.
A_N B_N
Output
If Kizahashi can complete all the jobs in time, print `Yes`; if he cannot, print `No`.
Examples
Input
5
2 4
1 9
1 8
4 9
3 12
Output
Yes
Input
3
334 1000
334 1000
334 1000
Output
No
Input
30
384 8895
1725 9791
170 1024
4 11105
2 6
578 1815
702 3352
143 5141
1420 6980
24 1602
849 999
76 7586
85 5570
444 4991
719 11090
470 10708
1137 4547
455 9003
110 9901
15 8578
368 3692
104 1286
3 4
366 12143
7 6649
610 2374
152 7324
4 7042
292 11386
334 5720
Output
Yes
"Correct Solution:
```
N = int(input())
arr = [list(map(int,input().split())) for _ in range(N)]
arr.sort(key=lambda x: x[1])
cnt = 0
for a,b in arr:
cnt += a
if cnt > b:
flag = "No"
break
flag = 'Yes'
print(flag)
```
| 102,742 |
Provide a correct Python 3 solution for this coding contest problem.
Kizahashi, who was appointed as the administrator of ABC at National Problem Workshop in the Kingdom of AtCoder, got too excited and took on too many jobs.
Let the current time be time 0. Kizahashi has N jobs numbered 1 to N.
It takes A_i units of time for Kizahashi to complete Job i. The deadline for Job i is time B_i, and he must complete the job before or at this time.
Kizahashi cannot work on two or more jobs simultaneously, but when he completes a job, he can start working on another immediately.
Can Kizahashi complete all the jobs in time? If he can, print `Yes`; if he cannot, print `No`.
Constraints
* All values in input are integers.
* 1 \leq N \leq 2 \times 10^5
* 1 \leq A_i, B_i \leq 10^9 (1 \leq i \leq N)
Input
Input is given from Standard Input in the following format:
N
A_1 B_1
.
.
.
A_N B_N
Output
If Kizahashi can complete all the jobs in time, print `Yes`; if he cannot, print `No`.
Examples
Input
5
2 4
1 9
1 8
4 9
3 12
Output
Yes
Input
3
334 1000
334 1000
334 1000
Output
No
Input
30
384 8895
1725 9791
170 1024
4 11105
2 6
578 1815
702 3352
143 5141
1420 6980
24 1602
849 999
76 7586
85 5570
444 4991
719 11090
470 10708
1137 4547
455 9003
110 9901
15 8578
368 3692
104 1286
3 4
366 12143
7 6649
610 2374
152 7324
4 7042
292 11386
334 5720
Output
Yes
"Correct Solution:
```
N = int(input())
AB = [list(map(int, input().split())) for i in range(N)]
AB.sort(key=lambda x: x[1])
time = 0
for a, b in AB:
time += a
if time > b:
print('No')
quit()
print('Yes')
```
| 102,743 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Kizahashi, who was appointed as the administrator of ABC at National Problem Workshop in the Kingdom of AtCoder, got too excited and took on too many jobs.
Let the current time be time 0. Kizahashi has N jobs numbered 1 to N.
It takes A_i units of time for Kizahashi to complete Job i. The deadline for Job i is time B_i, and he must complete the job before or at this time.
Kizahashi cannot work on two or more jobs simultaneously, but when he completes a job, he can start working on another immediately.
Can Kizahashi complete all the jobs in time? If he can, print `Yes`; if he cannot, print `No`.
Constraints
* All values in input are integers.
* 1 \leq N \leq 2 \times 10^5
* 1 \leq A_i, B_i \leq 10^9 (1 \leq i \leq N)
Input
Input is given from Standard Input in the following format:
N
A_1 B_1
.
.
.
A_N B_N
Output
If Kizahashi can complete all the jobs in time, print `Yes`; if he cannot, print `No`.
Examples
Input
5
2 4
1 9
1 8
4 9
3 12
Output
Yes
Input
3
334 1000
334 1000
334 1000
Output
No
Input
30
384 8895
1725 9791
170 1024
4 11105
2 6
578 1815
702 3352
143 5141
1420 6980
24 1602
849 999
76 7586
85 5570
444 4991
719 11090
470 10708
1137 4547
455 9003
110 9901
15 8578
368 3692
104 1286
3 4
366 12143
7 6649
610 2374
152 7324
4 7042
292 11386
334 5720
Output
Yes
Submitted Solution:
```
n = int(input())
l = [ list(map(int, input().split())) for _ in range(n) ]
c = 0
l.sort(key=lambda x: x[1])
for i in range(n):
c += l[i][0]
if c > l[i][1]:
print("No")
exit()
print("Yes")
```
Yes
| 102,744 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Kizahashi, who was appointed as the administrator of ABC at National Problem Workshop in the Kingdom of AtCoder, got too excited and took on too many jobs.
Let the current time be time 0. Kizahashi has N jobs numbered 1 to N.
It takes A_i units of time for Kizahashi to complete Job i. The deadline for Job i is time B_i, and he must complete the job before or at this time.
Kizahashi cannot work on two or more jobs simultaneously, but when he completes a job, he can start working on another immediately.
Can Kizahashi complete all the jobs in time? If he can, print `Yes`; if he cannot, print `No`.
Constraints
* All values in input are integers.
* 1 \leq N \leq 2 \times 10^5
* 1 \leq A_i, B_i \leq 10^9 (1 \leq i \leq N)
Input
Input is given from Standard Input in the following format:
N
A_1 B_1
.
.
.
A_N B_N
Output
If Kizahashi can complete all the jobs in time, print `Yes`; if he cannot, print `No`.
Examples
Input
5
2 4
1 9
1 8
4 9
3 12
Output
Yes
Input
3
334 1000
334 1000
334 1000
Output
No
Input
30
384 8895
1725 9791
170 1024
4 11105
2 6
578 1815
702 3352
143 5141
1420 6980
24 1602
849 999
76 7586
85 5570
444 4991
719 11090
470 10708
1137 4547
455 9003
110 9901
15 8578
368 3692
104 1286
3 4
366 12143
7 6649
610 2374
152 7324
4 7042
292 11386
334 5720
Output
Yes
Submitted Solution:
```
N = int(input())
AB = [list(map(int, input().split())) for i in range(N)]
AB.sort(key=lambda x: (x[1], x[0]))
s = 0
for t in AB:
s += t[0]
if (s > t[1]):
print('No')
quit()
print('Yes')
```
Yes
| 102,745 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Kizahashi, who was appointed as the administrator of ABC at National Problem Workshop in the Kingdom of AtCoder, got too excited and took on too many jobs.
Let the current time be time 0. Kizahashi has N jobs numbered 1 to N.
It takes A_i units of time for Kizahashi to complete Job i. The deadline for Job i is time B_i, and he must complete the job before or at this time.
Kizahashi cannot work on two or more jobs simultaneously, but when he completes a job, he can start working on another immediately.
Can Kizahashi complete all the jobs in time? If he can, print `Yes`; if he cannot, print `No`.
Constraints
* All values in input are integers.
* 1 \leq N \leq 2 \times 10^5
* 1 \leq A_i, B_i \leq 10^9 (1 \leq i \leq N)
Input
Input is given from Standard Input in the following format:
N
A_1 B_1
.
.
.
A_N B_N
Output
If Kizahashi can complete all the jobs in time, print `Yes`; if he cannot, print `No`.
Examples
Input
5
2 4
1 9
1 8
4 9
3 12
Output
Yes
Input
3
334 1000
334 1000
334 1000
Output
No
Input
30
384 8895
1725 9791
170 1024
4 11105
2 6
578 1815
702 3352
143 5141
1420 6980
24 1602
849 999
76 7586
85 5570
444 4991
719 11090
470 10708
1137 4547
455 9003
110 9901
15 8578
368 3692
104 1286
3 4
366 12143
7 6649
610 2374
152 7324
4 7042
292 11386
334 5720
Output
Yes
Submitted Solution:
```
N = int(input())
W = []
for _ in range(N):
a, b = map(int, input().split())
W.append([a, b])
s = 0
for a, b in sorted(W, key=lambda x: x[1]):
s += a
if s > b:
print('No')
quit()
print('Yes')
```
Yes
| 102,746 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Kizahashi, who was appointed as the administrator of ABC at National Problem Workshop in the Kingdom of AtCoder, got too excited and took on too many jobs.
Let the current time be time 0. Kizahashi has N jobs numbered 1 to N.
It takes A_i units of time for Kizahashi to complete Job i. The deadline for Job i is time B_i, and he must complete the job before or at this time.
Kizahashi cannot work on two or more jobs simultaneously, but when he completes a job, he can start working on another immediately.
Can Kizahashi complete all the jobs in time? If he can, print `Yes`; if he cannot, print `No`.
Constraints
* All values in input are integers.
* 1 \leq N \leq 2 \times 10^5
* 1 \leq A_i, B_i \leq 10^9 (1 \leq i \leq N)
Input
Input is given from Standard Input in the following format:
N
A_1 B_1
.
.
.
A_N B_N
Output
If Kizahashi can complete all the jobs in time, print `Yes`; if he cannot, print `No`.
Examples
Input
5
2 4
1 9
1 8
4 9
3 12
Output
Yes
Input
3
334 1000
334 1000
334 1000
Output
No
Input
30
384 8895
1725 9791
170 1024
4 11105
2 6
578 1815
702 3352
143 5141
1420 6980
24 1602
849 999
76 7586
85 5570
444 4991
719 11090
470 10708
1137 4547
455 9003
110 9901
15 8578
368 3692
104 1286
3 4
366 12143
7 6649
610 2374
152 7324
4 7042
292 11386
334 5720
Output
Yes
Submitted Solution:
```
n=int(input())
ab=[list(map(int,input().split())) for _ in range(n)]
ab.sort(key=lambda x:x[1])
jikoku=0
for i in range(n):
jikoku+=ab[i][0]
if jikoku>ab[i][1]:
print('No')
exit()
print('Yes')
```
Yes
| 102,747 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Kizahashi, who was appointed as the administrator of ABC at National Problem Workshop in the Kingdom of AtCoder, got too excited and took on too many jobs.
Let the current time be time 0. Kizahashi has N jobs numbered 1 to N.
It takes A_i units of time for Kizahashi to complete Job i. The deadline for Job i is time B_i, and he must complete the job before or at this time.
Kizahashi cannot work on two or more jobs simultaneously, but when he completes a job, he can start working on another immediately.
Can Kizahashi complete all the jobs in time? If he can, print `Yes`; if he cannot, print `No`.
Constraints
* All values in input are integers.
* 1 \leq N \leq 2 \times 10^5
* 1 \leq A_i, B_i \leq 10^9 (1 \leq i \leq N)
Input
Input is given from Standard Input in the following format:
N
A_1 B_1
.
.
.
A_N B_N
Output
If Kizahashi can complete all the jobs in time, print `Yes`; if he cannot, print `No`.
Examples
Input
5
2 4
1 9
1 8
4 9
3 12
Output
Yes
Input
3
334 1000
334 1000
334 1000
Output
No
Input
30
384 8895
1725 9791
170 1024
4 11105
2 6
578 1815
702 3352
143 5141
1420 6980
24 1602
849 999
76 7586
85 5570
444 4991
719 11090
470 10708
1137 4547
455 9003
110 9901
15 8578
368 3692
104 1286
3 4
366 12143
7 6649
610 2374
152 7324
4 7042
292 11386
334 5720
Output
Yes
Submitted Solution:
```
def main():
n = int(input())
ls = []
for _ in range(n):
a, b = map(int, input().split())
ls.append([b,a])
ls = ls.sort()
t=0
for i in ls:
t += i[1]
if t > i[0]:
print('No')
exit(0)
print('Yes')
if __name__ == '__main__':
main()
```
No
| 102,748 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Kizahashi, who was appointed as the administrator of ABC at National Problem Workshop in the Kingdom of AtCoder, got too excited and took on too many jobs.
Let the current time be time 0. Kizahashi has N jobs numbered 1 to N.
It takes A_i units of time for Kizahashi to complete Job i. The deadline for Job i is time B_i, and he must complete the job before or at this time.
Kizahashi cannot work on two or more jobs simultaneously, but when he completes a job, he can start working on another immediately.
Can Kizahashi complete all the jobs in time? If he can, print `Yes`; if he cannot, print `No`.
Constraints
* All values in input are integers.
* 1 \leq N \leq 2 \times 10^5
* 1 \leq A_i, B_i \leq 10^9 (1 \leq i \leq N)
Input
Input is given from Standard Input in the following format:
N
A_1 B_1
.
.
.
A_N B_N
Output
If Kizahashi can complete all the jobs in time, print `Yes`; if he cannot, print `No`.
Examples
Input
5
2 4
1 9
1 8
4 9
3 12
Output
Yes
Input
3
334 1000
334 1000
334 1000
Output
No
Input
30
384 8895
1725 9791
170 1024
4 11105
2 6
578 1815
702 3352
143 5141
1420 6980
24 1602
849 999
76 7586
85 5570
444 4991
719 11090
470 10708
1137 4547
455 9003
110 9901
15 8578
368 3692
104 1286
3 4
366 12143
7 6649
610 2374
152 7324
4 7042
292 11386
334 5720
Output
Yes
Submitted Solution:
```
n = int(input())
a_lst = []
b_lst = []
for i in range(0, n):
a, b = [int(elem) for elem in input().split()]
a_lst.append(a)
b_lst.append(b)
tmp = zip(b_lst, a_lst)
tmp = sorted(tmp)
b_lst, a_lst = zip(*tmp)
print(b_lst, a_lst)
flag = 0
sums = 0
for i in range(0, len(a_lst)):
sums += a_lst[i]
if sums > b_lst[i]:
flag = 1
break
if flag == 0:
print("Yes")
else:
print("No")
```
No
| 102,749 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Kizahashi, who was appointed as the administrator of ABC at National Problem Workshop in the Kingdom of AtCoder, got too excited and took on too many jobs.
Let the current time be time 0. Kizahashi has N jobs numbered 1 to N.
It takes A_i units of time for Kizahashi to complete Job i. The deadline for Job i is time B_i, and he must complete the job before or at this time.
Kizahashi cannot work on two or more jobs simultaneously, but when he completes a job, he can start working on another immediately.
Can Kizahashi complete all the jobs in time? If he can, print `Yes`; if he cannot, print `No`.
Constraints
* All values in input are integers.
* 1 \leq N \leq 2 \times 10^5
* 1 \leq A_i, B_i \leq 10^9 (1 \leq i \leq N)
Input
Input is given from Standard Input in the following format:
N
A_1 B_1
.
.
.
A_N B_N
Output
If Kizahashi can complete all the jobs in time, print `Yes`; if he cannot, print `No`.
Examples
Input
5
2 4
1 9
1 8
4 9
3 12
Output
Yes
Input
3
334 1000
334 1000
334 1000
Output
No
Input
30
384 8895
1725 9791
170 1024
4 11105
2 6
578 1815
702 3352
143 5141
1420 6980
24 1602
849 999
76 7586
85 5570
444 4991
719 11090
470 10708
1137 4547
455 9003
110 9901
15 8578
368 3692
104 1286
3 4
366 12143
7 6649
610 2374
152 7324
4 7042
292 11386
334 5720
Output
Yes
Submitted Solution:
```
import sys
n = int(input())
li = sorted(map(lambda x: list(map(int, x.split()[::-1])), sys.stdin.readlines()))
print(li)
sum = 0
flag = "Yes"
for x, y in li:
sum += y
if x < sum:
flag = "No"
break
print(flag)
```
No
| 102,750 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Kizahashi, who was appointed as the administrator of ABC at National Problem Workshop in the Kingdom of AtCoder, got too excited and took on too many jobs.
Let the current time be time 0. Kizahashi has N jobs numbered 1 to N.
It takes A_i units of time for Kizahashi to complete Job i. The deadline for Job i is time B_i, and he must complete the job before or at this time.
Kizahashi cannot work on two or more jobs simultaneously, but when he completes a job, he can start working on another immediately.
Can Kizahashi complete all the jobs in time? If he can, print `Yes`; if he cannot, print `No`.
Constraints
* All values in input are integers.
* 1 \leq N \leq 2 \times 10^5
* 1 \leq A_i, B_i \leq 10^9 (1 \leq i \leq N)
Input
Input is given from Standard Input in the following format:
N
A_1 B_1
.
.
.
A_N B_N
Output
If Kizahashi can complete all the jobs in time, print `Yes`; if he cannot, print `No`.
Examples
Input
5
2 4
1 9
1 8
4 9
3 12
Output
Yes
Input
3
334 1000
334 1000
334 1000
Output
No
Input
30
384 8895
1725 9791
170 1024
4 11105
2 6
578 1815
702 3352
143 5141
1420 6980
24 1602
849 999
76 7586
85 5570
444 4991
719 11090
470 10708
1137 4547
455 9003
110 9901
15 8578
368 3692
104 1286
3 4
366 12143
7 6649
610 2374
152 7324
4 7042
292 11386
334 5720
Output
Yes
Submitted Solution:
```
N = int(input())
task = []
for i in range(N):
M = list(map(int,input().split()))
M[0],M[1]=M[1],M[0]
task.append(M)
task.sort()
K = 0
ans = 1
for i in range(N):
K += task[i,1]
if (K>task[i,0]):
ans = 0
break
if ans:
print("Yes")
else:
print("No")
```
No
| 102,751 |
Provide a correct Python 3 solution for this coding contest problem.
We will play a one-player game using a number line and N pieces.
First, we place each of these pieces at some integer coordinate.
Here, multiple pieces can be placed at the same coordinate.
Our objective is to visit all of the M coordinates X_1, X_2, ..., X_M with these pieces, by repeating the following move:
Move: Choose a piece and let x be its coordinate. Put that piece at coordinate x+1 or x-1.
Note that the coordinates where we initially place the pieces are already regarded as visited.
Find the minimum number of moves required to achieve the objective.
Constraints
* All values in input are integers.
* 1 \leq N \leq 10^5
* 1 \leq M \leq 10^5
* -10^5 \leq X_i \leq 10^5
* X_1, X_2, ..., X_M are all different.
Input
Input is given from Standard Input in the following format:
N M
X_1 X_2 ... X_M
Output
Find the minimum number of moves required to achieve the objective.
Examples
Input
2 5
10 12 1 2 14
Output
5
Input
3 7
-10 -3 0 9 -100 2 17
Output
19
Input
100 1
-100000
Output
0
"Correct Solution:
```
n,m=map(int,input().split())
x=list(map(int,input().split()))
x.sort()
l=[]
for i in range(m-1):
l.append(x[i+1]-x[i])
l.sort(reverse=True)
cnt=sum(l[:n-1])
print(sum(l)-cnt)
```
| 102,752 |
Provide a correct Python 3 solution for this coding contest problem.
We will play a one-player game using a number line and N pieces.
First, we place each of these pieces at some integer coordinate.
Here, multiple pieces can be placed at the same coordinate.
Our objective is to visit all of the M coordinates X_1, X_2, ..., X_M with these pieces, by repeating the following move:
Move: Choose a piece and let x be its coordinate. Put that piece at coordinate x+1 or x-1.
Note that the coordinates where we initially place the pieces are already regarded as visited.
Find the minimum number of moves required to achieve the objective.
Constraints
* All values in input are integers.
* 1 \leq N \leq 10^5
* 1 \leq M \leq 10^5
* -10^5 \leq X_i \leq 10^5
* X_1, X_2, ..., X_M are all different.
Input
Input is given from Standard Input in the following format:
N M
X_1 X_2 ... X_M
Output
Find the minimum number of moves required to achieve the objective.
Examples
Input
2 5
10 12 1 2 14
Output
5
Input
3 7
-10 -3 0 9 -100 2 17
Output
19
Input
100 1
-100000
Output
0
"Correct Solution:
```
N, M = map(int, input().split())
X = list(map(int, input().split()))
X.sort()
L = [X[i+1] - X[i] for i in range(M-1)]
L.sort()
N = M if N > M else N
print(sum(L[:(M-1)-(N-1)]))
```
| 102,753 |
Provide a correct Python 3 solution for this coding contest problem.
We will play a one-player game using a number line and N pieces.
First, we place each of these pieces at some integer coordinate.
Here, multiple pieces can be placed at the same coordinate.
Our objective is to visit all of the M coordinates X_1, X_2, ..., X_M with these pieces, by repeating the following move:
Move: Choose a piece and let x be its coordinate. Put that piece at coordinate x+1 or x-1.
Note that the coordinates where we initially place the pieces are already regarded as visited.
Find the minimum number of moves required to achieve the objective.
Constraints
* All values in input are integers.
* 1 \leq N \leq 10^5
* 1 \leq M \leq 10^5
* -10^5 \leq X_i \leq 10^5
* X_1, X_2, ..., X_M are all different.
Input
Input is given from Standard Input in the following format:
N M
X_1 X_2 ... X_M
Output
Find the minimum number of moves required to achieve the objective.
Examples
Input
2 5
10 12 1 2 14
Output
5
Input
3 7
-10 -3 0 9 -100 2 17
Output
19
Input
100 1
-100000
Output
0
"Correct Solution:
```
N,M=map(int, input().split())
X=list(map(int, input().split()))
X.sort()
diff = [X[i]-X[i-1] for i in range(1,M)]
diff.sort()
if N != 1:
del diff[-N+1:]
print(sum(diff))
```
| 102,754 |
Provide a correct Python 3 solution for this coding contest problem.
We will play a one-player game using a number line and N pieces.
First, we place each of these pieces at some integer coordinate.
Here, multiple pieces can be placed at the same coordinate.
Our objective is to visit all of the M coordinates X_1, X_2, ..., X_M with these pieces, by repeating the following move:
Move: Choose a piece and let x be its coordinate. Put that piece at coordinate x+1 or x-1.
Note that the coordinates where we initially place the pieces are already regarded as visited.
Find the minimum number of moves required to achieve the objective.
Constraints
* All values in input are integers.
* 1 \leq N \leq 10^5
* 1 \leq M \leq 10^5
* -10^5 \leq X_i \leq 10^5
* X_1, X_2, ..., X_M are all different.
Input
Input is given from Standard Input in the following format:
N M
X_1 X_2 ... X_M
Output
Find the minimum number of moves required to achieve the objective.
Examples
Input
2 5
10 12 1 2 14
Output
5
Input
3 7
-10 -3 0 9 -100 2 17
Output
19
Input
100 1
-100000
Output
0
"Correct Solution:
```
n,m=map(int,input().split())
X=sorted(list(map(int,input().split())))
D=sorted([X[i+1]-X[i] for i in range(m-1)])
print(sum(D[:m-n]) if m>n else 0)
```
| 102,755 |
Provide a correct Python 3 solution for this coding contest problem.
We will play a one-player game using a number line and N pieces.
First, we place each of these pieces at some integer coordinate.
Here, multiple pieces can be placed at the same coordinate.
Our objective is to visit all of the M coordinates X_1, X_2, ..., X_M with these pieces, by repeating the following move:
Move: Choose a piece and let x be its coordinate. Put that piece at coordinate x+1 or x-1.
Note that the coordinates where we initially place the pieces are already regarded as visited.
Find the minimum number of moves required to achieve the objective.
Constraints
* All values in input are integers.
* 1 \leq N \leq 10^5
* 1 \leq M \leq 10^5
* -10^5 \leq X_i \leq 10^5
* X_1, X_2, ..., X_M are all different.
Input
Input is given from Standard Input in the following format:
N M
X_1 X_2 ... X_M
Output
Find the minimum number of moves required to achieve the objective.
Examples
Input
2 5
10 12 1 2 14
Output
5
Input
3 7
-10 -3 0 9 -100 2 17
Output
19
Input
100 1
-100000
Output
0
"Correct Solution:
```
N,M= map(int,input().split())
X=list(map(int,input().split()))
X.sort()
L=[0]*(M-1)
for i in range(M-1):
L[i] = X[i+1]-X[i]
list.sort(L,reverse=True)
print(sum(L[N-1:]))
```
| 102,756 |
Provide a correct Python 3 solution for this coding contest problem.
We will play a one-player game using a number line and N pieces.
First, we place each of these pieces at some integer coordinate.
Here, multiple pieces can be placed at the same coordinate.
Our objective is to visit all of the M coordinates X_1, X_2, ..., X_M with these pieces, by repeating the following move:
Move: Choose a piece and let x be its coordinate. Put that piece at coordinate x+1 or x-1.
Note that the coordinates where we initially place the pieces are already regarded as visited.
Find the minimum number of moves required to achieve the objective.
Constraints
* All values in input are integers.
* 1 \leq N \leq 10^5
* 1 \leq M \leq 10^5
* -10^5 \leq X_i \leq 10^5
* X_1, X_2, ..., X_M are all different.
Input
Input is given from Standard Input in the following format:
N M
X_1 X_2 ... X_M
Output
Find the minimum number of moves required to achieve the objective.
Examples
Input
2 5
10 12 1 2 14
Output
5
Input
3 7
-10 -3 0 9 -100 2 17
Output
19
Input
100 1
-100000
Output
0
"Correct Solution:
```
N, M, *X = map(int, open(0).read().split())
X.sort()
y = sorted([X[i + 1] - X[i] for i in range(len(X) - 1)], reverse=True)
print(sum(y[N - 1:]))
```
| 102,757 |
Provide a correct Python 3 solution for this coding contest problem.
We will play a one-player game using a number line and N pieces.
First, we place each of these pieces at some integer coordinate.
Here, multiple pieces can be placed at the same coordinate.
Our objective is to visit all of the M coordinates X_1, X_2, ..., X_M with these pieces, by repeating the following move:
Move: Choose a piece and let x be its coordinate. Put that piece at coordinate x+1 or x-1.
Note that the coordinates where we initially place the pieces are already regarded as visited.
Find the minimum number of moves required to achieve the objective.
Constraints
* All values in input are integers.
* 1 \leq N \leq 10^5
* 1 \leq M \leq 10^5
* -10^5 \leq X_i \leq 10^5
* X_1, X_2, ..., X_M are all different.
Input
Input is given from Standard Input in the following format:
N M
X_1 X_2 ... X_M
Output
Find the minimum number of moves required to achieve the objective.
Examples
Input
2 5
10 12 1 2 14
Output
5
Input
3 7
-10 -3 0 9 -100 2 17
Output
19
Input
100 1
-100000
Output
0
"Correct Solution:
```
n, m = map(int, input().split())
x = sorted(list(map(int, input().split())))
dist = sorted([x[i+1] - x[i] for i in range(m-1)], reverse = True)
print(sum(dist[n-1:]))
```
| 102,758 |
Provide a correct Python 3 solution for this coding contest problem.
We will play a one-player game using a number line and N pieces.
First, we place each of these pieces at some integer coordinate.
Here, multiple pieces can be placed at the same coordinate.
Our objective is to visit all of the M coordinates X_1, X_2, ..., X_M with these pieces, by repeating the following move:
Move: Choose a piece and let x be its coordinate. Put that piece at coordinate x+1 or x-1.
Note that the coordinates where we initially place the pieces are already regarded as visited.
Find the minimum number of moves required to achieve the objective.
Constraints
* All values in input are integers.
* 1 \leq N \leq 10^5
* 1 \leq M \leq 10^5
* -10^5 \leq X_i \leq 10^5
* X_1, X_2, ..., X_M are all different.
Input
Input is given from Standard Input in the following format:
N M
X_1 X_2 ... X_M
Output
Find the minimum number of moves required to achieve the objective.
Examples
Input
2 5
10 12 1 2 14
Output
5
Input
3 7
-10 -3 0 9 -100 2 17
Output
19
Input
100 1
-100000
Output
0
"Correct Solution:
```
N,M,*X=map(int,open(0).read().split())
X.sort()
print(0 if N>=M else sum(sorted(abs(X[i+1]-X[i])for i in range(M-1))[:M-N]))
```
| 102,759 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
We will play a one-player game using a number line and N pieces.
First, we place each of these pieces at some integer coordinate.
Here, multiple pieces can be placed at the same coordinate.
Our objective is to visit all of the M coordinates X_1, X_2, ..., X_M with these pieces, by repeating the following move:
Move: Choose a piece and let x be its coordinate. Put that piece at coordinate x+1 or x-1.
Note that the coordinates where we initially place the pieces are already regarded as visited.
Find the minimum number of moves required to achieve the objective.
Constraints
* All values in input are integers.
* 1 \leq N \leq 10^5
* 1 \leq M \leq 10^5
* -10^5 \leq X_i \leq 10^5
* X_1, X_2, ..., X_M are all different.
Input
Input is given from Standard Input in the following format:
N M
X_1 X_2 ... X_M
Output
Find the minimum number of moves required to achieve the objective.
Examples
Input
2 5
10 12 1 2 14
Output
5
Input
3 7
-10 -3 0 9 -100 2 17
Output
19
Input
100 1
-100000
Output
0
Submitted Solution:
```
n,m=map(int,input().split())
x=list(map(int,input().split()))
x.sort()
x_dif=[b-a for a,b in zip(x[:-1],x[1:])]
x_dif.sort(reverse=True)
print(sum(x_dif[(n-1):]))
```
Yes
| 102,760 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
We will play a one-player game using a number line and N pieces.
First, we place each of these pieces at some integer coordinate.
Here, multiple pieces can be placed at the same coordinate.
Our objective is to visit all of the M coordinates X_1, X_2, ..., X_M with these pieces, by repeating the following move:
Move: Choose a piece and let x be its coordinate. Put that piece at coordinate x+1 or x-1.
Note that the coordinates where we initially place the pieces are already regarded as visited.
Find the minimum number of moves required to achieve the objective.
Constraints
* All values in input are integers.
* 1 \leq N \leq 10^5
* 1 \leq M \leq 10^5
* -10^5 \leq X_i \leq 10^5
* X_1, X_2, ..., X_M are all different.
Input
Input is given from Standard Input in the following format:
N M
X_1 X_2 ... X_M
Output
Find the minimum number of moves required to achieve the objective.
Examples
Input
2 5
10 12 1 2 14
Output
5
Input
3 7
-10 -3 0 9 -100 2 17
Output
19
Input
100 1
-100000
Output
0
Submitted Solution:
```
n,m = map(int,input().split())
x = list(map(int,input().split()))
x.sort()
y = [x[i+1]-x[i] for i in range(m-1)]
y.sort()
if n >= m:
print(0)
else:
print(sum(y[:(m-n)]))
```
Yes
| 102,761 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
We will play a one-player game using a number line and N pieces.
First, we place each of these pieces at some integer coordinate.
Here, multiple pieces can be placed at the same coordinate.
Our objective is to visit all of the M coordinates X_1, X_2, ..., X_M with these pieces, by repeating the following move:
Move: Choose a piece and let x be its coordinate. Put that piece at coordinate x+1 or x-1.
Note that the coordinates where we initially place the pieces are already regarded as visited.
Find the minimum number of moves required to achieve the objective.
Constraints
* All values in input are integers.
* 1 \leq N \leq 10^5
* 1 \leq M \leq 10^5
* -10^5 \leq X_i \leq 10^5
* X_1, X_2, ..., X_M are all different.
Input
Input is given from Standard Input in the following format:
N M
X_1 X_2 ... X_M
Output
Find the minimum number of moves required to achieve the objective.
Examples
Input
2 5
10 12 1 2 14
Output
5
Input
3 7
-10 -3 0 9 -100 2 17
Output
19
Input
100 1
-100000
Output
0
Submitted Solution:
```
n, m = map(int, input().split())
x = list(map(int, input().split()))
x.sort()
dif = [x[i+1] - x[i] for i in range(m-1)]
dif.sort(reverse=True)
print(sum(dif[n-1:]))
```
Yes
| 102,762 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
We will play a one-player game using a number line and N pieces.
First, we place each of these pieces at some integer coordinate.
Here, multiple pieces can be placed at the same coordinate.
Our objective is to visit all of the M coordinates X_1, X_2, ..., X_M with these pieces, by repeating the following move:
Move: Choose a piece and let x be its coordinate. Put that piece at coordinate x+1 or x-1.
Note that the coordinates where we initially place the pieces are already regarded as visited.
Find the minimum number of moves required to achieve the objective.
Constraints
* All values in input are integers.
* 1 \leq N \leq 10^5
* 1 \leq M \leq 10^5
* -10^5 \leq X_i \leq 10^5
* X_1, X_2, ..., X_M are all different.
Input
Input is given from Standard Input in the following format:
N M
X_1 X_2 ... X_M
Output
Find the minimum number of moves required to achieve the objective.
Examples
Input
2 5
10 12 1 2 14
Output
5
Input
3 7
-10 -3 0 9 -100 2 17
Output
19
Input
100 1
-100000
Output
0
Submitted Solution:
```
N,M,*X=map(int,open(0).read().split());X.sort();print(0if N>=M else sum(sorted(abs(X[i+1]-X[i])for i in range(M-1))[:M-N]))
```
Yes
| 102,763 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
We will play a one-player game using a number line and N pieces.
First, we place each of these pieces at some integer coordinate.
Here, multiple pieces can be placed at the same coordinate.
Our objective is to visit all of the M coordinates X_1, X_2, ..., X_M with these pieces, by repeating the following move:
Move: Choose a piece and let x be its coordinate. Put that piece at coordinate x+1 or x-1.
Note that the coordinates where we initially place the pieces are already regarded as visited.
Find the minimum number of moves required to achieve the objective.
Constraints
* All values in input are integers.
* 1 \leq N \leq 10^5
* 1 \leq M \leq 10^5
* -10^5 \leq X_i \leq 10^5
* X_1, X_2, ..., X_M are all different.
Input
Input is given from Standard Input in the following format:
N M
X_1 X_2 ... X_M
Output
Find the minimum number of moves required to achieve the objective.
Examples
Input
2 5
10 12 1 2 14
Output
5
Input
3 7
-10 -3 0 9 -100 2 17
Output
19
Input
100 1
-100000
Output
0
Submitted Solution:
```
n,m = map(int, input().split())
x = sorted(list(map(int, input().split())))
print(sum(sorted(abs([x[i+1]-x[i]) for i in range(m-1)])[:-(n-1)]))
```
No
| 102,764 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
We will play a one-player game using a number line and N pieces.
First, we place each of these pieces at some integer coordinate.
Here, multiple pieces can be placed at the same coordinate.
Our objective is to visit all of the M coordinates X_1, X_2, ..., X_M with these pieces, by repeating the following move:
Move: Choose a piece and let x be its coordinate. Put that piece at coordinate x+1 or x-1.
Note that the coordinates where we initially place the pieces are already regarded as visited.
Find the minimum number of moves required to achieve the objective.
Constraints
* All values in input are integers.
* 1 \leq N \leq 10^5
* 1 \leq M \leq 10^5
* -10^5 \leq X_i \leq 10^5
* X_1, X_2, ..., X_M are all different.
Input
Input is given from Standard Input in the following format:
N M
X_1 X_2 ... X_M
Output
Find the minimum number of moves required to achieve the objective.
Examples
Input
2 5
10 12 1 2 14
Output
5
Input
3 7
-10 -3 0 9 -100 2 17
Output
19
Input
100 1
-100000
Output
0
Submitted Solution:
```
N,M = map(int,input().split())
L = list(map(int,input().split()))
L = sorted(L)
#print(L)
ans = 0
cnt = 0
if N >= M :
ans = 0
else :
left = L[0]
right = L[-1]
L = L[1:-1]
cnt = 2
#print(L)
while len(L) :
if abs(left - L[0]) < abs(right - L[-1]) :
if cnt < N :
cnt += 1
else :
ans += abs(left - L[0])
left = L[0]
L = L[1:]
else :
if cnt < N :
cnt += 1
else :
ans += abs(right - L[-1])
right = L[-1]
L = L[:-1]
print(ans)
#print(cnt)
```
No
| 102,765 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
We will play a one-player game using a number line and N pieces.
First, we place each of these pieces at some integer coordinate.
Here, multiple pieces can be placed at the same coordinate.
Our objective is to visit all of the M coordinates X_1, X_2, ..., X_M with these pieces, by repeating the following move:
Move: Choose a piece and let x be its coordinate. Put that piece at coordinate x+1 or x-1.
Note that the coordinates where we initially place the pieces are already regarded as visited.
Find the minimum number of moves required to achieve the objective.
Constraints
* All values in input are integers.
* 1 \leq N \leq 10^5
* 1 \leq M \leq 10^5
* -10^5 \leq X_i \leq 10^5
* X_1, X_2, ..., X_M are all different.
Input
Input is given from Standard Input in the following format:
N M
X_1 X_2 ... X_M
Output
Find the minimum number of moves required to achieve the objective.
Examples
Input
2 5
10 12 1 2 14
Output
5
Input
3 7
-10 -3 0 9 -100 2 17
Output
19
Input
100 1
-100000
Output
0
Submitted Solution:
```
n, m = map(int, input().split())
if m == 1:
print(0)
exit()
x = list(map(int, input().split()))
x.sort()
d = [0]*(m-1)
for i in range(m-1):
d[i] = x[i+1] - x[i]
d.sort(reverse = True)
sum = sum(d)
for i in range(n-1):
sum -= d[i]
print(sum)
```
No
| 102,766 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
We will play a one-player game using a number line and N pieces.
First, we place each of these pieces at some integer coordinate.
Here, multiple pieces can be placed at the same coordinate.
Our objective is to visit all of the M coordinates X_1, X_2, ..., X_M with these pieces, by repeating the following move:
Move: Choose a piece and let x be its coordinate. Put that piece at coordinate x+1 or x-1.
Note that the coordinates where we initially place the pieces are already regarded as visited.
Find the minimum number of moves required to achieve the objective.
Constraints
* All values in input are integers.
* 1 \leq N \leq 10^5
* 1 \leq M \leq 10^5
* -10^5 \leq X_i \leq 10^5
* X_1, X_2, ..., X_M are all different.
Input
Input is given from Standard Input in the following format:
N M
X_1 X_2 ... X_M
Output
Find the minimum number of moves required to achieve the objective.
Examples
Input
2 5
10 12 1 2 14
Output
5
Input
3 7
-10 -3 0 9 -100 2 17
Output
19
Input
100 1
-100000
Output
0
Submitted Solution:
```
N, M = map(int, input().split())
X = list(map(int, input().split()))
points = X[:]
rem = N
points.sort()
if M<=N:
ans = 0
else:
import queue
q = queue.Queue()
q.put([[] for _ in range(N)])
import sys
INT_MAX = sys.maxsize
ans = INT_MAX
import itertools
for v in itertools.combinations(list(range(1, M)),N-1):
v = list(v)
v.insert(0,0)
v.append(M)
#print(v)
cost_sum = 0
for i in range(1, len(v)):
sub_p = points[v[i-1]:v[i]]
cost = sub_p[-1] - sub_p[0]
#print(sub_p, cost)
cost_sum += cost
ans = min(ans, cost_sum)
print(ans)
```
No
| 102,767 |
Provide a correct Python 3 solution for this coding contest problem.
Mr. Infinity has a string S consisting of digits from `1` to `9`. Each time the date changes, this string changes as follows:
* Each occurrence of `2` in S is replaced with `22`. Similarly, each `3` becomes `333`, `4` becomes `4444`, `5` becomes `55555`, `6` becomes `666666`, `7` becomes `7777777`, `8` becomes `88888888` and `9` becomes `999999999`. `1` remains as `1`.
For example, if S is `1324`, it becomes `1333224444` the next day, and it becomes `133333333322224444444444444444` the day after next. You are interested in what the string looks like after 5 \times 10^{15} days. What is the K-th character from the left in the string after 5 \times 10^{15} days?
Constraints
* S is a string of length between 1 and 100 (inclusive).
* K is an integer between 1 and 10^{18} (inclusive).
* The length of the string after 5 \times 10^{15} days is at least K.
Input
Input is given from Standard Input in the following format:
S
K
Output
Print the K-th character from the left in Mr. Infinity's string after 5 \times 10^{15} days.
Examples
Input
1214
4
Output
2
Input
3
157
Output
3
Input
299792458
9460730472580800
Output
2
"Correct Solution:
```
S = input()
K = int(input())
for s in S[:K]:
if s != '1':
print(s)
break
else:
print(1)
```
| 102,768 |
Provide a correct Python 3 solution for this coding contest problem.
Mr. Infinity has a string S consisting of digits from `1` to `9`. Each time the date changes, this string changes as follows:
* Each occurrence of `2` in S is replaced with `22`. Similarly, each `3` becomes `333`, `4` becomes `4444`, `5` becomes `55555`, `6` becomes `666666`, `7` becomes `7777777`, `8` becomes `88888888` and `9` becomes `999999999`. `1` remains as `1`.
For example, if S is `1324`, it becomes `1333224444` the next day, and it becomes `133333333322224444444444444444` the day after next. You are interested in what the string looks like after 5 \times 10^{15} days. What is the K-th character from the left in the string after 5 \times 10^{15} days?
Constraints
* S is a string of length between 1 and 100 (inclusive).
* K is an integer between 1 and 10^{18} (inclusive).
* The length of the string after 5 \times 10^{15} days is at least K.
Input
Input is given from Standard Input in the following format:
S
K
Output
Print the K-th character from the left in Mr. Infinity's string after 5 \times 10^{15} days.
Examples
Input
1214
4
Output
2
Input
3
157
Output
3
Input
299792458
9460730472580800
Output
2
"Correct Solution:
```
S = input()
K = int(input())
i = 0
while i < K - 1 and S[i] == '1':
i += 1
print(S[i])
```
| 102,769 |
Provide a correct Python 3 solution for this coding contest problem.
Mr. Infinity has a string S consisting of digits from `1` to `9`. Each time the date changes, this string changes as follows:
* Each occurrence of `2` in S is replaced with `22`. Similarly, each `3` becomes `333`, `4` becomes `4444`, `5` becomes `55555`, `6` becomes `666666`, `7` becomes `7777777`, `8` becomes `88888888` and `9` becomes `999999999`. `1` remains as `1`.
For example, if S is `1324`, it becomes `1333224444` the next day, and it becomes `133333333322224444444444444444` the day after next. You are interested in what the string looks like after 5 \times 10^{15} days. What is the K-th character from the left in the string after 5 \times 10^{15} days?
Constraints
* S is a string of length between 1 and 100 (inclusive).
* K is an integer between 1 and 10^{18} (inclusive).
* The length of the string after 5 \times 10^{15} days is at least K.
Input
Input is given from Standard Input in the following format:
S
K
Output
Print the K-th character from the left in Mr. Infinity's string after 5 \times 10^{15} days.
Examples
Input
1214
4
Output
2
Input
3
157
Output
3
Input
299792458
9460730472580800
Output
2
"Correct Solution:
```
s = input()
k = int(input())
ans = '1'
for c in s[:k]:
if c != '1':
ans = c
break
print(ans)
```
| 102,770 |
Provide a correct Python 3 solution for this coding contest problem.
Mr. Infinity has a string S consisting of digits from `1` to `9`. Each time the date changes, this string changes as follows:
* Each occurrence of `2` in S is replaced with `22`. Similarly, each `3` becomes `333`, `4` becomes `4444`, `5` becomes `55555`, `6` becomes `666666`, `7` becomes `7777777`, `8` becomes `88888888` and `9` becomes `999999999`. `1` remains as `1`.
For example, if S is `1324`, it becomes `1333224444` the next day, and it becomes `133333333322224444444444444444` the day after next. You are interested in what the string looks like after 5 \times 10^{15} days. What is the K-th character from the left in the string after 5 \times 10^{15} days?
Constraints
* S is a string of length between 1 and 100 (inclusive).
* K is an integer between 1 and 10^{18} (inclusive).
* The length of the string after 5 \times 10^{15} days is at least K.
Input
Input is given from Standard Input in the following format:
S
K
Output
Print the K-th character from the left in Mr. Infinity's string after 5 \times 10^{15} days.
Examples
Input
1214
4
Output
2
Input
3
157
Output
3
Input
299792458
9460730472580800
Output
2
"Correct Solution:
```
n = input()
k = int(input())
ans = 1
for i in range(k):
if n[i] != "1":
ans = n[i]
break
print(ans)
```
| 102,771 |
Provide a correct Python 3 solution for this coding contest problem.
Mr. Infinity has a string S consisting of digits from `1` to `9`. Each time the date changes, this string changes as follows:
* Each occurrence of `2` in S is replaced with `22`. Similarly, each `3` becomes `333`, `4` becomes `4444`, `5` becomes `55555`, `6` becomes `666666`, `7` becomes `7777777`, `8` becomes `88888888` and `9` becomes `999999999`. `1` remains as `1`.
For example, if S is `1324`, it becomes `1333224444` the next day, and it becomes `133333333322224444444444444444` the day after next. You are interested in what the string looks like after 5 \times 10^{15} days. What is the K-th character from the left in the string after 5 \times 10^{15} days?
Constraints
* S is a string of length between 1 and 100 (inclusive).
* K is an integer between 1 and 10^{18} (inclusive).
* The length of the string after 5 \times 10^{15} days is at least K.
Input
Input is given from Standard Input in the following format:
S
K
Output
Print the K-th character from the left in Mr. Infinity's string after 5 \times 10^{15} days.
Examples
Input
1214
4
Output
2
Input
3
157
Output
3
Input
299792458
9460730472580800
Output
2
"Correct Solution:
```
S=input()
K=int(input())
a=1
for i in range(min(len(S),K)):
if S[i]!='1':
a=int(S[i])
break
print(a)
```
| 102,772 |
Provide a correct Python 3 solution for this coding contest problem.
Mr. Infinity has a string S consisting of digits from `1` to `9`. Each time the date changes, this string changes as follows:
* Each occurrence of `2` in S is replaced with `22`. Similarly, each `3` becomes `333`, `4` becomes `4444`, `5` becomes `55555`, `6` becomes `666666`, `7` becomes `7777777`, `8` becomes `88888888` and `9` becomes `999999999`. `1` remains as `1`.
For example, if S is `1324`, it becomes `1333224444` the next day, and it becomes `133333333322224444444444444444` the day after next. You are interested in what the string looks like after 5 \times 10^{15} days. What is the K-th character from the left in the string after 5 \times 10^{15} days?
Constraints
* S is a string of length between 1 and 100 (inclusive).
* K is an integer between 1 and 10^{18} (inclusive).
* The length of the string after 5 \times 10^{15} days is at least K.
Input
Input is given from Standard Input in the following format:
S
K
Output
Print the K-th character from the left in Mr. Infinity's string after 5 \times 10^{15} days.
Examples
Input
1214
4
Output
2
Input
3
157
Output
3
Input
299792458
9460730472580800
Output
2
"Correct Solution:
```
s,k=open(0)
for i,c in enumerate(s):
if c=="1":
if i+1==int(k):break
else:break
print(c)
```
| 102,773 |
Provide a correct Python 3 solution for this coding contest problem.
Mr. Infinity has a string S consisting of digits from `1` to `9`. Each time the date changes, this string changes as follows:
* Each occurrence of `2` in S is replaced with `22`. Similarly, each `3` becomes `333`, `4` becomes `4444`, `5` becomes `55555`, `6` becomes `666666`, `7` becomes `7777777`, `8` becomes `88888888` and `9` becomes `999999999`. `1` remains as `1`.
For example, if S is `1324`, it becomes `1333224444` the next day, and it becomes `133333333322224444444444444444` the day after next. You are interested in what the string looks like after 5 \times 10^{15} days. What is the K-th character from the left in the string after 5 \times 10^{15} days?
Constraints
* S is a string of length between 1 and 100 (inclusive).
* K is an integer between 1 and 10^{18} (inclusive).
* The length of the string after 5 \times 10^{15} days is at least K.
Input
Input is given from Standard Input in the following format:
S
K
Output
Print the K-th character from the left in Mr. Infinity's string after 5 \times 10^{15} days.
Examples
Input
1214
4
Output
2
Input
3
157
Output
3
Input
299792458
9460730472580800
Output
2
"Correct Solution:
```
S=input()
K=int(input())
ans=1
for i in range(K):
if (S[i]!='1'):
ans=S[i]
break
print(ans)
```
| 102,774 |
Provide a correct Python 3 solution for this coding contest problem.
Mr. Infinity has a string S consisting of digits from `1` to `9`. Each time the date changes, this string changes as follows:
* Each occurrence of `2` in S is replaced with `22`. Similarly, each `3` becomes `333`, `4` becomes `4444`, `5` becomes `55555`, `6` becomes `666666`, `7` becomes `7777777`, `8` becomes `88888888` and `9` becomes `999999999`. `1` remains as `1`.
For example, if S is `1324`, it becomes `1333224444` the next day, and it becomes `133333333322224444444444444444` the day after next. You are interested in what the string looks like after 5 \times 10^{15} days. What is the K-th character from the left in the string after 5 \times 10^{15} days?
Constraints
* S is a string of length between 1 and 100 (inclusive).
* K is an integer between 1 and 10^{18} (inclusive).
* The length of the string after 5 \times 10^{15} days is at least K.
Input
Input is given from Standard Input in the following format:
S
K
Output
Print the K-th character from the left in Mr. Infinity's string after 5 \times 10^{15} days.
Examples
Input
1214
4
Output
2
Input
3
157
Output
3
Input
299792458
9460730472580800
Output
2
"Correct Solution:
```
s=input()
k=int(input())
ans="1"
for i in range(k):
if (int(s[i])!=1):
ans=s[i]
break
print(ans)
```
| 102,775 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Mr. Infinity has a string S consisting of digits from `1` to `9`. Each time the date changes, this string changes as follows:
* Each occurrence of `2` in S is replaced with `22`. Similarly, each `3` becomes `333`, `4` becomes `4444`, `5` becomes `55555`, `6` becomes `666666`, `7` becomes `7777777`, `8` becomes `88888888` and `9` becomes `999999999`. `1` remains as `1`.
For example, if S is `1324`, it becomes `1333224444` the next day, and it becomes `133333333322224444444444444444` the day after next. You are interested in what the string looks like after 5 \times 10^{15} days. What is the K-th character from the left in the string after 5 \times 10^{15} days?
Constraints
* S is a string of length between 1 and 100 (inclusive).
* K is an integer between 1 and 10^{18} (inclusive).
* The length of the string after 5 \times 10^{15} days is at least K.
Input
Input is given from Standard Input in the following format:
S
K
Output
Print the K-th character from the left in Mr. Infinity's string after 5 \times 10^{15} days.
Examples
Input
1214
4
Output
2
Input
3
157
Output
3
Input
299792458
9460730472580800
Output
2
Submitted Solution:
```
S = input()
K = int(input())
for i in range(len(S)):
if S[i] != '1':
break
print('1' if K <= i else S[i])
```
Yes
| 102,776 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Mr. Infinity has a string S consisting of digits from `1` to `9`. Each time the date changes, this string changes as follows:
* Each occurrence of `2` in S is replaced with `22`. Similarly, each `3` becomes `333`, `4` becomes `4444`, `5` becomes `55555`, `6` becomes `666666`, `7` becomes `7777777`, `8` becomes `88888888` and `9` becomes `999999999`. `1` remains as `1`.
For example, if S is `1324`, it becomes `1333224444` the next day, and it becomes `133333333322224444444444444444` the day after next. You are interested in what the string looks like after 5 \times 10^{15} days. What is the K-th character from the left in the string after 5 \times 10^{15} days?
Constraints
* S is a string of length between 1 and 100 (inclusive).
* K is an integer between 1 and 10^{18} (inclusive).
* The length of the string after 5 \times 10^{15} days is at least K.
Input
Input is given from Standard Input in the following format:
S
K
Output
Print the K-th character from the left in Mr. Infinity's string after 5 \times 10^{15} days.
Examples
Input
1214
4
Output
2
Input
3
157
Output
3
Input
299792458
9460730472580800
Output
2
Submitted Solution:
```
S=input()
K=int(input())
F=1
for i in range(K):
if(S[i]!='1'):
print(S[i])
F=0
break
if(F):
print(1)
```
Yes
| 102,777 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Mr. Infinity has a string S consisting of digits from `1` to `9`. Each time the date changes, this string changes as follows:
* Each occurrence of `2` in S is replaced with `22`. Similarly, each `3` becomes `333`, `4` becomes `4444`, `5` becomes `55555`, `6` becomes `666666`, `7` becomes `7777777`, `8` becomes `88888888` and `9` becomes `999999999`. `1` remains as `1`.
For example, if S is `1324`, it becomes `1333224444` the next day, and it becomes `133333333322224444444444444444` the day after next. You are interested in what the string looks like after 5 \times 10^{15} days. What is the K-th character from the left in the string after 5 \times 10^{15} days?
Constraints
* S is a string of length between 1 and 100 (inclusive).
* K is an integer between 1 and 10^{18} (inclusive).
* The length of the string after 5 \times 10^{15} days is at least K.
Input
Input is given from Standard Input in the following format:
S
K
Output
Print the K-th character from the left in Mr. Infinity's string after 5 \times 10^{15} days.
Examples
Input
1214
4
Output
2
Input
3
157
Output
3
Input
299792458
9460730472580800
Output
2
Submitted Solution:
```
s = input()
k = int(input())
for i in range(k):
if s[i] != "1":
print(s[i])
exit()
print(1)
```
Yes
| 102,778 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Mr. Infinity has a string S consisting of digits from `1` to `9`. Each time the date changes, this string changes as follows:
* Each occurrence of `2` in S is replaced with `22`. Similarly, each `3` becomes `333`, `4` becomes `4444`, `5` becomes `55555`, `6` becomes `666666`, `7` becomes `7777777`, `8` becomes `88888888` and `9` becomes `999999999`. `1` remains as `1`.
For example, if S is `1324`, it becomes `1333224444` the next day, and it becomes `133333333322224444444444444444` the day after next. You are interested in what the string looks like after 5 \times 10^{15} days. What is the K-th character from the left in the string after 5 \times 10^{15} days?
Constraints
* S is a string of length between 1 and 100 (inclusive).
* K is an integer between 1 and 10^{18} (inclusive).
* The length of the string after 5 \times 10^{15} days is at least K.
Input
Input is given from Standard Input in the following format:
S
K
Output
Print the K-th character from the left in Mr. Infinity's string after 5 \times 10^{15} days.
Examples
Input
1214
4
Output
2
Input
3
157
Output
3
Input
299792458
9460730472580800
Output
2
Submitted Solution:
```
S=input()
K=int(input())
for i in range(K):
if S[i]!='1':
print(S[i])
exit()
print(S[K-1])
```
Yes
| 102,779 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Mr. Infinity has a string S consisting of digits from `1` to `9`. Each time the date changes, this string changes as follows:
* Each occurrence of `2` in S is replaced with `22`. Similarly, each `3` becomes `333`, `4` becomes `4444`, `5` becomes `55555`, `6` becomes `666666`, `7` becomes `7777777`, `8` becomes `88888888` and `9` becomes `999999999`. `1` remains as `1`.
For example, if S is `1324`, it becomes `1333224444` the next day, and it becomes `133333333322224444444444444444` the day after next. You are interested in what the string looks like after 5 \times 10^{15} days. What is the K-th character from the left in the string after 5 \times 10^{15} days?
Constraints
* S is a string of length between 1 and 100 (inclusive).
* K is an integer between 1 and 10^{18} (inclusive).
* The length of the string after 5 \times 10^{15} days is at least K.
Input
Input is given from Standard Input in the following format:
S
K
Output
Print the K-th character from the left in Mr. Infinity's string after 5 \times 10^{15} days.
Examples
Input
1214
4
Output
2
Input
3
157
Output
3
Input
299792458
9460730472580800
Output
2
Submitted Solution:
```
s = input()
n = int(input())
for i in s:
if i != "1":
print(i)
break
else:
print(1)
```
No
| 102,780 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Mr. Infinity has a string S consisting of digits from `1` to `9`. Each time the date changes, this string changes as follows:
* Each occurrence of `2` in S is replaced with `22`. Similarly, each `3` becomes `333`, `4` becomes `4444`, `5` becomes `55555`, `6` becomes `666666`, `7` becomes `7777777`, `8` becomes `88888888` and `9` becomes `999999999`. `1` remains as `1`.
For example, if S is `1324`, it becomes `1333224444` the next day, and it becomes `133333333322224444444444444444` the day after next. You are interested in what the string looks like after 5 \times 10^{15} days. What is the K-th character from the left in the string after 5 \times 10^{15} days?
Constraints
* S is a string of length between 1 and 100 (inclusive).
* K is an integer between 1 and 10^{18} (inclusive).
* The length of the string after 5 \times 10^{15} days is at least K.
Input
Input is given from Standard Input in the following format:
S
K
Output
Print the K-th character from the left in Mr. Infinity's string after 5 \times 10^{15} days.
Examples
Input
1214
4
Output
2
Input
3
157
Output
3
Input
299792458
9460730472580800
Output
2
Submitted Solution:
```
s = input()
k = int(input())
l = len(s)
first = ''
for i in range(l):
if s[i] != '1':
first = s[i]
pos = i
break
print('1' if k <= pos else first)
```
No
| 102,781 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Mr. Infinity has a string S consisting of digits from `1` to `9`. Each time the date changes, this string changes as follows:
* Each occurrence of `2` in S is replaced with `22`. Similarly, each `3` becomes `333`, `4` becomes `4444`, `5` becomes `55555`, `6` becomes `666666`, `7` becomes `7777777`, `8` becomes `88888888` and `9` becomes `999999999`. `1` remains as `1`.
For example, if S is `1324`, it becomes `1333224444` the next day, and it becomes `133333333322224444444444444444` the day after next. You are interested in what the string looks like after 5 \times 10^{15} days. What is the K-th character from the left in the string after 5 \times 10^{15} days?
Constraints
* S is a string of length between 1 and 100 (inclusive).
* K is an integer between 1 and 10^{18} (inclusive).
* The length of the string after 5 \times 10^{15} days is at least K.
Input
Input is given from Standard Input in the following format:
S
K
Output
Print the K-th character from the left in Mr. Infinity's string after 5 \times 10^{15} days.
Examples
Input
1214
4
Output
2
Input
3
157
Output
3
Input
299792458
9460730472580800
Output
2
Submitted Solution:
```
n = input()
m = int(input())
cnt = 0
for i in range(len(n)):
if n[i] == "1" :
cnt +=1
else:
if cnt >=m:
print(1)
else:
break
for i in range(len(n)):
if n[i] != "1":
print(n[i])
break
```
No
| 102,782 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Mr. Infinity has a string S consisting of digits from `1` to `9`. Each time the date changes, this string changes as follows:
* Each occurrence of `2` in S is replaced with `22`. Similarly, each `3` becomes `333`, `4` becomes `4444`, `5` becomes `55555`, `6` becomes `666666`, `7` becomes `7777777`, `8` becomes `88888888` and `9` becomes `999999999`. `1` remains as `1`.
For example, if S is `1324`, it becomes `1333224444` the next day, and it becomes `133333333322224444444444444444` the day after next. You are interested in what the string looks like after 5 \times 10^{15} days. What is the K-th character from the left in the string after 5 \times 10^{15} days?
Constraints
* S is a string of length between 1 and 100 (inclusive).
* K is an integer between 1 and 10^{18} (inclusive).
* The length of the string after 5 \times 10^{15} days is at least K.
Input
Input is given from Standard Input in the following format:
S
K
Output
Print the K-th character from the left in Mr. Infinity's string after 5 \times 10^{15} days.
Examples
Input
1214
4
Output
2
Input
3
157
Output
3
Input
299792458
9460730472580800
Output
2
Submitted Solution:
```
S = input()
K = int(input())
if S[0] == "1":
ind = 1
while S[ind] == "1":
ind += 1
print(S[ind])
else:
print(S[0])
```
No
| 102,783 |
Provide a correct Python 3 solution for this coding contest problem.
You are given positive integers X and Y. If there exists a positive integer not greater than 10^{18} that is a multiple of X but not a multiple of Y, choose one such integer and print it. If it does not exist, print -1.
Constraints
* 1 ≤ X,Y ≤ 10^9
* X and Y are integers.
Input
Input is given from Standard Input in the following format:
X Y
Output
Print a positive integer not greater than 10^{18} that is a multiple of X but not a multiple of Y, or print -1 if it does not exist.
Examples
Input
8 6
Output
16
Input
3 3
Output
-1
"Correct Solution:
```
X, Y = [int(i) for i in input().split()]
if X % Y == 0:
print(-1)
else:
print(X)
```
| 102,784 |
Provide a correct Python 3 solution for this coding contest problem.
You are given positive integers X and Y. If there exists a positive integer not greater than 10^{18} that is a multiple of X but not a multiple of Y, choose one such integer and print it. If it does not exist, print -1.
Constraints
* 1 ≤ X,Y ≤ 10^9
* X and Y are integers.
Input
Input is given from Standard Input in the following format:
X Y
Output
Print a positive integer not greater than 10^{18} that is a multiple of X but not a multiple of Y, or print -1 if it does not exist.
Examples
Input
8 6
Output
16
Input
3 3
Output
-1
"Correct Solution:
```
x,y=map(int,input().split())
print(-1 if x%y==0 else x*(y-1))
```
| 102,785 |
Provide a correct Python 3 solution for this coding contest problem.
You are given positive integers X and Y. If there exists a positive integer not greater than 10^{18} that is a multiple of X but not a multiple of Y, choose one such integer and print it. If it does not exist, print -1.
Constraints
* 1 ≤ X,Y ≤ 10^9
* X and Y are integers.
Input
Input is given from Standard Input in the following format:
X Y
Output
Print a positive integer not greater than 10^{18} that is a multiple of X but not a multiple of Y, or print -1 if it does not exist.
Examples
Input
8 6
Output
16
Input
3 3
Output
-1
"Correct Solution:
```
x,y=map(int,input().split())
a=x*(y-1)
if a%y==0:
print(-1)
else:
print(a)
```
| 102,786 |
Provide a correct Python 3 solution for this coding contest problem.
You are given positive integers X and Y. If there exists a positive integer not greater than 10^{18} that is a multiple of X but not a multiple of Y, choose one such integer and print it. If it does not exist, print -1.
Constraints
* 1 ≤ X,Y ≤ 10^9
* X and Y are integers.
Input
Input is given from Standard Input in the following format:
X Y
Output
Print a positive integer not greater than 10^{18} that is a multiple of X but not a multiple of Y, or print -1 if it does not exist.
Examples
Input
8 6
Output
16
Input
3 3
Output
-1
"Correct Solution:
```
x, y = input().split()
x = int(x)
y = int(y)
if x % y == 0:
print(-1)
else:
print(x * (y + 1))
```
| 102,787 |
Provide a correct Python 3 solution for this coding contest problem.
You are given positive integers X and Y. If there exists a positive integer not greater than 10^{18} that is a multiple of X but not a multiple of Y, choose one such integer and print it. If it does not exist, print -1.
Constraints
* 1 ≤ X,Y ≤ 10^9
* X and Y are integers.
Input
Input is given from Standard Input in the following format:
X Y
Output
Print a positive integer not greater than 10^{18} that is a multiple of X but not a multiple of Y, or print -1 if it does not exist.
Examples
Input
8 6
Output
16
Input
3 3
Output
-1
"Correct Solution:
```
x, y=map(int, input().split())
print(-1 if x%y==0 else x)
```
| 102,788 |
Provide a correct Python 3 solution for this coding contest problem.
You are given positive integers X and Y. If there exists a positive integer not greater than 10^{18} that is a multiple of X but not a multiple of Y, choose one such integer and print it. If it does not exist, print -1.
Constraints
* 1 ≤ X,Y ≤ 10^9
* X and Y are integers.
Input
Input is given from Standard Input in the following format:
X Y
Output
Print a positive integer not greater than 10^{18} that is a multiple of X but not a multiple of Y, or print -1 if it does not exist.
Examples
Input
8 6
Output
16
Input
3 3
Output
-1
"Correct Solution:
```
X, Y = map(int, input().split())
a = X / Y
if a == int(a):
ans = -1
else:
ans = X
print(ans)
```
| 102,789 |
Provide a correct Python 3 solution for this coding contest problem.
You are given positive integers X and Y. If there exists a positive integer not greater than 10^{18} that is a multiple of X but not a multiple of Y, choose one such integer and print it. If it does not exist, print -1.
Constraints
* 1 ≤ X,Y ≤ 10^9
* X and Y are integers.
Input
Input is given from Standard Input in the following format:
X Y
Output
Print a positive integer not greater than 10^{18} that is a multiple of X but not a multiple of Y, or print -1 if it does not exist.
Examples
Input
8 6
Output
16
Input
3 3
Output
-1
"Correct Solution:
```
X, Y = map(int, input().split())
ans = (Y - 1) * X
if ans % Y == 0:
print(-1)
else:
print(ans)
```
| 102,790 |
Provide a correct Python 3 solution for this coding contest problem.
You are given positive integers X and Y. If there exists a positive integer not greater than 10^{18} that is a multiple of X but not a multiple of Y, choose one such integer and print it. If it does not exist, print -1.
Constraints
* 1 ≤ X,Y ≤ 10^9
* X and Y are integers.
Input
Input is given from Standard Input in the following format:
X Y
Output
Print a positive integer not greater than 10^{18} that is a multiple of X but not a multiple of Y, or print -1 if it does not exist.
Examples
Input
8 6
Output
16
Input
3 3
Output
-1
"Correct Solution:
```
#15:15
x,y = map(int,input().split())
if x % y == 0:
print(-1)
else:
print(x)
```
| 102,791 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given positive integers X and Y. If there exists a positive integer not greater than 10^{18} that is a multiple of X but not a multiple of Y, choose one such integer and print it. If it does not exist, print -1.
Constraints
* 1 ≤ X,Y ≤ 10^9
* X and Y are integers.
Input
Input is given from Standard Input in the following format:
X Y
Output
Print a positive integer not greater than 10^{18} that is a multiple of X but not a multiple of Y, or print -1 if it does not exist.
Examples
Input
8 6
Output
16
Input
3 3
Output
-1
Submitted Solution:
```
def abc():
x, y = map(int, input().rstrip().split())
if x % y == 0:
print(-1)
return
print(x)
abc()
```
Yes
| 102,792 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given positive integers X and Y. If there exists a positive integer not greater than 10^{18} that is a multiple of X but not a multiple of Y, choose one such integer and print it. If it does not exist, print -1.
Constraints
* 1 ≤ X,Y ≤ 10^9
* X and Y are integers.
Input
Input is given from Standard Input in the following format:
X Y
Output
Print a positive integer not greater than 10^{18} that is a multiple of X but not a multiple of Y, or print -1 if it does not exist.
Examples
Input
8 6
Output
16
Input
3 3
Output
-1
Submitted Solution:
```
x,y=map(int,input().split())
if x%y==0:
print("-1")
else:
for i in range(1,x*y):
if x*i%y!=0:
print(x*i)
exit()
```
Yes
| 102,793 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given positive integers X and Y. If there exists a positive integer not greater than 10^{18} that is a multiple of X but not a multiple of Y, choose one such integer and print it. If it does not exist, print -1.
Constraints
* 1 ≤ X,Y ≤ 10^9
* X and Y are integers.
Input
Input is given from Standard Input in the following format:
X Y
Output
Print a positive integer not greater than 10^{18} that is a multiple of X but not a multiple of Y, or print -1 if it does not exist.
Examples
Input
8 6
Output
16
Input
3 3
Output
-1
Submitted Solution:
```
x,y=map(int,input().split());print((x+1)*(x%y>0)-1)
```
Yes
| 102,794 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given positive integers X and Y. If there exists a positive integer not greater than 10^{18} that is a multiple of X but not a multiple of Y, choose one such integer and print it. If it does not exist, print -1.
Constraints
* 1 ≤ X,Y ≤ 10^9
* X and Y are integers.
Input
Input is given from Standard Input in the following format:
X Y
Output
Print a positive integer not greater than 10^{18} that is a multiple of X but not a multiple of Y, or print -1 if it does not exist.
Examples
Input
8 6
Output
16
Input
3 3
Output
-1
Submitted Solution:
```
X, Y = map(int, input().split())
if X < Y or not(X%Y == 0):
print(X)
else:
print(-1)
```
Yes
| 102,795 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given positive integers X and Y. If there exists a positive integer not greater than 10^{18} that is a multiple of X but not a multiple of Y, choose one such integer and print it. If it does not exist, print -1.
Constraints
* 1 ≤ X,Y ≤ 10^9
* X and Y are integers.
Input
Input is given from Standard Input in the following format:
X Y
Output
Print a positive integer not greater than 10^{18} that is a multiple of X but not a multiple of Y, or print -1 if it does not exist.
Examples
Input
8 6
Output
16
Input
3 3
Output
-1
Submitted Solution:
```
x,y=map(int,input().split())
print(-1 if x%y else x)
```
No
| 102,796 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given positive integers X and Y. If there exists a positive integer not greater than 10^{18} that is a multiple of X but not a multiple of Y, choose one such integer and print it. If it does not exist, print -1.
Constraints
* 1 ≤ X,Y ≤ 10^9
* X and Y are integers.
Input
Input is given from Standard Input in the following format:
X Y
Output
Print a positive integer not greater than 10^{18} that is a multiple of X but not a multiple of Y, or print -1 if it does not exist.
Examples
Input
8 6
Output
16
Input
3 3
Output
-1
Submitted Solution:
```
x,y=map(int,input().split())
print(x if x%y==0 else -1)
```
No
| 102,797 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given positive integers X and Y. If there exists a positive integer not greater than 10^{18} that is a multiple of X but not a multiple of Y, choose one such integer and print it. If it does not exist, print -1.
Constraints
* 1 ≤ X,Y ≤ 10^9
* X and Y are integers.
Input
Input is given from Standard Input in the following format:
X Y
Output
Print a positive integer not greater than 10^{18} that is a multiple of X but not a multiple of Y, or print -1 if it does not exist.
Examples
Input
8 6
Output
16
Input
3 3
Output
-1
Submitted Solution:
```
x, y = map(int,input().split())
if x*(y-1)//y != 0:
print(x*(y-1))
else:
print(-1)
```
No
| 102,798 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given positive integers X and Y. If there exists a positive integer not greater than 10^{18} that is a multiple of X but not a multiple of Y, choose one such integer and print it. If it does not exist, print -1.
Constraints
* 1 ≤ X,Y ≤ 10^9
* X and Y are integers.
Input
Input is given from Standard Input in the following format:
X Y
Output
Print a positive integer not greater than 10^{18} that is a multiple of X but not a multiple of Y, or print -1 if it does not exist.
Examples
Input
8 6
Output
16
Input
3 3
Output
-1
Submitted Solution:
```
x,y = input().split(' ')
x = int(x)
y = int(y)
if y == 1:
print(-1)
else:
if 0 < x and x <= 1e18:
print(x)
else :
print(-1)
```
No
| 102,799 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.