message
stringlengths
2
44.5k
message_type
stringclasses
2 values
message_id
int64
0
1
conversation_id
int64
42
109k
cluster
float64
5
5
__index_level_0__
int64
84
217k
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given an integer n (n β‰₯ 0) represented with k digits in base (radix) b. So, $$$n = a_1 β‹… b^{k-1} + a_2 β‹… b^{k-2} + … a_{k-1} β‹… b + a_k.$$$ For example, if b=17, k=3 and a=[11, 15, 7] then n=11β‹…17^2+15β‹…17+7=3179+255+7=3441. Determine whether n is even or odd. Input The first line contains two integers b and k (2≀ b≀ 100, 1≀ k≀ 10^5) β€” the base of the number and the number of digits. The second line contains k integers a_1, a_2, …, a_k (0≀ a_i < b) β€” the digits of n. The representation of n contains no unnecessary leading zero. That is, a_1 can be equal to 0 only if k = 1. Output Print "even" if n is even, otherwise print "odd". You can print each letter in any case (upper or lower). Examples Input 13 3 3 2 7 Output even Input 10 9 1 2 3 4 5 6 7 8 9 Output odd Input 99 5 32 92 85 74 4 Output odd Input 2 2 1 0 Output even Note In the first example, n = 3 β‹… 13^2 + 2 β‹… 13 + 7 = 540, which is even. In the second example, n = 123456789 is odd. In the third example, n = 32 β‹… 99^4 + 92 β‹… 99^3 + 85 β‹… 99^2 + 74 β‹… 99 + 4 = 3164015155 is odd. In the fourth example n = 2. Submitted Solution: ``` b, k = [int(i) for i in input().split()] arr = [int(i) for i in input().split()] odd = 0 for i in arr: if b & 1 or i & 1: odd += 1 if odd & 1: print('odd') else: print('even') ```
instruction
0
98,655
5
197,310
No
output
1
98,655
5
197,311
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given an integer n (n β‰₯ 0) represented with k digits in base (radix) b. So, $$$n = a_1 β‹… b^{k-1} + a_2 β‹… b^{k-2} + … a_{k-1} β‹… b + a_k.$$$ For example, if b=17, k=3 and a=[11, 15, 7] then n=11β‹…17^2+15β‹…17+7=3179+255+7=3441. Determine whether n is even or odd. Input The first line contains two integers b and k (2≀ b≀ 100, 1≀ k≀ 10^5) β€” the base of the number and the number of digits. The second line contains k integers a_1, a_2, …, a_k (0≀ a_i < b) β€” the digits of n. The representation of n contains no unnecessary leading zero. That is, a_1 can be equal to 0 only if k = 1. Output Print "even" if n is even, otherwise print "odd". You can print each letter in any case (upper or lower). Examples Input 13 3 3 2 7 Output even Input 10 9 1 2 3 4 5 6 7 8 9 Output odd Input 99 5 32 92 85 74 4 Output odd Input 2 2 1 0 Output even Note In the first example, n = 3 β‹… 13^2 + 2 β‹… 13 + 7 = 540, which is even. In the second example, n = 123456789 is odd. In the third example, n = 32 β‹… 99^4 + 92 β‹… 99^3 + 85 β‹… 99^2 + 74 β‹… 99 + 4 = 3164015155 is odd. In the fourth example n = 2. Submitted Solution: ``` k, n = [int(i) for i in input().split()] a = [int(i) for i in input().split()] if len(a) != 1: if a[len(a) - 1] % 2 == 1: if k % 2 == 1: print('even') else: print('odd') else: if k % 2 == 1: print('odd') else: print('even') else: if a[len(a) - 1] % 2 == 0: print('even') else: print('odd') ```
instruction
0
98,656
5
197,312
No
output
1
98,656
5
197,313
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. The Greatest Secret Ever consists of n words, indexed by positive integers from 1 to n. The secret needs dividing between k Keepers (let's index them by positive integers from 1 to k), the i-th Keeper gets a non-empty set of words with numbers from the set Ui = (ui, 1, ui, 2, ..., ui, |Ui|). Here and below we'll presuppose that the set elements are written in the increasing order. We'll say that the secret is safe if the following conditions are hold: * for any two indexes i, j (1 ≀ i < j ≀ k) the intersection of sets Ui and Uj is an empty set; * the union of sets U1, U2, ..., Uk is set (1, 2, ..., n); * in each set Ui, its elements ui, 1, ui, 2, ..., ui, |Ui| do not form an arithmetic progression (in particular, |Ui| β‰₯ 3 should hold). Let us remind you that the elements of set (u1, u2, ..., us) form an arithmetic progression if there is such number d, that for all i (1 ≀ i < s) fulfills ui + d = ui + 1. For example, the elements of sets (5), (1, 10) and (1, 5, 9) form arithmetic progressions and the elements of sets (1, 2, 4) and (3, 6, 8) don't. Your task is to find any partition of the set of words into subsets U1, U2, ..., Uk so that the secret is safe. Otherwise indicate that there's no such partition. Input The input consists of a single line which contains two integers n and k (2 ≀ k ≀ n ≀ 106) β€” the number of words in the secret and the number of the Keepers. The numbers are separated by a single space. Output If there is no way to keep the secret safe, print a single integer "-1" (without the quotes). Otherwise, print n integers, the i-th of them representing the number of the Keeper who's got the i-th word of the secret. If there are multiple solutions, print any of them. Examples Input 11 3 Output 3 1 2 1 1 2 3 2 2 3 1 Input 5 2 Output -1 Submitted Solution: ``` n, k = map(int, input().split()) div_size = n // k if div_size < 3: print(-1) else: keepers = [] for i in range(k): keepers.append(i + 1) for i in range(k): for _ in range(div_size - 1): keepers.append(i + 1) shortage = n - len(keepers) for _ in range(shortage): keepers.append(k) print(*keepers) ```
instruction
0
98,936
5
197,872
Yes
output
1
98,936
5
197,873
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. The Greatest Secret Ever consists of n words, indexed by positive integers from 1 to n. The secret needs dividing between k Keepers (let's index them by positive integers from 1 to k), the i-th Keeper gets a non-empty set of words with numbers from the set Ui = (ui, 1, ui, 2, ..., ui, |Ui|). Here and below we'll presuppose that the set elements are written in the increasing order. We'll say that the secret is safe if the following conditions are hold: * for any two indexes i, j (1 ≀ i < j ≀ k) the intersection of sets Ui and Uj is an empty set; * the union of sets U1, U2, ..., Uk is set (1, 2, ..., n); * in each set Ui, its elements ui, 1, ui, 2, ..., ui, |Ui| do not form an arithmetic progression (in particular, |Ui| β‰₯ 3 should hold). Let us remind you that the elements of set (u1, u2, ..., us) form an arithmetic progression if there is such number d, that for all i (1 ≀ i < s) fulfills ui + d = ui + 1. For example, the elements of sets (5), (1, 10) and (1, 5, 9) form arithmetic progressions and the elements of sets (1, 2, 4) and (3, 6, 8) don't. Your task is to find any partition of the set of words into subsets U1, U2, ..., Uk so that the secret is safe. Otherwise indicate that there's no such partition. Input The input consists of a single line which contains two integers n and k (2 ≀ k ≀ n ≀ 106) β€” the number of words in the secret and the number of the Keepers. The numbers are separated by a single space. Output If there is no way to keep the secret safe, print a single integer "-1" (without the quotes). Otherwise, print n integers, the i-th of them representing the number of the Keeper who's got the i-th word of the secret. If there are multiple solutions, print any of them. Examples Input 11 3 Output 3 1 2 1 1 2 3 2 2 3 1 Input 5 2 Output -1 Submitted Solution: ``` import sys def solve(): n, k = map(int, input().split()) if n // k < 3 or n < 6: print(-1) return res = list() for i in range(1, k + 1): res.append(i) res.append(i) for i in range(1, k + 1): res.append(i) while len(res) < n: res.append(1); print(" ".join(map(str, res))) solve() ```
instruction
0
98,937
5
197,874
Yes
output
1
98,937
5
197,875
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. The Greatest Secret Ever consists of n words, indexed by positive integers from 1 to n. The secret needs dividing between k Keepers (let's index them by positive integers from 1 to k), the i-th Keeper gets a non-empty set of words with numbers from the set Ui = (ui, 1, ui, 2, ..., ui, |Ui|). Here and below we'll presuppose that the set elements are written in the increasing order. We'll say that the secret is safe if the following conditions are hold: * for any two indexes i, j (1 ≀ i < j ≀ k) the intersection of sets Ui and Uj is an empty set; * the union of sets U1, U2, ..., Uk is set (1, 2, ..., n); * in each set Ui, its elements ui, 1, ui, 2, ..., ui, |Ui| do not form an arithmetic progression (in particular, |Ui| β‰₯ 3 should hold). Let us remind you that the elements of set (u1, u2, ..., us) form an arithmetic progression if there is such number d, that for all i (1 ≀ i < s) fulfills ui + d = ui + 1. For example, the elements of sets (5), (1, 10) and (1, 5, 9) form arithmetic progressions and the elements of sets (1, 2, 4) and (3, 6, 8) don't. Your task is to find any partition of the set of words into subsets U1, U2, ..., Uk so that the secret is safe. Otherwise indicate that there's no such partition. Input The input consists of a single line which contains two integers n and k (2 ≀ k ≀ n ≀ 106) β€” the number of words in the secret and the number of the Keepers. The numbers are separated by a single space. Output If there is no way to keep the secret safe, print a single integer "-1" (without the quotes). Otherwise, print n integers, the i-th of them representing the number of the Keeper who's got the i-th word of the secret. If there are multiple solutions, print any of them. Examples Input 11 3 Output 3 1 2 1 1 2 3 2 2 3 1 Input 5 2 Output -1 Submitted Solution: ``` n, k = map(int, input().split()) if n < 3 * k: print(-1) else: d = n // k p = [min(1 + i // d, k) for i in range(n)] for i in range(d, n, 2 * d): p[i], p[i - 1] = p[i - 1], p[i] if k > 2: p[0], p[-1] = p[-1], p[0] print(' '.join(str(i) for i in p)) ```
instruction
0
98,938
5
197,876
Yes
output
1
98,938
5
197,877
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. The Greatest Secret Ever consists of n words, indexed by positive integers from 1 to n. The secret needs dividing between k Keepers (let's index them by positive integers from 1 to k), the i-th Keeper gets a non-empty set of words with numbers from the set Ui = (ui, 1, ui, 2, ..., ui, |Ui|). Here and below we'll presuppose that the set elements are written in the increasing order. We'll say that the secret is safe if the following conditions are hold: * for any two indexes i, j (1 ≀ i < j ≀ k) the intersection of sets Ui and Uj is an empty set; * the union of sets U1, U2, ..., Uk is set (1, 2, ..., n); * in each set Ui, its elements ui, 1, ui, 2, ..., ui, |Ui| do not form an arithmetic progression (in particular, |Ui| β‰₯ 3 should hold). Let us remind you that the elements of set (u1, u2, ..., us) form an arithmetic progression if there is such number d, that for all i (1 ≀ i < s) fulfills ui + d = ui + 1. For example, the elements of sets (5), (1, 10) and (1, 5, 9) form arithmetic progressions and the elements of sets (1, 2, 4) and (3, 6, 8) don't. Your task is to find any partition of the set of words into subsets U1, U2, ..., Uk so that the secret is safe. Otherwise indicate that there's no such partition. Input The input consists of a single line which contains two integers n and k (2 ≀ k ≀ n ≀ 106) β€” the number of words in the secret and the number of the Keepers. The numbers are separated by a single space. Output If there is no way to keep the secret safe, print a single integer "-1" (without the quotes). Otherwise, print n integers, the i-th of them representing the number of the Keeper who's got the i-th word of the secret. If there are multiple solutions, print any of them. Examples Input 11 3 Output 3 1 2 1 1 2 3 2 2 3 1 Input 5 2 Output -1 Submitted Solution: ``` n, k = map(int, input().split()) if k * 3 > n: print(-1) else: ans = [] for i in range(1, k * 2 + 1): ans.append(k if i % k == 0 else i % k) if k % 2: ans.append(k) for i in range(k - 1, 0, -1): if i % 2: ans.append(ans[-1] + i) else: ans.append(ans[-1] - i) else: ans.extend([i for i in range(k, 0, -1)]) ans.extend([(k - (i % k)) for i in range(k * 3 + 1, n + 1)]) print(*ans) ```
instruction
0
98,939
5
197,878
Yes
output
1
98,939
5
197,879
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. The Greatest Secret Ever consists of n words, indexed by positive integers from 1 to n. The secret needs dividing between k Keepers (let's index them by positive integers from 1 to k), the i-th Keeper gets a non-empty set of words with numbers from the set Ui = (ui, 1, ui, 2, ..., ui, |Ui|). Here and below we'll presuppose that the set elements are written in the increasing order. We'll say that the secret is safe if the following conditions are hold: * for any two indexes i, j (1 ≀ i < j ≀ k) the intersection of sets Ui and Uj is an empty set; * the union of sets U1, U2, ..., Uk is set (1, 2, ..., n); * in each set Ui, its elements ui, 1, ui, 2, ..., ui, |Ui| do not form an arithmetic progression (in particular, |Ui| β‰₯ 3 should hold). Let us remind you that the elements of set (u1, u2, ..., us) form an arithmetic progression if there is such number d, that for all i (1 ≀ i < s) fulfills ui + d = ui + 1. For example, the elements of sets (5), (1, 10) and (1, 5, 9) form arithmetic progressions and the elements of sets (1, 2, 4) and (3, 6, 8) don't. Your task is to find any partition of the set of words into subsets U1, U2, ..., Uk so that the secret is safe. Otherwise indicate that there's no such partition. Input The input consists of a single line which contains two integers n and k (2 ≀ k ≀ n ≀ 106) β€” the number of words in the secret and the number of the Keepers. The numbers are separated by a single space. Output If there is no way to keep the secret safe, print a single integer "-1" (without the quotes). Otherwise, print n integers, the i-th of them representing the number of the Keeper who's got the i-th word of the secret. If there are multiple solutions, print any of them. Examples Input 11 3 Output 3 1 2 1 1 2 3 2 2 3 1 Input 5 2 Output -1 Submitted Solution: ``` n, k = map(int, input().split()) if k * 3 < k: print(-1) else: ans = [] for i in range(1, k * 2 + 1): ans.append(k if i % k == 0 else i % k) if k % 2: ans.append(k) for i in range(k - 1, 0, -1): if i % 2: ans.append(ans[-1] + i) else: ans.append(ans[-1] - i) else: ans.extend([i for i in range(k, 0, -1)]) ans.extend([(k - (i % k)) for i in range(k * 3 + 1, n + 1)]) print(*ans) ```
instruction
0
98,940
5
197,880
No
output
1
98,940
5
197,881
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. The Greatest Secret Ever consists of n words, indexed by positive integers from 1 to n. The secret needs dividing between k Keepers (let's index them by positive integers from 1 to k), the i-th Keeper gets a non-empty set of words with numbers from the set Ui = (ui, 1, ui, 2, ..., ui, |Ui|). Here and below we'll presuppose that the set elements are written in the increasing order. We'll say that the secret is safe if the following conditions are hold: * for any two indexes i, j (1 ≀ i < j ≀ k) the intersection of sets Ui and Uj is an empty set; * the union of sets U1, U2, ..., Uk is set (1, 2, ..., n); * in each set Ui, its elements ui, 1, ui, 2, ..., ui, |Ui| do not form an arithmetic progression (in particular, |Ui| β‰₯ 3 should hold). Let us remind you that the elements of set (u1, u2, ..., us) form an arithmetic progression if there is such number d, that for all i (1 ≀ i < s) fulfills ui + d = ui + 1. For example, the elements of sets (5), (1, 10) and (1, 5, 9) form arithmetic progressions and the elements of sets (1, 2, 4) and (3, 6, 8) don't. Your task is to find any partition of the set of words into subsets U1, U2, ..., Uk so that the secret is safe. Otherwise indicate that there's no such partition. Input The input consists of a single line which contains two integers n and k (2 ≀ k ≀ n ≀ 106) β€” the number of words in the secret and the number of the Keepers. The numbers are separated by a single space. Output If there is no way to keep the secret safe, print a single integer "-1" (without the quotes). Otherwise, print n integers, the i-th of them representing the number of the Keeper who's got the i-th word of the secret. If there are multiple solutions, print any of them. Examples Input 11 3 Output 3 1 2 1 1 2 3 2 2 3 1 Input 5 2 Output -1 Submitted Solution: ``` n, k = map(int, input().split()) if k * 3 < n: print(-1) exit(0) ans = [0] * n if n % k == 0 and (n // k) % 2 == 1: if n == 3: print(-1) exit(0) l = n - (n % 6) - 6 l = max(0, l) filled = 0 f, s = 1, 2 for i in range(l): if f > k: f = 1 if s > k: s = 1 if filled == k: break j = i % 6 r = [f, f, s, f, s, s][j] ans[i] = j if j == 5: f, s = f + 2, s + 2 filled += 1 if j == 3: filled += 1 tail = [k - 2, k - 2, k, k - 2, k - 1, k - 1, k, k, k - 1] for i in range(9): ans[l + i] = tail[i] else: filled = 0 f, s = 1, 2 for i in range(n): if f > k: f = 1 if s > k: s = 1 if filled == k: break j = i % 6 r = [f, f, s, f, s, s][j] ans[i] = j if j == 5: f, s = f + 2, s + 2 filled += 1 if j == 3: filled += 1 for z in range(i, n): ans[z] = 1 print(*ans) ```
instruction
0
98,941
5
197,882
No
output
1
98,941
5
197,883
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. The Greatest Secret Ever consists of n words, indexed by positive integers from 1 to n. The secret needs dividing between k Keepers (let's index them by positive integers from 1 to k), the i-th Keeper gets a non-empty set of words with numbers from the set Ui = (ui, 1, ui, 2, ..., ui, |Ui|). Here and below we'll presuppose that the set elements are written in the increasing order. We'll say that the secret is safe if the following conditions are hold: * for any two indexes i, j (1 ≀ i < j ≀ k) the intersection of sets Ui and Uj is an empty set; * the union of sets U1, U2, ..., Uk is set (1, 2, ..., n); * in each set Ui, its elements ui, 1, ui, 2, ..., ui, |Ui| do not form an arithmetic progression (in particular, |Ui| β‰₯ 3 should hold). Let us remind you that the elements of set (u1, u2, ..., us) form an arithmetic progression if there is such number d, that for all i (1 ≀ i < s) fulfills ui + d = ui + 1. For example, the elements of sets (5), (1, 10) and (1, 5, 9) form arithmetic progressions and the elements of sets (1, 2, 4) and (3, 6, 8) don't. Your task is to find any partition of the set of words into subsets U1, U2, ..., Uk so that the secret is safe. Otherwise indicate that there's no such partition. Input The input consists of a single line which contains two integers n and k (2 ≀ k ≀ n ≀ 106) β€” the number of words in the secret and the number of the Keepers. The numbers are separated by a single space. Output If there is no way to keep the secret safe, print a single integer "-1" (without the quotes). Otherwise, print n integers, the i-th of them representing the number of the Keeper who's got the i-th word of the secret. If there are multiple solutions, print any of them. Examples Input 11 3 Output 3 1 2 1 1 2 3 2 2 3 1 Input 5 2 Output -1 Submitted Solution: ``` n, k = map(int, input().split()) if n < 3*k: print(-1) quit() ans = [1]*n from random import randint for i in range(n): ans[i] = randint(1, k) print(" ".join(str(k) for k in ans)) ```
instruction
0
98,942
5
197,884
No
output
1
98,942
5
197,885
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. The Greatest Secret Ever consists of n words, indexed by positive integers from 1 to n. The secret needs dividing between k Keepers (let's index them by positive integers from 1 to k), the i-th Keeper gets a non-empty set of words with numbers from the set Ui = (ui, 1, ui, 2, ..., ui, |Ui|). Here and below we'll presuppose that the set elements are written in the increasing order. We'll say that the secret is safe if the following conditions are hold: * for any two indexes i, j (1 ≀ i < j ≀ k) the intersection of sets Ui and Uj is an empty set; * the union of sets U1, U2, ..., Uk is set (1, 2, ..., n); * in each set Ui, its elements ui, 1, ui, 2, ..., ui, |Ui| do not form an arithmetic progression (in particular, |Ui| β‰₯ 3 should hold). Let us remind you that the elements of set (u1, u2, ..., us) form an arithmetic progression if there is such number d, that for all i (1 ≀ i < s) fulfills ui + d = ui + 1. For example, the elements of sets (5), (1, 10) and (1, 5, 9) form arithmetic progressions and the elements of sets (1, 2, 4) and (3, 6, 8) don't. Your task is to find any partition of the set of words into subsets U1, U2, ..., Uk so that the secret is safe. Otherwise indicate that there's no such partition. Input The input consists of a single line which contains two integers n and k (2 ≀ k ≀ n ≀ 106) β€” the number of words in the secret and the number of the Keepers. The numbers are separated by a single space. Output If there is no way to keep the secret safe, print a single integer "-1" (without the quotes). Otherwise, print n integers, the i-th of them representing the number of the Keeper who's got the i-th word of the secret. If there are multiple solutions, print any of them. Examples Input 11 3 Output 3 1 2 1 1 2 3 2 2 3 1 Input 5 2 Output -1 Submitted Solution: ``` n, k = map(int, input().split()) if k * 3 < 9: print(-1) else: ans = [] for i in range(1, k * 2 + 1): ans.append(k if i % k == 0 else i % k) if k % 2: ans.append(k) for i in range(k - 1, 0, -1): if i % 2: ans.append(ans[-1] + i) else: ans.append(ans[-1] - i) else: ans.extend([i for i in range(k, 0, -1)]) ans.extend([(k - (i % k)) for i in range(k * 3 + 1, n + 1)]) print(*ans) ```
instruction
0
98,943
5
197,886
No
output
1
98,943
5
197,887
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Let us call a pair of integer numbers m-perfect, if at least one number in the pair is greater than or equal to m. Thus, the pairs (3, 3) and (0, 2) are 2-perfect while the pair (-1, 1) is not. Two integers x, y are written on the blackboard. It is allowed to erase one of them and replace it with the sum of the numbers, (x + y). What is the minimum number of such operations one has to perform in order to make the given pair of integers m-perfect? Input Single line of the input contains three integers x, y and m ( - 1018 ≀ x, y, m ≀ 1018). Please, do not use the %lld specifier to read or write 64-bit integers in C++. It is preffered to use the cin, cout streams or the %I64d specifier. Output Print the minimum number of operations or "-1" (without quotes), if it is impossible to transform the given pair to the m-perfect one. Examples Input 1 2 5 Output 2 Input -1 4 15 Output 4 Input 0 -1 5 Output -1 Note In the first sample the following sequence of operations is suitable: (1, 2) <image> (3, 2) <image> (5, 2). In the second sample: (-1, 4) <image> (3, 4) <image> (7, 4) <image> (11, 4) <image> (15, 4). Finally, in the third sample x, y cannot be made positive, hence there is no proper sequence of operations. Submitted Solution: ``` x, y, m = map(int, input().split()) a, b = max(x, y), min(x, y) if a >= m: print(0) exit() if a <= 0: print(-1) exit() res = 0 if b < 0: res += -b // a b += res * a if a < b: a, b = b, a while a < m: b += a res += 1 if a < b: a, b = b, a print(res) ```
instruction
0
98,952
5
197,904
Yes
output
1
98,952
5
197,905
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Let us call a pair of integer numbers m-perfect, if at least one number in the pair is greater than or equal to m. Thus, the pairs (3, 3) and (0, 2) are 2-perfect while the pair (-1, 1) is not. Two integers x, y are written on the blackboard. It is allowed to erase one of them and replace it with the sum of the numbers, (x + y). What is the minimum number of such operations one has to perform in order to make the given pair of integers m-perfect? Input Single line of the input contains three integers x, y and m ( - 1018 ≀ x, y, m ≀ 1018). Please, do not use the %lld specifier to read or write 64-bit integers in C++. It is preffered to use the cin, cout streams or the %I64d specifier. Output Print the minimum number of operations or "-1" (without quotes), if it is impossible to transform the given pair to the m-perfect one. Examples Input 1 2 5 Output 2 Input -1 4 15 Output 4 Input 0 -1 5 Output -1 Note In the first sample the following sequence of operations is suitable: (1, 2) <image> (3, 2) <image> (5, 2). In the second sample: (-1, 4) <image> (3, 4) <image> (7, 4) <image> (11, 4) <image> (15, 4). Finally, in the third sample x, y cannot be made positive, hence there is no proper sequence of operations. Submitted Solution: ``` s = input().split() x, y, m = (int(i) for i in s) ans = 0 if x >= m or y >= m: print(0) elif x <= 0 and y <= 0: print(-1) else: if x < 0: q = abs(x // y) ans += q x += y * q elif y < 0: q = abs(y // x) ans += q y += x * q while x < m and y < m: ans += 1 if x < y: x = x + y else: y = x + y print(ans) ```
instruction
0
98,953
5
197,906
Yes
output
1
98,953
5
197,907
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Let us call a pair of integer numbers m-perfect, if at least one number in the pair is greater than or equal to m. Thus, the pairs (3, 3) and (0, 2) are 2-perfect while the pair (-1, 1) is not. Two integers x, y are written on the blackboard. It is allowed to erase one of them and replace it with the sum of the numbers, (x + y). What is the minimum number of such operations one has to perform in order to make the given pair of integers m-perfect? Input Single line of the input contains three integers x, y and m ( - 1018 ≀ x, y, m ≀ 1018). Please, do not use the %lld specifier to read or write 64-bit integers in C++. It is preffered to use the cin, cout streams or the %I64d specifier. Output Print the minimum number of operations or "-1" (without quotes), if it is impossible to transform the given pair to the m-perfect one. Examples Input 1 2 5 Output 2 Input -1 4 15 Output 4 Input 0 -1 5 Output -1 Note In the first sample the following sequence of operations is suitable: (1, 2) <image> (3, 2) <image> (5, 2). In the second sample: (-1, 4) <image> (3, 4) <image> (7, 4) <image> (11, 4) <image> (15, 4). Finally, in the third sample x, y cannot be made positive, hence there is no proper sequence of operations. Submitted Solution: ``` x, y, m = map(int, input().split()) res = 0 if (max(x, y) >= m): print(0) elif (x+y<m and x<=0 and y<=0): if (max(x,y)<m): print(-1) else: print(0) else: if x*y<0: x, y = min(x,y), max(x,y) if (y>=m): print(0) else: res += -x//y x += y*res while(max(x,y)<m): x, y = max(x,y), x+y res += 1 print(res) ```
instruction
0
98,954
5
197,908
Yes
output
1
98,954
5
197,909
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Let us call a pair of integer numbers m-perfect, if at least one number in the pair is greater than or equal to m. Thus, the pairs (3, 3) and (0, 2) are 2-perfect while the pair (-1, 1) is not. Two integers x, y are written on the blackboard. It is allowed to erase one of them and replace it with the sum of the numbers, (x + y). What is the minimum number of such operations one has to perform in order to make the given pair of integers m-perfect? Input Single line of the input contains three integers x, y and m ( - 1018 ≀ x, y, m ≀ 1018). Please, do not use the %lld specifier to read or write 64-bit integers in C++. It is preffered to use the cin, cout streams or the %I64d specifier. Output Print the minimum number of operations or "-1" (without quotes), if it is impossible to transform the given pair to the m-perfect one. Examples Input 1 2 5 Output 2 Input -1 4 15 Output 4 Input 0 -1 5 Output -1 Note In the first sample the following sequence of operations is suitable: (1, 2) <image> (3, 2) <image> (5, 2). In the second sample: (-1, 4) <image> (3, 4) <image> (7, 4) <image> (11, 4) <image> (15, 4). Finally, in the third sample x, y cannot be made positive, hence there is no proper sequence of operations. Submitted Solution: ``` x,y,m=[int(i) for i in input().split(' ')] x,y=max(x,y), min(x,y) a=0 if x>=m:print(0); quit() if x<=0: print(-1); quit() if x+y<0: a=abs(y//x)+1; y+=a*x while max(x,y)<m: if x<y: x+=y else: y+=x a+=1 print(a) ```
instruction
0
98,955
5
197,910
Yes
output
1
98,955
5
197,911
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Let us call a pair of integer numbers m-perfect, if at least one number in the pair is greater than or equal to m. Thus, the pairs (3, 3) and (0, 2) are 2-perfect while the pair (-1, 1) is not. Two integers x, y are written on the blackboard. It is allowed to erase one of them and replace it with the sum of the numbers, (x + y). What is the minimum number of such operations one has to perform in order to make the given pair of integers m-perfect? Input Single line of the input contains three integers x, y and m ( - 1018 ≀ x, y, m ≀ 1018). Please, do not use the %lld specifier to read or write 64-bit integers in C++. It is preffered to use the cin, cout streams or the %I64d specifier. Output Print the minimum number of operations or "-1" (without quotes), if it is impossible to transform the given pair to the m-perfect one. Examples Input 1 2 5 Output 2 Input -1 4 15 Output 4 Input 0 -1 5 Output -1 Note In the first sample the following sequence of operations is suitable: (1, 2) <image> (3, 2) <image> (5, 2). In the second sample: (-1, 4) <image> (3, 4) <image> (7, 4) <image> (11, 4) <image> (15, 4). Finally, in the third sample x, y cannot be made positive, hence there is no proper sequence of operations. Submitted Solution: ``` x,y,m=[int(i) for i in input().split(' ')] x,y=max(x,y), min(x,y) print(x, y, m) a=0 if x>=m:print(0); quit() if x<=0: print(-1); quit() if x+y<0: a=abs(y//x)+1; y+=a*x while max(x,y)<m: if x<y: x+=y else: y+=x a+=1 print(a) ```
instruction
0
98,956
5
197,912
No
output
1
98,956
5
197,913
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Let us call a pair of integer numbers m-perfect, if at least one number in the pair is greater than or equal to m. Thus, the pairs (3, 3) and (0, 2) are 2-perfect while the pair (-1, 1) is not. Two integers x, y are written on the blackboard. It is allowed to erase one of them and replace it with the sum of the numbers, (x + y). What is the minimum number of such operations one has to perform in order to make the given pair of integers m-perfect? Input Single line of the input contains three integers x, y and m ( - 1018 ≀ x, y, m ≀ 1018). Please, do not use the %lld specifier to read or write 64-bit integers in C++. It is preffered to use the cin, cout streams or the %I64d specifier. Output Print the minimum number of operations or "-1" (without quotes), if it is impossible to transform the given pair to the m-perfect one. Examples Input 1 2 5 Output 2 Input -1 4 15 Output 4 Input 0 -1 5 Output -1 Note In the first sample the following sequence of operations is suitable: (1, 2) <image> (3, 2) <image> (5, 2). In the second sample: (-1, 4) <image> (3, 4) <image> (7, 4) <image> (11, 4) <image> (15, 4). Finally, in the third sample x, y cannot be made positive, hence there is no proper sequence of operations. Submitted Solution: ``` import math x,y,m=map(int,input().split()) c=0 x,y=min(x,y),max(x,y) #print(x,y) if(y>=m): print(0) exit() elif(x<=0 and y<=0): print("-1") exit() elif(x<0 and y>0): c+=math.ceil((-1*x)/y) x+=y*(math.ceil((-1*x)/y)) #print(x,y,c) if x+y>=m: print(c+1) else: if x==0: x+=y y+=y c+=2 print(c+math.ceil((m+x)/(x+y))) ```
instruction
0
98,957
5
197,914
No
output
1
98,957
5
197,915
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Let us call a pair of integer numbers m-perfect, if at least one number in the pair is greater than or equal to m. Thus, the pairs (3, 3) and (0, 2) are 2-perfect while the pair (-1, 1) is not. Two integers x, y are written on the blackboard. It is allowed to erase one of them and replace it with the sum of the numbers, (x + y). What is the minimum number of such operations one has to perform in order to make the given pair of integers m-perfect? Input Single line of the input contains three integers x, y and m ( - 1018 ≀ x, y, m ≀ 1018). Please, do not use the %lld specifier to read or write 64-bit integers in C++. It is preffered to use the cin, cout streams or the %I64d specifier. Output Print the minimum number of operations or "-1" (without quotes), if it is impossible to transform the given pair to the m-perfect one. Examples Input 1 2 5 Output 2 Input -1 4 15 Output 4 Input 0 -1 5 Output -1 Note In the first sample the following sequence of operations is suitable: (1, 2) <image> (3, 2) <image> (5, 2). In the second sample: (-1, 4) <image> (3, 4) <image> (7, 4) <image> (11, 4) <image> (15, 4). Finally, in the third sample x, y cannot be made positive, hence there is no proper sequence of operations. Submitted Solution: ``` x,y,m = map(int,input().split()) a=max(x,y) if a<=0 and m>a: print(-1) else: b=max(x,y) a=min(x,y) ans = abs(b-a)//b a+=(b-a)*ans while max(a,b)<m: if a<=b: a=a+b else: b=a+b ans+=1 print(ans) ```
instruction
0
98,958
5
197,916
No
output
1
98,958
5
197,917
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Let us call a pair of integer numbers m-perfect, if at least one number in the pair is greater than or equal to m. Thus, the pairs (3, 3) and (0, 2) are 2-perfect while the pair (-1, 1) is not. Two integers x, y are written on the blackboard. It is allowed to erase one of them and replace it with the sum of the numbers, (x + y). What is the minimum number of such operations one has to perform in order to make the given pair of integers m-perfect? Input Single line of the input contains three integers x, y and m ( - 1018 ≀ x, y, m ≀ 1018). Please, do not use the %lld specifier to read or write 64-bit integers in C++. It is preffered to use the cin, cout streams or the %I64d specifier. Output Print the minimum number of operations or "-1" (without quotes), if it is impossible to transform the given pair to the m-perfect one. Examples Input 1 2 5 Output 2 Input -1 4 15 Output 4 Input 0 -1 5 Output -1 Note In the first sample the following sequence of operations is suitable: (1, 2) <image> (3, 2) <image> (5, 2). In the second sample: (-1, 4) <image> (3, 4) <image> (7, 4) <image> (11, 4) <image> (15, 4). Finally, in the third sample x, y cannot be made positive, hence there is no proper sequence of operations. Submitted Solution: ``` import os import sys from io import BytesIO, IOBase BUFSIZE = 8192 class FastIO(IOBase): newlines = 0 def __init__(self, file): self._fd = file.fileno() self.buffer = BytesIO() self.writable = "x" in file.mode or "r" not in file.mode self.write = self.buffer.write if self.writable else None def read(self): while True: b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE)) if not b: break ptr = self.buffer.tell() self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr) self.newlines = 0 return self.buffer.read() def readline(self): while self.newlines == 0: b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE)) self.newlines = b.count(b"\n") + (not b) ptr = self.buffer.tell() self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr) self.newlines -= 1 return self.buffer.readline() def flush(self): if self.writable: os.write(self._fd, self.buffer.getvalue()) self.buffer.truncate(0), self.buffer.seek(0) class IOWrapper(IOBase): def __init__(self, file): self.buffer = FastIO(file) self.flush = self.buffer.flush self.writable = self.buffer.writable self.write = lambda s: self.buffer.write(s.encode("ascii")) self.read = lambda: self.buffer.read().decode("ascii") self.readline = lambda: self.buffer.readline().decode("ascii") sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout) input = lambda: sys.stdin.readline().rstrip("\r\n") from collections import defaultdict from math import ceil,floor,sqrt,log2,gcd from heapq import heappush,heappop from bisect import bisect_left,bisect import sys abc='abcdefghijklmnopqrstuvwxyz' a,b,x=map(int,input().split()) c=0 if a>=x or b>=x: print(0) elif (a+b)<=0: print(-1) else: while a<x and b<x: # print(a,b) if a<b: a+=b c+=1 else: b+=a c+=1 # print(a,b) print(c) ```
instruction
0
98,959
5
197,918
No
output
1
98,959
5
197,919
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. At the children's day, the child came to Picks's house, and messed his house up. Picks was angry at him. A lot of important things were lost, in particular the favorite set of Picks. Fortunately, Picks remembers something about his set S: * its elements were distinct integers from 1 to limit; * the value of <image> was equal to sum; here lowbit(x) equals 2k where k is the position of the first one in the binary representation of x. For example, lowbit(100102) = 102, lowbit(100012) = 12, lowbit(100002) = 100002 (binary representation). Can you help Picks and find any set S, that satisfies all the above conditions? Input The first line contains two integers: sum, limit (1 ≀ sum, limit ≀ 105). Output In the first line print an integer n (1 ≀ n ≀ 105), denoting the size of S. Then print the elements of set S in any order. If there are multiple answers, print any of them. If it's impossible to find a suitable set, print -1. Examples Input 5 5 Output 2 4 5 Input 4 3 Output 3 2 3 1 Input 5 1 Output -1 Note In sample test 1: lowbit(4) = 4, lowbit(5) = 1, 4 + 1 = 5. In sample test 2: lowbit(1) = 1, lowbit(2) = 2, lowbit(3) = 1, 1 + 2 + 1 = 4. Submitted Solution: ``` def check(num): x=str(bin(num)) j=-1 for i in range(len(x)-1,-1,-1): j+=1 if(x[i]=='1'): break return j s,limit=[int(x) for x in input().split()] res=[] for i in range(1,limit+1): x=check(i) res.append([2**x,i]) res.sort(key=lambda x:x[0]) #print(res) ans=[] for i in range(len(res)-1,-1,-1): if(s>=res[i][0]): s-=res[i][0] ans.append(res[i][1]) if(s==0): break if(s!=0): print(-1) else: print(len(ans)) print(*ans,sep=" ") ```
instruction
0
99,014
5
198,028
Yes
output
1
99,014
5
198,029
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. At the children's day, the child came to Picks's house, and messed his house up. Picks was angry at him. A lot of important things were lost, in particular the favorite set of Picks. Fortunately, Picks remembers something about his set S: * its elements were distinct integers from 1 to limit; * the value of <image> was equal to sum; here lowbit(x) equals 2k where k is the position of the first one in the binary representation of x. For example, lowbit(100102) = 102, lowbit(100012) = 12, lowbit(100002) = 100002 (binary representation). Can you help Picks and find any set S, that satisfies all the above conditions? Input The first line contains two integers: sum, limit (1 ≀ sum, limit ≀ 105). Output In the first line print an integer n (1 ≀ n ≀ 105), denoting the size of S. Then print the elements of set S in any order. If there are multiple answers, print any of them. If it's impossible to find a suitable set, print -1. Examples Input 5 5 Output 2 4 5 Input 4 3 Output 3 2 3 1 Input 5 1 Output -1 Note In sample test 1: lowbit(4) = 4, lowbit(5) = 1, 4 + 1 = 5. In sample test 2: lowbit(1) = 1, lowbit(2) = 2, lowbit(3) = 1, 1 + 2 + 1 = 4. Submitted Solution: ``` n, m = map(int, input().split()) vals = {} temp = [] for j in range(1, m + 1): lowest_bit = j & (-j) if lowest_bit not in vals: vals[lowest_bit] = [] vals[lowest_bit].append(j) temp.append(lowest_bit) temp.sort() result = [] for x in reversed(temp): if x <=n and len(vals[x]): n -= x result.append(vals[x][-1]) vals[x].pop() if n == 0: print(len(result)) print(*result) else: print(-1) ```
instruction
0
99,015
5
198,030
Yes
output
1
99,015
5
198,031
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. At the children's day, the child came to Picks's house, and messed his house up. Picks was angry at him. A lot of important things were lost, in particular the favorite set of Picks. Fortunately, Picks remembers something about his set S: * its elements were distinct integers from 1 to limit; * the value of <image> was equal to sum; here lowbit(x) equals 2k where k is the position of the first one in the binary representation of x. For example, lowbit(100102) = 102, lowbit(100012) = 12, lowbit(100002) = 100002 (binary representation). Can you help Picks and find any set S, that satisfies all the above conditions? Input The first line contains two integers: sum, limit (1 ≀ sum, limit ≀ 105). Output In the first line print an integer n (1 ≀ n ≀ 105), denoting the size of S. Then print the elements of set S in any order. If there are multiple answers, print any of them. If it's impossible to find a suitable set, print -1. Examples Input 5 5 Output 2 4 5 Input 4 3 Output 3 2 3 1 Input 5 1 Output -1 Note In sample test 1: lowbit(4) = 4, lowbit(5) = 1, 4 + 1 = 5. In sample test 2: lowbit(1) = 1, lowbit(2) = 2, lowbit(3) = 1, 1 + 2 + 1 = 4. Submitted Solution: ``` s,limit=map(int,input().split()) Cnt=[[]] for i in range(10**5): Cnt.append([]) Ind=[0]*(10**5+1) m=0 for i in range(1,limit+1): pos=0 x=i while(x%2==0): x//=2 pos+=1 Cnt[2**pos].append(i) m=max(m,2**pos) L=[] while(s>0): e=s for j in range(min(m,s),-1,-1): if(Ind[j]<len(Cnt[j])): L.append(Cnt[j][Ind[j]]) Ind[j]+=1 s-=j m=min(m,j) break if(s==e): print(-1) break if(s==0): print(len(L)) for item in L: print(item,end=" ") ```
instruction
0
99,016
5
198,032
Yes
output
1
99,016
5
198,033
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. At the children's day, the child came to Picks's house, and messed his house up. Picks was angry at him. A lot of important things were lost, in particular the favorite set of Picks. Fortunately, Picks remembers something about his set S: * its elements were distinct integers from 1 to limit; * the value of <image> was equal to sum; here lowbit(x) equals 2k where k is the position of the first one in the binary representation of x. For example, lowbit(100102) = 102, lowbit(100012) = 12, lowbit(100002) = 100002 (binary representation). Can you help Picks and find any set S, that satisfies all the above conditions? Input The first line contains two integers: sum, limit (1 ≀ sum, limit ≀ 105). Output In the first line print an integer n (1 ≀ n ≀ 105), denoting the size of S. Then print the elements of set S in any order. If there are multiple answers, print any of them. If it's impossible to find a suitable set, print -1. Examples Input 5 5 Output 2 4 5 Input 4 3 Output 3 2 3 1 Input 5 1 Output -1 Note In sample test 1: lowbit(4) = 4, lowbit(5) = 1, 4 + 1 = 5. In sample test 2: lowbit(1) = 1, lowbit(2) = 2, lowbit(3) = 1, 1 + 2 + 1 = 4. Submitted Solution: ``` n,m=map(int,input().split()) ans=[] maxa=0 count=0 from collections import defaultdict al=defaultdict(list) for i in range(1,m+1): temp=bin(i) temp=temp[2:] temp=temp[::-1] flag=0 for j in range(len(temp)): if(temp[j]=='1'): al[pow(2,j)].append(i) count+=pow(2,j) maxa=max(maxa,pow(2,j)) flag=1 if(flag==1): break; ans=[] if(n>count): print(-1) else: while(maxa>=1 and n>0): if(n>=maxa): index=len(al[maxa])-1 while(n>=maxa and len(al[maxa])>0): ans.append(al[maxa][index]) n-=maxa al[maxa].pop() index-=1 maxa=maxa//2 print(len(ans)) print(*ans) ```
instruction
0
99,017
5
198,034
Yes
output
1
99,017
5
198,035
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. At the children's day, the child came to Picks's house, and messed his house up. Picks was angry at him. A lot of important things were lost, in particular the favorite set of Picks. Fortunately, Picks remembers something about his set S: * its elements were distinct integers from 1 to limit; * the value of <image> was equal to sum; here lowbit(x) equals 2k where k is the position of the first one in the binary representation of x. For example, lowbit(100102) = 102, lowbit(100012) = 12, lowbit(100002) = 100002 (binary representation). Can you help Picks and find any set S, that satisfies all the above conditions? Input The first line contains two integers: sum, limit (1 ≀ sum, limit ≀ 105). Output In the first line print an integer n (1 ≀ n ≀ 105), denoting the size of S. Then print the elements of set S in any order. If there are multiple answers, print any of them. If it's impossible to find a suitable set, print -1. Examples Input 5 5 Output 2 4 5 Input 4 3 Output 3 2 3 1 Input 5 1 Output -1 Note In sample test 1: lowbit(4) = 4, lowbit(5) = 1, 4 + 1 = 5. In sample test 2: lowbit(1) = 1, lowbit(2) = 2, lowbit(3) = 1, 1 + 2 + 1 = 4. Submitted Solution: ``` def lowbit(x): c = 1 while x: if x % 2: return c c *= 2 x /= 2 s, l = map(int, input().split()) x = [] for i in range(1, l + 1): x.append(lowbit(i)) ss = sum(x) if ss < s: print(-1) else: xx = 0; res = []; rc = 0 for i in range(len(x)): if xx + x[i] <= s: xx += x[i] res.append(i + 1) rc += 1 if xx == s: print(rc) for i in range(rc): print(res[i], end=' ') else: print(-1) ```
instruction
0
99,018
5
198,036
No
output
1
99,018
5
198,037
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. At the children's day, the child came to Picks's house, and messed his house up. Picks was angry at him. A lot of important things were lost, in particular the favorite set of Picks. Fortunately, Picks remembers something about his set S: * its elements were distinct integers from 1 to limit; * the value of <image> was equal to sum; here lowbit(x) equals 2k where k is the position of the first one in the binary representation of x. For example, lowbit(100102) = 102, lowbit(100012) = 12, lowbit(100002) = 100002 (binary representation). Can you help Picks and find any set S, that satisfies all the above conditions? Input The first line contains two integers: sum, limit (1 ≀ sum, limit ≀ 105). Output In the first line print an integer n (1 ≀ n ≀ 105), denoting the size of S. Then print the elements of set S in any order. If there are multiple answers, print any of them. If it's impossible to find a suitable set, print -1. Examples Input 5 5 Output 2 4 5 Input 4 3 Output 3 2 3 1 Input 5 1 Output -1 Note In sample test 1: lowbit(4) = 4, lowbit(5) = 1, 4 + 1 = 5. In sample test 2: lowbit(1) = 1, lowbit(2) = 2, lowbit(3) = 1, 1 + 2 + 1 = 4. Submitted Solution: ``` sum,limit = map(int,input().split()) def lowbit(k): count = 0 for i in k[::-1]: if i == '1': return 2**count else: count+=1 actual = 0 for i in range(1,limit+1): c = bin(i)[2:] actual+=lowbit(c) # print(actual) if sum<=actual: ans = [] count = 0 for i in range(2,limit+1,2): count+=lowbit(bin(i)[2:]) # print(count) ans.append(i) if count > sum: count-=lowbit(bin(i)[2:]) ans.pop(-1) break for i in range(1,limit+1,2): if count == sum: break else: count+=lowbit(bin(i)[2:]) ans.append(i) print(len(ans)) print(*ans) else: print(-1) ```
instruction
0
99,019
5
198,038
No
output
1
99,019
5
198,039
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. At the children's day, the child came to Picks's house, and messed his house up. Picks was angry at him. A lot of important things were lost, in particular the favorite set of Picks. Fortunately, Picks remembers something about his set S: * its elements were distinct integers from 1 to limit; * the value of <image> was equal to sum; here lowbit(x) equals 2k where k is the position of the first one in the binary representation of x. For example, lowbit(100102) = 102, lowbit(100012) = 12, lowbit(100002) = 100002 (binary representation). Can you help Picks and find any set S, that satisfies all the above conditions? Input The first line contains two integers: sum, limit (1 ≀ sum, limit ≀ 105). Output In the first line print an integer n (1 ≀ n ≀ 105), denoting the size of S. Then print the elements of set S in any order. If there are multiple answers, print any of them. If it's impossible to find a suitable set, print -1. Examples Input 5 5 Output 2 4 5 Input 4 3 Output 3 2 3 1 Input 5 1 Output -1 Note In sample test 1: lowbit(4) = 4, lowbit(5) = 1, 4 + 1 = 5. In sample test 2: lowbit(1) = 1, lowbit(2) = 2, lowbit(3) = 1, 1 + 2 + 1 = 4. Submitted Solution: ``` s,l=map(int,input().split()) list1=[] for i in range(1,l+1): list1.append(i&-i) list1.sort(reverse=True) ll=[] for i in range(l): if(list1[i]<=s): ll.append(list1[i]) s-=list1[i] if(s==0): print(len(ll)) print(*ll) else: print(-1) ```
instruction
0
99,020
5
198,040
No
output
1
99,020
5
198,041
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. At the children's day, the child came to Picks's house, and messed his house up. Picks was angry at him. A lot of important things were lost, in particular the favorite set of Picks. Fortunately, Picks remembers something about his set S: * its elements were distinct integers from 1 to limit; * the value of <image> was equal to sum; here lowbit(x) equals 2k where k is the position of the first one in the binary representation of x. For example, lowbit(100102) = 102, lowbit(100012) = 12, lowbit(100002) = 100002 (binary representation). Can you help Picks and find any set S, that satisfies all the above conditions? Input The first line contains two integers: sum, limit (1 ≀ sum, limit ≀ 105). Output In the first line print an integer n (1 ≀ n ≀ 105), denoting the size of S. Then print the elements of set S in any order. If there are multiple answers, print any of them. If it's impossible to find a suitable set, print -1. Examples Input 5 5 Output 2 4 5 Input 4 3 Output 3 2 3 1 Input 5 1 Output -1 Note In sample test 1: lowbit(4) = 4, lowbit(5) = 1, 4 + 1 = 5. In sample test 2: lowbit(1) = 1, lowbit(2) = 2, lowbit(3) = 1, 1 + 2 + 1 = 4. Submitted Solution: ``` sum, limit = map (int, input().split()) x = 0 lis = list() for i in range (sum, 0, -1) : if limit > 0 and x < sum : if i % 2 == 0 and i % 4 != 0 : x += 2 lis.append (i) limit -= 1 elif i % 4 == 0 : x += i lis.append (i) limit -= 1 else : x += 1 lis.append (i) limit -= 1 if x != sum : print (-1) else : print (len (lis)) for i in lis : print (i, "", end = '') ```
instruction
0
99,021
5
198,042
No
output
1
99,021
5
198,043
Provide a correct Python 3 solution for this coding contest problem. Enter a positive integer n of 4,000 or less, with a pair of integers a, b, c, d in the range 0-1000. a + b + c + d = n Create a program that outputs the number of combinations that satisfy the conditions. Input Given multiple datasets. Each dataset is given n on one row. Please process until the end of the input. The number of datasets does not exceed 50. Output For each data set, output the number of combinations of a, b, c, and d on one line. Example Input 2 3 35 Output 10 20 8436
instruction
0
99,345
5
198,690
"Correct Solution: ``` import sys m=1000;n=m*4 a=[0]*-~n for i in range(2001):a[i]=a[n-i]=(i+3)*(i+2)*(i+1)//6-a[~-i-m]*4*(i>~-m) for e in sys.stdin:print(a[int(e)]) ```
output
1
99,345
5
198,691
Provide a correct Python 3 solution for this coding contest problem. Enter a positive integer n of 4,000 or less, with a pair of integers a, b, c, d in the range 0-1000. a + b + c + d = n Create a program that outputs the number of combinations that satisfy the conditions. Input Given multiple datasets. Each dataset is given n on one row. Please process until the end of the input. The number of datasets does not exceed 50. Output For each data set, output the number of combinations of a, b, c, and d on one line. Example Input 2 3 35 Output 10 20 8436
instruction
0
99,346
5
198,692
"Correct Solution: ``` while True: try: n = int(input()) if n > 2000: n = 4000 - n ans = (n+1)*(n+2)*(n+3)/6 if n >= 1001: n = n - 1001 ans = ans - 2*(n+1)*(n+2)*(n+3)/3 print(int(ans)) except EOFError: break ```
output
1
99,346
5
198,693
Provide a correct Python 3 solution for this coding contest problem. Enter a positive integer n of 4,000 or less, with a pair of integers a, b, c, d in the range 0-1000. a + b + c + d = n Create a program that outputs the number of combinations that satisfy the conditions. Input Given multiple datasets. Each dataset is given n on one row. Please process until the end of the input. The number of datasets does not exceed 50. Output For each data set, output the number of combinations of a, b, c, and d on one line. Example Input 2 3 35 Output 10 20 8436
instruction
0
99,347
5
198,694
"Correct Solution: ``` import sys a=[0]*4001 for i in range(1999):a[i]=a[4000-i]=(i+3)*(i+2)*(i+1)//6-a[i-1001]*4*(i>999) for e in sys.stdin:print(a[int(e)]) ```
output
1
99,347
5
198,695
Provide a correct Python 3 solution for this coding contest problem. Enter a positive integer n of 4,000 or less, with a pair of integers a, b, c, d in the range 0-1000. a + b + c + d = n Create a program that outputs the number of combinations that satisfy the conditions. Input Given multiple datasets. Each dataset is given n on one row. Please process until the end of the input. The number of datasets does not exceed 50. Output For each data set, output the number of combinations of a, b, c, and d on one line. Example Input 2 3 35 Output 10 20 8436
instruction
0
99,348
5
198,696
"Correct Solution: ``` # -*- coding: utf-8 -*- import sys import os import math T = [0] * 2001 for a in range(1001): for b in range(1001): T[a + b] += 1 for s in sys.stdin: n = int(s) sum_n_num = 0 for a_b_sum in range(0, n+1): c_d_sum = n - a_b_sum if a_b_sum <= 2000 and c_d_sum <= 2000: sum_n_num += T[a_b_sum] * T[c_d_sum] print(sum_n_num) ```
output
1
99,348
5
198,697
Provide a correct Python 3 solution for this coding contest problem. Enter a positive integer n of 4,000 or less, with a pair of integers a, b, c, d in the range 0-1000. a + b + c + d = n Create a program that outputs the number of combinations that satisfy the conditions. Input Given multiple datasets. Each dataset is given n on one row. Please process until the end of the input. The number of datasets does not exceed 50. Output For each data set, output the number of combinations of a, b, c, and d on one line. Example Input 2 3 35 Output 10 20 8436
instruction
0
99,349
5
198,698
"Correct Solution: ``` A = [0 for i in range(2001)] for i in range(1001) : for j in range(1001) : A[i + j] += 1 while True : try : n = int(input()) cnt = 0 if(n > 4000) : print(0) elif(n > 2000) : for i in range(n - 2000, 2001) : cnt += A[i] * A[n - i] print(cnt) else : for i in range(n + 1) : cnt += A[i] * A[n - i] print(cnt) except : break ```
output
1
99,349
5
198,699
Provide a correct Python 3 solution for this coding contest problem. Enter a positive integer n of 4,000 or less, with a pair of integers a, b, c, d in the range 0-1000. a + b + c + d = n Create a program that outputs the number of combinations that satisfy the conditions. Input Given multiple datasets. Each dataset is given n on one row. Please process until the end of the input. The number of datasets does not exceed 50. Output For each data set, output the number of combinations of a, b, c, and d on one line. Example Input 2 3 35 Output 10 20 8436
instruction
0
99,350
5
198,700
"Correct Solution: ``` s = list(range(1,1001)) + list(range(1001,0,-1)) while True: try: n = int(input()) except: break ans = 0 for i in range(min(n+1,2001)): if 0 <= n-i <= 2000: ans += s[i] * s[n-i] print(ans) ```
output
1
99,350
5
198,701
Provide a correct Python 3 solution for this coding contest problem. Enter a positive integer n of 4,000 or less, with a pair of integers a, b, c, d in the range 0-1000. a + b + c + d = n Create a program that outputs the number of combinations that satisfy the conditions. Input Given multiple datasets. Each dataset is given n on one row. Please process until the end of the input. The number of datasets does not exceed 50. Output For each data set, output the number of combinations of a, b, c, and d on one line. Example Input 2 3 35 Output 10 20 8436
instruction
0
99,351
5
198,702
"Correct Solution: ``` from collections import Counter pair_dict = Counter() for i in range(2001): pair_dict[i] = min(i, 2000 - i) + 1 while True: try: n = int(input()) ans = 0 for i in range(n + 1): ans += pair_dict[i] * pair_dict[n - i] print(ans) except EOFError: break ```
output
1
99,351
5
198,703
Provide a correct Python 3 solution for this coding contest problem. Enter a positive integer n of 4,000 or less, with a pair of integers a, b, c, d in the range 0-1000. a + b + c + d = n Create a program that outputs the number of combinations that satisfy the conditions. Input Given multiple datasets. Each dataset is given n on one row. Please process until the end of the input. The number of datasets does not exceed 50. Output For each data set, output the number of combinations of a, b, c, and d on one line. Example Input 2 3 35 Output 10 20 8436
instruction
0
99,352
5
198,704
"Correct Solution: ``` import sys for line in sys.stdin.readlines(): n = int(line.rstrip()) count = 0 for i in range(1001): if 0 <= n - i <= 1000: count += (n-i+1)*(i+1) elif 1001 <= n-i <= 2000 : count += (2000-(n-i)+1)*(i+1) for i in range(1001,2001): if 0 <= n - i <= 1000: count += (n-i+1)*(2000-i+1) elif 1001 <= n-i <= 2000: count += (2000-(n-i)+1)*(2000-i+1) print(count) ```
output
1
99,352
5
198,705
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Enter a positive integer n of 4,000 or less, with a pair of integers a, b, c, d in the range 0-1000. a + b + c + d = n Create a program that outputs the number of combinations that satisfy the conditions. Input Given multiple datasets. Each dataset is given n on one row. Please process until the end of the input. The number of datasets does not exceed 50. Output For each data set, output the number of combinations of a, b, c, and d on one line. Example Input 2 3 35 Output 10 20 8436 Submitted Solution: ``` s=[0]*4001 for i in range(2001): a=a+2*(i-999)*(i-1000) if i>1000 else 0 s[i]=(i+3)*(i+2)*-~i//6-a s[4000-i]=s[i] while 1: try:print(s[int(input())]) except:break ```
instruction
0
99,355
5
198,710
Yes
output
1
99,355
5
198,711
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Enter a positive integer n of 4,000 or less, with a pair of integers a, b, c, d in the range 0-1000. a + b + c + d = n Create a program that outputs the number of combinations that satisfy the conditions. Input Given multiple datasets. Each dataset is given n on one row. Please process until the end of the input. The number of datasets does not exceed 50. Output For each data set, output the number of combinations of a, b, c, and d on one line. Example Input 2 3 35 Output 10 20 8436 Submitted Solution: ``` while True: try: N = int(input()) except EOFError: break ans = (N + 3) * (N + 2) * (N + 1) // 6 print(ans) ```
instruction
0
99,360
5
198,720
No
output
1
99,360
5
198,721
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. For given integers m and n, compute mn (mod 1,000,000,007). Here, A (mod M) is the remainder when A is divided by M. Constraints * 1 ≀ m ≀ 100 * 1 ≀ n ≀ 109 Input m n Two integers m and n are given in a line. Output Print mn (mod 1,000,000,007) in a line. Examples Input 2 3 Output 8 Input 5 8 Output 390625 Submitted Solution: ``` m,n=map(int, input().split()) MOD=10**9+7 ans = 1 t = m while n: if n&1: ans = (ans*t)%MOD n >>= 1 t = (t*t)%MOD print(ans) ```
instruction
0
99,455
5
198,910
Yes
output
1
99,455
5
198,911
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Mishka is trying really hard to avoid being kicked out of the university. In particular, he was doing absolutely nothing for the whole semester, miraculously passed some exams so that just one is left. There were n classes of that subject during the semester and on i-th class professor mentioned some non-negative integer a_i to the students. It turned out, the exam was to tell the whole sequence back to the professor. Sounds easy enough for those who attended every class, doesn't it? Obviously Mishka didn't attend any classes. However, professor left some clues on the values of a to help out students like Mishka: * a was sorted in non-decreasing order (a_1 ≀ a_2 ≀ ... ≀ a_n); * n was even; * the following sequence b, consisting of \frac n 2 elements, was formed and given out to students: b_i = a_i + a_{n - i + 1}. Professor also mentioned that any sequence a, which produces sequence b with the presented technique, will be acceptable. Help Mishka to pass that last exam. Restore any sorted sequence a of non-negative integers, which produces sequence b with the presented technique. It is guaranteed that there exists at least one correct sequence a, which produces the given sequence b. Input The first line contains a single integer n (2 ≀ n ≀ 2 β‹… 10^5) β€” the length of sequence a. n is always even. The second line contains \frac n 2 integers b_1, b_2, ..., b_{\frac n 2} (0 ≀ b_i ≀ 10^{18}) β€” sequence b, where b_i = a_i + a_{n - i + 1}. It is guaranteed that there exists at least one correct sequence a, which produces the given sequence b. Output Print n integers a_1, a_2, ..., a_n (0 ≀ a_i ≀ 10^{18}) in a single line. a_1 ≀ a_2 ≀ ... ≀ a_n should be satisfied. b_i = a_i + a_{n - i + 1} should be satisfied for all valid i. Examples Input 4 5 6 Output 2 3 3 3 Input 6 2 1 2 Output 0 0 1 1 1 2 Submitted Solution: ``` n = int(input()) b = [int(w) for w in input().split()] a = [0]*n l = n//2 - 1 r = n//2 a[l] = b[l] // 2 a[r] = b[l] - a[l] while l > 0: if b[l-1] >= b[l]: a[l-1] = a[l] a[r+1] = b[l-1] - a[l] else: a[r+1] = a[r] a[l-1] = b[l-1] - a[r] l -= 1 r += 1 print(*a) ```
instruction
0
99,511
5
199,022
Yes
output
1
99,511
5
199,023
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Mishka is trying really hard to avoid being kicked out of the university. In particular, he was doing absolutely nothing for the whole semester, miraculously passed some exams so that just one is left. There were n classes of that subject during the semester and on i-th class professor mentioned some non-negative integer a_i to the students. It turned out, the exam was to tell the whole sequence back to the professor. Sounds easy enough for those who attended every class, doesn't it? Obviously Mishka didn't attend any classes. However, professor left some clues on the values of a to help out students like Mishka: * a was sorted in non-decreasing order (a_1 ≀ a_2 ≀ ... ≀ a_n); * n was even; * the following sequence b, consisting of \frac n 2 elements, was formed and given out to students: b_i = a_i + a_{n - i + 1}. Professor also mentioned that any sequence a, which produces sequence b with the presented technique, will be acceptable. Help Mishka to pass that last exam. Restore any sorted sequence a of non-negative integers, which produces sequence b with the presented technique. It is guaranteed that there exists at least one correct sequence a, which produces the given sequence b. Input The first line contains a single integer n (2 ≀ n ≀ 2 β‹… 10^5) β€” the length of sequence a. n is always even. The second line contains \frac n 2 integers b_1, b_2, ..., b_{\frac n 2} (0 ≀ b_i ≀ 10^{18}) β€” sequence b, where b_i = a_i + a_{n - i + 1}. It is guaranteed that there exists at least one correct sequence a, which produces the given sequence b. Output Print n integers a_1, a_2, ..., a_n (0 ≀ a_i ≀ 10^{18}) in a single line. a_1 ≀ a_2 ≀ ... ≀ a_n should be satisfied. b_i = a_i + a_{n - i + 1} should be satisfied for all valid i. Examples Input 4 5 6 Output 2 3 3 3 Input 6 2 1 2 Output 0 0 1 1 1 2 Submitted Solution: ``` n=int(input()) a=[0]*n b=[int(i) for i in input().split()] for i in range(n//2): a[i]=0 a[n-i-1]=b[i] if(i==0): continue adj = max(a[i-1]-a[i],a[n-1-i]-a[n-i]) a[i]+=adj a[n-i-1]-=adj print(*a) ```
instruction
0
99,512
5
199,024
Yes
output
1
99,512
5
199,025
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Mishka is trying really hard to avoid being kicked out of the university. In particular, he was doing absolutely nothing for the whole semester, miraculously passed some exams so that just one is left. There were n classes of that subject during the semester and on i-th class professor mentioned some non-negative integer a_i to the students. It turned out, the exam was to tell the whole sequence back to the professor. Sounds easy enough for those who attended every class, doesn't it? Obviously Mishka didn't attend any classes. However, professor left some clues on the values of a to help out students like Mishka: * a was sorted in non-decreasing order (a_1 ≀ a_2 ≀ ... ≀ a_n); * n was even; * the following sequence b, consisting of \frac n 2 elements, was formed and given out to students: b_i = a_i + a_{n - i + 1}. Professor also mentioned that any sequence a, which produces sequence b with the presented technique, will be acceptable. Help Mishka to pass that last exam. Restore any sorted sequence a of non-negative integers, which produces sequence b with the presented technique. It is guaranteed that there exists at least one correct sequence a, which produces the given sequence b. Input The first line contains a single integer n (2 ≀ n ≀ 2 β‹… 10^5) β€” the length of sequence a. n is always even. The second line contains \frac n 2 integers b_1, b_2, ..., b_{\frac n 2} (0 ≀ b_i ≀ 10^{18}) β€” sequence b, where b_i = a_i + a_{n - i + 1}. It is guaranteed that there exists at least one correct sequence a, which produces the given sequence b. Output Print n integers a_1, a_2, ..., a_n (0 ≀ a_i ≀ 10^{18}) in a single line. a_1 ≀ a_2 ≀ ... ≀ a_n should be satisfied. b_i = a_i + a_{n - i + 1} should be satisfied for all valid i. Examples Input 4 5 6 Output 2 3 3 3 Input 6 2 1 2 Output 0 0 1 1 1 2 Submitted Solution: ``` import re import sys exit=sys.exit from bisect import bisect_left as bsl,bisect_right as bsr from collections import Counter,defaultdict as ddict,deque from functools import lru_cache cache=lru_cache(None) from heapq import * from itertools import * from math import inf from pprint import pprint as pp enum=enumerate ri=lambda:int(rln()) ris=lambda:list(map(int,rfs())) rln=sys.stdin.readline rl=lambda:rln().rstrip('\n') rfs=lambda:rln().split() cat=''.join catn='\n'.join mod=1000000007 d4=[(0,-1),(1,0),(0,1),(-1,0)] d8=[(-1,-1),(0,-1),(1,-1),(-1,0),(1,0),(-1,1),(0,1),(1,1)] ######################################################################## n=ri() b=ris() a=[0]*n lo,hi=0,inf for i,x in enum(b): hi=min(x-lo,hi) lo=max(lo,x-hi) a[i],a[~i]=lo,hi print(*a) ```
instruction
0
99,513
5
199,026
Yes
output
1
99,513
5
199,027
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Mishka is trying really hard to avoid being kicked out of the university. In particular, he was doing absolutely nothing for the whole semester, miraculously passed some exams so that just one is left. There were n classes of that subject during the semester and on i-th class professor mentioned some non-negative integer a_i to the students. It turned out, the exam was to tell the whole sequence back to the professor. Sounds easy enough for those who attended every class, doesn't it? Obviously Mishka didn't attend any classes. However, professor left some clues on the values of a to help out students like Mishka: * a was sorted in non-decreasing order (a_1 ≀ a_2 ≀ ... ≀ a_n); * n was even; * the following sequence b, consisting of \frac n 2 elements, was formed and given out to students: b_i = a_i + a_{n - i + 1}. Professor also mentioned that any sequence a, which produces sequence b with the presented technique, will be acceptable. Help Mishka to pass that last exam. Restore any sorted sequence a of non-negative integers, which produces sequence b with the presented technique. It is guaranteed that there exists at least one correct sequence a, which produces the given sequence b. Input The first line contains a single integer n (2 ≀ n ≀ 2 β‹… 10^5) β€” the length of sequence a. n is always even. The second line contains \frac n 2 integers b_1, b_2, ..., b_{\frac n 2} (0 ≀ b_i ≀ 10^{18}) β€” sequence b, where b_i = a_i + a_{n - i + 1}. It is guaranteed that there exists at least one correct sequence a, which produces the given sequence b. Output Print n integers a_1, a_2, ..., a_n (0 ≀ a_i ≀ 10^{18}) in a single line. a_1 ≀ a_2 ≀ ... ≀ a_n should be satisfied. b_i = a_i + a_{n - i + 1} should be satisfied for all valid i. Examples Input 4 5 6 Output 2 3 3 3 Input 6 2 1 2 Output 0 0 1 1 1 2 Submitted Solution: ``` n=int(input()) a=[0 for i in range(0,n)] b=list(map(int,input().split(" "))) a[0]=l=0;a[-1]=r=b[0] for i in range(1,n//2): if b[i]-l<=r: a[i]=l;r=a[-(i+1)]=b[i]-l elif b[i]-r>=l: a[-(i+1)]=r;l=a[i]=b[i]-r else: raise RuntimeError("gougoushishabi") for i in a: print(i,end=" ") ```
instruction
0
99,514
5
199,028
Yes
output
1
99,514
5
199,029
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Mishka is trying really hard to avoid being kicked out of the university. In particular, he was doing absolutely nothing for the whole semester, miraculously passed some exams so that just one is left. There were n classes of that subject during the semester and on i-th class professor mentioned some non-negative integer a_i to the students. It turned out, the exam was to tell the whole sequence back to the professor. Sounds easy enough for those who attended every class, doesn't it? Obviously Mishka didn't attend any classes. However, professor left some clues on the values of a to help out students like Mishka: * a was sorted in non-decreasing order (a_1 ≀ a_2 ≀ ... ≀ a_n); * n was even; * the following sequence b, consisting of \frac n 2 elements, was formed and given out to students: b_i = a_i + a_{n - i + 1}. Professor also mentioned that any sequence a, which produces sequence b with the presented technique, will be acceptable. Help Mishka to pass that last exam. Restore any sorted sequence a of non-negative integers, which produces sequence b with the presented technique. It is guaranteed that there exists at least one correct sequence a, which produces the given sequence b. Input The first line contains a single integer n (2 ≀ n ≀ 2 β‹… 10^5) β€” the length of sequence a. n is always even. The second line contains \frac n 2 integers b_1, b_2, ..., b_{\frac n 2} (0 ≀ b_i ≀ 10^{18}) β€” sequence b, where b_i = a_i + a_{n - i + 1}. It is guaranteed that there exists at least one correct sequence a, which produces the given sequence b. Output Print n integers a_1, a_2, ..., a_n (0 ≀ a_i ≀ 10^{18}) in a single line. a_1 ≀ a_2 ≀ ... ≀ a_n should be satisfied. b_i = a_i + a_{n - i + 1} should be satisfied for all valid i. Examples Input 4 5 6 Output 2 3 3 3 Input 6 2 1 2 Output 0 0 1 1 1 2 Submitted Solution: ``` n = int(input()) b = [int(elem) for elem in input().split(" ")] a = [0]*(n) a[-1] = b[0] for i in range(1, len(b)): if b[i] <= b[i-1]: if i != 0 and a[i-1] != 0: a[i] = a[i-1] a[n-i-1]=b[i]-a[i] else: a[i] = 0 a[n-i-1] = b[i] else: a[n-i-1] = a[n-i] a[i] = b[i]-b[i-1] for i in a: print(i, end=" ") print() ```
instruction
0
99,515
5
199,030
No
output
1
99,515
5
199,031
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Mishka is trying really hard to avoid being kicked out of the university. In particular, he was doing absolutely nothing for the whole semester, miraculously passed some exams so that just one is left. There were n classes of that subject during the semester and on i-th class professor mentioned some non-negative integer a_i to the students. It turned out, the exam was to tell the whole sequence back to the professor. Sounds easy enough for those who attended every class, doesn't it? Obviously Mishka didn't attend any classes. However, professor left some clues on the values of a to help out students like Mishka: * a was sorted in non-decreasing order (a_1 ≀ a_2 ≀ ... ≀ a_n); * n was even; * the following sequence b, consisting of \frac n 2 elements, was formed and given out to students: b_i = a_i + a_{n - i + 1}. Professor also mentioned that any sequence a, which produces sequence b with the presented technique, will be acceptable. Help Mishka to pass that last exam. Restore any sorted sequence a of non-negative integers, which produces sequence b with the presented technique. It is guaranteed that there exists at least one correct sequence a, which produces the given sequence b. Input The first line contains a single integer n (2 ≀ n ≀ 2 β‹… 10^5) β€” the length of sequence a. n is always even. The second line contains \frac n 2 integers b_1, b_2, ..., b_{\frac n 2} (0 ≀ b_i ≀ 10^{18}) β€” sequence b, where b_i = a_i + a_{n - i + 1}. It is guaranteed that there exists at least one correct sequence a, which produces the given sequence b. Output Print n integers a_1, a_2, ..., a_n (0 ≀ a_i ≀ 10^{18}) in a single line. a_1 ≀ a_2 ≀ ... ≀ a_n should be satisfied. b_i = a_i + a_{n - i + 1} should be satisfied for all valid i. Examples Input 4 5 6 Output 2 3 3 3 Input 6 2 1 2 Output 0 0 1 1 1 2 Submitted Solution: ``` import sys import math n=int(input()) lisa=[int(x) for x in input().strip().split()] first,second,prev=[],[],0 for i in range(n//2): if(i==0): first.append(0) second.append(lisa[i]) prev=lisa[i] else: if(prev<lisa[i]): second.append(prev) first.append(lisa[i]-prev) else: second.append(lisa[i]) first.append(0) prev=lisa[i] ksd=second[::-1] mad=first+ksd print(mad) ```
instruction
0
99,516
5
199,032
No
output
1
99,516
5
199,033
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Mishka is trying really hard to avoid being kicked out of the university. In particular, he was doing absolutely nothing for the whole semester, miraculously passed some exams so that just one is left. There were n classes of that subject during the semester and on i-th class professor mentioned some non-negative integer a_i to the students. It turned out, the exam was to tell the whole sequence back to the professor. Sounds easy enough for those who attended every class, doesn't it? Obviously Mishka didn't attend any classes. However, professor left some clues on the values of a to help out students like Mishka: * a was sorted in non-decreasing order (a_1 ≀ a_2 ≀ ... ≀ a_n); * n was even; * the following sequence b, consisting of \frac n 2 elements, was formed and given out to students: b_i = a_i + a_{n - i + 1}. Professor also mentioned that any sequence a, which produces sequence b with the presented technique, will be acceptable. Help Mishka to pass that last exam. Restore any sorted sequence a of non-negative integers, which produces sequence b with the presented technique. It is guaranteed that there exists at least one correct sequence a, which produces the given sequence b. Input The first line contains a single integer n (2 ≀ n ≀ 2 β‹… 10^5) β€” the length of sequence a. n is always even. The second line contains \frac n 2 integers b_1, b_2, ..., b_{\frac n 2} (0 ≀ b_i ≀ 10^{18}) β€” sequence b, where b_i = a_i + a_{n - i + 1}. It is guaranteed that there exists at least one correct sequence a, which produces the given sequence b. Output Print n integers a_1, a_2, ..., a_n (0 ≀ a_i ≀ 10^{18}) in a single line. a_1 ≀ a_2 ≀ ... ≀ a_n should be satisfied. b_i = a_i + a_{n - i + 1} should be satisfied for all valid i. Examples Input 4 5 6 Output 2 3 3 3 Input 6 2 1 2 Output 0 0 1 1 1 2 Submitted Solution: ``` n=int(input()) b=[int(i) for i in input().split()] a=[0]*n a[0]=0 a[n-1]=b[0] for i in range(1,n//2): if b[i]<=b[i-1]: a[i]=a[i-1] else: a[i]=a[i-1]+1 a[n-i-1]=b[i]-a[i] print(a) ```
instruction
0
99,517
5
199,034
No
output
1
99,517
5
199,035
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Mishka is trying really hard to avoid being kicked out of the university. In particular, he was doing absolutely nothing for the whole semester, miraculously passed some exams so that just one is left. There were n classes of that subject during the semester and on i-th class professor mentioned some non-negative integer a_i to the students. It turned out, the exam was to tell the whole sequence back to the professor. Sounds easy enough for those who attended every class, doesn't it? Obviously Mishka didn't attend any classes. However, professor left some clues on the values of a to help out students like Mishka: * a was sorted in non-decreasing order (a_1 ≀ a_2 ≀ ... ≀ a_n); * n was even; * the following sequence b, consisting of \frac n 2 elements, was formed and given out to students: b_i = a_i + a_{n - i + 1}. Professor also mentioned that any sequence a, which produces sequence b with the presented technique, will be acceptable. Help Mishka to pass that last exam. Restore any sorted sequence a of non-negative integers, which produces sequence b with the presented technique. It is guaranteed that there exists at least one correct sequence a, which produces the given sequence b. Input The first line contains a single integer n (2 ≀ n ≀ 2 β‹… 10^5) β€” the length of sequence a. n is always even. The second line contains \frac n 2 integers b_1, b_2, ..., b_{\frac n 2} (0 ≀ b_i ≀ 10^{18}) β€” sequence b, where b_i = a_i + a_{n - i + 1}. It is guaranteed that there exists at least one correct sequence a, which produces the given sequence b. Output Print n integers a_1, a_2, ..., a_n (0 ≀ a_i ≀ 10^{18}) in a single line. a_1 ≀ a_2 ≀ ... ≀ a_n should be satisfied. b_i = a_i + a_{n - i + 1} should be satisfied for all valid i. Examples Input 4 5 6 Output 2 3 3 3 Input 6 2 1 2 Output 0 0 1 1 1 2 Submitted Solution: ``` # your code goes here from collections import defaultdict import bisect from itertools import accumulate import os import sys import math from io import BytesIO, IOBase BUFSIZE = 8192 class FastIO(IOBase): newlines = 0 def __init__(self, file): self._fd = file.fileno() self.buffer = BytesIO() self.writable = "x" in file.mode or "r" not in file.mode self.write = self.buffer.write if self.writable else None def read(self): while True: b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE)) if not b: break ptr = self.buffer.tell() self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr) self.newlines = 0 return self.buffer.read() def readline(self): while self.newlines == 0: b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE)) self.newlines = b.count(b"\n") + (not b) ptr = self.buffer.tell() self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr) self.newlines -= 1 return self.buffer.readline() def flush(self): if self.writable: os.write(self._fd, self.buffer.getvalue()) self.buffer.truncate(0), self.buffer.seek(0) class IOWrapper(IOBase): def __init__(self, file): self.buffer = FastIO(file) self.flush = self.buffer.flush self.writable = self.buffer.writable self.write = lambda s: self.buffer.write(s.encode("ascii")) self.read = lambda: self.buffer.read().decode("ascii") self.readline = lambda: self.buffer.readline().decode("ascii") sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout) def input(): return sys.stdin.readline().rstrip("\r\n") # ------------------- fast io -------------------- n=int(input()) b=list(map(int,input().split())) ans=[0]*(n) l=0 r=10*18 for i in range(n//2): ans[i]=max(l,b[i]-r) ans[-i-1]=b[i]-ans[i] l=ans[i] r=b[i]-ans[i] print(*ans) ```
instruction
0
99,518
5
199,036
No
output
1
99,518
5
199,037
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Let f_{x} = c^{2x-6} β‹… f_{x-1} β‹… f_{x-2} β‹… f_{x-3} for x β‰₯ 4. You have given integers n, f_{1}, f_{2}, f_{3}, and c. Find f_{n} mod (10^{9}+7). Input The only line contains five integers n, f_{1}, f_{2}, f_{3}, and c (4 ≀ n ≀ 10^{18}, 1 ≀ f_{1}, f_{2}, f_{3}, c ≀ 10^{9}). Output Print f_{n} mod (10^{9} + 7). Examples Input 5 1 2 5 3 Output 72900 Input 17 97 41 37 11 Output 317451037 Note In the first example, f_{4} = 90, f_{5} = 72900. In the second example, f_{17} β‰ˆ 2.28 Γ— 10^{29587}. Submitted Solution: ``` #!/usr/bin/env python class Mat: def __init__(self, x): if x == 1: # identity self.m = [ [1, 0, 0], [0, 1, 0], [0, 0, 1], ] else: # x should be 3x3 self.m = [[ x[i][j] for j in range(3)] for i in range(3)] def __mul__(self, other): return Mat([[ (sum(self.m[i][k] * other.m[k][j] for k in range(3))) % (mod - 1) for j in range(3)] for i in range(3)]) def __rmul__(self, other): return Mat([[ (sum(other.m[i][k] * self.m[k][j] for k in range(3))) % (mod - 1) for j in range(3)] for i in range(3)]) def __mod__(self, _mod): return Mat([[ self.m[i][j] % _mod for j in range(3)] for i in range(3)]) def mat_bin_mod_pow(_mat, _mod, _pow): if _pow == 0: return Mat(1) return (mat_bin_mod_pow((_mat * _mat) % _mod, _mod, _pow >> 1) * (_mat if _pow & 1 else Mat(1))) % _mod def bin_mod_pow(_num, _mod, _pow): if _pow == 0: return 1 return (bin_mod_pow(_num**2 % _mod, _mod, _pow >> 1) * (_num if _pow & 1 else 1)) % _mod def bin_mod_inv(_num, _mod): return bin_mod_pow(_num, _mod, _mod - 2) % _mod if __name__ == "__main__": mod = 10**9 + 7 n, f1, f2, f3, c = map(int, input().split()) f = [f1, f2, f3] g = [(f[i] * c**(i + 1)) % mod for i in range(3)] mat = Mat([ [0, 1, 0], [0, 0, 1], [1, 1, 1], ]) p = mat_bin_mod_pow(_mat=mat, _mod=mod-1, _pow=n-3).m[-1] print(( bin_mod_pow(_num=g[0], _mod=mod, _pow=p[0]) * bin_mod_pow(_num=g[1], _mod=mod, _pow=p[1]) * bin_mod_pow(_num=g[2], _mod=mod, _pow=p[2]) * bin_mod_pow(_num=bin_mod_inv(_num=c, _mod=mod), _mod=mod, _pow=n) ) % mod) ```
instruction
0
99,559
5
199,118
Yes
output
1
99,559
5
199,119
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Let f_{x} = c^{2x-6} β‹… f_{x-1} β‹… f_{x-2} β‹… f_{x-3} for x β‰₯ 4. You have given integers n, f_{1}, f_{2}, f_{3}, and c. Find f_{n} mod (10^{9}+7). Input The only line contains five integers n, f_{1}, f_{2}, f_{3}, and c (4 ≀ n ≀ 10^{18}, 1 ≀ f_{1}, f_{2}, f_{3}, c ≀ 10^{9}). Output Print f_{n} mod (10^{9} + 7). Examples Input 5 1 2 5 3 Output 72900 Input 17 97 41 37 11 Output 317451037 Note In the first example, f_{4} = 90, f_{5} = 72900. In the second example, f_{17} β‰ˆ 2.28 Γ— 10^{29587}. Submitted Solution: ``` def _mul(A, B, MOD): C = [[0] * len(B[0]) for i in range(len(A))] for i in range(len(A)): for k in range(len(B)): for j in range(len(B[0])): C[i][j] = (C[i][j] + A[i][k]*B[k][j]) % MOD return C def pow_matrix(A, n, MOD): """A**nをダブγƒͺγƒ³γ‚°γ«γ‚ˆγ£γ¦ζ±‚γ‚γ‚‹""" B = [[0] * len(A) for i in range(len(A))] for i in range(len(A)): B[i][i] = 1 while n > 0: if n & 1: B = _mul(A, B, MOD) A = _mul(A, A, MOD) n = n // 2 return B n, f1, f2, f3, c = map(int, input().split()) MOD = 10**9 + 7 ans = 1 matrix = [[0]*3 for i in range(3)] matrix[0][0] = matrix[0][1] = matrix[0][2] =1 matrix[1][0] = 1 matrix[2][1] = 1 f_matrix = pow_matrix(matrix, n - 3, MOD - 1) ans *= pow(f3, f_matrix[0][0], MOD) ans *= pow(f2, f_matrix[0][1], MOD) ans *= pow(f1, f_matrix[0][2], MOD) matrix = [[0]*5 for i in range(5)] matrix[0][0] = matrix[0][1] = matrix[0][2] =1 matrix[0][3] = 2 matrix[0][4] = -6 matrix[1][0] = matrix[2][1] = 1 matrix[3][3] = matrix[3][4] = 1 matrix[4][4] = 1 c_matrix = pow_matrix(matrix, n - 3, MOD - 1) ans *= pow(c, c_matrix[0][3] * 4 + c_matrix[0][4], MOD) print(ans % MOD) ```
instruction
0
99,560
5
199,120
Yes
output
1
99,560
5
199,121
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Let f_{x} = c^{2x-6} β‹… f_{x-1} β‹… f_{x-2} β‹… f_{x-3} for x β‰₯ 4. You have given integers n, f_{1}, f_{2}, f_{3}, and c. Find f_{n} mod (10^{9}+7). Input The only line contains five integers n, f_{1}, f_{2}, f_{3}, and c (4 ≀ n ≀ 10^{18}, 1 ≀ f_{1}, f_{2}, f_{3}, c ≀ 10^{9}). Output Print f_{n} mod (10^{9} + 7). Examples Input 5 1 2 5 3 Output 72900 Input 17 97 41 37 11 Output 317451037 Note In the first example, f_{4} = 90, f_{5} = 72900. In the second example, f_{17} β‰ˆ 2.28 Γ— 10^{29587}. Submitted Solution: ``` MD = 10**9+7 def mult(A,B): n = len(A) C = [[0] * n for _ in range(n)] for i in range(len(A)): for j in range(len(A)): for k in range(len(A)): C[i][j] += A[i][k]*B[k][j] C[i][j] %= MD-1 return C def ex(A,k): n = len(A) R = [[0] * n for _ in range(n)] for i in range(n): R[i][i] = 1 while k > 0: if k & 1: R = mult(R,A) k //= 2 A = mult(A,A) return R cma = [ [1,1,1,1,0], [1,0,0,0,0], [0,1,0,0,0], [0,0,0,1,2], [0,0,0,0,1] ] tri = [ [1,1,1], [1,0,0], [0,1,0] ] n,f1,f2,f3,c = map(int,input().split()) ce = ex(cma,n-3) cp = ce[0][3]*2+ce[0][4] f = ex(tri,n-3) fp1 = f[0][2] fp2 = f[0][1] fp3 = f[0][0] r = pow(f1,fp1,MD)*pow(f2,fp2,MD)*pow(f3,fp3,MD)*pow(c,cp,MD) #print(fp1,fp2,fp3,cp) print(r%MD) ```
instruction
0
99,561
5
199,122
Yes
output
1
99,561
5
199,123
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Let f_{x} = c^{2x-6} β‹… f_{x-1} β‹… f_{x-2} β‹… f_{x-3} for x β‰₯ 4. You have given integers n, f_{1}, f_{2}, f_{3}, and c. Find f_{n} mod (10^{9}+7). Input The only line contains five integers n, f_{1}, f_{2}, f_{3}, and c (4 ≀ n ≀ 10^{18}, 1 ≀ f_{1}, f_{2}, f_{3}, c ≀ 10^{9}). Output Print f_{n} mod (10^{9} + 7). Examples Input 5 1 2 5 3 Output 72900 Input 17 97 41 37 11 Output 317451037 Note In the first example, f_{4} = 90, f_{5} = 72900. In the second example, f_{17} β‰ˆ 2.28 Γ— 10^{29587}. Submitted Solution: ``` # @author import sys class EProductOrientedRecurrence: def solve(self): MOD = 10 ** 9 + 7 D = 3 I = [ [1 if i == j else 0 for j in range(D)] for i in range(D) ] def mat_mult(A, B): n, m, p = len(A), len(A[0]), len(B[0]) assert (len(B) == m) C = [[0] * p for _ in range(n)] for i in range(n): for k in range(m): Aik = A[i][k] for j in range(p): C[i][j] = (C[i][j] + Aik * B[k][j]) % (MOD - 1) return C def mat_pow(A, p): if p == 0: return I if p == 1: return A if p % 2 == 0: return mat_pow(mat_mult(A, A), p // 2) else: return mat_mult(A, mat_pow(A, p - 1)) n, f1, f2, f3, c = [int(_) for _ in input().split()] M = [[0, 1, 0], [0, 0, 1], [1, 1, 1]] Rf1 = mat_mult(mat_pow(M, n - 1), [[1], [0], [0]])[0][0] Rf2 = mat_mult(mat_pow(M, n - 1), [[0], [1], [0]])[0][0] Rf3 = mat_mult(mat_pow(M, n - 1), [[0], [0], [1]])[0][0] Rpower = (mat_mult(mat_pow(M, n - 1), [[1], [2], [3]])[0][0] - n) % (MOD - 1) ans = pow(f1, Rf1, MOD) * pow(f2, Rf2, MOD) * pow(f3, Rf3, MOD) * pow(c, Rpower, MOD) ans %= MOD print(ans) solver = EProductOrientedRecurrence() input = sys.stdin.readline solver.solve() ```
instruction
0
99,562
5
199,124
Yes
output
1
99,562
5
199,125
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Let f_{x} = c^{2x-6} β‹… f_{x-1} β‹… f_{x-2} β‹… f_{x-3} for x β‰₯ 4. You have given integers n, f_{1}, f_{2}, f_{3}, and c. Find f_{n} mod (10^{9}+7). Input The only line contains five integers n, f_{1}, f_{2}, f_{3}, and c (4 ≀ n ≀ 10^{18}, 1 ≀ f_{1}, f_{2}, f_{3}, c ≀ 10^{9}). Output Print f_{n} mod (10^{9} + 7). Examples Input 5 1 2 5 3 Output 72900 Input 17 97 41 37 11 Output 317451037 Note In the first example, f_{4} = 90, f_{5} = 72900. In the second example, f_{17} β‰ˆ 2.28 Γ— 10^{29587}. Submitted Solution: ``` import math md = 10**9+7 def multiply(M,N): md = 10**9+7 R = [[0 for i in range(3)] for j in range(3)] for i in range(0, 3): for j in range(0, 3): for k in range(0, 3): R[i][j] += (M[i][k] * N[k][j])%md R[i][j] %= md return R def power(mat, n): res = [[1,0,0],[0,1,0],[0,0,1]] while n: if n&1: res = multiply(res, mat) mat = multiply(mat, mat) n//=2 return res n, f1, f2, f3, c = map(int, input().split()) f1 = (f1*c)%md f2 = (f2*c**2)%md f3 = (f3*c**3)%md mat = [[1,1,1],[1,0,0],[0,1,0]] res = power(mat, n-3) pw1, pw2, pw3 = res[0][2], res[0][1], res[0][0] f1 = pow(f1, pw1, md) f2 = pow(f2, pw2, md) f3 = pow(f3, pw3, md) ans = ((f1 * f2)%md * f3)%md c = pow(c, md-2, md) ans *= pow(c, n, md) ans %= md print(ans) ```
instruction
0
99,563
5
199,126
No
output
1
99,563
5
199,127