message stringlengths 2 39.6k | message_type stringclasses 2 values | message_id int64 0 1 | conversation_id int64 219 108k | cluster float64 11 11 | __index_level_0__ int64 438 217k |
|---|---|---|---|---|---|
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
One company of IT City decided to create a group of innovative developments consisting from 5 to 7 people and hire new employees for it. After placing an advertisment the company received n resumes. Now the HR department has to evaluate each possible group composition and select one of them. Your task is to count the number of variants of group composition to evaluate.
Input
The only line of the input contains one integer n (7 ≤ n ≤ 777) — the number of potential employees that sent resumes.
Output
Output one integer — the number of different variants of group composition.
Examples
Input
7
Output
29
Submitted Solution:
```
n = int(input())
fac_n = 1
fac1 = 1
fac2 = 1
fac3 = 1
i = 0
while i < n:
i += 1
fac_n = fac_n * i
i = 0
while i < n - 5:
i += 1
fac1 = fac1 * i
i = 0
while i < n - 6:
i += 1
fac2 = fac2 * i
i = 0
while i < n - 7:
i += 1
fac3 = fac3 * i
ans = fac_n / (fac1 * 120)+ fac_n / (fac2 * 720) + fac_n / (fac3 * 5040)
print(ans)
``` | instruction | 0 | 83,007 | 11 | 166,014 |
No | output | 1 | 83,007 | 11 | 166,015 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
One company of IT City decided to create a group of innovative developments consisting from 5 to 7 people and hire new employees for it. After placing an advertisment the company received n resumes. Now the HR department has to evaluate each possible group composition and select one of them. Your task is to count the number of variants of group composition to evaluate.
Input
The only line of the input contains one integer n (7 ≤ n ≤ 777) — the number of potential employees that sent resumes.
Output
Output one integer — the number of different variants of group composition.
Examples
Input
7
Output
29
Submitted Solution:
```
n = int(input())
print(n * (n - 1) * (n - 2) * (n - 3) * (n - 4) / 1 / 2 / 3 / 4 / 5 +
n * (n - 1) * (n - 2) * (n - 3) * (n - 4) * (n - 5) / 1 / 2 / 3 / 4 / 5 / 6 +
n * (n - 1) * (n - 2) * (n - 3) * (n - 4) * (n - 5) * (n - 6) / 1 / 2 / 3 / 4 / 5 / 6 / 7)
``` | instruction | 0 | 83,008 | 11 | 166,016 |
No | output | 1 | 83,008 | 11 | 166,017 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
One company of IT City decided to create a group of innovative developments consisting from 5 to 7 people and hire new employees for it. After placing an advertisment the company received n resumes. Now the HR department has to evaluate each possible group composition and select one of them. Your task is to count the number of variants of group composition to evaluate.
Input
The only line of the input contains one integer n (7 ≤ n ≤ 777) — the number of potential employees that sent resumes.
Output
Output one integer — the number of different variants of group composition.
Examples
Input
7
Output
29
Submitted Solution:
```
a=int(input())
pr=a*(a-1)*(a-2)*(a-3)*(a-4)
print(int(pr/120+pr*(a-5)/720+pr*(a-5)*(a-6)/5040))
``` | instruction | 0 | 83,009 | 11 | 166,018 |
No | output | 1 | 83,009 | 11 | 166,019 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
During the breaks between competitions, top-model Izabella tries to develop herself and not to be bored. For example, now she tries to solve Rubik's cube 2x2x2.
It's too hard to learn to solve Rubik's cube instantly, so she learns to understand if it's possible to solve the cube in some state using 90-degrees rotation of one face of the cube in any direction.
To check her answers she wants to use a program which will for some state of cube tell if it's possible to solve it using one rotation, described above.
Cube is called solved if for each face of cube all squares on it has the same color.
https://en.wikipedia.org/wiki/Rubik's_Cube
Input
In first line given a sequence of 24 integers ai (1 ≤ ai ≤ 6), where ai denotes color of i-th square. There are exactly 4 occurrences of all colors in this sequence.
Output
Print «YES» (without quotes) if it's possible to solve cube using one rotation and «NO» (without quotes) otherwise.
Examples
Input
2 5 4 6 1 3 6 2 5 5 1 2 3 5 3 1 1 2 4 6 6 4 3 4
Output
NO
Input
5 3 5 3 2 5 2 5 6 2 6 2 4 4 4 4 1 1 1 1 6 3 6 3
Output
YES
Note
In first test case cube looks like this:
<image>
In second test case cube looks like this:
<image>
It's possible to solve cube by rotating face with squares with numbers 13, 14, 15, 16.
Submitted Solution:
```
a = [int(i) for i in input().split()]
a1 = [[a[(j * 4) + i] for i in range(4)] for j in range(6)]
ver = a1[0]
per = a1[1]
niz = a1[2]
lev = a1[3]
prav = a1[4]
zad = a1[5]
res = "NO"
if len(set(lev)) == 1 and len(set(prav)) == 1:
per1 = (1 if per[1] == per[3] else 0)
ver1 = (1 if ver[1] == ver[3] else 0)
niz1 = (1 if niz[1] == niz[3] else 0)
zad1 = (1 if zad[0] == zad[2] else 0)
per2 = (1 if per[0] == per[2] else 0)
ver2 = (1 if ver[0] == ver[2] else 0)
niz2 = (1 if niz[0] == niz[2] else 0)
zad2 = (1 if zad[1] == zad[3] else 0)
if (per1 == ver2 and per[1] == ver[0]) and (ver1 == zad2 and zad[1] == ver[1]) and (zad1 == niz2 and zad[0] == niz[0]) and (niz1 == per2 and per[0] == niz[1]):
res = "YES"
elif (per1 == niz2 and per[1] == niz[0]) and (ver1 == per2 and per[0] == ver[1]) and (zad1 == ver2 and zad[0] == ver[0]) and (niz1 == zad2 and zad[1] == niz[1]):
res = "YES"
elif len(set(niz)) == 1 and len(set(ver)) == 1:
per1 = (1 if per[0] == per[1] else 0)
lev1 = (1 if lev[0] == lev[1] else 0)
prav1 = (1 if prav[0] == prav[1] else 0)
zad1 = (1 if zad[0] == zad[1] else 0)
per2 = (1 if per[2] == per[3] else 0)
lev2 = (1 if lev[2] == lev[3] else 0)
prav2 = (1 if prav[2] == prav[3] else 0)
zad2 = (1 if zad[2] == zad[3] else 0)
if (per1 == lev2 and per[0] == lev[2]) and (lev1 == zad2 and zad[2] == lev[0]) and (zad1 == prav2 and zad[0] == prav[2]) and (prav1 == per2 and per[2] == prav[0]):
res = "YES"
elif (per1 == prav2 and per[0] == prav[2]) and (prav1 == zad2 and zad[2] == prav[0]) and (zad1 == lev2 and zad[0] == lev[2]) and (lev1 == per2 and per[2] == lev[0]):
res = "YES"
elif len(set(per)) == 1 and len(set(zad)) == 1:
ver1 = (1 if ver[2] == ver[3] else 0)
lev1 = (1 if lev[3] == lev[1] else 0)
prav1 = (1 if prav[0] == prav[2] else 0)
niz1 = (1 if niz[0] == niz[1] else 0)
ver2 = (1 if ver[0] == ver[1] else 0)
lev2 = (1 if lev[2] == lev[0] else 0)
prav2 = (1 if prav[1] == prav[3] else 0)
niz2 = (1 if niz[2] == niz[3] else 0)
if (ver1 == lev2 and ver[2] == lev[2]) and (lev1 == niz2 and niz[2] == lev[3]) and (niz1 == prav2 and niz[0] == prav[1]) and (prav1 == ver2 and ver[0] == prav[0]):
res = "YES"
elif (ver1 == prav2 and ver[2] == prav[1]) and (prav1 == niz2 and niz[2] == prav[0]) and (niz1 == lev2 and niz[0] == lev[2]) and (lev1 == ver2 and ver[0] == lev[3]):
res = "YES"
if len(set(per)) == 1 and len(set(zad)) == 1 and len(set(niz)) == 1 and len(set(ver)) == 1 and len(set(lev)) == 1 and len(set(prav)) == 1:
res = "NO"
print(res)
``` | instruction | 0 | 83,099 | 11 | 166,198 |
Yes | output | 1 | 83,099 | 11 | 166,199 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
During the breaks between competitions, top-model Izabella tries to develop herself and not to be bored. For example, now she tries to solve Rubik's cube 2x2x2.
It's too hard to learn to solve Rubik's cube instantly, so she learns to understand if it's possible to solve the cube in some state using 90-degrees rotation of one face of the cube in any direction.
To check her answers she wants to use a program which will for some state of cube tell if it's possible to solve it using one rotation, described above.
Cube is called solved if for each face of cube all squares on it has the same color.
https://en.wikipedia.org/wiki/Rubik's_Cube
Input
In first line given a sequence of 24 integers ai (1 ≤ ai ≤ 6), where ai denotes color of i-th square. There are exactly 4 occurrences of all colors in this sequence.
Output
Print «YES» (without quotes) if it's possible to solve cube using one rotation and «NO» (without quotes) otherwise.
Examples
Input
2 5 4 6 1 3 6 2 5 5 1 2 3 5 3 1 1 2 4 6 6 4 3 4
Output
NO
Input
5 3 5 3 2 5 2 5 6 2 6 2 4 4 4 4 1 1 1 1 6 3 6 3
Output
YES
Note
In first test case cube looks like this:
<image>
In second test case cube looks like this:
<image>
It's possible to solve cube by rotating face with squares with numbers 13, 14, 15, 16.
Submitted Solution:
```
a = list(map(int, input().split()))
if ((a[0] == a[5] == a[2] == a[7]) and (a[4] == a[9] == a[6] == a[11]) and (a[20] == a[8] == a[10] == a[22]) and (a[21] == a[1] == a[23] == a[3])) or \
((a[4] == a[1] == a[6] == a[3]) and (a[8] == a[5] == a[10] == a[7]) and (a[21] == a[23] == a[9] == a[11]) and (a[0] == a[20] == a[2] == a[22])) or \
((a[4] == a[5] == a[14] == a[15]) and (a[16] == a[6] == a[17] == a[7]) and (a[20] == a[18] == a[21] == a[19]) and (a[22] == a[12] == a[13] == a[23])) or\
((a[12] == a[13] == a[6] == a[7]) and (a[4] == a[5] == a[19] == a[18]) and (a[16] == a[17] == a[22] == a[23]) and (a[15] == a[14] == a[21] == a[20])) or \
((a[2] == a[3] == a[17] == a[19]) and (a[11] == a[18] == a[10] == a[16]) and (a[8] == a[12] == a[9] == a[14]) and (a[1] == a[15] == a[0] == a[13])) or \
((a[16] == a[0] == a[1] == a[18]) and (a[3] == a[2] == a[12] == a[14]) and (a[11] == a[15] == a[10] == a[13]) and (a[8] == a[17] == a[9] == a[19])):
print('YES')
else:
print("NO")
``` | instruction | 0 | 83,100 | 11 | 166,200 |
Yes | output | 1 | 83,100 | 11 | 166,201 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
During the breaks between competitions, top-model Izabella tries to develop herself and not to be bored. For example, now she tries to solve Rubik's cube 2x2x2.
It's too hard to learn to solve Rubik's cube instantly, so she learns to understand if it's possible to solve the cube in some state using 90-degrees rotation of one face of the cube in any direction.
To check her answers she wants to use a program which will for some state of cube tell if it's possible to solve it using one rotation, described above.
Cube is called solved if for each face of cube all squares on it has the same color.
https://en.wikipedia.org/wiki/Rubik's_Cube
Input
In first line given a sequence of 24 integers ai (1 ≤ ai ≤ 6), where ai denotes color of i-th square. There are exactly 4 occurrences of all colors in this sequence.
Output
Print «YES» (without quotes) if it's possible to solve cube using one rotation and «NO» (without quotes) otherwise.
Examples
Input
2 5 4 6 1 3 6 2 5 5 1 2 3 5 3 1 1 2 4 6 6 4 3 4
Output
NO
Input
5 3 5 3 2 5 2 5 6 2 6 2 4 4 4 4 1 1 1 1 6 3 6 3
Output
YES
Note
In first test case cube looks like this:
<image>
In second test case cube looks like this:
<image>
It's possible to solve cube by rotating face with squares with numbers 13, 14, 15, 16.
Submitted Solution:
```
def checkRubik(l):
for i in range(1,25,4):
for j in range(i+1,i+4):
if l[j]!=l[i]:
return False
return True
a=list(map(int,input().split()))
a.insert(0,0)
o=checkRubik(a)
if not o:
b=a
b[1],b[3],b[5],b[7],b[9],b[11],b[24],b[22]=b[24],b[22],b[1],b[3],b[5],b[7],b[9],b[11]
o=checkRubik(b)
if not o:
b=a
b[1],b[3],b[5],b[7],b[9],b[11],b[24],b[22]=b[5],b[7],b[9],b[11],b[24],b[22],b[1],b[3]
o=checkRubik(b)
if not o:
b=a
b[2],b[4],b[6],b[8],b[10],b[12],b[23],b[21]=b[23],b[21],b[2],b[4],b[6],b[8],b[10],b[12]
o=checkRubik(b)
if not o:
b=a
b[2],b[4],b[6],b[8],b[10],b[12],b[23],b[21]=b[6],b[8],b[10],b[12],b[23],b[21],b[2],b[4]
o=checkRubik(b)
if not o:
b=a
b[13],b[14],b[5],b[6],b[17],b[18],b[21],b[22]=b[21],b[22],b[13],b[14],b[5],b[6],b[17],b[18]
o=checkRubik(b)
if not o:
b=a
b[13],b[14],b[5],b[6],b[17],b[18],b[21],b[22]=b[5],b[6],b[17],b[18],b[21],b[22],b[13],b[14]
o=checkRubik(b)
if not o:
b=a
b[15],b[16],b[7],b[8],b[19],b[20],b[23],b[24]=b[23],b[24],b[15],b[16],b[7],b[8],b[19],b[20]
o=checkRubik(b)
if not o:
b=a
b[15],b[16],b[7],b[8],b[19],b[20],b[23],b[24]=b[7],b[8],b[19],b[20],b[23],b[24],b[15],b[16]
o=checkRubik(b)
#start
if not o:
b=a
b[3],b[4],b[17],b[19],b[10],b[9],b[16],b[14]=b[16],b[14],b[3],b[4],b[17],b[19],b[10],b[9]
o=checkRubik(b)
if not o:
b=a
b[3],b[4],b[17],b[19],b[10],b[9],b[16],b[14]=b[17],b[19],b[10],b[9],b[16],b[14],b[3],b[4]
o=checkRubik(b)
if not o:
b=a
b[1],b[2],b[18],b[20],b[12],b[11],b[15],b[13]=b[15],b[13],b[1],b[2],b[18],b[20],b[12],b[11]
o=checkRubik(b)
if not o:
b=a
b[1],b[2],b[18],b[20],b[12],b[11],b[15],b[13]=b[18],b[20],b[12],b[11],b[15],b[13],b[1],b[2]
o=checkRubik(b)
if not o:
print("NO")
else:
print("YES")
else:
print("NO")
``` | instruction | 0 | 83,101 | 11 | 166,202 |
Yes | output | 1 | 83,101 | 11 | 166,203 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
During the breaks between competitions, top-model Izabella tries to develop herself and not to be bored. For example, now she tries to solve Rubik's cube 2x2x2.
It's too hard to learn to solve Rubik's cube instantly, so she learns to understand if it's possible to solve the cube in some state using 90-degrees rotation of one face of the cube in any direction.
To check her answers she wants to use a program which will for some state of cube tell if it's possible to solve it using one rotation, described above.
Cube is called solved if for each face of cube all squares on it has the same color.
https://en.wikipedia.org/wiki/Rubik's_Cube
Input
In first line given a sequence of 24 integers ai (1 ≤ ai ≤ 6), where ai denotes color of i-th square. There are exactly 4 occurrences of all colors in this sequence.
Output
Print «YES» (without quotes) if it's possible to solve cube using one rotation and «NO» (without quotes) otherwise.
Examples
Input
2 5 4 6 1 3 6 2 5 5 1 2 3 5 3 1 1 2 4 6 6 4 3 4
Output
NO
Input
5 3 5 3 2 5 2 5 6 2 6 2 4 4 4 4 1 1 1 1 6 3 6 3
Output
YES
Note
In first test case cube looks like this:
<image>
In second test case cube looks like this:
<image>
It's possible to solve cube by rotating face with squares with numbers 13, 14, 15, 16.
Submitted Solution:
```
l=list(map(int,input().split()))
l.insert(0,0)
c1=[1,6,3,8,5,10,7,12,9,23,11,21,13,14,15,16,17,18,19,20,4,22,2,24]
c2=[1,23,3,21,5,2,7,4,9,6,11,8,13,14,15,16,17,18,19,20,12,22,10,24]
c3=[1,2,3,4,5,6,15,16,9,10,11,12,13,14,23,24,17,18,7,8,21,22,19,20]
c4=[1,2,3,4,5,6,19,20,9,10,11,12,13,14,7,8,17,18,23,24,21,22,15,16]
c5=[1,2,16,14,5,6,7,8,19,17,11,12,13,9,15,10,3,18,4,20,21,22,23,24]
c6=[1,2,17,19,5,6,7,8,14,16,11,12,13,4,15,3,10,18,9,20,21,22,23,24]
flag=0
mark=0
for i in range(6):
if(l[c1[4*i]] == l[c1[4*i+1]] == l[c1[4*i+2]] == l[c1[4*i+3]]):
mark=1
else:
mark=0
break
if(mark):
flag=1
mark=0
for i in range(6):
if(l[c2[4*i]] == l[c2[4*i+1]] == l[c2[4*i+2]] == l[c2[4*i+3]]):
mark=1
else:
mark=0
break
if(mark):
flag=1
mark=0
for i in range(6):
if(l[c3[4*i]] == l[c3[4*i+1]] == l[c3[4*i+2]] == l[c3[4*i+3]]):
mark=1
else:
mark=0
break
if(mark):
flag=1
mark=0
for i in range(6):
if(l[c4[4*i]] == l[c4[4*i+1]] == l[c4[4*i+2]] == l[c4[4*i+3]]):
mark=1
else:
mark=0
break
if(mark):
flag=1
mark=0
for i in range(6):
if(l[c5[4*i]] == l[c5[4*i+1]] == l[c5[4*i+2]] == l[c5[4*i+3]]):
mark=1
else:
mark=0
break
if(mark):
flag=1
mark=0
for i in range(6):
if(l[c6[4*i]] == l[c6[4*i+1]] == l[c6[4*i+2]] == l[c6[4*i+3]]):
mark=1
else:
mark=0
break
if(mark):
flag=1
if(flag):
print("YES")
else:
print("NO")
``` | instruction | 0 | 83,102 | 11 | 166,204 |
Yes | output | 1 | 83,102 | 11 | 166,205 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
During the breaks between competitions, top-model Izabella tries to develop herself and not to be bored. For example, now she tries to solve Rubik's cube 2x2x2.
It's too hard to learn to solve Rubik's cube instantly, so she learns to understand if it's possible to solve the cube in some state using 90-degrees rotation of one face of the cube in any direction.
To check her answers she wants to use a program which will for some state of cube tell if it's possible to solve it using one rotation, described above.
Cube is called solved if for each face of cube all squares on it has the same color.
https://en.wikipedia.org/wiki/Rubik's_Cube
Input
In first line given a sequence of 24 integers ai (1 ≤ ai ≤ 6), where ai denotes color of i-th square. There are exactly 4 occurrences of all colors in this sequence.
Output
Print «YES» (without quotes) if it's possible to solve cube using one rotation and «NO» (without quotes) otherwise.
Examples
Input
2 5 4 6 1 3 6 2 5 5 1 2 3 5 3 1 1 2 4 6 6 4 3 4
Output
NO
Input
5 3 5 3 2 5 2 5 6 2 6 2 4 4 4 4 1 1 1 1 6 3 6 3
Output
YES
Note
In first test case cube looks like this:
<image>
In second test case cube looks like this:
<image>
It's possible to solve cube by rotating face with squares with numbers 13, 14, 15, 16.
Submitted Solution:
```
def f(a, d):
newa = a[::]
for i in range(24):
if (i + 1) in d:
newa[d[i + 1] - 1] = a[i]
#print(newa)
for i in range(0, 22, 4):
if newa[i] == newa[i + 1] == newa[i + 2] == newa[i + 3]:
return True
return False
arr = list(map(int, input().split()))
var = [dict() for i in range(8)]
#1
var[0][2] = 6
var[0][4] = 8
var[0][6] = 10
var[0][8] = 12
var[0][10] = 23
var[0][12] = 21
var[0][23] = 2
var[0][21] = 4
var[0][17] = 19
var[0][19] = 20
var[0][20] = 18
var[0][18] = 17
#3
var[2][1] = 5
var[2][3] = 7
var[2][5] = 9
var[2][7] = 11
var[2][9] = 24
var[2][11] = 22
var[2][24] = 1
var[2][22] = 3
var[2][13] = 14
var[2][15] = 13
var[2][16] = 15
var[2][14] = 16
#5
var[4][13] = 5
var[4][14] = 6
var[4][5] = 17
var[4][6] = 18
var[4][17] = 21
var[4][18] = 22
var[4][21] = 13
var[4][22] = 14
var[4][1] = 3
var[4][3] = 4
var[4][4] = 2
var[4][2] = 1
#7
var[6][15] = 7
var[6][16] = 8
var[6][7] = 19
var[6][8] = 20
var[6][19] = 23
var[6][20] = 24
var[6][23] = 15
var[6][24] = 16
var[6][9] = 10
var[6][10] = 12
var[6][12] = 11
var[6][11] = 9
for i in range(0, 8, 2):
for j in range(1, 25):
if j in var[i]:
var[i + 1][var[i][j]] = j
for i in range(8):
#print(i - 1)
if f(arr, var[i]):
print('YES')
exit()
print('NO')
``` | instruction | 0 | 83,103 | 11 | 166,206 |
No | output | 1 | 83,103 | 11 | 166,207 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
During the breaks between competitions, top-model Izabella tries to develop herself and not to be bored. For example, now she tries to solve Rubik's cube 2x2x2.
It's too hard to learn to solve Rubik's cube instantly, so she learns to understand if it's possible to solve the cube in some state using 90-degrees rotation of one face of the cube in any direction.
To check her answers she wants to use a program which will for some state of cube tell if it's possible to solve it using one rotation, described above.
Cube is called solved if for each face of cube all squares on it has the same color.
https://en.wikipedia.org/wiki/Rubik's_Cube
Input
In first line given a sequence of 24 integers ai (1 ≤ ai ≤ 6), where ai denotes color of i-th square. There are exactly 4 occurrences of all colors in this sequence.
Output
Print «YES» (without quotes) if it's possible to solve cube using one rotation and «NO» (without quotes) otherwise.
Examples
Input
2 5 4 6 1 3 6 2 5 5 1 2 3 5 3 1 1 2 4 6 6 4 3 4
Output
NO
Input
5 3 5 3 2 5 2 5 6 2 6 2 4 4 4 4 1 1 1 1 6 3 6 3
Output
YES
Note
In first test case cube looks like this:
<image>
In second test case cube looks like this:
<image>
It's possible to solve cube by rotating face with squares with numbers 13, 14, 15, 16.
Submitted Solution:
```
# by the authority of GOD author: Kritarth Sharma #
import math,copy
from collections import defaultdict,Counter
from itertools import permutations
def fact(n):
return 1 if (n == 1 or n == 0) else n * fact(n - 1)
def prime(n) :
if (n <= 1) :
return False
if (n <= 3) :
return True
if (n % 2 == 0 or n % 3 == 0) :
return False
i = 5
while(i * i <= n) :
if (n % i == 0 or n % (i + 2) == 0) :
return False
i = i + 6
return True
def inp():
l=list(map(int,input().split()))
return l
def one(l,i,s):
a=False
b=False
for ii in range(i-1,-1,-1):
if l[ii]==0 and s[ii]==0:
a=ii
break
for ii in range(i+1,len(l)):
if l[ii]==0 and s[ii]==0:
b=ii
break
if a==False:
return b
elif b==False:
return a
elif abs(a-i)>abs(b-i):
return b
else:
return a
## code starts here
#################################################################################################################
def main():
l=inp()
p=[0]*25
for i in range(1,25):
p[i]=l[i-1]
if p[17]==p[18]==p[19]==p[20] and p[13]==p[14]==p[15]==p[16] and p[1]==p[2]==p[3]==p[4] and p[9]==p[10]==p[11]==p[12] and p[5]==p[6]==p[7]==p[8] and p[21]==p[22]==p[23]==p[24]:
print("YES")
elif p[17]==p[18]==p[19]==p[20] and p[13]==p[14]==p[15]==p[16]:
if p[5]==p[7]==p[10]==p[12] and p[9]==p[11]==p[21]==p[23] and p[2]==p[4]==p[22]==p[24] and p[1]==p[3]==p[6]==p[8]:
print("YES")
elif p[5]==p[7]==p[2]==p[4] and p[9]==p[11]==p[6]==p[8] and p[12]==p[10]==p[22]==p[24] and p[1]==p[3]==p[21]==p[23]:
print("YES")
else:
print("NO")
elif p[1]==p[2]==p[3]==p[4] and p[9]==p[10]==p[11]==p[12]:
if p[5]==p[6]==p[19]==p[20] and p[7]==p[8]==p[13]==p[14] and p[17]==p[18]==p[23]==p[24] and p[21]==p[22]==p[16]==p[15]:
print("YES")
elif p[5]==p[6]==p[15]==p[16] and p[17]==p[18]==p[7]==p[8] and p[19]==p[20]==p[22]==p[21] and p[14]==p[13]==p[24]==p[23]:
print("YES")
else:
print("NO")
elif p[5]==p[6]==p[7]==p[8] and p[21]==p[22]==p[23]==p[24]:
if p[19]==p[17]==p[1]==p[2] and p[14]==p[16]==p[18]==p[20] and p[13]==p[15]==p[9]==p[10] and p[11]==p[12]==p[3]==p[4]:
print("YES")
elif p[18]==p[20]==p[3]==p[4] and p[17]==p[19]==p[13]==p[15] and p[11]==p[12]==p[14]==p[16] and p[1]==p[2]==p[9]==p[10]:
print("YES")
else:
print("NO")
else:
print("NO")
import os,sys
from io import BytesIO,IOBase
#Fast IO Region
BUFSIZE = 8192
class FastIO(IOBase):
newlines = 0
def __init__(self, file):
self._fd = file.fileno()
self.buffer = BytesIO()
self.writable = "x" in file.mode or "r" not in file.mode
self.write = self.buffer.write if self.writable else None
def read(self):
while True:
b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
if not b:
break
ptr = self.buffer.tell()
self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
self.newlines = 0
return self.buffer.read()
def readline(self):
while self.newlines == 0:
b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
self.newlines = b.count(b"\n") + (not b)
ptr = self.buffer.tell()
self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
self.newlines -= 1
return self.buffer.readline()
def flush(self):
if self.writable:
os.write(self._fd, self.buffer.getvalue())
self.buffer.truncate(0), self.buffer.seek(0)
class IOWrapper(IOBase):
def __init__(self, file):
self.buffer = FastIO(file)
self.flush = self.buffer.flush
self.writable = self.buffer.writable
self.write = lambda s: self.buffer.write(s.encode("ascii"))
self.read = lambda: self.buffer.read().decode("ascii")
self.readline = lambda: self.buffer.readline().decode("ascii")
sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")
if __name__ == "__main__":
main()
def random():
"""My code gets caught in plagiarism check for no reason due to the fast IO template, .
Due to this reason, I am making useless functions"""
rating=100
rating=rating*100
rating=rating*100
print(rating)
def random():
"""My code gets caught in plagiarism check for no reason due to the fast IO template, .
Due to this reason, I am making useless functions"""
rating=100
rating=rating*100
rating=rating*100
print(rating)
def random():
"""My code gets caught in plagiarism check for no reason due to the fast IO template, .
Due to this reason, I am making useless functions"""
rating=100
rating=rating*100
rating=rating*100
print(rating)
def random():
"""My code gets caught in plagiarism check for no reason due to the fast IO template, .
Due to this reason, I am making useless functions"""
rating=100
rating=rating*100
rating=rating*100
print(rating)
``` | instruction | 0 | 83,104 | 11 | 166,208 |
No | output | 1 | 83,104 | 11 | 166,209 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
During the breaks between competitions, top-model Izabella tries to develop herself and not to be bored. For example, now she tries to solve Rubik's cube 2x2x2.
It's too hard to learn to solve Rubik's cube instantly, so she learns to understand if it's possible to solve the cube in some state using 90-degrees rotation of one face of the cube in any direction.
To check her answers she wants to use a program which will for some state of cube tell if it's possible to solve it using one rotation, described above.
Cube is called solved if for each face of cube all squares on it has the same color.
https://en.wikipedia.org/wiki/Rubik's_Cube
Input
In first line given a sequence of 24 integers ai (1 ≤ ai ≤ 6), where ai denotes color of i-th square. There are exactly 4 occurrences of all colors in this sequence.
Output
Print «YES» (without quotes) if it's possible to solve cube using one rotation and «NO» (without quotes) otherwise.
Examples
Input
2 5 4 6 1 3 6 2 5 5 1 2 3 5 3 1 1 2 4 6 6 4 3 4
Output
NO
Input
5 3 5 3 2 5 2 5 6 2 6 2 4 4 4 4 1 1 1 1 6 3 6 3
Output
YES
Note
In first test case cube looks like this:
<image>
In second test case cube looks like this:
<image>
It's possible to solve cube by rotating face with squares with numbers 13, 14, 15, 16.
Submitted Solution:
```
def Pedy(arr1, arr2):
print(arr1)
print(arr2)
for i in range(8):
h = i
if i % 2:
continue
hh = 0
anss = 1
while (h != ((i - 1) + 8) % 8 and anss):
if arr1[h] != arr2[hh]:
anss = 0
h += 1
hh += 1
if h == 8:
h = 0
if anss and arr1[h] == arr2[hh] and (i == 0 or i == 2 or i == 6 or i == 4):
return 1
return 0
a = list(map(int, input().split()))
b = []
for j in range(6):
i = j * 4
if a[i] == a[i + 1] and a[i + 1] == a[i + 2] and a[i + 2] == a[i + 3]:
b.append(0)
else:
b.append(1)
c = []
c.append(b[0] or b[2])
c.append(b[1] or b[5])
c.append(b[3] or b[4])
if c[0] + c[1] + c[2] == 3 or c[0] + c[1] + c[2] == 1:
print("NO")
if c[0] + c[1] + c[2] == 0:
print("YES")
if c[0] + c[1] + c[2] == 2:
if c[0] + c[1] == 2:
arr1 = []
arr2 = []
arr1.append(a[0])
arr1.append(a[2])
arr1.append(a[4])
arr1.append(a[6])
arr1.append(a[8])
arr1.append(a[10])
arr1.append(a[21])
arr1.append(a[23])
arr2.append(a[1])
arr2.append(a[3])
arr2.append(a[5])
arr2.append(a[7])
arr2.append(a[9])
arr2.append(a[11])
arr2.append(a[20])
arr2.append(a[22])
if Pedy(arr1, arr2):
print("YES")
else:
print("NO")
if c[0] + c[2] == 2:
arr1 = []
arr2 = []
arr1.append(a[0])
arr1.append(a[1])
arr1.append(a[17])
arr1.append(a[19])
arr1.append(a[11])
arr1.append(a[10])
arr1.append(a[14])
arr1.append(a[12])
arr2.append(a[2])
arr2.append(a[3])
arr2.append(a[16])
arr2.append(a[18])
arr2.append(a[9])
arr2.append(a[8])
arr2.append(a[15])
arr2.append(a[13])
if Pedy(arr1, arr2):
print("YESs")
else:
print("NOo")
if c[1] + c[2] == 2:
arr1 = []
arr2 = []
arr1.append(a[12])
arr1.append(a[13])
arr1.append(a[4])
arr1.append(a[5])
arr1.append(a[16])
arr1.append(a[17])
arr1.append(a[20])
arr1.append(a[21])
arr2.append(a[14])
arr2.append(a[15])
arr2.append(a[6])
arr2.append(a[7])
arr2.append(a[18])
arr2.append(a[19])
arr2.append(a[22])
arr2.append(a[23])
if Pedy(arr1, arr2):
print("YES")
else:
print("NO")
``` | instruction | 0 | 83,105 | 11 | 166,210 |
No | output | 1 | 83,105 | 11 | 166,211 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
problem
You have to play a darts game with the following rules.
You can throw up to four arrows towards the target. You don't have to throw all four, you don't have to throw one. The target is divided into N parts. The score P1, ..., PN is written in each part. The total score S of the place where the arrow is stuck is the basis of your score. S is a predetermined score M or less. In the case of, S will be your score as it is. However, if S exceeds M, your score will be 0 points.
Create a program that finds the maximum number of points you can get given the written points and the value of M.
input
The input consists of multiple datasets. Each dataset is given in the following format.
On the first line, the integers N (1 ≤ N ≤ 1000) and M (1 ≤ M ≤ 200000000 = 2 × 108) are written in this order, separated by blanks. In (1 ≤ i ≤ N), Pi (1 ≤ Pi ≤ 100000000 = 108) is written.
Of the scoring data, 20% of the points satisfy N ≤ 100 and 50% of the points satisfy N ≤ 300.
When both N and M are 0, the input is completed. The number of data sets does not exceed 10.
output
Outputs the maximum number of points you can get for each dataset on one line.
Examples
Input
4 50
3
14
15
9
3 21
16
11
2
0 0
Output
48
20
Input
None
Output
None
Submitted Solution:
```
# http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0529
# http://judge.u-aizu.ac.jp/onlinejudge/review.jsp?rid=2985387#1
import bisect
while True:
n, m = map(int, input().split())
if n == 0: break
p = [int(input()) for i in range(n)]
p.append(0)
p.sort()
s = [i+j for i in p for j in p if i <= j]
s.sort()
t = bisect.bisect_left(s, m)
h = bisect.bisect_left(s, m>>1, 0, t)
if t < len(s):
if s[t] == m:
print(m);
continue
s = s[:t]
ans = 0
# for i in range(h-1, len(s)):
for i in range(h):
t = bisect.bisect_left(s, m-s[i])
if s[i]+s[t-1] > ans: ans = s[i]+s[t-1]
print(ans)
``` | instruction | 0 | 83,311 | 11 | 166,622 |
Yes | output | 1 | 83,311 | 11 | 166,623 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
problem
You have to play a darts game with the following rules.
You can throw up to four arrows towards the target. You don't have to throw all four, you don't have to throw one. The target is divided into N parts. The score P1, ..., PN is written in each part. The total score S of the place where the arrow is stuck is the basis of your score. S is a predetermined score M or less. In the case of, S will be your score as it is. However, if S exceeds M, your score will be 0 points.
Create a program that finds the maximum number of points you can get given the written points and the value of M.
input
The input consists of multiple datasets. Each dataset is given in the following format.
On the first line, the integers N (1 ≤ N ≤ 1000) and M (1 ≤ M ≤ 200000000 = 2 × 108) are written in this order, separated by blanks. In (1 ≤ i ≤ N), Pi (1 ≤ Pi ≤ 100000000 = 108) is written.
Of the scoring data, 20% of the points satisfy N ≤ 100 and 50% of the points satisfy N ≤ 300.
When both N and M are 0, the input is completed. The number of data sets does not exceed 10.
output
Outputs the maximum number of points you can get for each dataset on one line.
Examples
Input
4 50
3
14
15
9
3 21
16
11
2
0 0
Output
48
20
Input
None
Output
None
Submitted Solution:
```
import bisect
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline
def solve():
N, M = map(int, input().split())
if N*M == 0:
return False
P = [0]+[int(input()) for _ in range(N)]
# solve
k = [P[i]+P[j] for i in range(N) for j in range(i, N)]
k = sorted(k)
ret = 0
for tmp in k:
if tmp > M:
break
else:
r = M-tmp
l = bisect.bisect_right(k, r)
tmp += k[l-1]
ret = max(ret, tmp)
return ret
ans = []
while True:
ret = solve()
if ret:
ans.append(ret)
else:
break
print("\n".join(map(str, ans)))
``` | instruction | 0 | 83,312 | 11 | 166,624 |
Yes | output | 1 | 83,312 | 11 | 166,625 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
problem
You have to play a darts game with the following rules.
You can throw up to four arrows towards the target. You don't have to throw all four, you don't have to throw one. The target is divided into N parts. The score P1, ..., PN is written in each part. The total score S of the place where the arrow is stuck is the basis of your score. S is a predetermined score M or less. In the case of, S will be your score as it is. However, if S exceeds M, your score will be 0 points.
Create a program that finds the maximum number of points you can get given the written points and the value of M.
input
The input consists of multiple datasets. Each dataset is given in the following format.
On the first line, the integers N (1 ≤ N ≤ 1000) and M (1 ≤ M ≤ 200000000 = 2 × 108) are written in this order, separated by blanks. In (1 ≤ i ≤ N), Pi (1 ≤ Pi ≤ 100000000 = 108) is written.
Of the scoring data, 20% of the points satisfy N ≤ 100 and 50% of the points satisfy N ≤ 300.
When both N and M are 0, the input is completed. The number of data sets does not exceed 10.
output
Outputs the maximum number of points you can get for each dataset on one line.
Examples
Input
4 50
3
14
15
9
3 21
16
11
2
0 0
Output
48
20
Input
None
Output
None
Submitted Solution:
```
def solve():
while True:
n,m = map(int,input().split())
if not n and not m: break
lst = []
lst2 = []
for i in range(n):
lst.append(int(input()))
for i in lst:
for j in lst:
lst2.append(i + j)
lst2 = list(set(lst2 + lst))
lst2.sort()
ans = 0
def binary(x, left, right):
center = (left + right) // 2
length = right - left + 1
if length <= 0:
return -100
elif length == 1:
if lst2[center] > x:
return center - 1
else:
return center
elif length == 2:
if lst2[center] > x:
return center - 1
else:
return center
elif lst2[center] == x: return x
elif lst2[center] < x: return binary(x, center, right)
elif lst2[center] > x: return binary(x, left, center)
for i in lst2:
if i <= m:
ans = max(ans, i + lst2[binary(m - i, 0, len(lst2) - 1)])
else:
break
print(ans)
solve()
``` | instruction | 0 | 83,315 | 11 | 166,630 |
No | output | 1 | 83,315 | 11 | 166,631 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
problem
You have to play a darts game with the following rules.
You can throw up to four arrows towards the target. You don't have to throw all four, you don't have to throw one. The target is divided into N parts. The score P1, ..., PN is written in each part. The total score S of the place where the arrow is stuck is the basis of your score. S is a predetermined score M or less. In the case of, S will be your score as it is. However, if S exceeds M, your score will be 0 points.
Create a program that finds the maximum number of points you can get given the written points and the value of M.
input
The input consists of multiple datasets. Each dataset is given in the following format.
On the first line, the integers N (1 ≤ N ≤ 1000) and M (1 ≤ M ≤ 200000000 = 2 × 108) are written in this order, separated by blanks. In (1 ≤ i ≤ N), Pi (1 ≤ Pi ≤ 100000000 = 108) is written.
Of the scoring data, 20% of the points satisfy N ≤ 100 and 50% of the points satisfy N ≤ 300.
When both N and M are 0, the input is completed. The number of data sets does not exceed 10.
output
Outputs the maximum number of points you can get for each dataset on one line.
Examples
Input
4 50
3
14
15
9
3 21
16
11
2
0 0
Output
48
20
Input
None
Output
None
Submitted Solution:
```
# -*- coding: utf-8 -*-
"""
Created on Mon May 7 22:55:31 2018
@author: maezawa
"""
def search(p, m, i):
if i == 1:
if m<p[0]:
return -1
for j, k in enumerate(p):
if k>m:
return p[j-1]
elif j==n-1:
return p[n-1]
else:
dif = 2*10**8
for j, k in enumerate(p):
if m-k<0:
break
a = search(p, m-k, i-1)
#print(m-k, a, i-1)
if m-k-a < dif:
dif = m-k-a
return m-dif
while True:
p = []
n, m = list(map(int, input().split()))
if n==0 and m==0:
break
for i in range(n):
p.append(int(input()))
p.sort()
dif = 2*10**8
for i in range(1,5):
a = search(p, m, i)
if a<0:
continue
#print("outer",i,a)
if m-a < dif:
dif = m-a
print(m-dif)
``` | instruction | 0 | 83,317 | 11 | 166,634 |
No | output | 1 | 83,317 | 11 | 166,635 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Yui Hirasawa, who attends private Sakuragaoka Girls' High School, has to make a career hope by the day after tomorrow, but the trouble is that she hasn't decided anything yet. When I consulted with my friend Wa, I knew that my first choice was K University, so I consulted with my career guidance teacher to see if I could join K University.
As a career guidance teacher who was consulted, you decided to refer to Yui's final exam results in order to predict whether Yui would be able to enter K University. However, Yui's grades are greatly affected by whether or not he wins the exam, so he decided to check the best and worst scores of the final exams in the past. The data of the past final exams only remained for each score of the five subjects, and the total score of the exam did not remain. Therefore, your job is to write a program that takes the score data of each exam as input and outputs the score of the best time and the score of the worst time in the past final exams.
Notes on Test Cases
Multiple datasets are given in the above input format. Create a program that outputs each data set in the above output format.
When n is 0, it indicates the end of input.
<!-
Input
n
s11 s12 s13 s14 s15
...
sn1 sn2 sn3 sn4 sn5
n is the number of tests taken so far. The number of tests is 1 or more and 100 or less. The next n lines are given scores for 5 subjects in each exam. The range of points is an integer between 0 and 100.
Output
Output the highest and lowest points in one line. Separate the highest and lowest points with a single space and do not include any other characters.
Examples
Input
3
49 50 87 78 41
27 61 100 45 84
28 88 40 95 66
2
100 100 100 100 100
0 0 0 0 0
1
89 90 85 93 82
0
Output
317 305
500 0
439 439
Input
3
49 50 87 78 41
27 61 100 45 84
28 88 40 95 66
Output
317 305
Input
2
100 100 100 100 100
0 0 0 0 0
Output
500 0
Input
1
89 90 85 93 82
Output
439 439
Submitted Solution:
```
while True:
n = int(input())
if n == 0:
break
[print("{} {}".format(max(x), min(x))) for x in [[sum(map(int, input().split())) for i in range(n)]]]
``` | instruction | 0 | 83,335 | 11 | 166,670 |
Yes | output | 1 | 83,335 | 11 | 166,671 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Yui Hirasawa, who attends private Sakuragaoka Girls' High School, has to make a career hope by the day after tomorrow, but the trouble is that she hasn't decided anything yet. When I consulted with my friend Wa, I knew that my first choice was K University, so I consulted with my career guidance teacher to see if I could join K University.
As a career guidance teacher who was consulted, you decided to refer to Yui's final exam results in order to predict whether Yui would be able to enter K University. However, Yui's grades are greatly affected by whether or not he wins the exam, so he decided to check the best and worst scores of the final exams in the past. The data of the past final exams only remained for each score of the five subjects, and the total score of the exam did not remain. Therefore, your job is to write a program that takes the score data of each exam as input and outputs the score of the best time and the score of the worst time in the past final exams.
Notes on Test Cases
Multiple datasets are given in the above input format. Create a program that outputs each data set in the above output format.
When n is 0, it indicates the end of input.
<!-
Input
n
s11 s12 s13 s14 s15
...
sn1 sn2 sn3 sn4 sn5
n is the number of tests taken so far. The number of tests is 1 or more and 100 or less. The next n lines are given scores for 5 subjects in each exam. The range of points is an integer between 0 and 100.
Output
Output the highest and lowest points in one line. Separate the highest and lowest points with a single space and do not include any other characters.
Examples
Input
3
49 50 87 78 41
27 61 100 45 84
28 88 40 95 66
2
100 100 100 100 100
0 0 0 0 0
1
89 90 85 93 82
0
Output
317 305
500 0
439 439
Input
3
49 50 87 78 41
27 61 100 45 84
28 88 40 95 66
Output
317 305
Input
2
100 100 100 100 100
0 0 0 0 0
Output
500 0
Input
1
89 90 85 93 82
Output
439 439
Submitted Solution:
```
while True:
n = int(input())
if n == 0:break
lst = [sum(map(int, input().split())) for _ in range(n)]
print(max(lst), min(lst))
``` | instruction | 0 | 83,336 | 11 | 166,672 |
Yes | output | 1 | 83,336 | 11 | 166,673 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Yui Hirasawa, who attends private Sakuragaoka Girls' High School, has to make a career hope by the day after tomorrow, but the trouble is that she hasn't decided anything yet. When I consulted with my friend Wa, I knew that my first choice was K University, so I consulted with my career guidance teacher to see if I could join K University.
As a career guidance teacher who was consulted, you decided to refer to Yui's final exam results in order to predict whether Yui would be able to enter K University. However, Yui's grades are greatly affected by whether or not he wins the exam, so he decided to check the best and worst scores of the final exams in the past. The data of the past final exams only remained for each score of the five subjects, and the total score of the exam did not remain. Therefore, your job is to write a program that takes the score data of each exam as input and outputs the score of the best time and the score of the worst time in the past final exams.
Notes on Test Cases
Multiple datasets are given in the above input format. Create a program that outputs each data set in the above output format.
When n is 0, it indicates the end of input.
<!-
Input
n
s11 s12 s13 s14 s15
...
sn1 sn2 sn3 sn4 sn5
n is the number of tests taken so far. The number of tests is 1 or more and 100 or less. The next n lines are given scores for 5 subjects in each exam. The range of points is an integer between 0 and 100.
Output
Output the highest and lowest points in one line. Separate the highest and lowest points with a single space and do not include any other characters.
Examples
Input
3
49 50 87 78 41
27 61 100 45 84
28 88 40 95 66
2
100 100 100 100 100
0 0 0 0 0
1
89 90 85 93 82
0
Output
317 305
500 0
439 439
Input
3
49 50 87 78 41
27 61 100 45 84
28 88 40 95 66
Output
317 305
Input
2
100 100 100 100 100
0 0 0 0 0
Output
500 0
Input
1
89 90 85 93 82
Output
439 439
Submitted Solution:
```
while True:
n = int(input())
if n == 0:
break
total = []
for _ in range(n):
total.append(sum(list(map(int,input().split()))))
total.sort()
print(total[-1],total[0])
``` | instruction | 0 | 83,337 | 11 | 166,674 |
Yes | output | 1 | 83,337 | 11 | 166,675 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Yui Hirasawa, who attends private Sakuragaoka Girls' High School, has to make a career hope by the day after tomorrow, but the trouble is that she hasn't decided anything yet. When I consulted with my friend Wa, I knew that my first choice was K University, so I consulted with my career guidance teacher to see if I could join K University.
As a career guidance teacher who was consulted, you decided to refer to Yui's final exam results in order to predict whether Yui would be able to enter K University. However, Yui's grades are greatly affected by whether or not he wins the exam, so he decided to check the best and worst scores of the final exams in the past. The data of the past final exams only remained for each score of the five subjects, and the total score of the exam did not remain. Therefore, your job is to write a program that takes the score data of each exam as input and outputs the score of the best time and the score of the worst time in the past final exams.
Notes on Test Cases
Multiple datasets are given in the above input format. Create a program that outputs each data set in the above output format.
When n is 0, it indicates the end of input.
<!-
Input
n
s11 s12 s13 s14 s15
...
sn1 sn2 sn3 sn4 sn5
n is the number of tests taken so far. The number of tests is 1 or more and 100 or less. The next n lines are given scores for 5 subjects in each exam. The range of points is an integer between 0 and 100.
Output
Output the highest and lowest points in one line. Separate the highest and lowest points with a single space and do not include any other characters.
Examples
Input
3
49 50 87 78 41
27 61 100 45 84
28 88 40 95 66
2
100 100 100 100 100
0 0 0 0 0
1
89 90 85 93 82
0
Output
317 305
500 0
439 439
Input
3
49 50 87 78 41
27 61 100 45 84
28 88 40 95 66
Output
317 305
Input
2
100 100 100 100 100
0 0 0 0 0
Output
500 0
Input
1
89 90 85 93 82
Output
439 439
Submitted Solution:
```
#0が来るまで回数の入力を繰り返す
while True:
j = int(input())
if j == 0:break
#点数を合計し、一番小さいかずと、一番大きい数を出力する
else:
num_list = []
for _ in range(j):
line = list(map(int,input().split()))
num_list.append(sum(line))
print(str(max(num_list)) + " " + str(min(num_list)))
``` | instruction | 0 | 83,338 | 11 | 166,676 |
Yes | output | 1 | 83,338 | 11 | 166,677 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Yui Hirasawa, who attends private Sakuragaoka Girls' High School, has to make a career hope by the day after tomorrow, but the trouble is that she hasn't decided anything yet. When I consulted with my friend Wa, I knew that my first choice was K University, so I consulted with my career guidance teacher to see if I could join K University.
As a career guidance teacher who was consulted, you decided to refer to Yui's final exam results in order to predict whether Yui would be able to enter K University. However, Yui's grades are greatly affected by whether or not he wins the exam, so he decided to check the best and worst scores of the final exams in the past. The data of the past final exams only remained for each score of the five subjects, and the total score of the exam did not remain. Therefore, your job is to write a program that takes the score data of each exam as input and outputs the score of the best time and the score of the worst time in the past final exams.
Notes on Test Cases
Multiple datasets are given in the above input format. Create a program that outputs each data set in the above output format.
When n is 0, it indicates the end of input.
<!-
Input
n
s11 s12 s13 s14 s15
...
sn1 sn2 sn3 sn4 sn5
n is the number of tests taken so far. The number of tests is 1 or more and 100 or less. The next n lines are given scores for 5 subjects in each exam. The range of points is an integer between 0 and 100.
Output
Output the highest and lowest points in one line. Separate the highest and lowest points with a single space and do not include any other characters.
Examples
Input
3
49 50 87 78 41
27 61 100 45 84
28 88 40 95 66
2
100 100 100 100 100
0 0 0 0 0
1
89 90 85 93 82
0
Output
317 305
500 0
439 439
Input
3
49 50 87 78 41
27 61 100 45 84
28 88 40 95 66
Output
317 305
Input
2
100 100 100 100 100
0 0 0 0 0
Output
500 0
Input
1
89 90 85 93 82
Output
439 439
Submitted Solution:
```
["{} {}".format(max(x), min(x)) for x in [[sum(map(int, input().split())) for _ in range(int(input()))]]]
``` | instruction | 0 | 83,339 | 11 | 166,678 |
No | output | 1 | 83,339 | 11 | 166,679 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Yui Hirasawa, who attends private Sakuragaoka Girls' High School, has to make a career hope by the day after tomorrow, but the trouble is that she hasn't decided anything yet. When I consulted with my friend Wa, I knew that my first choice was K University, so I consulted with my career guidance teacher to see if I could join K University.
As a career guidance teacher who was consulted, you decided to refer to Yui's final exam results in order to predict whether Yui would be able to enter K University. However, Yui's grades are greatly affected by whether or not he wins the exam, so he decided to check the best and worst scores of the final exams in the past. The data of the past final exams only remained for each score of the five subjects, and the total score of the exam did not remain. Therefore, your job is to write a program that takes the score data of each exam as input and outputs the score of the best time and the score of the worst time in the past final exams.
Notes on Test Cases
Multiple datasets are given in the above input format. Create a program that outputs each data set in the above output format.
When n is 0, it indicates the end of input.
<!-
Input
n
s11 s12 s13 s14 s15
...
sn1 sn2 sn3 sn4 sn5
n is the number of tests taken so far. The number of tests is 1 or more and 100 or less. The next n lines are given scores for 5 subjects in each exam. The range of points is an integer between 0 and 100.
Output
Output the highest and lowest points in one line. Separate the highest and lowest points with a single space and do not include any other characters.
Examples
Input
3
49 50 87 78 41
27 61 100 45 84
28 88 40 95 66
2
100 100 100 100 100
0 0 0 0 0
1
89 90 85 93 82
0
Output
317 305
500 0
439 439
Input
3
49 50 87 78 41
27 61 100 45 84
28 88 40 95 66
Output
317 305
Input
2
100 100 100 100 100
0 0 0 0 0
Output
500 0
Input
1
89 90 85 93 82
Output
439 439
Submitted Solution:
```
[print("{} {}".format(max(x), min(x))) for x in [[sum(map(int, input().split())) for _ in range(int(input()))]]]
``` | instruction | 0 | 83,340 | 11 | 166,680 |
No | output | 1 | 83,340 | 11 | 166,681 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
A TV show called "Guess a number!" is gathering popularity. The whole Berland, the old and the young, are watching the show.
The rules are simple. The host thinks of an integer y and the participants guess it by asking questions to the host. There are four types of acceptable questions:
* Is it true that y is strictly larger than number x?
* Is it true that y is strictly smaller than number x?
* Is it true that y is larger than or equal to number x?
* Is it true that y is smaller than or equal to number x?
On each question the host answers truthfully, "yes" or "no".
Given the sequence of questions and answers, find any integer value of y that meets the criteria of all answers. If there isn't such value, print "Impossible".
Input
The first line of the input contains a single integer n (1 ≤ n ≤ 10000) — the number of questions (and answers). Next n lines each contain one question and one answer to it. The format of each line is like that: "sign x answer", where the sign is:
* ">" (for the first type queries),
* "<" (for the second type queries),
* ">=" (for the third type queries),
* "<=" (for the fourth type queries).
All values of x are integer and meet the inequation - 109 ≤ x ≤ 109. The answer is an English letter "Y" (for "yes") or "N" (for "no").
Consequtive elements in lines are separated by a single space.
Output
Print any of such integers y, that the answers to all the queries are correct. The printed number y must meet the inequation - 2·109 ≤ y ≤ 2·109. If there are many answers, print any of them. If such value doesn't exist, print word "Impossible" (without the quotes).
Examples
Input
4
>= 1 Y
< 3 N
<= -3 N
> 55 N
Output
17
Input
2
> 100 Y
< -100 Y
Output
Impossible
Submitted Solution:
```
n = int(input())
left = None
right = None
for i in range(n):
st = input()
op, num, ans = st.split(' ')
num = int(num)
if ans == 'N':
if op == '>=':
op = '<'
elif op == '>':
op = '<='
elif op == '<=':
op = '>'
else:
op = '>='
if op == '>=':
if left == None:
left = num
else:
left = max(left, num)
elif op == '>':
if left == None:
left = num+1
else:
left = max(left, num+1)
elif op == '<=':
if right == None:
right = num
else:
right = min(right, num)
else: # op == '<'
if right == None:
right = num-1
else:
right = min(right, num-1)
if left == None and right == None:
print(0)
elif left == None:
print(right)
elif right == None:
print(left)
elif left > right:
print('Impossible')
else:
print(left)
``` | instruction | 0 | 83,768 | 11 | 167,536 |
Yes | output | 1 | 83,768 | 11 | 167,537 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
A TV show called "Guess a number!" is gathering popularity. The whole Berland, the old and the young, are watching the show.
The rules are simple. The host thinks of an integer y and the participants guess it by asking questions to the host. There are four types of acceptable questions:
* Is it true that y is strictly larger than number x?
* Is it true that y is strictly smaller than number x?
* Is it true that y is larger than or equal to number x?
* Is it true that y is smaller than or equal to number x?
On each question the host answers truthfully, "yes" or "no".
Given the sequence of questions and answers, find any integer value of y that meets the criteria of all answers. If there isn't such value, print "Impossible".
Input
The first line of the input contains a single integer n (1 ≤ n ≤ 10000) — the number of questions (and answers). Next n lines each contain one question and one answer to it. The format of each line is like that: "sign x answer", where the sign is:
* ">" (for the first type queries),
* "<" (for the second type queries),
* ">=" (for the third type queries),
* "<=" (for the fourth type queries).
All values of x are integer and meet the inequation - 109 ≤ x ≤ 109. The answer is an English letter "Y" (for "yes") or "N" (for "no").
Consequtive elements in lines are separated by a single space.
Output
Print any of such integers y, that the answers to all the queries are correct. The printed number y must meet the inequation - 2·109 ≤ y ≤ 2·109. If there are many answers, print any of them. If such value doesn't exist, print word "Impossible" (without the quotes).
Examples
Input
4
>= 1 Y
< 3 N
<= -3 N
> 55 N
Output
17
Input
2
> 100 Y
< -100 Y
Output
Impossible
Submitted Solution:
```
n=int(input())
l=-2*10**9
r=2*10**9
for i in range(n):
s=input().split()
s[1]=int(s[1])
if s[2]=='Y':
if s[0]=='>=':
l=max(l,s[1])
elif s[0]=='>':
l=max(l,s[1]+1)
elif s[0]=='<=':
r=min(r,s[1])
else:
r=min(r,s[1]-1)
else:
if s[0]=='>=':
r=min(r,s[1]-1)
elif s[0]=='>':
r=min(r,s[1])
elif s[0]=='<=':
l=max(l,s[1]+1)
else:
l=max(l,s[1])
if l>r:
print('Impossible')
else:
print(l)
``` | instruction | 0 | 83,769 | 11 | 167,538 |
Yes | output | 1 | 83,769 | 11 | 167,539 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
A TV show called "Guess a number!" is gathering popularity. The whole Berland, the old and the young, are watching the show.
The rules are simple. The host thinks of an integer y and the participants guess it by asking questions to the host. There are four types of acceptable questions:
* Is it true that y is strictly larger than number x?
* Is it true that y is strictly smaller than number x?
* Is it true that y is larger than or equal to number x?
* Is it true that y is smaller than or equal to number x?
On each question the host answers truthfully, "yes" or "no".
Given the sequence of questions and answers, find any integer value of y that meets the criteria of all answers. If there isn't such value, print "Impossible".
Input
The first line of the input contains a single integer n (1 ≤ n ≤ 10000) — the number of questions (and answers). Next n lines each contain one question and one answer to it. The format of each line is like that: "sign x answer", where the sign is:
* ">" (for the first type queries),
* "<" (for the second type queries),
* ">=" (for the third type queries),
* "<=" (for the fourth type queries).
All values of x are integer and meet the inequation - 109 ≤ x ≤ 109. The answer is an English letter "Y" (for "yes") or "N" (for "no").
Consequtive elements in lines are separated by a single space.
Output
Print any of such integers y, that the answers to all the queries are correct. The printed number y must meet the inequation - 2·109 ≤ y ≤ 2·109. If there are many answers, print any of them. If such value doesn't exist, print word "Impossible" (without the quotes).
Examples
Input
4
>= 1 Y
< 3 N
<= -3 N
> 55 N
Output
17
Input
2
> 100 Y
< -100 Y
Output
Impossible
Submitted Solution:
```
n = int(input())
questions = []
for _ in range(n):
questions.append(input())
lower_bound, upper_bound = None, None
for q in questions:
bound = int(q.split()[1])
if (q.startswith('>') and q.endswith('Y')) or (q.startswith('<') and q.endswith('N')):
if ('Y' in q and '=' not in q) or ('N' in q and '=' in q):
bound += 1
lower_bound = bound if lower_bound == None else max(bound, lower_bound)
else:
if ('Y' in q and '=' not in q) or ('N' in q and '=' in q):
bound -= 1
upper_bound = bound if upper_bound == None else min(bound, upper_bound)
if lower_bound != None and upper_bound != None and lower_bound > upper_bound:
print('Impossible')
else:
print(lower_bound if lower_bound != None else upper_bound)
``` | instruction | 0 | 83,770 | 11 | 167,540 |
Yes | output | 1 | 83,770 | 11 | 167,541 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
A TV show called "Guess a number!" is gathering popularity. The whole Berland, the old and the young, are watching the show.
The rules are simple. The host thinks of an integer y and the participants guess it by asking questions to the host. There are four types of acceptable questions:
* Is it true that y is strictly larger than number x?
* Is it true that y is strictly smaller than number x?
* Is it true that y is larger than or equal to number x?
* Is it true that y is smaller than or equal to number x?
On each question the host answers truthfully, "yes" or "no".
Given the sequence of questions and answers, find any integer value of y that meets the criteria of all answers. If there isn't such value, print "Impossible".
Input
The first line of the input contains a single integer n (1 ≤ n ≤ 10000) — the number of questions (and answers). Next n lines each contain one question and one answer to it. The format of each line is like that: "sign x answer", where the sign is:
* ">" (for the first type queries),
* "<" (for the second type queries),
* ">=" (for the third type queries),
* "<=" (for the fourth type queries).
All values of x are integer and meet the inequation - 109 ≤ x ≤ 109. The answer is an English letter "Y" (for "yes") or "N" (for "no").
Consequtive elements in lines are separated by a single space.
Output
Print any of such integers y, that the answers to all the queries are correct. The printed number y must meet the inequation - 2·109 ≤ y ≤ 2·109. If there are many answers, print any of them. If such value doesn't exist, print word "Impossible" (without the quotes).
Examples
Input
4
>= 1 Y
< 3 N
<= -3 N
> 55 N
Output
17
Input
2
> 100 Y
< -100 Y
Output
Impossible
Submitted Solution:
```
def reverse(op):
a = ['>=', '>', '<=', '<']
b = ['<', '<=', '>', '>=']
indx = a.index(op)
return b[indx]
x = int(input())
minx = -2 * 10**9
maxx = 2 * 10**9
for i in range(x):
guess = input().split(' ')
if guess[2] == 'N':
op = reverse(guess[0])
else:
op = guess[0]
comp = int(guess[1])
if op == '>=':
minx = max(minx, comp)
elif op == '>':
minx = max(minx, comp + 1)
elif op == '<=':
maxx = min(maxx, comp)
else:
maxx = min(maxx, comp - 1)
if minx > maxx:
print("Impossible")
else:
print(minx)
``` | instruction | 0 | 83,771 | 11 | 167,542 |
Yes | output | 1 | 83,771 | 11 | 167,543 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
A TV show called "Guess a number!" is gathering popularity. The whole Berland, the old and the young, are watching the show.
The rules are simple. The host thinks of an integer y and the participants guess it by asking questions to the host. There are four types of acceptable questions:
* Is it true that y is strictly larger than number x?
* Is it true that y is strictly smaller than number x?
* Is it true that y is larger than or equal to number x?
* Is it true that y is smaller than or equal to number x?
On each question the host answers truthfully, "yes" or "no".
Given the sequence of questions and answers, find any integer value of y that meets the criteria of all answers. If there isn't such value, print "Impossible".
Input
The first line of the input contains a single integer n (1 ≤ n ≤ 10000) — the number of questions (and answers). Next n lines each contain one question and one answer to it. The format of each line is like that: "sign x answer", where the sign is:
* ">" (for the first type queries),
* "<" (for the second type queries),
* ">=" (for the third type queries),
* "<=" (for the fourth type queries).
All values of x are integer and meet the inequation - 109 ≤ x ≤ 109. The answer is an English letter "Y" (for "yes") or "N" (for "no").
Consequtive elements in lines are separated by a single space.
Output
Print any of such integers y, that the answers to all the queries are correct. The printed number y must meet the inequation - 2·109 ≤ y ≤ 2·109. If there are many answers, print any of them. If such value doesn't exist, print word "Impossible" (without the quotes).
Examples
Input
4
>= 1 Y
< 3 N
<= -3 N
> 55 N
Output
17
Input
2
> 100 Y
< -100 Y
Output
Impossible
Submitted Solution:
```
n = int(input())
MAX = 1000000000
minimum, maximum, temp_max, temp_min = [0]*4
i = 0
while i < n:
question = [x for x in input().split()]
if question[2] == 'Y':
if question[0] == ">=":
minimum = int(question[1])
maximum = MAX
elif question[0] == ">":
minimum = int(question[1])+1
maximum = MAX
elif question[0] == "<=":
minimum = -MAX
maximum = int(question[1])
else:
minimum = -MAX
maximum = int(question[1])-1
else:
if question[0] == ">=":
minimum = -MAX
maximum = int(question[1])
elif question[0] == ">":
minimum = -MAX
maximum = int(question[1])
elif question[0] == "<=":
minimum = int(question[1]) + 1
maximum = MAX
else:
minimum = int(question[1])
maximum = MAX
if i == 0:
temp_max = maximum
temp_min = minimum
else:
temp_max = min(temp_max, maximum)
temp_min = max(temp_min, minimum)
if temp_max < temp_min and abs(temp_min) <= MAX and abs(temp_max) <= MAX:
print("Impossible")
exit()
i += 1
if minimum != -MAX:
print(temp_min)
else:
print(temp_max)
``` | instruction | 0 | 83,772 | 11 | 167,544 |
No | output | 1 | 83,772 | 11 | 167,545 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
A TV show called "Guess a number!" is gathering popularity. The whole Berland, the old and the young, are watching the show.
The rules are simple. The host thinks of an integer y and the participants guess it by asking questions to the host. There are four types of acceptable questions:
* Is it true that y is strictly larger than number x?
* Is it true that y is strictly smaller than number x?
* Is it true that y is larger than or equal to number x?
* Is it true that y is smaller than or equal to number x?
On each question the host answers truthfully, "yes" or "no".
Given the sequence of questions and answers, find any integer value of y that meets the criteria of all answers. If there isn't such value, print "Impossible".
Input
The first line of the input contains a single integer n (1 ≤ n ≤ 10000) — the number of questions (and answers). Next n lines each contain one question and one answer to it. The format of each line is like that: "sign x answer", where the sign is:
* ">" (for the first type queries),
* "<" (for the second type queries),
* ">=" (for the third type queries),
* "<=" (for the fourth type queries).
All values of x are integer and meet the inequation - 109 ≤ x ≤ 109. The answer is an English letter "Y" (for "yes") or "N" (for "no").
Consequtive elements in lines are separated by a single space.
Output
Print any of such integers y, that the answers to all the queries are correct. The printed number y must meet the inequation - 2·109 ≤ y ≤ 2·109. If there are many answers, print any of them. If such value doesn't exist, print word "Impossible" (without the quotes).
Examples
Input
4
>= 1 Y
< 3 N
<= -3 N
> 55 N
Output
17
Input
2
> 100 Y
< -100 Y
Output
Impossible
Submitted Solution:
```
import random
import math
def getnum(signs, numbers, answers):
number = 0
ll = min(numbers) ** 2
ul = max(numbers)**2
for i in range(0, len(signs)):
if answers[i] == " Y":
if signs[i] == "<":
ul = numbers[i]
if signs[i] == ">":
ll = numbers[i]
if signs[i] == ">=":
if numbers[i] > ll:
ll = numbers[i] + 1
if signs[i] == "<=":
if numbers[i] < ul:
ul = numbers[i] + 1
if answers[i] == " N":
if signs[i] == "<":
if numbers[i]> ll:
ll = numbers[i]
if signs[i] == ">":
if numbers[i] < ul:
ul = numbers[i]
if signs[i] == ">=":
if numbers[i] > ll:
ul = numbers[i] + 1
if signs[i] == "<=":
if numbers[i] < ul:
ll = numbers[i] + 1
try:
number = random.randint(ll, ul)
except:
number = "Impossible"
print(number)
number = int(input())
i = 0
ins = []
while i < number:
ui = input()
ins += [ui,]
i += 1
signs = []
numbers = []
for i in ins:
sign = i[:i.index(" ")]
signs += [sign,]
for k in ins:
number = ""
if k[2] == "-" or k[3] == "-":
number += "-"
for j in k:
index =k.index(j)
if j.isdigit():
number += j
numbers += [int(number),]
answers = []
for y in ins:
curr = y[y.index(" ") +1 :]
curr1 = curr[curr.index(" ") : ]
answers += [curr1,]
getnum(signs, numbers, answers)
``` | instruction | 0 | 83,773 | 11 | 167,546 |
No | output | 1 | 83,773 | 11 | 167,547 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
A TV show called "Guess a number!" is gathering popularity. The whole Berland, the old and the young, are watching the show.
The rules are simple. The host thinks of an integer y and the participants guess it by asking questions to the host. There are four types of acceptable questions:
* Is it true that y is strictly larger than number x?
* Is it true that y is strictly smaller than number x?
* Is it true that y is larger than or equal to number x?
* Is it true that y is smaller than or equal to number x?
On each question the host answers truthfully, "yes" or "no".
Given the sequence of questions and answers, find any integer value of y that meets the criteria of all answers. If there isn't such value, print "Impossible".
Input
The first line of the input contains a single integer n (1 ≤ n ≤ 10000) — the number of questions (and answers). Next n lines each contain one question and one answer to it. The format of each line is like that: "sign x answer", where the sign is:
* ">" (for the first type queries),
* "<" (for the second type queries),
* ">=" (for the third type queries),
* "<=" (for the fourth type queries).
All values of x are integer and meet the inequation - 109 ≤ x ≤ 109. The answer is an English letter "Y" (for "yes") or "N" (for "no").
Consequtive elements in lines are separated by a single space.
Output
Print any of such integers y, that the answers to all the queries are correct. The printed number y must meet the inequation - 2·109 ≤ y ≤ 2·109. If there are many answers, print any of them. If such value doesn't exist, print word "Impossible" (without the quotes).
Examples
Input
4
>= 1 Y
< 3 N
<= -3 N
> 55 N
Output
17
Input
2
> 100 Y
< -100 Y
Output
Impossible
Submitted Solution:
```
n=int(input())
l=-(10**9)-3
r=(10**9)+3
for i in range(n):
sign,x,ans=map(str,input().split())
x=int(x)
if (sign==">" and ans=="Y") or (sign=="<=" and ans=="N"):
if x>l:
l=x-1
elif (sign=="<" and ans=="Y") or (sign==">=" and ans=="N"):
if x<r:
r=x+1
elif (sign==">=" and ans=="Y") or (sign=="<" and ans=="N"):
if x>l:
l=x
elif (sign=="<=" and ans=="Y") or (sign==">" and ans=="N"):
if x<r:
r=x
if l<=r:
print(l)
else:
print("Impossible")
``` | instruction | 0 | 83,774 | 11 | 167,548 |
No | output | 1 | 83,774 | 11 | 167,549 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
A TV show called "Guess a number!" is gathering popularity. The whole Berland, the old and the young, are watching the show.
The rules are simple. The host thinks of an integer y and the participants guess it by asking questions to the host. There are four types of acceptable questions:
* Is it true that y is strictly larger than number x?
* Is it true that y is strictly smaller than number x?
* Is it true that y is larger than or equal to number x?
* Is it true that y is smaller than or equal to number x?
On each question the host answers truthfully, "yes" or "no".
Given the sequence of questions and answers, find any integer value of y that meets the criteria of all answers. If there isn't such value, print "Impossible".
Input
The first line of the input contains a single integer n (1 ≤ n ≤ 10000) — the number of questions (and answers). Next n lines each contain one question and one answer to it. The format of each line is like that: "sign x answer", where the sign is:
* ">" (for the first type queries),
* "<" (for the second type queries),
* ">=" (for the third type queries),
* "<=" (for the fourth type queries).
All values of x are integer and meet the inequation - 109 ≤ x ≤ 109. The answer is an English letter "Y" (for "yes") or "N" (for "no").
Consequtive elements in lines are separated by a single space.
Output
Print any of such integers y, that the answers to all the queries are correct. The printed number y must meet the inequation - 2·109 ≤ y ≤ 2·109. If there are many answers, print any of them. If such value doesn't exist, print word "Impossible" (without the quotes).
Examples
Input
4
>= 1 Y
< 3 N
<= -3 N
> 55 N
Output
17
Input
2
> 100 Y
< -100 Y
Output
Impossible
Submitted Solution:
```
left_border_inclusive = float("-inf")
right_border_inclusive = float("inf")
inverse_signs = {
">": "<=",
"<=": ">",
">=": "<",
"<": ">="
}
NUMBERS = int(input())
EXTRA_FINISH = False
sign, value = None, None
for _ in range(NUMBERS):
sign, value, answer = input().split(' ')
value = int(value)
if answer == "N":
sign = inverse_signs[sign]
if sign == ">":
if value >= right_border_inclusive:
EXTRA_FINISH = True
break
left_border_inclusive = max(left_border_inclusive, value + 1)
elif sign == ">=":
if value > right_border_inclusive:
EXTRA_FINISH = True
break
left_border_inclusive = max(left_border_inclusive, value)
elif sign == "<":
if value <= left_border_inclusive:
EXTRA_FINISH = True
break
right_border_inclusive = max(right_border_inclusive, value-1)
elif sign == "<=":
if value < left_border_inclusive:
EXTRA_FINISH = True
break
right_border_inclusive = max(right_border_inclusive, value)
if not EXTRA_FINISH:
print(left_border_inclusive)
else:
print("Impossible")
``` | instruction | 0 | 83,775 | 11 | 167,550 |
No | output | 1 | 83,775 | 11 | 167,551 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Alexandra has a paper strip with n numbers on it. Let's call them ai from left to right.
Now Alexandra wants to split it into some pieces (possibly 1). For each piece of strip, it must satisfy:
* Each piece should contain at least l numbers.
* The difference between the maximal and the minimal number on the piece should be at most s.
Please help Alexandra to find the minimal number of pieces meeting the condition above.
Input
The first line contains three space-separated integers n, s, l (1 ≤ n ≤ 105, 0 ≤ s ≤ 109, 1 ≤ l ≤ 105).
The second line contains n integers ai separated by spaces ( - 109 ≤ ai ≤ 109).
Output
Output the minimal number of strip pieces.
If there are no ways to split the strip, output -1.
Examples
Input
7 2 2
1 3 1 2 4 1 2
Output
3
Input
7 2 2
1 100 1 100 1 100 1
Output
-1
Note
For the first sample, we can split the strip into 3 pieces: [1, 3, 1], [2, 4], [1, 2].
For the second sample, we can't let 1 and 100 be on the same piece, so no solution exists.
Submitted Solution:
```
n,s,l = [int(s) for s in input().split()]
a = [int(s) for s in input().split()]
pieces = []
m = 0
i = 1
tmpmin = a[0]
tmpmax = a[0]
tmppc = [a[0]]
while i<n:
if abs(a[i]-tmpmin)<=s and abs(a[i]-tmpmax)<=s:
tmppc.append(a[i])
if a[i]<tmpmin: tmpmin=a[i]
elif a[i]>tmpmax: tmpmax = a[i]
else:
pieces.append(tmppc)
tmppc = [a[i]]
tmpmin = a[i]
tmpmax = a[i]
i += 1
pieces.append(tmppc)
fail = False
for j in range(len(pieces)):
if len(pieces[j])<l:
if j>0:
prevpc = pieces[j-1]
minj = min(pieces[j])
maxj = max(pieces[j])
while len(pieces[j])<l:
tmp = prevpc.pop()
if abs(tmp-minj)<=s and abs(tmp-maxj)<=s:
pieces[j].insert(0,tmp)
else:
fail = True
break
if len(prevpc)<l:
fail = True
break
else:
fail = True
break
if not fail:
print(len(pieces))
else:
print(-1)
``` | instruction | 0 | 83,781 | 11 | 167,562 |
No | output | 1 | 83,781 | 11 | 167,563 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Alexandra has a paper strip with n numbers on it. Let's call them ai from left to right.
Now Alexandra wants to split it into some pieces (possibly 1). For each piece of strip, it must satisfy:
* Each piece should contain at least l numbers.
* The difference between the maximal and the minimal number on the piece should be at most s.
Please help Alexandra to find the minimal number of pieces meeting the condition above.
Input
The first line contains three space-separated integers n, s, l (1 ≤ n ≤ 105, 0 ≤ s ≤ 109, 1 ≤ l ≤ 105).
The second line contains n integers ai separated by spaces ( - 109 ≤ ai ≤ 109).
Output
Output the minimal number of strip pieces.
If there are no ways to split the strip, output -1.
Examples
Input
7 2 2
1 3 1 2 4 1 2
Output
3
Input
7 2 2
1 100 1 100 1 100 1
Output
-1
Note
For the first sample, we can split the strip into 3 pieces: [1, 3, 1], [2, 4], [1, 2].
For the second sample, we can't let 1 and 100 be on the same piece, so no solution exists.
Submitted Solution:
```
n,s,l = [int(s) for s in input().split()]
a = [int(s) for s in input().split()]
pieces = []
m = 0
i = 1
tmpmin = a[0]
tmpmax = a[0]
tmppc = [a[0]]
while i<n:
if abs(a[i]-tmpmin)<=s and abs(a[i]-tmpmax)<=s:
tmppc.append(a[i])
if a[i]<tmpmin: tmpmin=a[i]
elif a[i]>tmpmax: tmpmax = a[i]
else:
pieces.append(tmppc)
tmppc = [a[i]]
tmpmin = a[i]
tmpmax = a[i]
i += 1
pieces.append(tmppc)
fail = False
for j in range(len(pieces)):
if len(pieces[j])<l:
if j>0:
prevpc = pieces[j-1]
minj = min(pieces[j])
maxj = max(pieces[j])
while len(pieces[j])<l:
tmp = prevpc.pop()
if abs(tmp-minj)<=s and abs(tmp-maxj)<=s:
pieces[j].insert(0,tmp)
if tmp<minj: minj=tmp
elif tmp>maxj: maxj=tmp
else:
fail = True
break
if len(prevpc)<l:
fail = True
break
else:
fail = True
break
if not fail:
print(len(pieces))
else:
print(-1)
``` | instruction | 0 | 83,782 | 11 | 167,564 |
No | output | 1 | 83,782 | 11 | 167,565 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Alexandra has a paper strip with n numbers on it. Let's call them ai from left to right.
Now Alexandra wants to split it into some pieces (possibly 1). For each piece of strip, it must satisfy:
* Each piece should contain at least l numbers.
* The difference between the maximal and the minimal number on the piece should be at most s.
Please help Alexandra to find the minimal number of pieces meeting the condition above.
Input
The first line contains three space-separated integers n, s, l (1 ≤ n ≤ 105, 0 ≤ s ≤ 109, 1 ≤ l ≤ 105).
The second line contains n integers ai separated by spaces ( - 109 ≤ ai ≤ 109).
Output
Output the minimal number of strip pieces.
If there are no ways to split the strip, output -1.
Examples
Input
7 2 2
1 3 1 2 4 1 2
Output
3
Input
7 2 2
1 100 1 100 1 100 1
Output
-1
Note
For the first sample, we can split the strip into 3 pieces: [1, 3, 1], [2, 4], [1, 2].
For the second sample, we can't let 1 and 100 be on the same piece, so no solution exists.
Submitted Solution:
```
n,s,l = [int(s) for s in input().split()]
a = [int(s) for s in input().split()]
pieces = []
m = 0
i = 1
tmpmin = a[0]
tmpmax = a[0]
tmppc = [a[0]]
while i<n:
if abs(a[i]-tmpmin)<=s and abs(a[i]-tmpmax)<=s:
tmppc.append(a[i])
if a[i]<tmpmin: tmpmin=a[i]
elif a[i]>tmpmax: tmpmax = a[i]
else:
pieces.append(tmppc)
tmppc = [a[i]]
tmpmin = a[i]
tmpmax = a[i]
i += 1
pieces.append(tmppc)
fail = False
for j in range(len(pieces)):
if len(pieces[j])<l:
if j>0:
prevpc = pieces[j-1]
minj = min(pieces[j])
maxj = max(pieces[j])
while len(pieces[j])<l:
tmp = prevpc.pop()
if abs(tmp-minj)<=s and abs(tmp-maxj)<=s:
pieces[j].append(tmp)
else:
fail = True
break
if len(prevpc)<l:
fail = True
break
else:
fail = True
break
if not fail:
print(len(pieces))
else:
print(-1)
``` | instruction | 0 | 83,783 | 11 | 167,566 |
No | output | 1 | 83,783 | 11 | 167,567 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Recently, Duff has been practicing weight lifting. As a hard practice, Malek gave her a task. He gave her a sequence of weights. Weight of i-th of them is 2wi pounds. In each step, Duff can lift some of the remaining weights and throw them away. She does this until there's no more weight left. Malek asked her to minimize the number of steps.
<image>
Duff is a competitive programming fan. That's why in each step, she can only lift and throw away a sequence of weights 2a1, ..., 2ak if and only if there exists a non-negative integer x such that 2a1 + 2a2 + ... + 2ak = 2x, i. e. the sum of those numbers is a power of two.
Duff is a competitive programming fan, but not a programmer. That's why she asked for your help. Help her minimize the number of steps.
Input
The first line of input contains integer n (1 ≤ n ≤ 106), the number of weights.
The second line contains n integers w1, ..., wn separated by spaces (0 ≤ wi ≤ 106 for each 1 ≤ i ≤ n), the powers of two forming the weights values.
Output
Print the minimum number of steps in a single line.
Examples
Input
5
1 1 2 3 3
Output
2
Input
4
0 1 2 3
Output
4
Note
In the first sample case: One optimal way would be to throw away the first three in the first step and the rest in the second step. Also, it's not possible to do it in one step because their sum is not a power of two.
In the second sample case: The only optimal way is to throw away one weight in each step. It's not possible to do it in less than 4 steps because there's no subset of weights with more than one weight and sum equal to a power of two.
Submitted Solution:
```
# Description of the problem can be found at http://codeforces.com/problemset/problem/587/A
n = int(input())
w = map(int, input().split())
m = 1000001
s = [0] * m
for i in w:
s[i] += 1
ans = 0
z = 0
for i in range(m):
n_s = s[i]+z
z = n_s // 2
ans += n_s % 2
while z > 0:
ans += z % 2
z //= 2
print(ans)
``` | instruction | 0 | 83,803 | 11 | 167,606 |
Yes | output | 1 | 83,803 | 11 | 167,607 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Recently, Duff has been practicing weight lifting. As a hard practice, Malek gave her a task. He gave her a sequence of weights. Weight of i-th of them is 2wi pounds. In each step, Duff can lift some of the remaining weights and throw them away. She does this until there's no more weight left. Malek asked her to minimize the number of steps.
<image>
Duff is a competitive programming fan. That's why in each step, she can only lift and throw away a sequence of weights 2a1, ..., 2ak if and only if there exists a non-negative integer x such that 2a1 + 2a2 + ... + 2ak = 2x, i. e. the sum of those numbers is a power of two.
Duff is a competitive programming fan, but not a programmer. That's why she asked for your help. Help her minimize the number of steps.
Input
The first line of input contains integer n (1 ≤ n ≤ 106), the number of weights.
The second line contains n integers w1, ..., wn separated by spaces (0 ≤ wi ≤ 106 for each 1 ≤ i ≤ n), the powers of two forming the weights values.
Output
Print the minimum number of steps in a single line.
Examples
Input
5
1 1 2 3 3
Output
2
Input
4
0 1 2 3
Output
4
Note
In the first sample case: One optimal way would be to throw away the first three in the first step and the rest in the second step. Also, it's not possible to do it in one step because their sum is not a power of two.
In the second sample case: The only optimal way is to throw away one weight in each step. It's not possible to do it in less than 4 steps because there's no subset of weights with more than one weight and sum equal to a power of two.
Submitted Solution:
```
n=int(input())
l=list(map(int,input().split()))
cnt=[0]*(10**6+100)
for i in l:
cnt[i]+=1
s=0
ans=0
for i in cnt:
s+=i
ans+=s%2
s//=2
print(ans)
``` | instruction | 0 | 83,804 | 11 | 167,608 |
Yes | output | 1 | 83,804 | 11 | 167,609 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Recently, Duff has been practicing weight lifting. As a hard practice, Malek gave her a task. He gave her a sequence of weights. Weight of i-th of them is 2wi pounds. In each step, Duff can lift some of the remaining weights and throw them away. She does this until there's no more weight left. Malek asked her to minimize the number of steps.
<image>
Duff is a competitive programming fan. That's why in each step, she can only lift and throw away a sequence of weights 2a1, ..., 2ak if and only if there exists a non-negative integer x such that 2a1 + 2a2 + ... + 2ak = 2x, i. e. the sum of those numbers is a power of two.
Duff is a competitive programming fan, but not a programmer. That's why she asked for your help. Help her minimize the number of steps.
Input
The first line of input contains integer n (1 ≤ n ≤ 106), the number of weights.
The second line contains n integers w1, ..., wn separated by spaces (0 ≤ wi ≤ 106 for each 1 ≤ i ≤ n), the powers of two forming the weights values.
Output
Print the minimum number of steps in a single line.
Examples
Input
5
1 1 2 3 3
Output
2
Input
4
0 1 2 3
Output
4
Note
In the first sample case: One optimal way would be to throw away the first three in the first step and the rest in the second step. Also, it's not possible to do it in one step because their sum is not a power of two.
In the second sample case: The only optimal way is to throw away one weight in each step. It's not possible to do it in less than 4 steps because there's no subset of weights with more than one weight and sum equal to a power of two.
Submitted Solution:
```
def power_of_two(a):
return True
def main():
n = int(input())
w = list(map(int, input().split()))
flag = True
while flag:
flag = False
for i in range(1, len(w)):
if w[i-1] == w[i]:
w[i] *= 2
del w[i-1]
flag = True
break
print(len(w))
if __name__ == '__main__':
main()
``` | instruction | 0 | 83,807 | 11 | 167,614 |
No | output | 1 | 83,807 | 11 | 167,615 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Recently, Duff has been practicing weight lifting. As a hard practice, Malek gave her a task. He gave her a sequence of weights. Weight of i-th of them is 2wi pounds. In each step, Duff can lift some of the remaining weights and throw them away. She does this until there's no more weight left. Malek asked her to minimize the number of steps.
<image>
Duff is a competitive programming fan. That's why in each step, she can only lift and throw away a sequence of weights 2a1, ..., 2ak if and only if there exists a non-negative integer x such that 2a1 + 2a2 + ... + 2ak = 2x, i. e. the sum of those numbers is a power of two.
Duff is a competitive programming fan, but not a programmer. That's why she asked for your help. Help her minimize the number of steps.
Input
The first line of input contains integer n (1 ≤ n ≤ 106), the number of weights.
The second line contains n integers w1, ..., wn separated by spaces (0 ≤ wi ≤ 106 for each 1 ≤ i ≤ n), the powers of two forming the weights values.
Output
Print the minimum number of steps in a single line.
Examples
Input
5
1 1 2 3 3
Output
2
Input
4
0 1 2 3
Output
4
Note
In the first sample case: One optimal way would be to throw away the first three in the first step and the rest in the second step. Also, it's not possible to do it in one step because their sum is not a power of two.
In the second sample case: The only optimal way is to throw away one weight in each step. It's not possible to do it in less than 4 steps because there's no subset of weights with more than one weight and sum equal to a power of two.
Submitted Solution:
```
n = int(input())
list = map(int, input().split())
N = [0]*1000001
for i in list:
N[i] += 1
ans = 0
temp = 0
for j in range(1000001):
number = N[j] + temp
temp = number // 2
ans += number % 2
while temp > 0:
number = temp
temp //= 2
ans += temp%2
print(ans)
``` | instruction | 0 | 83,810 | 11 | 167,620 |
No | output | 1 | 83,810 | 11 | 167,621 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Kode Festival is an anual contest where the hardest stone in the world is determined. (Kode is a Japanese word for "hardness".)
This year, 2^N stones participated. The hardness of the i-th stone is A_i.
In the contest, stones are thrown at each other in a knockout tournament.
When two stones with hardness X and Y are thrown at each other, the following will happen:
* When X > Y: The stone with hardness Y will be destroyed and eliminated. The hardness of the stone with hardness X will become X-Y.
* When X = Y: One of the stones will be destroyed and eliminated. The hardness of the other stone will remain the same.
* When X < Y: The stone with hardness X will be destroyed and eliminated. The hardness of the stone with hardness Y will become Y-X.
The 2^N stones will fight in a knockout tournament as follows:
1. The following pairs will fight: (the 1-st stone versus the 2-nd stone), (the 3-rd stone versus the 4-th stone), ...
2. The following pairs will fight: (the winner of (1-st versus 2-nd) versus the winner of (3-rd versus 4-th)), (the winner of (5-th versus 6-th) versus the winner of (7-th versus 8-th)), ...
3. And so forth, until there is only one stone remaining.
Determine the eventual hardness of the last stone remaining.
Constraints
* 1 \leq N \leq 18
* 1 \leq A_i \leq 10^9
* A_i is an integer.
Input
The input is given from Standard Input in the following format:
N
A_1
A_2
:
A_{2^N}
Output
Print the eventual hardness of the last stone remaining.
Examples
Input
2
1
3
10
19
Output
7
Input
3
1
3
2
4
6
8
100
104
Output
2
Submitted Solution:
```
# -*- coding: utf-8 -*-
import sys
def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7
K = INT()
N = 2 ** K
A = LIST(N)
while len(A) >= 2:
tmp = []
for i in range(len(A)//2):
a, b = A[i*2], A[i*2+1]
if a == b:
tmp.append(a)
else:
tmp.append(abs(a - b))
A = tmp
print(A[0])
``` | instruction | 0 | 84,084 | 11 | 168,168 |
Yes | output | 1 | 84,084 | 11 | 168,169 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Kode Festival is an anual contest where the hardest stone in the world is determined. (Kode is a Japanese word for "hardness".)
This year, 2^N stones participated. The hardness of the i-th stone is A_i.
In the contest, stones are thrown at each other in a knockout tournament.
When two stones with hardness X and Y are thrown at each other, the following will happen:
* When X > Y: The stone with hardness Y will be destroyed and eliminated. The hardness of the stone with hardness X will become X-Y.
* When X = Y: One of the stones will be destroyed and eliminated. The hardness of the other stone will remain the same.
* When X < Y: The stone with hardness X will be destroyed and eliminated. The hardness of the stone with hardness Y will become Y-X.
The 2^N stones will fight in a knockout tournament as follows:
1. The following pairs will fight: (the 1-st stone versus the 2-nd stone), (the 3-rd stone versus the 4-th stone), ...
2. The following pairs will fight: (the winner of (1-st versus 2-nd) versus the winner of (3-rd versus 4-th)), (the winner of (5-th versus 6-th) versus the winner of (7-th versus 8-th)), ...
3. And so forth, until there is only one stone remaining.
Determine the eventual hardness of the last stone remaining.
Constraints
* 1 \leq N \leq 18
* 1 \leq A_i \leq 10^9
* A_i is an integer.
Input
The input is given from Standard Input in the following format:
N
A_1
A_2
:
A_{2^N}
Output
Print the eventual hardness of the last stone remaining.
Examples
Input
2
1
3
10
19
Output
7
Input
3
1
3
2
4
6
8
100
104
Output
2
Submitted Solution:
```
n = int(input())
a = []
for i in range(2**n):
a.append(int(input()))
for i in range(n):
delta = 2**(i+1)
half = delta // 2
for j in range(0, 2**n, delta):
p = a[j]; q = a[j + half]
if p == q:
continue
else:
a[j] = abs(p - q)
print(a[0])
``` | instruction | 0 | 84,085 | 11 | 168,170 |
Yes | output | 1 | 84,085 | 11 | 168,171 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Kode Festival is an anual contest where the hardest stone in the world is determined. (Kode is a Japanese word for "hardness".)
This year, 2^N stones participated. The hardness of the i-th stone is A_i.
In the contest, stones are thrown at each other in a knockout tournament.
When two stones with hardness X and Y are thrown at each other, the following will happen:
* When X > Y: The stone with hardness Y will be destroyed and eliminated. The hardness of the stone with hardness X will become X-Y.
* When X = Y: One of the stones will be destroyed and eliminated. The hardness of the other stone will remain the same.
* When X < Y: The stone with hardness X will be destroyed and eliminated. The hardness of the stone with hardness Y will become Y-X.
The 2^N stones will fight in a knockout tournament as follows:
1. The following pairs will fight: (the 1-st stone versus the 2-nd stone), (the 3-rd stone versus the 4-th stone), ...
2. The following pairs will fight: (the winner of (1-st versus 2-nd) versus the winner of (3-rd versus 4-th)), (the winner of (5-th versus 6-th) versus the winner of (7-th versus 8-th)), ...
3. And so forth, until there is only one stone remaining.
Determine the eventual hardness of the last stone remaining.
Constraints
* 1 \leq N \leq 18
* 1 \leq A_i \leq 10^9
* A_i is an integer.
Input
The input is given from Standard Input in the following format:
N
A_1
A_2
:
A_{2^N}
Output
Print the eventual hardness of the last stone remaining.
Examples
Input
2
1
3
10
19
Output
7
Input
3
1
3
2
4
6
8
100
104
Output
2
Submitted Solution:
```
#!/usr/bin/env python3
n = int(input())
a = [ int(input()) for _ in range(2**n) ]
while len(a) != 1:
b = []
for i in range(0, len(a), 2):
if a[i] == a[i+1]:
b += [ a[i] ]
else:
b += [ abs(a[i] - a[i+1]) ]
a = b
print(*a)
``` | instruction | 0 | 84,086 | 11 | 168,172 |
Yes | output | 1 | 84,086 | 11 | 168,173 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Kode Festival is an anual contest where the hardest stone in the world is determined. (Kode is a Japanese word for "hardness".)
This year, 2^N stones participated. The hardness of the i-th stone is A_i.
In the contest, stones are thrown at each other in a knockout tournament.
When two stones with hardness X and Y are thrown at each other, the following will happen:
* When X > Y: The stone with hardness Y will be destroyed and eliminated. The hardness of the stone with hardness X will become X-Y.
* When X = Y: One of the stones will be destroyed and eliminated. The hardness of the other stone will remain the same.
* When X < Y: The stone with hardness X will be destroyed and eliminated. The hardness of the stone with hardness Y will become Y-X.
The 2^N stones will fight in a knockout tournament as follows:
1. The following pairs will fight: (the 1-st stone versus the 2-nd stone), (the 3-rd stone versus the 4-th stone), ...
2. The following pairs will fight: (the winner of (1-st versus 2-nd) versus the winner of (3-rd versus 4-th)), (the winner of (5-th versus 6-th) versus the winner of (7-th versus 8-th)), ...
3. And so forth, until there is only one stone remaining.
Determine the eventual hardness of the last stone remaining.
Constraints
* 1 \leq N \leq 18
* 1 \leq A_i \leq 10^9
* A_i is an integer.
Input
The input is given from Standard Input in the following format:
N
A_1
A_2
:
A_{2^N}
Output
Print the eventual hardness of the last stone remaining.
Examples
Input
2
1
3
10
19
Output
7
Input
3
1
3
2
4
6
8
100
104
Output
2
Submitted Solution:
```
def solve(A):
if(len(A) == 1):
return A[0]
return solve([abs(A[i]-A[i+1]) for i in range(0,len(A),2)])
n = int(input())
A = []
for i in range(2**n):
A.append(int(input()))
print(solve(A))
``` | instruction | 0 | 84,087 | 11 | 168,174 |
Yes | output | 1 | 84,087 | 11 | 168,175 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Kode Festival is an anual contest where the hardest stone in the world is determined. (Kode is a Japanese word for "hardness".)
This year, 2^N stones participated. The hardness of the i-th stone is A_i.
In the contest, stones are thrown at each other in a knockout tournament.
When two stones with hardness X and Y are thrown at each other, the following will happen:
* When X > Y: The stone with hardness Y will be destroyed and eliminated. The hardness of the stone with hardness X will become X-Y.
* When X = Y: One of the stones will be destroyed and eliminated. The hardness of the other stone will remain the same.
* When X < Y: The stone with hardness X will be destroyed and eliminated. The hardness of the stone with hardness Y will become Y-X.
The 2^N stones will fight in a knockout tournament as follows:
1. The following pairs will fight: (the 1-st stone versus the 2-nd stone), (the 3-rd stone versus the 4-th stone), ...
2. The following pairs will fight: (the winner of (1-st versus 2-nd) versus the winner of (3-rd versus 4-th)), (the winner of (5-th versus 6-th) versus the winner of (7-th versus 8-th)), ...
3. And so forth, until there is only one stone remaining.
Determine the eventual hardness of the last stone remaining.
Constraints
* 1 \leq N \leq 18
* 1 \leq A_i \leq 10^9
* A_i is an integer.
Input
The input is given from Standard Input in the following format:
N
A_1
A_2
:
A_{2^N}
Output
Print the eventual hardness of the last stone remaining.
Examples
Input
2
1
3
10
19
Output
7
Input
3
1
3
2
4
6
8
100
104
Output
2
Submitted Solution:
```
import sys
N = int(sys.stdin.readline().strip())
array = [None for _ in range(2**N)]
for i in range(int(2**N)):
array[i] = int(sys.stdin.readline().strip())
for stage in range(N):
for i in range(int(2**(N-stage-1))):
array[i*2] = abs(array[i*2] - array[i*2+1])
#print(array)
print(array[0])
``` | instruction | 0 | 84,089 | 11 | 168,178 |
No | output | 1 | 84,089 | 11 | 168,179 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Kode Festival is an anual contest where the hardest stone in the world is determined. (Kode is a Japanese word for "hardness".)
This year, 2^N stones participated. The hardness of the i-th stone is A_i.
In the contest, stones are thrown at each other in a knockout tournament.
When two stones with hardness X and Y are thrown at each other, the following will happen:
* When X > Y: The stone with hardness Y will be destroyed and eliminated. The hardness of the stone with hardness X will become X-Y.
* When X = Y: One of the stones will be destroyed and eliminated. The hardness of the other stone will remain the same.
* When X < Y: The stone with hardness X will be destroyed and eliminated. The hardness of the stone with hardness Y will become Y-X.
The 2^N stones will fight in a knockout tournament as follows:
1. The following pairs will fight: (the 1-st stone versus the 2-nd stone), (the 3-rd stone versus the 4-th stone), ...
2. The following pairs will fight: (the winner of (1-st versus 2-nd) versus the winner of (3-rd versus 4-th)), (the winner of (5-th versus 6-th) versus the winner of (7-th versus 8-th)), ...
3. And so forth, until there is only one stone remaining.
Determine the eventual hardness of the last stone remaining.
Constraints
* 1 \leq N \leq 18
* 1 \leq A_i \leq 10^9
* A_i is an integer.
Input
The input is given from Standard Input in the following format:
N
A_1
A_2
:
A_{2^N}
Output
Print the eventual hardness of the last stone remaining.
Examples
Input
2
1
3
10
19
Output
7
Input
3
1
3
2
4
6
8
100
104
Output
2
Submitted Solution:
```
n=int(input())
a=[int(input())for i in range(2**n)]
while len(a)!=1:
s,t=a.pop(0),a.pop(0)
a.append(max(s-t,t-s))
print(a[0])
``` | instruction | 0 | 84,090 | 11 | 168,180 |
No | output | 1 | 84,090 | 11 | 168,181 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Kode Festival is an anual contest where the hardest stone in the world is determined. (Kode is a Japanese word for "hardness".)
This year, 2^N stones participated. The hardness of the i-th stone is A_i.
In the contest, stones are thrown at each other in a knockout tournament.
When two stones with hardness X and Y are thrown at each other, the following will happen:
* When X > Y: The stone with hardness Y will be destroyed and eliminated. The hardness of the stone with hardness X will become X-Y.
* When X = Y: One of the stones will be destroyed and eliminated. The hardness of the other stone will remain the same.
* When X < Y: The stone with hardness X will be destroyed and eliminated. The hardness of the stone with hardness Y will become Y-X.
The 2^N stones will fight in a knockout tournament as follows:
1. The following pairs will fight: (the 1-st stone versus the 2-nd stone), (the 3-rd stone versus the 4-th stone), ...
2. The following pairs will fight: (the winner of (1-st versus 2-nd) versus the winner of (3-rd versus 4-th)), (the winner of (5-th versus 6-th) versus the winner of (7-th versus 8-th)), ...
3. And so forth, until there is only one stone remaining.
Determine the eventual hardness of the last stone remaining.
Constraints
* 1 \leq N \leq 18
* 1 \leq A_i \leq 10^9
* A_i is an integer.
Input
The input is given from Standard Input in the following format:
N
A_1
A_2
:
A_{2^N}
Output
Print the eventual hardness of the last stone remaining.
Examples
Input
2
1
3
10
19
Output
7
Input
3
1
3
2
4
6
8
100
104
Output
2
Submitted Solution:
```
def battle(X, Y):
if X==Y:
return X
else:
return abs(X-Y)
N = int(input())
A = []
for i in range(2**N):
A.append(int(input()))
for i in range(2**N-1):
X = A.pop(0)
Y = A.pop(0)
A.append(battle(X, Y))
print(A[0])
``` | instruction | 0 | 84,091 | 11 | 168,182 |
No | output | 1 | 84,091 | 11 | 168,183 |
Provide a correct Python 3 solution for this coding contest problem.
<image>
At the request of a friend who started learning abacus, you decided to create a program to display the abacus beads. Create a program that takes a certain number as input and outputs a row of abacus beads. However, the number of digits of the abacus to be displayed is 5 digits, and the arrangement of beads from 0 to 9 is as follows using'*' (half-width asterisk),''(half-width blank), and'=' (half-width equal). It shall be expressed as.
<image>
Input
Multiple test cases are given. Up to 5 digits (integer) are given on one line for each test case.
The number of test cases does not exceed 1024.
Output
Output the abacus bead arrangement for each test case. Insert a blank line between the test cases.
Example
Input
2006
1111
Output
****
*
=====
* *
****
* ***
*****
*****
*****
=====
****
*
*****
*****
***** | instruction | 0 | 84,110 | 11 | 168,220 |
"Correct Solution:
```
f=0
while 1:
try:n=int(input())
except:break
if f:print()
f=1
a=[[0 for _ in range(5)]for _ in range(8)]
for i in range(4,-1,-1):
b=n%10
a[not b//5][i]=1
a[b%5+3][i]=1
n//=10
for i in range(8):
for j in range(5):
if i==2:print('=',end='')
else:print(' ' if a[i][j] else '*',end='')
print()
``` | output | 1 | 84,110 | 11 | 168,221 |
Provide a correct Python 3 solution for this coding contest problem.
<image>
At the request of a friend who started learning abacus, you decided to create a program to display the abacus beads. Create a program that takes a certain number as input and outputs a row of abacus beads. However, the number of digits of the abacus to be displayed is 5 digits, and the arrangement of beads from 0 to 9 is as follows using'*' (half-width asterisk),''(half-width blank), and'=' (half-width equal). It shall be expressed as.
<image>
Input
Multiple test cases are given. Up to 5 digits (integer) are given on one line for each test case.
The number of test cases does not exceed 1024.
Output
Output the abacus bead arrangement for each test case. Insert a blank line between the test cases.
Example
Input
2006
1111
Output
****
*
=====
* *
****
* ***
*****
*****
*****
=====
****
*
*****
*****
***** | instruction | 0 | 84,113 | 11 | 168,226 |
"Correct Solution:
```
# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0128
"""
import sys
from sys import stdin
input = stdin.readline
def conv_avacus(num_txt):
abacus = ['* = ****', '* =* ***', '* =** **', '* =*** *', '* =**** ',
' *= ****', ' *=* ***', ' *=** **', ' *=*** *', ' *=**** ']
ans = [abacus[int(num_txt[4])], abacus[int(num_txt[3])], abacus[int(num_txt[2])], abacus[int(num_txt[1])], abacus[int(num_txt[0])]]
return ans
def rotate_and_print(data):
y_size = len(data)
x_size = len(data[0])
A = [[''] * y_size for _ in range(x_size)]
for i in range(x_size):
for j in range(y_size):
A[i][j] = data[y_size-1-j][i]
for l in A:
print(''.join(l))
def main(args):
first_case = True
for line in sys.stdin:
if not first_case:
print()
num_txt = line.strip().zfill(5)
result = conv_avacus(num_txt)
rotate_and_print(result)
first_case = False
if __name__ == '__main__':
main(sys.argv[1:])
``` | output | 1 | 84,113 | 11 | 168,227 |
Provide a correct Python 3 solution for this coding contest problem.
<image>
At the request of a friend who started learning abacus, you decided to create a program to display the abacus beads. Create a program that takes a certain number as input and outputs a row of abacus beads. However, the number of digits of the abacus to be displayed is 5 digits, and the arrangement of beads from 0 to 9 is as follows using'*' (half-width asterisk),''(half-width blank), and'=' (half-width equal). It shall be expressed as.
<image>
Input
Multiple test cases are given. Up to 5 digits (integer) are given on one line for each test case.
The number of test cases does not exceed 1024.
Output
Output the abacus bead arrangement for each test case. Insert a blank line between the test cases.
Example
Input
2006
1111
Output
****
*
=====
* *
****
* ***
*****
*****
*****
=====
****
*
*****
*****
***** | instruction | 0 | 84,114 | 11 | 168,228 |
"Correct Solution:
```
import sys
isnewLine = False
pattern = {"0": "* = ****",
"1": "* =* ***",
"2": "* =** **",
"3": "* =*** *",
"4": "* =**** ",
"5": " *= ****",
"6": " *=* ***",
"7": " *=** **",
"8": " *=*** *",
"9": " *=**** ",
}
for line in sys.stdin:
if isnewLine:
print()
else:
isnewLine = True
line = line[:-1]
line = "0" * (5 - len(line)) + line
bar = [pattern[item] for item in line]
for i1, i2, i3, i4, i5 in zip(bar[0], bar[1], bar[2], bar[3], bar[4]):
print(i1 + i2 + i3 + i4 + i5)
``` | output | 1 | 84,114 | 11 | 168,229 |
Provide a correct Python 3 solution for this coding contest problem.
<image>
At the request of a friend who started learning abacus, you decided to create a program to display the abacus beads. Create a program that takes a certain number as input and outputs a row of abacus beads. However, the number of digits of the abacus to be displayed is 5 digits, and the arrangement of beads from 0 to 9 is as follows using'*' (half-width asterisk),''(half-width blank), and'=' (half-width equal). It shall be expressed as.
<image>
Input
Multiple test cases are given. Up to 5 digits (integer) are given on one line for each test case.
The number of test cases does not exceed 1024.
Output
Output the abacus bead arrangement for each test case. Insert a blank line between the test cases.
Example
Input
2006
1111
Output
****
*
=====
* *
****
* ***
*****
*****
*****
=====
****
*
*****
*****
***** | instruction | 0 | 84,115 | 11 | 168,230 |
"Correct Solution:
```
f=0
while 1:
try:n=int(input())
except:break
if f:print()
f=1
a=[['*' for _ in range(5)]for _ in range(8)]
for i in range(4,-1,-1):
b=n%10
a[not b//5][i]=' '
a[b%5+3][i]=' '
n//=10
a[2]='='*5
for i in a:
print(''.join(i),end='')
print()
``` | output | 1 | 84,115 | 11 | 168,231 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
<image>
At the request of a friend who started learning abacus, you decided to create a program to display the abacus beads. Create a program that takes a certain number as input and outputs a row of abacus beads. However, the number of digits of the abacus to be displayed is 5 digits, and the arrangement of beads from 0 to 9 is as follows using'*' (half-width asterisk),''(half-width blank), and'=' (half-width equal). It shall be expressed as.
<image>
Input
Multiple test cases are given. Up to 5 digits (integer) are given on one line for each test case.
The number of test cases does not exceed 1024.
Output
Output the abacus bead arrangement for each test case. Insert a blank line between the test cases.
Example
Input
2006
1111
Output
****
*
=====
* *
****
* ***
*****
*****
*****
=====
****
*
*****
*****
*****
Submitted Solution:
```
f=0
while 1:
try:n=int(input())
except:break
if f:print()
f=1
a=[[0 for _ in range(5)]for _ in range(8)]
for i in range(4,-1,-1):
b=n%10
if b>=5:a[0][i]=1
else: a[1][i]=1
a[b%5+3][i]=1
n//=10
for i in range(8):
for j in range(5):
if i==2:print('=',end='')
else:print(' ' if a[i][j] else '*',end='')
print()
``` | instruction | 0 | 84,116 | 11 | 168,232 |
Yes | output | 1 | 84,116 | 11 | 168,233 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
<image>
At the request of a friend who started learning abacus, you decided to create a program to display the abacus beads. Create a program that takes a certain number as input and outputs a row of abacus beads. However, the number of digits of the abacus to be displayed is 5 digits, and the arrangement of beads from 0 to 9 is as follows using'*' (half-width asterisk),''(half-width blank), and'=' (half-width equal). It shall be expressed as.
<image>
Input
Multiple test cases are given. Up to 5 digits (integer) are given on one line for each test case.
The number of test cases does not exceed 1024.
Output
Output the abacus bead arrangement for each test case. Insert a blank line between the test cases.
Example
Input
2006
1111
Output
****
*
=====
* *
****
* ***
*****
*****
*****
=====
****
*
*****
*****
*****
Submitted Solution:
```
L = [ "* = ****",
"* =* ***",
"* =** **",
"* =*** *",
"* =**** ",
" *= ****",
" *=* ***",
" *=** **",
" *=*** *",
" *=**** " ]
c=0
while True:
try:
num = int(input())
except EOFError:
break
if c > 0:
print()
c += 1
str = "{:05}".format(num)
s = [int(x) for x in list(str)]
for i in range(len(L[0])):
t = []
for j in range(len(s)):
t.append(L[s[j]][i])
print("".join(t))
``` | instruction | 0 | 84,117 | 11 | 168,234 |
Yes | output | 1 | 84,117 | 11 | 168,235 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
<image>
At the request of a friend who started learning abacus, you decided to create a program to display the abacus beads. Create a program that takes a certain number as input and outputs a row of abacus beads. However, the number of digits of the abacus to be displayed is 5 digits, and the arrangement of beads from 0 to 9 is as follows using'*' (half-width asterisk),''(half-width blank), and'=' (half-width equal). It shall be expressed as.
<image>
Input
Multiple test cases are given. Up to 5 digits (integer) are given on one line for each test case.
The number of test cases does not exceed 1024.
Output
Output the abacus bead arrangement for each test case. Insert a blank line between the test cases.
Example
Input
2006
1111
Output
****
*
=====
* *
****
* ***
*****
*****
*****
=====
****
*
*****
*****
*****
Submitted Solution:
```
# AOJ 0128 Abacus
# Python3 2018.6.19 bal4u
abacus = [
[ '*', '*', '*', '*', '*', ' ', ' ', ' ', ' ', ' ' ],
[ ' ', ' ', ' ', ' ', ' ', '*', '*', '*', '*', '*' ],
[ '=', '=', '=', '=', '=', '=', '=', '=', '=', '=' ],
[ ' ', '*', '*', '*', '*', ' ', '*', '*', '*', '*' ],
[ '*', ' ', '*', '*', '*', '*', ' ', '*', '*', '*' ],
[ '*', '*', ' ', '*', '*', '*', '*', ' ', '*', '*' ],
[ '*', '*', '*', ' ', '*', '*', '*', '*', ' ', '*' ],
[ '*', '*', '*', '*', ' ', '*', '*', '*', '*', ' ' ]]
ans = [['' for c in range(5)] for r in range(8)]
first = True
while True:
try: n = list(input())
except: break
for i in range(5-len(n)):
for r in range(8): ans[r][i] = abacus[r][0]
for i in range(len(n)):
for r in range(8): ans[r][5-len(n)+i] = abacus[r][int(n[i])]
if first: first = False
else: print()
for r in range(8): print(*ans[r], sep='')
``` | instruction | 0 | 84,118 | 11 | 168,236 |
Yes | output | 1 | 84,118 | 11 | 168,237 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
<image>
At the request of a friend who started learning abacus, you decided to create a program to display the abacus beads. Create a program that takes a certain number as input and outputs a row of abacus beads. However, the number of digits of the abacus to be displayed is 5 digits, and the arrangement of beads from 0 to 9 is as follows using'*' (half-width asterisk),''(half-width blank), and'=' (half-width equal). It shall be expressed as.
<image>
Input
Multiple test cases are given. Up to 5 digits (integer) are given on one line for each test case.
The number of test cases does not exceed 1024.
Output
Output the abacus bead arrangement for each test case. Insert a blank line between the test cases.
Example
Input
2006
1111
Output
****
*
=====
* *
****
* ***
*****
*****
*****
=====
****
*
*****
*****
*****
Submitted Solution:
```
def get_input():
while True:
try:
yield ''.join(input())
except EOFError:
break
table = \
["* = ****",\
"* =* ***",\
"* =** **",\
"* =*** *",\
"* =**** ",\
" *= ****",\
" *=* ***",\
" *=** **",\
" *=*** *",\
" *=**** "]
N = list(get_input())
for l in range(len(N)):
if l > 0:
print("")
num = int(N[l])
ans = []
for i in range(5):
ans.append(table[num // 10**(4-i)])
num = num % 10**(4-i)
for i in range(8):
for j in range(5):
print(ans[j][i], end="")
print("")
``` | instruction | 0 | 84,119 | 11 | 168,238 |
Yes | output | 1 | 84,119 | 11 | 168,239 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.