question
large_stringlengths
265
13.2k
Solve the programming task below in a Python markdown code block. The only difference between the two versions is that this version asks the maximal possible answer. Homer likes arrays a lot. Today he is painting an array $a_1, a_2, \dots, a_n$ with two kinds of colors, white and black. A painting assignment for $a_1...
Solve the programming task below in a Python markdown code block. Palindrome Problem Statement Find the number of palindromes closest to the integer n. Note that the non-negative integer x is the number of palindromes, which means that the character string in which x is expressed in decimal notation and the charact...
Solve the programming task below in a Python markdown code block. Let's define the cost of a string s as the number of index pairs i and j (1 ≀ i < j < |s|) such that s_i = s_j and s_{i+1} = s_{j+1}. You are given two positive integers n and k. Among all strings with length n that contain only the first k characters ...
Solve the programming task below in a Python markdown code block. Marina loves strings of the same length and Vasya loves when there is a third string, different from them in exactly t characters. Help Vasya find at least one such string. More formally, you are given two strings s_1, s_2 of length n and number t. Let...
Solve the programming task below in a Python markdown code block. It's a Pokemon battle! Your task is to calculate the damage that a particular move would do using the following formula (not the actual one from the game): Where: * attack = your attack power * defense = the opponent's defense * effectiveness = the ef...
Solve the programming task below in a Python markdown code block. Igor the analyst fell asleep on the work and had a strange dream. In the dream his desk was crowded with computer mice, so he bought a mousetrap to catch them. The desk can be considered as an infinite plane, then the mousetrap is a rectangle which sid...
Solve the programming task below in a Python markdown code block. Heidi has finally found the mythical Tree of Life – a legendary combinatorial structure which is said to contain a prophecy crucially needed to defeat the undead armies. On the surface, the Tree of Life is just a regular undirected tree well-known from...
Solve the programming task below in a Python markdown code block. A popular reality show is recruiting a new cast for the third season! $n$ candidates numbered from $1$ to $n$ have been interviewed. The candidate $i$ has aggressiveness level $l_i$, and recruiting this candidate will cost the show $s_i$ roubles. The s...
Solve the programming task below in a Python markdown code block. Polycarp plays a computer game (yet again). In this game, he fights monsters using magic spells. There are two types of spells: fire spell of power $x$ deals $x$ damage to the monster, and lightning spell of power $y$ deals $y$ damage to the monster an...
Solve the programming task below in a Python markdown code block. Let's call an array good if there is an element in the array that equals to the sum of all other elements. For example, the array $a=[1, 3, 3, 7]$ is good because there is the element $a_4=7$ which equals to the sum $1 + 3 + 3$. You are given an array ...
Solve the programming task below in a Python markdown code block. In Aizuwakamatsu Village, which is located far north of Aizuwakamatsu City, a bridge called "Yabashi" is the only way to move to the surrounding villages. Despite the large number of passers-by, the bridge is so old that it is almost broken. <image> ...
Solve the programming task below in a Python markdown code block. Valera loves to participate in competitions. Especially in programming contests. Today he has participated in the contest with his team, consisting of n students (including Valera). This contest was an individual competition, so each student in the team...
Solve the programming task below in a Python markdown code block. Assume we take a number `x` and perform any one of the following operations: ```Pearl a) Divide x by 3 (if it is divisible by 3), or b) Multiply x by 2 ``` After each operation, we write down the result. If we start with `9`, we can get a sequence such ...
Solve the programming task below in a Python markdown code block. We have weather records at AtCoder Town for some consecutive three days. A string of length 3, S, represents the records - if the i-th character is S, it means it was sunny on the i-th day; if that character is R, it means it was rainy on that day. Find...
Solve the programming task below in a Python markdown code block. Vova again tries to play some computer card game. The rules of deck creation in this game are simple. Vova is given an existing deck of n cards and a magic number k. The order of the cards in the deck is fixed. Each card has a number written on it; num...
Solve the programming task below in a Python markdown code block. On a circle lie $2n$ distinct points, with the following property: however you choose $3$ chords that connect $3$ disjoint pairs of points, no point strictly inside the circle belongs to all $3$ chords. The points are numbered $1, \, 2, \, \dots, \, 2n$...
Solve the programming task below in a Python markdown code block. There is a square matrix n Γ— n, consisting of non-negative integer numbers. You should find such a way on it that * starts in the upper left cell of the matrix; * each following cell is to the right or down from the current cell; * the way end...
Solve the programming task below in a Python markdown code block. Pavel made a photo of his favourite stars in the sky. His camera takes a photo of all points of the sky that belong to some rectangle with sides parallel to the coordinate axes. Strictly speaking, it makes a photo of all points with coordinates $(x, y)...
Solve the programming task below in a Python markdown code block. In fact, the problems E1 and E2 do not have much in common. You should probably think of them as two separate problems. You are given an integer array $a[1 \ldots n] = [a_1, a_2, \ldots, a_n]$. Let us consider an empty deque (double-ended queue). A de...
Solve the programming task below in a Python markdown code block. Let’s try a dice puzzle. The rules of this puzzle are as follows. 1. Dice with six faces as shown in Figure 1 are used in the puzzle. <image> Figure 1: Faces of a die 2. With twenty seven such dice, a 3 Γ— 3 Γ— 3 cube is built as shown in Figure 2. <...
Solve the programming task below in a Python markdown code block. Implement a function to calculate the sum of the numerical values in a nested list. For example : ```python sum_nested([1, [2, [3, [4]]]]) -> 10 ``` Write your solution by modifying this code: ```python def sum_nested(lst): ``` Your solution shoul...
Solve the programming task below in a Python markdown code block. Consider the numbers `6969` and `9116`. When you rotate them `180 degrees` (upside down), these numbers remain the same. To clarify, if we write them down on a paper and turn the paper upside down, the numbers will be the same. Try it and see! Some numb...
Solve the programming task below in a Python markdown code block. Polycarp has spent the entire day preparing problems for you. Now he has to sleep for at least $a$ minutes to feel refreshed. Polycarp can only wake up by hearing the sound of his alarm. So he has just fallen asleep and his first alarm goes off in $b$ ...
Solve the programming task below in a Python markdown code block. In Finite Encyclopedia of Integer Sequences (FEIS), all integer sequences of lengths between 1 and N (inclusive) consisting of integers between 1 and K (inclusive) are listed. Let the total number of sequences listed in FEIS be X. Among those sequences,...
Solve the programming task below in a Python markdown code block. William has a favorite bracket sequence. Since his favorite sequence is quite big he provided it to you as a sequence of positive integers $c_1, c_2, \dots, c_n$ where $c_i$ is the number of consecutive brackets "(" if $i$ is an odd number or the number...
Solve the programming task below in a Python markdown code block. A recently found Ancient Prophesy is believed to contain the exact Apocalypse date. The prophesy is a string that only consists of digits and characters "-". We'll say that some date is mentioned in the Prophesy if there is a substring in the Prophesy ...
Solve the programming task below in a Python markdown code block. In some game by Playrix it takes t minutes for an oven to bake k carrot cakes, all cakes are ready at the same moment t minutes after they started baking. Arkady needs at least n cakes to complete a task, but he currently don't have any. However, he has...
Solve the programming task below in a Python markdown code block. Takahashi and Aoki are playing a stone-taking game. Initially, there are N piles of stones, and the i-th pile contains A_i stones and has an associated integer K_i. Starting from Takahashi, Takahashi and Aoki take alternate turns to perform the followin...
Solve the programming task below in a Python markdown code block. John Doe has an n Γ— m table. John Doe can paint points in some table cells, not more than one point in one table cell. John Doe wants to use such operations to make each square subtable of size n Γ— n have exactly k points. John Doe wondered, how many d...
Solve the programming task below in a Python markdown code block. The research center Q has developed a new multi-core processor. The processor consists of n cores and has k cells of cache memory. Consider the work of this processor. At each cycle each core of the processor gets one instruction: either do nothing, or...
Solve the programming task below in a Python markdown code block. Read problems statements in Mandarin Chinese, Russian and Vietnamese as well. Little Egor likes to play with positive integers and their divisors. Bigger the number to play with, more the fun! The boy asked you to come up with an algorithm, that could ...
Solve the programming task below in a Python markdown code block. You are given a string S of length N consisting of A, B and C, and an integer K which is between 1 and N (inclusive). Print the string S after lowercasing the K-th character in it. -----Constraints----- - 1 ≀ N ≀ 50 - 1 ≀ K ≀ N - S is a string of le...
Solve the programming task below in a Python markdown code block. When you want to get the square of a binomial of two variables x and y, you will have: `$(x+y)^2 = x^2 + 2xy + y ^2$` And the cube: `$(x+y)^3 = x^3 + 3x^2y + 3xy^2 +y^3$` It is known from many centuries ago that for an exponent n, the result of a bi...
Solve the programming task below in a Python markdown code block. problem In the area where Kazakhstan is now located, there used to be a trade route called the "Silk Road". There are N + 1 cities on the Silk Road, numbered from west as city 0, city 1, ..., city N. The distance between city i -1 and city i (1 ≀ i ≀ ...
Solve the programming task below in a Python markdown code block. There was a big bank robbery in Tablecity. In order to catch the thief, the President called none other than Albert – Tablecity’s Chief of Police. Albert does not know where the thief is located, but he does know how he moves. Tablecity can be represen...
Solve the programming task below in a Python markdown code block. Dora loves adventures quite a lot. During some journey she encountered an amazing city, which is formed by $n$ streets along the Eastern direction and $m$ streets across the Southern direction. Naturally, this city has $nm$ intersections. At any interse...
Solve the programming task below in a Python markdown code block. Note that the memory limit is unusual. You are given an integer n and two sequences a_1, a_2, ..., a_n and b_1, b_2, ..., b_n. Let's call a set of integers S such that S βŠ† \{1, 2, 3, ..., n\} strange, if, for every element i of S, the following condit...
Solve the programming task below in a Python markdown code block. You are given a colored permutation $p_1, p_2, \dots, p_n$. The $i$-th element of the permutation has color $c_i$. Let's define an infinite path as infinite sequence $i, p[i], p[p[i]], p[p[p[i]]] \dots$ where all elements have same color ($c[i] = c[p[i...
Solve the programming task below in a Python markdown code block. Ichihime is the current priestess of the Mahjong Soul Temple. She claims to be human, despite her cat ears. These days the temple is holding a math contest. Usually, Ichihime lacks interest in these things, but this time the prize for the winner is her...
Solve the programming task below in a Python markdown code block. JAG mock qualifying practice session The ACM-ICPC OB / OG Association (Japanese Alumni Group; JAG) has N questions in stock of questions to be asked in the mock contest, and each question is numbered with an integer from 1 to N. Difficulty evaluation a...
Solve the programming task below in a Python markdown code block. Create a function that takes any sentence and redistributes the spaces (and adds additional spaces if needed) so that each word starts with a vowel. The letters should all be in the same order but every vowel in the sentence should be the start of a new...
Solve the programming task below in a Python markdown code block. Vasya wants to turn on Christmas lights consisting of m bulbs. Initially, all bulbs are turned off. There are n buttons, each of them is connected to some set of bulbs. Vasya can press any of these buttons. When the button is pressed, it turns on all th...
Solve the programming task below in a Python markdown code block. BerkomnadzorΒ β€” Federal Service for Supervision of Communications, Information Technology and Mass MediaΒ β€” is a Berland federal executive body that protects ordinary residents of Berland from the threats of modern internet. Berkomnadzor maintains a list...
Solve the programming task below in a Python markdown code block. Ringo is giving a present to Snuke. Ringo has found out that Snuke loves yakiniku (a Japanese term meaning grilled meat. yaki: grilled, niku: meat). He supposes that Snuke likes grilled things starting with `YAKI` in Japanese, and does not like other t...
Solve the programming task below in a Python markdown code block. Write a program which reads two integers x and y, and prints them in ascending order. Constraints * 0 ≀ x, y ≀ 10000 * the number of datasets ≀ 3000 Input The input consists of multiple datasets. Each dataset consists of two integers x and y separat...
Solve the programming task below in a Python markdown code block. Today, Yasser and Adel are at the shop buying cupcakes. There are $n$ cupcake types, arranged from $1$ to $n$ on the shelf, and there are infinitely many of each type. The tastiness of a cupcake of type $i$ is an integer $a_i$. There are both tasty and ...
Solve the programming task below in a Python markdown code block. Gildong was hiking a mountain, walking by millions of trees. Inspired by them, he suddenly came up with an interesting idea for trees in data structures: What if we add another edge in a tree? Then he found that such tree-like graphs are called 1-trees...
Solve the programming task below in a Python markdown code block. Imagine a city with n horizontal streets crossing m vertical streets, forming an (n - 1) Γ— (m - 1) grid. In order to increase the traffic flow, mayor of the city has decided to make each street one way. This means in each horizontal street, the traffic ...
Solve the programming task below in a Python markdown code block. When l is an odd number, the median of l numbers a_1, a_2, ..., a_l is the (\frac{l+1}{2})-th largest value among a_1, a_2, ..., a_l. You are given N numbers X_1, X_2, ..., X_N, where N is an even number. For each i = 1, 2, ..., N, let the median of X_...
Solve the programming task below in a Python markdown code block. An NBA game runs 48 minutes (Four 12 minute quarters). Players do not typically play the full game, subbing in and out as necessary. Your job is to extrapolate a player's points per game if they played the full 48 minutes. Write a function that takes t...
Solve the programming task below in a Python markdown code block. Childan is making up a legendary story and trying to sell his forgery β€” a necklace with a strong sense of "Wu" to the Kasouras. But Mr. Kasoura is challenging the truth of Childan's story. So he is going to ask a few questions about Childan's so-called ...
Solve the programming task below in a Python markdown code block. Let's denote that some array $b$ is bad if it contains a subarray $b_l, b_{l+1}, \dots, b_{r}$ of odd length more than $1$ ($l < r$ and $r - l + 1$ is odd) such that $\forall i \in \{0, 1, \dots, r - l\}$ $b_{l + i} = b_{r - i}$. If an array is not bad...
Solve the programming task below in a Python markdown code block. In the 17th century, Fermat wrote that he proved for any integer $n \geq 3$, there exist no positive integers $x$, $y$, $z$ such that $x^n + y^n = z^n$. However he never disclosed the proof. Later, this claim was named Fermat's Last Theorem or Fermat's ...
Solve the programming task below in a Python markdown code block. Sig has built his own keyboard. Designed for ultimate simplicity, this keyboard only has 3 keys on it: the 0 key, the 1 key and the backspace key. To begin with, he is using a plain text editor with this keyboard. This editor always displays one string ...
Solve the programming task below in a Python markdown code block. Kolya Gerasimov loves kefir very much. He lives in year 1984 and knows all the details of buying this delicious drink. One day, as you probably know, he found himself in year 2084, and buying kefir there is much more complicated. Kolya is hungry, so he...
Solve the programming task below in a Python markdown code block. In this Kata you are a game developer and have programmed the #1 MMORPG(Massively Multiplayer Online Role Playing Game) worldwide!!! Many suggestions came across you to make the game better, one of which you are interested in and will start working on a...
Solve the programming task below in a Python markdown code block. ## Task Given a positive integer `n`, calculate the following sum: ``` n + n/2 + n/4 + n/8 + ... ``` All elements of the sum are the results of integer division. ## Example ``` 25 => 25 + 12 + 6 + 3 + 1 = 47 ``` Write your solution by modifyin...
Solve the programming task below in a Python markdown code block. As bad weather continues and vegetable prices soar, Seven-Eleven is offering customers bulk purchase sales of vegetables. The store is very busy, as you can get vegetables that are hard to find in stores at reasonable prices. One day, a group of three ...
Solve the programming task below in a Python markdown code block. Two neighboring kingdoms decided to build a wall between them with some gates to enable the citizens to go from one kingdom to another. Each time a citizen passes through a gate, he has to pay one silver coin. The world can be represented by the first ...
Solve the programming task below in a Python markdown code block. Little boy Gerald studies at school which is quite far from his house. That's why he has to go there by bus every day. The way from home to school is represented by a segment of a straight line; the segment contains exactly n + 1 bus stops. All of them ...
Solve the programming task below in a Python markdown code block. Cyael is a teacher at a very famous school in Byteland and she is known by her students for being very polite to them and also to encourage them to get good marks on their tests. Then, if they get good marks she will reward them with candies :) However,...
Solve the programming task below in a Python markdown code block. Given a string made up of letters a, b, and/or c, switch the position of letters a and b (change a to b and vice versa). Leave any incidence of c untouched. Example: 'acb' --> 'bca' 'aabacbaa' --> 'bbabcabb' Write your solution by modifying this code...
Solve the programming task below in a Python markdown code block. Let's define a good tree:It is a tree with k * n nodes labeled from 0 to k * n - 1 Node i and node j are not adjacent, for all 0 ≀ i, j < k * n such that i div k = j div k (here div means integer division. E.g. 7 div 2 = 3) Given n and k, how many dif...
Solve the programming task below in a Python markdown code block. # Task Given a sorted array of integers `A`, find such an integer x that the value of `abs(A[0] - x) + abs(A[1] - x) + ... + abs(A[A.length - 1] - x)` is the smallest possible (here abs denotes the `absolute value`). If there are several possible ans...
Solve the programming task below in a Python markdown code block. At the first holiday in spring, the town Shortriver traditionally conducts a flower festival. Townsfolk wear traditional wreaths during these festivals. Each wreath contains exactly $k$ flowers. The work material for the wreaths for all $n$ citizens of...
Solve the programming task below in a Python markdown code block. Your task is to sort a given string. Each word in the string will contain a single number. This number is the position the word should have in the result. Note: Numbers can be from 1 to 9. So 1 will be the first word (not 0). If the input string is em...
Solve the programming task below in a Python markdown code block. Snuke has decided to construct a string that starts with A and ends with Z, by taking out a substring of a string s (that is, a consecutive part of s). Find the greatest length of the string Snuke can construct. Here, the test set guarantees that there ...
Solve the programming task below in a Python markdown code block. Given is a positive even number N. Find the number of strings s of length N consisting of `A`, `B`, and `C` that satisfy the following condition: * s can be converted to the empty string by repeating the following operation: * Choose two consecutive c...
Solve the programming task below in a Python markdown code block. A number is self-descriptive when the n'th digit describes the amount n appears in the number. E.g. 21200: There are two 0's in the number, so the first digit is 2. There is one 1 in the number, so the second digit is 1. There are two 2's in the num...
Solve the programming task below in a Python markdown code block. This version of the problem differs from the next one only in the constraint on n. Note that the memory limit in this problem is lower than in others. You have a vertical strip with n cells, numbered consecutively from 1 to n from top to bottom. You ...
Solve the programming task below in a Python markdown code block. Limak and Radewoosh are going to compete against each other in the upcoming algorithmic contest. They are equally skilled but they won't solve problems in the same order. There will be n problems. The i-th problem has initial score p_{i} and it takes e...
Solve the programming task below in a Python markdown code block. # Background My pet bridge-maker ants are marching across a terrain from left to right. If they encounter a gap, the first one stops and then next one climbs over him, then the next, and the next, until a bridge is formed across the gap. What clever...
Solve the programming task below in a Python markdown code block. There is an N-car train. You are given an integer i. Find the value of j such that the following statement is true: "the i-th car from the front of the train is the j-th car from the back." -----Constraints----- - 1 \leq N \leq 100 - 1 \leq i \leq N ...
Solve the programming task below in a Python markdown code block. As you know, majority of students and teachers of Summer Informatics School live in Berland for the most part of the year. Since corruption there is quite widespread, the following story is not uncommon. Elections are coming. You know the number of vot...
Solve the programming task below in a Python markdown code block. A triangular number is the number of dots in an equilateral triangle uniformly filled with dots. For example, three dots can be arranged in a triangle; thus three is a triangular number. The n-th triangular number is the number of dots in a triangle wit...
Solve the programming task below in a Python markdown code block. Read problems statements in Mandarin Chinese and Russian as well. Petr, Nikita G. and Nikita are the most influential music critics in Saint-Petersburg. They have recently downloaded their favorite band's new album and going to listen to it. Nikita cl...
Solve the programming task below in a Python markdown code block. Devu and his brother love each other a lot. As they are super geeks, they only like to play with arrays. They are given two arrays a and b by their father. The array a is given to Devu and b to his brother. As Devu is really a naughty kid, he wants th...
Solve the programming task below in a Python markdown code block. VK news recommendation system daily selects interesting publications of one of $n$ disjoint categories for each user. Each publication belongs to exactly one category. For each category $i$ batch algorithm selects $a_i$ publications. The latest A/B tes...
Solve the programming task below in a Python markdown code block. Tokitsukaze is playing a game derivated from Japanese mahjong. In this game, she has three tiles in her hand. Each tile she owns is a suited tile, which means it has a suit (manzu, pinzu or souzu) and a number (a digit ranged from $1$ to $9$). In this p...
Solve the programming task below in a Python markdown code block. You're given an array $a$ of length $n$. You can perform the following operation on it as many times as you want: Pick two integers $i$ and $j$ $(1 \le i,j \le n)$ such that $a_i+a_j$ is odd, then swap $a_i$ and $a_j$. What is lexicographically the s...
Solve the programming task below in a Python markdown code block. There are n children in Jzzhu's school. Jzzhu is going to give some candies to them. Let's number all the children from 1 to n. The i-th child wants to get at least a_{i} candies. Jzzhu asks children to line up. Initially, the i-th child stands at the ...
Solve the programming task below in a Python markdown code block. Create a function that transforms any positive number to a string representing the number in words. The function should work for all numbers between 0 and 999999. ### Examples ``` number2words(0) ==> "zero" number2words(1) ==> "one" number2words(...
Solve the programming task below in a Python markdown code block. Vasya follows a basketball game and marks the distances from which each team makes a throw. He knows that each successful throw has value of either 2 or 3 points. A throw is worth 2 points if the distance it was made from doesn't exceed some value of d ...
Solve the programming task below in a Python markdown code block. Adilbek was assigned to a special project. For Adilbek it means that he has $n$ days to run a special program and provide its results. But there is a problem: the program needs to run for $d$ days to calculate the results. Fortunately, Adilbek can opti...
Solve the programming task below in a Python markdown code block. You are given a string S of length n with each character being one of the first m lowercase English letters. Calculate how many different strings T of length n composed from the first m lowercase English letters exist such that the length of LCS (long...
Solve the programming task below in a Python markdown code block. In cryptography, Caesar cipher is one of the simplest and most widely known encryption method. Caesar cipher is a type of substitution cipher in which each letter in the text is replaced by a letter some fixed number of positions down the alphabet. For ...
Solve the programming task below in a Python markdown code block. One day, early in the morning, you decided to buy yourself a bag of chips in the nearby store. The store has chips of $n$ different flavors. A bag of the $i$-th flavor costs $a_i$ burles. The store may run out of some flavors, so you'll decide which on...
Solve the programming task below in a Python markdown code block. You are given an array $a$ of length $2n$. Consider a partition of array $a$ into two subsequences $p$ and $q$ of length $n$ each (each element of array $a$ should be in exactly one subsequence: either in $p$ or in $q$). Let's sort $p$ in non-decreasin...
Solve the programming task below in a Python markdown code block. Vasiliy lives at point (a, b) of the coordinate plane. He is hurrying up to work so he wants to get out of his house as soon as possible. New app suggested n available Beru-taxi nearby. The i-th taxi is located at point (x_{i}, y_{i}) and moves with a s...
Solve the programming task below in a Python markdown code block. Is there anything better than going to the zoo after a tiresome week at work? No wonder Grisha feels the same while spending the entire weekend accompanied by pretty striped zebras. Inspired by this adventure and an accidentally found plasticine pack ...
Solve the programming task below in a Python markdown code block. You're creating a game level for some mobile game. The level should contain some number of cells aligned in a row from left to right and numbered with consecutive integers starting from $1$, and in each cell you can either put a platform or leave it emp...
Solve the programming task below in a Python markdown code block. Your task is to return the sum of Triangular Numbers up-to-and-including the `nth` Triangular Number. Triangular Number: "any of the series of numbers (1, 3, 6, 10, 15, etc.) obtained by continued summation of the natural numbers 1, 2, 3, 4, 5, etc." ...
Solve the programming task below in a Python markdown code block. Alice and Bob are controlling a robot. They each have one switch that controls the robot. Alice started holding down her button A second after the start-up of the robot, and released her button B second after the start-up. Bob started holding down his...
Solve the programming task below in a Python markdown code block. There's a new security company in Paris, and they decided to give their employees an algorithm to make first name recognition faster. In the blink of an eye, they can now detect if a string is a first name, no matter if it is a one-word name or an hyphe...
Solve the programming task below in a Python markdown code block. You a captain of a ship. Initially you are standing in a point $(x_1, y_1)$ (obviously, all positions in the sea can be described by cartesian plane) and you want to travel to a point $(x_2, y_2)$. You know the weather forecast β€” the string $s$ of len...
Solve the programming task below in a Python markdown code block. Gennady is one of the best child dentists in Berland. Today n children got an appointment with him, they lined up in front of his office. All children love to cry loudly at the reception at the dentist. We enumerate the children with integers from 1 to...
Solve the programming task below in a Python markdown code block. Luke Skywalker gave Chewbacca an integer number x. Chewbacca isn't good at numbers but he loves inverting digits in them. Inverting digit t means replacing it with digit 9 - t. Help Chewbacca to transform the initial number x to the minimum possible p...
Solve the programming task below in a Python markdown code block. The cities of Byteland and Berland are located on the axis $Ox$. In addition, on this axis there are also disputed cities, which belong to each of the countries in their opinion. Thus, on the line $Ox$ there are three types of cities: the cities of Byt...
Solve the programming task below in a Python markdown code block. My friend wants a new band name for her band. She like bands that use the formula: "The" + a noun with the first letter capitalized, for example: `"dolphin" -> "The Dolphin"` However, when a noun STARTS and ENDS with the same letter, she likes to repe...
Solve the programming task below in a Python markdown code block. Petya loves lucky numbers. Everybody knows that lucky numbers are positive integers whose decimal representation contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Petya calls a number almost lucky...