Batata was visiting ZU for the first time, he introduced himself to the students, and asked them to print Hello Hello ZU
no input
print Hello Hello ZU
no input
Hello Hello ZU
Batata gave you an infinite straight line passing through two distinct integer points $$$A(x_1, y_1)$$$ and $$$B(x_2, y_2)$$$.
Find two distinct integer points $$$C(x_3, y_3)$$$ and $$$D(x_4, y_4)$$$ such that the infinite line passing through $$$C$$$ and $$$D$$$ is strictly parallel to the line passing through $$$A$$$ and $$$B$$$ (i.e., the two lines never intersect).
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 $$$x_1, y_1, x_2, y_2$$$ ($$$-1000 \le x_1, y_1, x_2, y_2 \le 1000$$$) — the coordinates of point $$$A$$$ and point $$$B$$$.
It is guaranteed that point $$$A$$$ and point $$$B$$$ are distinct (either $$$x_1 \neq x_2$$$ or $$$y_1 \neq y_2$$$).
For each test case, output four integers $$$x_3, y_3, x_4, y_4$$$ ($$$-10^9 \le x_3, y_3, x_4, y_4 \le 10^9$$$) — the coordinates of point $$$C$$$ and point $$$D$$$.
The following conditions must be met:
30 0 1 10 0 0 53 4 -2 1
0 1 1 2 1 0 1 5 3 5 -2 2
You are given a binary string $$$s$$$ of length $$$n$$$. The string is special: it contains exactly one 0 and $$$n-1$$$ 1s.
You need to process $$$q$$$ queries of the following two types:
Assume $$$1$$$-based indexing for all string positions.
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases.
The first line of each test case contains two integers $$$n$$$ and $$$q$$$ ($$$2 \le n \le 2 \cdot 10^5$$$; $$$1 \le q \le 2 \cdot 10^5$$$) — the length of the string and the number of queries.
The second line of each test case contains the binary string $$$s$$$ of length $$$n$$$.
It is guaranteed that $$$s$$$ contains exactly one 0.The following $$$q$$$ lines contain the queries. Each query is given as:
It is guaranteed that the sum of $$$n$$$ and the sum of $$$q$$$ over all test cases do not exceed $$$2 \cdot 10^5$$$
For each query of type $$$2$$$, output a single integer representing the index of the $$$k$$$-th 1. Print the answers for type $$$2$$$ queries separated by spaces. Output a newline after each test case.
25 4110112 31 12 12 43 20112 21 3
4 2 53
0xmar is exploring advanced string transformations. He defines the CharMex of a string as the first lowercase English letter in alphabetical order (a, b, c, ..., z) that does not appear in the string.
For example:
You are given a string $$$s$$$ of length $$$n$$$. Every character in $$$s$$$ is a lowercase English letter strictly between a and y (inclusive).
0xmar constructs a new string $$$t$$$ by calculating the CharMex for every possible contiguous substring of $$$s$$$. He appends these CharMex characters to $$$t$$$ in this exact order of substring indices $$$[i, j]$$$ (using $$$1$$$-based indexing):
Help 0xmar determine if the resulting string $$$t$$$ is a palindrome (reads the same forward and backward). Print YES if it is, and NO otherwise.
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 the string $$$s$$$, consisting of lowercase English letters from a to y.
It is guaranteed that the sum of the lengths of $$$s$$$ over all test cases does not exceed $$$2 \cdot 10^5$$$.
For each test case, output YES if the constructed string $$$t$$$ is a palindrome, and NO otherwise.
You can output "YES" and "NO" in any case (for example, strings "yES", "yes" and "Yes" will be recognized as a positive response).
9abcxabaababcaxayaaaba
NOYESNOYESNONOYESYESNO
Example Visualization for abc:
Let $$$s = \text{\texttt{abc}}$$$ ($$$n = 3$$$). We calculate the CharMex for each substring:
Result: The generated string is $$$t = \text{\texttt{bcdaaa}}$$$, which is not a palindrome (NO).
Void loves movies and has the ultimate home theater setup. However, this means he has to make his own popcorn—and Void is notoriously bad in the kitchen.
He has asked you to manage the tonjarah (pot) for him. You are given $$$n$$$ popcorn kernels. For the $$$i$$$-th kernel, you are given two integers: $$$P_i$$$ (the exact time it pops) and $$$B_i$$$ (the exact time it burns). A kernel is considered "perfect" if the pot is removed from the heat at time $$$T$$$ such that $$$P_i \le T \lt B_i$$$. It is guaranteed that $$$B_i \gt P_i$$$.
Find the best time $$$T$$$ to remove the pot from the heat to maximize the number of perfect popcorns for Void. If there are multiple times that yield the same maximum number of perfect popcorns, output the earliest possible time.
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases.
The first line of each test case contains a single integer $$$n$$$ ($$$1 \le n \le 10^5$$$), the number of kernels.
The next $$$n$$$ lines each contain two space-separated integers, $$$P_i$$$ and $$$B_i$$$ ($$$1 \le P_i \lt B_i \le 10^9$$$), representing the pop and burn times of the $$$i$$$-th kernel.
It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$2 \cdot 10^5$$$.
For each test case, print two space-separated integers on a new line: the maximum number of perfect popcorns, and the optimal time $$$T$$$ to remove the pot.
331 53 74 6410 2020 3015 2525 3521 22 3
3 42 151 1
In the first case, at $$$T=4$$$, all three kernels are perfect (since $$$1 \le 4 \lt 5$$$, $$$3 \le 4 \lt 7$$$, and $$$4 \le 4 \lt 6$$$).
In the second case, at $$$T=15$$$, the first and third kernels are perfect. At $$$T=25$$$, the third is burned.
In the third case, they do not overlap ($$$B_1 = P_2 = 2$$$). If $$$T=2$$$, the first kernel is already burned. So max perfect is 1 at $$$T=1$$$ (or $$$T=2$$$). The earliest is $$$T=1$$$.
Jebreel was strolling through his garden one day and decided to take up addition as a hobby for the day. Given two integers $$$a$$$ and $$$b$$$, output their sum.
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.
Each test case contains a single line with two integers $$$a$$$ and $$$b$$$ ($$$0 \le a, b \le 10^{100000}$$$).
It is guaranteed that the sum of the lengths of $$$a$$$ and $$$b$$$ over all test cases does not exceed $$$2 \cdot 10^5$$$.
For each test case, print a single integer — the value of $$$a + b$$$.
3111 123456 349 9
234 490 18
Jebreel has given you an array, you should do the following operation exactly once
remove all appearances of an integer x , what is the maximum sum of the array after the operation
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. 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 size of the array.
The second line of each test case contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$-10^9 \le a_i \le 10^9$$$) — the elements of the array.
It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$2 \cdot 10^5$$$.
For each test case, output a single integer — the maximum sum of the array after applying the operation exactly once.
451 2 3 -1 -24-5 -5 -5 -5610 10 10 5 5 23-1 2 -3
5 0 42 1
Hyasat is a dedicated software engineer who just inherited a legacy codebase. Upon running the linter, he discovers exactly $$$N$$$ warnings.To help clear the backlog, he has built two automated code-refactoring tools:
Because these tools are highly specialized, they will crash the entire system if they attempt to clear more warnings than are actually remaining.
Hyasat wants to completely eliminate all $$$N$$$ warnings using the minimum total number of tool runs.
Help him find the minimum number of times he needs to run his tools, or determine if it is impossible to clear exactly $$$N$$$ warnings without crashing the system.
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^5$$$) — the number of test cases.
Each test case consists of a single line containing one integer $$$n$$$ ($$$1 \le n \le 10^9$$$) — the number of warnings in the codebase.
For each test case, output a single integer: the minimum total number of tool runs required to clear exactly $$$n$$$ warnings. If it is impossible to clear the warnings exactly, output -1.
5101417324
223-14
Essam has recently discovered his love for arithmetic progressions. Today, he chose three positive integers $$$n$$$, $$$k$$$, and $$$l$$$.
He grabbed a marker and wrote two separate sequences on his whiteboard:
Essam is only interested in even numbers. He wants to find the total number of even integers written on his whiteboard across both sequences. If a number appears in both sequences, Essam writes it twice, and it should be counted twice. Given $$$n$$$, $$$k$$$, and $$$l$$$, help Essam find the total number of even integers.
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 three integers $$$n$$$, $$$k$$$, and $$$l$$$ ($$$1 \le n, k, l \le 10^9$$$).
For each test case, output a single integer — the total number of even integers written on the whiteboard.
34 2 35 3 510 4 6
6 4 20
Moon is playing a game against Batata. Moon has $$$N$$$ items. The $$$i$$$-th item has a power of $$$A_i$$$ and grants $$$C_i$$$ points if it successfully breaks Batata's $$$i$$$-th shield, which has a defense of $$$B_i$$$. Specifically, Moon earns $$$C_i$$$ points if his item's power $$$A_i \ge B_i$$$, and $$$0$$$ points otherwise.
Moon has a special ability: before the game starts, he can choose at most one of his items and change its power to exactly $$$X$$$. Batata will give Moon $$$Q$$$ independent queries.
For each query, Batata provides a modification value $$$X$$$. For each $$$X$$$, determine the maximum total points Moon can earn if he uses his special ability optimally.
The first line contains an integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — denoting the number of test cases.
For each test case:
The first line contains two integers $$$N, Q$$$ ($$$1 \le N, Q \le 2 \cdot 10^5$$$) — denoting the number of items and queries, respectively.
The second line contains $$$N$$$ integers $$$A_1, A_2, \ldots, A_N$$$ ($$$1 \le A_i \le 10^9$$$).
The third line contains $$$N$$$ integers $$$B_1, B_2, \ldots, B_N$$$ ($$$1 \le B_i \le 10^9$$$).
The fourth line contains $$$N$$$ integers $$$C_1, C_2, \ldots, C_N$$$ ($$$1 \le C_i \le 10^9$$$).
The next $$$Q$$$ lines each contain one integer $$$X$$$ ($$$1 \le X \le 10^9$$$) — denotes the given modification value for a query.
It is guaranteed that the sum of $$$N$$$ and the sum of $$$Q$$$ over all test cases do not exceed $$$2 \cdot 10^5$$$.
For each test case, output $$$Q$$$ lines. Each line should contain one integer, representing the maximum total points Moon can earn for the given modification value $$$X$$$.
15 41 2 4 5 63 1 5 8 71 5 5 2 13178
651010
Moon is playing a puzzle game designed by Aziz. Aziz gives him a permutation $$$a$$$ of length $$$n$$$.Moon can perform the following three-step operation on the permutation:
For example, if the permutation is $$$[1, 10, 4, 8, 7, 3, 5, 6, 2, 9]$$$ and Moon chooses a prefix of length $$$k=4$$$, the prefix $$$[1, 10, 4, 8]$$$ is reversed to $$$[8, 4, 10, 1]$$$ and moved to the back. The new permutation becomes $$$[7, 3, 5, 6, 2, 9, 8, 4, 10, 1]$$$. Note that if $$$n$$$ is chosen as the prefix length, the operation simply reverses the entire permutation.
Moon wants to sort the permutation in ascending order. He is looking for an efficient way to solve Aziz's puzzle. Help him find a sequence of at most $$$2n$$$ operations that sorts the permutation.
It can be shown that this is always possible
The first line of input contains a single integer $$$t$$$ ($$$1 \le t \le 5000$$$) — the number of test cases.
The first line of each test case contains a single integer $$$n$$$ ($$$1 \le n \le 5000$$$) — the length of the permutation $$$a$$$.
The second line of each test case contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \le a_i \le n$$$) — the permutation $$$a$$$.
It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$5000$$$.
For each test case, the first line of output should contain a single integer $$$q$$$ ($$$0 \le q \le 2n$$$) — the number of operations Moon will perform.
The second line should contain $$$q$$$ integers — the length of the prefix for each operation Moon performs, in order. After these operations, the permutation should be sorted.
If there are multiple valid solutions, you may print any of them.
253 2 1 5 431 2 3
84 1 1 2 3 1 1 531 1 1
zi is feeling incredibly sleepy during a late-night coding round. To stay awake, she has lined up $$$n$$$ cups of coffee on her desk. The $$$i$$$-th cup has a specific caffeine level represented by an integer $$$a_i$$$.
She knows her limits: to fully wake up and solve problems, she must drink exactly three cups of coffee that have the exact same caffeine level.
Given the caffeine levels of all $$$n$$$ cups, help zi find a caffeine level that appears at least three times so she can wake up. If no such caffeine level exists, print $$$-1$$$ so she knows it's time to give up and just go to sleep.
First line contains an integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases.
The first line of each test case contains contains an integer $$$n$$$ ($$$1 \le n \le 2*10^5$$$) — the total number of coffee cups on the desk.
Second line of each test case contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \le a_i \le n$$$) — the caffeine levels of each coffee cup.
For each test case, print any caffeine level that appears at least three times. If there is no such value, print $$$-1$$$.
51132 2 272 2 3 3 4 2 251 2 3 4 561 3 3 1 1 3
-1 2 2 -1 1
Batata and Moon have just discovered a massive treasure chest containing exactly $$$n$$$ ($$$n \ge 1$$$) golden coins. Unable to agree on who gets to keep the treasure, they decide to settle the dispute the only logical way: by playing a game.
The game is played with a single pile of $$$n$$$ coins. Batata and Moon take turns making moves, and Batata always goes first.
The rules for a single turn are as follows:
The player who is unable to make a valid move (because there are 0 coins left in the pile at the start of their turn) loses the game.
Assuming both Batata and Moon play optimally, determine who will win the game.
The first line of the input contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases.
Each test case consists of a single line containing one integer $$$n$$$ ($$$1 \le n \le 10^9$$$) — the initial number of coins in the pile.
For each test case, output the name of the winner on a new line: print "Batata" if Batata wins, or "Moon" if Moon wins.
2416
Batata Batata
In the first test case, there are $$$4$$$ coins. Batata can choose $$$k=2$$$ and remove exactly $$$2^2 = 4$$$ coins in a single action. The pile is now empty, so Moon cannot make a move. Batata wins.
In the second test case, there are $$$16$$$ coins. Batata can choose $$$k=4$$$ and remove exactly $$$2^4 = 16$$$ coins. Moon is left with $$$0$$$ coins and loses. Batata wins.