Aryan discovered that he might be at risk of Jeffersonoma, a devastating cellular disease, because his cells may carry out mitosis incorrectly. Mitosis is the process by which a cell splits into two daughter cells.
Specifically, he is concerned about the possibility that the chromosomes in his cells may not split properly. He has decided to measure the number of chromosomes of a cell sample before and after mitosis.
While normal human cells have $$$46$$$ chromosomes, Aryan's cells have $$$c$$$ chromosomes, where $$$c$$$ is positive integer. Aryan observes his sample cell splits into two daughter cells with $$$a$$$ and $$$b$$$ chromosomes respectively. The cell has correctly split if and only if $$$a$$$ and $$$b$$$ add up to $$$c$$$. If not, Aryan may be at risk of Jeffersonoma.
Aryan gives you the values of $$$a$$$, $$$b$$$, and $$$c$$$. Determine if he is not at risk for Jeffersonoma.
The first line of the input will contain three integers $$$a$$$, $$$b$$$, and $$$c$$$ ($$$1 \leq a, b, c \leq 100$$$).
Print "YES" (without quotes) if Aryan is at not at risk for Jeffersonoma and "NO" otherwise.
45 93 39
NO
39 21 60
YES
A Neural Network is a powerful Machine Learning technique that is inspired by the human brain. A Neural Network consists of several layers of nodes where information is passed through edges connecting the nodes.
More specifically, Akash is working with a Neural Network with $$$n$$$ layers, where the $$$i$$$-th layer has $$$a_i$$$ nodes. For every two adjacent layers, there is an edge connecting all pairs of nodes between one layer to the other layer. In other words, if two layers have $$$x$$$ and $$$y$$$ nodes, respectively, then a total of $$$x \cdot y$$$ edges will connect those layers.
Given the structure of his Neural Network, find the total number of edges needed to connect each pair of adjacent layers.
The first line of the input will contain $$$n$$$ ($$$1 \leq n \leq 1000$$$), the number of layers in the Neural Network.
The next line will contain the $$$n$$$ integers $$$a_1 \dots a_n$$$ ($$$1 \leq a_i \leq 1000$$$) representing the number of nodes in each layer.
Print a single integer, the total number of edges needed.
43 5 2 7
39
In the sample test case, a total of $$$39$$$ edges are needed.
So the total number of edges needed is $$$15 + 10 + 14 = 39$$$.
An organism's DNA can be represented by a string consisting of the characters "A", "T", "C", and "G". Due to the structure of DNA, "A" pairs with "T" and "C" pairs with "G", and these are called complementary pairs.
Daniel has sequenced a specific gene from an organism and has determined its DNA corresponds to the string $$$X$$$ with length $$$n$$$. He wants to compare this string to the target DNA $$$Y$$$ which is also a string of length $$$n$$$.
Daniel knows that because of mutations, the strings $$$X$$$ and $$$Y$$$ may not be equal. However, he hypothesizes that the only type of mutation that $$$X$$$ has is swapping complementary pairs. For example, a character "G" in the $$$i$$$-th location in $$$Y$$$ may have mutated into a character "C" at that same location but not a character "A", since "A" and "G" are not complementary.
Given both strings $$$X$$$ and $$$Y$$$, help Daniel determine whether his hypothesis is correct.
The first line will contain an integer $$$n$$$ ($$$1 \leq n \leq 10^5$$$) the length of the DNA sequence.
The second line will contain the string $$$X$$$ ($$$\lvert X \rvert = n$$$), the gene Daniel has sequenced.
The third line will contain the string $$$Y$$$ ($$$\lvert Y \rvert = n$$$), the target gene Daniel wants to compare to.
It is guaranteed that both $$$X$$$ and $$$Y$$$ only consist of the characters "A", "T", "C", and "G".
Print "YES" (without quotes) if Daniel's hypothesis is correct and the only mutations are complementary pair swaps and "NO" otherwise.
8GCAAGCCTCCATCCCT
YES
10CGTATGGACAATACTCACCA
NO
This is the easy version of the problem. The only difference between the easy and hard versions is the constraint on $$$n$$$. Solutions that pass under the time limit for the easy version may not pass the hard version.
Sritan has recently been investigating the predatory relationships of the TJ ecosystem. He has discovered that the $$$i$$$-th animal can be given a predator factor of $$$p_i$$$, which is a positive integer.
He learns that animals will prey on other animals based on their relative predator factors. An animal $$$i$$$ will prey on animal $$$j$$$ if the difference between $$$p_i$$$ and $$$p_j$$$ is at least $$$a$$$. However, if this difference is $$$b$$$ or more, animal $$$i$$$ considers the animal $$$j$$$ to be too weak and will not eat it.
There are $$$n$$$ animals in the TJ ecosystem. For each animal, find the number of predators and prey that it has.
The first line of the input contains three integers $$$n$$$, $$$a$$$, $$$b$$$ ($$$1 \leq n \leq 2 \cdot 10^3$$$, $$$1 \leq a \lt b \leq 10^9$$$).
The second line contains the $$$n$$$ integers $$$p_1 \dots p_n$$$ ($$$1 \leq p_i \leq 10^9$$$) representing the animals' predator factors.
Print $$$n$$$ lines. On the $$$i$$$-th line, print $$$2$$$ integers corresponding to the number of predators and the number of prey that animal $$$i$$$ has.
5 3 78 6 5 14 12
2 1 1 0 1 0 0 1 0 2
In the sample test case, animal $$$1$$$ will have $$$2$$$ predators (animals $$$4$$$ and $$$5$$$) and $$$1$$$ prey (animal $$$3$$$). Animal $$$4$$$ has only one prey (animal $$$1$$$) since animals $$$2$$$ and $$$3$$$ are too weak for it to eat.
This is the hard version of the problem. The only difference between the easy and hard versions is the constraint on $$$n$$$. Solutions that pass under the time limit for the easy version may not pass the hard version.
Sritan has recently been investigating the predatory relationships of the TJ ecosystem. He has discovered that the $$$i$$$-th animal can be given a predator factor of $$$p_i$$$, which is a positive integer.
He learns that animals will prey on other animals based on their relative predator factors. An animal $$$i$$$ will prey on animal $$$j$$$ if the difference between $$$p_i$$$ and $$$p_j$$$ is at least $$$a$$$. However, if this difference is $$$b$$$ or more, animal $$$i$$$ considers the animal $$$j$$$ to be too weak and will not eat it.
There are $$$n$$$ animals in the TJ ecosystem. For each animal, find the number of predators and prey that it has.
The first line of the input contains three integers $$$n$$$, $$$a$$$, $$$b$$$ ($$$1 \leq n \leq 2 \cdot 10^5$$$, $$$1 \leq a \lt b \leq 10^9$$$).
The second line contains the $$$n$$$ integers $$$p_1 \dots p_n$$$ ($$$1 \leq p_i \leq 10^9$$$) representing the animals' predator factors.
Print $$$n$$$ lines. On the $$$i$$$-th line, print $$$2$$$ integers corresponding to the number of predators and the number of prey that animal $$$i$$$ has.
5 3 78 6 5 14 12
2 1 1 0 1 0 0 1 0 2
In the sample test case, animal $$$1$$$ will have $$$2$$$ predators (animals $$$4$$$ and $$$5$$$) and $$$1$$$ prey (animal $$$3$$$). Animal $$$4$$$ has only one prey (animal $$$1$$$) since animals $$$2$$$ and $$$3$$$ are too weak for it to eat.
Jasmine has recently learned that the mitochondria are the powerhouse of the cell and produce ATP, which is the energy currency of your body. Since Jasmine is healthy and fit, her mitochondria produce $$$m$$$ ATP each day.
Jasmine has to do $$$n$$$ tasks today, numbered from $$$1$$$ to $$$n$$$ from highest to lowest priority. The $$$i$$$-th task costs $$$a_i$$$ ATP. Since some tasks have higher priority than others, Jasmine will choose some integer $$$k$$$ and only consider doing the $$$k$$$ tasks with the highest priority. Out of the tasks she considers, she tries to complete the most possible tasks. Jasmine cannot do the same task more than once.
For each $$$k$$$ from $$$1$$$ to $$$n$$$, find the maximum number of tasks that Jasmine could complete if she only considers the $$$k$$$ tasks with the highest priority.
The first line of the input will contain two integers $$$n$$$ and $$$m$$$ ($$$1 \leq n \leq 2 \cdot 10^5$$$, $$$1 \leq m \leq 10^9$$$).
The second line of the input will contain $$$n$$$ integers $$$a_1 \dots a_n$$$ ($$$1 \leq a_i \leq 10^9$$$).
For each $$$k$$$ from $$$1$$$ to $$$n$$$, print the maximum number of tasks that Jasmine can complete with $$$m$$$ ATP if she only considers the first $$$k$$$ tasks.
5 1514 15 11 4 4
1 1 1 2 2
Sanchali is a researcher who wants to protect an endangered species of trees. Their habitat consists of $$$n$$$ forests arranged in a line, where the $$$i$$$-th forest has a density of $$$t_i$$$.
Unfortunately, this habitat is very vulnerable to wildfires. A forest is either healthy or is burning with a wildfire of some integer strength $$$k \gt 0$$$. Wildfires can spread to adjacent forests (forests $$$i$$$ and $$$j$$$ are adjacent if $$$\lvert i - j \rvert = 1$$$).
For a pair of adjacent forests $$$i$$$ and $$$j$$$, if forest $$$i$$$ is healthy but forest $$$j$$$ has a wildfire of strength $$$k$$$, then a wildfire of strength $$$k'$$$ starts in forest $$$i$$$, where
$$$k' = \begin{cases} k+1 & k \lt t_i \\ k & k = t_i \\ k-1 & k \gt t_i \\ \end{cases} $$$
If $$$k' = 0$$$, no fire starts.
For each $$$i$$$ from $$$1$$$ to $$$n$$$, find the minimum strength needed for a wildfire to start at forest $$$i$$$ and burn all of the $$$n$$$ forests in the habitat.
The first line of the input will contain an integer $$$n$$$ ($$$1 \leq n \leq 5 \cdot 10^5$$$) representing the number of forests.
The second line will contain $$$n$$$ integers $$$t_1 \dots t_n$$$ ($$$0 \leq t_i \leq n$$$) representing the density of trees in each forest.
Print $$$n$$$ integers representing the minimum strength needed for a wildfire to start at each forest and burn all the forests in the habitat.
70 0 3 1 2 0 5
2 2 3 2 3 4 5
In the sample, a wildfire starting at forest $$$1$$$ can burn all of the $$$n$$$ forests with strength $$$2$$$.
Thus, the wildfire will reach all $$$n$$$ forests. On the other hand, if a wildfire with strength $$$1$$$ started at forest $$$1$$$, it would not be able to spread to forest $$$2$$$.
Dr. Zarif is studying the genome of a certain prokaryote and has developed an ingenious gene editing technology called the Lateral Omni-genomic Precision Integration and Targeting Apparatus and Laboratory (LOPITAL) to assist him.
An RNA strand is a string of nucleotides that are represented by one of the characters "A", "U", "C", or "G" which can be either circular or linear. For the organism that he is currently studying, Dr. Zarif is more interested in the number of linear RNA strands and doesn't care about circular RNA.
Dr. Zarif is planning to carry out some tests on the organism's genome, which is initially a single circular strand of RNA with $$$n$$$ nucleotides. Using LOPITAL, Dr. Zarif will do $$$q$$$ cumulative operations on the RNA, where each operation is one of the following types:
Note that since RNA strands are not bidirectional, cuts between $$$x$$$ and $$$y$$$ are not the same as between $$$y$$$ and $$$x$$$, and similarly for splices.
Dr. Zarif is interested in knowing the maximum possible number of linear RNA strands that could exist after each operation. Given the nucleotide sequence of the original circular RNA strand and the $$$q$$$ operations he performs, help Dr. Zarif compute these values.
The first line of the input will contain the integers $$$n$$$, $$$q$$$ ($$$1 \leq n, q \leq 2 \cdot 10^5$$$).
The second line will contain a string of length $$$n$$$ consisting of RNA nucleotides: the RNA strand used by Dr. Zarif.
The next $$$q$$$ lines each contain one operation that Dr. Zarif performs. An operation is described with three strings $$$t$$$, $$$x$$$, and $$$y$$$.
If $$$t$$$ is the string "CUT", then Dr. Zarif will use LOPITAL to make a cut between nucleotides $$$x$$$ and $$$y$$$.
If $$$t$$$ is the string "SPLICE", then Dr. Zarif will use LOPITAL to splice strands between nucleotides $$$x$$$ and $$$y$$$.
Print $$$q$$$ lines, where the $$$i$$$-th line contains the maximum possible number of linear strands after the first $$$i$$$ operations.
9 4 GGAAUGUCA CUT U C CUT G G SPLICE U G CUT A G
1 2 1 2
20 10 GAAUUCAUAUUCAGGCGGCC SPLICE C G CUT U C SPLICE G U CUT U A SPLICE C A SPLICE G G SPLICE U C CUT G U SPLICE C U CUT A U
0 2 2 3 3 3 1 1 1 4
In the first sample test case, the operations have the following effects.
Dr. Vijayram has an infinite grid of agar to grow bacteria. This grid can be represented by the $$$xy$$$-plane where bacteria can grow at integer coordinates. Every minute, each living bacteria on the grid can spread to any number of adjacent locations$$$^\dagger$$$ (including not spreading at all). A bacteria might also die and be decomposed after spreading.
To prepare for future experiments, Dr. Vijayram had sterilized the grid. Unfortunately, the grid was contaminated $$$t$$$ minutes ago by a bacteria at the point $$$(x_0, y_0)$$$. Dr. Vijayram doesn't know what $$$t$$$, $$$x_0$$$, and $$$y_0$$$ are, but he can tell you the locations of all bacteria that are currently alive. Help him find the lexicographically minimum valid tuple $$$(t, x_0, y_0)$$$ that is consistent with Dr. Vijayram's observations.
$$$^\dagger$$$Two points $$$(x_1, y_1)$$$ and $$$(x_2, y_2)$$$ are adjacent if $$$\lvert x_1 - x_2 \rvert + \lvert y_1 - y_2 \rvert = 1$$$.
The first line of the input will contain the integer $$$n$$$ ($$$1 \leq n \leq 2 \cdot 10^5$$$) representing the number of living bacteria.
Each of the next $$$n$$$ lines will contain two integers $$$x_i$$$ and $$$y_i$$$ ($$$1 \leq x_i, y_i \leq 10^9$$$).
Print three integers $$$t$$$, $$$x_0$$$, and $$$y_0$$$, a valid time and location for the initial bacteria contamination that is the lexicographically minimum possible.
67 14 16 11 105 74 5
8 1 3
In the sample test case, it can be shown that a bacteria can start at $$$(1, 3)$$$ and spread to each of the $$$n$$$ locations in $$$8$$$ minutes and that $$$(8, 1, 3)$$$ is the lexicographically minimum achievable tuple.
Medha is a researcher who is investigating a certain species of monkeys. These species have two characteristics of interest to researchers: a fitness score (represented by a positive integer) and a special OP gene. The OP gene has the property that at any given time, it is present in exactly one species of monkeys.
At the beginning of every epoch, a new species of monkey evolves and branches off from each existing species, but the original species also continues to exist. The only exception is the species that currently contains the OP gene, in which case a new species may or may not evolve from it.
Let's call the new species the child and the species it evolved from the parent. Since evolution is very effective at producing beneficial adaptations, the child species will always have a higher fitness score than its parent species.
In the present day, there are $$$n$$$ different species of monkeys where the $$$i$$$-th species has a fitness score of $$$i$$$. It is known that all species evolved at exactly one time in history and evolved from one parent species. Species $$$1$$$ is an ancestor of all other species.
Count the number of distinct evolutionary pathways modulo $$$998244353$$$. Two pathways are distinct if there are two species with the same fitness score that evolved from different parent species.
The first line of the input will contain an integer $$$t$$$ ($$$1 \leq t \leq 2 \cdot 10^5$$$), the number of test cases.
The next $$$t$$$ lines of the input will each contain an integer $$$n$$$ ($$$1 \leq n \leq 2 \cdot 10^5$$$).
Note that there is no constraint on the sum of $$$n$$$ over all test cases.
Print $$$t$$$ lines, the number of distinct evolutionary pathways for each testcase. Make sure to print your answer modulo $$$998244353$$$.
323100000
1 3 725526327
For the case when $$$n=3$$$, there are $$$3$$$ possibilities.
Note that the following situation is impossible.
This is because of the constraint that the child species will always have a higher fitness score than its parent species.