messages
listlengths
1
1
ground_truth
stringlengths
156
726k
dataset
stringclasses
2 values
[ { "content": "You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\nLet's define `increasing` numbers as the numbers whose digits, read from left to right, are never less than t...
[{"input": "50", "output": "[87959698326]", "fn_name": "total_inc_dec"}, {"input": "20", "output": "[40059819]", "fn_name": "total_inc_dec"}, {"input": "10", "output": "[277033]", "fn_name": "total_inc_dec"}, {"input": "6", "output": "[12952]", "fn_name": "total_inc_dec"}, {"input": "4", "output": "[1675]", "fn_name": ...
code_functional
[ { "content": "You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\nRead problems statements in Mandarin Chinese and Russian as well. \n\nMike likes strings. He is also interest...
[{"input": "ABACABA\n", "output": "2\n"}, {"input": "ABBCABA", "output": "2\n"}, {"input": "ABABBBA", "output": "0\n"}, {"input": "@BABBBA", "output": "1\n"}, {"input": "@BABCBA", "output": "3\n"}, {"input": "AB@BCAB", "output": "4\n"}, {"input": "BCABACB", "output": "6\n"}, {"input": "ABCBACB", "output": "5\n"}, {"inp...
code_stdio
[ { "content": "You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\nTwo players decided to play one interesting card game.\n\nThere is a deck of $n$ cards, with values from $1$ ...
[{"input": "2\n2 1 1\n2\n-1\n5 2 3\n1 3\n2 11 5\n", "output": "YES\nNO\n"}, {"input": "2\n2 1 1\n2\n-1\n5 2 3\n2 3\n2 2 5\n", "output": "YES\nNO\n"}, {"input": "2\n2 1 1\n2\n1\n5 2 3\n2 3\n-1 6 5\n", "output": "YES\nNO\n"}, {"input": "2\n2 1 1\n2\n-1\n5 2 3\n2 3\n3 2 5\n", "output": "YES\nNO\n"}, {"input": "2\n2 1 1\n2...
code_stdio
[ { "content": "You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\nToday, Snuke will eat B pieces of black chocolate and W pieces of white chocolate for an afternoon snack.\n\n...
[{"input": "69 1", "output": "500000004\n750000006\n875000007\n437500004\n718750006\n859375007\n429687504\n714843756\n857421882\n928710945\n464355473\n232177737\n116088869\n58044435\n29022218\n514511113\n257255557\n128627779\n64313890\n532156949\n266078475\n133039238\n566519623\n283259812\n641629910\n820814959\n4104074...
code_stdio
[ { "content": "You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\nRead problems statements in Mandarin Chinese and Russian. \n\nRecently Chef has decided to make some changes...
[{"input": "3\n2\n0 4\n5\n0 2 10 2 3\n3\n1 1 1", "output": "4\n11\n1\n"}, {"input": "3\n2\n2 2\n5\n0 0 11 4 3\n3\n0 3 0", "output": "2\n11\n3\n"}, {"input": "3\n2\n0 2\n5\n1 2 12 2 3\n3\n1 0 1", "output": "2\n13\n2\n"}, {"input": "3\n2\n2 2\n5\n0 2 12 4 3\n3\n1 0 1", "output": "2\n12\n2\n"}, {"input": "3\n2\n3 12\n5\n0...
code_stdio
[ { "content": "You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\nExample\n\nInput\n\n3\naab\nczc\nbaa\n\n\nOutput\n\naac### Format: Read the inputs from stdin solve the probl...
[{"input": "3\naab\nccz\nbaa", "output": "aac\n"}, {"input": "3\nbba\nzcc\nbaa", "output": "aaz\n"}, {"input": "3\nabb\nzbc\nbaa", "output": "aab\n"}, {"input": "3\nbbb\nzcd\nbaa", "output": "abc\n"}, {"input": "3\nabb\ncyc\nbba", "output": "aay\n"}, {"input": "3\nbba\nzbc\nbba", "output": "abb\n"}, {"input": "3\nbbb\n...
code_stdio
[ { "content": "You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\nLet's call an array consisting of n integer numbers a_1, a_2, ..., a_{n}, beautiful if it has the following p...
[{"input": "58 38\n6384 48910\n97759 90589\n28947 5031\n45169 32592\n85656 26360\n88538 42484\n44042 88351\n42837 79021\n96022 59200\n485 96735\n98000 3939\n3789 64468\n10894 58484\n26422 26618\n25515 95617\n37452 5250\n39557 66304\n79009 40610\n80703 60486\n90344 37588\n57504 61201\n62619 79797\n51282 68799\n15158 276...
code_stdio
[ { "content": "You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\nA string S of an odd length is said to be a strong palindrome if and only if all of the following conditions ...
[{"input": "qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq\n", "output": "Yes\n"}, {"input": "kszhkbpphykinkezplvfjaqmpmqajfvlpzeknikyhppbkhzskokszhkbpphykinkezplvfjaqmpmqajfvlpzeknikyhppbkhzsk\n", "output": "Yes\n"}, {"input": "avtvnrdyluacvrayggwnpnzidiznpnwggyarvc...
code_stdio
[ { "content": "You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\nEveryone loves a freebie. Especially students.\n\nIt is well-known that if in the night before exam a student...
[{"input": "100\n98 63 672 100 254 218 623 415 426 986 920 915 736 795 407 541 382 213 935 743 961 59 660 512 134 935 248 378 739 356 543 714 28 667 602 596 759 791 103 564 225 520 159 542 966 332 983 655 517 273 95 242 593 940 286 236 41 318 941 727 384 225 319 627 982 359 232 769 854 172 643 598 215 231 305 30 347 46...
code_stdio
[ { "content": "You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\nWrite a program which print coordinates $(x_i, y_i)$ of given $n$ points on the plane by the following criter...
[{"input": "5\n-1 3\n1 15\n-1 1\n-1 -1\n-1 -1", "output": "-1 -1\n-1 -1\n-1 1\n-1 3\n1 15\n"}, {"input": "5\n-1 3\n1 15\n-1 0\n-1 -1\n-1 -1", "output": "-1 -1\n-1 -1\n-1 0\n-1 3\n1 15\n"}, {"input": "5\n-1 3\n1 22\n-1 0\n-1 -1\n-1 -1", "output": "-1 -1\n-1 -1\n-1 0\n-1 3\n1 22\n"}, {"input": "5\n-1 5\n1 22\n-1 0\n-1 -1...
code_stdio
[ { "content": "You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\nMotorist Kojiro spent 10 years saving up for his favorite car brand, Furrari. Finally Kojiro's dream came tru...
[{"input": "386 20 29 30\n1 349\n2 482\n1 112\n1 93\n2 189\n1 207\n2 35\n2 -5\n1 422\n1 442\n1 402\n2 238\n3 258\n3 54\n2 369\n2 290\n2 329\n3 74\n3 -62\n2 170\n1 462\n2 15\n2 222\n1 309\n3 150\n1 -25\n3 130\n1 271\n1 -43\n351 250 91 102 0 286 123 93 100 205 328 269 188 83 73 35 188 223 73 215 199 64 47 379 61 298 295 ...
code_stdio
[ { "content": "You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\nThere are N cities. There are also K roads and L railways, extending between the cities. The i-th road bidire...
[{"input": "25 4 4\n1 2\n3 3\n2 5\n6 7\n3 5\n4 3\n3 4\n6 7", "output": "1 1 1 1 1 2 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1\n"}, {"input": "27 0 1\n0 0\n2 10\n3 -1\n1 0", "output": "1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1\n"}, {"input": "23 3 0\n-4 2\n2 4\n3 4\n10 5", "output": "1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...
code_stdio
[ { "content": "You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\nVasily the bear has got a sequence of positive integers a_1, a_2, ..., a_{n}. Vasily the Bear wants to write ...
[{"input": "39\n37749932 37750076 37750391 37750488 37750607 37750812 37750978 37751835 37752173 37752254 75497669 75497829 75497852 75498044 75498061 75498155 75498198 75498341 75498382 75498465 150994988 150994989 150995009 150995019 150995024 150995030 150995031 150995069 150995072 805306369 805306373 805306375 8053...
code_stdio
[ { "content": "You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\nA string t is called an anagram of the string s, if it is possible to rearrange letters in t so that it is id...
[{"input": "??fb???a??\ndeeefc\n", "output": "0\n"}, {"input": "??fb???a??\ndedefc\n", "output": "0\n"}, {"input": "??fb???a??\ndedefd\n", "output": "0\n"}, {"input": "??a???bf??\ndedefd\n", "output": "0\n"}, {"input": "??fb?a????\ndeeefc\n", "output": "0\n"}, {"input": "??a???bf??\ndedefc\n", "output": "0\n"}, {"input...
code_stdio
[ { "content": "You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\nToday is August 24, one of the five Product Days in a year.\n\nA date m-d (m is the month, d is the date) is ...
[{"input": "15 38", "output": "10\n"}, {"input": "16 38", "output": "11\n"}, {"input": "16 57", "output": "16\n"}, {"input": "16 94", "output": "19\n"}, {"input": "12 94", "output": "12\n"}, {"input": "26 38", "output": "15\n"}, {"input": "24 94", "output": "31\n"}, {"input": "14 68", "output": "13\n"}, {"input": "31 4...
code_stdio
[ { "content": "You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\nScheme? - Too loudly said. Just a new idea. Now Chef is expanding his business. He wants to make some new res...
[{"input": "3\n17\n7\n20", "output": "129140160\n2184\n486784383\n"}, {"input": "3\n19\n7\n21", "output": "162261457\n2184\n460353130\n"}, {"input": "3\n12\n13\n11", "output": "531444\n1594320\n177144\n"}, {"input": "3\n17\n7\n12", "output": "129140160\n2184\n531444\n"}, {"input": "3\n17\n7\n11", "output": "129140160\n...
code_stdio
[ { "content": "You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\nPermutation p is an ordered set of integers p_1, p_2, ..., p_{n}, consisting of n distinct positive intege...
[{"input": "011\n", "output": "890786230\n"}, {"input": "13\n", "output": "695720788\n"}, {"input": "15\n", "output": "150347555\n"}, {"input": "11\n", "output": "890786230\n"}, {"input": "11\n", "output": "890786230\n"}, {"input": "15\n", "output": "150347555\n"}, {"input": "13\n", "output": "695720788\n"}, {"input": ...
code_stdio
[ { "content": "You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\nYou are given an array of n positive integers a_1, a_2, …, a_n. Your task is to calculate the number of array...
[{"input": "100\n23 39 20 46 127 72 41 70 37 18 8 40 24 61 12 79 51 148 61 66 85 97 78 14 70 47 100 40 15 40 23 52 19 30 6 91 82 56 10 6 68 24 97 61 31 136 18 45 88 6 37 38 51 86 37 42 66 30 79 56 50 14 61 18 24 20 57 3 93 15 24 74 32 21 71 93 4 66 20 82 75 10 86 108 30 31 6 49 15 33 100 35 1 96 161 63 29 21 41 22\n", ...
code_stdio
[ { "content": "You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\nYou are given an array consisting of $n$ integers $a_1$, $a_2$, ..., $a_n$. Initially $a_x = 1$, all other el...
[{"input": "9\n100 50 6\n1 49\n51 100\n40 60\n30 70\n20 30\n70 80\n100 1 11\n1 1\n1 1\n1 1\n2 2\n2 100\n1 4\n2 3\n3 7\n5 6\n6 100\n4 5\n1 1 5\n1 1\n1 1\n1 1\n1 1\n1 1\n11 6 4\n6 6\n1 5\n7 11\n6 6\n3 3 2\n1 2\n2 3\n1000000000 1 1\n1 1000000000\n1000000000 1 1\n1 999999999\n1000000000 1 1\n2 1000000000\n1000000000 2 1\n1...
code_stdio
[ { "content": "You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\nWrite a program which identifies the number of combinations of three integers which satisfy the following con...
[{"input": "37 49\n0 0", "output": "151\n"}, {"input": "13 14\n0 0", "output": "10\n"}, {"input": "16 22\n0 0", "output": "26\n"}, {"input": "20 20\n0 0", "output": "24\n"}, {"input": "19 22\n0 0", "output": "30\n"}, {"input": "20 32\n0 0", "output": "45\n"}, {"input": "20 48\n0 0", "output": "12\n"}, {"input": "12 22\...
code_stdio
[ { "content": "You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\nLuba thinks about watering her garden. The garden can be represented as a segment of length k. Luba has got n...
[{"input": "100 100\n2 46 24 18 86 90 31 38 84 49 58 28 15 80 14 24 87 56 62 87 41 87 55 71 87 32 41 56 91 32 24 75 43 42 35 30 72 53 31 26 54 61 87 85 36 75 44 31 7 38 77 57 61 54 70 77 45 96 39 57 11 8 91 42 52 15 42 30 92 41 27 26 34 27 3 80 32 86 26 97 63 91 30 75 14 7 19 23 45 11 8 43 44 73 11 56 3 55 63 16\n", "o...
code_stdio
[ { "content": "You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\nLittle Artem has invented a time machine! He could go anywhere in time, but all his thoughts of course are wi...
[{"input": "10\n1 1 1000000000\n1 4 1000000000\n2 2 1000000000\n1 5 1000000000\n1 8 1000000000\n2 15 1000000000\n3 3 1000000000\n3 10 1000000000\n3 6 1000000000\n3 7 1000000000\n", "output": "0\n3\n2\n2\n"}, {"input": "10\n1 1 1000000000\n1 4 1000000000\n2 2 1000000000\n1 5 1000000000\n1 8 1000000000\n2 15 1000000000\n...
code_stdio
[ { "content": "You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\nLittle boy Gerald studies at school which is quite far from his house. That's why he has to go there by bus e...
[{"input": "68 74\n51 54\n3 22\n12 24\n3 27\n32 42\n36 55\n60 64\n1 4\n4 23\n11 64\n54 62\n50 56\n21 34\n27 63\n15 54\n28 61\n13 57\n39 53\n12 32\n32 40\n33 67\n55 61\n33 67\n30 37\n15 49\n27 45\n21 41\n8 42\n24 63\n40 48\n28 41\n30 67\n0 4\n7 15\n27 59\n60 62\n25 65\n30 31\n38 67\n24 43\n14 64\n26 46\n8 12\n34 41\n32 ...
code_stdio
[ { "content": "You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\nVasya learns to type. He has an unusual keyboard at his disposal: it is rectangular and it has n rows of keys...
[{"input": "10 10 2\nfriuxvShvg\nerslojqtgu\nzeqsmdewry\nwvhbeeyeSu\ngkofbjaavr\ntwkcdxugps\nnzlylSmafu\nstamkpxnzt\nuwxwximkrm\nmzxyboazbl\n100\nmRIfAtrLKmztpVkAmojDCiIgseBwlUilBIiyDQhqNhNAqVLLIobuCIretLdSvixNNdCiouFMXtwHZFlObCeaygmIiFBfaCirbmCa\n", "output": "19\n"}, {"input": "10 10 1\nmgziiihbkq\niobjknuogh\nvntwah...
code_stdio
[ { "content": "You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\nThe Hedgehog likes to give presents to his friend, but no less he likes to receive them.\n\nHaving received a...
[{"input": "350 22\n73 1 4 8 10 14 16 19 28 37 41 42 43 55 56 64 66 67 79 80 84 87 96 99 101 103 119 120 121 122 127 128 135 141 142 143 148 156 159 160 161 166 167 169 173 189 201 202 205 219 223 227 233 242 243 244 250 257 260 262 263 264 273 291 301 302 305 306 307 314 326 336 342 345\n", "output": "73\n"}, {"input"...
code_stdio
[ { "content": "You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\nCity X consists of n vertical and n horizontal infinite roads, forming n × n intersections. Roads (both verti...
[{"input": "9\n4 5\n2 3\n8 3\n5 6\n9 3\n4 4\n5 4\n4 7\n1 7\n8 4\n1 4\n1 5\n5 7\n7 8\n7 1\n9 9\n8 7\n7 5\n3 7\n6 6\n7 3\n5 2\n3 6\n7 4\n9 6\n5 8\n9 7\n6 3\n7 9\n1 2\n1 1\n6 2\n5 3\n7 2\n1 6\n4 1\n6 1\n8 9\n2 2\n3 9\n2 9\n7 7\n2 8\n9 4\n2 5\n8 6\n3 4\n2 1\n2 7\n6 5\n9 1\n3 3\n3 8\n5 5\n4 3\n3 1\n1 9\n6 4\n3 2\n6 8\n2 6\n...
code_stdio
[ { "content": "You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\nLet's call a string \"s-palindrome\" if it is symmetric about the middle of the string. For example, the stri...
[{"input": "mmmmmmmmmmmmmmmm\n", "output": "NIE\n"}, {"input": "mmmmmmmmmmmmmmmm\n", "output": "NIE\n"}, {"input": "mmmmmmmmmmmmmmmn\n", "output": "NIE\n"}, {"input": "nnnnnnnnnnnnn\n", "output": "NIE\n"}, {"input": "nnnnnnnnnnnnn\n", "output": "NIE\n"}, {"input": "onnnnnnnnnnnn\n", "output": "NIE\n"}, {"input": "AAAAN...
code_stdio
[ { "content": "You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\nYou have a team of N people. For a particular task, you can pick any non-empty subset of people. The cost of ...
[{"input": "1000000000 5000\n", "output": "642932262\n"}, {"input": "1000000000 5000\n", "output": "642932262\n"}, {"input": "158260522 4575\n", "output": "875142289\n"}, {"input": "602436426 4445\n", "output": "582490088\n"}, {"input": "262703497 2202\n", "output": "813734619\n"}, {"input": "971407775 4325\n", "output...
code_stdio
[ { "content": "You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\nYou are given a polynomial of degree N with integer coefficients: f(x)=a_Nx^N+a_{N-1}x^{N-1}+...+a_0. Find al...
[{"input": "0\n461740266", "output": "2\n3\n13\n1327\n1487\n"}, {"input": "0\n1326078230", "output": "2\n5\n1051\n126173\n"}, {"input": "0\n754892205", "output": "3\n5\n41\n853\n1439\n"}, {"input": "0\n732779016", "output": "2\n3\n17\n263\n6829\n"}, {"input": "0\n663325004", "output": "2\n29\n197\n29027\n"}, {"input": ...
code_stdio
[ { "content": "You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\nSitting in a station waiting room, Joisino is gazing at her train ticket.\nThe ticket is numbered with four d...
[{"input": "1222\n", "output": "1+2+2+2=7\n"}, {"input": "0290\n", "output": "0-2+9+0=7\n"}, {"input": "3242\n", "output": "3+2+4-2=7\n"}, {"input": "2364", "output": "2+3+6-4=7\n"}, {"input": "1114", "output": "1+1+1+4=7\n"}, {"input": "2005", "output": "2+0+0+5=7\n"}, {"input": "1455", "output": "1-4+5+5=7\n"}, {"inp...
code_stdio
[ { "content": "You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\nYou have $r$ red and $b$ blue beans. You'd like to distribute them among several (maybe, one) packets in such...
[{"input": "10\n1 1000000000 1000000000\n1 1000000000 1000000000\n1 1000000000 1000000000\n1 1000000000 1000000000\n1 1000000000 1000000000\n1 1000000000 1000000000\n1 1000000000 1000000000\n1 1000000000 1000000000\n1 1000000000 1000000000\n1 1000000000 1000000000\n", "output": "YES\nYES\nYES\nYES\nYES\nYES\nYES\nYES\n...
code_stdio
[ { "content": "You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\nAmidakuji is a traditional method of lottery in Japan.\nTo make an amidakuji, we first draw W parallel vertic...
[{"input": "100 8 8\n", "output": "467571711\n"}, {"input": "100 8 3\n", "output": "938282570\n"}, {"input": "100 8 1\n", "output": "755868507\n"}, {"input": "15 8 5\n", "output": "437760187\n"}, {"input": "77 7 7\n", "output": "237739357\n"}, {"input": "98 7 6\n", "output": "736412603\n"}, {"input": "57 5 1\n", "outpu...
code_stdio
[ { "content": "You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\nYou've got an n × m pixel picture. Each pixel can be white or black. Your task is to change the colors of as ...
[{"input": "56 2 2 2\n##\n##\n##\n..\n..\n##\n.#\n.#\n..\n##\n##\n..\n..\n#.\n#.\n#.\n#.\n##\n..\n.#\n..\n##\n##\n.#\n#.\n.#\n..\n..\n#.\n..\n##\n..\n#.\n.#\n#.\n#.\n#.\n##\n#.\n##\n##\n.#\n#.\n##\n..\n.#\n#.\n#.\n##\n..\n..\n#.\n##\n..\n..\n##\n", "output": "55\n"}, {"input": "56 2 2 2\n##\n##\n##\n..\n..\n##\n.#\n.#\...
code_stdio
[ { "content": "You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\nThe last contest held on Johnny's favorite competitive programming platform has been received rather positive...
[{"input": "3\n576460752303423484\n576460752303423484\n576460752303423485\n", "output": "1152921504606846911\n1152921504606846911\n1152921504606846912\n"}, {"input": "3\n576460752303423484\n576460752303423484\n576460752303423485\n", "output": "1152921504606846911\n1152921504606846911\n1152921504606846912\n"}, {"input":...
code_stdio
[ { "content": "You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\nThere are N people standing in a row from west to east. Each person is facing east or west. The directions of...
[{"input": "12\nEWWWEEEWEWEW", "output": "5\n"}, {"input": "12\nWWWWEEEWEWEE", "output": "6\n"}, {"input": "12\nEWWEWEEEWWWE", "output": "4\n"}, {"input": "12\nWEWWEEWWEWEE", "output": "6\n"}, {"input": "12\nEEWEWEEEWWWW", "output": "2\n"}, {"input": "12\nEWWWEEEWEWWE", "output": "5\n"}, {"input": "12\nEWWWEEEWWWEE", "...
code_stdio
[ { "content": "You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\nYou are given a matrix f with 4 rows and n columns. Each element of the matrix is either an asterisk (*) or a...
[{"input": "33\n548 102 31 979\n.**..**.**...******.*.**....**.**\n**..******...*.*...*.....*....*.*\n.**..*...*.**.*.....*..*..**.*..*\n.....**.....*..*...***.***..**.**\n", "output": "527\n"}, {"input": "33\n548 102 31 730\n.**..**.**...******.*.**....**.**\n**..******...*.*...*.....*....*.*\n.**..*...*.**.*.....*..*...
code_stdio
[ { "content": "You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\nproblem\n\nYou decide to invite your friends of the school and your friends of a friend to the Christmas part...
[{"input": "6\n5\n1 2\n1 3\n3 4\n2 3\n4 5\n10\n5\n2 3\n3 4\n4 3\n5 6\n1 6\n0\n0", "output": "3\n2\n"}, {"input": "6\n5\n1 2\n1 3\n3 4\n2 3\n4 5\n6\n5\n2 3\n3 4\n4 5\n5 6\n2 6\n0\n0", "output": "3\n0\n"}, {"input": "6\n5\n1 2\n1 3\n3 4\n2 3\n4 5\n6\n5\n2 3\n3 4\n1 5\n5 6\n2 6\n0\n0", "output": "3\n2\n"}, {"input": "6\n5...
code_stdio
[ { "content": "You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\nAuthors have come up with the string $s$ consisting of $n$ lowercase Latin letters.\n\nYou are given two perm...
[{"input": "6 5\n5 6 1 2 3 4\n6 5 1 2 3 4\n", "output": "YES\nbcdeaa\n"}, {"input": "6 5\n5 6 1 2 3 4\n6 5 1 2 3 4\n", "output": "YES\nbcdeaa\n"}, {"input": "5 2\n5 2 4 3 1\n5 4 3 1 2\n", "output": "YES\nbbbba\n"}, {"input": "5 2\n5 2 4 3 1\n5 4 3 1 2\n", "output": "YES\nbbbba\n"}, {"input": "5 1\n1 3 2 4 5\n2 3 5 1 4\...
code_stdio
[ { "content": "You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\nYou are given a set of $2n+1$ integer points on a Cartesian plane. Points are numbered from $0$ to $2n$ inclu...
[{"input": "1000000000000000000 1000000000000000000\n", "output": "1\n"}, {"input": "1 1000000000000000000\n", "output": "1000000000000000000\n"}, {"input": "1000000001 1000000000000000000\n", "output": "1000000000\n"}, {"input": "1000000001 1000000000000000000\n", "output": "1000000000\n"}, {"input": "1000000000000000...
code_stdio
[ { "content": "You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\nKostya likes the number 4 much. Of course! This number has such a lot of properties, like:\n\n- Four is the s...
[{"input": "5\n794947\n1850\n2424\n119\n24", "output": "2\n0\n2\n0\n1\n"}, {"input": "5\n1167956\n340\n2424\n40\n42", "output": "0\n1\n2\n1\n1\n"}, {"input": "5\n163328\n953\n2213\n157\n12", "output": "0\n0\n0\n0\n0\n"}, {"input": "5\n406876\n1014\n1542\n74\n18", "output": "1\n1\n1\n1\n0\n"}, {"input": "5\n428282\n1310...
code_stdio
[ { "content": "You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\nPolycarp starts his own business. Tomorrow will be the first working day of his car repair shop. For now the ...
[{"input": "30\n522692116 159\n589719489 488\n662495181 961\n915956552 470\n683572975 271\n498400137 480\n327010963 181\n200704287 367\n961198611 54\n978100746 208\n345455616 986\n106372142 876\n446972337 42\n309349333 200\n93462198 543\n167946793 318\n325598940 427\n121873339 459\n174934933 598\n279521023 1152\n739750...
code_stdio
[ { "content": "You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\nGiven is a string S consisting of `0` and `1`. Find the number of strings, modulo 998244353, that can result ...
[{"input": "1100011010101110110111101111011111011000111101110110010010101000101 108", "output": "298688651\n"}, {"input": "1100011010101110110111101111011111011000111101110110010011101000101 108", "output": "573021841\n"}, {"input": "1100011010101110110111101111010111011000111101110110010011101000101 108", "output": "9...
code_stdio
[ { "content": "You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\nThere are three points marked on the coordinate plane. The goal is to make a simple polyline, without self-in...
[{"input": "1000000000 -1000000000\n1000000000 1000000000\n-1000000000 -1000000000\n", "output": "2\n"}, {"input": "1000000000 -1000000000\n1000000000 1000000000\n-1000000000 -1000000000\n", "output": "2\n"}, {"input": "1000000000 -1000000000\n1000000000 1000000010\n-1000000000 -1000000000\n", "output": "2\n"}, {"input...
code_stdio
[ { "content": "You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\n# Introduction\n\n\nFish are an integral part of any ecosystem. Unfortunately, fish are often seen as high ma...
[{"input": "\"111111111111111111112222222222\"", "output": "[5]", "fn_name": "fish"}, {"input": "\"151128241212192113722321331\"", "output": "[5]", "fn_name": "fish"}, {"input": "\"111122223333\"", "output": "[4]", "fn_name": "fish"}, {"input": "\"111111111111\"", "output": "[3]", "fn_name": "fish"}, {"input": "\"11112...
code_functional
[ { "content": "You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\nGigi is a clever monkey, living in the zoo, his teacher (animal keeper) recently taught him some knowledge of...
[{"input": "\"abcdefghijklmnopqrstuvwxyz\"", "output": "[8]", "fn_name": "countzero"}, {"input": "\"1234567890\"", "output": "[5]", "fn_name": "countzero"}, {"input": "\"0oO0oO\"", "output": "[6]", "fn_name": "countzero"}, {"input": "\"BRA\"", "output": "[3]", "fn_name": "countzero"}, {"input": "\"()\"", "output": "[1]...
code_functional
[ { "content": "You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\nCreate a function that will return true if all numbers in the sequence follow the same counting pattern. If t...
[{"input": "[2, 4, 6, 8, 10, 12, 14, 16, 18, 22]", "output": "[false]", "fn_name": "validate_sequence"}, {"input": "[2, 4, 6, 8, 10, 12, 13, 16, 18, 20]", "output": "[false]", "fn_name": "validate_sequence"}, {"input": "[2, 4, 6, 8, 10, 12, 14, 16, 18, 20]", "output": "[true]", "fn_name": "validate_sequence"}, {"input"...
code_functional
[ { "content": "You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\nWherever the destination is, whoever we meet, let's render this song together.\n\nOn a Cartesian coordinate p...
[{"input": "20 50000 50000\n2 45955 55488\n1 19804 29337\n2 3767 90811\n2 24025 33558\n1 46985 56518\n2 21094 30627\n2 5787 15320\n1 4262 91306\n2 37231 46764\n1 18125 27658\n1 36532 12317\n1 31330 40863\n1 18992 28525\n1 29387 38920\n1 44654 54187\n2 45485 55018\n2 36850 46383\n1 44649 54182\n1 40922 50455\n2 12781 99...
code_stdio
[ { "content": "You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\nXXI Berland Annual Fair is coming really soon! Traditionally fair consists of $n$ booths, arranged in a circl...
[{"input": "78 74\n20194 1621 21498 13827 31277 19791 6583 13579 11160 20419 26490 160 3450 12925 18134 10381 27009 28815 10209 6478 18504 15371 32608 14197 12075 13723 12612 19020 28762 11057 12891 31164 16684 13717 19933 25453 2742 4955 6814 2863 10397 15461 20616 10905 2600 20137 4681 9199 27033 14388 32585 7241 351...
code_stdio
[ { "content": "You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\nFrog Gorf is traveling through Swamp kingdom. Unfortunately, after a poor jump, he fell into a well of $n$ me...
[{"input": "19\n1 1 3 4 5 3 5 0 0 6 3 1 10 3 13 9 1 4 2\n3 0 6 3 8 6 8 7 8 6 0 0 5 0 0 1 1 1 0\n", "output": "5\n17 15 2 1 0\n"}, {"input": "19\n1 1 3 4 5 3 5 11 0 6 5 3 10 3 13 9 1 4 17\n3 0 6 3 8 6 8 7 8 6 -1 0 5 0 0 1 1 1 0\n", "output": "3\n2 1 0\n"}, {"input": "19\n1 1 3 4 5 3 5 11 0 6 5 3 10 3 13 9 1 4 17\n3 0 6 ...
code_stdio
[ { "content": "You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\nIvan had string s consisting of small English letters. However, his friend Julia decided to make fun of him a...
[{"input": "20\nadabacabaeabacabada 1 359\nabadabacabafabaca 1 213\nacabagabacaba 1 315\ncabaeabacabadabacab 1 268\nfabacabadabacabaeab 1 352\ncabafabacabada 1 28\nacabadabacabaea 1 67\ncabadabacabaeabacaba 1 484\nabacabadabacaba 1 209\nacabaiabacaba 1 251\nacabafabacabadabac 1 475\nabacabaeabacabadaba 1 105\ncabadabac...
code_stdio
[ { "content": "You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\nWrite a program which reads $n$ dices constructed in the same way as Dice I, and determines whether they are ...
[{"input": "3\n-1 10 1 14 13 17\n6 0 35 1 0 0\n4 4 2 7 -1 -1", "output": "Yes\n"}, {"input": "3\n-1 10 1 14 13 17\n6 0 35 1 0 0\n4 4 2 5 -1 -1", "output": "Yes\n"}, {"input": "3\n0 10 1 14 9 17\n6 0 35 1 0 0\n13 4 2 7 -1 -1", "output": "Yes\n"}, {"input": "3\n0 10 1 14 13 17\n6 0 35 1 0 0\n4 4 2 7 -1 -1", "output": "Ye...
code_stdio
[ { "content": "You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\nPolycarp was given an array of $a[1 \\dots n]$ of $n$ integers. He can perform the following operation with t...
[{"input": "50\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n", "...
code_stdio
[ { "content": "You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\nBerland scientists noticed long ago that the world around them depends on Berland population. Due to persiste...
[{"input": "5833850738115444790123301858525860464609052423198474077217629208584932325696195827387610627649689452307781278299607661979317839675618367523485801890948530770658677574385684508313179053341358796468870615462459993169923271075382282788408147405323998383308800\n", "output": "YES\n1\n465\n232\n468898754020481677...
code_stdio
[ { "content": "You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\nYou are at the top left cell $(1, 1)$ of an $n \\times m$ labyrinth. Your goal is to get to the bottom right ...
[{"input": "10 10\n..........\n..........\n..........\n..........\n..........\n..........\n..........\n..........\n..........\n..........\n", "output": "48620\n"}, {"input": "10 10\n..........\n..........\n..........\n..........\n..........\n..........\n..........\n..........\n..........\n..........\n", "output": "4862...
code_stdio
[ { "content": "You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\nConnected undirected graph without cycles is called a tree. Trees is a class of graphs which is interesting n...
[{"input": "51\n28 3\n42 40\n40 51\n48 20\n13 28\n18 40\n44 40\n22 5\n22 27\n45 34\n40 9\n34 46\n40 34\n22 1\n22 11\n40 7\n28 40\n40 22\n14 40\n34 30\n40 20\n47 40\n12 34\n28 23\n40 24\n40 43\n41 40\n28 15\n49 32\n40 8\n32 10\n40 50\n40 36\n40 21\n16 33\n40 38\n34 2\n28 16\n34 4\n17 34\n19 40\n32 35\n40 29\n6 40\n40 39...
code_stdio
[ { "content": "You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\nWhile Mahmoud and Ehab were practicing for IOI, they found a problem which name was Longest common subsequenc...
[{"input": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\nbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\n", "ou...
code_stdio
[ { "content": "You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\nThe [Chinese zodiac](https://en.wikipedia.org/wiki/Chinese_zodiac) is a repeating cycle of 12 years, with eac...
[{"input": "6673", "output": "[\"Water Rooster\"]", "fn_name": "chinese_zodiac"}, {"input": "1968", "output": "[\"Earth Monkey\"]", "fn_name": "chinese_zodiac"}, {"input": "2323", "output": "[\"Water Rabbit\"]", "fn_name": "chinese_zodiac"}, {"input": "1938", "output": "[\"Earth Tiger\"]", "fn_name": "chinese_zodiac"},...
code_functional
[ { "content": "You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\nTaro is addicted to a novel. The novel has n volumes in total, and each volume has a different thickness. Tar...
[{"input": "3 9\n1051\n300\n800\n200\n100\n600\n900\n1032\n400\n4 3\n1000\n1000\n1000\n0 0", "output": "2151\n1000\n"}, {"input": "3 9\n1051\n300\n800\n200\n100\n600\n900\n1032\n400\n4 3\n1000\n1000\n1001\n0 0", "output": "2151\n1001\n"}, {"input": "3 9\n500\n300\n800\n200\n100\n600\n900\n1032\n400\n4 3\n1000\n1000\n10...
code_stdio
[ { "content": "You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\nYou are a judge of a programming contest. You are preparing a dataset for a graph problem to seek for the cos...
[{"input": "3 3 3\n1 2 3\n2 3 4\n1 3 8\n12 12 2010\n1 2 0\n2 3 3000\n3 4 0\n4 5 1940\n5 6 3000\n6 12 2010\n2 7 100\n7 8 200\n8 9 506\n12 10 400\n10 11 500\n11 6 512\n10 18 1\n1 2 7\n1 3 2\n1 4 16\n2 5 0\n3 6 10\n2 7 2\n3 5 10\n3 6 3\n3 7 10\n4 7 6\n5 8 10\n6 8 2\n6 9 11\n7 9 3\n1 9 16\n8 10 8\n9 10 1\n8 2 0\n0 0 0", "o...
code_stdio
[ { "content": "You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\nA binary heap which satisfies max-heap property is called max-heap. In a max-heap, for every node $i$ other t...
[{"input": "10\n-1 2 2 0 140 11 1 1 12 5", "output": " 140 12 11 1 5 2 1 -1 0 2\n"}, {"input": "10\n0 2 2 0 140 11 1 -1 12 5", "output": " 140 12 11 0 5 2 1 -1 0 2\n"}, {"input": "10\n1 -1 0 0 15 18 1 -1 -1 2", "output": " 18 15 1 0 2 0 1 -1 -1 -1\n"}, {"input": "10\n1 -1 1 -2 16 18 1 0 -1 1", "output": " 18 16 1 0 1 1...
code_stdio
[ { "content": "You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\nThe store sells $n$ beads. The color of each bead is described by a lowercase letter of the English alphabet ...
[{"input": "1\n364 1485\naaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccddddddddddddddddddddddddddeeeeeeeeeeeeeeeeeeeeeeefffffffffffffffffffffffffffgggggggggggggggggggggggggggggggggggggggghhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh...
code_stdio
[ { "content": "You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\nCodeforces user' handle color depends on his rating — it is red if his rating is greater or equal to 2400; it...
[{"input": "9\nmwAz9lQ 1786 -1631\nnYgYFXZQfY -1849 -1775\nKU4jF -1773 -3376\nopR 3752 2931\nGl -1481 -1002\nR -1111 3778\n0i9B21DC 3650 279\nQ8L2dS0 358 -3305\ng -2662 3968\n", "output": "NO\n"}, {"input": "9\nmwAz9lQ 1786 -1631\nnYgYFXZQfY -1849 -1775\nKU4jF -1773 -3376\nopR 3752 2854\nGl -1481 -1002\nR -1111 3778\n0...
code_stdio
[ { "content": "You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\nPolycarp thinks about the meaning of life very often. He does this constantly, even when typing in the editor...
[{"input": "babbbbabbabbbababbabbbbbbabaabaababaaabbbbbabbbbaaaaabbaaabbaabaabbbbabbbababbabaaabbababaaababbbaaa\n", "output": "babababababababababababa\n"}, {"input": "aaabbbabaaabababbaaababbababbbabbbbaabaabbaaabbaaaaabbbbabbbbbaaababaabaababbbbbbabbababbbabbabbbbab\n", "output": "abababababababababababab\n"}, {"inp...
code_stdio
[ { "content": "You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\nOnce Bob got to a sale of old TV sets. There were n TV sets at that sale. TV set with index i costs ai bellar...
[{"input": "99 17\n-993 -1745 -959 -989 -991 -995 -976 -997 -990 -1000 -996 -994 -999 -354 -1000 -983 -979 -1000 -989 -968 -994 -992 -962 -1593 -999 -983 -991 -979 -995 -993 -973 -999 -995 -995 -999 -993 -995 -992 -947 -1000 -999 -998 -982 -988 -757 -993 -426 -988 -980 -990 -979 -976 -995 -999 -981 -988 -998 -999 -970 ...
code_stdio
[ { "content": "You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\nYou can't possibly imagine how cold our friends are this winter in Nvodsk! Two of them play the following gam...
[{"input": "7938986881993\n", "output": "1\n378028993\n"}, {"input": "472670214391\n", "output": "1\n23020027\n"}, {"input": "1468526771489\n", "output": "1\n613783\n"}, {"input": "1245373417369\n", "output": "1\n908209\n"}, {"input": "1307514188557\n", "output": "1\n39283\n"}, {"input": "1408514752349\n", "output": "1...
code_stdio
[ { "content": "You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\nConsider creating the following number pattern.\n\n\n4 8 2 3 1 0 8 3 7 6\n2 0 5 4 1 8 1 0 3\n2 5 9 5 9 9 1 3\...
[{"input": "4823108376\n2273064329\n0123456789", "output": "5\n1\n4\n"}, {"input": "4823108376\n2314825047\n0123456789", "output": "5\n4\n4\n"}, {"input": "4823108376\n1842094049\n0123456789", "output": "5\n0\n4\n"}, {"input": "4823108376\n2704372300\n0123456789", "output": "5\n7\n4\n"}, {"input": "4823108376\n28114748...
code_stdio
[ { "content": "You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\nThere is a directed graph with N vertices numbered 1 to N and M edges.\nThe i-th edge is directed from Vertex...
[{"input": "2500 5000 0\n1206 2272 100000\n315 2399 100000\n1186 1435 100000\n303 1569 100000\n2364 581 100000\n1683 1969 100000\n700 1088 100000\n717 410 100000\n1412 1595 100000\n2066 813 100000\n1190 949 100000\n258 2307 100000\n423 2263 100000\n671 425 100000\n1712 1110 100000\n787 1469 100000\n1954 1281 100000\n23...
code_stdio
[ { "content": "You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\nWrite a function, which takes a non-negative integer (seconds) as input and returns the time in a human-reada...
[{"input": "359999", "output": "[\"99:59:59\"]", "fn_name": "make_readable"}, {"input": "86399", "output": "[\"23:59:59\"]", "fn_name": "make_readable"}, {"input": "86400", "output": "[\"24:00:00\"]", "fn_name": "make_readable"}, {"input": "3599", "output": "[\"00:59:59\"]", "fn_name": "make_readable"}, {"input": "3600...
code_functional
[ { "content": "You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\nTaro is playing with a puzzle that places numbers 1-9 in 9x9 squares. In this puzzle, you have to arrange the...
[{"input": "2\n-1 2 3 3 4 10 8 13 9\n6 5 1 7 39 9 1 2 3\n7 11 11 2 -1 3 2 5 8\n2 4 0 1 6 9 12 9 0\n0 8 7 8 9 1 2 1 4\n8 9 1 0 3 4 2 8 7\n1 4 5 8 7 8 9 1 3\n8 12 8 9 1 4 3 4 5\n12 0 2 3 4 0 13 7 0\n2 1 3 2 5 4 7 8 14\n4 5 6 7 8 9 0 1 3\n7 8 13 1 4 4 8 5 8\n2 6 4 8 6 7 8 9 1\n5 6 12 8 9 1 2 6 3\n2 14 1 2 3 4 5 6 2\n3 7 5...
code_stdio
[ { "content": "You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\nCascading Style Sheets (CSS) is a style sheet language used for describing the look and formatting of a docum...
[{"input": "\".test1 .test2.test3\"\n\".test1 .test4 .test5 .test6\"", "output": "[\".test1 .test4 .test5 .test6\"]", "fn_name": "compare"}, {"input": "\"div p span a\"\n\"div p span a b\"", "output": "[\"div p span a b\"]", "fn_name": "compare"}, {"input": "\".item\"\n\"#menu div ul li a\"", "output": "[\"#menu div ul...
code_functional
[ { "content": "You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\nAnya loves to watch horror movies. In the best traditions of horror, she will be visited by m ghosts tonight....
[{"input": "138 245 30\n3 5 6 8 9 13 15 16 19 20 24 25 27 29 30 32 33 34 35 36 37 38 40 42 47 51 52 53 55 56 58 59 63 66 67 68 69 72 73 74 75 77 78 80 81 82 85 86 87 89 91 93 95 96 99 100 102 104 105 108 110 111 112 117 122 124 125 128 129 131 133 136 139 144 145 146 147 148 149 151 153 155 156 159 162 163 164 165 168 ...
code_stdio
[ { "content": "You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\nYour search for Heidi is over – you finally found her at a library, dressed up as a human. In fact, she has s...
[{"input": "80 4\n71 49 41 21 72 71 37 14 51 59 73 11 70 15 36 46 32 57 58 15 72 67 16 75 70 11 67 3 40 36 2 9 63 68 32 22 63 52 67 55 35 19 72 59 22 19 44 55 59 74 4 34 53 3 22 57 32 27 78 12 71 4 26 15 43 21 79 10 67 39 34 74 38 26 31 78 2 78 69 42\n", "output": "62\n"}, {"input": "80 4\n71 49 41 21 72 71 37 14 51 59...
code_stdio
[ { "content": "You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\nThe robot is placed in the top left corner of a grid, consisting of $n$ rows and $m$ columns, in a cell $(1, ...
[{"input": "3\n2 3 1 3 0\n2 3 1 3 1\n5 5 3 4 1\n", "output": "3\n-1\n8\n"}, {"input": "2\n3 5 2 3 1\n5 3 3 2 1\n", "output": "-1\n-1\n"}, {"input": "2\n2 3 1 3 0\n2 3 1 3 1\n", "output": "3\n-1\n"}, {"input": "2\n3 3 2 2 1\n5 5 3 3 1\n", "output": "-1\n8\n"}, {"input": "1\n972 439 242 299 296\n", "output": "1409\n"}, {...
code_stdio
[ { "content": "You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\nHarry Water, Ronaldo, Her-my-oh-knee and their friends have started a new school year at their MDCS School of...
[{"input": "2\n10\n10\n", "output": "200\n"}, {"input": "2\n19\n10\n", "output": "380\n"}, {"input": "2\n4\n18\n", "output": "144\n"}, {"input": "2\n6\n18\n", "output": "216\n"}, {"input": "2\n6\n23\n", "output": "276\n"}, {"input": "2\n6\n30\n", "output": "360\n"}, {"input": "2\n6\n39\n", "output": "468\n"}, {"input":...
code_stdio
[ { "content": "You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\nIt is nighttime and Joe the Elusive got into the country's main bank's safe. The safe has n cells positioned ...
[{"input": "95 97575868 5\n4612 1644 3613 5413 5649 2419 5416 3926 4610 4419 2796 5062 2112 1071 3790 4220 3955 2142 4638 2832 2702 2115 2045 4085 3599 2452 5495 4767 1368 2344 4625 4132 5755 5815 2581 6259 1330 4938 815 5430 1628 3108 4342 3692 2928 1941 3714 4498 4471 4842 1822 867 3395 2587 3372 6394 6423 3728 3720 ...
code_stdio
[ { "content": "You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\nWrite a function ```convert_temp(temp, from_scale, to_scale)``` converting temperature from one scale to anot...
[{"input": "128.25\n\"Ro\"\n\"C\"", "output": "[230]", "fn_name": "convert_temp"}, {"input": "373.15\n\"K\"\n\"N\"", "output": "[33]", "fn_name": "convert_temp"}, {"input": "-273.15\n\"C\"\n\"R\"", "output": "[0]", "fn_name": "convert_temp"}, {"input": "-30\n\"De\"\n\"K\"", "output": "[393]", "fn_name": "convert_temp"}...
code_functional
[ { "content": "You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\nThere are three airports A, B and C, and flights between each pair of airports in both directions.\nA one-way...
[{"input": "001 -13 -101", "output": "-114\n"}, {"input": "100 100 100\n", "output": "200\n"}, {"input": "111 -117 -5", "output": "-122\n"}, {"input": "011 -5 -101", "output": "-106\n"}, {"input": "000 -93 -7", "output": "-100\n"}, {"input": "010 -10 -10", "output": "-20\n"}, {"input": "010 -10 -18", "output": "-28\n"}...
code_stdio
[ { "content": "You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\nThe Metropolis computer network consists of n servers, each has an encryption key in the range from 0 to 2^k ...
[{"input": "10 40 10\n838 215 738 782 183 422 127 283 103 129\n1 2\n1 4\n1 5\n1 6\n1 7\n1 8\n1 9\n1 10\n2 3\n2 4\n2 5\n2 6\n2 7\n2 8\n2 9\n2 10\n3 3\n3 5\n3 6\n3 7\n3 8\n3 9\n3 10\n4 5\n4 6\n4 7\n4 9\n4 10\n5 7\n5 8\n5 9\n5 10\n6 7\n6 8\n6 9\n6 10\n7 9\n7 10\n8 10\n9 10\n", "output": "1028608\n"}, {"input": "10 40 10\n...
code_stdio
[ { "content": "You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\nUnscramble the eggs.\n\nThe string given to your function has had an \"egg\" inserted directly after each con...
[{"input": "\"veggegeggyeggmeggitegge onegg teggoaseggtegg\"", "output": "[\"vegymite on toast\"]", "fn_name": "unscramble_eggs"}, {"input": "\"seggceggreggameggbeggleggedegg egegggeggsegg\"", "output": "[\"scrambled eggs\"]", "fn_name": "unscramble_eggs"}, {"input": "\"Heggeleggleggo weggoreggleggdegg\"", "output": "[...
code_functional
[ { "content": "You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\nThe student council has a shared document file. Every day, some members of the student council write the sequ...
[{"input": "5\n3\nTMT\n3\nTMT\n6\nTMTMTT\n6\nTMTTTT\n6\nTTMMTT\n", "output": "YES\nYES\nYES\nNO\nYES\n"}, {"input": "5\n3\nTMT\n3\nMTT\n6\nTMTMTT\n6\nTMTTTT\n6\nTTMMTT\n", "output": "\nYES\nNO\nYES\nNO\nYES\n"}, {"input": "5\n3\nTMT\n3\nMTT\n6\nTMTMTT\n6\nTMTTTT\n6\nTTMMTT\n", "output": "YES\nNO\nYES\nNO\nYES\n"}, {"in...
code_stdio
[ { "content": "You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\nYaroslav has an array, consisting of (2·n - 1) integers. In a single operation Yaroslav can change the sign o...
[{"input": "56\n-157 136 457 598 -138 -586 -338 752 -566 -718 -333 -965 309 -125 -938 -188 -390 17 -75 -902 -320 163 820 -970 -525 -329 81 488 -412 978 138 344 305 -358 -273 -967 253 -665 -245 187 602 252 -825 -511 828 764 -402 278 995 541 542 549 612 -536 527 -884 225 800 160 -409 -926 -795 -321 -791 981 812 599 381 7...
code_stdio
[ { "content": "You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\nThere are $n$ people who want to participate in a boat competition. The weight of the $i$-th participant is $...
[{"input": "4\n14\n2 6 5 9 5 8 13 14 12 5 6 14 5 2\n36\n15 22 27 14 23 36 10 17 33 21 18 22 3 4 32 24 8 19 36 22 17 11 24 10 33 4 30 6 2 17 11 16 18 1 2 20\n2\n2 2\n12\n4 9 10 6 1 9 5 8 12 9 9 12\n", "output": "3\n11\n1\n4\n"}, {"input": "4\n14\n2 6 5 9 5 8 13 14 12 5 6 14 5 2\n36\n15 22 27 14 23 36 10 17 33 21 18 22 3...
code_stdio
[ { "content": "You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\nAlice has a string $s$. She really likes the letter \"a\". She calls a string good if strictly more than half...
[{"input": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n", "output": "50\n"}, {"input": "ababababababababababababababababababababababababav\n", "output": "49\n"}, {"input": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n", "output": "50\n"}, {"input": "ababababababababababababababababababababababababav\n"...
code_stdio
[ { "content": "You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\nYou are given a multiset of n integers. You should select exactly k of them in a such way that the difference...
[{"input": "108 29 72\n738 192 711 235 288 288 679 36 785 233 706 71 216 144 216 1419 338 583 495 648 144 432 72 720 541 288 158 328 154 393 10 533 867 176 707 216 314 397 440 142 326 458 568 701 745 144 61 634 520 720 744 144 409 127 526 476 101 469 72 432 738 432 235 641 695 276 144 144 231 555 630 9 109 319 437 288 ...
code_stdio
[ { "content": "You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\nThere is a plane like Figure 1 with 8 vertical and 8 horizontal squares. There are several bombs on that plan...
[{"input": "2\n\n00010010\n00000100\n10001001\n00100010\n01000000\n00001000\n10100010\n01010010\n2\n5\n\n00010010\n00000100\n10001001\n00100010\n01000000\n00001000\n10100000\n01010010\n2\n5", "output": "Data 1:\n00000000\n00000100\n10001001\n00100000\n00000000\n00001000\n10100000\n00000000\nData 2:\n00010010\n00000100\...
code_stdio
[ { "content": "You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\nI decided to play rock-paper-scissors with a group of five good friends. Rock-paper-scissors has three hands:...
[{"input": "1\n3\n3\n2\n1\n1\n2\n2\n2\n1\n0", "output": "3\n3\n3\n3\n3\n1\n2\n2\n2\n1\n"}, {"input": "1\n1\n1\n2\n1\n1\n2\n2\n2\n1\n0", "output": "1\n1\n1\n2\n1\n1\n2\n2\n2\n1\n"}, {"input": "1\n2\n3\n2\n1\n1\n1\n2\n2\n1\n0", "output": "3\n3\n3\n3\n3\n1\n1\n2\n2\n1\n"}, {"input": "1\n2\n2\n2\n1\n1\n1\n2\n2\n1\n0", "out...
code_stdio
[ { "content": "You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\nPrior to having fancy iPhones, teenagers would wear out their thumbs sending SMS\nmessages on candybar-shaped...
[{"input": "\"WHERE DO U WANT 2 MEET L8R\"", "output": "[47]", "fn_name": "presses"}, {"input": "\"IS NE1 OUT THERE\"", "output": "[31]", "fn_name": "presses"}, {"input": "\"#codewars #rocks\"", "output": "[36]", "fn_name": "presses"}, {"input": "\"HOW R U\"", "output": "[13]", "fn_name": "presses"}, {"input": "\"ZER0\...
code_functional
[ { "content": "You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\nYou want to go on a trip with a friend. However, friends who have a habit of spending money cannot easily sav...
[{"input": "10000\n1225 3150\n861 12737\n0 -1\n5000 1050\n5000 4211\n5000 412\n5000 5000\n5000 5000\n-1 -1\n5075 1951\n9143 2494\n5000 2100\n29170\n100000 000000\n100010 110000\n100000 100000\n100000 100000\n100100 100100\n100000 111000\n100000 100000\n101000 100000\n100000 100010\n100000 100000\n100000 000000\n100000 ...
code_stdio
[ { "content": "You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\nRecently, Norge found a string $s = s_1 s_2 \\ldots s_n$ consisting of $n$ lowercase Latin letters. As an exe...
[{"input": "200 13\nvgfjhgkgwkftaeqejmbgildembgxdbskxfndwmcckjfkbeekxkgakmcjhclqsecpnkaigcxxhfghgegfadjktckftdhtifriemfifakygoesjfginnddjjklwiwlbjsgftwhtjdxmcadpvhaeddxwnmguwhetwbmffbmvdvuhecgjckddrbikgwkrfwfhdhqolidgkfm\na b c d e f g h i j k l m\n", "output": "578\n"}, {"input": "200 13\nvgfjhgkgwkftaeqejmbgildembgxd...
code_stdio
[ { "content": "You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\nFor his computer science class, Jacob builds a model tree with sticks and balls containing n nodes in the sha...
[{"input": "10 3\n703660 186846 317819 628672 131569 58472 247014 480113 252764 860936\n10 6\n7 4\n10 9\n9 5\n6 3\n6 2\n10 1\n10 7\n10 8\n", "output": "480113\n"}, {"input": "10 3\n703660 186846 317819 1004549 74457 58472 247014 480113 252764 1263340\n10 6\n7 4\n10 9\n9 5\n9 3\n6 2\n7 1\n10 7\n10 8\n", "output": "25276...
code_stdio
[ { "content": "You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\nLord Omkar has permitted you to enter the Holy Church of Omkar! To test your worthiness, Omkar gives you a pa...
[{"input": "80\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1...
code_stdio
[ { "content": "You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\nAs Famil Door’s birthday is coming, some of his friends (like Gabi) decided to buy a present for him. His fri...
[{"input": "1980 464\n))(()()))(((((((((()))))))(()(((()((()))()()())()))()))(()))))))(())((())))()())()((())())()())))(())()(()))(()())()((((()))())()(())))))(()()(()(((((()(()()))(((()))(())))))()())(())))))())()()((())))))))((()(())))))()()(()((()((()()))(()))(())(()))()((((())()()))))))()(())))()(()())()())(((((())...
code_stdio
[ { "content": "You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\nThe \"BerCorp\" company has got n employees. These employees can use m approved official languages for the fo...
[{"input": "100 100\n1 33\n0\n2 35 4\n2 40 78\n1 69\n0\n1 2\n0\n0\n2 81 34\n1 45\n0\n1 87\n1 50\n1 97\n0\n2 100 59\n0\n0\n0\n1 45\n0\n0\n0\n1 6\n1 54\n0\n0\n0\n4 79 96 52 84\n1 86\n0\n0\n0\n0\n0\n0\n0\n0\n3 90 2 80\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n1 2\n0\n1 64\n0\n1 78\n1 82\n0\n0\n0\n0\n0\n1 6\n0\n0\n2 47 57\n1 95\n0\n2...
code_stdio
[ { "content": "You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\nThe classic programming language of Bitland is Bit++. This language is so peculiar and complicated.\n\nThe la...
[{"input": "101\nX++\nX++\nX++\n++X\n--X\nX--\nX++\nX--\nX--\n--X\n--X\n++X\nX++\n++X\n++X\nX--\n--X\n++X\nX++\nX--\n++X\n--X\n--X\n--X\n++X\n--X\n++X\nX++\nX++\n++X\n--X\nX++\nX--\nX++\n++X\n++X\nX--\nX--\nX--\nX++\nX++\nX--\nX--\nX++\n++X\n++X\n++X\n--X\n--X\n++X\nX--\nX--\n--X\n++X\nX--\n++X\nX++\n++X\nX--\nX--\n--X...
code_stdio
[ { "content": "You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\nThis is the story of 20XX. The number of air passengers increased as a result of the stable energy supply by ...
[{"input": "6\n1 1\n.\n3 3\n...\n.W.\n...\n10 10\n..........\n.DDDDCCC..\n.DDDDCCC..\n.DDDDCCC..\nADDDDCCC..\nAAA..CCC..\n..CBBBBAAA\nAAABBBB...\n..BBBBB...\n..........\n10 10\n..........\n.DDDDDD...\n.DDDDCCC..\n.DDDDCCC..\nADDDDCCC..\nAAA.-CCC..\nAAABBBBC..\nAAABBBB...\n..BBBBB...\n..........\n10 10\nR..E..C.T.\nR.EE...
code_stdio
[ { "content": "You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\nProblem F Pizza Delivery\n\nAlyssa is a college student, living in New Tsukuba City. All the streets in the c...
[{"input": "4 5\n1 3 7\n4 2 6\n4 3 0\n2 1 34\n3 3 12", "output": "SOSO\nSOSO\nHAPPY\nHAPPY\nSOSO\n"}, {"input": "4 5\n1 1 5\n3 4 6\n4 2 13\n2 1 6\n2 3 17", "output": "SOSO\nSOSO\nSOSO\nHAPPY\nSOSO\n"}, {"input": "4 5\n1 3 5\n3 4 6\n2 2 7\n2 1 1\n2 3 17", "output": "SOSO\nSOSO\nSOSO\nHAPPY\nHAPPY\n"}, {"input": "4 5\n1 ...
code_stdio
[ { "content": "You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\nBilly investigates the question of applying greedy algorithm to different spheres of life. At the moment he i...
[{"input": "91\n4000000 3000000 2900000 2511334 2511333 2102003 1901011 1700000 1200000 999999 800000 750000 600000 508111 202000 101000 35000 20000 9000 5000 2000 899 630 629 628 627 626 625 624 623 622 621 620 619 618 617 616 615 614 613 612 611 610 609 608 607 606 605 604 603 602 601 504 405 404 403 402 401 305 304 ...
code_stdio
[ { "content": "You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\nThe new camp by widely-known over the country Spring Programming Camp is going to start soon. Hence, all the ...
[{"input": "01010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101...
code_stdio
[ { "content": "You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\nThis problem is a simplified version of D2, but it has significant differences, so read the whole statement.\...
[{"input": "10\n10\n25 25 7 61 97 -47 43 7 -11 -29\n10\n44 -10 -10 -64 -64 98 -64 62 -10 -64\n10\n20 50 65 35 65 -40 50 20 -55 -10\n10\n7 -91 -77 -91 -21 7 77 35 21 -7\n10\n56 -76 78 12 -54 -43 23 1 -65 45\n10\n-68 12 -88 -48 52 -8 -28 -8 92 -88\n10\n55 -2 -2 74 36 -59 -59 55 36 -78\n10\n70 -66 -76 71 3 44 96 -78 50 -5...
code_stdio
[ { "content": "You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\nBob is playing a game of Spaceship Solitaire. The goal of this game is to build a spaceship. In order to do t...
[{"input": "2\n4 4\n9\n1 1 1\n1 2 1\n1 3 1\n2 1 2\n2 2 2\n2 3 2\n2 3 1\n2 2 1\n2 1 1\n", "output": "7\n6\n5\n4\n3\n2\n2\n3\n4\n"}, {"input": "2\n4 4\n9\n1 1 1\n1 2 1\n1 3 1\n2 1 2\n2 2 2\n2 3 2\n2 3 1\n2 2 1\n2 1 1\n", "output": "7\n6\n5\n4\n3\n2\n2\n3\n4\n"}, {"input": "2\n4 4\n9\n1 1 1\n2 2 1\n1 3 1\n2 1 2\n2 2 2\n2 ...
code_stdio