You are given $$$4$$$ sticks of lengths $$$a$$$, $$$b$$$, $$$c$$$, and $$$d$$$. You can not break or bend them.
Determine whether it is possible to form a square$$$^{\text{∗}}$$$ using the given sticks.
$$$^{\text{∗}}$$$A square is defined as a polygon consisting of $$$4$$$ vertices, of which all sides have equal length and all inner angles are equal. No two edges of the polygon may intersect each other.
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases.
The only line of each test case contains four integers $$$a$$$, $$$b$$$, $$$c$$$, and $$$d$$$ ($$$1 \le a, b, c, d \le 10$$$) — the lengths of the sticks.
For each test case, print "YES" if it is possible to form a square using the given sticks, and "NO" otherwise.
You may print each letter in any case (uppercase or lowercase). For example, the strings "yEs", "yes", "Yes", and "YES" will all be recognized as a positive answer.
71 2 3 41 1 1 12 2 2 21 2 1 21 1 5 55 5 5 54 10 5 9
NOYESYESNONOYESNO
In the first test case, we can prove that we can't make a square.
In the second, third, and sixth test cases, we can make a square like this:
![]() |
khba is writing his girlfriend's name. He has $$$n$$$ cubes, each with one lowercase Latin letter written on it. They are arranged in a row, forming a string $$$s$$$. His girlfriend's name is also a string $$$t$$$, consisting of $$$n$$$ lowercase Latin letters.
To prove his love, he must check whether it is possible to rearrange the letters of string $$$s$$$ so that it becomes her name $$$t$$$.
The first line contains an integer $$$q$$$ ($$$1 \le q \le 1000$$$) — the number of test cases.
The first line of each test case contains an integer $$$n$$$ ($$$1 \le n \le 20$$$).
The second line of each test case contains two distinct strings $$$s$$$ and $$$t$$$, each consisting of $$$n$$$ lowercase Latin letters.
For each test case, output "YES" if the letters of $$$s$$$ can be arranged to form $$$t$$$; otherwise, output "NO".
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.
57humitsa mitsuha4orhi hori6aakima makima6nezuqo nezuko6misaka mikasa
YESYESNONOYES
In the first example, the initial string is "humitsa", and the following operations can be performed:
In the second example, the initial string is "orhi", and the following operations can be performed:
Isamatdin has $$$n$$$ toys arranged in a row. The $$$i$$$-th toy has an integer $$$a_i$$$. He wanted to sort them because otherwise, his mother would scold him.
However, Isamatdin never liked arranging toys in order, so his friend JahonaliX gave him a magic wand to help. Unfortunately, JahonaliX made a small mistake while creating the wand.
But Isamatdin couldn't wait any longer and decided to use the broken wand anyway. The wand can only swap two toys if their integers have different parity (one is even, the other is odd). In other words, you can swap toys in positions $$$(i, j)$$$ only if $$$a_i \bmod 2 \neq a_j \bmod 2$$$, where $$$\bmod$$$ — is the remainder of integer division.
Now he wants to know the lexicographically smallest$$$^{\text{∗}}$$$ arrangement he can achieve using this broken wand.
$$$^{\text{∗}}$$$A sequence $$$p$$$ is lexicographically smaller than a sequence $$$q$$$ if there exists an index $$$i$$$ such that $$$p_j = q_j$$$ for all $$$j \lt i$$$, and $$$p_i \lt q_i$$$.
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 10^4$$$). The description of the test cases follows.
The first line of each test case contains a single integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) — the number of toys.
The second line of each test case contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 10^9$$$) — the integers of the toys.
It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$2 \cdot 10^5$$$.
For each test case, output $$$n$$$ integers — the lexicographically smallest sequence that can be obtained using the described operation.
742 3 1 453 2 1 3 443 7 5 121000000000 231 3 552 5 3 1 742 4 8 6
1 2 3 4 1 2 3 3 4 3 7 5 1 1000000000 2 1 3 5 1 2 3 5 7 2 4 8 6
In the first test case, we can swap positions $$$(1, 3)$$$ and then $$$(2, 3)$$$.
In the second test case, we can swap positions $$$(1, 2)$$$, $$$(1, 3)$$$, and then $$$(2, 3)$$$.
In the third and fourth test cases, we can't swap any positions because all toy integers have the same parity.
You are given an integer $$$n$$$ and an array $$$a$$$ of length $$$n$$$.
Find the smallest integer $$$x$$$ ($$$2 \le x \le 10^{18}$$$) such that there exists an index $$$i$$$ ($$$1 \le i \le n$$$) with $$$\gcd$$$$$$^{\text{∗}}$$$$$$(a_i, x) = 1$$$. If no such $$$x$$$ exists within the range $$$[2,10^{18}]$$$, output $$$-1$$$.
$$$^{\text{∗}}$$$$$$\gcd(x, y)$$$ denotes the greatest common divisor (GCD) of integers $$$x$$$ and $$$y$$$.
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases.
Each of the following $$$t$$$ test cases consists of two lines:
The first line contains a single integer $$$n$$$ ($$$1 \le n \le 10^{5}$$$) — the length of the array.
The second line contains $$$n$$$ space-separated integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 10^{18}$$$).
It is guaranteed that the total sum of $$$n$$$ across all test cases does not exceed $$$10^{5}$$$.
For each test case, output a single integer: the smallest $$$x$$$ ($$$2 \le x \le 10^{18}$$$) such that there exists an index $$$i$$$ with $$$\gcd(a_i, x) = 1$$$. If there is no such $$$x$$$ in the range $$$[2,10^{18}]$$$, print $$$-1$$$.
41146 6 12 12324 120 21042 4 6 10
2553
In the first test case, $$$\gcd(2,1)=1$$$, which is the smallest number satisfying the condition.
In the second test case:
In the third test case:
In the fourth test case:
khba has $$$n$$$ friends, each standing on a line at position $$$a_i$$$, and each of them is in the range $$$[0, x]$$$.
They all want to come to him. One of his friends, Isamatdin, gave him $$$k$$$ teleports. Each friend will walk to the nearest teleport (choosing the shortest distance). Once a friend reaches a teleport, khba and the friend can instantly meet.
But khba is so tired that he'll be sleeping while his friends are walking toward him. Now he wants to choose $$$k$$$ teleport positions so that their positions are distinct and lie within the range $$$[0, x]$$$, in order to maximize the time it takes for the first friend who reaches a teleport to reach it. Assume that friends move at the same speed.
Since khba isn't good at calculations, you should output the $$$k$$$ chosen teleport positions.
Each test contains multiple test cases. The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^4$$$) — the number of test cases. The description of the test cases follows.
The first line of each test case contains three integers $$$n$$$, $$$k$$$, and $$$x$$$ ($$$1 \leq n, k \leq 2 \cdot 10^5$$$, $$$k - 1 \leq x \leq 10^9$$$) — the number of friends, the number of teleports, and the range of possible positions for the teleports.
The second line of each test case contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$0 \leq a_i \leq x$$$) — the positions of khba's friends.
It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$2 \cdot 10^5$$$.
It is guaranteed that the sum of $$$k$$$ over all test cases does not exceed $$$2 \cdot 10^5$$$.
For each test case, output a single line containing $$$k$$$ integers — the $$$k$$$ chosen teleport positions. The positions must be distinct and lie within the range $$$[0, x]$$$. The positions may be output in any order.
If there are multiple optimal choices, output any of them.
104 1 41 0 2 45 5 40 1 2 3 42 1 44 03 4 62 4 33 2 126 12 04 3 128 12 0 41 1 100000000001 1 100000000010000000003 4 98 7 93 4 92 0 1
3 0 1 2 3 4 2 0 1 5 6 3 9 2 6 10 1000000000 0 0 1 2 3 6 7 8 9
Sample 1. Friends at positions $$$[1,0,2,4]$$$. Chosen teleport position: $$$[3]$$$.
Nearest teleport for each friend is in $$$3$$$, minimal times for friends are $$$[2, 3, 1, 1]$$$, respectively.
Sample 2. Friends at positions $$$[0,1,2,3,4]$$$. Chosen teleport positions: $$$[0,1,2,3,4]$$$.
Minimal times for friends are $$$[0, 0, 0, 0, 0]$$$, respectively.
Sample 3. Friends at positions $$$[4,0]$$$. Chosen teleport position: $$$[2]$$$.
Minimal times for friends are $$$[2, 2]$$$, respectively.
Sample 4. Friends at positions $$$[2,4,3]$$$. Chosen teleport positions: $$$[0,1,5,6]$$$.
Minimal times for friends are $$$[1, 1, 2]$$$, respectively.
Sample 5. Friends at positions $$$[6,12,0]$$$. Chosen teleport positions: $$$[3,9]$$$.
Minimal times for friends are $$$[3, 3, 3]$$$, respectively.
Behruzbek received a tree$$$^{\text{∗}}$$$ with $$$n$$$ nodes. For a chosen root$$$^{\text{†}}$$$ $$$r$$$, Behruzbek wants to find cuteness of the tree.
Consider every set of $$$k$$$ distinct nodes of the tree. For each such set, compute its lowest common ancestor (LCA) in the tree when it is rooted at $$$r$$$. Let $$$S_r$$$ be the set of all distinct nodes obtained this way; then cuteness of the tree is $$$|S_r|$$$, where $$$|S|$$$ means the number of distinct elements.
After discovering the cuteness of trees, Behruzbek became interested in finding the kawaiiness of the tree! Kawaiiness is defined as:
$$$$$$ \sum_{r = 1}^{n} |S_r| = |S_1| + |S_2| + \dots + |S_n| $$$$$$
Unfortunately, Behruzbek is feeling sleepy now. Please help Behruzbek by finding the kawaiiness of the tree!
$$$^{\text{∗}}$$$A tree is a connected graph without cycles.
$$$^{\text{†}}$$$A rooted tree is a tree where one vertex is special and called the root.
The first line contains the number of test cases $$$t$$$ ($$$1 \leq t \leq 10^{4}$$$).
The first line of each test case contains two integers $$$n$$$ and $$$k$$$ ($$$2 \leq k \leq n \leq 2\cdot 10^{5}$$$) — the number of vertices in the tree and the number of distinct integers to be chosen.
The following $$$n-1$$$ lines of each test case describe the tree. Each of the lines contains two integers $$$u$$$ and $$$v$$$ ($$$1 \leq u,v \leq n$$$, $$$u \ne v$$$) that indicate an edge between vertex $$$u$$$ and $$$v$$$. It is guaranteed that these edges form a tree.
It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$2\cdot 10^{5}$$$.
For each test case, output one integer — the value of $$$\sum\limits_{r=1}^n |S_r|$$$.
42 21 25 31 21 31 41 56 31 21 32 42 53 610 55 64 93 92 62 88 96 101 64 7
291735
Let $$$f(i) = |S_i|$$$
For the third example:
Overall, $$$2 + 2 + 3 + 3 + 3 + 4 = 17$$$.
Muhammadali has an integer array $$$a_1,\dots,a_n$$$. He can change (replace) any subset of positions; changing position $$$i$$$ costs $$$c_i$$$ and replaces $$$a_i$$$ with any integer of his choice. The positions that he does not change must retain their original values.
After all changes, we call an index $$$i$$$ ($$$1 \le i \lt n$$$) a drop if the final value at position $$$i$$$ is strictly greater than the final value at position $$$i+1$$$. Muhammadali wants the final array to contain no drops.
Find the minimum cost of changes required to ensure that there are no drops in the array.
The first line contains an integer $$$t$$$ ($$$1 \le t \le 5000$$$) — the number of test cases.
Each test case consists of three lines:
The first line contains a single integer $$$n$$$ ($$$1 \le n \le 8000$$$) — the length of the arrays.
The second line contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 10^9$$$) — the elements of the array.
The third line contains $$$n$$$ integers $$$c_1, c_2, \dots, c_n$$$ ($$$1 \le c_i \le 10^9$$$) — the costs of changes.
It is guaranteed that the sum of $$$n$$$ across all test cases does not exceed $$$8000$$$.
For each test case, output a single integer — the minimum possible total cost required to eliminate all drops.
10110541 2 2 35 6 7 844 3 2 11 1 1 133 1 2100 1 155 5 5 5 510 1 10 1 1051 3 2 2 4100 1 1 1 100610 9 8 7 6 51 100 1 100 1 1005100 1 100 100 1001 100 1 1 142 1 2 15 4 3 271 5 3 4 2 6 710 1 10 1 10 1 10
0032012031611
In the first and second examples, the array already has no drops, so no changes are needed.
In the third example, one of the optimal arrays is: $$$[2,3,5,6]$$$; to achieve this, all elements except the second need to be replaced, so the answer is $$$c_1 + c_3 + c_4 = 3$$$.