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 |
|---|---|---|---|---|---|---|---|---|---|
4218b321e26d2ddfec1d7e89ce1f3bca | none | Santa Claus likes palindromes very much. There was his birthday recently. *k* of his friends came to him to congratulate him, and each of them presented to him a string *s**i* having the same length *n*. We denote the beauty of the *i*-th string by *a**i*. It can happen that *a**i* is negative — that means that Santa d... | {"inputs": ["7 3\nabb 2\naaa -3\nbba -1\nzyz -4\nabb 5\naaa 7\nxyx 4", "3 1\na 1\na 2\na 3", "2 5\nabcde 10000\nabcde 10000", "10 10\nnjxbzflaka -1\nfelbvvtkja 6\ngxiuztqkcw 5\naomvscmtti 6\njsqmkoyuca -2\nwckqtzuixg 5\najktvvblef -5\nittmcsvmoa -1\nakalfzbxjn 10\nacuyokmqsj 8", "10 20\njvyxocgomfmrtllgmagp 13\ngvtjnya... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 5 | codeforces | |
421b45ffdfe79c9f1edcd8d6002e3e6b | Beautiful Function | Every day Ruslan tried to count sheep to fall asleep, but this didn't help. Now he has found a more interesting thing to do. First, he thinks of some set of circles on a plane, and then tries to choose a beautiful set of points, such that there is at least one point from the set inside or on the border of each of the i... | {"inputs": ["3\n0 10 4\n10 0 4\n20 10 4", "3\n0 0 2\n5 7 5\n20 25 10", "1\n0 0 2", "4\n0 0 2\n50 50 2\n50 0 2\n0 50 2", "1\n50 50 50", "50\n48 45 42\n32 45 8\n15 41 47\n32 29 38\n7 16 48\n19 9 21\n18 40 5\n39 40 7\n37 0 6\n42 15 37\n9 33 37\n40 41 33\n25 43 2\n23 21 38\n30 20 32\n28 15 5\n47 9 19\n47 22 26\n26 9 18\n24... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 1 | codeforces | |
422bf825badd0a5368d73f8ba0f21a26 | Brevity is Soul of Wit | As we communicate, we learn much new information. However, the process of communication takes too much time. It becomes clear if we look at the words we use in our everyday speech.
We can list many simple words consisting of many letters: "information", "technologies", "university", "construction", "conservatoire", "r... | {"inputs": ["6\nprivet\nspasibo\ncodeforces\njava\nmarmelad\nnormalno", "5\naaa\naa\na\naaaa\naaaaa", "26\naaaaa\naaaab\naaaac\naaaad\naaaae\naaaaf\naaaag\naaaah\naaaai\naaaaj\naaaak\naaaal\naaaam\naaaan\naaaao\naaaap\naaaaq\naaaar\naaaas\naaaat\naaaau\naaaav\naaaaw\naaaax\naaaay\naaaaz", "26\naaaa\naaab\naaac\naaad\na... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 1 | codeforces | |
4232ec75dc18ac6e0a61e3e5a668e21d | Amr and The Large Array | Amr has got a large array of size *n*. Amr doesn't like large arrays so he intends to make it smaller.
Amr doesn't care about anything in the array except the beauty of it. The beauty of the array is defined to be the maximum number of times that some number occurs in this array. He wants to choose the smallest subseg... | {"inputs": ["5\n1 1 2 2 1", "5\n1 2 2 3 1", "6\n1 2 2 1 1 2", "10\n1 1000000 2 1000000 3 2 1000000 1 2 1", "10\n1 2 3 4 5 5 1 2 3 4", "10\n1 1 2 1 1 2 2 1 2 3", "10\n5 4 3 2 1 1 2 3 4 5", "10\n1 10 100 1000 10000 1 10 100 1000 10000", "10\n9 9 9 9 8 9 8 8 8 8", "10\n1 11 111 1111 1 11 11 1 1111 1111"], "outputs": ["1 5... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 77 | codeforces | |
426be2cfde0ba66b5780e3542f125b5d | Two Bases | After seeing the "ALL YOUR BASE ARE BELONG TO US" meme for the first time, numbers *X* and *Y* realised that they have different bases, which complicated their relations.
You're given a number *X* represented in base *b**x* and a number *Y* represented in base *b**y*. Compare those two numbers.
The first line of the i... | {"inputs": ["6 2\n1 0 1 1 1 1\n2 10\n4 7", "3 3\n1 0 2\n2 5\n2 4", "7 16\n15 15 4 0 0 7 10\n7 9\n4 8 0 3 1 5 0", "2 2\n1 0\n2 3\n1 0", "2 2\n1 0\n1 3\n1", "10 2\n1 0 1 0 1 0 1 0 1 0\n10 3\n2 2 2 2 2 2 2 2 2 2", "10 16\n15 15 4 0 0 0 0 7 10 9\n7 9\n4 8 0 3 1 5 0", "5 5\n4 4 4 4 4\n4 6\n5 5 5 5", "2 8\n1 0\n4 2\n1 0 0 0"... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 221 | codeforces | |
4290dd7eebb98be6552ad447c1d68e45 | Haar Features | The first algorithm for detecting a face on the image working in realtime was developed by Paul Viola and Michael Jones in 2001. A part of the algorithm is a procedure that computes Haar features. As part of this task, we consider a simplified model of this concept.
Let's consider a rectangular image that is represent... | {"inputs": ["6 8\nBBBBBBBB\nBBBBBBBB\nBBBBBBBB\nWWWWWWWW\nWWWWWWWW\nWWWWWWWW", "3 3\nWBW\nBWW\nWWW", "3 6\nWWBBWW\nWWBBWW\nWWBBWW", "4 4\nBBBB\nBBBB\nBBBB\nBBBW", "10 9\nBWWWBWWBB\nBBWWBWBBW\nBBWBWBWBB\nBWBWBBBBB\nBBWBWBWBW\nBWWBWWBBW\nWBWWWBWWW\nWBBWBWBWW\nBBWWBWWBB\nBBWWBWWBW", "4 1\nW\nW\nB\nB", "2 10\nBBWBWWBWBB\nB... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 11 | codeforces | |
4297a8089e219ee6655d445c9c6e9503 | Circular RMQ | You are given circular array *a*0,<=*a*1,<=...,<=*a**n*<=-<=1. There are two types of operations with it:
- *inc*(*lf*,<=*rg*,<=*v*) — this operation increases each element on the segment [*lf*,<=*rg*] (inclusively) by *v*; - *rmq*(*lf*,<=*rg*) — this operation returns minimal value on the segment [*lf*,<=*rg*] (in... | {"inputs": ["4\n1 2 3 4\n4\n3 0\n3 0 -1\n0 1\n2 1", "1\n-1\n10\n0 0 -1\n0 0\n0 0 1\n0 0\n0 0 1\n0 0\n0 0 0\n0 0\n0 0 -1\n0 0 1", "2\n-1 -1\n10\n0 0\n0 0\n0 0 1\n0 0\n1 1\n0 0 -1\n0 0 0\n0 0 1\n1 1 0\n0 0 -1"], "outputs": ["1\n0\n0", "-2\n-1\n0\n0", "-1\n-1\n0\n-1"]} | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 8 | codeforces | |
42ad930ecd13a48ee6b60a077599f993 | Sequence | Little Petya likes to play very much. And most of all he likes to play the following game:
He is given a sequence of *N* integer numbers. At each step it is allowed to increase the value of any number by 1 or to decrease it by 1. The goal of the game is to make the sequence non-decreasing with the smallest number of s... | {"inputs": ["5\n3 2 -1 2 11", "5\n2 1 1 1 1", "5\n0 0 0 0 0", "1\n11", "2\n10 2", "6\n1000000000 -1000000000 1000000000 -1000000000 1000000000 -1000000000", "7\n1000000000 -1000000000 1000000000 -1000000000 1000000000 -1000000000 1000000000", "10\n3 0 5 10 10 9 10 8 8 1", "20\n5 5 6 5 10 9 4 0 0 0 7 7 7 5 6 7 5 6 5 6",... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 7 | codeforces | |
42c6a5a548dc05112d0702ad7a0913f6 | The table | Harry Potter has a difficult homework. Given a rectangular table, consisting of *n*<=×<=*m* cells. Each cell of the table contains the integer. Harry knows how to use two spells: the first spell change the sign of the integers in the selected row, the second — in the selected column. Harry's task is to make non-negativ... | {"inputs": ["4 1\n-1\n-1\n-1\n-1", "2 4\n-1 -1 -1 2\n1 1 1 1", "10 5\n1 7 1 6 -3\n8 -8 0 -7 -8\n7 -10 -8 -3 6\n-3 0 -9 0 -3\n-1 5 -2 -9 10\n-2 9 2 0 7\n5 0 -1 -10 6\n7 -8 -3 -9 1\n-5 10 -10 5 9\n-7 4 -8 0 -4", "5 10\n-2 -7 -10 -9 5 -9 -3 8 -8 5\n3 0 9 8 -4 -3 -8 1 8 1\n2 3 7 5 -8 -3 0 -9 -7 -2\n-6 -7 0 0 6 9 -8 6 -8 3\... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 1 | codeforces | |
42c910c4a6919aef7498053ae7f7b086 | Cubical Planet | You can find anything whatsoever in our Galaxy! A cubical planet goes round an icosahedral star. Let us introduce a system of axes so that the edges of the cubical planet are parallel to the coordinate axes and two opposite vertices lay in the points (0,<=0,<=0) and (1,<=1,<=1). Two flies live on the planet. At the mom... | {"inputs": ["0 0 0\n0 1 0", "1 1 0\n0 1 0", "0 0 0\n1 1 1", "0 0 0\n1 0 0", "0 0 0\n0 1 0", "0 0 0\n1 1 0", "0 0 0\n0 0 1", "0 0 0\n1 0 1", "0 0 0\n0 1 1", "0 0 0\n1 1 1", "1 0 0\n0 0 0", "1 0 0\n0 1 0", "1 0 0\n1 1 0", "1 0 0\n0 0 1", "1 0 0\n1 0 1", "1 0 0\n0 1 1", "1 0 0\n1 1 1", "0 1 0\n0 0 0", "0 1 0\n1 0 0", "0 1... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 135 | codeforces | |
42db725c4f43301d5b259580e315cf37 | Sereja and Algorithm | Sereja loves all sorts of algorithms. He has recently come up with a new algorithm, which receives a string as an input. Let's represent the input string of the algorithm as *q*<==<=*q*1*q*2... *q**k*. The algorithm consists of two steps:
1. Find any continuous subsequence (substring) of three characters of string *q... | {"inputs": ["zyxxxxxxyyz\n5\n5 5\n1 3\n1 11\n1 4\n3 6", "yxzyzxzzxyyzzxxxzyyzzyzxxzxyzyyzxyzxyxxyzxyxzyzxyzxyyxzzzyzxyyxyzxxy\n10\n17 67\n6 35\n12 45\n56 56\n14 30\n25 54\n1 1\n46 54\n3 33\n19 40", "xxxxyyxyyzzyxyxzxyzyxzyyyzyzzxxxxzyyzzzzyxxxxzzyzzyzx\n5\n4 4\n3 3\n1 24\n3 28\n18 39", "yzxyzxyzxzxzyzxyzyzzzyxzyz\n9\n4... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 8 | codeforces | |
42df25d03c42a9281bb42d57dea8b11c | Vladik and Complicated Book | Vladik had started reading a complicated book about algorithms containing *n* pages. To improve understanding of what is written, his friends advised him to read pages in some order given by permutation *P*<==<=[*p*1,<=*p*2,<=...,<=*p**n*], where *p**i* denotes the number of page that should be read *i*-th in turn.
So... | {"inputs": ["5 5\n5 4 3 2 1\n1 5 3\n1 3 1\n2 4 3\n4 4 4\n2 5 3", "6 5\n1 4 3 2 5 6\n2 4 3\n1 6 2\n4 5 4\n1 3 3\n2 6 3", "10 10\n10 1 6 7 9 8 4 3 5 2\n1 1 1\n4 4 4\n7 7 7\n3 3 3\n1 6 5\n2 6 2\n6 8 7\n1 1 1\n7 9 9\n2 9 4", "20 20\n18 17 2 3 16 15 1 9 12 8 20 11 13 14 4 5 19 7 10 6\n13 15 15\n1 1 1\n2 2 2\n11 14 13\n10 11... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 30 | codeforces | |
4322bd062e78cfb6f7bdbdb6c2d4dea5 | Vasya and Types | Programmer Vasya is studying a new programming language &K*. The &K* language resembles the languages of the C family in its syntax. However, it is more powerful, which is why the rules of the actual C-like languages are unapplicable to it. To fully understand the statement, please read the language's descripti... | {"inputs": ["5\ntypedef void* ptv\ntypeof ptv\ntypedef &&ptv node\ntypeof node\ntypeof &ptv", "17\ntypedef void* b\ntypedef b* c\ntypeof b\ntypeof c\ntypedef &b b\ntypeof b\ntypeof c\ntypedef &&b* c\ntypeof c\ntypedef &b* c\ntypeof c\ntypedef &void b\ntypeof b\ntypedef b******* c\ntypeof c\ntypedef &&b* c\ntypeof c", "... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 6 | codeforces | |
43235ed4d2e5609de3c8d6267989703b | SwapSort | In this problem your goal is to sort an array consisting of *n* integers in at most *n* swaps. For the given array find the sequence of swaps that makes the array sorted in the non-descending order. Swaps are performed consecutively, one after another.
Note that in this problem you do not have to minimize the number o... | {"inputs": ["5\n5 2 5 1 4", "6\n10 20 20 40 60 60", "2\n101 100", "1\n1000", "2\n1000000000 -1000000000", "8\n5 2 6 8 3 1 6 8", "2\n200000000 199999999", "3\n100000000 100000002 100000001", "5\n1000000000 -10000000 0 8888888 7777777", "5\n10 30 20 50 40"], "outputs": ["2\n0 3\n4 2", "0", "1\n0 1", "0", "1\n0 1", "4\n0 ... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 9 | codeforces | |
436124fdf51dc694d298b358c9c52de6 | Short Code | Arkady's code contains $n$ variables. Each variable has a unique name consisting of lowercase English letters only. One day Arkady decided to shorten his code.
He wants to replace each variable name with its non-empty prefix so that these new names are still unique (however, a new name of some variable can coincide wi... | {"inputs": ["3\ncodeforces\ncodehorses\ncode", "5\nabba\nabb\nab\naa\naacada", "3\ntelegram\ndigital\nresistance", "1\na", "10\naaaba\nbabba\nbbba\naaabb\nabba\na\nbbb\nbaa\naaba\naa", "10\naaaaaaaaaaaaaaa\naaaaaaaaaaaaaa\naaaaaaaa\naaa\naaaaaaaaaaaa\naa\naaaaaaa\naaaaaaaaa\naaaaaaaaaaaaa\naaaaaaaaaa", "26\ni\nm\nz\na\... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 1 | codeforces | |
43679e980bde9e7eb4cadb169cffb376 | Try and Catch | Vasya is developing his own programming language VPL (Vasya Programming Language). Right now he is busy making the system of exceptions. He thinks that the system of exceptions must function like that.
The exceptions are processed by try-catch-blocks. There are two operators that work with the blocks:
1. The try oper... | {"inputs": ["8\ntry\n try\n throw ( AE ) \n catch ( BE, \"BE in line 3\")\n\n try\n catch(AE, \"AE in line 5\") \ncatch(AE,\"AE somewhere\")", "8\ntry\n try\n throw ( AE ) \n catch ( AE, \"AE in line 3\")\n\n try\n catch(BE, \"BE in line 5\") \ncatch(AE,\"AE somewhere\")", "8\ntry\... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 9 | codeforces | |
43742a6b0a3bfdc144e535cc28eadd52 | Mike and Chocolate Thieves | Bad news came to Mike's village, some thieves stole a bunch of chocolates from the local factory! Horrible!
Aside from loving sweet things, thieves from this area are known to be very greedy. So after a thief takes his number of chocolates for himself, the next thief will take exactly *k* times more than the previous... | {"inputs": ["1", "8", "10", "27", "28206", "32", "115", "81258", "116003", "149344197", "57857854", "999999999999999", "181023403153", "196071196742", "49729446417673", "14821870173923", "29031595887308", "195980601490039", "181076658641313", "166173583620704", "151269640772354", "136366565751970", "121463490731834", "... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 12 | codeforces | |
438d09394374feed263199efaf7d6f1d | Dima and Sequence | Dima got into number sequences. Now he's got sequence *a*1,<=*a*2,<=...,<=*a**n*, consisting of *n* positive integers. Also, Dima has got a function *f*(*x*), which can be defined with the following recurrence:
- *f*(0)<==<=0; - *f*(2·*x*)<==<=*f*(*x*); - *f*(2·*x*<=+<=1)<==<=*f*(*x*)<=+<=1.
Dima wonders, how many... | {"inputs": ["3\n1 2 4", "3\n5 3 1", "2\n469264357 996569493", "6\n396640239 62005863 473635171 329666981 510631133 207643327", "8\n851991424 32517099 310793856 776130403 342626527 58796623 49544509 517126753", "7\n481003311 553247971 728349004 258700257 916143165 398096105 412826266", "4\n363034183 741262741 657823174 ... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 20 | codeforces | |
43ad1fbd0312da59aa03d4cd429e18f2 | Jzzhu and Children | There are *n* children in Jzzhu's school. Jzzhu is going to give some candies to them. Let's number all the children from 1 to *n*. The *i*-th child wants to get at least *a**i* candies.
Jzzhu asks children to line up. Initially, the *i*-th child stands at the *i*-th place of the line. Then Jzzhu start distribution of... | {"inputs": ["5 2\n1 3 1 4 2", "6 4\n1 1 2 2 3 3", "7 3\n6 1 5 4 2 3 1", "10 5\n2 7 3 6 2 5 1 3 4 5", "100 1\n1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 7... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 355 | codeforces | |
43b813e4082830bfb6b515f350e10621 | Big Segment | A coordinate line has *n* segments, the *i*-th segment starts at the position *l**i* and ends at the position *r**i*. We will denote such a segment as [*l**i*,<=*r**i*].
You have suggested that one of the defined segments covers all others. In other words, there is such segment in the given set, which contains all oth... | {"inputs": ["3\n1 1\n2 2\n3 3", "6\n1 5\n2 3\n1 10\n7 10\n7 7\n10 10", "4\n1 5\n2 2\n2 4\n2 5", "5\n3 3\n1 3\n2 2\n2 3\n1 2", "7\n7 7\n8 8\n3 7\n1 6\n1 7\n4 7\n2 8", "3\n2 5\n3 4\n2 3", "16\n15 15\n8 12\n6 9\n15 16\n8 14\n3 12\n7 19\n9 13\n5 16\n9 17\n10 15\n9 14\n9 9\n18 19\n5 15\n6 19", "9\n1 10\n7 8\n6 7\n1 4\n5 9\n... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 403 | codeforces | |
43c46bb04031f2be203158f0103de1b3 | Segments Removal | Vasya has an array of integers of length *n*.
Vasya performs the following operations on the array: on each step he finds the longest segment of consecutive equal integers (the leftmost, if there are several such segments) and removes it. For example, if Vasya's array is [13,<=13,<=7,<=7,<=7,<=2,<=2,<=2], then after o... | {"inputs": ["4\n2 5 5 2", "5\n6 3 4 1 5", "8\n4 4 4 2 2 100 100 100", "6\n10 10 50 10 50 50", "1\n1", "100\n45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 1 | codeforces | |
442026842a6080e105907e188fe8446f | Travelling Salesman and Special Numbers | The Travelling Salesman spends a lot of time travelling so he tends to get bored. To pass time, he likes to perform operations on numbers. One such operation is to take a positive integer *x* and reduce it to the number of bits set to 1 in the binary representation of *x*. For example for number 13 it's true that 1310<... | {"inputs": ["110\n2", "111111011\n2", "100011110011110110100\n7", "110100110\n0", "10000000000000000000000000000000000000000000\n2", "100000000000000000000100000000000010100100001001000010011101010\n3", "101010110000\n3", "11010110000\n3", "100\n6", "100100100100\n5", "10000000000\n4", "10\n868", "1\n0", "1\n1", "10\n0... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 5 | codeforces | |
444bae627ba01124383dbebb45960ea7 | Semifinals | Two semifinals have just been in the running tournament. Each semifinal had *n* participants. There are *n* participants advancing to the finals, they are chosen as follows: from each semifinal, we choose *k* people (0<=≤<=2*k*<=≤<=*n*) who showed the best result in their semifinals and all other places in the finals g... | {"inputs": ["4\n9840 9920\n9860 9980\n9930 10020\n10040 10090", "4\n9900 9850\n9940 9930\n10000 10020\n10060 10110", "1\n1 2", "1\n2 1", "2\n1 2\n3 4", "2\n3 1\n4 2", "3\n1 3\n2 5\n4 6", "3\n2 1\n4 3\n5 6", "3\n1 4\n2 5\n3 6", "4\n5 1\n6 2\n7 3\n8 4", "2\n1 2\n4 3", "3\n1 2\n3 5\n4 6", "3\n1 2\n3 4\n5 6", "3\n1 3\n2 4\... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 38 | codeforces | |
445d9481502b5c3e25f57cafd9bf8b5a | Canvas Frames | Nicholas, a painter is going to paint several new canvases. Nicholas is sure that the canvases will turn out so great that each one will need framing and being hung on the wall. Frames are what Nicholas decided to begin with.
Nicholas has *n* sticks whose lengths equal *a*1,<=*a*2,<=... *a**n*. Nicholas does not want... | {"inputs": ["5\n2 4 3 2 3", "13\n2 2 4 4 4 4 6 6 6 7 7 9 9", "4\n3 3 3 5", "2\n3 5", "9\n1 2 3 4 5 6 7 8 9", "14\n2 4 2 6 2 3 4 1 4 5 4 3 4 1", "33\n1 2 2 6 10 10 33 11 17 32 25 6 7 29 11 32 33 8 13 17 17 6 11 11 11 8 10 26 29 26 32 33 36", "1\n1", "1\n10", "2\n1 1", "3\n1 1 1", "3\n1 2 2", "3\n3 2 1", "4\n1 1 1 1", "4... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 125 | codeforces | |
4473ff9e4adbc9cb1817d454202ff6d3 | Magic Powder - 1 | This problem is given in two versions that differ only by constraints. If you can solve this problem in large constraints, then you can just write a single solution to the both versions. If you find the problem too difficult in large constraints, you can write solution to the simplified version only.
Waking up in the ... | {"inputs": ["3 1\n2 1 4\n11 3 16", "4 3\n4 3 5 6\n11 12 14 20", "10 926\n5 6 8 1 2 5 1 8 4 4\n351 739 998 725 953 970 906 691 707 1000", "20 925\n7 3 1 2 1 3 1 3 1 2 3 1 5 8 1 3 7 3 4 2\n837 898 965 807 786 670 626 873 968 745 878 359 760 781 829 882 777 740 907 779", "30 300\n1 4 2 1 2 5 6 4 1 3 2 1 1 1 1 1 2 3 1 3 4 ... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 91 | codeforces | |
449f1c28e0986a00b861c10185315278 | Pouring Rain | A lot of people in Berland hates rain, but you do not. Rain pacifies, puts your thoughts in order. By these years you have developed a good tradition — when it rains, you go on the street and stay silent for a moment, contemplate all around you, enjoy freshness, think about big deeds you have to do.
Today everything ... | {"inputs": ["1 2 3 100", "1 1 1 1", "48 7946 7992 72", "72 6791 8546 46", "100 5635 9099 23", "20 287 3845 5", "48 6428 9807 83", "72 5272 4552 64", "100 4117 5106 34", "20 2961 9852 15", "48 1805 3109 93", "72 8534 7042 65", "1 47 80 68", "4 495 8813 1", "5 2797 5925 9", "1 8324 4362 23", "6 1976 8455 3", "7 2644 8080... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 216 | codeforces | |
44c0f23b8d8ca722aa4895215030b6d0 | PolandBall and Hypothesis | PolandBall is a young, clever Ball. He is interested in prime numbers. He has stated a following hypothesis: "There exists such a positive integer *n* that for each positive integer *m* number *n*·*m*<=+<=1 is a prime number".
Unfortunately, PolandBall is not experienced yet and doesn't know that his hypothesis is inc... | {"inputs": ["3", "4", "10", "153", "1000", "1", "2", "5", "6", "7", "8", "9", "11", "998", "996", "36", "210", "270", "306", "330", "336", "600", "726", "988", "12", "987", "13", "986", "14", "985", "15", "984", "16", "983", "17", "982", "18", "981", "19", "980", "20", "979", "21", "978", "22", "977", "23", "976", "24"... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 283 | codeforces | |
44dfc44778d571919af6c6951a9cfbd9 | Permutations | Happy PMP is freshman and he is learning about algorithmic problems. He enjoys playing algorithmic games a lot.
One of the seniors gave Happy PMP a nice game. He is given two permutations of numbers 1 through *n* and is asked to convert the first one to the second. In one move he can remove the last number from the pe... | {"inputs": ["3\n3 2 1\n1 2 3", "5\n1 2 3 4 5\n1 5 2 3 4", "5\n1 5 2 3 4\n1 2 3 4 5", "1\n1\n1", "7\n6 1 7 3 4 5 2\n6 1 7 3 4 5 2", "10\n5 8 1 10 3 6 2 9 7 4\n4 2 6 3 1 9 10 5 8 7", "10\n1 6 10 3 4 9 2 5 8 7\n7 5 1 6 10 3 4 8 9 2", "10\n2 1 10 3 7 8 5 6 9 4\n6 9 2 4 1 10 3 7 8 5", "10\n8 2 10 3 4 6 1 7 9 5\n8 2 10 3 4 6... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 9 | codeforces | |
44f8b44da74a30906d6c591697c555e4 | Green and Black Tea | Innokentiy likes tea very much and today he wants to drink exactly *n* cups of tea. He would be happy to drink more but he had exactly *n* tea bags, *a* of them are green and *b* are black.
Innokentiy doesn't like to drink the same tea (green or black) more than *k* times in a row. Your task is to determine the order ... | {"inputs": ["5 1 3 2", "7 2 2 5", "4 3 4 0", "2 2 0 2", "3 2 0 3", "1 1 0 1", "1 1 1 0", "11 2 3 8", "100000 39 24855 75145", "2 2 2 0", "2 2 1 1", "3 2 2 1", "3 2 1 2", "5 1 4 1", "10 1 7 3", "20 1 5 15", "1000 123 447 553", "3000 70 2946 54", "10000 590 4020 5980", "10001 1841 1052 8949", "50000 104 31045 18955", "59... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 19 | codeforces | |
45282fa05e4b8c2d025dd8d93e75065b | Palindrome pairs | You are given a non-empty string *s* consisting of lowercase letters. Find the number of pairs of non-overlapping palindromic substrings of this string.
In a more formal way, you have to find the quantity of tuples (*a*,<=*b*,<=*x*,<=*y*) such that 1<=≤<=*a*<=≤<=*b*<=<<=*x*<=≤<=*y*<=≤<=|*s*| and substrings *s*[*a*.... | {"inputs": ["aa", "aaa", "abacaba", "aaaaaaaaaa", "aabbb", "abbaa", "bbbbb", "bbaab", "aabba", "aaaaa", "abicabacka", "aiajadabaa", "abacabauabagabaeabacabadabacabbfabacamadabacabaeabacabadabacababcdggdefxeceadaffhecbgpdbeffecdcbfagcbbfgegaggcaffdfiafaeaab", "abacabadabacabaeabacabadabacabafabacabadabqcabaeoqacabagabac... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 11 | codeforces | |
45481b7f95028e4feb5463900ff4ae43 | Kefa and Company | Kefa wants to celebrate his first big salary by going to restaurant. However, he needs company.
Kefa has *n* friends, each friend will agree to go to the restaurant if Kefa asks. Each friend is characterized by the amount of money he has and the friendship factor in respect to Kefa. The parrot doesn't want any friend... | {"inputs": ["4 5\n75 5\n0 100\n150 20\n75 1", "5 100\n0 7\n11 32\n99 10\n46 8\n87 54", "1 1000000000\n15 12", "5 1\n5 9\n2 10\n8 5\n18 12\n1 1", "3 3\n4 15\n0 17\n9 11", "5 10\n8 90\n1009 1000000\n9 121\n10 298\n0 109092", "5 9\n0 98\n2 1000000000\n8 1000000000\n5 999999999\n3 989898989", "4 2\n10909234 9\n10909236 8\n... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 27 | codeforces | |
4563ded09df778b09bd7288d019e0de1 | Perfect Permutation | A permutation is a sequence of integers *p*1,<=*p*2,<=...,<=*p**n*, consisting of *n* distinct positive integers, each of them doesn't exceed *n*. Let's denote the *i*-th element of permutation *p* as *p**i*. We'll call number *n* the size of permutation *p*1,<=*p*2,<=...,<=*p**n*.
Nickolas adores permutations. He lik... | {"inputs": ["1", "2", "4", "3", "5", "6", "7", "20", "8", "9", "10", "11", "21", "50", "51", "52", "84", "86", "100", "98", "96", "33", "34", "36", "38", "40", "42", "44", "46", "48"], "outputs": ["-1", "2 1 ", "2 1 4 3 ", "-1", "-1", "2 1 4 3 6 5 ", "-1", "2 1 4 3 6 5 8 7 10 9 12 11 14 13 16 15 18 17 20 19 ", "2 1 4 3... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 464 | codeforces | |
4588cbcd745d482105ef033b27b0a596 | Shaass and Lights | There are *n* lights aligned in a row. These lights are numbered 1 to *n* from left to right. Initially some of the lights are switched on. Shaass wants to switch all the lights on. At each step he can switch a light on (this light should be switched off at that moment) if there's at least one adjacent light which is a... | {"inputs": ["3 1\n1", "4 2\n1 4", "11 2\n4 8", "4 2\n1 3", "4 4\n1 2 3 4", "4 2\n1 3", "4 4\n1 2 3 4", "1000 3\n100 900 10", "74 13\n6 14 19 20 21 24 30 43 58 61 69 70 73", "74 13\n6 14 19 20 21 24 30 43 58 61 69 70 73", "74 13\n6 14 19 20 21 24 30 43 58 61 69 70 73", "74 13\n6 14 19 20 21 24 30 43 58 61 69 70 73", "74... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 20 | codeforces | |
45986d9ec9e10c4ae93d52ad9184357c | Uncowed Forces | Kevin Sun has just finished competing in Codeforces Round #334! The round was 120 minutes long and featured five problems with maximum point values of 500, 1000, 1500, 2000, and 2500, respectively. Despite the challenging tasks, Kevin was uncowed and bulldozed through all of them, distinguishing himself from the herd a... | {"inputs": ["20 40 60 80 100\n0 1 2 3 4\n1 0", "119 119 119 119 119\n0 0 0 0 0\n10 0", "3 6 13 38 60\n6 10 10 3 8\n9 9", "21 44 11 68 75\n6 2 4 8 4\n2 8", "16 112 50 114 68\n1 4 8 4 9\n19 11", "55 66 75 44 47\n6 0 6 6 10\n19 0", "47 11 88 5 110\n6 10 4 2 3\n10 6", "5 44 61 103 92\n9 0 10 4 8\n15 7", "115 53 96 62 110\n... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 213 | codeforces | |
45cdd77b341010af99c45274268020a2 | Decoding | Polycarp is mad about coding, that is why he writes Sveta encoded messages. He calls the median letter in a word the letter which is in the middle of the word. If the word's length is even, the median letter is the left of the two middle letters. In the following examples, the median letter is highlighted: contest, inf... | {"inputs": ["5\nlogva", "2\nno", "4\nabba", "51\nkfsmpaeviowvkdbuhdagquxxqniselafnfbrgbhmsugcbbnlrvv", "1\nw", "2\ncb", "3\nqok", "4\naegi", "5\noqquy", "6\nulhpnm", "7\nijvxljt", "8\nwwmiwkeo", "9\ngmwqmpfow", "10\nhncmexsslh", "20\nrtcjbjlbtjfmvzdqutuw", "21\ngjyiqoebcnpsdegxnsauh", "30\nudotcwvcwxajkadxqvxvwgmwmnqrb... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 427 | codeforces | |
460c08cffe5027fca3f0e2f9dde6d342 | Playing Cubes | Petya and Vasya decided to play a little. They found *n* red cubes and *m* blue cubes. The game goes like that: the players take turns to choose a cube of some color (red or blue) and put it in a line from left to right (overall the line will have *n*<=+<=*m* cubes). Petya moves first. Petya's task is to get as many pa... | {"inputs": ["3 1", "2 4", "1 1", "2 1", "4 4", "10 7", "5 13", "7 11", "1 2", "10 10", "50 30", "80 120", "304 122", "500 800", "900 1000", "1 1000", "997 9", "341 678", "784 913", "57 888", "100000 100000", "10000 100000", "9999 99999", "12 100000", "9999 31411", "12930 98391", "98813 893", "99801 38179", "831 69318",... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 124 | codeforces | |
463cccac2b9d40599dd729d945815394 | Handshakes | On February, 30th *n* students came in the Center for Training Olympiad Programmers (CTOP) of the Berland State University. They came one by one, one after another. Each of them went in, and before sitting down at his desk, greeted with those who were present in the room by shaking hands. Each of the students who came ... | {"inputs": ["5\n2 1 3 0 1", "9\n0 2 3 4 1 1 0 2 2", "4\n0 2 1 1", "5\n1 0 2 1 0", "1\n0", "5\n3 0 4 1 2", "3\n1 0 0", "7\n3 0 0 4 2 2 1", "10\n1 0 2 3 3 0 4 4 2 5", "7\n2 4 3 5 1 6 0", "10\n6 2 8 1 4 5 7 3 9 3", "5\n2 0 3 1 1", "7\n2 2 3 3 4 0 1", "11\n3 1 1 1 2 2 0 0 2 1 3", "6\n0 1 2 1 2 0", "13\n1 2 0 4 2 1 0 2 0 0 ... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 6 | codeforces | |
4640822bd3e4682b578383e2576f98b9 | New Year and Entity Enumeration | You are given an integer *m*.
Let *M*<==<=2*m*<=-<=1.
You are also given a set of *n* integers denoted as the set *T*. The integers will be provided in base 2 as *n* binary strings of length *m*.
A set of integers *S* is called "good" if the following hold.
1. If , then . 1. If , then 1. 1. All elements of *... | {"inputs": ["5 3\n11010\n00101\n11000", "30 2\n010101010101010010101010101010\n110110110110110011011011011011", "30 10\n001000000011000111000010010000\n000001100001010000000000000100\n000110100010100000000000101000\n110000010000000001000000000000\n100001000000000010010101000101\n001001000000000100000000110000\n00000001... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 3 | codeforces | |
46813e083a580aa84a87678a0366f22b | Cipher | Sherlock Holmes found a mysterious correspondence of two VIPs and made up his mind to read it. But there is a problem! The correspondence turned out to be encrypted. The detective tried really hard to decipher the correspondence, but he couldn't understand anything.
At last, after some thought, he thought of somethin... | {"inputs": ["1\nab", "1\naaaaaaaaaaa", "2\nya\nklmbfxzb", "1\na", "1\nz", "1\naaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "1\nmnmnmnmnmnmnmnmnmnmnmnmnmnmnmnmnmnmnmnmnmnmnmnmnmnmnmnmnmnmnmnmnmnmnmnmnmnmnmnmnmnmnmnmnmnmnmnmnmnmn", "15\nejkf\nkc\nu\nznmjnznzn\nbjk... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 6 | codeforces | |
46a482ff61fe6337db5ac40a5cc6f9f2 | Blood Cousins Return | Polycarpus got hold of a family tree. The found tree describes the family relations of *n* people, numbered from 1 to *n*. Every person in this tree has at most one direct ancestor. Also, each person in the tree has a name, the names are not necessarily unique.
We call the man with a number *a* a 1-ancestor of the man... | {"inputs": ["6\npasha 0\ngerald 1\ngerald 1\nvalera 2\nigor 3\nolesya 1\n5\n1 1\n1 2\n1 3\n3 1\n6 1", "6\nvalera 0\nvalera 1\nvalera 1\ngerald 0\nvalera 4\nkolya 4\n7\n1 1\n1 2\n2 1\n2 2\n4 1\n5 1\n6 1", "1\nc 0\n20\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1", "2... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 3 | codeforces | |
46aca1272ff0ff57506eb619248874fd | Exponential notation | You are given a positive decimal number *x*.
Your task is to convert it to the "simple exponential notation".
Let *x*<==<=*a*·10*b*, where 1<=≤<=*a*<=<<=10, then in general case the "simple exponential notation" looks like "aEb". If *b* equals to zero, the part "Eb" should be skipped. If *a* is an integer, it shou... | {"inputs": ["16", "01.23400", ".100", "100.", "9000", "0.0012", "0001100", "1", "1.0000", "2206815224318443962208128404511577750057653265995300414539703580103256087275661997018352502651118684", ".642190250125247518637240673193254850619739079359757454472743329719747684651927659872735961709249479", "143529100720960530144... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 30 | codeforces | |
46b59a64a8ffb4422af5f48e844aa3b1 | Wet Shark and Bishops | Today, Wet Shark is given *n* bishops on a 1000 by 1000 grid. Both rows and columns of the grid are numbered from 1 to 1000. Rows are numbered from top to bottom, while columns are numbered from left to right.
Wet Shark thinks that two bishops attack each other if they share the same diagonal. Note, that this is the o... | {"inputs": ["5\n1 1\n1 5\n3 3\n5 1\n5 5", "3\n1 1\n2 3\n3 5", "3\n859 96\n634 248\n808 72", "3\n987 237\n891 429\n358 145", "3\n411 81\n149 907\n611 114", "3\n539 221\n895 89\n673 890", "3\n259 770\n448 54\n926 667", "3\n387 422\n898 532\n988 636", "10\n515 563\n451 713\n537 709\n343 819\n855 779\n457 60\n650 359\n631 ... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 95 | codeforces | |
46b8719c37868c51adb2235f67a51d17 | Greed | Jafar has *n* cans of cola. Each can is described by two integers: remaining volume of cola *a**i* and can's capacity *b**i* (*a**i* <=≤<= *b**i*).
Jafar has decided to pour all remaining cola into just 2 cans, determine if he can do this or not!
The first line of the input contains one integer *n* (2<=≤<=*n*<=≤<=100<... | {"inputs": ["2\n3 5\n3 6", "3\n6 8 9\n6 10 12", "5\n0 0 5 0 0\n1 1 8 10 5", "4\n4 1 0 3\n5 2 2 3", "10\n9 10 24 11 1 7 8 3 28 14\n86 20 34 11 22 94 8 16 73 85", "4\n25 35 7 31\n70 37 43 35", "10\n15 26 15 14 14 39 40 4 25 39\n27 72 16 44 69 48 53 17 63 42", "5\n22 5 19 16 32\n26 10 43 38 37", "5\n32 4 22 40 26\n39 20 3... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 424 | codeforces | |
46cfca38244a5a8772fa79339e7ec2e8 | Legacy | Rick and his co-workers have made a new radioactive formula and a lot of bad guys are after them. So Rick wants to give his legacy to Morty before bad guys catch them.
There are *n* planets in their universe numbered from 1 to *n*. Rick is in planet number *s* (the earth) and he doesn't know where Morty is. As we all... | {"inputs": ["3 5 1\n2 3 2 3 17\n2 3 2 2 16\n2 2 2 3 3\n3 3 1 1 12\n1 3 3 17", "4 3 1\n3 4 1 3 12\n2 2 3 4 10\n1 2 4 16", "6 1 5\n1 3 6 80612370", "10 8 7\n1 10 7 366692903\n1 4 8 920363557\n2 7 5 10 423509459\n2 2 5 7 431247033\n2 7 3 5 288617239\n2 7 3 3 175870925\n3 9 3 8 651538651\n3 4 2 5 826387883", "1 1 1\n1 1 1 ... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 1 | codeforces | |
46daac6efffe7aaf48972ca9d1a4c15c | Word Capitalization | Capitalization is writing a word with its first letter as a capital letter. Your task is to capitalize the given word.
Note, that during capitalization all the letters except the first one remains unchanged.
A single line contains a non-empty word. This word consists of lowercase and uppercase English letters. The len... | {"inputs": ["ApPLe", "konjac", "a", "A", "z", "ABACABA", "xYaPxPxHxGePfGtQySlNrLxSjDtNnTaRaEpAhPaQpWnDzMqGgRgEwJxGiBdZnMtHxFbObCaGiCeZkUqIgBhHtNvAqAlHpMnQhNeQbMyZrCdElVwHtKrPpJjIaHuIlYwHaRkAkUpPlOhNlBtXwDsKzPyHrPiUwNlXtTaPuMwTqYtJySgFoXvLiHbQwMjSvXsQfKhVlOxGdQkWjBhEyQvBjPoFkThNeRhTuIzFjInJtEfPjOlOsJpJuLgLzFnZmKvFgFrNsO... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 767 | codeforces | |
46daf8147d3fdd3c5f879a6c1f5892f2 | Petya and His Friends | Little Petya has a birthday soon. Due this wonderful event, Petya's friends decided to give him sweets. The total number of Petya's friends equals to *n*.
Let us remind you the definition of the greatest common divisor: *GCD*(*a*1,<=...,<=*a**k*)<==<=*d*, where *d* represents such a maximal positive number that each *... | {"inputs": ["3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "2", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31", "32", "33", "34", "35", "36", "37", "38", "39", "40", "41", "42", "43", "44", "45", "46", "47", "48", "49", "50"], "outputs": ["15\n10\n... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 52 | codeforces | |
46ecb3ceb53efac8fd05e4dde7dbd4d1 | String Task | Petya started to attend programming lessons. On the first lesson his task was to write a simple program. The program was supposed to do the following: in the given string, consisting if uppercase and lowercase Latin letters, it:
- deletes all the vowels, - inserts a character "." before each consonant, - replaces ... | {"inputs": ["tour", "Codeforces", "aBAcAba", "obn", "wpwl", "ggdvq", "pumesz", "g", "zjuotps", "jzbwuehe", "tnkgwuugu", "kincenvizh", "xattxjenual", "ktajqhpqsvhw", "xnhcigytnqcmy", "jfmtbejyilxcec", "D", "ab", "Ab", "aB", "AB", "ba", "bA", "Ba", "BA", "aab", "baa", "femOZeCArKCpUiHYnbBPTIOFmsHmcpObtPYcLCdjFrUMIyqYzAok... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 643 | codeforces | |
46ff3c92b7b33ba7e270a4dcfa4db14f | An overnight dance in discotheque | The crowdedness of the discotheque would never stop our friends from having fun, but a bit more spaciousness won't hurt, will it?
The discotheque can be seen as an infinite *xy*-plane, in which there are a total of *n* dancers. Once someone starts moving around, they will move only inside their own movement range, whi... | {"inputs": ["5\n2 1 6\n0 4 1\n2 -1 3\n1 -2 1\n4 -1 1", "8\n0 0 1\n0 0 2\n0 0 3\n0 0 4\n0 0 5\n0 0 6\n0 0 7\n0 0 8", "4\n1000000 -1000000 2\n1000000 -1000000 3\n-1000000 1000000 2\n-1000000 1000000 1000000", "15\n-848 0 848\n-758 0 758\n-442 0 442\n-372 0 372\n-358 0 358\n-355 0 355\n-325 0 325\n-216 0 216\n-74 0 74\n-1... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 9 | codeforces | |
475b7be76ae3f929743f3c88553a97fc | Recycling Bottles | It was recycling day in Kekoland. To celebrate it Adil and Bera went to Central Perk where they can take bottles from the ground and put them into a recycling bin.
We can think Central Perk as coordinate plane. There are *n* bottles on the ground, the *i*-th bottle is located at position (*x**i*,<=*y**i*). Both Adil a... | {"inputs": ["3 1 1 2 0 0\n3\n1 1\n2 1\n2 3", "5 0 4 2 2 0\n5\n5 2\n3 0\n5 5\n3 5\n3 3", "107 50 116 37 104 118\n12\n16 78\n95 113\n112 84\n5 88\n54 85\n112 80\n19 98\n25 14\n48 76\n95 70\n77 94\n38 32", "446799 395535 281981 494983 755701 57488\n20\n770380 454998\n147325 211816\n818964 223521\n408463 253399\n49120 2537... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 11 | codeforces | |
475dc6ca9903a8d02e194e325948ea5f | Stones on the Table | There are *n* stones on the table in a row, each of them can be red, green or blue. Count the minimum number of stones to take from the table so that any two neighboring stones had different colors. Stones in a row are considered neighboring if there are no other stones between them.
The first line contains integer *n*... | {"inputs": ["3\nRRG", "5\nRRRRR", "4\nBRBG", "1\nB", "2\nBG", "3\nBGB", "4\nRBBR", "5\nRGGBG", "10\nGGBRBRGGRB", "50\nGRBGGRBRGRBGGBBBBBGGGBBBBRBRGBRRBRGBBBRBBRRGBGGGRB", "15\nBRRBRGGBBRRRRGR", "20\nRRGBBRBRGRGBBGGRGRRR", "25\nBBGBGRBGGBRRBGRRBGGBBRBRB", "30\nGRGGGBGGRGBGGRGRBGBGBRRRRRRGRB", "35\nGBBGBRGBBGGRBBGBRRGGRR... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 557 | codeforces | |
475fa21447f510f90f4948dce380007d | Choosing Laptop | Vasya is choosing a laptop. The shop has *n* laptops to all tastes.
Vasya is interested in the following properties: processor speed, ram and hdd. Vasya is a programmer and not a gamer which is why he is not interested in all other properties.
If all three properties of a laptop are strictly less than those propertie... | {"inputs": ["5\n2100 512 150 200\n2000 2048 240 350\n2300 1024 200 320\n2500 2048 80 300\n2000 512 180 150", "2\n1500 500 50 755\n1600 600 80 700", "2\n1500 512 50 567\n1600 400 70 789", "4\n1000 300 5 700\n1100 400 10 600\n1200 500 15 500\n1300 600 20 400", "10\n2123 389 397 747\n2705 3497 413 241\n3640 984 470 250\n3... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 94 | codeforces | |
478f06460e80a324b95824a6a5f2042e | Simple XML | Let's define a string <x> as an opening tag, where *x* is any small letter of the Latin alphabet. Each opening tag matches a closing tag of the type </x>, where *x* is the same letter.
Tegs can be nested into each other: in this case one opening and closing tag pair is located inside another pair.
Let's d... | {"inputs": ["<a><b><c></c></b></a>", "<a><b></b><d><c></c></d></a>", "<z></z>", "<u><d></d></u><j></j>", "<a></a><n></n><v><r></r></v><z></z>", "<c><l></l><b><w><f><t><m></m></t></f><w></w></w></b></c>", "<u><d><g><k><m><a><u><j><d></d></j></u></a></m><m></m></k></g></d></u>", "<x><a><l></l></a><g><v></v><d></d></g><z>... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 91 | codeforces | |
479b4867ec26d62324e7d5242bf28120 | Jury Marks | Polycarp watched TV-show where *k* jury members one by one rated a participant by adding him a certain number of points (may be negative, i. e. points were subtracted). Initially the participant had some score, and each the marks were one by one added to his score. It is known that the *i*-th jury member gave *a**i* po... | {"inputs": ["4 1\n-5 5 0 20\n10", "2 2\n-2000 -2000\n3998000 4000000", "1 1\n-577\n1273042", "2 1\n614 -1943\n3874445", "3 1\n1416 -1483 1844\n3261895", "5 1\n1035 1861 1388 -622 1252\n2640169", "10 10\n-25 746 298 1602 -1453 -541 -442 1174 976 -1857\n-548062 -548253 -546800 -548943 -548402 -548794 -549236 -548700 -549... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 27 | codeforces | |
479ca5fddac6e338fcb23a04e17b977c | Luba And The Ticket | Luba has a ticket consisting of 6 digits. In one move she can choose digit in any position and replace it with arbitrary digit. She wants to know the minimum number of digits she needs to replace in order to make the ticket lucky.
The ticket is considered lucky if the sum of first three digits equals to the sum of las... | {"inputs": ["000000", "123456", "111000", "120111", "999999", "199880", "899889", "899888", "505777", "999000", "989010", "651894", "858022", "103452", "999801", "999990", "697742", "242367", "099999", "198999", "023680", "999911", "000990", "117099", "990999", "000111", "000444", "202597", "000333", "030039", "000009"... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 81 | codeforces | |
479de0715abdea147828ecdaa989f2df | Sereja and Subsequences | Sereja has a sequence that consists of *n* positive integers, *a*1,<=*a*2,<=...,<=*a**n*.
First Sereja took a piece of squared paper and wrote all distinct non-empty non-decreasing subsequences of sequence *a*. Then for each sequence written on the squared paper, Sereja wrote on a piece of lines paper all sequences t... | {"inputs": ["1\n42", "3\n1 2 2", "5\n1 2 3 4 5", "4\n11479 29359 26963 24465", "5\n5706 28146 23282 16828 9962", "6\n492 2996 11943 4828 5437 32392", "7\n14605 3903 154 293 12383 17422 18717", "8\n19719 19896 5448 21727 14772 11539 1870 19913", "9\n3 3 2 2 3 2 1 1 2", "10\n3 3 3 2 1 2 3 2 3 1", "42\n8 5 1 10 5 9 9 3 5 ... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 2 | codeforces | |
47ee1524fbb3f6faaf6dae5f5894c84b | Painting Pebbles | There are *n* piles of pebbles on the table, the *i*-th pile contains *a**i* pebbles. Your task is to paint each pebble using one of the *k* given colors so that for each color *c* and any two piles *i* and *j* the difference between the number of pebbles of color *c* in pile *i* and number of pebbles of color *c* in p... | {"inputs": ["4 4\n1 2 3 4", "5 2\n3 2 4 1 3", "5 4\n3 2 4 3 5", "4 3\n5 6 7 8", "5 6\n3 7 2 1 2", "9 5\n5 8 7 3 10 1 4 6 3", "2 1\n7 2", "87 99\n90 28 93 18 80 94 68 58 72 45 93 72 11 54 54 48 74 63 73 7 4 54 42 67 8 13 89 32 2 26 13 94 28 46 77 95 94 63 60 7 16 55 90 91 97 80 7 97 8 12 1 32 43 20 79 38 48 22 97 11 92 ... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 61 | codeforces | |
47ff0c9c87017ecba81beeb5b030881e | Mafia | One day *n* friends gathered together to play "Mafia". During each round of the game some player must be the supervisor and other *n*<=-<=1 people take part in the game. For each person we know in how many rounds he wants to be a player, not the supervisor: the *i*-th person wants to play *a**i* rounds. What is the min... | {"inputs": ["3\n3 2 2", "4\n2 2 2 2", "7\n9 7 7 8 8 7 8", "10\n13 12 10 13 13 14 10 10 12 12", "10\n94 96 91 95 99 94 96 92 95 99", "100\n1 555 876 444 262 234 231 598 416 261 206 165 181 988 469 123 602 592 533 97 864 716 831 156 962 341 207 377 892 51 866 96 757 317 832 476 549 472 770 1000 887 145 956 515 992 653 97... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 137 | codeforces | |
4845678942c09d8042afede09d048a1e | Unimodal Array | Array of integers is unimodal, if:
- it is strictly increasing in the beginning; - after that it is constant; - after that it is strictly decreasing.
The first block (increasing) and the last block (decreasing) may be absent. It is allowed that both of this blocks are absent.
For example, the following three arra... | {"inputs": ["6\n1 5 5 5 4 2", "5\n10 20 30 20 10", "4\n1 2 1 2", "7\n3 3 3 3 3 3 3", "6\n5 7 11 11 2 1", "1\n7", "100\n527 527 527 527 527 527 527 527 527 527 527 527 527 527 527 527 527 527 527 527 527 527 527 527 527 527 527 527 527 527 527 527 527 527 527 527 527 527 527 527 527 527 527 527 527 527 527 527 527 527 5... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 159 | codeforces | |
48476289549aff4bc826a1d50d25b85c | Block Towers | Students in a class are making towers of blocks. Each student makes a (non-zero) tower by stacking pieces lengthwise on top of each other. *n* of the students use pieces made of two blocks and *m* of the students use pieces made of three blocks.
The students don’t want to use too many blocks, but they also want to be ... | {"inputs": ["1 3", "3 2", "5 0", "4 2", "0 1000000", "1000000 1", "1083 724", "1184 868", "1285 877", "820189 548173", "968867 651952", "817544 553980", "813242 543613", "961920 647392", "825496 807050", "974174 827926", "969872 899794", "818549 720669", "967227 894524", "185253 152723", "195173 150801", "129439 98443"... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 42 | codeforces | |
4854574506ddb794691963b9439cc563 | Destroying Array | You are given an array consisting of *n* non-negative integers *a*1,<=*a*2,<=...,<=*a**n*.
You are going to destroy integers in the array one by one. Thus, you are given the permutation of integers from 1 to *n* defining the order elements of the array are destroyed.
After each element is destroyed you have to find o... | {"inputs": ["4\n1 3 2 5\n3 4 1 2", "5\n1 2 3 4 5\n4 2 3 5 1", "8\n5 5 4 4 6 6 5 5\n5 2 8 7 1 3 4 6", "10\n3 3 3 5 6 9 3 1 7 3\n3 4 6 7 5 1 10 9 2 8", "17\n12 9 17 5 0 6 5 1 3 1 17 17 2 14 5 1 17\n3 7 5 8 12 9 15 13 11 14 6 16 17 1 10 2 4", "17\n1 6 9 2 10 5 15 16 17 14 17 3 9 8 12 0 2\n9 13 15 14 16 17 11 10 12 4 6 5 7... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 37 | codeforces | |
488c56b385b3bc0349a543525b06b080 | Calendar Reform | Reforms have started in Berland again! At this time, the Parliament is discussing the reform of the calendar. To make the lives of citizens of Berland more varied, it was decided to change the calendar. As more and more people are complaining that "the years fly by...", it was decided that starting from the next year t... | {"inputs": ["25 3", "50 5", "1 1", "1 2", "1 10", "1 5000000", "5000000 5000000", "4000000 5000000", "3000000 5000000", "1000000 5000000", "1 10000000"], "outputs": ["30", "125", "1", "3", "38", "8224640917276", "24674231279431", "21384022194564", "18094224526592", "11514506860120", "32898872196712"]} | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 4 | codeforces | |
48b421286a3242f5c7b4c7f7ae6e7623 | Bear and Prime Numbers | Recently, the bear started studying data structures and faced the following problem.
You are given a sequence of integers *x*1,<=*x*2,<=...,<=*x**n* of length *n* and *m* queries, each of them is characterized by two integers *l**i*,<=*r**i*. Let's introduce *f*(*p*) to represent the number of such indexes *k*, that *... | {"inputs": ["6\n5 5 7 10 14 15\n3\n2 11\n3 12\n4 4", "7\n2 3 5 7 11 4 8\n2\n8 10\n2 123", "9\n50 50 50 50 50 50 50 50 50\n7\n20 20\n8 13\n13 13\n6 14\n3 5\n15 17\n341 1792", "1\n6\n1\n2 3", "1\n10000000\n1\n2000000000 2000000000", "12\n2 4 8 16 32 64 128 256 512 1024 2048 4096\n14\n2 2\n2 2000000000\n4 4\n8 8\n16 16\n3... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 13 | codeforces | |
48b50de9de6967190c06c4926651aaaa | Pythagorean Theorem II | In mathematics, the Pythagorean theorem — is a relation in Euclidean geometry among the three sides of a right-angled triangle. In terms of areas, it states:
In any right-angled triangle, the area of the square whose side is the hypotenuse (the side opposite the right angle) is equal to the sum of the areas of the s... | {"inputs": ["5", "74", "1000", "586", "2", "362", "778", "194", "906", "659", "75", "787", "851", "563", "979", "395", "755", "171", "883", "400", "817", "177", "593", "305", "721", "785", "497", "913", "625", "334", "10000", "9999"], "outputs": ["1", "35", "881", "472", "0", "258", "653", "120", "786", "535", "37", "6... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 97 | codeforces | |
48dea5d3b269153c9936806a0c9b97dc | Perfect Encoding | You are working as an analyst in a company working on a new system for big data storage. This system will store $n$ different objects. Each object should have a unique ID.
To create the system, you choose the parameters of the system — integers $m \ge 1$ and $b_{1}, b_{2}, \ldots, b_{m}$. With these parameters an ID o... | {"inputs": ["36", "37", "12345678901234567890123456789", "1", "2", "3", "4", "7421902501252475186372406731932548506197390793597574544727433297197476846519276598727359617092494798", "710578858933137458068945311385923411361750305113825125553645790612290407508150966702638025462019898281658661470271198618633853971796952242... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 2 | codeforces | |
48e78a1eb2688cd13b05a10a8592caf5 | The Last Fight Between Human and AI | 100 years have passed since the last victory of the man versus computer in Go. Technologies made a huge step forward and robots conquered the Earth! It's time for the final fight between human and robot that will decide the faith of the planet.
The following game was chosen for the fights: initially there is a polynom... | {"inputs": ["1 2\n-1\n?", "2 100\n-10000\n0\n1", "4 5\n?\n1\n?\n1\n?", "68 -9959\n-3666\n-3501\n9169\n5724\n1478\n-643\n-3039\n-5537\n-4295\n-1856\n-6720\n6827\n-39\n-9509\n-7005\n1942\n-5173\n-4564\n2390\n4604\n-6098\n-9847\n-9708\n2382\n7421\n8716\n9718\n9895\n-4553\n-8275\n4771\n1538\n-8131\n9912\n-4334\n-3702\n7035... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 1 | codeforces | |
490145635522fa9a26bed3be4055b932 | Counter Attack | Berland has managed to repel the flatlanders' attack and is now starting the counter attack.
Flatland has *n* cities, numbered from 1 to *n*, and some pairs of them are connected by bidirectional roads. The Flatlandian maps show roads between cities if and only if there is in fact no road between this pair of cities (... | {"inputs": ["4 4\n1 2\n1 3\n4 2\n4 3", "3 1\n1 2", "8 14\n1 3\n1 4\n1 5\n1 6\n1 7\n1 8\n2 3\n2 4\n2 5\n2 6\n2 7\n2 8\n5 6\n6 7", "6 9\n1 4\n1 5\n1 6\n2 4\n2 5\n2 6\n3 4\n3 5\n3 6", "4 6\n3 4\n2 3\n2 4\n1 3\n2 1\n4 1", "4 4\n2 3\n1 2\n3 4\n1 3", "5 8\n5 1\n5 2\n5 3\n3 1\n1 4\n4 2\n3 2\n5 4", "5 10\n3 5\n5 1\n1 3\n1 4\n2... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 1 | codeforces | |
490201d0bd08c1c3ad12301c1024bdd5 | Antipalindrome | A string is a palindrome if it reads the same from the left to the right and from the right to the left. For example, the strings "kek", "abacaba", "r" and "papicipap" are palindromes, while the strings "abb" and "iq" are not.
A substring $s[l \ldots r]$ ($1<=\leq<=l<=\leq<=r<=\leq<=|s|$) of a string $s<==<=s_{1}s_{2}... | {"inputs": ["mew", "wuffuw", "qqqqqqqq", "ijvji", "iiiiiii", "wobervhvvkihcuyjtmqhaaigvvgiaahqmtjyuchikvvhvrebow", "wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww", "wobervhvvkihcuyjtmqhaaigvahheoqleromusrartldojsjvy", "ijvxljt", "fyhcncnchyf", "ffffffffffff", "fyhcncfsepqj", "ybejrrlbcinttnicblrrjeby", "yyyyyyyyyy... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 453 | codeforces | |
493b20f8548f7eeddc61d9e27d46a567 | Beauty Pageant | General Payne has a battalion of *n* soldiers. The soldiers' beauty contest is coming up, it will last for *k* days. Payne decided that his battalion will participate in the pageant. Now he has choose the participants.
All soldiers in the battalion have different beauty that is represented by a positive integer. The v... | {"inputs": ["3 3\n1 2 3", "2 1\n7 12", "1 1\n1000", "5 8\n10 3 8 31 20", "5 15\n1 2 3 4 5", "8 25\n6 8 3 7 2 1 4 9", "10 9\n5 10 2 14 15 6 3 11 4 1", "10 27\n17 53 94 95 57 36 47 68 48 16", "6 5\n17 35 15 11 33 39", "10 27\n17 53 94 95 57 36 47 68 48 16", "30 122\n5858 8519 5558 2397 3059 3710 6238 8547 2167 9401 471 9... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 12 | codeforces | |
496ca3229acb846a688f9099b6dd5e8a | Valera and Elections | The city Valera lives in is going to hold elections to the city Parliament.
The city has *n* districts and *n*<=-<=1 bidirectional roads. We know that from any district there is a path along the roads to any other district. Let's enumerate all districts in some way by integers from 1 to *n*, inclusive. Furthermore, fo... | {"inputs": ["5\n1 2 2\n2 3 2\n3 4 2\n4 5 2", "5\n1 2 1\n2 3 2\n2 4 1\n4 5 1", "5\n1 2 2\n1 3 2\n1 4 2\n1 5 2", "5\n1 5 1\n5 4 2\n4 3 1\n3 2 2", "2\n1 2 1", "10\n7 5 1\n2 1 2\n8 7 2\n2 4 1\n4 5 2\n9 5 1\n3 2 2\n2 10 1\n6 5 2", "2\n2 1 1", "2\n1 2 2", "5\n3 1 1\n4 5 1\n1 4 1\n1 2 1", "5\n1 3 2\n5 4 2\n2 1 2\n4 3 2", "10\... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 27 | codeforces | |
4974f12e3cb593b80705adf0a057f681 | Fair Game | Petya and Vasya decided to play a game. They have *n* cards (*n* is an even number). A single integer is written on each card.
Before the game Petya will choose an integer and after that Vasya will choose another integer (different from the number that Petya chose). During the game each player takes all the cards with... | {"inputs": ["4\n11\n27\n27\n11", "2\n6\n6", "6\n10\n20\n30\n20\n10\n20", "6\n1\n1\n2\n2\n3\n3", "2\n1\n100", "2\n1\n1", "2\n100\n100", "14\n43\n43\n43\n43\n43\n43\n43\n43\n43\n43\n43\n43\n43\n43", "100\n14\n14\n14\n14\n14\n14\n14\n14\n14\n14\n14\n14\n14\n14\n14\n14\n14\n14\n14\n14\n14\n14\n14\n14\n14\n14\n14\n14\n14\n1... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 208 | codeforces | |
4982d2f28521315d88b166ca7f5f239e | Cards | User ainta loves to play with cards. He has *a* cards containing letter "o" and *b* cards containing letter "x". He arranges the cards in a row, and calculates the score of the deck by the formula below.
1. At first, the score is 0. 1. For each block of contiguous "o"s with length *x* the score increases by *x*2. 1.... | {"inputs": ["2 3", "4 0", "0 4", "8 6", "28691 28312", "1 1", "46000 39000", "1234 5678", "19310 18", "38 5", "2 122", "9966 12376", "4 2", "0 26501", "500 500", "98751 29491", "1 18468", "75232 0", "83093 94343", "86224 91008", "92608 85844", "94989 92701", "83195 80484", "4 9", "8 10", "223 874", "206 209", "493 442"... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 4 | codeforces | |
49b905b62f9c5824272b2291ceda48cc | New Year and North Pole | In this problem we assume the Earth to be a completely round ball and its surface a perfect sphere. The length of the equator and any meridian is considered to be exactly 40<=000 kilometers. Thus, travelling from North Pole to South Pole or vice versa takes exactly 20<=000 kilometers.
Limak, a polar bear, lives on the... | {"inputs": ["5\n7500 South\n10000 East\n3500 North\n4444 West\n4000 North", "2\n15000 South\n4000 East", "5\n20000 South\n1000 North\n1000000 West\n9000 North\n10000 North", "3\n20000 South\n10 East\n20000 North", "2\n1000 North\n1000 South", "4\n50 South\n50 North\n15000 South\n15000 North", "1\n1 South", "1\n1 East",... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 6 | codeforces | |
49bbc3a391b0992b425b3d452dcca37e | The Great Mixing | Sasha and Kolya decided to get drunk with Coke, again. This time they have *k* types of Coke. *i*-th type is characterised by its carbon dioxide concentration . Today, on the party in honour of Sergiy of Vancouver they decided to prepare a glass of Coke with carbon dioxide concentration . The drink should also be tasty... | {"inputs": ["400 4\n100 300 450 500", "50 2\n100 25", "500 3\n1000 5 5", "500 1\n1000", "874 3\n873 974 875", "999 2\n1 1000", "326 18\n684 49 373 57 747 132 441 385 640 575 567 665 323 515 527 656 232 701", "314 15\n160 769 201 691 358 724 248 47 420 432 667 601 596 370 469", "0 1\n0", "0 1\n1000", "345 5\n497 135 21 ... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 2 | codeforces | |
49f2657e95388d8b4d1a4f0171e94002 | Caesar's Legions | Gaius Julius Caesar, a famous general, loved to line up his soldiers. Overall the army had *n*1 footmen and *n*2 horsemen. Caesar thought that an arrangement is not beautiful if somewhere in the line there are strictly more that *k*1 footmen standing successively one after another, or there are strictly more than *k*2 ... | {"inputs": ["2 1 1 10", "2 3 1 2", "2 4 1 1", "10 10 5 7", "12 15 7 2", "20 8 4 8", "15 8 2 6", "100 100 10 10", "20 15 10 9", "18 4 3 1", "19 12 5 7", "20 4 9 4", "24 30 5 1", "56 37 4 1", "28 65 5 9", "67 26 6 1", "57 30 5 9", "56 40 3 2", "34 57 1 1", "78 21 10 1", "46 46 2 5", "34 55 2 9", "46 51 4 5", "64 23 3 6",... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 5 | codeforces | |
4a24486ea6580c3b63d77eca7df64ea9 | New Year's Eve | Since Grisha behaved well last year, at New Year's Eve he was visited by Ded Moroz who brought an enormous bag of gifts with him! The bag contains *n* sweet candies from the good ol' bakery, each labeled from 1 to *n* corresponding to its tastiness. No two candies have the same tastiness.
The choice of candies has a d... | {"inputs": ["4 3", "6 6", "2 2", "1022 10", "415853337373441 52", "75 12", "1000000000000000000 1000000000000000000", "1 1", "1000000000000000000 2", "49194939 22", "228104606 17", "817034381 7", "700976748 4", "879886415 9", "18007336 10353515", "196917003 154783328", "785846777 496205300", "964756444 503568330", "848... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 176 | codeforces | |
4a289f586bb2e6645c79c7f0cf249edc | Gerald is into Art | Gerald bought two very rare paintings at the Sotheby's auction and he now wants to hang them on the wall. For that he bought a special board to attach it to the wall and place the paintings on the board. The board has shape of an *a*1<=×<=*b*1 rectangle, the paintings have shape of a *a*2<=×<=*b*2 and *a*3<=×<=*b*3 rec... | {"inputs": ["3 2\n1 3\n2 1", "5 5\n3 3\n3 3", "4 2\n2 3\n1 2", "3 3\n1 1\n1 1", "1000 1000\n999 999\n1 1000", "7 7\n5 5\n2 4", "3 3\n2 2\n2 2", "2 9\n5 1\n3 2", "9 9\n3 8\n5 2", "10 10\n10 5\n4 3", "10 6\n10 1\n5 7", "6 10\n6 3\n6 2", "7 10\n7 5\n1 7", "10 10\n7 4\n3 5", "4 10\n1 1\n9 3", "8 7\n1 7\n3 2", "5 10\n5 2\n3... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 90 | codeforces | |
4a2923425f3801d7d9f54971416d2e24 | Fox And Polygon | Fox Ciel just designed a puzzle game called "Polygon"! It is played using triangulations of a regular *n*-edge polygon. The goal is to transform one triangulation to another by some tricky rules.
Triangulation of an *n*-edge poylgon is a set of *n*<=-<=3 diagonals satisfying the condition that no two diagonals share a... | {"inputs": ["4\n1 3\n2 4", "6\n2 6\n3 6\n4 6\n6 2\n5 2\n4 2", "8\n7 1\n2 7\n7 3\n6 3\n4 6\n6 1\n6 2\n6 3\n6 4\n6 8", "5\n5 2\n2 4\n5 2\n5 3", "5\n5 2\n2 4\n4 1\n3 1", "10\n1 3\n1 4\n1 5\n1 6\n1 7\n1 8\n1 9\n5 1\n5 2\n5 3\n5 7\n5 8\n5 9\n5 10", "20\n15 17\n15 18\n11 15\n11 18\n13 15\n13 11\n6 11\n6 18\n8 11\n8 6\n9 11\n... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 1 | codeforces | |
4a300e8ace2b5a9aa665fdd66426a084 | Economy Game | Kolya is developing an economy simulator game. His most favourite part of the development process is in-game testing. Once he was entertained by the testing so much, that he found out his game-coin score become equal to 0.
Kolya remembers that at the beginning of the game his game-coin score was equal to *n* and that ... | {"inputs": ["1359257", "17851817", "1000000000", "17851818", "438734347", "43873430", "999999987", "27406117", "27404883", "27403649", "27402415", "27401181", "999999999", "999999244", "999129999", "17159199", "13606913", "14841529", "915968473", "980698615", "912331505", "917261049", "999999997", "12345", "1234", "124... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 56 | codeforces | |
4a3abdb3853aba03dd032f21afa9b29e | Vanya and Cubes | Vanya got *n* cubes. He decided to build a pyramid from them. Vanya wants to build the pyramid as follows: the top level of the pyramid must consist of 1 cube, the second level must consist of 1<=+<=2<==<=3 cubes, the third level must have 1<=+<=2<=+<=3<==<=6 cubes, and so on. Thus, the *i*-th level of the pyramid must... | {"inputs": ["1", "25", "2", "4115", "9894", "7969", "6560", "4", "3", "5", "19", "20", "9880", "9879", "7770", "7769", "2925", "220", "219", "3046", "7590", "1014", "7142", "9999", "10000"], "outputs": ["1", "4", "1", "28", "38", "35", "33", "2", "1", "2", "3", "4", "38", "37", "35", "34", "25", "10", "9", "25", "34", ... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 291 | codeforces | |
4a53944b64c9021707880d6929270e7b | Blown Garland | Nothing is eternal in the world, Kostya understood it on the 7-th of January when he saw partially dead four-color garland.
Now he has a goal to replace dead light bulbs, however he doesn't know how many light bulbs for each color are required. It is guaranteed that for each of four colors at least one light is workin... | {"inputs": ["RYBGRYBGR", "!RGYB", "!!!!YGRB", "!GB!RG!Y!", "RYBG", "!Y!!!Y!!G!!!G!!B!!R!!!!B!!!!!Y!!G!R!!!!!!!!!!!!B!!!!GY!B!!!!!YR!G!!!!!!B!Y!B!!!!!!R!G!!!!!!!G!R!!!!B", "!R!GBRYG!RYGB!!G!!YG!!Y!!", "RBGYRBGYRBGYRBGYRBGYRBGYRBGYRBGYRBGYRBGYRBGYRBGYRBGYRBGYRBGYRBGYRBGYRBGYRBGYRBGYRBGYRBGYRBGYRBGYRBGY", "GYRB!", "RBYGR"... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 25 | codeforces | |
4abb8eb6057670c2c03f4e296ac68c82 | Restaurant Tables | In a small restaurant there are *a* tables for one person and *b* tables for two persons.
It it known that *n* groups of people come today, each consisting of one or two people.
If a group consist of one person, it is seated at a vacant one-seater table. If there are none of them, it is seated at a vacant two-seate... | {"inputs": ["4 1 2\n1 2 1 1", "4 1 1\n1 1 2 1", "1 1 1\n1", "2 1 2\n2 2", "5 1 3\n1 2 2 2 1", "7 6 1\n1 1 1 1 1 1 1", "10 2 1\n2 1 2 2 2 2 1 2 1 2", "20 4 3\n2 2 2 2 2 2 2 2 1 2 1 1 2 2 1 2 2 2 1 2", "1 1 1\n1", "1 1 1\n2", "1 200000 200000\n2", "30 10 10\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2", "... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 104 | codeforces | |
4acf4ae14d6675929825cacfbbbf1acd | Nastya Studies Informatics | Today on Informatics class Nastya learned about GCD and LCM (see links below). Nastya is very intelligent, so she solved all the tasks momentarily and now suggests you to solve one of them as well.
We define a pair of integers (*a*,<=*b*) good, if *GCD*(*a*,<=*b*)<==<=*x* and *LCM*(*a*,<=*b*)<==<=*y*, where *GCD*(*a*,... | {"inputs": ["1 2 1 2", "1 12 1 12", "50 100 3 30", "1 1000000000 1 1000000000", "1 1000000000 158260522 200224287", "1 1000000000 2 755829150", "1 1000000000 158260522 158260522", "1 1000000000 877914575 877914575", "232 380232688 116 760465376", "47259 3393570 267 600661890", "1 1000000000 1 672672000", "1000000000 10... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 30 | codeforces | |
4adbfa2180fc0d9acc69d767c335bc86 | Chat Order | Polycarp is a big lover of killing time in social networks. A page with a chatlist in his favourite network is made so that when a message is sent to some friend, his friend's chat rises to the very top of the page. The relative order of the other chats doesn't change. If there was no chat with this friend before, then... | {"inputs": ["4\nalex\nivan\nroman\nivan", "8\nalina\nmaria\nekaterina\ndarya\ndarya\nekaterina\nmaria\nalina", "1\nwdi", "2\nypg\nypg", "3\nexhll\nexhll\narruapexj", "3\nfv\nle\nle", "8\nm\nm\nm\nm\nm\nm\nm\nm", "10\nr\nr\ni\nw\nk\nr\nb\nu\nu\nr", "7\ne\nfau\ncmk\nnzs\nby\nwx\ntjmok", "6\nklrj\nwe\nklrj\nwe\nwe\nwe", "... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 358 | codeforces | |
4ae677cc69c7c41198e0d5325cef87d9 | Xenia and Divisors | Xenia the mathematician has a sequence consisting of *n* (*n* is divisible by 3) positive integers, each of them is at most 7. She wants to split the sequence into groups of three so that for each group of three *a*,<=*b*,<=*c* the following conditions held:
- *a*<=<<=*b*<=<<=*c*; - *a* divides *b*, *b* divide... | {"inputs": ["6\n1 1 1 2 2 2", "6\n2 2 1 1 4 6", "3\n1 2 3", "3\n7 5 7", "3\n1 3 4", "3\n1 1 1", "9\n1 3 6 6 3 1 3 1 6", "6\n1 2 4 1 3 5", "3\n1 3 7", "3\n1 1 1", "9\n1 2 4 1 2 4 1 3 6", "12\n3 6 1 1 3 6 1 1 2 6 2 6", "9\n1 1 1 4 4 4 6 2 2", "9\n1 2 4 6 3 1 3 1 5", "15\n2 1 2 1 3 6 1 2 1 6 1 3 4 6 4", "3\n2 3 6", "3\n2 ... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 155 | codeforces | |
4b157272fc9144a33406e44107e41fc0 | Karen and Coffee | To stay woke and attentive during classes, Karen needs some coffee!
Karen, a coffee aficionado, wants to know the optimal temperature for brewing the perfect cup of coffee. Indeed, she has spent some time reading several recipe books, including the universally acclaimed "The Art of the Covfefe".
She knows *n* coffee ... | {"inputs": ["3 2 4\n91 94\n92 97\n97 99\n92 94\n93 97\n95 96\n90 100", "2 1 1\n1 1\n200000 200000\n90 100", "1 1 1\n1 1\n1 1", "1 1 1\n200000 200000\n200000 200000"], "outputs": ["3\n3\n0\n4", "0", "1", "1"]} | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 107 | codeforces | |
4b2a63e8f645fb7d2ae4b5d1e88f3dd5 | GCD of Polynomials | Suppose you have two polynomials and . Then polynomial can be uniquely represented in the following way:
This can be done using [long division](https://en.wikipedia.org/wiki/Polynomial_long_division). Here, denotes the degree of polynomial *P*(*x*). is called the remainder of division of polynomial by polynomial ... | {"inputs": ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31", "32", "33", "34", "35", "36", "37", "38", "39", "40", "41", "42", "43", "44", "45", "46", "47", "48", "49", "50", "51", "52", "53",... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 11 | codeforces | |
4b3f5628318bf19366fb2f1bd0cf93fc | Domino Effect | Little Chris knows there's no fun in playing dominoes, he thinks it's too random and doesn't require skill. Instead, he decided to play with the dominoes and make a "domino show".
Chris arranges *n* dominoes in a line, placing each piece vertically upright. In the beginning, he simultaneously pushes some of the domino... | {"inputs": ["14\n.L.R...LR..L..", "1\n.", "1\nL", "1\nR", "2\nL.", "2\nRL", "2\n..", "10\nR........L", "9\nR.......L", "6\n..L.RL", "34\n..R...L..RL..RLRLR...L....R....L..", "2\nLR", "2\n.R", "2\nR.", "2\n.L", "3\nRLR", "3\nLRL", "5\n.L.R.", "5\n.R.L.", "5\nRL.RL", "14\nLR..LR....LRLR", "34\n.RL.R.L.R..L.R...L.R....L.R... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 2 | codeforces | |
4b49d862e1af6b9a457569a38e2ed5c2 | Rational Resistance | Mad scientist Mike is building a time machine in his spare time. To finish the work, he needs a resistor with a certain resistance value.
However, all Mike has is lots of identical resistors with unit resistance *R*0<==<=1. Elements with other resistance can be constructed from these resistors. In this problem, we wil... | {"inputs": ["1 1", "3 2", "199 200", "1 1000000000000000000", "3 1", "21 8", "18 55", "1 2", "2 1", "1 3", "2 3", "1 4", "5 2", "2 5", "4 5", "3 5", "13 4", "21 17", "5 8", "13 21", "74 99", "2377 1055", "645597 134285", "29906716 35911991", "3052460231 856218974", "288565475053 662099878640", "11504415412768 127540361... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 65 | codeforces | |
4b555db9f755aa0d187fe9ae322aa163 | Running Track | A boy named Ayrat lives on planet AMI-1511. Each inhabitant of this planet has a talent. Specifically, Ayrat loves running, moreover, just running is not enough for him. He is dreaming of making running a real art.
First, he wants to construct the running track with coating *t*. On planet AMI-1511 the coating of the t... | {"inputs": ["abc\ncbaabc", "aaabrytaaa\nayrat", "ami\nno", "r\nr", "r\nb", "randb\nbandr", "aaaaaa\naaaaa", "aaaaaa\naaaaaaa", "qwerty\nywertyrewqqq", "qwerty\nytrewq", "azaza\nzazaz", "mnbvcxzlkjhgfdsapoiuytrewq\nqwertyuiopasdfghjklzxcvbnm", "imnothalfthemaniusedtobetheresashadowhangingovermeohyesterdaycamesuddenlywgk... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 4 | codeforces | |
4b60048a0e4b413fa9ba63a4af5433db | Lucky Probability | Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.
Petya and his friend Vasya play an interesting game. Petya randomly chooses an integer *p* from the ... | {"inputs": ["1 10 1 10 2", "5 6 8 10 1", "1 20 100 120 5", "1 10 1 10 3", "1 100 1 100 2", "47 95 18 147 4", "1 1000000000 1 1000000000 47", "1 2 3 4 12", "1 50 64 80 4", "1 128 45 99 2", "45 855 69 854 7", "1 1000 1 1000 2", "999 999 1000 1000 1", "789 5888 1 10 7", "1 1000 1 1000 14", "4 4 7 7 2", "7 7 4 4 2", "2588 ... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 10 | codeforces | |
4b6a67bb76e77433f586d37d78ecdfae | Sofa Thief | Yet another round on DecoForces is coming! Grandpa Maks wanted to participate in it but someone has stolen his precious sofa! And how can one perform well with such a major loss?
Fortunately, the thief had left a note for Grandpa Maks. This note got Maks to the sofa storehouse. Still he had no idea which sofa belongs ... | {"inputs": ["2\n3 2\n3 1 3 2\n1 2 2 2\n1 0 0 1", "3\n10 10\n1 2 1 1\n5 5 6 5\n6 4 5 4\n2 1 2 0", "2\n2 2\n2 1 1 1\n1 2 2 2\n1 0 0 0", "1\n1 2\n1 1 1 2\n0 0 0 0", "1\n2 1\n2 1 1 1\n0 0 0 0", "1\n1000 1000\n63 902 63 901\n0 0 0 0", "6\n10 10\n3 6 3 7\n4 9 5 9\n5 4 5 3\n7 1 8 1\n9 10 8 10\n7 7 7 8\n0 5 2 3", "2\n4 4\n3 1 ... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 5 | codeforces | |
4b6ebb7fe049d8c36c6388590e93ec3c | Prime Gift | Opposite to Grisha's nice behavior, Oleg, though he has an entire year at his disposal, didn't manage to learn how to solve number theory problems in the past year. That's why instead of Ded Moroz he was visited by his teammate Andrew, who solemnly presented him with a set of *n* distinct prime numbers alongside with a... | {"inputs": ["3\n2 3 5\n7", "5\n3 7 11 13 31\n17", "2\n41 61\n66", "1\n2\n55", "7\n2 3 5 7 11 13 17\n2666471", "16\n2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53\n755104793", "8\n3 7 13 17 19 29 31 37\n68830", "8\n3 7 11 17 19 23 37 43\n528714", "8\n3 7 13 17 29 41 43 47\n430196", "8\n2 5 7 19 29 31 37 41\n912071", "9\n2 ... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 1 | codeforces | |
4b8bf6a7e20682853f8d4eb7977979bc | Kefa and Park | Kefa decided to celebrate his first big salary by going to the restaurant.
He lives by an unusual park. The park is a rooted tree consisting of *n* vertices with the root at vertex 1. Vertex 1 also contains Kefa's house. Unfortunaely for our hero, the park also contains cats. Kefa has already found out what are the v... | {"inputs": ["4 1\n1 1 0 0\n1 2\n1 3\n1 4", "7 1\n1 0 1 1 0 0 0\n1 2\n1 3\n2 4\n2 5\n3 6\n3 7", "3 2\n1 1 1\n1 2\n2 3", "5 2\n1 1 0 1 1\n1 2\n2 3\n3 4\n4 5", "6 1\n1 0 1 1 0 0\n1 2\n1 3\n1 4\n1 5\n1 6", "7 3\n1 1 1 1 1 0 1\n1 2\n1 3\n2 4\n3 5\n5 6\n6 7", "15 2\n1 0 1 0 1 0 0 0 0 0 0 0 0 0 0\n1 2\n1 3\n2 4\n2 5\n3 6\n3 7... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 44 | codeforces | |
4b9a92245483f4058b4f0cb60081df9b | XOR Equation | Two positive integers *a* and *b* have a sum of *s* and a bitwise XOR of *x*. How many possible values are there for the ordered pair (*a*,<=*b*)?
The first line of the input contains two integers *s* and *x* (2<=≤<=*s*<=≤<=1012, 0<=≤<=*x*<=≤<=1012), the sum and bitwise xor of the pair of positive integers, respectivel... | {"inputs": ["9 5", "3 3", "5 2", "6 0", "549755813887 549755813887", "2 0", "2 2", "433864631347 597596794426", "80 12", "549755813888 549755813886", "643057379466 24429729346", "735465350041 356516240229", "608032203317 318063018433", "185407964720 148793115916", "322414792152 285840263184", "547616456703 547599679487... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 22 | codeforces | |
4b9efbe937a1036c33df235b8132dfe0 | Invariance of Tree | A tree of size *n* is an undirected connected graph consisting of *n* vertices without cycles.
Consider some tree with *n* vertices. We call a tree invariant relative to permutation *p*<==<=*p*1*p*2... *p**n*, if for any two vertices of the tree *u* and *v* the condition holds: "vertices *u* and *v* are connected by a... | {"inputs": ["4\n4 3 2 1", "3\n3 1 2", "3\n3 2 1", "4\n3 4 1 2", "5\n5 3 2 1 4", "8\n1 2 6 4 5 7 8 3", "11\n7 3 5 2 10 1 9 6 8 4 11", "1\n1", "2\n1 2", "2\n2 1", "6\n2 1 6 5 3 4", "6\n2 1 4 5 6 3", "4\n2 3 4 1", "6\n2 3 4 1 6 5", "6\n4 1 2 3 6 5"], "outputs": ["YES\n4 1\n4 2\n1 3", "NO", "YES\n2 1\n2 3", "YES\n4 2\n4 1\... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 5 | codeforces | |
4bf42ec96ffd1342873f59118733cee4 | Full Binary Tree Queries | You have a full binary tree having infinite levels.
Each node has an initial value. If a node has value *x*, then its left child has value 2·*x* and its right child has value 2·*x*<=+<=1.
The value of the root is 1.
You need to answer *Q* queries.
There are 3 types of queries:
1. Cyclically shift the values of... | {"inputs": ["5\n3 12\n1 2 1\n3 12\n2 4 -1\n3 8", "5\n3 14\n1 5 -3\n3 14\n1 3 1\n3 14", "6\n3 1\n2 1 0\n3 10\n2 1 -4\n3 10\n2 10 -5", "3\n3 1000000000000000000\n1 12345 13\n3 1000000000000000000", "10\n3 999\n3 822\n2 339 -75\n2 924 -56\n3 863\n3 311\n1 269 84\n2 604 9\n2 788 -98\n1 233 60", "10\n2 64324170 413214447865... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 1 | codeforces | |
4bfe1e0069a303c77dfd34af728b3070 | Drazil and His Happy Friends | Drazil has many friends. Some of them are happy and some of them are unhappy. Drazil wants to make all his friends become happy. So he invented the following plan.
There are *n* boys and *m* girls among his friends. Let's number them from 0 to *n*<=-<=1 and 0 to *m*<=-<=1 separately. In *i*-th day, Drazil invites -th ... | {"inputs": ["2 3\n0\n1 0", "2 4\n1 0\n1 2", "2 3\n1 0\n1 1", "16 88\n6 5 14 2 0 12 7\n30 21 64 35 79 74 39 63 44 81 73 0 27 33 69 12 86 46 20 25 55 52 7 58 23 5 60 32 41 50 82", "52 91\n13 26 1 3 43 17 19 32 46 33 48 23 37 50\n25 78 26 1 40 2 67 42 4 56 30 70 84 32 20 85 59 8 86 34 73 23 10 88 24 11", "26 52\n8 0 14 16... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 28 | codeforces | |
4c06a1bab8e7d9a2924976ed686dc364 | Find Amir | A few years ago Sajjad left his school and register to another one due to security reasons. Now he wishes to find Amir, one of his schoolmates and good friends.
There are *n* schools numerated from 1 to *n*. One can travel between each pair of them, to do so, he needs to buy a ticket. The ticker between schools *i* an... | {"inputs": ["2", "10", "43670", "4217", "17879", "31809", "40873", "77859", "53022", "79227", "100000", "82801", "5188", "86539", "12802", "20289", "32866", "33377", "31775", "60397", "100000", "99999", "99998", "99997", "99996", "1", "2", "3", "4", "1", "3"], "outputs": ["0", "4", "21834", "2108", "8939", "15904", "20... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 170 | codeforces | |
4c5d9381944990813e0c5b4985ad0cc7 | Table Tennis | *n* people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins *k* games in a row. This player becomes the winner.
For each of t... | {"inputs": ["2 2\n1 2", "4 2\n3 1 2 4", "6 2\n6 5 3 1 2 4", "2 10000000000\n2 1", "4 4\n1 3 4 2", "2 2147483648\n2 1", "3 2\n1 3 2", "3 3\n1 2 3", "5 2\n2 1 3 4 5", "10 2\n7 10 5 8 9 3 4 6 1 2", "100 2\n62 70 29 14 12 87 94 78 39 92 84 91 61 49 60 33 69 37 19 82 42 8 45 97 81 43 54 67 1 22 77 58 65 17 18 28 25 57 16 90... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 206 | codeforces | |
4c5e4af36646b7431328b73207d396aa | Diagonal Walking | Mikhail walks on a 2D plane. He can go either up or right. You are given a sequence of Mikhail's moves. He thinks that this sequence is too long and he wants to make it as short as possible.
In the given sequence moving up is described by character U and moving right is described by character R. Mikhail can replace an... | {"inputs": ["5\nRUURU", "17\nUUURRRRRUUURURUUU", "100\nUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU", "100\nRRURRUUUURURRRURRRRURRRRRRURRUURRRUUURUURURRURUURUURRUURUURRURURUUUUURUUUUUURRUUURRRURRURRRUURRUUUUR", "100\nUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 249 | codeforces |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.