The city of Rio de Janeiro is under attack! By a swarm of bees? That act in a very specific manner? That's correct, and unfortunately, MatheusAB has been caught in the middle of this mess. Luckily for him though, he was able to find a bunker in time to hide in and for some reason he has a special device that is able to track the location and direction of the bees. As previously mentioned, they behave in a very specific way: there are $$$n$$$ queen bees that command a swarm of millions of bees and they will attack anything that is present in the smallest convex polygon that contains all the queen bees.
With MatheusAB's special device, he's able to track the location of the queen bees, and he realizes that each of them has a specific constant velocity and direction. Since he's exhausted from this situation, given the initial positions of the queen bees, he asks you to help him find out what's the minimum amount of time he'll have to wait in order for the city to be safe to roam in again. Initially, all queen bees are within city limits. Rio de Janeiro is considered safe once there aren't any areas within it that are susceptible to a bee attack. The city is conveniently a convex polygon defined by $$$m$$$ vertices.
The first line contains two integers, $$$n$$$, $$$m$$$, $$$(1 \leq n \leq 10^5)$$$, $$$(3 \leq m \leq 10^5)$$$ — the number of queen bees and the number of vertices that define the city.
Each of the next $$$n$$$ lines will contain the description of the queen bee. Each line contains four integers, $$$x_i$$$, $$$y_i$$$, $$$vx_i$$$, $$$vy_i$$$, $$$(-10^9 \leq x_i, y_i \leq 10^9)$$$, $$$(-10^7 \leq vx_i, vy_i \leq 10^7)$$$ — the position in the x and y coordinates and their respective velocities. The velocity is given in units per second. It is guaranteed that each queen bee starts within city limits.
Each of the next $$$m$$$ lines will contain two integers, $$$x_j$$$, $$$y_j$$$, $$$(-10^9 \leq x_j, y_j \leq 10^9)$$$ — the coordinates of the $$$j^{th}$$$ vertex that describes the city.
If the city is forever under attack, print the word rip in a single line.
Otherwise, output a real number — the minimum amount of time (in seconds) MatheusAB will have to wait. Your answer will be considered correct if its absolute or relative error does not exceed $$$10^{-6}$$$, that being if your answer is $$$a$$$ and the jury's is $$$b$$$, then the judge will check if $$$\frac{|a - b|}{max(1, b)} \leq 10^{-6}$$$.
3 3-3 0 -1 00 -3 1 10 3 1 1-5 00 50 -5
12
3 3-3 0 -1 00 -3 -1 -10 3 1 1-5 00 50 -5
rip
The following image describes the first test case. The polygon in red is the city, the polygon in blue describes the initial position of the queen bees and the green polygon represents their area at time $$$\approx 12$$$. For the second test case, it is easy to see that the bees will always be attacking the city.
I don't feel like wasting your time today with long statements, so let's cut straight to the point.
Let $$$p(x)$$$ be the product of all square numbers that divide $$$x$$$, or more formally, $$$p(x) = \displaystyle\prod_{\substack{i = 1 \\ i^2 | x}}^{\infty} i^2$$$.
Given $$$a$$$ and $$$b$$$, your task is to calculate the number of times $$$a!^b$$$ divides $$$p\big(a!^b\big)$$$. More formally, calculate the maximum value of $$$c$$$ such that $$$(a!^b)^c \mid p\big(a!^b\big)$$$.
Since $$$c$$$ can be quite large, print the sum of its digits in base $$$10$$$.
The input consists of the two integers $$$a$$$ and $$$b$$$ $$$(2\leq a \leq 4 \times 10^5, 1 \leq b \leq 10^4)$$$ on a single line.
Print the sum of digits of the maximum value of $$$c$$$ such that $$$(a!^b)^c$$$ divides $$$p\big(a!^b\big)$$$. In particular, we define the sum of digits of $$$c=0$$$ to be $$$0$$$.
5 3
6
5 5
10
3 1
0
42069 6969
78510
In the first example, $$$5!^3=1728000$$$, and we can check that $$$(5!^3)^6 \mid p(5!^3)$$$ but $$$(5!^3)^7 \nmid p(5!^3)$$$, so the answer is $$$c=6$$$ and the sum of its digits is $$$6$$$.
In the second example, we get $$$c=28$$$, and the sum of its digits is $$$2+8=10$$$.
In the third example, $$$3!^1=6$$$, and $$$p(3!^1)=1$$$, so $$$c=0$$$.
A lovely couple, Sergio and Ana, go out on a romantic evening to paint. They go to this place that has some very special paint colors, which are able to glow in the dark and some of which have some very funky effects! The event starts with the couple receiving $$$q$$$ blank canvases, and a whole variety of $$$k$$$ colors to choose from. The colors are numbered from $$$1$$$ to $$$k$$$. These can be divided into two: those who are weird and those who are permanent. The colors that are deemed weird have this special effect: if a person tries to color the canvas an even amount of times with the same weird color, every speck of it magically disappears! Permanent colors don't suffer from this (un)fortunate condition.
This painting gallery has some very strict rules on how to use the colors: the couple has $$$n$$$ color palettes to choose from, and once the palettes are chosen, they need to use every color contained in each one. As per guidelines, permanent colors can't be present in the same palette as weird ones. These palettes each contain each color at most once, and contains enough paint of each color to paint the entire canvas (the couple doesn't need to use the same palette twice). Every canvas is an independent query, so they have the complete set of palettes available.
For each $$$q_i$$$ canvas, Ana decides that she wants Sergio to paint it using a specific array of colors. As Sergio wants to paint each one without tiring himself too much, he wants to know for each canvas, what's the least amount of different palettes that he has to choose from in order to satisfy Ana.
The first line contains three integers, $$$n$$$, $$$k$$$, $$$q$$$, $$$(1 \leq n \leq 2 \times 10^5)$$$, $$$(1 \leq k \leq 20)$$$, $$$(1 \leq q \leq 10^6)$$$ — the number of palettes, the number of distinct colors and the number of canvases.
The second line will contain a string $$$s$$$, $$$|s| = k$$$, containing only the letters W and P, indicating whether the $$$i^{th}$$$ color is weird or permanent.
The next $$$n$$$ lines will describe the color palettes that exist. Each line begins with an integer $$$m$$$, $$$(1 \leq m \leq k)$$$ indicating the amount of colors that are contained in this palette. In the next $$$m$$$ integers on the same line, $$$(1 \leq c_1, c_2, ..., c_m \leq k)$$$ — the colors in the palette. It is guaranteed that every color in the same palette is of the same type.
The next $$$q$$$ lines will describe the colors in the canvases that Ana desires. Each line begins with an integer $$$t$$$, $$$(1 \leq t \leq k)$$$, indicating the amount of colors that Ana desires in her canvas. In the next $$$t$$$ integers on the same line, $$$(1 \leq a_1, a_2, ..., a_t \leq k)$$$ — the colors that are desired.
For each query, print out the minimum amount of palettes needed in order to get the colors that Ana desires. If it's not possible, print $$$-1$$$.
3 5 2WPWWP2 1 32 2 53 1 3 45 1 2 3 4 51 1
2 -1
5 7 4WWPPWPW3 2 5 73 1 7 52 3 41 62 2 55 1 7 2 3 44 1 2 3 42 4 63 5 6 2
3 3 -1 2
In the first example:
For the first canvas, Sergio is able to color it using the second and third palettes. It is easy to see that for the second canvas, it is impossible to reach the color array desired.
In the second example:
The second canvas can be created using palettes 1, 2, 3. The fourth canvas can be created using palettes 4 and 5.
Davi Holanda, usually known by his nickname, Deaga, has been fiddling around with arithmetic progressions, as it's something very important to know for the entrance exam of the Institute of Meaningful Equations, otherwise known as IME. He discovered the existence of third-order arithmetic progressions, which are arithmetic progressions that, given the first four elements, follow the construction rule: $$$a_{i + 3} - 3a_{i + 2} + 3a_{i + 1} - a_i = k$$$, where $$$k$$$ is some non-zero constant. The constant varies depending on the sequence.
In order to furthermore learn about this type of arithmetic sequence, he began playing around with making operations with it. He got an array $$$v$$$, of length $$$n$$$, and given the first four elements and two indices $$$i$$$ and $$$j$$$, $$$(i \lt j)$$$, he'd add the elements of the sequence onto the array. Of course he'd add them in order, with the first element being added to index $$$i$$$, and the $$$(j - i)^{th}$$$ element being added to index $$$j$$$. However, he'd perform these operations given some restrictions:
Deaga does this many times and ends up getting bored doing all the calculations, and asks for your help to speed things up! Based on the initially empty array, he performs $$$q$$$ queries, in which one will add a certain sequence to a certain range of the array, and another one which will ask the sum of elements of a certain range.
Such graphic depicts what a third-order arithmetic progression looks like The first line of the input contains two integers, $$$n$$$ and $$$q$$$, $$$(4 \leq n \leq 2 \times 10^5)$$$, $$$(1 \leq q \leq 2 \times 10^5)$$$ — the size of the empty array and the amount of queries.
The next $$$q$$$ lines will contain information about the $$$i^{th}$$$ query done by Deaga. Each line will start with an integer $$$t_i$$$, $$$(1 \leq t_i \leq 2)$$$ — the type of query.
For every query in which $$$t_i = 2$$$, print out the sum of the elements in the range $$$[l, r]$$$. Since the sum can be very large, print out the sum modulo Deaga's favorite prime number: 1000696969.
7 81 1 7 1 2 11 342 1 12 2 22 3 32 4 42 5 52 6 62 7 7
1 2 11 34 77 146 247
15 81 1 10 2 545 2224 51772 1 52 6 102 1 101 8 15 61 19 3 12 1 102 11 152 14 15
17490 172265 189755 189838 1000696814 1000696821
This is the easy version of the problem. The only difference between the two versions is the constraint on $$$|s|$$$ .
Navarro is (or was? I'm really not sure) a prominent student at the Institute of Making Ethanol, commonly known around the block as IME. He loves playing around with strings (of characters, not related to ropes) and so he also enjoys applying random algorithms to them. On one fine afternoon, he devised a simple algorithm to create a graph from a string with the following construction: two indices $$$i$$$ and $$$j$$$ are connected only if the substring $$$[i, j]$$$ is a palindrome. Seems simple right?
From the graph that's created, Navarro wants to find out the amount of connected components.
The input consists of a single string $$$s$$$, $$$(1 \leq |s| \leq 10^4)$$$, containing only lowercase Latin letters.
Output a single integer — the amount of connected components in the graph that's generated.
abcacba
4
navarrolikestacocat
14
We can see that the resulting graph will have the following edges:
1-7
2-6
3-5
Thus, there will be 4 connected components.
This is the hard version of the problem. The only difference between the two versions is the constraint on $$$|s|$$$ .
Navarro is (or was? I'm really not sure) a prominent student at the Institute of Making Ethanol, commonly known around the block as IME. He loves playing around with strings (of characters, not related to ropes) and so he also enjoys applying random algorithms to them. On one fine afternoon, he devised a simple algorithm to create a graph from a string with the following construction: two indices $$$i$$$ and $$$j$$$ are connected only if the substring $$$[i, j]$$$ is a palindrome. Seems simple right?
From the graph that's created, Navarro wants to find out the amount of connected components.
The input consists of a single string $$$s$$$, $$$(1 \leq |s| \leq 10^6)$$$, containing only lowercase Latin letters.
Output a single integer — the amount of connected components in the graph that's generated.
abcacba
4
navarrolikestacocat
14
You live in a tree-shaped country with $$$n$$$ cities, and you conveniently live in city $$$1$$$. It's almost Christmas, so you want to send a gift to your friends. Luckily, you can use the famous post service called IMEmail. It's so quick that it only takes one day to move packages between two neighboring cities (wow! What a relief!). As always, there are some caveats when it comes to this: once a package travels through a city, it can't take a route that passes through that city again. In other words, there can't be a cycle in the path a package takes.
This year, you decided to gift all your friends headphones! You just finished buying the headphones, but now realized that they didn't come with a charging cable. Your friends will only be happy if they receive both the headphones and the charging cable exactly on Christmas day. Now, you decide to call many manufacturers to see how soon they can start distributing the cables across the country.
On the $$$i^{th}$$$ query, you'll send the headphones $$$x$$$ days before Christmas. You also find out that there's a manufacturer located in city $$$u$$$ that will send out the chargers $$$y$$$ days before Christmas. Given these various parameters, for each query, you want to know how many friends will be happy on Christmas Day.
The first line contains two integers $$$n$$$, $$$q$$$, $$$(2 \leq n \leq 2 \times 10^5)$$$, $$$(1 \leq q \leq 2 \times 10^5)$$$ — the total number of cities and the number of queries, respectively.
The next line contains $$$n$$$ integers $$$f_1, f_2, \cdots, f_n\,(0 \leq f_i \leq 10^9)$$$ — the number of friends located in city $$$i$$$.
The following $$$n - 1$$$ lines each contain a pair of integers $$$u$$$, $$$v$$$, $$$(1\leq u, v\leq n,\, u \neq v)$$$ — indicating that cities $$$u$$$ and $$$v$$$ are connected. Of course, all the cities are somehow connected.
The next $$$q$$$ lines each contain three integers $$$u, x, y\, (2\leq u \leq n,\, 0 \leq x, y \leq n - 1)$$$ — indicating that there's a manufacturer located in city $$$u$$$ that will send the packages $$$y$$$ days before Christmas, while you send out the packages $$$x$$$ days before Christmas.
For each query, print out the number of friends that will be happy on Christmas Day.
7 33 8 1 9 2 0 31 22 31 44 52 61 76 1 15 2 03 1 3
8 2 12
Somewhere along a famous beach in Rio de Janeiro, $$$n$$$ friends share a house (because how can you afford rent alone?). They all follow one sacred rule: always leave your shoes by the door when entering.
Each friend has $$$k$$$ pairs of shoes, and since they are too poor to afford a decent shoe rack, they decided to just draw lines on the ground to create $$$nk$$$ slots to place their pairs of shoes. The slot $$$i$$$ is at a distance of $$$i$$$ from the door, and initially contains a shoe from the person $$$a_i$$$.
Every day, each person selects a random pair of shoes they own and leaves the house in the morning. They all arrive in the afternoon in a random order, and place their shoes on the first slot available (closest to the door).
You need to answer $$$q$$$ queries. On each query, given two integers $$$x$$$ and $$$d$$$, calculate the expected average distance of all the pairs of shoes of person $$$x$$$ to the door after $$$d$$$ days. It can be shown that this answer can always be expressed as a fraction $$$\frac{p}{q}$$$ where $$$p$$$ and $$$q$$$ are coprime integers. Calculate $$$p\cdot q^{-1}\mod (10^9+7)$$$.
The first line contains two integers $$$n$$$ and $$$k$$$ $$$(2\leq n \leq 10^5, 1\leq k \leq 10^5)$$$ — the number of friends and the number of pairs of shoes each of them owns. It is guaranteed that $$$n\cdot k \leq 5\cdot 10^5$$$.
The second line contains $$$n\cdot k$$$ integers $$$a_i$$$ $$$(1\leq a_i \leq n)$$$ — the owner of the shoe on the slot $$$i$$$ at the beginning.
The third line contains an integer $$$q$$$ $$$(1\leq q \leq 5\cdot 10^5)$$$ — the number of queries to answer.
The next $$$q$$$ lines contain each two integers $$$x$$$ and $$$d$$$ $$$(1\leq x\leq n, 0\leq d\leq 10^{18})$$$ — the person and the number of days for which you need to answer the query.
For each query, print one integer — the expected average distance of the shoes of the person $$$x$$$ after $$$d$$$ days.
3 11 2 351 02 69696942069691 4206969694203 13 0
1 2 2 2 3
3 21 2 1 2 3 381 02 03 01 12 21 33 41 1000000000000000000
2 3 500000009 750000008 375000006 812500009 625000008 763897687
On the first example: We see that for $$$d = 0$$$, then the shoes will remain in the same spot, and so their distance to the door will remain the same. For the query $$$\{3\,\, 1\}$$$, when the people return to the house on day $$$1$$$, each shoe has an equal probability of staying in each position, hence the answer being $$$2$$$.
On the second example: For the query $$$\{1\,\, 0\}$$$, the shoes won't move, and so their average distance to the door is 2. For the query $$$\{1\,\, 1\}$$$, we can check that the answer is $$$\frac{11}{4} \equiv 750000008 \mod 10^9 + 7$$$. You can easily brute force all possibilites and verify this.
In a fictitious universe, there are two species of aliens that have agreed to peacefully coexist until the heat death of the universe. Once every 500 trillion years, the two parties hold a conference in some galaxy to discuss issues (and have some nice drinks). You are given the task to decide in which galaxy to hold this amazing conference (party).
There is one catch: intergalactic travel is expensive, so an alien from one species will be happy with the chosen place if and only if there exists an alien from the other species that has to travel the exact same distance to arrive at the conference. Luckily, the $$$n$$$ galaxies are located in a straight line, with a separation of $$$1$$$ megaparsec between adjacent ones.
Given the distribution of the aliens of both species in these galaxies, what is the maximum number of aliens you can make happy by choosing the position of the conference?
The first line contains two integers $$$n_1$$$, $$$n_2$$$ $$$(1\leq n_1, n_2 \leq 5\cdot 10^5)$$$ — the number of galaxies that contain the aliens of the first species and second species respectively.
The next $$$n_1$$$ lines each contain two integers $$$g_{1,i}$$$, $$$p_{1,i}$$$ $$$(1\leq g_{1,i}\leq 5\cdot 10^5,\, 1\leq p_{1,i} \leq 10^9)$$$ — indicating that the galaxy $$$g_{1,i}$$$ contains $$$p_{1,i}$$$ aliens from the first species. It is guaranteed that $$$g_{1,i} \neq g_{1,j} \forall i \neq j$$$.
The next $$$n_2$$$ lines each contain two integers $$$g_{2,i}$$$, $$$p_{2,i}$$$ $$$(1\leq g_{2,i}\leq 5\cdot 10^5,\, 1\leq p_{2,i} \leq 10^9)$$$ — indicating that the galaxy $$$g_{2,i}$$$ contains $$$p_{2,i}$$$ aliens from the second species. It is guaranteed that $$$g_{2,i} \neq g_{2,j} \forall i \neq j$$$.
The maximum number of aliens you will make happy if you choose the conference position optimally. The position must be in some galaxy, but this galaxy does not need to contain any aliens.
2 21 24 61 36 5
16
3 22 34 56 13 25 1
0
4 47 110 15 11 38 29 31 44 3
15
For the first example, note that if the conference is placed at the $$$5^{th}$$$ galaxy, then the aliens from both species located at galaxy $$$1$$$ will be happy, as there'll be one from the other species that'll have to travel the same distance. In addition to that, the aliens from the first species at galaxy $$$4$$$ will be happy as aliens from the second species at galaxy $$$6$$$ will be happy as well; both will have to travel a distance of $$$1$$$ galaxy to reach galaxy $$$5$$$.
Pedro Vieira is a student at the Institute of Many Equations, commonly referred to as IME. He's attending a class hosted by none other than the infamous Mr. Potato and since his class is soooooo boring (really, it is), Pedro begins making up random algorithms and running them in his mind (as one commonly does).
On one beautiful morning, he overheard Mr. Potato talking some nonsense about XOR operations, and so, tried to come up with an algorithm that does the following: given an array of integers, find the greatest value that can be obtained from XOR-ing a subset of this array. Since this is too easy, he reformulated the problem. Given an array $$$a$$$ of $$$n$$$ elements, for every $$$i$$$ from $$$1 ... n$$$, find the maximum XOR value of a subset of the array $$$(a_1, a_2, ..., a_i)$$$.
The first line of the input contains a single integer, $$$n$$$, $$$(1 \leq n \leq 10^6)$$$ — the amount of elements in the array.
The second line contains $$$n$$$ integers $$$a_i$$$, $$$(0 \leq a_i \lt 2^{63})$$$ — the array $$$a$$$.
Output $$$n$$$ integers in a single line, each one separated by a space, indicating the maximum value of applying the XOR operation over a subset of the array $$$(a_1, a_2, ..., a_i)$$$.
54 3 5 2 19
4 7 7 7 23
7392 17179869184 229 1128 44439 12283 1337
392 17179869576 17179869576 17179870688 17179913623 17179913623 17179913643
At the 2023 Brazilian Summer Camp, prominent Polish coder kostka told his students how hashing is the best thing in the world. It makes problems related to strings that much easier! As such, an easy question related to strings must be made in order to show how efficient it is. The task is quite simple: you are given a string $$$s$$$ and an integer $$$k$$$. You only need to print out how many substrings $$$t$$$ exist, such that $$$(|t| * freq(t) = k)$$$, where $$$freq(t)$$$ is the amount of times the substring appears in the string. If at least one substring fits the criteria, you should print out the lexicographically smallest and the lexicographically largest (note that they may be the same). Quite an easy task, right?
Lexicographical order is defined as follows: when ordering two strings $$$a$$$ and $$$b$$$, $$$a$$$ is lexicographically smaller than $$$b$$$ if and only if one of the following holds:
The first line of the input contains two integers $$$n$$$ and $$$k$$$, $$$(1 \leq n \leq 10^6)$$$, $$$(1 \leq k \leq 10^{12})$$$ — the length of the string and the desired value.
The second line of the input will contain the string $$$s$$$, containing only lowercase Latin letters.
On the first line, output the amount of substrings that fit the criteria. Then, if substrings exist, print out the lexicographically smallest and then the lexicographically largest.
6 12aaaaaa
2 aaa aaaa
5 3zhdke
3 dke zhd
6 20kostka
0
The students of some programming summer camp love going to a meeting place known by all as the little gas station. For some reason, the city they currently live in can be thought of as having $$$n$$$ road intersections, with a total of $$$n - 1$$$ roads. From every intersection, you can reach every other one. They loved going to the same little gas station as always, which was originally located at the intersection whose label is $$$1$$$. However, the students sometimes complained that they had to walk too much in order to get to the original little gas station, as they could sometimes be on the other side of town.
Thus, a businessman from out of town appeared in order to help these poor students. Depending on the day, this businessman would build a replica of the original little gas station at some intersection $$$x$$$ (he would never build in an intersection that already contains a gas station). The owner of the original little gas station, furious with this new businessman, would, depending on the day, destroy one of the businessman's gas station replicas. However, the students simply didn't care enough about this fight between them, so given a day in which they wanted to hang out at a little gas station, they'd go to the nearest to the intersection they're currently at.
This fight lasted for $$$q$$$ days, and on each day, one of three events could occur: the businessman could build a replica at intersection $$$x$$$, the original owner could destroy a replica at intersection $$$y$$$, or the students, currently at intersection $$$z$$$, want to find out the minimum amount of roads they need to cover to reach any little gas station.
The first line contains two integers, $$$n$$$ and $$$q$$$, $$$(1 \leq n \leq 2 \times 10^5)$$$, $$$(1 \leq q \leq 2 \times 10^5)$$$ — the amount of intersections and days the conflict lasted.
The next $$$n - 1$$$ lines describe the structure of the city; the $$$i^{th}$$$ line contains two integers, $$$a_i$$$, $$$b_i$$$, $$$(1 \leq a_i, b_i \leq n)$$$, $$$(a_i \neq b_i)$$$ — the roads $$$a_i$$$ and $$$b_i$$$ are connected via a road.
The next $$$q$$$ lines will contain information about the event that occurs on the $$$i^{th}$$$ day. Each line will start with an integer $$$t_i$$$, $$$(1 \leq t \leq 3)$$$ — the type of event that occurs on that day.
For every day in which $$$t_i = 3$$$, output the minimum amount of roads that need to be traversed, with each one being on separate lines.
7 51 21 32 42 53 63 71 21 33 72 33 7
1 2
When the first $$$t_i = 3$$$ query is made, the closest node to $$$7$$$ is $$$3$$$, and we can see that the distance is equal to one. Once this gas station is destroyed, the closest one to $$$7$$$ is $$$1$$$.
Schubert has recently been studying properties of arrays, and something that caught his attention is called inversions. From what he recalls from class, the number of inversions of an array $$$a$$$ of size $$$n$$$ is defined by the number of pairs $$$(i, j)$$$ such that $$$(1 \leq i \lt j \leq n)$$$, in which $$$(a_i \gt a_j)$$$. Schubert realized that given an array, there are plenty of subarrays whose number of inversions is the same as the original array. As such, he gave this simple task: given an array, find the size of the smallest subarray in which the number of inversions is the same as in the original array.
An array $$$b$$$ is a subarray of an array $$$a$$$ if $$$b$$$ can be obtained from $$$a$$$ by deletion of several (possibly, zero or all) elements from the beginning and several (possibly, zero or all) elements from the end. In particular, an array is a subarray of itself.
The first line contains an integer $$$t$$$ $$$(1 \leq t \leq 10^5)$$$ — the number of test cases that Schubert gives to you.
The first line of each test case contains a single integer $$$n$$$ $$$(1 \leq n \leq 10^6)$$$ — the length of the array.
The second line of each test case contains $$$n$$$ integers $$$(a_1, a_2, ..., a_n)$$$ $$$(-10^9 \leq a_i \leq 10^9)$$$ — the elements of the array.
It is guaranteed that the sum of $$$n$$$ over all test cases doesn't exceed $$$10^6$$$.
For each test case, output a single integer in a separate line — the size of the smallest subarray in which the number of inversions is the same as the original one.
2449 0 2 -165 6 59 23 71 100
4 2
151 2 3 4 5
0