question large_stringlengths 265 13.2k |
|---|
Solve the programming task below in a Python markdown code block.
Caracal is fighting with a monster.
The health of the monster is H.
Caracal can attack by choosing one monster. When a monster is attacked, depending on that monster's health, the following happens:
- If the monster's health is 1, it drops to 0.
- If ... |
Solve the programming task below in a Python markdown code block.
Find the number of integers between 1 and N (inclusive) that contains exactly K non-zero digits when written in base ten.
-----Constraints-----
- 1 \leq N < 10^{100}
- 1 \leq K \leq 3
-----Input-----
Input is given from Standard Input in the followi... |
Solve the programming task below in a Python markdown code block.
Tokitsukaze is one of the characters in the game "Kantai Collection". In this game, every character has a common attribute — health points, shortened to HP.
In general, different values of HP are grouped into $4$ categories: Category $A$ if HP is in t... |
Solve the programming task below in a Python markdown code block.
Bob is an active user of the social network Faithbug. On this network, people are able to engage in a mutual friendship. That is, if $a$ is a friend of $b$, then $b$ is also a friend of $a$. Each user thus has a non-negative amount of friends.
This mor... |
Solve the programming task below in a Python markdown code block.
On her way to programming school tiger Dasha faced her first test — a huge staircase! [Image]
The steps were numbered from one to infinity. As we know, tigers are very fond of all striped things, it is possible that it has something to do with their c... |
Solve the programming task below in a Python markdown code block.
You are given two arrays A and B consisting of integers, sorted in non-decreasing order. Check whether it is possible to choose k numbers in array A and choose m numbers in array B so that any number chosen in the first array is strictly less than any n... |
Solve the programming task below in a Python markdown code block.
Petya is a beginner programmer. He has already mastered the basics of the C++ language and moved on to learning algorithms. The first algorithm he encountered was insertion sort. Petya has already written the code that implements this algorithm and sort... |
Solve the programming task below in a Python markdown code block.
An array $b$ is called to be a subarray of $a$ if it forms a continuous subsequence of $a$, that is, if it is equal to $a_l$, $a_{l + 1}$, $\ldots$, $a_r$ for some $l, r$.
Suppose $m$ is some known constant. For any array, having $m$ or more elements, ... |
Solve the programming task below in a Python markdown code block.
You are given an array $A$, consisting of $n$ positive integers $a_1, a_2, \dots, a_n$, and an array $B$, consisting of $m$ positive integers $b_1, b_2, \dots, b_m$.
Choose some element $a$ of $A$ and some element $b$ of $B$ such that $a+b$ doesn't be... |
Solve the programming task below in a Python markdown code block.
There are n cities in Westeros. The i-th city is inhabited by a_{i} people. Daenerys and Stannis play the following game: in one single move, a player chooses a certain town and burns it to the ground. Thus all its residents, sadly, die. Stannis starts ... |
Solve the programming task below in a Python markdown code block.
Saitama accidentally destroyed a hotel again. To repay the hotel company, Genos has volunteered to operate an elevator in one of its other hotels. The elevator is special — it starts on the top floor, can only move down, and has infinite capacity. Floor... |
Solve the programming task below in a Python markdown code block.
There was an electronic store heist last night.
All keyboards which were in the store yesterday were numbered in ascending order from some integer number $x$. For example, if $x = 4$ and there were $3$ keyboards in the store, then the devices had indic... |
Solve the programming task below in a Python markdown code block.
Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civi... |
Solve the programming task below in a Python markdown code block.
You are given an array a with n elements. Each element of a is either 0 or 1.
Let's denote the length of the longest subsegment of consecutive elements in a, consisting of only numbers one, as f(a). You can change no more than k zeroes to ones to maxim... |
Solve the programming task below in a Python markdown code block.
IA has so many colorful magnets on her fridge! Exactly one letter is written on each magnet, 'a' or 'b'. She loves to play with them, placing all magnets in a row. However, the girl is quickly bored and usually thinks how to make her entertainment more ... |
Solve the programming task below in a Python markdown code block.
Petya has k matches, placed in n matchboxes lying in a line from left to right. We know that k is divisible by n. Petya wants all boxes to have the same number of matches inside. For that, he can move a match from its box to the adjacent one in one move... |
Solve the programming task below in a Python markdown code block.
Yaroslav has an array that consists of n integers. In one second Yaroslav can swap two neighboring array elements. Now Yaroslav is wondering if he can obtain an array where any two neighboring elements would be distinct in a finite time.
Help Yaroslav.... |
Solve the programming task below in a Python markdown code block.
Notice that the memory limit is non-standard.
Recently Arthur and Sasha have studied correct bracket sequences. Arthur understood this topic perfectly and become so amazed about correct bracket sequences, so he even got himself a favorite correct brack... |
Solve the programming task below in a Python markdown code block.
Petya has recently learned data structure named "Binary heap".
The heap he is now operating with allows the following operations: put the given number into the heap; get the value of the minimum element in the heap; extract the minimum element from... |
Solve the programming task below in a Python markdown code block.
At the first holiday in spring, the town Shortriver traditionally conducts a flower festival. Townsfolk wear traditional wreaths during these festivals. Each wreath contains exactly $k$ flowers.
The work material for the wreaths for all $n$ citizens of... |
Solve the programming task below in a Python markdown code block.
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a_1, a_2, ..., a_{n} in the non-decreasing order. The pse... |
Solve the programming task below in a Python markdown code block.
Bizon the Champion isn't just attentive, he also is very hardworking.
Bizon the Champion decided to paint his old fence his favorite color, orange. The fence is represented as n vertical planks, put in a row. Adjacent planks have no gap between them. T... |
Solve the programming task below in a Python markdown code block.
Recently Irina arrived to one of the most famous cities of Berland — the Berlatov city. There are n showplaces in the city, numbered from 1 to n, and some of them are connected by one-directional roads. The roads in Berlatov are designed in a way such t... |
Solve the programming task below in a Python markdown code block.
Roma works in a company that sells TVs. Now he has to prepare a report for the last year.
Roma has got a list of the company's incomes. The list is a sequence that consists of n integers. The total income of the company is the sum of all integers in se... |
Solve the programming task below in a Python markdown code block.
A multi-subject competition is coming! The competition has $m$ different subjects participants can choose from. That's why Alex (the coach) should form a competition delegation among his students.
He has $n$ candidates. For the $i$-th person he knows ... |
Solve the programming task below in a Python markdown code block.
Xenia the beginner mathematician is a third year student at elementary school. She is now learning the addition operation.
The teacher has written down the sum of multiple numbers. Pupils should calculate the sum. To make the calculation easier, the su... |
Solve the programming task below in a Python markdown code block.
People do many crazy things to stand out in a crowd. Some of them dance, some learn by heart rules of Russian language, some try to become an outstanding competitive programmers, while others collect funny math objects.
Alis is among these collectors. ... |
Solve the programming task below in a Python markdown code block.
Bob is an avid fan of the video game "League of Leesins", and today he celebrates as the League of Leesins World Championship comes to an end!
The tournament consisted of $n$ ($n \ge 5$) teams around the world. Before the tournament starts, Bob has ma... |
Solve the programming task below in a Python markdown code block.
It's the year 5555. You have a graph, and you want to find a long cycle and a huge independent set, just because you can. But for now, let's just stick with finding either.
Given a connected graph with $n$ vertices, you can choose to either:
find an... |
Solve the programming task below in a Python markdown code block.
You are given an array $a$ consisting of $n$ integers. You can perform the following operations with it: Choose some positions $i$ and $j$ ($1 \le i, j \le n, i \ne j$), write the value of $a_i \cdot a_j$ into the $j$-th cell and remove the number fro... |
Solve the programming task below in a Python markdown code block.
Let's call the following process a transformation of a sequence of length $n$.
If the sequence is empty, the process ends. Otherwise, append the greatest common divisor (GCD) of all the elements of the sequence to the result and remove one arbitrary el... |
Solve the programming task below in a Python markdown code block.
Shichikuji is the new resident deity of the South Black Snail Temple. Her first job is as follows:
There are $n$ new cities located in Prefecture X. Cities are numbered from $1$ to $n$. City $i$ is located $x_i$ km North of the shrine and $y_i$ km East... |
Solve the programming task below in a Python markdown code block.
Dima, Inna and Seryozha have gathered in a room. That's right, someone's got to go. To cheer Seryozha up and inspire him to have a walk, Inna decided to cook something.
Dima and Seryozha have n fruits in the fridge. Each fruit has two parameters: the ... |
Solve the programming task below in a Python markdown code block.
The Bitlandians are quite weird people. They do everything differently. They have a different alphabet so they have a different definition for a string.
A Bitlandish string is a string made only of characters "0" and "1".
BitHaval (the mayor of Bitlan... |
Solve the programming task below in a Python markdown code block.
Jafar has n cans of cola. Each can is described by two integers: remaining volume of cola a_{i} and can's capacity b_{i} (a_{i} ≤ b_{i}).
Jafar has decided to pour all remaining cola into just 2 cans, determine if he can do this or not!
-----Input-... |
Solve the programming task below in a Python markdown code block.
This is the first subtask of problem F. The only differences between this and the second subtask are the constraints on the value of $m$ and the time limit. You need to solve both subtasks in order to hack this one.
There are $n+1$ distinct colours in ... |
Solve the programming task below in a Python markdown code block.
Bachgold problem is very easy to formulate. Given a positive integer n represent it as a sum of maximum possible number of prime numbers. One can prove that such representation exists for any integer greater than 1.
Recall that integer k is called prim... |
Solve the programming task below in a Python markdown code block.
There are $n$ candy boxes in front of Tania. The boxes are arranged in a row from left to right, numbered from $1$ to $n$. The $i$-th box contains $r_i$ candies, candies have the color $c_i$ (the color can take one of three values — red, green, or blu... |
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.
Given is a tree G with N vertices.
The vertices are numbered 1 through N, and the i-th edge connects Vertex a_i and Vertex b_i.
Consider painting the edges in G with some number of colors.
We want to paint them so that, for each vertex, the colors of th... |
Solve the programming task below in a Python markdown code block.
We have a string S of length N consisting of R, G, and B.
Find the number of triples (i,~j,~k)~(1 \leq i < j < k \leq N) that satisfy both of the following conditions:
- S_i \neq S_j, S_i \neq S_k, and S_j \neq S_k.
- j - i \neq k - j.
-----Constrain... |
Solve the programming task below in a Python markdown code block.
For years, the Day of city N was held in the most rainy day of summer. New mayor decided to break this tradition and select a not-so-rainy day for the celebration. The mayor knows the weather forecast for the $n$ days of summer. On the $i$-th day, $a_i$... |
Solve the programming task below in a Python markdown code block.
On a random day, Neko found $n$ treasure chests and $m$ keys. The $i$-th chest has an integer $a_i$ written on it and the $j$-th key has an integer $b_j$ on it. Neko knows those chests contain the powerful mysterious green Grapes, thus Neko wants to ope... |
Solve the programming task below in a Python markdown code block.
At a break Vanya came to the class and saw an array of $n$ $k$-bit integers $a_1, a_2, \ldots, a_n$ on the board. An integer $x$ is called a $k$-bit integer if $0 \leq x \leq 2^k - 1$.
Of course, Vanya was not able to resist and started changing the n... |
Solve the programming task below in a Python markdown code block.
There are n schoolchildren, boys and girls, lined up in the school canteen in front of the bun stall. The buns aren't ready yet and the line is undergoing some changes.
Each second all boys that stand right in front of girls, simultaneously swap places... |
Solve the programming task below in a Python markdown code block.
Arkady is playing Battleship. The rules of this game aren't really important.
There is a field of $n \times n$ cells. There should be exactly one $k$-decker on the field, i. e. a ship that is $k$ cells long oriented either horizontally or vertically. H... |
Solve the programming task below in a Python markdown code block.
Danny, the local Math Maniac, is fascinated by circles, Omkar's most recent creation. Help him solve this circle problem!
You are given $n$ nonnegative integers $a_1, a_2, \dots, a_n$ arranged in a circle, where $n$ must be odd (ie. $n-1$ is divisible ... |
Solve the programming task below in a Python markdown code block.
You are given a binary matrix $A$ of size $n \times n$. Let's denote an $x$-compression of the given matrix as a matrix $B$ of size $\frac{n}{x} \times \frac{n}{x}$ such that for every $i \in [1, n], j \in [1, n]$ the condition $A[i][j] = B[\lceil \frac... |
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.
The rules of Sith Tournament are well known to everyone. n Sith take part in the Tournament. The Tournament starts with the random choice of two Sith who will fight in the first battle. As one of them loses, his place is taken by the next randomly chose... |
Solve the programming task below in a Python markdown code block.
Ashish has an array $a$ of size $n$.
A subsequence of $a$ is defined as a sequence that can be obtained from $a$ by deleting some elements (possibly none), without changing the order of the remaining elements.
Consider a subsequence $s$ of $a$. He def... |
Solve the programming task below in a Python markdown code block.
In Berland a bus travels along the main street of the capital. The street begins from the main square and looks like a very long segment. There are n bus stops located along the street, the i-th of them is located at the distance a_{i} from the central ... |
Solve the programming task below in a Python markdown code block.
Berlanders like to eat cones after a hard day. Misha Square and Sasha Circle are local authorities of Berland. Each of them controls its points of cone trade. Misha has n points, Sasha — m. Since their subordinates constantly had conflicts with each oth... |
Solve the programming task below in a Python markdown code block.
Kilani is playing a game with his friends. This game can be represented as a grid of size $n \times m$, where each cell is either empty or blocked, and every player has one or more castles in some cells (there are no two castles in one cell).
The game ... |
Solve the programming task below in a Python markdown code block.
Wilbur the pig is tinkering with arrays again. He has the array a_1, a_2, ..., a_{n} initially consisting of n zeros. At one step, he can choose any index i and either add 1 to all elements a_{i}, a_{i} + 1, ... , a_{n} or subtract 1 from all elements a... |
Solve the programming task below in a Python markdown code block.
Recently Polycarp noticed that some of the buttons of his keyboard are malfunctioning. For simplicity, we assume that Polycarp's keyboard contains $26$ buttons (one for each letter of the Latin alphabet). Each button is either working fine or malfunctio... |
Solve the programming task below in a Python markdown code block.
You are given n points on the straight line — the positions (x-coordinates) of the cities and m points on the same line — the positions (x-coordinates) of the cellular towers. All towers work in the same way — they provide cellular network for all citie... |
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.
You will receive 3 points for solving this problem.
Manao is designing the genetic code for a new type of algae to efficiently produce fuel. Specifically, Manao is focusing on a stretch of DNA that encodes one protein. The stretch of DNA is represented... |
Solve the programming task below in a Python markdown code block.
Andrewid the Android is a galaxy-famous detective. In his free time he likes to think about strings containing zeros and ones.
Once he thought about a string of length n consisting of zeroes and ones. Consider the following operation: we choose any two... |
Solve the programming task below in a Python markdown code block.
Reforms continue entering Berland. For example, during yesterday sitting the Berland Parliament approved as much as n laws (each law has been assigned a unique number from 1 to n). Today all these laws were put on the table of the President of Berland, ... |
Solve the programming task below in a Python markdown code block.
You are given array $a$ of length $n$. You can choose one segment $[l, r]$ ($1 \le l \le r \le n$) and integer value $k$ (positive, negative or even zero) and change $a_l, a_{l + 1}, \dots, a_r$ by $k$ each (i.e. $a_i := a_i + k$ for each $l \le i \le r... |
Solve the programming task below in a Python markdown code block.
Levko loves permutations very much. A permutation of length n is a sequence of distinct positive integers, each is at most n.
Let’s assume that value gcd(a, b) shows the greatest common divisor of numbers a and b. Levko assumes that element p_{i} of pe... |
Solve the programming task below in a Python markdown code block.
Little X and Little Z are good friends. They always chat online. But both of them have schedules.
Little Z has fixed schedule. He always online at any moment of time between a_1 and b_1, between a_2 and b_2, ..., between a_{p} and b_{p} (all borders in... |
Solve the programming task below in a Python markdown code block.
Two bears are playing tic-tac-toe via mail. It's boring for them to play usual tic-tac-toe game, so they are a playing modified version of this game. Here are its rules.
The game is played on the following field. [Image]
Players are making moves by t... |
Solve the programming task below in a Python markdown code block.
The new "Die Hard" movie has just been released! There are n people at the cinema box office standing in a huge line. Each of them has a single 100, 50 or 25 ruble bill. A "Die Hard" ticket costs 25 rubles. Can the booking clerk sell a ticket to each pe... |
Solve the programming task below in a Python markdown code block.
You are given a string s of length n consisting of lowercase English letters.
For two given strings s and t, say S is the set of distinct characters of s and T is the set of distinct characters of t. The strings s and t are isomorphic if their lengths ... |
Solve the programming task below in a Python markdown code block.
Vadim is really keen on travelling. Recently he heard about kayaking activity near his town and became very excited about it, so he joined a party of kayakers.
Now the party is ready to start its journey, but firstly they have to choose kayaks. There a... |
Solve the programming task below in a Python markdown code block.
Little Petya likes arrays that consist of non-negative integers a lot. Recently his mom has presented him one such array consisting of n elements. Petya immediately decided to find there a segment of consecutive elements, such that the xor of all number... |
Solve the programming task below in a Python markdown code block.
The clique problem is one of the most well-known NP-complete problems. Under some simplification it can be formulated as follows. Consider an undirected graph G. It is required to find a subset of vertices C of the maximum size such that any two of them... |
Solve the programming task below in a Python markdown code block.
Polycarpus has got n candies and m friends (n ≥ m). He wants to make a New Year present with candies to each friend. Polycarpus is planning to present all candies and he wants to do this in the fairest (that is, most equal) manner. He wants to choose su... |
Solve the programming task below in a Python markdown code block.
Bob is a pirate looking for the greatest treasure the world has ever seen. The treasure is located at the point $T$, which coordinates to be found out.
Bob travelled around the world and collected clues of the treasure location at $n$ obelisks. These c... |
Solve the programming task below in a Python markdown code block.
Do you like summer? Residents of Berland do. They especially love eating ice cream in the hot summer. So this summer day a large queue of n Berland residents lined up in front of the ice cream stall. We know that each of them has a certain amount of ber... |
Solve the programming task below in a Python markdown code block.
Given a string $s$ of length $n$ and integer $k$ ($1 \le k \le n$). The string $s$ has a level $x$, if $x$ is largest non-negative integer, such that it's possible to find in $s$: $x$ non-intersecting (non-overlapping) substrings of length $k$, all ch... |
Solve the programming task below in a Python markdown code block.
Innovation technologies are on a victorious march around the planet. They integrate into all spheres of human activity!
A restaurant called "Dijkstra's Place" has started thinking about optimizing the booking system.
There are n booking requests rece... |
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.
Door's family is going celebrate Famil Doors's birthday party. They love Famil Door so they are planning to make his birthday cake weird!
The cake is a n × n square consisting of equal squares with side length 1. Each square is either empty or consists... |
Solve the programming task below in a Python markdown code block.
One day n friends met at a party, they hadn't seen each other for a long time and so they decided to make a group photo together.
Simply speaking, the process of taking photos can be described as follows. On the photo, each photographed friend occupie... |
Solve the programming task below in a Python markdown code block.
Sasha and Ira are two best friends. But they aren’t just friends, they are software engineers and experts in artificial intelligence. They are developing an algorithm for two bots playing a two-player game. The game is cooperative and turn based. In eac... |
Solve the programming task below in a Python markdown code block.
Quite recently, a very smart student named Jury decided that lectures are boring, so he downloaded a game called "Black Square" on his super cool touchscreen phone.
In this game, the phone's screen is divided into four vertical strips. Each second, a b... |
Solve the programming task below in a Python markdown code block.
Nam is playing with a string on his computer. The string consists of n lowercase English letters. It is meaningless, so Nam decided to make the string more beautiful, that is to make it be a palindrome by using 4 arrow keys: left, right, up, down.
Ther... |
Solve the programming task below in a Python markdown code block.
For a positive integer X, let f(X) be the number of positive divisors of X.
Given a positive integer N, find \sum_{K=1}^N K\times f(K).
-----Constraints-----
- 1 \leq N \leq 10^7
-----Input-----
Input is given from Standard Input in the following for... |
Solve the programming task below in a Python markdown code block.
Dolphin is planning to generate a small amount of a certain chemical substance C.
In order to generate the substance C, he must prepare a solution which is a mixture of two substances A and B in the ratio of M_a:M_b.
He does not have any stock of chem... |
Solve the programming task below in a Python markdown code block.
You are given an integer N. Among the divisors of N! (= 1 \times 2 \times ... \times N), how many Shichi-Go numbers (literally "Seven-Five numbers") are there?
Here, a Shichi-Go number is a positive integer that has exactly 75 divisors.
-----Note-----
... |
Solve the programming task below in a Python markdown code block.
There are $n$ students and $m$ clubs in a college. The clubs are numbered from $1$ to $m$. Each student has a potential $p_i$ and is a member of the club with index $c_i$. Initially, each student is a member of exactly one club. A technical fest starts ... |
Solve the programming task below in a Python markdown code block.
Every evening Vitalya sets n alarm clocks to wake up tomorrow. Every alarm clock rings during exactly one minute and is characterized by one integer a_{i} — number of minute after midnight in which it rings. Every alarm clock begins ringing at the begin... |
Solve the programming task below in a Python markdown code block.
And where the are the phone numbers?
You are given a string s consisting of lowercase English letters and an integer k. Find the lexicographically smallest string t of length k, such that its set of letters is a subset of the set of letters of s and s ... |
Solve the programming task below in a Python markdown code block.
Vasya likes taking part in Codeforces contests. When a round is over, Vasya follows all submissions in the system testing tab.
There are $n$ solutions, the $i$-th of them should be tested on $a_i$ tests, testing one solution on one test takes $1$ secon... |
Solve the programming task below in a Python markdown code block.
Moscow is hosting a major international conference, which is attended by n scientists from different countries. Each of the scientists knows exactly one language. For convenience, we enumerate all languages of the world with integers from 1 to 10^9.
In... |
Solve the programming task below in a Python markdown code block.
You are given a permutation p of numbers 1, 2, ..., n. Let's define f(p) as the following sum:$f(p) = \sum_{i = 1}^{n} \sum_{j = i}^{n} \operatorname{min}(p_{i}, p_{i + 1}, \ldots p_{j})$
Find the lexicographically m-th permutation of length n in the s... |
Solve the programming task below in a Python markdown code block.
Monocarp has arranged $n$ colored marbles in a row. The color of the $i$-th marble is $a_i$. Monocarp likes ordered things, so he wants to rearrange marbles in such a way that all marbles of the same color form a contiguos segment (and there is only one... |
Solve the programming task below in a Python markdown code block.
Masha wants to open her own bakery and bake muffins in one of the n cities numbered from 1 to n. There are m bidirectional roads, each of whose connects some pair of cities.
To bake muffins in her bakery, Masha needs to establish flour supply from some... |
Solve the programming task below in a Python markdown code block.
You are given array consisting of n integers. Your task is to find the maximum length of an increasing subarray of the given array.
A subarray is the sequence of consecutive elements of the array. Subarray is called increasing if each element of this s... |
Solve the programming task below in a Python markdown code block.
Vasya has found a piece of paper with an array written on it. The array consists of n integers a_1, a_2, ..., a_{n}. Vasya noticed that the following condition holds for the array a_{i} ≤ a_{i} + 1 ≤ 2·a_{i} for any positive integer i (i < n).
Vasya wa... |
Solve the programming task below in a Python markdown code block.
It is Professor R's last class of his teaching career. Every time Professor R taught a class, he gave a special problem for the students to solve. You being his favourite student, put your heart into solving it one last time.
You are given two polynomi... |
Solve the programming task below in a Python markdown code block.
After you had helped Fedor to find friends in the «Call of Soldiers 3» game, he stopped studying completely. Today, the English teacher told him to prepare an essay. Fedor didn't want to prepare the essay, so he asked Alex for help. Alex came to help an... |
Solve the programming task below in a Python markdown code block.
Valera had an undirected connected graph without self-loops and multiple edges consisting of n vertices. The graph had an interesting property: there were at most k edges adjacent to each of its vertices. For convenience, we will assume that the graph v... |
Solve the programming task below in a Python markdown code block.
It is winter now, and Max decided it's about time he watered the garden.
The garden can be represented as n consecutive garden beds, numbered from 1 to n. k beds contain water taps (i-th tap is located in the bed x_{i}), which, if turned on, start deli... |
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.
You have two integers $l$ and $r$. Find an integer $x$ which satisfies the conditions below:
$l \le x \le r$. All digits of $x$ are different.
If there are multiple answers, print any of them.
-----Input-----
The first line contains two integer... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.