question
large_stringlengths
265
13.2k
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. As we all know, Chef is cooking string for long days, his new discovery on string is the longest common pattern length. The longest common pattern length between two strings is the maximum number of characters that both strings have in common. Character...
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. This problem differs from one which was on the online contest. The sequence a1, a2, ..., an is called increasing, if ai < ai + 1 for i < n. The sequence s1, s2, ..., sk is called the subsequence of the sequence a1, a2, ..., an, if there exist such a s...
Solve the programming task below in a Python markdown code block. Eleven wants to choose a new name for herself. As a bunch of geeks, her friends suggested an algorithm to choose a name for her. Eleven wants her name to have exactly n characters. [Image] Her friend suggested that her name should only consist of upp...
Solve the programming task below in a Python markdown code block. You found a mysterious function f. The function takes two strings s1 and s2. These strings must consist only of lowercase English letters, and must be the same length. The output of the function f is another string of the same length. The i-th characte...
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. Takahashi and Aoki will play a game with a number line and some segments. Takahashi is standing on the number line and he is initially at coordinate 0. Aoki has N segments. The i-th segment is [L_i,R_i], that is, a segment consisting of points with coor...
Solve the programming task below in a Python markdown code block. This is the hard version of the problem. The difference between the versions is that the hard version does require you to output the numbers of the rods to be removed. You can make hacks only if all versions of the problem are solved. Stitch likes expe...
Solve the programming task below in a Python markdown code block. Taro and Hanako are playing card games. They have n cards each, and they compete n turns. At each turn Taro and Hanako respectively puts out a card. The name of the animal consisting of alphabetical letters is written on each card, and the bigger one in...
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. Arthur has bought a beautiful big table into his new flat. When he came home, Arthur noticed that the new table is unstable. In total the table Arthur bought has n legs, the length of the i-th leg is l_{i}. Arthur decided to make the table stable and ...
Solve the programming task below in a Python markdown code block. One player came to a casino and found a slot machine where everything depends only on how he plays. The rules follow. A positive integer a is initially on the screen. The player can put a coin into the machine and then add 1 to or subtract 1 from any t...
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. Read the inputs from stdin solve the problem and write the answer to stdout (do not directly test on...
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. You've got another problem dealing with arrays. Let's consider an arbitrary sequence containing n (not necessarily different) integers a1, a2, ..., an. We are interested in all possible pairs of numbers (ai, aj), (1 ≀ i, j ≀ n). In other words, let's co...
Solve the programming task below in a Python markdown code block. Takahashi wants to gain muscle, and decides to work out at AtCoder Gym. The exercise machine at the gym has N buttons, and exactly one of the buttons is lighten up. These buttons are numbered 1 through N. When Button i is lighten up and you press it, th...
Solve the programming task below in a Python markdown code block. There is a pond with a rectangular shape. The pond is divided into a grid with H rows and W columns of squares. We will denote the square at the i-th row from the top and j-th column from the left by (i,\ j). Some of the squares in the pond contains a l...
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. Polycarpus plays with red and blue marbles. He put n marbles from the left to the right in a row. As it turned out, the marbles form a zebroid. A non-empty sequence of red and blue marbles is a zebroid, if the colors of the marbles in this sequence alt...
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. You are given a grid with n rows and m columns, where each cell has a non-negative integer written on it. We say the grid is good if for each cell the following condition holds: if it has a number k > 0 written on it, then exactly k of its neighboring c...
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. For a string S, let f(S) be the lexicographically smallest cyclic shift of S. For example, if S = `babca`, f(S) = `ababc` because this is the smallest among all cyclic shifts (`babca`, `abcab`, `bcaba`, `cabab`, `ababc`). You are given three integers X...
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. 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. Jon Snow now has to fight with White Walkers. He has n rangers, each of which has his own strength. Also Jon Snow has his favourite number x. Each ranger can fight with a white walker only if the strength of the white walker equals his strength. He howe...
Solve the programming task below in a Python markdown code block. You are given an integer $N$ and a string consisting of '+' and digits. You are asked to transform the string into a valid formula whose calculation result is smaller than or equal to $N$ by modifying some characters. Here, you replace one character wit...
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. Ivan's classes at the university have just finished, and now he wants to go to the local CFK cafe and eat some fried chicken. CFK sells chicken chunks in small and large portions. A small portion contains 3 chunks; a large one β€” 7 chunks. Ivan wants to...
Solve the programming task below in a Python markdown code block. Alice has learnt factorization recently. Bob doesn't think she has learnt it properly and hence he has decided to quiz her. Bob gives Alice a very large number and asks her to find out the number of factors of that number. To make it a little easier for...
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. Stylish is a programming language whose syntax comprises names, that are sequences of Latin alphabet letters, three types of grouping symbols, periods ('.'), and newlines. Grouping symbols, namely round brackets ('(' and ')'), curly brackets ('{' and '}...
Solve the programming task below in a Python markdown code block. During the hypnosis session, Nicholas suddenly remembered a positive integer $n$, which doesn't contain zeros in decimal notation. Soon, when he returned home, he got curious: what is the maximum number of digits that can be removed from the number so ...
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. 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. Given a string ``string`` that contains only letters, you have to find out the number of **unique** strings (including ``string`` itself) that can be produced by re-arranging the letters of the ``string``. Strings are case **insensitive**. HINT: Gener...
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. AtCoder currently hosts three types of contests: ABC, ARC, and AGC. As the number of users has grown, in order to meet the needs of more users, AtCoder has decided to increase the number of contests to 26 types, from AAC to AZC. For convenience, we numb...
Solve the programming task below in a Python markdown code block. The R1 company has recently bought a high rise building in the centre of Moscow for its main office. It's time to decorate the new office, and the first thing to do is to write the company's slogan above the main entrance to the building. The slogan of...
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. 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. String can be called correct if it consists of characters "0" and "1" and there are no redundant leading zeroes. Here are some examples: "0", "10", "1001". You are given a correct string s. You can perform two different operations on this string: sw...
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. This is the harder version of the problem. In this version, 1 ≀ n, m ≀ 2β‹…10^5. You can hack this problem if you locked it. But you can hack the previous problem only if you locked both problems. You are given a sequence of integers a=[a_1,a_2,...,a_n] ...
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. 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. Polycarp loves geometric progressions β€” he collects them. However, as such progressions occur very rarely, he also loves the sequences of numbers where it is enough to delete a single element to get a geometric progression. In this task we shall define...
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. This problem is an extension of the problem "Wonderful Coloring - 1". It has quite many differences, so you should read this statement completely. Recently, Paul and Mary have found a new favorite sequence of integers $a_1, a_2, \dots, a_n$. They want ...
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. 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. You are given three piles of casino chips: white, green and black chips: * the first pile contains only white chips * the second pile contains only green chips * the third pile contains only black chips Each day you take exactly two chips of different...
Solve the programming task below in a Python markdown code block. # It's too hot, and they can't even… One hot summer day Pete and his friend Billy decided to buy watermelons. They chose the biggest crate. They rushed home, dying of thirst, and decided to divide their loot, however they faced a hard problem. Pete an...
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. There are N strings of lowercase alphabet only. The i-th string is S_i. Every string is unique. Provide answers for the Q queries below. The i-th query has the following format: Query: An integer k_i and a string p_{i,1}p_{i,2}...p_{i,26} that results...
Solve the programming task below in a Python markdown code block. To become a millionaire, M-kun has decided to make money by trading in the next N days. Currently, he has 1000 yen and no stocks - only one kind of stock is issued in the country where he lives. He is famous across the country for his ability to forese...
Solve the programming task below in a Python markdown code block. Takahashi loves the number 7 and multiples of K. Where is the first occurrence of a multiple of K in the sequence 7,77,777,\ldots? (Also see Output and Sample Input/Output below.) If the sequence contains no multiples of K, print -1 instead. -----Const...
Solve the programming task below in a Python markdown code block. Little penguin Polo adores strings. But most of all he adores strings of length n. One day he wanted to find a string that meets the following conditions: The string consists of n lowercase English letters (that is, the string's length equals n), exac...
Solve the programming task below in a Python markdown code block. Little girl Tanya climbs the stairs inside a multi-storey building. Every time Tanya climbs a stairway, she starts counting steps from $1$ to the number of steps in this stairway. She speaks every number aloud. For example, if she climbs two stairways, ...
Solve the programming task below in a Python markdown code block. Given are two strings s and t consisting of lowercase English letters. Determine if the number of non-negative integers i satisfying the following condition is finite, and find the maximum value of such i if the number is finite. - There exists a non-n...
Solve the programming task below in a Python markdown code block. Read problems statements in Mandarin Chinese and Russian as well. Chef wants to implement wildcard pattern matching supporting only the wildcard '?'. The wildcard character '?' can be substituted by any single lower case English letter for matching. H...
Solve the programming task below in a Python markdown code block. Your friend recently came up with a card game called UT-Rummy. The cards used in this game are numbered red, green, or blue and any number from 1 to 9. Each player in this game has 9 cards in his or her hand, chooses one from his or her hand, discards ...
Solve the programming task below in a Python markdown code block. Dwarfs have planted a very interesting plant, which is a triangle directed "upwards". This plant has an amusing feature. After one year a triangle plant directed "upwards" divides into four triangle plants: three of them will point "upwards" and one wil...
Solve the programming task below in a Python markdown code block. You are given an array $a$ consisting of $n$ integers. Indices of the array start from zero (i. e. the first element is $a_0$, the second one is $a_1$, and so on). You can reverse at most one subarray (continuous subsegment) of this array. Recall that ...
Solve the programming task below in a Python markdown code block. You are given a directed acyclic graph, consisting of $n$ vertices and $m$ edges. The vertices are numbered from $1$ to $n$. There are no multiple edges and self-loops. Let $\mathit{in}_v$ be the number of incoming edges (indegree) and $\mathit{out}_v$...
Solve the programming task below in a Python markdown code block. Kuro and Shiro are playing with a board composed of n squares lining up in a row. The squares are numbered 1 to n from left to right, and Square s has a mark on it. First, for each square, Kuro paints it black or white with equal probability, independen...
Solve the programming task below in a Python markdown code block. Example Input 3 y 7 y 6 n 5 Output 1 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. A bow adorned with nameless flowers that bears the earnest hopes of an equally nameless person. You have obtained the elegant bow known as the Windblume Ode. Inscribed in the weapon is an array of n (n β‰₯ 3) positive distinct integers (i.e. different, n...
Solve the programming task below in a Python markdown code block. Fukushima Prefecture is also famous for producing fruits, and among them, peaches and apples boast one of the highest production volumes in Japan. By the way, when I made a print manuscript of an English pamphlet for sale, I mistakenly wrote the descrip...
Solve the programming task below in a Python markdown code block. Akaki, a patissier, can make N kinds of doughnut using only a certain powder called "Okashi no Moto" (literally "material of pastry", simply called Moto below) as ingredient. These doughnuts are called Doughnut 1, Doughnut 2, ..., Doughnut N. In order t...
Solve the programming task below in a Python markdown code block. Let's pretend your company just hired your friend from college and paid you a referral bonus. Awesome! To celebrate, you're taking your team out to the terrible dive bar next door and using the referral bonus to buy, and build, the largest three-dimensi...
Solve the programming task below in a Python markdown code block. # Your Task The city of Darkishland has a strange hotel with infinite rooms. The groups that come to this hotel follow the following rules: * At the same time only members of one group can rent the hotel. * Each group comes in the morning of the check...
Solve the programming task below in a Python markdown code block. You are given an array $a$ consisting of $n$ positive integers. You are allowed to perform this operation any number of times (possibly, zero): choose an index $i$ ($2 \le i \le n$), and change $a_i$ to $a_i - a_{i-1}$. Is it possible to make $a_i=0$...
Solve the programming task below in a Python markdown code block. A [Mersenne prime](https://en.wikipedia.org/wiki/Mersenne_prime) is a prime number that can be represented as: Mn = 2^(n) - 1. Therefore, every Mersenne prime is one less than a power of two. Write a function that will return whether the given integer...
Solve the programming task below in a Python markdown code block. In a new version of the famous Pinball game, one of the most important parts of the game field is a sequence of n bumpers. The bumpers are numbered with integers from 1 to n from left to right. There are two types of bumpers. They are denoted by the cha...
Solve the programming task below in a Python markdown code block. You are given two integers a and b. In one turn, you can do one of the following operations: * Take an integer c (c > 1 and a should be divisible by c) and replace a with a/c; * Take an integer c (c > 1 and b should be divisible by c) and replace...
Solve the programming task below in a Python markdown code block. Kuro has recently won the "Most intelligent cat ever" contest. The three friends then decided to go to Katie's home to celebrate Kuro's winning. After a big meal, they took a small break then started playing games. Kuro challenged Katie to create a gam...
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...