question
large_stringlengths
265
13.2k
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. Takahashi has K 500-yen coins. (Yen is the currency of Japan.) If these coins add up to X yen or more, print Yes; otherwise, print No. -----Constraints----- - 1 \leq K \leq 100 - 1 \leq X \leq 10^5 -----Input----- Input is given from Standard Input ...
Solve the programming task below in a Python markdown code block. Snuke has a fair N-sided die that shows the integers from 1 to N with equal probability and a fair coin. He will play the following game with them: - Throw the die. The current score is the result of the die. - As long as the score is between 1 and K-...
Solve the programming task below in a Python markdown code block. Given is a string S representing the day of the week today. S is SUN, MON, TUE, WED, THU, FRI, or SAT, for Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, and Saturday, respectively. After how many days is the next Sunday (tomorrow or later)? ---...
Solve the programming task below in a Python markdown code block. The development of algae in a pond is as follows. Let the total weight of the algae at the beginning of the year i be x_i gram. For iβ‰₯2000, the following formula holds: - x_{i+1} = rx_i - D You are given r, D and x_{2000}. Calculate x_{2001}, ..., x_{2...
Solve the programming task below in a Python markdown code block. You are given an array $d_1, d_2, \dots, d_n$ consisting of $n$ integer numbers. Your task is to split this array into three parts (some of which may be empty) in such a way that each element of the array belongs to exactly one of the three parts, and ...
Solve the programming task below in a Python markdown code block. You are given three positive (i.e. strictly greater than zero) integers $x$, $y$ and $z$. Your task is to find positive integers $a$, $b$ and $c$ such that $x = \max(a, b)$, $y = \max(a, c)$ and $z = \max(b, c)$, or determine that it is impossible to f...
Solve the programming task below in a Python markdown code block. Recently, Norge found a string $s = s_1 s_2 \ldots s_n$ consisting of $n$ lowercase Latin letters. As an exercise to improve his typing speed, he decided to type all substrings of the string $s$. Yes, all $\frac{n (n + 1)}{2}$ of them! A substring of $...
Solve the programming task below in a Python markdown code block. Recall that the sequence $b$ is a a subsequence of the sequence $a$ if $b$ can be derived from $a$ by removing zero or more elements without changing the order of the remaining elements. For example, if $a=[1, 2, 1, 3, 1, 2, 1]$, then possible subsequen...
Solve the programming task below in a Python markdown code block. You are given an undirected unweighted connected graph consisting of $n$ vertices and $m$ edges. It is guaranteed that there are no self-loops or multiple edges in the given graph. Your task is to find any spanning tree of this graph such that the maxi...
Solve the programming task below in a Python markdown code block. You are given a board of size $n \times n$, where $n$ is odd (not divisible by $2$). Initially, each cell of the board contains one figure. In one move, you can select exactly one figure presented in some cell and move it to one of the cells sharing a ...
Solve the programming task below in a Python markdown code block. You are given one integer number $n$. Find three distinct integers $a, b, c$ such that $2 \le a, b, c$ and $a \cdot b \cdot c = n$ or say that it is impossible to do it. If there are several answers, you can print any. You have to answer $t$ independe...
Solve the programming task below in a Python markdown code block. Nikolay got a string $s$ of even length $n$, which consists only of lowercase Latin letters 'a' and 'b'. Its positions are numbered from $1$ to $n$. He wants to modify his string so that every its prefix of even length has an equal amount of letters 'a...
Solve the programming task below in a Python markdown code block. Maksim walks on a Cartesian plane. Initially, he stands at the point $(0, 0)$ and in one move he can go to any of four adjacent points (left, right, up, down). For example, if Maksim is currently at the point $(0, 0)$, he can go to any of the following ...
Solve the programming task below in a Python markdown code block. Takahashi is solving quizzes. He has easily solved all but the last one. The last quiz has three choices: 1, 2, and 3. With his supernatural power, Takahashi has found out that the choices A and B are both wrong. Print the correct choice for this proble...
Solve the programming task below in a Python markdown code block. Given is a positive integer L. Find the maximum possible volume of a rectangular cuboid whose sum of the dimensions (not necessarily integers) is L. -----Constraints----- - 1 ≀ L ≀ 1000 - L is an integer. -----Input----- Input is given from Standard...
Solve the programming task below in a Python markdown code block. In 2020, AtCoder Inc. with an annual sales of more than one billion yen (the currency of Japan) has started a business in programming education. One day, there was an exam where a one-year-old child must write a program that prints Hello World, and a t...
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. Given is a lowercase English letter C that is not z. Print the letter that follows C in alphabetical order. -----Constraints----- - C is a lowercase English letter that is not z. -----Input----- Input is given from Standard Input in the following for...
Solve the programming task below in a Python markdown code block. Given are two strings S and T consisting of lowercase English letters. Concatenate T and S in this order, without space in between, and print the resulting string. -----Constraints----- - S and T are strings consisting of lowercase English letters. -...
Solve the programming task below in a Python markdown code block. Polycarp has an array $a$ consisting of $n$ integers. He wants to play a game with this array. The game consists of several moves. On the first move he chooses any element and deletes it (after the first move the array contains $n-1$ elements). For eac...
Solve the programming task below in a Python markdown code block. There are $n$ monsters standing in a row numbered from $1$ to $n$. The $i$-th monster has $h_i$ health points (hp). You have your attack power equal to $a$ hp and your opponent has his attack power equal to $b$ hp. You and your opponent are fighting th...
Solve the programming task below in a Python markdown code block. You are given an array consisting of $n$ integers $a_1, a_2, \dots, a_n$, and a positive integer $m$. It is guaranteed that $m$ is a divisor of $n$. In a single move, you can choose any position $i$ between $1$ and $n$ and increase $a_i$ by $1$. Let's...
Solve the programming task below in a Python markdown code block. The only difference between easy and hard versions is constraints. Ivan plays a computer game that contains some microtransactions to make characters look cooler. Since Ivan wants his character to be really cool, he wants to use some of these microtran...
Solve the programming task below in a Python markdown code block. There are $n$ students at your university. The programming skill of the $i$-th student is $a_i$. As a coach, you want to divide them into teams to prepare them for the upcoming ICPC finals. Just imagine how good this university is if it has $2 \cdot 10^...
Solve the programming task below in a Python markdown code block. A positive (strictly greater than zero) integer is called round if it is of the form d00...0. In other words, a positive integer is round if all its digits except the leftmost (most significant) are equal to zero. In particular, all numbers from $1$ to ...
Solve the programming task below in a Python markdown code block. The only difference between easy and hard versions is constraints. There are $n$ kids, each of them is reading a unique book. At the end of any day, the $i$-th kid will give his book to the $p_i$-th kid (in case of $i = p_i$ the kid will give his book ...
Solve the programming task below in a Python markdown code block. You are both a shop keeper and a shop assistant at a small nearby shop. You have $n$ goods, the $i$-th good costs $a_i$ coins. You got tired of remembering the price of each product when customers ask for it, thus you decided to simplify your life. Mor...
Solve the programming task below in a Python markdown code block. In BerSoft $n$ programmers work, the programmer $i$ is characterized by a skill $r_i$. A programmer $a$ can be a mentor of a programmer $b$ if and only if the skill of the programmer $a$ is strictly greater than the skill of the programmer $b$ $(r_a > ...
Solve the programming task below in a Python markdown code block. Authors have come up with the string $s$ consisting of $n$ lowercase Latin letters. You are given two permutations of its indices (not necessary equal) $p$ and $q$ (both of length $n$). Recall that the permutation is the array of length $n$ which conta...
Solve the programming task below in a Python markdown code block. Recently Vasya decided to improve his pistol shooting skills. Today his coach offered him the following exercise. He placed $n$ cans in a row on a table. Cans are numbered from left to right from $1$ to $n$. Vasya has to knock down each can exactly once...
Solve the programming task below in a Python markdown code block. You are given a sequence of positive integers of length N, a = (a_1, a_2, ..., a_N). Your objective is to remove some of the elements in a so that a will be a good sequence. Here, an sequence b is a good sequence when the following condition holds true:...
Solve the programming task below in a Python markdown code block. We have five variables x_1, x_2, x_3, x_4, and x_5. The variable x_i was initially assigned a value of i. Snuke chose one of these variables and assigned it 0. You are given the values of the five variables after this assignment. Find out which variable...
Solve the programming task below in a Python markdown code block. We have a sequence of length N, a = (a_1, a_2, ..., a_N). Each a_i is a positive integer. Snuke's objective is to permute the element in a so that the following condition is satisfied: - For each 1 ≀ i ≀ N - 1, the product of a_i and a_{i + 1} is a mul...
Solve the programming task below in a Python markdown code block. We ask you to select some number of positive integers, and calculate the sum of them. It is allowed to select as many integers as you like, and as large integers as you wish. You have to follow these, however: each selected integer needs to be a multipl...
Solve the programming task below in a Python markdown code block. There is a farm whose length and width are A yard and B yard, respectively. A farmer, John, made a vertical road and a horizontal road inside the farm from one border to another, as shown below: (The gray part represents the roads.) What is the area of...
Solve the programming task below in a Python markdown code block. We have a long seat of width X centimeters. There are many people who wants to sit here. A person sitting on the seat will always occupy an interval of length Y centimeters. We would like to seat as many people as possible, but they are all very shy, an...
Solve the programming task below in a Python markdown code block. On a two-dimensional plane, there are N red points and N blue points. The coordinates of the i-th red point are (a_i, b_i), and the coordinates of the i-th blue point are (c_i, d_i). A red point and a blue point can form a friendly pair when, the x-coor...
Solve the programming task below in a Python markdown code block. In a public bath, there is a shower which emits water for T seconds when the switch is pushed. If the switch is pushed when the shower is already emitting water, from that moment it will be emitting water for T seconds. Note that it does not mean that t...
Solve the programming task below in a Python markdown code block. A Little Elephant from the Zoo of Lviv likes lucky strings, i.e., the strings that consist only of the lucky digits 4 and 7. The Little Elephant calls some string T of the length M balanced if there exists at least one integer X (1 ≀ X ≀ M) such that th...
Solve the programming task below in a Python markdown code block. There are n persons who initially don't know each other. On each morning, two of them, who were not friends before, become friends. We want to plan a trip for every evening of m days. On each trip, you have to select a group of people that will go on t...
Solve the programming task below in a Python markdown code block. Let's call a string a phone number if it has length 11 and fits the pattern "8xxxxxxxxxx", where each "x" is replaced by a digit. For example, "80123456789" and "80000000000" are phone numbers, while "8012345678" and "79000000000" are not. You have n ...
Solve the programming task below in a Python markdown code block. You are given q queries in the following form: Given three integers l_i, r_i and d_i, find minimum positive integer x_i such that it is divisible by d_i and it does not belong to the segment [l_i, r_i]. Can you answer all the queries? Recall that a n...
Solve the programming task below in a Python markdown code block. Note that this is the first problem of the two similar problems. You can hack this problem only if you solve both problems. You are given a tree with n nodes. In the beginning, 0 is written on all edges. In one operation, you can choose any 2 distinct ...
Solve the programming task below in a Python markdown code block. An array of integers p_{1},p_{2}, …,p_{n} is called a permutation if it contains each number from 1 to n exactly once. For example, the following arrays are permutations: [3,1,2], [1], [1,2,3,4,5] and [4,3,1,2]. The following arrays are not permutations...
Solve the programming task below in a Python markdown code block. This is the easier version of the problem. In this version 1 ≀ n, m ≀ 100. You can hack this problem only if you solve and lock both problems. You are given a sequence of integers a=[a_1,a_2,...,a_n] of length n. Its subsequence is obtained by removing...
Solve the programming task below in a Python markdown code block. There are n lamps on a line, numbered from 1 to n. Each one has an initial state off (0) or on (1). You're given k subsets A_1, …, A_k of \{1, 2, ..., n\}, such that the intersection of any three subsets is empty. In other words, for all 1 ≀ i_1 < i_2 ...
Solve the programming task below in a Python markdown code block. There are n points on a coordinate axis OX. The i-th point is located at the integer point x_i and has a speed v_i. It is guaranteed that no two points occupy the same coordinate. All n points move with the constant speed, the coordinate of the i-th poi...
Solve the programming task below in a Python markdown code block. You are given a complete directed graph K_n with n vertices: each pair of vertices u β‰  v in K_n have both directed edges (u, v) and (v, u); there are no self-loops. You should find such a cycle in K_n that visits every directed edge exactly once (allow...
Solve the programming task below in a Python markdown code block. Vasilisa the Wise from the Kingdom of Far Far Away got a magic box with a secret as a present from her friend Hellawisa the Wise from the Kingdom of A Little Closer. However, Vasilisa the Wise does not know what the box's secret is, since she cannot ope...
Solve the programming task below in a Python markdown code block. You may know that Euclid was a mathematician. Well, as it turns out, Morpheus knew it too. So when he wanted to play a mean trick on Euclid, he sent him an appropriate nightmare. In his bad dream Euclid has a set S of n m-dimensional vectors over the ...
Solve the programming task below in a Python markdown code block. Polycarp was dismantling his attic and found an old floppy drive on it. A round disc was inserted into the drive with n integers written on it. Polycarp wrote the numbers from the disk into the a array. It turned out that the drive works according to t...
Solve the programming task below in a Python markdown code block. You are given an integer n. You have to apply m operations to it. In a single operation, you must replace every digit d of the number with the decimal representation of integer d + 1. For example, 1912 becomes 21023 after applying the operation once. ...
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. You are given an equation: Ax2 + Bx + C = 0. Your task is to find the number of distinct roots of the equation and print all of them in ascending order. Input The first line contains three integer numbers A, B and C ( - 105 ≀ A, B, C ≀ 105). Any c...
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. There are n cows playing poker at a table. For the current betting phase, each player's status is either "ALLIN", "IN", or "FOLDED", and does not change throughout the phase. To increase the suspense, a player whose current status is not "FOLDED" may sh...
Solve the programming task below in a Python markdown code block. Vasily the Programmer loves romance, so this year he decided to illuminate his room with candles. Vasily has a candles.When Vasily lights up a new candle, it first burns for an hour and then it goes out. Vasily is smart, so he can make b went out candl...
Solve the programming task below in a Python markdown code block. Petya studies positional notations. He has already learned to add and subtract numbers in the systems of notations with different radices and has moved on to a more complicated action β€” multiplication. To multiply large numbers one has to learn the mult...
Solve the programming task below in a Python markdown code block. To celebrate the opening of the Winter Computer School the organizers decided to buy in n liters of cola. However, an unexpected difficulty occurred in the shop: it turned out that cola is sold in bottles 0.5, 1 and 2 liters in volume. At that, there ar...
Solve the programming task below in a Python markdown code block. A and B are preparing themselves for programming contests. B loves to debug his code. But before he runs the solution and starts debugging, he has to first compile the code. Initially, the compiler displayed n compilation errors, each of them is repre...
Solve the programming task below in a Python markdown code block. Little Susie listens to fairy tales before bed every day. Today's fairy tale was about wood cutters and the little girl immediately started imagining the choppers cutting wood. She imagined the situation that is described below. There are n trees locat...
Solve the programming task below in a Python markdown code block. Every day Ruslan tried to count sheep to fall asleep, but this didn't help. Now he has found a more interesting thing to do. First, he thinks of some set of circles on a plane, and then tries to choose a beautiful set of points, such that there is at le...
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. You are given a rebus of form ? + ? - ? + ? = n, consisting of only question marks, separated by arithmetic operation '+' and '-', equality and positive integer n. The goal is to replace each question mark with some positive integer from 1 to n, such th...
Solve the programming task below in a Python markdown code block. Nick has n bottles of soda left after his birthday. Each bottle is described by two values: remaining amount of soda ai and bottle volume bi (ai ≀ bi). Nick has decided to pour all remaining soda into minimal number of bottles, moreover he has to do it...
Solve the programming task below in a Python markdown code block. Our beloved detective, Sherlock is currently trying to catch a serial killer who kills a person each day. Using his powers of deduction, he came to know that the killer has a strategy for selecting his next victim. The killer starts with two potential ...
Solve the programming task below in a Python markdown code block. There is little time left before the release of the first national operating system BerlOS. Some of its components are not finished yet β€” the memory manager is among them. According to the developers' plan, in the first release the memory manager will b...
Solve the programming task below in a Python markdown code block. Some time ago Mister B detected a strange signal from the space, which he started to study. After some transformation the signal turned out to be a permutation p of length n or its cyclic shift. For the further investigation Mister B need some basis, t...
Solve the programming task below in a Python markdown code block. Igor is a post-graduate student of chemistry faculty in Berland State University (BerSU). He needs to conduct a complicated experiment to write his thesis, but laboratory of BerSU doesn't contain all the materials required for this experiment. Fortunat...
Solve the programming task below in a Python markdown code block. As technologies develop, manufacturers are making the process of unlocking a phone as user-friendly as possible. To unlock its new phone, Arkady's pet dog Mu-mu has to bark the password once. The phone represents a password as a string of two lowercase ...
Solve the programming task below in a Python markdown code block. Recenlty Luba got a credit card and started to use it. Let's consider n consecutive days Luba uses the card. She starts with 0 money on her account. In the evening of i-th day a transaction ai occurs. If ai > 0, then ai bourles are deposited to Luba's...
Solve the programming task below in a Python markdown code block. Luba thinks about watering her garden. The garden can be represented as a segment of length k. Luba has got n buckets, the i-th bucket allows her to water some continuous subsegment of garden of length exactly ai each hour. Luba can't water any parts of...
Solve the programming task below in a Python markdown code block. You and your friend are participating in a TV show "Run For Your Prize". At the start of the show n prizes are located on a straight line. i-th prize is located at position ai. Positions of all prizes are distinct. You start at position 1, your friend ...
Solve the programming task below in a Python markdown code block. You are given a tree (a graph with n vertices and n - 1 edges in which it's possible to reach any vertex from any other vertex using only its edges). A vertex can be destroyed if this vertex has even degree. If you destroy a vertex, all edges connected...
Solve the programming task below in a Python markdown code block. Adilbek's house is located on a street which can be represented as the OX axis. This street is really dark, so Adilbek wants to install some post lamps to illuminate it. Street has n positions to install lamps, they correspond to the integer numbers fro...
Solve the programming task below in a Python markdown code block. As you know Appu created aversion to Maths after that maths problem given by his teacher.So he stopped studying and began to do farming. He has some land where he starts growing sugarcane. At the end of the season he grew N sugarcanes. Is Appu satisfied...
Solve the programming task below in a Python markdown code block. In the previous problem Chandu bought some unsorted arrays and sorted them (in non-increasing order). Now, he has many sorted arrays to give to his girlfriend. But, the number of sorted arrays are very large so Chandu decided to merge two sorted arrays ...
Solve the programming task below in a Python markdown code block. Golu is given a task of clearing coins fallen down on floor. Naughty being his modus operandi, he thought of playing a game while clearing coins. He arranges the coins like an M X N matrix with random heads (1) and tails (0). In every move, he chooses...
Solve the programming task below in a Python markdown code block. A certain business maintains a list of all its customers' names. The list is arranged in order of importance, with the last customer in the list being the most important. Now, he want to create a new list sorted alphabetically according to customers' la...
Solve the programming task below in a Python markdown code block. Roy is going through the dark times of his life. Recently his girl friend broke up with him and to overcome the pain of acute misery he decided to restrict himself to Eat-Sleep-Code life cycle. For N days he did nothing but eat, sleep and code. A clo...
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. Having learned the multiplication table, Takahashi can multiply two integers between 1 and 9 (inclusive) together. He cannot do any other calculation. Given are two integers A and B. If Takahashi can calculate A \times B, print the result; if he canno...
Solve the programming task below in a Python markdown code block. AtCoDeer the deer found two positive integers, a and b. Determine whether the product of a and b is even or odd. Constraints * 1 ≀ a,b ≀ 10000 * a and b are integers. Input Input is given from Standard Input in the following format: a b Output ...
Solve the programming task below in a Python markdown code block. There are N students and M checkpoints on the xy-plane. The coordinates of the i-th student (1 \leq i \leq N) is (a_i,b_i), and the coordinates of the checkpoint numbered j (1 \leq j \leq M) is (c_j,d_j). When the teacher gives a signal, each student ha...
Solve the programming task below in a Python markdown code block. Two students of AtCoder Kindergarten are fighting over candy packs. There are three candy packs, each of which contains a, b, and c candies, respectively. Teacher Evi is trying to distribute the packs between the two students so that each student gets...
Solve the programming task below in a Python markdown code block. 4 different points on the plane Read the coordinates of $ A (x_a, y_a) $, $ B (x_b, y_b) $, $ C (x_c, y_c) $, $ D (x_d, y_d) $ and read those 4 points Create a program that outputs YES if there is no dent in the quadrangle $ ABCD $ with the coordinates ...
Solve the programming task below in a Python markdown code block. Sorting algorithms for sorting data are basic algorithms indispensable in computer science. For example, as shown in the figure below, the operation of "sorting the elements of an array of integer values ​​in ascending order" is alignment. <image> Ma...
Solve the programming task below in a Python markdown code block. PCK, which recycles Aizu's precious metal, Aizunium, has a network all over the country and collects Aizunium with many collection vehicles. This company standardizes the unit of weight and number of lumps for efficient processing. A unit called "bokko...
Solve the programming task below in a Python markdown code block. You are the God of Wind. By moving a big cloud around, you can decide the weather: it invariably rains under the cloud, and the sun shines everywhere else. But you are a benign God: your goal is to give enough rain to every field in the countryside, a...
Solve the programming task below in a Python markdown code block. Short Phrase A Short Phrase (aka. Tanku) is a fixed verse, inspired by Japanese poetry Tanka and Haiku. It is a sequence of words, each consisting of lowercase letters 'a' to 'z', and must satisfy the following condition: > (The Condition for a Short ...
Solve the programming task below in a Python markdown code block. I have n tickets for a train with a rabbit. Each ticket is numbered from 0 to n βˆ’ 1, and you can use the k ticket to go to pβ‹…ak + qβ‹…bk station. Rabbit wants to go to the all-you-can-eat carrot shop at the station m station ahead of the current station,...
Solve the programming task below in a Python markdown code block. Taro is an elementary school student who has just learned multiplication. Somehow, he likes multiplication, so when he sees numbers, he wants to multiply. He seems to like to do the following for integers greater than or equal to 0. (Processing flow) *...
Solve the programming task below in a Python markdown code block. Step up and down Kazuki, commonly known as Kerr, who attends JAG University, was invited by your friend this summer to participate in the ICPC (International Collegiate Potchari Contest). ICPC is a sports contest and requires a high degree of athletic ...
Solve the programming task below in a Python markdown code block. Taro is going to play a card game. However, now he has only n cards, even though there should be 52 cards (he has no Jokers). The 52 cards include 13 ranks of each of the four suits: spade, heart, club and diamond. Note θ§£θͺ¬ Input In the first line...
Solve the programming task below in a Python markdown code block. At a geometry lesson Gerald was given a task: to get vector B out of vector A. Besides, the teacher permitted him to perform the following operations with vector А: * Turn the vector by 90 degrees clockwise. * Add to the vector a certain vector C. ...
Solve the programming task below in a Python markdown code block. Awruk is taking part in elections in his school. It is the final round. He has only one opponent β€” Elodreip. The are n students in the school. Each student has exactly k votes and is obligated to use all of them. So Awruk knows that if a person gives a_...
Solve the programming task below in a Python markdown code block. You are given a binary matrix A of size n Γ— n. Let's denote an x-compression of the given matrix as a matrix B of size n/x Γ— n/x such that for every i ∈ [1, n], j ∈ [1, n] the condition A[i][j] = B[⌈ i/x βŒ‰][⌈ j/x βŒ‰] is met. Obviously, x-compression is ...
Solve the programming task below in a Python markdown code block. At the big break Nastya came to the school dining room. There are n pupils in the school, numbered from 1 to n. Unfortunately, Nastya came pretty late, so that all pupils had already stood in the queue, i.e. Nastya took the last place in the queue. Of c...
Solve the programming task below in a Python markdown code block. You are given a string s consisting of n lowercase Latin letters. Let's define a substring as a contiguous subsegment of a string. For example, "acab" is a substring of "abacaba" (it starts in position 3 and ends in position 6), but "aa" or "d" aren't ...