messages listlengths 1 1 | ground_truth stringlengths 156 726k | dataset stringclasses 1
value |
|---|---|---|
[
{
"content": "Recently, a start up by two students of a state university of city F gained incredible popularity. Now it's time to start a new company. But what do we call it?\n\nThe market analysts came up with a very smart plan: the name of the company should be identical to its reflection in a mirror! In othe... | [{"input": "OVWIHIWVYXMVAAAATOXWOIUUHYXHIHHVUIOOXWHOXTUUMUUVHVWWYUTIAUAITAOMHXWMTTOIVMIVOTHOVOIOHYHAOXWAUVWAVIVM\n", "output": "NO\n"}, {"input": "QDPINBMCRFWXPDBFGOZVVOCEMJRUCTOADEWEGTVBVBFWWRPGYEEYGPRWWFBVBVTGEWEDAOTCURJMECOVVZOGFBDPXWFRCMBNIPDQ\n", "output": "NO\n"}, {"input": "OVWIHIWVYXMVAAAATOXWOIUUHYXHIHHVUIOOXW... | code_stdio |
[
{
"content": "You are given a string S of length 2 or 3 consisting of lowercase English letters. If the length of the string is 2, print it as is; if the length is 3, print the string after reversing it.\n\nConstraints\n\n* The length of S is 2 or 3.\n* S consists of lowercase English letters.\n\nInput\n\nInput... | [{"input": "acc", "output": "cca\n"}, {"input": "acb", "output": "bca\n"}, {"input": "adb", "output": "bda\n"}, {"input": "`cb", "output": "bc`\n"}, {"input": "bc`", "output": "`cb\n"}, {"input": "cb`", "output": "`bc\n"}, {"input": "cba", "output": "abc\n"}, {"input": "cab", "output": "bac\n"}, {"input": "bac", "outpu... | code_stdio |
[
{
"content": "We have a pyramid with N steps, built with blocks. The steps are numbered 1 through N from top to bottom. For each 1β€iβ€N, step i consists of 2i-1 blocks aligned horizontally. The pyramid is built so that the blocks at the centers of the steps are aligned vertically.\n\n<image>\n\nA pyramid with N=... | [{"input": "4\n-1 1 0 1 2 18 2", "output": "1\n"}, {"input": "4\n-2 1 0 1 2 18 2", "output": "1\n"}, {"input": "4\n1 12 1 -1 4 5 2", "output": "1\n"}, {"input": "4\n-1 5 5 0 8 2 0", "output": "5\n"}, {"input": "4\n-2 3 3 7 7 5 0", "output": "7\n"}, {"input": "4\n-2 3 3 7 6 1 0", "output": "6\n"}, {"input": "4\n0 2 0 1 ... | code_stdio |
[
{
"content": "You are given two arrays: an array $a$ consisting of $n$ zeros and an array $b$ consisting of $n$ integers.\n\nYou can apply the following operation to the array $a$ an arbitrary number of times: choose some subsegment of $a$ of length $k$ and add the arithmetic progression $1, 2, \\ldots, k$ to t... | [{"input": "17 10\n465 868 29 633 291 357 62 929 22 124 182 995 903 75 71 924 416\n", "output": "611\n"}, {"input": "1 1\n1000000000000\n", "output": "1000000000000\n"}, {"input": "7 4\n1 10000 1 1 1 1 10000\n", "output": "7500\n"}, {"input": "7 3\n50 17 81 25 42 39 96\n", "output": "92\n"}, {"input": "3 3\n14159 26535... | code_stdio |
[
{
"content": "In this problem at each moment you have a set of intervals. You can move from interval (a, b) from our set to interval (c, d) from our set if and only if c < a < d or c < b < d. Also there is a path from interval I_1 from our set to interval I_2 from our set if there is a sequence of successive mo... | [{"input": "20\n1 1208 1583\n1 -258 729\n1 -409 1201\n1 194 1938\n1 -958 1575\n1 -1466 1752\n2 1 2\n2 1 2\n2 6 5\n1 -1870 1881\n1 -2002 2749\n1 -2002 2984\n1 -2002 3293\n2 2 4\n2 8 10\n2 9 6\n1 -2002 3572\n1 -2002 4175\n1 -2002 4452\n1 -2002 4605\n", "output": "YES\nYES\nYES\nYES\nYES\nNO\n"}, {"input": "20\n1 1208 158... | code_stdio |
[
{
"content": "Given a matrix (H Γ W) which contains only 1 and 0, find the area of the largest square matrix which only contains 0s.\n\nConstraints\n\n* 1 β€ H, W β€ 1,400\n\nInput\n\n\nH W\nc1,1 c1,2 ... c1,W\nc2,1 c2,2 ... c2,W\n:\ncH,1 cH,2 ... cH,W\n\n\nIn the first line, two integers H and W separated by a s... | [{"input": "1 1\n1 0 -1 -1 1\n1 0 0 0 1\n0 -2 0 1 -1\n0 -1 0 2 0", "output": "0\n"}, {"input": "3 2\n-1 0 1 0 0\n1 0 0 -1 1\n-1 -1 0 1 1\n0 0 0 -2 1", "output": "1\n"}, {"input": "1 1\n0 0 -1 -1 1\n1 0 0 0 1\n0 -2 0 1 -1\n0 -1 0 2 0", "output": "1\n"}, {"input": "3 2\n-1 0 1 0 0\n1 0 0 -1 1\n-1 -1 0 1 2\n0 0 0 -2 1", "... | code_stdio |
[
{
"content": "Drazil is playing a math game with Varda.\n\nLet's define <image> for positive integer x as a product of factorials of its digits. For example, <image>.\n\nFirst, they choose a decimal number a consisting of n digits that contains at least one digit larger than 1. This number may possibly start wi... | [{"input": "15\n989898989898989\n", "output": "777777777777777333333333333333322222222222222222222222222222\n"}, {"input": "15\n999999999999990\n", "output": "77777777777777333333333333333333333333333322222222222222\n"}, {"input": "15\n987654329876543\n", "output": "777777555533333333332222222222222\n"}, {"input": "12\... | code_stdio |
[
{
"content": "A new delivery of clothing has arrived today to the clothing store. This delivery consists of $a$ ties, $b$ scarves, $c$ vests and $d$ jackets.\n\nThe store does not sell single clothing items β instead, it sells suits of two types: a suit of the first type consists of one tie and one jacket; a ... | [{"input": "100000\n100000\n100000\n100000\n1000\n1000\n", "output": "100000000\n"}, {"input": "100000\n100000\n100000\n100000\n1000\n1000\n", "output": "100000000\n"}, {"input": "100000\n100000\n100100\n100000\n1000\n1000\n", "output": "100000000\n"}, {"input": "100000\n100000\n100000\n100000\n1000\n1\n", "output": "1... | code_stdio |
[
{
"content": "You are given n positive integers a_1, a_2, ..., a_{n}.\n\nFor every a_{i} you need to find a positive integer k_{i} such that the decimal notation of 2^{k}_{i} contains the decimal notation of a_{i} as a substring among its last min(100, length(2^{k}_{i})) digits. Here length(m) is the length of ... | [{"input": "100\n822\n991\n907\n729\n120\n707\n197\n280\n444\n45\n590\n951\n338\n740\n502\n345\n969\n240\n710\n476\n530\n674\n327\n187\n890\n530\n626\n767\n178\n831\n819\n406\n413\n119\n855\n13\n17\n460\n708\n30\n364\n974\n32\n615\n231\n758\n39\n731\n288\n955\n897\n897\n365\n246\n209\n17\n836\n496\n916\n610\n961\n181\n... | code_stdio |
[
{
"content": "Among Johnny's numerous hobbies, there are two seemingly harmless ones: applying bitwise operations and sneaking into his dad's office. As it is usually the case with small children, Johnny is unaware that combining these two activities can get him in a lot of trouble.\n\nThere is a set $S$ contai... | [{"input": "6\n4\n1 0 2 5\n6\n10 7 14 16 0 12\n2\n0 1\n3\n1 2 6\n6\n1 4 6 10 11 20\n2\n0 1023\n", "output": "-1\n-1\n1\n-1\n-1\n1023\n"}, {"input": "6\n4\n1 0 2 6\n6\n10 7 27 16 1 12\n2\n0 1\n3\n1 2 6\n6\n0 8 6 10 11 33\n2\n0 1023\n", "output": "-1\n11\n1\n-1\n-1\n1023\n"}, {"input": "6\n4\n1 0 2 5\n6\n10 7 14 16 0 12\... | code_stdio |
[
{
"content": "A group of $n$ dancers rehearses a performance for the closing ceremony. The dancers are arranged in a row, they've studied their dancing moves and can't change positions. For some of them, a white dancing suit is already bought, for some of them β a black one, and for the rest the suit will be bo... | [{"input": "20 53 67\n1 2 1 2 0 0 0 2 2 2 1 0 0 2 0 0 0 1 1 2\n", "output": "413\n"}, {"input": "20 53 67\n1 2 1 2 0 0 0 2 2 2 1 0 0 2 0 0 0 1 1 2\n", "output": "413\n"}, {"input": "20 53 67\n1 2 1 2 0 0 0 2 2 2 1 0 0 2 0 0 1 1 1 2\n", "output": "427\n"}, {"input": "20 53 67\n1 2 1 2 0 0 0 2 2 2 1 0 0 2 0 0 1 2 1 2\n",... | code_stdio |
[
{
"content": "Reziba has many magic gems. Each magic gem can be split into $M$ normal gems. The amount of space each magic (and normal) gem takes is $1$ unit. A normal gem cannot be split.\n\nReziba wants to choose a set of magic gems and split some of them, so the total space occupied by the resulting set of g... | [{"input": "1000000000000000000 100\n", "output": "161502719\n"}, {"input": "1000000000000000000 100\n", "output": "161502719\n"}, {"input": "1000000000000000000 42\n", "output": "683499162\n"}, {"input": "1000000000000000000 69\n", "output": "864131130\n"}, {"input": "1000000000000000000 99\n", "output": "847914677\n"... | code_stdio |
[
{
"content": "'Twas the night before Christmas, and Santa's frantically setting up his new Christmas tree! There are n nodes in the tree, connected by n-1 edges. On each edge of the tree, there's a set of Christmas lights, which can be represented by an integer in binary representation.\n\n<image>\n\nHe has m e... | [{"input": "4\n6 5\n1 2 -1\n1 3 1\n4 2 7\n6 3 0\n2 5 -1\n2 3 1\n2 5 0\n5 6 1\n6 1 1\n4 5 1\n5 3\n1 2 -1\n1 3 -1\n1 4 1\n4 5 -1\n2 4 0\n3 4 1\n2 3 1\n3 3\n1 2 -1\n1 3 -1\n2 2 0\n1 3 1\n2 3 0\n2 0\n1 2 1\n1 2 0\n", "output": "YES\n1 2 0\n1 3 1\n4 2 7\n6 3 0\n2 5 0\nYES\n1 2 1\n1 3 0\n1 4 1\n4 5 1\nYES\n1 2 1\n1 3 1\nYES\... | code_stdio |
[
{
"content": "Count the pairs of length-N sequences consisting of integers between 1 and M (inclusive), A_1, A_2, \\cdots, A_{N} and B_1, B_2, \\cdots, B_{N}, that satisfy all of the following conditions:\n - A_i \\neq B_i, for every i such that 1\\leq i\\leq N.\n - A_i \\neq A_j and B_i \\neq B_j, for every (i... | [{"input": "141421 356237\n", "output": "881613484\n"}, {"input": "500000 500000\n", "output": "869509376\n"}, {"input": "436426 479445\n", "output": "710501305\n"}, {"input": "148772 190081\n", "output": "685499830\n"}, {"input": "190629 433447\n", "output": "627318091\n"}, {"input": "47202 203497\n", "output": "37412... | code_stdio |
[
{
"content": "Polycarp is crazy about round numbers. He especially likes the numbers divisible by 10^{k}.\n\nIn the given number of n Polycarp wants to remove the least number of digits to get a number that is divisible by 10^{k}. For example, if k = 3, in the number 30020 it is enough to delete a single digit ... | [{"input": "1000000001 10\n", "output": "9\n"}, {"input": "1234567890 14\n", "output": "9\n"}, {"input": "1000999999 3\n", "output": "6\n"}, {"input": "1090090090 5\n", "output": "2\n"}, {"input": "1234567890 1\n", "output": "0\n"}, {"input": "1234567890 2\n", "output": "9\n"}, {"input": "1234567890 9\n", "output": "9\... | code_stdio |
[
{
"content": "At Aizu Shingakujuku, students are divided into classes by conducting a proficiency test when they enter the cram school. The test consists of three subjects: Mathematics, English, and Japanese, and students are divided into A, B, and C classes. The level of class A is the highest and then decreas... | [{"input": "4\n100 217 28\n253 43 197\n18 34 24\n19 22 189\n2\n190 106 20\n66 72 171\n0", "output": "A\nA\nC\nB\nA\nA\n"}, {"input": "4\n100 137 28\n143 43 197\n18 34 24\n19 19 65\n2\n196 106 20\n66 72 171\n0", "output": "A\nA\nC\nC\nA\nA\n"}, {"input": "4\n111 273 20\n165 86 15\n80 41 202\n0 88 65\n2\n147 81 12\n119 1... | code_stdio |
[
{
"content": "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 b... | [{"input": "100\n13 92 99 100 89 6 64 32 36 40 62 30 53 31 60 4 54 83 10 59 15 67 47 93 70 41 78 34 20 69 1 74 39 16 95 48 25 80 21 85 50 33 88 71 75 73 77 87 7 5 90 28 14 96 49 57 68 22 8 27 37 86 51 94 11 66 55 29 63 91 45 65 97 23 52 17 81 42 46 35 24 19 44 43 9 84 26 82 2 18 76 56 3 38 72 61 58 98 12 79\n", "output... | code_stdio |
[
{
"content": "Dasha logged into the system and began to solve problems. One of them is as follows:\n\nGiven two sequences a and b of length n each you need to write a sequence c of length n, the i-th element of which is calculated as follows: c_{i} = b_{i} - a_{i}.\n\nAbout sequences a and b we know that their ... | [{"input": "30 100 200\n102 108 122 116 107 145 195 145 119 110 187 196 140 174 104 190 193 181 118 127 157 111 139 175 173 191 181 105 142 166\n30 26 20 23 27 15 2 14 21 25 6 1 17 10 29 5 3 7 22 19 13 24 18 9 11 4 8 28 16 12\n", "output": "100 100 100 100 100 101 100 100 100 100 100 100 100 100 100 100 100 100 100 100... | code_stdio |
[
{
"content": "Levko loves array a1, a2, ... , an, consisting of integers, very much. That is why Levko is playing with array a, performing all sorts of operations with it. Each operation Levko performs is of one of two types:\n\n 1. Increase all elements from li to ri by di. In other words, perform assignments... | [{"input": "97 29\n2 78 82 356152\n2 14 29 430177\n1 59 84 3680\n1 49 89 -2247\n1 92 96 3701\n2 54 89 377271\n1 62 70 -507\n2 94 97 431563\n1 46 55 -9257\n1 51 83 1627\n1 10 20 6633\n1 17 34 -9263\n2 66 92 383251\n1 12 82 3884\n1 78 96 -5379\n2 13 35 424798\n1 68 91 2939\n2 80 84 214725\n1 61 85 -4390\n1 85 96 3106\n2 ... | code_stdio |
[
{
"content": "Chef likes to travel very much. He plans some travel routes and wants to know their lengths. He hired you to make these calculations. But be careful, some of the routes are incorrect. There may be some misspelling in city names or there will be no road between some two consecutive cities in the ro... | [{"input": "5\nDonetsk Kiev New-York Miami Hollywood\n9\nDonetsk Kiev 930\nKiev New-York 7507\nNew-York Miami 1764\nMiami Hollywood 28\nHollywood Miami 30\nMiami New-York 1764\nKiev Donetsk 550\nHollywood New-York 1736\nNew-York Hollywood 1738\n13\n5 Donetsk Kiev New-York Miami Hollywood\n5 Hlolywood Miami New-York Kie... | code_stdio |
[
{
"content": "Door's family is going celebrate Famil Doors's birthday party. They love Famil Door so they are planning to make his birthday cake weird!\n\nThe cake is a n Γ n square consisting of equal squares with side length 1. Each square is either empty or consists of a single chocolate. They bought the cak... | [{"input": "21\n...CCC.....CC..C..C.C\n..CCC...CC...CC.CCC.C\n....C.C.C..CCC..C.C.C\n....CCC..C..C.CC.CCC.\n...CCC.C..C.C.....CCC\n.CCC.....CCC..C...C.C\nCCCC.C...CCC.C...C.CC\nC..C...C.CCC..CC..C..\nC...CC..C.C.CC..C.CC.\nCC..CCCCCCCCC..C....C\n.C..CCCC.CCCC.CCC...C\nCCC...CCC...CCC.C..C.\n.CCCCCCCC.CCCC.CC.C..\n.C.C.... | code_stdio |
[
{
"content": "You are given a sequence D_1, D_2, ..., D_N of length N.\nThe values of D_i are all distinct.\nDoes a tree with N vertices that satisfies the following conditions exist?\n - The vertices are numbered 1,2,..., N.\n - The edges are numbered 1,2,..., N-1, and Edge i connects Vertex u_i and v_i.\n - F... | [{"input": "15\n57\n62\n47\n45\n42\n74\n90\n75\n54\n50\n66\n63\n77\n87\n51\n", "output": "1 10\n1 11\n2 8\n2 15\n3 5\n3 9\n4 5\n4 10\n5 15\n6 12\n6 14\n7 13\n9 12\n11 13\n"}, {"input": "15\n57\n62\n47\n45\n42\n74\n90\n75\n54\n50\n66\n63\n77\n87\n51", "output": "1 10\n1 11\n2 8\n2 15\n3 5\n3 9\n4 5\n4 10\n5 15\n6 12\n6 ... | code_stdio |
[
{
"content": "Let's define a number ebne (even but not even) if and only if its sum of digits is divisible by 2 but the number itself is not divisible by 2. For example, 13, 1227, 185217 are ebne numbers, while 12, 2, 177013, 265918 are not. If you're still unsure what ebne numbers are, you can look at the samp... | [{"input": "36\n6\n165310\n6\n177978\n6\n211759\n6\n212643\n6\n229540\n6\n250029\n6\n211519\n6\n256097\n6\n163478\n5\n91505\n5\n79280\n6\n260629\n6\n128051\n6\n121972\n6\n261633\n6\n172044\n6\n119055\n6\n208323\n6\n149942\n6\n161236\n6\n177150\n6\n233766\n5\n97949\n6\n230107\n6\n175822\n6\n213545\n6\n232837\n6\n179166\... | code_stdio |
[
{
"content": "At an arcade, Takahashi is playing a game called RPS Battle, which is played as follows:\n - The player plays N rounds of Rock Paper Scissors against the machine. (See Notes for the description of Rock Paper Scissors. A draw also counts as a round.)\n - Each time the player wins a round, depending... | [{"input": "99901 2\n3193 1797 2772\nssrprrspsrprsrpsrprsssprrsrssrrprppprrrrrrrsprrrrsprsprsspsspprrrrpprsrprrrrpsspprrrspspsprprprprrpprppsrspprrsssssprsrrsrrsssppsprsrprpprpspppsprrspsspsppsrpspprpprsrsrssrrrrprspprpprrspssprsrrsppsrsrpssprsssprspppspspssrrpsrprpsrpprsrpppsprssssprsrrrrpsrprrrppsrrrrrsssrrsrprrrrrpp... | code_stdio |
[
{
"content": "The next \"Data Structures and Algorithms\" lesson will be about Longest Increasing Subsequence (LIS for short) of a sequence. For better understanding, Nam decided to learn it a few days before the lesson.\n\nNam created a sequence a consisting of n (1 β€ n β€ 10^5) elements a_1, a_2, ..., a_{n} (1... | [{"input": "100\n102 157 177 149 138 193 19 74 127 156 128 122 6 101 154 92 24 188 51 89 18 77 112 100 65 11 113 173 79 124 102 81 11 171 114 43 60 168 44 86 87 82 177 8 12 181 139 121 140 28 108 17 173 63 18 4 148 125 117 153 193 180 188 142 46 75 163 126 128 22 32 163 164 1 161 19 162 59 190 14 93 85 93 37 73 64 64 1... | code_stdio |
[
{
"content": "Ahmed and Mostafa used to compete together in many programming contests for several years. Their coach Fegla asked them to solve one challenging problem, of course Ahmed was able to solve it but Mostafa couldn't.\n\nThis problem is similar to a standard problem but it has a different format and co... | [{"input": "14 14\n6 -1 1 1 1 1 1\n6 1 1 1 1 1 1\n6 2 1 1 1 1 1\n6 1 1 1 1 1 1\n6 1 1 1 1 1 1\n6 1 1 1 1 1 1\n6 1 1 1 1 1 1\n6 1 1 1 1 1 1\n6 1 1 1 1 1 1\n6 1 1 1 1 1 1\n6 1 1 1 1 1 1\n6 1 1 1 1 1 1\n6 1 1 1 1 1 1\n6 1 1 1 1 1 -1\n1 2 3 4 5 6 7 8 9 10 11 12 13 14\n", "output": "83\n"}, {"input": "14 14\n6 -1 1 1 1 1 1\... | code_stdio |
[
{
"content": "Β«BersoftΒ» company is working on a new version of its most popular text editor β Bord 2010. Bord, like many other text editors, should be able to print out multipage documents. A user keys a sequence of the document page numbers that he wants to print out (separates them with a comma, without space... | [{"input": "713,572,318,890,577,657,646,146,373,783,392,229,455,871,20,593,573,336,26,381,280,916,907,732,820,713,111,840,570,446,184,711,481,399,788,647,492,15,40,530,549,506,719,782,126,20,778,996,712,761,9,74,812,418,488,175,103,585,900,3,604,521,509,513,145,708,990,361,682,827,791,22,596,780,596,385,450,643,118,496... | code_stdio |
[
{
"content": "Piegirl was asked to implement two table join operation for distributed database system, minimizing the network traffic.\n\nSuppose she wants to join two tables, A and B. Each of them has certain number of rows which are distributed on different number of partitions. Table A is distributed on the ... | [{"input": "10 10\n933168403 308417110 823216696 818565876 448948583 884328249 809244579 473034231 407137956 871269623\n1302355559 145998557 644003076 138712151 839886312 479712343 709513279 138285801 858528549 643830064\n", "output": "11375801438\n"}, {"input": "10 10\n933168403 308417110 823216696 818565876 448948583... | code_stdio |
[
{
"content": "You are given $n$ rectangles, each of height $1$. Each rectangle's width is a power of $2$ (i. e. it can be represented as $2^x$ for some non-negative integer $x$).\n\nYou are also given a two-dimensional box of width $W$. Note that $W$ may or may not be a power of $2$. Moreover, $W$ is at least a... | [{"input": "2\n5 20\n1 2 16 2 8\n6 12\n4 8 8 4 2 8\n", "output": "2\n3\n"}, {"input": "2\n5 13\n2 2 8 2 8\n6 23\n1 16 8 2 2 1\n", "output": "2\n2\n"}, {"input": "2\n5 16\n1 2 8 4 8\n6 10\n2 8 8 2 2 8\n", "output": "\n2\n3\n"}, {"input": "2\n5 16\n1 2 8 4 8\n6 10\n2 8 8 2 2 8\n", "output": "2\n3\n"}, {"input": "2\n5 13\... | code_stdio |
[
{
"content": "A social network for dogs called DH (DogHouse) has k special servers to recompress uploaded videos of cute cats. After each video is uploaded, it should be recompressed on one (any) of the servers, and only after that it can be saved in the social network.\n\nWe know that each server takes one sec... | [{"input": "10 10\n999999991 1000000000\n999999992 1000000000\n999999993 1000000000\n999999994 1000000000\n999999995 1000000000\n999999996 1000000000\n999999997 1000000000\n999999998 1000000000\n999999999 1000000000\n1000000000 1000000000\n", "output": "1999999991\n1999999992\n1999999993\n1999999994\n1999999995\n199999... | code_stdio |
[
{
"content": "Everybody knows that the $m$-coder Tournament will happen soon. $m$ schools participate in the tournament, and only one student from each school participates.\n\nThere are a total of $n$ students in those schools. Before the tournament, all students put their names and the names of their schools i... | [{"input": "100 10 1\n62 68 24 82 66 47 73 43 85 23 78 13 94 14 84 17 27 5 72 48 59 46 97 81 88 9 76 69 11 15 12 61 70 7 91 34 99 52 54 57 56 64 55 67 40 38 74 25 30 4 22 92 33 3 86 45 37 26 87 53 75 71 58 96 98 20 36 1 95 63 10 49 19 41 89 21 39 100 93 42 32 90 28 83 6 29 60 65 44 35 18 16 8 50 80 31 51 2 77 79\n6 6 6... | code_stdio |
[
{
"content": "One very experienced problem writer decided to prepare a problem for April Fools Day contest. The task was very simple - given an arithmetic expression, return the result of evaluating this expression. However, looks like there is a bug in the reference solution...\n\n\n-----Input-----\n\nThe only... | [{"input": "255+255+255+255+255+255+255+255+255+255\n", "output": "-42450\n"}, {"input": "101+200+195+231+107+222+146+254+160+209\n", "output": "-43175\n"}, {"input": "101+200+195+231+107+222+146+254+160+209\n", "output": "-43175\n"}, {"input": "255+255+255+255+255+255+255+255+255+255\n", "output": "-42450\n"}, {"input... | code_stdio |
[
{
"content": "Recently Lynyrd and Skynyrd went to a shop where Lynyrd bought a permutation p of length n, and Skynyrd bought an array a of length m, consisting of integers from 1 to n. \n\nLynyrd and Skynyrd became bored, so they asked you q queries, each of which has the following form: \"does the subsegment o... | [{"input": "3 6 3\n2 1 3\n1 2 3 1 2 3\n1 6\n2 6\n3 5\n", "output": "110\n"}, {"input": "3 6 3\n2 1 3\n1 2 3 2 2 3\n1 5\n2 6\n3 5\n", "output": "100\n"}, {"input": "3 6 3\n2 1 3\n2 2 3 1 2 3\n1 6\n2 6\n3 5\n", "output": "110\n"}, {"input": "3 6 3\n2 1 3\n1 2 1 1 2 3\n1 5\n2 6\n3 5\n", "output": "010\n"}, {"input": "3 6 ... | code_stdio |
[
{
"content": "Petya and Vasya are tossing a coin. Their friend Valera is appointed as a judge. The game is very simple. First Vasya tosses a coin x times, then Petya tosses a coin y times. If the tossing player gets head, he scores one point. If he gets tail, nobody gets any points. The winner is the player wit... | [{"input": "100 100 1 1\n", "output": "4950\n2 1\n3 1\n3 2\n4 1\n4 2\n4 3\n5 1\n5 2\n5 3\n5 4\n6 1\n6 2\n6 3\n6 4\n6 5\n7 1\n7 2\n7 3\n7 4\n7 5\n7 6\n8 1\n8 2\n8 3\n8 4\n8 5\n8 6\n8 7\n9 1\n9 2\n9 3\n9 4\n9 5\n9 6\n9 7\n9 8\n10 1\n10 2\n10 3\n10 4\n10 5\n10 6\n10 7\n10 8\n10 9\n11 1\n11 2\n11 3\n11 4\n11 5\n11 6\n11 7\... | code_stdio |
[
{
"content": "You are given an array of N integers a1, a2, ..., aN and an integer K. Find the number of such unordered pairs {i, j} that \n\n- i β j\n- |ai + aj - K| is minimal possible\n\nOutput the minimal possible value of |ai + aj - K| (where i β j) and the number of such pairs for the given array and the ... | [{"input": "1 \n4 192\n14 -1 2 8", "output": "170 1\n"}, {"input": "1 \n4 279\n14 -1 2 8", "output": "257 1\n"}, {"input": "1 \n4 107\n1 -1 -1 2", "output": "104 1\n"}, {"input": "1 \n4 253\n14 -1 2 8", "output": "231 1\n"}, {"input": "1 \n4 51\n0 -1 -1 13", "output": "38 1\n"}, {"input": "1 \n4 51\n-1 -1 -... | code_stdio |
[
{
"content": "Ksusha the Squirrel is standing at the beginning of a straight road, divided into n sectors. The sectors are numbered 1 to n, from left to right. Initially, Ksusha stands in sector 1. \n\nKsusha wants to walk to the end of the road, that is, get to sector n. Unfortunately, there are some rocks on ... | [{"input": "10 3\n..........\n", "output": "YES\n"}, {"input": "10 3\n..........\n", "output": "YES\n"}, {"input": "10 1\n..........\n", "output": "YES\n"}, {"input": "10 4\n..........\n", "output": "YES\n"}, {"input": "10 2\n..........\n", "output": "YES\n"}, {"input": "8 2\n..........\n", "output": "YES\n"}, {"input"... | code_stdio |
[
{
"content": "Vasya has a sequence a consisting of n integers a_1, a_2, ..., a_n. Vasya may pefrom the following operation: choose some number from the sequence and swap any pair of bits in its binary representation. For example, Vasya can transform number 6 (... 00000000110_2) into 3 (... 00000000011_2), 12 (.... | [{"input": "5\n1000000000000000000 352839520853234088 165431853141398699 753467583475385837 895062156280564685\n", "output": "4\n"}, {"input": "5\n1000000000000000000 352839520853234088 257894004782222768 753467583475385837 895062156280564685\n", "output": "4\n"}, {"input": "5\n1000000000000000000 352839520853234088 17... | code_stdio |
[
{
"content": "Please notice the unusual memory limit of this problem.\n\nOrac likes games. Recently he came up with the new game, \"Game of Life\".\n\nYou should play this game on a black and white grid with n rows and m columns. Each cell is either black or white.\n\nFor each iteration of the game (the initial... | [{"input": "5 5 3\n01011\n10110\n01101\n11010\n00101\n2 1 -1\n1 2 3\n5 5 3\n", "output": "1\n0\n1\n"}, {"input": "5 5 3\n00011\n10110\n01101\n11010\n00101\n2 1 -1\n1 2 3\n5 5 3\n", "output": "1\n1\n1\n"}, {"input": "5 5 3\n01011\n10110\n01101\n11010\n10101\n2 1 4\n1 2 3\n5 5 3\n", "output": "1\n0\n1\n"}, {"input": "5 5... | code_stdio |
[
{
"content": "The only difference between the two versions is that this version asks the maximal possible answer.\n\nHomer likes arrays a lot. Today he is painting an array $a_1, a_2, \\dots, a_n$ with two kinds of colors, white and black. A painting assignment for $a_1, a_2, \\dots, a_n$ is described by an arr... | [{"input": "15\n3 5 2 5 3 2 2 5 5 4 5 5 1 3 1\n", "output": "14\n"}, {"input": "11\n2 3 10 3 3 8 9 2 11 10 3\n", "output": "11\n"}, {"input": "11\n10 5 8 8 2 7 9 3 5 1 10\n", "output": "11\n"}, {"input": "8\n1 2 4 1 4 5 4 4\n", "output": "8\n"}, {"input": "7\n1 1 2 2 3 3 3\n", "output": "6\n"}, {"input": "7\n1 2 3 4 5 ... | code_stdio |
[
{
"content": "Palindrome\n\nProblem Statement\n\nFind the number of palindromes closest to the integer n.\n\nNote that the non-negative integer x is the number of palindromes, which means that the character string in which x is expressed in decimal notation and the character string in which it is inverted are e... | [{"input": "4752", "output": "4774\n"}, {"input": "8517", "output": "8558\n"}, {"input": "3483", "output": "3443\n"}, {"input": "1868", "output": "1881\n"}, {"input": "2667", "output": "2662\n"}, {"input": "3332", "output": "3333\n"}, {"input": "4989", "output": "4994\n"}, {"input": "5975", "output": "5995\n"}, {"input... | code_stdio |
[
{
"content": "A and B are preparing themselves for programming contests.\n\nAn important part of preparing for a competition is sharing programming knowledge from the experienced members to those who are just beginning to deal with the contests. Therefore, during the next team training A decided to make teams s... | [{"input": "500000 500000\n", "output": "333333\n"}, {"input": "250000 500000\n", "output": "250000\n"}, {"input": "500000 250000\n", "output": "250000\n"}, {"input": "231646 398487\n", "output": "210044\n"}, {"input": "332019 281112\n", "output": "204377\n"}, {"input": "473686 122443\n", "output": "122443\n"}, {"input... | code_stdio |
[
{
"content": "As the first step in algebra, students learn quadratic formulas and their factorization. Often, the factorization is a severe burden for them. A large number of students cannot master the factorization; such students cannot be aware of the elegance of advanced algebra. It might be the case that th... | [{"input": "2 5 4\n1 0 1\n10 -7 -1\n2 0 -5\n0 0 0", "output": "Impossible\nImpossible\nImpossible\nImpossible\n"}, {"input": "4 5 2\n1 1 1\n11 -10 0\n1 0 -3\n0 0 0", "output": "Impossible\nImpossible\n11 -10 1 0\nImpossible\n"}, {"input": "4 5 4\n2 0 1\n10 -7 1\n1 -1 -1\n0 0 0", "output": "Impossible\nImpossible\n5 -1 ... | code_stdio |
[
{
"content": "Polycarp plays a well-known computer game (we won't mention its name). In this game, he can craft tools of two types β shovels and swords. To craft a shovel, Polycarp spends two sticks and one diamond; to craft a sword, Polycarp spends two diamonds and one stick.\n\nEach tool can be sold for exact... | [{"input": "4\n4 4\n1000000000 0\n12 15\n8 7\n", "output": "2\n0\n9\n5\n"}, {"input": "4\n4 4\n1010000000 0\n12 15\n8 7\n", "output": "2\n0\n9\n5\n"}, {"input": "4\n4 4\n1000000000 0\n7 15\n8 7\n", "output": "2\n0\n7\n5\n"}, {"input": "4\n4 4\n1000000000 0\n7 15\n8 7\n", "output": "2\n0\n7\n5\n"}, {"input": "1\n1319 17... | code_stdio |
[
{
"content": "Heidi has finally found the mythical Tree of Life β a legendary combinatorial structure which is said to contain a prophecy crucially needed to defeat the undead armies.\n\nOn the surface, the Tree of Life is just a regular undirected tree well-known from computer science. This means that it is a ... | [{"input": "10\n5 1\n1 2\n9 1\n10 8\n6 3\n8 5\n2 7\n2 3\n10 4\n", "output": "10\n"}, {"input": "10\n5 1\n1 2\n9 5\n10 5\n6 3\n8 10\n2 7\n2 3\n1 4\n", "output": "11\n"}, {"input": "10\n5 1\n1 2\n9 5\n10 5\n6 3\n8 10\n2 7\n1 3\n1 4\n", "output": "12\n"}, {"input": "10\n5 1\n1 2\n9 5\n10 5\n6 3\n8 10\n2 7\n1 3\n2 4\n", "o... | code_stdio |
[
{
"content": "A popular reality show is recruiting a new cast for the third season! $n$ candidates numbered from $1$ to $n$ have been interviewed. The candidate $i$ has aggressiveness level $l_i$, and recruiting this candidate will cost the show $s_i$ roubles.\n\nThe show host reviewes applications of all candi... | [{"input": "34 5\n2 2 5 4 3 1 3 5 3 1 3 1 3 5 5 2 1 3 3 3 1 1 1 4 5 1 3 2 5 5 2 1 2 2\n1357 797 4642 4072 3953 4020 207 344 1412 4061 400 214 708 389 567 3294 1336 3746 1513 3539 4220 4720 329 4516 1741 1744 2537 3963 4941 664 1169 4512 3358 4144\n-4668 -1085 109 -899 769 -1132 -2587 1503 760 -2869 4020 -3282 2208 -232... | code_stdio |
[
{
"content": "Polycarp plays a computer game (yet again). In this game, he fights monsters using magic spells.\n\nThere are two types of spells: fire spell of power $x$ deals $x$ damage to the monster, and lightning spell of power $y$ deals $y$ damage to the monster and doubles the damage of the next spell Poly... | [{"input": "6\n1 5\n0 10\n1 -5\n1 14\n1 11\n0 -10\n", "output": "5\n25\n10\n34\n59\n39\n"}, {"input": "6\n1 5\n0 10\n1 -5\n0 14\n1 11\n0 -10\n", "output": "5\n25\n10\n24\n49\n39\n"}, {"input": "6\n1 5\n0 10\n1 -5\n1 14\n1 16\n0 -10\n", "output": "5\n25\n10\n34\n66\n46\n"}, {"input": "6\n1 5\n0 10\n1 -5\n0 5\n1 11\n0 -1... | code_stdio |
[
{
"content": "Let's call an array good if there is an element in the array that equals to the sum of all other elements. For example, the array $a=[1, 3, 3, 7]$ is good because there is the element $a_4=7$ which equals to the sum $1 + 3 + 3$.\n\nYou are given an array $a$ consisting of $n$ integers. Your task i... | [{"input": "4\n500000 500000 1000000 1000000\n", "output": "2\n3 4 \n"}, {"input": "4\n500000 500000 1000000 1000000\n", "output": "2\n3 4\n"}, {"input": "4\n500000 251993 1000000 1000000\n", "output": "0\n\n"}, {"input": "6\n4 7 1 1 1 1\n", "output": "5\n2 3 4 5 6 \n"}, {"input": "4\n2 1000000 1000000 14\n", "output":... | code_stdio |
[
{
"content": "In Aizuwakamatsu Village, which is located far north of Aizuwakamatsu City, a bridge called \"Yabashi\" is the only way to move to the surrounding villages. Despite the large number of passers-by, the bridge is so old that it is almost broken.\n\n<image>\n\n\n\nYabashi is strong enough to withstan... | [{"input": "3\n125 -1 15\n108 12 25\n149 10 50\n3\n32 -1 10\n70 10 41\n22 67 84\n0", "output": "NG\nOK\n"}, {"input": "3\n125 -1 15\n108 8 25\n246 10 42\n3\n32 -1 10\n70 10 41\n22 67 129\n0", "output": "NG\nOK\n"}, {"input": "3\n125 -1 15\n108 7 25\n246 10 42\n3\n32 -1 10\n70 10 41\n22 67 129\n0", "output": "NG\nOK\n"}... | code_stdio |
[
{
"content": "Valera loves to participate in competitions. Especially in programming contests. Today he has participated in the contest with his team, consisting of n students (including Valera). This contest was an individual competition, so each student in the team solved problems individually.\n\nAfter the c... | [{"input": "1000 1000 1 1000 1000000 1000000\n", "output": "1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 ... | code_stdio |
[
{
"content": "We have weather records at AtCoder Town for some consecutive three days. A string of length 3, S, represents the records - if the i-th character is S, it means it was sunny on the i-th day; if that character is R, it means it was rainy on that day.\nFind the maximum number of consecutive rainy day... | [{"input": "RRS\n", "output": "2\n"}, {"input": "SSS\n", "output": "0\n"}, {"input": "RSR\n", "output": "1\n"}, {"input": "SRS\n", "output": "1\n"}, {"input": "SSR\n", "output": "1\n"}, {"input": "RRR\n", "output": "3\n"}, {"input": "RSS\n", "output": "1\n"}, {"input": "SRR\n", "output": "2\n"}, {"input": "SRR", "outpu... | code_stdio |
[
{
"content": "You are given a marine area map that is a mesh of squares, each representing either a land or sea area. Figure B-1 is an example of a map.\n\n<image>\nFigure B-1: A marine area map\n\nYou can walk from a square land area to another if they are horizontally, vertically, or diagonally adjacent to ea... | [{"input": "1 1\n0\n2 1\n0 1\n1 0\n3 2\n1 1 1\n1 1 1\n5 4\n1 0 1 0 0\n1 -1 1 0 0\n1 1 1 0 1\n1 0 0 1 0\n5 4\n1 1 1 0 2\n1 0 1 0 1\n0 0 1 0 1\n2 0 1 1 1\n5 5\n1 0 1 0 1\n0 0 1 0 0\n1 1 1 0 1\n0 0 1 0 0\n1 0 0 1 1\n0 0", "output": "0\n1\n0\n1\n1\n1\n5\n"}, {"input": "1 1\n0\n2 1\n0 1\n1 0\n3 2\n1 1 1\n1 1 1\n5 4\n1 0 1 0... | code_stdio |
[
{
"content": "Vova again tries to play some computer card game.\n\nThe rules of deck creation in this game are simple. Vova is given an existing deck of n cards and a magic number k. The order of the cards in the deck is fixed. Each card has a number written on it; number a_{i} is written on the i-th card in th... | [{"input": "100 72\n8 8 7 9 6 1 4 5 3 7 5 10 5 4 1 3 4 1 3 1 6 6 4 5 4 5 6 1 10 7 9 1 6 10 6 6 9 3 3 4 5 9 4 9 8 1 5 9 3 7 1 8 5 2 1 1 7 7 7 6 6 4 2 9 10 2 8 3 1 1 4 8 5 9 7 10 9 4 2 3 7 7 6 7 8 5 1 3 8 5 1 8 9 10 3 7 1 8 10 5\n", "output": "4549\n"}, {"input": "100 72\n8 8 7 9 6 1 4 5 3 7 5 10 5 4 1 3 4 1 3 1 6 6 4 5 ... | code_stdio |
[
{
"content": "The beauty of a sequence a of length n is defined as a_1 \\oplus \\cdots \\oplus a_n, where \\oplus denotes the bitwise exclusive or (XOR).\n\nYou are given a sequence A of length N. Snuke will insert zero or more partitions in A to divide it into some number of non-empty contiguous subsequences.\... | [{"input": "32\n0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 0 0 1 1 0 0", "output": "268435465\n"}, {"input": "32\n0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 1 0 0", "output": "33554438\n"}, {"input": "32\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", "output": "147483634"}, {... | code_stdio |
[
{
"content": "On a circle lie $2n$ distinct points, with the following property: however you choose $3$ chords that connect $3$ disjoint pairs of points, no point strictly inside the circle belongs to all $3$ chords. The points are numbered $1, \\, 2, \\, \\dots, \\, 2n$ in clockwise order.\n\nInitially, $k$ ch... | [{"input": "4\n6 2\n8 2\n1 4\n1 1\n2 1\n2 0\n10 2\n14 12\n4 20\n9 10\n13 18\n30 18\n11 7\n", "output": "12\n0\n1\n32\n"}, {"input": "4\n5 2\n8 2\n1 4\n1 1\n2 1\n2 0\n15 1\n13 12\n4 20\n9 10\n13 18\n30 18\n13 12\n", "output": "7\n0\n1\n91\n"}, {"input": "4\n7 2\n14 2\n1 4\n1 1\n2 1\n0 0\n10 6\n19 2\n3 20\n8 10\n16 18\n1... | code_stdio |
[
{
"content": "You are given a string s consisting only of characters 0 and 1. A substring [l, r] of s is a string s_{l}s_{l} + 1s_{l} + 2... s_{r}, and its length equals to r - l + 1. A substring is called balanced if the number of zeroes (0) equals to the number of ones in this substring.\n\nYou have to determ... | [{"input": "65\n11001000110001001011011110111100000000101001001010101111000100010\n", "output": "48\n"}, {"input": "65\n11001000110001001011011110111100000000101001001010101111000100010\n", "output": "48\n"}, {"input": "65\n11001000110101001011011110111100000000101001001010101111000100010\n", "output": "56\n"}, {"input... | code_stdio |
[
{
"content": "There is a square matrix n Γ n, consisting of non-negative integer numbers. You should find such a way on it that \n\n * starts in the upper left cell of the matrix; \n * each following cell is to the right or down from the current cell; \n * the way ends in the bottom right cell. \n\n\n\nMoreo... | [{"input": "10\n10 8 6 5 9 8 2 5 3 2\n3 1 8 10 8 10 5 10 7 8\n5 9 7 7 4 9 7 2 5 2\n5 9 9 5 4 2 6 6 8 1\n10 6 9 9 10 5 6 3 5 9\n6 7 10 3 1 4 3 6 7 6\n10 10 4 7 4 4 8 2 7 4\n10 5 8 2 2 7 4 4 1 4\n8 4 6 10 10 6 1 3 3 1\n9 9 7 2 11 5 1 8 6 3\n", "output": "1\nDRDDDRRDDDRRDRDRRR\n"}, {"input": "10\n10 8 6 5 9 8 2 5 3 2\n3 1... | code_stdio |
[
{
"content": "Pavel made a photo of his favourite stars in the sky. His camera takes a photo of all points of the sky that belong to some rectangle with sides parallel to the coordinate axes.\n\nStrictly speaking, it makes a photo of all points with coordinates $(x, y)$, such that $x_1 \\leq x \\leq x_2$ and $y... | [{"input": "2\n282238675 111160538 526707498 169652181\n", "output": "14299383119546189\n"}, {"input": "2\n229872385 40870434 715428884 160550871\n", "output": "46761413035493300\n"}, {"input": "2\n186213023 111160538 526707498 169652181\n", "output": "6881807548140320\n"}, {"input": "2\n229872385 25548581 715428884 16... | code_stdio |
[
{
"content": "In fact, the problems E1 and E2 do not have much in common. You should probably think of them as two separate problems.\n\nYou are given an integer array $a[1 \\ldots n] = [a_1, a_2, \\ldots, a_n]$.\n\nLet us consider an empty deque (double-ended queue). A deque is a data structure that supports a... | [{"input": "6\n4\n2 11 8 -1\n3\n10 2 1\n3\n3 10 2\n4\n1 2 1 -1\n4\n4 0 1 6\n5\n1 5 1 -1 0\n", "output": "1\n0\n0\n0\n1\n1\n"}, {"input": "6\n4\n2 11 8 -1\n3\n10 2 1\n3\n5 10 2\n4\n1 2 1 -1\n4\n1 0 1 6\n5\n1 5 1 -1 0\n", "output": "1\n0\n0\n0\n0\n1\n"}, {"input": "6\n4\n3 7 8 15\n3\n3 2 1\n3\n3 0 0\n4\n-1 2 1 -1\n4\n2 1... | code_stdio |
[
{
"content": "Hiroshi:? D-C'KOPUA\n\nPeter: What's wrong, Dr. David? I'm used to shouting something I don't understand, but I'm not even writing it today.\n\nHiroshi: Here.\n\n<image>\n\n\nPeter: What? This table ... oh, there was something like this in the qualifying question. Replacing characters using a tabl... | [{"input": "?DKC'-OPUB", "output": "PES WP E EIERD\n"}, {"input": "?DKC'-OPUA", "output": "PES WP E EIER\n"}, {"input": ".UPDL'BCN?", "output": "EP.PD IP?DSPP\n"}, {"input": ".UQDL'BCN?", "output": "EPF'K PEWLEPP\n"}, {"input": "?NDBULDQ'.", "output": "PEERED DKT,EE\n"}, {"input": ".'QDLUBDN?", "output": "EPPHD IHLKEPP... | code_stdio |
[
{
"content": "Letβs try a dice puzzle. The rules of this puzzle are as follows.\n\n1. Dice with six faces as shown in Figure 1 are used in the puzzle.\n\n<image>\n\nFigure 1: Faces of a die\n\n2. With twenty seven such dice, a 3 Γ 3 Γ 3 cube is built as shown in Figure 2.\n\n<image>\n\nFigure 2: 3 Γ 3 Γ 3 cube\... | [{"input": "4\n0 0 1\n0 1 0\n0 2 2\n0 2 2\n1 2 2\n6 -1 0\n0 7 4\n0 4 1\n4 1 0\n6 1 0\n12 -1 0\n4 1 -2\n1 -1 0\n1 2 0\n0 -1 -1\n5 1 2\n10 0 2\n-2 1 -2\n3 -1 -1\n-1 6 -2\n0 0 -1\n0 1 0\n-2 1 0\n3 0 0", "output": "0\n0\n0\n0\n"}, {"input": "4\n0 0 1\n0 1 0\n0 2 2\n0 2 2\n1 2 2\n6 -1 0\n0 7 4\n0 4 1\n4 1 0\n6 1 0\n12 -2 0\... | code_stdio |
[
{
"content": "Polycarp has spent the entire day preparing problems for you. Now he has to sleep for at least $a$ minutes to feel refreshed.\n\nPolycarp can only wake up by hearing the sound of his alarm. So he has just fallen asleep and his first alarm goes off in $b$ minutes.\n\nEvery time Polycarp wakes up, h... | [{"input": "7\n10 3 6 4\n11 3 6 4\n5 9 4 10\n6 5 2 3\n1 1 1 1\n3947465 47342 338129 123123\n234123843 13 361451236 361451000\n", "output": "27\n27\n9\n-1\n1\n6471793\n358578060125049\n"}, {"input": "7\n10 3 6 4\n11 3 6 0\n5 9 4 10\n6 5 2 3\n1 1 1 1\n3947465 47342 338129 123123\n234123843 13 361451236 361451000\n", "out... | code_stdio |
[
{
"content": "Takahashi and Aoki will play a game. They will repeatedly play it until one of them have N wins in total.\n\nWhen they play the game once, Takahashi wins with probability A %, Aoki wins with probability B %, and the game ends in a draw (that is, nobody wins) with probability C %. Find the expected... | [{"input": "100001 31 41 28", "output": "904789367\n"}, {"input": "000001 31 41 28", "output": "388888893\n"}, {"input": "000011 31 41 28", "output": "339871354\n"}, {"input": "010001 31 41 28", "output": "24577229\n"}, {"input": "100000 31 41 28", "output": "104136146"}, {"input": "14 110 0 -10", "output": "545454562\... | code_stdio |
[
{
"content": "You are given three strings $a$, $b$ and $c$ of the same length $n$. The strings consist of lowercase English letters only. The $i$-th letter of $a$ is $a_i$, the $i$-th letter of $b$ is $b_i$, the $i$-th letter of $c$ is $c_i$.\n\nFor every $i$ ($1 \\leq i \\leq n$) you must swap (i.e. exchange) ... | [{"input": "4\naaa\nbbb\nccc\nabc\nbca\nbca\naabb\nbbaa\nbaba\nimi\nmii\niim\n", "output": "NO\nYES\nYES\nNO\n"}, {"input": "4\naaa\nbbb\nccc\nabc\nbca\ncca\naabb\nbbaa\nbaba\niim\nmii\niim\n", "output": "NO\nNO\nYES\nYES\n"}, {"input": "4\naa`\ncbc\ncac\ncba\naca\ncca\nbaab\nbdaa\nabab\niil\nmih\nimj\n", "output": "YE... | code_stdio |
[
{
"content": "Palo Alto is an unusual city because it is an endless coordinate line. It is also known for the office of Lyft Level 5.\n\nLyft has become so popular so that it is now used by all $m$ taxi drivers in the city, who every day transport the rest of the city residentsΒ β $n$ riders.\n\nEach resident (i... | [{"input": "1 4\n2 4 6 10 15\n1 1 1 1 0\n", "output": "0 0 0 1 "}, {"input": "1 4\n2 4 6 10 14\n1 1 1 1 0\n", "output": "0 0 0 1\n"}, {"input": "1 4\n3 4 6 10 15\n1 1 1 1 0\n", "output": "0 0 0 1\n"}, {"input": "1 4\n2 4 6 10 27\n1 1 1 1 0\n", "output": "0 0 0 1\n"}, {"input": "1 4\n2 4 6 10 15\n1 1 1 1 0\n", "output":... | code_stdio |
[
{
"content": "There is a sequence of length N: A_1, A_2, ..., A_N. Initially, this sequence is a permutation of 1, 2, ..., N.\n\nOn this sequence, Snuke can perform the following operation:\n\n* Choose K consecutive elements in the sequence. Then, replace the value of each chosen element with the minimum value ... | [{"input": "128 2\n35 6 2 5 0 4 2 5", "output": "127\n"}, {"input": "163 2\n35 6 2 5 0 4 2 5", "output": "162\n"}, {"input": "128 6\n35 6 2 5 0 5 2 5", "output": "26\n"}, {"input": "8 3\n14 3 1 8 4 6 2 5", "output": "4\n"}, {"input": "8 2\n14 5 1 4 2 6 2 5", "output": "7\n"}, {"input": "8 3\n14 5 1 8 4 6 2 5", "output"... | code_stdio |
[
{
"content": "Do you know Just Odd Inventions? The business of this company is to \"just odd inventions\". Here, it is abbreviated as JOI.\n\nJOI is conducting research to confine many microorganisms in one petri dish alive. There are N microorganisms to be investigated, and they are numbered 1, 2, ..., N. When... | [{"input": "6\n12 13\n5 9\n2 4\n10 12\n6 12\n6 11", "output": "5\n"}, {"input": "6\n12 38\n5 9\n2 4\n10 12\n6 12\n11 9", "output": "5\n"}, {"input": "6\n12 13\n5 9\n2 2\n10 12\n6 12\n6 11", "output": "5\n"}, {"input": "6\n12 38\n5 9\n0 4\n10 12\n6 12\n11 9", "output": "5\n"}, {"input": "6\n12 9\n5 9\n2 4\n10 12\n10 12\... | code_stdio |
[
{
"content": "Peter wrote on the board a strictly increasing sequence of positive integers a_1, a_2, ..., a_{n}. Then Vasil replaced some digits in the numbers of this sequence by question marks. Thus, each question mark corresponds to exactly one lost digit.\n\nRestore the the original sequence knowing digits ... | [{"input": "98\n?\n?0\n2?\n6?\n6?\n69\n??\n??\n96\n1?2\n??3\n104\n??4\n1?9\n??2\n18?\n?01\n205\n?19\n244\n??8\n?5?\n?5?\n276\n??3\n???\n???\n?28\n?3?\n3??\n??8\n355\n4?0\n4??\n?10\n??1\n417\n4?9\n?3?\n4?4\n?61\n?8?\n???\n507\n?2?\n???\n??6\n5?7\n540\n5?9\n???\n?7?\n5??\n591\n?9?\n6?0\n620\n??4\n??1\n?35\n65?\n65?\n6?8\... | code_stdio |
[
{
"content": "Example\n\nInput\n\n3\n\n\nOutput\n\n1\n\nWrite Python code to solve this problem. Your program should read the input from stdin and write the output to stdout. Enclose your complete solution in a single ```python code block.",
"role": "user"
}
] | [{"input": "20093", "output": "276\n"}, {"input": "5663", "output": "100\n"}, {"input": "1761", "output": "292\n"}, {"input": "2283", "output": "36\n"}, {"input": "1253", "output": "88\n"}, {"input": "1203", "output": "20\n"}, {"input": "1457", "output": "44\n"}, {"input": "2031", "output": "78\n"}, {"input": "2941", "... | code_stdio |
[
{
"content": "You're given an array $a$ of $n$ integers, such that $a_1 + a_2 + \\cdots + a_n = 0$.\n\nIn one operation, you can choose two different indices $i$ and $j$ ($1 \\le i, j \\le n$), decrement $a_i$ by one and increment $a_j$ by one. If $i < j$ this operation is free, otherwise it costs one coin.\n\n... | [{"input": "7\n4\n-3 5 -3 1\n2\n1 -1\n4\n-3 2 -3 4\n4\n-1 1 1 -1\n7\n-5 7 -6 -4 17 -13 4\n6\n-1000000000 -1000000000 -1000000000 1000000000 1000000000 1000000000\n1\n0\n", "output": "3\n0\n4\n1\n8\n3000000000\n0\n"}, {"input": "7\n4\n-3 5 -3 1\n2\n1 -1\n4\n-3 2 -3 4\n4\n-1 1 1 -1\n7\n-5 7 -6 -4 17 -13 4\n6\n-1000000000... | code_stdio |
[
{
"content": "problem\n\nCryptography is all the rage at xryuseix's school. Xryuseix, who lives in a grid of cities, has come up with a new cryptography to decide where to meet.\n\nThe ciphertext consists of the $ N $ character string $ S $, and the $ S_i $ character determines the direction of movement from th... | [{"input": "5\nAMazA", "output": "3\nAAA\n"}, {"input": "5\nAMAza", "output": "3\nAAA\n"}, {"input": "5\nAMBza", "output": "3\nAAA\n"}, {"input": "5\nAaBzM", "output": "3\nAAA\n"}, {"input": "5\nAazBM", "output": "3\nAAA\n"}, {"input": "5\nazAMA", "output": "3\nAAA\n"}, {"input": "5\nALBza", "output": "3\nAAA\n"}, {"in... | code_stdio |
[
{
"content": "Pinkie Pie has bought a bag of patty-cakes with different fillings! But it appeared that not all patty-cakes differ from one another with filling. In other words, the bag contains some patty-cakes with the same filling.\n\nPinkie Pie eats the patty-cakes one-by-one. She likes having fun so she dec... | [{"input": "4\n7\n1 7 1 6 4 4 6\n8\n1 1 4 6 4 6 4 7\n3\n3 3 3\n6\n2 5 2 3 1 4\n", "output": "3\n2\n0\n4\n"}, {"input": "4\n7\n1 7 1 6 4 7 6\n8\n1 1 4 6 4 6 4 7\n3\n3 3 3\n6\n2 5 2 3 1 4\n", "output": "3\n2\n0\n4\n"}, {"input": "4\n7\n1 7 1 6 4 7 6\n8\n1 1 4 6 4 6 4 7\n3\n3 3 1\n6\n2 5 2 3 1 4\n", "output": "3\n2\n1\n4\... | code_stdio |
[
{
"content": "At the foot of Liyushan Mountain, n tents will be carefully arranged to provide accommodation for those who are willing to experience the joy of approaching nature, the tranquility of the night, and the bright starry sky.\n\nThe i-th tent is located at the point of (x_i, y_i) and has a weight of w... | [{"input": "10\n-535541974 -572774963 229181417\n-535541973 -590337106 348212269\n-535541972 -572774962 413415882\n-535541973 -717839722 657120913\n-535541975 -572774961 155042637\n-535541975 -706888442 81575270\n-535541971 -572774961 888834471\n-535541974 -721151373 899782743\n-535541971 -1600858205 614959267\n-535541... | code_stdio |
[
{
"content": "Recall that a binary search tree is a rooted binary tree, whose nodes each store a key and each have at most two distinguished subtrees, left and right. The key in each node must be greater than any key stored in the left subtree, and less than any key stored in the right subtree.\n\nThe depth of ... | [{"input": "1000000\n", "output": "0\n"}, {"input": "360561\n", "output": "0\n"}, {"input": "699049\n", "output": "1\n"}, {"input": "699047\n", "output": "0\n"}, {"input": "699050\n", "output": "1\n"}, {"input": "699048\n", "output": "0\n"}, {"input": "786432\n", "output": "0\n"}, {"input": "750096\n", "output": "0\n"}... | code_stdio |
[
{
"content": "This is an interactive problem. Refer to the Interaction section below for better understanding.\n\nIthea and Chtholly want to play a game in order to determine who can use the kitchen tonight.\n\n<image>\n\nInitially, Ithea puts n clear sheets of paper in a line. They are numbered from 1 to n fro... | [{"input": "10 120 15\n6\n11\n9\n11\n3\n12\n11\n12\n2\n8\n3\n11\n13\n5\n12\n11\n9\n3\n10\n9\n9\n13\n13\n5\n6\n11\n3\n15\n8\n8\n10\n13\n7\n6\n4\n14\n9\n10\n5\n13\n4\n1\n8\n6\n13\n1\n3\n4\n9\n12\n2\n7\n3\n3\n7\n2\n2\n9\n2\n4\n2\n2\n11\n12\n15\n13\n6\n2\n11\n1\n8\n3\n13\n6\n15\n6\n4\n3\n4\n15\n15\n9\n5\n8\n3\n6\n14\n14\n5... | code_stdio |
[
{
"content": "In Finite Encyclopedia of Integer Sequences (FEIS), all integer sequences of lengths between 1 and N (inclusive) consisting of integers between 1 and K (inclusive) are listed.\nLet the total number of sequences listed in FEIS be X. Among those sequences, find the (X/2)-th (rounded up to the neares... | [{"input": "0 39", "output": "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\n"}, {"input": "0 28", "output": "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\n"}, {"input": "13 27", "output": "7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 6 8\n"}, {"input": "2 27", "output": ... | code_stdio |
[
{
"content": "William has a favorite bracket sequence. Since his favorite sequence is quite big he provided it to you as a sequence of positive integers $c_1, c_2, \\dots, c_n$ where $c_i$ is the number of consecutive brackets \"(\" if $i$ is an odd number or the number of consecutive brackets \")\" if $i$ is a... | [{"input": "50\n980145241 167620437 937571657 683888733 687342940 596264451 470954757 312707590 782743417 441517678 539214535 498906886 521201165 581866343 987986939 770597138 136540061 812371324 567649512 704604401 873600670 364129557 600605741 459396557 173915633 607977424 480952533 834953681 878054436 827935116 4130... | code_stdio |
[
{
"content": "A recently found Ancient Prophesy is believed to contain the exact Apocalypse date. The prophesy is a string that only consists of digits and characters \"-\".\n\nWe'll say that some date is mentioned in the Prophesy if there is a substring in the Prophesy that is the date's record in the format \... | [{"input": "12-12-201312-12-201312-12-201313--12-201313--12-201313--12-201313--12-201313--12-201313--12-201313--12-201313--12-2013\n", "output": "12-12-2013\n"}, {"input": "12-12-211312-12-201312-12-201313--12-201313--02-201313--12-201313--12-201313--12-201313--12-201313--12-201313--12-2013\n", "output": "12-12-2013\n"... | code_stdio |
[
{
"content": "In some game by Playrix it takes t minutes for an oven to bake k carrot cakes, all cakes are ready at the same moment t minutes after they started baking. Arkady needs at least n cakes to complete a task, but he currently don't have any. However, he has infinitely many ingredients and one oven. Mo... | [{"input": "1000 1000 1000 1000\n", "output": "NO\n"}, {"input": "1000 1000 1000 1000\n", "output": "NO\n"}, {"input": "1000 1000 1001 1000\n", "output": "NO\n"}, {"input": "1000 1000 1 1000\n", "output": "YES\n"}, {"input": "1000 1000 1 1000\n", "output": "YES\n"}, {"input": "1000 1001 1 1000\n", "output": "YES\n"}, {... | code_stdio |
[
{
"content": "β Oh my sweet Beaverette, would you fancy a walk along a wonderful woodland belt with me? \n\nβ Of course, my Smart Beaver! Let us enjoy the splendid view together. How about Friday night? \n\nAt this point the Smart Beaver got rushing. Everything should be perfect by Friday, so he needed to prepa... | [{"input": "20\n-808998072 733614990 579897311 -337992089 579897311 120800519 -337992089 -354825441 733614990 -686536765 733614990 -803027570 -803027570 733614990 120800519 -1246630624 -686536765 579897311 -808998072 -686536765\n", "output": "4215055101 13\n1 4 7 8 10 12 13 15 16 17 18 19 20\n"}, {"input": "20\n-808998... | code_stdio |
[
{
"content": "Little chief has his own restaurant in the city. There are N workers there. Each worker has his own salary. The salary of the i-th worker equals to W_{i} (i = 1, 2, ..., N). Once, chief decided to equalize all workers, that is, he wants to make salaries of all workers to be equal. But for this goa... | [{"input": "2\n3\n0 -2 -1\n2\n75 42", "output": "3\n33\n"}, {"input": "2\n3\n0 -3 -1\n2\n75 42", "output": "5\n33\n"}, {"input": "2\n3\n1 -2 -1\n2\n60 42", "output": "4\n18\n"}, {"input": "2\n3\n0 -3 -1\n2\n75 16", "output": "5\n59\n"}, {"input": "2\n3\n1 -4 -1\n2\n75 42", "output": "8\n33\n"}, {"input": "2\n3\n0 -2 0\... | code_stdio |
[
{
"content": "Takahashi and Aoki are playing a stone-taking game. Initially, there are N piles of stones, and the i-th pile contains A_i stones and has an associated integer K_i.\nStarting from Takahashi, Takahashi and Aoki take alternate turns to perform the following operation:\n - Choose a pile. If the i-th ... | [{"input": "200\n48018902 1000000000\n671608134 1000000000\n821230959 1000000000\n839046240 1000000000\n871451860 1000000000\n201326387 1000000000\n95653264 1000000000\n118998199 1000000000\n661381768 1000000000\n265950246 1000000000\n443323091 1000000000\n621558889 1000000000\n486583499 1000000000\n185518031 100000000... | code_stdio |
[
{
"content": "The research center Q has developed a new multi-core processor. The processor consists of n cores and has k cells of cache memory. Consider the work of this processor.\n\nAt each cycle each core of the processor gets one instruction: either do nothing, or the number of the memory cell (the core wi... | [{"input": "100 1 100\n59\n37\n53\n72\n37\n15\n8\n93\n92\n74\n11\n11\n68\n16\n92\n40\n76\n20\n10\n86\n76\n5\n9\n95\n5\n81\n44\n57\n10\n24\n22\n2\n57\n6\n26\n67\n48\n95\n34\n97\n55\n33\n70\n66\n51\n70\n74\n65\n35\n85\n37\n9\n27\n43\n65\n6\n5\n57\n54\n27\n22\n41\n8\n29\n10\n50\n9\n68\n78\n9\n92\n30\n88\n62\n30\n5\n80\n58... | code_stdio |
[
{
"content": "Read problems statements in Mandarin Chinese, Russian and Vietnamese as well. \nLittle Egor likes to play with positive integers and their divisors. Bigger the number to play with, more the fun! The boy asked you to come up with an algorithm, that could play the following game: \nLet's define f(n)... | [{"input": "2\n1 18\n76 209", "output": "139\n15682\n"}, {"input": "2\n1 16\n76 209", "output": "108\n15682\n"}, {"input": "2\n1 7\n114 127", "output": "25\n1447\n"}, {"input": "2\n1 7\n76 209", "output": "25\n15682\n"}, {"input": "2\n1 9\n76 209", "output": "39\n15682\n"}, {"input": "2\n2 18\n42 82", "output": "138\n2... | code_stdio |
[
{
"content": "You are given a string S of length N consisting of A, B and C, and an integer K which is between 1 and N (inclusive).\nPrint the string S after lowercasing the K-th character in it.\n\n-----Constraints-----\n - 1 β€ N β€ 50\n - 1 β€ K β€ N\n - S is a string of length N consisting of A, B and C.\n\n---... | [{"input": "50 27\nACBCABCCCAACACCBBBACCBCBBBCCBAAAABAACACAAACCACCCCA\n", "output": "ACBCABCCCAACACCBBBACCBCBBBcCBAAAABAACACAAACCACCCCA\n"}, {"input": "50 50\nCABABCBBCBABCAACBCBBAAAACBCBCBBABBABBBCCBAACCAACAB\n", "output": "CABABCBBCBABCAACBCBBAAAACBCBCBBABBABBBCCBAACCAACAb\n"}, {"input": "40 38\nBCCACCBCACABBBBBCBABC... | code_stdio |
[
{
"content": "problem\n\nIn the area where Kazakhstan is now located, there used to be a trade route called the \"Silk Road\".\n\nThere are N + 1 cities on the Silk Road, numbered from west as city 0, city 1, ..., city N. The distance between city i -1 and city i (1 β€ i β€ N) is Di.\n\nJOI, a trader, decided to ... | [{"input": "3 5\n10\n25\n15\n50\n30\n15\n12\n30", "output": "855\n"}, {"input": "3 5\n10\n38\n18\n50\n30\n6\n40\n30", "output": "1068\n"}, {"input": "3 5\n10\n38\n18\n50\n30\n6\n40\n34", "output": "1140\n"}, {"input": "3 5\n10\n38\n18\n50\n27\n6\n40\n34", "output": "1110\n"}, {"input": "3 5\n10\n38\n28\n50\n27\n6\n40\n... | code_stdio |
[
{
"content": "There was a big bank robbery in Tablecity. In order to catch the thief, the President called none other than Albert β Tablecityβs Chief of Police. Albert does not know where the thief is located, but he does know how he moves.\n\nTablecity can be represented as 1000 Γ 2 grid, where every cell repr... | [{"input": "\u0412 \u044d\u0442\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0435 \u043d\u0435\u0442 \u043f\u0440\u0438\u043c\u0435\u0440\u043e\u0432 \u0432\u0432\u043e\u0434\u0430-\u0432\u044b\u0432\u043e\u0434\u0430.\nThis problem doesn't have sample inout and output.", "output": "2000\n1 1 1 2\n2 1 2 2\n3 1 3 2\n4 1 ... | code_stdio |
[
{
"content": "Note that the memory limit is unusual.\n\nYou are given an integer n and two sequences a_1, a_2, ..., a_n and b_1, b_2, ..., b_n.\n\nLet's call a set of integers S such that S β \\{1, 2, 3, ..., n\\} strange, if, for every element i of S, the following condition is met: for every j β [1, i - 1], i... | [{"input": "20\n27 6 6 60 47 97 62 25 67 28 41 93 65 32 16 56 57 53 66 61\n84392 -11227 -93200 -52089 4854 -99982 -81560 95957 -35579 -91088 31023 -68447 -41338 -27132 43558 23876 35055 -36267 77633 -94930\n", "output": "294839\n"}, {"input": "20\n27 6 6 60 47 97 62 25 67 28 41 93 65 32 16 56 57 53 66 61\n84392 -11227 ... | code_stdio |
[
{
"content": "You are given a colored permutation $p_1, p_2, \\dots, p_n$. The $i$-th element of the permutation has color $c_i$.\n\nLet's define an infinite path as infinite sequence $i, p[i], p[p[i]], p[p[p[i]]] \\dots$ where all elements have same color ($c[i] = c[p[i]] = c[p[p[i]]] = \\dots$).\n\nWe can als... | [{"input": "3\n4\n1 3 4 2\n1 1 2 3\n5\n2 3 4 5 1\n1 2 5 10 3\n8\n7 4 5 6 1 8 3 2\n5 3 4 4 12 5 8 9\n", "output": "1\n5\n4\n"}, {"input": "3\n4\n1 3 4 2\n1 2 2 3\n5\n2 3 4 5 1\n1 2 10 4 5\n8\n7 4 5 6 1 8 3 2\n5 3 6 4 7 5 8 4\n", "output": "1\n5\n2\n"}, {"input": "3\n4\n1 3 4 2\n1 1 2 3\n5\n2 3 4 5 1\n1 2 5 10 4\n8\n7 4 ... | code_stdio |
[
{
"content": "Professor Vasechkin is studying evolution of worms. Recently he put forward hypotheses that all worms evolve by division. There are n forms of worms. Worms of these forms have lengths a1, a2, ..., an. To prove his theory, professor needs to find 3 different forms that the length of the first form ... | [{"input": "100\n804 510 266 304 788 178 862 888 408 82 414 470 777 991 729 229 1767 406 601 1 596 720 608 706 432 361 527 548 59 548 474 515 4 991 263 568 681 24 117 563 576 587 281 643 904 521 891 106 842 884 943 54 605 1567 504 757 311 374 335 192 447 652 633 410 455 402 382 150 432 836 413 819 669 875 638 925 217 8... | code_stdio |
[
{
"content": "Ichihime is the current priestess of the Mahjong Soul Temple. She claims to be human, despite her cat ears.\n\nThese days the temple is holding a math contest. Usually, Ichihime lacks interest in these things, but this time the prize for the winner is her favorite β cookies. Ichihime decides to at... | [{"input": "14\n2374453 2374454 8591131 23094546\n5813291 5813292 9709163 35032815\n4280399 23049698 23049701 34728360\n15184184 18688462 22400847 22400849\n24397371 31462070 33936330 33936331\n21376685 28241116 38909200 38909202\n29491847 31628480 31628482 45225214\n15144763 15414479 36902879 36902881\n36023581 388899... | code_stdio |
[
{
"content": "JAG mock qualifying practice session\n\nThe ACM-ICPC OB / OG Association (Japanese Alumni Group; JAG) has N questions in stock of questions to be asked in the mock contest, and each question is numbered with an integer from 1 to N. Difficulty evaluation and recommendation voting are conducted for ... | [{"input": "5 3\n1 1\n2 3\n3 2\n3 17\n2 1\n4 2\n1 7\n2 1\n1 3\n2 5\n6 1\n1 3\n1 2\n1 8\n1 2\n1 7\n1 6\n20 9\n4 10\n2 6\n8 3\n1 6\n6 3\n7 4\n8 10\n4 12\n7 5\n1 8\n5 7\n1 5\n4 6\n9 9\n5 8\n6 7\n1 4\n6 4\n7 10\n3 5\n19 6\n4 2\n6 5\n5 10\n1 10\n3 10\n3 6\n2 3\n1 4\n2 10\n1 8\n3 4\n3 1\n5 4\n1 10\n1 3\n5 10\n5 2\n1 10\n2 3\... | code_stdio |
[
{
"content": "Vasya wants to turn on Christmas lights consisting of m bulbs. Initially, all bulbs are turned off. There are n buttons, each of them is connected to some set of bulbs. Vasya can press any of these buttons. When the button is pressed, it turns on all the bulbs it's connected to. Can Vasya light up... | [{"input": "1 100\n100 1 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 88 89 90 91 92 93 94 95 96 97 98 99 100\n", "... | code_stdio |
[
{
"content": "Digory Kirke and Polly Plummer are two kids living next door to each other. The attics of the two houses are connected to each other through a passage. Digory's Uncle Andrew has been secretly doing strange things in the attic of his house, and he always ensures that the room is locked. Being curio... | [{"input": "4\n####\n#..#.##\n##..#.#\n##.#....#", "output": "0\n1\n1\n2\n"}, {"input": "4\n####\n#..#.##\n#.#..##\n##.#....#", "output": "0\n1\n2\n2\n"}, {"input": "4\n####\n##.#..#\n#.#..##\n##.#....#", "output": "0\n2\n2\n2\n"}, {"input": "4\n####\n##.#..#\n#.#..##\n#....#.##", "output": "0\n2\n2\n1\n"}, {"input": "... | code_stdio |
[
{
"content": "Ringo is giving a present to Snuke.\n\nRingo has found out that Snuke loves yakiniku (a Japanese term meaning grilled meat. yaki: grilled, niku: meat). He supposes that Snuke likes grilled things starting with `YAKI` in Japanese, and does not like other things.\n\nYou are given a string S represen... | [{"input": "UKINIKAY", "output": "No\n"}, {"input": "UAKOYAKI", "output": "No\n"}, {"input": "NKIUIKAY", "output": "No\n"}, {"input": "IKAYOKAU", "output": "No\n"}, {"input": "NKIUAKIY", "output": "No\n"}, {"input": "AAKOYUKI", "output": "No\n"}, {"input": "OKIUAKIY", "output": "No\n"}, {"input": "AAKPYUKI", "output": ... | code_stdio |
[
{
"content": "Write a program which reads two integers x and y, and prints them in ascending order.\n\nConstraints\n\n* 0 β€ x, y β€ 10000\n* the number of datasets β€ 3000\n\nInput\n\nThe input consists of multiple datasets. Each dataset consists of two integers x and y separated by a single space.\n\nThe input e... | [{"input": "3 0\n-1 2\n15 3\n0 0", "output": "0 3\n-1 2\n3 15\n"}, {"input": "3 -1\n0 2\n27 3\n0 0", "output": "-1 3\n0 2\n3 27\n"}, {"input": "4 -1\n0 2\n27 3\n0 0", "output": "-1 4\n0 2\n3 27\n"}, {"input": "4 -1\n0 2\n18 3\n0 0", "output": "-1 4\n0 2\n3 18\n"}, {"input": "4 -1\n0 2\n18 5\n0 0", "output": "-1 4\n0 2\... | code_stdio |
[
{
"content": "Today, Yasser and Adel are at the shop buying cupcakes. There are $n$ cupcake types, arranged from $1$ to $n$ on the shelf, and there are infinitely many of each type. The tastiness of a cupcake of type $i$ is an integer $a_i$. There are both tasty and nasty cupcakes, so the tastiness can be posit... | [{"input": "12\n3\n7 -4 5\n3\n7 -5 4\n3\n4 -5 7\n3\n5 -4 7\n4\n5 -5 -6 6\n5\n100 100 100 -50 50\n10\n11 5 -12 7 -10 20 30 -10 50 60\n10\n10 5 -14 7 -7 20 30 -50 50 60\n2\n1 1\n2\n-1 -1\n3\n1000000000 1010000000 1000000000\n3\n-1000000000 -1000000000 -1000000000\n", "output": "YES\nNO\nNO\nYES\nNO\nNO\nYES\nYES\nYES\nNO... | code_stdio |
[
{
"content": "Gildong was hiking a mountain, walking by millions of trees. Inspired by them, he suddenly came up with an interesting idea for trees in data structures: What if we add another edge in a tree?\n\nThen he found that such tree-like graphs are called 1-trees. Since Gildong was bored of solving too ma... | [{"input": "14\n4 9\n3 7\n4 1\n3 2\n14 9\n7 6\n10 13\n8 7\n5 7\n7 10\n1 3\n12 3\n7 11\n20\n13 6 14 9 1\n6 4 3 7 9\n9 3 6 13 7\n6 11 11 5 9\n14 5 2 3 4\n13 12 4 2 7\n13 14 7 3 2\n9 5 13 13 6\n8 9 7 3 7\n14 10 11 12 7\n6 12 13 1 1\n8 13 8 10 8\n1 5 13 10 7\n1 4 13 2 6\n1 5 6 4 10\n6 9 11 8 5\n9 7 14 7 9\n12 5 6 8 9\n14 1... | code_stdio |
[
{
"content": "Imagine a city with n horizontal streets crossing m vertical streets, forming an (n - 1) Γ (m - 1) grid. In order to increase the traffic flow, mayor of the city has decided to make each street one way. This means in each horizontal street, the traffic moves only from west to east or only from eas... | [{"input": "20 20\n><<><<<<<<<>>><>>><<\n^^^^^^^^vvvv^vv^vvvv\n", "output": "YES\n"}, {"input": "20 20\n<>>>>>>>><>>><>><<<>\nvv^^vv^^^^v^vv^v^^^^\n", "output": "YES\n"}, {"input": "20 20\n>>><<<<<>>><><><<><<\n^^^vvv^^^v^^v^^v^vvv\n", "output": "YES\n"}, {"input": "20 20\n<<><<<<<<>>>>><<<>>>\nvvvvvv^v^vvv^^^^^^^^\n",... | code_stdio |
[
{
"content": "When l is an odd number, the median of l numbers a_1, a_2, ..., a_l is the (\\frac{l+1}{2})-th largest value among a_1, a_2, ..., a_l.\n\nYou are given N numbers X_1, X_2, ..., X_N, where N is an even number. For each i = 1, 2, ..., N, let the median of X_1, X_2, ..., X_N excluding X_i, that is, t... | [{"input": "6\n5 -1 -1 -1 13 -1", "output": "-1\n-1\n-1\n-1\n-1\n-1\n"}, {"input": "6\n5 -1 -1 -1 13 0", "output": "-1\n0\n0\n0\n-1\n-1\n"}, {"input": "6\n5 -2 -1 0 15 -2", "output": "-1\n0\n0\n-1\n-1\n0\n"}, {"input": "6\n5 -2 -1 1 15 -2", "output": "-1\n1\n1\n-1\n-1\n1\n"}, {"input": "6\n4 4 -1 -1 4 -7", "output": "-... | code_stdio |
[
{
"content": "Childan is making up a legendary story and trying to sell his forgery β a necklace with a strong sense of \"Wu\" to the Kasouras. But Mr. Kasoura is challenging the truth of Childan's story. So he is going to ask a few questions about Childan's so-called \"personal treasure\" necklace.\n\nThis \"p... | [{"input": "12 1 1\n0 1 2 3 2 5 6 11 0 10 10 17\n001010001000\n001010001000 100\n", "output": "1\n"}, {"input": "12 1 1\n0 1 2 3 2 6 6 11 0 10 10 17\n001010001000\n001010001000 100\n", "output": "1\n"}, {"input": "12 1 1\n0 1 2 3 2 2 6 11 0 10 10 17\n001010001000\n001010001000 100\n", "output": "1\n"}, {"input": "12 1 ... | code_stdio |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.