question large_stringlengths 265 13.2k |
|---|
Solve the programming task below in a Python markdown code block.
Allen is hosting a formal dinner party. $2n$ people come to the event in $n$ pairs (couples). After a night of fun, Allen wants to line everyone up for a final picture. The $2n$ people line up, but Allen doesn't like the ordering. Allen prefers if each ... |
Solve the programming task below in a Python markdown code block.
Consider the following array:
```
[1, 12, 123, 1234, 12345, 123456, 1234567, 12345678, 123456789, 12345678910, 1234567891011...]
```
If we join these blocks of numbers, we come up with an infinite sequence which starts with `112123123412345123456...`.... |
Solve the programming task below in a Python markdown code block.
Your wizard cousin works at a Quidditch stadium and wants you to write a function that calculates the points for the Quidditch scoreboard!
# Story
Quidditch is a sport with two teams. The teams score goals by throwing the Quaffle through a hoop, each... |
Solve the programming task below in a Python markdown code block.
You are given several queries. In the i-th query you are given a single positive integer ni. You are to represent ni as a sum of maximum possible number of composite summands and print this maximum number, or print -1, if there are no such splittings.
... |
Solve the programming task below in a Python markdown code block.
This is the easy version of the problem. The difference between the versions is in the constraints on the array elements. You can make hacks only if all versions of the problem are solved.
You are given an array [a_1, a_2, ..., a_n].
Your goal is to ... |
Solve the programming task below in a Python markdown code block.
3R2 as DJ Mashiro - Happiness Breeze Ice - DJ Mashiro is dead or alive
NEKO#Ξ¦ΟΞ¦ has just got a new maze game on her PC!
The game's main puzzle is a maze, in the forms of a $2 \times n$ rectangle grid. NEKO's task is to lead a Nekomimi girl from cell $... |
Solve the programming task below in a Python markdown code block.
There is a legend in the IT City college. A student that failed to answer all questions on the game theory exam is given one more chance by his professor. The student has to play a game with the professor.
The game is played on a square field consistin... |
Solve the programming task below in a Python markdown code block.
Implement a function which behaves like the uniq command in UNIX.
It takes as input a sequence and returns a sequence in which all duplicate elements following each other have been reduced to one instance.
Example:
```
["a", "a", "b", "b", "c", "a", ... |
Solve the programming task below in a Python markdown code block.
## Fixed xor
Write a function that takes two hex strings as input and XORs them against each other. If the strings are different lengths the output should be the length of the shortest string.
Hint: The strings would first need to be converted to bina... |
Solve the programming task below in a Python markdown code block.
When preparing a tournament, Codeforces coordinators try treir best to make the first problem as easy as possible. This time the coordinator had chosen some problem and asked $n$ people about their opinions. Each person answered whether this problem is ... |
Solve the programming task below in a Python markdown code block.
## Task:
Your task is to write a function which returns the sum of following series upto nth term(parameter).
Series: 1 + 1/4 + 1/7 + 1/10 + 1/13 + 1/16 +...
## Rules:
* You need to round the answer to 2 decimal places and return it as String.... |
Solve the programming task below in a Python markdown code block.
Country of Metropolia is holding Olympiad of Metrpolises soon. It mean that all jury members of the olympiad should meet together in Metropolis (the capital of the country) for the problem preparation process.
There are n + 1 cities consecutively numbe... |
Solve the programming task below in a Python markdown code block.
Pay attention to the non-standard memory limit in this problem.
In order to cut off efficient solutions from inefficient ones in this problem, the time limit is rather strict. Prefer to use compiled statically typed languages (e.g. C++). If you use Pyt... |
Solve the programming task below in a Python markdown code block.
Katsusando loves omelette rice.
Besides, he loves crème brûlée, tenderloin steak and so on, and believes that these foods are all loved by everyone.
To prove that hypothesis, he conducted a survey on M kinds of foods and asked N people whether they like... |
Solve the programming task below in a Python markdown code block.
Gildong is experimenting with an interesting machine Graph Traveler. In Graph Traveler, there is a directed graph consisting of n vertices numbered from 1 to n. The i-th vertex has m_i outgoing edges that are labeled as e_i[0], e_i[1], β¦, e_i[m_i-1], ea... |
Solve the programming task below in a Python markdown code block.
Imagine there's a big cube consisting of n^3 small cubes. Calculate, how many small cubes are not visible from outside.
For example, if we have a cube which has 4 cubes in a row, then the function should return 8, because there are 8 cubes inside our c... |
Solve the programming task below in a Python markdown code block.
After all the events in Orlando we all know, Sasha and Roma decided to find out who is still the team's biggest loser. Thankfully, Masha found somewhere a revolver with a rotating cylinder of n bullet slots able to contain exactly k bullets, now the boy... |
Solve the programming task below in a Python markdown code block.
Folding a Ribbon
Think of repetitively folding a very long and thin ribbon. First, the ribbon is spread out from left to right, then it is creased at its center, and one half of the ribbon is laid over the other. You can either fold it from the left to... |
Solve the programming task below in a Python markdown code block.
Ehab has an array $a$ of length $n$. He has just enough free time to make a new array consisting of $n$ copies of the old array, written back-to-back. What will be the length of the new array's longest increasing subsequence?
A sequence $a$ is a subseq... |
Solve the programming task below in a Python markdown code block.
Not so long ago company R2 bought company R1 and consequently, all its developments in the field of multicore processors. Now the R2 laboratory is testing one of the R1 processors.
The testing goes in n steps, at each step the processor gets some instr... |
Solve the programming task below in a Python markdown code block.
Zane the wizard had never loved anyone before, until he fell in love with a girl, whose name remains unknown to us.
[Image]
The girl lives in house m of a village. There are n houses in that village, lining in a straight line from left to right: hou... |
Solve the programming task below in a Python markdown code block.
In BerSoft $n$ programmers work, the programmer $i$ is characterized by a skill $r_i$.
A programmer $a$ can be a mentor of a programmer $b$ if and only if the skill of the programmer $a$ is strictly greater than the skill of the programmer $b$ $(r_a > ... |
Solve the programming task below in a Python markdown code block.
There are n cities in Bearland, numbered 1 through n. Cities are arranged in one long row. The distance between cities i and j is equal to |i - j|.
Limak is a police officer. He lives in a city a. His job is to catch criminals. It's hard because he doe... |
Solve the programming task below in a Python markdown code block.
Yurii is sure he can do everything. Can he solve this task, though?
He has an array $a$ consisting of $n$ positive integers. Let's call a subarray $a[l...r]$ good if the following conditions are simultaneously satisfied: $l+1 \leq r-1$, i.Β e. the sub... |
Solve the programming task below in a Python markdown code block.
The tram in Berland goes along a straight line from the point 0 to the point s and back, passing 1 meter per t_1 seconds in both directions. It means that the tram is always in the state of uniform rectilinear motion, instantly turning around at points ... |
Solve the programming task below in a Python markdown code block.
N tiles are arranged in a row from left to right. The initial color of each tile is represented by a string S of length N.
The i-th tile from the left is painted black if the i-th character of S is 0, and painted white if that character is 1.
You want t... |
Solve the programming task below in a Python markdown code block.
Given are a sequence of N positive integers A_1, A_2, \ldots, A_N, and a positive integer K.
Find the number of non-empty contiguous subsequences in A such that the remainder when dividing the sum of its elements by K is equal to the number of its eleme... |
Solve the programming task below in a Python markdown code block.
There are $n$ slimes in a row. Each slime has an integer value (possibly negative or zero) associated with it.
Any slime can eat its adjacent slime (the closest slime to its left or to its right, assuming that this slime exists).
When a slime with a ... |
Solve the programming task below in a Python markdown code block.
The sequence of $m$ integers is called the permutation if it contains all integers from $1$ to $m$ exactly once. The number $m$ is called the length of the permutation.
Dreamoon has two permutations $p_1$ and $p_2$ of non-zero lengths $l_1$ and $l_2$.
... |
Solve the programming task below in a Python markdown code block.
There are N pieces of sushi. Each piece has two parameters: "kind of topping" t_i and "deliciousness" d_i.
You are choosing K among these N pieces to eat.
Your "satisfaction" here will be calculated as follows:
- The satisfaction is the sum of the "bas... |
Solve the programming task below in a Python markdown code block.
Appleman has a tree with n vertices. Some of the vertices (at least one) are colored black and other vertices are colored white.
Consider a set consisting of k (0 β€ k < n) edges of Appleman's tree. If Appleman deletes these edges from the tree, then it... |
Solve the programming task below in a Python markdown code block.
Write a program which reads a sequence of $n$ integers $a_i (i = 1, 2, ... n)$, and prints the minimum value, maximum value and sum of the sequence.
Constraints
* $0 < n \leq 10000$
* $-1000000 \leq a_i \leq 1000000$
Input
In the first line, an inte... |
Solve the programming task below in a Python markdown code block.
Madoka wants to enter to "Novosibirsk State University", but in the entrance exam she came across a very difficult task:
Given an integer $n$, it is required to calculate $\sum{\operatorname{lcm}(c, \gcd(a, b))}$, for all triples of positive integers $... |
Solve the programming task below in a Python markdown code block.
The server in company A has a structure where N devices numbered 1, 2, ..., N are connected with N - 1 cables. The i-th cable connects Device U_i and Device V_i. Any two different devices are connected through some number of cables.
Each device v (1 \l... |
Solve the programming task below in a Python markdown code block.
Floating-Point Numbers
In this problem, we consider floating-point number formats, data representation formats to approximate real numbers on computers.
Scientific notation is a method to express a number, frequently used for numbers too large or too ... |
Solve the programming task below in a Python markdown code block.
You are given n integer numbers a_1, a_2, ..., a_n. Consider graph on n nodes, in which nodes i, j (iβ j) are connected if and only if, a_i AND a_jβ 0, where AND denotes the [bitwise AND operation](https://en.wikipedia.org/wiki/Bitwise_operation#AND).
... |
Solve the programming task below in a Python markdown code block.
Chain Disappearance Puzzle
We are playing a puzzle. An upright board with H rows by 5 columns of cells, as shown in the figure below, is used in this puzzle. A stone engraved with a digit, one of 1 through 9, is placed in each of the cells. When three ... |
Solve the programming task below in a Python markdown code block.
Vasya adores sport programming. He can't write programs but he loves to watch the contests' progress. Vasya even has a favorite coder and Vasya pays special attention to him.
One day Vasya decided to collect the results of all contests where his favori... |
Solve the programming task below in a Python markdown code block.
It is known that the area of a regular dodecagon inscribed in a circle of radius a is 3a^2.
Given an integer r, find the area of a regular dodecagon inscribed in a circle of radius r.
-----Constraints-----
- 1 \leq r \leq 100
- r is an integer.
----... |
Solve the programming task below in a Python markdown code block.
Berland has a long and glorious history. To increase awareness about it among younger citizens, King of Berland decided to compose an anthem.
Though there are lots and lots of victories in history of Berland, there is the one that stand out the most. K... |
Solve the programming task below in a Python markdown code block.
## The galactic games have begun!
It's the galactic games! Beings of all worlds come together to compete in several interesting sports, like nroogring, fredling and buzzing (the beefolks love the last one). However, there's also the traditional maratho... |
Solve the programming task below in a Python markdown code block.
In olden days finding square roots seemed to be difficult but nowadays it can be easily done using in-built functions available across many languages
.
Assume that you happen to hear the above words and you want to give a try in finding the square roo... |
Solve the programming task below in a Python markdown code block.
Some time ago Mister B detected a strange signal from the space, which he started to study.
After some transformation the signal turned out to be a permutation p of length n or its cyclic shift. For the further investigation Mister B need some basis, t... |
Solve the programming task below in a Python markdown code block.
We have two distinct integers A and B.
Print the integer K such that |A - K| = |B - K|.
If such an integer does not exist, print IMPOSSIBLE instead.
-----Constraints-----
- All values in input are integers.
- 0 \leq A,\ B \leq 10^9
- A and B are dis... |
Solve the programming task below in a Python markdown code block.
Of the real numbers, those with a circular decimal part and those with a finite number of digits can be expressed as fractions.
Given a real number that can be represented by a fraction, write a program that outputs an irreducible fraction equal to ... |
Solve the programming task below in a Python markdown code block.
Vasiliy is fond of solving different tasks. Today he found one he wasn't able to solve himself, so he asks you to help.
Vasiliy is given n strings consisting of lowercase English letters. He wants them to be sorted in lexicographical order (as in the d... |
Solve the programming task below in a Python markdown code block.
You are given $n$ one-dimensional segments (each segment is denoted by two integers β its endpoints).
Let's define the function $f(x)$ as the number of segments covering point $x$ (a segment covers the point $x$ if $l \le x \le r$, where $l$ is the lef... |
Solve the programming task below in a Python markdown code block.
The restaurant AtCoder serves the following five dishes:
- ABC Don (rice bowl): takes A minutes to serve.
- ARC Curry: takes B minutes to serve.
- AGC Pasta: takes C minutes to serve.
- APC Ramen: takes D minutes to serve.
- ATC Hanbagu (hamburger ... |
Solve the programming task below in a Python markdown code block.
Fox Ciel is playing a game. In this game there is an infinite long tape with cells indexed by integers (positive, negative and zero). At the beginning she is standing at the cell 0.
There are also n cards, each card has 2 attributes: length li and cost... |
Solve the programming task below in a Python markdown code block.
Xenia is a girl being born a noble. Due to the inflexibility and harshness of her family, Xenia has to find some ways to amuse herself.
Recently Xenia has bought $n_r$ red gems, $n_g$ green gems and $n_b$ blue gems. Each of the gems has a weight.
Now,... |
Solve the programming task below in a Python markdown code block.
Hideo Kojima has just quit his job at Konami. Now he is going to find a new place to work. Despite being such a well-known person, he still needs a CV to apply for a job.
During all his career Hideo has produced n games. Some of them were successful, s... |
Solve the programming task below in a Python markdown code block.
You want to make change for $ n $ cents. Assuming that you have infinite supply of coins of 1, 5, 10 and / or 25 cents coins respectively, find the minimum number of coins you need.
Constraints
* $ 1 \ le n \ le 10 ^ 9 $
Input
$ n $
The integer $... |
Solve the programming task below in a Python markdown code block.
You are given strings s and t, consisting of lowercase English letters.
You will create a string s' by freely rearranging the characters in s.
You will also create a string t' by freely rearranging the characters in t.
Determine whether it is possible t... |
Solve the programming task below in a Python markdown code block.
This year in Equestria was a year of plenty, so Applejack has decided to build some new apple storages. According to the advice of the farm designers, she chose to build two storages with non-zero area: one in the shape of a square and another one in th... |
Solve the programming task below in a Python markdown code block.
Your task is to shuffle a deck of n cards, each of which is marked by a alphabetical letter.
A single shuffle action takes out h cards from the bottom of the deck and moves them to the top of the deck.
The deck of cards is represented by a string as f... |
Solve the programming task below in a Python markdown code block.
Read problems statements in Mandarin Chinese, Russian and Vietnamese as well.
You are given two integer arrays A and B each of size N. Let us define interaction of arrays A and B to be the sum of A[i] * B[i] for each i from 1 to N.
You want to maximi... |
Solve the programming task below in a Python markdown code block.
Your friend is developing a computer game. He has already decided how the game world should look like β it should consist of n locations connected by m two-way passages. The passages are designed in such a way that it should be possible to get from any ... |
Solve the programming task below in a Python markdown code block.
Sometimes Mister B has free evenings when he doesn't know what to do. Fortunately, Mister B found a new game, where the player can play against aliens.
All characters in this game are lowercase English letters. There are two players: Mister B and his c... |
Solve the programming task below in a Python markdown code block.
<image>
There used to be a game called Joseph's potatoes. Let's say n people are participating. Participants form a circle facing the center and are numbered starting from 1. One hot potato is given to participant n (the large number 30 inside the fig... |
Solve the programming task below in a Python markdown code block.
There is a straight snowy road, divided into n blocks. The blocks are numbered from 1 to n from left to right. If one moves from the i-th block to the (i + 1)-th block, he will leave a right footprint on the i-th block. Similarly, if one moves from the ... |
Solve the programming task below in a Python markdown code block.
You have a new professor of graph theory and he speaks very quickly. You come up with the following plan to keep up with his lecture and make notes.
You know two languages, and the professor is giving the lecture in the first one. The words in both lan... |
Solve the programming task below in a Python markdown code block.
Write a function to calculate compound tax using the following table:
For $10 and under, the tax rate should be 10%.
For $20 and under, the tax rate on the first $10 is %10, and the tax on the rest is 7%.
For $30 and under, the tax rate on the first $1... |
Solve the programming task below in a Python markdown code block.
In music, if you double (or halve) the pitch of any note you will get to the same note again.
"Concert A" is fixed at 440 Hz, and every other note is defined based on that. 880 Hz is also an A, as is 1760 Hz, as is 220 Hz.
There are 12 notes in Wester... |
Solve the programming task below in a Python markdown code block.
Iβm planning to have a party on my birthday. Many of my friends will come to the party. Some of them will come with one or more pieces of cakes, but it is not certain if the number of the cakes is a multiple of the number of people coming.
I wish to en... |
Solve the programming task below in a Python markdown code block.
There are N bags, each containing two white balls. The i-th box contains two balls with integers x_i and y_i written on them, respectively.
For each of these bags, you will paint one of the balls red, and paint the other blue.
Afterwards, the 2N balls w... |
Solve the programming task below in a Python markdown code block.
Moamen and Ezzat are playing a game. They create an array $a$ of $n$ non-negative integers where every element is less than $2^k$.
Moamen wins if $a_1 \,\&\, a_2 \,\&\, a_3 \,\&\, \ldots \,\&\, a_n \ge a_1 \oplus a_2 \oplus a_3 \oplus \ldots \oplus a_n... |
Solve the programming task below in a Python markdown code block.
Given is a positive integer N. Consider repeatedly applying the operation below on N:
- First, choose a positive integer z satisfying all of the conditions below:
- z can be represented as z=p^e, where p is a prime number and e is a positive integer;
... |
Solve the programming task below in a Python markdown code block.
In the evening Polycarp decided to analyze his today's travel expenses on public transport.
The bus system in the capital of Berland is arranged in such a way that each bus runs along the route between two stops. Each bus has no intermediate stops. So ... |
Solve the programming task below in a Python markdown code block.
Evlampiy has found one more cool application to process photos. However the application has certain limitations.
Each photo i has a contrast v_{i}. In order for the processing to be truly of high quality, the application must receive at least k photos ... |
Solve the programming task below in a Python markdown code block.
Vladimir would like to prepare a present for his wife: they have an anniversary! He decided to buy her exactly $n$ flowers.
Vladimir went to a flower shop, and he was amazed to see that there are $m$ types of flowers being sold there, and there is unli... |
Solve the programming task below in a Python markdown code block.
Read problems statements in Mandarin Chinese, Russian and Vietnamese as well.
Zombies zombies everywhere!!Β
In a parallel world of zombies, there are N zombies. There are infinite number of unused cars, each of same model only differentiated by the the... |
Solve the programming task below in a Python markdown code block.
Write a program which reads an integer $S$ [second] and converts it to $h:m:s$ where $h$, $m$, $s$ denote hours, minutes (less than 60) and seconds (less than 60) respectively.
Constraints
* $0 \leq S \leq 86400$
Input
An integer $S$ is given in a l... |
Solve the programming task below in a Python markdown code block.
You are given four integer values $a$, $b$, $c$ and $m$.
Check if there exists a string that contains:
$a$ letters 'A';
$b$ letters 'B';
$c$ letters 'C';
no other letters;
exactly $m$ pairs of adjacent equal letters (exactly $m$ such positions $i$... |
Solve the programming task below in a Python markdown code block.
Your mission in this problem is to write a computer program that manipulates molecular for- mulae in virtual chemistry. As in real chemistry, each molecular formula represents a molecule consisting of one or more atoms. However, it may not have chemical... |
Solve the programming task below in a Python markdown code block.
Valera is a lazy student. He has m clean bowls and k clean plates.
Valera has made an eating plan for the next n days. As Valera is lazy, he will eat exactly one dish per day. At that, in order to eat a dish, he needs exactly one clean plate or bowl. ... |
Solve the programming task below in a Python markdown code block.
You are making your very own boardgame. The game is played by two opposing players, featuring a 6 x 6 tile system, with the players taking turns to move their pieces (similar to chess). The design is finished, now it's time to actually write and impleme... |
Solve the programming task below in a Python markdown code block.
Vasya is currently at a car rental service, and he wants to reach cinema. The film he has bought a ticket for starts in t minutes. There is a straight road of length s from the service to the cinema. Let's introduce a coordinate system so that the car r... |
Solve the programming task below in a Python markdown code block.
Burenka came to kindergarden. This kindergarten is quite strange, so each kid there receives two fractions ($\frac{a}{b}$ and $\frac{c}{d}$) with integer numerators and denominators. Then children are commanded to play with their fractions.
Burenka is ... |
Solve the programming task below in a Python markdown code block.
Shuseki Kingdom is the world's leading nation for innovation and technology. There are n cities in the kingdom, numbered from 1 to n.
Thanks to Mr. Kitayuta's research, it has finally become possible to construct teleportation pipes between two cities.... |
Solve the programming task below in a Python markdown code block.
Find the price of a product before tax such that, when the consumption tax rate is 8 percent and 10 percent, the amount of consumption tax levied on it is A yen and B yen, respectively. (Yen is the currency of Japan.)
Here, the price before tax must be ... |
Solve the programming task below in a Python markdown code block.
Every year, hundreds of people come to summer camps, they learn new algorithms and solve hard problems.
This is your first year at summer camp, and you are asked to solve the following problem. All integers starting with 1 are written in one line. The ... |
Solve the programming task below in a Python markdown code block.
A sequence a0, a1, ..., at - 1 is called increasing if ai - 1 < ai for each i: 0 < i < t.
You are given a sequence b0, b1, ..., bn - 1 and a positive integer d. In each move you may choose one element of the given sequence and add d to it. What is the ... |
Solve the programming task below in a Python markdown code block.
AtCoDeer the deer recently bought three paint cans.
The color of the one he bought two days ago is a, the color of the one he bought yesterday is b, and the color of the one he bought today is c.
Here, the color of each paint can is represented by an in... |
Solve the programming task below in a Python markdown code block.
Peter Parker wants to play a game with Dr. Octopus. The game is about cycles. Cycle is a sequence of vertices, such that first one is connected with the second, second is connected with third and so on, while the last one is connected with the first one... |
Solve the programming task below in a Python markdown code block.
There are N towns on a plane. The i-th town is located at the coordinates (x_i,y_i). There may be more than one town at the same coordinates.
You can build a road between two towns at coordinates (a,b) and (c,d) for a cost of min(|a-c|,|b-d|) yen (the ... |
Solve the programming task below in a Python markdown code block.
You've decided to carry out a survey in the theory of prime numbers. Let us remind you that a prime number is a positive integer that has exactly two distinct positive integer divisors.
Consider positive integers a, a + 1, ..., b (a β€ b). You want to f... |
Solve the programming task below in a Python markdown code block.
Oleg the client and Igor the analyst are good friends. However, sometimes they argue over little things. Recently, they started a new company, but they are having trouble finding a name for the company.
To settle this problem, they've decided to play a... |
Solve the programming task below in a Python markdown code block.
Vasya likes to solve equations. Today he wants to solve $(x~\mathrm{div}~k) \cdot (x \bmod k) = n$, where $\mathrm{div}$ and $\mathrm{mod}$ stand for integer division and modulo operations (refer to the Notes below for exact definition). In this equatio... |
Solve the programming task below in a Python markdown code block.
Little C loves number Β«3Β» very much. He loves all things about it.
Now he has a positive integer $n$. He wants to split $n$ into $3$ positive integers $a,b,c$, such that $a+b+c=n$ and none of the $3$ integers is a multiple of $3$. Help him to find a so... |
Solve the programming task below in a Python markdown code block.
The R1 company wants to hold a web search championship. There were n computers given for the competition, each of them is connected to the Internet. The organizers believe that the data transfer speed directly affects the result. The higher the speed of... |
Solve the programming task below in a Python markdown code block.
Problem
Mr. ukuku1333 is a little sloppy, so when I expanded the product of the linear expressions of x, I couldn't figure out the original linear expression.
Given the nth degree polynomial of x, factor it into the product of the original linear expre... |
Solve the programming task below in a Python markdown code block.
When a boy was cleaning up after his grand father passing, he found an old paper:
<image>
In addition, other side of the paper says that "go ahead a number of steps equivalent to the first integer, and turn clockwise by degrees equivalent to the sec... |
Solve the programming task below in a Python markdown code block.
Problem Statement
"Everlasting -One-" is an award-winning online game launched this year. This game has rapidly become famous for its large number of characters you can play.
In this game, a character is characterized by attributes. There are $N$ attr... |
Solve the programming task below in a Python markdown code block.
One day Vasya got hold of information on the Martian dollar course in bourles for the next n days. The buying prices and the selling prices for one dollar on day i are the same and are equal to ai. Vasya has b bourles. He can buy a certain number of dol... |
Solve the programming task below in a Python markdown code block.
Toad Rash has a binary string s. A binary string consists only of zeros and ones.
Let n be the length of s.
Rash needs to find the number of such pairs of integers l, r that 1 β€ l β€ r β€ n and there is at least one pair of integers x, k such that 1 β€ x... |
Solve the programming task below in a Python markdown code block.
To get money for a new aeonic blaster, ranger Qwerty decided to engage in trade for a while. He wants to buy some number of items (or probably not to buy anything at all) on one of the planets, and then sell the bought items on another planet. Note that... |
Solve the programming task below in a Python markdown code block.
You are given a Young diagram.
Given diagram is a histogram with n columns of lengths a_1, a_2, β¦, a_n (a_1 β₯ a_2 β₯ β¦ β₯ a_n β₯ 1).
<image> Young diagram for a=[3,2,2,2,1].
Your goal is to find the largest number of non-overlapping dominos that you ca... |
Solve the programming task below in a Python markdown code block.
~~~if-not:ruby,python
Return `1` when *any* odd bit of `x` equals 1; `0` otherwise.
~~~
~~~if:ruby,python
Return `true` when *any* odd bit of `x` equals 1; `false` otherwise.
~~~
Assume that:
* `x` is an unsigned, 32-bit integer;
* the bits are zero-in... |
Solve the programming task below in a Python markdown code block.
Young Timofey has a birthday today! He got kit of n cubes as a birthday present from his parents. Every cube has a number a_{i}, which is written on it. Timofey put all the cubes in a row and went to unpack other presents.
In this time, Timofey's elder... |
Solve the programming task below in a Python markdown code block.
Define a function that takes one integer argument and returns logical value `true` or `false` depending on if the integer is a prime.
Per Wikipedia, a prime number (or a prime) is a natural number greater than 1 that has no positive divisors other than... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.