question large_stringlengths 265 13.2k |
|---|
Solve the programming task below in a Python markdown code block.
One day Misha and Andrew were playing a very simple game. First, each player chooses an integer in the range from 1 to n. Let's assume that Misha chose number m, and Andrew chose number a.
Then, by using a random generator they choose a random integer ... |
Solve the programming task below in a Python markdown code block.
Define a method that accepts 2 strings as parameters. The method returns the first string sorted by the second.
```python
sort_string("foos", "of") == "oofs"
sort_string("string", "gnirts") == "gnirts"
sort_string("banana", "abn") == "aaabnn"
... |
Solve the programming task below in a Python markdown code block.
Nathan O. Davis is trying to capture a game and struggling to get a very rare item. This rare item can be obtained by arranging special patterns in a row on a casino slot machine. The slot machine has N reels, and pressing the button once stops the curr... |
Solve the programming task below in a Python markdown code block.
Given the list of numbers, you are to sort them in non decreasing order.
-----Input-----
t – the number of numbers in list, then t lines follow [t <= 10^6].
Each line contains one integer: N [0 <= N <= 10^6]
-----Output-----
Output given numbers in ... |
Solve the programming task below in a Python markdown code block.
To make it difficult to withdraw money, a certain bank allows its customers to withdraw only one of the following amounts in one operation:
- 1 yen (the currency of Japan)
- 6 yen, 6^2(=36) yen, 6^3(=216) yen, ...
- 9 yen, 9^2(=81) yen, 9^3(=729) yen... |
Solve the programming task below in a Python markdown code block.
Diameter of a Tree
Given a tree T with non-negative weight, find the diameter of the tree.
The diameter of a tree is the maximum distance between two nodes in a tree.
Constraints
* 1 ≤ n ≤ 100,000
* 0 ≤ wi ≤ 1,000
Input
n
s1 t1 w1
s2 t2 w2
:
s... |
Solve the programming task below in a Python markdown code block.
Takahashi has a strong stomach. He never gets a stomachache from eating something whose "best-by" date is at most X days earlier.
He gets a stomachache if the "best-by" date of the food is X+1 or more days earlier, though.
Other than that, he finds the ... |
Solve the programming task below in a Python markdown code block.
For a dynamic array $A = \\{a_0, a_1, ...\\}$ of integers, perform a sequence of the following operations:
* pushBack($x$): add element $x$ at the end of $A$
* randomAccess($p$):print element $a_p$
* popBack(): delete the last element of $A$
$A$ is ... |
Solve the programming task below in a Python markdown code block.
Read problems statements in Mandarin Chinese and Russian.
Roman has no idea, why this problem is called Stone. He also has no idea on how to solve the followong problem: given array of N integers A and a number K. During a turn the maximal value over ... |
Solve the programming task below in a Python markdown code block.
You are given three sticks with positive integer lengths of a, b, and c centimeters. You can increase length of some of them by some positive integer number of centimeters (different sticks can be increased by a different length), but in total by at mos... |
Solve the programming task below in a Python markdown code block.
Ekiden competitions are held every year in Aizukuni. The country of Aiz is dotted with N towns, each numbered from 1 to N. Several towns are connected by roads that allow them to come and go directly to each other. You can also follow several roads betw... |
Solve the programming task below in a Python markdown code block.
Write a program that prints a chessboard with N rows and M columns with the following rules:
The top left cell must be an asterisk (*)
Any cell touching (left, right, up or down) a cell with an asterisk must be a dot (.)
Any cell touching (left, right, ... |
Solve the programming task below in a Python markdown code block.
Vasya has got a magic matrix a of size n × m. The rows of the matrix are numbered from 1 to n from top to bottom, the columns are numbered from 1 to m from left to right. Let a_{ij} be the element in the intersection of the i-th row and the j-th column.... |
Solve the programming task below in a Python markdown code block.
There are K items placed on a grid of squares with R rows and C columns. Let (i, j) denote the square at the i-th row (1 \leq i \leq R) and the j-th column (1 \leq j \leq C). The i-th item is at (r_i, c_i) and has the value v_i.
Takahashi will begin at ... |
Solve the programming task below in a Python markdown code block.
You are given a grid with 2 rows and 3 columns of squares.
The color of the square at the i-th row and j-th column is represented by the character C_{ij}.
Write a program that prints YES if this grid remains the same when rotated 180 degrees, and prints... |
Solve the programming task below in a Python markdown code block.
To satisfy his love of matching socks, Phoenix has brought his $n$ socks ($n$ is even) to the sock store. Each of his socks has a color $c_i$ and is either a left sock or right sock.
Phoenix can pay one dollar to the sock store to either:
recolor a so... |
Solve the programming task below in a Python markdown code block.
In the good old Hachioji railroad station located in the west of Tokyo, there are several parking lines, and lots of freight trains come and go every day.
All freight trains travel at night, so these trains containing various types of cars are settled ... |
Solve the programming task below in a Python markdown code block.
Polycarpus got an internship in one well-known social network. His test task is to count the number of unique users who have visited a social network during the day. Polycarpus was provided with information on all user requests for this time period. For... |
Solve the programming task below in a Python markdown code block.
Takahashi has decided to make a Christmas Tree for the Christmas party in AtCoder, Inc.
A Christmas Tree is a tree with N vertices numbered 1 through N and N-1 edges, whose i-th edge (1\leq i\leq N-1) connects Vertex a_i and b_i.
He would like to make... |
Solve the programming task below in a Python markdown code block.
Sasha likes programming. Once, during a very long contest, Sasha decided that he was a bit tired and needed to relax. So he did. But since Sasha isn't an ordinary guy, he prefers to relax unusually. During leisure time Sasha likes to upsolve unsolved pr... |
Solve the programming task below in a Python markdown code block.
Laura really hates people using acronyms in her office and wants to force her colleagues to remove all acronyms before emailing her. She wants you to build a system that will edit out all known acronyms or else will notify the sender if unknown acronyms... |
Solve the programming task below in a Python markdown code block.
You've got two rectangular tables with sizes na × ma and nb × mb cells. The tables consist of zeroes and ones. We will consider the rows and columns of both tables indexed starting from 1. Then we will define the element of the first table, located at t... |
Solve the programming task below in a Python markdown code block.
A little bear Limak plays a game. He has five cards. There is one number written on each card. Each number is a positive integer.
Limak can discard (throw out) some cards. His goal is to minimize the sum of numbers written on remaining (not discarded) ... |
Solve the programming task below in a Python markdown code block.
Innokenty is a president of a new football league in Byteland. The first task he should do is to assign short names to all clubs to be shown on TV next to the score. Of course, the short names should be distinct, and Innokenty wants that all short names... |
Solve the programming task below in a Python markdown code block.
Write a function that calculates the *least common multiple* of its arguments; each argument is assumed to be a non-negative integer. In the case that there are no arguments (or the provided array in compiled languages is empty), return `1`.
~~~if:objc... |
Solve the programming task below in a Python markdown code block.
Short Phrase
A Short Phrase (aka. Tanku) is a fixed verse, inspired by Japanese poetry Tanka and Haiku. It is a sequence of words, each consisting of lowercase letters 'a' to 'z', and must satisfy the following condition:
> (The Condition for a Short ... |
Solve the programming task below in a Python markdown code block.
You will receive 5 points for solving this problem.
Manao has invented a new operation on strings that is called folding. Each fold happens between a pair of consecutive letters and places the second part of the string above first part, running in the ... |
Solve the programming task below in a Python markdown code block.
You are given a n × m field consisting only of periods ('.') and asterisks ('*'). Your task is to count all right triangles with two sides parallel to the square sides, whose vertices are in the centers of '*'-cells. A right triangle is a triangle in wh... |
Solve the programming task below in a Python markdown code block.
Squirrel Liss lived in a forest peacefully, but unexpected trouble happens. Stones fall from a mountain. Initially Squirrel Liss occupies an interval [0, 1]. Next, n stones will fall and Liss will escape from the stones. The stones are numbered from 1 t... |
Solve the programming task below in a Python markdown code block.
There is an empty array.
The following N operations will be performed to insert integers into the array.
In the i-th operation (1≤i≤N), b_i copies of an integer a_i are inserted into the array.
Find the K-th smallest integer in the array after the N ope... |
Solve the programming task below in a Python markdown code block.
You are given a string q. A sequence of k strings s_1, s_2, ..., s_{k} is called beautiful, if the concatenation of these strings is string q (formally, s_1 + s_2 + ... + s_{k} = q) and the first characters of these strings are distinct.
Find any beaut... |
Solve the programming task below in a Python markdown code block.
You are given two integers $a$ and $m$. Calculate the number of integers $x$ such that $0 \le x < m$ and $\gcd(a, m) = \gcd(a + x, m)$.
Note: $\gcd(a, b)$ is the greatest common divisor of $a$ and $b$.
-----Input-----
The first line contains the sin... |
Solve the programming task below in a Python markdown code block.
Melody Pond was stolen from her parents as a newborn baby by Madame Kovarian, to become a weapon of the Silence in their crusade against the Doctor. Madame Kovarian changed Melody's name to River Song, giving her a new identity that allowed her to kill ... |
Solve the programming task below in a Python markdown code block.
There are $n$ benches in the Berland Central park. It is known that $a_i$ people are currently sitting on the $i$-th bench. Another $m$ people are coming to the park and each of them is going to have a seat on some bench out of $n$ available.
Let $k$ b... |
Solve the programming task below in a Python markdown code block.
On his trip to Luxor and Aswan, Sagheer went to a Nubian market to buy some souvenirs for his friends and relatives. The market has some strange rules. It contains n different items numbered from 1 to n. The i-th item has base cost a_{i} Egyptian pounds... |
Solve the programming task below in a Python markdown code block.
There are many anime that are about "love triangles": Alice loves Bob, and Charlie loves Bob as well, but Alice hates Charlie. You are thinking about an anime which has n characters. The characters are labeled from 1 to n. Every pair of two characters c... |
Solve the programming task below in a Python markdown code block.
Bob is playing a game named "Walk on Matrix".
In this game, player is given an n × m matrix A=(a_{i,j}), i.e. the element in the i-th row in the j-th column is a_{i,j}. Initially, player is located at position (1,1) with score a_{1,1}.
To reach the g... |
Solve the programming task below in a Python markdown code block.
Little Petya loves looking for numbers' divisors. One day Petya came across the following problem:
You are given n queries in the form "xi yi". For each query Petya should count how many divisors of number xi divide none of the numbers xi - yi, xi - yi... |
Solve the programming task below in a Python markdown code block.
Read problems statements in Mandarin Chinese and Russian.
Once Chef decided to divide the tangerine into several parts. At first, he numbered tangerine's segments from 1 to n in the clockwise order starting from some segment. Then he intended to divi... |
Solve the programming task below in a Python markdown code block.
Vasya has a beautiful garden where wonderful fruit trees grow and yield fantastic harvest every year. But lately thieves started to sneak into the garden at nights and steal the fruit too often. Vasya can’t spend the nights in the garden and guard the f... |
Solve the programming task below in a Python markdown code block.
In this Kata, you will be given two positive integers `a` and `b` and your task will be to apply the following operations:
```
i) If a = 0 or b = 0, return [a,b]. Otherwise, go to step (ii);
ii) If a ≥ 2*b, set a = a - 2*b, and repeat step (i). Otherwi... |
Solve the programming task below in a Python markdown code block.
You are given a string $s$ of length $n$, which consists only of the first $k$ letters of the Latin alphabet. All letters in string $s$ are uppercase.
A subsequence of string $s$ is a string that can be derived from $s$ by deleting some of its symbols ... |
Solve the programming task below in a Python markdown code block.
Chef talks a lot on his mobile phone. As a result he exhausts his talk-value (in Rokdas) very quickly. One day at a mobile recharge shop, he noticed that his service provider gives add-on plans which can lower his calling rates (Rokdas/minute). One of t... |
Solve the programming task below in a Python markdown code block.
We have a grid with H horizontal rows and W vertical columns. Let (i,j) denote the square at the i-th row from the top and the j-th column from the left.
The square (i, j) has two numbers A_{ij} and B_{ij} written on it.
First, for each square, Takahash... |
Solve the programming task below in a Python markdown code block.
In Morse code, an letter of English alphabet is represented as a string of some length from $1$ to $4$. Moreover, each Morse code representation of an English letter contains only dots and dashes. In this task, we will represent a dot with a "0" and a d... |
Solve the programming task below in a Python markdown code block.
Create a program that reads the attendance numbers of students in a class and the data that stores the ABO blood group and outputs the number of people for each blood type. There are four types of ABO blood types: A, B, AB, and O.
Input
A comma-sepa... |
Solve the programming task below in a Python markdown code block.
Complete the function to determine the number of bits required to convert integer `A` to integer `B` (where `A` and `B` >= 0)
The upper limit for `A` and `B` is 2^(16), `int.MaxValue` or similar.
For example, you can change 31 to 14 by flipping the 4t... |
Solve the programming task below in a Python markdown code block.
## Witamy!
You are in Poland and want to order a drink. You need to ask "One beer please": "Jedno piwo poprosze"
``` java
Translator.orderingBeers(1) = "Jedno piwo poprosze"
```
But let's say you are really thirsty and want several beers. Then you ne... |
Solve the programming task below in a Python markdown code block.
Problem statement
Meatishi can increase or decrease the number of fingers.
There are n buns in front of Nikunishi-kun.
Meatishi is trying to count the number of steamed buns by breaking his finger.
There are only two shapes that Nishikun's fingers can ... |
Solve the programming task below in a Python markdown code block.
As we all know Barney's job is "PLEASE" and he has not much to do at work. That's why he started playing "cups and key". In this game there are three identical cups arranged in a line from left to right. Initially key to Barney's heart is under the midd... |
Solve the programming task below in a Python markdown code block.
There is an ice cream shop named Ten Ice Cream. At this store, we always have 10 types of ice cream on the shelves. The store manager creates a daily graph showing how well ice cream is selling for reference in product development.
For such a store man... |
Solve the programming task below in a Python markdown code block.
A string is called square if it is some string written twice in a row. For example, the strings "aa", "abcabc", "abab" and "baabaa" are square. But the strings "aaa", "abaaab" and "abcdabc" are not square.
For a given string $s$ determine if it is squa... |
Solve the programming task below in a Python markdown code block.
You have to write two methods to *encrypt* and *decrypt* strings.
Both methods have two parameters:
```
1. The string to encrypt/decrypt
2. The Qwerty-Encryption-Key (000-999)
```
The rules are very easy:
```
The crypting-regions are these 3 lines fro... |
Solve the programming task below in a Python markdown code block.
Recently, Dima met with Sasha in a philatelic store, and since then they are collecting coins together. Their favorite occupation is to sort collections of coins. Sasha likes having things in order, that is why he wants his coins to be arranged in a row... |
Solve the programming task below in a Python markdown code block.
A robber has attempted to rob a bank but failed to complete his task. However, he had managed to open all the safes.
Oleg the bank client loves money (who doesn't), and decides to take advantage of this failed robbery and steal some money from the safe... |
Solve the programming task below in a Python markdown code block.
Sheldon Cooper, Leonard Hofstadter and Penny decide to go for drinks at Cheese cake factory. Sheldon proposes to make a game out of this. Sheldon proposes as follows,
To decide the amount of beverage they plan to consume, say X.
Then order for a rando... |
Solve the programming task below in a Python markdown code block.
Monocarp is playing yet another computer game. In this game, his character has to kill a dragon. The battle with the dragon lasts $100^{500}$ seconds, during which Monocarp attacks the dragon with a poisoned dagger. The $i$-th attack is performed at the... |
Solve the programming task below in a Python markdown code block.
Champernown constant is an irrational number represented in decimal by "0." followed by concatenation of all positive integers in the increasing order. The first few digits of this constant are: 0.123456789101112...
Your task is to write a program that... |
Solve the programming task below in a Python markdown code block.
Your back at your newly acquired decrypting job for the secret organization when a new assignment comes in. Apparently the enemy has been communicating using a device they call "The Mirror".
It is a rudimentary device with encrypts the message by sw... |
Solve the programming task below in a Python markdown code block.
Alice and Bob love playing one-dimensional battle ships. They play on the field in the form of a line consisting of n square cells (that is, on a 1 × n table).
At the beginning of the game Alice puts k ships on the field without telling their positions... |
Solve the programming task below in a Python markdown code block.
Look for the Winner!
The citizens of TKB City are famous for their deep love in elections and vote counting. Today they hold an election for the next chairperson of the electoral commission. Now the voting has just been closed and the counting is going... |
Solve the programming task below in a Python markdown code block.
The whole world got obsessed with robots,and to keep pace with the progress, great Berland's programmer Draude decided to build his own robot. He was working hard at the robot. He taught it to walk the shortest path from one point to another, to record ... |
Solve the programming task below in a Python markdown code block.
There is a bookshelf which can fit $n$ books. The $i$-th position of bookshelf is $a_i = 1$ if there is a book on this position and $a_i = 0$ otherwise. It is guaranteed that there is at least one book on the bookshelf.
In one move, you can choose some... |
Solve the programming task below in a Python markdown code block.
Polycarp took $n$ videos, the duration of the $i$-th video is $a_i$ seconds. The videos are listed in the chronological order, i.e. the $1$-st video is the earliest, the $2$-nd video is the next, ..., the $n$-th video is the last.
Now Polycarp wants to... |
Solve the programming task below in a Python markdown code block.
Vasya writes his own library for building graphical user interface. Vasya called his creation VTK (VasyaToolKit). One of the interesting aspects of this library is that widgets are packed in each other.
A widget is some element of graphical interface.... |
Solve the programming task below in a Python markdown code block.
Akari has n kinds of flowers, one of each kind.
She is going to choose one or more of these flowers to make a bouquet.
However, she hates two numbers a and b, so the number of flowers in the bouquet cannot be a or b.
How many different bouquets are ther... |
Solve the programming task below in a Python markdown code block.
Well, the series which Stepan watched for a very long time, ended. In total, the series had n episodes. For each of them, Stepan remembers either that he definitely has watched it, or that he definitely hasn't watched it, or he is unsure, has he watched... |
Solve the programming task below in a Python markdown code block.
Let $LCM(x, y)$ be the minimum positive integer that is divisible by both $x$ and $y$. For example, $LCM(13, 37) = 481$, $LCM(9, 6) = 18$.
You are given two integers $l$ and $r$. Find two integers $x$ and $y$ such that $l \le x < y \le r$ and $l \le LC... |
Solve the programming task below in a Python markdown code block.
Read problems statements in Mandarin Chinese and Russian.
You are given an array A of N integers. You are to fulfill M queries. Each query has one of the following three types:
C d : Rotate the array A clockwise by d units.
A d : Rotate the array A ... |
Solve the programming task below in a Python markdown code block.
Calculate the product of all elements in an array.
```if:csharp
If the array is *null*, you should throw `ArgumentNullException` and if the array is empty, you should throw `InvalidOperationException`.
As a challenge, try writing your method in just on... |
Solve the programming task below in a Python markdown code block.
Valera's lifelong ambition was to be a photographer, so he bought a new camera. Every day he got more and more clients asking for photos, and one day Valera needed a program that would determine the maximum number of people he can serve.
The camera's m... |
Solve the programming task below in a Python markdown code block.
Take an integer `n (n >= 0)` and a digit `d (0 <= d <= 9)` as an integer. Square all numbers `k (0 <= k <= n)` between 0 and n. Count the numbers of
digits `d` used in the writing of all the `k**2`. Call `nb_dig` (or nbDig or ...) the function taking `... |
Solve the programming task below in a Python markdown code block.
Andrey thinks he is truly a successful developer, but in reality he didn't know about the binary search algorithm until recently. After reading some literature Andrey understood that this algorithm allows to quickly find a certain number $x$ in an array... |
Solve the programming task below in a Python markdown code block.
Ken loves ken-ken-pa (Japanese version of hopscotch). Today, he will play it on a directed graph G.
G consists of N vertices numbered 1 to N, and M edges. The i-th edge points from Vertex u_i to Vertex v_i.
First, Ken stands on Vertex S. He wants to rea... |
Solve the programming task below in a Python markdown code block.
Gardener Alexey teaches competitive programming to high school students. To congratulate Alexey on the Teacher's Day, the students have gifted him a collection of wooden sticks, where every stick has an integer length. Now Alexey wants to grow a tree fr... |
Solve the programming task below in a Python markdown code block.
Each month Blake gets the report containing main economic indicators of the company "Blake Technologies". There are n commodities produced by the company. For each of them there is exactly one integer in the final report, that denotes corresponding reve... |
Solve the programming task below in a Python markdown code block.
<image>
The International Clown and Pierrot Competition (ICPC), is one of the most distinguished and also the most popular events on earth in the show business.
One of the unique features of this contest is the great number of judges that sometimes co... |
Solve the programming task below in a Python markdown code block.
You have integer $n$. Calculate how many ways are there to fully cover belt-like area of $4n-2$ triangles with diamond shapes.
Diamond shape consists of two triangles. You can move, rotate or flip the shape, but you cannot scale it.
$2$ coverings ar... |
Solve the programming task below in a Python markdown code block.
You are given string s consists of opening and closing brackets of four kinds <>, {}, [], (). There are two types of brackets: opening and closing. You can replace any bracket by another of the same type. For example, you can replace < by the bracket {,... |
Solve the programming task below in a Python markdown code block.
It's that time of the year, Felicity is around the corner and you can see people celebrating all around the Himalayan region. The Himalayan region has n gyms. The i-th gym has g_{i} Pokemon in it. There are m distinct Pokemon types in the Himalayan regi... |
Solve the programming task below in a Python markdown code block.
We will call a string obtained by arranging the characters contained in a string a in some order, an anagram of a.
For example, greenbin is an anagram of beginner. As seen here, when the same character occurs multiple times, that character must be used ... |
Solve the programming task below in a Python markdown code block.
You stumbled upon a new kind of chess puzzles. The chessboard you are given is not necesserily $8 \times 8$, but it still is $N \times N$. Each square has some number written on it, all the numbers are from $1$ to $N^2$ and all the numbers are pairwise ... |
Solve the programming task below in a Python markdown code block.
Write a function which reduces fractions to their simplest form! Fractions will be presented as an array/tuple (depending on the language), and the reduced fraction must be returned as an array/tuple:
```
input: [numerator, denominator]
output: [new... |
Solve the programming task below in a Python markdown code block.
One way to create a task is to learn from life. You can choose some experience in real life, formalize it and then you will get a new task.
Let's think about a scene in real life: there are lots of people waiting in front of the elevator, each person w... |
Solve the programming task below in a Python markdown code block.
A girl named Sonya is studying in the scientific lyceum of the Kingdom of Kremland. The teacher of computer science (Sonya's favorite subject!) invented a task for her.
Given an array $a$ of length $n$, consisting only of the numbers $0$ and $1$, and t... |
Solve the programming task below in a Python markdown code block.
Winter is here at the North and the White Walkers are close. John Snow has an army consisting of n soldiers. While the rest of the world is fighting for the Iron Throne, he is going to get ready for the attack of the White Walkers.
He has created a met... |
Solve the programming task below in a Python markdown code block.
Constraints
* 1 ≤ |V| ≤ 100
* 0 ≤ |E| ≤ 9900
* -2 × 107 ≤ di ≤ 2 × 107
* There are no parallel edges
* There are no self-loops
Input
An edge-weighted graph G (V, E).
|V| |E|
s0 t0 d0
s1 t1 d1
:
s|E|-1 t|E|-1 d|E|-1
|V| is the number of vertices a... |
Solve the programming task below in a Python markdown code block.
There is an infinite 2-dimensional grid. The robot stands in cell $(0, 0)$ and wants to reach cell $(x, y)$. Here is a list of possible commands the robot can execute:
move north from cell $(i, j)$ to $(i, j + 1)$;
move east from cell $(i, j)$ to $(i ... |
Solve the programming task below in a Python markdown code block.
There is a rooted tree (see Notes) with N vertices numbered 1 to N. Each of the vertices, except the root, has a directed edge coming from its parent. Note that the root may not be Vertex 1.
Takahashi has added M new directed edges to this graph. Each ... |
Solve the programming task below in a Python markdown code block.
$n$ heroes fight against each other in the Arena. Initially, the $i$-th hero has level $a_i$.
Each minute, a fight between two different heroes occurs. These heroes can be chosen arbitrarily (it's even possible that it is the same two heroes that were ... |
Solve the programming task below in a Python markdown code block.
Lee was cleaning his house for the party when he found a messy string under the carpets. Now he'd like to make it clean accurately and in a stylish way...
The string $s$ he found is a binary string of length $n$ (i. e. string consists only of 0-s and 1... |
Solve the programming task below in a Python markdown code block.
Let's imagine we have a popular online RPG. A player begins with a score of 0 in class E5. A1 is the highest level a player can achieve.
Now let's say the players wants to rank up to class E4. To do so the player needs to achieve at least 100 points to... |
Solve the programming task below in a Python markdown code block.
There is a house with 4 levels.
In that house there is an elevator.
You can program this elevator to go up or down,
depending on what button the user touches inside the elevator.
Valid levels must be only these numbers: `0,1,2,3`
Valid buttons must be... |
Solve the programming task below in a Python markdown code block.
With a friend we used to play the following game on a chessboard
(8, rows, 8 columns).
On the first row at the *bottom* we put numbers:
`1/2, 2/3, 3/4, 4/5, 5/6, 6/7, 7/8, 8/9`
On row 2 (2nd row from the bottom) we have:
`1/3, 2/4, 3/5, 4/6, 5/7, 6/8... |
Solve the programming task below in a Python markdown code block.
It is the middle of 2018 and Maria Stepanovna, who lives outside Krasnokamensk (a town in Zabaikalsky region), wants to rent three displays to highlight an important problem.
There are $n$ displays placed along a road, and the $i$-th of them can displa... |
Solve the programming task below in a Python markdown code block.
An African crossword is a rectangular table n × m in size. Each cell of the table contains exactly one letter. This table (it is also referred to as grid) contains some encrypted word that needs to be decoded.
To solve the crossword you should cross ou... |
Solve the programming task below in a Python markdown code block.
Did you know that Chwee kueh, a cuisine of Singapore, means water rice cake ? Its a variety of the most popular South Indian savory cake, only that we call it here idli :). The tastiest idlis are made in Chennai, by none other than our famous chef, Dext... |
Solve the programming task below in a Python markdown code block.
You are given $n$ chips on a number line. The $i$-th chip is placed at the integer coordinate $x_i$. Some chips can have equal coordinates.
You can perform each of the two following types of moves any (possibly, zero) number of times on any chip:
Mo... |
Solve the programming task below in a Python markdown code block.
The Little Elephant from the Zoo of Lviv has an array A that consists of N positive integers. Let A[i] be the i-th number in this array (i = 1, 2, ..., N).
Find the minimal number x > 1 such that x is a divisor of all integers from array A. More formal... |
Solve the programming task below in a Python markdown code block.
Compare given two sequence $A = \\{a_0, a_1, ..., a_{n-1}\\}$ and $B = \\{b_0, b_1, ..., b_{m-1}$ lexicographically.
Constraints
* $1 \leq n, m \leq 1,000$
* $0 \leq a_i, b_i \leq 1,000$
Input
The input is given in the following format.
$n$
$a_0 \... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.