question
large_stringlengths
265
13.2k
Solve the programming task below in a Python markdown code block. One day Alex was creating a contest about his friends, but accidentally deleted it. Fortunately, all the problems were saved, but now he needs to find them among other problems. But there are too many problems, to do it manually. Alex asks you to write...
Solve the programming task below in a Python markdown code block. You are given array $a_1, a_2, \dots, a_n$. Find the subsegment $a_l, a_{l+1}, \dots, a_r$ ($1 \le l \le r \le n$) with maximum arithmetic mean $\frac{1}{r - l + 1}\sum\limits_{i=l}^{r}{a_i}$ (in floating-point numbers, i.e. without any rounding). If t...
Solve the programming task below in a Python markdown code block. Linear Kingdom has exactly one tram line. It has `n` stops, numbered from 1 to n in the order of tram's movement. At the i-th stop ai passengers exit the tram, while bi passengers enter it. The tram is empty before it arrives at the first stop. ## Your...
Solve the programming task below in a Python markdown code block. Given simple (without self-intersections) n-gon. It is not necessary convex. Also you are given m lines. For each line find the length of common part of the line and the n-gon. The boundary of n-gon belongs to polygon. It is possible that n-gon contain...
Solve the programming task below in a Python markdown code block. After lessons Nastya decided to read a book. The book contains $n$ chapters, going one after another, so that one page of the book belongs to exactly one chapter and each chapter contains at least one page. Yesterday evening Nastya did not manage to fi...
Solve the programming task below in a Python markdown code block. As you have noticed, there are lovely girls in Arpa’s land. People in Arpa's land are numbered from 1 to n. Everyone has exactly one crush, i-th person's crush is person with the number crushi. <image> Someday Arpa shouted Owf loudly from the top of ...
Solve the programming task below in a Python markdown code block. Convexity of a set of points on the plane is the size of the largest subset of points that form a convex polygon. Your task is to build a set of n points with the convexity of exactly m. Your set of points should not contain three points that lie on a s...
Solve the programming task below in a Python markdown code block. At the school where the twins Ami and Mami attend, the summer vacation has already begun, and a huge amount of homework has been given this year as well. However, the two of them were still trying to go out without doing any homework today. It is obviou...
Solve the programming task below in a Python markdown code block. Sasha and Dima want to buy two $n$-tier cakes. Each cake should consist of $n$ different tiers: from the size of $1$ to the size of $n$. Tiers should go in order from the smallest to the biggest (from top to bottom). They live on the same street, there...
Solve the programming task below in a Python markdown code block. Example Input 2 2 2 0 0 0 5 Output 1 3 3 1 0 Read the inputs from stdin solve the problem and write the answer to stdout (do not directly test on the sample inputs). Enclose your code within ```python delimiters.
Solve the programming task below in a Python markdown code block. Fafa owns a company that works on huge projects. There are n employees in Fafa's company. Whenever the company has a new project to start working on, Fafa has to divide the tasks of this project among all the employees. Fafa finds doing this every time...
Solve the programming task below in a Python markdown code block. Create a function that accepts dimensions, of Rows x Columns, as parameters in order to create a multiplication table sized according to the given dimensions. **The return value of the function must be an array, and the numbers must be Fixnums, NOT str...
Solve the programming task below in a Python markdown code block. A Madhav array has the following property: ```a[0] = a[1] + a[2] = a[3] + a[4] + a[5] = a[6] + a[7] + a[8] + a[9] = ...``` Complete the function/method that returns `true` if the given array is a Madhav array, otherwise it returns `false`. *Edge case...
Solve the programming task below in a Python markdown code block. Read problems statements in Mandarin Chinese and Russian. Aditi recently discovered a new magic trick. First, she gives you an integer N and asks you to think an integer between 1 and N. Then she gives you a bundle of cards each having a sorted list ...
Solve the programming task below in a Python markdown code block. You are given an undirected connected weighted graph consisting of $n$ vertices and $m$ edges. Let's denote the length of the shortest path from vertex $1$ to vertex $i$ as $d_i$. You have to erase some edges of the graph so that at most $k$ edges rem...
Solve the programming task below in a Python markdown code block. The sales department of Japanese Ancient Giant Corp. is visiting a hot spring resort for their recreational trip. For deepening their friendships, they are staying in one large room of a Japanese-style hotel called a ryokan. In the ryokan, people sleep...
Solve the programming task below in a Python markdown code block. Peter likes to travel by train. He likes it so much that on the train he falls asleep. Once in summer Peter was going by train from city A to city B, and as usual, was sleeping. Then he woke up, started to look through the window and noticed that ever...
Solve the programming task below in a Python markdown code block. A permutation of size n is an array of size n such that each integer from 1 to n occurs exactly once in this array. An inversion in a permutation p is a pair of indices (i, j) such that i > j and a_{i} < a_{j}. For example, a permutation [4, 1, 3, 2] co...
Solve the programming task below in a Python markdown code block. Dima is a beginner programmer. During his working process, he regularly has to repeat the following operation again and again: to remove every second element from the array. One day he has been bored with easy solutions of this problem, and he has come ...
Solve the programming task below in a Python markdown code block. # How much is the fish! (- Scooter ) The ocean is full of colorful fishes. We as programmers want to know the hexadecimal value of these fishes. ## Task Take all hexadecimal valid characters (a,b,c,d,e,f) of the given name and XOR them. Return the resu...
Solve the programming task below in a Python markdown code block. Limak is a little polar bear. He loves connecting with other bears via social networks. He has n friends and his relation with the i-th of them is described by a unique integer t_{i}. The bigger this value is, the better the friendship is. No two friend...
Solve the programming task below in a Python markdown code block. For a given sequence $A = \\{a_0, a_1, ... a_{n-1}\\}$, the number of pairs $(i, j)$ where $a_i > a_j$ and $i < j$, is called the number of inversions. The number of inversions is equal to the number of swaps of Bubble Sort defined in the following prog...
Solve the programming task below in a Python markdown code block. There are $n$ detachments on the surface, numbered from $1$ to $n$, the $i$-th detachment is placed in a point with coordinates $(x_i, y_i)$. All detachments are placed in different points. Brimstone should visit each detachment at least once. You can ...
Solve the programming task below in a Python markdown code block. You've got an array a, consisting of n integers. The array elements are indexed from 1 to n. Let's determine a two step operation like that: 1. First we build by the array a an array s of partial sums, consisting of n elements. Element number i (1 ≤ ...
Solve the programming task below in a Python markdown code block. You've just entered a programming contest and have a chance to win a million dollars. This is the last question you have to solve, so your victory (and your vacation) depend on it. Can you guess the function just by looking at the test cases? There are ...
Solve the programming task below in a Python markdown code block. A balance scale tips to the left if L>R, where L is the total weight of the masses on the left pan and R is the total weight of the masses on the right pan. Similarly, it balances if L=R, and tips to the right if L<R. Takahashi placed a mass of weight A...
Solve the programming task below in a Python markdown code block. # Task John won the championship of a TV show. He can get some bonuses. He needs to play a game to determine the amount of his bonus. Here are some cards in a row. A number is written on each card. In each turn, John can take a card, but only from t...
Solve the programming task below in a Python markdown code block. Gematria is an Assyro-Babylonian-Greek system of code and numerology later adopted into Jewish culture. The system assigns numerical value to a word or a phrase in the belief that words or phrases with identical numerical values bear some relation to ea...
Solve the programming task below in a Python markdown code block. In the school computer room there are n servers which are responsible for processing several computing tasks. You know the number of scheduled tasks for each server: there are m_{i} tasks assigned to the i-th server. In order to balance the load for ea...
Solve the programming task below in a Python markdown code block. A permutation of length n is an integer sequence such that each integer from 0 to (n - 1) appears exactly once in it. For example, sequence [0, 2, 1] is a permutation of length 3 while both [0, 2, 2] and [1, 2, 3] are not. A fixed point of a function i...
Solve the programming task below in a Python markdown code block. You have N items that you want to put them into a knapsack. Item i has value vi and weight wi. You want to find a subset of items to put such that: * The total value of the items is as large as possible. * The items have combined weight at most W, tha...
Solve the programming task below in a Python markdown code block. Eugeny loves listening to music. He has n songs in his play list. We know that song number i has the duration of t_{i} minutes. Eugeny listens to each song, perhaps more than once. He listens to song number i c_{i} times. Eugeny's play list is organized...
Solve the programming task below in a Python markdown code block. I need to save some money to buy a gift. I think I can do something like that: First week (W0) I save nothing on Sunday, 1 on Monday, 2 on Tuesday... 6 on Saturday, second week (W1) 2 on Monday... 7 on Saturday and so on according to the table below wh...
Solve the programming task below in a Python markdown code block. Snuke built an online judge to hold a programming contest. When a program is submitted to the judge, the judge returns a verdict, which is a two-character string that appears in the string S as a contiguous substring. (The judge can return any two-char...
Solve the programming task below in a Python markdown code block. Today Vasya visited a widely known site and learned that the continuation of his favourite game Codecraft II will appear after exactly k months. He looked at the calendar and learned that at the moment is the month number s. Vasya immediately got intere...
Solve the programming task below in a Python markdown code block. For a set $S$ of integers, perform a sequence of the following operations. Note that multiple elements can have equivalent values in $S$. * insert($x$): Insert $x$ to $S$ and report the number of elements in $S$ after the operation. * find($x$): Report...
Solve the programming task below in a Python markdown code block. As you may know, once some people pass their teens, they jokingly only celebrate their 20th or 21st birthday, forever. With some maths skills, that's totally possible - you only need to select the correct number base! For example, if they turn 32, that...
Solve the programming task below in a Python markdown code block. Given is a string S of length N consisting of lowercase English letters. Snuke can do this operation any number of times: remove fox occurring as a substring from s and concatenate the remaining parts of s. What is the minimum possible length of s after...
Solve the programming task below in a Python markdown code block. Madoka decided to entrust the organization of a major computer game tournament "OSU"! In this tournament, matches are held according to the "Olympic system". In other words, there are $2^n$ participants in the tournament, numbered with integers from $1...
Solve the programming task below in a Python markdown code block. Do you know a story about the three musketeers? Anyway, you will learn about its origins now. Richelimakieu is a cardinal in the city of Bearis. He is tired of dealing with crime by himself. He needs three brave warriors to help him to fight against ba...
Solve the programming task below in a Python markdown code block. There are $n$ models in the shop numbered from $1$ to $n$, with sizes $s_1, s_2, \ldots, s_n$. Orac will buy some of the models and will arrange them in the order of increasing numbers (i.e. indices, but not sizes). Orac thinks that the obtained arran...
Solve the programming task below in a Python markdown code block. A permutation p of size n is the sequence p1, p2, ..., pn, consisting of n distinct integers, each of them is from 1 to n (1 ≤ pi ≤ n). A lucky permutation is such permutation p, that any integer i (1 ≤ i ≤ n) meets this condition ppi = n - i + 1. You...
Solve the programming task below in a Python markdown code block. Consider the prime number `23`. If we sum the square of its digits we get: `2^2 + 3^2 = 13`, then for `13: 1^2 + 3^2 = 10`, and finally for `10: 1^2 + 0^2 = 1`. Similarly, if we start with prime number `7`, the sequence is: `7->49->97->130->10->1`. G...
Solve the programming task below in a Python markdown code block. Let's call an array $a$ of $m$ integers $a_1, a_2, \ldots, a_m$ Decinc if $a$ can be made increasing by removing a decreasing subsequence (possibly empty) from it. For example, if $a = [3, 2, 4, 1, 5]$, we can remove the decreasing subsequence $[a_1, a...
Solve the programming task below in a Python markdown code block. Hearing that energy drinks increase rating in those sites, Takahashi decides to buy up M cans of energy drinks. There are N stores that sell energy drinks. In the i-th store, he can buy at most B_i cans of energy drinks for A_i yen (the currency of Japa...
Solve the programming task below in a Python markdown code block. Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. One day Petya encountered a tree ...
Solve the programming task below in a Python markdown code block. Pig is visiting a friend. Pig's house is located at point 0, and his friend's house is located at point m on an axis. Pig can use teleports to move along the axis. To use a teleport, Pig should come to a certain point (where the teleport is located) ...
Solve the programming task below in a Python markdown code block. In graph theory, a graph is a collection of nodes with connections between them. Any node can be connected to any other node exactly once, and can be connected to no nodes, to some nodes, or to every other node. Nodes cannot be connected to themselves A...
Solve the programming task below in a Python markdown code block. Ivan had string s consisting of small English letters. However, his friend Julia decided to make fun of him and hid the string s. Ivan preferred making a new string to finding the old one. Ivan knows some information about the string s. Namely, he rem...
Solve the programming task below in a Python markdown code block. Kolya is developing an economy simulator game. His most favourite part of the development process is in-game testing. Once he was entertained by the testing so much, that he found out his game-coin score become equal to 0. Kolya remembers that at the b...
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? ---...
Solve the programming task below in a Python markdown code block. Naturally, the magical girl is very good at performing magic. She recently met her master wizard Devu, who gifted her R potions of red liquid, B potions of blue liquid, and G potions of green liquid. - The red liquid potions have liquid amounts given...
Solve the programming task below in a Python markdown code block. Nastya came to her informatics lesson, and her teacher who is, by the way, a little bit famous here gave her the following task. Two matrices $A$ and $B$ are given, each of them has size $n \times m$. Nastya can perform the following operation to matri...
Solve the programming task below in a Python markdown code block. Given an array of numbers (in string format), you must return a string. The numbers correspond to the letters of the alphabet in reverse order: a=26, z=1 etc. You should also account for `'!'`, `'?'` and `' '` that are represented by '27', '28' and '29'...
Solve the programming task below in a Python markdown code block. For an array of non-negative integers $a$ of size $n$, we construct another array $d$ as follows: $d_1 = a_1$, $d_i = |a_i - a_{i - 1}|$ for $2 \le i \le n$. Your task is to restore the array $a$ from a given array $d$, or to report that there are mult...
Solve the programming task below in a Python markdown code block. ## Task Complete the function that receives an array of strings (`arr`) as an argument and returns all the valid Roman numerals. Basic Roman numerals are denoted as: ``` I: 1, V: 5, X: 10, L: 50, C: 100, D: 500, M: 1000 ``` For the purposes of this ...
Solve the programming task below in a Python markdown code block. Given an integer a as input, print the value a + a^2 + a^3. -----Constraints----- - 1 \leq a \leq 10 - a is an integer. -----Input----- Input is given from Standard Input in the following format: a -----Output----- Print the value a + a^2 + a^3 as ...
Solve the programming task below in a Python markdown code block. Nearly each project of the F company has a whole team of developers working on it. They often are in different rooms of the office in different cities and even countries. To keep in touch and track the results of the project, the F company conducts shar...
Solve the programming task below in a Python markdown code block. Michael and Joe are playing a game. The game is played on a grid with $n$ rows and $m$ columns, filled with distinct integers. We denote the square on the $i$-th ($1\le i\le n$) row and $j$-th ($1\le j\le m$) column by $(i, j)$ and the number there by $...
Solve the programming task below in a Python markdown code block. During a recent research Berland scientists found out that there were n cities in Ancient Berland, joined by two-way paths. Any two cities are joined by no more than one path. No path joins a city with itself. According to a well-known tradition, the ro...
Solve the programming task below in a Python markdown code block. Thor is getting used to the Earth. As a gift Loki gave him a smartphone. There are n applications on this phone. Thor is fascinated by this phone. He has only one minor issue: he can't count the number of unread notifications generated by those applicat...
Solve the programming task below in a Python markdown code block. The employees of the F company have lots of ways to entertain themselves. Today they invited a famous magician who shows a trick with plastic cups and a marble. The point is to trick the spectator's attention. Initially, the spectator stands in front o...
Solve the programming task below in a Python markdown code block. ### self_converge `Goal`: Given a number (with a minimum of 3 digits), return the number of iterations it takes to arrive at a derived number that converges on to itself, as per the following [Kaprekar][Kaprekar] routine. As a learning exercise, come up...
Solve the programming task below in a Python markdown code block. You are given an array consisting of all integers from $[l, r]$ inclusive. For example, if $l = 2$ and $r = 5$, the array would be $[2, 3, 4, 5]$. What's the minimum number of elements you can delete to make the bitwise AND of the array non-zero? A bit...
Solve the programming task below in a Python markdown code block. Let's denote the median of a sequence $s$ with odd length as the value in the middle of $s$ if we sort $s$ in non-decreasing order. For example, let $s = [1, 2, 5, 7, 2, 3, 12]$. After sorting, we get sequence $[1, 2, 2, \underline{3}, 5, 7, 12]$, and t...
Solve the programming task below in a Python markdown code block. Alternate Escape Alice House Alice and Bob are playing board games. This board game is played using a board with squares in rows H and columns and one frame. In this game, the upper left square of the board is set as the 1st row and 1st column, and th...
Solve the programming task below in a Python markdown code block. In the beginning, Takahashi has A cookies, and Aoki has B cookies. They will perform the following operation alternately, starting from Takahashi: * If the number of cookies in his hand is odd, eat one of those cookies; if the number is even, do nothin...
Solve the programming task below in a Python markdown code block. Karen is getting ready for a new school day! [Image] It is currently hh:mm, given in a 24-hour format. As you know, Karen loves palindromes, and she believes that it is good luck to wake up when the time is a palindrome. What is the minimum number ...
Solve the programming task below in a Python markdown code block. During the archaeological research in the Middle East you found the traces of three ancient religions: First religion, Second religion and Third religion. You compiled the information on the evolution of each of these beliefs, and you now wonder if the ...
Solve the programming task below in a Python markdown code block. We have a string S of length N consisting of uppercase English letters. How many times does ABC occur in S as contiguous subsequences (see Sample Inputs and Outputs)? -----Constraints----- - 3 \leq N \leq 50 - S consists of uppercase English letters....
Solve the programming task below in a Python markdown code block. Dreamoon is a big fan of the Codeforces contests. One day, he claimed that he will collect all the places from $1$ to $54$ after two more rated contests. It's amazing! Based on this, you come up with the following problem: There is a person who parti...
Solve the programming task below in a Python markdown code block. Reminder: the median of the array $[a_1, a_2, \dots, a_{2k+1}]$ of odd number of elements is defined as follows: let $[b_1, b_2, \dots, b_{2k+1}]$ be the elements of the array in the sorted order. Then median of this array is equal to $b_{k+1}$. There ...
Solve the programming task below in a Python markdown code block. Dark Assembly is a governing body in the Netherworld. Here sit the senators who take the most important decisions for the player. For example, to expand the range of the shop or to improve certain characteristics of the character the Dark Assembly's app...
Solve the programming task below in a Python markdown code block. Given a string, swap the case for each of the letters. e.g. CodEwArs --> cODeWaRS ### Examples ``` "" -> "" "CodeWars" -> "cODEwARS" "abc" -> "ABC" "ABC" -> "abc" "123235" -> "123235" ``` Write your solution b...
Solve the programming task below in a Python markdown code block. As a big fan of Formula One, Charlie is really happy with the fact that he has to organize ticket sells for the next Grand Prix race in his own city. Unfortunately, the finacial crisis is striking everywhere and all the banknotes left in his country are...
Solve the programming task below in a Python markdown code block. The Smart Beaver from ABBYY began to develop a new educational game for children. The rules of the game are fairly simple and are described below. The playing field is a sequence of n non-negative integers ai numbered from 1 to n. The goal of the game ...
Solve the programming task below in a Python markdown code block. You are given a matrix of size $n \times n$ filled with lowercase English letters. You can change no more than $k$ letters in this matrix. Consider all paths from the upper left corner to the lower right corner that move from a cell to its neighboring ...
Solve the programming task below in a Python markdown code block. You are now in a bookshop with your friend Alice to buy a book, "The Winning Strategy for the Programming Koshien Contest,” just released today. As you definitely want to buy it, you are planning to borrow some money from Alice in case the amount you ha...
Solve the programming task below in a Python markdown code block. Let S be the sum of divisors of an integer N excluding the number itself. When N = S, N is called a perfect number, when N> S, N is called a defendant number, and when N <S, N is called an abundant number. Create a program that determines whether a give...
Solve the programming task below in a Python markdown code block. There are N lines in the xy-plane. The i-th line is represented by A_ix+B_iy=C_i. Any two lines among the N+2 lines, the above N lines plus the x-axis and y-axis, cross each other at exactly one point. For each pair 1 \leq i < j \leq N, there is a car ...
Solve the programming task below in a Python markdown code block. Recently Max has got himself into popular CCG "BrainStone". As "BrainStone" is a pretty intellectual game, Max has to solve numerous hard problems during the gameplay. Here is one of them: Max owns n creatures, i-th of them can be described with two nu...
Solve the programming task below in a Python markdown code block. You are given n segments on the Ox-axis. You can drive a nail in any integer point on the Ox-axis line nail so, that all segments containing this point, are considered nailed down. If the nail passes through endpoint of some segment, this segment is con...
Solve the programming task below in a Python markdown code block. You are given a string of words (x), for each word within the string you need to turn the word 'inside out'. By this I mean the internal letters will move out, and the external letters move toward the centre. If the word is even length, all letters wi...
Solve the programming task below in a Python markdown code block. Take a string and return a hash with all the ascii values of the characters in the string. Returns nil if the string is empty. The key is the character, and the value is the ascii value of the character. Repeated characters are to be ignored and non-alp...
Solve the programming task below in a Python markdown code block. On February, 30th n students came in the Center for Training Olympiad Programmers (CTOP) of the Berland State University. They came one by one, one after another. Each of them went in, and before sitting down at his desk, greeted with those who were pre...
Solve the programming task below in a Python markdown code block. An abundant number or excessive number is a number for which the sum of its proper divisors is greater than the number itself. The integer 12 is the first abundant number. Its proper divisors are 1, 2, 3, 4 and 6 for a total of 16 (> 12). Derive func...
Solve the programming task below in a Python markdown code block. We have five variables x_1, x_2, x_3, x_4, and x_5. The variable x_i was initially assigned a value of i. Snuke chose one of these variables and assigned it 0. You are given the values of the five variables after this assignment. Find out which variable...
Solve the programming task below in a Python markdown code block. One day Vasya came across three Berland coins. They didn't have any numbers that's why Vasya didn't understand how their denominations differ. He supposed that if one coin is heavier than the other one, then it should be worth more. Vasya weighed all th...
Solve the programming task below in a Python markdown code block. You have an array a consisting of n distinct positive integers, numbered from 1 to n. Define p_k as $$$p_k = ∑_{1 ≤ i, j ≤ k} a_i mod a_j, where x \bmod y denotes the remainder when x is divided by y. You have to find and print p_1, p_2, \ldots, p_n$$$....
Solve the programming task below in a Python markdown code block. Very simple, given a number, find its opposite. Examples: ``` 1: -1 14: -14 -34: 34 ``` ~~~if:sql You will be given a table: `opposite`, with a column: `number`. Return a table with a column: `res`. ~~~ Write your solution by modifying this code: ``...
Solve the programming task below in a Python markdown code block. In Absurdistan, there are n towns (numbered 1 through n) and m bidirectional railways. There is also an absurdly simple road network — for each pair of different towns x and y, there is a bidirectional road between towns x and y if and only if there is ...
Solve the programming task below in a Python markdown code block. A continued fraction of height n is a fraction of form $a_{1} + \frac{1}{a_{2} + \frac{1}{\ldots + \frac{1}{a_{n}}}}$. You are given two rational numbers, one is represented as [Image] and the other one is represented as a finite fraction of height n. C...
Solve the programming task below in a Python markdown code block. Neko loves divisors. During the latest number theory lesson, he got an interesting exercise from his math teacher. Neko has two integers $a$ and $b$. His goal is to find a non-negative integer $k$ such that the least common multiple of $a+k$ and $b+k$ ...
Solve the programming task below in a Python markdown code block. Mike has n strings s1, s2, ..., sn each consisting of lowercase English letters. In one move he can choose a string si, erase the first character and append it to the end of the string. For example, if he has the string "coolmike", in one move he can tr...
Solve the programming task below in a Python markdown code block. Arkady decides to observe a river for n consecutive days. The river's water level on each day is equal to some real value. Arkady goes to the riverside each day and makes a mark on the side of the channel at the height of the water level, but if it coi...
Solve the programming task below in a Python markdown code block. Today Adilbek is taking his probability theory test. Unfortunately, when Adilbek arrived at the university, there had already been a long queue of students wanting to take the same test. Adilbek has estimated that he will be able to start the test only ...
Solve the programming task below in a Python markdown code block. A lot of frogs want to cross a river. A river is $w$ units width, but frogs can only jump $l$ units long, where $l < w$. Frogs can also jump on lengths shorter than $l$. but can't jump longer. Hopefully, there are some stones in the river to help them. ...
Solve the programming task below in a Python markdown code block. Polycarp has recently got himself a new job. He now earns so much that his old wallet can't even store all the money he has. Berland bills somehow come in lots of different sizes. However, all of them are shaped as rectangles (possibly squares). All wa...
Solve the programming task below in a Python markdown code block. You are given an undirected weighted connected graph with $n$ vertices and $m$ edges without loops and multiple edges. The $i$-th edge is $e_i = (u_i, v_i, w_i)$; the distance between vertices $u_i$ and $v_i$ along the edge $e_i$ is $w_i$ ($1 \le w_i$)...
Solve the programming task below in a Python markdown code block. Problem Given $ N $ a pair of non-negative integers $ (a_i, b_i) $ and non-negative integers $ A $, $ B $. I want to do as many of the following operations as possible. * $ | a_i --b_i | \ leq A $ or $ B \ leq | a_i --b_i | \ leq Take out and delete ...