problem_id
stringlengths
32
32
name
stringlengths
2
112
problem
stringlengths
200
14k
test_cases
stringlengths
33
79.2M
difficulty
stringclasses
34 values
language
listlengths
1
1
source
stringclasses
15 values
num_solutions
int64
1
1.12M
starter_code
stringlengths
0
1.47k
subset
stringclasses
4 values
d6120d945ca2dd06ce7ce99e1cd247bb
Door Frames
Petya has equal wooden bars of length *n*. He wants to make a frame for two equal doors. Each frame has two vertical (left and right) sides of length *a* and one top side of length *b*. A solid (i.e. continuous without breaks) piece of bar is needed for each side. Determine a minimal number of wooden bars which are ne...
{"inputs": ["8\n1\n2", "5\n3\n4", "6\n4\n2", "20\n5\n6", "1\n1\n1", "3\n1\n2", "3\n2\n1", "1000\n1\n1", "1000\n1000\n1000", "1000\n1\n999", "1000\n1\n498", "1000\n1\n998", "31\n5\n6", "400\n100\n2", "399\n100\n2", "800\n401\n400", "141\n26\n11", "717\n40\n489", "293\n47\n30", "165\n59\n40", "404\n5\n183", "828\n468\n72...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
25
codeforces
d63bc03ec2d750bf0a79a037180d8b83
Yaroslav and Permutations
Yaroslav has an array that consists of *n* integers. In one second Yaroslav can swap two neighboring array elements. Now Yaroslav is wondering if he can obtain an array where any two neighboring elements would be distinct in a finite time. Help Yaroslav. The first line contains integer *n* (1<=≤<=*n*<=≤<=100) — the nu...
{"inputs": ["1\n1", "3\n1 1 2", "4\n7 7 7 7", "4\n479 170 465 146", "5\n996 437 605 996 293", "6\n727 539 896 668 36 896", "7\n674 712 674 674 674 674 674", "8\n742 742 742 742 742 289 742 742", "9\n730 351 806 806 806 630 85 757 967", "10\n324 539 83 440 834 640 440 440 440 440", "7\n925 830 925 98 987 162 356", "68\n...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
440
codeforces
d6450d9766b2a425003aff887bf2eda8
Pyramid of Glasses
Mary has just graduated from one well-known University and is now attending celebration party. Students like to dream of a beautiful life, so they used champagne glasses to construct a small pyramid. The height of the pyramid is *n*. The top level consists of only 1 glass, that stands on 2 glasses on the second level (...
{"inputs": ["3 5", "4 8", "1 1", "10 10000", "1 10000", "10 1", "1 0", "10 0", "10 1022", "10 1023", "10 1024", "1 2", "1 200", "7 128", "8 198", "2 2", "2 3", "2 4", "2 100", "2 10000", "3 7", "3 6", "3 8", "3 12", "3 1", "4 15", "4 14", "4 10", "4 16", "4 999", "4 9", "5 31", "5 30", "5 28", "5 25", "5 15", "5 32", "...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
39
codeforces
d6524006b988fe4a1c2e7fe334ad52cc
Jabber ID
Jabber ID on the national Berland service «Babber» has a form &lt;username&gt;@&lt;hostname&gt;[/resource], where - &lt;username&gt; — is a sequence of Latin letters (lowercase or uppercase), digits or underscores characters «_», the length of &lt;username&gt; is between 1 and 16, inclusive. - &lt;hostname&gt; — is...
{"inputs": ["mike@codeforces.com", "john.smith@codeforces.ru/contest.icpc/12", "test@test.ri/abacaba", "@ops", "this-is-the-test", "mike@codeforces.commike@codeforces.com", "oooop/oooop", "w@S8/XU.5._R7fHq.@../e.WP!54Ey1L\u007f.9jv", "lNC9D1L5U@.L!_!CcAOEEx.0z.aiW/S430sbQT", "@/YTd.K1@lD", "Fyi!d1l@.OesGopTnRn.81xdSb8q...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
28
codeforces
d6a099aefd615f395445dd46e03cae87
Noldbach problem
Nick is interested in prime numbers. Once he read about Goldbach problem. It states that every even integer greater than 2 can be expressed as the sum of two primes. That got Nick's attention and he decided to invent a problem of his own and call it Noldbach problem. Since Nick is interested only in prime numbers, Nold...
{"inputs": ["27 2", "45 7", "2 0", "15 1", "17 1", "34 5", "37 4", "43 5", "47 7", "50 5", "57 6", "60 8", "62 7", "76 9", "69 7", "113 10", "141 11", "207 16", "231 18", "296 19", "332 20", "378 24", "428 23", "497 27", "640 32", "798 35", "802 35", "864 40", "953 44", "995 44", "1000 44", "1000 0", "1000 1000", "2 10...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
238
codeforces
d6a3ee2245008b12cf3816a9aeb24318
Treasure
Malek has recently found a treasure map. While he was looking for a treasure he found a locked door. There was a string *s* written on the door consisting of characters '(', ')' and '#'. Below there was a manual on how to open the door. After spending a long time Malek managed to decode the manual and found out that th...
{"inputs": ["(((#)((#)", "()((#((#(#()", "#", "(#)", "(((((#(#(#(#()", "#))))", "((#(()#(##", "##((((((()", "(((((((((((((((((((###################", "((#)(", "((#)((#)((#)((#)((#)((#)((#)((#)((#)((#)((#)((#)((#)((#)((#)((##", ")((##((###", "(#))(#(#)((((#(##((#(#((((#(##((((((#((()(()(())((()#((((#((()((((#(((((#(##)(...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
41
codeforces
d6b80df56f0740882baccaea55763e55
Binary Blocks
You are given an image, that can be represented with a 2-d *n* by *m* grid of pixels. Each pixel of the image is either on or off, denoted by the characters "0" or "1", respectively. You would like to compress this image. You want to choose an integer *k*<=&gt;<=1 and split the image into *k* by *k* blocks. If *n* and ...
{"inputs": ["3 5\n00100\n10110\n11001"], "outputs": ["5"]}
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
4
codeforces
d6fd979c02770bacad2724d75d957157
none
Dreamoon likes to play with sets, integers and . is defined as the largest positive integer that divides both *a* and *b*. Let *S* be a set of exactly four distinct integers greater than 0. Define *S* to be of rank *k* if and only if for all pairs of distinct elements *s**i*, *s**j* from *S*, . Given *k* and *n*, Dr...
{"inputs": ["1 1", "2 2", "7 7", "13 7", "15 27", "19 21", "113 97", "10000 100", "10000 1", "1 100", "9252 39", "8096 59", "4237 87", "3081 11", "9221 39", "770 59", "5422 87", "1563 15", "407 39", "6518 18", "1171 46", "7311 70", "6155 94", "7704 18", "3844 46", "1 10"], "outputs": ["5\n1 3 4 5", "22\n2 6 8 10\n14 18...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
12
codeforces
d70abc6e8f9f2a1e2b0c2d7894d9ea5d
Ostap and Grasshopper
On the way to Rio de Janeiro Ostap kills time playing with a grasshopper he took with him in a special box. Ostap builds a line of length *n* such that some cells of this line are empty and some contain obstacles. Then, he places his grasshopper to one of the empty cells and a small insect in another empty cell. The gr...
{"inputs": ["5 2\n#G#T#", "6 1\nT....G", "7 3\nT..#..G", "6 2\n..GT..", "2 1\nGT", "100 5\nG####.####.####.####.####.####.####.####.####.####.####.####.####.####.####.####.####.####.####T####", "100 5\nG####.####.####.####.####.####.####.####.####.####.####.####.####.#########.####.####.####.####T####", "2 1\nTG", "99 ...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
254
codeforces
d73ca18f12aeb17663480d60129a16fa
Sagheer, the Hausmeister
Some people leave the lights at their workplaces on when they leave that is a waste of resources. As a hausmeister of DHBW, Sagheer waits till all students and professors leave the university building, then goes and turns all the lights off. The building consists of *n* floors with stairs at the left and the right sid...
{"inputs": ["2 2\n0010\n0100", "3 4\n001000\n000010\n000010", "4 3\n01110\n01110\n01110\n01110", "3 2\n0000\n0100\n0100", "1 89\n0000000000000000000000000000000100000000000000010000000000010000000000000000000000000000000", "2 73\n000000000000000000000000000000000000000000000000000000000000000000000000000\n0000000000000...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
28
codeforces
d766f3f2527be1fa3b8d7c99ab891efc
Eugeny and Array
Eugeny has array *a*<==<=*a*1,<=*a*2,<=...,<=*a**n*, consisting of *n* integers. Each integer *a**i* equals to -1, or to 1. Also, he has *m* queries: - Query number *i* is given as a pair of integers *l**i*, *r**i* (1<=≤<=*l**i*<=≤<=*r**i*<=≤<=*n*). - The response to the query will be integer 1, if the elements of a...
{"inputs": ["2 3\n1 -1\n1 1\n1 2\n2 2", "5 5\n-1 1 1 1 -1\n1 1\n2 3\n3 5\n2 5\n1 5", "3 3\n1 1 1\n2 2\n1 1\n1 1", "4 4\n-1 -1 -1 -1\n1 3\n1 2\n1 2\n1 1", "5 5\n-1 -1 -1 -1 -1\n1 1\n1 1\n3 4\n1 1\n1 4", "6 6\n-1 -1 1 -1 -1 1\n1 1\n3 4\n1 1\n1 1\n1 3\n1 4", "7 7\n-1 -1 -1 1 -1 -1 -1\n1 1\n2 7\n1 3\n1 5\n4 7\n1 7\n6 7", "...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
60
codeforces
d7919219ff4ad6a38979999432fab8f8
Two Paths
As you know, Bob's brother lives in Flatland. In Flatland there are *n* cities, connected by *n*<=-<=1 two-way roads. The cities are numbered from 1 to *n*. You can get from one city to another moving along the roads. The «Two Paths» company, where Bob's brother works, has won a tender to repair two paths in Flatland....
{"inputs": ["4\n1 2\n2 3\n3 4", "7\n1 2\n1 3\n1 4\n1 5\n1 6\n1 7", "6\n1 2\n2 3\n2 4\n5 4\n6 4", "2\n2 1", "3\n3 1\n1 2", "3\n1 3\n2 1", "4\n4 2\n2 3\n2 1", "4\n2 3\n1 3\n2 4", "4\n3 2\n3 4\n1 4", "5\n1 5\n5 2\n4 2\n3 1", "5\n2 4\n2 5\n1 5\n2 3", "5\n1 2\n5 1\n3 2\n3 4", "5\n5 3\n3 1\n4 1\n4 2", "6\n1 2\n2 5\n4 5\n4 6\...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
16
codeforces
d794d52aeb02422c0b71909eeaae5488
Email address
Sometimes one has to spell email addresses over the phone. Then one usually pronounces a dot as dot, an at sign as at. As a result, we get something like vasyaatgmaildotcom. Your task is to transform it into a proper email address ([[email protected]](/cdn-cgi/l/email-protection)). It is known that a proper email add...
{"inputs": ["vasyaatgmaildotcom", "dotdotdotatdotdotat", "aatt", "zdotdotatdotz", "dotdotdotdotatdotatatatdotdotdot", "taatta", "doatdt", "catdotdotdotatatdotdotdotnatjdotatdotdotdoteatatoatatatoatatatdotdotatdotdotwxrdotatfatgfdotuatata", "hmatcxatxatdotatlyucjatdothatdotcatatatdotqatatdotdotdotdotatjddotdotdotqdotdot...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
42
codeforces
d79706d0befbed03f9a2c3c0383c9b22
Petya and Coloring
Little Petya loves counting. He wants to count the number of ways to paint a rectangular checkered board of size *n*<=×<=*m* (*n* rows, *m* columns) in *k* colors. Besides, the coloring should have the following property: for any vertical line that passes along the grid lines and divides the board in two non-empty part...
{"inputs": ["2 2 1", "2 2 2", "3 2 2", "7 8 15", "5 3 1", "5 100 1", "5 20 25", "6 6 8", "1 1 1000000", "3 3 2", "1000 1000 1000000", "1000 2 1000000", "1000 1 992929", "997 752 10001", "994 2 999999", "1 1000 298298", "2 1000 100202", "3 997 999997", "777 777 777777", "105 3 2", "105 3 3", "126 125 440715", "755 51 70...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
1
codeforces
d7bf7d8f27e219e6e217db033c1b8e5d
Touchy-Feely Palindromes
The only line of the input contains a string of digits. The length of the string is between 1 and 10, inclusive. Output "Yes" or "No". The only line of the input contains a string of digits. The length of the string is between 1 and 10, inclusive. Output "Yes" or "No". Sample Input 373 121 436 Sample Output Yes No Ye...
{"inputs": ["373", "121", "436", "7", "8", "4357087936", "806975480", "3333333333", "90785", "7467467", "64", "584609", "69154", "363567", "557654", "772961", "788958", "992045", "116325", "320432", "314729", "531816", "673902416", "880089713", "004176110"], "outputs": ["Yes", "No", "Yes", "Yes", "No", "Yes", "Yes", "Y...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
11
codeforces
d7c0e156ffc26e831fc39e4852202444
HQ
The famous joke programming language HQ9+ has only 4 commands. In this problem we will explore its subset — a language called HQ... The only line of the input is a string between 1 and 106 characters long. Output "Yes" or "No". Sample Input HHHH HQHQH HHQHHQH HHQQHHQQHH Sample Output Yes No No Yes
{"inputs": ["HHHH", "HQHQH", "HHQHHQH", "HHQQHHQQHH", "Q", "HHHHHHHHHHQHHH", "HHQHQQQHHH", "QQQQQQHQQQQQQQQQQHQQQQQQQQQQHQQQQQQQQQQHQQQQQQQQQQHQQQQQQQQQQHQQQQHQQQQQQHQQQQQQQQQQHQQQQQQQQQQHQQQQQQQQQQHQQQQ", "QHQHHQQQQQQQQQQQHQQHQHQQQQQQHQHQQQQQQQQQQQHQQQQQQQHQQHQQHQQQQQQQQQQQQQQQQQQQQHHQQQQQQQQQQHQQQQHHQHQQHQQQQQHQQQQQQ...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
1
codeforces
d7c14ba7d0d268bccc5cdb4f6d715a9e
George and Sleep
George woke up and saw the current time *s* on the digital clock. Besides, George knows that he has slept for time *t*. Help George! Write a program that will, given time *s* and *t*, determine the time *p* when George went to bed. Note that George could have gone to bed yesterday relatively to the current time (see ...
{"inputs": ["05:50\n05:44", "00:00\n01:00", "00:01\n00:00", "23:59\n23:59", "23:44\n23:55", "00:00\n13:12", "12:00\n23:59", "12:44\n12:44", "05:55\n07:12", "07:12\n05:55", "22:22\n22:22", "22:22\n22:23", "23:24\n23:23", "00:00\n00:00", "23:30\n00:00", "01:00\n00:00", "05:44\n06:00", "00:00\n23:59", "21:00\n01:00", "21:...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
174
codeforces
d7c8cf60a201788ba8180140d2bc22a2
Cells Not Under Attack
Vasya has the square chessboard of size *n*<=×<=*n* and *m* rooks. Initially the chessboard is empty. Vasya will consequently put the rooks on the board one after another. The cell of the field is under rook's attack, if there is at least one rook located in the same row or in the same column with this cell. If there ...
{"inputs": ["3 3\n1 1\n3 1\n2 2", "5 2\n1 5\n5 1", "100000 1\n300 400", "10 4\n2 8\n1 8\n9 8\n6 9", "30 30\n3 13\n27 23\n18 24\n18 19\n14 20\n7 10\n27 13\n20 27\n11 1\n21 10\n2 9\n28 12\n29 19\n28 27\n27 29\n30 12\n27 2\n4 5\n8 19\n21 2\n24 27\n14 22\n20 3\n18 3\n23 9\n28 6\n15 12\n2 2\n16 27\n1 14", "70 31\n22 39\n33 ...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
143
codeforces
d7e7fbc84916c4ba69a3a51b3f1490a9
none
Tavas is a strange creature. Usually "zzz" comes out of people's mouth while sleeping, but string *s* of length *n* comes out from Tavas' mouth instead. Today Tavas fell asleep in Malekas' place. While he was sleeping, Malekas did a little process on *s*. Malekas has a favorite string *p*. He determined all positions ...
{"inputs": ["6 2\nioi\n1 3", "5 2\nioi\n1 2", "173700 6\nbcabcbcbcbaaacaccaacaccaabacabaacbcacbbccaccbcacbabcaccccccaacacabbbbbacabbaaacbcbbaccaccabbbbaabbacacbabccaabcabbbcacaaccbabbcaaaaaabccbbcabcacbcbcabcbcbbaabacaaccccabacaaaccacaaabbacacabbcccacbaabcacacbbaaaccaccbaccccccbccaabcacaacabaccababacabcccbcbbacbabacbcb...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
1
codeforces
d7edd56a5eee20eab6b6d09fdcfa9b83
Partial Sums
You've got an array *a*, consisting of *n* integers. The array elements are indexed from 1 to *n*. Let's determine a two step operation like that: 1. First we build by the array *a* an array *s* of partial sums, consisting of *n* elements. Element number *i* (1<=≤<=*i*<=≤<=*n*) of array *s* equals . The operation *x*...
{"inputs": ["3 1\n1 2 3", "5 0\n3 14 15 92 6", "1 1\n3", "1 0\n0", "1 0\n123", "1 1\n0", "4 1\n3 20 3 4", "5 20\n11 5 6 8 11", "17 239\n663 360 509 307 311 501 523 370 302 601 541 42 328 200 196 110 573", "13 666\n84 89 29 103 128 233 190 122 117 208 119 97 200", "42 42\n42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 ...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
6
codeforces
d82160a9327225936bababa5b49ea27a
Plane of Tanks: Pro
Vasya has been playing Plane of Tanks with his friends the whole year. Now it is time to divide the participants into several categories depending on their results. A player is given a non-negative integer number of points in each round of the Plane of Tanks. Vasya wrote results for each round of the last year. He ha...
{"inputs": ["5\nvasya 100\nvasya 200\nartem 100\nkolya 200\nigor 250", "3\nvasya 200\nkolya 1000\nvasya 1000", "1\nvasya 1000", "5\nvasya 1000\nvasya 100\nkolya 200\npetya 300\noleg 400", "10\na 1\nb 2\nc 3\nd 4\ne 5\nf 6\ng 7\nh 8\ni 9\nj 10", "10\nj 10\ni 9\nh 8\ng 7\nf 6\ne 5\nd 4\nc 3\nb 2\na 1", "1\ntest 0"], "out...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
10
codeforces
d828a1ebc83918c509c284ac5175b86f
Infinity Gauntlet
You took a peek on Thanos wearing Infinity Gauntlet. In the Gauntlet there is a place for six Infinity Gems: - the Power Gem of purple color, - the Time Gem of green color, - the Space Gem of blue color, - the Soul Gem of orange color, - the Reality Gem of red color, - the Mind Gem of yellow color. Using colors...
{"inputs": ["4\nred\npurple\nyellow\norange", "0", "6\npurple\nblue\nyellow\nred\ngreen\norange", "1\npurple", "3\nblue\norange\npurple", "2\nyellow\nred", "1\ngreen", "2\npurple\ngreen", "1\nblue", "2\npurple\nblue", "2\ngreen\nblue", "3\npurple\ngreen\nblue", "1\norange", "2\npurple\norange", "2\norange\ngreen", "3\n...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
452
codeforces
d84f506511837749a50dc95afd9a9b7e
Watering Flowers
A flowerbed has many flowers and two fountains. You can adjust the water pressure and set any values *r*1(*r*1<=≥<=0) and *r*2(*r*2<=≥<=0), giving the distances at which the water is spread from the first and second fountain respectively. You have to set such *r*1 and *r*2 that all the flowers are watered, that is, fo...
{"inputs": ["2 -1 0 5 3\n0 2\n5 2", "4 0 0 5 0\n9 4\n8 3\n-1 0\n1 4", "5 -6 -4 0 10\n-7 6\n-9 7\n-5 -1\n-2 1\n-8 10", "10 -68 10 87 22\n30 89\n82 -97\n-52 25\n76 -22\n-20 95\n21 25\n2 -3\n45 -7\n-98 -56\n-15 16", "1 -10000000 -10000000 -10000000 -9999999\n10000000 10000000"], "outputs": ["6", "33", "100", "22034", "799...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
1
codeforces
d85233139efbd43e85b826d96e5960b8
Tram
Linear Kingdom has exactly one tram line. It has *n* stops, numbered from 1 to *n* in the order of tram's movement. At the *i*-th stop *a**i* passengers exit the tram, while *b**i* passengers enter it. The tram is empty before it arrives at the first stop. Also, when the tram arrives at the last stop, all passengers ex...
{"inputs": ["4\n0 3\n2 5\n4 2\n4 0", "5\n0 4\n4 6\n6 5\n5 4\n4 0", "10\n0 5\n1 7\n10 8\n5 3\n0 5\n3 3\n8 8\n0 6\n10 1\n9 0", "3\n0 1\n1 1\n1 0", "4\n0 1\n0 1\n1 0\n1 0", "3\n0 0\n0 0\n0 0", "3\n0 1000\n1000 1000\n1000 0", "5\n0 73\n73 189\n189 766\n766 0\n0 0", "5\n0 0\n0 0\n0 0\n0 1\n1 0", "5\n0 917\n917 923\n904 992\...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
1,051
codeforces
d868b148d0994ff39d9a316418f8fd80
Numbers
Little Petya likes numbers a lot. He found that number 123 in base 16 consists of two digits: the first is 7 and the second is 11. So the sum of digits of 123 in base 16 is equal to 18. Now he wonders what is an average value of sum of digits of the number *A* written in all bases from 2 to *A*<=-<=1. Note that all c...
{"inputs": ["5", "3", "1000", "927", "260", "131", "386", "277", "766", "28", "406", "757", "6", "239", "322", "98", "208", "786", "879", "702", "948", "537", "984", "934", "726", "127", "504", "125", "604", "115", "27", "687", "880", "173", "264", "785", "399", "514", "381", "592", "417", "588", "852", "959", "841", "...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
200
codeforces
d87fa0907cbb094c1645c41452b5fceb
Game with Points
You are playing the following game. There are *n* points on a plane. They are the vertices of a regular *n*-polygon. Points are labeled with integer numbers from 1 to *n*. Each pair of distinct points is connected by a diagonal, which is colored in one of 26 colors. Points are denoted by lowercase English letters. Ther...
{"inputs": ["4\n2 3 4\n*aba\na*ab\nba*b\nabb*", "4\n2 3 4\n*abc\na*ab\nba*b\ncbb*", "3\n1 2 3\n*aa\na*a\naa*", "10\n9 8 6\n*abbbababb\na*babbaaaa\nbb*bbaabab\nbab*bbbaab\nbbbb*baaab\nababb*baaa\nbaabab*bba\naabaaab*ab\nbaaaaaba*a\nbabbbaaba*", "10\n3 9 5\n*aabbbaaaa\na*abbaaaaa\naa*baaaabb\nbbb*bbbaba\nbbab*babaa\nbaab...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
1
codeforces
d8a91763417050f3c37bf81e2019ac08
Mr. Kitayuta, the Treasure Hunter
The Shuseki Islands are an archipelago of 30001 small islands in the Yutampo Sea. The islands are evenly spaced along a line, numbered from 0 to 30000 from the west to the east. These islands are known to contain many treasures. There are *n* gems in the Shuseki Islands in total, and the *i*-th gem is located on island...
{"inputs": ["4 10\n10\n21\n27\n27", "8 8\n9\n19\n28\n36\n45\n55\n66\n78", "13 7\n8\n8\n9\n16\n17\n17\n18\n21\n23\n24\n24\n26\n30", "8 4\n9\n15\n15\n16\n22\n25\n25\n28", "1 30000\n30000", "1 12345\n23456", "1 1\n30000", "5 4\n4\n5\n9\n21\n25", "8 7\n8\n15\n18\n19\n23\n24\n25\n27", "11 15\n15\n18\n19\n19\n21\n23\n24\n26\...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
6
codeforces
d8ae5fce78d6970e097ff460a8ea8ae4
Fly
Natasha is going to fly on a rocket to Mars and return to Earth. Also, on the way to Mars, she will land on $n - 2$ intermediate planets. Formally: we number all the planets from $1$ to $n$. $1$ is Earth, $n$ is Mars. Natasha will make exactly $n$ flights: $1 \to 2 \to \ldots n \to 1$. Flight from $x$ to $y$ consists ...
{"inputs": ["2\n12\n11 8\n7 5", "3\n1\n1 4 1\n2 5 3", "6\n2\n4 6 3 3 5 6\n2 6 3 6 5 3", "3\n3\n1 2 1\n2 2 2", "4\n4\n2 3 2 2\n2 3 4 3", "5\n2\n1 2 2 1 2\n4 5 1 4 1", "7\n7\n3 2 6 2 2 2 5\n4 7 5 6 2 2 2", "2\n1000\n12 34\n56 78", "8\n4\n1 1 4 1 3 1 8 1\n1 1 1 1 1 3 1 2", "9\n2\n8 7 1 1 3 7 1 2 4\n4 1 1 8 7 7 1 1 5", "10...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
116
codeforces
d8d102de0b8305a5013c4be7d50a80f4
Jzzhu and Sequences
Jzzhu has invented a kind of sequences, they meet the following property: You are given *x* and *y*, please calculate *f**n* modulo 1000000007 (109<=+<=7). The first line contains two integers *x* and *y* (|*x*|,<=|*y*|<=≤<=109). The second line contains a single integer *n* (1<=≤<=*n*<=≤<=2·109). Output a single inte...
{"inputs": ["2 3\n3", "0 -1\n2", "-9 -11\n12345", "0 0\n1000000000", "-1000000000 1000000000\n2000000000", "-12345678 12345678\n1912345678", "728374857 678374857\n1928374839", "278374837 992837483\n1000000000", "-693849384 502938493\n982838498", "-783928374 983738273\n992837483", "-872837483 -682738473\n999999999", "-8...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
166
codeforces
d8def71219429750efca943f33e2929e
Two Bags of Potatoes
Valera had two bags of potatoes, the first of these bags contains *x* (*x*<=≥<=1) potatoes, and the second — *y* (*y*<=≥<=1) potatoes. Valera — very scattered boy, so the first bag of potatoes (it contains *x* potatoes) Valera lost. Valera remembers that the total amount of potatoes (*x*<=+<=*y*) in the two bags, first...
{"inputs": ["10 1 10", "10 6 40", "10 1 20", "1 10000 1000000000", "84817 1 33457", "21 37 99", "78 7 15", "74 17 27", "79 23 43", "32 33 3", "55 49 44", "64 59 404", "61 69 820", "17 28 532", "46592 52 232", "1541 58 648", "15946 76 360", "30351 86 424", "1 2 37493", "1 3 27764", "10 4 9174", "33 7 4971", "981 1 3387"...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
278
codeforces
d8f8774e428312b2de356559e7c80362
View Angle
Flatland has recently introduced a new type of an eye check for the driver's licence. The check goes like that: there is a plane with mannequins standing on it. You should tell the value of the minimum angle with the vertex at the origin of coordinates and with all mannequins standing inside or on the boarder of this a...
{"inputs": ["2\n2 0\n0 2", "3\n2 0\n0 2\n-2 2", "4\n2 0\n0 2\n-2 0\n0 -2", "2\n2 1\n1 2", "1\n1 1", "10\n9 7\n10 7\n6 5\n6 10\n7 6\n5 10\n6 7\n10 9\n5 5\n5 8", "10\n-1 28\n1 28\n1 25\n0 23\n-1 24\n-1 22\n1 27\n0 30\n1 22\n1 21", "10\n-5 9\n-10 6\n-8 8\n-9 9\n-6 5\n-8 9\n-5 7\n-6 6\n-5 10\n-8 7", "10\n6 -9\n9 -5\n10 -5\...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
41
codeforces
d8fedd0313ef52a71b02caf1971f7059
2Char
Andrew often reads articles in his favorite magazine 2Char. The main feature of these articles is that each of them uses at most two distinct letters. Andrew decided to send an article to the magazine, but as he hasn't written any article, he just decided to take a random one from magazine 26Char. However, before sendi...
{"inputs": ["4\nabb\ncacc\naaa\nbbb", "5\na\na\nbcbcb\ncdecdecdecdecdecde\naaaa", "1\na", "2\nz\nz", "5\nabcde\nfghij\nklmno\npqrst\nuvwxy", "6\ngggggg\ngggggg\ngggggg\ngggggg\ngggggg\ngggggg", "6\naaaaaa\naaaaaa\nbbbbbb\nbbbbbb\naaabbb\nababab", "1\nabc", "2\nabc\nbca", "3\nab\nba\nzzz", "3\nab\nba\nzzzzz", "5\nzzz\nz...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
104
codeforces
d912639c658962fc49408726816d8926
Vanya and Food Processor
Vanya smashes potato in a vertical food processor. At each moment of time the height of the potato in the processor doesn't exceed *h* and the processor smashes *k* centimeters of potato each second. If there are less than *k* centimeters remaining, than during this second processor smashes all the remaining potato. V...
{"inputs": ["5 6 3\n5 4 3 2 1", "5 6 3\n5 5 5 5 5", "5 6 3\n1 2 1 1 1", "10 100 80\n76 75 73 71 76 74 73 70 78 75", "10 100 88\n11 23 69 6 71 15 25 1 43 37", "10 100 81\n100 97 96 98 98 95 100 97 97 99", "10 1000000000 34\n262467899 490831561 793808758 450543931 364178715 95212706 14245051 92006075 424282318 436927280"...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
7
codeforces
d9166e3b0f0ed9de32f8e9449f984a1c
Memory and De-Evolution
Memory is now interested in the de-evolution of objects, specifically triangles. He starts with an equilateral triangle of side length *x*, and he wishes to perform operations to obtain an equilateral triangle of side length *y*. In a single second, he can modify the length of a single side of the current triangle suc...
{"inputs": ["6 3", "8 5", "22 4", "4 3", "57 27", "61 3", "5 4", "10 6", "20 10", "30 5", "25 24", "25 3", "12 7", "18 6", "100000 3", "100000 9999", "9999 3", "5323 32", "6666 66", "38578 32201", "49449 5291", "65310 32879", "41183 4453", "49127 9714", "19684 12784", "15332 5489", "33904 32701", "9258 2966", "21648 11...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
106
codeforces
d94229bdeee493d6d40f8e91e0886a42
Little Dima and Equation
Little Dima misbehaved during a math lesson a lot and the nasty teacher Mr. Pickles gave him the following problem as a punishment. Find all integer solutions *x* (0<=&lt;<=*x*<=&lt;<=109) of the equation: where *a*, *b*, *c* are some predetermined constant values and function *s*(*x*) determines the sum of all digi...
{"inputs": ["3 2 8", "1 2 -18", "2 2 -1", "1 1 0", "1 37 963", "1 298 -1665", "1 3034 -9234", "5 9998 9998", "5 10000 10000", "5 65 352", "5 9999 9999", "4 2099 -38", "1 1 -6708", "5 36 -46", "5 8975 -4", "3 2794 -3354", "5 1 4473", "5 1 -9999", "4 4 6", "5 19 -666", "5 5 -865", "2 8468 -3666", "4 9359 -3039", "5 5706 ...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
30
codeforces
d9838a48b531ba63f2671bdf2b42d709
Russian Roulette
After all the events in Orlando we all know, Sasha and Roma decided to find out who is still the team's biggest loser. Thankfully, Masha found somewhere a revolver with a rotating cylinder of *n* bullet slots able to contain exactly *k* bullets, now the boys have a chance to resolve the problem once and for all. Sash...
{"inputs": ["3 1 3\n1\n2\n3", "6 3 6\n1\n2\n3\n4\n5\n6", "5 2 5\n1\n2\n3\n4\n5", "4 2 8\n1\n3\n4\n2\n3\n4\n1\n2", "4 0 4\n1\n2\n3\n4", "10 2 10\n1\n2\n3\n4\n5\n6\n7\n8\n9\n10", "12 2 12\n1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12", "9 4 9\n1\n2\n3\n4\n5\n6\n7\n8\n9", "15 10 15\n1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
3
codeforces
d987e074cea379ef806078ed3db3e1f4
Help Caretaker
Autumn came late to the kingdom of Far Far Away. The harvest was exuberant and it is now time to get ready for the winter. As most people celebrate the Harvest festival, Simon the Caretaker tries to solve a very non-trivial task of how to find place for the agricultural equipment in the warehouse. He's got problems wi...
{"inputs": ["3 3", "5 6", "2 2", "4 2", "3 4", "5 3", "4 4", "3 6", "5 4", "5 5", "1 1", "1 2", "2 1", "1 3", "3 1", "1 4", "4 1", "1 5", "5 1", "1 6", "2 3", "3 2", "6 1", "1 7", "7 1", "1 8", "2 4", "8 1", "1 9", "9 1", "2 5", "5 2", "2 6", "4 3", "6 2", "2 7", "7 2", "3 5", "2 8", "8 2", "2 9", "6 3", "9 2", "4 5", ...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
2
codeforces
d994761ff4339bef8b16efd63c03a5fc
GukiZ and GukiZiana
Professor GukiZ was playing with arrays again and accidentally discovered new function, which he called *GukiZiana*. For given array *a*, indexed with integers from 1 to *n*, and number *y*, *GukiZiana*(*a*,<=*y*) represents maximum value of *j*<=-<=*i*, such that *a**j*<==<=*a**i*<==<=*y*. If there is no *y* as an ele...
{"inputs": ["4 3\n1 2 3 4\n1 1 2 1\n1 1 1 1\n2 3", "2 3\n1 2\n1 2 2 1\n2 3\n2 4", "8 5\n1 1 1 2 1 3 1 1\n2 1\n1 1 8 1\n2 2\n1 2 5 2\n2 4", "8 8\n1 9 1 9 2 3 4 5\n1 3 7 1\n2 6\n2 8\n2 9\n1 1 7 3\n2 11\n2 1000000000\n1 1 1 1", "7 3\n2 4 5 2 3 2 8\n2 2\n1 3 4 1\n2 4", "2 2\n1000000000 1000000000\n1 1 2 1\n2 1000000000", "...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
1
codeforces
d9a29a5abec504e0145e12b7ca9942e3
Arpa and a research in Mexican wave
Arpa is researching the Mexican wave. There are *n* spectators in the stadium, labeled from 1 to *n*. They start the Mexican wave at time 0. - At time 1, the first spectator stands. - At time 2, the second spectator stands. - ... - At time *k*, the *k*-th spectator stands. - At time *k*<=+<=1, the (*k*<=+<=1)-t...
{"inputs": ["10 5 3", "10 5 7", "10 5 12", "840585600 770678331 788528791", "25462281 23343504 8024619", "723717988 205757169 291917494", "27462087 20831796 15492397", "966696824 346707476 1196846860", "290274403 41153108 327683325", "170963478 151220598 222269210", "14264008 309456 11132789", "886869816 281212106 5289...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
246
codeforces
d9ad52fdcdc20660bf62fa8976e10a19
Bus Number
This night wasn't easy on Vasya. His favorite team lost, and he didn't find himself victorious either — although he played perfectly, his teammates let him down every time. He had to win at least one more time, but the losestreak only grew longer and longer... It's no wonder he didn't get any sleep this night at all. ...
{"inputs": ["97", "2028", "1", "10", "168", "999999", "987654320023456789", "1000000000000000000", "74774", "2", "3", "4", "5", "6", "7", "8", "9", "101010101", "1010101010", "707070707070707070", "19293", "987650", "123456", "900008", "1000000", "9900111", "11112222", "88888880", "100000009", "203456799", "890009800",...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
18
codeforces
d9cd69ac96b0cfa8b5d217423bac58b2
Fedor and coupons
All our characters have hobbies. The same is true for Fedor. He enjoys shopping in the neighboring supermarket. The goods in the supermarket have unique integer ids. Also, for every integer there is a product with id equal to this integer. Fedor has *n* discount coupons, the *i*-th of them can be used with products w...
{"inputs": ["4 2\n1 100\n40 70\n120 130\n125 180", "3 2\n1 12\n15 20\n25 30", "5 2\n1 10\n5 15\n14 50\n30 70\n99 100", "7 6\n-8 6\n7 9\n-10 -5\n-6 10\n-7 -3\n5 8\n4 10", "9 6\n-7 -3\n-3 10\n-6 1\n-1 8\n-9 4\n-7 -6\n-5 -3\n-10 -2\n3 4", "7 7\n9 10\n-5 3\n-6 2\n1 6\n-9 6\n-10 7\n-7 -5", "23 2\n-629722518 -626148345\n7399...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
4
codeforces
da2883d92f1247d31b17cf7ed15d3203
Saitama Destroys Hotel
Saitama accidentally destroyed a hotel again. To repay the hotel company, Genos has volunteered to operate an elevator in one of its other hotels. The elevator is special — it starts on the top floor, can only move down, and has infinite capacity. Floors are numbered from 0 to *s* and elevator initially starts on floor...
{"inputs": ["3 7\n2 1\n3 8\n5 2", "5 10\n2 77\n3 33\n8 21\n9 12\n10 64", "1 1000\n1000 1000", "1 1\n1 1", "1 1000\n1 1", "1 1000\n1 1000", "100 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\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...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
179
codeforces
da2f1cf3fd4cb162fa2d6e760291b9b8
Hyperspace Jump (easy)
The Rebel fleet is on the run. It consists of *m* ships currently gathered around a single planet. Just a few seconds ago, the vastly more powerful Empire fleet has appeared in the same solar system, and the Rebels will need to escape into hyperspace. In order to spread the fleet, the captain of each ship has independe...
{"inputs": ["4\n(99+98)/97\n(26+4)/10\n(12+33)/15\n(5+1)/7", "10\n(44+98)/19\n(36+58)/47\n(62+74)/68\n(69+95)/82\n(26+32)/29\n(32+46)/39\n(32+24)/28\n(47+61)/54\n(39+13)/26\n(98+98)/98", "30\n(89+76)/87\n(81+78)/18\n(60+97)/32\n(41+14)/48\n(55+65)/27\n(29+15)/95\n(64+13)/96\n(78+30)/75\n(43+6)/60\n(69+34)/48\n(62+2)/97...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
55
codeforces
da43b3d2628ee657c28f06e7172069e1
Not simply beatiful strings
Let's call a string adorable if its letters can be realigned in such a way that they form two consequent groups of equal symbols (note that different groups must contain different symbols). For example, ababa is adorable (you can transform it to aaabb, where the first three letters form a group of *a*-s and others — a ...
{"inputs": ["ababa", "zzcxx", "yeee", "a", "bbab", "abcd", "abc", "abcdaaaa", "aaaaaaaaaaaaaaa", "adb", "dcccbad", "bcbccccccca", "abcdefgh", "aabcdef", "aabc", "ssab", "ccdd", "abcc", "ab", "abcde", "aa", "aaabbb", "bbbba", "abbbc", "baabaa", "abacabadde", "aabbcc", "abbc", "aaaaaaabbbbbbcder", "aabb", "aabbccddee", "...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
110
codeforces
da5eb88fa07a9f4934cdc5e65e4121a0
Coprocessor
You are given a program you want to execute as a set of tasks organized in a dependency graph. The dependency graph is a directed acyclic graph: each task can depend on results of one or several other tasks, and there are no directed circular dependencies between tasks. A task can only be executed if all tasks it depen...
{"inputs": ["4 3\n0 1 0 1\n0 1\n1 2\n2 3", "4 3\n1 1 1 0\n0 1\n0 2\n3 0", "10 39\n0 1 0 1 0 1 1 0 1 1\n0 1\n0 2\n0 3\n0 4\n0 5\n0 6\n1 2\n1 3\n1 4\n1 5\n1 6\n1 7\n1 8\n1 9\n2 3\n2 4\n2 5\n2 6\n2 7\n2 8\n2 9\n3 4\n3 6\n3 7\n3 8\n3 9\n4 5\n4 6\n4 7\n4 9\n5 6\n5 7\n5 8\n5 9\n6 8\n6 9\n7 8\n7 9\n8 9", "10 16\n0 1 1 0 0 1 1...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
2
codeforces
da6fcb2593d5a371fcd55ed5d106176c
Between the Offices
As you may know, MemSQL has American offices in both San Francisco and Seattle. Being a manager in the company, you travel a lot between the two cities, always by plane. You prefer flying from Seattle to San Francisco than in the other direction, because it's warmer in San Francisco. You are so busy that you don't rem...
{"inputs": ["4\nFSSF", "2\nSF", "10\nFFFFFFFFFF", "10\nSSFFSFFSFF", "20\nSFSFFFFSSFFFFSSSSFSS", "20\nSSFFFFFSFFFFFFFFFFFF", "20\nSSFSFSFSFSFSFSFSSFSF", "20\nSSSSFSFSSFSFSSSSSSFS", "100\nFFFSFSFSFSSFSFFSSFFFFFSSSSFSSFFFFSFFFFFSFFFSSFSSSFFFFSSFFSSFSFFSSFSSSFSFFSFSFFSFSFFSSFFSFSSSSFSFSFSS", "100\nFFFFFFFFFFFFFFFFFFFFFFFFF...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
887
codeforces
da8590f2c736c318d86e744275cbf270
Chips
Gerald plays the following game. He has a checkered field of size *n*<=×<=*n* cells, where *m* various cells are banned. Before the game, he has to put a few chips on some border (but not corner) board cells. Then for *n*<=-<=1 minutes, Gerald every minute moves each chip into an adjacent cell. He moves each chip from ...
{"inputs": ["3 1\n2 2", "3 0", "4 3\n3 1\n3 2\n3 3", "2 1\n1 1", "2 3\n1 2\n2 1\n2 2", "5 1\n3 2", "5 1\n2 3", "1000 0", "999 0", "5 5\n3 2\n5 4\n3 3\n2 3\n1 2", "5 5\n3 2\n1 4\n5 1\n4 5\n3 1", "5 5\n2 2\n5 3\n2 3\n5 1\n4 4", "6 5\n2 6\n6 5\n3 1\n2 2\n1 2", "6 5\n2 6\n5 2\n4 3\n6 6\n2 5", "6 5\n2 1\n6 4\n2 2\n4 3\n4 1"...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
7
codeforces
da8ef89e28fe6467a869a3a606647489
Range Increments
Polycarpus is an amateur programmer. Now he is analyzing a friend's program. He has already found there the function rangeIncrement(l, r), that adds 1 to each element of some array *a* for all indexes in the segment [*l*,<=*r*]. In other words, this function does the following: Polycarpus knows the state of the array...
{"inputs": ["6\n1 2 1 1 4 1", "5\n1 0 1 0 1", "1\n1", "1\n100000", "5\n1 2 3 4 5", "12\n0 1 1 1 3 4 3 3 3 3 2 2", "2\n1 1", "2\n2 1", "2\n1 3", "2\n2 4", "3\n1 1 1", "3\n0 2 1", "3\n2 2 1", "3\n2 4 2", "5\n1 1 0 0 0", "5\n0 0 1 1 0", "5\n1 0 2 1 0", "5\n2 1 2 3 3", "20\n4 5 4 4 3 2 2 1 2 2 2 3 3 4 2 2 2 1 1 1", "20\n1 ...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
3
codeforces
da9eae118d525876722583eb6f68b38b
Cakeminator
You are given a rectangular cake, represented as an *r*<=×<=*c* grid. Each cell either has an evil strawberry, or is empty. For example, a 3<=×<=4 cake may look as follows: The cakeminator is going to eat the cake! Each time he eats, he chooses a row or a column that does not contain any evil strawberries and contains...
{"inputs": ["3 4\nS...\n....\n..S.", "2 2\n..\n..", "2 2\nSS\nSS", "7 3\nS..\nS..\nS..\nS..\nS..\nS..\nS..", "3 5\n..S..\nSSSSS\n..S..", "10 10\nSSSSSSSSSS\nSSSSSSSSSS\nSSSSSSSSSS\nSSSSSSSSSS\nSSSSSSSSSS\nSSSSSSSSSS\nSSSSSSSSSS\nSSSSSSSSSS\nSSSSSSSSSS\nSSSSSSSSSS", "10 10\nS...SSSSSS\nS...SSSSSS\nS...SSSSSS\nS...SSSSSS...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
520
codeforces
dae0c1d757095ab713064ab15b0d198f
Happy Line
Do you like summer? Residents of Berland do. They especially love eating ice cream in the hot summer. So this summer day a large queue of *n* Berland residents lined up in front of the ice cream stall. We know that each of them has a certain amount of berland dollars with them. The residents of Berland are nice people,...
{"inputs": ["2\n11 8", "5\n10 9 7 10 6", "3\n12 3 3", "4\n7 3 9 10", "1\n1", "5\n15 5 8 6 3", "1\n1000000000", "2\n2 1", "3\n11 1 9", "1\n0", "20\n38 32 21 44 26 24 15 32 34 40 31 33 33 13 26 28 12 10 14 18", "20\n43 38 20 41 16 37 27 29 19 17 24 19 28 8 14 32 13 21 32 16", "20\n44 50 41 18 28 31 21 38 12 20 28 15 12 2...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
13
codeforces
db083a6098652bce07324df7bb974915
Sherlock and his girlfriend
Sherlock has a new girlfriend (so unlike him!). Valentine's day is coming and he wants to gift her some jewelry. He bought *n* pieces of jewelry. The *i*-th piece has price equal to *i*<=+<=1, that is, the prices of the jewelry are 2,<=3,<=4,<=... *n*<=+<=1. Watson gave Sherlock a challenge to color these jewelry pie...
{"inputs": ["3", "4", "17", "25", "85", "105", "123", "452", "641", "293", "733", "1", "10", "287", "3202", "728", "3509", "5137", "2023", "4890", "8507", "1796", "3466", "1098", "11226", "11731", "11644", "14553", "17307", "23189", "6818", "1054", "28163", "30885", "27673", "11656", "36325", "31205", "29958", "1696", ...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
127
codeforces
db2e54f81215aad936adfd11356f0fc8
Pair of Numbers
Simon has an array *a*1,<=*a*2,<=...,<=*a**n*, consisting of *n* positive integers. Today Simon asked you to find a pair of integers *l*,<=*r* (1<=≤<=*l*<=≤<=*r*<=≤<=*n*), such that the following conditions hold: 1. there is integer *j* (*l*<=≤<=*j*<=≤<=*r*), such that all integers *a**l*,<=*a**l*<=+<=1,<=...,<=*a**r...
{"inputs": ["5\n4 6 9 3 6", "5\n1 3 5 7 9", "5\n2 3 5 7 11", "1\n1343", "1\n1000000", "1\n5", "1\n1", "2\n1 1000000", "2\n999999 1000000", "5\n3 3 6 2 2"], "outputs": ["1 3\n2 ", "1 4\n1 ", "5 0\n1 2 3 4 5 ", "1 0\n1 ", "1 0\n1 ", "1 0\n1 ", "1 0\n1 ", "1 1\n1 ", "2 0\n1 2 ", "2 2\n1 3 "]}
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
5
codeforces
db75ce1739f74864cfa3c19dc9613c42
New Reform
Berland has *n* cities connected by *m* bidirectional roads. No road connects a city to itself, and each pair of cities is connected by no more than one road. It is not guaranteed that you can get from any city to any other one, using only the existing roads. The President of Berland decided to make changes to the roa...
{"inputs": ["4 3\n2 1\n1 3\n4 3", "5 5\n2 1\n1 3\n2 3\n2 5\n4 3", "6 5\n1 2\n2 3\n4 5\n4 6\n5 6", "4 4\n1 2\n2 3\n3 4\n4 1", "10 45\n3 5\n2 3\n4 8\n2 5\n6 8\n5 7\n2 1\n3 7\n5 10\n6 1\n9 4\n3 6\n9 10\n6 7\n1 7\n7 9\n6 9\n9 3\n4 2\n2 6\n5 6\n5 8\n3 4\n10 8\n7 8\n4 6\n9 1\n5 9\n7 4\n1 10\n9 2\n2 8\n6 10\n9 8\n1 5\n7 2\n10...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
16
codeforces
db7e46473014ad3cea73d78b576463bc
Table
Simon has a rectangular table consisting of *n* rows and *m* columns. Simon numbered the rows of the table from top to bottom starting from one and the columns — from left to right starting from one. We'll represent the cell on the *x*-th row and the *y*-th column as a pair of numbers (*x*,<=*y*). The table corners are...
{"inputs": ["3 3\n0 0 0\n0 1 0\n0 0 0", "4 3\n0 0 0\n0 0 1\n1 0 0\n0 0 0", "50 4\n0 0 0 0\n0 0 0 0\n0 0 0 0\n0 0 0 0\n0 0 0 0\n0 0 0 0\n0 0 0 0\n0 0 0 0\n0 0 0 0\n0 0 0 0\n0 1 0 0\n0 0 0 0\n0 0 0 0\n0 0 0 0\n0 0 0 0\n0 0 0 0\n0 0 0 0\n0 0 0 0\n0 0 0 0\n0 0 0 0\n0 0 0 0\n0 0 0 0\n0 0 0 0\n0 0 0 0\n0 0 0 0\n0 0 0 0\n0 0 ...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
127
codeforces
dba7d865f424682bcd9b24c0a012fd31
Xors on Segments
You are given an array with *n* integers *a**i* and *m* queries. Each query is described by two integers (*l**j*,<=*r**j*). Let's define the function . The function is defined for only *u*<=≤<=*v*. For each query print the maximal value of the function *f*(*a**x*,<=*a**y*) over all *l**j*<=≤<=*x*,<=*y*<=≤<=*r**j*,<= ...
{"inputs": ["6 3\n1 2 3 4 5 6\n1 6\n2 5\n3 4", "1 1\n1\n1 1", "6 20\n10 21312 2314 214 1 322\n1 1\n1 2\n1 3\n1 4\n1 5\n1 6\n2 2\n2 3\n2 4\n2 5\n2 6\n3 4\n3 5\n3 6\n4 4\n4 5\n4 6\n5 5\n5 6\n6 6", "1 1\n1\n1 1", "5 10\n10 2 7 8 8\n2 5\n3 4\n5 5\n1 3\n3 4\n2 2\n2 5\n4 5\n5 5\n1 2"], "outputs": ["7\n7\n7", "1", "10\n21313\...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
1
codeforces
dbc16444769ffff8737f6cd7f40829fd
Party
*n* people came to a party. Then those, who had no friends among people at the party, left. Then those, who had exactly 1 friend among those who stayed, left as well. Then those, who had exactly 2,<=3,<=...,<=*n*<=-<=1 friends among those who stayed by the moment of their leaving, did the same. What is the maximum amo...
{"inputs": ["1\n3"], "outputs": ["1"]}
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
43
codeforces
dbc7d5ef45096d9e8efa03e27e9f8068
Olya and Energy Drinks
Olya loves energy drinks. She loves them so much that her room is full of empty cans from energy drinks. Formally, her room can be represented as a field of *n*<=×<=*m* cells, each cell of which is empty or littered with cans. Olya drank a lot of energy drink, so now she can run *k* meters per second. Each second she...
{"inputs": ["3 4 4\n....\n###.\n....\n1 1 3 1", "3 4 1\n....\n###.\n....\n1 1 3 1", "2 2 1\n.#\n#.\n1 1 2 2", "10 10 1\n##########\n#.........\n#.#######.\n#.#.....#.\n#.#.###.#.\n#.#.#.#.#.\n#.#.#.#.#.\n#.#.#...#.\n#.#.#####.\n#.#.......\n6 6 10 2", "10 10 3\n##########\n##########\n##########\n##########\n##########\...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
6
codeforces
dbcbc232b85bbf107db4ffb4922cc8f3
Puzzling Language
In this problem you will write a simple code generator for a 2D programming language derived from [Brainfuck](https://en.wikipedia.org/wiki/Brainfuck). The code in this language is a rectangular grid of characters '.' and 'X'. The code is converted to a Brainfuck program as follows: the characters are read in the usua...
{"inputs": ["$$$", "Codeforces", "!\"#$%&'()*", "zyxwvutsrq", "z", "!", "Q", "\\RM3uy$>", "fQs1@=", "%n<VD0Q=eO", "[=iG", "&o+(", "9IHC0", ">,05jka@?", "j0&)@0=", "ouuj0an8;", "\\ZN).!R$N<", "4]", "YYiu0", "3^7Ib`nt^\"", "WnX/v-1&", "<Zno", "&.Uv", "4Vo", "R8", "uNC", "*)f>H.;!P", "=veAmKR]N'", "\\RD?XXd", "\"8c]Q@6&e"...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
5
codeforces
dbf788c2f5d9376e093d86306456040f
Dima and To-do List
You helped Dima to have a great weekend, but it's time to work. Naturally, Dima, as all other men who have girlfriends, does everything wrong. Inna and Dima are now in one room. Inna tells Dima off for everything he does in her presence. After Inna tells him off for something, she goes to another room, walks there in ...
{"inputs": ["6 2\n3 2 1 6 5 4", "10 5\n1 3 5 7 9 9 4 1 8 5", "20 4\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1", "10 10\n8 4 5 7 6 9 2 2 3 5", "50 10\n1 2 3 4 5 6 7 8 9 10 10 1 1 1 1 1 1 1 1 1 10 1 1 1 1 1 1 1 1 1 10 1 1 1 1 1 1 1 1 1 10 1 1 1 1 1 1 1 1 1", "1 1\n1", "2 1\n1 1", "4 2\n2 1 1 3", "15 5\n5 5 5 5 5 1 2 3 4 5 ...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
75
codeforces
dc2aae63f53571f5e0dedbbc0e5197f4
Swapping Characters
We had a string *s* consisting of *n* lowercase Latin letters. We made *k* copies of this string, thus obtaining *k* identical strings *s*1,<=*s*2,<=...,<=*s**k*. After that, in each of these strings we swapped exactly two characters (the characters we swapped could be identical, but they had different indices in the s...
{"inputs": ["3 4\nabac\ncaab\nacba", "3 4\nkbbu\nkbub\nubkb", "5 4\nabcd\ndcba\nacbd\ndbca\nzzzz", "3 2\nxh\nxh\nxh", "3 4\nkbub\nkbbu\nubkb", "1 2\nyu", "1 3\nvts", "2 2\nnm\nnm", "2 3\nghn\nghn", "3 2\ncg\ncg\ncg", "3 3\nuvh\nvhu\nhuv", "100 2\nqz\nqz\nqz\nqz\nqz\nqz\nqz\nqz\nqz\nqz\nqz\nqz\nqz\nqz\nqz\nqz\nqz\nqz\nq...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
1
codeforces
dc300f461142b79d550b3d60d2b8001e
Hag's Khashba
Hag is a very talented person. He has always had an artist inside him but his father forced him to study mechanical engineering. Yesterday he spent all of his time cutting a giant piece of wood trying to make it look like a goose. Anyway, his dad found out that he was doing arts rather than studying mechanics and othe...
{"inputs": ["3 4\n0 0\n2 0\n2 2\n1 1 2\n2 1\n2 2\n2 3", "3 2\n-1 1\n0 0\n1 1\n1 1 2\n2 1", "10 10\n0 -100000000\n1 -100000000\n1566 -99999999\n2088 -99999997\n2610 -99999994\n3132 -99999990\n3654 -99999985\n4176 -99999979\n4698 -99999972\n5220 -99999964\n1 2 5\n2 1\n1 1 7\n2 5\n1 5 4\n1 4 2\n2 8\n1 7 9\n2 1\n1 2 10", "...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
3
codeforces
dc37a49da0b1d0da6a7014102922695b
Sereja and Suffixes
Sereja has an array *a*, consisting of *n* integers *a*1, *a*2, ..., *a**n*. The boy cannot sit and do nothing, he decided to study an array. Sereja took a piece of paper and wrote out *m* integers *l*1,<=*l*2,<=...,<=*l**m* (1<=≤<=*l**i*<=≤<=*n*). For each number *l**i* he wants to know how many distinct numbers are s...
{"inputs": ["10 10\n1 2 3 4 1 2 3 4 100000 99999\n1\n2\n3\n4\n5\n6\n7\n8\n9\n10", "8 3\n8 6 4 3 4 2 4 8\n6\n4\n2", "7 10\n1 3 8 6 2 2 7\n4\n2\n6\n3\n4\n4\n6\n2\n7\n4", "10 2\n2 6 5 7 2 2 3 2 4 8\n1\n2", "7 1\n68346 10956 76708 23018 84063 34833 80407\n1", "2 2\n8 4\n1\n1", "1 5\n5\n1\n1\n1\n1\n1", "4 7\n3 1 4 2\n4\n1\n...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
314
codeforces
dc8e5f65bf595e4b9d2f2ca02084f9da
MADMAX
As we all know, Max is the best video game player among her friends. Her friends were so jealous of hers, that they created an actual game just to prove that she's not the best at games. The game is played on a directed acyclic graph (a DAG) with *n* vertices and *m* edges. There's a character written on each edge, a l...
{"inputs": ["4 4\n1 2 b\n1 3 a\n2 4 c\n3 4 b", "5 8\n5 3 h\n1 2 c\n3 1 c\n3 2 r\n5 1 r\n4 3 z\n5 4 r\n5 2 h", "2 1\n1 2 q", "8 20\n2 4 a\n1 8 a\n1 2 v\n8 4 h\n1 7 w\n5 4 h\n2 8 h\n7 4 i\n4 3 w\n6 8 l\n1 4 v\n1 3 g\n5 3 b\n1 6 a\n7 3 w\n6 4 f\n6 7 g\n7 8 n\n5 8 g\n2 6 j", "3 2\n1 3 l\n2 1 v", "100 1\n92 93 p"], "outputs...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
5
codeforces
dc9dc468e2c937fdd3ca5379031d8341
Fingerprints
You are locked in a room with a door that has a keypad with 10 keys corresponding to digits from 0 to 9. To escape from the room, you need to enter a correct code. You also have a sequence of digits. Some keys on the keypad have fingerprints. You believe the correct code is the longest not necessarily contiguous subse...
{"inputs": ["7 3\n3 5 7 1 6 2 8\n1 2 7", "4 4\n3 4 1 0\n0 1 7 9", "9 4\n9 8 7 6 5 4 3 2 1\n2 4 6 8", "10 5\n3 7 1 2 4 6 9 0 5 8\n4 3 0 7 9", "10 10\n1 2 3 4 5 6 7 8 9 0\n4 5 6 7 1 2 3 0 9 8", "1 1\n4\n4", "3 7\n6 3 4\n4 9 0 1 7 8 6", "10 1\n9 0 8 1 7 4 6 5 2 3\n0", "5 10\n6 0 3 8 1\n3 1 0 5 4 7 2 8 9 6", "8 2\n7 2 9 6 ...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
645
codeforces
dcec153142741226f333194eb0ae6f7c
Careful Maneuvering
There are two small spaceship, surrounded by two groups of enemy larger spaceships. The space is a two-dimensional plane, and one group of the enemy spaceships is positioned in such a way that they all have integer $y$-coordinates, and their $x$-coordinate is equal to $-100$, while the second group is positioned in suc...
{"inputs": ["3 9\n1 2 3\n1 2 3 7 8 9 11 12 13", "5 5\n1 2 3 4 5\n1 2 3 4 5", "50 50\n744 333 562 657 680 467 357 376 759 311 371 327 369 172 286 577 446 922 16 69 350 92 627 852 878 733 148 857 663 969 131 250 563 665 67 169 178 625 975 457 414 434 146 602 235 86 240 756 161 675\n222 371 393 634 76 268 348 294 227 429 ...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
3
codeforces
dcfbb6638db328393fdcbc6d1ec406d6
Lucky Sum
Petya loves lucky numbers. Everybody knows that lucky numbers are positive integers whose decimal representation contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Let *next*(*x*) be the minimum lucky number which is larger than or equals *x*. Petya is interested ...
{"inputs": ["2 7", "7 7", "1 9", "4 7", "12 47", "6 77", "1 100", "1000000000 1000000000", "77 77", "69 788", "474 747", "4 77777", "1 1000000", "47 744447", "47444 1000000000", "48 854888", "854444 985555", "774744 774747", "654 987654", "477777 1000000000", "77777 777777777", "963 85555574", "47 7444", "1 1000000000"...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
76
codeforces
dcffb99df12778203441b22c7fe377c7
Jzzhu and Numbers
Jzzhu have *n* non-negative integers *a*1,<=*a*2,<=...,<=*a**n*. We will call a sequence of indexes *i*1,<=*i*2,<=...,<=*i**k* (1<=≤<=*i*1<=&lt;<=*i*2<=&lt;<=...<=&lt;<=*i**k*<=≤<=*n*) a group of size *k*. Jzzhu wonders, how many groups exists such that *a**i*1 &amp; *a**i*2 &amp; ... &amp; *a**i**k*<==<=0 (1<=≤<=*k*...
{"inputs": ["3\n2 3 3", "4\n0 1 2 3", "6\n5 2 0 5 2 1", "16\n0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15", "10\n450661 128600 993228 725823 293549 33490 843121 903634 556169 448234", "1\n0", "1\n1", "6\n524 529 5249 524 529 529", "55\n0 1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 9 2 3 4 5 6 7 8 9 3 4 5 6 7 8 9 4 5 6 7 8 9 5 6 7 8 9 6...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
6
codeforces
dd23dd1684258e60b52f6529bf828f6c
Amusing Joke
So, the New Year holidays are over. Santa Claus and his colleagues can take a rest and have guests at last. When two "New Year and Christmas Men" meet, thear assistants cut out of cardboard the letters from the guest's name and the host's name in honor of this event. Then the hung the letters above the main entrance. O...
{"inputs": ["SANTACLAUS\nDEDMOROZ\nSANTAMOROZDEDCLAUS", "PAPAINOEL\nJOULUPUKKI\nJOULNAPAOILELUPUKKI", "BABBONATALE\nFATHERCHRISTMAS\nBABCHRISTMASBONATALLEFATHER", "B\nA\nAB", "ONDOL\nJNPB\nONLNJBODP", "Y\nW\nYW", "OI\nM\nIMO", "VFQRWWWACX\nGHZJPOQUSXRAQDGOGMR\nOPAWDOUSGWWCGQXXQAZJRQRGHRMVF", "JUTCN\nPIGMZOPMEUFADQBW\nN...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
789
codeforces
dd26a1454c8815b3a6c8070afb3087a8
Road to Post Office
Vasiliy has a car and he wants to get from home to the post office. The distance which he needs to pass equals to *d* kilometers. Vasiliy's car is not new — it breaks after driven every *k* kilometers and Vasiliy needs *t* seconds to repair it. After repairing his car Vasiliy can drive again (but after *k* kilometers ...
{"inputs": ["5 2 1 4 10", "5 2 1 4 5", "1 1 1 2 1", "1000000000000 1000000 999999 1000000 1000000", "997167959139 199252 232602 952690 802746", "244641009859 748096 689016 889744 927808", "483524125987 264237 209883 668942 244358", "726702209411 813081 730750 893907 593611", "965585325539 329221 187165 817564 718673", ...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
8
codeforces
dd382f408ce546f2af364af2e0257c42
Levels and Regions
Radewoosh is playing a computer game. There are *n* levels, numbered 1 through *n*. Levels are divided into *k* regions (groups). Each region contains some positive number of consecutive levels. The game repeats the the following process: 1. If all regions are beaten then the game ends immediately. Otherwise, the sys...
{"inputs": ["4 2\n100 3 5 7", "6 2\n1 2 4 8 16 32", "10 5\n47 56 21 20 50 47 26 10 57 58", "10 5\n39 49 99 91 66 14 32 26 83 49", "20 3\n71 85 56 41 96 52 11 71 59 8 63 87 91 51 40 60 41 59 34 93", "20 4\n25 66 10 18 67 40 66 49 3 51 61 29 10 72 71 22 63 4 74 67", "20 5\n79 44 59 91 54 28 30 35 42 95 56 58 29 89 93 73 ...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
1
codeforces
dd4ab5a1ab3442824ebf7d06e96b723b
Kicker
Kicker (table football) is a board game based on football, in which players control the footballers' figures mounted on rods by using bars to get the ball into the opponent's goal. When playing two on two, one player of each team controls the goalkeeper and the full-backs (plays defence), the other player controls the ...
{"inputs": ["1 100\n100 1\n99 99\n99 99", "1 1\n2 2\n3 3\n2 2", "3 3\n2 2\n1 1\n2 2", "80 79\n79 30\n80 81\n40 80", "10 10\n4 9\n8 9\n7 6", "10 2\n9 3\n3 1\n9 4", "6 3\n6 10\n2 5\n4 4", "8 7\n1 5\n7 4\n8 8", "2 7\n8 4\n4 6\n10 8", "8 3\n4 9\n6 1\n5 6", "10 5\n3 1\n1 9\n1 2", "6 5\n10 6\n8 1\n3 2", "6 2\n7 5\n5 4\n8 6",...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
15
codeforces
dd6ed2b719807458cc8a9b1d59a13cfd
Maximum Subsequence
You are given an array *a* consisting of *n* integers, and additionally an integer *m*. You have to choose some sequence of indices *b*1,<=*b*2,<=...,<=*b**k* (1<=≤<=*b*1<=&lt;<=*b*2<=&lt;<=...<=&lt;<=*b**k*<=≤<=*n*) in such a way that the value of is maximized. Chosen sequence can be empty. Print the maximum possibl...
{"inputs": ["4 4\n5 2 4 1", "3 20\n199 41 299", "5 10\n47 100 49 2 56", "5 1000\n38361 75847 14913 11499 8297", "10 10\n48 33 96 77 67 59 35 15 14 86", "10 1000\n16140 63909 7177 99953 35627 40994 29288 7324 44476 36738", "30 10\n99 44 42 36 43 82 99 99 10 79 97 84 5 78 37 45 87 87 11 11 79 66 47 100 8 50 27 98 32 27",...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
21
codeforces
dd7a7a3defc3f56ae33425c26d2916d1
DZY Loves Hash
DZY has a hash table with *p* buckets, numbered from 0 to *p*<=-<=1. He wants to insert *n* numbers, in the order they are given, into the hash table. For the *i*-th number *x**i*, DZY will put it into the bucket numbered *h*(*x**i*), where *h*(*x*) is the hash function. In this problem we will assume, that *h*(*x*)<==...
{"inputs": ["10 5\n0\n21\n53\n41\n53", "5 5\n0\n1\n2\n3\n4", "10 6\n811966798\n734823552\n790326404\n929189974\n414343256\n560346537", "2 2\n788371161\n801743052", "10 6\n812796223\n122860157\n199259103\n597650585\n447742024\n521549402", "300 2\n822454942\n119374431", "300 2\n823284367\n507345500", "2 5\n791579811\n356...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
212
codeforces
dd967a53482a424ba1d1d758c4d3a4a0
An abandoned sentiment from past
A few years ago, Hitagi encountered a giant crab, who stole the whole of her body weight. Ever since, she tried to avoid contact with others, for fear that this secret might be noticed. To get rid of the oddity and recover her weight, a special integer sequence is needed. Hitagi's sequence has been broken for a long t...
{"inputs": ["4 2\n11 0 0 14\n5 4", "6 1\n2 3 0 8 9 10\n5", "4 1\n8 94 0 4\n89", "7 7\n0 0 0 0 0 0 0\n1 2 3 4 5 6 7", "40 1\n23 26 27 28 31 35 38 40 43 50 52 53 56 57 59 61 65 73 75 76 79 0 82 84 85 86 88 93 99 101 103 104 105 106 110 111 112 117 119 120\n80", "100 1\n99 95 22 110 47 20 37 34 23 0 16 69 64 49 111 42 112...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
246
codeforces
ddda23f7ef553a81823a6b2e7064dfe1
USB vs. PS/2
Due to the increase in the number of students of Berland State University it was decided to equip a new computer room. You were given the task of buying mouses, and you have to spend as little as possible. After all, the country is in crisis! The computers bought for the room were different. Some of them had only USB ...
{"inputs": ["2 1 1\n4\n5 USB\n6 PS/2\n3 PS/2\n7 PS/2", "1 4 4\n12\n36949214 USB\n683538043 USB\n595594834 PS/2\n24951774 PS/2\n131512123 USB\n327575645 USB\n30947411 USB\n916758386 PS/2\n474310330 USB\n350512489 USB\n281054887 USB\n875326145 USB", "3 0 3\n0", "1 2 4\n12\n257866589 PS/2\n246883568 USB\n104396128 USB\n99...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
42
codeforces
ddec47bec5554b2e632d663d5064df4e
Sea Battle
Galya is playing one-dimensional Sea Battle on a 1<=×<=*n* grid. In this game *a* ships are placed on the grid. Each of the ships consists of *b* consecutive cells. No cell can be part of two ships, however, the ships can touch each other. Galya doesn't know the ships location. She can shoot to some cells and after ea...
{"inputs": ["5 1 2 1\n00100", "13 3 2 3\n1000000010001", "1 1 1 0\n0", "2 2 1 0\n00", "5 4 1 0\n00000", "10 2 2 0\n0000000000", "20 1 3 5\n01001010000000010010", "100 17 4 11\n0100000100000000000000001000000000010001100000000000101000000000000000000000001000001000010000000000"], "outputs": ["2\n2 5 ", "2\n3 5 ", "1\n1 ...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
28
codeforces
ddf9a9ecc2e1e7a99780d4ed3a38540f
Shortest Path Queries
You are given an undirected connected graph with weighted edges. The length of some path between two vertices is the bitwise xor of weights of all edges belonging to this path (if some edge is traversed more than once, then it is included in bitwise xor the same number of times). There are three types of queries you ...
{"inputs": ["5 5\n1 2 3\n2 3 4\n3 4 5\n4 5 6\n1 5 1\n5\n3 1 5\n1 1 3 1\n3 1 5\n2 1 5\n3 1 5"], "outputs": ["1\n1\n2"]}
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
1
codeforces
de1be60077eb96d5bef6f2b195c6890c
Dreamoon and Stairs
Dreamoon wants to climb up a stair of *n* steps. He can climb 1 or 2 steps at each move. Dreamoon wants the number of moves to be a multiple of an integer *m*. What is the minimal number of moves making him climb to the top of the stairs that satisfies his condition? The single line contains two space separated integ...
{"inputs": ["10 2", "3 5", "29 7", "2 2", "1 2", "10000 2", "10000 3", "10000 10", "9999 3", "9999 2", "9999 10", "9999 9", "18 10", "19 10", "20 10", "21 10", "7688 5", "4608 5", "3979 2", "9985 6", "3230 8", "24 9", "3275 8", "6240 7", "5227 4", "3832 6", "4 2", "6 3", "10 5", "3 2", "6 4", "5 2", "8 2", "9 9", "4 5"...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
261
codeforces
de529027519466567e75557d762da495
Magic Spheres
Carl is a beginner magician. He has *a* blue, *b* violet and *c* orange magic spheres. In one move he can transform two spheres of the same color into one sphere of any other color. To make a spell that has never been seen before, he needs at least *x* blue, *y* violet and *z* orange spheres. Can he get them (possible,...
{"inputs": ["4 4 0\n2 1 2", "5 6 1\n2 7 2", "3 3 3\n2 2 2", "0 0 0\n0 0 0", "0 0 0\n0 0 1", "0 1 0\n0 0 0", "1 0 0\n1 0 0", "2 2 1\n1 1 2", "1 3 1\n2 1 1", "1000000 1000000 1000000\n1000000 1000000 1000000", "1000000 500000 500000\n0 750000 750000", "500000 1000000 500000\n750001 0 750000", "499999 500000 1000000\n7500...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
131
codeforces
de6126ca010eecf21706ad036f0b3f16
PolandBall and White-Red graph
PolandBall has an undirected simple graph consisting of *n* vertices. Unfortunately, it has no edges. The graph is very sad because of that. PolandBall wanted to make it happier, adding some red edges. Then, he will add white edges in every remaining place. Therefore, the final graph will be a clique in two colors: whi...
{"inputs": ["4 1", "5 2", "500 3", "1000 2", "10 2", "590 3", "1000 5", "5 3", "100 49", "4 2", "4 3", "5 4", "5 1", "7 2", "1000 1", "1000 3", "1000 4", "999 1", "999 2", "999 3", "999 4", "999 5", "8 2", "9 2", "6 3", "7 3", "8 3", "9 3", "10 3", "527 2", "218 2", "565 2", "11 2", "237 2", "107 2", "494 2", "40 2", "...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
2
codeforces
de907226bd55c2ddee0d451765d2e50c
Ralph and Mushrooms
Ralph is going to collect mushrooms in the Mushroom Forest. There are *m* directed paths connecting *n* trees in the Mushroom Forest. On each path grow some mushrooms. When Ralph passes a path, he collects all the mushrooms on the path. The Mushroom Forest has a magical fertile ground where mushrooms grow at a fantas...
{"inputs": ["2 2\n1 2 4\n2 1 4\n1", "3 3\n1 2 4\n2 3 3\n1 3 8\n1", "1 0\n1"], "outputs": ["16", "8", "0"]}
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
2
codeforces
de95ee4db2f47d9dd85262de180228c9
Olympic Medal
The World Programming Olympics Medal is a metal disk, consisting of two parts: the first part is a ring with outer radius of *r*1 cm, inner radius of *r*2 cm, (0<=&lt;<=*r*2<=&lt;<=*r*1) made of metal with density *p*1 g/cm3. The second part is an inner disk with radius *r*2 cm, it is made of metal with density *p*2 g/...
{"inputs": ["3 1 2 3\n1 2\n3 3 2 1\n1 2", "4 2 3 6 4\n2 1 2\n3 10 6 8\n2 1", "1 5\n1 3\n1 7\n515 892", "2 3 2\n3 2 3 1\n2 2 1\n733 883", "2 4 2\n3 1 2 3\n2 2 3\n676 769", "2 4 2\n3 2 3 1\n2 3 1\n772 833", "2 1 2\n3 2 3 1\n2 1 3\n452 219", "2 3 2\n3 3 2 1\n2 3 2\n417 202", "2 1 2\n3 1 2 3\n2 3 2\n596 206", "2 1 2\n3 3 1...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
111
codeforces
deed43691dc1ca42f8825b9adbcbbdef
Dense Subsequence
You are given a string *s*, consisting of lowercase English letters, and the integer *m*. One should choose some symbols from the given string so that any contiguous subsegment of length *m* has at least one selected symbol. Note that here we choose positions of symbols, not the symbols themselves. Then one uses the ...
{"inputs": ["3\ncbabc", "2\nabcab", "3\nbcabcbaccba", "5\nimmaydobun", "5\nwjjdqawypvtgrncmqvcsergermprauyevcegjtcrrblkwiugrcjfpjyxngyryxntauxlouvwgjzpsuxyxvhavgezwtuzknetdibv", "10\nefispvmzuutsrpxzfrykhabznxiyquwvhwhrksrgzodtuepfvamilfdynapzhzyhncorhzuewrrkcduvuhwsrprjrmgctnvrdtpj", "20\nhlicqhxayiodyephxlfoetfketnaa...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
7
codeforces
df24cb0120d4b4002bc23bc05b50de93
Cloud of Hashtags
Vasya is an administrator of a public page of organization "Mouse and keyboard" and his everyday duty is to publish news from the world of competitive programming. For each news he also creates a list of hashtags to make searching for a particular topic more comfortable. For the purpose of this problem we define hashta...
{"inputs": ["3\n#book\n#bigtown\n#big", "3\n#book\n#cool\n#cold", "4\n#car\n#cart\n#art\n#at", "3\n#apple\n#apple\n#fruit", "1\n#h", "2\n#y\n#q", "3\n#sima\n#simb\n#sima", "1\n#lxqnqdnkpeayhxh", "6\n#abu\n#abc\n#ac\n#bk\n#bmm\n#bb", "7\n#a\n#aab\n#abc\n#abq\n#ab\n#ac\n#z", "15\n#a\n#a\n#b\n#c\n#e\n#i\n#k\n#m\n#o\n#r\n#...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
21
codeforces
df35371b016a964a5bd7dcf6fa8d0ecd
Dome
The input contains a single floating-point number *x* with exactly 6 decimal places (0<=&lt;<=*x*<=&lt;<=5). Output two integers separated by a single space. Each integer should be between 1 and 10, inclusive. If several solutions exist, output any of them. Solution will exist for all tests. Sample Input 1.200000 2.57...
{"inputs": ["1.200000", "2.572479", "4.024922", "0.447214", "0.493197", "0.496139", "0.498273", "0.499026", "0.499230", "0.499376", "0.832050", "0.894427", "0.948683", "0.976187", "0.986394", "0.989949", "0.993884", "1.404494", "1.483405", "1.561738", "1.736486", "1.920553", "1.923048", "1.940285", "2.121320", "2.27777...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
7
codeforces
df7bd7b4c72c71c76502c093a86fd21f
Optical Experiment
Professor Phunsuk Wangdu has performed some experiments on rays. The setup for *n* rays is as follows. There is a rectangular box having exactly *n* holes on the opposite faces. All rays enter from the holes of the first side and exit from the holes of the other side of the box. Exactly one ray can enter or exit from ...
{"inputs": ["5\n1 4 5 2 3\n3 4 2 1 5", "3\n3 1 2\n2 3 1", "5\n1 2 4 5 3\n1 5 4 2 3", "3\n3 1 2\n1 3 2", "7\n1 5 2 7 4 3 6\n6 3 1 2 5 4 7", "4\n1 4 2 3\n2 3 1 4", "4\n2 4 1 3\n2 3 1 4", "10\n4 7 8 1 2 3 5 9 6 10\n6 3 8 7 10 2 1 4 5 9", "7\n1 5 7 2 4 3 6\n3 2 5 7 6 1 4", "9\n1 7 4 9 3 8 2 5 6\n8 4 7 1 3 2 9 6 5", "5\n1 4...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
3
codeforces
df928cfd18ea2303b90a1ab6e9203bda
Nastya and a Game
Nastya received one more array on her birthday, this array can be used to play a traditional Byteland game on it. However, to play the game the players should first select such a subsegment of the array that , where *p* is the product of all integers on the given array, *s* is their sum, and *k* is a given constant for...
{"inputs": ["1 1\n1", "4 2\n6 3 8 1", "94 58\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 29 58 1 1 1 29 58 58 1 1 29 1 1 1 1 2 1 58 1 1 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 1 1 1 29 1 1 1 1 1 58 1 29 1 1 1 1 1 1 1 1 1 1 1 1 58 1 1 1 1 1 2 1 1 1", "6 76\n1 38 1 1 1 1", "16 53\n53 1 1 1 1 1 53 1 1 1 1 1 1 1 1 1", "13 16\...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
5
codeforces
df97b5535fa90dfe37d6d91ebf948021
Brand New Easy Problem
A widely known among some people Belarusian sport programmer Lesha decided to make some money to buy a one square meter larger flat. To do this, he wants to make and carry out a Super Rated Match (SRM) on the site Torcoder.com. But there's a problem — a severe torcoder coordinator Ivan does not accept any Lesha's probl...
{"inputs": ["4\nfind the next palindrome\n1\n10 find the previous palindrome or print better luck next time", "3\nadd two numbers\n3\n1 add\n2 two two\n3 numbers numbers numbers", "4\nthese papers are formulas\n3\n6 what are these formulas and papers\n5 papers are driving me crazy\n4 crazy into the night", "3\nadd two ...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
1
codeforces
df9a647d53279e1dac6634dddd5e6756
Timofey and a tree
Each New Year Timofey and his friends cut down a tree of *n* vertices and bring it home. After that they paint all the *n* its vertices, so that the *i*-th vertex gets color *c**i*. Now it's time for Timofey birthday, and his mother asked him to remove the tree. Timofey removes the tree in the following way: he takes ...
{"inputs": ["4\n1 2\n2 3\n3 4\n1 2 1 1", "3\n1 2\n2 3\n1 2 3", "4\n1 2\n2 3\n3 4\n1 2 1 2", "3\n2 1\n2 3\n1 2 3", "4\n1 2\n2 4\n4 3\n1 1 3 2", "2\n1 2\n1 1", "10\n5 7\n4 5\n10 2\n3 6\n1 2\n3 4\n8 5\n4 9\n2 3\n15 15 15 15 5 15 26 18 15 15", "8\n1 2\n1 3\n3 5\n3 6\n1 4\n4 7\n4 8\n1 3 1 1 1 1 1 2", "3\n2 1\n2 3\n4 4 4", "...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
42
codeforces
dfce938d392bea22ed9c82eaa6a4d150
none
Currently Tiny is learning Computational Geometry. When trying to solve a problem called "The Closest Pair Of Points In The Plane", he found that a code which gave a wrong time complexity got Accepted instead of Time Limit Exceeded. The problem is the follows. Given *n* points in the plane, find a pair of points betwe...
{"inputs": ["4 3", "2 100", "5 6", "8 20", "6 15", "1808 505823289", "1850 507001807", "1892 948371814", "1788 94774524", "1947 944738707", "1989 367830", "1885 1096142", "1854 631695", "1750 215129", "1792 341122", "1834 1680860", "1657 1371995", "1699 1442450", "1595 1271214", "2000 1998999", "2000 1000000000", "2 1"...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
20
codeforces
dfd3423b46d9ac875c40fdb6e3391bae
Vasya and Basketball
Vasya follows a basketball game and marks the distances from which each team makes a throw. He knows that each successful throw has value of either 2 or 3 points. A throw is worth 2 points if the distance it was made from doesn't exceed some value of *d* meters, and a throw is worth 3 points if the distance is larger t...
{"inputs": ["3\n1 2 3\n2\n5 6", "5\n6 7 8 9 10\n5\n1 2 3 4 5", "5\n1 2 3 4 5\n5\n6 7 8 9 10", "3\n1 2 3\n3\n6 4 5", "10\n1 2 3 4 5 6 7 8 9 10\n1\n11", "10\n1 2 3 4 5 6 7 8 9 11\n1\n10", "3\n1 2 3\n3\n1 2 3", "3\n1 2 3\n3\n3 4 5", "4\n2 5 3 2\n4\n1 5 6 2", "2\n3 3\n3\n1 3 3", "3\n1 1 1\n4\n1 3 1 1", "4\n4 2 1 1\n4\n3 2 ...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
41
codeforces
dfdb6ca43f21c375705818cab533efac
Follow Traffic Rules
Everybody knows that the capital of Berland is connected to Bercouver (the Olympic capital) by a direct road. To improve the road's traffic capacity, there was placed just one traffic sign, limiting the maximum speed. Traffic signs in Berland are a bit peculiar, because they limit the speed only at that point on the ro...
{"inputs": ["1 1\n2 1 3", "5 70\n200 170 40", "6 80\n100 50 10", "7 80\n100 50 50", "8 80\n100 50 199", "200 1000\n3 2 1", "200 1000\n3 2 10000", "200 1000\n1000 500 1023", "200 1000\n1000 999 10", "20 40\n10000 1 30", "20 40\n10000 799 30", "20 40\n9958 9799 30", "9998 9999\n3 2 1", "9998 9999\n3 2 6580", "9998 9999\n...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
13
codeforces
dff35cfccaed3049a7d8dbccfbbaef3d
Divisibility
Find the number of *k*-divisible numbers on the segment [*a*,<=*b*]. In other words you need to find the number of such integer values *x* that *a*<=≤<=*x*<=≤<=*b* and *x* is divisible by *k*. The only line contains three space-separated integers *k*, *a* and *b* (1<=≤<=*k*<=≤<=1018;<=-<=1018<=≤<=*a*<=≤<=*b*<=≤<=1018)....
{"inputs": ["1 1 10", "2 -4 4", "1 1 1", "1 0 0", "1 0 1", "1 10181 10182", "1 10182 10183", "1 -191 1011", "2 0 0", "2 0 1", "2 1 2", "2 2 3", "2 -1 0", "2 -1 1", "2 -7 -6", "2 -7 -5", "2 -6 -6", "2 -6 -4", "2 -6 13", "2 -19171 1911", "3 123 456", "3 124 456", "3 125 456", "3 381 281911", "3 381 281912", "3 381 281913...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
89
codeforces
e002199dc05266707d905a6b35037cc1
Multiplication Table
Let's consider a table consisting of *n* rows and *n* columns. The cell located at the intersection of *i*-th row and *j*-th column contains number *i*<=×<=*j*. The rows and columns are numbered starting from 1. You are given a positive integer *x*. Your task is to count the number of cells in a table that contain num...
{"inputs": ["10 5", "6 12", "5 13", "1 1", "2 1", "100000 1", "1 1000000000", "100000 1000000000", "100000 362880", "1 4", "9 12", "10 123", "9551 975275379", "17286 948615687", "58942 936593001", "50000 989460910", "22741 989460910", "22740 989460910", "100000 989460910", "100000 98280", "100000 997920", "100000 72072...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
257
codeforces
e0304ed0a9986c1e8d9720575bb720bb
Alena's Schedule
Alena has successfully passed the entrance exams to the university and is now looking forward to start studying. One two-hour lesson at the Russian university is traditionally called a pair, it lasts for two academic hours (an academic hour is equal to 45 minutes). The University works in such a way that every day it...
{"inputs": ["5\n0 1 0 1 1", "7\n1 0 1 0 0 1 0", "1\n0", "1\n1", "2\n0 0", "2\n0 1", "2\n1 0", "2\n1 1", "10\n0 0 0 0 0 0 0 0 0 0", "9\n1 1 1 1 1 1 1 1 1", "11\n0 0 0 0 0 0 0 0 0 0 1", "12\n1 0 0 0 0 0 0 0 0 0 0 0", "20\n1 1 0 1 1 1 1 1 1 1 1 0 1 1 1 0 0 1 0 0", "41\n1 1 0 1 0 1 0 0 1 0 1 1 1 0 0 0 1 1 1 0 1 0 1 1 0 1 0...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
171
codeforces
e032edaee261e97dbb910310c3e107a9
Ternary Logic
Little Petya very much likes computers. Recently he has received a new "Ternatron IV" as a gift from his mother. Unlike other modern computers, "Ternatron IV" operates with ternary and not binary logic. Petya immediately wondered how the *xor* operation is performed on this computer (and whether there is anything like ...
{"inputs": ["14 34", "50 34", "387420489 225159023", "5 5", "23476 23875625", "11111 10101010", "1 23865354", "0 0", "2376234 0", "1 0", "581130733 0", "581131733 1", "0 1000000000", "1000000000 0", "1000000000 100000000", "956747697 9487", "229485033 8860", "5341 813849430", "227927516 956217829", "390 380875228", "33...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
5
codeforces
e0332eac78721837186baef3409b2d7d
Vile Grasshoppers
The weather is fine today and hence it's high time to climb the nearby pine and enjoy the landscape. The pine's trunk includes several branches, located one above another and numbered from 2 to *y*. Some of them (more precise, from 2 to *p*) are occupied by tiny vile grasshoppers which you're at war with. These grassh...
{"inputs": ["3 6", "3 4", "2 2", "5 50", "944192806 944193066", "1000000000 1000000000", "2 1000000000", "28788 944193066", "49 52", "698964997 734575900", "287894773 723316271", "171837140 733094070", "37839169 350746807", "125764821 234689174", "413598841 430509920", "145320418 592508508", "155098216 476450875", "459...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
41
codeforces
e047d6f8c864250517f98173e0289925
Prairie Partition
It can be shown that any positive integer *x* can be uniquely represented as *x*<==<=1<=+<=2<=+<=4<=+<=...<=+<=2*k*<=-<=1<=+<=*r*, where *k* and *r* are integers, *k*<=≥<=0, 0<=&lt;<=*r*<=≤<=2*k*. Let's call that representation prairie partition of *x*. For example, the prairie partitions of 12, 17, 7 and 1 are: 17<...
{"inputs": ["8\n1 1 2 2 3 4 5 8", "6\n1 1 1 2 2 2", "5\n1 2 4 4 4", "20\n1 1 1 1 2 2 2 2 4 4 4 4 8 8 8 8 8 10 10 11", "20\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2", "25\n1 1 1 1 2 2 2 2 4 4 4 4 8 8 8 8 13 15 16 16 31 32 36 41 55", "25\n1 1 1 1 2 2 2 2 4 4 4 4 8 8 8 9 16 16 32 40 43 53 61 64 128", "45\n1 1 1 1 1 2 2 2 2...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
4
codeforces
e06260a867da74744d2211c1c54a8ad6
Barcode
You've got an *n*<=×<=*m* pixel picture. Each pixel can be white or black. Your task is to change the colors of as few pixels as possible to obtain a barcode picture. A picture is a barcode if the following conditions are fulfilled: - All pixels in each column are of the same color. - The width of each monochrome ...
{"inputs": ["6 5 1 2\n##.#.\n.###.\n###..\n#...#\n.##.#\n###..", "10 5 3 7\n.####\n###..\n##.##\n#..#.\n.#...\n#.##.\n.##..\n.#.##\n#.#..\n.#..#", "6 3 1 4\n##.\n#..\n#..\n..#\n.#.\n#.#", "5 10 4 16\n.#####....\n##..#..##.\n.#..##.#..\n##..#####.\n...#.##..#", "5 4 1 4\n####\n..##\n##..\n..#.\n#..#", "1 1 1 2\n.", "3 4...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
31
codeforces
e066aeeb5f5b265ec4c40aa35e1d99b3
Easy Tape Programming
There is a programming language in which every program is a non-empty sequence of "&lt;" and "&gt;" signs and digits. Let's explain how the interpreter of this programming language works. A program is interpreted using movement of instruction pointer (IP) which consists of two parts. - Current character pointer (CP);...
{"inputs": ["7 4\n1>3>22<\n1 3\n4 7\n7 7\n1 7", "5 2\n>>>>>\n1 5\n1 2", "1 3\n9\n1 1\n1 1\n1 1", "7 1\n0101010\n1 7", "10 30\n306<<>4>04\n2 2\n6 6\n1 10\n1 8\n2 4\n9 10\n2 8\n3 5\n7 7\n2 6\n1 3\n3 7\n4 9\n3 10\n5 9\n7 10\n1 3\n5 7\n4 10\n6 10\n6 7\n4 5\n3 4\n4 6\n4 7\n7 9\n4 6\n2 8\n1 5\n2 6", "17 21\n187<9>82<818<4229...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
5
codeforces