Sasha has an array $$$a$$$ of $$$n$$$ integers. He got bored and for all $$$i$$$, $$$j$$$ ($$$i \lt j$$$), he wrote down the minimum value of $$$a_i$$$ and $$$a_j$$$. He obtained a new array $$$b$$$ of size $$$\frac{n\cdot (n-1)}{2}$$$.
For example, if $$$a=$$$ [$$$2,3,5,1$$$], he would write [$$$\min(2, 3), \min(2, 5), \min(2, 1), \min(3, 5), \min(3, 1), min(5, 1)$$$] $$$=$$$ [$$$2, 2, 1, 3, 1, 1$$$].
Then, he randomly shuffled all the elements of the array $$$b$$$.
Unfortunately, he forgot the array $$$a$$$, and your task is to restore any possible array $$$a$$$ from which the array $$$b$$$ could have been obtained.
The elements of array $$$a$$$ should be in the range $$$[-10^9,10^9]$$$.
The first line contains a single integer $$$t$$$ ($$$1\le t\le 200$$$) — the number of test cases.
The first line of each test case contains a single integer $$$n$$$ ($$$2\le n\le 10^3$$$) — the length of array $$$a$$$.
The second line of each test case contains $$$\frac{n\cdot (n-1)}{2}$$$ integers $$$b_1,b_2,\dots,b_{\frac{n\cdot (n-1)}{2}}$$$ ($$$−10^9\le b_i\le 10^9$$$) — the elements of array $$$b$$$.
It is guaranteed that the sum of $$$n$$$ over all tests does not exceed $$$10^3$$$ and for each array $$$b$$$ in the test, there exists an original array.
For each test case, output any possible array $$$a$$$ of length $$$n$$$.
531 3 121047 5 3 5 3 352 2 2 2 2 2 2 2 2 253 0 0 -2 0 -2 0 0 -2 -2
1 3 3 10 10 7 5 3 12 2 2 2 2 2 0 -2 0 3 5
In the first sample, Sasha chose the array $$$[1,3,3]$$$, then the array $$$b$$$ will look like $$$[\min(a_1,a_2)=1, \min(a_1,a_3)=1, \min(a_2,a_3)=3]$$$, after shuffling its elements, the array can look like $$$[1,3,1]$$$.
In the second sample, there is only one pair, so the array $$$[10,10]$$$ is suitable. Another suitable array could be $$$[15,10]$$$.
Your task is to determine whether it is possible to find exactly $$$m$$$ consecutive positive integers such that their total sum is exactly equal to $$$n$$$.
A sequence of numbers is considered strictly consecutive positive integers if it consists of integers greater than zero that follow each other continuously, with each subsequent number being exactly $$$1$$$ greater than the previous one. For example, $$$4, 5, 6$$$ are three consecutive positive integers, while $$$2, 4, 6$$$ (has gaps) and $$$-1, 0, 1$$$ (contains non-positive numbers) are not
The first line of the input contains a single integer $$$t$$$ ($$$1 \le t \le 10^5$$$) — the number of test cases.Each of the next $$$t$$$ lines contains two space-separated integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 10^{9},1 \le m \le 10^{9}$$$) — the target sum and the required number of consecutive positive integers, respectively.
For each test case, output YES if it is possible to form the sum $$$n$$$ using exactly $$$m$$$ consecutive positive integers. Otherwise, output NO.You can output the answer in any case (for example, the strings "yEs", "yes", "Yes", and "YES" will all be recognized as a positive answer).
118 3
YES
for the given testcase the three consecutive integers are: 5,6,7
You are given an array $$$a_1, a_2, \dots, a_n$$$ where all $$$a_i$$$ are integers and greater than $$$0$$$.
In one operation, you can choose two different indices $$$i$$$ and $$$j$$$ ($$$1 \le i, j \le n$$$). If $$$gcd(a_i, a_j)$$$ is equal to the minimum element of the whole array $$$a$$$, you can swap $$$a_i$$$ and $$$a_j$$$. $$$gcd(x, y)$$$ denotes the greatest common divisor (GCD) of integers $$$x$$$ and $$$y$$$.
Now you'd like to make $$$a$$$ non-decreasing using the operation any number of times (possibly zero). Determine if you can do this.
An array $$$a$$$ is non-decreasing if and only if $$$a_1 \le a_2 \le \ldots \le a_n$$$.
The first line contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases.
The first line of each test case contains one integer $$$n$$$ ($$$1 \le n \le 10^5$$$) — the length of array $$$a$$$.
The second line of each test case contains $$$n$$$ positive integers $$$a_1, a_2, \ldots a_n$$$ ($$$1 \le a_i \le 10^9$$$) — the array itself.
It is guaranteed that the sum of $$$n$$$ over all test cases doesn't exceed $$$10^5$$$.
For each test case, output "YES" if it is possible to make the array $$$a$$$ non-decreasing using the described operation, or "NO" if it is impossible to do so.
4 1 8 6 4 3 6 6 2 9 4 4 5 6 7 5 7 5 2 2 4
YES YES YES NO
In the first and third sample, the array is already non-decreasing.
In the second sample, we can swap $$$a_1$$$ and $$$a_3$$$ first, and swap $$$a_1$$$ and $$$a_5$$$ second to make the array non-decreasing.
In the forth sample, we cannot the array non-decreasing using the operation.
Aziz is making raviolis today! He has rolled out a large sheet of dough that can be represented as an $$$n \times m$$$ grid of unit squares.
A ravioli is defined as any rectangular section of the dough with integer side lengths whose sides are parallel to the edges of the main grid.
Aziz's dough is magical: every time he chooses a valid rectangular area to cut, he simply notes its dimensions and position, and the dough remains intact for his next calculation.
Help Aziz find the total number of distinct ravioli (sub-rectangles) he can identify within the $$$n \times m$$$ grid.
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ $$$( 1 \le t \le 10^5)$$$. The description of the test cases follows.
Each test case contains two integers $$$n,m$$$ $$$(1 \le n,m \le 10^{5})$$$– the size of the grid
For each test case:
Output an integer answer modulo $$$10^9+7$$$.
51 12 22 33 350 34
1 9 18 36 758625
$$$n \times m$$$ ravioli roll
an image showcasing the number of cuts of the $$$2 \times 2 $$$ roll
The ways to cut the $$$2 \times 2$$$ roll:
Majd Aldeen, a gemologist inspecting a chain of $$$n$$$ rocks in the Hashemite desert, observes that each rock holds a gemstone labeled with a positive integer. His favorite gemstone has label $$$K$$$. He considers a contiguous subsegment of rocks interesting if it contains at least one gemstone labeled $$$K$$$.Help Majd Aldeen count the number of interesting contiguous subsegments.
Formally, given an array $$$a$$$ of $$$n$$$ positive integers, count the number of pairs $$$(L, R)$$$ such that $$$1 \le L \le R \le n$$$ and $$$a_j = K$$$ for at least one index $$$j$$$ satisfying $$$L \le j \le R$$$.
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 two integers $$$n$$$ and $$$K$$$ ($$$1 \leq n \leq 2\times10^5$$$ , $$$1 \leq K \leq 10^9$$$) — the length of the array and the target value.
The second line of each test case contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \leq a_i \leq 10^9$$$).
It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$2 \times 10^5$$$.
For each test case, output a single integer — the number of contiguous subsegments that contain $$$K$$$ at least once.
24 21 2 3 23 51 2 3
80
In the first test case, the array is $$$[1, 2, 3, 2]$$$ and $$$K = 2$$$. The $$$8$$$ interesting subsegments are: $$$[1, 2]$$$, $$$[2]$$$ , $$$[2, 3]$$$, $$$[1, 2, 3]$$$, $$$[2]$$$ , $$$[3, 2]$$$, $$$[2, 3, 2]$$$, and $$$[1, 2, 3, 2]$$$.
In the second test case, the array is $$$[1, 2, 3]$$$ and $$$K = 5$$$. No element equals $$$5$$$, so the answer is $$$0$$$.