question
large_stringlengths
265
13.2k
Solve the programming task below in a Python markdown code block. The King of a little Kingdom on a little island in the Pacific Ocean frequently has childish ideas. One day he said, “You shall make use of a message relaying game when you inform me of something.” In response to the King’s statement, six servants were ...
Solve the programming task below in a Python markdown code block. One day, little Vasya found himself in a maze consisting of (n + 1) rooms, numbered from 1 to (n + 1). Initially, Vasya is at the first room and to get out of the maze, he needs to get to the (n + 1)-th one. The maze is organized as follows. Each room ...
Solve the programming task below in a Python markdown code block. To stay woke and attentive during classes, Karen needs some coffee! [Image] Karen, a coffee aficionado, wants to know the optimal temperature for brewing the perfect cup of coffee. Indeed, she has spent some time reading several recipe books, includin...
Solve the programming task below in a Python markdown code block. There are some beautiful girls in Arpa’s land as mentioned before. Once Arpa came up with an obvious problem: Given an array and a number x, count the number of pairs of indices i, j (1 ≤ i < j ≤ n) such that $a_{i} \oplus a_{j} = x$, where $\oplus$ i...
Solve the programming task below in a Python markdown code block. Valentin participates in a show called "Shockers". The rules are quite easy: jury selects one letter which Valentin doesn't know. He should make a small speech, but every time he pronounces a word that contains the selected letter, he receives an electr...
Solve the programming task below in a Python markdown code block. You should have done Product Partitions I to do this second part. If you solved it, you should have notice that we try to obtain the multiplicative partitions with ```n ≤ 100 ```. In this kata we will have more challenging values, our ```n ≤ 10000```....
Solve the programming task below in a Python markdown code block. Problem statement A programming contest will be held in the Russian Federation. The contest has N questions and has M participants. Question i has a score a_i, and it is known that participant j's ability is b_j. For problem i and participant j, partic...
Solve the programming task below in a Python markdown code block. You are given a string s. Among the different substrings of s, print the K-th lexicographically smallest one. A substring of s is a string obtained by taking out a non-empty contiguous part in s. For example, if s = ababc, a, bab and ababc are substring...
Solve the programming task below in a Python markdown code block. Kate likes to count words in text blocks. By words she means continuous sequences of English alphabetic characters (from a to z ). Here are examples: `Hello there, little user5453 374 ())$. I’d been using my sphere as a stool. Slow-moving target 839342...
Solve the programming task below in a Python markdown code block. Given an array A of N numbers, find the number of distinct pairs (i, j) such that j ≥i and A[i] = A[j]. First line of the input contains number of test cases T. Each test case has two lines, first line is the number N, followed by a line consisting of ...
Solve the programming task below in a Python markdown code block. The only difference between easy and hard versions is constraints. You are given a sequence $a$ consisting of $n$ positive integers. Let's define a three blocks palindrome as the sequence, consisting of at most two distinct elements (let these element...
Solve the programming task below in a Python markdown code block. A permutation is a sequence of integers from $1$ to $n$ of length $n$ containing each number exactly once. For example, $[1]$, $[4, 3, 5, 1, 2]$, $[3, 2, 1]$ — are permutations, and $[1, 1]$, $[4, 3, 1]$, $[2, 3, 4]$ — no. Permutation $a$ is lexicograp...
Solve the programming task below in a Python markdown code block. Once Vasya and Petya assembled a figure of m cubes, each of them is associated with a number between 0 and m - 1 (inclusive, each number appeared exactly once). Let's consider a coordinate system such that the OX is the ground, and the OY is directed up...
Solve the programming task below in a Python markdown code block. Bessie the cow has just intercepted a text that Farmer John sent to Burger Queen! However, Bessie is sure that there is a secret message hidden inside. The text is a string $s$ of lowercase Latin letters. She considers a string $t$ as hidden in string ...
Solve the programming task below in a Python markdown code block. As you probably know, Fibonacci sequence are the numbers in the following integer sequence: 1, 1, 2, 3, 5, 8, 13... Write a method that takes the index as an argument and returns last digit from fibonacci number. Example: getLastDigit(15) - 610. Your ...
Solve the programming task below in a Python markdown code block. Koa the Koala has a binary string $s$ of length $n$. Koa can perform no more than $n-1$ (possibly zero) operations of the following form: In one operation Koa selects positions $i$ and $i+1$ for some $i$ with $1 \le i < |s|$ and sets $s_i$ to $max(s_i,...
Solve the programming task below in a Python markdown code block. A new task for you! You have to create a method, that corrects a given time string. There was a problem in addition, so many of the time strings are broken. Time-Format is european. So from "00:00:00" to "23:59:59". Some examples: "09:10:01" -> "09:...
Solve the programming task below in a Python markdown code block. This is the first step to understanding FizzBuzz. Your inputs: a positive integer, n, greater than or equal to one. n is provided, you have NO CONTROL over its value. Your expected output is an array of positive integers from 1 to n (inclusive). Yo...
Solve the programming task below in a Python markdown code block. Vasya has a string $s$ of length $n$ consisting only of digits 0 and 1. Also he has an array $a$ of length $n$. Vasya performs the following operation until the string becomes empty: choose some consecutive substring of equal characters, erase it from...
Solve the programming task below in a Python markdown code block. In Japan, people make offerings called hina arare, colorful crackers, on March 3. We have a bag that contains N hina arare. (From here, we call them arare.) It is known that the bag either contains arare in three colors: pink, white and green, or contai...
Solve the programming task below in a Python markdown code block. Given a natural number n, we want to know in how many ways we may express these numbers as product of other numbers. For example the number ```python 18 = 2 x 9 = 3 x 6 = 2 x 3 x 3 # (we do not consider the product 18 x 1), (3 ways) ``` See this exa...
Solve the programming task below in a Python markdown code block. Read problems statements in Mandarin Chinese , Russian and Vietnamese as well. Sergey has made N measurements. Now, he wants to know the average value of the measurements made. In order to make the average value a better representative of the measure...
Solve the programming task below in a Python markdown code block. Chef loves arrays. But he really loves a specific kind of them - Rainbow Arrays. The array is a Rainbow Array if it has such a structure: - The first a1 elements equal to 1. - The next a2 elements equal to 2. - The next a3 elements equal to 3. - T...
Solve the programming task below in a Python markdown code block. Julia is going to cook a chicken in the kitchen of her dormitory. To save energy, the stove in the kitchen automatically turns off after k minutes after turning on. During cooking, Julia goes to the kitchen every d minutes and turns on the stove if it ...
Solve the programming task below in a Python markdown code block. Read problems statements in Mandarin Chinese here Read problems statements in Russian here ------ Problem Statement ------ One day Chef is waiting his girlfriend on the bus station. The girlfriend said that she will be at time_{1}. Chef went to the...
Solve the programming task below in a Python markdown code block. It is well known that the planet suffers from the energy crisis. Little Petya doesn't like that and wants to save the world. For this purpose he needs every accumulator to contain the same amount of energy. Initially every accumulator has some amount of...
Solve the programming task below in a Python markdown code block. Goldbach's Conjecture: For any even number n greater than or equal to 4, there exists at least one pair of prime numbers p1 and p2 such that n = p1 + p2. This conjecture has not been proved nor refused yet. No one is sure whether this conjecture actual...
Solve the programming task below in a Python markdown code block. Imagine two rings with numbers on them. The inner ring spins clockwise (decreasing by 1 each spin) and the outer ring spins counter clockwise (increasing by 1 each spin). We start with both rings aligned on 0 at the top, and on each move we spin each ri...
Solve the programming task below in a Python markdown code block. Given are N positive integers A_1,...,A_N. Consider positive integers B_1, ..., B_N that satisfy the following condition. Condition: For any i, j such that 1 \leq i < j \leq N, A_i B_i = A_j B_j holds. Find the minimum possible value of B_1 + ... + B_N ...
Solve the programming task below in a Python markdown code block. Read problems statements in Mandarin Chinese and Russian. Chef is on a vacation these days, so his friend Chefza is trying to solve Chef's everyday tasks. Today's task is to make a sweet roll. Rolls are made by a newly invented cooking machine. The m...
Solve the programming task below in a Python markdown code block. You have two variables a and b. Consider the following sequence of actions performed with these variables: If a = 0 or b = 0, end the process. Otherwise, go to step 2; If a ≥ 2·b, then set the value of a to a - 2·b, and repeat step 1. Otherwise, go to s...
Solve the programming task below in a Python markdown code block. The problem uses a simplified TCP/IP address model, please make sure you've read the statement attentively. Polycarpus has found a job, he is a system administrator. One day he came across n IP addresses. Each IP address is a 32 bit number, represented...
Solve the programming task below in a Python markdown code block. # RoboScript #3 - Implement the RS2 Specification ## Disclaimer The story presented in this Kata Series is purely fictional; any resemblance to actual programming languages, products, organisations or people should be treated as purely coincidental. ...
Solve the programming task below in a Python markdown code block. You are given two integer numbers, $n$ and $x$. You may perform several operations with the integer $x$. Each operation you perform is the following one: choose any digit $y$ that occurs in the decimal representation of $x$ at least once, and replace $...
Solve the programming task below in a Python markdown code block. Given are N integers A_1,\ldots,A_N. Find the sum of A_i \times A_j over all pairs (i,j) such that 1\leq i < j \leq N, modulo (10^9+7). -----Constraints----- - 2 \leq N \leq 2\times 10^5 - 0 \leq A_i \leq 10^9 - All values in input are integers. --...
Solve the programming task below in a Python markdown code block. Joisino is planning to open a shop in a shopping street. Each of the five weekdays is divided into two periods, the morning and the evening. For each of those ten periods, a shop must be either open during the whole period, or closed during the whole pe...
Solve the programming task below in a Python markdown code block. A rectangle with sides $A$ and $B$ is cut into rectangles with cuts parallel to its sides. For example, if $p$ horizontal and $q$ vertical cuts were made, $(p + 1) \cdot (q + 1)$ rectangles were left after the cutting. After the cutting, rectangles were...
Solve the programming task below in a Python markdown code block. Consider a tunnel on a one-way road. During a particular day, $n$ cars numbered from $1$ to $n$ entered and exited the tunnel exactly once. All the cars passed through the tunnel at constant speeds. A traffic enforcement camera is mounted at the tunnel...
Solve the programming task below in a Python markdown code block. There are n banks in the city where Vasya lives, they are located in a circle, such that any two banks are neighbouring if their indices differ by no more than 1. Also, bank 1 and bank n are neighbours if n > 1. No bank is a neighbour of itself. Vasya ...
Solve the programming task below in a Python markdown code block. You are given an undirected graph consisting of $n$ vertices and $n$ edges, where $n$ is divisible by $6$. Each edge has a weight, which is a positive (greater than zero) integer. The graph has the following structure: it is split into $\frac{n}{3}$ tr...
Solve the programming task below in a Python markdown code block. There are n servers in a laboratory, each of them can perform tasks. Each server has a unique id — integer from 1 to n. It is known that during the day q tasks will come, the i-th of them is characterized with three integers: t_{i} — the moment in seco...
Solve the programming task below in a Python markdown code block. Cengiz recently learned Fibonacci numbers and now he is studying different algorithms to find them. After getting bored of reading them, he came with his own new type of numbers that he named XORinacci numbers. He defined them as follows: $f(0) = a$; ...
Solve the programming task below in a Python markdown code block. Bike loves looking for the second maximum element in the sequence. The second maximum element in the sequence of distinct numbers x_1, x_2, ..., x_{k} (k > 1) is such maximum element x_{j}, that the following inequality holds: $x_{j} \neq \operatorname{...
Solve the programming task below in a Python markdown code block. Holidays are coming up really soon. Rick realized that it's time to think about buying a traditional spruce tree. But Rick doesn't want real trees to get hurt so he decided to find some in an $n \times m$ matrix consisting of "*" and ".". To find every...
Solve the programming task below in a Python markdown code block. Petya and Vasya arranged a game. The game runs by the following rules. Players have a directed graph consisting of n vertices and m edges. One of the vertices contains a chip. Initially the chip is located at vertex s. Players take turns moving the chip...
Solve the programming task below in a Python markdown code block. I, Fischl, Prinzessin der Verurteilung, descend upon this land by the call of fate an — Oh, you are also a traveler from another world? Very well, I grant you permission to travel with me. It is no surprise Fischl speaks with a strange choice of words....
Solve the programming task below in a Python markdown code block. Polar bears Menshykov and Uslada from the zoo of St. Petersburg and elephant Horace from the zoo of Kiev decided to build a house of cards. For that they've already found a hefty deck of n playing cards. Let's describe the house they want to make: 1...
Solve the programming task below in a Python markdown code block. You have an initially empty cauldron, and you want to brew a potion in it. The potion consists of two ingredients: magic essence and water. The potion you want to brew should contain exactly $k\ \%$ magic essence and $(100 - k)\ \%$ water. In one step,...
Solve the programming task below in a Python markdown code block. Aiz, which is located in cyberspace, trades information with Wakamatsu. The two countries are developing their economies by exchanging useful data with each other. The two countries, whose national policy is philanthropy and equality, and above all, the...
Solve the programming task below in a Python markdown code block. The first algorithm for detecting a face on the image working in realtime was developed by Paul Viola and Michael Jones in 2001. A part of the algorithm is a procedure that computes Haar features. As part of this task, we consider a simplified model of ...
Solve the programming task below in a Python markdown code block. Petya loves football very much, especially when his parents aren't home. Each morning he comes to the yard, gathers his friends and they play all day. From time to time they have a break to have some food or do some chores (for example, water the flower...
Solve the programming task below in a Python markdown code block. ### Preface You are currently working together with a local community to build a school teaching children how to code. First plans have been made and the community wants to decide on the best location for the coding school. In order to make this decisio...
Solve the programming task below in a Python markdown code block. Once a Mathematician was trapped by military people during a world war with his forty colleagues. The colleagues were without any weapons, only the mathematician had a knife. And with no weapons they were not able to fight with the military, so they dec...
Solve the programming task below in a Python markdown code block. You are given an integer N. Build an undirected graph with N vertices with indices 1 to N that satisfies the following two conditions: * The graph is simple and connected. * There exists an integer S such that, for every vertex, the sum of the indices ...
Solve the programming task below in a Python markdown code block. In this kata, you will do addition and subtraction on a given string. The return value must be also a string. **Note:** the input will not be empty. ## Examples ``` "1plus2plus3plus4" --> "10" "1plus2plus3minus4" --> "2" ``` Write your solution by...
Solve the programming task below in a Python markdown code block. There are $n$ students numerated from $1$ to $n$. The level of the $i$-th student is $a_i$. You need to split the students into stable groups. A group of students is called stable, if in the sorted array of their levels no two neighboring elements diffe...
Solve the programming task below in a Python markdown code block. You have a tree of $n$ vertices. You are going to convert this tree into $n$ rubber bands on infinitely large plane. Conversion rule follows: For every pair of vertices $a$ and $b$, rubber bands $a$ and $b$ should intersect if and only if there is an e...
Solve the programming task below in a Python markdown code block. A + B is often used as an example of the easiest problem possible to show some contest platform. However, some scientists have observed that sometimes this problem is not so easy to get accepted. Want to try? -----Input----- The input contains two in...
Solve the programming task below in a Python markdown code block. ## Task Let's say we have a positive integer, `$n$`. You have to find the smallest possible positive integer that when multiplied by `$n$`, becomes a perfect power of integer `$k$`. A perfect power of `$k$` is any positive integer that can be represent...
Solve the programming task below in a Python markdown code block. _A mad sociopath scientist just came out with a brilliant invention! He extracted his own memories to forget all the people he hates! Now there's a lot of information in there, so he needs your talent as a developer to automatize that task for him._ > ...
Solve the programming task below in a Python markdown code block. You play a computer game. Your character stands on some level of a multilevel ice cave. In order to move on forward, you need to descend one level lower and the only way to do this is to fall through the ice. The level of the cave where you are is a re...
Solve the programming task below in a Python markdown code block. Lucy loves to travel. Luckily she is a renowned computer scientist and gets to travel to international conferences using her department's budget. Each year, Society for Exciting Computer Science Research (SECSR) organizes several conferences around the...
Solve the programming task below in a Python markdown code block. You are given a string S consisting of letters `b`, `d`, `p` and `q`. Determine whether S is a mirror string. Here, a mirror string is a string S such that the following sequence of operations on S results in the same string S: 1. Reverse the order of...
Solve the programming task below in a Python markdown code block. Amr bought a new video game "Guess Your Way Out! II". The goal of the game is to find an exit from the maze that looks like a perfect binary tree of height h. The player is initially standing at the root of the tree and the exit from the tree is located...
Solve the programming task below in a Python markdown code block. Snuke has an integer sequence A of length N. He will make three cuts in A and divide it into four (non-empty) contiguous subsequences B, C, D and E. The positions of the cuts can be freely chosen. Let P,Q,R,S be the sums of the elements in B,C,D,E, re...
Solve the programming task below in a Python markdown code block. In April 2008, Aizuwakamatsu City succeeded in making yakitori with a length of 20 m 85 cm. The chicken used at this time is Aizu local chicken, which is a specialty of Aizu. Aizu local chicken is very delicious, but it is difficult to breed, so the pro...
Solve the programming task below in a Python markdown code block. This problem is same as the previous one, but has larger constraints. Shiro's just moved to the new house. She wants to invite all friends of her to the house so they can play monopoly. However, her house is too small, so she can only invite one friend...
Solve the programming task below in a Python markdown code block. Your task is to create function```isDivideBy``` (or ```is_divide_by```) to check if an integer number is divisible by each out of two arguments. A few cases: ``` (-12, 2, -6) -> true (-12, 2, -5) -> false (45, 1, 6) -> false (45, 5, 15) ->...
Solve the programming task below in a Python markdown code block. Vova is playing a computer game. There are in total $n$ turns in the game and Vova really wants to play all of them. The initial charge of his laptop battery (i.e. the charge before the start of the game) is $k$. During each turn Vova can choose what t...
Solve the programming task below in a Python markdown code block. AtCoDeer the deer is seeing a quick report of election results on TV. Two candidates are standing for the election: Takahashi and Aoki. The report shows the ratio of the current numbers of votes the two candidates have obtained, but not the actual numbe...
Solve the programming task below in a Python markdown code block. Welcome to Codeforces Stock Exchange! We're pretty limited now as we currently allow trading on one stock, Codeforces Ltd. We hope you'll still be able to make profit from the market! In the morning, there are $n$ opportunities to buy shares. The $i$-t...
Solve the programming task below in a Python markdown code block. Arya has n opponents in the school. Each day he will fight with all opponents who are present this day. His opponents have some fighting plan that guarantees they will win, but implementing this plan requires presence of them all. That means if one day ...
Solve the programming task below in a Python markdown code block. Local authorities have heard a lot about combinatorial abilities of Ostap Bender so they decided to ask his help in the question of urbanization. There are n people who plan to move to the cities. The wealth of the i of them is equal to a_{i}. Authoriti...
Solve the programming task below in a Python markdown code block. You are given a sequence of positive integers a_1, a_2, ..., a_{n}. While possible, you perform the following operation: find a pair of equal consecutive elements. If there are more than one such pair, find the leftmost (with the smallest indices of e...
Solve the programming task below in a Python markdown code block. Fast & Furious Driving School's (F&F) charges for lessons are as below: Time Cost Up to 1st hour $30 Every subsequent half hour** $10 ** Subsequent charges are calculated by rounding up to nearest half hour. For example, if student X has a l...
Solve the programming task below in a Python markdown code block. Let us define the FizzBuzz sequence a_1,a_2,... as follows: - If both 3 and 5 divides i, a_i=\mbox{FizzBuzz}. - If the above does not hold but 3 divides i, a_i=\mbox{Fizz}. - If none of the above holds but 5 divides i, a_i=\mbox{Buzz}. - If none of ...
Solve the programming task below in a Python markdown code block. One of the first algorithm used for approximating the integer square root of a positive integer `n` is known as "Hero's method", named after the first-century Greek mathematician Hero of Alexandria who gave the first description of the method. Hero's m...
Solve the programming task below in a Python markdown code block. A positive integer X is said to be a lunlun number if and only if the following condition is satisfied: - In the base ten representation of X (without leading zeros), for every pair of two adjacent digits, the absolute difference of those digits is at ...
Solve the programming task below in a Python markdown code block. Write a program which reads a $n \times m$ matrix $A$ and a $m \times l$ matrix $B$, and prints their product, a $n \times l$ matrix $C$. An element of matrix $C$ is obtained by the following formula: \\[ c_{ij} = \sum_{k=1}^m a_{ik}b_{kj} \\] where $...
Solve the programming task below in a Python markdown code block. Write a function which converts the input string to uppercase. ~~~if:bf For BF all inputs end with \0, all inputs are lowercases and there is no space between. ~~~ Write your solution by modifying this code: ```python def make_upper_case(s): ``` ...
Solve the programming task below in a Python markdown code block. There is a set of cards with positive integers written on them. Stack the cards to make several piles and arrange them side by side. Select two adjacent piles of cards from them, and stack the left pile on top of the right pile. Repeat this operation un...
Solve the programming task below in a Python markdown code block. Aika's house runs a small coffee shop. The scones baked by Aika's mother were very delicious and the shop was very prosperous. One of the jobs of Aika, a waitress, is to deliver the scones that are baked one after another to the customer's seat. The ba...
Solve the programming task below in a Python markdown code block. -----Input----- The input contains a single integer a (1 ≤ a ≤ 64). -----Output----- Output a single integer. -----Examples----- Input 2 Output 1 Input 4 Output 2 Input 27 Output 5 Input 42 Output 6 Read the inputs from stdin solve the pr...
Solve the programming task below in a Python markdown code block. Well, those numbers were right and we're going to feed their ego. Write a function, isNarcissistic, that takes in any amount of numbers and returns true if all the numbers are narcissistic. Return false for invalid arguments (numbers passed in as strin...
Solve the programming task below in a Python markdown code block. Late last night in the Tanner household, ALF was repairing his spaceship so he might get back to Melmac. Unfortunately for him, he forgot to put on the parking brake, and the spaceship took off during repair. Now it's hovering in space. ALF has the tec...
Solve the programming task below in a Python markdown code block. # Task Christmas is coming. In the [previous kata](https://www.codewars.com/kata/5a405ba4e1ce0e1d7800012e), we build a custom Christmas tree with the specified characters and the specified height. Now, we are interested in the center of the Christmas ...
Solve the programming task below in a Python markdown code block. Vasya became interested in bioinformatics. He's going to write an article about similar cyclic DNA sequences, so he invented a new method for determining the similarity of cyclic sequences. Let's assume that strings s and t have the same length n, then...
Solve the programming task below in a Python markdown code block. There are N children in AtCoder Kindergarten. Mr. Evi will arrange the children in a line, then give 1 candy to the first child in the line, 2 candies to the second child, ..., N candies to the N-th child. How many candies will be necessary in total? -...
Solve the programming task below in a Python markdown code block. A kindergarten teacher Natalia Pavlovna has invented a new ball game. This game not only develops the children's physique, but also teaches them how to count. The game goes as follows. Kids stand in circle. Let's agree to think of the children as numb...
Solve the programming task below in a Python markdown code block. I found this interesting interview question just today: > *8 coins are given where all the coins have equal weight, except one. The odd one weights less than the others, not being of pure gold. In the worst case, how many iterations are actually needed...
Solve the programming task below in a Python markdown code block. One day, after a difficult lecture a diligent student Sasha saw a graffitied desk in the classroom. She came closer and read: "Find such positive integer n, that among numbers n + 1, n + 2, ..., 2·n there are exactly m numbers which binary representatio...
Solve the programming task below in a Python markdown code block. You have full control over a robot that walks around in a rectangular field paved with square tiles like a chessboard. There are m columns of tiles from west to east, and n rows of tiles from south to north (1 <= m, n <= 100). Each tile is given a pair ...
Solve the programming task below in a Python markdown code block. In this Kata we are passing a number (n) into a function. Your code will determine if the number passed is even (or not). The function needs to return either a true or false. Numbers may be positive or negative, integers or floats. Floats are con...
Solve the programming task below in a Python markdown code block. We have a 3×3 square grid, where each square contains a lowercase English letters. The letter in the square at the i-th row from the top and j-th column from the left is c_{ij}. Print the string of length 3 that can be obtained by concatenating the lett...
Solve the programming task below in a Python markdown code block. Our beloved detective, Sherlock is currently trying to catch a serial killer who kills a person each day. Using his powers of deduction, he came to know that the killer has a strategy for selecting his next victim. The killer starts with two potential ...
Solve the programming task below in a Python markdown code block. The Resistance is trying to take control over as many planets of a particular solar system as possible. Princess Heidi is in charge of the fleet, and she must send ships to some planets in order to maximize the number of controlled planets. The Galaxy ...
Solve the programming task below in a Python markdown code block. In this Kata, you will be given an array of numbers in which two numbers occur once and the rest occur only twice. Your task will be to return the sum of the numbers that occur only once. For example, `repeats([4,5,7,5,4,8]) = 15` because only the num...
Solve the programming task below in a Python markdown code block. Polycarp is very careful. He even types numeric sequences carefully, unlike his classmates. If he sees a sequence without a space after the comma, with two spaces in a row, or when something else does not look neat, he rushes to correct it. For example,...
Solve the programming task below in a Python markdown code block. You survived several months of exam wars and were able to enter ICPC University on a sunny day. On the day of admission, there was an enthusiastic recruitment of circles on the campus of the university, and you received a large number of pamphlets and r...
Solve the programming task below in a Python markdown code block. You are given an integer array $a_1, a_2, \ldots, a_n$. The array $b$ is called to be a subsequence of $a$ if it is possible to remove some elements from $a$ to get $b$. Array $b_1, b_2, \ldots, b_k$ is called to be good if it is not empty and for eve...