question
large_stringlengths
265
13.2k
Solve the programming task below in a Python markdown code block. You are given an undirected tree consisting of $n$ vertices. An undirected tree is a connected undirected graph with $n - 1$ edges. Your task is to add the minimum number of edges in such a way that the length of the shortest path from the vertex $1$ t...
Solve the programming task below in a Python markdown code block. Emacs is a text editor which is widely used by many programmers. The advantage of Emacs is that we can move a cursor without arrow keys and the mice. For example, the cursor can be moved right, left, down, and up by pushing f, b, n, p with the Control ...
Solve the programming task below in a Python markdown code block. Santa Claus likes palindromes very much. There was his birthday recently. k of his friends came to him to congratulate him, and each of them presented to him a string s_{i} having the same length n. We denote the beauty of the i-th string by a_{i}. It c...
Solve the programming task below in a Python markdown code block. Alice lives on a line. Today, she will travel to some place in a mysterious vehicle. Initially, the distance between Alice and her destination is D. When she input a number x to the vehicle, it will travel in the direction of the destination by a distan...
Solve the programming task below in a Python markdown code block. Read problems statements in Mandarin Chinese and Russian. Suraj, the Chief Prankster is back in action now and this time he has stolen the valentine's day gift given by Ashi (the love of Chef) to the Chef and ran away with it to Byteland. Byteland is...
Solve the programming task below in a Python markdown code block. There are n stone quarries in Petrograd. Each quarry owns mi dumpers (1 ≤ i ≤ n). It is known that the first dumper of the i-th quarry has xi stones in it, the second dumper has xi + 1 stones in it, the third has xi + 2, and the mi-th dumper (the last ...
Solve the programming task below in a Python markdown code block. You are given an array of integers $a$ of length $n$. The elements of the array can be either different or the same. Each element of the array is colored either blue or red. There are no unpainted elements in the array. One of the two operations descri...
Solve the programming task below in a Python markdown code block. D: Arrow / Arrow problem rodea is in a one-dimensional coordinate system and stands at x = 0. From this position, throw an arrow of positive integer length that always moves at speed 1 towards the target at x = N. However, rodea is powerless, so we ha...
Solve the programming task below in a Python markdown code block. Given a set of $N$ axis-aligned rectangles in the plane, find the area of regions which are covered by at least one rectangle. Constraints * $ 1 \leq N \leq 2000 $ * $ −10^9 \leq x1_i < x2_i\leq 10^9 $ * $ −10^9 \leq y1_i < y2_i\leq 10^9 $ Input The...
Solve the programming task below in a Python markdown code block. There are three cells on an infinite 2-dimensional grid, labeled $A$, $B$, and $F$. Find the length of the shortest path from $A$ to $B$ if: in one move you can go to any of the four adjacent cells sharing a side; visiting the cell $F$ is forbidden (i...
Solve the programming task below in a Python markdown code block. After a team finished their training session on Euro football championship, Valeric was commissioned to gather the balls and sort them into baskets. Overall the stadium has n balls and m baskets. The baskets are positioned in a row from left to right an...
Solve the programming task below in a Python markdown code block. You are given a rooted tree with vertices numerated from $1$ to $n$. A tree is a connected graph without cycles. A rooted tree has a special vertex named root. Ancestors of the vertex $i$ are all vertices on the path from the root to the vertex $i$, ex...
Solve the programming task below in a Python markdown code block. Takahashi has N balls with positive integers written on them. The integer written on the i-th ball is A_i. He would like to form some number of pairs such that the sum of the integers written on each pair of balls is a power of 2. Note that a ball canno...
Solve the programming task below in a Python markdown code block. This is the easy version of the problem. The only difference is the constraints on $n$ and $k$. You can make hacks only if all versions of the problem are solved. You have a string $s$, and you can do two types of operations on it: Delete the last cha...
Solve the programming task below in a Python markdown code block. Today Sonya learned about long integers and invited all her friends to share the fun. Sonya has an initially empty multiset with integers. Friends give her t queries, each of one of the following type: 1. + ai — add non-negative integer ai to the mu...
Solve the programming task below in a Python markdown code block. The objective is to disambiguate two given names: the original with another This kata is slightly more evolved than the previous one: [Author Disambiguation: to the point!](https://www.codewars.com/kata/580a429e1cb4028481000019). The function ```could...
Solve the programming task below in a Python markdown code block. In Republic of Atcoder, there are N prefectures, and a total of M cities that belong to those prefectures. City i is established in year Y_i and belongs to Prefecture P_i. You can assume that there are no multiple cities that are established in the same...
Solve the programming task below in a Python markdown code block. Prof. Hachioji has devised a new numeral system of integral numbers with four lowercase letters "m", "c", "x", "i" and with eight digits "2", "3", "4", "5", "6", "7", "8", "9". He doesn't use digit "0" nor digit "1" in this system. The letters "m", "c"...
Solve the programming task below in a Python markdown code block. Problem statement There are rectangles with vertical and horizontal lengths of h and w, and square squares with a side length of 1 are spread inside. If the upper left cell is (0,0) and the cell to the right of j below (0,0) is represented as (i, j), (...
Solve the programming task below in a Python markdown code block. Let's solve the geometric problem Mr. A is still solving geometric problems today. It is important to be aware of floating point errors when solving geometric problems. Floating-point error is the error caused by the rounding that occurs when represen...
Solve the programming task below in a Python markdown code block. You have a long fence which consists of $n$ sections. Unfortunately, it is not painted, so you decided to hire $q$ painters to paint it. $i$-th painter will paint all sections $x$ such that $l_i \le x \le r_i$. Unfortunately, you are on a tight budget,...
Solve the programming task below in a Python markdown code block. Read problems statements in Mandarin Chinese, Russian and Vietnamese as well. After a long time, Chef has finally decided to renovate his house. Chef's house has N rooms in it numbered from 1 to N. Each room is currently painted in one of the red, blue...
Solve the programming task below in a Python markdown code block. There are league games and tournament games in sports competitions. In soccer league games, points are given to each of the wins, losses, and draws, and the rankings are competed based on the points. The points are win (3 points), negative (0 points), a...
Solve the programming task below in a Python markdown code block. problem AOR Ika and you came to the tournament-style table tennis tournament singles section for reconnaissance. For AOR Ika-chan, who wants to record all the games, you decide to ask for the number of games that will be played in this tournament. The...
Solve the programming task below in a Python markdown code block. Ryouko is an extremely forgetful girl, she could even forget something that has just happened. So in order to remember, she takes a notebook with her, called Ryouko's Memory Note. She writes what she sees and what she hears on the notebook, and the note...
Solve the programming task below in a Python markdown code block. There are N apple trees in a row. People say that one of them will bear golden apples. We want to deploy some number of inspectors so that each of these trees will be inspected. Each inspector will be deployed under one of the trees. For convenience, we...
Solve the programming task below in a Python markdown code block. The Romans have attacked again. This time they are much more than the Persians but Shapur is ready to defeat them. He says: "A lion is never afraid of a hundred sheep". Nevertheless Shapur has to find weaknesses in the Roman army to defeat them. So he...
Solve the programming task below in a Python markdown code block. This is a very simply formulated task. Let's call an integer number `N` 'green' if `N²` ends with all of the digits of `N`. Some examples: `5` is green, because `5² = 25` and `25` ends with `5`. `11` is not green, because `11² = 121` and `121` does no...
Solve the programming task below in a Python markdown code block. There are n students who have taken part in an olympiad. Now it's time to award the students. Some of them will receive diplomas, some wiil get certificates, and others won't receive anything. Students with diplomas and certificates are called winners....
Solve the programming task below in a Python markdown code block. Write a program which reads a list of student test scores and evaluates the performance for each student. The test scores for a student include scores of the midterm examination m (out of 50), the final examination f (out of 50) and the makeup examinat...
Solve the programming task below in a Python markdown code block. The description is rather long but it tries to explain what a financing plan is. The fixed monthly payment for a fixed rate mortgage is the amount paid by the borrower every month that ensures that the loan is paid off in full with interest at the en...
Solve the programming task below in a Python markdown code block. PolandBall has such a convex polygon with n veritces that no three of its diagonals intersect at the same point. PolandBall decided to improve it and draw some red segments. He chose a number k such that gcd(n, k) = 1. Vertices of the polygon are numb...
Solve the programming task below in a Python markdown code block. Chef loves games! But he likes to invent his own. Now he plays game "Digit Jump". Chef has a sequence of digits $S_{1}, S_{2}, \ldots , S_{N}$. He is staying in the first digit $S_{1}$ and wants to reach the last digit $S_{N}$ in the minimal number of j...
Solve the programming task below in a Python markdown code block. A sequence a_1,a_2,... ,a_n is said to be /\/\/\/ when the following conditions are satisfied: - For each i = 1,2,..., n-2, a_i = a_{i+2}. - Exactly two different numbers appear in the sequence. You are given a sequence v_1,v_2,...,v_n whose length is...
Solve the programming task below in a Python markdown code block. Polycarp has n different binary words. A word called binary if it contains only characters '0' and '1'. For example, these words are binary: "0001", "11", "0" and "0011100". Polycarp wants to offer his set of n binary words to play a game "words". In t...
Solve the programming task below in a Python markdown code block. ## Number pyramid Number pyramid is a recursive structure where each next row is constructed by adding adjacent values of the current row. For example: ``` Row 1 [1 2 3 4] Row 2 [3 5 7] Row 3 [8 12] Row 4 ...
Solve the programming task below in a Python markdown code block. Nam is playing with a string on his computer. The string consists of n lowercase English letters. It is meaningless, so Nam decided to make the string more beautiful, that is to make it be a palindrome by using 4 arrow keys: left, right, up, down. Ther...
Solve the programming task below in a Python markdown code block. You are both a shop keeper and a shop assistant at a small nearby shop. You have $n$ goods, the $i$-th good costs $a_i$ coins. You got tired of remembering the price of each product when customers ask for it, thus you decided to simplify your life. Mor...
Solve the programming task below in a Python markdown code block. One day, Snuke was given a permutation of length N, a_1, a_2, ..., a_N, from his friend. Find the following: <image> Constraints * 1 ≦ N ≦ 200,000 * (a_1, a_2, ..., a_N) is a permutation of (1, 2, ..., N). Input The input is given from Standard In...
Solve the programming task below in a Python markdown code block. You are given an integer N. Among the divisors of N! (= 1 \times 2 \times ... \times N), how many Shichi-Go numbers (literally "Seven-Five numbers") are there? Here, a Shichi-Go number is a positive integer that has exactly 75 divisors. -----Note----- ...
Solve the programming task below in a Python markdown code block. A team of students from the city S is sent to the All-Berland Olympiad in Informatics. Traditionally, they go on the train. All students have bought tickets in one carriage, consisting of n compartments (each compartment has exactly four people). We kno...
Solve the programming task below in a Python markdown code block. You are given two lists of non-zero digits. Let's call an integer pretty if its (base 10) representation has at least one digit from the first list and at least one digit from the second list. What is the smallest positive pretty integer? -----Input-...
Solve the programming task below in a Python markdown code block. Polycarp is a frequent user of the very popular messenger. He's chatting with his friends all the time. He has $n$ friends, numbered from $1$ to $n$. Recall that a permutation of size $n$ is an array of size $n$ such that each integer from $1$ to $n$ o...
Solve the programming task below in a Python markdown code block. Snuke has a blackboard and a set S consisting of N integers. The i-th element in S is S_i. He wrote an integer X on the blackboard, then performed the following operation N times: * Choose one element from S and remove it. * Let x be the number writte...
Solve the programming task below in a Python markdown code block. An architect, Devunky, who lives in Water Deven, has been asked to renovate an old large hospital. In some countries, people don't want to use numbers that are disliked as numerophobia (4 and 9 are famous in Japan). However, the room numbers in this ho...
Solve the programming task below in a Python markdown code block. Jzzhu has a big rectangular chocolate bar that consists of n × m unit squares. He wants to cut this bar exactly k times. Each cut must meet the following requirements: * each cut should be straight (horizontal or vertical); * each cut should go al...
Solve the programming task below in a Python markdown code block. Dark is going to attend Motarack's birthday. Dark decided that the gift he is going to give to Motarack is an array $a$ of $n$ non-negative integers. Dark created that array $1000$ years ago, so some elements in that array disappeared. Dark knows that ...
Solve the programming task below in a Python markdown code block. Chef has a binary tree. The binary tree consists of 1 or more nodes. Each node has a unique integer id. Each node has up to 2 children, which are identified by their ids, and each node is the child of at most 1 other node. A node X is considered to be a...
Solve the programming task below in a Python markdown code block. AtCoDeer the deer is going on a trip in a two-dimensional plane. In his plan, he will depart from point (0, 0) at time 0, then for each i between 1 and N (inclusive), he will visit point (x_i,y_i) at time t_i. If AtCoDeer is at point (x, y) at time t, h...
Solve the programming task below in a Python markdown code block. Each of you probably has your personal experience of riding public transportation and buying tickets. After a person buys a ticket (which traditionally has an even number of digits), he usually checks whether the ticket is lucky. Let us remind you that ...
Solve the programming task below in a Python markdown code block. Mr. Chanek is currently participating in a science fair that is popular in town. He finds an exciting puzzle in the fair and wants to solve it. There are $N$ atoms numbered from $1$ to $N$. These atoms are especially quirky. Initially, each atom is in ...
Solve the programming task below in a Python markdown code block. George is a cat, so he really likes to play. Most of all he likes to play with his array of positive integers b. During the game, George modifies the array by using special changes. Let's mark George's current array as b_1, b_2, ..., b_{|}b| (record |b|...
Solve the programming task below in a Python markdown code block. # Story John found a path to a treasure, and while searching for its precise location he wrote a list of directions using symbols `"^"`, `"v"`, `"<"`, `">"` which mean `north`, `east`, `west`, and `east` accordingly. On his way John had to try many dif...
Solve the programming task below in a Python markdown code block. There is "7 rows" in the game using playing cards. Here we consider a game that simplifies it. Arrange 7 using 13 cards with numbers 1 to 13 written on each. In the match, the game progresses as follows with only two players. 1. Place 7 cards in the "f...
Solve the programming task below in a Python markdown code block. Read problems statements in Mandarin Chinese and Russian as well. Vadim and Roman like discussing challenging problems with each other. One day Vadim told his friend following problem: Given N points on a plane. Each point p is defined by it's two int...
Solve the programming task below in a Python markdown code block. Example Input 2 2 1 2 0 3 4 1 Output 2 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. This problem differs from the previous one only in the absence of the constraint on the equal length of all numbers $a_1, a_2, \dots, a_n$. A team of SIS students is going to make a trip on a submarine. Their target is an ancient treasure in a sunken s...
Solve the programming task below in a Python markdown code block. Chanek Jones is back, helping his long-lost relative Indiana Jones, to find a secret treasure in a maze buried below a desert full of illusions. The map of the labyrinth forms a tree with n rooms numbered from 1 to n and n - 1 tunnels connecting them s...
Solve the programming task below in a Python markdown code block. Dr. Evil kidnapped Mahmoud and Ehab in the evil land because of their performance in the Evil Olympiad in Informatics (EOI). He decided to give them some problems to let them go. Dr. Evil is interested in sets, He has a set of n integers. Dr. Evil call...
Solve the programming task below in a Python markdown code block. Let's call an undirected graph of n vertices p-interesting, if the following conditions fulfill: the graph contains exactly 2n + p edges; the graph doesn't contain self-loops and multiple edges; for any integer k (1 ≤ k ≤ n), any subgraph consisting...
Solve the programming task below in a Python markdown code block. E869120 defined a sequence $a$ like this: * $a_1=a_2=1$, $a_{k+2}=a_{k+1}+a_k \ (k \ge 1)$ He also defined sequences $d_1, d_2, d_3, \dots , d_n$, as the following recurrence relation : * $d_{1, j} = a_j$ * $d_{i, j} = \sum_{k = 1}^j d_{i - 1, k} ...
Solve the programming task below in a Python markdown code block. Consider the decimal presentation of an integer. Let's call a number d-magic if digit d appears in decimal presentation of the number on even positions and nowhere else. For example, the numbers 1727374, 17, 1 are 7-magic but 77, 7, 123, 34, 71 are not...
Solve the programming task below in a Python markdown code block. Cowboy Beblop is a funny little boy who likes sitting at his computer. He somehow obtained two elastic hoops in the shape of 2D polygons, which are not necessarily convex. Since there's no gravity on his spaceship, the hoops are standing still in the ai...
Solve the programming task below in a Python markdown code block. Vika has an infinite sheet of squared paper. Initially all squares are white. She introduced a two-dimensional coordinate system on this sheet and drew n black horizontal and vertical segments parallel to the coordinate axes. All segments have width equ...
Solve the programming task below in a Python markdown code block. We conducted a survey on newspaper subscriptions. More specifically, we asked each of the N respondents the following two questions: * Question 1: Are you subscribing to Newspaper X? * Question 2: Are you subscribing to Newspaper Y? As the result, A...
Solve the programming task below in a Python markdown code block. Tunnel formula One day while exploring an abandoned mine, you found a long formula S written in the mine. If you like large numbers, you decide to take out the choke and add `(` or `)` so that the result of the formula calculation is as large as possib...
Solve the programming task below in a Python markdown code block. # Task * **_Given_** *three integers* `a` ,`b` ,`c`, **_return_** *the **_largest number_** obtained after inserting the following operators and brackets*: `+`, `*`, `()` * In other words , **_try every combination of a,b,c with [*+()] , and return the...
Solve the programming task below in a Python markdown code block. Chef Ciel wants to put a fancy neon signboard over the entrance of her restaurant. She has not enough money to buy the new one so she bought some old neon signboard through the internet. Ciel was quite disappointed when she received her order - some of ...
Solve the programming task below in a Python markdown code block. You are given a rectangular grid with $n$ rows and $m$ columns. The cell located on the $i$-th row from the top and the $j$-th column from the left has a value $a_{ij}$ written in it. You can perform the following operation any number of times (possibl...
Solve the programming task below in a Python markdown code block. Problem Den, the phone number of Ukunikia Co., Ltd., enters a very long phone number into the phone every day. One day, too tired, Den came up with a surprising idea. "Isn't it even a little easier if you rearrange the arrangement of the buttons on the...
Solve the programming task below in a Python markdown code block. Petya has a rectangular Board of size $n \times m$. Initially, $k$ chips are placed on the board, $i$-th chip is located in the cell at the intersection of $sx_i$-th row and $sy_i$-th column. In one action, Petya can move all the chips to the left, rig...
Solve the programming task below in a Python markdown code block. You may know that Euclid was a mathematician. Well, as it turns out, Morpheus knew it too. So when he wanted to play a mean trick on Euclid, he sent him an appropriate nightmare. In his bad dream Euclid has a set S of n m-dimensional vectors over the ...
Solve the programming task below in a Python markdown code block. Recently Vasya found a golden ticket — a sequence which consists of $n$ digits $a_1a_2\dots a_n$. Vasya considers a ticket to be lucky if it can be divided into two or more non-intersecting segments with equal sums. For example, ticket $350178$ is lucky...
Solve the programming task below in a Python markdown code block. Vasya is a school PE teacher. Unlike other PE teachers, Vasya doesn't like it when the students stand in line according to their height. Instead, he demands that the children stand in the following order: a1, a2, ..., an, where ai is the height of the i...
Solve the programming task below in a Python markdown code block. Vasya writes his own library for building graphical user interface. Vasya called his creation VTK (VasyaToolKit). One of the interesting aspects of this library is that widgets are packed in each other. A widget is some element of graphical interface....
Solve the programming task below in a Python markdown code block. A star map in Berland is a checked field n × m squares. In each square there is or there is not a star. The favourite constellation of all Berland's astronomers is the constellation of the Cross. This constellation can be formed by any 5 stars so, that ...
Solve the programming task below in a Python markdown code block. Write ```python smaller(arr) ``` that given an array ```arr```, you have to return the amount of numbers that are smaller than ```arr[i]``` to the right. For example: ```python smaller([5, 4, 3, 2, 1]) == [4, 3, 2, 1, 0] smaller([1, 2, 0]) == [1, 1, 0]...
Solve the programming task below in a Python markdown code block. You know that Japan is the country with almost the largest 'electronic devices per person' ratio. So you might be quite surprised to find out that the primary school in Japan teaches to count using a Soroban — an abacus developed in Japan. This phenomen...
Solve the programming task below in a Python markdown code block. The Kingdom of Takahashi has N towns, numbered 1 through N. There is one teleporter in each town. The teleporter in Town i (1 \leq i \leq N) sends you to Town A_i. Takahashi, the king, loves the positive integer K. The selfish king wonders what town he ...
Solve the programming task below in a Python markdown code block. FizzBuzz is often one of the first programming puzzles people learn. Now undo it with reverse FizzBuzz! Write a function that accepts a string, which will always be a valid section of FizzBuzz. Your function must return an array that contains the numbe...
Solve the programming task below in a Python markdown code block. Looking at consecutive powers of `2`, starting with `2^1`: `2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, ...` Note that out of all the digits `0-9`, the last one ever to appear is `7`. It only shows up for the first time i...
Solve the programming task below in a Python markdown code block. Nazar, a student of the scientific lyceum of the Kingdom of Kremland, is known for his outstanding mathematical abilities. Today a math teacher gave him a very difficult task. Consider two infinite sets of numbers. The first set consists of odd positiv...
Solve the programming task below in a Python markdown code block. The employees of the F company have lots of ways to entertain themselves. Today they invited a famous magician who shows a trick with plastic cups and a marble. The point is to trick the spectator's attention. Initially, the spectator stands in front o...
Solve the programming task below in a Python markdown code block. A factory produces thimbles in bulk. Typically, it can produce up to a thimbles a day. However, some of the machinery is defective, so it can currently only produce b thimbles each day. The factory intends to choose a k-day period to do maintenance and ...
Solve the programming task below in a Python markdown code block. A programming competition site AtCode provides algorithmic problems. Each problem is allocated a score based on its difficulty. Currently, for each integer i between 1 and D (inclusive), there are p_i problems with a score of 100i points. These p_1 + … ...
Solve the programming task below in a Python markdown code block. The Quarkgo Empire Expeditionary Force is an evil organization that plans to invade the Earth. In keeping with the tradition of the invaders, they continued to send monsters at a pace of one every week, targeting the area around Tokyo in Japan. However,...
Solve the programming task below in a Python markdown code block. Alice and Bob decided to eat some fruit. In the kitchen they found a large bag of oranges and apples. Alice immediately took an orange for herself, Bob took an apple. To make the process of sharing the remaining fruit more fun, the friends decided to pl...
Solve the programming task below in a Python markdown code block. Vasya likes taking part in Codeforces contests. When a round is over, Vasya follows all submissions in the system testing tab. There are n solutions, the i-th of them should be tested on a_i tests, testing one solution on one test takes 1 second. The s...
Solve the programming task below in a Python markdown code block. In this kata you have to correctly return who is the "survivor", ie: the last element of a Josephus permutation. Basically you have to assume that n people are put into a circle and that they are eliminated in steps of k elements, like this: ``` josep...
Solve the programming task below in a Python markdown code block. Kontti language is a finnish word play game. You add `-kontti` to the end of each word and then swap their characters until and including the first vowel ("aeiouy"); For example the word `tame` becomes `kome-tantti`; `fruity` becomes `koity-fruntti` ...
Solve the programming task below in a Python markdown code block. The year 2015 is almost over. Limak is a little polar bear. He has recently learnt about the binary system. He noticed that the passing year has exactly one zero in its representation in the binary system — 2015_10 = 11111011111_2. Note that he doesn't...
Solve the programming task below in a Python markdown code block. In this Kata we focus on finding a sum S(n) which is the total number of divisors taken for all natural numbers less or equal to n. More formally, we investigate the sum of n components denoted by d(1) + d(2) + ... + d(n) in which for any i starting fro...
Solve the programming task below in a Python markdown code block. Once upon a time in the Kingdom of Far Far Away lived Sir Lancelot, the chief Royal General. He was very proud of his men and he liked to invite the King to come and watch drill exercises which demonstrated the fighting techniques and tactics of the squ...
Solve the programming task below in a Python markdown code block. Serval soon said goodbye to Japari kindergarten, and began his life in Japari Primary School. In his favorite math class, the teacher taught him the following interesting definitions. A parenthesis sequence is a string, containing only characters "(" ...
Solve the programming task below in a Python markdown code block. Miyako came to the flea kingdom with a ukulele. She became good friends with local flea residents and played beautiful music for them every day. In return, the fleas made a bigger ukulele for her: it has $n$ strings, and each string has $(10^{18} + 1)$...
Solve the programming task below in a Python markdown code block. The range search problem consists of a set of attributed records S to determine which records from S intersect with a given range. For n points on a plane, report a set of points which are within in a given range. Note that you do not need to consider ...
Solve the programming task below in a Python markdown code block. Cara is applying for several different jobs. The online application forms ask her to respond within a specific character count. Cara needs to check that her answers fit into the character limit. Annoyingly, some application forms count spaces as a char...
Solve the programming task below in a Python markdown code block. We have N points numbered 1 to N arranged in a line in this order. Takahashi decides to make an undirected graph, using these points as the vertices. In the beginning, the graph has no edge. Takahashi will do M operations to add edges in this graph. Th...
Solve the programming task below in a Python markdown code block. Vova has won $n$ trophies in different competitions. Each trophy is either golden or silver. The trophies are arranged in a row. The beauty of the arrangement is the length of the longest subsegment consisting of golden trophies. Vova wants to swap two...
Solve the programming task below in a Python markdown code block. In distant future on Earth day lasts for n hours and that's why there are n timezones. Local times in adjacent timezones differ by one hour. For describing local time, hours numbers from 1 to n are used, i.e. there is no time "0 hours", instead of it "n...