message
stringlengths
2
67k
message_type
stringclasses
2 values
message_id
int64
0
1
conversation_id
int64
463
109k
cluster
float64
19
19
__index_level_0__
int64
926
217k
Provide a correct Python 3 solution for this coding contest problem. Problem GPA is an abbreviation for "Galaxy Point of Aizu" and takes real numbers from 0 to 4. GPA rock-paper-scissors is a game played by two people. After each player gives a signal of "rock-paper-scissors, pon (hoi)" to each other's favorite move, goo, choki, or par, the person with the higher GPA becomes the winner, and the person with the lower GPA becomes the loser. If they are the same, it will be a draw. Since the GPA data of N people is given, output the points won in each round-robin battle. However, the points won will be 3 when winning, 1 when drawing, and 0 when losing. Round-robin is a system in which all participants play against participants other than themselves exactly once. Constraints The input satisfies the following conditions. * 2 ≤ N ≤ 105 * N is an integer * 0.000 ≤ ai ≤ 4.000 (1 ≤ i ≤ N) * ai is a real number (1 ≤ i ≤ N) * Each GPA is given up to 3 decimal places Input The input is given in the following format. N a1 a2 ... aN The first line is given the number of people N to play GPA rock-paper-scissors. The following N lines are given the data ai of the i-th person's GPA in one line. Output Output the points of the i-th person on the i-line on one line. (1 ≤ i ≤ N) Examples Input 3 1.000 3.000 3.000 Output 0 4 4 Input 3 1.000 2.000 3.000 Output 0 3 6
instruction
0
106,985
19
213,970
"Correct Solution: ``` from bisect import * a=[] b=[] n=int(input()) for i in range(n): g=float(input()) a.append(g) insort_left(b,g) for i in range(n): win=bisect_left(b,a[i]) lose=n-bisect_right(b,a[i]) print(3*win+(n-win-lose-1)) ```
output
1
106,985
19
213,971
Provide a correct Python 3 solution for this coding contest problem. Problem GPA is an abbreviation for "Galaxy Point of Aizu" and takes real numbers from 0 to 4. GPA rock-paper-scissors is a game played by two people. After each player gives a signal of "rock-paper-scissors, pon (hoi)" to each other's favorite move, goo, choki, or par, the person with the higher GPA becomes the winner, and the person with the lower GPA becomes the loser. If they are the same, it will be a draw. Since the GPA data of N people is given, output the points won in each round-robin battle. However, the points won will be 3 when winning, 1 when drawing, and 0 when losing. Round-robin is a system in which all participants play against participants other than themselves exactly once. Constraints The input satisfies the following conditions. * 2 ≤ N ≤ 105 * N is an integer * 0.000 ≤ ai ≤ 4.000 (1 ≤ i ≤ N) * ai is a real number (1 ≤ i ≤ N) * Each GPA is given up to 3 decimal places Input The input is given in the following format. N a1 a2 ... aN The first line is given the number of people N to play GPA rock-paper-scissors. The following N lines are given the data ai of the i-th person's GPA in one line. Output Output the points of the i-th person on the i-line on one line. (1 ≤ i ≤ N) Examples Input 3 1.000 3.000 3.000 Output 0 4 4 Input 3 1.000 2.000 3.000 Output 0 3 6
instruction
0
106,986
19
213,972
"Correct Solution: ``` import bisect n = int(input()) a = [] for i in range(n): a.append(float(input())) a2 = sorted(a) for i in a: kati = bisect.bisect_left(a2, i) hiki = bisect.bisect_right(a2, i) - kati - 1 print(kati*3 + hiki) ```
output
1
106,986
19
213,973
Provide a correct Python 3 solution for this coding contest problem. Problem GPA is an abbreviation for "Galaxy Point of Aizu" and takes real numbers from 0 to 4. GPA rock-paper-scissors is a game played by two people. After each player gives a signal of "rock-paper-scissors, pon (hoi)" to each other's favorite move, goo, choki, or par, the person with the higher GPA becomes the winner, and the person with the lower GPA becomes the loser. If they are the same, it will be a draw. Since the GPA data of N people is given, output the points won in each round-robin battle. However, the points won will be 3 when winning, 1 when drawing, and 0 when losing. Round-robin is a system in which all participants play against participants other than themselves exactly once. Constraints The input satisfies the following conditions. * 2 ≤ N ≤ 105 * N is an integer * 0.000 ≤ ai ≤ 4.000 (1 ≤ i ≤ N) * ai is a real number (1 ≤ i ≤ N) * Each GPA is given up to 3 decimal places Input The input is given in the following format. N a1 a2 ... aN The first line is given the number of people N to play GPA rock-paper-scissors. The following N lines are given the data ai of the i-th person's GPA in one line. Output Output the points of the i-th person on the i-line on one line. (1 ≤ i ≤ N) Examples Input 3 1.000 3.000 3.000 Output 0 4 4 Input 3 1.000 2.000 3.000 Output 0 3 6
instruction
0
106,987
19
213,974
"Correct Solution: ``` if __name__ == "__main__": n = input() a = [0.0] * int(n) b = [0.0] * int(n) count = {"6.909":0} for i in range(int(n)): a[i] = input() b[i] = a[i] b.sort() for i in range(int(n)-1): if float(b[i]) == float(b[i+1]): if b[i] in count: x = count[b[i]] count[b[i]] = (x + 1) else: count[b[i]] = 2 i = 0 while i < int(n): if b[i] in count: x = count[b[i]] count[b[i]] = (3 * i + x - 1) i = i + x - 1 else: count[b[i]] = (3 * i) i = i + 1 for i in range(int(n)): print (count[a[i]]) ```
output
1
106,987
19
213,975
Provide a correct Python 3 solution for this coding contest problem. Problem GPA is an abbreviation for "Galaxy Point of Aizu" and takes real numbers from 0 to 4. GPA rock-paper-scissors is a game played by two people. After each player gives a signal of "rock-paper-scissors, pon (hoi)" to each other's favorite move, goo, choki, or par, the person with the higher GPA becomes the winner, and the person with the lower GPA becomes the loser. If they are the same, it will be a draw. Since the GPA data of N people is given, output the points won in each round-robin battle. However, the points won will be 3 when winning, 1 when drawing, and 0 when losing. Round-robin is a system in which all participants play against participants other than themselves exactly once. Constraints The input satisfies the following conditions. * 2 ≤ N ≤ 105 * N is an integer * 0.000 ≤ ai ≤ 4.000 (1 ≤ i ≤ N) * ai is a real number (1 ≤ i ≤ N) * Each GPA is given up to 3 decimal places Input The input is given in the following format. N a1 a2 ... aN The first line is given the number of people N to play GPA rock-paper-scissors. The following N lines are given the data ai of the i-th person's GPA in one line. Output Output the points of the i-th person on the i-line on one line. (1 ≤ i ≤ N) Examples Input 3 1.000 3.000 3.000 Output 0 4 4 Input 3 1.000 2.000 3.000 Output 0 3 6
instruction
0
106,988
19
213,976
"Correct Solution: ``` from bisect import bisect_left as bl from bisect import bisect_right as br n = int(input()) alst = [float(input()) for _ in range(n)] sorted_alst = sorted(alst) for a in alst: li = bl(sorted_alst, a) ri = br(sorted_alst, a) print(li * 3 + (ri - li - 1)) ```
output
1
106,988
19
213,977
Provide a correct Python 3 solution for this coding contest problem. Problem GPA is an abbreviation for "Galaxy Point of Aizu" and takes real numbers from 0 to 4. GPA rock-paper-scissors is a game played by two people. After each player gives a signal of "rock-paper-scissors, pon (hoi)" to each other's favorite move, goo, choki, or par, the person with the higher GPA becomes the winner, and the person with the lower GPA becomes the loser. If they are the same, it will be a draw. Since the GPA data of N people is given, output the points won in each round-robin battle. However, the points won will be 3 when winning, 1 when drawing, and 0 when losing. Round-robin is a system in which all participants play against participants other than themselves exactly once. Constraints The input satisfies the following conditions. * 2 ≤ N ≤ 105 * N is an integer * 0.000 ≤ ai ≤ 4.000 (1 ≤ i ≤ N) * ai is a real number (1 ≤ i ≤ N) * Each GPA is given up to 3 decimal places Input The input is given in the following format. N a1 a2 ... aN The first line is given the number of people N to play GPA rock-paper-scissors. The following N lines are given the data ai of the i-th person's GPA in one line. Output Output the points of the i-th person on the i-line on one line. (1 ≤ i ≤ N) Examples Input 3 1.000 3.000 3.000 Output 0 4 4 Input 3 1.000 2.000 3.000 Output 0 3 6
instruction
0
106,989
19
213,978
"Correct Solution: ``` import bisect n = int(input()) a = [float(input()) for _ in range(n)] b = sorted(a) for i in range(n): x = bisect.bisect_left(b, a[i]) y = bisect.bisect_right(b, a[i]) print(x * 2 + y - 1) ```
output
1
106,989
19
213,979
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Problem GPA is an abbreviation for "Galaxy Point of Aizu" and takes real numbers from 0 to 4. GPA rock-paper-scissors is a game played by two people. After each player gives a signal of "rock-paper-scissors, pon (hoi)" to each other's favorite move, goo, choki, or par, the person with the higher GPA becomes the winner, and the person with the lower GPA becomes the loser. If they are the same, it will be a draw. Since the GPA data of N people is given, output the points won in each round-robin battle. However, the points won will be 3 when winning, 1 when drawing, and 0 when losing. Round-robin is a system in which all participants play against participants other than themselves exactly once. Constraints The input satisfies the following conditions. * 2 ≤ N ≤ 105 * N is an integer * 0.000 ≤ ai ≤ 4.000 (1 ≤ i ≤ N) * ai is a real number (1 ≤ i ≤ N) * Each GPA is given up to 3 decimal places Input The input is given in the following format. N a1 a2 ... aN The first line is given the number of people N to play GPA rock-paper-scissors. The following N lines are given the data ai of the i-th person's GPA in one line. Output Output the points of the i-th person on the i-line on one line. (1 ≤ i ≤ N) Examples Input 3 1.000 3.000 3.000 Output 0 4 4 Input 3 1.000 2.000 3.000 Output 0 3 6 Submitted Solution: ``` n = int(input()) a = [float(input()) for _ in range(n)] b = sorted(a) for i in range(n): print(b.index(a[i]) * 3 + b.count(a[i]) - 1) ```
instruction
0
106,990
19
213,980
No
output
1
106,990
19
213,981
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Problem GPA is an abbreviation for "Galaxy Point of Aizu" and takes real numbers from 0 to 4. GPA rock-paper-scissors is a game played by two people. After each player gives a signal of "rock-paper-scissors, pon (hoi)" to each other's favorite move, goo, choki, or par, the person with the higher GPA becomes the winner, and the person with the lower GPA becomes the loser. If they are the same, it will be a draw. Since the GPA data of N people is given, output the points won in each round-robin battle. However, the points won will be 3 when winning, 1 when drawing, and 0 when losing. Round-robin is a system in which all participants play against participants other than themselves exactly once. Constraints The input satisfies the following conditions. * 2 ≤ N ≤ 105 * N is an integer * 0.000 ≤ ai ≤ 4.000 (1 ≤ i ≤ N) * ai is a real number (1 ≤ i ≤ N) * Each GPA is given up to 3 decimal places Input The input is given in the following format. N a1 a2 ... aN The first line is given the number of people N to play GPA rock-paper-scissors. The following N lines are given the data ai of the i-th person's GPA in one line. Output Output the points of the i-th person on the i-line on one line. (1 ≤ i ≤ N) Examples Input 3 1.000 3.000 3.000 Output 0 4 4 Input 3 1.000 2.000 3.000 Output 0 3 6 Submitted Solution: ``` n = int(input()) grade = [[] for i in range(4001)] for i in range(n): gpa = float(input()) grade[(int(gpa*1000))].append(i) win = 0 point = [0]*n for elm in grade: tie = len(elm) for p in elm: point[p] = win+tie-1 win += 3*tie for p in point: print(p) ```
instruction
0
106,991
19
213,982
No
output
1
106,991
19
213,983
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Problem GPA is an abbreviation for "Galaxy Point of Aizu" and takes real numbers from 0 to 4. GPA rock-paper-scissors is a game played by two people. After each player gives a signal of "rock-paper-scissors, pon (hoi)" to each other's favorite move, goo, choki, or par, the person with the higher GPA becomes the winner, and the person with the lower GPA becomes the loser. If they are the same, it will be a draw. Since the GPA data of N people is given, output the points won in each round-robin battle. However, the points won will be 3 when winning, 1 when drawing, and 0 when losing. Round-robin is a system in which all participants play against participants other than themselves exactly once. Constraints The input satisfies the following conditions. * 2 ≤ N ≤ 105 * N is an integer * 0.000 ≤ ai ≤ 4.000 (1 ≤ i ≤ N) * ai is a real number (1 ≤ i ≤ N) * Each GPA is given up to 3 decimal places Input The input is given in the following format. N a1 a2 ... aN The first line is given the number of people N to play GPA rock-paper-scissors. The following N lines are given the data ai of the i-th person's GPA in one line. Output Output the points of the i-th person on the i-line on one line. (1 ≤ i ≤ N) Examples Input 3 1.000 3.000 3.000 Output 0 4 4 Input 3 1.000 2.000 3.000 Output 0 3 6 Submitted Solution: ``` n= int(input()) lis = [[float(input()), i] for i in range(n)] lis.sort(key = lambda x: x[0]) ans = [[0,lis[0][1]] for i in range(n)] i = 1 while i < n: if lis[i][0] != lis[i-1][0]: ans[i][0] += (ans[i-1][0] + 3) ans[i][1] = lis[i][1] else: k = ans[i-1][0] v = i-1 while i < n: if lis[i][0] != lis[v][0]: break i += 1 i -= 1 ans[v][0] += (i-v) for j in range(v,i+1): ans[j][0] = ans[v][0] ans[j][1] = lis[j][1] i += 1 ans.sort(key = lambda x: x[1]) for i in ans: print(i[0]) ```
instruction
0
106,992
19
213,984
No
output
1
106,992
19
213,985
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Problem GPA is an abbreviation for "Galaxy Point of Aizu" and takes real numbers from 0 to 4. GPA rock-paper-scissors is a game played by two people. After each player gives a signal of "rock-paper-scissors, pon (hoi)" to each other's favorite move, goo, choki, or par, the person with the higher GPA becomes the winner, and the person with the lower GPA becomes the loser. If they are the same, it will be a draw. Since the GPA data of N people is given, output the points won in each round-robin battle. However, the points won will be 3 when winning, 1 when drawing, and 0 when losing. Round-robin is a system in which all participants play against participants other than themselves exactly once. Constraints The input satisfies the following conditions. * 2 ≤ N ≤ 105 * N is an integer * 0.000 ≤ ai ≤ 4.000 (1 ≤ i ≤ N) * ai is a real number (1 ≤ i ≤ N) * Each GPA is given up to 3 decimal places Input The input is given in the following format. N a1 a2 ... aN The first line is given the number of people N to play GPA rock-paper-scissors. The following N lines are given the data ai of the i-th person's GPA in one line. Output Output the points of the i-th person on the i-line on one line. (1 ≤ i ≤ N) Examples Input 3 1.000 3.000 3.000 Output 0 4 4 Input 3 1.000 2.000 3.000 Output 0 3 6 Submitted Solution: ``` n = int(input()) a = [float(input()) for _ in range(n)] p = [0] * n for i in range(n): for j in range(i + 1, n): if a[i] > a[j]: p[i] += 3 elif a[i] == a[j]: p[i] += 1 p[j] += 1 else: p[j] += 3 for i in p: print(i) ```
instruction
0
106,993
19
213,986
No
output
1
106,993
19
213,987
Provide a correct Python 3 solution for this coding contest problem. Write a program to simulate rolling a dice, which can be constructed by the following net. <image> <image> As shown in the figures, each face is identified by a different label from 1 to 6. Write a program which reads integers assigned to each face identified by the label and a sequence of commands to roll the dice, and prints the integer on the top face. At the initial state, the dice is located as shown in the above figures. Constraints * $0 \leq $ the integer assigned to a face $ \leq 100$ * $0 \leq $ the length of the command $\leq 100$ Input In the first line, six integers assigned to faces are given in ascending order of their corresponding labels. In the second line, a string which represents a sequence of commands, is given. The command is one of 'E', 'N', 'S' and 'W' representing four directions shown in the above figures. Output Print the integer which appears on the top face after the simulation. Examples Input 1 2 4 8 16 32 SE Output 8 Input 1 2 4 8 16 32 EESWN Output 32
instruction
0
107,010
19
214,020
"Correct Solution: ``` # coding : utf-8 class Dice: def __init__(self, label): self.d = label def north(self): d = self.d self.d = [d[1],d[5],d[2],d[3],d[0],d[4]] def east(self): d = self.d self.d = [d[3],d[1],d[0],d[5],d[4],d[2]] def west(self): d = self.d self.d = [d[2],d[1],d[5],d[0],d[4],d[3]] def south(self): d = self.d self.d = [d[4],d[0],d[2],d[3],d[5],d[1]] def output(self): d = self.d print(self.d[0]) label = list(map(int, input().split())) op_list = list(input()) d0 = Dice(label) for op in op_list: if op =='N': d0.north() if op =='E': d0.east() if op =='W': d0.west() if op =='S': d0.south() d0.output() ```
output
1
107,010
19
214,021
Provide a correct Python 3 solution for this coding contest problem. Write a program to simulate rolling a dice, which can be constructed by the following net. <image> <image> As shown in the figures, each face is identified by a different label from 1 to 6. Write a program which reads integers assigned to each face identified by the label and a sequence of commands to roll the dice, and prints the integer on the top face. At the initial state, the dice is located as shown in the above figures. Constraints * $0 \leq $ the integer assigned to a face $ \leq 100$ * $0 \leq $ the length of the command $\leq 100$ Input In the first line, six integers assigned to faces are given in ascending order of their corresponding labels. In the second line, a string which represents a sequence of commands, is given. The command is one of 'E', 'N', 'S' and 'W' representing four directions shown in the above figures. Output Print the integer which appears on the top face after the simulation. Examples Input 1 2 4 8 16 32 SE Output 8 Input 1 2 4 8 16 32 EESWN Output 32
instruction
0
107,011
19
214,022
"Correct Solution: ``` class Dise(): def __init__(self, aLabelList): self.LabelList = aLabelList self.NEWS = {"N": [0,4,5,1], "E": [0,2,5,3], "W": [0,3,5,2], "S": [0,1,5,4]} def move(self,aNEWS): idx = self.NEWS[aNEWS] tmp = self.LabelList[idx[0]] self.LabelList[idx[0]] = self.LabelList[idx[3]] self.LabelList[idx[3]] = self.LabelList[idx[2]] self.LabelList[idx[2]] = self.LabelList[idx[1]] self.LabelList[idx[1]] = tmp def DisePrint(self): print(self.LabelList[0]) myInstance = Dise(input().split()) x = input() for i in range(len(x)): myInstance.move(x[i:i+1]) myInstance.DisePrint() ```
output
1
107,011
19
214,023
Provide a correct Python 3 solution for this coding contest problem. Write a program to simulate rolling a dice, which can be constructed by the following net. <image> <image> As shown in the figures, each face is identified by a different label from 1 to 6. Write a program which reads integers assigned to each face identified by the label and a sequence of commands to roll the dice, and prints the integer on the top face. At the initial state, the dice is located as shown in the above figures. Constraints * $0 \leq $ the integer assigned to a face $ \leq 100$ * $0 \leq $ the length of the command $\leq 100$ Input In the first line, six integers assigned to faces are given in ascending order of their corresponding labels. In the second line, a string which represents a sequence of commands, is given. The command is one of 'E', 'N', 'S' and 'W' representing four directions shown in the above figures. Output Print the integer which appears on the top face after the simulation. Examples Input 1 2 4 8 16 32 SE Output 8 Input 1 2 4 8 16 32 EESWN Output 32
instruction
0
107,012
19
214,024
"Correct Solution: ``` # ['表面', '南面', '東面', '西面', '北面', '裏面'] dice = input().split() com = [c for c in input()] rolling = { 'E': [3, 1, 0, 5, 4, 2], 'W': [2, 1, 5, 0, 4, 3], 'S': [4, 0, 2, 3, 5, 1], 'N': [1, 5, 2, 3, 0, 4] } for c in com: dice = [dice[i] for i in rolling[c]] print(dice[0]) ```
output
1
107,012
19
214,025
Provide a correct Python 3 solution for this coding contest problem. Write a program to simulate rolling a dice, which can be constructed by the following net. <image> <image> As shown in the figures, each face is identified by a different label from 1 to 6. Write a program which reads integers assigned to each face identified by the label and a sequence of commands to roll the dice, and prints the integer on the top face. At the initial state, the dice is located as shown in the above figures. Constraints * $0 \leq $ the integer assigned to a face $ \leq 100$ * $0 \leq $ the length of the command $\leq 100$ Input In the first line, six integers assigned to faces are given in ascending order of their corresponding labels. In the second line, a string which represents a sequence of commands, is given. The command is one of 'E', 'N', 'S' and 'W' representing four directions shown in the above figures. Output Print the integer which appears on the top face after the simulation. Examples Input 1 2 4 8 16 32 SE Output 8 Input 1 2 4 8 16 32 EESWN Output 32
instruction
0
107,013
19
214,026
"Correct Solution: ``` d = [_ for _ in input().split()] commands = input() for c in commands: if c == 'E': d[0], d[2], d[3], d[5] = d[3], d[0], d[5], d[2] elif c == 'W': d[0], d[2], d[3], d[5] = d[2], d[5], d[0], d[3] elif c == 'N': d[0], d[1], d[4], d[5] = d[1], d[5], d[0], d[4] elif c == 'S': d[0], d[1], d[4], d[5] = d[4], d[0], d[5], d[1] print(d[0]) ```
output
1
107,013
19
214,027
Provide a correct Python 3 solution for this coding contest problem. Write a program to simulate rolling a dice, which can be constructed by the following net. <image> <image> As shown in the figures, each face is identified by a different label from 1 to 6. Write a program which reads integers assigned to each face identified by the label and a sequence of commands to roll the dice, and prints the integer on the top face. At the initial state, the dice is located as shown in the above figures. Constraints * $0 \leq $ the integer assigned to a face $ \leq 100$ * $0 \leq $ the length of the command $\leq 100$ Input In the first line, six integers assigned to faces are given in ascending order of their corresponding labels. In the second line, a string which represents a sequence of commands, is given. The command is one of 'E', 'N', 'S' and 'W' representing four directions shown in the above figures. Output Print the integer which appears on the top face after the simulation. Examples Input 1 2 4 8 16 32 SE Output 8 Input 1 2 4 8 16 32 EESWN Output 32
instruction
0
107,014
19
214,028
"Correct Solution: ``` d=list(map(int,input().split())) o=str(input()) for i in o: if i=='N': d[0],d[1],d[4],d[5]=d[1],d[5],d[0],d[4] elif i=='S': d[0],d[1],d[4],d[5]=d[4],d[0],d[5],d[1] elif i=='E': d[0],d[2],d[3],d[5]=d[3],d[0],d[5],d[2] elif i=='W': d[0],d[2],d[3],d[5]=d[2],d[5],d[0],d[3] print(int(d[0])) ```
output
1
107,014
19
214,029
Provide a correct Python 3 solution for this coding contest problem. Write a program to simulate rolling a dice, which can be constructed by the following net. <image> <image> As shown in the figures, each face is identified by a different label from 1 to 6. Write a program which reads integers assigned to each face identified by the label and a sequence of commands to roll the dice, and prints the integer on the top face. At the initial state, the dice is located as shown in the above figures. Constraints * $0 \leq $ the integer assigned to a face $ \leq 100$ * $0 \leq $ the length of the command $\leq 100$ Input In the first line, six integers assigned to faces are given in ascending order of their corresponding labels. In the second line, a string which represents a sequence of commands, is given. The command is one of 'E', 'N', 'S' and 'W' representing four directions shown in the above figures. Output Print the integer which appears on the top face after the simulation. Examples Input 1 2 4 8 16 32 SE Output 8 Input 1 2 4 8 16 32 EESWN Output 32
instruction
0
107,015
19
214,030
"Correct Solution: ``` a1,a2,a3,a4,a5,a6=map(int,input().split()) s=input() for i in s: if i=="E": a1,a2,a3,a4,a5,a6=a4,a2,a1,a6,a5,a3 elif i=="S": a1,a2,a3,a4,a5,a6=a5,a1,a3,a4,a6,a2 elif i=="W": a1,a2,a3,a4,a5,a6=a3,a2,a6,a1,a5,a4 elif i=="N": a1,a2,a3,a4,a5,a6=a2,a6,a3,a4,a1,a5 print(a1) ```
output
1
107,015
19
214,031
Provide a correct Python 3 solution for this coding contest problem. Write a program to simulate rolling a dice, which can be constructed by the following net. <image> <image> As shown in the figures, each face is identified by a different label from 1 to 6. Write a program which reads integers assigned to each face identified by the label and a sequence of commands to roll the dice, and prints the integer on the top face. At the initial state, the dice is located as shown in the above figures. Constraints * $0 \leq $ the integer assigned to a face $ \leq 100$ * $0 \leq $ the length of the command $\leq 100$ Input In the first line, six integers assigned to faces are given in ascending order of their corresponding labels. In the second line, a string which represents a sequence of commands, is given. The command is one of 'E', 'N', 'S' and 'W' representing four directions shown in the above figures. Output Print the integer which appears on the top face after the simulation. Examples Input 1 2 4 8 16 32 SE Output 8 Input 1 2 4 8 16 32 EESWN Output 32
instruction
0
107,016
19
214,032
"Correct Solution: ``` dice = list(input().split(' ')) a = list(input()) for i in a: if i == 'W': dice = [dice[2],dice[1],dice[5],dice[0],dice[4],dice[3]] elif i == 'S': dice = [dice[4],dice[0],dice[2],dice[3],dice[5],dice[1]] elif i == 'N': dice = [dice[1],dice[5],dice[2],dice[3],dice[0],dice[4]] elif i == 'E': dice = [dice[3],dice[1],dice[0],dice[5],dice[4],dice[2]] print(dice[0]) ```
output
1
107,016
19
214,033
Provide a correct Python 3 solution for this coding contest problem. Write a program to simulate rolling a dice, which can be constructed by the following net. <image> <image> As shown in the figures, each face is identified by a different label from 1 to 6. Write a program which reads integers assigned to each face identified by the label and a sequence of commands to roll the dice, and prints the integer on the top face. At the initial state, the dice is located as shown in the above figures. Constraints * $0 \leq $ the integer assigned to a face $ \leq 100$ * $0 \leq $ the length of the command $\leq 100$ Input In the first line, six integers assigned to faces are given in ascending order of their corresponding labels. In the second line, a string which represents a sequence of commands, is given. The command is one of 'E', 'N', 'S' and 'W' representing four directions shown in the above figures. Output Print the integer which appears on the top face after the simulation. Examples Input 1 2 4 8 16 32 SE Output 8 Input 1 2 4 8 16 32 EESWN Output 32
instruction
0
107,017
19
214,034
"Correct Solution: ``` def swap(dice,i,j,k,l):#diceの目をi→j→k→l→iの順に入れ替える x=dice[l] dice[l]=dice[k] dice[k]=dice[j] dice[j]=dice[i] dice[i]=x return dice dice=list(map(int,input().split())) Dice=[0] dice=Dice +dice roll=list(input()) for i in range(0,len(roll)): if(roll[i]=="S"): dice=swap(dice,1,2,6,5) elif(roll[i]=="E"): dice=swap(dice,1,3,6,4) elif(roll[i]=="W"): dice=swap(dice,1,4,6,3) elif(roll[i]=="N"): dice=swap(dice,1,5,6,2) print(dice[1]) ```
output
1
107,017
19
214,035
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Write a program to simulate rolling a dice, which can be constructed by the following net. <image> <image> As shown in the figures, each face is identified by a different label from 1 to 6. Write a program which reads integers assigned to each face identified by the label and a sequence of commands to roll the dice, and prints the integer on the top face. At the initial state, the dice is located as shown in the above figures. Constraints * $0 \leq $ the integer assigned to a face $ \leq 100$ * $0 \leq $ the length of the command $\leq 100$ Input In the first line, six integers assigned to faces are given in ascending order of their corresponding labels. In the second line, a string which represents a sequence of commands, is given. The command is one of 'E', 'N', 'S' and 'W' representing four directions shown in the above figures. Output Print the integer which appears on the top face after the simulation. Examples Input 1 2 4 8 16 32 SE Output 8 Input 1 2 4 8 16 32 EESWN Output 32 Submitted Solution: ``` initial=list( map(int,input().split())) change=initial def East(a,b,c,d,e,f): return [d, b, a, f, e, c] def West(a,b,c,d,e,f): return [c, b, f, a, e, d] def South(a,b,c,d,e,f): return [e, a, c, d, f, b] def North(a,b,c,d,e,f): return [b, f, c, d, a, e] a=input() for idx in range(0, len(a)): if a[idx]=="E": change=East(*change) elif a[idx]=="W": change=West(*change) elif a[idx]=="S": change=South(*change) elif a[idx]=="N": change=North(*change) print(change[0]) ```
instruction
0
107,018
19
214,036
Yes
output
1
107,018
19
214,037
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Write a program to simulate rolling a dice, which can be constructed by the following net. <image> <image> As shown in the figures, each face is identified by a different label from 1 to 6. Write a program which reads integers assigned to each face identified by the label and a sequence of commands to roll the dice, and prints the integer on the top face. At the initial state, the dice is located as shown in the above figures. Constraints * $0 \leq $ the integer assigned to a face $ \leq 100$ * $0 \leq $ the length of the command $\leq 100$ Input In the first line, six integers assigned to faces are given in ascending order of their corresponding labels. In the second line, a string which represents a sequence of commands, is given. The command is one of 'E', 'N', 'S' and 'W' representing four directions shown in the above figures. Output Print the integer which appears on the top face after the simulation. Examples Input 1 2 4 8 16 32 SE Output 8 Input 1 2 4 8 16 32 EESWN Output 32 Submitted Solution: ``` def rotate(l, d): if d == 'S': return [l[4], l[0], l[2], l[3], l[5], l[1]] if d == 'N': return [l[1], l[5], l[2], l[3], l[0], l[4]] if d == 'W': return [l[2], l[1], l[5], l[0], l[4], l[3]] if d == 'E': return [l[3], l[1], l[0], l[5], l[4], l[2]] l = list(map(int, input().split())) for c in input(): l = rotate(l, c) print(l[0]) ```
instruction
0
107,019
19
214,038
Yes
output
1
107,019
19
214,039
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Write a program to simulate rolling a dice, which can be constructed by the following net. <image> <image> As shown in the figures, each face is identified by a different label from 1 to 6. Write a program which reads integers assigned to each face identified by the label and a sequence of commands to roll the dice, and prints the integer on the top face. At the initial state, the dice is located as shown in the above figures. Constraints * $0 \leq $ the integer assigned to a face $ \leq 100$ * $0 \leq $ the length of the command $\leq 100$ Input In the first line, six integers assigned to faces are given in ascending order of their corresponding labels. In the second line, a string which represents a sequence of commands, is given. The command is one of 'E', 'N', 'S' and 'W' representing four directions shown in the above figures. Output Print the integer which appears on the top face after the simulation. Examples Input 1 2 4 8 16 32 SE Output 8 Input 1 2 4 8 16 32 EESWN Output 32 Submitted Solution: ``` dice = [int(e) for e in input().split()] roll = input() for roll1 in roll: if roll1 == "N": dice = [dice[1],dice[5],dice[2],dice[3],dice[0],dice[4]] elif roll1 == "W": dice = [dice[2],dice[1],dice[5],dice[0],dice[4],dice[3]] elif roll1 == "E": dice = [dice[3],dice[1],dice[0],dice[5],dice[4],dice[2]] elif roll1 == "S": dice = [dice[4],dice[0],dice[2],dice[3],dice[5],dice[1]] print(dice[0]) ```
instruction
0
107,020
19
214,040
Yes
output
1
107,020
19
214,041
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Write a program to simulate rolling a dice, which can be constructed by the following net. <image> <image> As shown in the figures, each face is identified by a different label from 1 to 6. Write a program which reads integers assigned to each face identified by the label and a sequence of commands to roll the dice, and prints the integer on the top face. At the initial state, the dice is located as shown in the above figures. Constraints * $0 \leq $ the integer assigned to a face $ \leq 100$ * $0 \leq $ the length of the command $\leq 100$ Input In the first line, six integers assigned to faces are given in ascending order of their corresponding labels. In the second line, a string which represents a sequence of commands, is given. The command is one of 'E', 'N', 'S' and 'W' representing four directions shown in the above figures. Output Print the integer which appears on the top face after the simulation. Examples Input 1 2 4 8 16 32 SE Output 8 Input 1 2 4 8 16 32 EESWN Output 32 Submitted Solution: ``` u, s, e, w, n, d = input().split() t = input() for i in t: if i == 'N': u, s, n, d = s, d, u, n elif i == 'E': u, e, w, d = w, u, d, e elif i == 'S': u, s, n, d = n, u, d, s elif i == 'W': u, e, w, d = e, d, u, w print(u) ```
instruction
0
107,021
19
214,042
Yes
output
1
107,021
19
214,043
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Write a program to simulate rolling a dice, which can be constructed by the following net. <image> <image> As shown in the figures, each face is identified by a different label from 1 to 6. Write a program which reads integers assigned to each face identified by the label and a sequence of commands to roll the dice, and prints the integer on the top face. At the initial state, the dice is located as shown in the above figures. Constraints * $0 \leq $ the integer assigned to a face $ \leq 100$ * $0 \leq $ the length of the command $\leq 100$ Input In the first line, six integers assigned to faces are given in ascending order of their corresponding labels. In the second line, a string which represents a sequence of commands, is given. The command is one of 'E', 'N', 'S' and 'W' representing four directions shown in the above figures. Output Print the integer which appears on the top face after the simulation. Examples Input 1 2 4 8 16 32 SE Output 8 Input 1 2 4 8 16 32 EESWN Output 32 Submitted Solution: ``` #!/usr/bin/env python faces = list(map(int, input().split())) print(faces) command = list(input()) print(command) def dice(face, command): face_1 = {"E": 4, "W": 3, "S": 5, "N": 2} face_2 = {"E": 4, "W": 3, "S": 1, "N": 6} face_3 = {"E": 2, "W": 5, "S": 1, "N": 6} face_4 = {"E": 5, "W": 2, "S": 1, "N": 6} face_5 = {"E": 4, "W": 3, "S": 6, "N": 1} face_6 = {"E": 4, "W": 3, "S": 2, "N": 1} rulebase = [face_1, face_2, face_3, face_4, face_5, face_6] return rulebase[face - 1][command] top = 1 for c in command: top = dice(top, c) print(top) print(faces[top - 1]) ```
instruction
0
107,022
19
214,044
No
output
1
107,022
19
214,045
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Write a program to simulate rolling a dice, which can be constructed by the following net. <image> <image> As shown in the figures, each face is identified by a different label from 1 to 6. Write a program which reads integers assigned to each face identified by the label and a sequence of commands to roll the dice, and prints the integer on the top face. At the initial state, the dice is located as shown in the above figures. Constraints * $0 \leq $ the integer assigned to a face $ \leq 100$ * $0 \leq $ the length of the command $\leq 100$ Input In the first line, six integers assigned to faces are given in ascending order of their corresponding labels. In the second line, a string which represents a sequence of commands, is given. The command is one of 'E', 'N', 'S' and 'W' representing four directions shown in the above figures. Output Print the integer which appears on the top face after the simulation. Examples Input 1 2 4 8 16 32 SE Output 8 Input 1 2 4 8 16 32 EESWN Output 32 Submitted Solution: ``` import sys data=list(map(int,input().split())) order=sys.stdin.readline() char_list=list(order) for i in char_list: if i=='N': print(i) k=data[1] m=data[5] data[0]=data[1] data[1]=data[5] data[4]=k data[5]=m elif i=='E': k=data[0] m=data[2] data[0]=data[3] data[2]=k data[3]=data[5] data[5]=m elif i=='S': k=data[0] m=data[1] data[0]=data[4] data[1]=k data[4]=data[5] data[5]=m elif i=='W': k=data[0] m=data[3] data[0]=data[2] data[3]=data[5] data[4]=k data[5]=m print(data[0]) ```
instruction
0
107,023
19
214,046
No
output
1
107,023
19
214,047
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Write a program to simulate rolling a dice, which can be constructed by the following net. <image> <image> As shown in the figures, each face is identified by a different label from 1 to 6. Write a program which reads integers assigned to each face identified by the label and a sequence of commands to roll the dice, and prints the integer on the top face. At the initial state, the dice is located as shown in the above figures. Constraints * $0 \leq $ the integer assigned to a face $ \leq 100$ * $0 \leq $ the length of the command $\leq 100$ Input In the first line, six integers assigned to faces are given in ascending order of their corresponding labels. In the second line, a string which represents a sequence of commands, is given. The command is one of 'E', 'N', 'S' and 'W' representing four directions shown in the above figures. Output Print the integer which appears on the top face after the simulation. Examples Input 1 2 4 8 16 32 SE Output 8 Input 1 2 4 8 16 32 EESWN Output 32 Submitted Solution: ``` l = list(map(int, input().split())) s = input() for c in s: if c == "S": l = [l[4], l[0], l[2], l[3], l[1], l[5]] elif c == "N": l = [l[1], l[5], l[2], l[3], l[4], l[0]] elif c == "E": l = [l[3], l[1], l[0], l[5], l[4], l[2]] else: l = [l[2], l[1], l[5], l[0], l[4], l[3]] print(l[0]) ```
instruction
0
107,024
19
214,048
No
output
1
107,024
19
214,049
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Write a program to simulate rolling a dice, which can be constructed by the following net. <image> <image> As shown in the figures, each face is identified by a different label from 1 to 6. Write a program which reads integers assigned to each face identified by the label and a sequence of commands to roll the dice, and prints the integer on the top face. At the initial state, the dice is located as shown in the above figures. Constraints * $0 \leq $ the integer assigned to a face $ \leq 100$ * $0 \leq $ the length of the command $\leq 100$ Input In the first line, six integers assigned to faces are given in ascending order of their corresponding labels. In the second line, a string which represents a sequence of commands, is given. The command is one of 'E', 'N', 'S' and 'W' representing four directions shown in the above figures. Output Print the integer which appears on the top face after the simulation. Examples Input 1 2 4 8 16 32 SE Output 8 Input 1 2 4 8 16 32 EESWN Output 32 Submitted Solution: ``` def __init__ (self,data): self.data = data class Dice: def move(self,direction): if direction == 'E': self.data[0],self.data[3],self.data[5],self.data[2] = \ self.data[3],self.data[5],self.data[2],self.data[0] elif direction == 'N': self.data[0],self.data[4],self.data[5],self.data[1] = \ self.data[4],elf.data[5],self.data[1],self.data[0] elif direction == 'S': self.data[0],self.data[1],self.data[5],self.data[4] = \ self.data[4],self.data[0],self.data[1],self.data[5] elif direction == 'W': self.data[0],self.data[2],self.data[5],self.data[3] = \ self.data[2],self.data[5],self.data[3],self.data[0] def getTop(self): return self.data[0] dice = Dice(input().split()) cmd = input() for i in range(len(cmd)): dice.move(cmd[i]) print(dice.getTop()) ```
instruction
0
107,025
19
214,050
No
output
1
107,025
19
214,051
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. The "Bulls and Cows" game needs two people to play. The thinker thinks of a number and the guesser tries to guess it. The thinker thinks of a four-digit number in the decimal system. All the digits in the number are different and the number may have a leading zero. It can't have more than one leading zero, because all it's digits should be different. The guesser tries to guess the number. He makes a series of guesses, trying experimental numbers and receives answers from the first person in the format "x bulls y cows". x represents the number of digits in the experimental number that occupy the same positions as in the sought number. y represents the number of digits of the experimental number that present in the sought number, but occupy different positions. Naturally, the experimental numbers, as well as the sought number, are represented by four-digit numbers where all digits are different and a leading zero can be present. For example, let's suppose that the thinker thought of the number 0123. Then the guessers' experimental number 1263 will receive a reply "1 bull 2 cows" (3 occupies the same positions in both numbers and 1 and 2 are present in both numbers but they occupy different positions). Also, the answer to number 8103 will be "2 bulls 1 cow" (analogically, 1 and 3 occupy the same positions and 0 occupies a different one). When the guesser is answered "4 bulls 0 cows", the game is over. Now the guesser has already made several guesses and wants to know whether his next guess can possibly be the last one. Input The first input line contains an integer n (1 ≤ n ≤ 10) which represents the number of already made guesses. Then follow n lines in the form of "ai bi ci", where ai is the i-th experimental number, bi is the number of bulls, ci is the number of cows (1 ≤ i ≤ n, 0 ≤ bi, ci, bi + ci ≤ 4). The experimental numbers are correct, i.e., each of them contains exactly four digits, in each of them all the four digits are different, and there can be a leading zero. All the experimental numbers are different. As the guesser hasn't guessed the number yet, the answer "4 bulls 0 cows" is not present. Output If the input data is enough to determine the sought number, print the number with four digits on a single line. If it has less than four digits, add leading zero. If the data is not enough, print "Need more data" without the quotes. If the thinker happens to have made a mistake in his replies, print "Incorrect data" without the quotes. Examples Input 2 1263 1 2 8103 2 1 Output Need more data Input 2 1234 2 2 1256 0 2 Output 2134 Input 2 0123 1 1 4567 1 2 Output Incorrect data Submitted Solution: ``` import sys from array import array # noqa: F401 from itertools import product def input(): return sys.stdin.buffer.readline().decode('utf-8') n = int(input()) cand = set() for i, (a, b, c) in enumerate(input().split() for _ in range(n)): a = list(map(int, a)) b, c = int(b), int(c) s = set() for p in product(range(10), repeat=4): if len(set(p)) < 4: continue b_, c_ = 0, 0 for j in range(4): if p[j] == a[j]: b_ += 1 elif p[j] in a: c_ += 1 if b == b_ and c == c_: s.add(''.join(map(str, p))) if i == 0: cand = s else: cand &= s if len(cand) == 1: print(cand.pop()) elif len(cand) > 1: print('Need more data') elif not cand: print('Incorrect data') else: assert False ```
instruction
0
107,431
19
214,862
Yes
output
1
107,431
19
214,863
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. The "Bulls and Cows" game needs two people to play. The thinker thinks of a number and the guesser tries to guess it. The thinker thinks of a four-digit number in the decimal system. All the digits in the number are different and the number may have a leading zero. It can't have more than one leading zero, because all it's digits should be different. The guesser tries to guess the number. He makes a series of guesses, trying experimental numbers and receives answers from the first person in the format "x bulls y cows". x represents the number of digits in the experimental number that occupy the same positions as in the sought number. y represents the number of digits of the experimental number that present in the sought number, but occupy different positions. Naturally, the experimental numbers, as well as the sought number, are represented by four-digit numbers where all digits are different and a leading zero can be present. For example, let's suppose that the thinker thought of the number 0123. Then the guessers' experimental number 1263 will receive a reply "1 bull 2 cows" (3 occupies the same positions in both numbers and 1 and 2 are present in both numbers but they occupy different positions). Also, the answer to number 8103 will be "2 bulls 1 cow" (analogically, 1 and 3 occupy the same positions and 0 occupies a different one). When the guesser is answered "4 bulls 0 cows", the game is over. Now the guesser has already made several guesses and wants to know whether his next guess can possibly be the last one. Input The first input line contains an integer n (1 ≤ n ≤ 10) which represents the number of already made guesses. Then follow n lines in the form of "ai bi ci", where ai is the i-th experimental number, bi is the number of bulls, ci is the number of cows (1 ≤ i ≤ n, 0 ≤ bi, ci, bi + ci ≤ 4). The experimental numbers are correct, i.e., each of them contains exactly four digits, in each of them all the four digits are different, and there can be a leading zero. All the experimental numbers are different. As the guesser hasn't guessed the number yet, the answer "4 bulls 0 cows" is not present. Output If the input data is enough to determine the sought number, print the number with four digits on a single line. If it has less than four digits, add leading zero. If the data is not enough, print "Need more data" without the quotes. If the thinker happens to have made a mistake in his replies, print "Incorrect data" without the quotes. Examples Input 2 1263 1 2 8103 2 1 Output Need more data Input 2 1234 2 2 1256 0 2 Output 2134 Input 2 0123 1 1 4567 1 2 Output Incorrect data Submitted Solution: ``` '''input 8 7954 0 1 5638 0 1 8204 0 2 8293 1 1 3598 0 1 0894 0 1 6324 1 2 0572 0 1 ''' from sys import stdin, setrecursionlimit import math from collections import defaultdict, deque import time from itertools import combinations, permutations from copy import deepcopy setrecursionlimit(15000) def take_intersection(): pass def discover_digits(guess): myset = {1, 2, 3, 4, 5, 6, 7, 8, 9, 0} flag = 0 count = 0 final = [] comb = permutations(myset, 4) for i in comb: ans = get_answer(guess, list(i)) if len(ans) == 4: count += 1 final.append(ans) flag = 1 if count == 1: for i in final[0]: print(i, end = '') elif count > 1: print("Need more data") if flag == 0: print("Incorrect data") def check(arr, guess, index): first = 0 total = 0 second = 0 for i in range(4): if arr[i] == int(guess[index][0][i]): first += 1 if str(arr[i]) in guess[index][0]: total += 1 second = total - first if first == int(guess[index][1]) and second == int(guess[index][2]): return True else: return False def get_answer(guess, answer): flag = 0 ans = [] for j in range(len(guess)): num = guess[j][0] if check(answer, guess, j): pass else: break else: ans = answer return ans # main starts n = int(stdin.readline().strip()) guess = [] for _ in range(n): guess.append(list(map(str, stdin.readline().split()))) # getting ready final list final = [] base = set() discover_digits(guess) ```
instruction
0
107,432
19
214,864
Yes
output
1
107,432
19
214,865
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. The "Bulls and Cows" game needs two people to play. The thinker thinks of a number and the guesser tries to guess it. The thinker thinks of a four-digit number in the decimal system. All the digits in the number are different and the number may have a leading zero. It can't have more than one leading zero, because all it's digits should be different. The guesser tries to guess the number. He makes a series of guesses, trying experimental numbers and receives answers from the first person in the format "x bulls y cows". x represents the number of digits in the experimental number that occupy the same positions as in the sought number. y represents the number of digits of the experimental number that present in the sought number, but occupy different positions. Naturally, the experimental numbers, as well as the sought number, are represented by four-digit numbers where all digits are different and a leading zero can be present. For example, let's suppose that the thinker thought of the number 0123. Then the guessers' experimental number 1263 will receive a reply "1 bull 2 cows" (3 occupies the same positions in both numbers and 1 and 2 are present in both numbers but they occupy different positions). Also, the answer to number 8103 will be "2 bulls 1 cow" (analogically, 1 and 3 occupy the same positions and 0 occupies a different one). When the guesser is answered "4 bulls 0 cows", the game is over. Now the guesser has already made several guesses and wants to know whether his next guess can possibly be the last one. Input The first input line contains an integer n (1 ≤ n ≤ 10) which represents the number of already made guesses. Then follow n lines in the form of "ai bi ci", where ai is the i-th experimental number, bi is the number of bulls, ci is the number of cows (1 ≤ i ≤ n, 0 ≤ bi, ci, bi + ci ≤ 4). The experimental numbers are correct, i.e., each of them contains exactly four digits, in each of them all the four digits are different, and there can be a leading zero. All the experimental numbers are different. As the guesser hasn't guessed the number yet, the answer "4 bulls 0 cows" is not present. Output If the input data is enough to determine the sought number, print the number with four digits on a single line. If it has less than four digits, add leading zero. If the data is not enough, print "Need more data" without the quotes. If the thinker happens to have made a mistake in his replies, print "Incorrect data" without the quotes. Examples Input 2 1263 1 2 8103 2 1 Output Need more data Input 2 1234 2 2 1256 0 2 Output 2134 Input 2 0123 1 1 4567 1 2 Output Incorrect data Submitted Solution: ``` import sys import math MAXNUM = math.inf MINNUM = -1 * math.inf ASCIILOWER = 97 ASCIIUPPER = 65 def getInt(): return int(sys.stdin.readline().rstrip()) def getInts(): return map(int, sys.stdin.readline().rstrip().split(" ")) def getString(): return sys.stdin.readline().rstrip() def printOutput(ans): sys.stdout.write() pass def numChecker(num, genNum, b, c): """checks number for bulls and cows against guess""" # order check: bullCheck = sum([1 if a == b else 0 for (a, b) in zip(num, genNum)]) # number check, this works because all digits must be different cowCheck = sum([1 if a in num else 0 for a in genNum]) - bullCheck return bullCheck == b and cowCheck == c def padLeft(s): while len(s) < 4: s = "0" + s return s def isLegal(s): for i in range(0, len(s)): for j in range(0, len(s)): if i != j and s[i] == s[j]: return False return True def solve(o): initialSet = set() for i in range(1, 10000): num = padLeft(str(i)) if isLegal(num): initialSet.add(num) # print(initialSet) for op in o: guess, b, c = op newSet = set() for num in initialSet: if numChecker(guess, num, b, c): newSet.add(num) initialSet = set.intersection(initialSet, newSet) if len(initialSet) == 1: return initialSet.pop() elif len(initialSet) > 1: return "Need more data" return "Incorrect data" def readinput(): ops = getInt() o = [] for _ in range(ops): num, b, c = getString().split(" ") o.append((num, int(b), int(c))) print(solve(o)) readinput() ```
instruction
0
107,433
19
214,866
Yes
output
1
107,433
19
214,867
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. The "Bulls and Cows" game needs two people to play. The thinker thinks of a number and the guesser tries to guess it. The thinker thinks of a four-digit number in the decimal system. All the digits in the number are different and the number may have a leading zero. It can't have more than one leading zero, because all it's digits should be different. The guesser tries to guess the number. He makes a series of guesses, trying experimental numbers and receives answers from the first person in the format "x bulls y cows". x represents the number of digits in the experimental number that occupy the same positions as in the sought number. y represents the number of digits of the experimental number that present in the sought number, but occupy different positions. Naturally, the experimental numbers, as well as the sought number, are represented by four-digit numbers where all digits are different and a leading zero can be present. For example, let's suppose that the thinker thought of the number 0123. Then the guessers' experimental number 1263 will receive a reply "1 bull 2 cows" (3 occupies the same positions in both numbers and 1 and 2 are present in both numbers but they occupy different positions). Also, the answer to number 8103 will be "2 bulls 1 cow" (analogically, 1 and 3 occupy the same positions and 0 occupies a different one). When the guesser is answered "4 bulls 0 cows", the game is over. Now the guesser has already made several guesses and wants to know whether his next guess can possibly be the last one. Input The first input line contains an integer n (1 ≤ n ≤ 10) which represents the number of already made guesses. Then follow n lines in the form of "ai bi ci", where ai is the i-th experimental number, bi is the number of bulls, ci is the number of cows (1 ≤ i ≤ n, 0 ≤ bi, ci, bi + ci ≤ 4). The experimental numbers are correct, i.e., each of them contains exactly four digits, in each of them all the four digits are different, and there can be a leading zero. All the experimental numbers are different. As the guesser hasn't guessed the number yet, the answer "4 bulls 0 cows" is not present. Output If the input data is enough to determine the sought number, print the number with four digits on a single line. If it has less than four digits, add leading zero. If the data is not enough, print "Need more data" without the quotes. If the thinker happens to have made a mistake in his replies, print "Incorrect data" without the quotes. Examples Input 2 1263 1 2 8103 2 1 Output Need more data Input 2 1234 2 2 1256 0 2 Output 2134 Input 2 0123 1 1 4567 1 2 Output Incorrect data Submitted Solution: ``` def is_valid_cand(a, b, c, cand): a = str(a) cand = str(cand) #if cand == '3210': # print(len(set(str(cand)).intersection(set(str(a)))), a, cand) if len(set(str(cand)).intersection(set(str(a)))) != b + c: return False total_b = 0 total_c = 0 for x, y in zip(str(cand), str(a)): if x == y: total_b += 1 elif x in a: total_c += 1 # print(total_b, total_c) if total_b == b and total_c == c: return True return False cands = ['0'* (4-len(str(i)))+str(i) for i in range(10000) if len(set('0'* (4-len(str(i)))+str(i))) == 4] n = int(input()) for i in range(n): a, b, c = list(map(str, input().split())) b = int(b) c = int(c) to_del = set() for i in range(len(cands)): valid = is_valid_cand(a, b, c, cands[i]) if not valid: to_del.add(cands[i]) cands = [x for x in cands if x not in to_del] #print(cands) if len(cands) == 0: print('Incorrect data') elif len(cands) > 1: print('Need more data') elif len(cands) == 1: print(cands[0]) ```
instruction
0
107,434
19
214,868
Yes
output
1
107,434
19
214,869
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. The "Bulls and Cows" game needs two people to play. The thinker thinks of a number and the guesser tries to guess it. The thinker thinks of a four-digit number in the decimal system. All the digits in the number are different and the number may have a leading zero. It can't have more than one leading zero, because all it's digits should be different. The guesser tries to guess the number. He makes a series of guesses, trying experimental numbers and receives answers from the first person in the format "x bulls y cows". x represents the number of digits in the experimental number that occupy the same positions as in the sought number. y represents the number of digits of the experimental number that present in the sought number, but occupy different positions. Naturally, the experimental numbers, as well as the sought number, are represented by four-digit numbers where all digits are different and a leading zero can be present. For example, let's suppose that the thinker thought of the number 0123. Then the guessers' experimental number 1263 will receive a reply "1 bull 2 cows" (3 occupies the same positions in both numbers and 1 and 2 are present in both numbers but they occupy different positions). Also, the answer to number 8103 will be "2 bulls 1 cow" (analogically, 1 and 3 occupy the same positions and 0 occupies a different one). When the guesser is answered "4 bulls 0 cows", the game is over. Now the guesser has already made several guesses and wants to know whether his next guess can possibly be the last one. Input The first input line contains an integer n (1 ≤ n ≤ 10) which represents the number of already made guesses. Then follow n lines in the form of "ai bi ci", where ai is the i-th experimental number, bi is the number of bulls, ci is the number of cows (1 ≤ i ≤ n, 0 ≤ bi, ci, bi + ci ≤ 4). The experimental numbers are correct, i.e., each of them contains exactly four digits, in each of them all the four digits are different, and there can be a leading zero. All the experimental numbers are different. As the guesser hasn't guessed the number yet, the answer "4 bulls 0 cows" is not present. Output If the input data is enough to determine the sought number, print the number with four digits on a single line. If it has less than four digits, add leading zero. If the data is not enough, print "Need more data" without the quotes. If the thinker happens to have made a mistake in his replies, print "Incorrect data" without the quotes. Examples Input 2 1263 1 2 8103 2 1 Output Need more data Input 2 1234 2 2 1256 0 2 Output 2134 Input 2 0123 1 1 4567 1 2 Output Incorrect data Submitted Solution: ``` n=int(input()) array=[str(t).zfill(4) for t in range(10000) if len(set(str(t).zfill(4)))==4] print (array) for _ in range(n): a,b,c=input().split() b=int(b) c=int(c) # for u in array: # print (u, set(u).intersection(set(a))) array=[u for u in array if len(set(u).intersection(set(a)))==b+c and sum(u[i]==a[i] for i in range(4))==b] # print (array) if len(array)>1:print("Need more data") elif len(array)==1:print(array[0]) else:print("Incorrect data") ```
instruction
0
107,435
19
214,870
No
output
1
107,435
19
214,871
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. The "Bulls and Cows" game needs two people to play. The thinker thinks of a number and the guesser tries to guess it. The thinker thinks of a four-digit number in the decimal system. All the digits in the number are different and the number may have a leading zero. It can't have more than one leading zero, because all it's digits should be different. The guesser tries to guess the number. He makes a series of guesses, trying experimental numbers and receives answers from the first person in the format "x bulls y cows". x represents the number of digits in the experimental number that occupy the same positions as in the sought number. y represents the number of digits of the experimental number that present in the sought number, but occupy different positions. Naturally, the experimental numbers, as well as the sought number, are represented by four-digit numbers where all digits are different and a leading zero can be present. For example, let's suppose that the thinker thought of the number 0123. Then the guessers' experimental number 1263 will receive a reply "1 bull 2 cows" (3 occupies the same positions in both numbers and 1 and 2 are present in both numbers but they occupy different positions). Also, the answer to number 8103 will be "2 bulls 1 cow" (analogically, 1 and 3 occupy the same positions and 0 occupies a different one). When the guesser is answered "4 bulls 0 cows", the game is over. Now the guesser has already made several guesses and wants to know whether his next guess can possibly be the last one. Input The first input line contains an integer n (1 ≤ n ≤ 10) which represents the number of already made guesses. Then follow n lines in the form of "ai bi ci", where ai is the i-th experimental number, bi is the number of bulls, ci is the number of cows (1 ≤ i ≤ n, 0 ≤ bi, ci, bi + ci ≤ 4). The experimental numbers are correct, i.e., each of them contains exactly four digits, in each of them all the four digits are different, and there can be a leading zero. All the experimental numbers are different. As the guesser hasn't guessed the number yet, the answer "4 bulls 0 cows" is not present. Output If the input data is enough to determine the sought number, print the number with four digits on a single line. If it has less than four digits, add leading zero. If the data is not enough, print "Need more data" without the quotes. If the thinker happens to have made a mistake in his replies, print "Incorrect data" without the quotes. Examples Input 2 1263 1 2 8103 2 1 Output Need more data Input 2 1234 2 2 1256 0 2 Output 2134 Input 2 0123 1 1 4567 1 2 Output Incorrect data Submitted Solution: ``` '''input 2 0123 1 1 4567 1 2 ''' from sys import stdin, setrecursionlimit import math from collections import defaultdict, deque import time from itertools import combinations, permutations from copy import deepcopy setrecursionlimit(15000) def take_intersection(): pass def discover_digits(guess): myset = {1, 2, 3, 4, 5, 6, 7, 8, 9, 0} flag = 0 count = 0 final = [] comb = combinations(myset, 4) for i in comb: ans = get_answer(guess, list(i)) if len(ans) == 4: count += 1 final = ans flag = 1 if count == 1: for i in final: print(i, end = '') elif count > 1: print("Need more data") if flag == 0: print("Incorrect data") def check(arr, guess, index): first = 0 total = 0 second = 0 for i in range(4): if arr[i] == int(guess[index][0][i]): first += 1 if str(arr[i]) in guess[index][0]: total += 1 second = total - first if first == int(guess[index][1]) and second == int(guess[index][2]): return True else: return False def get_answer(guess, answer): while len(answer) < 4: answer.append(-1) perm = permutations(answer) flag = 0 ans = [] for i in perm: if flag == 1: return ans i = list(i) for j in range(len(guess)): num = guess[j][0] if check(i, guess, j): pass else: flag = 0 break else: flag = 1 ans = i return ans def check_invalid(final): count = 0 tans = [] for element in final: if len(element) != 4: ans = get_answer(guess, element) if len(ans) > 0: return False return True if count == 1: for i in tans: print(i, end = '') return True else: return False def check_unique(final): count = 0 tans = [] for element in final: if len(element) == 4: ans = get_answer(guess, element) if len(ans) == 4: tans = ans count += 1 if count >= 1: for i in tans: print(i, end = '') return True else: return False # main starts n = int(stdin.readline().strip()) guess = [] for _ in range(n): guess.append(list(map(str, stdin.readline().split()))) # getting ready final list final = [] base = set() discover_digits(guess) ```
instruction
0
107,436
19
214,872
No
output
1
107,436
19
214,873
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. The "Bulls and Cows" game needs two people to play. The thinker thinks of a number and the guesser tries to guess it. The thinker thinks of a four-digit number in the decimal system. All the digits in the number are different and the number may have a leading zero. It can't have more than one leading zero, because all it's digits should be different. The guesser tries to guess the number. He makes a series of guesses, trying experimental numbers and receives answers from the first person in the format "x bulls y cows". x represents the number of digits in the experimental number that occupy the same positions as in the sought number. y represents the number of digits of the experimental number that present in the sought number, but occupy different positions. Naturally, the experimental numbers, as well as the sought number, are represented by four-digit numbers where all digits are different and a leading zero can be present. For example, let's suppose that the thinker thought of the number 0123. Then the guessers' experimental number 1263 will receive a reply "1 bull 2 cows" (3 occupies the same positions in both numbers and 1 and 2 are present in both numbers but they occupy different positions). Also, the answer to number 8103 will be "2 bulls 1 cow" (analogically, 1 and 3 occupy the same positions and 0 occupies a different one). When the guesser is answered "4 bulls 0 cows", the game is over. Now the guesser has already made several guesses and wants to know whether his next guess can possibly be the last one. Input The first input line contains an integer n (1 ≤ n ≤ 10) which represents the number of already made guesses. Then follow n lines in the form of "ai bi ci", where ai is the i-th experimental number, bi is the number of bulls, ci is the number of cows (1 ≤ i ≤ n, 0 ≤ bi, ci, bi + ci ≤ 4). The experimental numbers are correct, i.e., each of them contains exactly four digits, in each of them all the four digits are different, and there can be a leading zero. All the experimental numbers are different. As the guesser hasn't guessed the number yet, the answer "4 bulls 0 cows" is not present. Output If the input data is enough to determine the sought number, print the number with four digits on a single line. If it has less than four digits, add leading zero. If the data is not enough, print "Need more data" without the quotes. If the thinker happens to have made a mistake in his replies, print "Incorrect data" without the quotes. Examples Input 2 1263 1 2 8103 2 1 Output Need more data Input 2 1234 2 2 1256 0 2 Output 2134 Input 2 0123 1 1 4567 1 2 Output Incorrect data Submitted Solution: ``` import math from os import startfile import random from queue import Queue import time import heapq import sys def u(a): freq={} for e in a: if e not in freq: freq[e]=0 freq[e]+=1 for e in freq: if freq[e]>1: return False return True def main(q): ans=[] for i in range(1,10000): s=[c for c in str(i)] if len(s)!=4: s=[0]*(4-len(s))+s if u(s): w=True for e in q: s2,b,c=e s2=[c for c in str(s2)] if len(s2)!=4: s2=[0]*(4-len(s2))+s2 for k in range(len(s)): if s[k]==s2[k]: b-=1 else: if s[k] in s2: c-=1 if c!=0 or b!=0: w=False break if w: ans.append(s) if len(ans)==1: print("".join(ans[0])) elif len(ans)==0: print('Incorrect data') else: print("Need more data") return n=int(input()) arr=[] for i in range(n): arr.append(list(map(int,input().split()))) main(arr) ```
instruction
0
107,437
19
214,874
No
output
1
107,437
19
214,875
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. The "Bulls and Cows" game needs two people to play. The thinker thinks of a number and the guesser tries to guess it. The thinker thinks of a four-digit number in the decimal system. All the digits in the number are different and the number may have a leading zero. It can't have more than one leading zero, because all it's digits should be different. The guesser tries to guess the number. He makes a series of guesses, trying experimental numbers and receives answers from the first person in the format "x bulls y cows". x represents the number of digits in the experimental number that occupy the same positions as in the sought number. y represents the number of digits of the experimental number that present in the sought number, but occupy different positions. Naturally, the experimental numbers, as well as the sought number, are represented by four-digit numbers where all digits are different and a leading zero can be present. For example, let's suppose that the thinker thought of the number 0123. Then the guessers' experimental number 1263 will receive a reply "1 bull 2 cows" (3 occupies the same positions in both numbers and 1 and 2 are present in both numbers but they occupy different positions). Also, the answer to number 8103 will be "2 bulls 1 cow" (analogically, 1 and 3 occupy the same positions and 0 occupies a different one). When the guesser is answered "4 bulls 0 cows", the game is over. Now the guesser has already made several guesses and wants to know whether his next guess can possibly be the last one. Input The first input line contains an integer n (1 ≤ n ≤ 10) which represents the number of already made guesses. Then follow n lines in the form of "ai bi ci", where ai is the i-th experimental number, bi is the number of bulls, ci is the number of cows (1 ≤ i ≤ n, 0 ≤ bi, ci, bi + ci ≤ 4). The experimental numbers are correct, i.e., each of them contains exactly four digits, in each of them all the four digits are different, and there can be a leading zero. All the experimental numbers are different. As the guesser hasn't guessed the number yet, the answer "4 bulls 0 cows" is not present. Output If the input data is enough to determine the sought number, print the number with four digits on a single line. If it has less than four digits, add leading zero. If the data is not enough, print "Need more data" without the quotes. If the thinker happens to have made a mistake in his replies, print "Incorrect data" without the quotes. Examples Input 2 1263 1 2 8103 2 1 Output Need more data Input 2 1234 2 2 1256 0 2 Output 2134 Input 2 0123 1 1 4567 1 2 Output Incorrect data Submitted Solution: ``` def is_valid_cand(a, b, c, cand): a = str(a) cand = str(cand) if len(set(str(cand)).intersection(set(str(a)))) != b + c: return False total_b = 0 total_c = 0 for x, y in zip(str(cand), str(a)): if x == y: total_b += 1 elif x in a: total_c += 1 # print(total_b, total_c) if total_b == b and total_c == c: return True return False cands = ['0'* (4-len(str(i)))+str(i) for i in range(10000) if len(set('0'* (4-len(str(i)))+str(i))) == 4] n = int(input()) for i in range(n): a, b, c = list(map(int, input().split())) to_del = set() for i in range(len(cands)): valid = is_valid_cand(a, b, c, cands[i]) if not valid: to_del.add(cands[i]) cands = [x for x in cands if x not in to_del] if len(cands) == 0: print('Incorrect data') break if len(cands) > 1 and i == n - 1: print('Need more data') break elif len(cands) == 1: print(cands[0]) ```
instruction
0
107,438
19
214,876
No
output
1
107,438
19
214,877
Provide tags and a correct Python 3 solution for this coding contest problem. Mancala is a game famous in the Middle East. It is played on a board that consists of 14 holes. <image> Initially, each hole has a_i stones. When a player makes a move, he chooses a hole which contains a positive number of stones. He takes all the stones inside it and then redistributes these stones one by one in the next holes in a counter-clockwise direction. Note that the counter-clockwise order means if the player takes the stones from hole i, he will put one stone in the (i+1)-th hole, then in the (i+2)-th, etc. If he puts a stone in the 14-th hole, the next one will be put in the first hole. After the move, the player collects all the stones from holes that contain even number of stones. The number of stones collected by player is the score, according to Resli. Resli is a famous Mancala player. He wants to know the maximum score he can obtain after one move. Input The only line contains 14 integers a_1, a_2, …, a_{14} (0 ≤ a_i ≤ 10^9) — the number of stones in each hole. It is guaranteed that for any i (1≤ i ≤ 14) a_i is either zero or odd, and there is at least one stone in the board. Output Output one integer, the maximum possible score after one move. Examples Input 0 1 1 0 0 0 0 0 0 7 0 0 0 0 Output 4 Input 5 1 1 1 1 0 0 0 0 0 0 0 0 0 Output 8 Note In the first test case the board after the move from the hole with 7 stones will look like 1 2 2 0 0 0 0 0 0 0 1 1 1 1. Then the player collects the even numbers and ends up with a score equal to 4.
instruction
0
107,590
19
215,180
Tags: brute force, implementation Correct Solution: ``` a = list(map(int, input().split())) n = 14 f = lambda a: sum(x for x in a if x & 1 ^ 1) def g(a, x): b = a[:] y = a[x] b[x] = 0 for i in range(n): b[i] += y // n y %= n for i in range(x + 1, y + x + 1): b[i % 14] += 1 return f(b) print(max(g(a, i) for i in range(n))) ```
output
1
107,590
19
215,181
Provide tags and a correct Python 3 solution for this coding contest problem. Mancala is a game famous in the Middle East. It is played on a board that consists of 14 holes. <image> Initially, each hole has a_i stones. When a player makes a move, he chooses a hole which contains a positive number of stones. He takes all the stones inside it and then redistributes these stones one by one in the next holes in a counter-clockwise direction. Note that the counter-clockwise order means if the player takes the stones from hole i, he will put one stone in the (i+1)-th hole, then in the (i+2)-th, etc. If he puts a stone in the 14-th hole, the next one will be put in the first hole. After the move, the player collects all the stones from holes that contain even number of stones. The number of stones collected by player is the score, according to Resli. Resli is a famous Mancala player. He wants to know the maximum score he can obtain after one move. Input The only line contains 14 integers a_1, a_2, …, a_{14} (0 ≤ a_i ≤ 10^9) — the number of stones in each hole. It is guaranteed that for any i (1≤ i ≤ 14) a_i is either zero or odd, and there is at least one stone in the board. Output Output one integer, the maximum possible score after one move. Examples Input 0 1 1 0 0 0 0 0 0 7 0 0 0 0 Output 4 Input 5 1 1 1 1 0 0 0 0 0 0 0 0 0 Output 8 Note In the first test case the board after the move from the hole with 7 stones will look like 1 2 2 0 0 0 0 0 0 0 1 1 1 1. Then the player collects the even numbers and ends up with a score equal to 4.
instruction
0
107,591
19
215,182
Tags: brute force, implementation Correct Solution: ``` n = 14 a = None def checkCase(defList, i): global n a = list(defList) stone = a[i] % n stoneAll = a[i] // n a[i] = 0 j = i+1 while (stone > 0): if (j >= n): j = 0 a[j] += 1 j += 1 stone -= 1 pickedUp = 0 for k in range(n): a[k] += stoneAll if (a[k] % 2 == 0): pickedUp += a[k] return pickedUp def main(): global n, a a = [int(e) for e in input().split()] maxStones = 0 for i in range(n): if (a[i] > 0): maxStones = max(maxStones, checkCase(a, i)) print(maxStones) main() ```
output
1
107,591
19
215,183
Provide tags and a correct Python 3 solution for this coding contest problem. Mancala is a game famous in the Middle East. It is played on a board that consists of 14 holes. <image> Initially, each hole has a_i stones. When a player makes a move, he chooses a hole which contains a positive number of stones. He takes all the stones inside it and then redistributes these stones one by one in the next holes in a counter-clockwise direction. Note that the counter-clockwise order means if the player takes the stones from hole i, he will put one stone in the (i+1)-th hole, then in the (i+2)-th, etc. If he puts a stone in the 14-th hole, the next one will be put in the first hole. After the move, the player collects all the stones from holes that contain even number of stones. The number of stones collected by player is the score, according to Resli. Resli is a famous Mancala player. He wants to know the maximum score he can obtain after one move. Input The only line contains 14 integers a_1, a_2, …, a_{14} (0 ≤ a_i ≤ 10^9) — the number of stones in each hole. It is guaranteed that for any i (1≤ i ≤ 14) a_i is either zero or odd, and there is at least one stone in the board. Output Output one integer, the maximum possible score after one move. Examples Input 0 1 1 0 0 0 0 0 0 7 0 0 0 0 Output 4 Input 5 1 1 1 1 0 0 0 0 0 0 0 0 0 Output 8 Note In the first test case the board after the move from the hole with 7 stones will look like 1 2 2 0 0 0 0 0 0 0 1 1 1 1. Then the player collects the even numbers and ends up with a score equal to 4.
instruction
0
107,592
19
215,184
Tags: brute force, implementation Correct Solution: ``` if __name__ == "__main__": numbers = list(map(int, input().split())) v = [] for i in range(14): v.append(numbers[i]) result = 0 for i in range(14): k = numbers[i] v[i] = 0 c = int(k / 14) d = k % 14 for j in range(14): v[j] = v[j] + c j = i + 1 while j <= 13 and d > 0: v[j] = v[j] + 1 j = j + 1 d = d - 1 for j in range(d): v[j] = v[j] + 1 suma = 0 for j in range(14): if v[j] % 2 == 0: suma = suma + v[j] result = max(result, suma) for j in range(14): v[j] = numbers[j] print(result) ```
output
1
107,592
19
215,185
Provide tags and a correct Python 3 solution for this coding contest problem. Mancala is a game famous in the Middle East. It is played on a board that consists of 14 holes. <image> Initially, each hole has a_i stones. When a player makes a move, he chooses a hole which contains a positive number of stones. He takes all the stones inside it and then redistributes these stones one by one in the next holes in a counter-clockwise direction. Note that the counter-clockwise order means if the player takes the stones from hole i, he will put one stone in the (i+1)-th hole, then in the (i+2)-th, etc. If he puts a stone in the 14-th hole, the next one will be put in the first hole. After the move, the player collects all the stones from holes that contain even number of stones. The number of stones collected by player is the score, according to Resli. Resli is a famous Mancala player. He wants to know the maximum score he can obtain after one move. Input The only line contains 14 integers a_1, a_2, …, a_{14} (0 ≤ a_i ≤ 10^9) — the number of stones in each hole. It is guaranteed that for any i (1≤ i ≤ 14) a_i is either zero or odd, and there is at least one stone in the board. Output Output one integer, the maximum possible score after one move. Examples Input 0 1 1 0 0 0 0 0 0 7 0 0 0 0 Output 4 Input 5 1 1 1 1 0 0 0 0 0 0 0 0 0 Output 8 Note In the first test case the board after the move from the hole with 7 stones will look like 1 2 2 0 0 0 0 0 0 0 1 1 1 1. Then the player collects the even numbers and ends up with a score equal to 4.
instruction
0
107,593
19
215,186
Tags: brute force, implementation Correct Solution: ``` stones = list(map(int,input().split())) initial_sum = 0 def even_sum(arr): temp_sum = 0 for each in arr: if(each%2 == 0): temp_sum += each return temp_sum initial_sum = even_sum(stones) dup_sum = initial_sum for i in range(14): duplicate = list(stones) temp = stones[i] duplicate[i] = 0 j = i for each in range(14): duplicate[each] += temp//14 temp = temp%14 while temp > 0 : if( j == 13): j = -1 j += 1 duplicate[j] += 1 temp -= 1 ts = even_sum(duplicate) if(ts > initial_sum ): initial_sum = ts print(initial_sum) ```
output
1
107,593
19
215,187
Provide tags and a correct Python 3 solution for this coding contest problem. Mancala is a game famous in the Middle East. It is played on a board that consists of 14 holes. <image> Initially, each hole has a_i stones. When a player makes a move, he chooses a hole which contains a positive number of stones. He takes all the stones inside it and then redistributes these stones one by one in the next holes in a counter-clockwise direction. Note that the counter-clockwise order means if the player takes the stones from hole i, he will put one stone in the (i+1)-th hole, then in the (i+2)-th, etc. If he puts a stone in the 14-th hole, the next one will be put in the first hole. After the move, the player collects all the stones from holes that contain even number of stones. The number of stones collected by player is the score, according to Resli. Resli is a famous Mancala player. He wants to know the maximum score he can obtain after one move. Input The only line contains 14 integers a_1, a_2, …, a_{14} (0 ≤ a_i ≤ 10^9) — the number of stones in each hole. It is guaranteed that for any i (1≤ i ≤ 14) a_i is either zero or odd, and there is at least one stone in the board. Output Output one integer, the maximum possible score after one move. Examples Input 0 1 1 0 0 0 0 0 0 7 0 0 0 0 Output 4 Input 5 1 1 1 1 0 0 0 0 0 0 0 0 0 Output 8 Note In the first test case the board after the move from the hole with 7 stones will look like 1 2 2 0 0 0 0 0 0 0 1 1 1 1. Then the player collects the even numbers and ends up with a score equal to 4.
instruction
0
107,594
19
215,188
Tags: brute force, implementation Correct Solution: ``` arr = list(map(int, input().split())) ans = 0 for i in range(len(arr)): pol = arr[i] // 14 os = arr[i] % 14 cur = 0 if((pol) % 2 == 0): cur += pol j = i + 1 if(j == 14): j = 0 for u in range(13): num = 0 if(u < os): num += 1 num += arr[j] + pol if(num % 2 == 0): cur += num j = j + 1 if(j == 14): j = 0 if(cur > ans): #print(arr[i]) ans = cur print(ans) ```
output
1
107,594
19
215,189
Provide tags and a correct Python 3 solution for this coding contest problem. Mancala is a game famous in the Middle East. It is played on a board that consists of 14 holes. <image> Initially, each hole has a_i stones. When a player makes a move, he chooses a hole which contains a positive number of stones. He takes all the stones inside it and then redistributes these stones one by one in the next holes in a counter-clockwise direction. Note that the counter-clockwise order means if the player takes the stones from hole i, he will put one stone in the (i+1)-th hole, then in the (i+2)-th, etc. If he puts a stone in the 14-th hole, the next one will be put in the first hole. After the move, the player collects all the stones from holes that contain even number of stones. The number of stones collected by player is the score, according to Resli. Resli is a famous Mancala player. He wants to know the maximum score he can obtain after one move. Input The only line contains 14 integers a_1, a_2, …, a_{14} (0 ≤ a_i ≤ 10^9) — the number of stones in each hole. It is guaranteed that for any i (1≤ i ≤ 14) a_i is either zero or odd, and there is at least one stone in the board. Output Output one integer, the maximum possible score after one move. Examples Input 0 1 1 0 0 0 0 0 0 7 0 0 0 0 Output 4 Input 5 1 1 1 1 0 0 0 0 0 0 0 0 0 Output 8 Note In the first test case the board after the move from the hole with 7 stones will look like 1 2 2 0 0 0 0 0 0 0 1 1 1 1. Then the player collects the even numbers and ends up with a score equal to 4.
instruction
0
107,595
19
215,190
Tags: brute force, implementation Correct Solution: ``` a=list(map(int,input().split())) s=0 for i in range(14): l=0 if a[i]%2==1: k=a[i]//14 p=a[i]%14 b=a[:] b[i]=0 for j in range(1,15): b[(i+j)%14]+=k for j in range(1,p+1): b[(i+j)%14]=b[(i+j)%14]+1 for j in range(14): if b[j]%2==0: l+=b[j] #print(b,k,p,i) s=max(s,l) print(s) ```
output
1
107,595
19
215,191
Provide tags and a correct Python 3 solution for this coding contest problem. Mancala is a game famous in the Middle East. It is played on a board that consists of 14 holes. <image> Initially, each hole has a_i stones. When a player makes a move, he chooses a hole which contains a positive number of stones. He takes all the stones inside it and then redistributes these stones one by one in the next holes in a counter-clockwise direction. Note that the counter-clockwise order means if the player takes the stones from hole i, he will put one stone in the (i+1)-th hole, then in the (i+2)-th, etc. If he puts a stone in the 14-th hole, the next one will be put in the first hole. After the move, the player collects all the stones from holes that contain even number of stones. The number of stones collected by player is the score, according to Resli. Resli is a famous Mancala player. He wants to know the maximum score he can obtain after one move. Input The only line contains 14 integers a_1, a_2, …, a_{14} (0 ≤ a_i ≤ 10^9) — the number of stones in each hole. It is guaranteed that for any i (1≤ i ≤ 14) a_i is either zero or odd, and there is at least one stone in the board. Output Output one integer, the maximum possible score after one move. Examples Input 0 1 1 0 0 0 0 0 0 7 0 0 0 0 Output 4 Input 5 1 1 1 1 0 0 0 0 0 0 0 0 0 Output 8 Note In the first test case the board after the move from the hole with 7 stones will look like 1 2 2 0 0 0 0 0 0 0 1 1 1 1. Then the player collects the even numbers and ends up with a score equal to 4.
instruction
0
107,596
19
215,192
Tags: brute force, implementation Correct Solution: ``` def count(idx, nums): val = nums[idx] nums[idx] = 0 suma = 0 for i in range(1,15): x = nums[(idx+i)%14] + (val-i+1+13)//14 if x%2==0: suma += x nums[idx] = val return suma nums = list(map(int, input().strip().split())) maxi = 0 for i in range(len(nums)): maxi = max(maxi, count(i, nums)) print(maxi) ```
output
1
107,596
19
215,193
Provide tags and a correct Python 3 solution for this coding contest problem. Mancala is a game famous in the Middle East. It is played on a board that consists of 14 holes. <image> Initially, each hole has a_i stones. When a player makes a move, he chooses a hole which contains a positive number of stones. He takes all the stones inside it and then redistributes these stones one by one in the next holes in a counter-clockwise direction. Note that the counter-clockwise order means if the player takes the stones from hole i, he will put one stone in the (i+1)-th hole, then in the (i+2)-th, etc. If he puts a stone in the 14-th hole, the next one will be put in the first hole. After the move, the player collects all the stones from holes that contain even number of stones. The number of stones collected by player is the score, according to Resli. Resli is a famous Mancala player. He wants to know the maximum score he can obtain after one move. Input The only line contains 14 integers a_1, a_2, …, a_{14} (0 ≤ a_i ≤ 10^9) — the number of stones in each hole. It is guaranteed that for any i (1≤ i ≤ 14) a_i is either zero or odd, and there is at least one stone in the board. Output Output one integer, the maximum possible score after one move. Examples Input 0 1 1 0 0 0 0 0 0 7 0 0 0 0 Output 4 Input 5 1 1 1 1 0 0 0 0 0 0 0 0 0 Output 8 Note In the first test case the board after the move from the hole with 7 stones will look like 1 2 2 0 0 0 0 0 0 0 1 1 1 1. Then the player collects the even numbers and ends up with a score equal to 4.
instruction
0
107,597
19
215,194
Tags: brute force, implementation Correct Solution: ``` arr = list(map(int, input().split())) summ = 0 for i in range(14): copy = [0] * 14 now = arr[i] for j in range(14): copy[j] = arr[j] copy[i] = 0 for k in range(i + 1, 14): if now <= 0: break copy[k] += 1 now -= 1 s = now // 14 for k in range(14): copy[k] += s for k in range(now % 14): copy[k] += 1 local_s = 0 for el in copy: if el > 0 and el % 2 == 0: local_s += el if local_s > summ: summ = local_s print(summ) ```
output
1
107,597
19
215,195
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Mancala is a game famous in the Middle East. It is played on a board that consists of 14 holes. <image> Initially, each hole has a_i stones. When a player makes a move, he chooses a hole which contains a positive number of stones. He takes all the stones inside it and then redistributes these stones one by one in the next holes in a counter-clockwise direction. Note that the counter-clockwise order means if the player takes the stones from hole i, he will put one stone in the (i+1)-th hole, then in the (i+2)-th, etc. If he puts a stone in the 14-th hole, the next one will be put in the first hole. After the move, the player collects all the stones from holes that contain even number of stones. The number of stones collected by player is the score, according to Resli. Resli is a famous Mancala player. He wants to know the maximum score he can obtain after one move. Input The only line contains 14 integers a_1, a_2, …, a_{14} (0 ≤ a_i ≤ 10^9) — the number of stones in each hole. It is guaranteed that for any i (1≤ i ≤ 14) a_i is either zero or odd, and there is at least one stone in the board. Output Output one integer, the maximum possible score after one move. Examples Input 0 1 1 0 0 0 0 0 0 7 0 0 0 0 Output 4 Input 5 1 1 1 1 0 0 0 0 0 0 0 0 0 Output 8 Note In the first test case the board after the move from the hole with 7 stones will look like 1 2 2 0 0 0 0 0 0 0 1 1 1 1. Then the player collects the even numbers and ends up with a score equal to 4. Submitted Solution: ``` l=list(map(int,input().split())) l*=2 ans=0 for i in range(14): s=0 if l[i]!=0: a=l[i] x=l[i]%14 y=l[i]//14 l[i]=0 l[i+14]=0 for j in range(1,15): if j<=x: if (l[j+i]+1+y) %2==0: s+=l[j+i]+1+y else: if (l[j+i]+ y)%2==0: s+=l[j+i]+ y l[i]=a l[i+14]=a ans=max(ans,s) print(ans) ```
instruction
0
107,598
19
215,196
Yes
output
1
107,598
19
215,197
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Mancala is a game famous in the Middle East. It is played on a board that consists of 14 holes. <image> Initially, each hole has a_i stones. When a player makes a move, he chooses a hole which contains a positive number of stones. He takes all the stones inside it and then redistributes these stones one by one in the next holes in a counter-clockwise direction. Note that the counter-clockwise order means if the player takes the stones from hole i, he will put one stone in the (i+1)-th hole, then in the (i+2)-th, etc. If he puts a stone in the 14-th hole, the next one will be put in the first hole. After the move, the player collects all the stones from holes that contain even number of stones. The number of stones collected by player is the score, according to Resli. Resli is a famous Mancala player. He wants to know the maximum score he can obtain after one move. Input The only line contains 14 integers a_1, a_2, …, a_{14} (0 ≤ a_i ≤ 10^9) — the number of stones in each hole. It is guaranteed that for any i (1≤ i ≤ 14) a_i is either zero or odd, and there is at least one stone in the board. Output Output one integer, the maximum possible score after one move. Examples Input 0 1 1 0 0 0 0 0 0 7 0 0 0 0 Output 4 Input 5 1 1 1 1 0 0 0 0 0 0 0 0 0 Output 8 Note In the first test case the board after the move from the hole with 7 stones will look like 1 2 2 0 0 0 0 0 0 0 1 1 1 1. Then the player collects the even numbers and ends up with a score equal to 4. Submitted Solution: ``` #!/usr/bin/env python3 from sys import stdin, stdout def rint(): return map(int, stdin.readline().split()) #lines = stdin.readlines() def solve(i): tot_stone = a[i] same_dist = tot_stone//14 res_dist = tot_stone%14 ans = 0 aa = a[:] aa[i] = 0 for ii in range(14): aa[ii] += same_dist for ii in range(i+1, i+1+res_dist): aa[ii%14] += 1 for ii in range(14): if aa[ii] % 2 == 0: ans += aa[ii] return ans a = list(rint()) max_ans = 0 for i in range(14): s = solve(i) max_ans = max(s, max_ans) print(max_ans) ```
instruction
0
107,599
19
215,198
Yes
output
1
107,599
19
215,199
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Mancala is a game famous in the Middle East. It is played on a board that consists of 14 holes. <image> Initially, each hole has a_i stones. When a player makes a move, he chooses a hole which contains a positive number of stones. He takes all the stones inside it and then redistributes these stones one by one in the next holes in a counter-clockwise direction. Note that the counter-clockwise order means if the player takes the stones from hole i, he will put one stone in the (i+1)-th hole, then in the (i+2)-th, etc. If he puts a stone in the 14-th hole, the next one will be put in the first hole. After the move, the player collects all the stones from holes that contain even number of stones. The number of stones collected by player is the score, according to Resli. Resli is a famous Mancala player. He wants to know the maximum score he can obtain after one move. Input The only line contains 14 integers a_1, a_2, …, a_{14} (0 ≤ a_i ≤ 10^9) — the number of stones in each hole. It is guaranteed that for any i (1≤ i ≤ 14) a_i is either zero or odd, and there is at least one stone in the board. Output Output one integer, the maximum possible score after one move. Examples Input 0 1 1 0 0 0 0 0 0 7 0 0 0 0 Output 4 Input 5 1 1 1 1 0 0 0 0 0 0 0 0 0 Output 8 Note In the first test case the board after the move from the hole with 7 stones will look like 1 2 2 0 0 0 0 0 0 0 1 1 1 1. Then the player collects the even numbers and ends up with a score equal to 4. Submitted Solution: ``` arr = list(map(int, input().split())) ans = 0 for i in range(14): r = arr[i]//14 d = arr[i] % 14 c = 0 x = (i + 1) % 14 s = 0 temp2 = arr[i] arr[i] = 0 while c < 14: c += 1 temp = arr[x] + r if d > 0: temp += 1 d -= 1 x = (x + 1) % 14 s += (0 if temp % 2 else temp) arr[i] = temp2 ans = max(ans, s) print(ans) ```
instruction
0
107,600
19
215,200
Yes
output
1
107,600
19
215,201
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Mancala is a game famous in the Middle East. It is played on a board that consists of 14 holes. <image> Initially, each hole has a_i stones. When a player makes a move, he chooses a hole which contains a positive number of stones. He takes all the stones inside it and then redistributes these stones one by one in the next holes in a counter-clockwise direction. Note that the counter-clockwise order means if the player takes the stones from hole i, he will put one stone in the (i+1)-th hole, then in the (i+2)-th, etc. If he puts a stone in the 14-th hole, the next one will be put in the first hole. After the move, the player collects all the stones from holes that contain even number of stones. The number of stones collected by player is the score, according to Resli. Resli is a famous Mancala player. He wants to know the maximum score he can obtain after one move. Input The only line contains 14 integers a_1, a_2, …, a_{14} (0 ≤ a_i ≤ 10^9) — the number of stones in each hole. It is guaranteed that for any i (1≤ i ≤ 14) a_i is either zero or odd, and there is at least one stone in the board. Output Output one integer, the maximum possible score after one move. Examples Input 0 1 1 0 0 0 0 0 0 7 0 0 0 0 Output 4 Input 5 1 1 1 1 0 0 0 0 0 0 0 0 0 Output 8 Note In the first test case the board after the move from the hole with 7 stones will look like 1 2 2 0 0 0 0 0 0 0 1 1 1 1. Then the player collects the even numbers and ends up with a score equal to 4. Submitted Solution: ``` a = list(map(int, input().split())) m = 0 for i in range(len(a)): ai = a[i] giri = int(ai/14) modulo = ai % 14 tmp = a[i] a[i] = 0 s = 0 for j in range(len(a)): if (a[j] + giri) % 2 == 0: s += a[j] + giri j = (i+1)%14 cont = 1 while cont <= modulo: if (a[j] + giri) % 2 != 0: s += a[j] + giri + 1 else: s -= a[j] + giri cont += 1 j = (j+1) % 14 a[i] = tmp m = max(s, m) print(m) ```
instruction
0
107,601
19
215,202
Yes
output
1
107,601
19
215,203
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Mancala is a game famous in the Middle East. It is played on a board that consists of 14 holes. <image> Initially, each hole has a_i stones. When a player makes a move, he chooses a hole which contains a positive number of stones. He takes all the stones inside it and then redistributes these stones one by one in the next holes in a counter-clockwise direction. Note that the counter-clockwise order means if the player takes the stones from hole i, he will put one stone in the (i+1)-th hole, then in the (i+2)-th, etc. If he puts a stone in the 14-th hole, the next one will be put in the first hole. After the move, the player collects all the stones from holes that contain even number of stones. The number of stones collected by player is the score, according to Resli. Resli is a famous Mancala player. He wants to know the maximum score he can obtain after one move. Input The only line contains 14 integers a_1, a_2, …, a_{14} (0 ≤ a_i ≤ 10^9) — the number of stones in each hole. It is guaranteed that for any i (1≤ i ≤ 14) a_i is either zero or odd, and there is at least one stone in the board. Output Output one integer, the maximum possible score after one move. Examples Input 0 1 1 0 0 0 0 0 0 7 0 0 0 0 Output 4 Input 5 1 1 1 1 0 0 0 0 0 0 0 0 0 Output 8 Note In the first test case the board after the move from the hole with 7 stones will look like 1 2 2 0 0 0 0 0 0 0 1 1 1 1. Then the player collects the even numbers and ends up with a score equal to 4. Submitted Solution: ``` import sys from math import gcd, sqrt input = lambda: sys.stdin.readline().rstrip('\r\n') lcm = lambda x, y: (x * y) // gcd(x, y) a = list(map(int, input().split())) index = [] for i in range(14): if a[i] > 1: index.append(i) for idx in index: r = a[idx] a[idx] = 0 k = (idx + 1) % 14 for j in range(r): a[k] += 1 k = (k + 1) % 14 res = 0 for i in a: if i % 2 == 0: res += i print(res) ```
instruction
0
107,602
19
215,204
No
output
1
107,602
19
215,205
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Mancala is a game famous in the Middle East. It is played on a board that consists of 14 holes. <image> Initially, each hole has a_i stones. When a player makes a move, he chooses a hole which contains a positive number of stones. He takes all the stones inside it and then redistributes these stones one by one in the next holes in a counter-clockwise direction. Note that the counter-clockwise order means if the player takes the stones from hole i, he will put one stone in the (i+1)-th hole, then in the (i+2)-th, etc. If he puts a stone in the 14-th hole, the next one will be put in the first hole. After the move, the player collects all the stones from holes that contain even number of stones. The number of stones collected by player is the score, according to Resli. Resli is a famous Mancala player. He wants to know the maximum score he can obtain after one move. Input The only line contains 14 integers a_1, a_2, …, a_{14} (0 ≤ a_i ≤ 10^9) — the number of stones in each hole. It is guaranteed that for any i (1≤ i ≤ 14) a_i is either zero or odd, and there is at least one stone in the board. Output Output one integer, the maximum possible score after one move. Examples Input 0 1 1 0 0 0 0 0 0 7 0 0 0 0 Output 4 Input 5 1 1 1 1 0 0 0 0 0 0 0 0 0 Output 8 Note In the first test case the board after the move from the hole with 7 stones will look like 1 2 2 0 0 0 0 0 0 0 1 1 1 1. Then the player collects the even numbers and ends up with a score equal to 4. Submitted Solution: ``` arr = list(map(int, input().split())) max_ = max(arr) i_max = arr.index(max_) a = max_ % 14 for i in range(1, a+1): arr[(i_max+i) % 14] += max_//14 +1 res = 0 for a in arr: if a % 2 == 0: res += a print(res) ```
instruction
0
107,603
19
215,206
No
output
1
107,603
19
215,207
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Mancala is a game famous in the Middle East. It is played on a board that consists of 14 holes. <image> Initially, each hole has a_i stones. When a player makes a move, he chooses a hole which contains a positive number of stones. He takes all the stones inside it and then redistributes these stones one by one in the next holes in a counter-clockwise direction. Note that the counter-clockwise order means if the player takes the stones from hole i, he will put one stone in the (i+1)-th hole, then in the (i+2)-th, etc. If he puts a stone in the 14-th hole, the next one will be put in the first hole. After the move, the player collects all the stones from holes that contain even number of stones. The number of stones collected by player is the score, according to Resli. Resli is a famous Mancala player. He wants to know the maximum score he can obtain after one move. Input The only line contains 14 integers a_1, a_2, …, a_{14} (0 ≤ a_i ≤ 10^9) — the number of stones in each hole. It is guaranteed that for any i (1≤ i ≤ 14) a_i is either zero or odd, and there is at least one stone in the board. Output Output one integer, the maximum possible score after one move. Examples Input 0 1 1 0 0 0 0 0 0 7 0 0 0 0 Output 4 Input 5 1 1 1 1 0 0 0 0 0 0 0 0 0 Output 8 Note In the first test case the board after the move from the hole with 7 stones will look like 1 2 2 0 0 0 0 0 0 0 1 1 1 1. Then the player collects the even numbers and ends up with a score equal to 4. Submitted Solution: ``` from sys import stdin,stdout arr=[int(x) for x in stdin.readline().split()] sum=0 for x in range(len(arr)): if(not arr[x]): continue a=arr[x]//13 s=arr[x]%13 ssum=0 for i in range(1,14): val=(arr[(x+i)%14]+(1 if(s>0) else 0)+a) if (x+i)%14!=x else 0 ssum+=(val if(not val%2) else 0) s-=1 sum=max(sum,ssum) print(sum) ```
instruction
0
107,604
19
215,208
No
output
1
107,604
19
215,209
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Mancala is a game famous in the Middle East. It is played on a board that consists of 14 holes. <image> Initially, each hole has a_i stones. When a player makes a move, he chooses a hole which contains a positive number of stones. He takes all the stones inside it and then redistributes these stones one by one in the next holes in a counter-clockwise direction. Note that the counter-clockwise order means if the player takes the stones from hole i, he will put one stone in the (i+1)-th hole, then in the (i+2)-th, etc. If he puts a stone in the 14-th hole, the next one will be put in the first hole. After the move, the player collects all the stones from holes that contain even number of stones. The number of stones collected by player is the score, according to Resli. Resli is a famous Mancala player. He wants to know the maximum score he can obtain after one move. Input The only line contains 14 integers a_1, a_2, …, a_{14} (0 ≤ a_i ≤ 10^9) — the number of stones in each hole. It is guaranteed that for any i (1≤ i ≤ 14) a_i is either zero or odd, and there is at least one stone in the board. Output Output one integer, the maximum possible score after one move. Examples Input 0 1 1 0 0 0 0 0 0 7 0 0 0 0 Output 4 Input 5 1 1 1 1 0 0 0 0 0 0 0 0 0 Output 8 Note In the first test case the board after the move from the hole with 7 stones will look like 1 2 2 0 0 0 0 0 0 0 1 1 1 1. Then the player collects the even numbers and ends up with a score equal to 4. Submitted Solution: ``` arr = list(map(int, input().split())) from itertools import combinations best = 0 select = list(filter(lambda x:arr[x] != 0, range(14))) for items in range(len(select)): for combination in combinations(select, items+1): temp = [0] * 15 for index in combination: element = arr[index] temp[index] -= element start = (index + 1) % 14 temp[start] += element end = min(start+element, 14) temp[start] += 1 temp[end] -= 1 element = element - (end - start) if element: print("asdas") times = element // 14 temp[0] += times temp[14] -= times remaining = element % 14 temp[0] += 1 temp[remaining] -= 1 kk = 0 run_sum = 0 ans = 0 while kk < 14: run_sum += temp[kk] temp[kk] = run_sum + arr[kk] if temp[kk] % 2 == 0: ans += temp[kk] kk += 1 best = max(best, ans) print(best) ```
instruction
0
107,605
19
215,210
No
output
1
107,605
19
215,211
Provide a correct Python 3 solution for this coding contest problem. Alice, Bob and Charlie are playing Card Game for Three, as below: * At first, each of the three players has a deck consisting of some number of cards. Each card has a letter `a`, `b` or `c` written on it. The orders of the cards in the decks cannot be rearranged. * The players take turns. Alice goes first. * If the current player's deck contains at least one card, discard the top card in the deck. Then, the player whose name begins with the letter on the discarded card, takes the next turn. (For example, if the card says `a`, Alice takes the next turn.) * If the current player's deck is empty, the game ends and the current player wins the game. You are given the initial decks of the players. More specifically, you are given three strings S_A, S_B and S_C. The i-th (1≦i≦|S_A|) letter in S_A is the letter on the i-th card in Alice's initial deck. S_B and S_C describes Bob's and Charlie's initial decks in the same way. Determine the winner of the game. Constraints * 1≦|S_A|≦100 * 1≦|S_B|≦100 * 1≦|S_C|≦100 * Each letter in S_A, S_B, S_C is `a`, `b` or `c`. Input The input is given from Standard Input in the following format: S_A S_B S_C Output If Alice will win, print `A`. If Bob will win, print `B`. If Charlie will win, print `C`. Examples Input aca accc ca Output A Input abcb aacb bccc Output C
instruction
0
108,522
19
217,044
"Correct Solution: ``` A, B, C= [list(reversed(input())) for i in range(3)] d = {'a':A, 'b':B, 'c':C} x = 'a' while len(d[x]) != 0: x = d[x].pop() print(x.upper()) ```
output
1
108,522
19
217,045