question
large_stringlengths
265
13.2k
Solve the programming task below in a Python markdown code block. You are given an integer number $n$. The following algorithm is applied to it: if $n = 0$, then end algorithm; find the smallest prime divisor $d$ of $n$; subtract $d$ from $n$ and go to step $1$. Determine the number of subtrations the algorithm...
Solve the programming task below in a Python markdown code block. Victor tries to write his own text editor, with word correction included. However, the rules of word correction are really strange. Victor thinks that if a word contains two consecutive vowels, then it's kinda weird and it needs to be replaced. So the ...
Solve the programming task below in a Python markdown code block. Andrzej was given a task: There are n jars with pills. In every jar there is a different type of pill and the amount of pills in each jar is infinite. One type of pill makes a person glow about 30 minutes after taking and none of the other types has any...
Solve the programming task below in a Python markdown code block. We make a tower by stacking up blocks. The tower consists of several stages and each stage is constructed by connecting blocks horizontally. Each block is of the same weight and is tough enough to withstand the weight equivalent to up to $K$ blocks with...
Solve the programming task below in a Python markdown code block. Decades have passed since the beginning of AtCoder Beginner Contest. The contests are labeled as ABC001, ABC002, ... from the first round, but after the 999-th round ABC999, a problem occurred: how the future rounds should be labeled? In the end, the la...
Solve the programming task below in a Python markdown code block. Berland National Library has recently been built in the capital of Berland. In addition, in the library you can take any of the collected works of Berland leaders, the library has a reading room. Today was the pilot launch of an automated reading room ...
Solve the programming task below in a Python markdown code block. Emuskald is addicted to Codeforces, and keeps refreshing the main page not to miss any changes in the "recent actions" list. He likes to read thread conversations where each thread consists of multiple messages. Recent actions shows a list of n differe...
Solve the programming task below in a Python markdown code block. The Little Elephant loves to play with color cards. He has n cards, each has exactly two colors (the color of the front side and the color of the back side). Initially, all the cards lay on the table with the front side up. In one move the Little Eleph...
Solve the programming task below in a Python markdown code block. In order to make the "Sea Battle" game more interesting, Boris decided to add a new ship type to it. The ship consists of two rectangles. The first rectangle has a width of $w_1$ and a height of $h_1$, while the second rectangle has a width of $w_2$ and...
Solve the programming task below in a Python markdown code block. You are given a sequence $a_1, a_2, \dots, a_n$ consisting of $n$ non-zero integers (i.e. $a_i \ne 0$). You have to calculate two following values: the number of pairs of indices $(l, r)$ $(l \le r)$ such that $a_l \cdot a_{l + 1} \dots a_{r - 1} \cd...
Solve the programming task below in a Python markdown code block. Write a program which reads relations in a SNS (Social Network Service), and judges that given pairs of users are reachable each other through the network. Constraints * $2 \leq n \leq 100,000$ * $0 \leq m \leq 100,000$ * $1 \leq q \leq 10,000$ Input...
Solve the programming task below in a Python markdown code block. You are given an array a of size n, and q queries to it. There are queries of two types: 1 l_{i} r_{i} — perform a cyclic shift of the segment [l_{i}, r_{i}] to the right. That is, for every x such that l_{i} ≤ x < r_{i} new value of a_{x} + 1 becomes...
Solve the programming task below in a Python markdown code block. Lo and Behold! For you may be surprised by what our chief chef Noodle has in mind for this season! Today, Noodle announced one of his most extra-ordinary ideas ever - Project Spoon. Noodle plans to deploy large spoons in the atmosphere so that people a...
Solve the programming task below in a Python markdown code block. You are given an integer N. Among the integers between 1 and N (inclusive), how many Shichi-Go-San numbers (literally "Seven-Five-Three numbers") are there? Here, a Shichi-Go-San number is a positive integer that satisfies the following condition: - Wh...
Solve the programming task below in a Python markdown code block. Given is an integer N. Find the number of positive integers less than or equal to N that have an odd number of digits (in base ten without leading zeros). -----Constraints----- - 1 \leq N \leq 10^5 -----Input----- Input is given from Standard Input i...
Solve the programming task below in a Python markdown code block. Ternary numeric notation is quite popular in Berland. To telegraph the ternary number the Borze alphabet is used. Digit 0 is transmitted as «.», 1 as «-.» and 2 as «--». You are to decode the Borze code, i.e. to find out the ternary number given its rep...
Solve the programming task below in a Python markdown code block. You are given an array $A$ of length $N$ weights of masses $A_1$, $A_2$...$A_N$. No two weights have the same mass. You can put every weight on one side of the balance (left or right). You don't have to put weights in order $A_1$,...,$A_N$. There is als...
Solve the programming task below in a Python markdown code block. # Task You are given a string `s`. Every letter in `s` appears once. Consider all strings formed by rearranging the letters in `s`. After ordering these strings in dictionary order, return the middle term. (If the sequence has a even length `n`, de...
Solve the programming task below in a Python markdown code block. You are given an array $a$ of length $n$ and array $b$ of length $m$ both consisting of only integers $0$ and $1$. Consider a matrix $c$ of size $n \times m$ formed by following rule: $c_{i, j} = a_i \cdot b_j$ (i.e. $a_i$ multiplied by $b_j$). It's eas...
Solve the programming task below in a Python markdown code block. Santa Claus has received letters from $n$ different kids throughout this year. Of course, each kid wants to get some presents from Santa: in particular, the $i$-th kid asked Santa to give them one of $k_i$ different items as a present. Some items could ...
Solve the programming task below in a Python markdown code block. SmallR is an archer. SmallR is taking a match of archer with Zanoes. They try to shoot in the target in turns, and SmallR shoots first. The probability of shooting the target each time is $\frac{a}{b}$ for SmallR while $\frac{c}{d}$ for Zanoes. The one ...
Solve the programming task below in a Python markdown code block. You have a given integer $n$. Find the number of ways to fill all $3 \times n$ tiles with the shape described in the picture below. Upon filling, no empty spaces are allowed. Shapes cannot overlap. $\square$ This picture describes when $n = 4$. The left...
Solve the programming task below in a Python markdown code block. Young boy Artem tries to paint a picture, and he asks his mother Medina to help him. Medina is very busy, that's why she asked for your help. Artem wants to paint an $n \times m$ board. Each cell of the board should be colored in white or black. Lets...
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. You are given a positive integer $D$. Let's build the following graph from it: each vertex is a divisor of $D$ (not necessarily prime, $1$ and $D$ itself are also included); two vertices $x$ and $y$ ($x > y$) have an undirected edge between them if $...
Solve the programming task below in a Python markdown code block. The Little Elephant has an integer a, written in the binary notation. He wants to write this number on a piece of paper. To make sure that the number a fits on the piece of paper, the Little Elephant ought to delete exactly one any digit from number a ...
Solve the programming task below in a Python markdown code block. A direced graph is strongly connected if every two nodes are reachable from each other. In a strongly connected component of a directed graph, every two nodes of the component are mutually reachable. Constraints * 1 ≤ |V| ≤ 10,000 * 0 ≤ |E| ≤ 30,000 *...
Solve the programming task below in a Python markdown code block. INTERCAL is the oldest of esoteric programming languages. One of its many weird features is the method of character-based output, known as Turing Tape method. It converts an array of unsigned 8-bit integers into a sequence of characters to print, using ...
Solve the programming task below in a Python markdown code block. Overlooking the captivating blend of myriads of vernal hues, Arkady the painter lays out a long, long canvas. Arkady has a sufficiently large amount of paint of three colours: cyan, magenta, and yellow. On the one-dimensional canvas split into n consec...
Solve the programming task below in a Python markdown code block. You are given $n$ integers $w_i (i = 0, 1, ..., n-1)$ to be sorted in ascending order. You can swap two integers $w_i$ and $w_j$. Each swap operation has a cost, which is the sum of the two integers $w_i + w_j$. You can perform the operations any number...
Solve the programming task below in a Python markdown code block. A [Narcissistic Number](https://en.wikipedia.org/wiki/Narcissistic_number) is a positive number which is the sum of its own digits, each raised to the power of the number of digits in a given base. In this Kata, we will restrict ourselves to decimal (ba...
Solve the programming task below in a Python markdown code block. Polycarp is preparing the first programming contest for robots. There are $n$ problems in it, and a lot of robots are going to participate in it. Each robot solving the problem $i$ gets $p_i$ points, and the score of each robot in the competition is cal...
Solve the programming task below in a Python markdown code block. Mobile phones are equipped with a function that displays input candidates in order to efficiently input texts such as emails. This records frequently used words and presents words that have the entered letters as initial letters as input candidates. For...
Solve the programming task below in a Python markdown code block. Vova's house is an array consisting of $n$ elements (yeah, this is the first problem, I think, where someone lives in the array). There are heaters in some positions of the array. The $i$-th element of the array is $1$ if there is a heater in the positi...
Solve the programming task below in a Python markdown code block. It is known that there are k fish species in the polar ocean, numbered from 1 to k. They are sorted by non-decreasing order of their weight, which is a positive number. Let the weight of the i-th type of fish be wi, then 0 < w1 ≤ w2 ≤ ... ≤ wk holds. P...
Solve the programming task below in a Python markdown code block. In this Kata, you will be given an array of unique elements, and your task is to rerrange the values so that the first max value is followed by the first minimum, followed by second max value then second min value, etc. For example: The first max is `...
Solve the programming task below in a Python markdown code block. You are playing one RPG from the 2010s. You are planning to raise your smithing skill, so you need as many resources as possible. So how to get resources? By stealing, of course. You decided to rob a town's blacksmith and you take a follower with you. ...
Solve the programming task below in a Python markdown code block. As you know, every birthday party has a cake! This time, Babaei is going to prepare the very special birthday party's cake. Simple cake is a cylinder of some radius and height. The volume of the simple cake is equal to the volume of corresponding cylin...
Solve the programming task below in a Python markdown code block. The football season has just ended in Berland. According to the rules of Berland football, each match is played between two teams. The result of each match is either a draw, or a victory of one of the playing teams. If a team wins the match, it gets w p...
Solve the programming task below in a Python markdown code block. In an infinite array with two rows, the numbers in the top row are denoted `. . . , A[−2], A[−1], A[0], A[1], A[2], . . .` and the numbers in the bottom row are denoted `. . . , B[−2], B[−1], B[0], B[1], B[2], . . .` For each integer `k`, the entry ...
Solve the programming task below in a Python markdown code block. Vanya got n cubes. He decided to build a pyramid from them. Vanya wants to build the pyramid as follows: the top level of the pyramid must consist of 1 cube, the second level must consist of 1 + 2 = 3 cubes, the third level must have 1 + 2 + 3 = 6 cubes...
Solve the programming task below in a Python markdown code block. There are N bags of biscuits. The i-th bag contains A_i biscuits. Takaki will select some of these bags and eat all of the biscuits inside. Here, it is also possible to select all or none of the bags. He would like to select bags so that the total num...
Solve the programming task below in a Python markdown code block. Some days ago, I learned the concept of LCM (least common multiple). I've played with it for several times and I want to make a big number with it. But I also don't want to use many numbers, so I'll choose three positive integers (they don't have to be...
Solve the programming task below in a Python markdown code block. Given a string, return a new string that has transformed based on the input: * Change case of every character, ie. lower case to upper case, upper case to lower case. * Reverse the order of words from the input. **Note:** You will have to handle multi...
Solve the programming task below in a Python markdown code block. You are given a string S consisting of lowercase English letters. Determine whether all the characters in S are different. -----Constraints----- - 2 ≤ |S| ≤ 26, where |S| denotes the length of S. - S consists of lowercase English letters. -----Input...
Solve the programming task below in a Python markdown code block. The function is not returning the correct values. Can you figure out why? ```python get_planet_name(3) # should return 'Earth' ``` Write your solution by modifying this code: ```python def get_planet_name(id): ``` Your solution should implemented ...
Solve the programming task below in a Python markdown code block. # Task A lock has `n` buttons in it, numbered from `1 to n`. To open the lock, you have to press all buttons in some order, i.e. a key to the lock is a permutation of the first `n` integers. If you push the right button in the right order, it will be p...
Solve the programming task below in a Python markdown code block. Little Artem got n stones on his birthday and now wants to give some of them to Masha. He knows that Masha cares more about the fact of receiving the present, rather than the value of that present, so he wants to give her stones as many times as possibl...
Solve the programming task below in a Python markdown code block. To help those contestants who struggle a lot in contests, the headquarters of Codeforces are planning to introduce Division 5. In this new division, the tags of all problems will be announced prior to the round to help the contestants. The contest cons...
Solve the programming task below in a Python markdown code block. Monocarp has been collecting rare magazines for quite a while, and now he has decided to sell them. He distributed the magazines between $n$ boxes, arranged in a row. The $i$-th box contains $a_i$ magazines. Some of the boxes are covered with lids, othe...
Solve the programming task below in a Python markdown code block. Analyzing the mistakes people make while typing search queries is a complex and an interesting work. As there is no guaranteed way to determine what the user originally meant by typing some query, we have to use different sorts of heuristics. Polycarp ...
Solve the programming task below in a Python markdown code block. There is a city that can be represented as a square grid with corner points in $(0, 0)$ and $(10^6, 10^6)$. The city has $n$ vertical and $m$ horizontal streets that goes across the whole city, i. e. the $i$-th vertical streets goes from $(x_i, 0)$ to ...
Solve the programming task below in a Python markdown code block. In this Kata, you will be given an array of integers and your task is to return the number of arithmetic progressions of size `3` that are possible from that list. In each progression, the differences between the elements must be the same. ``` [1, 2, 3...
Solve the programming task below in a Python markdown code block. Find the minimum number with the given sum of digits $s$ such that all digits in it are distinct (i.e. all digits are unique). For example, if $s=20$, then the answer is $389$. This is the minimum number in which all digits are different and the sum of...
Solve the programming task below in a Python markdown code block. In Summer Informatics School, if a student doesn't behave well, teachers make a hole in his badge. And today one of the teachers caught a group of $n$ students doing yet another trick. Let's assume that all these students are numbered from $1$ to $n$....
Solve the programming task below in a Python markdown code block. The only difference between easy and hard versions is constraints. A session has begun at Beland State University. Many students are taking exams. Polygraph Poligrafovich is going to examine a group of $n$ students. Students will take the exam one-by-...
Solve the programming task below in a Python markdown code block. Polycarp is writing the prototype of a graphic editor. He has already made up his mind that the basic image transformations in his editor will be: rotate the image 90 degrees clockwise, flip the image horizontally (symmetry relative to the vertical line...
Solve the programming task below in a Python markdown code block. Being tired of participating in too many Codeforces rounds, Gildong decided to take some rest in a park. He sat down on a bench, and soon he found two rabbits hopping around. One of the rabbits was taller than the other. He noticed that the two rabbits...
Solve the programming task below in a Python markdown code block. There are some rabbits in Singapore Zoo. To feed them, Zookeeper bought $n$ carrots with lengths $a_1, a_2, a_3, \ldots, a_n$. However, rabbits are very fertile and multiply very quickly. Zookeeper now has $k$ rabbits and does not have enough carrots to...
Solve the programming task below in a Python markdown code block. Consider all binary strings of length $m$ ($1 \le m \le 60$). A binary string is a string that consists of the characters 0 and 1 only. For example, 0110 is a binary string, and 012aba is not. Obviously, there are exactly $2^m$ such strings in total. T...
Solve the programming task below in a Python markdown code block. In some countries of former Soviet Union there was a belief about lucky tickets. A transport ticket of any sort was believed to posess luck if sum of digits on the left half of its number was equal to the sum of digits on the right half. Here are exampl...
Solve the programming task below in a Python markdown code block. In the official contest this problem has a different statement, for which jury's solution was working incorrectly, and for this reason it was excluded from the contest. This mistake have been fixed and the current given problem statement and model solut...
Solve the programming task below in a Python markdown code block. A few years ago, Hitagi encountered a giant crab, who stole the whole of her body weight. Ever since, she tried to avoid contact with others, for fear that this secret might be noticed. To get rid of the oddity and recover her weight, a special integer...
Solve the programming task below in a Python markdown code block. For encrypting strings this region of chars is given (in this order!): * all letters (ascending, first all UpperCase, then all LowerCase) * all digits (ascending) * the following chars: `.,:;-?! '()$%&"` These are 77 chars! (This region is zero-based...
Solve the programming task below in a Python markdown code block. You are given a prime number $p$, $n$ integers $a_1, a_2, \ldots, a_n$, and an integer $k$. Find the number of pairs of indexes $(i, j)$ ($1 \le i < j \le n$) for which $(a_i + a_j)(a_i^2 + a_j^2) \equiv k \bmod p$. -----Input----- The first line c...
Solve the programming task below in a Python markdown code block. We have two desks: A and B. Desk A has a vertical stack of N books on it, and Desk B similarly has M books on it. It takes us A_i minutes to read the i-th book from the top on Desk A (1 \leq i \leq N), and B_i minutes to read the i-th book from the top ...
Solve the programming task below in a Python markdown code block. A soldier wants to buy w bananas in the shop. He has to pay k dollars for the first banana, 2k dollars for the second one and so on (in other words, he has to pay i·k dollars for the i-th banana). He has n dollars. How many dollars does he have to bor...
Solve the programming task below in a Python markdown code block. The Earth has been invaded by aliens. They demand our beer and threaten to destroy the Earth if we do not supply the exact number of beers demanded. Unfortunately, the aliens only speak Morse code. Write a program to convert morse code into numbers usi...
Solve the programming task below in a Python markdown code block. Fox Ciel is playing a card game with her friend Jiro. Jiro has n cards, each one has two attributes: position (Attack or Defense) and strength. Fox Ciel has m cards, each one has these two attributes too. It's known that position of all Ciel's cards is...
Solve the programming task below in a Python markdown code block. In Russia regular bus tickets usually consist of 6 digits. The ticket is called lucky when the sum of the first three digits equals to the sum of the last three digits. Write a function to find out whether the ticket is lucky or not. Return true if so, ...
Solve the programming task below in a Python markdown code block. While dad was at work, a little girl Tanya decided to play with dad's password to his secret database. Dad's password is a string consisting of n + 2 characters. She has written all the possible n three-letter continuous substrings of the password on pi...
Solve the programming task below in a Python markdown code block. You are given an array $a$ consisting of $500000$ integers (numbered from $1$ to $500000$). Initially all elements of $a$ are zero. You have to process two types of queries to this array: $1$ $x$ $y$ — increase $a_x$ by $y$; $2$ $x$ $y$ — compute $\s...
Solve the programming task below in a Python markdown code block. There is a building consisting of $10~000$ apartments numbered from $1$ to $10~000$, inclusive. Call an apartment boring, if its number consists of the same digit. Examples of boring apartments are $11, 2, 777, 9999$ and so on. Our character is a trou...
Solve the programming task below in a Python markdown code block. Ezzat has an array of $n$ integers (maybe negative). He wants to split it into two non-empty subsequences $a$ and $b$, such that every element from the array belongs to exactly one subsequence, and the value of $f(a) + f(b)$ is the maximum possible valu...
Solve the programming task below in a Python markdown code block. Mahmoud wrote a message s of length n. He wants to send it as a birthday present to his friend Moaz who likes strings. He wrote it on a magical paper but he was surprised because some characters disappeared while writing the string. That's because this ...
Solve the programming task below in a Python markdown code block. Create a function that interprets code in the esoteric language **Poohbear** ## The Language Poohbear is a stack-based language largely inspired by Brainfuck. It has a maximum integer value of 255, and 30,000 cells. The original intention of Poohbear ...
Solve the programming task below in a Python markdown code block. Problem statement Real variables $ x_1, x_2, ..., x_N $ satisfy the following conditions. 1. $ 0 \ leq x_i \ leq 1 $ ($ 1 \ leq i \ leq N $) 2. $ w_1x_1 + w_2x_2 + ... + w_Nx_N \ leq W $ At this time, find the maximum value that $ v_1x_1 + v_2x_2 +...
Solve the programming task below in a Python markdown code block. There are N towns in Takahashi Kingdom. They are conveniently numbered 1 through N. Takahashi the king is planning to go on a tour of inspection for M days. He will determine a sequence of towns c, and visit town c_i on the i-th day. That is, on the i-...
Solve the programming task below in a Python markdown code block. ATM machines allow 4 or 6 digit PIN codes and PIN codes cannot contain anything but **exactly** 4 digits or exactly 6 digits. If the function is passed a valid PIN string, return `true`, else return `false`. ## Examples ``` "1234" --> true "12345...
Solve the programming task below in a Python markdown code block. In this Kata, you will be given an integer `n` and your task will be to return `the largest integer that is <= n and has the highest digit sum`. For example: ``` solve(100) = 99. Digit Sum for 99 = 9 + 9 = 18. No other number <= 100 has a higher digit ...
Solve the programming task below in a Python markdown code block. Bertown is a city with $n$ buildings in a straight line. The city's security service discovered that some buildings were mined. A map was compiled, which is a string of length $n$, where the $i$-th character is "1" if there is a mine under the building...
Solve the programming task below in a Python markdown code block. There are n beacons located at distinct positions on a number line. The i-th beacon has position a_{i} and power level b_{i}. When the i-th beacon is activated, it destroys all beacons to its left (direction of decreasing coordinates) within distance b_...
Solve the programming task below in a Python markdown code block. Polycarp is playing a new computer game. This game has $n$ stones in a row. The stone on the position $i$ has integer power $a_i$. The powers of all stones are distinct. Each turn Polycarp can destroy either stone on the first position or stone on the ...
Solve the programming task below in a Python markdown code block. Anton likes to listen to fairy tales, especially when Danik, Anton's best friend, tells them. Right now Danik tells Anton a fairy tale: "Once upon a time, there lived an emperor. He was very rich and had much grain. One day he ordered to build a huge b...
Solve the programming task below in a Python markdown code block. There are N people living on a number line. The i-th person lives at coordinate X_i. You are going to hold a meeting that all N people have to attend. The meeting can be held at any integer coordinate. If you choose to hold the meeting at coordinate P, ...
Solve the programming task below in a Python markdown code block. You are given four integers $n$, $c_0$, $c_1$ and $h$ and a binary string $s$ of length $n$. A binary string is a string consisting of characters $0$ and $1$. You can change any character of the string $s$ (the string should be still binary after the ...
Solve the programming task below in a Python markdown code block. You are given an array a of length n. Let's define the eversion operation. Let x = a_n. Then array a is partitioned into two parts: left and right. The left part contains the elements of a that are not greater than x (≤ x). The right part contains the ...
Solve the programming task below in a Python markdown code block. You've got an array, consisting of n integers a_1, a_2, ..., a_{n}. Also, you've got m queries, the i-th query is described by two integers l_{i}, r_{i}. Numbers l_{i}, r_{i} define a subsegment of the original array, that is, the sequence of numbers a_...
Solve the programming task below in a Python markdown code block. Problem Given the string S, which consists of lowercase letters and numbers. Follow the steps below to compress the length of string S. 1. Change the order of the characters in the character string to any order. Example: "0ig3he12fz99"-> "efghiz012399...
Solve the programming task below in a Python markdown code block. Based on [this kata, Connect Four.](https://www.codewars.com/kata/connect-four-1) In this kata we play a modified game of connect four. It's connect X, and there can be multiple players. Write the function ```whoIsWinner(moves,connect,size)```. ```2 ...
Solve the programming task below in a Python markdown code block. Write a function that takes a string which has integers inside it separated by spaces, and your task is to convert each integer in the string into an integer and return their sum. ### Example ```python summy("1 2 3") ==> 6 ``` Good luck! Write your ...
Solve the programming task below in a Python markdown code block. Vasya owns three big integers — $a, l, r$. Let's define a partition of $x$ such a sequence of strings $s_1, s_2, \dots, s_k$ that $s_1 + s_2 + \dots + s_k = x$, where $+$ is a concatanation of strings. $s_i$ is the $i$-th element of the partition. For e...
Solve the programming task below in a Python markdown code block. Memory and his friend Lexa are competing to get higher score in one popular computer game. Memory starts with score a and Lexa starts with score b. In a single turn, both Memory and Lexa get some integer in the range [ - k;k] (i.e. one integer among - ...
Solve the programming task below in a Python markdown code block. # Task John was in math class and got bored, so he decided to fold some origami from a rectangular `a × b` sheet of paper (`a > b`). His first step is to make a square piece of paper from the initial rectangular piece of paper by folding the sheet along...
Solve the programming task below in a Python markdown code block. problem Given the sequence $ A $ of length $ N $. The $ i $ item in $ A $ is $ A_i $. You can do the following for this sequence: * $ 1 \ leq i \ leq N --Choose the integer i that is 1 $. Swap the value of $ A_i $ with the value of $ A_ {i + 1} $. ...
Solve the programming task below in a Python markdown code block. Given a string of integers, return the number of odd-numbered substrings that can be formed. For example, in the case of `"1341"`, they are `1, 1, 3, 13, 41, 341, 1341`, a total of `7` numbers. `solve("1341") = 7`. See test cases for more examples....
Solve the programming task below in a Python markdown code block. Amr doesn't like Maths as he finds it really boring, so he usually sleeps in Maths lectures. But one day the teacher suspected that Amr is sleeping and asked him a question to make sure he wasn't. First he gave Amr two positive integers n and k. Then h...
Solve the programming task below in a Python markdown code block. There is a circle with a circumference of L. Each point on the circumference has a coordinate value, which represents the arc length from a certain reference point clockwise to the point. On this circumference, there are N ants. These ants are numbered ...
Solve the programming task below in a Python markdown code block. Nathan O. Davis has been running an electronic bulletin board system named JAG-channel. He is now having hard time to add a new feature there --- threaded view. Like many other bulletin board systems, JAG-channel is thread-based. Here a thread (also ca...
Solve the programming task below in a Python markdown code block. # Task Given a string `s`, find out if its characters can be rearranged to form a palindrome. # Example For `s = "aabb"`, the output should be `true`. We can rearrange `"aabb"` to make `"abba"`, which is a palindrome. # Input/Output - `[input]...