question large_stringlengths 265 13.2k |
|---|
Solve the programming task below in a Python markdown code block.
There are n piles of stones of sizes a1, a2, ..., an lying on the table in front of you.
During one move you can take one pile and add it to the other. As you add pile i to pile j, the size of pile j increases by the current size of pile i, and pile i ... |
Solve the programming task below in a Python markdown code block.
Little Petya likes permutations a lot. Recently his mom has presented him permutation q1, q2, ..., qn of length n.
A permutation a of length n is a sequence of integers a1, a2, ..., an (1 β€ ai β€ n), all integers there are distinct.
There is only one ... |
Solve the programming task below in a Python markdown code block.
The little girl loves the problems on array queries very much.
One day she came across a rather well-known problem: you've got an array of n elements (the elements of the array are indexed starting from 1); also, there are q queries, each one is define... |
Solve the programming task below in a Python markdown code block.
You want to arrange n integers a1, a2, ..., an in some order in a row. Let's define the value of an arrangement as the sum of differences between all pairs of adjacent integers.
More formally, let's denote some arrangement as a sequence of integers x1,... |
Solve the programming task below in a Python markdown code block.
Lately, a national version of a bingo game has become very popular in Berland. There are n players playing the game, each player has a card with numbers. The numbers on each card are distinct, but distinct cards can have equal numbers. The card of the i... |
Solve the programming task below in a Python markdown code block.
Valera has got a rectangle table consisting of n rows and m columns. Valera numbered the table rows starting from one, from top to bottom and the columns β starting from one, from left to right. We will represent cell that is on the intersection of row ... |
Solve the programming task below in a Python markdown code block.
Gargari got bored to play with the bishops and now, after solving the problem about them, he is trying to do math homework. In a math book he have found k permutations. Each of them consists of numbers 1, 2, ..., n in some order. Now he should find the ... |
Solve the programming task below in a Python markdown code block.
Consider a sequence [a1, a2, ... , an]. Define its prefix product sequence <image>.
Now given n, find a permutation of [1, 2, ..., n], such that its prefix product sequence is a permutation of [0, 1, ..., n - 1].
Input
The only input line contains an... |
Solve the programming task below in a Python markdown code block.
Fox Ciel is playing a mobile puzzle game called "Two Dots". The basic levels are played on a board of size n Γ m cells, like this:
<image>
Each cell contains a dot that has some color. We will use different uppercase Latin characters to express differ... |
Solve the programming task below in a Python markdown code block.
Karafs is some kind of vegetable in shape of an 1 Γ h rectangle. Tavaspolis people love Karafs and they use Karafs in almost any kind of food. Tavas, himself, is crazy about Karafs.
<image>
Each Karafs has a positive integer height. Tavas has an infin... |
Solve the programming task below in a Python markdown code block.
Alena has successfully passed the entrance exams to the university and is now looking forward to start studying.
One two-hour lesson at the Russian university is traditionally called a pair, it lasts for two academic hours (an academic hour is equal to... |
Solve the programming task below in a Python markdown code block.
Genos needs your help. He was asked to solve the following programming problem by Saitama:
The length of some string s is denoted |s|. The Hamming distance between two strings s and t of equal length is defined as <image>, where si is the i-th characte... |
Solve the programming task below in a Python markdown code block.
Statistics claims that students sleep no more than three hours a day. But even in the world of their dreams, while they are snoring peacefully, the sense of impending doom is still upon them.
A poor student is dreaming that he is sitting the mathematic... |
Solve the programming task below in a Python markdown code block.
You are given names of two days of the week.
Please, determine whether it is possible that during some non-leap year the first day of some month was equal to the first day of the week you are given, while the first day of the next month was equal to th... |
Solve the programming task below in a Python markdown code block.
There is the faculty of Computer Science in Berland. In the social net "TheContact!" for each course of this faculty there is the special group whose name equals the year of university entrance of corresponding course of students at the university.
Ea... |
Solve the programming task below in a Python markdown code block.
Alice is a beginner composer and now she is ready to create another masterpiece. And not even the single one but two at the same time!
Alice has a sheet with n notes written on it. She wants to take two such non-empty non-intersecting subsequences tha... |
Solve the programming task below in a Python markdown code block.
There are n cities and n - 1 roads in the Seven Kingdoms, each road connects two cities and we can reach any city from any other by the roads.
Theon and Yara Greyjoy are on a horse in the first city, they are starting traveling through the roads. But t... |
Solve the programming task below in a Python markdown code block.
Let S(n) denote the number that represents the digits of n in sorted order. For example, S(1) = 1, S(5) = 5, S(50394) = 3459, S(353535) = 333555.
Given a number X, compute <image> modulo 109 + 7.
Input
The first line of input will contain the integer... |
Solve the programming task below in a Python markdown code block.
In Arcady's garden there grows a peculiar apple-tree that fruits one time per year. Its peculiarity can be explained in following way: there are n inflorescences, numbered from 1 to n. Inflorescence number 1 is situated near base of tree and any other i... |
Solve the programming task below in a Python markdown code block.
Two players play a game.
Initially there are n integers a_1, a_2, β¦, a_n written on the board. Each turn a player selects one number and erases it from the board. This continues until there is only one number left on the board, i. e. n - 1 turns are ma... |
Solve the programming task below in a Python markdown code block.
India is a cricket crazy nation. Chang also loves cricket and computations related to cricket. Chang has created a Cricket app.This app analyses the performance of a cricketer. If a cricketer under-performs, then a negative rating is awarded. If perform... |
Solve the programming task below in a Python markdown code block.
Milly loves chocolates very much. She is at the land of chocolates. This land has N rooms such that there are some chocolates of different brands in every room. It is possible that there can be multiple chocolates of same brand in a particular room. Now... |
Solve the programming task below in a Python markdown code block.
There is a kingdom, that has a long straight road of length L meters and width 0. Coordinate x on the road denotes point that is at x meters from the start of the road. That is coordinate 0 denotes beginning of the road and coordinate L denotes end of t... |
Solve the programming task below in a Python markdown code block.
Hackland is being attacked by Greyland, and you have been assigned the job to save it. Your enemies, known as Grey hats, are numbered starting from L to R, both inclusive. But, here is the fun part: Grey hats are known to switch sides, and you need to ... |
Solve the programming task below in a Python markdown code block.
The dark lord wants to send armies of imps to assault Hogwarts in the first wave of offense. The imps are accustomed to fight in communities and will not fight separately. Communities are sent to battle such that the size of each community sent must be ... |
Solve the programming task below in a Python markdown code block.
You are given a binary array A=(A_1,A_2,\cdots,A_N) of length N.
Process Q queries of the following types. The i-th query is represented by three integers T_i,L_i,R_i.
* T_i=1: Replace the value of A_j with 1-A_j for each L_i \leq j \leq R_i.
* T_i=2:... |
Solve the programming task below in a Python markdown code block.
Takahashi and Aoki will have a battle using their monsters.
The health and strength of Takahashi's monster are A and B, respectively, and those of Aoki's monster are C and D, respectively.
The two monsters will take turns attacking, in the order Takah... |
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 pro... |
Solve the programming task below in a Python markdown code block.
There are H rows and W columns of white square cells.
You will choose h of the rows and w of the columns, and paint all of the cells contained in those rows or columns.
How many white cells will remain?
It can be proved that this count does not depen... |
Solve the programming task below in a Python markdown code block.
You are given a sequence D_1, D_2, ..., D_N of length N. The values of D_i are all distinct. Does a tree with N vertices that satisfies the following conditions exist?
* The vertices are numbered 1,2,..., N.
* The edges are numbered 1,2,..., N-1, and E... |
Solve the programming task below in a Python markdown code block.
Some number of chocolate pieces were prepared for a training camp. The camp had N participants and lasted for D days. The i-th participant (1 \leq i \leq N) ate one chocolate piece on each of the following days in the camp: the 1-st day, the (A_i + 1)-t... |
Solve the programming task below in a Python markdown code block.
E869120 found a chest which is likely to contain treasure.
However, the chest is locked. In order to open it, he needs to enter a string S consisting of lowercase English letters.
He also found a string S', which turns out to be the string S with some o... |
Solve the programming task below in a Python markdown code block.
There are N cities and M roads. The i-th road (1β€iβ€M) connects two cities a_i and b_i (1β€a_i,b_iβ€N) bidirectionally. There may be more than one road that connects the same pair of two cities. For each city, how many roads are connected to the city?
Con... |
Solve the programming task below in a Python markdown code block.
Haiku is a short form of Japanese poetry. A Haiku consists of three phrases with 5, 7 and 5 syllables, in this order.
Iroha is looking for X,Y,Z-Haiku (defined below) in integer sequences.
Consider all integer sequences of length N whose elements are ... |
Solve the programming task below in a Python markdown code block.
The University of Aizu has a park covered with grass, and there are no trees or buildings that block the sunlight. On sunny summer days, sprinklers installed in the park operate to sprinkle water on the lawn. The frog Pyonkichi lives in this park. Pyonk... |
Solve the programming task below in a Python markdown code block.
I am a pipe tie craftsman. As long as you get the joints and pipes that connect the pipes, you can connect any pipe. Every day, my master gives me pipes and joints, which I connect and give to my master. But if you have too many pipes, you can't connect... |
Solve the programming task below in a Python markdown code block.
problem
Once upon a time there were settlements and many people lived there. People built buildings of various shapes and sizes. But those buildings have already been lost, only the literature and the pillars found in the ruins. Was a clue to the locat... |
Solve the programming task below in a Python markdown code block.
The city is full of ghosts, something the average person doesn't know about. Most of them are harmless, but the trouble is that there are quite a few evil spirits that curse people.
There was a girl who fought against such evil spirits. She goes to hig... |
Solve the programming task below in a Python markdown code block.
Encryption System
A programmer developed a new encryption system. However, his system has an issue that two or more distinct strings are `encrypted' to the same string.
We have a string encrypted by his system. To decode the original string, we want t... |
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.
Time Limit: 8 sec / Memory Limit: 64 MB
Example
Input
eggchickenegg
Output
egg
The input will be give
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 ... |
Solve the programming task below in a Python markdown code block.
Given a set of $N$ axis-aligned rectangular seals, find the number of overlapped seals on the region which has the maximum number of overlapped seals.
Constraints
* $ 1 \leq N \leq 100000 $
* $ 0 \leq x1_i < x2_i \leq 1000 $
* $ 0 \leq y1_i < y2_i \le... |
Solve the programming task below in a Python markdown code block.
Our Chef is very happy that his son was selected for training in one of the finest culinary schools of the world.
So he and his wife decide to buy a gift for the kid as a token of appreciation.
Unfortunately, the Chef hasn't been doing good business lat... |
Solve the programming task below in a Python markdown code block.
Everybody seems to think that the Martians are green, but it turns out they are metallic pink and fat. Ajs has two bags of distinct nonnegative integers. The bags are disjoint, and the union of the sets of numbers in the bags is \{0,1,β¦,M-1\}, for some ... |
Solve the programming task below in a Python markdown code block.
Ivan has number b. He is sorting through the numbers a from 1 to 10^{18}, and for every a writes ([a, b])/(a) on blackboard. Here [a, b] stands for least common multiple of a and b. Ivan is very lazy, that's why this task bored him soon. But he is... |
Solve the programming task below in a Python markdown code block.
You are given a string s=s_1s_2... s_n of length n, which only contains digits 1, 2, ..., 9.
A substring s[l ... r] of s is a string s_l s_{l + 1} s_{l + 2} β¦ s_r. A substring s[l ... r] of s is called even if the number represented by it is even.
Fi... |
Solve the programming task below in a Python markdown code block.
You are given a long decimal number a consisting of n digits from 1 to 9. You also have a function f that maps every digit from 1 to 9 to some (possibly the same) digit from 1 to 9.
You can perform the following operation no more than once: choose a no... |
Solve the programming task below in a Python markdown code block.
There are famous Russian nesting dolls named matryoshkas sold in one of the souvenir stores nearby, and you'd like to buy several of them. The store has n different matryoshkas. Any matryoshka is a figure of volume out_i with an empty space inside of vo... |
Solve the programming task below in a Python markdown code block.
You have two strings a and b of equal even length n consisting of characters 0 and 1.
We're in the endgame now. To finally make the universe perfectly balanced, you need to make strings a and b equal.
In one step, you can choose any prefix of a of eve... |
Solve the programming task below in a Python markdown code block.
Mr. Scrooge, a very busy man, decided to count the time he wastes on all sorts of useless stuff to evaluate the lost profit. He has already counted the time he wastes sleeping and eating. And now Mr. Scrooge wants to count the time he has wasted signing... |
Solve the programming task below in a Python markdown code block.
You are given an array a of length n and array b of length m both consisting of only integers 0 and 1. Consider a matrix c of size n Γ m formed by following rule: c_{i, j} = a_i β
b_j (i.e. a_i multiplied by b_j). It's easy to see that c consists of onl... |
Solve the programming task below in a Python markdown code block.
You are given two integers x and y. You can perform two types of operations:
1. Pay a dollars and increase or decrease any of these integers by 1. For example, if x = 0 and y = 7 there are four possible outcomes after this operation:
* x = 0, y... |
Solve the programming task below in a Python markdown code block.
The only difference between easy and hard versions is on constraints. In this version constraints are higher. You can make hacks only if all versions of the problem are solved.
Koa the Koala is at the beach!
The beach consists (from left to right) of ... |
Solve the programming task below in a Python markdown code block.
You are given a weighted undirected connected graph consisting of n vertices and m edges. It is guaranteed that there are no self-loops or multiple edges in the given graph.
Let's define the weight of the path consisting of k edges with indices e_1, e_... |
Solve the programming task below in a Python markdown code block.
You like numbers, don't you? Nastia has a lot of numbers and she wants to share them with you! Isn't it amazing?
Let a_i be how many numbers i (1 β€ i β€ k) you have.
An n Γ n matrix is called beautiful if it contains all the numbers you have, and for e... |
Solve the programming task below in a Python markdown code block.
You are given a string s of length n. Each character is either one of the first k lowercase Latin letters or a question mark.
You are asked to replace every question mark with one of the first k lowercase Latin letters in such a way that the following ... |
Solve the programming task below in a Python markdown code block.
The Smart Beaver from ABBYY decided to have a day off. But doing nothing the whole day turned out to be too boring, and he decided to play a game with pebbles. Initially, the Beaver has n pebbles. He arranges them in a equal rows, each row has b pebbles... |
Solve the programming task below in a Python markdown code block.
Vasya is an active Internet user. One day he came across an Internet resource he liked, so he wrote its address in the notebook. We know that the address of the written resource has format:
<protocol>://<domain>.ru[/<context>]
where:
* <protocol> c... |
Solve the programming task below in a Python markdown code block.
You are given the following concurrent program. There are N processes and the i-th process has the following pseudocode:
repeat ni times
yi := y
y := yiβ+β1
end repeat
Here y is a shared variable. Everyth... |
Solve the programming task below in a Python markdown code block.
Iahub is so happy about inventing bubble sort graphs that he's staying all day long at the office and writing permutations. Iahubina is angry that she is no more important for Iahub. When Iahub goes away, Iahubina comes to his office and sabotage his re... |
Solve the programming task below in a Python markdown code block.
One day, little Vasya found himself in a maze consisting of (n + 1) rooms, numbered from 1 to (n + 1). Initially, Vasya is at the first room and to get out of the maze, he needs to get to the (n + 1)-th one.
The maze is organized as follows. Each room ... |
Solve the programming task below in a Python markdown code block.
Bertown is under siege! The attackers have blocked all the ways out and their cannon is bombarding the city. Fortunately, Berland intelligence managed to intercept the enemies' shooting plan. Let's introduce the Cartesian system of coordinates, the orig... |
Solve the programming task below in a Python markdown code block.
Kyoya Ootori is selling photobooks of the Ouran High School Host Club. He has 26 photos, labeled "a" to "z", and he has compiled them into a photo booklet with some photos in some order (possibly with some photos being duplicated). A photo booklet can b... |
Solve the programming task below in a Python markdown code block.
You are given an alphabet consisting of n letters, your task is to make a string of the maximum possible length so that the following conditions are satisfied:
* the i-th letter occurs in the string no more than ai times;
* the number of occurren... |
Solve the programming task below in a Python markdown code block.
We all know the impressive story of Robin Hood. Robin Hood uses his archery skills and his wits to steal the money from rich, and return it to the poor.
There are n citizens in Kekoland, each person has ci coins. Each day, Robin Hood will take exactly ... |
Solve the programming task below in a Python markdown code block.
One of Timofey's birthday presents is a colourbook in a shape of an infinite plane. On the plane n rectangles with sides parallel to coordinate axes are situated. All sides of the rectangles have odd length. Rectangles cannot intersect, but they can tou... |
Solve the programming task below in a Python markdown code block.
Misha and Grisha are funny boys, so they like to use new underground. The underground has n stations connected with n - 1 routes so that each route connects two stations, and it is possible to reach every station from any other.
The boys decided to hav... |
Solve the programming task below in a Python markdown code block.
Country of Metropolia is holding Olympiad of Metrpolises soon. It mean that all jury members of the olympiad should meet together in Metropolis (the capital of the country) for the problem preparation process.
There are n + 1 cities consecutively numbe... |
Solve the programming task below in a Python markdown code block.
In Ann's favorite book shop are as many as n books on math and economics. Books are numbered from 1 to n. Each of them contains non-negative number of problems.
Today there is a sale: any subsegment of a segment from l to r can be bought at a fixed pri... |
Solve the programming task below in a Python markdown code block.
Suppose you have two polynomials <image> and <image>. Then polynomial <image> can be uniquely represented in the following way:
<image>
This can be done using [long division](https://en.wikipedia.org/wiki/Polynomial_long_division). Here, <image> denot... |
Solve the programming task below in a Python markdown code block.
Input
The input contains a single integer a (10 β€ a β€ 999).
Output
Output 0 or 1.
Examples
Input
13
Output
1
Input
927
Output
1
Input
48
Output
0
The input will be give
Read the inputs from stdin solve the problem and write the ... |
Solve the programming task below in a Python markdown code block.
Kuro is living in a country called Uberland, consisting of n towns, numbered from 1 to n, and n - 1 bidirectional roads connecting these towns. It is possible to reach each town from any other. Each road connects two towns a and b. Kuro loves walking an... |
Solve the programming task below in a Python markdown code block.
Benny noticed a random property of numbers. The numbers which followed this property were called as interesting numbers by Benny. Let's dive into what Benny discovered about these numbers.
1 is an interesting number.
For every N > 1 , N is interesting... |
Solve the programming task below in a Python markdown code block.
You are given an integer K. Print the string obtained by repeating the string `ACL` K times and concatenating them.
For example, if K = 3, print `ACLACLACL`.
Constraints
* 1 \leq K \leq 5
* All values in input are integers.
Input
Input is given fro... |
Solve the programming task below in a Python markdown code block.
There are three houses on a number line: House 1, 2 and 3, with coordinates A, B and C, respectively. Print `Yes` if we pass the coordinate of House 3 on the straight way from House 1 to House 2 without making a detour, and print `No` otherwise.
Constr... |
Solve the programming task below in a Python markdown code block.
Shichi-Go-San (literally "Seven-Five-Three") is a traditional event in a certain country to celebrate the growth of seven-, five- and three-year-old children.
Takahashi is now X years old. Will his growth be celebrated in Shichi-Go-San this time?
Cons... |
Solve the programming task below in a Python markdown code block.
In AtCoder Kingdom, Gregorian calendar is used, and dates are written in the "year-month-day" order, or the "month-day" order without the year.
For example, May 3, 2018 is written as 2018-5-3, or 5-3 without the year.
In this country, a date is called ... |
Solve the programming task below in a Python markdown code block.
Ringo has an undirected graph G with N vertices numbered 1,2,...,N and M edges numbered 1,2,...,M. Edge i connects Vertex a_{i} and b_{i} and has a length of w_i.
Now, he is in the middle of painting these N vertices in K colors numbered 1,2,...,K. Ver... |
Solve the programming task below in a Python markdown code block.
Takahashi wants to gain muscle, and decides to work out at AtCoder Gym.
The exercise machine at the gym has N buttons, and exactly one of the buttons is lighten up. These buttons are numbered 1 through N. When Button i is lighten up and you press it, t... |
Solve the programming task below in a Python markdown code block.
You are given two integers K and S.
Three variable X, Y and Z takes integer values satisfying 0β€X,Y,Zβ€K.
How many different assignments of values to X, Y and Z are there such that X + Y + Z = S?
Constraints
* 2β€Kβ€2500
* 0β€Sβ€3K
* K and S are integers.
... |
Solve the programming task below in a Python markdown code block.
We have a grid with H rows and W columns. At first, all cells were painted white.
Snuke painted N of these cells. The i-th ( 1 \leq i \leq N ) cell he painted is the cell at the a_i-th row and b_i-th column.
Compute the following:
* For each integer ... |
Solve the programming task below in a Python markdown code block.
Dr .: Peter, I've finally done it.
Peter: What's wrong, Dr. David? Is it a silly invention again?
Dr .: This table, this table.
| Character | Sign
--- | ---
(Blank) | 101
'| 000000
, | 000011
-| 10010001
. | 010001
? | 000001
A | 100101
B | 10011010
|... |
Solve the programming task below in a Python markdown code block.
"What are your shoe sizes?"
Suddenly, the doctor asked me when I met him for the first time.
"It's 23.5"
"Oh, that's a really nice number. It's 2 to the 4th power plus 2 to the 2nd power, 2 to the 1st power, 2 to the 0th power, and 2 to the 1st power.... |
Solve the programming task below in a Python markdown code block.
PCK Taxi in Aizu city, owned by PCK company, has adopted a unique billing system: the user can decide the taxi fare. Today as usual, many people are waiting in a queue at the taxi stand in front of the station.
In front of the station, there are $N$ pa... |
Solve the programming task below in a Python markdown code block.
Let A, B, C, D, E be sets of integers and let U is a universal set that includes all sets under consideration. All elements in any set are different (no repetitions).
u - union of two sets, AuB = {x β U : x β A or x β B} is the set of all elements whic... |
Solve the programming task below in a Python markdown code block.
Taro and Hanako have numbers of cards in their hands. Each of the cards has a score on it. Taro and Hanako wish to make the total scores of their cards equal by exchanging one card in one's hand with one card in the other's hand. Which of the cards shou... |
Solve the programming task below in a Python markdown code block.
International Center for Picassonian Cubism is a Spanish national museum of cubist artworks, dedicated to Pablo Picasso. The center held a competition for an artwork that will be displayed in front of the facade of the museum building. The artwork is a ... |
Solve the programming task below in a Python markdown code block.
Space Coconut Crab
Space coconut crab
English text is not available in this practice contest.
Ken Marine Blue is a space hunter who travels through the entire galaxy in search of space coconut crabs. The space coconut crab is the largest crustacean i... |
Solve the programming task below in a Python markdown code block.
Mr. A and Mr. B live in an N Γ M rectangular grid area. Each square is either a road, a wall, or a house. Since this area is famous for the frequent occurrence of molestation damage due to the complicated and intricate roads, the boundary between this a... |
Solve the programming task below in a Python markdown code block.
Find the area of intersection between a circle $c$ and a polygon $g$. The center coordinate of the circle is ($0, 0$).
The polygon $g$ is represented by a sequence of points $p_1$, $p_2$,..., $p_n$ where line segments connecting $p_i$ and $p_{i+1}$ ($1... |
Solve the programming task below in a Python markdown code block.
For a dictionary $M$ that stores elements formed by a pair of a string key and an integer value, perform a sequence of the following operations. Note that each key in $M$ must be unique.
* insert($key$, $x$): Insert an element formed by a pair of $key$... |
Solve the programming task below in a Python markdown code block.
Since Sonya has just learned the basics of matrices, she decided to play with them a little bit.
Sonya imagined a new type of matrices that she called rhombic matrices. These matrices have exactly one zero, while all other cells have the Manhattan dist... |
Solve the programming task below in a Python markdown code block.
Let's consider a simplified version of order book of some stock. The order book is a list of orders (offers) from people that want to buy or sell one unit of the stock, each order is described by direction (BUY or SELL) and price.
At every moment of ti... |
Solve the programming task below in a Python markdown code block.
Vova's family is building the Great Vova Wall (named by Vova himself). Vova's parents, grandparents, grand-grandparents contributed to it. Now it's totally up to Vova to put the finishing touches.
The current state of the wall can be respresented by a ... |
Solve the programming task below in a Python markdown code block.
Thanos wants to destroy the avengers base, but he needs to destroy the avengers along with their base.
Let we represent their base with an array, where each position can be occupied by many avengers, but one avenger can occupy only one position. Length... |
Solve the programming task below in a Python markdown code block.
Polycarp plays "Game 23". Initially he has a number n and his goal is to transform it to m. In one move, he can multiply n by 2 or multiply n by 3. He can perform any number of moves.
Print the number of moves needed to transform n to m. Print -1 if it... |
Solve the programming task below in a Python markdown code block.
You are given a binary string s (recall that a string is binary if each character is either 0 or 1).
Let f(t) be the decimal representation of integer t written in binary form (possibly with leading zeroes). For example f(011) = 3, f(00101) = 5, f(0000... |
Solve the programming task below in a Python markdown code block.
Several days ago you bought a new house and now you are planning to start a renovation. Since winters in your region can be very cold you need to decide how to heat rooms in your house.
Your house has n rooms. In the i-th room you can install at most c... |
Solve the programming task below in a Python markdown code block.
Alicia has an array, a_1, a_2, β¦, a_n, of non-negative integers. For each 1 β€ i β€ n, she has found a non-negative integer x_i = max(0, a_1, β¦, a_{i-1}). Note that for i=1, x_i = 0.
For example, if Alicia had the array a = \{0, 1, 2, 0, 3\}, then x = \{... |
Solve the programming task below in a Python markdown code block.
You are given a special jigsaw puzzle consisting of nβ
m identical pieces. Every piece has three tabs and one blank, as pictured below.
<image>
The jigsaw puzzle is considered solved if the following conditions hold:
1. The pieces are arranged into... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.