question
large_stringlengths
265
13.2k
Solve the programming task below in a Python markdown code block. International Christmas Present Company (ICPC) is a company to employ Santa and deliver presents on Christmas. Many parents request ICPC to deliver presents to their children at specified time of December 24. Although same Santa can deliver two or more ...
Solve the programming task below in a Python markdown code block. ## Task You have to write three functions namely - `PNum, GPNum and SPNum` (JS, Coffee), `p_num, g_p_num and s_p_num` (Python and Ruby), `pNum, gpNum and spNum` (Java, C#), `p-num, gp-num and sp-num` (Clojure) - to check whether a given argument `n` is...
Solve the programming task below in a Python markdown code block. Airport Codes Airport code In the Kingdom of JAG, airport codes are assigned to each domestic airport for identification. Airport codes are assigned according to the following rules based on the name of the airport in lowercase English alphabet: 1. ...
Solve the programming task below in a Python markdown code block. You are working for an administration office of the International Center for Picassonian Cubism (ICPC), which plans to build a new art gallery for young artists. The center is organizing an architectural design competition to find the best design for th...
Solve the programming task below in a Python markdown code block. Did you know that the yummy golden triangle was introduced in India as early as 13th century ? By the way, I'm referring to the popular South Asian snack, Samosa. I guess its hard to code while thinking of Samosa, especially if you are very hungry now ;...
Solve the programming task below in a Python markdown code block. Eshag has an array $a$ consisting of $n$ integers. Eshag can perform the following operation any number of times: choose some subsequence of $a$ and delete every element from it which is strictly larger than $AVG$, where $AVG$ is the average of the num...
Solve the programming task below in a Python markdown code block. Rikhail Mubinchik believes that the current definition of prime numbers is obsolete as they are too complex and unpredictable. A palindromic number is another matter. It is aesthetically pleasing, and it has a number of remarkable properties. Help Rikha...
Solve the programming task below in a Python markdown code block. Once again, Boris needs the help of Anton in creating a task. This time Anton needs to solve the following problem: There are two arrays of integers $a$ and $b$ of length $n$. It turned out that array $a$ contains only elements from the set $\{-1, 0, 1...
Solve the programming task below in a Python markdown code block. Inna and Dima bought a table of size n × m in the shop. Each cell of the table contains a single letter: "D", "I", "M", "A". Inna loves Dima, so she wants to go through his name as many times as possible as she moves through the table. For that, Inna a...
Solve the programming task below in a Python markdown code block. ### Task You've just moved into a perfectly straight street with exactly ```n``` identical houses on either side of the road. Naturally, you would like to find out the house number of the people on the other side of the street. The street looks somethin...
Solve the programming task below in a Python markdown code block. Let's call beauty of an array $b_1, b_2, \ldots, b_n$ ($n > 1$)  — $\min\limits_{1 \leq i < j \leq n} |b_i - b_j|$. You're given an array $a_1, a_2, \ldots a_n$ and a number $k$. Calculate the sum of beauty over all subsequences of the array of length ...
Solve the programming task below in a Python markdown code block. Given a string, turn each letter into its ASCII character code and join them together to create a number - let's call this number `total1`: ``` 'ABC' --> 'A' = 65, 'B' = 66, 'C' = 67 --> 656667 ``` Then replace any incidence of the number `7` with the...
Solve the programming task below in a Python markdown code block. Construct a function 'coordinates', that will return the distance between two points on a cartesian plane, given the x and y coordinates of each point. There are two parameters in the function, ```p1``` and ```p2```. ```p1``` is a list ```[x1,y1]``` wh...
Solve the programming task below in a Python markdown code block. Bob came to a cash & carry store, put n items into his trolley, and went to the checkout counter to pay. Each item is described by its price ci and time ti in seconds that a checkout assistant spends on this item. While the checkout assistant is occupie...
Solve the programming task below in a Python markdown code block. Gerald plays the following game. He has a checkered field of size n × n cells, where m various cells are banned. Before the game, he has to put a few chips on some border (but not corner) board cells. Then for n - 1 minutes, Gerald every minute moves ea...
Solve the programming task below in a Python markdown code block. There are N arrays. The length of each array is M and initially each array contains integers (1,2,...,M) in this order. Mr. Takahashi has decided to perform Q operations on those N arrays. For the i-th (1≤i≤Q) time, he performs the following operation....
Solve the programming task below in a Python markdown code block. Toad Zitz has an array of integers, each integer is between 0 and m-1 inclusive. The integers are a_1, a_2, …, a_n. In one operation Zitz can choose an integer k and k indices i_1, i_2, …, i_k such that 1 ≤ i_1 < i_2 < … < i_k ≤ n. He should then chang...
Solve the programming task below in a Python markdown code block. You are given a string s consisting of n lowercase Latin letters. You have to type this string using your keyboard. Initially, you have an empty string. Until you type the whole string, you may perform the following operation: add a character to the e...
Solve the programming task below in a Python markdown code block. In the world of DragonBool there are fierce warriors called Soints. Also there are even fiercer warriors called Sofloats – the mortal enemies of Soints. The power of each warrior is determined by the amount of chakra he possesses which is some positive...
Solve the programming task below in a Python markdown code block. Given the triangle of consecutive odd numbers: ``` 1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 ... ``` Calculate the row sums of this triangle from the row index (starting at index 1) e.g.: ...
Solve the programming task below in a Python markdown code block. A ski base is planned to be built in Walrusland. Recently, however, the project is still in the constructing phase. A large land lot was chosen for the construction. It contains n ski junctions, numbered from 1 to n. Initially the junctions aren't conne...
Solve the programming task below in a Python markdown code block. Cheesy Cheeseman just got a new monitor! He is happy with it, but he just discovered that his old desktop wallpaper no longer fits. He wants to find a new wallpaper, but does not know which size wallpaper he should be looking for, and alas, he just thre...
Solve the programming task below in a Python markdown code block. Given is an integer x that is greater than or equal to 0, and less than or equal to 1. Output 1 if x is equal to 0, or 0 if x is equal to 1. -----Constraints----- - 0 \leq x \leq 1 - x is an integer -----Input----- Input is given from Standard Input...
Solve the programming task below in a Python markdown code block. Phoenix has $n$ coins with weights $2^1, 2^2, \dots, 2^n$. He knows that $n$ is even. He wants to split the coins into two piles such that each pile has exactly $\frac{n}{2}$ coins and the difference of weights between the two piles is minimized. Forma...
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...
Solve the programming task below in a Python markdown code block. # 'Magic' recursion call depth number This Kata was designed as a Fork to the one from donaldsebleung Roboscript series with a reference to: https://www.codewars.com/collections/roboscript It is not more than an extension of Roboscript infinite "sing...
Solve the programming task below in a Python markdown code block. Given is a string S. Replace every character in S with x and print the result. -----Constraints----- - S is a string consisting of lowercase English letters. - The length of S is between 1 and 100 (inclusive). -----Input----- Input is given from Sta...
Solve the programming task below in a Python markdown code block. You are given an integer N. Find the number of the positive divisors of N!, modulo 10^9+7. -----Constraints----- - 1≤N≤10^3 -----Input----- The input is given from Standard Input in the following format: N -----Output----- Print the number of the po...
Solve the programming task below in a Python markdown code block. You are given two positive integers $x$ and $y$. You can perform the following operation with $x$: write it in its binary form without leading zeros, add $0$ or $1$ to the right of it, reverse the binary form and turn it into a decimal number which is a...
Solve the programming task below in a Python markdown code block. Snuke is buying a bicycle. The bicycle of his choice does not come with a bell, so he has to buy one separately. He has very high awareness of safety, and decides to buy two bells, one for each hand. The store sells three kinds of bells for the price of...
Solve the programming task below in a Python markdown code block. Square Route Square root English text is not available in this practice contest. Millionaire Shinada, who has decided to build a new mansion, is wondering in which city to build the new mansion. To tell the truth, Mr. Shinada is a strange person who ...
Solve the programming task below in a Python markdown code block. A `bouncy number` is a positive integer whose digits neither increase nor decrease. For example, 1235 is an increasing number, 5321 is a decreasing number, and 2351 is a bouncy number. By definition, all numbers under 100 are non-bouncy, and 101 is the ...
Solve the programming task below in a Python markdown code block. Takahashi became a pastry chef and opened a shop La Confiserie d'ABC to celebrate AtCoder Beginner Contest 100. The shop sells N kinds of cakes. Each kind of cake has three parameters "beauty", "tastiness" and "popularity". The i-th kind of cake has th...
Solve the programming task below in a Python markdown code block. Read problems statements in Mandarin Chinese . Given an array of n non-negative integers: A_{1}, A_{2}, …, A_{N}. Your mission is finding a pair of integers A_{u}, A_{v} (1 ≤ u < v ≤ N) such that (A_{u} and A_{v}) is as large as possible. And is a bi...
Solve the programming task below in a Python markdown code block. Once Volodya was at the museum and saw a regular chessboard as a museum piece. And there were only four chess pieces on it: two white rooks, a white king and a black king. "Aha, blacks certainly didn't win!", — Volodya said and was right for sure. And y...
Solve the programming task below in a Python markdown code block. For a given sequence of distinct non-negative integers $(b_1, b_2, \dots, b_k)$ we determine if it is good in the following way: Consider a graph on $k$ nodes, with numbers from $b_1$ to $b_k$ written on them. For every $i$ from $1$ to $k$: find such ...
Solve the programming task below in a Python markdown code block. This is an easier version of the next problem. The difference is only in constraints. You are given a rectangular $n \times m$ matrix $a$. In one move you can choose any column and cyclically shift elements in this column. You can perform this operatio...
Solve the programming task below in a Python markdown code block. Bomboslav likes to look out of the window in his room and watch lads outside playing famous shell game. The game is played by two persons: operator and player. Operator takes three similar opaque shells and places a ball beneath one of them. Then he shu...
Solve the programming task below in a Python markdown code block. You are at a water bowling training. There are l people who play with their left hand, r people, who play with their right hand, and a ambidexters, who can play with left or right hand. The coach decided to form a team of even number of players, exactl...
Solve the programming task below in a Python markdown code block. You have an array of integers (initially empty). You have to perform $q$ queries. Each query is of one of two types: "$1$ $x$" — add the element $x$ to the end of the array; "$2$ $x$ $y$" — replace all occurrences of $x$ in the array with $y$. Find ...
Solve the programming task below in a Python markdown code block. > I would, if I could, > If I couldn't how could I? > I couldn't, without I could, could I? > Could you, without you could, could ye? > Could ye? could ye? > Could you, without you could, could ye? It is true, as this old rhyme says, that we can o...
Solve the programming task below in a Python markdown code block. Gildong is now developing a puzzle game. The puzzle consists of n platforms numbered from 1 to n. The player plays the game as a character that can stand on each platform and the goal of the game is to move the character from the 1-st platform to the n-...
Solve the programming task below in a Python markdown code block. In number world, two different numbers are friends if they have a lot in common, but also each one has unique perks. More precisely, two different numbers a and b are friends if gcd(a,b), (a)/(gcd(a,b)), (b)/(gcd(a,b)) can form sides of a triangle. Th...
Solve the programming task below in a Python markdown code block. Snuke found a record of a tree with N vertices in ancient ruins. The findings are as follows: * The vertices of the tree were numbered 1,2,...,N, and the edges were numbered 1,2,...,N-1. * Edge i connected Vertex a_i and b_i. * The length of each edge ...
Solve the programming task below in a Python markdown code block. In this kata, you will write a function that returns the positions and the values of the "peaks" (or local maxima) of a numeric array. For example, the array `arr = [0, 1, 2, 5, 1, 0]` has a peak at position `3` with a value of `5` (since `arr[3]` equa...
Solve the programming task below in a Python markdown code block. ###Story Sometimes we are faced with problems when we have a big nested dictionary with which it's hard to work. Now, we need to solve this problem by writing a function that will flatten a given dictionary. ###Info Python dictionaries are a convenient...
Solve the programming task below in a Python markdown code block. In an attempt to escape the Mischievous Mess Makers' antics, Farmer John has abandoned his farm and is traveling to the other side of Bovinia. During the journey, he and his k cows have decided to stay at the luxurious Grand Moo-dapest Hotel. The hotel ...
Solve the programming task below in a Python markdown code block. At Aizu Riverside Hospital, inpatients walk twice a day for rehabilitation and health promotion. As the number of people trying to recover their physical strength by walking is increasing day by day in order to leave the hospital energetically, the dire...
Solve the programming task below in a Python markdown code block. Write a function that takes as its parameters *one or more numbers which are the diameters of circles.* The function should return the *total area of all the circles*, rounded to the nearest integer in a string that says "We have this much circle: xyz...
Solve the programming task below in a Python markdown code block. You are the "computer expert" of a local Athletic Association (C.A.A.). Many teams of runners come to compete. Each time you get a string of all race results of every team who has run. For example here is a string showing the individual results of a te...
Solve the programming task below in a Python markdown code block. A sequence $a_1, a_2, \dots, a_n$ is called good if, for each element $a_i$, there exists an element $a_j$ ($i \ne j$) such that $a_i+a_j$ is a power of two (that is, $2^d$ for some non-negative integer $d$). For example, the following sequences are go...
Solve the programming task below in a Python markdown code block. The mayor of Amida, the City of Miracle, is not elected like any other city. Once exhausted by long political struggles and catastrophes, the city has decided to leave the fate of all candidates to the lottery in order to choose all candidates fairly an...
Solve the programming task below in a Python markdown code block. Gerald plays the following game. He has a checkered field of size n × n cells, where m various cells are banned. Before the game, he has to put a few chips on some border (but not corner) board cells. Then for n - 1 minutes, Gerald every minute moves ea...
Solve the programming task below in a Python markdown code block. Dr. Asimov, a robotics researcher, released cleaning robots he developed (see Problem B). His robots soon became very popular and he got much income. Now he is pretty rich. Wonderful. First, he renovated his house. Once his house had 9 rooms that were ...
Solve the programming task below in a Python markdown code block. Vanya is doing his maths homework. He has an expression of form $x_{1} \diamond x_{2} \diamond x_{3} \diamond \ldots \diamond x_{n}$, where x_1, x_2, ..., x_{n} are digits from 1 to 9, and sign [Image] represents either a plus '+' or the multiplication ...
Solve the programming task below in a Python markdown code block. Mr. Funt now lives in a country with a very specific tax laws. The total income of mr. Funt during this year is equal to n (n ≥ 2) burles and the amount of tax he has to pay is calculated as the maximum divisor of n (not equal to n, of course). For exam...
Solve the programming task below in a Python markdown code block. Vasya is writing an operating system shell, and it should have commands for working with directories. To begin with, he decided to go with just two commands: cd (change the current directory) and pwd (display the current directory). Directories in Vasy...
Solve the programming task below in a Python markdown code block. Alice and Bob are playing a game with $n$ piles of stones. It is guaranteed that $n$ is an even number. The $i$-th pile has $a_i$ stones. Alice and Bob will play a game alternating turns with Alice going first. On a player's turn, they must choose exa...
Solve the programming task below in a Python markdown code block. # Task Write a function `deNico`/`de_nico()` that accepts two parameters: - `key`/`$key` - string consists of unique letters and digits - `message`/`$message` - string with encoded message and decodes the `message` using the `key`. First create a ...
Solve the programming task below in a Python markdown code block. You are given an undirected connected weighted graph with N vertices and M edges that contains neither self-loops nor double edges. The i-th (1≤i≤M) edge connects vertex a_i and vertex b_i with a distance of c_i. Here, a self-loop is an edge where a_i...
Solve the programming task below in a Python markdown code block. Ivan is collecting coins. There are only $N$ different collectible coins, Ivan has $K$ of them. He will be celebrating his birthday soon, so all his $M$ freinds decided to gift him coins. They all agreed to three terms: Everyone must gift as many coins...
Solve the programming task below in a Python markdown code block. A film festival is coming up in the city N. The festival will last for exactly n days and each day will have a premiere of exactly one film. Each film has a genre — an integer from 1 to k. On the i-th day the festival will show a movie of genre a_{i}. ...
Solve the programming task below in a Python markdown code block. The problem describes the properties of a command line. The description somehow resembles the one you usually see in real operating systems. However, there are differences in the behavior. Please make sure you've read the statement attentively and use i...
Solve the programming task below in a Python markdown code block. You are an adventurer currently journeying inside an evil temple. After defeating a couple of weak zombies, you arrived at a square room consisting of tiles forming an n × n grid. The rows are numbered 1 through n from top to bottom, and the columns are...
Solve the programming task below in a Python markdown code block. Imagine a triangle of numbers which follows this pattern: * Starting with the number "1", "1" is positioned at the top of the triangle. As this is the 1st row, it can only support a single number. * The 2nd row can support the next 2 numbers: "2" and...
Solve the programming task below in a Python markdown code block. You are given a sequence A_1, A_2, ..., A_N and an integer K. Print the maximum possible length of a sequence B that satisfies the following conditions: * B is a (not necessarily continuous) subsequence of A. * For each pair of adjacents elements of B...
Solve the programming task below in a Python markdown code block. You are given two matrices $A$ and $B$. Each matrix contains exactly $n$ rows and $m$ columns. Each element of $A$ is either $0$ or $1$; each element of $B$ is initially $0$. You may perform some operations with matrix $B$. During each operation, you c...
Solve the programming task below in a Python markdown code block. Chef Shifu and Chef Po are participating in the Greatest Dumpling Fight of 2012. Of course, Masterchef Oogway has formed the rules of the fight. There is a long horizontal rope of infinite length with a center point P. Initially both Chef Shifu and Che...
Solve the programming task below in a Python markdown code block. Interest rates are attached to the money deposited in banks, and the calculation method and interest rates vary from bank to bank. The combination of interest and principal is called principal and interest, but as a method of calculating principal and i...
Solve the programming task below in a Python markdown code block. Ostap already settled down in Rio de Janiero suburb and started to grow a tree in his garden. Recall that a tree is a connected undirected acyclic graph. Ostap's tree now has n vertices. He wants to paint some vertices of the tree black such that from...
Solve the programming task below in a Python markdown code block. We have N balance beams numbered 1 to N. The length of each beam is 1 meters. Snuke walks on Beam i at a speed of 1/A_i meters per second, and Ringo walks on Beam i at a speed of 1/B_i meters per second. Snuke and Ringo will play the following game: *...
Solve the programming task below in a Python markdown code block. You are given a sequence a1, a2, ..., aN. Find the smallest possible value of ai + aj, where 1 ≤ i < j ≤ N. -----Input----- The first line of the input contains an integer T denoting the number of test cases. The description of T test cases follows. T...
Solve the programming task below in a Python markdown code block. Write a program of the Selection Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: SelectionSort(A) 1 for i = 0 to A.length-1 2 mini = i 3 for j = i to A.length-1 4 i...
Solve the programming task below in a Python markdown code block. # Explanation It's your first day in the robot factory and your supervisor thinks that you should start with an easy task. So you are responsible for purchasing raw materials needed to produce the robots. A complete robot weights `50` kilogram. Iron i...
Solve the programming task below in a Python markdown code block. Kicker (table football) is a board game based on football, in which players control the footballers' figures mounted on rods by using bars to get the ball into the opponent's goal. When playing two on two, one player of each team controls the goalkeeper...
Solve the programming task below in a Python markdown code block. Professor GukiZ is concerned about making his way to school, because massive piles of boxes are blocking his way. In total there are n piles of boxes, arranged in a line, from left to right, i-th pile (1 ≤ i ≤ n) containing ai boxes. Luckily, m studen...
Solve the programming task below in a Python markdown code block. Did you hear about the Nibiru collision ? It is a supposed disastrous encounter between the earth and a large planetary object. Astronomers reject this idea. But why listen to other people's beliefs and opinions. We are coders above all, so what better ...
Solve the programming task below in a Python markdown code block. Two little greedy bears have found two pieces of cheese in the forest of weight a and b grams, correspondingly. The bears are so greedy that they are ready to fight for the larger piece. That's where the fox comes in and starts the dialog: "Little bears...
Solve the programming task below in a Python markdown code block. We call a 4-digit integer with three or more consecutive same digits, such as 1118, good. You are given a 4-digit integer N. Answer the question: Is N good? -----Constraints----- - 1000 ≤ N ≤ 9999 - N is an integer. -----Input----- Input is given fr...
Solve the programming task below in a Python markdown code block. During the last Sereja's Codesecrof round the server crashed many times, so the round was decided to be made unrated for some participants. Let's assume that n people took part in the contest. Let's assume that the participant who got the first place ...
Solve the programming task below in a Python markdown code block. # Task Imagine `n` horizontal lines and `m` vertical lines. Some of these lines intersect, creating rectangles. How many rectangles are there? # Examples For `n=2, m=2,` the result should be `1`. there is only one 1x1 rectangle. For `n=2, m=3`, th...
Solve the programming task below in a Python markdown code block. Dawid has four bags of candies. The i-th of them contains a_i candies. Also, Dawid has two friends. He wants to give each bag to one of his two friends. Is it possible to distribute the bags in such a way that each friend receives the same amount of can...
Solve the programming task below in a Python markdown code block. Given are integers S and P. Is there a pair of positive integers (N,M) such that N + M = S and N \times M = P? -----Constraints----- - All values in input are integers. - 1 \leq S,P \leq 10^{12} -----Input----- Input is given from Standard Input in ...
Solve the programming task below in a Python markdown code block. Input The input contains two integers a1, a2 (0 ≤ ai ≤ 109), separated by a single space. Output Output a single integer. Examples Input 3 14 Output 44 Input 27 12 Output 48 Input 100 200 Output 102 Read the inputs from stdin solve...
Solve the programming task below in a Python markdown code block. For given a sequence $A = \\{a_0, a_1, ..., a_{n-1}\\}$, print the previous permutation and the next permutation in lexicographic order. Constraints * $1 \leq n \leq 9$ * $a_i$ consist of $1, 2, ..., n$ Input A sequence is given in the following for...
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. There are N empty boxes arranged in a row from left to right. The integer i is written on the i-th box from the left (1 \leq i \leq N). For each of these boxes, Snuke can choose either to put a ball in it or to put nothing in it. We say a set of choices...
Solve the programming task below in a Python markdown code block. Consider the infinite sequence s of positive integers, created by repeating the following steps: 1. Find the lexicographically smallest triple of positive integers (a, b, c) such that * a ⊕ b ⊕ c = 0, where ⊕ denotes the [bitwise XOR operation](...
Solve the programming task below in a Python markdown code block. Recently, the Fair Nut has written k strings of length n, consisting of letters "a" and "b". He calculated c — the number of strings that are prefixes of at least one of the written strings. Every string was counted only one time. Then, he lost his she...
Solve the programming task below in a Python markdown code block. Mr. Kitayuta has just bought an undirected graph consisting of n vertices and m edges. The vertices of the graph are numbered from 1 to n. Each edge, namely edge i, has a color c_{i}, connecting vertex a_{i} and b_{i}. Mr. Kitayuta wants you to process...
Solve the programming task below in a Python markdown code block. You are given a bracket sequence consisting of $n$ characters '(' and/or )'. You perform several operations with it. During one operation, you choose the shortest prefix of this string (some amount of first characters of the string) that is good and re...
Solve the programming task below in a Python markdown code block. Welcome! Everything is fine. You have arrived in The Medium Place, the place between The Good Place and The Bad Place. You are assigned a task that will either make people happier or torture them for eternity. You have a list of k pairs of people who ...
Solve the programming task below in a Python markdown code block. Dreamoon likes coloring cells very much. There is a row of $n$ cells. Initially, all cells are empty (don't contain any color). Cells are numbered from $1$ to $n$. You are given an integer $m$ and $m$ integers $l_1, l_2, \ldots, l_m$ ($1 \le l_i \le n...
Solve the programming task below in a Python markdown code block. ### Description: Remove all exclamation marks from sentence except at the end. ### Examples ``` remove("Hi!") == "Hi!" remove("Hi!!!") == "Hi!!!" remove("!Hi") == "Hi" remove("!Hi!") == "Hi!" remove("Hi! Hi!") == "Hi Hi!" remove("Hi") == "Hi" ``` R...
Solve the programming task below in a Python markdown code block. Given a string of characters, I want the function `findMiddle()`/`find_middle()` to return the middle number in the product of each digit in the string. Example: 's7d8jd9' -> 7, 8, 9 -> 7\*8\*9=504, thus 0 should be returned as an integer. Not all str...
Solve the programming task below in a Python markdown code block. You are the head of a large enterprise. $n$ people work at you, and $n$ is odd (i. e. $n$ is not divisible by $2$). You have to distribute salaries to your employees. Initially, you have $s$ dollars for it, and the $i$-th employee should get a salary f...
Solve the programming task below in a Python markdown code block. Valery is very interested in magic. Magic attracts him so much that he sees it everywhere. He explains any strange and weird phenomenon through intervention of supernatural forces. But who would have thought that even in a regular array of numbers Valer...
Solve the programming task below in a Python markdown code block. We had a string s consisting of n lowercase Latin letters. We made k copies of this string, thus obtaining k identical strings s_1, s_2, ..., s_{k}. After that, in each of these strings we swapped exactly two characters (the characters we swapped could ...
Solve the programming task below in a Python markdown code block. One day Anna got the following task at school: to arrange several numbers in a circle so that any two neighboring numbers differs exactly by 1. Anna was given several numbers and arranged them in a circle to fulfill the task. Then she wanted to check if...
Solve the programming task below in a Python markdown code block. Wilbur is playing with a set of n points on the coordinate plane. All points have non-negative integer coordinates. Moreover, if some point (x, y) belongs to the set, then all points (x', y'), such that 0 ≤ x' ≤ x and 0 ≤ y' ≤ y also belong to this set....