question
large_stringlengths
265
13.2k
Solve the programming task below in a Python markdown code block. Alice and Bob are playing a game with n piles of stones. It is guaranteed that n is an even number. The i-th pile has a_i stones. Alice and Bob will play a game alternating turns with Alice going first. On a player's turn, they must choose exactly n/2...
Solve the programming task below in a Python markdown code block. There are $n$ block towers in a row, where tower $i$ has a height of $a_i$. You're part of a building crew, and you want to make the buildings look as nice as possible. In a single day, you can perform the following operation: Choose two indices $i$ an...
Solve the programming task below in a Python markdown code block. There is a complete graph of m vertices. Initially, the edges of the complete graph are uncolored. Sunuke did the following for each i (1 ≤ i ≤ n): Select ai vertices from the complete graph and color all edges connecting the selected vertices with colo...
Solve the programming task below in a Python markdown code block. Given are two strings S and T. Let us change some of the characters in S so that T will be a substring of S. At least how many characters do we need to change? Here, a substring is a consecutive subsequence. For example, xxx is a substring of yxxxy, but...
Solve the programming task below in a Python markdown code block. You are trying to cross a river by jumping along stones. Every time you land on a stone, you hop forwards by the value of that stone. If you skip *over* a stone then its value doesn't affect you in any way. Eg: ``` x--x-----x--> [1][2][5][1] ``` Of ...
Solve the programming task below in a Python markdown code block. Little Nastya has a hobby, she likes to remove some letters from word, to obtain another word. But it turns out to be pretty hard for her, because she is too young. Therefore, her brother Sergey always helps her. Sergey gives Nastya the word t and want...
Solve the programming task below in a Python markdown code block. Example Input 6 3 1 0 0 1 0 1 1 3 2 Output 1 Read the inputs from stdin solve the problem and write the answer to stdout (do not directly test on the sample inputs). Enclose your code within ```python delimiters.
Solve the programming task below in a Python markdown code block. ## Task: You have to write a function `pattern` which returns the following Pattern(See Examples) upto n number of rows. * Note:```Returning``` the pattern is not the same as ```Printing``` the pattern. ### Rules/Note: * The pattern should be creat...
Solve the programming task below in a Python markdown code block. Emuskald is an avid horticulturist and owns the world's longest greenhouse — it is effectively infinite in length. Over the years Emuskald has cultivated n plants in his greenhouse, of m different plant species numbered from 1 to m. His greenhouse is v...
Solve the programming task below in a Python markdown code block. One day the Codeforces round author sat exams. He had n exams and he needed to get an integer from 2 to 5 for each exam. He will have to re-sit each failed exam, i.e. the exam that gets mark 2. The author would need to spend too much time and effort t...
Solve the programming task below in a Python markdown code block. The Rebel fleet is afraid that the Empire might want to strike back again. Princess Heidi needs to know if it is possible to assign R Rebel spaceships to guard B bases so that every base has exactly one guardian and each spaceship has exactly one assign...
Solve the programming task below in a Python markdown code block. Fox Ciel is playing a card game with her friend Fox Jiro. There are n piles of cards on the table. And there is a positive integer on each card. The players take turns and Ciel takes the first turn. In Ciel's turn she takes a card from the top of any n...
Solve the programming task below in a Python markdown code block. Input Format N K a_1 a_2 a_3 ... a_N Output Format Print the minimum cost in one line. In the end put a line break. Constraints * 1 ≤ K ≤ N ≤ 15 * 1 ≤ a_i ≤ 10^9 Scoring Subtask 1 [120 points] * N = K Subtask 2 [90 points] * N ≤ 5 * a_i...
Solve the programming task below in a Python markdown code block. Make a function that returns the value multiplied by 50 and increased by 6. If the value entered is a string it should return "Error". Note: in `C#`, you'll always get the input as a string, so the above applies if the string isn't representing a doubl...
Solve the programming task below in a Python markdown code block. Let's play Amidakuji. In the following example, there are five vertical lines and four horizontal lines. The horizontal lines can intersect (jump across) the vertical lines. <image> In the starting points (top of the figure), numbers are assigned to...
Solve the programming task below in a Python markdown code block. Implement `String#parse_mana_cost`, which parses [Magic: the Gathering mana costs](http://mtgsalvation.gamepedia.com/Mana_cost) expressed as a string and returns a `Hash` with keys being kinds of mana, and values being the numbers. Don't include any ma...
Solve the programming task below in a Python markdown code block. Consider a table G of size n × m such that G(i, j) = GCD(i, j) for all 1 ≤ i ≤ n, 1 ≤ j ≤ m. GCD(a, b) is the greatest common divisor of numbers a and b. You have a sequence of positive integer numbers a_1, a_2, ..., a_{k}. We say that this sequence oc...
Solve the programming task below in a Python markdown code block. You are given three integers, A, B and C. Among them, two are the same, but the remaining one is different from the rest. For example, when A=5,B=7,C=5, A and C are the same, but B is different. Find the one that is different from the rest among the ...
Solve the programming task below in a Python markdown code block. You are given an integer sequence of length n, a_1, ..., a_n. Let us consider performing the following n operations on an empty sequence b. The i-th operation is as follows: 1. Append a_i to the end of b. 2. Reverse the order of the elements in b. ...
Solve the programming task below in a Python markdown code block. This is yet another problem dealing with regular bracket sequences. We should remind you that a bracket sequence is called regular, if by inserting «+» and «1» into it we can get a correct mathematical expression. For example, sequences «(())()», «()» ...
Solve the programming task below in a Python markdown code block. Find the number of integers between 1 and K (inclusive) satisfying the following condition, modulo 10^9 + 7: * The sum of the digits in base ten is a multiple of D. Constraints * All values in input are integers. * 1 \leq K < 10^{10000} * 1 \leq D \l...
Solve the programming task below in a Python markdown code block. In Dwango Co., Ltd., there is a content distribution system named 'Dwango Media Cluster', and it is called 'DMC' for short. The name 'DMC' sounds cool for Niwango-kun, so he starts to define DMC-ness of a string. Given a string S of length N and an int...
Solve the programming task below in a Python markdown code block. # Task Let's say that `"g" is happy` in the given string, if there is another "g" immediately to the right or to the left of it. Find out if all "g"s in the given string are happy. # Example For `str = "gg0gg3gg0gg"`, the output should be `true`. ...
Solve the programming task below in a Python markdown code block. Read problems statements in Mandarin Chinese here ------ Problem Statement ------ Maxim likes dividers of the numbers. Also Maxim is fond of lucky numbers of small elephant from Lviv city.   If you remember, lucky numbers are positive integers whose...
Solve the programming task below in a Python markdown code block. # Let's play Psychic A box contains green, red, and blue balls. The total number of balls is given by `n` (`0 < n < 50`). Each ball has a mass that depends on the ball color. Green balls weigh `5kg`, red balls weigh `4kg`, and blue balls weigh `3kg`....
Solve the programming task below in a Python markdown code block. She is an extraordinary girl. She works for a library. Since she is young and cute, she is forced to do a lot of laborious jobs. The most annoying job for her is to put returned books into shelves, carrying them by a cart. The cart is large enough to ca...
Solve the programming task below in a Python markdown code block. Today, hedgehog Filya went to school for the very first time! Teacher gave him a homework which Filya was unable to complete without your help. Filya is given an array of non-negative integers a_1, a_2, ..., a_{n}. First, he pick an integer x and then ...
Solve the programming task below in a Python markdown code block. Note : Issues Fixed with python 2.7.6 , Use any one you like :D , ( Thanks to Time , time , time . Your task is to write a function that will return the degrees on a analog clock from a digital time that is passed in as parameter . The digital time is...
Solve the programming task below in a Python markdown code block. AtCoder Mart sells 1000000 of each of the six items below: * Riceballs, priced at 100 yen (the currency of Japan) each * Sandwiches, priced at 101 yen each * Cookies, priced at 102 yen each * Cakes, priced at 103 yen each * Candies, priced at 104 yen e...
Solve the programming task below in a Python markdown code block. It is so boring in the summer holiday, isn't it? So Alice and Bob have invented a new game to play. The rules are as follows. First, they get a set of n distinct integers. And then they take turns to make the following moves. During each move, either Al...
Solve the programming task below in a Python markdown code block. Real stupidity beats artificial intelligence every time. — Terry Pratchett, Hogfather, Discworld You are given a string $s$ of length $n$ and a number $k$. Let's denote by $rev(s)$ the reversed string $s$ (i.e. $rev(s) = s_n s_{n-1} ... s_1$). You can...
Solve the programming task below in a Python markdown code block. There are n pictures delivered for the new exhibition. The i-th painting has beauty a_{i}. We know that a visitor becomes happy every time he passes from a painting to a more beautiful one. We are allowed to arranged pictures in any order. What is the ...
Solve the programming task below in a Python markdown code block. In a kindergarten, the children are being divided into groups. The teacher put the children in a line and associated each child with his or her integer charisma value. Each child should go to exactly one group. Each group should be a nonempty segment of...
Solve the programming task below in a Python markdown code block. Vasya had three strings $a$, $b$ and $s$, which consist of lowercase English letters. The lengths of strings $a$ and $b$ are equal to $n$, the length of the string $s$ is equal to $m$. Vasya decided to choose a substring of the string $a$, then choose...
Solve the programming task below in a Python markdown code block. Mad scientist Mike is building a time machine in his spare time. To finish the work, he needs a resistor with a certain resistance value. However, all Mike has is lots of identical resistors with unit resistance R_0 = 1. Elements with other resistance ...
Solve the programming task below in a Python markdown code block. Petya has n positive integers a_1, a_2, ..., a_{n}. His friend Vasya decided to joke and replaced all digits in Petya's numbers with a letters. He used the lowercase letters of the Latin alphabet from 'a' to 'j' and replaced all digits 0 with one lett...
Solve the programming task below in a Python markdown code block. Polycarp has $n$ coins, the value of the $i$-th coin is $a_i$. Polycarp wants to distribute all the coins between his pockets, but he cannot put two coins with the same value into the same pocket. For example, if Polycarp has got six coins represented ...
Solve the programming task below in a Python markdown code block. You are given two integers $a$ and $b$. In one move, you can choose some integer $k$ from $1$ to $10$ and add it to $a$ or subtract it from $a$. In other words, you choose an integer $k \in [1; 10]$ and perform $a := a + k$ or $a := a - k$. You may use...
Solve the programming task below in a Python markdown code block. Tom is interested in power consumption of his favourite laptop. His laptop has three modes. In normal mode laptop consumes P1 watt per minute. T1 minutes after Tom moved the mouse or touched the keyboard for the last time, a screensaver starts and power...
Solve the programming task below in a Python markdown code block. This problem is same as the next one, but has smaller constraints. It was a Sunday morning when the three friends Selena, Shiro and Katie decided to have a trip to the nearby power station (do not try this at home). After arriving at the power station,...
Solve the programming task below in a Python markdown code block. In the rush of modern life, people often forget how beautiful the world is. The time to enjoy those around them is so little that some even stand in queues to several rooms at the same time in the clinic, running from one queue to another. (Cultural no...
Solve the programming task below in a Python markdown code block. Takahashi is organizing a party. At the party, each guest will receive one or more snack pieces. Takahashi predicts that the number of guests at this party will be A or B. Find the minimum number of pieces that can be evenly distributed to the guests in...
Solve the programming task below in a Python markdown code block. A widely known among some people Belarusian sport programmer Yura possesses lots of information about cars. That is why he has been invited to participate in a game show called "Guess That Car!". The game show takes place on a giant parking lot, which ...
Solve the programming task below in a Python markdown code block. There are $n$ cities in Berland and some pairs of them are connected by two-way roads. It is guaranteed that you can pass from any city to any other, moving along the roads. Cities are numerated from $1$ to $n$. Two fairs are currently taking place in ...
Solve the programming task below in a Python markdown code block. Constanze is the smartest girl in her village but she has bad eyesight. One day, she was able to invent an incredible machine! When you pronounce letters, the machine will inscribe them onto a piece of paper. For example, if you pronounce 'c', 'o', 'd'...
Solve the programming task below in a Python markdown code block. Lengths are measures in Baden in inches and feet. To a length from centimeters it is enough to know that an inch equals three centimeters in Baden and one foot contains 12 inches. You are given a length equal to n centimeters. Your task is to convert i...
Solve the programming task below in a Python markdown code block. Very soon there will be a parade of victory over alien invaders in Berland. Unfortunately, all soldiers died in the war and now the army consists of entirely new recruits, many of whom do not even know from which leg they should begin to march. The civi...
Solve the programming task below in a Python markdown code block. ICPC Ranking Your mission in this problem is to write a program which, given the submission log of an ICPC (International Collegiate Programming Contest), determines team rankings. The log is a sequence of records of program submission in the order of...
Solve the programming task below in a Python markdown code block. We have a sequence of N integers: x=(x_0,x_1,\cdots,x_{N-1}). Initially, x_i=0 for each i (0 \leq i \leq N-1). Snuke will perform the following operation exactly M times: * Choose two distinct indices i, j (0 \leq i,j \leq N-1,\ i \neq j). Then, repla...
Solve the programming task below in a Python markdown code block. In this Kata, you will create a function that converts a string with letters and numbers to the inverse of that string (with regards to Alpha and Numeric characters). So, e.g. the letter `a` will become `1` and number `1` will become `a`; `z` will becom...
Solve the programming task below in a Python markdown code block. A bracketed sequence is called correct (regular) if by inserting "+" and "1" you can get a well-formed mathematical expression from it. For example, sequences "(())()", "()" and "(()(()))" are correct, while ")(", "(()" and "(()))(" are not. The teache...
Solve the programming task below in a Python markdown code block. A mischievous notice has arrived from the primitive slow-life organization "Akaruda". Akaruda is famous for mischief such as throwing a pie at the face of a VIP, but recently it has become more radical, such as using gunpowder to sprinkle rat fireworks ...
Solve the programming task below in a Python markdown code block. Alice and Bob are playing One Card Poker. One Card Poker is a two-player game using playing cards. Each card in this game shows an integer between 1 and 13, inclusive. The strength of a card is determined by the number written on it, as follows: W...
Solve the programming task below in a Python markdown code block. During a break in the buffet of the scientific lyceum of the Kingdom of Kremland, there was formed a queue of $n$ high school students numbered from $1$ to $n$. Initially, each student $i$ is on position $i$. Each student $i$ is characterized by two num...
Solve the programming task below in a Python markdown code block. Write a function that returns a sequence (index begins with 1) of all the even characters from a string. If the string is smaller than two characters or longer than 100 characters, the function should return "invalid string". For example: ````` "abcde...
Solve the programming task below in a Python markdown code block. B: Parentheses Number problem Define the correct parenthesis string as follows: * The empty string is the correct parenthesis string * For the correct parenthesis string S, `(` S `)` is the correct parenthesis string * For correct parentheses S, T ST...
Solve the programming task below in a Python markdown code block. Given an integer $n$, find the maximum value of integer $k$ such that the following condition holds: $n$ & ($n-1$) & ($n-2$) & ($n-3$) & ... ($k$) = $0$ where & denotes the bitwise AND operation. -----Input----- The first line contains a single inte...
Solve the programming task below in a Python markdown code block. Chef has just finished the construction of his new garden. He has sown the garden with patches of the most beautiful carpet grass he could find. He has filled it with patches of different color and now he wants to evaluate how elegant his garden is. Che...
Solve the programming task below in a Python markdown code block. You are given the array $a$ consisting of $n$ positive (greater than zero) integers. In one move, you can choose two indices $i$ and $j$ ($i \ne j$) such that the absolute difference between $a_i$ and $a_j$ is no more than one ($|a_i - a_j| \le 1$) and...
Solve the programming task below in a Python markdown code block. Imagine that you are given two sticks. You want to end up with three sticks of equal length. You are allowed to cut either or both of the sticks to accomplish this, and can throw away leftover pieces. Write a function, maxlen, that takes the lengths of...
Solve the programming task below in a Python markdown code block. Problem Statement We found a dictionary of the Ancient Civilization Mayo (ACM) during excavation of the ruins. After analysis of the dictionary, we revealed they used a language that had not more than 26 letters. So one of us mapped each letter to a di...
Solve the programming task below in a Python markdown code block. You are given two huge binary integer numbers $a$ and $b$ of lengths $n$ and $m$ respectively. You will repeat the following process: if $b > 0$, then add to the answer the value $a~ \&~ b$ and divide $b$ by $2$ rounding down (i.e. remove the last digit...
Solve the programming task below in a Python markdown code block. You are given an array $a$ consisting of $n$ integer numbers. You have to color this array in $k$ colors in such a way that: Each element of the array should be colored in some color; For each $i$ from $1$ to $k$ there should be at least one element...
Solve the programming task below in a Python markdown code block. Given an array containing only zeros and ones, find the index of the zero that, if converted to one, will make the longest sequence of ones. For instance, given the array: ``` [1, 0, 1, 1, 1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 0, 0, 1, 1] ``` replacing th...
Solve the programming task below in a Python markdown code block. Tonight, in your favourite cinema they are giving the movie Joker and all seats are occupied. In the cinema there are N rows with N seats each, forming an N\times N square. We denote with 1, 2,\dots, N the viewers in the first row (from left to right); ...
Solve the programming task below in a Python markdown code block. Ivar the Boneless is a great leader. He is trying to capture Kattegat from Lagertha. The war has begun and wave after wave Ivar's warriors are falling in battle. Ivar has $n$ warriors, he places them on a straight line in front of the main gate, in a w...
Solve the programming task below in a Python markdown code block. Create your own mechanical dartboard that gives back your score based on the coordinates of your dart. Task: Use the scoring rules for a standard dartboard: Finish method: ```python def get_score(x,y): ``` The coordinates are `(x, y)` are always r...
Solve the programming task below in a Python markdown code block. Cheaterius is a famous in all the Berland astrologist, magician and wizard, and he also is a liar and a cheater. One of his latest inventions is Cheaterius' amulets! They bring luck and wealth, but are rather expensive. Cheaterius makes them himself. Th...
Solve the programming task below in a Python markdown code block. Write a program of the Bubble Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: BubbleSort(A) 1 for i = 0 to A.length-1 2 for j = A.length-1 downto i+1 3 if A[j] < A[j-1]...
Solve the programming task below in a Python markdown code block. It seems like the year of 2013 came only yesterday. Do you know a curious fact? The year of 2013 is the first year after the old 1987 with only distinct digits. Now you are suggested to solve the following problem: given a year number, find the minimum...
Solve the programming task below in a Python markdown code block. problem In one programming contest, it is customary to play a bingo game at a social gathering after the competition. However, the bingo card used in this bingo game is a little special and is created according to the following conditions. * The Bingo...
Solve the programming task below in a Python markdown code block. We have an analog clock whose three hands (the second hand, the minute hand and the hour hand) rotate quite smoothly. You can measure two angles between the second hand and two other hands. Write a program to find the time at which "No two hands overla...
Solve the programming task below in a Python markdown code block. Recently you've discovered a new shooter. They say it has realistic game mechanics. Your character has a gun with magazine size equal to $k$ and should exterminate $n$ waves of monsters. The $i$-th wave consists of $a_i$ monsters and happens from the $...
Solve the programming task below in a Python markdown code block. B: 階層的計算機 (Hierarchical Calculator) Problem Ebi-chan has N formulae: y = a_i x for i =1, ..., N (inclusive). Now she considers a subsequence of indices with length k: s_1, s_2, ..., s_k. At first, let x_0 be 1 and evaluate s_1-th formulae with x = x_0...
Solve the programming task below in a Python markdown code block. There are $n$ points on a plane. The $i$-th point has coordinates $(x_i, y_i)$. You have two horizontal platforms, both of length $k$. Each platform can be placed anywhere on a plane but it should be placed horizontally (on the same $y$-coordinate) and ...
Solve the programming task below in a Python markdown code block. If there is an integer not less than 0 satisfying the following conditions, print the smallest such integer; otherwise, print -1. - The integer has exactly N digits in base ten. (We assume 0 to be a 1-digit integer. For other integers, leading zeros ar...
Solve the programming task below in a Python markdown code block. N problems are proposed for an upcoming contest. Problem i has an initial integer score of A_i points. M judges are about to vote for problems they like. Each judge will choose exactly V problems, independently from the other judges, and increase the s...
Solve the programming task below in a Python markdown code block. Shaass has n books. He wants to make a bookshelf for all his books. He wants the bookshelf's dimensions to be as small as possible. The thickness of the i-th book is t_{i} and its pages' width is equal to w_{i}. The thickness of each book is either 1 or...
Solve the programming task below in a Python markdown code block. 2N players are running a competitive table tennis training on N tables numbered from 1 to N. The training consists of rounds. In each round, the players form N pairs, one pair per table. In each pair, competitors play a match against each other. As a r...
Solve the programming task below in a Python markdown code block. Anadi has a set of dominoes. Every domino has two parts, and each part contains some dots. For every a and b such that 1 ≤ a ≤ b ≤ 6, there is exactly one domino with a dots on one half and b dots on the other half. The set contains exactly 21 dominoes....
Solve the programming task below in a Python markdown code block. Polycarpus loves lucky numbers. Everybody knows that lucky numbers are positive integers, whose decimal representation (without leading zeroes) contain only the lucky digits x and y. For example, if x = 4, and y = 7, then numbers 47, 744, 4 are lucky. ...
Solve the programming task below in a Python markdown code block. For a given array whose element values are randomly picked from single-digit integers `0` to `9`, return an array with the same digit order but all `0`'s paired. Paring two `0`'s generates one `0` at the location of the first. Ex: ```python pair_zeros(...
Solve the programming task below in a Python markdown code block. The aim of the kata is to decompose `n!` (factorial n) into its prime factors. Examples: ``` n = 12; decomp(12) -> "2^10 * 3^5 * 5^2 * 7 * 11" since 12! is divisible by 2 ten times, by 3 five times, by 5 two times and by 7 and 11 only once. n = 22; de...
Solve the programming task below in a Python markdown code block. After learning a lot about space exploration, a little girl named Ana wants to change the subject. Ana is a girl who loves palindromes (string that can be read the same backwards as forward). She has learned how to check for a given string whether it's...
Solve the programming task below in a Python markdown code block. In this task Anna and Maria play a game with a very unpleasant rival. Anna and Maria are in the opposite squares of a chessboard (8 × 8): Anna is in the upper right corner, and Maria is in the lower left one. Apart from them, the board has several statu...
Solve the programming task below in a Python markdown code block. ++++++++[>+>++>+++>++++>+++++>++++++>+++++++>++++++++>+++++++++>++++++++++>+ ++++++++++>++++++++++++>+++++++++++++>++++++++++++++>+++++++++++++++>+++++++ +++++++++<<<<<<<<<<<<<<<<-]>>>>>>>>>>.<<<<<<<<<<>>>>>>>>>>>>>>++.--<<<<<<<<< <<<<<>>>>>>>>>>>>>+.-<...
Solve the programming task below in a Python markdown code block. Inna likes sweets and a game called the "Candy Matrix". Today, she came up with the new game "Candy Matrix 2: Reload". The field for the new game is a rectangle table of size n × m. Each line of the table contains one cell with a dwarf figurine, one ce...
Solve the programming task below in a Python markdown code block. You have a positive integer m and a non-negative integer s. Your task is to find the smallest and the largest of the numbers that have length m and sum of digits s. The required numbers should be non-negative integers written in the decimal base without...
Solve the programming task below in a Python markdown code block. Vanya loves playing. He even has a special set of cards to play with. Each card has a single integer. The number on the card can be positive, negative and can even be equal to zero. The only limit is, the number on each card doesn't exceed x in the abso...
Solve the programming task below in a Python markdown code block. Consider the infinite sequence $s$ of positive integers, created by repeating the following steps: Find the lexicographically smallest triple of positive integers $(a, b, c)$ such that $a \oplus b \oplus c = 0$, where $\oplus$ denotes the bitwise X...
Solve the programming task below in a Python markdown code block. Given is a permutation P of \{1, 2, \ldots, N\}. For a pair (L, R) (1 \le L \lt R \le N), let X_{L, R} be the second largest value among P_L, P_{L+1}, \ldots, P_R. Find \displaystyle \sum_{L=1}^{N-1} \sum_{R=L+1}^{N} X_{L,R}. -----Constraints----- - ...
Solve the programming task below in a Python markdown code block. You are provided with array of positive non-zero ints and int n representing n-th power (n >= 2). For the given array, calculate the sum of each value to the n-th power. Then subtract the sum of the original array. Example 1: Input: {1, 2, 3}, 3 --> (...
Solve the programming task below in a Python markdown code block. Vadim loves decorating the Christmas tree, so he got a beautiful garland as a present. It consists of $n$ light bulbs in a single row. Each bulb has a number from $1$ to $n$ (in arbitrary order), such that all the numbers are distinct. While Vadim was s...
Solve the programming task below in a Python markdown code block. Bob is decorating his kitchen, more precisely, the floor. He has found a prime candidate for the tiles he will use. They come in a simple form factor — a square tile that is diagonally split into white and black part as depicted in the figure below. [Im...
Solve the programming task below in a Python markdown code block. You are given an angle $\text{ang}$. The Jury asks You to find such regular $n$-gon (regular polygon with $n$ vertices) that it has three vertices $a$, $b$ and $c$ (they can be non-consecutive) with $\angle{abc} = \text{ang}$ or report that there is n...
Solve the programming task below in a Python markdown code block. There are 2000001 stones placed on a number line. The coordinates of these stones are -1000000, -999999, -999998, \ldots, 999999, 1000000. Among them, some K consecutive stones are painted black, and the others are painted white. Additionally, we know t...
Solve the programming task below in a Python markdown code block. You are given a sequence of n integers S and a sequence of different q integers T. Write a program which outputs C, the number of integers in T which are also in the set S. Notes Constraints * Elements in S is sorted in ascending order * n ≤ 100000 *...
Solve the programming task below in a Python markdown code block. Help a fruit packer sort out the bad apples. There are 7 varieties of apples, all packaged as pairs and stacked in a fruit box. Some of the apples are spoiled. The fruit packer will have to make sure the spoiled apples are either removed from the frui...
Solve the programming task below in a Python markdown code block. You are given a string $s$ of even length $n$. String $s$ is binary, in other words, consists only of 0's and 1's. String $s$ has exactly $\frac{n}{2}$ zeroes and $\frac{n}{2}$ ones ($n$ is even). In one operation you can reverse any substring of $s$....
Solve the programming task below in a Python markdown code block. You are given two positive integers A and B. Compare the magnitudes of these numbers. -----Constraints----- - 1 ≤ A, B ≤ 10^{100} - Neither A nor B begins with a 0. -----Input----- Input is given from Standard Input in the following format: A B ---...