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
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
d919c3dbfa754f9bf126bdc7d28bb833
Benches
The city park of IT City contains *n* east to west paths and *n* north to south paths. Each east to west path crosses each north to south path, so there are *n*2 intersections. The city funded purchase of five benches. To make it seems that there are many benches it was decided to place them on as many paths as possib...
{"inputs": ["5", "6", "7", "15", "17", "72", "83", "95", "99", "100"], "outputs": ["120", "4320", "52920", "1082161080", "4594961280", "23491596420472320", "101159538130177920", "402852449038723320", "613867215317368320", "680185280130048000"]}
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
23
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
d947c674f71ad1869e3b4e4c2a9b4d08
Allowed Letters
Polycarp has just launched his new startup idea. The niche is pretty free and the key vector of development sounds really promising, so he easily found himself some investors ready to sponsor the company. However, he is yet to name the startup! Actually, Polycarp has already came up with the name but some improvement ...
{"inputs": ["bedefead\n5\n2 e\n1 dc\n5 b\n7 ef\n6 ef", "abacaba\n0", "fc\n2\n1 cfab\n2 f", "bbcbbc\n6\n1 c\n2 c\n3 b\n4 ab\n5 ab\n6 ab", "abcdefffffffffffffff\n5\n20 abcde\n19 abcde\n18 abcde\n17 abcde\n16 abcde", "abcdefffffffffffffff\n20\n1 acf\n2 cdef\n3 ef\n4 def\n5 adef\n6 acdef\n7 bdef\n8 abdf\n9 bcdf\n10 abf\n11...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
1
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
d9b86edee53889453397f5b7ce5a5e84
Brain Network (hard)
Breaking news from zombie neurology! It turns out that – contrary to previous beliefs – every zombie is born with a single brain, and only later it evolves into a complicated brain structure. In fact, whenever a zombie consumes a brain, a new brain appears in its nervous system and gets immediately connected to one of ...
{"inputs": ["2\n1", "3\n1\n2", "10\n1\n1\n1\n1\n3\n3\n7\n5\n5", "120\n1\n1\n2\n2\n3\n3\n4\n4\n5\n5\n6\n6\n7\n7\n8\n8\n9\n9\n10\n10\n11\n11\n12\n12\n13\n13\n14\n14\n15\n15\n16\n16\n17\n17\n18\n18\n19\n19\n20\n20\n21\n21\n22\n22\n23\n23\n24\n24\n25\n25\n26\n26\n27\n27\n28\n28\n29\n29\n30\n30\n31\n31\n32\n32\n33\n33\n34\n...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
1
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
da0df1b8f82f23e6dd788cf13a0aa7a2
Cola
To celebrate the opening of the Winter Computer School the organizers decided to buy in *n* liters of cola. However, an unexpected difficulty occurred in the shop: it turned out that cola is sold in bottles 0.5, 1 and 2 liters in volume. At that, there are exactly *a* bottles 0.5 in volume, *b* one-liter bottles and *c...
{"inputs": ["10 5 5 5", "3 0 0 2", "1 0 0 0", "1 1 0 0", "1 2 0 0", "1 0 1 0", "1 0 2 0", "1 0 0 1", "2 2 2 2", "3 3 2 1", "3 10 10 10", "5 2 1 1", "7 2 2 2", "7 3 0 5", "10 20 10 5", "10 0 8 10", "10 19 15 100", "20 1 2 3", "20 10 20 30", "25 10 5 10", "101 10 0 50", "101 10 10 50", "505 142 321 12", "999 999 899 299"...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
23
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
db1ffc2ec8f3719b2f915150a1a936fc
Vladik and chat
Recently Vladik discovered a new entertainment — coding bots for social networks. He would like to use machine learning in his bots so now he want to prepare some learning data for them. At first, he need to download *t* chats. Vladik coded a script which should have downloaded the chats, however, something went wrong...
{"inputs": ["1\n2\nVladik netman\n2\n?: Hello, Vladik!\n?: Hi", "1\n2\nnetman vladik\n3\nnetman:how are you?\n?:wrong message\nvladik:im fine", "2\n3\nnetman vladik Fedosik\n2\n?: users are netman, vladik, Fedosik\nvladik: something wrong with this chat\n4\nnetman tigerrrrr banany2001 klinchuh\n4\n?: tigerrrrr, banany2...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
3
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
db44ea9c41db94f6084b977e4c7cafc7
Adjacent Replacements
Mishka got an integer array $a$ of length $n$ as a birthday present (what a surprise!). Mishka doesn't like this present and wants to change it somehow. He has invented an algorithm and called it "Mishka's Adjacent Replacements Algorithm". This algorithm can be represented as a sequence of steps: - Replace each occu...
{"inputs": ["5\n1 2 4 5 10", "10\n10000 10 50605065 1 5 89 5 999999999 60506056 1000000000", "1\n999999999", "1\n1000000000", "1\n210400", "5\n100000000 100000000 100000000 100000000 100000000", "1\n2441139", "2\n2 2", "3\n2 2 2", "2\n4 4"], "outputs": ["1 1 3 5 9", "9999 9 50605065 1 5 89 5 999999999 60506055 99999999...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
217
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
dcf673ff4e3d272a4fef682339c0d6ea
Lucky Tickets
Gerald has a friend, Pollard. Pollard is interested in lucky tickets (ticket is a sequence of digits). At first he thought that a ticket is lucky if between some its digits we can add arithmetic signs and brackets so that the result obtained by the arithmetic expression was number 100. But he quickly analyzed all such ...
{"inputs": ["0 3", "7 4", "0 10000", "1 10000", "9999 10000", "9998 10000", "9997 10000", "9973 10000", "0 300000", "1 300000", "10000 300000", "9999 300000", "9973 300000", "9998 300000", "2 10000", "3 10000", "4 10000", "5 10000", "7 10000", "14 10000", "9996 10000", "10 10000", "256 10000", "9240 10000", "7560 10000...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
1
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
dd2461a6f9dafd41268ba6bff8d1830d
Domino
We all know the problem about the number of ways one can tile a 2<=×<=*n* field by 1<=×<=2 dominoes. You probably remember that it goes down to Fibonacci numbers. We will talk about some other problem below, there you also are going to deal with tiling a rectangular field with dominoes. You are given a 4<=×<=*n* recta...
{"inputs": ["4", "2", "3", "5", "1", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "91", "92", "93", "94", "95", "96", "97", "98", "99", "100"], "outputs": ["aacc\nbbdd\nzkkz\nzllz", "aa\nbb\naa\nbb", "aab\nccb\nbaa\nbcc...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
11
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
ddecee6a7da306e0f17ed95f4412dcba
Prime Problem
In Berland prime numbers are fashionable — the respectable citizens dwell only on the floors with numbers that are prime numbers. The numismatists value particularly high the coins with prime nominal values. All the prime days are announced holidays! Yet even this is not enough to make the Berland people happy. On the...
{"inputs": ["8", "2", "3", "4", "5", "6", "7", "8", "9", "10", "23", "233", "1009", "2009", "4009", "4509", "2539", "5000", "4999", "4997", "5997", "5998", "5999", "6000", "11", "2109", "4890", "4356", "1075", "169", "5792", "2244", "2757", "3769", "3789", "3510", "962", "1834", "5544", "5558", "1005", "3904", "4691", ...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
1
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
de8e21fefe42129a166a2cb60fb65d72
none
Group of Berland scientists, with whom you have a close business relationship, makes a research in the area of peaceful nuclear energy. In particular, they found that a group of four nanobots, placed on a surface of a plate, can run a powerful chain reaction under certain conditions. To be precise, researchers introd...
{"inputs": ["2\n1 1\n1 -1\n-1 1\n-1 -1\n1 1\n2 2\n4 4\n6 6", "1\n31 85\n9 49\n52 57\n11 85", "1\n183 65\n100 121\n138 31\n81 31", "1\n152 76\n152 112\n118 17\n83 129", "1\n54 42\n41 32\n83 57\n83 28", "1\n41 153\n-6 153\n112 92\n6 83", "1\n78 92\n98 10\n40 -17\n122 112", "1\n97 85\n108 10\n24 91\n29 10", "1\n3 0\n5 0\n...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
1
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
df9c6cd618727a365f261b12f93c16e7
Three Logos
Three companies decided to order a billboard with pictures of their logos. A billboard is a big square board. A logo of each company is a rectangle of a non-zero area. Advertisers will put up the ad only if it is possible to place all three logos on the billboard so that they do not overlap and the billboard has no e...
{"inputs": ["5 1 2 5 5 2", "4 4 2 6 4 2", "1 3 1 3 3 1", "2 4 1 4 1 4", "7 2 7 2 7 3", "1 10 6 10 3 10", "20 1 20 1 18 20", "75 31 69 100 25 31", "6 23 23 12 5 23", "40 12 2 40 26 40", "3 49 1 49 49 45", "56 6 35 56 15 56", "70 6 70 62 70 2", "80 65 80 12 3 80", "90 20 54 90 90 16", "75 100 19 100 6 100", "17 100 100 2...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
4
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
e01325cc3bb47d387ca422ff653548a6
none
Students love to celebrate their holidays. Especially if the holiday is the day of the end of exams! Despite the fact that Igor K., unlike his groupmates, failed to pass a programming test, he decided to invite them to go to a cafe so that each of them could drink a bottle of... fresh cow milk. Having entered the cafe...
{"inputs": ["2 500 3", "4 100 5", "4 100 7", "5 500 2", "4 100 8", "1 1000 2", "2 500 4", "2 500 5", "9 1000 12", "20 1000 30", "50 1000 50", "50 1000 49", "49 1000 50", "40 1000 50", "48 1000 50", "45 1000 50", "30 1000 40", "20 1000 25", "21 1000 27", "21 1000 28", "21 1000 29", "22 1000 30", "3 356 14", "9 120 13", ...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
5
codeforces
e01e94d3d663c0ea8272b045a34e994b
Post Lamps
Adilbek's house is located on a street which can be represented as the OX axis. This street is really dark, so Adilbek wants to install some post lamps to illuminate it. Street has $n$ positions to install lamps, they correspond to the integer numbers from $0$ to $n - 1$ on the OX axis. However, some positions are bloc...
{"inputs": ["6 2 3\n1 3\n1 2 3", "4 3 4\n1 2 3\n1 10 100 1000", "5 1 5\n0\n3 3 3 3 3", "7 4 3\n2 4 5 6\n3 14 15", "1 0 1\n\n1000000", "1 1 1\n0\n1000", "3 2 3\n1 2\n1 1 1000000", "3 0 3\n\n333 500 1001", "3 0 3\n\n334 500 1001", "6 2 3\n2 3\n1 1 3", "9 4 3\n3 4 7 8\n1 1 1", "11 4 6\n3 4 5 6\n1000000 1000000 1000000 100...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
3
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
e070fa09a730ded5af470dfb1b5ddf32
Almost Identity Permutations
A permutation *p* of size *n* is an array such that every integer from 1 to *n* occurs exactly once in this array. Let's call a permutation an almost identity permutation iff there exist at least *n*<=-<=*k* indices *i* (1<=≤<=*i*<=≤<=*n*) such that *p**i*<==<=*i*. Your task is to count the number of almost identity ...
{"inputs": ["4 1", "4 2", "5 3", "5 4", "200 1", "200 2", "200 3", "200 4", "400 1", "400 2", "400 3", "400 4", "600 1", "600 2", "600 3", "600 4", "800 1", "800 2", "800 3", "800 4", "1000 1", "1000 2", "1000 3", "1000 4", "4 4"], "outputs": ["1", "7", "31", "76", "1", "19901", "2646701", "584811251", "1", "79801", "2...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
118
codeforces
e081729c9849ecde07bd53798955d477
Lorry
A group of tourists is going to kayak and catamaran tour. A rented lorry has arrived to the boat depot to take kayaks and catamarans to the point of departure. It's known that all kayaks are of the same size (and each of them occupies the space of 1 cubic metre), and all catamarans are of the same size, but two times b...
{"inputs": ["3 2\n1 2\n2 7\n1 3", "5 3\n1 9\n2 9\n1 9\n2 10\n1 6", "10 10\n1 14\n2 15\n2 11\n2 12\n2 9\n1 14\n2 15\n1 9\n2 11\n2 6", "20 19\n2 47\n1 37\n1 48\n2 42\n2 48\n1 38\n2 47\n1 48\n2 47\n1 41\n2 46\n1 28\n1 49\n1 45\n2 34\n1 43\n2 29\n1 46\n2 45\n2 18", "50 27\n2 93\n1 98\n2 62\n1 56\n1 86\n1 42\n2 67\n2 97\n2 ...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
17
codeforces
e095fc0f2706652ae0c7e6370b7eedb8
Timetable
Ivan is a student at Berland State University (BSU). There are *n* days in Berland week, and each of these days Ivan might have some classes at the university. There are *m* working hours during each Berland day, and each lesson at the university lasts exactly one hour. If at some day Ivan's first lesson is during *i*...
{"inputs": ["2 5 1\n01001\n10110", "2 5 0\n01001\n10110", "3 4 0\n0000\n0000\n0000", "3 4 12\n1111\n1111\n1111", "3 4 6\n1111\n1111\n1111", "10 10 0\n1000000001\n1000000001\n1000000001\n1000000001\n1000000001\n1000000001\n1000000001\n1000000001\n1000000001\n1000000001", "10 10 5\n1000000001\n1000000001\n1000000001\n100...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
9
codeforces
e0978618e361da10f11b0837442672c5
Game on Tree
Momiji has got a rooted tree, consisting of *n* nodes. The tree nodes are numbered by integers from 1 to *n*. The root has number 1. Momiji decided to play a game on this tree. The game consists of several steps. On each step, Momiji chooses one of the remaining tree nodes (let's denote it by *v*) and removes all the ...
{"inputs": ["2\n1 2", "3\n1 2\n1 3", "10\n1 2\n2 3\n3 4\n1 5\n2 6\n6 7\n4 8\n6 9\n9 10", "6\n1 3\n2 4\n5 6\n3 6\n5 4"], "outputs": ["1.50000000000000000000", "2.00000000000000000000", "3.81666666666666690000", "2.45000000000000020000"]}
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
3
codeforces
e0a25aa6735cc7bbb4f5284e0f982675
Watching Fireworks is Fun
A festival will be held in a town's main street. There are *n* sections in the main street. The sections are numbered 1 through *n* from left to right. The distance between each adjacent sections is 1. In the festival *m* fireworks will be launched. The *i*-th (1<=≤<=*i*<=≤<=*m*) launching is on time *t**i* at section...
{"inputs": ["50 3 1\n49 1 1\n26 1 4\n6 1 10", "10 2 1\n1 1000 4\n9 1000 4", "30 8 2\n15 97 3\n18 64 10\n20 14 20\n16 18 36\n10 23 45\n12 60 53\n17 93 71\n11 49 85", "100 20 5\n47 93 3\n61 49 10\n14 69 10\n88 2 14\n35 86 18\n63 16 20\n39 49 22\n32 45 23\n66 54 25\n77 2 36\n96 85 38\n33 28 45\n29 78 53\n78 13 60\n58 96 6...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
3
codeforces
e0a8066c3ffaf53d1423dd8bb7537fb4
The Brand New Function
Polycarpus has a sequence, consisting of *n* non-negative integers: *a*1,<=*a*2,<=...,<=*a**n*. Let's define function *f*(*l*,<=*r*) (*l*,<=*r* are integer, 1<=≤<=*l*<=≤<=*r*<=≤<=*n*) for sequence *a* as an operation of bitwise OR of all the sequence elements with indexes from *l* to *r*. Formally: *f*(*l*,<=*r*)<==<=...
{"inputs": ["3\n1 2 0", "10\n1 2 3 4 5 6 1 2 9 10", "1\n123", "10\n6 8 4 5 1 9 10 2 3 7", "7\n1 2 4 8 16 32 64", "10\n375813 659427 484038 348181 432640 368050 271089 721588 345312 630771", "5\n0 1 2 0 4", "1\n0", "1\n1000000"], "outputs": ["4", "11", "1", "15", "28", "29", "7", "1", "1"]}
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
21
codeforces
e0d0422a544145c98c802c1517bec7f7
Industrial Nim
There are *n* stone quarries in Petrograd. Each quarry owns *m**i* dumpers (1<=≤<=*i*<=≤<=*n*). It is known that the first dumper of the *i*-th quarry has *x**i* stones in it, the second dumper has *x**i*<=+<=1 stones in it, the third has *x**i*<=+<=2, and the *m**i*-th dumper (the last for the *i*-th quarry) has *x**...
{"inputs": ["2\n2 1\n3 2", "4\n1 1\n1 1\n1 1\n1 1", "10\n2 3\n1 4\n5 8\n4 10\n10 8\n7 2\n1 2\n1 7\n4 10\n5 3", "20\n8 6\n6 3\n2 9\n7 8\n9 1\n2 4\n3 6\n6 3\n5 6\n5 3\n6 5\n2 10\n2 9\n6 3\n10 6\n10 10\n10 7\n3 9\n16 1\n1 3", "30\n53 12\n13 98\n21 60\n76 58\n39 5\n62 58\n73 80\n13 75\n37 45\n44 86\n1 85\n13 33\n17 50\n12 ...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
10
codeforces
e0d62a2e04817aababe97ea9ff251c84
Dividing the numbers
Petya has *n* integers: 1,<=2,<=3,<=...,<=*n*. He wants to split these integers in two non-empty groups in such a way that the absolute difference of sums of integers in each group is as small as possible. Help Petya to split the integers. Each of *n* integers should be exactly in one group. The first line contains a...
{"inputs": ["4", "2", "3", "5", "59998", "60000", "59991", "59989", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "59999", "59997", "59996", "59995", "59994", "59993", "59992", "59990", "100", "1000", "10001", "103", "1002", "31724", "2032", "42620", "1807...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
144
codeforces
e0d9b47413ecdfc4e7b25dd15d254c2c
Two Strings Swaps
You are given two strings $a$ and $b$ consisting of lowercase English letters, both of length $n$. The characters of both strings have indices from $1$ to $n$, inclusive. You are allowed to do the following changes: - Choose any index $i$ ($1 \le i \le n$) and swap characters $a_i$ and $b_i$; - Choose any index $...
{"inputs": ["7\nabacaba\nbacabaa", "5\nzcabd\ndbacz", "1\na\nb", "5\nahmad\nyogaa"], "outputs": ["4", "0", "1", "3"]}
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
18
codeforces
e1034fbea68dca22768a04b14ad82878
Booking System
Innovation technologies are on a victorious march around the planet. They integrate into all spheres of human activity! A restaurant called "Dijkstra's Place" has started thinking about optimizing the booking system. There are *n* booking requests received by now. Each request is characterized by two numbers: *c**i*...
{"inputs": ["3\n10 50\n2 100\n5 30\n3\n4 6 9", "1\n1 1\n1\n1", "1\n2 1\n1\n1", "2\n10 10\n5 5\n1\n5", "2\n10 10\n5 5\n1\n10", "2\n2 100\n10 10\n1\n10", "2\n10 100\n5 90\n2\n15 20", "3\n10 10\n3 5\n5 8\n3\n3 4 10", "10\n739 307\n523 658\n700 143\n373 577\n120 433\n353 833\n665 516\n988 101\n817 604\n800 551\n10\n431 425...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
46
codeforces
e12509b906dd993ec3ead38d458dc7f9
Maximize Sum of Digits
Anton has the integer *x*. He is interested what positive integer, which doesn't exceed *x*, has the maximum sum of digits. Your task is to help Anton and to find the integer that interests him. If there are several such integers, determine the biggest of them. The first line contains the positive integer *x* (1<=≤<=*...
{"inputs": ["100", "48", "521", "1", "2", "3", "39188", "5", "6", "7", "8", "9", "10", "59999154", "1000", "10000", "100000", "1000000", "10000000", "100000000", "1000000000", "10000000000", "100000000000", "1000000000000", "10000000000000", "100000000000000", "1000000000000000", "10000000000000000", "10000000000000000...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
15
codeforces
e130bca7c9717c52c141f6eb021a0626
Delete from the Left
You are given two strings $s$ and $t$. In a single move, you can choose any of two strings and delete the first (that is, the leftmost) character. After a move, the length of the string decreases by $1$. You can't choose a string if it is empty. For example: - by applying a move to the string "where", the result is ...
{"inputs": ["test\nwest", "codeforces\nyes", "test\nyes", "b\nab", "z\nz", "abacabadabacaba\nabacabadacaba", "z\na", "ama\nsama", "aaabc\nbc", "lxuyspmieeuyxluv\ndfwxqvavzxctblaa", "ahmedaly\naly", "aa\na", "aa\nba", "cccba\nba", "a\nab", "dadc\ndddc", "aacaaab\nb", "dddc\ncdcde", "bbdab\ndab", "a\naa", "aa\nab", "code...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
233
codeforces
e13a6e6f6d8c190168588e4e23f98439
DZY Loves Strings
DZY loves collecting special strings which only contain lowercase letters. For each lowercase letter *c* DZY knows its value *w**c*. For each special string *s*<==<=*s*1*s*2... *s*|*s*| (|*s*| is the length of the string) he represents its value with a function *f*(*s*), where Now DZY has a string *s*. He wants to in...
{"inputs": ["abc\n3\n1 2 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1", "mmzhr\n3\n443 497 867 471 195 670 453 413 579 466 553 881 847 642 269 996 666 702 487 209 257 741 974 133 519 453", "ajeeseerqnpaujubmajpibxrccazaawetywxmifzehojf\n23\n359 813 772 413 733 654 33 87 890 433 395 311 801 852 376 148 914 420 636 69...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
420
codeforces
e1478fe113da588a61423b6304a9e4dc
Godsend
Leha somehow found an array consisting of *n* integers. Looking at it, he came up with a task. Two players play the game on the array. Players move one by one. The first player can choose for his move a subsegment of non-zero length with an odd sum of numbers and remove it from the array, after that the remaining parts...
{"inputs": ["4\n1 3 2 3", "2\n2 2", "4\n2 4 6 8", "5\n1 1 1 1 1", "4\n720074544 345031254 849487632 80870826", "1\n0", "1\n999999999", "2\n1 999999999", "4\n3 3 4 4", "2\n1 2", "8\n2 2 2 1 1 2 2 2", "5\n3 3 2 2 2", "4\n0 1 1 0", "3\n1 2 2", "6\n2 2 1 1 4 2", "8\n2 2 2 3 3 2 2 2", "4\n2 3 3 4", "10\n2 2 2 2 3 1 2 2 2 2"...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
223
codeforces
e14b7011b3fe8a743e826ee023646996
Kitahara Haruki's Gift
Kitahara Haruki has bought *n* apples for Touma Kazusa and Ogiso Setsuna. Now he wants to divide all the apples between the friends. Each apple weights 100 grams or 200 grams. Of course Kitahara Haruki doesn't want to offend any of his friend. Therefore the total weight of the apples given to Touma Kazusa must be equa...
{"inputs": ["3\n100 200 100", "4\n100 100 100 200", "1\n100", "1\n200", "2\n100 100", "2\n200 200", "100\n200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 20...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
102
codeforces
e182ab5da357b6cd08d11902dd0b81d8
Cats Transport
Zxr960115 is owner of a large farm. He feeds *m* cute cats and employs *p* feeders. There's a straight road across the farm and *n* hills along the road, numbered from 1 to *n* from left to right. The distance between hill *i* and (*i*<=-<=1) is *d**i* meters. The feeders live in hill 1. One day, the cats went out to ...
{"inputs": ["4 6 2\n1 3 5\n1 0\n2 1\n4 9\n1 10\n2 10\n3 12"], "outputs": ["3"]}
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
1
codeforces
e186d5e1fd55287a9b94b5ef95540968
Distances to Zero
You are given the array of integer numbers *a*0,<=*a*1,<=...,<=*a**n*<=-<=1. For each element find the distance to the nearest zero (to the element which equals to zero). There is at least one zero element in the given array. The first line contains integer *n* (1<=≤<=*n*<=≤<=2·105) — length of the array *a*. The secon...
{"inputs": ["9\n2 1 0 3 0 0 3 2 4", "5\n0 1 2 3 4", "7\n5 6 0 1 -2 3 4", "1\n0", "2\n0 0", "2\n0 1", "2\n1 0", "5\n0 1000000000 1000000000 1000000000 1000000000", "5\n-1000000000 -1000000000 0 1000000000 1000000000", "5\n-1000000000 1000000000 1000000000 1000000000 0", "15\n1000000000 -1000000000 -1000000000 1000000000...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
109
codeforces
e1c5ad14b20dbf5c26e55715bcabf8fe
Blog Photo
One popular blog site edits the uploaded photos like this. It cuts a rectangular area out of them so that the ratio of height to width (i.e. the *height*<=/<=*width* quotient) can vary from 0.8 to 1.25 inclusively. Besides, at least one side of the cut area should have a size, equal to some power of number 2 (2*x* for ...
{"inputs": ["2 1", "2 2", "5 5", "9 10", "15 13", "47 46", "99 100", "939 887", "4774 4806", "39271 49032", "483242 484564", "4939191 4587461", "9909199 9945873", "49829224 49889315", "49728622 49605627", "49934587 49239195", "48298903 49928606", "49874820 49474021", "48945079 49798393", "99692141 99232337", "998557701...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
15
codeforces
e1c6638094e6ffa59cfa504b3bf9c472
Year of University Entrance
There is the faculty of Computer Science in Berland. In the social net "TheContact!" for each course of this faculty there is the special group whose name equals the year of university entrance of corresponding course of students at the university. Each of students joins the group of his course and joins all groups f...
{"inputs": ["3\n2014 2016 2015", "1\n2050", "1\n2010", "1\n2011", "3\n2010 2011 2012", "3\n2049 2047 2048", "5\n2043 2042 2041 2044 2040", "5\n2012 2013 2014 2015 2016", "1\n2045", "1\n2046", "1\n2099", "1\n2100", "3\n2011 2010 2012", "3\n2011 2012 2010", "3\n2012 2011 2010", "3\n2010 2012 2011", "3\n2012 2010 2011", "...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
202
codeforces
e1d1777c58d7782a80342ff92b03a1c9
Zublicanes and Mumocrates
It's election time in Berland. The favorites are of course parties of zublicanes and mumocrates. The election campaigns of both parties include numerous demonstrations on *n* main squares of the capital of Berland. Each of the *n* squares certainly can have demonstrations of only one party, otherwise it could lead to r...
{"inputs": ["8\n1 4\n2 4\n3 4\n6 5\n7 5\n8 5\n4 5", "5\n1 2\n1 3\n1 4\n1 5", "11\n1 7\n2 1\n2 9\n6 2\n7 10\n1 3\n5 2\n3 8\n8 11\n2 4", "20\n2 18\n15 18\n18 4\n4 20\n20 6\n8 6\n1 8\n9 6\n11 9\n11 12\n19 4\n3 9\n9 7\n7 13\n10 3\n16 20\n1 5\n5 17\n10 14", "11\n9 2\n9 4\n8 9\n7 9\n3 9\n5 9\n6 9\n10 9\n1 9\n11 9", "15\n4 12...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
1
codeforces