text
stringlengths
216
39.6k
conversation_id
int64
219
108k
embedding
list
cluster
int64
11
11
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) ``` No
83,007
[ 0.39599609375, -0.2413330078125, 0.1173095703125, 0.325439453125, -0.5703125, -0.440185546875, -0.12066650390625, 0.0526123046875, 0.0994873046875, 0.90185546875, 0.74951171875, 0.142578125, 0.236083984375, -0.55029296875, -0.19482421875, 0.166259765625, -0.498779296875, -0.9106445...
11
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) ``` No
83,008
[ 0.333740234375, -0.26806640625, 0.027679443359375, 0.2325439453125, -0.59765625, -0.391357421875, -0.135986328125, -0.0009722709655761719, 0.1796875, 0.953125, 0.71142578125, 0.1988525390625, 0.28369140625, -0.55224609375, -0.2135009765625, 0.142578125, -0.580078125, -0.98388671875...
11
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)) ``` No
83,009
[ 0.42041015625, -0.20361328125, -0.0229644775390625, 0.168212890625, -0.5498046875, -0.38525390625, -0.07049560546875, -0.005615234375, 0.1845703125, 0.92822265625, 0.67431640625, 0.1943359375, 0.2384033203125, -0.495849609375, -0.2027587890625, 0.13330078125, -0.52880859375, -0.930...
11
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) ``` Yes
83,099
[ 0.2445068359375, -0.06878662109375, -0.2734375, 0.046844482421875, -0.6103515625, -0.482666015625, -0.03802490234375, 0.235595703125, 0.1392822265625, 0.7919921875, 0.703125, 0.00885009765625, 0.31640625, -1.015625, -0.302490234375, 0.05206298828125, -0.576171875, -0.440673828125, ...
11
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") ``` Yes
83,100
[ 0.260009765625, -0.039794921875, -0.2705078125, 0.040252685546875, -0.57177734375, -0.46826171875, -0.0703125, 0.28271484375, 0.1363525390625, 0.85546875, 0.69140625, 0.08966064453125, 0.30712890625, -0.99072265625, -0.25341796875, -0.034698486328125, -0.484619140625, -0.4470214843...
11
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") ``` Yes
83,101
[ 0.282958984375, -0.0718994140625, -0.233642578125, 0.05560302734375, -0.5341796875, -0.429443359375, -0.0623779296875, 0.22314453125, 0.16015625, 0.8779296875, 0.68603515625, 0.0012378692626953125, 0.318115234375, -0.98583984375, -0.25341796875, 0.0318603515625, -0.57568359375, -0....
11
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") ``` Yes
83,102
[ 0.25537109375, -0.0235595703125, -0.1829833984375, 0.01461029052734375, -0.57177734375, -0.372314453125, -0.128173828125, 0.242431640625, 0.151123046875, 0.87548828125, 0.65771484375, 0.10272216796875, 0.269287109375, -0.9755859375, -0.316162109375, 0.01096343994140625, -0.546875, ...
11
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') ``` No
83,103
[ 0.2041015625, -0.03961181640625, -0.26806640625, 0.0205535888671875, -0.5556640625, -0.42626953125, -0.0189361572265625, 0.1807861328125, 0.1065673828125, 0.83837890625, 0.685546875, 0.023956298828125, 0.281494140625, -0.97119140625, -0.26416015625, 0.0022792816162109375, -0.59179687...
11
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) ``` No
83,104
[ 0.3564453125, -0.12445068359375, -0.313232421875, 0.049407958984375, -0.496826171875, -0.412841796875, -0.09136962890625, 0.1771240234375, 0.16162109375, 0.802734375, 0.6796875, -0.08392333984375, 0.333984375, -0.92041015625, -0.1981201171875, 0.0200042724609375, -0.5126953125, -0....
11
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") ``` No
83,105
[ 0.26171875, 0.07049560546875, -0.220947265625, 0.0726318359375, -0.56103515625, -0.4072265625, -0.05059814453125, 0.1824951171875, 0.2275390625, 0.7841796875, 0.6962890625, -0.0037517547607421875, 0.257080078125, -1.017578125, -0.312255859375, -0.00222015380859375, -0.4814453125, -...
11
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) ``` Yes
83,311
[ 0.153564453125, 0.3193359375, -0.12420654296875, 0.297119140625, -0.66943359375, -0.259033203125, -0.06719970703125, 0.312744140625, 0.03387451171875, 0.6328125, 0.4970703125, 0.09881591796875, 0.2381591796875, -0.896484375, -0.4033203125, 0.380859375, -0.61376953125, -0.7651367187...
11
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))) ``` Yes
83,312
[ 0.259765625, 0.32275390625, -0.10223388671875, 0.290771484375, -0.55322265625, -0.343994140625, -0.1781005859375, 0.248046875, -0.012969970703125, 0.446533203125, 0.4677734375, -0.01107025146484375, 0.2464599609375, -0.82470703125, -0.30615234375, 0.42626953125, -0.62890625, -0.798...
11
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() ``` No
83,315
[ 0.271484375, 0.322509765625, -0.08319091796875, 0.267578125, -0.5654296875, -0.2261962890625, -0.09051513671875, 0.458251953125, -0.005535125732421875, 0.44580078125, 0.373779296875, 0.0321044921875, 0.174072265625, -0.73876953125, -0.38037109375, 0.515625, -0.67431640625, -0.64355...
11
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) ``` No
83,317
[ 0.2252197265625, 0.2479248046875, -0.17919921875, 0.310546875, -0.51708984375, -0.293701171875, -0.140625, 0.402587890625, 0.0167236328125, 0.47021484375, 0.44140625, 0.025604248046875, 0.2440185546875, -0.72802734375, -0.366455078125, 0.4375, -0.6123046875, -0.61669921875, -0.54...
11
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)]]] ``` Yes
83,335
[ 0.1776123046875, -0.03643798828125, -0.212158203125, 0.043975830078125, -0.7900390625, -0.30859375, 0.00305938720703125, 0.3056640625, -0.020477294921875, 1.00390625, 0.26953125, 0.016937255859375, 0.38623046875, -0.92041015625, -0.765625, -0.210205078125, -0.54296875, -0.899902343...
11
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)) ``` Yes
83,336
[ 0.1776123046875, -0.03643798828125, -0.212158203125, 0.043975830078125, -0.7900390625, -0.30859375, 0.00305938720703125, 0.3056640625, -0.020477294921875, 1.00390625, 0.26953125, 0.016937255859375, 0.38623046875, -0.92041015625, -0.765625, -0.210205078125, -0.54296875, -0.899902343...
11
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]) ``` Yes
83,337
[ 0.1776123046875, -0.03643798828125, -0.212158203125, 0.043975830078125, -0.7900390625, -0.30859375, 0.00305938720703125, 0.3056640625, -0.020477294921875, 1.00390625, 0.26953125, 0.016937255859375, 0.38623046875, -0.92041015625, -0.765625, -0.210205078125, -0.54296875, -0.899902343...
11
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))) ``` Yes
83,338
[ 0.185546875, -0.0004019737243652344, -0.227783203125, 0.0526123046875, -0.79833984375, -0.30908203125, 0.015167236328125, 0.326171875, -0.004497528076171875, 0.94970703125, 0.274658203125, 0.032470703125, 0.401123046875, -0.90673828125, -0.8115234375, -0.23046875, -0.5048828125, -0...
11
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()))]]] ``` No
83,339
[ 0.1795654296875, -0.0201568603515625, -0.2166748046875, 0.04669189453125, -0.7978515625, -0.27880859375, -0.025482177734375, 0.32470703125, -0.017913818359375, 0.97607421875, 0.2342529296875, 0.00023543834686279297, 0.402099609375, -0.89501953125, -0.76220703125, -0.2008056640625, -0...
11
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()))]]] ``` No
83,340
[ 0.1826171875, -0.03594970703125, -0.2354736328125, 0.052001953125, -0.78955078125, -0.28125, -0.023895263671875, 0.311279296875, -0.0078277587890625, 0.970703125, 0.2310791015625, -0.0039825439453125, 0.413330078125, -0.890625, -0.7705078125, -0.22314453125, -0.5322265625, -0.90332...
11
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 &gt;= 1 Y &lt; 3 N &lt;= -3 N &gt; 55 N Output 17 Input 2 &gt; 100 Y &lt; -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) ``` Yes
83,768
[ 0.6064453125, 0.028472900390625, -0.2432861328125, 0.1376953125, -0.49609375, -0.17138671875, 0.161865234375, 0.4580078125, 0.046112060546875, 0.8525390625, 0.82763671875, 0.291748046875, 0.4345703125, -0.734375, -0.4375, -0.150390625, -0.69580078125, -0.79541015625, -0.577148437...
11
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 &gt;= 1 Y &lt; 3 N &lt;= -3 N &gt; 55 N Output 17 Input 2 &gt; 100 Y &lt; -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) ``` Yes
83,769
[ 0.61474609375, 0.031768798828125, -0.2418212890625, 0.138671875, -0.48974609375, -0.16943359375, 0.1607666015625, 0.468505859375, 0.043792724609375, 0.8564453125, 0.83447265625, 0.299560546875, 0.43408203125, -0.73681640625, -0.435791015625, -0.1513671875, -0.6845703125, -0.7983398...
11
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 &gt;= 1 Y &lt; 3 N &lt;= -3 N &gt; 55 N Output 17 Input 2 &gt; 100 Y &lt; -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) ``` Yes
83,770
[ 0.61083984375, 0.0222320556640625, -0.2384033203125, 0.138916015625, -0.48681640625, -0.1661376953125, 0.1683349609375, 0.459228515625, 0.04400634765625, 0.853515625, 0.81884765625, 0.28076171875, 0.43408203125, -0.7255859375, -0.43701171875, -0.152587890625, -0.701171875, -0.79052...
11
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 &gt;= 1 Y &lt; 3 N &lt;= -3 N &gt; 55 N Output 17 Input 2 &gt; 100 Y &lt; -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) ``` Yes
83,771
[ 0.60205078125, 0.00443267822265625, -0.2548828125, 0.1297607421875, -0.466796875, -0.161865234375, 0.1654052734375, 0.457763671875, 0.0321044921875, 0.87646484375, 0.853515625, 0.293701171875, 0.431396484375, -0.71484375, -0.42578125, -0.1552734375, -0.6875, -0.80078125, -0.58349...
11
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 &gt;= 1 Y &lt; 3 N &lt;= -3 N &gt; 55 N Output 17 Input 2 &gt; 100 Y &lt; -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) ``` No
83,772
[ 0.6025390625, 0.0418701171875, -0.22998046875, 0.185791015625, -0.492919921875, -0.170654296875, 0.172119140625, 0.454833984375, 0.050994873046875, 0.853515625, 0.8447265625, 0.272216796875, 0.407470703125, -0.75244140625, -0.435791015625, -0.13525390625, -0.68115234375, -0.8237304...
11
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 &gt;= 1 Y &lt; 3 N &lt;= -3 N &gt; 55 N Output 17 Input 2 &gt; 100 Y &lt; -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) ``` No
83,773
[ 0.61572265625, 0.0255584716796875, -0.2568359375, 0.1287841796875, -0.476806640625, -0.1702880859375, 0.1717529296875, 0.474609375, 0.0677490234375, 0.87255859375, 0.845703125, 0.255615234375, 0.455322265625, -0.71728515625, -0.40576171875, -0.155029296875, -0.69091796875, -0.79589...
11
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 &gt;= 1 Y &lt; 3 N &lt;= -3 N &gt; 55 N Output 17 Input 2 &gt; 100 Y &lt; -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") ``` No
83,774
[ 0.60888671875, 0.0231475830078125, -0.2322998046875, 0.1363525390625, -0.486572265625, -0.165771484375, 0.1632080078125, 0.456298828125, 0.04400634765625, 0.85986328125, 0.82666015625, 0.29736328125, 0.439208984375, -0.734375, -0.4384765625, -0.153564453125, -0.6865234375, -0.80175...
11
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 &gt;= 1 Y &lt; 3 N &lt;= -3 N &gt; 55 N Output 17 Input 2 &gt; 100 Y &lt; -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") ``` No
83,775
[ 0.6005859375, 0.0092926025390625, -0.2384033203125, 0.1463623046875, -0.496826171875, -0.1685791015625, 0.2166748046875, 0.46240234375, 0.04962158203125, 0.85302734375, 0.81005859375, 0.2841796875, 0.443603515625, -0.7216796875, -0.43212890625, -0.157470703125, -0.7001953125, -0.78...
11
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) ``` No
83,781
[ 0.5439453125, 0.380859375, -0.126953125, 0.21630859375, -0.701171875, -0.6630859375, -0.031707763671875, 0.21923828125, 0.1048583984375, 0.80615234375, 0.49365234375, 0.0140228271484375, -0.207275390625, -0.66162109375, -0.595703125, 0.1983642578125, -0.480712890625, -0.9873046875,...
11
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) ``` No
83,782
[ 0.5439453125, 0.380859375, -0.126953125, 0.21630859375, -0.701171875, -0.6630859375, -0.031707763671875, 0.21923828125, 0.1048583984375, 0.80615234375, 0.49365234375, 0.0140228271484375, -0.207275390625, -0.66162109375, -0.595703125, 0.1983642578125, -0.480712890625, -0.9873046875,...
11
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) ``` No
83,783
[ 0.5439453125, 0.380859375, -0.126953125, 0.21630859375, -0.701171875, -0.6630859375, -0.031707763671875, 0.21923828125, 0.1048583984375, 0.80615234375, 0.49365234375, 0.0140228271484375, -0.207275390625, -0.66162109375, -0.595703125, 0.1983642578125, -0.480712890625, -0.9873046875,...
11
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) ``` Yes
83,803
[ 0.29296875, 0.0709228515625, -0.12939453125, 0.34765625, -0.80859375, -0.155029296875, -0.198486328125, 0.1273193359375, 0.016204833984375, 0.7412109375, 0.587890625, -0.43359375, 0.0186614990234375, -1.0234375, -0.36474609375, 0.34423828125, -0.599609375, -0.923828125, -0.678222...
11
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) ``` Yes
83,804
[ 0.278564453125, 0.08355712890625, -0.1317138671875, 0.3642578125, -0.8310546875, -0.1710205078125, -0.18505859375, 0.1573486328125, -0.01372528076171875, 0.76611328125, 0.6005859375, -0.37890625, 0.0341796875, -1.076171875, -0.394287109375, 0.364013671875, -0.556640625, -0.95800781...
11
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() ``` No
83,807
[ 0.26220703125, 0.0231475830078125, -0.1019287109375, 0.385009765625, -0.83740234375, -0.1551513671875, -0.1756591796875, 0.1390380859375, 0.01251220703125, 0.72705078125, 0.60302734375, -0.4189453125, 0.047607421875, -1.0693359375, -0.358642578125, 0.369873046875, -0.5947265625, -0...
11
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) ``` No
83,810
[ 0.268798828125, 0.097900390625, -0.132080078125, 0.3798828125, -0.8544921875, -0.169189453125, -0.1956787109375, 0.139892578125, -0.0027294158935546875, 0.77587890625, 0.5966796875, -0.38671875, 0.0601806640625, -1.076171875, -0.3701171875, 0.3505859375, -0.56884765625, -0.97021484...
11
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]) ``` Yes
84,084
[ 0.21240234375, 0.337890625, 0.036163330078125, 0.2003173828125, -1.1845703125, -0.05706787109375, -0.25830078125, 0.25732421875, -0.0036220550537109375, 0.75732421875, 0.40478515625, 0.125732421875, 0.12115478515625, -0.6015625, -0.456298828125, 0.0577392578125, -0.90234375, -0.782...
11
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]) ``` Yes
84,085
[ 0.2130126953125, 0.376953125, 0.058258056640625, 0.1912841796875, -1.19921875, -0.07525634765625, -0.30419921875, 0.259765625, -0.0035495758056640625, 0.75341796875, 0.4775390625, 0.127197265625, 0.10540771484375, -0.63134765625, -0.43212890625, 0.119873046875, -0.96337890625, -0.7...
11
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) ``` Yes
84,086
[ 0.200927734375, 0.338134765625, 0.048828125, 0.1612548828125, -1.20703125, -0.064697265625, -0.308837890625, 0.254638671875, -0.0022792816162109375, 0.75732421875, 0.455078125, 0.09912109375, 0.11871337890625, -0.5830078125, -0.4443359375, 0.10015869140625, -0.94970703125, -0.77685...
11
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)) ``` Yes
84,087
[ 0.19482421875, 0.35791015625, 0.02947998046875, 0.208984375, -1.1611328125, -0.0772705078125, -0.311279296875, 0.2880859375, 0.02459716796875, 0.71240234375, 0.463623046875, 0.10888671875, 0.1407470703125, -0.62890625, -0.43310546875, 0.08203125, -0.9404296875, -0.74853515625, -0...
11
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]) ``` No
84,089
[ 0.1956787109375, 0.342041015625, 0.076416015625, 0.1854248046875, -1.20703125, -0.06744384765625, -0.322509765625, 0.2137451171875, -0.00357818603515625, 0.7451171875, 0.42578125, 0.099853515625, 0.10736083984375, -0.591796875, -0.439697265625, 0.06829833984375, -0.9072265625, -0.7...
11
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]) ``` No
84,090
[ 0.2003173828125, 0.380126953125, 0.069580078125, 0.19921875, -1.1904296875, -0.0845947265625, -0.32470703125, 0.2529296875, 0.0164794921875, 0.73388671875, 0.466064453125, 0.0994873046875, 0.11285400390625, -0.6318359375, -0.435302734375, 0.09283447265625, -0.95751953125, -0.770019...
11
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]) ``` No
84,091
[ 0.19091796875, 0.361572265625, 0.038970947265625, 0.187744140625, -1.1806640625, -0.073974609375, -0.2890625, 0.253173828125, 0.027496337890625, 0.74951171875, 0.475341796875, 0.11474609375, 0.12353515625, -0.63134765625, -0.412353515625, 0.07440185546875, -0.9697265625, -0.8017578...
11
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 **** * ===== * * **** * *** ***** ***** ***** ===== **** * ***** ***** ***** "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() ```
84,110
[ 0.2353515625, -0.1748046875, -0.030487060546875, 0.179931640625, -0.6552734375, -0.2127685546875, -0.0823974609375, 0.083740234375, 0.25732421875, 0.751953125, 0.64990234375, -0.303955078125, -0.1353759765625, -0.8857421875, -0.72900390625, 0.050079345703125, -0.461669921875, -0.70...
11
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 **** * ===== * * **** * *** ***** ***** ***** ===== **** * ***** ***** ***** "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:]) ```
84,113
[ 0.37255859375, -0.03399658203125, -0.08624267578125, 0.0233154296875, -0.65380859375, -0.15380859375, -0.115966796875, 0.1138916015625, 0.27294921875, 0.55322265625, 0.41650390625, -0.343505859375, -0.06646728515625, -0.91943359375, -0.705078125, 0.07147216796875, -0.371826171875, ...
11
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 **** * ===== * * **** * *** ***** ***** ***** ===== **** * ***** ***** ***** "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) ```
84,114
[ 0.2391357421875, -0.1578369140625, -0.00971221923828125, 0.1591796875, -0.66796875, -0.262939453125, -0.1361083984375, 0.091796875, 0.3525390625, 0.7744140625, 0.63916015625, -0.33251953125, -0.0997314453125, -0.892578125, -0.64013671875, 0.015625, -0.359375, -0.68896484375, -0.3...
11
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 **** * ===== * * **** * *** ***** ***** ***** ===== **** * ***** ***** ***** "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() ```
84,115
[ 0.282958984375, -0.1785888671875, -0.018768310546875, 0.198974609375, -0.64892578125, -0.219482421875, -0.09796142578125, 0.076171875, 0.25439453125, 0.72216796875, 0.638671875, -0.30126953125, -0.1463623046875, -0.8505859375, -0.70654296875, 0.031646728515625, -0.439453125, -0.694...
11
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() ``` Yes
84,116
[ 0.2244873046875, -0.2117919921875, -0.055023193359375, 0.1827392578125, -0.8076171875, -0.1756591796875, -0.1820068359375, 0.1307373046875, 0.2327880859375, 0.7724609375, 0.55712890625, -0.2469482421875, -0.155517578125, -0.86474609375, -0.7294921875, 0.04949951171875, -0.40795898437...
11
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)) ``` Yes
84,117
[ 0.28369140625, -0.2042236328125, 0.034271240234375, 0.206787109375, -0.7919921875, -0.1505126953125, -0.177001953125, 0.14453125, 0.254150390625, 0.701171875, 0.53662109375, -0.268310546875, -0.08941650390625, -0.8603515625, -0.685546875, 0.03680419921875, -0.303466796875, -0.72460...
11
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='') ``` Yes
84,118
[ 0.3447265625, -0.311279296875, -0.040008544921875, 0.155029296875, -0.69287109375, -0.1324462890625, -0.09442138671875, 0.17724609375, 0.2105712890625, 0.67822265625, 0.54833984375, -0.33837890625, -0.09912109375, -0.87109375, -0.66552734375, -0.036376953125, -0.345947265625, -0.70...
11
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("") ``` Yes
84,119
[ 0.30126953125, -0.179443359375, -0.0157623291015625, 0.1500244140625, -0.828125, -0.1636962890625, -0.2218017578125, 0.163818359375, 0.29833984375, 0.67138671875, 0.552734375, -0.248046875, -0.130859375, -0.89208984375, -0.6728515625, 0.053314208984375, -0.295166015625, -0.73974609...
11
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 = [[0 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]) ``` No
84,120
[ 0.3447265625, -0.311279296875, -0.040008544921875, 0.155029296875, -0.69287109375, -0.1324462890625, -0.09442138671875, 0.17724609375, 0.2105712890625, 0.67822265625, 0.54833984375, -0.33837890625, -0.09912109375, -0.87109375, -0.66552734375, -0.036376953125, -0.345947265625, -0.70...
11
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: ``` import sys pattern = {"0": "* = ****", "1": "* =* ***", "2": "* =** **", "3": "* =*** *", "4": "* =**** ", "5": " *= ****", "6": " *=* ***", "7": " *=** **", "8": " *=*** *", "9": " *=**** ", } for line in sys.stdin: 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) ``` No
84,121
[ 0.29248046875, -0.171142578125, 0.052337646484375, 0.1773681640625, -0.82568359375, -0.1282958984375, -0.281982421875, 0.10693359375, 0.2286376953125, 0.76611328125, 0.505859375, -0.308349609375, -0.1522216796875, -0.83642578125, -0.65673828125, 0.08355712890625, -0.251953125, -0.7...
11
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 a[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() ``` No
84,122
[ 0.2296142578125, -0.1824951171875, -0.0389404296875, 0.1864013671875, -0.81298828125, -0.172119140625, -0.1904296875, 0.13525390625, 0.231201171875, 0.7802734375, 0.56787109375, -0.25146484375, -0.1290283203125, -0.87451171875, -0.7353515625, 0.04730224609375, -0.40869140625, -0.74...
11
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Zibi is a competitive programming coach. There are n competitors who want to be prepared well. The training contests are quite unusual – there are two people in a team, two problems, and each competitor will code exactly one of them. Of course, people in one team will code different problems. Rules of scoring also aren't typical. The first problem is always an implementation problem: you have to implement some well-known algorithm very fast and the time of your typing is rated. The second one is an awful geometry task and you just have to get it accepted in reasonable time. Here the length and difficulty of your code are important. After that, Zibi will give some penalty points (possibly negative) for each solution and the final score of the team is the sum of them (the less the score is, the better). We know that the i-th competitor will always have score x_i when he codes the first task and y_i when he codes the second task. We can assume, that all competitors know each other's skills and during the contest distribute the problems in the way that minimizes their final score. Remember that each person codes exactly one problem in a contest. Zibi wants all competitors to write a contest with each other. However, there are m pairs of people who really don't like to cooperate and they definitely won't write a contest together. Still, the coach is going to conduct trainings for all possible pairs of people, such that the people in pair don't hate each other. The coach is interested for each participant, what will be his or her sum of scores of all teams he trained in? Input The first line contains two integers n and m (2 ≤ n ≤ 300 000, 0 ≤ m ≤ 300 000) — the number of participants and the number of pairs of people who will not write a contest together. Each of the next n lines contains two integers x_i and y_i (-10^9 ≤ x_i, y_i ≤ 10^9) — the scores which will the i-th competitor get on the first problem and on the second problem. It is guaranteed that there are no two people having both x_i and y_i same. Each of the next m lines contain two integers u_i and v_i (1 ≤ u_i, v_i ≤ n, u_i ≠ v_i) — indices of people who don't want to write a contest in one team. Each unordered pair of indices will appear at most once. Output Output n integers — the sum of scores for all participants in the same order as they appear in the input. Examples Input 3 2 1 2 2 3 1 3 1 2 2 3 Output 3 0 3 Input 3 3 1 2 2 3 1 3 1 2 2 3 1 3 Output 0 0 0 Input 5 3 -1 3 2 4 1 1 3 5 2 2 1 4 2 3 3 5 Output 4 14 4 16 10 Note In the first example, there will be only one team consisting of persons 1 and 3. The optimal strategy for them is to assign the first task to the 3-rd person and the second task to the 1-st person, this will lead to score equal to 1 + 2 = 3. In the second example, nobody likes anyone, so there won't be any trainings. It seems that Zibi won't be titled coach in that case... Submitted Solution: ``` import io import os import sys class FastI(io.BytesIO): """ FastIO for PyPy3 by Pajenegod """ def __init__(self): self.newlines = 0 def read1(self): b, ptr = os.read(0, (1 << 13) + os.fstat(0).st_size), self.tell() self.seek(0, 2) self.write(b) self.seek(ptr) return b def read(self): while self.read1(): pass return super(FastI, self).read() if self.stream.tell() else self.getvalue() def readline(self): while self.newlines == 0: b = self.read1() self.newlines += b.count(b'\n') + (not b) self.newlines -= 1 return super(FastI, self).readline() def readnumbers(self, var=int): """ Read numbers till EOF. Use var to change type. """ numbers, b = [], self.read() num, sign = var(0), 1 for char in b: if char >= b'0' [0]: num = 10 * num + char - 48 elif char == b'-' [0]: sign = -1 elif char != b'\r' [0]: numbers.append(sign * num) num, sign = var(0), 1 if b and b[-1] >= b'0' [0]: numbers.append(sign * num) return numbers sys.stdin, sys.stdout, stream = FastI(), io.IOBase(), io.BytesIO() sys.stdout.flush = lambda: os.write(1, stream.getvalue()) and not stream.truncate(0) and stream.seek(0) sys.stdout.write = lambda s: stream.write(s.encode()) input, flush = sys.stdin.readline, sys.stdout.flush def main(): n, m = map(int, input().split()) c = [0] * n a = [[int(j) for j in input().split()] + [i] for i in range(n)] for _ in range(m): x, y = map(int, input().split()) s = min(a[x - 1][0] + a[y - 1][1], a[x - 1][1] + a[y - 1][0]) c[x - 1] -= s c[y - 1] -= s a.sort(key=lambda x: x[1] - x[0]) sum_x = sum(i[0] for i in a) sum_y = 0 for i in range(n): sum_x -= a[i][0] c[a[i][2]] += sum_x + ((n - i - 1) * a[i][1]) + sum_y + (i * a[i][0]) sum_y += a[i][1] print(*c) if __name__ == '__main__': main() ``` Yes
84,235
[ 0.273193359375, 0.08721923828125, 0.00614166259765625, 0.06488037109375, -0.5322265625, -0.4482421875, -0.277099609375, 0.1927490234375, 0.0762939453125, 0.705078125, 0.31494140625, -0.1312255859375, 0.01361846923828125, -0.74462890625, -0.470703125, -0.2261962890625, -0.6494140625, ...
11
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Zibi is a competitive programming coach. There are n competitors who want to be prepared well. The training contests are quite unusual – there are two people in a team, two problems, and each competitor will code exactly one of them. Of course, people in one team will code different problems. Rules of scoring also aren't typical. The first problem is always an implementation problem: you have to implement some well-known algorithm very fast and the time of your typing is rated. The second one is an awful geometry task and you just have to get it accepted in reasonable time. Here the length and difficulty of your code are important. After that, Zibi will give some penalty points (possibly negative) for each solution and the final score of the team is the sum of them (the less the score is, the better). We know that the i-th competitor will always have score x_i when he codes the first task and y_i when he codes the second task. We can assume, that all competitors know each other's skills and during the contest distribute the problems in the way that minimizes their final score. Remember that each person codes exactly one problem in a contest. Zibi wants all competitors to write a contest with each other. However, there are m pairs of people who really don't like to cooperate and they definitely won't write a contest together. Still, the coach is going to conduct trainings for all possible pairs of people, such that the people in pair don't hate each other. The coach is interested for each participant, what will be his or her sum of scores of all teams he trained in? Input The first line contains two integers n and m (2 ≤ n ≤ 300 000, 0 ≤ m ≤ 300 000) — the number of participants and the number of pairs of people who will not write a contest together. Each of the next n lines contains two integers x_i and y_i (-10^9 ≤ x_i, y_i ≤ 10^9) — the scores which will the i-th competitor get on the first problem and on the second problem. It is guaranteed that there are no two people having both x_i and y_i same. Each of the next m lines contain two integers u_i and v_i (1 ≤ u_i, v_i ≤ n, u_i ≠ v_i) — indices of people who don't want to write a contest in one team. Each unordered pair of indices will appear at most once. Output Output n integers — the sum of scores for all participants in the same order as they appear in the input. Examples Input 3 2 1 2 2 3 1 3 1 2 2 3 Output 3 0 3 Input 3 3 1 2 2 3 1 3 1 2 2 3 1 3 Output 0 0 0 Input 5 3 -1 3 2 4 1 1 3 5 2 2 1 4 2 3 3 5 Output 4 14 4 16 10 Note In the first example, there will be only one team consisting of persons 1 and 3. The optimal strategy for them is to assign the first task to the 3-rd person and the second task to the 1-st person, this will lead to score equal to 1 + 2 = 3. In the second example, nobody likes anyone, so there won't be any trainings. It seems that Zibi won't be titled coach in that case... Submitted Solution: ``` #!/usr/bin/env python3 """ This file is part of https://github.com/cheran-senthil/PyRival Copyright 2019 Cheran Senthilkumar <hello@cheran.io> """ import os import sys from atexit import register from io import BytesIO input = BytesIO(os.read(0, os.fstat(0).st_size)).readline sys.stdout = BytesIO() true_write = sys.stdout.write sys.stdout.write = lambda s: true_write(s.encode()) register(lambda: os.write(1, sys.stdout.getvalue())) def main(): n, m = map(int, input().split()) c = [0] * n a = [[int(j) for j in input().split()] + [i] for i in range(n)] for _ in range(m): x, y = map(int, input().split()) s = min(a[x - 1][0] + a[y - 1][1], a[x - 1][1] + a[y - 1][0]) c[x - 1] -= s c[y - 1] -= s a.sort(key=lambda x: x[1] - x[0]) sum_x = sum(i[0] for i in a) sum_y = 0 for i in range(n): sum_x -= a[i][0] c[a[i][2]] += sum_x + ((n - i - 1) * a[i][1]) + sum_y + (i * a[i][0]) sum_y += a[i][1] print(*c) if __name__ == '__main__': main() ``` Yes
84,236
[ 0.273193359375, 0.08721923828125, 0.00614166259765625, 0.06488037109375, -0.5322265625, -0.4482421875, -0.277099609375, 0.1927490234375, 0.0762939453125, 0.705078125, 0.31494140625, -0.1312255859375, 0.01361846923828125, -0.74462890625, -0.470703125, -0.2261962890625, -0.6494140625, ...
11
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Zibi is a competitive programming coach. There are n competitors who want to be prepared well. The training contests are quite unusual – there are two people in a team, two problems, and each competitor will code exactly one of them. Of course, people in one team will code different problems. Rules of scoring also aren't typical. The first problem is always an implementation problem: you have to implement some well-known algorithm very fast and the time of your typing is rated. The second one is an awful geometry task and you just have to get it accepted in reasonable time. Here the length and difficulty of your code are important. After that, Zibi will give some penalty points (possibly negative) for each solution and the final score of the team is the sum of them (the less the score is, the better). We know that the i-th competitor will always have score x_i when he codes the first task and y_i when he codes the second task. We can assume, that all competitors know each other's skills and during the contest distribute the problems in the way that minimizes their final score. Remember that each person codes exactly one problem in a contest. Zibi wants all competitors to write a contest with each other. However, there are m pairs of people who really don't like to cooperate and they definitely won't write a contest together. Still, the coach is going to conduct trainings for all possible pairs of people, such that the people in pair don't hate each other. The coach is interested for each participant, what will be his or her sum of scores of all teams he trained in? Input The first line contains two integers n and m (2 ≤ n ≤ 300 000, 0 ≤ m ≤ 300 000) — the number of participants and the number of pairs of people who will not write a contest together. Each of the next n lines contains two integers x_i and y_i (-10^9 ≤ x_i, y_i ≤ 10^9) — the scores which will the i-th competitor get on the first problem and on the second problem. It is guaranteed that there are no two people having both x_i and y_i same. Each of the next m lines contain two integers u_i and v_i (1 ≤ u_i, v_i ≤ n, u_i ≠ v_i) — indices of people who don't want to write a contest in one team. Each unordered pair of indices will appear at most once. Output Output n integers — the sum of scores for all participants in the same order as they appear in the input. Examples Input 3 2 1 2 2 3 1 3 1 2 2 3 Output 3 0 3 Input 3 3 1 2 2 3 1 3 1 2 2 3 1 3 Output 0 0 0 Input 5 3 -1 3 2 4 1 1 3 5 2 2 1 4 2 3 3 5 Output 4 14 4 16 10 Note In the first example, there will be only one team consisting of persons 1 and 3. The optimal strategy for them is to assign the first task to the 3-rd person and the second task to the 1-st person, this will lead to score equal to 1 + 2 = 3. In the second example, nobody likes anyone, so there won't be any trainings. It seems that Zibi won't be titled coach in that case... Submitted Solution: ``` #!/usr/bin/env python from __future__ import division, print_function import os import sys from io import BytesIO, IOBase if sys.version_info[0] < 3: from __builtin__ import xrange as range from future_builtins import ascii, filter, hex, map, oct, zip class FastI(BytesIO): newlines = 0 def __init__(self, fd=0, bufsize=8192): self.fd = fd self.bufsize = bufsize def readline(self): while self.newlines == 0: b, ptr = os.read(self.fd, max(os.fstat(self.fd).st_size, self.bufsize)), self.tell() self.seek(0, 2), self.write(b), self.seek(ptr) self.newlines += b.count(b'\n') + (not b) self.newlines -= 1 return super(FastI, self).readline() class FastO(IOBase): def __init__(self, fd=1): stream = BytesIO() self.flush = lambda: os.write(fd, stream.getvalue()) and not stream.truncate(0) and stream.seek(0) self.write = stream.write if sys.version_info[0] < 3 else lambda b: stream.write(b.encode()) class ostream: def __lshift__(self, a): if a == endl: sys.stdout.write('\n') sys.stdout.flush() else: sys.stdout.write(str(a)) return self sys.stdin, sys.stdout = FastI(), FastO() input, flush = sys.stdin.readline, sys.stdout.flush cout, endl = ostream(), object() def main(): n, m = map(int, input().split()) a = [[int(ai) for ai in input().split()] + [i] for i in range(n)] c = [0] * n for _ in range(m): x, y = map(int, input().split()) s = min(a[x - 1][0] + a[y - 1][1], a[x - 1][1] + a[y - 1][0]) c[x - 1] -= s c[y - 1] -= s a.sort(key=lambda x: x[1] - x[0]) sum_x = sum(i[0] for i in a) sum_y = 0 for i in range(n): sum_x -= a[i][0] c[a[i][2]] += sum_x + ((n - i - 1) * a[i][1]) + sum_y + (i * a[i][0]) sum_y += a[i][1] print(*c) if __name__ == '__main__': main() ``` Yes
84,237
[ 0.273193359375, 0.08721923828125, 0.00614166259765625, 0.06488037109375, -0.5322265625, -0.4482421875, -0.277099609375, 0.1927490234375, 0.0762939453125, 0.705078125, 0.31494140625, -0.1312255859375, 0.01361846923828125, -0.74462890625, -0.470703125, -0.2261962890625, -0.6494140625, ...
11
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Zibi is a competitive programming coach. There are n competitors who want to be prepared well. The training contests are quite unusual – there are two people in a team, two problems, and each competitor will code exactly one of them. Of course, people in one team will code different problems. Rules of scoring also aren't typical. The first problem is always an implementation problem: you have to implement some well-known algorithm very fast and the time of your typing is rated. The second one is an awful geometry task and you just have to get it accepted in reasonable time. Here the length and difficulty of your code are important. After that, Zibi will give some penalty points (possibly negative) for each solution and the final score of the team is the sum of them (the less the score is, the better). We know that the i-th competitor will always have score x_i when he codes the first task and y_i when he codes the second task. We can assume, that all competitors know each other's skills and during the contest distribute the problems in the way that minimizes their final score. Remember that each person codes exactly one problem in a contest. Zibi wants all competitors to write a contest with each other. However, there are m pairs of people who really don't like to cooperate and they definitely won't write a contest together. Still, the coach is going to conduct trainings for all possible pairs of people, such that the people in pair don't hate each other. The coach is interested for each participant, what will be his or her sum of scores of all teams he trained in? Input The first line contains two integers n and m (2 ≤ n ≤ 300 000, 0 ≤ m ≤ 300 000) — the number of participants and the number of pairs of people who will not write a contest together. Each of the next n lines contains two integers x_i and y_i (-10^9 ≤ x_i, y_i ≤ 10^9) — the scores which will the i-th competitor get on the first problem and on the second problem. It is guaranteed that there are no two people having both x_i and y_i same. Each of the next m lines contain two integers u_i and v_i (1 ≤ u_i, v_i ≤ n, u_i ≠ v_i) — indices of people who don't want to write a contest in one team. Each unordered pair of indices will appear at most once. Output Output n integers — the sum of scores for all participants in the same order as they appear in the input. Examples Input 3 2 1 2 2 3 1 3 1 2 2 3 Output 3 0 3 Input 3 3 1 2 2 3 1 3 1 2 2 3 1 3 Output 0 0 0 Input 5 3 -1 3 2 4 1 1 3 5 2 2 1 4 2 3 3 5 Output 4 14 4 16 10 Note In the first example, there will be only one team consisting of persons 1 and 3. The optimal strategy for them is to assign the first task to the 3-rd person and the second task to the 1-st person, this will lead to score equal to 1 + 2 = 3. In the second example, nobody likes anyone, so there won't be any trainings. It seems that Zibi won't be titled coach in that case... Submitted Solution: ``` import sys,io stdin = io.FileIO(0) n,m = [int(x) for x in stdin.readline().split()] s = stdin.read() inp = [] sign = 1 numb = 0 for i in range(len(s)): if s[i]>=48: numb = 10*numb + s[i]-48 else: if s[i]==45: sign = -1 elif s[i]!=13: inp.append(sign*numb) numb = 0 sign = 1 if s[-1]>=48: inp.append(sign*numb) order = sorted(range(n),key=lambda i:inp[2*i]-inp[2*i+1]) score = [0]*n val = sum(inp[1:2*n:2]) for ind in range(n): i = order[ind] # Do second problem together with order[:ind] # Do first problem together with order[ind:] score[i] += val + inp[2*i+1]*(ind-1) + inp[2*i]*(n-ind-1) val += inp[2*i]-inp[2*i+1] for _ in range(m): u = inp[2*n+2*_]-1 v = inp[2*n+2*_+1]-1 s = min(inp[2*u]+inp[2*v+1],inp[2*v]+inp[2*u+1]) score[u] -= s score[v] -= s io.FileIO(1,'w').write(str(score).encode()[1:-1].replace(b',',b'')) ``` Yes
84,238
[ 0.273193359375, 0.08721923828125, 0.00614166259765625, 0.06488037109375, -0.5322265625, -0.4482421875, -0.277099609375, 0.1927490234375, 0.0762939453125, 0.705078125, 0.31494140625, -0.1312255859375, 0.01361846923828125, -0.74462890625, -0.470703125, -0.2261962890625, -0.6494140625, ...
11
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Zibi is a competitive programming coach. There are n competitors who want to be prepared well. The training contests are quite unusual – there are two people in a team, two problems, and each competitor will code exactly one of them. Of course, people in one team will code different problems. Rules of scoring also aren't typical. The first problem is always an implementation problem: you have to implement some well-known algorithm very fast and the time of your typing is rated. The second one is an awful geometry task and you just have to get it accepted in reasonable time. Here the length and difficulty of your code are important. After that, Zibi will give some penalty points (possibly negative) for each solution and the final score of the team is the sum of them (the less the score is, the better). We know that the i-th competitor will always have score x_i when he codes the first task and y_i when he codes the second task. We can assume, that all competitors know each other's skills and during the contest distribute the problems in the way that minimizes their final score. Remember that each person codes exactly one problem in a contest. Zibi wants all competitors to write a contest with each other. However, there are m pairs of people who really don't like to cooperate and they definitely won't write a contest together. Still, the coach is going to conduct trainings for all possible pairs of people, such that the people in pair don't hate each other. The coach is interested for each participant, what will be his or her sum of scores of all teams he trained in? Input The first line contains two integers n and m (2 ≤ n ≤ 300 000, 0 ≤ m ≤ 300 000) — the number of participants and the number of pairs of people who will not write a contest together. Each of the next n lines contains two integers x_i and y_i (-10^9 ≤ x_i, y_i ≤ 10^9) — the scores which will the i-th competitor get on the first problem and on the second problem. It is guaranteed that there are no two people having both x_i and y_i same. Each of the next m lines contain two integers u_i and v_i (1 ≤ u_i, v_i ≤ n, u_i ≠ v_i) — indices of people who don't want to write a contest in one team. Each unordered pair of indices will appear at most once. Output Output n integers — the sum of scores for all participants in the same order as they appear in the input. Examples Input 3 2 1 2 2 3 1 3 1 2 2 3 Output 3 0 3 Input 3 3 1 2 2 3 1 3 1 2 2 3 1 3 Output 0 0 0 Input 5 3 -1 3 2 4 1 1 3 5 2 2 1 4 2 3 3 5 Output 4 14 4 16 10 Note In the first example, there will be only one team consisting of persons 1 and 3. The optimal strategy for them is to assign the first task to the 3-rd person and the second task to the 1-st person, this will lead to score equal to 1 + 2 = 3. In the second example, nobody likes anyone, so there won't be any trainings. It seems that Zibi won't be titled coach in that case... Submitted Solution: ``` st = input() n = int(st.split()[0]) m = int(st.split()[1]) a = [] b = [] for i in range(n): st = input() st = st.split() a.append(int(st[0])) b.append(int(st[1])) su = [] def best(u1, u2): if (a[u1]+b[u2] < a[u2]+b[u1]): return a[u1]+b[u2] else: return a[u2]+b[u1] for i in range(n): s = 0 k = 0 while (k < i): s += best(i, k) k += 1 k = i+1 while (k < n): s += best(i, k) k += 1 su.append(s) for i in range(m): st = input() st = st.split() u1 = int(st[0])-1 u2 = int(st[1])-1 su[u1] -= best(u1, u2) su[u2] -= best(u1, u2) ``` No
84,239
[ 0.273193359375, 0.08721923828125, 0.00614166259765625, 0.06488037109375, -0.5322265625, -0.4482421875, -0.277099609375, 0.1927490234375, 0.0762939453125, 0.705078125, 0.31494140625, -0.1312255859375, 0.01361846923828125, -0.74462890625, -0.470703125, -0.2261962890625, -0.6494140625, ...
11
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Zibi is a competitive programming coach. There are n competitors who want to be prepared well. The training contests are quite unusual – there are two people in a team, two problems, and each competitor will code exactly one of them. Of course, people in one team will code different problems. Rules of scoring also aren't typical. The first problem is always an implementation problem: you have to implement some well-known algorithm very fast and the time of your typing is rated. The second one is an awful geometry task and you just have to get it accepted in reasonable time. Here the length and difficulty of your code are important. After that, Zibi will give some penalty points (possibly negative) for each solution and the final score of the team is the sum of them (the less the score is, the better). We know that the i-th competitor will always have score x_i when he codes the first task and y_i when he codes the second task. We can assume, that all competitors know each other's skills and during the contest distribute the problems in the way that minimizes their final score. Remember that each person codes exactly one problem in a contest. Zibi wants all competitors to write a contest with each other. However, there are m pairs of people who really don't like to cooperate and they definitely won't write a contest together. Still, the coach is going to conduct trainings for all possible pairs of people, such that the people in pair don't hate each other. The coach is interested for each participant, what will be his or her sum of scores of all teams he trained in? Input The first line contains two integers n and m (2 ≤ n ≤ 300 000, 0 ≤ m ≤ 300 000) — the number of participants and the number of pairs of people who will not write a contest together. Each of the next n lines contains two integers x_i and y_i (-10^9 ≤ x_i, y_i ≤ 10^9) — the scores which will the i-th competitor get on the first problem and on the second problem. It is guaranteed that there are no two people having both x_i and y_i same. Each of the next m lines contain two integers u_i and v_i (1 ≤ u_i, v_i ≤ n, u_i ≠ v_i) — indices of people who don't want to write a contest in one team. Each unordered pair of indices will appear at most once. Output Output n integers — the sum of scores for all participants in the same order as they appear in the input. Examples Input 3 2 1 2 2 3 1 3 1 2 2 3 Output 3 0 3 Input 3 3 1 2 2 3 1 3 1 2 2 3 1 3 Output 0 0 0 Input 5 3 -1 3 2 4 1 1 3 5 2 2 1 4 2 3 3 5 Output 4 14 4 16 10 Note In the first example, there will be only one team consisting of persons 1 and 3. The optimal strategy for them is to assign the first task to the 3-rd person and the second task to the 1-st person, this will lead to score equal to 1 + 2 = 3. In the second example, nobody likes anyone, so there won't be any trainings. It seems that Zibi won't be titled coach in that case... Submitted Solution: ``` n, k = [int(i) for i in input().split()] p = [[0,0] for i in range(n)] a = [0 for i in range(n)] for i in range(n): p[i] = [int(k) for k in input().split()] for j in range(i): d = min([p[i][0]+p[j][1], p[i][1] + p[j][0]]) a[j] += d a[i] += d for i in range(k): u, v = [int(k)-1 for k in input().split()] d = min([p[u][0]+p[v][1], p[u][1] + p[v][0]]) a[u] -= d a[v] -= d print(a) ``` No
84,240
[ 0.273193359375, 0.08721923828125, 0.00614166259765625, 0.06488037109375, -0.5322265625, -0.4482421875, -0.277099609375, 0.1927490234375, 0.0762939453125, 0.705078125, 0.31494140625, -0.1312255859375, 0.01361846923828125, -0.74462890625, -0.470703125, -0.2261962890625, -0.6494140625, ...
11
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Zibi is a competitive programming coach. There are n competitors who want to be prepared well. The training contests are quite unusual – there are two people in a team, two problems, and each competitor will code exactly one of them. Of course, people in one team will code different problems. Rules of scoring also aren't typical. The first problem is always an implementation problem: you have to implement some well-known algorithm very fast and the time of your typing is rated. The second one is an awful geometry task and you just have to get it accepted in reasonable time. Here the length and difficulty of your code are important. After that, Zibi will give some penalty points (possibly negative) for each solution and the final score of the team is the sum of them (the less the score is, the better). We know that the i-th competitor will always have score x_i when he codes the first task and y_i when he codes the second task. We can assume, that all competitors know each other's skills and during the contest distribute the problems in the way that minimizes their final score. Remember that each person codes exactly one problem in a contest. Zibi wants all competitors to write a contest with each other. However, there are m pairs of people who really don't like to cooperate and they definitely won't write a contest together. Still, the coach is going to conduct trainings for all possible pairs of people, such that the people in pair don't hate each other. The coach is interested for each participant, what will be his or her sum of scores of all teams he trained in? Input The first line contains two integers n and m (2 ≤ n ≤ 300 000, 0 ≤ m ≤ 300 000) — the number of participants and the number of pairs of people who will not write a contest together. Each of the next n lines contains two integers x_i and y_i (-10^9 ≤ x_i, y_i ≤ 10^9) — the scores which will the i-th competitor get on the first problem and on the second problem. It is guaranteed that there are no two people having both x_i and y_i same. Each of the next m lines contain two integers u_i and v_i (1 ≤ u_i, v_i ≤ n, u_i ≠ v_i) — indices of people who don't want to write a contest in one team. Each unordered pair of indices will appear at most once. Output Output n integers — the sum of scores for all participants in the same order as they appear in the input. Examples Input 3 2 1 2 2 3 1 3 1 2 2 3 Output 3 0 3 Input 3 3 1 2 2 3 1 3 1 2 2 3 1 3 Output 0 0 0 Input 5 3 -1 3 2 4 1 1 3 5 2 2 1 4 2 3 3 5 Output 4 14 4 16 10 Note In the first example, there will be only one team consisting of persons 1 and 3. The optimal strategy for them is to assign the first task to the 3-rd person and the second task to the 1-st person, this will lead to score equal to 1 + 2 = 3. In the second example, nobody likes anyone, so there won't be any trainings. It seems that Zibi won't be titled coach in that case... Submitted Solution: ``` import sys from collections import defaultdict def main(): [n, m] = map(int, next(sys.stdin).split()) a = [] orig = [()] xs, ys = 0, 0 for i in range(1,n+1): [x,y] = map(int, next(sys.stdin).split()) a.append((x, y, i)) orig.append((x, y)) ys += y nt = defaultdict(list) for i in range(1,m+1): [u, v] = map(int, next(sys.stdin).split()) nt[u].append(v) nt[v].append(u) a.sort(key=lambda p: p[0]-p[1]) print(a) seen = set() res = [0]*(n+1) for i, (x, y, idx) in enumerate(a): ys -= y s = i*y + (n-1-i)*x + xs + ys for v in nt[idx]: if v in seen: s -= y + orig[v][0] else: s -= x + orig[v][1] res[idx] = s xs += x seen.add(idx) print(' '.join(map(str,res[1:]))) if __name__ == '__main__': main() ``` No
84,241
[ 0.273193359375, 0.08721923828125, 0.00614166259765625, 0.06488037109375, -0.5322265625, -0.4482421875, -0.277099609375, 0.1927490234375, 0.0762939453125, 0.705078125, 0.31494140625, -0.1312255859375, 0.01361846923828125, -0.74462890625, -0.470703125, -0.2261962890625, -0.6494140625, ...
11
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Zibi is a competitive programming coach. There are n competitors who want to be prepared well. The training contests are quite unusual – there are two people in a team, two problems, and each competitor will code exactly one of them. Of course, people in one team will code different problems. Rules of scoring also aren't typical. The first problem is always an implementation problem: you have to implement some well-known algorithm very fast and the time of your typing is rated. The second one is an awful geometry task and you just have to get it accepted in reasonable time. Here the length and difficulty of your code are important. After that, Zibi will give some penalty points (possibly negative) for each solution and the final score of the team is the sum of them (the less the score is, the better). We know that the i-th competitor will always have score x_i when he codes the first task and y_i when he codes the second task. We can assume, that all competitors know each other's skills and during the contest distribute the problems in the way that minimizes their final score. Remember that each person codes exactly one problem in a contest. Zibi wants all competitors to write a contest with each other. However, there are m pairs of people who really don't like to cooperate and they definitely won't write a contest together. Still, the coach is going to conduct trainings for all possible pairs of people, such that the people in pair don't hate each other. The coach is interested for each participant, what will be his or her sum of scores of all teams he trained in? Input The first line contains two integers n and m (2 ≤ n ≤ 300 000, 0 ≤ m ≤ 300 000) — the number of participants and the number of pairs of people who will not write a contest together. Each of the next n lines contains two integers x_i and y_i (-10^9 ≤ x_i, y_i ≤ 10^9) — the scores which will the i-th competitor get on the first problem and on the second problem. It is guaranteed that there are no two people having both x_i and y_i same. Each of the next m lines contain two integers u_i and v_i (1 ≤ u_i, v_i ≤ n, u_i ≠ v_i) — indices of people who don't want to write a contest in one team. Each unordered pair of indices will appear at most once. Output Output n integers — the sum of scores for all participants in the same order as they appear in the input. Examples Input 3 2 1 2 2 3 1 3 1 2 2 3 Output 3 0 3 Input 3 3 1 2 2 3 1 3 1 2 2 3 1 3 Output 0 0 0 Input 5 3 -1 3 2 4 1 1 3 5 2 2 1 4 2 3 3 5 Output 4 14 4 16 10 Note In the first example, there will be only one team consisting of persons 1 and 3. The optimal strategy for them is to assign the first task to the 3-rd person and the second task to the 1-st person, this will lead to score equal to 1 + 2 = 3. In the second example, nobody likes anyone, so there won't be any trainings. It seems that Zibi won't be titled coach in that case... Submitted Solution: ``` from __future__ import division, print_function import itertools import os import sys from atexit import register if sys.version_info[0] < 3: from cStringIO import StringIO range = xrange filter = itertools.ifilter map = itertools.imap zip = itertools.izip else: from io import BytesIO as StringIO sys.stdout = StringIO() register(lambda: os.write(1, sys.stdout.getvalue())) if sys.version_info[0] >= 3: _write = sys.stdout.write sys.stdout.write = lambda s: _write(s.encode()) s = os.read(0, os.fstat(0).st_size) inp = [] sign = 1 numb = 0 for i in range(len(s)): if s[i] >= 48: numb = 10 * numb + s[i] - 48 else: if s[i] == 45: sign = -1 elif s[i] != 13: inp.append(sign * numb) numb = 0 sign = 1 if s[-1] >= 48: inp.append(sign * numb) n = inp[0] m = inp[1] for i in range(2, 2 * n + 2): inp[i] *= 1.0 order = sorted(range(n), key=lambda i: inp[2 * i + 2] - inp[2 * i + 3]) score = [0.0] * n val = sum(inp[3:2 * n + 2:2]) for ind in range(n): i = order[ind] # Do second problem together with order[:ind] # Do first problem together with order[ind:] score[i] += val + inp[2 * i + 3] * (ind - 1) + inp[2 * i + 2] * (n - ind - 1) val += inp[2 * i + 2] - inp[2 * i + 3] for _ in range(m): u = inp[2 * n + 2 * _ + 2] - 1 v = inp[2 * n + 2 * _ + 3] - 1 s = min(inp[2 * u + 2] + inp[2 * v + 3], inp[2 * v + 2] + inp[2 * u + 3]) score[u] -= s score[v] -= s print(*map(int, score)) os.write(1, sys.stdout.getvalue()) ``` No
84,242
[ 0.273193359375, 0.08721923828125, 0.00614166259765625, 0.06488037109375, -0.5322265625, -0.4482421875, -0.277099609375, 0.1927490234375, 0.0762939453125, 0.705078125, 0.31494140625, -0.1312255859375, 0.01361846923828125, -0.74462890625, -0.470703125, -0.2261962890625, -0.6494140625, ...
11
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You have got a shelf and want to put some books on it. You are given q queries of three types: 1. L id — put a book having index id on the shelf to the left from the leftmost existing book; 2. R id — put a book having index id on the shelf to the right from the rightmost existing book; 3. ? id — calculate the minimum number of books you need to pop from the left or from the right in such a way that the book with index id will be leftmost or rightmost. You can assume that the first book you will put can have any position (it does not matter) and queries of type 3 are always valid (it is guaranteed that the book in each such query is already placed). You can also assume that you don't put the same book on the shelf twice, so ids don't repeat in queries of first two types. Your problem is to answer all the queries of type 3 in order they appear in the input. Note that after answering the query of type 3 all the books remain on the shelf and the relative order of books does not change. If you are Python programmer, consider using PyPy instead of Python when you submit your code. Input The first line of the input contains one integer q (1 ≤ q ≤ 2 ⋅ 10^5) — the number of queries. Then q lines follow. The i-th line contains the i-th query in format as in the problem statement. It is guaranteed that queries are always valid (for query type 3, it is guaranteed that the book in each such query is already placed, and for other types, it is guaranteed that the book was not placed before). It is guaranteed that there is at least one query of type 3 in the input. In each query the constraint 1 ≤ id ≤ 2 ⋅ 10^5 is met. Output Print answers to queries of the type 3 in order they appear in the input. Examples Input 8 L 1 R 2 R 3 ? 2 L 4 ? 1 L 5 ? 1 Output 1 1 2 Input 10 L 100 R 100000 R 123 L 101 ? 123 L 10 R 115 ? 100 R 110 ? 115 Output 0 2 1 Note Let's take a look at the first example and let's consider queries: 1. The shelf will look like [1]; 2. The shelf will look like [1, 2]; 3. The shelf will look like [1, 2, 3]; 4. The shelf looks like [1, 2, 3] so the answer is 1; 5. The shelf will look like [4, 1, 2, 3]; 6. The shelf looks like [4, 1, 2, 3] so the answer is 1; 7. The shelf will look like [5, 4, 1, 2, 3]; 8. The shelf looks like [5, 4, 1, 2, 3] so the answer is 2. Let's take a look at the second example and let's consider queries: 1. The shelf will look like [100]; 2. The shelf will look like [100, 100000]; 3. The shelf will look like [100, 100000, 123]; 4. The shelf will look like [101, 100, 100000, 123]; 5. The shelf looks like [101, 100, 100000, 123] so the answer is 0; 6. The shelf will look like [10, 101, 100, 100000, 123]; 7. The shelf will look like [10, 101, 100, 100000, 123, 115]; 8. The shelf looks like [10, 101, 100, 100000, 123, 115] so the answer is 2; 9. The shelf will look like [10, 101, 100, 100000, 123, 115, 110]; 10. The shelf looks like [10, 101, 100, 100000, 123, 115, 110] so the answer is 1. Submitted Solution: ``` import sys def minp(): return sys.stdin.readline().strip() a = [0]*(2*(10**5)) w = [0]*(2*(10**5)+1) q = int(minp()) l = 0 r = 0 for i in range(q): c,id = minp().split() id = int(id) if c == 'L': l -= 1 if l < 0: l = 199999 a[l] = id w[id] = l elif c == 'R': a[r] = id w[id] = r r += 1 if r == 200000: r = 0 else: print(min((w[id]-l+400000)%200000,(r-w[id]-1+400000)%200000)) ``` Yes
84,251
[ 0.0804443359375, -0.111328125, 0.11846923828125, -0.157958984375, -0.47314453125, -0.2333984375, -0.036773681640625, 0.08294677734375, 0.052398681640625, 0.76171875, -0.09814453125, -0.11407470703125, -0.0869140625, -0.466796875, -0.5615234375, 0.0809326171875, -0.634765625, -0.285...
11
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You have got a shelf and want to put some books on it. You are given q queries of three types: 1. L id — put a book having index id on the shelf to the left from the leftmost existing book; 2. R id — put a book having index id on the shelf to the right from the rightmost existing book; 3. ? id — calculate the minimum number of books you need to pop from the left or from the right in such a way that the book with index id will be leftmost or rightmost. You can assume that the first book you will put can have any position (it does not matter) and queries of type 3 are always valid (it is guaranteed that the book in each such query is already placed). You can also assume that you don't put the same book on the shelf twice, so ids don't repeat in queries of first two types. Your problem is to answer all the queries of type 3 in order they appear in the input. Note that after answering the query of type 3 all the books remain on the shelf and the relative order of books does not change. If you are Python programmer, consider using PyPy instead of Python when you submit your code. Input The first line of the input contains one integer q (1 ≤ q ≤ 2 ⋅ 10^5) — the number of queries. Then q lines follow. The i-th line contains the i-th query in format as in the problem statement. It is guaranteed that queries are always valid (for query type 3, it is guaranteed that the book in each such query is already placed, and for other types, it is guaranteed that the book was not placed before). It is guaranteed that there is at least one query of type 3 in the input. In each query the constraint 1 ≤ id ≤ 2 ⋅ 10^5 is met. Output Print answers to queries of the type 3 in order they appear in the input. Examples Input 8 L 1 R 2 R 3 ? 2 L 4 ? 1 L 5 ? 1 Output 1 1 2 Input 10 L 100 R 100000 R 123 L 101 ? 123 L 10 R 115 ? 100 R 110 ? 115 Output 0 2 1 Note Let's take a look at the first example and let's consider queries: 1. The shelf will look like [1]; 2. The shelf will look like [1, 2]; 3. The shelf will look like [1, 2, 3]; 4. The shelf looks like [1, 2, 3] so the answer is 1; 5. The shelf will look like [4, 1, 2, 3]; 6. The shelf looks like [4, 1, 2, 3] so the answer is 1; 7. The shelf will look like [5, 4, 1, 2, 3]; 8. The shelf looks like [5, 4, 1, 2, 3] so the answer is 2. Let's take a look at the second example and let's consider queries: 1. The shelf will look like [100]; 2. The shelf will look like [100, 100000]; 3. The shelf will look like [100, 100000, 123]; 4. The shelf will look like [101, 100, 100000, 123]; 5. The shelf looks like [101, 100, 100000, 123] so the answer is 0; 6. The shelf will look like [10, 101, 100, 100000, 123]; 7. The shelf will look like [10, 101, 100, 100000, 123, 115]; 8. The shelf looks like [10, 101, 100, 100000, 123, 115] so the answer is 2; 9. The shelf will look like [10, 101, 100, 100000, 123, 115, 110]; 10. The shelf looks like [10, 101, 100, 100000, 123, 115, 110] so the answer is 1. Submitted Solution: ``` p=input() a=[0]*1000000 h=[] r=1 l=0 i=1 while i<=int(p): MainInput = input().split(" ") x= MainInput[0] m=int(MainInput[1]) if x=='R' : a[m]=r r+=1 elif x=='L' : a[m]=l l-=1 elif x=='?' : h.append(min(a[m]-l-1,r-a[m]-1)) i+=1 for x in range(len(h)): print(h[x]) ``` Yes
84,252
[ 0.0804443359375, -0.111328125, 0.11846923828125, -0.157958984375, -0.47314453125, -0.2333984375, -0.036773681640625, 0.08294677734375, 0.052398681640625, 0.76171875, -0.09814453125, -0.11407470703125, -0.0869140625, -0.466796875, -0.5615234375, 0.0809326171875, -0.634765625, -0.285...
11
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You have got a shelf and want to put some books on it. You are given q queries of three types: 1. L id — put a book having index id on the shelf to the left from the leftmost existing book; 2. R id — put a book having index id on the shelf to the right from the rightmost existing book; 3. ? id — calculate the minimum number of books you need to pop from the left or from the right in such a way that the book with index id will be leftmost or rightmost. You can assume that the first book you will put can have any position (it does not matter) and queries of type 3 are always valid (it is guaranteed that the book in each such query is already placed). You can also assume that you don't put the same book on the shelf twice, so ids don't repeat in queries of first two types. Your problem is to answer all the queries of type 3 in order they appear in the input. Note that after answering the query of type 3 all the books remain on the shelf and the relative order of books does not change. If you are Python programmer, consider using PyPy instead of Python when you submit your code. Input The first line of the input contains one integer q (1 ≤ q ≤ 2 ⋅ 10^5) — the number of queries. Then q lines follow. The i-th line contains the i-th query in format as in the problem statement. It is guaranteed that queries are always valid (for query type 3, it is guaranteed that the book in each such query is already placed, and for other types, it is guaranteed that the book was not placed before). It is guaranteed that there is at least one query of type 3 in the input. In each query the constraint 1 ≤ id ≤ 2 ⋅ 10^5 is met. Output Print answers to queries of the type 3 in order they appear in the input. Examples Input 8 L 1 R 2 R 3 ? 2 L 4 ? 1 L 5 ? 1 Output 1 1 2 Input 10 L 100 R 100000 R 123 L 101 ? 123 L 10 R 115 ? 100 R 110 ? 115 Output 0 2 1 Note Let's take a look at the first example and let's consider queries: 1. The shelf will look like [1]; 2. The shelf will look like [1, 2]; 3. The shelf will look like [1, 2, 3]; 4. The shelf looks like [1, 2, 3] so the answer is 1; 5. The shelf will look like [4, 1, 2, 3]; 6. The shelf looks like [4, 1, 2, 3] so the answer is 1; 7. The shelf will look like [5, 4, 1, 2, 3]; 8. The shelf looks like [5, 4, 1, 2, 3] so the answer is 2. Let's take a look at the second example and let's consider queries: 1. The shelf will look like [100]; 2. The shelf will look like [100, 100000]; 3. The shelf will look like [100, 100000, 123]; 4. The shelf will look like [101, 100, 100000, 123]; 5. The shelf looks like [101, 100, 100000, 123] so the answer is 0; 6. The shelf will look like [10, 101, 100, 100000, 123]; 7. The shelf will look like [10, 101, 100, 100000, 123, 115]; 8. The shelf looks like [10, 101, 100, 100000, 123, 115] so the answer is 2; 9. The shelf will look like [10, 101, 100, 100000, 123, 115, 110]; 10. The shelf looks like [10, 101, 100, 100000, 123, 115, 110] so the answer is 1. Submitted Solution: ``` # SHRi GANESHA author: Kunal Verma # import os,sys from collections import defaultdict, Counter, deque from io import BytesIO, IOBase from math import gcd, ceil def lcm(a,b): return (a*b)//gcd(a,b) ''' mod = 10 ** 9 + 7 fac = [1] for i in range(1, 2 * 10 ** 5 + 1): fac.append((fac[-1] * i) % mod) fac_in = [pow(fac[-1], mod - 2, mod)] for i in range(2 * 10 ** 5, 0, -1): fac_in.append((fac_in[-1] * i) % mod) fac_in.reverse() def comb(a, b): if a < b: return 0 return (fac[a] * fac_in[b] * fac_in[a - b]) % mod ''' MAXN = 100001 spf = [0 for i in range(MAXN)] def getFactorization(x): ret = list() while (x != 1): ret.append(spf[x]) x = x // spf[x] return ret def main(): pos=[0]*2000000 up,do=1,0 for _ in range(int(input())): a,b = input().split() if a=='L' : up-=1 pos[int(b)]=up elif a=='R': do+=1 pos[int(b)]=do else: print(min(pos[int(b)]-up,do-pos[int(b)])) #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() ``` Yes
84,253
[ 0.0804443359375, -0.111328125, 0.11846923828125, -0.157958984375, -0.47314453125, -0.2333984375, -0.036773681640625, 0.08294677734375, 0.052398681640625, 0.76171875, -0.09814453125, -0.11407470703125, -0.0869140625, -0.466796875, -0.5615234375, 0.0809326171875, -0.634765625, -0.285...
11
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You have got a shelf and want to put some books on it. You are given q queries of three types: 1. L id — put a book having index id on the shelf to the left from the leftmost existing book; 2. R id — put a book having index id on the shelf to the right from the rightmost existing book; 3. ? id — calculate the minimum number of books you need to pop from the left or from the right in such a way that the book with index id will be leftmost or rightmost. You can assume that the first book you will put can have any position (it does not matter) and queries of type 3 are always valid (it is guaranteed that the book in each such query is already placed). You can also assume that you don't put the same book on the shelf twice, so ids don't repeat in queries of first two types. Your problem is to answer all the queries of type 3 in order they appear in the input. Note that after answering the query of type 3 all the books remain on the shelf and the relative order of books does not change. If you are Python programmer, consider using PyPy instead of Python when you submit your code. Input The first line of the input contains one integer q (1 ≤ q ≤ 2 ⋅ 10^5) — the number of queries. Then q lines follow. The i-th line contains the i-th query in format as in the problem statement. It is guaranteed that queries are always valid (for query type 3, it is guaranteed that the book in each such query is already placed, and for other types, it is guaranteed that the book was not placed before). It is guaranteed that there is at least one query of type 3 in the input. In each query the constraint 1 ≤ id ≤ 2 ⋅ 10^5 is met. Output Print answers to queries of the type 3 in order they appear in the input. Examples Input 8 L 1 R 2 R 3 ? 2 L 4 ? 1 L 5 ? 1 Output 1 1 2 Input 10 L 100 R 100000 R 123 L 101 ? 123 L 10 R 115 ? 100 R 110 ? 115 Output 0 2 1 Note Let's take a look at the first example and let's consider queries: 1. The shelf will look like [1]; 2. The shelf will look like [1, 2]; 3. The shelf will look like [1, 2, 3]; 4. The shelf looks like [1, 2, 3] so the answer is 1; 5. The shelf will look like [4, 1, 2, 3]; 6. The shelf looks like [4, 1, 2, 3] so the answer is 1; 7. The shelf will look like [5, 4, 1, 2, 3]; 8. The shelf looks like [5, 4, 1, 2, 3] so the answer is 2. Let's take a look at the second example and let's consider queries: 1. The shelf will look like [100]; 2. The shelf will look like [100, 100000]; 3. The shelf will look like [100, 100000, 123]; 4. The shelf will look like [101, 100, 100000, 123]; 5. The shelf looks like [101, 100, 100000, 123] so the answer is 0; 6. The shelf will look like [10, 101, 100, 100000, 123]; 7. The shelf will look like [10, 101, 100, 100000, 123, 115]; 8. The shelf looks like [10, 101, 100, 100000, 123, 115] so the answer is 2; 9. The shelf will look like [10, 101, 100, 100000, 123, 115, 110]; 10. The shelf looks like [10, 101, 100, 100000, 123, 115, 110] so the answer is 1. Submitted Solution: ``` q = int(input()) mem = dict() _, n = input().split() n = int(n) left = 0 right = 0 mem[n] = 0 for _ in range(q - 1): s, n = input().split() n = int(n) if s == 'L': left -= 1 mem[n] = left elif s == 'R': right += 1 mem[n] = right else: print(min(mem[n] - left, right - mem[n])) ``` Yes
84,254
[ 0.0804443359375, -0.111328125, 0.11846923828125, -0.157958984375, -0.47314453125, -0.2333984375, -0.036773681640625, 0.08294677734375, 0.052398681640625, 0.76171875, -0.09814453125, -0.11407470703125, -0.0869140625, -0.466796875, -0.5615234375, 0.0809326171875, -0.634765625, -0.285...
11
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You have got a shelf and want to put some books on it. You are given q queries of three types: 1. L id — put a book having index id on the shelf to the left from the leftmost existing book; 2. R id — put a book having index id on the shelf to the right from the rightmost existing book; 3. ? id — calculate the minimum number of books you need to pop from the left or from the right in such a way that the book with index id will be leftmost or rightmost. You can assume that the first book you will put can have any position (it does not matter) and queries of type 3 are always valid (it is guaranteed that the book in each such query is already placed). You can also assume that you don't put the same book on the shelf twice, so ids don't repeat in queries of first two types. Your problem is to answer all the queries of type 3 in order they appear in the input. Note that after answering the query of type 3 all the books remain on the shelf and the relative order of books does not change. If you are Python programmer, consider using PyPy instead of Python when you submit your code. Input The first line of the input contains one integer q (1 ≤ q ≤ 2 ⋅ 10^5) — the number of queries. Then q lines follow. The i-th line contains the i-th query in format as in the problem statement. It is guaranteed that queries are always valid (for query type 3, it is guaranteed that the book in each such query is already placed, and for other types, it is guaranteed that the book was not placed before). It is guaranteed that there is at least one query of type 3 in the input. In each query the constraint 1 ≤ id ≤ 2 ⋅ 10^5 is met. Output Print answers to queries of the type 3 in order they appear in the input. Examples Input 8 L 1 R 2 R 3 ? 2 L 4 ? 1 L 5 ? 1 Output 1 1 2 Input 10 L 100 R 100000 R 123 L 101 ? 123 L 10 R 115 ? 100 R 110 ? 115 Output 0 2 1 Note Let's take a look at the first example and let's consider queries: 1. The shelf will look like [1]; 2. The shelf will look like [1, 2]; 3. The shelf will look like [1, 2, 3]; 4. The shelf looks like [1, 2, 3] so the answer is 1; 5. The shelf will look like [4, 1, 2, 3]; 6. The shelf looks like [4, 1, 2, 3] so the answer is 1; 7. The shelf will look like [5, 4, 1, 2, 3]; 8. The shelf looks like [5, 4, 1, 2, 3] so the answer is 2. Let's take a look at the second example and let's consider queries: 1. The shelf will look like [100]; 2. The shelf will look like [100, 100000]; 3. The shelf will look like [100, 100000, 123]; 4. The shelf will look like [101, 100, 100000, 123]; 5. The shelf looks like [101, 100, 100000, 123] so the answer is 0; 6. The shelf will look like [10, 101, 100, 100000, 123]; 7. The shelf will look like [10, 101, 100, 100000, 123, 115]; 8. The shelf looks like [10, 101, 100, 100000, 123, 115] so the answer is 2; 9. The shelf will look like [10, 101, 100, 100000, 123, 115, 110]; 10. The shelf looks like [10, 101, 100, 100000, 123, 115, 110] so the answer is 1. Submitted Solution: ``` def MinNumOfBooks(): numBook = int(input()) bookShelf = [] shelf = [] for l in range(numBook): temp = input() bookShelf.append([temp[0], temp[2:]]) print(bookShelf) for i in bookShelf: if i[0] == 'R': shelf.append(i[1]) elif i[0] == 'L': shelf.insert(0, i[1]) elif i[0] == '?': ind = shelf.index(i[1]) if ind < len(shelf)/2: print(ind) else: shelf.reverse() ind = shelf.index(i[1]) print(ind) shelf.reverse() MinNumOfBooks() ``` No
84,255
[ 0.0804443359375, -0.111328125, 0.11846923828125, -0.157958984375, -0.47314453125, -0.2333984375, -0.036773681640625, 0.08294677734375, 0.052398681640625, 0.76171875, -0.09814453125, -0.11407470703125, -0.0869140625, -0.466796875, -0.5615234375, 0.0809326171875, -0.634765625, -0.285...
11
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You have got a shelf and want to put some books on it. You are given q queries of three types: 1. L id — put a book having index id on the shelf to the left from the leftmost existing book; 2. R id — put a book having index id on the shelf to the right from the rightmost existing book; 3. ? id — calculate the minimum number of books you need to pop from the left or from the right in such a way that the book with index id will be leftmost or rightmost. You can assume that the first book you will put can have any position (it does not matter) and queries of type 3 are always valid (it is guaranteed that the book in each such query is already placed). You can also assume that you don't put the same book on the shelf twice, so ids don't repeat in queries of first two types. Your problem is to answer all the queries of type 3 in order they appear in the input. Note that after answering the query of type 3 all the books remain on the shelf and the relative order of books does not change. If you are Python programmer, consider using PyPy instead of Python when you submit your code. Input The first line of the input contains one integer q (1 ≤ q ≤ 2 ⋅ 10^5) — the number of queries. Then q lines follow. The i-th line contains the i-th query in format as in the problem statement. It is guaranteed that queries are always valid (for query type 3, it is guaranteed that the book in each such query is already placed, and for other types, it is guaranteed that the book was not placed before). It is guaranteed that there is at least one query of type 3 in the input. In each query the constraint 1 ≤ id ≤ 2 ⋅ 10^5 is met. Output Print answers to queries of the type 3 in order they appear in the input. Examples Input 8 L 1 R 2 R 3 ? 2 L 4 ? 1 L 5 ? 1 Output 1 1 2 Input 10 L 100 R 100000 R 123 L 101 ? 123 L 10 R 115 ? 100 R 110 ? 115 Output 0 2 1 Note Let's take a look at the first example and let's consider queries: 1. The shelf will look like [1]; 2. The shelf will look like [1, 2]; 3. The shelf will look like [1, 2, 3]; 4. The shelf looks like [1, 2, 3] so the answer is 1; 5. The shelf will look like [4, 1, 2, 3]; 6. The shelf looks like [4, 1, 2, 3] so the answer is 1; 7. The shelf will look like [5, 4, 1, 2, 3]; 8. The shelf looks like [5, 4, 1, 2, 3] so the answer is 2. Let's take a look at the second example and let's consider queries: 1. The shelf will look like [100]; 2. The shelf will look like [100, 100000]; 3. The shelf will look like [100, 100000, 123]; 4. The shelf will look like [101, 100, 100000, 123]; 5. The shelf looks like [101, 100, 100000, 123] so the answer is 0; 6. The shelf will look like [10, 101, 100, 100000, 123]; 7. The shelf will look like [10, 101, 100, 100000, 123, 115]; 8. The shelf looks like [10, 101, 100, 100000, 123, 115] so the answer is 2; 9. The shelf will look like [10, 101, 100, 100000, 123, 115, 110]; 10. The shelf looks like [10, 101, 100, 100000, 123, 115, 110] so the answer is 1. Submitted Solution: ``` q = int(input()) l = 0 r = 0 CHISLO = 200001 al = [0]*CHISLO ar = [0]*CHISLO for i in range(q): s = input().split() if s[0] == 'L': al[int(s[1])] = -l-1 ar[int(s[1])] = 0 l += 1 elif s[0] == 'R': ar[int(s[1])] = -r-1 al[int(s[1])] = 0 r += 1 else: print(min(al[int(s[1])]+l, ar[int(s[1])]+r)) ``` No
84,256
[ 0.0804443359375, -0.111328125, 0.11846923828125, -0.157958984375, -0.47314453125, -0.2333984375, -0.036773681640625, 0.08294677734375, 0.052398681640625, 0.76171875, -0.09814453125, -0.11407470703125, -0.0869140625, -0.466796875, -0.5615234375, 0.0809326171875, -0.634765625, -0.285...
11
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You have got a shelf and want to put some books on it. You are given q queries of three types: 1. L id — put a book having index id on the shelf to the left from the leftmost existing book; 2. R id — put a book having index id on the shelf to the right from the rightmost existing book; 3. ? id — calculate the minimum number of books you need to pop from the left or from the right in such a way that the book with index id will be leftmost or rightmost. You can assume that the first book you will put can have any position (it does not matter) and queries of type 3 are always valid (it is guaranteed that the book in each such query is already placed). You can also assume that you don't put the same book on the shelf twice, so ids don't repeat in queries of first two types. Your problem is to answer all the queries of type 3 in order they appear in the input. Note that after answering the query of type 3 all the books remain on the shelf and the relative order of books does not change. If you are Python programmer, consider using PyPy instead of Python when you submit your code. Input The first line of the input contains one integer q (1 ≤ q ≤ 2 ⋅ 10^5) — the number of queries. Then q lines follow. The i-th line contains the i-th query in format as in the problem statement. It is guaranteed that queries are always valid (for query type 3, it is guaranteed that the book in each such query is already placed, and for other types, it is guaranteed that the book was not placed before). It is guaranteed that there is at least one query of type 3 in the input. In each query the constraint 1 ≤ id ≤ 2 ⋅ 10^5 is met. Output Print answers to queries of the type 3 in order they appear in the input. Examples Input 8 L 1 R 2 R 3 ? 2 L 4 ? 1 L 5 ? 1 Output 1 1 2 Input 10 L 100 R 100000 R 123 L 101 ? 123 L 10 R 115 ? 100 R 110 ? 115 Output 0 2 1 Note Let's take a look at the first example and let's consider queries: 1. The shelf will look like [1]; 2. The shelf will look like [1, 2]; 3. The shelf will look like [1, 2, 3]; 4. The shelf looks like [1, 2, 3] so the answer is 1; 5. The shelf will look like [4, 1, 2, 3]; 6. The shelf looks like [4, 1, 2, 3] so the answer is 1; 7. The shelf will look like [5, 4, 1, 2, 3]; 8. The shelf looks like [5, 4, 1, 2, 3] so the answer is 2. Let's take a look at the second example and let's consider queries: 1. The shelf will look like [100]; 2. The shelf will look like [100, 100000]; 3. The shelf will look like [100, 100000, 123]; 4. The shelf will look like [101, 100, 100000, 123]; 5. The shelf looks like [101, 100, 100000, 123] so the answer is 0; 6. The shelf will look like [10, 101, 100, 100000, 123]; 7. The shelf will look like [10, 101, 100, 100000, 123, 115]; 8. The shelf looks like [10, 101, 100, 100000, 123, 115] so the answer is 2; 9. The shelf will look like [10, 101, 100, 100000, 123, 115, 110]; 10. The shelf looks like [10, 101, 100, 100000, 123, 115, 110] so the answer is 1. Submitted Solution: ``` from collections import deque import bisect q = deque() d = {} d1 = {} n = int(input()) length = 0 curr_index = 0 for _ in range(n): a,b = input().split() if a=="L": if d.get(0) is not None: curr_index+=1 else: d[0] = int(b) length+=1 d1[int(b)] = 0 elif a=="R": d[length] = int(b) d1[int(b)] = length-curr_index length+=1 else: val = d1[int(b)]+curr_index print(min(val,length-val-1)) ``` No
84,257
[ 0.0804443359375, -0.111328125, 0.11846923828125, -0.157958984375, -0.47314453125, -0.2333984375, -0.036773681640625, 0.08294677734375, 0.052398681640625, 0.76171875, -0.09814453125, -0.11407470703125, -0.0869140625, -0.466796875, -0.5615234375, 0.0809326171875, -0.634765625, -0.285...
11
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You have got a shelf and want to put some books on it. You are given q queries of three types: 1. L id — put a book having index id on the shelf to the left from the leftmost existing book; 2. R id — put a book having index id on the shelf to the right from the rightmost existing book; 3. ? id — calculate the minimum number of books you need to pop from the left or from the right in such a way that the book with index id will be leftmost or rightmost. You can assume that the first book you will put can have any position (it does not matter) and queries of type 3 are always valid (it is guaranteed that the book in each such query is already placed). You can also assume that you don't put the same book on the shelf twice, so ids don't repeat in queries of first two types. Your problem is to answer all the queries of type 3 in order they appear in the input. Note that after answering the query of type 3 all the books remain on the shelf and the relative order of books does not change. If you are Python programmer, consider using PyPy instead of Python when you submit your code. Input The first line of the input contains one integer q (1 ≤ q ≤ 2 ⋅ 10^5) — the number of queries. Then q lines follow. The i-th line contains the i-th query in format as in the problem statement. It is guaranteed that queries are always valid (for query type 3, it is guaranteed that the book in each such query is already placed, and for other types, it is guaranteed that the book was not placed before). It is guaranteed that there is at least one query of type 3 in the input. In each query the constraint 1 ≤ id ≤ 2 ⋅ 10^5 is met. Output Print answers to queries of the type 3 in order they appear in the input. Examples Input 8 L 1 R 2 R 3 ? 2 L 4 ? 1 L 5 ? 1 Output 1 1 2 Input 10 L 100 R 100000 R 123 L 101 ? 123 L 10 R 115 ? 100 R 110 ? 115 Output 0 2 1 Note Let's take a look at the first example and let's consider queries: 1. The shelf will look like [1]; 2. The shelf will look like [1, 2]; 3. The shelf will look like [1, 2, 3]; 4. The shelf looks like [1, 2, 3] so the answer is 1; 5. The shelf will look like [4, 1, 2, 3]; 6. The shelf looks like [4, 1, 2, 3] so the answer is 1; 7. The shelf will look like [5, 4, 1, 2, 3]; 8. The shelf looks like [5, 4, 1, 2, 3] so the answer is 2. Let's take a look at the second example and let's consider queries: 1. The shelf will look like [100]; 2. The shelf will look like [100, 100000]; 3. The shelf will look like [100, 100000, 123]; 4. The shelf will look like [101, 100, 100000, 123]; 5. The shelf looks like [101, 100, 100000, 123] so the answer is 0; 6. The shelf will look like [10, 101, 100, 100000, 123]; 7. The shelf will look like [10, 101, 100, 100000, 123, 115]; 8. The shelf looks like [10, 101, 100, 100000, 123, 115] so the answer is 2; 9. The shelf will look like [10, 101, 100, 100000, 123, 115, 110]; 10. The shelf looks like [10, 101, 100, 100000, 123, 115, 110] so the answer is 1. Submitted Solution: ``` n=int(input()) indr=0 indl=0 d={} for i in range(n): t,id=input().split() id=int(id) if i==0: d[id]=0 if t=='L': indl-=1 d[id] = indl elif t=='R': indr+=1 d[id] = indr else: k1 = abs(indr - d[id]) k2=abs(indl-d[id]) print(min(k1,k2)) ``` No
84,258
[ 0.0804443359375, -0.111328125, 0.11846923828125, -0.157958984375, -0.47314453125, -0.2333984375, -0.036773681640625, 0.08294677734375, 0.052398681640625, 0.76171875, -0.09814453125, -0.11407470703125, -0.0869140625, -0.466796875, -0.5615234375, 0.0809326171875, -0.634765625, -0.285...
11
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Jury picked a polynomial f(x) = a_0 + a_1 ⋅ x + a_2 ⋅ x^2 + ... + a_k ⋅ x^k. k ≤ 10 and all a_i are integer numbers and 0 ≤ a_i < 10^6 + 3. It's guaranteed that there is at least one i such that a_i > 0. Now jury wants you to find such an integer x_0 that f(x_0) ≡ 0 mod (10^6 + 3) or report that there is not such x_0. You can ask no more than 50 queries: you ask value x_q and jury tells you value f(x_q) mod (10^6 + 3). Note that printing the answer doesn't count as a query. Interaction To ask a question, print "? x_q" (0 ≤ x_q < 10^6 + 3). The judge will respond with a single integer f(x_q) mod (10^6 + 3). If you ever get a result of −1 (because you printed an invalid query), exit immediately to avoid getting other verdicts. After printing a query do not forget to output end of line and flush the output. Otherwise, you will get Idleness limit exceeded. To do this, use: * fflush(stdout) or cout.flush() in C++; * System.out.flush() in Java; * flush(output) in Pascal; * stdout.flush() in Python; * see documentation for other languages. When you are ready to answer, print "! x_0" where x_0 is the answer or -1 if there is no such x_0. You can ask at most 50 questions per test case. Hack Format To hack, use the following format. The only line should contain 11 integers a_0, a_1, ..., a_{10} (0 ≤ a_i < 10^6 + 3, max_{0 ≤ i ≤ 10}{a_i} > 0) — corresponding coefficients of the polynomial. Examples Input 1000002 0 Output ? 0 ? 1 ! 1 Input 5 2 1 Output ? 2 ? 1 ? 0 ! -1 Note The polynomial in the first sample is 1000002 + x^2. The polynomial in the second sample is 1 + x^2. Submitted Solution: ``` from sys import stdout M = 10 ** 6 + 3 need = 0 anew = 0 for i in range(50): print('?', need) a0 = int(input()) stdout.flush() if a0 == 0: print('!', need) exit(0) anew += a0 need -= anew need %= M print('!', -1) ``` No
84,285
[ 0.219970703125, 0.0369873046875, -0.1781005859375, -0.02154541015625, -0.45654296875, -0.12481689453125, -0.11444091796875, 0.04437255859375, -0.105224609375, 0.82470703125, 0.611328125, 0.07415771484375, 0.11541748046875, -0.9052734375, -0.258056640625, 0.1865234375, -0.35107421875,...
11
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Jury picked a polynomial f(x) = a_0 + a_1 ⋅ x + a_2 ⋅ x^2 + ... + a_k ⋅ x^k. k ≤ 10 and all a_i are integer numbers and 0 ≤ a_i < 10^6 + 3. It's guaranteed that there is at least one i such that a_i > 0. Now jury wants you to find such an integer x_0 that f(x_0) ≡ 0 mod (10^6 + 3) or report that there is not such x_0. You can ask no more than 50 queries: you ask value x_q and jury tells you value f(x_q) mod (10^6 + 3). Note that printing the answer doesn't count as a query. Interaction To ask a question, print "? x_q" (0 ≤ x_q < 10^6 + 3). The judge will respond with a single integer f(x_q) mod (10^6 + 3). If you ever get a result of −1 (because you printed an invalid query), exit immediately to avoid getting other verdicts. After printing a query do not forget to output end of line and flush the output. Otherwise, you will get Idleness limit exceeded. To do this, use: * fflush(stdout) or cout.flush() in C++; * System.out.flush() in Java; * flush(output) in Pascal; * stdout.flush() in Python; * see documentation for other languages. When you are ready to answer, print "! x_0" where x_0 is the answer or -1 if there is no such x_0. You can ask at most 50 questions per test case. Hack Format To hack, use the following format. The only line should contain 11 integers a_0, a_1, ..., a_{10} (0 ≤ a_i < 10^6 + 3, max_{0 ≤ i ≤ 10}{a_i} > 0) — corresponding coefficients of the polynomial. Examples Input 1000002 0 Output ? 0 ? 1 ! 1 Input 5 2 1 Output ? 2 ? 1 ? 0 ! -1 Note The polynomial in the first sample is 1000002 + x^2. The polynomial in the second sample is 1 + x^2. Submitted Solution: ``` from sys import stdout M = 10 ** 6 + 3 need = 0 anew = 0 for i in range(50): print('?', need) a0 = int(input()) stdout.flush() if a0 == 0: print('!', need) exit(0) a0 -= anew a0 %= M need += a0 need %= M anew = a0 print('!', -1) ``` No
84,286
[ 0.219970703125, 0.0369873046875, -0.1781005859375, -0.02154541015625, -0.45654296875, -0.12481689453125, -0.11444091796875, 0.04437255859375, -0.105224609375, 0.82470703125, 0.611328125, 0.07415771484375, 0.11541748046875, -0.9052734375, -0.258056640625, 0.1865234375, -0.35107421875,...
11
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Jury picked a polynomial f(x) = a_0 + a_1 ⋅ x + a_2 ⋅ x^2 + ... + a_k ⋅ x^k. k ≤ 10 and all a_i are integer numbers and 0 ≤ a_i < 10^6 + 3. It's guaranteed that there is at least one i such that a_i > 0. Now jury wants you to find such an integer x_0 that f(x_0) ≡ 0 mod (10^6 + 3) or report that there is not such x_0. You can ask no more than 50 queries: you ask value x_q and jury tells you value f(x_q) mod (10^6 + 3). Note that printing the answer doesn't count as a query. Interaction To ask a question, print "? x_q" (0 ≤ x_q < 10^6 + 3). The judge will respond with a single integer f(x_q) mod (10^6 + 3). If you ever get a result of −1 (because you printed an invalid query), exit immediately to avoid getting other verdicts. After printing a query do not forget to output end of line and flush the output. Otherwise, you will get Idleness limit exceeded. To do this, use: * fflush(stdout) or cout.flush() in C++; * System.out.flush() in Java; * flush(output) in Pascal; * stdout.flush() in Python; * see documentation for other languages. When you are ready to answer, print "! x_0" where x_0 is the answer or -1 if there is no such x_0. You can ask at most 50 questions per test case. Hack Format To hack, use the following format. The only line should contain 11 integers a_0, a_1, ..., a_{10} (0 ≤ a_i < 10^6 + 3, max_{0 ≤ i ≤ 10}{a_i} > 0) — corresponding coefficients of the polynomial. Examples Input 1000002 0 Output ? 0 ? 1 ! 1 Input 5 2 1 Output ? 2 ? 1 ? 0 ! -1 Note The polynomial in the first sample is 1000002 + x^2. The polynomial in the second sample is 1 + x^2. Submitted Solution: ``` from sys import stdout M = 10 ** 6 + 3 need = 0 for i in range(50): print('?', need) a0 = int(input()) stdout.flush() if a0 == 0: print('!', need) exit(0) need -= a0 need %= M print('!', -1) ``` No
84,287
[ 0.219970703125, 0.0369873046875, -0.1781005859375, -0.02154541015625, -0.45654296875, -0.12481689453125, -0.11444091796875, 0.04437255859375, -0.105224609375, 0.82470703125, 0.611328125, 0.07415771484375, 0.11541748046875, -0.9052734375, -0.258056640625, 0.1865234375, -0.35107421875,...
11
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Jury picked a polynomial f(x) = a_0 + a_1 ⋅ x + a_2 ⋅ x^2 + ... + a_k ⋅ x^k. k ≤ 10 and all a_i are integer numbers and 0 ≤ a_i < 10^6 + 3. It's guaranteed that there is at least one i such that a_i > 0. Now jury wants you to find such an integer x_0 that f(x_0) ≡ 0 mod (10^6 + 3) or report that there is not such x_0. You can ask no more than 50 queries: you ask value x_q and jury tells you value f(x_q) mod (10^6 + 3). Note that printing the answer doesn't count as a query. Interaction To ask a question, print "? x_q" (0 ≤ x_q < 10^6 + 3). The judge will respond with a single integer f(x_q) mod (10^6 + 3). If you ever get a result of −1 (because you printed an invalid query), exit immediately to avoid getting other verdicts. After printing a query do not forget to output end of line and flush the output. Otherwise, you will get Idleness limit exceeded. To do this, use: * fflush(stdout) or cout.flush() in C++; * System.out.flush() in Java; * flush(output) in Pascal; * stdout.flush() in Python; * see documentation for other languages. When you are ready to answer, print "! x_0" where x_0 is the answer or -1 if there is no such x_0. You can ask at most 50 questions per test case. Hack Format To hack, use the following format. The only line should contain 11 integers a_0, a_1, ..., a_{10} (0 ≤ a_i < 10^6 + 3, max_{0 ≤ i ≤ 10}{a_i} > 0) — corresponding coefficients of the polynomial. Examples Input 1000002 0 Output ? 0 ? 1 ! 1 Input 5 2 1 Output ? 2 ? 1 ? 0 ! -1 Note The polynomial in the first sample is 1000002 + x^2. The polynomial in the second sample is 1 + x^2. Submitted Solution: ``` from sys import stdout M = 10 ** 6 + 3 need = 0 anew = 0 for i in range(50): print('?', need) a0 = int(input()) stdout.flush() if a0 == 0: print('!', need) exit(0) a0 -= anew a0 %= M need += a0 need %= M anew += a0 anew %= M print('!', -1) ``` No
84,288
[ 0.219970703125, 0.0369873046875, -0.1781005859375, -0.02154541015625, -0.45654296875, -0.12481689453125, -0.11444091796875, 0.04437255859375, -0.105224609375, 0.82470703125, 0.611328125, 0.07415771484375, 0.11541748046875, -0.9052734375, -0.258056640625, 0.1865234375, -0.35107421875,...
11
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. The last contest held on Johnny's favorite competitive programming platform has been received rather positively. However, Johnny's rating has dropped again! He thinks that the presented tasks are lovely, but don't show the truth about competitors' skills. The boy is now looking at the ratings of consecutive participants written in a binary system. He thinks that the more such ratings differ, the more unfair is that such people are next to each other. He defines the difference between two numbers as the number of bit positions, where one number has zero, and another has one (we suppose that numbers are padded with leading zeros to the same length). For example, the difference of 5 = 101_2 and 14 = 1110_2 equals to 3, since 0101 and 1110 differ in 3 positions. Johnny defines the unfairness of the contest as the sum of such differences counted for neighboring participants. Johnny has just sent you the rating sequence and wants you to find the unfairness of the competition. You have noticed that you've got a sequence of consecutive integers from 0 to n. That's strange, but the boy stubbornly says that everything is right. So help him and find the desired unfairness for received numbers. Input The input consists of multiple test cases. The first line contains one integer t (1 ≤ t ≤ 10 000) — the number of test cases. The following t lines contain a description of test cases. The first and only line in each test case contains a single integer n (1 ≤ n ≤ 10^{18}). Output Output t lines. For each test case, you should output a single line with one integer — the unfairness of the contest if the rating sequence equals to 0, 1, ..., n - 1, n. Example Input 5 5 7 11 1 2000000000000 Output 8 11 19 1 3999999999987 Note For n = 5 we calculate unfairness of the following sequence (numbers from 0 to 5 written in binary with extra leading zeroes, so they all have the same length): * 000 * 001 * 010 * 011 * 100 * 101 The differences are equal to 1, 2, 1, 3, 1 respectively, so unfairness is equal to 1 + 2 + 1 + 3 + 1 = 8. Submitted Solution: ``` from sys import stdin from math import floor def func(n, i): x = pow(2, i) y = x//2 return i*(((n-y)//x)+1) for _ in range(int(stdin.readline())): n = int(stdin.readline()) #a, b = map(int, stdin.readline().split()) count = 0 i = 1 while(i < 63): count += func(n, i) i += 1 print(count) ``` Yes
84,398
[ 0.479736328125, 0.154541015625, -0.264404296875, 0.1649169921875, -0.6474609375, -0.6796875, -0.300048828125, -0.0618896484375, -0.287109375, 1.04296875, 0.298583984375, -0.1868896484375, 0.02362060546875, -0.94775390625, -0.28076171875, -0.52880859375, -0.65234375, -0.7587890625, ...
11
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. The last contest held on Johnny's favorite competitive programming platform has been received rather positively. However, Johnny's rating has dropped again! He thinks that the presented tasks are lovely, but don't show the truth about competitors' skills. The boy is now looking at the ratings of consecutive participants written in a binary system. He thinks that the more such ratings differ, the more unfair is that such people are next to each other. He defines the difference between two numbers as the number of bit positions, where one number has zero, and another has one (we suppose that numbers are padded with leading zeros to the same length). For example, the difference of 5 = 101_2 and 14 = 1110_2 equals to 3, since 0101 and 1110 differ in 3 positions. Johnny defines the unfairness of the contest as the sum of such differences counted for neighboring participants. Johnny has just sent you the rating sequence and wants you to find the unfairness of the competition. You have noticed that you've got a sequence of consecutive integers from 0 to n. That's strange, but the boy stubbornly says that everything is right. So help him and find the desired unfairness for received numbers. Input The input consists of multiple test cases. The first line contains one integer t (1 ≤ t ≤ 10 000) — the number of test cases. The following t lines contain a description of test cases. The first and only line in each test case contains a single integer n (1 ≤ n ≤ 10^{18}). Output Output t lines. For each test case, you should output a single line with one integer — the unfairness of the contest if the rating sequence equals to 0, 1, ..., n - 1, n. Example Input 5 5 7 11 1 2000000000000 Output 8 11 19 1 3999999999987 Note For n = 5 we calculate unfairness of the following sequence (numbers from 0 to 5 written in binary with extra leading zeroes, so they all have the same length): * 000 * 001 * 010 * 011 * 100 * 101 The differences are equal to 1, 2, 1, 3, 1 respectively, so unfairness is equal to 1 + 2 + 1 + 3 + 1 = 8. Submitted Solution: ``` import math we= int(input()) w = 1000000000000000000 s = list(bin(w).replace("0b", "")) arr = [0]*(len(s)+1) for i in range(1,len(s)+1): arr[i] = 2*arr[i-1] + i #print(arr) for erw in range(we): n = int(input()) s = list(bin(n).replace("0b", "")) #print(s) ans = 0 for i in range(len(s)): if(i==len(s) and s[i]=='1'): ans+=1 elif(s[i]=='1'): #print("herer") ans+= arr[len(s)-i-1] + len(s)-i print(ans) ``` Yes
84,399
[ 0.479736328125, 0.154541015625, -0.264404296875, 0.1649169921875, -0.6474609375, -0.6796875, -0.300048828125, -0.0618896484375, -0.287109375, 1.04296875, 0.298583984375, -0.1868896484375, 0.02362060546875, -0.94775390625, -0.28076171875, -0.52880859375, -0.65234375, -0.7587890625, ...
11
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. The last contest held on Johnny's favorite competitive programming platform has been received rather positively. However, Johnny's rating has dropped again! He thinks that the presented tasks are lovely, but don't show the truth about competitors' skills. The boy is now looking at the ratings of consecutive participants written in a binary system. He thinks that the more such ratings differ, the more unfair is that such people are next to each other. He defines the difference between two numbers as the number of bit positions, where one number has zero, and another has one (we suppose that numbers are padded with leading zeros to the same length). For example, the difference of 5 = 101_2 and 14 = 1110_2 equals to 3, since 0101 and 1110 differ in 3 positions. Johnny defines the unfairness of the contest as the sum of such differences counted for neighboring participants. Johnny has just sent you the rating sequence and wants you to find the unfairness of the competition. You have noticed that you've got a sequence of consecutive integers from 0 to n. That's strange, but the boy stubbornly says that everything is right. So help him and find the desired unfairness for received numbers. Input The input consists of multiple test cases. The first line contains one integer t (1 ≤ t ≤ 10 000) — the number of test cases. The following t lines contain a description of test cases. The first and only line in each test case contains a single integer n (1 ≤ n ≤ 10^{18}). Output Output t lines. For each test case, you should output a single line with one integer — the unfairness of the contest if the rating sequence equals to 0, 1, ..., n - 1, n. Example Input 5 5 7 11 1 2000000000000 Output 8 11 19 1 3999999999987 Note For n = 5 we calculate unfairness of the following sequence (numbers from 0 to 5 written in binary with extra leading zeroes, so they all have the same length): * 000 * 001 * 010 * 011 * 100 * 101 The differences are equal to 1, 2, 1, 3, 1 respectively, so unfairness is equal to 1 + 2 + 1 + 3 + 1 = 8. Submitted Solution: ``` import sys ''' 00001 = 1 [1] 00010 = 2 [1+(1)+1=3] 00011 = 1 00100 = 3 [3+(1+2)+1=7] 00101 = 1 00110 = 2 00111 = 1 01000 = 4 [7+7+1=15] 01001 = 1 01010 = 2 01011 = 1 01100 = 3 01101 = 1 01110 = 2 01111 = 1 10000 = 5 [31] 10000 = 5 ''' if __name__ == '__main__': IN = [x.strip() for x in sys.stdin.readlines()] T = int(IN[0]) vals = [] for i in range(T): vals.append( bin(int(IN[1+i]))[2:] ) nb = max([len(v) for v in vals]) bit2count = [2**i-1 for i in range(1,nb+1)] #print(bit2count) #nbits = len(bits) #tot_to_bit = [0]*nbits #print( arr ) for n in vals: #result = solve(n) n = n l = len(n) tot = 0 for i in range(l): #print(i,n) tot += bit2count[l-i-1] if n[i] == '1' else 0 print(tot) ``` Yes
84,400
[ 0.479736328125, 0.154541015625, -0.264404296875, 0.1649169921875, -0.6474609375, -0.6796875, -0.300048828125, -0.0618896484375, -0.287109375, 1.04296875, 0.298583984375, -0.1868896484375, 0.02362060546875, -0.94775390625, -0.28076171875, -0.52880859375, -0.65234375, -0.7587890625, ...
11
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. The last contest held on Johnny's favorite competitive programming platform has been received rather positively. However, Johnny's rating has dropped again! He thinks that the presented tasks are lovely, but don't show the truth about competitors' skills. The boy is now looking at the ratings of consecutive participants written in a binary system. He thinks that the more such ratings differ, the more unfair is that such people are next to each other. He defines the difference between two numbers as the number of bit positions, where one number has zero, and another has one (we suppose that numbers are padded with leading zeros to the same length). For example, the difference of 5 = 101_2 and 14 = 1110_2 equals to 3, since 0101 and 1110 differ in 3 positions. Johnny defines the unfairness of the contest as the sum of such differences counted for neighboring participants. Johnny has just sent you the rating sequence and wants you to find the unfairness of the competition. You have noticed that you've got a sequence of consecutive integers from 0 to n. That's strange, but the boy stubbornly says that everything is right. So help him and find the desired unfairness for received numbers. Input The input consists of multiple test cases. The first line contains one integer t (1 ≤ t ≤ 10 000) — the number of test cases. The following t lines contain a description of test cases. The first and only line in each test case contains a single integer n (1 ≤ n ≤ 10^{18}). Output Output t lines. For each test case, you should output a single line with one integer — the unfairness of the contest if the rating sequence equals to 0, 1, ..., n - 1, n. Example Input 5 5 7 11 1 2000000000000 Output 8 11 19 1 3999999999987 Note For n = 5 we calculate unfairness of the following sequence (numbers from 0 to 5 written in binary with extra leading zeroes, so they all have the same length): * 000 * 001 * 010 * 011 * 100 * 101 The differences are equal to 1, 2, 1, 3, 1 respectively, so unfairness is equal to 1 + 2 + 1 + 3 + 1 = 8. Submitted Solution: ``` #: Author - Soumya Saurav import sys,io,os,time from collections import defaultdict from collections import OrderedDict from collections import deque from itertools import combinations from itertools import permutations import bisect,math,heapq alphabet = "abcdefghijklmnopqrstuvwxyz" input = sys.stdin.readline ######################################## for ii in range(int(input())): n = int(input()) b = bin(n)[2:] l = len(b) ans = 0 #print("bin : ",b) for i in range(len(b)): if i == l-1: if i == "1": ans+=1 break if b[i] == "1": pos = l - i #print("pos : ", pos,pow(2,pos) - 1) ans += pow(2,pos) - 1 print(ans) ``` Yes
84,401
[ 0.479736328125, 0.154541015625, -0.264404296875, 0.1649169921875, -0.6474609375, -0.6796875, -0.300048828125, -0.0618896484375, -0.287109375, 1.04296875, 0.298583984375, -0.1868896484375, 0.02362060546875, -0.94775390625, -0.28076171875, -0.52880859375, -0.65234375, -0.7587890625, ...
11
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. The last contest held on Johnny's favorite competitive programming platform has been received rather positively. However, Johnny's rating has dropped again! He thinks that the presented tasks are lovely, but don't show the truth about competitors' skills. The boy is now looking at the ratings of consecutive participants written in a binary system. He thinks that the more such ratings differ, the more unfair is that such people are next to each other. He defines the difference between two numbers as the number of bit positions, where one number has zero, and another has one (we suppose that numbers are padded with leading zeros to the same length). For example, the difference of 5 = 101_2 and 14 = 1110_2 equals to 3, since 0101 and 1110 differ in 3 positions. Johnny defines the unfairness of the contest as the sum of such differences counted for neighboring participants. Johnny has just sent you the rating sequence and wants you to find the unfairness of the competition. You have noticed that you've got a sequence of consecutive integers from 0 to n. That's strange, but the boy stubbornly says that everything is right. So help him and find the desired unfairness for received numbers. Input The input consists of multiple test cases. The first line contains one integer t (1 ≤ t ≤ 10 000) — the number of test cases. The following t lines contain a description of test cases. The first and only line in each test case contains a single integer n (1 ≤ n ≤ 10^{18}). Output Output t lines. For each test case, you should output a single line with one integer — the unfairness of the contest if the rating sequence equals to 0, 1, ..., n - 1, n. Example Input 5 5 7 11 1 2000000000000 Output 8 11 19 1 3999999999987 Note For n = 5 we calculate unfairness of the following sequence (numbers from 0 to 5 written in binary with extra leading zeroes, so they all have the same length): * 000 * 001 * 010 * 011 * 100 * 101 The differences are equal to 1, 2, 1, 3, 1 respectively, so unfairness is equal to 1 + 2 + 1 + 3 + 1 = 8. Submitted Solution: ``` from math import ceil for iota in range(int(input())): n=int(input()) ans=0 i=1 if n==1: print(1) continue while n>0: ans+=i*ceil(n/2) n-=ceil(n/2) i+=1 print(ans) ``` No
84,402
[ 0.479736328125, 0.154541015625, -0.264404296875, 0.1649169921875, -0.6474609375, -0.6796875, -0.300048828125, -0.0618896484375, -0.287109375, 1.04296875, 0.298583984375, -0.1868896484375, 0.02362060546875, -0.94775390625, -0.28076171875, -0.52880859375, -0.65234375, -0.7587890625, ...
11
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. The last contest held on Johnny's favorite competitive programming platform has been received rather positively. However, Johnny's rating has dropped again! He thinks that the presented tasks are lovely, but don't show the truth about competitors' skills. The boy is now looking at the ratings of consecutive participants written in a binary system. He thinks that the more such ratings differ, the more unfair is that such people are next to each other. He defines the difference between two numbers as the number of bit positions, where one number has zero, and another has one (we suppose that numbers are padded with leading zeros to the same length). For example, the difference of 5 = 101_2 and 14 = 1110_2 equals to 3, since 0101 and 1110 differ in 3 positions. Johnny defines the unfairness of the contest as the sum of such differences counted for neighboring participants. Johnny has just sent you the rating sequence and wants you to find the unfairness of the competition. You have noticed that you've got a sequence of consecutive integers from 0 to n. That's strange, but the boy stubbornly says that everything is right. So help him and find the desired unfairness for received numbers. Input The input consists of multiple test cases. The first line contains one integer t (1 ≤ t ≤ 10 000) — the number of test cases. The following t lines contain a description of test cases. The first and only line in each test case contains a single integer n (1 ≤ n ≤ 10^{18}). Output Output t lines. For each test case, you should output a single line with one integer — the unfairness of the contest if the rating sequence equals to 0, 1, ..., n - 1, n. Example Input 5 5 7 11 1 2000000000000 Output 8 11 19 1 3999999999987 Note For n = 5 we calculate unfairness of the following sequence (numbers from 0 to 5 written in binary with extra leading zeroes, so they all have the same length): * 000 * 001 * 010 * 011 * 100 * 101 The differences are equal to 1, 2, 1, 3, 1 respectively, so unfairness is equal to 1 + 2 + 1 + 3 + 1 = 8. Submitted Solution: ``` ################om namh shivay##################37 ###############(BHOLE KI FAUJ KREGI MAUJ)############37 from sys import stdin,stdout import math,queue,heapq fastinput=stdin.readline fastout=stdout.write t=int(fastinput()) while t: t-=1 n=int(fastinput()) #n,m=map(int,fastinput().split()) #a=[0]+list(map(int,fastinput().split())) #b=list(map(int,fastinput().split())) #matrix=[list(map(int,fastinput().split())) for _ in range(n)] y=len(bin(n)) n+=1 y-=2 if n!=0: s=0 for i in range(y): count=math.ceil((n)/(1<<i)) s+=count-1 print(s) else: print(0) ``` No
84,403
[ 0.479736328125, 0.154541015625, -0.264404296875, 0.1649169921875, -0.6474609375, -0.6796875, -0.300048828125, -0.0618896484375, -0.287109375, 1.04296875, 0.298583984375, -0.1868896484375, 0.02362060546875, -0.94775390625, -0.28076171875, -0.52880859375, -0.65234375, -0.7587890625, ...
11
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. The last contest held on Johnny's favorite competitive programming platform has been received rather positively. However, Johnny's rating has dropped again! He thinks that the presented tasks are lovely, but don't show the truth about competitors' skills. The boy is now looking at the ratings of consecutive participants written in a binary system. He thinks that the more such ratings differ, the more unfair is that such people are next to each other. He defines the difference between two numbers as the number of bit positions, where one number has zero, and another has one (we suppose that numbers are padded with leading zeros to the same length). For example, the difference of 5 = 101_2 and 14 = 1110_2 equals to 3, since 0101 and 1110 differ in 3 positions. Johnny defines the unfairness of the contest as the sum of such differences counted for neighboring participants. Johnny has just sent you the rating sequence and wants you to find the unfairness of the competition. You have noticed that you've got a sequence of consecutive integers from 0 to n. That's strange, but the boy stubbornly says that everything is right. So help him and find the desired unfairness for received numbers. Input The input consists of multiple test cases. The first line contains one integer t (1 ≤ t ≤ 10 000) — the number of test cases. The following t lines contain a description of test cases. The first and only line in each test case contains a single integer n (1 ≤ n ≤ 10^{18}). Output Output t lines. For each test case, you should output a single line with one integer — the unfairness of the contest if the rating sequence equals to 0, 1, ..., n - 1, n. Example Input 5 5 7 11 1 2000000000000 Output 8 11 19 1 3999999999987 Note For n = 5 we calculate unfairness of the following sequence (numbers from 0 to 5 written in binary with extra leading zeroes, so they all have the same length): * 000 * 001 * 010 * 011 * 100 * 101 The differences are equal to 1, 2, 1, 3, 1 respectively, so unfairness is equal to 1 + 2 + 1 + 3 + 1 = 8. Submitted Solution: ``` from math import log2, ceil t = int(input()) for __ in range(t): n = int(input()) bit = 1 + int(log2(n)) ans = 0 for i in range(bit): ans += ceil((n + 1) / (1 << i)) - 1 print(ans) ``` No
84,404
[ 0.479736328125, 0.154541015625, -0.264404296875, 0.1649169921875, -0.6474609375, -0.6796875, -0.300048828125, -0.0618896484375, -0.287109375, 1.04296875, 0.298583984375, -0.1868896484375, 0.02362060546875, -0.94775390625, -0.28076171875, -0.52880859375, -0.65234375, -0.7587890625, ...
11
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. The last contest held on Johnny's favorite competitive programming platform has been received rather positively. However, Johnny's rating has dropped again! He thinks that the presented tasks are lovely, but don't show the truth about competitors' skills. The boy is now looking at the ratings of consecutive participants written in a binary system. He thinks that the more such ratings differ, the more unfair is that such people are next to each other. He defines the difference between two numbers as the number of bit positions, where one number has zero, and another has one (we suppose that numbers are padded with leading zeros to the same length). For example, the difference of 5 = 101_2 and 14 = 1110_2 equals to 3, since 0101 and 1110 differ in 3 positions. Johnny defines the unfairness of the contest as the sum of such differences counted for neighboring participants. Johnny has just sent you the rating sequence and wants you to find the unfairness of the competition. You have noticed that you've got a sequence of consecutive integers from 0 to n. That's strange, but the boy stubbornly says that everything is right. So help him and find the desired unfairness for received numbers. Input The input consists of multiple test cases. The first line contains one integer t (1 ≤ t ≤ 10 000) — the number of test cases. The following t lines contain a description of test cases. The first and only line in each test case contains a single integer n (1 ≤ n ≤ 10^{18}). Output Output t lines. For each test case, you should output a single line with one integer — the unfairness of the contest if the rating sequence equals to 0, 1, ..., n - 1, n. Example Input 5 5 7 11 1 2000000000000 Output 8 11 19 1 3999999999987 Note For n = 5 we calculate unfairness of the following sequence (numbers from 0 to 5 written in binary with extra leading zeroes, so they all have the same length): * 000 * 001 * 010 * 011 * 100 * 101 The differences are equal to 1, 2, 1, 3, 1 respectively, so unfairness is equal to 1 + 2 + 1 + 3 + 1 = 8. Submitted Solution: ``` import math for i in range(int(input())): n=int(input()) z=n ans=0 c=0 while(z>0): z=z//2 c+=1 for i in range(1,c+1): ans=ans+math.ceil(n/2)*i n=n//2 print(ans) ``` No
84,405
[ 0.479736328125, 0.154541015625, -0.264404296875, 0.1649169921875, -0.6474609375, -0.6796875, -0.300048828125, -0.0618896484375, -0.287109375, 1.04296875, 0.298583984375, -0.1868896484375, 0.02362060546875, -0.94775390625, -0.28076171875, -0.52880859375, -0.65234375, -0.7587890625, ...
11
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Today Adilbek is taking his probability theory test. Unfortunately, when Adilbek arrived at the university, there had already been a long queue of students wanting to take the same test. Adilbek has estimated that he will be able to start the test only T seconds after coming. Fortunately, Adilbek can spend time without revising any boring theorems or formulas. He has an app on this smartphone which contains n Japanese crosswords to solve. Adilbek has decided to solve them all one by one in the order they are listed in the app, without skipping any crossword. For each crossword, a number t_i is given that represents the time it takes an average crossword expert to solve this crossword (the time is given in seconds). Adilbek is a true crossword expert, but, unfortunately, he is sometimes unlucky in choosing the way to solve the crossword. So, it takes him either t_i seconds or t_i + 1 seconds to solve the i-th crossword, equiprobably (with probability 1/2 he solves the crossword in exactly t_i seconds, and with probability 1/2 he has to spend an additional second to finish the crossword). All these events are independent. After T seconds pass (or after solving the last crossword, if he manages to do it in less than T seconds), Adilbek closes the app (if he finishes some crossword at the same moment, that crossword is considered solved; otherwise Adilbek does not finish solving the current crossword at all). He thinks it would be an interesting probability theory problem to calculate E — the expected number of crosswords he will be able to solve completely. Can you calculate it? Recall that the expected value of a discrete random variable is the probability-weighted average of all possible values — in this problem it means that the expected value of the number of solved crosswords can be calculated as E = ∑ _{i = 0}^{n} i p_i, where p_i is the probability that Adilbek will solve exactly i crosswords. We can represent E as rational fraction P/Q with Q > 0. To give the answer, you should print P ⋅ Q^{-1} mod (10^9 + 7). Input The first line contains two integers n and T (1 ≤ n ≤ 2 ⋅ 10^5, 1 ≤ T ≤ 2 ⋅ 10^{14}) — the number of crosswords and the time Adilbek has to spend, respectively. The second line contains n integers t_1, t_2, ..., t_n (1 ≤ t_i ≤ 10^9), where t_i is the time it takes a crossword expert to solve the i-th crossword. Note that Adilbek solves the crosswords in the order they are given in the input without skipping any of them. Output Print one integer — the expected value of the number of crosswords Adilbek solves in T seconds, expressed in the form of P ⋅ Q^{-1} mod (10^9 + 7). Examples Input 3 5 2 2 2 Output 750000007 Input 3 5 2 1 2 Output 125000003 Note The answer for the first sample is equal to 14/8. The answer for the second sample is equal to 17/8. Submitted Solution: ``` from itertools import combinations from math import factorial mod = 10**9 + 7 n,T = map(int,input().split()) ti = [0] for i in map(int,input().split()): ti.append(i) ans = 0 def Modulo(a): b = mod residuo = 0 x = a // b residuo = a - (x*b) return residuo def Pow(a,x): ans = 1 while(x): if x&1: ans = ans*a%mod a=a*a%mod x = x>>1 return ans def Min(i): sim=0 for j in range(1,i+1): sim += ti[j] return min(T - sim,i) def Pi(i): sim = 0 mi = Min(i) for k in range(0,mi+1): sim += Modulo(int(factorial(i)/(factorial(k)*factorial(i-k)))) return sim * Pow(2**i,mod-2) for i in range(1,n+1): ans += Pi(i) ans = Modulo(ans) print(ans) print(17/8) ``` No
85,097
[ 0.03424072265625, 0.259033203125, -0.0906982421875, -0.1820068359375, -0.492431640625, -0.412353515625, 0.0860595703125, -0.0246734619140625, 0.208984375, 1.291015625, 0.93017578125, -0.1639404296875, 0.06500244140625, -0.9228515625, -0.2232666015625, -0.10919189453125, -0.6943359375...
11
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Today Adilbek is taking his probability theory test. Unfortunately, when Adilbek arrived at the university, there had already been a long queue of students wanting to take the same test. Adilbek has estimated that he will be able to start the test only T seconds after coming. Fortunately, Adilbek can spend time without revising any boring theorems or formulas. He has an app on this smartphone which contains n Japanese crosswords to solve. Adilbek has decided to solve them all one by one in the order they are listed in the app, without skipping any crossword. For each crossword, a number t_i is given that represents the time it takes an average crossword expert to solve this crossword (the time is given in seconds). Adilbek is a true crossword expert, but, unfortunately, he is sometimes unlucky in choosing the way to solve the crossword. So, it takes him either t_i seconds or t_i + 1 seconds to solve the i-th crossword, equiprobably (with probability 1/2 he solves the crossword in exactly t_i seconds, and with probability 1/2 he has to spend an additional second to finish the crossword). All these events are independent. After T seconds pass (or after solving the last crossword, if he manages to do it in less than T seconds), Adilbek closes the app (if he finishes some crossword at the same moment, that crossword is considered solved; otherwise Adilbek does not finish solving the current crossword at all). He thinks it would be an interesting probability theory problem to calculate E — the expected number of crosswords he will be able to solve completely. Can you calculate it? Recall that the expected value of a discrete random variable is the probability-weighted average of all possible values — in this problem it means that the expected value of the number of solved crosswords can be calculated as E = ∑ _{i = 0}^{n} i p_i, where p_i is the probability that Adilbek will solve exactly i crosswords. We can represent E as rational fraction P/Q with Q > 0. To give the answer, you should print P ⋅ Q^{-1} mod (10^9 + 7). Input The first line contains two integers n and T (1 ≤ n ≤ 2 ⋅ 10^5, 1 ≤ T ≤ 2 ⋅ 10^{14}) — the number of crosswords and the time Adilbek has to spend, respectively. The second line contains n integers t_1, t_2, ..., t_n (1 ≤ t_i ≤ 10^9), where t_i is the time it takes a crossword expert to solve the i-th crossword. Note that Adilbek solves the crosswords in the order they are given in the input without skipping any of them. Output Print one integer — the expected value of the number of crosswords Adilbek solves in T seconds, expressed in the form of P ⋅ Q^{-1} mod (10^9 + 7). Examples Input 3 5 2 2 2 Output 750000007 Input 3 5 2 1 2 Output 125000003 Note The answer for the first sample is equal to 14/8. The answer for the second sample is equal to 17/8. Submitted Solution: ``` mod = 10 ** 9 + 7 MAX = 2 * 10 ** 5 r = [1] * MAX factorial = [1] * MAX rfactorial = [1] * MAX rp = [1] * MAX for i in range(2, MAX): factorial[i] = i * factorial[i - 1] % mod r[i] = mod - (mod // i) * r[mod%i] % mod rfactorial[i] = rfactorial[i-1] * r[i] % mod for i in range(1, MAX): rp[i] = rp[i - 1] * (mod + 1) // 2 % mod n, T = list(map(int, input().split())) t = list(map(int, input().split())) t.append(10**14+1) S=0 EX=0 for i in range(n): cof = rp[1] for add in range(2): l_, r_ = max(0, T-S-t[i] + add), min(i, T-S) for x in range(l_, r_+1): EX = ( EX + i*(factorial[i]*(rfactorial[x]*rfactorial[i-x])) * rp[i]*cof) % mod S += t[i] print(EX) ``` No
85,098
[ 0.03424072265625, 0.259033203125, -0.0906982421875, -0.1820068359375, -0.492431640625, -0.412353515625, 0.0860595703125, -0.0246734619140625, 0.208984375, 1.291015625, 0.93017578125, -0.1639404296875, 0.06500244140625, -0.9228515625, -0.2232666015625, -0.10919189453125, -0.6943359375...
11
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Today Adilbek is taking his probability theory test. Unfortunately, when Adilbek arrived at the university, there had already been a long queue of students wanting to take the same test. Adilbek has estimated that he will be able to start the test only T seconds after coming. Fortunately, Adilbek can spend time without revising any boring theorems or formulas. He has an app on this smartphone which contains n Japanese crosswords to solve. Adilbek has decided to solve them all one by one in the order they are listed in the app, without skipping any crossword. For each crossword, a number t_i is given that represents the time it takes an average crossword expert to solve this crossword (the time is given in seconds). Adilbek is a true crossword expert, but, unfortunately, he is sometimes unlucky in choosing the way to solve the crossword. So, it takes him either t_i seconds or t_i + 1 seconds to solve the i-th crossword, equiprobably (with probability 1/2 he solves the crossword in exactly t_i seconds, and with probability 1/2 he has to spend an additional second to finish the crossword). All these events are independent. After T seconds pass (or after solving the last crossword, if he manages to do it in less than T seconds), Adilbek closes the app (if he finishes some crossword at the same moment, that crossword is considered solved; otherwise Adilbek does not finish solving the current crossword at all). He thinks it would be an interesting probability theory problem to calculate E — the expected number of crosswords he will be able to solve completely. Can you calculate it? Recall that the expected value of a discrete random variable is the probability-weighted average of all possible values — in this problem it means that the expected value of the number of solved crosswords can be calculated as E = ∑ _{i = 0}^{n} i p_i, where p_i is the probability that Adilbek will solve exactly i crosswords. We can represent E as rational fraction P/Q with Q > 0. To give the answer, you should print P ⋅ Q^{-1} mod (10^9 + 7). Input The first line contains two integers n and T (1 ≤ n ≤ 2 ⋅ 10^5, 1 ≤ T ≤ 2 ⋅ 10^{14}) — the number of crosswords and the time Adilbek has to spend, respectively. The second line contains n integers t_1, t_2, ..., t_n (1 ≤ t_i ≤ 10^9), where t_i is the time it takes a crossword expert to solve the i-th crossword. Note that Adilbek solves the crosswords in the order they are given in the input without skipping any of them. Output Print one integer — the expected value of the number of crosswords Adilbek solves in T seconds, expressed in the form of P ⋅ Q^{-1} mod (10^9 + 7). Examples Input 3 5 2 2 2 Output 750000007 Input 3 5 2 1 2 Output 125000003 Note The answer for the first sample is equal to 14/8. The answer for the second sample is equal to 17/8. Submitted Solution: ``` from sys import stdin, stdout, exit mod = 10**9 + 7 def gcd(x, y): if x > y: res = gcd(y, x) tmp = res[1] res[1] = res[2] res[2] = tmp return res if x == 0: return [y, 0, 1] res = gcd(y%x, x) tmp = res[1] res[1] = res[2] - tmp * (y // x) res[2] = tmp return res def modinv(x, m): res = gcd(x, m) res[1] %= m return res[1] N = 2*10**5 + 10 facts = [1]*N for i in range(1,N): facts[i] = facts[i-1] * i facts[i] %= mod def binom(n, k): ans = modinv(facts[k], mod) * modinv(facts[n-k], mod) ans %= mod ans *= facts[n] ans %= mod return ans #print("Finished preprocess") n, T = map(int, stdin.readline().split()) ts = list(map(int, stdin.readline().split())) ans = 0 total = sum(ts) running = total last_idx = n-1 while running > T: running -= ts[last_idx] last_idx -= 1 last_bd = -1 last_sum = 0 idx = last_idx while running + idx >= T: bd = T - running # print("time remaining for", idx, "is", bd) cur_sum = last_sum + binom(idx+2, last_bd) if last_bd >= 0 else 0 cur_sum *= modinv(2, mod) cur_sum %= mod for fresh in range(last_bd+1, bd+1): cur_sum += binom(idx+1, fresh) cur_sum %= mod # print("pr of", idx, "is", cur_sum / (2**(idx+1))) ans += cur_sum * modinv(pow(2, idx+1, mod), mod) ans %= mod running -= ts[idx] last_bd = bd last_sum = cur_sum idx -= 1 ans += idx+1 ans %= mod print(ans) ``` No
85,099
[ 0.03424072265625, 0.259033203125, -0.0906982421875, -0.1820068359375, -0.492431640625, -0.412353515625, 0.0860595703125, -0.0246734619140625, 0.208984375, 1.291015625, 0.93017578125, -0.1639404296875, 0.06500244140625, -0.9228515625, -0.2232666015625, -0.10919189453125, -0.6943359375...
11
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Today Adilbek is taking his probability theory test. Unfortunately, when Adilbek arrived at the university, there had already been a long queue of students wanting to take the same test. Adilbek has estimated that he will be able to start the test only T seconds after coming. Fortunately, Adilbek can spend time without revising any boring theorems or formulas. He has an app on this smartphone which contains n Japanese crosswords to solve. Adilbek has decided to solve them all one by one in the order they are listed in the app, without skipping any crossword. For each crossword, a number t_i is given that represents the time it takes an average crossword expert to solve this crossword (the time is given in seconds). Adilbek is a true crossword expert, but, unfortunately, he is sometimes unlucky in choosing the way to solve the crossword. So, it takes him either t_i seconds or t_i + 1 seconds to solve the i-th crossword, equiprobably (with probability 1/2 he solves the crossword in exactly t_i seconds, and with probability 1/2 he has to spend an additional second to finish the crossword). All these events are independent. After T seconds pass (or after solving the last crossword, if he manages to do it in less than T seconds), Adilbek closes the app (if he finishes some crossword at the same moment, that crossword is considered solved; otherwise Adilbek does not finish solving the current crossword at all). He thinks it would be an interesting probability theory problem to calculate E — the expected number of crosswords he will be able to solve completely. Can you calculate it? Recall that the expected value of a discrete random variable is the probability-weighted average of all possible values — in this problem it means that the expected value of the number of solved crosswords can be calculated as E = ∑ _{i = 0}^{n} i p_i, where p_i is the probability that Adilbek will solve exactly i crosswords. We can represent E as rational fraction P/Q with Q > 0. To give the answer, you should print P ⋅ Q^{-1} mod (10^9 + 7). Input The first line contains two integers n and T (1 ≤ n ≤ 2 ⋅ 10^5, 1 ≤ T ≤ 2 ⋅ 10^{14}) — the number of crosswords and the time Adilbek has to spend, respectively. The second line contains n integers t_1, t_2, ..., t_n (1 ≤ t_i ≤ 10^9), where t_i is the time it takes a crossword expert to solve the i-th crossword. Note that Adilbek solves the crosswords in the order they are given in the input without skipping any of them. Output Print one integer — the expected value of the number of crosswords Adilbek solves in T seconds, expressed in the form of P ⋅ Q^{-1} mod (10^9 + 7). Examples Input 3 5 2 2 2 Output 750000007 Input 3 5 2 1 2 Output 125000003 Note The answer for the first sample is equal to 14/8. The answer for the second sample is equal to 17/8. Submitted Solution: ``` mod = 10 ** 9 + 7 MAX = 2 * 10 ** 5+2 #"n" y "T" se definen como la cantidad de crucigramas y el tiempo maximo respectivamente. n, T = list(map(int, input().split())) #"t[i]" es el tiempo definido para el crucigrama "i". t = [0] t += list(map(int, input().split())) #Es solo para evitar desbordamiento. t += [MAX] #"factorial[i]" almacena el factorial de "i". r = [1] * MAX factorial = [1] * MAX rfactorial = [1] * MAX rp = [1] * MAX #"sim" hace referincia a "sigma", guarda la sumatoria de Combinacion de "sim_n" en "sim_p". sim = 0 sim_n = 0 sim_k = 0 #Almacena el valor esperado. E=0 #Es la suma acumulativa de los tiempos "t[i]" de los i-primeros crucigramas. S = [t[0]]*len(t) for i in range(1,len(t)): S[i] = S[i-1]+t[i] #Permite precalcular factorial hasta "MAX", para evitar tener que calcularlo varias veces #dentro de la ejecucion del programa. for i in range(2, MAX): factorial[i] = i * factorial[i - 1] % mod rfactorial[i] = rfactorial[i-1] * pow(i,mod-2,mod) % mod #Calcula el inverso de "p" para evitar usar fracciones racionales. for i in range(1, MAX): rp[i] = rp[i - 1] * pow(2,mod-2,mod) % mod #Permite calcular las Combinaciones de n en k. def Combination(n,k): if n < k: return 0 return factorial[n]*rfactorial[k]*rfactorial[n-k] #Calcula la sumatoria de las Combinaciones de "x" en "i", tal que "i" va desde cero a "mx". def simC(x): aux = 0 mx = min(x,T-S[x]) for i in range(0,mx+1): aux += Combination(x,i)%mod return x,mx,aux def next_simC(next_x): next_mx = min(next_x,T-S[next_x]) next_sim = 2*sim % mod next_sim = (next_sim + Combination(sim_n,sim_k + 1))%mod next_sim_n = sim_n + 1 next_sim_k = sim_k + 1 if next_sim_k > next_mx: next_sim = (next_sim - Combination(next_sim_n,next_sim_k)) % mod next_sim_k -= 1 return next_sim_n, next_sim_k, next_sim #Si "T - S[i] - i >= 0" implica que los i-primeros crucigramas tienen probabilidad "1" de que #sean resueltos. i = 1 while i <= n and T - S[i] - i >= 0: i +=1 E +=1 #Se debe calcular la probabilidad de todas las posibles combinaciones de los "i" crucigramas que necesitan tiempo extra #para ser resueltos. if i <= n: sim_n,sim_k,sim = simC(i) for x in range(i,n+1): E = (E + rp[x]*sim)%mod #No es posible que se resuelvan los restantes crucigramas. if T-S[x+1] < 0: break sim_n,sim_k,sim = next_simC(x+1) print(E) ``` No
85,100
[ 0.03424072265625, 0.259033203125, -0.0906982421875, -0.1820068359375, -0.492431640625, -0.412353515625, 0.0860595703125, -0.0246734619140625, 0.208984375, 1.291015625, 0.93017578125, -0.1639404296875, 0.06500244140625, -0.9228515625, -0.2232666015625, -0.10919189453125, -0.6943359375...
11
Provide tags and a correct Python 3 solution for this coding contest problem. During the last Sereja's Codesecrof round the server crashed many times, so the round was decided to be made unrated for some participants. Let's assume that n people took part in the contest. Let's assume that the participant who got the first place has rating a1, the second place participant has rating a2, ..., the n-th place participant has rating an. Then changing the rating on the Codesecrof site is calculated by the formula <image>. After the round was over, the Codesecrof management published the participants' results table. They decided that if for a participant di < k, then the round can be considered unrated for him. But imagine the management's surprise when they found out that the participants' rating table is dynamic. In other words, when some participant is removed from the rating, he is removed from the results' table and the rating is recalculated according to the new table. And of course, all applications for exclusion from the rating are considered in view of the current table. We know that among all the applications for exclusion from the rating the first application to consider is from the participant with the best rank (the rank with the minimum number), for who di < k. We also know that the applications for exclusion from rating were submitted by all participants. Now Sereja wonders, what is the number of participants to be excluded from the contest rating, and the numbers of the participants in the original table in the order of their exclusion from the rating. Pay attention to the analysis of the first test case for a better understanding of the statement. Input The first line contains two integers n, k (1 ≤ n ≤ 2·105, - 109 ≤ k ≤ 0). The second line contains n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 109) — ratings of the participants in the initial table. Output Print the numbers of participants in the order in which they were removed from the table. Print the initial numbers of the participants, that is, the numbers that the participants had in the initial table. Examples Input 5 0 5 3 4 1 2 Output 2 3 4 Input 10 -10 5 5 1 7 5 1 2 4 9 2 Output 2 4 5 7 8 9 Note Consider the first test sample. 1. Initially the sequence of the contest participants' ratings equals [5, 3, 4, 1, 2]. You can use this sequence to calculate the sequence of rating changes: [0, -9, -13, 8, 14]. According to the problem statement, the application of the participant who won the second place will be considered first. 2. As soon as the second place winner is out from the ratings, the participants' rating sequence will equal [5, 4, 1, 2]. By this sequence you can count the new sequence of rating changes: [0, -8, 2, 6]. According to the problem statement, the application of the participant who won the second place will be considered. Initially this participant won third place. 3. The new rating sequence equals [5, 1, 2], the new sequence of rating changes equals [0, -1, 1]. The second place participant's application is taken into consideration, initially this participant won the fourth place. 4. The new rating sequence equals [5, 2], the new sequence of rating changes equals [0, 0]. No more applications will be considered. Thus, you should print 2, 3, 4. Tags: implementation Correct Solution: ``` n, k = map(int, input().split()) arr = map(int, input().split()) s, j, all_res = 0, 0, [] for i, q in enumerate(arr, 1): if s - j * (n - i) * q < k: all_res.append(str(i)) else: s += q * j j += 1 print('\n'.join(all_res)) ```
85,284
[ 0.07452392578125, -0.1990966796875, -0.2069091796875, 0.4658203125, -0.26904296875, -0.6845703125, -0.52001953125, 0.1756591796875, -0.237548828125, 0.7900390625, 0.7080078125, 0.0361328125, 0.142333984375, -0.98095703125, -0.397216796875, 0.1455078125, -0.78271484375, -0.766601562...
11
Provide tags and a correct Python 3 solution for this coding contest problem. During the last Sereja's Codesecrof round the server crashed many times, so the round was decided to be made unrated for some participants. Let's assume that n people took part in the contest. Let's assume that the participant who got the first place has rating a1, the second place participant has rating a2, ..., the n-th place participant has rating an. Then changing the rating on the Codesecrof site is calculated by the formula <image>. After the round was over, the Codesecrof management published the participants' results table. They decided that if for a participant di < k, then the round can be considered unrated for him. But imagine the management's surprise when they found out that the participants' rating table is dynamic. In other words, when some participant is removed from the rating, he is removed from the results' table and the rating is recalculated according to the new table. And of course, all applications for exclusion from the rating are considered in view of the current table. We know that among all the applications for exclusion from the rating the first application to consider is from the participant with the best rank (the rank with the minimum number), for who di < k. We also know that the applications for exclusion from rating were submitted by all participants. Now Sereja wonders, what is the number of participants to be excluded from the contest rating, and the numbers of the participants in the original table in the order of their exclusion from the rating. Pay attention to the analysis of the first test case for a better understanding of the statement. Input The first line contains two integers n, k (1 ≤ n ≤ 2·105, - 109 ≤ k ≤ 0). The second line contains n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 109) — ratings of the participants in the initial table. Output Print the numbers of participants in the order in which they were removed from the table. Print the initial numbers of the participants, that is, the numbers that the participants had in the initial table. Examples Input 5 0 5 3 4 1 2 Output 2 3 4 Input 10 -10 5 5 1 7 5 1 2 4 9 2 Output 2 4 5 7 8 9 Note Consider the first test sample. 1. Initially the sequence of the contest participants' ratings equals [5, 3, 4, 1, 2]. You can use this sequence to calculate the sequence of rating changes: [0, -9, -13, 8, 14]. According to the problem statement, the application of the participant who won the second place will be considered first. 2. As soon as the second place winner is out from the ratings, the participants' rating sequence will equal [5, 4, 1, 2]. By this sequence you can count the new sequence of rating changes: [0, -8, 2, 6]. According to the problem statement, the application of the participant who won the second place will be considered. Initially this participant won third place. 3. The new rating sequence equals [5, 1, 2], the new sequence of rating changes equals [0, -1, 1]. The second place participant's application is taken into consideration, initially this participant won the fourth place. 4. The new rating sequence equals [5, 2], the new sequence of rating changes equals [0, 0]. No more applications will be considered. Thus, you should print 2, 3, 4. Tags: implementation Correct Solution: ``` f = lambda: map(int, input().split()) n, k = f() j = 0 for i, q in enumerate(f(), 1): if j * (i - n) * q < k: print(i) else: k -= q * j j += 1 ```
85,285
[ 0.07452392578125, -0.1990966796875, -0.2069091796875, 0.4658203125, -0.26904296875, -0.6845703125, -0.52001953125, 0.1756591796875, -0.237548828125, 0.7900390625, 0.7080078125, 0.0361328125, 0.142333984375, -0.98095703125, -0.397216796875, 0.1455078125, -0.78271484375, -0.766601562...
11
Provide tags and a correct Python 3 solution for this coding contest problem. During the last Sereja's Codesecrof round the server crashed many times, so the round was decided to be made unrated for some participants. Let's assume that n people took part in the contest. Let's assume that the participant who got the first place has rating a1, the second place participant has rating a2, ..., the n-th place participant has rating an. Then changing the rating on the Codesecrof site is calculated by the formula <image>. After the round was over, the Codesecrof management published the participants' results table. They decided that if for a participant di < k, then the round can be considered unrated for him. But imagine the management's surprise when they found out that the participants' rating table is dynamic. In other words, when some participant is removed from the rating, he is removed from the results' table and the rating is recalculated according to the new table. And of course, all applications for exclusion from the rating are considered in view of the current table. We know that among all the applications for exclusion from the rating the first application to consider is from the participant with the best rank (the rank with the minimum number), for who di < k. We also know that the applications for exclusion from rating were submitted by all participants. Now Sereja wonders, what is the number of participants to be excluded from the contest rating, and the numbers of the participants in the original table in the order of their exclusion from the rating. Pay attention to the analysis of the first test case for a better understanding of the statement. Input The first line contains two integers n, k (1 ≤ n ≤ 2·105, - 109 ≤ k ≤ 0). The second line contains n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 109) — ratings of the participants in the initial table. Output Print the numbers of participants in the order in which they were removed from the table. Print the initial numbers of the participants, that is, the numbers that the participants had in the initial table. Examples Input 5 0 5 3 4 1 2 Output 2 3 4 Input 10 -10 5 5 1 7 5 1 2 4 9 2 Output 2 4 5 7 8 9 Note Consider the first test sample. 1. Initially the sequence of the contest participants' ratings equals [5, 3, 4, 1, 2]. You can use this sequence to calculate the sequence of rating changes: [0, -9, -13, 8, 14]. According to the problem statement, the application of the participant who won the second place will be considered first. 2. As soon as the second place winner is out from the ratings, the participants' rating sequence will equal [5, 4, 1, 2]. By this sequence you can count the new sequence of rating changes: [0, -8, 2, 6]. According to the problem statement, the application of the participant who won the second place will be considered. Initially this participant won third place. 3. The new rating sequence equals [5, 1, 2], the new sequence of rating changes equals [0, -1, 1]. The second place participant's application is taken into consideration, initially this participant won the fourth place. 4. The new rating sequence equals [5, 2], the new sequence of rating changes equals [0, 0]. No more applications will be considered. Thus, you should print 2, 3, 4. Tags: implementation Correct Solution: ``` n, k = map(int, input().split()) c, m, l, r = 0, 0, [], 0 for e in [int(i) for i in input().split()]: d = m - c * (n - c - 1) * e r+= 1 if d < k: n -= 1 l += [r] else: m += c * e c += 1 l.sort() for e in l: print(e) ```
85,286
[ 0.07452392578125, -0.1990966796875, -0.2069091796875, 0.4658203125, -0.26904296875, -0.6845703125, -0.52001953125, 0.1756591796875, -0.237548828125, 0.7900390625, 0.7080078125, 0.0361328125, 0.142333984375, -0.98095703125, -0.397216796875, 0.1455078125, -0.78271484375, -0.766601562...
11
Provide tags and a correct Python 3 solution for this coding contest problem. During the last Sereja's Codesecrof round the server crashed many times, so the round was decided to be made unrated for some participants. Let's assume that n people took part in the contest. Let's assume that the participant who got the first place has rating a1, the second place participant has rating a2, ..., the n-th place participant has rating an. Then changing the rating on the Codesecrof site is calculated by the formula <image>. After the round was over, the Codesecrof management published the participants' results table. They decided that if for a participant di < k, then the round can be considered unrated for him. But imagine the management's surprise when they found out that the participants' rating table is dynamic. In other words, when some participant is removed from the rating, he is removed from the results' table and the rating is recalculated according to the new table. And of course, all applications for exclusion from the rating are considered in view of the current table. We know that among all the applications for exclusion from the rating the first application to consider is from the participant with the best rank (the rank with the minimum number), for who di < k. We also know that the applications for exclusion from rating were submitted by all participants. Now Sereja wonders, what is the number of participants to be excluded from the contest rating, and the numbers of the participants in the original table in the order of their exclusion from the rating. Pay attention to the analysis of the first test case for a better understanding of the statement. Input The first line contains two integers n, k (1 ≤ n ≤ 2·105, - 109 ≤ k ≤ 0). The second line contains n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 109) — ratings of the participants in the initial table. Output Print the numbers of participants in the order in which they were removed from the table. Print the initial numbers of the participants, that is, the numbers that the participants had in the initial table. Examples Input 5 0 5 3 4 1 2 Output 2 3 4 Input 10 -10 5 5 1 7 5 1 2 4 9 2 Output 2 4 5 7 8 9 Note Consider the first test sample. 1. Initially the sequence of the contest participants' ratings equals [5, 3, 4, 1, 2]. You can use this sequence to calculate the sequence of rating changes: [0, -9, -13, 8, 14]. According to the problem statement, the application of the participant who won the second place will be considered first. 2. As soon as the second place winner is out from the ratings, the participants' rating sequence will equal [5, 4, 1, 2]. By this sequence you can count the new sequence of rating changes: [0, -8, 2, 6]. According to the problem statement, the application of the participant who won the second place will be considered. Initially this participant won third place. 3. The new rating sequence equals [5, 1, 2], the new sequence of rating changes equals [0, -1, 1]. The second place participant's application is taken into consideration, initially this participant won the fourth place. 4. The new rating sequence equals [5, 2], the new sequence of rating changes equals [0, 0]. No more applications will be considered. Thus, you should print 2, 3, 4. Tags: implementation Correct Solution: ``` from sys import stdin,stdout nmbr = lambda: int(stdin.readline()) lst = lambda: list(map(int,stdin.readline().split())) for _ in range(1):#nmbr()): n,k=lst() a=lst() removed=0 positive_term=0 for i in range(1,n): negative_term=(i-removed)*a[i]*(n-i-1) if (positive_term-negative_term)<k: removed+=1 stdout.write(str(i+1)+'\n') else:positive_term += (i - removed) * a[i] ```
85,287
[ 0.07452392578125, -0.1990966796875, -0.2069091796875, 0.4658203125, -0.26904296875, -0.6845703125, -0.52001953125, 0.1756591796875, -0.237548828125, 0.7900390625, 0.7080078125, 0.0361328125, 0.142333984375, -0.98095703125, -0.397216796875, 0.1455078125, -0.78271484375, -0.766601562...
11
Provide tags and a correct Python 3 solution for this coding contest problem. During the last Sereja's Codesecrof round the server crashed many times, so the round was decided to be made unrated for some participants. Let's assume that n people took part in the contest. Let's assume that the participant who got the first place has rating a1, the second place participant has rating a2, ..., the n-th place participant has rating an. Then changing the rating on the Codesecrof site is calculated by the formula <image>. After the round was over, the Codesecrof management published the participants' results table. They decided that if for a participant di < k, then the round can be considered unrated for him. But imagine the management's surprise when they found out that the participants' rating table is dynamic. In other words, when some participant is removed from the rating, he is removed from the results' table and the rating is recalculated according to the new table. And of course, all applications for exclusion from the rating are considered in view of the current table. We know that among all the applications for exclusion from the rating the first application to consider is from the participant with the best rank (the rank with the minimum number), for who di < k. We also know that the applications for exclusion from rating were submitted by all participants. Now Sereja wonders, what is the number of participants to be excluded from the contest rating, and the numbers of the participants in the original table in the order of their exclusion from the rating. Pay attention to the analysis of the first test case for a better understanding of the statement. Input The first line contains two integers n, k (1 ≤ n ≤ 2·105, - 109 ≤ k ≤ 0). The second line contains n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 109) — ratings of the participants in the initial table. Output Print the numbers of participants in the order in which they were removed from the table. Print the initial numbers of the participants, that is, the numbers that the participants had in the initial table. Examples Input 5 0 5 3 4 1 2 Output 2 3 4 Input 10 -10 5 5 1 7 5 1 2 4 9 2 Output 2 4 5 7 8 9 Note Consider the first test sample. 1. Initially the sequence of the contest participants' ratings equals [5, 3, 4, 1, 2]. You can use this sequence to calculate the sequence of rating changes: [0, -9, -13, 8, 14]. According to the problem statement, the application of the participant who won the second place will be considered first. 2. As soon as the second place winner is out from the ratings, the participants' rating sequence will equal [5, 4, 1, 2]. By this sequence you can count the new sequence of rating changes: [0, -8, 2, 6]. According to the problem statement, the application of the participant who won the second place will be considered. Initially this participant won third place. 3. The new rating sequence equals [5, 1, 2], the new sequence of rating changes equals [0, -1, 1]. The second place participant's application is taken into consideration, initially this participant won the fourth place. 4. The new rating sequence equals [5, 2], the new sequence of rating changes equals [0, 0]. No more applications will be considered. Thus, you should print 2, 3, 4. Tags: implementation Correct Solution: ``` n, k = map(int, input().split()) c, v = 0, [] for i, a in enumerate(map(int, input().split())): j = i + 1 - len(v) d = c - (j - 1) * (n - j) * a if d < k: v.append(i + 1) n -= 1 else: c += a * (j - 1) print('\n'.join(map(str, v))) ```
85,288
[ 0.07452392578125, -0.1990966796875, -0.2069091796875, 0.4658203125, -0.26904296875, -0.6845703125, -0.52001953125, 0.1756591796875, -0.237548828125, 0.7900390625, 0.7080078125, 0.0361328125, 0.142333984375, -0.98095703125, -0.397216796875, 0.1455078125, -0.78271484375, -0.766601562...
11
Provide tags and a correct Python 3 solution for this coding contest problem. During the last Sereja's Codesecrof round the server crashed many times, so the round was decided to be made unrated for some participants. Let's assume that n people took part in the contest. Let's assume that the participant who got the first place has rating a1, the second place participant has rating a2, ..., the n-th place participant has rating an. Then changing the rating on the Codesecrof site is calculated by the formula <image>. After the round was over, the Codesecrof management published the participants' results table. They decided that if for a participant di < k, then the round can be considered unrated for him. But imagine the management's surprise when they found out that the participants' rating table is dynamic. In other words, when some participant is removed from the rating, he is removed from the results' table and the rating is recalculated according to the new table. And of course, all applications for exclusion from the rating are considered in view of the current table. We know that among all the applications for exclusion from the rating the first application to consider is from the participant with the best rank (the rank with the minimum number), for who di < k. We also know that the applications for exclusion from rating were submitted by all participants. Now Sereja wonders, what is the number of participants to be excluded from the contest rating, and the numbers of the participants in the original table in the order of their exclusion from the rating. Pay attention to the analysis of the first test case for a better understanding of the statement. Input The first line contains two integers n, k (1 ≤ n ≤ 2·105, - 109 ≤ k ≤ 0). The second line contains n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 109) — ratings of the participants in the initial table. Output Print the numbers of participants in the order in which they were removed from the table. Print the initial numbers of the participants, that is, the numbers that the participants had in the initial table. Examples Input 5 0 5 3 4 1 2 Output 2 3 4 Input 10 -10 5 5 1 7 5 1 2 4 9 2 Output 2 4 5 7 8 9 Note Consider the first test sample. 1. Initially the sequence of the contest participants' ratings equals [5, 3, 4, 1, 2]. You can use this sequence to calculate the sequence of rating changes: [0, -9, -13, 8, 14]. According to the problem statement, the application of the participant who won the second place will be considered first. 2. As soon as the second place winner is out from the ratings, the participants' rating sequence will equal [5, 4, 1, 2]. By this sequence you can count the new sequence of rating changes: [0, -8, 2, 6]. According to the problem statement, the application of the participant who won the second place will be considered. Initially this participant won third place. 3. The new rating sequence equals [5, 1, 2], the new sequence of rating changes equals [0, -1, 1]. The second place participant's application is taken into consideration, initially this participant won the fourth place. 4. The new rating sequence equals [5, 2], the new sequence of rating changes equals [0, 0]. No more applications will be considered. Thus, you should print 2, 3, 4. Tags: implementation Correct Solution: ``` n, k = map(int, input().split()) a = [int(x) for x in input().split()] rmv = 0 ss = 0 for ii in range(n): i = ii-rmv if ss - (n-rmv-i-1)*a[ii]*i < k: rmv += 1 print(ii+1) else: ss += a[ii]*i ```
85,289
[ 0.07452392578125, -0.1990966796875, -0.2069091796875, 0.4658203125, -0.26904296875, -0.6845703125, -0.52001953125, 0.1756591796875, -0.237548828125, 0.7900390625, 0.7080078125, 0.0361328125, 0.142333984375, -0.98095703125, -0.397216796875, 0.1455078125, -0.78271484375, -0.766601562...
11
Provide tags and a correct Python 3 solution for this coding contest problem. During the last Sereja's Codesecrof round the server crashed many times, so the round was decided to be made unrated for some participants. Let's assume that n people took part in the contest. Let's assume that the participant who got the first place has rating a1, the second place participant has rating a2, ..., the n-th place participant has rating an. Then changing the rating on the Codesecrof site is calculated by the formula <image>. After the round was over, the Codesecrof management published the participants' results table. They decided that if for a participant di < k, then the round can be considered unrated for him. But imagine the management's surprise when they found out that the participants' rating table is dynamic. In other words, when some participant is removed from the rating, he is removed from the results' table and the rating is recalculated according to the new table. And of course, all applications for exclusion from the rating are considered in view of the current table. We know that among all the applications for exclusion from the rating the first application to consider is from the participant with the best rank (the rank with the minimum number), for who di < k. We also know that the applications for exclusion from rating were submitted by all participants. Now Sereja wonders, what is the number of participants to be excluded from the contest rating, and the numbers of the participants in the original table in the order of their exclusion from the rating. Pay attention to the analysis of the first test case for a better understanding of the statement. Input The first line contains two integers n, k (1 ≤ n ≤ 2·105, - 109 ≤ k ≤ 0). The second line contains n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 109) — ratings of the participants in the initial table. Output Print the numbers of participants in the order in which they were removed from the table. Print the initial numbers of the participants, that is, the numbers that the participants had in the initial table. Examples Input 5 0 5 3 4 1 2 Output 2 3 4 Input 10 -10 5 5 1 7 5 1 2 4 9 2 Output 2 4 5 7 8 9 Note Consider the first test sample. 1. Initially the sequence of the contest participants' ratings equals [5, 3, 4, 1, 2]. You can use this sequence to calculate the sequence of rating changes: [0, -9, -13, 8, 14]. According to the problem statement, the application of the participant who won the second place will be considered first. 2. As soon as the second place winner is out from the ratings, the participants' rating sequence will equal [5, 4, 1, 2]. By this sequence you can count the new sequence of rating changes: [0, -8, 2, 6]. According to the problem statement, the application of the participant who won the second place will be considered. Initially this participant won third place. 3. The new rating sequence equals [5, 1, 2], the new sequence of rating changes equals [0, -1, 1]. The second place participant's application is taken into consideration, initially this participant won the fourth place. 4. The new rating sequence equals [5, 2], the new sequence of rating changes equals [0, 0]. No more applications will be considered. Thus, you should print 2, 3, 4. Tags: implementation Correct Solution: ``` n, k = map(int, input().split()) S = D = i = 0 ans = [] for val in map(int, input().split()): f = (n - i - 1) * val * (i - D) if S - f < k: D += 1 ans.append(i + 1) else: S += val * (i - D) i += 1 print(' '.join(map(str, ans))) ```
85,290
[ 0.07452392578125, -0.1990966796875, -0.2069091796875, 0.4658203125, -0.26904296875, -0.6845703125, -0.52001953125, 0.1756591796875, -0.237548828125, 0.7900390625, 0.7080078125, 0.0361328125, 0.142333984375, -0.98095703125, -0.397216796875, 0.1455078125, -0.78271484375, -0.766601562...
11
Provide tags and a correct Python 3 solution for this coding contest problem. During the last Sereja's Codesecrof round the server crashed many times, so the round was decided to be made unrated for some participants. Let's assume that n people took part in the contest. Let's assume that the participant who got the first place has rating a1, the second place participant has rating a2, ..., the n-th place participant has rating an. Then changing the rating on the Codesecrof site is calculated by the formula <image>. After the round was over, the Codesecrof management published the participants' results table. They decided that if for a participant di < k, then the round can be considered unrated for him. But imagine the management's surprise when they found out that the participants' rating table is dynamic. In other words, when some participant is removed from the rating, he is removed from the results' table and the rating is recalculated according to the new table. And of course, all applications for exclusion from the rating are considered in view of the current table. We know that among all the applications for exclusion from the rating the first application to consider is from the participant with the best rank (the rank with the minimum number), for who di < k. We also know that the applications for exclusion from rating were submitted by all participants. Now Sereja wonders, what is the number of participants to be excluded from the contest rating, and the numbers of the participants in the original table in the order of their exclusion from the rating. Pay attention to the analysis of the first test case for a better understanding of the statement. Input The first line contains two integers n, k (1 ≤ n ≤ 2·105, - 109 ≤ k ≤ 0). The second line contains n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 109) — ratings of the participants in the initial table. Output Print the numbers of participants in the order in which they were removed from the table. Print the initial numbers of the participants, that is, the numbers that the participants had in the initial table. Examples Input 5 0 5 3 4 1 2 Output 2 3 4 Input 10 -10 5 5 1 7 5 1 2 4 9 2 Output 2 4 5 7 8 9 Note Consider the first test sample. 1. Initially the sequence of the contest participants' ratings equals [5, 3, 4, 1, 2]. You can use this sequence to calculate the sequence of rating changes: [0, -9, -13, 8, 14]. According to the problem statement, the application of the participant who won the second place will be considered first. 2. As soon as the second place winner is out from the ratings, the participants' rating sequence will equal [5, 4, 1, 2]. By this sequence you can count the new sequence of rating changes: [0, -8, 2, 6]. According to the problem statement, the application of the participant who won the second place will be considered. Initially this participant won third place. 3. The new rating sequence equals [5, 1, 2], the new sequence of rating changes equals [0, -1, 1]. The second place participant's application is taken into consideration, initially this participant won the fourth place. 4. The new rating sequence equals [5, 2], the new sequence of rating changes equals [0, 0]. No more applications will be considered. Thus, you should print 2, 3, 4. Tags: implementation Correct Solution: ``` r = lambda: map(int, input().split()) n, k = r() data = list(r()) alc = 0 total = 0 for i in range(n): d = alc - total * (n - (i - total) - total - 1) * data[i] if d >= k: alc += total * data[i] total += 1 else: print(i + 1) ```
85,291
[ 0.07452392578125, -0.1990966796875, -0.2069091796875, 0.4658203125, -0.26904296875, -0.6845703125, -0.52001953125, 0.1756591796875, -0.237548828125, 0.7900390625, 0.7080078125, 0.0361328125, 0.142333984375, -0.98095703125, -0.397216796875, 0.1455078125, -0.78271484375, -0.766601562...
11
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. During the last Sereja's Codesecrof round the server crashed many times, so the round was decided to be made unrated for some participants. Let's assume that n people took part in the contest. Let's assume that the participant who got the first place has rating a1, the second place participant has rating a2, ..., the n-th place participant has rating an. Then changing the rating on the Codesecrof site is calculated by the formula <image>. After the round was over, the Codesecrof management published the participants' results table. They decided that if for a participant di < k, then the round can be considered unrated for him. But imagine the management's surprise when they found out that the participants' rating table is dynamic. In other words, when some participant is removed from the rating, he is removed from the results' table and the rating is recalculated according to the new table. And of course, all applications for exclusion from the rating are considered in view of the current table. We know that among all the applications for exclusion from the rating the first application to consider is from the participant with the best rank (the rank with the minimum number), for who di < k. We also know that the applications for exclusion from rating were submitted by all participants. Now Sereja wonders, what is the number of participants to be excluded from the contest rating, and the numbers of the participants in the original table in the order of their exclusion from the rating. Pay attention to the analysis of the first test case for a better understanding of the statement. Input The first line contains two integers n, k (1 ≤ n ≤ 2·105, - 109 ≤ k ≤ 0). The second line contains n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 109) — ratings of the participants in the initial table. Output Print the numbers of participants in the order in which they were removed from the table. Print the initial numbers of the participants, that is, the numbers that the participants had in the initial table. Examples Input 5 0 5 3 4 1 2 Output 2 3 4 Input 10 -10 5 5 1 7 5 1 2 4 9 2 Output 2 4 5 7 8 9 Note Consider the first test sample. 1. Initially the sequence of the contest participants' ratings equals [5, 3, 4, 1, 2]. You can use this sequence to calculate the sequence of rating changes: [0, -9, -13, 8, 14]. According to the problem statement, the application of the participant who won the second place will be considered first. 2. As soon as the second place winner is out from the ratings, the participants' rating sequence will equal [5, 4, 1, 2]. By this sequence you can count the new sequence of rating changes: [0, -8, 2, 6]. According to the problem statement, the application of the participant who won the second place will be considered. Initially this participant won third place. 3. The new rating sequence equals [5, 1, 2], the new sequence of rating changes equals [0, -1, 1]. The second place participant's application is taken into consideration, initially this participant won the fourth place. 4. The new rating sequence equals [5, 2], the new sequence of rating changes equals [0, 0]. No more applications will be considered. Thus, you should print 2, 3, 4. Submitted Solution: ``` n, k = map(int, input().split()) s = 0 rem, i = 0, 1 ans = [] for cur in map(int, input().split()): add = (n - i) * cur * (i - rem - 1) if s - add < k: rem += 1 ans.append(i) else: s += cur * (i - rem - 1) i += 1 print(' '.join(map(str, ans))) ``` Yes
85,292
[ 0.1669921875, -0.1617431640625, -0.1416015625, 0.351806640625, -0.383544921875, -0.6142578125, -0.55078125, 0.218994140625, -0.25048828125, 0.73095703125, 0.62548828125, 0.10675048828125, 0.099609375, -0.939453125, -0.337890625, 0.1007080078125, -0.7333984375, -0.751953125, -0.39...
11
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. During the last Sereja's Codesecrof round the server crashed many times, so the round was decided to be made unrated for some participants. Let's assume that n people took part in the contest. Let's assume that the participant who got the first place has rating a1, the second place participant has rating a2, ..., the n-th place participant has rating an. Then changing the rating on the Codesecrof site is calculated by the formula <image>. After the round was over, the Codesecrof management published the participants' results table. They decided that if for a participant di < k, then the round can be considered unrated for him. But imagine the management's surprise when they found out that the participants' rating table is dynamic. In other words, when some participant is removed from the rating, he is removed from the results' table and the rating is recalculated according to the new table. And of course, all applications for exclusion from the rating are considered in view of the current table. We know that among all the applications for exclusion from the rating the first application to consider is from the participant with the best rank (the rank with the minimum number), for who di < k. We also know that the applications for exclusion from rating were submitted by all participants. Now Sereja wonders, what is the number of participants to be excluded from the contest rating, and the numbers of the participants in the original table in the order of their exclusion from the rating. Pay attention to the analysis of the first test case for a better understanding of the statement. Input The first line contains two integers n, k (1 ≤ n ≤ 2·105, - 109 ≤ k ≤ 0). The second line contains n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 109) — ratings of the participants in the initial table. Output Print the numbers of participants in the order in which they were removed from the table. Print the initial numbers of the participants, that is, the numbers that the participants had in the initial table. Examples Input 5 0 5 3 4 1 2 Output 2 3 4 Input 10 -10 5 5 1 7 5 1 2 4 9 2 Output 2 4 5 7 8 9 Note Consider the first test sample. 1. Initially the sequence of the contest participants' ratings equals [5, 3, 4, 1, 2]. You can use this sequence to calculate the sequence of rating changes: [0, -9, -13, 8, 14]. According to the problem statement, the application of the participant who won the second place will be considered first. 2. As soon as the second place winner is out from the ratings, the participants' rating sequence will equal [5, 4, 1, 2]. By this sequence you can count the new sequence of rating changes: [0, -8, 2, 6]. According to the problem statement, the application of the participant who won the second place will be considered. Initially this participant won third place. 3. The new rating sequence equals [5, 1, 2], the new sequence of rating changes equals [0, -1, 1]. The second place participant's application is taken into consideration, initially this participant won the fourth place. 4. The new rating sequence equals [5, 2], the new sequence of rating changes equals [0, 0]. No more applications will be considered. Thus, you should print 2, 3, 4. Submitted Solution: ``` f = lambda: map(int, input().split()) n, k = f() s = j = 0 for i, q in enumerate(f(), 1): if s - j * (n - i) * q < k: print(i) else: s += q * j j += 1 ``` Yes
85,293
[ 0.1669921875, -0.1617431640625, -0.1416015625, 0.351806640625, -0.383544921875, -0.6142578125, -0.55078125, 0.218994140625, -0.25048828125, 0.73095703125, 0.62548828125, 0.10675048828125, 0.099609375, -0.939453125, -0.337890625, 0.1007080078125, -0.7333984375, -0.751953125, -0.39...
11
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. During the last Sereja's Codesecrof round the server crashed many times, so the round was decided to be made unrated for some participants. Let's assume that n people took part in the contest. Let's assume that the participant who got the first place has rating a1, the second place participant has rating a2, ..., the n-th place participant has rating an. Then changing the rating on the Codesecrof site is calculated by the formula <image>. After the round was over, the Codesecrof management published the participants' results table. They decided that if for a participant di < k, then the round can be considered unrated for him. But imagine the management's surprise when they found out that the participants' rating table is dynamic. In other words, when some participant is removed from the rating, he is removed from the results' table and the rating is recalculated according to the new table. And of course, all applications for exclusion from the rating are considered in view of the current table. We know that among all the applications for exclusion from the rating the first application to consider is from the participant with the best rank (the rank with the minimum number), for who di < k. We also know that the applications for exclusion from rating were submitted by all participants. Now Sereja wonders, what is the number of participants to be excluded from the contest rating, and the numbers of the participants in the original table in the order of their exclusion from the rating. Pay attention to the analysis of the first test case for a better understanding of the statement. Input The first line contains two integers n, k (1 ≤ n ≤ 2·105, - 109 ≤ k ≤ 0). The second line contains n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 109) — ratings of the participants in the initial table. Output Print the numbers of participants in the order in which they were removed from the table. Print the initial numbers of the participants, that is, the numbers that the participants had in the initial table. Examples Input 5 0 5 3 4 1 2 Output 2 3 4 Input 10 -10 5 5 1 7 5 1 2 4 9 2 Output 2 4 5 7 8 9 Note Consider the first test sample. 1. Initially the sequence of the contest participants' ratings equals [5, 3, 4, 1, 2]. You can use this sequence to calculate the sequence of rating changes: [0, -9, -13, 8, 14]. According to the problem statement, the application of the participant who won the second place will be considered first. 2. As soon as the second place winner is out from the ratings, the participants' rating sequence will equal [5, 4, 1, 2]. By this sequence you can count the new sequence of rating changes: [0, -8, 2, 6]. According to the problem statement, the application of the participant who won the second place will be considered. Initially this participant won third place. 3. The new rating sequence equals [5, 1, 2], the new sequence of rating changes equals [0, -1, 1]. The second place participant's application is taken into consideration, initially this participant won the fourth place. 4. The new rating sequence equals [5, 2], the new sequence of rating changes equals [0, 0]. No more applications will be considered. Thus, you should print 2, 3, 4. Submitted Solution: ``` from sys import stdin,stdout nmbr = lambda: int(stdin.readline()) lst = lambda: list(map(int,stdin.readline().split())) def fn(a): print('a',a) n=len(a) pos1=[0] for i in range(1,n): pos1+=[pos1[-1]+a[i]*i] print('pos1',pos1) neg=[] for i in range(n): neg+=[i*(n-i-1)*a[i]] print('neg',neg) d=[] for i in range(1,n+1): sm=0 for j in range(1,i): sm+=a[j-1]*(j-1)-(n-i)*a[i-1] d+=[sm] print('d',d); print('================================') p=-1 for i in range(1,n): if pos1[i-1]-neg[i]<k: p=i break if p==-1:return a.pop(p) fn(a) for _ in range(1):#nmbr()): n,k=lst() a=lst() # fn(a) # exit(0) pos = [0] for i in range(1, n): pos += [pos[-1] + a[i] * i] removed=0 positive_term=0 for i in range(1,n): negative_term=(i-removed)*a[i]*(n-i-1) # print(positive_term,positive_term-negative_term) if (positive_term-negative_term)<k: removed+=1 stdout.write(str(i+1)+'\n') else:positive_term += (i - removed) * a[i] ``` Yes
85,294
[ 0.1669921875, -0.1617431640625, -0.1416015625, 0.351806640625, -0.383544921875, -0.6142578125, -0.55078125, 0.218994140625, -0.25048828125, 0.73095703125, 0.62548828125, 0.10675048828125, 0.099609375, -0.939453125, -0.337890625, 0.1007080078125, -0.7333984375, -0.751953125, -0.39...
11
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. During the last Sereja's Codesecrof round the server crashed many times, so the round was decided to be made unrated for some participants. Let's assume that n people took part in the contest. Let's assume that the participant who got the first place has rating a1, the second place participant has rating a2, ..., the n-th place participant has rating an. Then changing the rating on the Codesecrof site is calculated by the formula <image>. After the round was over, the Codesecrof management published the participants' results table. They decided that if for a participant di < k, then the round can be considered unrated for him. But imagine the management's surprise when they found out that the participants' rating table is dynamic. In other words, when some participant is removed from the rating, he is removed from the results' table and the rating is recalculated according to the new table. And of course, all applications for exclusion from the rating are considered in view of the current table. We know that among all the applications for exclusion from the rating the first application to consider is from the participant with the best rank (the rank with the minimum number), for who di < k. We also know that the applications for exclusion from rating were submitted by all participants. Now Sereja wonders, what is the number of participants to be excluded from the contest rating, and the numbers of the participants in the original table in the order of their exclusion from the rating. Pay attention to the analysis of the first test case for a better understanding of the statement. Input The first line contains two integers n, k (1 ≤ n ≤ 2·105, - 109 ≤ k ≤ 0). The second line contains n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 109) — ratings of the participants in the initial table. Output Print the numbers of participants in the order in which they were removed from the table. Print the initial numbers of the participants, that is, the numbers that the participants had in the initial table. Examples Input 5 0 5 3 4 1 2 Output 2 3 4 Input 10 -10 5 5 1 7 5 1 2 4 9 2 Output 2 4 5 7 8 9 Note Consider the first test sample. 1. Initially the sequence of the contest participants' ratings equals [5, 3, 4, 1, 2]. You can use this sequence to calculate the sequence of rating changes: [0, -9, -13, 8, 14]. According to the problem statement, the application of the participant who won the second place will be considered first. 2. As soon as the second place winner is out from the ratings, the participants' rating sequence will equal [5, 4, 1, 2]. By this sequence you can count the new sequence of rating changes: [0, -8, 2, 6]. According to the problem statement, the application of the participant who won the second place will be considered. Initially this participant won third place. 3. The new rating sequence equals [5, 1, 2], the new sequence of rating changes equals [0, -1, 1]. The second place participant's application is taken into consideration, initially this participant won the fourth place. 4. The new rating sequence equals [5, 2], the new sequence of rating changes equals [0, 0]. No more applications will be considered. Thus, you should print 2, 3, 4. Submitted Solution: ``` n, k = map(int, input().split()) a = list(map(int, input().split())) tot = 0 nn = n ii = 1 for i in range(n): di = tot - (ii-1)*(nn-ii)*a[i] if i == 0: di = 0 # print(i, di) if di < k: print(i+1) nn -= 1 else: tot += a[i]*(ii-1) ii += 1 ``` Yes
85,295
[ 0.1669921875, -0.1617431640625, -0.1416015625, 0.351806640625, -0.383544921875, -0.6142578125, -0.55078125, 0.218994140625, -0.25048828125, 0.73095703125, 0.62548828125, 0.10675048828125, 0.099609375, -0.939453125, -0.337890625, 0.1007080078125, -0.7333984375, -0.751953125, -0.39...
11
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. During the last Sereja's Codesecrof round the server crashed many times, so the round was decided to be made unrated for some participants. Let's assume that n people took part in the contest. Let's assume that the participant who got the first place has rating a1, the second place participant has rating a2, ..., the n-th place participant has rating an. Then changing the rating on the Codesecrof site is calculated by the formula <image>. After the round was over, the Codesecrof management published the participants' results table. They decided that if for a participant di < k, then the round can be considered unrated for him. But imagine the management's surprise when they found out that the participants' rating table is dynamic. In other words, when some participant is removed from the rating, he is removed from the results' table and the rating is recalculated according to the new table. And of course, all applications for exclusion from the rating are considered in view of the current table. We know that among all the applications for exclusion from the rating the first application to consider is from the participant with the best rank (the rank with the minimum number), for who di < k. We also know that the applications for exclusion from rating were submitted by all participants. Now Sereja wonders, what is the number of participants to be excluded from the contest rating, and the numbers of the participants in the original table in the order of their exclusion from the rating. Pay attention to the analysis of the first test case for a better understanding of the statement. Input The first line contains two integers n, k (1 ≤ n ≤ 2·105, - 109 ≤ k ≤ 0). The second line contains n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 109) — ratings of the participants in the initial table. Output Print the numbers of participants in the order in which they were removed from the table. Print the initial numbers of the participants, that is, the numbers that the participants had in the initial table. Examples Input 5 0 5 3 4 1 2 Output 2 3 4 Input 10 -10 5 5 1 7 5 1 2 4 9 2 Output 2 4 5 7 8 9 Note Consider the first test sample. 1. Initially the sequence of the contest participants' ratings equals [5, 3, 4, 1, 2]. You can use this sequence to calculate the sequence of rating changes: [0, -9, -13, 8, 14]. According to the problem statement, the application of the participant who won the second place will be considered first. 2. As soon as the second place winner is out from the ratings, the participants' rating sequence will equal [5, 4, 1, 2]. By this sequence you can count the new sequence of rating changes: [0, -8, 2, 6]. According to the problem statement, the application of the participant who won the second place will be considered. Initially this participant won third place. 3. The new rating sequence equals [5, 1, 2], the new sequence of rating changes equals [0, -1, 1]. The second place participant's application is taken into consideration, initially this participant won the fourth place. 4. The new rating sequence equals [5, 2], the new sequence of rating changes equals [0, 0]. No more applications will be considered. Thus, you should print 2, 3, 4. Submitted Solution: ``` def IO(): import sys sys.stdout = open('output.txt', 'w') sys.stdin = open('input.txt', 'r') ###################### MAIN PROGRAM ##################### def main(): # IO() n, k = map(int, input().split()) a = list(map(int, input().split())) ans = list() run = int(0) deleted = 0 for i in range(n): ratingCh = run - a[i] * (n - i - 1) * (i) if (ratingCh < k): deleted += 1 ans.append(i) else: run += a[i] * i for e in ans: print(f"{e+1} ") ##################### END OF PROGRAM #################### if __name__ == "__main__": main() ``` No
85,296
[ 0.1669921875, -0.1617431640625, -0.1416015625, 0.351806640625, -0.383544921875, -0.6142578125, -0.55078125, 0.218994140625, -0.25048828125, 0.73095703125, 0.62548828125, 0.10675048828125, 0.099609375, -0.939453125, -0.337890625, 0.1007080078125, -0.7333984375, -0.751953125, -0.39...
11
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. During the last Sereja's Codesecrof round the server crashed many times, so the round was decided to be made unrated for some participants. Let's assume that n people took part in the contest. Let's assume that the participant who got the first place has rating a1, the second place participant has rating a2, ..., the n-th place participant has rating an. Then changing the rating on the Codesecrof site is calculated by the formula <image>. After the round was over, the Codesecrof management published the participants' results table. They decided that if for a participant di < k, then the round can be considered unrated for him. But imagine the management's surprise when they found out that the participants' rating table is dynamic. In other words, when some participant is removed from the rating, he is removed from the results' table and the rating is recalculated according to the new table. And of course, all applications for exclusion from the rating are considered in view of the current table. We know that among all the applications for exclusion from the rating the first application to consider is from the participant with the best rank (the rank with the minimum number), for who di < k. We also know that the applications for exclusion from rating were submitted by all participants. Now Sereja wonders, what is the number of participants to be excluded from the contest rating, and the numbers of the participants in the original table in the order of their exclusion from the rating. Pay attention to the analysis of the first test case for a better understanding of the statement. Input The first line contains two integers n, k (1 ≤ n ≤ 2·105, - 109 ≤ k ≤ 0). The second line contains n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 109) — ratings of the participants in the initial table. Output Print the numbers of participants in the order in which they were removed from the table. Print the initial numbers of the participants, that is, the numbers that the participants had in the initial table. Examples Input 5 0 5 3 4 1 2 Output 2 3 4 Input 10 -10 5 5 1 7 5 1 2 4 9 2 Output 2 4 5 7 8 9 Note Consider the first test sample. 1. Initially the sequence of the contest participants' ratings equals [5, 3, 4, 1, 2]. You can use this sequence to calculate the sequence of rating changes: [0, -9, -13, 8, 14]. According to the problem statement, the application of the participant who won the second place will be considered first. 2. As soon as the second place winner is out from the ratings, the participants' rating sequence will equal [5, 4, 1, 2]. By this sequence you can count the new sequence of rating changes: [0, -8, 2, 6]. According to the problem statement, the application of the participant who won the second place will be considered. Initially this participant won third place. 3. The new rating sequence equals [5, 1, 2], the new sequence of rating changes equals [0, -1, 1]. The second place participant's application is taken into consideration, initially this participant won the fourth place. 4. The new rating sequence equals [5, 2], the new sequence of rating changes equals [0, 0]. No more applications will be considered. Thus, you should print 2, 3, 4. Submitted Solution: ``` def IO(): import sys sys.stdout = open('output.txt', 'w') sys.stdin = open('input.txt', 'r') ###################### MAIN PROGRAM ##################### def main(): #IO() n, k = map(int, input().split()) a = list(map(int, input().split())) ans = list() run = int(0) deleted = 0 for i in range(n): ratingCh = run - a[i] * (n - i - 1) * (i - deleted) if (ratingCh < k): deleted += 1 ans.append(i) else: run += a[i] * i for e in ans: print(f"{e+1} ") ##################### END OF PROGRAM #################### if __name__ == "__main__": main() ``` No
85,297
[ 0.1669921875, -0.1617431640625, -0.1416015625, 0.351806640625, -0.383544921875, -0.6142578125, -0.55078125, 0.218994140625, -0.25048828125, 0.73095703125, 0.62548828125, 0.10675048828125, 0.099609375, -0.939453125, -0.337890625, 0.1007080078125, -0.7333984375, -0.751953125, -0.39...
11
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. During the last Sereja's Codesecrof round the server crashed many times, so the round was decided to be made unrated for some participants. Let's assume that n people took part in the contest. Let's assume that the participant who got the first place has rating a1, the second place participant has rating a2, ..., the n-th place participant has rating an. Then changing the rating on the Codesecrof site is calculated by the formula <image>. After the round was over, the Codesecrof management published the participants' results table. They decided that if for a participant di < k, then the round can be considered unrated for him. But imagine the management's surprise when they found out that the participants' rating table is dynamic. In other words, when some participant is removed from the rating, he is removed from the results' table and the rating is recalculated according to the new table. And of course, all applications for exclusion from the rating are considered in view of the current table. We know that among all the applications for exclusion from the rating the first application to consider is from the participant with the best rank (the rank with the minimum number), for who di < k. We also know that the applications for exclusion from rating were submitted by all participants. Now Sereja wonders, what is the number of participants to be excluded from the contest rating, and the numbers of the participants in the original table in the order of their exclusion from the rating. Pay attention to the analysis of the first test case for a better understanding of the statement. Input The first line contains two integers n, k (1 ≤ n ≤ 2·105, - 109 ≤ k ≤ 0). The second line contains n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 109) — ratings of the participants in the initial table. Output Print the numbers of participants in the order in which they were removed from the table. Print the initial numbers of the participants, that is, the numbers that the participants had in the initial table. Examples Input 5 0 5 3 4 1 2 Output 2 3 4 Input 10 -10 5 5 1 7 5 1 2 4 9 2 Output 2 4 5 7 8 9 Note Consider the first test sample. 1. Initially the sequence of the contest participants' ratings equals [5, 3, 4, 1, 2]. You can use this sequence to calculate the sequence of rating changes: [0, -9, -13, 8, 14]. According to the problem statement, the application of the participant who won the second place will be considered first. 2. As soon as the second place winner is out from the ratings, the participants' rating sequence will equal [5, 4, 1, 2]. By this sequence you can count the new sequence of rating changes: [0, -8, 2, 6]. According to the problem statement, the application of the participant who won the second place will be considered. Initially this participant won third place. 3. The new rating sequence equals [5, 1, 2], the new sequence of rating changes equals [0, -1, 1]. The second place participant's application is taken into consideration, initially this participant won the fourth place. 4. The new rating sequence equals [5, 2], the new sequence of rating changes equals [0, 0]. No more applications will be considered. Thus, you should print 2, 3, 4. Submitted Solution: ``` n, k = map(int, input().split()) S, D, i = 0, 0, 0 ans = [] for val in map(int, input().split()): f = (n - i + 1) * val * (i - D) if S - f < k: D += 1 ans.append(i + 1) else: S += val * (i - D) i += 1 print(' '.join(map(str, ans))) ``` No
85,298
[ 0.1669921875, -0.1617431640625, -0.1416015625, 0.351806640625, -0.383544921875, -0.6142578125, -0.55078125, 0.218994140625, -0.25048828125, 0.73095703125, 0.62548828125, 0.10675048828125, 0.099609375, -0.939453125, -0.337890625, 0.1007080078125, -0.7333984375, -0.751953125, -0.39...
11