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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1161687473cc8d5e3083ca002aaaffda | Array Queries | *a* is an array of *n* positive integers, all of which are not greater than *n*.
You have to process *q* queries to this array. Each query is represented by two numbers *p* and *k*. Several operations are performed in each query; each operation changes *p* to *p*<=+<=*a**p*<=+<=*k*. There operations are applied until ... | {"inputs": ["3\n1 1 1\n3\n1 1\n2 1\n3 1", "10\n3 5 4 3 7 10 6 7 2 3\n10\n4 5\n2 10\n4 6\n9 9\n9 2\n5 1\n6 4\n1 1\n5 6\n6 4", "50\n6 2 5 6 10 2 5 8 9 2 9 5 10 4 3 6 10 6 1 1 3 7 2 1 7 8 5 9 6 2 7 6 1 7 2 10 10 2 4 2 8 4 3 10 7 1 7 8 6 3\n50\n23 8\n12 8\n3 3\n46 3\n21 6\n7 4\n26 4\n12 1\n25 4\n18 7\n29 8\n27 5\n47 1\n50 ... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 6 | codeforces | Okay, let's see. I need to solve this programming problem where for each query, I have to compute the number of operations until p exceeds n. The operations are p = p + a_p + k. Hmm, so each step, p increases by a_p (the value at the current position) plus k. But wait, the k is fixed for the query, right? So for each q... | To solve this problem, we need to efficiently process multiple queries on an array of integers. Each query involves determining how many operations are required to move a starting position beyond the array's bounds by incrementally adding values from the array and a fixed constant. The challenge is to handle large inpu... | true | ||
116948838e1fa56269475f9485f3b01d | Shake It! | A never-ending, fast-changing and dream-like world unfolds, as the secret door opens.
A world is an unordered graph *G*, in whose vertex set *V*(*G*) there are two special vertices *s*(*G*) and *t*(*G*). An initial world has vertex set {*s*(*G*),<=*t*(*G*)} and an edge between them.
A total of *n* changes took place ... | {"inputs": ["3 2", "4 4", "7 3", "31 8", "1 1", "10 2", "33 22", "50 50", "1 2", "1 3", "2 1", "2 2", "2 3", "3 1", "3 3", "3 4", "4 1", "4 2", "4 3", "4 5", "5 1", "5 2", "5 3", "5 4", "5 5", "5 6", "6 1", "6 2", "6 3", "6 4", "6 5", "6 6", "6 7", "7 1", "7 2", "7 4", "7 5", "7 6", "7 7", "7 8", "8 5", "9 2", "10 4", ... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 1 | codeforces | Okay, let's try to tackle this problem. Hmm. So the problem is about counting the number of non-similar worlds that can be built after n changes, such that the minimum s-t cut is m. The worlds are built by adding vertices in a certain way, and we need to count them up to isomorphism that preserves s and t.
First, I n... | To solve this problem, we need to count the number of non-similar worlds that can be built under the constraints of a given number of operations and a specified minimum s-t cut. The solution involves dynamic programming to track the number of valid sequences of operations that result in the desired minimum cut.
### Ap... | false | Code is incorrect. | |
11baceb65703f5fa83aa13b9e1e98724 | Free Ice Cream | After their adventure with the magic mirror Kay and Gerda have returned home and sometimes give free ice cream to kids in the summer.
At the start of the day they have *x* ice cream packs. Since the ice cream is free, people start standing in the queue before Kay and Gerda's house even in the night. Each person in the... | {"inputs": ["5 7\n+ 5\n- 10\n- 20\n+ 40\n- 20", "5 17\n- 16\n- 2\n- 98\n+ 100\n- 98", "6 1000000000\n+ 1000000000\n+ 1000000000\n+ 1000000000\n+ 1000000000\n+ 1000000000\n+ 1000000000", "5 12\n- 12\n+ 7\n- 6\n- 1\n+ 46", "11 1000\n- 100\n+ 100\n+ 100\n+ 100\n+ 100\n- 100\n- 100\n- 100\n- 100\n- 100\n- 100", "1 0\n- 526... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 1,058 | codeforces | Okay, let's see. So the problem is about processing a queue of people who are either adding ice cream packs (carriers) or taking them (children). The initial number of ice cream packs is x. We need to track two things: the final number of ice cream packs left and the number of children who couldn't get their desired am... | To solve this problem, we need to process a queue of people who are either adding ice cream packs to Kay and Gerda's stock or attempting to take ice cream packs from them. The goal is to determine the final number of ice cream packs left and the number of children who left distressed because they couldn't get the desir... | true | ||
11bd126ec7b33ec1ee8b4f3a44b88d55 | Devu and Flowers | Devu wants to decorate his garden with flowers. He has purchased *n* boxes, where the *i*-th box contains *f**i* flowers. All flowers in a single box are of the same color (hence they are indistinguishable). Also, no two boxes have flowers of the same color.
Now Devu wants to select exactly *s* flowers from the boxes ... | {"inputs": ["2 3\n1 3", "2 4\n2 2", "3 5\n1 3 2", "2 270030023747\n891135146290 437305641972", "20 4385085334307\n273634411136 208521328637 450482376435 844118010709 197241285878 472126475472 2414038897 672334205413 809269727018 409013884362 739986692075 953956651947 462216461906 388007176838 245504550965 527140291750 ... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 1 | codeforces | Okay, let's see. So the problem is about finding the number of ways Devu can select exactly s flowers from n boxes, where each box i has f_i flowers. The answer needs to be modulo 1e9+7. Hmm.
Wait, the key here is that each box contributes some number of flowers between 0 and f_i, inclusive. And the sum of all selecte... | To solve this problem, we need to determine the number of ways Devu can select exactly `s` flowers from `n` boxes, where each box contains a specific number of flowers of a unique color. The solution must be computed modulo \(10^9 + 7\).
### Approach
1. **Problem Analysis**: The problem requires counting the number of... | true | ||
11bfc921b8411694b749730a04000c16 | Game | Vasya and Petya have invented a new game. Vasya takes a stripe consisting of 1<=×<=*n* square and paints the squares black and white. After that Petya can start moves — during a move he may choose any two neighboring squares of one color and repaint these two squares any way he wants, perhaps in different colors. Petya... | {"inputs": ["6\n111010", "5\n10001", "7\n1100010", "5\n00100", "3\n101", "6\n111111", "6\n000000", "10\n1000101001", "100\n1001001000011010001101000011100101101110101001110110010001110011011100111000010010011011101000011101", "100\n0000000000100000000000000000000000000000000000000000000000000000000000000000000000000000... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 31 | codeforces | Okay, let's see. I need to solve this problem where Petya wants to turn a stripe of black and white squares into one where no two adjacent squares are the same color. The goal is to find the minimum number of moves needed. Each move allows him to pick two adjacent squares of the same color and repaint them any way he l... | To solve this problem, we need to determine the minimum number of moves required for Petya to repaint a stripe of black and white squares such that no two adjacent squares are the same color. Each move allows Petya to choose any two adjacent squares of the same color and repaint them to any colors.
### Approach
1. **I... | false | Code is incorrect. | |
11c1c0b65c6949532970769144a92a59 | Idempotent functions | Some time ago Leonid have known about idempotent functions. Idempotent function defined on a set {1,<=2,<=...,<=*n*} is such function , that for any the formula *g*(*g*(*x*))<==<=*g*(*x*) holds.
Let's denote as *f*(*k*)(*x*) the function *f* applied *k* times to the value *x*. More formally, *f*(1)(*x*)<==<=*f*(*x*),... | {"inputs": ["4\n1 2 2 4", "3\n2 3 3", "3\n2 3 1", "1\n1", "16\n1 4 13 9 11 16 14 6 5 12 7 8 15 2 3 10", "20\n1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20", "20\n11 14 2 10 17 5 9 6 18 3 17 7 4 15 17 1 4 14 10 11", "100\n46 7 63 48 75 82 85 90 65 23 36 96 96 29 76 67 26 2 72 76 18 30 48 98 100 61 55 74 18 28 36 89... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 12 | codeforces | Okay, I need to solve this problem where I have to find the minimum k such that applying the function f k times results in an idempotent function. Let's start by understanding the problem thoroughly.
First, what's an idempotent function? Oh right, a function g is idempotent if applying it twice is the same as applying... | To solve this problem, we need to determine the minimum positive integer \( k \) such that applying the function \( f \) \( k \) times results in an idempotent function. A function \( g \) is idempotent if applying it twice is the same as applying it once, i.e., \( g(g(x)) = g(x) \) for all \( x \).
### Approach
1. **... | false | Code is incorrect. | |
11e1871581824dfb08ec542251c5ca25 | Travel Cards | In the evening Polycarp decided to analyze his today's travel expenses on public transport.
The bus system in the capital of Berland is arranged in such a way that each bus runs along the route between two stops. Each bus has no intermediate stops. So each of the buses continuously runs along the route from one stop t... | {"inputs": ["3 5 3 1 8\nBerBank University\nUniversity BerMall\nUniversity BerBank", "4 2 1 300 1000\na A\nA aa\naa AA\nAA a", "2 2 1 0 1\naca BCBA\nBCBA aca", "2 2 1 2 1\nBDDB C\nC BDDB", "2 3 1 1 9\nbacAB aAdb\nbacAB aAdb", "2 3 1 4 6\nAaCdC CdD\naBACc CdD", "1 2 1 2 1\nC BA", "1 3 1 1 4\nbCCCC BC", "1 4 3 1 1\nC bC"... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 5 | codeforces | Okay, let's see. I need to solve this programming problem. Let's read the problem carefully.
So the problem is about calculating the minimal cost Polycarp could have spent on his bus trips, considering he can buy up to k travel cards. Each travel card is for a specific bus route (which is a pair of stops in either dir... | To solve this problem, we need to determine the smallest amount of money Polycarp could have spent on his bus trips, considering he can buy up to `k` travel cards. Each travel card makes trips on a specific bus route free of charge. The solution involves calculating the initial cost without any travel cards, determinin... | true | ||
1227949a1bf9ddb09337a57819e135a2 | Exams | Vasiliy has an exam period which will continue for *n* days. He has to pass exams on *m* subjects. Subjects are numbered from 1 to *m*.
About every day we know exam for which one of *m* subjects can be passed on that day. Perhaps, some day you can't pass any exam. It is not allowed to pass more than one exam on any da... | {"inputs": ["7 2\n0 1 0 2 1 0 2\n2 1", "10 3\n0 0 1 2 3 0 2 0 1 2\n1 1 4", "5 1\n1 1 1 1 1\n5", "100 10\n1 1 6 6 6 2 5 7 6 5 3 7 10 10 8 9 7 6 9 2 6 7 8 6 7 5 2 5 10 1 10 1 8 10 2 9 7 1 6 8 3 10 9 4 4 8 8 6 6 1 5 5 6 5 6 6 6 9 4 7 5 4 6 6 1 1 2 1 8 10 6 2 1 7 2 1 8 10 9 2 7 3 1 5 10 2 8 10 10 10 8 9 5 4 6 10 8 9 6 6\n2... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 7 | codeforces | Okay, let's see. I need to solve this problem where Vasiliy has to pass all his exams within the given days, and find the minimum number of days required, or return -1 if it's impossible. Hmm.
First, let's understand the problem. So, each day he can either take an exam (if available that day), prepare for any subject,... | To solve this problem, we need to determine the minimum number of days in which Vasiliy can pass all his exams, considering the preparation days required for each subject. If it's impossible, we should return -1.
### Approach
The solution involves using a binary search approach to find the minimum number of days requi... | true | ||
1242b7a42964481d8e4bbc5e3d3435d6 | Greenhouse Effect | Emuskald is an avid horticulturist and owns the world's longest greenhouse — it is effectively infinite in length.
Over the years Emuskald has cultivated *n* plants in his greenhouse, of *m* different plant species numbered from 1 to *m*. His greenhouse is very narrow and can be viewed as an infinite line, with each p... | {"inputs": ["3 2\n2 1\n1 2.0\n1 3.100", "3 3\n1 5.0\n2 5.5\n3 6.0", "6 3\n1 14.284235\n2 17.921382\n1 20.328172\n3 20.842331\n1 25.790145\n1 27.204125", "1 1\n1 0", "8 2\n1 0.000000\n1 1.000000\n1 2.000000\n2 2.000001\n1 999999997.000000\n2 999999998.000000\n2 999999999.999999\n2 1000000000.000000", "15 5\n4 6.039627\n... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 28 | codeforces | Okay, let's see. The problem is about arranging plants in a greenhouse such that each species is in their own section. The goal is to find the minimum number of plants that need to be replanted. Hmm.
So, the greenhouse is divided into m sections with m-1 borders. Each section i must contain all plants of species i. Th... | To solve this problem, we need to determine the minimum number of plants that Emuskald needs to replant in order to arrange his greenhouse into sections where each section contains plants of a single species. The sections must be ordered from left to right by species number.
### Approach
The key insight is that the pr... | true | ||
1265110d8fb5c19020abe0903ee7b295 | LLPS | This problem's actual name, "Lexicographically Largest Palindromic Subsequence" is too long to fit into the page headline.
You are given string *s* consisting of lowercase English letters only. Find its lexicographically largest palindromic subsequence.
We'll call a non-empty string *s*[*p*1*p*2... *p**k*] = *s**p*1*... | {"inputs": ["radar", "bowwowwow", "codeforces", "mississipp", "tourist", "romka", "helloworld", "zzzzzzzazz", "testcase", "hahahahaha", "abbbbbbbbb", "zaz", "aza", "dcbaedcba", "abcdeabcd", "edcbabcde", "aaaaaaaaab", "testzzzzzz", "zzzzzzwait", "rrrrrqponm", "zzyzyy", "aababb", "zanzibar", "hhgfedcbaa", "aabcdefghh", "... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 713 | codeforces | Okay, let's see. The problem is to find the lexicographically largest palindromic subsequence of a given string. Hmm. I need to think about how to approach this.
First, I remember that a subsequence can be formed by deleting some characters from the string without changing the order. And a palindrome reads the same fo... | To solve this problem, we need to find the lexicographically largest palindromic subsequence from a given string. A palindrome reads the same forwards and backwards, and the lexicographically largest string is determined by the highest characters and their frequency.
### Approach
The key insight is that the lexicograp... | true | ||
127271f32b49adfdbf73c1c5f1ee489a | Turn the Rectangles | There are $n$ rectangles in a row. You can either turn each rectangle by $90$ degrees or leave it as it is. If you turn a rectangle, its width will be height, and its height will be width. Notice that you can turn any number of rectangles, you also can turn all or none of them. You can not change the order of the recta... | {"inputs": ["3\n3 4\n4 6\n3 5", "2\n3 4\n5 5", "10\n4 3\n1 1\n6 5\n4 5\n2 4\n9 5\n7 9\n9 2\n4 10\n10 1", "10\n241724251 76314740\n80658193 177743680\n213953908 406274173\n485639518 859188055\n103578427 56645210\n611931853 374099541\n916667853 408945969\n677773241 808703176\n575586508 440395988\n450102404 244301685", "1... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 34 | codeforces | Okay, let's try to solve this problem. So, the task is to determine if we can rotate each rectangle (or not) such that their heights form a non-ascending sequence. That is, each subsequent rectangle's height is less than or equal to the previous one.
Hmm. Let's think about the approach here. For each rectangle, we hav... | To solve this problem, we need to determine if we can rotate each rectangle such that their heights form a non-ascending sequence. This means each subsequent rectangle's height must be less than or equal to the previous one.
### Approach
1. **Initialization**: Start by reading the number of rectangles and their dimens... | true | ||
12785439f019574c6379b2557b4c2af2 | Love Triangle | As you could know there are no male planes nor female planes. However, each plane on Earth likes some other plane. There are *n* planes on Earth, numbered from 1 to *n*, and the plane with number *i* likes the plane with number *f**i*, where 1<=≤<=*f**i*<=≤<=*n* and *f**i*<=≠<=*i*.
We call a love triangle a situation ... | {"inputs": ["5\n2 4 5 1 3", "5\n5 5 5 5 1", "3\n3 1 2", "10\n4 10 9 5 3 1 5 10 6 4", "10\n5 5 4 9 10 9 9 5 3 1", "100\n50 40 60 87 39 58 44 84 46 68 16 57 77 87 92 95 42 31 74 15 36 84 30 3 47 15 87 90 76 66 6 63 74 19 40 49 6 84 41 9 77 34 7 12 11 73 58 24 81 14 81 29 65 100 1 85 64 32 38 4 54 67 32 81 80 7 100 71 29 ... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 490 | codeforces | Okay, let's see. The problem is to check if there's a love triangle among the planes. A love triangle here is when plane A likes B, B likes C, and C likes A. So we need to find three distinct planes where each one's liking forms a cycle of length exactly 3.
First, let's understand the input. The input is n planes, eac... | To solve this problem, we need to determine if there exists a love triangle among the planes. A love triangle is defined as a situation where plane A likes plane B, plane B likes plane C, and plane C likes plane A, forming a cycle of three distinct planes.
### Approach
1. **Problem Analysis**: Each plane likes exactly... | true | ||
1290054e6b5f04220016c64ece88f5db | Boy or Girl | Those days, many boys use beautiful girls' photos as avatars in forums. So it is pretty hard to tell the gender of a user at the first glance. Last year, our hero went to a forum and had a nice chat with a beauty (he thought so). After that they talked very often and eventually they became a couple in the network.
Bu... | {"inputs": ["wjmzbmr", "xiaodao", "sevenkplus", "pezu", "wnemlgppy", "zcinitufxoldnokacdvtmdohsfdjepyfioyvclhmujiqwvmudbfjzxjfqqxjmoiyxrfsbvseawwoyynn", "qsxxuoynwtebujwpxwpajitiwxaxwgbcylxneqiebzfphugwkftpaikixmumkhfbjiswmvzbtiyifbx", "qwbdfzfylckctudyjlyrtmvbidfatdoqfmrfshsqqmhzohhsczscvwzpwyoyswhktjlykumhvaounpzwpxc... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 595 | codeforces | Okay, let's see. The problem is to determine the gender based on the number of distinct characters in the username. If the count is odd, it's male; otherwise, female. So I need to write a Python function that reads a string from stdin and outputs the correct message.
First, I need to find out how many distinct charact... | To solve this problem, we need to determine the gender of a user based on their username using a specific method. The method states that if the number of distinct characters in the username is odd, the user is male; otherwise, the user is female.
### Approach
1. **Input Reading**: Read the username from the standard i... | true | ||
12ac6ee7b374eaba6ddb61a68ebddee3 | Reberland Linguistics | First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other.
For example, you should know l... | {"inputs": ["abacabaca", "abaca", "gzqgchv", "iosdwvzerqfi", "oawtxikrpvfuzugjweki", "abcdexyzzzz", "affviytdmexpwfqplpyrlniprbdphrcwlboacoqec", "lmnxtobrknqjvnzwadpccrlvisxyqbxxmghvl", "tbdbdpkluawodlrwldjgplbiylrhuywkhafbkiuoppzsjxwbaqqiwagprqtoauowtaexrhbmctcxwpmplkyjnpwukzwqrqpv", "caqmjjtwmqxytcsawfufvlofqcqdwnyvy... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 22 | codeforces | Okay, so I need to solve this problem where I have to find all possible suffixes of a given word according to the Reberland language rules. Let's read the problem statement carefully.
The rules say that the word is formed by a root (longer than 4 letters) followed by some suffixes. Each suffix must be 2 or 3 character... | To solve this problem, we need to identify all distinct suffixes of a given word according to the rules of the Reberland language. The suffixes must be 2 or 3 characters long, and consecutive suffixes in the word must not be the same. The solution involves dynamic programming to efficiently determine valid suffixes and... | false | Code is incorrect. | |
12be6f6b6f79389b9d1b141176a2b327 | Unordered Subsequence | The sequence is called ordered if it is non-decreasing or non-increasing. For example, sequnces [3, 1, 1, 0] and [1, 2, 3, 100] are ordered, but the sequence [1, 3, 3, 1] is not. You are given a sequence of numbers. You are to find it's shortest subsequence which is not ordered.
A subsequence is a sequence that can be... | {"inputs": ["3\n3 1 2", "1\n-895376", "2\n166442 61629", "3\n-771740 -255752 -300809", "4\n-227347 -573134 -671045 11011", "5\n834472 -373089 441294 -633071 -957672", "2\n7 8"], "outputs": ["3\n1 2 3", "0", "0", "3\n1 2 3", "3\n2 3 4", "3\n1 2 3", "0"]} | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 20 | codeforces | Okay, let's tackle this problem. The task is to find the shortest subsequence in a given sequence that is not ordered (i.e., it's neither non-decreasing nor non-increasing). If there's no such subsequence, output 0. Otherwise, output the length and the indices of the elements in the subsequence.
Hmm. So, the first thi... | To solve this problem, we need to determine the shortest subsequence of a given sequence that is neither non-decreasing nor non-increasing. If such a subsequence does not exist, we should output 0. Otherwise, we should output the length of the shortest such subsequence and the indices of its elements.
### Approach
1. ... | false | Code is incorrect. | |
12d93ca6906e39940b5ee321de7f9ae7 | Postcards and photos | Polycarpus has postcards and photos hung in a row on the wall. He decided to put them away to the closet and hang on the wall a famous painter's picture. Polycarpus does it like that: he goes from the left to the right and removes the objects consecutively. As Polycarpus doesn't want any mix-ups to happen, he will not ... | {"inputs": ["CPCPCPC", "CCCCCCPPPPPP", "CCCCCCPPCPPPPPPPPPP", "CCCCCCCCCC", "CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC", "CPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCPCP", "CCCCCCPPPPPPCCCCCCPPPPPPCCCCCCPPPPP... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 133 | codeforces | Okay, let's see. The problem is about Polycarpus removing postcards (C) and photos (P) from the wall, and needing to determine the minimum number of times he has to visit the closet. The constraints are that he can't carry more than 5 items at once, and he can't carry both types at the same time. So, he has to make tri... | To solve this problem, we need to determine the minimum number of times Polycarpus must visit the closet to store all postcards (C) and photos (P) from the wall. The constraints are that he can carry at most 5 items at once and cannot carry both postcards and photos simultaneously.
### Approach
1. **Initialization**: ... | false | Code is incorrect. | |
13056962b3f1cb803ad09d79e4bde485 | Primes on Interval | You've decided to carry out a survey in the theory of prime numbers. Let us remind you that a prime number is a positive integer that has exactly two distinct positive integer divisors.
Consider positive integers *a*, *a*<=+<=1, ..., *b* (*a*<=≤<=*b*). You want to find the minimum integer *l* (1<=≤<=*l*<=≤<=*b*<=-<=*a... | {"inputs": ["2 4 2", "6 13 1", "1 4 3", "5 8 2", "8 10 3", "1 5 2", "6 8 3", "21 29 2", "17 27 3", "1 1000000 10000", "690059 708971 10000", "12357 534133 2", "838069 936843 3", "339554 696485 4", "225912 522197 5", "404430 864261 6", "689973 807140 7", "177146 548389 8", "579857 857749 9", "35648 527231 10", "2 100000... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 27 | codeforces | Okay, I need to solve this problem where I have to find the minimum length l such that for every x in the range a to b - l + 1, the subrange x to x + l -1 has at least k primes. And if there's no such l, return -1. Hmm, let's think about how to approach this.
First, the problem is about primes in intervals. So I need ... | To solve this problem, we need to find the minimum length \( l \) such that every interval of length \( l \) within the range \([a, b]\) contains at least \( k \) prime numbers. If no such \( l \) exists, we return -1.
### Approach
1. **Generate Primes Using Sieve of Eratosthenes**: This helps in efficiently determini... | true | ||
1334299b4247da2d1bdae5974c6fcb0f | Red and Blue Balls | User ainta has a stack of *n* red and blue balls. He can apply a certain operation which changes the colors of the balls inside the stack.
- While the top ball inside the stack is red, pop the ball from the top of the stack. - Then replace the blue ball on the top with a red ball. - And finally push some blue balls... | {"inputs": ["3\nRBR", "4\nRBBR", "5\nRBBRR", "5\nRBRBR", "10\nRRBRRBBRRR", "10\nBRBRRRRRRR", "10\nBRRRRRRRRR", "20\nBRBRRRRRRRRRRRRRRRRR", "30\nRRBBBBBBBBBBBBBBBBBBBBBBBBBBBB", "50\nBRRRBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB", "20\nRRRBRBBBBBRRRRRRRRRR", "20\nRRBRBBBBBRRRRRRRRRRR", "1\nR", "1\nB", "2\nRR", "2\n... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 64 | codeforces | Okay, let's try to understand this problem. So, the task is to find the maximum number of operations Ainta can perform on a stack of red and blue balls. The operations are a bit tricky, so let's break them down step by step.
First, let's restate the operation steps to make sure I get them right. The operation goes lik... | To solve this problem, we need to determine the maximum number of operations Ainta can perform on a stack of red (R) and blue (B) balls, following specific rules. The key insight is to model each operation as incrementing a binary number where each blue ball contributes a value based on its position.
### Approach
1. *... | false | Code is incorrect. | |
13448478d4e49c8e2d1caa3ff518b3c1 | Valera and Antique Items | Valera is a collector. Once he wanted to expand his collection with exactly one antique item.
Valera knows *n* sellers of antiques, the *i*-th of them auctioned *k**i* items. Currently the auction price of the *j*-th object of the *i*-th seller is *s**ij*. Valera gets on well with each of the *n* sellers. He is perfec... | {"inputs": ["3 50000\n1 40000\n2 20000 60000\n3 10000 70000 190000", "3 50000\n1 50000\n3 100000 120000 110000\n3 120000 110000 120000", "2 100001\n1 895737\n1 541571", "1 1000000\n1 1000000", "1 1000000\n1 561774", "3 1000000\n5 1000000 568832 1000000 1000000 1000000\n13 1000000 1000000 1000000 596527 1000000 1000000 ... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 294 | codeforces | Okay, I need to solve this programming problem. Let's read the problem carefully.
So Valera wants to buy exactly one item from each of the n sellers. But he can only do that if he can outbid at least one item from a seller. The question is, for each seller, check if there's any item whose price is strictly less than V... | To solve this problem, Valera needs to determine which sellers he can make a deal with by outbidding at least one item from each seller using his available money. The goal is to identify the sellers who have at least one item priced lower than Valera's available funds, allowing him to place a higher bid within his budg... | true | ||
134adde1602a65ae3022bdcfbb7f3925 | Life Without Zeros | Can you imagine our life if we removed all zeros from it? For sure we will have many problems.
In this problem we will have a simple example if we removed all zeros from our life, it's the addition operation. Let's assume you are given this equation *a*<=+<=*b*<==<=*c*, where *a* and *b* are positive integers, and *c*... | {"inputs": ["101\n102", "105\n106", "544\n397", "822\n280", "101\n413", "309\n139", "693\n970", "981\n1", "352\n276", "164\n691", "110036\n43", "100\n1000", "1000000000\n1000000000", "999999999\n999999999", "6\n4", "123456\n876543", "1234567\n9876543", "1111111\n1119111", "10502405\n40403403", "1\n1", "5\n4", "1\n6", "... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 625 | codeforces | Okay, let's see. So the problem is about removing all zeros from the numbers in an equation a + b = c, and checking if the equation still holds after that. Hmm.
Wait, the input gives a and b. So first, I need to compute c as a + b. Then, remove all zeros from a, b, and c, and check if the sum of the modified a and mod... | To solve this problem, we need to determine if an equation remains valid after removing all zeros from the numbers involved. The equation is given as \( a + b = c \), where \( c \) is the sum of \( a \) and \( b \). We need to check if the equation still holds true when all zeros are removed from \( a \), \( b \), and ... | true | ||
134e58b9e1ffbdb158576f17eed68543 | Substring and Subsequence | One day Polycarpus got hold of two non-empty strings *s* and *t*, consisting of lowercase Latin letters. Polycarpus is quite good with strings, so he immediately wondered, how many different pairs of "*x* *y*" are there, such that *x* is a substring of string *s*, *y* is a subsequence of string *t*, and the content of ... | {"inputs": ["aa\naa", "codeforces\nforceofcode", "coderscontest\ncodeforces", "a\nb", "ab\nbbbba", "abbbccbba\nabcabc", "zxzxzxzxzxzxzx\nd", "pfdempfohomnpgbeegikfmflnalbbajpnpgeacaicoehopgnabnklheepnlnflohjegcciflmfjhachnhekckfjgoffhkblncidn\nidlhklpclcghngeggpjdgefccihndpoikojdjnbkdfjgaanoolfmnifnmbpeeghpicehjdiipnlf... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 1 | codeforces | Okay, let's tackle this problem. Hmm, the task is to find the number of different pairs (x, y) where x is a substring of s, y is a subsequence of t, and x and y are the same string. Oh right, and we have to count all possible such pairs, considering different positions as different even if the content is the same.
So... | To solve this problem, we need to count the number of pairs (x, y) where x is a substring of string s and y is a subsequence of string t such that the content of x and y is the same. The solution involves generating all possible substrings of s, counting their occurrences, and then determining how many times each of th... | true | ||
13b28296e941bf4b38a92e234423bc69 | Resort | Valera's finally decided to go on holiday! He packed up and headed for a ski resort.
Valera's fancied a ski trip but he soon realized that he could get lost in this new place. Somebody gave him a useful hint: the resort has *n* objects (we will consider the objects indexed in some way by integers from 1 to *n*), each ... | {"inputs": ["5\n0 0 0 0 1\n0 1 2 3 4", "5\n0 0 1 0 1\n0 1 2 2 4", "4\n1 0 0 0\n2 3 4 2", "10\n0 0 0 0 0 0 0 0 0 1\n4 0 8 4 7 8 5 5 7 2", "50\n0 0 0 0 0 0 0 0 0 0 1 0 1 0 0 1 1 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 0 0 1 1 0 0 0 1 0\n28 4 33 22 4 35 36 31 42 25 50 33 25 36 18 23 23 28 43 3 18 31 1 2 15 22 40 4... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 15 | codeforces | Okay, I need to solve this programming problem. Let's read the problem statement carefully.
So Valera is at a ski resort with n objects. Each object is either a hotel or a mountain. The ski tracks are such that each object v has at most one u where there's a track from u to v. Also, no hotel has a track leading out of... | To solve this problem, we need to find the longest possible path in a ski resort where Valera can ski from a mountain to a hotel, following the ski tracks. The path must start at a mountain and end at a hotel, with each intermediate mountain having exactly one outgoing ski track leading to the next object in the path.
... | true | ||
13b7ef974745d76a78439919a6ed01eb | Mike and gcd problem | Mike has a sequence *A*<==<=[*a*1,<=*a*2,<=...,<=*a**n*] of length *n*. He considers the sequence *B*<==<=[*b*1,<=*b*2,<=...,<=*b**n*] beautiful if the *gcd* of all its elements is bigger than 1, i.e. .
Mike wants to change his sequence in order to make it beautiful. In one move he can choose an index *i* (1<=≤<=*i*<... | {"inputs": ["2\n1 1", "3\n6 2 4", "2\n1 3", "9\n57 30 28 81 88 32 3 42 25", "2\n8 77", "4\n92 46 3 21", "2\n78 26", "2\n3 6", "2\n3 9", "2\n3 3", "3\n3 6 3", "3\n3 9 15", "3\n3 6 9", "3\n3 3 3", "3\n3 9 18", "5\n1 2 1 2 1", "2\n9 6", "4\n3 6 9 12", "3\n3 9 27", "3\n3 9 12", "5\n6 6 9 15 21", "2\n5 15", "4\n2 3 9 13", "... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 5 | codeforces | Okay, let's try to figure out this problem. So the task is to determine the minimal number of operations needed to make a sequence's GCD greater than 1. If it's possible, we output "YES" and the number of steps; otherwise, "NO".
Hmm, the operation allowed is to replace two elements a_i and a_{i+1} with three elements:... | To solve this problem, we need to determine the minimal number of operations required to transform a given sequence such that the greatest common divisor (GCD) of all its elements is greater than 1. If it's impossible to achieve this, we should return "NO".
### Approach
1. **Initial GCD Check**: First, we check if the... | false | Code is incorrect. | |
13bdb1f2506b952ef6004ba0c77808ec | Inbox (100500) | Over time, Alexey's mail box got littered with too many letters. Some of them are read, while others are unread.
Alexey's mail program can either show a list of all letters or show the content of a single letter. As soon as the program shows the content of an unread letter, it becomes read letter (if the program shows... | {"inputs": ["5\n0 1 0 1 0", "5\n1 1 0 0 1", "2\n0 0", "9\n1 0 1 0 1 0 1 0 1", "5\n1 1 1 1 1", "14\n0 0 1 1 1 0 1 1 1 0 1 1 1 0", "23\n1 1 1 0 1 1 0 1 1 0 1 1 1 0 1 1 0 1 1 0 1 1 1", "27\n0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0", "10\n1 0 0 0 0 1 0 0 0 1", "10\n1 0 0 1 0 0 1 1 0 1", "27\n0 0 0 0 0 0 0 0 0 ... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 209 | codeforces | Okay, I need to solve this programming problem. Let's read the problem carefully.
So the problem is about Alexey wanting to read all his unread letters with the minimum number of operations. The operations allowed are moving between the list and a letter, moving between letters (next or previous), and each time he vie... | To solve this problem, we need to determine the minimum number of operations Alexey needs to perform to read all unread letters in his mailbox. The operations allowed include moving between the list of letters and individual letters, as well as navigating between consecutive letters.
### Approach
1. **Identify Cluster... | true | ||
13cbed0d2f029102bb46ecec65fe6d8d | Switches and Lamps | You are given *n* switches and *m* lamps. The *i*-th switch turns on some subset of the lamps. This information is given as the matrix *a* consisting of *n* rows and *m* columns where *a**i*,<=*j*<==<=1 if the *i*-th switch turns on the *j*-th lamp and *a**i*,<=*j*<==<=0 if the *i*-th switch is not connected to the *j*... | {"inputs": ["4 5\n10101\n01000\n00111\n10000", "4 5\n10100\n01000\n00110\n00101", "1 5\n11111", "10 1\n1\n0\n0\n0\n0\n0\n0\n0\n0\n1", "1 1\n1", "3 4\n1010\n0100\n1101", "2 5\n10101\n11111", "5 5\n10000\n11000\n11100\n11110\n11111", "2 5\n10000\n11111", "4 5\n01000\n10100\n00010\n10101", "2 2\n10\n11", "2 5\n00100\n1111... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 99 | codeforces | Okay, so I have this programming problem to solve, and I need to figure out how to approach it. Let me read the problem carefully.
The problem is about switches and lamps. We have n switches and m lamps. Each switch can turn on some subset of lamps. The matrix a tells us which switch affects which lamp. The key points... | To solve this problem, we need to determine if there exists a switch that can be ignored such that pressing all the remaining switches still turns on all the lamps.
### Approach
The key insight is to identify if there is any switch that is not the sole provider for any lamp. If such a switch exists, it can be safely ... | true | ||
13ced2a3d8b5a62401f7b011c2f5576b | Simba on the Circle | You are given a circular array with *n* elements. The elements are numbered from some element with values from 1 to *n* in clockwise order. The *i*-th cell contains the value *a**i*. The robot Simba is in cell *s*.
Each moment of time the robot is in some of the *n* cells (at the begin he is in *s*). In one turn the r... | {"inputs": ["9 1\n0 1 2 2 2 1 0 1 1", "8 1\n0 1 0 1 0 1 0 1", "8 1\n1 2 3 4 5 6 7 8", "8 1\n0 0 0 0 0 0 0 0", "8 1\n0 1 2 2 1 0 1 1", "1 1\n4", "10 1\n-1 0 1 0 -1 1 0 0 1 -1", "20 7\n0 6 0 0 0 -7 -8 9 -7 4 7 2 -4 4 -5 2 6 8 -2 -7", "30 13\n68 50 99 23 84 23 24 -42 82 36 -10 -51 -96 96 19 -4 4 -41 74 92 13 58 26 79 -11 ... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 1 | codeforces | Okay, let's see. I need to solve this problem where a robot has to collect all the numbers in a circular array such that they are written in non-decreasing order, and the total time (movement) is minimized. The robot starts at position s, and each move to an adjacent cell takes 1 unit of time. Writing the numbers doesn... | To solve this problem, we need to determine the minimal time required for the robot Simba to visit each cell in a circular array such that the numbers written in each cell are collected in non-decreasing order. The robot can move clockwise or counter-clockwise, and each movement between adjacent cells takes one unit of... | false | Code is incorrect. | |
13d695394072750e82992d500f1bcc2c | Garden | Luba thinks about watering her garden. The garden can be represented as a segment of length *k*. Luba has got *n* buckets, the *i*-th bucket allows her to water some continuous subsegment of garden of length exactly *a**i* each hour. Luba can't water any parts of the garden that were already watered, also she can't wat... | {"inputs": ["3 6\n2 3 5", "6 7\n1 2 3 4 5 6", "5 97\n1 10 50 97 2", "5 97\n1 10 50 100 2", "100 100\n2 46 24 18 86 90 31 38 84 49 58 28 15 80 14 24 87 56 62 87 41 87 55 71 87 32 41 56 91 32 24 75 43 42 35 30 72 53 31 26 54 61 87 85 36 75 44 31 7 38 77 57 61 54 70 77 45 96 39 57 11 8 91 42 52 15 42 30 92 41 27 26 34 27 ... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 379 | codeforces | Okay, let's see. The problem is about Luba watering her garden, which is a segment of length k. She has n buckets, each can water a continuous subsegment of exactly a_i length each hour. The goal is to choose one bucket and find the minimum hours needed to water the entire garden. And we can't overlap or go outside, ri... | To solve this problem, we need to determine the minimum number of hours Luba needs to water her garden using one of her buckets. Each bucket can water a continuous subsegment of the garden of a specific length each hour, and Luba can only use one bucket type for the entire task. The solution involves identifying the op... | true | ||
1406f44b358d0fb8fc59355a2bc1ea3e | Binary Table | You are given a table consisting of *n* rows and *m* columns. Each cell of the table contains either 0 or 1. In one move, you are allowed to pick any row or any column and invert all values, that is, replace 0 by 1 and vice versa.
What is the minimum number of cells with value 1 you can get after applying some number ... | {"inputs": ["3 4\n0110\n1010\n0111", "1 1\n0", "1 1\n1", "2 1\n0\n1", "1 2\n10", "2 2\n01\n10", "2 2\n11\n10", "2 2\n00\n00", "2 2\n00\n11", "3 3\n100\n010\n001", "3 9\n010100100\n101011011\n101011101", "8 3\n000\n001\n010\n100\n110\n011\n101\n111", "1 10\n0110010001", "9 1\n0\n1\n1\n0\n1\n0\n1\n0\n1", "4 5\n01010\n101... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 1 | codeforces | Okay, let's see. The problem is about flipping rows and columns in a binary matrix to minimize the number of 1s. Hmm. So each move can flip an entire row or column. And I need to find the minimal possible number of 1s after some operations.
First, I need to understand how flipping affects the cells. If I flip a row, ... | To solve this problem, we need to minimize the number of 1s in a binary matrix after performing a series of row and column flips. Each flip operation inverts all values in a row or a column (0 becomes 1 and vice versa). The challenge is to determine the optimal sequence of flips to achieve the minimum number of 1s.
##... | true | ||
141fac17f61c95c45f5139058556a5cd | Four Segments | You are given an array of *n* integer numbers. Let *sum*(*l*,<=*r*) be the sum of all numbers on positions from *l* to *r* non-inclusive (*l*-th element is counted, *r*-th element is not counted). For indices *l* and *r* holds 0<=≤<=*l*<=≤<=*r*<=≤<=*n*. Indices in array are numbered from 0.
For example, if *a*<==<=[<... | {"inputs": ["3\n-1 2 3", "4\n0 0 -1 0", "1\n10000", "1\n-1", "1\n0", "10\n0 0 0 0 0 0 0 0 0 0", "100\n-1 -1 0 1 -1 0 0 -1 -1 1 1 0 1 0 -1 1 0 0 -1 0 0 0 1 0 0 1 1 1 1 0 -1 -1 0 0 0 1 1 -1 0 0 1 1 1 0 -1 -1 0 -1 0 -1 -1 0 1 0 1 -1 1 -1 -1 -1 0 0 -1 0 -1 -1 0 -1 1 1 -1 1 0 1 -1 -1 1 1 -1 1 0 -1 1 -1 1 1 1 1 1 -1 0 1 0 0 ... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 15 | codeforces | Okay, I need to solve this problem where I have to find three delimiters in an array to maximize a certain value called res. The res is calculated as sum(0, d0) - sum(d0, d1) + sum(d1, d2) - sum(d2, n). Hmm, let's break this down.
First, I should understand what the sum function represents. The sum from l to r is the ... | To solve this problem, we need to find three delimiters in an array that maximize a specific value calculated using sums of segments of the array. The optimal solution involves using prefix sums and precomputing maximum values to efficiently determine the best delimiters.
### Approach
1. **Prefix Sum Calculation**: Co... | false | Code is incorrect. | |
14224c4b4244d0fe292621f678e1422f | none | From beginning till end, this message has been waiting to be conveyed.
For a given unordered multiset of *n* lowercase English letters ("multi" means that a letter may appear more than once), we treat all letters as strings of length 1, and repeat the following operation *n*<=-<=1 times:
- Remove any two elements *s... | {"inputs": ["12", "3", "0", "2", "5", "10", "233", "418", "100000", "1", "4", "6", "7", "8", "9", "11", "1317", "1926", "14514", "25252", "99681", "99998", "82944", "831", "39393"], "outputs": ["abababab", "codeforces", "o", "aabb", "aaabbcc", "aaaaa", "ooououououououououooohhhhhhaaiiiiiibbjjjjjjcckkkkkkddlllllleemmmmm... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 35 | codeforces | Okay, let's try to understand this problem. So, the task is to generate a string (which represents a multiset of characters) such that when we perform a series of concatenation operations, the minimum total cost is exactly k.
Wait, the problem says that the process is done n-1 times for a multiset of n elements. Each... | To solve this problem, we need to generate a string representing a multiset of lowercase English letters such that the minimum accumulative cost of concatenating the elements of the multiset is exactly a given non-negative integer \( k \). The key insight is that the minimum cost is determined by the sum of triangular ... | false | Code is incorrect. | |
142ca9504dab57200c552d5380ecc69f | Almost Acyclic Graph | You are given a [directed graph](https://en.wikipedia.org/wiki/Directed_graph) consisting of *n* vertices and *m* edges (each edge is directed, so it can be traversed in only one direction). You are allowed to remove at most one edge from it.
Can you make this graph [acyclic](https://en.wikipedia.org/wiki/Directed_acy... | {"inputs": ["3 4\n1 2\n2 3\n3 2\n3 1", "5 6\n1 2\n2 3\n3 2\n3 1\n2 1\n4 5", "2 2\n1 2\n2 1", "7 7\n1 3\n3 6\n3 7\n5 3\n6 2\n6 7\n7 2", "500 50\n396 340\n47 341\n422 140\n492 209\n263 248\n461 300\n124 495\n33 6\n93 384\n389 182\n130 297\n217 329\n131 136\n355 94\n388 275\n115 368\n279 462\n126 285\n185 287\n223 221\n20... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 6 | codeforces | Okay, let's tackle this problem. The task is to determine whether removing at most one edge from a directed graph can make it acyclic. If yes, output YES; otherwise, NO. Hmm, how to approach this?
First, I remember that a directed acyclic graph (DAG) has no cycles. So, the original graph might already have cycles. Our... | To solve this problem, we need to determine if we can make a directed graph acyclic by removing at most one edge. If possible, we output "YES"; otherwise, we output "NO".
### Approach
1. **Check if the Graph is Already Acyclic**: Use a topological sort to check if the graph is a Directed Acyclic Graph (DAG). If it is,... | true | ||
143975608b5342cde4acac925204f195 | Little Elephant and Interval | The Little Elephant very much loves sums on intervals.
This time he has a pair of integers *l* and *r* (*l*<=≤<=*r*). The Little Elephant has to find the number of such integers *x* (*l*<=≤<=*x*<=≤<=*r*), that the first digit of integer *x* equals the last one (in decimal notation). For example, such numbers as 101, 4... | {"inputs": ["2 47", "47 1024", "1 1000", "1 10000", "47 8545", "1000 1000", "47547 4587554587754542", "1 1000000", "47 74", "10001 10000002", "10000 100000", "458754 4588754", "111 111", "110 147", "1 1000000000", "12 10000000000", "1000000000 1000000000", "1 1000000000000000000", "11 111111111111111100", "100000000000... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 52 | codeforces | Okay, let's see. The problem is to count the numbers between l and r (inclusive) where the first digit equals the last digit. Hmm. So for example, 101 is valid because first and last are 1. But 47 isn't because starts with 4 and ends with 7.
First, I need to figure out how to check if a number's first and last digits ... | To solve this problem, we need to count the numbers within a given interval [l, r] where the first digit is equal to the last digit. Given the constraints where l and r can be as large as 10^18, a brute force approach is impractical. Instead, we use a mathematical approach to efficiently compute the count of valid numb... | true | ||
143bfa7b8d53e4b19209a18df9563490 | "Or" Game | You are given *n* numbers *a*1,<=*a*2,<=...,<=*a**n*. You can perform at most *k* operations. For each operation you can multiply one of the numbers by *x*. We want to make as large as possible, where denotes the bitwise OR.
Find the maximum possible value of after performing at most *k* operations optimally.
The ... | {"inputs": ["3 1 2\n1 1 1", "4 2 3\n1 2 4 8", "2 1 2\n12 9", "2 1 2\n12 7", "3 1 3\n3 2 0", "5 10 8\n1000000000 1000000000 1000000000 1000000000 1000000000", "1 2 3\n612635770", "3 2 5\n0 2 3", "2 1 8\n18 17", "5 10 8\n0 0 0 0 0", "1 1 2\n1", "1 1 2\n0", "3 2 6\n724148075 828984987 810015532", "3 1 2\n17 18 4", "3 1 2\... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 22 | codeforces | Okay, let's see. The problem is to maximize the bitwise OR of a list of numbers after performing up to k operations. Each operation allows us to multiply a number by x. We can do this at most k times. Hmm.
First, I need to figure out how the operations affect the OR. Since the OR is a bitwise operation, each bit in th... | To solve this problem, we need to maximize the bitwise OR of a sequence of numbers after performing up to `k` operations where each operation involves multiplying a number by `x`. The goal is to determine the optimal way to apply these operations to achieve the highest possible OR value.
### Approach
1. **Precompute P... | false | Code is incorrect. | |
1450da53095949ecb270a669f433444e | Hopscotch | So nearly half of the winter is over and Maria is dreaming about summer. She's fed up with skates and sleds, she was dreaming about Hopscotch all night long. It's a very popular children's game. The game field, the court, looks as is shown in the figure (all blocks are square and are numbered from bottom to top, blocks... | {"inputs": ["1 0 0", "3 1 1", "3 0 10", "3 0 7", "3 4 0", "9 3 2", "100 0 953748", "17 0 1000000", "17 15 99999", "55 -20 1000000", "1 154871 37516", "1 -1 0", "1 -1 1", "1 0 2", "1 0 552012", "1 1 293372", "1 -1 551084", "5 -744240 145890", "5 -4 2", "5 -5 7", "5 -3 14", "5 0 660386", "5 5 918098", "5 -5 659458", "10 ... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 2 | codeforces | Okay, I need to solve this problem where Maria throws a stone into a coordinate system based on a hopscotch court. The goal is to determine which square the stone lands in, or -1 if it's on a border or outside. Let's think through this step by step.
First, let's understand the structure of the court. The pattern of ro... | To solve this problem, we need to determine if a stone thrown by Maria lands inside a square on a hopscotch court and, if so, identify which square it lands in. The court has a specific pattern of rows with varying numbers of squares, and the stone must be strictly inside a square to count.
### Approach
1. **Identify ... | true | ||
1462cea6e0234917f31a0424b8da0329 | none | Levko has an array that consists of integers: *a*1,<=*a*2,<=... ,<=*a**n*. But he doesn’t like this array at all.
Levko thinks that the beauty of the array *a* directly depends on value *c*(*a*), which can be calculated by the formula:
It’s time to change the world and Levko is going to change his array for the bett... | {"inputs": ["5 2\n4 7 4 7 4", "3 1\n-100 0 100", "6 3\n1 2 3 7 8 9", "4 1\n-1000000000 -1000000000 1000000000 1000000000", "10 1\n-6 5 -7 -7 -7 -7 5 -9 4 7", "20 17\n-5 -9 11 -7 -17 -8 0 -14 -20 -15 7 -13 0 -3 -14 0 9 -10 6 -19", "5 1\n-1000000000 1000000000 -1000000000 1000000000 -1000000000", "16 13\n441427217 689669... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 1 | codeforces | Okay, I need to solve this programming problem. Let's start by understanding the problem statement carefully.
So Levko has an array a, and the beauty is determined by c(a), which is the maximum value of the ceiling of (|a_i - a_j|) divided by (|i - j|) for all i and j where i != j. Wait, wait. Wait, the problem says t... | To solve this problem, we need to determine the minimum possible value of the maximum ceiling of the absolute differences between any two elements divided by their distance in the array after changing at most `k` elements. The key insight is that this problem can be transformed into finding the minimum possible maximum... | false | Code is incorrect. | |
1470983329ca5e3a2c6705a82cd173d6 | List Of Integers | Let's denote as *L*(*x*,<=*p*) an infinite sequence of integers *y* such that *gcd*(*p*,<=*y*)<==<=1 and *y*<=><=*x* (where *gcd* is the greatest common divisor of two integer numbers), sorted in ascending order. The elements of *L*(*x*,<=*p*) are 1-indexed; for example, 9, 13 and 15 are the first, the second and th... | {"inputs": ["3\n7 22 1\n7 22 2\n7 22 3", "5\n42 42 42\n43 43 43\n44 44 44\n45 45 45\n46 46 46"], "outputs": ["9\n13\n15", "187\n87\n139\n128\n141"]} | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 3 | codeforces | Okay, let's try to figure out how to solve this problem. So the problem is about finding the k-th element in this sequence L(x, p), which consists of numbers y that are greater than or equal to x, coprime with p, and sorted in ascending order. The challenge is to process multiple queries efficiently, especially given t... | To solve this problem, we need to find the k-th element in a sequence of integers greater than a given value x that are coprime with a given integer p. The sequence is sorted in ascending order. The solution must efficiently handle multiple queries, each with different values of x, p, and k.
### Approach
1. **Precompu... | true | ||
1478c482a3296de529bb34c0e7e351e4 | Ithea Plays With Chtholly | This is an interactive problem. Refer to the Interaction section below for better understanding.
Ithea and Chtholly want to play a game in order to determine who can use the kitchen tonight.
Initially, Ithea puts *n* clear sheets of paper in a line. They are numbered from 1 to *n* from left to right.
This game wil... | {"inputs": ["2 4 4\n2\n1\n3\n4", "2 2 2\n1\n2", "3 6 3\n1\n2\n1\n3\n1\n3", "4 8 4\n4\n4\n4\n4\n4\n4\n4\n4", "10 120 15\n6\n11\n9\n11\n3\n12\n11\n12\n2\n8\n3\n11\n13\n5\n12\n11\n9\n3\n10\n9\n9\n13\n13\n5\n6\n11\n3\n15\n8\n8\n10\n13\n7\n6\n4\n14\n9\n10\n5\n13\n4\n1\n8\n6\n13\n1\n3\n4\n9\n12\n2\n7\n3\n3\n7\n2\n2\n9\n2\n4\... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 5 | 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 a game between Ithea and Chtholly. The game involves n sheets arranged in a line. Each round, Ithea gives a number between 1 and c, and Chtholly writes it on one sheet. The goal is t... | To solve this problem, we need to help Chtholly win the game by writing numbers on sheets such that at any point, all sheets are filled and the numbers are in non-decreasing order. The solution involves strategically placing each number given by Ithea in the correct position to maintain the possibility of forming a non... | false | Code is incorrect. | |
1488e9b4a9ebd590be12f7ea2251d7c8 | Karen and Test | Karen has just arrived at school, and she has a math test today!
The test is about basic addition and subtraction. Unfortunately, the teachers were too busy writing tasks for Codeforces rounds, and had no time to make an actual test. So, they just put one question in the test that is worth all the points.
There are *... | {"inputs": ["5\n3 6 9 12 15", "4\n3 7 5 2", "1\n1", "16\n985629174 189232688 48695377 692426437 952164554 243460498 173956955 210310239 237322183 96515847 678847559 682240199 498792552 208770488 736004147 176573082", "18\n341796022 486073481 86513380 593942288 60606166 627385348 778725113 896678215 384223198 661124212 ... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 1 | codeforces | Okay, let's see. The problem is about performing alternating addition and subtraction on adjacent elements in each row until only one number remains. The first operation is addition. Then, for the next row, if the previous ended with addition, the next starts with subtraction, and so on. We need to find the final numbe... | To solve this problem, we need to determine the final integer remaining after alternately adding and subtracting adjacent pairs of integers in a row, starting with addition. The process is repeated on the resulting row until only one integer remains. The result should be given modulo \(10^9 + 7\).
### Approach
1. **Un... | false | Code is incorrect. | |
148e34843e6ea7ff1682255785649209 | Dorm Water Supply | The German University in Cairo (GUC) dorm houses are numbered from 1 to *n*. Underground water pipes connect these houses together. Each pipe has certain direction (water can flow only in this direction and not vice versa), and diameter (which characterizes the maximal amount of water it can handle).
For each house, t... | {"inputs": ["3 2\n1 2 10\n2 3 20", "3 3\n1 2 20\n2 3 10\n3 1 5", "4 2\n1 2 60\n3 4 50", "10 10\n10 3 70\n1 9 98\n9 10 67\n5 2 78\n8 6 71\n4 8 95\n7 1 10\n2 5 73\n6 7 94\n3 4 23", "7 5\n3 2 26\n4 6 84\n6 3 82\n5 1 57\n1 7 34", "9 6\n7 4 98\n5 9 72\n4 6 10\n2 8 22\n9 7 17\n3 1 66", "8 6\n1 3 84\n8 4 34\n7 2 10\n6 8 8\n3 ... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 15 | codeforces | Okay, I need to solve this programming problem. Let me read the problem statement carefully and understand what's required.
So, the problem is about houses connected by pipes. Each pipe has a direction and a diameter. Each house can have at most one incoming and one outgoing pipe. Tanks are installed on houses that ha... | To solve this problem, we need to determine the maximum amount of water that can be safely conveyed from each tank to its corresponding tap in a network of houses connected by directed pipes. Each tank is a house with an outgoing pipe but no incoming pipe, and each tap is a house with an incoming pipe but no outgoing p... | true | ||
149a65db8891987c69e12b3a698e18d4 | Card Game | Digital collectible card games have become very popular recently. So Vova decided to try one of these.
Vova has *n* cards in his collection. Each of these cards is characterised by its power *p**i*, magic number *c**i* and level *l**i*. Vova wants to build a deck with total power not less than *k*, but magic numbers m... | {"inputs": ["5 8\n5 5 1\n1 5 4\n4 6 3\n1 12 4\n3 12 1", "3 7\n4 4 1\n5 8 2\n5 3 3", "10 10\n3 3 6\n5 10 4\n4 7 9\n4 9 7\n1 9 4\n1 6 10\n4 10 1\n4 4 6\n2 7 2\n1 5 4", "10 20\n9 4 10\n2 8 9\n9 1 1\n8 10 10\n5 10 2\n1 2 10\n9 6 3\n2 10 5\n7 10 6\n6 3 1", "10 30\n23 83 9\n2 59 6\n10 6 4\n4 92 3\n19 13 6\n28 83 6\n25 58 4\n... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 3 | codeforces | Okay, I need to solve this programming problem. Let's read the problem carefully.
The problem is about Vova trying to build a deck of cards with certain constraints. The goal is to find the minimum level his character needs to be so that he can select some cards whose total power is at least k. But there are two main ... | To solve this problem, we need to determine the minimum level Vova's character must reach to build a deck of cards with the required total power, while adhering to constraints that no two cards in the deck have magic numbers summing to a prime number.
### Approach
1. **Prime Number Sieve**: Precompute prime numbers up... | false | Code is incorrect. | |
14b287b107fd7520ff268970f124a5ce | Search for Pretty Integers | You are given two lists of non-zero digits.
Let's call an integer pretty if its (base 10) representation has at least one digit from the first list and at least one digit from the second list. What is the smallest positive pretty integer?
The first line contains two integers *n* and *m* (1<=≤<=*n*,<=*m*<=≤<=9) — the l... | {"inputs": ["2 3\n4 2\n5 7 6", "8 8\n1 2 3 4 5 6 7 8\n8 7 6 5 4 3 2 1", "1 1\n9\n1", "9 1\n5 4 2 3 6 1 7 9 8\n9", "5 3\n7 2 5 8 6\n3 1 9", "4 5\n5 2 6 4\n8 9 1 3 7", "5 9\n4 2 1 6 7\n2 3 4 5 6 7 8 9 1", "9 9\n5 4 3 2 1 6 7 8 9\n3 2 1 5 4 7 8 9 6", "9 5\n2 3 4 5 6 7 8 9 1\n4 2 1 6 7", "9 9\n1 2 3 4 5 6 7 8 9\n1 2 3 4 5 ... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 355 | codeforces | Okay, let's see. I need to find the smallest positive integer that is considered 'pretty' based on the given lists. A pretty integer must have at least one digit from the first list and at least one from the second list. So, the task is to generate the smallest possible number that meets this condition.
Hmm. How to ap... | To solve this problem, we need to determine the smallest positive integer that contains at least one digit from each of two given lists. This integer, referred to as a "pretty" integer, must have digits from both lists. The solution involves checking for common digits first and then considering the smallest possible co... | true | ||
14c9740aff6f6fea9c424e0318ca8313 | Restoration of string | A substring of some string is called the most frequent, if the number of its occurrences is not less than number of occurrences of any other substring.
You are given a set of strings. A string (not necessarily from this set) is called good if all elements of the set are the most frequent substrings of this string. Res... | {"inputs": ["4\nmail\nai\nlru\ncf", "3\nkek\npreceq\ncheburek", "1\nz", "2\nab\nba", "2\nac\nbc", "2\ncd\nce", "2\nca\ncb", "2\ndc\nec", "26\nhw\nwb\nba\nax\nxl\nle\neo\nod\ndj\njt\ntm\nmq\nqf\nfk\nkn\nny\nyz\nzr\nrg\ngv\nvc\ncs\nsi\niu\nup\nph", "25\nsw\nwt\nc\nl\nyo\nag\nz\nof\np\nmz\nnm\nui\nzs\nj\nq\nk\ngd\nb\nen\n... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 8 | codeforces | Okay, I need to solve this programming problem. Let's read the problem statement carefully.
The task is to find a good string that satisfies certain conditions. Let's parse the requirements.
So, a good string is one where all the strings in the given set are the most frequent substrings. That means, for each string s... | To solve this problem, we need to find the shortest possible string (called a "good string") such that all given input strings are the most frequent substrings. If there are multiple such strings, we need the lexicographically smallest one. If no such string exists, we should return "NO".
### Approach
1. **Check for D... | false | Code is incorrect. | |
14cb93780999f0be5745dc2133c5dcc5 | Ability To Convert | Alexander is learning how to convert numbers from the decimal system to any other, however, he doesn't know English letters, so he writes any number only as a decimal number, it means that instead of the letter *A* he will write the number 10. Thus, by converting the number 475 from decimal to hexadecimal system, he ge... | {"inputs": ["13\n12", "16\n11311", "20\n999", "17\n2016", "1000\n1001", "1000\n1000", "2\n110111100000101101101011001110100111011001000000000000000000", "500\n29460456244280453288", "1000000000\n17289468142098080", "123\n7719", "25\n2172214240", "2\n1110110101111000010001011110101001011001110000000010111010", "3\n12100... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 6 | codeforces | Okay, let's see. The problem is about converting a number k (which is in base n, but written with digits as numbers, like 10 instead of 'A') back to the minimum possible decimal number. So Alexander converts a decimal number x to base n, but uses digits as decimal representations, leading to a string k. We need to find... | To solve this problem, we need to find the minimum decimal number that, when converted to a given base \( n \), results in a specific string \( k \). The string \( k \) represents the digits of the number in base \( n \), where each digit is written as a decimal number. Our task is to reverse this process and determine... | true | ||
1504039ac7ea1dfc39679c660b5763cb | none | You've got string *s*, consisting of only lowercase English letters. Find its lexicographically maximum subsequence.
We'll call a non-empty string *s*[*p*1*p*2... *p**k*]<==<=*s**p*1*s**p*2... *s**p**k*(1<=≤<=*p*1<=<<=*p*2<=<<=...<=<<=*p**k*<=≤<=|*s*|) a subsequence of string *s*<==<=*s*1*s*2... *s*|*s*|.
St... | {"inputs": ["ababba", "abbcbccacbbcbaaba", "thankstosamarasauteddybearsforthiscontest", "cantouristsolveitlessthaninoneminute", "arepretestsstrongforthisproblem", "whyareyoulookingfortestsdoyouhavewa", "aa", "zz", "a", "z", "b", "y", "zaz", "aza", "dcbaedcba", "abcdeabcd", "abcdedcba", "zyxzxzwyxywxxwabcdabdacdbcacdbca... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 51 | codeforces | Okay, I need to find the lexicographically maximum subsequence of a given string. Let's think about what that means. So a subsequence is formed by deleting some characters from the string without changing the order. The lex max one would be the largest possible in dictionary order.
Hmm, what's the approach here? Let'... | To solve this problem, we need to find the lexicographically maximum subsequence of a given string. A subsequence is formed by deleting some characters from the string without changing the order of the remaining characters. The goal is to determine the largest possible subsequence in dictionary order.
### Approach
The... | true | ||
1505530295dbd2d4bc8823b29ba39a2d | Little Elephant and Function | The Little Elephant enjoys recursive functions.
This time he enjoys the sorting function. Let *a* is a permutation of an integers from 1 to *n*, inclusive, and *a**i* denotes the *i*-th element of the permutation. The Little Elephant's recursive function *f*(*x*), that sorts the first *x* permutation's elements, works... | {"inputs": ["1", "2", "3", "4", "5", "6", "7", "1000", "999", "998", "997", "900", "101", "3", "67", "779", "195", "907", "971", "683", "99", "811", "875", "291", "3", "419", "779", "195", "907", "21", "22", "23", "24", "25"], "outputs": ["1 ", "2 1 ", "3 1 2 ", "4 1 2 3 ", "5 1 2 3 4 ", "6 1 2 3 4 5 ", "7 1 2 3 4 5 6 ... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 304 | codeforces | Okay, I need to find a permutation of numbers from 1 to n such that after applying the Little Elephant's recursive function f(n), the permutation becomes sorted in ascending order. Let's try to understand how this function works step by step.
So, the function f(x) is recursive. Let's break down the steps. The function... | To solve this problem, we need to find a permutation of numbers from 1 to n such that after applying a specific recursive function, the permutation becomes sorted in ascending order. The recursive function works by first sorting the first x-1 elements and then swapping the (x-1)th and xth elements.
### Approach
The k... | false | Code is incorrect. | |
150b646344f8eb91459c57d85944dfc9 | PolandBall and Game | PolandBall is playing a game with EnemyBall. The rules are simple. Players have to say words in turns. You cannot say a word which was already said. PolandBall starts. The Ball which can't say a new word loses.
You're given two lists of words familiar to PolandBall and EnemyBall. Can you determine who wins the game, i... | {"inputs": ["5 1\npolandball\nis\na\ncool\ncharacter\nnope", "2 2\nkremowka\nwadowicka\nkremowka\nwiedenska", "1 2\na\na\nb", "2 2\na\nb\nb\nc", "2 1\nc\na\na", "3 3\nab\nbc\ncd\ncd\ndf\nfg", "3 3\nc\na\nb\na\nd\ng", "1 1\naa\naa", "2 1\na\nb\na", "6 5\na\nb\nc\nd\ne\nf\nf\ne\nd\nz\ny", "3 2\na\nb\nc\nd\ne"], "outputs"... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 131 | codeforces | Okay, let's try to figure out this problem. So, the problem is about PolandBall and EnemyBall playing a game where they take turns saying words they know. The words can't be repeated, and the player who can't say a new word loses. We need to determine who will win if both play optimally. The input gives the words each ... | To solve this problem, we need to determine the winner of a word game between PolandBall and EnemyBall, where both players take turns saying words they know and cannot repeat any word. The player who cannot say a new word loses. PolandBall starts first, and both play optimally.
### Approach
1. **Identify Common Words*... | true | ||
151f68a26da83524d8b82f40c7e8092c | Group Photo 2 (online mirror version) | Many years have passed, and *n* friends met at a party again. Technologies have leaped forward since the last meeting, cameras with timer appeared and now it is not obligatory for one of the friends to stand with a camera, and, thus, being absent on the photo.
Simply speaking, the process of photographing can be descr... | {"inputs": ["3\n10 1\n20 2\n30 3", "3\n3 1\n2 2\n4 3", "1\n5 10", "1\n1 1", "1\n1000 1000", "1\n1 1000", "2\n1 1000\n1000 1", "2\n1 1\n1000 1000", "1\n1000 1", "5\n407 830\n12 199\n768 215\n668 28\n628 310", "3\n379 820\n923 407\n916 853", "3\n99 768\n477 885\n169 118", "3\n227 612\n223 259\n423 895", "3\n651 161\n480 ... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 2 | codeforces | Okay, let's see. I need to solve this programming problem. Let's read the problem statement carefully.
So, the problem is about friends taking a photo. Each friend can be standing or lying down. When standing, their dimensions are w_i by h_i. When lying, it's h_i by w_i. The total width of the photo is the sum of all ... | To solve this problem, we need to determine the minimum possible area of a group photo where each friend can either stand or lie down, with the constraint that no more than half of the friends (rounded down) can lie down. The photo's dimensions are determined by the sum of the widths of all friends and the maximum heig... | true | ||
1542f4a09d6ddea98267a3b58425bbd5 | Robot Rapping Results Report | While Farmer John rebuilds his farm in an unfamiliar portion of Bovinia, Bessie is out trying some alternative jobs. In her new gig as a reporter, Bessie needs to know about programming competition results as quickly as possible. When she covers the 2016 Robot Rap Battle Tournament, she notices that all of the robots o... | {"inputs": ["4 5\n2 1\n1 3\n2 3\n4 2\n4 3", "3 2\n1 2\n3 2", "2 1\n1 2", "2 1\n2 1", "5 10\n1 2\n1 3\n1 4\n1 5\n2 3\n2 4\n2 5\n3 4\n3 5\n4 5", "3 3\n2 1\n3 1\n3 2", "4 6\n1 4\n4 2\n2 3\n1 2\n1 3\n4 3", "3 3\n3 1\n3 2\n1 2", "5 10\n2 1\n1 4\n2 5\n2 3\n5 4\n3 4\n3 1\n3 5\n2 4\n1 5", "3 3\n1 2\n3 2\n1 3", "3 3\n2 3\n1 3\n... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 6 | codeforces | Okay, so I need to solve this problem where I have to determine the minimum number of the first k rap battles such that after processing the first k battles, the skill order of all robots is uniquely determined. If even after all m battles there are multiple possible orderings, output -1. Hmm.
Let me start by understa... | To solve this problem, we need to determine the minimum number of initial rap battles required to uniquely determine the skill order of all robots. The solution involves checking if the Directed Acyclic Graph (DAG) formed by the rap battles has a unique topological order after each battle.
### Approach
1. **Graph Repr... | true | ||
156d2508c063ef36fdc1332ed8ab8e1e | Iterated Linear Function | Consider a linear function *f*(*x*)<==<=*Ax*<=+<=*B*. Let's define *g*(0)(*x*)<==<=*x* and *g*(*n*)(*x*)<==<=*f*(*g*(*n*<=-<=1)(*x*)) for *n*<=><=0. For the given integer values *A*, *B*, *n* and *x* find the value of *g*(*n*)(*x*) modulo 109<=+<=7.
The only line contains four integers *A*, *B*, *n* and *x* (1<=≤<=*... | {"inputs": ["3 4 1 1", "3 4 2 1", "3 4 3 1", "1 1 1 1", "3 10 723 6", "14 81 51 82", "826504481 101791432 76 486624528", "475965351 844435993 96338 972382431", "528774798 650132512 6406119 36569714", "632656975 851906850 1 310973933", "1 1 352875518515340737 1", "978837295 606974665 846646545585165081 745145208", "2776... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 35 | codeforces | Okay, I need to solve this programming problem. Let's read the problem statement carefully.
The problem is about computing the value of a function g(n)(x) after applying a linear transformation multiple times. The function f(x) is Ax + B. Then, g is defined recursively: g(0)(x) = x, and for n>0, g(n)(x) = f(g(n-1)(x))... | To solve this problem, we need to compute the value of a function \( g(n)(x) \) after applying a linear transformation multiple times, where the function \( f(x) = Ax + B \) is applied iteratively. Given the constraints, especially the large value of \( n \) (up to \( 10^{18} \)), a direct iterative approach is infeasi... | true | ||
158444ebd70a822da08f95e3843ab7e3 | Wizards and Demonstration | Some country is populated by wizards. They want to organize a demonstration.
There are *n* people living in the city, *x* of them are the wizards who will surely go to the demonstration. Other city people (*n*<=-<=*x* people) do not support the wizards and aren't going to go to the demonstration. We know that the city... | {"inputs": ["10 1 14", "20 10 50", "1000 352 146", "68 65 20", "78 28 27", "78 73 58", "70 38 66", "54 4 38", "3 1 69", "11 9 60", "71 49 65", "78 55 96", "2765 768 9020", "3478 1728 9727", "9678 6173 5658", "1138 570 6666", "7754 204 9038", "8403 7401 4769", "4909 2111 8860", "6571 6449 8965", "9178 2255 7996", "6151 ... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 305 | codeforces | Okay, let's try to understand this problem. So, the wizards want to have a demonstration that meets a certain percentage of the city's population, but they can use clones (puppets) to make up the numbers. The key points here are:
The city has n people, x of which are wizards who will attend. The rest (n-x) are non-wiz... | To solve this problem, we need to determine the minimum number of clones that wizards must create to ensure their demonstration meets or exceeds a specified percentage of the city's population as perceived by the city administration.
### Approach
1. **Understanding the Requirement**: The city administration requires ... | true | ||
158ed5933ad363941eb78811545a4c1f | A Vital Problem | Polycarp has a strict daily schedule. He has *n* alarms set for each day, and the *i*-th alarm rings each day at the same time during exactly one minute.
Determine the longest time segment when Polycarp can sleep, i. e. no alarm rings in that period. It is possible that Polycarp begins to sleep in one day, and wakes u... | {"inputs": ["1\n05:43", "4\n22:00\n03:21\n16:03\n09:59", "20\n23:59\n00:00\n00:01\n00:02\n00:03\n00:04\n00:05\n00:06\n00:07\n00:08\n00:09\n00:10\n00:11\n00:12\n00:13\n00:14\n00:15\n00:16\n00:17\n00:18", "21\n23:28\n23:29\n23:30\n23:31\n23:32\n23:33\n23:34\n23:35\n23:36\n23:37\n23:38\n23:39\n23:40\n23:41\n23:42\n23:43\n... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 43 | codeforces | Okay, let's see. The problem is to find the longest time segment where Polycarp can sleep without any alarms. The alarms repeat every day, so the time wraps around. So the maximum sleep time could be between the end of one alarm and the start of another, considering all possible pairs, including the last and the first ... | To solve this problem, we need to determine the longest continuous time segment during which Polycarp can sleep without any alarms disturbing him. The solution involves calculating the gaps between consecutive alarms and finding the maximum gap, considering the circular nature of a 24-hour day.
### Approach
1. **Conve... | true | ||
1591a073be244b2dc292fed6a4ee16c2 | Inna and Huge Candy Matrix | Inna and Dima decided to surprise Sereja. They brought a really huge candy matrix, it's big even for Sereja! Let's number the rows of the giant matrix from 1 to *n* from top to bottom and the columns — from 1 to *m*, from left to right. We'll represent the cell on the intersection of the *i*-th row and *j*-th column as... | {"inputs": ["3 3 3 1 1 9\n1 1\n1 2\n1 3\n2 1\n2 2\n2 3\n3 1\n3 2\n3 3", "5 5 0 0 0 1\n1 4", "14 76 376219315 550904689 16684615 24\n11 21\n1 65\n5 25\n14 63\n11 30\n1 19\n5 7\n9 51\n2 49\n13 75\n9 9\n3 63\n8 49\n5 1\n1 67\n13 31\n9 35\n3 53\n13 73\n5 71\n1 32\n5 49\n1 41\n14 69", "63 67 18046757 61758841 85367218 68\n2... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 12 | codeforces | Okay, let's see. I need to solve this programming problem. The problem is about rotating a matrix in various ways and then determining the new positions of certain cells after all the rotations. Let's break it down.
So, the problem statement says that Sereja rotated the matrix x times clockwise, then did a horizontal ... | To solve this problem, we need to determine the new positions of candies in a matrix after a series of transformations, including rotations and horizontal flips. The transformations are applied in the order of clockwise rotations, horizontal flips, and counterclockwise rotations.
### Approach
1. **Effective Transforma... | true | ||
15dc09ce785b1080b799acedace9411c | Okabe and Banana Trees | Okabe needs bananas for one of his experiments for some strange reason. So he decides to go to the forest and cut banana trees.
Consider the point (*x*,<=*y*) in the 2D plane such that *x* and *y* are integers and 0<=≤<=*x*,<=*y*. There is a tree in such a point, and it has *x*<=+<=*y* bananas. There are no trees nor ... | {"inputs": ["1 5", "2 3", "4 6", "6 3", "1 1", "10 1", "20 10", "1000 10000", "139 9252", "859 8096", "987 4237", "411 3081", "539 9221", "259 770", "387 5422", "515 1563", "939 407", "518 6518", "646 1171", "70 7311", "494 6155", "918 7704", "46 3844", "174 2688", "894 4637", "22 3481", "446 5030", "440 8704", "569 75... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 72 | codeforces | Okay, let's see. So the problem is about finding the maximum number of bananas Okabe can collect by choosing the optimal rectangle under a given line. The line's equation is y = -x/m + b, right? Wait, wait. Wait, the problem says the line has equation something. Oh right, the line equation is given by the input m and b... | To solve this problem, we need to determine the maximum number of bananas Okabe can collect by selecting an optimal axis-aligned rectangle under a given line in a 2D plane. The line equation is given by \( y = -\frac{x}{m} + b \), where \( m \) and \( b \) are integers. The goal is to find the rectangle that maximizes ... | true | ||
15e263e85246dfd3aa917ff242354b00 | Alyona and Spreadsheet | During the lesson small girl Alyona works with one famous spreadsheet computer program and learns how to edit tables.
Now she has a table filled with integers. The table consists of *n* rows and *m* columns. By *a**i*,<=*j* we will denote the integer located at the *i*-th row and the *j*-th column. We say that the tab... | {"inputs": ["5 4\n1 2 3 5\n3 1 3 2\n4 5 2 3\n5 5 3 2\n4 4 3 4\n6\n1 1\n2 5\n4 5\n3 5\n1 3\n1 5", "1 1\n1\n1\n1 1", "10 1\n523130301\n127101624\n15573616\n703140639\n628818570\n957494759\n161270109\n386865653\n67832626\n53360557\n17\n4 5\n4 7\n8 8\n9 9\n3 9\n8 10\n8 9\n7 9\n4 5\n2 9\n4 6\n2 4\n2 6\n4 6\n7 9\n2 4\n8 10",... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 20 | codeforces | Okay, I need to solve this programming problem. Let's read the problem carefully.
So, the problem is about a table of integers with n rows and m columns. For each query, given a range of rows [l, r], I need to determine if there exists at least one column where the rows from l to r are non-decreasing. That is, in that... | To solve this problem, we need to determine if a given range of rows in a table is sorted in non-decreasing order in at least one column. The solution involves preprocessing the table to efficiently answer multiple queries.
### Approach
1. **Preprocessing**: For each column, identify the rows where a non-decreasing or... | false | Code is incorrect. | |
15f8e73bc9b0d7eb1a626278b62f9905 | Bathroom terminal | Smith wakes up at the side of a dirty, disused bathroom, his ankle chained to pipes. Next to him is tape-player with a hand-written message "Play Me". He finds a tape in his own back pocket. After putting the tape in the tape-player, he sees a key hanging from a ceiling, chained to some kind of a machine, which is conn... | {"inputs": ["3 1\nabc\naec\nac\na?c", "22 2\naaaab\naaabb\naabab\naabbb\nabaab\nababb\nabbab\nabbbb\naaab\naabb\nabab\nabbb\naab\nabb\nab\ncccd\nccdd\ncdcd\ncddd\nccd\ncdd\ncd\na???b\nc??d", "15 6\naaa\naaabbb\naaabb\naaaaa\naaaaaa\naaaa\naaabbbb\naaaaa\naaaaaa\naaaa\naaabbbb\naabbbb\naa\naa\naab\na\n?a?\n??\n?aa?bb?\n... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 1 | codeforces | Okay, let's tackle this problem. Hmm. So the task is, given N words and M patterns, for each pattern, count how many words match it. The patterns can have up to three '?' characters, which can match any character (a-e) or be empty. Oh right, and the words are up to length L, and the patterns are up to length L as well,... | To solve this problem, we need to determine how many words match each given pattern, where each pattern can contain up to three '?' characters. Each '?' can represent any character from 'a' to 'e' or be omitted, leading to various possible matches.
### Approach
1. **Preprocess Words**: Group words by their lengths us... | true | ||
160baf248c6c33b69df49066de5ff338 | Inna and Alarm Clock | Inna loves sleeping very much, so she needs *n* alarm clocks in total to wake up. Let's suppose that Inna's room is a 100<=×<=100 square with the lower left corner at point (0,<=0) and with the upper right corner at point (100,<=100). Then the alarm clocks are points with integer coordinates in this square.
The mornin... | {"inputs": ["4\n0 0\n0 1\n0 2\n1 0", "4\n0 0\n0 1\n1 0\n1 1", "4\n1 1\n1 2\n2 3\n3 3", "1\n0 0", "42\n28 87\n26 16\n59 90\n47 61\n28 83\n36 30\n67 10\n6 95\n9 49\n86 94\n52 24\n74 9\n86 24\n28 51\n25 99\n40 98\n57 33\n18 96\n43 36\n3 79\n4 86\n38 61\n25 61\n6 100\n58 81\n28 19\n64 4\n3 40\n2 56\n41 49\n97 100\n86 34\n4... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 165 | codeforces | Okay, so I need to solve this programming problem. Let's read the problem statement carefully.
The problem is about Inna turning off alarm clocks using vertical or horizontal lines. The goal is to find the minimum number of moves (segments) required to turn off all alarms. Each move is either a horizontal or vertical ... | To solve this problem, we need to determine the minimum number of vertical or horizontal segments required to turn off all alarm clocks in Inna's room. The key insight is that the optimal strategy involves choosing between vertical or horizontal segments, whichever results in fewer segments.
### Approach
1. **Problem ... | true | ||
16344fb7e2bc83409f14ef3f666a983c | King's Problem? | Every true king during his life must conquer the world, hold the Codeforces world finals, win pink panda in the shooting gallery and travel all over his kingdom.
King Copa has already done the first three things. Now he just needs to travel all over the kingdom. The kingdom is an infinite plane with Cartesian coordina... | {"inputs": ["3 1\n0 1 2 1\n1", "3 1\n1 0 2 1\n1", "4 5\n0 5 -1 -5 2\n3", "4 1\n0 5 -1 -5 2\n3", "10 5\n-231 598 312 -837 -711 553 -439 351 83 -605 -738\n791", "100 31\n-577 101 691 -95 809 125 -934 -645 -838 -548 259 312 -501 -962 -629 -637 -797 -259 -258 -687 537 303 -6 431 64 229 -897 -942 -805 804 -608 84 992 -563 2... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 3 | codeforces | Okay, let's try to figure out this problem. So, the problem is about finding the shortest possible route for King Copa to visit all cities starting from a specific city. Hmm. Let's read the problem statement again carefully.
So, the kingdom has n cities on the x-axis (since their y-coordinates are 0), and one city at ... | To solve this problem, we need to find the shortest possible route for King Copa to visit all cities starting from a specified city. The cities are either on the x-axis or at a specific off-axis point. The solution involves calculating the minimal path considering different scenarios for visiting all cities.
### Appro... | false | Code is incorrect. | |
1655768ab04bba468899388061617449 | Cowboys | A very tense moment: *n* cowboys stand in a circle and each one points his colt at a neighbor. Each cowboy can point the colt to the person who follows or precedes him in clockwise direction. Human life is worthless, just like in any real western.
The picture changes each second! Every second the cowboys analyse the s... | {"inputs": ["BABBBABBA", "ABABB", "ABABAB", "ABA", "AABB", "ABABBABBAABAB", "AAABAABABA", "ABABABABABABABABABAB", "BABABABABAAAABABAAAABAB", "ABABABBABA", "BBB", "AAAA", "ABBAB", "BBBABB", "BABBBBB", "ABABBAAB", "ABBBABBAB", "BAAABBBBBA", "AAAAAAAAAAA", "BABBAAAABAAA", "ABABBBABBBAAA", "BBBBBABBBBBABB", "AAAAAAAABAAAAA... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 1 | codeforces | Okay, let's see. So the problem is about finding the number of possible previous states that could lead to the given current state after one second. Each second, all pairs of adjacent cowboys pointing at each other (like A followed by B or B followed by A?) Wait, no. Wait, the problem says: if a pair of cowboys realize... | To solve this problem, we need to determine the number of possible previous states that could lead to the given current state after one second. Each second, all pairs of adjacent cowboys pointing at each other (A followed by B or B followed by A) flip their directions.
### Approach
1. **Identify Candidate Pairs**: Fi... | false | Code is incorrect. | |
166c3a794830622ff41a4fd1297a07d0 | System Administrator | Polycarpus is a system administrator. There are two servers under his strict guidance — *a* and *b*. To stay informed about the servers' performance, Polycarpus executes commands "ping a" and "ping b". Each ping command sends exactly ten packets to the server specified in the argument of the command. Executing a progra... | {"inputs": ["2\n1 5 5\n2 6 4", "3\n1 0 10\n2 0 10\n1 10 0", "10\n1 3 7\n2 4 6\n1 2 8\n2 5 5\n2 10 0\n2 10 0\n1 8 2\n2 2 8\n2 10 0\n1 1 9", "11\n1 8 2\n1 6 4\n1 9 1\n1 7 3\n2 0 10\n2 0 10\n1 8 2\n2 2 8\n2 6 4\n2 7 3\n2 9 1", "12\n1 5 5\n1 0 10\n1 4 6\n1 2 8\n1 2 8\n1 5 5\n1 9 1\n2 9 1\n1 5 5\n1 1 9\n2 9 1\n2 7 3", "13\n... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 300 | codeforces | Okay, let's see. So the problem is about determining whether servers a and b are alive based on their ping results. The condition is that at least half of the packets sent to each server must have reached successfully.
Hmm, each ping command sends exactly 10 packets. So for each server, we need to accumulate all the ... | To solve this problem, we need to determine if two servers, a and b, are considered "alive" based on the results of ping commands executed by Polycarpus. A server is considered alive if at least half of the packets sent to it successfully reached the server.
### Approach
1. **Input Reading**: Read the number of comman... | true | ||
16830fb49b20765e78781cea4be2a97f | The Contest | Pasha is participating in a contest on one well-known website. This time he wants to win the contest and will do anything to get to the first place!
This contest consists of *n* problems, and Pasha solves *i*th problem in *a**i* time units (his solutions are always correct). At any moment of time he can be thinking ab... | {"inputs": ["2\n3 4\n2\n1 4\n7 9", "1\n5\n1\n1 4", "1\n5\n1\n1 5", "5\n100000 100000 100000 100000 100000\n0", "5\n886 524 128 4068 298\n3\n416 3755\n4496 11945\n17198 18039", "10\n575 3526 1144 1161 889 1038 790 19 765 357\n2\n4475 10787\n16364 21678", "1\n4\n1\n5 9", "1\n200\n4\n1 10\n20 40\n50 55\n190 210", "4\n643 ... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 85 | codeforces | Okay, let's see. The problem is about Pasha solving programming contest problems and submitting them during specific time intervals. The goal is to find the earliest possible time when all his solutions are submitted. If it's impossible, output -1.
Hmm. So first, the key points to understand:
Pasha solves problems on... | To solve this problem, we need to determine the earliest possible time by which Pasha can submit all his solutions to the contest problems, given the constraints on the website's availability periods.
### Approach
1. **Problem Analysis**:
- Pasha can only submit solutions during specific time intervals when the w... | true | ||
168f6f1983f3160ebd9573e0d6a26d69 | Display Size | A big company decided to launch a new series of rectangular displays, and decided that the display must have exactly *n* pixels.
Your task is to determine the size of the rectangular display — the number of lines (rows) of pixels *a* and the number of columns of pixels *b*, so that:
- there are exactly *n* pixels o... | {"inputs": ["8", "64", "5", "999999", "716539", "1", "2", "3", "4", "6", "7", "9", "10", "11", "12", "15", "100", "101", "169", "179", "190", "1000", "10000", "10001", "100000", "100001", "1000000", "999983", "524288", "954493", "966289", "944663", "912673", "732641", "232897", "16807", "999958", "990151", "997002", "2... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 236 | codeforces | Okay, I need to solve this problem where I have to find the best possible dimensions a and b for a display with exactly n pixels. The conditions are that a <= b, and the difference b - a is as small as possible. Let's think through how to approach this.
First, the problem is essentially to find two factors of n, a and... | To solve this problem, we need to determine the dimensions of a rectangular display with exactly `n` pixels such that the number of rows (a) does not exceed the number of columns (b) and the difference between b and a is minimized.
### Approach
1. **Understand the Problem Requirements**: We need to find two integers ... | true | ||
16a03da19a666d6d16782abb48417091 | Division into Teams | Petya loves football very much, especially when his parents aren't home. Each morning he comes to the yard, gathers his friends and they play all day. From time to time they have a break to have some food or do some chores (for example, water the flowers).
The key in football is to divide into teams fairly before the ... | {"inputs": ["3\n1 2 1", "5\n2 3 3 1 1", "10\n2 2 2 2 2 2 2 1 2 2", "10\n2 3 3 1 3 1 1 1 2 2", "10\n2 3 2 3 3 1 1 3 1 1", "11\n1 3 1 2 1 2 2 2 1 1 1", "11\n54 83 96 75 33 27 36 35 26 22 77", "11\n1 1 1 1 1 1 1 1 1 1 1", "2\n1 1", "2\n35 36", "25\n1 2 2 1 2 2 2 2 2 1 1 2 2 2 2 2 1 2 2 2 1 1 2 2 1", "27\n2 1 1 3 1 2 1 1 3... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 13 | codeforces | Okay, let's see. The problem is about dividing a group of boys into two teams such that certain conditions are met. The conditions are:
1. Each boy is in exactly one team. So x + y = n.
2. The sizes differ by at most one. So |x - y| ≤ 1.
3. The total skills of the two teams differ by no more than the maximum individua... | To solve this problem, we need to divide a group of boys into two teams such that the division is fair according to specified conditions. The key challenge is to ensure that the total football playing skills of the two teams differ by no more than the maximum skill of any individual player, while also making sure the t... | false | Code is incorrect. | |
16ccd5806786645d788c5a6d9bc85b1e | Little Elephant and Problem | The Little Elephant has got a problem — somebody has been touching his sorted by non-decreasing array *a* of length *n* and possibly swapped some elements of the array.
The Little Elephant doesn't want to call the police until he understands if he could have accidentally changed the array himself. He thinks that he co... | {"inputs": ["2\n1 2", "3\n3 2 1", "4\n4 3 2 1", "3\n1 3 2", "2\n2 1", "9\n7 7 8 8 10 10 10 10 1000000000", "10\n1 2 9 4 5 6 7 8 3 10", "4\n2 2 2 1", "10\n1 2 4 4 4 5 5 7 7 10", "10\n4 5 11 12 13 14 16 16 16 18", "20\n38205814 119727790 127848638 189351562 742927936 284688399 318826601 326499046 387938139 395996609 4944... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 183 | codeforces | Okay, let's see. The problem is to determine if the given array can be sorted by swapping at most one pair of elements. So, the original array was sorted in non-decreasing order, but maybe someone swapped two elements. We need to check if the current array can be made sorted with just one swap.
Hmm. So the approach is... | To solve this problem, we need to determine if a given array can be sorted by swapping at most one pair of elements. The approach involves comparing the given array with its sorted version and checking if the discrepancies can be resolved with a single swap.
### Approach
1. **Check if Already Sorted**: If the array is... | true | ||
16e2a8ba7b90c835d233f81974a1987e | A and B and Interesting Substrings | A and B are preparing themselves for programming contests.
After several years of doing sports programming and solving many problems that require calculating all sorts of abstract objects, A and B also developed rather peculiar tastes.
A likes lowercase letters of the Latin alphabet. He has assigned to each letter a ... | {"inputs": ["1 1 -1 1 1 1 1 1 1 1 1 1 1 1 1 7 1 1 1 8 1 1 1 1 1 1\nxabcab", "1 1 -1 1 1 1 1 1 1 1 1 1 1 1 1 7 1 1 1 8 1 1 1 1 1 1\naaa", "1 1 -1 1 1 1 1 1 1 1 1 1 1 1 1 7 1 1 1 8 1 1 1 1 1 1\naabbccdd", "-3 4 -4 -1 3 5 -5 -3 3 2 1 4 5 -3 -1 4 2 -2 1 -1 1 5 -4 0 -5 4\nolspxykjqr", "-2 -2 2 1 4 0 -2 4 5 4 -5 -5 2 1 1 -1 ... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 19 | codeforces | Okay, I need to solve this programming problem. Let's read the problem carefully.
The problem is about counting substrings in a given string that meet two conditions. First, the substring must start and end with the same character and have a length greater than one. Second, the sum of the values of the characters in t... | To solve this problem, we need to count the number of substrings in a given string that start and end with the same character, have a length greater than one, and where the sum of the values of the characters between the start and end (exclusive) is zero.
### Approach
1. **Prefix Sum Calculation**: Compute the prefix... | true | ||
16ea217382917bb89accb42f3a9c6795 | Flag | According to a new ISO standard, a flag of every country should have a chequered field *n*<=×<=*m*, each square should be of one of 10 colours, and the flag should be «striped»: each horizontal row of the flag should contain squares of the same colour, and the colours of adjacent horizontal rows should be different. Be... | {"inputs": ["3 3\n000\n111\n222", "3 3\n000\n000\n111", "3 3\n000\n111\n002", "10 10\n2222222222\n5555555555\n0000000000\n4444444444\n1111111111\n3333333393\n3333333333\n5555555555\n0000000000\n8888888888", "10 13\n4442444444444\n8888888888888\n6666666666666\n0000000000000\n3333333333333\n4444444444444\n7777777777777\n... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 284 | codeforces | Okay, let's see. The problem is to check if a given flag meets the ISO standard. So the requirements are: each row must be the same color, and adjacent rows must have different colors. Also, each square is one of the 10 colors (digits 0-9). So how to approach this?
First, the input is n rows and m columns. For each ro... | To solve this problem, we need to determine if a given flag meets the new ISO standard, which requires each horizontal row to be of the same color and adjacent rows to have different colors.
### Approach
1. **Read Input**: First, we read the dimensions of the flag (number of rows `n` and columns `m`).
2. **Check Each ... | true | ||
16ecf492d63595584a0ea1707994c224 | Lala Land and Apple Trees | Amr lives in Lala Land. Lala Land is a very beautiful country that is located on a coordinate line. Lala Land is famous with its apple trees growing everywhere.
Lala Land has exactly *n* apple trees. Tree number *i* is located in a position *x**i* and has *a**i* apples growing on it. Amr wants to collect apples from t... | {"inputs": ["2\n-1 5\n1 5", "3\n-2 2\n1 4\n-1 3", "3\n1 9\n3 5\n7 10", "1\n1 1", "4\n10000 100000\n-1000 100000\n-2 100000\n-1 100000", "1\n-1 1", "27\n-30721 24576\n-6620 92252\n88986 24715\n-94356 10509\n-6543 29234\n-68554 69530\n39176 96911\n67266 99669\n95905 51002\n-94093 92134\n65382 23947\n-6525 79426\n-448 675... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 152 | codeforces | Okay, let's see. So the problem is about Amr collecting apples from trees on a coordinate line. The main thing is he starts at position 0, chooses to go left or right first, and then each time he visits a new tree, he reverses direction. We need to find the maximum apples he can collect.
Hmm. Let me think. So the key ... | To solve this problem, we need to determine the maximum number of apples Amr can collect by starting either left or right and alternating directions after each tree visited. The solution involves simulating the process for both starting directions and considering the special case where one direction has no trees.
### ... | false | Code is incorrect. | |
172d355f207b1c6d888955b4a88727e9 | Mahmoud and Longest Uncommon Subsequence | While Mahmoud and Ehab were practicing for IOI, they found a problem which name was Longest common subsequence. They solved it, and then Ehab challenged Mahmoud with another problem.
Given two strings *a* and *b*, find the length of their longest uncommon subsequence, which is the longest string that is a subsequence ... | {"inputs": ["abcd\ndefgh", "a\na", "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaacccccccccccccccccccccccccccccccccccccccccccccccccc\naaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaadddddddddddddddddddddddddddddddddddddddddddddddddd", "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 184 | codeforces | Okay, let's try to figure out this problem. So, the task is to find the longest uncommon subsequence between two strings a and b. Hmm. The longest uncommon subsequence is defined as the longest string that is a subsequence of one but not a subsequence of the other. And if there's none, we return -1.
Wait, so what's th... | To solve this problem, we need to determine the length of the longest uncommon subsequence between two given strings. The longest uncommon subsequence is defined as the longest string that is a subsequence of one of the given strings but not a subsequence of the other.
### Approach
The key insight to solve this proble... | true | ||
175a9fbb6934af1423c16e2e891e9830 | Pashmak and Buses | Recently Pashmak has been employed in a transportation company. The company has *k* buses and has a contract with a school which has *n* students. The school planned to take the students to *d* different places for *d* days (each day in one place). Each day the company provides all the buses for the trip. Pashmak has t... | {"inputs": ["3 2 2", "3 2 1", "7 2 3", "9 2 3", "2 1 1000", "512 2 9", "1000 1000000000 511", "1000 1000 1", "1000 3 1000", "1 1000000000 512", "1000 2 1000", "1000 3 1000", "1000 31 1000", "1000 32 1000", "1000 999 1000", "1000 1000 1000", "1000 536870912 1000", "1000 536870911 1000", "1000 1000000000 1000", "1000 2 8... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 7 | codeforces | Okay, let's try to understand this problem. So, the task is to arrange students into buses over d days such that no two students end up in the same bus every single day. If that's possible, we need to output the arrangement; otherwise, output -1.
Hmm, the key here is that each pair of students must differ in at least ... | To solve this problem, we need to arrange students in buses over multiple days such that no two students end up in the same bus every day. The key is to ensure that each student has a unique sequence of bus assignments over the given days.
### Approach
1. **Feasibility Check**: First, determine if it's possible to arr... | false | Code is incorrect. | |
1781dd23263cc5f4456420d34bd9eaa4 | Pashmak and Parmida's problem | Parmida is a clever girl and she wants to participate in Olympiads this year. Of course she wants her partner to be clever too (although he's not)! Parmida has prepared the following test problem for Pashmak.
There is a sequence *a* that consists of *n* integers *a*1,<=*a*2,<=...,<=*a**n*. Let's denote *f*(*l*,<=*r*,<... | {"inputs": ["7\n1 2 1 1 2 2 1", "3\n1 1 1", "5\n1 2 3 4 5", "24\n1 2 3 4 1 2 3 4 1 2 3 4 1 2 3 4 1 2 3 4 1 2 3 4", "1\n1", "2\n1 2", "2\n1 1", "4\n1 1 2 2", "5\n1 1 2 2 2"], "outputs": ["8", "1", "0", "114", "0", "0", "0", "1", "2"]} | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 14 | codeforces | Okay, I need to solve this programming problem. Let's read the problem statement carefully.
So, the task is to count the number of pairs (i, j) where i ≤ j, such that f(1, i, a_i) > f(j, n, a_j).
What's f here? Oh right, f(l, r, x) is the count of elements from index k between l and r (inclusive) where a_k is less t... | To solve this problem, we need to count the number of valid pairs (i, j) where 1 ≤ i ≤ j ≤ n such that the count of elements from 1 to i (inclusive) that are less than or equal to a[i] is greater than the count of elements from j to n (inclusive) that are less than or equal to a[j].
### Approach
1. **Coordinate Compre... | false | Code is incorrect. | |
17ec4d515c12743261193390f42cb456 | Mr. Bender and Square | Mr. Bender has a digital table of size *n*<=×<=*n*, each cell can be switched on or off. He wants the field to have at least *c* switched on squares. When this condition is fulfilled, Mr Bender will be happy.
We'll consider the table rows numbered from top to bottom from 1 to *n*, and the columns — numbered from left ... | {"inputs": ["6 4 3 1", "9 3 8 10", "9 4 3 10", "9 8 2 10", "1 1 1 1", "10 7 2 7", "8 2 6 10", "8 1 2 10", "6 1 4 10", "1000000 951981 612086 60277", "1000000 587964 232616 62357", "1000000 948438 69861 89178", "1000000000 504951981 646612086 602763371", "1000000000 81587964 595232616 623563697", "1000000000 55 60 71518... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 7 | codeforces | Okay, I need to solve this programming problem. Let's read the problem carefully.
The problem is about a digital table of size n x n. Each cell can be on or off. Initially, only the cell at (x, y) is on. Every second, all cells that are off but have at least one adjacent cell (side-adjacent) that's on will be turned o... | To solve this problem, we need to determine the minimum number of seconds required for a grid to have at least a specified number of cells switched on, starting from a single cell and spreading outwards each second. The spread occurs to cells that are side-adjacent to already switched-on cells.
### Approach
1. **Probl... | false | Code is incorrect. | |
17ff19eef74317819cc833b0e6176d2b | Heidi and Library (hard) | The good times at Heidi's library are over. Marmots finally got their internet connections and stopped coming to the library altogether. Not only that, but the bookstore has begun charging extortionate prices for some books. Namely, whereas in the previous versions each book could be bought for 1 CHF, now the price of ... | {"inputs": ["4 80\n1 2 2 1\n1 1 1 1", "4 1\n1 2 2 1\n1 1 1 1", "4 2\n1 2 3 1\n1 1 1 1", "7 2\n1 2 3 1 1 1 2\n1 10 1 0 0 0 0", "11 1\n1 2 3 5 1 10 10 1 1 3 5\n1 1 2 3 4 5 6 7 8 9 10", "5 2\n1 2 3 1 2\n1 1 1 1 1", "4 2\n1 2 3 2\n1 1 1 1", "80 4\n2 6 10 4 7 8 2 8 9 10 6 2 5 3 2 10 5 9 1 3 4 8 6 1 9 3 9 4 7 7 4 6 4 8 1 2 5... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 1 | codeforces | Okay, let's see. The problem is about finding the minimum cost to buy books such that all requests are satisfied. Hmm. Let me try to understand the problem step by step.
So, the input gives n and k. Then a sequence of book requests. For each request, we can either buy the book or borrow it from the library. But the li... | To solve this problem, we need to determine the minimum cost of buying books such that all requests are satisfied either by purchasing the book or borrowing it using a cache (library) with a limited capacity. The goal is to minimize the total cost of purchasing books while efficiently managing the cache to handle borro... | false | Code is incorrect. | |
183d5529b0961a41597819ab12cd61be | Voltage Keepsake | You have *n* devices that you want to use simultaneously.
The *i*-th device uses *a**i* units of power per second. This usage is continuous. That is, in λ seconds, the device will use λ·*a**i* units of power. The *i*-th device currently has *b**i* units of power stored. All devices can store an arbitrary amount of pow... | {"inputs": ["2 1\n2 2\n2 1000", "1 100\n1 1", "3 5\n4 3\n5 2\n6 1", "1 1\n1 87", "1 1\n100 77", "5 10\n3 81\n3 49\n1 20\n1 12\n1 30", "5 10\n4 3\n1 54\n2 57\n2 31\n1 99", "5 10\n2 81\n3 31\n4 49\n1 35\n1 67", "10 1\n1 92\n1 92\n1 92\n1 92\n1 92\n1 92\n1 92\n1 92\n1 92\n1 92", "10 1\n1 16\n1 16\n1 16\n1 16\n1 16\n1 16\n... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 22 | codeforces | Okay, let's try to figure out this problem. Hmm, the task is to find the maximum time until any device runs out of power. All devices are being used continuously, and we have a charger that can charge one device at a time. The challenge is to decide how to optimally use the charger to maximize the time before any devic... | To solve this problem, we need to determine the maximum amount of time we can use multiple devices until one of them runs out of power, given that we can charge one device at a time. If it's possible to use the devices indefinitely, we should return -1.
### Approach
1. **Initial Check for Indefinite Use**:
- Calcu... | true | ||
18570e5f148ba4dbe6c04aea7fe63509 | Combination Lock | Scrooge McDuck keeps his most treasured savings in a home safe with a combination lock. Each time he wants to put there the treasures that he's earned fair and square, he has to open the lock.
The combination lock is represented by *n* rotating disks with digits from 0 to 9 written on them. Scrooge McDuck has to turn ... | {"inputs": ["5\n82195\n64723", "12\n102021090898\n010212908089", "1\n8\n1", "2\n83\n57", "10\n0728592530\n1362615763", "100\n4176196363694273682807653052945037727131821799902563705176501742060696655282954944720643131654235909\n345991208492215450591028749987997565929823937151988986658547267442300883787812306710300534498... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 899 | codeforces | Okay, let's see. The problem is about finding the minimum number of moves needed to turn the disks on a lock from the original state to the target combination. Each move is turning one disk one step either forward or backward. Oh right, and turning from 0 to 9 or 9 to 0 is allowed, which counts as one move. So for each... | To solve this problem, we need to determine the minimum number of moves required to adjust the digits on a combination lock from their original state to a target state. Each move consists of rotating a single disk one step either forward or backward.
### Approach
1. **Problem Analysis**: Each disk on the lock can be r... | true | ||
18574ec81ce029d7932890bfd5465160 | Restoration of the Permutation | Let *A*<==<={*a*1,<=*a*2,<=...,<=*a**n*} be any permutation of the first *n* natural numbers {1,<=2,<=...,<=*n*}. You are given a positive integer *k* and another sequence *B*<==<={*b*1,<=*b*2,<=...,<=*b**n*}, where *b**i* is the number of elements *a**j* in *A* to the left of the element *a**t*<==<=*i* such that *a**j... | {"inputs": ["5 2\n1 2 1 0 0", "4 2\n1 0 0 0", "10 3\n4 2 4 2 1 0 1 0 0 0", "15 3\n4 2 7 5 1 1 1 0 0 0 0 0 0 0 0", "5 1\n1 3 2 0 0", "8 3\n2 0 2 2 1 0 0 0", "1 1\n0", "10 10\n0 0 0 0 0 0 0 0 0 0", "10 9\n1 0 0 0 0 0 0 0 0 0", "10 1\n9 8 7 6 5 4 3 2 1 0", "10 1\n7 6 5 4 3 2 1 0 0 0", "13 2\n1 2 3 4 5 4 3 2 1 0 0 0 0", "2... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 6 | codeforces | Okay, I need to solve this programming problem. Let's read the problem carefully.
The problem is about finding the lexicographically smallest permutation A given n, k, and the sequence B. The sequence B is defined such that each b_i is the number of elements a_j to the left of a_i in A that are >= (i + k). Wait, no, w... | To solve this problem, we need to determine the lexicographically smallest permutation \( A \) of the first \( n \) natural numbers given the constraints provided by sequence \( B \) and integer \( k \). The sequence \( B \) specifies the number of elements to the left of each element \( i \) in \( A \) that are greate... | true | ||
1863b6f28ad0474a2c0dc6ef0e81a030 | Megacity | The administration of the Tomsk Region firmly believes that it's time to become a megacity (that is, get population of one million). Instead of improving the demographic situation, they decided to achieve its goal by expanding the boundaries of the city.
The city of Tomsk can be represented as point on the plane with ... | {"inputs": ["4 999998\n1 1 1\n2 2 1\n3 3 1\n2 -2 1", "4 999998\n1 1 2\n2 2 1\n3 3 1\n2 -2 1", "2 1\n1 1 999997\n2 2 1", "4 999998\n3 3 10\n-3 3 10\n3 -3 10\n-3 -3 10", "15 95473\n-9 6 199715\n0 -8 110607\n0 2 6621\n-3 -2 59894\n-10 -8 175440\n-2 0 25814\n10 -4 68131\n7 1 9971\n6 7 821\n6 5 20208\n6 2 68468\n0 7 37427\n... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 120 | codeforces | Okay, let's see. I need to solve this programming problem. The problem is about finding the minimum radius of a circle around the origin (0,0) such that when you include all the points (locations) within or on this circle, their total population plus the initial city's population s reaches at least one million. If it's... | To solve this problem, we need to determine the minimum radius of a circle centered at the origin (0,0) such that the total population of Tomsk and all included locations within this circle reaches at least one million. If it's impossible to achieve this, we should return -1.
### Approach
1. **Initial Check**: If the ... | false | Code is incorrect. | |
18676c03598b38db0d03c7b1d0fce954 | Dijkstra? | You are given a weighted undirected graph. The vertices are enumerated from 1 to *n*. Your task is to find the shortest path between the vertex 1 and the vertex *n*.
The first line contains two integers *n* and *m* (2<=≤<=*n*<=≤<=105,<=0<=≤<=*m*<=≤<=105), where *n* is the number of vertices and *m* is the number of edg... | {"inputs": ["5 6\n1 2 2\n2 5 5\n2 3 4\n1 4 1\n4 3 3\n3 5 1", "5 6\n1 2 2\n2 5 5\n2 3 4\n1 4 1\n4 3 3\n3 5 1", "2 1\n1 2 1", "3 1\n1 2 1", "3 3\n1 2 1\n1 3 2\n2 3 1", "10 10\n1 5 12\n2 4 140\n2 10 149\n3 6 154\n3 7 9\n3 8 226\n3 10 132\n4 10 55\n5 8 33\n7 8 173", "10 10\n1 5 178\n1 8 221\n2 7 92\n2 8 159\n3 5 55\n3 6 17... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 147 | codeforces | Okay, I need to solve this problem where I have to find the shortest path in a weighted undirected graph from node 1 to node n. If there's no path, output -1. Otherwise, output the shortest path. Also, if there are multiple shortest paths, any is acceptable. Let's think about how to approach this.
First, the problem i... | To solve this problem, we need to find the shortest path in a weighted undirected graph from vertex 1 to vertex n using Dijkstra's algorithm. If no path exists, we should return -1. Otherwise, we should return the shortest path.
### Approach
1. **Graph Representation**: Use an adjacency list to represent the graph, wh... | true | ||
18731b0885aaff022fbbdb83087c9a43 | Lucky Ticket | 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 loves tickets very much. As we know, each ticket has a number that is a positive integer. It... | {"inputs": ["2\n47", "4\n4738", "4\n4774", "4\n4570", "6\n477477", "6\n777777", "20\n44444444444444444444", "2\n44", "10\n4745474547", "14\n77770004444444", "10\n4747777744", "10\n1234567890", "50\n44444444444444444444444444444444444444444444444444", "50\n44444444444444444444444444444444444444444444444447", "50\n744444... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 461 | codeforces | Okay, let's see. I need to solve this programming problem. Let's read the question carefully.
The problem is about determining if a given ticket is lucky according to Petya's definition. So, Petya says a ticket is lucky if two conditions are met. First, the ticket number must be a lucky number, which means all its dig... | To solve this problem, we need to determine if a given ticket number meets two specific conditions to be considered "lucky" according to Petya's criteria. The ticket number must be composed solely of the digits 4 and 7, and the sum of the digits in the first half of the number must equal the sum of the digits in the se... | true | ||
189d83c2d5a6b1b0f0bde452f2187d0a | Yaroslav and Time | Yaroslav is playing a game called "Time". The game has a timer showing the lifespan he's got left. As soon as the timer shows 0, Yaroslav's character dies and the game ends. Also, the game has *n* clock stations, station number *i* is at point (*x**i*,<=*y**i*) of the plane. As the player visits station number *i*, he ... | {"inputs": ["3 1000\n1000\n0 0\n0 1\n0 3", "3 1000\n1000\n1 0\n1 1\n1 2", "5 1421\n896 448 727\n-19 -40\n-87 40\n69 51\n-55 61\n-7 67", "6 1000\n142 712 254 869\n7 0\n95 38\n96 -20\n-7 93\n75 -45\n-80 -20", "7 1288\n943 265 649 447 806\n-4 -51\n-26 32\n47 -28\n31 32\n61 65\n-45 -37\n82 42", "8 1931\n440 627 324 538 539... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 9 | codeforces | Okay, let's try to solve this problem. Hmm. The goal is to find out how much money Yaroslav needs to reach station n. Let me understand the problem step by step.
So, the game has stations. Each station, except maybe the first and last, gives some time when visited. The movement between stations costs time, calculated ... | To solve this problem, we need to determine the minimum amount of money Yaroslav needs to spend to reach the final station (station n) from the initial station (station 1) without his timer dropping to zero. The solution involves finding the optimal path through intermediate stations that maximize the time collected fr... | true | ||
18b11fdbe3798b0b5243958f3bf2e4ef | Dependency management | Polycarp is currently developing a project in Vaja language and using a popular dependency management system called Vamen. From Vamen's point of view both Vaja project and libraries are treated projects for simplicity.
A project in Vaja has its own uniqie non-empty name consisting of lowercase latin letters with lengt... | {"inputs": ["4\na 3\n2\nb 1\nc 1\n\nb 2\n0\n\nb 1\n1\nb 2\n\nc 1\n1\nb 2", "9\ncodehorses 5\n3\nwebfrmk 6\nmashadb 1\nmashadb 2\n\ncommons 2\n0\n\nmashadb 3\n0\n\nwebfrmk 6\n2\nmashadb 3\ncommons 2\n\nextra 4\n1\nextra 3\n\nextra 3\n0\n\nextra 1\n0\n\nmashadb 1\n1\nextra 3\n\nmashadb 2\n1\nextra 1", "3\nabc 1\n2\nabc 3... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 8 | codeforces | Okay, let's tackle this problem. So, the task is to determine all the dependencies of Polycarp's project, considering collision resolution where multiple versions of the same project are present. The output should be the actual dependencies after resolving these collisions, sorted lexicographically.
First, I need to u... | To solve this problem, we need to determine all the dependencies of Polycarp's project, considering collision resolution where multiple versions of the same project are present. The output should be the actual dependencies after resolving these collisions, sorted lexicographically.
### Approach
1. **Parse Input**: Rea... | false | Code is incorrect. | |
18cd04f66c3a25d8ef9c84aaf20ac88c | Vicious Keyboard | Tonio has a keyboard with only two letters, "V" and "K".
One day, he has typed out a string *s* with only these two letters. He really likes it when the string "VK" appears, so he wishes to change at most one letter in the string (or do no changes) to maximize the number of occurrences of that string. Compute the maxi... | {"inputs": ["VK", "VV", "V", "VKKKKKKKKKVVVVVVVVVK", "KVKV", "VKKVVVKVKVK", "VKVVKVKVVKVKKKKVVVVVVVVKVKVVVVVVKKVKKVKVVKVKKVVVVKV", "VVKKVKKVVKKVKKVKVVKKVKKVVKKVKVVKKVKKVKVVKKVVKKVKVVKKVKVVKKVVKVVKKVKKVKKVKKVKKVKVVKKVKKVKKVKKVKKVVKVK", "KVVKKVKVKVKVKVKKVKVKVVKVKVVKVVKVKKVKVKVKVKVKVKVKVKVKVKVKVKVKVKVVKVKVVKKVKVKK", "KVVV... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 142 | codeforces | Okay, I need to solve this problem where Tonio can change at most one character in a string made of 'V's and 'K's to maximize the number of 'VK' substrings. Let's think through the steps here.
First, the problem says that Tonio can change at most one character. So my approach should be to find out the original count o... | To solve this problem, we need to determine the maximum number of occurrences of the substring "VK" in a given string after changing at most one character. The string consists only of the characters 'V' and 'K'.
### Approach
1. **Initial Count Calculation**: First, we calculate the number of "VK" substrings in the or... | true | ||
18dfbace2937f92f8edc7f2509adeb06 | Dishonest Sellers | Igor found out discounts in a shop and decided to buy *n* items. Discounts at the store will last for a week and Igor knows about each item that its price now is *a**i*, and after a week of discounts its price will be *b**i*.
Not all of sellers are honest, so now some products could be more expensive than after a week... | {"inputs": ["3 1\n5 4 6\n3 1 5", "5 3\n3 4 7 10 3\n4 5 5 12 5", "1 0\n9\n8", "2 0\n4 10\n1 2", "4 2\n19 5 17 13\n3 18 8 10", "5 3\n28 17 20 45 45\n39 12 41 27 9", "10 5\n87 96 19 81 10 88 7 49 36 21\n11 75 28 28 74 17 64 19 81 31", "50 45\n80 125 152 122 85 62 123 195 157 73 8 127 47 193 70 132 131 38 98 97 185 98 68 1... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 213 | codeforces | Okay, let's see. The problem is about Igor buying items either now or later, with the goal of minimizing the total cost. He has to buy at least k items now, but the rest can be bought later. But since some items might be cheaper now and others later, we need to choose wisely which ones to buy now to maximize savings.
... | To solve this problem, we need to determine the minimum amount of money Igor can spend to buy all items, ensuring he buys at least `k` items at their current price. The rest of the items can be bought later at their discounted price. The goal is to minimize the total expenditure by strategically choosing which items to... | true | ||
190cc916df6e471a15c1895a240a728e | A Simple Task | Given a simple graph, output the number of simple cycles in it. A simple cycle is a cycle with no repeated vertices or edges.
The first line of input contains two integers *n* and *m* (1<=≤<=*n*<=≤<=19, 0<=≤<=*m*) – respectively the number of vertices and edges of the graph. Each of the subsequent *m* lines contains tw... | {"inputs": ["4 6\n1 2\n1 3\n1 4\n2 3\n2 4\n3 4", "10 3\n4 8\n9 4\n8 9", "8 28\n1 2\n1 3\n1 4\n1 5\n1 6\n1 7\n1 8\n2 3\n2 4\n2 5\n2 6\n2 7\n2 8\n3 4\n3 5\n3 6\n3 7\n3 8\n4 5\n4 6\n4 7\n4 8\n5 6\n5 7\n5 8\n6 7\n6 8\n7 8", "12 10\n1 6\n4 5\n4 9\n5 10\n6 12\n7 9\n7 10\n8 10\n10 12\n11 12", "3 0", "6 0", "2 1\n1 2", "2 1\n1... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 1 | codeforces | Okay, I need to find the number of simple cycles in an undirected graph. Let's think about how to approach this.
First, what's a simple cycle? It's a path that starts and ends at the same vertex, doesn't repeat any vertices or edges, and has at least three edges. So, for example, a triangle (3 vertices connected in a... | To solve this problem, we need to count the number of simple cycles in an undirected graph. A simple cycle is defined as a cycle with no repeated vertices or edges and must have at least three edges. The approach involves using a backtracking algorithm to explore all possible cycles starting from each vertex while ensu... | true | ||
1920af96049061e297fe0a7e0d5bea73 | Driving Test | Polycarp has just attempted to pass the driving test. He ran over the straight road with the signs of four types.
- speed limit: this sign comes with a positive integer number — maximal speed of the car after the sign (cancel the action of the previous sign of this type); - overtake is allowed: this sign means that ... | {"inputs": ["11\n1 100\n3 70\n4\n2\n3 120\n5\n3 120\n6\n1 150\n4\n3 300", "5\n1 100\n3 200\n2\n4\n5", "7\n1 20\n2\n6\n4\n6\n6\n2", "1\n1 100", "2\n1 100\n2", "10\n1 37\n6\n5\n2\n5\n6\n5\n2\n4\n2", "10\n1 5\n4\n5\n4\n1 21\n6\n1 10\n1 1\n2\n3 1"], "outputs": ["2", "0", "2", "0", "0", "2", "1"]} | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 17 | codeforces | Okay, so I need to solve this programming problem. Let's try to understand the problem step by step.
The problem is about Polycarp driving and passing signs, and certain events happening. We need to find the minimal number of signs he can claim to have not noticed so that there are no rule violations in his actions.
... | To solve this problem, we need to determine the minimal number of road signs Polycarp should say he didn't notice, such that all his actions (changing speed and overtaking) are valid according to the remaining signs he did notice. The solution involves tracking the possible states of the car's speed limit and overtake ... | false | Code is incorrect. | |
1954f4f3cff193e51aefea4a144bdfcb | Save Luke | Luke Skywalker got locked up in a rubbish shredder between two presses. R2D2 is already working on his rescue, but Luke needs to stay alive as long as possible. For simplicity we will assume that everything happens on a straight line, the presses are initially at coordinates 0 and *L*, and they move towards each other ... | {"inputs": ["2 6 2 2", "1 9 1 2", "1 10000 1 1", "9999 10000 10000 10000", "1023 2340 1029 3021", "2173 2176 10000 9989", "1 2 123 1", "123 1242 12 312", "2 9997 3 12", "1 10000 10000 10000", "3274 4728 888 4578", "4600 9696 5634 8248", "2255 7902 8891 429", "6745 9881 2149 9907", "4400 8021 6895 2089", "5726 9082 7448... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 241 | codeforces | Okay, let's try to figure out how to solve this problem. Hmm. So, the problem is about two presses moving towards each other on a straight line. Luke is in between them, and he has a certain width d. The presses start at positions 0 and L. Their speeds are v1 and v2 respectively. We need to find the maximum time Luke c... | To solve this problem, we need to determine the maximum time Luke can stay alive between two moving presses that are closing in on each other. The solution involves calculating the time it takes for the distance between the presses to reduce to Luke's width, considering their initial positions and speeds.
### Approach... | false | Code is incorrect. | |
195a674edfdb1beb7260a34b31fe41f6 | Weird Game | Yaroslav, Andrey and Roman can play cubes for hours and hours. But the game is for three, so when Roman doesn't show up, Yaroslav and Andrey play another game.
Roman leaves a word for each of them. Each word consists of 2·*n* binary characters "0" or "1". After that the players start moving in turns. Yaroslav moves f... | {"inputs": ["2\n0111\n0001", "3\n110110\n001001", "3\n111000\n000111", "4\n01010110\n00101101", "4\n01100000\n10010011", "4\n10001001\n10101101", "3\n000000\n000100", "2\n0000\n1110", "4\n11111111\n10100110", "4\n10100111\n11011000", "4\n00101011\n11110100", "4\n11000011\n00111100", "4\n11101111\n01000110", "4\n0111011... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 8 | codeforces | Okay, let's try to figure out this problem. So the problem is about two players, Yaroslav and Andrey, playing a game where they choose characters from their respective strings to form the largest possible binary number. The goal is to determine who will win if both play optimally. The solution needs to be efficient sin... | To solve this problem, we need to determine the winner of a game where Yaroslav and Andrey take turns picking positions from their respective binary strings to form the largest possible number. The winner is determined by comparing the maximum numbers each can form, which depends on the count of '1's they collect optim... | true | ||
19652a10a291705df6b35df2213433ea | Random Teams | *n* participants of the competition were split into *m* teams in some manner so that each team has at least one participant. After the competition each pair of participants from the same team became friends.
Your task is to write a program that will find the minimum and the maximum number of pairs of friends that coul... | {"inputs": ["5 1", "3 2", "6 3", "5 3", "10 2", "10 6", "1000000000 1", "5000000 12", "1833 195", "1000000000 1000000000", "1000000000 1000000", "1000000000 32170", "1000000 1000", "1234 1123", "599222887 298488", "999999999 500000000", "1000000000 384842119", "1000000000 384842119", "1000000000 2", "1000000000 9999999... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 239 | codeforces | Okay, I need to solve this programming problem where I have to find the minimum and maximum number of friend pairs formed when n participants are divided into m teams. Each team has at least one member. The pairs are formed between all members of the same team. Let's think through this.
First, let's understand the pro... | To solve this problem, we need to determine the minimum and maximum number of pairs of friends that can be formed when splitting `n` participants into `m` teams, where each team must have at least one participant. Each pair of participants in the same team becomes friends.
### Approach
1. **Maximum Number of Pairs**:
... | true | ||
19822dd149e51b421976d336fb1fb4a8 | Equal Sums | You are given $k$ sequences of integers. The length of the $i$-th sequence equals to $n_i$.
You have to choose exactly two sequences $i$ and $j$ ($i \ne j$) such that you can remove exactly one element in each of them in such a way that the sum of the changed sequence $i$ (its length will be equal to $n_i - 1$) equals... | {"inputs": ["2\n5\n2 3 1 3 2\n6\n1 1 2 2 2 1", "3\n1\n5\n5\n1 1 1 1 1\n2\n2 3", "4\n6\n2 2 2 2 2 2\n5\n2 2 2 2 2\n3\n2 2 2\n5\n2 2 2 2 2", "2\n2\n0 -10000\n2\n10000 0"], "outputs": ["YES\n2 1\n1 4", "NO", "YES\n4 1\n2 5", "YES\n2 1\n1 2"]} | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 37 | codeforces | Okay, let's try to solve this programming problem. So, the problem is, given k sequences, find two distinct sequences where we can remove exactly one element from each such that their sums are equal. If there are multiple solutions, any is acceptable. Otherwise, output NO.
First, let's understand the problem step by s... | To solve this problem, we need to determine if there exist two distinct sequences from which we can remove exactly one element each such that the sums of the modified sequences are equal. If such a pair exists, we should output the indices of the sequences and the positions of the elements to remove. If no such pair ex... | false | Code is incorrect. | |
198410fd502067f83e7e63ffb6065693 | Distance in Tree | A tree is a connected graph that doesn't contain any cycles.
The distance between two vertices of a tree is the length (in edges) of the shortest path between these vertices.
You are given a tree with *n* vertices and a positive number *k*. Find the number of distinct pairs of the vertices which have a distance of ex... | {"inputs": ["5 2\n1 2\n2 3\n3 4\n2 5", "5 3\n1 2\n2 3\n3 4\n4 5", "10 1\n2 1\n3 1\n4 3\n5 4\n6 5\n7 1\n8 6\n9 2\n10 6", "10 2\n2 1\n3 1\n4 3\n5 4\n6 5\n7 1\n8 6\n9 2\n10 6", "10 3\n2 1\n3 1\n4 3\n5 4\n6 5\n7 1\n8 6\n9 2\n10 6", "50 3\n2 1\n3 2\n4 3\n5 4\n6 5\n7 6\n8 7\n9 8\n10 9\n11 10\n12 11\n13 12\n14 13\n15 14\n16 1... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 12 | codeforces | Okay, I need to solve this problem where I have to count the number of pairs of nodes in a tree that are exactly k edges apart. Let's see. The problem says that the tree has n nodes and the required distance is k. So, the input is the tree's edges, and I have to compute the number of such pairs.
First, I remember that... | To solve this problem, we need to count the number of distinct pairs of vertices in a tree that have a distance of exactly \( k \) edges between them. The solution involves using a breadth-first search (BFS) approach to efficiently compute the required distances for each node and then aggregating the results.
### Appr... | true | ||
19a6ec21c8071eaac811c5d886bdbcb5 | Bear and Friendship Condition | Bear Limak examines a social network. Its main functionality is that two members can become friends (then they can talk with each other and share funny pictures).
There are *n* members, numbered 1 through *n*. *m* pairs of members are friends. Of course, a member can't be a friend with themselves.
Let A-B denote that... | {"inputs": ["4 3\n1 3\n3 4\n1 4", "4 4\n3 1\n2 3\n3 4\n1 2", "10 4\n4 3\n5 10\n8 9\n1 2", "3 2\n1 2\n2 3", "3 0", "15 42\n8 1\n3 14\n7 14\n12 3\n7 9\n6 7\n6 12\n14 12\n3 10\n10 14\n6 3\n3 13\n13 10\n7 12\n7 2\n6 10\n11 4\n9 3\n8 4\n7 3\n2 3\n2 10\n9 13\n2 14\n6 14\n13 2\n1 4\n13 6\n7 10\n13 14\n12 10\n13 7\n12 2\n9 10\... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 79 | codeforces | Okay, I need to solve this programming problem. Let's read the problem statement carefully.
The problem is about checking if a social network is "reasonable". The condition for being reasonable is that for every trio of distinct members X, Y, Z, if X is friends with Y and Y is friends with Z, then X must also be frien... | To solve this problem, we need to determine if a social network is "reasonable" based on the given condition. The network is considered reasonable if for every trio of distinct members (X, Y, Z), if X is friends with Y and Y is friends with Z, then X must also be friends with Z. This essentially means that each connect... | true | ||
19abaf75e3070d35d8add03d295b55c9 | Romaji | Vitya has just started learning Berlanese language. It is known that Berlanese uses the Latin alphabet. Vowel letters are "a", "o", "u", "i", and "e". Other letters are consonant.
In Berlanese, there has to be a vowel after every consonant, but there can be any letter after any vowel. The only exception is a consonant... | {"inputs": ["sumimasen", "ninja", "codeforces", "auuaoonntanonnuewannnnpuuinniwoonennyolonnnvienonpoujinndinunnenannmuveoiuuhikucuziuhunnnmunzancenen", "n", "necnei", "nternn", "aucunuohja", "a", "b", "nn", "nnnzaaa", "zn", "ab", "aaaaaaaaaa", "aaaaaaaaab", "aaaaaaaaan", "baaaaaaaaa", "naaaaaaaaa", "nbaaaaaaaa", "bbaaa... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 159 | codeforces | Okay, so I need to solve this problem where I have to check if a given word follows the Berlanese rules. Let's read the problem carefully again.
The problem says that in Berlanese, every consonant (except 'n') must be followed by a vowel. The vowels are a, o, u, i, e. Any consonant can follow a vowel. The exception is... | To solve this problem, we need to determine if a given word conforms to the rules of the Berlanese language. Specifically, we need to check if every consonant (except 'n') is followed by a vowel, and ensure the word does not end with a consonant other than 'n'.
### Approach
1. **Identify Vowels and Consonants**: Vowel... | true | ||
19c0291bd1c79abe04f3ac01b584c1e5 | Powerful array | An array of positive integers *a*1,<=*a*2,<=...,<=*a**n* is given. Let us consider its arbitrary subarray *a**l*,<=*a**l*<=+<=1...,<=*a**r*, where 1<=≤<=*l*<=≤<=*r*<=≤<=*n*. For every positive integer *s* denote by *K**s* the number of occurrences of *s* into the subarray. We call the power of the subarray the sum of p... | {"inputs": ["3 2\n1 2 1\n1 2\n1 3", "8 3\n1 1 2 2 1 3 1 1\n2 7\n1 6\n2 7", "20 8\n1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2\n4 15\n1 2\n2 20\n7 7\n13 18\n7 7\n3 19\n3 8", "10 5\n10 9 8 7 6 5 4 3 2 1\n4 8\n1 10\n3 9\n2 2\n5 10", "8 10\n100 100 100 100 100 100 100 100\n1 8\n2 8\n3 8\n4 8\n5 8\n6 8\n7 8\n8 8\n1 1\n1 5", "1 ... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 1 | codeforces | Okay, so I need to solve this programming problem. Let's read the problem statement carefully.
The task is to compute the "power" of several subarrays of a given array. The power is defined as the sum of K_s squared multiplied by s, for each s present in the subarray. K_s is the number of times s occurs in the subarra... | To solve this problem, we need to efficiently compute the "power" of multiple subarrays of a given array. The power of a subarray is defined as the sum of \( K_s^2 \times s \) for each distinct element \( s \) in the subarray, where \( K_s \) is the count of \( s \) in the subarray. Given the constraints, a direct appr... | true | ||
19d2ecccfa97f05d68273ed6f8fa0fd3 | Permutations | You are given *n* *k*-digit integers. You have to rearrange the digits in the integers so that the difference between the largest and the smallest number was minimum. Digits should be rearranged by the same rule in all integers.
The first line contains integers *n* and *k* — the number and digit capacity of numbers cor... | {"inputs": ["6 4\n5237\n2753\n7523\n5723\n5327\n2537", "3 3\n010\n909\n012", "7 5\n50808\n36603\n37198\n44911\n29994\n42543\n50156", "5 5\n61374\n74304\n41924\n46010\n09118", "8 8\n68785928\n11981277\n32480720\n72495162\n69969623\n42118868\n64235849\n81412116", "7 1\n1\n0\n8\n5\n4\n9\n8", "3 8\n34848224\n16307102\n2518... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 16 | codeforces | Okay, so I need to solve this programming problem. Let me read the problem statement carefully.
The problem says that we have n numbers, each with k digits. We can rearrange the digits in all of them using the same permutation. For example, if we choose to swap the first and second digits in all numbers, then every nu... | To solve this problem, we need to rearrange the digits of each given number using the same permutation rule such that the difference between the largest and smallest numbers is minimized. The solution involves generating all possible permutations of the digits' positions and applying each permutation to all numbers to ... | true | ||
19d770e2c74d695b37b93d822093c5aa | Marathon | Valera takes part in the Berland Marathon. The marathon race starts at the stadium that can be represented on the plane as a square whose lower left corner is located at point with coordinates (0,<=0) and the length of the side equals *a* meters. The sides of the square are parallel to coordinate axes.
As the length o... | {"inputs": ["2 5\n2", "4.147 2.8819\n6", "16904.8597 21646.2846\n10", "40356.3702 72886.7142\n100", "70092.4982 95833.7741\n1000", "39712.7105 19285.2846\n10000", "97591.0354 49021.4126\n100000", "1 100000\n100000", "1 1\n1", "99999.9999 99999.9998\n100000", "1.0001 9999.9999\n100000", "100000 1\n100000", "100000 10000... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 6 | codeforces | Okay, I need to solve this programming problem. Let me read the problem carefully.
The problem is about Valera running a marathon around a square stadium. The square has its lower-left corner at (0, 0) with side length a. Valera runs counter-clockwise, and after every d meters, he gets a drink. The coach needs to know... | To solve this problem, we need to determine Valera's position after each segment of his marathon run around a square stadium. Valera starts at the point (0, 0) and runs counter-clockwise. The coach needs to know his position every `d` meters up to `n` times.
### Approach
1. **Understanding the Path**: The stadium is ... | false | Code is incorrect. | |
19dae5f00909e7d63f427950e41e714c | Game with Coins | Two pirates Polycarpus and Vasily play a very interesting game. They have *n* chests with coins, the chests are numbered with integers from 1 to *n*. Chest number *i* has *a**i* coins.
Polycarpus and Vasily move in turns. Polycarpus moves first. During a move a player is allowed to choose a positive integer *x* (2·*x... | {"inputs": ["1\n1", "3\n1 2 3", "100\n269 608 534 956 993 409 297 735 258 451 468 422 125 407 580 769 857 383 419 67 377 230 842 113 169 427 287 75 372 133 456 450 644 303 638 40 217 445 427 730 168 341 371 633 237 951 142 596 528 509 236 782 44 467 607 326 267 15 564 858 499 337 74 346 443 436 48 795 206 403 379 313 3... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 9 | codeforces | Okay, let's see. The problem is about two pirates taking coins from chests in a certain way, and we need to find the minimum number of moves to empty all chests. Hmm.
So, the rules are: each move, a player selects an x such that 2x + 1 ≤ n. Then, they take a coin from x, 2x, 2x+1. But if any of those chests have no co... | To solve this problem, we need to determine the minimum number of moves required for two pirates to empty all chests of coins, following specific rules. Each move allows a player to take a coin from a chest and its two children, if they exist. The goal is to minimize the total number of moves.
### Approach
1. **Revers... | false | Code is incorrect. | |
19e898254aab6b1c7f5fa0c9454533fb | R3D3’s Summer Adventure | R3D3 spent some time on an internship in MDCS. After earning enough money, he decided to go on a holiday somewhere far, far away. He enjoyed suntanning, drinking alcohol-free cocktails and going to concerts of popular local bands. While listening to "The White Buttons" and their hit song "Dacan the Baker", he met anoth... | {"inputs": ["4 1 2", "2 1 5", "3 1 1", "5 5 5", "4 0 0", "6 0 6", "6 6 0", "2 1 2", "100000000 1 0", "2 0 0", "2 100000000 100000000", "2 100000000 0", "2 0 100000000", "100000000 0 0", "100000000 100000000 100000000", "100000000 100000000 0", "100000000 0 100000000", "2 50000000 0", "2 50000000 100000000", "2 50000000... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 2 | codeforces | Okay, let's see. The problem is to create a binary prefix code for n letters such that no code is a prefix of another. And we need to minimize the total cost, where each '0' costs c0 and '1' costs c1. Hmm.
Wait, the example: for n=4, c0=1, c1=2. The output is 12. Let's think. For 4 letters, a possible prefix code is t... | To solve this problem, we need to generate an optimal binary prefix code for a given number of letters such that no code is a prefix of another, while minimizing the total cost. The cost for each '0' and '1' is given, and we need to ensure that the total cost of the entire alphabet is minimized.
### Approach
1. **Prob... | false | Code is incorrect. | |
1a01e8cd6ea9e6b13f69248a9cdca0db | Monitor | Reca company makes monitors, the most popular of their models is AB999 with the screen size *a*<=×<=*b* centimeters. Because of some production peculiarities a screen parameters are integer numbers. Recently the screen sides ratio *x*:<=*y* became popular with users. That's why the company wants to reduce monitor AB999... | {"inputs": ["800 600 4 3", "1920 1200 16 9", "1 1 1 2", "1002105126 227379125 179460772 1295256518", "625166755 843062051 1463070160 1958300154", "248228385 1458744978 824699604 1589655888", "186329049 1221011622 90104472 1769702163", "511020182 242192314 394753578 198572007", "134081812 857875240 82707261 667398699", ... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 34 | codeforces | Okay, let's tackle this problem. Hmm, the task is to find the largest possible screen dimensions that fit within the given a and b (as lower and upper bounds?), while maintaining the aspect ratio x:y. Wait, no, wait. Wait, the problem says that the screen size must be between a and b. Wait, the first line of input is a... | To solve this problem, we need to determine the largest possible screen dimensions that maintain a given aspect ratio while fitting within specified constraints. The solution involves finding the maximum integer dimensions that fit within the constraints and maximize the screen area.
### Approach
1. **Simplify the Asp... | true | ||
1a3833e219a41346e746f849967f9b3c | Meeting | The Super Duper Secret Meeting of the Super Duper Secret Military Squad takes place in a Super Duper Secret Place. The place is an infinite plane with introduced Cartesian coordinate system. The meeting table is represented as a rectangle whose sides are parallel to the coordinate axes and whose vertexes are located at... | {"inputs": ["2 5 4 2\n3\n3 1 2\n5 3 1\n1 3 2", "5 2 6 3\n2\n6 2 2\n6 5 3", "-705 595 -702 600\n1\n-589 365 261", "-555 674 -553 774\n5\n-656 128 631\n597 -220 999\n-399 793 155\n-293 -363 1000\n-557 -914 1000", "-210 783 -260 833\n10\n406 551 1000\n372 -373 999\n-12 -532 999\n371 -30 999\n258 480 558\n648 -957 1000\n-7... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 7 | codeforces | Okay, let's tackle this problem. So, the task is to determine the number of generals sitting on the perimeter of a rectangular table who are not warmed by any radiator. Each radiator has a certain radius, and if a general is within that radius from the radiator (distance less than or equal), they don't need a blanket. ... | To solve this problem, we need to determine the number of generals sitting on the perimeter of a rectangular table who are not warmed by any radiators. Each radiator has a heating radius, and a general within this radius does not need a blanket. The solution involves generating all perimeter points of the rectangle and... | true | ||
1a3944c48c6207815c1e4c534d54831f | Sereja and Table | Sereja has an *n*<=×<=*m* rectangular table *a*, each cell of the table contains a zero or a number one. Sereja wants his table to meet the following requirement: each connected component of the same values forms a rectangle with sides parallel to the sides of the table. Rectangles should be filled with cells, that is,... | {"inputs": ["5 5 2\n1 1 1 1 1\n1 1 1 1 1\n1 1 0 1 1\n1 1 1 1 1\n1 1 1 1 1", "3 4 1\n1 0 0 0\n0 1 1 1\n1 1 1 0", "3 4 1\n1 0 0 1\n0 1 1 0\n1 0 0 1", "8 1 4\n0\n0\n0\n1\n0\n1\n1\n0", "3 10 7\n0 1 0 0 1 0 1 0 0 0\n0 0 1 1 0 0 0 1 0 1\n1 0 1 1 1 0 1 1 0 0", "4 9 7\n0 0 0 1 0 1 1 0 0\n1 1 1 0 0 0 0 1 1\n1 1 0 0 1 1 0 1 0\n0... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 3 | codeforces | Okay, let's see. The problem is about determining if Sereja can change at most k cells in a grid so that each connected component of 0s or 1s forms a filled rectangle. And if possible, find the minimal number of changes required. If not possible even with k changes, output -1.
Hmm. So first, we need to check if the cu... | To solve this problem, we need to determine if Sereja can change at most `k` cells in a grid such that each connected component of 0s or 1s forms a filled rectangle. If possible, we need to find the minimum number of changes required. If not possible even with `k` changes, we should output -1.
### Approach
1. **Check ... | false | Code is incorrect. | |
1a542256851fbf03363cd7fffc84c4a0 | Bear and Tree Jumps | A tree is an undirected connected graph without cycles. The distance between two vertices is the number of edges in a simple path between them.
Limak is a little polar bear. He lives in a tree that consists of *n* vertices, numbered 1 through *n*.
Limak recently learned how to jump. He can jump from a vertex to any v... | {"inputs": ["6 2\n1 2\n1 3\n2 4\n2 5\n4 6", "13 3\n1 2\n3 2\n4 2\n5 2\n3 6\n10 6\n6 7\n6 13\n5 8\n5 9\n9 11\n11 12", "3 5\n2 1\n3 1", "2 1\n1 2", "2 5\n2 1", "15 1\n12 9\n13 7\n1 3\n10 4\n9 2\n2 15\n11 4\n2 14\n10 8\n6 7\n12 5\n8 7\n3 10\n10 2", "4 2\n3 4\n2 4\n3 1", "12 3\n5 11\n10 11\n6 4\n8 9\n4 12\n10 7\n4 1\n3 1\n... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 1 | codeforces | Okay, let's see. I need to solve this problem where I have to calculate the sum of the minimum number of jumps Limak needs to get from s to t for all ordered pairs s <= t. The tree has up to 200,000 nodes, which is quite big, so the solution has to be efficient.
Hmm. The key here is to find f(s, t) for each pair. Sinc... | To solve this problem, we need to calculate the sum of the minimum number of jumps required for Limak to travel between all pairs of vertices (s, t) where s < t in a tree. The solution involves efficiently computing the distances between all pairs of vertices and then determining the minimum jumps using these distances... | false | Code is incorrect. | |
1aa40a049ab142e496e372c4df124c0a | Perfect Security | Alice has a very important message *M* consisting of some non-negative integers that she wants to keep secret from Eve. Alice knows that the only theoretically secure cipher is one-time pad. Alice generates a random key *K* of the length equal to the message's length. Alice computes the bitwise xor of each element of t... | {"inputs": ["3\n8 4 13\n17 2 7", "5\n12 7 87 22 11\n18 39 9 12 16", "10\n331415699 278745619 998190004 423175621 42983144 166555524 843586353 802130100 337889448 685310951\n226011312 266003835 342809544 504667531 529814910 684873393 817026985 844010788 993949858 1031395667", "5\n134 246 57 176 239\n14 83 97 175 187", "... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 3 | codeforces | Okay, let's tackle this problem. So, the task is to find the lexicographically smallest possible original message O, given the encrypted message A and the permuted key P. The key point is that the key K was a permutation of P. So, each element in K is exactly the elements of P, just in some order. Then, for each positi... | To solve this problem, we need to determine the lexicographically smallest possible original message \( O \) given the encrypted message \( A \) and a permuted key \( P \). The solution involves using a bitwise XOR operation and a trie data structure to efficiently find the optimal permutation of the key.
### Approach... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.