question large_stringlengths 265 13.2k |
|---|
Solve the programming task below in a Python markdown code block.
A super computer has been built in the Turtle Academy of Sciences. The computer consists of n·m·k CPUs. The architecture was the paralellepiped of size n × m × k, split into 1 × 1 × 1 cells, each cell contains exactly one CPU. Thus, each CPU can be simu... |
Solve the programming task below in a Python markdown code block.
Once upon a time there were several little pigs and several wolves on a two-dimensional grid of size n × m. Each cell in this grid was either empty, containing one little pig, or containing one wolf.
A little pig and a wolf are adjacent if the cells th... |
Solve the programming task below in a Python markdown code block.
In late autumn evening n robots gathered in the cheerful company of friends. Each robot has a unique identifier — an integer from 1 to 10^9.
At some moment, robots decided to play the game "Snowball". Below there are the rules of this game. First, all ... |
Solve the programming task below in a Python markdown code block.
# Task
Given the birthdates of two people, find the date when the younger one is exactly half the age of the other.
# Notes
* The dates are given in the format YYYY-MM-DD and are not sorted in any particular order
* Round **down** to the nearest day
... |
Solve the programming task below in a Python markdown code block.
Check if given chord is minor or major.
_____________________________________________________________
Rules:
1. Basic minor/major chord have three elements.
2. Chord is minor when interval between first and second element equals 3 and between second ... |
Solve the programming task below in a Python markdown code block.
Polycarp has n dice d_1, d_2, ..., d_{n}. The i-th dice shows numbers from 1 to d_{i}. Polycarp rolled all the dice and the sum of numbers they showed is A. Agrippina didn't see which dice showed what number, she knows only the sum A and the values d_1,... |
Solve the programming task below in a Python markdown code block.
Ayrat has number n, represented as it's prime factorization p_{i} of size m, i.e. n = p_1·p_2·...·p_{m}. Ayrat got secret information that that the product of all divisors of n taken modulo 10^9 + 7 is the password to the secret data base. Now he wants ... |
Solve the programming task below in a Python markdown code block.
One day, liouzhou_101 got a chat record of Freda and Rainbow. Out of curiosity, he wanted to know which sentences were said by Freda, and which were said by Rainbow. According to his experience, he thought that Freda always said "lala." at the end of he... |
Solve the programming task below in a Python markdown code block.
You are given two integers A and B.
Find the largest value among A+B, A-B and A \times B.
-----Constraints-----
- -1000 \leq A,B \leq 1000
- All values in input are integers.
-----Input-----
Input is given from Standard Input in the following format... |
Solve the programming task below in a Python markdown code block.
On a number line there are n balls. At time moment 0 for each ball the following data is known: its coordinate xi, speed vi (possibly, negative) and weight mi. The radius of the balls can be ignored.
The balls collide elastically, i.e. if two balls wei... |
Solve the programming task below in a Python markdown code block.
Innokentiy likes tea very much and today he wants to drink exactly n cups of tea. He would be happy to drink more but he had exactly n tea bags, a of them are green and b are black.
Innokentiy doesn't like to drink the same tea (green or black) more th... |
Solve the programming task below in a Python markdown code block.
You are given an array of integers. Vasya can permute (change order) its integers. He wants to do it so that as many as possible integers will become on a place where a smaller integer used to stand. Help Vasya find the maximal number of such integers.
... |
Solve the programming task below in a Python markdown code block.
Create a program that reads the sales unit price and sales quantity and outputs the total sales amount and the average sales quantity.
Input
The input is given in the following format:
Sales unit price, sales quantity
Sales unit price, sales quant... |
Solve the programming task below in a Python markdown code block.
Given a positive integer `n`, return first n dgits of Thue-Morse sequence, as a string (see examples).
Thue-Morse sequence is a binary sequence with 0 as the first element. The rest of the sequece is obtained by adding the Boolean (binary) complement o... |
Solve the programming task below in a Python markdown code block.
Given an array A of N numbers, find the number of distinct pairs (i, j) such that j ≥i and A[i] = A[j].
First line of the input contains number of test cases T. Each test case has two lines, first line is the number N, followed by a line consisting of ... |
Solve the programming task below in a Python markdown code block.
Given is a tree T with N vertices. The i-th edge connects Vertex A_i and B_i (1 \leq A_i,B_i \leq N).
Now, each vertex is painted black with probability 1/2 and white with probability 1/2, which is chosen independently from other vertices. Then, let S b... |
Solve the programming task below in a Python markdown code block.
Last summer Peter was at his granny's in the country, when a wolf attacked sheep in the nearby forest. Now he fears to walk through the forest, to walk round the forest, even to get out of the house. He explains this not by the fear of the wolf, but by ... |
Solve the programming task below in a Python markdown code block.
Alex is transitioning from website design to coding and wants to sharpen his skills with CodeWars.
He can do ten kata in an hour, but when he makes a mistake, he must do pushups. These pushups really tire poor Alex out, so every time he does them they... |
Solve the programming task below in a Python markdown code block.
In this problem you are to calculate the sum of all integers from 1 to n, but you should take all powers of two with minus in the sum.
For example, for n = 4 the sum is equal to - 1 - 2 + 3 - 4 = - 4, because 1, 2 and 4 are 2^0, 2^1 and 2^2 respectiv... |
Solve the programming task below in a Python markdown code block.
# Introduction and Warm-up (Highly recommended)
# [Playing With Lists/Arrays Series](https://www.codewars.com/collections/playing-with-lists-slash-arrays)
___
# Task
**_Given_** an *array/list [] of integers* , **_Find_** **_The maximum difference_**... |
Solve the programming task below in a Python markdown code block.
Leo has developed a new programming language C+=. In C+=, integer variables can only be changed with a "+=" operation that adds the right-hand side value to the left-hand side variable. For example, performing "a += b" when a = $2$, b = $3$ changes the ... |
Solve the programming task below in a Python markdown code block.
There is an infinite set generated as follows:
$1$ is in this set.
If $x$ is in this set, $x \cdot a$ and $x+b$ both are in this set.
For example, when $a=3$ and $b=6$, the five smallest elements of the set are:
$1$,
$3$ ($1$ is in this set, so $1\... |
Solve the programming task below in a Python markdown code block.
You are given a sorted array $a_1, a_2, \dots, a_n$ (for each index $i > 1$ condition $a_i \ge a_{i-1}$ holds) and an integer $k$.
You are asked to divide this array into $k$ non-empty consecutive subarrays. Every element in the array should be include... |
Solve the programming task below in a Python markdown code block.
Alice is playing a game with her good friend, Marisa.
There are n boxes arranged in a line, numbered with integers from 1 to n from left to right. Marisa will hide a doll in one of the boxes. Then Alice will have m chances to guess where the doll is. I... |
Solve the programming task below in a Python markdown code block.
In Ancient Berland there were n cities and m two-way roads of equal length. The cities are numbered with integers from 1 to n inclusively. According to an ancient superstition, if a traveller visits three cities ai, bi, ci in row, without visiting other... |
Solve the programming task below in a Python markdown code block.
You have initially a string of N characters, denoted by A1,A2...AN. You have to print the size of the largest subsequence of string A such that all the characters in that subsequence are distinct ie. no two characters in that subsequence should be same.... |
Solve the programming task below in a Python markdown code block.
In this kata, you've to count lowercase letters in a given string and return the letter count in a hash with 'letter' as key and count as 'value'. The key must be 'symbol' instead of string in Ruby and 'char' instead of string in Crystal.
Example:
``... |
Solve the programming task below in a Python markdown code block.
You talked to Polycarp and asked him a question. You know that when he wants to answer "yes", he repeats Yes many times in a row.
Because of the noise, you only heard part of the answer — some substring of it. That is, if he answered YesYes, then you c... |
Solve the programming task below in a Python markdown code block.
# Introduction
There is a war and nobody knows - the alphabet war!
There are two groups of hostile letters. The tension between left side letters and right side letters was too high and the war began.
# Task
Write a function that accepts `fight` st... |
Solve the programming task below in a Python markdown code block.
Mr. Matsudaira is always careful about eco-friendliness in his life. Last month's water charge was 4280 yen, which exceeded the usual target of 4000 yen, so we have been trying to save water this month. How much have you saved on your water bill compare... |
Solve the programming task below in a Python markdown code block.
You are given n k-digit integers. You have to rearrange the digits in the integers so that the difference between the largest and the smallest number was minimum. Digits should be rearranged by the same rule in all integers.
Input
The first line conta... |
Solve the programming task below in a Python markdown code block.
Let's consider all integers in the range from $1$ to $n$ (inclusive).
Among all pairs of distinct integers in this range, find the maximum possible greatest common divisor of integers in pair. Formally, find the maximum value of $\mathrm{gcd}(a, b)$, w... |
Solve the programming task below in a Python markdown code block.
Anshal and his friends love watching TV series together,but Anshal has a habit of giving spoilers.In order to tackle this his friends anagrammed the list of the shows they were planning to watch.Somehow Anshal got hold of this list and started guessing ... |
Solve the programming task below in a Python markdown code block.
Finding your seat on a plane is never fun, particularly for a long haul flight... You arrive, realise again just how little leg room you get, and sort of climb into the seat covered in a pile of your own stuff.
To help confuse matters (although they cl... |
Solve the programming task below in a Python markdown code block.
Bamboo Blossoms
The bamboos live for decades, and at the end of their lives, they flower to make their seeds. Dr. ACM, a biologist, was fascinated by the bamboos in blossom in his travel to Tsukuba. He liked the flower so much that he was tempted to ma... |
Solve the programming task below in a Python markdown code block.
Alas, finding one's true love is not easy. Masha has been unsuccessful in that yet. Her friend Dasha told Masha about a way to determine the phone number of one's Prince Charming through arithmancy.
The phone number is divined like that. First one nee... |
Solve the programming task below in a Python markdown code block.
I am a craftsman specialized in interior works. A customer asked me to perform wiring work on a wall whose entire rectangular surface is tightly pasted with pieces of panels. The panels are all of the same size (2 m in width, 1 m in height) and the wall... |
Solve the programming task below in a Python markdown code block.
A rabbit who came to the fair found that the prize for a game at a store was a carrot cake. The rules for this game are as follows.
There is a grid-like field of vertical h squares x horizontal w squares, and each block has at most one block. Each bloc... |
Solve the programming task below in a Python markdown code block.
Given an array, return the difference between the count of even numbers and the count of odd numbers. `0` will be considered an even number.
```
For example:
solve([0,1,2,3]) = 0 because there are two even numbers and two odd numbers. Even - Odd = 2 -... |
Solve the programming task below in a Python markdown code block.
_This kata is based on [Project Euler Problem 546](https://projecteuler.net/problem=546)_
# Objective
Given the recursive sequence
fk(n) =
∑
i
=
0
n
fk(floor(i / k)) where fk(0) = 1
Define a function `f` that takes arguments `k` and `n` and... |
Solve the programming task below in a Python markdown code block.
For a string S consisting of the uppercase English letters `P` and `D`, let the doctoral and postdoctoral quotient of S be the total number of occurrences of `D` and `PD` in S as contiguous substrings. For example, if S = `PPDDP`, it contains two occurr... |
Solve the programming task below in a Python markdown code block.
Summer is coming! It's time for Iahub and Iahubina to work out, as they both want to look hot at the beach. The gym where they go is a matrix a with n lines and m columns. Let number a[i][j] represents the calories burned by performing workout at the ce... |
Solve the programming task below in a Python markdown code block.
Write a simple regex to validate a username. Allowed characters are:
- lowercase letters,
- numbers,
- underscore
Length should be between 4 and 16 characters (both included).
Write your solution by modifying this code:
```python
def validate_usr(us... |
Solve the programming task below in a Python markdown code block.
Oranges on Cans
square1001 You put a $ N $ can of aluminum on the table.
E869120 You put $ M $ of oranges on each aluminum can on the table.
How many oranges are on the aluminum can?
input
Input is given from standard input in the following format.... |
Solve the programming task below in a Python markdown code block.
Goal
Given a list of elements [a1, a2, ..., an], with each ai being a string, write a function **majority** that returns the value that appears the most in the list.
If there's no winner, the function should return None, NULL, nil, etc, based on the p... |
Solve the programming task below in a Python markdown code block.
Happy new year! The year 2020 is also known as Year Gyeongja (경자년, gyeongja-nyeon) in Korea. Where did the name come from? Let's briefly look at the Gapja system, which is traditionally used in Korea to name the years.
There are two sequences of $n$ st... |
Solve the programming task below in a Python markdown code block.
Recently personal training sessions have finished in the Berland State University Olympiad Programmer Training Centre. By the results of these training sessions teams are composed for the oncoming team contest season. Each team consists of three people.... |
Solve the programming task below in a Python markdown code block.
According to ISO 8601, the first calendar week (1) starts with the week containing the first thursday in january.
Every year contains of 52 (53 for leap years) calendar weeks.
**Your task is** to calculate the calendar week (1-53) from a given date.
Fo... |
Solve the programming task below in a Python markdown code block.
You are given an array $a_1, a_2, \dots, a_n$ where all $a_i$ are integers and greater than $0$.
In one operation, you can choose two different indices $i$ and $j$ ($1 \le i, j \le n$). If $gcd(a_i, a_j)$ is equal to the minimum element of the whole a... |
Solve the programming task below in a Python markdown code block.
The circle line of the Berland subway has n stations. We know the distances between all pairs of neighboring stations:
d_1 is the distance between the 1-st and the 2-nd station;
d_2 is the distance between the 2-nd and the 3-rd station;
...
d_{... |
Solve the programming task below in a Python markdown code block.
You are playing a popular video game which is famous for its depthful story and interesting puzzles. In the game you were locked in a mysterious house alone and there is no way to call for help, so you have to escape on yours own. However, almost every ... |
Solve the programming task below in a Python markdown code block.
So, the Berland is at war with its eternal enemy Flatland again, and Vasya, an accountant, was assigned to fulfil his duty to the nation.
Right now the situation in Berland is dismal — their both cities are surrounded! The armies of flatlanders stand ... |
Solve the programming task below in a Python markdown code block.
You are given a sequence of $n$ integers $a_1, \, a_2, \, \dots, \, a_n$.
Does there exist a sequence of $n$ integers $b_1, \, b_2, \, \dots, \, b_n$ such that the following property holds?
For each $1 \le i \le n$, there exist two (not necessarily di... |
Solve the programming task below in a Python markdown code block.
In this problem you have to simulate the workflow of one-thread server. There are n queries to process, the i-th will be received at moment t_{i} and needs to be processed for d_{i} units of time. All t_{i} are guaranteed to be distinct.
When a query a... |
Solve the programming task below in a Python markdown code block.
You play a strategic video game (yeah, we ran out of good problem legends). In this game you control a large army, and your goal is to conquer $n$ castles of your opponent.
Let's describe the game process in detail. Initially you control an army of $k$... |
Solve the programming task below in a Python markdown code block.
You drew lottery N times. In the i-th draw, you got an item of the kind represented by a string S_i.
How many kinds of items did you get?
-----Constraints-----
- 1 \leq N \leq 2\times 10^5
- S_i consists of lowercase English letters and has a length ... |
Solve the programming task below in a Python markdown code block.
Today, Wet Shark is given n integers. Using any of these integers no more than once, Wet Shark wants to get maximum possible even (divisible by 2) sum. Please, calculate this value for Wet Shark.
Note, that if Wet Shark uses no integers from the n int... |
Solve the programming task below in a Python markdown code block.
Recently, Petya learned about a new game "Slay the Dragon". As the name suggests, the player will have to fight with dragons. To defeat a dragon, you have to kill it and defend your castle. To do this, the player has a squad of $n$ heroes, the strength ... |
Solve the programming task below in a Python markdown code block.
You have a given picture with size $w \times h$. Determine if the given picture has a single "+" shape or not. A "+" shape is described below:
A "+" shape has one center nonempty cell. There should be some (at least one) consecutive non-empty cells ... |
Solve the programming task below in a Python markdown code block.
You are given three strings A, B and C. Each of these is a string of length N consisting of lowercase English letters.
Our objective is to make all these three strings equal. For that, you can repeatedly perform the following operation:
* Operation: C... |
Solve the programming task below in a Python markdown code block.
Given a string, determine if it's a valid identifier.
## Here is the syntax for valid identifiers:
* Each identifier must have at least one character.
* The first character must be picked from: alpha, underscore, or dollar sign. The first character can... |
Solve the programming task below in a Python markdown code block.
Write
```python
function repeating_fractions(numerator, denominator)
```
that given two numbers representing the numerator and denominator of a fraction, return the fraction in string format. If the fractional part has repeated digits, replace those dig... |
Solve the programming task below in a Python markdown code block.
A traveler is planning a water hike along the river. He noted the suitable rest points for the night and wrote out their distances from the starting point. Each of these locations is further characterized by its picturesqueness, so for the i-th rest poi... |
Solve the programming task below in a Python markdown code block.
It is a simplified version of problem F2. The difference between them is the constraints (F1: $k \le 2$, F2: $k \le 10$).
You are given an integer $n$. Find the minimum integer $x$ such that $x \ge n$ and the number $x$ is $k$-beautiful.
A number is c... |
Solve the programming task below in a Python markdown code block.
You are given an undirected graph with N vertices and 0 edges. Process Q queries of the following types.
* `0 u v`: Add an edge (u, v).
* `1 u v`: Print 1 if u and v are in the same connected component, 0 otherwise.
Constraints
* 1 \leq N \leq 200,00... |
Solve the programming task below in a Python markdown code block.
Your task is to write function which takes string and list of delimiters as an input and returns list of strings/characters after splitting given string.
Example:
```python
multiple_split('Hi, how are you?', [' ']) => ['Hi,', 'how', 'are', 'you?']
mult... |
Solve the programming task below in a Python markdown code block.
Example
Input
3 2
R1
Output
3 1 2
4 5 6
7 8 9
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.
There are N islands and M bridges.
The i-th bridge connects the A_i-th and B_i-th islands bidirectionally.
Initially, we can travel between any two islands using some of these bridges.
However, the results of a survey show that these bridges will all co... |
Solve the programming task below in a Python markdown code block.
Barbara was late for her math class so as a punishment the teacher made her solve the task on a sheet of paper. Barbara looked at the sheet of paper and only saw n numbers a_1, a_2, …, a_n without any mathematical symbols. The teacher explained to Barba... |
Solve the programming task below in a Python markdown code block.
Petya is a math teacher. n of his students has written a test consisting of m questions. For each student, it is known which questions he has answered correctly and which he has not.
If the student answers the j-th question correctly, he gets p_j point... |
Solve the programming task below in a Python markdown code block.
Mike decided to teach programming to children in an elementary school. He knows that it is not an easy task to interest children in that age to code. That is why he decided to give each child two sweets.
Mike has $n$ sweets with sizes $a_1, a_2, \ldots... |
Solve the programming task below in a Python markdown code block.
Example
Input
2
1 2
Output
2
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.
A chessboard n × m in size is given. During the zero minute we repaint all the black squares to the 0 color. During the i-th minute we repaint to the i color the initially black squares that have exactly four corner-adjacent squares painted i - 1 (all s... |
Solve the programming task below in a Python markdown code block.
Andrey's favourite number is n. Andrey's friends gave him two identical numbers n as a New Year present. He hung them on a wall and watched them adoringly.
Then Andrey got bored from looking at the same number and he started to swap digits first in one... |
Solve the programming task below in a Python markdown code block.
Takahashi has a tower which is divided into N layers. Initially, all the layers are uncolored. Takahashi is going to paint some of the layers in red, green or blue to make a beautiful tower. He defines the beauty of the tower as follows:
* The beauty o... |
Solve the programming task below in a Python markdown code block.
Polycarp likes numbers that are divisible by 3.
He has a huge number $s$. Polycarp wants to cut from it the maximum number of numbers that are divisible by $3$. To do this, he makes an arbitrary number of vertical cuts between pairs of adjacent digits.... |
Solve the programming task below in a Python markdown code block.
A prime number is a natural number which has exactly two distinct natural number divisors: 1 and itself. For example, the first four prime numbers are: 2, 3, 5 and 7.
Write a program which reads a list of N integers and prints the number of prime numbe... |
Solve the programming task below in a Python markdown code block.
Polycarp likes arithmetic progressions. A sequence $[a_1, a_2, \dots, a_n]$ is called an arithmetic progression if for each $i$ ($1 \le i < n$) the value $a_{i+1} - a_i$ is the same. For example, the sequences $[42]$, $[5, 5, 5]$, $[2, 11, 20, 29]$ and ... |
Solve the programming task below in a Python markdown code block.
Gennady owns a small hotel in the countryside where he lives a peaceful life. He loves to take long walks, watch sunsets and play cards with tourists staying in his hotel. His favorite game is called "Mau-Mau".
To play Mau-Mau, you need a pack of $52$ ... |
Solve the programming task below in a Python markdown code block.
Your friend won't stop texting his girlfriend. It's all he does. All day. Seriously. The texts are so mushy too! The whole situation just makes you feel ill.
Being the wonderful friend that you are, you hatch an evil plot. While he's sleeping, you ta... |
Solve the programming task below in a Python markdown code block.
A country has coins with denominations
```python
coins_list = d1 < d2 < · · · < dn.
```
You want to make change for n cents, using the smallest number of coins.
```python
# Example 1: U.S. coins
d1 = 1 d2 = 5 d3 = 10 d4 = 25
## Optimal change for 37 c... |
Solve the programming task below in a Python markdown code block.
There are two buttons, one of size A and one of size B.
When you press a button of size X, you get X coins and the size of that button decreases by 1.
You will press a button twice. Here, you can press the same button twice, or press both buttons once.
... |
Solve the programming task below in a Python markdown code block.
Barney lives in country USC (United States of Charzeh). USC has n cities numbered from 1 through n and n - 1 roads between them. Cities and roads of USC form a rooted tree (Barney's not sure why it is rooted). Root of the tree is the city number 1. Thus... |
Solve the programming task below in a Python markdown code block.
Create a function `isAlt()` that accepts a string as an argument and validates whether the vowels (a, e, i, o, u) and consonants are in alternate order.
```python
is_alt("amazon")
// true
is_alt("apple")
// false
is_alt("banana")
// true
```
Arguments... |
Solve the programming task below in a Python markdown code block.
There is a cube which consists of n × n × n small cubes. Small cubes have marks on their surfaces. An example where n = 4 is shown in the following figure.
<image>
Then, as shown in the figure above (right), make a hole that penetrates horizontally ... |
Solve the programming task below in a Python markdown code block.
Constraints
* 1 ≤ |V| ≤ 1000
* 0 ≤ |E| ≤ 2000
* -10000 ≤ di ≤ 10000
* There are no parallel edges
* There are no self-loops
Input
An edge-weighted graph G (V, E) and the source r.
|V| |E| r
s0 t0 d0
s1 t1 d1
:
s|E|-1 t|E|-1 d|E|-1
|V| is the numb... |
Solve the programming task below in a Python markdown code block.
B: Hokkaido University Hard
Note
Please note that the question settings are the same as question A, except for the constraints.
story
Homura-chan, who passed Hokkaido University and is excited about the beginning of a new life. But in front of her, ... |
Solve the programming task below in a Python markdown code block.
Implement `String#whitespace?(str)` (Ruby), `String.prototype.whitespace(str)` (JavaScript), `String::whitespace(str)` (CoffeeScript), or `whitespace(str)` (Python), which should return `true/True` if given object consists exclusively of zero or more wh... |
Solve the programming task below in a Python markdown code block.
Problem
KND is a student programmer at the University of Aizu. His chest is known to be very sexy.
<image>
For simplicity, the part of the skin that can be seen from the chest is represented by the isosceles triangle ABC in the figure. However, due ... |
Solve the programming task below in a Python markdown code block.
Takahashi is solving quizzes. He has easily solved all but the last one.
The last quiz has three choices: 1, 2, and 3.
With his supernatural power, Takahashi has found out that the choices A and B are both wrong.
Print the correct choice for this proble... |
Solve the programming task below in a Python markdown code block.
You are given an array $a[0 \ldots n-1]$ of length $n$ which consists of non-negative integers. Note that array indices start from zero.
An array is called good if the parity of each index matches the parity of the element at that index. More formally,... |
Solve the programming task below in a Python markdown code block.
The postal code in Atcoder Kingdom is A+B+1 characters long, its (A+1)-th character is a hyphen -, and the other characters are digits from 0 through 9.
You are given a string S. Determine whether it follows the postal code format in Atcoder Kingdom.
-... |
Solve the programming task below in a Python markdown code block.
CQXYM found a rectangle A of size n × m. There are n rows and m columns of blocks. Each block of the rectangle is an obsidian block or empty. CQXYM can change an obsidian block to an empty block or an empty block to an obsidian block in one operation.
... |
Solve the programming task below in a Python markdown code block.
Note that girls in Arpa’s land are really attractive.
Arpa loves overnight parties. In the middle of one of these parties Mehrdad suddenly appeared. He saw n pairs of friends sitting around a table. i-th pair consisted of a boy, sitting on the a_{i}-th... |
Solve the programming task below in a Python markdown code block.
Mash 2 arrays together so that the returning array has alternating elements of the 2 arrays . Both arrays will always be the same length.
eg. [1,2,3] + ['a','b','c'] = [1, 'a', 2, 'b', 3, 'c']
Write your solution by modifying this code:
```python
de... |
Solve the programming task below in a Python markdown code block.
Polycarp wrote on the board a string $s$ containing only lowercase Latin letters ('a'-'z'). This string is known for you and given in the input.
After that, he erased some letters from the string $s$, and he rewrote the remaining letters in any order. ... |
Solve the programming task below in a Python markdown code block.
Just to remind, girls in Arpa's land are really nice.
Mehrdad wants to invite some Hoses to the palace for a dancing party. Each Hos has some weight wi and some beauty bi. Also each Hos may have some friends. Hoses are divided in some friendship groups... |
Solve the programming task below in a Python markdown code block.
Write a program which reads an directed graph $G = (V, E)$, and finds the shortest distance from vertex $1$ to each vertex (the number of edges in the shortest path). Vertices are identified by IDs $1, 2, ... n$.
Constraints
* $1 \leq n \leq 100$
Inp... |
Solve the programming task below in a Python markdown code block.
A university student, Takahashi, has to take N examinations and pass all of them. Currently, his readiness for the i-th examination is A_{i}, and according to his investigation, it is known that he needs readiness of at least B_{i} in order to pass the ... |
Solve the programming task below in a Python markdown code block.
Stephen Queen wants to write a story. He is a very unusual writer, he uses only letters 'a', 'b', 'c', 'd' and 'e'!
To compose a story, Stephen wrote out $n$ words consisting of the first $5$ lowercase letters of the Latin alphabet. He wants to select ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.