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
69769ded2ddea958b4e6622ce7fb7d10
none
Pavel cooks barbecue. There are *n* skewers, they lay on a brazier in a row, each on one of *n* positions. Pavel wants each skewer to be cooked some time in every of *n* positions in two directions: in the one it was directed originally and in the reversed direction. Pavel has a plan: a permutation *p* and a sequence ...
{"inputs": ["4\n4 3 2 1\n0 1 1 1", "3\n2 3 1\n0 0 0", "1\n1\n0", "2\n1 2\n0 0", "2\n2 1\n0 0", "2\n1 2\n0 1", "2\n2 1\n1 0", "2\n1 2\n1 1", "2\n2 1\n1 1", "5\n2 1 3 4 5\n1 0 0 0 1", "10\n4 10 5 1 6 8 9 2 3 7\n0 1 0 0 1 0 0 1 0 0", "20\n10 15 20 17 8 1 14 6 3 13 19 2 16 12 4 5 11 7 9 18\n0 0 0 1 0 0 0 1 0 0 1 0 0 0 0 0 ...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
20
codeforces
Okay, so I need to solve this programming problem. Let me read the problem carefully. The problem says that Pavel wants each skewer to visit all 2n possible placements. Each placement is a combination of a position (1 to n) and a direction (original or reversed). Each second, the skewers are moved according to permuta...
To solve this problem, we need to determine the minimum number of changes required to both the permutation and the reversal sequence such that every skewer visits each of the 2n possible placements (each position in both directions). The solution involves analyzing the permutation cycles and ensuring that each cycle's ...
false
Code is incorrect.
6978724378602e63542d64fd1f157f42
Line
A line on the plane is described by an equation *Ax*<=+<=*By*<=+<=*C*<==<=0. You are to find any point on this line, whose coordinates are integer numbers from <=-<=5·1018 to 5·1018 inclusive, or to find out that such points do not exist. The first line contains three integers *A*, *B* and *C* (<=-<=2·109<=≤<=*A*,<=*B*...
{"inputs": ["2 5 3", "0 2 3", "931480234 -1767614767 -320146190", "-1548994394 -1586527767 -1203252104", "296038088 887120955 1338330394", "1906842444 749552572 -1693767003", "-1638453107 317016895 -430897103", "-1183748658 875864960 -1315510852", "427055698 738296578 -52640953", "-1516373701 -584304312 -746376800", "2...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
29
codeforces
Okay, I need to solve this problem where I have to find any integer point (x, y) on the line Ax + By + C = 0, with x and y between -5e18 and 5e18. If such a point exists, output it; otherwise, output -1. First, let me understand the problem. The line equation is Ax + By + C = 0. So for any point (x, y) on this line, t...
To solve this problem, we need to determine if there exists a point with integer coordinates on the line defined by the equation \(Ax + By + C = 0\). If such a point exists, we must find any one of these points; otherwise, we should return -1. ### Approach 1. **Understanding the Line Equation**: The given line equatio...
false
Code is incorrect.
69acc2eae81f23c8a6ec3869ee66ed2f
Archer
SmallR is an archer. SmallR is taking a match of archer with Zanoes. They try to shoot in the target in turns, and SmallR shoots first. The probability of shooting the target each time is for SmallR while for Zanoes. The one who shoots in the target first should be the winner. Output the probability that SmallR will...
{"inputs": ["1 2 1 2", "1 3 1 3", "1 3 2 3", "3 4 3 4", "1 2 10 11", "4 5 4 5", "466 701 95 721", "268 470 444 885", "632 916 713 821", "269 656 918 992", "71 657 187 695", "435 852 973 978", "518 816 243 359", "882 962 311 811", "684 774 580 736", "486 868 929 999", "132 359 996 998", "933 977 266 450", "298 833 615 8...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
353
codeforces
Okay, let's see. So the problem is about calculating the probability that SmallR wins the archery match. The setup is that SmallR and Zanoes take turns shooting, starting with SmallR. The first to hit the target wins. We need to find the probability that SmallR wins. The input gives four integers. Wait, the problem st...
To solve this problem, we need to determine the probability that SmallR will win an archery match against Zanoes, given their respective probabilities of hitting the target. SmallR shoots first, and the first to hit the target wins. ### Approach 1. **Understand the Problem**: The key observation is that the match can ...
true
6a1937e725b9a6aff7dc0feedc20e9f0
Binary Number
Little walrus Fangy loves math very much. That's why when he is bored he plays with a number performing some operations. Fangy takes some positive integer *x* and wants to get a number one from it. While *x* is not equal to 1, Fangy repeats the following action: if *x* is odd, then he adds 1 to it, otherwise he divide...
{"inputs": ["1", "1001001", "101110", "11", "11110001101", "1010101001001111000111110011111000010101011111101010", "1100000010010100111011100011110101111", "11000111111110110110100110110101111100010100110110010", "11100000110100011110101001101111100000011001111000011110000000111110111", "1000101100110000000001111010110...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
47
codeforces
Okay, I need to solve this problem where I have to calculate the number of steps it takes for Fangy to turn a given binary number into 1 using specific operations. Let me think through how to approach this. So the problem says that for a number x (given in binary), each step depends on whether it's odd or even. Wait, ...
To solve this problem, we need to determine the number of steps required for Fangy to transform a given binary number into 1 using specific operations: adding 1 if the number is odd and dividing by 2 if the number is even. The challenge is to efficiently handle very large binary numbers, up to 1,000,000 digits, without...
false
Code is incorrect.
6a442951f918b3291f7632fa0bf0689e
Connected Components?
You are given an undirected graph consisting of *n* vertices and edges. Instead of giving you the edges that exist in the graph, we give you *m* unordered pairs (*x*,<=*y*) such that there is no edge between *x* and *y*, and if some pair of vertices is not listed in the input, then there is an edge between these verti...
{"inputs": ["5 5\n1 2\n3 4\n3 2\n4 2\n2 5", "8 15\n2 1\n4 5\n2 4\n3 4\n2 5\n3 5\n2 6\n3 6\n5 6\n4 6\n2 7\n3 8\n2 8\n3 7\n6 7", "12 58\n1 2\n1 3\n1 4\n1 5\n1 6\n1 7\n1 8\n1 10\n1 11\n1 12\n2 3\n2 4\n2 5\n2 6\n2 7\n2 8\n2 9\n2 10\n2 11\n2 12\n3 4\n3 5\n3 6\n3 7\n3 8\n3 9\n3 10\n3 11\n3 12\n4 5\n4 6\n4 8\n4 11\n4 12\n5 6\...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
16
codeforces
Okay, so I need to solve this programming problem. Let's read the problem statement carefully. The problem is about finding connected components in a graph where the edges are given as the complement. That is, the input gives pairs of nodes that do NOT have an edge between them, and all other pairs do. My task is to c...
To solve this problem, we need to determine the number of connected components and their sizes in a graph where edges are defined as all possible pairs of nodes except for a given list of forbidden edges. The challenge is to efficiently handle the graph's dense nature due to the large number of possible edges. ### App...
true
6a66d1afd709b4c997f0e107675265b7
Fedya and Maths
Fedya studies in a gymnasium. Fedya's maths hometask is to calculate the following expression: for given value of *n*. Fedya managed to complete the task. Can you? Note that given number *n* can be extremely large (e.g. it can exceed any integer type of your programming language). The single line contains a single int...
{"inputs": ["4", "124356983594583453458888889", "2", "7854", "584660", "464", "192329", "85447", "956", "83", "33", "64", "971836", "578487", "71752", "2563", "51494", "247", "52577", "13", "26232", "0", "10", "12", "8", "1"], "outputs": ["4", "0", "0", "0", "4", "4", "0", "0", "4", "0", "0", "4", "4", "0", "4", "0", "...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
84
codeforces
Okay, I need to solve this problem where given a number n as a string, I have to compute the expression (1^n + 2^n + 3^n + 4^n) mod 5. Hmm, let's think about how to approach this. First, the problem mentions that n can be extremely large, up to 10^5 digits. So handling it as a regular integer in Python isn't feasible ...
To solve this problem, we need to compute the value of the expression \(1^n + 2^n + 3^n + 4^n \mod 5\) for a given very large integer \(n\). The challenge is to handle extremely large values of \(n\) efficiently using modular arithmetic properties. ### Approach 1. **Modular Arithmetic Insight**: The result of each ter...
true
6a681fb01eaba2e90830b8381036cd5d
Not Equal on a Segment
You are given array *a* with *n* integers and *m* queries. The *i*-th query is given with three integers *l**i*,<=*r**i*,<=*x**i*. For the *i*-th query find any position *p**i* (*l**i*<=≤<=*p**i*<=≤<=*r**i*) so that *a**p**i*<=≠<=*x**i*. The first line contains two integers *n*,<=*m* (1<=≤<=*n*,<=*m*<=≤<=2·105) — the ...
{"inputs": ["6 4\n1 2 1 1 3 5\n1 4 1\n2 6 2\n3 4 1\n3 4 2", "1 1\n1\n1 1 1", "1 1\n2\n1 1 2", "1 1\n569888\n1 1 967368", "10 10\n1 1 1 1 1 1 1 1 1 1\n3 10 1\n3 6 1\n1 8 1\n1 7 1\n1 5 1\n3 7 1\n4 7 1\n9 9 1\n6 7 1\n3 4 1", "10 10\n1 2 2 2 2 1 1 2 1 1\n3 3 1\n4 9 1\n4 8 1\n2 7 2\n2 8 2\n3 10 1\n7 7 2\n10 10 2\n1 5 1\n1 2...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
15
codeforces
Okay, let's tackle this programming problem. Hmm. The problem says that for each query, we need to find any position between l_i and r_i where the value is not equal to x_i. If all are x_i, then output -1. So, the straightforward approach would be for each query, iterate from l_i to r_i and check if any element is no...
To solve this problem, we need to efficiently determine if there exists any position within a given range that does not match a specified value for each query. Given the constraints, a direct approach would be too slow, so we need an optimized solution. ### Approach 1. **Preprocessing Arrays**: - **next_diff**: Fo...
false
Code is incorrect.
6a9c2f420ce1c26085455b0f8032be0f
Palindrome Degree
String *s* of length *n* is called *k*-palindrome, if it is a palindrome itself, and its prefix and suffix of length are (*k*<=-<=1)-palindromes. By definition, any string (even empty) is 0-palindrome. Let's call the palindrome degree of string *s* such a maximum number *k*, for which *s* is *k*-palindrome. For examp...
{"inputs": ["a2A", "abacaba", "CCeCeCCCee", "opooppppopppopoppopoooppopopooopopppooopppoppoppoppppoooppooooooopppoopoopooooppooooppppppppooopooop", "odribmizzsgholprdsth", "z"], "outputs": ["1", "6", "4", "3", "1", "1"]}
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
2
codeforces
Okay, let's see. I need to find the sum of the palindrome degrees for all prefixes of a given string. Hmm, the palindrome degree of a string is the maximum k such that it's a k-palindrome. And a k-palindrome is a palindrome where its prefix and suffix of length (n -1)/2 are (k-1)-palindromes. Oh right, and by definitio...
To solve this problem, we need to compute the sum of the palindrome degrees of all prefixes of a given string. A string's palindrome degree is the maximum value k such that the string is a k-palindrome. A k-palindrome is defined as a palindrome whose prefix and suffix of length (n-1)/2 are (k-1)-palindromes. ### Appro...
false
Code is incorrect.
6a9dad7100e9c491d15d4d8c2341be0d
Bear and Raspberry
The bear decided to store some raspberry for the winter. He cunningly found out the price for a barrel of honey in kilos of raspberry for each of the following *n* days. According to the bear's data, on the *i*-th (1<=≤<=*i*<=≤<=*n*) day, the price for one barrel of honey is going to is *x**i* kilos of raspberry. Unfo...
{"inputs": ["5 1\n5 10 7 3 20", "6 2\n100 1 10 40 10 40", "3 0\n1 2 3", "2 0\n2 1", "10 5\n10 1 11 2 12 3 13 4 14 5", "100 4\n2 57 70 8 44 10 88 67 50 44 93 79 72 50 69 19 21 9 71 47 95 13 46 10 68 72 54 40 15 83 57 92 58 25 4 22 84 9 8 55 87 0 16 46 86 58 5 21 32 28 10 46 11 29 13 33 37 34 78 33 33 21 46 70 77 51 45 9...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
297
codeforces
Okay, let's try to figure out how to solve this problem. So the bear wants to maximize his raspberry by borrowing a honey barrel, selling it on day d, then buying another on day d+1 and returning it along with c raspberries. Hmm. First, let's understand the process. The bear starts with nothing. He borrows a barrel on...
To solve this problem, we need to determine the maximum number of kilograms of raspberries the bear can earn by executing a plan to borrow and trade a honey barrel over consecutive days. The bear's profit is calculated by selling the borrowed barrel on one day and buying it back the next day, considering the rental fee...
true
6acf2fb9e0257a25a02dab4cf9af8c13
Minimal Labels
You are given a directed acyclic graph with *n* vertices and *m* edges. There are no self-loops or multiple edges between any pair of vertices. Graph can be disconnected. You should assign labels to all vertices in such a way that: - Labels form a valid permutation of length *n* — an integer sequence such that each ...
{"inputs": ["3 3\n1 2\n1 3\n3 2", "4 5\n3 1\n4 1\n2 3\n3 4\n2 4", "5 4\n3 1\n2 1\n2 3\n4 5", "2 1\n2 1", "5 10\n5 2\n4 1\n2 1\n3 4\n2 4\n3 2\n5 4\n3 5\n3 1\n5 1", "100 10\n73 55\n29 76\n15 12\n94 46\n77 67\n76 16\n72 50\n41 40\n89 75\n27 22", "100000 10\n4412 787\n97243 62644\n78549 66107\n43440 41961\n39621 35680\n870...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
21
codeforces
Okay, let's see. I need to solve this problem where I have to assign labels to the vertices of a directed acyclic graph (DAG) such that the labels form the lexicographically smallest permutation possible while satisfying the condition that for every edge v->u, the label of v is smaller than that of u. Hmm, right. So th...
To solve this problem, we need to assign labels to the vertices of a directed acyclic graph (DAG) such that the labels form the lexicographically smallest permutation possible while satisfying the condition that for every edge v->u, the label of v is smaller than that of u. ### Approach The key insight is to use a to...
false
Code is incorrect.
6b3e4bd0a44e3c15f50145c3a8b35a30
Pasha and Pixels
Pasha loves his phone and also putting his hair up... But the hair is now irrelevant. Pasha has installed a new game to his phone. The goal of the game is following. There is a rectangular field consisting of *n* row with *m* pixels in each row. Initially, all the pixels are colored white. In one move, Pasha can choos...
{"inputs": ["2 2 4\n1 1\n1 2\n2 1\n2 2", "2 3 6\n2 3\n2 2\n1 3\n2 2\n1 2\n1 1", "5 3 7\n2 3\n1 2\n1 1\n4 1\n3 1\n5 3\n3 2", "3 3 11\n2 1\n3 1\n1 1\n1 3\n1 2\n2 3\n3 3\n3 2\n2 2\n1 3\n3 3", "2 2 5\n1 1\n2 1\n2 1\n1 2\n2 2", "518 518 10\n37 97\n47 278\n17 467\n158 66\n483 351\n83 123\n285 219\n513 187\n380 75\n304 352", ...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
207
codeforces
Okay, so I need to solve this programming problem. Let's read the problem carefully. The problem is about a grid where Pasha is painting pixels black. Each move, he colors a pixel. The game ends when a 2x2 square of black pixels is formed. We have to determine if during any of the moves, after coloring, a 2x2 square i...
To solve this problem, we need to determine if and when Pasha loses the game by forming a 2x2 square of black pixels while following his plan of moves. The solution involves checking each move to see if it completes any 2x2 square of black pixels. ### Approach 1. **Track Painted Pixels**: Use a set to keep track of al...
true
6b3e915ee56ea07b2680bd5f2731c25e
Walking!
There is a sand trail in front of Alice's home. In daytime, people walk over it and leave a footprint on the trail for their every single step. Alice cannot distinguish the order of the footprints, but she can tell whether each footprint is made by left foot or right foot. Also she's certain that all people are walkin...
{"inputs": ["RRLRL", "RLRLRLRLR", "RRRRRLLLL", "RRLLRRRRLLRRLLRRLLLLRRLL", "RRLRRRLLRRLRRRLRLLRRLLLRRRLLRLRRRLRLLRRRRRLLLLRLRRRLRRRLRLRLLLRLLLLLRRLRLLLRRLLLLLRLRRLRRLLLRLLRRLRL", "L", "R", "LLLLRRRRRRLLLLLLRRRRR", "RLRRLLLRLRLRR", "LR", "RL", "LLRRRLLRRRLL", "RRLLLRRLLLRR", "RRLLR", "LLRRL"], "outputs": ["1\n2 5 1 3 4"...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
1
codeforces
Okay, let's tackle this problem. So, the task is to find the minimal number of backward steps for a given footprint sequence and also construct a possible step order that achieves this minimum. Hmm. Let me think. First, let's understand the problem. People walk by alternating left and right feet. Each step leaves a fo...
To solve this problem, we need to determine the minimum number of backward steps required to form a given sequence of footprints, considering that people alternate their steps between left and right feet. Additionally, we need to construct a possible permutation of steps that results in the given sequence with the mini...
false
Code is incorrect.
6b44c6785c6ccefed3314b846f146f9e
Molly's Chemicals
Molly Hooper has *n* different kinds of chemicals arranged in a line. Each of the chemicals has an affection value, The *i*-th of them has affection value *a**i*. Molly wants Sherlock to fall in love with her. She intends to do this by mixing a contiguous segment of chemicals together to make a love potion with total ...
{"inputs": ["4 2\n2 2 2 2", "4 -3\n3 -6 -3 12", "14 -9\n-2 -4 62 53 90 41 35 21 85 74 85 57 10 39", "20 9\n90 21 -6 -61 14 -21 -17 -65 -84 -75 -48 56 67 -50 16 65 -79 -61 92 85", "89 -7\n5972 4011 3914 670 3727 2913 6935 6927 2118 6645 7141 3585 9811 2859 459 8870 6578 8667 468 5152 3241 7455 7323 8817 4866 1040 5102 9...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
6
codeforces
Okay, let's see. I need to find the number of contiguous subarrays where the sum is a non-negative integer power of k. Hmm. So the problem is about checking all possible contiguous segments and counting those whose sum equals k^m for some m ≥0. But n is up to 1e5, so a naive O(n²) approach is definitely not going to wo...
To solve this problem, we need to determine the number of contiguous subarrays whose sum is a non-negative integer power of a given integer \( k \). The solution involves efficiently generating possible target values and using prefix sums to count valid subarrays. ### Approach 1. **Generate Target Values**: First, gen...
true
6b5a6f7fd3372a62826ecad686da6fb9
Cinema Cashier
All cinema halls in Berland are rectangles with *K* rows of *K* seats each, and *K* is an odd number. Rows and seats are numbered from 1 to *K*. For safety reasons people, who come to the box office to buy tickets, are not allowed to choose seats themselves. Formerly the choice was made by a cashier, but now this is th...
{"inputs": ["2 1\n1 1", "4 3\n1 2 3 1", "1 3\n1", "2 3\n3 3", "3 3\n3 2 3", "1 5\n5", "2 5\n3 4", "3 5\n2 5 2", "4 5\n5 5 3 5", "5 5\n4 1 3 1 1", "10 11\n3 11 6 4 4 11 9 2 1 9", "10 13\n12 8 7 11 11 9 2 12 10 1", "10 15\n15 6 1 9 3 10 11 1 14 10", "10 17\n5 8 13 5 11 12 10 17 16 7", "10 19\n8 19 17 12 4 5 9 16 7 3", "5...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
5
codeforces
Okay, let's tackle this programming problem. Hmm. So, the task is to simulate the seating program for a cinema hall. The cinema hall has K rows, each with K seats. K is an odd number, which means there's a definite center row and seat. The requests are for M consecutive seats in a single row, and we need to find the be...
To solve this problem, we need to simulate the seat allocation process in a cinema hall based on specific criteria. The cinema hall is a square with K rows and K seats per row, where K is an odd number. Each request asks for M consecutive seats in a row, and the goal is to find the optimal seats based on their proximit...
false
Code is incorrect.
6b5c9fda8d18efd41bd1e2f20140d0ed
Mind the Gap
These days Arkady works as an air traffic controller at a large airport. He controls a runway which is usually used for landings only. Thus, he has a schedule of planes that are landing in the nearest future, each landing lasts $1$ minute. He was asked to insert one takeoff in the schedule. The takeoff takes $1$ minut...
{"inputs": ["6 60\n0 0\n1 20\n3 21\n5 0\n19 30\n23 40", "16 50\n0 30\n1 20\n3 0\n4 30\n6 10\n7 50\n9 30\n11 10\n12 50\n14 30\n16 10\n17 50\n19 30\n21 10\n22 50\n23 59", "3 17\n0 30\n1 0\n12 0", "24 60\n0 21\n2 21\n2 46\n3 17\n4 15\n5 43\n6 41\n7 50\n8 21\n9 8\n10 31\n10 45\n12 30\n14 8\n14 29\n14 32\n14 52\n15 16\n16 7...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
85
codeforces
Okay, let's see. I need to find the earliest possible time to insert a takeoff such that it's at least s minutes away from all landings. The takeoff itself takes 1 minute. So the takeoff time has to be such that there's a gap of s minutes before and after. Wait, no. Wait, the problem says "for safety reasons there shou...
To solve this problem, we need to determine the earliest possible time to schedule a takeoff such that it maintains a safety gap of at least `s` minutes from all landings. The takeoff itself lasts 1 minute, and the given landings are in increasing order of their times. ### Approach 1. **Convert Landing Times to Minute...
true
6b803dbd74756c7a0ce25de8e96ff2e5
A Compatible Pair
Nian is a monster which lives deep in the oceans. Once a year, it shows up on the land, devouring livestock and even people. In order to keep the monster away, people fill their villages with red colour, light, and cracking noise, all of which frighten the monster out of coming. Little Tommy has *n* lanterns and Big B...
{"inputs": ["2 2\n20 18\n2 14", "5 3\n-1 0 1 2 3\n-1 0 1", "10 2\n1 6 2 10 2 3 2 10 6 4\n5 7", "50 50\n1 6 2 10 2 3 2 10 6 4 5 0 3 1 7 3 2 4 4 2 1 5 0 6 10 1 8 0 10 9 0 4 10 5 5 7 4 9 9 5 5 2 6 7 9 4 3 7 2 0\n0 5 9 4 4 6 1 8 2 1 6 6 8 6 4 4 7 2 1 8 6 7 4 9 8 3 0 2 0 10 7 1 4 9 4 4 2 5 3 5 1 3 2 4 1 6 5 3 8 6", "5 7\n-1...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
92
codeforces
Okay, let's see. The problem is about Tommy and Banban choosing lanterns in a way where Tommy wants to minimize the maximum possible product, and Banban wants to maximize it. Hmm. So Tommy will hide one lantern from his collection, then Banban picks one from Tommy's remaining and one of his own to make the product as l...
To solve this problem, we need to determine the optimal strategy for Tommy to minimize the maximum possible product of lantern brightness values after Banban selects his lanterns. Tommy will hide one of his lanterns, and Banban will then select one lantern from Tommy's remaining lanterns and one of his own to maximize ...
false
Code is incorrect.
6b871f4add35d8a08ea4c61c04c0b5d4
Mishka and trip
Little Mishka is a great traveller and she visited many countries. After thinking about where to travel this time, she chose XXX — beautiful, but little-known northern country. Here are some interesting facts about XXX: 1. XXX consists of *n* cities, *k* of whose (just imagine!) are capital cities. 1. All of cities...
{"inputs": ["4 1\n2 3 1 2\n3", "5 2\n3 5 2 2 4\n1 4", "3 1\n1 1 1\n1", "3 3\n1 1 1\n1 2 3", "7 7\n6 9 2 7 4 8 7\n1 2 3 4 5 6 7", "5 5\n6 2 4 10 2\n1 2 3 4 5", "5 5\n6 7 8 8 8\n1 2 3 4 5", "9 4\n5 6 7 1 5 4 8 7 1\n1 5 7 9", "7 2\n1 6 8 3 3 5 5\n1 3", "9 4\n182 938 865 240 911 25 373 22 875\n3 6 7 8", "10 4\n7931 7116 49...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
5
codeforces
Okay, let's tackle this problem. So, the task is to calculate the sum of the products of the beauty values of all pairs of cities that are connected by roads. The roads are a bit complex because of the capital cities. Let's break it down step by step. First, let's understand the structure of the roads. The cities are ...
To solve this problem, we need to calculate the total sum of the products of beauty values for each pair of cities connected by roads in a country with a cyclic structure and additional roads connecting capital cities to all other cities. The solution involves efficiently considering both the cyclic roads and the roads...
false
Code is incorrect.
6ba63d2f5d8138cc02354cc2aa491aa6
Watermelon
One hot summer day Pete and his friend Billy decided to buy a watermelon. They chose the biggest and the ripest one, in their opinion. After that the watermelon was weighed, and the scales showed *w* kilos. They rushed home, dying of thirst, and decided to divide the berry, however they faced a hard problem. Pete and ...
{"inputs": ["8", "5", "4", "3", "2", "1", "7", "6", "10", "9", "53", "77", "32", "44", "98", "99", "90", "67", "100", "88"], "outputs": ["YES", "NO", "YES", "NO", "NO", "NO", "NO", "YES", "YES", "NO", "NO", "NO", "YES", "YES", "YES", "NO", "YES", "NO", "YES", "YES"]}
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
693
codeforces
Okay, let's see. The problem is about dividing a watermelon into two parts where each part is an even number of kilos. Both parts need to be even. Hmm. So the input is a weight w, and we need to determine if it's possible to split it into two even parts. Wait, but how do we split it? Because the sum of the two parts h...
To solve this problem, we need to determine if a watermelon of weight \( w \) kilos can be divided into two parts such that each part is a positive even number of kilos. ### Approach The key insight here is that for two parts to be even, their sum (which is \( w \)) must also be even. However, simply checking if \( w...
true
6bf60cd692f741caed0e551b1119e8ec
Devu, the Singer and Churu, the Joker
Devu is a renowned classical singer. He is invited to many big functions/festivals. Recently he was invited to "All World Classical Singing Festival". Other than Devu, comedian Churu was also invited. Devu has provided organizers a list of the songs and required time for singing them. He will sing *n* songs, *i**th* s...
{"inputs": ["3 30\n2 2 1", "3 20\n2 1 1", "50 10000\n5 4 10 9 9 6 7 7 7 3 3 7 7 4 7 4 10 10 1 7 10 3 1 4 5 7 2 10 10 10 2 3 4 7 6 1 8 4 7 3 8 8 4 10 1 1 9 2 6 1", "50 10000\n4 7 15 9 11 12 20 9 14 14 10 13 6 13 14 17 6 8 20 12 10 15 13 17 5 12 13 11 7 5 5 2 3 15 13 7 14 14 19 2 13 14 5 15 3 19 15 16 4 1", "100 9000\n5 ...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
471
codeforces
Okay, let's see. I need to solve this programming problem. Let me read the problem statement carefully. So, the problem is about scheduling Devu's songs and Churu's jokes such that the total time doesn't exceed d minutes. The main goal is to maximize the number of jokes Churu can tell, but only if Devu can sing all hi...
To solve this problem, we need to schedule Devu's songs and Churu's jokes such that the total event duration does not exceed a given limit, while maximizing the number of jokes Churu can tell. Devu requires a 10-minute rest after each song except the last one, and Churu's jokes each take exactly 5 minutes. ### Approac...
true
6c50edebb128b0ef825474bcdce42054
Find The Bone
Zane the wizard is going to perform a magic show shuffling the cups. There are *n* cups, numbered from 1 to *n*, placed along the *x*-axis on a table that has *m* holes on it. More precisely, cup *i* is on the table at the position *x*<==<=*i*. The problematic bone is initially at the position *x*<==<=1. Zane will co...
{"inputs": ["7 3 4\n3 4 6\n1 2\n2 5\n5 7\n7 1", "5 1 2\n2\n1 2\n2 4", "10000 1 9\n55\n44 1\n2929 9292\n9999 9998\n44 55\n49 94\n55 53\n100 199\n55 50\n53 11", "100000 3 7\n2 3 4\n1 5\n5 1\n1 5\n5 1\n1 4\n4 3\n3 2", "1000000 9 11\n38 59 999999 199 283 4849 1000000 2 554\n39 94\n3 9\n1 39\n39 40\n40 292\n5399 5858\n292 4...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
50
codeforces
Okay, let's see. I need to find the final position of the bone after a series of swaps, considering that if the bone is on a hole at any time, it stops moving. So the bone starts at position 1. For each swap, if the current bone's position is either u_i or v_i, then it moves to the other position. But if during any ste...
To solve this problem, we need to determine the final position of a bone after a series of swaps between cups placed along the x-axis, considering that the bone will fall into a hole if it ever lands on one. ### Approach 1. **Initial Setup**: The bone starts at position 1. We first check if this initial position is a ...
true
6c7887430d8f0c8d26269c0b9a7af34e
You're a Professional
A simple recommendation system would recommend a user things liked by a certain number of their friends. In this problem you will implement part of such a system. You are given user's friends' opinions about a list of items. You are also given a threshold *T* — the minimal number of "likes" necessary for an item to be...
{"inputs": ["3 3 2\nYYY\nNNN\nYNY", "4 4 1\nNNNY\nNNYN\nNYNN\nYNNN", "3 5 2\nNYNNY\nYNNNN\nNNYYN", "1 10 1\nYYYNYNNYNN", "10 1 5\nY\nN\nN\nN\nY\nN\nN\nY\nN\nN", "10 10 1\nNNNNNNNNNN\nNNNNNNNNNN\nNNNNNNNNNN\nNNNNNNNNNN\nNNNNNNNNNN\nNNNNNNNNNN\nNNNNNNNNNN\nNNNNNNNNNN\nNNNNNNNNNN\nNNNNNNNNNN", "10 10 10\nYYYYYYYYYY\nYYYYY...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
16
codeforces
Okay, let's see. I need to solve this programming problem. Let me read the problem statement carefully. The task is to determine the number of items that are liked by at least T friends. So, for each item, count how many friends liked it (i.e., have a 'Y' in that item's position), and if that count is >= T, include it...
To solve this problem, we need to determine the number of items that are liked by at least a specified number of friends. The solution involves counting the likes for each item across all friends and checking if the count meets or exceeds the given threshold. ### Approach 1. **Read Input**: First, we read the number o...
true
6c919e2b0df67554198028b21a7e301e
First Digit Law
In the probability theory the following paradox called Benford's law is known: "In many lists of random numbers taken from real sources, numbers starting with digit 1 occur much more often than numbers starting with any other digit" (that's the simplest form of the law). Having read about it on Codeforces, the Hedgeho...
{"inputs": ["1\n1 2\n50", "2\n1 2\n9 11\n50", "3\n2 9\n20 99\n5 5\n0", "3\n2 9\n20 99\n5 5\n100", "1\n1 1\n100", "4\n1 100\n11 19\n101 199\n15 15\n100", "10\n10 17\n10 12\n3 6\n17 18\n6 15\n9 18\n3 10\n10 15\n17 19\n2 13\n59", "10\n5 20\n13 16\n12 30\n7 16\n10 29\n21 21\n22 26\n14 22\n2 10\n1 29\n48", "15\n11 20\n16 18...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
4
codeforces
Okay, I need to solve this problem where I have to calculate the probability that at least K% of the N random variables have their first digit as 1. Let's break this down. First, I remember Benford's Law, but this problem is about exact probabilities given specific ranges for each variable. Each variable can take any ...
To solve this problem, we need to determine the probability that at least K% of given random variables, each uniformly distributed over a specified interval, start with the digit 1. This involves calculating probabilities for each interval, then using dynamic programming to combine these probabilities. ### Approach 1....
true
6ca98a9abcdc68bfd325eb090fa72aab
New Year Cards
As meticulous Gerald sets the table, Alexander finished another post on Codeforces and begins to respond to New Year greetings from friends. Alexander has *n* friends, and each of them sends to Alexander exactly one e-card. Let us number his friends by numbers from 1 to *n* in the order in which they send the cards. Le...
{"inputs": ["4\n1 2 3 4\n4 1 3 2\n4 3 1 2\n3 4 2 1\n3 1 2 4", "2\n1 2\n2 1\n2 1", "3\n1 2 3\n2 3 1\n1 3 2\n3 2 1", "5\n1 4 2 3 5\n5 1 3 4 2\n3 2 4 1 5\n1 4 5 3 2\n5 2 3 4 1\n5 4 2 1 3", "10\n5 1 6 2 8 3 4 10 9 7\n3 1 10 6 8 5 2 7 9 4\n2 9 1 4 10 6 8 7 3 5\n10 1 7 8 3 2 4 6 5 9\n3 2 10 4 7 8 5 6 1 9\n5 6 3 10 8 7 2 9 4 ...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
6
codeforces
Okay, let's see. So the problem is about Alexander sending cards to his friends based on certain rules. We need to determine the order in which Alexander sends the cards so that each friend gets the best possible card according to their preferences, given the two rules he follows. Hmm. Let me read the problem again ca...
To solve this problem, we need to determine the optimal times for Alexander to send cards to his friends such that each friend receives the best possible card according to their preferences, while adhering to Alexander's rules. Alexander must send each friend a card that they did not send him and choose the card he pre...
false
Code is incorrect.
6cb4576303d3b40dbf510002d41cd3b1
Andrey and Problem
Andrey needs one more problem to conduct a programming contest. He has *n* friends who are always willing to help. He can ask some of them to come up with a contest problem. Andrey knows one value for each of his fiends — the probability that this friend will come up with a problem if Andrey asks him. Help Andrey choo...
{"inputs": ["4\n0.1 0.2 0.3 0.8", "2\n0.1 0.2", "1\n0.217266", "2\n0.608183 0.375030", "3\n0.388818 0.399762 0.393874", "4\n0.801024 0.610878 0.808545 0.732504", "5\n0.239482 0.686259 0.543226 0.764939 0.401318", "6\n0.462434 0.775020 0.479749 0.373861 0.492031 0.746333", "7\n0.745337 0.892271 0.792853 0.892917 0.76824...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
28
codeforces
Okay, so I need to solve this problem where Andrey wants to choose a subset of his friends such that the probability of exactly one of them coming up with a problem is maximized. The goal is to compute that maximum probability. Let's think about how to approach this. First, let's understand the problem. For each possi...
To solve this problem, we need to determine the optimal subset of Andrey's friends such that the probability of exactly one friend successfully creating a problem is maximized. The key challenge is to efficiently compute this probability without checking all possible subsets, which is computationally infeasible for lar...
false
Code is incorrect.
6cefe83344a570d72979ed5ace1b0015
Alyona and copybooks
Little girl Alyona is in a shop to buy some copybooks for school. She study four subjects so she wants to have equal number of copybooks for each of the subjects. There are three types of copybook's packs in the shop: it is possible to buy one copybook for *a* rubles, a pack of two copybooks for *b* rubles, and a pack ...
{"inputs": ["1 1 3 4", "6 2 1 1", "4 4 4 4", "999999999 1000000000 1000000000 1000000000", "1016 3 2 1", "17 100 100 1", "17 2 3 100", "18 1 3 3", "19 1 1 1", "999999997 999999990 1000000000 1000000000", "999999998 1000000000 999999990 1000000000", "634074578 336470888 481199252 167959139", "999999999 1000000000 100000...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
142
codeforces
Okay, let's try to solve this problem. So, Alyona needs to buy some copybooks such that the total (n plus the ones she buys) is divisible by 4. We need to find the minimal cost for that. The available packs are 1, 2, or 3 copybooks, each with their own prices a, b, c. Hmm. First, let's understand what's required. The ...
To solve this problem, we need to determine the minimum cost for Alyona to buy additional copybooks such that the total number of copybooks she has becomes divisible by 4. Alyona can purchase copybooks in packs of 1, 2, or 3, each with different costs. The goal is to find the optimal combination of these packs to minim...
true
6cf2d7404c1710c85dd4176b03c54664
Summer Camp
Every year, hundreds of people come to summer camps, they learn new algorithms and solve hard problems. This is your first year at summer camp, and you are asked to solve the following problem. All integers starting with 1 are written in one line. The prefix of these line is "123456789101112131415...". Your task is to...
{"inputs": ["3", "11", "12", "13", "29", "30", "1000", "999", "100", "123", "8", "157", "289", "179", "942", "879", "394", "423", "952", "121", "613", "945", "270", "781", "453", "171", "643", "570", "750", "500", "2", "1", "108", "500", "189", "491", "191"], "outputs": ["3", "0", "1", "1", "9", "2", "3", "9", "5", "6"...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
368
codeforces
Okay, let's see. The problem is to find the n-th digit in this sequence where all integers starting from 1 are written in a row. Like the example says, the string starts as "123456789101112131415..." and so on. So for n=3, it's 3, for n=11 it's 0, which is part of the 10's digits. Hmm. So the approach here is to figur...
To solve this problem, we need to determine the n-th digit in an infinite sequence formed by concatenating all positive integers starting from 1. The sequence looks like "123456789101112131415...". The challenge is to efficiently find the n-th digit without generating the entire sequence up to that point. ### Approach...
true
6d2e99edaf65af436e74bf409494fe5b
Very Beautiful Number
Teacher thinks that we make a lot of progress. Now we are even allowed to use decimal notation instead of counting sticks. After the test the teacher promised to show us a "very beautiful number". But the problem is, he's left his paper with the number in the teachers' office. The teacher remembers that the "very beau...
{"inputs": ["6 5", "1 2", "6 4", "11 1", "42 5", "36 5", "56 3", "88 9", "81 7", "100 1", "58 6", "3282 5", "24002 7", "8140 7", "23910 4", "11478 4", "12818 8", "999999 8", "100002 4", "337 6", "11389 6", "1000000 3", "1000000 1", "2 7", "1 1"], "outputs": ["142857", "Impossible", "102564", "11111111111", "10204081632...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
7
codeforces
Okay, let's try to solve this problem. So the task is to find the minimal number that satisfies certain conditions. Let's break down the problem. The number must have exactly p digits, no leading zeros. When we move the last digit to the front, the new number is exactly x times the original. And we need the smallest s...
To solve this problem, we need to find the smallest positive integer with exactly `p` digits that does not contain leading zeros and satisfies the condition where moving the last digit to the front results in a number that is `x` times the original number. If no such number exists, we should return "Impossible". ### A...
false
Code is incorrect.
6d5221a978b652defdeae7f5e3469cac
Levko and Permutation
Levko loves permutations very much. A permutation of length *n* is a sequence of distinct positive integers, each is at most *n*. Let’s assume that value *gcd*(*a*,<=*b*) shows the greatest common divisor of numbers *a* and *b*. Levko assumes that element *p**i* of permutation *p*1,<=*p*2,<=... ,<=*p**n* is good if *g...
{"inputs": ["4 2", "1 1", "7 4", "10 9", "10000 5000", "7 0", "1 0", "7 7", "100000 47", "100000 100000", "100000 43425", "7 6", "100000 99999", "47 46", "5 0", "4 2", "1533 1052", "81314 52747", "17767 145", "18168 7942", "26593 15915", "26593 8877", "13852 12727", "4 1", "8834 8834", "8485 8484", "14564 14564", "8254...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
108
codeforces
Okay, I need to solve this problem where I have to find a permutation of numbers from 1 to n such that exactly k elements are 'good'. A good element is one where the gcd of its position (i) and the value (p_i) is greater than 1. If it's not possible, I should return -1. Let me start by understanding the problem. So, g...
To solve this problem, we need to construct a permutation of numbers from 1 to n such that exactly k elements are 'good'. An element is considered good if the greatest common divisor (gcd) of its position (i) and its value (p_i) is greater than 1. If it's impossible to create such a permutation, we should return -1. #...
false
Code is incorrect.
6d5b1c026ba6c1af6fba85c8d6e409bb
Purification
You are an adventurer currently journeying inside an evil temple. After defeating a couple of weak zombies, you arrived at a square room consisting of tiles forming an *n*<=×<=*n* grid. The rows are numbered 1 through *n* from top to bottom, and the columns are numbered 1 through *n* from left to right. At the far side...
{"inputs": ["3\n.E.\nE.E\n.E.", "3\nEEE\nE..\nE.E", "5\nEE.EE\nE.EE.\nE...E\n.EE.E\nEE.EE", "3\n.EE\n.EE\n.EE", "5\nEE.EE\nEE..E\nEEE..\nEE..E\nEE.EE", "1\nE", "8\nE.EEE..E\nEEE.E.E.\nEEE.E.E.\nEE.E.E..\nE...EE..\nE.EE....\n..EE....\nE..E.EE.", "17\nEE...E.EE.EE..E..\nE.....EE..E..E..E\nEEEE.EEEE..E..E.E\n.E.E.EEE.EEEE...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
21
codeforces
Okay, let's tackle this problem. So, the goal is to find the minimum number of spells needed to purify all cells in an n x n grid. Some cells are particularly evil (marked 'E'), and we can't cast the spell on them. But they can be purified by other cells in their row or column. Hmm. First, let's understand the problem...
To solve this problem, we need to purify all cells in an n×n grid using the minimum number of "Purification" spells. The challenge is to avoid casting spells on cells marked 'E' (particularly evil), while ensuring every cell is purified either by a spell in its row or column. ### Approach 1. **Identify Bad Rows and Co...
true
6dadd620920edfb1edbee1553bb820ee
Dasha and Password
After overcoming the stairs Dasha came to classes. She needed to write a password to begin her classes. The password is a string of length *n* which satisfies the following requirements: - There is at least one digit in the string, - There is at least one lowercase (small) letter of the Latin alphabet in the string,...
{"inputs": ["3 4\n1**2\na3*0\nc4**", "5 5\n#*&#*\n*a1c&\n&q2w*\n#a3c#\n*&#*&", "5 2\n&l\n*0\n*9\n*#\n#o", "25 16\nvza**ooxkmd#*ywa\ndip#*#&ef&z&&&pv\nwggob&&72#*&&nku\nrsb##*&jm&#u**te\nzif#lu#t&2w#jbqb\nwfo&#&***0xp#&hp\njbw##h*###nkmkdn\nqrn*&y#3cnf&d*rc\nend*zg&0f*&g*&ak\niayh&r#8om#o**yq\nwym&e&*v0j&#zono\ntzu*vj&i...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
43
codeforces
Okay, let's see. I need to solve this programming problem. Let me read the problem carefully. So the problem is about Dasha trying to set a password by moving pointers on different strings. The password has to meet three criteria: at least one digit, one lowercase letter, and one of the symbols #, *, or &. Each charac...
To solve this problem, we need to determine the minimum number of operations required to form a valid password from given strings. The password must contain at least one digit, one lowercase letter, and one special character from the set {#, *, &}. Each character of the password is derived from a cyclic string, and we ...
true
6dd4ecd12771553ae125882e94ff943c
Significant Cups
Stepan is a very experienced olympiad participant. He has *n* cups for Physics olympiads and *m* cups for Informatics olympiads. Each cup is characterized by two parameters — its significance *c**i* and width *w**i*. Stepan decided to expose some of his cups on a shelf with width *d* in such a way, that: - there is ...
{"inputs": ["3 1 8\n4 2\n5 5\n4 2\n3 2", "4 3 12\n3 4\n2 4\n3 5\n3 4\n3 5\n5 2\n3 4", "2 2 2\n5 3\n6 3\n4 2\n8 1", "10 10 229\n15 17\n5 4\n4 15\n4 17\n15 11\n7 6\n5 19\n14 8\n4 1\n10 12\n20 13\n20 14\n16 13\n7 15\n2 16\n11 11\n19 20\n6 7\n4 11\n14 16", "10 20 498\n40 12\n23 25\n20 9\n8 1\n23 8\n31 24\n33 2\n22 33\n4 13...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
2
codeforces
Okay, let's try to understand this problem. So Stepan has two types of cups: Physics and Informatics. He wants to put some of them on a shelf with width d. The conditions are a bit tricky. Let's break them down. First, he must have at least one cup from each subject. Then, the total width can't exceed d. Also, for eac...
To solve this problem, we need to determine the maximum possible total significance of cups Stepan can place on a shelf, adhering to specific constraints. The solution involves efficiently selecting cups from both Physics and Informatics subjects such that their combined width does not exceed the shelf's width while en...
true
6df7a596947d9d0d3c1607821180ca35
Beautiful Paintings
There are *n* pictures delivered for the new exhibition. The *i*-th painting has beauty *a**i*. We know that a visitor becomes happy every time he passes from a painting to a more beautiful one. We are allowed to arranged pictures in any order. What is the maximum possible number of times the visitor may become happy ...
{"inputs": ["5\n20 30 10 50 40", "4\n200 100 100 200", "10\n2 2 2 2 2 2 2 2 2 2", "1\n1000", "2\n444 333", "100\n9 9 72 55 14 8 55 58 35 67 3 18 73 92 41 49 15 60 18 66 9 26 97 47 43 88 71 97 19 34 48 96 79 53 8 24 69 49 12 23 77 12 21 88 66 9 29 13 61 69 54 77 41 13 4 68 37 74 7 6 29 76 55 72 89 4 78 27 29 82 18 83 12...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
97
codeforces
Okay, so I need to find the maximum number of times a visitor becomes happy when moving through the paintings in order. The visitor becomes happy each time the next painting is more beautiful than the current one. So, the problem is to arrange the paintings in such a way that as many consecutive pairs as possible have ...
To solve this problem, we need to determine the maximum number of times a visitor becomes happy when passing through a sequence of paintings arranged in the most optimal order. A visitor becomes happy each time they move from a less beautiful painting to a more beautiful one. ### Approach The key insight is that the m...
true
6dfc961b9b9cd5602504e14fc0fb01c4
Finding Team Member
There is a programing contest named SnakeUp, 2*n* people want to compete for it. In order to attend this contest, people need to form teams of exactly two people. You are given the strength of each possible combination of two people. All the values of the strengths are distinct. Every contestant hopes that he can find...
{"inputs": ["2\n6\n1 2\n3 4 5", "3\n487060\n3831 161856\n845957 794650 976977\n83847 50566 691206 498447\n698377 156232 59015 382455 626960", "3\n8\n1 6\n14 13 15\n4 2 11 9\n12 5 3 7 10", "1\n1000000", "3\n1000000\n999999 999998\n999997 999996 999995\n999994 999993 999992 999991\n999990 999989 999988 999987 999986"], "...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
7
codeforces
Okay, I need to solve this programming problem. Let me read the question carefully. So, the problem is about forming teams of two people such that each pair (A, B) are each other's best possible remaining partners. The key here is understanding the pairing condition. Let's break it down. The input gives the strengt...
To solve this problem, we need to form teams of exactly two people such that each person's team has the highest possible strength. The key challenge is ensuring that each pair of teammates are each other's best possible partners, given the remaining unpaired contestants at each step. ### Approach 1. **Input Parsing**:...
false
Code is incorrect.
6dfcac919c08dffa6e6836e1c3a3b8ed
Sequence Formatting
Polycarp is very careful. He even types numeric sequences carefully, unlike his classmates. If he sees a sequence without a space after the comma, with two spaces in a row, or when something else does not look neat, he rushes to correct it. For example, number sequence written like "1,2 ,3,...,   10" will be corrected ...
{"inputs": ["1,2 ,3,..., 10", "1,,,4...5......6", ",,,,,,,,,,,,,", "123456789", ",", "1 4 5 6 7 999 1 1 1 2 311111111111111111111111111111111111111111", "1,2,,,,,,,,,5566", "...,", ",,", ",...,", "1...10", ", ,", "1235634615111235634615111235634615111235634615111235634615111235634...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
14
codeforces
Okay, let's tackle this problem. So, the task is to process a string according to specific rules that Polycarp uses to clean up the formatting. Hmm, the problem statement is a bit involved, so I need to parse all the requirements carefully. First, let me restate the requirements to make sure I understand them correctl...
To solve this problem, we need to format a given string according to specific rules. The string is composed of terms such as positive integers, commas, spaces, and three dots ("..."). The goal is to ensure proper spacing around commas and three dots, and reduce multiple spaces between numbers to a single space. ### Ap...
false
Code is incorrect.
6e0b77cb8cb7c6adcab680be206a2647
Points and Powers of Two
There are $n$ distinct points on a coordinate line, the coordinate of $i$-th point equals to $x_i$. Choose a subset of the given set of points such that the distance between each pair of points in a subset is an integral power of two. It is necessary to consider each pair of points, not only adjacent. Note that any sub...
{"inputs": ["6\n3 5 4 7 10 12", "5\n-1 2 5 8 11", "1\n42", "3\n0 -536870912 536870912", "2\n536870912 -536870912", "3\n1 2 3", "4\n1 2 3 8", "2\n1 2", "3\n0 1 2", "2\n-3 -2", "2\n-4 -2", "2\n2 1", "1\n1", "3\n0 2 6", "3\n2 4 8", "2\n1 0", "3\n5 6 7", "3\n-1 1 0"], "outputs": ["3\n3 4 5 ", "1\n-1 ", "1\n42 ", "3\n-53687...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
33
codeforces
Okay, I need to solve this problem where I have to find the maximum subset of points such that every pair of points in the subset is a distance that's a power of two. Hmm. Let's think about how to approach this. First, let's understand the problem. The subset needs to have the property that any two points in it are se...
To solve this problem, we need to find the largest subset of points such that the distance between each pair of points in the subset is an integral power of two. The solution involves checking for possible subsets of size 3 first, then subsets of size 2, and finally subsets of size 1 if no larger subsets are found. ##...
true
6e0bc12d128f12665442cb838644357e
Giga Tower
Giga Tower is the tallest and deepest building in Cyberland. There are 17<=777<=777<=777 floors, numbered from <=-<=8<=888<=888<=888 to 8<=888<=888<=888. In particular, there is floor 0 between floor <=-<=1 and floor 1. Every day, thousands of tourists come to this place to enjoy the wonderful view. In Cyberland, it ...
{"inputs": ["179", "-1", "18", "-410058385", "-586825624", "852318890", "919067153", "690422411", "-408490162", "-8", "-6", "-4", "-2", "0", "2", "4", "6", "8", "1000000000", "-1000000000", "88888", "89", "-80000000", "-8888", "-17", "78", "-19", "-999999998", "-999999997", "999999997", "811111111", "-8", "-5", "-7", "...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
325
codeforces
Okay, I need to solve this programming problem. Let me read the problem carefully again. The problem is about finding the minimum positive integer b such that when Henry moves up b floors from his current floor a, the resulting floor number contains at least one '8' in its decimal digits. The input is a single integer...
To solve this problem, we need to determine the minimum positive integer \( b \) such that moving \( b \) floors up from a given starting floor \( a \) results in a floor number that contains the digit '8'. The solution involves checking each subsequent floor number starting from \( a + 1 \) until we find one that incl...
true
6e0dc02ba7291c453c2ec9afee5215ce
Petya and Exam
It's hard times now. Today Petya needs to score 100 points on Informatics exam. The tasks seem easy to Petya, but he thinks he lacks time to finish them all, so he asks you to help with one.. There is a glob pattern in the statements (a string consisting of lowercase English letters, characters "?" and "*"). It is kno...
{"inputs": ["ab\na?a\n2\naaa\naab", "abc\na?a?a*\n4\nabacaba\nabaca\napapa\naaaaax", "s\nc*?cb\n26\nbbaa\nb\ncc\ncbaab\nacacc\nca\na\nc\ncb\nabb\nba\nb\nba\ncac\nccccb\nccb\nbbbc\nabbcb\na\nbc\nc\na\nabb\nca\ncacb\nac", "o\n*\n28\nbac\nbcc\ncbcb\ncaabc\ncb\nacab\ncbccb\ncbccc\nc\nbbaa\ncaaaa\nbbc\nba\nc\ncacbc\ncbab\na...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
8
codeforces
Okay, I need to solve this programming problem. Let's read the problem statement carefully. So the task is to determine for each query string whether it matches a given glob pattern. The pattern can include '?', which can be replaced by a good lowercase letter, and '*', which can appear at most once. The '*' can be re...
To solve this problem, we need to determine if each query string matches a given glob pattern, considering specific rules for wildcard characters. The pattern can include '?' which matches any good letter, and '*' which matches any sequence of bad letters (including an empty sequence). The good letters are provided as ...
true
6e5afbd84d28e58ac91f81bf4f65bc6c
Hexadecimal's Numbers
One beautiful July morning a terrible thing happened in Mainframe: a mean virus Megabyte somehow got access to the memory of his not less mean sister Hexadecimal. He loaded there a huge amount of *n* different natural numbers from 1 to *n* to obtain total control over her energy. But his plan failed. The reason for th...
{"inputs": ["10", "20", "72", "99", "100", "101", "102", "111", "112", "745", "23536", "1", "1010011", "312410141", "1000000000", "999999999", "111111111", "101010101", "121212121", "106341103", "901556123", "832513432", "3", "732875234", "7", "9", "2", "11", "12", "13", "101020101", "111100100", "110110101", "10011100...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
156
codeforces
Okay, let's see. The problem is to find out how many numbers from 1 to n (inclusive) are made up of only 0s and 1s in their decimal representation. So, for example, numbers like 1, 10, 11, 100, etc. But numbers like 2 or 12 would be excluded because they have digits other than 0 and 1. The sample input is 10, and the ...
To solve this problem, we need to determine how many numbers from 1 to a given number \( n \) (inclusive) are composed only of the digits 0 and 1 in their decimal representation. ### Approach The approach involves generating all valid numbers composed of the digits 0 and 1, starting from 1, and checking if they are le...
true
6e8114ca264a25df7a13855f7cf6b174
Palindrome
Given a string *s*, determine if it contains any palindrome of length exactly 100 as a subsequence. If it has any, print any one of them. If it doesn't have any, print a palindrome that is a subsequence of *s* and is as long as possible. The only line of the input contains one string *s* of length *n* (1<=≤<=*n*<=≤<=5·...
{"inputs": ["bbbabcbbb", "rquwmzexectvnbanemsmdufrg", "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "ab", "abacaba", "star...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
1
codeforces
Okay, I need to solve this problem where I have to check if a given string has a palindrome subsequence of exactly length 100. If not, find the longest possible palindrome subsequence. Hmm, let's think through this step by step. First, understanding the problem: a subsequence doesn't need to be contiguous. So for a pa...
To solve this problem, we need to determine if a given string contains a palindrome of length exactly 100 as a subsequence. If it does, we should print any one of them. If not, we should print the longest possible palindrome subsequence. ### Approach 1. **Check for Frequent Character**: First, check if any character a...
false
Code is incorrect.
6e860da383f076b1aad581c40df6343a
Rooter's Song
Wherever the destination is, whoever we meet, let's render this song together. On a Cartesian coordinate plane lies a rectangular stage of size *w*<=×<=*h*, represented by a rectangle with corners (0,<=0), (*w*,<=0), (*w*,<=*h*) and (0,<=*h*). It can be seen that no collisions will happen before one enters the stage. ...
{"inputs": ["8 10 8\n1 1 10\n1 4 13\n1 7 1\n1 8 2\n2 2 0\n2 5 14\n2 6 0\n2 6 1", "3 2 3\n1 1 2\n2 1 1\n1 1 5", "1 10 10\n1 8 1", "3 4 5\n1 3 9\n2 1 9\n1 2 8", "10 500 500\n2 88 59\n2 470 441\n1 340 500\n2 326 297\n1 74 45\n1 302 273\n1 132 103\n2 388 359\n1 97 68\n2 494 465", "20 50000 50000\n2 45955 55488\n1 19804 293...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
8
codeforces
Okay, let's tackle this programming problem. Hmm, the problem seems a bit complex, but I'll try to break it down step by step. So, the task is to find the stopping position for each dancer after they move, considering collisions that might happen when they meet. First, let me understand the setup. We have a rectangul...
To solve this problem, we need to determine the stopping positions of dancers on a Cartesian plane after considering their movements and collisions. The dancers move in specific directions after a waiting period, and upon collision, they swap directions. The goal is to efficiently compute the final positions of all dan...
false
Code is incorrect.
6e98357b8c0bdb3110306bd85830da4a
Convert to Ones
You've got a string $a_1, a_2, \dots, a_n$, consisting of zeros and ones. Let's call a sequence of consecutive elements $a_i, a_{i<=+<=1}, \ldots,<=a_j$ ($1\leq<=i\leq<=j\leq<=n$) a substring of string $a$. You can apply the following operations any number of times: - Choose some substring of string $a$ (for examp...
{"inputs": ["5 1 10\n01000", "5 10 1\n01000", "7 2 3\n1111111", "1 60754033 959739508\n0", "1 431963980 493041212\n1", "1 314253869 261764879\n0", "1 491511050 399084767\n1", "2 163093925 214567542\n00", "2 340351106 646854722\n10", "2 222640995 489207317\n01", "2 399898176 552898277\n11", "2 690218164 577155357\n00", ...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
118
codeforces
Okay, let's see. The problem is about finding the minimum cost to turn a binary string into all ones using reverse and flip operations. Hmm. Wait, the reverse operation's cost is x, and flipping a substring's cost is y. But how do these operations help us? Wait, the reverse operation itself doesn't change the bits, ri...
To solve this problem, we need to determine the minimum cost to convert a binary string consisting of zeros and ones into a string of all ones using two operations: reversing a substring and flipping all elements in a substring. The goal is to minimize the total cost of these operations. ### Approach 1. **Identify Zer...
true
6e9dcbd071b375bcf1238a31296b6008
Bear and Big Brother
Bear Limak wants to become the largest of bears, or at least to become larger than his brother Bob. Right now, Limak and Bob weigh *a* and *b* respectively. It's guaranteed that Limak's weight is smaller than or equal to his brother's weight. Limak eats a lot and his weight is tripled after every year, while Bob's we...
{"inputs": ["4 7", "4 9", "1 1", "4 6", "1 10", "1 1", "1 2", "1 3", "1 4", "1 5", "1 6", "1 7", "1 8", "1 9", "1 10", "2 2", "2 3", "2 4", "2 5", "2 6", "2 7", "2 8", "2 9", "2 10", "3 3", "3 4", "3 5", "3 6", "3 7", "3 8", "3 9", "3 10", "4 4", "4 5", "4 6", "4 7", "4 8", "4 9", "4 10", "5 5", "5 6", "5 7", "5 8", "5...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
631
codeforces
Okay, let's see. The problem is about determining how many full years it will take for Limak's weight to exceed Bob's. Right now, Limak's weight is a, and Bob's is b. And we know a <= b. Each year, Limak's weight triples, while Bob's doubles. We need to find the minimum number of years where after that, Limak is strict...
To solve this problem, we need to determine the number of full years it will take for Limak's weight to exceed Bob's weight given that Limak's weight triples each year and Bob's weight doubles each year. ### Approach 1. **Initialization**: Read the initial weights of Limak and Bob. 2. **Iteration**: Use a loop to repe...
true
6ec23bfaec147ed3968f9eb421419a85
Sorting Railway Cars
An infinitely long railway has a train consisting of *n* cars, numbered from 1 to *n* (the numbers of all the cars are distinct) and positioned in arbitrary order. David Blaine wants to sort the railway cars in the order of increasing numbers. In one move he can make one of the cars disappear from its place and telepor...
{"inputs": ["5\n4 1 2 5 3", "4\n4 1 3 2", "1\n1", "2\n1 2", "2\n2 1", "6\n5 3 6 1 4 2", "7\n1 2 3 6 7 4 5", "8\n6 2 1 8 5 7 3 4", "3\n1 2 3", "3\n1 3 2", "3\n2 1 3", "3\n2 3 1", "3\n3 1 2", "3\n3 2 1", "7\n1 3 5 7 2 4 6", "7\n1 5 2 6 3 7 4", "5\n1 4 2 3 5", "9\n1 6 4 5 9 8 7 3 2", "10\n5 1 6 2 8 3 4 10 9 7", "50\n39 8 ...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
82
codeforces
Okay, I need to solve this problem where David Blaine wants to sort the train cars with the minimum number of moves. Each move allows him to take a car and put it at the beginning or end. The goal is to find the minimal number of such moves required. Hmm, let's think. The problem is similar to finding a sequence of ca...
To solve this problem, we need to determine the minimum number of moves required to sort a train's cars in increasing order. Each move allows moving a car to either the beginning or the end of the train. The key insight is to find the longest subsequence of consecutive numbers that are already in the correct order, as ...
true
6eec6d76e2ac4d80c0ce716c2185a9b9
Lizards and Basements 2
This is simplified version of the problem used on the original contest. The original problem seems to have too difiicult solution. The constraints for input data have been reduced. Polycarp likes to play computer role-playing game «Lizards and Basements». At the moment he is playing it as a magician. At one of the las...
{"inputs": ["3 2 1\n2 2 2", "4 3 1\n1 4 1 1", "3 5 3\n1 2 1", "3 5 3\n3 2 2", "3 5 3\n3 2 2", "3 5 1\n10 10 10", "3 5 3\n10 9 7", "3 5 1\n1 9 10", "3 5 3\n10 9 7", "3 5 2\n9 3 6", "4 5 3\n2 2 2 1", "4 5 3\n2 3 2 2", "4 5 3\n4 2 4 2", "4 5 1\n4 9 1 8", "4 5 3\n9 9 3 4", "4 5 1\n8 8 9 8", "4 5 3\n10 10 10 10", "4 5 2\n7 ...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
5
codeforces
Okay, let's tackle this problem. Hmm, the goal is to find the minimum number of fireballs needed to kill all the archers. Each fireball hits a central archer (i), deals a damage of 'a' to it, and 'b' to adjacent ones. The first and last archers can't be targeted. So, the indexes we can use are from 2 to n-1. The sampl...
To solve this problem, we need to determine the minimum number of fireballs required to kill all archers in a line, where each fireball can hit an archer and adjacent archers with specific damage values. The goal is to minimize the number of fireballs while ensuring all archers' health is reduced to below zero. ### Ap...
true
6ef0e2137716f500bd93702edd34f22b
Propagating tree
Iahub likes trees very much. Recently he discovered an interesting tree named propagating tree. The tree consists of *n* nodes numbered from 1 to *n*, each node *i* having an initial value *a**i*. The root of the tree is node 1. This tree has a special property: when a value *val* is added to a value of node *i*, the ...
{"inputs": ["5 5\n1 2 1 1 2\n1 2\n1 3\n2 4\n2 5\n1 2 3\n1 1 2\n2 1\n2 2\n2 4", "10 10\n137 197 856 768 825 894 86 174 218 326\n7 8\n4 7\n8 9\n7 10\n1 2\n2 4\n3 6\n3 5\n2 3\n1 9 624\n2 1\n2 4\n1 6 505\n1 8 467\n1 3 643\n2 1\n1 8 631\n2 4\n1 7 244", "10 10\n418 45 865 869 745 901 177 773 854 462\n4 8\n1 4\n3 6\n1 5\n1 10...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
1
codeforces
Okay, let's see. The problem is about a propagating tree where adding a value to a node affects its children in a specific way. Hmm. So when you add 'val' to node x, all its children get -val added, then their children get val, and so on. It's like alternating signs with each level. The challenge is to handle multiple...
To solve this problem, we need to efficiently handle two types of queries on a tree with a special propagation property. The key challenge is to manage updates that affect all nodes in a subtree with alternating signs based on their depth relative to the updated node. We can achieve this using an Euler Tour technique c...
true
6f1948aa1a3f58e6b1b4feacc7b7e014
Tower of Hanoi
The Tower of Hanoi is a well-known mathematical puzzle. It consists of three rods, and a number of disks of different sizes which can slide onto any rod. The puzzle starts with the disks in a neat stack in ascending order of size on one rod, the smallest at the top, thus making a conical shape. The objective of the pu...
{"inputs": ["0 1 1\n1 0 1\n1 1 0\n3", "0 2 2\n1 0 100\n1 2 0\n3", "0 2 1\n1 0 100\n1 2 0\n5", "0 5835 1487\n6637 0 9543\n6961 6820 0\n7", "0 3287 5433\n6796 0 5787\n1445 6158 0\n26", "0 4449 3122\n6816 0 8986\n1048 1468 0\n4", "0 913 8129\n8352 0 4408\n9073 7625 0\n30", "0 8392 3430\n5262 0 6256\n8590 8091 0\n29", "0 6...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
2
codeforces
Okay, I need to solve this problem where the goal is to find the minimal cost to move all disks from rod 1 to rod 3, considering different costs for moving between rods. The standard Tower of Hanoi has a known minimal move count, but here each move has a cost, so the minimal cost might not follow the same path as the m...
To solve this problem, we need to determine the minimal cost to solve a variation of the Tower of Hanoi puzzle where each move between rods has a specific cost. The goal is to move all disks from the first rod to the third rod with the minimum total cost. ### Approach The problem can be approached using dynamic progra...
false
Code is incorrect.
6f32c4a1bdb0354e980a56e43f7f70b4
Matrix Walk
There is a matrix *A* of size *x*<=×<=*y* filled with integers. For every , *A**i*,<=*j*<==<=*y*(*i*<=-<=1)<=+<=*j*. Obviously, every integer from [1..*xy*] occurs exactly once in this matrix. You have traversed some path in this matrix. Your path can be described as a sequence of visited cells *a*1, *a*2, ..., *a**...
{"inputs": ["8\n1 2 3 6 9 8 5 2", "6\n1 2 1 2 5 3", "2\n1 10", "3\n1 2 2", "1\n1", "1\n6", "2\n2 3", "2\n1000000000 1", "4\n3 2 4 2", "5\n1 2 5 4 3", "2\n1 1", "3\n1 3 4", "1\n1000000000", "6\n1 4 5 6 3 2", "8\n1 2 3 6 9 8 7 6", "9\n4 3 2 1 5 6 7 8 9", "8\n2 5 8 9 6 3 2 1", "4\n1 2 1 3", "3\n1 4 3", "5\n1 2 3 4 1", "6\...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
1
codeforces
Okay, I need to solve this programming problem. Let's read the problem statement carefully. The problem is about determining if there exists a matrix of size x×y (with x and y being positive integers not exceeding 1e9) such that the matrix is filled in a row-wise manner. Each cell (i,j) contains the number (i-1)*y + j...
To solve this problem, we need to determine if there exists a matrix of size \(x \times y\) such that a given sequence of integers forms a valid path through adjacent cells. The matrix is filled row-wise, meaning each cell \((i, j)\) contains the integer \((i-1) \times y + j\). ### Approach 1. **Identify Vertical Step...
false
Code is incorrect.
6f6ba61afc5da72f67d05cadb8e29e00
Hungry Student Problem
Ivan's classes at the university have just finished, and now he wants to go to the local CFK cafe and eat some fried chicken. CFK sells chicken chunks in small and large portions. A small portion contains 3 chunks; a large one — 7 chunks. Ivan wants to eat exactly *x* chunks. Now he wonders whether he can buy exactly ...
{"inputs": ["2\n6\n5", "100\n1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17\n18\n19\n20\n21\n22\n23\n24\n25\n26\n27\n28\n29\n30\n31\n32\n33\n34\n35\n36\n37\n38\n39\n40\n41\n42\n43\n44\n45\n46\n47\n48\n49\n50\n51\n52\n53\n54\n55\n56\n57\n58\n59\n60\n61\n62\n63\n64\n65\n66\n67\n68\n69\n70\n71\n72\n73\n74\n75\n...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
205
codeforces
Okay, I need to solve this problem where Ivan wants to know if he can buy exactly x chicken chunks using any combination of small (3 chunks) and large (7 chunks) portions. So the task is to determine for each x_i whether there exist non-negative integers a and b such that 3a +7b = x. Hmm, let's think about the approac...
To solve this problem, we need to determine if Ivan can buy exactly the desired number of chicken chunks using a combination of small (3 chunks) and large (7 chunks) portions. The solution involves checking all possible combinations of these portions for each test case. ### Approach 1. **Problem Analysis**: The goal i...
true
6f88d078f556c38aa64f874a732d49a1
Spit Problem
In a Berland's zoo there is an enclosure with camels. It is known that camels like to spit. Bob watched these interesting animals for the whole day and registered in his notepad where each animal spitted. Now he wants to know if in the zoo there are two camels, which spitted at each other. Help him to solve this task. ...
{"inputs": ["2\n0 1\n1 -1", "3\n0 1\n1 1\n2 -2", "5\n2 -10\n3 10\n0 5\n5 -5\n10 1", "10\n-9897 -1144\n-4230 -6350\n2116 -3551\n-3635 4993\n3907 -9071\n-2362 4120\n-6542 984\n5807 3745\n7594 7675\n-5412 -6872", "11\n-1536 3809\n-2406 -8438\n-1866 395\n5636 -490\n-6867 -7030\n7525 3575\n-6796 2908\n3884 4629\n-2862 -6122...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
244
codeforces
Okay, let's see. So the problem is about camels spitting at each other. We need to find if there are two camels that spit in such a way that each hits the other. Hmm. First, let's understand the problem. Each camel is at position x_i. When it spits a distance d_i, the spit goes either right (if d_i is positive) or lef...
To solve this problem, we need to determine if there are two camels in a zoo that spit at each other such that each camel's spit lands exactly where the other camel is positioned. ### Approach 1. **Input Reading**: Read the number of camels and their respective positions and spit distances. 2. **Check Pairs**: For ea...
true
6f94033e42e6a08e91be2f6a70cd3a1f
Lakes in Berland
The map of Berland is a rectangle of the size *n*<=×<=*m*, which consists of cells of size 1<=×<=1. Each cell is either land or water. The map is surrounded by the ocean. Lakes are the maximal regions of water cells, connected by sides, which are not connected with the ocean. Formally, lake is a set of water cells, s...
{"inputs": ["5 4 1\n****\n*..*\n****\n**.*\n..**", "3 3 0\n***\n*.*\n***", "3 5 1\n.**.*\n*.*.*\n***..", "3 5 0\n.**.*\n*.*.*\n***..", "3 50 7\n***.********.*********************.**********.****\n*...**..*.**.*.*.*.*.*.*.*..*.*.*.*.*.*.*.*.*.*..*\n****************.*.********.**********************", "50 3 4\n***\n*.*\n...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
3
codeforces
Okay, I need to solve this programming problem. Let's read the problem statement carefully. The problem is about lakes on a map. The map is a grid of n rows and m columns. Each cell is land or water. Lakes are maximal regions of water cells connected by their sides, and they are not connected to the ocean. The ocean s...
To solve this problem, we need to transform a given map such that exactly `k` lakes remain by converting the minimum number of water cells to land. A lake is defined as a maximal region of water cells not connected to the ocean, which surrounds the map. ### Approach 1. **Identify Ocean-connected Cells**: Use a flood f...
true
6fa56519080e5ae2d001b4538fae2064
Less or Equal
You are given a sequence of integers of length $n$ and integer number $k$. You should print any integer number $x$ in the range of $[1; 10^9]$ (i.e. $1 \le x \le 10^9$) such that exactly $k$ elements of given sequence are less than or equal to $x$. Note that the sequence can contain equal elements. If there is no suc...
{"inputs": ["7 4\n3 7 5 1 10 3 20", "7 2\n3 7 5 1 10 3 20", "1 0\n1", "1 0\n2", "1 1\n1000000000", "3 0\n3 3 3", "3 0\n2 2 3", "5 0\n3 4 5 6 7", "4 0\n2 3 4 5", "2 2\n1000000000 1000000000", "7 2\n2 7 5 1 10 2 20", "2 1\n1 1", "5 3\n1 3 3 4 5", "4 4\n1000000000 1000000000 1000000000 1000000000"], "outputs": ["5", "-1",...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
34
codeforces
Okay, I need to solve this programming problem. Let's read the problem carefully. The task is: given a sequence of integers and a number k, find an integer x such that exactly k elements in the sequence are less than or equal to x. If there's no such x, output -1. Hmm. Let's think about how to approach this. First, ...
To solve this problem, we need to determine an integer \( x \) such that exactly \( k \) elements in a given sequence are less than or equal to \( x \). If no such \( x \) exists, we should return -1. ### Approach 1. **Sort the Array**: First, sort the given array to easily determine the positions of elements relativ...
false
Code is incorrect.
6fad140b01b60938c5f1ca7ca0c595c1
A Mist of Florescence
"I've been here once," Mino exclaims with delight, "it's breathtakingly amazing." "What is it like?" "Look, Kanno, you've got your paintbrush, and I've got my words. Have a try, shall we?" There are four kinds of flowers in the wood, Amaranths, Begonias, Centaureas and Dianthuses. The wood can be represented by a ...
{"inputs": ["5 3 2 1", "50 50 1 1", "1 6 4 5", "1 1 1 1", "4 8 16 32", "1 1 1 50", "19 58 20 18", "100 100 100 100", "1 1 1 2", "1 1 3 1", "1 4 1 1", "5 1 1 1", "1 4 7 3", "6 2 5 1", "1 5 6 3", "4 1 4 5", "4 5 3 6", "2 5 1 17", "11 4 5 14", "19 19 8 10", "49 49 49 49", "49 50 50 50", "50 50 51 50", "15 63 41 45", "45 3...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
37
codeforces
Okay, so I need to create a Python function that generates a grid of flowers (A, B, C, D) such that each type has exactly the required number of connected components as given by the input a, b, c, d. Hmm, the problem says that n and m can be chosen as long as they are between 1 and 50. So the first step is to figure ou...
To solve this problem, we need to generate a grid of flowers such that the number of connected components for each type of flower (Amaranths, Begonias, Centaureas, and Dianthuses) matches the given input values. The solution should ensure that the grid is valid and meets the constraints provided. ### Approach 1. **Gri...
false
Code is incorrect.
6fcc6e981568cc6fcb2d4525c65fed0a
Queries for Number of Palindromes
You've got a string *s*<==<=*s*1*s*2... *s*|*s*| of length |*s*|, consisting of lowercase English letters. There also are *q* queries, each query is described by two integers *l**i*,<=*r**i* (1<=≤<=*l**i*<=≤<=*r**i*<=≤<=|*s*|). The answer to the query is the number of substrings of string *s*[*l**i*... *r**i*], which a...
{"inputs": ["caaaba\n5\n1 1\n1 4\n2 3\n4 6\n4 5", "a\n100\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
1
codeforces
Okay, let's tackle this problem. So, the task is to count the number of palindromic substrings within a specific substring of the given string s. Each query gives a range [l, r], and we need to find all palindromic substrings that lie entirely within that range. Hmm. First, I need to understand what constitutes a pali...
To solve this problem, we need to efficiently count the number of palindromic substrings within specified ranges of a given string. Given the constraints, a brute-force approach is infeasible, so we use a precomputation strategy to answer each query in constant time. ### Approach 1. **Precompute Palindromic Substring...
true
6fd7e39fbfb49f8c3355674346e9c9e3
none
The main road in Bytecity is a straight line from south to north. Conveniently, there are coordinates measured in meters from the southernmost building in north direction. At some points on the road there are *n* friends, and *i*-th of them is standing at the point *x**i* meters and can move with any speed no greater ...
{"inputs": ["3\n7 1 3\n1 2 1", "4\n5 10 3 2\n2 3 2 4", "3\n1 1000000000 2\n1 2 1000000000", "2\n4 5\n10 8", "4\n14 12 10 17\n8 6 5 10", "5\n1 15 61 29 43\n15 11 19 19 19", "10\n20 11 17 38 15 27 2 40 24 37\n22 30 22 30 28 16 7 20 22 13", "2\n1000000000 1000000000\n1 1", "3\n1 1 1\n1 1 1"], "outputs": ["2.000000000000",...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
126
codeforces
Okay, so I need to solve this programming problem where I have to find the minimum time for all friends to meet at a single point. Let's try to understand the problem first. The problem says that each friend is on a straight road, each at position x_i. They can move either direction but their speed can't exceed v_i. W...
To solve this problem, we need to determine the minimum time required for all friends to gather at a single point on a straight road, given their positions and maximum speeds. The solution involves finding the optimal meeting point that minimizes the maximum time any friend takes to reach that point. ### Approach The ...
false
Code is incorrect.
6fef8e4304c116331fb41daf0b0b2c4b
Bear and Different Names
In the army, it isn't easy to form a group of soldiers that will be effective on the battlefield. The communication is crucial and thus no two soldiers should share a name (what would happen if they got an order that Bob is a scouter, if there are two Bobs?). A group of soldiers is effective if and only if their names...
{"inputs": ["8 3\nNO NO YES YES YES NO", "9 8\nYES NO", "3 2\nNO NO", "2 2\nYES", "2 2\nNO", "7 2\nYES NO YES YES NO YES", "18 7\nYES YES YES YES YES YES YES NO NO NO NO NO", "50 3\nNO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO ...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
48
codeforces
Okay, let's see. I need to solve this programming problem where I have to generate possible soldier names based on the given conditions. The problem statement says that for every consecutive group of k soldiers, the s_i string tells if that group is effective (all names unique) or not. And I have to find any possible n...
To solve this problem, we need to generate names for soldiers such that each consecutive group of `k` soldiers meets the specified effectiveness condition (either "YES" or "NO"). The solution must ensure that names are unique for "YES" groups and have at least one duplicate for "NO" groups. ### Approach 1. **Initial S...
false
Code is incorrect.
6ff3cefda98378fc0c21b62cb6ae02e9
Music
Little Lesha loves listening to music via his smartphone. But the smartphone doesn't have much memory, so Lesha listens to his favorite songs in a well-known social network InTalk. Unfortunately, internet is not that fast in the city of Ekaterinozavodsk and the song takes a lot of time to download. But Lesha is quite ...
{"inputs": ["5 2 2", "5 4 7", "6 2 3", "2 1 2", "2 1 3", "2 1 10000", "12326 6163 2", "10000 2500 4", "100000 99999 4", "12351 1223 6", "100000 1 10000", "10028 13 10000", "100000 99999 2", "100000 99999 3", "100000 1 2", "100000 1 3", "100000 1 4", "100000 1 5", "100000 3125 2", "12628 1804 7", "100000 45 13", "100000...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
92
codeforces
Okay, let's see. The problem is about Lesha downloading a song and restarting it whenever he reaches the end of the downloaded part. I need to calculate how many times he restarts the song, including the first start. Hmm. So, the parameters are T (total song duration), S (initial downloaded seconds), and q (download s...
To solve this problem, we need to determine how many times Lesha will restart his song playback while the song is still downloading. The key insight is to model the growth of the downloaded portion of the song each time Lesha restarts playback, considering the download speed factor. ### Approach 1. **Initialization**:...
true
6ff5c28d8fd9e8778ea5afef93fb2782
Lucky Tree
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. One day Petya encountered a tree with *n* vertexes. Besides, the tree was weighted, i. e. each edge ...
{"inputs": ["4\n1 2 4\n3 1 2\n1 4 7", "4\n1 2 4\n1 3 47\n1 4 7447", "9\n1 2 7\n1 3 12\n4 1 2\n4 5 4\n4 6 47\n4 7 9\n5 8 2\n5 9 1", "2\n1 2 7", "2\n2 1 1000000000", "9\n1 2 1\n1 3 7\n3 4 19\n3 5 2\n4 6 46\n7 4 25\n5 8 64\n5 9 73", "7\n1 2 47\n1 3 9\n3 7 7\n3 4 2\n3 5 4\n3 6 1", "5\n1 2 1\n2 3 1\n3 4 1\n4 5 2", "7\n1 2 4...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
2
codeforces
Okay, let's see. I need to solve this programming problem where I have to count the number of valid triples (i, j, k) in a tree such that the paths from i to j and i to k each have at least one lucky edge. Hmm. First, I need to understand the problem thoroughly. The tree is undirected and connected. Each edge is eithe...
To solve this problem, we need to count the number of valid vertex triples (i, j, k) in a tree such that both paths from i to j and from i to k include at least one lucky edge. A lucky edge is one whose weight consists only of the digits 4 and 7. ### Approach 1. **Identify Lucky Edges**: Determine which edges in the t...
true
6ff65660825765bf2edf2a8845293afc
Gotta Catch Em' All!
Bash wants to become a Pokemon master one day. Although he liked a lot of Pokemon, he has always been fascinated by Bulbasaur the most. Soon, things started getting serious and his fascination turned into an obsession. Since he is too young to go out and catch Bulbasaur, he came up with his own way of catching a Bulbas...
{"inputs": ["Bulbbasaur", "F", "aBddulbasaurrgndgbualdBdsagaurrgndbb", "BBBBBBBBBBbbbbbbbbbbuuuuuuuuuullllllllllssssssssssaaaaaaaaaarrrrrrrrrr", "BBBBBBBBBBbbbbbbbbbbbbbbbbbbbbuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuussssssssssssssssssssaaaaaaaaaaaaaaaaaaaaaaaa...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
162
codeforces
Okay, so I need to solve this problem where Bash is trying to form as many "Bulbasaur" as possible from a given string. The letters are case-sensitive, so the first letter must be uppercase 'B' and the rest lowercase. Each time he forms the word, he uses up those letters, and repeats until he can't form any more. My ta...
To solve this problem, we need to determine how many times the word "Bulbasaur" can be formed from a given string, considering case sensitivity. Each occurrence of "Bulbasaur" requires specific characters in exact quantities, and we need to maximize the number of times we can form this word using the characters from th...
true
704b7c118ec16d231e3db433b28d05dd
Minimal string
Petya recieved a gift of a string *s* with length up to 105 characters for his birthday. He took two more empty strings *t* and *u* and decided to play a game. This game has two possible moves: - Extract the first character of *s* and append *t* with this character. - Extract the last character of *t* and append *u*...
{"inputs": ["cab", "acdb", "a", "ab", "ba", "dijee", "bhrmc", "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "bababaaababaabbbbbabbbbbbaaabbabaaaaabbbbbaaaabbbbabaabaabababbbabbabbabaaababbabbababaaaaabaaaabbba", "bccbbcccbccbacacbaccaababcbaababaaaaabcaaabcaacba...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
51
codeforces
Okay, let's see. I need to solve this problem where Petya is playing a game with strings s, t, and u. The goal is to get u as lexicographically minimal as possible. Hmm. So the rules are that in each move, he can either take the first character of s and add it to the end of t, or take the last character of t and add it...
To solve this problem, we need to help Petya play a game with strings such that the resulting string `u` is lexicographically minimal. The game involves moving characters from string `s` to stack `t` and then from stack `t` to string `u` in a way that ensures `u` is as small as possible in lexicographical order. ### A...
true
705bd4865fdc3cbea4d14da2c58f73e0
Online Courses In BSU
Now you can take online courses in the Berland State University! Polycarp needs to pass *k* main online courses of his specialty to get a diploma. In total *n* courses are availiable for the passage. The situation is complicated by the dependence of online courses, for each course there is a list of those that must be...
{"inputs": ["6 2\n5 3\n0\n0\n0\n2 2 1\n1 4\n1 5", "9 3\n3 9 5\n0\n0\n3 9 4 5\n0\n0\n1 8\n1 6\n1 2\n2 1 2", "3 3\n1 2 3\n1 2\n1 3\n1 1", "5 3\n2 1 4\n0\n0\n1 5\n0\n0", "5 2\n4 1\n0\n1 4\n1 5\n0\n2 1 2", "5 2\n4 5\n2 3 4\n1 4\n1 4\n0\n0", "6 6\n5 4 3 2 6 1\n1 4\n0\n2 2 6\n2 3 6\n3 3 4 6\n0", "6 6\n4 1 6 3 2 5\n2 3 5\n4 1...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
6
codeforces
Okay, let's see. The problem is to find the minimal number of courses Polycarp needs to take, including all the main courses and their dependencies, and output the order in which he should take them. The order must respect the dependencies, and we need to minimize the total number of courses. Hmm. So, the input gives ...
To solve this problem, we need to determine the minimum number of courses Polycarp must take to complete all main courses and their dependencies, while ensuring the order respects all prerequisites. If there's a cycle in the dependencies, it's impossible to complete the courses, and we should return -1. ### Approach 1...
false
Code is incorrect.
7064cdd96129ae92a071cde28506aecb
Learning Languages
The "BerCorp" company has got *n* employees. These employees can use *m* approved official languages for the formal correspondence. The languages are numbered with integers from 1 to *m*. For each employee we have the list of languages, which he knows. This list could be empty, i. e. an employee may know no official la...
{"inputs": ["5 5\n1 2\n2 2 3\n2 3 4\n2 4 5\n1 5", "8 7\n0\n3 1 2 3\n1 1\n2 5 4\n2 6 7\n1 3\n2 7 4\n1 1", "2 2\n1 2\n0", "2 2\n0\n0", "5 5\n1 3\n0\n0\n2 4 1\n0", "6 2\n0\n0\n2 1 2\n1 1\n1 1\n0", "7 3\n3 1 3 2\n3 2 1 3\n2 2 3\n1 1\n2 2 3\n3 3 2 1\n3 2 3 1", "8 4\n0\n0\n4 2 3 1 4\n4 2 1 4 3\n3 4 3 1\n1 2\n2 4 1\n2 4 2", "...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
105
codeforces
Okay, let's see. I need to solve this programming problem. Let's read the problem carefully. So the problem is about connecting all employees through languages. The company wants every employee to be able to correspond with any other, possibly via others. The cost is the number of languages each employee needs to lear...
To solve this problem, we need to ensure that all employees in a company can communicate with each other, either directly or indirectly, through a common set of languages. The goal is to minimize the cost of teaching employees new languages to achieve this connectivity. ### Approach 1. **Model Employees and Languages ...
true
706acd5730014b72a9d13d61f09d85ff
Mister B and Book Reading
Mister B once received a gift: it was a book about aliens, which he started read immediately. This book had *c* pages. At first day Mister B read *v*0 pages, but after that he started to speed up. Every day, starting from the second, he read *a* pages more than on the previous day (at first day he read *v*0 pages, at ...
{"inputs": ["5 5 10 5 4", "12 4 12 4 1", "15 1 100 0 0", "1 1 1 0 0", "1000 999 1000 1000 998", "1000 2 2 5 1", "1000 1 1 1000 0", "737 41 74 12 11", "1000 1000 1000 0 999", "765 12 105 5 7", "15 2 2 1000 0", "1000 1 1000 1000 0", "20 3 7 1 2", "1000 500 500 1000 499", "1 1000 1000 1000 0", "1000 2 1000 56 0", "1000 2 ...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
195
codeforces
Okay, let's tackle this problem. Hmm. So the task is to calculate how many days Mister B needs to finish reading the book based on the given parameters. Let's break down the problem step by step. First, the parameters are c (total pages), v0 (initial speed), v1 (max speed), a (acceleration per day), and l (pages to re...
To solve this problem, we need to determine the number of days Mister B needs to finish reading a book given his reading speed, acceleration, maximum speed, and the pages he needs to re-read each day. ### Approach 1. **Initial Setup**: On the first day, Mister B reads `v0` pages. If this is sufficient to finish the b...
true
7076598337a1b1fdaeeb053b998c22c7
none
Память компьютера состоит из *n* ячеек, которые выстроены в ряд. Пронумеруем ячейки от 1 до *n* слева направо. Про каждую ячейку известно, свободна она или принадлежит какому-либо процессу (в таком случае известен процесс, которому она принадлежит). Для каждого процесса известно, что принадлежащие ему ячейки занимают ...
{"inputs": ["4\n0 2 2 1", "8\n0 8 8 8 0 4 4 2", "5\n0 0 0 1 1", "6\n0 0 0 3 0 0", "10\n0 10 10 0 0 3 3 0 0 0", "10\n0 9 9 9 9 0 8 8 8 8", "15\n0 0 6 6 0 0 0 0 4 0 0 0 9 0 0", "21\n0 11 11 11 11 0 7 0 12 12 12 12 12 0 19 19 19 0 1 1 1", "24\n0 0 6 6 6 0 22 22 0 23 23 0 19 19 19 19 0 0 17 0 0 3 3 3", "15\n1 1 1 1 5 5 5 4...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
4
codeforces
Okay, I need to solve this programming problem. Let's read the problem carefully and understand what's required. So the problem is about defragmenting computer memory. The memory consists of n cells arranged in a row. Each cell is either free (0) or occupied by a process (given by some number). The processes' cells mu...
To solve this problem, we need to defragment the computer memory such that all occupied cells are moved to the left, maintaining their relative order based on their first occurrence. The goal is to determine the minimum number of moves required to achieve this configuration. ### Approach 1. **Identify First Occurrence...
true
708287e8934727d8ebe2beebfac85f87
Chtholly's request
— I experienced so many great things. — You gave me memories like dreams... But I have to leave now... — One last request, can you... — Help me solve a Codeforces problem? — ...... — What? Chtholly has been thinking about a problem for days: If a number is palindrome and length of its decimal representation with...
{"inputs": ["2 100", "5 30", "42147 412393322", "77809 868097296", "5105 443422097", "75615 376679484", "22951 23793302", "12785 993582106", "60276 428978808", "84776 104860385", "41984 653766991", "100000 1000000000", "41163 472310076", "6983 765352180", "33493 967727004", "90898 94010922", "67298 349286579", "92452 2...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
239
codeforces
Okay, so I need to solve this problem where I have to find the sum of the k smallest zcy numbers and then output that sum modulo p. Let me think through how to approach this. First, let's understand what a zcy number is. A zcy number is a palindrome with an even number of digits. So, numbers like 1221 (since it's a pa...
To solve this problem, we need to generate the sum of the first k smallest zcy numbers and return the result modulo p. A zcy number is defined as a palindrome with an even number of digits. ### Approach 1. **Understanding Zcy Numbers**: A zcy number is formed by taking a number m, converting it to a string, and appen...
true
709787118e4472b115d8d0cf837ebc30
A Determined Cleanup
In order to put away old things and welcome a fresh new year, a thorough cleaning of the house is a must. Little Tommy finds an old polynomial and cleaned it up by taking it modulo another. But now he regrets doing this... Given two integers *p* and *k*, find a polynomial *f*(*x*) with non-negative integer coefficien...
{"inputs": ["46 2", "2018 214", "4 2", "5 2", "10 3", "250 1958", "1000000000000000000 2000", "1 2", "2 2", "3 2", "6 2", "7 2", "8 2", "9 2", "10 2", "1 3", "2 3", "3 3", "4 3", "5 3", "6 3", "7 3", "8 3", "9 3", "462 2", "462 3", "2018 4", "20180214 5", "1317 221", "1314 520", "1562 862", "6666666666666666 3", "25252...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
37
codeforces
Okay, let's tackle this problem. So the task is to find a polynomial f(x) with non-negative integer coefficients all less than k, such that when f(x) is divided by (x + k), the remainder is p. And we have to output the coefficients of this polynomial. If it's not possible, output -1. Hmm. Let me think about what this ...
To solve this problem, we need to find a polynomial \( f(x) \) with non-negative integer coefficients strictly less than \( k \) such that the remainder when \( f(x) \) is divided by \( (x + k) \) is \( p \). The key insight here is to represent \( p \) in a negative base \( -k \) and use the digits of this representat...
true
709fd4d9e29409d95b3039b0cf648ced
Correcting Mistakes
Analyzing the mistakes people make while typing search queries is a complex and an interesting work. As there is no guaranteed way to determine what the user originally meant by typing some query, we have to use different sorts of heuristics. Polycarp needed to write a code that could, given two words, check whether t...
{"inputs": ["7\nreading\ntrading", "5\nsweet\nsheep", "3\ntoy\ntry", "5\nspare\nspars", "1\na\nb", "1\nz\ny", "2\nab\nac", "2\nba\nca", "2\nac\ncb", "100\neebdeddddbecdbddaaecbbaccbecdeacedddcaddcdebedbabbceeeadecadbbeaecdaeabbceacbdbdbbdacebbbccdcbbeedbe\ndacdeebebeaeaacdeedadbcbaedcbddddddedacbabeddebaaebbdcebebaaccb...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
14
codeforces
Okay, let's see. So the problem is to find the number of possible words W such that by deleting exactly one character from W, we can get both S and T. And S and T are distinct and of the same length. Hmm. First, I need to understand the conditions for W. So W must be a word of length n+1. Because when you delete one c...
To solve this problem, we need to determine the number of distinct words \( W \) of length \( n+1 \) such that both given words \( S \) and \( T \) can be obtained by deleting exactly one character from \( W \). ### Approach 1. **Identify Common Prefix and Suffix**: - Compute the maximum length \( l \) where the ...
false
Code is incorrect.
70ad39a204d5f344618bb21bc61d6a45
Karen and Supermarket
On the way home, Karen decided to stop by the supermarket to buy some groceries. She needs to buy a lot of goods, but since she is a student her budget is still quite limited. In fact, she can only spend up to *b* dollars. The supermarket sells *n* goods. The *i*-th good can be bought for *c**i* dollars. Of course, e...
{"inputs": ["6 16\n10 9\n10 5 1\n12 2 1\n20 18 3\n10 2 3\n2 1 5", "5 10\n3 1\n3 1 1\n3 1 2\n3 1 3\n3 1 4", "13 30\n6 4\n25 5 1\n7 1 2\n9 4 2\n10 2 1\n12 3 1\n5 2 3\n10 9 6\n2 1 1\n5 3 9\n10 2 10\n10 9 6\n3 2 11", "8 9\n4 3\n8 3 1\n2 1 1\n4 2 2\n7 2 2\n3 1 2\n7 3 5\n2 1 3", "9 15\n3 1\n6 2 1\n8 3 2\n4 1 2\n2 1 2\n3 2 3\...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
2
codeforces
Okay, I need to solve this programming problem. Let's read the problem carefully and understand what's being asked. The problem is about Karen trying to buy as many goods as possible from a supermarket without exceeding her budget. The twist here is the coupons. Each coupon (for item i) reduces the price by d_i, but u...
To solve this problem, we need to determine the maximum number of goods Karen can buy from a supermarket without exceeding her budget, considering she can use coupons that have dependencies on other coupons. The problem requires a dynamic programming approach to efficiently handle the dependencies and maximize the numb...
false
Code is incorrect.
70cd612001f2bd39369ae10726c2feac
none
A remote island chain contains *n* islands, labeled 1 through *n*. Bidirectional bridges connect the islands to form a simple cycle — a bridge connects islands 1 and 2, islands 2 and 3, and so on, and additionally a bridge connects islands *n* and 1. The center of each island contains an identical pedestal, and all but...
{"inputs": ["3\n1 0 2\n2 0 1", "2\n1 0\n0 1", "4\n1 2 3 0\n0 3 2 1", "9\n3 8 4 6 7 1 5 2 0\n6 4 8 5 3 1 2 0 7", "4\n2 3 1 0\n2 0 1 3", "4\n0 1 2 3\n2 0 1 3", "4\n3 0 1 2\n1 0 2 3", "3\n0 2 1\n1 2 0", "2\n0 1\n0 1", "6\n3 1 5 4 0 2\n0 4 3 5 2 1", "4\n2 0 3 1\n3 1 0 2", "5\n3 0 2 1 4\n4 3 0 1 2", "3\n2 0 1\n1 0 2", "10\n...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
45
codeforces
Okay, let's see. The problem is about determining whether it's possible to rearrange statues on islands connected in a cycle so that the desired configuration is achieved. The movement is done by moving a statue to an adjacent empty pedestal each time. Hmm. First, I need to understand the constraints. The islands form...
To solve this problem, we need to determine if the statues on a cycle of islands can be rearranged into a desired configuration by moving an empty pedestal (denoted by 0) to adjacent islands. The key insight is that the non-zero statues must form a rotation of each other when the empty pedestal is ignored. ### Approac...
true
7106a5a4ccf392528293f254daca3836
Permutations
You are given a permutation *p* of numbers 1,<=2,<=...,<=*n*. Let's define *f*(*p*) as the following sum: Find the lexicographically *m*-th permutation of length *n* in the set of permutations having the maximum possible value of *f*(*p*). The single line of input contains two integers *n* and *m* (1<=≤<=*m*<=≤<=*cnt*...
{"inputs": ["2 2", "3 2", "1 1", "3 1", "3 3", "3 4", "4 1", "4 3", "4 4", "4 8", "5 2", "5 7", "5 15", "6 23", "7 7", "7 44", "8 1", "8 127", "8 128"], "outputs": ["2 1 ", "1 3 2 ", "1 ", "1 2 3 ", "2 3 1 ", "3 2 1 ", "1 2 3 4 ", "1 3 4 2 ", "1 4 3 2 ", "4 3 2 1 ", "1 2 3 5 4 ", "1 4 5 3 2 ", "4 5 3 2 1 ", "2 5 6 4 3 ...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
48
codeforces
Okay, let's try to solve this problem. Hmm, the problem is about finding the m-th lex permutation among all permutations that have the maximum possible value of f(p). So first, I need to understand what f(p) is. Wait, the question says "the following sum", but I don't see the definition here. Oh wait, maybe I missed it...
The problem statement provided is incomplete as it lacks the definition of the function \( f(p) \), which is crucial for determining the maximum value permutations. Without knowing how \( f(p) \) is computed, it's impossible to derive the correct solution. Please provide the complete problem statement including the def...
false
Does not contain code component.
7138af4685444691c2b25b0bdce983e3
Destruction of a Tree
You are given a tree (a graph with *n* vertices and *n*<=-<=1 edges in which it's possible to reach any vertex from any other vertex using only its edges). A vertex can be destroyed if this vertex has even degree. If you destroy a vertex, all edges connected to it are also deleted. Destroy all vertices in the given t...
{"inputs": ["5\n0 1 2 1 2", "4\n0 1 2 3", "1\n0", "8\n3 1 4 0 4 2 4 5", "100\n81 96 65 28 4 40 5 49 5 89 48 70 94 70 17 58 58 1 61 19 45 33 46 19 22 83 56 67 62 82 57 16 29 36 84 71 42 66 78 54 73 45 82 80 67 88 79 69 61 66 5 36 24 60 96 21 77 67 68 29 87 37 91 34 78 43 0 69 49 62 16 2 68 79 57 1 60 12 39 99 14 37 30 9...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
2
codeforces
Okay, so I've got this programming problem to solve. Let me read it carefully. The problem is about destroying all vertices in a tree. The condition for destroying a vertex is that its degree must be even. When you destroy a vertex, all edges connected to it are deleted, which affects the degrees of neighboring vertic...
To solve this problem, we need to determine if it's possible to destroy all vertices in a given tree such that each vertex is destroyed when its degree is even. If possible, we must also provide the order in which the vertices are destroyed. ### Approach 1. **Tree Structure Analysis**: The tree is represented using pa...
false
Code is incorrect.
716e110f0464198d037e1dd300a49754
Bear and Five Cards
A little bear Limak plays a game. He has five cards. There is one number written on each card. Each number is a positive integer. Limak can discard (throw out) some cards. His goal is to minimize the sum of numbers written on remaining (not discarded) cards. He is allowed to at most once discard two or three cards wi...
{"inputs": ["7 3 7 3 20", "7 9 3 1 8", "10 10 10 10 10", "8 7 1 8 7", "7 7 7 8 8", "8 8 8 2 2", "8 8 2 2 2", "5 50 5 5 60", "100 100 100 100 100", "1 1 1 1 1", "29 29 20 20 20", "20 29 20 29 20", "31 31 20 20 20", "20 20 20 31 31", "20 31 20 31 20", "20 20 20 30 30", "30 30 20 20 20", "8 1 8 8 8", "1 1 1 8 1", "1 2 3 4...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
133
codeforces
Okay, let's see. The problem is that Limak has five cards with numbers, and he can discard either two or three cards with the same number, but he can do this at most once. The goal is to find the minimal possible sum after possibly discarding those cards. Hmm. So, the steps I need to take here. First, I need to check ...
To solve this problem, we need to determine the minimum possible sum of numbers on the remaining cards after Limak discards either two or three cards with the same number, at most once. The key is to find the optimal discard that minimizes the sum. ### Approach 1. **Sum Calculation**: First, compute the total sum of a...
true
7191b886b2342aa9f0bc1752ce01932b
Pasha and String
Pasha got a very beautiful string *s* for his birthday, the string consists of lowercase Latin letters. The letters in the string are numbered from 1 to |*s*| from left to right, where |*s*| is the length of the given string. Pasha didn't like his present very much so he decided to change it. After his birthday Pasha ...
{"inputs": ["abcdef\n1\n2", "vwxyz\n2\n2 2", "abcdef\n3\n1 2 3", "jc\n5\n1 1 1 1 1", "wljqgdlxyc\n13\n3 4 3 3 5 4 4 2 4 4 5 3 3", "keicnqmuqinhsmtudqcilocxkbqgzhbkitmqwttdyoyvcbxincwjryzknubpacsngorexaldfurondbednowemnnlphhboycfavs\n2\n5 12", "xwcxggxvfqbdklewbxkjzibmufnaywuxsqvwakefxbbkfandvigasbhbatsxyqxicrosatfsfybe...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
104
codeforces
Okay, let's see. The problem is about reversing certain parts of a string multiple times and then outputting the final string. Hmm. Let's read the problem carefully. So, the input is a string s. Then there are m days. Each day, Pasha reverses a substring from position a_i to |s| - a_i + 1. Wait, wait. Let me parse tha...
To solve this problem, we need to determine the final state of a string after applying a series of reversals on specific segments. Each reversal operation is symmetric around the midpoint of the string, and we need to efficiently compute the cumulative effect of these operations without explicitly performing each rever...
false
Code is incorrect.
71bdb35746c7c54bba2602aa6767893a
Arthur and Brackets
Notice that the memory limit is non-standard. Recently Arthur and Sasha have studied correct bracket sequences. Arthur understood this topic perfectly and become so amazed about correct bracket sequences, so he even got himself a favorite correct bracket sequence of length 2*n*. Unlike Arthur, Sasha understood the top...
{"inputs": ["4\n1 1\n1 1\n1 1\n1 1", "3\n5 5\n3 3\n1 1", "3\n5 5\n3 3\n2 2", "3\n2 3\n1 4\n1 4", "6\n1 5\n2 4\n1 1\n1 1\n1 1\n1 1", "3\n1 4\n2 2\n1 1", "5\n1 3\n2 5\n3 4\n1 2\n1 9", "2\n3 3\n3 3", "1\n1 1", "10\n9 9\n5 5\n1 1\n1 1\n13 13\n11 11\n1 1\n5 5\n1 1\n1 1", "50\n97 97\n61 61\n59 59\n29 29\n13 13\n7 7\n5 5\n3 3...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
1
codeforces
Okay, let's tackle this problem. Hmm. So the task is to restore a correct bracket sequence based on the given constraints for each opening bracket. Each i-th opening bracket (from left to right) has a range [li, ri] for the distance between its position and the corresponding closing bracket. The challenge is to find a ...
To solve this problem, we need to restore a correct bracket sequence based on given constraints for each opening bracket. Each opening bracket has a specified range for the distance to its corresponding closing bracket. The challenge is to ensure that the sequence is valid and properly nested. ### Approach 1. **Check ...
false
Code is incorrect.
71e025842157ee5552327ed027b3b6d3
Substring
You are given a graph with $n$ nodes and $m$ directed edges. One lowercase letter is assigned to each node. We define a path's value as the number of the most frequently occurring letter. For example, if letters on a path are "abaca", then the value of that path is $3$. Your task is find a path whose value is the large...
{"inputs": ["5 4\nabaca\n1 2\n1 3\n3 4\n4 5", "6 6\nxzyabc\n1 2\n3 1\n2 3\n5 4\n4 3\n6 4", "10 14\nxzyzyzyzqx\n1 2\n2 4\n3 5\n4 5\n2 6\n6 8\n6 5\n2 10\n3 9\n10 9\n4 6\n1 10\n2 8\n3 7", "1 1\nf\n1 1", "10 50\nebibwbjihv\n1 10\n1 2\n5 4\n1 8\n9 7\n5 6\n1 8\n8 7\n2 6\n5 4\n1 9\n3 2\n8 3\n5 6\n5 9\n2 4\n2 7\n3 9\n1 2\n1 7\...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
24
codeforces
Okay, I need to solve this problem where I have to find the maximum path value in a directed graph. The problem says that the path's value is the maximum frequency of any single character along the path. And if there's a cycle that's part of a path, then the value can be infinitely large, so we output -1. Hmm, right. S...
To solve this problem, we need to determine the maximum value of a path in a directed graph, where the value is defined as the highest frequency of any single character along the path. If the graph contains a cycle, the value can be arbitrarily large, so we should output -1 in such cases. ### Approach 1. **Cycle Detec...
true
71f7922bb52860546e0b6c4ad6365d5d
Quasi-palindrome
Let quasi-palindromic number be such number that adding some leading zeros (possible none) to it produces a palindromic string. String *t* is called a palindrome, if it reads the same from left to right and from right to left. For example, numbers 131 and 2010200 are quasi-palindromic, they can be transformed to str...
{"inputs": ["131", "320", "2010200", "1", "1000000000", "999999999", "999999998", "102000", "210000000", "213443120", "99", "22002", "1010", "1201", "6460046", "503435", "21002", "101001", "200102", "20010002", "33003", "100101", "1021", "1101", "10101100", "101", "1011", "11010", "10110", "110000", "2011", "10020001",...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
246
codeforces
Okay, let's see. I need to write a Python function that checks if a given number is quasi-palindromic. Hmm, what does quasi-palindromic mean again? Oh right, it's when adding some leading zeros (maybe none) makes it a palindrome. So the key is to find if there's any way to add leading zeros so that the resulting string...
To solve this problem, we need to determine if a given number can be transformed into a palindrome by adding leading zeros. The key insight is that the number must have a core part that is a palindrome when trailing zeros are removed, and adding leading zeros to this core part should form a palindrome. ### Approach 1....
true
72154bce8f297ac2e3f2dbe058abef0e
Marvolo Gaunt's Ring
Professor Dumbledore is helping Harry destroy the Horcruxes. He went to Gaunt Shack as he suspected a Horcrux to be present there. He saw Marvolo Gaunt's Ring and identified it as a Horcrux. Although he destroyed it, he is still affected by its curse. Professor Snape is helping Dumbledore remove the curse. For this, he...
{"inputs": ["5 1 2 3\n1 2 3 4 5", "5 1 2 -3\n-1 -2 -3 -4 -5", "5 886327859 82309257 -68295239\n-731225382 354766539 -48222231 -474691998 360965777", "4 -96405765 -495906217 625385006\n-509961652 392159235 -577128498 -744548876", "43 959134961 -868367850 142426380\n921743429 63959718 -797293233 122041422 -407576197 7001...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
96
codeforces
Okay, I need to solve this problem where I have to find the maximum value of p*a_i + q*a_j + r*a_k such that i <= j <= k. Hmm. Let's think about how to approach this. First, let's understand the constraints. The array can be up to 1e5 elements, so any O(n^3) approach is definitely out of the question. Even O(n^2) migh...
To solve this problem, we need to find the maximum value of the expression \( p \cdot a_i + q \cdot a_j + r \cdot a_k \) where \( 1 \leq i \leq j \leq k \leq n \). Given the constraints, an efficient approach is necessary to handle large input sizes. ### Approach 1. **Precompute Maximum Values**: - **Left Maximum A...
true
72192ff030fb3bf908ee666a246cd70b
Mentors
In BerSoft $n$ programmers work, the programmer $i$ is characterized by a skill $r_i$. A programmer $a$ can be a mentor of a programmer $b$ if and only if the skill of the programmer $a$ is strictly greater than the skill of the programmer $b$ $(r_a &gt; r_b)$ and programmers $a$ and $b$ are not in a quarrel. You are...
{"inputs": ["4 2\n10 4 10 15\n1 2\n4 3", "10 4\n5 4 1 5 4 3 7 1 2 5\n4 6\n2 1\n10 8\n3 5", "2 0\n3 1", "2 0\n1 1", "10 35\n322022227 751269818 629795150 369443545 344607287 250044294 476897672 184054549 986884572 917181121\n6 3\n7 3\n1 9\n7 9\n10 7\n3 4\n8 6\n7 4\n6 10\n7 2\n3 5\n6 9\n3 10\n8 7\n6 5\n8 1\n8 5\n1 7\n8 1...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
22
codeforces
Okay, I need to solve this programming problem. Let's read the problem carefully. So, the problem is about programmers and their mentorship possibilities. Each programmer has a skill level. A programmer a can be a mentor to b if two conditions are met: a's skill is strictly greater than b's, and they are not in a quar...
To solve this problem, we need to determine how many programmers each programmer can mentor based on their skill levels and quarrels. A programmer can mentor another if their skill is strictly higher and they are not in a quarrel. ### Approach 1. **Input Reading and Initialization**: Read the number of programmers and...
true
7228f18da7fed17083cc15458e82d310
Domino piling
You are given a rectangular board of *M*<=×<=*N* squares. Also you are given an unlimited number of standard domino pieces of 2<=×<=1 squares. You are allowed to rotate the pieces. You are asked to place as many dominoes as possible on the board so as to meet the following conditions: 1. Each domino completely covers ...
{"inputs": ["2 4", "3 3", "1 5", "1 6", "1 15", "1 16", "2 5", "2 6", "2 7", "2 14", "2 15", "1 4", "2 16", "3 5", "3 6", "3 10", "3 14", "3 15", "3 16", "5 7", "16 16", "15 16", "2 3", "15 15", "14 16", "11 13", "5 16", "8 15", "2 2", "3 4", "4 4", "1 1", "1 2", "1 3", "14 15"], "outputs": ["4", "4", "2", "3", "7", "8...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
3,908
codeforces
Okay, let's see. The problem is to find the maximum number of dominoes that can fit on an M x N board. Each domino covers two squares. So I need to figure out the maximum possible number given the constraints. Hmm, dominoes are 2x1 or 1x2. So each domino covers two adjacent squares. The question is, how many such domi...
To solve this problem, we need to determine the maximum number of 2x1 dominoes that can be placed on an MxN rectangular board without overlapping and ensuring each domino lies entirely within the board. ### Approach The key insight to solve this problem is to recognize that each domino covers exactly two squares. The...
true
722da95a33955b90c2bf82a34b3bb610
Pig and Palindromes
Peppa the Pig was walking and walked into the forest. What a strange coincidence! The forest has the shape of a rectangle, consisting of *n* rows and *m* columns. We enumerate the rows of the rectangle from top to bottom with numbers from 1 to *n*, and the columns — from left to right with numbers from 1 to *m*. Let's ...
{"inputs": ["3 4\naaab\nbaaa\nabba", "2 2\nab\naa", "3 5\nqqqrw\nwqqtw\newqqq", "1 5\nabbba", "1 5\nabbbb", "1 4\nabca", "5 1\na\na\na\na\na", "5 2\nab\nab\ncc\nba\nba", "5 3\naba\naba\nccc\nbaa\nbaa", "5 5\naaaaa\naaaaa\naaaaa\naaaaa\naaaaa", "5 5\naaaaa\nadaaa\naaaaa\naaaaa\naacaa", "5 5\naaaqa\naaaaa\naaaaa\naaaaa\n...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
5
codeforces
Okay, let's see. The problem is to count the number of beautiful paths from (1,1) to (n,m), where the path is a palindrome. Hmm. So the path must form a palindrome sequence. That means the first cell is the same as the last, the second same as the second last, and so on. First, I need to model the paths. Since the pi...
To solve this problem, we need to count the number of beautiful paths from the top-left corner to the bottom-right corner of a grid, where the path forms a palindrome. The solution involves dynamic programming (DP) to efficiently explore all possible paths while ensuring the sequence of cells visited forms a palindrome...
false
Code is incorrect.
72392bfc46fcb8be3645ce5e5dc8ca05
Mountain Scenery
Little Bolek has found a picture with *n* mountain peaks painted on it. The *n* painted peaks are represented by a non-closed polyline, consisting of 2*n* segments. The segments go through 2*n*<=+<=1 points with coordinates (1,<=*y*1), (2,<=*y*2), ..., (2*n*<=+<=1,<=*y*2*n*<=+<=1), with the *i*-th segment connecting th...
{"inputs": ["3 2\n0 5 3 5 1 5 2", "1 1\n0 2 0", "1 1\n1 100 0", "3 1\n0 1 0 1 0 2 0", "3 1\n0 1 0 2 0 1 0", "3 3\n0 100 35 67 40 60 3", "7 3\n1 2 1 3 1 2 1 2 1 3 1 3 1 2 1", "100 100\n1 3 1 3 1 3 0 2 0 3 1 3 1 3 1 3 0 3 1 3 0 2 0 2 0 3 0 2 0 2 0 3 1 3 1 3 1 3 1 3 0 2 0 3 1 3 0 2 0 2 0 2 0 2 0 2 0 3 0 3 0 3 0 3 0 2 0 3 ...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
128
codeforces
Okay, let's try to understand this problem. So, the problem is about reconstructing the original mountain peaks image after Bolek modified it. Bolek selected exactly k mountain peaks, which are the even vertices. For each selected peak, he erased the segments around it (so the segments connected to it) and increased it...
To solve this problem, we need to reconstruct the original polyline of mountain peaks after Bolek modified it by increasing the height of exactly `k` peaks and adjusting the segments. The approach involves identifying which peaks were modified and reverting those changes to get the original polyline. ### Approach 1. *...
false
Code is incorrect.
724a4c13f3ca6aa5877b722fc19e0413
Resource Distribution
One department of some software company has $n$ servers of different specifications. Servers are indexed with consecutive integers from $1$ to $n$. Suppose that the specifications of the $j$-th server may be expressed with a single integer number $c_j$ of artificial resource units. In order for production to work, it ...
{"inputs": ["6 8 16\n3 5 2 9 8 7", "4 20 32\n21 11 11 12", "4 11 32\n5 5 16 16", "5 12 20\n7 8 4 11 9", "2 1 1\n1 1", "2 1 1\n1 1000000", "2 1 1\n1000000000 1000000000", "2 1 2\n1 1", "15 250 200\n71 2 77 69 100 53 54 40 73 32 82 58 24 82 41", "4 12 11\n4 4 6 11"], "outputs": ["Yes\n4 2\n3 1 2 6\n5 4", "Yes\n1 3\n1\n2 ...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
8
codeforces
Okay, let's see. I need to solve this problem where we have to deploy two services on servers such that each server is used for at most one service, and the sum of their resources meets the required divided x_i / k_i for each service. Hmm. Wait, the problem says that for service S_i, if it's deployed on k_i servers, e...
To solve this problem, we need to deploy two services on a set of servers such that each server is used for exactly one service or left unused. Each service has specific resource requirements, and the servers have varying capacities. The goal is to determine if both services can be deployed and, if so, specify which se...
false
Code is incorrect.
72820233354134500e4063498a6717f0
Weird Rounding
Polycarp is crazy about round numbers. He especially likes the numbers divisible by 10*k*. In the given number of *n* Polycarp wants to remove the least number of digits to get a number that is divisible by 10*k*. For example, if *k*<==<=3, in the number 30020 it is enough to delete a single digit (2). In this case, t...
{"inputs": ["30020 3", "100 9", "10203049 2", "0 1", "0 9", "100 2", "102030404 2", "1000999999 3", "12000000 4", "1090090090 5", "10 1", "10 2", "10 9", "100 1", "100 3", "101010110 3", "101010110 1", "101010110 2", "101010110 4", "101010110 5", "101010110 9", "1234567890 1", "1234567890 2", "1234567890 9", "200000000...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
179
codeforces
Okay, I need to solve this problem where I have to find the minimum number of digits to delete from a number n so that the resulting number is divisible by 10^k. The result shouldn't have leading zeros except for the case when it's zero itself. Hmm, let's think about how to approach this. First, let's understand what ...
To solve this problem, we need to determine the minimum number of digits to delete from a given number so that the resulting number is divisible by \(10^k\). The resulting number should not have unnecessary leading zeros unless it is exactly zero. ### Approach 1. **Identify Trailing Zeros**: The resulting number must ...
true
72b27ecee4e2a8f3268f429ae77dad23
Ant on the Tree
Connected undirected graph without cycles is called a tree. Trees is a class of graphs which is interesting not only for people, but for ants too. An ant stands at the root of some tree. He sees that there are *n* vertexes in the tree, and they are connected by *n*<=-<=1 edges so that there is a path between any pair ...
{"inputs": ["3\n1 2\n2 3\n3", "6\n1 2\n1 3\n2 4\n4 5\n4 6\n5 6 3", "6\n1 2\n1 3\n2 4\n4 5\n4 6\n5 3 6", "10\n8 10\n2 1\n7 5\n5 4\n6 10\n2 3\n3 10\n2 9\n7 2\n6 9 4 8", "8\n4 3\n6 7\n8 6\n6 1\n4 6\n6 5\n6 2\n3 2 7 8 5", "8\n4 3\n1 4\n8 5\n7 6\n3 5\n7 3\n4 2\n2 6 8", "20\n4 13\n17 7\n19 10\n18 1\n5 15\n2 6\n11 7\n3 6\n5 1...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
13
codeforces
Okay, let's see. I need to solve this programming problem where an ant has to traverse a tree in such a way that each edge is traversed exactly twice, and the leaves are visited in a specific order. The output should be the route, or -1 if it's impossible. First, let's understand the problem. The tree is rooted at 1. ...
To solve this problem, we need to determine if an ant can traverse a tree such that each edge is traversed exactly twice, starting and ending at the root, while visiting the leaves in a specified order. If possible, we must output the route; otherwise, output -1. ### Approach 1. **Tree Structure and Input Parsing**: R...
false
Code is incorrect.
72b42c09aa731632c82d0fda042cc4d8
Lucky Subsequence
Petya loves lucky numbers very much. Everybody knows that lucky numbers are positive integers whose decimal record contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Petya has sequence *a* consisting of *n* integers. The subsequence of the sequence *a* is such su...
{"inputs": ["3 2\n10 10 10", "4 2\n4 4 7 7", "7 4\n1 2 3 4 5 6 7", "7 4\n7 7 7 7 7 7 7", "10 1\n1 2 3 4 5 6 7 8 9 10", "10 7\n1 2 3 4 5 6 7 8 9 10", "20 7\n1 4 5 8 47 777777777 1 5 4 8 5 9 5 4 7 4 5 7 7 44474", "5 2\n47 47 47 47 47", "13 5\n44 44 44 44 44 44 44 44 77 55 66 99 55", "3 2\n1 47 47", "2 2\n47 47", "2 2\n44...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
3
codeforces
Okay, let's see. So the problem is to find the number of different lucky subsequences in a given sequence. The definition here is a bit tricky. Let me parse the problem statement carefully. A lucky subsequence is one that has exactly length k, and in this subsequence, there are no two identical lucky numbers. Unlucky ...
To solve this problem, we need to determine the number of distinct lucky subsequences of length `k` from a given sequence of integers. A lucky subsequence is defined as a subsequence where all elements that are lucky numbers (composed only of the digits 4 and 7) are unique, while non-lucky numbers can be repeated. The ...
true
72bbbcff66eb716aa7bc1702a512ce3d
Dima and Guards
Nothing has changed since the last round. Dima and Inna still love each other and want to be together. They've made a deal with Seryozha and now they need to make a deal with the dorm guards... There are four guardposts in Dima's dorm. Each post contains two guards (in Russia they are usually elderly women). You can b...
{"inputs": ["10\n5 6 5 6\n6 6 7 7\n5 8 6 6\n9 9 9 9", "10\n6 6 6 6\n7 7 7 7\n4 4 4 4\n8 8 8 8", "5\n3 3 3 3\n3 3 3 3\n3 3 3 3\n3 3 3 3", "100000\n100000 100000 100000 100000\n100000 100000 100000 100000\n100000 100000 100000 100000\n100000 100000 100000 100000", "5\n3 2 3 3\n3 2 3 3\n4 4 4 4\n4 4 1 1", "100\n1 1 2 2\n1...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
57
codeforces
Okay, let's see. The problem is about finding a guardpost where Dima can buy exactly two gifts (one for each guard) such that the total cost equals exactly n rubles. And each gift must meet the minimum prices for each guard's required item. Hmm. So each guardpost has two guards. For each guard, you have to choose eith...
To solve this problem, we need to determine if Dima can bribe the guards at any of the four guardposts such that the total cost of the bribes exactly equals a given amount, `n`. Each guard at a post can be bribed with either a chocolate bar or a juice box, each of which has a minimum acceptable price. The goal is to fi...
false
Code is incorrect.
72d25ec743d032211913d9611cd07a45
Square Earth?
Meg the Rabbit decided to do something nice, specifically — to determine the shortest distance between two points on the surface of our planet. But Meg... what can you say, she wants everything simple. So, she already regards our planet as a two-dimensional circle. No, wait, it's even worse — as a square of side *n*. T...
{"inputs": ["2 0 0 1 0", "2 0 1 2 1", "100 0 0 100 100", "4 0 3 1 4", "10 8 10 10 0", "26 21 0 26 14", "15 0 1 11 0", "26 26 7 26 12", "6 6 0 2 6", "5 1 5 2 5", "99 12 0 35 99", "44 44 31 28 0", "42 42 36 5 0", "87 87 66 0 5", "85 0 32 0 31", "30 20 30 3 0", "5 4 0 5 1", "40 24 40 4 0", "11 0 2 11 4", "82 0 11 35 0", "...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
28
codeforces
Okay, let's try to figure out this problem. So, the task is to find the shortest distance between two points on the perimeter of a square. The square has its sides aligned such that the vertices are at (0,0), (n,0), (0,n), and (n,n). The points given are on the edges of this square, and we need to compute the minimal p...
To solve this problem, we need to determine the shortest distance between two points on the perimeter of a square. The square's vertices are at (0,0), (n,0), (0,n), and (n,n), and the points given are guaranteed to lie on the perimeter. The shortest path will be along the perimeter of the square. ### Approach 1. **Mod...
true
7307aab67e8176e638767b6378a44995
Chocolate Bar
You have a rectangular chocolate bar consisting of *n*<=×<=*m* single squares. You want to eat exactly *k* squares, so you may need to break the chocolate bar. In one move you can break any single rectangular piece of chocolate in two rectangular pieces. You can break only by lines between squares: horizontally or ve...
{"inputs": ["4\n2 2 1\n2 2 3\n2 2 2\n2 2 4"], "outputs": ["5\n5\n4\n0"]}
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
3
codeforces
Okay, let's see. I need to solve this problem where I have to find the minimum total cost of breaking a chocolate bar into exactly k squares. Hmm. The cost is the square of the break length. So, each time I break a piece into two parts, the cost is the square of the length of the break. For example, breaking a 2x3 bar ...
To solve this problem, we need to determine the minimum total cost of breaking a chocolate bar into exactly `k` squares. The cost of breaking a piece of chocolate is the square of the break length. The solution involves dynamic programming (DP) to precompute the minimum costs for all possible configurations of the choc...
true
733c09dbb540865f8619f90de41154e5
The Wall
Iahub and his friend Floyd have started painting a wall. Iahub is painting the wall red and Floyd is painting it pink. You can consider the wall being made of a very large number of bricks, numbered 1, 2, 3 and so on. Iahub has the following scheme of painting: he skips *x*<=-<=1 consecutive bricks, then he paints th...
{"inputs": ["2 3 6 18", "4 6 20 201", "15 27 100 10000", "105 60 3456 78910", "1 1 1000 100000", "3 2 5 5", "555 777 1 1000000", "1000 1000 1 32323", "45 125 93451125 100000000", "101 171 1 1000000000", "165 255 69696 1000000000", "555 777 666013 1000000000", "23 46 123321 900000000", "321 123 15 1000000", "819 1000 95...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
148
codeforces
Okay, I need to solve this programming problem. Let's read the question carefully. So, the problem is about two friends painting a wall. Iahub paints every x-th brick, starting from x. Floyd paints every y-th brick starting from y. Some bricks are painted both colors. We need to find out how many such bricks are there...
To solve this problem, we need to determine how many bricks are painted both red and pink by Iahub and Floyd within a specified range. The key insight is that a brick painted by both will be a common multiple of their respective painting intervals. ### Approach 1. **Understanding the Problem**: Iahub paints every x-t...
true
7342c11337a3f2aed7498a23929c2593
GCD Table
Consider a table *G* of size *n*<=×<=*m* such that *G*(*i*,<=*j*)<==<=*GCD*(*i*,<=*j*) for all 1<=≤<=*i*<=≤<=*n*,<=1<=≤<=*j*<=≤<=*m*. *GCD*(*a*,<=*b*) is the greatest common divisor of numbers *a* and *b*. You have a sequence of positive integer numbers *a*1,<=*a*2,<=...,<=*a**k*. We say that this sequence occurs in t...
{"inputs": ["100 100 5\n5 2 1 2 1", "100 8 5\n5 2 1 2 1", "100 100 7\n1 2 3 4 5 6 7", "5 5 5\n1 1 1 1 1", "11 10 1\n11", "108 942 35\n1 1 3 1 1 3 1 1 3 1 1 3 1 1 3 1 1 3 1 1 3 1 1 3 31 1 3 1 1 3 1 1 3 1 1", "1000000000000 1000000000000 116\n1587924000 7 2 3 4 5 6 1 56 9 10 1 12 13 2 105 16 1 18 1 620 3 14 1 24 25 26 27...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
6
codeforces
Okay, I need to solve this programming problem. Let's read the problem statement carefully. The task is to determine whether a given sequence of integers occurs consecutively in some row of a table G. The table G is defined such that G(i, j) is the GCD of i and j. The rows are for a fixed i, varying j from 1 to m. The...
To solve this problem, we need to determine if a given sequence of integers occurs consecutively in any row of a table where each element is the greatest common divisor (GCD) of its row and column indices. The solution involves checking for the existence of valid row and column indices that match the sequence using mat...
true
735a04aff31665beb4885fab2271e2bf
Playing with Paper
One day Vasya was sitting on a not so interesting Maths lesson and making an origami from a rectangular *a* mm <=×<= *b* mm sheet of paper (*a*<=&gt;<=*b*). Usually the first step in making an origami is making a square piece of paper from the rectangular sheet by folding the sheet along the bisector of the right angle...
{"inputs": ["2 1", "10 7", "1000000000000 1", "3 1", "4 1", "3 2", "4 2", "1000 700", "959986566087 524054155168", "4 3", "7 6", "1000 999", "1000 998", "1000 997", "42 1", "1000 1", "8 5", "13 8", "987 610", "442 42", "754 466", "1000000000000 999999999999", "1000000000000 999999999998", "941 14", "998 2", "1000 42", ...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
312
codeforces
Okay, I need to solve this problem where Vasya makes origami ships by repeatedly cutting squares from a rectangle. The goal is to find out how many ships he makes in total. Let's think through this step by step. So, the initial rectangle is a x b, and a >= b. The process is: each time, he cuts as many squares of size ...
To solve this problem, we need to determine how many origami ships Vasya can make by repeatedly cutting squares from a rectangular sheet of paper until only a square piece remains. The solution involves using a method similar to the Euclidean algorithm for finding the greatest common divisor (GCD), where we sum the num...
true
736d64400df84fb0b7e53e0ca922c7a8
Polycarpus' Dice
Polycarp has *n* dice *d*1,<=*d*2,<=...,<=*d**n*. The *i*-th dice shows numbers from 1 to *d**i*. Polycarp rolled all the dice and the sum of numbers they showed is *A*. Agrippina didn't see which dice showed what number, she knows only the sum *A* and the values *d*1,<=*d*2,<=...,<=*d**n*. However, she finds it enough...
{"inputs": ["2 8\n4 4", "1 3\n5", "2 3\n2 3", "1 1\n3", "1 2\n3", "2 2\n2 3", "2 4\n2 3", "3 3\n5 1 5", "3 4\n5 1 5", "3 5\n5 1 5", "3 6\n5 1 5", "3 7\n5 1 5", "3 8\n5 1 5", "3 5\n1 2 100", "10 20\n1 1 1 1 5 100 1 1 1 1", "5 50\n1 1 1 1 1000000", "5 50\n2 2 2 2 1000000", "5 50\n10 10 10 10 1000000", "10 19\n1 5 6 1 6 4...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
70
codeforces
Okay, let's see. I need to solve this problem where for each dice, I have to find the number of values that it couldn't possibly have shown, given the sum A. Hmm. Let's try to understand the problem step by step. So, the problem says that each dice i can show a number between 1 and d_i. The total sum of all dice is A....
To solve this problem, we need to determine the number of values each dice couldn't have shown given the total sum of all dice rolls. This involves calculating the minimum and maximum possible values each dice could have contributed to the sum and then determining the impossible values based on these bounds. ### Appro...
true
73844bd17524419c97f556d2c107bd32
Clothes
A little boy Gerald entered a clothes shop and found out something very unpleasant: not all clothes turns out to match. For example, Gerald noticed that he looks rather ridiculous in a smoking suit and a baseball cap. Overall the shop sells *n* clothing items, and exactly *m* pairs of clothing items match. Each item h...
{"inputs": ["3 3\n1 2 3\n1 2\n2 3\n3 1", "3 2\n2 3 4\n2 3\n2 1", "4 4\n1 1 1 1\n1 2\n2 3\n3 4\n4 1", "4 3\n10 10 5 1\n2 1\n3 1\n3 4", "4 0\n9 8 2 10", "4 3\n5 5 9 6\n3 2\n1 4\n3 4", "4 3\n5 1 10 1\n2 1\n3 2\n1 4", "4 3\n1 2 8 6\n1 3\n1 4\n3 4", "4 4\n9 3 3 1\n1 2\n3 1\n3 2\n4 3", "4 3\n6 8 10 1\n2 3\n1 4\n3 4", "4 5\n4...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
15
codeforces
Okay, let's see. I need to find three clothing items that all match each other, and their total cost is the minimum possible. If there's no such trio, output -1. Hmm. First, the input gives n items and m pairs. Each pair represents two items that match. But for three items to be a valid trio, each pair among them must...
To solve this problem, we need to find three clothing items that match each other such that their total cost is minimized. If no such trio exists, we should return -1. The solution involves checking both possible triplets of the cheapest items and common neighbors in the edges. ### Approach 1. **Input Reading and Init...
true
73ac9650486f781ac4e25a416255efdb
Cutting Carrot
Igor the analyst has adopted *n* little bunnies. As we all know, bunnies love carrots. Thus, Igor has bought a carrot to be shared between his bunnies. Igor wants to treat all the bunnies equally, and thus he wants to cut the carrot into *n* pieces of equal area. Formally, the carrot can be viewed as an isosceles tri...
{"inputs": ["3 2", "2 100000", "1000 100000", "2 1", "1000 1", "20 17", "999 1", "998 99999", "574 29184", "2 5713", "937 23565", "693 39706", "449 88550", "642 37394", "961 53535", "4 31901", "4 23850", "4 72694", "4 21538", "4 70383", "5 1", "5 1", "5 1", "5 1", "5 1", "20 1", "775 1", "531 1", "724 1", "917 1", "458...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
167
codeforces
Okay, let's see. The problem is about cutting an isosceles triangle into n pieces with equal area by making n-1 cuts parallel to the base. The base has length 1 and height h. The cuts are to be made such that each resulting piece (from the top down) has the same area. We need to find the positions of these cuts, measur...
To solve this problem, we need to determine the positions where Igor should make parallel cuts to an isosceles triangle (representing a carrot) so that each resulting piece has an equal area. The triangle has a base length of 1 and a height of h, and we need to make n-1 cuts to create n equal areas. ### Approach 1. **...
false
Code is incorrect.
73c2c373039ed01f1cd16fb20ce3d7a7
Lucky Mask
Petya loves lucky numbers very much. Everybody knows that lucky numbers are positive integers whose decimal record contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Petya calls a mask of a positive integer *n* the number that is obtained after successive writing ...
{"inputs": ["1 7", "100 47", "458 47", "7 7", "547 47", "77 77", "44 4", "740 4", "100000 77777", "77777 77777", "47 74", "74 77", "77 74", "98545 7474", "99997 4", "100000 7", "99997 47", "47774 774", "47744 7", "45896 4", "45679 77777", "99979 77", "10 77777", "1 47774", "47774 47774", "47580 47774", "55557 74", "597...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
33
codeforces
Okay, let's try to understand the problem here. So Petya needs to find the smallest number c that is greater than or equal to a, such that the mask of c equals the lucky number b. The mask is formed by taking all the lucky digits (4 and 7) in their original order from left to right. And the given b is a lucky number al...
To solve this problem, we need to find the smallest number \( c \) that is greater than or equal to a given number \( a \) such that the mask of \( c \) matches a given lucky number \( b \). The mask of a number is formed by concatenating all its lucky digits (4 and 7) in the order they appear. ### Approach 1. **Under...
false
Code is incorrect.
73c44a48d44126430dc7349b0c20f436
Magnum Opus
Salve, mi amice. Et tu quidem de lapis philosophorum. Barba non facit philosophum. Labor omnia vincit. Non potest creatio ex nihilo. Necesse est partibus. Rp:     I Aqua Fortis     I Aqua Regia     II Amalgama     VII Minium     IV Vitriol Misce in vitro et æstus, et nil admirari. Festina lente, et nulla tenaci...
{"inputs": ["2 4 6 8 10", "50 27 17 31 89", "50 87 29 81 21", "74 21 36 68 80", "75 82 48 95 12", "41 85 14 43 23", "94 28 3 29 9", "94 21 36 89 20", "60 92 82 71 53", "46 68 3 0 51", "12 39 3 50 84", "12 31 47 31 84", "79 2 93 92 16", "65 46 3 77 81", "31 38 47 26 13", "42 9 59 19 24", "51 19 70 5 78", "51 56 14 99 21...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
17
codeforces
Okay, let's try to figure out this problem. So, the input is a list of integers, and we need to output a single integer. The sample input is 2 4 6 8 10 and the output is 1. Hmm, what's the pattern here? Wait, looking at the sample input. All those numbers are even, but the output is 1. Maybe the problem is to find how...
To solve this problem, we need to determine the highest power of 2 that divides the greatest common divisor (GCD) of a list of integers. The solution involves computing the GCD of all input numbers and then finding the exponent of 2 in its prime factorization. ### Approach 1. **Compute the GCD**: The first step is to ...
false
Code is incorrect.
73d950c4bb08b0f14ae222ba7f1c8b69
Compatible Numbers
Two integers *x* and *y* are compatible, if the result of their bitwise "AND" equals zero, that is, *a* &amp; *b*<==<=0. For example, numbers 90 (10110102) and 36 (1001002) are compatible, as 10110102 &amp; 1001002<==<=02, and numbers 3 (112) and 6 (1102) are not compatible, as 112 &amp; 1102<==<=102. You are given an...
{"inputs": ["2\n90 36", "4\n3 6 3 6", "5\n10 6 9 8 2", "10\n4 9 8 3 2 6 8 2 9 7", "10\n3 5 18 12 4 20 11 19 15 6", "15\n8 4 9 3 6 6 6 6 1 6 7 1 8 9 2", "20\n280 983 126 941 167 215 868 748 383 554 917 285 43 445 331 800 527 998 503 164", "5\n1 4 2 3 5", "1\n1", "1\n4000000", "1\n2097152"], "outputs": ["36 90", "-1 -1 -...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
7
codeforces
Okay, I need to solve this problem where for each element in the array, I have to find another element that is compatible with it. Compatible here means their bitwise AND is zero. If there's no such element, output -1. Otherwise, output any one of them. Let me start by understanding the problem. For each a_i in the ar...
To solve this problem, we need to determine if each element in an array has a compatible element such that their bitwise AND operation results in zero. If such an element exists, we need to return it; otherwise, return -1. ### Approach 1. **Bitwise Compatibility Check**: Two numbers are compatible if their bitwise AND...
true
73e0e3099a08bef90835f286bcd130e8
none
One day student Vasya was sitting on a lecture and mentioned a string *s*1*s*2... *s**n*, consisting of letters "a", "b" and "c" that was written on his desk. As the lecture was boring, Vasya decided to complete the picture by composing a graph *G* with the following properties: - *G* has exactly *n* vertices, numbe...
{"inputs": ["2 1\n1 2", "4 3\n1 2\n1 3\n1 4", "4 4\n1 2\n1 3\n1 4\n3 4", "1 0", "8 28\n3 2\n4 2\n7 4\n6 3\n3 7\n8 1\n3 4\n5 1\n6 5\n5 3\n7 1\n5 8\n5 4\n6 1\n6 4\n2 1\n4 1\n8 2\n7 2\n6 8\n8 4\n6 7\n3 1\n7 8\n3 8\n5 7\n5 2\n6 2", "8 28\n3 2\n4 2\n7 4\n6 3\n3 7\n8 1\n3 4\n5 1\n6 5\n5 3\n7 1\n5 8\n5 4\n6 1\n6 4\n2 1\n4 1\n...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
12
codeforces
Okay, let's see. The problem is to determine if a given graph could have been generated by Vasya's string of a, b, c. And if so, output such a string. So the graph's edges must correspond to pairs of characters that are either equal or adjacent (a-b or b-c). First, the approach. The key is to assign each node a chara...
To solve this problem, we need to determine if a given graph could have been generated by a string of characters 'a', 'b', and 'c' such that edges exist between nodes if their characters are the same or adjacent in the alphabet. If such a string exists, we must construct it. ### Approach 1. **Identify Complete Nodes**...
false
Code is incorrect.
740f0bdf10e187653b10fb1e412b52c9
Game
Two players play a simple game. Each player is provided with a box with balls. First player's box contains exactly *n*1 balls and second player's box contains exactly *n*2 balls. In one move first player can take from 1 to *k*1 balls from his box and throw them away. Similarly, the second player can take from 1 to *k*2...
{"inputs": ["2 2 1 2", "2 1 1 1", "5 7 4 1", "5 7 1 4", "5 7 10 10", "5 7 1 10", "1 1 1 1", "50 50 50 50", "50 49 1 2", "50 48 3 1", "48 50 12 11", "49 50 11 12", "49 49 4 1", "49 49 3 3", "1 50 1 50", "1 50 50 50", "50 1 1 1", "50 1 1 50", "32 31 10 9", "32 4 17 3"], "outputs": ["Second", "First", "Second", "Second", ...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
375
codeforces
Okay, let's see. I need to solve this problem where two players are playing a game with balls in their boxes. The first player starts, and each can take between 1 to k balls from their own box each turn. The one who can't move loses. The goal is to determine who wins given n1, n2, k1, k2. Hmm, wait. The problem statem...
To solve this problem, we need to determine the winner of a game where two players take turns removing balls from their respective boxes. The first player starts, and each player can remove between 1 and a specified maximum number of balls from their own box on their turn. The player who cannot make a move loses. ###...
false
Code is incorrect.
74216fbb643744f747461380b71d0be3
Checking the Calendar
You are given names of two days of the week. Please, determine whether it is possible that during some non-leap year the first day of some month was equal to the first day of the week you are given, while the first day of the next month was equal to the second day of the week you are given. Both months should belong t...
{"inputs": ["monday\ntuesday", "sunday\nsunday", "saturday\ntuesday", "tuesday\nthursday", "friday\nwednesday", "sunday\nsaturday", "monday\nmonday", "monday\nwednesday", "monday\nthursday", "monday\nfriday", "monday\nsaturday", "monday\nsunday", "tuesday\nmonday", "tuesday\ntuesday", "tuesday\nwednesday", "tuesday\nfr...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
156
codeforces
Okay, so I need to solve this problem where I have to determine if two consecutive months in a non-leap year have their first days as the given two days. Let me think through this step by step. First, let's understand the problem. The input is two days of the week, like Monday and Tuesday. We need to check if there's ...
To solve this problem, we need to determine if there exists a pair of consecutive months in a non-leap year where the first day of the first month is the first given day of the week and the first day of the next month is the second given day of the week. ### Approach 1. **Understand the Transition**: The key insight ...
true
74244487ce06cc0da0e22a0572c585c6
Leha and Function
Leha like all kinds of strange things. Recently he liked the function *F*(*n*,<=*k*). Consider all possible *k*-element subsets of the set [1,<=2,<=...,<=*n*]. For subset find minimal element in it. *F*(*n*,<=*k*) — mathematical expectation of the minimal element among all *k*-element subsets. But only function does n...
{"inputs": ["5\n7 3 5 3 4\n2 1 3 2 3", "7\n4 6 5 8 8 2 6\n2 1 2 2 1 1 2"], "outputs": ["4 7 3 5 3", "2 6 4 5 8 8 6"]}
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
54
codeforces
Okay, let's see. The problem is about rearranging array A such that when we pair each element of the rearranged A' with the corresponding B element, the sum of F(A'_i, B_j) is maximized. And there's a condition that for all i and j, A_i >= B_j. Wait, no, wait. Wait, the problem says: "for all i, j such that 1 ≤ i, j ≤ ...
To solve this problem, we need to rearrange the elements of array A such that the sum of the mathematical expectation of the minimal element in k-element subsets (F(n, k)) for each corresponding element in array B is maximized. The key insight is that F(n, k) simplifies to (n + 1) / (k + 1), allowing us to maximize the...
true