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 |
|---|---|---|---|---|---|---|---|---|---|
362156831077fb306342d4c49eb233dc | Socks | Arseniy is already grown-up and independent. His mother decided to leave him alone for *m* days and left on a vacation. She have prepared a lot of food, left some money and washed all Arseniy's clothes.
Ten minutes before her leave she realized that it would be also useful to prepare instruction of which particular c... | {"inputs": ["3 2 3\n1 2 3\n1 2\n2 3", "3 2 2\n1 1 2\n1 2\n2 1", "3 3 3\n1 2 3\n1 2\n2 3\n3 1", "4 2 4\n1 2 3 4\n1 2\n3 4", "10 3 2\n2 1 1 2 1 1 2 1 2 2\n4 10\n9 3\n5 7", "10 3 3\n2 2 1 3 1 2 1 2 2 2\n10 8\n9 6\n8 10", "4 3 2\n1 1 2 2\n1 2\n3 4\n2 3", "4 3 4\n1 2 3 4\n1 2\n3 4\n4 1"], "outputs": ["2", "0", "2", "2", "2"... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 6 | codeforces | |
362feba21c62cb2d514cc00014d0d4ca | Road Widening | Mayor of city S just hates trees and lawns. They take so much space and there could be a road on the place they occupy!
The Mayor thinks that one of the main city streets could be considerably widened on account of lawn nobody needs anyway. Moreover, that might help reduce the car jams which happen from time to time o... | {"inputs": ["3\n4 5\n4 5\n4 10", "4\n1 100\n100 1\n1 100\n100 1", "3\n1 1\n100 100\n1 1", "10\n21005 10850\n27020 13372\n28183 3724\n22874 13564\n27446 11493\n22522 10012\n24819 11529\n24166 11084\n24539 9211\n24152 9235", "1\n1 0", "1\n1 1000000", "1\n1000000 1000000", "1\n1 0", "1\n1 0", "1\n1 1", "2\n2 2\n1 1", "2\n... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 3 | codeforces | |
363712d886c67d89c4774c1ab80e1323 | Vanya and Lanterns | Vanya walks late at night along a straight street of length *l*, lit by *n* lanterns. Consider the coordinate system with the beginning of the street corresponding to the point 0, and its end corresponding to the point *l*. Then the *i*-th lantern is at the point *a**i*. The lantern lights all points of the street that... | {"inputs": ["7 15\n15 5 3 7 9 14 0", "2 5\n2 5", "46 615683844\n431749087 271781274 274974690 324606253 480870261 401650581 13285442 478090364 266585394 425024433 588791449 492057200 391293435 563090494 317950 173675329 473068378 356306865 311731938 192959832 321180686 141984626 578985584 512026637 175885185 590844074 ... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 247 | codeforces | |
365b239ca6df2157eeed016988a58111 | String Manipulation 1.0 | One popular website developed an unusual username editing procedure. One can change the username only by deleting some characters from it: to change the current name *s*, a user can pick number *p* and character *c* and delete the *p*-th occurrence of character *c* from the name. After the user changed his name, he can... | {"inputs": ["2\nbac\n3\n2 a\n1 b\n2 c", "1\nabacaba\n4\n1 a\n1 a\n1 c\n2 b", "1\naabbabbb\n7\n2 a\n1 a\n1 a\n2 b\n1 b\n3 b\n1 b", "1\na\n0", "4\ndb\n5\n1 d\n2 d\n2 b\n1 d\n2 b", "10\nbabcbcbcba\n40\n24 b\n14 a\n19 b\n25 b\n26 c\n7 c\n5 c\n2 a\n4 c\n7 a\n46 b\n14 a\n28 b\n4 c\n5 a\n10 c\n4 c\n4 b\n12 a\n4 a\n30 b\n4 a\n... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 14 | codeforces | |
36647db424d1b4e3c8cb6f7a5bff699e | Run For Your Prize | You and your friend are participating in a TV show "Run For Your Prize".
At the start of the show *n* prizes are located on a straight line. *i*-th prize is located at position *a**i*. Positions of all prizes are distinct. You start at position 1, your friend — at position 106 (and there is no prize in any of these tw... | {"inputs": ["3\n2 3 9", "2\n2 999995", "1\n20", "6\n2 3 500000 999997 999998 999999", "1\n999999", "1\n510000", "3\n2 5 27", "2\n600000 800000", "5\n2 5 6 27 29", "1\n500001", "10\n3934 38497 42729 45023 51842 68393 77476 82414 91465 98055", "1\n900000", "1\n500000", "1\n999998", "3\n999997 999998 999999", "2\n999997 9... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 139 | codeforces | |
366f6a376c67748485aab11d0553e116 | One Bomb | You are given a description of a depot. It is a rectangular checkered field of *n*<=×<=*m* size. Each cell in a field can be empty (".") or it can be occupied by a wall ("*").
You have one bomb. If you lay the bomb at the cell (*x*,<=*y*), then after triggering it will wipe out all walls in the row *x* and all walls ... | {"inputs": ["3 4\n.*..\n....\n.*..", "3 3\n..*\n.*.\n*..", "6 5\n..*..\n..*..\n*****\n..*..\n..*..\n..*..", "1 10\n**********", "10 1\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*", "10 10\n.........*\n.........*\n........**\n.........*\n.........*\n.........*\n.........*\n.........*\n.........*\n.........*", "10 10\n.........*\n........ | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 44 | codeforces | |
37208f991037cb5e2d4dcaa11439e2a7 | Stack Sorting | Let's suppose you have an array *a*, a stack *s* (initially empty) and an array *b* (also initially empty).
You may perform the following operations until both *a* and *s* are empty:
- Take the first element of *a*, push it into *s* and remove it from *a* (if *a* is not empty); - Take the top element from *s*, appe... | {"inputs": ["5 3\n3 2 1", "5 3\n2 3 1", "5 1\n3", "5 2\n3 4", "100000 1\n98419", "20 19\n2 18 19 11 9 20 15 1 8 14 4 6 5 12 17 16 7 13 3", "10 1\n6", "100000 2\n64398 63673", "20 18\n8 14 18 10 1 3 7 15 2 12 17 19 5 4 11 13 20 16", "10 2\n3 7", "100000 3\n43791 91790 34124", "20 17\n9 11 19 4 8 16 13 3 1 6 18 2 20 10 1... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 8 | codeforces | |
3779847abee2f9fe6408a04982f8ab8c | Magic Formulas | People in the Tomskaya region like magic formulas very much. You can see some of them below.
Imagine you are given a sequence of positive integer numbers *p*1, *p*2, ..., *p**n*. Lets write down some magic formulas:
Here, "mod" means the operation of taking the residue after dividing.
The expression means applying ... | {"inputs": ["3\n1 2 3", "1\n0", "2\n65535 0", "10\n1356106972 165139648 978829595 410669403 873711167 287346624 117863440 228957745 835903650 1575323015", "20\n1999581813 313463235 1733614990 662007911 1789348031 1120800519 196972430 1579897311 191001928 241720485 1426288783 1103088596 839698523 1974815116 77040208 904... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 41 | codeforces | |
378178d27a3bda3a7b1f7222ba920c1a | Generate a String | zscoder wants to generate an input file for some programming competition problem.
His input is a string consisting of *n* letters 'a'. He is too lazy to write a generator so he will manually generate the input in a text editor.
Initially, the text editor is empty. It takes him *x* seconds to insert or delete a letter... | {"inputs": ["8 1 1", "8 1 10", "10 62 99", "88 417 591", "57 5289 8444", "382 81437847 324871127", "244 575154303 436759189", "85 902510038 553915152", "1926 84641582 820814219", "3768 561740421 232937477", "2313 184063453 204869248", "35896 278270961 253614967", "483867 138842067 556741142", "4528217 187553422 9567316... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 19 | codeforces | |
37bdb804b3a8f89ec2cce9cc72ad2faf | Vladik and fractions | Vladik and Chloe decided to determine who of them is better at math. Vladik claimed that for any positive integer *n* he can represent fraction as a sum of three distinct positive fractions in form .
Help Vladik with that, i.e for a given *n* find three distinct positive integers *x*, *y* and *z* such that . Because ... | {"inputs": ["3", "7", "2", "5", "4", "7", "82", "56", "30", "79", "28", "4116", "1", "6491", "8865", "1239", "3614", "5988", "8363", "737", "3112", "9562", "1936", "4311", "6685", "9060", "1434", "3809", "6183", "8558", "932", "7274", "9648", "2023", "4397", "6772", "9146", "1521", "4938", "6143", "6230", "10000", "1",... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 87 | codeforces | |
37d4336f42407eff62c58aca172c1ac5 | Two Problems | A boy Valera registered on site Codeforces as Valera, and wrote his first Codeforces Round #300. He boasted to a friend Arkady about winning as much as *x* points for his first contest. But Arkady did not believe his friend's words and decided to check whether Valera could have shown such a result.
He knows that the c... | {"inputs": ["30 5 20 20 3 5", "10 4 100 5 5 1", "0 7 30 50 3 4", "50 10 30 20 1 2", "40 1 40 5 11 2", "35 8 20 20 1 2", "10 2 27 4 11 1", "64 12 258 141 10 7", "5 3 11 100 2 4", "5 4 11 80 2 4", "28 3 16 20 3 10", "6 2 11 1 11 1", "15 5 230 213 32 25", "223 92 123 118 1 1", "375 6 133 267 19 36", "80 5 39 40 1 1", "543... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 24 | codeforces | |
37e42fdcd1037129a1f34ce83dd72e75 | Problem of offices | Earlier, when there was no Internet, each bank had a lot of offices all around Bankopolis, and it caused a lot of problems. Namely, each day the bank had to collect cash from all the offices.
Once Oleg the bank client heard a dialogue of two cash collectors. Each day they traveled through all the departments and offic... | {"inputs": ["5\n2 3 4 5\n1 1 1 1", "10\n3 8 9 10\n1 2 2 2 2 2 1 1 1", "13\n13 12 9 7\n1 1 1 1 5 5 2 2 2 3 3 4", "11\n2 4 9 11\n1 1 3 3 3 3 3 1 1 10", "11\n4 2 9 11\n1 1 3 3 3 3 3 1 1 10", "6\n2 3 4 5\n1 1 1 1 1", "15\n3 9 15 13\n1 2 2 1 5 5 1 8 1 10 1 12 1 14", "15\n8 13 5 10\n1 2 1 4 1 6 6 1 9 1 11 12 1 14", "15\n15 2... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 1 | codeforces | |
37eadde8522bad99e820e7f5d7ae04d2 | Partition | You are given a sequence *a* consisting of *n* integers. You may partition this sequence into two sequences *b* and *c* in such a way that every element belongs exactly to one of these sequences.
Let *B* be the sum of elements belonging to *b*, and *C* be the sum of elements belonging to *c* (if some of these sequenc... | {"inputs": ["3\n1 -2 0", "6\n16 23 16 15 42 8", "1\n-1", "100\n-100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -1... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 390 | codeforces | |
37f46064990b21a89a9ebaabdcaa6116 | Little Elephant and Bits | The Little Elephant has an integer *a*, written in the binary notation. He wants to write this number on a piece of paper.
To make sure that the number *a* fits on the piece of paper, the Little Elephant ought to delete exactly one any digit from number *a* in the binary record. At that a new number appears. It consis... | {"inputs": ["101", "110010", "10000", "1111111110", "10100101011110101", "111010010111", "11110111011100000000", "11110010010100001110110101110011110110100111101", "1001011111010010100111111", "1111111111", "1111111111111111111100111101001110110111111000001111110101001101001110011000001011001111111000110101", "11010110... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 540 | codeforces | |
37f844d788fd8dae07bad399725a4218 | Vasily the Bear and Fly | One beautiful day Vasily the bear painted 2*m* circles of the same radius *R* on a coordinate plane. Circles with numbers from 1 to *m* had centers at points (2*R*<=-<=*R*,<=0), (4*R*<=-<=*R*,<=0), ..., (2*Rm*<=-<=*R*,<=0), respectively. Circles with numbers from *m*<=+<=1 to 2*m* had centers at points (2*R*<=-<=*R*,<=... | {"inputs": ["1 1", "2 2", "100000 3", "2344 5", "999 10", "6 1", "43 4", "3333 3", "4444 4", "100000 10", "3134 9", "9 9", "32 9", "33333 9", "99999 1", "99999 9", "99999 7", "4234 4", "66666 6", "66666 9", "67676 7", "7777 7", "7656 2", "2 8", "2 10", "2 4", "8 1", "8 8", "92399 1", "1 10", "3 1"], "outputs": ["2.0000... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 9 | codeforces | |
38108be8e55699235894cccfaad42904 | Berland Federalization | Recently, Berland faces federalization requests more and more often. The proponents propose to divide the country into separate states. Moreover, they demand that there is a state which includes exactly *k* towns.
Currently, Berland has *n* towns, some pairs of them are connected by bilateral roads. Berland has only *... | {"inputs": ["5 2\n1 2\n2 3\n3 4\n4 5", "5 3\n1 2\n1 3\n1 4\n1 5", "1 1", "11 4\n1 2\n1 3\n1 4\n2 6\n2 7\n1 5\n2 8\n4 9\n4 10\n4 11", "11 10\n1 2\n1 3\n1 4\n2 6\n2 7\n1 5\n2 8\n4 9\n4 10\n4 11", "12 3\n1 2\n1 3\n1 4\n2 6\n2 7\n1 5\n2 8\n4 9\n4 10\n4 11\n11 12", "12 6\n1 2\n1 3\n1 4\n2 6\n2 7\n1 5\n2 8\n4 9\n4 10\n4 11\n... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 1 | codeforces | |
386d4f4859cedad536c80392fb1a9f57 | none | The All-Berland National Olympiad in Informatics has just ended! Now Vladimir wants to upload the contest from the Olympiad as a gym to a popular Codehorses website.
Unfortunately, the archive with Olympiad's data is a mess. For example, the files with tests are named arbitrary without any logic.
Vladimir wants to re... | {"inputs": ["5\n01 0\n2 1\n2extra 0\n3 1\n99 0", "2\n1 0\n2 1", "5\n1 0\n11 1\n111 0\n1111 1\n11111 0", "4\nir7oz8 1\nvj4v5t 1\nkwkahb 1\nj5s8o1 0", "4\n3 1\n1o0bp2 0\n9tn379 0\nv04v6j 1", "4\n1 0\nsc7czx 0\nfr4033 1\n3 0", "4\n4 0\n1 0\n2 0\nizfotg 1", "4\n2 0\n3 0\n1 1\n4 1", "5\npuusew 1\npvoy4h 0\nwdzx4r 0\n1z84cx ... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 3 | codeforces | |
38761594b2560cef7c16e6b89aea0872 | Parquet Re-laying | Peter decided to lay a parquet in the room of size *n*<=×<=*m*, the parquet consists of tiles of size 1<=×<=2. When the workers laid the parquet, it became clear that the tiles pattern looks not like Peter likes, and workers will have to re-lay it.
The workers decided that removing entire parquet and then laying it ag... | {"inputs": ["2 3\nULR\nDLR\nLRU\nLRD", "4 3\nULR\nDLR\nLRU\nLRD\nULR\nDUU\nUDD\nDLR", "2 5\nLRUUU\nLRDDD\nLRLRU\nLRLRD", "3 8\nLRULRLRU\nUUDLRLRD\nDDLRLRLR\nULRLRLRU\nDLRLRLRD\nLRLRLRLR", "7 6\nULRULR\nDLRDLR\nUUULRU\nDDDLRD\nLRUULR\nLRDDUU\nLRLRDD\nULRLRU\nDUUUUD\nUDDDDU\nDLRLRD\nULRULR\nDLRDUU\nLRLRDD", "10 9\nLRLRLR... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 1 | codeforces | |
38845cbb3505f416bccfeb0211eb9e98 | Rock-Paper-Scissors | Nikephoros and Polycarpus play rock-paper-scissors. The loser gets pinched (not too severely!).
Let us remind you the rules of this game. Rock-paper-scissors is played by two players. In each round the players choose one of three items independently from each other. They show the items with their hands: a rock, scisso... | {"inputs": ["7\nRPS\nRSPP", "5\nRRRRRRRR\nR", "23\nRSP\nRPSS", "52\nRRPSS\nRSSPRPRPPP", "1293\nRRPSSRSSPRPRPPPRPPPRPPPPPRPSPRSSRPSPPRPRR\nSSPSSSSRPPSSSSRPRPRPPSRSRRSPPSPPRPSRSPSRR", "103948\nRRPSSRSSPRPRPPPRPPPRPPPPPRPSPRSSRPSPPRPRRSSPSSSSRPPSSSSRPRPRPPSRSRRSPPSPPRPSRSPSRRPSRSRSRPRPRSSPSPRPRSSPRPSPPRPRRRPRRPRPSPRPRSSRR... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 15 | codeforces | |
388ebdc52277ab7440b7e20c3040e284 | Which floor? | In a building where Polycarp lives there are equal number of flats on each floor. Unfortunately, Polycarp don't remember how many flats are on each floor, but he remembers that the flats are numbered from 1 from lower to upper floors. That is, the first several flats are on the first floor, the next several flats are o... | {"inputs": ["10 3\n6 2\n2 1\n7 3", "8 4\n3 1\n6 2\n5 2\n2 1", "8 3\n7 2\n6 2\n1 1", "4 2\n8 3\n3 1", "11 4\n16 4\n11 3\n10 3\n15 4", "16 6\n3 1\n16 4\n10 3\n9 3\n19 5\n8 2", "1 0", "1 1\n1 1", "1 1\n1 1", "1 2\n1 1\n2 2", "2 2\n2 1\n1 1", "2 0", "2 1\n3 3", "3 2\n1 1\n3 3", "3 3\n1 1\n3 3\n2 2", "3 0", "1 1\n2 1", "2 2... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 50 | codeforces | |
38a0572f7ab04f490a1b64127c32ee44 | Text Editor | Vasya is pressing the keys on the keyboard reluctantly, squeezing out his ideas on the classical epos depicted in Homer's Odysseus... How can he explain to his literature teacher that he isn't going to become a writer? In fact, he is going to become a programmer. So, he would take great pleasure in writing a program, b... | {"inputs": ["4\n2 1 6 4\n3 4 4 2", "4\n10 5 6 4\n1 11 4 2", "3\n10 1 10\n1 10 1 1", "4\n2 1 6 4\n4 2 3 5", "3\n20 3 20\n1 20 1 1", "2\n10 1\n1 3 2 1", "20\n3 1 9 9 6 1 3 4 5 6 7 3 1 9 9 1 9 1 5 7\n17 7 19 5", "20\n81 90 11 68 23 18 78 75 45 86 58 37 21 15 98 40 53 100 10 70\n11 55 8 19", "25\n55 47 5 63 55 11 8 32 0 62... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 5 | codeforces | |
38a77f9b1565bb7b2f12271aa22b060e | Dead Ends | Life in Bertown has become hard. The city has too many roads and the government spends too much to maintain them. There are *n* junctions and *m* two way roads, at which one can get from each junction to any other one. The mayor wants to close some roads so that the number of roads left totaled to *n*<=-<=1 roads and i... | {"inputs": ["3 3 2\n1 2\n2 3\n1 3", "4 6 2\n1 2\n2 3\n3 4\n4 1\n1 3\n2 4", "4 6 3\n1 2\n2 3\n3 4\n4 1\n1 3\n2 4", "5 4 3\n2 1\n5 3\n3 2\n1 4", "5 10 2\n2 4\n1 5\n2 5\n3 5\n4 3\n1 4\n3 1\n5 4\n3 2\n2 1", "6 6 2\n6 3\n5 2\n5 1\n3 5\n6 2\n4 3", "7 7 5\n2 1\n4 2\n7 1\n4 5\n7 6\n2 6\n2 3", "5 5 2\n1 2\n2 3\n3 4\n4 2\n4 5", ... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 1 | codeforces | |
38b21dffaeb42cac1f2f9489c6203f5b | Karen and Morning | Karen is getting ready for a new school day!
It is currently hh:mm, given in a 24-hour format. As you know, Karen loves palindromes, and she believes that it is good luck to wake up when the time is a palindrome.
What is the minimum number of minutes she should sleep, such that, when she wakes up, the time is a palin... | {"inputs": ["05:39", "13:31", "23:59", "13:32", "14:40", "14:00", "05:50", "12:22", "12:34", "05:30", "14:14", "01:10", "02:20", "03:30", "04:40", "10:01", "11:11", "12:21", "14:41", "15:51", "20:02", "21:12", "22:22", "23:32", "01:11", "02:21", "03:31", "04:41", "05:51", "10:02", "11:12", "14:42", "15:52", "20:03", "2... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 133 | codeforces | |
38bbe6896f63d0ca66f3881b65296b14 | Hacking Cypher | Polycarpus participates in a competition for hacking into a new secure messenger. He's almost won.
Having carefully studied the interaction protocol, Polycarpus came to the conclusion that the secret key can be obtained if he properly cuts the public key of the application into two parts. The public key is a long inte... | {"inputs": ["116401024\n97 1024", "284254589153928171911281811000\n1009 1000", "120\n12 1", "604\n6 4", "2108\n7 8", "7208\n10 1", "97502821\n25 91", "803405634\n309 313", "15203400\n38 129", "8552104774\n973 76", "2368009434\n320 106", "425392502895812\n4363 2452", "142222201649130\n4854 7853", "137871307228140\n9375 ... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 4 | codeforces | |
38bddbbfe2d04819082a90ef67615560 | Sum the Fibonacci | You are given an array *s* of *n* non-negative integers.
A 5-tuple of integers (*a*,<=*b*,<=*c*,<=*d*,<=*e*) is said to be valid if it satisfies the following conditions:
- 1<=≤<=*a*,<=*b*,<=*c*,<=*d*,<=*e*<=≤<=*n* - (*s**a* | *s**b*) & *s**c* & (*s**d* ^ *s**e*)<==<=2*i* for some integer *i* - *s**a* &am... | {"inputs": ["2\n1 2", "3\n7 4 1", "10\n1 3 0 7 3 7 6 5 7 5", "10\n50 9 11 44 39 40 5 39 23 7", "10\n4 4 3 1 5 1 3 6 4 4", "10\n5 6 3 2 6 4 3 0 2 7", "10\n7 0 4 3 7 6 2 1 0 2", "10\n1 2 4 4 7 1 1 2 7 5", "10\n3 5 5 4 0 4 1 4 5 1", "10\n6826 5946 9767 38900 11942 58422 45007 53023 3656 41010", "10\n53002 36454 23921 1410... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 2 | codeforces | |
38cc59de94bca64c6c7c4f4eb9abdbc9 | Permutation Sum | Permutation *p* is an ordered set of integers *p*1,<=<=*p*2,<=<=...,<=<=*p**n*, consisting of *n* distinct positive integers, each of them doesn't exceed *n*. We'll denote the *i*-th element of permutation *p* as *p**i*. We'll call number *n* the size or the length of permutation *p*1,<=<=*p*2,<=<=...,<=<=*p**n*.
Pety... | {"inputs": ["3", "5", "13", "1", "2", "4", "6", "15", "16", "7", "8", "9", "10", "11", "12", "14"], "outputs": ["18", "1800", "695720788", "1", "0", "0", "0", "150347555", "0", "670320", "0", "734832000", "0", "890786230", "0", "0"]} | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 6 | codeforces | |
38e555730668a446d73aaad7b3fe78f0 | Roads in Berland | There are *n* cities numbered from 1 to *n* in Berland. Some of them are connected by two-way roads. Each road has its own length — an integer number from 1 to 1000. It is known that from each city it is possible to get to any other city by existing roads. Also for each pair of cities it is known the shortest distance ... | {"inputs": ["2\n0 5\n5 0\n1\n1 2 3", "3\n0 4 5\n4 0 9\n5 9 0\n2\n2 3 8\n1 2 1", "3\n0 983 173\n983 0 810\n173 810 0\n3\n3 2 567\n2 3 767\n1 2 763", "4\n0 537 1064 656\n537 0 527 119\n1064 527 0 408\n656 119 408 0\n4\n1 4 123\n1 4 344\n3 2 982\n3 2 587", "5\n0 954 1255 266 751\n954 0 1677 688 1173\n1255 1677 0 989 504\n... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 11 | codeforces | |
3903f48dfec315a3660b8c5081fb87be | Letter | Patrick has just finished writing a message to his sweetheart Stacey when he noticed that the message didn't look fancy. Patrick was nervous while writing the message, so some of the letters there were lowercase and some of them were uppercase.
Patrick believes that a message is fancy if any uppercase letter stands to... | {"inputs": ["PRuvetSTAaYA", "OYPROSTIYAOPECHATALSYAPRIVETSTASYA", "helloworld", "P", "t", "XdJ", "FSFlNEelYY", "lgtyasficu", "WYKUDTDDBT", "yysxwlyqboatikfnpxczmpijziiojbvadlfozjqldssffcxdegyxfrvohoxvgsrvlzjlkcuffoeisrpvagxtbkapkpzcafadzzjd", "mnAkOBuKxaiJwXhKnlcCvjxYXGXDoIqfUYkiLrdSYWhMemgWFzsgpoKOtHqooxbLYFuABWQSXuHd... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 188 | codeforces | |
392ed5caa360e1dc63110f061175dd82 | Thor | Thor is getting used to the Earth. As a gift Loki gave him a smartphone. There are *n* applications on this phone. Thor is fascinated by this phone. He has only one minor issue: he can't count the number of unread notifications generated by those applications (maybe Loki put a curse on it so he can't).
*q* events are ... | {"inputs": ["3 4\n1 3\n1 1\n1 2\n2 3", "4 6\n1 2\n1 4\n1 2\n3 3\n1 3\n1 3", "10 85\n2 2\n1 10\n1 1\n2 6\n1 2\n1 4\n1 7\n2 1\n1 1\n3 3\n1 9\n1 6\n1 8\n1 10\n3 8\n2 8\n1 6\n1 3\n1 9\n1 6\n1 3\n1 8\n1 1\n1 6\n1 10\n2 1\n2 10\n1 10\n1 1\n1 10\n1 6\n1 2\n1 8\n1 3\n1 4\n1 9\n1 5\n1 5\n2 2\n2 4\n1 7\n1 1\n2 4\n1 9\n1 1\n1 7\n... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 21 | codeforces | |
39309ddd3f632f4dfef8be76b7678c4c | Paths in a Complete Binary Tree | *T* is a complete binary tree consisting of *n* vertices. It means that exactly one vertex is a root, and each vertex is either a leaf (and doesn't have children) or an inner node (and has exactly two children). All leaves of a complete binary tree have the same depth (distance from the root). So *n* is a number such t... | {"inputs": ["15 2\n4\nUURL\n8\nLRLLLLLLLL", "1 1\n1\nL", "1 1\n1\nR", "1 1\n1\nU", "1 10\n1\nURLRLULUR\n1\nLRRRURULULL\n1\nLURURRUUUU\n1\nRRULLLRRUL\n1\nUULLUURL\n1\nRLRRULUL\n1\nLURRLRUULRR\n1\nLULLULUUUL\n1\nURULLULL\n1\nLRRLRUUUURRLRRL", "3 10\n2\nRUUUULULULUU\n1\nULLLURLU\n3\nLLURLULU\n2\nRRLURLURLLR\n3\nLRURURLRLL... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 23 | codeforces | |
394d35313163682fb593a583a299c398 | none | There are *n* types of coins in Byteland. Conveniently, the denomination of the coin type *k* divides the denomination of the coin type *k*<=+<=1, the denomination of the coin type 1 equals 1 tugrick. The ratio of the denominations of coin types *k*<=+<=1 and *k* equals *a**k*. It is known that for each *x* there are a... | {"inputs": ["1\n\n4\n2", "2\n1\n4 4\n2", "3\n3 3\n10 10 10\n17", "2\n2\n200000 100000\n34567", "20\n2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 299981\n1234567890", "20\n2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2\n299981 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1\n1034567", "10\n1 1 1 1 1 1 1 1 2... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 1 | codeforces | |
39544f28821bb5aa59b8dec97a4e1e49 | Error Correct System | Ford Prefect got a job as a web developer for a small company that makes towels. His current work task is to create a search engine for the website of the company. During the development process, he needs to write a subroutine for comparing strings *S* and *T* of equal length to be "similar". After a brief search on th... | {"inputs": ["9\npergament\npermanent", "6\nwookie\ncookie", "4\npetr\negor", "6\ndouble\nbundle", "1\na\na", "1\na\nb", "2\naa\naa", "2\nzz\nzz", "2\nzx\nzz", "2\nzz\nzx", "2\nxy\nzz", "2\nzz\nxy", "2\nzx\nxz", "2\nab\nbc", "2\nab\ncb", "2\nxx\nyy", "10\ncdcddbacdb\naababacabc", "2\nab\ncd", "2\naa\nab", "3\nabc\nbca",... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 27 | codeforces | |
3958501202101ff6b2ac1fdd5918475d | Buggy Robot | Ivan has a robot which is situated on an infinite grid. Initially the robot is standing in the starting cell (0,<=0). The robot can process commands. There are four types of commands it can perform:
- U — move from the cell (*x*,<=*y*) to (*x*,<=*y*<=+<=1); - D — move from (*x*,<=*y*) to (*x*,<=*y*<=-<=1); - L — mo... | {"inputs": ["4\nLDUR", "5\nRRRUU", "6\nLLRRRR", "88\nLLUUULRDRRURDDLURRLRDRLLRULRUUDDLLLLRRDDURDURRLDURRLDRRRUULDDLRRRDDRRLUULLURDURUDDDDDLDR", "89\nLDLLLDRDUDURRRRRUDULDDDLLUDLRLRLRLDLDUULRDUDLRRDLUDLURRDDRRDLDUDUUURUUUDRLUDUDLURDLDLLDDU", "90\nRRRDUULLLRDUUDDRLDLRLUDURDRDUUURUURDDRRRURLDDDUUDRLLLULURDRDRURLDRRRRUULDU... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 226 | codeforces | |
3988deb311c9bfcfc4ac5c195612dbd0 | Far Relative’s Birthday Cake | Door's family is going celebrate Famil Doors's birthday party. They love Famil Door so they are planning to make his birthday cake weird!
The cake is a *n*<=×<=*n* square consisting of equal squares with side length 1. Each square is either empty or consists of a single chocolate. They bought the cake and randomly sta... | {"inputs": ["3\n.CC\nC..\nC.C", "4\nCC..\nC..C\n.CC.\n.CC.", "5\n.CCCC\nCCCCC\n.CCC.\nCC...\n.CC.C", "7\n.CC..CC\nCC.C..C\nC.C..C.\nC...C.C\nCCC.CCC\n.CC...C\n.C.CCC.", "8\n..C....C\nC.CCC.CC\n.C..C.CC\nCC......\nC..C..CC\nC.C...C.\nC.C..C..\nC...C.C.", "9\n.C...CCCC\nC.CCCC...\n....C..CC\n.CC.CCC..\n.C.C..CC.\nC...C.C... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 430 | codeforces | |
39bbee704fc84a224ebeb5084d155b4f | Make a Square | You are given a positive integer $n$, written without leading zeroes (for example, the number 04 is incorrect).
In one operation you can delete any digit of the given integer so that the result remains a positive integer without leading zeros.
Determine the minimum number of operations that you need to consistently ... | {"inputs": ["8314", "625", "333", "1881388645", "1059472069", "1354124829", "149723943", "101", "1999967841", "2000000000", "1999431225", "30", "1000", "3081", "10", "2003064", "701", "1234567891", "10625", "13579", "1999999999", "150000", "8010902", "20100", "40404", "70000729", "1899933124", "1999999081", "326700", "... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 76 | codeforces | |
39d7d73ee8bf7fb917707a725fcecbc3 | Potions Homework | Harry Water, Ronaldo, Her-my-oh-knee and their friends have started a new school year at their MDCS School of Speechcraft and Misery. At the time, they are very happy to have seen each other after a long time. The sun is shining, birds are singing, flowers are blooming, and their Potions class teacher, professor Snipe ... | {"inputs": ["2\n1\n3"], "outputs": ["6"]} | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 43 | codeforces | |
39e33fe03d8030b451d146fb78f7dab7 | Point on Spiral | Valera the horse lives on a plane. The Cartesian coordinate system is defined on this plane. Also an infinite spiral is painted on the plane. The spiral consists of segments: [(0,<=0),<=(1,<=0)], [(1,<=0),<=(1,<=1)], [(1,<=1),<=(<=-<=1,<=1)], [(<=-<=1,<=1),<=(<=-<=1,<=<=-<=1)], [(<=-<=1,<=<=-<=1),<=(2,<=<=-<=1)], [(2,<... | {"inputs": ["0 0", "1 0", "0 1", "-1 -1", "10 10", "0 6", "-7 -13", "37 -100", "99 100", "16 -32", "1 1", "-1 1", "-1 0", "3 -5", "0 -1", "1 -1", "100 100", "0 99", "-98 98", "-97 0", "-96 -96", "0 -95", "94 -94", "93 0", "17 25", "1 -84", "-5 44", "11 -15", "42 9", "-81 3", "100 99", "2 -1"], "outputs": ["0", "0", "2"... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 6 | codeforces | |
39e8800931f696ffb8fdfc41c39b18dd | Valera and Contest | Valera loves to participate in competitions. Especially in programming contests. Today he has participated in the contest with his team, consisting of *n* students (including Valera). This contest was an individual competition, so each student in the team solved problems individually.
After the contest was over, Valer... | {"inputs": ["5 3 1 3 13 9", "5 3 1 3 15 9", "50 25 1 1 50 25", "1000 700 782 1000 892330 648282", "1000 999 500 503 501513 501013", "999 998 500 501 500009 499509", "999 998 500 500 499500 499000", "999 997 500 502 500516 499516", "1000 300 50 500 269795 127658", "50 25 1000 1000 50000 25000", "100 100 500 1000 75589 7... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 35 | codeforces | |
3a2ed3d0ddf1e89b171a443e3b293e3c | The number of positions | Petr stands in line of *n* people, but he doesn't know exactly which position he occupies. He can say that there are no less than *a* people standing in front of him and no more than *b* people standing behind him. Find the number of different positions Petr can occupy.
The only line contains three integers *n*, *a* an... | {"inputs": ["3 1 1", "5 2 3", "5 4 0", "6 5 5", "9 4 3", "11 4 6", "13 8 7", "14 5 5", "16 6 9", "20 13 17", "22 4 8", "23 8 14", "26 18 22", "28 6 1", "29 5 23", "32 27 15", "33 11 5", "37 21 15", "39 34 33", "41 27 11", "42 25 16", "45 7 43", "47 16 17", "49 11 37", "51 38 39", "52 29 7", "56 43 12", "58 57 28", "59 ... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 466 | codeforces | |
3a34b87fc366a4d65f122e24216aa3f8 | Tell Your World | Connect the countless points with lines, till we reach the faraway yonder.
There are *n* points on a coordinate plane, the *i*-th of which being (*i*,<=*y**i*).
Determine whether it's possible to draw two parallel and non-overlapping lines, such that every point in the set lies on exactly one of them, and each of the... | {"inputs": ["5\n7 5 8 6 9", "5\n-1 -2 0 0 -5", "5\n5 4 3 2 1", "5\n1000000000 0 0 0 0", "5\n1000000000 1 0 -999999999 -1000000000", "3\n998 244 353", "3\n-1000000000 0 1000000000", "5\n-1 -1 -1 -1 1", "4\n-9763 530 3595 6660", "4\n-253090305 36298498 374072642 711846786", "5\n-186772848 -235864239 -191561068 -193955178... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 29 | codeforces | |
3a4944a4a61a49529d73e0c3ffb1252b | Bag of mice | The dragon and the princess are arguing about what to do on the New Year's Eve. The dragon suggests flying to the mountains to watch fairies dancing in the moonlight, while the princess thinks they should just go to bed early. They are desperate to come to an amicable agreement, so they decide to leave this up to chanc... | {"inputs": ["1 3", "5 5", "100 100", "100 1", "1 100", "67 420", "0 1000", "1000 0", "0 0", "1000 1000", "32 1000", "581 406", "459 52", "900 853", "778 218", "219 20", "815 665", "773 467", "215 269", "93 633", "267 270", "226 72", "666 436", "544 519", "141 883", "581 685", "459 487", "980 133", "858 934", "455 299",... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 3 | codeforces | |
3a7496dc01395a64dcd10c9444286d53 | Guess a number! | A TV show called "Guess a number!" is gathering popularity. The whole Berland, the old and the young, are watching the show.
The rules are simple. The host thinks of an integer *y* and the participants guess it by asking questions to the host. There are four types of acceptable questions:
- Is it true that *y* is st... | {"inputs": ["4\n>= 1 Y\n< 3 N\n<= -3 N\n> 55 N", "2\n> 100 Y\n< -100 Y", "4\n< 1 N\n> 1 N\n> 1 N\n> 1 N", "4\n<= 1 Y\n>= 1 Y\n>= 1 Y\n<= 1 Y", "4\n< 10 Y\n> -6 Y\n< 10 Y\n< -10 N", "1\n< 1 N", "1\n<= 1 Y", "1\n> 1 N", "1\n>= 1 Y", "4\n< 1 N\n< 1 N\n< 1 N\n<= 1 Y", "4\n< 1 N\n>= 1 Y\n< 1 N\n< 1 N", "4\n> 1 N\n<= 1 Y\n<=... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 61 | codeforces | |
3a77f3f4e5388497e5271357cd5d6a2b | Path Counting | You are given a rooted tree. Let's denote *d*(*x*) as depth of node *x*: depth of the root is 1, depth of any other node *x* is *d*(*y*)<=+<=1, where *y* is a parent of *x*.
The tree has the following property: every node *x* with *d*(*x*)<==<=*i* has exactly *a**i* children. Maximum possible depth of a node is *n*, a... | {"inputs": ["4\n2 2 2", "3\n2 3", "2\n2", "6\n2 2 4 2 4"], "outputs": ["14 19 20 20 16 16 ", "8 13 6 9 ", "2 1 ", "182 415 420 980 1216 2432 1536 3328 2048 4096 "]} | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 2 | codeforces | |
3a9926b5ae6c5e1afb1e2414cad41a5d | Vasya the Architect | Once Vasya played bricks. All the bricks in the set had regular cubical shape. Vasya vas a talented architect, however the tower he built kept falling apart.
Let us consider the building process. Vasya takes a brick and puts it on top of the already built tower so that the sides of the brick are parallel to the sides ... | {"inputs": ["2\n0 0 3 3\n1 0 4 3", "2\n0 0 3 3\n2 0 5 3", "3\n0 0 3 3\n1 0 4 3\n2 0 5 3", "5\n7 -10 -8 5\n4 -7 -5 2\n2 -5 -3 0\n-9 48 50 -11\n50 -4 -2 48", "5\n6 -2 13 -9\n17 2 2 -13\n13 -2 6 -9\n4 0 15 -11\n8 -7 11 -4", "7\n4 6 1 9\n-1 4 6 11\n8 13 -3 2\n-5 0 45 50\n-2 50 45 3\n45 50 -4 1\n45 50 -1 4", "7\n24 6 11 -7\... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 1 | codeforces | |
3add68635ce4d4c3e1958fcf25655fc7 | Browser | Luba is surfing the Internet. She currently has *n* opened tabs in her browser, indexed from 1 to *n* from left to right. The mouse cursor is currently located at the *pos*-th tab. Luba needs to use the tabs with indices from *l* to *r* (inclusive) for her studies, and she wants to close all the tabs that don't belong ... | {"inputs": ["6 3 2 4", "6 3 1 3", "5 2 1 5", "100 1 1 99", "100 50 1 99", "100 99 1 99", "100 100 1 99", "100 50 2 100", "100 1 100 100", "100 50 50 50", "6 4 2 5", "100 5 2 50", "10 7 3 9", "7 4 2 5", "43 16 2 18", "100 50 2 51", "6 5 2 4", "10 5 2 7", "10 10 2 9", "10 7 3 7", "64 64 8 44", "5 4 2 4", "6 6 3 5", "10 6... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 94 | codeforces | |
3aedbea91125683b6bcdb3225a3a9a4b | Team | Now it's time of Olympiads. Vanya and Egor decided to make his own team to take part in a programming Olympiad. They've been best friends ever since primary school and hopefully, that can somehow help them in teamwork.
For each team Olympiad, Vanya takes his play cards with numbers. He takes only the cards containing ... | {"inputs": ["1 2", "4 8", "4 10", "1 5", "3 4", "3 10", "74 99", "19 30", "33 77", "3830 6966", "1000000 1000000", "1027 2030", "4610 4609", "3342 3339", "7757 7755", "10 8", "4247 8495", "7101 14204", "9801 19605", "4025 6858", "7129 13245", "8826 12432", "6322 9256", "8097 14682", "6196 6197", "1709 2902", "455 512",... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 106 | codeforces | |
3b240e3783c43aa47c25b9f1274195ff | Xenia and Bit Operations | Xenia the beginner programmer has a sequence *a*, consisting of 2*n* non-negative integers: *a*1,<=*a*2,<=...,<=*a*2*n*. Xenia is currently studying bit operations. To better understand how they work, Xenia decided to calculate some value *v* for *a*.
Namely, it takes several iterations to calculate value *v*. At the ... | {"inputs": ["2 4\n1 6 3 5\n1 4\n3 4\n1 2\n1 2", "1 1\n1 1\n1 1", "1 10\n6 26\n1 11\n1 9\n1 31\n1 10\n2 12\n1 8\n2 10\n2 4\n2 18\n1 31", "1 10\n22 17\n2 15\n2 12\n1 6\n1 16\n2 24\n1 21\n2 19\n2 25\n2 19\n2 1", "2 10\n15 27 17 18\n2 12\n4 19\n2 3\n4 1\n3 15\n3 11\n2 5\n1 26\n1 17\n3 18", "2 10\n31 17 22 5\n2 15\n2 26\n1 ... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 3 | codeforces | |
3b5282f8f5542b87becd68ad6319772f | Representative Sampling | The Smart Beaver from ABBYY has a long history of cooperating with the "Institute of Cytology and Genetics". Recently, the Institute staff challenged the Beaver with a new problem. The problem is as follows.
There is a collection of *n* proteins (not necessarily distinct). Each protein is a string consisting of lowerc... | {"inputs": ["3 2\naba\nbzd\nabq", "4 3\neee\nrrr\nttt\nqqq", "4 3\naaa\nabba\nabbc\nabbd", "1 1\nhelloeveryonethisisjustaverylongstringwouldyoueverexpectthisyesthisstringisveryverylongidonothaveenoughimaginationsohereyougohelloeveryonethisisjustaverylongstringwouldyoueverexpectthisyesthisstringisveryverylongidonothavee... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 2 | codeforces | |
3b61de978dbfc1b20b9f022753ecc871 | 4-point polyline | You are given a rectangular grid of lattice points from (0,<=0) to (*n*,<=*m*) inclusive. You have to choose exactly 4 different points to build a polyline possibly with self-intersections and self-touching. This polyline should be as long as possible.
A polyline defined by points *p*1,<=*p*2,<=*p*3,<=*p*4 consists of... | {"inputs": ["1 1", "0 10", "10 10", "100 100", "10 100", "20 1000", "1000 20", "100 10", "2 2", "3 3", "2 15", "15 2", "1000 1000", "1000 999", "999 1000", "987 567", "555 555", "555 1", "1 4", "955 956", "4 0", "0 3", "3 0", "2 3", "3 2", "3 4", "4 3", "3 5", "5 3", "3 6", "6 3", "4 4", "4 5", "5 4", "4 6", "6 4", "4 ... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 11 | codeforces | |
3b63b03c271256ddd7519d874f49bf6d | Ciel the Commander | Now Fox Ciel becomes a commander of Tree Land. Tree Land, like its name said, has *n* cities connected by *n*<=-<=1 undirected roads, and for any two cities there always exists a path between them.
Fox Ciel needs to assign an officer to each city. Each officer has a rank — a letter from 'A' to 'Z'. So there will be 26... | {"inputs": ["4\n1 2\n1 3\n1 4", "10\n1 2\n2 3\n3 4\n4 5\n5 6\n6 7\n7 8\n8 9\n9 10", "6\n1 2\n2 4\n4 5\n6 4\n3 2", "2\n2 1", "15\n1 2\n1 3\n2 4\n2 5\n3 6\n3 7\n4 8\n4 9\n5 10\n5 11\n6 12\n6 13\n7 14\n7 15", "30\n23 13\n10 23\n21 10\n17 21\n2 17\n4 2\n14 4\n1 14\n19 1\n26 19\n11 26\n15 11\n25 15\n3 25\n28 3\n5 28\n18 5\n... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 3 | codeforces | |
3b7679613a34b5a0390fc195fff3af71 | IT Restaurants | Сity N. has a huge problem with roads, food and IT-infrastructure. In total the city has *n* junctions, some pairs of them are connected by bidirectional roads. The road network consists of *n*<=-<=1 roads, you can get from any junction to any other one by these roads. Yes, you're right — the road network forms an undi... | {"inputs": ["5\n1 2\n2 3\n3 4\n4 5", "10\n1 2\n2 3\n3 4\n5 6\n6 7\n7 4\n8 9\n9 10\n10 4", "3\n3 1\n2 1", "4\n4 3\n4 1\n4 2", "5\n5 4\n4 1\n5 2\n3 2", "5\n1 4\n2 1\n5 1\n1 3", "6\n1 5\n3 4\n6 1\n3 2\n3 1", "6\n5 1\n1 2\n1 3\n6 1\n4 1", "6\n5 4\n2 1\n2 5\n3 4\n3 6", "18\n7 12\n14 8\n11 4\n6 3\n2 3\n15 10\n8 16\n6 16\n15 ... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 5 | codeforces | |
3b8a51ebdac11b1f7888e126253f4c09 | Bets | In Chelyabinsk lives a much respected businessman Nikita with a strange nickname "Boss". Once Nikita decided to go with his friend Alex to the Summer Biathlon World Cup. Nikita, as a very important person, received a token which allows to place bets on each section no more than on one competitor.
To begin with friends... | {"inputs": ["4 4\n1 4 20 5\n1 3 21 10\n3 3 4 30\n3 4 4 20", "8 4\n1 5 24 10\n2 4 6 15\n4 6 30 50\n6 7 4 20", "2 2\n1 2 3 1\n2 2 3 10", "20 30\n15 17 54 46\n4 18 26 18\n18 20 49 94\n12 12 83 12\n11 13 88 47\n8 8 8 12\n18 18 94 2\n14 17 88 96\n19 19 62 97\n1 12 81 67\n10 12 78 26\n19 20 63 93\n9 20 38 32\n7 9 90 17\n9 10... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 16 | codeforces | |
3b8efefac394b48855026af6e68d01ea | Anton and Letters | Recently, Anton has found a set. The set consists of small English letters. Anton carefully wrote out all the letters from the set in one line, separated by a comma. He also added an opening curved bracket at the beginning of the line and a closing curved bracket at the end of the line.
Unfortunately, from time to ti... | {"inputs": ["{a, b, c}", "{b, a, b, a}", "{}", "{a, a, c, b, b, b, c, c, c, c}", "{a, c, b, b}", "{a, b}", "{a}", "{b, a, b, a, b, c, c, b, c, b}", "{e, g, c, e}", "{a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 771 | codeforces | |
3b9d861c71dcfb2461f6d7a5f9309258 | Tree Constructing | You are given three integers $n$, $d$ and $k$.
Your task is to construct an undirected tree on $n$ vertices with diameter $d$ and degree of each vertex at most $k$, or say that it is impossible.
An undirected tree is a connected undirected graph with $n - 1$ edges.
Diameter of a tree is the maximum length of a simpl... | {"inputs": ["6 3 3", "6 2 3", "10 4 3", "8 5 3", "8 3 3", "5 4 2", "5 4 3", "5 5 2", "5 5 3", "6 4 2", "6 4 3", "6 5 2", "6 5 3", "7 4 2", "7 4 3", "7 5 2", "7 5 3", "1 1 1", "400000 400000 400000", "400000 399999 400000", "400000 399999 2", "200000 100000 3", "200000 100000 2", "400000 2 399999", "400000 100 399999", ... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 6 | codeforces | |
3ba660d87505352bc671bca512dd542a | Little Elephant and Inversions | The Little Elephant has array *a*, consisting of *n* positive integers, indexed from 1 to *n*. Let's denote the number with index *i* as *a**i*.
The Little Elephant wants to count, how many pairs of integers *l* and *r* are there, such that 1<=≤<=*l*<=<<=*r*<=≤<=*n* and sequence *b*<==<=*a*1*a*2... *a**l**a**r**a**... | {"inputs": ["3 1\n1 3 2", "5 2\n1 3 2 1 7", "7 3\n1 7 6 4 9 5 3", "5 0\n1 2 3 4 5", "2 1\n2 1", "3 1000000000000\n3 2 1", "10 5\n1 4 4 2 3 7 6 5 1 2", "10 10\n7 5 5 5 9 10 9 8 7 5", "7 1\n10 38 46 40 88 5 94", "20 7\n5 10 23 7 24 7 15 11 13 18 18 18 8 20 5 16 7 25 2 22", "40 1000000000000000000\n83 35 47 18 96 63 24 91... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 1 | codeforces | |
3bf5c3e48c7b053e6aa8fc1ca6730f73 | Han Solo and Lazer Gun | There are *n* Imperial stormtroopers on the field. The battle field is a plane with Cartesian coordinate system. Each stormtrooper is associated with his coordinates (*x*,<=*y*) on this plane.
Han Solo has the newest duplex lazer gun to fight these stormtroopers. It is situated at the point (*x*0,<=*y*0). In one shot... | {"inputs": ["4 0 0\n1 1\n2 2\n2 0\n-1 -1", "2 1 2\n1 1\n1 0", "1 1 1\n0 0", "2 0 0\n10000 -10000\n-10000 10000", "2 0 0\n10000 -10000\n10000 10000", "10 -4 -4\n2 -4\n2 0\n-4 2\n5 -4\n-3 -5\n1 4\n-4 2\n-3 5\n0 -3\n2 4", "10 5 -3\n1 1\n2 -1\n2 2\n1 -2\n4 -5\n1 4\n0 1\n1 -4\n-2 0\n-4 -5", "10 -3 3\n3 -5\n4 3\n0 -2\n0 0\n3... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 49 | codeforces | |
3c01c47c4140ffb5cc3d12303aab46b6 | Radio Station | As the guys fried the radio station facilities, the school principal gave them tasks as a punishment. Dustin's task was to add comments to nginx configuration for school's website. The school has *n* servers. Each server has a name and an ip (names aren't necessarily unique, but ips are). Dustin knows the ip and name o... | {"inputs": ["2 2\nmain 192.168.0.2\nreplica 192.168.0.1\nblock 192.168.0.1;\nproxy 192.168.0.2;", "3 5\ngoogle 8.8.8.8\ncodeforces 212.193.33.27\nserver 138.197.64.57\nredirect 138.197.64.57;\nblock 8.8.8.8;\ncf 212.193.33.27;\nunblock 8.8.8.8;\ncheck 138.197.64.57;", "10 10\nittmcs 112.147.123.173\njkt 228.40.73.178\n... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 318 | codeforces | |
3c179f3122e0ce363e5ca25b758760cf | Yet Another Array Queries Problem | You are given an array *a* of size *n*, and *q* queries to it. There are queries of two types:
- 1 *l**i* *r**i* — perform a cyclic shift of the segment [*l**i*,<=*r**i*] to the right. That is, for every *x* such that *l**i*<=≤<=*x*<=<<=*r**i* new value of *a**x*<=+<=1 becomes equal to old value of *a**x*, and ne... | {"inputs": ["6 3 5\n1 2 3 4 5 6\n2 1 3\n2 3 6\n1 1 6\n2 2 1 5 3", "5 2 5\n64 3 4 665 2\n1 1 3\n2 1 5\n1 2 3 4 5", "1 1 1\n474812122\n2 1 1\n1"], "outputs": ["3 3 1 5 2 ", "2 665 3 64 4 ", "474812122 "]} | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 6 | codeforces | |
3c222ec7bff9ab0113db8765e93d9bcc | The least round way | There is a square matrix *n*<=×<=*n*, consisting of non-negative integer numbers. You should find such a way on it that
- starts in the upper left cell of the matrix; - each following cell is to the right or down from the current cell; - the way ends in the bottom right cell.
Moreover, if we multiply together all... | {"inputs": ["3\n1 2 3\n4 5 6\n7 8 9", "2\n7 6\n3 8", "3\n4 10 5\n10 9 4\n6 5 3", "4\n1 1 9 9\n3 4 7 3\n7 9 1 7\n1 7 1 5", "5\n8 3 2 1 4\n3 7 2 4 8\n9 2 8 9 10\n2 3 6 10 1\n8 2 2 8 4", "6\n5 5 4 10 5 5\n7 10 8 7 6 6\n7 1 7 9 7 8\n5 5 3 3 10 9\n5 8 10 6 3 8\n3 10 5 4 3 4", "7\n2 9 8 2 7 4 8\n9 5 4 4 8 5 3\n5 7 2 10 8 1 8... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 13 | codeforces | |
3c32c34ac5004228f7041da8bc753e4d | Cows and Primitive Roots | The cows have just learned what a primitive root is! Given a prime *p*, a primitive root is an integer *x* (1<=≤<=*x*<=<<=*p*) such that none of integers *x*<=-<=1,<=*x*2<=-<=1,<=...,<=*x**p*<=-<=2<=-<=1 are divisible by *p*, but *x**p*<=-<=1<=-<=1 is.
Unfortunately, computing primitive roots can be time consumin... | {"inputs": ["3", "5", "7", "11", "17", "19", "1583", "997", "2", "1987", "1993", "1997", "1999", "1297", "163", "1259", "821", "29", "43", "1949", "1879", "1759", "1597", "1619", "1277", "1097", "953", "751", "607", "509", "431", "317", "211", "127", "101", "31"], "outputs": ["1", "2", "2", "4", "8", "6", "672", "328",... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 51 | codeforces | |
3c5efa15dc96e7b2f9d279fa7af33f0a | Design Tutorial: Make It Nondeterministic | A way to make a new task is to make it nondeterministic or probabilistic. For example, the hard task of Topcoder SRM 595, Constellation, is the probabilistic version of a convex hull.
Let's try to make a new task. Firstly we will use the following task. There are *n* people, sort them by their name. It is just an ordi... | {"inputs": ["3\ngennady korotkevich\npetr mitrichev\ngaoyuan chen\n1 2 3", "3\ngennady korotkevich\npetr mitrichev\ngaoyuan chen\n3 1 2", "2\ngalileo galilei\nnicolaus copernicus\n2 1", "10\nrean schwarzer\nfei claussell\nalisa reinford\neliot craig\nlaura arseid\njusis albarea\nmachias regnitz\nsara valestin\nemma mil... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 6 | codeforces | |
3cb7da3f6aa21d20c10d29e847128545 | Squares and not squares | Ann and Borya have *n* piles with candies and *n* is even number. There are *a**i* candies in pile with number *i*.
Ann likes numbers which are square of some integer and Borya doesn't like numbers which are square of any integer. During one move guys can select some pile with candies and add one candy to it (this can... | {"inputs": ["4\n12 14 30 4", "6\n0 0 0 0 0 0", "6\n120 110 23 34 25 45", "10\n121 56 78 81 45 100 1 0 54 78", "10\n0 675178538 310440616 608075179 0 0 0 0 0 0", "10\n49727640 89440577 0 957792200 0 0 0 0 623726477 0", "20\n4 595258838 0 305922562 0 471450344 1 1 29794053 307197649 0 32960227 1 0 0 1 1 0 0 1", "100\n444... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 36 | codeforces | |
3cb7e99c1a5ccde8a994db6ed8ab3f38 | A Prosperous Lot | Apart from Nian, there is a daemon named Sui, which terrifies children and causes them to become sick. Parents give their children money wrapped in red packets and put them under the pillow, so that when Sui tries to approach them, it will be driven away by the fairies inside.
Big Banban is hesitating over the amount ... | {"inputs": ["2", "6", "3", "4", "5", "1000000", "1", "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", "462", "1317", "88", "87"], "outputs": ["8", "888", "86", "88", "8... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 103 | codeforces | |
3cbd09c654179a180514a5cac06fafc4 | Scissors | Jenya has recently acquired quite a useful tool — *k*-scissors for cutting strings. They are generally used for cutting out two non-intersecting substrings of length *k* from an arbitrary string *s* (its length should be at least 2·*k* in order to perform this operation) and concatenating them afterwards (preserving th... | {"inputs": ["7 4 3\nbaabaab\naaaa", "6 3 2\ncbcbcb\nbcc", "7 5 3\naabbaaa\naaaaa", "16 6 4\nabcdcadbbbcacdca\ndcadbc", "81 5 3\nacbbcccbcbcbbbabaabbbcbacbaabbabaacccaaaaaabbbaacbaabcbcacbbacacbaaaaccbbcacbbcba\ncbbab", "12 3 4\ndbcbabbbdcbb\nbba", "18 3 4\ndcdbdbadddbddbbccc\nbba", "7 3 3\naaabbaa\naaa", "8 3 4\nbcbaaa... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 1 | codeforces | |
3cc5285df504e353dace9de67bd01859 | Mahmoud and Ehab and the xor-MST | Ehab is interested in the bitwise-xor operation and the special graphs. Mahmoud gave him a problem that combines both. He has a complete graph consisting of *n* vertices numbered from 0 to *n*<=-<=1. For all 0<=≤<=*u*<=<<=*v*<=<<=*n*, vertex *u* and vertex *v* are connected with an undirected edge that has weight... | {"inputs": ["4", "10", "2", "1000000000000", "999999999999", "23131234", "100000", "1024", "536870912", "536870911", "536870913", "123456789", "200", "3", "5", "6", "7", "1000", "12000", "65536", "1048576", "8", "549755813888", "549755813887", "549755813889"], "outputs": ["4", "21", "1", "20140978692096", "201409786920... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 9 | codeforces | |
3ccb12ebf4d2df622e19e5477742fdb5 | none | Limak has a grid that consists of 2 rows and *n* columns. The *j*-th cell in the *i*-th row contains an integer *t**i*,<=*j* which can be positive, negative or zero.
A non-empty rectangle of cells is called nice if and only if the sum of numbers in its cells is equal to 0.
Limak wants to choose some nice rectangles a... | {"inputs": ["6\n70 70 70 70 70 -15\n90 -60 -30 30 -30 15", "4\n0 -1 0 0\n0 0 1 0", "3\n1000000000 999999999 -1000000000\n999999999 -1000000000 -999999998", "1\n0\n0", "1\n20\n-20", "2\n-1 0\n0 0", "3\n-2 -1 1\n0 1 0", "5\n-1 -2 2 0 -2\n-1 2 -2 2 2", "10\n0 0 0 0 0 0 0 0 0 0\n0 0 0 0 0 0 0 0 0 0", "10\n2 1 -2 -1 2 2 -2 ... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 1 | codeforces | |
3ce0692ddab193d819e892b99a92e440 | Divisibility by Eight | You are given a non-negative integer *n*, its decimal representation consists of at most 100 digits and doesn't contain leading zeroes.
Your task is to determine if it is possible in this case to remove some of the digits (possibly not remove any digit at all) so that the result contains at least one digit, forms a no... | {"inputs": ["3454", "10", "111111", "8996988892", "5555555555", "1", "8147522776919916277306861346922924221557534659480258977017038624458370459299847590937757625791239188", "8", "14", "2363", "3554", "312", "7674", "126", "344", "976", "3144", "1492", "1000", "303", "1111111111111111111111711111111111111111111111111111... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 72 | codeforces | |
3cf407119513b751bc463ccedd2359a7 | Letter | Vasya decided to write an anonymous letter cutting the letters out of a newspaper heading. He knows heading *s*1 and text *s*2 that he wants to send. Vasya can use every single heading letter no more than once. Vasya doesn't have to cut the spaces out of the heading — he just leaves some blank space to mark them. Help ... | {"inputs": ["Instead of dogging Your footsteps it disappears but you dont notice anything\nwhere is your dog", "Instead of dogging Your footsteps it disappears but you dont notice anything\nYour dog is upstears", "Instead of dogging your footsteps it disappears but you dont notice anything\nYour dog is upstears", "abcd... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 248 | codeforces | |
3cfec1b69fe2adf1d00ee6f434777a8c | Blood Cousins | Polycarpus got hold of a family relationship tree. The tree describes family relationships of *n* people, numbered 1 through *n*. Each person in the tree has no more than one parent.
Let's call person *a* a 1-ancestor of person *b*, if *a* is the parent of *b*.
Let's call person *a* a *k*-ancestor (*k*<=><=1) of p... | {"inputs": ["6\n0 1 1 0 4 4\n7\n1 1\n1 2\n2 1\n2 2\n4 1\n5 1\n6 1", "1\n0\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\n0 1\n20\n2 1\n2 1\n2 1\n2 1\n2 1\n2 1\n1 1\n1 1\n1 1\n2 1\n1 1\n2 1\n2 1\n2 1\n1 1\n2 1\n2 1\n1 1\n1 1\n2 1", "3\n0 0 2\n20\n2 1\n1 1\n1... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 3 | codeforces | |
3cffef1fee59b03bd6899de7b943aa9b | Key races | Two boys decided to compete in text typing on the site "Key races". During the competition, they have to type a text consisting of *s* characters. The first participant types one character in *v*1 milliseconds and has ping *t*1 milliseconds. The second participant types one character in *v*2 milliseconds and has ping *... | {"inputs": ["5 1 2 1 2", "3 3 1 1 1", "4 5 3 1 5", "1000 1000 1000 1000 1000", "1 1 1 1 1", "8 8 1 1 1", "15 14 32 65 28", "894 197 325 232 902", "1 2 8 8 5", "37 261 207 1 1000", "29 344 406 900 1", "1 2 8 9 8", "2 9 8 8 9", "213 480 811 134 745", "2 313 856 964 421", "1 10 2 6 10", "2 7 6 2 3", "637 324 69 612 998", ... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 613 | codeforces | |
3d2a87f340c6112637ca5c250096c894 | Worms | It is lunch time for Mole. His friend, Marmot, prepared him a nice game for lunch.
Marmot brought Mole *n* ordered piles of worms such that *i*-th pile contains *a**i* worms. He labeled all these worms with consecutive integers: worms in first pile are labeled with numbers 1 to *a*1, worms in second pile are labeled w... | {"inputs": ["5\n2 7 3 4 9\n3\n1 25 11"], "outputs": ["1\n5\n3"]} | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 207 | codeforces | |
3d44911c778a334eb3c3c200eb0958dc | Mysterious Present | Peter decided to wish happy birthday to his friend from Australia and send him a card. To make his present more mysterious, he decided to make a chain. Chain here is such a sequence of envelopes *A*<==<={*a*1,<=<=*a*2,<=<=...,<=<=*a**n*}, where the width and the height of the *i*-th envelope is strictly higher than the... | {"inputs": ["2 1 1\n2 2\n2 2", "3 3 3\n5 4\n12 11\n9 8", "5 10 10\n22 23\n17 19\n13 17\n8 12\n2 6", "5 13 13\n4 4\n10 10\n7 7\n1 1\n13 13", "4 12 140\n172 60\n71 95\n125 149\n53 82", "3 500 789\n56 32\n64 42\n74 55", "4 100 100\n332 350\n232 250\n32 50\n132 150", "2 10 10\n15 15\n16 16", "6 1 1\n900000 900000\n902400 9... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 4 | codeforces | |
3d5dfedec0811ef539a5f2b64322feb4 | Restore a Number | Vasya decided to pass a very large integer *n* to Kate. First, he wrote that number as a string, then he appended to the right integer *k* — the number of digits in *n*.
Magically, all the numbers were shuffled in arbitrary order while this note was passed to Kate. The only thing that Vasya remembers, is a non-empty ... | {"inputs": ["003512\n021", "199966633300\n63", "01\n0", "0000454312911\n9213544", "13\n3", "00010454312921\n9213544", "11317110\n01", "1516532320120301262110112013012410838210025280432402042406224604110031740090203024020012\n0126064", "233121122272652143504001162131110307236110231414093112213120271312010423132181004\n0... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 1 | codeforces | |
3d7a918b546bcb1f8edc711f260f83e9 | Numbers | One quite ordinary day Valera went to school (there's nowhere else he should go on a week day). In a maths lesson his favorite teacher Ms. Evans told students about divisors. Despite the fact that Valera loved math, he didn't find this particular topic interesting. Even more, it seemed so boring that he fell asleep in ... | {"inputs": ["1 10 2", "12 23 3", "6 19 5", "1 80 7", "100 1000 1009", "11 124 11", "1000 10000 19", "2020 6300 29", "213 1758 41", "201 522 233", "97 10403 101", "1 340431 3", "3500 100000 1009", "300 300000 5003", "100000 100000 5", "300 700 41", "7000 43000 61", "12 20000000 11", "35000 100000000 50021", "1 20000000 ... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 1 | codeforces | |
3d88853ec11a6f22622d7af3d8efba50 | Pseudorandom Sequence Period | Polycarpus has recently got interested in sequences of pseudorandom numbers. He learned that many programming languages generate such sequences in a similar way: (for *i*<=≥<=1). Here *a*, *b*, *m* are constants, fixed for the given realization of the pseudorandom numbers generator, *r*0 is the so-called *randseed* (t... | {"inputs": ["2 6 12 11", "2 3 5 1", "3 6 81 9", "10 11 12 3", "4 4 5 4", "0 1 6 5", "1 0 7 3", "25 154 200 68", "0 0 1 0", "1 1 100000 0", "73 778 36193 20163", "65 101 43738 16242", "177 329 83469 5951", "452 53 51476 50033", "900 209 34129 21607", "137 936 79151 3907", "687 509 56521 48466", "977 461 14937 9343", "54... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 19 | codeforces | |
3d9e1596deea889723ff8b12ffa03c48 | Spider's Web | Paw the Spider is making a web. Web-making is a real art, Paw has been learning to do it his whole life. Let's consider the structure of the web.
There are *n* main threads going from the center of the web. All main threads are located in one plane and divide it into *n* equal infinite sectors. The sectors are indexed... | {"inputs": ["7\n3 1 6 7\n4 3 5 2 9\n2 8 1\n4 3 7 6 4\n3 2 5 9\n3 6 3 8\n3 4 2 9", "3\n1 1\n1 2\n1 3", "3\n2 1 2\n2 3 4\n2 5 6", "5\n3 2 4 10\n2 1 6\n2 8 7\n3 2 4 10\n2 1 6", "3\n5 2 7 6 9 8\n4 10 1 5 4\n1 3", "4\n5 2 6 10 8 3\n1 7\n2 10 4\n2 9 5", "5\n3 12 10 19\n5 1 4 18 11 13\n4 17 15 2 6\n4 3 12 18 10\n4 2 8 5 9", "... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 3 | codeforces | |
3dab8c5075e0332c36e38519909f1c65 | Japanese Crosswords Strike Back | A one-dimensional Japanese crossword can be represented as a binary string of length *x*. An encoding of this crossword is an array *a* of size *n*, where *n* is the number of segments formed completely of 1's, and *a**i* is the length of *i*-th segment. No two segments touch or intersect.
For example:
- If *x*<==<... | {"inputs": ["2 4\n1 3", "3 10\n3 3 2", "2 10\n1 3", "1 1\n1", "1 10\n10", "1 10000\n10000", "10 1\n5 78 3 87 4 9 5 8 9 1235", "3 12\n3 3 3", "3 9\n2 2 2", "2 5\n1 1", "1 2\n1", "3 13\n3 3 3", "3 6\n1 1 1", "1 6\n5", "3 11\n3 3 2", "2 6\n1 3", "3 10\n2 2 2", "3 8\n2 1 1", "1 5\n2", "1 3\n1", "5 5\n1 1 1 1 1", "2 10\n4 4... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 211 | codeforces | |
3dbee8c53095be15c54fd95fa1d23783 | Lucky Interval | Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.
One day Petya came across an interval of numbers [*a*,<=*a*<=+<=*l*<=-<=1]. Let *F*(*x*) be the numb... | {"inputs": ["7 4", "4 7", "10 10", "47 74", "469 1", "47 74", "100 1", "104 1", "477 7", "777 10", "100 100", "1 1000", "47 9454", "458 10000", "9548 748", "10000 10000", "46999 100000", "548454 845445", "459544 48587874", "1000000000 1000000000", "779999 1000000000", "4699999 1000000000", "9999 107545", "954 71", "974... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 1 | codeforces | |
3dc2dd5bf116a1f0df0313bb38a1a3d8 | Traffic Lights | A car moves from point A to point B at speed *v* meters per second. The action takes place on the X-axis. At the distance *d* meters from A there are traffic lights. Starting from time 0, for the first *g* seconds the green light is on, then for the following *r* seconds the red light is on, then again the green light ... | {"inputs": ["2 1 3 4 5", "5 4 3 1 1", "862 33 604 888 704", "458 251 49 622 472", "772 467 142 356 889", "86 64 587 89 657", "400 333 31 823 74", "714 474 124 205 491", "29 12 569 939 259", "65 24 832 159 171", "2 1 1 1 1", "2 1 1 1 1000", "2 1 1 1000 1", "2 1 1 1000 1000", "2 1 1000 1 1", "2 1 1000 1 1000", "2 1 1000 ... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 53 | codeforces | |
3ddf6953a9633fbc02a19ac2d84f63d3 | Красивая команда | Завтра у хоккейной команды, которой руководит Евгений, важный матч. Евгению нужно выбрать шесть игроков, которые выйдут на лед в стартовом составе: один вратарь, два защитника и три нападающих.
Так как это стартовый состав, Евгения больше волнует, насколько красива будет команда на льду, чем способности игроков. А име... | {"inputs": ["1 2 3\n15\n10 19\n20 11 13", "2 3 4\n16 40\n20 12 19\n13 21 11 10", "4 4 5\n15 16 19 6\n8 11 9 18\n5 3 1 12 14", "6 7 7\n32 35 26 33 16 23\n4 40 36 12 28 24 3\n39 11 31 37 1 25 6", "9 10 7\n935 433 848 137 548 958 758 576 592\n780 129 631 991 575 421 245 944 487 771\n430 34 276 8 165 188 727", "17 15 17\n5... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 21 | codeforces | |
3de5d2ad422d9650f7b7c73ff464e988 | A Simple Task | This task is very simple. Given a string *S* of length *n* and *q* queries each query is on the format *i* *j* *k* which means sort the substring consisting of the characters from *i* to *j* in non-decreasing order if *k*<==<=1 or in non-increasing order if *k*<==<=0.
Output the final string after applying the queries... | {"inputs": ["10 5\nabacdabcda\n7 10 0\n5 8 1\n1 4 0\n3 6 0\n7 10 1", "10 1\nagjucbvdfk\n1 10 1", "10 6\nrmaahmdmuo\n1 3 1\n4 6 0\n5 6 1\n7 8 0\n8 10 0\n8 9 1", "10 5\nhbtngdflmj\n1 10 1\n2 9 0\n3 8 1\n4 7 0\n5 6 1", "13 0\nokaywearedone"], "outputs": ["cbcaaaabdd", "abcdfgjkuv", "amrmahmoud", "bnflhjgmdt", "okaywearedo... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 1 | codeforces | |
3df03802b37da8b768eedaa9b38bc34c | T-decomposition | You've got a undirected tree *s*, consisting of *n* nodes. Your task is to build an optimal T-decomposition for it. Let's define a T-decomposition as follows.
Let's denote the set of all nodes *s* as *v*. Let's consider an undirected tree *t*, whose nodes are some non-empty subsets of *v*, we'll call them *x**i* . The... | {"inputs": ["2\n1 2", "3\n1 2\n2 3", "4\n2 1\n3 1\n4 1", "6\n2 5\n4 3\n4 2\n4 6\n3 1", "6\n3 6\n4 2\n3 4\n3 1\n6 5", "6\n3 2\n6 5\n1 3\n1 4\n6 1", "6\n5 3\n4 2\n5 6\n6 1\n5 4", "5\n1 2\n1 3\n4 5\n4 1", "5\n1 5\n5 3\n2 4\n4 1", "5\n1 5\n5 2\n1 4\n1 3", "4\n1 4\n3 1\n3 2", "20\n19 2\n19 18\n20 9\n20 10\n18 4\n17 5\n17 13... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 1 | codeforces | |
3e0305ad00a8ce7041ada4c908f96a24 | none | Sasha is taking part in a programming competition. In one of the problems she should check if some rooted trees are isomorphic or not. She has never seen this problem before, but, being an experienced participant, she guessed that she should match trees to some sequences and then compare these sequences instead of tree... | {"inputs": ["2\n1 1 1", "2\n1 2 2", "10\n1 1 1 1 1 1 1 1 1 1 1", "10\n1 1 1 1 1 2 1 1 1 1 1", "10\n1 1 1 1 2 2 1 1 1 1 1", "10\n1 1 1 1 1 1 1 2 1 1 2", "10\n1 1 1 3 2 1 2 4 1 3 1", "10\n1 1 1 4 1 1 2 1 5 1 2", "10\n1 1 11 12 12 11 15 13 8 8 8", "10\n1 1 21 1 20 1 14 1 19 1 20", "10\n1 1 93 121 112 103 114 112 112 122 1... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 46 | codeforces | |
3e1d040318b5b2ff2bff5feb4d9fa67a | Lovely Palindromes | Pari has a friend who loves palindrome numbers. A palindrome number is a number that reads the same forward or backward. For example 12321, 100001 and 1 are palindrome numbers, while 112 and 1021 are not.
Pari is trying to love them too, but only very special and gifted people can understand the beauty behind palindro... | {"inputs": ["1", "10", "11", "12", "100", "1321", "2", "3", "4", "5", "6", "7", "8", "9", "13", "14", "15", "16", "17", "18", "19", "20", "26550", "16137", "91471", "41242", "30866", "4442231232741003009964183199713851566466079882929007253443848371978048610682180431295671905105980116", "78065260847320107428504709029792... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 477 | codeforces | |
3e50d65928f72db74df1ec21ab597cd8 | none | Поликарп мечтает стать программистом и фанатеет от степеней двойки. Среди двух чисел ему больше нравится то, которое делится на большую степень числа 2.
По заданной последовательности целых положительных чисел *a*1,<=*a*2,<=...,<=*a**n* требуется найти *r* — максимальную степень числа 2, на которую делится хотя бы од... | {"inputs": ["5\n80 7 16 4 48", "4\n21 5 3 33", "10\n8 112 52 86 93 102 24 24 100 826791168", "3\n458297759 18 104", "7\n12 14 40 8 74 104 11", "11\n35 16 664311776 46 48 52 63 82 84 80 23", "7\n67 68 58 24 96 73 72", "8\n48 112 40 8 112 14 80 36", "10\n14 6 68 8 84 949689614 91 26 80 56", "4\n39 56 939117699 56", "5\n9... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 36 | codeforces | |
3e647b09d39c70908a6b850df8244f27 | none | Welcome to another task about breaking the code lock! Explorers Whitfield and Martin came across an unusual safe, inside of which, according to rumors, there are untold riches, among which one can find the solution of the problem of discrete logarithm!
Of course, there is a code lock is installed on the safe. The lock... | {"inputs": ["6\nabacbb\nbabcba", "3\naba\nbba", "1\nw\nw", "2\nvb\nvb", "7\nvhypflg\nvprhfly", "8\nzyzxzyzw\nzzyzxywz", "8\nvnidcatu\nuiacnvdt", "3\nxhh\nxhh", "4\nwnsc\nnwcs", "5\nutvrb\nvbtru", "8\nvnidcatu\nvnidcatu", "8\nabbabaab\nbaababba", "8\nabaababa\nabaaabab", "49\nssizfrtawiuefcgtrrapgoivdxmmipwvdtqggsczdipn... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 8 | codeforces | |
3e78ba92ef883d1b1e8971722951af9d | Numbers | Furik loves writing all sorts of problems, especially such that he can't solve himself. You've got one of his problems, the one Furik gave to Rubik. And Rubik asks you to solve it.
There is integer *n* and array *a*, consisting of ten integers, indexed by numbers from 0 to 9. Your task is to count the number of positi... | {"inputs": ["1\n0 0 0 0 0 0 0 0 0 1", "2\n1 1 0 0 0 0 0 0 0 0", "3\n1 1 0 0 0 0 0 0 0 0", "4\n0 1 0 1 2 0 0 0 0 0", "5\n2 1 2 0 0 0 0 0 0 0", "6\n1 1 0 1 2 1 0 0 0 0", "7\n0 0 2 2 1 0 1 0 0 0", "8\n1 0 1 0 1 1 2 2 0 0", "9\n1 1 1 2 1 0 0 2 0 1", "10\n2 0 0 1 0 2 0 1 1 0", "100\n10 11 14 16 12 17 10 10 0 0", "100\n0 0 0... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 5 | codeforces | |
3e9a4ebf95b6b8fe90488c34ac94b6b2 | Cardiogram | In this problem, your task is to use ASCII graphics to paint a cardiogram.
A cardiogram is a polyline with the following corners:
That is, a cardiogram is fully defined by a sequence of positive integers *a*1,<=*a*2,<=...,<=*a**n*.
Your task is to paint a cardiogram by given sequence *a**i*.
The first line contains... | {"inputs": ["5\n3 1 2 5 1", "3\n1 5 1", "2\n1 1", "2\n2 1", "2\n1 2", "2\n2 2", "3\n1 1 1", "100\n14 6 10 12 11 12 6 19 12 7 10 17 8 10 10 5 9 6 9 14 15 5 9 11 8 12 14 15 9 9 9 11 13 15 11 10 4 10 8 7 13 11 17 10 14 14 15 8 10 7 12 8 7 15 13 8 7 13 5 11 12 8 9 8 7 16 11 10 10 15 9 11 2 12 12 9 9 13 7 6 9 7 8 7 4 6 15 6... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 13 | codeforces | |
3eba397c78e7876c6f513acead37b714 | The Intriguing Obsession | — This is not playing but duty as allies of justice, Nii-chan!
— Not allies but justice itself, Onii-chan!
With hands joined, go everywhere at a speed faster than our thoughts! This time, the Fire Sisters — Karen and Tsukihi — is heading for somewhere they've never reached — water-surrounded islands!
There are three... | {"inputs": ["1 1 1", "1 2 2", "1 3 5", "6 2 9", "7 3 7", "135 14 39", "5000 5000 5000", "2 1 1", "1 1 3", "1 2 3", "4 1 2", "5 9 4", "4 2 5", "9 4 10", "16 8 29", "17 46 45", "28 47 1", "94 87 10", "84 29 61", "179 856 377", "1925 1009 273", "1171 2989 2853", "3238 2923 4661", "1158 506 4676", "4539 2805 2702", "4756 7... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 31 | codeforces | |
3ec537dbbb4d9020531b843e0d184b4d | Chris and Magic Square | ZS the Coder and Chris the Baboon arrived at the entrance of Udayland. There is a *n*<=×<=*n* magic grid on the entrance which is filled with integers. Chris noticed that exactly one of the cells in the grid is empty, and to enter Udayland, they need to fill a positive integer into the empty cell.
Chris tried filling ... | {"inputs": ["3\n4 0 2\n3 5 7\n8 1 6", "4\n1 1 1 1\n1 1 0 1\n1 1 1 1\n1 1 1 1", "4\n1 1 1 1\n1 1 0 1\n1 1 2 1\n1 1 1 1", "1\n0", "10\n92 67 99 74 1 51 8 58 15 40\n17 42 24 49 0 26 83 33 90 65\n98 73 80 55 7 57 14 64 16 41\n23 48 5 30 82 32 89 39 91 66\n4 54 81 56 88 63 20 70 22 47\n79 29 6 31 13 38 95 45 97 72\n85 60 87... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 10 | codeforces | |
3ee91e91636c5ffb1ea55d1b76d482a0 | Good Sequences | Squirrel Liss is interested in sequences. She also has preferences of integers. She thinks *n* integers *a*1,<=*a*2,<=...,<=*a**n* are good.
Now she is interested in good sequences. A sequence *x*1,<=*x*2,<=...,<=*x**k* is called good if it satisfies the following three conditions:
- The sequence is strictly increas... | {"inputs": ["5\n2 3 4 6 9", "9\n1 2 3 5 6 7 8 9 10", "4\n1 2 4 6", "7\n1 2 3 4 7 9 10", "1\n1", "8\n3 4 5 6 7 8 9 10", "5\n2 3 7 9 10", "3\n1 4 7", "1\n4", "9\n1 2 3 4 5 6 7 9 10", "49\n10 34 58 72 126 166 176 180 198 200 208 228 238 248 302 332 340 344 350 354 380 406 418 428 438 442 482 532 536 544 546 554 596 626 64... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 35 | codeforces | |
3ef2760c88ad3bfbe9fc232ac88a8cf4 | Code For 1 | Jon fought bravely to rescue the wildlings who were attacked by the white-walkers at Hardhome. On his arrival, Sam tells him that he wants to go to Oldtown to train at the Citadel to become a maester, so he can return and take the deceased Aemon's place as maester of Castle Black. Jon agrees to Sam's proposal and Sam s... | {"inputs": ["7 2 5", "10 3 10", "56 18 40", "203 40 124", "903316762502 354723010040 354723105411", "33534354842198 32529564319236 32529564342569", "62518534961045 50734311240112 50734311287877", "95173251245550 106288351347530 106288351372022", "542 321 956", "3621 237 2637", "9056 336 896", "36007 368 24490", "244269... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 67 | codeforces | |
3f39c6661843648becc971efaa0a76e1 | Merge Equal Elements | You are given a sequence of positive integers *a*1,<=*a*2,<=...,<=*a**n*.
While possible, you perform the following operation: find a pair of equal consecutive elements. If there are more than one such pair, find the leftmost (with the smallest indices of elements). If the two integers are equal to *x*, delete both a... | {"inputs": ["6\n5 2 1 1 2 2", "4\n1000000000 1000000000 1000000000 1000000000", "7\n4 10 22 11 12 5 6", "2\n1 1", "3\n2 1 1", "4\n3 2 1 1", "7\n5 5 4 4 5 6 7"], "outputs": ["2\n5 4 ", "1\n1000000002 ", "7\n4 10 22 11 12 5 6 ", "1\n2 ", "1\n3 ", "1\n4 ", "3\n7 6 7 "]} | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 13 | codeforces | |
3fa3ff835903925f73dff6b30ce57d8d | 000001 | The input contains a single integer *a* (1<=≤<=*a*<=≤<=64).
Output a single integer.
The input contains a single integer *a* (1<=≤<=*a*<=≤<=64).
Output a single integer.
Sample Input
2
4
27
42
Sample Output
1
2
5
6
| {"inputs": ["2", "4", "27", "42", "1", "3", "64", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "28", "29", "30", "31", "32", "33", "34", "35", "36", "37", "38", "39", "40", "41", "43", "44", "45", "46", "47", "48", "49", "50", "51", "52",... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 4 | codeforces | |
3fa63a22428f9feb1c46ac8c4c844904 | Bark to Unlock | As technologies develop, manufacturers are making the process of unlocking a phone as user-friendly as possible. To unlock its new phone, Arkady's pet dog Mu-mu has to bark the password once. The phone represents a password as a string of two lowercase English letters.
Mu-mu's enemy Kashtanka wants to unlock Mu-mu's p... | {"inputs": ["ya\n4\nah\noy\nto\nha", "hp\n2\nht\ntp", "ah\n1\nha", "bb\n4\nba\nab\naa\nbb", "bc\n4\nca\nba\nbb\ncc", "ba\n4\ncd\nad\ncc\ncb", "pg\n4\nzl\nxs\ndi\nxn", "bn\n100\ndf\nyb\nze\nml\nyr\nof\nnw\nfm\ndw\nlv\nzr\nhu\nzt\nlw\nld\nmo\nxz\ntp\nmr\nou\nme\npx\nvp\nes\nxi\nnr\nbx\nqc\ngm\njs\nkn\ntw\nrq\nkz\nuc\nvc\... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 237 | codeforces | |
3fa9b04e87068a56cf8b8d30f96c8e17 | Marlin | The city of Fishtopia can be imagined as a grid of $4$ rows and an odd number of columns. It has two main villages; the first is located at the top-left cell $(1,1)$, people who stay there love fishing at the Tuna pond at the bottom-right cell $(4, n)$. The second village is located at $(4, 1)$ and its people love the ... | {"inputs": ["7 2", "5 3", "3 2", "3 0", "49 1", "9 4", "9 5", "99 193", "99 14", "57 15", "99 3", "3 1", "9 9", "67 9", "99 99", "31 32", "5 1", "5 2", "5 4", "5 6", "5 5", "7 9", "7 10", "19 12", "19 3", "37 14", "37 15", "37 37", "37 36", "37 35", "37 34", "37 38", "37 39", "37 40", "5 0", "67 1", "37 19", "77 7", "3... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 51 | codeforces | |
3fc3f99751dce181d2a4d87285222ec8 | Colorful Field | Fox Ciel saw a large field while she was on a bus. The field was a *n*<=×<=*m* rectangle divided into 1<=×<=1 cells. Some cells were wasteland, and other each cell contained crop plants: either carrots or kiwis or grapes.
After seeing the field carefully, Ciel found that the crop plants of each cell were planted in f... | {"inputs": ["4 5 5 6\n4 3\n1 3\n3 3\n2 5\n3 2\n1 3\n1 4\n2 3\n2 4\n1 1\n1 1", "2 3 2 2\n1 1\n2 2\n2 1\n2 2", "31 31 31 4\n4 9\n16 27\n11 29\n8 28\n11 2\n10 7\n22 6\n1 25\n14 8\n9 7\n9 1\n2 3\n5 2\n21 16\n20 19\n23 14\n27 6\n25 21\n14 1\n18 14\n7 2\n19 12\n30 27\n4 27\n24 12\n25 20\n26 22\n21 17\n11 6\n5 28\n28 24\n17 3... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 97 | codeforces | |
3fc90abc9145be915e2ce28bbd6e8bb7 | Towers | As you know, all the kids in Berland love playing with cubes. Little Petya has *n* towers consisting of cubes of the same size. Tower with number *i* consists of *a**i* cubes stacked one on top of the other. Petya defines the instability of a set of towers as a value equal to the difference between the heights of the h... | {"inputs": ["3 2\n5 8 5", "3 4\n2 2 4", "5 3\n8 3 2 6 3", "4 6\n1 10 8 2", "5 3\n2 2 2 2 2", "95 720\n9119 7480 7245 2431 7986 4088 3498 7724 9291 3853 9733 4018 1109 6476 6915 6456 8956 2877 8090 7557 1886 5944 9952 6275 2877 6488 2688 319 4635 8618 2724 7047 3261 8750 971 9114 6552 7749 4356 6059 1495 5713 2625 7230 ... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 4 | codeforces | |
3fd31c857915f9f288689eeab0d1ed96 | Paper Airplanes | To make a paper airplane, one has to use a rectangular piece of paper. From a sheet of standard size you can make $s$ airplanes.
A group of $k$ people decided to make $n$ airplanes each. They are going to buy several packs of paper, each of them containing $p$ sheets, and then distribute the sheets between the people.... | {"inputs": ["5 3 2 3", "5 3 100 1", "10000 10000 1 1", "1 1 10000 10000", "300 300 21 23", "300 2 37 51", "2 400 23 57", "1 1 1 1", "10000 10000 3 2", "1 2 1 2", "1 1 2 2", "1 1 10 10", "5324 5439 32 13", "9000 1 2432 1", "230 1234 9124 23", "11 1 1 1", "6246 8489 1227 9", "9 20 5 7"], "outputs": ["4", "5", "100000000"... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 414 | codeforces | |
3fd6411c52c2bb52d854c5fde1244ac1 | Da Vinci Powers | The input contains a single integer *a* (0<=≤<=*a*<=≤<=35).
Output a single integer.
The input contains a single integer *a* (0<=≤<=*a*<=≤<=35).
Output a single integer.
Sample Input
3
10
Sample Output
8
1024
| {"inputs": ["3", "10", "35", "0", "1", "2", "4", "5", "6", "7", "8", "9", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31", "32", "33", "34"], "outputs": ["8", "1024", "33940307968", "1", "2", "4", "16", "32", "64", "128", "256", "512", "2048",... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 71 | codeforces |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.