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
1462cea6e0234917f31a0424b8da0329
none
Levko has an array that consists of integers: *a*1,<=*a*2,<=... ,<=*a**n*. But he doesn’t like this array at all. Levko thinks that the beauty of the array *a* directly depends on value *c*(*a*), which can be calculated by the formula: It’s time to change the world and Levko is going to change his array for the bett...
{"inputs": ["5 2\n4 7 4 7 4", "3 1\n-100 0 100", "6 3\n1 2 3 7 8 9", "4 1\n-1000000000 -1000000000 1000000000 1000000000", "10 1\n-6 5 -7 -7 -7 -7 5 -9 4 7", "20 17\n-5 -9 11 -7 -17 -8 0 -14 -20 -15 7 -13 0 -3 -14 0 9 -10 6 -19", "5 1\n-1000000000 1000000000 -1000000000 1000000000 -1000000000", "16 13\n441427217 689669...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
1
codeforces
14670758b684ab5678725d0901e35d73
Password
Asterix, Obelix and their temporary buddies Suffix and Prefix has finally found the Harmony temple. However, its doors were firmly locked and even Obelix had no luck opening them. A little later they found a string *s*, carved on a rock below the temple's gates. Asterix supposed that that's the password that opens the...
{"inputs": ["fixprefixsuffix", "abcdabc", "qwertyqwertyqwerty", "papapapap", "aaaaaaaaaa", "ghbdtn", "a", "aa", "ab", "aaa", "aba", "aab", "abb", "abc", "aaabaabaaaaab", "aabaaabaaaaab", "aaabaaaabab", "abcabcabcabcabc", "aaaaabaaaa", "aaaabaaaaaaa", "ghghghgxghghghg", "kincenvizh", "amcksgurlgqzqizdauqminfzshiweejkevb...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
115
codeforces
1470983329ca5e3a2c6705a82cd173d6
List Of Integers
Let's denote as *L*(*x*,<=*p*) an infinite sequence of integers *y* such that *gcd*(*p*,<=*y*)<==<=1 and *y*<=&gt;<=*x* (where *gcd* is the greatest common divisor of two integer numbers), sorted in ascending order. The elements of *L*(*x*,<=*p*) are 1-indexed; for example, 9, 13 and 15 are the first, the second and th...
{"inputs": ["3\n7 22 1\n7 22 2\n7 22 3", "5\n42 42 42\n43 43 43\n44 44 44\n45 45 45\n46 46 46"], "outputs": ["9\n13\n15", "187\n87\n139\n128\n141"]}
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
3
codeforces
1478c482a3296de529bb34c0e7e351e4
Ithea Plays With Chtholly
This is an interactive problem. Refer to the Interaction section below for better understanding. Ithea and Chtholly want to play a game in order to determine who can use the kitchen tonight. Initially, Ithea puts *n* clear sheets of paper in a line. They are numbered from 1 to *n* from left to right. This game wil...
{"inputs": ["2 4 4\n2\n1\n3\n4", "2 2 2\n1\n2", "3 6 3\n1\n2\n1\n3\n1\n3", "4 8 4\n4\n4\n4\n4\n4\n4\n4\n4", "10 120 15\n6\n11\n9\n11\n3\n12\n11\n12\n2\n8\n3\n11\n13\n5\n12\n11\n9\n3\n10\n9\n9\n13\n13\n5\n6\n11\n3\n15\n8\n8\n10\n13\n7\n6\n4\n14\n9\n10\n5\n13\n4\n1\n8\n6\n13\n1\n3\n4\n9\n12\n2\n7\n3\n3\n7\n2\n2\n9\n2\n4\...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
5
codeforces
1488e9b4a9ebd590be12f7ea2251d7c8
Karen and Test
Karen has just arrived at school, and she has a math test today! The test is about basic addition and subtraction. Unfortunately, the teachers were too busy writing tasks for Codeforces rounds, and had no time to make an actual test. So, they just put one question in the test that is worth all the points. There are *...
{"inputs": ["5\n3 6 9 12 15", "4\n3 7 5 2", "1\n1", "16\n985629174 189232688 48695377 692426437 952164554 243460498 173956955 210310239 237322183 96515847 678847559 682240199 498792552 208770488 736004147 176573082", "18\n341796022 486073481 86513380 593942288 60606166 627385348 778725113 896678215 384223198 661124212 ...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
1
codeforces
148e34843e6ea7ff1682255785649209
Dorm Water Supply
The German University in Cairo (GUC) dorm houses are numbered from 1 to *n*. Underground water pipes connect these houses together. Each pipe has certain direction (water can flow only in this direction and not vice versa), and diameter (which characterizes the maximal amount of water it can handle). For each house, t...
{"inputs": ["3 2\n1 2 10\n2 3 20", "3 3\n1 2 20\n2 3 10\n3 1 5", "4 2\n1 2 60\n3 4 50", "10 10\n10 3 70\n1 9 98\n9 10 67\n5 2 78\n8 6 71\n4 8 95\n7 1 10\n2 5 73\n6 7 94\n3 4 23", "7 5\n3 2 26\n4 6 84\n6 3 82\n5 1 57\n1 7 34", "9 6\n7 4 98\n5 9 72\n4 6 10\n2 8 22\n9 7 17\n3 1 66", "8 6\n1 3 84\n8 4 34\n7 2 10\n6 8 8\n3 ...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
15
codeforces
149a65db8891987c69e12b3a698e18d4
Card Game
Digital collectible card games have become very popular recently. So Vova decided to try one of these. Vova has *n* cards in his collection. Each of these cards is characterised by its power *p**i*, magic number *c**i* and level *l**i*. Vova wants to build a deck with total power not less than *k*, but magic numbers m...
{"inputs": ["5 8\n5 5 1\n1 5 4\n4 6 3\n1 12 4\n3 12 1", "3 7\n4 4 1\n5 8 2\n5 3 3", "10 10\n3 3 6\n5 10 4\n4 7 9\n4 9 7\n1 9 4\n1 6 10\n4 10 1\n4 4 6\n2 7 2\n1 5 4", "10 20\n9 4 10\n2 8 9\n9 1 1\n8 10 10\n5 10 2\n1 2 10\n9 6 3\n2 10 5\n7 10 6\n6 3 1", "10 30\n23 83 9\n2 59 6\n10 6 4\n4 92 3\n19 13 6\n28 83 6\n25 58 4\n...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
3
codeforces
14b287b107fd7520ff268970f124a5ce
Search for Pretty Integers
You are given two lists of non-zero digits. Let's call an integer pretty if its (base 10) representation has at least one digit from the first list and at least one digit from the second list. What is the smallest positive pretty integer? The first line contains two integers *n* and *m* (1<=≤<=*n*,<=*m*<=≤<=9) — the l...
{"inputs": ["2 3\n4 2\n5 7 6", "8 8\n1 2 3 4 5 6 7 8\n8 7 6 5 4 3 2 1", "1 1\n9\n1", "9 1\n5 4 2 3 6 1 7 9 8\n9", "5 3\n7 2 5 8 6\n3 1 9", "4 5\n5 2 6 4\n8 9 1 3 7", "5 9\n4 2 1 6 7\n2 3 4 5 6 7 8 9 1", "9 9\n5 4 3 2 1 6 7 8 9\n3 2 1 5 4 7 8 9 6", "9 5\n2 3 4 5 6 7 8 9 1\n4 2 1 6 7", "9 9\n1 2 3 4 5 6 7 8 9\n1 2 3 4 5 ...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
355
codeforces
14c08f41b8f7741fa46a3cff0a623a6c
Multiplication Table
Petya studies positional notations. He has already learned to add and subtract numbers in the systems of notations with different radices and has moved on to a more complicated action — multiplication. To multiply large numbers one has to learn the multiplication table. Unfortunately, in the second grade students learn...
{"inputs": ["10", "3", "2", "4", "5", "6", "7", "8", "9"], "outputs": ["1 2 3 4 5 6 7 8 9 \n2 4 6 8 10 12 14 16 18 \n3 6 9 12 15 18 21 24 27 \n4 8 12 16 20 24 28 32 36 \n5 10 15 20 25 30 35 40 45 \n6 12 18 24 30 36 42 48 54 \n7 14 21 28 35 42 49 56 63 \n8 16 24 32 40 48 56 64 72 \n9 18 27 36 45 54 63 72 81 ", "1 2 \n2 ...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
41
codeforces
14c9740aff6f6fea9c424e0318ca8313
Restoration of string
A substring of some string is called the most frequent, if the number of its occurrences is not less than number of occurrences of any other substring. You are given a set of strings. A string (not necessarily from this set) is called good if all elements of the set are the most frequent substrings of this string. Res...
{"inputs": ["4\nmail\nai\nlru\ncf", "3\nkek\npreceq\ncheburek", "1\nz", "2\nab\nba", "2\nac\nbc", "2\ncd\nce", "2\nca\ncb", "2\ndc\nec", "26\nhw\nwb\nba\nax\nxl\nle\neo\nod\ndj\njt\ntm\nmq\nqf\nfk\nkn\nny\nyz\nzr\nrg\ngv\nvc\ncs\nsi\niu\nup\nph", "25\nsw\nwt\nc\nl\nyo\nag\nz\nof\np\nmz\nnm\nui\nzs\nj\nq\nk\ngd\nb\nen\n...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
8
codeforces
14cb93780999f0be5745dc2133c5dcc5
Ability To Convert
Alexander is learning how to convert numbers from the decimal system to any other, however, he doesn't know English letters, so he writes any number only as a decimal number, it means that instead of the letter *A* he will write the number 10. Thus, by converting the number 475 from decimal to hexadecimal system, he ge...
{"inputs": ["13\n12", "16\n11311", "20\n999", "17\n2016", "1000\n1001", "1000\n1000", "2\n110111100000101101101011001110100111011001000000000000000000", "500\n29460456244280453288", "1000000000\n17289468142098080", "123\n7719", "25\n2172214240", "2\n1110110101111000010001011110101001011001110000000010111010", "3\n12100...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
6
codeforces
1504039ac7ea1dfc39679c660b5763cb
none
You've got string *s*, consisting of only lowercase English letters. Find its lexicographically maximum subsequence. We'll call a non-empty string *s*[*p*1*p*2... *p**k*]<==<=*s**p*1*s**p*2... *s**p**k*(1<=≤<=*p*1<=&lt;<=*p*2<=&lt;<=...<=&lt;<=*p**k*<=≤<=|*s*|) a subsequence of string *s*<==<=*s*1*s*2... *s*|*s*|. St...
{"inputs": ["ababba", "abbcbccacbbcbaaba", "thankstosamarasauteddybearsforthiscontest", "cantouristsolveitlessthaninoneminute", "arepretestsstrongforthisproblem", "whyareyoulookingfortestsdoyouhavewa", "aa", "zz", "a", "z", "b", "y", "zaz", "aza", "dcbaedcba", "abcdeabcd", "abcdedcba", "zyxzxzwyxywxxwabcdabdacdbcacdbca...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
51
codeforces
1505530295dbd2d4bc8823b29ba39a2d
Little Elephant and Function
The Little Elephant enjoys recursive functions. This time he enjoys the sorting function. Let *a* is a permutation of an integers from 1 to *n*, inclusive, and *a**i* denotes the *i*-th element of the permutation. The Little Elephant's recursive function *f*(*x*), that sorts the first *x* permutation's elements, works...
{"inputs": ["1", "2", "3", "4", "5", "6", "7", "1000", "999", "998", "997", "900", "101", "3", "67", "779", "195", "907", "971", "683", "99", "811", "875", "291", "3", "419", "779", "195", "907", "21", "22", "23", "24", "25"], "outputs": ["1 ", "2 1 ", "3 1 2 ", "4 1 2 3 ", "5 1 2 3 4 ", "6 1 2 3 4 5 ", "7 1 2 3 4 5 6 ...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
304
codeforces
150b646344f8eb91459c57d85944dfc9
PolandBall and Game
PolandBall is playing a game with EnemyBall. The rules are simple. Players have to say words in turns. You cannot say a word which was already said. PolandBall starts. The Ball which can't say a new word loses. You're given two lists of words familiar to PolandBall and EnemyBall. Can you determine who wins the game, i...
{"inputs": ["5 1\npolandball\nis\na\ncool\ncharacter\nnope", "2 2\nkremowka\nwadowicka\nkremowka\nwiedenska", "1 2\na\na\nb", "2 2\na\nb\nb\nc", "2 1\nc\na\na", "3 3\nab\nbc\ncd\ncd\ndf\nfg", "3 3\nc\na\nb\na\nd\ng", "1 1\naa\naa", "2 1\na\nb\na", "6 5\na\nb\nc\nd\ne\nf\nf\ne\nd\nz\ny", "3 2\na\nb\nc\nd\ne"], "outputs"...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
131
codeforces
151f68a26da83524d8b82f40c7e8092c
Group Photo 2 (online mirror version)
Many years have passed, and *n* friends met at a party again. Technologies have leaped forward since the last meeting, cameras with timer appeared and now it is not obligatory for one of the friends to stand with a camera, and, thus, being absent on the photo. Simply speaking, the process of photographing can be descr...
{"inputs": ["3\n10 1\n20 2\n30 3", "3\n3 1\n2 2\n4 3", "1\n5 10", "1\n1 1", "1\n1000 1000", "1\n1 1000", "2\n1 1000\n1000 1", "2\n1 1\n1000 1000", "1\n1000 1", "5\n407 830\n12 199\n768 215\n668 28\n628 310", "3\n379 820\n923 407\n916 853", "3\n99 768\n477 885\n169 118", "3\n227 612\n223 259\n423 895", "3\n651 161\n480 ...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
2
codeforces
1542f4a09d6ddea98267a3b58425bbd5
Robot Rapping Results Report
While Farmer John rebuilds his farm in an unfamiliar portion of Bovinia, Bessie is out trying some alternative jobs. In her new gig as a reporter, Bessie needs to know about programming competition results as quickly as possible. When she covers the 2016 Robot Rap Battle Tournament, she notices that all of the robots o...
{"inputs": ["4 5\n2 1\n1 3\n2 3\n4 2\n4 3", "3 2\n1 2\n3 2", "2 1\n1 2", "2 1\n2 1", "5 10\n1 2\n1 3\n1 4\n1 5\n2 3\n2 4\n2 5\n3 4\n3 5\n4 5", "3 3\n2 1\n3 1\n3 2", "4 6\n1 4\n4 2\n2 3\n1 2\n1 3\n4 3", "3 3\n3 1\n3 2\n1 2", "5 10\n2 1\n1 4\n2 5\n2 3\n5 4\n3 4\n3 1\n3 5\n2 4\n1 5", "3 3\n1 2\n3 2\n1 3", "3 3\n2 3\n1 3\n...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
6
codeforces
1559308881797ee2f5f8be601e158dd4
Polycarp's phone book
There are *n* phone numbers in Polycarp's contacts on his phone. Each number is a 9-digit integer, starting with a digit different from 0. All the numbers are distinct. There is the latest version of Berdroid OS installed on Polycarp's phone. If some number is entered, is shows up all the numbers in the contacts for w...
{"inputs": ["3\n123456789\n100000000\n100123456", "4\n123456789\n193456789\n134567819\n934567891", "1\n167038488", "5\n115830748\n403459907\n556271610\n430358099\n413961410", "5\n139127034\n452751056\n193432721\n894001929\n426470953", "5\n343216531\n914073407\n420246472\n855857272\n801664978", "5\n567323818\n353474649\...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
24
codeforces
156d2508c063ef36fdc1332ed8ab8e1e
Iterated Linear Function
Consider a linear function *f*(*x*)<==<=*Ax*<=+<=*B*. Let's define *g*(0)(*x*)<==<=*x* and *g*(*n*)(*x*)<==<=*f*(*g*(*n*<=-<=1)(*x*)) for *n*<=&gt;<=0. For the given integer values *A*, *B*, *n* and *x* find the value of *g*(*n*)(*x*) modulo 109<=+<=7. The only line contains four integers *A*, *B*, *n* and *x* (1<=≤<=*...
{"inputs": ["3 4 1 1", "3 4 2 1", "3 4 3 1", "1 1 1 1", "3 10 723 6", "14 81 51 82", "826504481 101791432 76 486624528", "475965351 844435993 96338 972382431", "528774798 650132512 6406119 36569714", "632656975 851906850 1 310973933", "1 1 352875518515340737 1", "978837295 606974665 846646545585165081 745145208", "2776...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
35
codeforces
157a3165ac77cae8dc1878f04883493a
Jeopardy!
'Jeopardy!' is an intellectual game where players answer questions and earn points. Company Q conducts a simplified 'Jeopardy!' tournament among the best IT companies. By a lucky coincidence, the old rivals made it to the finals: company R1 and company R2. The finals will have *n* questions, *m* of them are auction q...
{"inputs": ["4 1\n1 3 7 5\n3", "3 2\n10 3 8\n2 3", "2 2\n100 200\n1 2", "1 1\n1\n1", "2 2\n1 5\n1 2", "5 3\n5 8 7 1 9\n2 5 3", "5 5\n9 1 6 2 1\n3 1 4 5 2", "25 5\n66 41 91 33 86 67 38 79 49 7 77 54 29 19 22 48 63 37 11 100 8 6 47 27 26\n12 14 1 23 18", "50 10\n19098 20847 65754 94580 54808 57092 23130 15638 43645 52323...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
28
codeforces
158444ebd70a822da08f95e3843ab7e3
Wizards and Demonstration
Some country is populated by wizards. They want to organize a demonstration. There are *n* people living in the city, *x* of them are the wizards who will surely go to the demonstration. Other city people (*n*<=-<=*x* people) do not support the wizards and aren't going to go to the demonstration. We know that the city...
{"inputs": ["10 1 14", "20 10 50", "1000 352 146", "68 65 20", "78 28 27", "78 73 58", "70 38 66", "54 4 38", "3 1 69", "11 9 60", "71 49 65", "78 55 96", "2765 768 9020", "3478 1728 9727", "9678 6173 5658", "1138 570 6666", "7754 204 9038", "8403 7401 4769", "4909 2111 8860", "6571 6449 8965", "9178 2255 7996", "6151 ...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
305
codeforces
158ed5933ad363941eb78811545a4c1f
A Vital Problem
Polycarp has a strict daily schedule. He has *n* alarms set for each day, and the *i*-th alarm rings each day at the same time during exactly one minute. Determine the longest time segment when Polycarp can sleep, i. e. no alarm rings in that period. It is possible that Polycarp begins to sleep in one day, and wakes u...
{"inputs": ["1\n05:43", "4\n22:00\n03:21\n16:03\n09:59", "20\n23:59\n00:00\n00:01\n00:02\n00:03\n00:04\n00:05\n00:06\n00:07\n00:08\n00:09\n00:10\n00:11\n00:12\n00:13\n00:14\n00:15\n00:16\n00:17\n00:18", "21\n23:28\n23:29\n23:30\n23:31\n23:32\n23:33\n23:34\n23:35\n23:36\n23:37\n23:38\n23:39\n23:40\n23:41\n23:42\n23:43\n...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
43
codeforces
1591a073be244b2dc292fed6a4ee16c2
Inna and Huge Candy Matrix
Inna and Dima decided to surprise Sereja. They brought a really huge candy matrix, it's big even for Sereja! Let's number the rows of the giant matrix from 1 to *n* from top to bottom and the columns — from 1 to *m*, from left to right. We'll represent the cell on the intersection of the *i*-th row and *j*-th column as...
{"inputs": ["3 3 3 1 1 9\n1 1\n1 2\n1 3\n2 1\n2 2\n2 3\n3 1\n3 2\n3 3", "5 5 0 0 0 1\n1 4", "14 76 376219315 550904689 16684615 24\n11 21\n1 65\n5 25\n14 63\n11 30\n1 19\n5 7\n9 51\n2 49\n13 75\n9 9\n3 63\n8 49\n5 1\n1 67\n13 31\n9 35\n3 53\n13 73\n5 71\n1 32\n5 49\n1 41\n14 69", "63 67 18046757 61758841 85367218 68\n2...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
12
codeforces
15dc09ce785b1080b799acedace9411c
Okabe and Banana Trees
Okabe needs bananas for one of his experiments for some strange reason. So he decides to go to the forest and cut banana trees. Consider the point (*x*,<=*y*) in the 2D plane such that *x* and *y* are integers and 0<=≤<=*x*,<=*y*. There is a tree in such a point, and it has *x*<=+<=*y* bananas. There are no trees nor ...
{"inputs": ["1 5", "2 3", "4 6", "6 3", "1 1", "10 1", "20 10", "1000 10000", "139 9252", "859 8096", "987 4237", "411 3081", "539 9221", "259 770", "387 5422", "515 1563", "939 407", "518 6518", "646 1171", "70 7311", "494 6155", "918 7704", "46 3844", "174 2688", "894 4637", "22 3481", "446 5030", "440 8704", "569 75...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
72
codeforces
15e263e85246dfd3aa917ff242354b00
Alyona and Spreadsheet
During the lesson small girl Alyona works with one famous spreadsheet computer program and learns how to edit tables. Now she has a table filled with integers. The table consists of *n* rows and *m* columns. By *a**i*,<=*j* we will denote the integer located at the *i*-th row and the *j*-th column. We say that the tab...
{"inputs": ["5 4\n1 2 3 5\n3 1 3 2\n4 5 2 3\n5 5 3 2\n4 4 3 4\n6\n1 1\n2 5\n4 5\n3 5\n1 3\n1 5", "1 1\n1\n1\n1 1", "10 1\n523130301\n127101624\n15573616\n703140639\n628818570\n957494759\n161270109\n386865653\n67832626\n53360557\n17\n4 5\n4 7\n8 8\n9 9\n3 9\n8 10\n8 9\n7 9\n4 5\n2 9\n4 6\n2 4\n2 6\n4 6\n7 9\n2 4\n8 10",...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
20
codeforces
15f8e73bc9b0d7eb1a626278b62f9905
Bathroom terminal
Smith wakes up at the side of a dirty, disused bathroom, his ankle chained to pipes. Next to him is tape-player with a hand-written message "Play Me". He finds a tape in his own back pocket. After putting the tape in the tape-player, he sees a key hanging from a ceiling, chained to some kind of a machine, which is conn...
{"inputs": ["3 1\nabc\naec\nac\na?c", "22 2\naaaab\naaabb\naabab\naabbb\nabaab\nababb\nabbab\nabbbb\naaab\naabb\nabab\nabbb\naab\nabb\nab\ncccd\nccdd\ncdcd\ncddd\nccd\ncdd\ncd\na???b\nc??d", "15 6\naaa\naaabbb\naaabb\naaaaa\naaaaaa\naaaa\naaabbbb\naaaaa\naaaaaa\naaaa\naaabbbb\naabbbb\naa\naa\naab\na\n?a?\n??\n?aa?bb?\n...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
1
codeforces
160baf248c6c33b69df49066de5ff338
Inna and Alarm Clock
Inna loves sleeping very much, so she needs *n* alarm clocks in total to wake up. Let's suppose that Inna's room is a 100<=×<=100 square with the lower left corner at point (0,<=0) and with the upper right corner at point (100,<=100). Then the alarm clocks are points with integer coordinates in this square. The mornin...
{"inputs": ["4\n0 0\n0 1\n0 2\n1 0", "4\n0 0\n0 1\n1 0\n1 1", "4\n1 1\n1 2\n2 3\n3 3", "1\n0 0", "42\n28 87\n26 16\n59 90\n47 61\n28 83\n36 30\n67 10\n6 95\n9 49\n86 94\n52 24\n74 9\n86 24\n28 51\n25 99\n40 98\n57 33\n18 96\n43 36\n3 79\n4 86\n38 61\n25 61\n6 100\n58 81\n28 19\n64 4\n3 40\n2 56\n41 49\n97 100\n86 34\n4...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
165
codeforces
162e217540a33d9eb197e241489b3c61
Alice, Bob and Chocolate
Alice and Bob like games. And now they are ready to start a new game. They have placed *n* chocolate bars in a line. Alice starts to eat chocolate bars one by one from left to right, and Bob — from right to left. For each chocololate bar the time, needed for the player to consume it, is known (Alice and Bob eat them wi...
{"inputs": ["5\n2 9 8 2 7", "1\n1", "2\n1 1", "3\n1 1 1", "4\n1 1 1 1", "1\n6", "2\n8 2", "3\n6 8 4", "4\n4 3 2 8", "5\n1 9 8 2 7", "6\n1 4 7 3 2 1", "11\n7 9 1 8 7 1 7 1 4 8 1", "12\n4 2 7 1 9 5 6 2 7 8 5 7", "13\n9 9 9 9 9 9 9 9 9 9 9 9 9"], "outputs": ["2 3", "1 0", "1 1", "2 1", "2 2", "1 0", "1 1", "1 2", "3 1", "...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
138
codeforces
16344fb7e2bc83409f14ef3f666a983c
King's Problem?
Every true king during his life must conquer the world, hold the Codeforces world finals, win pink panda in the shooting gallery and travel all over his kingdom. King Copa has already done the first three things. Now he just needs to travel all over the kingdom. The kingdom is an infinite plane with Cartesian coordina...
{"inputs": ["3 1\n0 1 2 1\n1", "3 1\n1 0 2 1\n1", "4 5\n0 5 -1 -5 2\n3", "4 1\n0 5 -1 -5 2\n3", "10 5\n-231 598 312 -837 -711 553 -439 351 83 -605 -738\n791", "100 31\n-577 101 691 -95 809 125 -934 -645 -838 -548 259 312 -501 -962 -629 -637 -797 -259 -258 -687 537 303 -6 431 64 229 -897 -942 -805 804 -608 84 992 -563 2...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
3
codeforces
1655768ab04bba468899388061617449
Cowboys
A very tense moment: *n* cowboys stand in a circle and each one points his colt at a neighbor. Each cowboy can point the colt to the person who follows or precedes him in clockwise direction. Human life is worthless, just like in any real western. The picture changes each second! Every second the cowboys analyse the s...
{"inputs": ["BABBBABBA", "ABABB", "ABABAB", "ABA", "AABB", "ABABBABBAABAB", "AAABAABABA", "ABABABABABABABABABAB", "BABABABABAAAABABAAAABAB", "ABABABBABA", "BBB", "AAAA", "ABBAB", "BBBABB", "BABBBBB", "ABABBAAB", "ABBBABBAB", "BAAABBBBBA", "AAAAAAAAAAA", "BABBAAAABAAA", "ABABBBABBBAAA", "BBBBBABBBBBABB", "AAAAAAAABAAAAA...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
1
codeforces
166c3a794830622ff41a4fd1297a07d0
System Administrator
Polycarpus is a system administrator. There are two servers under his strict guidance — *a* and *b*. To stay informed about the servers' performance, Polycarpus executes commands "ping a" and "ping b". Each ping command sends exactly ten packets to the server specified in the argument of the command. Executing a progra...
{"inputs": ["2\n1 5 5\n2 6 4", "3\n1 0 10\n2 0 10\n1 10 0", "10\n1 3 7\n2 4 6\n1 2 8\n2 5 5\n2 10 0\n2 10 0\n1 8 2\n2 2 8\n2 10 0\n1 1 9", "11\n1 8 2\n1 6 4\n1 9 1\n1 7 3\n2 0 10\n2 0 10\n1 8 2\n2 2 8\n2 6 4\n2 7 3\n2 9 1", "12\n1 5 5\n1 0 10\n1 4 6\n1 2 8\n1 2 8\n1 5 5\n1 9 1\n2 9 1\n1 5 5\n1 1 9\n2 9 1\n2 7 3", "13\n...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
300
codeforces
167db4a35cf6f51b76cf83f7e8c141cf
Brain's Photos
Small, but very brave, mouse Brain was not accepted to summer school of young villains. He was upset and decided to postpone his plans of taking over the world, but to become a photographer instead. As you may know, the coolest photos are on the film (because you can specify the hashtag #film for such). Brain took a ...
{"inputs": ["2 2\nC M\nY Y", "3 2\nW W\nW W\nB B", "1 1\nW", "2 3\nW W W\nB G Y", "1 1\nW", "5 5\nW G B Y M\nG B Y M C\nB Y M C W\nY M C W G\nM C W G B", "1 6\nC M Y W G B", "1 3\nW G B", "1 1\nW", "5 5\nW G B W G\nG B W G B\nB W G B W\nW G B W G\nG B W G B", "2 3\nW W W\nB G C", "2 3\nW W W\nB G M", "3 3\nC B W\nB Y M...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
531
codeforces
16830fb49b20765e78781cea4be2a97f
The Contest
Pasha is participating in a contest on one well-known website. This time he wants to win the contest and will do anything to get to the first place! This contest consists of *n* problems, and Pasha solves *i*th problem in *a**i* time units (his solutions are always correct). At any moment of time he can be thinking ab...
{"inputs": ["2\n3 4\n2\n1 4\n7 9", "1\n5\n1\n1 4", "1\n5\n1\n1 5", "5\n100000 100000 100000 100000 100000\n0", "5\n886 524 128 4068 298\n3\n416 3755\n4496 11945\n17198 18039", "10\n575 3526 1144 1161 889 1038 790 19 765 357\n2\n4475 10787\n16364 21678", "1\n4\n1\n5 9", "1\n200\n4\n1 10\n20 40\n50 55\n190 210", "4\n643 ...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
85
codeforces
168f6f1983f3160ebd9573e0d6a26d69
Display Size
A big company decided to launch a new series of rectangular displays, and decided that the display must have exactly *n* pixels. Your task is to determine the size of the rectangular display — the number of lines (rows) of pixels *a* and the number of columns of pixels *b*, so that: - there are exactly *n* pixels o...
{"inputs": ["8", "64", "5", "999999", "716539", "1", "2", "3", "4", "6", "7", "9", "10", "11", "12", "15", "100", "101", "169", "179", "190", "1000", "10000", "10001", "100000", "100001", "1000000", "999983", "524288", "954493", "966289", "944663", "912673", "732641", "232897", "16807", "999958", "990151", "997002", "2...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
236
codeforces
16a03da19a666d6d16782abb48417091
Division into Teams
Petya loves football very much, especially when his parents aren't home. Each morning he comes to the yard, gathers his friends and they play all day. From time to time they have a break to have some food or do some chores (for example, water the flowers). The key in football is to divide into teams fairly before the ...
{"inputs": ["3\n1 2 1", "5\n2 3 3 1 1", "10\n2 2 2 2 2 2 2 1 2 2", "10\n2 3 3 1 3 1 1 1 2 2", "10\n2 3 2 3 3 1 1 3 1 1", "11\n1 3 1 2 1 2 2 2 1 1 1", "11\n54 83 96 75 33 27 36 35 26 22 77", "11\n1 1 1 1 1 1 1 1 1 1 1", "2\n1 1", "2\n35 36", "25\n1 2 2 1 2 2 2 2 2 1 1 2 2 2 2 2 1 2 2 2 1 1 2 2 1", "27\n2 1 1 3 1 2 1 1 3...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
13
codeforces
16ccd5806786645d788c5a6d9bc85b1e
Little Elephant and Problem
The Little Elephant has got a problem — somebody has been touching his sorted by non-decreasing array *a* of length *n* and possibly swapped some elements of the array. The Little Elephant doesn't want to call the police until he understands if he could have accidentally changed the array himself. He thinks that he co...
{"inputs": ["2\n1 2", "3\n3 2 1", "4\n4 3 2 1", "3\n1 3 2", "2\n2 1", "9\n7 7 8 8 10 10 10 10 1000000000", "10\n1 2 9 4 5 6 7 8 3 10", "4\n2 2 2 1", "10\n1 2 4 4 4 5 5 7 7 10", "10\n4 5 11 12 13 14 16 16 16 18", "20\n38205814 119727790 127848638 189351562 742927936 284688399 318826601 326499046 387938139 395996609 4944...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
183
codeforces
16e2a8ba7b90c835d233f81974a1987e
A and B and Interesting Substrings
A and B are preparing themselves for programming contests. After several years of doing sports programming and solving many problems that require calculating all sorts of abstract objects, A and B also developed rather peculiar tastes. A likes lowercase letters of the Latin alphabet. He has assigned to each letter a ...
{"inputs": ["1 1 -1 1 1 1 1 1 1 1 1 1 1 1 1 7 1 1 1 8 1 1 1 1 1 1\nxabcab", "1 1 -1 1 1 1 1 1 1 1 1 1 1 1 1 7 1 1 1 8 1 1 1 1 1 1\naaa", "1 1 -1 1 1 1 1 1 1 1 1 1 1 1 1 7 1 1 1 8 1 1 1 1 1 1\naabbccdd", "-3 4 -4 -1 3 5 -5 -3 3 2 1 4 5 -3 -1 4 2 -2 1 -1 1 5 -4 0 -5 4\nolspxykjqr", "-2 -2 2 1 4 0 -2 4 5 4 -5 -5 2 1 1 -1 ...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
19
codeforces
16ea217382917bb89accb42f3a9c6795
Flag
According to a new ISO standard, a flag of every country should have a chequered field *n*<=×<=*m*, each square should be of one of 10 colours, and the flag should be «striped»: each horizontal row of the flag should contain squares of the same colour, and the colours of adjacent horizontal rows should be different. Be...
{"inputs": ["3 3\n000\n111\n222", "3 3\n000\n000\n111", "3 3\n000\n111\n002", "10 10\n2222222222\n5555555555\n0000000000\n4444444444\n1111111111\n3333333393\n3333333333\n5555555555\n0000000000\n8888888888", "10 13\n4442444444444\n8888888888888\n6666666666666\n0000000000000\n3333333333333\n4444444444444\n7777777777777\n...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
284
codeforces
16ecf492d63595584a0ea1707994c224
Lala Land and Apple Trees
Amr lives in Lala Land. Lala Land is a very beautiful country that is located on a coordinate line. Lala Land is famous with its apple trees growing everywhere. Lala Land has exactly *n* apple trees. Tree number *i* is located in a position *x**i* and has *a**i* apples growing on it. Amr wants to collect apples from t...
{"inputs": ["2\n-1 5\n1 5", "3\n-2 2\n1 4\n-1 3", "3\n1 9\n3 5\n7 10", "1\n1 1", "4\n10000 100000\n-1000 100000\n-2 100000\n-1 100000", "1\n-1 1", "27\n-30721 24576\n-6620 92252\n88986 24715\n-94356 10509\n-6543 29234\n-68554 69530\n39176 96911\n67266 99669\n95905 51002\n-94093 92134\n65382 23947\n-6525 79426\n-448 675...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
152
codeforces
172d355f207b1c6d888955b4a88727e9
Mahmoud and Longest Uncommon Subsequence
While Mahmoud and Ehab were practicing for IOI, they found a problem which name was Longest common subsequence. They solved it, and then Ehab challenged Mahmoud with another problem. Given two strings *a* and *b*, find the length of their longest uncommon subsequence, which is the longest string that is a subsequence ...
{"inputs": ["abcd\ndefgh", "a\na", "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaacccccccccccccccccccccccccccccccccccccccccccccccccc\naaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaadddddddddddddddddddddddddddddddddddddddddddddddddd", "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
184
codeforces
175a9fbb6934af1423c16e2e891e9830
Pashmak and Buses
Recently Pashmak has been employed in a transportation company. The company has *k* buses and has a contract with a school which has *n* students. The school planned to take the students to *d* different places for *d* days (each day in one place). Each day the company provides all the buses for the trip. Pashmak has t...
{"inputs": ["3 2 2", "3 2 1", "7 2 3", "9 2 3", "2 1 1000", "512 2 9", "1000 1000000000 511", "1000 1000 1", "1000 3 1000", "1 1000000000 512", "1000 2 1000", "1000 3 1000", "1000 31 1000", "1000 32 1000", "1000 999 1000", "1000 1000 1000", "1000 536870912 1000", "1000 536870911 1000", "1000 1000000000 1000", "1000 2 8...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
7
codeforces
1781dd23263cc5f4456420d34bd9eaa4
Pashmak and Parmida's problem
Parmida is a clever girl and she wants to participate in Olympiads this year. Of course she wants her partner to be clever too (although he's not)! Parmida has prepared the following test problem for Pashmak. There is a sequence *a* that consists of *n* integers *a*1,<=*a*2,<=...,<=*a**n*. Let's denote *f*(*l*,<=*r*,<...
{"inputs": ["7\n1 2 1 1 2 2 1", "3\n1 1 1", "5\n1 2 3 4 5", "24\n1 2 3 4 1 2 3 4 1 2 3 4 1 2 3 4 1 2 3 4 1 2 3 4", "1\n1", "2\n1 2", "2\n1 1", "4\n1 1 2 2", "5\n1 1 2 2 2"], "outputs": ["8", "1", "0", "114", "0", "0", "0", "1", "2"]}
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
14
codeforces
17d85a2526ca819f521a1a67dba02824
Restore Cube
Peter had a cube with non-zero length of a side. He put the cube into three-dimensional space in such a way that its vertices lay at integer points (it is possible that the cube's sides are not parallel to the coordinate axes). Then he took a piece of paper and wrote down eight lines, each containing three integers — c...
{"inputs": ["0 0 0\n0 0 1\n0 0 1\n0 0 1\n0 1 1\n0 1 1\n0 1 1\n1 1 1", "0 0 0\n0 0 0\n0 0 0\n0 0 0\n1 1 1\n1 1 1\n1 1 1\n1 1 1", "0 0 0\n1 0 0\n0 1 0\n1 1 0\n0 0 1\n1 0 1\n0 1 1\n1 1 1", "6 -2 -2\n-5 1 -6\n6 -6 7\n6 3 4\n9 -7 8\n-9 -2 -6\n-9 1 6\n-9 -1 0", "-5 -3 -8\n-8 8 -5\n-3 3 6\n6 3 8\n-8 6 -3\n8 -8 6\n-3 -5 3\n-5 ...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
2
codeforces
17ec4d515c12743261193390f42cb456
Mr. Bender and Square
Mr. Bender has a digital table of size *n*<=×<=*n*, each cell can be switched on or off. He wants the field to have at least *c* switched on squares. When this condition is fulfilled, Mr Bender will be happy. We'll consider the table rows numbered from top to bottom from 1 to *n*, and the columns — numbered from left ...
{"inputs": ["6 4 3 1", "9 3 8 10", "9 4 3 10", "9 8 2 10", "1 1 1 1", "10 7 2 7", "8 2 6 10", "8 1 2 10", "6 1 4 10", "1000000 951981 612086 60277", "1000000 587964 232616 62357", "1000000 948438 69861 89178", "1000000000 504951981 646612086 602763371", "1000000000 81587964 595232616 623563697", "1000000000 55 60 71518...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
7
codeforces
17ff19eef74317819cc833b0e6176d2b
Heidi and Library (hard)
The good times at Heidi's library are over. Marmots finally got their internet connections and stopped coming to the library altogether. Not only that, but the bookstore has begun charging extortionate prices for some books. Namely, whereas in the previous versions each book could be bought for 1 CHF, now the price of ...
{"inputs": ["4 80\n1 2 2 1\n1 1 1 1", "4 1\n1 2 2 1\n1 1 1 1", "4 2\n1 2 3 1\n1 1 1 1", "7 2\n1 2 3 1 1 1 2\n1 10 1 0 0 0 0", "11 1\n1 2 3 5 1 10 10 1 1 3 5\n1 1 2 3 4 5 6 7 8 9 10", "5 2\n1 2 3 1 2\n1 1 1 1 1", "4 2\n1 2 3 2\n1 1 1 1", "80 4\n2 6 10 4 7 8 2 8 9 10 6 2 5 3 2 10 5 9 1 3 4 8 6 1 9 3 9 4 7 7 4 6 4 8 1 2 5...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
1
codeforces
183d5529b0961a41597819ab12cd61be
Voltage Keepsake
You have *n* devices that you want to use simultaneously. The *i*-th device uses *a**i* units of power per second. This usage is continuous. That is, in λ seconds, the device will use λ·*a**i* units of power. The *i*-th device currently has *b**i* units of power stored. All devices can store an arbitrary amount of pow...
{"inputs": ["2 1\n2 2\n2 1000", "1 100\n1 1", "3 5\n4 3\n5 2\n6 1", "1 1\n1 87", "1 1\n100 77", "5 10\n3 81\n3 49\n1 20\n1 12\n1 30", "5 10\n4 3\n1 54\n2 57\n2 31\n1 99", "5 10\n2 81\n3 31\n4 49\n1 35\n1 67", "10 1\n1 92\n1 92\n1 92\n1 92\n1 92\n1 92\n1 92\n1 92\n1 92\n1 92", "10 1\n1 16\n1 16\n1 16\n1 16\n1 16\n1 16\n...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
22
codeforces
18570e5f148ba4dbe6c04aea7fe63509
Combination Lock
Scrooge McDuck keeps his most treasured savings in a home safe with a combination lock. Each time he wants to put there the treasures that he's earned fair and square, he has to open the lock. The combination lock is represented by *n* rotating disks with digits from 0 to 9 written on them. Scrooge McDuck has to turn ...
{"inputs": ["5\n82195\n64723", "12\n102021090898\n010212908089", "1\n8\n1", "2\n83\n57", "10\n0728592530\n1362615763", "100\n4176196363694273682807653052945037727131821799902563705176501742060696655282954944720643131654235909\n345991208492215450591028749987997565929823937151988986658547267442300883787812306710300534498...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
899
codeforces
18574ec81ce029d7932890bfd5465160
Restoration of the Permutation
Let *A*<==<={*a*1,<=*a*2,<=...,<=*a**n*} be any permutation of the first *n* natural numbers {1,<=2,<=...,<=*n*}. You are given a positive integer *k* and another sequence *B*<==<={*b*1,<=*b*2,<=...,<=*b**n*}, where *b**i* is the number of elements *a**j* in *A* to the left of the element *a**t*<==<=*i* such that *a**j...
{"inputs": ["5 2\n1 2 1 0 0", "4 2\n1 0 0 0", "10 3\n4 2 4 2 1 0 1 0 0 0", "15 3\n4 2 7 5 1 1 1 0 0 0 0 0 0 0 0", "5 1\n1 3 2 0 0", "8 3\n2 0 2 2 1 0 0 0", "1 1\n0", "10 10\n0 0 0 0 0 0 0 0 0 0", "10 9\n1 0 0 0 0 0 0 0 0 0", "10 1\n9 8 7 6 5 4 3 2 1 0", "10 1\n7 6 5 4 3 2 1 0 0 0", "13 2\n1 2 3 4 5 4 3 2 1 0 0 0 0", "2...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
6
codeforces
1863b6f28ad0474a2c0dc6ef0e81a030
Megacity
The administration of the Tomsk Region firmly believes that it's time to become a megacity (that is, get population of one million). Instead of improving the demographic situation, they decided to achieve its goal by expanding the boundaries of the city. The city of Tomsk can be represented as point on the plane with ...
{"inputs": ["4 999998\n1 1 1\n2 2 1\n3 3 1\n2 -2 1", "4 999998\n1 1 2\n2 2 1\n3 3 1\n2 -2 1", "2 1\n1 1 999997\n2 2 1", "4 999998\n3 3 10\n-3 3 10\n3 -3 10\n-3 -3 10", "15 95473\n-9 6 199715\n0 -8 110607\n0 2 6621\n-3 -2 59894\n-10 -8 175440\n-2 0 25814\n10 -4 68131\n7 1 9971\n6 7 821\n6 5 20208\n6 2 68468\n0 7 37427\n...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
120
codeforces
18676c03598b38db0d03c7b1d0fce954
Dijkstra?
You are given a weighted undirected graph. The vertices are enumerated from 1 to *n*. Your task is to find the shortest path between the vertex 1 and the vertex *n*. The first line contains two integers *n* and *m* (2<=≤<=*n*<=≤<=105,<=0<=≤<=*m*<=≤<=105), where *n* is the number of vertices and *m* is the number of edg...
{"inputs": ["5 6\n1 2 2\n2 5 5\n2 3 4\n1 4 1\n4 3 3\n3 5 1", "5 6\n1 2 2\n2 5 5\n2 3 4\n1 4 1\n4 3 3\n3 5 1", "2 1\n1 2 1", "3 1\n1 2 1", "3 3\n1 2 1\n1 3 2\n2 3 1", "10 10\n1 5 12\n2 4 140\n2 10 149\n3 6 154\n3 7 9\n3 8 226\n3 10 132\n4 10 55\n5 8 33\n7 8 173", "10 10\n1 5 178\n1 8 221\n2 7 92\n2 8 159\n3 5 55\n3 6 17...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
147
codeforces
18731b0885aaff022fbbdb83087c9a43
Lucky Ticket
Petya loves lucky numbers very much. Everybody knows that lucky numbers are positive integers whose decimal record contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Petya loves tickets very much. As we know, each ticket has a number that is a positive integer. It...
{"inputs": ["2\n47", "4\n4738", "4\n4774", "4\n4570", "6\n477477", "6\n777777", "20\n44444444444444444444", "2\n44", "10\n4745474547", "14\n77770004444444", "10\n4747777744", "10\n1234567890", "50\n44444444444444444444444444444444444444444444444444", "50\n44444444444444444444444444444444444444444444444447", "50\n744444...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
461
codeforces
189d83c2d5a6b1b0f0bde452f2187d0a
Yaroslav and Time
Yaroslav is playing a game called "Time". The game has a timer showing the lifespan he's got left. As soon as the timer shows 0, Yaroslav's character dies and the game ends. Also, the game has *n* clock stations, station number *i* is at point (*x**i*,<=*y**i*) of the plane. As the player visits station number *i*, he ...
{"inputs": ["3 1000\n1000\n0 0\n0 1\n0 3", "3 1000\n1000\n1 0\n1 1\n1 2", "5 1421\n896 448 727\n-19 -40\n-87 40\n69 51\n-55 61\n-7 67", "6 1000\n142 712 254 869\n7 0\n95 38\n96 -20\n-7 93\n75 -45\n-80 -20", "7 1288\n943 265 649 447 806\n-4 -51\n-26 32\n47 -28\n31 32\n61 65\n-45 -37\n82 42", "8 1931\n440 627 324 538 539...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
9
codeforces
18b11fdbe3798b0b5243958f3bf2e4ef
Dependency management
Polycarp is currently developing a project in Vaja language and using a popular dependency management system called Vamen. From Vamen's point of view both Vaja project and libraries are treated projects for simplicity. A project in Vaja has its own uniqie non-empty name consisting of lowercase latin letters with lengt...
{"inputs": ["4\na 3\n2\nb 1\nc 1\n\nb 2\n0\n\nb 1\n1\nb 2\n\nc 1\n1\nb 2", "9\ncodehorses 5\n3\nwebfrmk 6\nmashadb 1\nmashadb 2\n\ncommons 2\n0\n\nmashadb 3\n0\n\nwebfrmk 6\n2\nmashadb 3\ncommons 2\n\nextra 4\n1\nextra 3\n\nextra 3\n0\n\nextra 1\n0\n\nmashadb 1\n1\nextra 3\n\nmashadb 2\n1\nextra 1", "3\nabc 1\n2\nabc 3...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
8
codeforces
18b1871eff3e76fa481fabb660e7fa4a
Slava and tanks
Slava plays his favorite game "Peace Lightning". Now he is flying a bomber on a very specific map. Formally, map is a checkered field of size 1<=×<=*n*, the cells of which are numbered from 1 to *n*, in each cell there can be one or several tanks. Slava doesn't know the number of tanks and their positions, because he ...
{"inputs": ["2", "3", "4", "6", "10", "15", "100", "100000", "55333", "42273", "29857", "27687", "25517", "23347", "10931", "98514", "6591", "94174", "92004", "59221", "46806", "54882", "42466", "40296", "27880", "25710", "23540", "11124", "8954", "85387", "72971", "81047", "5"], "outputs": ["3\n2 1 2 ", "4\n2 1 3 2 ",...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
57
codeforces
18cd04f66c3a25d8ef9c84aaf20ac88c
Vicious Keyboard
Tonio has a keyboard with only two letters, "V" and "K". One day, he has typed out a string *s* with only these two letters. He really likes it when the string "VK" appears, so he wishes to change at most one letter in the string (or do no changes) to maximize the number of occurrences of that string. Compute the maxi...
{"inputs": ["VK", "VV", "V", "VKKKKKKKKKVVVVVVVVVK", "KVKV", "VKKVVVKVKVK", "VKVVKVKVVKVKKKKVVVVVVVVKVKVVVVVVKKVKKVKVVKVKKVVVVKV", "VVKKVKKVVKKVKKVKVVKKVKKVVKKVKVVKKVKKVKVVKKVVKKVKVVKKVKVVKKVVKVVKKVKKVKKVKKVKKVKVVKKVKKVKKVKKVKKVVKVK", "KVVKKVKVKVKVKVKKVKVKVVKVKVVKVVKVKKVKVKVKVKVKVKVKVKVKVKVKVKVKVKVVKVKVVKKVKVKK", "KVVV...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
142
codeforces
18dfbace2937f92f8edc7f2509adeb06
Dishonest Sellers
Igor found out discounts in a shop and decided to buy *n* items. Discounts at the store will last for a week and Igor knows about each item that its price now is *a**i*, and after a week of discounts its price will be *b**i*. Not all of sellers are honest, so now some products could be more expensive than after a week...
{"inputs": ["3 1\n5 4 6\n3 1 5", "5 3\n3 4 7 10 3\n4 5 5 12 5", "1 0\n9\n8", "2 0\n4 10\n1 2", "4 2\n19 5 17 13\n3 18 8 10", "5 3\n28 17 20 45 45\n39 12 41 27 9", "10 5\n87 96 19 81 10 88 7 49 36 21\n11 75 28 28 74 17 64 19 81 31", "50 45\n80 125 152 122 85 62 123 195 157 73 8 127 47 193 70 132 131 38 98 97 185 98 68 1...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
213
codeforces
19069faac761fefd3f5fae43dd32fd49
Tourist
Tourist walks along the *X* axis. He can choose either of two directions and any speed not exceeding *V*. He can also stand without moving anywhere. He knows from newspapers that at time *t*1 in the point with coordinate *x*1 an interesting event will occur, at time *t*2 in the point with coordinate *x*2 — another one,...
{"inputs": ["3\n-1 1\n42 7\n40 8\n2", "5\n1 5\n6 7\n17127 17\n17072 42\n17042 77\n3", "7\n-976754 20479\n79929143 911181\n9598220 82517\n-51609349 810257\n67416551 266544\n-14170975 307690\n-15476178 491195\n352", "12\n-6712 6\n2375 73\n4643 197\n-5660 215\n-378 223\n2228 307\n3305 340\n3449 468\n-4389 707\n-7161 729\n...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
1
codeforces
190cc916df6e471a15c1895a240a728e
A Simple Task
Given a simple graph, output the number of simple cycles in it. A simple cycle is a cycle with no repeated vertices or edges. The first line of input contains two integers *n* and *m* (1<=≤<=*n*<=≤<=19, 0<=≤<=*m*) – respectively the number of vertices and edges of the graph. Each of the subsequent *m* lines contains tw...
{"inputs": ["4 6\n1 2\n1 3\n1 4\n2 3\n2 4\n3 4", "10 3\n4 8\n9 4\n8 9", "8 28\n1 2\n1 3\n1 4\n1 5\n1 6\n1 7\n1 8\n2 3\n2 4\n2 5\n2 6\n2 7\n2 8\n3 4\n3 5\n3 6\n3 7\n3 8\n4 5\n4 6\n4 7\n4 8\n5 6\n5 7\n5 8\n6 7\n6 8\n7 8", "12 10\n1 6\n4 5\n4 9\n5 10\n6 12\n7 9\n7 10\n8 10\n10 12\n11 12", "3 0", "6 0", "2 1\n1 2", "2 1\n1...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
1
codeforces
1920af96049061e297fe0a7e0d5bea73
Driving Test
Polycarp has just attempted to pass the driving test. He ran over the straight road with the signs of four types. - speed limit: this sign comes with a positive integer number — maximal speed of the car after the sign (cancel the action of the previous sign of this type); - overtake is allowed: this sign means that ...
{"inputs": ["11\n1 100\n3 70\n4\n2\n3 120\n5\n3 120\n6\n1 150\n4\n3 300", "5\n1 100\n3 200\n2\n4\n5", "7\n1 20\n2\n6\n4\n6\n6\n2", "1\n1 100", "2\n1 100\n2", "10\n1 37\n6\n5\n2\n5\n6\n5\n2\n4\n2", "10\n1 5\n4\n5\n4\n1 21\n6\n1 10\n1 1\n2\n3 1"], "outputs": ["2", "0", "2", "0", "0", "2", "1"]}
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
17
codeforces
193c184144e66d2a88598d7fa03827ac
Shaass and Painter Robot
Shaass thinks a kitchen with all white floor tiles is so boring. His kitchen floor is made of *n*·*m* square tiles forming a *n*<=×<=*m* rectangle. Therefore he's decided to color some of the tiles in black so that the floor looks like a checkerboard, which is no two side-adjacent tiles should have the same color. Sha...
{"inputs": ["3 4\n1 1 DR", "3 4\n3 3 DR", "3 3\n1 1 DR", "3 3\n1 2 DL", "2 5\n2 3 DR", "2 3\n2 3 DL", "3 2\n3 1 DL", "3 4\n1 1 DL", "2 2\n2 2 UR", "547 180\n96 1 UR", "657 213\n549 1 UL", "76 153\n1 74 UL", "80304 59860\n27585 59860 UR", "15954 45613\n15954 45142 UR", "66972 6779\n1 5667 UL", "2622 82284\n2540 1 UL", "...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
1
codeforces
1954f4f3cff193e51aefea4a144bdfcb
Save Luke
Luke Skywalker got locked up in a rubbish shredder between two presses. R2D2 is already working on his rescue, but Luke needs to stay alive as long as possible. For simplicity we will assume that everything happens on a straight line, the presses are initially at coordinates 0 and *L*, and they move towards each other ...
{"inputs": ["2 6 2 2", "1 9 1 2", "1 10000 1 1", "9999 10000 10000 10000", "1023 2340 1029 3021", "2173 2176 10000 9989", "1 2 123 1", "123 1242 12 312", "2 9997 3 12", "1 10000 10000 10000", "3274 4728 888 4578", "4600 9696 5634 8248", "2255 7902 8891 429", "6745 9881 2149 9907", "4400 8021 6895 2089", "5726 9082 7448...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
241
codeforces
195a674edfdb1beb7260a34b31fe41f6
Weird Game
Yaroslav, Andrey and Roman can play cubes for hours and hours. But the game is for three, so when Roman doesn't show up, Yaroslav and Andrey play another game. Roman leaves a word for each of them. Each word consists of 2·*n* binary characters "0" or "1". After that the players start moving in turns. Yaroslav moves f...
{"inputs": ["2\n0111\n0001", "3\n110110\n001001", "3\n111000\n000111", "4\n01010110\n00101101", "4\n01100000\n10010011", "4\n10001001\n10101101", "3\n000000\n000100", "2\n0000\n1110", "4\n11111111\n10100110", "4\n10100111\n11011000", "4\n00101011\n11110100", "4\n11000011\n00111100", "4\n11101111\n01000110", "4\n0111011...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
8
codeforces
19652a10a291705df6b35df2213433ea
Random Teams
*n* participants of the competition were split into *m* teams in some manner so that each team has at least one participant. After the competition each pair of participants from the same team became friends. Your task is to write a program that will find the minimum and the maximum number of pairs of friends that coul...
{"inputs": ["5 1", "3 2", "6 3", "5 3", "10 2", "10 6", "1000000000 1", "5000000 12", "1833 195", "1000000000 1000000000", "1000000000 1000000", "1000000000 32170", "1000000 1000", "1234 1123", "599222887 298488", "999999999 500000000", "1000000000 384842119", "1000000000 384842119", "1000000000 2", "1000000000 9999999...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
239
codeforces
19822dd149e51b421976d336fb1fb4a8
Equal Sums
You are given $k$ sequences of integers. The length of the $i$-th sequence equals to $n_i$. You have to choose exactly two sequences $i$ and $j$ ($i \ne j$) such that you can remove exactly one element in each of them in such a way that the sum of the changed sequence $i$ (its length will be equal to $n_i - 1$) equals...
{"inputs": ["2\n5\n2 3 1 3 2\n6\n1 1 2 2 2 1", "3\n1\n5\n5\n1 1 1 1 1\n2\n2 3", "4\n6\n2 2 2 2 2 2\n5\n2 2 2 2 2\n3\n2 2 2\n5\n2 2 2 2 2", "2\n2\n0 -10000\n2\n10000 0"], "outputs": ["YES\n2 1\n1 4", "NO", "YES\n4 1\n2 5", "YES\n2 1\n1 2"]}
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
37
codeforces
198410fd502067f83e7e63ffb6065693
Distance in Tree
A tree is a connected graph that doesn't contain any cycles. The distance between two vertices of a tree is the length (in edges) of the shortest path between these vertices. You are given a tree with *n* vertices and a positive number *k*. Find the number of distinct pairs of the vertices which have a distance of ex...
{"inputs": ["5 2\n1 2\n2 3\n3 4\n2 5", "5 3\n1 2\n2 3\n3 4\n4 5", "10 1\n2 1\n3 1\n4 3\n5 4\n6 5\n7 1\n8 6\n9 2\n10 6", "10 2\n2 1\n3 1\n4 3\n5 4\n6 5\n7 1\n8 6\n9 2\n10 6", "10 3\n2 1\n3 1\n4 3\n5 4\n6 5\n7 1\n8 6\n9 2\n10 6", "50 3\n2 1\n3 2\n4 3\n5 4\n6 5\n7 6\n8 7\n9 8\n10 9\n11 10\n12 11\n13 12\n14 13\n15 14\n16 1...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
12
codeforces
19a6ec21c8071eaac811c5d886bdbcb5
Bear and Friendship Condition
Bear Limak examines a social network. Its main functionality is that two members can become friends (then they can talk with each other and share funny pictures). There are *n* members, numbered 1 through *n*. *m* pairs of members are friends. Of course, a member can't be a friend with themselves. Let A-B denote that...
{"inputs": ["4 3\n1 3\n3 4\n1 4", "4 4\n3 1\n2 3\n3 4\n1 2", "10 4\n4 3\n5 10\n8 9\n1 2", "3 2\n1 2\n2 3", "3 0", "15 42\n8 1\n3 14\n7 14\n12 3\n7 9\n6 7\n6 12\n14 12\n3 10\n10 14\n6 3\n3 13\n13 10\n7 12\n7 2\n6 10\n11 4\n9 3\n8 4\n7 3\n2 3\n2 10\n9 13\n2 14\n6 14\n13 2\n1 4\n13 6\n7 10\n13 14\n12 10\n13 7\n12 2\n9 10\...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
79
codeforces
19abaf75e3070d35d8add03d295b55c9
Romaji
Vitya has just started learning Berlanese language. It is known that Berlanese uses the Latin alphabet. Vowel letters are "a", "o", "u", "i", and "e". Other letters are consonant. In Berlanese, there has to be a vowel after every consonant, but there can be any letter after any vowel. The only exception is a consonant...
{"inputs": ["sumimasen", "ninja", "codeforces", "auuaoonntanonnuewannnnpuuinniwoonennyolonnnvienonpoujinndinunnenannmuveoiuuhikucuziuhunnnmunzancenen", "n", "necnei", "nternn", "aucunuohja", "a", "b", "nn", "nnnzaaa", "zn", "ab", "aaaaaaaaaa", "aaaaaaaaab", "aaaaaaaaan", "baaaaaaaaa", "naaaaaaaaa", "nbaaaaaaaa", "bbaaa...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
159
codeforces
19c0291bd1c79abe04f3ac01b584c1e5
Powerful array
An array of positive integers *a*1,<=*a*2,<=...,<=*a**n* is given. Let us consider its arbitrary subarray *a**l*,<=*a**l*<=+<=1...,<=*a**r*, where 1<=≤<=*l*<=≤<=*r*<=≤<=*n*. For every positive integer *s* denote by *K**s* the number of occurrences of *s* into the subarray. We call the power of the subarray the sum of p...
{"inputs": ["3 2\n1 2 1\n1 2\n1 3", "8 3\n1 1 2 2 1 3 1 1\n2 7\n1 6\n2 7", "20 8\n1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2\n4 15\n1 2\n2 20\n7 7\n13 18\n7 7\n3 19\n3 8", "10 5\n10 9 8 7 6 5 4 3 2 1\n4 8\n1 10\n3 9\n2 2\n5 10", "8 10\n100 100 100 100 100 100 100 100\n1 8\n2 8\n3 8\n4 8\n5 8\n6 8\n7 8\n8 8\n1 1\n1 5", "1 ...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
1
codeforces
19d2ecccfa97f05d68273ed6f8fa0fd3
Permutations
You are given *n* *k*-digit integers. You have to rearrange the digits in the integers so that the difference between the largest and the smallest number was minimum. Digits should be rearranged by the same rule in all integers. The first line contains integers *n* and *k* — the number and digit capacity of numbers cor...
{"inputs": ["6 4\n5237\n2753\n7523\n5723\n5327\n2537", "3 3\n010\n909\n012", "7 5\n50808\n36603\n37198\n44911\n29994\n42543\n50156", "5 5\n61374\n74304\n41924\n46010\n09118", "8 8\n68785928\n11981277\n32480720\n72495162\n69969623\n42118868\n64235849\n81412116", "7 1\n1\n0\n8\n5\n4\n9\n8", "3 8\n34848224\n16307102\n2518...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
16
codeforces
19d770e2c74d695b37b93d822093c5aa
Marathon
Valera takes part in the Berland Marathon. The marathon race starts at the stadium that can be represented on the plane as a square whose lower left corner is located at point with coordinates (0,<=0) and the length of the side equals *a* meters. The sides of the square are parallel to coordinate axes. As the length o...
{"inputs": ["2 5\n2", "4.147 2.8819\n6", "16904.8597 21646.2846\n10", "40356.3702 72886.7142\n100", "70092.4982 95833.7741\n1000", "39712.7105 19285.2846\n10000", "97591.0354 49021.4126\n100000", "1 100000\n100000", "1 1\n1", "99999.9999 99999.9998\n100000", "1.0001 9999.9999\n100000", "100000 1\n100000", "100000 10000...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
6
codeforces
19dae5f00909e7d63f427950e41e714c
Game with Coins
Two pirates Polycarpus and Vasily play a very interesting game. They have *n* chests with coins, the chests are numbered with integers from 1 to *n*. Chest number *i* has *a**i* coins. Polycarpus and Vasily move in turns. Polycarpus moves first. During a move a player is allowed to choose a positive integer *x* (2·*x...
{"inputs": ["1\n1", "3\n1 2 3", "100\n269 608 534 956 993 409 297 735 258 451 468 422 125 407 580 769 857 383 419 67 377 230 842 113 169 427 287 75 372 133 456 450 644 303 638 40 217 445 427 730 168 341 371 633 237 951 142 596 528 509 236 782 44 467 607 326 267 15 564 858 499 337 74 346 443 436 48 795 206 403 379 313 3...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
9
codeforces
19e898254aab6b1c7f5fa0c9454533fb
R3D3’s Summer Adventure
R3D3 spent some time on an internship in MDCS. After earning enough money, he decided to go on a holiday somewhere far, far away. He enjoyed suntanning, drinking alcohol-free cocktails and going to concerts of popular local bands. While listening to "The White Buttons" and their hit song "Dacan the Baker", he met anoth...
{"inputs": ["4 1 2", "2 1 5", "3 1 1", "5 5 5", "4 0 0", "6 0 6", "6 6 0", "2 1 2", "100000000 1 0", "2 0 0", "2 100000000 100000000", "2 100000000 0", "2 0 100000000", "100000000 0 0", "100000000 100000000 100000000", "100000000 100000000 0", "100000000 0 100000000", "2 50000000 0", "2 50000000 100000000", "2 50000000...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
2
codeforces
1a01e8cd6ea9e6b13f69248a9cdca0db
Monitor
Reca company makes monitors, the most popular of their models is AB999 with the screen size *a*<=×<=*b* centimeters. Because of some production peculiarities a screen parameters are integer numbers. Recently the screen sides ratio *x*:<=*y* became popular with users. That's why the company wants to reduce monitor AB999...
{"inputs": ["800 600 4 3", "1920 1200 16 9", "1 1 1 2", "1002105126 227379125 179460772 1295256518", "625166755 843062051 1463070160 1958300154", "248228385 1458744978 824699604 1589655888", "186329049 1221011622 90104472 1769702163", "511020182 242192314 394753578 198572007", "134081812 857875240 82707261 667398699", ...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
34
codeforces
1a3833e219a41346e746f849967f9b3c
Meeting
The Super Duper Secret Meeting of the Super Duper Secret Military Squad takes place in a Super Duper Secret Place. The place is an infinite plane with introduced Cartesian coordinate system. The meeting table is represented as a rectangle whose sides are parallel to the coordinate axes and whose vertexes are located at...
{"inputs": ["2 5 4 2\n3\n3 1 2\n5 3 1\n1 3 2", "5 2 6 3\n2\n6 2 2\n6 5 3", "-705 595 -702 600\n1\n-589 365 261", "-555 674 -553 774\n5\n-656 128 631\n597 -220 999\n-399 793 155\n-293 -363 1000\n-557 -914 1000", "-210 783 -260 833\n10\n406 551 1000\n372 -373 999\n-12 -532 999\n371 -30 999\n258 480 558\n648 -957 1000\n-7...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
7
codeforces
1a3944c48c6207815c1e4c534d54831f
Sereja and Table
Sereja has an *n*<=×<=*m* rectangular table *a*, each cell of the table contains a zero or a number one. Sereja wants his table to meet the following requirement: each connected component of the same values forms a rectangle with sides parallel to the sides of the table. Rectangles should be filled with cells, that is,...
{"inputs": ["5 5 2\n1 1 1 1 1\n1 1 1 1 1\n1 1 0 1 1\n1 1 1 1 1\n1 1 1 1 1", "3 4 1\n1 0 0 0\n0 1 1 1\n1 1 1 0", "3 4 1\n1 0 0 1\n0 1 1 0\n1 0 0 1", "8 1 4\n0\n0\n0\n1\n0\n1\n1\n0", "3 10 7\n0 1 0 0 1 0 1 0 0 0\n0 0 1 1 0 0 0 1 0 1\n1 0 1 1 1 0 1 1 0 0", "4 9 7\n0 0 0 1 0 1 1 0 0\n1 1 1 0 0 0 0 1 1\n1 1 0 0 1 1 0 1 0\n0...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
3
codeforces
1a542256851fbf03363cd7fffc84c4a0
Bear and Tree Jumps
A tree is an undirected connected graph without cycles. The distance between two vertices is the number of edges in a simple path between them. Limak is a little polar bear. He lives in a tree that consists of *n* vertices, numbered 1 through *n*. Limak recently learned how to jump. He can jump from a vertex to any v...
{"inputs": ["6 2\n1 2\n1 3\n2 4\n2 5\n4 6", "13 3\n1 2\n3 2\n4 2\n5 2\n3 6\n10 6\n6 7\n6 13\n5 8\n5 9\n9 11\n11 12", "3 5\n2 1\n3 1", "2 1\n1 2", "2 5\n2 1", "15 1\n12 9\n13 7\n1 3\n10 4\n9 2\n2 15\n11 4\n2 14\n10 8\n6 7\n12 5\n8 7\n3 10\n10 2", "4 2\n3 4\n2 4\n3 1", "12 3\n5 11\n10 11\n6 4\n8 9\n4 12\n10 7\n4 1\n3 1\n...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
1
codeforces
1aa40a049ab142e496e372c4df124c0a
Perfect Security
Alice has a very important message *M* consisting of some non-negative integers that she wants to keep secret from Eve. Alice knows that the only theoretically secure cipher is one-time pad. Alice generates a random key *K* of the length equal to the message's length. Alice computes the bitwise xor of each element of t...
{"inputs": ["3\n8 4 13\n17 2 7", "5\n12 7 87 22 11\n18 39 9 12 16", "10\n331415699 278745619 998190004 423175621 42983144 166555524 843586353 802130100 337889448 685310951\n226011312 266003835 342809544 504667531 529814910 684873393 817026985 844010788 993949858 1031395667", "5\n134 246 57 176 239\n14 83 97 175 187", "...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
3
codeforces
1aae09d59fdc0c4399e58e8469772e31
Equation
You are given an equation: Your task is to find the number of distinct roots of the equation and print all of them in ascending order. The first line contains three integer numbers *A*,<=*B* and *C* (<=-<=105<=≤<=*A*,<=*B*,<=*C*<=≤<=105). Any coefficient may be equal to 0. In case of infinite root count print the onl...
{"inputs": ["1 -5 6", "1 1 1", "1 2 1", "0 0 0", "0 -2 1", "0 -2 0", "0 0 1", "0 0 -100000", "0 10000 -100000", "1 100000 -100000", "0 3431 43123", "100 200 100", "50000 100000 50000", "-1 10 20", "-50000 100000 -50000", "1 -2 1", "1000 -5000 6000", "0 -100000 0", "1 -100000 0", "1223 -23532 1232", "-1 -2 -1", "1 0 0",...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
36
codeforces
1adf051fd4437e5a6984d9c248647615
Drazil and Date
Someday, Drazil wanted to go on date with Varda. Drazil and Varda live on Cartesian plane. Drazil's home is located in point (0,<=0) and Varda's home is located in point (*a*,<=*b*). In each step, he can move in a unit distance in horizontal or vertical direction. In other words, from position (*x*,<=*y*) he can go to ...
{"inputs": ["5 5 11", "10 15 25", "0 5 1", "0 0 2", "999999999 999999999 2000000000", "-606037695 998320124 820674098", "948253616 -83299062 1031552680", "711980199 216568284 928548487", "-453961301 271150176 725111473", "0 0 2000000000", "0 0 1999999999", "1000000000 1000000000 2000000000", "-1000000000 1000000000 200...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
146
codeforces
1b086a205dcde6ba4c9ab03dfd1792b0
Two strings
You are given two strings *a* and *b*. You have to remove the minimum possible number of consecutive (standing one after another) characters from string *b* in such a way that it becomes a subsequence of string *a*. It can happen that you will not need to remove any characters at all, or maybe you will have to remove a...
{"inputs": ["hi\nbob", "abca\naccepted", "abacaba\nabcdcba", "lo\neuhaqdhhzlnkmqnakgwzuhurqlpmdm", "aaeojkdyuilpdvyewjfrftkpcobhcumwlaoiocbfdtvjkhgda\nmlmarpivirqbxcyhyerjoxlslyfzftrylpjyouypvk", "npnkmawey\nareakefvowledfriyjejqnnaeqheoh", "fdtffutxkujflswyddvhusfcook\nkavkhnhphcvckogqqqqhdmgwjdfenzizrebefsbuhzzwhzvc"...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
8
codeforces
1b36d9af899bb91e38c9a85d7cb7a906
Data Recovery
Not so long ago company R2 bought company R1 and consequently, all its developments in the field of multicore processors. Now the R2 laboratory is testing one of the R1 processors. The testing goes in *n* steps, at each step the processor gets some instructions, and then its temperature is measured. The head engineer ...
{"inputs": ["2 1 1 2\n1", "3 1 1 3\n2", "2 1 1 3\n2", "3 1 1 5\n3", "3 2 1 5\n1 5", "3 2 1 5\n1 1", "3 2 1 5\n5 5", "3 2 1 5\n1 6", "3 2 5 10\n1 10", "6 5 3 6\n4 4 4 4 4", "100 50 68 97\n20 42 93 1 98 6 32 11 48 46 82 96 24 73 40 100 99 10 55 87 65 80 97 54 59 48 30 22 16 92 66 2 22 60 23 81 64 60 34 60 99 99 4 70 91 9...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
38
codeforces
1b5ef8cfd69d5dc48a7f392e465d3a59
A Colourful Prospect
Firecrackers scare Nian the monster, but they're wayyyyy too noisy! Maybe fireworks make a nice complement. Little Tommy is watching a firework show. As circular shapes spread across the sky, a splendid view unfolds on the night of Lunar New Year's eve. A wonder strikes Tommy. How many regions are formed by the circl...
{"inputs": ["3\n0 0 1\n2 0 1\n4 0 1", "3\n0 0 2\n3 0 2\n6 0 2", "3\n0 0 2\n2 0 2\n1 1 2", "1\n0 0 10", "2\n-10 10 1\n10 -10 1", "2\n-6 6 9\n3 -6 6", "2\n-10 -10 10\n10 10 10", "3\n-4 1 5\n-7 7 10\n-3 -4 8", "3\n-2 8 10\n3 -2 5\n3 1 3", "3\n0 0 2\n0 0 4\n3 0 2", "3\n8 5 7\n7 3 7\n5 2 5", "3\n-6 5 7\n1 -2 7\n7 9 7", "3\n...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
1
codeforces
1b67757cd76a83e0896376acaf8af9eb
Vacations
Vasya has *n* days of vacations! So he decided to improve his IT skills and do sport. Vasya knows the following information about each of this *n* days: whether that gym opened and whether a contest was carried out in the Internet on that day. For the *i*-th day there are four options: 1. on this day the gym is close...
{"inputs": ["4\n1 3 2 0", "7\n1 3 3 2 1 2 3", "2\n2 2", "1\n0", "10\n0 0 1 1 0 0 0 0 1 0", "100\n3 2 3 3 3 2 3 1 3 2 2 3 2 3 3 3 3 3 3 1 2 2 3 1 3 3 2 2 2 3 1 0 3 3 3 2 3 3 1 1 3 1 3 3 3 1 3 1 3 0 1 3 2 3 2 1 1 3 2 3 3 3 2 3 1 3 3 3 3 2 2 2 1 3 1 3 3 3 3 1 3 2 3 3 0 3 3 3 3 3 1 0 2 1 3 3 0 2 3 3", "10\n2 3 0 1 3 1 2 2 ...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
490
codeforces
1ba3cfe4997ee8dcd640bb7f5ff1c2d8
Orange
The first line of the input is a string (between 1 and 50 characters long, inclusive). Each character will be a letter of English alphabet, lowercase or uppercase. The second line of the input is an integer between 0 and 26, inclusive. Output the required string. Sample Input AprilFool 14 Sample Output AprILFooL
{"inputs": ["AprilFool\n14", "abcdefabc\n3", "fgWjSAlPOvcAbCdDEFjz\n7", "sm\n26", "GnlFOqPeZtPiBkvvLhaDvGPgFqBTnLgMT\n12", "sPWSFWWqZBPon\n3", "fQHHXCdeaintxHWcFcaSGWFvqnYMEByMlSNKumiFgnJB\n0", "RtsUOGkraqKyjTktAXloOEmQj\n18", "DuFhhnq\n4", "RvpuYTxsbDiJDOLauRlfatcfwvtnDzKyaewGrZ\n22", "isfvbcBEEPaXUDhbVhwddjEutVQqNdli...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
16
codeforces
1ba91a102a7f37aac8832718ae66b16b
Biridian Forest
You're a mikemon breeder currently in the middle of your journey to become a mikemon master. Your current obstacle is go through the infamous Biridian Forest. The forest The Biridian Forest is a two-dimensional grid consisting of *r* rows and *c* columns. Each cell in Biridian Forest may contain a tree, or may be vac...
{"inputs": ["5 7\n000E0T3\nT0TT0T0\n010T0T0\n2T0T0T0\n0T0S000", "1 4\nSE23", "3 3\n000\nS0E\n000", "5 5\nS9999\nTTTT9\n99999\n9TTTT\n9999E", "1 10\n9T9TSET9T9", "10 1\nS\n9\n9\n9\n9\nE\n9\n9\n9\n9", "4 3\nS01\n234\n567\n89E", "2 2\nE9\nS4", "3 3\n920\n752\nE8S", "5 1\n9\nT\nE\n6\nS", "1 5\n78S6E", "9 8\n38030772\n697T8...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
8
codeforces
1bbc1b8f93c00a8c754ecaa1479f9bbf
Lesha and array splitting
One spring day on his way to university Lesha found an array *A*. Lesha likes to split arrays into several parts. This time Lesha decided to split the array *A* into several, possibly one, new arrays so that the sum of elements in each of the new arrays is not zero. One more condition is that if we place the new arrays...
{"inputs": ["3\n1 2 -3", "8\n9 -12 3 4 -4 -10 7 3", "1\n0", "4\n1 2 3 -5", "6\n0 0 0 0 0 0", "100\n507 -724 -243 -846 697 -569 -786 472 756 -272 731 -534 -664 202 592 -381 161 -668 -895 296 472 -868 599 396 -617 310 -283 -118 829 -218 807 939 -152 -343 -96 692 -570 110 442 159 -446 -631 -881 784 894 -3 -792 654 -273 -7...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
88
codeforces
1bc048bce4f6f19733a32be0b610de7a
Wonderful Randomized Sum
Learn, learn and learn again — Valera has to do this every day. He is studying at mathematical school, where math is the main discipline. The mathematics teacher loves her discipline very much and tries to cultivate this love in children. That's why she always gives her students large and difficult homework. Despite th...
{"inputs": ["3\n-1 -2 -3", "5\n-4 2 0 5 0", "5\n-1 10 -5 10 -2", "1\n-3", "4\n1 4 -5 -2", "7\n-17 6 5 0 1 4 -1", "3\n0 -2 3", "2\n0 3", "15\n14 0 -10 -5 0 19 -6 0 -11 -20 -18 -8 -3 19 -7", "15\n0 -35 32 24 0 27 10 0 -19 -38 30 -30 40 -3 22", "100\n-43 0 -81 10 67 61 0 76 -16 1 -1 69 -59 -87 14 -20 -48 -41 90 96 8 -94 -...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
18
codeforces
1bc2b438bd8b82a4aa536af61323166e
Magazine Ad
The main city magazine offers its readers an opportunity to publish their ads. The format of the ad should be like this: There are space-separated non-empty words of lowercase and uppercase Latin letters. There are hyphen characters '-' in some words, their positions set word wrapping points. Word can include more th...
{"inputs": ["4\ngarage for sa-le", "4\nEdu-ca-tion-al Ro-unds are so fun", "1\nj", "10\nb", "1\nQGVsfZevMD", "1\nqUOYCytbKgoGRgaqhjrohVRxKTKjjOUPPnEjiXJWlvpCyqiRzbnpyNqDylWverSTrcgZpEoDKhJCrOOvsuXHzkPtbXeKCKMwUTVk", "100000\nBGRHXGrqgjMxCBCdQTCpQyHNMkraTRxhyZBztkxXNFEKnCNjHWeCWmmrRjiczJAdfQqdQfnuupPqzRhEKnpuTCsVPNVTIMi...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
25
codeforces
1bc3e611b56cd450a7fb71b37744f2d8
Sagheer and Apple Tree
Sagheer is playing a game with his best friend Soliman. He brought a tree with *n* nodes numbered from 1 to *n* and rooted at node 1. The *i*-th node has *a**i* apples. This tree has a special property: the lengths of all paths from the root to any leaf have the same parity (i.e. all paths have even length or all paths...
{"inputs": ["3\n2 2 3\n1 1", "3\n1 2 3\n1 1", "8\n7 2 2 5 4 3 1 1\n1 1 1 4 4 5 6", "6\n7 7 7 7 7 7\n1 1 1 1 1", "6\n3 1 1 1 2 2\n1 1 1 1 1", "6\n1 2 3 4 5 6\n1 2 3 4 5", "7\n15 3 5 1 2 4 8\n1 1 2 2 3 3", "7\n15 3 5 1 2 4 9\n1 1 2 2 3 3", "7\n15 16 32 1 2 4 9\n1 1 2 2 3 3", "6\n49 70 74 18 64 63\n1 2 2 1 5", "9\n15 17 6...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
3
codeforces
1bd2de89b88911f54537f09932bbfcf9
Degenerate Matrix
The determinant of a matrix 2<=×<=2 is defined as follows: A matrix is called degenerate if its determinant is equal to zero. The norm ||*A*|| of a matrix *A* is defined as a maximum of absolute values of its elements. You are given a matrix . Consider any degenerate matrix *B* such that norm ||*A*<=-<=*B*|| is min...
{"inputs": ["1 2\n3 4", "1 0\n0 1", "1000000000 0\n0 1000000000", "8205 9482\n11 -63", "0 0\n0 0", "1000000000 -1000000000\n1000000000 1000000000", "1000000000 1000000000\n1000000000 -1000000000", "-1 -1\n1 0", "5 2\n-15 -6", "2 -5\n-3 2", "-5 -2\n-1 -3", "-5 8\n1 6", "1 3\n3 2", "-42 63\n77 -32", "91 -7\n-21 91", "-67...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
19
codeforces
1be5e5a36186928a169b53c3d91ce365
Nephren Runs a Cinema
Lakhesh loves to make movies, so Nephren helps her run a cinema. We may call it No. 68 Cinema. However, one day, the No. 68 Cinema runs out of changes (they don't have 50-yuan notes currently), but Nephren still wants to start their business. (Assume that yuan is a kind of currency in Regulu Ere.) There are three t...
{"inputs": ["4 97 2 3", "4 100 0 4", "13 143 6 11", "999 998244353 666 777", "23333 1000000007 0 23333", "100000 100160063 2332 99774", "100000 996991027 54321 67890", "1 1 0 0", "1 1 0 1", "1 233332 0 0", "1 999888663 0 1", "1 2000000000 1 1", "2 14 0 0", "2 39 0 1", "2 1999999999 0 2", "2 15 1 1", "2 2 1 2", "2 3 2 2...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
1
codeforces
1c3d7c7c251da6bd6d5318dc55816483
On Segment's Own Points
Our old friend Alexey has finally entered the University of City N — the Berland capital. Alexey expected his father to get him a place to live in but his father said it was high time for Alexey to practice some financial independence. So, Alexey is living in a dorm. The dorm has exactly one straight dryer — a 100 ce...
{"inputs": ["3\n0 5\n2 8\n1 6", "3\n0 10\n1 5\n7 15", "1\n0 100", "2\n1 9\n1 9", "2\n1 9\n5 10", "2\n1 9\n3 5", "2\n3 5\n1 9", "10\n43 80\n39 75\n26 71\n4 17\n11 57\n31 42\n1 62\n9 19\n27 76\n34 53", "50\n33 35\n98 99\n1 2\n4 6\n17 18\n63 66\n29 30\n35 37\n44 45\n73 75\n4 5\n39 40\n92 93\n96 97\n23 27\n49 50\n2 3\n60 6...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
80
codeforces
1c41a03010f966e896c90f173d265027
PLEASE
As we all know Barney's job is "PLEASE" and he has not much to do at work. That's why he started playing "cups and key". In this game there are three identical cups arranged in a line from left to right. Initially key to Barney's heart is under the middle cup. Then at one turn Barney swaps the cup in the middle with a...
{"inputs": ["1\n2", "3\n1 1 1", "1\n983155795040951739", "2\n467131402341701583 956277077729692725", "10\n217673221404542171 806579927281665969 500754531396239406 214319484250163112 328494187336342674 427465830578952934 951554014286436941 664022909283791499 653206814724654845 66704816231807388", "8\n137264686188377169 ...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
7
codeforces
1c6303b7e51d261699ad1d56d6f87efd
Seller Bob
Last year Bob earned by selling memory sticks. During each of *n* days of his work one of the two following events took place: - A customer came to Bob and asked to sell him a 2*x* MB memory stick. If Bob had such a stick, he sold it and got 2*x* berllars. - Bob won some programming competition and got a 2*x* MB me...
{"inputs": ["7\nwin 10\nwin 5\nwin 3\nsell 5\nsell 3\nwin 10\nsell 10", "3\nwin 5\nsell 6\nsell 4", "60\nwin 30\nsell 30\nwin 29\nsell 29\nwin 28\nsell 28\nwin 27\nsell 27\nwin 26\nsell 26\nwin 25\nsell 25\nwin 24\nsell 24\nwin 23\nsell 23\nwin 22\nsell 22\nwin 21\nsell 21\nwin 20\nsell 20\nwin 19\nsell 19\nwin 18\nsel...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
65
codeforces
1c9df2f477b8d47d31cf463f5a731156
Joty and Chocolate
Little Joty has got a task to do. She has a line of *n* tiles indexed from 1 to *n*. She has to paint them in a strange pattern. An unpainted tile should be painted Red if it's index is divisible by *a* and an unpainted tile should be painted Blue if it's index is divisible by *b*. So the tile with the number divisibl...
{"inputs": ["5 2 3 12 15", "20 2 3 3 5", "1 1 1 1 1", "1 2 2 2 2", "2 1 3 3 3", "3 1 1 3 3", "4 1 5 4 3", "8 8 1 1 1", "15 14 32 65 28", "894 197 325 232 902", "8581 6058 3019 2151 4140", "41764 97259 54586 18013 75415", "333625 453145 800800 907251 446081", "4394826 2233224 609367 3364334 898489", "13350712 76770926 6...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
107
codeforces
1cc716b77421e3d6b18974cbc830152f
Hard problem
Vasiliy is fond of solving different tasks. Today he found one he wasn't able to solve himself, so he asks you to help. Vasiliy is given *n* strings consisting of lowercase English letters. He wants them to be sorted in lexicographical order (as in the dictionary), but he is not allowed to swap any of them. The only o...
{"inputs": ["2\n1 2\nba\nac", "3\n1 3 1\naa\nba\nac", "2\n5 5\nbbb\naaa", "2\n3 3\naaa\naa", "4\n0 0 8 6\nbi\nqp\nbt\nya", "5\n8 0 4 8 2\nac\ncl\ngg\ngm\nfs", "10\n7 7 0 0 0 1 6 6 7 3\ndv\ngb\nvg\nxg\nkt\nml\nqm\nnq\nrt\nxn", "3\n999999999 999999999 999999999\nxosbqqnmxq\nsdbvjhvytx\naydpuidgvy", "3\n228 1488 228\nkek\...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
10
codeforces
1cc7f991569d0b44661ef185c3842674
Party Lemonade
A New Year party is not a New Year party without lemonade! As usual, you are expecting a lot of guests, and buying lemonade has already become a pleasant necessity. Your favorite store sells lemonade in bottles of *n* different volumes at different costs. A single bottle of type *i* has volume 2*i*<=-<=1 liters and co...
{"inputs": ["4 12\n20 30 70 90", "4 3\n10000 1000 100 10", "4 3\n10 100 1000 10000", "5 787787787\n123456789 234567890 345678901 456789012 987654321", "30 792520535\n528145579 682850171 79476920 178914057 180053263 538638086 433143781 299775597 723428544 177615223 959893339 639448861 506106572 807471834 42398440 347390...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
46
codeforces
1ccc257b517cd0fd9a4117df8d25e6ba
Broken Clock
You are given a broken clock. You know, that it is supposed to show time in 12- or 24-hours HH:MM format. In 12-hours format hours change from 1 to 12, while in 24-hours it changes from 0 to 23. In both formats minutes change from 0 to 59. You are given a time in format HH:MM that is currently displayed on the broken ...
{"inputs": ["24\n17:30", "12\n17:30", "24\n99:99", "12\n05:54", "12\n00:05", "24\n23:80", "24\n73:16", "12\n03:77", "12\n47:83", "24\n23:88", "24\n51:67", "12\n10:33", "12\n00:01", "12\n07:74", "12\n00:60", "24\n08:32", "24\n42:59", "24\n19:87", "24\n26:98", "12\n12:91", "12\n11:30", "12\n90:32", "12\n03:69", "12\n33:8...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
62
codeforces
1cdc43323dd7fe34277766feb4665594
Gargari and Bishops
Gargari is jealous that his friend Caisa won the game from the previous problem. He wants to prove that he is a genius. He has a *n*<=×<=*n* chessboard. Each cell of the chessboard has a number written on it. Gargari wants to place two bishops on the chessboard in such a way that there is no cell that is attacked by b...
{"inputs": ["4\n1 1 1 1\n2 1 1 0\n1 1 1 0\n1 0 0 1", "10\n48 43 75 80 32 30 65 31 18 91\n99 5 12 43 26 90 54 91 4 88\n8 87 68 95 73 37 53 46 53 90\n50 1 85 24 32 16 5 48 98 74\n38 49 78 2 91 3 43 96 93 46\n35 100 84 2 94 56 90 98 54 43\n88 3 95 72 78 78 87 82 25 37\n8 15 85 85 68 27 40 10 22 84\n7 8 36 90 10 81 98 51 7...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
10
codeforces
1ce225768b73b495b489addb4d0fd10a
Okabe and Boxes
Okabe and Super Hacker Daru are stacking and removing boxes. There are *n* boxes numbered from 1 to *n*. Initially there are no boxes on the stack. Okabe, being a control freak, gives Daru 2*n* commands: *n* of which are to add a box to the top of the stack, and *n* of which are to remove a box from the top of the sta...
{"inputs": ["3\nadd 1\nremove\nadd 2\nadd 3\nremove\nremove", "7\nadd 3\nadd 2\nadd 1\nremove\nadd 4\nremove\nremove\nremove\nadd 6\nadd 7\nadd 5\nremove\nremove\nremove", "4\nadd 1\nadd 3\nremove\nadd 4\nadd 2\nremove\nremove\nremove", "2\nadd 1\nremove\nadd 2\nremove", "1\nadd 1\nremove", "15\nadd 12\nadd 7\nadd 10\n...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
33
codeforces
1cec334a5ccee5eb45955d9a63427621
Graph Coloring
You are given an undirected graph that consists of *n* vertices and *m* edges. Initially, each edge is colored either red or blue. Each turn a player picks a single vertex and switches the color of all edges incident to it. That is, all red edges with an endpoint in this vertex change the color to blue, while all blue ...
{"inputs": ["3 3\n1 2 B\n3 1 R\n3 2 B", "6 5\n1 3 R\n2 3 R\n3 4 B\n4 5 R\n4 6 R", "4 5\n1 2 R\n1 3 R\n2 3 B\n3 4 B\n1 4 B", "6 6\n1 2 R\n1 3 R\n2 3 R\n4 5 B\n4 6 B\n5 6 B", "3 3\n1 2 R\n1 3 R\n2 3 R", "11 7\n1 2 B\n1 3 R\n3 2 R\n4 5 R\n6 7 R\n8 9 R\n10 11 R", "2 1\n1 2 B"], "outputs": ["1\n2 ", "2\n3 4 ", "-1", "-1", "...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
1
codeforces