2050. Belarusian scientists managed to recreate dinosaurs from their remains, and now you can safely meet dinosaurs walking around somewhere near Mogilev.
Mogilev Zoo urgently needs two stegosauruses for a grandiose show "Spikes and Tails" in which various animals will take part. There's not much time left, and we need to tame the stegosaurus (luckily, the animals bred by scientists are perfectly trainable).
The organizers did not decide to go somewhere for the stegosauruses, because it is not easy to deliver such animals from another city. So they decided to find stegosaurus near the zoo.
They got lucky! They found $$$n$$$ beautiful stegosaurus, and $$$i$$$th of them had $$$a_i$$$ spikes. Now they had to pick any two to put on a show.
Clearly, the stegosaurses had to look good together. So zoo director Alexandrus wants to choose them so that the number of spikes they have is almost the same. Simply put, he wants to choose such stegosaurses $$$i$$$ and $$$j$$$ that $$$|a_i - a_j|$$$ is minimal.
Here $$$|k|$$$ denotes the modulus of the number $$$k$$$, that is, $$$|k| = k$$$ if $$$k \geq 0$$$, and $$$|k| = -k$$$ otherwise. So, $$$|3| = 3$$$, and $$$|-2| = 2$$$.
Help Alexandrus determine how well he can choose stegosaurus, that is, find the minimal $$$|a_i - a_j|$$$.
The first line contains one integer $$$n$$$ —the number of stegosaurses ($$$2 \le n \le 10^5$$$).
Then the second line takes $$$n$$$ integers $$$a_i$$$ — the number of spikes of $$$i$$$th stegosaurus ($$$0 \le a_i \le 10^9$$$).
Output a single non-negative integer: the minimal possible difference between the number of spikes of two stegosaurses.
In this problem there is a test score, i.e. for each test the points are given independently, and then summed up. Tests are conventionally divided into subtasks, and points are awarded for the completion of all tests of a subtask. The subtasks are given in the following table:
| № | Constraints | Score for the subtask |
| 1 | $$$n = 2$$$ | 10 |
| 2 | $$$n = 3$$$ | 10 |
| 3 | $$$a_i \le 2$$$ | 10 |
| 4 | $$$n \le 300$$$ | 20 |
| 5 | $$$n \le 3000$$$ | 20 |
| 6 | $$$a_i \le 3000$$$ | 15 |
| 7 | No additional constraints | 15 |
5 2 6 0 19 10
2
7 1 2 1 2 4 2 3
0
2 10 15
5
In the first test case, you can choose stegosauruses with numbers $$$1$$$ and $$$3$$$, then the number of spikes they have differs by $$$2$$$.
In the second test case, you can choose stegosauruses with numbers $$$2$$$ and $$$6$$$, then the number of spikes differs by $$$0$$$. You could also choose, for example, stegosauruses with numbers $$$1$$$ and $$$3$$$.
In the third test case, you could choose stegosauruses with numbers $$$1$$$ and $$$2$$$, because there are simply no others.
Not so long ago Alexandis watched an interesting program on a well-known TV channel, in which it was said that important historical events occur on palindrome dates. Thus, for example, it was argued that... Wait a minute, what are palindromic dates?
As you know, any date can be represented as $$$DD$$$.$$$MM$$$.$$$Y^*$$$, where DD — is the day number, MM — is the month number, and $$$Y^*$$$ — is the current year number. So, for example, $$$5$$$ of April $$$1690$$$ can be represented as 05.04.1690, and, say, $$$29$$$ of December $$$192$$$ can be represented as 29.12.192. More formally, we can say that the day number is written using two digits, with perhaps zeros to the left if the number is less than ten. Similarly, the month number is written with two digits according to the same rules. The year number is written as a positive integer without leading zeros.
A palindrome is such a string that it reads equally from left to right and from right to left. For example, the string abacaba is a palindrome, but the string aaba is not.
But now how do we check if a date is a palindrome? It's pretty simple. We take the date as a string, remove the dots from the string, and then check to see if the string is a palindrome. So, for example, April 5th, $$$1690$$$ is not a palindrome date because the date representation 05.04.1690 with the dots removed looks like 05041690 and that string is not a palindrome. At the same time, say the twenty-ninth of December $$$192$$$ can be represented as 29.12.192, its representation without dots looks like 2912192, this string is a palindrome, and therefore the date is a palindrome.
In case you're still interested, the show on this TV channel claimed that it was on the palindrome date that people first saw Bigfoot, it was on the palindrome date that our planet was visited by aliens from Nibiru, and so on... There was quite a long list, which, frankly, was irrelevant to the task at hand.
Alexandis wondered: how many palindromic dates have there been since the very first day of our era, that is, since the first of January of the first year?
This problem uses the Gregorian calendar. In other words, a year is considered leap year if its number is divided by $$$4$$$. However, if the year number is divided by $$$100$$$ and not divided by $$$400$$$, then the year is not considered a leap year.
The input is a single integer $$$n$$$ ($$$1 \le n \le 10^7$$$) — the number of days, counting from $$$1$$$ January $$$1$$$ year, among which Alexandis wants to find palindromic dates.
Output a single non-negative integer — the number of palindromic dates among $$$n$$$ the first days of our era.
In this problem there is a test score, i.e. for each test the points are given independently, and then summed up. Tests are conventionally divided into subtasks, and points are awarded for the completion of all tests of a subtask. The subtasks are given in the following table:
| № | Constraints | Score for the subtask |
| 1 | $$$n \le 365$$$ | 10 |
| 2 | $$$n \le 3650$$$ | 15 |
| 3 | $$$n \le 3\cdot 10^5$$$ | 50 |
| 4 | No additional constraints | 25 |
12
1
103
3
In the first test case, the only palindrome date is $$$11$$$ of January of the first year (11.01.1).
In the second test case, there are three palindromic dates: $$$11$$$ of January, $$$12$$$ of February, and $$$13$$$ of March (of the first year), i.e. 11.01.1, 12.02.1, and 13.03.1.
Alexandrik — a well-known security software developer. Today he thought he'd been hacked, so he decided to update the passwords on all his accounts.
To do that, Alexandrik invented a special hard-to-crack string $$$s$$$, which for some reason consists only of the letters a' and b'. And now he wants to choose the largest «perfectly protected» substring from it, for only it will ensure the safety of his precious personal data. Recall that a substring is a contiguous subsegment of a string. For example, for string ababaaa, string bab is a substring because it lies in that string continuously (ababaaa). At the same time, the string abb is not a substring, because although it enters this string (ababaaa), it does not lie in this string continuously. The string bbb is also not a substring, because it does not lie in this string at all.
A string is called «perfectly protected» if it turns out that every character of this string is different from the corresponding character in its «inverted» version (i.e. a string in which the characters of the original string are written in reverse order). So, for example, the string abaabbab is «perfectly protected» because:
abaabbab
babbaabaaba
are distinct in each character. At the same time, the string aaabaabb is not «perfectly protected», because its «inverted» version (babaabaaa) matches the original string in the third and sixth positions.
So, help Alexandrik find the longest substring of his string, which is «perfectly protected».
The first line of input contains a single integer $$$n$$$ —the number of characters in the string $$$s$$$ ($$$2 \le n \le 5 \cdot 10^5$$$).
The second line of input data contains the string $$$s$$$ itself, consisting of the letters a' and b'.
Print a single non-negative integer — the size of the longest substring of string $$$s$$$, which is «perfectly protected».
In this problem there is a subtask scores. Score for a subtask are counted only if all tests for that subtask are passed. The subtasks are listed in the following table:
| № | Constraints | Scores for the subtask |
| 1 | $$$n \le 3$$$ | 7 |
| 2 | $$$n \le 300$$$ | 15 |
| 3 | $$$n \le 3000$$$ | 27 |
| 4 | $$$n \le 1.5 \cdot 10^5$$$ | 32 |
| 5 | No additional constraints | 19 |
9 abbababba
4
12 aaabbaabbaaa
8
10 aabbbabbaa
4
10 aabbbaaabb
10
7 aaaaaaa
0
In the first test case, for example, baba can be selected as a substring.
In the second test case, for example, bbaabbaa can be selected as a substring.
In the third test case, for example, bbaa can be selected as a substring.
Alexander asks you to solve the following problem:
He has an array $$$a$$$ of $$$n$$$ positive integers. Now he wants you to answer $$$q$$$ queries. The $$$i$$$-th query contains two positive integers $$$l_i$$$ and $$$r_i$$$ ($$$1 \le l_i \le r_i \le n$$$). Alexander asks you to find the number of divisors of $$$a_{l_i} \cdot a_{l_i + 1} \cdot \ldots \cdot a_{r_i}$$$, that is, the number of divisors of the product of numbers on the segment $$$[l_i, r_i]$$$.
Since the answers can be very large, print them modulo $$$10^9 + 7$$$.
The first line contains two integers $$$n$$$ and $$$q$$$ ($$$1 \le n \le 10^5, 1 \le q \le 10^5$$$) —the number of numbers and queries, respectively.
The second line contains $$$n$$$ integers $$$a_i$$$ ($$$1 \le a_i \le 10^7$$$) — elements of the array $$$a$$$.
Then $$$q$$$ lines each contains two integers $$$l_i$$$ and $$$r_i$$$ ($$$1 \le l_i \le r_i \le n$$$) — parameters of $$$i$$$th query.
Print query responses, one response per query in separate line.
In this problem there is a subtask scores. Score for a subtask are counted only if all tests for that subtask are passed. The subtasks are listed in the following table:
| № | Constraints | Scores for the subtask |
| 1 | $$$n \le 4$$$, $$$a_i \le 100$$$, $$$q \le 10$$$ | 9 |
| 2 | $$$n \le 6$$$, $$$a_i \le 500$$$, $$$q \le 10$$$ | 7 |
| 3 | $$$a_i \le 10^5$$$, $$$l_i = r_i$$$ | 8 |
| 4 | $$$l_i = r_i$$$ | 9 |
| 5 | $$$n \le 100$$$, $$$a_i \le 10^4$$$, $$$q \le 100$$$ | 14 |
| 6 | $$$n \le 3000$$$, $$$a_i \le 10^5$$$, $$$q \le 3000$$$ | 17 |
| 7 | $$$a_i \le 100$$$ | 14 |
| 8 | $$$a_i \le 10^5$$$ | 9 |
| 9 | No additional constraints | 13 |
7 5 4 6 1 1 5 12 9 1 7 2 5 3 3 2 5 3 6
60 8 1 8 12
Consider the answer to the fifth query. $$$a_3 \cdot a_4 \cdot a_5 \cdot a_6 = 60$$$. The number $$$60$$$ has the following divisors: $$$1$$$, $$$2$$$, $$$3$$$, $$$4$$$, $$$5$$$, $$$6$$$, $$$10$$$, $$$12$$$, $$$15$$$, $$$20$$$, $$$30$$$, $$$60$$$.