question
large_stringlengths
265
13.2k
Solve the programming task below in a Python markdown code block. Tax Rate Changed VAT (value-added tax) is a tax imposed at a certain rate proportional to the sale price. Our store uses the following rules to calculate the after-tax prices. * When the VAT rate is x%, for an item with the before-tax price of p yen,...
Solve the programming task below in a Python markdown code block. During the breaks between competitions, top-model Izabella tries to develop herself and not to be bored. For example, now she tries to solve Rubik's cube 2x2x2. It's too hard to learn to solve Rubik's cube instantly, so she learns to understand if it's...
Solve the programming task below in a Python markdown code block. Om Nom really likes candies and doesn't like spiders as they frequently steal candies. One day Om Nom fancied a walk in a park. Unfortunately, the park has some spiders and Om Nom doesn't want to see them at all. [Image] The park can be represented as...
Solve the programming task below in a Python markdown code block. You have recently discovered that horses travel in a unique pattern - they're either running (at top speed) or resting (standing still). Here's an example of how one particular horse might travel: ``` The horse Blaze can run at 14 metres/second for 60...
Solve the programming task below in a Python markdown code block. problem Given the sequence $ A $ of length $ N $. Find the maximum value of $ \ sum B_i $, where $ B $ is one of the longest increasing subsequences of the sequence $ A $. The longest increasing subsequence of the sequence $ A $ is the longest subsequ...
Solve the programming task below in a Python markdown code block. We have a set S of N points in a two-dimensional plane. The coordinates of the i-th point are (x_i, y_i). The N points have distinct x-coordinates and distinct y-coordinates. For a non-empty subset T of S, let f(T) be the number of points contained in t...
Solve the programming task below in a Python markdown code block. A bitstring is a string consisting only of the characters 0 and 1. A bitstring is called k-balanced if every substring of size k of this bitstring has an equal amount of 0 and 1 characters (k/2 of each). You are given an integer k and a string s which ...
Solve the programming task below in a Python markdown code block. Write a function that gets a sequence and value and returns `true/false` depending on whether the variable exists in a multidimentional sequence. Example: ``` locate(['a','b',['c','d',['e']]],'e'); // should return true locate(['a','b',['c','d',['e']]]...
Solve the programming task below in a Python markdown code block. Vanya and his friends are walking along the fence of height h and they do not want the guard to notice them. In order to achieve this the height of each of the friends should not exceed h. If the height of some person is greater than h he can bend down ...
Solve the programming task below in a Python markdown code block. Read problems statements in Mandarin Chinese and Russian. This is a very easy warm-up problem. You are given a string. Your task is to determine whether number of occurrences of some character in the string is equal to the sum of the numbers of occur...
Solve the programming task below in a Python markdown code block. The little girl loves the problems on array queries very much. One day she came across a rather well-known problem: you've got an array of n elements (the elements of the array are indexed starting from 1); also, there are q queries, each one is define...
Solve the programming task below in a Python markdown code block. We have a sequence of N integers: A_1, A_2, \cdots, A_N. You can perform the following operation between 0 and K times (inclusive): - Choose two integers i and j such that i \neq j, each between 1 and N (inclusive). Add 1 to A_i and -1 to A_j, possibly...
Solve the programming task below in a Python markdown code block. The prison of your city has n prisoners. As the prison can't accommodate all of them, the city mayor has decided to transfer c of the prisoners to a prison located in another city. For this reason, he made the n prisoners to stand in a line, with a num...
Solve the programming task below in a Python markdown code block. In "Takahashi-ya", a ramen restaurant, a bowl of ramen costs 700 yen (the currency of Japan), plus 100 yen for each kind of topping (boiled egg, sliced pork, green onions). A customer ordered a bowl of ramen and told which toppings to put on his ramen t...
Solve the programming task below in a Python markdown code block. I decided to plant vegetables in the vegetable garden. There were n seeds, so I sown n seeds one by one a day over n days. All seeds sprout and grow quickly. I can't wait for the harvest time. One day, when I was watering the seedlings as usual, I noti...
Solve the programming task below in a Python markdown code block. The main city magazine offers its readers an opportunity to publish their ads. The format of the ad should be like this: There are space-separated non-empty words of lowercase and uppercase Latin letters. There are hyphen characters '-' in some words,...
Solve the programming task below in a Python markdown code block. The task is simply stated. Given an integer n (3 < n < 10^(9)), find the length of the smallest list of [*perfect squares*](https://en.wikipedia.org/wiki/Square_number) which add up to n. Come up with the best algorithm you can; you'll need it! Example...
Solve the programming task below in a Python markdown code block. Dr .: Peter, do you know "Yes, I have a number"? Peter: I used to do it on TV the other day. You remember something by the number of characters in each word contained in a sentence. "Yes, I have a number", so it means "the number 3.14" and is a keyword...
Solve the programming task below in a Python markdown code block. 3D Printing We are designing an installation art piece consisting of a number of cubes with 3D printing technology for submitting one to Installation art Contest with Printed Cubes (ICPC). At this time, we are trying to model a piece consisting of exac...
Solve the programming task below in a Python markdown code block. Write a program which converts uppercase/lowercase letters to lowercase/uppercase for a given string. Constraints * The length of the input string < 1200 Input A string is given in a line. Output Print the converted string in a line. Note that you...
Solve the programming task below in a Python markdown code block. Create the function ```consecutive(arr)``` that takes an array of integers and return the minimum number of integers needed to make the contents of ```arr``` consecutive from the lowest number to the highest number. For example: If ```arr``` contains [...
Solve the programming task below in a Python markdown code block. The characters of Chima need your help. Their weapons got mixed up! They need you to write a program that accepts the name of a character in Chima then tells which weapon he/she owns. For example: for the character `"Laval"` your program should return ...
Solve the programming task below in a Python markdown code block. Vasya and Petya are playing a simple game. Vasya thought of number x between 1 and n, and Petya tries to guess the number. Petya can ask questions like: "Is the unknown number divisible by number y?". The game is played by the following rules: first P...
Solve the programming task below in a Python markdown code block. ### Task: Your job is to take a pair of parametric equations, passed in as strings, and convert them into a single rectangular equation by eliminating the parameter. Both parametric halves will represent linear equations of x as a function of time and ...
Solve the programming task below in a Python markdown code block. You are given a string of numbers between 0-9. Find the average of these numbers and return it as a floored whole number (ie: no decimal places) written out as a string. Eg: "zero nine five two" -> "four" If the string is empty or includes a number gr...
Solve the programming task below in a Python markdown code block. In this Kata, you will write a function `doubles` that will remove double string characters that are adjacent to each other. For example: `doubles('abbcccdddda') = 'aca'`, because, from left to right: ```Haskell a) There is only one 'a' on the left ha...
Solve the programming task below in a Python markdown code block. Bob loves everything sweet. His favorite chocolate bar consists of pieces, each piece may contain a nut. Bob wants to break the bar of chocolate into multiple pieces so that each part would contain exactly one nut and any break line goes between two adj...
Solve the programming task below in a Python markdown code block. Example Input 201 Output 701 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. The brothers Hiroshi and Kenjiro came to Lake Inawashiro for fishing. The two decided to score as follows and compete with the total score of the fish they caught. * One char is a point * One yamame trout b points * Add c points for every 10 chars * Ad...
Solve the programming task below in a Python markdown code block. Read problems statements in Mandarin Chinese and Russian Chef is sitting in a very boring lecture, waiting for it to end. He has recently asked his friend about the time, and instead of the straightforward answer, his friend, being an absolute jerk,...
Solve the programming task below in a Python markdown code block. Tokyo has a very complex railway system. For example, there exists a partial map of lines and stations as shown in Figure D-1. <image> Figure D-1: A sample railway network Suppose you are going to station D from station A. Obviously, the path with t...
Solve the programming task below in a Python markdown code block. The goal of this Kata is to remind/show you, how Z-algorithm works and test your implementation. For a string str[0..n-1], Z array is of same length as string. An element Z[i] of Z array stores length of the longest substring starting from str[i] which...
Solve the programming task below in a Python markdown code block. You are given an integer $n$. Check if $n$ has an odd divisor, greater than one (does there exist such a number $x$ ($x > 1$) that $n$ is divisible by $x$ and $x$ is odd). For example, if $n=6$, then there is $x=3$. If $n=4$, then such a number does no...
Solve the programming task below in a Python markdown code block. The sequence of n - 1 consecutive composite numbers (positive integers that are not prime and not equal to 1) lying between two successive prime numbers p and p + n is called a prime gap of length n. For example, (24, 25, 26, 27, 28) between 23 and 29 i...
Solve the programming task below in a Python markdown code block. Ilya is a very good-natured lion. He likes maths. Of all mathematical objects, his favourite one is matrices. Now he's faced a complicated matrix problem he needs to solve. He's got a square 2^{n} × 2^{n}-sized matrix and 4^{n} integers. You need to ar...
Solve the programming task below in a Python markdown code block. You have an n × m rectangle table, its cells are not initially painted. Your task is to paint all cells of the table. The resulting picture should be a tiling of the table with squares. More formally: each cell must be painted some color (the colors ar...
Solve the programming task below in a Python markdown code block. Mike wants to prepare for IMO but he doesn't know geometry, so his teacher gave him an interesting geometry problem. Let's define f([l, r]) = r - l + 1 to be the number of integer points in the segment [l, r] with l ≤ r (say that $f(\varnothing) = 0$). ...
Solve the programming task below in a Python markdown code block. Snuke has N sticks. The length of the i-th stick is l_i. Snuke is making a snake toy by joining K of the sticks together. The length of the toy is represented by the sum of the individual sticks that compose it. Find the maximum possible length of the t...
Solve the programming task below in a Python markdown code block. You are asked to watch your nephew who likes to play with toy blocks in a strange way. He has $n$ boxes and the $i$-th box has $a_i$ blocks. His game consists of two steps: he chooses an arbitrary box $i$; he tries to move all blocks from the $i$-th ...
Solve the programming task below in a Python markdown code block. You work as a system administrator in a dormitory, which has $n$ rooms one after another along a straight hallway. Rooms are numbered from $1$ to $n$. You have to connect all $n$ rooms to the Internet. You can connect each room to the Internet directl...
Solve the programming task below in a Python markdown code block. Takahashi is standing on a multiplication table with infinitely many rows and columns. The square (i,j) contains the integer i \times j. Initially, Takahashi is standing at (1,1). In one move, he can move from (i,j) to either (i+1,j) or (i,j+1). Given a...
Solve the programming task below in a Python markdown code block. Takahashi wants to be a member of some web service. He tried to register himself with the ID S, which turned out to be already used by another user. Thus, he decides to register using a string obtained by appending one character at the end of S as his I...
Solve the programming task below in a Python markdown code block. Little Petya likes points a lot. Recently his mom has presented him n points lying on the line OX. Now Petya is wondering in how many ways he can choose three distinct points so that the distance between the two farthest of them doesn't exceed d. Note ...
Solve the programming task below in a Python markdown code block. # Situation You have been hired by a company making electric garage doors. Accidents with the present product line have resulted in numerous damaged cars, broken limbs and several killed pets. Your mission is to write a safer version of their controller...
Solve the programming task below in a Python markdown code block. Bear Limak prepares problems for a programming competition. Of course, it would be unprofessional to mention the sponsor name in the statement. Limak takes it seriously and he is going to change some words. To make it still possible to read, he will try...
Solve the programming task below in a Python markdown code block. Write a function that returns the count of characters that have to be removed in order to get a string with no consecutive repeats. *Note:* This includes any characters ## Examples ```python 'abbbbc' => 'abc' # answer: 3 'abbcca' => 'abca' #...
Solve the programming task below in a Python markdown code block. Today Johnny wants to increase his contribution. His plan assumes writing $n$ blogs. One blog covers one topic, but one topic can be covered by many blogs. Moreover, some blogs have references to each other. Each pair of blogs that are connected by a re...
Solve the programming task below in a Python markdown code block. You have just been put in charge of developing a new shredder for the Shredding Company. Although a ``normal'' shredder would just shred sheets of paper into little pieces so that the contents would become unreadable, this new shredder needs to have the...
Solve the programming task below in a Python markdown code block. An SNS has N users - User 1, User 2, \cdots, User N. Between these N users, there are some relationships - M friendships and K blockships. For each i = 1, 2, \cdots, M, there is a bidirectional friendship between User A_i and User B_i. For each i = 1, 2...
Solve the programming task below in a Python markdown code block. Innopolis University scientists continue to investigate the periodic table. There are n·m known elements and they form a periodic table: a rectangle with n rows and m columns. Each element can be described by its coordinates (r, c) (1 ≤ r ≤ n, 1 ≤ c ≤ m...
Solve the programming task below in a Python markdown code block. Vasya owns a cornfield which can be defined with two integers $n$ and $d$. The cornfield can be represented as rectangle with vertices having Cartesian coordinates $(0, d), (d, 0), (n, n - d)$ and $(n - d, n)$. [Image] An example of a cornfield with $...
Solve the programming task below in a Python markdown code block. Pooja would like to withdraw X US from an ATM. The cash machine will only accept the transaction if X is a multiple of 5, and Pooja's account balance has enough cash to perform the withdrawal transaction (including bank charges). For each successful wi...
Solve the programming task below in a Python markdown code block. Since Sonya has just learned the basics of matrices, she decided to play with them a little bit. Sonya imagined a new type of matrices that she called rhombic matrices. These matrices have exactly one zero, while all other cells have the Manhattan dist...
Solve the programming task below in a Python markdown code block. Vasya has n days of vacations! So he decided to improve his IT skills and do sport. Vasya knows the following information about each of this n days: whether that gym opened and whether a contest was carried out in the Internet on that day. For the i-th ...
Solve the programming task below in a Python markdown code block. Snuke prepared 6 problems for a upcoming programming contest. For each of those problems, Rng judged whether it can be used in the contest or not. You are given a string S of length 6. If the i-th character of s is `1`, it means that the i-th problem p...
Solve the programming task below in a Python markdown code block. You are given <var>Q</var> tuples of integers <var>(L_i, A_i, B_i, M_i)</var>. For each tuple, answer the following question. There is an arithmetic progression with L terms: s_0, s_1, s_2, ... , s_{L-1}. The initial term is A, and the common differenc...
Solve the programming task below in a Python markdown code block. Allen wants to enter a fan zone that occupies a round square and has $n$ entrances. There already is a queue of $a_i$ people in front of the $i$-th entrance. Each entrance allows one person from its queue to enter the fan zone in one minute. Allen use...
Solve the programming task below in a Python markdown code block. Let's define a multiplication operation between a string $a$ and a positive integer $x$: $a \cdot x$ is the string that is a result of writing $x$ copies of $a$ one after another. For example, "abc" $\cdot~2~=$ "abcabc", "a" $\cdot~5~=$ "aaaaa". A stri...
Solve the programming task below in a Python markdown code block. You are given a sequence $s$ consisting of $n$ digits from $1$ to $9$. You have to divide it into at least two segments (segment — is a consecutive sequence of elements) (in other words, you have to place separators between some digits of the sequence)...
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. Consider a billiard table of rectangular size $n \times m$ with four pockets. Let's introduce a coordinate system with the origin at the lower left corner (see the picture). [Image] There is one ball at the point $(x, y)$ currently. Max comes to the ...
Solve the programming task below in a Python markdown code block. Valera is a collector. Once he wanted to expand his collection with exactly one antique item. Valera knows n sellers of antiques, the i-th of them auctioned k_{i} items. Currently the auction price of the j-th object of the i-th seller is s_{ij}. Valer...
Solve the programming task below in a Python markdown code block. You are given a Young diagram. Given diagram is a histogram with $n$ columns of lengths $a_1, a_2, \ldots, a_n$ ($a_1 \geq a_2 \geq \ldots \geq a_n \geq 1$). [Image] Young diagram for $a=[3,2,2,2,1]$. Your goal is to find the largest number of non-o...
Solve the programming task below in a Python markdown code block. Write a function that will encrypt a given sentence into International Morse Code, both the input and out puts will be strings. Characters should be separated by a single space. Words should be separated by a triple space. For example, "HELLO WORLD" s...
Solve the programming task below in a Python markdown code block. Let's introduce a number system which is based on a roman digits. There are digits I, V, X, L which correspond to the numbers 1, 5, 10 and 50 respectively. The use of other roman digits is not allowed. Numbers in this system are written as a sequence o...
Solve the programming task below in a Python markdown code block. The internet is a very confounding place for some adults. Tom has just joined an online forum and is trying to fit in with all the teens and tweens. It seems like they're speaking in another language! Help Tom fit in by translating his well-formatted En...
Solve the programming task below in a Python markdown code block. A and B are preparing themselves for programming contests. B loves to debug his code. But before he runs the solution and starts debugging, he has to first compile the code. Initially, the compiler displayed n compilation errors, each of them is repre...
Solve the programming task below in a Python markdown code block. A high school has a strange principal. On the first day, he has his students perform an odd opening day ceremony: There are number of lockers "n" and number of students "n" in the school. The principal asks the first student to go to every locker and o...
Solve the programming task below in a Python markdown code block. Polycarp found a rectangular table consisting of $n$ rows and $m$ columns. He noticed that each cell of the table has its number, obtained by the following algorithm "by columns": cells are numbered starting from one; cells are numbered from left to r...
Solve the programming task below in a Python markdown code block. A tree is an undirected connected graph without cycles. You are given a tree of n vertices. Find the number of ways to choose exactly k vertices in this tree (i. e. a k-element subset of vertices) so that all pairwise distances between the selected ver...
Solve the programming task below in a Python markdown code block. Nikolay has a lemons, b apples and c pears. He decided to cook a compote. According to the recipe the fruits should be in the ratio 1: 2: 4. It means that for each lemon in the compote should be exactly 2 apples and exactly 4 pears. You can't crumble up...
Solve the programming task below in a Python markdown code block. Ziota found a video game called "Monster Invaders". Similar to every other shooting RPG game, "Monster Invaders" involves killing monsters and bosses with guns. For the sake of simplicity, we only consider two different types of monsters and three dif...
Solve the programming task below in a Python markdown code block. You are given a bracket sequence $s$ consisting of $n$ opening '(' and closing ')' brackets. A regular bracket sequence is a bracket sequence that can be transformed into a correct arithmetic expression by inserting characters '1' and '+' between the o...
Solve the programming task below in a Python markdown code block. As you might remember from the previous round, Vova is currently playing a strategic game known as Rage of Empires. Vova managed to build a large army, but forgot about the main person in the army - the commander. So he tries to hire a commander, and h...
Solve the programming task below in a Python markdown code block. You are given a permutation p of length n. Remove one element from permutation to make the number of records the maximum possible. We remind that in a sequence of numbers a_1, a_2, ..., a_{k} the element a_{i} is a record if for every integer j (1 ≤ j ...
Solve the programming task below in a Python markdown code block. Alice has a birthday today, so she invited home her best friend Bob. Now Bob needs to find a way to commute to the Alice's home. In the city in which Alice and Bob live, the first metro line is being built. This metro line contains $n$ stations numbere...
Solve the programming task below in a Python markdown code block. Little Elephant loves magic squares very much. A magic square is a 3 × 3 table, each cell contains some positive integer. At that the sums of integers in all rows, columns and diagonals of the table are equal. The figure below shows the magic square, t...
Solve the programming task below in a Python markdown code block. problem There are fine icicles under the eaves of JOI's house in Canada. Because of this, JOI decided to investigate the icicles. There are N (2 ≤ N ≤ 100000 = 105) icicles under the eaves of JOI's house. These icicles are aligned and i cm (1 ≤ i ≤ N)...
Solve the programming task below in a Python markdown code block. Third day at your new cryptoanalyst job and you come across your toughest assignment yet. Your job is to implement a simple keyword cipher. A keyword cipher is a type of monoalphabetic substitution where two parameters are provided as such (string, keyw...
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. Jabber ID on the national Berland service «Babber» has a form <username>@<hostname>[/resource], where * <username> — is a sequence of Latin letters (lowercase or uppercase), digits or underscores characters «_», the length of <username> is between 1...
Solve the programming task below in a Python markdown code block. There is an airplane which has n rows from front to back. There will be m people boarding this airplane. This airplane has an entrance at the very front and very back of the plane. Each person has some assigned seat. It is possible for multiple people...
Solve the programming task below in a Python markdown code block. A boy named Vasya has taken part in an Olympiad. His teacher knows that in total Vasya got at least x points for both tours of the Olympiad. The teacher has the results of the first and the second tour of the Olympiad but the problem is, the results hav...
Solve the programming task below in a Python markdown code block. Oh, New Year. The time to gather all your friends and reflect on the heartwarming events of the past year... $n$ friends live in a city which can be represented as a number line. The $i$-th friend lives in a house with an integer coordinate $x_i$. The ...
Solve the programming task below in a Python markdown code block. # Rock Paper Scissors Let's play! You have to return which player won! In case of a draw return `Draw!`. Examples: ![rockpaperscissors](http://i.imgur.com/aimOQVX.png) Read the inputs from stdin solve the problem and write the answer to stdout (do n...
Solve the programming task below in a Python markdown code block. Vasya has a non-negative integer n. He wants to round it to nearest integer, which ends up with 0. If n already ends up with 0, Vasya considers it already rounded. For example, if n = 4722 answer is 4720. If n = 5 Vasya can round it to 0 or to 10. Both...
Solve the programming task below in a Python markdown code block. Notes Template in C Constraints * 1 ≤ n ≤ 100000 * 1 ≤ q ≤ 1000 * 1 ≤ timei ≤ 50000 * 1 ≤ length of namei ≤ 10 * 1 ≤ Sum of timei ≤ 1000000 Input n q name1 time1 name2 time2 ... namen timen In the first line the number of processes n and the quan...
Solve the programming task below in a Python markdown code block. Given a string (`str`) containing a base-10 integer between `0` and `10000`, convert the integer to its binary representation. At that point, obtain a count of the maximum amount of consecutive 0s. From there, return the count in written form with a cap...
Solve the programming task below in a Python markdown code block. N problems have been chosen by the judges, now it's time to assign scores to them! Problem i must get an integer score A_i between 1 and N, inclusive. The problems have already been sorted by difficulty: A_1 \le A_2 \le \ldots \le A_N must hold. Differ...
Solve the programming task below in a Python markdown code block. You are given a text that consists of lowercase Latin letters, spaces and punctuation marks (dot, comma, exclamation mark and question mark). A word is defined as a sequence of consecutive Latin letters. Your task is to add spaces to the text by the fo...
Solve the programming task below in a Python markdown code block. Snuke has a rooted tree with N+1 vertices. The vertices are numbered 0 through N, and Vertex 0 is the root of the tree. The parent of Vertex i (1 \leq i \leq N) is Vertex p_i. Besides this tree, Snuke also has an box which is initially empty and many ma...
Solve the programming task below in a Python markdown code block. Vasya plays the Geometry Horse. The game goal is to destroy geometric figures of the game world. A certain number of points is given for destroying each figure depending on the figure type and the current factor value. There are n types of geometric ...
Solve the programming task below in a Python markdown code block. You are planning to buy an apartment in a $n$-floor building. The floors are numbered from $1$ to $n$ from the bottom to the top. At first for each floor you want to know the minimum total time to reach it from the first (the bottom) floor. Let: $a_i$...
Solve the programming task below in a Python markdown code block. How many ways are there to choose two distinct positive integers totaling N, disregarding the order? Constraints * 1 \leq N \leq 10^6 * N is an integer. Input Input is given from Standard Input in the following format: N Output Print the answer...
Solve the programming task below in a Python markdown code block. You are given a string $s$ of 0's and 1's. You are allowed to perform the following operation: choose a non-empty contiguous substring of $s$ that contains an equal number of 0's and 1's; flip all characters in the substring, that is, replace all 0's ...
Solve the programming task below in a Python markdown code block. Two players are playing a game. First each of them writes an integer from 1 to 6, and then a dice is thrown. The player whose written number got closer to the number on the dice wins. If both payers have the same difference, it's a draw. The first play...
Solve the programming task below in a Python markdown code block. Vasya tries to break in a safe. He knows that a code consists of n numbers, and every number is a 0 or a 1. Vasya has made m attempts to enter the code. After each attempt the system told him in how many position stand the right numbers. It is not said ...
Solve the programming task below in a Python markdown code block. # Two samurai generals are discussing dinner plans after a battle, but they can't seem to agree. The discussion gets heated and you are cannot risk favoring either of them as this might damage your political standing with either of the two clans the sa...
Solve the programming task below in a Python markdown code block. You are given an array $a_1, a_2, \dots, a_n$ and an integer $k$. You are asked to divide this array into $k$ non-empty consecutive subarrays. Every element in the array should be included in exactly one subarray. Let $f(i)$ be the index of subarray th...
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)$, $\frac{a}{gcd(a,b)}$, $\frac{b}{gcd(a,b)}$ can form sides ...