Today is Rajaee's birthday!! $$$Who$$$ $$$Asked?$$$
Sadly, no one remembered his birthday, so he decided to make a birthday cake by himself. He went searching in the kitchen for suitable ingredients, but unfortunately, he found nothing but an array of positive integer numbers. He is going to make a cake out of this array using the following technique:
Rajaee is wondering in how many ways he can divide the array into smaller subarrays such that he can make a cake out of it. Rajaee is too bad at maths so he needs your help to know the number of ways modulo $$$10^9 + 7$$$.
Two ways are considered different if there exists an element with index $$$i$$$ belonging to two different subarrays in each way.
The first line contains a single integer number $$$N$$$ $$$(3 \le N \le 10^6)$$$, the size of the array.
The second line contains $$$N$$$ integer numbers $$$a_1, a_2,.., a_N$$$ $$$(1 \le a_i \le 10^9)$$$, the elements of the array.
Output the number of ways modulo $$$10^9 + 7$$$.
33 4 5
1
61 5 2 4 1 2
18
107 2 3 5 8 3 1 9 4 5
436
Omar and Ahmed are playing with an infinite deck of cards. Each card has a single-digit number written on it (ranging from $$$1$$$ to $$$9$$$).
Ahmed teaches Omar a new trick. Here are the steps:
Given the remaining cards in the deck (after all transformations) except the hidden card, can you determine the hidden one?
It is guaranteed that the answer always exists
The order of the number is not important, for example the $$$[1$$$ $$$8$$$ $$$1$$$ $$$5$$$ $$$6$$$ $$$2$$$ $$$1]$$$ and $$$[1$$$ $$$8$$$ $$$1$$$ $$$5$$$ $$$6$$$ $$$1$$$ $$$2]$$$ give the same answer which is $$$3$$$
The first line contains one integer number $$$(1 \le T \le 10^4)$$$, the number of test cases.
The first line of each test case contains $$$2$$$ integers $$$n, m$$$ $$$(2 \le n \le 33, 2 \le m \le 10^6)$$$.
The second line contains $$$m$$$ integers $$$a_1,a_2,..,a_m (1 \le a_i \le 9)$$$.
An additional constraint on the input: the sum of $$$m$$$ over all test cases doesn't exceed $$$10^6$$$.
It is guaranteed that the set of cards is always a valid set
For each test case, print a single integer — The card Omar has hidden.
12 71 8 1 5 6 2 1
3
In the first test case:
Yaman, the proud owner of a spirited Arabian horse, set out on a journey through the enchanting desert. Aware of his horse's hearty appetite, Yaman scattered food dishes along the path, each with its own eating time and position.
The food dishes are numbered from $$$1$$$ to $$$n$$$, and each food dish has two numbers $$$p_i$$$ and $$$t_i$$$, the position and the number of minutes needed to eat the $$$i$$$-th dish respectively.
The horse starts at position $$$0$$$ and it can move forward and can't go back. Also, every step the horse takes forward would consume an additional minute.
As is known, the Arabian horse is intelligent, so it will choose the maximum number of dishes possible to eat during the $$$D$$$-minute journey.
With time ticking away, Yaman aimed to determine the maximum number of dishes his Arabian horse could relish during the journey. Help Yaman determine it.
The first line contains the number of test cases $$$t$$$ $$$( 1 \le t \le 10^{5} )$$$. A description of the test cases follows.
The first line of each test case contains three integers $$$n$$$ $$$( 1 \le n \le 10^{5} )$$$, $$$( 1 \le D \le 10^{9} )$$$ — the number of food dishes and the journey duration in minutes respectively.
The next line contains $$$n$$$ integers $$$p_i$$$ $$$( 1 \le p_i \le 10^{9})$$$ — the position of the $$$i$$$-th dish.
The next line contains $$$n$$$ integers $$$t_i$$$ $$$( 1 \le t_i \le 10^{9})$$$ — the number of minutes needed to eat the $$$i$$$-th dish.
It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$10^{5}$$$, and it is guaranteed that all positions $$$p_i$$$ are unique.
For each test case, print the maximum number of dishes that the horse could eat.
25 101 2 3 4 51 1 1 1 25 101 2 3 4 51 1 1 1 1
4 5
Uncle Eyad is a Linux creep and his friend Jaber has always begged him to switch to Windows and he finally did!! Eyad works for the uncleship company owned and managed by his boss Hosen the grand uncle, and he is in control of the company's database system. Hosen usually gives Eyad queries to the database, and Eyad usually responds to them and maintains the database easily using Linux, but not anymore!!
As a good friend of Eyad, he asked you to help him respond to Hosen's queries and maintain the database accordingly.
Initially, the database is empty, Hosen gives Eyad $$$Q$$$ uncly queries one by one, and the queries have $$$5$$$ different types as described in the following:
The first line contains a single integer number $$$Q$$$ $$$(1 \le Q \le 2 * 10^5)$$$. The following $$$Q$$$ lines contain the description of the queries in the previous format in the problem statement.
For each query of the $$$5$$$-th type, output the answer to it.
131 a 31 b 61 ab 51 ca 21 ac 101 aba 15 caba 3 62 25 caba 3 63 1 4 25 caba 3 64 6 6 55 caba 3 6
4 3 0 1
George enjoys playing old classic games. One day, he started playing the popular game called "General Zero Hour" on his computer. While playing the game, he encountered a problem and had to stop.
In the game, George has a certain number of soldiers, denoted by $$$n$$$. Each soldier is assigned a power level, denoted by $$$a_i$$$. Now, George needs to divide these soldiers into groups, while adhering to the following two conditions:
Can you help George with this problem so he can continue playing?
The first line contains the number of test cases $$$t$$$ $$$( 1 \le t \le 10^{5} )$$$. A description of the test cases follows.
The first line of each test case contains a single integer $$$n$$$ $$$( 1 \le n \le 10^{5} )$$$ indicating the number of soldiers.
The second line of each test case contains $$$n$$$ integers $$$a_1,a_2,...,a_n$$$ $$$( 0 \le a_i \lt 2^{60} )$$$ , $$$a_i$$$ indicates the power of the soldier $$$i$$$ .
It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$10^{5}$$$.
For each test case, print the minimum number of groups.
161 2 3 4 5 6
3
In the old city of Damascus, two ancient arrays, $$$a$$$ and $$$b$$$, each of length $$$n$$$, have been discovered by the greatest professor in his prime, George The Great
The legend whispers of a unique measure of beauty for these arrays:
We ask you to print the maximal beauty you can get of the two arrays after rearrangement of the array $$$a$$$.
The first line contains one integer number $$$(1 \le T \le 100)$$$ the number of test cases.
The first line of each test case contains an integer $$$(1 \le n \le 500)$$$.
The second line contains $$$n$$$ integers $$$a_1,a_2,..,a_n (1 \le a_i \le 10^6)$$$. The third line contains $$$n$$$ integers $$$b_1,b_2,..,b_n (1 \le b_i \le 10^6)$$$.
An additional constraint on the input: the sum of $$$n$$$ over all test cases does not exceed $$$500$$$.
For each test case, print a single integer — The maximal beauty of $$$a$$$ and $$$b$$$, or $$$-1$$$ if there is no suitable arrangement.
236 10 121 2 331 2 33 3 3
4 -1
In the city of contests, Yaman managed a popular storage facility called "Secure Storages" with a range of lockers numbered from $$$1$$$ to $$$n$$$. Contestants relied on Secure Storages to securely store their belongings.
One day, Yaman received $$$q$$$ requests from individuals, each with an ID from $$$1$$$ to $$$m$$$. These requests specified the desired locker number and a time interval for rental.
In other words, Yaman received $$$q$$$ requests, and each request contains three numbers $$$x, l, r$$$, which means that the locker $$$x$$$ will be rented at the time $$$[l, r]$$$.
Yaman faced the challenge of assigning lockers without any intersections or conflicts and was determined to provide excellent service. Yaman carefully reviewed the requests. He aimed to delete at most one request, allowing for a seamless locker assignment process. Yaman's goal was to ensure that no locker was shared by multiple requests at the same time.
Help Yaman determine if he can achieve his goal.
The first line contains the number of test cases $$$t$$$ $$$( 1 \le t \le 10^{3} )$$$. A description of the test cases follows.
The first line of each test case contains two integers $$$n, q$$$ $$$( 1 \le n, q \le 10^{3} )$$$, — the number of lockers, and the number of requests, respectively.
Each of the next $$$q$$$ lines contains three integers $$$x_i, l_i, r_i$$$ $$$( 1 \le x_i \le n), (1 \le l \le r \le 10^{3})$$$ — the representation of the $$$i$$$-th request.
It is guaranteed that the sum of $$$q$$$ and the sum of $$$n$$$ over all test cases does not exceed $$$10^{3}$$$.
For each test case, print "YES" (without quotes) if Yaman can achieve his goal; otherwise, you have to print "NO" (without quotes).
23 51 1 52 1 22 2 33 1 52 4 52 51 1 52 1 22 2 32 1 52 4 5
YES NO
The contest arena is under attack ! George wants to save it, so he will use his special ability called "One Punch MEX".
George has $$$n$$$ power stones numbered from $$$1$$$ to $$$n$$$. For $$$n$$$ times the following action will happen in order:
George is wondering what will be the expected damage of the One Punch MEX if he has $$$n$$$ power stones
MEX is the minimum positive number not present in the set. MEX of $$$[]$$$ is $$$1$$$, MEX of $$$[3,5,1]$$$ is $$$2$$$
The first line contains the number of test cases $$$t$$$ $$$( 1 \le t \le 10^{5} )$$$. A description of the test cases follows
The first line of each test case contains a single integer $$$n$$$ $$$( 1 \le n \le 10^{5} )$$$ indicating the number of power stones
It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$10^{5}$$$
For each test case, output a single line containing the expected damage of One Punch MEX modulo $$$998244353$$$
212
1 499122179
In the second test case:
George has stones [1, 2]
With the probability $$$\frac{1}{2}$$$, the first stone will be removed, then the second stone with the sum of MEX equal to 2
With the probability $$$\frac{1}{2}$$$, the second stone will be removed, then the first stone with the sum of MEX equal to 3
The expected damage of One Punch MEX is $$$\frac{5}{2}$$$
Since coach Attal loves geometry problems, he tried to make an interesting problem to discuss it with DCPC community coaches. After discussing it, they came up with a simple solution. So they will tell you the problem.
You are given $$$n$$$ circles numbered from $$$1$$$ to $$$n$$$. Each circle is defined by an integer center $$$(x_i, y_i)$$$ and an integer radius $$$r_i$$$.
Then we will ask you $$$q$$$ questions. In each question, we will give you an integer point $$$(x_i, y_i)$$$, and you have to find the number of circles that cover this point.
The first line contains the number of test cases $$$t$$$ $$$( 1 \le t \le 10^{5} )$$$. A description of the test cases follows.
The first line of each test case contains two integers $$$n, q$$$ $$$( 1 \le n, q \le 10^{5} )$$$ — the number of circles, the number of questions, respectively.
Each of the next $$$n$$$ lines contains three integers $$$x_i, y_i, r_i$$$ $$$( 1 \le x_i, y_i \le 10^{5}), ( 1 \le r_i \le 10)$$$ — the center and the radius of the $$$i$$$-th circle.
Each of the next $$$q$$$ lines contains two integers $$$x_i, y_i$$$ $$$( 1 \le x_i, y_i \le 10^{5})$$$ — the point of the $$$i$$$-th question.
It is guaranteed that the sum of $$$q$$$ and $$$n$$$ over all test cases does not exceed $$$10^{5}$$$.
For each question $$$i$$$, print the number of circles that cover the point in the $$$i$$$-th question.
23 31 1 12 2 13 3 11 12 23 33 51 2 32 3 23 4 11 14 58 104 33 2
1 1 1 1 0 0 1 2
George is so excited to see an epic fight between the legends Ahmad and Yaman.
George gives them $$$n$$$ cells that are numbered from $$$1$$$ to $$$n$$$ where each cell $$$i$$$ and $$$i+1$$$ $$$(1 \le i \le n-1)$$$ are connected by a two-way road to play a game on them.
The game is going as follows: First of all, Yaman will choose a cell to put an egg on it and mark it as a visited cell, then they will take turns starting from Ahmad as follows:
Now Yaman is wondering how many cells he can choose so he can win.
The first line contains the number of test cases $$$t$$$ $$$( 1 \le t \le 10^{5} )$$$. A description of the test cases follows.
The first line of each test case contains a single integer $$$n$$$ $$$( 1 \le n \le 10^{18} )$$$ indicating the number of cells.
A single integer represents the number of winning starting cells for Yaman.
4137772
1 2 389 0
The final exams season of school is so close, and Ahmad is a teacher in some school, and his task is extremely boring. He has to sum up the marks of every student in all subjects to find the total score of the students. He wants help from you in summing up the marks. He will provide you the marks of $$$n$$$ students, and you have to sum them up for him. There are $$$8$$$ subjects in the school, so for every student, you will be given $$$8$$$ integers, and you have to print the total score.
The first line contains an integer $$$t$$$ $$$(1 \le t \le 100)$$$, the number of test cases.
Every test case consists of $$$n + 1$$$ lines. The first contains an integer $$$n$$$ $$$(1 \le n \le 100)$$$, the number of students that Ahmad will provide their marks.
Each of the next $$$n$$$ lines contains $$$8$$$ integers $$$[mark_{i1}, mark_{i2}, ..., mark_{i8}]$$$ $$$(1 \le mark_{ij} \le 100)$$$ — the mark of the $$$i$$$-th student in the $$$j$$$-th subject.
For every test case, you have to print $$$n$$$ integers each on a line, the total score of the student.
121 2 3 4 5 6 7 810 3 4 5 6 7 8 2
36 45
You are given a balanced bracket sequence of only $$$'('$$$ and $$$')'$$$ brackets of length $$$2n$$$, a value of $$$a_i$$$ is attached to every bracket, and for every two matched pair of brackets, they have the same value
For example, let the balanced bracket sequence be: $$$()(())()$$$ and the array $$$a$$$: $$$[1, 1, 5, 1, 1, 5, 2, 2]$$$, Notice that values at indexes $$$1$$$ and $$$2$$$ are same because the bracket of index $$$2$$$ is the one that closes the bracket at index $$$1$$$, values at indexes $$$3$$$ and $$$6$$$ are same because the bracket of the index $$$6$$$ is the one the closes the bracket at index $$$3$$$, and so on for every two matched pair in the balanced bracket sequence
You are also given two types of queries:
The query of type $$$1$$$ is as follows: $$$1$$$ $$$l_1$$$ $$$r_1$$$ $$$l_2$$$ $$$r_2$$$ $$$v$$$, where $$$l_1$$$ and $$$r_1$$$ are indexes of two matched brackets, $$$l_2$$$ and $$$r_2$$$ are also indexes of two matched brackets, in such query you have to add a value of $$$v$$$ to the value of every two matched brackets which their opening bracket is before or equal to $$$\min(l_1, l_2)$$$ and closing bracket is after or equal to $$$\max(r_1, r_2)$$$
Please note that it isn't necessary that $$$l1 \le l2$$$ nor $$$r1 \le l2$$$
The query of type $$$2$$$ is as follows: $$$2$$$ $$$l$$$ $$$r$$$, where $$$l$$$ and $$$r$$$ are indexes of two matched brackets, in such query you have to find the value of these two brackets, (note that always any two matched brackets will have the same value and you are asked to find this value, not the sum of values of the two brackets)
Refer to the notes and check the described example for better understanding
A balanced bracket sequence is a string consisting of only brackets, such that this sequence when inserted with certain numbers and mathematical operations, gives a valid mathematical expression
The first contains an integer $$$t$$$ $$$( 1 \le t \le 10^{5} )$$$ the number of testcases
In every test case you will read two integers $$$(1 \le n \le 5*10^{5})$$$ and $$$(1 \le q \le 5*10^{5})$$$, where $$$2n$$$ is the length of the string and $$$q$$$ is the number of queries
The second line of every testcase contains the string of brackets balanced bracket sequence, the length of the string is $$$2n$$$,
The third line of every testcase contains the array $$$a$$$ $$$(0 \le a_i \le 10^{9})$$$, the values attached to the brackets
The following $$$q$$$ lines contains the $$$q$$$ queries
It's guaranteed that all $$$ls$$$ and $$$rs$$$ in queries are between $$$1$$$ and $$$2n$$$, and the string forms a balanced bracket sequence with brackets of type $$$()$$$ only (doesn't contains brackets of other types like $$$[]$$$ or $$${}$$$)
It's guaranteed that the sum of $$$n$$$ and $$$q$$$ all test cases don't exceed $$$5*10^{5}$$$
For every testcase, for each query of type $$$2$$$ you have to print its answer as described above
15 4(()(())())3 1 1 5 1 1 5 2 2 32 4 71 2 3 4 7 52 1 102 2 3
5 8 1
Description of the given sample:
First query: $$$4$$$ $$$7$$$
The value of the matched pair at indexes $$$4$$$ and $$$7$$$ is $$$5$$$
Second query: $$$2$$$ $$$3$$$ $$$4$$$ $$$7$$$ $$$5$$$
The matched pair at indexes $$$1$$$ $$$10$$$ is the only matched pair of brackets that includes pairs $$$2$$$ $$$3$$$ and $$$4$$$ $$$7$$$ together, hence we increase its value by $$$5$$$ and the array of values after this query becomes: $$$8$$$ $$$1$$$ $$$1$$$ $$$5$$$ $$$1$$$ $$$1$$$ $$$5$$$ $$$2$$$ $$$2$$$ $$$8$$$
Third query: $$$1$$$ $$$10$$$
The value of the matched pair at indexes $$$1$$$ $$$10$$$ is $$$8$$$
Forth query: $$$2$$$ $$$3$$$
The value of the matched pair at indexes $$$2$$$ $$$3$$$ is $$$1$$$
Both Arab Collegiate Programming Contest and Aleppo Collegiate Programming Contest can be abbreviated with ACPC which could lead to ambiguity, but when you are in Aleppo Collegiate Programming Contest then ACPC should mean Aleppo Collegiate Programming Contest, one of your friends doesn't know that so you have to tell him what is the correct meaning of ACPC, with knowing that you are at Aleppo Collegiate Programming Contest
The input contains one string s $$$(1 \le |s| \le 10)$$$, the name of your friend
The output should be "Aleppo" (without quotes)
ahmad
Aleppo
hossain
Aleppo