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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
a3f1a98e1d913a9a756aac7c1010239d | Matching Names | Teachers of one programming summer school decided to make a surprise for the students by giving them names in the style of the "Hobbit" movie. Each student must get a pseudonym maximally similar to his own name. The pseudonym must be a name of some character of the popular saga and now the teachers are busy matching ps... | {"inputs": ["5\ngennady\ngalya\nboris\nbill\ntoshik\nbilbo\ntorin\ngendalf\nsmaug\ngaladriel", "1\na\na", "2\na\na\na\na", "2\na\nb\na\na", "2\nb\nb\na\na", "2\na\nb\na\nb", "10\nbaa\na\nba\naabab\naa\nbaab\nbb\nabbbb\na\na\na\nba\nba\nbaabbb\nba\na\naabb\nbaa\nab\nb", "10\nabaabbaaa\nacccccaacabc\nacbaabaaabbca\naaccc... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 1 | codeforces | Okay, let's tackle this problem. Hmm, the goal is to find a matching between student names and pseudonyms such that the sum of the lengths of their longest common prefixes is maximized. And we need to output the maximum sum and the actual matching.
First, I need to understand the problem thoroughly. So each student is... | To solve this problem, we need to find an optimal matching between student names and pseudonyms such that the sum of the lengths of their longest common prefixes (LCP) is maximized. Each student must be assigned exactly one pseudonym, and each pseudonym must be assigned to exactly one student.
### Approach
1. **Trie C... | false | Code is incorrect. | |
a3f7d08d933ed661efd4b6e37e7599db | Minimum Difficulty | Mike is trying rock climbing but he is awful at it.
There are *n* holds on the wall, *i*-th hold is at height *a**i* off the ground. Besides, let the sequence *a**i* increase, that is, *a**i*<=<<=*a**i*<=+<=1 for all *i* from 1 to *n*<=-<=1; we will call such sequence a track. Mike thinks that the track *a*1, ...,... | {"inputs": ["3\n1 4 6", "5\n1 2 3 4 5", "5\n1 2 3 7 8", "3\n1 500 1000", "10\n1 2 3 4 5 6 7 8 9 10", "10\n1 4 9 16 25 36 49 64 81 100", "10\n300 315 325 338 350 365 379 391 404 416", "15\n87 89 91 92 93 95 97 99 101 103 105 107 109 111 112", "60\n3 5 7 8 15 16 18 21 24 26 40 41 43 47 48 49 50 51 52 54 55 60 62 71 74 84... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 416 | codeforces | Okay, let's tackle this problem. So Mike wants to remove one hold from the track such that the maximum difference between adjacent holds is minimized. And the first and last holds must stay. Hmm.
Let me think. The original track is increasing, so after removing one element, we need to check the adjacent differences wh... | To solve this problem, we need to determine the minimum difficulty of a rock climbing track after removing one hold such that the maximum distance between any two adjacent holds is minimized. The first and last holds must remain in their positions.
### Approach
1. **Understand the Problem**: The difficulty of the trac... | true | ||
a4657b14d49366265fcbca7ce5474e37 | Roman and Numbers | Roman is a young mathematician, very famous in Uzhland. Unfortunately, Sereja doesn't think so. To make Sereja change his mind, Roman is ready to solve any mathematical problem. After some thought, Sereja asked Roma to find, how many numbers are close to number *n*, modulo *m*.
Number *x* is considered close to number... | {"inputs": ["104 2", "223 4", "7067678 8", "202 10", "1306432 9", "9653092 9", "600038 6", "4064044 4", "5899025 7", "2496234323687 2", "1 1", "123456789123456789 2", "123 1", "6328128 6", "8966261 5", "8900064 4", "576021249 86", "682459775 6", "458498549 4", "511736928 87", "275126649 81", "576279776452 33", "4504977... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 1 | codeforces | Okay, let's tackle this problem. So, the task is to find how many numbers are close to n modulo m. The conditions are that the number is a permutation of the digits of n, has no leading zeros, and is divisible by m. Hmm.
First, I need to understand the problem. Let's take the sample input to get an idea. For example, ... | To solve this problem, we need to determine how many numbers can be formed by rearranging the digits of a given number \( n \) such that the resulting number is divisible by \( m \) and does not have leading zeros. The solution involves using dynamic programming (DP) with memoization to efficiently count valid permutat... | false | Code is incorrect. | |
a475ab27993339a77c13dc5ef2a69e3c | Diverse Team | There are $n$ students in a school class, the rating of the $i$-th student on Codehorses is $a_i$. You have to form a team consisting of $k$ students ($1 \le k \le n$) such that the ratings of all team members are distinct.
If it is impossible to form a suitable team, print "NO" (without quotes). Otherwise print "YES"... | {"inputs": ["5 3\n15 13 15 15 12", "5 4\n15 13 15 15 12", "4 4\n20 10 40 30", "1 1\n1", "100 53\n16 17 1 2 27 5 9 9 53 24 17 33 35 24 20 48 56 73 12 14 39 55 58 13 59 73 29 26 40 33 22 29 34 22 55 38 63 66 36 13 60 42 10 15 21 9 11 5 23 37 79 47 26 3 79 53 44 8 71 75 42 11 34 39 79 33 10 26 23 23 17 14 54 41 60 31 83 5... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 184 | codeforces | Okay, let's tackle this problem. Hmm. The task is to form a team of k students with distinct ratings. If it's not possible, output NO. Otherwise, output YES and the indices of the chosen students.
First, I need to understand what the input is. The first line gives n and k. Then the second line has a list of n integer... | To solve this problem, we need to form a team of students such that each member has a distinct rating. If it's impossible to form such a team, we should output "NO". Otherwise, we output "YES" along with the indices of the selected students.
### Approach
1. **Check Unique Ratings**: First, determine the number of uniq... | true | ||
a4bd2375265606dcb3fc9755ddcf11e7 | Wonder Room | The start of the new academic year brought about the problem of accommodation students into dormitories. One of such dormitories has a *a*<=×<=*b* square meter wonder room. The caretaker wants to accommodate exactly *n* students there. But the law says that there must be at least 6 square meters per student in a room (... | {"inputs": ["3 3 5", "2 4 4", "1 1 1", "1 1000000000 1000000000", "8 7 5", "1000000000 1 1", "1000000000 1000000000 1000000000", "800000003 7 7", "11 7 7", "1000000000 1 1", "100000 100 1000", "1000000000 6000 1000000", "1 1000000000 1000000000", "980000000 2 100000", "13 7 6", "16 19 5", "258180623 16000 16000", "9999... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 3 | codeforces | Okay, let's tackle this problem. Hmm, the task is to find the minimal possible area of the room after possibly enlarging the sides, such that the area is at least 6*n. Also, the original dimensions are a and b, but since the problem says a ≤×≤ b, I think maybe the order of a and b doesn't matter, but maybe we need to c... | To solve this problem, we need to ensure that a dormitory room can accommodate exactly `n` students while meeting the legal requirement of at least 6 square meters per student. The goal is to find the minimal possible area of the room after possibly enlarging its sides, such that the new area is at least `6*n` square m... | false | Code is incorrect. | |
a4c73b1bebe0b753f5fd0adb2bd62c52 | Jeff and Permutation | Jeff's friends know full well that the boy likes to get sequences and arrays for his birthday. Thus, Jeff got sequence *p*1,<=*p*2,<=...,<=*p**n* for his birthday.
Jeff hates inversions in sequences. An inversion in sequence *a*1,<=*a*2,<=...,<=*a**n* is a pair of indexes *i*,<=*j* (1<=≤<=*i*<=<<=*j*<=≤<=*n*), such... | {"inputs": ["2\n2 1", "9\n-2 0 -1 0 -1 2 1 0 -1", "9\n0 0 1 1 0 0 1 0 1", "8\n0 1 2 -1 -2 1 -2 2", "24\n-1 -1 2 2 0 -2 2 -1 0 0 2 -2 3 0 2 -3 0 -3 -1 1 0 0 -1 -2", "1\n0", "31\n-2 2 -2 -1 0 0 1 2 1 1 -1 -2 1 -1 -2 2 0 1 -1 -2 -1 -2 -1 2 2 2 2 1 1 0 1", "9\n1 -1 -1 0 -1 0 1 1 1", "5\n1 0 1 -2 1", "31\n-5 -5 5 3 -1 3 1 -... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 1 | codeforces | Okay, so I've got this programming problem to solve. Let's read through it carefully.
The problem is about Jeff's sequence of numbers. Jeff can flip the signs of some elements (multiply by -1) to minimize the number of inversions. Our task is to find the minimum possible number of inversions after flipping some elemen... | To solve this problem, we need to minimize the number of inversions in a sequence after possibly flipping the sign of some elements. An inversion is a pair of indices (i, j) such that i < j and a[i] > a[j]. The goal is to determine the minimum number of inversions achievable by flipping the signs of some elements.
###... | false | Code is incorrect. | |
a4cc49fca72a78529802e27c6dbba97f | Bracket Sequences Concatenation Problem | A bracket sequence is a string containing only characters "(" and ")".
A regular bracket sequence is a bracket sequence that can be transformed into a correct arithmetic expression by inserting characters "1" and "+" between the original characters of the sequence. For example, bracket sequences "()()", "(())" are reg... | {"inputs": ["3\n)\n()\n(", "2\n()\n()", "7\n()(\n)\n)(\n())\n(((\n()()()\n()", "6\n(\n((\n(((\n))))\n)))))\n))))))", "9\n(()\n((())\n(\n)\n(()()(()())))\n)\n)(()(\n)())(\n)()(", "2\n(((((((((()\n)))))))))", "1\n)(", "1\n()", "2\n(((\n)))", "10\n()()(\n)((\n)()(((()(\n(((()(\n)(()((\n))\n()()()()\n))()))((\n)\n))())(", ... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 44 | codeforces | Okay, let's tackle this problem. So, we need to find the number of pairs (i, j) where the concatenation of s_i and s_j forms a regular bracket sequence. Hmm. Regular bracket sequences have to be balanced, right? So the total number of opening and closing brackets must be equal. Also, at any point in the sequence, the n... | To solve this problem, we need to determine the number of pairs of bracket sequences such that their concatenation forms a regular bracket sequence. A regular bracket sequence is one that can be transformed into a correct arithmetic expression by inserting numbers and operators.
### Approach
1. **Understanding Regular... | true | ||
a4d1149733c96e064b611faa2a965482 | Useful Decomposition | Ramesses knows a lot about problems involving trees (undirected connected graphs without cycles)!
He created a new useful tree decomposition, but he does not know how to construct it, so he asked you for help!
The decomposition is the splitting the edges of the tree in some simple paths in such a way that each two pa... | {"inputs": ["4\n1 2\n2 3\n3 4", "6\n1 2\n2 3\n3 4\n2 5\n3 6", "5\n1 2\n1 3\n1 4\n1 5", "2\n1 2", "8\n1 2\n1 3\n1 4\n1 8\n7 8\n6 8\n5 8", "9\n1 2\n1 3\n1 4\n1 5\n1 6\n6 7\n7 8\n7 9", "3\n2 3\n1 2"], "outputs": ["Yes\n1\n1 4", "No", "Yes\n4\n1 2\n1 3\n1 4\n1 5", "Yes\n1\n1 2", "No", "No", "Yes\n1\n1 3"]} | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 21 | codeforces | Okay, I need to solve this problem where I have to decompose a tree into paths such that every pair of paths shares at least one common vertex, and each edge is in exactly one path. Let's start by understanding the problem deeply.
First, the decomposition must cover all edges, each in exactly one path. Also, any two p... | To solve this problem, we need to decompose a tree into paths such that each pair of paths shares at least one common vertex, and each edge is part of exactly one path. The solution involves identifying a central node from which all paths can be constructed, ensuring all paths share this node.
### Approach
1. **Identi... | true | ||
a4f83e70290499e2174902d149702f3e | Keyboard | Vasya learns to type. He has an unusual keyboard at his disposal: it is rectangular and it has *n* rows of keys containing *m* keys in each row. Besides, the keys are of two types. Some of the keys have lowercase Latin letters on them and some of the keys work like the "Shift" key on standard keyboards, that is, they m... | {"inputs": ["2 2 1\nab\ncd\n1\nA", "2 2 1\nab\ncd\n1\ne", "2 2 1\nab\ncS\n5\nabcBA", "3 9 4\nqwertyuio\nasdfghjkl\nSzxcvbnmS\n35\nTheQuIcKbRoWnFOXjummsovertHeLazYDOG", "10 9 3\noboxlgpey\nyxcuwkkmp\njuqeflhwq\nsfnxqtjqS\nkkudcnyjl\nhgjlcrkjq\njnofqksxn\nqbhsnuguv\nlvahnifao\nebwnnlrwe\n35\nCodeforcesBetaRoundproblemAte... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 32 | codeforces | Okay, let's try to solve this problem. Hmm, the problem statement is a bit complex. Let's read through it carefully.
So, the task is to determine the minimum number of times Vasya has to use his other hand while typing a given text. The other hand is needed when a character can't be typed with one hand. But when can a... | To solve this problem, we need to determine the minimum number of times Vasya will have to use his other hand while typing a given text on a special keyboard. The keyboard has lowercase letters and shift keys, and Vasya can press one or two keys with one hand if their Euclidean distance is within a given threshold. The... | true | ||
a51153791f483833a64b7568e351adfb | Mishka and Contest | Mishka started participating in a programming contest. There are $n$ problems in the contest. Mishka's problem-solving skill is equal to $k$.
Mishka arranges all problems from the contest into a list. Because of his weird principles, Mishka only solves problems from one of the ends of the list. Every time, he chooses ... | {"inputs": ["8 4\n4 2 3 1 5 1 6 4", "5 2\n3 1 2 1 3", "5 100\n12 34 55 43 21", "100 100\n44 47 36 83 76 94 86 69 31 2 22 77 37 51 10 19 25 78 53 25 1 29 48 95 35 53 22 72 49 86 60 38 13 91 89 18 54 19 71 2 25 33 65 49 53 5 95 90 100 68 25 5 87 48 45 72 34 14 100 44 94 75 80 26 25 7 57 82 49 73 55 43 42 60 34 8 51 11 71... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 265 | codeforces | Okay, let's see. I need to solve this problem where Mishka is trying to solve as many problems as possible from either end of a list. The key points are that he can only take from the left or right end each time, and each problem he takes must have a difficulty <= k. Once he can't take either end, he stops. The goal is... | To solve this problem, we need to determine the maximum number of problems Mishka can solve from either end of a list, given his problem-solving skill. Mishka can only solve problems from either end of the list if their difficulty does not exceed his skill level, and he stops when he can no longer solve any problems fr... | true | ||
a54faeb0d9470c4cfd362bc7fddfe085 | Coloring Brackets | Once Petya read a problem about a bracket sequence. He gave it much thought but didn't find a solution. Today you will face it.
You are given string *s*. It represents a correct bracket sequence. A correct bracket sequence is the sequence of opening ("(") and closing (")") brackets, such that it is possible to obtain ... | {"inputs": ["(())", "(()())", "()", "((()))", "()(())", "()()()", "(())(())", "()()()()()()()()()()()(())", "()(())()((()))", "()()(())()(())", "()()()()()()()()()()()()()()()()", "(()()())", "()(()())()", "(())()(())()", "()()(()())(())()()()", "()()()((((())))())()()()()()((()))()()(())()(((())))()(()())((())())((()(... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 5 | codeforces | Okay, so I have this programming problem to solve, and I need to think through how to approach it. Let's start by understanding the problem carefully.
The problem says that we're given a correct bracket sequence. We need to color some of the brackets such that three conditions are met. Let's break down those condition... | To solve this problem, we need to determine the number of valid ways to color a correct bracket sequence such that each pair of matching brackets has exactly one colored bracket, and no two adjacent colored brackets have the same color. The result should be computed modulo \(10^9 + 7\).
### Approach
1. **Preprocessing... | false | Code is incorrect. | |
a59b13d5653d4598ad0c3212f76b67ab | Mashmokh and ACM | Mashmokh's boss, Bimokh, didn't like Mashmokh. So he fired him. Mashmokh decided to go to university and participate in ACM instead of finding a new job. He wants to become a member of Bamokh's team. In order to join he was given some programming tasks and one week to solve them. Mashmokh is not a very experienced prog... | {"inputs": ["3 2", "6 4", "2 1", "1478 194", "1415 562", "1266 844", "680 1091", "1229 1315", "1766 1038", "1000 1", "2000 100", "1 1", "2000 1000", "1928 1504", "2000 2000", "29 99", "56 48", "209 370", "83 37", "49 110", "217 3", "162 161", "273 871", "43 1640", "1472 854", "1639 1056", "359 896", "1544 648", "436 13... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 79 | codeforces | Okay, let's tackle this problem. The task is to find the number of good sequences of length k where each element divides the next one. The sequences must be non-decreasing and all elements are between 1 and n inclusive. The result needs to be modulo 1e9+7.
Hmm, first, I need to understand what a 'good' sequence is. Oh... | To solve this problem, we need to count the number of good sequences of length \( k \) where each element divides the next and all elements are between 1 and \( n \). The result should be computed modulo \( 10^9 + 7 \).
### Approach
1. **Dynamic Programming (DP) Setup**: Use a 2D array `dp` where `dp[i][j]` represents... | true | ||
a5a3bb978243d6aaa482cd809f293382 | Ilya and Sticks | In the evening, after the contest Ilya was bored, and he really felt like maximizing. He remembered that he had a set of *n* sticks and an instrument. Each stick is characterized by its length *l**i*.
Ilya decided to make a rectangle from the sticks. And due to his whim, he decided to make rectangles in such a way tha... | {"inputs": ["4\n2 4 4 2", "4\n2 2 3 5", "4\n100003 100004 100005 100006", "8\n5 3 3 3 3 4 4 4", "10\n123 124 123 124 2 2 2 2 9 9", "8\n10 10 10 10 11 10 11 10", "1\n1000000", "10\n10519 10519 10520 10520 10520 10521 10521 10521 10522 10523", "100\n4116 4116 4117 4117 4117 4117 4118 4119 4119 4119 4119 4120 4120 4120 41... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 53 | codeforces | Okay, I need to solve this problem where I have to find the maximum total area of rectangles that Ilya can make using his sticks. The sticks can be shortened by at most 1 unit each. Let's think through this step by step.
First, let's understand the problem. We need to form as many rectangles as possible, and each rect... | To solve this problem, we need to determine the maximum total area of rectangles that can be formed using a given set of sticks. Each stick can be reduced by at most 1 unit in length. The goal is to maximize the area by forming valid rectangles, each consisting of two pairs of equal-length sticks.
### Approach
1. **So... | true | ||
a5bae04f5bb19ba1e9501f2a8499e803 | Number of Ways | You've got array *a*[1],<=*a*[2],<=...,<=*a*[*n*], consisting of *n* integers. Count the number of ways to split all the elements of the array into three contiguous parts so that the sum of elements in each part is the same.
More formally, you need to find the number of such pairs of indices *i*,<=*j* (2<=≤<=*i*<=≤<=... | {"inputs": ["5\n1 2 3 0 3", "4\n0 1 -1 0", "2\n4 1", "9\n0 0 0 0 0 0 0 0 0", "10\n2 5 -2 2 -3 -2 3 5 -5 -2", "1\n1", "3\n1 2 3", "100\n1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 103 | codeforces | Okay, let's see. I need to solve this problem where I have to count the number of ways to split an array into three contiguous parts with equal sums. The problem says that the array is non-decreasing, but wait, the input description actually says "You've got array a[1] <= a[2] <= ... <= a[n], consisting of n integers."... | To solve this problem, we need to count the number of ways to split an array into three contiguous parts such that each part has the same sum. The solution involves checking for valid splits by leveraging prefix and suffix sums and efficiently counting valid indices using binary search.
### Approach
1. **Check Divisib... | true | ||
a5e4fdeedafed69e2a72d16220c9c4f7 | Inna and Pink Pony | Dima and Inna are doing so great! At the moment, Inna is sitting on the magic lawn playing with a pink pony. Dima wanted to play too. He brought an *n*<=×<=*m* chessboard, a very tasty candy and two numbers *a* and *b*.
Dima put the chessboard in front of Inna and placed the candy in position (*i*,<=*j*) on the board.... | {"inputs": ["5 7 1 3 2 2", "5 5 2 3 1 1", "1 1 1 1 1 1", "23000 15500 100 333 9 1", "33999 99333 33000 99000 3 9", "5 7 1 3 1 2", "1 100 1 50 1 50", "1000 1 1 1 1 500", "304 400 12 20 4 4", "1000000 1000000 1000000 1000000 1000000 1000000", "1000000 99999 12345 23456 23 54", "50000 100000 500 1000 500 1000", "50000 100... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 8 | codeforces | Okay, let's tackle this problem. So, the task is to find the minimum number of moves required to get the candy from the starting position to one of the four corners of the chessboard using the given move types. If it's not possible, we output the poor message.
Hmm. Let's think about the moves. Each move can be in four... | To solve this problem, we need to determine the minimum number of moves required to move a candy from its initial position on a chessboard to one of the four corners using specific move types. Each move changes the position by ±a in the row and ±b in the column. If it's impossible to reach any corner, we return a speci... | false | Code is incorrect. | |
a605b693f3432e792d6baf61b184cb2d | Fish | *n* fish, numbered from 1 to *n*, live in a lake. Every day right one pair of fish meet, and the probability of each other pair meeting is the same. If two fish with indexes i and j meet, the first will eat up the second with the probability *a**ij*, and the second will eat up the first with the probability *a**ji*<==<... | {"inputs": ["2\n0 0.5\n0.5 0", "4\n0 0.5 0.5 0.5\n0.5 0 0.5 0.5\n0.5 0.5 0 0.5\n0.5 0.5 0.5 0", "5\n0 1 1 1 1\n0 0 0.5 0.5 0.5\n0 0.5 0 0.5 0.5\n0 0.5 0.5 0 0.5\n0 0.5 0.5 0.5 0", "1\n0.000", "2\n0.000 0.551\n0.449 0.000", "3\n0.000 0.817 0.584\n0.183 0.000 0.665\n0.416 0.335 0.000", "4\n0.000 0.083 0.548 0.503\n0.917 ... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 9 | codeforces | Okay, let's see. So the problem is about fish in a lake. Each day, two fish meet, and one eats the other with certain probabilities. This continues until only one fish remains. We need to calculate the probability that each fish is the last one surviving.
Hmm. The input gives the matrix a where a_ij is the probability... | To solve this problem, we need to determine the probability that each fish will survive to be the last one in the lake. The solution involves simulating all possible encounters between fish using dynamic programming (DP) with bitmasking to efficiently track the state of the lake.
### Approach
1. **Bitmask Representati... | false | Code is incorrect. | |
a619d42eed633f3050df62f94d10b7c1 | King's Path | The black king is standing on a chess field consisting of 109 rows and 109 columns. We will consider the rows of the field numbered with integers from 1 to 109 from top to bottom. The columns are similarly numbered with integers from 1 to 109 from left to right. We will denote a cell of the field that is located in the... | {"inputs": ["5 7 6 11\n3\n5 3 8\n6 7 11\n5 2 5", "3 4 3 10\n3\n3 1 4\n4 5 9\n3 10 10", "1 1 2 10\n2\n1 1 3\n2 6 10", "9 8 7 8\n9\n10 6 6\n10 6 6\n7 7 8\n9 5 6\n8 9 9\n9 5 5\n9 8 8\n8 5 6\n9 10 10", "6 15 7 15\n9\n6 15 15\n7 14 14\n6 15 15\n9 14 14\n7 14 16\n6 15 15\n6 15 15\n7 14 14\n8 15 15", "13 16 20 10\n18\n13 16 1... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 68 | codeforces | Okay, so I need to solve this programming problem where a king is moving on a chessboard made of allowed cells. The goal is to find the minimum number of moves from the starting position to the target. If there's no path, return -1. Let's break this down.
First, the chessboard is huge (1e9x1e9), but the allowed cells ... | To solve this problem, we need to determine the minimum number of moves a king needs to travel from a starting position to a target position on a chessboard, moving only through allowed cells. The allowed cells are provided in segments, and the chessboard is extremely large, so we need an efficient way to handle these ... | true | ||
a645e12baf8641d60fc64287c60ce752 | Trains | Vasya the programmer lives in the middle of the Programming subway branch. He has two girlfriends: Dasha and Masha, who live at the different ends of the branch, each one is unaware of the other one's existence.
When Vasya has some free time, he goes to one of his girlfriends. He descends into the subway at some time,... | {"inputs": ["3 7", "5 3", "2 3", "31 88", "8 75", "32 99", "77 4", "27 1", "84 11", "4 6", "52 53", "397 568", "22 332", "419 430", "638 619", "393 325", "876 218", "552 551", "906 912", "999 996", "652 653", "3647 7698", "2661 8975", "251 9731", "9886 8671", "8545 7312", "4982 2927", "7660 7658", "9846 9844", "9632 96... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 91 | codeforces | Okay, I need to solve this problem where Vasya is choosing between two subway trains. Let's read the problem statement carefully.
So the problem is about determining which girlfriend (Dasha or Masha) Vasya will visit more often based on the train schedules. The trains for Dasha come every 'a' minutes, and for Masha ev... | To solve this problem, we need to determine which girlfriend Vasya will visit more frequently based on the train schedules. The trains for Dasha come every `a` minutes, and for Masha every `b` minutes. If both trains arrive at the same time, Vasya chooses the direction with the lower frequency (longer interval).
### A... | true | ||
a64bde11b9445dc1e39be04d2fceef00 | Modified GCD | Well, here is another math class task. In mathematics, GCD is the greatest common divisor, and it's an easy task to calculate the GCD between two positive integers.
A common divisor for two positive numbers is a number which both numbers are divisible by.
But your teacher wants to give you a harder task, in this task... | {"inputs": ["9 27\n3\n1 5\n10 11\n9 11", "48 72\n2\n8 29\n29 37", "90 100\n10\n51 61\n6 72\n1 84\n33 63\n37 69\n18 21\n9 54\n49 90\n14 87\n37 90", "84 36\n1\n18 32", "90 36\n16\n13 15\n5 28\n11 30\n26 35\n2 8\n19 36\n3 17\n5 14\n4 26\n22 33\n16 33\n18 27\n4 17\n1 2\n29 31\n18 36", "84 90\n18\n10 75\n2 40\n30 56\n49 62\... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 62 | codeforces | Okay, I need to solve this problem where for each query, I have to find the greatest common divisor (GCD) of a and b that falls within a given range [low, high]. If there's none, output -1. Let's think about how to approach this.
First, the basic idea is that any common divisor of a and b must be a divisor of their GC... | To solve this problem, we need to determine the greatest common divisor (GCD) of two integers that falls within a specified range for multiple queries. The solution involves computing the GCD of the two integers, generating all divisors of this GCD, and efficiently checking each query to find the largest valid divisor ... | true | ||
a65a8ddec22e98a4bdf4fef23ccebc2e | Animals | Once upon a time DravDe, an outstanding person famous for his professional achievements (as you must remember, he works in a warehouse storing Ogudar-Olok, a magical but non-alcoholic drink) came home after a hard day. That day he had to drink 9875 boxes of the drink and, having come home, he went to bed at once.
Drav... | {"inputs": ["3 4\n1 1 1", "3 6\n1 1 1", "1 12\n1", "3 100\n1 1 1", "5 75\n1 1 1 1 1", "7 115\n1 1 1 1 1 1 1", "10 1055\n7 1 1 2 8 7 8 2 5 8", "7 3623\n20 14 24 4 14 14 24", "10 3234\n24 2 28 18 6 15 31 2 28 16", "15 402\n3 3 3 3 2 2 3 3 3 3 3 3 2 2 1", "25 5523\n24 29 6 35 11 7 24 10 17 43 2 25 15 36 31 8 22 40 23 23 7... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 23 | codeforces | Okay, let's try to understand the problem here. So, we need to find the maximum number of animals that can be on the farm by the end of day n, such that all of them are fed every day from their arrival day until day n, and the total food consumed doesn't exceed X. The key is to select a subset of the animals (each arri... | To solve this problem, we need to determine the maximum number of animals that can be accommodated on DravDe's farm without any animal going hungry, given a fixed initial amount of food. Each animal arrives on a specific day and consumes a certain amount of food daily from its arrival day until the end of the dream.
#... | true | ||
a67247ddc642337fb665ffad33a5c619 | Lunch Rush | Having written another programming contest, three Rabbits decided to grab some lunch. The coach gave the team exactly *k* time units for the lunch break.
The Rabbits have a list of *n* restaurants to lunch in: the *i*-th restaurant is characterized by two integers *f**i* and *t**i*. Value *t**i* shows the time the Rab... | {"inputs": ["2 5\n3 3\n4 5", "4 6\n5 8\n3 6\n2 3\n2 2", "1 5\n1 7", "4 9\n10 13\n4 18\n13 3\n10 6", "1 1\n1 1000000000", "1 1\n1000000000 1000000000", "1 1\n1000000000 1", "2 3\n1000000000 1\n2 2", "2 5\n1 7\n1 1000000000"], "outputs": ["4", "3", "-1", "13", "-999999998", "1", "1000000000", "1000000000", "-1"]} | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 208 | codeforces | Okay, let's tackle this problem. So, the task is to find the maximum joy the rabbits can get by choosing exactly one restaurant. Hmm. Let's read the problem statement again carefully.
The key points are: each restaurant has f_i and t_i. The joy from restaurant i depends on whether t_i is greater than the allowed time ... | To solve this problem, we need to determine the maximum joy the Rabbits can get from visiting exactly one restaurant during their lunch break. The joy from each restaurant depends on whether the time required for lunch at the restaurant exceeds the allowed time given by the coach.
### Approach
1. **Input Reading**: Re... | true | ||
a67a70733c91214a0387239b6c5f3b0b | The Great Game | Two teams meet in The Game World Championship. Some scientists consider this game to be the most intellectually challenging game in the world. You are given two strings describing the teams' actions in the final battle. Figure out who became the champion.
The input contains two strings of equal length (between 2 and 20... | {"inputs": ["[]()[]8<\n8<[]()8<", "8<8<()\n[]8<[]", "()\n[]", "()\n8<", "8<\n[]", "[]8<()()()()8<8<8<[]\n()()[][][]8<[]()8<8<", "()[]()()()\n[]()[][]8<", "()\n8<", "()[][]()()[][]()8<8<\n8<[]()()()8<[][]()()", "()[][]8<\n8<()8<()", "8<()8<8<8<8<()8<\n[]()()8<()[][][]", "[][]8<8<8<8<\n8<[][]()8<()", "[]\n()", "8<8<8<[]\... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 18 | codeforces | Okay, let's see. I need to solve this problem where two teams have actions in a game, and based on those actions, determine which team wins. The input is two strings of equal length. Each character represents an action. The output depends on comparing the actions of each team at each position and determining which team... | To solve this problem, we need to determine the winner of a game between two teams based on their actions in a final battle. The actions are described by two strings of equal length, and each character in these strings represents a specific action. The winner is determined by comparing the actions of the teams at each ... | false | Code is incorrect. | |
a6836333c0cd74c9f9fb81e34f53cab5 | Testing Robots | The Cybernetics Failures (CF) organisation made a prototype of a bomb technician robot. To find the possible problems it was decided to carry out a series of tests. At the beginning of each test the robot prototype will be placed in cell (*x*0,<=*y*0) of a rectangular squared field of size *x*<=×<=*y*, after that a min... | {"inputs": ["3 4 2 2\nUURDRDRL", "2 2 2 2\nULD", "1 1 1 1\nURDLUURRDDLLURDL", "15 17 8 9\nURRDLUULLDD", "15 17 8 9\nURRDLUULLDDDRRUR", "15 17 8 9\nURRDLUULLDDDRRURR", "1 2 1 1\nR", "2 1 1 1\nD", "1 2 1 2\nLR", "2 1 2 1\nUD", "4 4 2 2\nDRUL", "4 4 3 3\nLUDRUL", "15 17 8 9\nURRDLU", "15 17 8 9\nURRDLUULLDDR", "15 17 8 9\... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 31 | codeforces | Okay, let's try to understand this problem. So, the task is to determine for each k from 0 to the length of the command string s, how many tests (mine positions) would result in the robot exploding exactly after k steps.
The robot starts at (x0, y0), and in each test, a mine is placed in a unique cell (all cells are ... | To solve this problem, we need to predict the results of a series of tests conducted on a bomb technician robot. The robot moves on a grid based on a sequence of commands, and we need to determine how many tests result in the robot exploding after exactly k commands for each k from 0 to the length of the command sequen... | true | ||
a6be5c5b3f940ae34740357bd4512ea4 | Petya and Strings | Little Petya loves presents. His mum bought him two strings of the same size for his birthday. The strings consist of uppercase and lowercase Latin letters. Now Petya wants to compare those two strings lexicographically. The letters' case does not matter, that is an uppercase letter is considered equivalent to the corr... | {"inputs": ["aaaa\naaaA", "abs\nAbz", "abcdefg\nAbCdEfF", "asadasdasd\nasdwasdawd", "aslkjlkasdd\nasdlkjdajwi", "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\naaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "aAaaaAAaAaaAzZsssSsdDfeEaeqZlpP\nAaaaAaaAaaAaZzSSSSsDdFeeAeQZLpp", "bwuEhEveouaTECagLZiqmUdxEmhRSOzMauJRWLQMppZOumxhAmwuG... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 534 | codeforces | Okay, let's tackle this problem. So, the task is to compare two strings lexicographically, but case-insensitive. Hmm. Right, lexicographic order is like dictionary order. But since the case doesn't matter, we need to compare each character in the same case.
First, I need to read two input strings. Oh right, each of t... | To solve this problem, we need to compare two strings lexicographically in a case-insensitive manner. The goal is to determine if the first string is less than, greater than, or equal to the second string, ignoring case differences.
### Approach
1. **Input Reading**: Read the two input strings from standard input.
2. ... | true | ||
a6c0ec0f94b080801d3e32b45ed8ec9c | How Many Squares? | You are given a 0-1 rectangular matrix. What is the number of squares in it? A square is a solid square frame (border) with linewidth equal to 1. A square should be at least 2<=×<=2. We are only interested in two types of squares:
1. squares with each side parallel to a side of the matrix; 1. squares with each side... | {"inputs": ["2\n8 8\n00010001\n00101000\n01000100\n10000010\n01000100\n00101000\n11010011\n11000011\n10 10\n1111111000\n1000001000\n1011001000\n1011001010\n1000001101\n1001001010\n1010101000\n1001001000\n1000001000\n1111111000", "1\n12 11\n11111111111\n10000000001\n10111111101\n10100000101\n10101100101\n10101100101\n10... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 1 | codeforces | Okay, let's tackle this problem. Hmm, the task is to count the number of valid squares in a given binary matrix. The squares can be of two types: those with sides parallel to the matrix edges (like axis-aligned) and those with sides parallel to the diagonals (like rotated 45 degrees). But there are several constraints.... | To solve this problem, we need to count the number of valid squares in a binary matrix. The squares can be of two types: axis-aligned squares (sides parallel to the matrix edges) and diagonal-aligned squares (sides parallel to the matrix diagonals). Each valid square must be a solid frame (border) of 1's with linewidth... | true | ||
a6c41ea9c9ce50b21113df8a612d7106 | Nearest Minimums | You are given an array of *n* integer numbers *a*0,<=*a*1,<=...,<=*a**n*<=-<=1. Find the distance between two closest (nearest) minimums in it. It is guaranteed that in the array a minimum occurs at least two times.
The first line contains positive integer *n* (2<=≤<=*n*<=≤<=105) — size of the given array. The second l... | {"inputs": ["2\n3 3", "3\n5 6 5", "9\n2 1 3 5 4 1 2 3 1", "6\n4 6 7 8 6 4", "2\n1000000000 1000000000", "42\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", "2\n10000000 10000000", "5\n100000000 100000001 100000000 100000001 100000000", "9\n4 3 4 3 4 1 3 3 1", "3\n10000000 10000000... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 217 | codeforces | Okay, I need to solve this problem where I have to find the distance between the two closest minimums in an array. Let's see. The problem says the array is already given, and there are at least two minimums. The distance is the difference in their indices, right?
Wait, right. The distance between two elements is the a... | To solve this problem, we need to determine the minimum distance between two consecutive occurrences of the smallest element in an array. The approach involves identifying the positions of the minimum elements and then calculating the shortest distance between consecutive positions.
### Approach
1. **Identify the Mini... | true | ||
a6cab46b8ce1e78c5fa12073774b1b7d | Alyona and Strings | After returned from forest, Alyona started reading a book. She noticed strings *s* and *t*, lengths of which are *n* and *m* respectively. As usual, reading bored Alyona and she decided to pay her attention to strings *s* and *t*, which she considered very similar.
Alyona has her favourite positive integer *k* and bec... | {"inputs": ["3 2 2\nabc\nab", "9 12 4\nbbaaababb\nabbbabbaaaba", "11 11 4\naaababbabbb\nbbbaaaabaab", "15 9 4\nababaaabbaaaabb\nbbaababbb", "2 7 1\nbb\nbbaabaa", "13 4 3\nabbaababaaaab\naaab", "2 3 2\nab\naab", "13 9 1\noaflomxegekyv\nbgwwqizfo", "5 9 1\nbabcb\nabbcbaacb", "8 12 2\nbccbbaac\nabccbcaccaaa", "11 2 2\nbcb... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 2 | codeforces | Okay, I need to solve this problem where Alyona wants to find k disjoint substrings in both s and t, in the same order, and maximize their total length. Let's think about how to approach this.
First, let's understand the problem. We have two strings, s and t. We need to select k non-overlapping substrings from s, such... | To solve this problem, we need to find k non-overlapping substrings in both strings s and t such that these substrings appear in the same order in both strings and their combined length is maximized. This problem can be efficiently tackled using dynamic programming (DP) with a precomputed longest common substring (LCS)... | false | Code is incorrect. | |
a6dbb69f10ce63f83e7b2804af0bd856 | The Golden Age | Unlucky year in Berland is such a year that its number *n* can be represented as *n*<==<=*x**a*<=+<=*y**b*, where *a* and *b* are non-negative integer numbers.
For example, if *x*<==<=2 and *y*<==<=3 then the years 4 and 17 are unlucky (4<==<=20<=+<=31, 17<==<=23<=+<=32<==<=24<=+<=30) and year 18 isn't unlucky as the... | {"inputs": ["2 3 1 10", "3 5 10 22", "2 3 3 5", "2 2 1 10", "2 2 1 1000000", "2 2 1 1000000000000000000", "2 3 1 1000000", "2 3 1 1000000000000000000", "12345 54321 1 1000000", "54321 12345 1 1000000000000000000", "2 3 100000000 1000000000000", "2 14 732028847861235712 732028847861235712", "14 2 732028847861235713 7320... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 93 | codeforces | Okay, let's see. The problem is about finding the longest consecutive period (Golden Age) within the interval [l, r] where none of the years are unlucky. Unlucky years are those that can be expressed as x^a + y^b, where a and b are non-negative integers. So, my task is to compute all possible unlucky years in the [l, r... | To solve this problem, we need to determine the longest consecutive period (Golden Age) within a given interval [l, r] where none of the years are considered unlucky. A year is deemed unlucky if it can be expressed as the sum of two non-negative integer powers of given values x and y.
### Approach
1. **Generate Possi... | true | ||
a70764fb4fd16794e40aeac14235d364 | Berland National Library | Berland National Library has recently been built in the capital of Berland. In addition, in the library you can take any of the collected works of Berland leaders, the library has a reading room.
Today was the pilot launch of an automated reading room visitors' accounting system! The scanner of the system is installed... | {"inputs": ["6\n+ 12001\n- 12001\n- 1\n- 1200\n+ 1\n+ 7", "2\n- 1\n- 2", "2\n+ 1\n- 1", "5\n+ 1\n- 1\n+ 2\n+ 3\n- 4", "3\n- 1\n- 2\n- 3", "4\n+ 1\n+ 2\n- 1\n+ 3", "6\n+ 1\n+ 2\n- 1\n+ 3\n- 2\n+ 4", "3\n+ 1\n+ 2\n- 3", "3\n- 1\n+ 2\n- 2", "4\n- 1\n- 2\n+ 3\n+ 4", "1\n+ 1", "1\n- 1", "3\n- 1\n+ 1\n- 1", "10\n+ 1\n+ 2\n+ ... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 37 | codeforces | Okay, let's see. I need to find the minimum possible capacity of the reading room based on the log entries. Hmm. So the problem is to determine the maximum number of people that must have been present in the room at any given time, considering that some people might have been there before the system started logging, an... | To solve this problem, we need to determine the minimum possible capacity of the reading room based on the log entries from an automated system. The log records events of readers entering or leaving the room, and we need to account for the possibility that some readers might have been present before the system started ... | true | ||
a7154105f6f9c9c7b051cbe3640e655a | Mobile Communications | A sum of *p* rubles is charged from Arkady's mobile phone account every day in the morning. Among the following *m* days, there are *n* days when Arkady will top up the account: in the day *d**i* he will deposit *t**i* rubles on his mobile phone account. Arkady will always top up the account before the daily payment wi... | {"inputs": ["3 6 7\n2 13\n4 20\n7 9", "5 4 100\n10 70\n15 76\n21 12\n30 100\n67 85", "14 25 100\n1 209\n2 224\n3 58\n4 31\n5 135\n6 16\n7 130\n8 113\n9 230\n10 60\n11 209\n12 185\n13 118\n14 16", "1 1 1\n1 1", "1 2 1\n1 1", "1 2 1\n1 3", "1 1000000000 1\n1 1000000000", "1 100000000 1\n1 99999999", "10 1 10\n1 100000000... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 6 | codeforces | Okay, let's see. I need to solve this problem where Arkady's phone account balance is tracked over m days. Each day, there's a payment of p rubles in the morning. But before that payment, there might be a top-up on certain days. The goal is to find out how many days end up with a negative balance after the payment.
Hm... | To solve this problem, we need to determine the number of days within a given period where Arkady's mobile phone account balance becomes negative after the daily payment. The challenge is to efficiently compute this without iterating each day individually, given the constraints that the number of days can be very large... | false | Code is incorrect. | |
a7575a52a521f677485b619b19b3277a | Toy Army | The hero of our story, Valera, and his best friend Arcady are still in school, and therefore they spend all the free time playing turn-based strategy "GAGA: Go And Go Again". The gameplay is as follows.
There are two armies on the playing field each of which consists of *n* men (*n* is always even). The current playe... | {"inputs": ["2", "4", "6", "8", "10", "140", "500", "1000", "2000", "50000", "10000", "25460", "54646", "59790", "578456", "56798056", "8457980", "5687986", "10984932", "99999994", "99999996", "99999998", "100000000"], "outputs": ["3", "6", "9", "12", "15", "210", "750", "1500", "3000", "75000", "15000", "38190", "8196... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 270 | codeforces | Okay, let's try to figure out this problem. So the problem is about a game where two players, Valera and Arcady, take turns attacking each other's soldiers. The game has three steps: Valera goes first, then Arcady, then Valera again. Each time a player attacks, all their soldiers shoot their targets simultaneously. The... | To solve this problem, we need to determine the maximum number of soldiers that can be killed in a turn-based strategy game played by Valera and Arcady over three turns. The game starts with Valera's turn, followed by Arcady's turn, and ends with Valera's final turn. The goal is to maximize the total number of soldiers... | true | ||
a75c2796222c96034eb516cffb9cd766 | Yet Another Number Game | Since most contestants do not read this part, I have to repeat that Bitlandians are quite weird. They have their own jobs, their own working method, their own lives, their own sausages and their own games!
Since you are so curious about Bitland, I'll give you the chance of peeking at one of these games.
BitLGM and Bi... | {"inputs": ["2\n1 1", "2\n1 2", "3\n1 2 1", "2\n1 3", "2\n3 5", "2\n9 10", "2\n6 8", "3\n0 0 0", "2\n223 58", "2\n106 227", "2\n125 123", "3\n31 132 7", "2\n41 29", "3\n103 286 100", "3\n9 183 275", "3\n19 88 202", "3\n234 44 69", "3\n244 241 295", "1\n6", "1\n231", "2\n241 289", "2\n200 185", "2\n218 142", "3\n124 47 ... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 1 | codeforces | Okay, I need to solve this problem where two players take turns decreasing elements of an array, and the one who can't move loses. The problem is to determine who wins given the initial array, assuming both play optimally. Let's think through how to approach this.
First, the game rules: Each player can either subtract... | To solve this problem, we need to determine the winner of a game played between two players, BitLGM and BitAryo, given a sequence of non-negative integers. The players take turns to either decrease a single element by a positive integer or decrease all elements by the same positive integer. The player who cannot make a... | true | ||
a769601d5a0746ed3aedd5004fa7c43c | The Door Problem | Moriarty has trapped *n* people in *n* distinct rooms in a hotel. Some rooms are locked, others are unlocked. But, there is a condition that the people in the hotel can only escape when all the doors are unlocked at the same time. There are *m* switches. Each switch control doors of some rooms, but each door is control... | {"inputs": ["3 3\n1 0 1\n2 1 3\n2 1 2\n2 2 3", "3 3\n1 0 1\n3 1 2 3\n1 2\n2 1 3", "3 3\n1 0 1\n3 1 2 3\n2 1 2\n1 3", "11 10\n0 0 1 0 0 0 0 1 1 0 1\n3 2 3 11\n1 3\n2 6 7\n1 5\n1 11\n1 10\n5 4 6 8 9 10\n2 1 5\n1 7\n5 1 2 4 8 9", "10 9\n1 0 1 1 0 1 0 0 1 0\n4 2 3 9 10\n4 3 4 5 8\n2 1 6\n2 7 8\n1 7\n1 5\n1 10\n2 2 4\n3 1 6... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 13 | codeforces | Okay, let's see. The problem is about determining whether there's a way to toggle some switches so that all doors become unlocked. Each door is controlled by exactly two switches. So, each time you toggle a switch, it flips the state of all doors connected to it. The initial configuration of the doors is given. We need... | To solve this problem, we need to determine if there exists a way to toggle switches such that all doors in a hotel are unlocked simultaneously. Each door is controlled by exactly two switches, and toggling a switch changes the state of all doors it controls.
### Approach
1. **Problem Analysis**:
- Each door's sta... | true | ||
a776432a650f3bf651bc2f3fd6206d17 | Volatile Kite | You are given a convex polygon *P* with *n* distinct vertices *p*1,<=*p*2,<=...,<=*p**n*. Vertex *p**i* has coordinates (*x**i*,<=*y**i*) in the 2D plane. These vertices are listed in clockwise order.
You can choose a real number *D* and move each vertex of the polygon a distance of at most *D* from their original pos... | {"inputs": ["4\n0 0\n0 1\n1 1\n1 0", "6\n5 0\n10 0\n12 -4\n10 -8\n5 -8\n3 -4", "19\n449447997 711296339\n530233434 692216537\n535464528 613140435\n535533467 100893188\n530498867 -265063956\n519107979 -271820709\n482156929 -287792333\n-303730271 -287970295\n-416935204 -263348201\n-443613873 -249980523\n-453444829 -17390... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 23 | codeforces | Okay, so I need to find the maximum D such that no matter how the vertices of a convex polygon are moved by at most D units, the polygon remains convex. Hmm. Let's think about this.
First, the problem says that even after moving the vertices within distance D, the polygon must stay convex. So the worst-case scenario i... | To solve this problem, we need to determine the maximum distance \( D \) such that each vertex of a convex polygon can be moved by at most \( D \) units while ensuring the polygon remains convex. The solution involves analyzing the minimal distance from each vertex to the line formed by its adjacent vertices and using ... | false | Code is incorrect. | |
a797ac3b124c17d4c2c31ee0aba85c2c | The Way to Home | A frog lives on the axis *Ox* and needs to reach home which is in the point *n*. She starts from the point 1. The frog can jump to the right at a distance not more than *d*. So, after she jumped from the point *x* she can reach the point *x*<=+<=*a*, where *a* is an integer from 1 to *d*.
For each point from 1 to *n* ... | {"inputs": ["8 4\n10010101", "4 2\n1001", "8 4\n11100101", "12 3\n101111100101", "5 4\n11011", "5 4\n10001", "10 7\n1101111011", "10 9\n1110000101", "10 9\n1100000001", "20 5\n11111111110111101001", "20 11\n11100000111000011011", "20 19\n10100000000000000001", "50 13\n10011010100010100111010000010000000000010100000101"... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 553 | codeforces | Okay, let's see. The problem is about a frog trying to reach point n from point 1, jumping on lily pads. The frog can jump right with a distance up to d. We need to find the minimal number of jumps. If it's not possible, return -1.
Hmm, the input gives us the string s where each character represents if there's a lily ... | To solve this problem, we need to determine the minimal number of jumps a frog needs to reach home (position `n`) starting from position 1, given that the frog can jump a maximum distance of `d` and can only land on positions with lily flowers (denoted by '1' in the input string). If the frog cannot reach home, we shou... | true | ||
a7ac01ff36356b6ef5d9d6b3571169af | Approximating a Constant Range | When Xellos was doing a practice course in university, he once had to measure the intensity of an effect that slowly approached equilibrium. A good way to determine the equilibrium intensity would be choosing a sufficiently large number of consecutive data points that seems as constant as possible and taking their aver... | {"inputs": ["5\n1 2 3 3 2", "11\n5 4 5 5 6 7 8 8 8 7 6", "2\n3 2", "4\n1001 1000 1000 1001", "4\n1 1 2 3", "3\n1 2 1", "3\n1 2 3", "18\n10 9 8 7 6 5 4 3 2 1 2 3 4 5 6 7 8 9", "3\n1 2 2", "4\n10 9 10 9", "4\n4 3 2 3", "4\n8 8 7 7", "3\n99998 99999 100000", "3\n100000 99999 99998", "3\n1 1 1", "2\n99999 100000", "2\n1000... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 188 | codeforces | Okay, let's see. I need to find the longest almost constant range in a sequence of numbers. The definition of almost constant here is that the max and min in the range differ by at most 1. Hmm. So for each possible subarray, I need to check if the max and min are within 1. And find the longest such subarray.
The const... | To solve this problem, we need to find the longest almost constant range in a sequence of data points where the difference between consecutive points is at most 1. An almost constant range is defined as a subarray where the difference between the maximum and minimum values is at most 1.
### Approach
The solution uses ... | true | ||
a7b83f74c9b94bdf5a673fec7894c3ad | Down the Hatch! | Everybody knows that the Berland citizens are keen on health, especially students. Berland students are so tough that all they drink is orange juice!
Yesterday one student, Vasya and his mates made some barbecue and they drank this healthy drink only. After they ran out of the first barrel of juice, they decided to pl... | {"inputs": ["4\nabbba", "4\nabbab", "4\naaa", "4\naab", "4\naabaabbba", "6\naaaaaaaaaaaaaaaa", "7\nabbbaaabbbaaaab", "9\naaaabaaaaa", "4\na", "4\nb", "4\nab", "4\nbb", "4\naba", "4\nbbb", "4\nabab", "4\nabaa", "4\nabbbaaabba", "4\nababba", "4\naaaaaa", "5\nbbbbaabaaa", "2000\na", "2000\naabaaabaabababbbbbbabbbbb", "4\n... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 38 | codeforces | Okay, let's tackle this problem. Hmm. So the problem is about Vasya trying to maximize the number of glasses he drinks by choosing his actions optimally. The other players' actions are fixed. We need to find the maximum possible glasses he could have had.
First, let's understand the setup. The participants are sitting... | To solve this problem, we need to determine the maximum number of glasses of juice Vasya could have drunk if he played optimally. The key is to identify the optimal moves Vasya can make at his turns to maximize the number of times four consecutive moves are the same, leading to him drinking a glass of juice.
### Appro... | true | ||
a7b9003851fc4cb8632f1823cb585985 | Clear The Matrix | You are given a matrix *f* with 4 rows and *n* columns. Each element of the matrix is either an asterisk (*) or a dot (.).
You may perform the following operation arbitrary number of times: choose a square submatrix of *f* with size *k*<=×<=*k* (where 1<=≤<=*k*<=≤<=4) and replace each element of the chosen submatrix w... | {"inputs": ["4\n1 10 8 20\n***.\n***.\n***.\n...*", "7\n2 1 8 2\n.***...\n.***..*\n.***...\n....*..", "4\n10 10 1 10\n***.\n*..*\n*..*\n.***", "5\n4 3 4 4\n.....\n****.\n..***\n...**", "6\n15 3 18 16\n.*.***\n...**.\n*.....\n**..*.", "5\n2 1 2 1\n*.***\n***.*\n.*..*\n***..", "4\n2 23 19 1\n..**\n*...\n**.*\n.*.*", "4\n... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 1 | codeforces | Okay, I need to solve this programming problem. Let's read the problem carefully.
The problem says we have a matrix with 4 rows and n columns. Each cell is either a * or a . We can perform operations where we choose a square submatrix of size k x k (k can be 1,2,3,4) and replace all elements in it with dots. Each oper... | To solve this problem, we need to determine the minimum number of coins required to replace all asterisks (*) with dots (.) in a 4-row matrix using square submatrices of varying sizes. Each submatrix operation has a specific cost, and we can use any number of these operations to achieve our goal.
### Approach
The key ... | false | Code is incorrect. | |
a7f405ddb27670ecb47318df840304fc | Bus Video System | The busses in Berland are equipped with a video surveillance system. The system records information about changes in the number of passengers in a bus after stops.
If $x$ is the number of passengers in a bus just before the current bus stop and $y$ is the number of passengers in the bus just after current bus stop, th... | {"inputs": ["3 5\n2 1 -3", "2 4\n-1 1", "4 10\n2 4 1 2", "2 10\n-1 2", "3 4\n-3 -4 4", "10 1\n-1 -1 3 -4 2 3 0 -3 3 2", "5 21\n-3 2 -4 -1 -5", "5 9\n-2 -1 2 -1 -2", "8 7\n-5 0 -3 1 -1 5 0 -6", "3 4\n-2 -1 0", "1 1000000000\n0", "2 1000000000\n-1000000 -1000000", "2 1000000000\n1000000 -1000000", "2 1000000000\n-1000000... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 20 | codeforces | Okay, let's try to figure out how to solve this problem. So the problem is about determining the number of possible initial passenger counts in a bus such that after applying all the changes from the bus stops, the number of passengers never exceeds the capacity and never goes below zero. The capacity is given as w, wh... | To solve this problem, we need to determine the number of possible initial passenger counts in a bus such that after applying all the changes from the bus stops, the number of passengers never exceeds the bus capacity and never goes below zero.
### Approach
1. **Understand the Problem Constraints**: The bus has a capa... | true | ||
a81e7d7125035b8f7bdaadf1cc9b1c92 | ACM ICPC | In a small but very proud high school it was decided to win ACM ICPC. This goal requires to compose as many teams of three as possible, but since there were only 6 students who wished to participate, the decision was to build exactly two teams.
After practice competition, participant number *i* got a score of *a**i*. ... | {"inputs": ["1 3 2 1 2 1", "1 1 1 1 1 99", "1000 1000 1000 1000 1000 1000", "0 0 0 0 0 0", "633 609 369 704 573 416", "353 313 327 470 597 31", "835 638 673 624 232 266", "936 342 19 398 247 874", "417 666 978 553 271 488", "71 66 124 199 67 147", "54 26 0 171 239 12", "72 8 186 92 267 69", "180 179 188 50 75 214", "16... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 279 | codeforces | Okay, I need to solve this programming problem. Let's read the problem statement carefully.
The task is to determine if it's possible to split six students into two teams of three each such that the sum of the team scores is equal. Each team has exactly three members, and we have to use all six students. So the input ... | To solve this problem, we need to determine if it's possible to split six students into two teams of three members each such that both teams have equal total scores.
### Approach
1. **Sum Check**: First, check if the total sum of all six scores is even. If it's odd, it's immediately impossible to split them into two ... | true | ||
a83d76638f25ffd2fcd9c09cc652d2c2 | Artem and Array | Artem has an array of *n* positive integers. Artem decided to play with it. The game consists of *n* moves. Each move goes like this. Artem chooses some element of the array and removes it. For that, he gets *min*(*a*,<=*b*) points, where *a* and *b* are numbers that were adjacent with the removed number. If the number... | {"inputs": ["5\n3 1 5 2 6", "5\n1 2 3 4 5", "5\n1 100 101 100 1", "10\n96 66 8 18 30 48 34 11 37 42", "1\n87", "2\n93 51", "3\n31 19 5", "4\n86 21 58 60", "5\n21 6 54 69 32", "6\n46 30 38 9 65 23", "7\n82 60 92 4 2 13 15", "8\n77 84 26 34 17 56 76 3", "9\n72 49 39 50 68 35 75 94 56", "10\n4 2 2 4 1 2 2 4 2 1", "1\n4", ... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 3 | codeforces | Okay, let's see. The problem is about Artem removing elements from an array and getting points based on the minimum of the adjacent elements. The goal is to find the maximum possible points he can get after all n moves.
Hmm, let's start by understanding the problem step by step. Each time Artem removes an element, he ... | To solve this problem, we need to determine the maximum total points Artem can get by removing elements from an array in an optimal order. Each time an element is removed, points are awarded based on the minimum value of its adjacent elements, provided both neighbors exist.
### Approach
1. **Problem Analysis**: The ke... | false | Code is incorrect. | |
a84f6423a5d54508f5988f076c9607ab | Magical Array | Valery is very interested in magic. Magic attracts him so much that he sees it everywhere. He explains any strange and weird phenomenon through intervention of supernatural forces. But who would have thought that even in a regular array of numbers Valera manages to see something beautiful and magical.
Valera absolutel... | {"inputs": ["4\n2 1 1 4", "5\n-2 -2 -2 0 1", "1\n10", "2\n5 6", "5\n5 5 4 5 5", "8\n1 2 0 0 0 0 3 3", "12\n-4 3 3 2 3 3 3 -4 2 -4 -4 -4", "10\n7 1 0 10 0 -5 -3 -2 0 0", "20\n6 0 0 -3 1 -3 0 -8 1 3 5 2 -1 -5 -1 9 0 6 -2 4", "100\n0 -18 -9 -15 3 16 -28 0 -28 0 28 -20 -9 9 -11 0 18 -15 -18 -26 0 -27 -25 -22 6 -5 8 14 -17 ... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 96 | codeforces | Okay, so I need to find the number of magical subarrays in a given array. A magical subarray is one where all elements are the same, right? Because the min and max of the subarray have to be equal, which means all elements in the subarray are the same. Oh right, because if even one element is different, then the min an... | To solve this problem, we need to count the number of magical subarrays in a given array. A subarray is considered magical if all its elements are the same, which implies that the minimum and maximum values in the subarray are equal.
### Approach
1. **Identify Consecutive Elements**: The key insight is that a magical ... | true | ||
a850a1bcad64de860c139cea3c8ba010 | Zoo | The Zoo in the Grid Kingdom is represented by an infinite grid. The Zoo has *n* observation binoculars located at the *OX* axis. For each *i* between 1 and *n*, inclusive, there exists a single binocular located at the point with coordinates (*i*,<=0). There are *m* flamingos in the Zoo, located at points with positive... | {"inputs": ["5 5\n2 1\n4 1\n3 2\n4 3\n4 4", "3 3\n1 1\n2 10\n3 100", "1 2\n450000001 500000000\n900000001 1000000000", "3 6\n1 1\n1 2\n1 3\n2 1\n2 2\n3 1", "3 3\n227495634 254204506\n454991267 508409012\n715803819 799841973", "3 3\n96684705 23204141\n193369409 46408282\n217792636 52269809", "1000000 2\n136395332 110293... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 1 | codeforces | Okay, let's try to figure out this problem. So, we have these binoculars along the OX axis (which is the x-axis, I think), and each binocular is at (i, 0) for i from 1 to n. Then there are m flamingos at points with positive coordinates. Each binocular can be rotated to face a certain direction, which is a straight lin... | To solve this problem, we need to determine the maximum number of flamingos visible by each binocular located along the OX axis. The goal is to find the optimal angle for each binocular such that it can see the maximum number of flamingos, and then sum these maximum values for all binoculars.
### Approach
1. **Problem... | true | ||
a855c7679049814a0a06cbf78812c973 | Greg and Caves | Greg has a pad. The pad's screen is an *n*<=×<=*m* rectangle, each cell can be either black or white. We'll consider the pad rows to be numbered with integers from 1 to *n* from top to bottom. Similarly, the pad's columns are numbered with integers from 1 to *m* from left to right.
Greg thinks that the pad's screen di... | {"inputs": ["1 1", "4 4", "3 5", "5 3", "5 5", "7 8", "9 8", "10 10", "100 100", "100 110", "100 200", "1 1000", "1000 1", "1000 3", "3 1000", "10 1000", "10 500", "250 250", "500 1000", "1000 500", "1000 1000", "1 2", "2000 2000", "1500 2000", "2000 1777", "1999 1994", "1994 1995", "1 2000", "2000 1", "2 2000", "2000 ... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 1 | codeforces | Okay, so I need to solve this programming problem. Let's read the problem carefully and understand what's required.
The problem is about counting the number of ways to paint a grid as a "cave" according to Greg's conditions. Let's parse the conditions.
First, the cave conditions are:
1. There exists a segment [l, r]... | To solve this problem, we need to determine the number of ways to paint a grid such that it forms a "cave" structure according to Greg's conditions. The solution involves dynamic programming (DP) with prefix sums to efficiently count valid configurations.
### Approach
1. **Problem Analysis**:
- A cave structure has... | false | Code is incorrect. | |
a8695a151c7d1fee85c1c1e62cc8f6c1 | Jeff and Furik | Jeff has become friends with Furik. Now these two are going to play one quite amusing game.
At the beginning of the game Jeff takes a piece of paper and writes down a permutation consisting of *n* numbers: *p*1, *p*2, ..., *p**n*. Then the guys take turns to make moves, Jeff moves first. During his move, Jeff chooses ... | {"inputs": ["2\n1 2", "5\n3 5 2 4 1", "16\n6 15 3 8 7 11 9 10 2 13 4 14 1 16 5 12", "9\n1 7 8 5 3 4 6 9 2", "5\n2 3 4 5 1", "9\n4 1 8 6 7 5 2 9 3", "10\n3 4 1 5 7 9 8 10 6 2", "13\n3 1 11 12 4 5 8 10 13 7 9 2 6", "10\n8 4 1 7 6 10 9 5 3 2", "2\n2 1", "95\n68 56 24 89 79 20 74 69 49 59 85 67 95 66 15 34 2 13 92 25 84 77... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 7 | codeforces | Okay, let's try to understand this problem. So Jeff and Furik are playing a game where they take turns swapping adjacent elements in a permutation. The goal is to reach a sorted permutation in increasing order. Jeff wants to minimize the expected number of moves they make. Jeff swaps optimally, while Furik's moves are ... | To solve this problem, we need to determine the minimum mathematical expectation of the number of moves in a game where Jeff and Furik take turns to sort a permutation. Jeff moves optimally to minimize the number of moves, while Furik's moves are probabilistic based on coin tosses.
### Approach
The key insight here i... | false | Code is incorrect. | |
a875c5dded52170798e08effa7cb6695 | Vasya and Socks | Vasya has *n* pairs of socks. In the morning of each day Vasya has to put on a pair of socks before he goes to school. When he comes home in the evening, Vasya takes off the used socks and throws them away. Every *m*-th day (at days with numbers *m*,<=2*m*,<=3*m*,<=...) mom buys a pair of socks to Vasya. She does it la... | {"inputs": ["2 2", "9 3", "1 2", "2 3", "1 99", "4 4", "10 2", "10 9", "100 100", "2 27", "99 100", "99 2", "100 3", "98 3", "4 4", "100 2", "62 4", "99 10", "100 5", "80 80", "95 16", "75 16", "99 74", "20 21", "52 96", "24 5"], "outputs": ["3", "13", "1", "2", "1", "5", "19", "11", "101", "2", "99", "197", "149", "14... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 468 | codeforces | Okay, let's see. I need to solve this problem where Vasya has a certain number of socks, and each day he uses a pair. Then, every m-th day, his mom buys him a new pair. The question is, how many days can he go consecutively before he runs out of socks?
Hmm. Let's think through the example. The first sample input is 2 ... | To solve this problem, we need to determine how many consecutive days Vasya can use his socks before he runs out, considering that his mom buys him a new pair every m-th day in the evening.
### Approach
1. **Initialization**: Start with the given number of pairs of socks, `n`, and the day interval `m` when new socks ... | true | ||
a8970e2b436e94ec4bcc241534b45bd6 | Tiling with Hexagons | Several ages ago Berland was a kingdom. The King of Berland adored math. That's why, when he first visited one of his many palaces, he first of all paid attention to the floor in one hall. The floor was tiled with hexagonal tiles.
The hall also turned out hexagonal in its shape. The King walked along the perimeter of ... | {"inputs": ["2 3 4", "2 2 2", "7 8 13", "14 7 75", "201 108 304", "999 998 996", "2 2 3", "2 3 2", "3 2 2", "2 3 3", "3 2 3", "3 3 2", "3 3 3", "4 5 3", "2 2 856", "2 986 2", "985 2 2", "2 958 983", "992 2 912", "789 894 2", "1000 1000 1000", "384 458 284", "709 14 290", "485 117 521", "849 333 102", "998 999 1000", "2... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 64 | codeforces | Okay, so I need to find the total number of hexagonal tiles in a hall that's shaped like a hexagon. The input gives me a, b, c, and the perimeter of the hall's six sides are arranged as a, b, c, a, b, c. The sample input is 2 3 4 and the output is 18. Hmm, how do I approach this?
First, I remember that a regular hexag... | To solve this problem, we need to determine the total number of hexagonal tiles in a hall shaped like a hexagon with sides given as \(a\), \(b\), \(c\), \(a\), \(b\), and \(c\). The solution involves using a mathematical formula derived from analyzing the structure of the hexagon.
### Approach
The key insight is to re... | true | ||
a89c8820cafbc7a9c6e3baacc9ad9840 | Wilbur and Points | Wilbur is playing with a set of *n* points on the coordinate plane. All points have non-negative integer coordinates. Moreover, if some point (*x*, *y*) belongs to the set, then all points (*x*', *y*'), such that 0<=≤<=*x*'<=≤<=*x* and 0<=≤<=*y*'<=≤<=*y* also belong to this set.
Now Wilbur wants to number the points i... | {"inputs": ["5\n2 0\n0 0\n1 0\n1 1\n0 1\n0 -1 -2 1 0", "3\n1 0\n0 0\n2 0\n0 1 2", "9\n0 0\n1 0\n2 0\n0 1\n1 1\n2 1\n1 2\n2 2\n0 2\n0 0 0 -1 -1 -2 1 1 2", "18\n0 0\n0 1\n0 2\n0 3\n0 4\n0 5\n0 6\n0 7\n0 8\n0 9\n0 10\n0 11\n0 12\n0 13\n0 14\n0 15\n0 16\n1 0\n0 1 2 3 4 5 6 7 8 9 -1 10 11 12 13 14 15 16", "1\n0 0\n0", "37\n... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 12 | codeforces | Okay, let's try to tackle this problem. So the problem is about finding an aesthetically pleasing numbering of points in a set such that each point's special value (which is y - x) matches the given sequence w_i when numbered. If such a numbering exists, we need to output YES along with the points in order; otherwise, ... | To solve this problem, we need to determine if there exists an aesthetically pleasing numbering of points in a set such that the special value (y - x) of each point matches a given sequence. The points must be ordered such that any point northeast of another point comes after it in the sequence.
### Approach
1. **Chec... | false | Code is incorrect. | |
a8b1aab3a22f8405c79e530a2a79375e | Christmas Spruce | Consider a rooted tree. A rooted tree has one special vertex called the root. All edges are directed from the root. Vertex *u* is called a child of vertex *v* and vertex *v* is called a parent of vertex *u* if there exists a directed edge from *v* to *u*. A vertex is called a leaf if it doesn't have children and has a ... | {"inputs": ["4\n1\n1\n1", "7\n1\n1\n1\n2\n2\n2", "8\n1\n1\n1\n1\n3\n3\n3", "3\n1\n1", "13\n1\n2\n2\n2\n1\n6\n6\n6\n1\n10\n10\n10", "7\n1\n2\n2\n1\n1\n1", "7\n1\n1\n1\n1\n2\n2", "8\n1\n1\n1\n1\n5\n5\n5", "9\n1\n1\n1\n1\n2\n6\n6\n6", "12\n1\n1\n1\n2\n5\n5\n5\n5\n1\n2\n2", "20\n1\n1\n1\n1\n2\n2\n2\n3\n3\n3\n4\n4\n4\n5\n5\... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 122 | codeforces | Okay, let's see. I need to check if a given rooted tree is a spruce. The definition says that every non-leaf vertex must have at least 3 leaf children. Hmm. So first, I need to figure out for each node whether it's a leaf or not. Then, for each non-leaf node, check if it has at least 3 leaves as children.
Wait, but ho... | To solve this problem, we need to determine if a given rooted tree is a spruce. A spruce tree is defined as a tree where every non-leaf vertex has at least 3 leaf children.
### Approach
1. **Input Reading**: Read the number of vertices and the parent-child relationships.
2. **Tree Construction**: Construct the tree u... | true | ||
a8b9f0bb25f28f00fcfd1efbbfb86d8e | Paper Work | Polycarpus has been working in the analytic department of the "F.R.A.U.D." company for as much as *n* days. Right now his task is to make a series of reports about the company's performance for the last *n* days. We know that the main information in a day report is value *a**i*, the company's profit on the *i*-th day. ... | {"inputs": ["11\n1 2 3 -4 -5 -6 5 -5 -6 -7 6", "5\n0 -1 100 -1 0", "1\n0", "1\n-1", "2\n0 0", "2\n-2 2", "2\n-2 -1", "12\n1 -12 -5 -8 0 -8 -1 -1 -6 12 -9 12", "4\n1 2 0 3", "4\n4 -3 3 3", "4\n0 -3 4 -3", "4\n-3 -2 4 -3", "4\n-3 -2 -1 -4", "5\n-2 -2 4 0 -1", "5\n-5 -3 -1 2 -1", "5\n-3 -2 -3 -2 -3", "10\n0 5 2 3 10 9 4 9... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 100 | codeforces | Okay, let's see. The problem is about grouping consecutive days into folders such that no folder has three or more days with a loss (a_i <=0). And we need to minimize the number of folders. Also, we have to output the sizes of each folder.
Hmm. So, the main constraint is that each folder can have at most two loss days... | To solve this problem, we need to group consecutive daily reports into folders such that no folder contains three or more days with losses (negative or zero profit). The goal is to minimize the number of folders used.
### Approach
1. **Problem Analysis**: We need to ensure that each folder contains at most two days wi... | false | Code is incorrect. | |
a8bdd009f7ce1f2f44c150ad8504bc9a | Lipshitz Sequence | A function is called Lipschitz continuous if there is a real constant *K* such that the inequality |*f*(*x*)<=-<=*f*(*y*)|<=≤<=*K*·|*x*<=-<=*y*| holds for all . We'll deal with a more... discrete version of this term.
For an array , we define it's Lipschitz constant as follows:
- if *n*<=<<=2, - if *n*<=≥<=2,... | {"inputs": ["10 4\n1 5 2 9 1 3 4 2 1 7\n2 4\n3 8\n7 10\n1 9", "7 6\n5 7 7 4 6 6 2\n1 2\n2 3\n2 6\n1 7\n4 7\n3 5", "2 2\n0 0\n1 2\n1 2", "2 2\n0 100000000\n1 2\n1 2", "4 6\n1 2 3 2\n1 2\n1 3\n1 4\n2 3\n2 4\n3 4", "3 6\n10 20 30\n1 2\n1 3\n2 3\n1 2\n2 3\n1 3", "3 6\n48261735 26888803 75904937\n1 2\n1 3\n2 3\n1 2\n2 3\n1 ... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 1 | codeforces | Okay, I need to solve this problem where for each query [l, r], I have to compute the sum of Lipschitz constants of all subarrays of the subarray h[l..r]. Let's understand the problem step by step.
First, what's the Lipschitz constant for a given array? The definition says that for an array with n < 2, the constant is... | To solve this problem, we need to determine the sum of Lipschitz constants for all subarrays of a given subarray from an array. The Lipschitz constant for a subarray is defined as the maximum absolute difference between consecutive elements in that subarray.
### Approach
1. **Understanding Lipschitz Constant**: The L... | true | ||
a8d9c374dc35bbbb2575ed30d529d3b7 | Little Elephant and Sorting | The Little Elephant loves sortings.
He has an array *a* consisting of *n* integers. Let's number the array elements from 1 to *n*, then the *i*-th element will be denoted as *a**i*. The Little Elephant can make one move to choose an arbitrary pair of integers *l* and *r* (1<=≤<=*l*<=≤<=*r*<=≤<=*n*) and increase *a**i*... | {"inputs": ["3\n1 2 3", "3\n3 2 1", "4\n7 4 1 47", "10\n1 2 3 4 5 6 7 8 9 1000000000", "10\n1000000000 1 1000000000 1 1000000000 1 1000000000 1 1000000000 1", "7\n47 47 47 47 47 47 48", "47\n479793446 951468508 89486286 338446715 32648506 624498057 608503040 669251062 922459299 753303599 15471514 633954104 726178809 25... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 54 | codeforces | Okay, let's tackle this problem. So the task is to find the minimum number of moves needed to turn an array into a non-decreasing one using specific operations. Each move allows us to select a range [l, r] and increase all elements in that range by 1. The goal is to figure out the least number of such operations requir... | To solve this problem, we need to determine the minimum number of operations required to convert an array into a non-decreasing order using specific range increment operations. Each operation allows us to select a contiguous subarray and increment each element by 1. The goal is to find the minimal number of such operat... | true | ||
a9142d7a0d07b86b7e2a3da2f1ed8549 | Rumor | Vova promised himself that he would never play computer games... But recently Firestorm — a well-known game developing company — published their newest game, World of Farcraft, and it became really popular. Of course, Vova started playing it.
Now he tries to solve a quest. The task is to come to a settlement named Ove... | {"inputs": ["5 2\n2 5 3 4 8\n1 4\n4 5", "10 0\n1 2 3 4 5 6 7 8 9 10", "10 5\n1 6 2 7 3 8 4 9 5 10\n1 2\n3 4\n5 6\n7 8\n9 10", "1 0\n0", "1 0\n1000000000", "2 0\n0 0", "2 0\n1000000000 0", "2 0\n0 1000000000", "2 0\n1000000000 1000000000", "2 1\n0 0\n1 2"], "outputs": ["10", "55", "15", "0", "1000000000", "0", "10000000... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 104 | codeforces | Okay, I need to solve this programming problem. Let's read the problem statement carefully.
So, the problem is about finding the minimum cost to spread a rumor to all characters in a city. The characters are connected via friendships, which form some kind of groups. The idea is that if you bribe one person in a group,... | To solve this problem, we need to determine the minimum amount of gold Vova needs to spend to ensure that every character in Overcity knows the rumor. The solution involves leveraging the friendships between characters to spread the rumor efficiently.
### Approach
1. **Problem Analysis**: Characters in Overcity form c... | true | ||
a9334ecfe4eda493c86d67d26b117c09 | Random Query | You are given an array *a* consisting of *n* positive integers. You pick two integer numbers *l* and *r* from 1 to *n*, inclusive (numbers are picked randomly, equiprobably and independently). If *l*<=><=*r*, then you swap values of *l* and *r*. You have to calculate the expected value of the number of unique elemen... | {"inputs": ["2\n1 2", "2\n2 2", "10\n9 6 8 5 5 2 8 9 2 2", "20\n49 33 9 8 50 21 12 44 23 39 24 10 17 4 17 40 24 19 27 21", "1\n1000000"], "outputs": ["1.500000", "1.000000", "3.100000", "7.010000", "1.000000"]} | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 8 | codeforces | Okay, let's see. I need to find the expected number of unique elements in a segment [l, r] of the array, where l and r are chosen uniformly at random from 1 to n, and then swapped if l > r. Hmm. So the first thing is to model how l and r are chosen. Since l and r are selected independently and uniformly, and then swapp... | To solve this problem, we need to calculate the expected number of unique elements in a randomly chosen segment of an array. The segment is defined by two indices \( l \) and \( r \), which are chosen uniformly at random from 1 to \( n \), and then swapped if \( l > r \). The solution involves leveraging the linearity ... | false | Code is incorrect. | |
a954c9b3c7a84fd96eda0a8f7520b89c | Painting Eggs | The Bitlandians are quite weird people. They have very peculiar customs.
As is customary, Uncle J. wants to have *n* eggs painted for Bitruz (an ancient Bitland festival). He has asked G. and A. to do the work.
The kids are excited because just as is customary, they're going to be paid for the job!
Overall uncle J.... | {"inputs": ["2\n1 999\n999 1", "3\n400 600\n400 600\n400 600", "2\n500 500\n500 500", "1\n1 999", "10\n1 999\n1 999\n1 999\n1 999\n1 999\n1 999\n1 999\n1 999\n1 999\n1 999", "2\n499 501\n501 499", "3\n500 500\n1 999\n400 600", "1\n0 1000", "1\n500 500", "1\n1000 0"], "outputs": ["AG", "AGA", "AG", "A", "AAAAAAAAAA", "A... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 3 | 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 assigning each egg to either A or G such that the absolute difference between the total paid to A and G is at most 500. The key constraints here are that for each egg, a_i + g_i = ... | To solve this problem, we need to distribute eggs between two children, A and G, such that the absolute difference between the total money paid to each child does not exceed 500. The key insight is that the difference in total payments depends only on the number of eggs assigned to each child, not on which specific egg... | false | Code is incorrect. | |
a979154b5b2a8175788285841d9e28d3 | Game With Sticks | After winning gold and silver in IOI 2014, Akshat and Malvika want to have some fun. Now they are playing a game on a grid made of *n* horizontal and *m* vertical sticks.
An intersection point is any point on the grid which is formed by the intersection of one horizontal stick and one vertical stick.
In the grid show... | {"inputs": ["2 2", "2 3", "3 3", "20 68", "1 1", "1 2", "1 3", "2 1", "2 2", "3 1", "3 2", "68 42", "1 35", "25 70", "59 79", "65 63", "46 6", "28 82", "98 98", "98 99", "98 100", "99 98", "99 99", "99 100", "100 98", "100 99", "100 100", "3 4"], "outputs": ["Malvika", "Malvika", "Akshat", "Malvika", "Akshat", "Akshat"... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 254 | codeforces | Okay, let's see. I need to solve this problem where two players take turns removing sticks from a grid. The loser is the one who can't make a move. The key is to determine who wins when both play optimally. Hmm.
So the grid is made of n horizontal sticks and m vertical sticks. Each intersection is a point where a hori... | To solve this problem, we need to determine the winner of a game played on a grid with `n` horizontal and `m` vertical sticks, where players take turns removing intersection points formed by these sticks. The player who cannot make a move loses. Both players play optimally.
### Approach
The key insight is that each mo... | true | ||
a9b139efa7de061f69403d9289843020 | Happy Farm 5 | The Happy Farm 5 creators decided to invent the mechanism of cow grazing. The cows in the game are very slow and they move very slowly, it can even be considered that they stand still. However, carnivores should always be chased off them.
For that a young player Vasya decided to make the shepherd run round the cows a... | {"inputs": ["4\n1 1\n5 1\n5 3\n1 3", "3\n0 0\n5 0\n0 5", "5\n0 0\n7 7\n7 5\n5 7\n1 1", "5\n1 0\n-1 0\n1 0\n-1 0\n0 0", "9\n1 0\n-1 0\n1 0\n-1 0\n0 0\n1 1\n-1 -1\n1 -1\n-1 1", "5\n-10 10\n-10 -10\n10 -10\n9 8\n1 2", "1\n7 -10", "3\n7 -10\n7 -10\n7 -10", "2\n-10 0\n-10 7", "5\n-10 0\n-10 7\n-10 0\n-10 7\n-10 0", "11\n0 0... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 1 | codeforces | Okay, let's try to figure out this problem. So, the task is to find the minimum number of moves a shepherd needs to make to run around all the cows in such a way that all cows are strictly inside the path. The movement is in 8 directions, so each step can be horizontal, vertical, or diagonal. The key points here are to... | To solve this problem, we need to determine the minimum number of moves a shepherd must make to run around a herd of cows such that all cows are strictly inside the path. The shepherd can move in eight directions (horizontal, vertical, or diagonal), and each move counts as one step regardless of direction.
### Approac... | false | Code is incorrect. | |
a9e7f39b20cf005323eea47e365c2890 | Encrypting Messages | The Smart Beaver from ABBYY invented a new message encryption method and now wants to check its performance. Checking it manually is long and tiresome, so he decided to ask the ABBYY Cup contestants for help.
A message is a sequence of *n* integers *a*1,<=*a*2,<=...,<=*a**n*. Encryption uses a key which is a sequence ... | {"inputs": ["4 3 2\n1 1 1 1\n1 1 1", "3 1 5\n1 2 3\n4", "5 2 7\n0 0 1 2 4\n3 5", "20 15 17\n4 9 14 11 15 16 15 4 0 10 7 12 10 1 8 6 7 14 1 13\n6 3 14 8 8 11 16 4 5 9 2 13 6 14 15", "80 6 99\n48 97 9 77 73 21 86 78 48 5 71 16 42 67 90 27 30 52 41 86 53 4 60 17 66 38 94 46 51 51 70 11 1 16 74 53 17 12 82 95 51 33 83 70 4... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 32 | codeforces | Okay, let's see. The problem is about encrypting a message by adding a key multiple times in different steps. Hmm, the input gives the message a, the key b, and we need to compute the encrypted message after all steps. The challenge is to do this efficiently, especially for large n and m where a naive approach would be... | To solve this problem, we need to efficiently compute the result of encrypting a message using a given key. The encryption process involves repeatedly adding the key to different segments of the message, which can be optimized using prefix sums to avoid a naive approach that would be too slow for large inputs.
### App... | true | ||
a9edd7e23c7a56dec735305f3eb667a2 | Cyclic Cipher | You are given *n* sequences. Each sequence consists of positive integers, not exceeding *m*. All integers in one sequence are distinct, but the same integer may appear in multiple sequences. The length of the *i*-th sequence is *k**i*.
Each second integers in each of the sequences are shifted by one to the left, i.e. ... | {"inputs": ["3 4\n3 3 4 1\n4 1 3 4 2\n3 3 1 4", "5 5\n2 3 1\n4 5 1 3 2\n4 2 1 3 5\n1 3\n2 5 3", "4 6\n3 4 5 3\n2 6 3\n2 3 6\n3 3 6 5", "10 5\n2 2 4\n2 4 5\n2 1 2\n4 3 1 5 2\n4 1 3 2 5\n5 3 4 5 2 1\n3 3 5 4\n1 1\n2 4 1\n1 5", "10 10\n2 1 5\n2 3 4\n4 7 1 10 4\n4 6 3 9 7\n2 3 5\n3 4 9 7\n3 6 5 9\n5 8 5 4 10 6\n3 5 7 1\n1 ... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 1 | codeforces | Okay, I need to solve this programming problem. Let's read the problem statement carefully.
The problem says we have n sequences. Each sequence is rotated every second. For each second, we take the first element of each sequence and write it to a new array. Then, for each x from 1 to m, find the longest consecutive se... | To solve this problem, we need to determine the longest consecutive segment of each integer from 1 to m in the array formed by taking the first element of each sequence every second for 10^100 seconds. The sequences are rotated left every second, so each element's position in the array is determined by its position in ... | false | Code is incorrect. | |
a9f1db41bf78794ebd59fce0b08f9ad0 | Expression | Petya studies in a school and he adores Maths. His class has been studying arithmetic expressions. On the last class the teacher wrote three positive integers *a*, *b*, *c* on the blackboard. The task was to insert signs of operations '+' and '*', and probably brackets between the numbers so that the value of the resul... | {"inputs": ["1\n2\n3", "2\n10\n3", "1\n1\n1", "1\n2\n1", "10\n10\n10", "5\n1\n3", "3\n1\n5", "6\n7\n1", "1\n8\n3", "9\n7\n2", "1\n1\n10", "9\n1\n1", "10\n5\n6", "8\n9\n7", "4\n2\n10", "2\n8\n3", "3\n5\n7", "1\n10\n1", "2\n2\n2", "5\n6\n1", "10\n1\n1", "1\n6\n1", "1\n9\n1", "2\n1\n2", "2\n6\n1", "9\n2\n1", "1\n9\n2", "1... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 341 | codeforces | Okay, let's see. So the problem is that we have three numbers a, b, c. We need to insert + or * between them, and possibly add brackets, to get the maximum possible result. But we can't reorder the numbers; they have to stay in a, b, c order. So the task is to find all possible valid expressions and compute their value... | To solve this problem, we need to determine the maximum value that can be obtained by inserting arithmetic operations (addition or multiplication) and parentheses between three given integers a, b, and c. The integers must remain in their original order, and we can use parentheses to change the order of operations.
##... | true | ||
aa0e79b94b0ba6e8643b2b44c935d9eb | Random Task | One day, after a difficult lecture a diligent student Sasha saw a graffitied desk in the classroom. She came closer and read: "Find such positive integer *n*, that among numbers *n*<=+<=1, *n*<=+<=2, ..., 2·*n* there are exactly *m* numbers which binary representation contains exactly *k* digits one".
The girl got int... | {"inputs": ["1 1", "3 2", "3 3", "1 11", "4 20", "45902564 24", "330 8", "10 10", "0 2", "1000000 55", "1 60", "1000000000 52", "101628400788615604 30", "101628400798615604 31", "55 55", "14240928 10", "1000000000 10", "1111111 11", "10000000000000000 35", "0 19", "768 10", "3691 6", "16 15", "427 4", "669 9", "0 16", ... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 2 | codeforces | Okay, let's try to figure out how to solve this problem. The problem is asking for a positive integer n such that exactly m numbers in the range [n, 2n] inclusive have exactly k ones in their binary representations. And we need to find such an n. Hmm.
First, I need to understand what the problem is exactly looking for... | To solve this problem, we need to find a positive integer \( n \) such that exactly \( m \) numbers in the range \([n, 2n-1]\) have exactly \( k \) ones in their binary representation. The solution involves efficiently counting numbers with a specific number of set bits and using binary search to determine the minimal ... | true | ||
aa3049696d389bffae6f06d2bf84bfeb | Liebig's Barrels | You have *m*<==<=*n*·*k* wooden staves. The *i*-th stave has length *a**i*. You have to assemble *n* barrels consisting of *k* staves each, you can use any *k* staves to construct a barrel. Each stave must belong to exactly one barrel.
Let volume *v**j* of barrel *j* be equal to the length of the minimal stave in it.
... | {"inputs": ["4 2 1\n2 2 1 2 3 2 2 3", "2 1 0\n10 10", "1 2 1\n5 2", "3 2 1\n1 2 3 4 5 6", "10 3 189\n267 697 667 4 52 128 85 616 142 344 413 660 962 194 618 329 266 593 558 447 89 983 964 716 32 890 267 164 654 71", "10 3 453\n277 706 727 812 692 686 196 507 911 40 498 704 573 381 463 759 704 381 693 640 326 405 47 834... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 63 | codeforces | Okay, let's tackle this programming problem. So, the problem is about selecting staves to form barrels in such a way that the sum of the volumes is maximized, while ensuring that the difference between any two barrels' volumes is at most l. Hmm.
Let me first understand the problem statement properly. So, each barrel i... | To solve this problem, we need to assemble exactly `n` barrels from `n * k` wooden staves such that the total volume of the barrels is maximized while ensuring that the difference between the volumes of any two barrels does not exceed `l`. The volume of a barrel is determined by the length of the shortest stave in it.
... | false | Code is incorrect. | |
aa38306070eb8e4093e1bf4283d68da4 | Bubble Sort Graph | Iahub recently has learned Bubble Sort, an algorithm that is used to sort a permutation with *n* elements *a*1, *a*2, ..., *a**n* in ascending order. He is bored of this so simple algorithm, so he invents his own graph. The graph (let's call it *G*) initially has *n* vertices and 0 edges. During Bubble Sort execution, ... | {"inputs": ["3\n3 1 2", "5\n4 2 1 3 5", "10\n1 9 8 10 2 3 4 6 5 7", "50\n12 24 42 43 36 3 40 29 7 34 10 13 28 9 35 23 25 21 19 4 20 18 11 38 41 48 6 46 33 17 31 37 2 30 32 44 45 5 47 49 16 15 50 27 26 14 39 22 1 8", "100\n36 48 92 87 28 85 42 10 44 41 39 3 79 9 14 56 1 16 46 35 93 8 82 26 100 59 60 2 96 52 13 98 70 81 ... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 22 | codeforces | Okay, let's see. I need to find the size of the maximum independent set in the graph G generated by the Bubble Sort process described. Hmm. Wait, the graph starts with n vertices and adds edges during the Bubble Sort steps. So the edges are added whenever a swap happens between two elements. Because in each iteration o... | To solve this problem, we need to determine the size of the maximum independent set in a graph generated during the execution of the Bubble Sort algorithm on a given permutation. The graph's edges are formed between adjacent indices whenever a swap occurs between them during the sorting process.
### Approach
1. **Unde... | false | Code is incorrect. | |
aa3c1b41277165391ffdeec88676f3de | Leaving Auction | There are *n* people taking part in auction today. The rules of auction are classical. There were *n* bids made, though it's not guaranteed they were from different people. It might happen that some people made no bids at all.
Each bid is define by two integers (*a**i*,<=*b**i*), where *a**i* is the index of the perso... | {"inputs": ["6\n1 10\n2 100\n3 1000\n1 10000\n2 100000\n3 1000000\n3\n1 3\n2 2 3\n2 1 2", "3\n1 10\n2 100\n1 1000\n2\n2 1 2\n2 2 3", "1\n1 1\n1\n1 1", "2\n1 1\n2 2\n3\n1 1\n1 2\n2 1 2", "4\n1 3\n2 7\n1 8\n3 10\n15\n1 1\n1 2\n1 3\n1 4\n2 1 2\n2 1 3\n2 1 4\n2 2 3\n2 2 4\n2 3 4\n3 1 2 3\n3 1 2 4\n3 1 3 4\n3 2 3 4\n4 1 2 3... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 1 | codeforces | Okay, let's see. I need to solve this programming problem. Let's read the problem statement carefully.
So, the problem is about an auction with n bids. Each bid is made by a participant, and the bids are in order. The rules are that no two consecutive bids are from the same person. Now, for each query, we have to excl... | To solve this problem, we need to determine the winner of an auction under various scenarios where certain participants are absent. The solution involves processing each query efficiently to determine the highest bid and the participant who made it, considering the absence of certain participants and merging consecutiv... | true | ||
aa58cc23ec95ad4e4034fc6ce173c19c | Hamsters and Tigers | Today there is going to be an unusual performance at the circus — hamsters and tigers will perform together! All of them stand in circle along the arena edge and now the trainer faces a difficult task: he wants to swap the animals' positions so that all the hamsters stood together and all the tigers also stood together... | {"inputs": ["3\nHTH", "9\nHTHTHTHHT", "2\nTH", "4\nHTTH", "4\nHTHT", "7\nTTTHTTT", "8\nHHTHHTHH", "13\nHTTTHHHTTTTHH", "20\nTTHTHTHHTHTTHHTTTHHH", "35\nTTTTTTHTTHTTTTTHTTTTTTTTTTTHTHTTTTT", "120\nTTTTTTTHTHTHTTTTTHTHTTTTHTTTTTTTTTTTTTTTTTTTTHTTHTTTTHTTHTTTTTTTTTTTTTTTHTTTTTTHTHTTHTTTTTTHTTTTTTTTTHTTHTTTTHTTTHTTTTTH", "... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 72 | codeforces | Okay, let's see. The problem is to find the minimal number of swaps needed to arrange all hamsters (H) and tigers (T) such that they form a contiguous block in a circular arrangement. So all Hs must be grouped together and all Ts as well. The output should be the minimal swaps required.
Hmm. Since the arrangement is c... | To solve this problem, we need to determine the minimal number of swaps required to group all hamsters (H) and tigers (T) into contiguous blocks in a circular arrangement. The key insight is that the minimal number of swaps corresponds to the minimal number of Ts in any window of size equal to the number of Hs in the i... | true | ||
aa6ceb741b91e022653c4ce5b955f3ff | Bus | There is a bus stop near the university. The lessons are over, and *n* students come to the stop. The *i*-th student will appear at the bus stop at time *t**i* (all *t**i*'s are distinct).
We shall assume that the stop is located on the coordinate axis *Ox*, at point *x*<==<=0, and the bus goes along the ray *Ox*, tha... | {"inputs": ["1 10\n3 5", "2 1\n3 5\n4 5", "5 4\n3 5\n4 5\n5 5\n6 5\n7 1", "20 4\n28 13\n31 13\n35 6\n36 4\n52 6\n53 4\n83 2\n84 4\n87 1\n93 6\n108 4\n113 6\n116 1\n125 2\n130 2\n136 13\n162 2\n166 4\n184 1\n192 2", "1 1\n109 15", "2 1\n43 5\n102 1", "4 2\n7 1\n12 14\n90 15\n176 1", "8 8\n48 14\n74 12\n94 4\n127 14\n151... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 4 | codeforces | Okay, let's tackle this programming problem. Hmm, the problem statement is a bit complex, so I need to understand it thoroughly before jumping into coding. Let's break it down step by step.
So, the problem is about students arriving at a bus stop and taking the bus to their destinations. The bus has a capacity m. Stud... | To solve this problem, we need to simulate the operation of a bus transporting students from a bus stop to their respective destinations. The bus operates in cycles, picking up students in batches and transporting them to their destinations while adhering to specific constraints on capacity and timing.
### Approach
1.... | false | Code is incorrect. | |
aa87f34e616f70cb9788a76c5f75ea43 | HDD is Outdated Technology | HDD hard drives group data by sectors. All files are split to fragments and each of them are written in some sector of hard drive. Note the fragments can be written in sectors in arbitrary order.
One of the problems of HDD hard drives is the following: the magnetic head should move from one sector to another to read s... | {"inputs": ["3\n3 1 2", "5\n1 3 5 4 2", "1\n1", "1\n1", "1\n1", "10\n8 2 10 3 4 6 1 7 9 5", "10\n1 2 3 4 5 6 7 8 9 10", "10\n1 3 5 7 9 10 8 6 4 2", "100\n11 9 35 34 51 74 16 67 26 21 14 80 84 79 7 61 28 3 53 43 42 5 56 36 69 30 22 88 1 27 65 91 46 31 59 50 17 96 25 18 64 55 78 2 63 24 95 48 93 13 38 76 89 94 15 90 45 8... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 136 | codeforces | Okay, let's see. The problem is about calculating the total time needed to read a file that's split into fragments stored in different sectors on an HDD. The magnetic head starts at the sector with the first fragment and then moves to each subsequent fragment in order. The time taken is the sum of the absolute differen... | To solve this problem, we need to determine the total time required to read a file split into fragments stored in different sectors on an HDD. The magnetic head starts at the sector containing the first fragment and moves sequentially to each subsequent fragment. The time taken for each move is the absolute difference ... | true | ||
aa909528de85efa4b55581fd8e03c2e2 | Kuro and Topological Parity | Kuro has recently won the "Most intelligent cat ever" contest. The three friends then decided to go to Katie's home to celebrate Kuro's winning. After a big meal, they took a small break then started playing games.
Kuro challenged Katie to create a game with only a white paper, a pencil, a pair of scissors and a lot o... | {"inputs": ["3 1\n-1 0 1", "2 1\n1 0", "1 1\n-1", "1 0\n-1", "1 1\n0", "5 1\n-1 -1 -1 -1 -1", "5 0\n-1 -1 -1 -1 -1", "10 1\n1 1 1 1 0 0 0 1 0 0", "50 1\n-1 -1 1 0 1 1 0 -1 1 0 -1 -1 0 0 -1 -1 0 1 1 -1 1 0 -1 1 1 -1 -1 -1 1 -1 -1 0 -1 0 -1 0 0 -1 -1 0 1 -1 0 1 -1 1 0 -1 -1 1", "20 1\n0 0 -1 0 1 1 1 1 -1 -1 1 1 1 -1 0 0 ... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 1 | codeforces | Okay, I need to solve this problem. Let me read the problem statement again carefully.
So, the problem is about counting the number of ways to put arrows and color the pieces such that the total number of valid paths (which are paths of alternating colors) has a certain parity (even or odd). The answer needs to be mod... | To solve this problem, we need to determine the number of valid ways to place arrows and color the pieces such that the number of valid paths of alternating colors has a specific parity (even or odd). The solution involves dynamic programming and linear algebra over GF(2) to efficiently compute the required parity cond... | false | Code is incorrect. | |
aa950f6569484d8c8e06d95a3f7aaf3a | Boxes Packing | Mishka has got *n* empty boxes. For every *i* (1<=≤<=*i*<=≤<=*n*), *i*-th box is a cube with side length *a**i*.
Mishka can put a box *i* into another box *j* if the following conditions are met:
- *i*-th box is not put into another box; - *j*-th box doesn't contain any other boxes; - box *i* is smaller than box *... | {"inputs": ["3\n1 2 3", "4\n4 2 4 3", "10\n58 58 58 58 58 58 58 58 58 58", "10\n86 89 89 86 86 89 86 86 89 89", "100\n981 288 186 186 292 876 341 288 981 360 783 907 292 186 341 292 360 876 360 360 981 398 783 288 292 398 876 981 398 907 783 360 288 981 907 186 360 288 186 981 186 288 907 876 288 907 876 360 341 292 90... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 197 | codeforces | Okay, let's see. The problem is about putting boxes inside each other to minimize the visible ones. So, the goal is to find the minimal number of boxes that can't be nested into others based on the given conditions.
Hmm. Let me think about the conditions again. Each box can be put into another only if the first is sm... | To solve this problem, we need to determine the minimum number of visible boxes after nesting as many boxes as possible according to the given conditions. The key insight is that the number of visible boxes is determined by the maximum frequency of any box size, as each occurrence of the same size requires a separate c... | true | ||
aa95201684f692785e83233e7b14292e | Cycle | A tournament is a directed graph without self-loops in which every pair of vertexes is connected by exactly one directed edge. That is, for any two vertexes *u* and *v* (*u*<=≠<=*v*) exists either an edge going from *u* to *v*, or an edge from *v* to *u*.
You are given a tournament consisting of *n* vertexes. Your tas... | {"inputs": ["5\n00100\n10000\n01001\n11101\n11000", "5\n01111\n00000\n01000\n01100\n01110", "5\n01000\n00101\n10010\n11001\n10100", "5\n00110\n10110\n00011\n00000\n11010", "10\n0011000010\n1011001101\n0000101100\n0010101010\n1100000100\n1111101100\n1000100000\n1001001011\n0110111001\n1011111000", "10\n0111001000\n00111... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 1 | codeforces | Okay, let's see. The problem is to find a cycle of three nodes (a triangle) in a tournament graph. If such a cycle exists, output the three nodes; otherwise, output -1.
Hmm, I remember that tournaments have some properties. Like, every tournament has a Hamiltonian path. But for cycles of length three, maybe there's a... | To solve this problem, we need to find a cycle of length three (a triangle) in a tournament graph. A tournament graph is a directed graph where every pair of distinct vertices is connected by a single directed edge. The solution must efficiently determine if such a cycle exists and return the vertices forming the cycle... | false | Code is incorrect. | |
aaa6c5a197701f18e7cecda2a36fc449 | Endless Roses Most Beautiful | Arkady decided to buy roses for his girlfriend.
A flower shop has white, orange and red roses, and the total amount of them is *n*. Arkady thinks that red roses are not good together with white roses, so he won't buy a bouquet containing both red and white roses. Also, Arkady won't buy a bouquet where all roses have t... | {"inputs": ["5 3\n4 3 4 1 6\nRROWW", "5 2\n10 20 14 20 11\nRRRRR", "11 5\n5 6 3 2 3 4 7 5 4 5 6\nRWOORWORROW", "15 10\n8560 6244 9607 5137 7187 3217 5527 9919 282 8748 3529 6110 5767 521 3393\nOWRWOORWRORWWRO", "10 4\n1208 5835 2637 5827 3722 6837 3499 6438 43 5333\nWRRWRWRWRW", "13 3\n9675 8988 5499 6356 5083 6067 558... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 4 | codeforces | Okay, let's see. The problem is about selecting k roses from n available, but with some constraints. The main constraints are:
1. The bouquet can't have both red and white roses. So any valid bouquet is either:
- Without red and white together. So possible color combinations are:
- Only white and orange (since... | To solve this problem, we need to determine the maximum possible total beauty of a bouquet of exactly `k` roses that Arkady can buy, given the constraints that he cannot have both red and white roses in the bouquet and the bouquet must contain at least two different colors.
### Approach
1. **Input Parsing**: Read the ... | true | ||
aaab33deadf08632a19f4bb503f27565 | none | Alice and Bob decided to eat some fruit. In the kitchen they found a large bag of oranges and apples. Alice immediately took an orange for herself, Bob took an apple. To make the process of sharing the remaining fruit more fun, the friends decided to play a game. They put multiple cards and on each one they wrote a let... | {"inputs": ["1 4", "2 2", "3 2", "2 1", "5 3", "5 2", "8 5", "97 101", "1 3", "1000000000000000000 999999999999999999", "55 89", "610 987", "4181 6765", "46368 75025", "832040 514229", "5702887 9227465", "701408733 433494437", "956722026041 591286729879", "498454011879264 806515533049393", "420196140727489673 679891637... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 16 | codeforces | Okay, let's try to figure out how to solve this problem. The problem says that Alice and Bob take some cards, each being 'A' or 'B', and based on the sequence of these cards, they exchange fruits in a certain way. Our task is to find any possible sequence of cards (in a compressed format) that would result in the initi... | To solve this problem, we need to determine a sequence of cards ('A' or 'B') that Alice and Bob could have played to share the remaining fruits in the bag according to specific rules. The sequence must be presented in a compressed format, and if no valid sequence exists, we should return "Impossible".
### Approach
1. ... | false | Code is incorrect. | |
aaae939c861210fcad59ff469f432ee8 | Bakery | Masha wants to open her own bakery and bake muffins in one of the *n* cities numbered from 1 to *n*. There are *m* bidirectional roads, each of whose connects some pair of cities.
To bake muffins in her bakery, Masha needs to establish flour supply from some storage. There are only *k* storages, located in different c... | {"inputs": ["5 4 2\n1 2 5\n1 2 3\n2 3 4\n1 4 10\n1 5", "3 1 1\n1 2 3\n3", "2 3 1\n1 2 3\n1 2 18\n1 2 13\n2", "3 7 0\n1 3 9\n1 2 5\n1 2 21\n1 2 12\n1 2 13\n2 3 19\n2 3 8", "4 13 1\n1 4 10\n1 3 6\n1 4 3\n3 4 1\n1 3 2\n1 2 15\n1 4 21\n1 4 20\n2 4 13\n1 4 7\n2 4 2\n1 2 8\n1 3 17\n1", "5 7 3\n2 3 20\n1 2 10\n1 2 11\n4 5 15\... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 23 | codeforces | Okay, let's see. The problem is about finding the minimum distance from any non-storage city to the nearest storage city. And then choosing the smallest such distance. If there are no such cities where this is possible, we return -1.
First, I need to process the input correctly. So the input has n cities, m roads, k s... | To solve this problem, we need to determine the minimum cost for Masha to open a bakery in a city that does not have a flour storage, ensuring she can get flour from the nearest storage at the lowest possible cost. This involves finding the shortest path from any non-storage city to the nearest storage city using a mul... | true | ||
aaaffe668fb66d099e8688f0232544af | Vessels | There is a system of *n* vessels arranged one above the other as shown in the figure below. Assume that the vessels are numbered from 1 to *n*, in the order from the highest to the lowest, the volume of the *i*-th vessel is *a**i* liters.
Initially, all the vessels are empty. In some vessels water is poured. All the w... | {"inputs": ["2\n5 10\n6\n1 1 4\n2 1\n1 2 5\n1 1 4\n2 1\n2 2", "3\n5 10 8\n6\n1 1 12\n2 2\n1 1 6\n1 3 2\n2 2\n2 3", "10\n71 59 88 55 18 98 38 73 53 58\n20\n1 5 93\n1 7 69\n2 3\n1 1 20\n2 10\n1 6 74\n1 7 100\n1 9 14\n2 3\n2 4\n2 7\n1 3 31\n2 4\n1 6 64\n2 2\n2 2\n1 3 54\n2 9\n2 1\n1 6 86", "10\n3 7 10 1 5 4 4 3 3 1\n20\n2... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 5 | codeforces | Okay, so I need to solve this programming problem where I have to simulate pouring water into vessels and handle queries about the water levels. Let's see. The problem statement says that when you add water to a vessel, any overflow goes to the next one below, and so on until the bottom vessel, where it spills out. And... | To solve this problem, we need to simulate pouring water into a series of vessels and handle overflow efficiently. The goal is to process each query in optimal time, ensuring that the solution can handle up to 200,000 vessels and queries efficiently.
### Approach
1. **Data Structures**: Use an array `current` to track... | true | ||
aac6bac239d06f0aeceefefe8a47c5e9 | Let's Watch Football | Valeric and Valerko missed the last Euro football game, so they decided to watch the game's key moments on the Net. They want to start watching as soon as possible but the connection speed is too low. If they turn on the video right now, it will "hang up" as the size of data to watch per second will be more than the si... | {"inputs": ["4 1 1", "10 3 2", "13 12 1", "2 1 3", "6 2 4", "5 2 1", "2 1 1", "2 1 4", "5 1 5", "2 1 2", "60 16 1", "64 12 8", "66 38 4", "70 32 1", "24 12 12", "24 19 9", "244 87 4", "305 203 421", "888 777 1", "888 777 1000", "888 777 888", "5 4 10", "1000 1 1", "1000 1 1000", "1000 999 1", "1000 999 1000", "945 812 ... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 196 | codeforces | Okay, let's tackle this problem. Hmm, the goal is to find the minimum integer t such that after waiting t seconds, Valeric and Valerko can start watching the video without any pauses. The key is to ensure that at every moment during their viewing (from t to t + c seconds), the downloaded data is enough for the portion ... | To solve this problem, we need to determine the minimum number of seconds Valeric and Valerko must wait before starting to watch a video such that the video does not pause due to insufficient downloaded data. The solution involves calculating the minimum waiting time based on the given constraints of data download and ... | true | ||
aaf53c3223958d02a7990a2f62318615 | Remove Extra One | You are given a permutation *p* of length *n*. Remove one element from permutation to make the number of records the maximum possible.
We remind that in a sequence of numbers *a*1,<=*a*2,<=...,<=*a**k* the element *a**i* is a record if for every integer *j* (1<=≤<=*j*<=<<=*i*) the following holds: *a**j*<=<<=*a*... | {"inputs": ["1\n1", "5\n5 1 2 3 4", "5\n4 3 5 1 2", "9\n9 5 8 6 3 2 4 1 7", "3\n3 2 1", "7\n1 6 7 4 2 5 3", "48\n38 6 31 19 45 28 27 43 11 35 36 20 9 16 42 48 14 22 39 18 12 10 34 25 13 26 40 29 17 8 33 46 24 30 37 44 1 15 2 21 3 5 4 47 32 23 41 7", "26\n23 14 15 19 9 22 20 12 5 4 21 1 16 8 6 11 3 17 2 10 24 26 13 18 2... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 12 | codeforces | Okay, let's see. I need to solve this problem where I have to remove one element from a permutation to maximize the number of records. The record is defined as an element that's larger than all the ones before it. So, for example, the first element is always a record. Then any element that's bigger than all previous el... | To solve this problem, we need to determine which element to remove from a permutation such that the number of records (elements greater than all previous elements) is maximized. If there are multiple elements that yield the same maximum number of records, we choose the smallest element.
### Approach
1. **Understandin... | false | Code is incorrect. | |
ab1ba7a3a8c64af0d4dacb38a45591ed | Sanatorium | Vasiliy spent his vacation in a sanatorium, came back and found that he completely forgot details of his vacation!
Every day there was a breakfast, a dinner and a supper in a dining room of the sanatorium (of course, in this order). The only thing that Vasiliy has now is a card from the dining room contaning notes ho... | {"inputs": ["3 2 1", "1 0 0", "1 1 1", "1000000000000000000 0 1000000000000000000", "1000 0 0", "0 1 0", "0 0 1", "1 1 0", "0 1 1", "1000000000000000000 999999999999999999 999999999999999999", "1000000000000000000 1000000000000000000 999999999999999999", "1000000000000000000 1000000000000000000 1000000000000000000", "9... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 16 | codeforces | Okay, I need to solve this problem where Vasiliy has some counts of breakfasts, dinners, and suppers he had, and I have to find the minimum number of meals he could have missed. Let's try to understand the problem step by step.
So the key points are:
- Each day has breakfast, dinner, supper in that order.
- Vasiliy a... | To solve this problem, we need to determine the minimum number of meals Vasiliy could have missed during his stay at the sanatorium, given the counts of breakfasts, dinners, and suppers he had. The key insight is to consider the maximum count of any meal type and use it to derive the minimum possible missed meals.
###... | true | ||
ab243f42ee37afd8273312305780af22 | Electric Charges | Programmer Sasha is a student at MIPT (Moscow Institute of Physics and Technology) and he needs to make a laboratory work to pass his finals.
A laboratory unit is a plane with standard coordinate axes marked on it. Physicists from Moscow Institute of Physics and Technology charged the axes by large electric charges: a... | {"inputs": ["3\n1 10\n1 20\n1 30", "2\n1 10\n10 1", "10\n1 6\n2 2\n-1 9\n-8 8\n-4 10\n-10 -6\n5 -1\n-3 -7\n-4 3\n9 4", "18\n-14 -745\n87 -4611\n89 -3748\n-77 273\n-21 -4654\n-86 -5108\n-70 3232\n25 -6313\n-71 -4846\n88 -1894\n-65 9707\n-51 -3290\n-19 -580\n-62 -2408\n1 -6832\n52 -4279\n21 -7322\n55 9392", "12\n996 -72\... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 1 | codeforces | Okay, let's see. I need to solve this programming problem where Sasha has to place electrons or protons on each of the n points such that when they drop to either the X-axis (electrons) or Y-axis (protons), the maximum distance between any two resulting points is minimized. And I have to output the square of the minima... | To solve this problem, we need to determine the optimal placement of electrons and protons on a set of points such that the maximum distance between any two resulting points is minimized. The solution involves considering three different scenarios and selecting the one that yields the smallest maximum distance.
### Ap... | false | Code is incorrect. | |
ab514d2189903ec3467ac95baa7abde1 | Table Decorations | You have *r* red, *g* green and *b* blue balloons. To decorate a single table for the banquet you need exactly three balloons. Three balloons attached to some table shouldn't have the same color. What maximum number *t* of tables can be decorated if we know number of balloons of each color?
Your task is to write a pro... | {"inputs": ["5 4 3", "1 1 1", "2 3 3", "0 1 0", "0 3 3", "4 0 4", "1000000000 1000000000 1000000000", "100 99 56", "1000 1000 1002", "0 1 1000000000", "500000000 1000000000 500000000", "1000000000 2000000000 1000000000", "2000000000 2000000000 2000000000", "0 0 0", "1 2000000000 1000000000", "1585222789 1889821127 2000... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 77 | codeforces | Okay, let's tackle this problem. So the task is to find the maximum number of tables we can decorate, each requiring exactly three balloons, but no three can be the same color. Hmm, right. So each table must have either two of one color and one of another, or all three different colors. Wait no, wait. Wait, the problem... | To solve this problem, we need to determine the maximum number of tables that can be decorated using red, green, and blue balloons such that each table has exactly three balloons, and no table has all three balloons of the same color.
### Approach
The solution involves two key insights:
1. The maximum number of tables... | true | ||
ab84e591c27936e4ef3d86b9651f6fd0 | Optimal Point on a Line | You are given *n* points on a line with their coordinates *x**i*. Find the point *x* so the sum of distances to the given points is minimal.
The first line contains integer *n* (1<=≤<=*n*<=≤<=3·105) — the number of points on the line.
The second line contains *n* integers *x**i* (<=-<=109<=≤<=*x**i*<=≤<=109) — the coo... | {"inputs": ["4\n1 2 3 4", "5\n-1 -10 2 6 7", "10\n-68 10 87 22 30 89 82 -97 -52 25", "100\n457 827 807 17 871 935 907 -415 536 170 551 -988 865 758 -457 -892 -875 -488 684 19 0 555 -807 -624 -239 826 318 811 20 -732 -91 460 551 -610 555 -493 -154 442 -141 946 -913 -104 704 -380 699 32 106 -455 -518 214 -464 -861 243 -7... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 107 | codeforces | Okay, I need to solve this problem where I have to find a point x on a line such that the sum of distances from x to all given points is minimized. And if there are multiple such points, I have to choose the leftmost one. Let's think about how to approach this.
Hmm, I remember from my studies that the point which mini... | To solve this problem, we need to find the point on a line such that the sum of distances from this point to all given points is minimized. If there are multiple such points, we should choose the leftmost one. The optimal point for this problem is the median of the given points, specifically the lower median when there... | true | ||
ab9570f400b71baf4b0f8f8379616f4c | Not Afraid | Since the giant heads have appeared in the sky all humanity is in danger, so all Ricks and Mortys from all parallel universes are gathering in groups to find a solution to get rid of them.
There are *n* parallel universes participating in this event (*n* Ricks and *n* Mortys). I. e. each of *n* universes has one Rick... | {"inputs": ["4 2\n1 -3\n4 -2 3 2 -3", "5 2\n5 3 -2 1 -1 5\n3 -5 2 5", "7 2\n3 -1 6 7\n7 -5 4 2 4 7 -3 4", "2 1\n2 -2 2", "7 7\n1 -2\n1 6\n2 7 -6\n2 -6 4\n2 -4 -6\n3 -5 7 -5\n1 -6", "100 50\n2 62 -62\n2 19 -19\n2 38 -38\n2 -84 84\n2 -16 16\n2 67 -67\n2 41 -41\n2 -32 32\n2 32 -32\n2 -62 62\n2 89 -89\n2 -84 84\n2 96 -96\n... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 69 | codeforces | Okay, let's see. The problem is about determining whether there's at least one possible scenario where all members of a group are traitors, which would mean the world ends. So Summer needs to know if such a scenario exists, and we have to output "YES" or "NO" accordingly.
Hmm, the input is groups of Ricks and Mortys f... | To solve this problem, we need to determine if there exists at least one scenario where every member of a group is a traitor, which would result in the world ending. Each universe contributes exactly one traitor, either Rick or Morty. Our task is to check if any group can be composed entirely of traitors without any co... | true | ||
ab9bbca22e4ebbfac690204da5b4e636 | pSort | One day *n* cells of some array decided to play the following game. Initially each cell contains a number which is equal to it's ordinal number (starting from 1). Also each cell determined it's favourite number. On it's move *i*-th cell can exchange it's value with the value of some other *j*-th cell, if |*i*<=-<=*j*|<... | {"inputs": ["5\n5 4 3 2 1\n1 1 1 1 1", "7\n4 3 5 1 2 7 6\n4 6 6 1 6 6 1", "7\n4 2 5 1 3 7 6\n4 6 6 1 6 6 1", "6\n3 2 1 4 6 5\n3 6 1 6 6 1", "6\n3 5 1 4 6 2\n3 6 1 6 6 1", "4\n1 2 3 4\n1 1 1 1", "71\n1 63 3 4 5 6 7 8 9 44 29 12 13 14 55 34 42 18 52 20 21 33 23 24 25 26 27 28 19 30 47 32 15 71 37 36 69 38 39 40 41 17 43 ... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 27 | codeforces | Okay, let's see. I need to determine if a given permutation can be achieved from the initial state where each cell has its ordinal number. The cells can swap values any number of times as long as the swap between i and j satisfies |i - j| ≤ d_i, where d_i is the favorite number of cell i. So, the problem is to check if... | To solve this problem, we need to determine if a given permutation of an array can be achieved through a series of allowed swaps. Each cell in the array can swap its value with another cell if the distance between them is within the favorite number of the initiating cell. The solution involves checking if each element ... | false | Code is incorrect. | |
abbad00030e70b95b58997b453592058 | Playing with Dice | Two players are playing a game. First each of them writes an integer from 1 to 6, and then a dice is thrown. The player whose written number got closer to the number on the dice wins. If both payers have the same difference, it's a draw.
The first player wrote number *a*, the second player wrote number *b*. How many w... | {"inputs": ["2 5", "2 4", "5 3", "1 6", "5 1", "6 3", "2 3", "5 6", "4 4", "1 1", "6 4", "1 4", "5 5", "4 5", "4 3", "1 5", "6 5", "2 2", "1 3", "3 6", "3 1", "3 2", "3 5", "3 3", "6 2", "4 1", "5 2", "4 2", "2 1", "6 1", "4 6", "2 6", "3 4", "1 2", "6 6", "5 4", "3 3", "1 1"], "outputs": ["3 0 3", "2 1 3", "2 1 3", "3... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 672 | codeforces | Okay, let's see. I need to solve this problem where two players have written numbers a and b, and based on the dice roll (which can be 1 to 6), we have to determine the number of outcomes where the first player wins, draws, or the second player wins. The output should be three numbers for each case.
Hmm. So the dice c... | To solve this problem, we need to determine the number of possible outcomes when a dice is thrown, which result in the first player winning, a draw, or the second player winning. The solution involves comparing the differences between each player's chosen number and the dice roll outcome.
### Approach
1. **Input Readi... | true | ||
abc27619c76daf559804e27c90524aa3 | Black and White Tree | The board has got a painted tree graph, consisting of *n* nodes. Let us remind you that a non-directed graph is called a tree if it is connected and doesn't contain any cycles.
Each node of the graph is painted black or white in such a manner that there aren't two nodes of the same color, connected by an edge. Each ed... | {"inputs": ["3\n1 3\n1 2\n0 5", "6\n1 0\n0 3\n1 8\n0 2\n0 3\n0 0", "2\n0 0\n1 0", "5\n1 11\n0 9\n1 4\n0 4\n0 2", "10\n0 24\n1 164\n0 206\n0 45\n1 110\n0 66\n1 59\n1 92\n0 152\n1 68", "20\n0 569\n1 328\n1 74\n1 88\n1 90\n1 124\n0 78\n0 39\n1 9\n1 59\n1 41\n1 73\n1 45\n0 45\n0 13\n1 39\n0 24\n0 37\n0 95\n0 70", "30\n0 11... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 1 | codeforces | Okay, let's see. So the problem is about restoring a tree structure based on the colors of the nodes and their s values. Each node's color is either black or white, and adjacent nodes must have different colors. The sum s_v for each node is the sum of the weights of all edges connected to it. Our task is to find the or... | To solve this problem, we need to reconstruct a tree graph from given node colors and their associated sum values. The tree must be bipartite, meaning adjacent nodes have different colors. Each node's sum value is the total of the weights of edges connected to it.
### Approach
1. **Split Nodes by Color**: Separate no... | false | Code is incorrect. | |
abf11aeddeb0af07ea9ac20715e7c810 | Solution for Cube | During the breaks between competitions, top-model Izabella tries to develop herself and not to be bored. For example, now she tries to solve Rubik's cube 2x2x2.
It's too hard to learn to solve Rubik's cube instantly, so she learns to understand if it's possible to solve the cube in some state using 90-degrees rotation... | {"inputs": ["2 5 4 6 1 3 6 2 5 5 1 2 3 5 3 1 1 2 4 6 6 4 3 4", "5 3 5 3 2 5 2 5 6 2 6 2 4 4 4 4 1 1 1 1 6 3 6 3", "2 6 3 3 5 5 2 6 1 1 6 4 4 4 2 4 6 5 3 1 2 5 3 1", "3 4 2 3 5 5 6 6 4 5 4 6 5 1 1 1 6 2 1 3 3 2 4 2", "5 5 2 5 3 3 2 6 6 4 2 4 6 1 4 3 1 6 2 1 3 4 5 1", "6 6 1 2 6 1 1 3 5 4 3 4 3 5 5 2 4 4 6 2 1 5 3 2", "2... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 29 | codeforces | Okay, so I need to solve this programming problem where I have to determine if a given 2x2x2 Rubik's cube can be solved with a single 90-degree rotation of one face. Let's see how to approach this.
First, I need to understand the cube structure. A 2x2 cube has 6 faces, each with 4 squares. The input is a sequence of 2... | To solve this problem, we need to determine if a given 2x2x2 Rubik's cube can be solved with a single 90-degree rotation of one face in any direction. The cube is considered solved if each face has all four squares of the same color.
### Approach
1. **Input Parsing**: Read the input as a list of 24 integers representi... | false | Code is incorrect. | |
ac0c2716962ff08b4b4c6c7396f716d9 | Tree Requests | Roman planted a tree consisting of *n* vertices. Each vertex contains a lowercase English letter. Vertex 1 is the root of the tree, each of the *n*<=-<=1 remaining vertices has a parent in the tree. Vertex is connected with its parent by an edge. The parent of vertex *i* is vertex *p**i*, the parent index is always les... | {"inputs": ["6 5\n1 1 1 3 3\nzacccd\n1 1\n3 3\n4 1\n6 1\n1 2", "5 6\n1 1 2 3\ncbcab\n3 1\n5 2\n1 3\n4 1\n4 2\n1 1", "5 6\n1 2 2 1\nbaabb\n1 1\n1 2\n5 1\n4 1\n4 2\n3 2", "5 9\n1 1 1 2\nedbcb\n1 3\n2 1\n1 3\n2 1\n2 2\n2 2\n1 1\n1 3\n2 1", "8 12\n1 1 1 2 1 1 4\ncbecdcce\n1 2\n1 2\n2 1\n1 1\n2 1\n1 3\n1 3\n1 3\n1 2\n2 3\n1... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 4 | codeforces | Okay, let's try to solve this problem. Hmm, the problem statement says that for each query, we need to check if the letters in the subtree of a given vertex vi at depth hi can form a palindrome when rearranged. Oh right, to form a palindrome, the counts of each character must meet certain conditions. For even-length st... | To solve this problem, we need to determine if the letters from nodes in the subtree of a given vertex at a specified depth can be rearranged to form a palindrome. The solution involves preprocessing the tree to efficiently answer multiple queries.
### Approach
1. **Tree Representation and Depth Calculation**: Represe... | false | Code is incorrect. | |
ac413e3d23d2317e4f1b0c9a24087720 | Fix a Tree | A tree is an undirected connected graph without cycles.
Let's consider a rooted undirected tree with *n* vertices, numbered 1 through *n*. There are many ways to represent such a tree. One way is to create an array with *n* integers *p*1,<=*p*2,<=...,<=*p**n*, where *p**i* denotes a parent of vertex *i* (here, for con... | {"inputs": ["4\n2 3 3 4", "5\n3 2 2 5 3", "8\n2 3 5 4 1 6 6 7", "2\n1 2", "7\n4 3 2 6 3 5 2", "6\n6 2 6 2 4 2", "7\n1 6 4 4 5 6 7", "7\n7 5 3 1 2 1 5", "7\n1 2 3 4 5 6 7", "18\n2 3 4 5 2 7 8 9 10 7 11 12 14 15 13 17 18 18", "8\n2 1 2 2 6 5 6 6", "3\n2 1 1"], "outputs": ["1\n2 3 4 4 ", "0\n3 2 2 5 3 ", "2\n2 3 7 8 1 6 6... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 12 | codeforces | Okay, I need to solve this problem where I have to find the minimum number of changes to make a given sequence a valid parent array for a rooted tree. Hmm. Let's think about the problem carefully.
First, what defines a valid sequence? The key points are:
1. There must be exactly one root r where p_r = r. All other no... | To solve this problem, we need to transform a given sequence into a valid parent array for a rooted tree with the minimum number of changes. A valid parent array must have exactly one root (a node pointing to itself) and form a tree structure without cycles.
### Approach
1. **Identify Existing Roots**: Determine the n... | false | Code is incorrect. | |
ac9108f0e82902b1ab432959abb62764 | Counterexample | Your friend has recently learned about coprime numbers. A pair of numbers {*a*,<=*b*} is called coprime if the maximum number that divides both *a* and *b* is equal to one.
Your friend often comes up with different statements. He has recently supposed that if the pair (*a*,<=*b*) is coprime and the pair (*b*,<=*c*) i... | {"inputs": ["2 4", "10 11", "900000000000000009 900000000000000029", "640097987171091791 640097987171091835", "19534350415104721 19534350415104725", "933700505788726243 933700505788726280", "1 3", "1 4", "1 1", "266540997167959130 266540997167959164", "267367244641009850 267367244641009899", "268193483524125978 2681934... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 367 | codeforces | Okay, let's tackle this problem. The task is to find three distinct numbers a, b, c within the range [l, r] such that a < b < c. The conditions are that gcd(a, b) = 1, gcd(b, c) = 1, but gcd(a, c) > 1. If such a triplet doesn't exist, we return -1.
Hmm, first, I need to understand how to find such triplets efficiently... | To solve this problem, we need to find three distinct numbers \(a\), \(b\), and \(c\) within a given range \([l, r]\) such that \(a < b < c\), \( \text{gcd}(a, b) = 1 \), \( \text{gcd}(b, c) = 1 \), and \( \text{gcd}(a, c) > 1 \). If no such triplet exists, we should return -1.
### Approach
1. **Generate the Range**: ... | true | ||
ac9bff232861d45cba367272ddb2c80e | Eternal Victory | Valerian was captured by Shapur. The victory was such a great one that Shapur decided to carve a scene of Valerian's defeat on a mountain. So he had to find the best place to make his victory eternal!
He decided to visit all *n* cities of Persia to find the best available mountain, but after the recent war he was too ... | {"inputs": ["3\n1 2 3\n2 3 4", "3\n1 2 3\n1 3 3", "5\n5 3 60\n4 3 63\n2 1 97\n3 1 14", "3\n2 1 63\n3 1 78", "13\n8 2 58\n2 1 49\n13 10 41\n11 9 67\n6 4 18\n7 1 79\n3 2 58\n9 7 92\n10 6 62\n4 3 5\n12 4 87\n5 3 66", "2\n2 1 89", "12\n3 1 31\n5 2 94\n9 8 37\n10 9 45\n7 5 75\n4 2 77\n6 3 31\n11 6 14\n8 7 19\n2 1 68\n12 1 6... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 18 | codeforces | Okay, let's tackle this problem. So the task is to find the minimal traversal distance for Shapur to visit all cities starting from city 1, possibly ending in any city. The roads form a tree since there's a unique path between any two cities. Hmm.
Wait, the problem says that he wants to visit each city at least once w... | To solve this problem, we need to determine the minimal traversal distance for Shapur to visit all cities starting from city 1, considering he can finish his travels in any city. The cities are connected in a tree structure, which allows us to leverage specific properties of trees to find an optimal solution.
### Appr... | true | ||
acd4c4fb1076614e330c5341053f7a0a | Rectangle and Square | Little Petya very much likes rectangles and especially squares. Recently he has received 8 points on the plane as a gift from his mother. The points are pairwise distinct. Petya decided to split them into two sets each containing 4 points so that the points from the first set lay at the vertexes of some square and the ... | {"inputs": ["0 0\n10 11\n10 0\n0 11\n1 1\n2 2\n2 1\n1 2", "0 0\n1 1\n2 2\n3 3\n4 4\n5 5\n6 6\n7 7", "0 0\n4 4\n4 0\n0 4\n1 2\n2 3\n3 2\n2 1", "-160 336\n-76 672\n8 168\n-580 588\n-1000 504\n-496 840\n-496 84\n-664 0", "8 -328\n-440 568\n-104 8\n-1000 -664\n8 456\n-328 8\n-552 120\n-664 -1000", "65 852\n-645 284\n-361 7... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 8 | codeforces | Okay, so I need to solve this programming problem where I have to check if 8 given points can be split into a square and a rectangle (which could also be a square). Hmm. Let's think about how to approach this.
First, the problem states that we have 8 points. We need to partition them into two groups of 4 each. One gro... | To solve this problem, we need to determine if we can partition 8 given points into two groups: one forming a square and the other forming a rectangle (which can also be a square). The solution involves checking all possible combinations of 4 points to find a valid square and then verifying if the remaining points form... | false | Code is incorrect. | |
ad14725a5fe6b814b4b6bbb9fe4458f0 | Destroying Roads | In some country there are exactly *n* cities and *m* bidirectional roads connecting the cities. Cities are numbered with integers from 1 to *n*. If cities *a* and *b* are connected by a road, then in an hour you can go along this road either from city *a* to city *b*, or from city *b* to city *a*. The road network is s... | {"inputs": ["5 4\n1 2\n2 3\n3 4\n4 5\n1 3 2\n3 5 2", "5 4\n1 2\n2 3\n3 4\n4 5\n1 3 2\n2 4 2", "5 4\n1 2\n2 3\n3 4\n4 5\n1 3 2\n3 5 1", "9 9\n1 2\n2 3\n2 4\n4 5\n5 7\n5 6\n3 8\n8 9\n9 6\n1 7 4\n3 6 3", "9 9\n1 2\n2 3\n2 4\n4 5\n5 7\n5 6\n3 8\n8 9\n9 6\n1 7 4\n3 6 4", "10 11\n1 3\n2 3\n3 4\n4 5\n4 6\n3 7\n3 8\n4 9\n4 10\... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 1 | codeforces | Okay, let's try to tackle this problem. So the task is to find the maximum number of roads we can destroy such that after destruction, the two paths (s1 to t1 in <= l1 hours and s2 to t2 in <= l2 hours) are still possible. The roads are bidirectional, each road takes 1 hour to traverse. And the original road network is... | To solve this problem, we need to determine the maximum number of roads that can be destroyed while still allowing travel from city `s1` to `t1` within `l1` hours and from city `s2` to `t2` within `l2` hours. The key insight is to find the minimal number of roads required to satisfy both travel constraints, which allow... | false | Code is incorrect. | |
ad1f8a840e84be956b38eac4b391343f | Petr and Permutations | Petr likes to come up with problems about randomly generated data. This time problem is about random permutation. He decided to generate a random permutation this way: he takes identity permutation of numbers from $1$ to $n$ and then $3n$ times takes a random pair of different elements and swaps them. Alex envies Petr ... | {"inputs": ["5\n2 4 5 1 3"], "outputs": ["Petr"]} | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 13 | codeforces | Okay, I need to solve this problem where I have to determine whether a given permutation was generated by Petr's method or Alex's. Let's think through the problem step by step.
First, let's understand the problem statement. Petr and Alex generate permutations by starting with the identity permutation and then swapping... | To solve this problem, we need to determine whether a given permutation was generated using Petr's method or Alex's method. The key insight is that the number of swaps performed in each method affects the parity (even or odd nature) of the permutation. By comparing the permutation's parity with the expected parities fr... | true | ||
ad220da3e1b05b8f889f1484c2d540f7 | Drazil and Park | Drazil is a monkey. He lives in a circular park. There are *n* trees around the park. The distance between the *i*-th tree and (*i*<=+<=1)-st trees is *d**i*, the distance between the *n*-th tree and the first tree is *d**n*. The height of the *i*-th tree is *h**i*.
Drazil starts each day with the morning run. The mor... | {"inputs": ["5 3\n2 2 2 2 2\n3 5 2 1 4\n1 3\n2 2\n4 5", "3 3\n5 1 4\n5 1 4\n3 3\n2 2\n1 1", "10 10\n8477 33103 38654 6582 27496 1106 15985 3644 29818 8849\n88745 72099 87767 85285 73517 94562 87214 63194 83791 77619\n2 8\n1 5\n9 5\n7 8\n6 9\n8 1\n6 1\n4 9\n8 10\n5 10", "9 9\n1 1 1 1 1 1 1 1 1\n1 1 1 1 1000000000 1 1 1 ... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 1 | codeforces | Okay, let's tackle this problem. Hmm. So, Drazil is a monkey choosing two trees for his morning run, but he can't pick any tree that's near the children's play area. The goal is to find the maximum energy he can expend each day. The energy is calculated as 2*(hx + hy) plus the distance between x and y along the allowed... | To solve this problem, we need to determine the maximum energy Drazil can expend during his morning run each day, given that he cannot choose trees near children playing. The energy expended is calculated based on the heights of the chosen trees and the distance between them along an allowed path that avoids the childr... | true | ||
ad656fd9fb168c5779c1eec25fd50ee2 | Sagheer and Crossroads | Sagheer is walking in the street when he comes to an intersection of two roads. Each road can be represented as two parts where each part has 3 lanes getting into the intersection (one for each direction) and 3 lanes getting out of the intersection, so we have 4 parts in total. Each part has 4 lights, one for each lane... | {"inputs": ["1 0 0 1\n0 1 0 0\n0 0 1 0\n0 0 0 1", "0 1 1 0\n1 0 1 0\n1 1 0 0\n0 0 0 1", "1 0 0 0\n0 0 0 1\n0 0 0 0\n1 0 1 0", "0 0 0 0\n0 0 0 1\n0 0 0 1\n0 0 0 1", "1 1 1 0\n0 1 0 1\n1 1 1 0\n1 1 1 1", "0 1 1 0\n0 1 0 0\n1 0 0 1\n1 0 0 0", "1 0 0 0\n0 1 0 0\n1 1 0 0\n0 1 1 0", "0 0 0 0\n0 1 0 1\n1 0 1 1\n1 1 1 0", "1 1... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 74 | codeforces | Okay, let's try to figure out this problem. The task is to determine if there's a possibility of an accident based on the traffic light configurations. An accident happens when a pedestrian light (p) is green at the same time as any of the car lights (l, s, r) in the same part, or in a part that's connected via the lan... | To solve this problem, we need to determine if there's a possibility of an accident at a traffic intersection based on the configuration of traffic lights. An accident can occur if a pedestrian crossing light (p) is green at the same time as any car lane light (l, s, r) that can lead into or out of the same part of the... | true | ||
ad7defe219bd7fa8acbe1890ffa08b24 | none | You are given an array *a*1,<=*a*2,<=...,<=*a**n* consisting of *n* integers, and an integer *k*. You have to split the array into exactly *k* non-empty subsegments. You'll then compute the minimum integer on each subsegment, and take the maximum integer over the *k* obtained minimums. What is the maximum possible inte... | {"inputs": ["5 2\n1 2 3 4 5", "5 1\n-4 -5 -3 -2 -1", "10 2\n10 9 1 -9 -7 -9 3 8 -10 5", "10 4\n-8 -1 2 -3 9 -8 4 -3 5 9", "1 1\n504262064", "3 3\n-54481850 -878017339 -486296116", "2 2\n-333653905 224013643", "14 2\n-14 84 44 46 -75 -75 77 -49 44 -82 -74 -51 -9 -50", "88 71\n-497 -488 182 104 40 183 201 282 -384 44 -29... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 140 | codeforces | Okay, I need to solve this programming problem. Let's read the problem statement carefully.
The problem is: Given a sorted array in non-decreasing order, split it into exactly k non-empty subsegments (contiguous parts). For each subsegment, find the minimum, then take the maximum of these minima. We need to find the m... | To solve this problem, we need to split a given non-decreasing array into exactly `k` non-empty contiguous subsegments such that the maximum value of the minimum values from each subsegment is maximized.
### Approach
The key insight here is based on the fact that the array is sorted in non-decreasing order. When split... | false | Code is incorrect. | |
adb059482de1a081f75f56e8d0085745 | Position in Fraction | You have a fraction . You need to find the first occurrence of digit *c* into decimal notation of the fraction after decimal point.
The first contains three single positive integers *a*, *b*, *c* (1<=≤<=*a*<=<<=*b*<=≤<=105, 0<=≤<=*c*<=≤<=9).
Print position of the first occurrence of digit *c* into the fraction. Posi... | {"inputs": ["1 2 0", "2 3 7", "1 100000 1", "1 7 7", "99999 100000 8", "44102 73848 2", "7 31 3", "8880 81608 9", "4942 62768 5", "69168 84860 4", "971 1883 3", "1636 3269 6", "6873 7769 3", "13805 15538 3", "10958 21926 3", "8 51 0", "1 10 1", "1 9 0", "53 101 6", "1 10001 9", "25102 31579 2", "38790 39359 0", "47117 ... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 86 | codeforces | Okay, I need to solve this programming problem. Let's read the problem statement carefully.
The task is to find the first occurrence of a digit c in the decimal expansion of the fraction a/b after the decimal point. The position is numbered starting from 1. If the digit doesn't appear, return -1.
So, the input is thr... | To solve this problem, we need to determine the position of the first occurrence of a specific digit in the decimal expansion of a fraction after the decimal point. The solution involves manually performing the long division process to track each digit generated and detect any repeating cycles to avoid infinite loops.
... | false | Code is incorrect. | |
adbf79a9d4af5e615e98841bd63ff9b3 | Meeting of Old Friends | Today an outstanding event is going to happen in the forest — hedgehog Filya will come to his old fried Sonya!
Sonya is an owl and she sleeps during the day and stay awake from minute *l*1 to minute *r*1 inclusive. Also, during the minute *k* she prinks and is unavailable for Filya.
Filya works a lot and he plans to ... | {"inputs": ["1 10 9 20 1", "1 100 50 200 75", "6 6 5 8 9", "1 1000000000 1 1000000000 1", "5 100 8 8 8", "1 1000000000000000000 2 99999999999999999 1000000000", "1 1 1 1 1", "1 2 3 4 5", "1 1000000000 2 999999999 3141592", "24648817341102 41165114064236 88046848035 13602161452932 10000831349205", "1080184299348 3466682... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 142 | codeforces | Okay, let's tackle this problem. Hmm. The goal is to find the overlapping time between Sonya's available time and Filya's visit, but subtract the minute when Sonya is prinking if it's in that overlap. Right.
So first, I need to find the intersection of the two time intervals [l1, r1] and [l2, r2]. The overlapping part... | To solve this problem, we need to determine the number of minutes Sonya and Filya can spend together, considering their respective available time intervals and a specific minute when Sonya is unavailable due to prinking.
### Approach
1. **Identify Overlapping Interval**: Calculate the overlapping time interval between... | true | ||
adc74535feb0901a59a1c5135823da3b | Word Correction | Victor tries to write his own text editor, with word correction included. However, the rules of word correction are really strange.
Victor thinks that if a word contains two consecutive vowels, then it's kinda weird and it needs to be replaced. So the word corrector works in such a way: as long as there are two consec... | {"inputs": ["5\nweird", "4\nword", "5\naaeaa", "100\naaaaabbbbboyoyoyoyoyacadabbbbbiuiufgiuiuaahjabbbklboyoyoyoyoyaaaaabbbbbiuiuiuiuiuaaaaabbbbbeyiyuyzyw", "69\nbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb", "12\nmmmmmmmmmmmm", "18\nyaywptqwuyiqypwoyw", "85\nbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 307 | codeforces | Okay, let's see. I need to solve this problem where Victor's text editor corrects words by removing certain vowels. The rule is that as long as there are two consecutive vowels in the word, we delete the first vowel in such a pair. And we do this repeatedly until there are no two consecutive vowels left. Hmm.
Wait, th... | To solve this problem, we need to correct a word by removing consecutive vowels according to specific rules. The goal is to repeatedly remove the second vowel in the first occurrence of consecutive vowels until no such pairs remain.
### Approach
1. **Identify Consecutive Vowels**: Check the word from left to right to ... | true | ||
adcd6dbdc21f29d273d9dcf1d6cb45ab | Tavas and Karafs | Karafs is some kind of vegetable in shape of an 1<=×<=*h* rectangle. Tavaspolis people love Karafs and they use Karafs in almost any kind of food. Tavas, himself, is crazy about Karafs.
Each Karafs has a positive integer height. Tavas has an infinite 1-based sequence of Karafses. The height of the *i*-th Karafs is *s*... | {"inputs": ["2 1 4\n1 5 3\n3 3 10\n7 10 2\n6 4 8", "1 5 2\n1 5 10\n2 7 4", "1 1 4\n1 1000000 1000000\n1 1 1000000\n1 1000000 1\n1 1 1", "1000000 1000000 1\n1000000 1000000 1000000", "999999 1000000 1\n1 1000000 1000000", "1 1000000 1\n1 1000000 1000000", "1 5000 1\n1 1000000 1000000", "1 1 1\n1 1000000 1000000", "447 7... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 10 | codeforces | Okay, I need to solve this programming problem. Let's read the problem statement carefully.
So, the problem is about Karafses arranged in a sequence. Each Karafs has a height defined by s_i = A + (i-1)*B. So it's an arithmetic sequence starting at A with difference B. For each query, we get l, t, m and need to find th... | To solve this problem, we need to determine the largest range of Karafses (a sequence of vegetables with heights in an arithmetic progression) that can be completely eaten using a given number of operations. Each operation can decrease the height of up to `m` distinct Karafses by 1. The solution involves efficiently ch... | true | ||
ade770083603ea41310a40d70e1f2c83 | Recover the String | For each string *s* consisting of characters '0' and '1' one can define four integers *a*00, *a*01, *a*10 and *a*11, where *a**xy* is the number of subsequences of length 2 of the string *s* equal to the sequence {*x*,<=*y*}.
In these problem you are given four integers *a*00, *a*01, *a*10, *a*11 and have to find any... | {"inputs": ["1 2 3 4", "1 2 2 1", "10 7 28 21", "0 0 0 0", "499928010 820999488 178951395 499991253", "49995000 11667 4308334 93096", "499928010 601314341 398636540 499991253", "0 2548 1752 650", "4950 53524 2876 158766", "20946628 20410736 263003096 958497436", "49995000 1061 8939 0", "0 0 0 45", "49995000 302076 4017... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 6 | codeforces | Okay, I need to solve this problem where given four integers a00, a01, a10, a11, I have to find a binary string that matches these counts of subsequences of two characters. If it's not possible, output Impossible. Hmm. Let's think.
First, I remember that the counts of the pairs like a00, a01, etc., are based on the nu... | To solve this problem, we need to generate a binary string that matches given counts of subsequences of length 2. The solution involves checking the validity of the input counts and constructing the string accordingly.
### Approach
1. **Check Validity of Input Counts**:
- For the given counts of subsequences `a00` ... | false | Code is incorrect. |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.