text
stringlengths
0
801
In the first test case, $a=[1]$ initially.
In the first loop:
1. Set $sum := sum + a_1 = 0+1=1$; 2. Set $b_1 :=\ \operatorname{MAD}([a_1])=\ \operatorname{MAD}([1])=0$, and then set $a_1 := b_1$.
After the first loop, $a=[0]$ and the process ends. The value of $sum$ after the process is $1$.
In the second test case, $a=[2,2,3]$ initially.
After the first loop, $a=[0,2,2]$ and $sum=7$.
After the second loop, $a=[0,0,2]$ and $sum=11$.
After the third loop, $a=[0,0,0]$ and $sum=13$. Then the process ends.
The value of $sum$ after the process is $13$.
You are given an array $b$ of $n - 1$ integers.
An array $a$ of $n$ integers is called good if $b_i = a_i \, \& \, a_{i + 1}$ for $1 \le i \le n-1$, where $\&$ denotes the [bitwise AND operator](https://en.wikipedia.org/wiki/Bitwise_operation#AND).
Construct a good array, or report that no good arrays exist.
Each test contains multiple test cases. The first line contains a single integer $t$ ($1 \le t \le 10^4$) — the number of test cases. The description of test cases follows.
The first line of each test case contains a single integer $n$ ($2 \le n \le 10^5$) — the length of the array $a$.
The second line of each test case contains $n - 1$ integers $b_1, b_2, \ldots, b_{n - 1}$ ($0 \le b_i < 2^{30}$) — the elements of the array $b$.
It is guaranteed that the sum of $n$ over all test cases does not exceed $10^5$.
For each test case, output a single integer $-1$ if no good arrays exist.
Otherwise, output $n$ space-separated integers $a_1, a_2, \ldots, a_n$ ($0 \le a_i < 2^{30}$) — the elements of a good array $a$.
If there are multiple solutions, you may output any of them.
In the first test case, $b = [1]$. A possible good array is $a=[5, 3]$, because $a_1 \, \& \, a_2 = 5 \, \& \, 3 = 1 = b_1$.
In the second test case, $b = [2, 0]$. A possible good array is $a=[3, 2, 1]$, because $a_1 \, \& \, a_2 = 3 \, \& \, 2 = 2 = b_1$ and $a_2 \, \& \, a_3 = 2 \, \& \, 1 = 0 = b_2$.
In the third test case, $b = [1, 2, 3]$. It can be shown that no good arrays exist, so the output is $-1$.
In the fourth test case, $b = [3, 5, 4, 2]$. A possible good array is $a=[3, 7, 5, 6, 3]$.
You are given $n$ sticks, numbered from $1$ to $n$. The length of the $i$-th stick is $a_i$.
You need to answer $q$ queries. In each query, you are given two integers $l$ and $r$ ($1 \le l < r \le n$, $r - l + 1 \ge 6$). Determine whether it is possible to choose $6$ distinct sticks from the sticks numbered $l$ to $r$, to form $2$ non-degenerate triangles$^{\text{∗}}$.
$^{\text{∗}}$A triangle with side lengths $a$, $b$, and $c$ is called non-degenerate if:
* $a < b + c$, * $b < a + c$, and * $c < a + b$.
The first line contains two integers $n$ and $q$ ($6 \le n \le 10^5$, $1 \le q \le 10^5$) — the number of sticks and the number of queries respectively.
The second line contains $n$ integers $a_1, a_2, \ldots, a_n$ ($1 \le a_i \le 10^9$) — $a_i$ denotes the length of the $i$-th stick.
Each of the following $q$ lines contains two integers $l$ and $r$ ($1 \le l < r \le n$, $r - l + 1 \ge 6$) — the parameters of each query.
For each query, output "YES" (without quotes) if it is possible to form $2$ triangles, and "NO" (without quotes) otherwise.
You can output the answer in any case (upper or lower). For example, the strings "yEs", "yes", "Yes", and "YES" will be recognized as positive responses.
In the first query, the lengths of the sticks are $[5, 2, 2, 10, 4, 10]$. Two sets of sticks $[2, 4, 5]$ and $[2, 10, 10]$ can be selected to form $2$ non-degenerate triangles.
In the second query, the lengths of the sticks are $[2, 2, 10, 4, 10, 6]$. It can be shown that it is impossible to form $2$ non-degenerate triangles.
In the third query, the lengths of the sticks are $[2, 2, 10, 4, 10, 6, 1]$. Two sets of sticks $[1, 2, 2]$ and $[4, 10, 10]$ can be selected to form $2$ non-degenerate triangles.
In the fourth query, the lengths of the sticks are $[4, 10, 6, 1, 5, 3]$. It can be shown that it is impossible to form $2$ non-degenerate triangles.
In the fifth query, the lengths of the sticks are $[10, 4, 10, 6, 1, 5, 3]$. Two sets of sticks $[1, 10, 10]$ and $[3, 4, 5]$ can be selected to f
Alice and Bob are playing a game with $n$ piles of stones, where the $i$-th pile has $a_i$ stones. Players take turns making moves, with Alice going first.
On each move, the player does the following three-step process:
1. Choose an integer $k$ ($1 \leq k \leq \frac n 2$). Note that the value of $k$ can be different for different moves. 2. Remove $k$ piles of stones. 3. Choose another $k$ piles of stones and split each pile into two piles. The number of stones in each new pile must be a prime number.
The player who is unable to make a move loses.
Determine who will win if both players play optimally.
Each test contains multiple test cases. The first line contains a single integer $t$ ($1 \le t \le 10^4$) — the number of test cases. The description of test cases follows.
The first line of each test case contains a single integer $n$ ($2 \le n \le 2 \cdot 10^5$) — the number of piles of stones.
The second line of each test case contains $n$ integers $a_1, a_2, \ldots, a_n$ ($1 \le a_i \le 2 \cdot 10^5$) — the number of stones in the piles.
It is guaranteed that the sum of $n$ over all test cases does not exceed $2 \cdot 10^5$.
For each test case, output "Alice" (without quotes) if Alice wins and "Bob" (without quotes) otherwise.
You can output each letter in any case (upper or lower). For example, the strings "alIcE", "Alice", and "alice" will all be considered identical.
In the first test case, there are $2$ piles of stones with $2$ and $1$ stones respectively. Since neither $1$ nor $2$ can be split into two prime numbers, Alice cannot make a move, so Bob wins.
In the second test case, there are $3$ piles of stones with $3$, $5$, and $7$ stones respectively. Alice can choose $k = 1$, remove the pile of $7$ stones, and then split the pile of $5$ stones into two piles of prime numbers of stones, $2$ and $3$. Then, the piles consist of $3$ piles of stones with $3$, $2$, and $3$ stones respectively, leaving Bob with no valid moves, so Alice wins.
In the third test case, there are $4$ piles
This is an interactive problem.