question large_stringlengths 265 13.2k |
|---|
Solve the programming task below in a Python markdown code block.
Dima loves Inna very much. He decided to write a song for her. Dima has a magic guitar with n strings and m frets. Dima makes the guitar produce sounds like that: to play a note, he needs to hold one of the strings on one of the frets and then pull the ... |
Solve the programming task below in a Python markdown code block.
# Kata Task
Given a list of random integers, return the Three Amigos.
These are 3 numbers that live next to each other in the list, and who have the **most** in common with each other by these rules:
* lowest statistical range
* same parity
# Notes
... |
Solve the programming task below in a Python markdown code block.
Snuke has decided to play with a six-sided die. Each of its six sides shows an integer 1 through 6, and two numbers on opposite sides always add up to 7.
Snuke will first put the die on the table with an arbitrary side facing upward, then repeatedly per... |
Solve the programming task below in a Python markdown code block.
We have a 3 \times 3 grid. A number c_{i, j} is written in the square (i, j), where (i, j) denotes the square at the i-th row from the top and the j-th column from the left.
According to Takahashi, there are six integers a_1, a_2, a_3, b_1, b_2, b_3 wh... |
Solve the programming task below in a Python markdown code block.
> In information theory and computer science, the Levenshtein distance is a string metric for measuring the difference between two sequences. Informally, the Levenshtein distance between two words is the minimum number of single-character edits (i.e. in... |
Solve the programming task below in a Python markdown code block.
Mr. Kitayuta has kindly given you a string s consisting of lowercase English letters. You are asked to insert exactly one lowercase English letter into s to make it a palindrome. A palindrome is a string that reads the same forward and backward. For exa... |
Solve the programming task below in a Python markdown code block.
Prize
Segtree entered a programming contest with a team of $ N $ and won a $ K $ yen prize! I'm trying to distribute this prize now.
Each $ N $ team member, including Segtree, is numbered from $ 1 $ to $ N $ in order of ability. Segtree is $ 1 $.
If ... |
Solve the programming task below in a Python markdown code block.
There was a powerful school where powerful people gathered. At the athletic meet of the powerful school, powerful people march in a formation.
While the powerhouses always want to show off their power, most of them don't want to walk on their own. So I... |
Solve the programming task below in a Python markdown code block.
Petya is a big fan of mathematics, especially its part related to fractions. Recently he learned that a fraction $\frac{a}{b}$ is called proper iff its numerator is smaller than its denominator (a < b) and that the fraction is called irreducible if its ... |
Solve the programming task below in a Python markdown code block.
Snuke, who loves animals, built a zoo.
There are N animals in this zoo. They are conveniently numbered 1 through N, and arranged in a circle.
The animal numbered i (2≤i≤N-1) is adjacent to the animals numbered i-1 and i+1. Also, the animal numbered 1 is... |
Solve the programming task below in a Python markdown code block.
# Longest Palindromic Substring (Linear)
A palindrome is a word, phrase, or sequence that reads the same backward as forward, e.g.,
'madam' or 'racecar'. Even the letter 'x' is considered a palindrome.
For this Kata, you are given a string ```s```. W... |
Solve the programming task below in a Python markdown code block.
To make a paper airplane, one has to use a rectangular piece of paper. From a sheet of standard size you can make $s$ airplanes.
A group of $k$ people decided to make $n$ airplanes each. They are going to buy several packs of paper, each of them contai... |
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 l_{i} and c... |
Solve the programming task below in a Python markdown code block.
<!--
Problem B
-->
On-Screen Keyboard
You are to input a string with an OSK (on-screen keyboard). A remote control with five buttons, four arrows and an OK (Fig. B-1), is used for the OSK. Find the minimum number of button presses required to input ... |
Solve the programming task below in a Python markdown code block.
# Task
Given a number `n`, return a string representing it as a sum of distinct powers of three, or return `"Impossible"` if that's not possible to achieve.
# Input/Output
`[input]` integer `n`
A positive integer n.
`1 ≤ n ≤ 10^16`.
`[output]` ... |
Solve the programming task below in a Python markdown code block.
There is a house with $n$ flats situated on the main street of Berlatov. Vova is watching this house every night. The house can be represented as an array of $n$ integer numbers $a_1, a_2, \dots, a_n$, where $a_i = 1$ if in the $i$-th flat the light is ... |
Solve the programming task below in a Python markdown code block.
10^{10^{10}} participants, including Takahashi, competed in two programming contests. In each contest, all participants had distinct ranks from first through 10^{10^{10}}-th.
The score of a participant is the product of his/her ranks in the two contest... |
Solve the programming task below in a Python markdown code block.
Alexander is learning how to convert numbers from the decimal system to any other, however, he doesn't know English letters, so he writes any number only as a decimal number, it means that instead of the letter A he will write the number 10. Thus, by co... |
Solve the programming task below in a Python markdown code block.
Little penguin Polo loves his home village. The village has n houses, indexed by integers from 1 to n. Each house has a plaque containing an integer, the i-th house has a plaque containing integer pi (1 ≤ pi ≤ n).
Little penguin Polo loves walking arou... |
Solve the programming task below in a Python markdown code block.
Some dwarves that are finishing the StUDY (State University for Dwarven Youngsters) Bachelor courses, have been told "no genome, no degree". That means that all dwarves should write a thesis on genome. Dwarven genome is far from simple. It is represente... |
Solve the programming task below in a Python markdown code block.
Takahashi is hosting an sports meet. There are N people who will participate. These people are conveniently numbered 1 through N. Also, there are M options of sports for this event. These sports are numbered 1 through M. Among these options, Takahashi w... |
Solve the programming task below in a Python markdown code block.
In Russia, there is an army-purposed station named UVB-76 or "Buzzer" (see also https://en.wikipedia.org/wiki/UVB-76). Most of time specific "buzz" noise is being broadcasted, but on very rare occasions, the buzzer signal is interrupted and a voice tran... |
Solve the programming task below in a Python markdown code block.
In this kata you need to build a function to return either `true/True` or `false/False` if a string can be seen as the repetition of a simpler/shorter subpattern or not.
For example:
```cpp,java
hasSubpattern("a") == false; //no repeated pattern
hasSu... |
Solve the programming task below in a Python markdown code block.
The Bubble Cup hypothesis stood unsolved for $130$ years. Who ever proves the hypothesis will be regarded as one of the greatest mathematicians of our time! A famous mathematician Jerry Mao managed to reduce the hypothesis to this problem:
Given a numb... |
Solve the programming task below in a Python markdown code block.
Little Susie listens to fairy tales before bed every day. Today's fairy tale was about wood cutters and the little girl immediately started imagining the choppers cutting wood. She imagined the situation that is described below.
There are n trees locat... |
Solve the programming task below in a Python markdown code block.
Kaavi, the mysterious fortune teller, deeply believes that one's fate is inevitable and unavoidable. Of course, she makes her living by predicting others' future. While doing divination, Kaavi believes that magic spells can provide great power for her t... |
Solve the programming task below in a Python markdown code block.
You have n dices each one having s sides numbered from 1 to s.
How many outcomes add up to a specified number k?
For example if we roll four normal six-sided dices we
have four outcomes that add up to 5.
(1, 1, 1, 2)
(1, 1, 2, 1)
(1, 2, 1, 1)
(2, 1, ... |
Solve the programming task below in a Python markdown code block.
# Right in the Center
_This is inspired by one of Nick Parlante's exercises on the [CodingBat](https://codingbat.com/java) online code practice tool._
Given a sequence of characters, does `"abc"` appear in the CENTER of the sequence?
The sequence of ... |
Solve the programming task below in a Python markdown code block.
Your task is to create a function called ```sum_arrays()``` in Python or ```addArrays``` in Javascript, which takes two arrays consisting of integers, and returns the sum of those two arrays.
The twist is that (for example) ```[3,2,9]``` does not equal... |
Solve the programming task below in a Python markdown code block.
This winter is so cold in Nvodsk! A group of n friends decided to buy k bottles of a soft drink called "Take-It-Light" to warm up a bit. Each bottle has l milliliters of the drink. Also they bought c limes and cut each of them into d slices. After that ... |
Solve the programming task below in a Python markdown code block.
Two chess pieces, a rook and a knight, stand on a standard chessboard 8 × 8 in size. The positions in which they are situated are known. It is guaranteed that none of them beats the other one.
Your task is to find the number of ways to place another kn... |
Solve the programming task below in a Python markdown code block.
Example
Input
1
Output
)(
Read the inputs from stdin solve the problem and write the answer to stdout (do not directly test on the sample inputs). Enclose your code within ```python delimiters. |
Solve the programming task below in a Python markdown code block.
And where the are the phone numbers?
You are given a string s consisting of lowercase English letters and an integer k. Find the lexicographically smallest string t of length k, such that its set of letters is a subset of the set of letters of s and s ... |
Solve the programming task below in a Python markdown code block.
You have given an array $a$ of length $n$ and an integer $x$ to a brand new robot. What the robot does is the following: it iterates over the elements of the array, let the current element be $q$. If $q$ is divisible by $x$, the robot adds $x$ copies of... |
Solve the programming task below in a Python markdown code block.
Write a program which performs the following operations to a binary search tree $T$ by adding delete operation to B: Binary Search Tree II.
* insert $k$: Insert a node containing $k$ as key into $T$.
* find $k$: Report whether $T$ has a node containin... |
Solve the programming task below in a Python markdown code block.
At the school where Vasya is studying, preparations are underway for the graduation ceremony. One of the planned performances is a ball, which will be attended by pairs of boys and girls.
Each class must present two couples to the ball. In Vasya's clas... |
Solve the programming task below in a Python markdown code block.
You are given an array $a$ consisting of $n$ integers.
In one move, you can choose two indices $1 \le i, j \le n$ such that $i \ne j$ and set $a_i := a_j$. You can perform such moves any number of times (possibly, zero). You can choose different indice... |
Solve the programming task below in a Python markdown code block.
Niwango-kun, an employee of Dwango Co., Ltd., likes Niconico TV-chan, so he collected a lot of soft toys of her and spread them on the floor.
Niwango-kun has N black rare soft toys of Niconico TV-chan and they are spread together with ordinary ones. He... |
Solve the programming task below in a Python markdown code block.
Problem D: Mr. Rito Post Office
You are a programmer working at a post office on a remote island. The area you live in consists of multiple islands. There is one or more port towns on each island. There may be other towns and villages in addition to th... |
Solve the programming task below in a Python markdown code block.
The king of a country loves prime numbers and gambling. The unit of currency in this country is called prime. As of November 1, 2007, Prime's cross-yen rate was just prime at 9973, so the King is overjoyed. Subsidiary coins with 1/101 prime as one subpr... |
Solve the programming task below in a Python markdown code block.
The Chef's latest idea is that some cooks might work better in pairs. So, he is going to experiment by pairing up some of his employees to see if the quality of the food prepared in his kitchen increases. However, only some pairs of employees are compat... |
Solve the programming task below in a Python markdown code block.
Let's introduce the designation <image>, where x is a string, n is a positive integer and operation " + " is the string concatenation operation. For example, [abc, 2] = abcabc.
We'll say that string s can be obtained from string t, if we can remove som... |
Solve the programming task below in a Python markdown code block.
Petya has equal wooden bars of length n. He wants to make a frame for two equal doors. Each frame has two vertical (left and right) sides of length a and one top side of length b. A solid (i.e. continuous without breaks) piece of bar is needed for each ... |
Solve the programming task below in a Python markdown code block.
DevuLand is a very strange place. There are n villages in it. Some of the villages are occupied by dinosaurs while the remaining ones by villagers.
You are given the information of DevuLand
by an array D of size n. If D[i] is non-negative, it means t... |
Solve the programming task below in a Python markdown code block.
Let a and b be some non-negative integers. Let's define strange addition of a and b as following:
1. write down the numbers one under another and align them by their least significant digit;
2. add them up digit by digit and concatenate the respec... |
Solve the programming task below in a Python markdown code block.
Given are three integers A_1, A_2, and A_3.
If A_1+A_2+A_3 is greater than or equal to 22, print bust; otherwise, print win.
-----Constraints-----
- 1 \leq A_i \leq 13 \ \ (i=1,2,3)
- All values in input are integers.
-----Input-----
Input is given ... |
Solve the programming task below in a Python markdown code block.
You are given N points in the xy-plane. You have a circle of radius one and move it on the xy-plane, so as to enclose as many of the points as possible. Find how many points can be simultaneously enclosed at the maximum. A point is considered enclosed b... |
Solve the programming task below in a Python markdown code block.
The process of mammoth's genome decoding in Berland comes to its end!
One of the few remaining tasks is to restore unrecognized nucleotides in a found chain s. Each nucleotide is coded with a capital letter of English alphabet: 'A', 'C', 'G' or 'T'. Un... |
Solve the programming task below in a Python markdown code block.
Compare two strings by comparing the sum of their values (ASCII character code).
* For comparing treat all letters as UpperCase
* `null/NULL/Nil/None` should be treated as empty strings
* If the string contains other characters than letters, treat the ... |
Solve the programming task below in a Python markdown code block.
We consider a positive integer perfect, if and only if the sum of its digits is exactly $10$. Given a positive integer $k$, your task is to find the $k$-th smallest perfect positive integer.
-----Input-----
A single line with a positive integer $k$ (... |
Solve the programming task below in a Python markdown code block.
Convenience store Deven Eleven is planning to open its first store in Aizuwakamatsu City to expand its business. There are already many other convenience stores in Aizuwakamatsu, so the place to open a new store is likely to be the key to success. Under... |
Solve the programming task below in a Python markdown code block.
You play a computer game. In this game, you lead a party of $m$ heroes, and you have to clear a dungeon with $n$ monsters. Each monster is characterized by its power $a_i$. Each hero is characterized by his power $p_i$ and endurance $s_i$.
The heroes c... |
Solve the programming task below in a Python markdown code block.
In this problem MEX of a certain array is the smallest positive integer not contained in this array.
Everyone knows this definition, including Lesha. But Lesha loves MEX, so he comes up with a new problem involving MEX every day, including today.
You ... |
Solve the programming task below in a Python markdown code block.
As a New Year's gift, Dolphin received a string s of length 19.
The string s has the following format: `[five lowercase English letters],[seven lowercase English letters],[five lowercase English letters]`.
Dolphin wants to convert the comma-separated st... |
Solve the programming task below in a Python markdown code block.
Vanya is managed to enter his favourite site Codehorses. Vanya uses n distinct passwords for sites at all, however he can't remember which one exactly he specified during Codehorses registration.
Vanya will enter passwords in order of non-decreasing th... |
Solve the programming task below in a Python markdown code block.
In Berland a bus travels along the main street of the capital. The street begins from the main square and looks like a very long segment. There are n bus stops located along the street, the i-th of them is located at the distance a_{i} from the central ... |
Solve the programming task below in a Python markdown code block.
Ms. Iyo Kiffa-Australis has a balance and only two kinds of weights to measure a dose of medicine.
For example, to measure 200mg of aspirin using 300mg weights and 700mg weights, she can put one 700mg weight on the side of the medicine and three 300mg ... |
Solve the programming task below in a Python markdown code block.
There are n TV shows you want to watch. Suppose the whole time is split into equal parts called "minutes". The i-th of the shows is going from l_i-th to r_i-th minute, both ends inclusive.
You need a TV to watch a TV show and you can't watch two TV sho... |
Solve the programming task below in a Python markdown code block.
Given 2 strings, your job is to find out if there is a substring that appears in both strings. You will return true if you find a substring that appears in both strings, or false if you do not. We only care about substrings that are longer than one lett... |
Solve the programming task below in a Python markdown code block.
Print the K-th element of the following sequence of length 32:
1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51
Constraints
* 1 \leq K \leq 32
* All values in input are integers.
Input
Input is give... |
Solve the programming task below in a Python markdown code block.
In the spring of 2014, a student successfully passed the university and started living alone. The problem here is what to do with the supper. He decided to plan a supper for the next N days.
He wants to maximize the total happiness he gets in N days. O... |
Solve the programming task below in a Python markdown code block.
The name of one small but proud corporation consists of n lowercase English letters. The Corporation has decided to try rebranding — an active marketing strategy, that includes a set of measures to change either the brand (both for the company and the g... |
Solve the programming task below in a Python markdown code block.
Victor and Peter are playing hide-and-seek. Peter has hidden, and Victor is to find him. In the room where they are playing, there is only one non-transparent wall and one double-sided mirror. Victor and Peter are points with coordinates (xv, yv) and (x... |
Solve the programming task below in a Python markdown code block.
You have a card deck of $n$ cards, numbered from top to bottom, i. e. the top card has index $1$ and bottom card — index $n$. Each card has its color: the $i$-th card has color $a_i$.
You should process $q$ queries. The $j$-th query is described by int... |
Solve the programming task below in a Python markdown code block.
Limak is a little bear who loves to play. Today he is playing by destroying block towers. He built n towers in a row. The i-th tower is made of hi identical blocks. For clarification see picture for the first sample.
Limak will repeat the following ope... |
Solve the programming task below in a Python markdown code block.
You are given an integer $n$ from $1$ to $10^{18}$ without leading zeroes.
In one move you can swap any two adjacent digits in the given number in such a way that the resulting number will not contain leading zeroes. In other words, after each move the... |
Solve the programming task below in a Python markdown code block.
Given a string $s$ of length $n$ and integer $k$ ($1 \le k \le n$). The string $s$ has a level $x$, if $x$ is largest non-negative integer, such that it's possible to find in $s$: $x$ non-intersecting (non-overlapping) substrings of length $k$, all ch... |
Solve the programming task below in a Python markdown code block.
You are the planning manager of an animation production company. What animation production companies produce these days is not limited to animation itself. Related products, such as figures of characters and character song CDs, are also important source... |
Solve the programming task below in a Python markdown code block.
Ryouko is an extremely forgetful girl, she could even forget something that has just happened. So in order to remember, she takes a notebook with her, called Ryouko's Memory Note. She writes what she sees and what she hears on the notebook, and the note... |
Solve the programming task below in a Python markdown code block.
There are N pieces of source code. The characteristics of the i-th code is represented by M integers A_{i1}, A_{i2}, ..., A_{iM}.
Additionally, you are given integers B_1, B_2, ..., B_M and C.
The i-th code correctly solves this problem if and only if A... |
Solve the programming task below in a Python markdown code block.
Vasya the programmer lives in the middle of the Programming subway branch. He has two girlfriends: Dasha and Masha, who live at the different ends of the branch, each one is unaware of the other one's existence.
When Vasya has some free time, he goes t... |
Solve the programming task below in a Python markdown code block.
The flag of Berland is such rectangular field n × m that satisfies following conditions:
Flag consists of three colors which correspond to letters 'R', 'G' and 'B'. Flag consists of three equal in width and height stripes, parralel to each other and... |
Solve the programming task below in a Python markdown code block.
Let's consider equation:x^2 + s(x)·x - n = 0,
where x, n are positive integers, s(x) is the function, equal to the sum of digits of number x in the decimal number system.
You are given an integer n, find the smallest positive integer root of equatio... |
Solve the programming task below in a Python markdown code block.
There are N boxes arranged in a circle. The i-th box contains A_i stones.
Determine whether it is possible to remove all the stones from the boxes by repeatedly performing the following operation:
* Select one box. Let the box be the i-th box. Then, f... |
Solve the programming task below in a Python markdown code block.
The $\text{$gcdSum$}$ of a positive integer is the $gcd$ of that integer with its sum of digits. Formally, $\text{$gcdSum$}(x) = gcd(x, \text{ sum of digits of } x)$ for a positive integer $x$. $gcd(a, b)$ denotes the greatest common divisor of $a$ and ... |
Solve the programming task below in a Python markdown code block.
As shown in the following figure, there is a paper consisting of a grid structure where each cell is indicated by (x, y) coordinate system.
We are going to put drops of ink on the paper. A drop comes in three different sizes: Large, Medium, and Small. ... |
Solve the programming task below in a Python markdown code block.
Mr. A wants to get to the destination on the Yamanote line.
After getting on the train, Mr. A gets up for a minute and sleeps for b minutes repeatedly. It is c minutes after boarding to the destination, and you can get off if you are awake at this time... |
Solve the programming task below in a Python markdown code block.
Maxim wants to buy some games at the local game shop. There are $n$ games in the shop, the $i$-th game costs $c_i$.
Maxim has a wallet which can be represented as an array of integers. His wallet contains $m$ bills, the $j$-th bill has value $a_j$.
Ga... |
Solve the programming task below in a Python markdown code block.
Vasya's telephone contains n photos. Photo number 1 is currently opened on the phone. It is allowed to move left and right to the adjacent photo by swiping finger over the screen. If you swipe left from the first photo, you reach photo n. Similarly, by ... |
Solve the programming task below in a Python markdown code block.
You are given a weighted undirected graph. The vertices are enumerated from 1 to n. Your task is to find the shortest path between the vertex 1 and the vertex n.
Input
The first line contains two integers n and m (2 ≤ n ≤ 105, 0 ≤ m ≤ 105), where n is... |
Solve the programming task below in a Python markdown code block.
The cake shop made a lot of roll cakes of various sizes. You have been tasked with arranging this cake in a box.
The roll cake is so soft that it will collapse if another roll cake is on top. Therefore, as shown in Fig. (A), all roll cakes must be arra... |
Solve the programming task below in a Python markdown code block.
# Task
Given some sticks by an array `V` of positive integers, where V[i] represents the length of the sticks, find the number of ways we can choose three of them to form a triangle.
# Example
For `V = [2, 3, 7, 4]`, the result should be `1`.
There... |
Solve the programming task below in a Python markdown code block.
Ilya the Lion wants to help all his friends with passing exams. They need to solve the following problem to pass the IT exam.
You've got string s = s_1s_2... s_{n} (n is the length of the string), consisting only of characters "." and "#" and m queries... |
Solve the programming task below in a Python markdown code block.
A set of four prime numbers arranged like (a, a + 2, a + 6, a + 8) is called a quadruplet prime number. Of the four prime numbers that make up a quadruplet prime, the largest number is called the size of the quadruplet prime. For example, the smallest p... |
Solve the programming task below in a Python markdown code block.
Given a list of unique words. Find all pairs of distinct indices (i, j) in the given list so that the concatenation of the two words, i.e. words[i] + words[j] is a palindrome.
Examples:
Non-string inputs should be converted to strings.
Return an arra... |
Solve the programming task below in a Python markdown code block.
Let $n$ be a positive integer. Let $a, b, c$ be nonnegative integers such that $a + b + c = n$.
Alice and Bob are gonna play rock-paper-scissors $n$ times. Alice knows the sequences of hands that Bob will play. However, Alice has to play rock $a$ times... |
Solve the programming task below in a Python markdown code block.
If I give you a date, can you tell me what day that date is? For example, december 8th, 2015 is a tuesday.
Your job is to write the function ```day(d)```
which takes a string representation of a date as input, in the format YYYYMMDD. The example would ... |
Solve the programming task below in a Python markdown code block.
Snuke loves "paper cutting": he cuts out characters from a newspaper headline and rearranges them to form another string.
He will receive a headline which contains one of the strings S_1,...,S_n tomorrow.
He is excited and already thinking of what strin... |
Solve the programming task below in a Python markdown code block.
You are the gym teacher in the school.
There are $n$ students in the row. And there are two rivalling students among them. The first one is in position $a$, the second in position $b$. Positions are numbered from $1$ to $n$ from left to right.
Since t... |
Solve the programming task below in a Python markdown code block.
Make the 2D list by the sequential integers started by the ```head``` number.
See the example test cases for the expected output.
```
Note:
-10**20 < the head number <10**20
1 <= the number of rows <= 1000
0 <= the number of columms <= 1000
```
R... |
Solve the programming task below in a Python markdown code block.
Professor Abacus has just built a new computing engine for making numerical tables. It was designed to calculate the values of a polynomial function in one variable at several points at a time. With the polynomial function f(x) = x2 + 2x + 1, for instan... |
Solve the programming task below in a Python markdown code block.
With your birthday coming up soon, your eccentric friend sent you a message to say "happy birthday":
hhhappyyyy biirrrrrthddaaaayyyyyyy to youuuu
hhapppyyyy biirtttthdaaay too youuu
happy birrrthdayy to youuu
happpyyyy birrtthdaaay tooo... |
Solve the programming task below in a Python markdown code block.
10^9 contestants, numbered 1 to 10^9, will compete in a competition. There will be two contests in this competition.
The organizer prepared N problems, numbered 1 to N, to use in these contests. When Problem i is presented in a contest, it will be solv... |
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.
<image>
Recently Xenia has bought n_r red gems, n_g green gems and n_b blue gems. Each of the gems has a weight.
N... |
Solve the programming task below in a Python markdown code block.
N people are waiting in a single line in front of the Takahashi Store. The cash on hand of the i-th person from the front of the line is a positive integer A_i.
Mr. Takahashi, the shop owner, has decided on the following scheme: He picks a product, set... |
Solve the programming task below in a Python markdown code block.
Your program fails again. This time it gets "Wrong answer on test 233"
.
This is the easier version of the problem. In this version 1 ≤ n ≤ 2000. You can hack this problem only if you solve and lock both problems.
The problem is about a test containi... |
Solve the programming task below in a Python markdown code block.
Amugae has a sentence consisting of $n$ words. He want to compress this sentence into one word. Amugae doesn't like repetitions, so when he merges two words into one word, he removes the longest prefix of the second word that coincides with a suffix of ... |
Solve the programming task below in a Python markdown code block.
There are n incoming messages for Vasya. The i-th message is going to be received after t_{i} minutes. Each message has a cost, which equals to A initially. After being received, the cost of a message decreases by B each minute (it can become negative).... |
Solve the programming task below in a Python markdown code block.
There is a plan view consisting of 12 vertical and 12 horizontal squares showing the terrain. Each square is painted white or black. White represents the sea and black represents the land. When two black squares touch each other vertically or horizontal... |
Solve the programming task below in a Python markdown code block.
Flatland is inhabited by pixels of three colors: red, green and blue. We know that if two pixels of different colors meet in a violent fight, only one of them survives the fight (that is, the total number of pixels decreases by one). Besides, if pixels ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.