Search is not available for this dataset
problem_id stringlengths 32 32 | name stringlengths 2 112 | problem stringlengths 200 14k | test_cases stringlengths 33 79.2M | difficulty stringclasses 33
values | language listlengths 1 1 | source stringclasses 14
values | num_solutions int64 2 1.9M | starter_code stringlengths 0 1.47k | subset stringclasses 3
values |
|---|---|---|---|---|---|---|---|---|---|
f992f4c7e4d9227cecb52b2bd79864d2 | Grandfather Dovlet’s calculator | Once Max found an electronic calculator from his grandfather Dovlet's chest. He noticed that the numbers were written with seven-segment indicators ([https://en.wikipedia.org/wiki/Seven-segment_display](https://en.wikipedia.org/wiki/Seven-segment_display)).
Max starts to type all the values from *a* to *b*. After typi... | {"inputs": ["1 3", "10 15", "1 100", "100 10000", "213 221442", "1 1000000", "1000000 1000000", "222145 353252", "2 1000000", "1 999999", "192 200"], "outputs": ["12", "39", "928", "188446", "5645356", "28733372", "38", "3860750", "28733370", "28733334", "122"]} | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 111 | codeforces | |
f9a7d083273864ce5cfc8a3db52acfc5 | Strongly Connected City | Imagine a city with *n* horizontal streets crossing *m* vertical streets, forming an (*n*<=-<=1)<=×<=(*m*<=-<=1) grid. In order to increase the traffic flow, mayor of the city has decided to make each street one way. This means in each horizontal street, the traffic moves only from west to east or only from east to wes... | {"inputs": ["3 3\n><>\nv^v", "4 6\n<><>\nv^v^v^", "2 2\n<>\nv^", "2 2\n>>\n^v", "3 3\n>><\n^^v", "3 4\n>><\n^v^v", "3 8\n>><\nv^^^^^^^", "7 2\n<><<<<>\n^^", "4 5\n><<<\n^^^^v", "2 20\n><\n^v^^v^^v^^^v^vv^vv^^", "2 20\n<>\nv^vv^v^^vvv^^^v^vvv^", "20 2\n<><<><<>><<<>><><<<<\n^^", "20 2\n><>><>><>><<<><<><><\n^v", "11 12\... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 129 | codeforces | |
f9a85cbfe549efd66c2fb1f532902fe2 | Jamie and Binary Sequence (changed after round) | Jamie is preparing a Codeforces round. He has got an idea for a problem, but does not know how to solve it. Help him write a solution to the following problem:
Find *k* integers such that the sum of two to the power of each number equals to the number *n* and the largest integer in the answer is as small as possible. ... | {"inputs": ["23 5", "13 2", "1 2", "1 1", "1000000000000000000 100000", "7 2", "7 3", "7 4", "521325125150442808 10", "498518679725149504 1000", "464823731286228582 100000", "1 4", "9 4", "3 4", "144 4", "59 4", "78 4", "192 4", "107 4", "552 5", "680 5", "808 5", "1528 5", "1656 5", "26972 8", "23100 8", "19228 8", "2... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 8 | codeforces | |
f9c5a5763559e747e28b34dcacc8f6e9 | Difference Row | You want to arrange *n* integers *a*1,<=*a*2,<=...,<=*a**n* in some order in a row. Let's define the value of an arrangement as the sum of differences between all pairs of adjacent integers.
More formally, let's denote some arrangement as a sequence of integers *x*1,<=*x*2,<=...,<=*x**n*, where sequence *x* is a permu... | {"inputs": ["5\n100 -100 50 0 -50", "10\n764 -367 0 963 -939 -795 -26 -49 948 -282", "20\n262 -689 -593 161 -678 -555 -633 -697 369 258 673 50 833 737 -650 198 -651 -621 -396 939", "50\n-262 -377 -261 903 547 759 -800 -53 670 92 758 109 547 877 152 -901 -318 -527 -388 24 139 -227 413 -135 811 -886 -22 -526 -643 -431 28... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 144 | codeforces | |
f9e30533a717a56cf7677d43d0cff780 | Ball | *N* ladies attend the ball in the King's palace. Every lady can be described with three values: beauty, intellect and richness. King's Master of Ceremonies knows that ladies are very special creatures. If some lady understands that there is other lady at the ball which is more beautiful, smarter and more rich, she can ... | {"inputs": ["3\n1 4 2\n4 3 2\n2 5 3", "5\n2 8 10 0 7\n7 7 3 0 10\n2 8 3 2 2", "5\n3 0 0 2 0\n7 10 7 4 0\n9 1 6 1 9", "5\n5 4 0 2 5\n8 3 1 0 10\n4 5 0 0 5", "5\n9 7 0 2 10\n8 6 5 5 9\n1 9 3 0 1", "10\n7 7 10 1 2 1 7 1 5 9\n9 10 6 2 5 6 7 7 5 5\n2 7 4 0 7 10 5 6 2 2", "10\n7 7 0 1 2 6 0 10 3 5\n5 8 4 0 3 4 7 10 5 0\n0 10... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 2 | codeforces | |
f9eb516e2cbf8e42e3e834b5fb2eebba | The Child and Homework | Once upon a time a child got a test consisting of multiple-choice questions as homework. A multiple-choice question consists of four choices: A, B, C and D. Each choice has a description, and the child should find out the only one that is correct.
Fortunately the child knows how to solve such complicated test. The chi... | {"inputs": ["A.VFleaKing_is_the_author_of_this_problem\nB.Picks_is_the_author_of_this_problem\nC.Picking_is_the_author_of_this_problem\nD.Ftiasch_is_cute", "A.ab\nB.abcde\nC.ab\nD.abc", "A.c\nB.cc\nC.c\nD.c", "A.He_nan_de_yang_guang_zhao_yao_zhe_wo_men_mei_guo_ren_lian_shang_dou_xiao_kai_yan_wahaaaaaaaaaaaaaaaa\nB.Li_b... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 142 | codeforces | |
f9ee988bce99481ccbaa17ab2d8b86b1 | Mysterious numbers - 2 | The only line of input contains three integers *a*1,<=*a*2,<=*a*3 (1<=≤<=*a*1,<=*a*2,<=*a*3<=≤<=20), separated by spaces.
Output a single integer.
The only line of input contains three integers *a*1,<=*a*2,<=*a*3 (1<=≤<=*a*1,<=*a*2,<=*a*3<=≤<=20), separated by spaces.
Output a single integer.
Sample Input
2 3 2
13 14 ... | {"inputs": ["2 3 2", "13 14 1", "14 5 9", "17 18 3", "1 1 1", "4 6 7", "1 1 20", "20 20 1", "20 20 20", "12 9 18", "1 19 15", "5 5 5", "10 11 12", "3 7 17", "8 2 9"], "outputs": ["5", "14", "464", "53", "1", "110", "10946", "20", "218920", "42420", "11967", "40", "2474", "14140", "236"]} | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 17 | codeforces | |
f9fcb4af74ccacc29497705beb13400c | One-Way Reform | There are *n* cities and *m* two-way roads in Berland, each road connects two cities. It is known that there is no more than one road connecting each pair of cities, and there is no road which connects the city with itself. It is possible that there is no way to get from one city to some other city using only these roa... | {"inputs": ["2\n5 5\n2 1\n4 5\n2 3\n1 3\n3 5\n7 2\n3 7\n4 2", "4\n9 17\n3 6\n2 6\n6 9\n4 1\n2 8\n1 9\n7 9\n8 5\n1 7\n4 9\n6 7\n3 4\n9 3\n8 4\n2 1\n3 8\n2 7\n5 6\n2 5\n3 4\n1 3\n4 5\n5 3\n2 3\n12 8\n10 2\n9 2\n6 9\n10 6\n8 2\n4 10\n11 2\n4 11\n19 10\n6 2\n3 12\n17 7\n2 19\n17 4\n1 13\n7 1\n13 7\n6 8\n11 7", "1\n200 0", ... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 2 | codeforces | |
fa0b50fbf360b509f5fb8c307ce28ba4 | Strings of Power | Volodya likes listening to heavy metal and (occasionally) reading. No wonder Volodya is especially interested in texts concerning his favourite music style.
Volodya calls a string powerful if it starts with "heavy" and ends with "metal". Finding all powerful substrings (by substring Volodya means a subsequence of cons... | {"inputs": ["heavymetalisheavymetal", "heavymetalismetal", "trueheavymetalissotruewellitisalsosoheavythatyoucanalmostfeeltheweightofmetalonyou", "fpgzbvhheavymheheavyzmheavyavyebknkhheavyhsbqmmetheavyalmetalheavyyomtua", "metametaheavyetalalmetalavylkeoheavyhemetaleavycdk", "hg"], "outputs": ["3", "2", "3", "5", "3", "... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 9 | codeforces | |
fa95baebd3d1219835ac38b5de362bb9 | Roma and Changing Signs | Roma works in a company that sells TVs. Now he has to prepare a report for the last year.
Roma has got a list of the company's incomes. The list is a sequence that consists of *n* integers. The total income of the company is the sum of all integers in sequence. Roma decided to perform exactly *k* changes of signs of s... | {"inputs": ["3 2\n-1 -1 1", "3 1\n-1 -1 1", "17 27\n257 320 676 1136 2068 2505 2639 4225 4951 5786 7677 7697 7851 8337 8429 8469 9343", "69 28\n-9822 -9264 -9253 -9221 -9139 -9126 -9096 -8981 -8521 -8313 -8257 -8253 -7591 -7587 -7301 -7161 -7001 -6847 -6441 -6241 -5949 -5896 -5713 -5692 -5644 -5601 -5545 -5525 -5331 -5... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 79 | codeforces | |
fa9e6b7e16715652317cbfb661c3b1f5 | none | Stepan likes to repeat vowel letters when he writes words. For example, instead of the word "pobeda" he can write "pobeeeedaaaaa".
Sergey does not like such behavior, so he wants to write a program to format the words written by Stepan. This program must combine all consecutive equal vowels to a single vowel. The vowe... | {"inputs": ["13\npobeeeedaaaaa", "22\niiiimpleeemeentatiioon", "18\naeiouyaaeeiioouuyy", "24\naaaoooiiiuuuyyyeeeggghhh", "36\naeiouyaaeeiioouuyyaaaeeeiiiooouuuyyy", "100\noiyufyyyioueoudosizoryuoedatenougiuaeuouuyoiimaeigeeycewuooyovacoiyuaygfuuaiaeuahuieeafxsciylaebeufi", "200\nmmffggzvuuzzlkafduueqocuybiiaaeeoiioouaa... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 48 | codeforces | |
faad69b01b68c5b762c9f2b9f2e0453f | Anti-Palindromize | A string *a* of length *m* is called antipalindromic iff *m* is even, and for each *i* (1<=≤<=*i*<=≤<=*m*) *a**i*<=≠<=*a**m*<=-<=*i*<=+<=1.
Ivan has a string *s* consisting of *n* lowercase Latin letters; *n* is even. He wants to form some string *t* that will be an antipalindromic permutation of *s*. Also Ivan has de... | {"inputs": ["8\nabacabac\n1 1 1 1 1 1 1 1", "8\nabaccaba\n1 2 3 4 5 6 7 8", "8\nabacabca\n1 2 3 4 4 3 2 1", "100\nbaaacbccbccaccaccaaabcabcabccacaabcbccbccabbabcbcbbaacacbacacacaacccbcbbbbacccababcbacacbacababcacbc\n28 28 36 36 9 53 7 54 66 73 63 30 55 53 54 74 60 2 34 36 72 56 13 63 99 4 44 54 29 75 9 68 80 49 74 94 4... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 2 | codeforces | |
fab2904a98f86333c60dab6a407ca40b | Coloring a Tree | You are given a rooted tree with *n* vertices. The vertices are numbered from 1 to *n*, the root is the vertex number 1.
Each vertex has a color, let's denote the color of vertex *v* by *c**v*. Initially *c**v*<==<=0.
You have to color the tree into the given colors using the smallest possible number of steps. On eac... | {"inputs": ["6\n1 2 2 1 5\n2 1 1 1 1 1", "7\n1 1 2 3 1 4\n3 3 1 1 1 2 3", "2\n1\n2 2", "3\n1 1\n2 2 2", "4\n1 2 1\n1 2 3 4", "4\n1 2 3\n4 1 2 4", "5\n1 2 1 4\n1 1 1 2 2", "3\n1 2\n2 1 1", "4\n1 1 1\n3 1 3 1", "4\n1 1 2\n4 1 4 1", "4\n1 2 2\n3 1 2 3", "3\n1 1\n1 2 2"], "outputs": ["3", "5", "1", "1", "4", "4", "2", "2",... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 136 | codeforces | |
fb0053531c0e388ce49fc51a56856d5c | Coprime Arrays | Let's call an array *a* of size *n* coprime iff *gcd*(*a*1,<=*a*2,<=...,<=*a**n*)<==<=1, where *gcd* is the greatest common divisor of the arguments.
You are given two numbers *n* and *k*. For each *i* (1<=≤<=*i*<=≤<=*k*) you have to determine the number of coprime arrays *a* of size *n* such that for every *j* (1<=≤<... | {"inputs": ["3 4", "2000000 8", "1000 1000", "400000 400000", "1000 2000", "400000 800000", "1000 3000", "400000 1200000", "1000 4000", "400000 1600000", "1000 5000", "400000 2000000", "2000 1000", "800000 400000", "2000 2000", "800000 800000", "2000 3000", "800000 1200000", "2000 4000", "800000 1600000", "2000 5000", ... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 3 | codeforces | |
fb0ee76ebf2e3c8996349f51635551f9 | Heads or Tails | Petya and Vasya are tossing a coin. Their friend Valera is appointed as a judge. The game is very simple. First Vasya tosses a coin *x* times, then Petya tosses a coin *y* times. If the tossing player gets head, he scores one point. If he gets tail, nobody gets any points. The winner is the player with most points by t... | {"inputs": ["3 2 1 1", "2 4 2 2", "1 1 1 1", "4 5 2 3", "10 6 3 4", "10 10 1 1", "9 7 4 7", "5 5 3 2", "10 10 1 1", "20 10 1 8", "10 20 4 6", "50 50 1 30", "60 50 30 40", "100 100 1 1", "100 99 10 13", "99 100 20 7", "100 90 100 83", "80 100 1 50", "100 39 70 5", "70 80 30 80", "100 100 1 1", "100 100 100 5", "99 99 1 ... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 67 | codeforces | |
fb100470ea9dd5ea633506679773b01e | Poster | The R1 company has recently bought a high rise building in the centre of Moscow for its main office. It's time to decorate the new office, and the first thing to do is to write the company's slogan above the main entrance to the building.
The slogan of the company consists of *n* characters, so the decorators hung a l... | {"inputs": ["2 2\nR1", "2 1\nR1", "6 4\nGO?GO!", "7 3\nME,YOU.", "10 1\nEK5JQMS5QN", "85 84\n73IW80UODC8B,UR7S8WMNATV0JSRF4W0B2VV8LCAX6SGCYY8?LHDKJEO29WXQWT9.WY1VY7408S1W04GNDZPK", "59 53\n7NWD!9PC11C8S4TQABBTJO,?CO6YGOM!W0QR94CZJBD9U1YJY23YB354,8F", "100 79\nF2.58O.L4A!QX!,.,YQUE.RZW.ENQCZKUFNG?.J6FT?L59BIHKFB?,44MAHS... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 110 | codeforces | |
fb31e30d59f65c09b714f42e0893a6fa | Birds | Apart from plush toys, Imp is a huge fan of little yellow birds!
To summon birds, Imp needs strong magic. There are *n* trees in a row on an alley in a park, there is a nest on each of the trees. In the *i*-th nest there are *c**i* birds; to summon one bird from this nest Imp needs to stay under this tree and it costs... | {"inputs": ["2 12 0 4\n3 4\n4 2", "4 1000 10 35\n1 2 4 5\n1000 500 250 200", "2 10 7 11\n2 10\n6 1", "5 1 4 6\n3 4 6 5 1\n3 0 10 2 9", "75 262 870 596\n22 13 37 6 15 25 5 1 2 13 6 3 14 7 8 15 6 15 10 3 1 21 33 2 7 14 17 7 4 9 16 29 31 4 31 16 3 11 13 38 3 14 8 18 9 3 1 10 1 5 10 16 7 5 33 9 24 9 8 13 3 31 8 18 33 17 22... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 1 | codeforces | |
fb358ff1430bb7b1c364bc7027e80b87 | Leaving the Bar | For a vector $\vec{v} = (x, y)$, define $|v| = \sqrt{x^2 + y^2}$.
Allen had a bit too much to drink at the bar, which is at the origin. There are $n$ vectors $\vec{v_1}, \vec{v_2}, \cdots, \vec{v_n}$. Allen will make $n$ moves. As Allen's sense of direction is impaired, during the $i$-th move he will either move in th... | {"inputs": ["3\n999999 0\n0 999999\n999999 0", "1\n-824590 246031", "8\n-67761 603277\n640586 -396671\n46147 -122580\n569609 -2112\n400 914208\n131792 309779\n-850150 -486293\n5272 721899", "6\n1000000 0\n1000000 0\n-1000000 0\n0 1000000\n0 -1000000\n0 -1000000", "8\n-411248 143802\n300365 629658\n363219 343742\n396148... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 3 | codeforces | |
fb35ad5ba58debd68f0aba5949e0c149 | Little Artem and Presents | Little Artem got *n* stones on his birthday and now wants to give some of them to Masha. He knows that Masha cares more about the fact of receiving the present, rather than the value of that present, so he wants to give her stones as many times as possible. However, Masha remembers the last present she received, so Art... | {"inputs": ["1", "2", "3", "4", "100", "101", "102", "1000000000", "5", "6", "999999999", "999999998", "999999997", "999999996", "999999995", "999999994", "999999993", "999999992", "999999991", "1000", "10000", "100000", "1000000", "10000000", "100000000", "7"], "outputs": ["1", "1", "2", "3", "67", "67", "68", "666666... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 365 | codeforces | |
fb4f19ca832f912bcbe6c0aec5b2d3cd | Chat Online | Little X and Little Z are good friends. They always chat online. But both of them have schedules.
Little Z has fixed schedule. He always online at any moment of time between *a*1 and *b*1, between *a*2 and *b*2, ..., between *a**p* and *b**p* (all borders inclusive). But the schedule of Little X is quite strange, it d... | {"inputs": ["1 1 0 4\n2 3\n0 1", "2 3 0 20\n15 17\n23 26\n1 4\n7 11\n15 17", "5 2 27 452\n148 154\n421 427\n462 470\n777 786\n969 978\n245 247\n313 322", "3 6 25 785\n273 275\n391 397\n775 783\n84 89\n348 354\n480 483\n552 556\n711 716\n838 844", "1 6 364 421\n649 688\n31 39\n438 441\n516 524\n609 615\n708 710\n850 851... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 8 | codeforces | |
fb638f1ba3ca020d1c377de702d1dada | Substrings Sort | You are given $n$ strings. Each string consists of lowercase English letters. Rearrange (reorder) the given strings in such a way that for every string, all strings that are placed before it are its substrings.
String $a$ is a substring of string $b$ if it is possible to choose several consecutive letters in $b$ in su... | {"inputs": ["5\na\naba\nabacaba\nba\naba", "5\na\nabacaba\nba\naba\nabab", "3\nqwerty\nqwerty\nqwerty", "1\nwronganswer", "3\na\nb\nab", "2\nababaab\nabaab", "2\nq\nqq", "5\nabab\nbab\nba\nab\na", "3\nb\nc\nd", "3\naba\nbab\nababa", "4\na\nba\nabacabac\nb", "4\nab\nba\nabab\na", "3\naaa\naab\naaab", "2\nac\nabac", "2\n... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 169 | codeforces | |
fb72cf1ab655d21cc8e2271adda07ca1 | Guess the Permutation | Bob has a permutation of integers from 1 to *n*. Denote this permutation as *p*. The *i*-th element of *p* will be denoted as *p**i*. For all pairs of distinct integers *i*,<=*j* between 1 and *n*, he wrote the number *a**i*,<=*j*<==<=*min*(*p**i*,<=*p**j*). He writes *a**i*,<=*i*<==<=0 for all integer *i* from 1 to *n... | {"inputs": ["2\n0 1\n1 0", "5\n0 2 2 1 2\n2 0 4 1 3\n2 4 0 1 3\n1 1 1 0 1\n2 3 3 1 0", "10\n0 1 5 2 5 3 4 5 5 5\n1 0 1 1 1 1 1 1 1 1\n5 1 0 2 6 3 4 6 6 6\n2 1 2 0 2 2 2 2 2 2\n5 1 6 2 0 3 4 8 8 7\n3 1 3 2 3 0 3 3 3 3\n4 1 4 2 4 3 0 4 4 4\n5 1 6 2 8 3 4 0 9 7\n5 1 6 2 8 3 4 9 0 7\n5 1 6 2 7 3 4 7 7 0", "4\n0 1 3 2\n1 0 ... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 123 | codeforces | |
fb74f0c531da115dd79246f7353102f6 | Ace It! | The only line of the input is a string of 7 characters. The first character is letter A, followed by 6 digits. The input is guaranteed to be valid (for certain definition of "valid").
Output a single integer.
The only line of the input is a string of 7 characters. The first character is letter A, followed by 6 digits.... | {"inputs": ["A221033", "A223635", "A232726", "A102210", "A231010", "A222222", "A555555", "A102222", "A234567", "A987654", "A101010", "A246810", "A210210", "A458922", "A999999", "A888888", "A232232", "A222210", "A710210", "A342987", "A987623", "A109109", "A910109", "A292992", "A388338", "A764598", "A332567", "A108888", ... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 43 | codeforces | |
fb9cfeffe8719c2c83cb84f4009cb5d2 | Little Elephant and Broken Sorting | The Little Elephant loves permutations of integers from 1 to *n* very much. But most of all he loves sorting them. To sort a permutation, the Little Elephant repeatedly swaps some elements. As a result, he must receive a permutation 1,<=2,<=3,<=...,<=*n*.
This time the Little Elephant has permutation *p*1,<=*p*2,<=...... | {"inputs": ["2 1\n1 2\n1 2", "4 3\n1 3 2 4\n1 2\n2 3\n1 4", "7 4\n7 6 4 2 1 5 3\n1 3\n2 1\n7 2\n3 5", "10 1\n1 2 3 4 5 6 7 8 9 10\n1 10", "9 20\n9 8 7 6 5 4 3 2 1\n4 6\n9 4\n5 9\n6 8\n1 9\n5 8\n6 9\n7 3\n1 9\n8 3\n4 5\n9 6\n3 8\n4 1\n1 2\n3 2\n4 9\n6 7\n7 5\n9 6", "20 7\n3 17 7 14 11 4 1 18 20 19 13 12 5 6 15 16 9 2 8 ... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 1 | codeforces | |
fbd08e2f563c304ba65fe1928a5c64af | none | You are given set of *n* points in 5-dimensional space. The points are labeled from 1 to *n*. No two points coincide.
We will call point *a* bad if there are different points *b* and *c*, not equal to *a*, from the given set such that angle between vectors and is acute (i.e. strictly less than ). Otherwise, the poin... | {"inputs": ["6\n0 0 0 0 0\n1 0 0 0 0\n0 1 0 0 0\n0 0 1 0 0\n0 0 0 1 0\n0 0 0 0 1", "3\n0 0 1 2 0\n0 0 9 2 0\n0 0 5 9 0", "1\n0 0 0 0 0", "2\n0 1 2 3 4\n5 6 7 8 9", "10\n0 -110 68 -51 -155\n-85 -110 68 -51 -155\n85 -70 51 68 -230\n0 -40 51 68 75\n0 5 -51 -68 -190\n85 0 0 0 0\n85 -115 -68 51 35\n85 -75 -187 34 -40\n-85 -... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 24 | codeforces | |
fbd8081c2cfde92f282508744d168fcb | Bulls and Cows | The "Bulls and Cows" game needs two people to play. The thinker thinks of a number and the guesser tries to guess it.
The thinker thinks of a four-digit number in the decimal system. All the digits in the number are different and the number may have a leading zero. It can't have more than one leading zero, because all... | {"inputs": ["2\n1263 1 2\n8103 2 1", "2\n1234 2 2\n1256 0 2", "2\n0123 1 1\n4567 1 2", "1\n1234 0 0", "4\n4789 1 0\n7189 1 0\n7829 1 0\n7893 1 0", "4\n1789 1 0\n7198 1 0\n9817 1 0\n8971 1 0", "6\n1234 3 0\n1235 3 0\n1236 3 0\n1237 3 0\n1238 3 0\n1239 3 0", "3\n0123 0 4\n1230 0 4\n3012 0 4", "1\n0714 1 1", "2\n0159 1 0\... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 14 | codeforces | |
fbe7c79a79bced6e28d91c1e7989b060 | Fortune Telling | Marina loves Sasha. But she keeps wondering whether Sasha loves her. Of course, the best way to know it is fortune telling. There are many ways of telling fortune, but Marina has picked the easiest one. She takes in her hand one or several camomiles and tears off the petals one by one. After each petal she pronounces a... | {"inputs": ["1\n1", "1\n2", "3\n5 6 7", "2\n5 7", "3\n1 2 3", "4\n4 3 1 2", "10\n90 72 76 60 22 87 5 67 17 65", "10\n18 42 20 68 88 10 87 37 55 51", "100\n25 43 35 79 53 13 91 91 45 65 83 57 9 41 39 85 45 71 51 61 59 31 13 63 39 25 21 79 39 91 67 21 61 97 75 93 83 29 79 59 97 11 37 63 51 39 55 91 23 21 17 47 23 35 75 4... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 58 | codeforces | |
fc15856b0b1fce8b88f14daf45f5346a | Painting Fence | Bizon the Champion isn't just attentive, he also is very hardworking.
Bizon the Champion decided to paint his old fence his favorite color, orange. The fence is represented as *n* vertical planks, put in a row. Adjacent planks have no gap between them. The planks are numbered from the left to the right starting from o... | {"inputs": ["5\n2 2 1 2 1", "2\n2 2", "1\n5", "5\n2 2 1 2 2", "5\n2 2 1 5 1", "1\n1", "1\n1000000000", "2\n999635584 999595693", "10\n3 3 6 4 2 3 2 2 3 3", "14\n1 1 3 1 1 4 4 4 4 4 4 4 4 4", "6\n100 100 100 100 100 1", "7\n5 5 1 5 5 4 1", "4\n3 4 5 6", "4\n2 3 4 5", "8\n5000 5000 5 5000 5000 5000 5000 5000", "10\n4 4 4... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 5 | codeforces | |
fc1b001cfed3da5734fdd1993f262d18 | Demiurges Play Again | Demiurges Shambambukli and Mazukta love to watch the games of ordinary people. Today, they noticed two men who play the following game.
There is a rooted tree on *n* nodes, *m* of which are leaves (a leaf is a nodes that does not have any children), edges of the tree are directed from parent to children. In the leaves... | {"inputs": ["5\n1 2\n1 3\n2 4\n2 5", "6\n1 2\n1 3\n3 4\n1 5\n5 6", "1", "2\n1 2", "3\n1 2\n1 3", "10\n1 2\n1 3\n3 4\n3 5\n4 6\n1 7\n3 8\n2 9\n6 10", "50\n1 2\n2 3\n3 4\n4 5\n5 6\n6 7\n7 8\n8 9\n9 10\n10 11\n11 12\n12 13\n13 14\n14 15\n15 16\n16 17\n17 18\n18 19\n19 20\n20 21\n21 22\n22 23\n23 24\n24 25\n25 26\n26 27\n2... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 1 | codeforces | |
fc3f5cc330553f4dda9bd40e698161f3 | Quantity of Strings | Just in case somebody missed it: this winter is totally cold in Nvodsk! It is so cold that one gets funny thoughts. For example, let's say there are strings with the length exactly *n*, based on the alphabet of size *m*. Any its substring with length equal to *k* is a palindrome. How many such strings exist? Your task ... | {"inputs": ["1 1 1", "5 2 4", "7 4 20", "8 13 9", "10 23 9", "10 25 8", "997 1752 1000", "784 1 1999", "341 9 342", "777 1 777", "542 13 542", "1501 893 1501", "1321 95 2", "2000 1000 3", "1769 849 1000", "1000 2 1", "345 1777 1", "1999 2000 2000", "1984 1847 1992", "2000 2000 2000", "1451 239 1451", "2000 2000 1", "12... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 15 | codeforces | |
fc5b374c0c467d1243d8dce71f849633 | Remove Duplicates | Petya has an array $a$ consisting of $n$ integers. He wants to remove duplicate (equal) elements.
Petya wants to leave only the rightmost entry (occurrence) for each element of the array. The relative order of the remaining unique elements should not be changed.
The first line contains a single integer $n$ ($1 \le n \... | {"inputs": ["6\n1 5 5 1 6 1", "5\n2 4 2 4 4", "5\n6 6 6 6 6", "7\n1 2 3 4 2 2 3", "9\n100 100 100 99 99 99 100 100 100", "27\n489 489 487 488 750 230 43 645 42 42 489 42 973 42 973 750 645 355 868 112 868 489 750 489 887 489 868", "40\n151 421 421 909 117 222 909 954 227 421 227 954 954 222 421 227 421 421 421 151 421 ... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 191 | codeforces | |
fc7661143e4b4a08461bb4de57185e76 | Connecting Universities | Treeland is a country in which there are *n* towns connected by *n*<=-<=1 two-way road such that it's possible to get from any town to any other town.
In Treeland there are 2*k* universities which are located in different towns.
Recently, the president signed the decree to connect universities by high-speed network... | {"inputs": ["7 2\n1 5 6 2\n1 3\n3 2\n4 5\n3 7\n4 3\n4 6", "9 3\n3 2 1 6 5 9\n8 9\n3 2\n2 7\n3 4\n7 6\n4 5\n2 1\n2 8", "41 3\n11 10 15 35 34 6\n28 2\n25 3\n9 4\n11 5\n7 6\n24 7\n19 8\n1 9\n34 10\n23 11\n17 12\n32 13\n32 14\n32 15\n33 16\n8 17\n19 18\n40 19\n15 20\n6 21\n41 22\n35 23\n13 24\n6 25\n22 26\n4 27\n31 28\n34 ... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 7 | codeforces | |
fc7f2f0fe3c4df9f28490f80781ce3fe | The Tag Game | Alice got tired of playing the tag game by the usual rules so she offered Bob a little modification to it. Now the game should be played on an undirected rooted tree of *n* vertices. Vertex 1 is the root of the tree.
Alice starts at vertex 1 and Bob starts at vertex *x* (*x*<=≠<=1). The moves are made in turns, Bob go... | {"inputs": ["4 3\n1 2\n2 3\n2 4", "5 2\n1 2\n2 3\n3 4\n2 5", "2 2\n2 1", "3 3\n2 1\n3 1", "3 3\n1 2\n3 2", "10 4\n5 4\n8 3\n4 6\n5 3\n7 9\n1 3\n5 10\n2 9\n9 8", "10 7\n8 7\n2 8\n2 3\n10 6\n4 6\n4 1\n10 5\n7 5\n9 8", "8 3\n2 1\n3 1\n4 3\n5 1\n6 1\n7 1\n8 6", "34 33\n2 1\n3 2\n4 3\n5 2\n6 3\n7 2\n8 5\n9 7\n10 8\n11 7\n12... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 13 | codeforces | |
fc8112700bb19b73b5f2cb0b6e677aac | Robot Arm | Roger is a robot. He has an arm that is a series of *n* segments connected to each other. The endpoints of the *i*-th segment are initially located at points (*i*<=-<=1,<=0) and (*i*,<=0). The endpoint at (*i*<=-<=1,<=0) is colored red and the endpoint at (*i*,<=0) is colored blue for all segments. Thus, the blue endpo... | {"inputs": ["5 4\n1 1 3\n2 3 90\n2 5 48\n1 4 1", "1 1\n2 1 302", "50 50\n1 41 261\n2 47 324\n1 41 256\n1 31 339\n2 23 116\n2 44 184\n2 32 115\n1 40 301\n2 40 303\n1 29 309\n2 49 348\n2 47 356\n1 41 263\n2 42 276\n1 45 135\n1 33 226\n2 31 166\n1 50 171\n2 47 166\n2 50 284\n2 25 324\n2 48 307\n2 41 176\n1 50 353\n1 45 32... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 1 | codeforces | |
fc94946d03aa4b544ec22213ebaed643 | Jury Size | In 2013, the writers of Berland State University should prepare problems for *n* Olympiads. We will assume that the Olympiads are numbered with consecutive integers from 1 to *n*. For each Olympiad we know how many members of the jury must be involved in its preparation, as well as the time required to prepare the prob... | {"inputs": ["2\n5 23 1 2\n3 13 2 3", "3\n12 9 2 1\n12 8 1 3\n12 8 2 2", "1\n1 10 1 13", "3\n3 16 25 1\n3 15 9 34\n3 14 90 87", "4\n2 15 52 53\n2 15 35 81\n2 15 39 96\n2 14 87 7", "5\n3 6 40 89\n3 4 24 64\n2 28 83 1\n3 3 15 32\n3 8 54 28", "10\n8 8 4 18\n8 10 100 36\n8 9 17 51\n8 10 90 8\n8 10 64 45\n8 10 90 81\n8 11 20... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 9 | codeforces | |
fcc1dd7c8d355e18d211514350671eac | Curriculum Vitae | Hideo Kojima has just quit his job at Konami. Now he is going to find a new place to work. Despite being such a well-known person, he still needs a CV to apply for a job.
During all his career Hideo has produced *n* games. Some of them were successful, some were not. Hideo wants to remove several of them (possibly zer... | {"inputs": ["4\n1 1 0 1", "6\n0 1 0 0 1 0", "1\n0", "100\n0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0", "100\n0 0 1 1 1 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 ... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 88 | codeforces | |
fccff7b6eaf8ac7a2e50f9817666b74d | Flowers | We saw the little game Marmot made for Mole's lunch. Now it's Marmot's dinner time and, as we all know, Marmot eats flowers. At every dinner he eats some red and white flowers. Therefore a dinner can be represented as a sequence of several flowers, some of them white and some of them red.
But, for a dinner to be tasty... | {"inputs": ["3 2\n1 3\n2 3\n4 4", "1 1\n1 3", "1 2\n64329 79425"], "outputs": ["6\n5\n5", "14", "0"]} | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 28 | codeforces | |
fcd19da2696717da4756587afbd33c82 | Epic Game | Simon and Antisimon play a game. Initially each player receives one fixed positive integer that doesn't change throughout the game. Simon receives number *a* and Antisimon receives number *b*. They also have a heap of *n* stones. The players take turns to make a move and Simon starts. During a move a player should take... | {"inputs": ["3 5 9", "1 1 100", "23 12 16", "95 26 29", "73 32 99", "1 1 1", "41 12 65", "13 61 100", "100 100 10", "12 24 26", "73 21 96", "17 22 81", "14 88 97", "42 81 17", "34 36 19", "21 87 12", "97 92 98", "49 25 62", "29 17 44", "10 1 10", "99 98 100", "100 100 1", "11 99 55", "8 13 21", "34 55 89", "21 34 55", ... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 780 | codeforces | |
fcf8b343a907be0b2bab4149edfec28a | Valhalla Siege | Ivar the Boneless is a great leader. He is trying to capture Kattegat from Lagertha. The war has begun and wave after wave Ivar's warriors are falling in battle.
Ivar has $n$ warriors, he places them on a straight line in front of the main gate, in a way that the $i$-th warrior stands right after $(i-1)$-th warrior. T... | {"inputs": ["5 5\n1 2 1 2 1\n3 10 1 1 1", "4 4\n1 2 3 4\n9 1 10 6", "10 3\n1 1 1 1 1 1 1 1 1 1\n10 10 5", "1 1\n56563128\n897699770", "100 55\n1 2 4 4 3 5 5 2 3 4 2 1 1 2 3 5 1 5 4 2 5 4 4 3 3 5 3 4 4 5 5 2 3 3 4 4 3 4 5 5 5 5 3 5 1 2 4 3 4 5 3 3 2 1 4 5 3 4 4 1 5 1 5 2 2 1 4 5 3 3 1 4 2 5 4 5 3 2 5 5 2 3 2 3 2 2 3 4 4... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 129 | codeforces | |
fd02ef2593cc46942a3abcb5c85a76c8 | Case of Matryoshkas | Andrewid the Android is a galaxy-famous detective. He is now investigating the case of vandalism at the exhibition of contemporary art.
The main exhibit is a construction of *n* matryoshka dolls that can be nested one into another. The matryoshka dolls are numbered from 1 to *n*. A matryoshka with a smaller number can... | {"inputs": ["3 2\n2 1 2\n1 3", "7 3\n3 1 3 7\n2 2 5\n2 4 6", "1 1\n1 1", "3 2\n1 2\n2 1 3", "5 3\n1 4\n3 1 2 3\n1 5", "8 5\n2 1 2\n2 3 4\n1 5\n2 6 7\n1 8", "10 10\n1 5\n1 4\n1 10\n1 3\n1 7\n1 1\n1 8\n1 6\n1 9\n1 2", "20 6\n3 8 9 13\n3 4 14 20\n2 15 17\n3 2 5 11\n5 7 10 12 18 19\n4 1 3 6 16", "50 10\n6 17 21 31 42 45 49... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 36 | codeforces | |
fd0688f764c0b19252d911aef21b9a3b | AND-permutations | Given an integer *N*, find two permutations:
1. Permutation *p* of numbers from 1 to *N* such that *p**i*<=≠<=*i* and *p**i*<=&<=*i*<==<=0 for all *i*<==<=1,<=2,<=...,<=*N*. 1. Permutation *q* of numbers from 1 to *N* such that *q**i*<=≠<=*i* and *q**i*<=&<=*i*<=≠<=0 for all *i*<==<=1,<=2,<=...,<=*N*.
&... | {"inputs": ["3", "6", "100000", "15", "16", "17", "1", "2", "4", "5", "7", "8", "9", "10", "31", "32", "33", "63", "64", "65", "127", "128", "129", "255", "256", "257", "511", "512", "513", "1023", "1024", "1025", "2047", "2048", "2049", "4095", "4096", "4097", "8191", "8192", "8193", "16383", "16384", "16385", "32767"... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 1 | codeforces | |
fd06e19867352ee76d0b1a3b9ab11217 | Ann and Books | In Ann's favorite book shop are as many as *n* books on math and economics. Books are numbered from 1 to *n*. Each of them contains non-negative number of problems.
Today there is a sale: any subsegment of a segment from *l* to *r* can be bought at a fixed price.
Ann decided that she wants to buy such non-empty subs... | {"inputs": ["4 1\n1 1 1 2\n1 1 1 1\n4\n1 2\n1 3\n1 4\n3 4", "4 0\n1 2 1 2\n0 0 0 0\n1\n1 4", "10 10\n2 1 1 1 1 1 1 1 1 2\n0 10 10 0 0 10 10 10 10 0\n10\n4 10\n3 7\n9 9\n2 9\n10 10\n5 5\n2 2\n6 8\n3 4\n1 3", "10 -10\n1 2 1 2 1 1 2 2 2 1\n7 7 10 3 7 10 6 8 0 1\n10\n2 6\n10 10\n6 9\n5 8\n7 10\n2 7\n2 9\n2 7\n5 6\n2 8", "1... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 2 | codeforces | |
fd09090ef729ff93446db38cf1352d0b | Autocomplete | Autocomplete is a program function that enables inputting the text (in editors, command line shells, browsers etc.) completing the text by its inputted part. Vasya is busy working on a new browser called 'BERowser'. He happens to be working on the autocomplete function in the address line at this very moment. A list co... | {"inputs": ["next\n2\nnextpermutation\nnextelement", "find\n4\nfind\nfindfirstof\nfindit\nfand", "find\n4\nfondfind\nfondfirstof\nfondit\nfand", "kudljmxcse\n4\nkudljmxcse\nszjebdoad\nchz\na", "ntqwpa\n5\nvvepyowvn\nntqwpakay\nhh\nygiafasda\nntqwpadm", "aflb\n6\nsaej\nujxsiijg\npp\nhgoprw\ncp\nnt", "dzwzyj\n7\nwvixktp\... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 135 | codeforces | |
fd0a5d9f400dd636829e4e517f91376f | Friends and Presents | You have two friends. You want to present each of them several positive integers. You want to present *cnt*1 numbers to the first friend and *cnt*2 numbers to the second friend. Moreover, you want all presented numbers to be distinct, that also means that no number should be presented to both friends.
In addition, the... | {"inputs": ["3 1 2 3", "1 3 2 3", "916200 69682 2 3", "808351 17767 433 509", "8851 901 20897 26183", "5099 2895 16273 29473", "5099 2895 16273 29473", "4969 694 293 2347", "683651932 161878530 2 5", "325832598 637961741 2 3", "999999999 1 2 3", "11006 976 6287 9007", "150064728 173287472 439 503", "819712074 101394406... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 33 | codeforces | |
fd147d05260e80bd25ba2a334bf9f277 | Comparing Two Long Integers | You are given two very long integers *a*,<=*b* (leading zeroes are allowed). You should check what number *a* or *b* is greater or determine that they are equal.
The input size is very large so don't use the reading of symbols one by one. Instead of that use the reading of a whole line or token.
As input/output can r... | {"inputs": ["9\n10", "11\n10", "00012345\n12345", "0123\n9", "0123\n111", "9\n9", "0\n0000", "1213121\n1213121", "8631749422082281871941140403034638286979613893271246118706788645620907151504874585597378422393911017\n1460175633701201615285047975806206470993708143873675499262156511814213451040881275819636625899967479", "... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 93 | codeforces | |
fd1ce315ca7b872f90047714c866c036 | Inventory | Companies always have a lot of equipment, furniture and other things. All of them should be tracked. To do this, there is an inventory number assigned with each item. It is much easier to create a database by using those numbers and keep the track of everything.
During an audit, you were surprised to find out that the... | {"inputs": ["3\n1 3 2", "4\n2 2 3 3", "1\n2", "3\n3 3 1", "5\n1 1 1 1 1", "5\n5 3 4 4 2", "5\n19 11 8 8 10", "15\n2 2 1 2 1 2 3 3 1 3 2 1 2 3 2", "18\n3 11 5 9 5 4 6 4 5 7 5 1 8 11 11 2 1 9", "42\n999 863 440 1036 1186 908 330 265 382 417 858 286 834 922 42 569 79 158 312 1175 1069 188 21 1207 985 375 59 417 256 595 73... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 88 | codeforces | |
fd83dbf0a860282e31913add3b44f5c3 | Permutations | A permutation is a sequence of integers from 1 to *n* of length *n* containing each number exactly once. For example, (1), (4,<=3,<=5,<=1,<=2), (3,<=2,<=1) are permutations, and (1,<=1), (4,<=3,<=1), (2,<=3,<=4) are not.
There are many tasks on permutations. Today you are going to solve one of them. Let’s imagine tha... | {"inputs": ["9\n1 2 3 1 2 1 4 2 5", "4\n4 3 2 1", "4\n1 2 2 3", "1\n1", "1\n2", "5\n1 1 1 1 1", "3\n2 1 1", "6\n3 3 2 2 1 1", "2\n1000 1", "5\n2 2 1 1 3", "10\n2 1 2 4 6 1 5 3 7 1", "10\n4 1 2 1 3 3 1 2 2 1", "10\n1 2 5 1 1 1 4 1 3 2", "20\n2 7 3 8 4 6 3 7 6 4 13 5 1 12 1 10 2 11 5 9", "20\n1 1 1 2 3 1 5 9 5 8 4 6 7 3 ... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 19 | codeforces | |
fd8886c6850c1ea1e514d52a6f360e82 | Autocompletion | Arcady is a copywriter. His today's task is to type up an already well-designed story using his favorite text editor.
Arcady types words, punctuation signs and spaces one after another. Each letter and each sign (including line feed) requires one keyboard click in order to be printed. Moreover, when Arcady has a non-e... | {"inputs": ["snow affects sports such as skiing, snowboarding, and snowmachine travel.\nsnowboarding is a recreational activity and olympic and paralympic sport.", "'co-co-co, codeforces?!'", "thun-thun-thunder, thunder, thunder\nthunder, thun-, thunder\nthun-thun-thunder, thunder\nthunder, feel the thunder\nlightning ... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 1 | codeforces | |
fd92b19e89743bc74823f16a399a7d87 | none | Hamed has recently found a string *t* and suddenly became quite fond of it. He spent several days trying to find all occurrences of *t* in other strings he had. Finally he became tired and started thinking about the following problem. Given a string *s* how many ways are there to extract *k*<=≥<=1 non-overlapping subst... | {"inputs": ["ababa\naba", "welcometoroundtwohundredandeightytwo\nd", "ddd\nd", "vnssnssnssnssnssnssnssnssnssnssnssnssnssnssnssnssn\nnssnssns", "kpjmawawawawawawawawawawawawawawawawawawawawawawaw\nwawawawa", "vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv\nvvvvvvvv", "a\na", "a\naa", "a\nb", "ababababab\nabab"], "ou... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 3 | codeforces | |
fdcea445eb25dcf698ddd83d96b0a8bf | Sysadmin Bob | Email address in Berland is a string of the form *A*@*B*, where *A* and *B* are arbitrary strings consisting of small Latin letters.
Bob is a system administrator in «Bersoft» company. He keeps a list of email addresses of the company's staff. This list is as a large string, where all addresses are written in arbitra... | {"inputs": ["a@aa@a", "a@a@a", "@aa@a", "aba@caba@daba", "asd@qwasd@qwasd@qwasd@qwasd@qw", "qwer@ty", "@", "g", "@@", "@@@", "r@@", "@@r", "@r@", "w@", "@e", "jj", "@gh", "n@m", "kl@", "fpm", "@@@@", "q@@@", "@d@@", "@@v@", "@@@c", "@@zx", "@x@a", "@pq@", "w@@e", "e@s@", "ec@@", "@hjk", "e@vb", "tg@q", "jkl@", "werb", ... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 22 | codeforces | |
fdd530dfaa50125be7d4251073dd47dd | Hiring Staff | A new Berland businessman Vitaly is going to open a household appliances' store. All he's got to do now is to hire the staff.
The store will work seven days a week, but not around the clock. Every day at least *k* people must work in the store.
Berland has a law that determines the order of working days and non-worki... | {"inputs": ["4 3 2", "3 3 1", "5 5 3", "7 6 8", "8 3 2", "5 1 1", "6 5 1", "2 1 1", "2 2 1", "3 1 1", "3 2 1", "3 3 1", "4 1 1", "4 2 1", "4 3 1", "4 4 1", "183 1 1", "284 282 1", "359 358 1", "801 801 1", "1000 1 1", "1000 999 1", "1000 1000 1", "2 1 2", "2 2 2", "3 1 2", "3 2 2", "3 3 2", "4 1 2", "4 2 2", "4 3 2", "... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 6 | codeforces | |
fde4f9235dd44012d3470d60a923de13 | Sereja and Intervals | Sereja is interested in intervals of numbers, so he has prepared a problem about intervals for you. An interval of numbers is a pair of integers [*l*,<=*r*] (1<=≤<=*l*<=≤<=*r*<=≤<=*m*). Interval [*l*1,<=*r*1] belongs to interval [*l*2,<=*r*2] if the following condition is met: *l*2<=≤<=*l*1<=≤<=*r*1<=≤<=*r*2.
Sereja w... | {"inputs": ["1 1 1", "3 5 1", "2 3 3", "11 79 54", "18 46 26", "8 96 61", "154 5 3", "34 22 8", "29 27 7", "12 68 35", "23 12 10", "6 42 23", "143 645 43", "14 724 55", "166 36 1", "273 41 17", "54 806 191", "6159 7 7", "115 624 37", "8 967 200", "112 440 258", "490 119 1", "745 116 85", "52 978 871", "37 746 303", "10... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 1 | codeforces | |
fe12c51426fe404f0b6fb444fa11ed53 | Convex Shape | Consider an *n*<=×<=*m* grid. Initially all the cells of the grid are colored white. Lenny has painted some of the cells (at least one) black. We call a painted grid convex if one can walk from any black cell to any another black cell using a path of side-adjacent black cells changing his direction at most once during ... | {"inputs": ["3 4\nWWBW\nBWWW\nWWWB", "3 1\nB\nB\nW", "1 1\nB", "1 2\nBB", "2 1\nB\nB", "1 2\nBW", "2 1\nW\nB", "5 5\nWBBBW\nWBBBW\nWBBWW\nWBBBW\nWWWWW", "5 5\nWBBWW\nBBBWW\nBBBWW\nBBBWW\nBBBBB", "5 5\nWWWBB\nBBBBB\nWWWBB\nWWWBB\nWWWBW", "5 5\nWBBBW\nWBBWW\nWBBWW\nBBBWW\nBBWWW", "5 5\nWBBBB\nWBBBB\nWBBBB\nBBBBB\nBBBBB",... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 7 | codeforces | |
feaa637b31fdce3c496608b4398a079b | Tricky Function | Iahub and Sorin are the best competitive programmers in their town. However, they can't both qualify to an important contest. The selection will be made with the help of a single problem. Blatnatalag, a friend of Iahub, managed to get hold of the problem before the contest. Because he wants to make sure Iahub will be t... | {"inputs": ["4\n1 0 0 -1", "2\n1 -1", "100\n-57 -64 83 76 80 27 60 76 -80 -56 52 72 -17 92 -96 87 41 -88 94 89 12 42 36 34 -100 -43 -42 62 3 87 -69 -6 -27 -59 -7 5 -90 -23 63 -87 -60 -92 -40 54 -16 -47 67 -64 10 33 -19 53 -7 -62 16 -74 -36 4 -75 -55 92 3 -22 43 -30 48 -27 88 -58 41 36 8 -40 -30 -18 16 22 -66 -91 -46 48... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 4 | codeforces | |
feb6b1e03e665a72ca3cb3f0ccfc5ca2 | Two Arithmetic Progressions | You are given two arithmetic progressions: *a*1*k*<=+<=*b*1 and *a*2*l*<=+<=*b*2. Find the number of integers *x* such that *L*<=≤<=*x*<=≤<=*R* and *x*<==<=*a*1*k*'<=+<=*b*1<==<=*a*2*l*'<=+<=*b*2, for some integers *k*',<=*l*'<=≥<=0.
The only line contains six integers *a*1,<=*b*1,<=*a*2,<=*b*2,<=*L*,<=*R* (0<=<<=*a... | {"inputs": ["2 0 3 3 5 21", "2 4 3 0 6 17", "2 0 4 2 -39 -37", "1 9 3 11 49 109", "3 81 5 72 -1761 501", "8 -89 20 67 8771 35222", "1 -221 894 86403 -687111 141371", "1 -1074 271 17741 -2062230 1866217", "3 2408 819 119198 -8585197 7878219", "1 341 8581 3946733 -59420141 33253737", "1 10497 19135 2995296 -301164547 -18... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 9 | codeforces | |
febea4f23d6799418a46ea0af82f70af | Permutation | You are given a permutation of numbers from 1 to *n*. Determine whether there's a pair of integers *a*,<=*b* (1<=≤<=*a*,<=*b*<=≤<=*n*; *a*<=≠<=*b*) such that the element (note, that it is usual division, not integer one) is between *a* and *b* in this permutation.
First line consists of a single integer *n* (1<=≤<=*n*... | {"inputs": ["4\n1 3 4 2", "5\n1 5 2 4 3", "100\n17 41 19 23 46 16 10 31 82 12 77 32 11 71 83 25 98 18 34 59 13 73 80 65 37 22 6 2 24 5 94 42 51 63 52 92 97 26 93 38 36 87 64 70 14 43 68 85 33 44 74 89 56 1 69 88 20 49 48 21 84 90 7 47 39 55 81 86 76 57 3 62 15 78 100 60 61 66 91 30 58 35 99 96 54 27 79 9 29 50 45 72 75... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 1 | codeforces | |
fecd3371aac8091bff48bc8e2f52941c | Kalevitch and Chess | A famous Berland's painter Kalevitch likes to shock the public. One of his last obsessions is chess. For more than a thousand years people have been playing this old game on uninteresting, monotonous boards. Kalevitch decided to put an end to this tradition and to introduce a new attitude to chessboards.
As before, th... | {"inputs": ["WWWBWWBW\nBBBBBBBB\nWWWBWWBW\nWWWBWWBW\nWWWBWWBW\nWWWBWWBW\nWWWBWWBW\nWWWBWWBW", "WWWWWWWW\nBBBBBBBB\nWWWWWWWW\nWWWWWWWW\nWWWWWWWW\nWWWWWWWW\nWWWWWWWW\nWWWWWWWW", "WWWWWWWW\nWWWWWWWW\nWWWWWWWW\nWWWWWWWW\nWWWWWWWW\nWWWWWWWW\nWWWWWWWW\nWWWWWWWW", "BBBBBBBB\nBBBBBBBB\nBBBBBBBB\nBBBBBBBB\nBBBBBBBB\nBBBBBBBB\nB... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 170 | codeforces | |
fed340b160e4eb32c6a5954134630705 | Hierarchy | Nick's company employed *n* people. Now Nick needs to build a tree hierarchy of «supervisor-surbodinate» relations in the company (this is to say that each employee, except one, has exactly one supervisor). There are *m* applications written in the following form: «employee *a**i* is ready to become a supervisor of emp... | {"inputs": ["4\n7 2 3 1\n4\n1 2 5\n2 4 1\n3 4 1\n1 3 5", "3\n1 2 3\n2\n3 1 2\n3 1 3", "1\n2\n0", "2\n5 3\n4\n1 2 0\n1 2 5\n1 2 0\n1 2 7", "3\n9 4 5\n5\n3 2 4\n1 2 4\n3 2 8\n1 3 5\n3 2 5", "3\n2 5 9\n5\n3 1 7\n2 1 1\n2 1 6\n2 1 2\n3 1 5", "3\n6 2 9\n5\n1 2 10\n3 1 4\n1 2 5\n1 2 2\n3 1 4", "4\n10 6 7 4\n5\n1 3 1\n3 4 1\n... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 85 | codeforces | |
fee1c0d82e0df1ec46bbb228704921c3 | Relatively Prime Graph | Let's call an undirected graph $G = (V, E)$ relatively prime if and only if for each edge $(v, u) \in E$ $GCD(v, u) = 1$ (the greatest common divisor of $v$ and $u$ is $1$). If there is no edge between some pair of vertices $v$ and $u$ then the value of $GCD(v, u)$ doesn't matter. The vertices are numbered from $1$ to... | {"inputs": ["5 6", "6 12", "572 99643", "571 99403", "100 3043", "10 31", "1 1", "2 1", "100000 1", "100000 99999", "100000 100000", "1000 100000", "572 99644", "571 99404", "100 3044", "10 32", "100000 99998", "55910 88645", "72050 72069", "53599 55493", "56557 100000", "1001 100000", "50000 100000", "530 100000", "46... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 28 | codeforces | |
fef0dc43ecff47f600561e8599217ddf | Bookshelves | Mr Keks is a typical white-collar in Byteland.
He has a bookshelf in his office with some books on it, each book has an integer positive price.
Mr Keks defines the value of a shelf as the sum of books prices on it.
Miraculously, Mr Keks was promoted and now he is moving into a new office.
He learned that in the ne... | {"inputs": ["10 4\n9 14 28 1 7 13 15 29 2 31", "7 3\n3 14 15 92 65 35 89", "40 5\n6 18 24 5 14 16 31 9 15 5 25 2 18 12 19 27 10 23 23 18 22 14 1 14 6 14 17 28 11 21 8 23 10 30 21 5 17 11 26 16", "20 15\n927353279298143 655102800384382 40376603048780 1008958973042960 1123049780860278 853122601026128 154596679092462 2000... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 12 | codeforces | |
fefe761d353a35a1825f8de3622e0e44 | Phone numbers | Phone number in Berland is a sequence of *n* digits. Often, to make it easier to memorize the number, it is divided into groups of two or three digits. For example, the phone number 1198733 is easier to remember as 11-987-33. Your task is to find for a given phone number any of its divisions into groups of two or three... | {"inputs": ["6\n549871", "7\n1198733", "2\n74", "2\n33", "3\n074", "3\n081", "4\n3811", "5\n21583", "8\n33408349", "9\n988808426", "10\n0180990956", "15\n433488906230138", "22\n7135498415686025907059", "49\n2429965524999668169991253653390090510755018570235", "72\n49192533778411177050014761988172752557003973550743936062... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 157 | codeforces | |
ff10d04958977d2d3ed41f2c817605a8 | String Compression | Ivan wants to write a letter to his friend. The letter is a string *s* consisting of lowercase Latin letters.
Unfortunately, when Ivan started writing the letter, he realised that it is very long and writing the whole letter may take extremely long time. So he wants to write the compressed version of string *s* instea... | {"inputs": ["aaaaaaaaaa", "abcab", "cczabababab", "kbyjorwqjk", "baaabbbaba", "aaaaaaaaaa", "cbbbcccbbc", "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "hltcdvuobkormkxkbmpfjniilublkrckmvvxemcyietgxcyjgrjwsdsgsfmoqnmbxozfavxopklhldhnsjpxhejxaxuctxeifglx", "agdmd... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 3 | codeforces | |
ff140e99d830432ae85962a533046d13 | Feed the cat | After waking up at *hh*:*mm*, Andrew realised that he had forgotten to feed his only cat for yet another time (guess why there's only one cat). The cat's current hunger level is *H* points, moreover each minute without food increases his hunger by *D* points.
At any time Andrew can visit the store where tasty buns are... | {"inputs": ["19 00\n255 1 100 1", "17 41\n1000 6 15 11", "16 34\n61066 14 50 59", "18 18\n23331 86 87 41", "10 48\n68438 8 18 29", "08 05\n63677 9 83 25", "00 00\n100000 100 100 100", "20 55\n100000 100 100 100", "23 59\n100000 100 100 100", "00 00\n1 100 100 100", "21 26\n33193 54 97 66", "20 45\n33756 24 21 1", "14 3... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 144 | codeforces | |
ff421c3540ee1df661234b450f1c7093 | Chip Play | Let's consider the following game. We have a rectangular field *n*<=×<=*m* in size. Some squares of the field contain chips.
Each chip has an arrow painted on it. Thus, each chip on the field points in one of the following directions: up, down, left or right.
The player may choose a chip and make a move with it.
The... | {"inputs": ["4 4\nDRLD\nU.UL\n.UUR\nRDDL", "2 2\nRD\nUL", "5 5\nUD..L\nRRD..\n..RDD\nUUL..\nDDLRR", "10 10\n.L.....R..\n.........U\n..D....D..\n.R......L.\n....L.....\n.........D\n......U...\nD....R....\n...U......\n........L.", "17 13\n...LD.UR.RUU.\nLDLULDUDRRDRL\nDD.RRLRUR.UD.\nRU...D...LD..\n.UR.R...URUUD\n.RURD.RL... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 1 | codeforces | |
ff63427e0a246e9a8c857186864b88ce | k-String | A string is called a *k*-string if it can be represented as *k* concatenated copies of some string. For example, the string "aabaabaabaab" is at the same time a 1-string, a 2-string and a 4-string, but it is not a 3-string, a 5-string, or a 6-string and so on. Obviously any string is a 1-string.
You are given a string... | {"inputs": ["2\naazz", "3\nabcabcabz", "1\na", "2\nabba", "2\naaab", "7\nabacaba", "5\naaaaa", "3\naabaaaaabb", "2\naaab", "2\nbabac", "3\nbbbccc", "2\naa", "250\ncecececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececececec... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 324 | codeforces | |
ff80a5b10d8a65e60f520fb16ca6252b | none | Fox Ciel is participating in a party in Prime Kingdom. There are *n* foxes there (include Fox Ciel). The i-th fox is *a**i* years old.
They will have dinner around some round tables. You want to distribute foxes such that:
1. Each fox is sitting at some table. 1. Each table has at least 3 foxes sitting around it. 1... | {"inputs": ["4\n3 4 8 9", "5\n2 2 2 2 2", "12\n2 3 4 5 6 7 8 9 10 11 12 13", "24\n2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25", "4\n2 2 9973 9967", "30\n2 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", "20\n76 38 74 176 106 134 12 88 66 178 63 105 199 99 29 67 135 ... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 1 | codeforces | |
ff9235cd44659116788a8be5c260fa52 | Lucky Permutation | Petya loves lucky numbers. Everybody knows that lucky numbers are positive integers whose decimal representation contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.
One day Petya dreamt of a lexicographically *k*-th permutation of integers from 1 to *n*. Determine ... | {"inputs": ["7 4", "4 7", "7 1", "7 5040", "10 1023", "7 7477", "10 10000", "3 7", "27 1", "40 8544", "47 1", "47 8547744", "50 1000000000", "64 87", "98 854555", "100 1", "9985 5888454", "1 1", "1 2", "2 1000000000", "10 1000000000", "20 1000000000", "777777 1", "777777 2", "777474 10000", "1000000000 1", "777777777 5... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 5 | codeforces | |
ffffc0199ae7229539d28ba0d02e9047 | Mr. Kitayuta's Gift | Mr. Kitayuta has kindly given you a string *s* consisting of lowercase English letters. You are asked to insert exactly one lowercase English letter into *s* to make it a palindrome. A palindrome is a string that reads the same forward and backward. For example, "noon", "testset" and "a" are all palindromes, while "tes... | {"inputs": ["revive", "ee", "kitayuta", "evima", "a", "yutampo", "fft", "shuseki", "lsdijfjisl", "ewcdcwerp", "noon", "add", "iq", "hogloid", "yosupo", "stat", "level", "iwiwi", "racecar", "dog", "squirrel", "slime", "palindrome", "nqwcvcwqn", "lsdijfjisl", "jewiiwefj", "vnwmvvmonv", "zennyuu", "mrtoudai", "z", "babccb... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 108 | codeforces |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.