text stringlengths 198 433k | conversation_id int64 0 109k |
|---|---|
Provide a correct Python 3 solution for this coding contest problem.
There is a right triangle ABC with ∠ABC=90°.
Given the lengths of the three sides, |AB|,|BC| and |CA|, find the area of the right triangle ABC.
It is guaranteed that the area of the triangle ABC is an integer.
Constraints
* 1 \leq |AB|,|BC|,|CA| \leq 100
* All values in input are integers.
* The area of the triangle ABC is an integer.
Input
Input is given from Standard Input in the following format:
|AB| |BC| |CA|
Output
Print the area of the triangle ABC.
Examples
Input
3 4 5
Output
6
Input
5 12 13
Output
30
Input
45 28 53
Output
630
"Correct Solution:
```
#116a
a,b,c=map(int,input().split())
print(a*b//2)
```
| 88,200 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There is a right triangle ABC with ∠ABC=90°.
Given the lengths of the three sides, |AB|,|BC| and |CA|, find the area of the right triangle ABC.
It is guaranteed that the area of the triangle ABC is an integer.
Constraints
* 1 \leq |AB|,|BC|,|CA| \leq 100
* All values in input are integers.
* The area of the triangle ABC is an integer.
Input
Input is given from Standard Input in the following format:
|AB| |BC| |CA|
Output
Print the area of the triangle ABC.
Examples
Input
3 4 5
Output
6
Input
5 12 13
Output
30
Input
45 28 53
Output
630
Submitted Solution:
```
x,y,z = map(int,input().split())
print(int(x*y/2))
```
Yes
| 88,201 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There is a right triangle ABC with ∠ABC=90°.
Given the lengths of the three sides, |AB|,|BC| and |CA|, find the area of the right triangle ABC.
It is guaranteed that the area of the triangle ABC is an integer.
Constraints
* 1 \leq |AB|,|BC|,|CA| \leq 100
* All values in input are integers.
* The area of the triangle ABC is an integer.
Input
Input is given from Standard Input in the following format:
|AB| |BC| |CA|
Output
Print the area of the triangle ABC.
Examples
Input
3 4 5
Output
6
Input
5 12 13
Output
30
Input
45 28 53
Output
630
Submitted Solution:
```
a, b, c = map(int, input().split())
print((int)(a*b/2))
```
Yes
| 88,202 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There is a right triangle ABC with ∠ABC=90°.
Given the lengths of the three sides, |AB|,|BC| and |CA|, find the area of the right triangle ABC.
It is guaranteed that the area of the triangle ABC is an integer.
Constraints
* 1 \leq |AB|,|BC|,|CA| \leq 100
* All values in input are integers.
* The area of the triangle ABC is an integer.
Input
Input is given from Standard Input in the following format:
|AB| |BC| |CA|
Output
Print the area of the triangle ABC.
Examples
Input
3 4 5
Output
6
Input
5 12 13
Output
30
Input
45 28 53
Output
630
Submitted Solution:
```
c,a,b = map(int,input().split())
print(int(1/2 * c * a))
```
Yes
| 88,203 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There is a right triangle ABC with ∠ABC=90°.
Given the lengths of the three sides, |AB|,|BC| and |CA|, find the area of the right triangle ABC.
It is guaranteed that the area of the triangle ABC is an integer.
Constraints
* 1 \leq |AB|,|BC|,|CA| \leq 100
* All values in input are integers.
* The area of the triangle ABC is an integer.
Input
Input is given from Standard Input in the following format:
|AB| |BC| |CA|
Output
Print the area of the triangle ABC.
Examples
Input
3 4 5
Output
6
Input
5 12 13
Output
30
Input
45 28 53
Output
630
Submitted Solution:
```
A,B,C=map(int,input().split())
print(int(A*B/2))
```
Yes
| 88,204 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There is a right triangle ABC with ∠ABC=90°.
Given the lengths of the three sides, |AB|,|BC| and |CA|, find the area of the right triangle ABC.
It is guaranteed that the area of the triangle ABC is an integer.
Constraints
* 1 \leq |AB|,|BC|,|CA| \leq 100
* All values in input are integers.
* The area of the triangle ABC is an integer.
Input
Input is given from Standard Input in the following format:
|AB| |BC| |CA|
Output
Print the area of the triangle ABC.
Examples
Input
3 4 5
Output
6
Input
5 12 13
Output
30
Input
45 28 53
Output
630
Submitted Solution:
```
a,b,c=map(int,input().split())
print(str(int(0.5*(a+c))))
```
No
| 88,205 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There is a right triangle ABC with ∠ABC=90°.
Given the lengths of the three sides, |AB|,|BC| and |CA|, find the area of the right triangle ABC.
It is guaranteed that the area of the triangle ABC is an integer.
Constraints
* 1 \leq |AB|,|BC|,|CA| \leq 100
* All values in input are integers.
* The area of the triangle ABC is an integer.
Input
Input is given from Standard Input in the following format:
|AB| |BC| |CA|
Output
Print the area of the triangle ABC.
Examples
Input
3 4 5
Output
6
Input
5 12 13
Output
30
Input
45 28 53
Output
630
Submitted Solution:
```
A = int(input())
p = A
C = []
while A not in C:
C.append(A)
if A % 2 == 0:
A = A//2
else:
A = A*3+1
print(len(C)+1)
```
No
| 88,206 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There is a right triangle ABC with ∠ABC=90°.
Given the lengths of the three sides, |AB|,|BC| and |CA|, find the area of the right triangle ABC.
It is guaranteed that the area of the triangle ABC is an integer.
Constraints
* 1 \leq |AB|,|BC|,|CA| \leq 100
* All values in input are integers.
* The area of the triangle ABC is an integer.
Input
Input is given from Standard Input in the following format:
|AB| |BC| |CA|
Output
Print the area of the triangle ABC.
Examples
Input
3 4 5
Output
6
Input
5 12 13
Output
30
Input
45 28 53
Output
630
Submitted Solution:
```
a,b,c=list(input().split())
AB=int(a)
BC=int(b)
ptint(int(AB*BC/2))
```
No
| 88,207 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There is a right triangle ABC with ∠ABC=90°.
Given the lengths of the three sides, |AB|,|BC| and |CA|, find the area of the right triangle ABC.
It is guaranteed that the area of the triangle ABC is an integer.
Constraints
* 1 \leq |AB|,|BC|,|CA| \leq 100
* All values in input are integers.
* The area of the triangle ABC is an integer.
Input
Input is given from Standard Input in the following format:
|AB| |BC| |CA|
Output
Print the area of the triangle ABC.
Examples
Input
3 4 5
Output
6
Input
5 12 13
Output
30
Input
45 28 53
Output
630
Submitted Solution:
```
a, b, c = map(int, input().split(' '))
print(a*b/2)
```
No
| 88,208 |
Provide a correct Python 3 solution for this coding contest problem.
You are given a string S. Each character of S is uppercase or lowercase English letter. Determine if S satisfies all of the following conditions:
* The initial character of S is an uppercase `A`.
* There is exactly one occurrence of `C` between the third character from the beginning and the second to last character (inclusive).
* All letters except the `A` and `C` mentioned above are lowercase.
Constraints
* 4 ≤ |S| ≤ 10 (|S| is the length of the string S.)
* Each character of S is uppercase or lowercase English letter.
Input
Input is given from Standard Input in the following format:
S
Output
If S satisfies all of the conditions in the problem statement, print `AC`; otherwise, print `WA`.
Examples
Input
AtCoder
Output
AC
Input
ACoder
Output
WA
Input
AcycliC
Output
WA
Input
AtCoCo
Output
WA
Input
Atcoder
Output
WA
"Correct Solution:
```
S = input()
if S[0]=='A' and S[2:-1].count('C')==1 and (S[1:S.find('C')]+S[S.find('C')+1:]).islower():
print('AC')
else:
print('WA')
```
| 88,209 |
Provide a correct Python 3 solution for this coding contest problem.
You are given a string S. Each character of S is uppercase or lowercase English letter. Determine if S satisfies all of the following conditions:
* The initial character of S is an uppercase `A`.
* There is exactly one occurrence of `C` between the third character from the beginning and the second to last character (inclusive).
* All letters except the `A` and `C` mentioned above are lowercase.
Constraints
* 4 ≤ |S| ≤ 10 (|S| is the length of the string S.)
* Each character of S is uppercase or lowercase English letter.
Input
Input is given from Standard Input in the following format:
S
Output
If S satisfies all of the conditions in the problem statement, print `AC`; otherwise, print `WA`.
Examples
Input
AtCoder
Output
AC
Input
ACoder
Output
WA
Input
AcycliC
Output
WA
Input
AtCoCo
Output
WA
Input
Atcoder
Output
WA
"Correct Solution:
```
s=input();print('WAAC'['A'==s[0] and s[2:-1].count('C')==1 and s.replace('A','').replace('C','').islower()::2])
```
| 88,210 |
Provide a correct Python 3 solution for this coding contest problem.
You are given a string S. Each character of S is uppercase or lowercase English letter. Determine if S satisfies all of the following conditions:
* The initial character of S is an uppercase `A`.
* There is exactly one occurrence of `C` between the third character from the beginning and the second to last character (inclusive).
* All letters except the `A` and `C` mentioned above are lowercase.
Constraints
* 4 ≤ |S| ≤ 10 (|S| is the length of the string S.)
* Each character of S is uppercase or lowercase English letter.
Input
Input is given from Standard Input in the following format:
S
Output
If S satisfies all of the conditions in the problem statement, print `AC`; otherwise, print `WA`.
Examples
Input
AtCoder
Output
AC
Input
ACoder
Output
WA
Input
AcycliC
Output
WA
Input
AtCoCo
Output
WA
Input
Atcoder
Output
WA
"Correct Solution:
```
S=input()
print("AC" if "C" in S[2:-1] and "A" in S and S[1:].replace("C","",1).islower() else "WA")
```
| 88,211 |
Provide a correct Python 3 solution for this coding contest problem.
You are given a string S. Each character of S is uppercase or lowercase English letter. Determine if S satisfies all of the following conditions:
* The initial character of S is an uppercase `A`.
* There is exactly one occurrence of `C` between the third character from the beginning and the second to last character (inclusive).
* All letters except the `A` and `C` mentioned above are lowercase.
Constraints
* 4 ≤ |S| ≤ 10 (|S| is the length of the string S.)
* Each character of S is uppercase or lowercase English letter.
Input
Input is given from Standard Input in the following format:
S
Output
If S satisfies all of the conditions in the problem statement, print `AC`; otherwise, print `WA`.
Examples
Input
AtCoder
Output
AC
Input
ACoder
Output
WA
Input
AcycliC
Output
WA
Input
AtCoCo
Output
WA
Input
Atcoder
Output
WA
"Correct Solution:
```
s=input()
if 'A' in s and 'C' in s[2:-1] and s[1:].replace('C','',1).islower()==True:
print('AC')
else:
print('WA')
```
| 88,212 |
Provide a correct Python 3 solution for this coding contest problem.
You are given a string S. Each character of S is uppercase or lowercase English letter. Determine if S satisfies all of the following conditions:
* The initial character of S is an uppercase `A`.
* There is exactly one occurrence of `C` between the third character from the beginning and the second to last character (inclusive).
* All letters except the `A` and `C` mentioned above are lowercase.
Constraints
* 4 ≤ |S| ≤ 10 (|S| is the length of the string S.)
* Each character of S is uppercase or lowercase English letter.
Input
Input is given from Standard Input in the following format:
S
Output
If S satisfies all of the conditions in the problem statement, print `AC`; otherwise, print `WA`.
Examples
Input
AtCoder
Output
AC
Input
ACoder
Output
WA
Input
AcycliC
Output
WA
Input
AtCoCo
Output
WA
Input
Atcoder
Output
WA
"Correct Solution:
```
S=input()
judge = "AC" if (S[0] == 'A' and S[2:-1].count('C') == 1 and S[1:].replace('C', '').islower()) else "WA"
print(judge)
```
| 88,213 |
Provide a correct Python 3 solution for this coding contest problem.
You are given a string S. Each character of S is uppercase or lowercase English letter. Determine if S satisfies all of the following conditions:
* The initial character of S is an uppercase `A`.
* There is exactly one occurrence of `C` between the third character from the beginning and the second to last character (inclusive).
* All letters except the `A` and `C` mentioned above are lowercase.
Constraints
* 4 ≤ |S| ≤ 10 (|S| is the length of the string S.)
* Each character of S is uppercase or lowercase English letter.
Input
Input is given from Standard Input in the following format:
S
Output
If S satisfies all of the conditions in the problem statement, print `AC`; otherwise, print `WA`.
Examples
Input
AtCoder
Output
AC
Input
ACoder
Output
WA
Input
AcycliC
Output
WA
Input
AtCoCo
Output
WA
Input
Atcoder
Output
WA
"Correct Solution:
```
import re
p = re.compile(r'^A[a-z]{1,}C[a-z]{1,}$')
S = input()
if bool(p.match(S)):
print('AC')
else:
print('WA')
```
| 88,214 |
Provide a correct Python 3 solution for this coding contest problem.
You are given a string S. Each character of S is uppercase or lowercase English letter. Determine if S satisfies all of the following conditions:
* The initial character of S is an uppercase `A`.
* There is exactly one occurrence of `C` between the third character from the beginning and the second to last character (inclusive).
* All letters except the `A` and `C` mentioned above are lowercase.
Constraints
* 4 ≤ |S| ≤ 10 (|S| is the length of the string S.)
* Each character of S is uppercase or lowercase English letter.
Input
Input is given from Standard Input in the following format:
S
Output
If S satisfies all of the conditions in the problem statement, print `AC`; otherwise, print `WA`.
Examples
Input
AtCoder
Output
AC
Input
ACoder
Output
WA
Input
AcycliC
Output
WA
Input
AtCoCo
Output
WA
Input
Atcoder
Output
WA
"Correct Solution:
```
S = input()
if S[0] == 'A' and S[2:-1].count('C') == 1 and S.replace('A', '').replace('C', '').islower():
print('AC')
else:
print('WA')
```
| 88,215 |
Provide a correct Python 3 solution for this coding contest problem.
You are given a string S. Each character of S is uppercase or lowercase English letter. Determine if S satisfies all of the following conditions:
* The initial character of S is an uppercase `A`.
* There is exactly one occurrence of `C` between the third character from the beginning and the second to last character (inclusive).
* All letters except the `A` and `C` mentioned above are lowercase.
Constraints
* 4 ≤ |S| ≤ 10 (|S| is the length of the string S.)
* Each character of S is uppercase or lowercase English letter.
Input
Input is given from Standard Input in the following format:
S
Output
If S satisfies all of the conditions in the problem statement, print `AC`; otherwise, print `WA`.
Examples
Input
AtCoder
Output
AC
Input
ACoder
Output
WA
Input
AcycliC
Output
WA
Input
AtCoCo
Output
WA
Input
Atcoder
Output
WA
"Correct Solution:
```
i = input()
if i[0]=="A"and i[2:-1].count("C")==1\
and i[1:].replace("C","c",1).islower()==True:
print("AC")
else:print("WA")
```
| 88,216 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given a string S. Each character of S is uppercase or lowercase English letter. Determine if S satisfies all of the following conditions:
* The initial character of S is an uppercase `A`.
* There is exactly one occurrence of `C` between the third character from the beginning and the second to last character (inclusive).
* All letters except the `A` and `C` mentioned above are lowercase.
Constraints
* 4 ≤ |S| ≤ 10 (|S| is the length of the string S.)
* Each character of S is uppercase or lowercase English letter.
Input
Input is given from Standard Input in the following format:
S
Output
If S satisfies all of the conditions in the problem statement, print `AC`; otherwise, print `WA`.
Examples
Input
AtCoder
Output
AC
Input
ACoder
Output
WA
Input
AcycliC
Output
WA
Input
AtCoCo
Output
WA
Input
Atcoder
Output
WA
Submitted Solution:
```
import re
S = input()
if re.match(r'^A[a-z][a-z]*?C[a-z]*?[a-z]$', S):
print('AC')
else:
print('WA')
```
Yes
| 88,217 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given a string S. Each character of S is uppercase or lowercase English letter. Determine if S satisfies all of the following conditions:
* The initial character of S is an uppercase `A`.
* There is exactly one occurrence of `C` between the third character from the beginning and the second to last character (inclusive).
* All letters except the `A` and `C` mentioned above are lowercase.
Constraints
* 4 ≤ |S| ≤ 10 (|S| is the length of the string S.)
* Each character of S is uppercase or lowercase English letter.
Input
Input is given from Standard Input in the following format:
S
Output
If S satisfies all of the conditions in the problem statement, print `AC`; otherwise, print `WA`.
Examples
Input
AtCoder
Output
AC
Input
ACoder
Output
WA
Input
AcycliC
Output
WA
Input
AtCoCo
Output
WA
Input
Atcoder
Output
WA
Submitted Solution:
```
s = input()
print("AC" if s[0] == "A" and s[2:len(s)-1].count("C") == 1 and s[1:].replace("C","",1).islower() else "WA")
```
Yes
| 88,218 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given a string S. Each character of S is uppercase or lowercase English letter. Determine if S satisfies all of the following conditions:
* The initial character of S is an uppercase `A`.
* There is exactly one occurrence of `C` between the third character from the beginning and the second to last character (inclusive).
* All letters except the `A` and `C` mentioned above are lowercase.
Constraints
* 4 ≤ |S| ≤ 10 (|S| is the length of the string S.)
* Each character of S is uppercase or lowercase English letter.
Input
Input is given from Standard Input in the following format:
S
Output
If S satisfies all of the conditions in the problem statement, print `AC`; otherwise, print `WA`.
Examples
Input
AtCoder
Output
AC
Input
ACoder
Output
WA
Input
AcycliC
Output
WA
Input
AtCoCo
Output
WA
Input
Atcoder
Output
WA
Submitted Solution:
```
import re
S = input().strip()
print('AC' if re.match(r'^A[a-z]+C[a-z]+$', S) else 'WA')
```
Yes
| 88,219 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given a string S. Each character of S is uppercase or lowercase English letter. Determine if S satisfies all of the following conditions:
* The initial character of S is an uppercase `A`.
* There is exactly one occurrence of `C` between the third character from the beginning and the second to last character (inclusive).
* All letters except the `A` and `C` mentioned above are lowercase.
Constraints
* 4 ≤ |S| ≤ 10 (|S| is the length of the string S.)
* Each character of S is uppercase or lowercase English letter.
Input
Input is given from Standard Input in the following format:
S
Output
If S satisfies all of the conditions in the problem statement, print `AC`; otherwise, print `WA`.
Examples
Input
AtCoder
Output
AC
Input
ACoder
Output
WA
Input
AcycliC
Output
WA
Input
AtCoCo
Output
WA
Input
Atcoder
Output
WA
Submitted Solution:
```
s = input()
if s[0]=="A" and s[2:-1].count("C")==1 and s[1:].replace("C","a",1).islower()==True:
print('AC')
else:
print('WA')
```
Yes
| 88,220 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given a string S. Each character of S is uppercase or lowercase English letter. Determine if S satisfies all of the following conditions:
* The initial character of S is an uppercase `A`.
* There is exactly one occurrence of `C` between the third character from the beginning and the second to last character (inclusive).
* All letters except the `A` and `C` mentioned above are lowercase.
Constraints
* 4 ≤ |S| ≤ 10 (|S| is the length of the string S.)
* Each character of S is uppercase or lowercase English letter.
Input
Input is given from Standard Input in the following format:
S
Output
If S satisfies all of the conditions in the problem statement, print `AC`; otherwise, print `WA`.
Examples
Input
AtCoder
Output
AC
Input
ACoder
Output
WA
Input
AcycliC
Output
WA
Input
AtCoCo
Output
WA
Input
Atcoder
Output
WA
Submitted Solution:
```
s=input()
ans = True
count = 0
for i in range(len(s)):
if s[i].isupper():
count+=1
if count != 2:
print('Wa')
exit()
elif s[2:-1].count('C') != 1 or s[0]!='A' or not s[1].islower():
print('Wa')
else:
print('AC')
```
No
| 88,221 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given a string S. Each character of S is uppercase or lowercase English letter. Determine if S satisfies all of the following conditions:
* The initial character of S is an uppercase `A`.
* There is exactly one occurrence of `C` between the third character from the beginning and the second to last character (inclusive).
* All letters except the `A` and `C` mentioned above are lowercase.
Constraints
* 4 ≤ |S| ≤ 10 (|S| is the length of the string S.)
* Each character of S is uppercase or lowercase English letter.
Input
Input is given from Standard Input in the following format:
S
Output
If S satisfies all of the conditions in the problem statement, print `AC`; otherwise, print `WA`.
Examples
Input
AtCoder
Output
AC
Input
ACoder
Output
WA
Input
AcycliC
Output
WA
Input
AtCoCo
Output
WA
Input
Atcoder
Output
WA
Submitted Solution:
```
import re
s = input()
print('AC' if s[0].isupper() and (s[2:-2].count('C') == 1 or (s[2:-2] == '' and s[2] == 'C')) and len(re.findall('[a-z]', s)) == len(s) - 2 else 'WA')
```
No
| 88,222 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given a string S. Each character of S is uppercase or lowercase English letter. Determine if S satisfies all of the following conditions:
* The initial character of S is an uppercase `A`.
* There is exactly one occurrence of `C` between the third character from the beginning and the second to last character (inclusive).
* All letters except the `A` and `C` mentioned above are lowercase.
Constraints
* 4 ≤ |S| ≤ 10 (|S| is the length of the string S.)
* Each character of S is uppercase or lowercase English letter.
Input
Input is given from Standard Input in the following format:
S
Output
If S satisfies all of the conditions in the problem statement, print `AC`; otherwise, print `WA`.
Examples
Input
AtCoder
Output
AC
Input
ACoder
Output
WA
Input
AcycliC
Output
WA
Input
AtCoCo
Output
WA
Input
Atcoder
Output
WA
Submitted Solution:
```
import sys
str = input()
if str[0] != 'A' :
print("WA")
sys.exit()
str.replace('A', 'a', 1)
flag = False
for i in range(2, len(str) - 1) :
if str[i] == 'C':
str.replace('C' , 'c', 1)
flag = True
if not flag :
print("WA")
sys.exit()
if str.islower():
print("AC")
else:
print("WA")
```
No
| 88,223 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given a string S. Each character of S is uppercase or lowercase English letter. Determine if S satisfies all of the following conditions:
* The initial character of S is an uppercase `A`.
* There is exactly one occurrence of `C` between the third character from the beginning and the second to last character (inclusive).
* All letters except the `A` and `C` mentioned above are lowercase.
Constraints
* 4 ≤ |S| ≤ 10 (|S| is the length of the string S.)
* Each character of S is uppercase or lowercase English letter.
Input
Input is given from Standard Input in the following format:
S
Output
If S satisfies all of the conditions in the problem statement, print `AC`; otherwise, print `WA`.
Examples
Input
AtCoder
Output
AC
Input
ACoder
Output
WA
Input
AcycliC
Output
WA
Input
AtCoCo
Output
WA
Input
Atcoder
Output
WA
Submitted Solution:
```
large=list("BDEFGHIJKLMNOPQRSTUVWXYZ")
small=list("abcdefghijklmnopqrstuvwxyz")
s=list(input())
if s[0]!="A" or s.count("A")!=1:
print("WA")
exit()
t=s[3:len(s)-1]
if t.count("C")!=1:
print("WA")
exit()
for i in s:
if i in large:
print("WA")
exit()
print("AC")
```
No
| 88,224 |
Provide a correct Python 3 solution for this coding contest problem.
You are given an H \times W grid. The square at the top-left corner will be represented by (0, 0), and the square at the bottom-right corner will be represented by (H-1, W-1).
Of those squares, N squares (x_1, y_1), (x_2, y_2), ..., (x_N, y_N) are painted black, and the other squares are painted white.
Let the shortest distance between white squares A and B be the minimum number of moves required to reach B from A visiting only white squares, where one can travel to an adjacent square sharing a side (up, down, left or right) in one move.
Since there are H × W - N white squares in total, there are _{(H×W-N)}C_2 ways to choose two of the white squares.
For each of these _{(H×W-N)}C_2 ways, find the shortest distance between the chosen squares, then find the sum of all those distances, modulo 1 000 000 007=10^9+7.
Constraints
* 1 \leq H, W \leq 10^6
* 1 \leq N \leq 30
* 0 \leq x_i \leq H-1
* 0 \leq y_i \leq W-1
* If i \neq j, then either x_i \neq x_j or y_i \neq y_j.
* There is at least one white square.
* For every pair of white squares A and B, it is possible to reach B from A visiting only white squares.
Input
Input is given from Standard Input in the following format:
H W
N
x_1 y_1
x_2 y_2
:
x_N y_N
Output
Print the sum of the shortest distances, modulo 10^9+7.
Examples
Input
2 3
1
1 1
Output
20
Input
2 3
1
1 2
Output
16
Input
3 3
1
1 1
Output
64
Input
4 4
4
0 1
1 1
2 1
2 2
Output
268
Input
1000000 1000000
1
0 0
Output
333211937
"Correct Solution:
```
from collections import deque, Counter
import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
mod = 10**9 + 7
h, w = map(int, input().split())
n = int(input())
ans = 0
black = []
row = Counter()
column = Counter()
for _ in range(n):
x, y = map(int, input().split())
row[x] += 1
column[y] += 1
black.append((x, y))
row[h] += 1
column[w] += 1
def sqsum(x):
return x*(x+1)*(2*x+1)//6
pre = -1
top = 0
bottom = h*w - n
area = []
for i in sorted(row.keys()):
if i == pre+2:
top += w
bottom -= w
area.append([-1, 1])
elif i > pre+2:
ans += (i-pre-2)*top*bottom + ((i-pre-2)*(i-pre-1)//2) * \
w*(bottom-top) - sqsum(i-pre-2)*(w**2)
ans %= mod
top += (i-pre-1)*w
bottom -= (i-pre-1)*w
area.append([-1, i-pre-1])
if i != h:
top += w-row[i]
bottom -= w-row[i]
area.append([i])
pre = i
R = len(area)
pre = -1
left = 0
right = h*w-n
area2 = []
for j in sorted(column.keys()):
if j == pre+2:
left += h
right -= h
area2.append([area[i][1] if area[i][0] == -1 else 1 for i in range(R)])
elif j > pre+2:
ans += (j-pre-2)*left*right + ((j-pre-2)*(j-pre-1)//2) * \
h*(right-left) - sqsum(j-pre-2)*(h**2)
ans %= mod
left += (j-pre-1)*h
right -= (j-pre-1)*h
area2.append([(j-pre-1)*area[i][1] if area[i][0]
== -1 else (j-pre-1) for i in range(R)])
if j != w:
left += h-column[j]
right -= h-column[j]
tmp = []
for i in range(R):
if area[i][0] == -1:
tmp.append(area[i][1])
else:
if (area[i][0], j) in black:
tmp.append(0)
else:
tmp.append(1)
area2.append(tmp)
pre = j
C = len(area2)
area2 = [[area2[j][i] for j in range(C)] for i in range(R)]
vec = [[1, 0], [0, 1], [-1, 0], [0, -1]]
def bfs(p, q):
dist = [[10**5 for _ in range(C)] for __ in range(R)]
visited = [[False for _ in range(C)] for __ in range(R)]
dist[p][q] = 0
visited[p][q] = True
q = deque([(p, q)])
while q:
x, y = q.popleft()
for dx, dy in vec:
if 0 <= x+dx < R and 0 <= y+dy < C and area2[x+dx][y+dy] != 0:
if not visited[x+dx][y+dy]:
dist[x+dx][y+dy] = dist[x][y] + 1
visited[x+dx][y+dy] = True
q.append((x+dx, y+dy))
return dist
ans2 = 0
for x in range(R*C):
i = x//C
j = x % C
if area2[i][j] == 0:
continue
d = bfs(i, j)
for y in range(R*C):
k = y//C
l = y % C
if area2[k][l] == 0:
continue
ans2 += area2[i][j]*area2[k][l]*d[k][l]
ans2 %= mod
ans2 *= pow(2, mod-2, mod)
print((ans+ans2) % mod)
```
| 88,225 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given an H \times W grid. The square at the top-left corner will be represented by (0, 0), and the square at the bottom-right corner will be represented by (H-1, W-1).
Of those squares, N squares (x_1, y_1), (x_2, y_2), ..., (x_N, y_N) are painted black, and the other squares are painted white.
Let the shortest distance between white squares A and B be the minimum number of moves required to reach B from A visiting only white squares, where one can travel to an adjacent square sharing a side (up, down, left or right) in one move.
Since there are H × W - N white squares in total, there are _{(H×W-N)}C_2 ways to choose two of the white squares.
For each of these _{(H×W-N)}C_2 ways, find the shortest distance between the chosen squares, then find the sum of all those distances, modulo 1 000 000 007=10^9+7.
Constraints
* 1 \leq H, W \leq 10^6
* 1 \leq N \leq 30
* 0 \leq x_i \leq H-1
* 0 \leq y_i \leq W-1
* If i \neq j, then either x_i \neq x_j or y_i \neq y_j.
* There is at least one white square.
* For every pair of white squares A and B, it is possible to reach B from A visiting only white squares.
Input
Input is given from Standard Input in the following format:
H W
N
x_1 y_1
x_2 y_2
:
x_N y_N
Output
Print the sum of the shortest distances, modulo 10^9+7.
Examples
Input
2 3
1
1 1
Output
20
Input
2 3
1
1 2
Output
16
Input
3 3
1
1 1
Output
64
Input
4 4
4
0 1
1 1
2 1
2 2
Output
268
Input
1000000 1000000
1
0 0
Output
333211937
Submitted Solution:
```
from collections import deque
mod = 10**9 + 7
h, w = map(int, input().split())
n = int(input())
ans = 0
black = []
row = [0]*h
column = [0]*w
for _ in range(n):
x, y = map(int, input().split())
row[x] += 1
column[y] += 1
black.append([x, y])
cnt = 0
top = 0
bottom = h*w - n
area = []
for i in range(h):
if row[i] == 0:
cnt += 1
if i != h-1 and row[i+1] == 0:
top += w
bottom -= w
ans += top*bottom
ans %= mod
else:
area.append([cnt for _ in range(w)])
else:
top += w-row[i]
bottom -= w-row[i]
area.append([1 for _ in range(w)])
for x, y in black:
if x == i:
area[-1][y] = 0
cnt = 0
R = len(area)
cnt = 0
left = 0
right = h*w - n
area2 = []
for j in range(w):
if column[j] == 0:
cnt += 1
if j != w-1 and column[j+1] == 0:
left += h
right -= h
ans += left*right
ans %= mod
else:
area2.append([cnt*area[i][j] for i in range(R)])
else:
left += w-column[j]
right -= w-column[j]
area2.append([area[i][j] for i in range(R)])
cnt = 0
C = len(area2)
vec = [[1, 0], [0, 1], [-1, 0], [0, -1]]
def bfs(p, q):
dist = [[10**9 for _ in range(R)] for __ in range(C)]
visited = [[False for _ in range(R)] for __ in range(C)]
dist[p][q] = 0
visited[p][q] = True
q = deque([(p, q)])
while q:
x, y = q.popleft()
for dx, dy in vec:
if 0 <= x+dx < C and 0 <= y+dy < R and area2[x+dx][y+dy] != 0:
if not visited[x+dx][y+dy]:
dist[x+dx][y+dy] = dist[x][y] + 1
visited[x+dx][y+dy] = True
q.append((x+dx, y+dy))
return dist
ans2 = 0
for i in range(C):
for j in range(R):
d = bfs(i, j)
for k in range(C):
for l in range(R):
ans2 += area2[i][j]*area2[k][l]*d[k][l]
ans2 %= mod
ans2 *= pow(2, mod-2, mod)
print((ans+ans2) % mod)
```
No
| 88,226 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given an H \times W grid. The square at the top-left corner will be represented by (0, 0), and the square at the bottom-right corner will be represented by (H-1, W-1).
Of those squares, N squares (x_1, y_1), (x_2, y_2), ..., (x_N, y_N) are painted black, and the other squares are painted white.
Let the shortest distance between white squares A and B be the minimum number of moves required to reach B from A visiting only white squares, where one can travel to an adjacent square sharing a side (up, down, left or right) in one move.
Since there are H × W - N white squares in total, there are _{(H×W-N)}C_2 ways to choose two of the white squares.
For each of these _{(H×W-N)}C_2 ways, find the shortest distance between the chosen squares, then find the sum of all those distances, modulo 1 000 000 007=10^9+7.
Constraints
* 1 \leq H, W \leq 10^6
* 1 \leq N \leq 30
* 0 \leq x_i \leq H-1
* 0 \leq y_i \leq W-1
* If i \neq j, then either x_i \neq x_j or y_i \neq y_j.
* There is at least one white square.
* For every pair of white squares A and B, it is possible to reach B from A visiting only white squares.
Input
Input is given from Standard Input in the following format:
H W
N
x_1 y_1
x_2 y_2
:
x_N y_N
Output
Print the sum of the shortest distances, modulo 10^9+7.
Examples
Input
2 3
1
1 1
Output
20
Input
2 3
1
1 2
Output
16
Input
3 3
1
1 1
Output
64
Input
4 4
4
0 1
1 1
2 1
2 2
Output
268
Input
1000000 1000000
1
0 0
Output
333211937
Submitted Solution:
```
from collections import Counter
mod = 10**9+7
h, w = map(int, input().split())
n = int(input())
ans = 0
black = []
row = Counter()
column = Counter()
for _ in range(n):
x, y = map(int, input().split())
row[x] += 1
column[y] += 1
black.append((x, y))
row[h] += 1
column[w] += 1
def sqsum(x):
return x*(x+1)*(2*x+1)//6
pre = -1
top = 0
bottom = h*w - n
area = []
for i in sorted(row.keys()):
if i == pre+2:
top += w
bottom -= w
area.append([-1, 1])
elif i > pre+2:
# for x in range(pre+1, i-1):
# top += w
# bottom -= w
# ans += top*bottom
# ans %= mod
ans += (i-pre-2)*top*bottom + ((i-pre-2)*(i-pre-1)//2) * \
w*(bottom-top) - sqsum(i-pre-2)*(w**2)
ans %= mod
top += (i-pre-1)*w
bottom -= (i-pre-1)*w
area.append([-1, i-pre-1])
if i != h:
top += w-row[i]
bottom -= w-row[i]
area.append([i])
pre = i
R = len(area)
pre = -1
left = 0
right = h*w-n
area2 = []
for j in sorted(column.keys()):
if j == pre+2:
left += h
right -= h
area2.append([area[i][1] if area[i][0] == -1 else 1 for i in range(R)])
elif j > pre+2:
ans += (j-pre-2)*left*right + ((j-pre-2)*(j-pre-1)//2) * \
h*(right-left) - sqsum(j-pre-2)*(h**2)
ans %= mod
left += (j-pre-1)*h
right -= (j-pre-1)*h
area2.append([(j-pre-1)*area[i][1] if area[i][0]
== -1 else (j-pre-1) for i in range(R)])
if j != w:
left += h-column[j]
right -= h-column[j]
tmp = []
for i in range(R):
if area[i][0] == -1:
tmp.append(area[i][1])
else:
if (area[i][0], j) in black:
tmp.append(0)
else:
tmp.append(1)
area2.append(tmp)
pre = j
C = len(area2)
area2 = [[area2[j][i] % mod for j in range(C)] for i in range(R)]
# print(R, C)
# for x in area2:
# print(*x)
# exit()
INF = 10**9+7
d = [[INF]*(R*C) for _ in range(R*C)]
vec = [[1, 0], [0, 1], [-1, 0], [0, -1]]
for i in range(R*C):
x = i//C
y = i % C
if area2[x][y] == 0:
continue
for dx, dy in vec:
j = (x+dx)*C + y+dy
if 0 <= x+dx < R and 0 <= y+dy < C and area2[x+dx][y+dy] != 0:
d[i][j] = d[j][i] = 1
def warfl(d, card):
for i in range(card):
d[i][i] = 0
for k in range(card):
for i in range(card):
for j in range(card):
if d[i][k] != INF and d[k][j] != INF:
d[i][j] = min(d[i][j], d[i][k] + d[k][j])
return d
ans2 = 0
d = warfl(d, R*C)
for i in range(R*C):
for j in range(R*C):
ans2 += area2[i//C][i % C]*area2[j//C][j % C]*d[i][j]
ans2 %= mod
ans2 *= pow(2, mod-2, mod)
print((ans+ans2) % mod)
```
No
| 88,227 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given an H \times W grid. The square at the top-left corner will be represented by (0, 0), and the square at the bottom-right corner will be represented by (H-1, W-1).
Of those squares, N squares (x_1, y_1), (x_2, y_2), ..., (x_N, y_N) are painted black, and the other squares are painted white.
Let the shortest distance between white squares A and B be the minimum number of moves required to reach B from A visiting only white squares, where one can travel to an adjacent square sharing a side (up, down, left or right) in one move.
Since there are H × W - N white squares in total, there are _{(H×W-N)}C_2 ways to choose two of the white squares.
For each of these _{(H×W-N)}C_2 ways, find the shortest distance between the chosen squares, then find the sum of all those distances, modulo 1 000 000 007=10^9+7.
Constraints
* 1 \leq H, W \leq 10^6
* 1 \leq N \leq 30
* 0 \leq x_i \leq H-1
* 0 \leq y_i \leq W-1
* If i \neq j, then either x_i \neq x_j or y_i \neq y_j.
* There is at least one white square.
* For every pair of white squares A and B, it is possible to reach B from A visiting only white squares.
Input
Input is given from Standard Input in the following format:
H W
N
x_1 y_1
x_2 y_2
:
x_N y_N
Output
Print the sum of the shortest distances, modulo 10^9+7.
Examples
Input
2 3
1
1 1
Output
20
Input
2 3
1
1 2
Output
16
Input
3 3
1
1 1
Output
64
Input
4 4
4
0 1
1 1
2 1
2 2
Output
268
Input
1000000 1000000
1
0 0
Output
333211937
Submitted Solution:
```
from collections import deque, Counter
mod = 10**9 + 7
h, w = map(int, input().split())
n = int(input())
ans = 0
black = []
row = Counter()
column = Counter()
for _ in range(n):
x, y = map(int, input().split())
row[x] += 1
column[y] += 1
black.append((x, y))
row[h] += 1
column[w] += 1
def sqsum(x):
return x*(x+1)*(2*x+1)//6
pre = -1
top = 0
bottom = h*w - n
area = []
for i in sorted(row.keys()):
if i == pre+2:
top += w
bottom -= w
area.append([-1, 1])
elif i > pre+2:
# for x in range(pre+1, i-1):
# top += w
# bottom -= w
# ans += top*bottom
# ans %= mod
ans += (i-pre-2)*top*bottom + ((i-pre-2)*(i-pre-1)//2) *w*(bottom-top) - sqsum(i-pre-2)*(w**2)
ans %= mod
top += (i-pre-1)*w
bottom -= (i-pre-1)*w
area.append([-1, i-pre-1])
if i != h:
top += w-row[i]
bottom -= w-row[i]
area.append([i])
pre = i
R = len(area)
pre = -1
left = 0
right = h*w-n
area2 = []
for j in sorted(column.keys()):
if j == pre+2:
left += h
right -= h
area2.append([area[i][1] if area[i][0] == -1 else 1 for i in range(R)])
elif j > pre+2:
ans += (j-pre-2)*left*right + ((j-pre-2)*(j-pre-1)//2) *h*(right-left) - sqsum(j-pre-2)*(h**2)
ans %= mod
left += (j-pre-1)*h
right -= (j-pre-1)*h
area2.append([(j-pre-1)*area[i][1] if area[i][0]
== -1 else (j-pre-1) for i in range(R)])
if j != w:
left += h-column[j]
right -= h-column[j]
tmp = []
for i in range(R):
if area[i][0] == -1:
tmp.append(area[i][1])
else:
if (area[i][0], j) in black:
tmp.append(0)
else:
tmp.append(1)
area2.append(tmp)
pre = j
C = len(area2)
area2 = [[area2[j][i] for j in range(C)] for i in range(R)]
vec = [[1, 0], [0, 1], [-1, 0], [0, -1]]
def bfs(p, q):
dist = [[10**5 for _ in range(C)] for __ in range(R)]
visited = [[False for _ in range(C)] for __ in range(R)]
dist[p][q] = 0
visited[p][q] = True
q = deque([(p, q)])
while q:
x, y = q.popleft()
for dx, dy in vec:
if 0 <= x+dx < R and 0 <= y+dy < C and area2[x+dx][y+dy] != 0:
if not visited[x+dx][y+dy]:
dist[x+dx][y+dy] = dist[x][y] + 1
visited[x+dx][y+dy] = True
q.append((x+dx, y+dy))
return dist
ans2 = 0
for i in range(R):
for j in range(C):
if area2[i][j] == 0:
continue
d = bfs(i, j)
for k in range(R):
for l in range(C):
if area2[k][l] == 0:
continue
ans2 += area2[i][j]*area2[k][l]*d[k][l]
ans2 %= mod
ans2 *= pow(2, mod-2, mod)
print((ans+ans2) % mod)
```
No
| 88,228 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given an H \times W grid. The square at the top-left corner will be represented by (0, 0), and the square at the bottom-right corner will be represented by (H-1, W-1).
Of those squares, N squares (x_1, y_1), (x_2, y_2), ..., (x_N, y_N) are painted black, and the other squares are painted white.
Let the shortest distance between white squares A and B be the minimum number of moves required to reach B from A visiting only white squares, where one can travel to an adjacent square sharing a side (up, down, left or right) in one move.
Since there are H × W - N white squares in total, there are _{(H×W-N)}C_2 ways to choose two of the white squares.
For each of these _{(H×W-N)}C_2 ways, find the shortest distance between the chosen squares, then find the sum of all those distances, modulo 1 000 000 007=10^9+7.
Constraints
* 1 \leq H, W \leq 10^6
* 1 \leq N \leq 30
* 0 \leq x_i \leq H-1
* 0 \leq y_i \leq W-1
* If i \neq j, then either x_i \neq x_j or y_i \neq y_j.
* There is at least one white square.
* For every pair of white squares A and B, it is possible to reach B from A visiting only white squares.
Input
Input is given from Standard Input in the following format:
H W
N
x_1 y_1
x_2 y_2
:
x_N y_N
Output
Print the sum of the shortest distances, modulo 10^9+7.
Examples
Input
2 3
1
1 1
Output
20
Input
2 3
1
1 2
Output
16
Input
3 3
1
1 1
Output
64
Input
4 4
4
0 1
1 1
2 1
2 2
Output
268
Input
1000000 1000000
1
0 0
Output
333211937
Submitted Solution:
```
print("bandzebo")
```
No
| 88,229 |
Provide a correct Python 3 solution for this coding contest problem.
It is September 9 in Japan now.
You are given a two-digit integer N. Answer the question: Is 9 contained in the decimal notation of N?
Constraints
* 10≤N≤99
Input
Input is given from Standard Input in the following format:
N
Output
If 9 is contained in the decimal notation of N, print `Yes`; if not, print `No`.
Examples
Input
29
Output
Yes
Input
72
Output
No
Input
91
Output
Yes
"Correct Solution:
```
print('Yes' if '9' in str(input()) else 'No')
```
| 88,230 |
Provide a correct Python 3 solution for this coding contest problem.
It is September 9 in Japan now.
You are given a two-digit integer N. Answer the question: Is 9 contained in the decimal notation of N?
Constraints
* 10≤N≤99
Input
Input is given from Standard Input in the following format:
N
Output
If 9 is contained in the decimal notation of N, print `Yes`; if not, print `No`.
Examples
Input
29
Output
Yes
Input
72
Output
No
Input
91
Output
Yes
"Correct Solution:
```
n=list(str(input()))
print("Yes" if "9" in n else "No")
```
| 88,231 |
Provide a correct Python 3 solution for this coding contest problem.
It is September 9 in Japan now.
You are given a two-digit integer N. Answer the question: Is 9 contained in the decimal notation of N?
Constraints
* 10≤N≤99
Input
Input is given from Standard Input in the following format:
N
Output
If 9 is contained in the decimal notation of N, print `Yes`; if not, print `No`.
Examples
Input
29
Output
Yes
Input
72
Output
No
Input
91
Output
Yes
"Correct Solution:
```
print('Yes' if input().count('9') else 'No')
```
| 88,232 |
Provide a correct Python 3 solution for this coding contest problem.
It is September 9 in Japan now.
You are given a two-digit integer N. Answer the question: Is 9 contained in the decimal notation of N?
Constraints
* 10≤N≤99
Input
Input is given from Standard Input in the following format:
N
Output
If 9 is contained in the decimal notation of N, print `Yes`; if not, print `No`.
Examples
Input
29
Output
Yes
Input
72
Output
No
Input
91
Output
Yes
"Correct Solution:
```
print('YNeos'[input().find('9')==-1::2])
```
| 88,233 |
Provide a correct Python 3 solution for this coding contest problem.
It is September 9 in Japan now.
You are given a two-digit integer N. Answer the question: Is 9 contained in the decimal notation of N?
Constraints
* 10≤N≤99
Input
Input is given from Standard Input in the following format:
N
Output
If 9 is contained in the decimal notation of N, print `Yes`; if not, print `No`.
Examples
Input
29
Output
Yes
Input
72
Output
No
Input
91
Output
Yes
"Correct Solution:
```
a = input()
print(['No','Yes']['9' in a])
```
| 88,234 |
Provide a correct Python 3 solution for this coding contest problem.
It is September 9 in Japan now.
You are given a two-digit integer N. Answer the question: Is 9 contained in the decimal notation of N?
Constraints
* 10≤N≤99
Input
Input is given from Standard Input in the following format:
N
Output
If 9 is contained in the decimal notation of N, print `Yes`; if not, print `No`.
Examples
Input
29
Output
Yes
Input
72
Output
No
Input
91
Output
Yes
"Correct Solution:
```
a=input()
print('Yes' if a[0]=='9' or a[1]=='9' else 'No')
```
| 88,235 |
Provide a correct Python 3 solution for this coding contest problem.
It is September 9 in Japan now.
You are given a two-digit integer N. Answer the question: Is 9 contained in the decimal notation of N?
Constraints
* 10≤N≤99
Input
Input is given from Standard Input in the following format:
N
Output
If 9 is contained in the decimal notation of N, print `Yes`; if not, print `No`.
Examples
Input
29
Output
Yes
Input
72
Output
No
Input
91
Output
Yes
"Correct Solution:
```
print("YNeos"[not'9'in(input())::2])
```
| 88,236 |
Provide a correct Python 3 solution for this coding contest problem.
It is September 9 in Japan now.
You are given a two-digit integer N. Answer the question: Is 9 contained in the decimal notation of N?
Constraints
* 10≤N≤99
Input
Input is given from Standard Input in the following format:
N
Output
If 9 is contained in the decimal notation of N, print `Yes`; if not, print `No`.
Examples
Input
29
Output
Yes
Input
72
Output
No
Input
91
Output
Yes
"Correct Solution:
```
N = input()
print('Yes' if N.find('9') != -1 else 'No')
```
| 88,237 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
It is September 9 in Japan now.
You are given a two-digit integer N. Answer the question: Is 9 contained in the decimal notation of N?
Constraints
* 10≤N≤99
Input
Input is given from Standard Input in the following format:
N
Output
If 9 is contained in the decimal notation of N, print `Yes`; if not, print `No`.
Examples
Input
29
Output
Yes
Input
72
Output
No
Input
91
Output
Yes
Submitted Solution:
```
print("Yes") if "9" in list(input()) else print("No")
```
Yes
| 88,238 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
It is September 9 in Japan now.
You are given a two-digit integer N. Answer the question: Is 9 contained in the decimal notation of N?
Constraints
* 10≤N≤99
Input
Input is given from Standard Input in the following format:
N
Output
If 9 is contained in the decimal notation of N, print `Yes`; if not, print `No`.
Examples
Input
29
Output
Yes
Input
72
Output
No
Input
91
Output
Yes
Submitted Solution:
```
print("Yes" if input().count("9") >= 1 else "No")
```
Yes
| 88,239 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
It is September 9 in Japan now.
You are given a two-digit integer N. Answer the question: Is 9 contained in the decimal notation of N?
Constraints
* 10≤N≤99
Input
Input is given from Standard Input in the following format:
N
Output
If 9 is contained in the decimal notation of N, print `Yes`; if not, print `No`.
Examples
Input
29
Output
Yes
Input
72
Output
No
Input
91
Output
Yes
Submitted Solution:
```
N = input()
print("Yes" if N.count("9") != 0 else "No")
```
Yes
| 88,240 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
It is September 9 in Japan now.
You are given a two-digit integer N. Answer the question: Is 9 contained in the decimal notation of N?
Constraints
* 10≤N≤99
Input
Input is given from Standard Input in the following format:
N
Output
If 9 is contained in the decimal notation of N, print `Yes`; if not, print `No`.
Examples
Input
29
Output
Yes
Input
72
Output
No
Input
91
Output
Yes
Submitted Solution:
```
n = input()
print('Yes' if '9' in set(n) else 'No')
```
Yes
| 88,241 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
It is September 9 in Japan now.
You are given a two-digit integer N. Answer the question: Is 9 contained in the decimal notation of N?
Constraints
* 10≤N≤99
Input
Input is given from Standard Input in the following format:
N
Output
If 9 is contained in the decimal notation of N, print `Yes`; if not, print `No`.
Examples
Input
29
Output
Yes
Input
72
Output
No
Input
91
Output
Yes
Submitted Solution:
```
print(5)
```
No
| 88,242 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
It is September 9 in Japan now.
You are given a two-digit integer N. Answer the question: Is 9 contained in the decimal notation of N?
Constraints
* 10≤N≤99
Input
Input is given from Standard Input in the following format:
N
Output
If 9 is contained in the decimal notation of N, print `Yes`; if not, print `No`.
Examples
Input
29
Output
Yes
Input
72
Output
No
Input
91
Output
Yes
Submitted Solution:
```
N = int(input())
print("Yes" if N % 10 == 9 or N // 10 % 9 else "No")
```
No
| 88,243 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
It is September 9 in Japan now.
You are given a two-digit integer N. Answer the question: Is 9 contained in the decimal notation of N?
Constraints
* 10≤N≤99
Input
Input is given from Standard Input in the following format:
N
Output
If 9 is contained in the decimal notation of N, print `Yes`; if not, print `No`.
Examples
Input
29
Output
Yes
Input
72
Output
No
Input
91
Output
Yes
Submitted Solution:
```
n = list(input())
print('YES' if '9' in n else 'NO')
```
No
| 88,244 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
It is September 9 in Japan now.
You are given a two-digit integer N. Answer the question: Is 9 contained in the decimal notation of N?
Constraints
* 10≤N≤99
Input
Input is given from Standard Input in the following format:
N
Output
If 9 is contained in the decimal notation of N, print `Yes`; if not, print `No`.
Examples
Input
29
Output
Yes
Input
72
Output
No
Input
91
Output
Yes
Submitted Solution:
```
from scipy.sparse import*
(N,M,R),r,*t=[map(int,i.split())for i in __import__("sys").stdin]
a,b,c=zip(*t)
l=csgraph.dijkstra(csr_matrix((c,(a,b)),[N+1]*2),0)
print(min(sum(int(l[i][j])for i,j in zip(a[:-1],a[1:]))for a in __import__("itertools").permutations(r)))
```
No
| 88,245 |
Provide a correct Python 3 solution for this coding contest problem.
How many infinite sequences a_1, a_2, ... consisting of {{1, ... ,n}} satisfy the following conditions?
* The n-th and subsequent elements are all equal. That is, if n \leq i,j, a_i = a_j.
* For every integer i, the a_i elements immediately following the i-th element are all equal. That is, if i < j < k\leq i+a_i, a_j = a_k.
Find the count modulo 10^9+7.
Constraints
* 1 \leq n \leq 10^6
Input
Input is given from Standard Input in the following format:
n
Output
Print how many sequences satisfy the conditions, modulo 10^9+7.
Examples
Input
2
Output
4
Input
654321
Output
968545283
"Correct Solution:
```
import math
#import numpy as np
import queue
from collections import deque,defaultdict
import heapq as hpq
from sys import stdin,setrecursionlimit
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)
def main():
n = int(ipt())
mod = 10**9+7
a = [n,n*n%mod]
sa = [0,0]
for i in range(2,n):
a.append((a[-1]+sa[-1]+(n-i+1)*n%mod)%mod)
sa.append((sa[-1]+a[i-2]+n-1)%mod)
print(a[-1])
return
if __name__ == '__main__':
main()
```
| 88,246 |
Provide a correct Python 3 solution for this coding contest problem.
How many infinite sequences a_1, a_2, ... consisting of {{1, ... ,n}} satisfy the following conditions?
* The n-th and subsequent elements are all equal. That is, if n \leq i,j, a_i = a_j.
* For every integer i, the a_i elements immediately following the i-th element are all equal. That is, if i < j < k\leq i+a_i, a_j = a_k.
Find the count modulo 10^9+7.
Constraints
* 1 \leq n \leq 10^6
Input
Input is given from Standard Input in the following format:
n
Output
Print how many sequences satisfy the conditions, modulo 10^9+7.
Examples
Input
2
Output
4
Input
654321
Output
968545283
"Correct Solution:
```
def main():
mod = 10**9+7
n = int(input())
a, b, c, p = 1, 1, n, n-1
for i in range(n-1):
p = (p+a-1) % mod
a, b, c = b, c, ((n-1)*(n-1)+p+c) % mod
print(c)
main()
```
| 88,247 |
Provide a correct Python 3 solution for this coding contest problem.
How many infinite sequences a_1, a_2, ... consisting of {{1, ... ,n}} satisfy the following conditions?
* The n-th and subsequent elements are all equal. That is, if n \leq i,j, a_i = a_j.
* For every integer i, the a_i elements immediately following the i-th element are all equal. That is, if i < j < k\leq i+a_i, a_j = a_k.
Find the count modulo 10^9+7.
Constraints
* 1 \leq n \leq 10^6
Input
Input is given from Standard Input in the following format:
n
Output
Print how many sequences satisfy the conditions, modulo 10^9+7.
Examples
Input
2
Output
4
Input
654321
Output
968545283
"Correct Solution:
```
P = 10 ** 9 + 7
N = int(input())
k = (N-1) ** 2 % P + 2
a, b, c = 1, 0, 0
ans = 0
for i in range(N-1):
ans += a * (k + min(i, N-3))
ans %= P
a, b, c = a + b, b + c, a
if a >= P: a -= P
if b >= P: b -= P
ans += N * a
ans %= P
print(ans)
```
| 88,248 |
Provide a correct Python 3 solution for this coding contest problem.
How many infinite sequences a_1, a_2, ... consisting of {{1, ... ,n}} satisfy the following conditions?
* The n-th and subsequent elements are all equal. That is, if n \leq i,j, a_i = a_j.
* For every integer i, the a_i elements immediately following the i-th element are all equal. That is, if i < j < k\leq i+a_i, a_j = a_k.
Find the count modulo 10^9+7.
Constraints
* 1 \leq n \leq 10^6
Input
Input is given from Standard Input in the following format:
n
Output
Print how many sequences satisfy the conditions, modulo 10^9+7.
Examples
Input
2
Output
4
Input
654321
Output
968545283
"Correct Solution:
```
N=int(input())
mod=10**9+7
DP=[0]*(N*2+5)
X=[0]*(N*2+5)
Y=[0]*(N*2+5)
C=0
Y[0]=-1
for i in range(N):
C=(C+X[i])%mod
DP[i]=(C-Y[i])%mod
Y[i+2]=DP[i]
X[i+1]=(X[i+1]+DP[i])%mod
X[i+N+2]=(X[i+N+2]-DP[i])%mod
for i in range(N,N*2+2):
C=(C+X[i])%mod
DP[i]=(C-Y[i])%mod
P=sum(DP[N:])
for i in range(N-1):
P=(P+DP[i]*(N-1)*(N-1))%mod
print(P)
```
| 88,249 |
Provide a correct Python 3 solution for this coding contest problem.
How many infinite sequences a_1, a_2, ... consisting of {{1, ... ,n}} satisfy the following conditions?
* The n-th and subsequent elements are all equal. That is, if n \leq i,j, a_i = a_j.
* For every integer i, the a_i elements immediately following the i-th element are all equal. That is, if i < j < k\leq i+a_i, a_j = a_k.
Find the count modulo 10^9+7.
Constraints
* 1 \leq n \leq 10^6
Input
Input is given from Standard Input in the following format:
n
Output
Print how many sequences satisfy the conditions, modulo 10^9+7.
Examples
Input
2
Output
4
Input
654321
Output
968545283
"Correct Solution:
```
n = int(input())
dp = [0] * (n+1)
mod = 10**9+7
dp[0] = n
dp[1] = n*n
SUM = n+n*n
for i in range(2,n):
dp[i] = (n-1)*(n-1) + n-i+1+SUM-dp[i-2]
dp[i] %= mod
SUM += dp[i]
SUM %= mod
print(dp[n-1])
```
| 88,250 |
Provide a correct Python 3 solution for this coding contest problem.
How many infinite sequences a_1, a_2, ... consisting of {{1, ... ,n}} satisfy the following conditions?
* The n-th and subsequent elements are all equal. That is, if n \leq i,j, a_i = a_j.
* For every integer i, the a_i elements immediately following the i-th element are all equal. That is, if i < j < k\leq i+a_i, a_j = a_k.
Find the count modulo 10^9+7.
Constraints
* 1 \leq n \leq 10^6
Input
Input is given from Standard Input in the following format:
n
Output
Print how many sequences satisfy the conditions, modulo 10^9+7.
Examples
Input
2
Output
4
Input
654321
Output
968545283
"Correct Solution:
```
MOD = 10 ** 9 + 7
n = int(input())
if n == 1:
print(1)
exit()
dp = [0] * (n)
dp[0] = 1
dp[1] = 1
dpsum = 2
for l in range(2, n):
dp[l] = dpsum
dp[l] -= dp[l-2]
dp[l] %= MOD
dpsum += dp[l]
dpsum %= MOD
ans = 1 + (dpsum - dp[-1]) * (n-1) # end with "1..."
ans %= MOD
for l in range(n-1):
ans += dp[l] * (n - 1) ** 2
ans %= MOD
ans += dp[n-1] * (n - 1)
ans %= MOD
print(ans)
```
| 88,251 |
Provide a correct Python 3 solution for this coding contest problem.
How many infinite sequences a_1, a_2, ... consisting of {{1, ... ,n}} satisfy the following conditions?
* The n-th and subsequent elements are all equal. That is, if n \leq i,j, a_i = a_j.
* For every integer i, the a_i elements immediately following the i-th element are all equal. That is, if i < j < k\leq i+a_i, a_j = a_k.
Find the count modulo 10^9+7.
Constraints
* 1 \leq n \leq 10^6
Input
Input is given from Standard Input in the following format:
n
Output
Print how many sequences satisfy the conditions, modulo 10^9+7.
Examples
Input
2
Output
4
Input
654321
Output
968545283
"Correct Solution:
```
import sys
mod = 10**9 + 7
def solve():
n = int(input())
if n == 1:
print(1)
return
dp = [0] * (n + 1)
dp[1] = n % mod
dp[2] = n**2 % mod
acc = [0] * (n + 1)
acc[1] = dp[1] % mod
acc[2] = (dp[1] + dp[2]) % mod
for k in range(3, n + 1):
dp[k] = (dp[k - 1] + (n - 1)**2 + acc[k - 3] + n - k + 2) % mod
acc[k] = (acc[k - 1] + dp[k]) % mod
ans = dp[n]
print(ans)
def debug(x, table):
for name, val in table.items():
if x is val:
print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)
return None
if __name__ == '__main__':
solve()
```
| 88,252 |
Provide a correct Python 3 solution for this coding contest problem.
How many infinite sequences a_1, a_2, ... consisting of {{1, ... ,n}} satisfy the following conditions?
* The n-th and subsequent elements are all equal. That is, if n \leq i,j, a_i = a_j.
* For every integer i, the a_i elements immediately following the i-th element are all equal. That is, if i < j < k\leq i+a_i, a_j = a_k.
Find the count modulo 10^9+7.
Constraints
* 1 \leq n \leq 10^6
Input
Input is given from Standard Input in the following format:
n
Output
Print how many sequences satisfy the conditions, modulo 10^9+7.
Examples
Input
2
Output
4
Input
654321
Output
968545283
"Correct Solution:
```
n = int(input())
if n == 1:
print(1)
else:
res_v = [0]*(n + 1)
res_v_cumsum = [0]*(n + 1)
res_v[0] = 0
res_v[1] = 1
res_v[2] = 1
res_v_cumsum[0] = 0
res_v_cumsum[1] = 1
res_v_cumsum[2] = 2
M = 1000000007
for k in range(3, n):
res_v[k] = (1 + res_v_cumsum[k-1] - res_v[k-2]) % M
res_v_cumsum[k] = (res_v_cumsum[k-1] + res_v[k]) % M
#print(res_v)
print((((res_v_cumsum[n-2] * (((n-1) * (n-1)) % M)) % M) + ((res_v_cumsum[n-1] * (n-1)) % M) + n + (n-1)*(n-1)%M) % M)
```
| 88,253 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
How many infinite sequences a_1, a_2, ... consisting of {{1, ... ,n}} satisfy the following conditions?
* The n-th and subsequent elements are all equal. That is, if n \leq i,j, a_i = a_j.
* For every integer i, the a_i elements immediately following the i-th element are all equal. That is, if i < j < k\leq i+a_i, a_j = a_k.
Find the count modulo 10^9+7.
Constraints
* 1 \leq n \leq 10^6
Input
Input is given from Standard Input in the following format:
n
Output
Print how many sequences satisfy the conditions, modulo 10^9+7.
Examples
Input
2
Output
4
Input
654321
Output
968545283
Submitted Solution:
```
MOD = 10 ** 9 + 7
n = int(input())
"""
dp = [-1] * (n + 1)
dp[0] = 1
def cnt(num):
ans = 0
if num < 0:
return 1
if dp[num] != -1:
return dp[num]
if num == 1:
dp[num] = n
return n
for i in range(n):
if i == 0:
ans += cnt(num - 1)
ans %= MOD
else:
if num - 2 - i < 0:
ans += 1
else:
ans += cnt(num - 2 - i)
ans += n - 1
ans %= MOD
dp[num] = ans
return ans
dp[0] = 1
print(cnt(n))
"""
dq = [0] * (n + 1)
sum_ = [0] * (n + 1)
dq[0] = 1
sum_[0] = 1
for i in range(n):
if i == 0:
dq[i + 1] = n
sum_[i + 1] = sum_[i] + dq[i + 1]
continue
"""
for j in range(n):
if j == 0:
dq[i + 1] += dq[i]
else:
if i - 1 - j < 0:
dq[i + 1] += 1
else:
dq[i + 1] += dq[i - 1 - j]
dq[i + 1] += n - 1
"""
dq[i + 1] += dq[i]
dq[i + 1] += (n - 1) * (n - 1)
dq[i + 1] += sum_[i - 2]
dq[i + 1] += abs(i - n)
dq[i + 1] %= MOD
sum_[i + 1] = sum_[i] + dq[i + 1]
sum_[i + 1] %= MOD
print(dq[-1])
```
Yes
| 88,254 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
How many infinite sequences a_1, a_2, ... consisting of {{1, ... ,n}} satisfy the following conditions?
* The n-th and subsequent elements are all equal. That is, if n \leq i,j, a_i = a_j.
* For every integer i, the a_i elements immediately following the i-th element are all equal. That is, if i < j < k\leq i+a_i, a_j = a_k.
Find the count modulo 10^9+7.
Constraints
* 1 \leq n \leq 10^6
Input
Input is given from Standard Input in the following format:
n
Output
Print how many sequences satisfy the conditions, modulo 10^9+7.
Examples
Input
2
Output
4
Input
654321
Output
968545283
Submitted Solution:
```
# dp[i] := i 項目以降を見たときの場合の数
# = dp[i+1] + (Σ_{3<=d<=N-1} dp[i+d]) + (n-1)**2
# i 項目と i+1 項目について、
# (1) i 項目が 1 の場合
# (2) i 項目が 1 で無く、i+1 項目が 1 の場合
# (3) i 項目も i+1 項目も 1 で無い場合
# で場合分けしてそれぞれを足している
# これを累積和で高速化する
# 初期化がややこしい
N = int(input())
mod = 10**9+7
dp = [0] * N
dp[N-1] = N
dp[N-2] = N*N
c = N * (N+1) + N-1
const = (N-1)**2
for i in range(N-3, -1, -1):
ans = c - dp[i+2] + const
dp[i] = ans
c = (c + ans - 1) % mod
print(dp[0]%mod)
```
Yes
| 88,255 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
How many infinite sequences a_1, a_2, ... consisting of {{1, ... ,n}} satisfy the following conditions?
* The n-th and subsequent elements are all equal. That is, if n \leq i,j, a_i = a_j.
* For every integer i, the a_i elements immediately following the i-th element are all equal. That is, if i < j < k\leq i+a_i, a_j = a_k.
Find the count modulo 10^9+7.
Constraints
* 1 \leq n \leq 10^6
Input
Input is given from Standard Input in the following format:
n
Output
Print how many sequences satisfy the conditions, modulo 10^9+7.
Examples
Input
2
Output
4
Input
654321
Output
968545283
Submitted Solution:
```
n=int(input())
if n==1:
print(1)
exit()
mod=10**9+7
dp=[0]*(n+1)
S=[0]*(n+1)
dp[0]=1
dp[1]=1
dp[2]=1
S[0]=1
for i in range(n):
if i+1>=3:
dp[i+1]=2*dp[i]-dp[i-1]+dp[i-2]
dp[i+1]%=mod
S[i+1]=S[i]+(n-1)*dp[i]
S[i+1]%=mod
ans=S[n]
for i in range(1,n):
ans+=((n-1)**2)*dp[i-1]
ans%=mod
print(ans)
#print(S)
#print(dp)
```
Yes
| 88,256 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
How many infinite sequences a_1, a_2, ... consisting of {{1, ... ,n}} satisfy the following conditions?
* The n-th and subsequent elements are all equal. That is, if n \leq i,j, a_i = a_j.
* For every integer i, the a_i elements immediately following the i-th element are all equal. That is, if i < j < k\leq i+a_i, a_j = a_k.
Find the count modulo 10^9+7.
Constraints
* 1 \leq n \leq 10^6
Input
Input is given from Standard Input in the following format:
n
Output
Print how many sequences satisfy the conditions, modulo 10^9+7.
Examples
Input
2
Output
4
Input
654321
Output
968545283
Submitted Solution:
```
n=int(input());a,b,c,p=1,1,n,n-1
for i in range(n-1):
p+=a-1;a,b,c=b,c,((n-1)**2+p+c)%(10**9+7)
print(c)
```
Yes
| 88,257 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
How many infinite sequences a_1, a_2, ... consisting of {{1, ... ,n}} satisfy the following conditions?
* The n-th and subsequent elements are all equal. That is, if n \leq i,j, a_i = a_j.
* For every integer i, the a_i elements immediately following the i-th element are all equal. That is, if i < j < k\leq i+a_i, a_j = a_k.
Find the count modulo 10^9+7.
Constraints
* 1 \leq n \leq 10^6
Input
Input is given from Standard Input in the following format:
n
Output
Print how many sequences satisfy the conditions, modulo 10^9+7.
Examples
Input
2
Output
4
Input
654321
Output
968545283
Submitted Solution:
```
INF=10**9+7
N=int(input())
a=[0 for i in range(N)]
a[0]=1
for i in range(N):
a[i]=sum(a)%INF
print(a[n]%INF)
```
No
| 88,258 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
How many infinite sequences a_1, a_2, ... consisting of {{1, ... ,n}} satisfy the following conditions?
* The n-th and subsequent elements are all equal. That is, if n \leq i,j, a_i = a_j.
* For every integer i, the a_i elements immediately following the i-th element are all equal. That is, if i < j < k\leq i+a_i, a_j = a_k.
Find the count modulo 10^9+7.
Constraints
* 1 \leq n \leq 10^6
Input
Input is given from Standard Input in the following format:
n
Output
Print how many sequences satisfy the conditions, modulo 10^9+7.
Examples
Input
2
Output
4
Input
654321
Output
968545283
Submitted Solution:
```
import numpy as np
n = int(input())
if n == 1:
print(1)
else:
res_v = np.zeros(n + 1, dtype='int64')
res_v_cumsum = np.zeros(n + 1, dtype='int64')
res_v[0] = 0
res_v[1] = 1
res_v[2] = 1
res_v_cumsum[0] = 0
res_v_cumsum[1] = 1
res_v_cumsum[2] = 2
M = 1000000007
for k in range(3, n):
res_v[k] = (1 + res_v_cumsum[k-1] - res_v[k-2]) % M
res_v_cumsum[k] = (res_v_cumsum[k-1] + res_v[k]) % M
print((((res_v_cumsum[n-2] * (((n-1) * (n-1)) % M)) % M) + ((res_v_cumsum[n-1] * (n-1)) % M) + n + (n-1)*(n-1)%M) % M)
```
No
| 88,259 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
How many infinite sequences a_1, a_2, ... consisting of {{1, ... ,n}} satisfy the following conditions?
* The n-th and subsequent elements are all equal. That is, if n \leq i,j, a_i = a_j.
* For every integer i, the a_i elements immediately following the i-th element are all equal. That is, if i < j < k\leq i+a_i, a_j = a_k.
Find the count modulo 10^9+7.
Constraints
* 1 \leq n \leq 10^6
Input
Input is given from Standard Input in the following format:
n
Output
Print how many sequences satisfy the conditions, modulo 10^9+7.
Examples
Input
2
Output
4
Input
654321
Output
968545283
Submitted Solution:
```
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
from random import *
def readln():
_res = list(map(int,str(input()).split(' ')))
return _res
p = 1000000000 + 7
n = readln()[0]
f = [0 for i in range(0,n+1)]
f[1] = n
f[2] = n * n
s = f[:]
s[2] = f[1] + f[2]
for i in range(3,n+1):
f[i] = f[i-1] + (n - 1) * (n - 1)
f[i] = f[i] + s[i - 3] + (n - i + 2)
f[i] = f[i] % p
s[i] = s[i - 1] + f[i]
s[i] = s[i] % p
print(f[n])
```
No
| 88,260 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
How many infinite sequences a_1, a_2, ... consisting of {{1, ... ,n}} satisfy the following conditions?
* The n-th and subsequent elements are all equal. That is, if n \leq i,j, a_i = a_j.
* For every integer i, the a_i elements immediately following the i-th element are all equal. That is, if i < j < k\leq i+a_i, a_j = a_k.
Find the count modulo 10^9+7.
Constraints
* 1 \leq n \leq 10^6
Input
Input is given from Standard Input in the following format:
n
Output
Print how many sequences satisfy the conditions, modulo 10^9+7.
Examples
Input
2
Output
4
Input
654321
Output
968545283
Submitted Solution:
```
import sys
input = sys.stdin.readline
MOD = 10**9 + 7
N = int(input())
dp = [0] * (N+10)
dp_cum = [0] * (N+10)
dp[1] = N-1; dp_cum[1] = N-1
dp[2] = N-1; dp_cum[2] = 2*(N-1)
for n in range(3,N+1):
dp[n] = dp[n-1] + dp_cum[n-3]
dp_cum[n] = (dp_cum[n-1] + dp[n]) % MOD
answer = sum(dp[1:N])*N + dp[-1] + 1
answer %= MOD
print(answer)
```
No
| 88,261 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Input
The input is given from Standard Input in the following format:
> $N \ Q$ $a_1 \ b_1$ $a_2 \ b_2$ $ : \ : $ $a_Q \ b_Q$
Output
* You have to print $N$ lines.
* The $i$-th line should contain the number of dishes of sushi had eaten for customer $i (1 \le i \le N)$.
Constraints
* $3 \le N, Q \le 100,000$
* $1 \le a_i \le N$
* $1 \le b_i \le 10^{12}$
* Any final results do not exceed $2 \times 10^{13}$.
Subtasks
Subtask 1 [ $60$ points ]
* $N, Q \le 100$
* $b_i = 1$
Subtask 2 [ $400$ points ]
* $N, Q \le 100$
* $b_i \le 10^{12}$
Subtask 3 [ $240$ points ]
* $N, Q \le 100,000$
* $b_i = 1$
Subtask 4 [ $500$ points ]
* There are no additional constraints.
Output
* You have to print $N$ lines.
* The $i$-th line should contain the number of dishes of sushi had eaten for customer $i (1 \le i \le N)$.
Constraints
* $3 \le N, Q \le 100,000$
* $1 \le a_i \le N$
* $1 \le b_i \le 10^{12}$
* Any final results do not exceed $2 \times 10^{13}$.
Subtasks
Subtask 1 [ $60$ points ]
* $N, Q \le 100$
* $b_i = 1$
Subtask 2 [ $400$ points ]
* $N, Q \le 100$
* $b_i \le 10^{12}$
Subtask 3 [ $240$ points ]
* $N, Q \le 100,000$
* $b_i = 1$
Subtask 4 [ $500$ points ]
* There are no additional constraints.
Input
The input is given from Standard Input in the following format:
> $N \ Q$ $a_1 \ b_1$ $a_2 \ b_2$ $ : \ : $ $a_Q \ b_Q$
Examples
Input
9 3
5 11
8 4
4 7
Output
4
4
4
4
2
2
1
1
0
Input
6 6
3 5
6 11
1 6
4 7
5 2
2 5
Output
10
10
5
5
4
2
Input
5 6
1 1
2 1
3 1
1 1
5 1
3 1
Output
2
2
1
1
0
Input
10 10
10 10
9 20
8 30
7 40
6 50
5 60
4 70
3 80
2 90
1 100
Output
223
123
77
50
33
21
12
7
3
1
Submitted Solution:
```
import sys
import numpy as np
import numba
from numba import njit
i8 = numba.int64
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
@njit((i8[:], ), cache=True)
def build(raw_data):
bit = raw_data.copy()
for i in range(len(bit)):
j = i + (i & (-i))
if j < len(bit):
bit[j] += bit[i]
return bit
@njit((i8[:], i8), cache=True)
def get_sum(bit, i):
s = 0
while i:
s += bit[i]
i -= i & -i
return s
@njit((i8[:], i8, i8), cache=True)
def add(bit, i, x):
while i < len(bit):
bit[i] += x
i += i & -i
@njit((i8[:], i8), cache=True)
def find_kth_element(bit, k):
N = len(bit)
x, sx = 0, 0
dx = 1
while 2 * dx < N:
dx *= 2
while dx:
y = x + dx
if y < N:
sy = sx + bit[y]
if sy < k:
x, sx = y, sy
dx //= 2
return x + 1
@njit((i8, i8[:]), cache=True)
def main(N, AB):
A, B = AB[::2], AB[1::2]
Q = len(A)
bit = np.zeros(N + 1, np.int64) # 長方形の右上になる x 座標集合を管理
bit_raw = np.zeros(N + 1, np.int64)
H = np.zeros(N + 1, np.int64) # 長方形の高さを管理
H[0] = 10**13 + 10
bit_raw[N] = 1
add(bit, N, 1)
for i in range(Q):
a, b = A[i], B[i]
n = get_sum(bit, a - 1)
h = H[find_kth_element(bit, 1 + n)]
if not bit_raw[a]:
bit_raw[a] = 1
add(bit, a, 1)
H[a] = h
r = a
while b:
l = 0 if n == 0 else find_kth_element(bit, n)
n -= 1
area = (H[l] - H[r]) * (r - l)
if area <= b:
b -= area
if l:
bit_raw[l] = 0
add(bit, l, -1)
H[l], H[r] = 0, H[l]
continue
k = b // (r - l)
b -= k * (r - l)
H[r] += k
if b:
m = l + b
bit_raw[m] = 1
add(bit, m, 1)
H[m] = H[r] + 1
b = 0
for n in range(N, 0, -1):
H[n - 1] = max(H[n - 1], H[n])
return H[1:N + 1]
N, Q = map(int, readline().split())
AB = np.array(read().split(), np.int64)
ans = main(N, AB)
print('\n'.join(map(str, ans.tolist())))
```
No
| 88,262 |
Provide a correct Python 3 solution for this coding contest problem.
Your task is to write a program which reads a date (from 2004/1/1 to 2004/12/31) and prints the day of the date. Jan. 1, 2004, is Thursday. Note that 2004 is a leap year and we have Feb. 29.
Input
The input is a sequence of datasets. The end of the input is indicated by a line containing one zero. Each dataset consists of two integers m and d separated by a single space in a line. These integers respectively represent the month and the day.
The number of datasets is less than or equal to 50.
Output
For each dataset, print the day (please see the following words) in a line.
Monday
Tuesday
Wednesday
Thursday
Friday
Saturday
Sunday
Example
Input
1 1
2 29
0 0
Output
Thursday
Sunday
"Correct Solution:
```
# Aizu Problem 0027: What day is today?
#
import sys, math, os, datetime
# read input:
PYDEV = os.environ.get('PYDEV')
if PYDEV=="True":
sys.stdin = open("sample-input.txt", "rt")
DAY = ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"]
while True:
m, d = [int(_) for _ in input().split()]
if m == d == 0:
break
print(DAY[datetime.date(2004, m, d).weekday()])
```
| 88,263 |
Provide a correct Python 3 solution for this coding contest problem.
Your task is to write a program which reads a date (from 2004/1/1 to 2004/12/31) and prints the day of the date. Jan. 1, 2004, is Thursday. Note that 2004 is a leap year and we have Feb. 29.
Input
The input is a sequence of datasets. The end of the input is indicated by a line containing one zero. Each dataset consists of two integers m and d separated by a single space in a line. These integers respectively represent the month and the day.
The number of datasets is less than or equal to 50.
Output
For each dataset, print the day (please see the following words) in a line.
Monday
Tuesday
Wednesday
Thursday
Friday
Saturday
Sunday
Example
Input
1 1
2 29
0 0
Output
Thursday
Sunday
"Correct Solution:
```
from datetime import date
week=["Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"]
while True:
a,b=map(int,input().split())
if a==0:
break
print(week[date(2004,a,b).weekday()])
```
| 88,264 |
Provide a correct Python 3 solution for this coding contest problem.
Your task is to write a program which reads a date (from 2004/1/1 to 2004/12/31) and prints the day of the date. Jan. 1, 2004, is Thursday. Note that 2004 is a leap year and we have Feb. 29.
Input
The input is a sequence of datasets. The end of the input is indicated by a line containing one zero. Each dataset consists of two integers m and d separated by a single space in a line. These integers respectively represent the month and the day.
The number of datasets is less than or equal to 50.
Output
For each dataset, print the day (please see the following words) in a line.
Monday
Tuesday
Wednesday
Thursday
Friday
Saturday
Sunday
Example
Input
1 1
2 29
0 0
Output
Thursday
Sunday
"Correct Solution:
```
# -*- coding:utf-8 -*-
import datetime
def main(a, b):
dt = datetime.datetime(2004, a, b)
week_num = dt.weekday()
if week_num == 0:
print('Monday')
elif week_num == 1:
print('Tuesday')
elif week_num == 2:
print('Wednesday')
elif week_num == 3:
print('Thursday')
elif week_num == 4:
print('Friday')
elif week_num == 5:
print('Saturday')
elif week_num == 6:
print('Sunday')
while True:
a, b = [int(e) for e in input().split()]
if a == 0 and b == 0:
break
main(a, b)
```
| 88,265 |
Provide a correct Python 3 solution for this coding contest problem.
Your task is to write a program which reads a date (from 2004/1/1 to 2004/12/31) and prints the day of the date. Jan. 1, 2004, is Thursday. Note that 2004 is a leap year and we have Feb. 29.
Input
The input is a sequence of datasets. The end of the input is indicated by a line containing one zero. Each dataset consists of two integers m and d separated by a single space in a line. These integers respectively represent the month and the day.
The number of datasets is less than or equal to 50.
Output
For each dataset, print the day (please see the following words) in a line.
Monday
Tuesday
Wednesday
Thursday
Friday
Saturday
Sunday
Example
Input
1 1
2 29
0 0
Output
Thursday
Sunday
"Correct Solution:
```
import datetime
for e in iter(input,'0 0'):print(['Mon','Tues','Wednes','Thurs','Fri','Satur','Sun'][datetime.date(2004,*map(int,e.split())).weekday()]+'day')
```
| 88,266 |
Provide a correct Python 3 solution for this coding contest problem.
Your task is to write a program which reads a date (from 2004/1/1 to 2004/12/31) and prints the day of the date. Jan. 1, 2004, is Thursday. Note that 2004 is a leap year and we have Feb. 29.
Input
The input is a sequence of datasets. The end of the input is indicated by a line containing one zero. Each dataset consists of two integers m and d separated by a single space in a line. These integers respectively represent the month and the day.
The number of datasets is less than or equal to 50.
Output
For each dataset, print the day (please see the following words) in a line.
Monday
Tuesday
Wednesday
Thursday
Friday
Saturday
Sunday
Example
Input
1 1
2 29
0 0
Output
Thursday
Sunday
"Correct Solution:
```
import sys
readline = sys.stdin.readline
write = sys.stdout.write
def convert(y, m, d):
if m <= 2:
m += 12
y -= 1
mjd = int(365.25*y) + (y//400) - (y//100) + int(30.59*(m-2)) + d - 678912
return mjd
youbi = [
"Monday",
"Tuesday",
"Wednesday",
"Thursday",
"Friday",
"Saturday",
"Sunday",
]
def solve():
m, d = map(int, readline().split())
if m == 0:
return False
write("%s\n" % youbi[(convert(2004, m, d) - convert(2004, 1, 1) + 3) % 7])
return True
while solve():
...
```
| 88,267 |
Provide a correct Python 3 solution for this coding contest problem.
Your task is to write a program which reads a date (from 2004/1/1 to 2004/12/31) and prints the day of the date. Jan. 1, 2004, is Thursday. Note that 2004 is a leap year and we have Feb. 29.
Input
The input is a sequence of datasets. The end of the input is indicated by a line containing one zero. Each dataset consists of two integers m and d separated by a single space in a line. These integers respectively represent the month and the day.
The number of datasets is less than or equal to 50.
Output
For each dataset, print the day (please see the following words) in a line.
Monday
Tuesday
Wednesday
Thursday
Friday
Saturday
Sunday
Example
Input
1 1
2 29
0 0
Output
Thursday
Sunday
"Correct Solution:
```
ndays = [31,29,31,30,31,30,31,31,30,31,30,31]
days = ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"]
offset = 3
while(1):
m,d = [int(i) for i in input().split()]
if m == 0 and d == 0:
break
tot_d = sum(ndays[:m-1]) + d
print(days[(tot_d + offset - 1)%7])
```
| 88,268 |
Provide a correct Python 3 solution for this coding contest problem.
Your task is to write a program which reads a date (from 2004/1/1 to 2004/12/31) and prints the day of the date. Jan. 1, 2004, is Thursday. Note that 2004 is a leap year and we have Feb. 29.
Input
The input is a sequence of datasets. The end of the input is indicated by a line containing one zero. Each dataset consists of two integers m and d separated by a single space in a line. These integers respectively represent the month and the day.
The number of datasets is less than or equal to 50.
Output
For each dataset, print the day (please see the following words) in a line.
Monday
Tuesday
Wednesday
Thursday
Friday
Saturday
Sunday
Example
Input
1 1
2 29
0 0
Output
Thursday
Sunday
"Correct Solution:
```
while(True):
m,d = map(int,input().split())
if m==0 and d==0:
break
dn = sum([[31,29,31,30,31,30,31,31,30,31,30,31][a] for a in range(m-1)]) + d-1
print(["Thursday","Friday","Saturday","Sunday","Monday","Tuesday","Wednesday"][dn%7])
```
| 88,269 |
Provide a correct Python 3 solution for this coding contest problem.
Your task is to write a program which reads a date (from 2004/1/1 to 2004/12/31) and prints the day of the date. Jan. 1, 2004, is Thursday. Note that 2004 is a leap year and we have Feb. 29.
Input
The input is a sequence of datasets. The end of the input is indicated by a line containing one zero. Each dataset consists of two integers m and d separated by a single space in a line. These integers respectively represent the month and the day.
The number of datasets is less than or equal to 50.
Output
For each dataset, print the day (please see the following words) in a line.
Monday
Tuesday
Wednesday
Thursday
Friday
Saturday
Sunday
Example
Input
1 1
2 29
0 0
Output
Thursday
Sunday
"Correct Solution:
```
# AOJ 0027 What day is today?
# Python3 2018.6.11 bal4u
def Zeller(y, m, d):
if m == 1 or m == 2:
y -= 1
m += 12
return (y + y//4 - y//100 + y//400 + (13*m + 8)//5 + d) % 7
import sys
week = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]
for line in sys.stdin:
m, d = list(map(int, line.split()))
if m >= 1:
print(week[Zeller(2004, m, d)])
else:
break
```
| 88,270 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Your task is to write a program which reads a date (from 2004/1/1 to 2004/12/31) and prints the day of the date. Jan. 1, 2004, is Thursday. Note that 2004 is a leap year and we have Feb. 29.
Input
The input is a sequence of datasets. The end of the input is indicated by a line containing one zero. Each dataset consists of two integers m and d separated by a single space in a line. These integers respectively represent the month and the day.
The number of datasets is less than or equal to 50.
Output
For each dataset, print the day (please see the following words) in a line.
Monday
Tuesday
Wednesday
Thursday
Friday
Saturday
Sunday
Example
Input
1 1
2 29
0 0
Output
Thursday
Sunday
Submitted Solution:
```
days_in_month = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
day = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday']
while True:
m, d = map(int, input().split())
if m == 0 or d == 0:
break
days = 0
for month in range(0, m-1):
days += days_in_month[month]
days += d + 2
days %= 7
print(day[days])
```
Yes
| 88,271 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Your task is to write a program which reads a date (from 2004/1/1 to 2004/12/31) and prints the day of the date. Jan. 1, 2004, is Thursday. Note that 2004 is a leap year and we have Feb. 29.
Input
The input is a sequence of datasets. The end of the input is indicated by a line containing one zero. Each dataset consists of two integers m and d separated by a single space in a line. These integers respectively represent the month and the day.
The number of datasets is less than or equal to 50.
Output
For each dataset, print the day (please see the following words) in a line.
Monday
Tuesday
Wednesday
Thursday
Friday
Saturday
Sunday
Example
Input
1 1
2 29
0 0
Output
Thursday
Sunday
Submitted Solution:
```
days = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday']
nums = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
while True:
try:
m, d = map(int, input().split())
if not m:
break
except:
break
print(days[(sum(nums[:m - 1]) + d + 2) % 7])
```
Yes
| 88,272 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Your task is to write a program which reads a date (from 2004/1/1 to 2004/12/31) and prints the day of the date. Jan. 1, 2004, is Thursday. Note that 2004 is a leap year and we have Feb. 29.
Input
The input is a sequence of datasets. The end of the input is indicated by a line containing one zero. Each dataset consists of two integers m and d separated by a single space in a line. These integers respectively represent the month and the day.
The number of datasets is less than or equal to 50.
Output
For each dataset, print the day (please see the following words) in a line.
Monday
Tuesday
Wednesday
Thursday
Friday
Saturday
Sunday
Example
Input
1 1
2 29
0 0
Output
Thursday
Sunday
Submitted Solution:
```
import datetime
weekdays = [
'Monday',
'Tuesday',
'Wednesday',
'Thursday',
'Friday',
'Saturday',
'Sunday'
]
while True:
m,d = [int(i) for i in input().split()]
if not(m or d):
break
print(weekdays[datetime.date(2004, m, d).weekday()])
```
Yes
| 88,273 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Your task is to write a program which reads a date (from 2004/1/1 to 2004/12/31) and prints the day of the date. Jan. 1, 2004, is Thursday. Note that 2004 is a leap year and we have Feb. 29.
Input
The input is a sequence of datasets. The end of the input is indicated by a line containing one zero. Each dataset consists of two integers m and d separated by a single space in a line. These integers respectively represent the month and the day.
The number of datasets is less than or equal to 50.
Output
For each dataset, print the day (please see the following words) in a line.
Monday
Tuesday
Wednesday
Thursday
Friday
Saturday
Sunday
Example
Input
1 1
2 29
0 0
Output
Thursday
Sunday
Submitted Solution:
```
day = ['Wednesday','Thursday', 'Friday', 'Saturday', 'Sunday', 'Monday', 'Tuesday', 'Wednesday']
month = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
m, d = [int(i) for i in input().split()]
while m != 0:
sum = 0
for i in range(0, m - 1):
sum += month[i]
sum += d
print(day[sum % 7])
m, d = [int(i) for i in input().split()]
```
Yes
| 88,274 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Your task is to write a program which reads a date (from 2004/1/1 to 2004/12/31) and prints the day of the date. Jan. 1, 2004, is Thursday. Note that 2004 is a leap year and we have Feb. 29.
Input
The input is a sequence of datasets. The end of the input is indicated by a line containing one zero. Each dataset consists of two integers m and d separated by a single space in a line. These integers respectively represent the month and the day.
The number of datasets is less than or equal to 50.
Output
For each dataset, print the day (please see the following words) in a line.
Monday
Tuesday
Wednesday
Thursday
Friday
Saturday
Sunday
Example
Input
1 1
2 29
0 0
Output
Thursday
Sunday
Submitted Solution:
```
days = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday']
nums = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
while True:
try:
m, d = map(int, input().split())
if not m:
break
except:
break
print(days[(sum(nums[:m - 1]) + d) % 7 + 2])
```
No
| 88,275 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Your task is to write a program which reads a date (from 2004/1/1 to 2004/12/31) and prints the day of the date. Jan. 1, 2004, is Thursday. Note that 2004 is a leap year and we have Feb. 29.
Input
The input is a sequence of datasets. The end of the input is indicated by a line containing one zero. Each dataset consists of two integers m and d separated by a single space in a line. These integers respectively represent the month and the day.
The number of datasets is less than or equal to 50.
Output
For each dataset, print the day (please see the following words) in a line.
Monday
Tuesday
Wednesday
Thursday
Friday
Saturday
Sunday
Example
Input
1 1
2 29
0 0
Output
Thursday
Sunday
Submitted Solution:
```
from datetime import date
week=["Monday","Trueday","Wednesday","Thursday","Friday","Saturday","Sunday"]
while True:
a,b=map(int,input().split())
if a==0:
break
print(week[date(2004,a,b).weekday()])
```
No
| 88,276 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Your task is to write a program which reads a date (from 2004/1/1 to 2004/12/31) and prints the day of the date. Jan. 1, 2004, is Thursday. Note that 2004 is a leap year and we have Feb. 29.
Input
The input is a sequence of datasets. The end of the input is indicated by a line containing one zero. Each dataset consists of two integers m and d separated by a single space in a line. These integers respectively represent the month and the day.
The number of datasets is less than or equal to 50.
Output
For each dataset, print the day (please see the following words) in a line.
Monday
Tuesday
Wednesday
Thursday
Friday
Saturday
Sunday
Example
Input
1 1
2 29
0 0
Output
Thursday
Sunday
Submitted Solution:
```
lis=[0 for i in range(7)]
lis[0]="Wednesday"
lis[1]="Thursday"
lis[2]="Friday"
lis[3]="Saturday"
lis[4]="Sunday"
lis[5]="Monday"
lis[6]="Tuesday"
while 1:
date=0
x,y=map(int,input().split())
if x!=0 and y!=0:
for i in range(1,x):
if i==4 or i==6 or i==9 or i==11:
date=date+30
elif i==2:
date =date+29
else:
date=date+31
print(date)
k=(date+y)%7
print(date+y)
print(lis[k])
else:
break
```
No
| 88,277 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Your task is to write a program which reads a date (from 2004/1/1 to 2004/12/31) and prints the day of the date. Jan. 1, 2004, is Thursday. Note that 2004 is a leap year and we have Feb. 29.
Input
The input is a sequence of datasets. The end of the input is indicated by a line containing one zero. Each dataset consists of two integers m and d separated by a single space in a line. These integers respectively represent the month and the day.
The number of datasets is less than or equal to 50.
Output
For each dataset, print the day (please see the following words) in a line.
Monday
Tuesday
Wednesday
Thursday
Friday
Saturday
Sunday
Example
Input
1 1
2 29
0 0
Output
Thursday
Sunday
Submitted Solution:
```
week = {1: "Thursday", 2: "Friday", 3: "Saturday", 4: "Sunday", 5: "Monday", 6: "Tuesday", 7: "Wednesday"}
month = {1: 0, 2: 31, 3: 60, 4: 91, 5: 121, 6: 152, 7: 182, 8: 213, 9: 244, 10: 274, 11: 305, 12: 335}
m, d = map(int, input().split())
while m:
days = month[m] + d
print(week[days % 7])
m, d = map(int, input().split())
```
No
| 88,278 |
Provide a correct Python 3 solution for this coding contest problem.
For a positive integer n
* If n is even, divide by 2.
* If n is odd, multiply by 3 and add 1.
If you repeat the above operation, the result will be 1. A problem called "Colatz conjecture" is that repeating this operation for any positive integer n will always result in 1. This problem is an unsolved problem, also known as the "Kakutani problem" in Japan. It is known that there is no counterexample for a very large number 3 × 253 = 27,021,597,764,222,976 using a computer, but it has not been mathematically proven.
Create a program that takes the integer n as an input and outputs the number of operations that are repeated until the result is 1. The integer n should be an integer that is 1 or more and the value in the middle of repeating the above calculation is 1000000 or less. For example, if you receive 3 as input, the operation column will be
3 → 10 → 5 → 16 → 8 → 4 → 2 → 1
Therefore, 7 is output, which is the number of operations (the number of arrows above).
Input
A sequence of multiple datasets is given as input. The end of the input is indicated by a single line of zeros. One integer n (n ≤ 1000000) is given on one row for each dataset.
The number of datasets does not exceed 50.
Output
Outputs the number of operations for each dataset on one line.
Example
Input
3
10
0
Output
7
6
"Correct Solution:
```
import sys
import math
def koratsu(n,i):
if(n==1):
return i
elif(n%2==0):
n=n//2
i=i+1
return koratsu(n,i)
else:
n=3*n+1
i=i+1
return koratsu(n,i)
i=0
while i<50:
n=int(input())
if(n==0):
break
kaisu=koratsu(n,i)
print(str(kaisu))
```
| 88,279 |
Provide a correct Python 3 solution for this coding contest problem.
For a positive integer n
* If n is even, divide by 2.
* If n is odd, multiply by 3 and add 1.
If you repeat the above operation, the result will be 1. A problem called "Colatz conjecture" is that repeating this operation for any positive integer n will always result in 1. This problem is an unsolved problem, also known as the "Kakutani problem" in Japan. It is known that there is no counterexample for a very large number 3 × 253 = 27,021,597,764,222,976 using a computer, but it has not been mathematically proven.
Create a program that takes the integer n as an input and outputs the number of operations that are repeated until the result is 1. The integer n should be an integer that is 1 or more and the value in the middle of repeating the above calculation is 1000000 or less. For example, if you receive 3 as input, the operation column will be
3 → 10 → 5 → 16 → 8 → 4 → 2 → 1
Therefore, 7 is output, which is the number of operations (the number of arrows above).
Input
A sequence of multiple datasets is given as input. The end of the input is indicated by a single line of zeros. One integer n (n ≤ 1000000) is given on one row for each dataset.
The number of datasets does not exceed 50.
Output
Outputs the number of operations for each dataset on one line.
Example
Input
3
10
0
Output
7
6
"Correct Solution:
```
while True:
n = int(input());
if n == 0:
break;
i = 0;
while n != 1:
i += 1;
if n % 2 == 0:
n = n / 2;
else:
n = n * 3 + 1;
print(i);
```
| 88,280 |
Provide a correct Python 3 solution for this coding contest problem.
For a positive integer n
* If n is even, divide by 2.
* If n is odd, multiply by 3 and add 1.
If you repeat the above operation, the result will be 1. A problem called "Colatz conjecture" is that repeating this operation for any positive integer n will always result in 1. This problem is an unsolved problem, also known as the "Kakutani problem" in Japan. It is known that there is no counterexample for a very large number 3 × 253 = 27,021,597,764,222,976 using a computer, but it has not been mathematically proven.
Create a program that takes the integer n as an input and outputs the number of operations that are repeated until the result is 1. The integer n should be an integer that is 1 or more and the value in the middle of repeating the above calculation is 1000000 or less. For example, if you receive 3 as input, the operation column will be
3 → 10 → 5 → 16 → 8 → 4 → 2 → 1
Therefore, 7 is output, which is the number of operations (the number of arrows above).
Input
A sequence of multiple datasets is given as input. The end of the input is indicated by a single line of zeros. One integer n (n ≤ 1000000) is given on one row for each dataset.
The number of datasets does not exceed 50.
Output
Outputs the number of operations for each dataset on one line.
Example
Input
3
10
0
Output
7
6
"Correct Solution:
```
while True:
n=int(input())
s=0
if n==0:
break
while n!=1:
if n!=0:
if n%2==0:
n=n/2
s+=1
else:
n=n*3+1
s+=1
print(s)
```
| 88,281 |
Provide a correct Python 3 solution for this coding contest problem.
For a positive integer n
* If n is even, divide by 2.
* If n is odd, multiply by 3 and add 1.
If you repeat the above operation, the result will be 1. A problem called "Colatz conjecture" is that repeating this operation for any positive integer n will always result in 1. This problem is an unsolved problem, also known as the "Kakutani problem" in Japan. It is known that there is no counterexample for a very large number 3 × 253 = 27,021,597,764,222,976 using a computer, but it has not been mathematically proven.
Create a program that takes the integer n as an input and outputs the number of operations that are repeated until the result is 1. The integer n should be an integer that is 1 or more and the value in the middle of repeating the above calculation is 1000000 or less. For example, if you receive 3 as input, the operation column will be
3 → 10 → 5 → 16 → 8 → 4 → 2 → 1
Therefore, 7 is output, which is the number of operations (the number of arrows above).
Input
A sequence of multiple datasets is given as input. The end of the input is indicated by a single line of zeros. One integer n (n ≤ 1000000) is given on one row for each dataset.
The number of datasets does not exceed 50.
Output
Outputs the number of operations for each dataset on one line.
Example
Input
3
10
0
Output
7
6
"Correct Solution:
```
while True:
num = int(input())
if num == 0:
break
count = 0
while num != 1:
if num % 2 == 0:
num >>= 1
count += 1
else:
num += num // 2 + 1
count += 2
print(count)
```
| 88,282 |
Provide a correct Python 3 solution for this coding contest problem.
For a positive integer n
* If n is even, divide by 2.
* If n is odd, multiply by 3 and add 1.
If you repeat the above operation, the result will be 1. A problem called "Colatz conjecture" is that repeating this operation for any positive integer n will always result in 1. This problem is an unsolved problem, also known as the "Kakutani problem" in Japan. It is known that there is no counterexample for a very large number 3 × 253 = 27,021,597,764,222,976 using a computer, but it has not been mathematically proven.
Create a program that takes the integer n as an input and outputs the number of operations that are repeated until the result is 1. The integer n should be an integer that is 1 or more and the value in the middle of repeating the above calculation is 1000000 or less. For example, if you receive 3 as input, the operation column will be
3 → 10 → 5 → 16 → 8 → 4 → 2 → 1
Therefore, 7 is output, which is the number of operations (the number of arrows above).
Input
A sequence of multiple datasets is given as input. The end of the input is indicated by a single line of zeros. One integer n (n ≤ 1000000) is given on one row for each dataset.
The number of datasets does not exceed 50.
Output
Outputs the number of operations for each dataset on one line.
Example
Input
3
10
0
Output
7
6
"Correct Solution:
```
while True:
n = int(input())
if n == 0:
break
cnt = 0
while n != 1:
n = 3*n+1 if n % 2 else n//2
cnt += 1
print(cnt)
```
| 88,283 |
Provide a correct Python 3 solution for this coding contest problem.
For a positive integer n
* If n is even, divide by 2.
* If n is odd, multiply by 3 and add 1.
If you repeat the above operation, the result will be 1. A problem called "Colatz conjecture" is that repeating this operation for any positive integer n will always result in 1. This problem is an unsolved problem, also known as the "Kakutani problem" in Japan. It is known that there is no counterexample for a very large number 3 × 253 = 27,021,597,764,222,976 using a computer, but it has not been mathematically proven.
Create a program that takes the integer n as an input and outputs the number of operations that are repeated until the result is 1. The integer n should be an integer that is 1 or more and the value in the middle of repeating the above calculation is 1000000 or less. For example, if you receive 3 as input, the operation column will be
3 → 10 → 5 → 16 → 8 → 4 → 2 → 1
Therefore, 7 is output, which is the number of operations (the number of arrows above).
Input
A sequence of multiple datasets is given as input. The end of the input is indicated by a single line of zeros. One integer n (n ≤ 1000000) is given on one row for each dataset.
The number of datasets does not exceed 50.
Output
Outputs the number of operations for each dataset on one line.
Example
Input
3
10
0
Output
7
6
"Correct Solution:
```
while True:
x = int(input())
if x == 0:
break
c=0
while True:
if x==1:
break
elif x%2==0:
x = x//2
else:
x = x*3 +1
c += 1
print(c)
```
| 88,284 |
Provide a correct Python 3 solution for this coding contest problem.
For a positive integer n
* If n is even, divide by 2.
* If n is odd, multiply by 3 and add 1.
If you repeat the above operation, the result will be 1. A problem called "Colatz conjecture" is that repeating this operation for any positive integer n will always result in 1. This problem is an unsolved problem, also known as the "Kakutani problem" in Japan. It is known that there is no counterexample for a very large number 3 × 253 = 27,021,597,764,222,976 using a computer, but it has not been mathematically proven.
Create a program that takes the integer n as an input and outputs the number of operations that are repeated until the result is 1. The integer n should be an integer that is 1 or more and the value in the middle of repeating the above calculation is 1000000 or less. For example, if you receive 3 as input, the operation column will be
3 → 10 → 5 → 16 → 8 → 4 → 2 → 1
Therefore, 7 is output, which is the number of operations (the number of arrows above).
Input
A sequence of multiple datasets is given as input. The end of the input is indicated by a single line of zeros. One integer n (n ≤ 1000000) is given on one row for each dataset.
The number of datasets does not exceed 50.
Output
Outputs the number of operations for each dataset on one line.
Example
Input
3
10
0
Output
7
6
"Correct Solution:
```
while True:
n=int(input())
if n==0:
break
else:
a=0
while True:
if n==1:
print(a)
break
elif n%2==0:
n/=2
a+=1
else:
n*=3
n+=1
a+=1
```
| 88,285 |
Provide a correct Python 3 solution for this coding contest problem.
For a positive integer n
* If n is even, divide by 2.
* If n is odd, multiply by 3 and add 1.
If you repeat the above operation, the result will be 1. A problem called "Colatz conjecture" is that repeating this operation for any positive integer n will always result in 1. This problem is an unsolved problem, also known as the "Kakutani problem" in Japan. It is known that there is no counterexample for a very large number 3 × 253 = 27,021,597,764,222,976 using a computer, but it has not been mathematically proven.
Create a program that takes the integer n as an input and outputs the number of operations that are repeated until the result is 1. The integer n should be an integer that is 1 or more and the value in the middle of repeating the above calculation is 1000000 or less. For example, if you receive 3 as input, the operation column will be
3 → 10 → 5 → 16 → 8 → 4 → 2 → 1
Therefore, 7 is output, which is the number of operations (the number of arrows above).
Input
A sequence of multiple datasets is given as input. The end of the input is indicated by a single line of zeros. One integer n (n ≤ 1000000) is given on one row for each dataset.
The number of datasets does not exceed 50.
Output
Outputs the number of operations for each dataset on one line.
Example
Input
3
10
0
Output
7
6
"Correct Solution:
```
for i in range(50):
n = int(input())
if n == 0: break
i = 0
while 1:
if n == 1: break
if n % 2 == 0:
n = n / 2
else:
n = n*3 + 1
i += 1
print(i)
```
| 88,286 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
For a positive integer n
* If n is even, divide by 2.
* If n is odd, multiply by 3 and add 1.
If you repeat the above operation, the result will be 1. A problem called "Colatz conjecture" is that repeating this operation for any positive integer n will always result in 1. This problem is an unsolved problem, also known as the "Kakutani problem" in Japan. It is known that there is no counterexample for a very large number 3 × 253 = 27,021,597,764,222,976 using a computer, but it has not been mathematically proven.
Create a program that takes the integer n as an input and outputs the number of operations that are repeated until the result is 1. The integer n should be an integer that is 1 or more and the value in the middle of repeating the above calculation is 1000000 or less. For example, if you receive 3 as input, the operation column will be
3 → 10 → 5 → 16 → 8 → 4 → 2 → 1
Therefore, 7 is output, which is the number of operations (the number of arrows above).
Input
A sequence of multiple datasets is given as input. The end of the input is indicated by a single line of zeros. One integer n (n ≤ 1000000) is given on one row for each dataset.
The number of datasets does not exceed 50.
Output
Outputs the number of operations for each dataset on one line.
Example
Input
3
10
0
Output
7
6
Submitted Solution:
```
while True:
a = int(input())
if a == 0:
break
c = 0
while a != 1:
c += 1
if a %2:
a = 3 * a +1
else:
a = a//2
print(c)
```
Yes
| 88,287 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
For a positive integer n
* If n is even, divide by 2.
* If n is odd, multiply by 3 and add 1.
If you repeat the above operation, the result will be 1. A problem called "Colatz conjecture" is that repeating this operation for any positive integer n will always result in 1. This problem is an unsolved problem, also known as the "Kakutani problem" in Japan. It is known that there is no counterexample for a very large number 3 × 253 = 27,021,597,764,222,976 using a computer, but it has not been mathematically proven.
Create a program that takes the integer n as an input and outputs the number of operations that are repeated until the result is 1. The integer n should be an integer that is 1 or more and the value in the middle of repeating the above calculation is 1000000 or less. For example, if you receive 3 as input, the operation column will be
3 → 10 → 5 → 16 → 8 → 4 → 2 → 1
Therefore, 7 is output, which is the number of operations (the number of arrows above).
Input
A sequence of multiple datasets is given as input. The end of the input is indicated by a single line of zeros. One integer n (n ≤ 1000000) is given on one row for each dataset.
The number of datasets does not exceed 50.
Output
Outputs the number of operations for each dataset on one line.
Example
Input
3
10
0
Output
7
6
Submitted Solution:
```
while True:
n = int(input())
if n == 0: break
k = 0
while n > 1:
if n & 1:
n = n + ((n+1)>>1)
k += 2
else:
n >>= 1
k += 1
print(k)
```
Yes
| 88,288 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
For a positive integer n
* If n is even, divide by 2.
* If n is odd, multiply by 3 and add 1.
If you repeat the above operation, the result will be 1. A problem called "Colatz conjecture" is that repeating this operation for any positive integer n will always result in 1. This problem is an unsolved problem, also known as the "Kakutani problem" in Japan. It is known that there is no counterexample for a very large number 3 × 253 = 27,021,597,764,222,976 using a computer, but it has not been mathematically proven.
Create a program that takes the integer n as an input and outputs the number of operations that are repeated until the result is 1. The integer n should be an integer that is 1 or more and the value in the middle of repeating the above calculation is 1000000 or less. For example, if you receive 3 as input, the operation column will be
3 → 10 → 5 → 16 → 8 → 4 → 2 → 1
Therefore, 7 is output, which is the number of operations (the number of arrows above).
Input
A sequence of multiple datasets is given as input. The end of the input is indicated by a single line of zeros. One integer n (n ≤ 1000000) is given on one row for each dataset.
The number of datasets does not exceed 50.
Output
Outputs the number of operations for each dataset on one line.
Example
Input
3
10
0
Output
7
6
Submitted Solution:
```
while 1:
n = int(input())
if n == 0:
break
cnt = 0
while n != 1:
if n % 2 == 0:
n //= 2
else:
n = n * 3 + 1
cnt += 1
print(cnt)
```
Yes
| 88,289 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
For a positive integer n
* If n is even, divide by 2.
* If n is odd, multiply by 3 and add 1.
If you repeat the above operation, the result will be 1. A problem called "Colatz conjecture" is that repeating this operation for any positive integer n will always result in 1. This problem is an unsolved problem, also known as the "Kakutani problem" in Japan. It is known that there is no counterexample for a very large number 3 × 253 = 27,021,597,764,222,976 using a computer, but it has not been mathematically proven.
Create a program that takes the integer n as an input and outputs the number of operations that are repeated until the result is 1. The integer n should be an integer that is 1 or more and the value in the middle of repeating the above calculation is 1000000 or less. For example, if you receive 3 as input, the operation column will be
3 → 10 → 5 → 16 → 8 → 4 → 2 → 1
Therefore, 7 is output, which is the number of operations (the number of arrows above).
Input
A sequence of multiple datasets is given as input. The end of the input is indicated by a single line of zeros. One integer n (n ≤ 1000000) is given on one row for each dataset.
The number of datasets does not exceed 50.
Output
Outputs the number of operations for each dataset on one line.
Example
Input
3
10
0
Output
7
6
Submitted Solution:
```
while True:
n = int(input())
ans = 0
if n == 0:
break
while n > 1:
ans += 1
if n % 2 == 0:
n = n/2
else:
n = 3 * n + 1
print(ans)
```
Yes
| 88,290 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
For a positive integer n
* If n is even, divide by 2.
* If n is odd, multiply by 3 and add 1.
If you repeat the above operation, the result will be 1. A problem called "Colatz conjecture" is that repeating this operation for any positive integer n will always result in 1. This problem is an unsolved problem, also known as the "Kakutani problem" in Japan. It is known that there is no counterexample for a very large number 3 × 253 = 27,021,597,764,222,976 using a computer, but it has not been mathematically proven.
Create a program that takes the integer n as an input and outputs the number of operations that are repeated until the result is 1. The integer n should be an integer that is 1 or more and the value in the middle of repeating the above calculation is 1000000 or less. For example, if you receive 3 as input, the operation column will be
3 → 10 → 5 → 16 → 8 → 4 → 2 → 1
Therefore, 7 is output, which is the number of operations (the number of arrows above).
Input
A sequence of multiple datasets is given as input. The end of the input is indicated by a single line of zeros. One integer n (n ≤ 1000000) is given on one row for each dataset.
The number of datasets does not exceed 50.
Output
Outputs the number of operations for each dataset on one line.
Example
Input
3
10
0
Output
7
6
Submitted Solution:
```
def f(n, t):
if n % 2 == 0:
n = int(n / 2)
else:
n = n * 3 + 1
t += 1
if n == 1:
return t
else:
return f(n, t)
while True:
_n = int(input())
if _n == 0:
break
print(_n if _n == 1 else f(_n, 0))
```
No
| 88,291 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
For a positive integer n
* If n is even, divide by 2.
* If n is odd, multiply by 3 and add 1.
If you repeat the above operation, the result will be 1. A problem called "Colatz conjecture" is that repeating this operation for any positive integer n will always result in 1. This problem is an unsolved problem, also known as the "Kakutani problem" in Japan. It is known that there is no counterexample for a very large number 3 × 253 = 27,021,597,764,222,976 using a computer, but it has not been mathematically proven.
Create a program that takes the integer n as an input and outputs the number of operations that are repeated until the result is 1. The integer n should be an integer that is 1 or more and the value in the middle of repeating the above calculation is 1000000 or less. For example, if you receive 3 as input, the operation column will be
3 → 10 → 5 → 16 → 8 → 4 → 2 → 1
Therefore, 7 is output, which is the number of operations (the number of arrows above).
Input
A sequence of multiple datasets is given as input. The end of the input is indicated by a single line of zeros. One integer n (n ≤ 1000000) is given on one row for each dataset.
The number of datasets does not exceed 50.
Output
Outputs the number of operations for each dataset on one line.
Example
Input
3
10
0
Output
7
6
Submitted Solution:
```
def f(n, t):
if n % 2 == 0:
n = int(n / 2)
else:
n = n * 3 + 1
t += 1
if n == 1:
return t
else:
return f(n, t)
while True:
_n = int(input())
if _n == 0:
break
print(f(_n, 0))
```
No
| 88,292 |
Provide a correct Python 3 solution for this coding contest problem.
The cloth coasters produced and sold by Aizu Takada City are known for their symmetrical design and great beauty. As part of quality control, Aizu Takada City has installed cameras on the production line to automatically verify that the images obtained by shooting each coaster are symmetrical. Each coaster is represented as a square black and white image of N x N pixels. Each pixel has a value of 0 or 1 corresponding to a white or black image.
This time, the software of the image analysis system will be updated along with the equipment update of the production line. The new system has been devised to reduce the amount of communication data, and data is sent from the camera to the analysis system by the following method.
* The information of the first coaster flowing on the line is sent to the system as an N × N pixel image.
* For the coaster information on the second and subsequent images, only the difference from the previous image is sent. The difference is given as a set of pixel positions that change from "0 to 1" or "1 to 0".
For C coasters, enter the pixel information of the first image and the difference information of the following C-1 image, and create a program that reports the number of coasters that are vertically symmetrical and symmetrical.
Input
The input is given in the following format.
C N
p11p12 ... p1N
p21p22 ... p2N
::
pN1pN2 ... pNN
diff1
diff2
::
diffC-1
The first line gives the number of coasters C (1 ≤ C ≤ 10000) and the number of pixels N (2 ≤ N ≤ 1000 and N is even) in the vertical and horizontal directions of the image. Lines 2 to N + 1 are given the number pij (pij is 0 or 1) in rows N x columns N representing the pixels of the image of the first coaster.
After the N + 2nd line, the difference diffi representing the information of the 2nd and subsequent coasters is given in the following format.
D
r1 c1
r2 c2
::
rD cD
The number of changed pixels D (0 ≤ D ≤ 100) is given in the first line. The following D rows are given ri and ci (1 ≤ ri, ci ≤ N), which represent the row and column numbers of the changed pixels, respectively. The same position cannot be given more than once in diffi.
Output
The number of coasters that are vertically symmetrical and symmetrical is output on one line.
Examples
Input
7 8
00100000
00011000
10111101
01100110
01000110
10111101
00011000
00100100
2
5 3
1 6
1
6 8
3
6 8
3 3
3 6
2
6 3
6 6
0
2
3 8
6 8
Output
3
Input
1 6
000000
000000
010010
010010
000000
000000
Output
1
Input
2 2
00
00
4
1 1
1 2
2 1
2 2
Output
2
"Correct Solution:
```
def main():
C, n = map(int, input().split())
mp = [input() for _ in range(n)]
diff_dic = {}
def change(x, y):
if (x, y) in diff_dic:
diff_dic.pop((x, y))
else:
diff_dic[(x, y)] = True
for y in range(n // 2):
for x in range(n // 2):
base = mp[y][x]
if mp[y][n - 1 - x] != base:
change(n - 1 - x, y)
if mp[n - 1 - y][x] != base:
change(x, n - 1 - y)
if mp[n - 1 - y][n - 1 - x] != base:
change(n - 1 - x, n - 1 - y)
if n % 2:
for x in range(n // 2):
if mp[n // 2][x] != mp[n // 2][n - 1 - x]:
chenge(n - 1 - x, n // 2)
for y in range(n // 2):
if mp[y][n // 2] != mp[n - 1 - y][n // 2]:
change(n // 2, n - 1 - y)
ans = 0
if not diff_dic:
ans += 1
for _ in range(C - 1):
d = int(input())
for _ in range(d):
r, c = map(int, input().split())
r -= 1
c -= 1
if r < n // 2 and c < n // 2:
change(c, n - 1 - r)
change(n - 1 - c, r)
change(n - 1 - c, n - 1 - r)
elif n % 2 and r == n // 2 and c != n // 2:
change(max(c, n - 1 - c), r)
elif n % 2 and r != n // 2 and c == n // 2:
change(c, max(r, n - 1 - r))
else:
change(c, r)
if not diff_dic:
ans += 1
print(ans)
main()
```
| 88,293 |
Provide a correct Python 3 solution for this coding contest problem.
The cloth coasters produced and sold by Aizu Takada City are known for their symmetrical design and great beauty. As part of quality control, Aizu Takada City has installed cameras on the production line to automatically verify that the images obtained by shooting each coaster are symmetrical. Each coaster is represented as a square black and white image of N x N pixels. Each pixel has a value of 0 or 1 corresponding to a white or black image.
This time, the software of the image analysis system will be updated along with the equipment update of the production line. The new system has been devised to reduce the amount of communication data, and data is sent from the camera to the analysis system by the following method.
* The information of the first coaster flowing on the line is sent to the system as an N × N pixel image.
* For the coaster information on the second and subsequent images, only the difference from the previous image is sent. The difference is given as a set of pixel positions that change from "0 to 1" or "1 to 0".
For C coasters, enter the pixel information of the first image and the difference information of the following C-1 image, and create a program that reports the number of coasters that are vertically symmetrical and symmetrical.
Input
The input is given in the following format.
C N
p11p12 ... p1N
p21p22 ... p2N
::
pN1pN2 ... pNN
diff1
diff2
::
diffC-1
The first line gives the number of coasters C (1 ≤ C ≤ 10000) and the number of pixels N (2 ≤ N ≤ 1000 and N is even) in the vertical and horizontal directions of the image. Lines 2 to N + 1 are given the number pij (pij is 0 or 1) in rows N x columns N representing the pixels of the image of the first coaster.
After the N + 2nd line, the difference diffi representing the information of the 2nd and subsequent coasters is given in the following format.
D
r1 c1
r2 c2
::
rD cD
The number of changed pixels D (0 ≤ D ≤ 100) is given in the first line. The following D rows are given ri and ci (1 ≤ ri, ci ≤ N), which represent the row and column numbers of the changed pixels, respectively. The same position cannot be given more than once in diffi.
Output
The number of coasters that are vertically symmetrical and symmetrical is output on one line.
Examples
Input
7 8
00100000
00011000
10111101
01100110
01000110
10111101
00011000
00100100
2
5 3
1 6
1
6 8
3
6 8
3 3
3 6
2
6 3
6 6
0
2
3 8
6 8
Output
3
Input
1 6
000000
000000
010010
010010
000000
000000
Output
1
Input
2 2
00
00
4
1 1
1 2
2 1
2 2
Output
2
"Correct Solution:
```
c, n = map(int, input().split())
P = [list(map(int, input())) for i in range(n)]
S = [[0]*n for i in range(n)]
T = [[0]*n for i in range(n)]
dS = dT = 0
for i in range(n):
for j in range(n//2):
S[i][j] = P[i][j] ^ P[i][n-1-j]
dS += S[i][j]
for j in range(n):
for i in range(n//2):
T[i][j] = P[i][j] ^ P[n-1-i][j]
dT += T[i][j]
ans = +(dS == dT == 0)
for i in range(c-1):
d = int(input())
for j in range(d):
r, c = map(int, input().split())
S[r-1][min(c-1, n-c)] ^= 1
if S[r-1][min(c-1, n-c)]:
dS += 1
else:
dS -= 1
T[min(r-1, n-r)][c-1] ^= 1
if T[min(r-1, n-r)][c-1]:
dT += 1
else:
dT -= 1
if dS == dT == 0:
ans += 1
print(ans)
```
| 88,294 |
Provide a correct Python 3 solution for this coding contest problem.
The cloth coasters produced and sold by Aizu Takada City are known for their symmetrical design and great beauty. As part of quality control, Aizu Takada City has installed cameras on the production line to automatically verify that the images obtained by shooting each coaster are symmetrical. Each coaster is represented as a square black and white image of N x N pixels. Each pixel has a value of 0 or 1 corresponding to a white or black image.
This time, the software of the image analysis system will be updated along with the equipment update of the production line. The new system has been devised to reduce the amount of communication data, and data is sent from the camera to the analysis system by the following method.
* The information of the first coaster flowing on the line is sent to the system as an N × N pixel image.
* For the coaster information on the second and subsequent images, only the difference from the previous image is sent. The difference is given as a set of pixel positions that change from "0 to 1" or "1 to 0".
For C coasters, enter the pixel information of the first image and the difference information of the following C-1 image, and create a program that reports the number of coasters that are vertically symmetrical and symmetrical.
Input
The input is given in the following format.
C N
p11p12 ... p1N
p21p22 ... p2N
::
pN1pN2 ... pNN
diff1
diff2
::
diffC-1
The first line gives the number of coasters C (1 ≤ C ≤ 10000) and the number of pixels N (2 ≤ N ≤ 1000 and N is even) in the vertical and horizontal directions of the image. Lines 2 to N + 1 are given the number pij (pij is 0 or 1) in rows N x columns N representing the pixels of the image of the first coaster.
After the N + 2nd line, the difference diffi representing the information of the 2nd and subsequent coasters is given in the following format.
D
r1 c1
r2 c2
::
rD cD
The number of changed pixels D (0 ≤ D ≤ 100) is given in the first line. The following D rows are given ri and ci (1 ≤ ri, ci ≤ N), which represent the row and column numbers of the changed pixels, respectively. The same position cannot be given more than once in diffi.
Output
The number of coasters that are vertically symmetrical and symmetrical is output on one line.
Examples
Input
7 8
00100000
00011000
10111101
01100110
01000110
10111101
00011000
00100100
2
5 3
1 6
1
6 8
3
6 8
3 3
3 6
2
6 3
6 6
0
2
3 8
6 8
Output
3
Input
1 6
000000
000000
010010
010010
000000
000000
Output
1
Input
2 2
00
00
4
1 1
1 2
2 1
2 2
Output
2
"Correct Solution:
```
C, n = map(int, input().split())
mp = [input() for _ in range(n)]
diff_dic = {}
def change(x, y):
global diff_dic
if (x, y) in diff_dic:
diff_dic.pop((x, y))
else:
diff_dic[(x, y)] = True
for y in range(n // 2):
for x in range(n // 2):
base = mp[y][x]
if mp[y][n - 1 - x] != base:
change(n - 1 - x, y)
if mp[n - 1 - y][x] != base:
change(x, n - 1 - y)
if mp[n - 1 - y][n - 1 - x] != base:
change(n - 1 - x, n - 1 - y)
if n % 2:
for x in range(n // 2):
if mp[n // 2][x] != mp[n // 2][n - 1 - x]:
chenge(n - 1 - x, n // 2)
for y in range(n // 2):
if mp[y][n // 2] != mp[n - 1 - y][n // 2]:
change(n // 2, n - 1 - y)
ans = 0
if not diff_dic:
ans += 1
for _ in range(C - 1):
d = int(input())
for _ in range(d):
r, c = map(int, input().split())
r -= 1
c -= 1
if r < n // 2 and c < n // 2:
change(c, n - 1 - r)
change(n - 1 - c, r)
change(n - 1 - c, n - 1 - r)
elif n % 2 and r == n // 2 and c != n // 2:
change(max(c, n - 1 - c), r)
elif n % 2 and r != n // 2 and c == n // 2:
change(c, max(r, n - 1 - r))
else:
change(c, r)
if not diff_dic:
ans += 1
print(ans)
```
| 88,295 |
Provide a correct Python 3 solution for this coding contest problem.
The cloth coasters produced and sold by Aizu Takada City are known for their symmetrical design and great beauty. As part of quality control, Aizu Takada City has installed cameras on the production line to automatically verify that the images obtained by shooting each coaster are symmetrical. Each coaster is represented as a square black and white image of N x N pixels. Each pixel has a value of 0 or 1 corresponding to a white or black image.
This time, the software of the image analysis system will be updated along with the equipment update of the production line. The new system has been devised to reduce the amount of communication data, and data is sent from the camera to the analysis system by the following method.
* The information of the first coaster flowing on the line is sent to the system as an N × N pixel image.
* For the coaster information on the second and subsequent images, only the difference from the previous image is sent. The difference is given as a set of pixel positions that change from "0 to 1" or "1 to 0".
For C coasters, enter the pixel information of the first image and the difference information of the following C-1 image, and create a program that reports the number of coasters that are vertically symmetrical and symmetrical.
Input
The input is given in the following format.
C N
p11p12 ... p1N
p21p22 ... p2N
::
pN1pN2 ... pNN
diff1
diff2
::
diffC-1
The first line gives the number of coasters C (1 ≤ C ≤ 10000) and the number of pixels N (2 ≤ N ≤ 1000 and N is even) in the vertical and horizontal directions of the image. Lines 2 to N + 1 are given the number pij (pij is 0 or 1) in rows N x columns N representing the pixels of the image of the first coaster.
After the N + 2nd line, the difference diffi representing the information of the 2nd and subsequent coasters is given in the following format.
D
r1 c1
r2 c2
::
rD cD
The number of changed pixels D (0 ≤ D ≤ 100) is given in the first line. The following D rows are given ri and ci (1 ≤ ri, ci ≤ N), which represent the row and column numbers of the changed pixels, respectively. The same position cannot be given more than once in diffi.
Output
The number of coasters that are vertically symmetrical and symmetrical is output on one line.
Examples
Input
7 8
00100000
00011000
10111101
01100110
01000110
10111101
00011000
00100100
2
5 3
1 6
1
6 8
3
6 8
3 3
3 6
2
6 3
6 6
0
2
3 8
6 8
Output
3
Input
1 6
000000
000000
010010
010010
000000
000000
Output
1
Input
2 2
00
00
4
1 1
1 2
2 1
2 2
Output
2
"Correct Solution:
```
def next(N, i):
return ((N-i-1)+N)%N
def getState(N, G, i, j):
return G[i][j] == G[i][next(N, j)] and G[i][j] == G[next(N, i)][j] and G[i][j] == G[next(N, i)][next(N, j)]
def getInit(N, G):
dcnt = 0
for i in range(N//2):
for j in range(N//2):
if not getState(N, G, i, j): dcnt += 1
return dcnt
C, N = map(int, input().split())
#G = [[0]*N]*N
G = [['N' for _ in range(N)] for _ in range(N)]
for i in range(N):
str = input()
for j in range(N):
G[i][j] = int(str[j])
ans = 0
dcnt = getInit(N, G)
if dcnt == 0: ans += 1
for i in range(C-1):
k = int(input())
for j in range(k):
r, c = map(int, input().split())
r -= 1
c -= 1
pre = getState(N, G, r, c)
G[r][c] = 0 if G[r][c]== 1 else 1
post = getState(N, G, r, c)
if not pre and post: dcnt -= 1
elif pre and not post: dcnt += 1
if dcnt == 0: ans += 1
print(ans)
```
| 88,296 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
The cloth coasters produced and sold by Aizu Takada City are known for their symmetrical design and great beauty. As part of quality control, Aizu Takada City has installed cameras on the production line to automatically verify that the images obtained by shooting each coaster are symmetrical. Each coaster is represented as a square black and white image of N x N pixels. Each pixel has a value of 0 or 1 corresponding to a white or black image.
This time, the software of the image analysis system will be updated along with the equipment update of the production line. The new system has been devised to reduce the amount of communication data, and data is sent from the camera to the analysis system by the following method.
* The information of the first coaster flowing on the line is sent to the system as an N × N pixel image.
* For the coaster information on the second and subsequent images, only the difference from the previous image is sent. The difference is given as a set of pixel positions that change from "0 to 1" or "1 to 0".
For C coasters, enter the pixel information of the first image and the difference information of the following C-1 image, and create a program that reports the number of coasters that are vertically symmetrical and symmetrical.
Input
The input is given in the following format.
C N
p11p12 ... p1N
p21p22 ... p2N
::
pN1pN2 ... pNN
diff1
diff2
::
diffC-1
The first line gives the number of coasters C (1 ≤ C ≤ 10000) and the number of pixels N (2 ≤ N ≤ 1000 and N is even) in the vertical and horizontal directions of the image. Lines 2 to N + 1 are given the number pij (pij is 0 or 1) in rows N x columns N representing the pixels of the image of the first coaster.
After the N + 2nd line, the difference diffi representing the information of the 2nd and subsequent coasters is given in the following format.
D
r1 c1
r2 c2
::
rD cD
The number of changed pixels D (0 ≤ D ≤ 100) is given in the first line. The following D rows are given ri and ci (1 ≤ ri, ci ≤ N), which represent the row and column numbers of the changed pixels, respectively. The same position cannot be given more than once in diffi.
Output
The number of coasters that are vertically symmetrical and symmetrical is output on one line.
Examples
Input
7 8
00100000
00011000
10111101
01100110
01000110
10111101
00011000
00100100
2
5 3
1 6
1
6 8
3
6 8
3 3
3 6
2
6 3
6 6
0
2
3 8
6 8
Output
3
Input
1 6
000000
000000
010010
010010
000000
000000
Output
1
Input
2 2
00
00
4
1 1
1 2
2 1
2 2
Output
2
Submitted Solution:
```
c, n = map(int, input().split())
p = [list(input()) for _ in range(n)]
diff = []
for _ in range(c-1):
hoge = int(input())
diff.append([list(map(int, input().split())) for _ in range(hoge)])
def check(p, n):
flag = True
for i in range(n):
for j in range(n//2):
if p[i][j] != p[i][n-1-j]:
flag = False
for i in range(n//2):
for j in range(n//2):
if p[i][j] != p[n-1-i][j]:
flag = False
return flag
ans = 0
ans += check(p, n)
for l in diff:
for i in l:
p[i[0]-1][i[1]-1] = str((int(p[i[0]-1][i[1]-1])+1) % 2)
ans += check(p, n)
print(ans)
```
No
| 88,297 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
The cloth coasters produced and sold by Aizu Takada City are known for their symmetrical design and great beauty. As part of quality control, Aizu Takada City has installed cameras on the production line to automatically verify that the images obtained by shooting each coaster are symmetrical. Each coaster is represented as a square black and white image of N x N pixels. Each pixel has a value of 0 or 1 corresponding to a white or black image.
This time, the software of the image analysis system will be updated along with the equipment update of the production line. The new system has been devised to reduce the amount of communication data, and data is sent from the camera to the analysis system by the following method.
* The information of the first coaster flowing on the line is sent to the system as an N × N pixel image.
* For the coaster information on the second and subsequent images, only the difference from the previous image is sent. The difference is given as a set of pixel positions that change from "0 to 1" or "1 to 0".
For C coasters, enter the pixel information of the first image and the difference information of the following C-1 image, and create a program that reports the number of coasters that are vertically symmetrical and symmetrical.
Input
The input is given in the following format.
C N
p11p12 ... p1N
p21p22 ... p2N
::
pN1pN2 ... pNN
diff1
diff2
::
diffC-1
The first line gives the number of coasters C (1 ≤ C ≤ 10000) and the number of pixels N (2 ≤ N ≤ 1000 and N is even) in the vertical and horizontal directions of the image. Lines 2 to N + 1 are given the number pij (pij is 0 or 1) in rows N x columns N representing the pixels of the image of the first coaster.
After the N + 2nd line, the difference diffi representing the information of the 2nd and subsequent coasters is given in the following format.
D
r1 c1
r2 c2
::
rD cD
The number of changed pixels D (0 ≤ D ≤ 100) is given in the first line. The following D rows are given ri and ci (1 ≤ ri, ci ≤ N), which represent the row and column numbers of the changed pixels, respectively. The same position cannot be given more than once in diffi.
Output
The number of coasters that are vertically symmetrical and symmetrical is output on one line.
Examples
Input
7 8
00100000
00011000
10111101
01100110
01000110
10111101
00011000
00100100
2
5 3
1 6
1
6 8
3
6 8
3 3
3 6
2
6 3
6 6
0
2
3 8
6 8
Output
3
Input
1 6
000000
000000
010010
010010
000000
000000
Output
1
Input
2 2
00
00
4
1 1
1 2
2 1
2 2
Output
2
Submitted Solution:
```
import copy
from pprint import pprint
def rotate90(p):
n = len(p)
q = [ [ 0 for _ in [0]*n ] for __ in [0]*n ]
for y in range(n):
for x in range(n):
q[y][x] = p[n-1-x][y]
return q
def check(p):
n = len(p)
for y in range(n):
if p[y] != list(reversed(p[y])):
return False
for x in range(n):
if p[y][x] != p[n-1-y][x]:
return False
return True
def main():
C,N=map(int,input().split())
p = [ [ 0 for _ in [0]*N ] for __ in [0]*N ]
for i in range(N):
s = input()
for j in range(N):
p[i][j] = int(s[j])
ans = 0
if check(p):
ans += 1
for _ in range(C-1):
D = int(input())
for __ in range(D):
y,x = map(int,input().split())
y -= 1
x -= 1
p[y][x] = ( p[y][x] + 1 ) % 2
if check(p):
ans += 1
print(ans)
if __name__ == "__main__":
main()
```
No
| 88,298 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
The cloth coasters produced and sold by Aizu Takada City are known for their symmetrical design and great beauty. As part of quality control, Aizu Takada City has installed cameras on the production line to automatically verify that the images obtained by shooting each coaster are symmetrical. Each coaster is represented as a square black and white image of N x N pixels. Each pixel has a value of 0 or 1 corresponding to a white or black image.
This time, the software of the image analysis system will be updated along with the equipment update of the production line. The new system has been devised to reduce the amount of communication data, and data is sent from the camera to the analysis system by the following method.
* The information of the first coaster flowing on the line is sent to the system as an N × N pixel image.
* For the coaster information on the second and subsequent images, only the difference from the previous image is sent. The difference is given as a set of pixel positions that change from "0 to 1" or "1 to 0".
For C coasters, enter the pixel information of the first image and the difference information of the following C-1 image, and create a program that reports the number of coasters that are vertically symmetrical and symmetrical.
Input
The input is given in the following format.
C N
p11p12 ... p1N
p21p22 ... p2N
::
pN1pN2 ... pNN
diff1
diff2
::
diffC-1
The first line gives the number of coasters C (1 ≤ C ≤ 10000) and the number of pixels N (2 ≤ N ≤ 1000 and N is even) in the vertical and horizontal directions of the image. Lines 2 to N + 1 are given the number pij (pij is 0 or 1) in rows N x columns N representing the pixels of the image of the first coaster.
After the N + 2nd line, the difference diffi representing the information of the 2nd and subsequent coasters is given in the following format.
D
r1 c1
r2 c2
::
rD cD
The number of changed pixels D (0 ≤ D ≤ 100) is given in the first line. The following D rows are given ri and ci (1 ≤ ri, ci ≤ N), which represent the row and column numbers of the changed pixels, respectively. The same position cannot be given more than once in diffi.
Output
The number of coasters that are vertically symmetrical and symmetrical is output on one line.
Examples
Input
7 8
00100000
00011000
10111101
01100110
01000110
10111101
00011000
00100100
2
5 3
1 6
1
6 8
3
6 8
3 3
3 6
2
6 3
6 6
0
2
3 8
6 8
Output
3
Input
1 6
000000
000000
010010
010010
000000
000000
Output
1
Input
2 2
00
00
4
1 1
1 2
2 1
2 2
Output
2
Submitted Solution:
```
from copy import deepcopy as cd
def rotate90(p):
h,w = len(p[0]),len(p)
ret = [[0 for i in range(w)] for j in range(h)]
for y in range(h):
for x in range(w):
ret[y][x] = p[w-1-x][y]
return ret
def check(p):
a,b,c = cd(p),cd(p),cd(p)
return p == rotate90(rotate90(a)) and rotate90(b) == rotate90(rotate90(rotate90(c)))
def main():
C,N=map(int,input().split())
p = []
for i in range(N):
s=input()
p.append([])
for c in s:
p[i].append(int(c))
ans = 1 if check(p) else 0
for _ in [0]*(C-1):
D=int(input())
for i in range(D):
y,x=map(int,input().split())
p[y-1][x-1] = (p[y-1][x-1]+1)&1
if check(p):
ans += 1
print(ans)
if __name__ == "__main__":
main()
```
No
| 88,299 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.