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
2d58be359632795d42ddf9dc59da7fee
MYSTERIOUS LANGUAGE
You are given a mysterious language (codenamed "Secret") available in "Custom Test" tab. Find out what this language is and write a program which outputs its name. Note that the program must be written in this language. This program has only one test, and it's empty (it doesn't give your program anything to read). Outp...
{"inputs": ["1"], "outputs": ["INTERCAL"]}
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
13
codeforces
2d5b514c88c7afb88eed33428014607a
Efim and Strange Grade
Efim just received his grade for the last test. He studies in a special school and his grade can be equal to any positive decimal fraction. First he got disappointed, as he expected a way more pleasant result. Then, he developed a tricky plan. Each second, he can ask his teacher to round the grade at any place after th...
{"inputs": ["6 1\n10.245", "6 2\n10.245", "3 100\n9.2", "12 5\n872.04488525", "35 8\n984227318.2031144444444444494637612", "320 142\n2704701300865535.43222331223343411413001111322010242013132301034414420112430314444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
16
codeforces
2d6458ca956b28b24231b7eba658436d
z-sort
A student of *z*-school found a kind of sorting called *z*-sort. The array *a* with *n* elements are *z*-sorted if two conditions hold: 1. *a**i*<=≥<=*a**i*<=-<=1 for all even *i*, 1. *a**i*<=≤<=*a**i*<=-<=1 for all odd *i*<=&gt;<=1. For example the arrays [1,2,1,2] and [1,1,1,1] are *z*-sorted while the array [1,2...
{"inputs": ["4\n1 2 2 1", "5\n1 3 2 2 5", "1\n1", "10\n1 1 1 1 1 1 1 1 1 1", "10\n1 9 7 6 2 4 7 8 1 3", "100\n82 51 81 14 37 17 78 92 64 15 8 86 89 8 87 77 66 10 15 12 100 25 92 47 21 78 20 63 13 49 41 36 41 79 16 87 87 69 3 76 80 60 100 49 70 59 72 8 38 71 45 97 71 14 76 54 81 4 59 46 39 29 92 3 49 22 53 99 59 52 74 3...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
185
codeforces
2d6ce72a85e606a5171c5872b40f1b6b
Image Preview
Vasya's telephone contains *n* photos. Photo number 1 is currently opened on the phone. It is allowed to move left and right to the adjacent photo by swiping finger over the screen. If you swipe left from the first photo, you reach photo *n*. Similarly, by swiping right from the last photo you reach photo 1. It takes *...
{"inputs": ["4 2 3 10\nwwhw", "5 2 4 13\nhhwhh", "5 2 4 1000\nhhwhh", "3 1 100 10\nwhw", "10 2 3 32\nhhwwhwhwwh", "1 2 3 3\nw", "100 20 100 10202\nwwwwhhwhhwhhwhhhhhwwwhhhwwwhwwhwhhwwhhwwwhwwhwwwhwhwhwwhhhwhwhhwhwwhhwhwhwwwhwwwwhwhwwwwhwhhhwhwhwww", "20 10 10 1\nhwhwhwhwhwhwhwhwhhhw", "12 10 10 1\nwhwhwhwhwhwh", "2 5 5...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
2
codeforces
2d807654d96829234b558af3cc2ac5d3
Our Tanya is Crying Out Loud
Right now she actually isn't. But she will be, if you don't solve this problem. You are given integers *n*, *k*, *A* and *B*. There is a number *x*, which is initially equal to *n*. You are allowed to perform two types of operations: 1. Subtract 1 from *x*. This operation costs you *A* coins. 1. Divide *x* by *k*....
{"inputs": ["9\n2\n3\n1", "5\n5\n2\n20", "19\n3\n4\n2", "1845999546\n999435865\n1234234\n2323423", "1604353664\n1604353665\n9993432\n1", "777888456\n1\n98\n43", "1162261467\n3\n1\n2000000000", "1000000000\n1999999999\n789987\n184569875", "2000000000\n2\n1\n2000000000", "1999888325\n3\n2\n2000000000", "1897546487\n687\n...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
69
codeforces
2dfa063f0f70a652c3e61aa500d3bd6d
none
One day in the IT lesson Anna and Maria learned about the lexicographic order. String *x* is lexicographically less than string *y*, if either *x* is a prefix of *y* (and *x*<=≠<=*y*), or there exists such *i* (1<=≤<=*i*<=≤<=*min*(|*x*|,<=|*y*|)), that *x**i*<=&lt;<=*y**i*, and for any *j* (1<=≤<=*j*<=&lt;<=*i*) *x**j...
{"inputs": ["aa\n2", "abc\n5", "abab\n7", "codeforces\n1", "cccc\n8", "abcdefghijklmnopqrstuvwxyz\n27", "cba\n6", "z\n100000", "kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
11
codeforces
2e0e65d582aa86344f25fa47e856073f
Valued Keys
You found a mysterious function *f*. The function takes two strings *s*1 and *s*2. These strings must consist only of lowercase English letters, and must be the same length. The output of the function *f* is another string of the same length. The *i*-th character of the output is equal to the minimum of the *i*-th cha...
{"inputs": ["ab\naa", "nzwzl\nniwel", "ab\nba", "r\nl", "d\ny", "yvowz\ncajav", "lwzjp\ninjit", "epqnlxmiicdidyscjaxqznwur\neodnlemiicdedmkcgavqbnqmm", "qqdabbsxiibnnjgsgxllfvdqj\nuxmypqtwfdezewdxfgplannrs", "aanerbaqslfmqmuciqbxyznkevukvznpkmxlcorpmrenwxhzfgbmlfpxtkqpxdrmcqcmbf\naanebbaqkgfiimcciqbaoznkeqqkrgapdillccr...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
287
codeforces
2e1370625bc74674d7dc606d54188d02
Almost Arithmetic Progression
Polycarp likes arithmetic progressions. A sequence $[a_1, a_2, \dots, a_n]$ is called an arithmetic progression if for each $i$ ($1 \le i &lt; n$) the value $a_{i+1} - a_i$ is the same. For example, the sequences $[42]$, $[5, 5, 5]$, $[2, 11, 20, 29]$ and $[3, 2, 1, 0]$ are arithmetic progressions, but $[1, 0, 1]$, $[1...
{"inputs": ["4\n24 21 14 10", "2\n500 500", "3\n14 5 1", "5\n1 3 6 9 12", "1\n1000000000", "2\n1000000000 1", "3\n34 70 52", "3\n1 2 1", "6\n1 1 3 5 6 5", "3\n2 1 2", "10\n9 5 3 4 7 1 2 8 10 6", "4\n20 15 20 15", "4\n10 21 14 24", "3\n5 9 5", "10\n10 9 8 7 6 1 2 3 4 5", "4\n2 6 3 1", "5\n1 3 6 8 10", "4\n1 3 1 3", "3\n...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
15
codeforces
2ed4f6b0ea75c25b51bae97215bfef0b
none
A positive integer is called a 2-3-integer, if it is equal to 2*x*·3*y* for some non-negative integers *x* and *y*. In other words, these integers are such integers that only have 2 and 3 among their prime divisors. For example, integers 1, 6, 9, 16 and 108 — are 2-3 integers, while 5, 10, 21 and 120 are not. Print th...
{"inputs": ["1 10", "100 200", "1 2000000000", "1088391168 1934917632", "1088391167 1934917632", "1088391169 1934917632", "1088391168 1934917631", "1088391168 1934917633", "4 134217728", "209952 43046722", "25165825 43046719", "5183 25165825", "388645 455910", "472069 972050", "1 1", "2 2", "12 1999999931", "1999999999...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
169
codeforces
2ed76b685dc12befd8dabe6097fb961b
Sheldon and Ice Pieces
Do you remember how Kai constructed the word "eternity" using pieces of ice as components? Little Sheldon plays with pieces of ice, each piece has exactly one digit between 0 and 9. He wants to construct his favourite number *t*. He realized that digits 6 and 9 are very similar, so he can rotate piece of ice with 6 to...
{"inputs": ["42\n23454", "169\n12118999", "1\n1", "7\n777", "18\n8118", "33\n33333333", "1780\n8170880870810081711018110878070777078711", "2\n5255", "5\n22252", "9\n666969", "6\n9669969", "25\n52", "2591\n5291", "9697\n979966799976", "5518\n22882121", "533\n355233333332", "2569\n9592525295556669222269569596622566529699...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
35
codeforces
2ed9ecb5353cf9c74167e9d3a4305f94
Bear and String Distance
Limak is a little polar bear. He likes nice strings — strings of length *n*, consisting of lowercase English letters only. The distance between two letters is defined as the difference between their positions in the alphabet. For example, , and . Also, the distance between two nice strings is defined as the sum of di...
{"inputs": ["4 26\nbear", "2 7\naf", "3 1000\nhey", "5 50\nkzsij", "5 500\nvsdxg", "1 0\na", "1 1\ng", "1 25\nr", "1 15\no", "10 100\naddaiyssyp", "50 100\ntewducenaqgpilgftjcmzttrgebnyldwfgbtttrygaiqtkgbjb", "2 1\nzz", "8 8\nabcdefgh", "1 25\nz", "1 24\nz", "1 24\ny", "2 49\nzz", "1 26\na", "1 25\na", "4 17\nrzsq", "6...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
65
codeforces
2edeeac50e31bc716f0e02afb027d0d3
Days of Floral Colours
The Floral Clock has been standing by the side of Mirror Lake for years. Though unable to keep time, it reminds people of the passage of time and the good old days. On the rim of the Floral Clock are 2*n* flowers, numbered from 1 to 2*n* clockwise, each of which has a colour among all *n* possible ones. For each colou...
{"inputs": ["3", "4", "7", "15", "10", "99", "1317", "50000", "5", "6", "8", "9", "11", "12", "13", "14", "16", "17", "18", "19", "20", "33", "39", "89", "144", "233", "396", "418", "431", "831", "985", "998", "1000", "2017", "3939", "5000", "8081", "10000", "10001", "10492", "20178", "23333", "25252", "30000", "35000"...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
1
codeforces
2f2d711ae79c779f5d447f7d9a907eb7
Kefa and First Steps
Kefa decided to make some money doing business on the Internet for exactly *n* days. He knows that on the *i*-th day (1<=≤<=*i*<=≤<=*n*) he makes *a**i* money. Kefa loves progress, that's why he wants to know the length of the maximum non-decreasing subsegment in sequence *a**i*. Let us remind you that the subsegment o...
{"inputs": ["6\n2 2 1 3 4 1", "3\n2 2 9", "5\n10 100 111 1 2", "10\n1 2 3 4 1 2 3 4 5 6", "50\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1", "100\n1 838 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
250
codeforces
2f3f7b94851f56f96e4ed58c3ab91d6f
Greg's Workout
Greg is a beginner bodybuilder. Today the gym coach gave him the training plan. All it had was *n* integers *a*1,<=*a*2,<=...,<=*a**n*. These numbers mean that Greg needs to do exactly *n* exercises today. Besides, Greg should repeat the *i*-th in order exercise *a**i* times. Greg now only does three types of exercise...
{"inputs": ["2\n2 8", "3\n5 1 10", "7\n3 3 2 7 9 6 8", "4\n5 6 6 2", "5\n8 2 2 6 3", "6\n8 7 2 5 3 4", "8\n7 2 9 10 3 8 10 6", "9\n5 4 2 3 4 4 5 2 2", "10\n4 9 8 5 3 8 8 10 4 2", "11\n10 9 7 6 1 3 9 7 1 3 5", "12\n24 22 6 16 5 21 1 7 2 19 24 5", "13\n24 10 5 7 16 17 2 7 9 20 15 2 24", "14\n13 14 19 8 5 17 9 16 15 9 5 6...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
802
codeforces
2f7db9cb6c84ba4b95dc8cedb622e240
Fox and Number Game
Fox Ciel is playing a game with numbers now. Ciel has *n* positive integers: *x*1, *x*2, ..., *x**n*. She can do the following operation as many times as needed: select two different indexes *i* and *j* such that *x**i* &gt; *x**j* hold, and then apply assignment *x**i* = *x**i* - *x**j*. The goal is to make the sum ...
{"inputs": ["2\n1 2", "3\n2 4 6", "2\n12 18", "5\n45 12 27 30 18", "2\n1 1", "2\n100 100", "2\n87 58", "39\n52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52", "59\n96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 9...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
315
codeforces
2f824162334d023d3a67d940eb317f6c
Anton and Classes
Anton likes to play chess. Also he likes to do programming. No wonder that he decided to attend chess classes and programming classes. Anton has *n* variants when he will attend chess classes, *i*-th variant is given by a period of time (*l*1,<=*i*,<=*r*1,<=*i*). Also he has *m* variants when he will attend programmin...
{"inputs": ["3\n1 5\n2 6\n2 3\n2\n2 4\n6 8", "3\n1 5\n2 6\n3 7\n2\n2 4\n1 4", "20\n13 141\n57 144\n82 124\n16 23\n18 44\n64 65\n117 133\n84 117\n77 142\n40 119\n105 120\n71 92\n5 142\n48 132\n106 121\n5 80\n45 92\n66 81\n7 93\n27 71\n3\n75 96\n127 140\n54 74", "10\n16 16\n20 20\n13 13\n31 31\n42 42\n70 70\n64 64\n63 63...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
9
codeforces
2fcaec95ca0fe52784f2e76a62c1e938
Soldier and Bananas
A soldier wants to buy *w* bananas in the shop. He has to pay *k* dollars for the first banana, 2*k* dollars for the second one and so on (in other words, he has to pay *i*·*k* dollars for the *i*-th banana). He has *n* dollars. How many dollars does he have to borrow from his friend soldier to buy *w* bananas? The f...
{"inputs": ["3 17 4", "1 2 1", "1 1 1", "1 5 6", "1 1000000000 1", "1000 0 1000", "859 453892 543", "1000 1000000000 1000", "1000 500500000 1000", "1000 500500001 1000", "1000 500499999 1000", "634 87973 214", "432 10000 241", "111 111111111 111", "20 43 3"], "outputs": ["13", "0", "0", "16", "0", "500500000", "1264169...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
620
codeforces
2ff5a19d85e28f8e54918a2087001c0c
Space mines
Once upon a time in the galaxy of far, far away... Darth Wader found out the location of a rebels' base. Now he is going to destroy the base (and the whole planet that the base is located at), using the Death Star. When the rebels learnt that the Death Star was coming, they decided to use their new secret weapon — sp...
{"inputs": ["0 0 0 1 0 0 5\n2\n10 8 0 2 2\n0 -3 0\n2 2 0\n20 0 0 4 3\n2 4 0\n-4 3 0\n1 -5 0", "8 8 4 4 4 2 6\n1\n-2 -2 -1 3 0", "30 30 2 1 2 1 20\n3\n0 0 40 5 1\n1 4 4\n-10 -40 -5 7 0\n100 200 95 8 1\n-10 0 0", "100 99 30 -1 -5 -3 100\n1\n100 -90 -50 5 4\n0 6 0\n7 0 0\n6 1 1\n0 -6 -1", "0 0 0 5 5 5 20\n1\n-20 0 -30 10 ...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
1
codeforces
301e737070363b274b194f0490596d1d
Shopping
Ayush is a cashier at the shopping center. Recently his department has started a ''click and collect" service which allows users to shop online. The store contains *k* items. *n* customers have already used the above service. Each user paid for *m* items. Let *a**ij* denote the *j*-th item in the *i*-th person's orde...
{"inputs": ["2 2 5\n3 4 1 2 5\n1 5\n3 1", "4 4 4\n1 2 3 4\n3 4 2 1\n4 3 2 1\n4 1 2 3\n4 1 2 3", "1 1 1\n1\n1", "10 1 100\n1 55 67 75 40 86 24 84 82 26 81 23 70 79 51 54 21 78 31 98 68 93 66 88 99 65 20 52 35 85 16 12 94 100 59 56 18 33 47 46 71 8 38 57 2 92 3 95 6 4 87 22 48 80 15 29 11 45 72 76 44 60 91 90 39 74 41 36...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
65
codeforces
30494f7ac1c5ba89c23a40068f7d26fe
Exams
Student Valera is an undergraduate student at the University. His end of term exams are approaching and he is to pass exactly *n* exams. Valera is a smart guy, so he will be able to pass any exam he takes on his first try. Besides, he can take several exams on one day, and in any order. According to the schedule, a st...
{"inputs": ["3\n5 2\n3 1\n4 2", "3\n6 1\n5 2\n4 3", "1\n1000000000 999999999", "1\n2 1", "2\n3 2\n3 2", "5\n4 3\n4 2\n4 1\n4 1\n4 1", "6\n12 11\n10 9\n8 7\n6 5\n4 3\n2 1", "2\n3 1\n3 2", "2\n4 2\n4 1", "2\n5 2\n5 1", "6\n3 1\n3 2\n4 1\n4 2\n5 4\n5 4", "3\n3 2\n4 1\n100 10", "3\n4 3\n5 2\n10 8", "5\n6 5\n6 4\n6 3\n6 2\n...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
46
codeforces
308f31764bb3b87376289f22975af96f
Amr and Pins
Amr loves Geometry. One day he came up with a very interesting problem. Amr has a circle of radius *r* and center in point (*x*,<=*y*). He wants the circle center to be in new position (*x*',<=*y*'). In one step Amr can put a pin to the border of the circle in a certain point, then rotate the circle around that pin b...
{"inputs": ["2 0 0 0 4", "1 1 1 4 4", "4 5 6 5 6", "10 20 0 40 0", "9 20 0 40 0", "5 -1 -6 -5 1", "99125 26876 -21414 14176 17443", "8066 7339 19155 -90534 -60666", "100000 -100000 -100000 100000 100000", "10 20 0 41 0", "25 -64 -6 -56 64", "125 455 450 439 721", "5 6 3 7 2", "24 130 14786 3147 2140", "125 -363 176 93 ...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
469
codeforces
309df1bdd3f15ef54a7d1d973fe42330
Fence
There is a fence in front of Polycarpus's home. The fence consists of *n* planks of the same width which go one after another from left to right. The height of the *i*-th plank is *h**i* meters, distinct planks can have distinct heights. Polycarpus has bought a posh piano and is thinking about how to get it into the h...
{"inputs": ["7 3\n1 2 6 1 1 7 1", "1 1\n100", "2 1\n10 20", "10 5\n1 2 3 1 2 2 3 1 4 5", "10 2\n3 1 4 1 4 6 2 1 4 6", "2 2\n20 10", "2 1\n20 1", "3 1\n1 2 3", "3 1\n2 1 3", "3 1\n3 2 1", "3 2\n1 2 3", "3 2\n3 2 1", "3 3\n1 2 3", "4 2\n9 8 11 7", "4 2\n10 1 2 3", "6 3\n56 56 56 2 1 2", "8 3\n1 1 1 1 2 60 90 1", "4 1\n1 ...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
209
codeforces
30a248252fde97fb2547f74417918dcc
The Big Race
Vector Willman and Array Bolt are the two most famous athletes of Byteforces. They are going to compete in a race with a distance of *L* meters today. Willman and Bolt have exactly the same speed, so when they compete the result is always a tie. That is a problem for the organizers because they want a winner. While ...
{"inputs": ["10 3 2", "7 1 2", "1 1 1", "5814 31 7", "94268 813 766", "262610 5583 4717", "3898439 96326 71937", "257593781689876390 32561717 4411677", "111319886766128339 7862842484895022 3003994959686829", "413850294331656955 570110918058849723 409853735661743839", "3000000000000000000 2999999999999999873 29999999999...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
146
codeforces
30b0da6da608e9e1c0bcfb1c6a77658e
Xenia and Tree
Xenia the programmer has a tree consisting of *n* nodes. We will consider the tree nodes indexed from 1 to *n*. We will also consider the first node to be initially painted red, and the other nodes — to be painted blue. The distance between two tree nodes *v* and *u* is the number of edges in the shortest path between...
{"inputs": ["5 4\n1 2\n2 3\n2 4\n4 5\n2 1\n2 5\n1 2\n2 5"], "outputs": ["0\n3\n2"]}
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
4
codeforces
30cbb8e50f856c890357da22cf574c69
Cyclic Components
You are given an undirected graph consisting of $n$ vertices and $m$ edges. Your task is to find the number of connected components which are cycles. Here are some definitions of graph theory. An undirected graph consists of two sets: set of nodes (called vertices) and set of edges. Each edge connects a pair of verti...
{"inputs": ["5 4\n1 2\n3 4\n5 4\n3 5", "17 15\n1 8\n1 12\n5 11\n11 9\n9 15\n15 5\n4 13\n3 13\n4 3\n10 16\n7 10\n16 7\n14 3\n14 4\n17 6", "4 4\n1 2\n2 3\n1 3\n1 4", "5 5\n1 2\n2 3\n3 4\n4 1\n3 5", "200000 0", "1 0", "5 10\n1 2\n2 3\n3 4\n4 5\n5 1\n1 4\n2 4\n3 5\n3 1\n2 5", "5 10\n1 2\n1 3\n1 4\n1 5\n2 3\n2 4\n2 5\n3 4\n...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
8
codeforces
30db901d2974d16a3492d3335b4eb28f
Collective Mindsets (medium)
Way to go! Heidi now knows how many brains there must be for her to get one. But throwing herself in the midst of a clutch of hungry zombies is quite a risky endeavor. Hence Heidi wonders: what is the smallest number of brains that must be in the chest for her to get out at all (possibly empty-handed, but alive)? The ...
{"inputs": ["1", "3", "2", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "99", "100", "9999", "21736", "873467", "4124980", "536870910", "536870912", "876543210", "987654321", "1000000000"], "outputs": ["0", "1", "0", "0", "2", "1", "3", "0", "4", "1", "5", "2", "6", "3...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
5
codeforces
30de59f08fe3576a3c3ef0138a341c0f
Gabriel and Caterpillar
The 9-th grade student Gabriel noticed a caterpillar on a tree when walking around in a forest after the classes. The caterpillar was on the height *h*1 cm from the ground. On the height *h*2 cm (*h*2<=&gt;<=*h*1) on the same tree hung an apple and the caterpillar was crawling to the apple. Gabriel is interested when ...
{"inputs": ["10 30\n2 1", "10 13\n1 1", "10 19\n1 2", "1 50\n5 4", "1 1000\n2 1", "999 1000\n1 1", "999 1000\n1 1000", "1 1000\n999 1", "1 1000\n100 99", "500 509\n1 1", "500 555\n6 1", "1 100000\n2 1", "99990 100000\n1 1", "90000 100000\n2 1", "10 100000\n1 100000", "1 41\n5 6", "1 100000\n1 100000", "1 9\n1 1", "8 16...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
40
codeforces
30de7ee740a6e995d73e72689e102fa6
Four Melodies
Author note: I think some of you might remember the problem "Two Melodies" from Eductational Codeforces Round 22. Now it's time to make it a bit more difficult! Alice is a composer, and recently she had recorded two tracks that became very popular. Now she has got a lot of fans who are waiting for new tracks. This t...
{"inputs": ["5\n1 3 5 7 9", "5\n1 3 5 7 2", "4\n1 3 5 7", "4\n1 1 1 1", "4\n1 1 2 1", "4\n3 2 3 1", "4\n3 4 2 2", "4\n5 3 4 3", "4\n5 3 1 4", "4\n3 5 2 4", "4\n8 6 8 1", "4\n6 3 6 4", "5\n8 1 4 8 2", "6\n2 7 8 6 5 7", "7\n9 12 12 1 8 12 12", "8\n16 1 8 13 14 5 4 4", "9\n5 4 10 10 13 17 15 15 12", "10\n19 18 20 1 7 1 3 ...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
1
codeforces
30f04343d73228a109494c7b3fd6aa52
Maximum Increase
You are given array consisting of *n* integers. Your task is to find the maximum length of an increasing subarray of the given array. A subarray is the sequence of consecutive elements of the array. Subarray is called increasing if each element of this subarray strictly greater than previous. The first line contains s...
{"inputs": ["5\n1 7 2 11 15", "6\n100 100 100 100 100 100", "3\n1 2 3", "1\n1000000000", "10\n802030518 598196518 640274071 983359971 71550121 96204862 799843967 446173607 796619138 402690754", "2\n2 1", "5\n1 2 3 3 4", "4\n1 2 2 3", "3\n2 1 1", "3\n1 2 1", "1\n1", "2\n1 2", "3\n1 1 2", "11\n1 2 3 1 2 3 2 1 2 3 4", "9\...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
389
codeforces
310156f005df4f13b9a0d5cafd315f04
Andryusha and Colored Balloons
Andryusha goes through a park each day. The squares and paths between them look boring to Andryusha, so he decided to decorate them. The park consists of *n* squares connected with (*n*<=-<=1) bidirectional paths in such a way that any square is reachable from any other using these paths. Andryusha decided to hang a c...
{"inputs": ["3\n2 3\n1 3", "5\n2 3\n5 3\n4 3\n1 3", "5\n2 1\n3 2\n4 3\n5 4", "10\n5 3\n9 2\n7 1\n3 8\n4 1\n1 9\n10 1\n8 9\n6 2", "3\n2 1\n3 2", "10\n2 7\n8 2\n9 8\n1 9\n4 1\n3 4\n6 3\n10 6\n5 10", "5\n4 2\n3 1\n3 4\n3 5", "7\n3 6\n3 1\n3 2\n3 5\n3 4\n3 7", "10\n8 6\n10 5\n8 4\n2 7\n3 8\n10 3\n3 9\n2 1\n3 2", "50\n45 2\...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
24
codeforces
3109c0e4b05b3087bcfdcb8b1ca095d3
Heidi and Library (medium)
Whereas humans nowadays read fewer and fewer books on paper, book readership among marmots has surged. Heidi has expanded the library and is now serving longer request sequences. Same as the easy version, but the limits have changed: 1<=≤<=*n*,<=*k*<=≤<=400<=000. Same as the easy version. Sample Input 4 100 1 2 2 1 4 1...
{"inputs": ["4 100\n1 2 2 1", "4 1\n1 2 2 1", "4 2\n1 2 3 1", "11 1\n1 2 3 5 1 10 10 1 1 3 5", "5 2\n1 2 3 1 2", "4 2\n1 2 3 2", "1 1\n1"], "outputs": ["2", "3", "3", "9", "4", "3", "1"]}
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
1
codeforces
311321b9f47985d2496064b27ba62fd1
The Wall (easy)
"The zombies are lurking outside. Waiting. Moaning. And when they come..." "When they come?" "I hope the Wall is high enough." Zombie attacks have hit the Wall, our line of defense in the North. Its protection is failing, and cracks are showing. In places, gaps have appeared, splitting the wall into multiple segment...
{"inputs": ["3 7\n.......\n.......\n.BB.B..", "4 5\n..B..\n..B..\nB.B.B\nBBB.B", "4 6\n..B...\nB.B.BB\nBBB.BB\nBBBBBB", "1 1\nB", "10 7\n.......\n.......\n.......\n.......\n.......\n.......\n.......\n.......\n...B...\nB.BB.B.", "8 8\n........\n........\n........\n........\n.B......\n.B.....B\n.B.....B\n.BB...BB"], "out...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
37
codeforces
311a06f18b45f0869a1d65aeb21bc2eb
Mausoleum
King of Berland Berl IV has recently died. Hail Berl V! As a sign of the highest achievements of the deceased king the new king decided to build a mausoleum with Berl IV's body on the main square of the capital. The mausoleum will be constructed from 2*n* blocks, each of them has the shape of a cuboid. Each block has ...
{"inputs": ["3 0", "3 1\n2 > 3", "4 1\n3 = 6", "5 2\n1 < 2\n9 > 10", "35 0", "10 5\n17 <= 10\n16 >= 18\n9 > 18\n8 = 8\n6 >= 13", "5 2\n1 = 10\n2 = 9", "3 3\n1 = 2\n3 = 4\n5 = 6", "4 3\n2 > 3\n4 > 5\n6 > 7", "1 1\n1 > 2", "1 1\n1 <= 2", "5 3\n2 > 10\n4 > 8\n3 = 6", "5 3\n2 <= 4\n6 <= 7\n5 > 6", "8 5\n2 <= 4\n5 > 10\n3 <...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
1
codeforces
313572d7684606e9ef8c0c75910331c7
Wet Shark and Odd and Even
Today, Wet Shark is given *n* integers. Using any of these integers no more than once, Wet Shark wants to get maximum possible even (divisible by 2) sum. Please, calculate this value for Wet Shark. Note, that if Wet Shark uses no integers from the *n* integers, the sum is an even integer 0. The first line of the inpu...
{"inputs": ["3\n1 2 3", "5\n999999999 999999999 999999999 999999999 999999999", "1\n1", "15\n39 52 88 78 46 95 84 98 55 3 68 42 6 18 98", "15\n59 96 34 48 8 72 67 90 15 85 7 90 97 47 25", "15\n87 37 91 29 58 45 51 74 70 71 47 38 91 89 44", "15\n11 81 49 7 11 14 30 67 29 50 90 81 77 18 59", "15\n39 21 95 89 73 90 9 55 8...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
423
codeforces
315d11810d627ff4e0a6a72ba8f9720f
New Year Letter
Many countries have such a New Year or Christmas tradition as writing a letter to Santa including a wish list for presents. Vasya is an ordinary programmer boy. Like all ordinary boys, he is going to write the letter to Santa on the New Year Eve (we Russians actually expect Santa for the New Year, not for Christmas). ...
{"inputs": ["3 2 2 2", "3 3 2 2", "3 0 2 2", "4 3 2 1", "4 2 2 1", "3 0 1 1", "50 0 100 100", "50 1 100 100", "4 32 23 32", "5 45 23 32", "6 54 23 32", "7 120 23 32", "8 664 100 100", "8 661 100 99", "8 704 99 100", "10 189 44 100", "3 1 1 6", "3 1 6 1", "50 1000000000 100 100", "6 4 3 2", "5 4 3 2", "3 3 3 3", "48 512...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
3
codeforces
315da27429573e9d68899fd06513f3c6
Equator
Polycarp has created his own training plan to prepare for the programming contests. He will train for $n$ days, all days are numbered from $1$ to $n$, beginning from the first. On the $i$-th day Polycarp will necessarily solve $a_i$ problems. One evening Polycarp plans to celebrate the equator. He will celebrate it on...
{"inputs": ["4\n1 3 2 1", "6\n2 2 2 2 2 2", "1\n10000", "3\n2 1 1", "2\n1 3", "4\n2 1 1 3", "3\n1 1 3", "3\n1 1 1", "2\n1 2", "3\n2 1 2", "5\n1 2 4 3 5", "5\n2 2 2 4 3", "4\n1 2 3 1", "6\n7 3 10 7 3 11", "2\n3 4", "5\n1 1 1 1 1", "4\n1 3 2 3", "2\n2 3", "3\n32 10 23", "7\n1 1 1 1 1 1 1", "3\n1 2 4", "6\n3 3 3 2 4 4", "...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
255
codeforces
316f0e162d83207ee04cbb016580e7bf
Code obfuscation
Kostya likes Codeforces contests very much. However, he is very disappointed that his solutions are frequently hacked. That's why he decided to obfuscate (intentionally make less readable) his code before upcoming contest. To obfuscate the code, Kostya first looks at the first variable name used in his program and rep...
{"inputs": ["abacaba", "jinotega", "aaaaaaaaaaa", "aba", "bab", "a", "abcdefghijklmnopqrstuvwxyz", "fihyxmbnzq", "aamlaswqzotaanasdhcvjoaiwdhctezzawagkdgfffeqkyrvbcrfqgkdsvximsnvmkmjyofswmtjdoxgwamsaatngenqvsvrvwlbzuoeaolfcnmdacrmdleafbsmerwmxzyylfhemnkoayuhtpbikm", "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
115
codeforces
3180e2f8457950e4376b77f29145be1f
none
Emuskald considers himself a master of flow algorithms. Now he has completed his most ingenious program yet — it calculates the maximum flow in an undirected graph. The graph consists of *n* vertices and *m* edges. Vertices are numbered from 1 to *n*. Vertices 1 and *n* being the source and the sink respectively. Howe...
{"inputs": ["3 3\n3 2 10\n1 2 10\n3 1 5", "4 5\n1 2 10\n1 3 10\n2 3 5\n4 2 15\n3 4 5", "10 17\n8 1 1\n4 8 2\n7 10 8\n1 4 1\n5 4 3\n6 9 6\n3 5 4\n1 9 1\n3 9 5\n7 1 1\n1 2 1\n1 3 1\n6 7 7\n8 2 1\n1 10 1\n1 5 1\n6 1 1", "10 20\n3 8 41\n1 2 21\n9 1 31\n1 3 53\n5 9 67\n10 1 8\n6 1 16\n5 2 21\n1 7 50\n5 4 38\n6 4 16\n4 8 16\...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
3
codeforces
318a48f1fb2864089f31d5bec97f167e
DZY Loves Physics
DZY loves Physics, and he enjoys calculating density. Almost everything has density, even a graph. We define the density of a non-directed graph (nodes and edges of the graph have some values) as follows: Once DZY got a graph *G*, now he wants to find a connected induced subgraph *G*' of the graph, such that the den...
{"inputs": ["1 0\n1", "2 1\n1 2\n1 2 1", "5 6\n13 56 73 98 17\n1 2 56\n1 3 29\n1 4 42\n2 3 95\n2 4 88\n3 4 63", "1 0\n734135", "10 10\n132402 148489 472187 403302 657890 205188 750668 276911 372190 828796\n8 10 162\n1 8 489\n6 7 279\n1 10 740\n5 6 721\n3 6 862\n2 3 194\n7 10 601\n2 10 658\n1 5 930", "20 20\n265918 7442...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
24
codeforces
31b2068c4127a3a6df25dd29749cbb94
Text Messaging
Fangy the little walrus, as all the modern walruses, loves to communicate via text messaging. One day he faced the following problem: When he sends large texts, they are split into parts each containing *n* characters (which is the size of one text message). Thus, whole sentences and words get split! Fangy did not lik...
{"inputs": ["25\nHello. I am a little walrus.", "2\nHow are you?", "19\nHello! Do you like fish? Why?", "4\na. A.", "191\nEvx vnxZtUSgtzH yDNXCsTaxCKQus gVZLHppOplkGGekIK xbme. krbusMqUs YEnBBTJpjNicZPlx TqEtBPcbejZMzvn fFTub CHYWLmiOFkDdzR! LoQmXPfHJ KVnfrbrFooVSkj xwAZwrRr DdILZ kpco cLoRmJbVKhnbOEhnHKpci. PgYhxFPXdl...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
9
codeforces
31d742885e0896f01ad4f25eb86abb43
Magic Odd Square
Find an *n*<=×<=*n* matrix with different numbers from 1 to *n*2, so the sum in each row, column and both main diagonals are odd. The only line contains odd integer *n* (1<=≤<=*n*<=≤<=49). Print *n* lines with *n* integers. All the integers should be different and from 1 to *n*2. The sum in each row, column and both ma...
{"inputs": ["1", "3", "5", "7", "9", "11", "13", "15", "17", "19", "21", "23", "25", "27", "29", "31", "33", "35", "37", "39", "41", "43", "45", "47", "49"], "outputs": ["1", "2 1 4\n3 5 7\n6 9 8", "2 4 1 6 8\n10 3 5 7 12\n9 11 13 15 17\n14 19 21 23 16\n18 20 25 22 24", "2 4 6 1 8 10 12\n14 16 3 5 7 18 20\n22 9 11 13 1...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
52
codeforces
31f82a93c86ffaf724da238d322c7f70
Periodical Numbers
A non-empty string *s* is called binary, if it consists only of characters "0" and "1". Let's number the characters of binary string *s* from 1 to the string's length and let's denote the *i*-th character in string *s* as *s**i*. Binary string *s* with length *n* is periodical, if there is an integer 1<=≤<=*k*<=&lt;<=...
{"inputs": ["1 10", "25 38", "7 9", "12 20", "7 49", "28 97", "65 72", "49 116", "883 947", "1 1000000000000000000", "6967967 165556564", "74 99", "883 947", "3165 7131", "31958 81314", "134285 645597", "7404389 8927556", "29906716 35911991", "168183636 812682195", "856218974 3052460231", "29374454626 62592774235", "28...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
2
codeforces
32006bbd8168b03e94f8db7f3234053e
Nested Segments
You are given *n* segments on a line. There are no ends of some segments that coincide. For each segment find the number of segments it contains. The first line contains a single integer *n* (1<=≤<=*n*<=≤<=2·105) — the number of segments on a line. Each of the next *n* lines contains two integers *l**i* and *r**i* (<=...
{"inputs": ["4\n1 8\n2 3\n4 7\n5 6", "3\n3 4\n1 5\n2 6", "1\n-1000000000 1000000000", "2\n-1000000000 999999999\n-999999999 1000000000", "2\n-1000000000 1000000000\n-999999999 999999999", "3\n-999999997 999999997\n-999999998 999999998\n-999999999 999999999", "3\n-999999999 999999997\n-999999998 999999998\n-999999997 99...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
15
codeforces
3204a88d5f3940fd5744f4629c906e37
Land Lot
Vasya has a beautiful garden where wonderful fruit trees grow and yield fantastic harvest every year. But lately thieves started to sneak into the garden at nights and steal the fruit too often. Vasya can’t spend the nights in the garden and guard the fruit because there’s no house in the garden! Vasya had been saving ...
{"inputs": ["2 2\n1 0\n1 1\n1 1", "4 5\n0 0 1 0 1\n0 1 1 1 0\n1 0 1 0 1\n1 1 1 1 1\n2 3", "3 3\n0 0 0\n0 0 0\n0 0 0\n1 2", "3 3\n1 1 1\n1 1 1\n1 1 1\n2 1", "3 2\n1 1\n1 1\n1 0\n2 1", "2 3\n1 0 1\n0 1 0\n3 2", "1 1\n0\n1 1", "1 1\n1\n1 1", "3 4\n1 0 1 0\n0 1 0 1\n1 0 1 0\n2 2", "3 4\n1 1 1 1\n1 0 0 1\n1 1 1 1\n3 1", "10...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
32
codeforces
322ce5c93133c4b042488dad39f21d9a
Magnets
Mad scientist Mike entertains himself by arranging rows of dominoes. He doesn't need dominoes, though: he uses rectangular magnets instead. Each magnet has two poles, positive (a "plus") and negative (a "minus"). If two magnets are put together at a close distance, then the like poles will repel each other and the oppo...
{"inputs": ["6\n10\n10\n10\n01\n10\n10", "4\n01\n01\n10\n10", "1\n10", "2\n01\n10", "2\n10\n10", "3\n10\n01\n10", "1\n01", "2\n01\n01", "2\n10\n01", "3\n01\n01\n01", "3\n10\n10\n01", "3\n01\n10\n10", "115\n10\n10\n10\n10\n01\n01\n10\n10\n10\n01\n01\n10\n01\n01\n10\n10\n10\n01\n10\n01\n10\n10\n01\n01\n10\n10\n10\n10\n01...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
484
codeforces
322e8db062139940fd3ce280df4450dd
Guess Your Way Out!
Amr bought a new video game "Guess Your Way Out!". The goal of the game is to find an exit from the maze that looks like a perfect binary tree of height *h*. The player is initially standing at the root of the tree and the exit from the tree is located at some leaf node. Let's index all the leaf nodes from the left t...
{"inputs": ["1 2", "2 3", "3 6", "10 1024", "10 577", "11 550", "19 12783", "28 72803174", "39 457181784666", "12 955", "13 154", "14 2334", "15 15512", "16 21395", "17 80239", "18 153276", "20 589266", "21 1687606", "24 14428281", "29 113463931", "1 1", "3 8", "31 1819651953", "33 2599588275", "38 262402936512", "4 13...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
17
codeforces
322e969544dec25cdee4270be8cac5b7
Parking Lot
To quickly hire highly skilled specialists one of the new IT City companies made an unprecedented move. Every employee was granted a car, and an employee can choose one of four different car makes. The parking lot before the office consists of one line of (2*n*<=-<=2) parking spaces. Unfortunately the total number of ...
{"inputs": ["3", "4", "5", "6", "7", "12", "15", "28", "29", "30"], "outputs": ["24", "132", "672", "3264", "15360", "27525120", "2214592512", "280349076803813376", "1161928703861587968", "4809844402031689728"]}
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
18
codeforces
324634a6d5274599dbfc95cf907a3d09
Bus Game
After Fox Ciel won an onsite round of a programming contest, she took a bus to return to her castle. The fee of the bus was 220 yen. She met Rabbit Hanako in the bus. They decided to play the following game because they got bored in the bus. - Initially, there is a pile that contains *x* 100-yen coins and *y* 10-yen ...
{"inputs": ["2 2", "3 22", "0 22", "1000 1000", "0 0", "0 21", "1 11", "1 12", "2 1", "2 23", "2 24", "3 1", "3 2", "3 13", "3 14", "4 1", "4 2", "4 25", "4 26", "5 1", "5 2", "5 15", "5 16", "5 23", "5 24", "6 1", "6 2", "6 13", "6 14", "6 23", "6 24", "7 1", "7 2", "7 13", "7 14", "7 25", "7 26", "8 1", "8 2", "8 15"...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
36
codeforces
326a73695d6ab2a8c0ceb3ffa601d027
Dragons
Kirito is stuck on a level of the MMORPG he is playing now. To move on in the game, he's got to defeat all *n* dragons that live on this level. Kirito and the dragons have strength, which is represented by an integer. In the duel between two opponents the duel's outcome is determined by their strength. Initially, Kirit...
{"inputs": ["2 2\n1 99\n100 0", "10 1\n100 100", "123 2\n78 10\n130 0", "999 2\n1010 10\n67 89", "2 5\n5 1\n2 1\n3 1\n1 1\n4 1", "2 2\n3 5\n1 2", "1 2\n1 0\n1 0", "5 10\n20 1\n4 3\n5 1\n100 1\n4 2\n101 1\n10 0\n10 2\n17 3\n12 84", "2 2\n1 98\n100 0", "2 2\n1 2\n3 5", "5 3\n13 20\n3 10\n15 5", "2 5\n1 1\n2 1\n3 1\n4 1\n...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
57
codeforces
326c9cfa4b463c80581756abe06cf25f
Vasya's Function
Vasya is studying number theory. He has denoted a function *f*(*a*,<=*b*) such that: - *f*(*a*,<=0)<==<=0; - *f*(*a*,<=*b*)<==<=1<=+<=*f*(*a*,<=*b*<=-<=*gcd*(*a*,<=*b*)), where *gcd*(*a*,<=*b*) is the greatest common divisor of *a* and *b*. Vasya has two numbers *x* and *y*, and he wants to calculate *f*(*x*,<=*y*)...
{"inputs": ["3 5", "6 3", "1000000009 1000000008", "1000000007 1000000006", "2000000018 2000000017", "1000000000000 1", "1000000000000 1000000000000", "1 1000000000000", "100000000000 100000000000", "1 100000000000", "100000000000 1", "1000000009 1000000000000", "1000000000000 1000000007", "124556361363 136616361", "15...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
8
codeforces
32713f0e3bc63c4144e2655dda3099c3
Case of the Zeros and Ones
Andrewid the Android is a galaxy-famous detective. In his free time he likes to think about strings containing zeros and ones. Once he thought about a string of length *n* consisting of zeroes and ones. Consider the following operation: we choose any two adjacent positions in the string, and if one them contains 0, an...
{"inputs": ["4\n1100", "5\n01010", "8\n11101111", "1\n0", "1\n1", "2\n00", "2\n01", "2\n10", "2\n11", "3\n001", "6\n110110", "7\n0000011", "6\n110010", "6\n110100", "3\n100", "6\n010111", "8\n01011100", "6\n001011", "7\n1110000", "9\n011111101"], "outputs": ["0", "1", "6", "1", "1", "2", "0", "0", "2", "1", "2", "3", "...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
684
codeforces
3276d7d8749b698eee6a4ed34e59647f
BF Calculator
In this problem you will write a simple generator of Brainfuck ([https://en.wikipedia.org/wiki/Brainfuck](https://en.wikipedia.org/wiki/Brainfuck)) calculators. You are given an arithmetic expression consisting of integers from 0 to 255 and addition/subtraction signs between them. Output a Brainfuck program which, whe...
{"inputs": ["2+3", "9-7", "1+1+1", "1+11+111", "111-11-1", "1+1-1+1-1+1-1+1-1+1", "9+1", "10-1", "31+49+49+71-51-61+59-111+51", "255+255+255+255+255-255-255-255-255-255", "100+100+10+10+10+10+10+5", "255-255+255-255+255-255+255-255+255", "0-255-255-255-255+255+255+255+255+255", "34+45+29-49+52-111-4+4+2+9", "0+0+0+0+0+...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
43
codeforces
3278bb2a3c74f0b3ae56cb0cb81379c1
Peter and Snow Blower
Peter got a new snow blower as a New Year present. Of course, Peter decided to try it immediately. After reading the instructions he realized that it does not work like regular snow blowing machines. In order to make it work, you need to tie it to some point that it does not cover, and then switch it on. As a result it...
{"inputs": ["3 0 0\n0 1\n-1 2\n1 2", "4 1 -1\n0 0\n1 2\n2 0\n1 1", "3 0 0\n-1 1\n0 3\n1 1", "3 -4 2\n-3 2\n5 -5\n5 3", "3 -84 8\n-83 8\n21 -62\n3 53", "6 -94 -51\n-93 -51\n48 -25\n61 27\n73 76\n-10 87\n-48 38", "5 -94 52\n-93 52\n-78 -56\n-54 -81\n56 -87\n97 85", "10 -100 90\n-99 90\n-98 -12\n-72 -87\n7 -84\n86 -79\n96...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
20
codeforces
327dbb40ce764338d44efe10a6b74c17
none
Appleman has a tree with *n* vertices. Some of the vertices (at least one) are colored black and other vertices are colored white. Consider a set consisting of *k* (0<=≤<=*k*<=&lt;<=*n*) edges of Appleman's tree. If Appleman deletes these edges from the tree, then it will split into (*k*<=+<=1) parts. Note, that each ...
{"inputs": ["3\n0 0\n0 1 1", "6\n0 1 1 0 4\n1 1 0 0 1 0", "10\n0 1 2 1 4 4 4 0 8\n0 0 0 1 0 1 1 0 0 1", "5\n0 1 1 3\n0 0 0 1 1", "10\n0 1 1 2 4 3 3 3 2\n1 0 1 1 1 0 0 1 1 0", "100\n0 0 2 2 0 3 5 0 6 2 0 4 0 2 3 7 8 3 15 19 13 8 18 19 3 14 23 9 6 3 6 17 26 24 20 6 4 27 8 5 14 5 35 31 27 3 41 25 20 14 25 31 49 40 0 1 10 ...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
6
codeforces
328f6c972f176799aaf085e6e87dbdad
Love Triangles
There are many anime that are about "love triangles": Alice loves Bob, and Charlie loves Bob as well, but Alice hates Charlie. You are thinking about an anime which has *n* characters. The characters are labeled from 1 to *n*. Every pair of two characters can either mutually love each other or mutually hate each other ...
{"inputs": ["3 0", "4 4\n1 2 1\n2 3 1\n3 4 0\n4 1 0", "4 4\n1 2 1\n2 3 1\n3 4 0\n4 1 1", "100000 0", "100 3\n1 2 0\n2 3 0\n3 1 0", "9 2\n1 2 0\n2 3 0", "28567 13\n28079 24675 1\n18409 26720 1\n980 10815 1\n20794 16571 1\n7376 19861 1\n11146 706 1\n4255 16391 1\n27376 18263 1\n10019 28444 1\n6574 28053 1\n5036 16610 1\n...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
4
codeforces
32affc2f5bd9de0f7bc25972e4d32d68
Game of Robots
In late autumn evening *n* robots gathered in the cheerful company of friends. Each robot has a unique identifier — an integer from 1 to 109. At some moment, robots decided to play the game "Snowball". Below there are the rules of this game. First, all robots stand in a row. Then the first robot says his identifier. A...
{"inputs": ["2 2\n1 2", "4 5\n10 4 18 3", "1 1\n4", "2 1\n5 1", "2 2\n1 4", "2 3\n6 7", "3 1\n4 5 6", "3 2\n4 5 6", "3 3\n4 5 6", "3 4\n4 5 6", "3 5\n4 5 6", "3 6\n4 5 6", "4 1\n5 1000000000 999999999 12", "4 2\n5 1000000000 999999999 12", "4 3\n5 1000000000 999999999 12", "4 4\n5 1000000000 999999999 12", "4 5\n5 1000...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
108
codeforces
32b593c62c436e6641f62fa3556c9ea8
Splitting in Teams
There were *n* groups of students which came to write a training contest. A group is either one person who can write the contest with anyone else, or two people who want to write the contest in the same team. The coach decided to form teams of exactly three people for this training. Determine the maximum number of tea...
{"inputs": ["4\n1 1 2 1", "2\n2 2", "7\n2 2 2 1 1 1 1", "3\n1 1 1", "3\n2 2 2", "3\n1 2 1", "5\n2 2 1 1 1", "7\n1 1 2 2 1 2 1", "10\n1 2 2 1 2 2 1 2 1 1", "5\n2 2 2 1 2", "43\n1 2 2 2 1 1 2 2 1 1 2 2 2 2 1 2 2 2 2 2 1 2 1 2 1 2 2 2 2 2 2 2 2 1 2 2 2 2 2 2 2 2 2", "72\n1 2 1 2 2 1 2 1 1 1 1 2 2 1 2 1 2 1 2 2 2 2 1 2 2 2...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
293
codeforces
32c40fe5862f7157a9677fdcb855a752
Copying Data
We often have to copy large volumes of information. Such operation can take up many computer resources. Therefore, in this problem you are advised to come up with a way to copy some part of a number array into another one, quickly. More formally, you've got two arrays of integers *a*1,<=*a*2,<=...,<=*a**n* and *b*1,<=...
{"inputs": ["5 10\n1 2 0 -1 3\n3 1 5 -2 0\n2 5\n1 3 3 3\n2 5\n2 4\n2 1\n1 2 1 4\n2 1\n2 4\n1 4 2 1\n2 2", "1 4\n-2\n1\n1 1 1 1\n2 1\n1 1 1 1\n1 1 1 1", "2 5\n-3 2\n3 -4\n1 1 1 2\n2 1\n2 1\n1 2 2 1\n2 1", "3 6\n4 -3 0\n1 3 -5\n2 2\n2 3\n1 2 1 2\n1 2 1 2\n2 2\n2 2", "4 1\n-1 1 1 -1\n2 -2 -3 2\n2 4", "10 10\n-1 1 -1 2 -2 ...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
2
codeforces
33553ad9c3a573ef7247b41c1bf0ebf7
Kolya and Tanya
Kolya loves putting gnomes at the circle table and giving them coins, and Tanya loves studying triplets of gnomes, sitting in the vertexes of an equilateral triangle. More formally, there are 3*n* gnomes sitting in a circle. Each gnome can have from 1 to 3 coins. Let's number the places in the order they occur in the ...
{"inputs": ["1", "2", "3", "4", "5", "7", "10", "14", "58000", "6", "8", "9", "15", "20", "22", "48", "74", "100", "866", "1673", "555", "2000", "9877", "5984", "2091", "10000", "10868", "66115", "62212", "100000", "2441", "18569", "69289", "85417", "68841", "10000", "4343", "12312", "5462", "100", "11", "100000"], "ou...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
41
codeforces
337896c5b273e41731e70fbabf4b27e5
none
Polycarp has interviewed Oleg and has written the interview down without punctuation marks and spaces to save time. Thus, the interview is now a string *s* consisting of *n* lowercase English letters. There is a filler word ogo in Oleg's speech. All words that can be obtained from ogo by adding go several times to the...
{"inputs": ["7\naogogob", "13\nogogmgogogogo", "9\nogoogoogo", "32\nabcdefogoghijklmnogoopqrstuvwxyz", "100\nggogogoooggogooggoggogggggogoogoggooooggooggoooggogoooggoggoogggoogoggogggoooggoggoggogggogoogggoooo", "10\nogooggoggo", "20\nooggooogooogooogooog", "30\ngoggogoooggooggggoggoggoogoggo", "40\nogggogooggoogoogggo...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
285
codeforces
3399ed59347105551d7d5cb871498172
Save Energy!
Julia is going to cook a chicken in the kitchen of her dormitory. To save energy, the stove in the kitchen automatically turns off after *k* minutes after turning on. During cooking, Julia goes to the kitchen every *d* minutes and turns on the stove if it is turned off. While the cooker is turned off, it stays warm. T...
{"inputs": ["3 2 6", "4 2 20", "8 10 9", "43 50 140", "251 79 76", "892 67 1000", "1000 1000 1000", "87 4 1000", "1 629 384378949109878497", "2124 6621 12695", "27548 68747 111", "74974 46016 1000000000", "223 844 704", "1 558 743", "43 387 402", "972 2 763", "330 167 15", "387 43 650", "1 314 824", "2 4 18", "3 5 127"...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
43
codeforces
33e5305fc23a3704e1479f3760b06f6f
Sum
Vasya has found a piece of paper with an array written on it. The array consists of *n* integers *a*1,<=*a*2,<=...,<=*a**n*. Vasya noticed that the following condition holds for the array *a**i*<=≤<=*a**i*<=+<=1<=≤<=2·*a**i* for any positive integer *i* (*i*<=&lt;<=*n*). Vasya wants to add either a "+" or a "-" before...
{"inputs": ["4\n1 2 3 5", "3\n3 3 5", "4\n2 4 5 6", "6\n3 5 10 11 12 20", "10\n10 14 17 22 43 72 74 84 88 93", "11\n3 6 7 11 13 16 26 52 63 97 97", "12\n3 3 4 7 14 26 51 65 72 72 85 92", "40\n3 3 3 6 10 10 18 19 34 66 107 150 191 286 346 661 1061 1620 2123 3679 5030 8736 10539 19659 38608 47853 53095 71391 135905 25521...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
5
codeforces
33edfc25c7487cb0fc1143c0b9e271e8
Anton and School - 2
As you probably know, Anton goes to school. One of the school subjects that Anton studies is Bracketology. On the Bracketology lessons students usually learn different sequences that consist of round brackets (characters "(" and ")" (without quotes)). On the last lesson Anton learned about the regular simple bracket s...
{"inputs": [")(()()", "()()()", ")))", ")())((((((()))()((()))()((()()()((()()()))", "(", ")", "((", "))", "()", ")(", "(()", "()(", ")()", ")((", "))(", "((((()())))())((((((()(()())(()())()((()()))(((())()()()(())))))()())())))(()()(()))))()(((()(((())()))())())))))(()()()((((((())(()())())()())(()))))()(()))(((()()(...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
1
codeforces
340c87239d4362efcde1f0ab2cb806df
Sereja and Brackets
Sereja has a bracket sequence *s*1,<=*s*2,<=...,<=*s**n*, or, in other words, a string *s* of length *n*, consisting of characters "(" and ")". Sereja needs to answer *m* queries, each of them is described by two integers *l**i*,<=*r**i* (1<=≤<=*l**i*<=≤<=*r**i*<=≤<=*n*). The answer to the *i*-th query is the length o...
{"inputs": ["())(())(())(\n7\n1 1\n2 3\n1 2\n1 12\n8 12\n5 11\n2 10", "(((((()((((((((((()((()(((((\n1\n8 15", "((()((())(((((((((()(()(()(((((((((((((((()(()((((((((((((((()(((((((((((((((((((()(((\n39\n28 56\n39 46\n57 63\n29 48\n51 75\n14 72\n5 70\n51 73\n10 64\n31 56\n50 54\n15 78\n78 82\n1 11\n1 70\n1 19\n10 22\n1...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
9
codeforces
3417e3d9a9ea16b13582c2fc739d1b21
Fish Weight
It is known that there are *k* fish species in the polar ocean, numbered from 1 to *k*. They are sorted by non-decreasing order of their weight, which is a positive number. Let the weight of the *i*-th type of fish be *w**i*, then 0<=&lt;<=*w*1<=≤<=*w*2<=≤<=...<=≤<=*w**k* holds. Polar bears Alice and Bob each have cau...
{"inputs": ["3 3 3\n2 2 2\n1 1 3", "4 7 9\n5 2 7 3\n3 5 2 7 3 8 7", "5 5 10\n8 2 8 5 9\n9 1 7 5 1", "7 7 10\n8 2 8 10 6 9 10\n2 4 9 5 6 2 5", "15 15 10\n4 5 9 1 4 6 4 1 4 3 7 9 9 2 6\n6 6 7 7 2 9 1 6 10 9 7 10 7 10 9", "25 25 10\n10 6 2 1 9 7 2 5 6 9 2 3 2 8 5 8 2 9 10 8 9 7 7 4 8\n6 2 10 4 7 9 3 2 4 5 1 8 6 9 8 6 9 8 ...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
21
codeforces
342e643c0d0a6a9c822577ccc2a5c0d8
Splits
Let's define a split of $n$ as a nonincreasing sequence of positive integers, the sum of which is $n$. For example, the following sequences are splits of $8$: $[4, 4]$, $[3, 3, 2]$, $[2, 2, 1, 1, 1, 1]$, $[5, 2, 1]$. The following sequences aren't splits of $8$: $[1, 7]$, $[5, 4]$, $[11, -3]$, $[1, 1, 4, 1, 1]$. Th...
{"inputs": ["7", "8", "9", "1", "286", "48", "941", "45154", "60324", "91840", "41909", "58288", "91641", "62258", "79811", "88740", "12351", "1960", "29239", "85801", "43255", "13439", "35668", "19122", "60169", "50588", "2467", "39315", "29950", "17286", "7359066", "1016391", "7928871", "3968891", "2636452", "5076901...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
167
codeforces
344fab95a62f2e223e567ae427805ecc
Synchrophasotron
For some experiments little Petya needs a synchrophasotron. He has already got the device, all that's left is to set the fuel supply. Fuel comes through a system of nodes numbered from 1 to *n* and connected by pipes. Pipes go from every node with smaller number to every node with greater number. Fuel can only flow thr...
{"inputs": ["2\n1 2 1 2 3", "3\n1 2 1 2 3\n1 3 0 0 0\n2 3 3 4 5", "4\n1 2 0 2 1\n2 3 0 2 1\n1 3 0 2 6\n1 4 0 0 1\n2 4 0 0 0\n3 4 2 3 0", "3\n1 2 0 2 1\n1 3 1 2 1\n2 3 1 2 1", "4\n3 4 2 2 6\n2 3 1 1 6\n1 2 1 3 1\n1 4 2 3 4\n2 4 0 3 2\n1 3 1 2 5", "6\n1 2 5 5 0\n1 3 0 5 0\n1 4 0 5 0\n1 5 0 5 0\n1 6 5 5 0\n2 3 0 5 0\n2 4 ...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
2
codeforces
34558fb2ad23f2817beb36abd1ad784f
Thief in a Shop
A thief made his way to a shop. As usual he has his lucky knapsack with him. The knapsack can contain *k* objects. There are *n* kinds of products in the shop and an infinite number of products of each kind. The cost of one product of kind *i* is *a**i*. The thief is greedy, so he will take exactly *k* products (it's...
{"inputs": ["3 2\n1 2 3", "5 5\n1 1 1 1 1", "3 3\n3 5 11", "10 3\n3 4 12 5 7 13 5 6 1 6", "10 3\n1 2 3 4 5 6 7 8 9 10", "10 1000\n630 764 679 16 34 691 778 366 982 30", "3 1000\n674 751 563", "13 1000\n494 391 821 980 716 237 801 893 765 946 338 656 698", "4 973\n40 32 21 21", "100 100\n6 7 100 8 5 61 5 75 59 65 51 47 ...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
2
codeforces
347dc5817edcdfb675a5ae884dd312b4
Accounting
A long time ago in some far country lived king Copa. After the recent king's reform, he got so large powers that started to keep the books by himself. The total income *A* of his kingdom during 0-th year is known, as well as the total income *B* during *n*-th year (these numbers can be negative — it means that there w...
{"inputs": ["2 18 2", "-1 8 3", "0 0 10", "1 16 5", "0 1 2", "3 0 4", "1 1000 1", "7 896 7", "4 972 1", "-1 -1 5", "-1 0 4", "-7 0 1", "-5 -5 3", "-5 -5 9", "-5 -5 6", "-4 0 1", "-5 0 3", "-4 4 9", "10 0 6", "-5 3 4", "0 3 6", "3 6 10", "-3 7 5", "-526 526 1", "-373 373 3", "-141 0 8", "7 175 1", "-5 -560 1", "-1 -512 ...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
65
codeforces
34da494efdcd2edb25622a0a0d9ff23f
Removing Columns
You are given an *n*<=×<=*m* rectangular table consisting of lower case English letters. In one operation you can completely remove one column from the table. The remaining parts are combined forming a new table. For example, after removing the second column from the table   we obtain the table:   A table is called...
{"inputs": ["1 10\ncodeforces", "4 4\ncase\ncare\ntest\ncode", "5 4\ncode\nforc\nesco\ndefo\nrces", "2 2\nfb\nye", "5 5\nrzrzh\nrzrzh\nrzrzh\nrzrzh\nrzrzh", "10 10\nddorannorz\nmdrnzqvqgo\ngdtdjmlsuf\neoxbrntqdp\nhribwlslgo\newlqrontvk\nnxibmnawnh\nvxiwdjvdom\nhyhhewmzmp\niysgvzayst", "9 7\nygqartj\nlgwxlqv\nancjjpr\nw...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
70
codeforces
34daa3e2403efa872cf4d014beb68904
1-2-3
Ilya is working for the company that constructs robots. Ilya writes programs for entertainment robots, and his current project is "Bob", a new-generation game robot. Ilya's boss wants to know his progress so far. Especially he is interested if Bob is better at playing different games than the previous model, "Alice". ...
{"inputs": ["10 2 1\n1 1 1\n1 1 1\n1 1 1\n2 2 2\n2 2 2\n2 2 2", "8 1 1\n2 2 1\n3 3 1\n3 1 3\n1 1 1\n2 1 1\n1 2 3", "5 1 1\n1 2 2\n2 2 2\n2 2 2\n1 2 2\n2 2 2\n2 2 2", "1 1 1\n3 3 1\n1 1 1\n3 2 2\n2 2 2\n1 3 1\n3 3 2", "1 3 1\n1 3 3\n2 3 2\n2 1 3\n1 3 2\n3 3 2\n3 1 1", "10 2 1\n2 2 1\n3 2 2\n3 1 3\n3 1 3\n1 2 2\n3 3 2", ...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
16
codeforces
34dbf16cc55730780ff1f7789f263b4d
Picking Strings
Alice has a string consisting of characters 'A', 'B' and 'C'. Bob can use the following transitions on any substring of our string in any order any number of times: - A BC - B AC - C AB - AAA empty string Note that a substring is one or more consecutive characters. For given queries, determine whether it is ...
{"inputs": ["AABCCBAAB\nABCB\n5\n1 3 1 2\n2 2 2 4\n7 9 1 1\n3 4 2 3\n4 5 1 3", "AAAAAA\nAAAAAA\n30\n3 4 1 2\n3 3 4 4\n5 6 3 4\n3 3 2 3\n6 6 1 5\n2 4 4 6\n1 6 2 5\n6 6 3 4\n3 5 1 4\n4 5 3 6\n2 3 2 4\n3 4 4 4\n6 6 4 6\n3 3 2 5\n1 5 3 3\n4 6 1 2\n6 6 6 6\n3 3 3 4\n6 6 6 6\n5 6 4 4\n6 6 5 5\n2 3 1 4\n3 6 4 5\n3 5 6 6\n4 5 ...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
2
codeforces
3515fc2a1fbcc6446b9110ce2fe061c5
none
On the way to school, Karen became fixated on the puzzle game on her phone! The game is played as follows. In each level, you have a grid with *n* rows and *m* columns. Each cell originally contains the number 0. One move consists of choosing one row or column, and adding 1 to all of the cells in that row or column. ...
{"inputs": ["3 5\n2 2 2 3 2\n0 0 0 1 0\n1 1 1 2 1", "3 3\n0 0 0\n0 1 0\n0 0 0", "3 3\n1 1 1\n1 1 1\n1 1 1", "3 5\n2 4 2 2 3\n0 2 0 0 1\n1 3 1 1 2", "3 5\n0 0 0 0 0\n0 0 0 0 0\n0 0 0 0 1", "9 10\n14 5 6 4 8 9 4 14 14 13\n13 4 5 3 7 8 3 13 13 12\n16 7 8 6 10 11 6 16 16 15\n10 1 2 0 4 5 0 10 10 9\n11 2 3 1 5 6 1 11 11 10\...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
17
codeforces
351bdba27ec36bf894c8f6e8f3d2d4f6
Link/Cut Tree
Programmer Rostislav got seriously interested in the Link/Cut Tree data structure, which is based on Splay trees. Specifically, he is now studying the *expose* procedure. Unfortunately, Rostislav is unable to understand the definition of this procedure, so he decided to ask programmer Serezha to help him. Serezha agre...
{"inputs": ["1 10 2", "2 4 5", "18102 43332383920 28554", "19562 31702689720 17701", "11729 55221128400 313", "5482 100347128000 342", "3680 37745933600 10", "17098 191120104800 43", "10462 418807699200 2", "30061 641846400000 3", "1 1000000000000000000 2", "32 2498039712000 4", "1 2576683920000 2", "5 25 5", "1 90 90"...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
291
codeforces
351d38b093b038b4adf2014310a08cf4
Mr. Kitayuta's Colorful Graph
Mr. Kitayuta has just bought an undirected graph with *n* vertices and *m* edges. The vertices of the graph are numbered from 1 to *n*. Each edge, namely edge *i*, has a color *c**i*, connecting vertex *a**i* and *b**i*. Mr. Kitayuta wants you to process the following *q* queries. In the *i*-th query, he gives you tw...
{"inputs": ["4 5\n1 2 1\n1 2 2\n2 3 1\n2 3 3\n2 4 3\n3\n1 2\n3 4\n1 4", "5 7\n1 5 1\n2 5 1\n3 5 1\n4 5 1\n1 2 2\n2 3 2\n3 4 2\n5\n1 5\n5 1\n2 5\n1 5\n1 4", "2 1\n1 2 1\n1\n1 2", "2 3\n1 2 3\n1 2 2\n1 2 1\n1\n1 2"], "outputs": ["2\n1\n0", "1\n1\n1\n1\n2", "1", "3"]}
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
1
codeforces
3537031fc4532bfb7e6075640be51fb9
Sockets
Vasya has got many devices that work on electricity. He's got *n* supply-line filters to plug the devices, the *i*-th supply-line filter has *a**i* sockets. Overall Vasya has got *m* devices and *k* electrical sockets in his flat, he can plug the devices or supply-line filters directly. Of course, he can plug the supp...
{"inputs": ["3 5 3\n3 1 2", "4 7 2\n3 3 2 4", "5 5 1\n1 3 1 2 1", "4 5 8\n3 2 4 3", "5 10 1\n4 3 4 2 4", "7 13 2\n5 3 4 1 2 1 2", "7 17 5\n1 6 2 1 1 4 3", "10 25 7\n5 7 4 8 3 3 5 4 5 5", "10 8 4\n1 1 2 1 3 1 3 1 4 2", "13 20 9\n2 9 2 2 5 11 10 10 13 4 6 11 14", "9 30 8\n3 6 10 8 1 5 3 9 3", "15 26 4\n3 6 7 1 5 2 4 4 7 ...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
86
codeforces
3553127609b2c2c91915f8e356fcb797
Parquet
Once Bob decided to lay a parquet floor in his living room. The living room is of size *n*<=×<=*m* metres. Bob had planks of three types: *a* planks 1<=×<=2 meters, *b* planks 2<=×<=1 meters, and *c* planks 2<=×<=2 meters. Help Bob find out, if it is possible to parquet the living room with such a set of planks, and if...
{"inputs": ["2 6 2 2 1", "1 1 100 100 100", "4 4 10 10 10", "2 2 0 0 1", "2 3 2 1 0", "3 2 1 0 1", "7 7 9 7 4", "8 10 2 2 18", "29 10 89 28 14", "56 59 982 294 188", "80 80 668 62 1235", "100 100 2208 1898 447", "100 100 2474 270 1128", "100 100 570 808 1811", "99 100 1146 3732 36", "95 100 2574 1056 560", "97 100 58 1...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
4
codeforces
355c9baf71d3c5cab2adeb90c9135a4f
Proper Nutrition
Vasya has *n* burles. One bottle of Ber-Cola costs *a* burles and one Bars bar costs *b* burles. He can buy any non-negative integer number of bottles of Ber-Cola and any non-negative integer number of Bars bars. Find out if it's possible to buy some amount of bottles of Ber-Cola and Bars bars and spend exactly *n* bu...
{"inputs": ["7\n2\n3", "100\n25\n10", "15\n4\n8", "9960594\n2551\n2557", "10000000\n1\n1", "9999999\n9999\n9999", "9963629\n2591\n2593", "1\n7\n8", "9963630\n2591\n2593", "7516066\n1601\n4793", "6509546\n1607\n6221", "2756250\n8783\n29", "7817510\n2377\n743", "6087210\n1583\n1997", "4\n2\n2", "7996960\n4457\n5387", "79...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
55
codeforces
359e28c8ab146c95acd465504924699d
none
In some country live wizards. They love playing with numbers. The blackboard has two numbers written on it — *a* and *b*. The order of the numbers is not important. Let's consider *a*<=≤<=*b* for the sake of definiteness. The players can cast one of the two spells in turns: - Replace *b* with *b*<=-<=*a**k*. Number...
{"inputs": ["4\n10 21\n31 10\n0 1\n10 30", "66\n7 0\n5 7\n1 3\n3 2\n3 5\n0 6\n1 2\n0 7\n4 5\n4 7\n5 1\n2 0\n4 0\n0 5\n3 6\n7 3\n6 0\n5 2\n6 6\n1 7\n5 6\n2 2\n3 4\n2 1\n5 3\n4 6\n6 2\n3 3\n100000000000 1000000000000000000\n0 1\n4 1\n2 6\n5 5\n4 3\n0 3\n3 7\n3 1\n1 0\n4 4\n1000000000000000000 100000000000\n7 6\n4 2\n7 5\...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
3
codeforces
35a0480187633dd2e1d868bcfd998504
Adding Digits
Vasya has got two number: *a* and *b*. However, Vasya finds number *a* too short. So he decided to repeat the operation of lengthening number *a* *n* times. One operation of lengthening a number means adding exactly one digit to the number (in the decimal notation) to the right provided that the resulting number is di...
{"inputs": ["5 4 5", "12 11 1", "260 150 10", "78843 5684 42717", "93248 91435 1133", "100000 10 64479", "99999 21 73839", "99991 623 36438", "99999 334 94854", "99252 9827 84849", "99313 9833 10561", "94885 55815 11417", "99492 58525 53481", "99858 28531 79193", "99136 47208 42607", "63270 19953 5555", "10240 128 1000...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
265
codeforces
35a50ea38e4221ed5865e1c798e31f70
Queue
During the lunch break all *n* Berland State University students lined up in the food court. However, it turned out that the food court, too, has a lunch break and it temporarily stopped working. Standing in a queue that isn't being served is so boring! So, each of the students wrote down the number of the student ID ...
{"inputs": ["4\n92 31\n0 7\n31 0\n7 141", "2\n0 1\n2 0", "3\n0 2\n1 3\n2 0", "4\n101 0\n0 102\n102 100\n103 101", "5\n0 1\n1 4\n4 0\n3 2\n5 3", "6\n10001 0\n0 10005\n10003 10001\n10002 10000\n10005 10002\n10004 10003", "3\n0 743259\n72866 70294\n743259 0", "4\n263750 0\n513707 263750\n0 718595\n718595 148112", "5\n6458...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
17
codeforces
35bbecc566196fcd74d783f982cc2af3
Fuzzy Search
Leonid works for a small and promising start-up that works on decoding the human genome. His duties include solving complex problems of finding certain patterns in long strings consisting of letters 'A', 'T', 'G' and 'C'. Let's consider the following scenario. There is a fragment of a human DNA chain, recorded as a st...
{"inputs": ["10 4 1\nAGCAATTCAT\nACAT", "1 1 0\nA\nA", "1 1 0\nA\nT", "1 1 1\nA\nT", "5 3 0\nATATA\nATA", "5 3 1\nATATA\nATA", "7 1 2\nATGCGTA\nA", "7 1 3\nATGCGTA\nA", "4 4 0\nATGC\nGCTA", "4 4 1\nATGC\nGCTA", "4 4 2\nATGC\nGCTA"], "outputs": ["3", "1", "0", "0", "2", "3", "6", "7", "0", "0", "0"]}
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
1
codeforces
35f59990d3bb3ade5fa8445f532d08bd
Mike and Shortcuts
Recently, Mike was very busy with studying for exams and contests. Now he is going to chill a bit by doing some sight seeing in the city. City consists of *n* intersections numbered from 1 to *n*. Mike starts walking from his house located at the intersection number 1 and goes along some sequence of intersections. Wal...
{"inputs": ["3\n2 2 3", "5\n1 2 3 4 5", "7\n4 4 4 4 7 7 7", "98\n17 17 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 87 90 90 90 90 90 90 90 90 90 90 90 92 92 92 92 92 92 92 92 92 92 92 92 92 92 92 92 92 92 92 92 92 ...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
112
codeforces
360d5ca53c21826c3cdfaeaf31bc161f
Degree Set
You are given a sequence of *n* positive integers *d*1,<=*d*2,<=...,<=*d**n* (*d*1<=&lt;<=*d*2<=&lt;<=...<=&lt;<=*d**n*). Your task is to construct an undirected graph such that: - there are exactly *d**n*<=+<=1 vertices; - there are no self-loops; - there are no multiple edges; - there are no more than 106 edges;...
{"inputs": ["3\n2 3 4", "3\n1 2 3", "4\n1 3 4 6", "1\n1", "1\n1000", "2\n1 2", "2\n999 1000", "2\n1 1000", "3\n1 500 1000", "10\n1 2 3 4 5 6 7 8 9 10", "100\n1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 ...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
6
codeforces
361c65a707055feadf945f9300058ab5
Game of the Rows
Daenerys Targaryen has an army consisting of *k* groups of soldiers, the *i*-th group contains *a**i* soldiers. She wants to bring her army to the other side of the sea to get the Iron Throne. She has recently bought an airplane to carry her army through the sea. The airplane has *n* rows, each of them has 8 seats. We ...
{"inputs": ["2 2\n5 8", "1 2\n7 1", "1 2\n4 4", "1 4\n2 2 1 2", "10000 100\n749 2244 949 2439 2703 44 2394 124 285 3694 3609 717 1413 155 974 1778 1448 1327 1487 3458 319 1395 3783 2184 2062 43 826 38 3276 807 1837 4635 171 1386 1768 1128 2020 2536 800 782 3058 174 455 83 647 595 658 109 33 23 70 39 38 1 6 35 94 9 22 1...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
5
codeforces
362156831077fb306342d4c49eb233dc
Socks
Arseniy is already grown-up and independent. His mother decided to leave him alone for *m* days and left on a vacation. She have prepared a lot of food, left some money and washed all Arseniy's clothes. Ten minutes before her leave she realized that it would be also useful to prepare instruction of which particular c...
{"inputs": ["3 2 3\n1 2 3\n1 2\n2 3", "3 2 2\n1 1 2\n1 2\n2 1", "3 3 3\n1 2 3\n1 2\n2 3\n3 1", "4 2 4\n1 2 3 4\n1 2\n3 4", "10 3 2\n2 1 1 2 1 1 2 1 2 2\n4 10\n9 3\n5 7", "10 3 3\n2 2 1 3 1 2 1 2 2 2\n10 8\n9 6\n8 10", "4 3 2\n1 1 2 2\n1 2\n3 4\n2 3", "4 3 4\n1 2 3 4\n1 2\n3 4\n4 1"], "outputs": ["2", "0", "2", "2", "2"...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
6
codeforces
362feba21c62cb2d514cc00014d0d4ca
Road Widening
Mayor of city S just hates trees and lawns. They take so much space and there could be a road on the place they occupy! The Mayor thinks that one of the main city streets could be considerably widened on account of lawn nobody needs anyway. Moreover, that might help reduce the car jams which happen from time to time o...
{"inputs": ["3\n4 5\n4 5\n4 10", "4\n1 100\n100 1\n1 100\n100 1", "3\n1 1\n100 100\n1 1", "10\n21005 10850\n27020 13372\n28183 3724\n22874 13564\n27446 11493\n22522 10012\n24819 11529\n24166 11084\n24539 9211\n24152 9235", "1\n1 0", "1\n1 1000000", "1\n1000000 1000000", "1\n1 0", "1\n1 0", "1\n1 1", "2\n2 2\n1 1", "2\n...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
3
codeforces
363712d886c67d89c4774c1ab80e1323
Vanya and Lanterns
Vanya walks late at night along a straight street of length *l*, lit by *n* lanterns. Consider the coordinate system with the beginning of the street corresponding to the point 0, and its end corresponding to the point *l*. Then the *i*-th lantern is at the point *a**i*. The lantern lights all points of the street that...
{"inputs": ["7 15\n15 5 3 7 9 14 0", "2 5\n2 5", "46 615683844\n431749087 271781274 274974690 324606253 480870261 401650581 13285442 478090364 266585394 425024433 588791449 492057200 391293435 563090494 317950 173675329 473068378 356306865 311731938 192959832 321180686 141984626 578985584 512026637 175885185 590844074 ...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
247
codeforces
365b239ca6df2157eeed016988a58111
String Manipulation 1.0
One popular website developed an unusual username editing procedure. One can change the username only by deleting some characters from it: to change the current name *s*, a user can pick number *p* and character *c* and delete the *p*-th occurrence of character *c* from the name. After the user changed his name, he can...
{"inputs": ["2\nbac\n3\n2 a\n1 b\n2 c", "1\nabacaba\n4\n1 a\n1 a\n1 c\n2 b", "1\naabbabbb\n7\n2 a\n1 a\n1 a\n2 b\n1 b\n3 b\n1 b", "1\na\n0", "4\ndb\n5\n1 d\n2 d\n2 b\n1 d\n2 b", "10\nbabcbcbcba\n40\n24 b\n14 a\n19 b\n25 b\n26 c\n7 c\n5 c\n2 a\n4 c\n7 a\n46 b\n14 a\n28 b\n4 c\n5 a\n10 c\n4 c\n4 b\n12 a\n4 a\n30 b\n4 a\n...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
14
codeforces
36647db424d1b4e3c8cb6f7a5bff699e
Run For Your Prize
You and your friend are participating in a TV show "Run For Your Prize". At the start of the show *n* prizes are located on a straight line. *i*-th prize is located at position *a**i*. Positions of all prizes are distinct. You start at position 1, your friend — at position 106 (and there is no prize in any of these tw...
{"inputs": ["3\n2 3 9", "2\n2 999995", "1\n20", "6\n2 3 500000 999997 999998 999999", "1\n999999", "1\n510000", "3\n2 5 27", "2\n600000 800000", "5\n2 5 6 27 29", "1\n500001", "10\n3934 38497 42729 45023 51842 68393 77476 82414 91465 98055", "1\n900000", "1\n500000", "1\n999998", "3\n999997 999998 999999", "2\n999997 9...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
139
codeforces
366f6a376c67748485aab11d0553e116
One Bomb
You are given a description of a depot. It is a rectangular checkered field of *n*<=×<=*m* size. Each cell in a field can be empty (".") or it can be occupied by a wall ("*"). You have one bomb. If you lay the bomb at the cell (*x*,<=*y*), then after triggering it will wipe out all walls in the row *x* and all walls ...
{"inputs": ["3 4\n.*..\n....\n.*..", "3 3\n..*\n.*.\n*..", "6 5\n..*..\n..*..\n*****\n..*..\n..*..\n..*..", "1 10\n**********", "10 1\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*", "10 10\n.........*\n.........*\n........**\n.........*\n.........*\n.........*\n.........*\n.........*\n.........*\n.........*", "10 10\n.........*\n........
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
44
codeforces
37208f991037cb5e2d4dcaa11439e2a7
Stack Sorting
Let's suppose you have an array *a*, a stack *s* (initially empty) and an array *b* (also initially empty). You may perform the following operations until both *a* and *s* are empty: - Take the first element of *a*, push it into *s* and remove it from *a* (if *a* is not empty); - Take the top element from *s*, appe...
{"inputs": ["5 3\n3 2 1", "5 3\n2 3 1", "5 1\n3", "5 2\n3 4", "100000 1\n98419", "20 19\n2 18 19 11 9 20 15 1 8 14 4 6 5 12 17 16 7 13 3", "10 1\n6", "100000 2\n64398 63673", "20 18\n8 14 18 10 1 3 7 15 2 12 17 19 5 4 11 13 20 16", "10 2\n3 7", "100000 3\n43791 91790 34124", "20 17\n9 11 19 4 8 16 13 3 1 6 18 2 20 10 1...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
8
codeforces
3779847abee2f9fe6408a04982f8ab8c
Magic Formulas
People in the Tomskaya region like magic formulas very much. You can see some of them below. Imagine you are given a sequence of positive integer numbers *p*1, *p*2, ..., *p**n*. Lets write down some magic formulas: Here, "mod" means the operation of taking the residue after dividing. The expression means applying ...
{"inputs": ["3\n1 2 3", "1\n0", "2\n65535 0", "10\n1356106972 165139648 978829595 410669403 873711167 287346624 117863440 228957745 835903650 1575323015", "20\n1999581813 313463235 1733614990 662007911 1789348031 1120800519 196972430 1579897311 191001928 241720485 1426288783 1103088596 839698523 1974815116 77040208 904...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
41
codeforces
378178d27a3bda3a7b1f7222ba920c1a
Generate a String
zscoder wants to generate an input file for some programming competition problem. His input is a string consisting of *n* letters 'a'. He is too lazy to write a generator so he will manually generate the input in a text editor. Initially, the text editor is empty. It takes him *x* seconds to insert or delete a letter...
{"inputs": ["8 1 1", "8 1 10", "10 62 99", "88 417 591", "57 5289 8444", "382 81437847 324871127", "244 575154303 436759189", "85 902510038 553915152", "1926 84641582 820814219", "3768 561740421 232937477", "2313 184063453 204869248", "35896 278270961 253614967", "483867 138842067 556741142", "4528217 187553422 9567316...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
19
codeforces
37bdb804b3a8f89ec2cce9cc72ad2faf
Vladik and fractions
Vladik and Chloe decided to determine who of them is better at math. Vladik claimed that for any positive integer *n* he can represent fraction as a sum of three distinct positive fractions in form . Help Vladik with that, i.e for a given *n* find three distinct positive integers *x*, *y* and *z* such that . Because ...
{"inputs": ["3", "7", "2", "5", "4", "7", "82", "56", "30", "79", "28", "4116", "1", "6491", "8865", "1239", "3614", "5988", "8363", "737", "3112", "9562", "1936", "4311", "6685", "9060", "1434", "3809", "6183", "8558", "932", "7274", "9648", "2023", "4397", "6772", "9146", "1521", "4938", "6143", "6230", "10000", "1",...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
87
codeforces
37d4336f42407eff62c58aca172c1ac5
Two Problems
A boy Valera registered on site Codeforces as Valera, and wrote his first Codeforces Round #300. He boasted to a friend Arkady about winning as much as *x* points for his first contest. But Arkady did not believe his friend's words and decided to check whether Valera could have shown such a result. He knows that the c...
{"inputs": ["30 5 20 20 3 5", "10 4 100 5 5 1", "0 7 30 50 3 4", "50 10 30 20 1 2", "40 1 40 5 11 2", "35 8 20 20 1 2", "10 2 27 4 11 1", "64 12 258 141 10 7", "5 3 11 100 2 4", "5 4 11 80 2 4", "28 3 16 20 3 10", "6 2 11 1 11 1", "15 5 230 213 32 25", "223 92 123 118 1 1", "375 6 133 267 19 36", "80 5 39 40 1 1", "543...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
24
codeforces
37e42fdcd1037129a1f34ce83dd72e75
Problem of offices
Earlier, when there was no Internet, each bank had a lot of offices all around Bankopolis, and it caused a lot of problems. Namely, each day the bank had to collect cash from all the offices. Once Oleg the bank client heard a dialogue of two cash collectors. Each day they traveled through all the departments and offic...
{"inputs": ["5\n2 3 4 5\n1 1 1 1", "10\n3 8 9 10\n1 2 2 2 2 2 1 1 1", "13\n13 12 9 7\n1 1 1 1 5 5 2 2 2 3 3 4", "11\n2 4 9 11\n1 1 3 3 3 3 3 1 1 10", "11\n4 2 9 11\n1 1 3 3 3 3 3 1 1 10", "6\n2 3 4 5\n1 1 1 1 1", "15\n3 9 15 13\n1 2 2 1 5 5 1 8 1 10 1 12 1 14", "15\n8 13 5 10\n1 2 1 4 1 6 6 1 9 1 11 12 1 14", "15\n15 2...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
1
codeforces
37eadde8522bad99e820e7f5d7ae04d2
Partition
You are given a sequence *a* consisting of *n* integers. You may partition this sequence into two sequences *b* and *c* in such a way that every element belongs exactly to one of these sequences. Let *B* be the sum of elements belonging to *b*, and *C* be the sum of elements belonging to *c* (if some of these sequenc...
{"inputs": ["3\n1 -2 0", "6\n16 23 16 15 42 8", "1\n-1", "100\n-100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 -1...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
390
codeforces
37f46064990b21a89a9ebaabdcaa6116
Little Elephant and Bits
The Little Elephant has an integer *a*, written in the binary notation. He wants to write this number on a piece of paper. To make sure that the number *a* fits on the piece of paper, the Little Elephant ought to delete exactly one any digit from number *a* in the binary record. At that a new number appears. It consis...
{"inputs": ["101", "110010", "10000", "1111111110", "10100101011110101", "111010010111", "11110111011100000000", "11110010010100001110110101110011110110100111101", "1001011111010010100111111", "1111111111", "1111111111111111111100111101001110110111111000001111110101001101001110011000001011001111111000110101", "11010110...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
540
codeforces
37f844d788fd8dae07bad399725a4218
Vasily the Bear and Fly
One beautiful day Vasily the bear painted 2*m* circles of the same radius *R* on a coordinate plane. Circles with numbers from 1 to *m* had centers at points (2*R*<=-<=*R*,<=0), (4*R*<=-<=*R*,<=0), ..., (2*Rm*<=-<=*R*,<=0), respectively. Circles with numbers from *m*<=+<=1 to 2*m* had centers at points (2*R*<=-<=*R*,<=...
{"inputs": ["1 1", "2 2", "100000 3", "2344 5", "999 10", "6 1", "43 4", "3333 3", "4444 4", "100000 10", "3134 9", "9 9", "32 9", "33333 9", "99999 1", "99999 9", "99999 7", "4234 4", "66666 6", "66666 9", "67676 7", "7777 7", "7656 2", "2 8", "2 10", "2 4", "8 1", "8 8", "92399 1", "1 10", "3 1"], "outputs": ["2.0000...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
9
codeforces