question
large_stringlengths
265
13.2k
Solve the programming task below in a Python markdown code block. Write a function named `first_non_repeating_letter` that takes a string input, and returns the first character that is not repeated anywhere in the string. For example, if given the input `'stress'`, the function should return `'t'`, since the letter *...
Solve the programming task below in a Python markdown code block. Vasya has got a robot which is situated on an infinite Cartesian plane, initially in the cell $(0, 0)$. Robot can perform the following four kinds of operations: U — move from $(x, y)$ to $(x, y + 1)$; D — move from $(x, y)$ to $(x, y - 1)$; L — mov...
Solve the programming task below in a Python markdown code block. In some country live wizards. They love playing with numbers. The blackboard has two numbers written on it — a and b. The order of the numbers is not important. Let's consider a ≤ b for the sake of definiteness. The players can cast one of the two spe...
Solve the programming task below in a Python markdown code block. As AtCoder Beginner Contest 100 is taking place, the office of AtCoder, Inc. is decorated with a sequence of length N, a = {a_1, a_2, a_3, ..., a_N}. Snuke, an employee, would like to play with this sequence. Specifically, he would like to repeat the f...
Solve the programming task below in a Python markdown code block. Four players participate in the playoff tournament. The tournament is held according to the following scheme: the first player will play with the second, and the third player with the fourth, then the winners of the pairs will play in the finals of the ...
Solve the programming task below in a Python markdown code block. For a given positive integer n denote its k-rounding as the minimum positive integer x, such that x ends with k or more zeros in base 10 and is divisible by n. For example, 4-rounding of 375 is 375·80 = 30000. 30000 is the minimum integer such that it ...
Solve the programming task below in a Python markdown code block. You are fed up with your messy room, so you decided to clean it up. Your room is a bracket sequence $s=s_{1}s_{2}\dots s_{n}$ of length $n$. Each character of this string is either an opening bracket '(' or a closing bracket ')'. In one operation you ...
Solve the programming task below in a Python markdown code block. You are given the string s of length n and the numbers p, q. Split the string s to pieces of length p and q. For example, the string "Hello" for p = 2, q = 3 can be split to the two strings "Hel" and "lo" or to the two strings "He" and "llo". Note it ...
Solve the programming task below in a Python markdown code block. In this problem you have to solve a simple classification task: given an image, determine whether it depicts a Fourier doodle. You are given a set of 50 images with ids 1 through 50. You are also given a text file labels.txt containing the labels for ...
Solve the programming task below in a Python markdown code block. A substring of some string is called the most frequent, if the number of its occurrences is not less than number of occurrences of any other substring. You are given a set of strings. A string (not necessarily from this set) is called good if all eleme...
Solve the programming task below in a Python markdown code block. You are given a permutation $p_1, p_2, \ldots, p_n$. In one move you can swap two adjacent values. You want to perform a minimum number of moves, such that in the end there will exist a subsegment $1,2,\ldots, k$, in other words in the end there shoul...
Solve the programming task below in a Python markdown code block. Write a function which outputs the positions of matching bracket pairs. The output should be a dictionary with keys the positions of the open brackets '(' and values the corresponding positions of the closing brackets ')'. For example: input = "(first)...
Solve the programming task below in a Python markdown code block. Addition of Big Integers Given two integers $A$ and $B$, compute the sum, $A + B$. Input Two integers $A$ and $B$ separated by a space character are given in a line. Output Print the sum in a line. Constraints * $-1 \times 10^{100000} \leq A, B \...
Solve the programming task below in a Python markdown code block. Celebrating the new year, many people post videos of falling dominoes; Here's a list of them: https://www.youtube.com/results?search_query=New+Years+Dominos User ainta, who lives in a 2D world, is going to post a video as well. There are n dominoes on...
Solve the programming task below in a Python markdown code block. George has recently entered the BSUCP (Berland State University for Cool Programmers). George has a friend Alex who has also entered the university. Now they are moving into a dormitory. George and Alex want to live in the same room. The dormitory has...
Solve the programming task below in a Python markdown code block. Your friend Jeff Zebos has been trying to run his new online company, but it's not going very well. He's not getting a lot of sales on his website which he decided to call Azamon. His big problem, you think, is that he's not ranking high enough on the s...
Solve the programming task below in a Python markdown code block. Bob is preparing to pass IQ test. The most frequent task in this test is `to find out which one of the given numbers differs from the others`. Bob observed that one number usually differs from the others in **evenness**. Help Bob — to check his answers,...
Solve the programming task below in a Python markdown code block. Kate has a set $S$ of $n$ integers $\{1, \dots, n\} $. She thinks that imperfection of a subset $M \subseteq S$ is equal to the maximum of $gcd(a, b)$ over all pairs $(a, b)$ such that both $a$ and $b$ are in $M$ and $a \neq b$. Kate is a very neat ...
Solve the programming task below in a Python markdown code block. Chef is fan of pairs and he likes all things that come in pairs. He even has a doll collection in which the dolls come in pairs. One day while going through his collection he found that there are odd number of dolls. Someone had stolen a doll!!! Help ...
Solve the programming task below in a Python markdown code block. A string is called palindrome if it reads the same from left to right and from right to left. For example "kazak", "oo", "r" and "mikhailrubinchikkihcniburliahkim" are palindroms, but strings "abb" and "ij" are not. You are given string s consisting of...
Solve the programming task below in a Python markdown code block. You might have heard about our new goodie distribution program aka the "Laddu Accrual System". This problem is designed to give you a glimpse of its rules. You can read the page once before attempting the problem if you wish, nonetheless we will be prov...
Solve the programming task below in a Python markdown code block. The only difference between easy and hard versions are constraints on $n$ and $k$. You are messaging in one of the popular social networks via your smartphone. Your smartphone can show at most $k$ most recent conversations with your friends. Initially,...
Solve the programming task below in a Python markdown code block. According to Berland laws it is only allowed to sell alcohol to people not younger than 18 years. Vasya's job is to monitor the law's enforcement. Tonight he entered a bar and saw n people sitting there. For every one of them Vasya happened to determine...
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$ integers. You may perform the following operation on this sequence: choose any element and either increase or decrease it by one. Calculate the minimum possible difference between the m...
Solve the programming task below in a Python markdown code block. In this problem is used an extremely simplified version of HTML table markup. Please use the statement as a formal document and read it carefully. A string is a bHTML table, if it satisfies the grammar: TABLE ::= <table>ROWS</tabl...
Solve the programming task below in a Python markdown code block. Snuke stands on a number line. He has L ears, and he will walk along the line continuously under the following conditions: * He never visits a point with coordinate less than 0, or a point with coordinate greater than L. * He starts walking at a point ...
Solve the programming task below in a Python markdown code block. In one of the games Arkady is fond of the game process happens on a rectangular field. In the game process Arkady can buy extensions for his field, each extension enlarges one of the field sizes in a particular number of times. Formally, there are n ext...
Solve the programming task below in a Python markdown code block. One day shooshuns found a sequence of n integers, written on a blackboard. The shooshuns can perform one operation with it, the operation consists of two steps: 1. Find the number that goes k-th in the current sequence and add the same number to the ...
Solve the programming task below in a Python markdown code block. Mr. A, who will graduate next spring, decided to move when he got a job. The company that finds a job has offices in several towns, and the offices that go to work differ depending on the day. So Mr. A decided to live in a town where he had a short time...
Solve the programming task below in a Python markdown code block. Let's define a forest as a non-directed acyclic graph (also without loops and parallel edges). One day Misha played with the forest consisting of n vertices. For each vertex v from 0 to n - 1 he wrote down two integers, degreev and sv, were the first in...
Solve the programming task below in a Python markdown code block. B: Dansunau www --Dance Now!- story Last lab life! Daigakuin! !! Dosanko Snow has won 9th place in the event "Master Idol World", which can be said to be the outpost of the biggest competition "Lab Life" where master idols compete. The sharp dance is ...
Solve the programming task below in a Python markdown code block. Write a function that takes a positive integer and returns the next smaller positive integer containing the same digits. For example: ```python next_smaller(21) == 12 next_smaller(531) == 513 next_smaller(2071) == 2017 ``` Return -1 (for `Haskell`: r...
Solve the programming task below in a Python markdown code block. problem Five students, Taro, Jiro, Saburo, Shiro, and Hanako, participated in the JOI High School class. In this class, a final exam was conducted. All five people took the final exam. For students with a final exam score of 40 or higher, the final ex...
Solve the programming task below in a Python markdown code block. Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given a and b. Constraints * 0 < a, b ≤ 2,000,000,000 * LCM(a, b) ≤ 2,000,000,000 * The number of data sets ≤ 50 Input Input consists of several ...
Solve the programming task below in a Python markdown code block. You have a string s = s_1s_2...s_{|}s|, where |s| is the length of string s, and s_{i} its i-th character. Let's introduce several definitions: A substring s[i..j] (1 ≤ i ≤ j ≤ |s|) of string s is string s_{i}s_{i} + 1...s_{j}. The prefix of string ...
Solve the programming task below in a Python markdown code block. You manage 4 buildings, each of which has 3 floors, each of which consists of 10 rooms. Write a program which reads a sequence of tenant/leaver notices, and reports the number of tenants for each room. For each notice, you are given four integers b, f,...
Solve the programming task below in a Python markdown code block. Takahashi has a lot of peculiar devices. These cylindrical devices receive balls from left and right. Each device is in one of the two states A and B, and for each state, the device operates as follows: * When a device in state A receives a ball from e...
Solve the programming task below in a Python markdown code block. See the following triangle: ``` ____________________________________ 1 2 4 2 3 6 9 6 3 4 8 12 16 12 8 4 5 10 15 20 25 ...
Solve the programming task below in a Python markdown code block. Step through my `green glass door`. You can take the `moon`, but not the `sun`. You can take your `slippers`, but not your `sandals`. You can go through `yelling`, but not `shouting`. You can't run through `fast`, but you can run with `speed`. You ...
Solve the programming task below in a Python markdown code block. You are given a string S of length 2N, containing N occurrences of `a` and N occurrences of `b`. You will choose some of the characters in S. Here, for each i = 1,2,...,N, it is not allowed to choose exactly one of the following two: the i-th occurrenc...
Solve the programming task below in a Python markdown code block. 10^{10^{10}} participants, including Takahashi, competed in two programming contests. In each contest, all participants had distinct ranks from first through 10^{10^{10}}-th. The score of a participant is the product of his/her ranks in the two contests...
Solve the programming task below in a Python markdown code block. After you had helped Fedor to find friends in the «Call of Soldiers 3» game, he stopped studying completely. Today, the English teacher told him to prepare an essay. Fedor didn't want to prepare the essay, so he asked Alex for help. Alex came to help an...
Solve the programming task below in a Python markdown code block. Gerald has been selling state secrets at leisure. All the secrets cost the same: n marks. The state which secrets Gerald is selling, has no paper money, only coins. But there are coins of all positive integer denominations that are powers of three: 1 ma...
Solve the programming task below in a Python markdown code block. N of us are going on a trip, by train or taxi. The train will cost each of us A yen (the currency of Japan). The taxi will cost us a total of B yen. How much is our minimum total travel expense? -----Constraints----- - All values in input are integers...
Solve the programming task below in a Python markdown code block. Pari wants to buy an expensive chocolate from Arya. She has n coins, the value of the i-th coin is c_{i}. The price of the chocolate is k, so Pari will take a subset of her coins with sum equal to k and give it to Arya. Looking at her coins, a question...
Solve the programming task below in a Python markdown code block. Write a program which reads three integers a, b and c, and prints "Yes" if a < b < c, otherwise "No". Constraints * 0 ≤ a, b, c ≤ 100 Input Three integers a, b and c separated by a single space are given in a line. Output Print "Yes" or "No" in a ...
Solve the programming task below in a Python markdown code block. A population of bears consists of black bears, brown bears, and white bears. The input is an array of two elements. Determine whether the offspring of the two bears will return `'black'`, `'brown'`, `'white'`, `'dark brown'`, `'grey'`, `'light brown'...
Solve the programming task below in a Python markdown code block. You're given an array $a$. You should repeat the following operation $k$ times: find the minimum non-zero element in the array, print it, and then subtract it from all the non-zero elements of the array. If all the elements are 0s, just print 0. -----...
Solve the programming task below in a Python markdown code block. Recently Vladik discovered a new entertainment — coding bots for social networks. He would like to use machine learning in his bots so now he want to prepare some learning data for them. At first, he need to download t chats. Vladik coded a script whic...
Solve the programming task below in a Python markdown code block. Arithmetic Progressions An arithmetic progression is a sequence of numbers $a_1, a_2, ..., a_k$ where the difference of consecutive members $a_{i+1} - a_i$ is a constant ($1 \leq i \leq k-1$). For example, the sequence 5, 8, 11, 14, 17 is an arithmetic...
Solve the programming task below in a Python markdown code block. A triple of numbers is said to be poor when two of those numbers are equal but the other number is different from those two numbers. You will be given three integers A, B, and C. If this triple is poor, print Yes; otherwise, print No. -----Constraints-...
Solve the programming task below in a Python markdown code block. Takahashi and Aoki are going to together construct a sequence of integers. First, Takahashi will provide a sequence of integers a, satisfying all of the following conditions: - The length of a is N. - Each element in a is an integer between 1 and K, i...
Solve the programming task below in a Python markdown code block. We have N+1 integers: 10^{100}, 10^{100}+1, ..., 10^{100}+N. We will choose K or more of these integers. Find the number of possible values of the sum of the chosen numbers, modulo (10^9+7). -----Constraints----- - 1 \leq N \leq 2\times 10^5 - 1 \leq...
Solve the programming task below in a Python markdown code block. Ivan unexpectedly saw a present from one of his previous birthdays. It is array of $n$ numbers from $1$ to $200$. Array is old and some numbers are hard to read. Ivan remembers that for all elements at least one of its neighbours ls not less than it, mo...
Solve the programming task below in a Python markdown code block. General primality test are often computationally expensive, so in the biggest prime number race the idea is to study special sub-families of prime number and develop more effective tests for them. [Mersenne Primes](https://en.wikipedia.org/wiki/Mersen...
Solve the programming task below in a Python markdown code block. Karafs is some kind of vegetable in shape of an 1 × h rectangle. Tavaspolis people love Karafs and they use Karafs in almost any kind of food. Tavas, himself, is crazy about Karafs. [Image] Each Karafs has a positive integer height. Tavas has an infin...
Solve the programming task below in a Python markdown code block. Your task is to determine the top 3 place finishes in a pole vault competition involving several different competitors. This is isn't always so simple, and it is often a source of confusion for people who don't know the actual rules. Here's what you ne...
Solve the programming task below in a Python markdown code block. One day, Niwango-kun, an employee of Dwango Co., Ltd., found an integer sequence (a_1, ..., a_N) of length N. He is interested in properties of the sequence a. For a nonempty contiguous subsequence a_l, ..., a_r (1 \leq l \leq r \leq N) of the sequence...
Solve the programming task below in a Python markdown code block. Zonk is addictive dice game. In each round player rolls 6 dice. Then (s)he composes combinations from them. Each combination gives certain points. Then player can take one or more dice combinations to his hand and re-roll remaining dice or save his sc...
Solve the programming task below in a Python markdown code block. King of Berland Berl IV has recently died. Hail Berl V! As a sign of the highest achievements of the deceased king the new king decided to build a mausoleum with Berl IV's body on the main square of the capital. The mausoleum will be constructed from 2...
Solve the programming task below in a Python markdown code block. Professor Matsuzaki is a scientist studying the truth of the universe. Life, the universe, all the answers are said to be 42, but Professor Matsuzaki thinks that this alone is not enough to elucidate the truth of the universe. Professor Matsuzaki believ...
Solve the programming task below in a Python markdown code block. A robot is put at the origin in a two-dimensional plane. Initially, the robot is facing in the positive x-axis direction. This robot will be given an instruction sequence s. s consists of the following two kinds of letters, and will be executed in order...
Solve the programming task below in a Python markdown code block. You are given a string $s$ of length $n$ consisting only of lowercase Latin letters. A substring of a string is a contiguous subsequence of that string. So, string "forces" is substring of string "codeforces", but string "coder" is not. Your task is t...
Solve the programming task below in a Python markdown code block. In the Bus of Characters there are $n$ rows of seat, each having $2$ seats. The width of both seats in the $i$-th row is $w_i$ centimeters. All integers $w_i$ are distinct. Initially the bus is empty. On each of $2n$ stops one passenger enters the bus....
Solve the programming task below in a Python markdown code block. We have a tree with N vertices, whose i-th edge connects Vertex u_i and Vertex v_i. Vertex i has an integer a_i written on it. For every integer k from 1 through N, solve the following problem: - We will make a sequence by lining up the integers writte...
Solve the programming task below in a Python markdown code block. We have a string of letters 'a' and 'b'. We want to perform some operations on it. On each step we choose one of substrings "ab" in the string and replace it with the string "bba". If we have no "ab" as a substring, our job is done. Print the minimum nu...
Solve the programming task below in a Python markdown code block. Iroha has a sequence of N strings S_1, S_2, ..., S_N. The length of each string is L. She will concatenate all of the strings in some order, to produce a long string. Among all strings that she can produce in this way, find the lexicographically smalles...
Solve the programming task below in a Python markdown code block. Suppose there is a $h \times w$ grid consisting of empty or full cells. Let's make some definitions: $r_{i}$ is the number of consecutive full cells connected to the left side in the $i$-th row ($1 \le i \le h$). In particular, $r_i=0$ if the leftmos...
Solve the programming task below in a Python markdown code block. In the online judge system, a judge file may include multiple datasets to check whether the submitted program outputs a correct answer for each test case. This task is to practice solving a problem with multiple datasets. Write a program which reads an...
Solve the programming task below in a Python markdown code block. You have a statistic of price changes for one product represented as an array of $n$ positive integers $p_0, p_1, \dots, p_{n - 1}$, where $p_0$ is the initial price of the product and $p_i$ is how the price was increased during the $i$-th month. Using...
Solve the programming task below in a Python markdown code block. All of the animals are having a feast! Each animal is bringing one dish. There is just one rule: the dish must start and end with the same letters as the animal's name. For example, the great blue heron is bringing garlic naan and the chickadee is bring...
Solve the programming task below in a Python markdown code block. <image> <image> *The two images are equivalent, feel free to use either one. Input The input contains a single integer a (-100 ≤ a ≤ 100). Output Output the result – an integer number. Example Input 1 Output 1 Read the inputs from stdin so...
Solve the programming task below in a Python markdown code block. There are S sheep and W wolves. If the number of wolves is greater than or equal to that of sheep, the wolves will attack the sheep. If the wolves will attack the sheep, print unsafe; otherwise, print safe. -----Constraints----- - 1 \leq S \leq 100 -...
Solve the programming task below in a Python markdown code block. In a very ancient country the following game was popular. Two people play the game. Initially first player writes a string s1, consisting of exactly nine digits and representing a number that does not exceed a. After that second player looks at s1 and w...
Solve the programming task below in a Python markdown code block. The pair of integer numbers `(m, n)`, such that `10 > m > n > 0`, (below 10), that its sum, `(m + n)`, and rest, `(m - n)`, are perfect squares, is (5, 4). Let's see what we have explained with numbers. ``` 5 + 4 = 9 = 3² 5 - 4 = 1 = 1² (10 > 5 > 4 > ...
Solve the programming task below in a Python markdown code block. # Task Alireza and Ali have a `3×3 table` and playing on that. they have 4 table(2×2) A,B,C and D in this table. At beginning all of 9 numbers in 3×3 table is zero. Alireza in each move choose a 2×2 table from A, B, C and D and increase all of 4 ...
Solve the programming task below in a Python markdown code block. Takahashi had a pair of two positive integers not exceeding N, (a,b), which he has forgotten. He remembers that the remainder of a divided by b was greater than or equal to K. Find the number of possible pairs that he may have had. Constraints * 1 \le...
Solve the programming task below in a Python markdown code block. Food contains three nutrients called "protein", "fat" and "carbohydrate", which are called three major nutrients. It is calculated that protein and carbohydrate are 4 kcal (kilocalories) and fat is 9 kcal per 1 g (gram). For example, according to the ta...
Solve the programming task below in a Python markdown code block. Andrew, Fedor and Alex are inventive guys. Now they invent the game with strings for two players. Given a group of n non-empty strings. During the game two players build the word together, initially the word is empty. The players move in turns. On his ...
Solve the programming task below in a Python markdown code block. I'm traveling to a country with a rabbit. There are n cities in this country numbered from 1 to n, and the rabbit is now in city 1. City i is a point on the coordinate plane (xi, yi) ). Rabbits travel to meet the following conditions. * The travel pat...
Solve the programming task below in a Python markdown code block. Numbers of black and white points are placed on a plane. Let's imagine that a straight line of infinite length is drawn on the plane. When the line does not meet any of the points, the line divides these points into two groups. If the division by such a...
Solve the programming task below in a Python markdown code block. Consider a tic-tac-toe on a 3x3 board. Tic-tac-toe is a two-player battle game. Decide the first attack and the second attack, one hits Kuroishi and one hits Shiraishi. The winner is the person who puts stones one by one on the board alternately and arr...
Solve the programming task below in a Python markdown code block. Petya has come to the math exam and wants to solve as many problems as possible. He prepared and carefully studied the rules by which the exam passes. The exam consists of $n$ problems that can be solved in $T$ minutes. Thus, the exam begins at time $0...
Solve the programming task below in a Python markdown code block. "Hey, it's homework time" — thought Polycarpus and of course he started with his favourite subject, IT. Polycarpus managed to solve all tasks but for the last one in 20 minutes. However, as he failed to solve the last task after some considerable time, ...
Solve the programming task below in a Python markdown code block. Vasya is reading a e-book. The file of the book consists of $n$ pages, numbered from $1$ to $n$. The screen is currently displaying the contents of page $x$, and Vasya wants to read the page $y$. There are two buttons on the book which allow Vasya to sc...
Solve the programming task below in a Python markdown code block. Read problems statements in Mandarin Chinese and Russian. Chef loves to prepare delicious dishes. This time, Chef has decided to prepare a special dish for you, and needs to gather several apples to do so. Chef has N apple trees in his home garden. ...
Solve the programming task below in a Python markdown code block. Write a function ```python alternate_sort(l) ``` that combines the elements of an array by sorting the elements ascending by their **absolute value** and outputs negative and non-negative integers alternatingly (starting with the negative value, if any)...
Solve the programming task below in a Python markdown code block. Leha plays a computer game, where is on each level is given a connected graph with n vertices and m edges. Graph can contain multiple edges, but can not contain self loops. Each vertex has an integer d_{i}, which can be equal to 0, 1 or - 1. To pass th...
Solve the programming task below in a Python markdown code block. We define $x \bmod y$ as the remainder of division of $x$ by $y$ ($\%$ operator in C++ or Java, mod operator in Pascal). Let's call an array of positive integers $[a_1, a_2, \dots, a_k]$ stable if for every permutation $p$ of integers from $1$ to $k$, ...
Solve the programming task below in a Python markdown code block. Some programming contest problems are really tricky: not only do they require a different output format from what you might have expected, but also the sample output does not show the difference. For an example, let us look at permutations. A permutati...
Solve the programming task below in a Python markdown code block. Lexicographic permutations are ordered combinations of a set of items ordered in a specific way. For instance, the first 8 permutations of the digits 0123, in lexicographic order, are: ``` 1st 0123 2nd 0132 3rd 0213 4th 0231 5th 0312 6th 0321 7th 1023...
Solve the programming task below in a Python markdown code block. There are n boys and m girls attending a theatre club. To set a play "The Big Bang Theory", they need to choose a group containing exactly t actors containing no less than 4 boys and no less than one girl. How many ways are there to choose a group? Of c...
Solve the programming task below in a Python markdown code block. There is a special offer in Vasya's favourite supermarket: if the customer buys $a$ chocolate bars, he or she may take $b$ additional bars for free. This special offer can be used any number of times. Vasya currently has $s$ roubles, and he wants to ge...
Solve the programming task below in a Python markdown code block. There is a bar of chocolate with a height of H blocks and a width of W blocks. Snuke is dividing this bar into exactly three pieces. He can only cut the bar along borders of blocks, and the shape of each piece must be a rectangle. Snuke is trying to div...
Solve the programming task below in a Python markdown code block. Tattah is asleep if and only if Tattah is attending a lecture. This is a well-known formula among Tattah's colleagues. On a Wednesday afternoon, Tattah was attending Professor HH's lecture. At 12:21, right before falling asleep, he was staring at the d...
Solve the programming task below in a Python markdown code block. J: City Santa decides to deliver a present to a city. The city has a rectangular shape divided into north-south $ H $ parcels x east-west $ W $ parcels, with one house delivering gifts to each parcel. The $ X $ th section from the north and the $ Y $...
Solve the programming task below in a Python markdown code block. Vasya plays the LionAge II. He was bored of playing with a stupid computer, so he installed this popular MMORPG, to fight with his friends. Vasya came up with the name of his character — non-empty string s, consisting of a lowercase Latin letters. Howev...
Solve the programming task below in a Python markdown code block. Find the smallest possible sum of the digits in the decimal notation of a positive multiple of K. -----Constraints----- - 2 \leq K \leq 10^5 - K is an integer. -----Input----- Input is given from Standard Input in the following format: K -----Outpu...
Solve the programming task below in a Python markdown code block. Problem Statement The Animal School is a primary school for animal children. You are a fox attending this school. One day, you are given a problem called "Arithmetical Restorations" from the rabbit teacher, Hanako. Arithmetical Restorations are the pr...
Solve the programming task below in a Python markdown code block. There are N positive integers written on a blackboard: A_1, ..., A_N. Snuke can perform the following operation when all integers on the blackboard are even: - Replace each integer X on the blackboard by X divided by 2. Find the maximum possible number...