question large_stringlengths 265 13.2k |
|---|
Solve the programming task below in a Python markdown code block.
Disclaimer: there are lots of untranslateable puns in the Russian version of the statement, so there is one more reason for you to learn Russian :)
Rick and Morty like to go to the ridge High Cry for crying loudlyΒ β there is an extraordinary echo. Rece... |
Solve the programming task below in a Python markdown code block.
A frog is about to return to the burrow. The burrow is D centimeters ahead of the frog, and the frog goes straight toward the burrow. There are only two actions that a frog can do:
* Large jump (go forward L centimeters)
* Small jump (go 1 cm forward)
... |
Solve the programming task below in a Python markdown code block.
Alexandra has a paper strip with n numbers on it. Let's call them ai from left to right.
Now Alexandra wants to split it into some pieces (possibly 1). For each piece of strip, it must satisfy:
* Each piece should contain at least l numbers.
* The... |
Solve the programming task below in a Python markdown code block.
Problem
The popular video posting site "ZouTube" is now in the midst of an unprecedented "virtual ZouTuber" boom. Among them, the one that has been attracting particular attention recently is the junior virtual ZouTuber "Aizumarim (commonly known as Az... |
Solve the programming task below in a Python markdown code block.
This morning Chef wants to jump a little. In a few minutes he will arrive at the point 0. Then he will perform a lot of jumps in such a sequence: 1-jump, 2-jump, 3-jump, 1-jump, 2-jump, 3-jump, 1-jump, and so on.
1-jump means that if Chef is at the poin... |
Solve the programming task below in a Python markdown code block.
Iahub is a big fan of tourists. He wants to become a tourist himself, so he planned a trip. There are n destinations on a straight road that Iahub wants to visit. Iahub starts the excursion from kilometer 0. The n destinations are described by a non-neg... |
Solve the programming task below in a Python markdown code block.
You are given a multiset (i. e. a set that can contain multiple equal integers) containing $2n$ integers. Determine if you can split it into exactly $n$ pairs (i. e. each element should be in exactly one pair) so that the sum of the two elements in each... |
Solve the programming task below in a Python markdown code block.
Polycarpus has an array, consisting of n integers a_1, a_2, ..., a_{n}. Polycarpus likes it when numbers in an array match. That's why he wants the array to have as many equal numbers as possible. For that Polycarpus performs the following operation mul... |
Solve the programming task below in a Python markdown code block.
Masha has $n$ types of tiles of size $2 \times 2$. Each cell of the tile contains one integer. Masha has an infinite number of tiles of each type.
Masha decides to construct the square of size $m \times m$ consisting of the given tiles. This square als... |
Solve the programming task below in a Python markdown code block.
Mary has just graduated from one well-known University and is now attending celebration party. Students like to dream of a beautiful life, so they used champagne glasses to construct a small pyramid. The height of the pyramid is n. The top level consist... |
Solve the programming task below in a Python markdown code block.
"Pizza At", a fast food chain, offers three kinds of pizza: "A-pizza", "B-pizza" and "AB-pizza". A-pizza and B-pizza are completely different pizzas, and AB-pizza is one half of A-pizza and one half of B-pizza combined together. The prices of one A-pizz... |
Solve the programming task below in a Python markdown code block.
Snuke had N cards numbered 1 through N.
Each card has an integer written on it; written on Card i is a_i.
Snuke did the following procedure:
- Let X and x be the maximum and minimum values written on Snuke's cards, respectively.
- If X = x, terminate ... |
Solve the programming task below in a Python markdown code block.
Baby Ehab was toying around with arrays. He has an array $a$ of length $n$. He defines an array to be good if there's no way to partition it into $2$ subsequences such that the sum of the elements in the first is equal to the sum of the elements in the ... |
Solve the programming task below in a Python markdown code block.
Yui Hirasawa, who attends private Sakuragaoka Girls' High School, has to make a career hope by the day after tomorrow, but the trouble is that she hasn't decided anything yet. When I consulted with my friend Wa, I knew that my first choice was K Univers... |
Solve the programming task below in a Python markdown code block.
There are N people numbered 1 to N. Each person wears a red hat or a blue hat.
You are given a string s representing the colors of the people. Person i wears a red hat if s_i is `R`, and a blue hat if s_i is `B`.
Determine if there are more people wea... |
Solve the programming task below in a Python markdown code block.
During cleaning the coast, Alice found $n$ piles of stones. The $i$-th pile has $a_i$ stones.
Piles $i$ and $i + 1$ are neighbouring for all $1 \leq i \leq n - 1$. If pile $i$ becomes empty, piles $i - 1$ and $i + 1$ doesn't become neighbouring.
Alice... |
Solve the programming task below in a Python markdown code block.
In the building of Jewelry Art Gallery (JAG), there is a long corridor in the east-west direction. There is a window on the north side of the corridor, and $N$ windowpanes are attached to this window. The width of each windowpane is $W$, and the height ... |
Solve the programming task below in a Python markdown code block.
Having two standards for a keypad layout is inconvenient!
Computer keypad's layout:
Cell phone keypad's layout:
Solve the horror of unstandartized keypads by providing a function that converts computer input to a number as if it was typed by... |
Solve the programming task below in a Python markdown code block.
Rule 30 is a one-dimensional binary cellular automaton. You can have some information here:
* [https://en.wikipedia.org/wiki/Rule_30](https://en.wikipedia.org/wiki/Rule_30)
You have to write a function that takes as input an array of 0 and 1 and a p... |
Solve the programming task below in a Python markdown code block.
At the pancake shop you work for, pancake dough is lined up in a row on an elongated iron plate and baked. Pancakes can be completed by turning them over with a spatula several times. How many times you turn it over to complete it depends on the pancake... |
Solve the programming task below in a Python markdown code block.
You are given a convex polygon P with n distinct vertices p_1, p_2, ..., p_{n}. Vertex p_{i} has coordinates (x_{i}, y_{i}) in the 2D plane. These vertices are listed in clockwise order.
You can choose a real number D and move each vertex of the polygo... |
Solve the programming task below in a Python markdown code block.
Takahashi loves takoyaki - a ball-shaped snack.
With a takoyaki machine, he can make at most X pieces of takoyaki at a time, taking T minutes regardless of the number of pieces to make.
How long does it take to make N takoyaki?
-----Constraints-----
-... |
Solve the programming task below in a Python markdown code block.
Vova, the Ultimate Thule new shaman, wants to build a pipeline. As there are exactly n houses in Ultimate Thule, Vova wants the city to have exactly n pipes, each such pipe should be connected to the water supply. A pipe can be connected to the water su... |
Solve the programming task below in a Python markdown code block.
Your task is to validate rhythm with a meter.
_________________________________________________
Rules:
1. Rhythmic division requires that in one whole note (1) there are two half notes (2) or four quarter notes (4) or eight eighth notes (8).
Examples... |
Solve the programming task below in a Python markdown code block.
# Task
Given a `sequence` of integers, check whether it is possible to obtain a strictly increasing sequence by erasing no more than one element from it.
# Example
For `sequence = [1, 3, 2, 1]`, the output should be `false`;
For `sequence = [1, 3... |
Solve the programming task below in a Python markdown code block.
Mr. A is planning to travel alone on a highway bus (hereinafter referred to as "bus") during his high school holidays. First, Mr. A chose the town he wanted to visit the most and made it his destination. Next, you have to decide the route to transfer th... |
Solve the programming task below in a Python markdown code block.
Let A = {a1, a2, ..., an} be any permutation of the first n natural numbers {1, 2, ..., n}. You are given a positive integer k and another sequence B = {b1, b2, ..., bn}, where bi is the number of elements aj in A to the left of the element at = i such ... |
Solve the programming task below in a Python markdown code block.
I decided to create a program that displays a "round and round pattern". The "round and round pattern" is as follows.
* If the length of one side is n, it is displayed as a character string with n rows and n columns.
* A spiral pattern that rotates clo... |
Solve the programming task below in a Python markdown code block.
A multi-subject competition is coming! The competition has $m$ different subjects participants can choose from. That's why Alex (the coach) should form a competition delegation among his students.
He has $n$ candidates. For the $i$-th person he knows ... |
Solve the programming task below in a Python markdown code block.
In the city, there are two pastry shops. One shop was very popular because its cakes are pretty tasty. However, there was a man who is displeased at the shop. He was an owner of another shop. Although cause of his shop's unpopularity is incredibly awful... |
Solve the programming task below in a Python markdown code block.
You are an all-powerful being and you have created a rectangular world. In fact, your world is so bland that it could be represented by a $r \times c$ grid. Each cell on the grid represents a country. Each country has a dominant religion. There are only... |
Solve the programming task below in a Python markdown code block.
You may be familiar with the concept of combinations: for example, if you take 5 cards from a 52 cards deck as you would playing poker, you can have a certain number (2,598,960, would you say?) of different combinations.
In mathematics the number of *k... |
Solve the programming task below in a Python markdown code block.
Vasya has found a strange device. On the front panel of a device there are: a red button, a blue button and a display showing some positive integer. After clicking the red button, device multiplies the displayed number by two. After clicking the blue bu... |
Solve the programming task below in a Python markdown code block.
We have a sequence of length N consisting of non-negative integers. Consider performing the following operation on this sequence until the largest element in this sequence becomes N-1 or smaller. (The operation is the same as the one in Problem D.)
* D... |
Solve the programming task below in a Python markdown code block.
You are given a sequence of $n$ integers $a_1, a_2, \ldots, a_n$.
You have to construct two sequences of integers $b$ and $c$ with length $n$ that satisfy: for every $i$ ($1\leq i\leq n$) $b_i+c_i=a_i$ $b$ is non-decreasing, which means that for ever... |
Solve the programming task below in a Python markdown code block.
The first positive integer, `n`, with its value `4nΒ² + 1`, being divisible by `5` and `13` is `4`. (condition 1)
It can be demonstrated that we have infinite numbers that may satisfy the above condition.
If we name **ai**, the different terms of the s... |
Solve the programming task below in a Python markdown code block.
Multiplication of Big Integers II
Given two integers $A$ and $B$, compute the product, $A \times B$.
Input
Two integers $A$ and $B$ separated by a space character are given in a line.
Output
Print the product in a line.
Constraints
* $-1 \times 1... |
Solve the programming task below in a Python markdown code block.
The marmots have prepared a very easy problem for this year's HC^2 β this one. It involves numbers n, k and a sequence of n positive integers a_1, a_2, ..., a_{n}. They also came up with a beautiful and riveting story for the problem statement. It expla... |
Solve the programming task below in a Python markdown code block.
You will be given two strings `a` and `b` consisting of lower case letters, but `a` will have at most one asterix character. The asterix (if any) can be replaced with an arbitrary sequence (possibly empty) of lowercase letters. No other character of str... |
Solve the programming task below in a Python markdown code block.
Consider an array that has no prime numbers, and none of its elements has any prime digit. It would start with: `[1,4,6,8,9,10,14,16,18,..]`.
`12` and `15` are not in the list because `2` and `5` are primes.
You will be given an integer `n` and your ... |
Solve the programming task below in a Python markdown code block.
zscoder loves simple strings! A string t is called simple if every pair of adjacent characters are distinct. For example ab, aba, zscoder are simple whereas aa, add are not simple.
zscoder is given a string s. He wants to change a minimum number of cha... |
Solve the programming task below in a Python markdown code block.
You are given two integers n and d. You need to construct a rooted binary tree consisting of n vertices with a root at the vertex 1 and the sum of depths of all vertices equals to d.
A tree is a connected graph without cycles. A rooted tree has a speci... |
Solve the programming task below in a Python markdown code block.
During a normal walk in the forest, Katie has stumbled upon a mysterious code! However, the mysterious code had some characters unreadable. She has written down this code as a string c consisting of lowercase English characters and asterisks ("*"), wher... |
Solve the programming task below in a Python markdown code block.
problem
Taro often shop at JOI general stores. At JOI general stores, there are enough coins of 500 yen, 100 yen, 50 yen, 10 yen, 5 yen, and 1 yen, and we always pay the change so that the number of coins is the smallest. Create a program to find the n... |
Solve the programming task below in a Python markdown code block.
Once Bob took a paper stripe of n squares (the height of the stripe is 1 square). In each square he wrote an integer number, possibly negative. He became interested in how many ways exist to cut this stripe into two pieces so that the sum of numbers fro... |
Solve the programming task below in a Python markdown code block.
Baby Ehab has a piece of Cut and Stick with an array a of length n written on it. He plans to grab a pair of scissors and do the following to it:
* pick a range (l, r) and cut out every element a_l, a_{l + 1}, ..., a_r in this range;
* stick some ... |
Solve the programming task below in a Python markdown code block.
As Sherlock Holmes was investigating a crime, he identified n suspects. He knows for sure that exactly one of them committed the crime. To find out which one did it, the detective lines up the suspects and numbered them from 1 to n. After that, he asked... |
Solve the programming task below in a Python markdown code block.
You are given a string $s$ consisting only of lowercase Latin letters.
You can rearrange all letters of this string as you wish. Your task is to obtain a good string by rearranging the letters of the given string or report that it is impossible to do i... |
Solve the programming task below in a Python markdown code block.
Lapindrome is defined as a string which when split in the middle, gives two halves having the same characters and same frequency of each character. If there are odd number of characters in the string, we ignore the middle character and check for lapindr... |
Solve the programming task below in a Python markdown code block.
You have a matrix $2 \times 2$ filled with distinct integers. You want your matrix to become beautiful. The matrix is beautiful if the following two conditions are satisfied:
in each row, the first element is smaller than the second element;
in each c... |
Solve the programming task below in a Python markdown code block.
## Sum Even Fibonacci Numbers
* Write a func named SumEvenFibonacci that takes a parameter of type int and returns a value of type int
* Generate all of the Fibonacci numbers starting with 1 and 2 and ending on the highest number before exceeding the ... |
Solve the programming task below in a Python markdown code block.
In AtCoder City, there are three stations numbered 1, 2, and 3.
Each of these stations is operated by one of the two railway companies, A and B. A string S of length 3 represents which company operates each station. If S_i is A, Company A operates Stati... |
Solve the programming task below in a Python markdown code block.
One cold winter evening Alice and her older brother Bob was sitting at home near the fireplace and giving each other interesting problems to solve. When it was Alice's turn, she told the number n to Bob and said:
βShuffle the digits in this number in o... |
Solve the programming task below in a Python markdown code block.
Let's call an undirected graph of n vertices p-interesting, if the following conditions fulfill:
* the graph contains exactly 2n + p edges;
* the graph doesn't contain self-loops and multiple edges;
* for any integer k (1 β€ k β€ n), any subgrap... |
Solve the programming task below in a Python markdown code block.
The problem describes the properties of a command line. The description somehow resembles the one you usually see in real operating systems. However, there are differences in the behavior. Please make sure you've read the statement attentively and use i... |
Solve the programming task below in a Python markdown code block.
You are an adventurer currently journeying inside an evil temple. After defeating a couple of weak zombies, you arrived at a square room consisting of tiles forming an n Γ n grid. The rows are numbered 1 through n from top to bottom, and the columns are... |
Solve the programming task below in a Python markdown code block.
Imagine a triangle of numbers which follows this pattern:
* Starting with the number "1", "1" is positioned at the top of the triangle. As this is the 1st row, it can only support a single number.
* The 2nd row can support the next 2 numbers: "2" and... |
Solve the programming task below in a Python markdown code block.
You are given an integer k and an undirected tree, consisting of n vertices.
The length of a simple path (a path in which each vertex appears at most once) between some pair of vertices is the number of edges in this path. A diameter of a tree is the m... |
Solve the programming task below in a Python markdown code block.
You are given a sequence A_1, A_2, ..., A_N and an integer K.
Print the maximum possible length of a sequence B that satisfies the following conditions:
* B is a (not necessarily continuous) subsequence of A.
* For each pair of adjacents elements of B... |
Solve the programming task below in a Python markdown code block.
You are given two matrices $A$ and $B$. Each matrix contains exactly $n$ rows and $m$ columns. Each element of $A$ is either $0$ or $1$; each element of $B$ is initially $0$.
You may perform some operations with matrix $B$. During each operation, you c... |
Solve the programming task below in a Python markdown code block.
Chef Shifu and Chef Po are participating in the Greatest Dumpling Fight of 2012.
Of course, Masterchef Oogway has formed the rules of the fight.
There is a long horizontal rope of infinite length with a center point P.
Initially both Chef Shifu and Che... |
Solve the programming task below in a Python markdown code block.
Oh no! You have stumbled upon a mysterious signal consisting of beeps of various lengths, and it is of utmost importance that you find out the secret message hidden in the beeps. There are long and short beeps, the longer ones roughly three times as l... |
Solve the programming task below in a Python markdown code block.
We have N balance beams numbered 1 to N. The length of each beam is 1 meters. Snuke walks on Beam i at a speed of 1/A_i meters per second, and Ringo walks on Beam i at a speed of 1/B_i meters per second.
Snuke and Ringo will play the following game:
*... |
Solve the programming task below in a Python markdown code block.
Students love to celebrate their holidays. Especially if the holiday is the day of the end of exams!
Despite the fact that Igor K., unlike his groupmates, failed to pass a programming test, he decided to invite them to go to a cafe so that each of them... |
Solve the programming task below in a Python markdown code block.
Kicker (table football) is a board game based on football, in which players control the footballers' figures mounted on rods by using bars to get the ball into the opponent's goal. When playing two on two, one player of each team controls the goalkeeper... |
Solve the programming task below in a Python markdown code block.
Professor GukiZ is concerned about making his way to school, because massive piles of boxes are blocking his way.
In total there are n piles of boxes, arranged in a line, from left to right, i-th pile (1 β€ i β€ n) containing ai boxes. Luckily, m studen... |
Solve the programming task below in a Python markdown code block.
Did you hear about the Nibiru collision ? It is a supposed disastrous encounter between the earth and a large planetary object. Astronomers reject this idea. But why listen to other people's beliefs and opinions. We are coders above all, so what better ... |
Solve the programming task below in a Python markdown code block.
The great hero guards the country where Homer lives. The hero has attack power $A$ and initial health value $B$. There are $n$ monsters in front of the hero. The $i$-th monster has attack power $a_i$ and initial health value $b_i$.
The hero or a monste... |
Solve the programming task below in a Python markdown code block.
Sonya was unable to think of a story for this problem, so here comes the formal description.
You are given the array containing n positive integers. At one turn you can pick any element and increase or decrease it by 1. The goal is the make the array s... |
Solve the programming task below in a Python markdown code block.
You are given two circles. Find the area of their intersection.
-----Input-----
The first line contains three integers x_1, y_1, r_1 ( - 10^9 β€ x_1, y_1 β€ 10^9, 1 β€ r_1 β€ 10^9) β the position of the center and the radius of the first circle.
The sec... |
Solve the programming task below in a Python markdown code block.
There are two 100-story buildings, called A and B. (In this problem, the ground floor is called the first floor.)
For each i = 1,\dots, 100, the i-th floor of A and that of B are connected by a corridor.
Also, for each i = 1,\dots, 99, there is a corrid... |
Solve the programming task below in a Python markdown code block.
In order to participate in the Asian Regional Qualifiers of the International Collegiate Programming Contest held every year in Japan, we must break through the strict domestic qualifiers.
Even though it is a university competition, multiple teams from... |
Solve the programming task below in a Python markdown code block.
I need some help with my math homework. I have a number of problems I need to return the derivative for.
They will all be of the form:
ax^b,
A and B are both integers, but can be positive or negative.
Note:
- if b is 1, then the equation will be... |
Solve the programming task below in a Python markdown code block.
Write a function that calculates the original product price, without VAT.
## Example
If a product price is `200.00` and VAT is `15%`, then the final product price (with VAT) is: `200.00 + 15% = 230.00`
Thus, if your function receives `230.00` as input... |
Solve the programming task below in a Python markdown code block.
A game field is a strip of 1 Γ n square cells. In some cells there are Packmen, in some cellsΒ β asterisks, other cells are empty.
Packman can move to neighboring cell in 1 time unit. If there is an asterisk in the target cell then Packman eats it. Pack... |
Solve the programming task below in a Python markdown code block.
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.
Unfortunately, not all numbers ar... |
Solve the programming task below in a Python markdown code block.
Polycarpus has a sequence, consisting of n non-negative integers: a_1, a_2, ..., a_{n}.
Let's define function f(l, r) (l, r are integer, 1 β€ l β€ r β€ n) for sequence a as an operation of bitwise OR of all the sequence elements with indexes from l to r. ... |
Solve the programming task below in a Python markdown code block.
A trick I learned in elementary school to determine whether or not a number was divisible by three is to add all of the integers in the number together and to divide the resulting sum by three. If there is no remainder from dividing the sum by three, th... |
Solve the programming task below in a Python markdown code block.
Sorting algorithms for sorting data are basic algorithms indispensable in computer science. For example, as shown in the figure below, the operation of "sorting the elements of an array of integer values ββin ascending order" is alignment.
<image>
Ma... |
Solve the programming task below in a Python markdown code block.
Valera considers a number beautiful, if it equals 2^{k} or -2^{k} for some integer k (k β₯ 0). Recently, the math teacher asked Valera to represent number n as the sum of beautiful numbers. As Valera is really greedy, he wants to complete the task using ... |
Solve the programming task below in a Python markdown code block.
In Disgaea as in most role-playing games, characters have skills that determine the character's ability to use certain weapons or spells. If the character does not have the necessary skill, he cannot use it. The skill level is represented as an integer ... |
Solve the programming task below in a Python markdown code block.
Vasya has got many devices that work on electricity. He's got n supply-line filters to plug the devices, the i-th supply-line filter has a_{i} sockets.
Overall Vasya has got m devices and k electrical sockets in his flat, he can plug the devices or sup... |
Solve the programming task below in a Python markdown code block.
Polycarp often uses his smartphone. He has already installed $n$ applications on it. Application with number $i$ takes up $a_i$ units of memory.
Polycarp wants to free at least $m$ units of memory (by removing some applications).
Of course, some appli... |
Solve the programming task below in a Python markdown code block.
You are given n points on a line with their coordinates x_{i}. Find the point x so the sum of distances to the given points is minimal.
-----Input-----
The first line contains integer n (1 β€ n β€ 3Β·10^5) β the number of points on the line.
The second... |
Solve the programming task below in a Python markdown code block.
Write a function that takes in a string of one or more words, and returns the same string, but with all five or more letter words reversed (Just like the name of this Kata). Strings passed in will consist of only letters and spaces. Spaces will be inclu... |
Solve the programming task below in a Python markdown code block.
Two little greedy bears have found two pieces of cheese in the forest of weight a and b grams, correspondingly. The bears are so greedy that they are ready to fight for the larger piece. That's where the fox comes in and starts the dialog: "Little bears... |
Solve the programming task below in a Python markdown code block.
During the last Sereja's Codesecrof round the server crashed many times, so the round was decided to be made unrated for some participants.
Let's assume that n people took part in the contest. Let's assume that the participant who got the first place ... |
Solve the programming task below in a Python markdown code block.
Sam has opened a new sushi train restaurant - a restaurant where sushi is served on plates that travel around the bar on a conveyor belt and customers take the plate that they like.
Sam is using Glamazon's new visual recognition technology that allows ... |
Solve the programming task below in a Python markdown code block.
Given are integers S and P.
Is there a pair of positive integers (N,M) such that N + M = S and N \times M = P?
-----Constraints-----
- All values in input are integers.
- 1 \leq S,P \leq 10^{12}
-----Input-----
Input is given from Standard Input in ... |
Solve the programming task below in a Python markdown code block.
Input
The input contains two integers a1, a2 (0 β€ ai β€ 109), separated by a single space.
Output
Output a single integer.
Examples
Input
3 14
Output
44
Input
27 12
Output
48
Input
100 200
Output
102
Read the inputs from stdin solv... |
Solve the programming task below in a Python markdown code block.
problem
Once upon a time there were settlements and many people lived there. People built buildings of various shapes and sizes. But those buildings have already been lost, only the literature and the pillars found in the ruins. Was a clue to the locat... |
Solve the programming task below in a Python markdown code block.
You have $N$ items that you want to put them into a knapsack of capacity $W$. Item $i$ ($1 \le i \le N$) has weight $w_i$ and value $v_i$ for the weight.
When you put some items into the knapsack, the following conditions must be satisfied:
* The tota... |
Solve the programming task below in a Python markdown code block.
Consider the infinite sequence s of positive integers, created by repeating the following steps:
1. Find the lexicographically smallest triple of positive integers (a, b, c) such that
* a β b β c = 0, where β denotes the [bitwise XOR operation](... |
Solve the programming task below in a Python markdown code block.
Recently, the Fair Nut has written k strings of length n, consisting of letters "a" and "b". He calculated c β the number of strings that are prefixes of at least one of the written strings. Every string was counted only one time.
Then, he lost his she... |
Solve the programming task below in a Python markdown code block.
# Task
Your Informatics teacher at school likes coming up with new ways to help you understand the material. When you started studying numeral systems, he introduced his own numeral system, which he's convinced will help clarify things. His numeral sys... |
Solve the programming task below in a Python markdown code block.
Mr. Kitayuta has just bought an undirected graph consisting of n vertices and m edges. The vertices of the graph are numbered from 1 to n. Each edge, namely edge i, has a color c_{i}, connecting vertex a_{i} and b_{i}.
Mr. Kitayuta wants you to process... |
Solve the programming task below in a Python markdown code block.
You are given a bracket sequence consisting of $n$ characters '(' and/or )'. You perform several operations with it.
During one operation, you choose the shortest prefix of this string (some amount of first characters of the string) that is good and re... |
Solve the programming task below in a Python markdown code block.
Welcome! Everything is fine.
You have arrived in The Medium Place, the place between The Good Place and The Bad Place. You are assigned a task that will either make people happier or torture them for eternity.
You have a list of k pairs of people who ... |
Solve the programming task below in a Python markdown code block.
Dreamoon likes coloring cells very much.
There is a row of $n$ cells. Initially, all cells are empty (don't contain any color). Cells are numbered from $1$ to $n$.
You are given an integer $m$ and $m$ integers $l_1, l_2, \ldots, l_m$ ($1 \le l_i \le n... |
Solve the programming task below in a Python markdown code block.
### Description:
Remove all exclamation marks from sentence except at the end.
### Examples
```
remove("Hi!") == "Hi!"
remove("Hi!!!") == "Hi!!!"
remove("!Hi") == "Hi"
remove("!Hi!") == "Hi!"
remove("Hi! Hi!") == "Hi Hi!"
remove("Hi") == "Hi"
```
W... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.