source int64 2 2 | difficulty int64 7 25 | name stringlengths 9 60 | description stringlengths 164 7.12k | public_tests dict | private_tests dict | cf_rating int64 0 3.5k | cf_points float64 0 4k |
|---|---|---|---|---|---|---|---|
2 | 7 | 1059_A. Cashier | Vasya has recently got a job as a cashier at a local store. His day at work is L minutes long. Vasya has already memorized n regular customers, the i-th of which comes after t_{i} minutes after the beginning of the day, and his service consumes l_{i} minutes. It is guaranteed that no customer will arrive while Vasya is... | {
"input": [
"2 11 3\n0 1\n1 1\n",
"0 5 2\n",
"1 3 2\n1 2\n"
],
"output": [
"3\n",
"2\n",
"0\n"
]
} | {
"input": [
"0 1 1\n",
"1 5 3\n3 1\n",
"0 1000000000 1\n",
"3 21 3\n3 3\n9 3\n15 3\n",
"0 1000000000 1000000000\n",
"1 1 1\n0 1\n",
"2 10 3\n0 1\n9 1\n",
"1 1000000000 1\n0 1000000000\n",
"0 1000000000 500000000\n",
"1 10 5\n5 2\n",
"1 3 2\n1 1\n",
"1 2 1\n1 1\n"
],
... | 1,000 | 500 |
2 | 9 | 1080_C. Masha and two friends | Recently, Masha was presented with a chessboard with a height of n and a width of m.
The rows on the chessboard are numbered from 1 to n from bottom to top. The columns are numbered from 1 to m from left to right. Therefore, each cell can be specified with the coordinates (x,y), where x is the column number, and y is ... | {
"input": [
"5\n2 2\n1 1 2 2\n1 1 2 2\n3 4\n2 2 3 2\n3 1 4 3\n1 5\n1 1 5 1\n3 1 5 1\n4 4\n1 1 4 2\n1 3 4 4\n3 4\n1 2 4 2\n2 1 3 3\n"
],
"output": [
"0 4\n3 9\n2 3\n8 8\n4 8\n"
]
} | {
"input": [
"1\n3456 4567\n1 234 678 1000\n346 903 1005 2003\n"
],
"output": [
"7772142 8011410\n"
]
} | 1,500 | 1,250 |
2 | 8 | 10_B. Cinema Cashier | All cinema halls in Berland are rectangles with K rows of K seats each, and K is an odd number. Rows and seats are numbered from 1 to K. For safety reasons people, who come to the box office to buy tickets, are not allowed to choose seats themselves. Formerly the choice was made by a cashier, but now this is the respon... | {
"input": [
"4 3\n1 2 3 1\n",
"2 1\n1 1\n"
],
"output": [
"2 2 2\n1 1 2\n3 1 3\n2 1 1\n",
"1 1 1\n-1\n"
]
} | {
"input": [
"2 3\n3 3\n",
"80 29\n19 15 15 27 2 25 2 5 29 11 6 4 20 11 27 16 6 6 10 2 5 12 8 23 11 7 11 13 19 29 8 4 9 13 14 22 16 29 7 12 17 5 17 14 6 15 8 25 11 16 14 4 3 7 25 2 5 2 12 12 22 18 14 16 5 19 25 4 21 24 7 11 21 27 10 16 21 17 19 13\n",
"1 3\n1\n",
"100 57\n5 19 50 55 18 54 30 56 54 16 ... | 1,500 | 0 |
2 | 7 | 1121_A. Technogoblet of Fire | Everybody knows that the m-coder Tournament will happen soon. m schools participate in the tournament, and only one student from each school participates.
There are a total of n students in those schools. Before the tournament, all students put their names and the names of their schools into the Technogoblet of Fire. ... | {
"input": [
"8 4 4\n1 2 3 4 5 6 7 8\n4 3 2 1 4 3 2 1\n3 4 5 6\n",
"7 3 1\n1 5 3 4 6 7 2\n1 3 1 2 1 2 3\n3\n"
],
"output": [
"2\n",
"1\n"
]
} | {
"input": [
"2 1 1\n1 2\n1 1\n1\n",
"2 1 1\n1 2\n1 1\n2\n",
"1 1 1\n1\n1\n1\n",
"10 5 4\n4 2 1 7 10 9 6 3 5 8\n3 2 1 4 5 1 4 2 4 2\n9 3 2 6\n",
"10 1 10\n9 1 2 3 5 7 4 10 6 8\n1 1 1 1 1 1 1 1 1 1\n8 9 5 7 1 10 6 2 4 3\n",
"5 1 1\n4 3 2 1 5\n1 1 1 1 1\n5\n",
"13 2 4\n8 13 2 4 6 9 5 12 3 11... | 1,100 | 500 |
2 | 9 | 1148_C. Crazy Diamond | You are given a permutation p of integers from 1 to n, where n is an even number.
Your goal is to sort the permutation. To do so, you can perform zero or more operations of the following type:
* take two indices i and j such that 2 β
|i - j| β₯ n and swap p_i and p_j.
There is no need to minimize the number of... | {
"input": [
"2\n2 1\n",
"4\n3 4 1 2\n",
"6\n2 5 3 1 4 6\n"
],
"output": [
"1\n1 2\n",
"2\n1 3\n2 4\n",
"5\n1 6\n2 6\n1 6\n1 5\n1 4\n"
]
} | {
"input": [
"10\n6 1 2 9 3 5 4 10 7 8\n",
"100\n47 54 37 8 33 97 74 80 35 96 55 39 15 67 85 92 49 50 1 25 70 53 48 19 86 16 14 68 60 41 40 87 29 27 34 94 26 42 17 38 45 4 22 13 31 57 23 99 73 90 44 88 3 63 59 93 52 30 20 21 18 7 12 58 56 81 32 82 84 76 9 10 64 77 2 65 61 5 43 66 100 69 71 36 79 11 95 46 6 28... | 1,700 | 1,500 |
2 | 12 | 1206_F. Almost All | You are given a tree with n nodes. You have to write non-negative integers on its edges so that the following condition would be satisfied:
For every two nodes i, j, look at the path between them and count the sum of numbers on the edges of this path. Write all obtained sums on the blackboard. Then every integer from ... | {
"input": [
"4\n2 4\n2 3\n2 1\n",
"3\n2 3\n2 1\n",
"5\n1 2\n1 3\n1 4\n2 5\n"
],
"output": [
"2 4 1\n2 3 2\n2 1 4\n",
"2 3 1\n2 1 2\n",
"1 2 1\n2 5 1\n1 3 3\n1 4 6\n"
]
} | {
"input": [
"43\n7 29\n19 18\n32 4\n39 40\n21 11\n34 28\n30 23\n13 19\n33 39\n13 35\n37 21\n29 8\n40 1\n7 9\n8 38\n7 31\n8 12\n7 42\n33 20\n5 36\n17 32\n30 43\n39 34\n40 3\n8 24\n13 37\n35 16\n23 22\n7 41\n35 30\n9 14\n13 2\n7 27\n10 25\n17 15\n41 10\n39 26\n39 17\n33 7\n20 13\n39 6\n34 5\n",
"10\n1 2\n1 4\n... | 2,700 | 2,000 |
2 | 8 | 1225_B1. TV Subscriptions (Easy Version) | The only difference between easy and hard versions is constraints.
The BerTV channel every day broadcasts one episode of one of the k TV shows. You know the schedule for the next n days: a sequence of integers a_1, a_2, ..., a_n (1 β€ a_i β€ k), where a_i is the show, the episode of which will be shown in i-th day.
The... | {
"input": [
"4\n5 2 2\n1 2 1 2 1\n9 3 3\n3 3 3 2 2 2 1 1 1\n4 10 4\n10 8 6 4\n16 9 8\n3 1 4 1 5 9 2 6 5 3 5 8 9 7 9 3\n"
],
"output": [
"2\n1\n4\n5\n"
]
} | {
"input": [
"1\n100 20 1\n10 17 9 8 11 8 8 3 7 20 11 10 7 7 2 13 10 7 7 10 7 8 4 17 20 9 5 18 12 8 3 5 19 1 18 14 9 11 12 11 11 12 12 9 13 8 20 3 8 1 15 20 6 18 8 1 13 11 4 17 12 15 4 4 11 19 18 5 2 12 15 20 5 8 11 16 14 13 17 14 14 5 6 8 8 13 6 3 18 14 8 14 11 11 9 4 18 1 16 6\n",
"1\n100 100 99\n100 99 98 ... | 1,000 | 750 |
2 | 10 | 1249_D1. Too Many Segments (easy version) | The only difference between easy and hard versions is constraints.
You are given n segments on the coordinate axis OX. Segments can intersect, lie inside each other and even coincide. The i-th segment is [l_i; r_i] (l_i β€ r_i) and it covers all integer points j such that l_i β€ j β€ r_i.
The integer point is called bad... | {
"input": [
"5 1\n29 30\n30 30\n29 29\n28 30\n30 30\n",
"7 2\n11 11\n9 11\n7 8\n8 9\n7 8\n9 11\n7 9\n",
"6 1\n2 3\n3 3\n2 3\n2 2\n2 3\n2 3\n"
],
"output": [
"3\n4 1 5 ",
"3\n7 4 6 ",
"4\n1 3 5 6\n"
]
} | {
"input": [
"15 2\n4 4\n16 18\n16 18\n6 9\n3 14\n8 11\n3 13\n3 6\n14 16\n5 17\n7 14\n11 14\n4 4\n10 11\n13 17\n",
"16 3\n181 182\n183 184\n179 181\n178 178\n182 185\n177 184\n179 184\n176 184\n177 184\n176 176\n176 185\n183 185\n175 177\n179 183\n184 184\n175 176\n",
"18 1\n116 138\n106 165\n105 130\n142... | 1,800 | 0 |
2 | 19 | 1267_L. Lexicography | Lucy likes letters. She studied the definition of the lexicographical order at school and plays with it.
At first, she tried to construct the lexicographically smallest word out of given letters. It was so easy! Then she tried to build multiple words and minimize one of them. This was much harder!
Formally, Lucy want... | {
"input": [
"2 3 1\nabcabc\n",
"3 2 2\nabcdef\n"
],
"output": [
"aab\nbcc\n",
"ad\nbc\nef\n"
]
} | {
"input": [
"5 5 5\nuuuuuyyyyybbbbbqqqqqkkkkk\n",
"10 9 2\nskpjgpwrqajrdnynybnsmybttmhkboiqlndqtghvqyorholdzwasytnvteawhahjfhjknhfobiifrtfrlbjkqyxgnc\n",
"10 1 3\navdtkzddkk\n",
"3 2 2\nabcdef\n",
"1 10 1\nlduuukmwxx\n",
"9 1 9\neeeeeeeee\n",
"9 10 5\nafdfhplzplgrnrgzpzplbdhnulrxplafgpgbz... | 1,800 | 0 |
2 | 13 | 1332_G. No Monotone Triples | Given a sequence of integers a of length n, a tuple (i,j,k) is called monotone triples if
* 1 β€ i<j<kβ€ n;
* a_i β€ a_j β€ a_k or a_i β₯ a_j β₯ a_k is satisfied.
For example, a=[5,3,4,5], then (2,3,4) is monotone triples for sequence a while (1,3,4) is not.
Bob is given a sequence of integers a of length n in a ... | {
"input": [
"6 2\n3 1 4 1 5 9\n1 3\n4 6\n"
],
"output": [
"3\n1 2 3 \n0\n\n"
]
} | {
"input": [
"10 5\n448242954 927941687 223935474 107020324 288030870 635970780 444360884 697847668 783719272 808030300\n3 10\n4 9\n3 8\n2 5\n5 9\n",
"3 1\n1000000000 1000000000 1000000000\n1 3\n",
"30 27\n698632656 525581861 577504542 296603772 998990943 682881766 954895689 281259836 501177498 256330408 ... | 3,100 | 3,000 |
2 | 9 | 1353_C. Board Moves | You are given a board of size n Γ n, where n is odd (not divisible by 2). Initially, each cell of the board contains one figure.
In one move, you can select exactly one figure presented in some cell and move it to one of the cells sharing a side or a corner with the current cell, i.e. from the cell (i, j) you can move... | {
"input": [
"3\n1\n5\n499993\n"
],
"output": [
"0\n40\n41664916690999888\n"
]
} | {
"input": [
"3\n5\n3005\n3005\n",
"1\n69791\n",
"1\n214541\n",
"1\n499999\n",
"1\n214145\n"
],
"output": [
"40\n9045074040\n9045074040\n",
"113312287936960\n",
"3291619655775960\n",
"41666416667000000\n",
"3273426253628160\n"
]
} | 1,000 | 0 |
2 | 8 | 1373_B. 01 Game | Alica and Bob are playing a game.
Initially they have a binary string s consisting of only characters 0 and 1.
Alice and Bob make alternating moves: Alice makes the first move, Bob makes the second move, Alice makes the third one, and so on. During each move, the current player must choose two different adjacent char... | {
"input": [
"3\n01\n1111\n0011\n"
],
"output": [
"DA\nNET\nNET\n"
]
} | {
"input": [
"1\n00000000000\n",
"1\n111111111111111110000000000000000\n",
"1\n11111111111\n",
"1\n1\n",
"1\n0\n",
"1\n1111111111\n",
"2\n11111111111\n11111111111\n"
],
"output": [
"NET\n",
"NET\n",
"NET\n",
"NET\n",
"NET\n",
"NET\n",
"NET\nNET\n"
]
} | 900 | 0 |
2 | 7 | 1396_A. Multiples of Length | You are given an array a of n integers.
You want to make all elements of a equal to zero by doing the following operation exactly three times:
* Select a segment, for each number in this segment we can add a multiple of len to it, where len is the length of this segment (added integers can be different).
It can... | {
"input": [
"4\n1 3 2 4\n"
],
"output": [
"1 1\n-1\n2 4\n9 6 12\n1 4\n0 -12 -8 -16\n"
]
} | {
"input": [
"1\n-2\n",
"1\n-1\n",
"16\n-15108237 489260742 681810357 -78861365 -416467743 -896443270 904192296 -932642644 173249302 402207268 -329323498 537696045 -899233426 902347982 -595589754 -480337024\n",
"2\n-492673762 -496405053\n",
"1\n34688642\n",
"32\n474784688 671671886 -592758087 ... | 1,600 | 500 |
2 | 9 | 141_C. Queue | In the Main Berland Bank n people stand in a queue at the cashier, everyone knows his/her height hi, and the heights of the other people in the queue. Each of them keeps in mind number ai β how many people who are taller than him/her and stand in queue in front of him.
After a while the cashier has a lunch break and t... | {
"input": [
"4\nvasya 0\npetya 1\nmanya 3\ndunay 3\n",
"4\na 0\nb 2\nc 0\nd 0\n"
],
"output": [
"-1\n",
"a 1\nc 3\nd 4\nb 2\n"
]
} | {
"input": [
"23\nfgtxkw 4\nqgbokh 0\nfrb 0\nnninr 10\nbczzdfvjkh 1\nuxpelsmxxq 2\nntvvx 2\nardaae 0\nctetnl 0\nhgk 0\nvmwo 18\nojaubfibf 1\nnu 7\ngbixtuotft 4\nekmjrgxylj 1\navcygg 1\nmxgdulijf 1\notjmjmvpz 3\nxzubpxqnj 14\nlowoz 3\nmnfg 4\no 15\nm 1\n",
"5\ngnaczgg 2\nzokbxiahao 4\nb 0\nnljumplxkn 4\nfyclu ... | 1,800 | 2,000 |
2 | 9 | 1438_C. Engineer Artem | Artem is building a new robot. He has a matrix a consisting of n rows and m columns. The cell located on the i-th row from the top and the j-th column from the left has a value a_{i,j} written in it.
If two adjacent cells contain the same value, the robot will break. A matrix is called good if no two adjacent cells c... | {
"input": [
"3\n3 2\n1 2\n4 5\n7 8\n2 2\n1 1\n3 3\n2 2\n1 3\n2 2\n"
],
"output": [
"2 3\n5 6\n8 9\n2 1\n3 4\n2 3\n3 2\n"
]
} | {
"input": [
"1\n10 10\n1 1 1 1 1 1 1 1 1 1\n1 1 1 1 1 1 1 1 1 1\n1 1 1 1 1 1 1 1 1 1\n1 1 1 1 1 1 1 1 1 1\n1 1 1 1 1 1 1 1 1 1\n1 1 1 1 1 1 1 1 1 1\n1 1 1 1 1 1 1 1 1 1\n1 1 1 1 1 1 1 1 1 1\n1 1 1 1 1 1 1 1 1 1\n1 1 1 1 1 1 1 1 1 1\n",
"3\n3 2\n1 2\n4 5\n7 8\n2 2\n1 1\n3 3\n2 2\n1 3\n2 2\n"
],
"output": ... | 2,000 | 1,250 |
2 | 8 | 1463_B. Find The Array | You are given an array [a_1, a_2, ..., a_n] such that 1 β€ a_i β€ 10^9. Let S be the sum of all elements of the array a.
Let's call an array b of n integers beautiful if:
* 1 β€ b_i β€ 10^9 for each i from 1 to n;
* for every pair of adjacent integers from the array (b_i, b_{i + 1}), either b_i divides b_{i + 1}, or... | {
"input": [
"4\n5\n1 2 3 4 5\n2\n4 6\n2\n1 1000000000\n6\n3 4 8 1 2 3\n"
],
"output": [
"\n3 3 3 3 3\n3 6\n1 1000000000\n4 4 8 1 3 3\n"
]
} | {
"input": [
"1\n10\n1000000000 500000001 500000001 500000001 500000001 500000001 500000001 500000001 500000001 500000001\n",
"2\n7\n818 14 386 159 110 186 49\n7\n694 42 511 953 30 284 57\n",
"1\n3\n1 1 1\n",
"1\n4\n37 19 19 19\n",
"1\n50\n1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 8 8 8 ... | 1,400 | 0 |
2 | 8 | 148_B. Escape | The princess is going to escape the dragon's cave, and she needs to plan it carefully.
The princess runs at vp miles per hour, and the dragon flies at vd miles per hour. The dragon will discover the escape after t hours and will chase the princess immediately. Looks like there's no chance to success, but the princess ... | {
"input": [
"1\n2\n1\n1\n10\n",
"1\n2\n1\n1\n8\n"
],
"output": [
"2\n",
"1\n"
]
} | {
"input": [
"71\n19\n2\n10\n645\n",
"6\n24\n9\n8\n628\n",
"26\n36\n4\n7\n318\n",
"2\n100\n10\n10\n739\n",
"47\n43\n10\n9\n43\n",
"71\n45\n2\n6\n547\n",
"2\n1\n1\n1\n1000\n",
"13\n14\n3\n3\n79\n",
"77\n1\n6\n8\n831\n",
"2\n27\n4\n9\n937\n",
"6\n45\n7\n8\n407\n",
"51\n42... | 1,500 | 1,000 |
2 | 10 | 1539_D. PriceFixed | Lena is the most economical girl in Moscow. So, when her dad asks her to buy some food for a trip to the country, she goes to the best store β "PriceFixed". Here are some rules of that store:
* The store has an infinite number of items of every product.
* All products have the same price: 2 rubles per item.
* ... | {
"input": [
"5\n2 7\n2 8\n1 2\n2 4\n1 8\n",
"3\n3 4\n1 3\n1 5\n"
],
"output": [
"12\n",
"8\n"
]
} | {
"input": [
"8\n1 8\n1 6\n1 5\n1 3\n1 3\n1 8\n1 7\n1 3\n",
"4\n4 1\n2 2\n1 6\n1 2\n",
"7\n2 11\n3 12\n2 1\n2 6\n1 6\n2 2\n3 14\n",
"8\n1 7\n3 16\n1 15\n2 1\n1 15\n4 11\n1 4\n2 15\n",
"4\n2 1\n3 2\n4 3\n5 100\n",
"15\n1 7\n1 14\n1 6\n1 13\n1 9\n1 10\n1 5\n1 14\n1 14\n1 11\n1 5\n1 4\n1 10\n1 8\... | 1,600 | 1,500 |
2 | 7 | 166_A. Rank List | Another programming contest is over. You got hold of the contest's final results table. The table has the following data. For each team we are shown two numbers: the number of problems and the total penalty time. However, for no team we are shown its final place.
You know the rules of comparing the results of two give... | {
"input": [
"5 4\n3 1\n3 1\n5 3\n3 1\n3 1\n",
"7 2\n4 10\n4 10\n4 10\n3 20\n2 1\n2 1\n1 10\n"
],
"output": [
"4\n",
"3\n"
]
} | {
"input": [
"50 50\n50 50\n50 50\n50 50\n50 50\n50 50\n50 50\n50 50\n50 50\n50 50\n50 50\n50 50\n50 50\n50 50\n50 50\n50 50\n50 50\n50 50\n50 50\n50 50\n50 50\n50 50\n50 50\n50 50\n50 50\n50 50\n50 50\n50 50\n50 50\n50 50\n50 50\n50 50\n50 50\n50 50\n50 50\n50 50\n50 50\n50 50\n50 50\n50 50\n50 50\n50 50\n50 50\... | 1,100 | 500 |
2 | 9 | 233_C. Cycles | John Doe started thinking about graphs. After some thought he decided that he wants to paint an undirected graph, containing exactly k cycles of length 3.
A cycle of length 3 is an unordered group of three distinct graph vertices a, b and c, such that each pair of them is connected by a graph edge.
John has been pa... | {
"input": [
"10\n",
"1\n"
],
"output": [
"5\n01111\n10111\n11011\n11101\n11110\n",
"3\n011\n101\n110\n"
]
} | {
"input": [
"99016\n",
"99022\n",
"5\n",
"99007\n",
"7\n",
"99007\n",
"98685\n",
"100000\n",
"99020\n",
"99994\n",
"97560\n",
"4\n",
"99021\n",
"97560\n",
"99994\n",
"99011\n",
"99004\n",
"9\n",
"99999\n",
"99009\n",
"99004\n",
"... | 1,600 | 500 |
2 | 8 | 259_B. Little Elephant and Magic Square | Little Elephant loves magic squares very much.
A magic square is a 3 Γ 3 table, each cell contains some positive integer. At that the sums of integers in all rows, columns and diagonals of the table are equal. The figure below shows the magic square, the sum of integers in all its rows, columns and diagonals equals 15... | {
"input": [
"0 1 1\n1 0 1\n1 1 0\n",
"0 3 6\n5 0 5\n4 7 0\n"
],
"output": [
"1 1 1\n1 1 1\n1 1 1\n",
"6 3 6\n5 5 5\n4 7 4\n"
]
} | {
"input": [
"0 100000 100000\n100000 0 100000\n100000 100000 0\n",
"0 99626 99582\n99766 0 99258\n99442 99398 0\n",
"0 6361 2304\n1433 0 8103\n7232 3175 0\n",
"0 28 10\n12 0 24\n26 8 0\n",
"0 97 56\n69 0 71\n84 43 0\n",
"0 4 4\n4 0 4\n4 4 0\n",
"0 9 2\n3 0 7\n8 1 0\n",
"0 99978 99920\... | 1,100 | 1,000 |
2 | 8 | 282_B. Painting Eggs | The Bitlandians are quite weird people. They have very peculiar customs.
As is customary, Uncle J. wants to have n eggs painted for Bitruz (an ancient Bitland festival). He has asked G. and A. to do the work.
The kids are excited because just as is customary, they're going to be paid for the job!
Overall uncle J. h... | {
"input": [
"2\n1 999\n999 1\n",
"3\n400 600\n400 600\n400 600\n"
],
"output": [
"AG\n",
"AGA\n"
]
} | {
"input": [
"1\n500 500\n",
"2\n500 500\n500 500\n",
"1\n1 999\n",
"2\n499 501\n501 499\n",
"10\n1 999\n1 999\n1 999\n1 999\n1 999\n1 999\n1 999\n1 999\n1 999\n1 999\n",
"1\n0 1000\n",
"1\n1000 0\n",
"3\n500 500\n1 999\n400 600\n"
],
"output": [
"A\n",
"AG\n",
"A\n",
... | 1,500 | 1,000 |
2 | 7 | 305_A. Strange Addition | Unfortunately, Vasya can only sum pairs of integers (a, b), such that for any decimal place at least one number has digit 0 in this place. For example, Vasya can sum numbers 505 and 50, but he cannot sum 1 and 4.
Vasya has a set of k distinct non-negative integers d1, d2, ..., dk.
Vasya wants to choose some integers ... | {
"input": [
"4\n100 10 1 0\n",
"3\n2 70 3\n"
],
"output": [
"4\n100 10 1 0\n",
"2\n2 70\n"
]
} | {
"input": [
"1\n1\n",
"39\n16 72 42 70 17 36 32 40 47 94 27 30 100 55 23 77 67 28 49 50 53 83 38 33 60 65 62 64 6 66 69 86 96 75 85 0 89 73 29\n",
"3\n99 10 6\n",
"2\n10 12\n",
"4\n0 100 10 99\n",
"1\n100\n",
"1\n99\n",
"2\n5 6\n",
"3\n0 100 10\n",
"96\n17 10 0 85 57 78 15 99 ... | 1,600 | 500 |
2 | 7 | 331_A2. Oh Sweet Beaverette | β Oh my sweet Beaverette, would you fancy a walk along a wonderful woodland belt with me?
β Of course, my Smart Beaver! Let us enjoy the splendid view together. How about Friday night?
At this point the Smart Beaver got rushing. Everything should be perfect by Friday, so he needed to prepare the belt to the upcomin... | {
"input": [
"5\n1 2 3 1 2\n",
"5\n1 -2 3 1 -2\n"
],
"output": [
"8 1\n1 ",
"5 2\n2 5 "
]
} | {
"input": [
"3\n1000000000 1000000000 1000000000\n",
"6\n-1 3 3 5 5 -1\n",
"10\n-589330597 -126288833 -126288833 -834860352 -834860352 -834860352 -834860352 -21170405 -834860352 -834860352\n",
"20\n-808998072 733614990 579897311 -337992089 579897311 120800519 -337992089 -803027570 733614990 -68653676... | 1,500 | 70 |
2 | 7 | 377_A. Maze | Pavel loves grid mazes. A grid maze is an n Γ m rectangle maze where each cell is either empty, or is a wall. You can go from one cell to another only if both cells are empty and have a common side.
Pavel drew a grid maze with all empty cells forming a connected area. That is, you can go from any empty cell to any oth... | {
"input": [
"3 4 2\n#..#\n..#.\n#...\n",
"5 4 5\n#...\n#.#.\n.#..\n...#\n.#.#\n"
],
"output": [
"#..#\n..#X\n#..X\n",
"#...\n#.#.\nX#..\nXX.#\nX#X#\n"
]
} | {
"input": [
"2 5 3\n.....\n..#..\n",
"3 5 1\n#....\n..#..\n..###\n",
"7 7 18\n#.....#\n..#.#..\n.#...#.\n...#...\n.#...#.\n..#.#..\n#.....#\n",
"4 4 3\n....\n.#..\n..##\n..##\n",
"5 7 4\n.......\n...#...\n...#...\n...#...\n...#...\n",
"5 4 4\n#..#\n....\n.##.\n....\n#..#\n",
"4 5 1\n........ | 1,600 | 500 |
2 | 9 | 399_C. Cards | User ainta loves to play with cards. He has a cards containing letter "o" and b cards containing letter "x". He arranges the cards in a row, and calculates the score of the deck by the formula below.
1. At first, the score is 0.
2. For each block of contiguous "o"s with length x the score increases by x2.
3. F... | {
"input": [
"0 4\n",
"2 3\n",
"4 0\n"
],
"output": [
"-16\nxxxx\n",
"-1\nxxoox\n",
"16\noooo\n"
]
} | {
"input": [
"7 18030\n",
"79979 92032\n",
"5 17\n",
"1 2\n",
"83093 94343\n",
"1698 32709\n",
"31161 18112\n",
"38 5\n",
"9966 12376\n",
"1 0\n",
"21478 14813\n",
"206 209\n",
"4 9\n",
"4 7\n",
"99979 12032\n",
"19310 18\n",
"21944 37439\n",
"78... | 0 | 500 |
2 | 10 | 421_D. Bug in Code | Recently a serious bug has been found in the FOS code. The head of the F company wants to find the culprit and punish him. For that, he set up an organizational meeting, the issue is: who's bugged the code? Each of the n coders on the meeting said: 'I know for sure that either x or y did it!'
The head of the company d... | {
"input": [
"8 6\n5 6\n5 7\n5 8\n6 2\n2 1\n7 3\n1 3\n1 4\n",
"4 2\n2 3\n1 4\n1 4\n2 1\n"
],
"output": [
"1\n",
"6\n"
]
} | {
"input": [
"10 3\n6 3\n6 10\n2 5\n5 7\n6 2\n9 2\n8 1\n10 5\n5 10\n7 6\n",
"4 2\n3 4\n4 3\n4 2\n3 1\n",
"10 10\n5 6\n1 4\n1 4\n1 2\n1 2\n1 2\n1 3\n1 3\n1 3\n1 4\n",
"5 5\n3 2\n3 4\n2 5\n3 2\n4 3\n",
"6 6\n5 6\n5 6\n5 6\n1 2\n1 3\n3 4\n",
"5 3\n4 5\n4 5\n4 5\n3 2\n2 3\n",
"8 8\n6 5\n1 6\n1... | 1,900 | 2,000 |
2 | 8 | 448_B. Suffix Structures | Bizon the Champion isn't just a bison. He also is a favorite of the "Bizons" team.
At a competition the "Bizons" got the following problem: "You are given two distinct words (strings of English letters), s and t. You need to transform word s into word t". The task looked simple to the guys because they know the suffix... | {
"input": [
"need\ntree\n",
"automaton\ntomat\n",
"array\narary\n",
"both\nhot\n"
],
"output": [
"need tree\n",
"automaton\n",
"array\n",
"both\n"
]
} | {
"input": [
"hxsvvydmzhxrswvhkvrbjrfqkazbkjabnrdghposgyfeslzumaovfkallszzumztftgpcilwfrzpvhhbgdzdvnmseqywlzmhhoxh\ndbelhtzgkssyfrqgzuurdjhwvmdbhylhmvphjgxpzhxbb\n",
"smywwqeolrsytkthfgacnbufzaulgszikbhluzcdbafjclkqueepxbhoamrwswxherzhhuqqcttokbljfbppdinzqgdupkfevmke\nsmywwqeolrsytkthfgacnbufzaulgszikbhluzcdb... | 1,400 | 1,000 |
2 | 9 | 46_C. Hamsters and Tigers | Today there is going to be an unusual performance at the circus β hamsters and tigers will perform together! All of them stand in circle along the arena edge and now the trainer faces a difficult task: he wants to swap the animals' positions so that all the hamsters stood together and all the tigers also stood together... | {
"input": [
"3\nHTH\n",
"9\nHTHTHTHHT\n"
],
"output": [
"0",
"2"
]
} | {
"input": [
"13\nHTTTHHHTTTTHH\n",
"35\nTTTTTTHTTHTTTTTHTTTTTTTTTTTHTHTTTTT\n",
"178\nTHHHTHTTTHTTHTTHHHHHTTTHTTHHTHTTTHTHTTTTTHHHTHTHHHTHHHTTTTTTTTHHHHTTHHTHHHHTHTTTHHHHHHTHHTHTTHTHTTTTTTTTTHHTTHHTHTTHHTHHHHHTTHHTTHHTTHHHTTHHTTTTHTHHHTHTTHTHTTTHHHHTHHTHHHTHTTTTTT\n",
"7\nTTTHTTT\n",
"8\nHHTHHTHH... | 1,600 | 0 |
2 | 10 | 492_D. Vanya and Computer Game | Vanya and his friend Vova play a computer game where they need to destroy n monsters to pass a level. Vanya's character performs attack with frequency x hits per second and Vova's character performs attack with frequency y hits per second. Each character spends fixed time to raise a weapon and then he hits (the time to... | {
"input": [
"2 1 1\n1\n2\n",
"4 3 2\n1\n2\n3\n4\n"
],
"output": [
"Both\nBoth\n",
"Vanya\nVova\nVanya\nBoth\n"
]
} | {
"input": [
"10 13 27\n3\n21\n23\n17\n15\n23\n16\n7\n24\n20\n",
"5 5 6\n999999999\n999999998\n999999997\n999999996\n999999995\n",
"10 10 1\n1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n",
"11 22 33\n55\n56\n57\n58\n59\n60\n61\n62\n63\n64\n65\n",
"5 999999 1000000\n1999997\n1999998\n1999999\n2000000\n2000001\n"... | 1,800 | 2,000 |
2 | 11 | 56_E. Domino Principle | Vasya is interested in arranging dominoes. He is fed up with common dominoes and he uses the dominoes of different heights. He put n dominoes on the table along one axis, going from left to right. Every domino stands perpendicular to that axis so that the axis passes through the center of its base. The i-th domino has ... | {
"input": [
"4\n16 5\n20 5\n10 10\n18 2\n",
"4\n0 10\n1 5\n9 10\n15 10\n"
],
"output": [
"3 1 4 1 ",
"4 1 2 1 "
]
} | {
"input": [
"4\n-6 9\n9 5\n-7 4\n0 9\n",
"6\n20 39\n38 13\n-25 48\n-22 38\n13 39\n90 54\n",
"5\n-47 19\n-43 14\n83 27\n-67 46\n-58 98\n",
"3\n6 7\n2 9\n-6 10\n",
"10\n34 9\n-41 26\n-62 32\n1 10\n77 14\n92 7\n-45 35\n75 19\n-23 2\n-46 8\n"
],
"output": [
"2 1 3 1 ",
"2 1 5 4 3 1 ",
... | 2,200 | 2,500 |
2 | 9 | 591_C. Median Smoothing | A schoolboy named Vasya loves reading books on programming and mathematics. He has recently read an encyclopedia article that described the method of median smoothing (or median filter) and its many applications in science and engineering. Vasya liked the idea of the method very much, and he decided to try it in practi... | {
"input": [
"5\n0 1 0 1 0\n",
"4\n0 0 1 1\n"
],
"output": [
"2\n0 0 0 0 0",
"0\n0 0 1 1"
]
} | {
"input": [
"4\n0 1 0 1\n",
"3\n1 1 0\n",
"3\n1 0 1\n",
"3\n0 1 1\n",
"3\n0 0 0\n",
"168\n0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0... | 1,700 | 750 |
2 | 7 | 613_A. 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... | {
"input": [
"3 0 0\n0 1\n-1 2\n1 2\n",
"4 1 -1\n0 0\n1 2\n2 0\n1 1\n"
],
"output": [
"12.566370614359172464\n",
"21.991148575128551812\n"
]
} | {
"input": [
"10 -99 91\n-99 90\n-98 -12\n-72 -87\n7 -84\n86 -79\n96 -2\n100 36\n99 59\n27 83\n-14 93\n",
"4 0 0\n1 -1\n1 3\n3 3\n3 -1\n",
"5 -1 -1\n0 0\n8 5\n10 7\n7 5\n2 5\n",
"5 -94 52\n-93 52\n-78 -56\n-54 -81\n56 -87\n97 85\n",
"49 -1 -1\n0 0\n95 2\n47 1\n42 1\n93 7\n56 6\n47 7\n63 13\n98 24\... | 1,900 | 750 |
2 | 7 | 633_A. Ebony and Ivory | Dante is engaged in a fight with "The Savior". Before he can fight it with his sword, he needs to break its shields. He has two guns, Ebony and Ivory, each of them is able to perform any non-negative number of shots.
For every bullet that hits the shield, Ebony deals a units of damage while Ivory deals b units of dama... | {
"input": [
"6 11 6\n",
"3 2 7\n",
"4 6 15\n"
],
"output": [
"YES",
"YES",
"NO"
]
} | {
"input": [
"15 12 26\n",
"79 36 2854\n",
"11 34 383\n",
"16 78 712\n",
"76 69 4122\n",
"48 65 917\n",
"57 52 2634\n",
"12 17 15\n",
"62 1 501\n",
"70 24 1784\n",
"21 71 657\n",
"63 17 858\n",
"1 1 10000\n",
"2 17 105\n",
"94 9 168\n",
"84 9 530\n",
... | 1,100 | 250 |
2 | 10 | 774_D. Lie or Truth | Vasya has a sequence of cubes and exactly one integer is written on each cube. Vasya exhibited all his cubes in a row. So the sequence of numbers written on the cubes in the order from the left to the right equals to a1, a2, ..., an.
While Vasya was walking, his little brother Stepan played with Vasya's cubes and chan... | {
"input": [
"4 2 4\n1 1 1 1\n1 1 1 1\n",
"5 2 4\n3 4 2 3 1\n3 2 3 4 1\n",
"3 1 2\n1 2 3\n3 1 2\n"
],
"output": [
"TRUTH\n",
"TRUTH\n",
"LIE\n"
]
} | {
"input": [
"5 1 3\n2 2 2 1 2\n2 2 2 1 2\n",
"7 2 4\n1 2 3 4 5 7 6\n1 2 3 4 5 6 7\n",
"5 1 2\n1 2 3 4 5\n1 2 3 5 4\n",
"10 1 10\n6 7 6 1 10 10 9 5 3 9\n7 10 9 6 1 5 9 3 10 6\n",
"8 3 6\n5 3 1 1 1 1 3 5\n3 3 1 1 1 1 5 5\n",
"4 2 2\n2 1 2 2\n1 2 2 2\n",
"4 3 4\n1 2 3 4\n2 1 3 4\n",
"7 1... | 1,500 | 0 |
2 | 10 | 799_D. Field expansion | In one of the games Arkady is fond of the game process happens on a rectangular field. In the game process Arkady can buy extensions for his field, each extension enlarges one of the field sizes in a particular number of times. Formally, there are n extensions, the i-th of them multiplies the width or the length (by Ar... | {
"input": [
"5 5 1 2 3\n2 2 3\n",
"3 3 3 3 5\n2 3 5 4 2\n",
"3 3 2 4 4\n2 5 4 10\n",
"3 4 1 1 3\n2 3 2\n"
],
"output": [
"-1",
"0",
"1",
"3"
]
} | {
"input": [
"662 859 2 3 17\n3 2 2 2 3 3 3 2 3 3 2 3 2 2 2 2 2\n",
"21865 53623 9 7 116\n2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 ... | 2,100 | 2,000 |
2 | 8 | 845_B. Luba And The Ticket | Luba has a ticket consisting of 6 digits. In one move she can choose digit in any position and replace it with arbitrary digit. She wants to know the minimum number of digits she needs to replace in order to make the ticket lucky.
The ticket is considered lucky if the sum of first three digits equals to the sum of las... | {
"input": [
"111000\n",
"000000\n",
"123456\n"
],
"output": [
"1\n",
"0\n",
"2\n"
]
} | {
"input": [
"191578\n",
"877542\n",
"977330\n",
"000990\n",
"100172\n",
"202597\n",
"944234\n",
"000009\n",
"033788\n",
"000018\n",
"123996\n",
"444776\n",
"123689\n",
"317596\n",
"011299\n",
"858022\n",
"899888\n",
"999801\n",
"889444\n",
... | 1,600 | 0 |
2 | 10 | 865_D. Buy Low Sell High | You can perfectly predict the price of a certain stock for the next N days. You would like to profit on this knowledge, but only want to transact one share of stock per day. That is, each day you will either buy one share, sell one share, or do nothing. Initially you own zero shares, and you cannot sell shares when you... | {
"input": [
"9\n10 5 4 7 9 12 6 2 10\n",
"20\n3 1 4 1 5 9 2 6 5 3 5 8 9 7 9 3 2 3 8 4\n"
],
"output": [
"20\n",
"41\n"
]
} | {
"input": [
"100\n411 642 560 340 276 440 515 519 182 314 35 227 390 136 97 5 502 584 567 79 543 444 413 463 455 316 545 329 437 443 9 435 291 384 328 501 603 234 285 297 453 587 550 72 130 163 282 298 605 349 270 198 24 179 243 92 115 56 83 26 3 456 622 325 366 360 299 153 140 552 216 117 61 307 278 189 496 562... | 2,400 | 2,000 |
2 | 13 | 913_G. Power Substring | You are given n positive integers a1, a2, ..., an.
For every ai you need to find a positive integer ki such that the decimal notation of 2ki contains the decimal notation of ai as a substring among its last min(100, length(2ki)) digits. Here length(m) is the length of the decimal notation of m.
Note that you don't ha... | {
"input": [
"2\n8\n2\n",
"2\n3\n4857\n"
],
"output": [
"3\n1\n",
"5\n20\n"
]
} | {
"input": [
"50\n415546\n6493493\n5136540\n6965643\n8466744\n3329383\n9711334\n9543203\n4478668\n375580\n1919986\n1906588\n2651062\n6256271\n1372732\n5775823\n7301593\n4894751\n189902\n5406338\n8281625\n3220812\n7228487\n965119\n6142296\n3854700\n685373\n9076805\n5770856\n9690466\n6965459\n6120825\n2706148\n7123... | 3,200 | 3,000 |
2 | 7 | 936_A. 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. The s... | {
"input": [
"4 2 20\n",
"3 2 6\n"
],
"output": [
"20.000000000000000",
"6.500000000000000"
]
} | {
"input": [
"8 10 9\n",
"312 93 1000000000000000000\n",
"42 9 1000000000000000000\n",
"1000 1000 1000\n",
"963276084 698548036 1000000000\n",
"200 10 979220166595737684\n",
"3260 4439 6837\n",
"87 4 1000\n",
"6 3 417701740543616353\n",
"9 1000000000000000000 100000000000000000... | 1,700 | 500 |
2 | 9 | 1016_C. Vasya And The Mushrooms | Vasya's house is situated in a forest, and there is a mushroom glade near it. The glade consists of two rows, each of which can be divided into n consecutive cells. For each cell Vasya knows how fast the mushrooms grow in this cell (more formally, how many grams of mushrooms grow in this cell each minute). Vasya spends... | {
"input": [
"3\n1 2 3\n6 5 4\n",
"3\n1 1000 10000\n10 100 100000\n"
],
"output": [
"70\n",
"543210\n"
]
} | {
"input": [
"6\n12 8 12 17 20 5\n17 4 8 8 8 4\n",
"6\n4 1 12 9 3 11\n12 20 19 12 19 11\n",
"1\n1\n1\n",
"2\n1 2\n1 1\n",
"1\n7\n5\n",
"6\n16 20 18 7 14 2\n17 12 4 10 7 4\n"
],
"output": [
"705\n",
"917\n",
"1\n",
"9\n",
"5\n",
"741\n"
]
} | 1,800 | 0 |
2 | 9 | 103_C. 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.
Sasha se... | {
"input": [
"5 2 5\n1\n2\n3\n4\n5\n",
"6 3 6\n1\n2\n3\n4\n5\n6\n",
"3 1 3\n1\n2\n3\n"
],
"output": [
"...XX\n",
".X.X.X\n",
"..X\n"
]
} | {
"input": [
"7 7 7\n1\n2\n3\n4\n5\n6\n7\n",
"4 2 8\n1\n3\n4\n2\n3\n4\n1\n2\n",
"9 4 9\n1\n2\n3\n4\n5\n6\n7\n8\n9\n",
"7 5 7\n1\n2\n3\n4\n5\n6\n7\n",
"15 10 15\n1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n",
"4 0 4\n1\n2\n3\n4\n",
"12 2 12\n1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n",
... | 1,900 | 1,500 |
2 | 10 | 1062_D. Fun with Integers | You are given a positive integer n greater or equal to 2. For every pair of integers a and b (2 β€ |a|, |b| β€ n), you can transform a into b if and only if there exists an integer x such that 1 < |x| and (a β
x = b or b β
x = a), where |x| denotes the absolute value of x.
After such a transformation, your score increas... | {
"input": [
"2\n",
"4\n",
"6\n"
],
"output": [
"0",
"8",
"28"
]
} | {
"input": [
"28237\n",
"13190\n",
"39914\n",
"81367\n",
"8554\n",
"61106\n",
"67448\n",
"39004\n",
"22308\n",
"16054\n",
"71468\n",
"60501\n",
"100\n",
"300\n",
"59632\n",
"90783\n",
"5611\n",
"1000\n",
"69475\n",
"69753\n",
"10\n",
... | 1,800 | 2,000 |
2 | 9 | 1084_C. The Fair Nut and String | The Fair Nut found a string s. The string consists of lowercase Latin letters. The Nut is a curious guy, so he wants to find the number of strictly increasing sequences p_1, p_2, β¦, p_k, such that:
1. For each i (1 β€ i β€ k), s_{p_i} = 'a'.
2. For each i (1 β€ i < k), there is such j that p_i < j < p_{i + 1} and s... | {
"input": [
"agaa\n",
"baaaa\n",
"abbaa\n"
],
"output": [
"3\n",
"4\n",
"5\n"
]
} | {
"input": [
"aaaaabb\n",
"aabaaaa\n",
"babbabaabbbbabwbvbhbbbaaabbabbbbbbbkabbbbabaaabbbbbbajabbaaabazbbbzbalbabbwbbaabbabacabdbabbbfaaabbb\n",
"baaahbbbba\n",
"ababavvvv\n",
"abnxabbaab\n",
"krflnzhter\n",
"amaabbbbxaabbbabaabaabbaaabaaaaabibbabaabaaabaabcaaxabablbbbbmbbbaaaaaabbaabb... | 1,500 | 1,500 |
2 | 11 | 1131_E. String Multiplication | Roman and Denis are on the trip to the programming competition. Since the trip was long, they soon got bored, and hence decided to came up with something. Roman invented a pizza's recipe, while Denis invented a string multiplication. According to Denis, the result of multiplication (product) of strings s of length m an... | {
"input": [
"2\nbnn\na\n",
"3\na\nb\na\n"
],
"output": [
"1",
"3"
]
} | {
"input": [
"9\nlfpgbnlzyn\nc\ns\nw\nr\nm\nq\ny\nyinfblfcdhidphyfvgkxyuwomahiibbhnigdslsguhjkplibnhhrshtekwgefxeugyyyyy\n",
"6\nu\np\nm\nz\nv\nvv\n",
"4\nqe\nnd\niqryhukieskfvaeettersinksrmazelxtgvartuz\nvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv... | 2,300 | 2,500 |
2 | 7 | 1152_A. Neko Finds Grapes | On a random day, Neko found n treasure chests and m keys. The i-th chest has an integer a_i written on it and the j-th key has an integer b_j on it. Neko knows those chests contain the powerful mysterious green Grapes, thus Neko wants to open as many treasure chests as possible.
The j-th key can be used to unlock the ... | {
"input": [
"5 1\n2 4 6 8 10\n5\n",
"1 4\n10\n20 30 40 50\n",
"5 4\n9 14 6 2 11\n8 4 7 20\n"
],
"output": [
"1\n",
"0\n",
"3\n"
]
} | {
"input": [
"4 1\n3 5 7 8\n2\n",
"5 1\n2 2 2 3 3\n3\n",
"4 1\n1 1 2 2\n2\n",
"10 10\n522312461 931001459 598654597 488228616 544064902 21923894 329635457 980089248 988262691 654502493\n967529230 543358150 835120075 128123793 809901567 613170206 152157661 479980560 859252956 318029856\n",
"27 9\n7... | 800 | 500 |
2 | 9 | 1191_C. Tokitsukaze and Discard Items | Recently, Tokitsukaze found an interesting game. Tokitsukaze had n items at the beginning of this game. However, she thought there were too many items, so now she wants to discard m (1 β€ m β€ n) special items of them.
These n items are marked with indices from 1 to n. In the beginning, the item with index i is placed o... | {
"input": [
"13 4 5\n7 8 9 10\n",
"10 4 5\n3 5 7 10\n"
],
"output": [
"1\n",
"3\n"
]
} | {
"input": [
"10 5 5\n2 3 4 5 6\n",
"1 1 1\n1\n",
"1000000000000000000 10 68\n9818112234872670 233245257111863071 266483628625876079 375103213040049805 431982380866113633 489732004669478331 501030096787260719 541800997319766183 551892546260532408 696178619227890200\n",
"1000000000000000000 2 1\n1 1000... | 1,400 | 500 |
2 | 7 | 1230_A. Dawid and Bags of Candies | Dawid has four bags of candies. The i-th of them contains a_i candies. Also, Dawid has two friends. He wants to give each bag to one of his two friends. Is it possible to distribute the bags in such a way that each friend receives the same amount of candies in total?
Note, that you can't keep bags for yourself or thro... | {
"input": [
"1 7 11 5\n",
"7 3 2 5\n"
],
"output": [
"YES\n",
"NO\n"
]
} | {
"input": [
"44 58 90 53\n",
"20 14 37 71\n",
"4 2 4 2\n",
"1 2 5 5\n",
"1 2 8 9\n",
"99 100 3 98\n",
"92 69 83 97\n",
"3 1 1 1\n",
"18 88 18 18\n",
"1 1 1 1\n",
"69 7 44 30\n",
"90 30 30 30\n",
"1 2 3 5\n",
"1 1 3 1\n",
"6 3 6 6\n",
"26 52 7 19\n",
... | 800 | 500 |
2 | 9 | 1271_C. Shawarma Tent | The map of the capital of Berland can be viewed on the infinite coordinate plane. Each point with integer coordinates contains a building, and there are streets connecting every building to four neighbouring buildings. All streets are parallel to the coordinate axes.
The main school of the capital is located in (s_x, ... | {
"input": [
"7 10 12\n5 6\n20 23\n15 4\n16 5\n4 54\n12 1\n4 15\n",
"4 3 2\n1 3\n4 2\n5 1\n4 1\n",
"3 100 100\n0 0\n0 0\n100 200\n"
],
"output": [
"4\n11 12",
"3\n4 2",
"2\n99 100"
]
} | {
"input": [
"1 1000000000 7\n1000000000 9\n",
"3 2 2\n2 4\n2 1\n3 6\n",
"2 1000000000 100000\n1000000000 1000000\n1000000000 10000\n",
"1 100 100\n50 70\n",
"1 100 100\n101 100\n"
],
"output": [
"1\n1000000000 8",
"2\n2 3",
"1\n1000000000 100001",
"1\n99 100",
"1\n101 100"... | 1,300 | 1,250 |
2 | 10 | 1315_D. Recommendations | VK news recommendation system daily selects interesting publications of one of n disjoint categories for each user. Each publication belongs to exactly one category. For each category i batch algorithm selects a_i publications.
The latest A/B test suggests that users are reading recommended publications more actively ... | {
"input": [
"5\n3 7 9 7 8\n5 2 5 7 5\n",
"5\n1 2 3 4 5\n1 1 1 1 1\n"
],
"output": [
"6\n",
"0\n"
]
} | {
"input": [
"5\n1000000000 1000000000 1000000000 1000000000 1000000000\n100000 100000 100000 100000 100000\n",
"10\n14 31 50 67 42 44 86 82 35 63\n76 17 26 44 60 54 50 73 71 70\n",
"10\n4 4 1 2 2 2 5 4 1 5\n28 81 36 44 2 40 39 43 36 33\n",
"10\n69564153 558821634 273092444 121621442 354953668 1570211... | 1,700 | 500 |
2 | 10 | 1359_D. Yet Another Yet Another Task | Alice and Bob are playing yet another card game. This time the rules are the following. There are n cards lying in a row in front of them. The i-th card has value a_i.
First, Alice chooses a non-empty consecutive segment of cards [l; r] (l β€ r). After that Bob removes a single card j from that segment (l β€ j β€ r). Th... | {
"input": [
"3\n-10 6 -15\n",
"8\n5 2 5 3 -30 -30 6 9\n",
"5\n5 -2 10 -1 4\n"
],
"output": [
"0\n",
"10\n",
"6\n"
]
} | {
"input": [
"10\n-3 4 -4 1 1 -4 -5 3 -4 -2\n",
"10\n8 9 -10 -10 -4 -3 5 9 -9 9\n",
"6\n5 -4 2 -1 2 -2\n",
"11\n3 0 1 -2 5 -5 -1 0 3 2 2\n",
"10\n4 -2 -2 -2 2 0 1 0 -4 -1\n",
"4\n2 2 -3 4\n",
"11\n-11 -7 -2 -24 30 -26 24 9 -8 -9 23\n",
"6\n30 -29 5 5 -29 30\n",
"24\n-8 -6 6 -11 -15... | 2,000 | 0 |
2 | 10 | 139_D. Digits Permutations | Andrey's favourite number is n. Andrey's friends gave him two identical numbers n as a New Year present. He hung them on a wall and watched them adoringly.
Then Andrey got bored from looking at the same number and he started to swap digits first in one, then in the other number, then again in the first number and so o... | {
"input": [
"500\n",
"198\n"
],
"output": [
"500\n500",
"981\n819"
]
} | {
"input": [
"545\n",
"2603340571199714716025114079373828413509944752618962350632892540710372640383149198328312562980217104434880337288055817064\n",
"670042\n",
"1099\n",
"8679647744\n",
"5057017252180797906185\n",
"404\n",
"4877\n",
"7665711\n",
"346762409573609367635944363650... | 1,900 | 1,000 |
2 | 7 | 1443_A. Kids Seating | Today the kindergarten has a new group of n kids who need to be seated at the dinner table. The chairs at the table are numbered from 1 to 4n. Two kids can't sit on the same chair. It is known that two kids who sit on chairs with numbers a and b (a β b) will indulge if:
1. gcd(a, b) = 1 or,
2. a divides b or b d... | {
"input": [
"3\n2\n3\n4\n"
],
"output": [
"8 6\n12 10 8\n16 14 12 10\n"
]
} | {
"input": [
"3\n2\n3\n4\n",
"100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n... | 800 | 500 |
2 | 9 | 1493_C. K-beautiful Strings | You are given a string s consisting of lowercase English letters and a number k. Let's call a string consisting of lowercase English letters beautiful if the number of occurrences of each letter in that string is divisible by k. You are asked to find the lexicographically smallest beautiful string of length n, which is... | {
"input": [
"4\n4 2\nabcd\n3 1\nabc\n4 3\naaaa\n9 3\nabaabaaaa\n"
],
"output": [
"\nacac\nabc\n-1\nabaabaaab\n"
]
} | {
"input": [
"12\n12 3\nzazasqzqsasq\n1 1\nz\n1 1\na\n15 4\nabccbaabccbazaa\n16 8\ncadjfdsljfdkljds\n6 2\nbaazaa\n6 3\nbosszb\n6 1\nqwerty\n7 7\ndaaaaaa\n14 2\nacabcbdeffewzd\n18 6\nzzzzzzzzzzzzyyyyyz\n9 4\naabaabbbc\n"
],
"output": [
"zazasqzqsasq\nz\na\n-1\ncbbbbbbbbccccccc\nbaazbz\nbpbbpp\nqwerty\ndddd... | 2,000 | 1,750 |
2 | 9 | 171_C. A Piece of Cake | How to make a cake you'll never eat.
Ingredients.
* 2 carrots
* 0 calories
* 100 g chocolate spread
* 1 pack of flour
* 1 egg
Method.
1. Put calories into the mixing bowl.
2. Take carrots from refrigerator.
3. Chop carrots.
4. Take chocolate spread from refrigerator.
5. Put chocolate spread ... | {
"input": [
"4 1 2 3 4\n"
],
"output": [
"30"
]
} | {
"input": [
"20 228 779 225 819 142 849 24 494 45 172 95 207 908 510 424 78 100 166 869 456\n",
"4 220 380 729 969\n",
"23 486 261 249 312 592 411 874 397 18 70 417 512 338 679 517 997 938 328 418 793 522 745 59\n",
"17 644 532 255 57 108 413 51 284 364 300 597 646 712 470 42 730 231\n",
"16 29 6... | 2,000 | 0 |
2 | 7 | 191_A. Dynasty Puzzles | The ancient Berlanders believed that the longer the name, the more important its bearer is. Thus, Berland kings were famous for their long names. But long names are somewhat inconvenient, so the Berlanders started to abbreviate the names of their kings. They called every king by the first letters of its name. Thus, the... | {
"input": [
"4\nvvp\nvvp\ndam\nvvp\n",
"3\nab\nc\ndef\n",
"3\nabc\nca\ncba\n"
],
"output": [
"0\n",
"1\n",
"6\n"
]
} | {
"input": [
"10\nabdcced\nbdacdac\necb\ndc\neaeeebdd\nadcdbadcac\neb\naadecccde\nedbaeacad\naccd\n",
"100\nd\na\ne\neb\nc\nd\nd\ne\nc\ne\nac\nd\nc\naa\na\ne\nda\ne\ne\nc\ne\na\nc\nc\nbc\nbd\nd\nda\ncc\nbe\nb\na\nee\nd\nbe\nbe\ne\nb\na\ned\ncb\nab\na\nea\nac\naa\ned\nd\nb\neb\ne\ned\nc\nce\nc\nd\nc\nd\nd\nee\... | 1,500 | 500 |
2 | 7 | 215_A. Bicycle Chain | Vasya's bicycle chain drive consists of two parts: n stars are attached to the pedal axle, m stars are attached to the rear wheel axle. The chain helps to rotate the rear wheel by transmitting the pedal rotation.
We know that the i-th star on the pedal axle has ai (0 < a1 < a2 < ... < an) teeth, and the j-th star on t... | {
"input": [
"4\n1 2 3 4\n5\n10 11 12 13 14\n",
"2\n4 5\n3\n12 13 15\n"
],
"output": [
"1\n",
"2\n"
]
} | {
"input": [
"1\n1\n2\n1 2\n",
"50\n17 20 22 28 36 38 46 47 48 50 52 57 58 62 63 69 70 74 75 78 79 81 82 86 87 90 93 95 103 202 292 442 1756 1769 2208 2311 2799 2957 3483 4280 4324 4932 5109 5204 6225 6354 6561 7136 8754 9670\n40\n68 214 957 1649 1940 2078 2134 2716 3492 3686 4462 4559 4656 4756 4850 5044 549... | 900 | 500 |
2 | 7 | 239_A. Two Bags of Potatoes | Valera had two bags of potatoes, the first of these bags contains x (x β₯ 1) potatoes, and the second β y (y β₯ 1) potatoes. Valera β very scattered boy, so the first bag of potatoes (it contains x potatoes) Valera lost. Valera remembers that the total amount of potatoes (x + y) in the two bags, firstly, was not gerater ... | {
"input": [
"10 6 40\n",
"10 1 10\n"
],
"output": [
"2 8 14 20 26\n",
"-1\n"
]
} | {
"input": [
"78 7 15\n",
"10 4 9174\n",
"1 999999999 1000000000\n",
"17 28 532\n",
"1 100000007 1000000000\n",
"30351 86 424\n",
"100000000 1000000000 1000000000\n",
"1000000000 1 1\n",
"15946 76 360\n",
"46592 52 232\n",
"48 6 50\n",
"123 2 50000\n",
"500000000 50... | 1,200 | 500 |
2 | 10 | 263_D. Cycle in Graph | You've got a undirected graph G, consisting of n nodes. We will consider the nodes of the graph indexed by integers from 1 to n. We know that each node of graph G is connected by edges with at least k other nodes of this graph. Your task is to find in the given graph a simple cycle of length of at least k + 1.
A simpl... | {
"input": [
"4 6 3\n4 3\n1 2\n1 3\n1 4\n2 3\n2 4\n",
"3 3 2\n1 2\n2 3\n3 1\n"
],
"output": [
"4\n1 2 3 4 ",
"3\n1 2 3 "
]
} | {
"input": [
"30 70 4\n22 1\n1 25\n27 5\n25 10\n10 2\n29 4\n29 26\n28 18\n15 18\n25 11\n11 10\n11 28\n4 11\n4 26\n26 7\n26 18\n18 21\n14 17\n17 30\n30 9\n30 6\n30 27\n27 22\n22 15\n22 8\n8 4\n8 17\n17 16\n16 19\n16 12\n12 23\n23 20\n20 1\n1 23\n23 15\n15 24\n24 28\n28 21\n21 9\n21 27\n29 13\n13 5\n20 19\n20 5\n5 ... | 1,800 | 2,000 |
2 | 8 | 335_B. Palindrome | Given a string s, determine if it contains any palindrome of length exactly 100 as a subsequence. If it has any, print any one of them. If it doesn't have any, print a palindrome that is a subsequence of s and is as long as possible.
Input
The only line of the input contains one string s of length n (1 β€ n β€ 5Β·104) c... | {
"input": [
"rquwmzexectvnbanemsmdufrg\n",
"bbbabcbbb\n"
],
"output": [
"rumenanemur",
"bbbcbbb"
]
} | {
"input": [
"gamjuklsvzwddaocadujdmvlenyyvlflipneqofeyipmtunbdmbdyhkovnpdetueeiunsipowrhxrhtastjniqdhmehcumdcrghewljvpikcraoouhfwtnoaukbnykjapkvyakdnckkypargamvnsqtchesbmuffqqycnjvolmtpjfykvkeexkpdxjexrvdzpcbthhkxuucermkaebrvcxoovidpqnpkgbhiatyjvumihptrigqxsemqbbxwmyunmmayubqqjaioqmzyekhtqgoockiskyqihopmkastfvqi... | 1,900 | 1,000 |
2 | 8 | 358_B. Dima and Text Messages | Seryozha has a very changeable character. This time he refused to leave the room to Dima and his girlfriend (her hame is Inna, by the way). However, the two lovebirds can always find a way to communicate. Today they are writing text messages to each other.
Dima and Inna are using a secret code in their text messages. ... | {
"input": [
"7\ni\nam\nnot\nmain\nin\nthe\nfamily\n<3i<>3am<3the<3<main<3in<3the<3><3family<3\n",
"3\ni\nlove\nyou\n<3i<3love<23you<3\n"
],
"output": [
"no\n",
"no\n"
]
} | {
"input": [
"3\ni\nlove\nyou\n<3i<3love<23you<3ww\n",
"1\na\n<3a<3b\n",
"4\na\nb\nc\nd\n<3a<3b<3c<3d\n",
"3\ni\nlove\nyou\n<3i<3love<3you<3\n",
"4\na\nb\nc\nd\na<3b<3c<3d<3\n",
"1\naa\n<3a<3\n",
"1\na\na\n",
"3\ni\nlove\nyou\n<3i<3lo<3ve<3y<<<<<<<ou3<3\n",
"7\ni\nam\nnot\nmain\nin... | 1,500 | 1,000 |
2 | 7 | 381_A. Sereja and Dima | Sereja and Dima play a game. The rules of the game are very simple. The players have n cards in a row. Each card contains a number, all numbers on the cards are distinct. The players take turns, Sereja moves first. During his turn a player can take one card: either the leftmost card in a row, or the rightmost one. The ... | {
"input": [
"7\n1 2 3 4 5 6 7\n",
"4\n4 1 2 10\n"
],
"output": [
"16 12\n",
"12 5\n"
]
} | {
"input": [
"1\n1\n",
"30\n334 443 223 424 168 549 189 303 429 559 516 220 459 134 344 346 316 446 209 148 487 526 69 286 102 366 518 280 392 325\n",
"95\n122 29 188 265 292 287 183 225 222 187 155 256 64 148 173 278 218 136 290 17 31 130 2 87 57 283 255 280 68 166 174 142 102 39 116 206 288 154 26 78 29... | 800 | 500 |
2 | 7 | 42_A. Guilty β to the kitchen! | It's a very unfortunate day for Volodya today. He got bad mark in algebra and was therefore forced to do some work in the kitchen, namely to cook borscht (traditional Russian soup). This should also improve his algebra skills.
According to the borscht recipe it consists of n ingredients that have to be mixed in propor... | {
"input": [
"1 100\n1\n40\n",
"2 100\n1 1\n60 60\n",
"2 100\n1 1\n25 30\n"
],
"output": [
"40.0000",
"100.0000",
"50.0000"
]
} | {
"input": [
"5 5005\n5 53 65 52 99\n21 49 9 3 66\n",
"14 3615\n81 79 13 94 54 69 92 5 47 98 40 64 44 88\n52 73 7 12 29 40 46 47 60 66 63 68 71 4\n",
"7 529\n77 18 67 64 43 51 30\n35 87 17 52 1 97 84\n",
"16 1718\n42 68 96 52 47 31 89 5 87 70 25 69 35 86 86 11\n35 37 51 15 33 94 18 48 91 2 4 89 73 93 ... | 1,400 | 500 |
2 | 10 | 451_D. Count Good Substrings | We call a string good, if after merging all the consecutive equal characters, the resulting string is palindrome. For example, "aabba" is good, because after the merging step it will become "aba".
Given a string, you have to find two values:
1. the number of good substrings of even length;
2. the number of good ... | {
"input": [
"babaa\n",
"bb\n",
"baab\n",
"babb\n"
],
"output": [
"2 7\n",
"1 2\n",
"2 4\n",
"2 5\n"
]
} | {
"input": [
"bbabaaabaaaabaabbababbbabababaabaaaaabbaabbbbbaababaabbbaabaabaaaababaabaabbabaaabaabbbabbaaaaaaabaabababaaabaaabbbabbabbaabaaabaabbbbbabbababbbbbbbababbababbbabbbbbababaaaababaabbabaaabbaaabaabbbbabbaaababbbbbbaaabbaaabbaaabaaaaaababaabababaabaaabaaaabaabbabbabbbbabbaaabaabbaababaaabbbbbaabbbbabbba... | 2,000 | 2,500 |
2 | 9 | 474_C. Captain Marmot | Captain Marmot wants to prepare a huge and important battle against his enemy, Captain Snake. For this battle he has n regiments, each consisting of 4 moles.
Initially, each mole i (1 β€ i β€ 4n) is placed at some position (xi, yi) in the Cartesian plane. Captain Marmot wants to move some moles to make the regiments com... | {
"input": [
"4\n1 1 0 0\n-1 1 0 0\n-1 1 0 0\n1 -1 0 0\n1 1 0 0\n-2 1 0 0\n-1 1 0 0\n1 -1 0 0\n1 1 0 0\n-1 1 0 0\n-1 1 0 0\n-1 1 0 0\n2 2 0 1\n-1 0 0 -2\n3 0 0 -2\n-1 1 -2 0\n"
],
"output": [
"1\n-1\n3\n3\n"
]
} | {
"input": [
"1\n1 0 2 0\n-1 0 -2 0\n0 1 0 2\n0 -1 0 -2\n",
"4\n1 0 0 0\n0 2 0 0\n-1 0 0 0\n0 -2 0 0\n1 0 0 0\n0 1 0 0\n-1 0 0 0\n0 -1 0 0\n1 2 0 0\n-1 2 0 0\n-1 -2 0 0\n1 -2 0 0\n19 0 0 0\n0 20 0 0\n-19 0 0 0\n0 -20 0 0\n",
"1\n1 1 1 1\n1 1 1 1\n2 2 2 2\n2 2 2 2\n",
"1\n-1 1 -9999 9999\n-1 -1 9998 99... | 2,000 | 1,500 |
2 | 9 | 521_C. Pluses everywhere | Vasya is sitting on an extremely boring math class. To have fun, he took a piece of paper and wrote out n numbers on a single line. After that, Vasya began to write out different ways to put pluses ("+") in the line between certain digits in the line so that the result was a correct arithmetic expression; formally, no ... | {
"input": [
"3 1\n108\n",
"3 2\n108\n"
],
"output": [
"27\n",
"9\n"
]
} | {
"input": [
"57 13\n177946005798852216692528643323484389368821547834013121843\n",
"16 15\n8086179429588546\n",
"14 6\n00000000000001\n",
"200 100\n5698871975581557589328225408146769846248580378214263136938518099974663962255455988428119336734228355923883410691738816604802005685291129339437794996418536... | 2,200 | 2,500 |
2 | 8 | 618_B. Guess the Permutation | Bob has a permutation of integers from 1 to n. Denote this permutation as p. The i-th element of p will be denoted as pi. For all pairs of distinct integers i, j between 1 and n, he wrote the number ai, j = min(pi, pj). He writes ai, i = 0 for all integer i from 1 to n.
Bob gave you all the values of ai, j that he wro... | {
"input": [
"2\n0 1\n1 0\n",
"5\n0 2 2 1 2\n2 0 4 1 3\n2 4 0 1 3\n1 1 1 0 1\n2 3 3 1 0\n"
],
"output": [
"1 2 ",
"2 4 5 1 3 "
]
} | {
"input": [
"10\n0 1 5 2 5 3 4 5 5 5\n1 0 1 1 1 1 1 1 1 1\n5 1 0 2 6 3 4 6 6 6\n2 1 2 0 2 2 2 2 2 2\n5 1 6 2 0 3 4 8 8 7\n3 1 3 2 3 0 3 3 3 3\n4 1 4 2 4 3 0 4 4 4\n5 1 6 2 8 3 4 0 9 7\n5 1 6 2 8 3 4 9 0 7\n5 1 6 2 7 3 4 7 7 0\n",
"4\n0 1 3 2\n1 0 1 1\n3 1 0 2\n2 1 2 0\n",
"13\n0 5 5 2 5 4 5 5 3 5 5 5 1\n... | 1,100 | 1,000 |
2 | 10 | 638_D. Three-dimensional Turtle Super Computer | A super computer has been built in the Turtle Academy of Sciences. The computer consists of nΒ·mΒ·k CPUs. The architecture was the paralellepiped of size n Γ m Γ k, split into 1 Γ 1 Γ 1 cells, each cell contains exactly one CPU. Thus, each CPU can be simultaneously identified as a group of three numbers from the layer nu... | {
"input": [
"1 1 10\n0101010101\n",
"2 2 3\n000\n000\n\n111\n111\n",
"3 3 3\n111\n111\n111\n\n111\n111\n111\n\n111\n111\n111\n"
],
"output": [
"0\n",
"2\n",
"19\n"
]
} | {
"input": [
"1 1 3\n111\n",
"1 3 1\n1\n1\n1\n",
"3 1 1\n1\n\n1\n\n1\n",
"3 1 1\n1\n\n0\n\n1\n",
"1 1 3\n011\n",
"1 3 1\n1\n0\n1\n",
"6 8 3\n011\n001\n000\n100\n111\n110\n100\n100\n\n000\n100\n011\n001\n011\n000\n100\n111\n\n110\n111\n011\n110\n101\n001\n110\n000\n\n100\n000\n110\n001\n110... | 1,800 | 2,000 |
2 | 7 | 690_A1. Collective Mindsets (easy) | Tonight is brain dinner night and all zombies will gather together to scarf down some delicious brains. The artful Heidi plans to crash the party, incognito, disguised as one of them. Her objective is to get away with at least one brain, so she can analyze the zombies' mindset back home and gain a strategic advantage.
... | {
"input": [
"1\n",
"4\n"
],
"output": [
"1\n",
"2\n"
]
} | {
"input": [
"1000000000\n",
"536870912\n",
"16\n",
"6\n",
"18\n",
"13\n",
"20\n",
"7\n",
"10\n",
"8\n",
"2\n",
"21736\n",
"12\n",
"9\n",
"9999\n",
"873467\n",
"536870910\n",
"17\n",
"4124980\n",
"15\n",
"5\n",
"876543210\n",
... | 1,100 | 0 |
2 | 10 | 712_D. Memory and Scores | Memory and his friend Lexa are competing to get higher score in one popular computer game. Memory starts with score a and Lexa starts with score b. In a single turn, both Memory and Lexa get some integer in the range [ - k;k] (i.e. one integer among - k, - k + 1, - k + 2, ..., - 2, - 1, 0, 1, 2, ..., k - 1, k) and add... | {
"input": [
"1 2 2 1\n",
"1 1 1 2\n",
"2 12 3 1\n"
],
"output": [
" 6\n",
" 31\n",
"0\n"
]
} | {
"input": [
"38 38 701 74\n",
"10 10 1000 100\n",
"2 56 438 41\n",
"40 94 510 53\n",
"69 69 443 53\n",
"60 60 86 51\n",
"40 40 955 95\n",
"14 47 184 49\n",
"3 7 8 6\n",
"81 13 607 21\n",
"1 8 1 4\n",
"45 54 4 5\n",
"5 3 1 1\n",
"99 99 913 42\n",
"44 80 814 ... | 2,200 | 2,250 |
2 | 9 | 733_C. Epidemic in Monstropolis | There was an epidemic in Monstropolis and all monsters became sick. To recover, all monsters lined up in queue for an appointment to the only doctor in the city.
Soon, monsters became hungry and began to eat each other.
One monster can eat other monster if its weight is strictly greater than the weight of the monste... | {
"input": [
"5\n1 1 1 3 3\n3\n2 1 6\n",
"6\n1 2 2 2 1 2\n2\n5 5\n",
"5\n1 2 3 4 5\n1\n15\n"
],
"output": [
"NO\n",
"YES\n2 L\n1 R\n2 R\n2 R\n",
"YES\n5 L\n4 L\n3 L\n2 L\n"
]
} | {
"input": [
"3\n2 1 3\n1\n6\n",
"3\n3 2 1\n1\n6\n",
"3\n1 2 2\n1\n5\n",
"2\n1 1\n1\n1\n",
"5\n1 2 3 4 5\n3\n1 2 3\n",
"5\n3 3 2 2 1\n2\n8 3\n",
"3\n3 2 5\n1\n10\n",
"6\n2 1 2 2 1 2\n2\n5 5\n",
"2\n5 5\n1\n5\n",
"14\n5 5 5 5 4 4 4 3 3 3 4 4 4 4\n3\n32 21 4\n",
"4\n2 2 1 2\n... | 1,800 | 2,000 |
2 | 7 | 779_A. Pupils Redistribution | In Berland each high school student is characterized by academic performance β integer value between 1 and 5.
In high school 0xFF there are two groups of pupils: the group A and the group B. Each group consists of exactly n students. An academic performance of each student is known β integer value between 1 and 5.
Th... | {
"input": [
"6\n1 1 1 1 1 1\n5 5 5 5 5 5\n",
"4\n5 4 4 4\n5 5 4 5\n",
"9\n3 2 5 5 2 3 3 3 2\n4 1 4 1 1 2 4 4 1\n",
"1\n5\n3\n"
],
"output": [
"3\n",
"1\n",
"4\n",
"-1\n"
]
} | {
"input": [
"100\n3 4 5 3 5 4 5 4 4 4 2 4 5 4 3 2 3 4 3 5 2 5 2 5 4 3 4 2 5 2 5 3 4 5 2 5 4 2 4 5 4 3 2 4 4 5 2 5 5 3 3 5 2 4 4 2 3 3 2 5 5 5 2 4 5 5 4 2 2 5 3 3 2 4 4 2 4 5 5 2 5 5 3 2 5 2 4 4 3 3 5 4 5 5 2 5 4 5 4 3\n4 3 5 5 2 4 2 4 5 5 5 2 3 3 3 3 5 5 5 5 3 5 2 3 5 2 3 2 2 5 5 3 5 3 4 2 2 5 3 3 3 3 5 2 4 5 3 ... | 1,000 | 500 |
2 | 11 | 825_E. Minimal Labels | You are given a directed acyclic graph with n vertices and m edges. There are no self-loops or multiple edges between any pair of vertices. Graph can be disconnected.
You should assign labels to all vertices in such a way that:
* Labels form a valid permutation of length n β an integer sequence such that each integ... | {
"input": [
"3 3\n1 2\n1 3\n3 2\n",
"4 5\n3 1\n4 1\n2 3\n3 4\n2 4\n",
"5 4\n3 1\n2 1\n2 3\n4 5\n"
],
"output": [
"1 3 2\n",
"4 1 2 3\n",
"3 1 2 4 5\n"
]
} | {
"input": [
"2 1\n2 1\n",
"100 10\n73 55\n29 76\n15 12\n94 46\n77 67\n76 16\n72 50\n41 40\n89 75\n27 22\n",
"5 10\n5 2\n4 1\n2 1\n3 4\n2 4\n3 2\n5 4\n3 5\n3 1\n5 1\n"
],
"output": [
"2 1\n",
"1 2 3 4 5 6 7 8 9 10 11 13 14 15 12 18 19 20 21 22 23 25 26 27 28 29 24 30 16 31 32 33 34 35 36 37 38... | 2,300 | 0 |
2 | 7 | 870_A. Search for Pretty Integers | You are given two lists of non-zero digits.
Let's call an integer pretty if its (base 10) representation has at least one digit from the first list and at least one digit from the second list. What is the smallest positive pretty integer?
Input
The first line contains two integers n and m (1 β€ n, m β€ 9) β the length... | {
"input": [
"8 8\n1 2 3 4 5 6 7 8\n8 7 6 5 4 3 2 1\n",
"2 3\n4 2\n5 7 6\n"
],
"output": [
"1\n",
"25\n"
]
} | {
"input": [
"4 3\n1 3 5 9\n2 8 9\n",
"1 2\n5\n2 5\n",
"2 4\n8 9\n1 2 3 9\n",
"9 9\n9 8 7 6 5 4 3 2 1\n9 8 7 6 5 4 3 2 1\n",
"2 2\n1 5\n2 5\n",
"3 2\n4 5 6\n1 5\n",
"9 9\n5 4 3 2 1 6 7 8 9\n3 2 1 5 4 7 8 9 6\n",
"3 3\n3 5 6\n1 5 9\n",
"3 3\n2 4 9\n7 8 9\n",
"5 3\n3 4 5 6 7\n1 5... | 900 | 500 |
2 | 7 | 918_A. Eleven | Eleven wants to choose a new name for herself. As a bunch of geeks, her friends suggested an algorithm to choose a name for her. Eleven wants her name to have exactly n characters.
<image>
Her friend suggested that her name should only consist of uppercase and lowercase letters 'O'. More precisely, they suggested th... | {
"input": [
"8\n",
"15\n"
],
"output": [
"OOOoOooO\n",
"OOOoOooOooooOoo\n"
]
} | {
"input": [
"381\n",
"1000\n",
"5\n",
"781\n",
"999\n",
"805\n",
"3\n",
"61\n",
"256\n",
"512\n",
"1\n",
"17\n",
"2\n",
"933\n",
"85\n",
"49\n"
],
"output": [
"OOOoOooOooooOoooooooOooooooooooooOooooooooooooooooooooOoooooooooooooooooooooooooooooo... | 800 | 500 |
2 | 7 | 940_A. Points on the line | We've got no test cases. A big olympiad is coming up. But the problemsetters' number one priority should be adding another problem to the round.
The diameter of a multiset of points on the line is the largest distance between two points from this set. For example, the diameter of the multiset {1, 3, 2, 1} is 2.
Diame... | {
"input": [
"6 3\n1 3 4 6 9 10\n",
"3 1\n2 1 4\n",
"3 0\n7 7 7\n"
],
"output": [
"3\n",
"1\n",
"0\n"
]
} | {
"input": [
"1 100\n22\n",
"3 2\n1 50 99\n",
"100 56\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 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87... | 1,200 | 500 |
2 | 10 | 967_D. Resource Distribution | One department of some software company has n servers of different specifications. Servers are indexed with consecutive integers from 1 to n. Suppose that the specifications of the j-th server may be expressed with a single integer number c_j of artificial resource units.
In order for production to work, it is needed ... | {
"input": [
"4 20 32\n21 11 11 12\n",
"4 11 32\n5 5 16 16\n",
"6 8 16\n3 5 2 9 8 7\n",
"5 12 20\n7 8 4 11 9\n"
],
"output": [
"Yes\n1 3\n1 \n2 3 4 \n",
"No\n",
"Yes\n2 2\n2 6 \n5 4 ",
"No\n"
]
} | {
"input": [
"2 1 1\n1 1000000\n",
"2 1 1\n1 1\n",
"2 1 2\n1 1\n",
"6 8 16\n3 5 2 9 8 7\n",
"15 250 200\n71 2 77 69 100 53 54 40 73 32 82 58 24 82 41\n",
"4 12 11\n4 4 6 11\n",
"2 1 1\n1000000000 1000000000\n"
],
"output": [
"Yes\n1 1\n1 \n2 \n",
"Yes\n1 1\n1 \n2 \n",
"No\n... | 1,700 | 1,000 |
2 | 10 | 993_D. Compute Power | You need to execute several tasks, each associated with number of processors it needs, and the compute power it will consume.
You have sufficient number of analog computers, each with enough processors for any task. Each computer can execute up to one task at a time, and no more than two tasks total. The first task ca... | {
"input": [
"6\n8 10 9 9 8 10\n1 1 1 1 1 1\n",
"6\n8 10 9 9 8 10\n1 10 5 5 1 10\n"
],
"output": [
"9000\n",
"1160\n"
]
} | {
"input": [
"5\n21581303 73312811 99923326 93114466 53291492\n32 75 75 33 5\n",
"10\n7 9 8 9 4 8 5 2 10 5\n6 6 7 8 9 7 10 1 1 7\n",
"50\n2 10 10 6 8 1 5 10 3 4 3 5 5 8 4 5 8 2 3 3 3 8 8 5 5 5 5 8 2 5 1 5 4 8 3 7 10 8 6 1 4 9 4 9 1 9 2 7 9 9\n10 6 2 2 3 6 5 5 4 1 3 1 2 3 10 10 6 8 7 2 8 5 2 5 4 9 7 5 2 8 ... | 2,500 | 1,500 |
2 | 10 | 1008_D. Pave the Parallelepiped | You are given a rectangular parallelepiped with sides of positive integer lengths A, B and C.
Find the number of different groups of three integers (a, b, c) such that 1β€ aβ€ bβ€ c and parallelepiped AΓ BΓ C can be paved with parallelepipeds aΓ bΓ c. Note, that all small parallelepipeds have to be rotated in the same d... | {
"input": [
"4\n1 1 1\n1 6 1\n2 2 2\n100 100 100\n"
],
"output": [
"1\n4\n4\n165\n"
]
} | {
"input": [
"10\n1 1 1\n1 1 1\n1 1 1\n1 1 1\n1 1 1\n1 1 1\n1 1 1\n1 1 1\n1 1 1\n1 1 1\n",
"1\n100000 100000 100000\n",
"10\n9 6 8\n5 5 2\n8 9 2\n2 7 9\n6 4 10\n1 1 8\n2 8 1\n10 6 3\n7 5 2\n9 5 4\n"
],
"output": [
"1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n",
"8436\n",
"41\n6\n21\n12\n39\n4\n7\n26\n8\... | 2,400 | 1,000 |
2 | 8 | 1031_B. Curiosity Has No Limits | When Masha came to math classes today, she saw two integer sequences of length n - 1 on the blackboard. Let's denote the elements of the first sequence as a_i (0 β€ a_i β€ 3), and the elements of the second sequence as b_i (0 β€ b_i β€ 3).
Masha became interested if or not there is an integer sequence of length n, which e... | {
"input": [
"4\n3 3 2\n1 2 0\n",
"3\n1 3\n3 2\n"
],
"output": [
"YES\n1 3 2 0 ",
"NO"
]
} | {
"input": [
"2\n2\n0\n",
"50\n3 1 2 2 3 1 1 1 3 3 1 0 2 0 1 1 0 0 1 2 2 0 0 0 2 3 0 3 1 2 0 3 0 0 1 0 3 3 1 3 1 1 2 3 1 3 2 1 3\n2 1 1 1 1 0 2 2 0 1 2 3 0 1 0 1 1 1 0 0 3 1 3 3 1 0 0 1 1 2 0 2 1 1 2 0 0 0 0 2 3 3 0 1 1 1 0 2 0\n",
"2\n2\n3\n",
"2\n1\n0\n",
"2\n0\n3\n",
"100\n2 2 2 2 3 3 3 3 3... | 1,500 | 1,000 |
2 | 8 | 1054_B. Appending Mex | Initially Ildar has an empty array. He performs n steps. On each step he takes a subset of integers already added to the array and appends the mex of this subset to the array.
The mex of an multiset of integers is the smallest non-negative integer not presented in the multiset. For example, the mex of the multiset [0... | {
"input": [
"3\n1 0 1\n",
"4\n0 1 2 1\n",
"4\n0 1 2 239\n"
],
"output": [
"1\n",
"-1\n",
"4\n"
]
} | {
"input": [
"2\n0 1\n",
"3\n0 1 1000000000\n",
"3\n0 2 4\n",
"1\n1\n",
"2\n0 0\n",
"2\n0 1000000000\n",
"2\n1 1\n",
"5\n0 0 0 0 0\n",
"2\n1 2\n",
"1\n1000000000\n",
"5\n0 0 2 2 3\n",
"2\n0 2\n",
"4\n0 0 2 1\n",
"5\n0 0 2 3 4\n",
"3\n0 0 2\n",
"3\n3 4 5\... | 1,000 | 750 |
2 | 8 | 1076_B. Divisor Subtraction | You are given an integer number n. The following algorithm is applied to it:
1. if n = 0, then end algorithm;
2. find the smallest prime divisor d of n;
3. subtract d from n and go to step 1.
Determine the number of subtrations the algorithm will make.
Input
The only line contains a single integer n (2 β€... | {
"input": [
"4\n",
"5\n"
],
"output": [
"2\n",
"1\n"
]
} | {
"input": [
"9999999999\n",
"10000000000\n",
"9999999967\n",
"2\n",
"6969696\n",
"473\n",
"9998200081\n",
"3000000021\n"
],
"output": [
"4999999999\n",
"5000000000\n",
"1\n",
"1\n",
"3484848\n",
"232\n",
"4999050046\n",
"1500000010\n"
]
} | 1,200 | 0 |
2 | 8 | 1097_B. Petr and a Combination Lock | Petr has just bought a new car. He's just arrived at the most known Petersburg's petrol station to refuel it when he suddenly discovered that the petrol tank is secured with a combination lock! The lock has a scale of 360 degrees and a pointer which initially points at zero:
<image>
Petr called his car dealer, who in... | {
"input": [
"3\n10\n10\n10\n",
"3\n120\n120\n120\n",
"3\n10\n20\n30\n"
],
"output": [
"NO\n",
"YES\n",
"YES\n"
]
} | {
"input": [
"5\n179\n179\n179\n179\n4\n",
"5\n179\n170\n160\n111\n100\n",
"4\n1\n178\n180\n1\n",
"6\n180\n178\n157\n143\n63\n1\n",
"5\n100\n100\n100\n100\n40\n",
"9\n80\n80\n80\n80\n80\n80\n80\n80\n80\n",
"5\n179\n179\n179\n92\n91\n",
"5\n30\n30\n120\n120\n120\n",
"9\n1\n2\n4\n8\n... | 1,200 | 1,000 |
2 | 9 | 1118_C. Palindromic Matrix | Let's call some square matrix with integer values in its cells palindromic if it doesn't change after the order of rows is reversed and it doesn't change after the order of columns is reversed.
For example, the following matrices are palindromic:
<image>
The following matrices are not palindromic because they change... | {
"input": [
"4\n1 8 8 1 2 2 2 2 2 2 2 2 1 8 8 1\n",
"4\n1 2 1 9 8 4 3 8 8 3 4 8 9 2 1 1\n",
"1\n10\n",
"3\n1 1 1 1 1 3 3 3 3\n"
],
"output": [
"YES\n1 2 2 1 \n2 8 8 2 \n2 8 8 2 \n1 2 2 1 \n",
"NO\n",
"YES\n10 \n",
"YES\n1 3 1 \n3 1 3 \n1 3 1 \n"
]
} | {
"input": [
"3\n13 13 42 42 69 69 420 420 666\n",
"11\n1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 2 2 3 3 3 3 3 3 3 3 3 3 3 3 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 5 5 5 5 5 5 5 5 5 6 6 6 6 6 6 6 6 6 6 6 6 7 7 7 7 7 7 7 7 7 7 7 7 8 8 8 8 8 8 8 8 8 8 8 8 9 9 9 9 9 9 9 9 9 9 9 9 10 10 10 10 10 10 10 10 10 10 10 10 11... | 1,700 | 0 |
2 | 12 | 1144_F. Graph Without Long Directed Paths | You are given a connected undirected graph consisting of n vertices and m edges. There are no self-loops or multiple edges in the given graph.
You have to direct its edges in such a way that the obtained directed graph does not contain any paths of length two or greater (where the length of path is denoted as the numb... | {
"input": [
"6 5\n1 5\n2 1\n1 4\n3 1\n6 1\n"
],
"output": [
"YES\n10100"
]
} | {
"input": [
"8 9\n8 1\n1 2\n1 5\n2 6\n6 5\n6 4\n4 7\n7 3\n3 5\n",
"10 10\n2 1\n3 4\n7 1\n4 10\n6 1\n8 4\n9 1\n5 8\n1 8\n3 6\n",
"10 10\n1 3\n9 6\n4 5\n1 9\n8 5\n9 7\n3 2\n5 7\n5 3\n10 5\n",
"7 7\n4 1\n7 3\n4 7\n4 2\n1 3\n6 4\n5 3\n",
"4 5\n1 2\n2 3\n3 4\n4 1\n1 3\n",
"10 10\n4 3\n6 8\n5 3\n4 ... | 1,700 | 0 |
2 | 10 | 1184_D1. Parallel Universes (Easy) | The Third Doctor Who once correctly said that travel between parallel universes is "like travelling sideways". However, he incorrectly thought that there were infinite parallel universes, whereas in fact, as we now all know, there will never be more than 250.
Heidi recently got her hands on a multiverse observation to... | {
"input": [
"5 2 10 4\n0 1\n1 1\n0 4\n1 2\n"
],
"output": [
"4 1\n5 2\n4 2\n5 3\n"
]
} | {
"input": [
"10 5 20 4\n1 1\n0 4\n1 7\n1 7\n"
],
"output": [
"11 6\n7 2\n8 2\n9 2\n"
]
} | 1,600 | 0 |
2 | 7 | 1203_A. Circle of Students | There are n students standing in a circle in some order. The index of the i-th student is p_i. It is guaranteed that all indices of students are distinct integers from 1 to n (i. e. they form a permutation).
Students want to start a round dance. A clockwise round dance can be started if the student 2 comes right after... | {
"input": [
"5\n4\n1 2 3 4\n3\n1 3 2\n5\n1 2 3 5 4\n1\n1\n5\n3 2 1 5 4\n"
],
"output": [
"YES\nYES\nNO\nYES\nYES\n"
]
} | {
"input": [
"1\n11\n11 2 3 4 5 6 7 8 9 10 1\n",
"1\n12\n12 3 4 5 6 7 8 9 10 11 1 2\n"
],
"output": [
"NO\n",
"NO\n"
]
} | 1,000 | 0 |
2 | 9 | 121_C. Lucky Permutation | 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.
One day Petya dreamt of a lexicographically k-th permutation of integers from 1 to n. Determine how ... | {
"input": [
"4 7\n",
"7 4\n"
],
"output": [
"1",
"1"
]
} | {
"input": [
"7 1000\n",
"7 5032\n",
"7 980\n",
"777477774 1\n",
"77 47\n",
"777777 2\n",
"7 985\n",
"7 127\n",
"7479 58884598\n",
"49 1000000000\n",
"10 1\n",
"47 8547744\n",
"7 5040\n",
"64 87\n",
"4 25\n",
"7 2048\n",
"27 1\n",
"20 1000000000\... | 1,900 | 1,500 |
2 | 13 | 1244_G. Running in Pairs | Demonstrative competitions will be held in the run-up to the 20NN Berlatov Olympic Games. Today is the day for the running competition!
Berlatov team consists of 2n runners which are placed on two running tracks; n runners are placed on each track. The runners are numbered from 1 to n on each track. The runner with nu... | {
"input": [
"10 54\n",
"3 9\n",
"5 20\n"
],
"output": [
"-1\n",
"8\n1 2 3\n3 2 1\n",
"20\n1 2 3 4 5 \n5 3 2 4 1 "
]
} | {
"input": [
"10 81\n",
"3 1\n",
"500 125251\n",
"50 1274\n",
"10000 75005000\n",
"2 1\n",
"50 1901\n",
"500000 125000249999\n",
"1 1\n",
"3 6\n",
"3 7\n",
"50 1275\n",
"100000 5000049999\n",
"10000 74621728\n",
"10000 75004999\n",
"50 1900\n",
"2 3\... | 2,400 | 3,000 |
2 | 7 | 1286_A. Garland | Vadim loves decorating the Christmas tree, so he got a beautiful garland as a present. It consists of n light bulbs in a single row. Each bulb has a number from 1 to n (in arbitrary order), such that all the numbers are distinct. While Vadim was solving problems, his home Carp removed some light bulbs from the garland.... | {
"input": [
"7\n1 0 0 5 0 0 2\n",
"5\n0 5 0 2 3\n"
],
"output": [
"1\n",
"2\n"
]
} | {
"input": [
"100\n0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 48 69 63 77 67 28 7 23 97 99 20 42 50 43 27 81 18 76 87 79 52 37 29 24 65 85 83 68 25 10 45 75 33 15 66 71 6 21 64 47 22 8 39 57 4 1 19 35 12 34 13 9 53 40 62 94 44 90 31\n",
"1\n0\n",
"100\n63 0 0 20 0 0 ... | 1,800 | 500 |
2 | 8 | 1305_B. Kuroni and Simple Strings | Now that Kuroni has reached 10 years old, he is a big boy and doesn't like arrays of integers as presents anymore. This year he wants a Bracket sequence as a Birthday present. More specifically, he wants a bracket sequence so complex that no matter how hard he tries, he will not be able to remove a simple subsequence!
... | {
"input": [
"(()((\n",
"(()())\n",
")(\n"
],
"output": [
"1\n2\n1 3 ",
"1\n4\n1 2 5 6 ",
"0"
]
} | {
"input": [
"()()()()()()()(\n",
"()\n"
],
"output": [
"1\n8\n1 3 5 7 8 10 12 14 ",
"1\n2\n1 2 "
]
} | 1,200 | 1,000 |
2 | 10 | 1349_D. Slime and Biscuits | Slime and his n friends are at a party. Slime has designed a game for his friends to play.
At the beginning of the game, the i-th player has a_i biscuits. At each second, Slime will choose a biscuit randomly uniformly among all a_1 + a_2 + β¦ + a_n biscuits, and the owner of this biscuit will give it to a random unifor... | {
"input": [
"2\n1 2\n",
"5\n8 4 2 0 1\n",
"2\n1 1\n",
"5\n0 0 0 0 35\n"
],
"output": [
"3\n",
"801604029\n",
"1\n",
"0\n"
]
} | {
"input": [
"36\n110 7 51 3 36 69 30 7 122 22 11 96 98 17 133 44 38 75 7 10 4 3 68 50 43 25 4 29 42 36 11 7 36 12 75 1\n",
"10\n7758 19921 15137 1138 90104 17467 82544 55151 3999 6781\n",
"100\n4364 698 1003 1128 1513 39 4339 969 7452 3415 1154 1635 6649 136 1442 50 834 1680 107 978 983 3176 4017 1692 11... | 3,200 | 2,000 |
2 | 8 | 136_B. 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 it... | {
"input": [
"387420489 225159023\n",
"14 34\n",
"50 34\n",
"5 5\n"
],
"output": [
"1000000001\n",
"50\n",
"14\n",
"0\n"
]
} | {
"input": [
"976954722 548418041\n",
"4232 755480607\n",
"640735701 335933492\n",
"5341 813849430\n",
"23476 23875625\n",
"47229813 6200\n",
"657244587 28654748\n",
"278014879 3453211\n",
"5849 7211\n",
"417584836 896784933\n",
"19079106 69880743\n",
"922263603 3875066... | 1,100 | 1,000 |
2 | 8 | 1392_B. Omkar and Infinity Clock | Being stuck at home, Ray became extremely bored. To pass time, he asks Lord Omkar to use his time bending power: Infinity Clock! However, Lord Omkar will only listen to mortals who can solve the following problem:
You are given an array a of n integers. You are also given an integer k. Lord Omkar wants you to do k ope... | {
"input": [
"3\n2 1\n-199 192\n5 19\n5 -1 4 2 0\n1 2\n69\n"
],
"output": [
"391 0 \n0 6 1 3 5 \n0 \n"
]
} | {
"input": [
"1\n2 1\n-2 -3\n",
"3\n1 1\n1\n5 4\n5 -1 4 2 0\n1 2\n69\n",
"1\n5 1\n-5 -4 -3 -2 -1\n",
"1\n2 1\n-6 -9\n",
"1\n1 398708496844866113\n959414461\n",
"1\n2 1\n-5 -4\n",
"2\n3 1\n-1 -2 0\n3 2\n-1 -2 0\n",
"1\n5 1\n-1 -2 -3 -4 -5\n",
"1\n2 1\n-1000000000 -1000000000\n",
... | 800 | 750 |
2 | 9 | 1433_C. Dominant Piranha | There are n piranhas with sizes a_1, a_2, β¦, a_n in the aquarium. Piranhas are numbered from left to right in order they live in the aquarium.
Scientists of the Berland State University want to find if there is dominant piranha in the aquarium. The piranha is called dominant if it can eat all the other piranhas in the... | {
"input": [
"6\n5\n5 3 4 4 5\n3\n1 1 1\n5\n4 4 3 4 4\n5\n5 5 4 3 2\n3\n1 1 2\n5\n5 4 3 5 5\n"
],
"output": [
"1\n-1\n2\n2\n3\n1\n"
]
} | {
"input": [
"1\n3\n5 3 4\n",
"6\n5\n5 3 4 4 5\n3\n1 1 1\n5\n4 4 3 4 4\n5\n5 5 4 3 2\n3\n1 1 2\n5\n5 4 3 5 5\n",
"1\n3\n10 1 5\n"
],
"output": [
"1\n",
"1\n-1\n2\n2\n3\n1\n",
"1\n"
]
} | 900 | 0 |
2 | 8 | 1458_B. Glass Half Spilled | There are n glasses on the table numbered 1, β¦, n. The glass i can hold up to a_i units of water, and currently contains b_i units of water.
You would like to choose k glasses and collect as much water in them as possible. To that effect you can pour water from one glass to another as many times as you like. However, ... | {
"input": [
"3\n6 5\n6 5\n10 2\n"
],
"output": [
"\n7.0000000000 11.0000000000 12.0000000000\n"
]
} | {
"input": [
"100\n1 0\n1 0\n1 0\n1 0\n1 0\n1 1\n1 0\n1 0\n1 0\n1 1\n1 0\n1 0\n1 0\n1 0\n1 0\n1 0\n1 0\n1 0\n1 1\n1 0\n1 0\n1 0\n1 0\n1 1\n1 0\n1 1\n1 0\n1 1\n1 1\n1 0\n1 0\n1 0\n1 1\n1 0\n1 0\n1 0\n1 1\n1 1\n1 0\n1 1\n1 0\n1 1\n1 1\n1 0\n1 0\n1 0\n1 0\n1 1\n1 0\n1 0\n1 0\n1 0\n1 1\n1 0\n1 0\n1 1\n1 0\n1 0\n1 0\n... | 2,000 | 1,000 |
2 | 8 | 1481_B. New Colony | After reaching your destination, you want to build a new colony on the new planet. Since this planet has many mountains and the colony must be built on a flat surface you decided to flatten the mountains using boulders (you are still dreaming so this makes sense to you).
<image>
You are given an array h_1, h_2, ..., ... | {
"input": [
"4\n4 3\n4 1 2 3\n2 7\n1 8\n4 5\n4 1 2 3\n3 1\n5 3 1\n"
],
"output": [
"\n2\n1\n-1\n-1\n"
]
} | {
"input": [
"14\n7 150\n11 21 25 35 45 52 62\n7 145\n11 21 31 41 51 61 71\n7 50\n2 12 22 32 42 52 62\n7 204\n11 21 21 31 41 51 61\n7 101\n11 21 31 41 51 61 71\n7 107\n11 21 31 41 51 59 69\n7 218\n11 19 29 39 49 54 64\n7 199\n58 7 24 70 5 43 69\n7 335\n72 55 43 64 96 23 57\n7 36\n96 83 98 58 73 30 23\n7 92\n68 22... | 1,100 | 750 |
2 | 9 | 1508_C. Complete the MST | As a teacher, Riko Hakozaki often needs to help her students with problems from various subjects. Today, she is asked a programming task which goes as follows.
You are given an undirected complete graph with n nodes, where some edges are pre-assigned with a positive weight while the rest aren't. You need to assign all... | {
"input": [
"4 4\n2 1 14\n1 4 14\n3 2 15\n4 3 8\n",
"5 6\n2 3 11\n5 3 7\n1 4 10\n2 4 14\n4 3 8\n2 5 6\n",
"6 6\n3 6 4\n2 4 1\n4 5 7\n3 4 10\n3 5 1\n5 2 15\n"
],
"output": [
"\n15\n",
"\n6\n",
"\n0\n"
]
} | {
"input": [
"2 0\n",
"6 8\n1 4 1\n1 5 1\n1 6 1\n2 4 1\n2 5 1\n2 6 1\n3 5 1\n3 6 1\n",
"6 12\n1 3 8763000\n1 4 8763000\n1 5 8763000\n1 6 8763000\n2 3 8763000\n2 4 1\n2 5 8763000\n2 6 1\n3 5 8763000\n3 6 8763000\n4 5 8763000\n4 6 2\n"
],
"output": [
"0\n",
"0\n",
"8763002\n"
]
} | 2,500 | 1,500 |
2 | 10 | 1534_D. Lost Tree | This is an interactive problem.
Little Dormi was faced with an awkward problem at the carnival: he has to guess the edges of an unweighted tree of n nodes! The nodes of the tree are numbered from 1 to n.
The game master only allows him to ask one type of question:
* Little Dormi picks a node r (1 β€ r β€ n), and the... | {
"input": [
"4\n\n0 1 2 2\n\n1 0 1 1",
"5\n\n2 2 1 1 0\n"
],
"output": [
"\n? 1\n\n? 2\n\n!\n4 2\n1 2\n2 3\n",
"\n? 5\n\n!\n4 5\n3 5\n2 4\n1 3\n"
]
} | {
"input": [
"5\n5 3\n2 4\n3 1\n4 5\n",
"4\n2 4\n3 2\n2 1\n",
"5\n5 3\n2 4\n3 1\n4 5\n",
"2\n1 2\n",
"4\n3 4\n2 3\n3 1\n",
"10\n8 10\n2 9\n7 8\n4 1\n7 3\n4 7\n2 5\n2 4\n4 6\n",
"5\n3 4\n3 2\n3 1\n1 5\n",
"3\n1 2\n2 3\n",
"5\n1 2\n1 3\n1 4\n1 5\n"
],
"output": [
"",
"1 2... | 0 | 1,500 |
2 | 8 | 181_B. Number of Triplets | You are given n points on a plane. All points are different.
Find the number of different groups of three points (A, B, C) such that point B is the middle of segment AC.
The groups of three points are considered unordered, that is, if point B is the middle of segment AC, then groups (A, B, C) and (C, B, A) are consi... | {
"input": [
"3\n0 0\n-1 0\n0 1\n",
"3\n1 1\n2 2\n3 3\n"
],
"output": [
"0\n",
"1\n"
]
} | {
"input": [
"10\n-2 1\n2 -2\n-1 -2\n0 0\n2 -1\n0 -2\n2 2\n0 2\n-1 -1\n1 -2\n",
"40\n-8 24\n2 -1\n1 -18\n72 -70\n5 -4\n-308 436\n-19 40\n36 -35\n-178 265\n-1 2\n-7 30\n-1 0\n3 -2\n200 -285\n17 -16\n-35 74\n0 -4\n-86 106\n-1 4\n-7 6\n0 1\n-5 4\n-2 3\n6 -5\n-4 5\n181 -262\n76 -118\n0 0\n-7 18\n-58 104\n-5 6\n-6... | 1,300 | 1,000 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.