message stringlengths 2 16.2k | message_type stringclasses 2 values | message_id int64 0 1 | conversation_id int64 575 109k | cluster float64 16 16 | __index_level_0__ int64 1.15k 217k |
|---|---|---|---|---|---|
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Snuke and Raccoon have a heap of N cards. The i-th card from the top has the integer a_i written on it.
They will share these cards. First, Snuke will take some number of cards from the top of the heap, then Raccoon will take all the remaining cards. Here, both Snuke and Raccoon have to take at least one card.
Let the sum of the integers on Snuke's cards and Raccoon's cards be x and y, respectively. They would like to minimize |x-y|. Find the minimum possible value of |x-y|.
Constraints
* 2 \leq N \leq 2 \times 10^5
* -10^{9} \leq a_i \leq 10^{9}
* a_i is an integer.
Input
Input is given from Standard Input in the following format:
N
a_1 a_2 ... a_{N}
Output
Print the answer.
Examples
Input
6
1 2 3 4 5 6
Output
1
Input
2
10 -10
Output
20
Submitted Solution:
```
from fractions import gcd
from collections import Counter, deque, defaultdict
from heapq import heappush, heappop, heappushpop, heapify, heapreplace, merge
from bisect import bisect_left, bisect_right, bisect, insort_left, insort_right, insort
from itertools import product, combinations,permutations
from copy import deepcopy
import sys
sys.setrecursionlimit(4100000)
if __name__ == '__main__':
N = int(input())
A = list(map(int, input().split()))
acc_A = []
acc = 0
for a in A:
acc += a
acc_A.append(acc)
minv = 1001001001
for c in acc_A:
minv = min(abs(c-(acc_A[-1]-c)), minv)
print(minv)
``` | instruction | 0 | 33,215 | 16 | 66,430 |
No | output | 1 | 33,215 | 16 | 66,431 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Snuke and Raccoon have a heap of N cards. The i-th card from the top has the integer a_i written on it.
They will share these cards. First, Snuke will take some number of cards from the top of the heap, then Raccoon will take all the remaining cards. Here, both Snuke and Raccoon have to take at least one card.
Let the sum of the integers on Snuke's cards and Raccoon's cards be x and y, respectively. They would like to minimize |x-y|. Find the minimum possible value of |x-y|.
Constraints
* 2 \leq N \leq 2 \times 10^5
* -10^{9} \leq a_i \leq 10^{9}
* a_i is an integer.
Input
Input is given from Standard Input in the following format:
N
a_1 a_2 ... a_{N}
Output
Print the answer.
Examples
Input
6
1 2 3 4 5 6
Output
1
Input
2
10 -10
Output
20
Submitted Solution:
```
N = int(input())
a = list(map(int,input().split()))
x = a[0]
y = sum(a[1:])
ans = abs(x-y)
for i in range(N-1):
x += a[i+1]
y -= a[i+1]
ans = min(ans, abs(x-y))
print(ans)
``` | instruction | 0 | 33,216 | 16 | 66,432 |
No | output | 1 | 33,216 | 16 | 66,433 |
Provide a correct Python 3 solution for this coding contest problem.
Snuke has decided to play with a six-sided die. Each of its six sides shows an integer 1 through 6, and two numbers on opposite sides always add up to 7.
Snuke will first put the die on the table with an arbitrary side facing upward, then repeatedly perform the following operation:
* Operation: Rotate the die 90° toward one of the following directions: left, right, front (the die will come closer) and back (the die will go farther). Then, obtain y points where y is the number written in the side facing upward.
For example, let us consider the situation where the side showing 1 faces upward, the near side shows 5 and the right side shows 4, as illustrated in the figure. If the die is rotated toward the right as shown in the figure, the side showing 3 will face upward. Besides, the side showing 4 will face upward if the die is rotated toward the left, the side showing 2 will face upward if the die is rotated toward the front, and the side showing 5 will face upward if the die is rotated toward the back.
864abc2e4a08c26015ffd007a30aab03.png
Find the minimum number of operation Snuke needs to perform in order to score at least x points in total.
Constraints
* 1 ≦ x ≦ 10^{15}
* x is an integer.
Input
The input is given from Standard Input in the following format:
x
Output
Print the answer.
Examples
Input
7
Output
2
Input
149696127901
Output
27217477801 | instruction | 0 | 33,217 | 16 | 66,434 |
"Correct Solution:
```
a=int(input())
ans=a//11*2
a%=11
if 6>=a>=1:ans+=1
elif a!=0:ans+=2
print(ans)
``` | output | 1 | 33,217 | 16 | 66,435 |
Provide a correct Python 3 solution for this coding contest problem.
Snuke has decided to play with a six-sided die. Each of its six sides shows an integer 1 through 6, and two numbers on opposite sides always add up to 7.
Snuke will first put the die on the table with an arbitrary side facing upward, then repeatedly perform the following operation:
* Operation: Rotate the die 90° toward one of the following directions: left, right, front (the die will come closer) and back (the die will go farther). Then, obtain y points where y is the number written in the side facing upward.
For example, let us consider the situation where the side showing 1 faces upward, the near side shows 5 and the right side shows 4, as illustrated in the figure. If the die is rotated toward the right as shown in the figure, the side showing 3 will face upward. Besides, the side showing 4 will face upward if the die is rotated toward the left, the side showing 2 will face upward if the die is rotated toward the front, and the side showing 5 will face upward if the die is rotated toward the back.
864abc2e4a08c26015ffd007a30aab03.png
Find the minimum number of operation Snuke needs to perform in order to score at least x points in total.
Constraints
* 1 ≦ x ≦ 10^{15}
* x is an integer.
Input
The input is given from Standard Input in the following format:
x
Output
Print the answer.
Examples
Input
7
Output
2
Input
149696127901
Output
27217477801 | instruction | 0 | 33,218 | 16 | 66,436 |
"Correct Solution:
```
n=int(input());print((n//11)*2+([0]+[1]*6+[2]*4)[n%11])
``` | output | 1 | 33,218 | 16 | 66,437 |
Provide a correct Python 3 solution for this coding contest problem.
Snuke has decided to play with a six-sided die. Each of its six sides shows an integer 1 through 6, and two numbers on opposite sides always add up to 7.
Snuke will first put the die on the table with an arbitrary side facing upward, then repeatedly perform the following operation:
* Operation: Rotate the die 90° toward one of the following directions: left, right, front (the die will come closer) and back (the die will go farther). Then, obtain y points where y is the number written in the side facing upward.
For example, let us consider the situation where the side showing 1 faces upward, the near side shows 5 and the right side shows 4, as illustrated in the figure. If the die is rotated toward the right as shown in the figure, the side showing 3 will face upward. Besides, the side showing 4 will face upward if the die is rotated toward the left, the side showing 2 will face upward if the die is rotated toward the front, and the side showing 5 will face upward if the die is rotated toward the back.
864abc2e4a08c26015ffd007a30aab03.png
Find the minimum number of operation Snuke needs to perform in order to score at least x points in total.
Constraints
* 1 ≦ x ≦ 10^{15}
* x is an integer.
Input
The input is given from Standard Input in the following format:
x
Output
Print the answer.
Examples
Input
7
Output
2
Input
149696127901
Output
27217477801 | instruction | 0 | 33,219 | 16 | 66,438 |
"Correct Solution:
```
x=int(input())
n=(x//11)*2+(x%11)//6
if (x%11)%6==0:
print(n)
else:
print(n+1)
``` | output | 1 | 33,219 | 16 | 66,439 |
Provide a correct Python 3 solution for this coding contest problem.
Snuke has decided to play with a six-sided die. Each of its six sides shows an integer 1 through 6, and two numbers on opposite sides always add up to 7.
Snuke will first put the die on the table with an arbitrary side facing upward, then repeatedly perform the following operation:
* Operation: Rotate the die 90° toward one of the following directions: left, right, front (the die will come closer) and back (the die will go farther). Then, obtain y points where y is the number written in the side facing upward.
For example, let us consider the situation where the side showing 1 faces upward, the near side shows 5 and the right side shows 4, as illustrated in the figure. If the die is rotated toward the right as shown in the figure, the side showing 3 will face upward. Besides, the side showing 4 will face upward if the die is rotated toward the left, the side showing 2 will face upward if the die is rotated toward the front, and the side showing 5 will face upward if the die is rotated toward the back.
864abc2e4a08c26015ffd007a30aab03.png
Find the minimum number of operation Snuke needs to perform in order to score at least x points in total.
Constraints
* 1 ≦ x ≦ 10^{15}
* x is an integer.
Input
The input is given from Standard Input in the following format:
x
Output
Print the answer.
Examples
Input
7
Output
2
Input
149696127901
Output
27217477801 | instruction | 0 | 33,220 | 16 | 66,440 |
"Correct Solution:
```
iX=int(input())-1
print((iX//11)*2+((iX%11)//6)+1)
``` | output | 1 | 33,220 | 16 | 66,441 |
Provide a correct Python 3 solution for this coding contest problem.
Snuke has decided to play with a six-sided die. Each of its six sides shows an integer 1 through 6, and two numbers on opposite sides always add up to 7.
Snuke will first put the die on the table with an arbitrary side facing upward, then repeatedly perform the following operation:
* Operation: Rotate the die 90° toward one of the following directions: left, right, front (the die will come closer) and back (the die will go farther). Then, obtain y points where y is the number written in the side facing upward.
For example, let us consider the situation where the side showing 1 faces upward, the near side shows 5 and the right side shows 4, as illustrated in the figure. If the die is rotated toward the right as shown in the figure, the side showing 3 will face upward. Besides, the side showing 4 will face upward if the die is rotated toward the left, the side showing 2 will face upward if the die is rotated toward the front, and the side showing 5 will face upward if the die is rotated toward the back.
864abc2e4a08c26015ffd007a30aab03.png
Find the minimum number of operation Snuke needs to perform in order to score at least x points in total.
Constraints
* 1 ≦ x ≦ 10^{15}
* x is an integer.
Input
The input is given from Standard Input in the following format:
x
Output
Print the answer.
Examples
Input
7
Output
2
Input
149696127901
Output
27217477801 | instruction | 0 | 33,221 | 16 | 66,442 |
"Correct Solution:
```
n = int(input())
ret = (n-1)//11*2+1
if (n-1)%11 >= 6: ret += 1
print(ret)
``` | output | 1 | 33,221 | 16 | 66,443 |
Provide a correct Python 3 solution for this coding contest problem.
Snuke has decided to play with a six-sided die. Each of its six sides shows an integer 1 through 6, and two numbers on opposite sides always add up to 7.
Snuke will first put the die on the table with an arbitrary side facing upward, then repeatedly perform the following operation:
* Operation: Rotate the die 90° toward one of the following directions: left, right, front (the die will come closer) and back (the die will go farther). Then, obtain y points where y is the number written in the side facing upward.
For example, let us consider the situation where the side showing 1 faces upward, the near side shows 5 and the right side shows 4, as illustrated in the figure. If the die is rotated toward the right as shown in the figure, the side showing 3 will face upward. Besides, the side showing 4 will face upward if the die is rotated toward the left, the side showing 2 will face upward if the die is rotated toward the front, and the side showing 5 will face upward if the die is rotated toward the back.
864abc2e4a08c26015ffd007a30aab03.png
Find the minimum number of operation Snuke needs to perform in order to score at least x points in total.
Constraints
* 1 ≦ x ≦ 10^{15}
* x is an integer.
Input
The input is given from Standard Input in the following format:
x
Output
Print the answer.
Examples
Input
7
Output
2
Input
149696127901
Output
27217477801 | instruction | 0 | 33,222 | 16 | 66,444 |
"Correct Solution:
```
import math
x = int(input())
if x == 6 or (x-6)%11 == 0:
x -= 1
print(math.ceil(x/5.5))
``` | output | 1 | 33,222 | 16 | 66,445 |
Provide a correct Python 3 solution for this coding contest problem.
Snuke has decided to play with a six-sided die. Each of its six sides shows an integer 1 through 6, and two numbers on opposite sides always add up to 7.
Snuke will first put the die on the table with an arbitrary side facing upward, then repeatedly perform the following operation:
* Operation: Rotate the die 90° toward one of the following directions: left, right, front (the die will come closer) and back (the die will go farther). Then, obtain y points where y is the number written in the side facing upward.
For example, let us consider the situation where the side showing 1 faces upward, the near side shows 5 and the right side shows 4, as illustrated in the figure. If the die is rotated toward the right as shown in the figure, the side showing 3 will face upward. Besides, the side showing 4 will face upward if the die is rotated toward the left, the side showing 2 will face upward if the die is rotated toward the front, and the side showing 5 will face upward if the die is rotated toward the back.
864abc2e4a08c26015ffd007a30aab03.png
Find the minimum number of operation Snuke needs to perform in order to score at least x points in total.
Constraints
* 1 ≦ x ≦ 10^{15}
* x is an integer.
Input
The input is given from Standard Input in the following format:
x
Output
Print the answer.
Examples
Input
7
Output
2
Input
149696127901
Output
27217477801 | instruction | 0 | 33,223 | 16 | 66,446 |
"Correct Solution:
```
x = int(input())
a = x // 11 * 2
b = x % 11
res = a + (b + 5) // 6
print(res)
``` | output | 1 | 33,223 | 16 | 66,447 |
Provide a correct Python 3 solution for this coding contest problem.
Snuke has decided to play with a six-sided die. Each of its six sides shows an integer 1 through 6, and two numbers on opposite sides always add up to 7.
Snuke will first put the die on the table with an arbitrary side facing upward, then repeatedly perform the following operation:
* Operation: Rotate the die 90° toward one of the following directions: left, right, front (the die will come closer) and back (the die will go farther). Then, obtain y points where y is the number written in the side facing upward.
For example, let us consider the situation where the side showing 1 faces upward, the near side shows 5 and the right side shows 4, as illustrated in the figure. If the die is rotated toward the right as shown in the figure, the side showing 3 will face upward. Besides, the side showing 4 will face upward if the die is rotated toward the left, the side showing 2 will face upward if the die is rotated toward the front, and the side showing 5 will face upward if the die is rotated toward the back.
864abc2e4a08c26015ffd007a30aab03.png
Find the minimum number of operation Snuke needs to perform in order to score at least x points in total.
Constraints
* 1 ≦ x ≦ 10^{15}
* x is an integer.
Input
The input is given from Standard Input in the following format:
x
Output
Print the answer.
Examples
Input
7
Output
2
Input
149696127901
Output
27217477801 | instruction | 0 | 33,224 | 16 | 66,448 |
"Correct Solution:
```
p, q = divmod(int(input()), 11)
print(p*2 + (q and [1, 2][q > 6]))
``` | output | 1 | 33,224 | 16 | 66,449 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Snuke has decided to play with a six-sided die. Each of its six sides shows an integer 1 through 6, and two numbers on opposite sides always add up to 7.
Snuke will first put the die on the table with an arbitrary side facing upward, then repeatedly perform the following operation:
* Operation: Rotate the die 90° toward one of the following directions: left, right, front (the die will come closer) and back (the die will go farther). Then, obtain y points where y is the number written in the side facing upward.
For example, let us consider the situation where the side showing 1 faces upward, the near side shows 5 and the right side shows 4, as illustrated in the figure. If the die is rotated toward the right as shown in the figure, the side showing 3 will face upward. Besides, the side showing 4 will face upward if the die is rotated toward the left, the side showing 2 will face upward if the die is rotated toward the front, and the side showing 5 will face upward if the die is rotated toward the back.
864abc2e4a08c26015ffd007a30aab03.png
Find the minimum number of operation Snuke needs to perform in order to score at least x points in total.
Constraints
* 1 ≦ x ≦ 10^{15}
* x is an integer.
Input
The input is given from Standard Input in the following format:
x
Output
Print the answer.
Examples
Input
7
Output
2
Input
149696127901
Output
27217477801
Submitted Solution:
```
import math
x = int(input())
print(2*math.ceil(x/11.0)+(-1 if 1 <= x%11 <= 6 else 0))
``` | instruction | 0 | 33,225 | 16 | 66,450 |
Yes | output | 1 | 33,225 | 16 | 66,451 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Snuke has decided to play with a six-sided die. Each of its six sides shows an integer 1 through 6, and two numbers on opposite sides always add up to 7.
Snuke will first put the die on the table with an arbitrary side facing upward, then repeatedly perform the following operation:
* Operation: Rotate the die 90° toward one of the following directions: left, right, front (the die will come closer) and back (the die will go farther). Then, obtain y points where y is the number written in the side facing upward.
For example, let us consider the situation where the side showing 1 faces upward, the near side shows 5 and the right side shows 4, as illustrated in the figure. If the die is rotated toward the right as shown in the figure, the side showing 3 will face upward. Besides, the side showing 4 will face upward if the die is rotated toward the left, the side showing 2 will face upward if the die is rotated toward the front, and the side showing 5 will face upward if the die is rotated toward the back.
864abc2e4a08c26015ffd007a30aab03.png
Find the minimum number of operation Snuke needs to perform in order to score at least x points in total.
Constraints
* 1 ≦ x ≦ 10^{15}
* x is an integer.
Input
The input is given from Standard Input in the following format:
x
Output
Print the answer.
Examples
Input
7
Output
2
Input
149696127901
Output
27217477801
Submitted Solution:
```
x=int(input())
n=x//11
if x%11==0:
print(2*n)
elif x%11<=6:
print(2*n+1)
else:
print(2*n+2)
``` | instruction | 0 | 33,226 | 16 | 66,452 |
Yes | output | 1 | 33,226 | 16 | 66,453 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Snuke has decided to play with a six-sided die. Each of its six sides shows an integer 1 through 6, and two numbers on opposite sides always add up to 7.
Snuke will first put the die on the table with an arbitrary side facing upward, then repeatedly perform the following operation:
* Operation: Rotate the die 90° toward one of the following directions: left, right, front (the die will come closer) and back (the die will go farther). Then, obtain y points where y is the number written in the side facing upward.
For example, let us consider the situation where the side showing 1 faces upward, the near side shows 5 and the right side shows 4, as illustrated in the figure. If the die is rotated toward the right as shown in the figure, the side showing 3 will face upward. Besides, the side showing 4 will face upward if the die is rotated toward the left, the side showing 2 will face upward if the die is rotated toward the front, and the side showing 5 will face upward if the die is rotated toward the back.
864abc2e4a08c26015ffd007a30aab03.png
Find the minimum number of operation Snuke needs to perform in order to score at least x points in total.
Constraints
* 1 ≦ x ≦ 10^{15}
* x is an integer.
Input
The input is given from Standard Input in the following format:
x
Output
Print the answer.
Examples
Input
7
Output
2
Input
149696127901
Output
27217477801
Submitted Solution:
```
N=int(input())
ans1=N//11*2
ans2=(0<N%11)+(6<N%11)
print(ans1+ans2)
``` | instruction | 0 | 33,227 | 16 | 66,454 |
Yes | output | 1 | 33,227 | 16 | 66,455 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Snuke has decided to play with a six-sided die. Each of its six sides shows an integer 1 through 6, and two numbers on opposite sides always add up to 7.
Snuke will first put the die on the table with an arbitrary side facing upward, then repeatedly perform the following operation:
* Operation: Rotate the die 90° toward one of the following directions: left, right, front (the die will come closer) and back (the die will go farther). Then, obtain y points where y is the number written in the side facing upward.
For example, let us consider the situation where the side showing 1 faces upward, the near side shows 5 and the right side shows 4, as illustrated in the figure. If the die is rotated toward the right as shown in the figure, the side showing 3 will face upward. Besides, the side showing 4 will face upward if the die is rotated toward the left, the side showing 2 will face upward if the die is rotated toward the front, and the side showing 5 will face upward if the die is rotated toward the back.
864abc2e4a08c26015ffd007a30aab03.png
Find the minimum number of operation Snuke needs to perform in order to score at least x points in total.
Constraints
* 1 ≦ x ≦ 10^{15}
* x is an integer.
Input
The input is given from Standard Input in the following format:
x
Output
Print the answer.
Examples
Input
7
Output
2
Input
149696127901
Output
27217477801
Submitted Solution:
```
x=int(input())
q,r = divmod(x,11)
if r==0:a=0
elif r <= 6:a = 1
else:a = 2
print(2*q+a)
``` | instruction | 0 | 33,228 | 16 | 66,456 |
Yes | output | 1 | 33,228 | 16 | 66,457 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Snuke has decided to play with a six-sided die. Each of its six sides shows an integer 1 through 6, and two numbers on opposite sides always add up to 7.
Snuke will first put the die on the table with an arbitrary side facing upward, then repeatedly perform the following operation:
* Operation: Rotate the die 90° toward one of the following directions: left, right, front (the die will come closer) and back (the die will go farther). Then, obtain y points where y is the number written in the side facing upward.
For example, let us consider the situation where the side showing 1 faces upward, the near side shows 5 and the right side shows 4, as illustrated in the figure. If the die is rotated toward the right as shown in the figure, the side showing 3 will face upward. Besides, the side showing 4 will face upward if the die is rotated toward the left, the side showing 2 will face upward if the die is rotated toward the front, and the side showing 5 will face upward if the die is rotated toward the back.
864abc2e4a08c26015ffd007a30aab03.png
Find the minimum number of operation Snuke needs to perform in order to score at least x points in total.
Constraints
* 1 ≦ x ≦ 10^{15}
* x is an integer.
Input
The input is given from Standard Input in the following format:
x
Output
Print the answer.
Examples
Input
7
Output
2
Input
149696127901
Output
27217477801
Submitted Solution:
```
x = int(input())
print(x//5.5+1)
``` | instruction | 0 | 33,229 | 16 | 66,458 |
No | output | 1 | 33,229 | 16 | 66,459 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Snuke has decided to play with a six-sided die. Each of its six sides shows an integer 1 through 6, and two numbers on opposite sides always add up to 7.
Snuke will first put the die on the table with an arbitrary side facing upward, then repeatedly perform the following operation:
* Operation: Rotate the die 90° toward one of the following directions: left, right, front (the die will come closer) and back (the die will go farther). Then, obtain y points where y is the number written in the side facing upward.
For example, let us consider the situation where the side showing 1 faces upward, the near side shows 5 and the right side shows 4, as illustrated in the figure. If the die is rotated toward the right as shown in the figure, the side showing 3 will face upward. Besides, the side showing 4 will face upward if the die is rotated toward the left, the side showing 2 will face upward if the die is rotated toward the front, and the side showing 5 will face upward if the die is rotated toward the back.
864abc2e4a08c26015ffd007a30aab03.png
Find the minimum number of operation Snuke needs to perform in order to score at least x points in total.
Constraints
* 1 ≦ x ≦ 10^{15}
* x is an integer.
Input
The input is given from Standard Input in the following format:
x
Output
Print the answer.
Examples
Input
7
Output
2
Input
149696127901
Output
27217477801
Submitted Solution:
```
x=int(input())
ans=x/11*2
if x%11==0:
print(ans)
elif x%11<=6:
print(ans+1)
else:
print(ans+2)
``` | instruction | 0 | 33,230 | 16 | 66,460 |
No | output | 1 | 33,230 | 16 | 66,461 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Snuke has decided to play with a six-sided die. Each of its six sides shows an integer 1 through 6, and two numbers on opposite sides always add up to 7.
Snuke will first put the die on the table with an arbitrary side facing upward, then repeatedly perform the following operation:
* Operation: Rotate the die 90° toward one of the following directions: left, right, front (the die will come closer) and back (the die will go farther). Then, obtain y points where y is the number written in the side facing upward.
For example, let us consider the situation where the side showing 1 faces upward, the near side shows 5 and the right side shows 4, as illustrated in the figure. If the die is rotated toward the right as shown in the figure, the side showing 3 will face upward. Besides, the side showing 4 will face upward if the die is rotated toward the left, the side showing 2 will face upward if the die is rotated toward the front, and the side showing 5 will face upward if the die is rotated toward the back.
864abc2e4a08c26015ffd007a30aab03.png
Find the minimum number of operation Snuke needs to perform in order to score at least x points in total.
Constraints
* 1 ≦ x ≦ 10^{15}
* x is an integer.
Input
The input is given from Standard Input in the following format:
x
Output
Print the answer.
Examples
Input
7
Output
2
Input
149696127901
Output
27217477801
Submitted Solution:
```
x = int(input())
# 5 or 6
if x % 11 == 0:
ans = x // 11 * 2
elif x % 11 <= 5:
ans = x // 11 * 2 + 1
else:
ans = x // 11 * 2 + 2
print(ans)
``` | instruction | 0 | 33,231 | 16 | 66,462 |
No | output | 1 | 33,231 | 16 | 66,463 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Snuke has decided to play with a six-sided die. Each of its six sides shows an integer 1 through 6, and two numbers on opposite sides always add up to 7.
Snuke will first put the die on the table with an arbitrary side facing upward, then repeatedly perform the following operation:
* Operation: Rotate the die 90° toward one of the following directions: left, right, front (the die will come closer) and back (the die will go farther). Then, obtain y points where y is the number written in the side facing upward.
For example, let us consider the situation where the side showing 1 faces upward, the near side shows 5 and the right side shows 4, as illustrated in the figure. If the die is rotated toward the right as shown in the figure, the side showing 3 will face upward. Besides, the side showing 4 will face upward if the die is rotated toward the left, the side showing 2 will face upward if the die is rotated toward the front, and the side showing 5 will face upward if the die is rotated toward the back.
864abc2e4a08c26015ffd007a30aab03.png
Find the minimum number of operation Snuke needs to perform in order to score at least x points in total.
Constraints
* 1 ≦ x ≦ 10^{15}
* x is an integer.
Input
The input is given from Standard Input in the following format:
x
Output
Print the answer.
Examples
Input
7
Output
2
Input
149696127901
Output
27217477801
Submitted Solution:
```
a, b = divmod(int(input()), 11)
print(a * 2 + (b > 6) + 1)
``` | instruction | 0 | 33,232 | 16 | 66,464 |
No | output | 1 | 33,232 | 16 | 66,465 |
Provide a correct Python 3 solution for this coding contest problem.
We have N bricks arranged in a row from left to right.
The i-th brick from the left (1 \leq i \leq N) has an integer a_i written on it.
Among them, you can break at most N-1 bricks of your choice.
Let us say there are K bricks remaining. Snuke will be satisfied if, for each integer i (1 \leq i \leq K), the i-th of those brick from the left has the integer i written on it.
Find the minimum number of bricks you need to break to satisfy Snuke's desire. If his desire is unsatisfiable, print `-1` instead.
Constraints
* All values in input are integers.
* 1 \leq N \leq 200000
* 1 \leq a_i \leq N
Input
Input is given from Standard Input in the following format:
N
a_1 a_2 ... a_N
Output
Print the minimum number of bricks that need to be broken to satisfy Snuke's desire, or print `-1` if his desire is unsatisfiable.
Examples
Input
3
2 1 2
Output
1
Input
3
2 2 2
Output
-1
Input
10
3 1 4 1 5 9 2 6 5 3
Output
7
Input
1
1
Output
0 | instruction | 0 | 34,034 | 16 | 68,068 |
"Correct Solution:
```
N = int(input())
A = list(map(int, input().split()))
i = 1
for a in A:
if a == i:
i += 1
if i == 1:
print(-1)
else:
print(N-i+1)
``` | output | 1 | 34,034 | 16 | 68,069 |
Provide a correct Python 3 solution for this coding contest problem.
We have N bricks arranged in a row from left to right.
The i-th brick from the left (1 \leq i \leq N) has an integer a_i written on it.
Among them, you can break at most N-1 bricks of your choice.
Let us say there are K bricks remaining. Snuke will be satisfied if, for each integer i (1 \leq i \leq K), the i-th of those brick from the left has the integer i written on it.
Find the minimum number of bricks you need to break to satisfy Snuke's desire. If his desire is unsatisfiable, print `-1` instead.
Constraints
* All values in input are integers.
* 1 \leq N \leq 200000
* 1 \leq a_i \leq N
Input
Input is given from Standard Input in the following format:
N
a_1 a_2 ... a_N
Output
Print the minimum number of bricks that need to be broken to satisfy Snuke's desire, or print `-1` if his desire is unsatisfiable.
Examples
Input
3
2 1 2
Output
1
Input
3
2 2 2
Output
-1
Input
10
3 1 4 1 5 9 2 6 5 3
Output
7
Input
1
1
Output
0 | instruction | 0 | 34,035 | 16 | 68,070 |
"Correct Solution:
```
N=int(input())
A=list(map(int,input().split()))
k=0
for i in range(N):
if A[i]==k+1:
k+=1
if k==0:
k=N+1
print(N-k)
``` | output | 1 | 34,035 | 16 | 68,071 |
Provide a correct Python 3 solution for this coding contest problem.
We have N bricks arranged in a row from left to right.
The i-th brick from the left (1 \leq i \leq N) has an integer a_i written on it.
Among them, you can break at most N-1 bricks of your choice.
Let us say there are K bricks remaining. Snuke will be satisfied if, for each integer i (1 \leq i \leq K), the i-th of those brick from the left has the integer i written on it.
Find the minimum number of bricks you need to break to satisfy Snuke's desire. If his desire is unsatisfiable, print `-1` instead.
Constraints
* All values in input are integers.
* 1 \leq N \leq 200000
* 1 \leq a_i \leq N
Input
Input is given from Standard Input in the following format:
N
a_1 a_2 ... a_N
Output
Print the minimum number of bricks that need to be broken to satisfy Snuke's desire, or print `-1` if his desire is unsatisfiable.
Examples
Input
3
2 1 2
Output
1
Input
3
2 2 2
Output
-1
Input
10
3 1 4 1 5 9 2 6 5 3
Output
7
Input
1
1
Output
0 | instruction | 0 | 34,036 | 16 | 68,072 |
"Correct Solution:
```
n=int(input())
a=list(map(int,input().split()))
s=1
for i in range(n):
if a[i]==s:
s+=1
if s==1:
print(-1)
else:
print(n-(s-1))
``` | output | 1 | 34,036 | 16 | 68,073 |
Provide a correct Python 3 solution for this coding contest problem.
We have N bricks arranged in a row from left to right.
The i-th brick from the left (1 \leq i \leq N) has an integer a_i written on it.
Among them, you can break at most N-1 bricks of your choice.
Let us say there are K bricks remaining. Snuke will be satisfied if, for each integer i (1 \leq i \leq K), the i-th of those brick from the left has the integer i written on it.
Find the minimum number of bricks you need to break to satisfy Snuke's desire. If his desire is unsatisfiable, print `-1` instead.
Constraints
* All values in input are integers.
* 1 \leq N \leq 200000
* 1 \leq a_i \leq N
Input
Input is given from Standard Input in the following format:
N
a_1 a_2 ... a_N
Output
Print the minimum number of bricks that need to be broken to satisfy Snuke's desire, or print `-1` if his desire is unsatisfiable.
Examples
Input
3
2 1 2
Output
1
Input
3
2 2 2
Output
-1
Input
10
3 1 4 1 5 9 2 6 5 3
Output
7
Input
1
1
Output
0 | instruction | 0 | 34,037 | 16 | 68,074 |
"Correct Solution:
```
N=int(input())
A=list(map(int,input().split()))
cnt=0
for a in A:
cnt+=1 if cnt+1==a else 0
print(N-cnt if cnt>0 else -1)
``` | output | 1 | 34,037 | 16 | 68,075 |
Provide a correct Python 3 solution for this coding contest problem.
We have N bricks arranged in a row from left to right.
The i-th brick from the left (1 \leq i \leq N) has an integer a_i written on it.
Among them, you can break at most N-1 bricks of your choice.
Let us say there are K bricks remaining. Snuke will be satisfied if, for each integer i (1 \leq i \leq K), the i-th of those brick from the left has the integer i written on it.
Find the minimum number of bricks you need to break to satisfy Snuke's desire. If his desire is unsatisfiable, print `-1` instead.
Constraints
* All values in input are integers.
* 1 \leq N \leq 200000
* 1 \leq a_i \leq N
Input
Input is given from Standard Input in the following format:
N
a_1 a_2 ... a_N
Output
Print the minimum number of bricks that need to be broken to satisfy Snuke's desire, or print `-1` if his desire is unsatisfiable.
Examples
Input
3
2 1 2
Output
1
Input
3
2 2 2
Output
-1
Input
10
3 1 4 1 5 9 2 6 5 3
Output
7
Input
1
1
Output
0 | instruction | 0 | 34,038 | 16 | 68,076 |
"Correct Solution:
```
N=int(input())
a=list(map(int,input().split()))
t=1
for i in a:
if t==i:
t+=1
if t==1:
print(-1)
else:
print(N-t+1)
``` | output | 1 | 34,038 | 16 | 68,077 |
Provide a correct Python 3 solution for this coding contest problem.
We have N bricks arranged in a row from left to right.
The i-th brick from the left (1 \leq i \leq N) has an integer a_i written on it.
Among them, you can break at most N-1 bricks of your choice.
Let us say there are K bricks remaining. Snuke will be satisfied if, for each integer i (1 \leq i \leq K), the i-th of those brick from the left has the integer i written on it.
Find the minimum number of bricks you need to break to satisfy Snuke's desire. If his desire is unsatisfiable, print `-1` instead.
Constraints
* All values in input are integers.
* 1 \leq N \leq 200000
* 1 \leq a_i \leq N
Input
Input is given from Standard Input in the following format:
N
a_1 a_2 ... a_N
Output
Print the minimum number of bricks that need to be broken to satisfy Snuke's desire, or print `-1` if his desire is unsatisfiable.
Examples
Input
3
2 1 2
Output
1
Input
3
2 2 2
Output
-1
Input
10
3 1 4 1 5 9 2 6 5 3
Output
7
Input
1
1
Output
0 | instruction | 0 | 34,039 | 16 | 68,078 |
"Correct Solution:
```
n=int(input())
a=list(map(int,input().split()))
m=1
for i in range(n):
if a[i]==m:
m+=1
if m==1:
print(-1)
else:
print(n-m+1)
``` | output | 1 | 34,039 | 16 | 68,079 |
Provide a correct Python 3 solution for this coding contest problem.
We have N bricks arranged in a row from left to right.
The i-th brick from the left (1 \leq i \leq N) has an integer a_i written on it.
Among them, you can break at most N-1 bricks of your choice.
Let us say there are K bricks remaining. Snuke will be satisfied if, for each integer i (1 \leq i \leq K), the i-th of those brick from the left has the integer i written on it.
Find the minimum number of bricks you need to break to satisfy Snuke's desire. If his desire is unsatisfiable, print `-1` instead.
Constraints
* All values in input are integers.
* 1 \leq N \leq 200000
* 1 \leq a_i \leq N
Input
Input is given from Standard Input in the following format:
N
a_1 a_2 ... a_N
Output
Print the minimum number of bricks that need to be broken to satisfy Snuke's desire, or print `-1` if his desire is unsatisfiable.
Examples
Input
3
2 1 2
Output
1
Input
3
2 2 2
Output
-1
Input
10
3 1 4 1 5 9 2 6 5 3
Output
7
Input
1
1
Output
0 | instruction | 0 | 34,040 | 16 | 68,080 |
"Correct Solution:
```
N=int(input())
A=list(map(int,input().split()))
t=0
for i in range(N):
if A[i]==t+1:
t+=1
print((-1,N-t)[t>0])
``` | output | 1 | 34,040 | 16 | 68,081 |
Provide a correct Python 3 solution for this coding contest problem.
We have N bricks arranged in a row from left to right.
The i-th brick from the left (1 \leq i \leq N) has an integer a_i written on it.
Among them, you can break at most N-1 bricks of your choice.
Let us say there are K bricks remaining. Snuke will be satisfied if, for each integer i (1 \leq i \leq K), the i-th of those brick from the left has the integer i written on it.
Find the minimum number of bricks you need to break to satisfy Snuke's desire. If his desire is unsatisfiable, print `-1` instead.
Constraints
* All values in input are integers.
* 1 \leq N \leq 200000
* 1 \leq a_i \leq N
Input
Input is given from Standard Input in the following format:
N
a_1 a_2 ... a_N
Output
Print the minimum number of bricks that need to be broken to satisfy Snuke's desire, or print `-1` if his desire is unsatisfiable.
Examples
Input
3
2 1 2
Output
1
Input
3
2 2 2
Output
-1
Input
10
3 1 4 1 5 9 2 6 5 3
Output
7
Input
1
1
Output
0 | instruction | 0 | 34,041 | 16 | 68,082 |
"Correct Solution:
```
N = int(input())
a = map(int, input().split())
A = 0
C = 1
for i in a:
if i == C:
C += 1
else:
A += 1
print(-1 if C == 1 else A)
``` | output | 1 | 34,041 | 16 | 68,083 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
We have N bricks arranged in a row from left to right.
The i-th brick from the left (1 \leq i \leq N) has an integer a_i written on it.
Among them, you can break at most N-1 bricks of your choice.
Let us say there are K bricks remaining. Snuke will be satisfied if, for each integer i (1 \leq i \leq K), the i-th of those brick from the left has the integer i written on it.
Find the minimum number of bricks you need to break to satisfy Snuke's desire. If his desire is unsatisfiable, print `-1` instead.
Constraints
* All values in input are integers.
* 1 \leq N \leq 200000
* 1 \leq a_i \leq N
Input
Input is given from Standard Input in the following format:
N
a_1 a_2 ... a_N
Output
Print the minimum number of bricks that need to be broken to satisfy Snuke's desire, or print `-1` if his desire is unsatisfiable.
Examples
Input
3
2 1 2
Output
1
Input
3
2 2 2
Output
-1
Input
10
3 1 4 1 5 9 2 6 5 3
Output
7
Input
1
1
Output
0
Submitted Solution:
```
n=int(input())
ar=list(map(int,input().split()))
m=0
for i in ar:
if i-1==m:
m=i
if m: print(n-m)
else: print(-1)
``` | instruction | 0 | 34,042 | 16 | 68,084 |
Yes | output | 1 | 34,042 | 16 | 68,085 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
We have N bricks arranged in a row from left to right.
The i-th brick from the left (1 \leq i \leq N) has an integer a_i written on it.
Among them, you can break at most N-1 bricks of your choice.
Let us say there are K bricks remaining. Snuke will be satisfied if, for each integer i (1 \leq i \leq K), the i-th of those brick from the left has the integer i written on it.
Find the minimum number of bricks you need to break to satisfy Snuke's desire. If his desire is unsatisfiable, print `-1` instead.
Constraints
* All values in input are integers.
* 1 \leq N \leq 200000
* 1 \leq a_i \leq N
Input
Input is given from Standard Input in the following format:
N
a_1 a_2 ... a_N
Output
Print the minimum number of bricks that need to be broken to satisfy Snuke's desire, or print `-1` if his desire is unsatisfiable.
Examples
Input
3
2 1 2
Output
1
Input
3
2 2 2
Output
-1
Input
10
3 1 4 1 5 9 2 6 5 3
Output
7
Input
1
1
Output
0
Submitted Solution:
```
n = int(input())
a = list(map(int, input().split()))
now = 1
for x in a:
if x == now:
now += 1
print(-1 if now == 1 else n-now+1)
``` | instruction | 0 | 34,043 | 16 | 68,086 |
Yes | output | 1 | 34,043 | 16 | 68,087 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
We have N bricks arranged in a row from left to right.
The i-th brick from the left (1 \leq i \leq N) has an integer a_i written on it.
Among them, you can break at most N-1 bricks of your choice.
Let us say there are K bricks remaining. Snuke will be satisfied if, for each integer i (1 \leq i \leq K), the i-th of those brick from the left has the integer i written on it.
Find the minimum number of bricks you need to break to satisfy Snuke's desire. If his desire is unsatisfiable, print `-1` instead.
Constraints
* All values in input are integers.
* 1 \leq N \leq 200000
* 1 \leq a_i \leq N
Input
Input is given from Standard Input in the following format:
N
a_1 a_2 ... a_N
Output
Print the minimum number of bricks that need to be broken to satisfy Snuke's desire, or print `-1` if his desire is unsatisfiable.
Examples
Input
3
2 1 2
Output
1
Input
3
2 2 2
Output
-1
Input
10
3 1 4 1 5 9 2 6 5 3
Output
7
Input
1
1
Output
0
Submitted Solution:
```
n=int(input())
a=[int(x) for x in input().split()]
x=0
for i in range(n):
if a[i]==x+1:
x+=1
if x!=0:
print(n-x)
else:
print(-1)
``` | instruction | 0 | 34,044 | 16 | 68,088 |
Yes | output | 1 | 34,044 | 16 | 68,089 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
We have N bricks arranged in a row from left to right.
The i-th brick from the left (1 \leq i \leq N) has an integer a_i written on it.
Among them, you can break at most N-1 bricks of your choice.
Let us say there are K bricks remaining. Snuke will be satisfied if, for each integer i (1 \leq i \leq K), the i-th of those brick from the left has the integer i written on it.
Find the minimum number of bricks you need to break to satisfy Snuke's desire. If his desire is unsatisfiable, print `-1` instead.
Constraints
* All values in input are integers.
* 1 \leq N \leq 200000
* 1 \leq a_i \leq N
Input
Input is given from Standard Input in the following format:
N
a_1 a_2 ... a_N
Output
Print the minimum number of bricks that need to be broken to satisfy Snuke's desire, or print `-1` if his desire is unsatisfiable.
Examples
Input
3
2 1 2
Output
1
Input
3
2 2 2
Output
-1
Input
10
3 1 4 1 5 9 2 6 5 3
Output
7
Input
1
1
Output
0
Submitted Solution:
```
N=int(input())
a=[int(x) for x in input().split()]
cnt=1
for x in a:
if x==cnt:
cnt+=1
print(-1 if cnt==1 else N-cnt+1)
``` | instruction | 0 | 34,045 | 16 | 68,090 |
Yes | output | 1 | 34,045 | 16 | 68,091 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
We have N bricks arranged in a row from left to right.
The i-th brick from the left (1 \leq i \leq N) has an integer a_i written on it.
Among them, you can break at most N-1 bricks of your choice.
Let us say there are K bricks remaining. Snuke will be satisfied if, for each integer i (1 \leq i \leq K), the i-th of those brick from the left has the integer i written on it.
Find the minimum number of bricks you need to break to satisfy Snuke's desire. If his desire is unsatisfiable, print `-1` instead.
Constraints
* All values in input are integers.
* 1 \leq N \leq 200000
* 1 \leq a_i \leq N
Input
Input is given from Standard Input in the following format:
N
a_1 a_2 ... a_N
Output
Print the minimum number of bricks that need to be broken to satisfy Snuke's desire, or print `-1` if his desire is unsatisfiable.
Examples
Input
3
2 1 2
Output
1
Input
3
2 2 2
Output
-1
Input
10
3 1 4 1 5 9 2 6 5 3
Output
7
Input
1
1
Output
0
Submitted Solution:
```
def babble_sort(arr):
length = len(arr)
count = 0
for i in range(length):
for j in reversed(range(i+1, length)):
if arr[j-1] > arr[j]:
count += 1
arr[j-1], arr[j] = arr[j], arr[j-1]
print(count//2)
return arr
N = int(input())
an = list(map(int, input().split(' ')))
babble_sort(an)
``` | instruction | 0 | 34,046 | 16 | 68,092 |
No | output | 1 | 34,046 | 16 | 68,093 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
We have N bricks arranged in a row from left to right.
The i-th brick from the left (1 \leq i \leq N) has an integer a_i written on it.
Among them, you can break at most N-1 bricks of your choice.
Let us say there are K bricks remaining. Snuke will be satisfied if, for each integer i (1 \leq i \leq K), the i-th of those brick from the left has the integer i written on it.
Find the minimum number of bricks you need to break to satisfy Snuke's desire. If his desire is unsatisfiable, print `-1` instead.
Constraints
* All values in input are integers.
* 1 \leq N \leq 200000
* 1 \leq a_i \leq N
Input
Input is given from Standard Input in the following format:
N
a_1 a_2 ... a_N
Output
Print the minimum number of bricks that need to be broken to satisfy Snuke's desire, or print `-1` if his desire is unsatisfiable.
Examples
Input
3
2 1 2
Output
1
Input
3
2 2 2
Output
-1
Input
10
3 1 4 1 5 9 2 6 5 3
Output
7
Input
1
1
Output
0
Submitted Solution:
```
N = int(input())
A = list(map(int,input().split()))
count = 0
k=0
while k<len(A):
if A[k] == k+1:
k += 1
else:
count += 1
A.pop(k)
if count == N:
print(-1)
else:
print(count)
``` | instruction | 0 | 34,047 | 16 | 68,094 |
No | output | 1 | 34,047 | 16 | 68,095 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
We have N bricks arranged in a row from left to right.
The i-th brick from the left (1 \leq i \leq N) has an integer a_i written on it.
Among them, you can break at most N-1 bricks of your choice.
Let us say there are K bricks remaining. Snuke will be satisfied if, for each integer i (1 \leq i \leq K), the i-th of those brick from the left has the integer i written on it.
Find the minimum number of bricks you need to break to satisfy Snuke's desire. If his desire is unsatisfiable, print `-1` instead.
Constraints
* All values in input are integers.
* 1 \leq N \leq 200000
* 1 \leq a_i \leq N
Input
Input is given from Standard Input in the following format:
N
a_1 a_2 ... a_N
Output
Print the minimum number of bricks that need to be broken to satisfy Snuke's desire, or print `-1` if his desire is unsatisfiable.
Examples
Input
3
2 1 2
Output
1
Input
3
2 2 2
Output
-1
Input
10
3 1 4 1 5 9 2 6 5 3
Output
7
Input
1
1
Output
0
Submitted Solution:
```
import sys
input = sys.stdin.readline
n = int(input())
li = list(map(int,input().split()))
breakpoint = 0
stoppoint = 0
for i in range(n):
for j in range(stoppoint,n):
if li[j] != i+1:
breakpoint += 1
else:
stoppoint = j+1
break
if breakpoint == n:
breakpoint = -1
break
print(breakpoint)
``` | instruction | 0 | 34,048 | 16 | 68,096 |
No | output | 1 | 34,048 | 16 | 68,097 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
We have N bricks arranged in a row from left to right.
The i-th brick from the left (1 \leq i \leq N) has an integer a_i written on it.
Among them, you can break at most N-1 bricks of your choice.
Let us say there are K bricks remaining. Snuke will be satisfied if, for each integer i (1 \leq i \leq K), the i-th of those brick from the left has the integer i written on it.
Find the minimum number of bricks you need to break to satisfy Snuke's desire. If his desire is unsatisfiable, print `-1` instead.
Constraints
* All values in input are integers.
* 1 \leq N \leq 200000
* 1 \leq a_i \leq N
Input
Input is given from Standard Input in the following format:
N
a_1 a_2 ... a_N
Output
Print the minimum number of bricks that need to be broken to satisfy Snuke's desire, or print `-1` if his desire is unsatisfiable.
Examples
Input
3
2 1 2
Output
1
Input
3
2 2 2
Output
-1
Input
10
3 1 4 1 5 9 2 6 5 3
Output
7
Input
1
1
Output
0
Submitted Solution:
```
# 初期入力
N = int(input())
#A = list(map(int, input().split()))
A = list(map(int, input().split()))
# 1の左側は砕く、以降数字が大きくなるほど右側にあればいいが、順番が違うと砕く必要あり。
from copy import deepcopy
x = 0
y =0
z = 0
for i in range(1,N+1):
if i in A[x:]:
y = A[x:].index(i )
#z.append(y)
z +=1
x += y
#if y==0:
# break
else:
y = -1
break
#
renga_kudaku = 0
if z ==0 and y==-1:
renga_kudaku = -1
elif z ==0:
renga_kudaku = 0
else:
renga_kudaku=N-z # 求める物=全体ー残る要素数、zは残る文字の配列
print(renga_kudaku)
``` | instruction | 0 | 34,049 | 16 | 68,098 |
No | output | 1 | 34,049 | 16 | 68,099 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There are N jewels, numbered 1 to N. The color of these jewels are represented by integers between 1 and K (inclusive), and the color of Jewel i is C_i. Also, these jewels have specified values, and the value of Jewel i is V_i.
Snuke would like to choose some of these jewels to exhibit. Here, the set of the chosen jewels must satisfy the following condition:
* For each chosen jewel, there is at least one more jewel of the same color that is chosen.
For each integer x such that 1 \leq x \leq N, determine if it is possible to choose exactly x jewels, and if it is possible, find the maximum possible sum of the values of chosen jewels in that case.
Constraints
* 1 \leq N \leq 2 \times 10^5
* 1 \leq K \leq \lfloor N/2 \rfloor
* 1 \leq C_i \leq K
* 1 \leq V_i \leq 10^9
* For each of the colors, there are at least two jewels of that color.
* All values in input are integers.
Input
Input is given from Standard Input in the following format:
N K
C_1 V_1
C_2 V_2
:
C_N V_N
Output
Print N lines. In the i-th line, if it is possible to choose exactly i jewels, print the maximum possible sum of the values of chosen jewels in that case, and print -1 otherwise.
Examples
Input
5 2
1 1
1 2
1 3
2 4
2 5
Output
-1
9
6
14
15
Input
5 2
1 1
1 2
2 3
2 4
2 5
Output
-1
9
12
12
15
Input
8 4
3 2
2 3
4 5
1 7
3 11
4 13
1 17
2 19
Output
-1
24
-1
46
-1
64
-1
77
Input
15 5
3 87
1 25
1 27
3 58
2 85
5 19
5 39
1 58
3 12
4 13
5 54
4 100
2 33
5 13
2 55
Output
-1
145
173
285
318
398
431
491
524
576
609
634
653
666
678
Submitted Solution:
```
N, K = map(int, input().split())
X = [[] for _ in range(K)]
Y = []
for i in range(N):
c, v = map(int, input().split())
X[c-1].append(v)
Z = []
ii = 0
for i in range(K):
X[i] = sorted(X[i])[::-1]
if len(X[i]) == 2:
Z.append(sum(X[i]))
else:
Y.append([])
Y[ii] = [0] * (len(X[i]) + 1)
Y[ii][1] = -1
Y[ii][2] = X[i][0]+X[i][1]
for j in range(2, len(X[i])):
Y[ii][j+1] = Y[ii][j] + X[i][j]
ii += 1
if len(Z) > 0:
Z = sorted(Z)[::-1]
Y.append([-1]*(len(Z)*2+1))
Y[-1][0] = 0
for i in range(len(Z)):
Y[-1][2*(i+1)] = Y[-1][2*i] + Z[i]
post = [0]
pre = []
for i in range(K):
pre = post
post = [a for a in pre] + [-1] * (len(Y[i]) - 1)
for j in range(len(pre)):
for k in range(2, len(Y[i])):
if j == 0 or pre[j]>0:
post[j+k] = max(post[j+k], pre[j]+Y[i][k])
for a in post[1:]:
print(a)
``` | instruction | 0 | 36,699 | 16 | 73,398 |
No | output | 1 | 36,699 | 16 | 73,399 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There are N jewels, numbered 1 to N. The color of these jewels are represented by integers between 1 and K (inclusive), and the color of Jewel i is C_i. Also, these jewels have specified values, and the value of Jewel i is V_i.
Snuke would like to choose some of these jewels to exhibit. Here, the set of the chosen jewels must satisfy the following condition:
* For each chosen jewel, there is at least one more jewel of the same color that is chosen.
For each integer x such that 1 \leq x \leq N, determine if it is possible to choose exactly x jewels, and if it is possible, find the maximum possible sum of the values of chosen jewels in that case.
Constraints
* 1 \leq N \leq 2 \times 10^5
* 1 \leq K \leq \lfloor N/2 \rfloor
* 1 \leq C_i \leq K
* 1 \leq V_i \leq 10^9
* For each of the colors, there are at least two jewels of that color.
* All values in input are integers.
Input
Input is given from Standard Input in the following format:
N K
C_1 V_1
C_2 V_2
:
C_N V_N
Output
Print N lines. In the i-th line, if it is possible to choose exactly i jewels, print the maximum possible sum of the values of chosen jewels in that case, and print -1 otherwise.
Examples
Input
5 2
1 1
1 2
1 3
2 4
2 5
Output
-1
9
6
14
15
Input
5 2
1 1
1 2
2 3
2 4
2 5
Output
-1
9
12
12
15
Input
8 4
3 2
2 3
4 5
1 7
3 11
4 13
1 17
2 19
Output
-1
24
-1
46
-1
64
-1
77
Input
15 5
3 87
1 25
1 27
3 58
2 85
5 19
5 39
1 58
3 12
4 13
5 54
4 100
2 33
5 13
2 55
Output
-1
145
173
285
318
398
431
491
524
576
609
634
653
666
678
Submitted Solution:
```
N, K = map(int, input().split())
X = [[] for _ in range(K)]
Y = [0] * K
for i in range(N):
c, v = map(int, input().split())
X[c-1].append(v)
for i in range(K):
X[i] = sorted(X[i])[::-1]
Y[i] = [0] * (len(X[i]) + 1)
Y[i][1] = -1
Y[i][2] = X[i][0]+X[i][1]
for j in range(2, len(X[i])):
Y[i][j+1] = Y[i][j] + X[i][j]
post = [0]
pre = []
for i in range(K):
pre = post
post = [a for a in pre] + [-1] * (len(Y[i]) - 1)
for j in range(len(pre)):
for k in range(2, len(Y[i])):
if j == 0 or pre[j]>0:
post[j+k] = max(post[j+k], pre[j]+Y[i][k])
for a in post[1:]:
print(a)
``` | instruction | 0 | 36,700 | 16 | 73,400 |
No | output | 1 | 36,700 | 16 | 73,401 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There are N jewels, numbered 1 to N. The color of these jewels are represented by integers between 1 and K (inclusive), and the color of Jewel i is C_i. Also, these jewels have specified values, and the value of Jewel i is V_i.
Snuke would like to choose some of these jewels to exhibit. Here, the set of the chosen jewels must satisfy the following condition:
* For each chosen jewel, there is at least one more jewel of the same color that is chosen.
For each integer x such that 1 \leq x \leq N, determine if it is possible to choose exactly x jewels, and if it is possible, find the maximum possible sum of the values of chosen jewels in that case.
Constraints
* 1 \leq N \leq 2 \times 10^5
* 1 \leq K \leq \lfloor N/2 \rfloor
* 1 \leq C_i \leq K
* 1 \leq V_i \leq 10^9
* For each of the colors, there are at least two jewels of that color.
* All values in input are integers.
Input
Input is given from Standard Input in the following format:
N K
C_1 V_1
C_2 V_2
:
C_N V_N
Output
Print N lines. In the i-th line, if it is possible to choose exactly i jewels, print the maximum possible sum of the values of chosen jewels in that case, and print -1 otherwise.
Examples
Input
5 2
1 1
1 2
1 3
2 4
2 5
Output
-1
9
6
14
15
Input
5 2
1 1
1 2
2 3
2 4
2 5
Output
-1
9
12
12
15
Input
8 4
3 2
2 3
4 5
1 7
3 11
4 13
1 17
2 19
Output
-1
24
-1
46
-1
64
-1
77
Input
15 5
3 87
1 25
1 27
3 58
2 85
5 19
5 39
1 58
3 12
4 13
5 54
4 100
2 33
5 13
2 55
Output
-1
145
173
285
318
398
431
491
524
576
609
634
653
666
678
Submitted Solution:
```
N, K = map(int, input().split())
X = [[] for _ in range(K)]
Y = []
for i in range(N):
c, v = map(int, input().split())
X[c-1].append(v)
Z = []
ii = 0
for i in range(K):
X[i] = sorted(X[i])[::-1]
if len(X[i]) == 2:
Z.append(sum(X[i]))
else:
Y.append([])
Y[ii] = [0] * (len(X[i]) + 1)
Y[ii][1] = -1
Y[ii][2] = X[i][0]+X[i][1]
for j in range(2, len(X[i])):
Y[ii][j+1] = Y[ii][j] + X[i][j]
ii += 1
if len(Z) > 0:
Z = sorted(Z)[::-1]
Y.append([-1]*(len(Z)*2+3))
Y[-1][0] = 0
for i in range(len(Z)):
Y[-1][2*(i+1)] = Y[-1][2*i] + Z[i]
post = [0]
pre = []
for i in range(K):
pre = post
post = [a for a in pre] + [-1] * (len(Y[i]) - 1)
for j in range(len(pre)):
for k in range(2, len(Y[i])):
if j == 0 or pre[j]>0:
post[j+k] = max(post[j+k], pre[j]+Y[i][k])
for a in post[1:]:
print(a)
``` | instruction | 0 | 36,701 | 16 | 73,402 |
No | output | 1 | 36,701 | 16 | 73,403 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There are N jewels, numbered 1 to N. The color of these jewels are represented by integers between 1 and K (inclusive), and the color of Jewel i is C_i. Also, these jewels have specified values, and the value of Jewel i is V_i.
Snuke would like to choose some of these jewels to exhibit. Here, the set of the chosen jewels must satisfy the following condition:
* For each chosen jewel, there is at least one more jewel of the same color that is chosen.
For each integer x such that 1 \leq x \leq N, determine if it is possible to choose exactly x jewels, and if it is possible, find the maximum possible sum of the values of chosen jewels in that case.
Constraints
* 1 \leq N \leq 2 \times 10^5
* 1 \leq K \leq \lfloor N/2 \rfloor
* 1 \leq C_i \leq K
* 1 \leq V_i \leq 10^9
* For each of the colors, there are at least two jewels of that color.
* All values in input are integers.
Input
Input is given from Standard Input in the following format:
N K
C_1 V_1
C_2 V_2
:
C_N V_N
Output
Print N lines. In the i-th line, if it is possible to choose exactly i jewels, print the maximum possible sum of the values of chosen jewels in that case, and print -1 otherwise.
Examples
Input
5 2
1 1
1 2
1 3
2 4
2 5
Output
-1
9
6
14
15
Input
5 2
1 1
1 2
2 3
2 4
2 5
Output
-1
9
12
12
15
Input
8 4
3 2
2 3
4 5
1 7
3 11
4 13
1 17
2 19
Output
-1
24
-1
46
-1
64
-1
77
Input
15 5
3 87
1 25
1 27
3 58
2 85
5 19
5 39
1 58
3 12
4 13
5 54
4 100
2 33
5 13
2 55
Output
-1
145
173
285
318
398
431
491
524
576
609
634
653
666
678
Submitted Solution:
```
giveup
``` | instruction | 0 | 36,702 | 16 | 73,404 |
No | output | 1 | 36,702 | 16 | 73,405 |
Provide a correct Python 3 solution for this coding contest problem.
There are N squares arranged in a row, numbered 1, 2, ..., N from left to right. You are given a string S of length N consisting of `.` and `#`. If the i-th character of S is `#`, Square i contains a rock; if the i-th character of S is `.`, Square i is empty.
In the beginning, Snuke stands on Square A, and Fnuke stands on Square B.
You can repeat the following operation any number of times:
* Choose Snuke or Fnuke, and make him jump one or two squares to the right. The destination must be one of the squares, and it must not contain a rock or the other person.
You want to repeat this operation so that Snuke will stand on Square C and Fnuke will stand on Square D.
Determine whether this is possible.
Constraints
* 4 \leq N \leq 200\ 000
* S is a string of length N consisting of `.` and `#`.
* 1 \leq A, B, C, D \leq N
* Square A, B, C and D do not contain a rock.
* A, B, C and D are all different.
* A < B
* A < C
* B < D
Input
Input is given from Standard Input in the following format:
N A B C D
S
Output
Print `Yes` if the objective is achievable, and `No` if it is not.
Examples
Input
7 1 3 6 7
.#..#..
Output
Yes
Input
7 1 3 7 6
.#..#..
Output
No
Input
15 1 3 15 13
...#.#...#.#...
Output
Yes | instruction | 0 | 38,376 | 16 | 76,752 |
"Correct Solution:
```
N, A, B, C, D = map(int, input().split())
S = input()
if '##' in S[A-1:max(C, D)]:
print('No')
elif C < D:
print('Yes')
else:
print('Yes' if '...' in S[B-2:D+1] else 'No')
``` | output | 1 | 38,376 | 16 | 76,753 |
Provide a correct Python 3 solution for this coding contest problem.
There are N squares arranged in a row, numbered 1, 2, ..., N from left to right. You are given a string S of length N consisting of `.` and `#`. If the i-th character of S is `#`, Square i contains a rock; if the i-th character of S is `.`, Square i is empty.
In the beginning, Snuke stands on Square A, and Fnuke stands on Square B.
You can repeat the following operation any number of times:
* Choose Snuke or Fnuke, and make him jump one or two squares to the right. The destination must be one of the squares, and it must not contain a rock or the other person.
You want to repeat this operation so that Snuke will stand on Square C and Fnuke will stand on Square D.
Determine whether this is possible.
Constraints
* 4 \leq N \leq 200\ 000
* S is a string of length N consisting of `.` and `#`.
* 1 \leq A, B, C, D \leq N
* Square A, B, C and D do not contain a rock.
* A, B, C and D are all different.
* A < B
* A < C
* B < D
Input
Input is given from Standard Input in the following format:
N A B C D
S
Output
Print `Yes` if the objective is achievable, and `No` if it is not.
Examples
Input
7 1 3 6 7
.#..#..
Output
Yes
Input
7 1 3 7 6
.#..#..
Output
No
Input
15 1 3 15 13
...#.#...#.#...
Output
Yes | instruction | 0 | 38,377 | 16 | 76,754 |
"Correct Solution:
```
n,a,b,c,d = map(int,input().split())
S = input()
if ('##' in S[a:c-1]) or ('##' in S[b:d-1]): print('No')
else:
if d < c:
if ('...' in S[b-2:d+1]): print('Yes')
else: print('No')
else: print('Yes')
``` | output | 1 | 38,377 | 16 | 76,755 |
Provide a correct Python 3 solution for this coding contest problem.
There are N squares arranged in a row, numbered 1, 2, ..., N from left to right. You are given a string S of length N consisting of `.` and `#`. If the i-th character of S is `#`, Square i contains a rock; if the i-th character of S is `.`, Square i is empty.
In the beginning, Snuke stands on Square A, and Fnuke stands on Square B.
You can repeat the following operation any number of times:
* Choose Snuke or Fnuke, and make him jump one or two squares to the right. The destination must be one of the squares, and it must not contain a rock or the other person.
You want to repeat this operation so that Snuke will stand on Square C and Fnuke will stand on Square D.
Determine whether this is possible.
Constraints
* 4 \leq N \leq 200\ 000
* S is a string of length N consisting of `.` and `#`.
* 1 \leq A, B, C, D \leq N
* Square A, B, C and D do not contain a rock.
* A, B, C and D are all different.
* A < B
* A < C
* B < D
Input
Input is given from Standard Input in the following format:
N A B C D
S
Output
Print `Yes` if the objective is achievable, and `No` if it is not.
Examples
Input
7 1 3 6 7
.#..#..
Output
Yes
Input
7 1 3 7 6
.#..#..
Output
No
Input
15 1 3 15 13
...#.#...#.#...
Output
Yes | instruction | 0 | 38,378 | 16 | 76,756 |
"Correct Solution:
```
N, A, B, C, D = map(lambda x: int(x)-1, input().split())
L = input()
reachable = not ("##" in L[A:C+1] or "##" in L[B:D+1])
interupt = "..." in L[B-1:D+2]
if reachable and (C < D or interupt):
print("Yes")
else:
print("No")
``` | output | 1 | 38,378 | 16 | 76,757 |
Provide a correct Python 3 solution for this coding contest problem.
There are N squares arranged in a row, numbered 1, 2, ..., N from left to right. You are given a string S of length N consisting of `.` and `#`. If the i-th character of S is `#`, Square i contains a rock; if the i-th character of S is `.`, Square i is empty.
In the beginning, Snuke stands on Square A, and Fnuke stands on Square B.
You can repeat the following operation any number of times:
* Choose Snuke or Fnuke, and make him jump one or two squares to the right. The destination must be one of the squares, and it must not contain a rock or the other person.
You want to repeat this operation so that Snuke will stand on Square C and Fnuke will stand on Square D.
Determine whether this is possible.
Constraints
* 4 \leq N \leq 200\ 000
* S is a string of length N consisting of `.` and `#`.
* 1 \leq A, B, C, D \leq N
* Square A, B, C and D do not contain a rock.
* A, B, C and D are all different.
* A < B
* A < C
* B < D
Input
Input is given from Standard Input in the following format:
N A B C D
S
Output
Print `Yes` if the objective is achievable, and `No` if it is not.
Examples
Input
7 1 3 6 7
.#..#..
Output
Yes
Input
7 1 3 7 6
.#..#..
Output
No
Input
15 1 3 15 13
...#.#...#.#...
Output
Yes | instruction | 0 | 38,379 | 16 | 76,758 |
"Correct Solution:
```
n, a, b, c, d = map(int, input().split())
s = input()
if "##" in s[a - 1:max(c, d)]:
print("No")
exit()
elif c > d and not "..." in s[b - 2:d + 1]:
print("No")
exit()
print("Yes")
``` | output | 1 | 38,379 | 16 | 76,759 |
Provide a correct Python 3 solution for this coding contest problem.
There are N squares arranged in a row, numbered 1, 2, ..., N from left to right. You are given a string S of length N consisting of `.` and `#`. If the i-th character of S is `#`, Square i contains a rock; if the i-th character of S is `.`, Square i is empty.
In the beginning, Snuke stands on Square A, and Fnuke stands on Square B.
You can repeat the following operation any number of times:
* Choose Snuke or Fnuke, and make him jump one or two squares to the right. The destination must be one of the squares, and it must not contain a rock or the other person.
You want to repeat this operation so that Snuke will stand on Square C and Fnuke will stand on Square D.
Determine whether this is possible.
Constraints
* 4 \leq N \leq 200\ 000
* S is a string of length N consisting of `.` and `#`.
* 1 \leq A, B, C, D \leq N
* Square A, B, C and D do not contain a rock.
* A, B, C and D are all different.
* A < B
* A < C
* B < D
Input
Input is given from Standard Input in the following format:
N A B C D
S
Output
Print `Yes` if the objective is achievable, and `No` if it is not.
Examples
Input
7 1 3 6 7
.#..#..
Output
Yes
Input
7 1 3 7 6
.#..#..
Output
No
Input
15 1 3 15 13
...#.#...#.#...
Output
Yes | instruction | 0 | 38,380 | 16 | 76,760 |
"Correct Solution:
```
n, a, b, c, d = map(int, input().split())
s = input()
if c < d:
print("Yes" if s[a - 1:d].count("##") == 0 else "No")
else:
print("Yes" if s[a - 1:c].count("##") ==
0 and s[b - 2:d + 1].count("...") > 0 else "No")
``` | output | 1 | 38,380 | 16 | 76,761 |
Provide a correct Python 3 solution for this coding contest problem.
There are N squares arranged in a row, numbered 1, 2, ..., N from left to right. You are given a string S of length N consisting of `.` and `#`. If the i-th character of S is `#`, Square i contains a rock; if the i-th character of S is `.`, Square i is empty.
In the beginning, Snuke stands on Square A, and Fnuke stands on Square B.
You can repeat the following operation any number of times:
* Choose Snuke or Fnuke, and make him jump one or two squares to the right. The destination must be one of the squares, and it must not contain a rock or the other person.
You want to repeat this operation so that Snuke will stand on Square C and Fnuke will stand on Square D.
Determine whether this is possible.
Constraints
* 4 \leq N \leq 200\ 000
* S is a string of length N consisting of `.` and `#`.
* 1 \leq A, B, C, D \leq N
* Square A, B, C and D do not contain a rock.
* A, B, C and D are all different.
* A < B
* A < C
* B < D
Input
Input is given from Standard Input in the following format:
N A B C D
S
Output
Print `Yes` if the objective is achievable, and `No` if it is not.
Examples
Input
7 1 3 6 7
.#..#..
Output
Yes
Input
7 1 3 7 6
.#..#..
Output
No
Input
15 1 3 15 13
...#.#...#.#...
Output
Yes | instruction | 0 | 38,381 | 16 | 76,762 |
"Correct Solution:
```
N, A, B, C, D = map(int, input().split())
S = input()
print('No' if '##' in S[A:C-1] or '##' in S[B:D-1] or C == D or C > D and '...' not in S[B-2:D+1] else 'Yes')
``` | output | 1 | 38,381 | 16 | 76,763 |
Provide a correct Python 3 solution for this coding contest problem.
There are N squares arranged in a row, numbered 1, 2, ..., N from left to right. You are given a string S of length N consisting of `.` and `#`. If the i-th character of S is `#`, Square i contains a rock; if the i-th character of S is `.`, Square i is empty.
In the beginning, Snuke stands on Square A, and Fnuke stands on Square B.
You can repeat the following operation any number of times:
* Choose Snuke or Fnuke, and make him jump one or two squares to the right. The destination must be one of the squares, and it must not contain a rock or the other person.
You want to repeat this operation so that Snuke will stand on Square C and Fnuke will stand on Square D.
Determine whether this is possible.
Constraints
* 4 \leq N \leq 200\ 000
* S is a string of length N consisting of `.` and `#`.
* 1 \leq A, B, C, D \leq N
* Square A, B, C and D do not contain a rock.
* A, B, C and D are all different.
* A < B
* A < C
* B < D
Input
Input is given from Standard Input in the following format:
N A B C D
S
Output
Print `Yes` if the objective is achievable, and `No` if it is not.
Examples
Input
7 1 3 6 7
.#..#..
Output
Yes
Input
7 1 3 7 6
.#..#..
Output
No
Input
15 1 3 15 13
...#.#...#.#...
Output
Yes | instruction | 0 | 38,382 | 16 | 76,764 |
"Correct Solution:
```
from copy import*
n,a,b,c,d=map(int,input().split())
s=input()
if "##" in s[a-1:c] or "##" in s[b-1:d]:
print("No")
else:
if c<d:
print("Yes")
else:
if "..." in s[max(0,b-2):min(d+1,n)]:
print("Yes")
else:
print("No")
``` | output | 1 | 38,382 | 16 | 76,765 |
Provide a correct Python 3 solution for this coding contest problem.
There are N squares arranged in a row, numbered 1, 2, ..., N from left to right. You are given a string S of length N consisting of `.` and `#`. If the i-th character of S is `#`, Square i contains a rock; if the i-th character of S is `.`, Square i is empty.
In the beginning, Snuke stands on Square A, and Fnuke stands on Square B.
You can repeat the following operation any number of times:
* Choose Snuke or Fnuke, and make him jump one or two squares to the right. The destination must be one of the squares, and it must not contain a rock or the other person.
You want to repeat this operation so that Snuke will stand on Square C and Fnuke will stand on Square D.
Determine whether this is possible.
Constraints
* 4 \leq N \leq 200\ 000
* S is a string of length N consisting of `.` and `#`.
* 1 \leq A, B, C, D \leq N
* Square A, B, C and D do not contain a rock.
* A, B, C and D are all different.
* A < B
* A < C
* B < D
Input
Input is given from Standard Input in the following format:
N A B C D
S
Output
Print `Yes` if the objective is achievable, and `No` if it is not.
Examples
Input
7 1 3 6 7
.#..#..
Output
Yes
Input
7 1 3 7 6
.#..#..
Output
No
Input
15 1 3 15 13
...#.#...#.#...
Output
Yes | instruction | 0 | 38,383 | 16 | 76,766 |
"Correct Solution:
```
n, a, b, c, d = map(int, input().split())
s = input()
a -= 1
b -= 1
c -= 1
d -= 1
# 2個以上の岩があればNG
if "##" in s[a:max(c,d)]:
print("No")
exit()
# AがBを抜けるかどうか
if d < c and not "..." in s[b-1:d+2]:
print("No")
exit()
print("Yes")
``` | output | 1 | 38,383 | 16 | 76,767 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There are N squares arranged in a row, numbered 1, 2, ..., N from left to right. You are given a string S of length N consisting of `.` and `#`. If the i-th character of S is `#`, Square i contains a rock; if the i-th character of S is `.`, Square i is empty.
In the beginning, Snuke stands on Square A, and Fnuke stands on Square B.
You can repeat the following operation any number of times:
* Choose Snuke or Fnuke, and make him jump one or two squares to the right. The destination must be one of the squares, and it must not contain a rock or the other person.
You want to repeat this operation so that Snuke will stand on Square C and Fnuke will stand on Square D.
Determine whether this is possible.
Constraints
* 4 \leq N \leq 200\ 000
* S is a string of length N consisting of `.` and `#`.
* 1 \leq A, B, C, D \leq N
* Square A, B, C and D do not contain a rock.
* A, B, C and D are all different.
* A < B
* A < C
* B < D
Input
Input is given from Standard Input in the following format:
N A B C D
S
Output
Print `Yes` if the objective is achievable, and `No` if it is not.
Examples
Input
7 1 3 6 7
.#..#..
Output
Yes
Input
7 1 3 7 6
.#..#..
Output
No
Input
15 1 3 15 13
...#.#...#.#...
Output
Yes
Submitted Solution:
```
N,A,B,C,D=map(int,input().split())
S=input()
if "##" in S[A-1:max(C,D)] or ("..." not in S[B-2:min(C,D)+1] and C>D):
print("No")
else:
print("Yes")
``` | instruction | 0 | 38,384 | 16 | 76,768 |
Yes | output | 1 | 38,384 | 16 | 76,769 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There are N squares arranged in a row, numbered 1, 2, ..., N from left to right. You are given a string S of length N consisting of `.` and `#`. If the i-th character of S is `#`, Square i contains a rock; if the i-th character of S is `.`, Square i is empty.
In the beginning, Snuke stands on Square A, and Fnuke stands on Square B.
You can repeat the following operation any number of times:
* Choose Snuke or Fnuke, and make him jump one or two squares to the right. The destination must be one of the squares, and it must not contain a rock or the other person.
You want to repeat this operation so that Snuke will stand on Square C and Fnuke will stand on Square D.
Determine whether this is possible.
Constraints
* 4 \leq N \leq 200\ 000
* S is a string of length N consisting of `.` and `#`.
* 1 \leq A, B, C, D \leq N
* Square A, B, C and D do not contain a rock.
* A, B, C and D are all different.
* A < B
* A < C
* B < D
Input
Input is given from Standard Input in the following format:
N A B C D
S
Output
Print `Yes` if the objective is achievable, and `No` if it is not.
Examples
Input
7 1 3 6 7
.#..#..
Output
Yes
Input
7 1 3 7 6
.#..#..
Output
No
Input
15 1 3 15 13
...#.#...#.#...
Output
Yes
Submitted Solution:
```
N, A, B, C, D = map(int, input().split())
S = input()
if ("##" in S[A:C+1]) or ("##" in S[B:D+1]):
print("No")
else:
if C < D:
print("Yes")
else:
if "..." in S[B-2:D+1]:
print("Yes")
else:
print("No")
``` | instruction | 0 | 38,385 | 16 | 76,770 |
Yes | output | 1 | 38,385 | 16 | 76,771 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There are N squares arranged in a row, numbered 1, 2, ..., N from left to right. You are given a string S of length N consisting of `.` and `#`. If the i-th character of S is `#`, Square i contains a rock; if the i-th character of S is `.`, Square i is empty.
In the beginning, Snuke stands on Square A, and Fnuke stands on Square B.
You can repeat the following operation any number of times:
* Choose Snuke or Fnuke, and make him jump one or two squares to the right. The destination must be one of the squares, and it must not contain a rock or the other person.
You want to repeat this operation so that Snuke will stand on Square C and Fnuke will stand on Square D.
Determine whether this is possible.
Constraints
* 4 \leq N \leq 200\ 000
* S is a string of length N consisting of `.` and `#`.
* 1 \leq A, B, C, D \leq N
* Square A, B, C and D do not contain a rock.
* A, B, C and D are all different.
* A < B
* A < C
* B < D
Input
Input is given from Standard Input in the following format:
N A B C D
S
Output
Print `Yes` if the objective is achievable, and `No` if it is not.
Examples
Input
7 1 3 6 7
.#..#..
Output
Yes
Input
7 1 3 7 6
.#..#..
Output
No
Input
15 1 3 15 13
...#.#...#.#...
Output
Yes
Submitted Solution:
```
n, a, b, c, d = map(int, input().split())
s = input()
lbound = min(a, b) - 1
if "##" in s[a - 1 : c] or "##" in s[b - 1 : d]:
print("No")
elif ((a > b) ^ (c > d)) and "..." not in s[max(a, b) - 2 : min(c, d) + 1]:
print("No")
else:
print("Yes")
``` | instruction | 0 | 38,386 | 16 | 76,772 |
Yes | output | 1 | 38,386 | 16 | 76,773 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There are N squares arranged in a row, numbered 1, 2, ..., N from left to right. You are given a string S of length N consisting of `.` and `#`. If the i-th character of S is `#`, Square i contains a rock; if the i-th character of S is `.`, Square i is empty.
In the beginning, Snuke stands on Square A, and Fnuke stands on Square B.
You can repeat the following operation any number of times:
* Choose Snuke or Fnuke, and make him jump one or two squares to the right. The destination must be one of the squares, and it must not contain a rock or the other person.
You want to repeat this operation so that Snuke will stand on Square C and Fnuke will stand on Square D.
Determine whether this is possible.
Constraints
* 4 \leq N \leq 200\ 000
* S is a string of length N consisting of `.` and `#`.
* 1 \leq A, B, C, D \leq N
* Square A, B, C and D do not contain a rock.
* A, B, C and D are all different.
* A < B
* A < C
* B < D
Input
Input is given from Standard Input in the following format:
N A B C D
S
Output
Print `Yes` if the objective is achievable, and `No` if it is not.
Examples
Input
7 1 3 6 7
.#..#..
Output
Yes
Input
7 1 3 7 6
.#..#..
Output
No
Input
15 1 3 15 13
...#.#...#.#...
Output
Yes
Submitted Solution:
```
n, a, b, c, d = map(int, input().split())
S = input()
if c < d and (S[a-1:d+1].count("##") == 0):
print("Yes")
exit()
if c > d and (S[b-2:d+1].count("...") >= 1) and (S[a-1:d+1].count("##") == 0):
print("Yes")
exit()
print("No")
``` | instruction | 0 | 38,387 | 16 | 76,774 |
Yes | output | 1 | 38,387 | 16 | 76,775 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.