question
large_stringlengths
265
13.2k
Solve the programming task below in a Python markdown code block. Just in case somebody missed it: this winter is totally cold in Nvodsk! It is so cold that one gets funny thoughts. For example, let's say there are strings with the length exactly n, based on the alphabet of size m. Any its substring with length equal ...
Solve the programming task below in a Python markdown code block. We all know the impressive story of Robin Hood. Robin Hood uses his archery skills and his wits to steal the money from rich, and return it to the poor. There are n citizens in Kekoland, each person has ci coins. Each day, Robin Hood will take exactly ...
Solve the programming task below in a Python markdown code block. In Berland each high school student is characterized by academic performance — integer value between 1 and 5. In high school 0xFF there are two groups of pupils: the group A and the group B. Each group consists of exactly n students. An academic perfor...
Solve the programming task below in a Python markdown code block. A star is a figure of the following type: an asterisk character '*' in the center of the figure and four rays (to the left, right, top, bottom) of the same positive length. The size of a star is the length of its rays. The size of a star must be a posit...
Solve the programming task below in a Python markdown code block. Do you know the story about the three musketeers? Anyway, you must help them now. Richelimakieu is a cardinal in the city of Bearis. He found three brave warriors and called them the three musketeers. Athos has strength a, Borthos strength b, and Caram...
Solve the programming task below in a Python markdown code block. In this problem at each moment you have a set of intervals. You can move from interval (a, b) from our set to interval (c, d) from our set if and only if c < a < d or c < b < d. Also there is a path from interval I1 from our set to interval I2 from our ...
Solve the programming task below in a Python markdown code block. Kostya likes Codeforces contests very much. However, he is very disappointed that his solutions are frequently hacked. That's why he decided to obfuscate (intentionally make less readable) his code before upcoming contest. To obfuscate the code, Kostya...
Solve the programming task below in a Python markdown code block. Takahashi, who lives on the number line, is now at coordinate X. He will make exactly K moves of distance D in the positive or negative direction. More specifically, in one move, he can go from coordinate x to x + D or x - D. He wants to make K moves so...
Solve the programming task below in a Python markdown code block. Polycarpus got an internship in one well-known social network. His test task is to count the number of unique users who have visited a social network during the day. Polycarpus was provided with information on all user requests for this time period. For...
Solve the programming task below in a Python markdown code block. You are given four digits N_1, N_2, N_3 and N_4. Determine if these can be arranged into the sequence of digits "1974". Constraints * 0 \leq N_1, N_2, N_3, N_4 \leq 9 * N_1, N_2, N_3 and N_4 are integers. Input Input is given from Standard Input in ...
Solve the programming task below in a Python markdown code block. You are given two strings $s$ and $t$, both consisting only of lowercase Latin letters. The substring $s[l..r]$ is the string which is obtained by taking characters $s_l, s_{l + 1}, \dots, s_r$ without changing the order. Each of the occurrences of st...
Solve the programming task below in a Python markdown code block. While Vasya finished eating his piece of pizza, the lesson has already started. For being late for the lesson, the teacher suggested Vasya to solve one interesting problem. Vasya has an array a and integer x. He should find the number of different order...
Solve the programming task below in a Python markdown code block. Little Petya very much likes gifts. Recently he has received a new laptop as a New Year gift from his mother. He immediately decided to give it to somebody else as what can be more pleasant than giving somebody gifts. And on this occasion he organized a...
Solve the programming task below in a Python markdown code block. E869120 found a chest which is likely to contain treasure. However, the chest is locked. In order to open it, he needs to enter a string S consisting of lowercase English letters. He also found a string S', which turns out to be the string S with some...
Solve the programming task below in a Python markdown code block. On Children's Day, the child got a toy from Delayyy as a present. However, the child is so naughty that he can't wait to destroy the toy. The toy consists of n parts and m ropes. Each rope links two parts, but every pair of parts is linked by at most o...
Solve the programming task below in a Python markdown code block. Today we will be playing a red and white colouring game (no, this is not the Russian Civil War; these are just the colours of the Canadian flag). You are given an $n \times m$ grid of "R", "W", and "." characters. "R" is red, "W" is white and "." is bl...
Solve the programming task below in a Python markdown code block. Good evening, contestants. If a and d are relatively prime positive integers, the arithmetic sequence beginning with a and increasing by d, i.e., a, a + d, a + 2d, a + 3d, a + 4d, ..., contains infinitely many prime numbers. This fact is known as Diric...
Solve the programming task below in a Python markdown code block. Tattah's youngest brother, Tuftuf, is new to programming. Since his older brother is such a good programmer, his biggest dream is to outshine him. Tuftuf is a student at the German University in Cairo (GUC) where he learns to write programs in Gava. T...
Solve the programming task below in a Python markdown code block. # Task CodeBots decided to make a gift for CodeMaster's birthday. They got a pack of candies of various sizes from the store, but instead of giving the whole pack they are trying to make the biggest possible candy from them. On each turn it is possible...
Solve the programming task below in a Python markdown code block. Consider the string `"adfa"` and the following rules: ```Pearl a) each character MUST be changed either to the one before or the one after in alphabet. b) "a" can only be changed to "b" and "z" to "y". ``` From our string, we get: ```Pearl "adfa" -> ...
Solve the programming task below in a Python markdown code block. Problem statement N first-year students of the Faculty of Information Science and Technology of R University take the final exam of the lecture called Programming Exercise 1. The test is a perfect score of m. In other words, the score that one student ...
Solve the programming task below in a Python markdown code block. A palindrome is a string $t$ which reads the same backward as forward (formally, $t[i] = t[|t| + 1 - i]$ for all $i \in [1, |t|]$). Here $|t|$ denotes the length of a string $t$. For example, the strings 010, 1001 and 0 are palindromes. You have $n$ bi...
Solve the programming task below in a Python markdown code block. Search trees are data structures that support dynamic set operations including insert, search, delete and so on. Thus a search tree can be used both as a dictionary and as a priority queue. Binary search tree is one of fundamental search trees. The key...
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. Just in case somebody missed it: this winter is totally cold in Nvodsk! It is so cold that one gets funny thoughts. For example, let's say there are strings with the length exactly n, based on the alphabet of size m. Any its substring with length equal ...
Solve the programming task below in a Python markdown code block. Write a function that takes a string and returns an array of the repeated characters (letters, numbers, whitespace) in the string. If a charater is repeated more than once, only show it once in the result array. Characters should be shown **by the ord...
Solve the programming task below in a Python markdown code block. The sequence is called ordered if it is non-decreasing or non-increasing. For example, sequnces [3, 1, 1, 0] and [1, 2, 3, 100] are ordered, but the sequence [1, 3, 3, 1] is not. You are given a sequence of numbers. You are to find it's shortest subsequ...
Solve the programming task below in a Python markdown code block. It can be shown that any positive integer x can be uniquely represented as x = 1 + 2 + 4 + ... + 2^{k} - 1 + r, where k and r are integers, k ≥ 0, 0 < r ≤ 2^{k}. Let's call that representation prairie partition of x. For example, the prairie partitions...
Solve the programming task below in a Python markdown code block. School holidays come in Berland. The holidays are going to continue for n days. The students of school №N are having the time of their lives and the IT teacher Marina Sergeyevna, who has spent all the summer busy checking the BSE (Berland State Examinat...
Solve the programming task below in a Python markdown code block. Two players play a game. The game is played on a rectangular board with n × m squares. At the beginning of the game two different squares of the board have two chips. The first player's goal is to shift the chips to the same square. The second player ai...
Solve the programming task below in a Python markdown code block. In this kata you will be given a random string of letters and tasked with returning them as a string of comma-separated sequences sorted alphabetically, with each sequence starting with an uppercase character followed by `n-1` lowercase characters, wher...
Solve the programming task below in a Python markdown code block. Dima has a hamsters farm. Soon N hamsters will grow up on it and Dima will sell them in a city nearby. Hamsters should be transported in boxes. If some box is not completely full, the hamsters in it are bored, that's why each box should be completely f...
Solve the programming task below in a Python markdown code block. A hero is on his way to the castle to complete his mission. However, he's been told that the castle is surrounded with a couple of powerful dragons! each dragon takes 2 bullets to be defeated, our hero has no idea how many bullets he should carry.. Assu...
Solve the programming task below in a Python markdown code block. You are given a string S of length N consisting of lowercase English letters. Process Q queries of the following two types: - Type 1: change the i_q-th character of S to c_q. (Do nothing if the i_q-th character is already c_q.) - Type 2: answer the nu...
Solve the programming task below in a Python markdown code block. Given the integer $n$ — the number of available blocks. You must use all blocks to build a pedestal. The pedestal consists of $3$ platforms for $2$-nd, $1$-st and $3$-rd places respectively. The platform for the $1$-st place must be strictly higher tha...
Solve the programming task below in a Python markdown code block. Truncate the given string (first argument) if it is longer than the given maximum length (second argument). Return the truncated string with a `"..."` ending. Note that inserting the three dots to the end will add to the string length. However, if the...
Solve the programming task below in a Python markdown code block. During one of the space missions, humans have found an evidence of previous life at one of the planets. They were lucky enough to find a book with birth and death years of each individual that had been living at this planet. What's interesting is that t...
Solve the programming task below in a Python markdown code block. Petya has got an interesting flower. Petya is a busy person, so he sometimes forgets to water it. You are given n days from Petya's live and you have to determine what happened with his flower in the end. The flower grows as follows: * If the flowe...
Solve the programming task below in a Python markdown code block. In Conway's Game of Life, cells in a grid are used to simulate biological cells. Each cell is considered to be either alive or dead. At each step of the simulation each cell's current status and number of living neighbors is used to determine the status...
Solve the programming task below in a Python markdown code block. AND gates and OR gates are basic components used in building digital circuits. Both gates have two input lines and one output line. The output of an AND gate is 1 if both inputs are 1, otherwise the output is 0. The output of an OR gate is 1 if at least...
Solve the programming task below in a Python markdown code block. Lucy had recently learned the game, called Natural Numbers. The rules of the game are really simple. There are N players. At the same time, every player says one natural number. Let's call the number said by the i-th player Ai. The person with the small...
Solve the programming task below in a Python markdown code block. Check if it is a vowel(a, e, i, o, u,) on the ```n``` position in a string (the first argument). Don't forget about uppercase. A few cases: ``` { checkVowel('cat', 1) -> true // 'a' is a vowel checkVowel('cat', 0) -> false // 'c' is not a vowel ...
Solve the programming task below in a Python markdown code block. An infinitely long railway has a train consisting of n cars, numbered from 1 to n (the numbers of all the cars are distinct) and positioned in arbitrary order. David Blaine wants to sort the railway cars in the order of increasing numbers. In one move h...
Solve the programming task below in a Python markdown code block. Родители Васи хотят, чтобы он как можно лучше учился. Поэтому если он получает подряд три положительные оценки («четвёрки» или «пятёрки»), они дарят ему подарок. Соответственно, оценки «единица», «двойка» и «тройка» родители Васи считают плохими. Когда ...
Solve the programming task below in a Python markdown code block. You are given a positive integer $n$ greater or equal to $2$. For every pair of integers $a$ and $b$ ($2 \le |a|, |b| \le n$), you can transform $a$ into $b$ if and only if there exists an integer $x$ such that $1 < |x|$ and ($a \cdot x = b$ or $b \cdot...
Solve the programming task below in a Python markdown code block. You are given string S and T consisting of lowercase English letters. Determine if S equals T after rotation. That is, determine if S equals T after the following operation is performed some number of times: Operation: Let S = S_1 S_2 ... S_{|S|}. Chang...
Solve the programming task below in a Python markdown code block. The palindromic number `595` is interesting because it can be written as the sum of consecutive squares: `6^2 + 7^2 + 8^2 + 9^2 + 10^2 + 11^2 + 12^2 = 595`. There are exactly eleven palindromes below one-thousand that can be written as consecutive squa...
Solve the programming task below in a Python markdown code block. Vasya goes to visit his classmate Petya. Vasya knows that Petya's apartment number is $n$. There is only one entrance in Petya's house and the distribution of apartments is the following: the first floor contains $2$ apartments, every other floor cont...
Solve the programming task below in a Python markdown code block. A Little Elephant and his friends from the Zoo of Lviv like candies very much. There are N elephants in the Zoo. The elephant with number K (1 ≤ K ≤ N) will be happy if he receives at least A_{K} candies. There are C candies in all in the Zoo. The Zoo...
Solve the programming task below in a Python markdown code block. While walking down the street Vanya saw a label "Hide&Seek". Because he is a programmer, he used & as a bitwise AND for these two words represented as a integers in base 64 and got new word. Now Vanya thinks of some string s and wants to know the number...
Solve the programming task below in a Python markdown code block. Lately, a national version of a bingo game has become very popular in Berland. There are n players playing the game, each player has a card with numbers. The numbers on each card are distinct, but distinct cards can have equal numbers. The card of the i...
Solve the programming task below in a Python markdown code block. Initially, you have the array $a$ consisting of one element $1$ ($a = [1]$). In one move, you can do one of the following things: Increase some (single) element of $a$ by $1$ (choose some $i$ from $1$ to the current length of $a$ and increase $a_i$ ...
Solve the programming task below in a Python markdown code block. Lolek and Bolek are about to travel abroad by plane. The local airport has a special "Choose Your Plane" offer. The offer's conditions are as follows: * it is up to a passenger to choose a plane to fly on; * if the chosen plane has x (x > 0) empty...
Solve the programming task below in a Python markdown code block. Amugae is in a very large round corridor. The corridor consists of two areas. The inner area is equally divided by $n$ sectors, and the outer area is equally divided by $m$ sectors. A wall exists between each pair of sectors of same area (inner or outer...
Solve the programming task below in a Python markdown code block. Fox Ciel has n boxes in her room. They have the same size and weight, but they might have different strength. The i-th box can hold at most xi boxes on its top (we'll call xi the strength of the box). Since all the boxes have the same size, Ciel canno...
Solve the programming task below in a Python markdown code block. Ivan has number $b$. He is sorting through the numbers $a$ from $1$ to $10^{18}$, and for every $a$ writes $\frac{[a, \,\, b]}{a}$ on blackboard. Here $[a, \,\, b]$ stands for least common multiple of $a$ and $b$. Ivan is very lazy, that's why this task...
Solve the programming task below in a Python markdown code block. Jack is working on his jumping skills recently. Currently he's located at point zero of the number line. He would like to get to the point x. In order to train, he has decided that he'll first jump by only one unit, and each subsequent jump will be exac...
Solve the programming task below in a Python markdown code block. Finished her homework, Nastya decided to play computer games. Passing levels one by one, Nastya eventually faced a problem. Her mission is to leave a room, where a lot of monsters live, as quickly as possible. There are $n$ manholes in the room which a...
Solve the programming task below in a Python markdown code block. This problem is given in two versions that differ only by constraints. If you can solve this problem in large constraints, then you can just write a single solution to the both versions. If you find the problem too difficult in large constraints, you ca...
Solve the programming task below in a Python markdown code block. Once upon a time when people still believed in magic, there was a great wizard Aranyaka Gondlir. After twenty years of hard training in a deep forest, he had finally mastered ultimate magic, and decided to leave the forest for his home. Arriving at his...
Solve the programming task below in a Python markdown code block. The Travelling Salesman spends a lot of time travelling so he tends to get bored. To pass time, he likes to perform operations on numbers. One such operation is to take a positive integer x and reduce it to the number of bits set to 1 in the binary repr...
Solve the programming task below in a Python markdown code block. Polycarp decided to relax on his weekend and visited to the performance of famous ropewalkers: Agafon, Boniface and Konrad. The rope is straight and infinite in both directions. At the beginning of the performance, Agafon, Boniface and Konrad are locat...
Solve the programming task below in a Python markdown code block. In a flower bed, there are N flowers, numbered 1,2,......,N. Initially, the heights of all flowers are 0. You are given a sequence h=\{h_1,h_2,h_3,......\} as input. You would like to change the height of Flower k to h_k for all k (1 \leq k \leq N), by...
Solve the programming task below in a Python markdown code block. Arkady owns a non-decreasing array $a_1, a_2, \ldots, a_n$. You are jealous of its beauty and want to destroy this property. You have a so-called XOR-gun that you can use one or more times. In one step you can select two consecutive elements of the arr...
Solve the programming task below in a Python markdown code block. Given a number `n` we will define its scORe to be `0 | 1 | 2 | 3 | ... | n`, where `|` is the [bitwise OR operator](https://en.wikipedia.org/wiki/Bitwise_operation#OR). Write a function that takes `n` and finds its scORe. --------------------- | n ...
Solve the programming task below in a Python markdown code block. Omkar is standing at the foot of Celeste mountain. The summit is $n$ meters away from him, and he can see all of the mountains up to the summit, so for all $1 \leq j \leq n$ he knows that the height of the mountain at the point $j$ meters away from hims...
Solve the programming task below in a Python markdown code block. Alice wants to send an email to Miku on her mobile phone. The only buttons that can be used for input on mobile phones are number buttons. Therefore, in order to input characters, the number buttons are pressed several times to input characters. The fo...
Solve the programming task below in a Python markdown code block. You are given three integers A, B and C. Determine whether C is not less than A and not greater than B. -----Constraints----- - -100≤A,B,C≤100 - A, B and C are all integers. -----Input----- Input is given from Standard Input in the following format...
Solve the programming task below in a Python markdown code block. We have three stones at points (0, 0), (1,0), and (0,1) on a two-dimensional plane. These three stones are said to form an L when they satisfy the following conditions: - Each of the stones is at integer coordinates. - Each of the stones is adjacent t...
Solve the programming task below in a Python markdown code block. You are given a non-decreasing array of non-negative integers $a_1, a_2, \ldots, a_n$. Also you are given a positive integer $k$. You want to find $m$ non-decreasing arrays of non-negative integers $b_1, b_2, \ldots, b_m$, such that: The size of $b_i$...
Solve the programming task below in a Python markdown code block. -----Input----- The only line of the input is a string of 7 characters. The first character is letter A, followed by 6 digits. The input is guaranteed to be valid (for certain definition of "valid"). -----Output----- Output a single integer. -----...
Solve the programming task below in a Python markdown code block. Recently Luba bought a monitor. Monitor is a rectangular matrix of size n × m. But then she started to notice that some pixels cease to work properly. Luba thinks that the monitor will become broken the first moment when it contains a square k × k consi...
Solve the programming task below in a Python markdown code block. Emily's birthday is next week and Jack has decided to buy a present for her. He knows she loves books so he goes to the local bookshop, where there are n books on sale from one of m genres. In the bookshop, Jack decides to buy two books of different ge...
Solve the programming task below in a Python markdown code block. Read problems statements in Mandarin Chinese , Russian and Vietnamese as well. Akhil comes across a string S of length N. He started wondering about the smallest lexicographical subsequence of string S of length K. A subsequence of a string is formed b...
Solve the programming task below in a Python markdown code block. Write a program which replace all the lower-case letters of a given text with the corresponding captital letters. Input A text including lower-case letters, periods, and space is given in a line. The number of characters in the text is less than or ...
Solve the programming task below in a Python markdown code block. Recently, a chaotic virus Hexadecimal advanced a new theorem which will shake the Universe. She thinks that each Fibonacci number can be represented as sum of three not necessary different Fibonacci numbers. Let's remember how Fibonacci numbers can be ...
Solve the programming task below in a Python markdown code block. Complete the function that takes two numbers as input, ```num``` and ```nth``` and return the `nth` digit of `num` (counting from right to left). ## Note - If ```num``` is negative, ignore its sign and treat it as a positive value - If ```nth``` is not...
Solve the programming task below in a Python markdown code block. Squirrel Liss loves nuts. There are n trees (numbered 1 to n from west to east) along a street and there is a delicious nut on the top of each tree. The height of the tree i is h_{i}. Liss wants to eat all nuts. Now Liss is on the root of the tree with...
Solve the programming task below in a Python markdown code block. There is a square grid with N rows and M columns. Each square contains an integer: 0 or 1. The square at the i-th row from the top and the j-th column from the left contains a_{ij}. Among the 2^{N+M} possible pairs of a subset A of the rows and a subse...
Solve the programming task below in a Python markdown code block. Guy-Manuel and Thomas have an array $a$ of $n$ integers [$a_1, a_2, \dots, a_n$]. In one step they can add $1$ to any element of the array. Formally, in one step they can choose any integer index $i$ ($1 \le i \le n$) and do $a_i := a_i + 1$. If either...
Solve the programming task below in a Python markdown code block. Write a program which prints the central coordinate $(p_x, p_y)$ and the radius $r$ of a circumscribed circle of a triangle which is constructed by three points $(x_1, y_1)$, $(x_2, y_2)$ and $(x_3, y_3)$ on the plane surface. Constraints * $-100 \leq...
Solve the programming task below in a Python markdown code block. A smelt fishing tournament was held at Lake Hibara. It seems that catch and release is recommended this time. Create a program that reads the participant number and the number of fish caught or released in order as one event, and outputs the participan...
Solve the programming task below in a Python markdown code block. Tenten runs a weapon shop for ninjas. Today she is willing to sell $n$ shurikens which cost $1$, $2$, ..., $n$ ryo (local currency). During a day, Tenten will place the shurikens onto the showcase, which is empty at the beginning of the day. Her job is ...
Solve the programming task below in a Python markdown code block. One of the games that uses the Hyakunin Isshu tag is "Buddhist turning". It is a simple game that uses only picture cards, so it is widely enjoyed. There are various derivative types of rules, but the shaved turn considered here is performed by N partic...
Solve the programming task below in a Python markdown code block. You are a biologist working on the amino acid composition of proteins. Every protein consists of a long chain of 20 different amino acids with different properties. Currently, you are collecting data on the percentage, various amino acids make up a pr...
Solve the programming task below in a Python markdown code block. Vus the Cossack has a field with dimensions n × m, which consists of "0" and "1". He is building an infinite field from this field. He is doing this in this way: 1. He takes the current field and finds a new inverted field. In other words, the new fi...
Solve the programming task below in a Python markdown code block. Marina loves Sasha. But she keeps wondering whether Sasha loves her. Of course, the best way to know it is fortune telling. There are many ways of telling fortune, but Marina has picked the easiest one. She takes in her hand one or several camomiles and...
Solve the programming task below in a Python markdown code block. In this Kata, you will be given an integer array and your task is to return the sum of elements occupying prime-numbered indices. ~~~if-not:fortran The first element of the array is at index `0`. ~~~ ~~~if:fortran The first element of an array is at ...
Solve the programming task below in a Python markdown code block. # Task The string is called `prime` if it cannot be constructed by concatenating some (more than one) equal strings together. For example, "abac" is prime, but "xyxy" is not("xyxy"="xy"+"xy"). Given a string determine if it is prime or not. # Inp...
Solve the programming task below in a Python markdown code block. Morning desert sun horizon Rise above the sands of time... Fates Warning, "Exodus" After crossing the Windswept Wastes, Ori has finally reached the Windtorn Ruins to find the Heart of the Forest! However, the ancient repository containing this pricel...
Solve the programming task below in a Python markdown code block. There are a total of W x H squares, with H rows vertically and W columns horizontally. Some squares are marked. Create a program that reads the marked state of each square and outputs the maximum rectangular area consisting of only the unmarked squares....
Solve the programming task below in a Python markdown code block. A very passive-aggressive co-worker of yours was just fired. While he was gathering his things, he quickly inserted a bug into your system which renamed everything to what looks like jibberish. He left two notes on his desk, one reads: "ABCDEFGHIJKLMNOP...
Solve the programming task below in a Python markdown code block. You are currently in the United States of America. The main currency here is known as the United States Dollar (USD). You are planning to travel to another country for vacation, so you make it today's goal to convert your USD (all bills, no cents) into ...
Solve the programming task below in a Python markdown code block. Andrewid the Android is a galaxy-famous detective. He is now investigating the case of vandalism at the exhibition of contemporary art. The main exhibit is a construction of n matryoshka dolls that can be nested one into another. The matryoshka dolls a...
Solve the programming task below in a Python markdown code block. Maki is a house cat. One day she fortunately came at a wonderful-looking dried fish. Since she felt not hungry on that day, she put it up in her bed. However there was a problem; a rat was living in her house, and he was watching for a chance to steal h...
Solve the programming task below in a Python markdown code block. Last week, Hamed learned about a new type of equations in his math class called Modular Equations. Lets define i modulo j as the remainder of division of i by j and denote it by $i \operatorname{mod} j$. A Modular Equation, as Hamed's teacher described,...
Solve the programming task below in a Python markdown code block. Your task is to write a function that does just what the title suggests (so, fair warning, be aware that you are not getting out of it just throwing a lame bas sorting method there) with an array/list/vector of integers and the expected number `n` of sm...
Solve the programming task below in a Python markdown code block. Let us consider the following operations on a string consisting of A and B: - Select a character in a string. If it is A, replace it with BB. If it is B, replace with AA. - Select a substring that is equal to either AAA or BBB, and delete it from the ...
Solve the programming task below in a Python markdown code block. There are N slimes lining up from left to right. The colors of these slimes will be given as a string S of length N consisting of lowercase English letters. The i-th slime from the left has the color that corresponds to the i-th character of S. Adjacent...
Solve the programming task below in a Python markdown code block. Internet search engines, such as Google, automatically sort and categorize web pages around the world to create a huge database. It also parses the search keywords entered by the user and creates an inquiry statement for database search. In each case, ...