question
large_stringlengths
265
13.2k
Solve the programming task below in a Python markdown code block. The only difference between easy and hard versions is the maximum value of $n$. You are given a positive integer number $n$. You really love good numbers so you want to find the smallest good number greater than or equal to $n$. The positive integer i...
Solve the programming task below in a Python markdown code block. Given a matrix (H Γ— W) which contains only 1 and 0, find the area of the largest rectangle which only contains 0s. Constraints * 1 ≀ H, W ≀ 1,400 Input H W c1,1 c1,2 ... c1,W c2,1 c2,2 ... c2,W : cH,1 cH,2 ... cH,W In the first line, two integers...
Solve the programming task below in a Python markdown code block. Little Elephant from the Zoo of Lviv likes cards. He has N cards, each of which has one of 1000 colors. The colors are numbered from 1 to 1000. Little Elephant and Big Hippo are playing the following game. At first Little Elephant takes some subset of c...
Solve the programming task below in a Python markdown code block. An expedition group flew from planet ACM-1 to Earth in order to study the bipedal species (its representatives don't even have antennas on their heads!). The flying saucer, on which the brave pioneers set off, consists of three sections. These sections...
Solve the programming task below in a Python markdown code block. A telephone number is a sequence of exactly 11 digits, where the first digit is 8. For example, the sequence 80011223388 is a telephone number, but the sequences 70011223388 and 80000011223388 are not. You are given a string $s$ of length $n$, consisti...
Solve the programming task below in a Python markdown code block. You are an upcoming movie director, and you have just released your first movie. You have also launched a simple review site with two buttons to press β€” upvote and downvote. However, the site is not so simple on the inside. There are two servers, each ...
Solve the programming task below in a Python markdown code block. Vasya plays the Need For Brake. He plays because he was presented with a new computer wheel for birthday! Now he is sure that he will win the first place in the championship in his favourite racing computer game! n racers take part in the championship...
Solve the programming task below in a Python markdown code block. A positive integer is called a 2-3-integer, if it is equal to 2^{x}Β·3^{y} for some non-negative integers x and y. In other words, these integers are such integers that only have 2 and 3 among their prime divisors. For example, integers 1, 6, 9, 16 and 1...
Solve the programming task below in a Python markdown code block. You are given a permutation $p$ of $n$ integers $1$, $2$, ..., $n$ (a permutation is an array where each element from $1$ to $n$ occurs exactly once). Let's call some subsegment $p[l, r]$ of this permutation special if $p_l + p_r = \max \limits_{i = l}...
Solve the programming task below in a Python markdown code block. # Fourier transformations are hard. Fouriest transformations are harder. This Kata is based on the SMBC Comic on fourier transformations. A fourier transformation on a number is one that converts the number to a base in which it has more `4`s ( `10` i...
Solve the programming task below in a Python markdown code block. There is a tree with N vertices, numbered 1, 2, \ldots, N. For each i (1 \leq i \leq N - 1), the i-th edge connects Vertex x_i and y_i. Taro has decided to paint each vertex in white or black, so that any black vertex can be reached from any other blac...
Solve the programming task below in a Python markdown code block. Taro came to a square to look for treasure. There are many treasures buried in this square, but Taro has the latest machines, so he knows everything about where the treasures are buried. Since the square is very wide Taro decided to look for the treasur...
Solve the programming task below in a Python markdown code block. Passer ratings are the generally accepted standard for evaluating NFL quarterbacks. I knew a rating of 100 is pretty good, but never knew what makes up the rating. So out of curiosity I took a look at the wikipedia page and had an idea or my first kata:...
Solve the programming task below in a Python markdown code block. In Berland recently a new collection of toys went on sale. This collection consists of 10^9 types of toys, numbered with integers from 1 to 10^9. A toy from the new collection of the i-th type costs i bourles. Tania has managed to collect n different t...
Solve the programming task below in a Python markdown code block. Decimal numbers are a common notation system currently in use and use ten symbols 0, 1, 2, 3, 4, 5, 6, 7, 8, and 9 to represent all numbers. Binary numbers are a popular notation in the computer world and use two symbols, 0 and 1, to represent all numb...
Solve the programming task below in a Python markdown code block. There is an infinitely long street that runs west to east, which we consider as a number line. There are N roadworks scheduled on this street. The i-th roadwork blocks the point at coordinate X_i from time S_i - 0.5 to time T_i - 0.5. Q people are stand...
Solve the programming task below in a Python markdown code block. Find places where a string P is found within a text T. Print all indices of T where P found. The indices of T start with 0. Constraints * 1 ≀ length of T ≀ 1000000 * 1 ≀ length of P ≀ 10000 * The input consists of alphabetical characters and digits I...
Solve the programming task below in a Python markdown code block. The Smart Beaver from ABBYY began to develop a new educational game for children. The rules of the game are fairly simple and are described below. The playing field is a sequence of n non-negative integers ai numbered from 1 to n. The goal of the game ...
Solve the programming task below in a Python markdown code block. Sakuzyo - Imprinting A.R.C. Markland-N is a tall building with $n$ floors numbered from $1$ to $n$. Between each two adjacent floors in the building, there is a staircase connecting them. It's lunchtime for our sensei Colin "ConneR" Neumann Jr, and he...
Solve the programming task below in a Python markdown code block. ### Task Yes, your eyes are no problem, this is toLoverCase (), not toLowerCase (), we want to make the world full of love. ### What do we need to do? You need to add a prototype function to the String, the name is toLoverCase. Function can c...
Solve the programming task below in a Python markdown code block. We have a tree with N vertices. The i-th edge connects Vertex A_i and B_i bidirectionally. Takahashi is standing at Vertex u, and Aoki is standing at Vertex v. Now, they will play a game of tag as follows: - 1. If Takahashi and Aoki are standing at the...
Solve the programming task below in a Python markdown code block. Jon Snow is on the lookout for some orbs required to defeat the white walkers. There are k different types of orbs and he needs at least one of each. One orb spawns daily at the base of a Weirwood tree north of the wall. The probability of this orb bein...
Solve the programming task below in a Python markdown code block. You have to create a method "compoundArray" which should take as input two int arrays of different length and return one int array with numbers of both arrays shuffled one by one. ```Example: Input - {1,2,3,4,5,6} and {9,8,7,6} Output - {1,9,2,8,3,7,...
Solve the programming task below in a Python markdown code block. Piegirl has found a monster and a book about monsters and pies. When she is reading the book, she found out that there are n types of monsters, each with an ID between 1 and n. If you feed a pie to a monster, the monster will split into some number of m...
Solve the programming task below in a Python markdown code block. Takahashi has an empty string S and a variable x whose initial value is 0. Also, we have a string T consisting of `0` and `1`. Now, Takahashi will do the operation with the following two steps |T| times. * Insert a `0` or a `1` at any position of S o...
Solve the programming task below in a Python markdown code block. Given 2 elevators (named "left" and "right") in a building with 3 floors (numbered `0` to `2`), write a function `elevator` accepting 3 arguments (in order): - `left` - The current floor of the left elevator - `right` - The current floor of the right e...
Solve the programming task below in a Python markdown code block. Problem Given the integer n, output the smallest m such that nCm (the number of combinations that choose m out of n different ones) is even. Constraints The input satisfies the following conditions. * 1 ≀ n ≀ 1018 Input The input is given in the f...
Solve the programming task below in a Python markdown code block. Write a function that accepts two parameters (a and b) and says whether a is smaller than, bigger than, or equal to b. Here is an example code: var noIfsNoButs = function (a,b) { if(a > b) return a + " is greater than " + b else if(a < b) return a ...
Solve the programming task below in a Python markdown code block. There are N balls in the xy-plane. The coordinates of the i-th of them is (x_i, i). Thus, we have one ball on each of the N lines y = 1, y = 2, ..., y = N. In order to collect these balls, Snuke prepared 2N robots, N of type A and N of type B. Then, he ...
Solve the programming task below in a Python markdown code block. There are n phone numbers in Polycarp's contacts on his phone. Each number is a 9-digit integer, starting with a digit different from 0. All the numbers are distinct. There is the latest version of Berdroid OS installed on Polycarp's phone. If some num...
Solve the programming task below in a Python markdown code block. Read problems statements in Mandarin Chinese and Russian. You are given an array A of integers of size N. You will be given Q queries where each query is represented by two integers L, R. You have to find the gcd(Greatest Common Divisor) of the array...
Solve the programming task below in a Python markdown code block. As you must know, the maximum clique problem in an arbitrary graph is NP-hard. Nevertheless, for some graphs of specific kinds it can be solved effectively. Just in case, let us remind you that a clique in a non-directed graph is a subset of the vertic...
Solve the programming task below in a Python markdown code block. We're giving away nice huge bags containing number tiles! A bag we want to present to you contains n tiles. Each of them has a single number written on it β€” either 1 or 2. However, there is one condition you must fulfill in order to receive the prize. ...
Solve the programming task below in a Python markdown code block. Multiple polygonal lines are given on the xy-plane. Given a list of polygonal lines and a template, you must find out polygonal lines which have the same shape as the template. A polygonal line consists of several line segments parallel to x-axis or y-...
Solve the programming task below in a Python markdown code block. You are given $n$ numbers $a_1, a_2, \dots, a_n$. With a cost of one coin you can perform the following operation: Choose one of these numbers and add or subtract $1$ from it. In particular, we can apply this operation to the same number several times...
Solve the programming task below in a Python markdown code block. There are times you recall a good old friend and everything you've come through together. Luckily there are social networksΒ β€” they store all your message history making it easy to know what you argued over 10 years ago. More formal, your message histor...
Solve the programming task below in a Python markdown code block. Vanya has a table consisting of 100 rows, each row contains 100 cells. The rows are numbered by integers from 1 to 100 from bottom to top, the columns are numbered from 1 to 100 from left to right. In this table, Vanya chose n rectangles with sides th...
Solve the programming task below in a Python markdown code block. For a given polygon g, print "1" if g is a convex polygon, "0" otherwise. Here, in a convex polygon, all interior angles are less than or equal to 180 degrees. g is represented by a sequence of points p1, p2,..., pn where line segments connecting pi an...
Solve the programming task below in a Python markdown code block. Andryusha goes through a park each day. The squares and paths between them look boring to Andryusha, so he decided to decorate them. The park consists of n squares connected with (n - 1) bidirectional paths in such a way that any square is reachable fr...
Solve the programming task below in a Python markdown code block. A string of length 6 consisting of lowercase English letters is said to be coffee-like if and only if its 3-rd and 4-th characters are equal and its 5-th and 6-th characters are also equal. Given a string S, determine whether it is coffee-like. -----C...
Solve the programming task below in a Python markdown code block. Takahashi has decided to work on K days of his choice from the N days starting with tomorrow. You are given an integer C and a string S. Takahashi will choose his workdays as follows: - After working for a day, he will refrain from working on the subse...
Solve the programming task below in a Python markdown code block. The Floral Clock has been standing by the side of Mirror Lake for years. Though unable to keep time, it reminds people of the passage of time and the good old days. On the rim of the Floral Clock are 2n flowers, numbered from 1 to 2n clockwise, each of...
Solve the programming task below in a Python markdown code block. ###Task: You have to write a function **pattern** which returns the following Pattern(See Examples) upto n rows, where n is parameter. ####Rules/Note: * If the Argument is 0 or a Negative Integer then it should return "" i.e. empty string. * The lengt...
Solve the programming task below in a Python markdown code block. In telecomunications we use information coding to detect and prevent errors while sending data. A parity bit is a bit added to a string of binary code that indicates whether the number of 1-bits in the string is even or odd. Parity bits are used as th...
Solve the programming task below in a Python markdown code block. Little Artem found a grasshopper. He brought it to his house and constructed a jumping area for him. The area looks like a strip of cells 1 Γ— n. Each cell contains the direction for the next jump and the length of that jump. Grasshopper starts in the f...
Solve the programming task below in a Python markdown code block. Given a positive number n > 1 find the prime factor decomposition of n. The result will be a string with the following form : ``` "(p1**n1)(p2**n2)...(pk**nk)" ``` where ```a ** b``` means ```a``` to the power of ```b``` with the p(i) in increasing or...
Solve the programming task below in a Python markdown code block. problem AOR Ika made a set $ S = \\ {a_1, ..., a_N \\} $ and a map $ f: S β†’ S $. $ f (a_i) = b_i $. For any element $ x $ in the set $ S $, all maps $ g, h: S β†’ S $ satisfying $ g (f (x)) = h (f (x)) $ are $ g (x). ) = Determine if h (x) $ is satisfied...
Solve the programming task below in a Python markdown code block. Given a string containing a list of integers separated by commas, write the function string_to_int_list(s) that takes said string and returns a new list containing all integers present in the string, preserving the order. For example, give the string "...
Solve the programming task below in a Python markdown code block. You are given a sequence of $n$ integers $a_1$, $a_2$, ..., $a_n$. Let us call an index $j$ ($2 \le j \le {{n-1}}$) a hill if $a_j > a_{{j+1}}$ and $a_j > a_{{j-1}}$; and let us call it a valley if $a_j < a_{{j+1}}$ and $a_j < a_{{j-1}}$. Let us define...
Solve the programming task below in a Python markdown code block. Bandits appeared in the city! One of them is trying to catch as many citizens as he can. The city consists of $n$ squares connected by $n-1$ roads in such a way that it is possible to reach any square from any other square. The square number $1$ is the...
Solve the programming task below in a Python markdown code block. There are n student groups at the university. During the study day, each group can take no more than 7 classes. Seven time slots numbered from 1 to 7 are allocated for the classes. The schedule on Monday is known for each group, i. e. time slots when g...
Solve the programming task below in a Python markdown code block. Student Andrey has been skipping physical education lessons for the whole term, and now he must somehow get a passing grade on this subject. Obviously, it is impossible to do this by legal means, but Andrey doesn't give up. Having obtained an empty cert...
Solve the programming task below in a Python markdown code block. In Omkar's last class of math, he learned about the least common multiple, or $LCM$. $LCM(a, b)$ is the smallest positive integer $x$ which is divisible by both $a$ and $b$. Omkar, having a laudably curious mind, immediately thought of a problem involv...
Solve the programming task below in a Python markdown code block. Danny, the local Math Maniac, is fascinated by circles, Omkar's most recent creation. Help him solve this circle problem! You are given $n$ nonnegative integers $a_1, a_2, \dots, a_n$ arranged in a circle, where $n$ must be odd (ie. $n-1$ is divisible ...
Solve the programming task below in a Python markdown code block. Recently, Tokitsukaze found an interesting game. Tokitsukaze had $n$ items at the beginning of this game. However, she thought there were too many items, so now she wants to discard $m$ ($1 \le m \le n$) special items of them. These $n$ items are marke...
Solve the programming task below in a Python markdown code block. Create a __moreZeros__ function which will __receive a string__ for input, and __return an array__ (or null terminated string in C) containing only the characters from that string whose __binary representation of its ASCII value__ consists of _more zero...
Solve the programming task below in a Python markdown code block. You are a secret agent from the Intelligence Center of Peacemaking Committee. You've just sneaked into a secret laboratory of an evil company, Automated Crime Machines. Your mission is to get a confidential document kept in the laboratory. To reach the...
Solve the programming task below in a Python markdown code block. User ainta loves to play with cards. He has a cards containing letter "o" and b cards containing letter "x". He arranges the cards in a row, and calculates the score of the deck by the formula below. 1. At first, the score is 0. 2. For each block ...
Solve the programming task below in a Python markdown code block. Valera loves his garden, where n fruit trees grow. This year he will enjoy a great harvest! On the i-th tree b_{i} fruit grow, they will ripen on a day number a_{i}. Unfortunately, the fruit on the tree get withered, so they can only be collected on da...
Solve the programming task below in a Python markdown code block. The recent All-Berland Olympiad in Informatics featured n participants with each scoring a certain amount of points. As the head of the programming committee, you are to determine the set of participants to be awarded with diplomas with respect to the ...
Solve the programming task below in a Python markdown code block. You are given a complete undirected graph. For each pair of vertices you are given the length of the edge that connects them. Find the shortest paths between each pair of vertices in the graph and return the length of the longest of them. -----Input--...
Solve the programming task below in a Python markdown code block. Hooray! Polycarp turned n years old! The Technocup Team sincerely congratulates Polycarp! Polycarp celebrated all of his n birthdays: from the 1-th to the n-th. At the moment, he is wondering: how many times he turned beautiful number of years? Accord...
Solve the programming task below in a Python markdown code block. On a clear night, a boy, Campanella looked up at the sky, there were many stars which have different colors such as red, yellow, green, blue, purple, etc. He was watching the stars and just lost track of time. Presently, he wondered, | <image> ---|---...
Solve the programming task below in a Python markdown code block. Valera's finally decided to go on holiday! He packed up and headed for a ski resort. Valera's fancied a ski trip but he soon realized that he could get lost in this new place. Somebody gave him a useful hint: the resort has n objects (we will consider ...
Solve the programming task below in a Python markdown code block. Santa has to send presents to the kids. He has a large stack of $n$ presents, numbered from $1$ to $n$; the topmost present has number $a_1$, the next present is $a_2$, and so on; the bottom present has number $a_n$. All numbers are distinct. Santa has...
Solve the programming task below in a Python markdown code block. Today is the ticket release date for Aizu Entertainment's recommended idol group "Akabeko & Koboushi". There are four types of tickets: S seat 6000 yen A seat 4000 yen B seat 3000 yen C seat 2000 yen You, the sales manager, are excitedly waiting for t...
Solve the programming task below in a Python markdown code block. In the speed skating badge test, grades are awarded when the time specified for two distances is exceeded. For example, to reach Class A, 500 M requires less than 40.0 seconds and 1000 M requires less than 1 minute and 23 seconds. Create a program that...
Solve the programming task below in a Python markdown code block. Imp is in a magic forest, where xorangles grow (wut?) [Image] A xorangle of order n is such a non-degenerate triangle, that lengths of its sides are integers not exceeding n, and the xor-sum of the lengths is equal to zero. Imp has to count the numb...
Solve the programming task below in a Python markdown code block. Takahashi, who works at DISCO, is standing before an iron bar. The bar has N-1 notches, which divide the bar into N sections. The i-th section from the left has a length of A_i millimeters. Takahashi wanted to choose a notch and cut the bar at that poi...
Solve the programming task below in a Python markdown code block. The only difference between the easy and the hard versions is the maximum value of $k$. You are given an infinite sequence of form "112123123412345$\dots$" which consist of blocks of all consecutive positive integers written one after another. The firs...
Solve the programming task below in a Python markdown code block. Create a program of the square picking method, which is one of the classical random number generation methods. The square harvesting method was proposed by von Neumann in the mid-1940s. In the square picking method, when the number of digits of the gen...
Solve the programming task below in a Python markdown code block. Inaka has a disc, the circumference of which is n units. The circumference is equally divided by n points numbered clockwise from 1 to n, such that points i and i + 1 (1 ≀ i < n) are adjacent, and so are points n and 1. There are m straight segments on...
Solve the programming task below in a Python markdown code block. You need to execute several tasks, each associated with number of processors it needs, and the compute power it will consume. You have sufficient number of analog computers, each with enough processors for any task. Each computer can execute up to one ...
Solve the programming task below in a Python markdown code block. Vova has taken his summer practice this year and now he should write a report on how it went. Vova has already drawn all the tables and wrote down all the formulas. Moreover, he has already decided that the report will consist of exactly $n$ pages and ...
Solve the programming task below in a Python markdown code block. In this kata, your task is to identify the pattern underlying a sequence of numbers. For example, if the sequence is [1, 2, 3, 4, 5], then the pattern is [1], since each number in the sequence is equal to the number preceding it, plus 1. See the test ca...
Solve the programming task below in a Python markdown code block. It seems that Borya is seriously sick. He is going visit n doctors to find out the exact diagnosis. Each of the doctors needs the information about all previous visits, so Borya has to visit them in the prescribed order (i.e. Borya should first visit do...
Solve the programming task below in a Python markdown code block. Duff is addicted to meat! Malek wants to keep her happy for n days. In order to be happy in i-th day, she needs to eat exactly a_{i} kilograms of meat. [Image] There is a big shop uptown and Malek wants to buy meat for her from there. In i-th day, the...
Solve the programming task below in a Python markdown code block. Converting a normal (12-hour) time like "8:30 am" or "8:30 pm" to 24-hour time (like "0830" or "2030") sounds easy enough, right? Well, let's see if you can do it! You will have to define a function named "to24hourtime", and you will be given an hour ...
Solve the programming task below in a Python markdown code block. "Night gathers, and now my watch begins. It shall not end until my death. I shall take no wife, hold no lands, father no children. I shall wear no crowns and win no glory. I shall live and die at my post. I am the sword in the darkness. I am the watcher...
Solve the programming task below in a Python markdown code block. You can obtain profits from foreign exchange margin transactions. For example, if you buy 1000 dollar at a rate of 100 yen per dollar, and sell them at a rate of 108 yen per dollar, you can obtain (108 - 100) Γ— 1000 = 8000 yen. Write a program which re...
Solve the programming task below in a Python markdown code block. Remember the game 2048? The main part of this game is merging identical tiles in a row. * Implement a function that models the process of merging all of the tile values in a single row. * This function takes the array line as a parameter and return...
Solve the programming task below in a Python markdown code block. In JavaScript, ```if..else``` is the most basic condition statement, it consists of three parts:```condition, statement1, statement2```, like this: ```python if condition: statementa else: statementb ``` It means that if the condition is true, t...
Solve the programming task below in a Python markdown code block. In this problem, we only consider strings consisting of lowercase English letters. Strings s and t are said to be isomorphic when the following conditions are satisfied: * |s| = |t| holds. * For every pair i, j, one of the following holds: * s_i = s_j...
Solve the programming task below in a Python markdown code block. Sonya was unable to think of a story for this problem, so here comes the formal description. You are given the array containing n positive integers. At one turn you can pick any element and increase or decrease it by 1. The goal is the make the array s...
Solve the programming task below in a Python markdown code block. Consider the following arithmetic progression with n terms: * x, x + d, x + 2d, \ldots, x + (n-1)d What is the product of all terms in this sequence? Compute the answer modulo 1\ 000\ 003. You are given Q queries of this form. In the i-th query, co...
Solve the programming task below in a Python markdown code block. Rabbits and cats are competing. The rules are as follows. First, each of the two animals wrote n2 integers on a piece of paper in a square with n rows and n columns, and drew one card at a time. Shuffle two cards and draw them one by one alternately. E...
Solve the programming task below in a Python markdown code block. Vova's family is building the Great Vova Wall (named by Vova himself). Vova's parents, grandparents, grand-grandparents contributed to it. Now it's totally up to Vova to put the finishing touches. The current state of the wall can be respresented by a ...
Solve the programming task below in a Python markdown code block. Denis, after buying flowers and sweets (you will learn about this story in the next task), went to a date with Nastya to ask her to become a couple. Now, they are sitting in the cafe and finally... Denis asks her to be together, but ... Nastya doesn't g...
Solve the programming task below in a Python markdown code block. There is a programing contest named SnakeUp, 2n people want to compete for it. In order to attend this contest, people need to form teams of exactly two people. You are given the strength of each possible combination of two people. All the values of the...
Solve the programming task below in a Python markdown code block. You are given two integers K and S. Three variable X, Y and Z takes integer values satisfying 0≀X,Y,Z≀K. How many different assignments of values to X, Y and Z are there such that X + Y + Z = S? -----Constraints----- - 2≀K≀2500 - 0≀S≀3K - K an...
Solve the programming task below in a Python markdown code block. Alex, Bob and Carl will soon participate in a team chess tournament. Since they are all in the same team, they have decided to practise really hard before the tournament. But it's a bit difficult for them because chess is a game for two players, not thr...
Solve the programming task below in a Python markdown code block. Given an integer $x$. Your task is to find out how many positive integers $n$ ($1 \leq n \leq x$) satisfy $$n \cdot a^n \equiv b \quad (\textrm{mod}\;p),$$ where $a, b, p$ are all known constants. -----Input----- The only line contains four integers ...
Solve the programming task below in a Python markdown code block. Student Dima from Kremland has a matrix $a$ of size $n \times m$ filled with non-negative integers. He wants to select exactly one integer from each row of the matrix so that the bitwise exclusive OR of the selected integers is strictly greater than ze...
Solve the programming task below in a Python markdown code block. Implement `String#ipv4_address?`, which should return true if given object is an IPv4 address - four numbers (0-255) separated by dots. It should only accept addresses in canonical representation, so no leading `0`s, spaces etc. Read the inputs from s...
Solve the programming task below in a Python markdown code block. As a token of his gratitude, Takahashi has decided to give his mother an integer sequence. The sequence A needs to satisfy the conditions below: - A consists of integers between X and Y (inclusive). - For each 1\leq i \leq |A|-1, A_{i+1} is a multiple...
Solve the programming task below in a Python markdown code block. Mr. Frugal bought a new house. He feels deeply in love with his new house because it has a comfortable living room in which he can put himself completely at ease. He thinks his new house is a really good buy. But, to his disappointment, the floor of it...
Solve the programming task below in a Python markdown code block. A Narcissistic Number is a number of length n in which the sum of its digits to the power of n is equal to the original number. If this seems confusing, refer to the example below. Ex: 153, where n = 3 (number of digits in 153) 1^(3) + 5^(3) + 3^(3) = ...
Solve the programming task below in a Python markdown code block. Dima and his friends have been playing hide and seek at Dima's place all night. As a result, Dima's place got messy. In the morning they decided that they need to clean the place. To decide who exactly would clean the apartment, the friends want to pla...
Solve the programming task below in a Python markdown code block. There is a tree with N vertices numbered 1 through N. The i-th edge connects Vertex x_i and y_i. Each vertex is painted white or black. The initial color of Vertex i is represented by a letter c_i. c_i = W represents the vertex is white; c_i = B represe...
Solve the programming task below in a Python markdown code block. Vasya has a multiset s consisting of n integer numbers. Vasya calls some number x nice if it appears in the multiset exactly once. For example, multiset \{1, 1, 2, 3, 3, 3, 4\} contains nice numbers 2 and 4. Vasya wants to split multiset s into two mul...