question
large_stringlengths
265
13.2k
Solve the programming task below in a Python markdown code block. Snark and Philip are preparing the problemset for the upcoming pre-qualification round for semi-quarter-finals. They have a bank of n problems, and they want to select any non-empty subset of it as a problemset. k experienced teams are participating in...
Solve the programming task below in a Python markdown code block. Write a program which reads a sequence A of n elements and an integer M, and outputs "yes" if you can make M by adding elements in A, otherwise "no". You can use an element only once. You are given the sequence A and q questions where each question con...
Solve the programming task below in a Python markdown code block. Casimir has a rectangular piece of paper with a checkered field of size $n \times m$. Initially, all cells of the field are white. Let us denote the cell with coordinates $i$ vertically and $j$ horizontally by $(i, j)$. The upper left cell will be refe...
Solve the programming task below in a Python markdown code block. Gildong is playing with his dog, Badugi. They're at a park that has $n$ intersections and $n-1$ bidirectional roads, each $1$ meter in length and connecting two intersections with each other. The intersections are numbered from $1$ to $n$, and for every...
Solve the programming task below in a Python markdown code block. We have a directed weighted graph with N vertices. Each vertex has two integers written on it, and the integers written on Vertex i are A_i and B_i. In this graph, there is an edge from Vertex x to Vertex y for all pairs 1 \leq x,y \leq N, and its weig...
Solve the programming task below in a Python markdown code block. A bracket sequence is called regular if it is possible to obtain correct arithmetic expression by inserting characters + and 1 into this sequence. For example, sequences (())(), () and (()(())) are regular, while )(, (() and (()))( are not. Let's call a...
Solve the programming task below in a Python markdown code block. # Task You are given a `moment` in time and space. What you must do is break it down into time and space, to determine if that moment is from the past, present or future. `Time` is the sum of characters that increase time (i.e. numbers in range ['1'....
Solve the programming task below in a Python markdown code block. A witch named Marie lived deep in a remote forest. Since she is a witch, she magically covers everything she needs to live, such as food, water, and fuel. Her magic is activated by drawing a magic circle using some magical stones and strings. This magi...
Solve the programming task below in a Python markdown code block. Spin-off of this kata, here you will have to figure out an efficient strategy to solve the problem of finding the sole duplicate number among an unsorted array/list of numbers starting from 1 up to n. Hints: a solution in linear time can be found; usin...
Solve the programming task below in a Python markdown code block. You are given the strings $a$ and $b$, consisting of lowercase Latin letters. You can do any number of the following operations in any order: if $|a| > 0$ (the length of the string $a$ is greater than zero), delete the first character of the string $a$...
Solve the programming task below in a Python markdown code block. A flower shop has got n bouquets, and the i-th bouquet consists of a_{i} flowers. Vasya, the manager of the shop, decided to make large bouquets from these bouquets. Vasya thinks that a bouquet is large if it is made of two or more initial bouquets, a...
Solve the programming task below in a Python markdown code block. Heidi's friend Jenny is asking Heidi to deliver an important letter to one of their common friends. Since Jenny is Irish, Heidi thinks that this might be a prank. More precisely, she suspects that the message she is asked to deliver states: "Send the fo...
Solve the programming task below in a Python markdown code block. Alice likes snow a lot! Unfortunately, this year's winter is already over, and she can't expect to have any more of it. Bob has thus bought her a giftΒ β€” a large snow maker. He plans to make some amount of snow every day. On day i he will make a pile of ...
Solve the programming task below in a Python markdown code block. ### Tongues Gandalf's writings have long been available for study, but no one has yet figured out what language they are written in. Recently, due to programming work by a hacker known only by the code name ROT13, it has been discovered that Gandalf us...
Solve the programming task below in a Python markdown code block. Snuke has N strings. The i-th string is s_i. Let us concatenate these strings into one string after arranging them in some order. Find the maximum possible number of occurrences of `AB` in the resulting string. Constraints * 1 \leq N \leq 10^{4} * 2 ...
Solve the programming task below in a Python markdown code block. Given an input string s, reverse the order of the words. A word is defined as a sequence of non-space characters. The words in s will be separated by at least one space. Return a string of the words in reverse order concatenated by a single space. No...
Solve the programming task below in a Python markdown code block. Write a function called calculate that takes 3 values. The first and third values are numbers. The second value is a character. If the character is "+" , "-", "*", or "/", the function will return the result of the corresponding mathematical function on...
Solve the programming task below in a Python markdown code block. Every evening Vitalya sets n alarm clocks to wake up tomorrow. Every alarm clock rings during exactly one minute and is characterized by one integer a_{i}Β β€” number of minute after midnight in which it rings. Every alarm clock begins ringing at the begin...
Solve the programming task below in a Python markdown code block. Ujan decided to make a new wooden roof for the house. He has $n$ rectangular planks numbered from $1$ to $n$. The $i$-th plank has size $a_i \times 1$ (that is, the width is $1$ and the height is $a_i$). Now, Ujan wants to make a square roof. He will f...
Solve the programming task below in a Python markdown code block. "Duel!" Betting on the lovely princess Claris, the duel between Tokitsukaze and Quailty has started. There are $n$ cards in a row. Each card has two sides, one of which has color. At first, some of these cards are with color sides facing up and others...
Solve the programming task below in a Python markdown code block. This time Baby Ehab will only cut and not stick. He starts with a piece of paper with an array a of length n written on it, and then he does the following: * he picks a range (l, r) and cuts the subsegment a_l, a_{l + 1}, …, a_r out, removing the res...
Solve the programming task below in a Python markdown code block. Your friend has n cards. You know that each card has a lowercase English letter on one side and a digit on the other. Currently, your friend has laid out the cards on a table so only one side of each card is visible. You would like to know if the fol...
Solve the programming task below in a Python markdown code block. You received a whatsup message from an unknown number. Could it be from that girl/boy with a foreign accent you met yesterday evening? Write a simple regex to check if the string contains the word hallo in different languages. These are the languages ...
Solve the programming task below in a Python markdown code block. A few years ago Sajjad left his school and register to another one due to security reasons. Now he wishes to find Amir, one of his schoolmates and good friends. There are n schools numerated from 1 to n. One can travel between each pair of them, to do ...
Solve the programming task below in a Python markdown code block. This is a harder version of the problem. In this version $n \le 500\,000$ The outskirts of the capital are being actively built up in Berland. The company "Kernel Panic" manages the construction of a residential complex of skyscrapers in New Berlskva. ...
Solve the programming task below in a Python markdown code block. # Number encrypting: cypher ## Part I of Number encrypting Katas *** ## Introduction Back then when the internet was coming up, most search functionalities simply looked for keywords in text to show relevant documents. Hackers weren't very keen on havi...
Solve the programming task below in a Python markdown code block. Santa has $n$ candies and he wants to gift them to $k$ kids. He wants to divide as many candies as possible between all $k$ kids. Santa can't divide one candy into parts but he is allowed to not use some candies at all. Suppose the kid who recieves the...
Solve the programming task below in a Python markdown code block. A Ministry for Defense sent a general to inspect the Super Secret Military Squad under the command of the Colonel SuperDuper. Having learned the news, the colonel ordered to all n squad soldiers to line up on the parade ground. By the military charter ...
Solve the programming task below in a Python markdown code block. At first, let's define function $f(x)$ as follows: $$ \begin{matrix} f(x) & = & \left\{ \begin{matrix} \frac{x}{2} & \mbox{if } x \text{ is even} \\ x - 1 & \mbox{otherwise } \end{matrix} \right. \end{matrix} $$ We can see that if we choose some value ...
Solve the programming task below in a Python markdown code block. -----Input----- The input consists of a single string of uppercase letters A-Z. The length of the string is between 1 and 10 characters, inclusive. -----Output----- Output "YES" or "NO". -----Examples----- Input NEAT Output YES Input WORD Outpu...
Solve the programming task below in a Python markdown code block. There is one apple tree in Arkady's garden. It can be represented as a set of junctions connected with branches so that there is only one way to reach any junctions from any other one using branches. The junctions are enumerated from $1$ to $n$, the jun...
Solve the programming task below in a Python markdown code block. When provided with a String, capitalize all vowels For example: Input : "Hello World!" Output : "HEllO WOrld!" Note: Y is not a vowel in this kata. Write your solution by modifying this code: ```python def swap(st): ``` Your solution should imp...
Solve the programming task below in a Python markdown code block. Once Max found an electronic calculator from his grandfather Dovlet's chest. He noticed that the numbers were written with seven-segment indicators (https://en.wikipedia.org/wiki/Seven-segment_display). [Image] Max starts to type all the values from a...
Solve the programming task below in a Python markdown code block. Gray code is a form of binary encoding where transitions between consecutive numbers differ by only one bit. This is a useful encoding for reducing hardware data hazards with values that change rapidly and/or connect to slower hardware as inputs. It is ...
Solve the programming task below in a Python markdown code block. Mutual Recursion allows us to take the fun of regular recursion (where a function calls itself until a terminating condition) and apply it to multiple functions calling each other! Let's use the Hofstadter Female and Male sequences to demonstrate this...
Solve the programming task below in a Python markdown code block. Create a method `sayHello`/`say_hello`/`SayHello` that takes as input a name, city, and state to welcome a person. Note that `name` will be an array consisting of one or more values that should be joined together with one space between each, and the len...
Solve the programming task below in a Python markdown code block. Hamed has recently found a string t and suddenly became quite fond of it. He spent several days trying to find all occurrences of t in other strings he had. Finally he became tired and started thinking about the following problem. Given a string s how m...
Solve the programming task below in a Python markdown code block. Recall that the bracket sequence is considered regular if it is possible to insert symbols '+' and '1' into it so that the result is a correct arithmetic expression. For example, a sequence "(()())" is regular, because we can get correct arithmetic expr...
Solve the programming task below in a Python markdown code block. Nuske has a grid with N rows and M columns of squares. The rows are numbered 1 through N from top to bottom, and the columns are numbered 1 through M from left to right. Each square in the grid is painted in either blue or white. If S_{i,j} is 1, the sq...
Solve the programming task below in a Python markdown code block. The Binomial Form of a polynomial has many uses, just as the standard form does. For comparison, if p(x) is in Binomial Form and q(x) is in standard form, we might write p(x) := a0 \* xC0 + a1 \* xC1 + a2 \* xC2 + ... + aN \* xCN q(x) := b0 + b1 \* x...
Solve the programming task below in a Python markdown code block. For a positive integer X, let f(X) be the number of positive divisors of X. Given a positive integer N, find \sum_{K=1}^N K\times f(K). -----Constraints----- - 1 \leq N \leq 10^7 -----Input----- Input is given from Standard Input in the following for...
Solve the programming task below in a Python markdown code block. Vasya wrote down two strings s of length n and t of length m consisting of small English letters 'a' and 'b'. What is more, he knows that string t has a form "abab...", namely there are letters 'a' on odd positions and letters 'b' on even positions. Su...
Solve the programming task below in a Python markdown code block. Three numbers A, B and C are the inputs. Write a program to find second largest among them. -----Input----- The first line contains an integer T, the total number of testcases. Then T lines follow, each line contains three integers A, B and C. -----...
Solve the programming task below in a Python markdown code block. A family consisting of father bear, mother bear and son bear owns three cars. Father bear can climb into the largest car and he likes it. Also, mother bear can climb into the middle car and she likes it. Moreover, son bear can climb into the smallest ca...
Solve the programming task below in a Python markdown code block. The image shows how we can obtain the Harmonic Conjugated Point of three aligned points A, B, C. - We choose any point L, that is not in the line with A, B and C. We form the triangle ABL - Then we draw a line from point C that intersects the sides of...
Solve the programming task below in a Python markdown code block. Efim just received his grade for the last test. He studies in a special school and his grade can be equal to any positive decimal fraction. First he got disappointed, as he expected a way more pleasant result. Then, he developed a tricky plan. Each seco...
Solve the programming task below in a Python markdown code block. ###Task: You have to write a function **pattern** which creates the following Pattern(See Examples) upto n(parameter) number of rows. ####Rules/Note: * If the Argument is 0 or a Negative Integer then it should return "" i.e. empty string. * All the li...
Solve the programming task below in a Python markdown code block. Princess'Marriage Marriage of a princess English text is not available in this practice contest. A brave princess in a poor country, knowing that gambling payouts are determined by the parimutuel method, felt more familiar with gambling and was convi...
Solve the programming task below in a Python markdown code block. You are given strings s and t. Find one longest string that is a subsequence of both s and t. Constraints * s and t are strings consisting of lowercase English letters. * 1 \leq |s|, |t| \leq 3000 Input Input is given from Standard Input in the foll...
Solve the programming task below in a Python markdown code block. You are a *khm*mad*khm* scientist and you decided to play with electron distribution among atom's shells. You know that basic idea of electron distribution is that electrons should fill a shell untill it's holding the maximum number of electrons. --...
Solve the programming task below in a Python markdown code block. IT City company developing computer games invented a new way to reward its employees. After a new game release users start buying it actively, and the company tracks the number of sales with precision to each transaction. Every time when the next number...
Solve the programming task below in a Python markdown code block. Let {\rm comb}(n,r) be the number of ways to choose r objects from among n objects, disregarding order. From n non-negative integers a_1, a_2, ..., a_n, select two numbers a_i > a_j so that {\rm comb}(a_i,a_j) is maximized. If there are multiple pairs t...
Solve the programming task below in a Python markdown code block. Mike has a string s consisting of only lowercase English letters. He wants to change exactly one character from the string so that the resulting one is a palindrome. A palindrome is a string that reads the same backward as forward, for example strings...
Solve the programming task below in a Python markdown code block. When you play the game of thrones, you win, or you die. There is no middle ground. Cersei Lannister, A Game of Thrones by George R. R. Martin There are $n$ nobles, numbered from $1$ to $n$. Noble $i$ has a power of $i$. There are also $m$ "friendships...
Solve the programming task below in a Python markdown code block. You are given a sequence $a_1, a_2, \dots, a_n$ consisting of $n$ integers. You can choose any non-negative integer $D$ (i.e. $D \ge 0$), and for each $a_i$ you can: add $D$ (only once), i. e. perform $a_i := a_i + D$, or subtract $D$ (only once), ...
Solve the programming task below in a Python markdown code block. Read problems statements in Mandarin Chinese , Russian and Vietnamese as well. You are given a uniformly randomly generated string S, consisting of letters from the set {"A", "B"}. Your task is to find a string T that appears in S as a subsequence exa...
Solve the programming task below in a Python markdown code block. Polycarp takes part in a quadcopter competition. According to the rules a flying robot should: start the race from some point of a field, go around the flag, close cycle returning back to the starting point. Polycarp knows the coordinates of the ...
Solve the programming task below in a Python markdown code block. Woken up by the alarm clock Igor the financial analyst hurried up to the work. He ate his breakfast and sat in his car. Sadly, when he opened his GPS navigator, he found that some of the roads in Bankopolis, the city where he lives, are closed due to ro...
Solve the programming task below in a Python markdown code block. Tomash keeps wandering off and getting lost while he is walking along the streets of Berland. It's no surprise! In his home town, for any pair of intersections there is exactly one way to walk from one intersection to the other one. The capital of Berla...
Solve the programming task below in a Python markdown code block. Simple, given a string of words, return the length of the shortest word(s). String will never be empty and you do not need to account for different data types. Write your solution by modifying this code: ```python def find_short(s): ``` Your solut...
Solve the programming task below in a Python markdown code block. Katie, Kuro and Shiro are best friends. They have known each other since kindergarten. That's why they often share everything with each other and work together on some very hard problems. Today is Shiro's birthday. She really loves pizza so she wants t...
Solve the programming task below in a Python markdown code block. As you might know, cooking is the process of taking a food item and subjecting it to various processes(like heating, roasting, baking etc). A food item gets prepared after it has been subjected to exactly N processes. The order in which the processes ar...
Solve the programming task below in a Python markdown code block. Dr. Moriarty is about to send a message to Sherlock Holmes. He has a string s. String p is called a substring of string s if you can read it starting from some position in the string s. For example, string "aba" has six substrings: "a", "b", "a", "ab"...
Solve the programming task below in a Python markdown code block. Calculate the number of items in a vector that appear at the same index in each vector, with the same value. ```python vector_affinity([1, 2, 3, 4, 5], [1, 2, 2, 4, 3]) # => 0.6 vector_affinity([1, 2, 3], [1, 2, 3]) # => 1.0 ``` Affinity value ...
Solve the programming task below in a Python markdown code block. In order to put away old things and welcome a fresh new year, a thorough cleaning of the house is a must. Little Tommy finds an old polynomial and cleaned it up by taking it modulo another. But now he regrets doing this... Given two integers p and k, ...
Solve the programming task below in a Python markdown code block. Stick n circular stickers with a radius of 1 on a square origami paper with a side length of 10. The stickers can be stacked. Create a program that reads the coordinates of the position where the stickers are to be attached and outputs the number of sti...
Solve the programming task below in a Python markdown code block. Recently, Anton has found a set. The set consists of small English letters. Anton carefully wrote out all the letters from the set in one line, separated by a comma. He also added an opening curved bracket at the beginning of the line and a closing curv...
Solve the programming task below in a Python markdown code block. There are N dishes, numbered 1, 2, \ldots, N. Initially, for each i (1 \leq i \leq N), Dish i has a_i (1 \leq a_i \leq 3) pieces of sushi on it. Taro will perform the following operation repeatedly until all the pieces of sushi are eaten: * Roll a die...
Solve the programming task below in a Python markdown code block. Valera the horse lives on a plane. The Cartesian coordinate system is defined on this plane. Also an infinite spiral is painted on the plane. The spiral consists of segments: [(0, 0), (1, 0)], [(1, 0), (1, 1)], [(1, 1), ( - 1, 1)], [( - 1, 1), ( - 1, -...
Solve the programming task below in a Python markdown code block. In this Kata, you will implement a function `count` that takes an integer and returns the number of digits in `factorial(n)`. For example, `count(5) = 3`, because `5! = 120`, and `120` has `3` digits. More examples in the test cases. Brute force ...
Solve the programming task below in a Python markdown code block. In computer science, cycle detection is the algorithmic problem of finding a cycle in a sequence of iterated function values. For any function Ζ’, and any initial value x0 in S, the sequence of iterated function values x0,x1=f(x0), x2=f(x1), ...,xi...
Solve the programming task below in a Python markdown code block. Create a program to determine the positional relationship between a triangle and a circle on a plane. All target figures shall include boundaries. The triangle is given the position of three vertices, and the circle is given the position of the center a...
Solve the programming task below in a Python markdown code block. I always thought that my old friend John was rather richer than he looked, but I never knew exactly how much money he actually had. One day (as I was plying him with questions) he said: * "Imagine I have between `m` and `n` Zloty..." (or did he say Que...
Solve the programming task below in a Python markdown code block. Polycarp is an organizer of a Berland ICPC regional event. There are $n$ universities in Berland numbered from $1$ to $n$. Polycarp knows all competitive programmers in the region. There are $n$ students: the $i$-th student is enrolled at a university $...
Solve the programming task below in a Python markdown code block. Berland annual chess tournament is coming! Organizers have gathered 2Β·n chess players who should be divided into two teams with n people each. The first team is sponsored by BerOil and the second team is sponsored by BerMobile. Obviously, organizers sh...
Solve the programming task below in a Python markdown code block. The mobile application store has a new game called "Subway Roller". The protagonist of the game Philip is located in one end of the tunnel and wants to get out of the other one. The tunnel is a rectangular field consisting of three rows and n columns. ...
Solve the programming task below in a Python markdown code block. You are given names of two days of the week. Please, determine whether it is possible that during some non-leap year the first day of some month was equal to the first day of the week you are given, while the first day of the next month was equal to th...
Solve the programming task below in a Python markdown code block. Mr. A came to Aizu for sightseeing. You can overlook the Aizu Basin from the window of the hotel where you stayed. As I was looking at the scenery, I noticed a piece of the photo on the floor. Apparently I took the outside view from the window. "Which a...
Solve the programming task below in a Python markdown code block. Brave Ponta has finally arrived at the final dungeon. This is a dark wilderness in front of the fort of the evil emperor Boromos, with fairly strong monsters guarding their territories. <image> Figure 1: Wilderness As shown in Fig. 1, the wilderness...
Solve the programming task below in a Python markdown code block. Valera has array a, consisting of n integers a_0, a_1, ..., a_{n} - 1, and function f(x), taking an integer from 0 to 2^{n} - 1 as its single argument. Value f(x) is calculated by formula $f(x) = \sum_{i = 0}^{n - 1} a_{i} \cdot b i t(i)$, where value b...
Solve the programming task below in a Python markdown code block. Uh oh, Someone at the office has dropped all these sequences on the floor and forgotten to label them with their correct bases. We have to fix this before the boss gets back or we're all going to be fired! This is what your years of coding have been ...
Solve the programming task below in a Python markdown code block. We arrange the numbers between 1 and N (1 <= N <= 10000) in increasing order and decreasing order like this: 1 2 3 4 5 6 7 8 9 . . . N N . . . 9 8 7 6 5 4 3 2 1 Two numbers faced each other form a pair. Your task is to compute the number of pairs P ...
Solve the programming task below in a Python markdown code block. Given is a string S representing the day of the week today. S is SUN, MON, TUE, WED, THU, FRI, or SAT, for Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, and Saturday, respectively. After how many days is the next Sunday (tomorrow or later)? ---...
Solve the programming task below in a Python markdown code block. Given is a positive integer N. How many tuples (A,B,C) of positive integers satisfy A \times B + C = N? -----Constraints----- - 2 \leq N \leq 10^6 - All values in input are integers. -----Input----- Input is given from Standard Input in the followi...
Solve the programming task below in a Python markdown code block. Polycarp loves lowercase letters and dislikes uppercase ones. Once he got a string s consisting only of lowercase and uppercase Latin letters. Let A be a set of positions in the string. Let's call it pretty if following conditions are met: letters on ...
Solve the programming task below in a Python markdown code block. You are given two arrays $a$ and $b$, each consisting of $n$ positive integers, and an integer $x$. Please determine if one can rearrange the elements of $b$ so that $a_i + b_i \leq x$ holds for each $i$ ($1 \le i \le n$). -----Input----- The first l...
Solve the programming task below in a Python markdown code block. Vitaly is a very weird man. He's got two favorite digits a and b. Vitaly calls a positive integer good, if the decimal representation of this integer only contains digits a and b. Vitaly calls a good number excellent, if the sum of its digits is a good ...
Solve the programming task below in a Python markdown code block. ## Nova polynomial add This kata is from a series on polynomial handling. ( [#1](http://www.codewars.com/kata/nova-polynomial-1-add-1) [#2](http://www.codewars.com/kata/570eb07e127ad107270005fe) [#3](http://www.codewars.com/kata/5714041e8807940ff300114...
Solve the programming task below in a Python markdown code block. Given are positive integers A and B. Let us choose some number of positive common divisors of A and B. Here, any two of the chosen divisors must be coprime. At most, how many divisors can we choose?Definition of common divisor An integer d is said to be...
Solve the programming task below in a Python markdown code block. problem A mysterious $ X $ [cm] plant grows in one place. This plant has the following mysterious properties. * Say "nobiro" to this plant and it will grow $ A $ [cm]. * Say "tidime" to this plant and it will grow $ B $ [cm]. * If you say "karero" to ...
Solve the programming task below in a Python markdown code block. problem Given a sequence $ a_i $ of length $ N $. Output all integers $ K (1 \ le K \ le N) $ that satisfy the following conditions. Condition: Well sorted $ a_1, \ cdots, a_K $ matches $ a_ {N-K + 1}, \ cdots, a_N $. Example Input 8 5 2 4 9 4 ...
Solve the programming task below in a Python markdown code block. Takahashi is doing a research on sets of points in a plane. Takahashi thinks a set S of points in a coordinate plane is a good set when S satisfies both of the following conditions: * The distance between any two points in S is not \sqrt{D_1}. * The di...
Solve the programming task below in a Python markdown code block. Given is a sequence of N integers A_1, \ldots, A_N. Find the (multiplicative) inverse of the sum of the inverses of these numbers, \frac{1}{\frac{1}{A_1} + \ldots + \frac{1}{A_N}}. -----Constraints----- - 1 \leq N \leq 100 - 1 \leq A_i \leq 1000 ---...
Solve the programming task below in a Python markdown code block. Write ```python word_pattern(pattern, string) ``` that given a ```pattern``` and a string ```str```, find if ```str``` follows the same sequence as ```pattern```. For example: ```python word_pattern('abab', 'truck car truck car') == True word_pattern(...
Solve the programming task below in a Python markdown code block. Let's consider one interesting word game. In this game you should transform one word into another through special operations. Let's say we have word w, let's split this word into two non-empty parts x and y so, that w = xy. A split operation is transf...
Solve the programming task below in a Python markdown code block. Sometimes Mister B has free evenings when he doesn't know what to do. Fortunately, Mister B found a new game, where the player can play against aliens. All characters in this game are lowercase English letters. There are two players: Mister B and his c...
Solve the programming task below in a Python markdown code block. You are an environmental activist at heart but the reality is harsh and you are just a cashier in a cinema. But you can still do something! You have $n$ tickets to sell. The price of the $i$-th ticket is $p_i$. As a teller, you have a possibility to se...
Solve the programming task below in a Python markdown code block. Monocarp has got an array $a$ consisting of $n$ integers. Let's denote $k$ as the mathematic mean of these elements (note that it's possible that $k$ is not an integer). The mathematic mean of an array of $n$ elements is the sum of elements divided by ...
Solve the programming task below in a Python markdown code block. There are $n$ candles on a Hanukkah menorah, and some of its candles are initially lit. We can describe which candles are lit with a binary string $s$, where the $i$-th candle is lit if and only if $s_i=1$. Initially, the candle lights are described by...
Solve the programming task below in a Python markdown code block. Relative B came to Mr. A's house. He is 3 years old and loves blocks. The block he has is shaped like Figure 1. <image> Figure 1 Mr. B is laying blocks on the board. When I asked him, "What are you making?", He replied cheerfully, "Maze !!". The maze...