question
large_stringlengths
265
13.2k
Solve the programming task below in a Python markdown code block. Monocarp has drawn a tree (an undirected connected acyclic graph) and then has given each vertex an index. All indices are distinct numbers from $1$ to $n$. For every edge $e$ of this tree, Monocarp has written two numbers: the maximum indices of the ve...
Solve the programming task below in a Python markdown code block. Crazy Town is a plane on which there are n infinite line roads. Each road is defined by the equation a_{i}x + b_{i}y + c_{i} = 0, where a_{i} and b_{i} are not both equal to the zero. The roads divide the plane into connected regions, possibly of infini...
Solve the programming task below in a Python markdown code block. Write a function that takes two arguments, and returns a new array populated with the elements **that only appear once, in either one array or the other, taken only once**; display order should follow what appears in arr1 first, then arr2: ```python h...
Solve the programming task below in a Python markdown code block. # Summation Write a program that finds the summation of every number from 1 to num. The number will always be a positive integer greater than 0. For example: ```if-not:racket ~~~ summation(2) -> 3 1 + 2 summation(8) -> 36 1 + 2 + 3 + 4 + 5 + 6 + 7 + ...
Solve the programming task below in a Python markdown code block. Hofstadter sequences are a family of related integer sequences, among which the first ones were described by an American professor Douglas Hofstadter in his book Gödel, Escher, Bach. ### Task Today we will be implementing the rather chaotic recursive ...
Solve the programming task below in a Python markdown code block. The city of Kyoto is well-known for its Chinese plan: streets are either North-South or East-West. Some streets are numbered, but most of them have real names. Crossings are named after the two streets crossing there, e.g. Kawaramachi-Sanjo is the cross...
Solve the programming task below in a Python markdown code block. It's time polar bears Menshykov and Uslada from the zoo of St. Petersburg and elephant Horace from the zoo of Kiev got down to business. In total, there are n tasks for the day and each animal should do each of these tasks. For each task, they have eval...
Solve the programming task below in a Python markdown code block. We have N cards. A number a_i is written on the i-th card. Alice and Bob will play a game using these cards. In this game, Alice and Bob alternately take one card. Alice goes first. The game ends when all the cards are taken by the two players, and th...
Solve the programming task below in a Python markdown code block. In this Kata, you will be given two integers `n` and `k` and your task is to remove `k-digits` from `n` and return the lowest number possible, without changing the order of the digits in `n`. Return the result as a string. Let's take an example of `sol...
Solve the programming task below in a Python markdown code block. Each employee of the "Blake Techologies" company uses a special messaging app "Blake Messenger". All the stuff likes this app and uses it constantly. However, some important futures are missing. For example, many users want to be able to search through ...
Solve the programming task below in a Python markdown code block. You will be given a fruit which a farmer has harvested, your job is to see if you should buy or sell. You will be given 3 pairs of fruit. Your task is to trade your harvested fruit back into your harvested fruit via the intermediate pair, you should re...
Solve the programming task below in a Python markdown code block. Sergey attends lessons of the N-ish language. Each lesson he receives a hometask. This time the task is to translate some sentence to the N-ish language. Sentences of the N-ish language can be represented as strings consisting of lowercase Latin letters...
Solve the programming task below in a Python markdown code block. <image> As shown in the figure above, cut a convex polygon g by a line p1p2 and print the area of the cut polygon which is on the left-hand side of the line. 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. There is a string s of length 3 or greater. No two neighboring characters in s are equal. Takahashi and Aoki will play a game against each other. The two players alternately performs the following operation, Takahashi going first: * Remove one of the ...
Solve the programming task below in a Python markdown code block. Snuke received a positive integer N from Takahashi. A positive integer m is called a favorite number when the following condition is satisfied: * The quotient and remainder of N divided by m are equal, that is, \lfloor \frac{N}{m} \rfloor = N \bmod m h...
Solve the programming task below in a Python markdown code block. A shop sells N kinds of fruits, Fruit 1, \ldots, N, at prices of p_1, \ldots, p_N yen per item, respectively. (Yen is the currency of Japan.) Here, we will choose K kinds of fruits and buy one of each chosen kind. Find the minimum possible total price o...
Solve the programming task below in a Python markdown code block. We need to write some code to return the original price of a product, the return type must be of type decimal and the number must be rounded to two decimal places. We will be given the sale price (discounted price), and the sale percentage, our job is ...
Solve the programming task below in a Python markdown code block. Given few numbers, you need to print out the digits that are not being used. Example: ```python unused_digits(12, 34, 56, 78) # "09" unused_digits(2015, 8, 26) # "3479" ``` Note: - Result string should be sorted - The test case won't pass Integer wi...
Solve the programming task below in a Python markdown code block. Each year in the castle of Dwarven King there is a competition in growing mushrooms among the dwarves. The competition is one of the most prestigious ones, and the winner gets a wooden salad bowl. This year's event brought together the best mushroom gro...
Solve the programming task below in a Python markdown code block. Imagine that you have a twin brother or sister. Having another person that looks exactly like you seems very unusual. It's hard to say if having something of an alter ego is good or bad. And if you do have a twin, then you very well know what it's like....
Solve the programming task below in a Python markdown code block. This kata is blatantly copied from inspired by This Kata Welcome this is the second in the series of the string iterations kata! Here we go! --------------------------------------------------------------------------------- We have a string s Let'...
Solve the programming task below in a Python markdown code block. One quite ordinary day Valera went to school (there's nowhere else he should go on a week day). In a maths lesson his favorite teacher Ms. Evans told students about divisors. Despite the fact that Valera loved math, he didn't find this particular topic ...
Solve the programming task below in a Python markdown code block. Serval is fighting with a monster. The health of the monster is H. In one attack, Serval can decrease the monster's health by A. There is no other way to decrease the monster's health. Serval wins when the monster's health becomes 0 or below. Find the n...
Solve the programming task below in a Python markdown code block. A **pandigital number** is one that has its digits from ```1``` to ```9``` occuring only once (they do not have the digit 0). The number ```169```, is the first pandigital square, higher than ```100```, having its square root, ```13```, pandigital too....
Solve the programming task below in a Python markdown code block. You are given an array of n integer numbers a_0, a_1, ..., a_{n} - 1. Find the distance between two closest (nearest) minimums in it. It is guaranteed that in the array a minimum occurs at least two times. -----Input----- The first line contains posi...
Solve the programming task below in a Python markdown code block. Alice and Bob play ping-pong with simplified rules. During the game, the player serving the ball commences a play. The server strikes the ball then the receiver makes a return by hitting the ball back. Thereafter, the server and receiver must alternate...
Solve the programming task below in a Python markdown code block. Programmer Vasya is studying a new programming language &K*. The &K* language resembles the languages of the C family in its syntax. However, it is more powerful, which is why the rules of the actual C-like languages are unapplicable to it. To fully und...
Solve the programming task below in a Python markdown code block. There are N cats. We number them from 1 through N. Each of the cats wears a hat. Cat i says: "there are exactly a_i different colors among the N - 1 hats worn by the cats except me." Determine whether there exists a sequence of colors of the hats that...
Solve the programming task below in a Python markdown code block. Our friendly friend Pete is really a nice person, but he tends to be rather... Inappropriate. And possibly loud, if given enough ethanol and free rein, so we ask you to write a function that should take its not always "clean" speech and cover as much a...
Solve the programming task below in a Python markdown code block. Stepan had a favorite string s which consisted of the lowercase letters of the Latin alphabet. After graduation, he decided to remember it, but it was a long time ago, so he can't now remember it. But Stepan remembers some information about the string...
Solve the programming task below in a Python markdown code block. This is the easy version of the problem. The difference between the versions is in the constraints on the array elements. You can make hacks only if all versions of the problem are solved. You are given an array [a_1, a_2, ..., a_n]. Your goal is to ...
Solve the programming task below in a Python markdown code block. You are given a string s consisting of lowercase English letters and a number k. Let's call a string consisting of lowercase English letters beautiful if the number of occurrences of each letter in that string is divisible by k. You are asked to find th...
Solve the programming task below in a Python markdown code block. This is the easy version of the problem. The only difference is that in this version q = 1. You can make hacks only if both versions of the problem are solved. There is a process that takes place on arrays a and b of length n and length n-1 respectivel...
Solve the programming task below in a Python markdown code block. Polycarp must pay exactly $n$ burles at the checkout. He has coins of two nominal values: $1$ burle and $2$ burles. Polycarp likes both kinds of coins equally. So he doesn't want to pay with more coins of one type than with the other. Thus, Polycarp wa...
Solve the programming task below in a Python markdown code block. Consider integer coordinates x, y in the Cartesian plan and three functions f, g, h defined by: ``` f: 1 <= x <= n, 1 <= y <= n --> f(x, y) = min(x, y) g: 1 <= x <= n, 1 <= y <= n --> g(x, y) = max(x, y) h: 1 <= x <= n, 1 <= y <= n --> h(x, y) = x + y `...
Solve the programming task below in a Python markdown code block. There is a rectangular grid of n rows of m initially-white cells each. Arkady performed a certain number (possibly zero) of operations on it. In the i-th operation, a non-empty subset of rows Ri and a non-empty subset of columns Ci are chosen. For each...
Solve the programming task below in a Python markdown code block. Vova decided to clean his room. The room can be represented as the coordinate axis $OX$. There are $n$ piles of trash in the room, coordinate of the $i$-th pile is the integer $p_i$. All piles have different coordinates. Let's define a total cleanup as...
Solve the programming task below in a Python markdown code block. This is an easier version of the next problem. In this version, $q = 0$. A sequence of integers is called nice if its elements are arranged in blocks like in $[3, 3, 3, 4, 1, 1]$. Formally, if two elements are equal, everything in between must also be ...
Solve the programming task below in a Python markdown code block. Vasya likes taking part in Codeforces contests. When a round is over, Vasya follows all submissions in the system testing tab. There are $n$ solutions, the $i$-th of them should be tested on $a_i$ tests, testing one solution on one test takes $1$ secon...
Solve the programming task below in a Python markdown code block. The game of Berland poker is played with a deck of $n$ cards, $m$ of which are jokers. $k$ players play this game ($n$ is divisible by $k$). At the beginning of the game, each player takes $\frac{n}{k}$ cards from the deck (so each card is taken by exa...
Solve the programming task below in a Python markdown code block. Given an array of integer $a_1, a_2, \ldots, a_n$. In one operation you can make $a_i := a_i + 1$ if $i < n$ and $a_i \leq a_{i + 1}$, or $i = n$ and $a_i \leq a_1$. You need to check whether the array $a_1, a_2, \ldots, a_n$ can become equal to the ar...
Solve the programming task below in a Python markdown code block. One day, Chef prepared D brand new dishes. He named the i-th dish by a string Si. After the cooking, he decided to categorize each of these D dishes as special or not. A dish Si is called special if it's name (i.e. the string Si) can be represented in ...
Solve the programming task below in a Python markdown code block. A sequence of square brackets is regular if by inserting symbols "+" and "1" into it, you can get a regular mathematical expression from it. For example, sequences "[[]][]", "[]" and "[[][[]]]" — are regular, at the same time "][", "[[]" and "[[]]][" — ...
Solve the programming task below in a Python markdown code block. You are given an array $a$, consisting of $n$ integers. Each position $i$ ($1 \le i \le n$) of the array is either locked or unlocked. You can take the values on the unlocked positions, rearrange them in any order and place them back into the unlocked ...
Solve the programming task below in a Python markdown code block. Given is a string S consisting of L and R. Let N be the length of S. There are N squares arranged from left to right, and the i-th character of S from the left is written on the i-th square from the left. The character written on the leftmost square is ...
Solve the programming task below in a Python markdown code block. In a building where Polycarp lives there are equal number of flats on each floor. Unfortunately, Polycarp don't remember how many flats are on each floor, but he remembers that the flats are numbered from 1 from lower to upper floors. That is, the first...
Solve the programming task below in a Python markdown code block. **This Kata is intended as a small challenge for my students** Create a function, called ``removeVowels`` (or ``remove_vowels``), that takes a string argument and returns that same string with all vowels removed (vowels are "a", "e", "i", "o", "u"). W...
Solve the programming task below in a Python markdown code block. An isogram is a word that has no repeating letters, consecutive or non-consecutive. Implement a function that determines whether a string that contains only letters is an isogram. Assume the empty string is an isogram. Ignore letter case. ```python is_...
Solve the programming task below in a Python markdown code block. A correct expression of the form a+b=c was written; a, b and c are non-negative integers without leading zeros. In this expression, the plus and equally signs were lost. The task is to restore the expression. In other words, one character '+' and one ch...
Solve the programming task below in a Python markdown code block. The Olympic Games in Bercouver are in full swing now. Here everyone has their own objectives: sportsmen compete for medals, and sport commentators compete for more convenient positions to give a running commentary. Today the main sport events take place...
Solve the programming task below in a Python markdown code block. Polycarp lives on a coordinate line at the point $x = 0$. He goes to his friend that lives at the point $x = a$. Polycarp can move only from left to right, he can pass one unit of length each second. Now it's raining, so some segments of his way are in...
Solve the programming task below in a Python markdown code block. Methodius received an email from his friend Polycarp. However, Polycarp's keyboard is broken, so pressing a key on it once may cause the corresponding symbol to appear more than once (if you press a key on a regular keyboard, it prints exactly one symbo...
Solve the programming task below in a Python markdown code block. We often go to supermarkets to buy some fruits or vegetables, and on the tag there prints the price for a kilo. But in some supermarkets, when asked how much the items are, the clerk will say that $a$ yuan for $b$ kilos (You don't need to care about wha...
Solve the programming task below in a Python markdown code block. ##Background - the Collatz Conjecture: Imagine you are given a positive integer, `n`, then: * if `n` is even, calculate: `n / 2` * if `n` is odd, calculate: `3 * n + 1` Repeat until your answer is `1`. The Collatz conjecture states that performing th...
Solve the programming task below in a Python markdown code block. Sunuke received a d-dimensional hypercube with a side length of l1 × ... × ld as a birthday present. Sunuke placed this rectangular parallelepiped so that the range of the i-th coordinate was 0 or more and li or less, and ate the part that satisfied x1 ...
Solve the programming task below in a Python markdown code block. As you have noticed, there are lovely girls in Arpa’s land. People in Arpa's land are numbered from 1 to n. Everyone has exactly one crush, i-th person's crush is person with the number crush_{i}. [Image] Someday Arpa shouted Owf loudly from the top ...
Solve the programming task below in a Python markdown code block. Yuki made a sugoroku so that everyone can play at the children's association event. In this sugoroku, squares are lined up in a ring, and each square has an integer of 1 or more written on it. The player chooses a square as a starting point and places ...
Solve the programming task below in a Python markdown code block. Anatoly lives in the university dorm as many other students do. As you know, cockroaches are also living there together with students. Cockroaches might be of two colors: black and red. There are n cockroaches living in Anatoly's room. Anatoly just mad...
Solve the programming task below in a Python markdown code block. You can print your name on a billboard ad. Find out how much it will cost you. Each letter has a default price of £30, but that can be different if you are given 2 parameters instead of 1. You can not use multiplier "*" operator. If your name would be...
Solve the programming task below in a Python markdown code block. # Task John is new to spreadsheets. He is well aware of rows and columns, but he is not comfortable with spreadsheets numbering system. ``` Spreadsheet Row Column A1 R1C1 D5 R5C4 AA48 ...
Solve the programming task below in a Python markdown code block. The north country is conquered by the great shogun-sama (which means king). Recently many beautiful dice which were made by order of the great shogun-sama were given to all citizens of the country. All citizens received the beautiful dice with a tear of...
Solve the programming task below in a Python markdown code block. Your program fails again. This time it gets "Wrong answer on test 233". This is the harder version of the problem. In this version, $1 \le n \le 2\cdot10^5$. You can hack this problem if you locked it. But you can hack the previous problem only if you ...
Solve the programming task below in a Python markdown code block. Bad news came to Mike's village, some thieves stole a bunch of chocolates from the local factory! Horrible! Aside from loving sweet things, thieves from this area are known to be very greedy. So after a thief takes his number of chocolates for himself...
Solve the programming task below in a Python markdown code block. You are given an array $a$ of length $n$. The array is called 3SUM-closed if for all distinct indices $i$, $j$, $k$, the sum $a_i + a_j + a_k$ is an element of the array. More formally, $a$ is 3SUM-closed if for all integers $1 \leq i < j < k \leq n$, t...
Solve the programming task below in a Python markdown code block. Mr. Kitayuta has kindly given you a string s consisting of lowercase English letters. You are asked to insert exactly n lowercase English letters into s to make it a palindrome. (A palindrome is a string that reads the same forward and backward. For exa...
Solve the programming task below in a Python markdown code block. Snuke has N integers. Among them, the smallest is A, and the largest is B. We are interested in the sum of those N integers. How many different possible sums there are? Constraints * 1 ≤ N,A,B ≤ 10^9 * A and B are integers. Input Input is given from...
Solve the programming task below in a Python markdown code block. Dr. Asimov, a robotics researcher, loves to research, but hates houseworks and his house were really dirty. So, he has developed a cleaning robot. As shown in the following figure, his house has 9 rooms, where each room is identified by an alphabet: ...
Solve the programming task below in a Python markdown code block. Polo, the Penguin, likes numbers. He says that the goodness of a number is itself multiplied by the number of digits in it's decimal representation. For example, the goodness of the integer 474 is 474*3 = 1422. Help him to count the sum of goodness of a...
Solve the programming task below in a Python markdown code block. There are $n$ people sitting in a circle, numbered from $1$ to $n$ in the order in which they are seated. That is, for all $i$ from $1$ to $n-1$, the people with id $i$ and $i+1$ are adjacent. People with id $n$ and $1$ are adjacent as well. The person...
Solve the programming task below in a Python markdown code block. Mr. Santa asks all the great programmers of the world to solve a trivial problem. He gives them an integer m and asks for the number of positive integers n, such that the factorial of n ends with exactly m zeroes. Are you among those great programmers w...
Solve the programming task below in a Python markdown code block. Little Tanya decided to present her dad a postcard on his Birthday. She has already created a message — string s of length n, consisting of uppercase and lowercase English letters. Tanya can't write yet, so she found a newspaper and decided to cut out t...
Solve the programming task below in a Python markdown code block. This is related to my other Kata about cats and dogs. # Kata Task I have a cat and a dog which I got as kitten / puppy. I forget when that was, but I do know their current ages as `catYears` and `dogYears`. Find how long I have owned each of my pets...
Solve the programming task below in a Python markdown code block. It is Borya's eleventh birthday, and he has got a great present: n cards with numbers. The i-th card has the number a_{i} written on it. Borya wants to put his cards in a row to get one greater number. For example, if Borya has cards with numbers 1, 31,...
Solve the programming task below in a Python markdown code block. Roma works in a company that sells TVs. Now he has to prepare a report for the last year. Roma has got a list of the company's incomes. The list is a sequence that consists of n integers. The total income of the company is the sum of all integers in se...
Solve the programming task below in a Python markdown code block. Given are 1-digit positive integers a and b. Consider these two strings: the concatenation of b copies of the digit a, and the concatenation of a copies of the digit b. Which of these is lexicographically smaller? -----Constraints----- - 1 \leq a \leq...
Solve the programming task below in a Python markdown code block. It's now 260 AD. Shapur, being extremely smart, became the King of Persia. He is now called Shapur, His majesty King of kings of Iran and Aniran. Recently the Romans declared war on Persia. They dreamed to occupy Armenia. In the recent war, the Romans ...
Solve the programming task below in a Python markdown code block. We have a board with H horizontal rows and W vertical columns of squares. There is a bishop at the top-left square on this board. How many squares can this bishop reach by zero or more movements? Here the bishop can only move diagonally. More formally,...
Solve the programming task below in a Python markdown code block. Snuke has N integers: 1,2,\ldots,N. He will choose K of them and give those to Takahashi. How many ways are there to choose K consecutive integers? Constraints * All values in input are integers. * 1 \leq K \leq N \leq 50 Input Input is given from ...
Solve the programming task below in a Python markdown code block. Sasha grew up and went to first grade. To celebrate this event her mother bought her a multiplication table $M$ with $n$ rows and $n$ columns such that $M_{ij}=a_i \cdot a_j$ where $a_1, \dots, a_n$ is some sequence of positive integers. Of course, the...
Solve the programming task below in a Python markdown code block. You are given a program that consists of $n$ instructions. Initially a single variable $x$ is assigned to $0$. Afterwards, the instructions are of two types: increase $x$ by $1$; decrease $x$ by $1$. You are given $m$ queries of the following format:...
Solve the programming task below in a Python markdown code block. Developers often face with regular expression patterns. A pattern is usually defined as a string consisting of characters and metacharacters that sets the rules for your search. These patterns are most often used to check whether a particular string mee...
Solve the programming task below in a Python markdown code block. Fedya studies in a gymnasium. Fedya's maths hometask is to calculate the following expression:(1^{n} + 2^{n} + 3^{n} + 4^{n}) mod 5 for given value of n. Fedya managed to complete the task. Can you? Note that given number n can be extremely large (e.g....
Solve the programming task below in a Python markdown code block. Kuroni is very angry at the other setters for using him as a theme! As a punishment, he forced them to solve the following problem: You have an array $a$ consisting of $n$ positive integers. An operation consists of choosing an element and either addin...
Solve the programming task below in a Python markdown code block. Sonya decided to organize an exhibition of flowers. Since the girl likes only roses and lilies, she decided that only these two kinds of flowers should be in this exhibition. There are $n$ flowers in a row in the exhibition. Sonya can put either a rose...
Solve the programming task below in a Python markdown code block. Long ago, when Petya was a schoolboy, he was very much interested in the Petr# language grammar. During one lesson Petya got interested in the following question: how many different continuous substrings starting with the sbegin and ending with the send...
Solve the programming task below in a Python markdown code block. In Aizuwakamatsu City, there is a first city called "Tokaichi" on January 10th every year. This Tokaichi has a history of about 600 years and is the largest first city in the Aizu region. It is also well known that Okiagari-koboshi, a familiar lucky cha...
Solve the programming task below in a Python markdown code block. Little Vasya loves orange juice very much. That's why any food and drink in his kitchen necessarily contains orange juice. There are n drinks in his fridge, the volume fraction of orange juice in the i-th drink equals pi percent. One day Vasya decided ...
Solve the programming task below in a Python markdown code block. Patrick has just finished writing a message to his sweetheart Stacey when he noticed that the message didn't look fancy. Patrick was nervous while writing the message, so some of the letters there were lowercase and some of them were uppercase. Patrick...
Solve the programming task below in a Python markdown code block. There are N people (with different names) and K clubs. For each club you know the list of members (so you have K unordered lists). Each person can be a member of many clubs (and also 0 clubs) and two different clubs might have exactly the same members. ...
Solve the programming task below in a Python markdown code block. Mike received an array $a$ of length $n$ as a birthday present and decided to test how pretty it is. An array would pass the $i$-th prettiness test if there is a way to get an array with a sum of elements totaling $s_i$, using some number (possibly zer...
Solve the programming task below in a Python markdown code block. # Task Your task is to find the similarity of given sorted arrays `a` and `b`, which is defined as follows: you take the number of elements which are present in both arrays and divide it by the number of elements which are present in at least one a...
Solve the programming task below in a Python markdown code block. Dolphin resides in two-dimensional Cartesian plane, with the positive x-axis pointing right and the positive y-axis pointing up. Currently, he is located at the point (sx,sy). In each second, he can move up, down, left or right by a distance of 1. Here,...
Solve the programming task below in a Python markdown code block. You like playing chess tournaments online. In your last tournament you played $n$ games. For the sake of this problem, each chess game is either won or lost (no draws). When you lose a game you get $0$ points. When you win you get $1$ or $2$ points: if...
Solve the programming task below in a Python markdown code block. Vasya commutes by train every day. There are n train stations in the city, and at the i-th station it's possible to buy only tickets to stations from i + 1 to a_{i} inclusive. No tickets are sold at the last station. Let ρ_{i}, j be the minimum number ...
Solve the programming task below in a Python markdown code block. After many years of research, Ikta has acquired the ability to predict the future! The time and money he spent on this research was enormous, but it's finally time to be rewarded. To get the money back, Ikta decided to start investing in stocks. Ikta d...
Solve the programming task below in a Python markdown code block. Programmer Vasya is studying a new programming language &K*. The &K* language resembles the languages of the C family in its syntax. However, it is more powerful, which is why the rules of the actual C-like languages are unapplicable to it. To fully und...
Solve the programming task below in a Python markdown code block. In the army, it isn't easy to form a group of soldiers that will be effective on the battlefield. The communication is crucial and thus no two soldiers should share a name (what would happen if they got an order that Bob is a scouter, if there are two B...
Solve the programming task below in a Python markdown code block. AtCoDeer the deer found two rectangles lying on the table, each with height 1 and width W. If we consider the surface of the desk as a two-dimensional plane, the first rectangle covers the vertical range of [0,1] and the horizontal range of [a,a+W], and...
Solve the programming task below in a Python markdown code block. Student Valera is an undergraduate student at the University. His end of term exams are approaching and he is to pass exactly n exams. Valera is a smart guy, so he will be able to pass any exam he takes on his first try. Besides, he can take several exa...
Solve the programming task below in a Python markdown code block. Consider a football tournament where n teams participate. Each team has two football kits: for home games, and for away games. The kit for home games of the i-th team has color x_{i} and the kit for away games of this team has color y_{i} (x_{i} ≠ y_{i}...