problem_id stringlengths 32 32 | name stringlengths 2 112 | problem stringlengths 200 14k | test_cases stringlengths 33 79.2M | difficulty stringclasses 34
values | language listlengths 1 1 | source stringclasses 15
values | num_solutions int64 1 1.12M | starter_code stringlengths 0 1.47k | subset stringclasses 4
values | reasoning stringlengths 1.09k 133k | deepseek_solution stringlengths 60 15k | correctness bool 2
classes | reason stringclasses 3
values |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
b8647a7e2926935660a06e9ef1fce9ea | Declined Finalists | This year, as in previous years, MemSQL is inviting the top 25 competitors from the Start[c]up qualification round to compete onsite for the final round. Not everyone who is eligible to compete onsite can afford to travel to the office, though. Initially the top 25 contestants are invited to come onsite. Each eligible ... | {"inputs": ["25\n2 3 4 5 6 7 8 9 10 11 12 14 15 16 17 18 19 20 21 22 23 24 25 26 28", "5\n16 23 8 15 4", "3\n14 15 92", "1\n1000000", "25\n1000000 999999 999998 999997 999996 999995 999994 999993 999992 999991 999990 999989 999988 999987 999986 999985 999984 999983 999982 999981 999980 999979 999978 999977 999976", "25... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 279 | codeforces | Okay, let's try to figure out this problem. So, the task is to determine the minimum possible number of contestants that declined the invitation to the onsite competition. Hmm. Let's see. The setup is that the top 25 are invited initially, but if any of them decline, they get replaced by the next highest ranked. This p... | To solve this problem, we need to determine the minimum number of contestants that declined the invitation to compete onsite in the final round of the MemSQL competition. The key insight is that each contestant who accepted an invitation with a rank higher than 25 must have been invited due to someone else declining. T... | true | ||
b86e30843c84440849b6b0560eb93808 | st-Spanning Tree | You are given an undirected connected graph consisting of *n* vertices and *m* edges. There are no loops and no multiple edges in the graph.
You are also given two distinct vertices *s* and *t*, and two values *d**s* and *d**t*. Your task is to build any spanning tree of the given graph (note that the graph is not wei... | {"inputs": ["3 3\n1 2\n2 3\n3 1\n1 2 1 1", "7 8\n7 4\n1 3\n5 4\n5 7\n3 2\n2 4\n6 1\n1 2\n6 4 1 4", "10 15\n4 1\n5 10\n2 1\n5 7\n9 2\n4 6\n6 7\n9 1\n6 9\n8 4\n8 3\n9 8\n3 9\n2 3\n7 10\n10 1 2 3", "10 10\n1 3\n10 3\n6 1\n2 7\n1 7\n1 9\n9 5\n2 10\n10 8\n4 3\n9 5 2 4", "4 4\n1 4\n4 2\n1 3\n4 3\n3 4 3 3", "3 2\n3 1\n2 3\n1 ... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 1 | codeforces | Okay, I need to solve this programming problem. Let's read the problem carefully.
The task is to find a spanning tree of an undirected connected graph such that the degrees of two specific vertices s and t do not exceed ds and dt respectively. If it's impossible, output "No". Otherwise, output the edges of such a span... | To solve this problem, we need to construct a spanning tree of an undirected connected graph such that the degrees of two specific vertices, s and t, do not exceed given constraints. If it's impossible to form such a tree, we should output "No".
### Approach
1. **Input Parsing and Edge Classification**: Read the input... | false | Code is incorrect. | |
b8a883f6d70b75a151dc0664da41aa54 | Counting Rectangles is Fun | There is an *n*<=×<=*m* rectangular grid, each cell of the grid contains a single integer: zero or one. Let's call the cell on the *i*-th row and the *j*-th column as (*i*,<=*j*).
Let's define a "rectangle" as four integers *a*,<=*b*,<=*c*,<=*d* (1<=≤<=*a*<=≤<=*c*<=≤<=*n*; 1<=≤<=*b*<=≤<=*d*<=≤<=*m*). Rectangle denotes... | {"inputs": ["5 5 5\n00101\n00000\n00001\n01000\n00001\n1 2 2 4\n4 5 4 5\n1 2 5 2\n2 2 4 5\n4 2 5 3", "4 7 5\n0000100\n0000010\n0011000\n0000000\n1 7 2 7\n3 1 3 1\n2 3 4 5\n1 2 2 7\n2 2 4 7", "10 10 10\n0010001010\n0011011010\n0100001110\n0010100000\n0000100011\n0100000001\n0000010100\n1000000010\n0000010000\n0110010000... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 1 | codeforces | Okay, I need to solve this programming problem. Let's read the problem statement carefully.
The problem is about counting the number of "good rectangles" within a given query rectangle. A good rectangle is one that contains only zeros. So for each query, which specifies a subrectangle of the grid, we need to find out ... | To solve this problem, we need to efficiently count the number of "good rectangles" (rectangles containing only zeros) within specified sub-rectangles of a grid for multiple queries. The challenge is to handle up to 300,000 queries efficiently given the constraints of grid size up to 40x40.
### Approach
1. **Preproces... | true | ||
b8bf78afb79fadde1f00b79f93ba318c | none | Карта звёздного неба представляет собой прямоугольное поле, состоящее из *n* строк по *m* символов в каждой строке. Каждый символ — это либо «.» (означает пустой участок неба), либо «*» (означает то, что в этом месте на небе есть звезда).
Новое издание карты звёздного неба будет напечатано на квадратных листах, поэто... | {"inputs": ["4 4\n....\n..*.\n...*\n..**", "1 3\n*.*", "2 1\n.\n*", "1 1\n*", "1 2\n.*", "1 2\n*.", "1 2\n**", "2 1\n.\n*", "2 1\n*\n.", "2 1\n*\n*", "5 3\n..*\n.**\n..*\n...\n..*", "1 1\n*", "1 2\n*.", "1 2\n**", "1 3\n.**", "1 3\n*.*", "1 4\n..**", "1 4\n*..*", "1 5\n.*.**", "1 5\n.*..*", "2 1\n*\n.", "2 1\n*\n*", "2... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 8 | codeforces | Okay, let's tackle this programming problem. Hmm, the task is to find the minimal side length of a square that can cover all the stars on the map. The square's boundaries must be aligned with the grid, right? So first, I need to figure out the positions of all the stars. Then, find the smallest square that can enclose ... | To solve this problem, we need to determine the minimum side length of a square that can enclose all the stars on a given rectangular map. The square must be aligned with the grid and cover all the stars such that its boundaries are parallel to the edges of the map.
### Approach
1. **Identify Star Positions**: Travers... | true | ||
b8d8b73277f7749e7852f8884ff19b71 | Subtractions | You've got two numbers. As long as they are both larger than zero, they go through the same operation: subtract the lesser number from the larger one. If they equal substract one number from the another. For example, one operation transforms pair (4,17) to pair (4,13), it transforms (5,5) to (0,5).
You've got some num... | {"inputs": ["2\n4 17\n7 987654321", "10\n7 987654321\n7 987654321\n7 987654321\n7 987654321\n7 987654321\n7 987654321\n7 987654321\n7 987654321\n7 987654321\n7 987654321", "1\n536870912 32", "20\n1000000000 999999999\n1000000000 999999999\n1000000000 999999999\n1000000000 999999999\n1000000000 999999999\n1000000000 999... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 242 | codeforces | Okay, let's see. I need to solve this problem where for each pair of numbers (a, b), I have to find out how many operations are performed until one of them becomes zero. The operation is subtracting the smaller number from the larger one each time. But wait, if they are equal, subtracting one from the other makes one z... | To solve this problem, we need to determine the number of operations required to reduce each pair of numbers (a, b) to a pair where one of the numbers becomes zero. Each operation involves subtracting the smaller number from the larger one repeatedly until one of the numbers becomes zero.
### Approach
The key insight ... | true | ||
b8e4040e30b7e2f49655da687a4e31d4 | Bash's Big Day | Bash has set out on a journey to become the greatest Pokemon master. To get his first Pokemon, he went to Professor Zulu's Lab. Since Bash is Professor Zulu's favourite student, Zulu allows him to take as many Pokemon from his lab as he pleases.
But Zulu warns him that a group of *k*<=><=1 Pokemon with strengths {*... | {"inputs": ["3\n2 3 4", "5\n2 3 4 6 7", "3\n5 6 4", "8\n41 74 4 27 85 39 100 36", "6\n89 20 86 81 62 23", "71\n23 84 98 8 14 4 42 56 83 87 28 22 32 50 5 96 90 1 59 74 77 88 71 38 62 36 85 97 99 6 81 20 49 57 66 9 45 41 29 68 35 19 27 76 78 72 55 25 46 48 26 53 39 31 94 34 63 37 64 16 79 24 82 17 12 3 89 61 80 30 10", "... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 39 | codeforces | Okay, I need to solve this problem where Bash wants to take as many Pokemon as possible, but their group's GCD must be greater than 1. Otherwise, they'll fight. So my task is to find the maximum subset size where the GCD of all elements in the subset is greater than 1. Let's think about how to approach this.
First, le... | To solve this problem, we need to determine the maximum number of Pokémon Bash can take from Professor Zulu's lab such that their strengths have a greatest common divisor (GCD) greater than 1. This ensures they won't fight among themselves.
### Approach
1. **Prime Factorization Insight**: If a group of Pokémon has a G... | false | Code is incorrect. | |
b8fffd9ad83f41df8f97739b5e939e71 | Make a Permutation! | Ivan has an array consisting of *n* elements. Each of the elements is an integer from 1 to *n*.
Recently Ivan learned about permutations and their lexicographical order. Now he wants to change (replace) minimum number of elements in his array in such a way that his array becomes a permutation (i.e. each of the integer... | {"inputs": ["4\n3 2 2 3", "6\n4 5 6 3 2 1", "10\n6 8 4 6 7 1 6 3 4 5", "6\n5 5 5 6 4 6", "50\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1", "50\n1 1 2 1 1 1 1 1 1 1 1 1 2 1 2 1 1 2 1 1 1 1 1 1 1 1 1 2 1 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1", "50\n2 4 1 2 3 7 ... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 31 | codeforces | Okay, let's see. I need to solve this problem where Ivan's array has to be transformed into a permutation of 1 to n with the minimum number of changes. And if there are multiple ways, pick the lex smallest one. Hmm.
First, the problem statement says that the first priority is to minimize the number of changes. So the ... | To solve this problem, we need to transform Ivan's array into a permutation of integers from 1 to n with the minimum number of changes. If there are multiple valid permutations, we should choose the lexicographically smallest one.
### Approach
1. **Identify Missing Elements**: Determine which numbers from 1 to n are m... | false | Code is incorrect. | |
b90159b3b2c41c91a4086c3dd7b577d5 | Vladik and Memorable Trip | Vladik often travels by trains. He remembered some of his trips especially well and I would like to tell you about one of these trips:
Vladik is at initial train station, and now *n* people (including Vladik) want to get on the train. They are already lined up in some order, and for each of them the city code *a**i* i... | {"inputs": ["6\n4 4 2 5 2 3", "9\n5 1 3 1 5 2 4 2 5", "5\n1558 4081 3591 1700 3232", "10\n3838 1368 4825 2068 4755 2048 1342 4909 2837 4854", "10\n4764 4867 2346 1449 1063 2002 2577 2089 1566 614", "10\n689 3996 3974 4778 1740 3481 2916 2744 294 1376", "100\n1628 4511 4814 3756 4625 1254 906 1033 2420 2622 2640 3225 35... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 12 | codeforces | Okay, I need to solve this programming problem. Let's read the problem statement carefully.
So, the problem is about finding the maximum possible total comfort when splitting a sequence of people into segments. The rules are that all people going to the same city must be in the same segment (or not selected at all). T... | To solve this problem, we need to maximize the total comfort of a train trip by selecting disjoint segments of people such that all people going to the same city are in the same segment. The comfort of each segment is the XOR of distinct city codes in that segment. The goal is to find the maximum possible sum of these ... | true | ||
b93fdbb19a50d95418de5887b98a8017 | Sasha and Sticks | It's one more school day now. Sasha doesn't like classes and is always bored at them. So, each day he invents some game and plays in it alone or with friends.
Today he invented one simple game to play with Lena, with whom he shares a desk. The rules are simple. Sasha draws *n* sticks in a row. After that the players t... | {"inputs": ["1 1", "10 4", "251656215122324104 164397544865601257", "963577813436662285 206326039287271924", "1000000000000000000 1", "253308697183523656 25332878317796706", "669038685745448997 501718093668307460", "116453141993601660 87060381463547965", "766959657 370931668", "255787422422806632 146884995820359999", "... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 350 | codeforces | Okay, let's try to figure out this problem. So the problem is about Sasha and Lena taking turns to cross out exactly k sticks from either end of a row. Sasha goes first. The game ends when there are less than k sticks left. Sasha wins if he makes strictly more moves than Lena. We need to determine whether Sasha will wi... | To solve this problem, we need to determine if Sasha wins a game where he and Lena take turns crossing out exactly `k` sticks from either end of a row of `n` sticks. Sasha wins if he makes strictly more moves than Lena.
### Approach
The key insight is that each player removes exactly `k` sticks in their turn. The tota... | true | ||
b95a8706627d77a638a45e9ced72df03 | none | This is an interactive problem.
Natasha is going to fly to Mars. Finally, Natasha sat in the rocket. She flies, flies... but gets bored. She wishes to arrive to Mars already! So she decides to find something to occupy herself. She couldn't think of anything better to do than to calculate the distance to the red planet... | {"inputs": ["5 2 3\n1 0", "1 1 1\n1", "3 2 3\n1 0", "6 3 5\n1 1 1", "10 4 3\n0 0 1 0", "30 5 16\n0 1 1 1 0", "60 6 21\n1 0 0 1 0 1", "100 7 73\n0 0 0 1 0 1 1", "1000000000 29 958572235\n1 1 0 1 1 1 1 0 1 0 1 0 0 0 1 0 0 0 0 0 0 0 0 0 1 1 1 0 0", "738009704 30 116044407\n0 0 1 1 0 0 1 0 0 0 1 0 0 0 1 0 0 1 1 0 1 0 1 1 0... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 27 | codeforces | Okay, I need to solve this problem where Natasha has to determine the correct x value between 1 and m by asking up to 60 questions. The rocket's answers depend on a cyclic sequence p of 0s and 1s of length n. Each question's answer is either correct or a lie based on the current element in p. The challenge is to find x... | To solve this problem, we need to determine the distance to Mars, denoted as \( x \), by asking up to 60 questions to a rocket that may provide incorrect answers based on a cyclic sequence of truth and lies. The solution must ensure that we receive a 0 answer from the rocket, which indicates the correct value of \( x \... | false | Code is incorrect. | |
b9622c31d50bf23062fb84ae34d8743b | New Year Book Reading | New Year is coming, and Jaehyun decided to read many books during 2015, unlike this year. He has *n* books numbered by integers from 1 to *n*. The weight of the *i*-th (1<=≤<=*i*<=≤<=*n*) book is *w**i*.
As Jaehyun's house is not large enough to have a bookshelf, he keeps the *n* books by stacking them vertically. Whe... | {"inputs": ["3 5\n1 2 3\n1 3 2 3 1", "3 3\n10 20 30\n1 2 3", "2 2\n10 12\n2 1", "10 10\n61 59 97 16 2 94 57 48 91 93\n2 8 6 5 3 1 3 4 9 10", "50 50\n75 71 23 37 28 23 69 75 5 62 3 11 96 100 13 50 57 51 8 90 4 6 84 27 11 89 95 81 10 62 48 52 69 87 97 95 30 74 21 42 36 64 31 80 81 50 56 53 33 99\n26 30 5 33 35 29 6 15 36... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 6 | codeforces | Okay, let's try to figure out how to solve this problem. The problem statement is a bit complex, so I need to parse it carefully.
So, Jaehyun has n books stacked vertically. Each day he reads a book, and when he does that, he has to lift all the books above it. The total weight of the books he lifts each day over m da... | To solve this problem, we need to minimize the total weight Jaehyun has to lift when reading books over a series of days. The key insight is to arrange the books in an optimal initial order such that the sum of the weights of the books he lifts each time is minimized. The optimal initial order is determined by the firs... | true | ||
b97db026ba1258b019779e2780f685b7 | Lie or Truth | Vasya has a sequence of cubes and exactly one integer is written on each cube. Vasya exhibited all his cubes in a row. So the sequence of numbers written on the cubes in the order from the left to the right equals to *a*1,<=*a*2,<=...,<=*a**n*.
While Vasya was walking, his little brother Stepan played with Vasya's cub... | {"inputs": ["5 2 4\n3 4 2 3 1\n3 2 3 4 1", "3 1 2\n1 2 3\n3 1 2", "4 2 4\n1 1 1 1\n1 1 1 1", "5 1 3\n2 2 2 1 2\n2 2 2 1 2", "7 1 4\n2 5 5 5 4 3 4\n2 5 5 5 4 3 4", "10 1 10\n6 7 6 1 10 10 9 5 3 9\n7 10 9 6 1 5 9 3 10 6", "1 1 1\n1\n1", "4 3 4\n1 2 3 4\n2 1 3 4", "7 2 4\n1 2 3 4 5 7 6\n1 2 3 4 5 6 7", "5 1 2\n1 2 3 4 5\n... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 56 | codeforces | Okay, let's see. I need to determine if Stepan is telling the truth or lying. The problem says that Stepan claims he swapped cubes only between positions l and r (inclusive), and that the rest of the cubes (outside this range) are in the same order. But the cubes inside l to r could have been reordered in any way. So t... | To solve this problem, we need to determine if Stepan's claim about rearranging cubes between specific positions in a sequence is truthful or not. The solution involves checking if the elements outside the specified range are unchanged and if the elements within the specified range can be reordered to match the target ... | true | ||
b9872594d263a975d2c53559931b8334 | Little Pony and Expected Maximum | Twilight Sparkle was playing Ludo with her friends Rainbow Dash, Apple Jack and Flutter Shy. But she kept losing. Having returned to the castle, Twilight Sparkle became interested in the dice that were used in the game.
The dice has *m* faces: the first face of the dice contains a dot, the second one contains two dots... | {"inputs": ["6 1", "6 3", "2 2", "5 4", "5 8", "3 10", "3 6", "1 8", "24438 9", "94444 9", "8 66716", "4 25132", "51520 73331", "54230 31747", "24236 90163", "26946 99523", "50323 7", "53033 3", "55743 5", "59964 79", "1 1", "1 1", "3 1", "1 2", "53513 34040", "100000 100000", "1 100000", "100000 1", "2 100000", "10000... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 192 | codeforces | Okay, I need to solve this problem where I have to compute the expected maximum value after rolling an m-faced die n times. Let's think about how to approach this.
First, the problem says that each die face from 1 to m has an equal probability, and each toss is independent. The maximum value after n tosses is a random... | To solve this problem, we need to calculate the expected maximum number of dots obtained after rolling an m-faced die n times. The solution involves using mathematical insights to efficiently compute the expected value using probability theory.
### Approach
The key insight is to recognize that the expected maximum val... | false | Code is incorrect. | |
b98a21fa072aed9a5f1c1c67eb2c1ce9 | Create a Maze | ZS the Coder loves mazes. Your job is to create one so that he can play with it. A maze consists of *n*<=×<=*m* rooms, and the rooms are arranged in *n* rows (numbered from the top to the bottom starting from 1) and *m* columns (numbered from the left to the right starting from 1). The room in the *i*-th row and *j*-th... | {"inputs": ["3", "4", "576460752303423488", "576460752303423487", "99999988898898889", "989466010702279111", "1000000000000000000", "1", "2", "201620162016201600", "138944482508455329", "327543848458922240", "516143210114421854", "481370539210112956", "639733286738742273", "604960615834433375", "793559981784900286", "9... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 2 | codeforces | Okay, I need to generate a maze such that the number of paths from (1,1) to (n,m) is exactly T. The constraints are that the maze can be up to 50x50 and the number of locked doors is at most 300. Hmm.
First, let's think about how the number of paths works in a grid. In a normal grid without any locked doors, the numbe... | To solve this problem, we need to generate a maze such that the number of distinct paths from the top-left corner (1,1) to the bottom-right corner (n,m) is exactly T. The maze must be constructed within the constraints of maximum grid size (50x50) and a limited number of locked doors (300).
### Approach
1. **Grid Stru... | false | Code is incorrect. | |
b9ad6ca1fc6d03437f5d46ec93ad89c2 | Inna and Sweet Matrix | Inna loves sweets very much. That's why she decided to play a game called "Sweet Matrix".
Inna sees an *n*<=×<=*m* matrix and *k* candies. We'll index the matrix rows from 1 to *n* and the matrix columns from 1 to *m*. We'll represent the cell in the *i*-th row and *j*-th column as (*i*,<=*j*). Two cells (*i*,<=*j*) a... | {"inputs": ["4 4 4", "1 1 1", "1 50 50", "50 1 50", "50 50 1", "4 4 9", "10 10 10", "10 10 100", "10 10 50", "10 10 25", "10 10 75", "50 50 1000", "50 50 2500", "50 50 1", "50 50 10", "50 50 100", "50 50 500", "50 50 200", "50 50 1000", "50 50 1500", "50 50 2000", "50 50 2499", "30 30 56", "30 30 800", "2 2 3", "1 2 1"... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 1 | codeforces | Okay, let's try to understand this problem. So, Inna is placing k candies in an n x m matrix. Each time she places a candy, she has to choose a path from (1,1) to some cell (i,j) that doesn't go through any cells that already have candies. The penalty is the sum of the lengths of all these paths, and we need to minimiz... | To solve this problem, we need to place k candies in an n x m matrix such that each candy is placed using a path starting from (1,1) and ending at the target cell, ensuring that no path overlaps with previously placed candies. The goal is to minimize the total penalty, which is the sum of the lengths of all paths used.... | false | Code is incorrect. | |
b9b279d1b0b471a11dcd0b7afc2c685e | Searching for Graph | Let's call an undirected graph of *n* vertices *p*-interesting, if the following conditions fulfill:
- the graph contains exactly 2*n*<=+<=*p* edges; - the graph doesn't contain self-loops and multiple edges; - for any integer *k* (1<=≤<=*k*<=≤<=*n*), any subgraph consisting of *k* vertices contains at most 2*k*<=... | {"inputs": ["1\n6 0", "1\n5 0", "5\n6 0\n5 0\n7 0\n8 0\n9 0", "5\n6 1\n5 0\n7 1\n8 1\n9 1", "5\n24 0\n23 0\n22 0\n21 0\n24 1", "5\n24 1\n23 1\n22 1\n21 1\n20 1", "5\n20 0\n19 0\n18 0\n17 0\n16 0", "5\n15 0\n14 0\n13 0\n12 0\n11 0", "5\n10 0\n20 0\n24 0\n19 0\n17 0", "5\n24 0\n23 0\n24 1\n23 1\n22 0", "5\n24 0\n24 0\n24... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 62 | codeforces | Okay, I need to generate a p-interesting graph for given n and p. Let's try to understand the problem first.
The conditions for a p-interesting graph are:
1. The graph has exactly 2n + p edges. Wait, wait. Wait, the first condition says "exactly 2n <=+<= p edges". Oh, maybe that's a typo in the problem statement. Look... | To solve this problem, we need to construct a p-interesting graph for given values of n (number of vertices) and p (interest value). The graph must meet specific conditions regarding the number of edges and constraints on subgraphs.
### Approach
1. **Understand the Problem Requirements**: The graph must have exactly \... | false | Code is incorrect. | |
b9b2cf2e122e6b22549b44b01e380445 | Vasya and Wrestling | Vasya has become interested in wrestling. In wrestling wrestlers use techniques for which they are awarded points by judges. The wrestler who gets the most points wins.
When the numbers of points of both wrestlers are equal, the wrestler whose sequence of points is lexicographically greater, wins.
If the sequences of... | {"inputs": ["5\n1\n2\n-3\n-4\n3", "3\n-1\n-2\n3", "2\n4\n-4", "7\n1\n2\n-3\n4\n5\n-6\n7", "14\n1\n2\n3\n4\n5\n6\n7\n-8\n-9\n-10\n-11\n-12\n-13\n-14", "4\n16\n12\n19\n-98", "5\n-6\n-1\n-1\n5\n3", "11\n1\n-1\n1\n-1\n1\n-1\n1\n-1\n1\n-1\n1", "1\n-534365", "1\n10253033", "3\n-1\n-2\n3", "8\n1\n-2\n-3\n4\n5\n-6\n-7\n8", "2\... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 157 | codeforces | Okay, let's see. I need to solve this programming problem. Let's read the problem statement carefully.
The problem is about determining which wrestler wins based on their points. The rules are a bit specific. So the first thing to do is understand all the conditions.
So, the input is a number n, followed by n integer... | To solve this problem, we need to determine the winner of a wrestling match based on the points awarded to each wrestler. The winner is determined by three criteria in descending order: total points, lexicographical order of the sequences of points, and the last technique performed if the first two criteria are tied.
... | true | ||
b9b4e52303af6ee09e25948b343ce56f | Where Are My Flakes? | One morning the Cereal Guy found out that all his cereal flakes were gone. He found a note instead of them. It turned out that his smart roommate hid the flakes in one of *n* boxes. The boxes stand in one row, they are numbered from 1 to *n* from the left to the right. The roommate left hints like "Hidden to the left o... | {"inputs": ["2 1\nTo the left of 2", "3 2\nTo the right of 1\nTo the right of 2", "3 1\nTo the left of 3", "3 2\nTo the left of 2\nTo the right of 1", "3 0", "2 2\nTo the left of 2\nTo the left of 2", "5 0", "6 2\nTo the right of 2\nTo the left of 4", "8 6\nTo the right of 3\nTo the left of 4\nTo the left of 4\nTo the ... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 46 | codeforces | Okay, let's see. I need to solve this programming problem. Let me read the problem carefully.
The problem is about finding the minimal number of boxes that must be checked based on some hints. The hints are either "left of i" or "right of i", which means the flakes are definitely not in box i and also not in the boxes... | To solve this problem, we need to determine the minimal number of boxes the Cereal Guy must check to find his cereal flakes based on the given hints. If the hints are contradictory, we should return -1.
### Approach
1. **Understand the Hints**: Each hint either restricts the possible boxes to the left or right of a sp... | true | ||
b9ce4117c8187dc8b1c2b57344133486 | Case of Fake Numbers | Andrewid the Android is a galaxy-famous detective. He is now investigating a case of frauds who make fake copies of the famous Stolp's gears, puzzles that are as famous as the Rubik's cube once was.
Its most important components are a button and a line of *n* similar gears. Each gear has *n* teeth containing all numbe... | {"inputs": ["3\n1 0 0", "5\n4 2 1 4 3", "4\n0 2 3 1", "1\n0", "2\n1 0", "5\n2 4 4 1 1", "10\n0 1 2 3 4 5 6 7 8 9", "10\n1 5 1 0 6 1 3 5 9 9", "20\n10 11 12 13 14 15 16 17 18 19 0 1 2 3 4 5 6 7 8 9", "20\n2 15 18 0 3 12 4 16 13 7 17 9 8 2 15 18 19 17 5 8", "50\n38 13 40 15 42 17 44 19 46 21 48 23 0 25 2 27 4 29 6 31 8 3... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 18 | codeforces | Okay, let's see. So the problem is about these gears and their active teeth after pressing a button multiple times. We need to determine if there's a way to press the button some number of times so that the active teeth form the sequence 0,1,2,...,n-1.
Hmm, the gears rotate in alternating directions. The first gear go... | To solve this problem, we need to determine if a given puzzle of gears can be adjusted such that the active teeth form a sequence from 0 to n-1 after pressing a button multiple times. Each gear rotates in an alternating direction (clockwise for odd-indexed gears, counter-clockwise for even-indexed gears) with each butt... | true | ||
b9e45bc4775a8d7761b45f8ab27508bc | Прокат велосипедов | Как известно, в теплую погоду многие жители крупных городов пользуются сервисами городского велопроката. Вот и Аркадий сегодня будет добираться от школы до дома, используя городские велосипеды.
Школа и дом находятся на одной прямой улице, кроме того, на той же улице есть *n* точек, где можно взять велосипед в прокат и... | {"inputs": ["4 4\n3 6 8 10", "2 9\n10 20", "12 3\n4 6 7 9 10 11 13 15 17 18 20 21", "2 1\n11164 11165", "3 7\n45823 45825 45829", "2 100000\n0 100000", "50 15001\n1269 1580 5431 5916 6642 14145 15760 19922 20589 22062 24138 33454 33505 35916 37012 42577 43140 49457 54720 55188 56205 56639 56870 57997 58379 59088 59297 ... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 103 | codeforces | Okay, let's see. So the problem is about Arkady trying to get from his school to his home using bike rentals. The school is at the first bike point, home at the last. The key is that each bike can be ridden for at most k kilometers. We need to find the minimal number of bike rentals he needs, or return -1 if it's impos... | To solve this problem, we need to determine if Arkady can travel from his school (located at the first bike rental point) to his home (located at the last bike rental point) using the available bike rentals, and if so, find the minimum number of bike rentals required. Each bike can be ridden for a maximum of `k` kilome... | true | ||
b9ea26d8fd625c2e46bc6f4fbe356598 | George and Round | George decided to prepare a Codesecrof round, so he has prepared *m* problems for the round. Let's number the problems with integers 1 through *m*. George estimates the *i*-th problem's complexity by integer *b**i*.
To make the round good, he needs to put at least *n* problems there. Besides, he needs to have at least... | {"inputs": ["3 5\n1 2 3\n1 2 2 3 3", "3 5\n1 2 3\n1 1 1 1 1", "3 1\n2 3 4\n1", "29 100\n20 32 41 67 72 155 331 382 399 412 465 470 484 511 515 529 616 637 679 715 733 763 826 843 862 903 925 979 989\n15 15 15 17 18 19 19 20 21 21 22 24 25 26 26 27 28 31 32 32 37 38 38 39 39 40 41 42 43 43 45 45 46 47 49 49 50 50 50 51 ... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 225 | codeforces | Okay, let's tackle this problem. Hmm, so the problem is about George needing to create a good round for Codesecrof. He has m prepared problems, each with a certain complexity. But he needs at least n problems in the round, each of which must have exactly the complexities a1, a2, ..., an. And he can simplify existing pr... | To solve this problem, we need to determine the minimum number of additional problems George needs to create to ensure he can form a good round for Codesecrof. The key insight is to efficiently use the existing problems by simplifying them to meet the required complexities if possible.
### Approach
1. **Problem Analys... | true | ||
b9ec62d47e98670266215b759dd020f0 | Sagheer and Nubian Market | On his trip to Luxor and Aswan, Sagheer went to a Nubian market to buy some souvenirs for his friends and relatives. The market has some strange rules. It contains *n* different items numbered from 1 to *n*. The *i*-th item has base cost *a**i* Egyptian pounds. If Sagheer buys *k* items with indices *x*1,<=*x*2,<=...,<... | {"inputs": ["3 11\n2 3 5", "4 100\n1 2 5 6", "1 7\n7", "1 7\n5", "1 1\n1", "4 33\n4 3 2 1", "86 96\n89 48 14 55 5 35 7 79 49 70 74 18 64 63 35 93 63 97 90 77 33 11 100 75 60 99 54 38 3 6 55 1 7 64 56 90 21 76 35 16 61 78 38 78 93 21 89 1 58 53 34 77 56 37 46 59 30 5 85 1 52 87 84 99 97 9 15 66 29 60 17 16 59 23 88 93 3... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 135 | codeforces | Okay, let's see. The problem is about Sagheer buying souvenirs with certain cost calculations. The goal is to find the maximum number of items he can buy without exceeding his budget S. And if there are multiple ways to buy that maximum number, we need to choose the one with the minimal total cost.
Hmm, the cost calcu... | To solve this problem, we need to determine the maximum number of souvenirs Sagheer can buy without exceeding his budget, while minimizing the total cost if there are multiple ways to buy the maximum number of souvenirs.
### Approach
1. **Problem Analysis**:
- Each souvenir has a base cost and an additional cost th... | true | ||
b9ffc730bfcf1d8951e5290a7cc2ca24 | Divisibility by 25 | You are given an integer $n$ from $1$ to $10^{18}$ without leading zeroes.
In one move you can swap any two adjacent digits in the given number in such a way that the resulting number will not contain leading zeroes. In other words, after each move the number you have cannot contain any leading zeroes.
What is the mi... | {"inputs": ["5071", "705", "1241367", "7501", "507", "17010", "52231", "50267", "574196831896431419", "1", "10", "123456123450", "1000000000000000000", "100000000000762582", "123456789987654321", "213716413141380147", "5284691", "750000000000000001", "101", "275257725752725722", "50932", "50272", "25", "52", "57", "75"... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 4 | codeforces | Okay, I need to solve this problem where I have to find the minimum number of adjacent swaps to turn a given number into one divisible by 25. If it's impossible, return -1. Let's think about how to approach this.
Hmm, numbers divisible by 25 must end with specific two-digit combinations. Those combinations are 00, 25,... | To solve this problem, we need to determine the minimum number of adjacent swaps required to transform a given number into one that is divisible by 25. If it is impossible, we return -1. A number is divisible by 25 if its last two digits form one of the pairs: 00, 25, 50, or 75.
### Approach
1. **Identify Valid Ending... | false | Code is incorrect. | |
ba27c1ae25a9c6f3a632edc8ad96ab06 | none | Santa Claus has Robot which lives on the infinite grid and can move along its lines. He can also, having a sequence of *m* points *p*1,<=*p*2,<=...,<=*p**m* with integer coordinates, do the following: denote its initial location by *p*0. First, the robot will move from *p*0 to *p*1 along one of the shortest paths betwe... | {"inputs": ["4\nRURD", "6\nRRULDD", "26\nRRRULURURUULULLLDLDDRDRDLD", "3\nRLL", "4\nLRLR", "5\nLRDLR", "10\nDDRDUULUDD", "1\nD"], "outputs": ["2", "2", "7", "2", "4", "4", "3", "1"]} | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 107 | codeforces | Okay, let's see. I need to find the minimum possible length of the sequence of points that the robot followed based on its movement protocol. The movements are given as a string of directions, and each segment is a unit move. The key here is that between consecutive points in the sequence, the robot takes a shortest pa... | To solve this problem, we need to determine the minimum possible length of the sequence of points that a robot followed based on its movement protocol. The robot moves along the shortest path between consecutive points in the sequence, and our goal is to split the given movement into the fewest possible segments where ... | true | ||
ba4d78b29a18d60849c1647760ddd911 | Arpa and a game with Mojtaba | Mojtaba and Arpa are playing a game. They have a list of *n* numbers in the game.
In a player's turn, he chooses a number *p**k* (where *p* is a prime number and *k* is a positive integer) such that *p**k* divides at least one number in the list. For each number in the list divisible by *p**k*, call it *x*, the player... | {"inputs": ["4\n1 1 1 1", "4\n1 1 17 17", "4\n1 1 17 289", "5\n1 2 3 4 5", "10\n10 14 16 9 17 13 12 4 6 10", "10\n13 13 18 3 8 9 19 12 20 14", "10\n10 18 16 10 8 20 8 4 4 2", "10\n1 4 15 1 16 14 7 17 11 8", "10\n9 19 4 1 20 7 19 18 11 11", "100\n80 35 113 179 195 92 143 152 125 55 68 121 71 147 172 153 87 68 143 133 32... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 1 | codeforces | Okay, let's try to solve this problem. The problem is about a game between two players where they take turns making moves based on certain rules, and we need to determine who will win if both play optimally. Hmm, the key here is to model the game using combinatorial game theory concepts like Grundy numbers or Nimbers. ... | To solve this problem, we need to determine the winner of a game played by Mojtaba and Arpa using a list of numbers. The game involves selecting a prime power that divides at least one number in the list and replacing each divisible number by the quotient of the number divided by the prime power. The player who cannot ... | true | ||
ba5f27a8af10e0175f956f2fcf748134 | Grandma Laura and Apples | Grandma Laura came to the market to sell some apples. During the day she sold all the apples she had. But grandma is old, so she forgot how many apples she had brought to the market.
She precisely remembers she had *n* buyers and each of them bought exactly half of the apples she had at the moment of the purchase and ... | {"inputs": ["2 10\nhalf\nhalfplus", "3 10\nhalfplus\nhalfplus\nhalfplus", "10 328\nhalf\nhalfplus\nhalfplus\nhalf\nhalfplus\nhalf\nhalf\nhalf\nhalfplus\nhalfplus", "1 2\nhalfplus", "5 6\nhalf\nhalf\nhalfplus\nhalf\nhalfplus", "10 2\nhalfplus\nhalfplus\nhalfplus\nhalf\nhalfplus\nhalf\nhalfplus\nhalf\nhalfplus\nhalfplus"... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 80 | codeforces | Okay, let's see. I need to solve this problem where Grandma Laura sold apples to n buyers, and I have to calculate the total money she should have. The input gives the number of buyers and the price per apple, and then for each buyer, whether she gave a half apple as a gift. The output is the total money, which depends... | To solve this problem, we need to determine the total money Grandma Laura should have earned from selling apples to her buyers. Each buyer either bought half of the apples she had or bought half plus an additional half apple as a gift if the number of apples was odd. The challenge is to reverse-engineer the initial num... | true | ||
ba60028702652ff2df427b79f2f6558d | Functions again | Something happened in Uzhlyandia again... There are riots on the streets... Famous Uzhlyandian superheroes Shean the Sheep and Stas the Giraffe were called in order to save the situation. Upon the arriving, they found that citizens are worried about maximum values of the Main Uzhlyandian Function *f*, which is defined ... | {"inputs": ["5\n1 4 2 3 1", "4\n1 5 4 7", "8\n16 14 12 10 8 100 50 0", "2\n1 1", "50\n-5 -9 0 44 -10 37 34 -49 11 -22 -26 44 8 -13 23 -46 34 12 -24 2 -40 -15 -28 38 -40 -42 -42 7 -43 5 2 -11 10 43 9 49 -13 36 2 24 46 50 -15 -26 -6 -6 8 4 -44 -3", "100\n23 64 60 -45 -36 -64 -59 15 -75 69 -30 -7 -20 17 -77 58 93 -76 -98 ... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 112 | codeforces | Okay, let's try to figure out how to solve this problem. So the problem is about finding the maximum value of a function f(l, r) for a given array. The function f is defined as the absolute difference between the sum of elements in the first part (from l to m) and the sum in the second part (from m+1 to r), where m is ... | To solve this problem, we need to determine the maximum value of the function \( f(l, r) \) defined as the absolute difference between the sum of two subarrays split at the midpoint \( m \) of the segment \([l, r]\). The midpoint \( m \) is calculated as \((l + r - 1) // 2\). Given the constraints, a direct approach ch... | false | Code is incorrect. | |
baddb954f5f204cdf827de7b355fa03f | Dima and Lisa | Dima loves representing an odd number as the sum of multiple primes, and Lisa loves it when there are at most three primes. Help them to represent the given number as the sum of at most than three primes.
More formally, you are given an odd numer *n*. Find a set of numbers *p**i* (1<=≤<=*i*<=≤<=*k*), such that
1. 1<=... | {"inputs": ["27", "3", "25", "9", "91", "57", "31", "555", "700000001", "5", "7", "11", "13", "15", "17", "19", "21", "23", "29", "79", "99", "27", "55", "79", "585", "245", "793", "133", "681", "981399", "867773", "654141", "202985", "784533", "370359", "396831", "492211", "838347", "1098945", "1313565", "1349631", "1... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 9 | codeforces | Okay, let's see. I need to write a Python function that takes an odd number n as input and outputs up to three primes that sum up to n. The sample input was 27, and the output was three primes: 5, 11, 11. So that's 5+11+11=27. Hmm. Right.
First, the problem says that the sum must consist of at most three primes. Since... | To solve this problem, we need to represent an odd number \( n \) as the sum of at most three prime numbers. The solution must be efficient and handle large values of \( n \) up to \( 10^9 \).
### Approach
1. **Check if \( n \) is a Prime**: If \( n \) itself is a prime number, we can directly return \( n \) as the so... | false | Code is incorrect. | |
bafeb7c12c0d4cc7009ce0f7dfa473fc | Bear and Colors | Bear Limak has *n* colored balls, arranged in one long row. Balls are numbered 1 through *n*, from left to right. There are *n* possible colors, also numbered 1 through *n*. The *i*-th ball has color *t**i*.
For a fixed interval (set of consecutive elements) of balls we can define a dominant color. It's a color occurr... | {"inputs": ["4\n1 2 1 2", "3\n1 1 1", "10\n9 1 5 2 9 2 9 2 1 1", "50\n17 13 19 19 19 34 32 24 24 13 34 17 19 19 7 32 19 13 13 30 19 34 34 28 41 24 24 47 22 34 21 21 30 7 22 21 32 19 34 19 34 22 7 28 6 13 19 30 13 30", "150\n28 124 138 71 71 18 78 136 138 93 145 93 18 15 71 47 47 64 18 72 138 72 18 150 7 71 109 149 18 1... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 11 | codeforces | Okay, I need to solve this problem where I have to count the number of intervals where each color is the dominant one. Let me think through this step by step.
First, the problem says that for every possible non-empty interval of the balls, I have to determine the dominant color and then count how many times each color... | To solve this problem, we need to determine the number of intervals where each color is the dominant color. The dominant color of an interval is the color that occurs the most frequently, and in case of a tie, the smallest color number is chosen.
### Approach
1. **Problem Analysis**:
- We need to consider all possi... | true | ||
bb1e3bb6c310b0882dcd8872d6ac76d1 | Games | Manao works on a sports TV. He's spent much time watching the football games of some country. After a while he began to notice different patterns. For example, each team has two sets of uniforms: home uniform and guest uniform. When a team plays a game at home, the players put on the home uniform. When a team plays as ... | {"inputs": ["3\n1 2\n2 4\n3 4", "4\n100 42\n42 100\n5 42\n100 5", "2\n1 2\n1 2", "7\n4 7\n52 55\n16 4\n55 4\n20 99\n3 4\n7 52", "10\n68 42\n1 35\n25 70\n59 79\n65 63\n46 6\n28 82\n92 62\n43 96\n37 28", "30\n10 39\n89 1\n78 58\n75 99\n36 13\n77 50\n6 97\n79 28\n27 52\n56 5\n93 96\n40 21\n33 74\n26 37\n53 59\n98 56\n61 6... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 925 | codeforces | Okay, let's see. I need to solve this programming problem. Let me read the problem statement carefully.
The problem is about football teams and their uniforms. Each team has a home uniform and a guest uniform. When a team plays at home, they wear their home uniform. But there's an exception: if the home team's home un... | To solve this problem, we need to determine how many times a host team will wear their guest uniform during a football championship. This occurs when the home uniform color of the host team matches the guest uniform color of the visiting team.
### Approach
1. **Input Reading**: Read the number of teams and their resp... | true | ||
bb4f21e3fb5d468b2df9010b6f3af889 | Last Chance | Having read half of the book called "Storm and Calm" on the IT lesson, Innocentius was absolutely determined to finish the book on the maths lessons. All was fine until the math teacher Ms. Watkins saw Innocentius reading fiction books instead of solving equations of the fifth degree. As during the last maths class Inn... | {"inputs": ["Abo", "OEIS", "auBAAbeelii", "AaaBRAaaCAaaDAaaBRAaa", "EA", "BBBAABAABAABBBB", "b", "AABAABAABAA", "aaaaaaa", "AAAAAAABBB", "aabaaaaaaaaaaaaaaab", "aaaaabaaaaabaaaaabaaaaabaaaaabaaaaabaaaaabaaaaabaaaaabaaaaabaaaaabaaaaabaaaaabaaaaabaaaaabaaaaabaaaaabaaaaabaaaaabaaaaabaaaaab", "aaaaabaaaaabaaaaabaaaaabaaaaa... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 4 | codeforces | Okay, let's tackle this problem step by step. Hmm, the problem is to find the longest good substring in a given string and count how many times such substrings occur. A good substring is one where the number of vowels is at most twice the number of consonants. So, vowels <= 2 * consonants.
First, I need to understand... | To solve this problem, we need to find the longest substring of a given string where the number of vowels is at most twice the number of consonants. Additionally, we need to count how many such substrings of the maximum length exist.
### Approach
1. **Transform the String**: Convert each vowel in the string to +1 and ... | true | ||
bb53026b93847d7813469885cb9da1cf | Helga Hufflepuff's Cup | Harry, Ron and Hermione have figured out that Helga Hufflepuff's cup is a horcrux. Through her encounter with Bellatrix Lestrange, Hermione came to know that the cup is present in Bellatrix's family vault in Gringott's Wizarding Bank.
The Wizarding bank is in the form of a tree with total *n* vaults where each vault ... | {"inputs": ["4 2\n1 2\n2 3\n1 4\n1 2", "3 3\n1 2\n1 3\n2 1", "3 1\n1 2\n1 3\n1 1", "3 1000000000\n2 3\n3 1\n585430050 9", "4 50000\n2 1\n4 2\n2 3\n42169 9", "15 100000\n9 7\n15 13\n1 13\n14 5\n6 10\n5 12\n4 14\n4 6\n8 3\n8 2\n9 3\n10 15\n11 8\n10 3\n16283 7"], "outputs": ["1", "13", "0", "91592837", "542369366", "77019... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 2 | codeforces | Okay, let's see. The problem is to count the number of ways to assign types to each vault in a tree structure such that certain conditions are met. Let's break down the problem step by step.
First, the conditions are:
1. All vaults of type k are the highest security. So any vault with type k must be part of the highe... | To solve this problem, we need to determine the number of valid ways to assign types to vaults in a tree structure such that the highest security vaults (type `k`) form an independent set with at most `x` elements, and adjacent vaults to these highest security vaults have types less than `k`.
### Approach
1. **Tree St... | false | Code is incorrect. | |
bb6533d1cf6db1f3d3ef4bc882371c7c | none | An expedition group flew from planet ACM-1 to Earth in order to study the bipedal species (its representatives don't even have antennas on their heads!).
The flying saucer, on which the brave pioneers set off, consists of three sections. These sections are connected by a chain: the 1-st section is adjacent only to the... | {"inputs": ["1 10", "3 8", "8 12", "4 84", "9 95", "331358794 820674098", "5 56", "10 22", "8 73", "7 63", "1 57", "6 5", "6 25", "1 39", "3 60", "2 81", "5 35", "8 100", "6 29", "7 90", "1 37", "7 34", "3 49", "1 38", "7 88", "9 30", "333734901 647005907", "140068687 419634856", "725891944 969448805", "792362041 42349... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 24 | codeforces | Okay, so I need to find the minimal time required for all n aliens to move from section 3 to section 1. The movement rules are a bit tricky. Let me try to understand the problem step by step.
First, the setup: the saucer has three sections connected in a chain. Section 1 is connected to 2, 2 to 1 and 3, 3 to 2. All al... | To solve this problem, we need to determine the minimum time required for all aliens to move from the 3rd section to the 1st section of the spacecraft, following specific movement rules. The solution involves recognizing a pattern in the movement steps, which can be derived using modular arithmetic and efficient comput... | true | ||
bb658a7df66938411259566bbf53ad8e | Links and Pearls | A necklace can be described as a string of links ('-') and pearls ('o'), with the last link or pearl connected to the first one.
You can remove a link or a pearl and insert it between two other existing links or pearls (or between a link and a pearl) on the necklace. This process can be repeated as many times as you l... | {"inputs": ["-o-o--", "-o---", "-o---o-", "ooo", "---", "--o-o-----o----o--oo-o-----ooo-oo---o--", "-o--o-oo---o-o-o--o-o----oo------oo-----o----o-o-o--oo-o--o---o--o----------o---o-o-oo---o--o-oo-o--", "-ooo--", "---o--", "oo-ooo", "------o-o--o-----o--", "--o---o----------o----o----------o--o-o-----o-oo---oo--oo---o-... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 216 | codeforces | Okay, I need to solve this problem where I have to determine if a given necklace (represented as a string of 'o's and '-'s) can be rearranged such that the number of links between every two adjacent pearls is equal. Let's think through this step by step.
First, let's understand the problem. The necklace is circular. W... | To solve this problem, we need to determine if a given necklace (represented as a string of 'o's for pearls and '-' for links) can be rearranged such that the number of links between every pair of adjacent pearls is equal. The solution must consider the circular nature of the necklace and the requirement that all parts... | false | Code is incorrect. | |
bb6f8901c7e3ad27813fe9d022d7ed4d | Water The Garden | It is winter now, and Max decided it's about time he watered the garden.
The garden can be represented as *n* consecutive garden beds, numbered from 1 to *n*. *k* beds contain water taps (*i*-th tap is located in the bed *x**i*), which, if turned on, start delivering water to neighbouring beds. If the tap on the bed *... | {"inputs": ["3\n5 1\n3\n3 3\n1 2 3\n4 1\n1", "26\n1 1\n1\n2 1\n2\n2 1\n1\n2 2\n1 2\n3 1\n3\n3 1\n2\n3 2\n2 3\n3 1\n1\n3 2\n1 3\n3 2\n1 2\n3 3\n1 2 3\n4 1\n4\n4 1\n3\n4 2\n3 4\n4 1\n2\n4 2\n2 4\n4 2\n2 3\n4 3\n2 3 4\n4 1\n1\n4 2\n1 4\n4 2\n1 3\n4 3\n1 3 4\n4 2\n1 2\n4 3\n1 2 4\n4 3\n1 2 3\n4 4\n1 2 3 4", "31\n5 1\n5\n5 ... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 132 | codeforces | Okay, let's see. So the problem is about watering a garden with some taps, and we need to find the minimum time after which all the garden beds are watered. Hmm. Let's think through this step by step.
First, the garden has n beds arranged in a line. Each tap, when turned on, starts spreading water to neighboring beds ... | To solve this problem, we need to determine the minimum number of seconds required to water all garden beds after turning on all the water taps simultaneously. The water from each tap spreads outwards incrementally each second, and we need to ensure that the entire garden is covered by the combined spread from all taps... | true | ||
bb71d6ab1355a5ce318f88adc38bf033 | Little Xor | Little Petya likes arrays that consist of non-negative integers a lot. Recently his mom has presented him one such array consisting of *n* elements. Petya immediately decided to find there a segment of consecutive elements, such that the *xor* of all numbers from this segment was maximal possible. Help him with that.
... | {"inputs": ["5\n1 2 1 1 2", "3\n1 2 7", "4\n4 2 4 8", "5\n1 1 1 1 1", "16\n0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15", "20\n1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10", "100\n28 20 67 103 72 81 82 83 7 109 122 30 50 118 83 89 108 82 92 17 97 3 62 12 9 100 14 11 99 106 10 8 60 101 88 119 104 62 76 6 5 57 32 94 60 50 58 97 1 ... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 71 | codeforces | Okay, so I need to solve this problem where I have to find the maximum XOR of a consecutive subarray in a given array of non-negative integers. Let me think about how to approach this.
First, let's understand the problem. The task is to compute the maximum possible XOR value of any contiguous subarray. The XOR of a su... | To solve this problem, we need to find the maximum XOR value of any contiguous subarray in a given array of non-negative integers. The XOR operation is a bitwise exclusive "OR", which can be efficiently computed using a prefix XOR array approach.
### Approach
1. **Prefix XOR Array**: Compute a prefix XOR array where e... | true | ||
bb883e074b47c2bd5d1d4f497d9eb006 | Inversions problem | You are given a permutation of *n* numbers *p*1,<=*p*2,<=...,<=*p**n*. We perform *k* operations of the following type: choose uniformly at random two indices *l* and *r* (*l*<=≤<=*r*) and reverse the order of the elements *p**l*,<=*p**l*<=+<=1,<=...,<=*p**r*. Your task is to find the expected value of the number of in... | {"inputs": ["3 1\n1 2 3", "3 4\n1 3 2", "6 1\n4 2 5 1 3 6", "6 2\n1 4 6 5 2 3", "4 4\n2 3 1 4", "4 1\n3 4 2 1", "4 3\n3 1 2 4", "4 4\n4 2 3 1", "4 1\n1 2 4 3", "5 4\n4 3 2 5 1", "5 2\n3 1 2 5 4", "5 1\n3 5 1 2 4", "6 1\n5 2 3 4 1 6", "5 2\n4 3 2 1 5", "6 1\n5 3 4 6 2 1", "6 4\n1 2 3 4 5 6", "6 4\n6 5 4 3 2 1", "1 1\n1"... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 9 | codeforces | Okay, I need to solve this problem where I have to compute the expected number of inversions after k random reverse operations on a permutation. Hmm, let's think about how to approach this.
First, understanding the problem: Each operation involves selecting a random interval [l, r] (with l <= r) and reversing the elem... | To solve this problem, we need to compute the expected number of inversions in a permutation after performing a series of random reversal operations. The solution leverages the linearity of expectation and probability theory to efficiently handle the problem constraints.
### Approach
1. **Linearity of Expectation**: I... | false | Code is incorrect. | |
bbd37e23be19f61cce43427551e0e712 | The Same Calendar | The girl Taylor has a beautiful calendar for the year *y*. In the calendar all days are given with their days of week: Monday, Tuesday, Wednesday, Thursday, Friday, Saturday and Sunday.
The calendar is so beautiful that she wants to know what is the next year after *y* when the calendar will be exactly the same. Help ... | {"inputs": ["2016", "2000", "50501", "1000", "1900", "1899", "99999", "50000", "99900", "12345", "1004", "2100", "1313", "1872", "2098", "2072", "2002", "1179", "2096", "1096", "1796", "2014", "2006", "1874", "1884", "2342", "2010", "2097", "1072", "1191", "2896", "1797", "1002", "99988", "1788", "1994", "5094", "99996... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 43 | codeforces | Okay, let's see. I need to find the next year after a given year y where the calendar will be exactly the same. So the problem is about determining when the days of the week align again, considering leap years and the number of days each year contributes.
First, I should understand what makes two years have the same c... | To solve this problem, we need to determine the next year after a given year `y` where the calendar will be exactly the same. This means the target year must start on the same day of the week as `y` and have the same leap year status.
### Approach
1. **Leap Year Check**: Determine if the given year `y` is a leap year.... | true | ||
bbda5083b762ef3b2b0b127c37da519c | Jumping Jack | Jack is working on his jumping skills recently. Currently he's located at point zero of the number line. He would like to get to the point *x*. In order to train, he has decided that he'll first jump by only one unit, and each subsequent jump will be exactly one longer than the previous one. He can go either left or ri... | {"inputs": ["2", "6", "0", "-1000000000", "999961560", "999961561", "999961559", "-488979819", "-865918189", "-278253406", "-87275307", "103702792", "294680891", "485658989", "676637088", "867615187", "-941406715", "-897912263", "-706934164", "-790244010", "16417015", "823078041", "-517744582", "288916443", "-904422532... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 61 | codeforces | Okay, I need to solve this problem where Jack jumps on a number line. The goal is to find the minimal number of jumps he needs to reach a certain point x. Let me think through how to approach this.
So the problem says Jack starts at 0. Each jump starts with length 1, and each subsequent jump increases by 1. He can jum... | To solve this problem, we need to determine the minimal number of jumps Jack requires to reach a specific point on a number line, starting from zero. Each subsequent jump is longer than the previous one by exactly one unit, and Jack can jump in either direction (left or right).
### Approach
1. **Understanding the Prob... | true | ||
bbfbef8cfdb66fcb1844230b423e42e2 | XOR and OR | The Bitlandians are quite weird people. They do everything differently. They have a different alphabet so they have a different definition for a string.
A Bitlandish string is a string made only of characters "0" and "1".
BitHaval (the mayor of Bitland) loves to play with Bitlandish strings. He takes some Bitlandish ... | {"inputs": ["11\n10", "1\n01", "000\n101", "1101\n1111", "11000001\n00000001", "01\n10", "0000\n1110", "010101\n101010", "0\n1", "1\n1", "0\n0", "1\n0", "100\n11111", "1000000000000000000000000000000000000011111111000000000000\n0111111111100000000000111111111000000000000000111111110001", "000000000000000000000000000000... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 2 | codeforces | Okay, I need to solve this problem where I have to determine if one Bitlandish string can be transformed into another using specific operations. Let me read the problem statement carefully.
The operation allowed is taking two adjacent characters x and y, compute p = x XOR y and q = x OR y. Then replace one of them wit... | To solve this problem, we need to determine if one Bitlandish string can be transformed into another using specific operations. The operations involve replacing two adjacent characters with their XOR and OR results. The key insight is to recognize the necessary conditions for transformation based on the presence of '1'... | true | ||
bc032e5d3c2c75050a8a48f992de8d6e | Fibonacci Sums | Fibonacci numbers have the following form:
Let's consider some non-empty set *S*<==<={*s*1,<=*s*2,<=...,<=*s**k*}, consisting of different Fibonacci numbers. Let's find the sum of values of this set's elements:
Let's call the set *S* a number *n*'s decomposition into Fibonacci sum.
It's easy to see that several num... | {"inputs": ["2\n13\n16", "10\n1\n2\n3\n4\n5\n6\n7\n8\n9\n10", "10\n24\n37\n42\n58\n60\n73\n79\n84\n92\n99", "5\n484775665757\n968685776575\n687675666422\n348587665784\n373875686864", "1\n123456789101112", "22\n304056783818718320\n491974210728665289\n187917426909946968\n796030994547383610\n912170329762608884\n9839524503... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 1 | codeforces | Okay, let's see. The problem is to find the number of different decompositions of a given number n into a sum of distinct Fibonacci numbers. The Fibonacci sequence here is the standard one, right? Like 1, 2, 3, 5, 8, 13, etc., where each number is the sum of the two before it. Wait, wait, wait—wait, wait. Wait, the sta... | To solve this problem, we need to determine the number of distinct decompositions of a given number \( n \) into sums of distinct Fibonacci numbers. The solution involves generating all possible Fibonacci numbers up to \( n \) and using dynamic programming to count the valid decompositions.
### Approach
1. **Generate ... | true | ||
bc4528d68579e1604b5cfcbe0e276380 | Candies | After passing a test, Vasya got himself a box of $n$ candies. He decided to eat an equal amount of candies each morning until there are no more candies. However, Petya also noticed the box and decided to get some candies for himself.
This means the process of eating candies is the following: in the beginning Vasya cho... | {"inputs": ["68", "1", "2", "42", "43", "756", "999999972", "999999973", "1000000000000000000", "6", "3", "4", "5", "66", "67", "1000", "10000", "100500", "1000000", "10000000", "100000000", "123456789", "543212345", "505050505", "777777777", "888888871", "1000000000", "999999999999999973", "999999999999999998", "99999... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 56 | codeforces | Okay, let's tackle this problem. Hmm, the task is to find the minimal k such that Vasya eats at least half of the initial n candies. So, given n, we need to compute the smallest k where Vasya's total is >= n/2.
Let me understand the process step by step. Each day, Vasya eats k candies in the morning. If there are les... | To solve this problem, we need to determine the minimal integer value of \( k \) such that Vasya can eat at least half of the initial candies \( n \) in the box, considering that Petya eats 10% of the remaining candies each evening. The solution involves simulating the process for different values of \( k \) and using ... | true | ||
bc613d8c5d133aa3218104a12bd2c957 | Ant colony | Mole is hungry again. He found one ant colony, consisting of *n* ants, ordered in a row. Each ant *i* (1<=≤<=*i*<=≤<=*n*) has a strength *s**i*.
In order to make his dinner more interesting, Mole organizes a version of «Hunger Games» for the ants. He chooses two numbers *l* and *r* (1<=≤<=*l*<=≤<=*r*<=≤<=*n*) and each... | {"inputs": ["5\n1 3 2 4 2\n4\n1 5\n2 5\n3 5\n4 5"], "outputs": ["4\n4\n1\n1"]} | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 3 | codeforces | Okay, I need to solve this problem where for each query [l, r], I have to determine how many ants Mole eats. The key here is to find the number of ants in the segment [l, r] that do NOT meet the condition v_i <= (r - l). Wait, no. Wait, the problem says that an ant is freed only if v_i is less than or equal to (r - l).... | To solve this problem, we need to determine how many ants Mole will eat for each query segment. An ant is freed if it gains a battle point in every fight it participates in, which translates to the ant's strength dividing the strengths of all other ants in the segment.
### Approach
1. **Segment Tree for GCD Queries**... | true | ||
bc64e74229636684b4bed21608cbda11 | Billiard | Consider a [billiard table](https://en.wikipedia.org/wiki/Billiard_table) of rectangular size $n \times m$ with four pockets. Let's introduce a coordinate system with the origin at the lower left corner (see the picture).
There is one ball at the point $(x, y)$ currently. Max comes to the table and strikes the ball. ... | {"inputs": ["4 3 2 2 -1 1", "4 4 2 0 1 1", "10 10 10 1 -1 0", "1000000000 1000000000 1 1000000000 0 1", "2 1 1 0 -1 -1", "4 2 1 2 1 1", "5 3 4 3 1 -1", "15 9 1 1 1 1", "15 9 1 1 -1 -1", "15 9 2 1 1 1", "15 9 2 1 -1 1", "1000000000 999999999 999999998 999999999 -1 -1", "1000000000 999999999 999999998 999999999 -1 1", "1... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 5 | codeforces | Okay, so I need to solve this billiard table problem where the ball is moving in certain directions and I have to find out which pocket it ends up in, or -1 if it never does. Let's see.
The problem says that the ball moves in a direction that's either parallel to the axes or at a 45-degree angle. Wait, wait, the initi... | To solve this problem, we need to determine whether a ball on a billiard table will eventually fall into one of the four pockets and, if so, which pocket it will be. The ball moves either parallel to the axes or at a 45-degree angle, reflecting off the table's edges. The solution involves analyzing the ball's trajector... | true | ||
bc675e3dd359f3855d27c61fbbe05bb0 | Bear and Strings | The bear has a string *s*<==<=*s*1*s*2... *s*|*s*| (record |*s*| is the string's length), consisting of lowercase English letters. The bear wants to count the number of such pairs of indices *i*,<=*j* (1<=≤<=*i*<=≤<=*j*<=≤<=|*s*|), that string *x*(*i*,<=*j*)<==<=*s**i**s**i*<=+<=1... *s**j* contains at least one string... | {"inputs": ["bearbtear", "bearaabearc", "pbearbearhbearzqbearjkterasjhy", "pbearjbearbebearnbabcffbearbearwubearjezpiorrbearbearjbdlbearbearqbearjbearwipmsbearoaftrsebearzsnqb", "bear", "a", "be"], "outputs": ["6", "20", "291", "4419", "1", "0", "0"]} | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 145 | codeforces | Okay, so I need to solve this problem where I have to count the number of pairs (i,j) such that the substring from i to j contains "bear" as a substring. Hmm, let's think about how to approach this.
First, the problem is to count all possible substrings that have at least one occurrence of "bear". But checking every p... | To solve this problem, we need to count the number of substrings of a given string that contain the substring "bear" at least once. The solution involves efficiently determining the valid substrings using preprocessing and binary search to optimize the computation.
### Approach
1. **Identify Positions of "bear":** Fir... | true | ||
bc6d7c53a34b7bb783f08170fd4f3ffb | Subsequences | For the given sequence with *n* different elements find the number of increasing subsequences with *k*<=+<=1 elements. It is guaranteed that the answer is not greater than 8·1018.
First line contain two integer values *n* and *k* (1<=≤<=*n*<=≤<=105,<=0<=≤<=*k*<=≤<=10) — the length of sequence and the number of elements... | {"inputs": ["5 2\n1\n2\n3\n5\n4", "1 0\n1", "2 1\n1\n2", "2 1\n2\n1", "3 2\n1\n2\n3", "3 1\n1\n3\n2", "3 1\n2\n1\n3", "3 1\n2\n3\n1", "3 1\n3\n1\n2", "3 2\n3\n2\n1", "10 2\n6\n10\n9\n7\n1\n2\n8\n5\n4\n3", "100 7\n1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17\n18\n19\n20\n21\n22\n23\n24\n25\n26\n27\n28\n29\n... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 6 | codeforces | Okay, let's see. The problem is to find the number of increasing subsequences with at least k elements. Wait, no, the description says "k <=+<=1 elements". Wait, maybe that's a typo. Oh right, probably the problem is to find increasing subsequences with length exactly k. Or wait, maybe the original problem statement ha... | To solve this problem, we need to count the number of strictly increasing subsequences of length exactly \( k+1 \) in a given sequence of \( n \) distinct elements. The solution involves using dynamic programming (DP) combined with Fenwick Trees (Binary Indexed Trees) for efficient computation.
### Approach
1. **Coord... | true | ||
bc958cdf56381e768a6fa20968b74312 | Congruence Equation | Given an integer $x$. Your task is to find out how many positive integers $n$ ($1 \leq n \leq x$) satisfy $$n \cdot a^n \equiv b \quad (\textrm{mod}\;p),$$ where $a, b, p$ are all known constants.
The only line contains four integers $a,b,p,x$ ($2 \leq p \leq 10^6+3$, $1 \leq a,b < p$, $1 \leq x \leq 10^{12}$). It i... | {"inputs": ["2 3 5 8", "4 6 7 13", "233 233 10007 1", "338792 190248 339821 152634074578", "629260 663548 739463 321804928248", "656229 20757 818339 523535590429", "1000002 1000002 1000003 1000000000000", "345 2746 1000003 5000000", "802942 824238 836833 605503824329", "1 1 2 880336470888", "2 2 3 291982585081", "69960... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 3 | codeforces | Okay, let's tackle this problem. So, we need to find the number of positive integers n up to x that satisfy the congruence equation n * a^n ≡ b mod p. The inputs are a, b, p, x. And p is a prime. Hmm.
First, I remember that when dealing with exponents modulo primes, Fermat's little theorem might be useful. Since p is ... | To solve this problem, we need to determine how many positive integers \( n \) (where \( 1 \leq n \leq x \)) satisfy the congruence equation \( n \cdot a^n \equiv b \ (\text{mod} \ p) \) given constants \( a, b, p, x \). The solution leverages properties of modular arithmetic and the Chinese Remainder Theorem (CRT) to ... | true | ||
bcbdca7bed3cf5b0c900d268a0fbb27e | Casinos and travel | John has just bought a new car and is planning a journey around the country. Country has *N* cities, some of which are connected by bidirectional roads. There are *N*<=-<=1 roads and every city is reachable from any other city. Cities are labeled from 1 to *N*.
John first has to select from which city he will start hi... | {"inputs": ["2\n1 2", "3\n1 2\n2 3", "4\n1 2\n2 3\n3 4"], "outputs": ["4", "10", "24"]} | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 6 | codeforces | Okay, let's try to understand this problem. Hmm. So, the problem is about John traveling through cities connected in a tree structure (since there are N cities and N-1 roads, and it's connected). Jack needs to choose a starting city for John and decide which cities have casinos such that no matter how John travels (whi... | To solve this problem, we need to determine the number of valid ways Jack can select a starting city and cities with casinos such that John ends his journey in a good mood, regardless of the path he takes. The solution involves understanding the tree structure of the cities and leveraging properties of leaves in the tr... | true | ||
bcbfe74a23a31ba03505e0c77eeef23c | Alena And The Heater | "We've tried solitary confinement, waterboarding and listening to Just In Beaver, to no avail. We need something extreme."
"Little Alena got an array as a birthday present..."
The array *b* of length *n* is obtained from the array *a* of length *n* and two integers *l* and *r* (*l*<=≤<=*r*) using the following proced... | {"inputs": ["5\n1 2 3 4 5\n00001", "10\n-10 -9 -8 -7 -6 6 7 8 9 10\n0000111110", "10\n-8 -9 -9 -7 -10 -10 -8 -8 -9 -10\n0000000011", "11\n226 226 226 226 226 227 1000000000 1000000000 228 1000000000 1000000000\n00001111110", "95\n-97 -98 -92 -93 94 96 91 98 95 85 90 86 84 83 81 79 82 79 73 -99 -91 -93 -92 -97 -85 -88 -... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 23 | codeforces | Okay, let's see. I need to find l and r such that when I apply the given algorithm to array a with these l and r, the resulting b array matches the given b'. The problem says that an answer exists, so I don't have to worry about no solution cases.
First, I need to understand the algorithm for generating b from a, l, a... | To solve this problem, we need to determine two integers, `l` and `r`, such that applying a specific algorithm to an array `a` with these integers results in an array `b` that matches the given array `b'`. The algorithm for generating `b` from `a`, `l`, and `r` involves checking conditions on the previous four elements... | false | Code is incorrect. | |
bcc97263183979d209e5ab6a23185300 | Field expansion | In one of the games Arkady is fond of the game process happens on a rectangular field. In the game process Arkady can buy extensions for his field, each extension enlarges one of the field sizes in a particular number of times. Formally, there are *n* extensions, the *i*-th of them multiplies the width or the length (b... | {"inputs": ["3 3 2 4 4\n2 5 4 10", "3 3 3 3 5\n2 3 5 4 2", "5 5 1 2 3\n2 2 3", "3 4 1 1 3\n2 3 2", "572 540 6 2 12\n2 3 2 2 2 3 3 3 2 2 2 2", "375 905 1 1 17\n2 2 3 3 3 3 3 3 2 2 2 2 3 2 2 2 3", "37 23 4 1 16\n2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2", "20 19 6 8 18\n3 4 2 3 4 3 2 4 2 2 4 2 4 3 2 4 4 2", "11 11 5 3 11\n4 4 2 4 ... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 1 | codeforces | Okay, I need to solve this programming problem. Let me read the problem statement carefully.
The problem is about Arkady's game field. The initial field has dimensions h × w. He can use extensions which multiply either the width or the length by a_i. Each extension can be used once, in any order. The goal is to determ... | To solve this problem, we need to determine the minimum number of extensions required for Arkady's game field to fit a rectangle of given dimensions. The extensions can be applied to either the width or the length of the field, and each extension can be used only once. The goal is to find the optimal way to use the ext... | true | ||
bcce2d002f657ac7dccfcbef1ce7137d | Average Numbers | You are given a sequence of positive integers *a*1,<=*a*2,<=...,<=*a**n*. Find all such indices *i*, that the *i*-th element equals the arithmetic mean of all other elements (that is all elements except for this one).
The first line contains the integer *n* (2<=≤<=*n*<=≤<=2·105). The second line contains elements of th... | {"inputs": ["5\n1 2 3 4 5", "4\n50 50 50 50", "3\n2 3 1", "2\n4 2", "2\n1 1", "10\n3 3 3 3 3 4 3 3 3 2", "10\n15 7 10 7 7 7 4 4 7 2", "6\n2 2 2 2 2 2", "6\n3 3 3 3 3 3", "4\n6 6 6 7", "2\n1 2", "3\n3 3 4", "5\n7 6 6 6 6", "4\n3 5 5 9", "3\n99 100 99", "4\n5 6 5 5", "6\n1 1 2 1 1 1", "2\n4 5", "4\n1 1 1 2", "3\n1 2 4", ... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 130 | codeforces | Okay, I need to solve this problem where I have to find all indices i in a non-decreasing sequence of integers such that the i-th element is equal to the arithmetic mean of all the other elements. Let's think about how to approach this.
First, let's understand the problem. For each element a_i in the array, we have to... | To solve this problem, we need to find all indices in a non-decreasing sequence of integers where the element at that index is equal to the arithmetic mean of all other elements in the sequence.
### Approach
1. **Sum Calculation**: Calculate the total sum of the sequence.
2. **Check Divisibility**: Determine if the t... | true | ||
bcd6a289c4ca64bddbb3a92d687dfda3 | Sum of Nestings | Recall that the bracket sequence is considered regular if it is possible to insert symbols '+' and '1' into it so that the result is a correct arithmetic expression. For example, a sequence "(()())" is regular, because we can get correct arithmetic expression insering symbols '+' and '1': "((1+1)+(1+1))". Also the foll... | {"inputs": ["3 1", "4 6", "2 5", "1 0", "2 0", "2 1", "3 0", "10 42", "3 2", "3 3", "4 1", "4 2", "4 0", "4 3", "4 4", "4 5", "20 132", "5 0", "5 1", "5 2", "5 3", "5 4", "5 5", "5 6", "5 7", "5 8", "5 9", "5 10", "5 11", "50 282", "100 4298", "201 19557", "301 43259", "333 3286", "400 14432", "500 12169", "1000 101063... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 9 | codeforces | Okay, let's tackle this problem. So, the task is to construct a regular bracket sequence of length 2n where the sum of the nesting of all opening brackets equals exactly k. If it's impossible, we output "Impossible". Hmm.
First, I need to understand what the nesting sum is. The example given was "()(())" where each op... | To solve this problem, we need to construct a regular bracket sequence of length 2n such that the total sum of nesting of all opening brackets equals exactly k. If it's impossible to construct such a sequence, we should return "Impossible".
### Approach
1. **Check Feasibility**: First, we check if the given k is withi... | false | Code is incorrect. | |
bce21ee8b1160c20c0b326ab3867d800 | none | Squirrel Liss lived in a forest peacefully, but unexpected trouble happens. Stones fall from a mountain. Initially Squirrel Liss occupies an interval [0,<=1]. Next, *n* stones will fall and Liss will escape from the stones. The stones are numbered from 1 to *n* in order.
The stones always fall to the center of Liss's ... | {"inputs": ["llrlr", "rrlll", "lrlrr", "lllrlrllrl", "llrlrrrlrr", "rlrrrllrrr", "lrrlrrllrrrrllllllrr", "rlrrrlrrrllrrllrlrll", "lllrrlrlrllrrrrrllrl", "rrrllrrrlllrlllrlrrr", "rrlllrrrlrrlrrrlllrlrlrrrlllrllrrllrllrrlrlrrllllrlrrrrlrlllrlrrrlrlrllrlrlrrlrrllrrrlrlrlllrrllllrl", "llrlrlllrrllrllllrlrrlrlrrllrlrlrrlrrr... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 145 | codeforces | Okay, let's see. The problem is about simulating the positions of stones after each step. Hmm. So, the squirrel Liss starts in the interval [0, 1], and each time a stone falls, she moves left or right, and the stone's position is determined by the center of her previous interval. Wait, the stone falls to the center. So... | To solve this problem, we need to determine the order of stones from left to right after they fall, based on the directions given for each stone. Each stone falls at the center of the current interval, and the interval is adjusted to the left or right based on the direction provided. The goal is to output the stones' n... | true | ||
bcf965fe41db5c767e712d73903ad8b4 | IQ Test | Petya is preparing for IQ test and he has noticed that there many problems like: you are given a sequence, find the next number. Now Petya can solve only problems with arithmetic or geometric progressions.
Arithmetic progression is a sequence *a*1, *a*1<=+<=*d*, *a*1<=+<=2*d*, ..., *a*1<=+<=(*n*<=-<=1)*d*, where *a*1 ... | {"inputs": ["836 624 412 200", "1 334 667 1000", "501 451 400 350", "836 624 412 200", "1 334 667 1000", "11 234 457 680", "640 431 222 13", "1 1 1 1", "1 10 100 1000", "3 18 108 648", "512 384 288 216", "891 297 99 33", "64 160 400 1000", "501 451 400 350", "501 450 400 350", "4 32 48 64", "9 8 7 5", "992 994 998 1000... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 15 | codeforces | Okay, let's tackle this problem. So the task is to determine whether a given sequence of four integers is an arithmetic or geometric progression, then find the next term. If neither, output 42. Also, if the next term isn't an integer in the geometric case, output 42 as well. Hmm.
First, I need to understand the defini... | To solve this problem, we need to determine if a given sequence of four integers forms an arithmetic or geometric progression. If it does, we compute the next term in the sequence. If the sequence is neither, or if the next term in a valid geometric progression is not an integer, we return 42.
### Approach
1. **Check ... | true | ||
bcfaa0ca75d2308244afef49d1cea846 | Eight Point Sets | Gerald is very particular to eight point sets. He thinks that any decent eight point set must consist of all pairwise intersections of three distinct integer vertical straight lines and three distinct integer horizontal straight lines, except for the average of these nine points. In other words, there must be three int... | {"inputs": ["0 0\n0 1\n0 2\n1 0\n1 2\n2 0\n2 1\n2 2", "0 0\n1 0\n2 0\n3 0\n4 0\n5 0\n6 0\n7 0", "1 1\n1 2\n1 3\n2 1\n2 2\n2 3\n3 1\n3 2", "0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0", "1000000 1000000\n1000000 999999\n1000000 999998\n999999 1000000\n999999 999998\n999998 1000000\n999998 999999\n999998 999998", "0 0\n1 0\n0... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 36 | codeforces | Okay, let's see. I need to determine if a given set of eight points fits Gerald's criteria. So Gerald's eight-point set must be formed by three vertical lines and three horizontal lines, all with distinct integer coordinates, and the points are all the intersections except the middle one (x2, y2). Hmm.
First, I need t... | To solve this problem, we need to determine if a given set of eight points conforms to Gerald's specific criteria for an eight-point set. The criteria state that the points must be all pairwise intersections of three distinct vertical lines and three distinct horizontal lines, except for the middle intersection point.
... | true | ||
bd184280a9f5454d5dab9c2732b3319e | Login Verification | When registering in a social network, users are allowed to create their own convenient login to make it easier to share contacts, print it on business cards, etc.
Login is an arbitrary sequence of lower and uppercase latin letters, digits and underline symbols («_»). However, in order to decrease the number of frauds ... | {"inputs": ["1_wat\n2\n2_wat\nwat_1", "000\n3\n00\nooA\noOo", "_i_\n3\n__i_\n_1_\nI", "La0\n3\n2a0\nLa1\n1a0", "abc\n1\naBc", "0Lil\n2\nLIL0\n0Ril", "iloO\n3\niIl0\noIl0\nIooO", "L1il0o1L1\n5\niLLoLL\noOI1Io10il\nIoLLoO\nO01ilOoI\nI10l0o", "ELioO1lOoOIOiLoooi1iolul1O\n7\nOoEIuOIl1ui1010uiooOoi0Oio001L0EoEolO0\nOLIoOEuo... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 193 | codeforces | Okay, I need to solve this problem where I have to check if a new user's login is similar to any existing logins. The similarity is determined by certain transformations. Hmm, let's think about how to approach this.
First, the problem says two logins are similar if one can be transformed into another by a series of th... | To solve this problem, we need to determine if a newly created user login is similar to any existing logins in a social network. Similarity is defined based on specific transformations involving case changes, substitutions between 'O' and '0', and substitutions among '1', 'l', and 'I'.
### Approach
1. **Normalization ... | true | ||
bd2451122914e33f4f8c5309b0ce78a4 | Ralph And His Magic Field | Ralph has a magic field which is divided into *n*<=×<=*m* blocks. That is to say, there are *n* rows and *m* columns on the field. Ralph can put an integer in each block. However, the magic field doesn't always work properly. It works only if the product of integers in each row and each column equals to *k*, where *k* ... | {"inputs": ["1 1 -1", "1 3 1", "3 3 -1", "2 7 1", "1 1 1", "2 4 -1", "173 69 -1", "110 142 1", "162 162 -1", "49 153 -1", "94 182 1", "106666666 233333333 1", "2 2 1", "146 34 -1", "94 86 -1", "2529756051797760 2682355969139391 -1", "3126690179932000 2474382898739836 -1", "3551499873841921 2512677762780671 -1", "361345... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 18 | codeforces | Okay, let's tackle this problem. So, Ralph's magic field requires that the product of each row and each column is k, which can be 1 or -1. We need to find the number of valid ways to fill the grid modulo 1e9+7. Hmm.
First, let's understand the constraints. Each row's product must be k, and each column's product must a... | To solve this problem, we need to determine the number of valid ways to fill an \(n \times m\) grid with integers such that the product of each row and each column equals \(k\), where \(k\) is either 1 or -1. The solution must be returned modulo \(10^9 + 7\).
### Approach
1. **Constraints Analysis**:
- If \(k = -1\... | true | ||
bd3cadf754cab70e6a2d233db4f043b8 | Educational Game | The Smart Beaver from ABBYY began to develop a new educational game for children. The rules of the game are fairly simple and are described below.
The playing field is a sequence of *n* non-negative integers *a**i* numbered from 1 to *n*. The goal of the game is to make numbers *a*1,<=*a*2,<=...,<=*a**k* (i.e. some pr... | {"inputs": ["4\n1 0 1 2", "8\n1 2 3 4 5 6 7 8", "5\n4 1 4 7 6", "9\n13 13 7 11 3 9 3 5 5", "30\n8 17 20 15 18 15 20 10 5 13 5 4 15 9 11 14 18 15 7 16 18 9 17 7 10 9 5 13 17 16", "80\n72 66 82 46 44 22 63 92 71 65 5 30 45 84 29 73 9 90 25 19 26 15 12 29 33 19 85 92 91 66 83 39 100 53 20 99 11 81 26 41 36 51 21 72 28 100... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 76 | codeforces | Okay, I need to solve this programming problem. Let's read the problem statement carefully.
The problem is about a game where we have a sequence of non-negative integers. The goal is to make the first k elements all zero, for each k from 1 to n-1, using the minimum number of moves possible. Each move allows us to sele... | To solve this problem, we need to determine the minimum number of moves required to make the first k elements of a sequence zero for each k from 1 to n-1. Each move allows transferring a value from position i to position i+2t, where t is a non-negative integer.
### Approach
The key insight is to realize that each elem... | false | Code is incorrect. | |
bd4762d12fc7e77b0c0d4de102cb8527 | Toy Cars | Little Susie, thanks to her older brother, likes to play with cars. Today she decided to set up a tournament between them. The process of a tournament is described in the next paragraph.
There are *n* toy cars. Each pair collides. The result of a collision can be one of the following: no car turned over, one car turne... | {"inputs": ["3\n-1 0 0\n0 -1 1\n0 2 -1", "4\n-1 3 3 3\n3 -1 3 3\n3 3 -1 3\n3 3 3 -1", "1\n-1", "2\n-1 0\n0 -1", "2\n-1 1\n2 -1", "2\n-1 2\n1 -1", "2\n-1 3\n3 -1"], "outputs": ["2\n1 3 ", "0", "1\n1 ", "2\n1 2 ", "1\n2 ", "1\n1 ", "0"]} | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 18 | codeforces | Okay, let's see. I need to solve this problem where I have to determine which cars are considered 'good' based on the collision matrix. Hmm. Let me read the problem statement again carefully.
So, a good car is one that turned over in no collision. That means for a car to be good, in every collision it was part of, it ... | To solve this problem, we need to determine which cars are considered "good" based on the results of their collisions. A car is defined as good if it did not turn over in any collision it was involved in. The results of these collisions are provided in a matrix format, where each entry indicates the outcome of a collis... | true | ||
bd5208069eb280e2184f0cb0354c9f46 | Roman Digits | Let's introduce a number system which is based on a roman digits. There are digits I, V, X, L which correspond to the numbers $1$, $5$, $10$ and $50$ respectively. The use of other roman digits is not allowed.
Numbers in this system are written as a sequence of one or more digits. We define the value of the sequence s... | {"inputs": ["1", "2", "10", "1000", "2000", "5000", "10000", "111199", "101232812", "1000000000", "3", "4", "5", "6", "7", "8", "9", "11", "12", "13", "55", "100", "150", "1200", "9999999", "100000000", "500000000", "600000000", "709000900", "999999999", "12", "10", "20", "35", "56", "83", "116", "155", "198", "244", "... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 61 | codeforces | Okay, let's try to figure out how to solve this problem. The problem is about counting the number of distinct integers that can be formed by using exactly n roman digits (I, V, X, L) where each digit contributes its value (1,5,10,50) to the sum. The order doesn't matter here, so it's just a matter of how many times eac... | To solve this problem, we need to determine the number of distinct integers that can be represented using exactly `n` Roman digits (I, V, X, L) where each digit contributes its value (1, 5, 10, 50) to the sum. The solution involves recognizing a mathematical pattern in the possible sums formed by these digits.
### App... | false | Code is incorrect. | |
bd719ab213ef0b26f27fe550275da0a6 | Bishwock | Bishwock is a chess figure that consists of three squares resembling an "L-bar". This figure can be rotated by 90, 180 and 270 degrees so it can have four possible states:
Bishwocks don't attack any squares and can even occupy on the adjacent squares as long as they don't occupy the same square.
Vasya has a board wi... | {"inputs": ["00\n00", "00X00X0XXX0\n0XXX0X00X00", "0X0X0\n0X0X0", "0XXX0\n00000", "0\n0", "0\nX", "X\n0", "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\nXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", "0000X0X... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 64 | codeforces | Okay, let's try to solve this problem. The task is to find the maximum number of bishwocks (which are like L-shaped tetris blocks) that can be placed on a 2xN board, considering that some squares are occupied by pawns (marked with X). The bishwocks can't overlap each other or the pawns.
Hmm, first, I need to understan... | To solve this problem, we need to determine the maximum number of L-shaped bishwocks (each covering three squares) that can be placed on a 2xN chessboard, where some squares are occupied by pawns. The bishwocks cannot overlap each other or occupy squares with pawns.
### Approach
1. **Dynamic Programming (DP) Setup**: ... | true | ||
bd9edbfd06ea3a9c193aa506376798d5 | Queue at the School | During the break the schoolchildren, boys and girls, formed a queue of *n* people in the canteen. Initially the children stood in the order they entered the canteen. However, after a while the boys started feeling awkward for standing in front of the girls in the queue and they started letting the girls move forward ea... | {"inputs": ["5 1\nBGGBG", "5 2\nBGGBG", "4 1\nGGGB", "2 1\nBB", "2 1\nBG", "6 2\nBBGBBG", "8 3\nBBGBGBGB", "10 3\nBBGBBBBBBG", "22 7\nGBGGBGGGGGBBBGGBGBGBBB", "50 4\nGBBGBBBGGGGGBBGGBBBBGGGBBBGBBBGGBGGBGBBBGGBGGBGGBG", "50 8\nGGGGBGGBGGGBGBBBGGGGGGGGBBGBGBGBBGGBGGBGGGGGGGGBBG", "50 30\nBGGGGGGBGGBGBGGGGBGBBGBBBGGBBBGBG... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 274 | codeforces | Okay, let's see. I need to solve this problem where boys and girls are swapping positions in a queue over a certain number of seconds. The boys let the girls go in front of them each second. So the task is to figure out the arrangement after t seconds.
Hmm, the problem says that each second, any boy that is immediatel... | To solve this problem, we need to simulate the process where boys (B) let girls (G) move forward in a queue over a given number of seconds. Each second, any boy standing directly in front of a girl will swap places with her. This process happens simultaneously for all such pairs in the queue each second.
### Approach
... | true | ||
bdb9dc8c6e0599d351c32f5631a32ceb | Igor and his way to work | Woken up by the alarm clock Igor the financial analyst hurried up to the work. He ate his breakfast and sat in his car. Sadly, when he opened his GPS navigator, he found that some of the roads in Bankopolis, the city where he lives, are closed due to road works. Moreover, Igor has some problems with the steering wheel,... | {"inputs": ["5 5\nS....\n****.\n.....\n.****\n..T..", "1 2\nST", "3 1\nS\n*\nT", "3 3\n*..\n...\nTS.", "3 3\nT.*\n*.*\n*S*", "7 7\n.S.****\n...*.*.\n.****..\n.*.**.*\n..T*...\n***..*.\n*******", "3 3\n**T\n*S*\n***", "2 2\nST\n*.", "2 2\nS.\n.T", "2 2\nTS\n.*", "2 2\n.T\nS*"], "outputs": ["NO", "YES", "NO", "YES", "YES... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 16 | codeforces | Okay, let's see. The problem is about finding a path from S to T with at most two turns, avoiding any cells with road works (*). The grid is up to 1000x1000, so we need an efficient solution. Hmm. How to approach this?
First, the main constraint is the number of turns. A turn is when the direction changes. So, the pat... | To solve this problem, we need to determine if there exists a path from Igor's home (marked 'S') to his office (marked 'T') on a grid, avoiding road works (marked '*'), with no more than two turns. A turn is defined as a change in movement direction.
### Approach
1. **Problem Analysis**: The grid can be up to 1000x100... | true | ||
bdbd3d0e9509abf077169578711b6d9d | Cookies | Olga came to visit the twins Anna and Maria and saw that they have many cookies. The cookies are distributed into bags. As there are many cookies, Olga decided that it's no big deal if she steals a bag. However, she doesn't want the sisters to quarrel because of nothing when they divide the cookies. That's why Olga wan... | {"inputs": ["1\n1", "10\n1 2 2 3 4 4 4 2 2 2", "11\n2 2 2 2 2 2 2 2 2 2 99", "2\n1 1", "2\n2 2", "2\n1 2", "7\n7 7 7 7 7 7 7", "8\n1 2 3 4 5 6 7 8", "100\n1 1 1 1 1 2 2 2 2 2 1 1 1 1 1 2 2 2 2 2 1 1 1 1 1 2 2 2 2 2 1 1 1 1 1 2 2 2 2 2 1 1 1 1 1 2 2 2 2 2 1 1 1 1 1 2 2 2 2 2 1 1 1 1 1 2 2 2 2 2 1 1 1 1 1 2 2 2 2 2 1 1 1... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 729 | codeforces | Okay, let's tackle this problem. So the task is to find out how many ways Olga can steal exactly one bag such that the remaining total cookies is even. Hmm. Right, so the main idea is to check for each bag, if removing it leaves an even sum. Then count all such possible bags.
Wait, let's break it down. The total sum o... | To solve this problem, we need to determine how many ways Olga can steal exactly one bag of cookies such that the remaining total number of cookies is even. This ensures that Anna and Maria can evenly divide the remaining cookies without any quarrel.
### Approach
1. **Understand the Parity Requirement**: The key insig... | true | ||
bdc6c256029b80385a04823c5aed31f5 | Stages | Natasha is going to fly to Mars. She needs to build a rocket, which consists of several stages in some order. Each of the stages is defined by a lowercase Latin letter. This way, the rocket can be described by the string — concatenation of letters, which correspond to the stages.
There are $n$ stages available. The ro... | {"inputs": ["5 3\nxyabd", "7 4\nproblem", "2 2\nab", "12 1\nabaabbaaabbb", "50 13\nqwertyuiopasdfghjklzxcvbnmaaaaaaaaaaaaaaaaaaaaaaaa", "50 14\nqwertyuiopasdfghjklzxcvbnmaaaaaaaaaaaaaaaaaaaaaaaa", "1 1\na", "50 1\naaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "50 2\naaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 213 | codeforces | Okay, I need to solve this programming problem. Let's read the problem statement carefully.
So, the task is to build a rocket with exactly k stages from n available stages. Each stage is a lowercase letter. The rocket must have the stages in such an order that each subsequent stage is at least two letters after the pr... | To solve this problem, we need to build a rocket with exactly `k` stages from `n` available stages, each represented by a lowercase Latin letter. The stages must be ordered such that each subsequent stage is at least two positions after the previous one in the alphabet. The goal is to minimize the total weight of the r... | true | ||
bdccebbc59ea21c3a871ae1558ed6845 | The Sum of the k-th Powers | There are well-known formulas: , , . Also mathematicians found similar formulas for higher degrees.
Find the value of the sum modulo 109<=+<=7 (so you should find the remainder after dividing the answer by the value 109<=+<=7).
The only line contains two integers *n*,<=*k* (1<=≤<=*n*<=≤<=109,<=0<=≤<=*k*<=≤<=106).
Pri... | {"inputs": ["4 1", "4 2", "4 3", "4 0", "10 0", "1 1", "1 0", "1 1000000", "1000000000 0", "100 100", "10000 100", "100 10000", "1000000000 1000000", "1000000 1000000", "999999 1000000", "77674473 447444", "333312494 795258", "761637147 673329", "335185991 514401", "203702132 355473", "1000000000 999935"], "outputs": [... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 5 | codeforces | Okay, I need to solve this programming problem. Let's read the problem carefully.
The task is to compute the sum S = 1^k + 2^k + ... + n^k modulo 1e9+7. The constraints are n up to 1e9 and k up to 1e6. Hmm, that's a big n. So a naive approach of calculating each term and adding up is impossible because for n=1e9, even... | To solve this problem, we need to compute the sum of the k-th powers of the first n natural numbers modulo \(10^9 + 7\). The challenge is to handle large values of n (up to \(10^9\)) and k (up to \(10^6\)) efficiently.
### Approach
The solution leverages mathematical properties involving Stirling numbers of the second... | true | ||
bdd1384c3c4e5c12f47e15657aa8931f | Square and Rectangles | You are given *n* rectangles. The corners of rectangles have integer coordinates and their edges are parallel to the *Ox* and *Oy* axes. The rectangles may touch each other, but they do not overlap (that is, there are no points that belong to the interior of more than one rectangle).
Your task is to determine if the ... | {"inputs": ["5\n0 0 2 3\n0 3 3 5\n2 0 5 2\n3 2 5 5\n2 2 3 3", "4\n0 0 2 3\n0 3 3 5\n2 0 5 2\n3 2 5 5", "5\n0 0 10000 20000\n10000 0 15000 19999\n10000 19999 14999 20000\n0 20000 15000 31400\n15000 0 31400 31400", "5\n0 0 10000 20000\n10000 0 15000 19999\n10000 19999 15000 20000\n0 20000 15000 31400\n15000 0 31400 31400... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 10 | codeforces | Okay, so I need to solve this problem where I have to check if a set of rectangles forms a perfect square without overlapping. Hmm. Let's think about the approach here.
First, the problem states that the rectangles don't overlap, but they can touch each other. So the combined area of all the rectangles should exactly ... | To solve this problem, we need to determine if a given set of non-overlapping rectangles forms a perfect square. The solution involves checking the total area covered by the rectangles and verifying if their combined shape forms a square without any gaps.
### Approach
1. **Calculate Total Area**: Sum the areas of all ... | true | ||
bde75bac39cbfe4af0d371bb6c7c6336 | Encryption (easy) | Rebel spy Heidi has just obtained the plans for the Death Star from the Empire and, now on her way to safety, she is trying to break the encryption of the plans (of course they are encrypted – the Empire may be evil, but it is not stupid!). The encryption has several levels of security, and here is how the first one lo... | {"inputs": ["4 10\n3 4 7 2", "10 12\n16 3 24 13 9 8 7 5 12 12", "2 2\n9 9", "2 2\n8 8", "5 50\n1 1 1 1 1", "5 50\n100 150 200 100 50"], "outputs": ["16", "13", "2", "0", "5", "0"]} | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 52 | codeforces | Okay, I need to solve this problem where Heidi has to split an array into two non-overlapping contiguous parts such that the sum of their modulo p scores is maximized. Let's think through this step by step.
The problem statement says that the two parts must each have at least one element, be contiguous, and not overla... | To solve this problem, we need to split an array into two non-overlapping contiguous parts such that the sum of their scores, computed as the sum of elements modulo a given integer \( p \), is maximized.
### Approach
1. **Prefix Sum Calculation**: Compute the prefix sum array to efficiently get the sum of elements up ... | true | ||
bdfe2b1e3fe543e13b9b8077113d91f6 | Oleg and shares | Oleg the bank client checks share prices every day. There are *n* share prices he is interested in. Today he observed that each second exactly one of these prices decreases by *k* rubles (note that each second exactly one price changes, but at different seconds different prices can change). Prices can become negative. ... | {"inputs": ["3 3\n12 9 15", "2 2\n10 9", "4 1\n1 1000000000 1000000000 1000000000", "1 11\n123", "20 6\n38 86 86 50 98 62 32 2 14 62 98 50 2 50 32 38 62 62 8 14", "20 5\n59 54 19 88 55 100 54 3 6 13 99 38 36 71 59 6 64 85 45 54", "100 10\n340 70 440 330 130 120 340 210 440 110 410 120 180 40 50 230 70 110 310 360 480 7... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 171 | codeforces | Okay, let's try to figure out this problem. So, the problem is about Oleg checking share prices. Each second, exactly one price decreases by k rubles. We need to find the minimum time for all prices to become equal, or determine if it's impossible.
First, let's understand the problem step by step. The key points here ... | To solve this problem, we need to determine the minimum number of seconds required for all share prices to become equal if each second exactly one price decreases by a fixed amount \( k \). If it is impossible for all prices to become equal, we should return -1.
### Approach
1. **Check for Feasibility**: First, we nee... | true | ||
be28a9f0e51e26043794e8ef4aac3703 | Work Group | One Big Software Company has *n* employees numbered from 1 to *n*. The director is assigned number 1. Every employee of the company except the director has exactly one immediate superior. The director, of course, doesn't have a superior.
We will call person *a* a subordinates of another person *b*, if either *b* is an... | {"inputs": ["7\n-1 3\n1 2\n1 1\n1 4\n4 5\n4 3\n5 2", "1\n-1 42", "2\n-1 3\n1 2", "3\n-1 3\n1 1\n1 2", "3\n-1 1\n1 2\n1 3", "3\n-1 3\n1 2\n2 1", "20\n-1 100\n1 10\n2 26\n2 33\n3 31\n2 28\n1 47\n6 18\n6 25\n9 2\n4 17\n6 18\n6 2\n6 30\n13 7\n5 25\n7 11\n11 7\n17 40\n12 43", "20\n-1 100\n1 35\n2 22\n3 28\n3 2\n4 8\n3 17\n2... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 1 | codeforces | Okay, let's tackle this problem. Hmm. So the task is to form a workgroup where each member has an even number of subordinates in the workgroup. And we need to maximize the total efficiency. Let's think about how to model this.
First, let's understand the structure. The employees form a tree since each person except th... | To solve this problem, we need to form a workgroup from employees of a company such that each member of the workgroup can pair all their subordinates within the workgroup. The goal is to maximize the total efficiency of the workgroup while adhering to this condition.
### Approach
1. **Tree Structure**: The company hie... | true | ||
be357e1a04067eead63b9cf1cc2b9af5 | Little Frog | Once upon a time a little frog whose name was Vasya decided to travel around his home swamp. Overall there are *n* mounds on the swamp, located on one line. The distance between the neighboring mounds is one meter. Vasya wants to visit all the mounds in one day; besides, he wants to visit each one exactly once. For tha... | {"inputs": ["2", "3", "4", "5", "6", "1", "9149", "2877", "2956", "3035", "3114", "3193", "3273", "7000", "7079", "4653", "9995", "9996", "9997", "9998", "9999", "10000"], "outputs": ["1 2 ", "1 3 2 ", "1 4 2 3 ", "1 5 2 4 3 ", "1 6 2 5 3 4 ", "1 ", "1 9149 2 9148 3 9147 4 9146 5 9145 6 9144 7 9143 8 9142 9 9141 10 914... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 123 | codeforces | Okay, I need to solve this programming problem. Let's read the problem carefully.
The task is to generate a route for the frog Vasya such that he visits all n mounds exactly once, and every consecutive jump has a unique length. The key constraints are that each mound is visited exactly once, and all the absolute diffe... | To solve this problem, we need to generate a route plan for a frog named Vasya such that he visits all the mounds exactly once, and each consecutive jump between mounds has a unique length. The solution involves constructing a permutation of the mound indices that ensures all consecutive jumps have distinct lengths.
#... | false | Code is incorrect. | |
be67cd8ea92d99b084fd6081677642af | Tree of Life (easy) | Heidi has finally found the mythical Tree of Life – a legendary combinatorial structure which is said to contain a prophecy crucially needed to defeat the undead armies.
On the surface, the Tree of Life is just a regular undirected tree well-known from computer science. This means that it is a collection of *n* points... | {"inputs": ["4\n1 2\n1 3\n1 4", "5\n1 2\n2 3\n3 4\n3 5", "2\n1 2", "3\n2 1\n3 2", "10\n5 1\n1 2\n9 3\n10 5\n6 3\n8 5\n2 7\n2 3\n9 4"], "outputs": ["3", "4", "0", "1", "11"]} | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 24 | codeforces | Okay, let's see. The problem is to count the number of paths of length 2 in a tree. Hmm. So a path of length 2 means two edges connected by a common vertex. Like, a central node connected to two others, and the path goes through those two edges. Wait, right. So for example, if a node has degree d, then the number of su... | To solve this problem, we need to count the number of lifelines (paths of length 2) in a given tree structure. Each path of length 2 consists of two edges connected through a common vertex. The approach involves calculating the number of such paths efficiently by leveraging the degree of each vertex in the tree.
### A... | true | ||
beb216e4c28803c082eec7de44f0dd98 | none | Petya loves lucky numbers very much. Everybody knows that lucky numbers are positive integers whose decimal record contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.
Petya has two strings *a* and *b* of the same length *n*. The strings consist only of lucky digits... | {"inputs": ["47\n74", "774\n744", "777\n444", "74747474\n77777777", "444444444444\n777777777777", "4744744447774474447474774\n4477774777444444444777447", "7\n4", "4\n7", "7777777777\n7777777774", "47777777777\n77777777774", "47747477747744447774774444444777444747474747777774\n4477744477447744777744477447777747777444447... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 110 | codeforces | Okay, I need to solve this problem where Petya can swap any digits in string a and flip digits (4 to 7 and vice versa). The goal is to find the minimum number of operations to turn a into b. Let's think through how to approach this.
First, let's understand the problem. The operations allowed are flip any single digit ... | To solve this problem, we need to determine the minimum number of operations required to convert string `a` into string `b` using two types of operations: flipping a digit (4 to 7 or 7 to 4) and swapping any two digits. The key insight is that we can minimize operations by leveraging swaps to handle pairs of mismatched... | true | ||
bec9ea76bca8acdbb8400cd3fe1e396f | The Artful Expedient | Rock... Paper!
After Karen have found the deterministic winning (losing?) strategy for rock-paper-scissors, her brother, Koyomi, comes up with a new game as a substitute. The game works as follows.
A positive integer *n* is decided first. Both Koyomi and Karen independently choose *n* distinct positive integers, deno... | {"inputs": ["3\n1 2 3\n4 5 6", "5\n2 4 6 8 10\n9 7 5 3 1", "1\n1\n2000000", "2\n97153 2000000\n1999998 254", "15\n31 30 29 28 27 26 25 24 23 22 21 20 19 18 17\n1 2 3 4 5 6 7 8 9 10 11 12 13 14 15", "30\n79656 68607 871714 1858841 237684 1177337 532141 161161 1111201 527235 323345 1979059 665353 507265 1290761 610606 12... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 84 | codeforces | Okay, let's try to figure out this problem. So the problem is about determining whether the number of ordered pairs (i,j) where x_i XOR y_j is present in the combined set of x's and y's is even or odd. Depending on that, Karen or Koyomi wins.
First, let's understand the problem step by step. We need to count all pairs... | To solve this problem, we need to determine the winner of a game between Koyomi and Karen based on the parity of the count of ordered pairs (i, j) where the XOR of their chosen integers results in one of the integers from their combined sequences. Karen wins if the count is even, and Koyomi wins if it is odd.
### Appr... | true | ||
bee568ff74ad54cec8202b1f59786496 | Physics Practical | One day Vasya was on a physics practical, performing the task on measuring the capacitance. He followed the teacher's advice and did as much as *n* measurements, and recorded the results in the notebook. After that he was about to show the results to the teacher, but he remembered that at the last lesson, the teacher h... | {"inputs": ["6\n4 5 3 8 3 7", "4\n4 3 2 4", "6\n5 6 4 9 4 8", "4\n5 4 1 5", "2\n3 2", "10\n39 9 18 13 6 16 47 15 1 24", "20\n43 49 46 46 40 41 49 49 48 30 35 36 33 34 42 38 40 46 50 45", "30\n6 1 26 13 16 30 16 23 9 1 5 14 7 2 17 22 21 23 16 3 5 17 22 10 1 24 4 30 8 18", "50\n3 61 16 13 13 12 3 8 14 16 1 32 8 23 29 7 2... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 71 | codeforces | Okay, let's see. The problem is to find the minimum number of measurements Vasya needs to erase so that the remaining ones have max and min where max ≤ 2*min. Hmm. So we need to select a subset of the measurements where the maximum is at most twice the minimum, and this subset should be as large as possible. Then the a... | To solve this problem, we need to determine the minimum number of measurements Vasya must erase so that the remaining measurements have a maximum value that is at most twice the minimum value. The solution involves finding the largest valid subset of measurements and then calculating the number of measurements to remov... | true | ||
beedede080fa2c18f6b59e2bbe40ce40 | Malek Dance Club | As a tradition, every year before IOI all the members of Natalia Fan Club are invited to Malek Dance Club to have a fun night together. Malek Dance Club has 2*n* members and coincidentally Natalia Fan Club also has 2*n* members. Each member of MDC is assigned a unique id *i* from 0 to 2*n*<=-<=1. The same holds for eac... | {"inputs": ["11", "01", "1", "1111111111111111111111111111111111", "0000000000000000000000000000000000000", "11111111111111111111111111111111111000000000000000000000000000", "00000000000000000000111111111111111111111111111111111111111111", "10100101000010011110101011011110001", "0101010000101011111100111100100010101001... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 22 | codeforces | Okay, let's try to understand this problem. So, we need to calculate the complexity of a dance pair assignment based on a given binary number x. The complexity is the number of pairs of dancing pairs (a, b) and (c, d) such that a < c and b > d. Hmm, that sounds like counting the number of inversions in some way. Wait, ... | To solve this problem, we need to calculate the complexity of a dance pair assignment based on a given binary number \( x \). The complexity is defined as the number of pairs \((i, j)\) where \( i < j \) and \((i \oplus x) > (j \oplus x)\). This can be efficiently computed using bitwise operations and modular arithmeti... | true | ||
bf3e927823c777d2ef7bd32bc83e59eb | Easter Eggs | The Easter Rabbit laid *n* eggs in a circle and is about to paint them.
Each egg should be painted one color out of 7: red, orange, yellow, green, blue, indigo or violet. Also, the following conditions should be satisfied:
- Each of the seven colors should be used to paint at least one egg. - Any four eggs lying s... | {"inputs": ["8", "13", "7", "10", "14", "50", "9", "11", "12", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "28", "29", "34", "43", "61", "79", "81", "92", "95", "96", "97", "98", "99", "100"], "outputs": ["ROYGBIVG", "ROYGBIVOYGBIV", "ROYGBIV", "ROYGBIVYGB", "ROYGBIVROYGBIV", "ROYGBIVROYGBIVROYGBI... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 274 | codeforces | Okay, let's tackle this problem. So, we need to paint n eggs arranged in a circle with seven colors, each used at least once. Also, any four consecutive eggs must have different colors. Hmm, the challenge is to find a pattern that meets these conditions for any n between 7 and 100.
First, let's understand the constrai... | To solve this problem, we need to paint a circle of eggs such that each egg is one of seven colors, every color is used at least once, and no four consecutive eggs have the same color. The solution must be efficient and work for any number of eggs between 7 and 100.
### Approach
1. **Initial Setup**: Start with the se... | false | Code is incorrect. | |
bf4dd0423ecea20ddef0b68b094f200c | Holiday Of Equality | In Berland it is the holiday of equality. In honor of the holiday the king decided to equalize the welfare of all citizens in Berland by the expense of the state treasury.
Totally in Berland there are *n* citizens, the welfare of each of them is estimated as the integer in *a**i* burles (burle is the currency in Berl... | {"inputs": ["5\n0 1 2 3 4", "5\n1 1 0 1 1", "3\n1 3 1", "1\n12", "3\n1 2 3", "14\n52518 718438 358883 462189 853171 592966 225788 46977 814826 295697 676256 561479 56545 764281", "21\n842556 216391 427181 626688 775504 168309 851038 448402 880826 73697 593338 519033 135115 20128 424606 939484 846242 756907 377058 24154... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 1,122 | codeforces | Okay, let's tackle this problem. So, the task is to find the minimum number of burles the king needs to distribute so that all citizens have equal welfare. But wait, the king can only give money, not take it away. So, we need to raise everyone's welfare to the level of the highest one. Because if there's someone with l... | To solve this problem, we need to determine the minimum number of burles the king must distribute to ensure all citizens have equal welfare. The king can only give money, so we must raise each citizen's welfare to match the highest current welfare level.
### Approach
1. **Read Input**: First, we read the number of cit... | true | ||
bf66bc37c82f2c30ec50a774ce6d0932 | Coat of Anticubism | As some of you know, cubism is a trend in art, where the problem of constructing volumetrical shape on a plane with a combination of three-dimensional geometric shapes comes to the fore.
A famous sculptor Cicasso, whose self-portrait you can contemplate, hates cubism. He is more impressed by the idea to transmit two-... | {"inputs": ["3\n1 2 1", "5\n20 4 3 2 1", "7\n77486105 317474713 89523018 332007362 7897847 949616701 54820086", "14\n245638694 2941428 4673577 12468 991349408 44735727 14046308 60637707 81525 104620306 88059371 53742651 8489205 3528194", "19\n479740 7703374 196076708 180202968 579604 17429 16916 11989886 30832424 63849... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 147 | codeforces | Okay, let's tackle this problem. So, the task is to find the minimal integer length z that needs to be added to the existing rods so that we can form a convex polygon with all the rods (including the new one). The given rods currently can't form such a polygon.
Hmm, the first thing I remember is that for a set of len... | To solve this problem, we need to determine the minimum length of an additional rod that allows forming a convex polygon using all the given rods and the new one. The key insight is that the sum of the lengths of all other rods must exceed the length of the longest rod for a valid convex polygon.
### Approach
1. **Pro... | true | ||
bf68fad205ecadb130b7e87b5aac8a68 | Chris and Road | And while Mishka is enjoying her trip...
Chris is a little brown bear. No one knows, where and when he met Mishka, but for a long time they are together (excluding her current trip). However, best friends are important too. John is Chris' best friend.
Once walking with his friend, John gave Chris the following proble... | {"inputs": ["5 5 1 2\n1 2\n3 1\n4 3\n3 4\n1 4", "3 3 5 2\n3 1\n4 0\n5 1", "3 3 2 4\n0 1\n2 1\n1 2", "3 3 1 1\n0 0\n1 1\n0 2", "9 10 5 2\n22 5\n25 0\n29 0\n31 2\n32 5\n31 8\n29 10\n25 10\n23 8", "10 10 2 4\n-4 5\n-3 2\n-1 0\n3 0\n5 2\n6 5\n5 8\n3 10\n-1 10\n-2 9", "10 10 1 4\n-1 5\n0 2\n2 0\n5 0\n7 1\n9 5\n8 8\n6 10\n2 ... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 1 | codeforces | Okay, let's try to figure out this problem. Hmm. The pedestrian needs to cross the road from (0,0) to (0,w) without getting hit by the bus. The bus is moving left along the x-axis at speed v. The pedestrian can move up or down the y-axis at speed up to u. We need to find the minimum time to cross, ensuring that at no p... | To solve this problem, we need to determine the minimum time required for a pedestrian to cross a road from point (0, 0) to (0, w) without being hit by a moving bus, which is represented as a convex polygon. The bus moves left along the x-axis at a constant speed, and the pedestrian can move vertically along the y-axis... | false | Code is incorrect. | |
bf78b5d20ae69dfbd2374b041a0e3b55 | Valera and Tubes | Valera has got a rectangle table consisting of *n* rows and *m* columns. Valera numbered the table rows starting from one, from top to bottom and the columns – starting from one, from left to right. We will represent cell that is on the intersection of row *x* and column *y* by a pair of integers (*x*,<=*y*).
Valera w... | {"inputs": ["3 3 3", "2 3 1", "2 3 1", "300 300 2", "300 300 150", "300 299 299", "300 300 45000", "300 299 44850", "2 2 2", "2 3 3", "3 3 4", "5 5 12", "7 5 17", "135 91 4352", "32 27 153", "74 83 2667", "296 218 5275", "89 82 2330", "15 68 212", "95 4 177", "60 136 8", "91 183 7827", "2 15 3", "139 275 10770", "114 2... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 91 | codeforces | Okay, let's tackle this problem. The goal is to arrange k tubes on an n x m grid such that every cell is covered exactly once by the tubes, each tube has at least two cells, and they don't overlap. The output should be the sequence of cells for each tube.
First, I need to understand the constraints. The tubes must be ... | To solve this problem, we need to place exactly `k` tubes on an `n x m` grid such that every cell is covered exactly once by the tubes, each tube has at least two cells, and no two tubes overlap. The solution involves generating a snake-like path through the grid and then splitting this path into the required number of... | false | Code is incorrect. | |
bf841357522a9a2799b0b9ada43e47dd | Ksusha and Array | Ksusha is a beginner coder. Today she starts studying arrays. She has array *a*1,<=*a*2,<=...,<=*a**n*, consisting of *n* positive integers.
Her university teacher gave her a task. Find such number in the array, that all array elements are divisible by it. Help her and find the number!
The first line contains integer ... | {"inputs": ["3\n2 2 4", "5\n2 1 3 1 6", "3\n2 3 5", "1\n331358794", "5\n506904227 214303304 136194869 838256937 183952885", "2\n500000000 1000000000", "2\n4 6", "5\n10 8 6 4 2", "2\n6 10", "1\n1000000000", "2\n6 8", "5\n2 2 2 2 1000000000", "2\n6 4"], "outputs": ["2", "1", "-1", "331358794", "-1", "500000000", "-1", "2... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 187 | codeforces | Okay, let's see. So the problem is to find a number in the array such that all elements are divisible by it. Hmm. Wait, right. So the number must be a divisor of every element in the array. And we have to output that number if it exists in the array, otherwise -1.
First, I need to think about how to approach this. Let... | To solve this problem, we need to find a number in an array such that all elements in the array are divisible by this number. If such a number exists, we return it; otherwise, we return -1.
### Approach
1. **Understanding the Problem**: The key insight is that the number we are looking for must be a common divisor of ... | true | ||
c008ffb743cb2d9e14ef24a4fd1394ae | Mages and Monsters | Vova plays a computer game known as Mages and Monsters. Vova's character is a mage. Though as he has just started, his character knows no spells.
Vova's character can learn new spells during the game. Every spell is characterized by two values *x**i* and *y**i* — damage per second and mana cost per second, respectivel... | {"inputs": ["3 100\n1 4 9\n2 19 49\n2 19 49", "10 442006988299\n2 10 47\n1 9 83\n1 15 24\n2 19 47\n2 75 99\n2 85 23\n2 8 33\n2 9 82\n1 86 49\n2 71 49", "2 424978864039\n2 7 3\n2 10 8", "3 10\n1 1 1\n2 1 1\n2 999999 999999", "12 100\n1 8 8\n2 200 101\n2 10 99\n1 9 9\n2 10 99\n2 200 101\n1 14 4\n2 194 195\n2 194 194\n2 9... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 1 | codeforces | Okay, so I've got this programming problem to solve. Let me read through the problem statement again carefully to understand what's required.
The problem is about Vova's character in a game learning spells and fighting monsters. Each spell has a damage per second (x) and mana cost per second (y). For each fight agains... | To solve this problem, we need to determine if Vova's character can defeat a monster using learned spells under given constraints of time and mana. The solution involves efficiently tracking the best spells in terms of damage per second and mana efficiency to quickly evaluate each query.
### Approach
1. **Data Structu... | true | ||
c01e2b377cf5803a3db4c18e169a42d5 | Tennis Game | Petya and Gena love playing table tennis. A single match is played according to the following rules: a match consists of multiple sets, each set consists of multiple serves. Each serve is won by one of the players, this player scores one point. As soon as one of the players scores *t* points, he wins the set; then the ... | {"inputs": ["5\n1 2 1 2 1", "4\n1 1 1 1", "4\n1 2 1 2", "8\n2 1 2 1 1 1 1 1", "14\n2 1 2 1 1 1 1 2 1 1 2 1 2 1", "10\n1 1 2 2 1 1 2 2 1 1", "20\n1 1 2 2 2 2 2 2 2 2 2 2 1 2 2 1 2 2 2 1", "186\n2 1 2 1 1 1 1 1 2 1 1 2 2 2 1 1 2 2 1 1 1 2 1 1 2 2 1 1 1 2 2 1 1 1 1 1 2 1 1 1 2 1 2 1 1 2 1 1 1 2 2 2 2 2 2 2 1 2 1 2 1 1 2 1... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 1 | codeforces | Okay, let's tackle this problem. Hmm, the problem is about determining all possible s and t values that could result in the given sequence of serve wins. The main challenge is to find all valid (s, t) pairs where the sequence of serve wins aligns with the rules of the match.
First, I need to understand the rules prope... | To solve this problem, we need to determine all valid pairs of (s, t) values that could have produced the given sequence of serve wins according to the rules of table tennis matches. Each match consists of sets, and each set ends when a player scores exactly t points. The match ends when a player wins s sets.
### Appr... | true | ||
c0315ec500973071a258e2b530a085a5 | Maxim Buys an Apartment | Maxim wants to buy an apartment in a new house at Line Avenue of Metropolis. The house has *n* apartments that are numbered from 1 to *n* and are arranged in a row. Two apartments are adjacent if their indices differ by 1. Some of the apartments can already be inhabited, others are available for sale.
Maxim often visi... | {"inputs": ["6 3", "10 1", "10 9", "8 0", "8 8", "966871928 890926970", "20 2", "1 0", "1 1", "2 0", "2 1", "2 2", "7 2", "8 3", "9 4", "10 3", "10 4", "10 5", "1000 1000", "1000 333", "1000 334", "999 333", "999 334", "998 332", "998 333", "89 4", "66 50", "88 15", "95 43", "900 344", "777 113", "964 42", "982 867", "... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 82 | codeforces | Okay, let's try to figure out this problem. The task is to find the minimum and maximum possible number of 'good' apartments for Maxim. A good apartment is one that's available for sale and has at least one inhabited neighbor. The inhabited apartments are exactly k in number, but their positions are unknown. So we need... | To solve this problem, we need to determine the minimum and maximum possible number of 'good' apartments for Maxim. An apartment is considered good if it is available for sale and has at least one adjacent inhabited apartment.
### Approach
1. **Understanding the Problem**:
- Maxim wants to buy an apartment such t... | true | ||
c0519a7dc6f0c45ebc244c6c22cec56d | Max History | You are given an array *a* of length *n*. We define *f**a* the following way:
- Initially *f**a*<==<=0, *M*<==<=1; - for every 2<=≤<=*i*<=≤<=*n* if *a**M*<=<<=*a**i* then we set *f**a*<==<=*f**a*<=+<=*a**M* and then set *M*<==<=*i*.
Calculate the sum of *f**a* over all *n*! permutations of the array *a* modulo 1... | {"inputs": ["2\n1 3", "3\n1 1 2", "6\n1 4 5 2 3 3", "8\n8 7 5 4 6 6 6 6", "8\n1 2 3 9 100 100 100 100", "1\n364489807", "1\n194945396", "9\n25401015 88843847 702650194 306965770 57623156 571088345 835502151 56113403 116176210", "3\n855856619 518546431 920370158", "7\n686312223 948248999 138090108 566544521 711825575 41... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 3 | codeforces | Okay, let's try to understand this problem. So we need to calculate the sum of f_a over all permutations of the given array a. Then output that sum modulo 1e9+7. The function f_a is computed in a specific way, which depends on the permutation.
Let me first re-read the definition of f_a. The initial M is 1, and f_a is... | To solve this problem, we need to compute the sum of the function f_a over all permutations of an array a, modulo \(10^9 + 7\). The function f_a is defined based on the sequence of maximum values encountered in the permutation.
### Approach
1. **Understanding the Function f_a**: The function f_a starts with the first ... | false | Code is incorrect. | |
c05fc5f9b4c21dc89887cfb96b7400ea | Colored Balls | There are *n* boxes with colored balls on the table. Colors are numbered from 1 to *n*. *i*-th box contains *a**i* balls, all of which have color *i*. You have to write a program that will divide all balls into sets such that:
- each ball belongs to exactly one of the sets, - there are no empty sets, - there is no ... | {"inputs": ["3\n4 7 8", "2\n2 7", "1\n1", "1\n1000000000", "2\n1000000000 1", "2\n9 6", "2\n948507270 461613425", "5\n8 7 4 8 3", "5\n11703 91351 99 16279 50449", "20\n3 2 1 1 1 2 2 2 3 3 1 1 3 2 3 3 2 3 3 2", "20\n895 8894 6182 5852 9830 7562 8854 4004 5909 4979 6863 2987 3586 1319 513 5496 9543 9561 6590 5063", "200\... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 5 | codeforces | Okay, let's see. I need to solve this programming problem. Let me read the question carefully.
So, the problem is about dividing balls from different boxes into sets. Each box has balls of a single color. The conditions are:
1. Every ball is in exactly one set.
2. No empty sets.
3. Each set has only one color.
4. No ... | To solve this problem, we need to divide balls of different colors into sets such that each set contains balls of a single color, and the sizes of the sets differ by at most 1. The goal is to find the minimum possible number of sets.
### Approach
1. **Problem Analysis**:
- Each set must contain balls of only one co... | false | Code is incorrect. | |
c086d2e71d8091df7b4eef2dd781beec | Valera and Number | Valera is a coder. Recently he wrote a funny program. The pseudo code for this program is given below:
Now Valera wonders: given the values *x*, *k* and *p*, what is the expected value of the resulting number *s*?
The first line of the input contains three integers *x*,<=*k*,<=*p* (1<=≤<=*x*<=≤<=109; 1<=≤<=*k*<=≤<=200... | {"inputs": ["1 1 50", "5 3 0", "5 3 25", "1132123 200 0", "1213112 200 100", "490879136 12 75", "114566801 2 55", "331870050 6 98", "252615193 9 45", "224314221 19 51", "510823354 20 18", "573292218 200 77", "465672965 100 95", "853095531 50 72", "254290166 200 95", "206910020 200 4", "680841078 112 48", "92021679 54 2... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 1 | codeforces | Okay, I need to solve this programming problem. Let's read the problem statement carefully.
The problem is about Valera's program, which has some pseudo-code, and we need to compute the expected value of the resulting number s after executing the program. The input is x, k, p, and the output is the expected value with... | To solve this problem, we need to determine the expected value of a number after performing a series of operations based on given probabilities. The operations involve either adding 1 and then dividing by 2 or simply dividing by 2, each with a specified probability.
### Approach
The problem can be efficiently solved ... | false | Code is incorrect. | |
c08a7770e7aaa6e439fb7923a9c9b201 | Two Melodies | Alice is a beginner composer and now she is ready to create another masterpiece. And not even the single one but two at the same time!
Alice has a sheet with *n* notes written on it. She wants to take two such non-empty non-intersecting subsequences that both of them form a melody and sum of their lengths is maximal.... | {"inputs": ["4\n1 2 4 5", "6\n62 22 60 61 48 49", "2\n1 4", "2\n5 4", "10\n9 6 8 5 5 2 8 9 2 2", "10\n7776 32915 1030 71664 7542 72359 65387 75222 95899 40333", "10\n1 1 1 1 1 1 1 1 1 1", "4\n15 11 28 17", "3\n1 36 6", "6\n3 12 4 12 5 6", "6\n7 20 21 22 23 28"], "outputs": ["4", "5", "2", "2", "9", "6", "10", "2", "3",... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 1 | codeforces | Okay, I need to solve this problem where Alice wants to split her notes into two non-overlapping subsequences, each forming a melody. The goal is to maximize the sum of their lengths. Hmm, let's think through how to approach this.
First, let's understand the melody condition. Each adjacent pair in the subsequence must... | To solve this problem, we need to find two non-empty, non-overlapping subsequences from a given list of notes such that each subsequence forms a melody. A melody is defined such that each pair of adjacent notes either differs by 1 or is congruent modulo 7. The goal is to maximize the sum of the lengths of these two sub... | true | ||
c0c1479e7ce5028f5eaa529aedd3e85c | Bars | Polycarp's workday lasts exactly $n$ minutes. He loves chocolate bars and can eat one bar in one minute. Today Polycarp has $k$ bars at the beginning of the workday.
In some minutes of the workday Polycarp has important things to do and in such minutes he is not able to eat a chocolate bar. In other minutes he can eit... | {"inputs": ["3 3\n010", "8 3\n01010110", "9 5\n001100110", "2 2\n00", "3 2\n010", "3 2\n000", "3 3\n000", "4 2\n0000", "4 2\n0100", "4 2\n0010", "4 2\n0110", "4 3\n0000", "4 3\n0010", "4 3\n0100", "4 3\n0110", "4 4\n0000", "4 4\n0100", "4 4\n0010", "4 4\n0110", "10 3\n0111011010", "100 19\n00110111100111111110101111011... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 7 | codeforces | Okay, I need to solve this programming problem. Let me read the problem carefully and understand what's required.
So, the problem is about Polycarp eating chocolate bars during his workday. The workday is n minutes long, and he starts with k bars. The constraints are that in some minutes he's busy and can't eat, but h... | To solve this problem, we need to determine the optimal order for Polycarp to eat his chocolate bars such that the maximum break time between eating bars is minimized. The solution involves binary search to efficiently find the minimum possible maximum break time.
### Approach
1. **Problem Analysis**: Polycarp must ea... | true | ||
c0c31df16741dd7d0059f2a9ec8f3864 | Super Agent | There is a very secret base in Potatoland where potato mash is made according to a special recipe. The neighbours from Porridgia decided to seize this recipe and to sell it to Pilauland. For this mission they have been preparing special agent Pearlo for many years. When, finally, Pearlo learned all secrets of espionage... | {"inputs": ["XX.\n...\n.XX", ".X.\n.X.\n.X.", "XXX\nXXX\nXXX", "XXX\nX.X\nXXX", "X..\n.X.\n..X", "...\nX.X\nX..", ".X.\nX.X\n.X.", "X.X\n.X.\nX.X", "...\n...\n..X", "XXX\n...\nXXX", "..X\nX..\n..X", ".X.\n...\nX.X", "X.X\nX.X\nX.X", ".X.\nX.X\nXX.", "...\nXXX\nXXX", "XXX\n..X\nXXX", "X..\nX.X\n.X.", "...\n..X\nXXX", ".... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 320 | codeforces | Okay, I need to solve this programming problem. Let's read the problem carefully.
The task is to determine if the password entered on a 3x3 keypad is symmetric with respect to the central button. The input is a 3x3 grid where 'X' represents pressed buttons (part of the password) and '.' means not pressed. The password... | To solve this problem, we need to determine if the password entered on a 3x3 keypad is symmetric with respect to the central button. The input is a 3x3 grid where 'X' represents pressed buttons and '.' represents unpressed buttons. The password is considered symmetric if every 'X' has a corresponding 'X' in the positio... | true | ||
c0f901607f527b8e6f3e00116e7c7ab4 | Petya and Square | Little Petya loves playing with squares. Mum bought him a square 2*n*<=×<=2*n* in size. Petya marked a cell inside the square and now he is solving the following task.
The task is to draw a broken line that would go along the grid lines and that would cut the square into two equal parts. The cutting line should not ha... | {"inputs": ["4 1 1", "2 2 2", "8 2 5", "6 1 6", "2 1 1", "2 1 2", "2 2 1", "4 2 2", "4 2 3", "4 2 4", "60 30 30", "60 34 30", "60 31 29", "100 61 30", "100 52 50", "100 51 51", "100 1 2", "100 1 8", "100 19 99", "100 18 82", "100 100 50", "100 51 100", "100 100 100", "6 3 3", "6 4 4", "6 3 1", "6 3 5", "8 4 4", "6 3 2"... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 1 | codeforces | Okay, let's tackle this problem. Hmm, the task is to determine if we can split a square of size 2n x 2n into two equal parts via a broken line that doesn't touch the marked cell. The two parts must be equal up to rotation. Oh right, and the broken line has to follow grid lines.
First, I need to understand what kind of... | To solve this problem, we need to determine if a square of size 2n x 2n can be split into two equal parts using a broken line that does not touch a marked cell. The two resulting parts must be equal up to rotation. The key insight is that the line must pass through the center of the square, and if the marked cell is ad... | true | ||
c1099b4137bcb0dc819f8df0ea6630c3 | Multi-judge Solving | Makes solves problems on Decoforces and lots of other different online judges. Each problem is denoted by its difficulty — a positive integer number. Difficulties are measured the same across all the judges (the problem with difficulty *d* on Decoforces is as hard as the problem with difficulty *d* on any other judge).... | {"inputs": ["3 3\n2 1 9", "4 20\n10 3 6 3", "1 1000000000\n1", "1 1\n3", "50 100\n74 55 33 5 83 24 75 59 30 36 13 4 62 28 96 17 6 35 45 53 33 11 37 93 34 79 61 72 13 31 44 75 7 3 63 46 18 16 44 89 62 25 32 12 38 55 75 56 61 82", "100 10\n246 286 693 607 87 612 909 312 621 37 801 558 504 914 416 762 187 974 976 123 635 ... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 61 | codeforces | Okay, I need to solve this programming problem. Let me read the problem statement carefully and understand what's being asked.
So, the problem is about Makes who wants to solve a list of problems on Decoforces. Each problem has a certain difficulty, and they are sorted in non-decreasing order. But to solve a problem, ... | To solve this problem, we need to determine the minimum number of additional problems Makes needs to solve on other judges to be able to solve all chosen problems on Decoforces. The key requirement is that Makes can only solve a problem on Decoforces if he has already solved a problem with a difficulty exactly one less... | false | Code is incorrect. | |
c11ed3f7cf93b87239cbf0e5d6a42e5b | Alyona and Numbers | After finishing eating her bun, Alyona came up with two integers *n* and *m*. She decided to write down two columns of integers — the first column containing integers from 1 to *n* and the second containing integers from 1 to *m*. Now the girl wants to count how many pairs of integers she can choose, one from the first... | {"inputs": ["6 12", "11 14", "1 5", "3 8", "5 7", "21 21", "10 15", "1 1", "1 1000000", "1000000 1", "1000000 1000000", "944 844", "368 984", "792 828", "920 969", "640 325", "768 170", "896 310", "320 154", "744 999", "630 843", "54 688", "478 828", "902 184", "31 29", "751 169", "879 14", "7 858", "431 702", "855 355... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 371 | codeforces | Okay, let's see. I need to find the number of pairs (x, y) where x is between 1 and n, y is between 1 and m, and x + y is divisible by 5. Hmm. How can I approach this efficiently?
Wait, the brute force way would be to check every possible pair, but with n and m up to a million, that's 1e12 operations. That's way too s... | To solve this problem, we need to count the number of pairs (x, y) such that 1 ≤ x ≤ n, 1 ≤ y ≤ m, and the sum (x + y) is divisible by 5. The solution involves leveraging modular arithmetic to efficiently compute the count without iterating through all possible pairs.
### Approach
1. **Modular Arithmetic Insight**: Fo... | true | ||
c12241ccb6ccd236b53aeca845120461 | Ciel and Duel | Fox Ciel is playing a card game with her friend Jiro.
Jiro has *n* cards, each one has two attributes: *position* (Attack or Defense) and *strength*. Fox Ciel has *m* cards, each one has these two attributes too. It's known that position of all Ciel's cards is Attack.
Now is Ciel's battle phase, Ciel can do the follo... | {"inputs": ["2 3\nATK 2000\nDEF 1700\n2500\n2500\n2500", "3 4\nATK 10\nATK 100\nATK 1000\n1\n11\n101\n1001", "2 4\nDEF 0\nATK 0\n0\n0\n1\n1", "1 1\nATK 100\n99", "4 8\nDEF 100\nDEF 200\nDEF 300\nATK 100\n100\n101\n201\n301\n1\n1\n1\n1", "3 4\nDEF 100\nATK 200\nDEF 300\n101\n201\n301\n1", "4 4\nDEF 0\nDEF 0\nDEF 0\nATK ... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 5 | codeforces | Okay, let's see. I need to solve this programming problem. Hmm, the problem is about a card game between Fox Ciel and Jiro. The goal is to calculate the maximum damage Jiro can get based on how Ciel uses her attack cards. Let me try to understand the problem step by step.
So, Jiro has n cards, each either Attack or De... | To solve this problem, we need to determine the maximum damage Jiro can receive when Fox Ciel uses her cards optimally. The solution involves considering two main scenarios: attacking all of Jiro's cards and then using remaining cards for direct damage, or attacking a subset of Jiro's cards and not using the remaining ... | true | ||
c15f635616d643c4688b14322dc81920 | Amr and Music | Amr is a young coder who likes music a lot. He always wanted to learn how to play music but he was busy coding so he got an idea.
Amr has *n* instruments, it takes *a**i* days to learn *i*-th instrument. Being busy, Amr dedicated *k* days to learn how to play the maximum possible number of instruments.
Amr asked for ... | {"inputs": ["4 10\n4 3 1 2", "5 6\n4 3 1 1 2", "1 3\n4", "2 100\n100 100", "3 150\n50 50 50", "4 0\n100 100 100 100", "100 7567\n100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 192 | codeforces | Okay, let's tackle this problem. Hmm, the goal is to find the maximum number of instruments Amr can learn within k days. Oh right, and we need to choose the instruments in such a way that their total learning time is as small as possible, so we can fit as many as possible. Oh right, because if we sort the instruments b... | To solve this problem, we need to determine the maximum number of musical instruments Amr can learn within a given number of days, using an optimal selection of instruments that minimizes the total number of days required.
### Approach
1. **Problem Analysis**: The goal is to maximize the number of instruments Amr can... | false | Code is incorrect. | |
c1728962a6cce0de630f0372867289aa | Game Shopping | Maxim wants to buy some games at the local game shop. There are $n$ games in the shop, the $i$-th game costs $c_i$.
Maxim has a wallet which can be represented as an array of integers. His wallet contains $m$ bills, the $j$-th bill has value $a_j$.
Games in the shop are ordered from left to right, Maxim tries to buy ... | {"inputs": ["5 4\n2 4 5 2 4\n5 3 4 6", "5 2\n20 40 50 20 40\n19 20", "6 4\n4 8 15 16 23 42\n1000 1000 1000 1000", "5 1\n1 1 1 1 1\n5", "5 1\n10 1 1 1 1\n1000", "5 1\n100 100 100 100 100\n100", "2 1\n2 1\n1", "2 3\n3 1\n2 4 2", "1 5\n4\n1 4 3 3 2", "5 3\n4 2 3 1 1\n2 1 3", "3 5\n5 2 5\n1 4 1 4 2", "7 3\n9 7 10 2 1 1 1\n... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 321 | codeforces | Okay, let's see. I need to solve this programming problem. Let me read the problem statement carefully.
So, the problem is about Maxim buying games in a shop. There are n games in order, each with a cost c_i. His wallet has m bills, which are in an array. He tries to buy each game in order. For each game, he takes the... | To solve this problem, we need to determine how many games Maxim can buy from a shop given the costs of the games and the values of the bills in his wallet. Maxim tries to buy each game in order, using the first bill in his wallet each time. If the bill's value is sufficient, he buys the game and the bill is removed fr... | true | ||
c1e7da4ca3f099a03821e7eefe9f889b | Ilya and Escalator | Ilya got tired of sports programming, left university and got a job in the subway. He was given the task to determine the escalator load factor.
Let's assume that *n* people stand in the queue for the escalator. At each second one of the two following possibilities takes place: either the first person in the queue en... | {"inputs": ["1 0.50 1", "1 0.50 4", "4 0.20 2", "2000 0.61 2000", "100 1.00 200", "417 0.57 742", "100 0.01 53", "300 0.05 55", "1400 0.02 200", "2000 0.01 234", "1 0.01 2000", "300 0.99 1000", "400 0.96 1754", "2000 0.93 100", "1000 0.90 1733", "1 1.00 1", "2000 1.00 2000", "2000 0.00 2000", "2000 0.01 2000", "2000 0.... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 25 | codeforces | Okay, I need to solve this problem where I have to compute the expected number of people on the escalator after t seconds. Let me try to understand the problem first.
So, there are n people in a queue. Each second, the first person in the queue can either get on the escalator with probability p or stay (with probabili... | To solve this problem, we need to determine the expected number of people on an escalator after a given number of seconds, considering that each person in the queue has a certain probability of entering the escalator each second. This problem can be efficiently solved using dynamic programming (DP) to model the possibl... | false | Code is incorrect. | |
c20295e447351fec89195b82e112921a | Preparing Olympiad | You have *n* problems. You have estimated the difficulty of the *i*-th one as integer *c**i*. Now you want to prepare a problemset for a contest, using some of the problems you've made.
A problemset for the contest must consist of at least two problems. You think that the total difficulty of the problems of the contes... | {"inputs": ["3 5 6 1\n1 2 3", "4 40 50 10\n10 20 30 25", "5 25 35 10\n10 10 20 10 20", "4 15 60 10\n10 20 30 25", "1 10 20 1\n15", "10 626451 11471247 246428\n369649 684428 303821 287098 422756 301599 720377 177567 515216 750602", "15 1415849 15540979 356865\n8352 960238 276753 259695 712845 945369 60023 920446 181269 ... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 67 | codeforces | Okay, I need to solve this programming problem. Let's read the problem statement carefully.
So the task is to find the number of ways to choose a subset of problems such that:
1. The subset has at least two problems.
2. The total difficulty is between l and r, inclusive.
3. The difference between the maximum and mini... | To solve this problem, we need to determine the number of ways to select a subset of problems such that the subset meets specific criteria related to total difficulty, the difference between the hardest and easiest problems, and the number of problems in the subset.
### Approach
1. **Generate Subsets**: Use bitmasking... | true | ||
c238239f5c75f82bf35be066d8493e38 | Sonya and Queries | 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. <=+<= *a**i* — add non-negative integer *a**i* to the multiset. Note, that she has a multiset, thus there may b... | {"inputs": ["12\n+ 1\n+ 241\n? 1\n+ 361\n- 241\n? 0101\n+ 101\n? 101\n- 101\n? 101\n+ 4000\n? 0", "4\n+ 200\n+ 200\n- 200\n? 0", "20\n+ 61\n+ 99\n+ 51\n+ 70\n+ 7\n+ 34\n+ 71\n+ 86\n+ 68\n+ 39\n+ 78\n+ 81\n+ 89\n? 10\n? 00\n? 10\n? 01\n? 01\n? 00\n? 00", "20\n+ 13\n+ 50\n+ 9\n? 0\n+ 24\n? 0\n- 24\n? 0\n+ 79\n? 11\n- 13\... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 30 | codeforces | Okay, let's tackle this problem. Hmm, the problem is about maintaining a multiset of integers and handling three types of queries: adding, removing, and querying the count of numbers that match a certain pattern. The pattern is based on the parity of each digit when aligned from the right. Oh right, and the pattern and... | To solve this problem, we need to maintain a multiset of integers and handle three types of queries: adding an integer, removing an integer, and counting how many integers match a given pattern based on the parity of their digits. The pattern is given as a string of 0s (even) and 1s (odd), and we need to check if the p... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.