description stringlengths 171 4k | code stringlengths 94 3.98k | normalized_code stringlengths 57 4.99k |
|---|---|---|
You have a bag of size $n$. Also you have $m$ boxes. The size of $i$-th box is $a_i$, where each $a_i$ is an integer non-negative power of two.
You can divide boxes into two parts of equal size. Your goal is to fill the bag completely.
For example, if $n = 10$ and $a = [1, 1, 32]$ then you have to divide the box of size $32$ into two parts of size $16$, and then divide the box of size $16$. So you can fill the bag with boxes of size $1$, $1$ and $8$.
Calculate the minimum number of divisions required to fill the bag of size $n$.
-----Input-----
The first line contains one integer $t$ ($1 \le t \le 1000$) β the number of test cases.
The first line of each test case contains two integers $n$ and $m$ ($1 \le n \le 10^{18}, 1 \le m \le 10^5$) β the size of bag and the number of boxes, respectively.
The second line of each test case contains $m$ integers $a_1, a_2, \dots , a_m$ ($1 \le a_i \le 10^9$) β the sizes of boxes. It is guaranteed that each $a_i$ is a power of two.
It is also guaranteed that sum of all $m$ over all test cases does not exceed $10^5$.
-----Output-----
For each test case print one integer β the minimum number of divisions required to fill the bag of size $n$ (or $-1$, if it is impossible).
-----Example-----
Input
3
10 3
1 32 1
23 4
16 1 4 1
20 5
2 1 16 1 8
Output
2
-1
0 | def solve(n, A):
cnt = [0] * 64
for a in A:
cnt[a.bit_length() - 1] += 1
result = 0
for i in range(n.bit_length()):
if n >> i & 1:
for j in range(i, 64):
if cnt[j] > 0:
break
if cnt[j] == 0:
print(-1)
return
cnt[j] -= 1
result += j - i
for j in range(i, j):
cnt[j] += 1
cnt[i + 1] += cnt[i] // 2
print(result)
def main():
t = int(input().strip())
for _ in range(t):
n, m = [int(s) for s in input().strip().split()]
A = [int(s) for s in input().strip().split()]
solve(n, A)
main() | FUNC_DEF ASSIGN VAR BIN_OP LIST NUMBER NUMBER FOR VAR VAR VAR BIN_OP FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR IF BIN_OP BIN_OP VAR VAR NUMBER FOR VAR FUNC_CALL VAR VAR NUMBER IF VAR VAR NUMBER IF VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER RETURN VAR VAR NUMBER VAR BIN_OP VAR VAR FOR VAR FUNC_CALL VAR VAR VAR VAR VAR NUMBER VAR BIN_OP VAR NUMBER BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR |
You have a bag of size $n$. Also you have $m$ boxes. The size of $i$-th box is $a_i$, where each $a_i$ is an integer non-negative power of two.
You can divide boxes into two parts of equal size. Your goal is to fill the bag completely.
For example, if $n = 10$ and $a = [1, 1, 32]$ then you have to divide the box of size $32$ into two parts of size $16$, and then divide the box of size $16$. So you can fill the bag with boxes of size $1$, $1$ and $8$.
Calculate the minimum number of divisions required to fill the bag of size $n$.
-----Input-----
The first line contains one integer $t$ ($1 \le t \le 1000$) β the number of test cases.
The first line of each test case contains two integers $n$ and $m$ ($1 \le n \le 10^{18}, 1 \le m \le 10^5$) β the size of bag and the number of boxes, respectively.
The second line of each test case contains $m$ integers $a_1, a_2, \dots , a_m$ ($1 \le a_i \le 10^9$) β the sizes of boxes. It is guaranteed that each $a_i$ is a power of two.
It is also guaranteed that sum of all $m$ over all test cases does not exceed $10^5$.
-----Output-----
For each test case print one integer β the minimum number of divisions required to fill the bag of size $n$ (or $-1$, if it is impossible).
-----Example-----
Input
3
10 3
1 32 1
23 4
16 1 4 1
20 5
2 1 16 1 8
Output
2
-1
0 | q = int(input())
for rwrea in range(q):
n, m = map(int, input().split())
l = list(map(int, input().split()))
if sum(l) < n:
print(-1)
else:
dick = {}
i = 1
while i < 10**9:
dick[i] = 0
i *= 2
for i in range(m):
dick[l[i]] += 1
potrz = {}
i = 1
while n > 0:
potrz[i] = n % 2
n //= 2
i *= 2
while i < 10**9:
potrz[i] = 0
i *= 2
for i in dick:
odj = min(potrz[i], dick[i])
potrz[i] -= odj
dick[i] -= odj
kroki = 0
docelowy = {}
for i in dick:
docelowy[i] = 0
problem = 1
while True:
if problem > 10**9:
break
if potrz == docelowy:
break
if potrz[problem] == 0:
j = 1
while j <= problem:
usu = dick[j] // 2
try:
dick[j] -= 2 * usu
dick[2 * j] += usu
j *= 2
except Exception:
break
problem *= 2
else:
cykk = min(potrz[problem], dick[problem])
potrz[problem] -= cykk
dick[problem] -= cykk
if problem > 10**9:
break
if potrz[problem] > 0:
j = problem
while dick[j] == 0:
j *= 2
dick[j] -= 1
while j > problem:
kroki += 1
j //= 2
dick[j] += 1
dick[j] += 1
print(kroki) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR DICT ASSIGN VAR NUMBER WHILE VAR BIN_OP NUMBER NUMBER ASSIGN VAR VAR NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR VAR VAR NUMBER ASSIGN VAR DICT ASSIGN VAR NUMBER WHILE VAR NUMBER ASSIGN VAR VAR BIN_OP VAR NUMBER VAR NUMBER VAR NUMBER WHILE VAR BIN_OP NUMBER NUMBER ASSIGN VAR VAR NUMBER VAR NUMBER FOR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR DICT FOR VAR VAR ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER WHILE NUMBER IF VAR BIN_OP NUMBER NUMBER IF VAR VAR IF VAR VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP VAR VAR NUMBER VAR VAR BIN_OP NUMBER VAR VAR BIN_OP NUMBER VAR VAR VAR NUMBER VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR IF VAR BIN_OP NUMBER NUMBER IF VAR VAR NUMBER ASSIGN VAR VAR WHILE VAR VAR NUMBER VAR NUMBER VAR VAR NUMBER WHILE VAR VAR VAR NUMBER VAR NUMBER VAR VAR NUMBER VAR VAR NUMBER EXPR FUNC_CALL VAR VAR |
You have a bag of size $n$. Also you have $m$ boxes. The size of $i$-th box is $a_i$, where each $a_i$ is an integer non-negative power of two.
You can divide boxes into two parts of equal size. Your goal is to fill the bag completely.
For example, if $n = 10$ and $a = [1, 1, 32]$ then you have to divide the box of size $32$ into two parts of size $16$, and then divide the box of size $16$. So you can fill the bag with boxes of size $1$, $1$ and $8$.
Calculate the minimum number of divisions required to fill the bag of size $n$.
-----Input-----
The first line contains one integer $t$ ($1 \le t \le 1000$) β the number of test cases.
The first line of each test case contains two integers $n$ and $m$ ($1 \le n \le 10^{18}, 1 \le m \le 10^5$) β the size of bag and the number of boxes, respectively.
The second line of each test case contains $m$ integers $a_1, a_2, \dots , a_m$ ($1 \le a_i \le 10^9$) β the sizes of boxes. It is guaranteed that each $a_i$ is a power of two.
It is also guaranteed that sum of all $m$ over all test cases does not exceed $10^5$.
-----Output-----
For each test case print one integer β the minimum number of divisions required to fill the bag of size $n$ (or $-1$, if it is impossible).
-----Example-----
Input
3
10 3
1 32 1
23 4
16 1 4 1
20 5
2 1 16 1 8
Output
2
-1
0 | for _ in range(int(input())):
n, m = map(int, input().split())
s = map(int, input().split())
bit = [0] * 100
s = list(s)
if sum(s) < n:
print(-1)
continue
for x in s:
bit[int.bit_length(x) - 1] += 1
ans = 0
pre = None
now = n % 2
for i in range(90):
if now == 1:
if bit[i] > 0:
bit[i] -= 1
if bit[i] > 0 and pre != None:
ans += i - pre
bit[i] -= 1
pre = None
elif pre == None:
pre = i
if now == 0:
if bit[i] > 0 and pre != None:
ans += i - pre
bit[i] -= 1
pre = None
bit[i + 1] += bit[i] // 2
n //= 2
now = n % 2
print(ans) | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR NUMBER FOR VAR VAR VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR NONE ASSIGN VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER IF VAR NUMBER IF VAR VAR NUMBER VAR VAR NUMBER IF VAR VAR NUMBER VAR NONE VAR BIN_OP VAR VAR VAR VAR NUMBER ASSIGN VAR NONE IF VAR NONE ASSIGN VAR VAR IF VAR NUMBER IF VAR VAR NUMBER VAR NONE VAR BIN_OP VAR VAR VAR VAR NUMBER ASSIGN VAR NONE VAR BIN_OP VAR NUMBER BIN_OP VAR VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR |
You have a bag of size $n$. Also you have $m$ boxes. The size of $i$-th box is $a_i$, where each $a_i$ is an integer non-negative power of two.
You can divide boxes into two parts of equal size. Your goal is to fill the bag completely.
For example, if $n = 10$ and $a = [1, 1, 32]$ then you have to divide the box of size $32$ into two parts of size $16$, and then divide the box of size $16$. So you can fill the bag with boxes of size $1$, $1$ and $8$.
Calculate the minimum number of divisions required to fill the bag of size $n$.
-----Input-----
The first line contains one integer $t$ ($1 \le t \le 1000$) β the number of test cases.
The first line of each test case contains two integers $n$ and $m$ ($1 \le n \le 10^{18}, 1 \le m \le 10^5$) β the size of bag and the number of boxes, respectively.
The second line of each test case contains $m$ integers $a_1, a_2, \dots , a_m$ ($1 \le a_i \le 10^9$) β the sizes of boxes. It is guaranteed that each $a_i$ is a power of two.
It is also guaranteed that sum of all $m$ over all test cases does not exceed $10^5$.
-----Output-----
For each test case print one integer β the minimum number of divisions required to fill the bag of size $n$ (or $-1$, if it is impossible).
-----Example-----
Input
3
10 3
1 32 1
23 4
16 1 4 1
20 5
2 1 16 1 8
Output
2
-1
0 | import sys
def main():
import sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
N, M = map(int, input().split())
A = list(map(int, input().split()))
C = [0] * 100
for a in A:
C[a.bit_length() - 1] += 1
ans = 0
flg = 1
for j in range(N.bit_length()):
if N >> j & 1:
if C[j]:
C[j] -= 1
C[j + 1] += C[j] // 2
else:
ok = 1
k = j + 1
while True:
if C[k]:
C[k] -= 1
ans += k - j
for l in range(k - 1, j - 1, -1):
C[l] += 1
break
k += 1
if k == 100:
ok = 0
break
if not ok:
flg = 0
break
else:
C[j + 1] += C[j] // 2
if flg:
print(ans)
else:
print(-1)
main() | IMPORT FUNC_DEF IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER FOR VAR VAR VAR BIN_OP FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR IF BIN_OP BIN_OP VAR VAR NUMBER IF VAR VAR VAR VAR NUMBER VAR BIN_OP VAR NUMBER BIN_OP VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER WHILE NUMBER IF VAR VAR VAR VAR NUMBER VAR BIN_OP VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER NUMBER VAR VAR NUMBER VAR NUMBER IF VAR NUMBER ASSIGN VAR NUMBER IF VAR ASSIGN VAR NUMBER VAR BIN_OP VAR NUMBER BIN_OP VAR VAR NUMBER IF VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR |
You have a bag of size $n$. Also you have $m$ boxes. The size of $i$-th box is $a_i$, where each $a_i$ is an integer non-negative power of two.
You can divide boxes into two parts of equal size. Your goal is to fill the bag completely.
For example, if $n = 10$ and $a = [1, 1, 32]$ then you have to divide the box of size $32$ into two parts of size $16$, and then divide the box of size $16$. So you can fill the bag with boxes of size $1$, $1$ and $8$.
Calculate the minimum number of divisions required to fill the bag of size $n$.
-----Input-----
The first line contains one integer $t$ ($1 \le t \le 1000$) β the number of test cases.
The first line of each test case contains two integers $n$ and $m$ ($1 \le n \le 10^{18}, 1 \le m \le 10^5$) β the size of bag and the number of boxes, respectively.
The second line of each test case contains $m$ integers $a_1, a_2, \dots , a_m$ ($1 \le a_i \le 10^9$) β the sizes of boxes. It is guaranteed that each $a_i$ is a power of two.
It is also guaranteed that sum of all $m$ over all test cases does not exceed $10^5$.
-----Output-----
For each test case print one integer β the minimum number of divisions required to fill the bag of size $n$ (or $-1$, if it is impossible).
-----Example-----
Input
3
10 3
1 32 1
23 4
16 1 4 1
20 5
2 1 16 1 8
Output
2
-1
0 | t = int(input())
power = {}
for i in range(30):
power[2**i] = i
hyper = 30
for _ in range(t):
ans = 0
n, m = map(int, input().split())
raw = list(map(int, input().split()))
son = sum(raw)
if son < n:
print(-1)
continue
box = [(0) for _ in range(hyper)]
for i in range(m):
box[power[raw[i]]] += 1
box.reverse()
for d in range(hyper):
scale = 2 ** (hyper - 1 - d)
p = n // scale
mini = min(p, box[d])
son -= scale * box[d]
n -= scale * mini
box[d] -= mini
if son < n:
tmp = (n - son - 1) // scale + 1
box[d] -= tmp
box[d + 1] += 2 * tmp
ans += tmp
son += tmp * scale
print(ans) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR DICT FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP NUMBER VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR VAR VAR VAR VAR NUMBER EXPR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP NUMBER BIN_OP BIN_OP VAR NUMBER VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR VAR BIN_OP VAR VAR VAR VAR BIN_OP VAR VAR VAR VAR VAR IF VAR VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP BIN_OP VAR VAR NUMBER VAR NUMBER VAR VAR VAR VAR BIN_OP VAR NUMBER BIN_OP NUMBER VAR VAR VAR VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR VAR |
You have a bag of size $n$. Also you have $m$ boxes. The size of $i$-th box is $a_i$, where each $a_i$ is an integer non-negative power of two.
You can divide boxes into two parts of equal size. Your goal is to fill the bag completely.
For example, if $n = 10$ and $a = [1, 1, 32]$ then you have to divide the box of size $32$ into two parts of size $16$, and then divide the box of size $16$. So you can fill the bag with boxes of size $1$, $1$ and $8$.
Calculate the minimum number of divisions required to fill the bag of size $n$.
-----Input-----
The first line contains one integer $t$ ($1 \le t \le 1000$) β the number of test cases.
The first line of each test case contains two integers $n$ and $m$ ($1 \le n \le 10^{18}, 1 \le m \le 10^5$) β the size of bag and the number of boxes, respectively.
The second line of each test case contains $m$ integers $a_1, a_2, \dots , a_m$ ($1 \le a_i \le 10^9$) β the sizes of boxes. It is guaranteed that each $a_i$ is a power of two.
It is also guaranteed that sum of all $m$ over all test cases does not exceed $10^5$.
-----Output-----
For each test case print one integer β the minimum number of divisions required to fill the bag of size $n$ (or $-1$, if it is impossible).
-----Example-----
Input
3
10 3
1 32 1
23 4
16 1 4 1
20 5
2 1 16 1 8
Output
2
-1
0 | import sys
readline = sys.stdin.readline
readlines = sys.stdin.readlines
ns = lambda: readline().rstrip()
ni = lambda: int(readline().rstrip())
nm = lambda: map(int, readline().split())
nl = lambda: list(map(int, readline().split()))
prn = lambda x: print(*x, sep="\n")
def solve():
n, k = nm()
a = nl()
if sum(a) < n:
print(-1)
return
g = [0] * 80
ans = 0
for x in a:
g[x.bit_length() - 1] += 1
for i in range(64):
if n & 1 << i:
if not g[i]:
for j in range(i + 1, 64):
if g[j]:
ans += j - i
for u in range(i, j):
g[u] += 1
g[j] -= 1
break
g[i] -= 1
g[i + 1] += g[i] // 2
print(ans)
return
T = ni()
for _ in range(T):
solve() | IMPORT ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR STRING FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR IF FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR NUMBER RETURN ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR VAR VAR BIN_OP FUNC_CALL VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER IF BIN_OP VAR BIN_OP NUMBER VAR IF VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER IF VAR VAR VAR BIN_OP VAR VAR FOR VAR FUNC_CALL VAR VAR VAR VAR VAR NUMBER VAR VAR NUMBER VAR VAR NUMBER VAR BIN_OP VAR NUMBER BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR VAR RETURN ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR |
You have a bag of size $n$. Also you have $m$ boxes. The size of $i$-th box is $a_i$, where each $a_i$ is an integer non-negative power of two.
You can divide boxes into two parts of equal size. Your goal is to fill the bag completely.
For example, if $n = 10$ and $a = [1, 1, 32]$ then you have to divide the box of size $32$ into two parts of size $16$, and then divide the box of size $16$. So you can fill the bag with boxes of size $1$, $1$ and $8$.
Calculate the minimum number of divisions required to fill the bag of size $n$.
-----Input-----
The first line contains one integer $t$ ($1 \le t \le 1000$) β the number of test cases.
The first line of each test case contains two integers $n$ and $m$ ($1 \le n \le 10^{18}, 1 \le m \le 10^5$) β the size of bag and the number of boxes, respectively.
The second line of each test case contains $m$ integers $a_1, a_2, \dots , a_m$ ($1 \le a_i \le 10^9$) β the sizes of boxes. It is guaranteed that each $a_i$ is a power of two.
It is also guaranteed that sum of all $m$ over all test cases does not exceed $10^5$.
-----Output-----
For each test case print one integer β the minimum number of divisions required to fill the bag of size $n$ (or $-1$, if it is impossible).
-----Example-----
Input
3
10 3
1 32 1
23 4
16 1 4 1
20 5
2 1 16 1 8
Output
2
-1
0 | for _ in range(int(input())):
m, n = map(int, input().split())
a = list(map(int, input().split()))
mark = [0] * 65
now = 1
for indx in range(65):
for i in a:
if i == now:
mark[indx] += 1
now <<= 1
s = bin(m)[2:]
s = s[::-1]
ans = 0
flg = 1
carry = 0
indx = 0
for now in s:
if now == "0":
carry += (1 << indx) * mark[indx]
elif mark[indx]:
carry += (1 << indx) * (mark[indx] - 1)
elif carry >= 1 << indx:
carry -= 1 << indx
else:
j = indx
while j < 65:
if mark[j]:
break
j += 1
if j == 65:
flg = 0
break
mark[j] -= 1
for h in range(j - 1, indx, -1):
mark[h] += 1
ans += 1
ans += 1
indx += 1
if flg:
print(ans)
else:
print(-1) | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FOR VAR VAR IF VAR VAR VAR VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF VAR STRING VAR BIN_OP BIN_OP NUMBER VAR VAR VAR IF VAR VAR VAR BIN_OP BIN_OP NUMBER VAR BIN_OP VAR VAR NUMBER IF VAR BIN_OP NUMBER VAR VAR BIN_OP NUMBER VAR ASSIGN VAR VAR WHILE VAR NUMBER IF VAR VAR VAR NUMBER IF VAR NUMBER ASSIGN VAR NUMBER VAR VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER VAR VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER IF VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NUMBER |
You have a bag of size $n$. Also you have $m$ boxes. The size of $i$-th box is $a_i$, where each $a_i$ is an integer non-negative power of two.
You can divide boxes into two parts of equal size. Your goal is to fill the bag completely.
For example, if $n = 10$ and $a = [1, 1, 32]$ then you have to divide the box of size $32$ into two parts of size $16$, and then divide the box of size $16$. So you can fill the bag with boxes of size $1$, $1$ and $8$.
Calculate the minimum number of divisions required to fill the bag of size $n$.
-----Input-----
The first line contains one integer $t$ ($1 \le t \le 1000$) β the number of test cases.
The first line of each test case contains two integers $n$ and $m$ ($1 \le n \le 10^{18}, 1 \le m \le 10^5$) β the size of bag and the number of boxes, respectively.
The second line of each test case contains $m$ integers $a_1, a_2, \dots , a_m$ ($1 \le a_i \le 10^9$) β the sizes of boxes. It is guaranteed that each $a_i$ is a power of two.
It is also guaranteed that sum of all $m$ over all test cases does not exceed $10^5$.
-----Output-----
For each test case print one integer β the minimum number of divisions required to fill the bag of size $n$ (or $-1$, if it is impossible).
-----Example-----
Input
3
10 3
1 32 1
23 4
16 1 4 1
20 5
2 1 16 1 8
Output
2
-1
0 | table = {(1 << i): i for i in range(64)}
for _ in range(int(input())):
big, n = map(int, input().split())
pows = list(map(int, input().split()))
bits = [0] * 65
for p in pows:
bits[table[p]] += 1
ans = 0
for i in range(64):
bits[i] += bits[i - 1] // 2
if big % 2:
if bits[i] > 0:
bits[i] -= 1
else:
for j in range(i, 64):
if bits[j] != 0:
bits[j] -= 1
for k in range(j - 1, i - 1, -1):
bits[k] += 1
ans += 1
break
if j == 63:
ans = -1
break
big //= 2
print(ans) | ASSIGN VAR BIN_OP NUMBER VAR VAR VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER FOR VAR VAR VAR VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR VAR BIN_OP VAR BIN_OP VAR NUMBER NUMBER IF BIN_OP VAR NUMBER IF VAR VAR NUMBER VAR VAR NUMBER FOR VAR FUNC_CALL VAR VAR NUMBER IF VAR VAR NUMBER VAR VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER NUMBER VAR VAR NUMBER VAR NUMBER IF VAR NUMBER ASSIGN VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR |
You have a bag of size $n$. Also you have $m$ boxes. The size of $i$-th box is $a_i$, where each $a_i$ is an integer non-negative power of two.
You can divide boxes into two parts of equal size. Your goal is to fill the bag completely.
For example, if $n = 10$ and $a = [1, 1, 32]$ then you have to divide the box of size $32$ into two parts of size $16$, and then divide the box of size $16$. So you can fill the bag with boxes of size $1$, $1$ and $8$.
Calculate the minimum number of divisions required to fill the bag of size $n$.
-----Input-----
The first line contains one integer $t$ ($1 \le t \le 1000$) β the number of test cases.
The first line of each test case contains two integers $n$ and $m$ ($1 \le n \le 10^{18}, 1 \le m \le 10^5$) β the size of bag and the number of boxes, respectively.
The second line of each test case contains $m$ integers $a_1, a_2, \dots , a_m$ ($1 \le a_i \le 10^9$) β the sizes of boxes. It is guaranteed that each $a_i$ is a power of two.
It is also guaranteed that sum of all $m$ over all test cases does not exceed $10^5$.
-----Output-----
For each test case print one integer β the minimum number of divisions required to fill the bag of size $n$ (or $-1$, if it is impossible).
-----Example-----
Input
3
10 3
1 32 1
23 4
16 1 4 1
20 5
2 1 16 1 8
Output
2
-1
0 | for i in range(int(input())):
k, n = map(int, input().split())
a = list(map(int, input().split()))
d = {}
for i in a:
d[i] = d.get(i, 0) + 1
i = 0
if sum(a) < k:
print(-1)
else:
nn = k
ans = 0
while nn > 0:
if 1 << i & k > 0:
if d.get(1 << i, 0) == 0:
j = 1 << i
while d.get(j, 0) == 0:
j *= 2
ans += 1
d[j] -= 1
while j != 1 << i:
j //= 2
d[j] = d.get(j, 0) + 1
else:
d[1 << i + 1] = d.get(1 << i + 1, 0) + (d.get(1 << i, 0) - 1) // 2
nn -= 1 << i
else:
d[1 << i + 1] = d.get(1 << i + 1, 0) + d.get(1 << i, 0) // 2
i += 1
print(ans) | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR DICT FOR VAR VAR ASSIGN VAR VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER ASSIGN VAR NUMBER IF FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR VAR ASSIGN VAR NUMBER WHILE VAR NUMBER IF BIN_OP BIN_OP NUMBER VAR VAR NUMBER IF FUNC_CALL VAR BIN_OP NUMBER VAR NUMBER NUMBER ASSIGN VAR BIN_OP NUMBER VAR WHILE FUNC_CALL VAR VAR NUMBER NUMBER VAR NUMBER VAR NUMBER VAR VAR NUMBER WHILE VAR BIN_OP NUMBER VAR VAR NUMBER ASSIGN VAR VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER ASSIGN VAR BIN_OP NUMBER BIN_OP VAR NUMBER BIN_OP FUNC_CALL VAR BIN_OP NUMBER BIN_OP VAR NUMBER NUMBER BIN_OP BIN_OP FUNC_CALL VAR BIN_OP NUMBER VAR NUMBER NUMBER NUMBER VAR BIN_OP NUMBER VAR ASSIGN VAR BIN_OP NUMBER BIN_OP VAR NUMBER BIN_OP FUNC_CALL VAR BIN_OP NUMBER BIN_OP VAR NUMBER NUMBER BIN_OP FUNC_CALL VAR BIN_OP NUMBER VAR NUMBER NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR |
You have a bag of size $n$. Also you have $m$ boxes. The size of $i$-th box is $a_i$, where each $a_i$ is an integer non-negative power of two.
You can divide boxes into two parts of equal size. Your goal is to fill the bag completely.
For example, if $n = 10$ and $a = [1, 1, 32]$ then you have to divide the box of size $32$ into two parts of size $16$, and then divide the box of size $16$. So you can fill the bag with boxes of size $1$, $1$ and $8$.
Calculate the minimum number of divisions required to fill the bag of size $n$.
-----Input-----
The first line contains one integer $t$ ($1 \le t \le 1000$) β the number of test cases.
The first line of each test case contains two integers $n$ and $m$ ($1 \le n \le 10^{18}, 1 \le m \le 10^5$) β the size of bag and the number of boxes, respectively.
The second line of each test case contains $m$ integers $a_1, a_2, \dots , a_m$ ($1 \le a_i \le 10^9$) β the sizes of boxes. It is guaranteed that each $a_i$ is a power of two.
It is also guaranteed that sum of all $m$ over all test cases does not exceed $10^5$.
-----Output-----
For each test case print one integer β the minimum number of divisions required to fill the bag of size $n$ (or $-1$, if it is impossible).
-----Example-----
Input
3
10 3
1 32 1
23 4
16 1 4 1
20 5
2 1 16 1 8
Output
2
-1
0 | def main(n, m, a):
j = 0
tmp = 0
divisions = 0
for i in range(50):
if n >> i & 1 == 0:
continue
elif tmp >> i & 1 == 1:
tmp -= 1 << i
continue
elif tmp >> i & 1 == 0:
while tmp < 1 << i:
if j == len(a):
return -1
tmp += a[j]
j += 1
shift = 0
while tmp >> i + shift & 1 == 0:
shift += 1
divisions += 1
tmp -= 1 << i
return divisions
t = int(input())
for _ in range(t):
n, m = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
divisions = main(n, m, a)
print(divisions) | FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER IF BIN_OP BIN_OP VAR VAR NUMBER NUMBER IF BIN_OP BIN_OP VAR VAR NUMBER NUMBER VAR BIN_OP NUMBER VAR IF BIN_OP BIN_OP VAR VAR NUMBER NUMBER WHILE VAR BIN_OP NUMBER VAR IF VAR FUNC_CALL VAR VAR RETURN NUMBER VAR VAR VAR VAR NUMBER ASSIGN VAR NUMBER WHILE BIN_OP BIN_OP VAR BIN_OP VAR VAR NUMBER NUMBER VAR NUMBER VAR NUMBER VAR BIN_OP NUMBER VAR RETURN VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR |
You have a bag of size $n$. Also you have $m$ boxes. The size of $i$-th box is $a_i$, where each $a_i$ is an integer non-negative power of two.
You can divide boxes into two parts of equal size. Your goal is to fill the bag completely.
For example, if $n = 10$ and $a = [1, 1, 32]$ then you have to divide the box of size $32$ into two parts of size $16$, and then divide the box of size $16$. So you can fill the bag with boxes of size $1$, $1$ and $8$.
Calculate the minimum number of divisions required to fill the bag of size $n$.
-----Input-----
The first line contains one integer $t$ ($1 \le t \le 1000$) β the number of test cases.
The first line of each test case contains two integers $n$ and $m$ ($1 \le n \le 10^{18}, 1 \le m \le 10^5$) β the size of bag and the number of boxes, respectively.
The second line of each test case contains $m$ integers $a_1, a_2, \dots , a_m$ ($1 \le a_i \le 10^9$) β the sizes of boxes. It is guaranteed that each $a_i$ is a power of two.
It is also guaranteed that sum of all $m$ over all test cases does not exceed $10^5$.
-----Output-----
For each test case print one integer β the minimum number of divisions required to fill the bag of size $n$ (or $-1$, if it is impossible).
-----Example-----
Input
3
10 3
1 32 1
23 4
16 1 4 1
20 5
2 1 16 1 8
Output
2
-1
0 | for _ in range(int(input())):
a, n = map(int, input().split())
ar = [int(x) for x in input().split()]
ar.sort()
b = bin(a).replace("0b", "")
b = b[::-1]
d = {}
ans = 0
sm = 0
for i in ar:
sm += i
if i not in d:
d[i] = 1
else:
d[i] += 1
bl = False
if sm < a:
bl = True
if bl == False:
for i in range(len(b)):
if b[i] == "0":
if 2**i in d:
if 2 ** (i + 1) in d:
d[2 ** (i + 1)] += d[2**i] // 2
else:
d[2 ** (i + 1)] = d[2**i] // 2
elif 2 ** i in d and d[2**i] > 0:
d[2**i] -= 1
if 2 ** (i + 1) in d:
d[2 ** (i + 1)] += d[2**i] // 2
else:
d[2 ** (i + 1)] = d[2**i] // 2
else:
j = i + 1
while 2**j not in d:
j += 1
val = 2**j
d[val] -= 1
while val != 2**i:
val = val // 2
ans += 1
if val in d:
d[val] += 1
else:
d[val] = 1
print(ans)
else:
print("-1") | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR VAR STRING STRING ASSIGN VAR VAR NUMBER ASSIGN VAR DICT ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR VAR VAR IF VAR VAR ASSIGN VAR VAR NUMBER VAR VAR NUMBER ASSIGN VAR NUMBER IF VAR VAR ASSIGN VAR NUMBER IF VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR STRING IF BIN_OP NUMBER VAR VAR IF BIN_OP NUMBER BIN_OP VAR NUMBER VAR VAR BIN_OP NUMBER BIN_OP VAR NUMBER BIN_OP VAR BIN_OP NUMBER VAR NUMBER ASSIGN VAR BIN_OP NUMBER BIN_OP VAR NUMBER BIN_OP VAR BIN_OP NUMBER VAR NUMBER IF BIN_OP NUMBER VAR VAR VAR BIN_OP NUMBER VAR NUMBER VAR BIN_OP NUMBER VAR NUMBER IF BIN_OP NUMBER BIN_OP VAR NUMBER VAR VAR BIN_OP NUMBER BIN_OP VAR NUMBER BIN_OP VAR BIN_OP NUMBER VAR NUMBER ASSIGN VAR BIN_OP NUMBER BIN_OP VAR NUMBER BIN_OP VAR BIN_OP NUMBER VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER WHILE BIN_OP NUMBER VAR VAR VAR NUMBER ASSIGN VAR BIN_OP NUMBER VAR VAR VAR NUMBER WHILE VAR BIN_OP NUMBER VAR ASSIGN VAR BIN_OP VAR NUMBER VAR NUMBER IF VAR VAR VAR VAR NUMBER ASSIGN VAR VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR STRING |
You have a bag of size $n$. Also you have $m$ boxes. The size of $i$-th box is $a_i$, where each $a_i$ is an integer non-negative power of two.
You can divide boxes into two parts of equal size. Your goal is to fill the bag completely.
For example, if $n = 10$ and $a = [1, 1, 32]$ then you have to divide the box of size $32$ into two parts of size $16$, and then divide the box of size $16$. So you can fill the bag with boxes of size $1$, $1$ and $8$.
Calculate the minimum number of divisions required to fill the bag of size $n$.
-----Input-----
The first line contains one integer $t$ ($1 \le t \le 1000$) β the number of test cases.
The first line of each test case contains two integers $n$ and $m$ ($1 \le n \le 10^{18}, 1 \le m \le 10^5$) β the size of bag and the number of boxes, respectively.
The second line of each test case contains $m$ integers $a_1, a_2, \dots , a_m$ ($1 \le a_i \le 10^9$) β the sizes of boxes. It is guaranteed that each $a_i$ is a power of two.
It is also guaranteed that sum of all $m$ over all test cases does not exceed $10^5$.
-----Output-----
For each test case print one integer β the minimum number of divisions required to fill the bag of size $n$ (or $-1$, if it is impossible).
-----Example-----
Input
3
10 3
1 32 1
23 4
16 1 4 1
20 5
2 1 16 1 8
Output
2
-1
0 | def solve() -> None:
n = [int(i) for i in input().split()][0]
bs = [0] * 32
for i in input().split():
i = int(i)
for bi in range(len(bs) - 1, -1, -1):
bv = 1 << bi
if i & bv != 0:
bs[bi] += 1
break
sm = [bs[0]] * len(bs)
for bi in range(1, len(bs)):
bv = 1 << bi
sm[bi] = sm[bi - 1] + bv * bs[bi]
if sm[-1] < n:
print("-1")
return
res = 0
for bi in range(1, len(bs)):
bv = 1 << bi
sm[bi] = sm[bi - 1] + bv * bs[bi]
lbi = -1
for bi in range(len(bs) - 1, -1, -1):
if sm[bi] < n:
bs[bi] += 2
res += lbi - bi
bv = 1 << bi
need = min(n // bv, bs[bi])
n -= need * bv
bs[bi] -= need
if bs[bi] > 0:
lbi = bi
print(res)
t = int(input())
while t:
t -= 1
solve() | FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER NUMBER FOR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER NUMBER ASSIGN VAR BIN_OP NUMBER VAR IF BIN_OP VAR VAR NUMBER VAR VAR NUMBER ASSIGN VAR BIN_OP LIST VAR NUMBER FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR ASSIGN VAR BIN_OP NUMBER VAR ASSIGN VAR VAR BIN_OP VAR BIN_OP VAR NUMBER BIN_OP VAR VAR VAR IF VAR NUMBER VAR EXPR FUNC_CALL VAR STRING RETURN ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR ASSIGN VAR BIN_OP NUMBER VAR ASSIGN VAR VAR BIN_OP VAR BIN_OP VAR NUMBER BIN_OP VAR VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER NUMBER IF VAR VAR VAR VAR VAR NUMBER VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP NUMBER VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR VAR BIN_OP VAR VAR VAR VAR VAR IF VAR VAR NUMBER ASSIGN VAR VAR EXPR FUNC_CALL VAR VAR NONE ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR VAR NUMBER EXPR FUNC_CALL VAR |
You have a bag of size $n$. Also you have $m$ boxes. The size of $i$-th box is $a_i$, where each $a_i$ is an integer non-negative power of two.
You can divide boxes into two parts of equal size. Your goal is to fill the bag completely.
For example, if $n = 10$ and $a = [1, 1, 32]$ then you have to divide the box of size $32$ into two parts of size $16$, and then divide the box of size $16$. So you can fill the bag with boxes of size $1$, $1$ and $8$.
Calculate the minimum number of divisions required to fill the bag of size $n$.
-----Input-----
The first line contains one integer $t$ ($1 \le t \le 1000$) β the number of test cases.
The first line of each test case contains two integers $n$ and $m$ ($1 \le n \le 10^{18}, 1 \le m \le 10^5$) β the size of bag and the number of boxes, respectively.
The second line of each test case contains $m$ integers $a_1, a_2, \dots , a_m$ ($1 \le a_i \le 10^9$) β the sizes of boxes. It is guaranteed that each $a_i$ is a power of two.
It is also guaranteed that sum of all $m$ over all test cases does not exceed $10^5$.
-----Output-----
For each test case print one integer β the minimum number of divisions required to fill the bag of size $n$ (or $-1$, if it is impossible).
-----Example-----
Input
3
10 3
1 32 1
23 4
16 1 4 1
20 5
2 1 16 1 8
Output
2
-1
0 | for _ in range(int(input())):
n, m = map(int, input().split())
boxes = list(map(int, input().split()))
if sum(boxes) < n:
print(-1)
continue
needed = [0] * 60
got = [0] * 60
for b in boxes:
got[b.bit_length() - 1] += 1
divisions = 0
for bit in range(60):
if 1 << bit & n:
if got[bit]:
got[bit] -= 1
else:
for j in range(bit + 1, 60):
divisions += 1
if got[j]:
got[j] -= 1
t = j - 1
while t > bit:
got[t] += 1
t -= 1
got[t] = 1
break
if bit != 59:
got[bit + 1] += got[bit] // 2
print(divisions) | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR BIN_OP LIST NUMBER NUMBER FOR VAR VAR VAR BIN_OP FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER IF BIN_OP BIN_OP NUMBER VAR VAR IF VAR VAR VAR VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER VAR NUMBER IF VAR VAR VAR VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER WHILE VAR VAR VAR VAR NUMBER VAR NUMBER ASSIGN VAR VAR NUMBER IF VAR NUMBER VAR BIN_OP VAR NUMBER BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR VAR |
You are given an array $[a_1, a_2, \dots, a_n]$ such that $1 \le a_i \le 10^9$. Let $S$ be the sum of all elements of the array $a$.
Let's call an array $b$ of $n$ integers beautiful if:
$1 \le b_i \le 10^9$ for each $i$ from $1$ to $n$;
for every pair of adjacent integers from the array $(b_i, b_{i + 1})$, either $b_i$ divides $b_{i + 1}$, or $b_{i + 1}$ divides $b_i$ (or both);
$2 \sum \limits_{i = 1}^{n} |a_i - b_i| \le S$.
Your task is to find any beautiful array. It can be shown that at least one beautiful array always exists.
-----Input-----
The first line contains one integer $t$ ($1 \le t \le 1000$) β the number of test cases.
Each test case consists of two lines. The first line contains one integer $n$ ($2 \le n \le 50$).
The second line contains $n$ integers $a_1, a_2, \dots, a_n$ ($1 \le a_i \le 10^9$).
-----Output-----
For each test case, print the beautiful array $b_1, b_2, \dots, b_n$ ($1 \le b_i \le 10^9$) on a separate line. It can be shown that at least one beautiful array exists under these circumstances. If there are multiple answers, print any of them.
-----Examples-----
Input
4
5
1 2 3 4 5
2
4 6
2
1 1000000000
6
3 4 8 1 2 3
Output
3 3 3 3 3
3 6
1 1000000000
4 4 8 1 3 3
-----Note-----
None | import sys
t = int(sys.stdin.readline())
for _ in range(t):
n = int(sys.stdin.readline())
arr = list(map(int, sys.stdin.readline().strip().split()))
s = sum(arr)
sarr = ["1"] * n
x = sum(arr[i] for i in range(0, n, 2))
y = sum(arr[i] for i in range(1, n, 2))
if x > y:
for i in range(0, n, 2):
sarr[i] = str(arr[i])
else:
for i in range(1, n, 2):
sarr[i] = str(arr[i])
print(" ".join(sarr)) | IMPORT ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST STRING VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR FUNC_CALL VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR VAR FUNC_CALL VAR NUMBER VAR NUMBER IF VAR VAR FOR VAR FUNC_CALL VAR NUMBER VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FOR VAR FUNC_CALL VAR NUMBER VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR FUNC_CALL STRING VAR |
You are given an array $[a_1, a_2, \dots, a_n]$ such that $1 \le a_i \le 10^9$. Let $S$ be the sum of all elements of the array $a$.
Let's call an array $b$ of $n$ integers beautiful if:
$1 \le b_i \le 10^9$ for each $i$ from $1$ to $n$;
for every pair of adjacent integers from the array $(b_i, b_{i + 1})$, either $b_i$ divides $b_{i + 1}$, or $b_{i + 1}$ divides $b_i$ (or both);
$2 \sum \limits_{i = 1}^{n} |a_i - b_i| \le S$.
Your task is to find any beautiful array. It can be shown that at least one beautiful array always exists.
-----Input-----
The first line contains one integer $t$ ($1 \le t \le 1000$) β the number of test cases.
Each test case consists of two lines. The first line contains one integer $n$ ($2 \le n \le 50$).
The second line contains $n$ integers $a_1, a_2, \dots, a_n$ ($1 \le a_i \le 10^9$).
-----Output-----
For each test case, print the beautiful array $b_1, b_2, \dots, b_n$ ($1 \le b_i \le 10^9$) on a separate line. It can be shown that at least one beautiful array exists under these circumstances. If there are multiple answers, print any of them.
-----Examples-----
Input
4
5
1 2 3 4 5
2
4 6
2
1 1000000000
6
3 4 8 1 2 3
Output
3 3 3 3 3
3 6
1 1000000000
4 4 8 1 3 3
-----Note-----
None | import sys
input = sys.stdin.readline
print = sys.stdout.write
def ii():
return int(input())
def mii():
return map(int, input().rstrip().split())
def lmii():
return list(map(int, input().rstrip().split()))
t = ii()
for _ in range(t):
n = ii()
A = lmii()
for i in range(n):
tmp = 1
while tmp <= A[i]:
tmp *= 2
print(str(tmp // 2) + " ")
print("\n") | IMPORT ASSIGN VAR VAR ASSIGN VAR VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER WHILE VAR VAR VAR VAR NUMBER EXPR FUNC_CALL VAR BIN_OP FUNC_CALL VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR STRING |
You are given an array $[a_1, a_2, \dots, a_n]$ such that $1 \le a_i \le 10^9$. Let $S$ be the sum of all elements of the array $a$.
Let's call an array $b$ of $n$ integers beautiful if:
$1 \le b_i \le 10^9$ for each $i$ from $1$ to $n$;
for every pair of adjacent integers from the array $(b_i, b_{i + 1})$, either $b_i$ divides $b_{i + 1}$, or $b_{i + 1}$ divides $b_i$ (or both);
$2 \sum \limits_{i = 1}^{n} |a_i - b_i| \le S$.
Your task is to find any beautiful array. It can be shown that at least one beautiful array always exists.
-----Input-----
The first line contains one integer $t$ ($1 \le t \le 1000$) β the number of test cases.
Each test case consists of two lines. The first line contains one integer $n$ ($2 \le n \le 50$).
The second line contains $n$ integers $a_1, a_2, \dots, a_n$ ($1 \le a_i \le 10^9$).
-----Output-----
For each test case, print the beautiful array $b_1, b_2, \dots, b_n$ ($1 \le b_i \le 10^9$) on a separate line. It can be shown that at least one beautiful array exists under these circumstances. If there are multiple answers, print any of them.
-----Examples-----
Input
4
5
1 2 3 4 5
2
4 6
2
1 1000000000
6
3 4 8 1 2 3
Output
3 3 3 3 3
3 6
1 1000000000
4 4 8 1 3 3
-----Note-----
None | t = int(input())
while t > 0:
n = int(input())
a = list(map(int, input().split()))
even = sum(a[::2])
odd = sum(a[1::2])
if even >= odd:
i = 0
while i < n:
if i % 2 == 0:
print(a[i], end=" ")
else:
print(1, end=" ")
i += 1
else:
i = 0
while i < n:
if i % 2 == 1:
print(a[i], end=" ")
else:
print(1, end=" ")
i += 1
print("")
t -= 1 | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER NUMBER IF VAR VAR ASSIGN VAR NUMBER WHILE VAR VAR IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR VAR VAR STRING EXPR FUNC_CALL VAR NUMBER STRING VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR VAR VAR STRING EXPR FUNC_CALL VAR NUMBER STRING VAR NUMBER EXPR FUNC_CALL VAR STRING VAR NUMBER |
You are given an array $[a_1, a_2, \dots, a_n]$ such that $1 \le a_i \le 10^9$. Let $S$ be the sum of all elements of the array $a$.
Let's call an array $b$ of $n$ integers beautiful if:
$1 \le b_i \le 10^9$ for each $i$ from $1$ to $n$;
for every pair of adjacent integers from the array $(b_i, b_{i + 1})$, either $b_i$ divides $b_{i + 1}$, or $b_{i + 1}$ divides $b_i$ (or both);
$2 \sum \limits_{i = 1}^{n} |a_i - b_i| \le S$.
Your task is to find any beautiful array. It can be shown that at least one beautiful array always exists.
-----Input-----
The first line contains one integer $t$ ($1 \le t \le 1000$) β the number of test cases.
Each test case consists of two lines. The first line contains one integer $n$ ($2 \le n \le 50$).
The second line contains $n$ integers $a_1, a_2, \dots, a_n$ ($1 \le a_i \le 10^9$).
-----Output-----
For each test case, print the beautiful array $b_1, b_2, \dots, b_n$ ($1 \le b_i \le 10^9$) on a separate line. It can be shown that at least one beautiful array exists under these circumstances. If there are multiple answers, print any of them.
-----Examples-----
Input
4
5
1 2 3 4 5
2
4 6
2
1 1000000000
6
3 4 8 1 2 3
Output
3 3 3 3 3
3 6
1 1000000000
4 4 8 1 3 3
-----Note-----
None | for _ in range(int(input())):
n = int(input())
a = list(map(int, input().split()))
even = 0
odd = 0
for i in range(n):
if i % 2 == 0:
even += a[i]
else:
odd += a[i]
b = [0] * n
if even > odd:
i = 0
else:
i = 1
for j in range(i, n, 2):
b[j] = a[j]
for i in range(n):
if b[i] == 0:
print(1, end=" ")
else:
print(b[i], end=" ")
print() | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER NUMBER VAR VAR VAR VAR VAR VAR ASSIGN VAR BIN_OP LIST NUMBER VAR IF VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR VAR VAR VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER STRING EXPR FUNC_CALL VAR VAR VAR STRING EXPR FUNC_CALL VAR |
You are given an array $[a_1, a_2, \dots, a_n]$ such that $1 \le a_i \le 10^9$. Let $S$ be the sum of all elements of the array $a$.
Let's call an array $b$ of $n$ integers beautiful if:
$1 \le b_i \le 10^9$ for each $i$ from $1$ to $n$;
for every pair of adjacent integers from the array $(b_i, b_{i + 1})$, either $b_i$ divides $b_{i + 1}$, or $b_{i + 1}$ divides $b_i$ (or both);
$2 \sum \limits_{i = 1}^{n} |a_i - b_i| \le S$.
Your task is to find any beautiful array. It can be shown that at least one beautiful array always exists.
-----Input-----
The first line contains one integer $t$ ($1 \le t \le 1000$) β the number of test cases.
Each test case consists of two lines. The first line contains one integer $n$ ($2 \le n \le 50$).
The second line contains $n$ integers $a_1, a_2, \dots, a_n$ ($1 \le a_i \le 10^9$).
-----Output-----
For each test case, print the beautiful array $b_1, b_2, \dots, b_n$ ($1 \le b_i \le 10^9$) on a separate line. It can be shown that at least one beautiful array exists under these circumstances. If there are multiple answers, print any of them.
-----Examples-----
Input
4
5
1 2 3 4 5
2
4 6
2
1 1000000000
6
3 4 8 1 2 3
Output
3 3 3 3 3
3 6
1 1000000000
4 4 8 1 3 3
-----Note-----
None | for _ in range(int(input())):
n = map(int, input().split())
a = list(map(int, input().split()))
c = 1
i = 0
while c <= 1000000000:
d = 2 * c
if c <= a[i] <= d:
print(c, end=" ")
i += 1
d = 1
if i == len(a):
break
c = d
print("") | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR NUMBER ASSIGN VAR BIN_OP NUMBER VAR IF VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR STRING VAR NUMBER ASSIGN VAR NUMBER IF VAR FUNC_CALL VAR VAR ASSIGN VAR VAR EXPR FUNC_CALL VAR STRING |
You are given an array $[a_1, a_2, \dots, a_n]$ such that $1 \le a_i \le 10^9$. Let $S$ be the sum of all elements of the array $a$.
Let's call an array $b$ of $n$ integers beautiful if:
$1 \le b_i \le 10^9$ for each $i$ from $1$ to $n$;
for every pair of adjacent integers from the array $(b_i, b_{i + 1})$, either $b_i$ divides $b_{i + 1}$, or $b_{i + 1}$ divides $b_i$ (or both);
$2 \sum \limits_{i = 1}^{n} |a_i - b_i| \le S$.
Your task is to find any beautiful array. It can be shown that at least one beautiful array always exists.
-----Input-----
The first line contains one integer $t$ ($1 \le t \le 1000$) β the number of test cases.
Each test case consists of two lines. The first line contains one integer $n$ ($2 \le n \le 50$).
The second line contains $n$ integers $a_1, a_2, \dots, a_n$ ($1 \le a_i \le 10^9$).
-----Output-----
For each test case, print the beautiful array $b_1, b_2, \dots, b_n$ ($1 \le b_i \le 10^9$) on a separate line. It can be shown that at least one beautiful array exists under these circumstances. If there are multiple answers, print any of them.
-----Examples-----
Input
4
5
1 2 3 4 5
2
4 6
2
1 1000000000
6
3 4 8 1 2 3
Output
3 3 3 3 3
3 6
1 1000000000
4 4 8 1 3 3
-----Note-----
None | t = int(input())
for tt in range(t):
n = int(input())
a = list(map(int, input().split()))
cnt0 = 0
cnt1 = 1
for i in range(len(a)):
if i % 2 == 0:
cnt0 += a[i]
else:
cnt1 += a[i]
if cnt0 < cnt1:
for i in range(len(a)):
if i % 2 == 0:
print(1, end=" ")
else:
print(a[i], end=" ")
print()
else:
for i in range(len(a)):
if i % 2 == 1:
print(1, end=" ")
else:
print(a[i], end=" ")
print() | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER NUMBER VAR VAR VAR VAR VAR VAR IF VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR NUMBER STRING EXPR FUNC_CALL VAR VAR VAR STRING EXPR FUNC_CALL VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR NUMBER STRING EXPR FUNC_CALL VAR VAR VAR STRING EXPR FUNC_CALL VAR |
You are given an array $[a_1, a_2, \dots, a_n]$ such that $1 \le a_i \le 10^9$. Let $S$ be the sum of all elements of the array $a$.
Let's call an array $b$ of $n$ integers beautiful if:
$1 \le b_i \le 10^9$ for each $i$ from $1$ to $n$;
for every pair of adjacent integers from the array $(b_i, b_{i + 1})$, either $b_i$ divides $b_{i + 1}$, or $b_{i + 1}$ divides $b_i$ (or both);
$2 \sum \limits_{i = 1}^{n} |a_i - b_i| \le S$.
Your task is to find any beautiful array. It can be shown that at least one beautiful array always exists.
-----Input-----
The first line contains one integer $t$ ($1 \le t \le 1000$) β the number of test cases.
Each test case consists of two lines. The first line contains one integer $n$ ($2 \le n \le 50$).
The second line contains $n$ integers $a_1, a_2, \dots, a_n$ ($1 \le a_i \le 10^9$).
-----Output-----
For each test case, print the beautiful array $b_1, b_2, \dots, b_n$ ($1 \le b_i \le 10^9$) on a separate line. It can be shown that at least one beautiful array exists under these circumstances. If there are multiple answers, print any of them.
-----Examples-----
Input
4
5
1 2 3 4 5
2
4 6
2
1 1000000000
6
3 4 8 1 2 3
Output
3 3 3 3 3
3 6
1 1000000000
4 4 8 1 3 3
-----Note-----
None | for _ in range(int(input())):
n = int(input())
a = list(map(int, input().split()))
odd_sum = 0
for i in range(1, n, +2):
odd_sum += a[i]
even_sum = 0
for i in range(0, n, +2):
even_sum += a[i]
final_arr = []
if odd_sum <= even_sum:
for i in range(0, n):
if i % 2 == 0:
final_arr.append(a[i])
else:
final_arr.append(1)
else:
for i in range(0, n):
if i % 2 == 0:
final_arr.append(1)
else:
final_arr.append(a[i])
print(*final_arr) | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR NUMBER VAR VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR NUMBER VAR VAR VAR ASSIGN VAR LIST IF VAR VAR FOR VAR FUNC_CALL VAR NUMBER VAR IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR |
You are given an array $[a_1, a_2, \dots, a_n]$ such that $1 \le a_i \le 10^9$. Let $S$ be the sum of all elements of the array $a$.
Let's call an array $b$ of $n$ integers beautiful if:
$1 \le b_i \le 10^9$ for each $i$ from $1$ to $n$;
for every pair of adjacent integers from the array $(b_i, b_{i + 1})$, either $b_i$ divides $b_{i + 1}$, or $b_{i + 1}$ divides $b_i$ (or both);
$2 \sum \limits_{i = 1}^{n} |a_i - b_i| \le S$.
Your task is to find any beautiful array. It can be shown that at least one beautiful array always exists.
-----Input-----
The first line contains one integer $t$ ($1 \le t \le 1000$) β the number of test cases.
Each test case consists of two lines. The first line contains one integer $n$ ($2 \le n \le 50$).
The second line contains $n$ integers $a_1, a_2, \dots, a_n$ ($1 \le a_i \le 10^9$).
-----Output-----
For each test case, print the beautiful array $b_1, b_2, \dots, b_n$ ($1 \le b_i \le 10^9$) on a separate line. It can be shown that at least one beautiful array exists under these circumstances. If there are multiple answers, print any of them.
-----Examples-----
Input
4
5
1 2 3 4 5
2
4 6
2
1 1000000000
6
3 4 8 1 2 3
Output
3 3 3 3 3
3 6
1 1000000000
4 4 8 1 3 3
-----Note-----
None | import sys
mod = 1000000007
eps = 10**-9
def main():
import sys
input = sys.stdin.readline
for _ in range(int(input())):
N = int(input())
A = list(map(int, input().split()))
S0 = S1 = 0
for i, a in enumerate(A):
if i & 1:
S1 += a
else:
S0 += a
if S0 < S1:
B = []
for i, a in enumerate(A):
if i & 1:
B.append(a)
else:
B.append(1)
else:
B = []
for i, a in enumerate(A):
if i & 1:
B.append(1)
else:
B.append(a)
print(*B)
main() | IMPORT ASSIGN VAR NUMBER ASSIGN VAR BIN_OP NUMBER NUMBER FUNC_DEF IMPORT ASSIGN VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER FOR VAR VAR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER VAR VAR VAR VAR IF VAR VAR ASSIGN VAR LIST FOR VAR VAR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR LIST FOR VAR VAR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR |
You are given an array $[a_1, a_2, \dots, a_n]$ such that $1 \le a_i \le 10^9$. Let $S$ be the sum of all elements of the array $a$.
Let's call an array $b$ of $n$ integers beautiful if:
$1 \le b_i \le 10^9$ for each $i$ from $1$ to $n$;
for every pair of adjacent integers from the array $(b_i, b_{i + 1})$, either $b_i$ divides $b_{i + 1}$, or $b_{i + 1}$ divides $b_i$ (or both);
$2 \sum \limits_{i = 1}^{n} |a_i - b_i| \le S$.
Your task is to find any beautiful array. It can be shown that at least one beautiful array always exists.
-----Input-----
The first line contains one integer $t$ ($1 \le t \le 1000$) β the number of test cases.
Each test case consists of two lines. The first line contains one integer $n$ ($2 \le n \le 50$).
The second line contains $n$ integers $a_1, a_2, \dots, a_n$ ($1 \le a_i \le 10^9$).
-----Output-----
For each test case, print the beautiful array $b_1, b_2, \dots, b_n$ ($1 \le b_i \le 10^9$) on a separate line. It can be shown that at least one beautiful array exists under these circumstances. If there are multiple answers, print any of them.
-----Examples-----
Input
4
5
1 2 3 4 5
2
4 6
2
1 1000000000
6
3 4 8 1 2 3
Output
3 3 3 3 3
3 6
1 1000000000
4 4 8 1 3 3
-----Note-----
None | for _ in range(int(input())):
n = int(input())
a = list(map(int, input().split()))
flag = []
for i in range(n):
if i % 2 == 0:
flag.append(1)
else:
flag.append(a[i])
cnt = []
for j in range(n):
if j % 2 == 0:
cnt.append(a[j])
else:
cnt.append(1)
sum1 = 0
for num in range(n):
sum1 += abs(a[num] - flag[num])
if 2 * sum1 <= sum(a):
print(*flag)
else:
print(*cnt) | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR IF BIN_OP NUMBER VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR |
You are given an array $[a_1, a_2, \dots, a_n]$ such that $1 \le a_i \le 10^9$. Let $S$ be the sum of all elements of the array $a$.
Let's call an array $b$ of $n$ integers beautiful if:
$1 \le b_i \le 10^9$ for each $i$ from $1$ to $n$;
for every pair of adjacent integers from the array $(b_i, b_{i + 1})$, either $b_i$ divides $b_{i + 1}$, or $b_{i + 1}$ divides $b_i$ (or both);
$2 \sum \limits_{i = 1}^{n} |a_i - b_i| \le S$.
Your task is to find any beautiful array. It can be shown that at least one beautiful array always exists.
-----Input-----
The first line contains one integer $t$ ($1 \le t \le 1000$) β the number of test cases.
Each test case consists of two lines. The first line contains one integer $n$ ($2 \le n \le 50$).
The second line contains $n$ integers $a_1, a_2, \dots, a_n$ ($1 \le a_i \le 10^9$).
-----Output-----
For each test case, print the beautiful array $b_1, b_2, \dots, b_n$ ($1 \le b_i \le 10^9$) on a separate line. It can be shown that at least one beautiful array exists under these circumstances. If there are multiple answers, print any of them.
-----Examples-----
Input
4
5
1 2 3 4 5
2
4 6
2
1 1000000000
6
3 4 8 1 2 3
Output
3 3 3 3 3
3 6
1 1000000000
4 4 8 1 3 3
-----Note-----
None | import sys
input = sys.stdin.readline
def inp():
return int(input())
def inlt():
return list(map(int, input().split()))
def insr():
s = input()
return list(s[: len(s) - 1])
def invr():
return map(int, input().split())
def bam(x):
b = x.bit_length()
a = 1 << b - 1
c = 2 * a
if x - a <= c - x:
return a
else:
if c > 10**9:
return a
return c
def solve(n, ass):
return [bam(x) for x in ass]
for _ in range(inp()):
n = inp()
ass = inlt()
print(*solve(n, ass)) | IMPORT ASSIGN VAR VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR RETURN FUNC_CALL VAR VAR BIN_OP FUNC_CALL VAR VAR NUMBER FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP NUMBER VAR IF BIN_OP VAR VAR BIN_OP VAR VAR RETURN VAR IF VAR BIN_OP NUMBER NUMBER RETURN VAR RETURN VAR FUNC_DEF RETURN FUNC_CALL VAR VAR VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR |
You are given an array $[a_1, a_2, \dots, a_n]$ such that $1 \le a_i \le 10^9$. Let $S$ be the sum of all elements of the array $a$.
Let's call an array $b$ of $n$ integers beautiful if:
$1 \le b_i \le 10^9$ for each $i$ from $1$ to $n$;
for every pair of adjacent integers from the array $(b_i, b_{i + 1})$, either $b_i$ divides $b_{i + 1}$, or $b_{i + 1}$ divides $b_i$ (or both);
$2 \sum \limits_{i = 1}^{n} |a_i - b_i| \le S$.
Your task is to find any beautiful array. It can be shown that at least one beautiful array always exists.
-----Input-----
The first line contains one integer $t$ ($1 \le t \le 1000$) β the number of test cases.
Each test case consists of two lines. The first line contains one integer $n$ ($2 \le n \le 50$).
The second line contains $n$ integers $a_1, a_2, \dots, a_n$ ($1 \le a_i \le 10^9$).
-----Output-----
For each test case, print the beautiful array $b_1, b_2, \dots, b_n$ ($1 \le b_i \le 10^9$) on a separate line. It can be shown that at least one beautiful array exists under these circumstances. If there are multiple answers, print any of them.
-----Examples-----
Input
4
5
1 2 3 4 5
2
4 6
2
1 1000000000
6
3 4 8 1 2 3
Output
3 3 3 3 3
3 6
1 1000000000
4 4 8 1 3 3
-----Note-----
None | for t in range(int(input())):
n = int(input())
a = list(map(int, input().split()))
i = 0
c = [(1) for i in range(n)]
add = 0
while i < n:
add += a[i]
i += 2
sum = 0
i = 1
while i < n:
sum += a[i]
i += 2
if add > sum:
i = 0
while i < n:
c[i] = a[i]
i += 2
else:
i = 1
while i < n:
c[i] = a[i]
i += 2
for i in range(n):
print(c[i], end=" ")
print() | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER WHILE VAR VAR VAR VAR VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR VAR VAR VAR VAR NUMBER IF VAR VAR ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN VAR VAR VAR VAR VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN VAR VAR VAR VAR VAR NUMBER FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR STRING EXPR FUNC_CALL VAR |
You are given an array $[a_1, a_2, \dots, a_n]$ such that $1 \le a_i \le 10^9$. Let $S$ be the sum of all elements of the array $a$.
Let's call an array $b$ of $n$ integers beautiful if:
$1 \le b_i \le 10^9$ for each $i$ from $1$ to $n$;
for every pair of adjacent integers from the array $(b_i, b_{i + 1})$, either $b_i$ divides $b_{i + 1}$, or $b_{i + 1}$ divides $b_i$ (or both);
$2 \sum \limits_{i = 1}^{n} |a_i - b_i| \le S$.
Your task is to find any beautiful array. It can be shown that at least one beautiful array always exists.
-----Input-----
The first line contains one integer $t$ ($1 \le t \le 1000$) β the number of test cases.
Each test case consists of two lines. The first line contains one integer $n$ ($2 \le n \le 50$).
The second line contains $n$ integers $a_1, a_2, \dots, a_n$ ($1 \le a_i \le 10^9$).
-----Output-----
For each test case, print the beautiful array $b_1, b_2, \dots, b_n$ ($1 \le b_i \le 10^9$) on a separate line. It can be shown that at least one beautiful array exists under these circumstances. If there are multiple answers, print any of them.
-----Examples-----
Input
4
5
1 2 3 4 5
2
4 6
2
1 1000000000
6
3 4 8 1 2 3
Output
3 3 3 3 3
3 6
1 1000000000
4 4 8 1 3 3
-----Note-----
None | t = int(input())
for i in range(t):
n = int(input())
lst = list(map(int, input().split()))
lst1 = []
s = sum(lst)
ind = 0
c = 0
while True:
if ind > n - 1:
break
else:
if c % 2 == 0:
lst1.append(1)
else:
lst1.append(lst[ind])
ind += 1
c += 1
s1 = 0
for j in range(n):
s1 += abs(lst[j] - lst1[j])
if 2 * s1 <= s:
print(*lst1)
else:
lst1 = []
s = sum(lst)
ind = 0
c = 0
while True:
if ind > n - 1:
break
else:
if c % 2 != 0:
lst1.append(1)
else:
lst1.append(lst[ind])
ind += 1
c += 1
print(*lst1) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE NUMBER IF VAR BIN_OP VAR NUMBER IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR VAR VAR VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR IF BIN_OP NUMBER VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE NUMBER IF VAR BIN_OP VAR NUMBER IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR VAR VAR VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR |
You are given an array $[a_1, a_2, \dots, a_n]$ such that $1 \le a_i \le 10^9$. Let $S$ be the sum of all elements of the array $a$.
Let's call an array $b$ of $n$ integers beautiful if:
$1 \le b_i \le 10^9$ for each $i$ from $1$ to $n$;
for every pair of adjacent integers from the array $(b_i, b_{i + 1})$, either $b_i$ divides $b_{i + 1}$, or $b_{i + 1}$ divides $b_i$ (or both);
$2 \sum \limits_{i = 1}^{n} |a_i - b_i| \le S$.
Your task is to find any beautiful array. It can be shown that at least one beautiful array always exists.
-----Input-----
The first line contains one integer $t$ ($1 \le t \le 1000$) β the number of test cases.
Each test case consists of two lines. The first line contains one integer $n$ ($2 \le n \le 50$).
The second line contains $n$ integers $a_1, a_2, \dots, a_n$ ($1 \le a_i \le 10^9$).
-----Output-----
For each test case, print the beautiful array $b_1, b_2, \dots, b_n$ ($1 \le b_i \le 10^9$) on a separate line. It can be shown that at least one beautiful array exists under these circumstances. If there are multiple answers, print any of them.
-----Examples-----
Input
4
5
1 2 3 4 5
2
4 6
2
1 1000000000
6
3 4 8 1 2 3
Output
3 3 3 3 3
3 6
1 1000000000
4 4 8 1 3 3
-----Note-----
None | for _ in range(int(input())):
n = int(input())
a = [*map(int, input().split())]
b = [1] * n
c = [1] * n
s = sum(a)
for i in range(n):
if i % 2:
b[i] = a[i]
else:
c[i] = a[i]
if 2 * sum(abs(a[i] - b[i]) for i in range(n)) <= s:
print(*b)
else:
print(*c) | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER ASSIGN VAR VAR VAR VAR ASSIGN VAR VAR VAR VAR IF BIN_OP NUMBER FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR |
You are given an array $[a_1, a_2, \dots, a_n]$ such that $1 \le a_i \le 10^9$. Let $S$ be the sum of all elements of the array $a$.
Let's call an array $b$ of $n$ integers beautiful if:
$1 \le b_i \le 10^9$ for each $i$ from $1$ to $n$;
for every pair of adjacent integers from the array $(b_i, b_{i + 1})$, either $b_i$ divides $b_{i + 1}$, or $b_{i + 1}$ divides $b_i$ (or both);
$2 \sum \limits_{i = 1}^{n} |a_i - b_i| \le S$.
Your task is to find any beautiful array. It can be shown that at least one beautiful array always exists.
-----Input-----
The first line contains one integer $t$ ($1 \le t \le 1000$) β the number of test cases.
Each test case consists of two lines. The first line contains one integer $n$ ($2 \le n \le 50$).
The second line contains $n$ integers $a_1, a_2, \dots, a_n$ ($1 \le a_i \le 10^9$).
-----Output-----
For each test case, print the beautiful array $b_1, b_2, \dots, b_n$ ($1 \le b_i \le 10^9$) on a separate line. It can be shown that at least one beautiful array exists under these circumstances. If there are multiple answers, print any of them.
-----Examples-----
Input
4
5
1 2 3 4 5
2
4 6
2
1 1000000000
6
3 4 8 1 2 3
Output
3 3 3 3 3
3 6
1 1000000000
4 4 8 1 3 3
-----Note-----
None | t = int(input())
for _ in range(t):
n = int(input())
ary = [int(i) for i in input().split()]
for num in ary:
a = 1
while a * 2 <= num:
a *= 2
print(a, end=" ")
print("") | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR VAR ASSIGN VAR NUMBER WHILE BIN_OP VAR NUMBER VAR VAR NUMBER EXPR FUNC_CALL VAR VAR STRING EXPR FUNC_CALL VAR STRING |
You are given an array $[a_1, a_2, \dots, a_n]$ such that $1 \le a_i \le 10^9$. Let $S$ be the sum of all elements of the array $a$.
Let's call an array $b$ of $n$ integers beautiful if:
$1 \le b_i \le 10^9$ for each $i$ from $1$ to $n$;
for every pair of adjacent integers from the array $(b_i, b_{i + 1})$, either $b_i$ divides $b_{i + 1}$, or $b_{i + 1}$ divides $b_i$ (or both);
$2 \sum \limits_{i = 1}^{n} |a_i - b_i| \le S$.
Your task is to find any beautiful array. It can be shown that at least one beautiful array always exists.
-----Input-----
The first line contains one integer $t$ ($1 \le t \le 1000$) β the number of test cases.
Each test case consists of two lines. The first line contains one integer $n$ ($2 \le n \le 50$).
The second line contains $n$ integers $a_1, a_2, \dots, a_n$ ($1 \le a_i \le 10^9$).
-----Output-----
For each test case, print the beautiful array $b_1, b_2, \dots, b_n$ ($1 \le b_i \le 10^9$) on a separate line. It can be shown that at least one beautiful array exists under these circumstances. If there are multiple answers, print any of them.
-----Examples-----
Input
4
5
1 2 3 4 5
2
4 6
2
1 1000000000
6
3 4 8 1 2 3
Output
3 3 3 3 3
3 6
1 1000000000
4 4 8 1 3 3
-----Note-----
None | t = int(input())
for _ in range(t):
n = int(input())
array = [int(x) for x in input().split()]
s = sum(array)
cur = [0, 0]
for i in range(n):
cur[i % 2] += array[i] - 1
for j in range(2):
if 2 * cur[j] > s:
continue
for i in range(n):
if i % 2 == j:
array[i] = 1
break
for i in range(n):
print(array[i], end=" ")
print() | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR VAR BIN_OP VAR NUMBER BIN_OP VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER IF BIN_OP NUMBER VAR VAR VAR FOR VAR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER VAR ASSIGN VAR VAR NUMBER FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR STRING EXPR FUNC_CALL VAR |
You are given an array $[a_1, a_2, \dots, a_n]$ such that $1 \le a_i \le 10^9$. Let $S$ be the sum of all elements of the array $a$.
Let's call an array $b$ of $n$ integers beautiful if:
$1 \le b_i \le 10^9$ for each $i$ from $1$ to $n$;
for every pair of adjacent integers from the array $(b_i, b_{i + 1})$, either $b_i$ divides $b_{i + 1}$, or $b_{i + 1}$ divides $b_i$ (or both);
$2 \sum \limits_{i = 1}^{n} |a_i - b_i| \le S$.
Your task is to find any beautiful array. It can be shown that at least one beautiful array always exists.
-----Input-----
The first line contains one integer $t$ ($1 \le t \le 1000$) β the number of test cases.
Each test case consists of two lines. The first line contains one integer $n$ ($2 \le n \le 50$).
The second line contains $n$ integers $a_1, a_2, \dots, a_n$ ($1 \le a_i \le 10^9$).
-----Output-----
For each test case, print the beautiful array $b_1, b_2, \dots, b_n$ ($1 \le b_i \le 10^9$) on a separate line. It can be shown that at least one beautiful array exists under these circumstances. If there are multiple answers, print any of them.
-----Examples-----
Input
4
5
1 2 3 4 5
2
4 6
2
1 1000000000
6
3 4 8 1 2 3
Output
3 3 3 3 3
3 6
1 1000000000
4 4 8 1 3 3
-----Note-----
None | def find(b, a):
s = 0
s1 = sum(b)
for i in range(len(b)):
s += abs(a[i] - b[i])
if 2 * s <= s1:
return True
return False
for i in range(int(input())):
n = int(input())
a = [int(x) for x in input().split()]
b = [1] * n
p = [1] * n
for j in range(0, n, 2):
b[j] = a[j]
for j in range(1, n, 2):
p[j] = a[j]
if find(a, b):
print(*b)
else:
print(*p) | FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR IF BIN_OP NUMBER VAR VAR RETURN NUMBER RETURN NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR NUMBER VAR NUMBER ASSIGN VAR VAR VAR VAR FOR VAR FUNC_CALL VAR NUMBER VAR NUMBER ASSIGN VAR VAR VAR VAR IF FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR |
You are given an array $[a_1, a_2, \dots, a_n]$ such that $1 \le a_i \le 10^9$. Let $S$ be the sum of all elements of the array $a$.
Let's call an array $b$ of $n$ integers beautiful if:
$1 \le b_i \le 10^9$ for each $i$ from $1$ to $n$;
for every pair of adjacent integers from the array $(b_i, b_{i + 1})$, either $b_i$ divides $b_{i + 1}$, or $b_{i + 1}$ divides $b_i$ (or both);
$2 \sum \limits_{i = 1}^{n} |a_i - b_i| \le S$.
Your task is to find any beautiful array. It can be shown that at least one beautiful array always exists.
-----Input-----
The first line contains one integer $t$ ($1 \le t \le 1000$) β the number of test cases.
Each test case consists of two lines. The first line contains one integer $n$ ($2 \le n \le 50$).
The second line contains $n$ integers $a_1, a_2, \dots, a_n$ ($1 \le a_i \le 10^9$).
-----Output-----
For each test case, print the beautiful array $b_1, b_2, \dots, b_n$ ($1 \le b_i \le 10^9$) on a separate line. It can be shown that at least one beautiful array exists under these circumstances. If there are multiple answers, print any of them.
-----Examples-----
Input
4
5
1 2 3 4 5
2
4 6
2
1 1000000000
6
3 4 8 1 2 3
Output
3 3 3 3 3
3 6
1 1000000000
4 4 8 1 3 3
-----Note-----
None | for _ in range(int(input())):
n = int(input())
a = list(map(int, input().split()))
s_odd = 0
s_even = 0
s = sum(a)
for i in range(n):
if i % 2 == 0:
s_odd += a[i]
else:
s_even += a[i]
if s_odd <= s // 2:
for i in range(n):
if i % 2 == 0:
a[i] = 1
else:
for i in range(n):
if i % 2 != 0:
a[i] = 1
print(*a) | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER NUMBER VAR VAR VAR VAR VAR VAR IF VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR VAR NUMBER EXPR FUNC_CALL VAR VAR |
You are given an array $[a_1, a_2, \dots, a_n]$ such that $1 \le a_i \le 10^9$. Let $S$ be the sum of all elements of the array $a$.
Let's call an array $b$ of $n$ integers beautiful if:
$1 \le b_i \le 10^9$ for each $i$ from $1$ to $n$;
for every pair of adjacent integers from the array $(b_i, b_{i + 1})$, either $b_i$ divides $b_{i + 1}$, or $b_{i + 1}$ divides $b_i$ (or both);
$2 \sum \limits_{i = 1}^{n} |a_i - b_i| \le S$.
Your task is to find any beautiful array. It can be shown that at least one beautiful array always exists.
-----Input-----
The first line contains one integer $t$ ($1 \le t \le 1000$) β the number of test cases.
Each test case consists of two lines. The first line contains one integer $n$ ($2 \le n \le 50$).
The second line contains $n$ integers $a_1, a_2, \dots, a_n$ ($1 \le a_i \le 10^9$).
-----Output-----
For each test case, print the beautiful array $b_1, b_2, \dots, b_n$ ($1 \le b_i \le 10^9$) on a separate line. It can be shown that at least one beautiful array exists under these circumstances. If there are multiple answers, print any of them.
-----Examples-----
Input
4
5
1 2 3 4 5
2
4 6
2
1 1000000000
6
3 4 8 1 2 3
Output
3 3 3 3 3
3 6
1 1000000000
4 4 8 1 3 3
-----Note-----
None | def func(n, arr):
s = sum(arr)
odds = [(1 if i & 1 else arr[i]) for i in range(n)]
if sum(map(lambda i: abs(odds[i] - arr[i]), range(n))) << 1 <= s:
return odds
return [(1 if i & 1 == 0 else arr[i]) for i in range(n)]
for _ in range(int(input())):
print(*func(int(input()), list(map(int, input().split())))) | FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR NUMBER NUMBER VAR VAR VAR FUNC_CALL VAR VAR IF BIN_OP FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR FUNC_CALL VAR VAR NUMBER VAR RETURN VAR RETURN BIN_OP VAR NUMBER NUMBER NUMBER VAR VAR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR |
You are given an array $[a_1, a_2, \dots, a_n]$ such that $1 \le a_i \le 10^9$. Let $S$ be the sum of all elements of the array $a$.
Let's call an array $b$ of $n$ integers beautiful if:
$1 \le b_i \le 10^9$ for each $i$ from $1$ to $n$;
for every pair of adjacent integers from the array $(b_i, b_{i + 1})$, either $b_i$ divides $b_{i + 1}$, or $b_{i + 1}$ divides $b_i$ (or both);
$2 \sum \limits_{i = 1}^{n} |a_i - b_i| \le S$.
Your task is to find any beautiful array. It can be shown that at least one beautiful array always exists.
-----Input-----
The first line contains one integer $t$ ($1 \le t \le 1000$) β the number of test cases.
Each test case consists of two lines. The first line contains one integer $n$ ($2 \le n \le 50$).
The second line contains $n$ integers $a_1, a_2, \dots, a_n$ ($1 \le a_i \le 10^9$).
-----Output-----
For each test case, print the beautiful array $b_1, b_2, \dots, b_n$ ($1 \le b_i \le 10^9$) on a separate line. It can be shown that at least one beautiful array exists under these circumstances. If there are multiple answers, print any of them.
-----Examples-----
Input
4
5
1 2 3 4 5
2
4 6
2
1 1000000000
6
3 4 8 1 2 3
Output
3 3 3 3 3
3 6
1 1000000000
4 4 8 1 3 3
-----Note-----
None | for _ in range(int(input())):
n = int(input())
l = list(map(int, input().split()))
ans = []
for i in range(n):
x = 1
while x * 2 <= l[i]:
x = x * 2
ans.append(x)
print(*ans) | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER WHILE BIN_OP VAR NUMBER VAR VAR ASSIGN VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR |
You are given an array $[a_1, a_2, \dots, a_n]$ such that $1 \le a_i \le 10^9$. Let $S$ be the sum of all elements of the array $a$.
Let's call an array $b$ of $n$ integers beautiful if:
$1 \le b_i \le 10^9$ for each $i$ from $1$ to $n$;
for every pair of adjacent integers from the array $(b_i, b_{i + 1})$, either $b_i$ divides $b_{i + 1}$, or $b_{i + 1}$ divides $b_i$ (or both);
$2 \sum \limits_{i = 1}^{n} |a_i - b_i| \le S$.
Your task is to find any beautiful array. It can be shown that at least one beautiful array always exists.
-----Input-----
The first line contains one integer $t$ ($1 \le t \le 1000$) β the number of test cases.
Each test case consists of two lines. The first line contains one integer $n$ ($2 \le n \le 50$).
The second line contains $n$ integers $a_1, a_2, \dots, a_n$ ($1 \le a_i \le 10^9$).
-----Output-----
For each test case, print the beautiful array $b_1, b_2, \dots, b_n$ ($1 \le b_i \le 10^9$) on a separate line. It can be shown that at least one beautiful array exists under these circumstances. If there are multiple answers, print any of them.
-----Examples-----
Input
4
5
1 2 3 4 5
2
4 6
2
1 1000000000
6
3 4 8 1 2 3
Output
3 3 3 3 3
3 6
1 1000000000
4 4 8 1 3 3
-----Note-----
None | for _ in range(int(input())):
n = int(input())
l = list(map(int, input().split()))
s = sum(l)
s1 = 0
s2 = 0
for i in range(n):
if i % 2 == 0:
s1 += l[i]
else:
s2 += l[i]
if 2 * s2 <= s:
for i in range(n):
if i % 2 == 0:
print(l[i], end=" ")
else:
print(1, end=" ")
else:
for i in range(n):
if i % 2 == 0:
print(1, end=" ")
else:
print(l[i], end=" ")
print() | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER NUMBER VAR VAR VAR VAR VAR VAR IF BIN_OP NUMBER VAR VAR FOR VAR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR VAR VAR STRING EXPR FUNC_CALL VAR NUMBER STRING FOR VAR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR NUMBER STRING EXPR FUNC_CALL VAR VAR VAR STRING EXPR FUNC_CALL VAR |
You are given an array $[a_1, a_2, \dots, a_n]$ such that $1 \le a_i \le 10^9$. Let $S$ be the sum of all elements of the array $a$.
Let's call an array $b$ of $n$ integers beautiful if:
$1 \le b_i \le 10^9$ for each $i$ from $1$ to $n$;
for every pair of adjacent integers from the array $(b_i, b_{i + 1})$, either $b_i$ divides $b_{i + 1}$, or $b_{i + 1}$ divides $b_i$ (or both);
$2 \sum \limits_{i = 1}^{n} |a_i - b_i| \le S$.
Your task is to find any beautiful array. It can be shown that at least one beautiful array always exists.
-----Input-----
The first line contains one integer $t$ ($1 \le t \le 1000$) β the number of test cases.
Each test case consists of two lines. The first line contains one integer $n$ ($2 \le n \le 50$).
The second line contains $n$ integers $a_1, a_2, \dots, a_n$ ($1 \le a_i \le 10^9$).
-----Output-----
For each test case, print the beautiful array $b_1, b_2, \dots, b_n$ ($1 \le b_i \le 10^9$) on a separate line. It can be shown that at least one beautiful array exists under these circumstances. If there are multiple answers, print any of them.
-----Examples-----
Input
4
5
1 2 3 4 5
2
4 6
2
1 1000000000
6
3 4 8 1 2 3
Output
3 3 3 3 3
3 6
1 1000000000
4 4 8 1 3 3
-----Note-----
None | for _ in range(int(input())):
n = int(input())
a = list(map(int, input().split()))
res = [0, 0]
for i in range(n):
res[i % 2] += a[i] - 1
for i in range(2):
if 2 * res[i] <= sum(a):
for j in range(n):
if j % 2 == i:
a[j] = 1
break
print(*a) | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR VAR BIN_OP VAR NUMBER BIN_OP VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER IF BIN_OP NUMBER VAR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER VAR ASSIGN VAR VAR NUMBER EXPR FUNC_CALL VAR VAR |
You are given an array $[a_1, a_2, \dots, a_n]$ such that $1 \le a_i \le 10^9$. Let $S$ be the sum of all elements of the array $a$.
Let's call an array $b$ of $n$ integers beautiful if:
$1 \le b_i \le 10^9$ for each $i$ from $1$ to $n$;
for every pair of adjacent integers from the array $(b_i, b_{i + 1})$, either $b_i$ divides $b_{i + 1}$, or $b_{i + 1}$ divides $b_i$ (or both);
$2 \sum \limits_{i = 1}^{n} |a_i - b_i| \le S$.
Your task is to find any beautiful array. It can be shown that at least one beautiful array always exists.
-----Input-----
The first line contains one integer $t$ ($1 \le t \le 1000$) β the number of test cases.
Each test case consists of two lines. The first line contains one integer $n$ ($2 \le n \le 50$).
The second line contains $n$ integers $a_1, a_2, \dots, a_n$ ($1 \le a_i \le 10^9$).
-----Output-----
For each test case, print the beautiful array $b_1, b_2, \dots, b_n$ ($1 \le b_i \le 10^9$) on a separate line. It can be shown that at least one beautiful array exists under these circumstances. If there are multiple answers, print any of them.
-----Examples-----
Input
4
5
1 2 3 4 5
2
4 6
2
1 1000000000
6
3 4 8 1 2 3
Output
3 3 3 3 3
3 6
1 1000000000
4 4 8 1 3 3
-----Note-----
None | def arraycreator(lst):
s = sum(lst)
ind = lst.index(max(lst))
blanck1 = [1] * len(lst)
blanck2 = [1] * len(lst)
for i in range(1, len(lst), 2):
blanck1[i] = lst[i]
for i in range(0, len(lst), 2):
blanck2[i] = lst[i]
lst3 = list(map(lambda x, y: abs(x - y), lst, blanck1))
if 2 * sum(lst3) <= s:
print(*blanck1)
return ""
lst4 = list(map(lambda x, y: abs(x - y), lst, blanck2))
if 2 * sum(lst4) <= s:
print(*blanck2)
return ""
for i in set(lst):
lst2 = [i] * len(lst)
lst3 = list(map(lambda x, y: abs(x - y), lst, lst2))
if 2 * sum(lst3) <= s:
print(*lst2)
return ""
t = int(input())
for i in range(t):
a = input()
lst = list(map(int, input().strip().split()))
print(arraycreator(lst)) | FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR VAR VAR FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR IF BIN_OP NUMBER FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR RETURN STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR IF BIN_OP NUMBER FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR RETURN STRING FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR IF BIN_OP NUMBER FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR RETURN STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR |
You are given an array $[a_1, a_2, \dots, a_n]$ such that $1 \le a_i \le 10^9$. Let $S$ be the sum of all elements of the array $a$.
Let's call an array $b$ of $n$ integers beautiful if:
$1 \le b_i \le 10^9$ for each $i$ from $1$ to $n$;
for every pair of adjacent integers from the array $(b_i, b_{i + 1})$, either $b_i$ divides $b_{i + 1}$, or $b_{i + 1}$ divides $b_i$ (or both);
$2 \sum \limits_{i = 1}^{n} |a_i - b_i| \le S$.
Your task is to find any beautiful array. It can be shown that at least one beautiful array always exists.
-----Input-----
The first line contains one integer $t$ ($1 \le t \le 1000$) β the number of test cases.
Each test case consists of two lines. The first line contains one integer $n$ ($2 \le n \le 50$).
The second line contains $n$ integers $a_1, a_2, \dots, a_n$ ($1 \le a_i \le 10^9$).
-----Output-----
For each test case, print the beautiful array $b_1, b_2, \dots, b_n$ ($1 \le b_i \le 10^9$) on a separate line. It can be shown that at least one beautiful array exists under these circumstances. If there are multiple answers, print any of them.
-----Examples-----
Input
4
5
1 2 3 4 5
2
4 6
2
1 1000000000
6
3 4 8 1 2 3
Output
3 3 3 3 3
3 6
1 1000000000
4 4 8 1 3 3
-----Note-----
None | def solve():
n = int(input())
a = list(map(int, input().split()))
sum_a = 0
for i in a:
sum_a += i
first_arr = [0] * n
second_arr = [0] * n
for i in range(n):
if i % 2 == 0:
first_arr[i] = a[i]
second_arr[i] = 1
else:
first_arr[i] = 1
second_arr[i] = a[i]
dif1, dif2 = 0, 0
for i in range(n):
dif1 += abs(a[i] - first_arr[i])
dif2 += abs(a[i] - second_arr[i])
if 2 * dif1 <= sum_a:
print(*first_arr, sep=" ")
else:
print(*second_arr, sep=" ")
t = int(input())
for q in range(t):
solve() | FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR VAR VAR VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR VAR VAR VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR VAR VAR VAR ASSIGN VAR VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR VAR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR IF BIN_OP NUMBER VAR VAR EXPR FUNC_CALL VAR VAR STRING EXPR FUNC_CALL VAR VAR STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR |
You are given an array $[a_1, a_2, \dots, a_n]$ such that $1 \le a_i \le 10^9$. Let $S$ be the sum of all elements of the array $a$.
Let's call an array $b$ of $n$ integers beautiful if:
$1 \le b_i \le 10^9$ for each $i$ from $1$ to $n$;
for every pair of adjacent integers from the array $(b_i, b_{i + 1})$, either $b_i$ divides $b_{i + 1}$, or $b_{i + 1}$ divides $b_i$ (or both);
$2 \sum \limits_{i = 1}^{n} |a_i - b_i| \le S$.
Your task is to find any beautiful array. It can be shown that at least one beautiful array always exists.
-----Input-----
The first line contains one integer $t$ ($1 \le t \le 1000$) β the number of test cases.
Each test case consists of two lines. The first line contains one integer $n$ ($2 \le n \le 50$).
The second line contains $n$ integers $a_1, a_2, \dots, a_n$ ($1 \le a_i \le 10^9$).
-----Output-----
For each test case, print the beautiful array $b_1, b_2, \dots, b_n$ ($1 \le b_i \le 10^9$) on a separate line. It can be shown that at least one beautiful array exists under these circumstances. If there are multiple answers, print any of them.
-----Examples-----
Input
4
5
1 2 3 4 5
2
4 6
2
1 1000000000
6
3 4 8 1 2 3
Output
3 3 3 3 3
3 6
1 1000000000
4 4 8 1 3 3
-----Note-----
None | for _ in range(int(input())):
n = int(input())
a = list(map(int, input().split()))
b = [0] * n
e, o = 0, 0
for i in range(0, n, 2):
e += a[i]
for i in range(1, n, 2):
o += a[i]
if o >= e:
for i in range(n):
if i % 2 == 0:
b[i] = 1
else:
b[i] = a[i]
else:
for i in range(n):
if i % 2 == 0:
b[i] = a[i]
else:
b[i] = 1
print(*b) | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR NUMBER VAR VAR VAR FOR VAR FUNC_CALL VAR NUMBER VAR NUMBER VAR VAR VAR IF VAR VAR FOR VAR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR VAR VAR VAR FOR VAR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR VAR VAR VAR ASSIGN VAR VAR NUMBER EXPR FUNC_CALL VAR VAR |
You are given an array $[a_1, a_2, \dots, a_n]$ such that $1 \le a_i \le 10^9$. Let $S$ be the sum of all elements of the array $a$.
Let's call an array $b$ of $n$ integers beautiful if:
$1 \le b_i \le 10^9$ for each $i$ from $1$ to $n$;
for every pair of adjacent integers from the array $(b_i, b_{i + 1})$, either $b_i$ divides $b_{i + 1}$, or $b_{i + 1}$ divides $b_i$ (or both);
$2 \sum \limits_{i = 1}^{n} |a_i - b_i| \le S$.
Your task is to find any beautiful array. It can be shown that at least one beautiful array always exists.
-----Input-----
The first line contains one integer $t$ ($1 \le t \le 1000$) β the number of test cases.
Each test case consists of two lines. The first line contains one integer $n$ ($2 \le n \le 50$).
The second line contains $n$ integers $a_1, a_2, \dots, a_n$ ($1 \le a_i \le 10^9$).
-----Output-----
For each test case, print the beautiful array $b_1, b_2, \dots, b_n$ ($1 \le b_i \le 10^9$) on a separate line. It can be shown that at least one beautiful array exists under these circumstances. If there are multiple answers, print any of them.
-----Examples-----
Input
4
5
1 2 3 4 5
2
4 6
2
1 1000000000
6
3 4 8 1 2 3
Output
3 3 3 3 3
3 6
1 1000000000
4 4 8 1 3 3
-----Note-----
None | t = int(input())
for _ in range(t):
n = input()
A = list(map(int, input().split()))
B = []
for a in A:
if a == 1:
B.append(1)
else:
div = B[-1] if len(B) > 0 else 2
q = a // div
if q != 0:
B.append(q * div)
else:
B.append(1)
print(" ".join(list(map(str, B)))) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL STRING FUNC_CALL VAR FUNC_CALL VAR VAR VAR |
You are given an array $[a_1, a_2, \dots, a_n]$ such that $1 \le a_i \le 10^9$. Let $S$ be the sum of all elements of the array $a$.
Let's call an array $b$ of $n$ integers beautiful if:
$1 \le b_i \le 10^9$ for each $i$ from $1$ to $n$;
for every pair of adjacent integers from the array $(b_i, b_{i + 1})$, either $b_i$ divides $b_{i + 1}$, or $b_{i + 1}$ divides $b_i$ (or both);
$2 \sum \limits_{i = 1}^{n} |a_i - b_i| \le S$.
Your task is to find any beautiful array. It can be shown that at least one beautiful array always exists.
-----Input-----
The first line contains one integer $t$ ($1 \le t \le 1000$) β the number of test cases.
Each test case consists of two lines. The first line contains one integer $n$ ($2 \le n \le 50$).
The second line contains $n$ integers $a_1, a_2, \dots, a_n$ ($1 \le a_i \le 10^9$).
-----Output-----
For each test case, print the beautiful array $b_1, b_2, \dots, b_n$ ($1 \le b_i \le 10^9$) on a separate line. It can be shown that at least one beautiful array exists under these circumstances. If there are multiple answers, print any of them.
-----Examples-----
Input
4
5
1 2 3 4 5
2
4 6
2
1 1000000000
6
3 4 8 1 2 3
Output
3 3 3 3 3
3 6
1 1000000000
4 4 8 1 3 3
-----Note-----
None | from sys import stdin
for _ in range(int(stdin.readline())):
n = int(input())
list1 = list(map(int, stdin.readline().split()))
list2 = [1]
suno1 = list1[0] - 1
for h in range(1, n):
if h % 2 != 0:
list2.append(list1[h])
else:
list2.append(1)
suno1 += abs(list1[h] - 1)
suno2 = 0
list3 = [list1[0]]
for m in range(1, n):
if m % 2 == 0:
list3.append(list1[m])
else:
list3.append(1)
suno2 += abs(list1[m] - 1)
if suno2 <= suno1:
print(*list3)
else:
print(*list2) | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST NUMBER ASSIGN VAR BIN_OP VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR |
You are given an array $[a_1, a_2, \dots, a_n]$ such that $1 \le a_i \le 10^9$. Let $S$ be the sum of all elements of the array $a$.
Let's call an array $b$ of $n$ integers beautiful if:
$1 \le b_i \le 10^9$ for each $i$ from $1$ to $n$;
for every pair of adjacent integers from the array $(b_i, b_{i + 1})$, either $b_i$ divides $b_{i + 1}$, or $b_{i + 1}$ divides $b_i$ (or both);
$2 \sum \limits_{i = 1}^{n} |a_i - b_i| \le S$.
Your task is to find any beautiful array. It can be shown that at least one beautiful array always exists.
-----Input-----
The first line contains one integer $t$ ($1 \le t \le 1000$) β the number of test cases.
Each test case consists of two lines. The first line contains one integer $n$ ($2 \le n \le 50$).
The second line contains $n$ integers $a_1, a_2, \dots, a_n$ ($1 \le a_i \le 10^9$).
-----Output-----
For each test case, print the beautiful array $b_1, b_2, \dots, b_n$ ($1 \le b_i \le 10^9$) on a separate line. It can be shown that at least one beautiful array exists under these circumstances. If there are multiple answers, print any of them.
-----Examples-----
Input
4
5
1 2 3 4 5
2
4 6
2
1 1000000000
6
3 4 8 1 2 3
Output
3 3 3 3 3
3 6
1 1000000000
4 4 8 1 3 3
-----Note-----
None | T = int(input())
r = 1
while r <= T:
n = int(input())
arr = list(map(int, input().split()))
ans = []
for ele in arr:
s = bin(ele)
base = 1 << len(s) - 3
if base > 1 and ele >= base + base // 2:
base *= 2
if base > 10**9:
base = base // 2
ans.append(base)
ans = map(str, ans)
print(" ".join(ans))
r += 1 | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER IF VAR NUMBER VAR BIN_OP VAR BIN_OP VAR NUMBER VAR NUMBER IF VAR BIN_OP NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR FUNC_CALL STRING VAR VAR NUMBER |
You are given an array $[a_1, a_2, \dots, a_n]$ such that $1 \le a_i \le 10^9$. Let $S$ be the sum of all elements of the array $a$.
Let's call an array $b$ of $n$ integers beautiful if:
$1 \le b_i \le 10^9$ for each $i$ from $1$ to $n$;
for every pair of adjacent integers from the array $(b_i, b_{i + 1})$, either $b_i$ divides $b_{i + 1}$, or $b_{i + 1}$ divides $b_i$ (or both);
$2 \sum \limits_{i = 1}^{n} |a_i - b_i| \le S$.
Your task is to find any beautiful array. It can be shown that at least one beautiful array always exists.
-----Input-----
The first line contains one integer $t$ ($1 \le t \le 1000$) β the number of test cases.
Each test case consists of two lines. The first line contains one integer $n$ ($2 \le n \le 50$).
The second line contains $n$ integers $a_1, a_2, \dots, a_n$ ($1 \le a_i \le 10^9$).
-----Output-----
For each test case, print the beautiful array $b_1, b_2, \dots, b_n$ ($1 \le b_i \le 10^9$) on a separate line. It can be shown that at least one beautiful array exists under these circumstances. If there are multiple answers, print any of them.
-----Examples-----
Input
4
5
1 2 3 4 5
2
4 6
2
1 1000000000
6
3 4 8 1 2 3
Output
3 3 3 3 3
3 6
1 1000000000
4 4 8 1 3 3
-----Note-----
None | for _ in range(int(input())):
n = int(input())
a = [int(i) for i in input().split()]
ans1 = a[:]
ans2 = a[:]
dif1 = 0
dif2 = 0
for i in range(n):
if i % 2:
ans1[i] = 1
dif1 += a[i] - 1
else:
ans2[i] = 1
dif2 += a[i] - 1
if 2 * dif1 < sum(a):
print(*ans1)
else:
print(*ans2) | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER ASSIGN VAR VAR NUMBER VAR BIN_OP VAR VAR NUMBER ASSIGN VAR VAR NUMBER VAR BIN_OP VAR VAR NUMBER IF BIN_OP NUMBER VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR |
You are given an array $[a_1, a_2, \dots, a_n]$ such that $1 \le a_i \le 10^9$. Let $S$ be the sum of all elements of the array $a$.
Let's call an array $b$ of $n$ integers beautiful if:
$1 \le b_i \le 10^9$ for each $i$ from $1$ to $n$;
for every pair of adjacent integers from the array $(b_i, b_{i + 1})$, either $b_i$ divides $b_{i + 1}$, or $b_{i + 1}$ divides $b_i$ (or both);
$2 \sum \limits_{i = 1}^{n} |a_i - b_i| \le S$.
Your task is to find any beautiful array. It can be shown that at least one beautiful array always exists.
-----Input-----
The first line contains one integer $t$ ($1 \le t \le 1000$) β the number of test cases.
Each test case consists of two lines. The first line contains one integer $n$ ($2 \le n \le 50$).
The second line contains $n$ integers $a_1, a_2, \dots, a_n$ ($1 \le a_i \le 10^9$).
-----Output-----
For each test case, print the beautiful array $b_1, b_2, \dots, b_n$ ($1 \le b_i \le 10^9$) on a separate line. It can be shown that at least one beautiful array exists under these circumstances. If there are multiple answers, print any of them.
-----Examples-----
Input
4
5
1 2 3 4 5
2
4 6
2
1 1000000000
6
3 4 8 1 2 3
Output
3 3 3 3 3
3 6
1 1000000000
4 4 8 1 3 3
-----Note-----
None | for _ in range(int(input())):
n = int(input())
a = [x for x in map(int, input().split())]
odd = 0
even = 0
for i in range(n):
if i % 2 == 0:
odd += abs(a[i] - 1)
else:
even += abs(a[i] - 1)
if odd > even:
for i in range(n):
if i % 2 == 1:
print(1, end=" ")
else:
print(a[i], end=" ")
else:
for i in range(n):
if i % 2 == 1:
print(a[i], end=" ")
else:
print(1, end=" ")
print() | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER NUMBER VAR FUNC_CALL VAR BIN_OP VAR VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR VAR NUMBER IF VAR VAR FOR VAR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR NUMBER STRING EXPR FUNC_CALL VAR VAR VAR STRING FOR VAR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR VAR VAR STRING EXPR FUNC_CALL VAR NUMBER STRING EXPR FUNC_CALL VAR |
You are given an array $[a_1, a_2, \dots, a_n]$ such that $1 \le a_i \le 10^9$. Let $S$ be the sum of all elements of the array $a$.
Let's call an array $b$ of $n$ integers beautiful if:
$1 \le b_i \le 10^9$ for each $i$ from $1$ to $n$;
for every pair of adjacent integers from the array $(b_i, b_{i + 1})$, either $b_i$ divides $b_{i + 1}$, or $b_{i + 1}$ divides $b_i$ (or both);
$2 \sum \limits_{i = 1}^{n} |a_i - b_i| \le S$.
Your task is to find any beautiful array. It can be shown that at least one beautiful array always exists.
-----Input-----
The first line contains one integer $t$ ($1 \le t \le 1000$) β the number of test cases.
Each test case consists of two lines. The first line contains one integer $n$ ($2 \le n \le 50$).
The second line contains $n$ integers $a_1, a_2, \dots, a_n$ ($1 \le a_i \le 10^9$).
-----Output-----
For each test case, print the beautiful array $b_1, b_2, \dots, b_n$ ($1 \le b_i \le 10^9$) on a separate line. It can be shown that at least one beautiful array exists under these circumstances. If there are multiple answers, print any of them.
-----Examples-----
Input
4
5
1 2 3 4 5
2
4 6
2
1 1000000000
6
3 4 8 1 2 3
Output
3 3 3 3 3
3 6
1 1000000000
4 4 8 1 3 3
-----Note-----
None | def gen_beautiful_arr(arr, parity):
res = []
for c in range(len(arr)):
if c % 2 == parity:
res.append(arr[c])
else:
res.append("1")
return res
def main():
T = int(input())
for c in range(T):
n = int(input())
arr = input().rstrip().split(" ")
s_even = s_odd = 0
for c in range(n):
if c % 2 == 0:
s_odd += int(arr[c]) - 1
else:
s_even += int(arr[c]) - 1
print(" ".join(gen_beautiful_arr(arr, 1 if s_odd < s_even else 0)))
main() | FUNC_DEF ASSIGN VAR LIST FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER VAR EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR STRING RETURN VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER NUMBER VAR BIN_OP FUNC_CALL VAR VAR VAR NUMBER VAR BIN_OP FUNC_CALL VAR VAR VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL STRING FUNC_CALL VAR VAR VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR |
You are given an array $[a_1, a_2, \dots, a_n]$ such that $1 \le a_i \le 10^9$. Let $S$ be the sum of all elements of the array $a$.
Let's call an array $b$ of $n$ integers beautiful if:
$1 \le b_i \le 10^9$ for each $i$ from $1$ to $n$;
for every pair of adjacent integers from the array $(b_i, b_{i + 1})$, either $b_i$ divides $b_{i + 1}$, or $b_{i + 1}$ divides $b_i$ (or both);
$2 \sum \limits_{i = 1}^{n} |a_i - b_i| \le S$.
Your task is to find any beautiful array. It can be shown that at least one beautiful array always exists.
-----Input-----
The first line contains one integer $t$ ($1 \le t \le 1000$) β the number of test cases.
Each test case consists of two lines. The first line contains one integer $n$ ($2 \le n \le 50$).
The second line contains $n$ integers $a_1, a_2, \dots, a_n$ ($1 \le a_i \le 10^9$).
-----Output-----
For each test case, print the beautiful array $b_1, b_2, \dots, b_n$ ($1 \le b_i \le 10^9$) on a separate line. It can be shown that at least one beautiful array exists under these circumstances. If there are multiple answers, print any of them.
-----Examples-----
Input
4
5
1 2 3 4 5
2
4 6
2
1 1000000000
6
3 4 8 1 2 3
Output
3 3 3 3 3
3 6
1 1000000000
4 4 8 1 3 3
-----Note-----
None | t = int(input())
while t:
t -= 1
n = int(input())
a = list(map(int, input().split()))
s1, s2 = 0, 0
for i in range(n):
if i % 2:
s1 += a[i]
else:
s2 += a[i]
if s1 > s2:
for i in range(n):
if i % 2:
print(a[i], end=" ")
else:
print(1, end=" ")
else:
for i in range(n):
if i % 2 == 0:
print(a[i], end=" ")
else:
print(1, end=" ")
print() | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER VAR VAR VAR VAR VAR VAR IF VAR VAR FOR VAR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR VAR STRING EXPR FUNC_CALL VAR NUMBER STRING FOR VAR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR VAR VAR STRING EXPR FUNC_CALL VAR NUMBER STRING EXPR FUNC_CALL VAR |
You are given an array $[a_1, a_2, \dots, a_n]$ such that $1 \le a_i \le 10^9$. Let $S$ be the sum of all elements of the array $a$.
Let's call an array $b$ of $n$ integers beautiful if:
$1 \le b_i \le 10^9$ for each $i$ from $1$ to $n$;
for every pair of adjacent integers from the array $(b_i, b_{i + 1})$, either $b_i$ divides $b_{i + 1}$, or $b_{i + 1}$ divides $b_i$ (or both);
$2 \sum \limits_{i = 1}^{n} |a_i - b_i| \le S$.
Your task is to find any beautiful array. It can be shown that at least one beautiful array always exists.
-----Input-----
The first line contains one integer $t$ ($1 \le t \le 1000$) β the number of test cases.
Each test case consists of two lines. The first line contains one integer $n$ ($2 \le n \le 50$).
The second line contains $n$ integers $a_1, a_2, \dots, a_n$ ($1 \le a_i \le 10^9$).
-----Output-----
For each test case, print the beautiful array $b_1, b_2, \dots, b_n$ ($1 \le b_i \le 10^9$) on a separate line. It can be shown that at least one beautiful array exists under these circumstances. If there are multiple answers, print any of them.
-----Examples-----
Input
4
5
1 2 3 4 5
2
4 6
2
1 1000000000
6
3 4 8 1 2 3
Output
3 3 3 3 3
3 6
1 1000000000
4 4 8 1 3 3
-----Note-----
None | for __ in range(int(input())):
n = int(input())
ar = list(map(int, input().split()))
ans = []
for i in range(n):
num1 = 0
while 2**num1 <= ar[i]:
num1 += 1
if 2**num1 - ar[i] > ar[i] - 2 ** (num1 - 1) or 2**num1 > 10**9:
ans.append(2 ** (num1 - 1))
else:
ans.append(2**num1)
print(*ans) | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER WHILE BIN_OP NUMBER VAR VAR VAR VAR NUMBER IF BIN_OP BIN_OP NUMBER VAR VAR VAR BIN_OP VAR VAR BIN_OP NUMBER BIN_OP VAR NUMBER BIN_OP NUMBER VAR BIN_OP NUMBER NUMBER EXPR FUNC_CALL VAR BIN_OP NUMBER BIN_OP VAR NUMBER EXPR FUNC_CALL VAR BIN_OP NUMBER VAR EXPR FUNC_CALL VAR VAR |
You are given an array $[a_1, a_2, \dots, a_n]$ such that $1 \le a_i \le 10^9$. Let $S$ be the sum of all elements of the array $a$.
Let's call an array $b$ of $n$ integers beautiful if:
$1 \le b_i \le 10^9$ for each $i$ from $1$ to $n$;
for every pair of adjacent integers from the array $(b_i, b_{i + 1})$, either $b_i$ divides $b_{i + 1}$, or $b_{i + 1}$ divides $b_i$ (or both);
$2 \sum \limits_{i = 1}^{n} |a_i - b_i| \le S$.
Your task is to find any beautiful array. It can be shown that at least one beautiful array always exists.
-----Input-----
The first line contains one integer $t$ ($1 \le t \le 1000$) β the number of test cases.
Each test case consists of two lines. The first line contains one integer $n$ ($2 \le n \le 50$).
The second line contains $n$ integers $a_1, a_2, \dots, a_n$ ($1 \le a_i \le 10^9$).
-----Output-----
For each test case, print the beautiful array $b_1, b_2, \dots, b_n$ ($1 \le b_i \le 10^9$) on a separate line. It can be shown that at least one beautiful array exists under these circumstances. If there are multiple answers, print any of them.
-----Examples-----
Input
4
5
1 2 3 4 5
2
4 6
2
1 1000000000
6
3 4 8 1 2 3
Output
3 3 3 3 3
3 6
1 1000000000
4 4 8 1 3 3
-----Note-----
None | T = int(input())
while T > 0:
T -= 1
n = int(input())
a = list(map(int, input("").split()))
Sum = sum(a)
tot = 0
i = 0
while i < n:
tot += 2 * (a[i] - 1)
i += 2
if tot <= Sum:
i = 0
ans = []
while i < n:
if i % 2 == 1:
ans.append(a[i])
else:
ans.append(1)
i += 1
print(*ans)
else:
i = 0
ans = []
while i < n:
if i % 2 == 0:
ans.append(a[i])
else:
ans.append(1)
i += 1
print(*ans) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR VAR BIN_OP NUMBER BIN_OP VAR VAR NUMBER VAR NUMBER IF VAR VAR ASSIGN VAR NUMBER ASSIGN VAR LIST WHILE VAR VAR IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR LIST WHILE VAR VAR IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR |
You are given an array $[a_1, a_2, \dots, a_n]$ such that $1 \le a_i \le 10^9$. Let $S$ be the sum of all elements of the array $a$.
Let's call an array $b$ of $n$ integers beautiful if:
$1 \le b_i \le 10^9$ for each $i$ from $1$ to $n$;
for every pair of adjacent integers from the array $(b_i, b_{i + 1})$, either $b_i$ divides $b_{i + 1}$, or $b_{i + 1}$ divides $b_i$ (or both);
$2 \sum \limits_{i = 1}^{n} |a_i - b_i| \le S$.
Your task is to find any beautiful array. It can be shown that at least one beautiful array always exists.
-----Input-----
The first line contains one integer $t$ ($1 \le t \le 1000$) β the number of test cases.
Each test case consists of two lines. The first line contains one integer $n$ ($2 \le n \le 50$).
The second line contains $n$ integers $a_1, a_2, \dots, a_n$ ($1 \le a_i \le 10^9$).
-----Output-----
For each test case, print the beautiful array $b_1, b_2, \dots, b_n$ ($1 \le b_i \le 10^9$) on a separate line. It can be shown that at least one beautiful array exists under these circumstances. If there are multiple answers, print any of them.
-----Examples-----
Input
4
5
1 2 3 4 5
2
4 6
2
1 1000000000
6
3 4 8 1 2 3
Output
3 3 3 3 3
3 6
1 1000000000
4 4 8 1 3 3
-----Note-----
None | t = int(input())
for q in range(t):
n = int(input())
mass = [int(x) for x in input().split()]
answer = 0
for i in range(n - 1):
if mass[i] % mass[i + 1] != 0 and mass[i + 1] % mass[i] != 0:
mass[i + 1] = max(1, mass[i + 1] - mass[i + 1] % mass[i])
print(*mass) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF BIN_OP VAR VAR VAR BIN_OP VAR NUMBER NUMBER BIN_OP VAR BIN_OP VAR NUMBER VAR VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER FUNC_CALL VAR NUMBER BIN_OP VAR BIN_OP VAR NUMBER BIN_OP VAR BIN_OP VAR NUMBER VAR VAR EXPR FUNC_CALL VAR VAR |
You are given an array $[a_1, a_2, \dots, a_n]$ such that $1 \le a_i \le 10^9$. Let $S$ be the sum of all elements of the array $a$.
Let's call an array $b$ of $n$ integers beautiful if:
$1 \le b_i \le 10^9$ for each $i$ from $1$ to $n$;
for every pair of adjacent integers from the array $(b_i, b_{i + 1})$, either $b_i$ divides $b_{i + 1}$, or $b_{i + 1}$ divides $b_i$ (or both);
$2 \sum \limits_{i = 1}^{n} |a_i - b_i| \le S$.
Your task is to find any beautiful array. It can be shown that at least one beautiful array always exists.
-----Input-----
The first line contains one integer $t$ ($1 \le t \le 1000$) β the number of test cases.
Each test case consists of two lines. The first line contains one integer $n$ ($2 \le n \le 50$).
The second line contains $n$ integers $a_1, a_2, \dots, a_n$ ($1 \le a_i \le 10^9$).
-----Output-----
For each test case, print the beautiful array $b_1, b_2, \dots, b_n$ ($1 \le b_i \le 10^9$) on a separate line. It can be shown that at least one beautiful array exists under these circumstances. If there are multiple answers, print any of them.
-----Examples-----
Input
4
5
1 2 3 4 5
2
4 6
2
1 1000000000
6
3 4 8 1 2 3
Output
3 3 3 3 3
3 6
1 1000000000
4 4 8 1 3 3
-----Note-----
None | t = int(input())
for i in range(t):
n = int(input())
a = [int(j) for j in input().split()]
if_a_good = True
for j in range(n - 1):
if a[j] % a[j + 1] != 0 and a[j + 1] % a[j] != 0:
if_a_good = False
break
if if_a_good == True:
print(" ".join([str(j) for j in a]))
else:
b1 = a.copy()
b2 = a.copy()
diff1 = 0
diff2 = 0
for j in range(n):
if j % 2 == 1:
b1[j] = 1
diff1 += abs(a[j] - b1[j])
else:
b2[j] = 1
diff2 += abs(a[j] - b2[j])
if diff1 <= sum(a) // 2:
print(" ".join([str(j) for j in b1]))
else:
print(" ".join([str(j) for j in b2])) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF BIN_OP VAR VAR VAR BIN_OP VAR NUMBER NUMBER BIN_OP VAR BIN_OP VAR NUMBER VAR VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL STRING FUNC_CALL VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR ASSIGN VAR VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR IF VAR BIN_OP FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL STRING FUNC_CALL VAR VAR VAR VAR EXPR FUNC_CALL VAR FUNC_CALL STRING FUNC_CALL VAR VAR VAR VAR |
You are given an array $[a_1, a_2, \dots, a_n]$ such that $1 \le a_i \le 10^9$. Let $S$ be the sum of all elements of the array $a$.
Let's call an array $b$ of $n$ integers beautiful if:
$1 \le b_i \le 10^9$ for each $i$ from $1$ to $n$;
for every pair of adjacent integers from the array $(b_i, b_{i + 1})$, either $b_i$ divides $b_{i + 1}$, or $b_{i + 1}$ divides $b_i$ (or both);
$2 \sum \limits_{i = 1}^{n} |a_i - b_i| \le S$.
Your task is to find any beautiful array. It can be shown that at least one beautiful array always exists.
-----Input-----
The first line contains one integer $t$ ($1 \le t \le 1000$) β the number of test cases.
Each test case consists of two lines. The first line contains one integer $n$ ($2 \le n \le 50$).
The second line contains $n$ integers $a_1, a_2, \dots, a_n$ ($1 \le a_i \le 10^9$).
-----Output-----
For each test case, print the beautiful array $b_1, b_2, \dots, b_n$ ($1 \le b_i \le 10^9$) on a separate line. It can be shown that at least one beautiful array exists under these circumstances. If there are multiple answers, print any of them.
-----Examples-----
Input
4
5
1 2 3 4 5
2
4 6
2
1 1000000000
6
3 4 8 1 2 3
Output
3 3 3 3 3
3 6
1 1000000000
4 4 8 1 3 3
-----Note-----
None | for _ in range(int(input())):
n = int(input())
a = list(map(int, input().split()))
s = sum(a) / 2
b1, b2 = [1] * n, [1] * n
for i in range(0, n, 2):
b1[i] = a[i]
for i in range(1, n, 2):
b2[i] = a[i]
check = 0
for i in range(n):
check += abs(a[i] - b1[i])
if check <= s:
print(*b1)
continue
check = 0
for i in range(n):
check += abs(a[i] - b2[i])
if check <= s:
print(*b2)
continue
while True:
a = 2 | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR BIN_OP LIST NUMBER VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR NUMBER VAR NUMBER ASSIGN VAR VAR VAR VAR FOR VAR FUNC_CALL VAR NUMBER VAR NUMBER ASSIGN VAR VAR VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR IF VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR IF VAR VAR EXPR FUNC_CALL VAR VAR WHILE NUMBER ASSIGN VAR NUMBER |
You are given an array $[a_1, a_2, \dots, a_n]$ such that $1 \le a_i \le 10^9$. Let $S$ be the sum of all elements of the array $a$.
Let's call an array $b$ of $n$ integers beautiful if:
$1 \le b_i \le 10^9$ for each $i$ from $1$ to $n$;
for every pair of adjacent integers from the array $(b_i, b_{i + 1})$, either $b_i$ divides $b_{i + 1}$, or $b_{i + 1}$ divides $b_i$ (or both);
$2 \sum \limits_{i = 1}^{n} |a_i - b_i| \le S$.
Your task is to find any beautiful array. It can be shown that at least one beautiful array always exists.
-----Input-----
The first line contains one integer $t$ ($1 \le t \le 1000$) β the number of test cases.
Each test case consists of two lines. The first line contains one integer $n$ ($2 \le n \le 50$).
The second line contains $n$ integers $a_1, a_2, \dots, a_n$ ($1 \le a_i \le 10^9$).
-----Output-----
For each test case, print the beautiful array $b_1, b_2, \dots, b_n$ ($1 \le b_i \le 10^9$) on a separate line. It can be shown that at least one beautiful array exists under these circumstances. If there are multiple answers, print any of them.
-----Examples-----
Input
4
5
1 2 3 4 5
2
4 6
2
1 1000000000
6
3 4 8 1 2 3
Output
3 3 3 3 3
3 6
1 1000000000
4 4 8 1 3 3
-----Note-----
None | for _ in range(int(input())):
n = int(input())
l = list(map(int, input().split()))
l1 = []
count = 0
count2 = 0
for i in range(n):
if i % 2 == 0:
l1.append(1)
count += abs(l[i] - 1)
else:
l1.append(l[i])
l2 = []
for i in range(n):
if i % 2 == 0:
l2.append(l[i])
else:
l2.append(1)
count2 += abs(l[i] - 1)
s = sum(l)
if count <= s // 2:
print(*l1)
else:
print(*l2) | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR IF VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR |
You are given an array $[a_1, a_2, \dots, a_n]$ such that $1 \le a_i \le 10^9$. Let $S$ be the sum of all elements of the array $a$.
Let's call an array $b$ of $n$ integers beautiful if:
$1 \le b_i \le 10^9$ for each $i$ from $1$ to $n$;
for every pair of adjacent integers from the array $(b_i, b_{i + 1})$, either $b_i$ divides $b_{i + 1}$, or $b_{i + 1}$ divides $b_i$ (or both);
$2 \sum \limits_{i = 1}^{n} |a_i - b_i| \le S$.
Your task is to find any beautiful array. It can be shown that at least one beautiful array always exists.
-----Input-----
The first line contains one integer $t$ ($1 \le t \le 1000$) β the number of test cases.
Each test case consists of two lines. The first line contains one integer $n$ ($2 \le n \le 50$).
The second line contains $n$ integers $a_1, a_2, \dots, a_n$ ($1 \le a_i \le 10^9$).
-----Output-----
For each test case, print the beautiful array $b_1, b_2, \dots, b_n$ ($1 \le b_i \le 10^9$) on a separate line. It can be shown that at least one beautiful array exists under these circumstances. If there are multiple answers, print any of them.
-----Examples-----
Input
4
5
1 2 3 4 5
2
4 6
2
1 1000000000
6
3 4 8 1 2 3
Output
3 3 3 3 3
3 6
1 1000000000
4 4 8 1 3 3
-----Note-----
None | innum = lambda: int(input())
inmul = lambda: map(int, input().split())
instr = lambda: str(input())
inarr = lambda: list(map(int, input().split()))
def solve():
n = innum()
a = inarr()
s = sum(a)
seq1 = [(a[i] if i % 2 == 0 else 1) for i in range(n)]
seq2 = [(1 if i % 2 == 0 else a[i]) for i in range(n)]
s1 = sum([abs(a[i] - seq1[i]) for i in range(n)])
s2 = sum([abs(a[i] - seq2[i]) for i in range(n)])
if 2 * s1 <= s:
print(*seq1)
else:
print(*seq2)
def main():
t = 1
t = int(input())
for _ in range(t):
solve()
main() | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR NUMBER NUMBER VAR VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR NUMBER NUMBER NUMBER VAR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR VAR FUNC_CALL VAR VAR IF BIN_OP NUMBER VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR |
You are given an array $[a_1, a_2, \dots, a_n]$ such that $1 \le a_i \le 10^9$. Let $S$ be the sum of all elements of the array $a$.
Let's call an array $b$ of $n$ integers beautiful if:
$1 \le b_i \le 10^9$ for each $i$ from $1$ to $n$;
for every pair of adjacent integers from the array $(b_i, b_{i + 1})$, either $b_i$ divides $b_{i + 1}$, or $b_{i + 1}$ divides $b_i$ (or both);
$2 \sum \limits_{i = 1}^{n} |a_i - b_i| \le S$.
Your task is to find any beautiful array. It can be shown that at least one beautiful array always exists.
-----Input-----
The first line contains one integer $t$ ($1 \le t \le 1000$) β the number of test cases.
Each test case consists of two lines. The first line contains one integer $n$ ($2 \le n \le 50$).
The second line contains $n$ integers $a_1, a_2, \dots, a_n$ ($1 \le a_i \le 10^9$).
-----Output-----
For each test case, print the beautiful array $b_1, b_2, \dots, b_n$ ($1 \le b_i \le 10^9$) on a separate line. It can be shown that at least one beautiful array exists under these circumstances. If there are multiple answers, print any of them.
-----Examples-----
Input
4
5
1 2 3 4 5
2
4 6
2
1 1000000000
6
3 4 8 1 2 3
Output
3 3 3 3 3
3 6
1 1000000000
4 4 8 1 3 3
-----Note-----
None | t = int(input())
while t:
t -= 1
n = int(input())
a = list(map(int, input().split()))
b = a[:]
oddsum = sum(a[::2])
s = sum(a)
if oddsum >= s // 2:
for i in range(1, n, 2):
b[i] = 1
else:
for i in range(0, n, 2):
b[i] = 1
print(*b) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR IF VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR NUMBER ASSIGN VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR NUMBER ASSIGN VAR VAR NUMBER EXPR FUNC_CALL VAR VAR |
You are given an array $[a_1, a_2, \dots, a_n]$ such that $1 \le a_i \le 10^9$. Let $S$ be the sum of all elements of the array $a$.
Let's call an array $b$ of $n$ integers beautiful if:
$1 \le b_i \le 10^9$ for each $i$ from $1$ to $n$;
for every pair of adjacent integers from the array $(b_i, b_{i + 1})$, either $b_i$ divides $b_{i + 1}$, or $b_{i + 1}$ divides $b_i$ (or both);
$2 \sum \limits_{i = 1}^{n} |a_i - b_i| \le S$.
Your task is to find any beautiful array. It can be shown that at least one beautiful array always exists.
-----Input-----
The first line contains one integer $t$ ($1 \le t \le 1000$) β the number of test cases.
Each test case consists of two lines. The first line contains one integer $n$ ($2 \le n \le 50$).
The second line contains $n$ integers $a_1, a_2, \dots, a_n$ ($1 \le a_i \le 10^9$).
-----Output-----
For each test case, print the beautiful array $b_1, b_2, \dots, b_n$ ($1 \le b_i \le 10^9$) on a separate line. It can be shown that at least one beautiful array exists under these circumstances. If there are multiple answers, print any of them.
-----Examples-----
Input
4
5
1 2 3 4 5
2
4 6
2
1 1000000000
6
3 4 8 1 2 3
Output
3 3 3 3 3
3 6
1 1000000000
4 4 8 1 3 3
-----Note-----
None | def check(n, a, b, s):
z = 0
for i in range(n):
z += abs(a[i] - b[i])
return 2 * z <= s
t = int(input())
for i in range(t):
n = int(input())
a = [int(x) for x in input().split()]
s = sum(a)
b = a[:]
b[::2] = [1] * len(b[::2])
if check(n, a, b, s):
print(*b)
else:
b = a[:]
b[1::2] = [1] * len(b[1::2])
if check(n, a, b, s):
print(*b)
else:
raise Exception("invalid assumption") | FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR RETURN BIN_OP NUMBER VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR ASSIGN VAR NUMBER BIN_OP LIST NUMBER FUNC_CALL VAR VAR NUMBER IF FUNC_CALL VAR VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR VAR ASSIGN VAR NUMBER NUMBER BIN_OP LIST NUMBER FUNC_CALL VAR VAR NUMBER NUMBER IF FUNC_CALL VAR VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR FUNC_CALL VAR STRING |
You are given an array $[a_1, a_2, \dots, a_n]$ such that $1 \le a_i \le 10^9$. Let $S$ be the sum of all elements of the array $a$.
Let's call an array $b$ of $n$ integers beautiful if:
$1 \le b_i \le 10^9$ for each $i$ from $1$ to $n$;
for every pair of adjacent integers from the array $(b_i, b_{i + 1})$, either $b_i$ divides $b_{i + 1}$, or $b_{i + 1}$ divides $b_i$ (or both);
$2 \sum \limits_{i = 1}^{n} |a_i - b_i| \le S$.
Your task is to find any beautiful array. It can be shown that at least one beautiful array always exists.
-----Input-----
The first line contains one integer $t$ ($1 \le t \le 1000$) β the number of test cases.
Each test case consists of two lines. The first line contains one integer $n$ ($2 \le n \le 50$).
The second line contains $n$ integers $a_1, a_2, \dots, a_n$ ($1 \le a_i \le 10^9$).
-----Output-----
For each test case, print the beautiful array $b_1, b_2, \dots, b_n$ ($1 \le b_i \le 10^9$) on a separate line. It can be shown that at least one beautiful array exists under these circumstances. If there are multiple answers, print any of them.
-----Examples-----
Input
4
5
1 2 3 4 5
2
4 6
2
1 1000000000
6
3 4 8 1 2 3
Output
3 3 3 3 3
3 6
1 1000000000
4 4 8 1 3 3
-----Note-----
None | def read_int():
return int(input())
def read_ints():
return map(int, input().split(" "))
t = read_int()
for case_num in range(t):
n = read_int()
a = list(read_ints())
s = sum(a)
odd = [(a[i] if i % 2 == 1 else 1) for i in range(n)]
if sum(abs(odd[i] - a[i]) for i in range(n)) * 2 <= s:
print(" ".join(map(str, odd)))
continue
even = [(a[i] if i % 2 == 0 else 1) for i in range(n)]
print(" ".join(map(str, even))) | FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR NUMBER NUMBER VAR VAR NUMBER VAR FUNC_CALL VAR VAR IF BIN_OP FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR VAR FUNC_CALL VAR VAR NUMBER VAR EXPR FUNC_CALL VAR FUNC_CALL STRING FUNC_CALL VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER NUMBER VAR VAR NUMBER VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL STRING FUNC_CALL VAR VAR VAR |
You are given an array $[a_1, a_2, \dots, a_n]$ such that $1 \le a_i \le 10^9$. Let $S$ be the sum of all elements of the array $a$.
Let's call an array $b$ of $n$ integers beautiful if:
$1 \le b_i \le 10^9$ for each $i$ from $1$ to $n$;
for every pair of adjacent integers from the array $(b_i, b_{i + 1})$, either $b_i$ divides $b_{i + 1}$, or $b_{i + 1}$ divides $b_i$ (or both);
$2 \sum \limits_{i = 1}^{n} |a_i - b_i| \le S$.
Your task is to find any beautiful array. It can be shown that at least one beautiful array always exists.
-----Input-----
The first line contains one integer $t$ ($1 \le t \le 1000$) β the number of test cases.
Each test case consists of two lines. The first line contains one integer $n$ ($2 \le n \le 50$).
The second line contains $n$ integers $a_1, a_2, \dots, a_n$ ($1 \le a_i \le 10^9$).
-----Output-----
For each test case, print the beautiful array $b_1, b_2, \dots, b_n$ ($1 \le b_i \le 10^9$) on a separate line. It can be shown that at least one beautiful array exists under these circumstances. If there are multiple answers, print any of them.
-----Examples-----
Input
4
5
1 2 3 4 5
2
4 6
2
1 1000000000
6
3 4 8 1 2 3
Output
3 3 3 3 3
3 6
1 1000000000
4 4 8 1 3 3
-----Note-----
None | tests = int(input())
for t in range(tests):
n = int(input())
ls = list(map(int, input().split()))
ls_others = [(2**i) for i in range(0, 30)]
ans = []
for item in ls:
for sel_idx in range(len(ls_others)):
if sel_idx < len(ls_others) - 1:
if abs(item - ls_others[sel_idx]) <= abs(item - ls_others[sel_idx + 1]):
ans.append(ls_others[sel_idx])
break
else:
ans.append(ls_others[sel_idx])
print(" ".join([str(item) for item in ans])) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP NUMBER VAR VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR LIST FOR VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF FUNC_CALL VAR BIN_OP VAR VAR VAR FUNC_CALL VAR BIN_OP VAR VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR FUNC_CALL STRING FUNC_CALL VAR VAR VAR VAR |
You are given an array $[a_1, a_2, \dots, a_n]$ such that $1 \le a_i \le 10^9$. Let $S$ be the sum of all elements of the array $a$.
Let's call an array $b$ of $n$ integers beautiful if:
$1 \le b_i \le 10^9$ for each $i$ from $1$ to $n$;
for every pair of adjacent integers from the array $(b_i, b_{i + 1})$, either $b_i$ divides $b_{i + 1}$, or $b_{i + 1}$ divides $b_i$ (or both);
$2 \sum \limits_{i = 1}^{n} |a_i - b_i| \le S$.
Your task is to find any beautiful array. It can be shown that at least one beautiful array always exists.
-----Input-----
The first line contains one integer $t$ ($1 \le t \le 1000$) β the number of test cases.
Each test case consists of two lines. The first line contains one integer $n$ ($2 \le n \le 50$).
The second line contains $n$ integers $a_1, a_2, \dots, a_n$ ($1 \le a_i \le 10^9$).
-----Output-----
For each test case, print the beautiful array $b_1, b_2, \dots, b_n$ ($1 \le b_i \le 10^9$) on a separate line. It can be shown that at least one beautiful array exists under these circumstances. If there are multiple answers, print any of them.
-----Examples-----
Input
4
5
1 2 3 4 5
2
4 6
2
1 1000000000
6
3 4 8 1 2 3
Output
3 3 3 3 3
3 6
1 1000000000
4 4 8 1 3 3
-----Note-----
None | for tt in range(int(input())):
n = int(input())
a = list(map(int, input().split()))
ans = []
for x in a:
mn = float("inf")
best = 0
for i in range(0, 30):
if abs(2**i - x) < mn:
mn = abs(2**i - x)
best = 2**i
ans.append(best)
print(*ans) | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER IF FUNC_CALL VAR BIN_OP BIN_OP NUMBER VAR VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP NUMBER VAR VAR ASSIGN VAR BIN_OP NUMBER VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR |
You are given an array $[a_1, a_2, \dots, a_n]$ such that $1 \le a_i \le 10^9$. Let $S$ be the sum of all elements of the array $a$.
Let's call an array $b$ of $n$ integers beautiful if:
$1 \le b_i \le 10^9$ for each $i$ from $1$ to $n$;
for every pair of adjacent integers from the array $(b_i, b_{i + 1})$, either $b_i$ divides $b_{i + 1}$, or $b_{i + 1}$ divides $b_i$ (or both);
$2 \sum \limits_{i = 1}^{n} |a_i - b_i| \le S$.
Your task is to find any beautiful array. It can be shown that at least one beautiful array always exists.
-----Input-----
The first line contains one integer $t$ ($1 \le t \le 1000$) β the number of test cases.
Each test case consists of two lines. The first line contains one integer $n$ ($2 \le n \le 50$).
The second line contains $n$ integers $a_1, a_2, \dots, a_n$ ($1 \le a_i \le 10^9$).
-----Output-----
For each test case, print the beautiful array $b_1, b_2, \dots, b_n$ ($1 \le b_i \le 10^9$) on a separate line. It can be shown that at least one beautiful array exists under these circumstances. If there are multiple answers, print any of them.
-----Examples-----
Input
4
5
1 2 3 4 5
2
4 6
2
1 1000000000
6
3 4 8 1 2 3
Output
3 3 3 3 3
3 6
1 1000000000
4 4 8 1 3 3
-----Note-----
None | for t in range(int(input())):
n = int(input())
a = list(map(int, input().split()))
b = []
for i in range(n):
if i % 2:
b.append(a[i])
else:
b.append(1)
if sum([abs(a[i] - b[i]) for i in range(n)]) * 2 <= sum(a):
print(" ".join([str(i) for i in b]))
else:
b = []
for i in range(n):
if not i % 2:
b.append(a[i])
else:
b.append(1)
print(" ".join([str(i) for i in b])) | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR NUMBER IF BIN_OP FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR VAR FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL STRING FUNC_CALL VAR VAR VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL STRING FUNC_CALL VAR VAR VAR VAR |
You are given an array $[a_1, a_2, \dots, a_n]$ such that $1 \le a_i \le 10^9$. Let $S$ be the sum of all elements of the array $a$.
Let's call an array $b$ of $n$ integers beautiful if:
$1 \le b_i \le 10^9$ for each $i$ from $1$ to $n$;
for every pair of adjacent integers from the array $(b_i, b_{i + 1})$, either $b_i$ divides $b_{i + 1}$, or $b_{i + 1}$ divides $b_i$ (or both);
$2 \sum \limits_{i = 1}^{n} |a_i - b_i| \le S$.
Your task is to find any beautiful array. It can be shown that at least one beautiful array always exists.
-----Input-----
The first line contains one integer $t$ ($1 \le t \le 1000$) β the number of test cases.
Each test case consists of two lines. The first line contains one integer $n$ ($2 \le n \le 50$).
The second line contains $n$ integers $a_1, a_2, \dots, a_n$ ($1 \le a_i \le 10^9$).
-----Output-----
For each test case, print the beautiful array $b_1, b_2, \dots, b_n$ ($1 \le b_i \le 10^9$) on a separate line. It can be shown that at least one beautiful array exists under these circumstances. If there are multiple answers, print any of them.
-----Examples-----
Input
4
5
1 2 3 4 5
2
4 6
2
1 1000000000
6
3 4 8 1 2 3
Output
3 3 3 3 3
3 6
1 1000000000
4 4 8 1 3 3
-----Note-----
None | for _ in range(int(input())):
n = int(input())
A = [int(a) for a in input().split()]
odd = []
even = []
s_odd = 0
s_even = 0
for i in range(n):
if i % 2 == 0:
odd.append(A[i])
s_odd += A[i]
even.append(1)
s_even += 1
else:
even.append(A[i])
s_even += A[i]
odd.append(1)
s_odd += 1
B = []
if s_odd < s_even:
B = even
else:
B = odd
print(*B) | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR VAR VAR VAR VAR VAR EXPR FUNC_CALL VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR VAR VAR VAR VAR EXPR FUNC_CALL VAR NUMBER VAR NUMBER ASSIGN VAR LIST IF VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR EXPR FUNC_CALL VAR VAR |
You are given an array $[a_1, a_2, \dots, a_n]$ such that $1 \le a_i \le 10^9$. Let $S$ be the sum of all elements of the array $a$.
Let's call an array $b$ of $n$ integers beautiful if:
$1 \le b_i \le 10^9$ for each $i$ from $1$ to $n$;
for every pair of adjacent integers from the array $(b_i, b_{i + 1})$, either $b_i$ divides $b_{i + 1}$, or $b_{i + 1}$ divides $b_i$ (or both);
$2 \sum \limits_{i = 1}^{n} |a_i - b_i| \le S$.
Your task is to find any beautiful array. It can be shown that at least one beautiful array always exists.
-----Input-----
The first line contains one integer $t$ ($1 \le t \le 1000$) β the number of test cases.
Each test case consists of two lines. The first line contains one integer $n$ ($2 \le n \le 50$).
The second line contains $n$ integers $a_1, a_2, \dots, a_n$ ($1 \le a_i \le 10^9$).
-----Output-----
For each test case, print the beautiful array $b_1, b_2, \dots, b_n$ ($1 \le b_i \le 10^9$) on a separate line. It can be shown that at least one beautiful array exists under these circumstances. If there are multiple answers, print any of them.
-----Examples-----
Input
4
5
1 2 3 4 5
2
4 6
2
1 1000000000
6
3 4 8 1 2 3
Output
3 3 3 3 3
3 6
1 1000000000
4 4 8 1 3 3
-----Note-----
None | for _ in range(int(input())):
n = int(input())
arr = list(map(int, input().split()))
s = sum(arr)
b = [0] * n
for i in range(n):
b[i] = arr[i] if i % 2 == 0 else 1
su = 0
for i in range(n):
su += abs(arr[i] - b[i])
if 2 * su > s:
for i in range(n):
b[i] = arr[i] if i % 2 == 1 else 1
print(*b) | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR BIN_OP VAR NUMBER NUMBER VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR IF BIN_OP NUMBER VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR BIN_OP VAR NUMBER NUMBER VAR VAR NUMBER EXPR FUNC_CALL VAR VAR |
You are given an array $[a_1, a_2, \dots, a_n]$ such that $1 \le a_i \le 10^9$. Let $S$ be the sum of all elements of the array $a$.
Let's call an array $b$ of $n$ integers beautiful if:
$1 \le b_i \le 10^9$ for each $i$ from $1$ to $n$;
for every pair of adjacent integers from the array $(b_i, b_{i + 1})$, either $b_i$ divides $b_{i + 1}$, or $b_{i + 1}$ divides $b_i$ (or both);
$2 \sum \limits_{i = 1}^{n} |a_i - b_i| \le S$.
Your task is to find any beautiful array. It can be shown that at least one beautiful array always exists.
-----Input-----
The first line contains one integer $t$ ($1 \le t \le 1000$) β the number of test cases.
Each test case consists of two lines. The first line contains one integer $n$ ($2 \le n \le 50$).
The second line contains $n$ integers $a_1, a_2, \dots, a_n$ ($1 \le a_i \le 10^9$).
-----Output-----
For each test case, print the beautiful array $b_1, b_2, \dots, b_n$ ($1 \le b_i \le 10^9$) on a separate line. It can be shown that at least one beautiful array exists under these circumstances. If there are multiple answers, print any of them.
-----Examples-----
Input
4
5
1 2 3 4 5
2
4 6
2
1 1000000000
6
3 4 8 1 2 3
Output
3 3 3 3 3
3 6
1 1000000000
4 4 8 1 3 3
-----Note-----
None | import sys
def main():
def modst(a, s):
ret = 1
while s:
if s % 2:
ret = ret * a % mod
a = a * a % mod
s //= 2
return ret
def Cnk(n, k):
return (k <= n and n >= 0) * (
f[n] * modst(f[k] * f[n - k] % mod, mod - 2) % mod
)
n = int(sys.stdin.readline().strip())
q = list(map(int, sys.stdin.readline().split()))
fl = sum([q[i] for i in range(0, n, 2)]) > sum([q[i] for i in range(1, n, 2)])
print(*[(1 if i % 2 == fl else q[i]) for i in range(n)])
for i in range(int(input())):
main() | IMPORT FUNC_DEF FUNC_DEF ASSIGN VAR NUMBER WHILE VAR IF BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR VAR NUMBER RETURN VAR FUNC_DEF RETURN BIN_OP VAR VAR VAR NUMBER BIN_OP BIN_OP VAR VAR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR VAR BIN_OP VAR VAR VAR BIN_OP VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR FUNC_CALL VAR NUMBER VAR NUMBER FUNC_CALL VAR VAR VAR VAR FUNC_CALL VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER VAR VAR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR EXPR FUNC_CALL VAR |
Read problem statements in [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
You are given an integer $C$. Let $d$ be the smallest integer such that $2^{d}$ is strictly greater than $C$.
Consider all pairs of non-negative integers $(A,B)$ such that $A,B < 2^{d}$ and $A \oplus B = C$ ($\oplus$ denotes the bitwise XOR operation). Find the maximum value of $A \cdot B$ over all these pairs.
------ Input ------
The first line of the input contains a single integer $T$ denoting the number of test cases. The description of $T$ test cases follows.
The first and only line of each test case contains a single integer $C$.
------ Output ------
For each test case, print a single line containing one integer β the maximum possible product $A \cdot B$.
------ Constraints ------
$1 β€ T β€ 10^{5}$
$1 β€ C β€ 10^{9}$
------ Subtasks ------
Subtask #1 (30 points): $1 β€ C β€ 10^{3}$
Subtask #2 (70 points): original constraints
----- Sample Input 1 ------
2
13
10
----- Sample Output 1 ------
70
91
----- explanation 1 ------
Example case 1: The binary representation of $13$ is "1101". We can use $A = 10$ ("1010" in binary) and $B = 7$ ("0111" in binary). This gives us the product $70$. No other valid pair $(A, B)$ can give us a larger product.
Example case 2: The binary representation of $10$ is "1010". We can use $A = 13$ ("1101") and $B = 7$ ("0111"). This gives us the maximum product $91$. | for _ in range(int(input())):
c = int(input())
b = bin(c)[2:]
o = []
for i in range(len(b)):
if i == 0:
o.append("1")
elif b[i] == "1":
o.append("0")
else:
o.append("1")
n1 = int("".join(o), 2)
n2 = c ^ n1
print(n1 * n2) | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR STRING IF VAR VAR STRING EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL STRING VAR NUMBER ASSIGN VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR |
Read problem statements in [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
You are given an integer $C$. Let $d$ be the smallest integer such that $2^{d}$ is strictly greater than $C$.
Consider all pairs of non-negative integers $(A,B)$ such that $A,B < 2^{d}$ and $A \oplus B = C$ ($\oplus$ denotes the bitwise XOR operation). Find the maximum value of $A \cdot B$ over all these pairs.
------ Input ------
The first line of the input contains a single integer $T$ denoting the number of test cases. The description of $T$ test cases follows.
The first and only line of each test case contains a single integer $C$.
------ Output ------
For each test case, print a single line containing one integer β the maximum possible product $A \cdot B$.
------ Constraints ------
$1 β€ T β€ 10^{5}$
$1 β€ C β€ 10^{9}$
------ Subtasks ------
Subtask #1 (30 points): $1 β€ C β€ 10^{3}$
Subtask #2 (70 points): original constraints
----- Sample Input 1 ------
2
13
10
----- Sample Output 1 ------
70
91
----- explanation 1 ------
Example case 1: The binary representation of $13$ is "1101". We can use $A = 10$ ("1010" in binary) and $B = 7$ ("0111" in binary). This gives us the product $70$. No other valid pair $(A, B)$ can give us a larger product.
Example case 2: The binary representation of $10$ is "1010". We can use $A = 13$ ("1101") and $B = 7$ ("0111"). This gives us the maximum product $91$. | for _ in range(int(input())):
n = int(input())
s = bin(n)[2:]
l = len(s)
x, y = "", ""
for i in range(l):
if i == 0:
if s[i] == "1":
x += "1"
y += "0"
else:
x += "1"
y += "1"
elif s[i] == "1":
x += "0"
y += "1"
else:
x += "1"
y += "1"
x = int(x, 2)
y = int(y, 2)
print(x * y) | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR STRING STRING FOR VAR FUNC_CALL VAR VAR IF VAR NUMBER IF VAR VAR STRING VAR STRING VAR STRING VAR STRING VAR STRING IF VAR VAR STRING VAR STRING VAR STRING VAR STRING VAR STRING ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR VAR |
Read problem statements in [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
You are given an integer $C$. Let $d$ be the smallest integer such that $2^{d}$ is strictly greater than $C$.
Consider all pairs of non-negative integers $(A,B)$ such that $A,B < 2^{d}$ and $A \oplus B = C$ ($\oplus$ denotes the bitwise XOR operation). Find the maximum value of $A \cdot B$ over all these pairs.
------ Input ------
The first line of the input contains a single integer $T$ denoting the number of test cases. The description of $T$ test cases follows.
The first and only line of each test case contains a single integer $C$.
------ Output ------
For each test case, print a single line containing one integer β the maximum possible product $A \cdot B$.
------ Constraints ------
$1 β€ T β€ 10^{5}$
$1 β€ C β€ 10^{9}$
------ Subtasks ------
Subtask #1 (30 points): $1 β€ C β€ 10^{3}$
Subtask #2 (70 points): original constraints
----- Sample Input 1 ------
2
13
10
----- Sample Output 1 ------
70
91
----- explanation 1 ------
Example case 1: The binary representation of $13$ is "1101". We can use $A = 10$ ("1010" in binary) and $B = 7$ ("0111" in binary). This gives us the product $70$. No other valid pair $(A, B)$ can give us a larger product.
Example case 2: The binary representation of $10$ is "1010". We can use $A = 13$ ("1101") and $B = 7$ ("0111"). This gives us the maximum product $91$. | testcases = int(input())
for i in range(testcases):
C = int(input())
temp = bin(C).replace("0b", "")
x = "0"
y = "1"
z = len(temp)
for k in range(1, z):
if temp[k] == "1":
x = x + "1"
y = y + "0"
else:
x = x + "1"
y = y + "1"
A = int(x, 2)
B = int(y, 2)
print(A * B) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR VAR STRING STRING ASSIGN VAR STRING ASSIGN VAR STRING ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR STRING ASSIGN VAR BIN_OP VAR STRING ASSIGN VAR BIN_OP VAR STRING ASSIGN VAR BIN_OP VAR STRING ASSIGN VAR BIN_OP VAR STRING ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR VAR |
Read problem statements in [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
You are given an integer $C$. Let $d$ be the smallest integer such that $2^{d}$ is strictly greater than $C$.
Consider all pairs of non-negative integers $(A,B)$ such that $A,B < 2^{d}$ and $A \oplus B = C$ ($\oplus$ denotes the bitwise XOR operation). Find the maximum value of $A \cdot B$ over all these pairs.
------ Input ------
The first line of the input contains a single integer $T$ denoting the number of test cases. The description of $T$ test cases follows.
The first and only line of each test case contains a single integer $C$.
------ Output ------
For each test case, print a single line containing one integer β the maximum possible product $A \cdot B$.
------ Constraints ------
$1 β€ T β€ 10^{5}$
$1 β€ C β€ 10^{9}$
------ Subtasks ------
Subtask #1 (30 points): $1 β€ C β€ 10^{3}$
Subtask #2 (70 points): original constraints
----- Sample Input 1 ------
2
13
10
----- Sample Output 1 ------
70
91
----- explanation 1 ------
Example case 1: The binary representation of $13$ is "1101". We can use $A = 10$ ("1010" in binary) and $B = 7$ ("0111" in binary). This gives us the product $70$. No other valid pair $(A, B)$ can give us a larger product.
Example case 2: The binary representation of $10$ is "1010". We can use $A = 13$ ("1101") and $B = 7$ ("0111"). This gives us the maximum product $91$. | def main():
T = int(input())
for counter in range(T):
ans = 0
a = ""
b = ""
c = int(input())
cbin = bin(c)[2:]
d = len(cbin)
cbin = str(cbin)
countera = 0
counterb = 0
for i in range(len(cbin)):
if cbin[i] == "0":
a += "1"
b += "1"
elif countera > counterb:
a += "0"
b += "1"
counterb += 2 ** (d - i)
else:
a += "1"
b += "0"
countera += 2 ** (d - i)
ans = int(a, 2) * int(b, 2)
print(ans)
main() | FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR STRING ASSIGN VAR STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR STRING VAR STRING IF VAR VAR VAR STRING VAR STRING VAR BIN_OP NUMBER BIN_OP VAR VAR VAR STRING VAR STRING VAR BIN_OP NUMBER BIN_OP VAR VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR |
Read problem statements in [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
You are given an integer $C$. Let $d$ be the smallest integer such that $2^{d}$ is strictly greater than $C$.
Consider all pairs of non-negative integers $(A,B)$ such that $A,B < 2^{d}$ and $A \oplus B = C$ ($\oplus$ denotes the bitwise XOR operation). Find the maximum value of $A \cdot B$ over all these pairs.
------ Input ------
The first line of the input contains a single integer $T$ denoting the number of test cases. The description of $T$ test cases follows.
The first and only line of each test case contains a single integer $C$.
------ Output ------
For each test case, print a single line containing one integer β the maximum possible product $A \cdot B$.
------ Constraints ------
$1 β€ T β€ 10^{5}$
$1 β€ C β€ 10^{9}$
------ Subtasks ------
Subtask #1 (30 points): $1 β€ C β€ 10^{3}$
Subtask #2 (70 points): original constraints
----- Sample Input 1 ------
2
13
10
----- Sample Output 1 ------
70
91
----- explanation 1 ------
Example case 1: The binary representation of $13$ is "1101". We can use $A = 10$ ("1010" in binary) and $B = 7$ ("0111" in binary). This gives us the product $70$. No other valid pair $(A, B)$ can give us a larger product.
Example case 2: The binary representation of $10$ is "1010". We can use $A = 13$ ("1101") and $B = 7$ ("0111"). This gives us the maximum product $91$. | for _ in range(int(input())):
n = int(input())
binary = bin(n)
binary = binary[2:]
a = "1"
b = "0"
for i in range(1, len(binary)):
if binary[i] == "1":
b += "1"
a += "0"
else:
a += "1"
b += "1"
print(int(a, 2) * int(b, 2)) | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER ASSIGN VAR STRING ASSIGN VAR STRING FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR IF VAR VAR STRING VAR STRING VAR STRING VAR STRING VAR STRING EXPR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR NUMBER |
Read problem statements in [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
You are given an integer $C$. Let $d$ be the smallest integer such that $2^{d}$ is strictly greater than $C$.
Consider all pairs of non-negative integers $(A,B)$ such that $A,B < 2^{d}$ and $A \oplus B = C$ ($\oplus$ denotes the bitwise XOR operation). Find the maximum value of $A \cdot B$ over all these pairs.
------ Input ------
The first line of the input contains a single integer $T$ denoting the number of test cases. The description of $T$ test cases follows.
The first and only line of each test case contains a single integer $C$.
------ Output ------
For each test case, print a single line containing one integer β the maximum possible product $A \cdot B$.
------ Constraints ------
$1 β€ T β€ 10^{5}$
$1 β€ C β€ 10^{9}$
------ Subtasks ------
Subtask #1 (30 points): $1 β€ C β€ 10^{3}$
Subtask #2 (70 points): original constraints
----- Sample Input 1 ------
2
13
10
----- Sample Output 1 ------
70
91
----- explanation 1 ------
Example case 1: The binary representation of $13$ is "1101". We can use $A = 10$ ("1010" in binary) and $B = 7$ ("0111" in binary). This gives us the product $70$. No other valid pair $(A, B)$ can give us a larger product.
Example case 2: The binary representation of $10$ is "1010". We can use $A = 13$ ("1101") and $B = 7$ ("0111"). This gives us the maximum product $91$. | p = int(input())
for i in range(p):
c = int(input())
w = bin(c)[2:]
a = ""
b = ""
se = False
for i in range(len(w)):
if not se and w[i] == "1":
a += "1"
b += "0"
se = True
elif w[i] == "1":
a += "0"
b += "1"
else:
a += "1"
b += "1"
print(int(a, 2) * int(b, 2)) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR STRING ASSIGN VAR STRING ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR VAR STRING VAR STRING VAR STRING ASSIGN VAR NUMBER IF VAR VAR STRING VAR STRING VAR STRING VAR STRING VAR STRING EXPR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR NUMBER |
Read problem statements in [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
You are given an integer $C$. Let $d$ be the smallest integer such that $2^{d}$ is strictly greater than $C$.
Consider all pairs of non-negative integers $(A,B)$ such that $A,B < 2^{d}$ and $A \oplus B = C$ ($\oplus$ denotes the bitwise XOR operation). Find the maximum value of $A \cdot B$ over all these pairs.
------ Input ------
The first line of the input contains a single integer $T$ denoting the number of test cases. The description of $T$ test cases follows.
The first and only line of each test case contains a single integer $C$.
------ Output ------
For each test case, print a single line containing one integer β the maximum possible product $A \cdot B$.
------ Constraints ------
$1 β€ T β€ 10^{5}$
$1 β€ C β€ 10^{9}$
------ Subtasks ------
Subtask #1 (30 points): $1 β€ C β€ 10^{3}$
Subtask #2 (70 points): original constraints
----- Sample Input 1 ------
2
13
10
----- Sample Output 1 ------
70
91
----- explanation 1 ------
Example case 1: The binary representation of $13$ is "1101". We can use $A = 10$ ("1010" in binary) and $B = 7$ ("0111" in binary). This gives us the product $70$. No other valid pair $(A, B)$ can give us a larger product.
Example case 2: The binary representation of $10$ is "1010". We can use $A = 13$ ("1101") and $B = 7$ ("0111"). This gives us the maximum product $91$. | def decimalToBinary(n):
return bin(n).replace("0b", "")
case = int(input())
for i in range(case):
c = int(input())
n = str(decimalToBinary(c))
a = [0] * len(n)
b = [0] * len(n)
a[0] = 1
for i in range(1, len(n)):
if n[i] == "0":
a[i] = 1
b[i] = 1
else:
b[i] = 1
k = len(n) - 1
A = 0
B = 0
i = 0
while k >= 0:
A += 2**k * a[i]
B += 2**k * b[i]
i += 1
k -= 1
print(A * B) | FUNC_DEF RETURN FUNC_CALL FUNC_CALL VAR VAR STRING STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER FUNC_CALL VAR VAR ASSIGN VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR IF VAR VAR STRING ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR NUMBER VAR BIN_OP BIN_OP NUMBER VAR VAR VAR VAR BIN_OP BIN_OP NUMBER VAR VAR VAR VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR VAR |
Read problem statements in [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
You are given an integer $C$. Let $d$ be the smallest integer such that $2^{d}$ is strictly greater than $C$.
Consider all pairs of non-negative integers $(A,B)$ such that $A,B < 2^{d}$ and $A \oplus B = C$ ($\oplus$ denotes the bitwise XOR operation). Find the maximum value of $A \cdot B$ over all these pairs.
------ Input ------
The first line of the input contains a single integer $T$ denoting the number of test cases. The description of $T$ test cases follows.
The first and only line of each test case contains a single integer $C$.
------ Output ------
For each test case, print a single line containing one integer β the maximum possible product $A \cdot B$.
------ Constraints ------
$1 β€ T β€ 10^{5}$
$1 β€ C β€ 10^{9}$
------ Subtasks ------
Subtask #1 (30 points): $1 β€ C β€ 10^{3}$
Subtask #2 (70 points): original constraints
----- Sample Input 1 ------
2
13
10
----- Sample Output 1 ------
70
91
----- explanation 1 ------
Example case 1: The binary representation of $13$ is "1101". We can use $A = 10$ ("1010" in binary) and $B = 7$ ("0111" in binary). This gives us the product $70$. No other valid pair $(A, B)$ can give us a larger product.
Example case 2: The binary representation of $10$ is "1010". We can use $A = 13$ ("1101") and $B = 7$ ("0111"). This gives us the maximum product $91$. | for _ in range(int(input())):
c = int(input())
a = b = 0
flag = False
for i in range(32, -1, -1):
if flag:
if c & 1 << i > 0:
a |= 1 << i
else:
a |= 1 << i
b |= 1 << i
elif c & 1 << i > 0:
flag = True
b = 1 << i
print(a * b) | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER NUMBER IF VAR IF BIN_OP VAR BIN_OP NUMBER VAR NUMBER VAR BIN_OP NUMBER VAR VAR BIN_OP NUMBER VAR VAR BIN_OP NUMBER VAR IF BIN_OP VAR BIN_OP NUMBER VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP NUMBER VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR |
Read problem statements in [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
You are given an integer $C$. Let $d$ be the smallest integer such that $2^{d}$ is strictly greater than $C$.
Consider all pairs of non-negative integers $(A,B)$ such that $A,B < 2^{d}$ and $A \oplus B = C$ ($\oplus$ denotes the bitwise XOR operation). Find the maximum value of $A \cdot B$ over all these pairs.
------ Input ------
The first line of the input contains a single integer $T$ denoting the number of test cases. The description of $T$ test cases follows.
The first and only line of each test case contains a single integer $C$.
------ Output ------
For each test case, print a single line containing one integer β the maximum possible product $A \cdot B$.
------ Constraints ------
$1 β€ T β€ 10^{5}$
$1 β€ C β€ 10^{9}$
------ Subtasks ------
Subtask #1 (30 points): $1 β€ C β€ 10^{3}$
Subtask #2 (70 points): original constraints
----- Sample Input 1 ------
2
13
10
----- Sample Output 1 ------
70
91
----- explanation 1 ------
Example case 1: The binary representation of $13$ is "1101". We can use $A = 10$ ("1010" in binary) and $B = 7$ ("0111" in binary). This gives us the product $70$. No other valid pair $(A, B)$ can give us a larger product.
Example case 2: The binary representation of $10$ is "1010". We can use $A = 13$ ("1101") and $B = 7$ ("0111"). This gives us the maximum product $91$. | for _ in range(int(input())):
n = int(input())
x = bin(n).replace("0b", "")
p = 1 << len(x) + 1 - 1
p //= 2
print((p - 1) * (n ^ p - 1)) | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR VAR STRING STRING ASSIGN VAR BIN_OP NUMBER BIN_OP BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER VAR NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER BIN_OP VAR BIN_OP VAR NUMBER |
Read problem statements in [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
You are given an integer $C$. Let $d$ be the smallest integer such that $2^{d}$ is strictly greater than $C$.
Consider all pairs of non-negative integers $(A,B)$ such that $A,B < 2^{d}$ and $A \oplus B = C$ ($\oplus$ denotes the bitwise XOR operation). Find the maximum value of $A \cdot B$ over all these pairs.
------ Input ------
The first line of the input contains a single integer $T$ denoting the number of test cases. The description of $T$ test cases follows.
The first and only line of each test case contains a single integer $C$.
------ Output ------
For each test case, print a single line containing one integer β the maximum possible product $A \cdot B$.
------ Constraints ------
$1 β€ T β€ 10^{5}$
$1 β€ C β€ 10^{9}$
------ Subtasks ------
Subtask #1 (30 points): $1 β€ C β€ 10^{3}$
Subtask #2 (70 points): original constraints
----- Sample Input 1 ------
2
13
10
----- Sample Output 1 ------
70
91
----- explanation 1 ------
Example case 1: The binary representation of $13$ is "1101". We can use $A = 10$ ("1010" in binary) and $B = 7$ ("0111" in binary). This gives us the product $70$. No other valid pair $(A, B)$ can give us a larger product.
Example case 2: The binary representation of $10$ is "1010". We can use $A = 13$ ("1101") and $B = 7$ ("0111"). This gives us the maximum product $91$. | for _ in range(int(input())):
n = int(input())
binary = bin(n)
binary = binary[2:]
a = ""
b = ""
for i in range(len(binary)):
if binary[i] == "1":
temp_1 = a + "1"
temp_2 = b + "0"
temp_3 = a + "0"
temp_4 = b + "1"
if int(temp_1, 2) * int(temp_2, 2) > int(temp_3, 2) * int(temp_4, 2):
a = temp_1
b = temp_2
else:
a = temp_3
b = temp_4
else:
a += "1"
b += "1"
print(int(a, 2) * int(b, 2)) | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER ASSIGN VAR STRING ASSIGN VAR STRING FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR STRING ASSIGN VAR BIN_OP VAR STRING ASSIGN VAR BIN_OP VAR STRING ASSIGN VAR BIN_OP VAR STRING ASSIGN VAR BIN_OP VAR STRING IF BIN_OP FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR VAR STRING VAR STRING EXPR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR NUMBER |
Read problem statements in [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
You are given an integer $C$. Let $d$ be the smallest integer such that $2^{d}$ is strictly greater than $C$.
Consider all pairs of non-negative integers $(A,B)$ such that $A,B < 2^{d}$ and $A \oplus B = C$ ($\oplus$ denotes the bitwise XOR operation). Find the maximum value of $A \cdot B$ over all these pairs.
------ Input ------
The first line of the input contains a single integer $T$ denoting the number of test cases. The description of $T$ test cases follows.
The first and only line of each test case contains a single integer $C$.
------ Output ------
For each test case, print a single line containing one integer β the maximum possible product $A \cdot B$.
------ Constraints ------
$1 β€ T β€ 10^{5}$
$1 β€ C β€ 10^{9}$
------ Subtasks ------
Subtask #1 (30 points): $1 β€ C β€ 10^{3}$
Subtask #2 (70 points): original constraints
----- Sample Input 1 ------
2
13
10
----- Sample Output 1 ------
70
91
----- explanation 1 ------
Example case 1: The binary representation of $13$ is "1101". We can use $A = 10$ ("1010" in binary) and $B = 7$ ("0111" in binary). This gives us the product $70$. No other valid pair $(A, B)$ can give us a larger product.
Example case 2: The binary representation of $10$ is "1010". We can use $A = 13$ ("1101") and $B = 7$ ("0111"). This gives us the maximum product $91$. | def gcd(a, b):
if b == 0:
return a
return gcd(b, a % b)
t = int(input())
while t:
t -= 1
c = int(input())
i = 0
while 1 << i <= c:
i += 1
a = 0
b = 0
flag = True
for j in range(i - 1, -1, -1):
if c & 1 << j == 0:
a |= 1 << j
b |= 1 << j
elif flag:
b |= 1 << j
flag = False
else:
a |= 1 << j
print(a * b) | FUNC_DEF IF VAR NUMBER RETURN VAR RETURN FUNC_CALL VAR VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER WHILE BIN_OP NUMBER VAR VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER IF BIN_OP VAR BIN_OP NUMBER VAR NUMBER VAR BIN_OP NUMBER VAR VAR BIN_OP NUMBER VAR IF VAR VAR BIN_OP NUMBER VAR ASSIGN VAR NUMBER VAR BIN_OP NUMBER VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR |
Read problem statements in [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
You are given an integer $C$. Let $d$ be the smallest integer such that $2^{d}$ is strictly greater than $C$.
Consider all pairs of non-negative integers $(A,B)$ such that $A,B < 2^{d}$ and $A \oplus B = C$ ($\oplus$ denotes the bitwise XOR operation). Find the maximum value of $A \cdot B$ over all these pairs.
------ Input ------
The first line of the input contains a single integer $T$ denoting the number of test cases. The description of $T$ test cases follows.
The first and only line of each test case contains a single integer $C$.
------ Output ------
For each test case, print a single line containing one integer β the maximum possible product $A \cdot B$.
------ Constraints ------
$1 β€ T β€ 10^{5}$
$1 β€ C β€ 10^{9}$
------ Subtasks ------
Subtask #1 (30 points): $1 β€ C β€ 10^{3}$
Subtask #2 (70 points): original constraints
----- Sample Input 1 ------
2
13
10
----- Sample Output 1 ------
70
91
----- explanation 1 ------
Example case 1: The binary representation of $13$ is "1101". We can use $A = 10$ ("1010" in binary) and $B = 7$ ("0111" in binary). This gives us the product $70$. No other valid pair $(A, B)$ can give us a larger product.
Example case 2: The binary representation of $10$ is "1010". We can use $A = 13$ ("1101") and $B = 7$ ("0111"). This gives us the maximum product $91$. | t = int(input())
for _ in range(t):
n = int(input())
n = bin(n).replace("0b", "")
leng = len(n)
a = str()
b = str()
a1 = 1
for i in range(leng):
if n[i] == "1" and a1 == 1:
a = a + "1"
b = b + "0"
a1 = 0
elif n[i] == "0":
a = a + "1"
b = b + "1"
elif n[i] == "1":
a = a + "0"
b = b + "1"
a = "0b" + a
b = "0b" + b
a = int(a, 2)
b = int(b, 2)
print(a * b) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR VAR STRING STRING ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR NUMBER ASSIGN VAR BIN_OP VAR STRING ASSIGN VAR BIN_OP VAR STRING ASSIGN VAR NUMBER IF VAR VAR STRING ASSIGN VAR BIN_OP VAR STRING ASSIGN VAR BIN_OP VAR STRING IF VAR VAR STRING ASSIGN VAR BIN_OP VAR STRING ASSIGN VAR BIN_OP VAR STRING ASSIGN VAR BIN_OP STRING VAR ASSIGN VAR BIN_OP STRING VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR VAR |
Read problem statements in [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
You are given an integer $C$. Let $d$ be the smallest integer such that $2^{d}$ is strictly greater than $C$.
Consider all pairs of non-negative integers $(A,B)$ such that $A,B < 2^{d}$ and $A \oplus B = C$ ($\oplus$ denotes the bitwise XOR operation). Find the maximum value of $A \cdot B$ over all these pairs.
------ Input ------
The first line of the input contains a single integer $T$ denoting the number of test cases. The description of $T$ test cases follows.
The first and only line of each test case contains a single integer $C$.
------ Output ------
For each test case, print a single line containing one integer β the maximum possible product $A \cdot B$.
------ Constraints ------
$1 β€ T β€ 10^{5}$
$1 β€ C β€ 10^{9}$
------ Subtasks ------
Subtask #1 (30 points): $1 β€ C β€ 10^{3}$
Subtask #2 (70 points): original constraints
----- Sample Input 1 ------
2
13
10
----- Sample Output 1 ------
70
91
----- explanation 1 ------
Example case 1: The binary representation of $13$ is "1101". We can use $A = 10$ ("1010" in binary) and $B = 7$ ("0111" in binary). This gives us the product $70$. No other valid pair $(A, B)$ can give us a larger product.
Example case 2: The binary representation of $10$ is "1010". We can use $A = 13$ ("1101") and $B = 7$ ("0111"). This gives us the maximum product $91$. | for i in range(int(input())):
c = int(input())
a = 0
b = 0
t = 0
for j in range(32, -1, -1):
r = c & 1 << j
if r > 0:
if t == 0:
t = 1
if a < b:
a += r
else:
b += r
elif t != 0:
a += 1 << j
b += 1 << j
print(a * b) | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER NUMBER ASSIGN VAR BIN_OP VAR BIN_OP NUMBER VAR IF VAR NUMBER IF VAR NUMBER ASSIGN VAR NUMBER IF VAR VAR VAR VAR VAR VAR IF VAR NUMBER VAR BIN_OP NUMBER VAR VAR BIN_OP NUMBER VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR |
Read problem statements in [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
You are given an integer $C$. Let $d$ be the smallest integer such that $2^{d}$ is strictly greater than $C$.
Consider all pairs of non-negative integers $(A,B)$ such that $A,B < 2^{d}$ and $A \oplus B = C$ ($\oplus$ denotes the bitwise XOR operation). Find the maximum value of $A \cdot B$ over all these pairs.
------ Input ------
The first line of the input contains a single integer $T$ denoting the number of test cases. The description of $T$ test cases follows.
The first and only line of each test case contains a single integer $C$.
------ Output ------
For each test case, print a single line containing one integer β the maximum possible product $A \cdot B$.
------ Constraints ------
$1 β€ T β€ 10^{5}$
$1 β€ C β€ 10^{9}$
------ Subtasks ------
Subtask #1 (30 points): $1 β€ C β€ 10^{3}$
Subtask #2 (70 points): original constraints
----- Sample Input 1 ------
2
13
10
----- Sample Output 1 ------
70
91
----- explanation 1 ------
Example case 1: The binary representation of $13$ is "1101". We can use $A = 10$ ("1010" in binary) and $B = 7$ ("0111" in binary). This gives us the product $70$. No other valid pair $(A, B)$ can give us a larger product.
Example case 2: The binary representation of $10$ is "1010". We can use $A = 13$ ("1101") and $B = 7$ ("0111"). This gives us the maximum product $91$. | try:
for i in range(int(input())):
n = int(input())
bi = bin(n).replace("0b", "")
a = 2 ** len(bi) // 2
l = 2 ** len(bi) - 1
b = l - (n - a)
a -= 1
print(a * b)
except Exception as e:
print(e) | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR VAR STRING STRING ASSIGN VAR BIN_OP BIN_OP NUMBER FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP NUMBER FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP VAR VAR VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR VAR VAR EXPR FUNC_CALL VAR VAR |
Read problem statements in [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
You are given an integer $C$. Let $d$ be the smallest integer such that $2^{d}$ is strictly greater than $C$.
Consider all pairs of non-negative integers $(A,B)$ such that $A,B < 2^{d}$ and $A \oplus B = C$ ($\oplus$ denotes the bitwise XOR operation). Find the maximum value of $A \cdot B$ over all these pairs.
------ Input ------
The first line of the input contains a single integer $T$ denoting the number of test cases. The description of $T$ test cases follows.
The first and only line of each test case contains a single integer $C$.
------ Output ------
For each test case, print a single line containing one integer β the maximum possible product $A \cdot B$.
------ Constraints ------
$1 β€ T β€ 10^{5}$
$1 β€ C β€ 10^{9}$
------ Subtasks ------
Subtask #1 (30 points): $1 β€ C β€ 10^{3}$
Subtask #2 (70 points): original constraints
----- Sample Input 1 ------
2
13
10
----- Sample Output 1 ------
70
91
----- explanation 1 ------
Example case 1: The binary representation of $13$ is "1101". We can use $A = 10$ ("1010" in binary) and $B = 7$ ("0111" in binary). This gives us the product $70$. No other valid pair $(A, B)$ can give us a larger product.
Example case 2: The binary representation of $10$ is "1010". We can use $A = 13$ ("1101") and $B = 7$ ("0111"). This gives us the maximum product $91$. | for _ in range(int(input())):
c = int(input())
s = str(bin(c))[2:]
s1, s2 = "", ""
k = True
for i in s:
if i == "0":
s1 += "1"
s2 += "1"
elif k:
s1 += "1"
s2 += "0"
k = False
else:
s1 += "0"
s2 += "1"
a = 0
for i in range(len(s1)):
a += int(s1[::-1][i]) * 2**i
b = 0
for i in range(len(s2)):
b += int(s2[::-1][i]) * 2**i
print(a * b) | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR STRING STRING ASSIGN VAR NUMBER FOR VAR VAR IF VAR STRING VAR STRING VAR STRING IF VAR VAR STRING VAR STRING ASSIGN VAR NUMBER VAR STRING VAR STRING ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR BIN_OP FUNC_CALL VAR VAR NUMBER VAR BIN_OP NUMBER VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR BIN_OP FUNC_CALL VAR VAR NUMBER VAR BIN_OP NUMBER VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR |
Read problem statements in [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
You are given an integer $C$. Let $d$ be the smallest integer such that $2^{d}$ is strictly greater than $C$.
Consider all pairs of non-negative integers $(A,B)$ such that $A,B < 2^{d}$ and $A \oplus B = C$ ($\oplus$ denotes the bitwise XOR operation). Find the maximum value of $A \cdot B$ over all these pairs.
------ Input ------
The first line of the input contains a single integer $T$ denoting the number of test cases. The description of $T$ test cases follows.
The first and only line of each test case contains a single integer $C$.
------ Output ------
For each test case, print a single line containing one integer β the maximum possible product $A \cdot B$.
------ Constraints ------
$1 β€ T β€ 10^{5}$
$1 β€ C β€ 10^{9}$
------ Subtasks ------
Subtask #1 (30 points): $1 β€ C β€ 10^{3}$
Subtask #2 (70 points): original constraints
----- Sample Input 1 ------
2
13
10
----- Sample Output 1 ------
70
91
----- explanation 1 ------
Example case 1: The binary representation of $13$ is "1101". We can use $A = 10$ ("1010" in binary) and $B = 7$ ("0111" in binary). This gives us the product $70$. No other valid pair $(A, B)$ can give us a larger product.
Example case 2: The binary representation of $10$ is "1010". We can use $A = 13$ ("1101") and $B = 7$ ("0111"). This gives us the maximum product $91$. | t = int(input())
for u in range(t):
n = int(input())
a = b = 0
i = 0
while n > 1:
r = n % 2
if r:
b += 2**i
else:
a += 2**i
b += 2**i
n //= 2
i += 1
a += 2**i
print(a * b) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER WHILE VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF VAR VAR BIN_OP NUMBER VAR VAR BIN_OP NUMBER VAR VAR BIN_OP NUMBER VAR VAR NUMBER VAR NUMBER VAR BIN_OP NUMBER VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR |
Read problem statements in [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
You are given an integer $C$. Let $d$ be the smallest integer such that $2^{d}$ is strictly greater than $C$.
Consider all pairs of non-negative integers $(A,B)$ such that $A,B < 2^{d}$ and $A \oplus B = C$ ($\oplus$ denotes the bitwise XOR operation). Find the maximum value of $A \cdot B$ over all these pairs.
------ Input ------
The first line of the input contains a single integer $T$ denoting the number of test cases. The description of $T$ test cases follows.
The first and only line of each test case contains a single integer $C$.
------ Output ------
For each test case, print a single line containing one integer β the maximum possible product $A \cdot B$.
------ Constraints ------
$1 β€ T β€ 10^{5}$
$1 β€ C β€ 10^{9}$
------ Subtasks ------
Subtask #1 (30 points): $1 β€ C β€ 10^{3}$
Subtask #2 (70 points): original constraints
----- Sample Input 1 ------
2
13
10
----- Sample Output 1 ------
70
91
----- explanation 1 ------
Example case 1: The binary representation of $13$ is "1101". We can use $A = 10$ ("1010" in binary) and $B = 7$ ("0111" in binary). This gives us the product $70$. No other valid pair $(A, B)$ can give us a larger product.
Example case 2: The binary representation of $10$ is "1010". We can use $A = 13$ ("1101") and $B = 7$ ("0111"). This gives us the maximum product $91$. | T = int(input())
for t in range(T):
C = bin(int(input()))
if C == "0b1":
print(0)
else:
A = "0b1"
B = "0b"
for i in range(3, len(C)):
B += "1"
if C[i] == "1":
A += "0"
else:
A += "1"
print(int(A, 2) * int(B, 2)) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR IF VAR STRING EXPR FUNC_CALL VAR NUMBER ASSIGN VAR STRING ASSIGN VAR STRING FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR VAR STRING IF VAR VAR STRING VAR STRING VAR STRING EXPR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR NUMBER |
Read problem statements in [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
You are given an integer $C$. Let $d$ be the smallest integer such that $2^{d}$ is strictly greater than $C$.
Consider all pairs of non-negative integers $(A,B)$ such that $A,B < 2^{d}$ and $A \oplus B = C$ ($\oplus$ denotes the bitwise XOR operation). Find the maximum value of $A \cdot B$ over all these pairs.
------ Input ------
The first line of the input contains a single integer $T$ denoting the number of test cases. The description of $T$ test cases follows.
The first and only line of each test case contains a single integer $C$.
------ Output ------
For each test case, print a single line containing one integer β the maximum possible product $A \cdot B$.
------ Constraints ------
$1 β€ T β€ 10^{5}$
$1 β€ C β€ 10^{9}$
------ Subtasks ------
Subtask #1 (30 points): $1 β€ C β€ 10^{3}$
Subtask #2 (70 points): original constraints
----- Sample Input 1 ------
2
13
10
----- Sample Output 1 ------
70
91
----- explanation 1 ------
Example case 1: The binary representation of $13$ is "1101". We can use $A = 10$ ("1010" in binary) and $B = 7$ ("0111" in binary). This gives us the product $70$. No other valid pair $(A, B)$ can give us a larger product.
Example case 2: The binary representation of $10$ is "1010". We can use $A = 13$ ("1101") and $B = 7$ ("0111"). This gives us the maximum product $91$. | t = int(input())
for _ in range(t):
C = int(input())
d = len(bin(C)) - 2
A = 2**d - 1 ^ C
B = A
A |= 2 ** (d - 1)
C ^= 2 ** (d - 1)
B = B | C
print(A * B) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP NUMBER VAR NUMBER VAR ASSIGN VAR VAR VAR BIN_OP NUMBER BIN_OP VAR NUMBER VAR BIN_OP NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR |
Read problem statements in [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
You are given an integer $C$. Let $d$ be the smallest integer such that $2^{d}$ is strictly greater than $C$.
Consider all pairs of non-negative integers $(A,B)$ such that $A,B < 2^{d}$ and $A \oplus B = C$ ($\oplus$ denotes the bitwise XOR operation). Find the maximum value of $A \cdot B$ over all these pairs.
------ Input ------
The first line of the input contains a single integer $T$ denoting the number of test cases. The description of $T$ test cases follows.
The first and only line of each test case contains a single integer $C$.
------ Output ------
For each test case, print a single line containing one integer β the maximum possible product $A \cdot B$.
------ Constraints ------
$1 β€ T β€ 10^{5}$
$1 β€ C β€ 10^{9}$
------ Subtasks ------
Subtask #1 (30 points): $1 β€ C β€ 10^{3}$
Subtask #2 (70 points): original constraints
----- Sample Input 1 ------
2
13
10
----- Sample Output 1 ------
70
91
----- explanation 1 ------
Example case 1: The binary representation of $13$ is "1101". We can use $A = 10$ ("1010" in binary) and $B = 7$ ("0111" in binary). This gives us the product $70$. No other valid pair $(A, B)$ can give us a larger product.
Example case 2: The binary representation of $10$ is "1010". We can use $A = 13$ ("1101") and $B = 7$ ("0111"). This gives us the maximum product $91$. | for i in range(int(input())):
c = int(input())
b = bin(c).replace("0b", "")
b = str(b)
a = "1"
r = "0"
for j in range(1, len(b)):
if b[j] == "0":
a += "1"
r += "1"
else:
a += "0"
r += "1"
a = int(a, 2)
b = int(b, 2)
r = int(r, 2)
print(a * r) | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR VAR STRING STRING ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR STRING ASSIGN VAR STRING FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR IF VAR VAR STRING VAR STRING VAR STRING VAR STRING VAR STRING ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR VAR |
Read problem statements in [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
You are given an integer $C$. Let $d$ be the smallest integer such that $2^{d}$ is strictly greater than $C$.
Consider all pairs of non-negative integers $(A,B)$ such that $A,B < 2^{d}$ and $A \oplus B = C$ ($\oplus$ denotes the bitwise XOR operation). Find the maximum value of $A \cdot B$ over all these pairs.
------ Input ------
The first line of the input contains a single integer $T$ denoting the number of test cases. The description of $T$ test cases follows.
The first and only line of each test case contains a single integer $C$.
------ Output ------
For each test case, print a single line containing one integer β the maximum possible product $A \cdot B$.
------ Constraints ------
$1 β€ T β€ 10^{5}$
$1 β€ C β€ 10^{9}$
------ Subtasks ------
Subtask #1 (30 points): $1 β€ C β€ 10^{3}$
Subtask #2 (70 points): original constraints
----- Sample Input 1 ------
2
13
10
----- Sample Output 1 ------
70
91
----- explanation 1 ------
Example case 1: The binary representation of $13$ is "1101". We can use $A = 10$ ("1010" in binary) and $B = 7$ ("0111" in binary). This gives us the product $70$. No other valid pair $(A, B)$ can give us a larger product.
Example case 2: The binary representation of $10$ is "1010". We can use $A = 13$ ("1101") and $B = 7$ ("0111"). This gives us the maximum product $91$. | def largest(i):
k = 2
while k <= i:
k = k * 2
return k
i = int(input())
listk = []
for _ in range(i):
listno = []
kk = int(input())
max = 0
ls = largest(kk)
no = ""
for k in range(len(format(kk, "b"))):
if k == 0:
no = "1"
elif str(format(kk, "b"))[k] == "0":
no = no + "1"
elif str(format(kk, "b"))[k] == "1":
no = no + "0"
max = int(no, 2) * (int(no, 2) ^ kk)
listk.append(max)
for ele in listk:
print(ele) | FUNC_DEF ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP VAR NUMBER RETURN VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR STRING FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR STRING IF VAR NUMBER ASSIGN VAR STRING IF FUNC_CALL VAR FUNC_CALL VAR VAR STRING VAR STRING ASSIGN VAR BIN_OP VAR STRING IF FUNC_CALL VAR FUNC_CALL VAR VAR STRING VAR STRING ASSIGN VAR BIN_OP VAR STRING ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER VAR EXPR FUNC_CALL VAR VAR FOR VAR VAR EXPR FUNC_CALL VAR VAR |
Read problem statements in [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
You are given an integer $C$. Let $d$ be the smallest integer such that $2^{d}$ is strictly greater than $C$.
Consider all pairs of non-negative integers $(A,B)$ such that $A,B < 2^{d}$ and $A \oplus B = C$ ($\oplus$ denotes the bitwise XOR operation). Find the maximum value of $A \cdot B$ over all these pairs.
------ Input ------
The first line of the input contains a single integer $T$ denoting the number of test cases. The description of $T$ test cases follows.
The first and only line of each test case contains a single integer $C$.
------ Output ------
For each test case, print a single line containing one integer β the maximum possible product $A \cdot B$.
------ Constraints ------
$1 β€ T β€ 10^{5}$
$1 β€ C β€ 10^{9}$
------ Subtasks ------
Subtask #1 (30 points): $1 β€ C β€ 10^{3}$
Subtask #2 (70 points): original constraints
----- Sample Input 1 ------
2
13
10
----- Sample Output 1 ------
70
91
----- explanation 1 ------
Example case 1: The binary representation of $13$ is "1101". We can use $A = 10$ ("1010" in binary) and $B = 7$ ("0111" in binary). This gives us the product $70$. No other valid pair $(A, B)$ can give us a larger product.
Example case 2: The binary representation of $10$ is "1010". We can use $A = 13$ ("1101") and $B = 7$ ("0111"). This gives us the maximum product $91$. | for _ in range(int(input())):
x = int(input())
a = "1"
b = "0"
x = bin(x)[2:]
for i in x[1:]:
if i == "0":
a += "1"
b += "1"
else:
b += "1"
a += "0"
print(int(a, 2) * int(b, 2)) | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR STRING ASSIGN VAR STRING ASSIGN VAR FUNC_CALL VAR VAR NUMBER FOR VAR VAR NUMBER IF VAR STRING VAR STRING VAR STRING VAR STRING VAR STRING EXPR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR NUMBER |
Read problem statements in [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
You are given an integer $C$. Let $d$ be the smallest integer such that $2^{d}$ is strictly greater than $C$.
Consider all pairs of non-negative integers $(A,B)$ such that $A,B < 2^{d}$ and $A \oplus B = C$ ($\oplus$ denotes the bitwise XOR operation). Find the maximum value of $A \cdot B$ over all these pairs.
------ Input ------
The first line of the input contains a single integer $T$ denoting the number of test cases. The description of $T$ test cases follows.
The first and only line of each test case contains a single integer $C$.
------ Output ------
For each test case, print a single line containing one integer β the maximum possible product $A \cdot B$.
------ Constraints ------
$1 β€ T β€ 10^{5}$
$1 β€ C β€ 10^{9}$
------ Subtasks ------
Subtask #1 (30 points): $1 β€ C β€ 10^{3}$
Subtask #2 (70 points): original constraints
----- Sample Input 1 ------
2
13
10
----- Sample Output 1 ------
70
91
----- explanation 1 ------
Example case 1: The binary representation of $13$ is "1101". We can use $A = 10$ ("1010" in binary) and $B = 7$ ("0111" in binary). This gives us the product $70$. No other valid pair $(A, B)$ can give us a larger product.
Example case 2: The binary representation of $10$ is "1010". We can use $A = 13$ ("1101") and $B = 7$ ("0111"). This gives us the maximum product $91$. | for _ in range(int(input().strip())):
C = int(input().strip())
bin_c = bin(C)[2:]
out_bin_A = ["1"] + ["0"] * (len(bin_c) - 1)
out_bin_B = ["0"] * len(bin_c)
for idx, bit in enumerate(bin_c[1:], 1):
if bit == "0":
out_bin_A[idx] = "1"
out_bin_B[idx] = "1"
elif bit == "1":
out_bin_B[idx] = "1"
print(int("".join(out_bin_A), 2) * int("".join(out_bin_B), 2)) | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP LIST STRING BIN_OP LIST STRING BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP LIST STRING FUNC_CALL VAR VAR FOR VAR VAR FUNC_CALL VAR VAR NUMBER NUMBER IF VAR STRING ASSIGN VAR VAR STRING ASSIGN VAR VAR STRING IF VAR STRING ASSIGN VAR VAR STRING EXPR FUNC_CALL VAR BIN_OP FUNC_CALL VAR FUNC_CALL STRING VAR NUMBER FUNC_CALL VAR FUNC_CALL STRING VAR NUMBER |
Read problem statements in [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
You are given an integer $C$. Let $d$ be the smallest integer such that $2^{d}$ is strictly greater than $C$.
Consider all pairs of non-negative integers $(A,B)$ such that $A,B < 2^{d}$ and $A \oplus B = C$ ($\oplus$ denotes the bitwise XOR operation). Find the maximum value of $A \cdot B$ over all these pairs.
------ Input ------
The first line of the input contains a single integer $T$ denoting the number of test cases. The description of $T$ test cases follows.
The first and only line of each test case contains a single integer $C$.
------ Output ------
For each test case, print a single line containing one integer β the maximum possible product $A \cdot B$.
------ Constraints ------
$1 β€ T β€ 10^{5}$
$1 β€ C β€ 10^{9}$
------ Subtasks ------
Subtask #1 (30 points): $1 β€ C β€ 10^{3}$
Subtask #2 (70 points): original constraints
----- Sample Input 1 ------
2
13
10
----- Sample Output 1 ------
70
91
----- explanation 1 ------
Example case 1: The binary representation of $13$ is "1101". We can use $A = 10$ ("1010" in binary) and $B = 7$ ("0111" in binary). This gives us the product $70$. No other valid pair $(A, B)$ can give us a larger product.
Example case 2: The binary representation of $10$ is "1010". We can use $A = 13$ ("1101") and $B = 7$ ("0111"). This gives us the maximum product $91$. | T = int(input())
for i in range(T):
n = int(input())
s = bin(n)[2:]
p = 0
sec = 0
x = 0
for z in range(len(s) - 1, -1, -1):
if s[z] == "0":
p = p + 2**x
sec = sec + 2**x
x += 1
else:
if z == 0:
p = p + 2**x
else:
sec = sec + 2**x
x += 1
print(p * sec) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER NUMBER IF VAR VAR STRING ASSIGN VAR BIN_OP VAR BIN_OP NUMBER VAR ASSIGN VAR BIN_OP VAR BIN_OP NUMBER VAR VAR NUMBER IF VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP NUMBER VAR ASSIGN VAR BIN_OP VAR BIN_OP NUMBER VAR VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR VAR |
Read problem statements in [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
You are given an integer $C$. Let $d$ be the smallest integer such that $2^{d}$ is strictly greater than $C$.
Consider all pairs of non-negative integers $(A,B)$ such that $A,B < 2^{d}$ and $A \oplus B = C$ ($\oplus$ denotes the bitwise XOR operation). Find the maximum value of $A \cdot B$ over all these pairs.
------ Input ------
The first line of the input contains a single integer $T$ denoting the number of test cases. The description of $T$ test cases follows.
The first and only line of each test case contains a single integer $C$.
------ Output ------
For each test case, print a single line containing one integer β the maximum possible product $A \cdot B$.
------ Constraints ------
$1 β€ T β€ 10^{5}$
$1 β€ C β€ 10^{9}$
------ Subtasks ------
Subtask #1 (30 points): $1 β€ C β€ 10^{3}$
Subtask #2 (70 points): original constraints
----- Sample Input 1 ------
2
13
10
----- Sample Output 1 ------
70
91
----- explanation 1 ------
Example case 1: The binary representation of $13$ is "1101". We can use $A = 10$ ("1010" in binary) and $B = 7$ ("0111" in binary). This gives us the product $70$. No other valid pair $(A, B)$ can give us a larger product.
Example case 2: The binary representation of $10$ is "1010". We can use $A = 13$ ("1101") and $B = 7$ ("0111"). This gives us the maximum product $91$. | for _ in range(int(input())):
c = int(input())
d = len(bin(c)) - 2
x = 2 ** (d - 1) - 1
print(x * (c ^ x)) | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP NUMBER BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR BIN_OP VAR BIN_OP VAR VAR |
Read problem statements in [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
You are given an integer $C$. Let $d$ be the smallest integer such that $2^{d}$ is strictly greater than $C$.
Consider all pairs of non-negative integers $(A,B)$ such that $A,B < 2^{d}$ and $A \oplus B = C$ ($\oplus$ denotes the bitwise XOR operation). Find the maximum value of $A \cdot B$ over all these pairs.
------ Input ------
The first line of the input contains a single integer $T$ denoting the number of test cases. The description of $T$ test cases follows.
The first and only line of each test case contains a single integer $C$.
------ Output ------
For each test case, print a single line containing one integer β the maximum possible product $A \cdot B$.
------ Constraints ------
$1 β€ T β€ 10^{5}$
$1 β€ C β€ 10^{9}$
------ Subtasks ------
Subtask #1 (30 points): $1 β€ C β€ 10^{3}$
Subtask #2 (70 points): original constraints
----- Sample Input 1 ------
2
13
10
----- Sample Output 1 ------
70
91
----- explanation 1 ------
Example case 1: The binary representation of $13$ is "1101". We can use $A = 10$ ("1010" in binary) and $B = 7$ ("0111" in binary). This gives us the product $70$. No other valid pair $(A, B)$ can give us a larger product.
Example case 2: The binary representation of $10$ is "1010". We can use $A = 13$ ("1101") and $B = 7$ ("0111"). This gives us the maximum product $91$. | def solve():
num = int(input())
tmp = bin(num)[2:]
a = ""
b = ""
flag = True
for i in tmp:
if i == "1":
if flag:
a += "1"
b += "0"
flag = False
else:
a += "0"
b += "1"
else:
a += "1"
b += "1"
print(int(a, 2) * int(b, 2))
t = int(input())
while t != 0:
t -= 1
solve() | FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR STRING ASSIGN VAR STRING ASSIGN VAR NUMBER FOR VAR VAR IF VAR STRING IF VAR VAR STRING VAR STRING ASSIGN VAR NUMBER VAR STRING VAR STRING VAR STRING VAR STRING EXPR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR |
Read problem statements in [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
You are given an integer $C$. Let $d$ be the smallest integer such that $2^{d}$ is strictly greater than $C$.
Consider all pairs of non-negative integers $(A,B)$ such that $A,B < 2^{d}$ and $A \oplus B = C$ ($\oplus$ denotes the bitwise XOR operation). Find the maximum value of $A \cdot B$ over all these pairs.
------ Input ------
The first line of the input contains a single integer $T$ denoting the number of test cases. The description of $T$ test cases follows.
The first and only line of each test case contains a single integer $C$.
------ Output ------
For each test case, print a single line containing one integer β the maximum possible product $A \cdot B$.
------ Constraints ------
$1 β€ T β€ 10^{5}$
$1 β€ C β€ 10^{9}$
------ Subtasks ------
Subtask #1 (30 points): $1 β€ C β€ 10^{3}$
Subtask #2 (70 points): original constraints
----- Sample Input 1 ------
2
13
10
----- Sample Output 1 ------
70
91
----- explanation 1 ------
Example case 1: The binary representation of $13$ is "1101". We can use $A = 10$ ("1010" in binary) and $B = 7$ ("0111" in binary). This gives us the product $70$. No other valid pair $(A, B)$ can give us a larger product.
Example case 2: The binary representation of $10$ is "1010". We can use $A = 13$ ("1101") and $B = 7$ ("0111"). This gives us the maximum product $91$. | t = int(input())
while t > 0:
c = 0
n = int(input())
m = n
while m != 0:
m = m >> 1
c += 1
a_ = 0
b_ = 0
flag = False
for i in range(c - 1, -1, -1):
mask = 1 << i
val = n & mask
if val == 0:
a_ = a_ | 1 << i
b_ = b_ | 1 << i
elif flag == False:
a_ = a_ | 1 << i
flag = True
else:
b_ = b_ | 1 << i
print(a_ * b_)
t -= 1 | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR WHILE VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER ASSIGN VAR BIN_OP NUMBER VAR ASSIGN VAR BIN_OP VAR VAR IF VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP NUMBER VAR ASSIGN VAR BIN_OP VAR BIN_OP NUMBER VAR IF VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP NUMBER VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP NUMBER VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR VAR NUMBER |
Read problem statements in [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
You are given an integer $C$. Let $d$ be the smallest integer such that $2^{d}$ is strictly greater than $C$.
Consider all pairs of non-negative integers $(A,B)$ such that $A,B < 2^{d}$ and $A \oplus B = C$ ($\oplus$ denotes the bitwise XOR operation). Find the maximum value of $A \cdot B$ over all these pairs.
------ Input ------
The first line of the input contains a single integer $T$ denoting the number of test cases. The description of $T$ test cases follows.
The first and only line of each test case contains a single integer $C$.
------ Output ------
For each test case, print a single line containing one integer β the maximum possible product $A \cdot B$.
------ Constraints ------
$1 β€ T β€ 10^{5}$
$1 β€ C β€ 10^{9}$
------ Subtasks ------
Subtask #1 (30 points): $1 β€ C β€ 10^{3}$
Subtask #2 (70 points): original constraints
----- Sample Input 1 ------
2
13
10
----- Sample Output 1 ------
70
91
----- explanation 1 ------
Example case 1: The binary representation of $13$ is "1101". We can use $A = 10$ ("1010" in binary) and $B = 7$ ("0111" in binary). This gives us the product $70$. No other valid pair $(A, B)$ can give us a larger product.
Example case 2: The binary representation of $10$ is "1010". We can use $A = 13$ ("1101") and $B = 7$ ("0111"). This gives us the maximum product $91$. | ass = int(input())
for i in range(ass):
bn = int(input())
bn = bin(bn)[2:]
r = len(bn)
bn = bn[1:]
a = ["1"] + [("0" if i == "1" else "1") for i in bn]
b = ["0"] + ["1"] * (r - 1)
a = "".join(a)
b = "".join(b)
c = int(a, 2) * int(b, 2)
print(c) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER ASSIGN VAR BIN_OP LIST STRING VAR STRING STRING STRING VAR VAR ASSIGN VAR BIN_OP LIST STRING BIN_OP LIST STRING BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL STRING VAR ASSIGN VAR FUNC_CALL STRING VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR VAR |
Read problem statements in [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
You are given an integer $C$. Let $d$ be the smallest integer such that $2^{d}$ is strictly greater than $C$.
Consider all pairs of non-negative integers $(A,B)$ such that $A,B < 2^{d}$ and $A \oplus B = C$ ($\oplus$ denotes the bitwise XOR operation). Find the maximum value of $A \cdot B$ over all these pairs.
------ Input ------
The first line of the input contains a single integer $T$ denoting the number of test cases. The description of $T$ test cases follows.
The first and only line of each test case contains a single integer $C$.
------ Output ------
For each test case, print a single line containing one integer β the maximum possible product $A \cdot B$.
------ Constraints ------
$1 β€ T β€ 10^{5}$
$1 β€ C β€ 10^{9}$
------ Subtasks ------
Subtask #1 (30 points): $1 β€ C β€ 10^{3}$
Subtask #2 (70 points): original constraints
----- Sample Input 1 ------
2
13
10
----- Sample Output 1 ------
70
91
----- explanation 1 ------
Example case 1: The binary representation of $13$ is "1101". We can use $A = 10$ ("1010" in binary) and $B = 7$ ("0111" in binary). This gives us the product $70$. No other valid pair $(A, B)$ can give us a larger product.
Example case 2: The binary representation of $10$ is "1010". We can use $A = 13$ ("1101") and $B = 7$ ("0111"). This gives us the maximum product $91$. | T = int(input())
for _ in range(T):
C = int(input())
A, B = "1", "0"
for i in bin(C)[3:]:
if i == "0":
A += "1"
B += "1"
else:
B += "1"
A += "0"
print(int(A, 2) * int(B, 2)) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR STRING STRING FOR VAR FUNC_CALL VAR VAR NUMBER IF VAR STRING VAR STRING VAR STRING VAR STRING VAR STRING EXPR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR NUMBER |
Read problem statements in [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
You are given an integer $C$. Let $d$ be the smallest integer such that $2^{d}$ is strictly greater than $C$.
Consider all pairs of non-negative integers $(A,B)$ such that $A,B < 2^{d}$ and $A \oplus B = C$ ($\oplus$ denotes the bitwise XOR operation). Find the maximum value of $A \cdot B$ over all these pairs.
------ Input ------
The first line of the input contains a single integer $T$ denoting the number of test cases. The description of $T$ test cases follows.
The first and only line of each test case contains a single integer $C$.
------ Output ------
For each test case, print a single line containing one integer β the maximum possible product $A \cdot B$.
------ Constraints ------
$1 β€ T β€ 10^{5}$
$1 β€ C β€ 10^{9}$
------ Subtasks ------
Subtask #1 (30 points): $1 β€ C β€ 10^{3}$
Subtask #2 (70 points): original constraints
----- Sample Input 1 ------
2
13
10
----- Sample Output 1 ------
70
91
----- explanation 1 ------
Example case 1: The binary representation of $13$ is "1101". We can use $A = 10$ ("1010" in binary) and $B = 7$ ("0111" in binary). This gives us the product $70$. No other valid pair $(A, B)$ can give us a larger product.
Example case 2: The binary representation of $10$ is "1010". We can use $A = 13$ ("1101") and $B = 7$ ("0111"). This gives us the maximum product $91$. | for _ in range(int(input())):
c = int(input())
id = 0
a = 0
b = 0
flag = 1
for i in range(31, -1, -1):
if c & 1 << i:
id = i
break
for i in range(id, -1, -1):
if c & 1 << i:
if flag == 1:
a = a | 1 << i
flag = 0
else:
b = b | 1 << i
else:
a = a | 1 << i
b = b | 1 << i
print(a * b) | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER NUMBER IF BIN_OP VAR BIN_OP NUMBER VAR ASSIGN VAR VAR FOR VAR FUNC_CALL VAR VAR NUMBER NUMBER IF BIN_OP VAR BIN_OP NUMBER VAR IF VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP NUMBER VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP NUMBER VAR ASSIGN VAR BIN_OP VAR BIN_OP NUMBER VAR ASSIGN VAR BIN_OP VAR BIN_OP NUMBER VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR |
Read problem statements in [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
You are given an integer $C$. Let $d$ be the smallest integer such that $2^{d}$ is strictly greater than $C$.
Consider all pairs of non-negative integers $(A,B)$ such that $A,B < 2^{d}$ and $A \oplus B = C$ ($\oplus$ denotes the bitwise XOR operation). Find the maximum value of $A \cdot B$ over all these pairs.
------ Input ------
The first line of the input contains a single integer $T$ denoting the number of test cases. The description of $T$ test cases follows.
The first and only line of each test case contains a single integer $C$.
------ Output ------
For each test case, print a single line containing one integer β the maximum possible product $A \cdot B$.
------ Constraints ------
$1 β€ T β€ 10^{5}$
$1 β€ C β€ 10^{9}$
------ Subtasks ------
Subtask #1 (30 points): $1 β€ C β€ 10^{3}$
Subtask #2 (70 points): original constraints
----- Sample Input 1 ------
2
13
10
----- Sample Output 1 ------
70
91
----- explanation 1 ------
Example case 1: The binary representation of $13$ is "1101". We can use $A = 10$ ("1010" in binary) and $B = 7$ ("0111" in binary). This gives us the product $70$. No other valid pair $(A, B)$ can give us a larger product.
Example case 2: The binary representation of $10$ is "1010". We can use $A = 13$ ("1101") and $B = 7$ ("0111"). This gives us the maximum product $91$. | t = int(input())
for _ in range(t):
n = int(input())
bi_num = bin(n)[2:]
a, b = 1, 0
for i in bi_num[1:]:
if i == "1":
a, b = 2 * a, 2 * b + 1
else:
a, b = 2 * a + 1, 2 * b + 1
print(a * b) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR NUMBER NUMBER FOR VAR VAR NUMBER IF VAR STRING ASSIGN VAR VAR BIN_OP NUMBER VAR BIN_OP BIN_OP NUMBER VAR NUMBER ASSIGN VAR VAR BIN_OP BIN_OP NUMBER VAR NUMBER BIN_OP BIN_OP NUMBER VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR VAR |
Read problem statements in [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
You are given an integer $C$. Let $d$ be the smallest integer such that $2^{d}$ is strictly greater than $C$.
Consider all pairs of non-negative integers $(A,B)$ such that $A,B < 2^{d}$ and $A \oplus B = C$ ($\oplus$ denotes the bitwise XOR operation). Find the maximum value of $A \cdot B$ over all these pairs.
------ Input ------
The first line of the input contains a single integer $T$ denoting the number of test cases. The description of $T$ test cases follows.
The first and only line of each test case contains a single integer $C$.
------ Output ------
For each test case, print a single line containing one integer β the maximum possible product $A \cdot B$.
------ Constraints ------
$1 β€ T β€ 10^{5}$
$1 β€ C β€ 10^{9}$
------ Subtasks ------
Subtask #1 (30 points): $1 β€ C β€ 10^{3}$
Subtask #2 (70 points): original constraints
----- Sample Input 1 ------
2
13
10
----- Sample Output 1 ------
70
91
----- explanation 1 ------
Example case 1: The binary representation of $13$ is "1101". We can use $A = 10$ ("1010" in binary) and $B = 7$ ("0111" in binary). This gives us the product $70$. No other valid pair $(A, B)$ can give us a larger product.
Example case 2: The binary representation of $10$ is "1010". We can use $A = 13$ ("1101") and $B = 7$ ("0111"). This gives us the maximum product $91$. | for t in range(int(input())):
c = int(input())
a = 0
b = 0
msbc = 0
for i in range(31, -1, -1):
if 1 << i & c:
msbc = i
break
flag = True
for i in range(msbc, -1, -1):
if 1 << i & c:
if flag:
a |= 1 << i
flag = False
else:
b |= 1 << i
else:
a |= 1 << i
b |= 1 << i
print(a * b) | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER NUMBER IF BIN_OP BIN_OP NUMBER VAR VAR ASSIGN VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR NUMBER NUMBER IF BIN_OP BIN_OP NUMBER VAR VAR IF VAR VAR BIN_OP NUMBER VAR ASSIGN VAR NUMBER VAR BIN_OP NUMBER VAR VAR BIN_OP NUMBER VAR VAR BIN_OP NUMBER VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR |
Read problem statements in [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
You are given an integer $C$. Let $d$ be the smallest integer such that $2^{d}$ is strictly greater than $C$.
Consider all pairs of non-negative integers $(A,B)$ such that $A,B < 2^{d}$ and $A \oplus B = C$ ($\oplus$ denotes the bitwise XOR operation). Find the maximum value of $A \cdot B$ over all these pairs.
------ Input ------
The first line of the input contains a single integer $T$ denoting the number of test cases. The description of $T$ test cases follows.
The first and only line of each test case contains a single integer $C$.
------ Output ------
For each test case, print a single line containing one integer β the maximum possible product $A \cdot B$.
------ Constraints ------
$1 β€ T β€ 10^{5}$
$1 β€ C β€ 10^{9}$
------ Subtasks ------
Subtask #1 (30 points): $1 β€ C β€ 10^{3}$
Subtask #2 (70 points): original constraints
----- Sample Input 1 ------
2
13
10
----- Sample Output 1 ------
70
91
----- explanation 1 ------
Example case 1: The binary representation of $13$ is "1101". We can use $A = 10$ ("1010" in binary) and $B = 7$ ("0111" in binary). This gives us the product $70$. No other valid pair $(A, B)$ can give us a larger product.
Example case 2: The binary representation of $10$ is "1010". We can use $A = 13$ ("1101") and $B = 7$ ("0111"). This gives us the maximum product $91$. | for _ in range(int(input())):
n = int(input())
c = bin(n).replace("0b", "")
a = ""
b = ""
c = list(c)
f = 1
for i in range(len(c)):
if c[i] == "1" and f == 1:
a += "1"
b += "0"
f = 0
elif c[i] == "1" and f == 0:
b += "1"
a += "0"
elif c[i] == "0":
a += "1"
b += "1"
print(int(a, 2) * int(b, 2)) | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR VAR STRING STRING ASSIGN VAR STRING ASSIGN VAR STRING ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR NUMBER VAR STRING VAR STRING ASSIGN VAR NUMBER IF VAR VAR STRING VAR NUMBER VAR STRING VAR STRING IF VAR VAR STRING VAR STRING VAR STRING EXPR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR NUMBER |
Read problem statements in [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
You are given an integer $C$. Let $d$ be the smallest integer such that $2^{d}$ is strictly greater than $C$.
Consider all pairs of non-negative integers $(A,B)$ such that $A,B < 2^{d}$ and $A \oplus B = C$ ($\oplus$ denotes the bitwise XOR operation). Find the maximum value of $A \cdot B$ over all these pairs.
------ Input ------
The first line of the input contains a single integer $T$ denoting the number of test cases. The description of $T$ test cases follows.
The first and only line of each test case contains a single integer $C$.
------ Output ------
For each test case, print a single line containing one integer β the maximum possible product $A \cdot B$.
------ Constraints ------
$1 β€ T β€ 10^{5}$
$1 β€ C β€ 10^{9}$
------ Subtasks ------
Subtask #1 (30 points): $1 β€ C β€ 10^{3}$
Subtask #2 (70 points): original constraints
----- Sample Input 1 ------
2
13
10
----- Sample Output 1 ------
70
91
----- explanation 1 ------
Example case 1: The binary representation of $13$ is "1101". We can use $A = 10$ ("1010" in binary) and $B = 7$ ("0111" in binary). This gives us the product $70$. No other valid pair $(A, B)$ can give us a larger product.
Example case 2: The binary representation of $10$ is "1010". We can use $A = 13$ ("1101") and $B = 7$ ("0111"). This gives us the maximum product $91$. | for _ in range(int(input())):
c = int(input())
binary = bin(c).replace("0b", "")
a = 0
b = 0
for i in range(len(binary)):
if binary[i] == "0":
a += 2 ** (len(binary) - i - 1)
b += 2 ** (len(binary) - i - 1)
elif i == 0:
a += 2 ** (len(binary) - 1)
else:
b += 2 ** (len(binary) - 1 - i)
print(a * b) | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR VAR STRING STRING ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR BIN_OP NUMBER BIN_OP BIN_OP FUNC_CALL VAR VAR VAR NUMBER VAR BIN_OP NUMBER BIN_OP BIN_OP FUNC_CALL VAR VAR VAR NUMBER IF VAR NUMBER VAR BIN_OP NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER VAR BIN_OP NUMBER BIN_OP BIN_OP FUNC_CALL VAR VAR NUMBER VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR |
Read problem statements in [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
You are given an integer $C$. Let $d$ be the smallest integer such that $2^{d}$ is strictly greater than $C$.
Consider all pairs of non-negative integers $(A,B)$ such that $A,B < 2^{d}$ and $A \oplus B = C$ ($\oplus$ denotes the bitwise XOR operation). Find the maximum value of $A \cdot B$ over all these pairs.
------ Input ------
The first line of the input contains a single integer $T$ denoting the number of test cases. The description of $T$ test cases follows.
The first and only line of each test case contains a single integer $C$.
------ Output ------
For each test case, print a single line containing one integer β the maximum possible product $A \cdot B$.
------ Constraints ------
$1 β€ T β€ 10^{5}$
$1 β€ C β€ 10^{9}$
------ Subtasks ------
Subtask #1 (30 points): $1 β€ C β€ 10^{3}$
Subtask #2 (70 points): original constraints
----- Sample Input 1 ------
2
13
10
----- Sample Output 1 ------
70
91
----- explanation 1 ------
Example case 1: The binary representation of $13$ is "1101". We can use $A = 10$ ("1010" in binary) and $B = 7$ ("0111" in binary). This gives us the product $70$. No other valid pair $(A, B)$ can give us a larger product.
Example case 2: The binary representation of $10$ is "1010". We can use $A = 13$ ("1101") and $B = 7$ ("0111"). This gives us the maximum product $91$. | for _ in range(int(input())):
s = int(input())
s = bin(s).replace("0b", "")
a = ""
b = ""
count = 0
for i in s:
if i == "0":
a += "1"
b += "1"
elif i == "1":
if count == 0:
a += "1"
b += "0"
count += 1
else:
b += "1"
a += "0"
print(int(a, 2) * int(b, 2)) | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR VAR STRING STRING ASSIGN VAR STRING ASSIGN VAR STRING ASSIGN VAR NUMBER FOR VAR VAR IF VAR STRING VAR STRING VAR STRING IF VAR STRING IF VAR NUMBER VAR STRING VAR STRING VAR NUMBER VAR STRING VAR STRING EXPR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR NUMBER |
Read problem statements in [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
You are given an integer $C$. Let $d$ be the smallest integer such that $2^{d}$ is strictly greater than $C$.
Consider all pairs of non-negative integers $(A,B)$ such that $A,B < 2^{d}$ and $A \oplus B = C$ ($\oplus$ denotes the bitwise XOR operation). Find the maximum value of $A \cdot B$ over all these pairs.
------ Input ------
The first line of the input contains a single integer $T$ denoting the number of test cases. The description of $T$ test cases follows.
The first and only line of each test case contains a single integer $C$.
------ Output ------
For each test case, print a single line containing one integer β the maximum possible product $A \cdot B$.
------ Constraints ------
$1 β€ T β€ 10^{5}$
$1 β€ C β€ 10^{9}$
------ Subtasks ------
Subtask #1 (30 points): $1 β€ C β€ 10^{3}$
Subtask #2 (70 points): original constraints
----- Sample Input 1 ------
2
13
10
----- Sample Output 1 ------
70
91
----- explanation 1 ------
Example case 1: The binary representation of $13$ is "1101". We can use $A = 10$ ("1010" in binary) and $B = 7$ ("0111" in binary). This gives us the product $70$. No other valid pair $(A, B)$ can give us a larger product.
Example case 2: The binary representation of $10$ is "1010". We can use $A = 13$ ("1101") and $B = 7$ ("0111"). This gives us the maximum product $91$. | t = int(input())
for _ in range(t):
n = int(input())
b = "{0:b}".format(n)
b = list(b)
x = ""
y = ""
flag = False
for i in range(len(b)):
if not flag and b[i] == "1":
x += "1"
y += "0"
flag = True
elif b[i] == "1":
x += "0"
y += "1"
else:
x += "1"
y += "1"
res_1 = 0
res_2 = 0
for i in range(len(x)):
res_1 += int(x[i]) * 2 ** (len(x) - (i + 1))
res_2 += int(y[i]) * 2 ** (len(y) - (i + 1))
print(res_1 * res_2) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL STRING VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR STRING ASSIGN VAR STRING ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR VAR STRING VAR STRING VAR STRING ASSIGN VAR NUMBER IF VAR VAR STRING VAR STRING VAR STRING VAR STRING VAR STRING ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR BIN_OP FUNC_CALL VAR VAR VAR BIN_OP NUMBER BIN_OP FUNC_CALL VAR VAR BIN_OP VAR NUMBER VAR BIN_OP FUNC_CALL VAR VAR VAR BIN_OP NUMBER BIN_OP FUNC_CALL VAR VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR VAR |
Read problem statements in [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
You are given an integer $C$. Let $d$ be the smallest integer such that $2^{d}$ is strictly greater than $C$.
Consider all pairs of non-negative integers $(A,B)$ such that $A,B < 2^{d}$ and $A \oplus B = C$ ($\oplus$ denotes the bitwise XOR operation). Find the maximum value of $A \cdot B$ over all these pairs.
------ Input ------
The first line of the input contains a single integer $T$ denoting the number of test cases. The description of $T$ test cases follows.
The first and only line of each test case contains a single integer $C$.
------ Output ------
For each test case, print a single line containing one integer β the maximum possible product $A \cdot B$.
------ Constraints ------
$1 β€ T β€ 10^{5}$
$1 β€ C β€ 10^{9}$
------ Subtasks ------
Subtask #1 (30 points): $1 β€ C β€ 10^{3}$
Subtask #2 (70 points): original constraints
----- Sample Input 1 ------
2
13
10
----- Sample Output 1 ------
70
91
----- explanation 1 ------
Example case 1: The binary representation of $13$ is "1101". We can use $A = 10$ ("1010" in binary) and $B = 7$ ("0111" in binary). This gives us the product $70$. No other valid pair $(A, B)$ can give us a larger product.
Example case 2: The binary representation of $10$ is "1010". We can use $A = 13$ ("1101") and $B = 7$ ("0111"). This gives us the maximum product $91$. | t = int(input())
for i in range(t):
n = int(input())
a = ""
while n >= 1:
a = str(n % 2) + a
n = n // 2
c = 1
p = ""
q = ""
for i in a:
if i == "1":
if c == 1:
p = p + "1"
q = q + "0"
c = c + 1
else:
q = q + "1"
p = p + "0"
else:
p = p + "1"
q = q + "1"
i = 0
x = 0
while True:
if p == "":
break
else:
x = x + int(p[-1]) * 2**i
p = p[0:-1]
i = i + 1
j = 0
y = 0
while True:
if q == "":
break
else:
y = y + int(q[-1]) * 2**j
q = q[0:-1]
j = j + 1
print(x * y) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR STRING WHILE VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR BIN_OP VAR NUMBER VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR STRING ASSIGN VAR STRING FOR VAR VAR IF VAR STRING IF VAR NUMBER ASSIGN VAR BIN_OP VAR STRING ASSIGN VAR BIN_OP VAR STRING ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR STRING ASSIGN VAR BIN_OP VAR STRING ASSIGN VAR BIN_OP VAR STRING ASSIGN VAR BIN_OP VAR STRING ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE NUMBER IF VAR STRING ASSIGN VAR BIN_OP VAR BIN_OP FUNC_CALL VAR VAR NUMBER BIN_OP NUMBER VAR ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE NUMBER IF VAR STRING ASSIGN VAR BIN_OP VAR BIN_OP FUNC_CALL VAR VAR NUMBER BIN_OP NUMBER VAR ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR VAR |
Read problem statements in [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
You are given an integer $C$. Let $d$ be the smallest integer such that $2^{d}$ is strictly greater than $C$.
Consider all pairs of non-negative integers $(A,B)$ such that $A,B < 2^{d}$ and $A \oplus B = C$ ($\oplus$ denotes the bitwise XOR operation). Find the maximum value of $A \cdot B$ over all these pairs.
------ Input ------
The first line of the input contains a single integer $T$ denoting the number of test cases. The description of $T$ test cases follows.
The first and only line of each test case contains a single integer $C$.
------ Output ------
For each test case, print a single line containing one integer β the maximum possible product $A \cdot B$.
------ Constraints ------
$1 β€ T β€ 10^{5}$
$1 β€ C β€ 10^{9}$
------ Subtasks ------
Subtask #1 (30 points): $1 β€ C β€ 10^{3}$
Subtask #2 (70 points): original constraints
----- Sample Input 1 ------
2
13
10
----- Sample Output 1 ------
70
91
----- explanation 1 ------
Example case 1: The binary representation of $13$ is "1101". We can use $A = 10$ ("1010" in binary) and $B = 7$ ("0111" in binary). This gives us the product $70$. No other valid pair $(A, B)$ can give us a larger product.
Example case 2: The binary representation of $10$ is "1010". We can use $A = 13$ ("1101") and $B = 7$ ("0111"). This gives us the maximum product $91$. | def decimalToBinary(n):
return bin(n).replace("0b", "")
t = int(input())
for z in range(t):
n = int(input())
l = list(decimalToBinary(n))
s = ""
s1 = ""
for i in range(len(l) - 1, 0, -1):
if l[i] == "1":
s = s + "1"
s1 = s1 + "0"
else:
s += "1"
s1 = s1 + "1"
if l[0] == "1":
s += "0"
s1 += "1"
else:
s += "0"
s1 += "0"
print(int(s[::-1], 2) * int(s1[::-1], 2)) | FUNC_DEF RETURN FUNC_CALL FUNC_CALL VAR VAR STRING STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR STRING ASSIGN VAR STRING FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER NUMBER IF VAR VAR STRING ASSIGN VAR BIN_OP VAR STRING ASSIGN VAR BIN_OP VAR STRING VAR STRING ASSIGN VAR BIN_OP VAR STRING IF VAR NUMBER STRING VAR STRING VAR STRING VAR STRING VAR STRING EXPR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER FUNC_CALL VAR VAR NUMBER NUMBER |
Read problem statements in [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
You are given an integer $C$. Let $d$ be the smallest integer such that $2^{d}$ is strictly greater than $C$.
Consider all pairs of non-negative integers $(A,B)$ such that $A,B < 2^{d}$ and $A \oplus B = C$ ($\oplus$ denotes the bitwise XOR operation). Find the maximum value of $A \cdot B$ over all these pairs.
------ Input ------
The first line of the input contains a single integer $T$ denoting the number of test cases. The description of $T$ test cases follows.
The first and only line of each test case contains a single integer $C$.
------ Output ------
For each test case, print a single line containing one integer β the maximum possible product $A \cdot B$.
------ Constraints ------
$1 β€ T β€ 10^{5}$
$1 β€ C β€ 10^{9}$
------ Subtasks ------
Subtask #1 (30 points): $1 β€ C β€ 10^{3}$
Subtask #2 (70 points): original constraints
----- Sample Input 1 ------
2
13
10
----- Sample Output 1 ------
70
91
----- explanation 1 ------
Example case 1: The binary representation of $13$ is "1101". We can use $A = 10$ ("1010" in binary) and $B = 7$ ("0111" in binary). This gives us the product $70$. No other valid pair $(A, B)$ can give us a larger product.
Example case 2: The binary representation of $10$ is "1010". We can use $A = 13$ ("1101") and $B = 7$ ("0111"). This gives us the maximum product $91$. | def Power(n):
ans, x = 1, 2
while n != 0:
if n & 1 == 1:
ans = ans * x
n = n >> 1
x = x * x
return ans
for _ in range(int(input())):
c = int(input())
s1, s2, d = 0, 0, 0
for i in range(31, -1, -1):
if c >> i & 1 == 1 and s1 == 0:
s1 = s1 + Power(i)
d = i
elif c >> i & 1 == 1 and s1 != 0:
s2 = s2 + Power(i)
if c >> i & 1 == 0 and s1 != 0:
s1 = s1 + Power(i)
s2 = s2 + Power(i)
if s1 >= Power(d + 1):
s1 = s1 - 1
if s2 >= Power(d + 1):
s2 = s2 - 1
print(s1 * s2) | FUNC_DEF ASSIGN VAR VAR NUMBER NUMBER WHILE VAR NUMBER IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR VAR RETURN VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER NUMBER IF BIN_OP BIN_OP VAR VAR NUMBER NUMBER VAR NUMBER ASSIGN VAR BIN_OP VAR FUNC_CALL VAR VAR ASSIGN VAR VAR IF BIN_OP BIN_OP VAR VAR NUMBER NUMBER VAR NUMBER ASSIGN VAR BIN_OP VAR FUNC_CALL VAR VAR IF BIN_OP BIN_OP VAR VAR NUMBER NUMBER VAR NUMBER ASSIGN VAR BIN_OP VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR FUNC_CALL VAR VAR IF VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR VAR |
Read problem statements in [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
You are given an integer $C$. Let $d$ be the smallest integer such that $2^{d}$ is strictly greater than $C$.
Consider all pairs of non-negative integers $(A,B)$ such that $A,B < 2^{d}$ and $A \oplus B = C$ ($\oplus$ denotes the bitwise XOR operation). Find the maximum value of $A \cdot B$ over all these pairs.
------ Input ------
The first line of the input contains a single integer $T$ denoting the number of test cases. The description of $T$ test cases follows.
The first and only line of each test case contains a single integer $C$.
------ Output ------
For each test case, print a single line containing one integer β the maximum possible product $A \cdot B$.
------ Constraints ------
$1 β€ T β€ 10^{5}$
$1 β€ C β€ 10^{9}$
------ Subtasks ------
Subtask #1 (30 points): $1 β€ C β€ 10^{3}$
Subtask #2 (70 points): original constraints
----- Sample Input 1 ------
2
13
10
----- Sample Output 1 ------
70
91
----- explanation 1 ------
Example case 1: The binary representation of $13$ is "1101". We can use $A = 10$ ("1010" in binary) and $B = 7$ ("0111" in binary). This gives us the product $70$. No other valid pair $(A, B)$ can give us a larger product.
Example case 2: The binary representation of $10$ is "1010". We can use $A = 13$ ("1101") and $B = 7$ ("0111"). This gives us the maximum product $91$. | def toBin(n):
return bin(n).replace("0b", " ")
def solve(n):
s = str(toBin(n))
a = []
b = []
for i in range(len(s)):
if s[i] == "1":
if a.count("1") == 0:
a.append("1")
b.append("0")
else:
b.append("1")
a.append("0")
elif s[i] == "0":
a.append("1")
b.append("1")
a = "".join(a)
b = "".join(b)
a = int(a, 2)
b = int(b, 2)
return a * b
for _ in range(int(input())):
c = int(input())
print(solve(c)) | FUNC_DEF RETURN FUNC_CALL FUNC_CALL VAR VAR STRING STRING FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR STRING IF FUNC_CALL VAR STRING NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING IF VAR VAR STRING EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL STRING VAR ASSIGN VAR FUNC_CALL STRING VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER RETURN BIN_OP VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR |
Read problem statements in [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
You are given an integer $C$. Let $d$ be the smallest integer such that $2^{d}$ is strictly greater than $C$.
Consider all pairs of non-negative integers $(A,B)$ such that $A,B < 2^{d}$ and $A \oplus B = C$ ($\oplus$ denotes the bitwise XOR operation). Find the maximum value of $A \cdot B$ over all these pairs.
------ Input ------
The first line of the input contains a single integer $T$ denoting the number of test cases. The description of $T$ test cases follows.
The first and only line of each test case contains a single integer $C$.
------ Output ------
For each test case, print a single line containing one integer β the maximum possible product $A \cdot B$.
------ Constraints ------
$1 β€ T β€ 10^{5}$
$1 β€ C β€ 10^{9}$
------ Subtasks ------
Subtask #1 (30 points): $1 β€ C β€ 10^{3}$
Subtask #2 (70 points): original constraints
----- Sample Input 1 ------
2
13
10
----- Sample Output 1 ------
70
91
----- explanation 1 ------
Example case 1: The binary representation of $13$ is "1101". We can use $A = 10$ ("1010" in binary) and $B = 7$ ("0111" in binary). This gives us the product $70$. No other valid pair $(A, B)$ can give us a larger product.
Example case 2: The binary representation of $10$ is "1010". We can use $A = 13$ ("1101") and $B = 7$ ("0111"). This gives us the maximum product $91$. | def decimalToBinary(n):
return bin(n).replace("0b", "")
for i in range(int(input())):
n = int(input())
binary = decimalToBinary(n)
a1 = 0
a2 = 0
for i in range(len(binary)):
if binary[i] == "0":
a1 = a1 * 2 + 1
a2 = a2 * 2 + 1
if binary[i] == "1":
if i == 0:
a1 = a1 * 2 + 1
a2 = a2 * 2
elif a1 > a2:
a1 = a1 * 2
a2 = a2 * 2 + 1
else:
a1 = a1 * 2 + 1
a2 = a2 * 2
print(a1 * a2) | FUNC_DEF RETURN FUNC_CALL FUNC_CALL VAR VAR STRING STRING FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR STRING ASSIGN VAR BIN_OP BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER NUMBER IF VAR VAR STRING IF VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR VAR |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.