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
1aae09d59fdc0c4399e58e8469772e31
Equation
You are given an equation: Your task is to find the number of distinct roots of the equation and print all of them in ascending order. The first line contains three integer numbers *A*,<=*B* and *C* (<=-<=105<=≤<=*A*,<=*B*,<=*C*<=≤<=105). Any coefficient may be equal to 0. In case of infinite root count print the onl...
{"inputs": ["1 -5 6", "1 1 1", "1 2 1", "0 0 0", "0 -2 1", "0 -2 0", "0 0 1", "0 0 -100000", "0 10000 -100000", "1 100000 -100000", "0 3431 43123", "100 200 100", "50000 100000 50000", "-1 10 20", "-50000 100000 -50000", "1 -2 1", "1000 -5000 6000", "0 -100000 0", "1 -100000 0", "1223 -23532 1232", "-1 -2 -1", "1 0 0",...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
36
codeforces
Okay, I need to write a Python function that reads three integers A, B, C from stdin and solves the equation to find the number of distinct roots. Then output them in ascending order. Hmm, let's think step by step. First, the equation isn't given explicitly. Wait, wait, maybe it's a quadratic equation? Like Ax² + Bx +...
To solve this problem, we need to determine the number of distinct roots of a quadratic equation given by the coefficients \(A\), \(B\), and \(C\). The solution must handle various edge cases, including linear equations (when \(A = 0\)) and special cases where there are infinite or no roots. ### Approach 1. **Linear E...
false
Code is incorrect.
1adf051fd4437e5a6984d9c248647615
Drazil and Date
Someday, Drazil wanted to go on date with Varda. Drazil and Varda live on Cartesian plane. Drazil's home is located in point (0,<=0) and Varda's home is located in point (*a*,<=*b*). In each step, he can move in a unit distance in horizontal or vertical direction. In other words, from position (*x*,<=*y*) he can go to ...
{"inputs": ["5 5 11", "10 15 25", "0 5 1", "0 0 2", "999999999 999999999 2000000000", "-606037695 998320124 820674098", "948253616 -83299062 1031552680", "711980199 216568284 928548487", "-453961301 271150176 725111473", "0 0 2000000000", "0 0 1999999999", "1000000000 1000000000 2000000000", "-1000000000 1000000000 200...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
146
codeforces
Okay, let's see. The problem is to determine whether it's possible for Drazil to reach (a, b) from (0,0) in exactly s steps. Each step is moving one unit in any of the four directions. But since he moves randomly, the path can be anything as long as it's exactly s steps and ends at (a, b). So what's the condition here?...
To solve this problem, we need to determine if Drazil can reach Varda's home at coordinates (a, b) from his home at (0, 0) in exactly s steps, moving one unit in any of the four cardinal directions (up, down, left, right) each step. ### Approach 1. **Manhattan Distance Calculation**: The minimum number of steps requir...
true
1b086a205dcde6ba4c9ab03dfd1792b0
Two strings
You are given two strings *a* and *b*. You have to remove the minimum possible number of consecutive (standing one after another) characters from string *b* in such a way that it becomes a subsequence of string *a*. It can happen that you will not need to remove any characters at all, or maybe you will have to remove a...
{"inputs": ["hi\nbob", "abca\naccepted", "abacaba\nabcdcba", "lo\neuhaqdhhzlnkmqnakgwzuhurqlpmdm", "aaeojkdyuilpdvyewjfrftkpcobhcumwlaoiocbfdtvjkhgda\nmlmarpivirqbxcyhyerjoxlslyfzftrylpjyouypvk", "npnkmawey\nareakefvowledfriyjejqnnaeqheoh", "fdtffutxkujflswyddvhusfcook\nkavkhnhphcvckogqqqqhdmgwjdfenzizrebefsbuhzzwhzvc"...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
8
codeforces
Okay, I need to solve this problem where given two strings a and b, I have to remove the minimum possible number of consecutive characters from b so that the resulting string is a subsequence of a. The output should be the resulting subsequence, or a minus if it's empty. Hmm. Let's think about the problem again. The k...
To solve this problem, we need to find the longest possible subsequence of string `b` that can be formed by removing the minimum number of consecutive characters from `b` such that the resulting string is a subsequence of string `a`. If no characters need to be removed, the entire `b` is the answer. If all characters n...
false
Code is incorrect.
1b36d9af899bb91e38c9a85d7cb7a906
Data Recovery
Not so long ago company R2 bought company R1 and consequently, all its developments in the field of multicore processors. Now the R2 laboratory is testing one of the R1 processors. The testing goes in *n* steps, at each step the processor gets some instructions, and then its temperature is measured. The head engineer ...
{"inputs": ["2 1 1 2\n1", "3 1 1 3\n2", "2 1 1 3\n2", "3 1 1 5\n3", "3 2 1 5\n1 5", "3 2 1 5\n1 1", "3 2 1 5\n5 5", "3 2 1 5\n1 6", "3 2 5 10\n1 10", "6 5 3 6\n4 4 4 4 4", "100 50 68 97\n20 42 93 1 98 6 32 11 48 46 82 96 24 73 40 100 99 10 55 87 65 80 97 54 59 48 30 22 16 92 66 2 22 60 23 81 64 60 34 60 99 99 4 70 91 9...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
38
codeforces
Okay, let's see. I need to solve this programming problem. The problem is about determining whether the assistant's reported temperatures can be upgraded to meet certain conditions. Let me read the problem statement again to make sure I understand it. So, the input gives n, m, min, max, and then m temperatures. The qu...
To solve this problem, we need to determine if the given set of temperatures reported by an assistant can be expanded to meet specific minimum and maximum temperature requirements. The goal is to check if it's possible to add temperatures such that the resulting set meets the required minimum and maximum values. ### A...
true
1b5ef8cfd69d5dc48a7f392e465d3a59
A Colourful Prospect
Firecrackers scare Nian the monster, but they're wayyyyy too noisy! Maybe fireworks make a nice complement. Little Tommy is watching a firework show. As circular shapes spread across the sky, a splendid view unfolds on the night of Lunar New Year's eve. A wonder strikes Tommy. How many regions are formed by the circl...
{"inputs": ["3\n0 0 1\n2 0 1\n4 0 1", "3\n0 0 2\n3 0 2\n6 0 2", "3\n0 0 2\n2 0 2\n1 1 2", "1\n0 0 10", "2\n-10 10 1\n10 -10 1", "2\n-6 6 9\n3 -6 6", "2\n-10 -10 10\n10 10 10", "3\n-4 1 5\n-7 7 10\n-3 -4 8", "3\n-2 8 10\n3 -2 5\n3 1 3", "3\n0 0 2\n0 0 4\n3 0 2", "3\n8 5 7\n7 3 7\n5 2 5", "3\n-6 5 7\n1 -2 7\n7 9 7", "3\n...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
1
codeforces
Okay, I need to solve this problem where I have to find the number of regions formed by n circles on a plane. The input gives up to 3 circles. Let's think about how the regions are formed based on the number of circles and their intersections. First, I remember from some math that the maximum number of regions created...
To solve this problem, we need to determine the number of regions formed by up to three circles on a plane. The regions are defined as connected areas bounded by the circles, with exactly one region extending infinitely. The solution involves calculating the number of intersections between circles and applying graph th...
false
Code is incorrect.
1b67757cd76a83e0896376acaf8af9eb
Vacations
Vasya has *n* days of vacations! So he decided to improve his IT skills and do sport. Vasya knows the following information about each of this *n* days: whether that gym opened and whether a contest was carried out in the Internet on that day. For the *i*-th day there are four options: 1. on this day the gym is close...
{"inputs": ["4\n1 3 2 0", "7\n1 3 3 2 1 2 3", "2\n2 2", "1\n0", "10\n0 0 1 1 0 0 0 0 1 0", "100\n3 2 3 3 3 2 3 1 3 2 2 3 2 3 3 3 3 3 3 1 2 2 3 1 3 3 2 2 2 3 1 0 3 3 3 2 3 3 1 1 3 1 3 3 3 1 3 1 3 0 1 3 2 3 2 1 1 3 2 3 3 3 2 3 1 3 3 3 3 2 2 2 1 3 1 3 3 3 3 1 3 2 3 3 0 3 3 3 3 3 1 0 2 1 3 3 0 2 3 3", "10\n2 3 0 1 3 1 2 2 ...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
490
codeforces
Okay, let's try to solve this problem. So, the task is to find the minimum number of days Vasya has to rest, given the constraints that he can't do the same activity on two consecutive days. Hmm, right. First, I need to understand the problem thoroughly. The input is a list of days, each day has a certain code (0-3) t...
To solve this problem, we need to determine the minimum number of days Vasya will rest during his vacation, given the constraints that he cannot do the same activity (sport or contest) on consecutive days. The solution involves using dynamic programming to track the minimum rest days required based on the activities al...
true
1ba3cfe4997ee8dcd640bb7f5ff1c2d8
Orange
The first line of the input is a string (between 1 and 50 characters long, inclusive). Each character will be a letter of English alphabet, lowercase or uppercase. The second line of the input is an integer between 0 and 26, inclusive. Output the required string. Sample Input AprilFool 14 Sample Output AprILFooL
{"inputs": ["AprilFool\n14", "abcdefabc\n3", "fgWjSAlPOvcAbCdDEFjz\n7", "sm\n26", "GnlFOqPeZtPiBkvvLhaDvGPgFqBTnLgMT\n12", "sPWSFWWqZBPon\n3", "fQHHXCdeaintxHWcFcaSGWFvqnYMEByMlSNKumiFgnJB\n0", "RtsUOGkraqKyjTktAXloOEmQj\n18", "DuFhhnq\n4", "RvpuYTxsbDiJDOLauRlfatcfwvtnDzKyaewGrZ\n22", "isfvbcBEEPaXUDhbVhwddjEutVQqNdli...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
16
codeforces
Okay, let's tackle this programming problem. So the task is to process a string based on some integer input and output a modified version of the string. Hmm. Let's read the problem carefully again. The input is a string and an integer. The output is the required string. The sample input is "AprilFool" and 14, and the ...
To solve this problem, we need to transform a given string based on an integer input. The transformation involves changing the case of each character depending on its position in the alphabet relative to the given integer. ### Approach 1. **Input Reading**: Read the input string and the integer. 2. **Character Proces...
true
1ba91a102a7f37aac8832718ae66b16b
Biridian Forest
You're a mikemon breeder currently in the middle of your journey to become a mikemon master. Your current obstacle is go through the infamous Biridian Forest. The forest The Biridian Forest is a two-dimensional grid consisting of *r* rows and *c* columns. Each cell in Biridian Forest may contain a tree, or may be vac...
{"inputs": ["5 7\n000E0T3\nT0TT0T0\n010T0T0\n2T0T0T0\n0T0S000", "1 4\nSE23", "3 3\n000\nS0E\n000", "5 5\nS9999\nTTTT9\n99999\n9TTTT\n9999E", "1 10\n9T9TSET9T9", "10 1\nS\n9\n9\n9\n9\nE\n9\n9\n9\n9", "4 3\nS01\n234\n567\n89E", "2 2\nE9\nS4", "3 3\n920\n752\nE8S", "5 1\n9\nT\nE\n6\nS", "1 5\n78S6E", "9 8\n38030772\n697T8...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
8
codeforces
Okay, let's tackle this problem. Hmm, the problem statement is a bit complex, but I'll try to break it down step by step. So, the main goal is to find the minimum number of mikemon battles that the player has to participate in when moving from their starting position 'S' to the exit 'E' in a grid. The other breeders ...
To solve this problem, we need to determine the minimum number of mikemon battles the player must engage in while navigating from the start position 'S' to the exit 'E' in the Biridian Forest. The other breeders will move optimally to intercept the player, and our goal is to choose a path that minimizes these encounter...
true
1bbc1b8f93c00a8c754ecaa1479f9bbf
Lesha and array splitting
One spring day on his way to university Lesha found an array *A*. Lesha likes to split arrays into several parts. This time Lesha decided to split the array *A* into several, possibly one, new arrays so that the sum of elements in each of the new arrays is not zero. One more condition is that if we place the new arrays...
{"inputs": ["3\n1 2 -3", "8\n9 -12 3 4 -4 -10 7 3", "1\n0", "4\n1 2 3 -5", "6\n0 0 0 0 0 0", "100\n507 -724 -243 -846 697 -569 -786 472 756 -272 731 -534 -664 202 592 -381 161 -668 -895 296 472 -868 599 396 -617 310 -283 -118 829 -218 807 939 -152 -343 -96 692 -570 110 442 159 -446 -631 -881 784 894 -3 -792 654 -273 -7...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
88
codeforces
Okay, let's tackle this problem. So, the task is to split the given array into subarrays such that the sum of each subarray is not zero. And the subarrays need to be contiguous and cover the entire array. If it's impossible, we output NO. Otherwise, we need to provide the split. Hmm. Let's think about the possible cas...
To solve this problem, we need to split an array into one or more contiguous subarrays such that the sum of each subarray is non-zero. If it's impossible to split the array under these constraints, we should output "NO". Otherwise, we need to provide a valid split. ### Approach 1. **Check Total Sum**: If the sum of th...
false
Code is incorrect.
1bc2b438bd8b82a4aa536af61323166e
Magazine Ad
The main city magazine offers its readers an opportunity to publish their ads. The format of the ad should be like this: There are space-separated non-empty words of lowercase and uppercase Latin letters. There are hyphen characters '-' in some words, their positions set word wrapping points. Word can include more th...
{"inputs": ["4\ngarage for sa-le", "4\nEdu-ca-tion-al Ro-unds are so fun", "1\nj", "10\nb", "1\nQGVsfZevMD", "1\nqUOYCytbKgoGRgaqhjrohVRxKTKjjOUPPnEjiXJWlvpCyqiRzbnpyNqDylWverSTrcgZpEoDKhJCrOOvsuXHzkPtbXeKCKMwUTVk", "100000\nBGRHXGrqgjMxCBCdQTCpQyHNMkraTRxhyZBztkxXNFEKnCNjHWeCWmmrRjiczJAdfQqdQfnuupPqzRhEKnpuTCsVPNVTIMi...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
25
codeforces
Okay, let's tackle this problem. So, the task is to find the minimal width of an ad such that it fits into k lines. The width is the maximum line length among all lines. We need to minimize this maximum width. Hmm. Let's start by understanding the problem. The ad is made up of words that can have hyphens. Hyphens are ...
To solve this problem, we need to determine the minimal width of an ad such that it can be formatted into at most `k` lines. The width is defined as the maximum length of any line in the formatted ad. The ad text consists of words that can be split at hyphens, and spaces between words. The goal is to find the optimal w...
false
Code is incorrect.
1bc3e611b56cd450a7fb71b37744f2d8
Sagheer and Apple Tree
Sagheer is playing a game with his best friend Soliman. He brought a tree with *n* nodes numbered from 1 to *n* and rooted at node 1. The *i*-th node has *a**i* apples. This tree has a special property: the lengths of all paths from the root to any leaf have the same parity (i.e. all paths have even length or all paths...
{"inputs": ["3\n2 2 3\n1 1", "3\n1 2 3\n1 1", "8\n7 2 2 5 4 3 1 1\n1 1 1 4 4 5 6", "6\n7 7 7 7 7 7\n1 1 1 1 1", "6\n3 1 1 1 2 2\n1 1 1 1 1", "6\n1 2 3 4 5 6\n1 2 3 4 5", "7\n15 3 5 1 2 4 8\n1 1 2 2 3 3", "7\n15 3 5 1 2 4 9\n1 1 2 2 3 3", "7\n15 16 32 1 2 4 9\n1 1 2 2 3 3", "6\n49 70 74 18 64 63\n1 2 2 1 5", "9\n15 17 6...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
3
codeforces
Okay, let's see. I need to solve this programming problem. Let me read the problem statement carefully. So, Sagheer has a tree where each node has some apples. The tree has a special property: all root-to-leaf paths have the same parity (either all even or all odd length). Sagheer can swap the apples of any two distin...
To solve this problem, we need to determine the number of valid node swaps in a tree such that Sagheer will win the game if both players play optimally. The solution involves analyzing the tree structure, computing Grundy numbers, and using XOR operations to determine the optimal swaps. ### Approach 1. **Tree Structur...
true
1bd2de89b88911f54537f09932bbfcf9
Degenerate Matrix
The determinant of a matrix 2<=×<=2 is defined as follows: A matrix is called degenerate if its determinant is equal to zero. The norm ||*A*|| of a matrix *A* is defined as a maximum of absolute values of its elements. You are given a matrix . Consider any degenerate matrix *B* such that norm ||*A*<=-<=*B*|| is min...
{"inputs": ["1 2\n3 4", "1 0\n0 1", "1000000000 0\n0 1000000000", "8205 9482\n11 -63", "0 0\n0 0", "1000000000 -1000000000\n1000000000 1000000000", "1000000000 1000000000\n1000000000 -1000000000", "-1 -1\n1 0", "5 2\n-15 -6", "2 -5\n-3 2", "-5 -2\n-1 -3", "-5 8\n1 6", "1 3\n3 2", "-42 63\n77 -32", "91 -7\n-21 91", "-67...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
19
codeforces
Okay, let's tackle this problem. The task is to find the minimum possible norm ||A - B|| where B is a degenerate matrix (determinant zero). The norm here is the maximum absolute value of the elements of the matrix A - B. So, we need to adjust the elements of B such that the determinant of B is zero, and the maximum dif...
To solve this problem, we need to determine the minimum possible value of the norm ||A - B||, where B is a degenerate matrix (a matrix with a determinant of zero) and A is the given matrix. The norm is defined as the maximum absolute value of the elements of the matrix A - B. ### Approach 1. **Check for Degenerate Mat...
false
Code is incorrect.
1be5e5a36186928a169b53c3d91ce365
Nephren Runs a Cinema
Lakhesh loves to make movies, so Nephren helps her run a cinema. We may call it No. 68 Cinema. However, one day, the No. 68 Cinema runs out of changes (they don't have 50-yuan notes currently), but Nephren still wants to start their business. (Assume that yuan is a kind of currency in Regulu Ere.) There are three t...
{"inputs": ["4 97 2 3", "4 100 0 4", "13 143 6 11", "999 998244353 666 777", "23333 1000000007 0 23333", "100000 100160063 2332 99774", "100000 996991027 54321 67890", "1 1 0 0", "1 1 0 1", "1 233332 0 0", "1 999888663 0 1", "1 2000000000 1 1", "2 14 0 0", "2 39 0 1", "2 1999999999 0 2", "2 15 1 1", "2 2 1 2", "2 3 2 2...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
1
codeforces
Okay, let's try to understand this problem. So, the task is to calculate the number of possible customer queues such that the cinema can provide change when needed, and after serving all customers, the number of 50-yuan notes they have is between l and r, inclusive. We also need to compute this modulo p. Hmm. Let's br...
To solve this problem, we need to determine the number of valid customer queues for a cinema that can run smoothly given certain constraints. The solution involves combinatorial mathematics and dynamic programming to efficiently compute the required values. ### Approach 1. **Combinatorial Analysis**: The problem can b...
false
Code is incorrect.
1c3d7c7c251da6bd6d5318dc55816483
On Segment's Own Points
Our old friend Alexey has finally entered the University of City N — the Berland capital. Alexey expected his father to get him a place to live in but his father said it was high time for Alexey to practice some financial independence. So, Alexey is living in a dorm. The dorm has exactly one straight dryer — a 100 ce...
{"inputs": ["3\n0 5\n2 8\n1 6", "3\n0 10\n1 5\n7 15", "1\n0 100", "2\n1 9\n1 9", "2\n1 9\n5 10", "2\n1 9\n3 5", "2\n3 5\n1 9", "10\n43 80\n39 75\n26 71\n4 17\n11 57\n31 42\n1 62\n9 19\n27 76\n34 53", "50\n33 35\n98 99\n1 2\n4 6\n17 18\n63 66\n29 30\n35 37\n44 45\n73 75\n4 5\n39 40\n92 93\n96 97\n23 27\n49 50\n2 3\n60 6...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
80
codeforces
Okay, let's see. I need to solve this programming problem. Let's read the problem carefully. So, the problem is about Alexey's dryer segment. He is student 1, and we need to find the total length of the parts of his segment that are not covered by any other students' segments. Oh right, because he doesn't want anyone ...
To solve this problem, we need to determine the total length of the dryer segment that Alexey can use exclusively, without any overlap from segments assigned to other students. ### Approach 1. **Input Reading**: Read the number of students and their respective segments. 2. **Identify Alexey's Segment**: The first seg...
true
1c41a03010f966e896c90f173d265027
PLEASE
As we all know Barney's job is "PLEASE" and he has not much to do at work. That's why he started playing "cups and key". In this game there are three identical cups arranged in a line from left to right. Initially key to Barney's heart is under the middle cup. Then at one turn Barney swaps the cup in the middle with a...
{"inputs": ["1\n2", "3\n1 1 1", "1\n983155795040951739", "2\n467131402341701583 956277077729692725", "10\n217673221404542171 806579927281665969 500754531396239406 214319484250163112 328494187336342674 427465830578952934 951554014286436941 664022909283791499 653206814724654845 66704816231807388", "8\n137264686188377169 ...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
7
codeforces
Okay, I need to solve this problem where after n turns, the probability that the key is in the middle cup is required. The input gives an array whose product is n, and I have to compute the probability as a reduced fraction modulo 1e9+7. Let's start by understanding the problem. So, the key starts under the middle cup...
To solve this problem, we need to determine the probability that the key remains under the middle cup after a series of swaps, given as an irreducible fraction modulo \(10^9 + 7\). The number of swaps \(n\) is the product of elements in an input array, which can be extremely large. ### Approach 1. **State Transition ...
true
1c9df2f477b8d47d31cf463f5a731156
Joty and Chocolate
Little Joty has got a task to do. She has a line of *n* tiles indexed from 1 to *n*. She has to paint them in a strange pattern. An unpainted tile should be painted Red if it's index is divisible by *a* and an unpainted tile should be painted Blue if it's index is divisible by *b*. So the tile with the number divisibl...
{"inputs": ["5 2 3 12 15", "20 2 3 3 5", "1 1 1 1 1", "1 2 2 2 2", "2 1 3 3 3", "3 1 1 3 3", "4 1 5 4 3", "8 8 1 1 1", "15 14 32 65 28", "894 197 325 232 902", "8581 6058 3019 2151 4140", "41764 97259 54586 18013 75415", "333625 453145 800800 907251 446081", "4394826 2233224 609367 3364334 898489", "13350712 76770926 6...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
107
codeforces
Okay, let's see. The problem is about Joty painting tiles in such a way that she maximizes the chocolates she gets. So, the tiles are from 1 to n. Each tile can be painted red if divisible by a, blue if divisible by b. But if a tile is divisible by both a and b, she can choose either color. The goal is to choose optima...
To solve this problem, we need to determine the maximum number of chocolates Joty can get by painting tiles in a way that maximizes her chocolates. The tiles can be painted either red or blue based on their indices and given divisors. The challenge is to optimally choose the color for tiles that meet both divisibility ...
true
1cc716b77421e3d6b18974cbc830152f
Hard problem
Vasiliy is fond of solving different tasks. Today he found one he wasn't able to solve himself, so he asks you to help. Vasiliy is given *n* strings consisting of lowercase English letters. He wants them to be sorted in lexicographical order (as in the dictionary), but he is not allowed to swap any of them. The only o...
{"inputs": ["2\n1 2\nba\nac", "3\n1 3 1\naa\nba\nac", "2\n5 5\nbbb\naaa", "2\n3 3\naaa\naa", "4\n0 0 8 6\nbi\nqp\nbt\nya", "5\n8 0 4 8 2\nac\ncl\ngg\ngm\nfs", "10\n7 7 0 0 0 1 6 6 7 3\ndv\ngb\nvg\nxg\nkt\nml\nqm\nnq\nrt\nxn", "3\n999999999 999999999 999999999\nxosbqqnmxq\nsdbvjhvytx\naydpuidgvy", "3\n228 1488 228\nkek\...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
10
codeforces
Okay, let's try to solve this problem. So the task is to find the minimum energy required to reverse some of the strings so that the resulting sequence is lexicographically sorted. Hmm. First, let's understand the problem. Each string can be either reversed (with cost ci) or not. The reversed versions of the strings m...
To solve this problem, we need to determine the minimum energy required to reverse some strings such that they are sorted in lexicographical order. Each string can either be left as is or reversed, with each reversal having a specific energy cost. The goal is to find the optimal way to achieve the sorted order with the...
true
1cc7f991569d0b44661ef185c3842674
Party Lemonade
A New Year party is not a New Year party without lemonade! As usual, you are expecting a lot of guests, and buying lemonade has already become a pleasant necessity. Your favorite store sells lemonade in bottles of *n* different volumes at different costs. A single bottle of type *i* has volume 2*i*<=-<=1 liters and co...
{"inputs": ["4 12\n20 30 70 90", "4 3\n10000 1000 100 10", "4 3\n10 100 1000 10000", "5 787787787\n123456789 234567890 345678901 456789012 987654321", "30 792520535\n528145579 682850171 79476920 178914057 180053263 538638086 433143781 299775597 723428544 177615223 959893339 639448861 506106572 807471834 42398440 347390...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
46
codeforces
Okay, let's see. The problem is about buying lemonade bottles such that we get at least L liters, with the minimal cost. The bottles have different volumes and costs. Each type i has a volume of 2^(i-1) liters and cost c_i. Hmm, but wait, the first line says "bottle of type i has volume 2^(i-1) liters". Oh right, so th...
To solve this problem, we need to determine the minimum cost to buy at least L liters of lemonade from bottles of varying sizes and costs. The key insight is to leverage the fact that larger bottle sizes can sometimes be more cost-effective than smaller ones, even if their individual costs are higher. ### Approach 1....
true
1cdc43323dd7fe34277766feb4665594
Gargari and Bishops
Gargari is jealous that his friend Caisa won the game from the previous problem. He wants to prove that he is a genius. He has a *n*<=×<=*n* chessboard. Each cell of the chessboard has a number written on it. Gargari wants to place two bishops on the chessboard in such a way that there is no cell that is attacked by b...
{"inputs": ["4\n1 1 1 1\n2 1 1 0\n1 1 1 0\n1 0 0 1", "10\n48 43 75 80 32 30 65 31 18 91\n99 5 12 43 26 90 54 91 4 88\n8 87 68 95 73 37 53 46 53 90\n50 1 85 24 32 16 5 48 98 74\n38 49 78 2 91 3 43 96 93 46\n35 100 84 2 94 56 90 98 54 43\n88 3 95 72 78 78 87 82 25 37\n8 15 85 85 68 27 40 10 22 84\n7 8 36 90 10 81 98 51 7...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
10
codeforces
Okay, let's see. The problem is about placing two bishops on a chessboard such that no cell is attacked by both, and the sum of the values of all cells attacked by either bishop is maximized. Hmm. So each bishop attacks along its diagonals, but we need to choose two positions where their attacked cells don't overlap. T...
To solve this problem, we need to place two bishops on an n×n chessboard such that no cell is attacked by both bishops, and the sum of the values of all cells attacked by either bishop is maximized. ### Approach 1. **Sum Calculation for Diagonals**: Each bishop attacks cells along its main diagonal (from top-left to ...
false
Code is incorrect.
1ce225768b73b495b489addb4d0fd10a
Okabe and Boxes
Okabe and Super Hacker Daru are stacking and removing boxes. There are *n* boxes numbered from 1 to *n*. Initially there are no boxes on the stack. Okabe, being a control freak, gives Daru 2*n* commands: *n* of which are to add a box to the top of the stack, and *n* of which are to remove a box from the top of the sta...
{"inputs": ["3\nadd 1\nremove\nadd 2\nadd 3\nremove\nremove", "7\nadd 3\nadd 2\nadd 1\nremove\nadd 4\nremove\nremove\nremove\nadd 6\nadd 7\nadd 5\nremove\nremove\nremove", "4\nadd 1\nadd 3\nremove\nadd 4\nadd 2\nremove\nremove\nremove", "2\nadd 1\nremove\nadd 2\nremove", "1\nadd 1\nremove", "15\nadd 12\nadd 7\nadd 10\n...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
33
codeforces
Okay, let's try to solve this problem. Hmm, the problem statement is a bit complex, but let's break it down. So, we have Daru who needs to follow a sequence of commands (add and remove) from Okabe. The catch is that when a remove command is issued, the top of the stack must be the next expected box (starting from 1 up ...
To solve this problem, we need to determine the minimum number of times Daru needs to reorder the stack of boxes to follow Okabe's commands such that boxes are removed in the order from 1 to n. The challenge arises when the next expected box to be removed is not at the top of the stack, necessitating a reorder. ### Ap...
false
Code is incorrect.
1cec334a5ccee5eb45955d9a63427621
Graph Coloring
You are given an undirected graph that consists of *n* vertices and *m* edges. Initially, each edge is colored either red or blue. Each turn a player picks a single vertex and switches the color of all edges incident to it. That is, all red edges with an endpoint in this vertex change the color to blue, while all blue ...
{"inputs": ["3 3\n1 2 B\n3 1 R\n3 2 B", "6 5\n1 3 R\n2 3 R\n3 4 B\n4 5 R\n4 6 R", "4 5\n1 2 R\n1 3 R\n2 3 B\n3 4 B\n1 4 B", "6 6\n1 2 R\n1 3 R\n2 3 R\n4 5 B\n4 6 B\n5 6 B", "3 3\n1 2 R\n1 3 R\n2 3 R", "11 7\n1 2 B\n1 3 R\n3 2 R\n4 5 R\n6 7 R\n8 9 R\n10 11 R", "2 1\n1 2 B"], "outputs": ["1\n2 ", "2\n3 4 ", "-1", "-1", "...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
1
codeforces
Okay, I need to solve this problem where I have to find the minimum number of vertex flips to turn all edges the same color. Hmm. Let's think about how the flipping works. Each edge's color can be toggled by flipping either of its two vertices. Because flipping a vertex affects all edges incident to it. So, for each e...
To solve this problem, we need to determine the minimum number of vertex flips required to make all edges in an undirected graph the same color, either red or blue. Each vertex flip toggles the color of all edges incident to that vertex. The solution must consider both target colors (red and blue) and determine the opt...
false
Code is incorrect.
1cf5b764b7c020a63fed240ea3c9ed09
Pasha and Phone
Pasha has recently bought a new phone jPager and started adding his friends' phone numbers there. Each phone number consists of exactly *n* digits. Also Pasha has a number *k* and two sequences of length *n*<=/<=*k* (*n* is divisible by *k*) *a*1,<=*a*2,<=...,<=*a**n*<=/<=*k* and *b*1,<=*b*2,<=...,<=*b**n*<=/<=*k*. Le...
{"inputs": ["6 2\n38 56 49\n7 3 4", "8 2\n1 22 3 44\n5 4 3 2", "2 1\n9 9\n9 9", "2 1\n9 9\n0 9", "4 1\n4 3 2 1\n1 2 3 4", "18 9\n2 3\n0 4", "4 4\n1122\n2", "10 5\n8378 11089\n7 5", "10 5\n52057 11807\n0 1", "10 1\n3 1 1 4 8 7 5 6 4 1\n0 0 0 5 5 6 8 8 4 0", "100 4\n388 2056 122 1525 2912 1465 3066 257 5708 3604 3039 618...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
30
codeforces
Okay, I need to solve this programming problem. Let's read the problem statement carefully. So, the problem is about counting the number of valid phone numbers based on certain conditions. The phone number is divided into blocks, each of length k. For each block, there are two conditions: the first digit of the block ...
To solve this problem, we need to determine the number of valid phone numbers of length `n` that meet specific criteria when divided into blocks of length `k`. Each block must not start with a specified digit and must be divisible by a given number. The solution involves calculating valid numbers for each block and com...
true
1cfd8e00daefe70b7d76fc42938a21b8
New Password
Innokentiy decides to change the password in the social net "Contact!", but he is too lazy to invent a new password by himself. That is why he needs your help. Innokentiy decides that new password should satisfy the following conditions: - the length of the password must be equal to *n*, - the password should cons...
{"inputs": ["4 3", "6 6", "5 2", "3 2", "10 2", "26 13", "100 2", "100 10", "3 3", "6 3", "10 3", "50 3", "90 2", "6 2", "99 3", "4 2", "100 3", "40 22", "13 8", "16 15", "17 17", "19 4", "100 26", "100 25", "26 26", "27 26", "2 2", "26 25", "99 2", "99 26", "4 4", "5 3", "5 4", "5 5", "24 22", "26 14", "26 15", "30 12...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
611
codeforces
Okay, let's see. I need to generate a password that meets certain conditions. The problem states that the password must have length n, exactly k distinct characters, and no two consecutive characters are the same. Also, it's guaranteed that a solution exists, so I don't have to worry about impossible cases. First, I n...
To solve this problem, we need to generate a password of length `n` using exactly `k` distinct lowercase Latin letters such that no two consecutive characters are the same. The solution must ensure that the generated password meets all the given conditions. ### Approach 1. **Initial Sequence**: Start by creating an in...
false
Code is incorrect.
1d1a1e0764f53ad7c036de5671142880
Sad powers
You're given *Q* queries of the form (*L*,<=*R*). For each query you have to find the number of such *x* that *L*<=≤<=*x*<=≤<=*R* and there exist integer numbers *a*<=&gt;<=0, *p*<=&gt;<=1 such that *x*<==<=*a**p*. The first line contains the number of queries *Q* (1<=≤<=*Q*<=≤<=105). The next *Q* lines contains two...
{"inputs": ["6\n1 4\n9 9\n5 7\n12 29\n137 591\n1 1000000", "20\n862 928\n758 964\n541 789\n622 943\n328 900\n14 764\n217 972\n461 847\n442 468\n900 986\n518 529\n938 993\n549 851\n690 944\n484 601\n320 910\n98 868\n816 915\n765 880\n551 770"], "outputs": ["2\n1\n0\n3\n17\n1111", "1\n4\n5\n6\n14\n32\n20\n9\n0\n2\n1\n1\n...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
2
codeforces
Okay, so I need to solve this problem where for each query L to R, I have to find how many numbers x in that range can be expressed as a^p, where a is a non-negative integer and p is at least 2. Hmm, right. So the task is to count all perfect squares, cubes, etc. between L and R, but making sure that we don't double co...
To solve this problem, we need to determine the number of integers \( x \) in the range \([L, R]\) that can be expressed as \( a^p \) where \( a \) is a non-negative integer and \( p \) is an integer greater than or equal to 2. This requires an efficient approach due to the large constraints on \( L \) and \( R \). ##...
false
Code is incorrect.
1d43ed69859cb281bfafbf1d2a06eb3f
Promocodes with Mistakes
During a New Year special offer the "Sudislavl Bars" offered *n* promo codes. Each promo code consists of exactly six digits and gives right to one free cocktail at the bar "Mosquito Shelter". Of course, all the promocodes differ. As the "Mosquito Shelter" opens only at 9, and partying in Sudislavl usually begins at a...
{"inputs": ["2\n000000\n999999", "6\n211111\n212111\n222111\n111111\n112111\n121111", "1\n123456", "2\n000000\n099999", "2\n000000\n009999", "2\n000000\n000999", "2\n000000\n000099", "2\n000000\n000009", "1\n000000", "1\n999999", "10\n946965\n781372\n029568\n336430\n456975\n119377\n179098\n925374\n878716\n461563", "10\...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
15
codeforces
Okay, so I need to solve this problem where I have to find the maximum k such that any promo code can be uniquely identified even if there are up to k errors. The errors here are individual digits that are wrong. The key is to find the minimal number of differing digits between any pair of promo codes, and then determi...
To solve this problem, we need to determine the maximum number of errors (k) allowed in entering a promo code such that each promo code can still be uniquely identified. The solution involves calculating the minimum Hamming distance between all pairs of promo codes and using this value to determine the maximum allowabl...
true
1d8453764c751d2f477673148a740919
Points and Segments (easy)
Iahub isn't well prepared on geometry problems, but he heard that this year there will be a lot of geometry problems on the IOI selection camp. Scared, Iahub locked himself in the basement and started thinking of new problems of this kind. One of them is the following. Iahub wants to draw *n* distinct points and *m* s...
{"inputs": ["3 3\n3 7 14\n1 5\n6 10\n11 15", "3 4\n1 2 3\n1 2\n2 3\n5 6\n2 2", "10 10\n3 4 2 6 1 9 0 5 8 7\n5 7\n2 6\n0 1\n5 6\n3 4\n2 5\n2 10\n4 6\n3 6\n3 7", "3 3\n50 51 52\n1 5\n6 10\n11 15", "3 1\n1 2 3\n2 3"], "outputs": ["0 0 0", "1 0 1 ", "0 1 1 1 0 0 1 0 1 0 ", "1 0 1 ", "1 0 1 "]}
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
29
codeforces
Okay, let's see. The problem is to color each point either red or blue such that for every segment, the absolute difference between the number of red and blue points in that segment is at most 1. Hmm. So each segment can have r_i and b_i where |r_i - b_i| ≤1. First, I need to process the input. The points are given, ...
To solve this problem, we need to determine a valid coloring of points on the OX axis such that for each given segment, the absolute difference between the number of red and blue points within the segment is at most 1. The solution involves a systematic approach to handle constraints from segments with even and odd num...
false
Code is incorrect.
1d95be69ba194a67b9185fef152c655f
Army Creation
As you might remember from our previous rounds, Vova really likes computer games. Now he is playing a strategy game known as Rage of Empires. In the game Vova can hire *n* different warriors; *i*th warrior has the type *a**i*. Vova wants to create a balanced army hiring some subset of warriors. An army is called balan...
{"inputs": ["6 2\n1 1 1 2 2 2\n5\n1 6\n4 3\n1 1\n2 6\n2 6", "5 5\n3 4 4 2 1\n5\n5 5\n5 4\n5 4\n3 4\n5 5", "5 5\n2 1 2 4 1\n5\n5 3\n1 1\n5 1\n2 1\n2 3", "10 5\n4 5 7 3 5 6 6 8 10 9\n5\n10 8\n9 8\n7 5\n8 10\n5 8", "20 5\n9 5 4 10 2 1 8 9 7 4 1 5 4 9 8 10 5 8 4 10\n5\n9 13\n17 13\n6 12\n13 11\n8 8", "100 5\n45 51 23 10 62...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
1
codeforces
Okay, let's see. The problem is about finding the maximum size of a balanced army for each query. The army has to be a subset of warriors in a certain range, and each type can't have more than k warriors in it. So for each query, which gives a range [l_i, r_i], we need to determine the maximum possible size of such a s...
To solve this problem, we need to determine the largest size of a balanced army for each query, where a balanced army is defined as a subset of warriors such that no type of warrior exceeds a given count `k`. Each query specifies a range of warriors to consider, and the results of previous queries affect the parameters...
true
1dad4aab8c75f71ea2952a36002504ad
Predict Outcome of the Game
There are *n* games in a football tournament. Three teams are participating in it. Currently *k* games had already been played. You are an avid football fan, but recently you missed the whole *k* games. Fortunately, you remember a guess of your friend for these *k* games. Your friend did not tell exact number of wins...
{"inputs": ["5\n3 0 0 0\n3 3 0 0\n6 4 1 0\n6 3 3 0\n3 3 3 2"], "outputs": ["yes\nyes\nyes\nno\nno"]}
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
1
codeforces
Okay, let's try to figure out this problem. So the task is to determine whether it's possible for three football teams to end up with the same number of wins after n games, given that k games have already been played and the friend's guess about the differences between their wins. The friend's guess says that after k g...
To solve this problem, we need to determine if it's possible for three football teams to end up with the same number of wins after `n` games, given that `k` games have already been played and a friend's guess about the differences between their wins. The friend's guess specifies that after `k` games, the absolute diffe...
true
1df64825d70c19acab8be693fb95a789
Bear and Three Musketeers
Do you know a story about the three musketeers? Anyway, you will learn about its origins now. Richelimakieu is a cardinal in the city of Bearis. He is tired of dealing with crime by himself. He needs three brave warriors to help him to fight against bad guys. There are *n* warriors. Richelimakieu wants to choose thre...
{"inputs": ["5 6\n1 2\n1 3\n2 3\n2 4\n3 4\n4 5", "7 4\n2 1\n3 6\n5 1\n1 7", "5 0", "7 14\n3 6\n2 3\n5 2\n5 6\n7 5\n7 4\n6 2\n3 5\n7 1\n4 1\n6 1\n7 6\n6 4\n5 4", "15 15\n4 15\n12 1\n15 6\n11 6\n15 7\n6 8\n15 10\n6 12\n12 8\n15 8\n15 3\n11 9\n7 3\n6 4\n12 11", "12 66\n9 12\n1 4\n8 4\n5 3\n10 5\n12 2\n3 2\n2 7\n1 7\n3 7\n...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
101
codeforces
Okay, I need to solve this programming problem. Let me read the problem statement carefully. So, the problem is about finding three musketeers (warriors) who know each other. The main conditions are that they must form a trio where each knows the other two, and we need to minimize the sum of their recognitions. Recogn...
To solve this problem, we need to determine if it's possible to select three warriors (musketeers) who know each other and compute the minimum possible sum of their recognitions. Recognition for each musketeer is defined as the number of other warriors they know, excluding the other two musketeers. ### Approach 1. **G...
true
1e05c048abf89b10b87662857fb3d340
Porcelain
During her tantrums the princess usually smashes some collectable porcelain. Every furious shriek is accompanied with one item smashed. The collection of porcelain is arranged neatly on *n* shelves. Within each shelf the items are placed in one row, so that one can access only the outermost items — the leftmost or the...
{"inputs": ["2 3\n3 3 7 2\n3 4 1 5", "1 3\n4 4 3 1 2", "1 4\n6 5 1 10 1 1 5", "3 2\n1 10\n1 2\n1 5", "1 68\n100 26 58 15 8 69 66 49 97 18 74 27 39 19 76 37 25 4 88 75 17 79 41 21 44 39 7 42 63 82 92 87 41 85 25 30 43 80 95 70 98 88 16 15 97 74 81 76 33 19 64 3 14 72 17 36 33 21 34 59 38 75 48 1 57 20 81 56 74 67 14 89 ...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
1
codeforces
Okay, I need to solve this programming problem. Let's read the problem statement carefully. The problem is about finding the maximal damage the princess can do by smashing m items from n shelves. The key point is that each shelf is arranged such that you can only take items from the left or right end. For each shelf, ...
To solve this problem, we need to determine the maximum damage the princess can inflict by smashing exactly `m` items from `n` shelves, where each shelf allows taking items only from the leftmost or rightmost end. The solution involves dynamic programming to efficiently compute the maximum possible sum of items taken. ...
true
1e20de0e4e64dcaf65977de7275cd6b7
Array
Vitaly has an array of *n* distinct integers. Vitaly wants to divide this array into three non-empty sets so as the following conditions hold: 1. The product of all numbers in the first set is less than zero (<=&lt;<=0). 1. The product of all numbers in the second set is greater than zero (<=&gt;<=0). 1. The produ...
{"inputs": ["3\n-1 2 0", "4\n-1 -2 -3 0", "5\n-1 -2 1 2 0", "100\n-64 -51 -75 -98 74 -26 -1 -8 -99 -76 -53 -80 -43 -22 -100 -62 -34 -5 -65 -81 -18 -91 -92 -16 -23 -95 -9 -19 -44 -46 -79 52 -35 4 -87 -7 -90 -20 -71 -61 -67 -50 -66 -68 -49 -27 -32 -57 -85 -59 -30 -36 -3 -77 86 -25 -94 -56 60 -24 -37 -72 -41 -31 11 -48 28...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
248
codeforces
Okay, let's tackle this problem. So, the task is to divide an array of distinct integers into three non-empty sets. The conditions are: 1. First set's product is <=0 (so, less than or equal to zero). 2. Second set's product is >0 (greater than zero). 3. Third set's product is zero. 4. Each element must be in exactly o...
To solve this problem, we need to divide an array of distinct integers into three non-empty sets such that the product of the elements in each set meets specific conditions. The third set must contain the element zero, the first set must have a product less than or equal to zero, and the second set must have a product ...
false
Code is incorrect.
1e526c78e232fa1191bd872a5767a30a
Maximum Control (easy)
The Resistance is trying to take control over all planets in a particular solar system. This solar system is shaped like a tree. More precisely, some planets are connected by bidirectional hyperspace tunnels in such a way that there is a path between every pair of the planets, but removing any tunnel would disconnect s...
{"inputs": ["5\n4 1\n4 2\n1 3\n1 5", "4\n1 2\n4 3\n1 4", "10\n4 3\n2 6\n10 1\n5 7\n5 8\n10 6\n5 9\n9 3\n2 9"], "outputs": ["3", "2", "4"]}
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
104
codeforces
Okay, I need to solve this problem where I have to count the number of remote planets in a tree structure. A remote planet is one that's only connected via a single tunnel. So, in tree terms, that's a leaf node. Because in a tree, a leaf has exactly one edge. So the problem reduces to counting the number of leaf nodes ...
To solve this problem, we need to determine the number of remote planets in a tree structure. A remote planet is defined as a planet connected to the rest via only one hyperspace tunnel, which corresponds to a leaf node in a tree. ### Approach 1. **Understanding the Tree Structure**: Each planet is a node in a tree, a...
true
1e55fccee6224084c321804a4e02e995
Forecast
The Department of economic development of IT City created a model of city development till year 2100. To prepare report about growth perspectives it is required to get growth estimates from the model. To get the growth estimates it is required to solve a quadratic equation. Since the Department of economic developmen...
{"inputs": ["1 30 200", "1 1 -1", "-1 1 1", "1000 1 -1", "-1 1000 1", "1000 1000 -999", "633 304 -186", "-181 -227 368", "-779 -814 321", "1 1 0", "1 0 -9"], "outputs": ["-10.000000000000000\n-20.000000000000000", "0.618033988749895\n-1.618033988749895", "1.618033988749895\n-0.618033988749895", "0.031126729201737\n-0.0...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
10
codeforces
Okay, let's see. I need to write a Python function that solves a quadratic equation and outputs the roots in the correct order. The input is three integers a, b, c, which are the coefficients of the equation ax² + bx + c = 0. The problem states that there are exactly two distinct real roots, so I don't have to handle c...
To solve this problem, we need to determine the roots of a quadratic equation given by the coefficients \(a\), \(b\), and \(c\). The roots must be printed such that the larger (optimistic) root is printed first, followed by the smaller (pessimistic) root. The solution must ensure that the absolute or relative error doe...
false
Code is incorrect.
1e5d848978933dde5b192f0f60219f6d
Credit Card
Recenlty Luba got a credit card and started to use it. Let's consider *n* consecutive days Luba uses the card. She starts with 0 money on her account. In the evening of *i*-th day a transaction *a**i* occurs. If *a**i*<=&gt;<=0, then *a**i* bourles are deposited to Luba's account. If *a**i*<=&lt;<=0, then *a**i* bour...
{"inputs": ["5 10\n-1 5 0 -5 3", "3 4\n-10 0 20", "5 10\n-5 0 10 -11 0", "5 13756\n-2 -9 -10 0 10", "20 23036\n-1 1 -1 -1 -1 -1 1 -1 -1 0 0 1 1 0 0 1 0 0 -1 -1", "12 82016\n1 -2 -1 -1 -2 -1 0 -2 -1 1 -2 2", "7 8555\n-2 -3 -2 3 0 -2 0", "16 76798\n-1 11 -7 -4 0 -11 -12 3 0 -7 6 -4 8 6 5 -10", "20 23079\n0 1 1 -1 1 0 -1 ...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
4
codeforces
Okay, let's see. I need to solve this problem where Luba has to manage her credit card account over n days. The problem is about tracking the balance and ensuring that certain conditions are met. Hmm. So the main points are: Each evening, a transaction happens. If ai is positive, that's a deposit. Wait no, wait. Wait,...
To solve this problem, we need to determine the minimum number of days Luba needs to deposit money into her account to ensure that her account balance never exceeds a given limit and remains non-negative on check days. Check days are days when the transaction amount is zero. ### Approach 1. **Track the Balance**: Star...
false
Code is incorrect.
1e69e3da1ef219365379e87e1145a53c
Crosses
There is a board with a grid consisting of *n* rows and *m* columns, the rows are numbered from 1 from top to bottom and the columns are numbered from 1 from left to right. In this grid we will denote the cell that lies on row number *i* and column number *j* as (*i*,<=*j*). A group of six numbers (*a*,<=*b*,<=*c*,<=*...
{"inputs": ["2 2 1", "3 4 5", "2 2 3", "5 1 3", "9 7 55", "5 10 25", "20 12 101", "21 10 155", "49 7 105", "74 99 5057", "9 10 5", "10 14 47", "6 14 23", "27 9 57", "20 17 319", "2 20 37", "10 4 33", "30 8 53", "48 76 2921", "2 78 117", "2 55 9", "56 54 2639", "72 65 2843", "32 71 297", "48 81 2573", "1 1 1", "100 100 ...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
1
codeforces
Okay, I need to solve this programming problem. Let's try to understand the problem first. So, the problem is about counting the number of distinct 6-tuples (a, b, c, d, x0, y0) that form a cross with area exactly s, and the cross is entirely placed on an n x m grid. The cross is defined such that a cell (x, y) is par...
To solve this problem, we need to count the number of distinct 6-tuples (a, b, c, d, x0, y0) that form a cross with a given area `s` on an `n` x `m` grid. The cross is defined as the union of two rectangles centered at (x0, y0), and the cross must be entirely within the grid boundaries. ### Approach 1. **Understanding...
false
Code is incorrect.
1e6b1ebdeec5065319d5165cebc63f4d
Robbers' watch
Robbers, who attacked the Gerda's cab, are very successful in covering from the kingdom police. To make the goal of catching them even harder, they use their own watches. First, as they know that kingdom police is bad at math, robbers use the positional numeral system with base 7. Second, they divide one day in *n* ho...
{"inputs": ["2 3", "8 2", "1 1", "1 2", "8 8", "50 50", "344 344", "282475250 282475250", "8 282475250", "1000000000 1000000000", "16808 7", "2402 50", "343 2401", "1582 301", "421414245 4768815", "2401 343", "2 1", "282475250 8", "8 7", "50 7", "16808 8", "2402 49", "123 123", "123 456", "1 9", "1 10", "50 67", "7 117...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
14
codeforces
Okay, let's see. So the problem is about counting the number of valid time pairs where the hour and minute, when represented in base 7 with leading zeros, have all distinct digits. Hmm. First, I need to understand how the watches are structured. The problem says that each part (hours and minutes) uses the smallest pos...
To solve this problem, we need to determine the number of valid time pairs (hours and minutes) where all digits displayed on the robbers' watches, using a base-7 numeral system, are distinct. The watches display hours and minutes with the minimum number of digits required for their respective ranges, padded with leadin...
true
1e74392cb55352ace00ff81a62ba0aa3
Calculating Function
For a positive integer *n* let's define a function *f*: *f*(*n*)<==<=<=-<=1<=+<=2<=-<=3<=+<=..<=+<=(<=-<=1)*n**n* Your task is to calculate *f*(*n*) for a given integer *n*. The single line contains the positive integer *n* (1<=≤<=*n*<=≤<=1015). Print *f*(*n*) in a single line. Sample Input 4 5 Sample Output 2 -3
{"inputs": ["4", "5", "1000000000", "1000000001", "1000000000000000", "100", "101", "102", "103", "104", "105", "106", "107", "108", "109", "208170109961052", "46017661651072", "4018154546667", "288565475053", "3052460231", "29906716", "87897701693326", "8240", "577935", "62", "1", "2", "9999999999999", "1000000000000"...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
371
codeforces
Okay, let's see. I need to find f(n) which is defined as this alternating sum: 1 - 2 + 3 - 4 ... up to n terms, but each term is multiplied by (-1) raised to (i+1) or something like that. Wait, the definition says the last term is (-1)^n * n. Hmm, maybe I need to clarify the pattern here. Wait, let's break it down. Th...
To solve this problem, we need to compute the value of a function \( f(n) \) defined as the sum of an alternating series. The series starts with 1, subtracts 2, adds 3, subtracts 4, and so on, up to \( n \) terms. The challenge is to compute this efficiently even for very large values of \( n \) (up to \( 10^{15} \)). ...
true
1ebe3a50c08a441116f53867534813de
A Serial Killer
Our beloved detective, Sherlock is currently trying to catch a serial killer who kills a person each day. Using his powers of deduction, he came to know that the killer has a strategy for selecting his next victim. The killer starts with two potential victims on his first day, selects one of these two, kills selected ...
{"inputs": ["ross rachel\n4\nross joey\nrachel phoebe\nphoebe monica\nmonica chandler", "icm codeforces\n1\ncodeforces technex", "a b\n3\na c\nb d\nd e", "ze udggmyop\n4\nze szhrbmft\nudggmyop mjorab\nszhrbmft ojdtfnzxj\nojdtfnzxj yjlkg", "q s\n10\nq b\nb j\ns g\nj f\nf m\ng c\nc a\nm d\nd z\nz o", "iii iiiiii\n7\niii ...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
264
codeforces
Okay, let's tackle this problem. Hmm. So the task is to track the killer's pairs of potential victims each day based on the initial pair and the daily replacements. The input gives the initial two names, then n days of data. For each day, a victim is killed and replaced by a new person. We need to output the pair of po...
To solve this problem, we need to track the pairs of potential victims each day based on the initial pair and the daily replacements provided. The goal is to output the pairs of potential victims at each day, starting from the initial pair and updating it each day based on the given murders and replacements. ### Appro...
true
1ebfd6c2cb572ab66eb2884fa508a34f
k-Interesting Pairs Of Integers
Vasya has the sequence consisting of *n* integers. Vasya consider the pair of integers *x* and *y* k-interesting, if their binary representation differs from each other exactly in *k* bits. For example, if *k*<==<=2, the pair of integers *x*<==<=5 and *y*<==<=3 is k-interesting, because their binary representation *x*=...
{"inputs": ["4 1\n0 3 2 1", "6 0\n200 100 100 100 200 200", "2 0\n1 1", "2 0\n0 0", "2 0\n10000 10000", "2 0\n0 10000", "2 1\n0 1", "2 1\n0 2", "3 1\n0 1 2", "3 2\n0 3 3", "3 2\n3 3 3", "10 0\n1 1 1 1 1 1 1 1 1 1", "100 14\n8192 8192 8192 8192 8191 8192 8192 8192 8192 8192 8191 8191 8191 8192 8191 8191 8191 8192 8192 8...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
3
codeforces
Okay, I need to solve this problem where I have to count the number of pairs (i, j) in a sequence such that i < j and the binary representations of a_i and a_j differ in exactly k bits. Hmm, let's think about how to approach this. First, let's understand the problem. For each j, I need to find all i < j where the Hamm...
To solve this problem, we need to count the number of pairs (i, j) in a sequence such that i < j and the binary representations of the elements at these positions differ in exactly k bits. This is equivalent to finding pairs where the Hamming distance between the elements is exactly k. ### Approach 1. **Understanding ...
true
1ec7fb216711d8f95bde17bc32969245
Clear Symmetry
Consider some square matrix *A* with side *n* consisting of zeros and ones. There are *n* rows numbered from 1 to *n* from top to bottom and *n* columns numbered from 1 to *n* from left to right in this matrix. We'll denote the element of the matrix which is located at the intersection of the *i*-row and the *j*-th col...
{"inputs": ["4", "9", "10", "12", "1", "19", "3", "2", "5", "6", "7", "8", "11", "13", "14", "15", "16", "17", "18", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31", "32", "33", "34", "35", "36", "37", "38", "39", "40", "41", "42", "43", "44", "45", "46", "47", "48", "49", "50", "51", "52", "53",...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
20
codeforces
Okay, let's see. The problem is to find the smallest n such that there's a clear symmetrical matrix of size n x n with sharpness x (which is the number of ones). And the matrix has to be both clear (no adjacent ones) and symmetrical according to horizontal and vertical reflections. Hmm. Let me try to understand the sy...
To solve this problem, we need to determine the smallest positive integer \( n \) such that there exists a clear, symmetrical matrix \( A \) of size \( n \times n \) with a given sharpness \( x \). The matrix must be clear (no two adjacent ones) and symmetrical (symmetric both horizontally and vertically). ### Approac...
true
1ed6ca77cf602d8ebffe43cfd3e5166b
Party
To celebrate the second ABBYY Cup tournament, the Smart Beaver decided to throw a party. The Beaver has a lot of acquaintances, some of them are friends with each other, and some of them dislike each other. To make party successful, the Smart Beaver wants to invite only those of his friends who are connected by friends...
{"inputs": ["9\n8\n1 2\n1 3\n2 3\n4 5\n6 7\n7 8\n8 9\n9 6\n2\n1 6\n7 9", "2\n1\n1 2\n0", "2\n0\n1\n1 2", "3\n2\n1 2\n1 3\n1\n2 3", "3\n3\n1 3\n2 1\n2 3\n0", "4\n3\n1 2\n2 3\n3 1\n3\n1 4\n4 2\n3 4", "7\n8\n1 2\n1 3\n1 4\n1 5\n2 4\n2 5\n3 4\n5 6\n3\n2 6\n5 7\n6 7", "14\n20\n1 2\n4 5\n4 6\n4 11\n5 7\n5 8\n5 13\n5 14\n7 8\...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
13
codeforces
Okay, let's tackle this problem. So the goal is to find the maximum number of people the Beaver can invite to the party under certain conditions. The conditions are a bit complex, so I need to break them down carefully. First, let's restate the problem in my own words. We need to select a subset of acquaintances such ...
To solve this problem, we need to determine the maximum number of acquaintances the Smart Beaver can invite to a party while satisfying the conditions that all friends of an invited person are also invited, no invited people dislike each other, and all invited people are connected through friendships. ### Approach 1. ...
true
1f1dcedf1144203ac39ca0e477b614f3
Pasha Maximizes
Pasha has a positive integer *a* without leading zeroes. Today he decided that the number is too small and he should make it larger. Unfortunately, the only operation Pasha can do is to swap two adjacent decimal digits of the integer. Help Pasha count the maximum number he can get if he has the time to make at most *k...
{"inputs": ["1990 1", "300 0", "1034 2", "9090000078001234 6", "1234 3", "5 100", "1234 5", "1234 6", "9022 2", "66838 4", "39940894417248510 10", "5314 4", "1026 9", "4529 8", "83811284 3", "92153348 6", "5846059 3", "521325125110071928 4", "39940894417248510 10", "77172428736634377 29", "337775999910796051 37", "1169...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
90
codeforces
Okay, I need to solve this problem where Pasha can swap adjacent digits up to k times to make the largest possible number. Let's think about how to approach this. So the input is a number a and k. The output should be the maximum possible number after at most k adjacent swaps. Let's take the sample input 1990 and k=1....
To solve this problem, we need to maximize the value of a given integer by performing up to k adjacent swaps. The goal is to rearrange the digits such that the resulting number is as large as possible, using the allowed number of swaps efficiently. ### Approach 1. **Convert the Number to a List of Digits**: This allow...
true
1f4cbe261ba5bc12af16f0c6bfe7bd72
Load Testing
Polycarp plans to conduct a load testing of its new project Fakebook. He already agreed with his friends that at certain points in time they will send requests to Fakebook. The load testing will last *n* minutes and in the *i*-th minute friends will send *a**i* requests. Polycarp plans to test Fakebook under a special...
{"inputs": ["5\n1 4 3 2 5", "5\n1 2 2 2 1", "7\n10 20 40 50 70 90 30", "1\n1", "2\n1 15", "4\n36 54 55 9", "5\n984181411 215198610 969039668 60631313 85746445", "10\n12528139 986722043 1595702 997595062 997565216 997677838 999394520 999593240 772077 998195916", "100\n9997 9615 4045 2846 7656 2941 2233 9214 837 2369 583...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
8
codeforces
Okay, I need to solve this problem where I have to find the minimum number of additional requests Polycarp needs to add so that the array becomes strictly increasing up to a peak and then strictly decreasing. The peak can be at any position, and either the increasing or decreasing part can be empty. But the entire arra...
To solve this problem, we need to determine the minimum number of additional requests Polycarp must add to ensure the load on the server is strictly increasing up to a peak and then strictly decreasing. The approach involves precomputing two arrays to efficiently calculate the required values for each possible peak pos...
true
1f4e69ed4131031462be5f829f047a10
Sonya and Exhibition
Sonya decided to organize an exhibition of flowers. Since the girl likes only roses and lilies, she decided that only these two kinds of flowers should be in this exhibition. There are $n$ flowers in a row in the exhibition. Sonya can put either a rose or a lily in the $i$-th position. Thus each of $n$ positions shoul...
{"inputs": ["5 3\n1 3\n2 4\n2 5", "6 3\n5 6\n1 4\n4 6", "10 4\n3 3\n1 6\n9 9\n10 10", "1 1\n1 1", "1000 10\n3 998\n2 1000\n1 999\n2 1000\n3 998\n2 1000\n3 998\n1 1000\n2 1000\n3 999", "1000 20\n50 109\n317 370\n710 770\n440 488\n711 757\n236 278\n314 355\n131 190\n115 162\n784 834\n16 56\n677 730\n802 844\n632 689\n23 ...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
202
codeforces
Okay, so I need to solve this problem where Sonya wants to arrange roses and lilies in a row such that the sum of the beauties of all given segments is maximized. The beauty of each segment is the product of the number of roses and lilies in that segment. Hmm, let's break this down. First, the input gives n flowers an...
To solve this problem, we need to maximize the sum of the beauty of segments visited by people at an exhibition of roses and lilies. The beauty of a segment is defined as the product of the number of roses and lilies in that segment. The solution involves determining an optimal arrangement of roses (0) and lilies (1) t...
false
Code is incorrect.
1f5631011a2485df36b8c0ae1a556024
Peculiar apple-tree
In Arcady's garden there grows a peculiar apple-tree that fruits one time per year. Its peculiarity can be explained in following way: there are *n* inflorescences, numbered from 1 to *n*. Inflorescence number 1 is situated near base of tree and any other inflorescence with number *i* (*i*<=&gt;<=1) is situated at the ...
{"inputs": ["3\n1 1", "5\n1 2 2 2", "18\n1 1 1 4 4 3 2 2 2 10 8 9 9 9 10 10 4", "2\n1", "3\n1 2", "20\n1 1 1 1 1 4 1 2 4 1 2 1 7 1 2 2 9 7 1", "20\n1 2 1 2 2 1 2 4 1 6 2 2 4 3 2 6 2 5 9", "20\n1 1 1 4 2 4 3 1 2 8 3 2 11 13 15 1 12 13 12", "20\n1 2 2 4 3 5 5 6 6 9 11 9 9 12 13 10 15 13 15", "20\n1 2 3 4 5 6 7 8 9 6 11 1...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
60
codeforces
Okay, let's try to figure out how to solve this problem. The problem is a bit tricky, but let's break it down step by step. So, the apple tree has n inflorescences. Each inflorescence except the first is connected to a parent p_i, which is lower in the tree. Each apple starts at its inflorescence and rolls down every ...
To solve this problem, we need to determine how many apples Arcady will collect from the first inflorescence of a peculiar apple tree. Each apple rolls down the tree towards the base, and if two or more apples meet at the same inflorescence, they annihilate each other. The goal is to count the number of apples that rea...
true
1fa51f9955817acd74ac1d152389d2d2
Correct Bracket Sequence Editor
Recently Polycarp started to develop a text editor that works only with correct bracket sequences (abbreviated as CBS). Note that a bracket sequence is correct if it is possible to get a correct mathematical expression by adding "+"-s and "1"-s to it. For example, sequences "(())()", "()" and "(()(()))" are correct, ...
{"inputs": ["8 4 5\n(())()()\nRDLD", "12 5 3\n((()())(()))\nRRDLD", "8 8 8\n(())()()\nLLLLLLDD", "4 2 2\n()()\nLD", "6 4 1\n()()()\nDRRD", "8 2 4\n(())()()\nRR", "10 7 3\n(()())()()\nRDLRDRD", "12 10 11\n(())()()()()\nDLRDLRDDLR", "14 8 13\n((())())((()))\nDLRLLRLR", "16 2 10\n(((())())())()()\nLD", "18 8 11\n((()))(()...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
3
codeforces
Okay, let's tackle this problem. So, the task is to simulate Polycarp's text editor that processes a correct bracket sequence (CBS) with a series of operations. The operations are moving left (L), right (R), or deleting a pair along with the brackets between them (D). After each D operation, the cursor moves to the nea...
To solve this problem, we need to simulate the behavior of a text editor that processes a correct bracket sequence (CBS) with a series of operations. The operations include moving the cursor left (L), right (R), or deleting a pair of brackets along with the brackets between them (D). The challenge is to efficiently han...
false
Code is incorrect.
1fb3786e6d9b85eeaa60c2c28a859b75
Sail
The polar bears are going fishing. They plan to sail from (*s**x*,<=*s**y*) to (*e**x*,<=*e**y*). However, the boat can only sail by wind. At each second, the wind blows in one of these directions: east, south, west or north. Assume the boat is currently at (*x*,<=*y*). - If the wind blows to the east, the boat will ...
{"inputs": ["5 0 0 1 1\nSESNW", "10 5 3 3 6\nNENSWESNEE", "19 -172106364 -468680119 -172106365 -468680119\nSSEEESSSESESWSEESSS", "39 -1000000000 -1000000000 -999999997 -1000000000\nENEENWSWSSWESNSSEESNSESWSWNSWESNENWNWEE", "41 -264908123 -86993764 -264908123 -86993723\nNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "34 -1...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
225
codeforces
Okay, let's see. The problem is about polar bears trying to sail from a starting point to an ending point using the wind directions over time. The boat can either move according to the wind direction each second or stay anchored. We need to find the earliest time they reach the destination. Hmm. So the input gives us ...
To solve this problem, we need to determine the earliest time the polar bears can reach their destination given the wind directions over a period of time. The boat can either move according to the wind direction each second or stay anchored. The goal is to find the minimum time required to reach the destination. ### A...
true
1fc7fba6d45b4304f5f03ecf43c6b69a
Yet Another Problem On a Subsequence
The sequence of integers $a_1, a_2, \dots, a_k$ is called a good array if $a_1 = k - 1$ and $a_1 &gt; 0$. For example, the sequences $[3, -1, 44, 0], [1, -99]$ are good arrays, and the sequences $[3, 7, 8], [2, 5, 4, 1], [0]$ — are not. A sequence of integers is called good if it can be divided into a positive number ...
{"inputs": ["3\n2 1 1", "4\n1 1 1 1", "1\n0", "1\n1"], "outputs": ["2", "7", "0", "0"]}
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
2
codeforces
Okay, let's see. The problem is to count the number of good subsequences of a given array. Hmm. Wait, what's a good sequence? Oh right, a good sequence can be divided into a positive number of good arrays. Each good array is a subsegment (so contiguous elements) of the sequence. And each element is in exactly one array...
To solve this problem, we need to count the number of valid subsequences of a given array that can be partitioned into one or more "good arrays". A good array is defined as a sequence where the first element is positive and equals the length of the array minus one. The solution involves dynamic programming to efficient...
true
1ffbf62bfc508f4f29980f6d780c61fa
Anton and Danik
Anton likes to play chess, and so does his friend Danik. Once they have played *n* games in a row. For each game it's known who was the winner — Anton or Danik. None of the games ended with a tie. Now Anton wonders, who won more games, he or Danik? Help him determine this. The first line of the input contains a singl...
{"inputs": ["6\nADAAAA", "7\nDDDAADA", "6\nDADADA", "10\nDDDDADDADD", "40\nAAAAAAAAADDAAAAAAAAAAADADDAAAAAAAAAAADAA", "200\nDDDDDDDADDDDDDAADADAADAAADAADADAAADDDADDDDDDADDDAADDDAADADDDDDADDDAAAADAAADDDDDAAADAADDDAAAADDADADDDAADDAADAAADAADAAAADDAADDADAAAADADDDAAAAAADDAADAADAADADDDAAADAAAADADDADAAAAAADADADDDADDDAADDADDDA...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
731
codeforces
Okay, let's see. So the problem is about determining who won more chess games between Anton and Danik. The input gives the number of games and a string of 'A's and 'D's representing each game's winner. We need to count how many times each occurs and then decide the result based on those counts. Hmm. Let's think about ...
To solve this problem, we need to determine who won more games between Anton and Danik based on the outcomes of a series of games. The solution involves counting the number of wins for each player and comparing these counts to decide the result. ### Approach 1. **Read Input**: First, we read the number of games played...
true
203a84df1d79d9a67272cb7eb7e52e97
Sale
Once Bob got to a sale of old TV sets. There were *n* TV sets at that sale. TV set with index *i* costs *a**i* bellars. Some TV sets have a negative price — their owners are ready to pay Bob if he buys their useless apparatus. Bob can «buy» any TV sets he wants. Though he's very strong, Bob can carry at most *m* TV set...
{"inputs": ["5 3\n-6 0 35 -2 4", "4 2\n7 0 0 -7", "6 6\n756 -611 251 -66 572 -818", "5 5\n976 437 937 788 518", "5 3\n-2 -2 -2 -2 -2", "5 1\n998 997 985 937 998", "2 2\n-742 -187", "3 3\n522 597 384", "4 2\n-215 -620 192 647", "10 6\n557 605 685 231 910 633 130 838 -564 -85", "20 14\n932 442 960 943 624 624 955 998 631...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
841
codeforces
Okay, let's try to figure out this problem. So, Bob wants to earn as much money as possible by taking some TV sets. The key here is that some TVs have negative prices, which means Bob gets paid when he takes them. But he can only carry up to m TVs. So, the problem is to select some TVs (up to m of them) such that the s...
To solve this problem, we need to determine the maximum sum of money Bob can earn by taking up to `m` TV sets from a sale where some TV sets have negative prices (meaning the owner pays Bob to take them). ### Approach 1. **Input Reading**: Read the number of TV sets `n` and the maximum number of TV sets `m` Bob can ca...
true
205ab1b2596b19d0ff35371ea3cf18a1
Mashmokh and Lights
Mashmokh works in a factory. At the end of each day he must turn off all of the lights. The lights on the factory are indexed from 1 to *n*. There are *n* buttons in Mashmokh's room indexed from 1 to *n* as well. If Mashmokh pushes button with index *i*, then each light with index not less than *i* that is still turn...
{"inputs": ["5 4\n4 3 1 2", "5 5\n5 4 3 2 1", "16 11\n8 5 12 10 14 2 6 3 15 9 1", "79 22\n76 32 48 28 33 44 58 59 1 51 77 13 15 64 49 72 74 21 61 12 60 57", "25 19\n3 12 21 11 19 6 5 15 4 16 20 8 9 1 22 23 25 18 13", "48 8\n42 27 40 1 18 3 19 2", "44 19\n13 20 7 10 9 14 43 17 18 39 21 42 37 1 33 8 35 4 6", "80 29\n79 5...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
214
codeforces
Okay, I need to solve this problem where Mashmokh pressed some buttons in a certain order, and for each light, I have to determine which button press turned it off. Let's think through this step by step. So the problem statement says that each time a button i is pressed, all lights with index >= i that are still on ge...
To solve this problem, we need to determine which button press turned off each light in a factory. The lights and buttons are indexed from 1 to n, and each button press affects all lights with an index greater than or equal to the button's index that are still on. The solution involves simulating the button presses and...
true
2069be9dcf332b37be07c41ab9a6cbe3
Prime Number
Simon has a prime number *x* and an array of non-negative integers *a*1,<=*a*2,<=...,<=*a**n*. Simon loves fractions very much. Today he wrote out number on a piece of paper. After Simon led all fractions to a common denominator and summed them up, he got a fraction: , where number *t* equals *x**a*1<=+<=*a*2<=+<=......
{"inputs": ["2 2\n2 2", "3 3\n1 2 3", "2 2\n29 29", "4 5\n0 0 0 0", "1 2\n1000000000", "26 2\n0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 2", "26 7\n0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 2", "3 2\n0 1 1", "1 127\n1000000000", "1 800000011\n800000011", "1 800000011\n999999999", "3 3\n1 1 1"], "outputs"...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
13
codeforces
Okay, I need to solve this programming problem. Let's read the problem statement carefully. So Simon has a prime number x and an array of non-negative integers a_1 to a_n, sorted in non-decreasing order. The task is to compute the GCD of two numbers s and t, where t is x raised to the sum of all a_i. Then, s is the su...
To solve this problem, we need to determine the greatest common divisor (GCD) of two numbers, s and t, where t is a power of a prime number x, and s is derived from a sum of fractions. The result should be given modulo 1000000007. ### Approach 1. **Understanding the Problem**: Simon has a prime number x and an array o...
false
Code is incorrect.
207eede200d9ba24f994330c2b8cfabe
Pearls in a Row
There are *n* pearls in a row. Let's enumerate them with integers from 1 to *n* from the left to the right. The pearl number *i* has the type *a**i*. Let's call a sequence of consecutive pearls a segment. Let's call a segment good if it contains two pearls of the same type. Split the row of the pearls to the maximal ...
{"inputs": ["5\n1 2 3 4 1", "5\n1 2 3 4 5", "7\n1 2 1 3 1 2 1", "9\n1 2 1 2 1 2 1 2 1", "11\n1 1 2 1 2 1 2 1 2 1 1", "1\n576560149", "10\n460626451 460626451 460626451 460626451 460626451 460626451 460626451 460626451 460626451 460626451", "10\n933677171 80672280 80672280 933677171 933677171 933677171 933677171 8067228...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
39
codeforces
Okay, I need to solve this programming problem. Let's read the problem carefully. So, the problem is about partitioning a row of pearls into the maximum number of good segments. A good segment is a consecutive sequence that contains at least two pearls of the same type. Each pearl must be in exactly one segment. If it...
To solve this problem, we need to partition a row of pearls into the maximum number of good segments. A good segment is defined as a consecutive sequence of pearls that contains at least two pearls of the same type. Each pearl must appear in exactly one segment. If it's impossible to partition the row into good segment...
false
Code is incorrect.
208e0d102a4aff006ad18836092a1fd9
Jeff and Digits
Jeff's got *n* cards, each card contains either digit 0, or digit 5. Jeff can choose several cards and put them in a line so that he gets some number. What is the largest possible number divisible by 90 Jeff can make from the cards he's got? Jeff must make the number without leading zero. At that, we assume that numbe...
{"inputs": ["4\n5 0 5 0", "11\n5 5 5 5 5 5 5 5 0 5 5", "7\n5 5 5 5 5 5 5", "1\n5", "1\n0", "11\n5 0 5 5 5 0 0 5 5 5 5", "23\n5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 0 0 0 0 0", "9\n5 5 5 5 5 5 5 5 5", "24\n5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 0 0 0 0 0", "10\n0 0 0 0 0 0 0 0 0 0", "10\n5 5 5 5 5 0 0 5 0 5", "3\n5 5 0", "5...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
159
codeforces
Okay, let's tackle this problem step by step. So, the problem is that Jeff has some cards with either 0 or 5, and he needs to make the largest possible number divisible by 90. If it's not possible, return -1. Hmm. First, I remember that a number divisible by 90 must be divisible by both 9 and 10. So for divisibility b...
To solve this problem, we need to determine the largest possible number divisible by 90 that Jeff can create using cards with digits 5 and 0. The solution involves understanding the divisibility rules for 9 and 10 and applying them to maximize the number's length. ### Approach 1. **Divisibility Rules**: - A number ...
true
2098cd490c69f659d881f9271b7531fc
String Game
Little Nastya has a hobby, she likes to remove some letters from word, to obtain another word. But it turns out to be pretty hard for her, because she is too young. Therefore, her brother Sergey always helps her. Sergey gives Nastya the word *t* and wants to get the word *p* out of it. Nastya removes letters in a cert...
{"inputs": ["ababcba\nabb\n5 3 4 1 7 6 2", "bbbabb\nbb\n1 6 3 4 2 5", "cacaccccccacccc\ncacc\n10 9 14 5 1 7 15 3 6 12 4 8 11 13 2", "aaaabaaabaabaaaaaaaa\naaaa\n18 5 4 6 13 9 1 3 7 8 16 10 12 19 17 15 14 11 20 2", "aaaaaaaadbaaabbbbbddaaabdadbbbbbdbbabbbabaabdbbdababbbddddbdaabbddbbbbabbbbbabadaadabaaaadbbabbbaddb\naaa...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
82
codeforces
Okay, I need to solve this programming problem. Let's read the problem statement carefully. So, the problem is about Nastya removing letters from a word t according to a permutation of indices, and Sergey wants to stop her as late as possible so that the remaining letters can form the word p. Our task is to find the m...
To solve this problem, we need to determine the maximum number of letters Nastya can remove from the word `t` such that the remaining string still contains the word `p` as a subsequence. The order of removal is given by a permutation of indices of `t`. ### Approach 1. **Binary Search**: We use binary search to efficie...
true
20bba2c3e5ff8b9338dc245960535aab
Vanya and Triangles
Vanya got bored and he painted *n* distinct points on the plane. After that he connected all the points pairwise and saw that as a result many triangles were formed with vertices in the painted points. He asks you to count the number of the formed triangles with the non-zero area. The first line contains integer *n* (1...
{"inputs": ["4\n0 0\n1 1\n2 0\n2 2", "3\n0 0\n1 1\n2 0", "1\n1 1", "5\n0 0\n1 1\n2 2\n3 3\n4 4", "5\n0 0\n1 1\n2 3\n3 6\n4 10", "4\n-100 -100\n-100 100\n100 -100\n100 100", "5\n-100 -100\n-100 100\n100 -100\n100 100\n0 0", "4\n1 -100\n2 -100\n100 -99\n99 -99", "25\n26 -54\n16 56\n-42 -51\n92 -58\n100 52\n57 -98\n-84 -2...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
11
codeforces
Okay, I need to solve this problem where I have to count the number of triangles with non-zero area formed by given points. Hmm. Let's think about how to approach this. First, the problem is asking for the number of distinct triangles that have area. So, a triangle has non-zero area if the three points are not colinea...
To solve this problem, we need to count the number of triangles with non-zero area formed by given points on a plane. A triangle has a non-zero area if its three vertices are not collinear. The solution involves efficiently determining the number of collinear triplets of points and subtracting them from the total possi...
true
20bfb8b140bbbbc6164f4c0a84a2dc05
Sonya and Problem Wihtout a Legend
Sonya was unable to think of a story for this problem, so here comes the formal description. You are given the array containing *n* positive integers. At one turn you can pick any element and increase or decrease it by 1. The goal is the make the array strictly increasing by making the minimum possible number of opera...
{"inputs": ["7\n2 1 5 11 5 9 11", "5\n5 4 3 2 1", "2\n1 1000", "2\n1000 1", "5\n100 80 60 70 90", "10\n10 16 17 11 1213 1216 1216 1209 3061 3062", "20\n103 103 110 105 107 119 113 121 116 132 128 124 128 125 138 137 140 136 154 158", "1\n1", "5\n1 1 1 2 3", "1\n1000", "50\n499 780 837 984 481 526 944 482 862 136 265 60...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
14
codeforces
Okay, I need to solve this problem where I have to find the minimum number of operations to make an array strictly increasing by incrementing or decrementing elements. The operations allowed are changing any element by 1 each time, and the goal is to minimize the total steps. Let's think about how to approach this. Hm...
To solve this problem, we need to transform an array into a strictly increasing sequence with the minimum number of operations, where each operation consists of incrementing or decrementing an element by 1. The solution involves using a greedy approach with a max-heap to efficiently track and merge segments of the arra...
true
20c1e9422796af441c387c631d2715ab
Code Parsing
Little Vitaly loves different algorithms. Today he has invented a new algorithm just for you. Vitaly's algorithm works with string *s*, consisting of characters "x" and "y", and uses two following operations at runtime: 1. Find two consecutive characters in the string, such that the first of them equals "y", and the ...
{"inputs": ["x", "yxyxy", "xxxxxy", "yxyyxyyx", "yxxyxyx", "xxx", "xxyxx", "xxxyx", "yxxxx", "xyyxyyyyyxxxxxxxyxyxyyxyyxyyxxyxyxyxxxyxxy", "xyyxyyyyyxxxxxxxyxyxyyxyyxyyxxyxyxyxxxyxxy", "xxxxxxxxxxxyxyyxxxxyxxxxxyxxxxxyxxxxxxxxyx", "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", "yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
54
codeforces
Okay, let's tackle this problem. So, the task is to simulate Vitaly's algorithm on a given string composed of 'x's and 'y's. The algorithm has two operations, and it keeps applying them until neither can be applied. The challenge is to find out what the final string looks like after all possible operations are done. H...
To solve this problem, we need to simulate Vitaly's algorithm on a given string composed of 'x' and 'y' characters. The algorithm repeatedly applies two operations until neither can be applied, and we need to determine the final string after all operations are executed. ### Approach The key insight is that the operati...
true
20c573c0f46f02b35925d1e59ce6fc1e
Voting
There are *n* employees in Alternative Cake Manufacturing (ACM). They are now voting on some very important question and the leading world media are trying to predict the outcome of the vote. Each of the employees belongs to one of two fractions: depublicans or remocrats, and these two fractions have opposite opinions...
{"inputs": ["5\nDDRRR", "6\nDDRRRR", "1\nD", "1\nR", "2\nDR", "3\nRDD", "3\nDRD", "4\nDRRD", "4\nDRRR", "4\nRDRD", "5\nDRDRR", "4\nRRRR", "5\nRDDRD", "5\nDDRRD", "5\nDRRRD", "5\nDDDDD", "6\nDRRDDR", "7\nRDRDRDD", "7\nRDRDDRD", "7\nRRRDDDD", "8\nRRRDDDDD", "9\nRRRDDDDDR", "9\nRRDDDRRDD", "9\nRRDDDRDRD", "10\nDDRRRDRRDD"...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
11
codeforces
Okay, let's see. The problem is about simulating a voting process where employees from two factions (D and R) take turns making statements. The goal is to determine which faction will win based on their optimal strategies. Hmm. So, the rules are a bit complex. Each employee, when it's their turn, can choose to elimina...
To solve this problem, we need to simulate the voting process of employees from two factions, depublicans (D) and remocrats (R), who take turns eliminating each other until only one employee remains. The key is to determine which faction will win based on optimal strategies where each employee eliminates the next oppos...
false
Code is incorrect.
20ca84dc7382a495acdf33245bff71ca
Bear and Fair Set
Limak is a grizzly bear. He is big and dreadful. You were chilling in the forest when you suddenly met him. It's very unfortunate for you. He will eat all your cookies unless you can demonstrate your mathematical skills. To test you, Limak is going to give you a puzzle to solve. It's a well-known fact that Limak, as e...
{"inputs": ["10 20 1\n10 10", "10 20 3\n15 10\n5 0\n10 5", "10 20 2\n15 3\n20 10", "15 27 2\n6 4\n23 5", "50 7654 4\n1273 11\n6327 38\n1244 3\n5208 22", "50 7654 4\n2899 15\n3848 26\n2718 12\n5511 36", "50 7654 4\n4881 20\n4957 6\n4764 50\n944 44", "50 6457 1\n945 41", "500 5000 5\n1289 221\n694 178\n2179 454\n160 11\n...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
3
codeforces
Okay, let's tackle this problem. So the task is to determine whether there exists a set of numbers that satisfies all the given conditions and hints. If such a set exists, we output 'fair'; otherwise, 'unfair'. First, let's understand the problem requirements. The set has n elements, all distinct positive integers be...
To solve this problem, we need to determine if there exists a valid set of numbers that meets the given conditions and hints. The set must have exactly `n` distinct positive integers between 1 and `b`, with each element giving a distinct remainder when divided by 5. Additionally, the set must satisfy all the provided h...
false
Code is incorrect.
20e1b109cf2c373246172c975ecfd79e
Polo the Penguin and Matrix
Little penguin Polo has an *n*<=×<=*m* matrix, consisting of integers. Let's index the matrix rows from 1 to *n* from top to bottom and let's index the columns from 1 to *m* from left to right. Let's represent the matrix element on the intersection of row *i* and column *j* as *a**ij*. In one move the penguin can add ...
{"inputs": ["2 2 2\n2 4\n6 8", "1 2 7\n6 7", "3 2 1\n5 7\n1 2\n5 100", "3 3 3\n5 8 5\n11 11 17\n14 5 2", "3 3 3\n5 8 5\n11 11 17\n14 5 3", "2 2 4\n5 5\n5 5", "7 4 5\n7 7 7 12\n7 12 12 7\n7 7 7 7\n7 7 12 7\n7 7 12 12\n12 12 7 12\n7 7 7 7", "7 7 47\n91 91 91 91 91 91 91\n91 91 91 91 91 91 91\n91 91 91 91 91 91 91\n91 91 ...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
200
codeforces
Okay, let's see. The problem is about making all elements in a matrix equal by adding or subtracting d each move. We need to find the minimum number of moves or return -1 if it's impossible. Hmm, first, I need to think about the conditions when it's possible. For all elements to be made equal, they must have the same ...
To solve this problem, we need to determine the minimum number of moves required to make all elements of a matrix equal by adding or subtracting a given value `d` each move. If it is impossible to achieve this, we should return `-1`. ### Approach 1. **Check Feasibility**: First, check if all elements in the matrix hav...
true
20f1c94c1e992cb8f01b83ea4ed216fb
none
Bob recently read about bitwise operations used in computers: AND, OR and XOR. He have studied their properties and invented a new game. Initially, Bob chooses integer *m*, bit depth of the game, which means that all numbers in the game will consist of *m* bits. Then he asks Peter to choose some *m*-bit number. After ...
{"inputs": ["3 3\na := 101\nb := 011\nc := ? XOR b", "5 1\na := 1\nbb := 0\ncx := ? OR a\nd := ? XOR ?\ne := d AND bb", "2 10\nb := 0100101101\na := ? XOR b", "1 10\na := 0110110011", "1 6\na := ? OR ?", "13 6\na := 111010\nb := 100100\nc := 001110\nd := b AND b\ne := c AND ?\nf := e OR c\ng := 011110\nh := d XOR ?\ni ...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
6
codeforces
Okay, let's see. The problem is about finding the minimal and maximal possible sum of variables based on Peter's chosen number. Each variable is either a constant or a combination of previous variables or the chosen number using bitwise operations. We need to determine the optimal bits for Peter's number in each positi...
To solve this problem, we need to determine the optimal binary number Peter should choose to minimize and maximize the sum of all variables computed by Bob's bitwise operations. The solution involves analyzing each bit position independently to decide the best choice for Peter's number. ### Approach 1. **Problem Analy...
true
20fd49f9c64735d6bfb5a2ded627b23d
Shifts
You are given a table consisting of *n* rows and *m* columns. Each cell of the table contains a number, 0 or 1. In one move we can choose some row of the table and cyclically shift its values either one cell to the left, or one cell to the right. To cyclically shift a table row one cell to the right means to move the ...
{"inputs": ["3 6\n101010\n000100\n100000", "2 3\n111\n000", "1 1\n1", "1 1\n0", "3 1\n1\n1\n0", "6 2\n10\n11\n01\n01\n10\n11", "3 3\n001\n010\n100", "4 4\n0001\n0100\n0010\n1000", "5 5\n10000\n01000\n00100\n00010\n00001", "5 5\n10001\n00100\n01000\n01001\n11111", "5 5\n11111\n11111\n11111\n11111\n00000", "5 10\n0001000...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
9
codeforces
Okay, I need to solve this programming problem. Let's read the problem statement carefully. The problem is about finding the minimum number of moves required to make some column in a table consist entirely of 1s. Each move involves cyclically shifting a row either left or right. The challenge is to compute the minimal...
To solve this problem, we need to determine the minimum number of moves required to make a column in a table consist entirely of 1s by cyclically shifting rows either left or right. ### Approach 1. **Input Reading and Initial Checks**: Read the input values and check if any row lacks a '1'. If any row has no '1's, it...
true
20fee0d2046c45179bcd2f922d225aae
Queue
There are *n* walruses standing in a queue in an airport. They are numbered starting from the queue's tail: the 1-st walrus stands at the end of the queue and the *n*-th walrus stands at the beginning of the queue. The *i*-th walrus has the age equal to *a**i*. The *i*-th walrus becomes displeased if there's a younger...
{"inputs": ["6\n10 8 5 3 50 45", "7\n10 4 6 3 2 8 15", "5\n10 3 1 10 11", "13\n18 9 8 9 23 20 18 18 33 25 31 37 36", "10\n15 21 17 22 27 21 31 26 32 30", "10\n18 20 18 17 17 13 22 20 34 29", "13\n16 14 12 9 11 28 30 21 35 30 32 31 43", "15\n18 6 18 21 14 20 13 9 18 20 28 13 19 25 21", "11\n15 17 18 18 26 22 23 33 33 21...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
51
codeforces
Okay, let's see. I need to solve this programming problem. Let's read the problem carefully. The problem is about walruses standing in a queue. Each walrus has an age. For each walrus i (from 1 to n, where 1 is the end of the queue and n is the front), we need to find the farthest walrus j that is in front of i (so j ...
To solve this problem, we need to determine the displeasure of each walrus in a queue based on the ages of the walruses standing in front of them. The displeasure of a walrus is defined as the number of walruses between him and the furthest younger walrus ahead of him. If there is no younger walrus ahead, the displeasu...
true
20ffe02488c708a6ac25d6687efe45a2
Snacktower
According to an old legeng, a long time ago Ankh-Morpork residents did something wrong to miss Fortune, and she cursed them. She said that at some time *n* snacks of distinct sizes will fall on the city, and the residents should build a Snacktower of them by placing snacks one on another. Of course, big snacks should b...
{"inputs": ["3\n3 1 2", "5\n4 5 1 2 3", "1\n1", "2\n1 2", "10\n5 1 6 2 8 3 4 10 9 7", "30\n16 10 4 29 5 28 12 21 11 30 18 6 14 3 17 22 20 15 9 1 27 19 24 26 13 25 2 23 8 7", "100\n98 52 63 2 18 96 31 58 84 40 41 45 66 100 46 71 26 48 81 20 73 91 68 76 13 93 17 29 64 95 79 21 55 75 19 85 54 51 89 78 15 87 43 59 36 1 90 ...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
283
codeforces
Okay, let's see. The problem is about building a snack tower where each day a snack falls, and the residents can only place it on the tower if all larger snacks have already been placed. So, the tower is built in a way that each new snack is placed on top immediately when possible. We need to model this process and out...
To solve this problem, we need to model the behavior of Ankh-Morpork residents building a Snacktower where each snack must be placed immediately when all larger snacks have fallen. The goal is to determine which snacks can be placed each day. ### Approach 1. **Track Received Snacks**: Use a set to keep track of snacks...
false
Code is incorrect.
2107d7677a31fc3b2e3f2f48f90ea65d
Coach
A programming coach has *n* students to teach. We know that *n* is divisible by 3. Let's assume that all students are numbered from 1 to *n*, inclusive. Before the university programming championship the coach wants to split all students into groups of three. For some pairs of students we know that they want to be on ...
{"inputs": ["3 0", "6 4\n1 2\n2 3\n3 4\n5 6", "3 3\n1 2\n2 3\n1 3", "6 3\n1 2\n3 4\n5 6", "15 9\n1 4\n1 6\n2 7\n2 11\n4 6\n5 12\n7 11\n9 14\n13 15", "3 1\n1 3", "15 13\n1 9\n1 11\n2 7\n2 12\n3 8\n3 15\n4 10\n5 6\n5 14\n6 14\n7 12\n8 15\n9 11", "36 27\n1 34\n2 18\n2 20\n3 9\n3 21\n4 5\n4 25\n5 25\n6 13\n6 22\n8 23\n8 31...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
17
codeforces
Okay, so I have this programming problem to solve. Let me read through the problem statement again to make sure I understand it correctly. The task is to split n students into groups of three such that all pairs of students who want to be together are in the same group. Also, each student must be in exactly one group....
To solve this problem, we need to split students into groups of three such that all pairs of students who want to be together are in the same group. If it's impossible to form such groups, we should output -1. Otherwise, we need to print the valid groups. ### Approach 1. **Graph Representation**: Represent the student...
false
Code is incorrect.
210b0dcb71762d4b15aa74549a099ce5
Compote
Nikolay has *a* lemons, *b* apples and *c* pears. He decided to cook a compote. According to the recipe the fruits should be in the ratio 1:<=2:<=4. It means that for each lemon in the compote should be exactly 2 apples and exactly 4 pears. You can't crumble up, break up or cut these fruits into pieces. These fruits — ...
{"inputs": ["2\n5\n7", "4\n7\n13", "2\n3\n2", "1\n1\n1", "1\n2\n4", "1000\n1000\n1000", "1\n1\n4", "1\n2\n3", "1\n1000\n1000", "1000\n1\n1000", "1000\n2\n1000", "1000\n500\n1000", "1000\n1000\n4", "1000\n1000\n3", "4\n8\n12", "10\n20\n40", "100\n200\n399", "200\n400\n800", "199\n400\n800", "201\n400\n800", "200\n399\n8...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
334
codeforces
Okay, let's see. The problem is about finding the maximum number of fruits Nikolay can use to make compote, following a specific ratio. The ratio is 1 lemon to exactly 2 apples and exactly 4 pears. So for each lemon used, he needs 2 apples and 4 pears. And all fruits have to be used whole; no cutting or splitting. Hmm...
To solve this problem, we need to determine the maximum number of fruits Nikolay can use to make compote following the exact ratio of 1 lemon, 2 apples, and 4 pears. The solution involves calculating the maximum possible number of such fruit sets and then summing their total. ### Approach 1. **Understand the Ratio**: ...
true
21597ff5cde4d9dc159f25a26dd6a0ce
Directed Roads
ZS the Coder and Chris the Baboon has explored Udayland for quite some time. They realize that it consists of *n* towns numbered from 1 to *n*. There are *n* directed roads in the Udayland. *i*-th of them goes from town *i* to some other town *a**i* (*a**i*<=≠<=*i*). ZS the Coder can flip the direction of any road in...
{"inputs": ["3\n2 3 1", "4\n2 1 1 1", "5\n2 4 2 5 3", "4\n2 1 4 3", "7\n2 3 4 1 6 5 4", "20\n2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 1", "2\n2 1", "84\n2 50 67 79 71 45 43 40 57 20 25 8 60 47 52 10 37 23 1 28 22 26 3 42 11 63 61 68 49 32 55 18 5 24 31 70 66 27 38 41 54 12 65 51 15 34 30 35 77 74 21 62 33 16 81...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
8
codeforces
Okay, let's try to solve this problem. Hmm, the problem is about flipping roads to avoid cycles. So, the initial roads form a directed graph where each town has exactly one outgoing edge. But since each road can be flipped (or not), we need to count the number of subsets of roads to flip such that the resulting graph d...
To solve this problem, we need to determine the number of ways to flip some subset of roads in Udayland such that the resulting graph does not contain any directed cycles. The solution involves analyzing the structure of the graph, identifying cycles, and calculating valid configurations to break these cycles. ### App...
true
216626f8e3129d6463eb791d51eaa0ad
Permutation Cycle
For a permutation *P*[1... *N*] of integers from 1 to *N*, function *f* is defined as follows: Let *g*(*i*) be the minimum positive integer *j* such that *f*(*i*,<=*j*)<==<=*i*. We can show such *j* always exists. For given *N*,<=*A*,<=*B*, find a permutation *P* of integers from 1 to *N* such that for 1<=≤<=*i*<=≤<=...
{"inputs": ["9 2 5", "3 2 1", "7 4 4", "1000000 999998 3", "1 1 1", "993012 997 1001", "1000000 2017 881", "390612 20831 55790", "689292 69319 96267", "99929 99929 2", "807990 72713 11616", "514004 50866 26101", "631610 7702 63553", "391861 47354 60383", "822954 53638 55936", "794948 794948 85946", "786009 37429 59524"...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
21
codeforces
Okay, let's see. I need to find a permutation P of numbers from 1 to N such that for each i, g(i) is either A or B. Hmm. What's g(i) again? Oh right, g(i) is the smallest j such that the minimum of the first j elements of the permutation (including the j-th) is equal to i. Wait, no, wait. Wait the function f(i, j) is t...
To solve this problem, we need to construct a permutation of integers from 1 to N such that for each integer i, the minimum position j where the minimum of the first j elements equals i is either A or B. If no such permutation exists, we should return -1. ### Approach 1. **Key Insight**: The position of the integer 1 ...
false
Code is incorrect.
21675d66e7006d324b0336d4ffb917d7
Almost Permutation
Recently Ivan noticed an array *a* while debugging his code. Now Ivan can't remember this array, but the bug he was trying to fix didn't go away, so Ivan thinks that the data from this array might help him to reproduce the bug. Ivan clearly remembers that there were *n* elements in the array, and each element was not ...
{"inputs": ["3 0", "3 1\n1 1 3 2", "3 2\n1 1 3 2\n2 1 3 2", "3 2\n1 1 3 2\n2 1 3 1", "50 0", "50 1\n2 31 38 25", "50 2\n2 38 41 49\n1 19 25 24", "50 10\n2 4 24 29\n1 14 49 9\n2 21 29 12\n2 2 46 11\n2 4 11 38\n2 3 36 8\n1 24 47 28\n2 23 40 32\n1 16 50 38\n1 31 49 38", "50 20\n1 14 22 40\n1 23 41 3\n1 32 39 26\n1 8 47 25...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
4
codeforces
Okay, I need to solve this programming problem. Let's read the problem statement carefully. So, the task is to find an array of size n that satisfies q constraints given by Ivan's remembered facts. Then, among all such possible arrays, find the one with the minimal cost, where the cost is the sum of (cnt[i] - 1)^2 for...
To solve this problem, we need to determine the minimum possible cost of an array that satisfies given constraints. The cost is defined as the sum of the squares of the counts of each element in the array. The array elements must be within the range [1, n] and satisfy the constraints provided. ### Approach 1. **Constr...
true
216b7c32d3e33f332f60bc12ab2da822
Logo Turtle
A lot of people associate Logo programming language with turtle graphics. In this case the turtle moves along the straight line and accepts commands "T" ("turn around") and "F" ("move 1 unit forward"). You are given a list of commands that will be given to the turtle. You have to change exactly *n* commands from the l...
{"inputs": ["FT\n1", "FFFTFFF\n2", "F\n1", "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF\n50", "FTFTFTFFFFTFTFTTTTTTFFTTTTFFTFFFTFTFTFFTFTFTFFFTTTFTTFTTTTTFFFFTTT\n12", "TTFFTFTTFTTTFFFTFTFFTFFTTFFTFTFTFTFFTTTFTFFTFFTTTTFTTTFFT\n46", "TTFFFFFFFTTTTFTTFTFFTTFFFTFTT...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
7
codeforces
Okay, let's see. I need to solve this problem where a turtle moves based on commands, and we can change exactly n commands to maximize the distance from the starting point. Hmm. The problem says we must change exactly n commands. So each of those changes can be either flipping a T to F or F to T. And we have to do exac...
To solve this problem, we need to determine the maximum distance a turtle can move from its starting point after executing a sequence of commands, where exactly `n` commands are changed. The turtle can either move forward ("F") or turn around ("T"), and changing a command toggles it between "F" and "T". ### Approach 1...
true
217e38012c7854256183c07a6bdc62c5
Petya's Exams
Petya studies at university. The current academic year finishes with $n$ special days. Petya needs to pass $m$ exams in those special days. The special days in this problem are numbered from $1$ to $n$. There are three values about each exam: - $s_i$ — the day, when questions for the $i$-th exam will be published, -...
{"inputs": ["5 2\n1 3 1\n1 5 1", "3 2\n1 3 1\n1 2 1", "10 3\n4 7 2\n1 10 3\n8 9 1", "2 1\n1 2 1", "3 1\n1 2 2", "3 1\n1 3 2", "100 1\n1 100 99", "100 1\n1 100 100", "100 1\n1 100 98", "100 2\n1 100 49\n1 99 49", "10 2\n3 7 4\n6 10 1", "10 4\n2 5 1\n1 4 2\n4 7 1\n7 10 2", "20 5\n6 16 3\n4 14 4\n3 13 1\n1 11 1\n10 20 4",...
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 scheduling Petya's exams and preparation days. The goal is to find a valid schedule where he prepares for each exam exactly the required number of days between s_i and d_i-1, and takes each exam on their...
To solve this problem, we need to schedule Petya's exam preparation days such that he can prepare for all exams and take them on their respective days. If it's impossible to meet the requirements, we should return -1. Otherwise, we need to provide a valid schedule. ### Approach 1. **Check Feasibility**: For each exam,...
true
2189a2c8e311addc29b933b2d542edfc
Circle of Numbers
*n* evenly spaced points have been marked around the edge of a circle. There is a number written at each point. You choose a positive real number *k*. Then you may repeatedly select a set of 2 or more points which are evenly spaced, and either increase all numbers at points in the set by *k* or decrease all numbers at ...
{"inputs": ["30\n000100000100000110000000001100", "6\n314159", "3\n000", "15\n522085220852208", "300\n51849955123882532841766314023795544655059625429948511546532555041357758442089311502553567597180892645169105593021958599780734407001184543473352601711893354858975964992001656857820176956422821004573923066450696828141422...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
1
codeforces
Okay, let's try to figure out this problem. Hmm. So the problem is about determining whether we can perform a series of operations to make all numbers on a circle zero. The operations involve selecting evenly spaced points and adding or subtracting a fixed k. The key is to find if there's some k such that this is possi...
To solve this problem, we need to determine if it is possible to make all numbers on a circle zero by repeatedly selecting sets of evenly spaced points and adjusting their values by a positive real number \( k \). The key insight is to check if the sums of numbers in specific groups of points (formed by divisors of the...
false
Code is incorrect.
218df72e4efbe2b7cc341ffe3d16707e
Rebranding
The name of one small but proud corporation consists of *n* lowercase English letters. The Corporation has decided to try rebranding — an active marketing strategy, that includes a set of measures to change either the brand (both for the company and the goods it produces) or its components: the name, the logo, the slog...
{"inputs": ["6 1\npolice\np m", "11 6\nabacabadaba\na b\nb c\na d\ne g\nf a\nb b", "1 1\nf\nz h", "1 1\na\na b", "10 10\nlellelleel\ne l\ne l\ne l\ne l\ne l\ne e\nl l\nl e\nl l\ne e"], "outputs": ["molice", "cdcbcdcfcdc", "f", "b", "lellelleel"]}
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
119
codeforces
Okay, I need to solve this programming problem. Let's read the problem statement carefully. The problem says that the corporation's name is modified by m designers consecutively. Each designer swaps all occurrences of x_i and y_i in the current name. So, after each swap, any x_i becomes y_i and vice versa. But this ha...
To solve this problem, we need to determine the final version of a corporation's name after applying a series of character swaps designed by multiple designers. Each designer swaps two specific characters in the current version of the name, and we need to efficiently compute the result after all swaps have been applied...
true
219366dfd3d5a68d977c0efa6cb0721a
DZY Loves Sequences
DZY has a sequence *a*, consisting of *n* integers. We'll call a sequence *a**i*,<=*a**i*<=+<=1,<=...,<=*a**j* (1<=≤<=*i*<=≤<=*j*<=≤<=*n*) a subsegment of the sequence *a*. The value (*j*<=-<=*i*<=+<=1) denotes the length of the subsegment. Your task is to find the longest subsegment of *a*, such that it is possible ...
{"inputs": ["6\n7 2 3 1 5 6", "10\n424238336 649760493 681692778 714636916 719885387 804289384 846930887 957747794 596516650 189641422", "50\n804289384 846930887 681692778 714636916 957747794 424238336 719885387 649760493 596516650 189641422 25202363 350490028 783368691 102520060 44897764 967513927 365180541 540383427 ...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
59
codeforces
Okay, so I need to solve this programming problem where I have to find the longest subsegment of a sequence where changing at most one element makes it strictly increasing. Hmm. Let's think about how to approach this. First, the problem states that we can change one element in the subsegment to any value, and after th...
To solve this problem, we need to find the longest subsegment of an array where changing at most one element makes it strictly increasing. The solution involves analyzing the array to identify potential segments that can be merged by modifying one element, thereby forming a longer strictly increasing sequence. ### App...
false
Code is incorrect.
21981a6dd776117fe98a2f0d77c136c9
Average Sleep Time
It's been almost a week since Polycarp couldn't get rid of insomnia. And as you may already know, one week in Berland lasts *k* days! When Polycarp went to a doctor with his problem, the doctor asked him about his sleeping schedule (more specifically, the average amount of hours of sleep per week). Luckily, Polycarp k...
{"inputs": ["3 2\n3 4 7", "1 1\n10", "8 2\n1 2 4 100000 123 456 789 1", "1 1\n1", "1 1\n100000", "3 1\n1 2 3", "10 4\n11 3 5 20 12 7 9 2 2 20", "10 5\n15 9 3 2 17 10 9 18 4 19", "10 6\n19 3 20 16 14 10 1 13 7 3", "10 7\n8 16 2 13 15 9 5 13 9 2", "10 4\n127 1459 718 1183 880 1044 1857 1340 725 1496", "10 5\n1384 1129 17...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
97
codeforces
Okay, let's see. The problem is to calculate the average of all possible consecutive k-day weeks in the given list of n days. Hmm. So for each possible week (which is a sliding window of k days), we need to compute the sum of those k days and then take the average over all those sums. Wait right. For example, in the f...
To solve this problem, we need to calculate the average sleep time over all possible consecutive k-day weeks from the given n days of sleep records. The solution efficiently computes this using a sliding window technique to maintain the sum of each consecutive k-day window, ensuring optimal performance even for large i...
true
21b7de902f49277b20a3051ca8ba9528
Rook, Bishop and King
Little Petya is learning to play chess. He has already learned how to move a king, a rook and a bishop. Let us remind you the rules of moving chess pieces. A chessboard is 64 square fields organized into an 8<=×<=8 table. A field is represented by a pair of integers (*r*,<=*c*) — the number of the row and the number of...
{"inputs": ["4 3 1 6", "5 5 5 6", "1 1 8 8", "1 1 8 1", "1 1 1 8", "8 1 1 1", "8 1 1 8", "7 7 6 6", "8 1 8 8", "1 8 1 1", "1 8 8 1", "1 8 8 8", "8 8 1 1", "8 8 1 8", "8 8 8 1", "1 3 1 6", "1 3 1 4", "1 3 1 5", "3 3 2 4", "3 3 1 5", "1 6 2 1", "1 5 6 4", "1 3 3 7", "1 1 8 1", "1 7 5 4", "1 5 2 7", "1 4 6 2", "1 2 3 5", ...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
217
codeforces
Okay, I need to solve this problem where I have to calculate the minimum number of moves for a rook, bishop, and king to move from one position to another on a chessboard. Let's think about each piece's movement and how to compute their moves. First, let's break down each piece's movement: Rook: Moves horizontally or...
To solve this problem, we need to determine the minimum number of moves required for a rook, a bishop, and a king to move from a starting position to a target position on a chessboard. Each piece has unique movement rules, and we need to account for these rules to compute the minimum moves accurately. ### Approach 1. ...
true
21c7afb1480e78ad47c23361b6dbbc61
Valera and Plates
Valera is a lazy student. He has *m* clean bowls and *k* clean plates. Valera has made an eating plan for the next *n* days. As Valera is lazy, he will eat exactly one dish per day. At that, in order to eat a dish, he needs exactly one clean plate or bowl. We know that Valera can cook only two types of dishes. He can...
{"inputs": ["3 1 1\n1 2 1", "4 3 1\n1 1 1 1", "3 1 2\n2 2 2", "8 2 2\n1 2 1 2 1 2 1 2", "2 100 100\n2 2", "1 1 1\n2", "233 100 1\n2 2 1 1 1 2 2 2 2 1 1 2 2 2 1 2 2 1 1 1 2 2 1 1 1 1 2 1 2 2 1 1 2 2 1 2 2 1 2 1 2 1 2 2 2 1 1 1 1 2 1 2 1 1 2 1 1 2 2 1 2 1 2 1 1 1 1 1 1 1 1 1 2 1 2 2 2 1 1 2 2 1 1 1 1 2 1 1 2 1 2 2 2 1 1 ...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
223
codeforces
Okay, let's try to figure out this problem. So Valera has a certain number of bowls and plates, and each day he eats a dish that requires either a bowl or a plate. The goal is to calculate the minimum number of times he has to wash dishes so that he can eat every day as planned. First, let's understand the problem. Va...
To solve this problem, we need to determine the minimum number of times Valera will need to wash a plate or bowl if he acts optimally. Valera can only use clean kitchenware, and after each use, the kitchenware becomes dirty. The key is to optimally use the available clean bowls and plates to minimize washing. ### Appr...
true
21c80b84de37c0a6a459ebd411c862bc
Maxim and Discounts
Maxim always goes to the supermarket on Sundays. Today the supermarket has a special offer of discount systems. There are *m* types of discounts. We assume that the discounts are indexed from 1 to *m*. To use the discount number *i*, the customer takes a special basket, where he puts exactly *q**i* items he buys. Unde...
{"inputs": ["1\n2\n4\n50 50 100 100", "2\n2 3\n5\n50 50 50 50 50", "1\n1\n7\n1 1 1 1 1 1 1", "60\n7 4 20 15 17 6 2 2 3 18 13 14 16 11 13 12 6 10 14 1 16 6 4 9 10 8 10 15 16 13 13 9 16 11 5 4 11 1 20 5 11 20 19 9 14 13 10 6 6 9 2 13 11 4 1 6 8 18 10 3\n26\n2481 6519 9153 741 9008 6601 6117 1689 5911 2031 2538 5553 1358 ...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
35
codeforces
Okay, let's try to figure out this problem. So the task is to help Maxim buy all his items with the minimum cost by using the discount system optimally. Hmm, the discount allows him to take a certain number of items (exactly qi for discount type i) in a basket and then get up to two free items. But those free items can...
To solve this problem, we need to determine the minimum sum of money Maxim needs to spend to buy all his items while optimally using the supermarket's discount system. The discount system allows up to two free items when a certain number of items are bought using a specific basket. The goal is to maximize the use of fr...
true
21d3086ee327553584f533280fdd7ad2
Broken checker
"This problem is rubbish! There is not statement, and there are only 5 test cases. The problemsetter took liberties with this problem!" — people complained in the comments to one round on Codeforces. And even more... No, wait, the checker for the problem was alright, that's a mercy. The only line of the input contains ...
{"inputs": ["3", "1", "4", "2", "5"], "outputs": ["1", "2", "2", "3", "1"]}
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
39
codeforces
Okay, let's tackle this problem. Hmm, the problem statement is a bit unclear, but let's try to parse it. So the task is to write a Python function that reads an integer from stdin (between 1 and 5) and outputs an integer between 1 and 3. The sample input and output are not given, but all test cases are different, meani...
To solve this problem, we need to generate a function that maps an integer input between 1 and 5 to an integer output between 1 and 3. The key challenge is to ensure that each input is mapped to a valid output within the specified range, even though there are more possible inputs than outputs. ### Approach The approac...
false
Code is incorrect.
21daae042f23778474d174e49a3103bf
DravDe saves the world
How horrible! The empire of galactic chickens tries to conquer a beautiful city "Z", they have built a huge incubator that produces millions of chicken soldiers a day, and fenced it around. The huge incubator looks like a polygon on the plane *Oxy* with *n* vertices. Naturally, DravDe can't keep still, he wants to dest...
{"inputs": ["4\n0 0\n1 0\n1 1\n0 1\n0 -1\n1 0 1\n-1\n0 1 -1", "4\n0 0\n0 1\n1 1\n1 0\n0 -1\n-1 -1 1\n-1\n0 1 -1", "4\n0 0\n1 0\n1 1\n0 1\n0 -1\n1 1 1\n-1\n1 1 -1", "3\n-3 4\n5 -1\n-1 0\n-4 3\n4 4 5\n-3\n0 -3 -4", "4\n-2 1\n3 3\n2 -4\n0 -5\n-4 3\n2 4 4\n-4\n2 5 -4", "5\n10 10\n9 10\n8 9\n9 8\n10 9\n-10 -10\n1 1 1\n-1\n0...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
1
codeforces
Okay, let's see. I need to find the minimum t1 and t2 such that when DravDe jumps out of the plane at time t1, he lands inside the polygon. And the constraints are that he can open his parachute at any time during his fall, which affects his trajectory. Hmm. First, let's parse the problem. The plane starts at point A ...
To solve this problem, we need to determine the optimal time for DravDe to drop from his jet airplane and land inside the polygon representing the incubator's territory. The solution involves calculating the earliest possible time `t1` when DravDe should drop from the plane and the time `t2` when he should open his par...
false
Code is incorrect.
21e1ee2d6df8c4908bb9a6d812841345
Word Folding
You will receive 5 points for solving this problem. Manao has invented a new operation on strings that is called folding. Each fold happens between a pair of consecutive letters and places the second part of the string above first part, running in the opposite direction and aligned to the position of the fold. Using t...
{"inputs": ["ABRACADABRA", "ABBBCBDB", "AB", "ABBCDEFB", "THISISATEST", "Z", "ZZ", "ABCDEFGHIJKLMNOPQRSTUVWXYZ", "ABACBCABACACB", "LEHLLLLLLHAFGEGLLHAFDLHHLLLLLDGGEHGGHLLLLLLLLDFLCBLLEFLLCBLLCGLEDLGGLECLDGLEHLLLGELLLEGLLLLGDLLLDALD", "THISISTHELASTTEST"], "outputs": ["3", "3", "1", "3", "3", "1", "2", "1", "4", "49", "...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
2
codeforces
Okay, let's tackle this problem. So the task is to find the maximum size of a pile of identical characters after performing some fold operations on the given string. The folds can be placed between any consecutive letters, and each fold creates a new level. The piles are formed by stacking parts of the string verticall...
To solve this problem, we need to determine the maximum size of a pile of identical characters that can be formed by folding a given string. Each fold operation splits the string into parts and reverses the right part, stacking it above the left part. The goal is to find the largest pile of the same character that star...
false
Code is incorrect.
21fc26573a8d903daa076191d191a0f5
Unbearable Controversy of Being
Tomash keeps wandering off and getting lost while he is walking along the streets of Berland. It's no surprise! In his home town, for any pair of intersections there is exactly one way to walk from one intersection to the other one. The capital of Berland is very different! Tomash has noticed that even simple cases of...
{"inputs": ["5 4\n1 2\n2 3\n1 4\n4 3", "4 12\n1 2\n1 3\n1 4\n2 1\n2 3\n2 4\n3 1\n3 2\n3 4\n4 1\n4 2\n4 3", "1 0", "10 20\n6 10\n4 2\n1 5\n6 1\n8 9\n1 3\n2 6\n9 7\n4 5\n3 7\n9 2\n3 9\n4 8\n1 10\n6 9\n8 5\n7 6\n1 8\n8 10\n5 6", "3000 0", "1 0", "2 0", "2 1\n1 2", "2 2\n1 2\n2 1", "3 0", "3 6\n1 2\n1 3\n2 1\n2 3\n3 1\n3 2...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
2
codeforces
Okay, let's see. I need to find the number of "damn rhombi" in a directed graph. The definition says a rhombus consists of four distinct nodes a, b, c, d such that there's a path a->b->c and a->d->c, and also there's a direct road from a to c? Wait no, wait the problem statement says that a rhombus is when a has roads ...
To solve this problem, we need to count the number of "damn rhombi" in a directed graph. A "damn rhombus" is defined as a set of four distinct nodes \(a, b, c, d\) such that there are two paths from \(a\) to \(c\): one through \(b\) and another through \(d\). The solution involves efficiently determining the number of ...
true
22091ef7481b60323c746ca6fbc97fc7
Vitya in the Countryside
Every summer Vitya comes to visit his grandmother in the countryside. This summer, he got a huge wart. Every grandma knows that one should treat warts when the moon goes down. Thus, Vitya has to catch the moment when the moon is down. Moon cycle lasts 30 days. The size of the visible part of the moon (in Vitya's units...
{"inputs": ["5\n3 4 5 6 7", "7\n12 13 14 15 14 13 12", "1\n8", "44\n7 8 9 10 11 12 13 14 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 14 13 12 11 10", "92\n3 4 5 6 7 8 9 10 11 12 13 14 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
123
codeforces
Okay, let's see. So the problem is about determining whether the moon's visible part will increase (UP) or decrease (DOWN) the next day after Vitya's observations. If it's not possible to determine, we return -1. Hmm. First, I need to understand the moon's cycle. The cycle is 30 days long. The sequence given is 0,1,2,...
To solve this problem, we need to determine whether the visible part of the moon will increase (UP), decrease (DOWN), or cannot be determined (-1) based on Vitya's recorded observations. The moon's cycle follows a specific pattern, and we need to check all possible positions in this cycle that match the recorded observ...
true
22198e3a7c0abd019255159882cb5048
Eevee
You are solving the crossword problem K from IPSC 2014. You solved all the clues except for one: who does Eevee evolve into? You are not very into pokemons, but quick googling helped you find out, that Eevee can evolve into eight different pokemons: Vaporeon, Jolteon, Flareon, Espeon, Umbreon, Leafeon, Glaceon, and Syl...
{"inputs": ["7\n...feon", "7\n.l.r.o.", "6\n.s..o.", "7\nglaceon", "8\n.a.o.e.n", "7\n.laceon", "7\n..lveon", "7\n.l.ceon", "7\n..areon"], "outputs": ["leafeon", "flareon", "espeon", "glaceon", "vaporeon", "glaceon", "sylveon", "glaceon", "flareon"]}
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
172
codeforces
Okay, let's see. I need to solve this crossword problem where I have to determine which Eevee evolution matches a given pattern. The input gives the length of the word and a string with some letters and dots for unknowns. The output should be the correct Pokémon name in lowercase. First, I should list all the possible...
To solve this problem, we need to determine which Pokémon evolution of Eevee matches a given crossword pattern. The pattern consists of known letters and dots (indicating unknown letters), and we need to find the unique Pokémon name that fits the pattern. ### Approach 1. **Understand the Evolutions**: Eevee has eight ...
true
2233068987c95f8e6f31d0648e88a1bb
Gena's Code
It's the year 4527 and the tanks game that we all know and love still exists. There also exists Great Gena's code, written in 2016. The problem this code solves is: given the number of tanks that go into the battle from each country, find their product. If it is turns to be too large, then the servers might have not en...
{"inputs": ["3\n5 10 1", "4\n1 1 10 11", "5\n0 3 1 100 1", "40\n10 100 10 1 10 10 100 10 10 100 10 100 100 10 1824868942 100 100 1 10 100 100 10 100 100 10 100 10 1 10 100 100 100 10 1 10 1 10 10 100 100", "6\n1000000000000000000000000000000000000 6643573784 1000000000000000000000000000000000000 10000000000000000000000...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
81
codeforces
Okay, let's try to figure out how to solve this problem. So the task is to compute the product of all the numbers given as input, where most of them are "beautiful" numbers except possibly one. The beautiful numbers are those that have only 0s and at most one 1. The problem also mentions that the input has at least n-1...
To solve this problem, we need to compute the product of the number of tanks from each country, where most of these numbers are "beautiful" (composed of '0's and at most one '1'). The challenge is to handle very large numbers efficiently by leveraging the structure of beautiful numbers. ### Approach 1. **Check for Zer...
true
22c337ec8ce9b0fba407e3224879d095
Consecutive Subsequence
You are given an integer array of length $n$. You have to choose some subsequence of this array of maximum length such that this subsequence forms a increasing sequence of consecutive integers. In other words the required sequence should be equal to $[x, x + 1, \dots, x + k - 1]$ for some value $x$ and length $k$. Su...
{"inputs": ["7\n3 3 4 7 5 6 8", "6\n1 3 5 2 4 6", "4\n10 9 8 7", "9\n6 7 8 3 4 5 9 10 11", "1\n1337", "2\n456 123", "7\n100 3 4 7 5 6 8", "7\n3 3 4 5 6 7 8", "12\n1 2 3 4 5 6 7 8 9 10 11 12"], "outputs": ["4\n2 3 5 6 ", "2\n1 4 ", "1\n1 ", "6\n1 2 3 7 8 9 ", "1\n1 ", "1\n1 ", "4\n2 3 5 6 ", "6\n2 3 4 5 6 7 ", "12\n1 2 ...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
5
codeforces
Okay, let's see. The problem is to find the longest subsequence in an array that forms consecutive increasing integers. Hmm. The subsequence can be any elements as long as their order is preserved, but the values have to form something like x, x+1, x+2, ..., x+k-1. So, the goal is to maximize k. First, I need to think...
To solve this problem, we need to find the longest subsequence of an array that forms a sequence of consecutive integers. The subsequence must maintain the order of elements as they appear in the original array. ### Approach 1. **Dynamic Programming (DP) with Dictionary**: We use a dictionary to track the maximum leng...
false
Code is incorrect.
22e73f576e0a29ac8f1acaad7b95ca42
Kuriyama Mirai's Stones
Kuriyama Mirai has killed many monsters and got many (namely *n*) stones. She numbers the stones from 1 to *n*. The cost of the *i*-th stone is *v**i*. Kuriyama Mirai wants to know something about these stones so she will ask you two kinds of questions: 1. She will tell you two numbers, *l* and *r* (1<=≤<=*l*<=≤<=*r*...
{"inputs": ["6\n6 4 2 7 2 7\n3\n2 3 6\n1 3 4\n1 1 6", "4\n5 5 2 3\n10\n1 2 4\n2 1 4\n1 1 1\n2 1 4\n2 1 2\n1 1 1\n1 3 3\n1 1 3\n1 4 4\n1 2 2", "4\n2 2 3 6\n9\n2 2 3\n1 1 3\n2 2 3\n2 2 3\n2 2 2\n1 1 3\n1 1 3\n2 1 4\n1 1 2", "18\n26 46 56 18 78 88 86 93 13 77 21 84 59 61 5 74 72 52\n25\n1 10 10\n1 9 13\n2 13 17\n1 8 14\n2...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
467
codeforces
Okay, let's see. I need to solve this programming problem. Let's read the problem carefully. So, the problem is about stones with costs. There are two types of queries. For type 1, we sum the original array from l to r. For type 2, we sum the sorted array from l to r. Oh right, and the indices here are 1-based. Wait, ...
To solve this problem, we need to efficiently answer two types of queries regarding the costs of stones. The first query type requires the sum of costs in a specified range of the original array, while the second query type requires the sum of costs in a specified range of the sorted array. ### Approach 1. **Preproce...
true
23300678e886bea71fe9a35c71bc04e8
R2D2 and Droid Army
An army of *n* droids is lined up in one row. Each droid is described by *m* integers *a*1,<=*a*2,<=...,<=*a**m*, where *a**i* is the number of details of the *i*-th type in this droid's mechanism. R2-D2 wants to destroy the sequence of consecutive droids of maximum length. He has *m* weapons, the *i*-th weapon can aff...
{"inputs": ["5 2 4\n4 0\n1 2\n2 1\n0 2\n1 3", "3 2 4\n1 2\n1 3\n2 2", "1 1 0\n0", "1 1 0\n1", "1 1 1\n0", "4 5 33\n2 10 2 3 2\n10 6 4 5 0\n3 1 7 3 2\n4 4 2 1 5", "4 5 40\n0 10 9 0 4\n10 5 5 7 4\n9 9 5 5 2\n6 7 9 4 3", "31 2 1913\n845 576\n862 325\n914 283\n431 837\n193 171\n30 248\n290 488\n810 552\n463 74\n765 469\n78...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
1
codeforces
Okay, I need to solve this programming problem. Let's read the problem statement carefully. The problem is about finding the longest consecutive sequence of droids that R2-D2 can destroy by using his weapons in such a way that the total shots used are at most k. Each weapon corresponds to a detail type, and each shot ...
To solve this problem, we need to determine the maximum length of consecutive droids that can be destroyed by R2-D2 using his weapons in such a way that the total number of shots used does not exceed a given limit. Each weapon targets a specific type of detail in the droids, and a droid is considered destroyed when all...
true
233f32c704219a8929d73e179f9d4a8f
Little Pony and Crystal Mine
Twilight Sparkle once got a crystal from the Crystal Mine. A crystal of size *n* (*n* is odd; *n*<=&gt;<=1) is an *n*<=×<=*n* matrix with a diamond inscribed into it. You are given an odd integer *n*. You need to draw a crystal of size *n*. The diamond cells of the matrix should be represented by character "D". All ot...
{"inputs": ["3", "5", "7", "11", "15", "21", "33", "57", "69", "81", "91", "101"], "outputs": ["*D*\nDDD\n*D*", "**D**\n*DDD*\nDDDDD\n*DDD*\n**D**", "***D***\n**DDD**\n*DDDDD*\nDDDDDDD\n*DDDDD*\n**DDD**\n***D***", "*****D*****\n****DDD****\n***DDDDD***\n**DDDDDDD**\n*DDDDDDDDD*\nDDDDDDDDDDD\n*DDDDDDDDD*\n**DDDDDDD**\n*...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
308
codeforces
Okay, let's see. I need to generate a crystal pattern based on an odd integer n. The crystal is an n x n matrix where a diamond is inscribed. The diamond cells are 'D's and the rest are '*'s. Hmm. First, let's understand the examples. For n=3, the output is: *D* DDD *D* So the middle row is all D's. The first and th...
To solve this problem, we need to generate a diamond pattern within an n x n matrix where the diamond cells are represented by 'D' and the remaining cells by '*'. The diamond shape is determined based on the Manhattan distance from the center of the matrix. ### Approach 1. **Understanding the Diamond Shape**: The diam...
false
Code is incorrect.
23522805b8d87a2adfb4a95b8c4ba94f
Functions On The Segments
You have an array *f* of *n* functions.The function *f**i*(*x*) (1<=≤<=*i*<=≤<=*n*) is characterized by parameters: *x*1,<=*x*2,<=*y*1,<=*a*,<=*b*,<=*y*2 and take values: - *y*1, if *x*<=≤<=*x*1. - *a*·*x*<=+<=*b*, if *x*1<=&lt;<=*x*<=≤<=*x*2. - *y*2, if *x*<=&gt;<=*x*2. There are *m* queries. Each query is deter...
{"inputs": ["1\n1 2 1 4 5 10\n1\n1 1 2", "3\n2 5 1 1 1 4\n3 6 8 2 5 7\n1 3 5 1 4 10\n3\n1 3 3\n2 3 2\n1 2 5", "7\n4 8 562244866 6 8 140807945\n5 7 415374420 7 6 596093578\n3 4 766370993 3 7 973128805\n4 6 841321398 3 2 893107667\n4 9 968214628 5 8 329310838\n0 10 64315145 9 4 716996081\n1 6 568407659 3 0 22184171\n15\n...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
1
codeforces
Okay, let's try to figure out how to solve this problem. Hmm. The problem statement is a bit complex, so I need to break it down step by step. First, the problem involves processing multiple functions and answering a bunch of queries. Each function is piecewise linear, and for each query, we need to compute the sum of...
To solve this problem, we need to efficiently compute the sum of piecewise functions over a range for multiple queries. Each query's input depends on the result of the previous query, which adds a layer of complexity. The solution involves using segment trees to handle range queries efficiently. ### Approach 1. **Prob...
true
23782452cf5313c2d3b5626ea74e0e61
Water Taps
Consider a system of *n* water taps all pouring water into the same container. The *i*-th water tap can be set to deliver any amount of water from 0 to *a**i* ml per second (this amount may be a real number). The water delivered by *i*-th tap has temperature *t**i*. If for every you set *i*-th tap to deliver exactly ...
{"inputs": ["2 100\n3 10\n50 150", "3 9\n5 5 30\n6 6 10", "2 12\n1 3\n10 15", "20 30\n70 97 14 31 83 22 83 56 19 87 59 7 7 89 24 82 34 40 6 24\n10 4 47 46 11 18 32 55 16 32 53 37 43 32 41 46 57 14 60 44", "1 1\n1000000\n1", "1 200\n1000000\n100", "1 1000000\n1000000\n1000000"], "outputs": ["6.000000000000000", "40.0000...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
3
codeforces
Okay, let's see. The problem is about maximizing the total water flow from taps such that the resulting temperature is exactly T. Hmm. So each tap can output between 0 and a_i ml/s. The temperature of each tap's water is t_i. The combined temperature is the weighted average by flow. So the formula would be sum(x_i * t_...
To solve this problem, we need to maximize the amount of water poured into a container from multiple taps such that the resulting temperature is exactly T. Each tap can be adjusted to deliver water at a certain rate and temperature, and we need to ensure the weighted average temperature of the combined flow equals T. ...
false
Code is incorrect.
237ca36d287733e0a58c9626c31d87aa
Businessmen Problems
Two famous competing companies ChemForces and TopChemist decided to show their sets of recently discovered chemical elements on an exhibition. However they know that no element should be present in the sets of both companies. In order to avoid this representatives of both companies decided to make an agreement on the ...
{"inputs": ["3\n1 2\n7 2\n3 10\n4\n1 4\n2 4\n3 4\n4 4", "1\n1000000000 239\n3\n14 15\n92 65\n35 89", "10\n598654597 488228616\n544064902 21923894\n329635457 980089248\n988262691 654502493\n967529230 543358150\n835120075 128123793\n809901567 613170206\n152157661 479980560\n859252956 318029856\n614959273 735298093\n10\n8...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
212
codeforces
Okay, I need to solve this programming problem. Let's read the problem carefully. The problem is about two companies, ChemForces and TopChemist, each of which has a set of elements. Each element gives some income if included in their set. The catch is that no element can be in both sets. We have to choose subsets for ...
To solve this problem, we need to maximize the total income for two companies, ChemForces and TopChemist, such that no element is present in both companies' sets. The solution involves selecting elements from each company's list such that common elements are chosen from the company that offers the higher income, while ...
true
2397732f27101ac11fd5369b72448274
Epidemic in Monstropolis
There was an epidemic in Monstropolis and all monsters became sick. To recover, all monsters lined up in queue for an appointment to the only doctor in the city. Soon, monsters became hungry and began to eat each other. One monster can eat other monster if its weight is strictly greater than the weight of the monste...
{"inputs": ["6\n1 2 2 2 1 2\n2\n5 5", "5\n1 2 3 4 5\n1\n15", "5\n1 1 1 3 3\n3\n2 1 6", "5\n1 1 1 1 2\n3\n1 1 4", "5\n1 1 1 1 1\n4\n1 1 2 1", "6\n2 1 2 2 1 2\n2\n5 5", "8\n2 5 3 1 4 2 3 4\n3\n10 6 8", "1\n959139\n1\n470888", "3\n2 2 1\n1\n5", "3\n1 2 2\n1\n5", "5\n1 2 3 4 5\n1\n10", "5\n325539 329221 106895 882089 71867...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
3
codeforces
Okay, let's tackle this problem. Hmm, the task is to determine if the initial sequence of monster weights can be transformed into the final sequence by monsters eating each other according to the rules. And if possible, output the steps taken. Otherwise, output NO. First, I need to understand the problem thoroughly. L...
To solve this problem, we need to determine if the initial queue of monsters can be transformed into the final queue through a series of valid eating operations. Each monster can eat its neighbor if it is strictly heavier, and after eating, the queue is adjusted accordingly. The solution involves checking if the transf...
false
Code is incorrect.
239a5762998495b0fe4bf42d3952fd48
Tea Queue
Recently *n* students from city S moved to city P to attend a programming camp. They moved there by train. In the evening, all students in the train decided that they want to drink some tea. Of course, no two people can use the same teapot simultaneously, so the students had to form a queue to get their tea. *i*-th s...
{"inputs": ["2\n2\n1 3\n1 4\n3\n1 5\n1 1\n2 3", "19\n1\n1 1\n1\n1 2\n1\n1 1000\n1\n1 2000\n1\n2 2\n1\n2 3\n1\n2 1000\n1\n2 2000\n1\n1999 1999\n1\n1999 2000\n1\n2000 2000\n2\n1 1\n1 1\n2\n1 1\n1 2\n2\n1 2\n1 1\n2\n1 2000\n1 1\n2\n1 1\n1 2000\n2\n1 2000\n2 2\n2\n2 2000\n2 2\n2\n2 2\n2 2000", "1\n11\n1 1\n1 1\n1 1\n1 1\n1...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
72
codeforces
Okay, let's see. I need to solve this programming problem. Let's start by understanding the problem statement thoroughly. So, the problem is about students queuing up to use a teapot. Each student arrives at the queue at the beginning of the l_i-th second. They join the end of the queue. If multiple students arrive a...
To solve this problem, we need to determine the exact second each student will use the teapot or if they leave without using it. The students arrive at a specific time and join a queue, which they might leave if they can't get their turn before a specified deadline. ### Approach 1. **Input Reading**: Read the number o...
false
Code is incorrect.
23c012a6f7008cf0064bf7ecf55b2fd3
Antichain
You have a directed acyclic graph *G*, consisting of *n* vertexes, numbered from 0 to *n*<=-<=1. The graph contains *n* edges numbered from 0 to *n*<=-<=1. An edge with number *i* connects vertexes *i* and (*i*<=+<=1) *mod* *n*, and it can be directed in either direction (from *i* to (*i*<=+<=1) *mod* *n*, or vise vers...
{"inputs": ["001", "110010", "0010011110", "0111001010101110001100000010011000100101110010001100111110101110001110101010111000010010011000000110", "0110101100", "0111110110", "0001011111", "0000011010101001001100101111111011100000011000101001011001000111110000010000100011011011101101100110", "00001000001100101000100101...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
1
codeforces
Okay, let's see. So the problem is about finding the maximum antichain in a directed acyclic graph (DAG) that's constructed in a specific way. The antichain is a set of vertices where no two are comparable, meaning there's no path between any two of them. The goal is to find the largest such set. Hmm. The graph is giv...
To solve this problem, we need to determine the size of the maximum antichain in a directed acyclic graph (DAG) formed by a circular arrangement of nodes with edges directed according to a given string. The solution involves analyzing the structure of the graph and leveraging the properties of direction changes in the ...
false
Code is incorrect.
23c3c1aedb4a37389c4a191f8443ae42
Interesting drink
Vasiliy likes to rest after a hard work, so you may often meet him in some bar nearby. As all programmers do, he loves the famous drink "Beecola", which can be bought in *n* different shops in the city. It's known that the price of one bottle in the shop *i* is equal to *x**i* coins. Vasiliy plans to buy his favorite ...
{"inputs": ["5\n3 10 8 6 11\n4\n1\n10\n3\n11", "5\n868 987 714 168 123\n10\n424\n192\n795\n873\n117\n914\n735\n158\n631\n471", "3\n435 482 309\n7\n245\n241\n909\n745\n980\n29\n521", "1\n653\n9\n903\n980\n80\n770\n965\n874\n381\n657\n969", "12\n35345 58181 32223 84621 35905 73863 99537 30666 67771 39229 36847 29038\n23\...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
284
codeforces
Okay, let's see. The problem is about finding, for each day, how many shops have a price less than or equal to the money Vasiliy has that day. Oh right, the shops have their prices, and each day he has some m_i coins. So for each m_i, we need to count how many x_i's are <= m_i. Hmm, the first thing that comes to mind ...
To solve this problem, we need to determine how many shops Vasiliy can buy his favorite drink from each day, given his daily budget. The solution involves efficiently processing each query to count the number of shops with prices within his budget for that day. ### Approach 1. **Read Input and Sort Prices**: First, we...
true
23ebcca15bd46dead8f1b185628d3dc9
Packmen
A game field is a strip of 1<=×<=*n* square cells. In some cells there are Packmen, in some cells — asterisks, other cells are empty. Packman can move to neighboring cell in 1 time unit. If there is an asterisk in the target cell then Packman eats it. Packman doesn't spend any time to eat an asterisk. In the initial ...
{"inputs": ["7\n*..P*P*", "10\n.**PP.*P.*", "19\n**P.*..*..P..*.*P**", "12\nP**.*P*P*P**", "58\n..P.P*.P*.P...PPP...P*....*..*.**......*P.*P.....**P...*P*", "10\n..P*.P.*.*", "10\n***.*.*..P", "15\nP***..PPP..P*.P", "20\n.P**P**P**PP.PP**PP*", "20\n.....*.**..........P", "25\n...*..**..*.....*..*...P.", "30\n*P.*...*.*...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
7
codeforces
Okay, I need to solve this programming problem. Let's read the problem statement carefully. So the problem is about Packmen moving on a game field (a strip of cells) to eat all the asterisks in the minimum possible time. Each Packman can move left or right, change direction any number of times. All start moving at the...
To solve this problem, we need to determine the minimum possible time required for Packmen to eat all the asterisks on a game field. Each Packman can move left or right, change direction any number of times, and starts moving at the same time. The goal is to find the optimal paths for the Packmen to minimize the maximu...
false
Code is incorrect.
23eee3079293ce0dc454eed8b1e186ab
Let's Play Osu!
You're playing a game called Osu! Here's a simplified version of it. There are *n* clicks in a game. For each click there are two outcomes: correct or bad. Let us denote correct as "O", bad as "X", then the whole play can be encoded as a sequence of *n* characters "O" and "X". Using the play sequence you can calculate...
{"inputs": ["3\n0.5 0.5 0.5", "4\n0.7 0.2 0.1 0.9", "5\n1 1 1 1 1", "10\n0.684846 0.156794 0.153696 0.714526 0.281868 0.628256 0.745339 0.123854 0.748936 0.856333", "10\n0.684488 0.834971 0.834886 0.643646 0.162710 0.119851 0.659401 0.743950 0.220986 0.839665", "10\n0.684416 0.170607 0.491124 0.469470 0.458879 0.658170...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
14
codeforces
Okay, so I need to solve this problem where I have to compute the expected score of a play in Osu! based on the probabilities of each click being correct. Hmm, let's think. The problem says that the score is the sum of squares of the lengths of each maximal consecutive 'O's block. For example, "OOXOOO" would contribut...
To solve this problem, we need to calculate the expected score for a game sequence in Osu! where each click has a certain probability of being correct. The score is determined by the sum of the squares of the lengths of consecutive correct clicks (denoted as 'O'). ### Approach The key insight is to use dynamic progra...
false
Code is incorrect.
23f7e534541a11b5794fceedb3aa1919
Road Map
There are *n* cities in Berland. Each city has its index — an integer number from 1 to *n*. The capital has index *r*1. All the roads in Berland are two-way. The road system is such that there is exactly one path from the capital to each city, i.e. the road map looks like a tree. In Berland's chronicles the road map is...
{"inputs": ["3 2 3\n2 2", "6 2 4\n6 1 2 4 2", "7 7 6\n7 7 5 5 7 7", "4 2 3\n2 1 3", "5 5 4\n5 4 1 5", "6 2 1\n4 1 2 2 2", "2 1 2\n1", "2 2 1\n2", "3 1 3\n1 2", "10 4 3\n5 6 9 10 1 9 6 8 4", "100 62 42\n45 66 13 18 93 47 83 19 41 66 5 70 16 29 54 28 65 91 92 24 90 54 7 40 77 53 68 58 70 65 68 30 94 80 16 18 69 21 94 1 9...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
12
codeforces
Okay, let's see. The problem is about restructuring a tree when the capital (root) is changed from r1 to r2. The initial tree is structured such that each node except r1 has a parent p_i, which represents the last node on the path from r1 to i. Now, when the new capital is r2, we need to find the new parent array where...
To solve this problem, we need to restructure the tree representation of cities in Berland when the capital is moved from one city to another. The goal is to determine the new parent relationships for each city (except the new capital) based on the new root of the tree. ### Approach 1. **Input Reading and Initializati...
true