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
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. After you had helped George and Alex to move in the dorm, they went to help their friend Fedor play a new computer game «Call of Soldiers 3». The game has (m + 1) players and n types of soldiers in total. Players «Call of Soldiers 3» are numbered form 1 to (m + 1). Types of soldiers are numbered from 0 to n - 1. Each player has an army. Army of the i-th player can be described by non-negative integer xi. Consider binary representation of xi: if the j-th bit of number xi equal to one, then the army of the i-th player has soldiers of the j-th type. Fedor is the (m + 1)-th player of the game. He assume that two players can become friends if their armies differ in at most k types of soldiers (in other words, binary representations of the corresponding numbers differ in at most k bits). Help Fedor and count how many players can become his friends. Input The first line contains three integers n, m, k (1 ≤ k ≤ n ≤ 20; 1 ≤ m ≤ 1000). The i-th of the next (m + 1) lines contains a single integer xi (1 ≤ xi ≤ 2n - 1), that describes the i-th player's army. We remind you that Fedor is the (m + 1)-th player. Output Print a single integer — the number of Fedor's potential friends. Examples Input 7 3 1 8 5 111 17 Output 0 Input 3 3 3 1 2 3 4 Output 3 Submitted Solution: ``` #https://codeforces.com/problemset/problem/467/B n,m,k=map(int,input().split()) L = [] for i in range(m+1): o = int(input()) L.append(o) c=0 for i in range(len(L)-1): p = L[i]^L[-1] y=0 while(p>0): e = p&1 if(e==1): y+=1 p=p>>1 if(y<=k): c+=1 print(c) ```
instruction
0
51,702
19
103,404
Yes
output
1
51,702
19
103,405
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. After you had helped George and Alex to move in the dorm, they went to help their friend Fedor play a new computer game «Call of Soldiers 3». The game has (m + 1) players and n types of soldiers in total. Players «Call of Soldiers 3» are numbered form 1 to (m + 1). Types of soldiers are numbered from 0 to n - 1. Each player has an army. Army of the i-th player can be described by non-negative integer xi. Consider binary representation of xi: if the j-th bit of number xi equal to one, then the army of the i-th player has soldiers of the j-th type. Fedor is the (m + 1)-th player of the game. He assume that two players can become friends if their armies differ in at most k types of soldiers (in other words, binary representations of the corresponding numbers differ in at most k bits). Help Fedor and count how many players can become his friends. Input The first line contains three integers n, m, k (1 ≤ k ≤ n ≤ 20; 1 ≤ m ≤ 1000). The i-th of the next (m + 1) lines contains a single integer xi (1 ≤ xi ≤ 2n - 1), that describes the i-th player's army. We remind you that Fedor is the (m + 1)-th player. Output Print a single integer — the number of Fedor's potential friends. Examples Input 7 3 1 8 5 111 17 Output 0 Input 3 3 3 1 2 3 4 Output 3 Submitted Solution: ``` n,m,k=[int(x) for x in input().split()] l=[] for i in range(m+1): l.append(int(input())) ans=0 for i in range(m): x=l[i]^l[m] count=0 while x!=0: if x%2!=0: count+=1 x//=2 if count<=k: ans+=1 print(ans) ```
instruction
0
51,703
19
103,406
Yes
output
1
51,703
19
103,407
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. After you had helped George and Alex to move in the dorm, they went to help their friend Fedor play a new computer game «Call of Soldiers 3». The game has (m + 1) players and n types of soldiers in total. Players «Call of Soldiers 3» are numbered form 1 to (m + 1). Types of soldiers are numbered from 0 to n - 1. Each player has an army. Army of the i-th player can be described by non-negative integer xi. Consider binary representation of xi: if the j-th bit of number xi equal to one, then the army of the i-th player has soldiers of the j-th type. Fedor is the (m + 1)-th player of the game. He assume that two players can become friends if their armies differ in at most k types of soldiers (in other words, binary representations of the corresponding numbers differ in at most k bits). Help Fedor and count how many players can become his friends. Input The first line contains three integers n, m, k (1 ≤ k ≤ n ≤ 20; 1 ≤ m ≤ 1000). The i-th of the next (m + 1) lines contains a single integer xi (1 ≤ xi ≤ 2n - 1), that describes the i-th player's army. We remind you that Fedor is the (m + 1)-th player. Output Print a single integer — the number of Fedor's potential friends. Examples Input 7 3 1 8 5 111 17 Output 0 Input 3 3 3 1 2 3 4 Output 3 Submitted Solution: ``` n, m, k = map(int, input(). split()) a, b = [0] * (m + 1), [0] * (m + 1) s = 0 for i in range(m, -1, -1): a[i] = int(input()) x, izm = 1, 0 while 2 ** x <= a[i] and x > 0: x += 1 x -= 1 while x >= 0: if a[i] - (2 ** x) >= 0: b[i] = b[i] * 10 + 1 a[i] -= 2 ** x else: b[i] *= 10 if a[i] - (2 ** x) == 0: a[i] -= 2 ** x x -= 1 if i != m: y1 = 10 y2 = 1 while b[i] > 0: if (b[i] % y1) // y2 != (b[m] % y1) // y2: izm += 1 y1 *= 10 y2 *= 10 b[i] //= 10 if izm < k: s += 1 print(s) ```
instruction
0
51,704
19
103,408
No
output
1
51,704
19
103,409
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. After you had helped George and Alex to move in the dorm, they went to help their friend Fedor play a new computer game «Call of Soldiers 3». The game has (m + 1) players and n types of soldiers in total. Players «Call of Soldiers 3» are numbered form 1 to (m + 1). Types of soldiers are numbered from 0 to n - 1. Each player has an army. Army of the i-th player can be described by non-negative integer xi. Consider binary representation of xi: if the j-th bit of number xi equal to one, then the army of the i-th player has soldiers of the j-th type. Fedor is the (m + 1)-th player of the game. He assume that two players can become friends if their armies differ in at most k types of soldiers (in other words, binary representations of the corresponding numbers differ in at most k bits). Help Fedor and count how many players can become his friends. Input The first line contains three integers n, m, k (1 ≤ k ≤ n ≤ 20; 1 ≤ m ≤ 1000). The i-th of the next (m + 1) lines contains a single integer xi (1 ≤ xi ≤ 2n - 1), that describes the i-th player's army. We remind you that Fedor is the (m + 1)-th player. Output Print a single integer — the number of Fedor's potential friends. Examples Input 7 3 1 8 5 111 17 Output 0 Input 3 3 3 1 2 3 4 Output 3 Submitted Solution: ``` n, m, k = [int(s) for s in input().split()] x = [int(input()) for i in range(m)] Fedor=int(input()) Fedor_bin=list(str(bin(Fedor)).replace('0b','').zfill(n)) total=0 for i in x: x_bin= list(str(bin(i)).replace('0b','').zfill(n)) rev_Fedor_bin=Fedor_bin[::-1] rev_x_bin=x_bin[::-1] print("flen: {}; xlen: {}".format(len(Fedor_bin), len(x_bin))) count=0 for j in range(len(Fedor_bin)): if rev_Fedor_bin[j] != rev_x_bin[j]: count+=1 else: if count<=k: total+=1 print(total) ```
instruction
0
51,705
19
103,410
No
output
1
51,705
19
103,411
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. After you had helped George and Alex to move in the dorm, they went to help their friend Fedor play a new computer game «Call of Soldiers 3». The game has (m + 1) players and n types of soldiers in total. Players «Call of Soldiers 3» are numbered form 1 to (m + 1). Types of soldiers are numbered from 0 to n - 1. Each player has an army. Army of the i-th player can be described by non-negative integer xi. Consider binary representation of xi: if the j-th bit of number xi equal to one, then the army of the i-th player has soldiers of the j-th type. Fedor is the (m + 1)-th player of the game. He assume that two players can become friends if their armies differ in at most k types of soldiers (in other words, binary representations of the corresponding numbers differ in at most k bits). Help Fedor and count how many players can become his friends. Input The first line contains three integers n, m, k (1 ≤ k ≤ n ≤ 20; 1 ≤ m ≤ 1000). The i-th of the next (m + 1) lines contains a single integer xi (1 ≤ xi ≤ 2n - 1), that describes the i-th player's army. We remind you that Fedor is the (m + 1)-th player. Output Print a single integer — the number of Fedor's potential friends. Examples Input 7 3 1 8 5 111 17 Output 0 Input 3 3 3 1 2 3 4 Output 3 Submitted Solution: ``` nmk = [int(i) for i in input().split()] n = nmk[0] m = nmk[1] k = nmk[2] x = [] ans = 0 for i in range(m): x.append(int(input())) s = int(input()) s_bits = [] for i in range(n): s_bits.append(s % 2) s //= 2 for i in range(m): x_bits = [] for j in range(n): x_bits.append(x[i] % 2) x[i] //= 2 t = 0 for j in range(n): if x_bits != s_bits: t += 1 if t <= k: ans += 1 print(ans) ```
instruction
0
51,706
19
103,412
No
output
1
51,706
19
103,413
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. After you had helped George and Alex to move in the dorm, they went to help their friend Fedor play a new computer game «Call of Soldiers 3». The game has (m + 1) players and n types of soldiers in total. Players «Call of Soldiers 3» are numbered form 1 to (m + 1). Types of soldiers are numbered from 0 to n - 1. Each player has an army. Army of the i-th player can be described by non-negative integer xi. Consider binary representation of xi: if the j-th bit of number xi equal to one, then the army of the i-th player has soldiers of the j-th type. Fedor is the (m + 1)-th player of the game. He assume that two players can become friends if their armies differ in at most k types of soldiers (in other words, binary representations of the corresponding numbers differ in at most k bits). Help Fedor and count how many players can become his friends. Input The first line contains three integers n, m, k (1 ≤ k ≤ n ≤ 20; 1 ≤ m ≤ 1000). The i-th of the next (m + 1) lines contains a single integer xi (1 ≤ xi ≤ 2n - 1), that describes the i-th player's army. We remind you that Fedor is the (m + 1)-th player. Output Print a single integer — the number of Fedor's potential friends. Examples Input 7 3 1 8 5 111 17 Output 0 Input 3 3 3 1 2 3 4 Output 3 Submitted Solution: ``` n,m,k=map(int,input().split()) others=[] friend=0 for i in range(m): others.append(int(input())) fedor=int(input()) fedor=bin(fedor) fedor.lstrip('0b') fedor=list(fedor) fedor.reverse() fedor=fedor+['0']*(n-1-len(fedor)) for i in others: differ=0 i=bin(i) i.lstrip('0b') i=list(i) i.reverse() i=i+['0']*(n-1-len(i)) for j in range(n-1): if i[j] != fedor[j]: differ=differ+1 if differ<=k: friend=friend+1 print(friend) ```
instruction
0
51,707
19
103,414
No
output
1
51,707
19
103,415
Provide tags and a correct Python 3 solution for this coding contest problem. Peter Parker wants to play a game with Dr. Octopus. The game is about cycles. Cycle is a sequence of vertices, such that first one is connected with the second, second is connected with third and so on, while the last one is connected with the first one again. Cycle may consist of a single isolated vertex. Initially there are k cycles, i-th of them consisting of exactly vi vertices. Players play alternatively. Peter goes first. On each turn a player must choose a cycle with at least 2 vertices (for example, x vertices) among all available cycles and replace it by two cycles with p and x - p vertices where 1 ≤ p < x is chosen by the player. The player who cannot make a move loses the game (and his life!). Peter wants to test some configurations of initial cycle sets before he actually plays with Dr. Octopus. Initially he has an empty set. In the i-th test he adds a cycle with ai vertices to the set (this is actually a multiset because it can contain two or more identical cycles). After each test, Peter wants to know that if the players begin the game with the current set of cycles, who wins? Peter is pretty good at math, but now he asks you to help. Input The first line of the input contains a single integer n (1 ≤ n ≤ 100 000) — the number of tests Peter is about to make. The second line contains n space separated integers a1, a2, ..., an (1 ≤ ai ≤ 109), i-th of them stands for the number of vertices in the cycle added before the i-th test. Output Print the result of all tests in order they are performed. Print 1 if the player who moves first wins or 2 otherwise. Examples Input 3 1 2 3 Output 2 1 1 Input 5 1 1 5 1 1 Output 2 2 2 2 2 Note In the first sample test: In Peter's first test, there's only one cycle with 1 vertex. First player cannot make a move and loses. In his second test, there's one cycle with 1 vertex and one with 2. No one can make a move on the cycle with 1 vertex. First player can replace the second cycle with two cycles of 1 vertex and second player can't make any move and loses. In his third test, cycles have 1, 2 and 3 vertices. Like last test, no one can make a move on the first cycle. First player can replace the third cycle with one cycle with size 1 and one with size 2. Now cycles have 1, 1, 2, 2 vertices. Second player's only move is to replace a cycle of size 2 with 2 cycles of size 1. And cycles are 1, 1, 1, 1, 2. First player replaces the last cycle with 2 cycles with size 1 and wins. In the second sample test: Having cycles of size 1 is like not having them (because no one can make a move on them). In Peter's third test: There a cycle of size 5 (others don't matter). First player has two options: replace it with cycles of sizes 1 and 4 or 2 and 3. * If he replaces it with cycles of sizes 1 and 4: Only second cycle matters. Second player will replace it with 2 cycles of sizes 2. First player's only option to replace one of them with two cycles of size 1. Second player does the same thing with the other cycle. First player can't make any move and loses. * If he replaces it with cycles of sizes 2 and 3: Second player will replace the cycle of size 3 with two of sizes 1 and 2. Now only cycles with more than one vertex are two cycles of size 2. As shown in previous case, with 2 cycles of size 2 second player wins. So, either way first player loses.
instruction
0
51,773
19
103,546
Tags: games, math Correct Solution: ``` import sys fin = sys.stdin fout = sys.stdout n = int(fin.readline()) a = list(map(int, fin.readline().split())) res = [] curN = 2 for cur in a: if cur % 2 == 0: curN = 3 - curN res.append(curN) fout.write('\n'.join(map(str, res))) ```
output
1
51,773
19
103,547
Provide tags and a correct Python 3 solution for this coding contest problem. Peter Parker wants to play a game with Dr. Octopus. The game is about cycles. Cycle is a sequence of vertices, such that first one is connected with the second, second is connected with third and so on, while the last one is connected with the first one again. Cycle may consist of a single isolated vertex. Initially there are k cycles, i-th of them consisting of exactly vi vertices. Players play alternatively. Peter goes first. On each turn a player must choose a cycle with at least 2 vertices (for example, x vertices) among all available cycles and replace it by two cycles with p and x - p vertices where 1 ≤ p < x is chosen by the player. The player who cannot make a move loses the game (and his life!). Peter wants to test some configurations of initial cycle sets before he actually plays with Dr. Octopus. Initially he has an empty set. In the i-th test he adds a cycle with ai vertices to the set (this is actually a multiset because it can contain two or more identical cycles). After each test, Peter wants to know that if the players begin the game with the current set of cycles, who wins? Peter is pretty good at math, but now he asks you to help. Input The first line of the input contains a single integer n (1 ≤ n ≤ 100 000) — the number of tests Peter is about to make. The second line contains n space separated integers a1, a2, ..., an (1 ≤ ai ≤ 109), i-th of them stands for the number of vertices in the cycle added before the i-th test. Output Print the result of all tests in order they are performed. Print 1 if the player who moves first wins or 2 otherwise. Examples Input 3 1 2 3 Output 2 1 1 Input 5 1 1 5 1 1 Output 2 2 2 2 2 Note In the first sample test: In Peter's first test, there's only one cycle with 1 vertex. First player cannot make a move and loses. In his second test, there's one cycle with 1 vertex and one with 2. No one can make a move on the cycle with 1 vertex. First player can replace the second cycle with two cycles of 1 vertex and second player can't make any move and loses. In his third test, cycles have 1, 2 and 3 vertices. Like last test, no one can make a move on the first cycle. First player can replace the third cycle with one cycle with size 1 and one with size 2. Now cycles have 1, 1, 2, 2 vertices. Second player's only move is to replace a cycle of size 2 with 2 cycles of size 1. And cycles are 1, 1, 1, 1, 2. First player replaces the last cycle with 2 cycles with size 1 and wins. In the second sample test: Having cycles of size 1 is like not having them (because no one can make a move on them). In Peter's third test: There a cycle of size 5 (others don't matter). First player has two options: replace it with cycles of sizes 1 and 4 or 2 and 3. * If he replaces it with cycles of sizes 1 and 4: Only second cycle matters. Second player will replace it with 2 cycles of sizes 2. First player's only option to replace one of them with two cycles of size 1. Second player does the same thing with the other cycle. First player can't make any move and loses. * If he replaces it with cycles of sizes 2 and 3: Second player will replace the cycle of size 3 with two of sizes 1 and 2. Now only cycles with more than one vertex are two cycles of size 2. As shown in previous case, with 2 cycles of size 2 second player wins. So, either way first player loses.
instruction
0
51,774
19
103,548
Tags: games, math Correct Solution: ``` a=int(input()) x=list(map(int,input().split())) last=0 for i in range(a): last+=x[i]-1 if last%2: print(1) else: print(2) ```
output
1
51,774
19
103,549
Provide tags and a correct Python 3 solution for this coding contest problem. Peter Parker wants to play a game with Dr. Octopus. The game is about cycles. Cycle is a sequence of vertices, such that first one is connected with the second, second is connected with third and so on, while the last one is connected with the first one again. Cycle may consist of a single isolated vertex. Initially there are k cycles, i-th of them consisting of exactly vi vertices. Players play alternatively. Peter goes first. On each turn a player must choose a cycle with at least 2 vertices (for example, x vertices) among all available cycles and replace it by two cycles with p and x - p vertices where 1 ≤ p < x is chosen by the player. The player who cannot make a move loses the game (and his life!). Peter wants to test some configurations of initial cycle sets before he actually plays with Dr. Octopus. Initially he has an empty set. In the i-th test he adds a cycle with ai vertices to the set (this is actually a multiset because it can contain two or more identical cycles). After each test, Peter wants to know that if the players begin the game with the current set of cycles, who wins? Peter is pretty good at math, but now he asks you to help. Input The first line of the input contains a single integer n (1 ≤ n ≤ 100 000) — the number of tests Peter is about to make. The second line contains n space separated integers a1, a2, ..., an (1 ≤ ai ≤ 109), i-th of them stands for the number of vertices in the cycle added before the i-th test. Output Print the result of all tests in order they are performed. Print 1 if the player who moves first wins or 2 otherwise. Examples Input 3 1 2 3 Output 2 1 1 Input 5 1 1 5 1 1 Output 2 2 2 2 2 Note In the first sample test: In Peter's first test, there's only one cycle with 1 vertex. First player cannot make a move and loses. In his second test, there's one cycle with 1 vertex and one with 2. No one can make a move on the cycle with 1 vertex. First player can replace the second cycle with two cycles of 1 vertex and second player can't make any move and loses. In his third test, cycles have 1, 2 and 3 vertices. Like last test, no one can make a move on the first cycle. First player can replace the third cycle with one cycle with size 1 and one with size 2. Now cycles have 1, 1, 2, 2 vertices. Second player's only move is to replace a cycle of size 2 with 2 cycles of size 1. And cycles are 1, 1, 1, 1, 2. First player replaces the last cycle with 2 cycles with size 1 and wins. In the second sample test: Having cycles of size 1 is like not having them (because no one can make a move on them). In Peter's third test: There a cycle of size 5 (others don't matter). First player has two options: replace it with cycles of sizes 1 and 4 or 2 and 3. * If he replaces it with cycles of sizes 1 and 4: Only second cycle matters. Second player will replace it with 2 cycles of sizes 2. First player's only option to replace one of them with two cycles of size 1. Second player does the same thing with the other cycle. First player can't make any move and loses. * If he replaces it with cycles of sizes 2 and 3: Second player will replace the cycle of size 3 with two of sizes 1 and 2. Now only cycles with more than one vertex are two cycles of size 2. As shown in previous case, with 2 cycles of size 2 second player wins. So, either way first player loses.
instruction
0
51,775
19
103,550
Tags: games, math Correct Solution: ``` n = int(input()) arr = list(map(int, input().split())) s = 0 for i in range(n): s += arr[i] -1 if s % 2 == 1: print(1) else: print(2) ```
output
1
51,775
19
103,551
Provide tags and a correct Python 3 solution for this coding contest problem. Peter Parker wants to play a game with Dr. Octopus. The game is about cycles. Cycle is a sequence of vertices, such that first one is connected with the second, second is connected with third and so on, while the last one is connected with the first one again. Cycle may consist of a single isolated vertex. Initially there are k cycles, i-th of them consisting of exactly vi vertices. Players play alternatively. Peter goes first. On each turn a player must choose a cycle with at least 2 vertices (for example, x vertices) among all available cycles and replace it by two cycles with p and x - p vertices where 1 ≤ p < x is chosen by the player. The player who cannot make a move loses the game (and his life!). Peter wants to test some configurations of initial cycle sets before he actually plays with Dr. Octopus. Initially he has an empty set. In the i-th test he adds a cycle with ai vertices to the set (this is actually a multiset because it can contain two or more identical cycles). After each test, Peter wants to know that if the players begin the game with the current set of cycles, who wins? Peter is pretty good at math, but now he asks you to help. Input The first line of the input contains a single integer n (1 ≤ n ≤ 100 000) — the number of tests Peter is about to make. The second line contains n space separated integers a1, a2, ..., an (1 ≤ ai ≤ 109), i-th of them stands for the number of vertices in the cycle added before the i-th test. Output Print the result of all tests in order they are performed. Print 1 if the player who moves first wins or 2 otherwise. Examples Input 3 1 2 3 Output 2 1 1 Input 5 1 1 5 1 1 Output 2 2 2 2 2 Note In the first sample test: In Peter's first test, there's only one cycle with 1 vertex. First player cannot make a move and loses. In his second test, there's one cycle with 1 vertex and one with 2. No one can make a move on the cycle with 1 vertex. First player can replace the second cycle with two cycles of 1 vertex and second player can't make any move and loses. In his third test, cycles have 1, 2 and 3 vertices. Like last test, no one can make a move on the first cycle. First player can replace the third cycle with one cycle with size 1 and one with size 2. Now cycles have 1, 1, 2, 2 vertices. Second player's only move is to replace a cycle of size 2 with 2 cycles of size 1. And cycles are 1, 1, 1, 1, 2. First player replaces the last cycle with 2 cycles with size 1 and wins. In the second sample test: Having cycles of size 1 is like not having them (because no one can make a move on them). In Peter's third test: There a cycle of size 5 (others don't matter). First player has two options: replace it with cycles of sizes 1 and 4 or 2 and 3. * If he replaces it with cycles of sizes 1 and 4: Only second cycle matters. Second player will replace it with 2 cycles of sizes 2. First player's only option to replace one of them with two cycles of size 1. Second player does the same thing with the other cycle. First player can't make any move and loses. * If he replaces it with cycles of sizes 2 and 3: Second player will replace the cycle of size 3 with two of sizes 1 and 2. Now only cycles with more than one vertex are two cycles of size 2. As shown in previous case, with 2 cycles of size 2 second player wins. So, either way first player loses.
instruction
0
51,776
19
103,552
Tags: games, math Correct Solution: ``` n = int(input()) arr = list(map(int, input().split())) win = 2 # who wins turn = 1 for i in range(n): if arr[i] != 1: if arr[i] % 2 == 1: print(3 - turn) else: turn = 3 - turn print(3 - turn) else: print(3 - turn) ```
output
1
51,776
19
103,553
Provide tags and a correct Python 3 solution for this coding contest problem. Peter Parker wants to play a game with Dr. Octopus. The game is about cycles. Cycle is a sequence of vertices, such that first one is connected with the second, second is connected with third and so on, while the last one is connected with the first one again. Cycle may consist of a single isolated vertex. Initially there are k cycles, i-th of them consisting of exactly vi vertices. Players play alternatively. Peter goes first. On each turn a player must choose a cycle with at least 2 vertices (for example, x vertices) among all available cycles and replace it by two cycles with p and x - p vertices where 1 ≤ p < x is chosen by the player. The player who cannot make a move loses the game (and his life!). Peter wants to test some configurations of initial cycle sets before he actually plays with Dr. Octopus. Initially he has an empty set. In the i-th test he adds a cycle with ai vertices to the set (this is actually a multiset because it can contain two or more identical cycles). After each test, Peter wants to know that if the players begin the game with the current set of cycles, who wins? Peter is pretty good at math, but now he asks you to help. Input The first line of the input contains a single integer n (1 ≤ n ≤ 100 000) — the number of tests Peter is about to make. The second line contains n space separated integers a1, a2, ..., an (1 ≤ ai ≤ 109), i-th of them stands for the number of vertices in the cycle added before the i-th test. Output Print the result of all tests in order they are performed. Print 1 if the player who moves first wins or 2 otherwise. Examples Input 3 1 2 3 Output 2 1 1 Input 5 1 1 5 1 1 Output 2 2 2 2 2 Note In the first sample test: In Peter's first test, there's only one cycle with 1 vertex. First player cannot make a move and loses. In his second test, there's one cycle with 1 vertex and one with 2. No one can make a move on the cycle with 1 vertex. First player can replace the second cycle with two cycles of 1 vertex and second player can't make any move and loses. In his third test, cycles have 1, 2 and 3 vertices. Like last test, no one can make a move on the first cycle. First player can replace the third cycle with one cycle with size 1 and one with size 2. Now cycles have 1, 1, 2, 2 vertices. Second player's only move is to replace a cycle of size 2 with 2 cycles of size 1. And cycles are 1, 1, 1, 1, 2. First player replaces the last cycle with 2 cycles with size 1 and wins. In the second sample test: Having cycles of size 1 is like not having them (because no one can make a move on them). In Peter's third test: There a cycle of size 5 (others don't matter). First player has two options: replace it with cycles of sizes 1 and 4 or 2 and 3. * If he replaces it with cycles of sizes 1 and 4: Only second cycle matters. Second player will replace it with 2 cycles of sizes 2. First player's only option to replace one of them with two cycles of size 1. Second player does the same thing with the other cycle. First player can't make any move and loses. * If he replaces it with cycles of sizes 2 and 3: Second player will replace the cycle of size 3 with two of sizes 1 and 2. Now only cycles with more than one vertex are two cycles of size 2. As shown in previous case, with 2 cycles of size 2 second player wins. So, either way first player loses.
instruction
0
51,777
19
103,554
Tags: games, math Correct Solution: ``` t = int(input()) tests = [int(i) for i in input().split()] current = [] am = 0 for i in range(t): if tests[i] % 2 == 0: am += 1 if am % 2 == 0: print(2) else: print(1) ```
output
1
51,777
19
103,555
Provide tags and a correct Python 3 solution for this coding contest problem. Peter Parker wants to play a game with Dr. Octopus. The game is about cycles. Cycle is a sequence of vertices, such that first one is connected with the second, second is connected with third and so on, while the last one is connected with the first one again. Cycle may consist of a single isolated vertex. Initially there are k cycles, i-th of them consisting of exactly vi vertices. Players play alternatively. Peter goes first. On each turn a player must choose a cycle with at least 2 vertices (for example, x vertices) among all available cycles and replace it by two cycles with p and x - p vertices where 1 ≤ p < x is chosen by the player. The player who cannot make a move loses the game (and his life!). Peter wants to test some configurations of initial cycle sets before he actually plays with Dr. Octopus. Initially he has an empty set. In the i-th test he adds a cycle with ai vertices to the set (this is actually a multiset because it can contain two or more identical cycles). After each test, Peter wants to know that if the players begin the game with the current set of cycles, who wins? Peter is pretty good at math, but now he asks you to help. Input The first line of the input contains a single integer n (1 ≤ n ≤ 100 000) — the number of tests Peter is about to make. The second line contains n space separated integers a1, a2, ..., an (1 ≤ ai ≤ 109), i-th of them stands for the number of vertices in the cycle added before the i-th test. Output Print the result of all tests in order they are performed. Print 1 if the player who moves first wins or 2 otherwise. Examples Input 3 1 2 3 Output 2 1 1 Input 5 1 1 5 1 1 Output 2 2 2 2 2 Note In the first sample test: In Peter's first test, there's only one cycle with 1 vertex. First player cannot make a move and loses. In his second test, there's one cycle with 1 vertex and one with 2. No one can make a move on the cycle with 1 vertex. First player can replace the second cycle with two cycles of 1 vertex and second player can't make any move and loses. In his third test, cycles have 1, 2 and 3 vertices. Like last test, no one can make a move on the first cycle. First player can replace the third cycle with one cycle with size 1 and one with size 2. Now cycles have 1, 1, 2, 2 vertices. Second player's only move is to replace a cycle of size 2 with 2 cycles of size 1. And cycles are 1, 1, 1, 1, 2. First player replaces the last cycle with 2 cycles with size 1 and wins. In the second sample test: Having cycles of size 1 is like not having them (because no one can make a move on them). In Peter's third test: There a cycle of size 5 (others don't matter). First player has two options: replace it with cycles of sizes 1 and 4 or 2 and 3. * If he replaces it with cycles of sizes 1 and 4: Only second cycle matters. Second player will replace it with 2 cycles of sizes 2. First player's only option to replace one of them with two cycles of size 1. Second player does the same thing with the other cycle. First player can't make any move and loses. * If he replaces it with cycles of sizes 2 and 3: Second player will replace the cycle of size 3 with two of sizes 1 and 2. Now only cycles with more than one vertex are two cycles of size 2. As shown in previous case, with 2 cycles of size 2 second player wins. So, either way first player loses.
instruction
0
51,778
19
103,556
Tags: games, math Correct Solution: ``` n = int(input()) a = [int(i) for i in input().split(' ')] sum = 0 for x in range(n): sum += a[x] b = sum - x print ((b % 2)+1) ```
output
1
51,778
19
103,557
Provide tags and a correct Python 3 solution for this coding contest problem. Peter Parker wants to play a game with Dr. Octopus. The game is about cycles. Cycle is a sequence of vertices, such that first one is connected with the second, second is connected with third and so on, while the last one is connected with the first one again. Cycle may consist of a single isolated vertex. Initially there are k cycles, i-th of them consisting of exactly vi vertices. Players play alternatively. Peter goes first. On each turn a player must choose a cycle with at least 2 vertices (for example, x vertices) among all available cycles and replace it by two cycles with p and x - p vertices where 1 ≤ p < x is chosen by the player. The player who cannot make a move loses the game (and his life!). Peter wants to test some configurations of initial cycle sets before he actually plays with Dr. Octopus. Initially he has an empty set. In the i-th test he adds a cycle with ai vertices to the set (this is actually a multiset because it can contain two or more identical cycles). After each test, Peter wants to know that if the players begin the game with the current set of cycles, who wins? Peter is pretty good at math, but now he asks you to help. Input The first line of the input contains a single integer n (1 ≤ n ≤ 100 000) — the number of tests Peter is about to make. The second line contains n space separated integers a1, a2, ..., an (1 ≤ ai ≤ 109), i-th of them stands for the number of vertices in the cycle added before the i-th test. Output Print the result of all tests in order they are performed. Print 1 if the player who moves first wins or 2 otherwise. Examples Input 3 1 2 3 Output 2 1 1 Input 5 1 1 5 1 1 Output 2 2 2 2 2 Note In the first sample test: In Peter's first test, there's only one cycle with 1 vertex. First player cannot make a move and loses. In his second test, there's one cycle with 1 vertex and one with 2. No one can make a move on the cycle with 1 vertex. First player can replace the second cycle with two cycles of 1 vertex and second player can't make any move and loses. In his third test, cycles have 1, 2 and 3 vertices. Like last test, no one can make a move on the first cycle. First player can replace the third cycle with one cycle with size 1 and one with size 2. Now cycles have 1, 1, 2, 2 vertices. Second player's only move is to replace a cycle of size 2 with 2 cycles of size 1. And cycles are 1, 1, 1, 1, 2. First player replaces the last cycle with 2 cycles with size 1 and wins. In the second sample test: Having cycles of size 1 is like not having them (because no one can make a move on them). In Peter's third test: There a cycle of size 5 (others don't matter). First player has two options: replace it with cycles of sizes 1 and 4 or 2 and 3. * If he replaces it with cycles of sizes 1 and 4: Only second cycle matters. Second player will replace it with 2 cycles of sizes 2. First player's only option to replace one of them with two cycles of size 1. Second player does the same thing with the other cycle. First player can't make any move and loses. * If he replaces it with cycles of sizes 2 and 3: Second player will replace the cycle of size 3 with two of sizes 1 and 2. Now only cycles with more than one vertex are two cycles of size 2. As shown in previous case, with 2 cycles of size 2 second player wins. So, either way first player loses.
instruction
0
51,779
19
103,558
Tags: games, math Correct Solution: ``` #Ami ekta bokchod n =int(input()) a=list(map(int,input().split())) b=2 for i in a: if i % 2 == 0: b=3-b print(b) ```
output
1
51,779
19
103,559
Provide tags and a correct Python 3 solution for this coding contest problem. Peter Parker wants to play a game with Dr. Octopus. The game is about cycles. Cycle is a sequence of vertices, such that first one is connected with the second, second is connected with third and so on, while the last one is connected with the first one again. Cycle may consist of a single isolated vertex. Initially there are k cycles, i-th of them consisting of exactly vi vertices. Players play alternatively. Peter goes first. On each turn a player must choose a cycle with at least 2 vertices (for example, x vertices) among all available cycles and replace it by two cycles with p and x - p vertices where 1 ≤ p < x is chosen by the player. The player who cannot make a move loses the game (and his life!). Peter wants to test some configurations of initial cycle sets before he actually plays with Dr. Octopus. Initially he has an empty set. In the i-th test he adds a cycle with ai vertices to the set (this is actually a multiset because it can contain two or more identical cycles). After each test, Peter wants to know that if the players begin the game with the current set of cycles, who wins? Peter is pretty good at math, but now he asks you to help. Input The first line of the input contains a single integer n (1 ≤ n ≤ 100 000) — the number of tests Peter is about to make. The second line contains n space separated integers a1, a2, ..., an (1 ≤ ai ≤ 109), i-th of them stands for the number of vertices in the cycle added before the i-th test. Output Print the result of all tests in order they are performed. Print 1 if the player who moves first wins or 2 otherwise. Examples Input 3 1 2 3 Output 2 1 1 Input 5 1 1 5 1 1 Output 2 2 2 2 2 Note In the first sample test: In Peter's first test, there's only one cycle with 1 vertex. First player cannot make a move and loses. In his second test, there's one cycle with 1 vertex and one with 2. No one can make a move on the cycle with 1 vertex. First player can replace the second cycle with two cycles of 1 vertex and second player can't make any move and loses. In his third test, cycles have 1, 2 and 3 vertices. Like last test, no one can make a move on the first cycle. First player can replace the third cycle with one cycle with size 1 and one with size 2. Now cycles have 1, 1, 2, 2 vertices. Second player's only move is to replace a cycle of size 2 with 2 cycles of size 1. And cycles are 1, 1, 1, 1, 2. First player replaces the last cycle with 2 cycles with size 1 and wins. In the second sample test: Having cycles of size 1 is like not having them (because no one can make a move on them). In Peter's third test: There a cycle of size 5 (others don't matter). First player has two options: replace it with cycles of sizes 1 and 4 or 2 and 3. * If he replaces it with cycles of sizes 1 and 4: Only second cycle matters. Second player will replace it with 2 cycles of sizes 2. First player's only option to replace one of them with two cycles of size 1. Second player does the same thing with the other cycle. First player can't make any move and loses. * If he replaces it with cycles of sizes 2 and 3: Second player will replace the cycle of size 3 with two of sizes 1 and 2. Now only cycles with more than one vertex are two cycles of size 2. As shown in previous case, with 2 cycles of size 2 second player wins. So, either way first player loses.
instruction
0
51,780
19
103,560
Tags: games, math Correct Solution: ``` def main(): n=int(input()) t=list(map(int, input().split())) somme=0 for i in range(len(t)): somme+=t[i]-1 if somme%2==0: print(2) else: print(1) main() ```
output
1
51,780
19
103,561
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Peter Parker wants to play a game with Dr. Octopus. The game is about cycles. Cycle is a sequence of vertices, such that first one is connected with the second, second is connected with third and so on, while the last one is connected with the first one again. Cycle may consist of a single isolated vertex. Initially there are k cycles, i-th of them consisting of exactly vi vertices. Players play alternatively. Peter goes first. On each turn a player must choose a cycle with at least 2 vertices (for example, x vertices) among all available cycles and replace it by two cycles with p and x - p vertices where 1 ≤ p < x is chosen by the player. The player who cannot make a move loses the game (and his life!). Peter wants to test some configurations of initial cycle sets before he actually plays with Dr. Octopus. Initially he has an empty set. In the i-th test he adds a cycle with ai vertices to the set (this is actually a multiset because it can contain two or more identical cycles). After each test, Peter wants to know that if the players begin the game with the current set of cycles, who wins? Peter is pretty good at math, but now he asks you to help. Input The first line of the input contains a single integer n (1 ≤ n ≤ 100 000) — the number of tests Peter is about to make. The second line contains n space separated integers a1, a2, ..., an (1 ≤ ai ≤ 109), i-th of them stands for the number of vertices in the cycle added before the i-th test. Output Print the result of all tests in order they are performed. Print 1 if the player who moves first wins or 2 otherwise. Examples Input 3 1 2 3 Output 2 1 1 Input 5 1 1 5 1 1 Output 2 2 2 2 2 Note In the first sample test: In Peter's first test, there's only one cycle with 1 vertex. First player cannot make a move and loses. In his second test, there's one cycle with 1 vertex and one with 2. No one can make a move on the cycle with 1 vertex. First player can replace the second cycle with two cycles of 1 vertex and second player can't make any move and loses. In his third test, cycles have 1, 2 and 3 vertices. Like last test, no one can make a move on the first cycle. First player can replace the third cycle with one cycle with size 1 and one with size 2. Now cycles have 1, 1, 2, 2 vertices. Second player's only move is to replace a cycle of size 2 with 2 cycles of size 1. And cycles are 1, 1, 1, 1, 2. First player replaces the last cycle with 2 cycles with size 1 and wins. In the second sample test: Having cycles of size 1 is like not having them (because no one can make a move on them). In Peter's third test: There a cycle of size 5 (others don't matter). First player has two options: replace it with cycles of sizes 1 and 4 or 2 and 3. * If he replaces it with cycles of sizes 1 and 4: Only second cycle matters. Second player will replace it with 2 cycles of sizes 2. First player's only option to replace one of them with two cycles of size 1. Second player does the same thing with the other cycle. First player can't make any move and loses. * If he replaces it with cycles of sizes 2 and 3: Second player will replace the cycle of size 3 with two of sizes 1 and 2. Now only cycles with more than one vertex are two cycles of size 2. As shown in previous case, with 2 cycles of size 2 second player wins. So, either way first player loses. Submitted Solution: ``` n=int(input()) a=list(map(int,input().split())) k=0 c=2 if a[0]%2==1: print(c) else: c-=1 print(c) for i in range(1,n): if a[i]%2==0: if c==1: c=2 print(c) else: c=1 print(c) else: print(c) ```
instruction
0
51,781
19
103,562
Yes
output
1
51,781
19
103,563
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Peter Parker wants to play a game with Dr. Octopus. The game is about cycles. Cycle is a sequence of vertices, such that first one is connected with the second, second is connected with third and so on, while the last one is connected with the first one again. Cycle may consist of a single isolated vertex. Initially there are k cycles, i-th of them consisting of exactly vi vertices. Players play alternatively. Peter goes first. On each turn a player must choose a cycle with at least 2 vertices (for example, x vertices) among all available cycles and replace it by two cycles with p and x - p vertices where 1 ≤ p < x is chosen by the player. The player who cannot make a move loses the game (and his life!). Peter wants to test some configurations of initial cycle sets before he actually plays with Dr. Octopus. Initially he has an empty set. In the i-th test he adds a cycle with ai vertices to the set (this is actually a multiset because it can contain two or more identical cycles). After each test, Peter wants to know that if the players begin the game with the current set of cycles, who wins? Peter is pretty good at math, but now he asks you to help. Input The first line of the input contains a single integer n (1 ≤ n ≤ 100 000) — the number of tests Peter is about to make. The second line contains n space separated integers a1, a2, ..., an (1 ≤ ai ≤ 109), i-th of them stands for the number of vertices in the cycle added before the i-th test. Output Print the result of all tests in order they are performed. Print 1 if the player who moves first wins or 2 otherwise. Examples Input 3 1 2 3 Output 2 1 1 Input 5 1 1 5 1 1 Output 2 2 2 2 2 Note In the first sample test: In Peter's first test, there's only one cycle with 1 vertex. First player cannot make a move and loses. In his second test, there's one cycle with 1 vertex and one with 2. No one can make a move on the cycle with 1 vertex. First player can replace the second cycle with two cycles of 1 vertex and second player can't make any move and loses. In his third test, cycles have 1, 2 and 3 vertices. Like last test, no one can make a move on the first cycle. First player can replace the third cycle with one cycle with size 1 and one with size 2. Now cycles have 1, 1, 2, 2 vertices. Second player's only move is to replace a cycle of size 2 with 2 cycles of size 1. And cycles are 1, 1, 1, 1, 2. First player replaces the last cycle with 2 cycles with size 1 and wins. In the second sample test: Having cycles of size 1 is like not having them (because no one can make a move on them). In Peter's third test: There a cycle of size 5 (others don't matter). First player has two options: replace it with cycles of sizes 1 and 4 or 2 and 3. * If he replaces it with cycles of sizes 1 and 4: Only second cycle matters. Second player will replace it with 2 cycles of sizes 2. First player's only option to replace one of them with two cycles of size 1. Second player does the same thing with the other cycle. First player can't make any move and loses. * If he replaces it with cycles of sizes 2 and 3: Second player will replace the cycle of size 3 with two of sizes 1 and 2. Now only cycles with more than one vertex are two cycles of size 2. As shown in previous case, with 2 cycles of size 2 second player wins. So, either way first player loses. Submitted Solution: ``` n = int(input()) a = list(map(int, input().split())) answer = 0 for i in range(n): a[i] %= 2 answer = 1 - a[0] print(2 - answer) for i in a[1:]: if answer == i: answer = 1 print(2 - answer) else: answer = 0 print(2 - answer) ```
instruction
0
51,782
19
103,564
Yes
output
1
51,782
19
103,565
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Peter Parker wants to play a game with Dr. Octopus. The game is about cycles. Cycle is a sequence of vertices, such that first one is connected with the second, second is connected with third and so on, while the last one is connected with the first one again. Cycle may consist of a single isolated vertex. Initially there are k cycles, i-th of them consisting of exactly vi vertices. Players play alternatively. Peter goes first. On each turn a player must choose a cycle with at least 2 vertices (for example, x vertices) among all available cycles and replace it by two cycles with p and x - p vertices where 1 ≤ p < x is chosen by the player. The player who cannot make a move loses the game (and his life!). Peter wants to test some configurations of initial cycle sets before he actually plays with Dr. Octopus. Initially he has an empty set. In the i-th test he adds a cycle with ai vertices to the set (this is actually a multiset because it can contain two or more identical cycles). After each test, Peter wants to know that if the players begin the game with the current set of cycles, who wins? Peter is pretty good at math, but now he asks you to help. Input The first line of the input contains a single integer n (1 ≤ n ≤ 100 000) — the number of tests Peter is about to make. The second line contains n space separated integers a1, a2, ..., an (1 ≤ ai ≤ 109), i-th of them stands for the number of vertices in the cycle added before the i-th test. Output Print the result of all tests in order they are performed. Print 1 if the player who moves first wins or 2 otherwise. Examples Input 3 1 2 3 Output 2 1 1 Input 5 1 1 5 1 1 Output 2 2 2 2 2 Note In the first sample test: In Peter's first test, there's only one cycle with 1 vertex. First player cannot make a move and loses. In his second test, there's one cycle with 1 vertex and one with 2. No one can make a move on the cycle with 1 vertex. First player can replace the second cycle with two cycles of 1 vertex and second player can't make any move and loses. In his third test, cycles have 1, 2 and 3 vertices. Like last test, no one can make a move on the first cycle. First player can replace the third cycle with one cycle with size 1 and one with size 2. Now cycles have 1, 1, 2, 2 vertices. Second player's only move is to replace a cycle of size 2 with 2 cycles of size 1. And cycles are 1, 1, 1, 1, 2. First player replaces the last cycle with 2 cycles with size 1 and wins. In the second sample test: Having cycles of size 1 is like not having them (because no one can make a move on them). In Peter's third test: There a cycle of size 5 (others don't matter). First player has two options: replace it with cycles of sizes 1 and 4 or 2 and 3. * If he replaces it with cycles of sizes 1 and 4: Only second cycle matters. Second player will replace it with 2 cycles of sizes 2. First player's only option to replace one of them with two cycles of size 1. Second player does the same thing with the other cycle. First player can't make any move and loses. * If he replaces it with cycles of sizes 2 and 3: Second player will replace the cycle of size 3 with two of sizes 1 and 2. Now only cycles with more than one vertex are two cycles of size 2. As shown in previous case, with 2 cycles of size 2 second player wins. So, either way first player loses. Submitted Solution: ``` n = int(input()) sum = 0 l = list(map(int,input().split())) for x in l: sum += x-1 if sum&1: print(1) else: print (2) ```
instruction
0
51,783
19
103,566
Yes
output
1
51,783
19
103,567
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Peter Parker wants to play a game with Dr. Octopus. The game is about cycles. Cycle is a sequence of vertices, such that first one is connected with the second, second is connected with third and so on, while the last one is connected with the first one again. Cycle may consist of a single isolated vertex. Initially there are k cycles, i-th of them consisting of exactly vi vertices. Players play alternatively. Peter goes first. On each turn a player must choose a cycle with at least 2 vertices (for example, x vertices) among all available cycles and replace it by two cycles with p and x - p vertices where 1 ≤ p < x is chosen by the player. The player who cannot make a move loses the game (and his life!). Peter wants to test some configurations of initial cycle sets before he actually plays with Dr. Octopus. Initially he has an empty set. In the i-th test he adds a cycle with ai vertices to the set (this is actually a multiset because it can contain two or more identical cycles). After each test, Peter wants to know that if the players begin the game with the current set of cycles, who wins? Peter is pretty good at math, but now he asks you to help. Input The first line of the input contains a single integer n (1 ≤ n ≤ 100 000) — the number of tests Peter is about to make. The second line contains n space separated integers a1, a2, ..., an (1 ≤ ai ≤ 109), i-th of them stands for the number of vertices in the cycle added before the i-th test. Output Print the result of all tests in order they are performed. Print 1 if the player who moves first wins or 2 otherwise. Examples Input 3 1 2 3 Output 2 1 1 Input 5 1 1 5 1 1 Output 2 2 2 2 2 Note In the first sample test: In Peter's first test, there's only one cycle with 1 vertex. First player cannot make a move and loses. In his second test, there's one cycle with 1 vertex and one with 2. No one can make a move on the cycle with 1 vertex. First player can replace the second cycle with two cycles of 1 vertex and second player can't make any move and loses. In his third test, cycles have 1, 2 and 3 vertices. Like last test, no one can make a move on the first cycle. First player can replace the third cycle with one cycle with size 1 and one with size 2. Now cycles have 1, 1, 2, 2 vertices. Second player's only move is to replace a cycle of size 2 with 2 cycles of size 1. And cycles are 1, 1, 1, 1, 2. First player replaces the last cycle with 2 cycles with size 1 and wins. In the second sample test: Having cycles of size 1 is like not having them (because no one can make a move on them). In Peter's third test: There a cycle of size 5 (others don't matter). First player has two options: replace it with cycles of sizes 1 and 4 or 2 and 3. * If he replaces it with cycles of sizes 1 and 4: Only second cycle matters. Second player will replace it with 2 cycles of sizes 2. First player's only option to replace one of them with two cycles of size 1. Second player does the same thing with the other cycle. First player can't make any move and loses. * If he replaces it with cycles of sizes 2 and 3: Second player will replace the cycle of size 3 with two of sizes 1 and 2. Now only cycles with more than one vertex are two cycles of size 2. As shown in previous case, with 2 cycles of size 2 second player wins. So, either way first player loses. Submitted Solution: ``` n=input() i=0 for k in input().split(" "): i+=int(k)-1 if(i%2==0): print(2) else: print(1) ```
instruction
0
51,784
19
103,568
Yes
output
1
51,784
19
103,569
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Peter Parker wants to play a game with Dr. Octopus. The game is about cycles. Cycle is a sequence of vertices, such that first one is connected with the second, second is connected with third and so on, while the last one is connected with the first one again. Cycle may consist of a single isolated vertex. Initially there are k cycles, i-th of them consisting of exactly vi vertices. Players play alternatively. Peter goes first. On each turn a player must choose a cycle with at least 2 vertices (for example, x vertices) among all available cycles and replace it by two cycles with p and x - p vertices where 1 ≤ p < x is chosen by the player. The player who cannot make a move loses the game (and his life!). Peter wants to test some configurations of initial cycle sets before he actually plays with Dr. Octopus. Initially he has an empty set. In the i-th test he adds a cycle with ai vertices to the set (this is actually a multiset because it can contain two or more identical cycles). After each test, Peter wants to know that if the players begin the game with the current set of cycles, who wins? Peter is pretty good at math, but now he asks you to help. Input The first line of the input contains a single integer n (1 ≤ n ≤ 100 000) — the number of tests Peter is about to make. The second line contains n space separated integers a1, a2, ..., an (1 ≤ ai ≤ 109), i-th of them stands for the number of vertices in the cycle added before the i-th test. Output Print the result of all tests in order they are performed. Print 1 if the player who moves first wins or 2 otherwise. Examples Input 3 1 2 3 Output 2 1 1 Input 5 1 1 5 1 1 Output 2 2 2 2 2 Note In the first sample test: In Peter's first test, there's only one cycle with 1 vertex. First player cannot make a move and loses. In his second test, there's one cycle with 1 vertex and one with 2. No one can make a move on the cycle with 1 vertex. First player can replace the second cycle with two cycles of 1 vertex and second player can't make any move and loses. In his third test, cycles have 1, 2 and 3 vertices. Like last test, no one can make a move on the first cycle. First player can replace the third cycle with one cycle with size 1 and one with size 2. Now cycles have 1, 1, 2, 2 vertices. Second player's only move is to replace a cycle of size 2 with 2 cycles of size 1. And cycles are 1, 1, 1, 1, 2. First player replaces the last cycle with 2 cycles with size 1 and wins. In the second sample test: Having cycles of size 1 is like not having them (because no one can make a move on them). In Peter's third test: There a cycle of size 5 (others don't matter). First player has two options: replace it with cycles of sizes 1 and 4 or 2 and 3. * If he replaces it with cycles of sizes 1 and 4: Only second cycle matters. Second player will replace it with 2 cycles of sizes 2. First player's only option to replace one of them with two cycles of size 1. Second player does the same thing with the other cycle. First player can't make any move and loses. * If he replaces it with cycles of sizes 2 and 3: Second player will replace the cycle of size 3 with two of sizes 1 and 2. Now only cycles with more than one vertex are two cycles of size 2. As shown in previous case, with 2 cycles of size 2 second player wins. So, either way first player loses. Submitted Solution: ``` n=int(input()) a=list(map(int,input().split())) x=0 for i in range(n): if a[i]==2: x+=1 elif a[i]>2: x+=2*(a[i]//2) print(1 if x%2!=0 else 2) ```
instruction
0
51,785
19
103,570
No
output
1
51,785
19
103,571
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Peter Parker wants to play a game with Dr. Octopus. The game is about cycles. Cycle is a sequence of vertices, such that first one is connected with the second, second is connected with third and so on, while the last one is connected with the first one again. Cycle may consist of a single isolated vertex. Initially there are k cycles, i-th of them consisting of exactly vi vertices. Players play alternatively. Peter goes first. On each turn a player must choose a cycle with at least 2 vertices (for example, x vertices) among all available cycles and replace it by two cycles with p and x - p vertices where 1 ≤ p < x is chosen by the player. The player who cannot make a move loses the game (and his life!). Peter wants to test some configurations of initial cycle sets before he actually plays with Dr. Octopus. Initially he has an empty set. In the i-th test he adds a cycle with ai vertices to the set (this is actually a multiset because it can contain two or more identical cycles). After each test, Peter wants to know that if the players begin the game with the current set of cycles, who wins? Peter is pretty good at math, but now he asks you to help. Input The first line of the input contains a single integer n (1 ≤ n ≤ 100 000) — the number of tests Peter is about to make. The second line contains n space separated integers a1, a2, ..., an (1 ≤ ai ≤ 109), i-th of them stands for the number of vertices in the cycle added before the i-th test. Output Print the result of all tests in order they are performed. Print 1 if the player who moves first wins or 2 otherwise. Examples Input 3 1 2 3 Output 2 1 1 Input 5 1 1 5 1 1 Output 2 2 2 2 2 Note In the first sample test: In Peter's first test, there's only one cycle with 1 vertex. First player cannot make a move and loses. In his second test, there's one cycle with 1 vertex and one with 2. No one can make a move on the cycle with 1 vertex. First player can replace the second cycle with two cycles of 1 vertex and second player can't make any move and loses. In his third test, cycles have 1, 2 and 3 vertices. Like last test, no one can make a move on the first cycle. First player can replace the third cycle with one cycle with size 1 and one with size 2. Now cycles have 1, 1, 2, 2 vertices. Second player's only move is to replace a cycle of size 2 with 2 cycles of size 1. And cycles are 1, 1, 1, 1, 2. First player replaces the last cycle with 2 cycles with size 1 and wins. In the second sample test: Having cycles of size 1 is like not having them (because no one can make a move on them). In Peter's third test: There a cycle of size 5 (others don't matter). First player has two options: replace it with cycles of sizes 1 and 4 or 2 and 3. * If he replaces it with cycles of sizes 1 and 4: Only second cycle matters. Second player will replace it with 2 cycles of sizes 2. First player's only option to replace one of them with two cycles of size 1. Second player does the same thing with the other cycle. First player can't make any move and loses. * If he replaces it with cycles of sizes 2 and 3: Second player will replace the cycle of size 3 with two of sizes 1 and 2. Now only cycles with more than one vertex are two cycles of size 2. As shown in previous case, with 2 cycles of size 2 second player wins. So, either way first player loses. Submitted Solution: ``` n = int(input()) arr = input().split(' ') for i in range(n): if int(arr[i])%2 == 0 or int(arr[i]) == 3: print(1) else: print(2) ```
instruction
0
51,786
19
103,572
No
output
1
51,786
19
103,573
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Peter Parker wants to play a game with Dr. Octopus. The game is about cycles. Cycle is a sequence of vertices, such that first one is connected with the second, second is connected with third and so on, while the last one is connected with the first one again. Cycle may consist of a single isolated vertex. Initially there are k cycles, i-th of them consisting of exactly vi vertices. Players play alternatively. Peter goes first. On each turn a player must choose a cycle with at least 2 vertices (for example, x vertices) among all available cycles and replace it by two cycles with p and x - p vertices where 1 ≤ p < x is chosen by the player. The player who cannot make a move loses the game (and his life!). Peter wants to test some configurations of initial cycle sets before he actually plays with Dr. Octopus. Initially he has an empty set. In the i-th test he adds a cycle with ai vertices to the set (this is actually a multiset because it can contain two or more identical cycles). After each test, Peter wants to know that if the players begin the game with the current set of cycles, who wins? Peter is pretty good at math, but now he asks you to help. Input The first line of the input contains a single integer n (1 ≤ n ≤ 100 000) — the number of tests Peter is about to make. The second line contains n space separated integers a1, a2, ..., an (1 ≤ ai ≤ 109), i-th of them stands for the number of vertices in the cycle added before the i-th test. Output Print the result of all tests in order they are performed. Print 1 if the player who moves first wins or 2 otherwise. Examples Input 3 1 2 3 Output 2 1 1 Input 5 1 1 5 1 1 Output 2 2 2 2 2 Note In the first sample test: In Peter's first test, there's only one cycle with 1 vertex. First player cannot make a move and loses. In his second test, there's one cycle with 1 vertex and one with 2. No one can make a move on the cycle with 1 vertex. First player can replace the second cycle with two cycles of 1 vertex and second player can't make any move and loses. In his third test, cycles have 1, 2 and 3 vertices. Like last test, no one can make a move on the first cycle. First player can replace the third cycle with one cycle with size 1 and one with size 2. Now cycles have 1, 1, 2, 2 vertices. Second player's only move is to replace a cycle of size 2 with 2 cycles of size 1. And cycles are 1, 1, 1, 1, 2. First player replaces the last cycle with 2 cycles with size 1 and wins. In the second sample test: Having cycles of size 1 is like not having them (because no one can make a move on them). In Peter's third test: There a cycle of size 5 (others don't matter). First player has two options: replace it with cycles of sizes 1 and 4 or 2 and 3. * If he replaces it with cycles of sizes 1 and 4: Only second cycle matters. Second player will replace it with 2 cycles of sizes 2. First player's only option to replace one of them with two cycles of size 1. Second player does the same thing with the other cycle. First player can't make any move and loses. * If he replaces it with cycles of sizes 2 and 3: Second player will replace the cycle of size 3 with two of sizes 1 and 2. Now only cycles with more than one vertex are two cycles of size 2. As shown in previous case, with 2 cycles of size 2 second player wins. So, either way first player loses. Submitted Solution: ``` n = int(input()) li = list(map(int,input().split())) for i in li: #s = 0 if i-1%4 == 1 or i-1%4 == 2: s = "odd" print(1) elif i-1%4 == 0 or i-1%4==3: s = "even" print(2) ```
instruction
0
51,787
19
103,574
No
output
1
51,787
19
103,575
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Peter Parker wants to play a game with Dr. Octopus. The game is about cycles. Cycle is a sequence of vertices, such that first one is connected with the second, second is connected with third and so on, while the last one is connected with the first one again. Cycle may consist of a single isolated vertex. Initially there are k cycles, i-th of them consisting of exactly vi vertices. Players play alternatively. Peter goes first. On each turn a player must choose a cycle with at least 2 vertices (for example, x vertices) among all available cycles and replace it by two cycles with p and x - p vertices where 1 ≤ p < x is chosen by the player. The player who cannot make a move loses the game (and his life!). Peter wants to test some configurations of initial cycle sets before he actually plays with Dr. Octopus. Initially he has an empty set. In the i-th test he adds a cycle with ai vertices to the set (this is actually a multiset because it can contain two or more identical cycles). After each test, Peter wants to know that if the players begin the game with the current set of cycles, who wins? Peter is pretty good at math, but now he asks you to help. Input The first line of the input contains a single integer n (1 ≤ n ≤ 100 000) — the number of tests Peter is about to make. The second line contains n space separated integers a1, a2, ..., an (1 ≤ ai ≤ 109), i-th of them stands for the number of vertices in the cycle added before the i-th test. Output Print the result of all tests in order they are performed. Print 1 if the player who moves first wins or 2 otherwise. Examples Input 3 1 2 3 Output 2 1 1 Input 5 1 1 5 1 1 Output 2 2 2 2 2 Note In the first sample test: In Peter's first test, there's only one cycle with 1 vertex. First player cannot make a move and loses. In his second test, there's one cycle with 1 vertex and one with 2. No one can make a move on the cycle with 1 vertex. First player can replace the second cycle with two cycles of 1 vertex and second player can't make any move and loses. In his third test, cycles have 1, 2 and 3 vertices. Like last test, no one can make a move on the first cycle. First player can replace the third cycle with one cycle with size 1 and one with size 2. Now cycles have 1, 1, 2, 2 vertices. Second player's only move is to replace a cycle of size 2 with 2 cycles of size 1. And cycles are 1, 1, 1, 1, 2. First player replaces the last cycle with 2 cycles with size 1 and wins. In the second sample test: Having cycles of size 1 is like not having them (because no one can make a move on them). In Peter's third test: There a cycle of size 5 (others don't matter). First player has two options: replace it with cycles of sizes 1 and 4 or 2 and 3. * If he replaces it with cycles of sizes 1 and 4: Only second cycle matters. Second player will replace it with 2 cycles of sizes 2. First player's only option to replace one of them with two cycles of size 1. Second player does the same thing with the other cycle. First player can't make any move and loses. * If he replaces it with cycles of sizes 2 and 3: Second player will replace the cycle of size 3 with two of sizes 1 and 2. Now only cycles with more than one vertex are two cycles of size 2. As shown in previous case, with 2 cycles of size 2 second player wins. So, either way first player loses. Submitted Solution: ``` n = int(input()) a = [int(x) for x in input().split()] for x in a: f = x // 2 f += x % 2 if f == 2: print(1) else: print(2) ```
instruction
0
51,788
19
103,576
No
output
1
51,788
19
103,577
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Several years ago Tolya had n computer games and at some point of time he decided to burn them to CD. After that he wrote down the names of the games one after another in a circle on the CD in clockwise order. The names were distinct, the length of each name was equal to k. The names didn't overlap. Thus, there is a cyclic string of length n·k written on the CD. Several years have passed and now Tolya can't remember which games he burned to his CD. He knows that there were g popular games that days. All of the games he burned were among these g games, and no game was burned more than once. You have to restore any valid list of games Tolya could burn to the CD several years ago. Input The first line of the input contains two positive integers n and k (1 ≤ n ≤ 105, 1 ≤ k ≤ 105) — the amount of games Tolya burned to the CD, and the length of each of the names. The second line of the input contains one string consisting of lowercase English letters — the string Tolya wrote on the CD, split in arbitrary place. The length of the string is n·k. It is guaranteed that the length is not greater than 106. The third line of the input contains one positive integer g (n ≤ g ≤ 105) — the amount of popular games that could be written on the CD. It is guaranteed that the total length of names of all popular games is not greater than 2·106. Each of the next g lines contains a single string — the name of some popular game. Each name consists of lowercase English letters and has length k. It is guaranteed that the names are distinct. Output If there is no answer, print "NO" (without quotes). Otherwise, print two lines. In the first line print "YES" (without quotes). In the second line, print n integers — the games which names were written on the CD. You should print games in the order they could have been written on the CD, it means, in clockwise order. You can print games starting from any position. Remember, that no game was burned to the CD more than once. If there are several possible answers, print any of them. Examples Input 3 1 abc 4 b a c d Output YES 2 1 3 Input 4 2 aabbccdd 4 dd ab bc cd Output NO Submitted Solution: ``` m,n=list(map(int,input().split())) name=input() mas=[] inp=[] answer=[] f=0 for i in range(len(name)//n): mas.append(name[i*n:(i+1)*n]) x=int(input()) for i in range(x): inp.append(input()) for word in mas: if word in inp: answer.append(inp.index(word)+1) else: f=1 break if f==0: print('YES') for i in range(len(answer)-1): print(answer[i],' ',end='') print(answer[len(answer)-1]) else: print('NO') ```
instruction
0
51,789
19
103,578
No
output
1
51,789
19
103,579
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Several years ago Tolya had n computer games and at some point of time he decided to burn them to CD. After that he wrote down the names of the games one after another in a circle on the CD in clockwise order. The names were distinct, the length of each name was equal to k. The names didn't overlap. Thus, there is a cyclic string of length n·k written on the CD. Several years have passed and now Tolya can't remember which games he burned to his CD. He knows that there were g popular games that days. All of the games he burned were among these g games, and no game was burned more than once. You have to restore any valid list of games Tolya could burn to the CD several years ago. Input The first line of the input contains two positive integers n and k (1 ≤ n ≤ 105, 1 ≤ k ≤ 105) — the amount of games Tolya burned to the CD, and the length of each of the names. The second line of the input contains one string consisting of lowercase English letters — the string Tolya wrote on the CD, split in arbitrary place. The length of the string is n·k. It is guaranteed that the length is not greater than 106. The third line of the input contains one positive integer g (n ≤ g ≤ 105) — the amount of popular games that could be written on the CD. It is guaranteed that the total length of names of all popular games is not greater than 2·106. Each of the next g lines contains a single string — the name of some popular game. Each name consists of lowercase English letters and has length k. It is guaranteed that the names are distinct. Output If there is no answer, print "NO" (without quotes). Otherwise, print two lines. In the first line print "YES" (without quotes). In the second line, print n integers — the games which names were written on the CD. You should print games in the order they could have been written on the CD, it means, in clockwise order. You can print games starting from any position. Remember, that no game was burned to the CD more than once. If there are several possible answers, print any of them. Examples Input 3 1 abc 4 b a c d Output YES 2 1 3 Input 4 2 aabbccdd 4 dd ab bc cd Output NO Submitted Solution: ``` ar = input().split(" ") n = int(ar[0]) k = int(ar[1]) str = input() sr = [] for p in range(n): sr.append(str[:k]) str = str[k:] g = int(input()) arr = [] for i in range(g): arr.append(input()) b = True for k in range(n): try: arr.index(sr[k]) except Exception: b = False if b: print("YES") for t in range(n): print(int(arr.index(sr[t])) + 1, end=" ") else: print("NO") ```
instruction
0
51,790
19
103,580
No
output
1
51,790
19
103,581
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Several years ago Tolya had n computer games and at some point of time he decided to burn them to CD. After that he wrote down the names of the games one after another in a circle on the CD in clockwise order. The names were distinct, the length of each name was equal to k. The names didn't overlap. Thus, there is a cyclic string of length n·k written on the CD. Several years have passed and now Tolya can't remember which games he burned to his CD. He knows that there were g popular games that days. All of the games he burned were among these g games, and no game was burned more than once. You have to restore any valid list of games Tolya could burn to the CD several years ago. Input The first line of the input contains two positive integers n and k (1 ≤ n ≤ 105, 1 ≤ k ≤ 105) — the amount of games Tolya burned to the CD, and the length of each of the names. The second line of the input contains one string consisting of lowercase English letters — the string Tolya wrote on the CD, split in arbitrary place. The length of the string is n·k. It is guaranteed that the length is not greater than 106. The third line of the input contains one positive integer g (n ≤ g ≤ 105) — the amount of popular games that could be written on the CD. It is guaranteed that the total length of names of all popular games is not greater than 2·106. Each of the next g lines contains a single string — the name of some popular game. Each name consists of lowercase English letters and has length k. It is guaranteed that the names are distinct. Output If there is no answer, print "NO" (without quotes). Otherwise, print two lines. In the first line print "YES" (without quotes). In the second line, print n integers — the games which names were written on the CD. You should print games in the order they could have been written on the CD, it means, in clockwise order. You can print games starting from any position. Remember, that no game was burned to the CD more than once. If there are several possible answers, print any of them. Examples Input 3 1 abc 4 b a c d Output YES 2 1 3 Input 4 2 aabbccdd 4 dd ab bc cd Output NO Submitted Solution: ``` n, k = map(int, input().split()) S = input() g = int(input()) pop = [input() for x in range(g)] games = [ [] for x in range(k)] nums = [[] for x in range(k)] i = 0 dif = [] v = [] h = '' s = '' T = False for i in range(k): v = [] s = S for i in range(n-1): h = s[i:i+k] s = s[:i] + s[i+k:] v.append(h) s = s[i:] + s[:i] v.append(s) dif.append(v) for x in range(k): for i in range(n): if dif[x][i] in pop and dif[x][i] not in games[x]: nums[x].append(pop.index(dif[x][i])+1) games[x].append(dif[x][i]) else: break if len(nums[x]) == n: T = True break if T: print('YES') [print(l, end = ' ') for l in nums[x]] else: print('NO') ```
instruction
0
51,791
19
103,582
No
output
1
51,791
19
103,583
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Several years ago Tolya had n computer games and at some point of time he decided to burn them to CD. After that he wrote down the names of the games one after another in a circle on the CD in clockwise order. The names were distinct, the length of each name was equal to k. The names didn't overlap. Thus, there is a cyclic string of length n·k written on the CD. Several years have passed and now Tolya can't remember which games he burned to his CD. He knows that there were g popular games that days. All of the games he burned were among these g games, and no game was burned more than once. You have to restore any valid list of games Tolya could burn to the CD several years ago. Input The first line of the input contains two positive integers n and k (1 ≤ n ≤ 105, 1 ≤ k ≤ 105) — the amount of games Tolya burned to the CD, and the length of each of the names. The second line of the input contains one string consisting of lowercase English letters — the string Tolya wrote on the CD, split in arbitrary place. The length of the string is n·k. It is guaranteed that the length is not greater than 106. The third line of the input contains one positive integer g (n ≤ g ≤ 105) — the amount of popular games that could be written on the CD. It is guaranteed that the total length of names of all popular games is not greater than 2·106. Each of the next g lines contains a single string — the name of some popular game. Each name consists of lowercase English letters and has length k. It is guaranteed that the names are distinct. Output If there is no answer, print "NO" (without quotes). Otherwise, print two lines. In the first line print "YES" (without quotes). In the second line, print n integers — the games which names were written on the CD. You should print games in the order they could have been written on the CD, it means, in clockwise order. You can print games starting from any position. Remember, that no game was burned to the CD more than once. If there are several possible answers, print any of them. Examples Input 3 1 abc 4 b a c d Output YES 2 1 3 Input 4 2 aabbccdd 4 dd ab bc cd Output NO Submitted Solution: ``` s = input().split(' ') count = int(s[0]) length = int(s[1]) names = input() gcount = int(input()) games = {} for i in range(gcount): games[input()] = i tg = [names[i:i+length] for i in range(0, count * length, length)] res = [] for game in tg: if game not in games: print('NO') exit() if games[game] in res: print('NO') exit() res.append(games[game]) result = '' for g in res: result += str(g + 1) + ' ' print('YES') print(result) ```
instruction
0
51,792
19
103,584
No
output
1
51,792
19
103,585
Provide a correct Python 3 solution for this coding contest problem. Alice and Brown loves games. Today, they will play the following game. In this game, there are two piles initially consisting of X and Y stones, respectively. Alice and Bob alternately perform the following operation, starting from Alice: * Take 2i stones from one of the piles. Then, throw away i of them, and put the remaining i in the other pile. Here, the integer i (1≤i) can be freely chosen as long as there is a sufficient number of stones in the pile. The player who becomes unable to perform the operation, loses the game. Given X and Y, determine the winner of the game, assuming that both players play optimally. Constraints * 0 ≤ X, Y ≤ 10^{18} Input Input is given from Standard Input in the following format: X Y Output Print the winner: either `Alice` or `Brown`. Examples Input 2 1 Output Brown Input 5 0 Output Alice Input 0 0 Output Brown Input 4 8 Output Alice
instruction
0
52,044
19
104,088
"Correct Solution: ``` # 解説AC X,Y = map(int, input().split()) print("Alice" if abs(X - Y) > 1 else "Brown") ```
output
1
52,044
19
104,089
Provide a correct Python 3 solution for this coding contest problem. Alice and Brown loves games. Today, they will play the following game. In this game, there are two piles initially consisting of X and Y stones, respectively. Alice and Bob alternately perform the following operation, starting from Alice: * Take 2i stones from one of the piles. Then, throw away i of them, and put the remaining i in the other pile. Here, the integer i (1≤i) can be freely chosen as long as there is a sufficient number of stones in the pile. The player who becomes unable to perform the operation, loses the game. Given X and Y, determine the winner of the game, assuming that both players play optimally. Constraints * 0 ≤ X, Y ≤ 10^{18} Input Input is given from Standard Input in the following format: X Y Output Print the winner: either `Alice` or `Brown`. Examples Input 2 1 Output Brown Input 5 0 Output Alice Input 0 0 Output Brown Input 4 8 Output Alice
instruction
0
52,045
19
104,090
"Correct Solution: ``` #!usr/bin/env python3 from collections import defaultdict from heapq import heappush, heappop import sys import math import bisect import random def LI(): return list(map(int, sys.stdin.readline().split())) def I(): return int(sys.stdin.readline()) def LS():return list(map(list, sys.stdin.readline().split())) def S(): return list(sys.stdin.readline())[:-1] def IR(n): l = [None for i in range(n)] for i in range(n):l[i] = I() return l def LIR(n): l = [None for i in range(n)] for i in range(n):l[i] = LI() return l def SR(n): l = [None for i in range(n)] for i in range(n):l[i] = S() return l def LSR(n): l = [None for i in range(n)] for i in range(n):l[i] = SR() return l mod = 1000000007 #A #B #C """ n = I() a = LI() ans = 0 k = a[0] for i in range(1,n): if k*(k+a[i]) >= 0: if k < 0: ans += abs(1-k-a[i]) a[i] = 1-k k = 1 else: ans += abs(-1-k-a[i]) a[i] = -1-k k = -1 else: k += a[i] print(ans) """ #D x,y = LI() if abs(x-y) <= 1: print("Brown") else: print("Alice") #E #F #G #H #I #J #K #L #M #N #O #P #Q #R #S #T ```
output
1
52,045
19
104,091
Provide a correct Python 3 solution for this coding contest problem. Alice and Brown loves games. Today, they will play the following game. In this game, there are two piles initially consisting of X and Y stones, respectively. Alice and Bob alternately perform the following operation, starting from Alice: * Take 2i stones from one of the piles. Then, throw away i of them, and put the remaining i in the other pile. Here, the integer i (1≤i) can be freely chosen as long as there is a sufficient number of stones in the pile. The player who becomes unable to perform the operation, loses the game. Given X and Y, determine the winner of the game, assuming that both players play optimally. Constraints * 0 ≤ X, Y ≤ 10^{18} Input Input is given from Standard Input in the following format: X Y Output Print the winner: either `Alice` or `Brown`. Examples Input 2 1 Output Brown Input 5 0 Output Alice Input 0 0 Output Brown Input 4 8 Output Alice
instruction
0
52,046
19
104,092
"Correct Solution: ``` #!/usr/bin/env python X,Y = map(int, input().split()) if X+Y <= 1: print('Brown') exit(0) if abs(X-Y) <= 1: print('Brown') else: print('Alice') ```
output
1
52,046
19
104,093
Provide a correct Python 3 solution for this coding contest problem. Alice and Brown loves games. Today, they will play the following game. In this game, there are two piles initially consisting of X and Y stones, respectively. Alice and Bob alternately perform the following operation, starting from Alice: * Take 2i stones from one of the piles. Then, throw away i of them, and put the remaining i in the other pile. Here, the integer i (1≤i) can be freely chosen as long as there is a sufficient number of stones in the pile. The player who becomes unable to perform the operation, loses the game. Given X and Y, determine the winner of the game, assuming that both players play optimally. Constraints * 0 ≤ X, Y ≤ 10^{18} Input Input is given from Standard Input in the following format: X Y Output Print the winner: either `Alice` or `Brown`. Examples Input 2 1 Output Brown Input 5 0 Output Alice Input 0 0 Output Brown Input 4 8 Output Alice
instruction
0
52,047
19
104,094
"Correct Solution: ``` #01:25 a,b = map(int,input().split()) if abs(a-b) <= 1: print('Brown') else: print('Alice') ```
output
1
52,047
19
104,095
Provide a correct Python 3 solution for this coding contest problem. Alice and Brown loves games. Today, they will play the following game. In this game, there are two piles initially consisting of X and Y stones, respectively. Alice and Bob alternately perform the following operation, starting from Alice: * Take 2i stones from one of the piles. Then, throw away i of them, and put the remaining i in the other pile. Here, the integer i (1≤i) can be freely chosen as long as there is a sufficient number of stones in the pile. The player who becomes unable to perform the operation, loses the game. Given X and Y, determine the winner of the game, assuming that both players play optimally. Constraints * 0 ≤ X, Y ≤ 10^{18} Input Input is given from Standard Input in the following format: X Y Output Print the winner: either `Alice` or `Brown`. Examples Input 2 1 Output Brown Input 5 0 Output Alice Input 0 0 Output Brown Input 4 8 Output Alice
instruction
0
52,048
19
104,096
"Correct Solution: ``` X,Y = input().split() X =int(X) Y = int(Y) if (X-Y)**2 > 1: print("Alice") else: print("Brown") ```
output
1
52,048
19
104,097
Provide a correct Python 3 solution for this coding contest problem. Alice and Brown loves games. Today, they will play the following game. In this game, there are two piles initially consisting of X and Y stones, respectively. Alice and Bob alternately perform the following operation, starting from Alice: * Take 2i stones from one of the piles. Then, throw away i of them, and put the remaining i in the other pile. Here, the integer i (1≤i) can be freely chosen as long as there is a sufficient number of stones in the pile. The player who becomes unable to perform the operation, loses the game. Given X and Y, determine the winner of the game, assuming that both players play optimally. Constraints * 0 ≤ X, Y ≤ 10^{18} Input Input is given from Standard Input in the following format: X Y Output Print the winner: either `Alice` or `Brown`. Examples Input 2 1 Output Brown Input 5 0 Output Alice Input 0 0 Output Brown Input 4 8 Output Alice
instruction
0
52,049
19
104,098
"Correct Solution: ``` X, Y = map(int, input().split()) print('Alice' if abs(X-Y)>=2 else 'Brown') ```
output
1
52,049
19
104,099
Provide a correct Python 3 solution for this coding contest problem. Alice and Brown loves games. Today, they will play the following game. In this game, there are two piles initially consisting of X and Y stones, respectively. Alice and Bob alternately perform the following operation, starting from Alice: * Take 2i stones from one of the piles. Then, throw away i of them, and put the remaining i in the other pile. Here, the integer i (1≤i) can be freely chosen as long as there is a sufficient number of stones in the pile. The player who becomes unable to perform the operation, loses the game. Given X and Y, determine the winner of the game, assuming that both players play optimally. Constraints * 0 ≤ X, Y ≤ 10^{18} Input Input is given from Standard Input in the following format: X Y Output Print the winner: either `Alice` or `Brown`. Examples Input 2 1 Output Brown Input 5 0 Output Alice Input 0 0 Output Brown Input 4 8 Output Alice
instruction
0
52,050
19
104,100
"Correct Solution: ``` import sys input = sys.stdin.buffer.readline #sys.setrecursionlimit(10**9) #from functools import lru_cache def RD(): return input().rstrip().decode() def II(): return int(input()) def FI(): return int(input()) def MI(): return map(int,input().split()) def MF(): return map(float,input().split()) def LI(): return list(map(int,input().split())) def LF(): return list(map(float,input().split())) def TI(): return tuple(map(int,input().split())) # rstrip().decode() def main(): x,y=MI() a=abs(x-y) print("Brown" if a<=1 else "Alice") if __name__ == "__main__": main() ```
output
1
52,050
19
104,101
Provide a correct Python 3 solution for this coding contest problem. Alice and Brown loves games. Today, they will play the following game. In this game, there are two piles initially consisting of X and Y stones, respectively. Alice and Bob alternately perform the following operation, starting from Alice: * Take 2i stones from one of the piles. Then, throw away i of them, and put the remaining i in the other pile. Here, the integer i (1≤i) can be freely chosen as long as there is a sufficient number of stones in the pile. The player who becomes unable to perform the operation, loses the game. Given X and Y, determine the winner of the game, assuming that both players play optimally. Constraints * 0 ≤ X, Y ≤ 10^{18} Input Input is given from Standard Input in the following format: X Y Output Print the winner: either `Alice` or `Brown`. Examples Input 2 1 Output Brown Input 5 0 Output Alice Input 0 0 Output Brown Input 4 8 Output Alice
instruction
0
52,051
19
104,102
"Correct Solution: ``` def alice_and_brown(X: int, Y: int)->str: return 'Alice' if abs(X-Y) > 1 else 'Brown' if __name__ == "__main__": X, Y = map(int, input().split()) ans = alice_and_brown(X, Y) print(ans) ```
output
1
52,051
19
104,103
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Alice and Brown loves games. Today, they will play the following game. In this game, there are two piles initially consisting of X and Y stones, respectively. Alice and Bob alternately perform the following operation, starting from Alice: * Take 2i stones from one of the piles. Then, throw away i of them, and put the remaining i in the other pile. Here, the integer i (1≤i) can be freely chosen as long as there is a sufficient number of stones in the pile. The player who becomes unable to perform the operation, loses the game. Given X and Y, determine the winner of the game, assuming that both players play optimally. Constraints * 0 ≤ X, Y ≤ 10^{18} Input Input is given from Standard Input in the following format: X Y Output Print the winner: either `Alice` or `Brown`. Examples Input 2 1 Output Brown Input 5 0 Output Alice Input 0 0 Output Brown Input 4 8 Output Alice Submitted Solution: ``` X,Y=map(int,input().split()) if X+Y<=1: print("Brown") else: n=X-Y if n<0: n=(-1)*n if n<=1: print("Brown") else: print("Alice") ```
instruction
0
52,052
19
104,104
Yes
output
1
52,052
19
104,105
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Alice and Brown loves games. Today, they will play the following game. In this game, there are two piles initially consisting of X and Y stones, respectively. Alice and Bob alternately perform the following operation, starting from Alice: * Take 2i stones from one of the piles. Then, throw away i of them, and put the remaining i in the other pile. Here, the integer i (1≤i) can be freely chosen as long as there is a sufficient number of stones in the pile. The player who becomes unable to perform the operation, loses the game. Given X and Y, determine the winner of the game, assuming that both players play optimally. Constraints * 0 ≤ X, Y ≤ 10^{18} Input Input is given from Standard Input in the following format: X Y Output Print the winner: either `Alice` or `Brown`. Examples Input 2 1 Output Brown Input 5 0 Output Alice Input 0 0 Output Brown Input 4 8 Output Alice Submitted Solution: ``` X, Y = map(int, input().split()) print("Alice" if abs(X - Y) > 1 else "Brown") ```
instruction
0
52,053
19
104,106
Yes
output
1
52,053
19
104,107
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Alice and Brown loves games. Today, they will play the following game. In this game, there are two piles initially consisting of X and Y stones, respectively. Alice and Bob alternately perform the following operation, starting from Alice: * Take 2i stones from one of the piles. Then, throw away i of them, and put the remaining i in the other pile. Here, the integer i (1≤i) can be freely chosen as long as there is a sufficient number of stones in the pile. The player who becomes unable to perform the operation, loses the game. Given X and Y, determine the winner of the game, assuming that both players play optimally. Constraints * 0 ≤ X, Y ≤ 10^{18} Input Input is given from Standard Input in the following format: X Y Output Print the winner: either `Alice` or `Brown`. Examples Input 2 1 Output Brown Input 5 0 Output Alice Input 0 0 Output Brown Input 4 8 Output Alice Submitted Solution: ``` import sys sys.setrecursionlimit(2147483647) INF=float("inf") MOD=10**9+7 input=lambda :sys.stdin.readline().rstrip() def resolve(): x,y=map(int,input().split()) print("Alice" if(abs(x-y)>1) else "Brown") resolve() ```
instruction
0
52,054
19
104,108
Yes
output
1
52,054
19
104,109
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Alice and Brown loves games. Today, they will play the following game. In this game, there are two piles initially consisting of X and Y stones, respectively. Alice and Bob alternately perform the following operation, starting from Alice: * Take 2i stones from one of the piles. Then, throw away i of them, and put the remaining i in the other pile. Here, the integer i (1≤i) can be freely chosen as long as there is a sufficient number of stones in the pile. The player who becomes unable to perform the operation, loses the game. Given X and Y, determine the winner of the game, assuming that both players play optimally. Constraints * 0 ≤ X, Y ≤ 10^{18} Input Input is given from Standard Input in the following format: X Y Output Print the winner: either `Alice` or `Brown`. Examples Input 2 1 Output Brown Input 5 0 Output Alice Input 0 0 Output Brown Input 4 8 Output Alice Submitted Solution: ``` # -*- coding: utf-8 -*- import bisect import heapq import math import random import sys from collections import Counter, defaultdict, deque from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal from functools import lru_cache, reduce from itertools import combinations, combinations_with_replacement, product, permutations from operator import add, mul, sub sys.setrecursionlimit(10000) def read_int(): return int(input()) def read_int_n(): return list(map(int, input().split())) def read_float(): return float(input()) def read_float_n(): return list(map(float, input().split())) def read_str(): return input().strip() def read_str_n(): return list(map(str, input().split())) def error_print(*args): print(*args, file=sys.stderr) def mt(f): import time def wrap(*args, **kwargs): s = time.time() ret = f(*args, **kwargs) e = time.time() error_print(e - s, 'sec') return ret return wrap @mt def slv(X, Y): if abs(X-Y) > 1: return 'Alice' return 'Brown' def main(): X, Y = read_int_n() print(slv(X, Y)) if __name__ == '__main__': main() ```
instruction
0
52,055
19
104,110
Yes
output
1
52,055
19
104,111
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Alice and Brown loves games. Today, they will play the following game. In this game, there are two piles initially consisting of X and Y stones, respectively. Alice and Bob alternately perform the following operation, starting from Alice: * Take 2i stones from one of the piles. Then, throw away i of them, and put the remaining i in the other pile. Here, the integer i (1≤i) can be freely chosen as long as there is a sufficient number of stones in the pile. The player who becomes unable to perform the operation, loses the game. Given X and Y, determine the winner of the game, assuming that both players play optimally. Constraints * 0 ≤ X, Y ≤ 10^{18} Input Input is given from Standard Input in the following format: X Y Output Print the winner: either `Alice` or `Brown`. Examples Input 2 1 Output Brown Input 5 0 Output Alice Input 0 0 Output Brown Input 4 8 Output Alice Submitted Solution: ``` X, Y = map(int, input().split()) if abs(X//2 - Y//2) <= 1: print("Brown") else: print("Alice") ```
instruction
0
52,056
19
104,112
No
output
1
52,056
19
104,113
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Alice and Brown loves games. Today, they will play the following game. In this game, there are two piles initially consisting of X and Y stones, respectively. Alice and Bob alternately perform the following operation, starting from Alice: * Take 2i stones from one of the piles. Then, throw away i of them, and put the remaining i in the other pile. Here, the integer i (1≤i) can be freely chosen as long as there is a sufficient number of stones in the pile. The player who becomes unable to perform the operation, loses the game. Given X and Y, determine the winner of the game, assuming that both players play optimally. Constraints * 0 ≤ X, Y ≤ 10^{18} Input Input is given from Standard Input in the following format: X Y Output Print the winner: either `Alice` or `Brown`. Examples Input 2 1 Output Brown Input 5 0 Output Alice Input 0 0 Output Brown Input 4 8 Output Alice Submitted Solution: ``` #一問目 x,y=map(int,input().split()) if abs(x-y)<=1: print("Blown") else: print("Alice") ```
instruction
0
52,057
19
104,114
No
output
1
52,057
19
104,115
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Alice and Brown loves games. Today, they will play the following game. In this game, there are two piles initially consisting of X and Y stones, respectively. Alice and Bob alternately perform the following operation, starting from Alice: * Take 2i stones from one of the piles. Then, throw away i of them, and put the remaining i in the other pile. Here, the integer i (1≤i) can be freely chosen as long as there is a sufficient number of stones in the pile. The player who becomes unable to perform the operation, loses the game. Given X and Y, determine the winner of the game, assuming that both players play optimally. Constraints * 0 ≤ X, Y ≤ 10^{18} Input Input is given from Standard Input in the following format: X Y Output Print the winner: either `Alice` or `Brown`. Examples Input 2 1 Output Brown Input 5 0 Output Alice Input 0 0 Output Brown Input 4 8 Output Alice Submitted Solution: ``` x,y=map(int,input().split()) if x<2 and y<2: print("Brown") elif x==2 and y==2: print("Brown") elif (x==3 and y==0) or (x==0 and y==3): print("Alice") else: if (x//2==x/2 and y//2==y/2) or (x//2!=x/2 and y//2!=y/2): print("Alice") else: print("Brown") ```
instruction
0
52,058
19
104,116
No
output
1
52,058
19
104,117
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Alice and Brown loves games. Today, they will play the following game. In this game, there are two piles initially consisting of X and Y stones, respectively. Alice and Bob alternately perform the following operation, starting from Alice: * Take 2i stones from one of the piles. Then, throw away i of them, and put the remaining i in the other pile. Here, the integer i (1≤i) can be freely chosen as long as there is a sufficient number of stones in the pile. The player who becomes unable to perform the operation, loses the game. Given X and Y, determine the winner of the game, assuming that both players play optimally. Constraints * 0 ≤ X, Y ≤ 10^{18} Input Input is given from Standard Input in the following format: X Y Output Print the winner: either `Alice` or `Brown`. Examples Input 2 1 Output Brown Input 5 0 Output Alice Input 0 0 Output Brown Input 4 8 Output Alice Submitted Solution: ``` # -*- coding: utf-8 -*- X, Y = map(int, input().split()) if X >= 2 and Y >= 2 or X >= 4 or Y >= 4 or X >= 2 and Y == 0 or X == 0 and Y >= 2: print('Alice') else: print('Brown') ```
instruction
0
52,059
19
104,118
No
output
1
52,059
19
104,119
Provide tags and a correct Python 3 solution for this coding contest problem. Sam has been teaching Jon the Game of Stones to sharpen his mind and help him devise a strategy to fight the white walkers. The rules of this game are quite simple: * The game starts with n piles of stones indexed from 1 to n. The i-th pile contains si stones. * The players make their moves alternatively. A move is considered as removal of some number of stones from a pile. Removal of 0 stones does not count as a move. * The player who is unable to make a move loses. Now Jon believes that he is ready for battle, but Sam does not think so. To prove his argument, Sam suggested that they play a modified version of the game. In this modified version, no move can be made more than once on a pile. For example, if 4 stones are removed from a pile, 4 stones cannot be removed from that pile again. Sam sets up the game and makes the first move. Jon believes that Sam is just trying to prevent him from going to battle. Jon wants to know if he can win if both play optimally. Input First line consists of a single integer n (1 ≤ n ≤ 106) — the number of piles. Each of next n lines contains an integer si (1 ≤ si ≤ 60) — the number of stones in i-th pile. Output Print a single line containing "YES" (without quotes) if Jon wins, otherwise print "NO" (without quotes) Examples Input 1 5 Output NO Input 2 1 2 Output YES Note In the first case, Sam removes all the stones and Jon loses. In second case, the following moves are possible by Sam: <image> In each of these cases, last move can be made by Jon to win the game as follows: <image>
instruction
0
52,711
19
105,422
Tags: bitmasks, dp, games Correct Solution: ``` import sys input = sys.stdin.readline def large(x): for i in range(10, -1, -1): if i*(i+1)//2 <= x: return i x = int(input()) l = [] for i in range(x): l.append(int(input())) a = [large(i) for i in range(0, 61)] lol = 0 for i in l: i = a[i] lol = lol ^ i if (lol == 0): print("YES") else: print("NO") ```
output
1
52,711
19
105,423
Provide tags and a correct Python 3 solution for this coding contest problem. Sam has been teaching Jon the Game of Stones to sharpen his mind and help him devise a strategy to fight the white walkers. The rules of this game are quite simple: * The game starts with n piles of stones indexed from 1 to n. The i-th pile contains si stones. * The players make their moves alternatively. A move is considered as removal of some number of stones from a pile. Removal of 0 stones does not count as a move. * The player who is unable to make a move loses. Now Jon believes that he is ready for battle, but Sam does not think so. To prove his argument, Sam suggested that they play a modified version of the game. In this modified version, no move can be made more than once on a pile. For example, if 4 stones are removed from a pile, 4 stones cannot be removed from that pile again. Sam sets up the game and makes the first move. Jon believes that Sam is just trying to prevent him from going to battle. Jon wants to know if he can win if both play optimally. Input First line consists of a single integer n (1 ≤ n ≤ 106) — the number of piles. Each of next n lines contains an integer si (1 ≤ si ≤ 60) — the number of stones in i-th pile. Output Print a single line containing "YES" (without quotes) if Jon wins, otherwise print "NO" (without quotes) Examples Input 1 5 Output NO Input 2 1 2 Output YES Note In the first case, Sam removes all the stones and Jon loses. In second case, the following moves are possible by Sam: <image> In each of these cases, last move can be made by Jon to win the game as follows: <image>
instruction
0
52,712
19
105,424
Tags: bitmasks, dp, games Correct Solution: ``` s = 0 for t in range(int(input())): s ^= int((8 * int(input()) + 1) ** 0.5 - 1) // 2 print(['YES', 'NO'][s > 0]) ```
output
1
52,712
19
105,425
Provide tags and a correct Python 3 solution for this coding contest problem. Sam has been teaching Jon the Game of Stones to sharpen his mind and help him devise a strategy to fight the white walkers. The rules of this game are quite simple: * The game starts with n piles of stones indexed from 1 to n. The i-th pile contains si stones. * The players make their moves alternatively. A move is considered as removal of some number of stones from a pile. Removal of 0 stones does not count as a move. * The player who is unable to make a move loses. Now Jon believes that he is ready for battle, but Sam does not think so. To prove his argument, Sam suggested that they play a modified version of the game. In this modified version, no move can be made more than once on a pile. For example, if 4 stones are removed from a pile, 4 stones cannot be removed from that pile again. Sam sets up the game and makes the first move. Jon believes that Sam is just trying to prevent him from going to battle. Jon wants to know if he can win if both play optimally. Input First line consists of a single integer n (1 ≤ n ≤ 106) — the number of piles. Each of next n lines contains an integer si (1 ≤ si ≤ 60) — the number of stones in i-th pile. Output Print a single line containing "YES" (without quotes) if Jon wins, otherwise print "NO" (without quotes) Examples Input 1 5 Output NO Input 2 1 2 Output YES Note In the first case, Sam removes all the stones and Jon loses. In second case, the following moves are possible by Sam: <image> In each of these cases, last move can be made by Jon to win the game as follows: <image>
instruction
0
52,713
19
105,426
Tags: bitmasks, dp, games Correct Solution: ``` from math import ceil from sys import stdin, stdout def f(v): return ceil(((9 + 8 * v) ** 0.5 - 3) / 2) n, x = int(stdin.readline()), 0 for i in range(n): x ^= f(int(stdin.readline())) stdout.write("NO" if x else "YES") ```
output
1
52,713
19
105,427
Provide tags and a correct Python 3 solution for this coding contest problem. Sam has been teaching Jon the Game of Stones to sharpen his mind and help him devise a strategy to fight the white walkers. The rules of this game are quite simple: * The game starts with n piles of stones indexed from 1 to n. The i-th pile contains si stones. * The players make their moves alternatively. A move is considered as removal of some number of stones from a pile. Removal of 0 stones does not count as a move. * The player who is unable to make a move loses. Now Jon believes that he is ready for battle, but Sam does not think so. To prove his argument, Sam suggested that they play a modified version of the game. In this modified version, no move can be made more than once on a pile. For example, if 4 stones are removed from a pile, 4 stones cannot be removed from that pile again. Sam sets up the game and makes the first move. Jon believes that Sam is just trying to prevent him from going to battle. Jon wants to know if he can win if both play optimally. Input First line consists of a single integer n (1 ≤ n ≤ 106) — the number of piles. Each of next n lines contains an integer si (1 ≤ si ≤ 60) — the number of stones in i-th pile. Output Print a single line containing "YES" (without quotes) if Jon wins, otherwise print "NO" (without quotes) Examples Input 1 5 Output NO Input 2 1 2 Output YES Note In the first case, Sam removes all the stones and Jon loses. In second case, the following moves are possible by Sam: <image> In each of these cases, last move can be made by Jon to win the game as follows: <image>
instruction
0
52,714
19
105,428
Tags: bitmasks, dp, games Correct Solution: ``` ans=0 for _ in range(int(input())): ans^=int((8*int(input())+1)**0.5-1)//2 print(['YES', 'NO'][ans>0]) ```
output
1
52,714
19
105,429
Provide tags and a correct Python 3 solution for this coding contest problem. Sam has been teaching Jon the Game of Stones to sharpen his mind and help him devise a strategy to fight the white walkers. The rules of this game are quite simple: * The game starts with n piles of stones indexed from 1 to n. The i-th pile contains si stones. * The players make their moves alternatively. A move is considered as removal of some number of stones from a pile. Removal of 0 stones does not count as a move. * The player who is unable to make a move loses. Now Jon believes that he is ready for battle, but Sam does not think so. To prove his argument, Sam suggested that they play a modified version of the game. In this modified version, no move can be made more than once on a pile. For example, if 4 stones are removed from a pile, 4 stones cannot be removed from that pile again. Sam sets up the game and makes the first move. Jon believes that Sam is just trying to prevent him from going to battle. Jon wants to know if he can win if both play optimally. Input First line consists of a single integer n (1 ≤ n ≤ 106) — the number of piles. Each of next n lines contains an integer si (1 ≤ si ≤ 60) — the number of stones in i-th pile. Output Print a single line containing "YES" (without quotes) if Jon wins, otherwise print "NO" (without quotes) Examples Input 1 5 Output NO Input 2 1 2 Output YES Note In the first case, Sam removes all the stones and Jon loses. In second case, the following moves are possible by Sam: <image> In each of these cases, last move can be made by Jon to win the game as follows: <image>
instruction
0
52,715
19
105,430
Tags: bitmasks, dp, games Correct Solution: ``` n = int(input()) arr = [int(input()) for i in range(n)] b = [0 for i in range(n)] s = 0 for i in range(n): j = int((arr[i] << 1) ** 0.5) if j * (j + 1) > (arr[i] << 1): j -= 1 s ^= j if s != 0: print('NO') else: print('YES') ```
output
1
52,715
19
105,431
Provide tags and a correct Python 3 solution for this coding contest problem. Sam has been teaching Jon the Game of Stones to sharpen his mind and help him devise a strategy to fight the white walkers. The rules of this game are quite simple: * The game starts with n piles of stones indexed from 1 to n. The i-th pile contains si stones. * The players make their moves alternatively. A move is considered as removal of some number of stones from a pile. Removal of 0 stones does not count as a move. * The player who is unable to make a move loses. Now Jon believes that he is ready for battle, but Sam does not think so. To prove his argument, Sam suggested that they play a modified version of the game. In this modified version, no move can be made more than once on a pile. For example, if 4 stones are removed from a pile, 4 stones cannot be removed from that pile again. Sam sets up the game and makes the first move. Jon believes that Sam is just trying to prevent him from going to battle. Jon wants to know if he can win if both play optimally. Input First line consists of a single integer n (1 ≤ n ≤ 106) — the number of piles. Each of next n lines contains an integer si (1 ≤ si ≤ 60) — the number of stones in i-th pile. Output Print a single line containing "YES" (without quotes) if Jon wins, otherwise print "NO" (without quotes) Examples Input 1 5 Output NO Input 2 1 2 Output YES Note In the first case, Sam removes all the stones and Jon loses. In second case, the following moves are possible by Sam: <image> In each of these cases, last move can be made by Jon to win the game as follows: <image>
instruction
0
52,716
19
105,432
Tags: bitmasks, dp, games Correct Solution: ``` import sys input=sys.stdin.readline #sys.setrecursionlimit(1000000) dp={} def cal(x,y): x,y=int(x),int(y) a=set() if (x,y) in dp: return dp[(x,y)] for i in range(min(int(60),x)): p=y&(1<<i) if p>0: continue r=cal(x-i-1,y|(1<<i)) a.add(r) cn=0 for i in range(len(a)+2): if cn in a: cn+=1 else: break dp[(x,y)]=cn return cn n=int(input()) ans=0 for i in range(n): x=int(input()) ans^=cal(x,0) if ans==0: print("YES") else: print("NO") ```
output
1
52,716
19
105,433
Provide tags and a correct Python 3 solution for this coding contest problem. Sam has been teaching Jon the Game of Stones to sharpen his mind and help him devise a strategy to fight the white walkers. The rules of this game are quite simple: * The game starts with n piles of stones indexed from 1 to n. The i-th pile contains si stones. * The players make their moves alternatively. A move is considered as removal of some number of stones from a pile. Removal of 0 stones does not count as a move. * The player who is unable to make a move loses. Now Jon believes that he is ready for battle, but Sam does not think so. To prove his argument, Sam suggested that they play a modified version of the game. In this modified version, no move can be made more than once on a pile. For example, if 4 stones are removed from a pile, 4 stones cannot be removed from that pile again. Sam sets up the game and makes the first move. Jon believes that Sam is just trying to prevent him from going to battle. Jon wants to know if he can win if both play optimally. Input First line consists of a single integer n (1 ≤ n ≤ 106) — the number of piles. Each of next n lines contains an integer si (1 ≤ si ≤ 60) — the number of stones in i-th pile. Output Print a single line containing "YES" (without quotes) if Jon wins, otherwise print "NO" (without quotes) Examples Input 1 5 Output NO Input 2 1 2 Output YES Note In the first case, Sam removes all the stones and Jon loses. In second case, the following moves are possible by Sam: <image> In each of these cases, last move can be made by Jon to win the game as follows: <image>
instruction
0
52,717
19
105,434
Tags: bitmasks, dp, games Correct Solution: ``` from math import sqrt k = 0 for t in range(int(input())): k ^= int(int(sqrt(8 * int(input()) + 1) - 1) / 2) print("NO" if k != 0 else "YES") ```
output
1
52,717
19
105,435
Provide tags and a correct Python 3 solution for this coding contest problem. Sam has been teaching Jon the Game of Stones to sharpen his mind and help him devise a strategy to fight the white walkers. The rules of this game are quite simple: * The game starts with n piles of stones indexed from 1 to n. The i-th pile contains si stones. * The players make their moves alternatively. A move is considered as removal of some number of stones from a pile. Removal of 0 stones does not count as a move. * The player who is unable to make a move loses. Now Jon believes that he is ready for battle, but Sam does not think so. To prove his argument, Sam suggested that they play a modified version of the game. In this modified version, no move can be made more than once on a pile. For example, if 4 stones are removed from a pile, 4 stones cannot be removed from that pile again. Sam sets up the game and makes the first move. Jon believes that Sam is just trying to prevent him from going to battle. Jon wants to know if he can win if both play optimally. Input First line consists of a single integer n (1 ≤ n ≤ 106) — the number of piles. Each of next n lines contains an integer si (1 ≤ si ≤ 60) — the number of stones in i-th pile. Output Print a single line containing "YES" (without quotes) if Jon wins, otherwise print "NO" (without quotes) Examples Input 1 5 Output NO Input 2 1 2 Output YES Note In the first case, Sam removes all the stones and Jon loses. In second case, the following moves are possible by Sam: <image> In each of these cases, last move can be made by Jon to win the game as follows: <image>
instruction
0
52,718
19
105,436
Tags: bitmasks, dp, games Correct Solution: ``` memo = {} def get_reachable_states(k, max_allowed): states = [] for i in range(1, min(k,max_allowed) + 1): new_k = k - i states.append((new_k, i - 1)) return states def Grundy(k, max_allowed): if k == 0: return 0 if (k, max_allowed) in memo: return memo[(k, max_allowed)] reachable_states = get_reachable_states(k, max_allowed) if len(reachable_states) == 0: memo[(k, max_allowed)] = 0 return 0 s = set() for state in reachable_states: s.add(Grundy(*state)) i = 0 while i in s: i += 1 memo[(k, max_allowed)] = i return memo[(k, max_allowed)] n = int(input()) GrundyTotal = 0 for i in range(n): k = int(input()) GrundyTotal ^= Grundy(k, k) print("YES" if GrundyTotal == 0 else "NO") ```
output
1
52,718
19
105,437