{"problem": "This version of the problem differs from the next one only in the constraint on n.\n\nNote that the memory limit in this problem is lower than in others.\n\nYou have a vertical strip with n cells, numbered consecutively from 1 to n from top to bottom.\n\nYou also have a token that is initially placed in cell n. You will move the token up until it arrives at cell 1.\n\nLet the token be in cell x > 1 at some moment. One shift of the token can have either of the following kinds: \n\n * Subtraction: you choose an integer y between 1 and x-1, inclusive, and move the token from cell x to cell x - y. \n * Floored division: you choose an integer z between 2 and x, inclusive, and move the token from cell x to cell ⌊ x/z ⌋ (x divided by z rounded down). \n\n\n\nFind the number of ways to move the token from cell n to cell 1 using one or more shifts, and print it modulo m. Note that if there are several ways to move the token from one cell to another in one shift, all these ways are considered distinct (check example explanation for a better understanding).\n\nInput\n\nThe only line contains two integers n and m (2 ≤ n ≤ 2 ⋅ 10^5; 10^8 < m < 10^9; m is a prime number) — the length of the strip and the modulo.\n\nOutput\n\nPrint the number of ways to move the token from cell n to cell 1, modulo m.\n\nExamples\n\nInput\n\n\n3 998244353\n\n\nOutput\n\n\n5\n\n\nInput\n\n\n5 998244353\n\n\nOutput\n\n\n25\n\n\nInput\n\n\n42 998244353\n\n\nOutput\n\n\n793019428\n\nNote\n\nIn the first test, there are three ways to move the token from cell 3 to cell 1 in one shift: using subtraction of y = 2, or using division by z = 2 or z = 3.\n\nThere are also two ways to move the token from cell 3 to cell 1 via cell 2: first subtract y = 1, and then either subtract y = 1 again or divide by z = 2.\n\nTherefore, there are five ways in total.", "test_cases": {"inputs": ["5 998244353\n", "42 998244353\n", "3 998244353\n", "6 732284177\n", "634 982032773\n", "199862 999999937\n", "2 554714911\n", "124953 922406879\n", "8045 992942057\n", "200000 665880409\n", "158032 121694641\n", "199568 100000007\n", "48 166017469\n", "200000 187160003\n", "199995 597768679\n", "200000 558920641\n", "199660 160959167\n", "191683 549754339\n", "349 528449821\n", "140750 872921717\n", "6 1390462132\n", "1049 982032773\n", "4 554714911\n", "59857 922406879\n", "11821 992942057\n", "25184 665880409\n", "158032 108325441\n", "65711 100000007\n", "48 250636721\n", "162685 187160003\n", "197426 597768679\n", "200000 316925344\n", "199660 117675997\n", "349 602811213\n", "140750 887458748\n", "5 638085038\n", "83 998244353\n", "3 1205924298\n", "1819 982032773\n", "33754 922406879\n", "25184 636766460\n", "46721 108325441\n", "65711 15505247\n", "95 250636721\n", "197426 364348492\n", "199660 52002887\n", "581 602811213\n", "83 469355691\n", "3568 982032773\n", "14760 636766460\n"], "outputs": ["25", "793019428", "5", "55", "695544646", "750469605", "2", "768303295", "882251038", "86083213", "114975792", "31278679", "119670181", "147468989", "390104637", "14322946", "32483089", "207301921", "190306170", "17972639", "55\n", "471592080\n", "12\n", "831986499\n", "257412568\n", "409096655\n", "47582277\n", "11333950\n", "158347232\n", "175888140\n", "54217445\n", "253547906\n", "44508239\n", "70144617\n", "669831877\n", "25\n", "436912026\n", "5\n", "287588159\n", "270535288\n", "261135210\n", "86700212\n", "1951828\n", "249812670\n", "289708472\n", "10533840\n", "542179078\n", "439789304\n", "353478967\n", "272754163\n"]}, "starter_code": "", "problem_sha1": "399ead8c549d8fc9034d3bcb10d40037fd49d658", "n_test_cases_total": 220, "n_test_cases_kept": 50, "test_cases_truncated": true, "seed_id": "cc-06490", "original_id": null, "source": "code_contests", "domain": "code", "test_case_format": "stdin_stdout", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": null} {"problem": "A binary string is a string that consists of characters 0 and 1.\n\nLet \\operatorname{MEX} of a binary string be the smallest digit among 0, 1, or 2 that does not occur in the string. For example, \\operatorname{MEX} of 001011 is 2, because 0 and 1 occur in the string at least once, \\operatorname{MEX} of 1111 is 0, because 0 and 2 do not occur in the string and 0 < 2.\n\nA binary string s is given. You should cut it into any number of substrings such that each character is in exactly one substring. It is possible to cut the string into a single substring — the whole string.\n\nA string a is a substring of a string b if a can be obtained from b by deletion of several (possibly, zero or all) characters from the beginning and several (possibly, zero or all) characters from the end.\n\nWhat is the minimal sum of \\operatorname{MEX} of all substrings pieces can be?\n\nInput\n\nThe input consists of multiple test cases. The first line contains a single integer t (1 ≤ t ≤ 10^4) — the number of test cases. Description of the test cases follows.\n\nEach test case contains a single binary string s (1 ≤ |s| ≤ 10^5).\n\nIt's guaranteed that the sum of lengths of s over all test cases does not exceed 10^5.\n\nOutput\n\nFor each test case print a single integer — the minimal sum of \\operatorname{MEX} of all substrings that it is possible to get by cutting s optimally.\n\nExample\n\nInput\n\n\n6\n01\n1111\n01100\n101\n0000\n01010\n\n\nOutput\n\n\n1\n0\n2\n1\n1\n2\n\nNote\n\nIn the first test case the minimal sum is \\operatorname{MEX}(0) + \\operatorname{MEX}(1) = 1 + 0 = 1.\n\nIn the second test case the minimal sum is \\operatorname{MEX}(1111) = 0.\n\nIn the third test case the minimal sum is \\operatorname{MEX}(01100) = 2.", "test_cases": {"inputs": ["6\n01\n1111\n01100\n101\n0000\n01010\n", "6\n01\n1111\n01100\n100\n0000\n01010\n", "6\n01\n1011\n01100\n100\n0000\n01010\n", "6\n01\n1001\n01100\n111\n0000\n01010\n", "6\n1\n1001\n01100\n111\n0000\n01010\n", "6\n01\n1010\n01100\n100\n0000\n01010\n", "6\n1\n1001\n01100\n101\n0000\n01010\n", "6\n01\n1010\n11100\n100\n0000\n01010\n", "6\n01\n1001\n11100\n100\n0000\n11010\n", "6\n1\n1111\n01100\n101\n1000\n11010\n", "6\n1\n1010\n11100\n100\n0000\n01010\n", "6\n01\n1001\n11100\n100\n0000\n11011\n", "6\n0\n1011\n01100\n010\n0000\n01010\n", "6\n0\n1001\n01100\n110\n0010\n01010\n", "6\n0\n1001\n01100\n111\n0010\n01010\n", "6\n01\n1111\n01101\n100\n1000\n11110\n", "6\n1\n0010\n01100\n100\n0000\n01010\n", "6\n01\n1001\n11100\n100\n0001\n11111\n", "6\n01\n1111\n01101\n100\n1010\n11010\n", "6\n1\n1001\n11100\n100\n0011\n11111\n", "6\n1\n1001\n11100\n100\n0011\n11110\n", "6\n1\n1001\n11100\n000\n0010\n11110\n", "6\n1\n1001\n11100\n010\n0010\n11110\n", "6\n1\n1001\n11100\n000\n0110\n11010\n", "6\n1\n1001\n11000\n000\n0111\n11010\n", "6\n1\n1000\n11010\n000\n0101\n11010\n", "6\n1\n1000\n11010\n000\n0101\n11011\n", "6\n1\n1000\n11010\n100\n0111\n11011\n", "6\n1\n1100\n11010\n000\n0101\n11111\n", "6\n1\n1100\n11010\n010\n0101\n11111\n", "6\n1\n1100\n11010\n010\n0101\n11110\n", "6\n1\n1100\n10010\n010\n0111\n11110\n", "6\n1\n1100\n10010\n010\n0111\n11010\n", "6\n1\n1000\n11010\n111\n0111\n11110\n", "6\n1\n1000\n11010\n111\n0110\n11110\n", "6\n1\n1010\n11010\n111\n0110\n11110\n", "6\n1\n1010\n11010\n111\n1110\n11110\n", "6\n1\n1010\n11100\n100\n0010\n01010\n", "6\n01\n1001\n11100\n100\n0100\n11011\n", "6\n0\n1001\n01100\n010\n0010\n01010\n", "6\n01\n1111\n01101\n100\n1000\n11111\n", "6\n1\n0010\n01101\n100\n0010\n01010\n", "6\n1\n1001\n11100\n010\n0011\n11110\n", "6\n0\n1001\n00000\n011\n0110\n01000\n", "6\n0\n1000\n11010\n100\n0111\n11011\n", "6\n1\n0100\n11010\n000\n0101\n11111\n", "6\n1\n1100\n10010\n010\n0110\n11010\n", "6\n1\n1010\n11010\n011\n0110\n11000\n", "6\n1\n1000\n11000\n111\n0111\n11110\n", "6\n0\n1010\n11010\n111\n0110\n11110\n"], "outputs": ["1\n0\n2\n1\n1\n2\n", "1\n0\n2\n1\n1\n2\n", "1\n1\n2\n1\n1\n2\n", "1\n1\n2\n0\n1\n2\n", "0\n1\n2\n0\n1\n2\n", "1\n2\n2\n1\n1\n2\n", "0\n1\n2\n1\n1\n2\n", "1\n2\n1\n1\n1\n2\n", "1\n1\n1\n1\n1\n2\n", "0\n0\n2\n1\n1\n2\n", "0\n2\n1\n1\n1\n2\n", "1\n1\n1\n1\n1\n1\n", "1\n1\n2\n2\n1\n2\n", "1\n1\n2\n1\n2\n2\n", "1\n1\n2\n0\n2\n2\n", "1\n0\n2\n1\n1\n1\n", "0\n2\n2\n1\n1\n2\n", "1\n1\n1\n1\n1\n0\n", "1\n0\n2\n1\n2\n2\n", "0\n1\n1\n1\n1\n0\n", "0\n1\n1\n1\n1\n1\n", "0\n1\n1\n1\n2\n1\n", "0\n1\n1\n2\n2\n1\n", "0\n1\n1\n1\n2\n2\n", "0\n1\n1\n1\n1\n2\n", "0\n1\n2\n1\n2\n2\n", "0\n1\n2\n1\n2\n1\n", "0\n1\n2\n1\n1\n1\n", "0\n1\n2\n1\n2\n0\n", "0\n1\n2\n2\n2\n0\n", "0\n1\n2\n2\n2\n1\n", "0\n1\n2\n2\n1\n1\n", "0\n1\n2\n2\n1\n2\n", "0\n1\n2\n0\n1\n1\n", "0\n1\n2\n0\n2\n1\n", "0\n2\n2\n0\n2\n1\n", "0\n2\n2\n0\n1\n1\n", "0\n2\n1\n1\n2\n2\n", "1\n1\n1\n1\n2\n1\n", "1\n1\n2\n2\n2\n2\n", "1\n0\n2\n1\n1\n0\n", "0\n2\n2\n1\n2\n2\n", "0\n1\n1\n2\n1\n1\n", "1\n1\n1\n1\n2\n2\n", "1\n1\n2\n1\n1\n1\n", "0\n2\n2\n1\n2\n0\n", "0\n1\n2\n2\n2\n2\n", "0\n2\n2\n1\n2\n1\n", "0\n1\n1\n0\n1\n1\n", "1\n2\n2\n0\n2\n1\n"]}, "starter_code": "", "problem_sha1": "e1625c1ffc589e90c72ff034ed67ef24f97d58f3", "n_test_cases_total": 201, "n_test_cases_kept": 50, "test_cases_truncated": true, "seed_id": "cc-06495", "original_id": null, "source": "code_contests", "domain": "code", "test_case_format": "stdin_stdout", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": null} {"problem": "You are given a string s, consisting of n letters, each letter is either 'a' or 'b'. The letters in the string are numbered from 1 to n.\n\ns[l; r] is a continuous substring of letters from index l to r of the string inclusive. \n\nA string is called balanced if the number of letters 'a' in it is equal to the number of letters 'b'. For example, strings \"baba\" and \"aabbab\" are balanced and strings \"aaab\" and \"b\" are not.\n\nFind any non-empty balanced substring s[l; r] of string s. Print its l and r (1 ≤ l ≤ r ≤ n). If there is no such substring, then print -1 -1.\n\nInput\n\nThe first line contains a single integer t (1 ≤ t ≤ 1000) — the number of testcases.\n\nThen the descriptions of t testcases follow.\n\nThe first line of the testcase contains a single integer n (1 ≤ n ≤ 50) — the length of the string.\n\nThe second line of the testcase contains a string s, consisting of n letters, each letter is either 'a' or 'b'.\n\nOutput\n\nFor each testcase print two integers. If there exists a non-empty balanced substring s[l; r], then print l r (1 ≤ l ≤ r ≤ n). Otherwise, print -1 -1.\n\nExample\n\nInput\n\n\n4\n1\na\n6\nabbaba\n6\nabbaba\n9\nbabbabbaa\n\n\nOutput\n\n\n-1 -1\n1 6\n3 6\n2 5\n\nNote\n\nIn the first testcase there are no non-empty balanced subtrings.\n\nIn the second and third testcases there are multiple balanced substrings, including the entire string \"abbaba\" and substring \"baba\".", "test_cases": {"inputs": ["4\n1\na\n6\nabbaba\n6\nabbaba\n9\nbabbabbaa\n", "1\n30\naaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n", "1\n29\naaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n", "4\n1\na\n6\nabbaba\n6\nabbaba\n9\nbabbabbaa\n", "4\n1\na\n6\nabbaba\n6\nabbaba\n7\nbabbabbaa\n", "1\n29\naabaaaaaaaaaaaaaaaaaaaaaaaaaa\n", "1\n27\naaaaaaaaaabaaaaaaaaaababaabaa\n", "4\n1\na\n6\nababba\n6\nabbaba\n9\nbbababbaa\n", "4\n1\na\n6\nababba\n6\nbbbaba\n9\nbbababbaa\n", "1\n17\naaabaaaaaabaaaaaaaaaabbbaabaa\n", "1\n21\naaaaabaabaaaaaaaaaaaaaabaabaa\n", "1\n14\naaaaaaabaabaaaaaaaaaababaab`a\n", "1\n6\nbaaaaaaaaabaaaa`aaaaababaabaa\n", "1\n29\naaaaaaaaaaaaaaaaaaaaaaaaaabaa\n", "1\n17\naaaaaaaaaaaabaaaaaaaabbbaabaa\n", "1\n30\naaaaaaaaaaabaaaaaaaaaaaaaaaaaa\n", "1\n8\naaaaaabaaaab`aaaaa`aaabaaaaaa\n", "1\n29\naaaaaaaabaaaaaaaaaaaaaabaabaa\n", "1\n30\naaaaaaaaaaaaaaaaaabaaaaaaaaaaa\n", "1\n21\naabaaaaaaaaaaaaaaaaaaaaaaaaaa\n", "1\n21\naabaabaaaaaaaaaaaaaaaaaaaaaaa\n", "1\n21\naabaababaaaaaaaaaaaaaaaaaaaaa\n", "1\n21\naabaababaaaaaaaaaabaaaaaaaaaa\n", "1\n27\naabaababaaaaaaaaaabaaaaaaaaaa\n", "1\n17\naaaaaaaaaabaaaaaaaaaababaabaa\n", "1\n17\naaaaaaaaaabaaaaaaaaaabbbaabaa\n", "4\n1\na\n6\nababba\n6\nabbaba\n9\nbabbabbaa\n", "1\n21\naabaabaaaaaaaaaaaaaabaaaaaaaa\n", "1\n14\naabaababaaaaaaaaaabaaaaaaaaaa\n", "1\n27\naabaabaaaaaaabaaaabaaaaaaaaaa\n", "1\n27\naabaababaaaaaaaaaabaaaaaaaaab\n", "1\n19\naaaaaaaaaabaaaaaaaaaababaabaa\n", "1\n10\naabaababaaaaaaaaaabaaaaaaaaaa\n", "1\n3\naabaababaaaaaaaaaabaaaaaaaaab\n", "1\n10\naabaababaaaaaaaaaaaaaaaaaaaaa\n", "1\n8\naabaaaaaaaaaaaaaaaaaaaaaaaaaa\n", "1\n5\naabaababaaaaaaaaaabaaaaaaaaaa\n", "1\n27\naaaaaaaaaababaaaaaaaababaabaa\n", "1\n21\naaaaaaaaaabaaaaaaaaaababaabaa\n", "4\n1\nb\n6\nababba\n6\nabbaba\n9\nbabbabbaa\n", "1\n21\naabaabaaaaaaaaaaaaaabaabaaaaa\n", "1\n14\naaaaaaaaaabaaaaaaaaaababaabaa\n", "1\n19\naabaababaaaaaaaaaabaaaaaaaaaa\n", "1\n3\naabaababaaaaa`aaaabaaaaaaaaab\n", "1\n10\naabaababaaaaaaaaaaaaaaaaaa`aa\n", "1\n8\naabaaaaaaaaaaaaaaa`aaaaaaaaaa\n", "1\n21\naabaabababaaaaaaaabaaaaaaaaaa\n", "1\n15\naaabaaaaaabaaaaaaaaaabbbaabaa\n", "1\n14\naaaaaaaaaabaaaaaaaaaababaab`a\n", "1\n19\naabaababaaaaaaaaaabbaaaaaaaaa\n"], "outputs": ["-1 -1\n1 2\n1 2\n1 2\n", "-1 -1\n", "-1 -1\n", "-1 -1\n1 2\n1 2\n1 2\n", "-1 -1\n1 2\n1 2\n1 2\n", "2 3\n", "10 11\n", "-1 -1\n1 2\n1 2\n2 3\n", "-1 -1\n1 2\n3 4\n2 3\n", "3 4\n", "5 6\n", "7 8\n", "1 2\n", "26 27\n", "12 13\n", "11 12\n", "6 7\n", "8 9\n", "18 19\n", "2 3\n", "2 3\n", "2 3\n", "2 3\n", "2 3\n", "10 11\n", "10 11\n", "-1 -1\n1 2\n1 2\n1 2\n", "2 3\n", "2 3\n", "2 3\n", "2 3\n", "10 11\n", "2 3\n", "2 3\n", "2 3\n", "2 3\n", "2 3\n", "10 11\n", "10 11\n", "-1 -1\n1 2\n1 2\n1 2\n", "2 3\n", "10 11\n", "2 3\n", "2 3\n", "2 3\n", "2 3\n", "2 3\n", "3 4\n", "10 11\n", "2 3\n"]}, "starter_code": "", "problem_sha1": "dcfcb2d6ae0e94fcd657bad1316bc03c4534cc79", "n_test_cases_total": 204, "n_test_cases_kept": 50, "test_cases_truncated": true, "seed_id": "cc-06500", "original_id": null, "source": "code_contests", "domain": "code", "test_case_format": "stdin_stdout", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": null} {"problem": "You are given four integer values a, b, c and m.\n\nCheck if there exists a string that contains: \n\n * a letters 'A'; \n * b letters 'B'; \n * c letters 'C'; \n * no other letters; \n * exactly m pairs of adjacent equal letters (exactly m such positions i that the i-th letter is equal to the (i+1)-th one). \n\nInput\n\nThe first line contains a single integer t (1 ≤ t ≤ 10^4) — the number of testcases.\n\nEach of the next t lines contains the description of the testcase — four integers a, b, c and m (1 ≤ a, b, c ≤ 10^8; 0 ≤ m ≤ 10^8).\n\nOutput\n\nFor each testcase print \"YES\" if there exists a string that satisfies all the requirements. Print \"NO\" if there are no such strings.\n\nYou may print every letter in any case you want (so, for example, the strings yEs, yes, Yes and YES will all be recognized as positive answer).\n\nExample\n\nInput\n\n\n3\n2 2 1 0\n1 1 1 1\n1 2 3 2\n\n\nOutput\n\n\nYES\nNO\nYES\n\nNote\n\nIn the first testcase strings \"ABCAB\" or \"BCABA\" satisfy the requirements. There exist other possible strings.\n\nIn the second testcase there's no way to put adjacent equal letters if there's no letter that appears at least twice.\n\nIn the third testcase string \"CABBCC\" satisfies the requirements. There exist other possible strings.", "test_cases": {"inputs": ["3\n2 2 1 0\n1 1 1 1\n1 2 3 2\n", "1\n1 2 2 114514\n", "1\n1 1 1 1919810\n", "1\n1 1 1 46\n", "1\n114514 1 1 1919810\n", "2\n23 1 2 1\n1 1 1 46\n", "1\n1 2 2 70572\n", "2\n23 1 2 1\n2 1 1 46\n", "2\n5 1 1 2\n2 4 1 8\n", "3\n3 2 1 0\n1 1 1 1\n1 2 3 2\n", "2\n5 1 1 2\n2 4 1 2\n", "1\n2 1 4 4\n", "3\n3 2 1 0\n1 1 1 1\n1 2 3 6\n", "2\n23 1 2 4\n2 1 2 0\n", "3\n2 2 1 0\n2 1 1 1\n1 2 3 2\n", "1\n1 1 2 1919810\n", "1\n1 1 2 46\n", "1\n35936 1 1 1919810\n", "1\n1 2 2 34959\n", "1\n1 1 2 2722288\n", "1\n1 1 2 55\n", "1\n59831 1 1 1919810\n", "2\n23 1 2 2\n2 1 1 46\n", "1\n1 2 2 14130\n", "1\n1 0 2 2722288\n", "1\n1 1 3 55\n", "1\n59831 1 1 250092\n", "2\n23 1 2 2\n2 1 1 18\n", "1\n1 2 2 26497\n", "1\n1 0 1 2722288\n", "1\n1 2 3 55\n", "1\n1253 1 1 250092\n", "2\n23 1 2 4\n2 1 1 18\n", "1\n2 2 2 26497\n", "1\n1 0 2 4187757\n", "1\n1 1 4 55\n", "2\n40 1 2 4\n2 1 1 18\n", "1\n2 1 2 26497\n", "1\n1 1 2 4187757\n", "1\n1 1 4 107\n", "2\n40 1 2 4\n2 1 1 36\n", "1\n2 1 2 38332\n", "1\n1 2 2 4187757\n", "1\n1 2 4 107\n", "2\n40 1 2 4\n2 2 1 36\n", "1\n2 1 2 57583\n", "1\n1 3 2 4187757\n", "1\n1 2 0 107\n", "2\n69 1 2 4\n2 2 1 36\n", "1\n3 1 2 57583\n"], "outputs": ["YES\nNO\nYES\n", "NO\n", "NO\n", "NO\n", "NO\n", "NO\nNO\n", "NO\n", "NO\nNO\n", "YES\nNO\n", "YES\nNO\nYES\n", "YES\nYES\n", "YES\n", "YES\nNO\nNO\n", "NO\nYES\n", "YES\nYES\nYES\n", "NO\n", "NO\n", "NO\n", "NO\n", "NO\n", "NO\n", "NO\n", "NO\nNO\n", "NO\n", "NO\n", "NO\n", "NO\n", "NO\nNO\n", "NO\n", "NO\n", "NO\n", "NO\n", "NO\nNO\n", "NO\n", "NO\n", "NO\n", "NO\nNO\n", "NO\n", "NO\n", "NO\n", "NO\nNO\n", "NO\n", "NO\n", "NO\n", "NO\nNO\n", "NO\n", "NO\n", "NO\n", "NO\nNO\n", "NO\n"]}, "starter_code": "", "problem_sha1": "e2b11c3f8cae4aa5e6e1c5efde80c9851488b63f", "n_test_cases_total": 206, "n_test_cases_kept": 50, "test_cases_truncated": true, "seed_id": "cc-06505", "original_id": null, "source": "code_contests", "domain": "code", "test_case_format": "stdin_stdout", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": null} {"seed_id": "apps-00003", "original_id": null, "source": "apps", "domain": "code", "problem": "Alice and Bob play a game. They have a binary string $s$ (a string such that each character in it is either $0$ or $1$). Alice moves first, then Bob, then Alice again, and so on.\n\nDuring their move, the player can choose any number (not less than one) of consecutive equal characters in $s$ and delete them.\n\nFor example, if the string is $10110$, there are $6$ possible moves (deleted characters are bold): $\\textbf{1}0110 \\to 0110$; $1\\textbf{0}110 \\to 1110$; $10\\textbf{1}10 \\to 1010$; $101\\textbf{1}0 \\to 1010$; $10\\textbf{11}0 \\to 100$; $1011\\textbf{0} \\to 1011$. \n\nAfter the characters are removed, the characters to the left and to the right of the removed block become adjacent. I. e. the following sequence of moves is valid: $10\\textbf{11}0 \\to 1\\textbf{00} \\to 1$.\n\nThe game ends when the string becomes empty, and the score of each player is the number of $1$-characters deleted by them.\n\nEach player wants to maximize their score. Calculate the resulting score of Alice.\n\n\n-----Input-----\n\nThe first line contains one integer $T$ ($1 \\le T \\le 500$) — the number of test cases.\n\nEach test case contains exactly one line containing a binary string $s$ ($1 \\le |s| \\le 100$).\n\n\n-----Output-----\n\nFor each test case, print one integer — the resulting score of Alice (the number of $1$-characters deleted by her).\n\n\n-----Example-----\nInput\n5\n01111001\n0000\n111111\n101010101\n011011110111\n\nOutput\n4\n0\n6\n3\n6\n\n\n\n-----Note-----\n\nQuestions about the optimal strategy will be ignored.", "starter_code": "", "test_cases": {"inputs": ["5\n01111001\n0000\n111111\n101010101\n011011110111\n"], "outputs": ["4\n0\n6\n3\n6\n"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "b540f037b4a93966bdfd32c4266cae034eb9e707", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-00008", "original_id": null, "source": "apps", "domain": "code", "problem": "There are $n$ positive integers $a_1, a_2, \\dots, a_n$. For the one move you can choose any even value $c$ and divide by two all elements that equal $c$.\n\nFor example, if $a=[6,8,12,6,3,12]$ and you choose $c=6$, and $a$ is transformed into $a=[3,8,12,3,3,12]$ after the move.\n\nYou need to find the minimal number of moves for transforming $a$ to an array of only odd integers (each element shouldn't be divisible by $2$).\n\n\n-----Input-----\n\nThe first line of the input contains one integer $t$ ($1 \\le t \\le 10^4$) — the number of test cases in the input. Then $t$ test cases follow.\n\nThe first line of a test case contains $n$ ($1 \\le n \\le 2\\cdot10^5$) — the number of integers in the sequence $a$. The second line contains positive integers $a_1, a_2, \\dots, a_n$ ($1 \\le a_i \\le 10^9$).\n\nThe sum of $n$ for all test cases in the input doesn't exceed $2\\cdot10^5$.\n\n\n-----Output-----\n\nFor $t$ test cases print the answers in the order of test cases in the input. The answer for the test case is the minimal number of moves needed to make all numbers in the test case odd (i.e. not divisible by $2$).\n\n\n-----Example-----\nInput\n4\n6\n40 6 40 3 20 1\n1\n1024\n4\n2 4 8 16\n3\n3 1 7\n\nOutput\n4\n10\n4\n0\n\n\n\n-----Note-----\n\nIn the first test case of the example, the optimal sequence of moves can be as follows:\n\n before making moves $a=[40, 6, 40, 3, 20, 1]$; choose $c=6$; now $a=[40, 3, 40, 3, 20, 1]$; choose $c=40$; now $a=[20, 3, 20, 3, 20, 1]$; choose $c=20$; now $a=[10, 3, 10, 3, 10, 1]$; choose $c=10$; now $a=[5, 3, 5, 3, 5, 1]$ — all numbers are odd. \n\nThus, all numbers became odd after $4$ moves. In $3$ or fewer moves, you cannot make them all odd.", "starter_code": "", "test_cases": {"inputs": ["4\n6\n40 6 40 3 20 1\n1\n1024\n4\n2 4 8 16\n3\n3 1 7\n"], "outputs": ["4\n10\n4\n0\n"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "beec331d46540560eacae212d1ebb602e4492c46", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-00013", "original_id": null, "source": "apps", "domain": "code", "problem": "You are given an array $a$ of length $n$, which initially is a permutation of numbers from $1$ to $n$. In one operation, you can choose an index $i$ ($1 \\leq i < n$) such that $a_i < a_{i + 1}$, and remove either $a_i$ or $a_{i + 1}$ from the array (after the removal, the remaining parts are concatenated). \n\nFor example, if you have the array $[1, 3, 2]$, you can choose $i = 1$ (since $a_1 = 1 < a_2 = 3$), then either remove $a_1$ which gives the new array $[3, 2]$, or remove $a_2$ which gives the new array $[1, 2]$.\n\nIs it possible to make the length of this array equal to $1$ with these operations?\n\n\n-----Input-----\n\nThe first line contains a single integer $t$ ($1 \\leq t \\leq 2 \\cdot 10^4$)  — the number of test cases. The description of the test cases follows.\n\nThe first line of each test case contains a single integer $n$ ($2 \\leq n \\leq 3 \\cdot 10^5$)  — the length of the array.\n\nThe second line of each test case contains $n$ integers $a_1$, $a_2$, ..., $a_n$ ($1 \\leq a_i \\leq n$, $a_i$ are pairwise distinct) — elements of the array.\n\nIt is guaranteed that the sum of $n$ over all test cases doesn't exceed $3 \\cdot 10^5$.\n\n\n-----Output-----\n\nFor each test case, output on a single line the word \"YES\" if it is possible to reduce the array to a single element using the aforementioned operation, or \"NO\" if it is impossible to do so.\n\n\n-----Example-----\nInput\n4\n3\n1 2 3\n4\n3 1 2 4\n3\n2 3 1\n6\n2 4 6 1 3 5\n\nOutput\nYES\nYES\nNO\nYES\n\n\n\n-----Note-----\n\nFor the first two test cases and the fourth test case, we can operate as follow (the bolded elements are the pair chosen for that operation):\n\n$[\\text{1}, \\textbf{2}, \\textbf{3}] \\rightarrow [\\textbf{1}, \\textbf{2}] \\rightarrow [\\text{1}]$\n\n$[\\text{3}, \\textbf{1}, \\textbf{2}, \\text{4}] \\rightarrow [\\text{3}, \\textbf{1}, \\textbf{4}] \\rightarrow [\\textbf{3}, \\textbf{4}] \\rightarrow [\\text{4}]$\n\n$[\\textbf{2}, \\textbf{4}, \\text{6}, \\text{1}, \\text{3}, \\text{5}] \\rightarrow [\\textbf{4}, \\textbf{6}, \\text{1}, \\text{3}, \\text{5}] \\rightarrow [\\text{4}, \\text{1}, \\textbf{3}, \\textbf{5}] \\rightarrow [\\text{4}, \\textbf{1}, \\textbf{5}] \\rightarrow [\\textbf{4}, \\textbf{5}] \\rightarrow [\\text{4}]$", "starter_code": "", "test_cases": {"inputs": ["4\n3\n1 2 3\n4\n3 1 2 4\n3\n2 3 1\n6\n2 4 6 1 3 5\n"], "outputs": ["YES\nYES\nNO\nYES\n"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "a8c4d756aada6aed175e13e5b912ba534b3d1a0b", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-00018", "original_id": null, "source": "apps", "domain": "code", "problem": "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) $c_i$ with either $a_i$ or $b_i$. So in total you'll perform exactly $n$ swap operations, each of them either $c_i \\leftrightarrow a_i$ or $c_i \\leftrightarrow b_i$ ($i$ iterates over all integers between $1$ and $n$, inclusive).\n\nFor example, if $a$ is \"code\", $b$ is \"true\", and $c$ is \"help\", you can make $c$ equal to \"crue\" taking the $1$-st and the $4$-th letters from $a$ and the others from $b$. In this way $a$ becomes \"hodp\" and $b$ becomes \"tele\".\n\nIs it possible that after these swaps the string $a$ becomes exactly the same as the string $b$?\n\n\n-----Input-----\n\nThe input consists of multiple test cases. The first line contains a single integer $t$ ($1 \\leq t \\leq 100$)  — the number of test cases. The description of the test cases follows.\n\nThe first line of each test case contains a string of lowercase English letters $a$.\n\nThe second line of each test case contains a string of lowercase English letters $b$.\n\nThe third line of each test case contains a string of lowercase English letters $c$.\n\nIt is guaranteed that in each test case these three strings are non-empty and have the same length, which is not exceeding $100$.\n\n\n-----Output-----\n\nPrint $t$ lines with answers for all test cases. For each test case:\n\nIf it is possible to make string $a$ equal to string $b$ print \"YES\" (without quotes), otherwise print \"NO\" (without quotes).\n\nYou can print either lowercase or uppercase letters in the answers.\n\n\n-----Example-----\nInput\n4\naaa\nbbb\nccc\nabc\nbca\nbca\naabb\nbbaa\nbaba\nimi\nmii\niim\n\nOutput\nNO\nYES\nYES\nNO\n\n\n\n-----Note-----\n\nIn the first test case, it is impossible to do the swaps so that string $a$ becomes exactly the same as string $b$.\n\nIn the second test case, you should swap $c_i$ with $a_i$ for all possible $i$. After the swaps $a$ becomes \"bca\", $b$ becomes \"bca\" and $c$ becomes \"abc\". Here the strings $a$ and $b$ are equal.\n\nIn the third test case, you should swap $c_1$ with $a_1$, $c_2$ with $b_2$, $c_3$ with $b_3$ and $c_4$ with $a_4$. Then string $a$ becomes \"baba\", string $b$ becomes \"baba\" and string $c$ becomes \"abab\". Here the strings $a$ and $b$ are equal.\n\nIn the fourth test case, it is impossible to do the swaps so that string $a$ becomes exactly the same as string $b$.", "starter_code": "", "test_cases": {"inputs": ["4\naaa\nbbb\nccc\nabc\nbca\nbca\naabb\nbbaa\nbaba\nimi\nmii\niim\n"], "outputs": ["NO\nYES\nYES\nNO\n"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "aced6436b98571f41452b822382b91aca016d9c0", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-00023", "original_id": null, "source": "apps", "domain": "code", "problem": "There are several cards arranged in a row, and each card has an associated number of points The points are given in the integer array cardPoints.\nIn one step, you can take one card from the beginning or from the end of the row. You have to take exactly k cards.\nYour score is the sum of the points of the cards you have taken.\nGiven the integer array cardPoints and the integer k, return the maximum score you can obtain.\n \nExample 1:\nInput: cardPoints = [1,2,3,4,5,6,1], k = 3\nOutput: 12\nExplanation: After the first step, your score will always be 1. However, choosing the rightmost card first will maximize your total score. The optimal strategy is to take the three cards on the right, giving a final score of 1 + 6 + 5 = 12.\n\nExample 2:\nInput: cardPoints = [2,2,2], k = 2\nOutput: 4\nExplanation: Regardless of which two cards you take, your score will always be 4.\n\nExample 3:\nInput: cardPoints = [9,7,7,9,7,7,9], k = 7\nOutput: 55\nExplanation: You have to take all the cards. Your score is the sum of points of all cards.\n\nExample 4:\nInput: cardPoints = [1,1000,1], k = 1\nOutput: 1\nExplanation: You cannot take the card in the middle. Your best score is 1. \n\nExample 5:\nInput: cardPoints = [1,79,80,1,1,1,200,1], k = 3\nOutput: 202\n\n \nConstraints:\n\n1 <= cardPoints.length <= 10^5\n1 <= cardPoints[i] <= 10^4\n1 <= k <= cardPoints.length", "starter_code": "\nclass Solution:\n def maxScore(self, cardPoints: List[int], k: int) -> int:\n ", "test_cases": {"inputs": [[[1, 2, 3, 4, 5, 6, 1], 3]], "outputs": [12], "fn_name": "maxScore"}, "test_case_format": "function_call", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "18a729dc0929b33a09f397766f358bbc5fc99e70", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "maxScore"} {"seed_id": "apps-00028", "original_id": null, "source": "apps", "domain": "code", "problem": "There is a group of G members, and a list of various crimes they could commit.\nThe ith crime generates a profit[i] and requires group[i] members to participate in it.\nIf a member participates in one crime, that member can't participate in another crime.\nLet's call a profitable scheme any subset of these crimes that generates at least P profit, and the total number of members participating in that subset of crimes is at most G.\nHow many schemes can be chosen?  Since the answer may be very large, return it modulo 10^9 + 7.\n \nExample 1:\nInput: G = 5, P = 3, group = [2,2], profit = [2,3]\nOutput: 2\nExplanation: \nTo make a profit of at least 3, the group could either commit crimes 0 and 1, or just crime 1.\nIn total, there are 2 schemes.\n\n\nExample 2:\nInput: G = 10, P = 5, group = [2,3,5], profit = [6,7,8]\nOutput: 7\nExplanation: \nTo make a profit of at least 5, the group could commit any crimes, as long as they commit one.\nThere are 7 possible schemes: (0), (1), (2), (0,1), (0,2), (1,2), and (0,1,2).\n\n \n\nNote:\n\n1 <= G <= 100\n0 <= P <= 100\n1 <= group[i] <= 100\n0 <= profit[i] <= 100\n1 <= group.length = profit.length <= 100", "starter_code": "\nclass Solution:\n def profitableSchemes(self, G: int, P: int, group: List[int], profit: List[int]) -> int:\n ", "test_cases": {"inputs": [[5, 3, [2, 2], [2, 3]]], "outputs": [2], "fn_name": "profitableSchemes"}, "test_case_format": "function_call", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "fa76b728665c4da64a4682f5406a141971de1db7", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "profitableSchemes"} {"seed_id": "apps-00033", "original_id": null, "source": "apps", "domain": "code", "problem": "Given two sequences pushed and popped with distinct values, return true if and only if this could have been the result of a sequence of push and pop operations on an initially empty stack.\n \n\nExample 1:\nInput: pushed = [1,2,3,4,5], popped = [4,5,3,2,1]\nOutput: true\nExplanation: We might do the following sequence:\npush(1), push(2), push(3), push(4), pop() -> 4,\npush(5), pop() -> 5, pop() -> 3, pop() -> 2, pop() -> 1\n\n\nExample 2:\nInput: pushed = [1,2,3,4,5], popped = [4,3,5,1,2]\nOutput: false\nExplanation: 1 cannot be popped before 2.\n\n\n\n \nConstraints:\n\n0 <= pushed.length == popped.length <= 1000\n0 <= pushed[i], popped[i] < 1000\npushed is a permutation of popped.\npushed and popped have distinct values.", "starter_code": "\nclass Solution:\n def validateStackSequences(self, pushed: List[int], popped: List[int]) -> bool:\n ", "test_cases": {"inputs": [[[1, 2, 3, 4, 5], [4, 5, 3, 2, 1]]], "outputs": [true], "fn_name": "validateStackSequences"}, "test_case_format": "function_call", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "46133ee99e845fd4c31d87b3f8012de8245c4308", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "validateStackSequences"} {"seed_id": "apps-00038", "original_id": null, "source": "apps", "domain": "code", "problem": "The i-th person has weight people[i], and each boat can carry a maximum weight of limit.\nEach boat carries at most 2 people at the same time, provided the sum of the weight of those people is at most limit.\nReturn the minimum number of boats to carry every given person.  (It is guaranteed each person can be carried by a boat.)\n \n\nExample 1:\nInput: people = [1,2], limit = 3\nOutput: 1\nExplanation: 1 boat (1, 2)\n\n\nExample 2:\nInput: people = [3,2,2,1], limit = 3\nOutput: 3\nExplanation: 3 boats (1, 2), (2) and (3)\n\n\nExample 3:\nInput: people = [3,5,3,4], limit = 5\nOutput: 4\nExplanation: 4 boats (3), (3), (4), (5)\nNote:\n\n1 <= people.length <= 50000\n1 <= people[i] <= limit <= 30000", "starter_code": "\nclass Solution:\n def numRescueBoats(self, people: List[int], limit: int) -> int:\n ", "test_cases": {"inputs": [[[1, 2], 3]], "outputs": [1], "fn_name": "numRescueBoats"}, "test_case_format": "function_call", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "0093b677f471065e19cf49a96a501ab3aec4d92c", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "numRescueBoats"} {"seed_id": "apps-00043", "original_id": null, "source": "apps", "domain": "code", "problem": "Given an encoded string, return it's decoded string.\n\n\nThe encoding rule is: k[encoded_string], where the encoded_string inside the square brackets is being repeated exactly k times. Note that k is guaranteed to be a positive integer.\n\n\nYou may assume that the input string is always valid; No extra white spaces, square brackets are well-formed, etc.\n\nFurthermore, you may assume that the original data does not contain any digits and that digits are only for those repeat numbers, k. For example, there won't be input like 3a or 2[4].\n\n\nExamples:\n\ns = \"3[a]2[bc]\", return \"aaabcbc\".\ns = \"3[a2[c]]\", return \"accaccacc\".\ns = \"2[abc]3[cd]ef\", return \"abcabccdcdcdef\".", "starter_code": "\nclass Solution:\n def decodeString(self, s: str) -> str:\n ", "test_cases": {"inputs": [["\"3[a]2[bc]\""]], "outputs": ["\"aaabcbc\""], "fn_name": "decodeString"}, "test_case_format": "function_call", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "0c3544a68c129364de738b5e8ec6c6c42de5d244", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "decodeString"} {"seed_id": "apps-00048", "original_id": null, "source": "apps", "domain": "code", "problem": "A password is considered strong if below conditions are all met:\n\n\n It has at least 6 characters and at most 20 characters. \n It must contain at least one lowercase letter, at least one uppercase letter, and at least one digit. \n It must NOT contain three repeating characters in a row (\"...aaa...\" is weak, but \"...aa...a...\" is strong, assuming other conditions are met). \n\n\nWrite a function strongPasswordChecker(s), that takes a string s as input, and return the MINIMUM change required to make s a strong password. If s is already strong, return 0.\n\nInsertion, deletion or replace of any one character are all considered as one change.", "starter_code": "\nclass Solution:\n def strongPasswordChecker(self, s: str) -> int:\n ", "test_cases": {"inputs": [["\"a\""]], "outputs": [3], "fn_name": "strongPasswordChecker"}, "test_case_format": "function_call", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "7d96d0829112bd8db10ac6e04ecceaefd7de3861", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "strongPasswordChecker"} {"seed_id": "apps-00053", "original_id": null, "source": "apps", "domain": "code", "problem": "Given an input string (s) and a pattern (p), implement wildcard pattern matching with support for '?' and '*'.\n\n\n'?' Matches any single character.\n'*' Matches any sequence of characters (including the empty sequence).\n\n\nThe matching should cover the entire input string (not partial).\n\nNote:\n\n\n s could be empty and contains only lowercase letters a-z.\n p could be empty and contains only lowercase letters a-z, and characters like ? or *.\n\n\nExample 1:\n\n\nInput:\ns = \"aa\"\np = \"a\"\nOutput: false\nExplanation: \"a\" does not match the entire string \"aa\".\n\n\nExample 2:\n\n\nInput:\ns = \"aa\"\np = \"*\"\nOutput: true\nExplanation: '*' matches any sequence.\n\n\nExample 3:\n\n\nInput:\ns = \"cb\"\np = \"?a\"\nOutput: false\nExplanation: '?' matches 'c', but the second letter is 'a', which does not match 'b'.\n\n\nExample 4:\n\n\nInput:\ns = \"adceb\"\np = \"*a*b\"\nOutput: true\nExplanation: The first '*' matches the empty sequence, while the second '*' matches the substring \"dce\".\n\n\nExample 5:\n\n\nInput:\ns = \"acdcb\"\np = \"a*c?b\"\nOutput: false", "starter_code": "\nclass Solution:\n def isMatch(self, s: str, p: str) -> bool:\n ", "test_cases": {"inputs": [["\"aa\"", "\"a\""]], "outputs": [false], "fn_name": "isMatch"}, "test_case_format": "function_call", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "646b90347de8504f6077154d6704fc1ff2107759", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "isMatch"} {"seed_id": "apps-00058", "original_id": null, "source": "apps", "domain": "code", "problem": "Given two strings text1 and text2, return the length of their longest common subsequence.\nA subsequence of a string is a new string generated from the original string with some characters(can be none) deleted without changing the relative order of the remaining characters. (eg, \"ace\" is a subsequence of \"abcde\" while \"aec\" is not). A common subsequence of two strings is a subsequence that is common to both strings.\n \nIf there is no common subsequence, return 0.\n \nExample 1:\nInput: text1 = \"abcde\", text2 = \"ace\" \nOutput: 3 \nExplanation: The longest common subsequence is \"ace\" and its length is 3.\n\nExample 2:\nInput: text1 = \"abc\", text2 = \"abc\"\nOutput: 3\nExplanation: The longest common subsequence is \"abc\" and its length is 3.\n\nExample 3:\nInput: text1 = \"abc\", text2 = \"def\"\nOutput: 0\nExplanation: There is no such common subsequence, so the result is 0.\n\n \nConstraints:\n\n1 <= text1.length <= 1000\n1 <= text2.length <= 1000\nThe input strings consist of lowercase English characters only.", "starter_code": "\nclass Solution:\n def longestCommonSubsequence(self, text1: str, text2: str) -> int:\n ", "test_cases": {"inputs": [["\"abcde\"", "\"ace\""]], "outputs": [5], "fn_name": "longestCommonSubsequence"}, "test_case_format": "function_call", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "18498f07333d48c8ef2f1f2d63dcd572eb15964e", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "longestCommonSubsequence"} {"seed_id": "apps-00063", "original_id": null, "source": "apps", "domain": "code", "problem": "Given a string s and an integer k. You should construct k non-empty palindrome strings using all the characters in s.\nReturn True if you can use all the characters in s to construct k palindrome strings or False otherwise.\n \nExample 1:\nInput: s = \"annabelle\", k = 2\nOutput: true\nExplanation: You can construct two palindromes using all characters in s.\nSome possible constructions \"anna\" + \"elble\", \"anbna\" + \"elle\", \"anellena\" + \"b\"\n\nExample 2:\nInput: s = \"leetcode\", k = 3\nOutput: false\nExplanation: It is impossible to construct 3 palindromes using all the characters of s.\n\nExample 3:\nInput: s = \"true\", k = 4\nOutput: true\nExplanation: The only possible solution is to put each character in a separate string.\n\nExample 4:\nInput: s = \"yzyzyzyzyzyzyzy\", k = 2\nOutput: true\nExplanation: Simply you can put all z's in one string and all y's in the other string. Both strings will be palindrome.\n\nExample 5:\nInput: s = \"cr\", k = 7\nOutput: false\nExplanation: We don't have enough characters in s to construct 7 palindromes.\n\n \nConstraints:\n\n1 <= s.length <= 10^5\nAll characters in s are lower-case English letters.\n1 <= k <= 10^5", "starter_code": "\nclass Solution:\n def canConstruct(self, s: str, k: int) -> bool:\n ", "test_cases": {"inputs": [["\"annabelle\"", 2]], "outputs": [true], "fn_name": "canConstruct"}, "test_case_format": "function_call", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "d05b0ce4ce9502027964d6c3d4aed20723a97882", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "canConstruct"} {"seed_id": "apps-00068", "original_id": null, "source": "apps", "domain": "code", "problem": "Given an array of integers arr of even length n and an integer k.\nWe want to divide the array into exactly n / 2 pairs such that the sum of each pair is divisible by k.\nReturn True If you can find a way to do that or False otherwise.\n \nExample 1:\nInput: arr = [1,2,3,4,5,10,6,7,8,9], k = 5\nOutput: true\nExplanation: Pairs are (1,9),(2,8),(3,7),(4,6) and (5,10).\n\nExample 2:\nInput: arr = [1,2,3,4,5,6], k = 7\nOutput: true\nExplanation: Pairs are (1,6),(2,5) and(3,4).\n\nExample 3:\nInput: arr = [1,2,3,4,5,6], k = 10\nOutput: false\nExplanation: You can try all possible pairs to see that there is no way to divide arr into 3 pairs each with sum divisible by 10.\n\nExample 4:\nInput: arr = [-10,10], k = 2\nOutput: true\n\nExample 5:\nInput: arr = [-1,1,-2,2,-3,3,-4,4], k = 3\nOutput: true\n\n \nConstraints:\n\narr.length == n\n1 <= n <= 10^5\nn is even.\n-10^9 <= arr[i] <= 10^9\n1 <= k <= 10^5", "starter_code": "\nclass Solution:\n def canArrange(self, arr: List[int], k: int) -> bool:\n ", "test_cases": {"inputs": [[[1, 2, 3, 4, 5, 10, 6, 7, 8, 9], 5]], "outputs": [true], "fn_name": "canArrange"}, "test_case_format": "function_call", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "ed4cf751117834eb0557e1f8036420ea9dbc845e", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "canArrange"} {"seed_id": "apps-00073", "original_id": null, "source": "apps", "domain": "code", "problem": "Given an unsorted array of integers, find the length of longest increasing subsequence.\n\nExample:\n\n\nInput: [10,9,2,5,3,7,101,18]\nOutput: 4 \nExplanation: The longest increasing subsequence is [2,3,7,101], therefore the length is 4. \n\nNote: \n\n\n There may be more than one LIS combination, it is only necessary for you to return the length.\n Your algorithm should run in O(n2) complexity.\n\n\nFollow up: Could you improve it to O(n log n) time complexity?", "starter_code": "\nclass Solution:\n def lengthOfLIS(self, nums: List[int]) -> int:\n ", "test_cases": {"inputs": [[[10, 9, 2, 5, 3, 7, 101, 18]]], "outputs": [4], "fn_name": "lengthOfLIS"}, "test_case_format": "function_call", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "1872d6320296785848d508c17a10a219fd3d9919", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "lengthOfLIS"} {"seed_id": "apps-00078", "original_id": null, "source": "apps", "domain": "code", "problem": "Given a binary string s and an integer k.\nReturn True if every binary code of length k is a substring of s. Otherwise, return False.\n \nExample 1:\nInput: s = \"00110110\", k = 2\nOutput: true\nExplanation: The binary codes of length 2 are \"00\", \"01\", \"10\" and \"11\". They can be all found as substrings at indicies 0, 1, 3 and 2 respectively.\n\nExample 2:\nInput: s = \"00110\", k = 2\nOutput: true\n\nExample 3:\nInput: s = \"0110\", k = 1\nOutput: true\nExplanation: The binary codes of length 1 are \"0\" and \"1\", it is clear that both exist as a substring. \n\nExample 4:\nInput: s = \"0110\", k = 2\nOutput: false\nExplanation: The binary code \"00\" is of length 2 and doesn't exist in the array.\n\nExample 5:\nInput: s = \"0000000001011100\", k = 4\nOutput: false\n\n \nConstraints:\n\n1 <= s.length <= 5 * 10^5\ns consists of 0's and 1's only.\n1 <= k <= 20", "starter_code": "\nclass Solution:\n def hasAllCodes(self, s: str, k: int) -> bool:\n ", "test_cases": {"inputs": [["\"00110110\"", 2]], "outputs": [true], "fn_name": "hasAllCodes"}, "test_case_format": "function_call", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "75e3f73ff33dcf7eb55daa72e49e976976eed534", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "hasAllCodes"} {"seed_id": "apps-00083", "original_id": null, "source": "apps", "domain": "code", "problem": "Given an array of digits, you can write numbers using each digits[i] as many times as we want.  For example, if digits = ['1','3','5'], we may write numbers such as '13', '551', and '1351315'.\nReturn the number of positive integers that can be generated that are less than or equal to a given integer n.\n \nExample 1:\nInput: digits = [\"1\",\"3\",\"5\",\"7\"], n = 100\nOutput: 20\nExplanation: \nThe 20 numbers that can be written are:\n1, 3, 5, 7, 11, 13, 15, 17, 31, 33, 35, 37, 51, 53, 55, 57, 71, 73, 75, 77.\n\nExample 2:\nInput: digits = [\"1\",\"4\",\"9\"], n = 1000000000\nOutput: 29523\nExplanation: \nWe can write 3 one digit numbers, 9 two digit numbers, 27 three digit numbers,\n81 four digit numbers, 243 five digit numbers, 729 six digit numbers,\n2187 seven digit numbers, 6561 eight digit numbers, and 19683 nine digit numbers.\nIn total, this is 29523 integers that can be written using the digits array.\n\nExample 3:\nInput: digits = [\"7\"], n = 8\nOutput: 1\n\n \nConstraints:\n\n1 <= digits.length <= 9\ndigits[i].length == 1\ndigits[i] is a digit from '1' to '9'.\nAll the values in digits are unique.\n1 <= n <= 109", "starter_code": "\nclass Solution:\n def atMostNGivenDigitSet(self, digits: List[str], n: int) -> int:\n ", "test_cases": {"inputs": [[["\"1\"", "\"3\"", "\"5\"", "\"7\""], 100]], "outputs": [84], "fn_name": "atMostNGivenDigitSet"}, "test_case_format": "function_call", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "dd8f489abdd3fdc9803c91500e0d2826f6034280", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "atMostNGivenDigitSet"} {"seed_id": "apps-00088", "original_id": null, "source": "apps", "domain": "code", "problem": "Given a circular array C of integers represented by A, find the maximum possible sum of a non-empty subarray of C.\nHere, a circular array means the end of the array connects to the beginning of the array.  (Formally, C[i] = A[i] when 0 <= i < A.length, and C[i+A.length] = C[i] when i >= 0.)\nAlso, a subarray may only include each element of the fixed buffer A at most once.  (Formally, for a subarray C[i], C[i+1], ..., C[j], there does not exist i <= k1, k2 <= j with k1 % A.length = k2 % A.length.)\n \n\nExample 1:\nInput: [1,-2,3,-2]\nOutput: 3\nExplanation: Subarray [3] has maximum sum 3\n\n\nExample 2:\nInput: [5,-3,5]\nOutput: 10\nExplanation: Subarray [5,5] has maximum sum 5 + 5 = 10\n\n\nExample 3:\nInput: [3,-1,2,-1]\nOutput: 4\nExplanation: Subarray [2,-1,3] has maximum sum 2 + (-1) + 3 = 4\n\n\nExample 4:\nInput: [3,-2,2,-3]\nOutput: 3\nExplanation: Subarray [3] and [3,-2,2] both have maximum sum 3\n\nExample 5:\nInput: [-2,-3,-1]\nOutput: -1\nExplanation: Subarray [-1] has maximum sum -1\n\n \nNote: \n\n-30000 <= A[i] <= 30000\n1 <= A.length <= 30000", "starter_code": "\nclass Solution:\n def maxSubarraySumCircular(self, A: List[int]) -> int:\n ", "test_cases": {"inputs": [[[-2, 3, -2, 1]]], "outputs": [3], "fn_name": "maxSubarraySumCircular"}, "test_case_format": "function_call", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "74a1f999e0e4819b790f172adaccc9b33f8a6155", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "maxSubarraySumCircular"} {"seed_id": "apps-00093", "original_id": null, "source": "apps", "domain": "code", "problem": "Given n, how many structurally unique BST's (binary search trees) that store values 1 ... n?\n\nExample:\n\n\nInput: 3\nOutput: 5\nExplanation:\nGiven n = 3, there are a total of 5 unique BST's:\n\n 1 3 3 2 1\n \\ / / / \\ \\\n 3 2 1 1 3 2\n / / \\ \\\n 2 1 2 3", "starter_code": "\nclass Solution:\n def numTrees(self, n: int) -> int:\n ", "test_cases": {"inputs": [[3]], "outputs": [5], "fn_name": "numTrees"}, "test_case_format": "function_call", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "23a1a3423447a40763fdeb07a3faa7ffb59f463c", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "numTrees"} {"seed_id": "apps-00098", "original_id": null, "source": "apps", "domain": "code", "problem": "Given a list of non negative integers, arrange them such that they form the largest number.\n\nExample 1:\n\n\nInput: [10,2]\nOutput: \"210\"\n\nExample 2:\n\n\nInput: [3,30,34,5,9]\nOutput: \"9534330\"\n\n\nNote: The result may be very large, so you need to return a string instead of an integer.", "starter_code": "\nclass Solution:\n def largestNumber(self, nums: List[int]) -> str:\n ", "test_cases": {"inputs": [[[10, 2]]], "outputs": ["210"], "fn_name": "largestNumber"}, "test_case_format": "function_call", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "cfe3b7b8426aa3b7162826b1fc632b34923ec3a5", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "largestNumber"} {"seed_id": "apps-00103", "original_id": null, "source": "apps", "domain": "code", "problem": "Given an array of unique integers, each integer is strictly greater than 1.\nWe make a binary tree using these integers and each number may be used for any number of times.\nEach non-leaf node's value should be equal to the product of the values of it's children.\nHow many binary trees can we make?  Return the answer modulo 10 ** 9 + 7.\nExample 1:\nInput: A = [2, 4]\nOutput: 3\nExplanation: We can make these trees: [2], [4], [4, 2, 2]\nExample 2:\nInput: A = [2, 4, 5, 10]\nOutput: 7\nExplanation: We can make these trees: [2], [4], [5], [10], [4, 2, 2], [10, 2, 5], [10, 5, 2].\n \nNote:\n\n1 <= A.length <= 1000.\n2 <= A[i] <= 10 ^ 9.", "starter_code": "\nclass Solution:\n def numFactoredBinaryTrees(self, A: List[int]) -> int:\n ", "test_cases": {"inputs": [[[2, 4]]], "outputs": [3], "fn_name": "numFactoredBinaryTrees"}, "test_case_format": "function_call", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "d2baa31fdcd19ddd6026552d704bcad72a165e2c", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "numFactoredBinaryTrees"} {"seed_id": "apps-00108", "original_id": null, "source": "apps", "domain": "code", "problem": "A string S of lowercase letters is given.  Then, we may make any number of moves.\nIn each move, we choose one of the first K letters (starting from the left), remove it, and place it at the end of the string.\nReturn the lexicographically smallest string we could have after any number of moves.\n \n\nExample 1:\nInput: S = \"cba\", K = 1\nOutput: \"acb\"\nExplanation: \nIn the first move, we move the 1st character (\"c\") to the end, obtaining the string \"bac\".\nIn the second move, we move the 1st character (\"b\") to the end, obtaining the final result \"acb\".\n\n\nExample 2:\nInput: S = \"baaca\", K = 3\nOutput: \"aaabc\"\nExplanation: \nIn the first move, we move the 1st character (\"b\") to the end, obtaining the string \"aacab\".\nIn the second move, we move the 3rd character (\"c\") to the end, obtaining the final result \"aaabc\".\n\n \nNote:\n\n1 <= K <= S.length <= 1000\nS consists of lowercase letters only.", "starter_code": "\nclass Solution:\n def orderlyQueue(self, S: str, K: int) -> str:\n ", "test_cases": {"inputs": [["\"cba\"", 1]], "outputs": ["\"\"cba"], "fn_name": "orderlyQueue"}, "test_case_format": "function_call", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "80423d8ecb8d532061f7734762a80c9d5702aa0f", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "orderlyQueue"} {"seed_id": "apps-00113", "original_id": null, "source": "apps", "domain": "code", "problem": "Given an array of citations sorted in ascending order (each citation is a non-negative integer) of a researcher, write a function to compute the researcher's h-index.\n\nAccording to the definition of h-index on Wikipedia: \"A scientist has index h if h of his/her N papers have at least h citations each, and the other N − h papers have no more than h citations each.\"\n\nExample:\n\n\nInput: citations = [0,1,3,5,6]\nOutput: 3 \nExplanation: [0,1,3,5,6] means the researcher has 5 papers in total and each of them had \n received 0, 1, 3, 5, 6 citations respectively. \n  Since the researcher has 3 papers with at least 3 citations each and the remaining \n  two with no more than 3 citations each, her h-index is 3.\n\nNote:\n\nIf there are several possible values for h, the maximum one is taken as the h-index.\n\nFollow up:\n\n\n This is a follow up problem to H-Index, where citations is now guaranteed to be sorted in ascending order.\n Could you solve it in logarithmic time complexity?", "starter_code": "\nclass Solution:\n def hIndex(self, citations: List[int]) -> int:\n ", "test_cases": {"inputs": [[[0, 1, 3, 5, 6]]], "outputs": [3], "fn_name": "hIndex"}, "test_case_format": "function_call", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "62fb2f5aa772608f1ae73d7768c919ff026d6165", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "hIndex"} {"seed_id": "apps-00118", "original_id": null, "source": "apps", "domain": "code", "problem": "Given a string s and an integer k.\nReturn the maximum number of vowel letters in any substring of s with length k.\nVowel letters in English are (a, e, i, o, u).\n \nExample 1:\nInput: s = \"abciiidef\", k = 3\nOutput: 3\nExplanation: The substring \"iii\" contains 3 vowel letters.\n\nExample 2:\nInput: s = \"aeiou\", k = 2\nOutput: 2\nExplanation: Any substring of length 2 contains 2 vowels.\n\nExample 3:\nInput: s = \"leetcode\", k = 3\nOutput: 2\nExplanation: \"lee\", \"eet\" and \"ode\" contain 2 vowels.\n\nExample 4:\nInput: s = \"rhythms\", k = 4\nOutput: 0\nExplanation: We can see that s doesn't have any vowel letters.\n\nExample 5:\nInput: s = \"tryhard\", k = 4\nOutput: 1\n\n \nConstraints:\n\n1 <= s.length <= 10^5\ns consists of lowercase English letters.\n1 <= k <= s.length", "starter_code": "\nclass Solution:\n def maxVowels(self, s: str, k: int) -> int:\n ", "test_cases": {"inputs": [["\"abciiidef\"", 3]], "outputs": [3], "fn_name": "maxVowels"}, "test_case_format": "function_call", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "281dd74daf6fc1183a57d6d68b0a5e36860e337d", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "maxVowels"} {"seed_id": "apps-00123", "original_id": null, "source": "apps", "domain": "code", "problem": "A sequence of number is called arithmetic if it consists of at least three elements and if the difference between any two consecutive elements is the same.\n\nFor example, these are arithmetic sequence:\n1, 3, 5, 7, 9\n7, 7, 7, 7\n3, -1, -5, -9\n\nThe following sequence is not arithmetic. 1, 1, 2, 5, 7 \n\n\nA zero-indexed array A consisting of N numbers is given. A slice of that array is any pair of integers (P, Q) such that 0 \n\nA slice (P, Q) of array A is called arithmetic if the sequence:\n A[P], A[p + 1], ..., A[Q - 1], A[Q] is arithmetic. In particular, this means that P + 1 < Q.\n\nThe function should return the number of arithmetic slices in the array A. \n\n\nExample:\n\nA = [1, 2, 3, 4]\n\nreturn: 3, for 3 arithmetic slices in A: [1, 2, 3], [2, 3, 4] and [1, 2, 3, 4] itself.", "starter_code": "\nclass Solution:\n def numberOfArithmeticSlices(self, A: List[int]) -> int:\n ", "test_cases": {"inputs": [[[1, 2, 3, 4]]], "outputs": [3], "fn_name": "numberOfArithmeticSlices"}, "test_case_format": "function_call", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "bcb882a7128a8146a494b2c2861057ce9928f505", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "numberOfArithmeticSlices"} {"seed_id": "apps-00128", "original_id": null, "source": "apps", "domain": "code", "problem": "On an infinite plane, a robot initially stands at (0, 0) and faces north.  The robot can receive one of three instructions:\n\n\"G\": go straight 1 unit;\n\"L\": turn 90 degrees to the left;\n\"R\": turn 90 degress to the right.\n\nThe robot performs the instructions given in order, and repeats them forever.\nReturn true if and only if there exists a circle in the plane such that the robot never leaves the circle.\n \nExample 1:\nInput: \"GGLLGG\"\nOutput: true\nExplanation: \nThe robot moves from (0,0) to (0,2), turns 180 degrees, and then returns to (0,0).\nWhen repeating these instructions, the robot remains in the circle of radius 2 centered at the origin.\n\nExample 2:\nInput: \"GG\"\nOutput: false\nExplanation: \nThe robot moves north indefinitely.\n\nExample 3:\nInput: \"GL\"\nOutput: true\nExplanation: \nThe robot moves from (0, 0) -> (0, 1) -> (-1, 1) -> (-1, 0) -> (0, 0) -> ...\n\n \nNote:\n\n1 <= instructions.length <= 100\ninstructions[i] is in {'G', 'L', 'R'}", "starter_code": "\nclass Solution:\n def isRobotBounded(self, instructions: str) -> bool:\n ", "test_cases": {"inputs": [["\"GGLLGG\""]], "outputs": [true], "fn_name": "isRobotBounded"}, "test_case_format": "function_call", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "00b6e856522e42c332566ae5cecde8fc0b70ef3e", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "isRobotBounded"} {"seed_id": "apps-00133", "original_id": null, "source": "apps", "domain": "code", "problem": "Given an array of integers arr and an integer target.\nYou have to find two non-overlapping sub-arrays of arr each with sum equal target. There can be multiple answers so you have to find an answer where the sum of the lengths of the two sub-arrays is minimum.\nReturn the minimum sum of the lengths of the two required sub-arrays, or return -1 if you cannot find such two sub-arrays.\n \nExample 1:\nInput: arr = [3,2,2,4,3], target = 3\nOutput: 2\nExplanation: Only two sub-arrays have sum = 3 ([3] and [3]). The sum of their lengths is 2.\n\nExample 2:\nInput: arr = [7,3,4,7], target = 7\nOutput: 2\nExplanation: Although we have three non-overlapping sub-arrays of sum = 7 ([7], [3,4] and [7]), but we will choose the first and third sub-arrays as the sum of their lengths is 2.\n\nExample 3:\nInput: arr = [4,3,2,6,2,3,4], target = 6\nOutput: -1\nExplanation: We have only one sub-array of sum = 6.\n\nExample 4:\nInput: arr = [5,5,4,4,5], target = 3\nOutput: -1\nExplanation: We cannot find a sub-array of sum = 3.\n\nExample 5:\nInput: arr = [3,1,1,1,5,1,2,1], target = 3\nOutput: 3\nExplanation: Note that sub-arrays [1,2] and [2,1] cannot be an answer because they overlap.\n\n \nConstraints:\n\n1 <= arr.length <= 10^5\n1 <= arr[i] <= 1000\n1 <= target <= 10^8", "starter_code": "\nclass Solution:\n def minSumOfLengths(self, arr: List[int], target: int) -> int:\n ", "test_cases": {"inputs": [[[3, 2, 2, 4, 3], 3]], "outputs": [2], "fn_name": "minSumOfLengths"}, "test_case_format": "function_call", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "b832a132bedaa0952b6887fb90838a86d5ffdc49", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "minSumOfLengths"} {"seed_id": "apps-00138", "original_id": null, "source": "apps", "domain": "code", "problem": "Given a non-negative integer n, count all numbers with unique digits, x, where 0 ≤ x < 10n.\n\n\n Example:\nGiven n = 2, return 91. (The answer should be the total numbers in the range of 0 ≤ x < 100, excluding [11,22,33,44,55,66,77,88,99])\n\n\nCredits:Special thanks to @memoryless for adding this problem and creating all test cases.", "starter_code": "\nclass Solution:\n def countNumbersWithUniqueDigits(self, n: int) -> int:\n ", "test_cases": {"inputs": [[2]], "outputs": [91], "fn_name": "countNumbersWithUniqueDigits"}, "test_case_format": "function_call", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "55617c18f5f4242ee637ece4c23e2a2f256de3f1", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "countNumbersWithUniqueDigits"} {"seed_id": "apps-00143", "original_id": null, "source": "apps", "domain": "code", "problem": "A sequence of numbers is called a wiggle sequence if the differences between successive numbers strictly alternate between positive and negative. The first difference (if one exists) may be either positive or negative. A sequence with fewer than two elements is trivially a wiggle sequence. \n\nFor example, [1,7,4,9,2,5] is a wiggle sequence because the differences (6,-3,5,-7,3) are alternately positive and negative. In contrast, [1,4,7,2,5] and [1,7,4,5,5] are not wiggle sequences, the first because its first two differences are positive and the second because its last difference is zero.\n\nGiven a sequence of integers, return the length of the longest subsequence that is a wiggle sequence. A subsequence is obtained by deleting some number of elements (eventually, also zero) from the original sequence, leaving the remaining elements in their original order.\n\nExamples:\n\nInput: [1,7,4,9,2,5]\nOutput: 6\nThe entire sequence is a wiggle sequence.\n\nInput: [1,17,5,10,13,15,10,5,16,8]\nOutput: 7\nThere are several subsequences that achieve this length. One is [1,17,10,13,10,16,8].\n\nInput: [1,2,3,4,5,6,7,8,9]\nOutput: 2\n\n\n\nFollow up:\nCan you do it in O(n) time?\n\n\nCredits:Special thanks to @agave and @StefanPochmann for adding this problem and creating all test cases.", "starter_code": "\nclass Solution:\n def wiggleMaxLength(self, nums: List[int]) -> int:\n ", "test_cases": {"inputs": [[[1, 7, 4, 9, 2, 5]]], "outputs": [6], "fn_name": "wiggleMaxLength"}, "test_case_format": "function_call", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "ad9f5b33b42c797baec8dc451942e98b18f8c23c", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "wiggleMaxLength"} {"seed_id": "apps-00148", "original_id": null, "source": "apps", "domain": "code", "problem": "You are given a string s, a split is called good if you can split s into 2 non-empty strings p and q where its concatenation is equal to s and the number of distinct letters in p and q are the same.\nReturn the number of good splits you can make in s.\n \nExample 1:\nInput: s = \"aacaba\"\nOutput: 2\nExplanation: There are 5 ways to split \"aacaba\" and 2 of them are good. \n(\"a\", \"acaba\") Left string and right string contains 1 and 3 different letters respectively.\n(\"aa\", \"caba\") Left string and right string contains 1 and 3 different letters respectively.\n(\"aac\", \"aba\") Left string and right string contains 2 and 2 different letters respectively (good split).\n(\"aaca\", \"ba\") Left string and right string contains 2 and 2 different letters respectively (good split).\n(\"aacab\", \"a\") Left string and right string contains 3 and 1 different letters respectively.\n\nExample 2:\nInput: s = \"abcd\"\nOutput: 1\nExplanation: Split the string as follows (\"ab\", \"cd\").\n\nExample 3:\nInput: s = \"aaaaa\"\nOutput: 4\nExplanation: All possible splits are good.\nExample 4:\nInput: s = \"acbadbaada\"\nOutput: 2\n\n \nConstraints:\n\ns contains only lowercase English letters.\n1 <= s.length <= 10^5", "starter_code": "\nclass Solution:\n def numSplits(self, s: str) -> int:\n ", "test_cases": {"inputs": [["\"aacaba\""]], "outputs": [2], "fn_name": "numSplits"}, "test_case_format": "function_call", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "a52dbd5594c49bdfb383e87602dd93997d099da0", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "numSplits"} {"seed_id": "apps-00153", "original_id": null, "source": "apps", "domain": "code", "problem": "Given n boxes, each box is given in the format [status, candies, keys, containedBoxes] where:\n\nstatus[i]: an integer which is 1 if box[i] is open and 0 if box[i] is closed.\ncandies[i]: an integer representing the number of candies in box[i].\nkeys[i]: an array contains the indices of the boxes you can open with the key in box[i].\ncontainedBoxes[i]: an array contains the indices of the boxes found in box[i].\n\nYou will start with some boxes given in initialBoxes array. You can take all the candies in any open box and you can use the keys in it to open new boxes and you also can use the boxes you find in it.\nReturn the maximum number of candies you can get following the rules above.\n \nExample 1:\nInput: status = [1,0,1,0], candies = [7,5,4,100], keys = [[],[],[1],[]], containedBoxes = [[1,2],[3],[],[]], initialBoxes = [0]\nOutput: 16\nExplanation: You will be initially given box 0. You will find 7 candies in it and boxes 1 and 2. Box 1 is closed and you don't have a key for it so you will open box 2. You will find 4 candies and a key to box 1 in box 2.\nIn box 1, you will find 5 candies and box 3 but you will not find a key to box 3 so box 3 will remain closed.\nTotal number of candies collected = 7 + 4 + 5 = 16 candy.\n\nExample 2:\nInput: status = [1,0,0,0,0,0], candies = [1,1,1,1,1,1], keys = [[1,2,3,4,5],[],[],[],[],[]], containedBoxes = [[1,2,3,4,5],[],[],[],[],[]], initialBoxes = [0]\nOutput: 6\nExplanation: You have initially box 0. Opening it you can find boxes 1,2,3,4 and 5 and their keys. The total number of candies will be 6.\n\nExample 3:\nInput: status = [1,1,1], candies = [100,1,100], keys = [[],[0,2],[]], containedBoxes = [[],[],[]], initialBoxes = [1]\nOutput: 1\n\nExample 4:\nInput: status = [1], candies = [100], keys = [[]], containedBoxes = [[]], initialBoxes = []\nOutput: 0\n\nExample 5:\nInput: status = [1,1,1], candies = [2,3,2], keys = [[],[],[]], containedBoxes = [[],[],[]], initialBoxes = [2,1,0]\nOutput: 7\n\n \nConstraints:\n\n1 <= status.length <= 1000\nstatus.length == candies.length == keys.length == containedBoxes.length == n\nstatus[i] is 0 or 1.\n1 <= candies[i] <= 1000\n0 <= keys[i].length <= status.length\n0 <= keys[i][j] < status.length\nAll values in keys[i] are unique.\n0 <= containedBoxes[i].length <= status.length\n0 <= containedBoxes[i][j] < status.length\nAll values in containedBoxes[i] are unique.\nEach box is contained in one box at most.\n0 <= initialBoxes.length <= status.length\n0 <= initialBoxes[i] < status.length", "starter_code": "\nclass Solution:\n def maxCandies(self, status: List[int], candies: List[int], keys: List[List[int]], containedBoxes: List[List[int]], initialBoxes: List[int]) -> int:\n ", "test_cases": {"inputs": [[[1, 1, 1, 0], [7, 5, 4, 100], [[], [], [1], [], [], []], [[1, 2], [3], [], [], [], []], [0]]], "outputs": [16], "fn_name": "maxCandies"}, "test_case_format": "function_call", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "6d6b0018921fcd53335a1f51b47a3700a5f19421", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "maxCandies"} {"seed_id": "apps-00158", "original_id": null, "source": "apps", "domain": "code", "problem": "There is a room with n bulbs, numbered from 1 to n, arranged in a row from left to right. Initially, all the bulbs are turned off.\nAt moment k (for k from 0 to n - 1), we turn on the light[k] bulb. A bulb change color to blue only if it is on and all the previous bulbs (to the left) are turned on too.\nReturn the number of moments in which all turned on bulbs are blue.\n \nExample 1:\n\nInput: light = [2,1,3,5,4]\nOutput: 3\nExplanation: All bulbs turned on, are blue at the moment 1, 2 and 4.\n\nExample 2:\nInput: light = [3,2,4,1,5]\nOutput: 2\nExplanation: All bulbs turned on, are blue at the moment 3, and 4 (index-0).\n\nExample 3:\nInput: light = [4,1,2,3]\nOutput: 1\nExplanation: All bulbs turned on, are blue at the moment 3 (index-0).\nBulb 4th changes to blue at the moment 3.\n\nExample 4:\nInput: light = [2,1,4,3,6,5]\nOutput: 3\n\nExample 5:\nInput: light = [1,2,3,4,5,6]\nOutput: 6\n\n \nConstraints:\n\nn == light.length\n1 <= n <= 5 * 10^4\nlight is a permutation of  [1, 2, ..., n]", "starter_code": "\nclass Solution:\n def numTimesAllBlue(self, light: List[int]) -> int:\n ", "test_cases": {"inputs": [[[2, 1, 3, 5, 4]]], "outputs": [3], "fn_name": "numTimesAllBlue"}, "test_case_format": "function_call", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "39ce02f45dd4ee7722246224d9aead4929bee38a", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "numTimesAllBlue"} {"seed_id": "apps-00163", "original_id": null, "source": "apps", "domain": "code", "problem": "Given an integer array, return the k-th smallest distance among all the pairs. The distance of a pair (A, B) is defined as the absolute difference between A and B. \n\nExample 1:\n\nInput:\nnums = [1,3,1]\nk = 1\nOutput: 0 \nExplanation:\nHere are all the pairs:\n(1,3) -> 2\n(1,1) -> 0\n(3,1) -> 2\nThen the 1st smallest distance pair is (1,1), and its distance is 0.\n\n\n\nNote:\n\n2 .\n0 .\n1 .", "starter_code": "\nclass Solution:\n def smallestDistancePair(self, nums: List[int], k: int) -> int:\n ", "test_cases": {"inputs": [[[1, 1, 3], 1]], "outputs": [0], "fn_name": "smallestDistancePair"}, "test_case_format": "function_call", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "c48fe17be7f39c577eb279dcd3449879806c6dc7", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "smallestDistancePair"} {"seed_id": "apps-00168", "original_id": null, "source": "apps", "domain": "code", "problem": "There is a room with n lights which are turned on initially and 4 buttons on the wall. After performing exactly m unknown operations towards buttons, you need to return how many different kinds of status of the n lights could be.\n\n\n\nSuppose n lights are labeled as number [1, 2, 3 ..., n], function of these 4 buttons are given below:\n\n\nFlip all the lights.\nFlip lights with even numbers.\nFlip lights with odd numbers.\nFlip lights with (3k + 1) numbers, k = 0, 1, 2, ...\n\n\n\n\nExample 1:\n\nInput: n = 1, m = 1.\nOutput: 2\nExplanation: Status can be: [on], [off]\n\n\n\n\nExample 2:\n\nInput: n = 2, m = 1.\nOutput: 3\nExplanation: Status can be: [on, off], [off, on], [off, off]\n\n\n\n\nExample 3:\n\nInput: n = 3, m = 1.\nOutput: 4\nExplanation: Status can be: [off, on, off], [on, off, on], [off, off, off], [off, on, on].\n\n\n\nNote:\nn and m both fit in range [0, 1000].", "starter_code": "\nclass Solution:\n def flipLights(self, n: int, m: int) -> int:\n ", "test_cases": {"inputs": [[1, 1]], "outputs": [2], "fn_name": "flipLights"}, "test_case_format": "function_call", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "eeaf29df9f3f9400409e399e858b13110f6b982d", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "flipLights"} {"seed_id": "apps-00173", "original_id": null, "source": "apps", "domain": "code", "problem": "The n-queens puzzle is the problem of placing n queens on an n×n chessboard such that no two queens attack each other.\n\n\n\nGiven an integer n, return the number of distinct solutions to the n-queens puzzle.\n\nExample:\n\n\nInput: 4\nOutput: 2\nExplanation: There are two distinct solutions to the 4-queens puzzle as shown below.\n[\n [\".Q..\",  // Solution 1\n  \"...Q\",\n  \"Q...\",\n  \"..Q.\"],\n\n [\"..Q.\",  // Solution 2\n  \"Q...\",\n  \"...Q\",\n  \".Q..\"]\n]", "starter_code": "\nclass Solution:\n def totalNQueens(self, n: int) -> int:\n ", "test_cases": {"inputs": [[4]], "outputs": [2], "fn_name": "totalNQueens"}, "test_case_format": "function_call", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "0e1df28050dca35c2d0bd65e9538d3c59db1e888", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "totalNQueens"} {"seed_id": "apps-00178", "original_id": null, "source": "apps", "domain": "code", "problem": "We write the integers of A and B (in the order they are given) on two separate horizontal lines.\nNow, we may draw connecting lines: a straight line connecting two numbers A[i] and B[j] such that:\n\nA[i] == B[j];\nThe line we draw does not intersect any other connecting (non-horizontal) line.\n\nNote that a connecting lines cannot intersect even at the endpoints: each number can only belong to one connecting line.\nReturn the maximum number of connecting lines we can draw in this way.\n \nExample 1:\n\nInput: A = [1,4,2], B = [1,2,4]\nOutput: 2\nExplanation: We can draw 2 uncrossed lines as in the diagram.\nWe cannot draw 3 uncrossed lines, because the line from A[1]=4 to B[2]=4 will intersect the line from A[2]=2 to B[1]=2.\n\n\nExample 2:\nInput: A = [2,5,1,2,5], B = [10,5,2,1,5,2]\nOutput: 3\n\n\nExample 3:\nInput: A = [1,3,7,1,7,5], B = [1,9,2,5,1]\nOutput: 2\n \n\n\nNote:\n\n1 <= A.length <= 500\n1 <= B.length <= 500\n1 <= A[i], B[i] <= 2000", "starter_code": "\nclass Solution:\n def maxUncrossedLines(self, A: List[int], B: List[int]) -> int:\n ", "test_cases": {"inputs": [[[1, 4, 2], [1, 2, 4]]], "outputs": [2], "fn_name": "maxUncrossedLines"}, "test_case_format": "function_call", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "5948ef981eebcf8165407af89c1be149bfa2ea75", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "maxUncrossedLines"} {"seed_id": "apps-00183", "original_id": null, "source": "apps", "domain": "code", "problem": "Given an integer array with all positive numbers and no duplicates, find the number of possible combinations that add up to a positive integer target.\n\nExample:\n\nnums = [1, 2, 3]\ntarget = 4\n\nThe possible combination ways are:\n(1, 1, 1, 1)\n(1, 1, 2)\n(1, 2, 1)\n(1, 3)\n(2, 1, 1)\n(2, 2)\n(3, 1)\n\nNote that different sequences are counted as different combinations.\n\nTherefore the output is 7.\n\n\n\nFollow up:\nWhat if negative numbers are allowed in the given array?\nHow does it change the problem?\nWhat limitation we need to add to the question to allow negative numbers? \n\nCredits:Special thanks to @pbrother for adding this problem and creating all test cases.", "starter_code": "\nclass Solution:\n def combinationSum4(self, nums: List[int], target: int) -> int:\n ", "test_cases": {"inputs": [[[1, 2, 3], 4]], "outputs": [7], "fn_name": "combinationSum4"}, "test_case_format": "function_call", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "074547b11f283c67fd2045e378217c1d9fbc872d", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "combinationSum4"} {"seed_id": "apps-00188", "original_id": null, "source": "apps", "domain": "code", "problem": "Return the length of the shortest, non-empty, contiguous subarray of A with sum at least K.\nIf there is no non-empty subarray with sum at least K, return -1.\n \n\n\n\nExample 1:\nInput: A = [1], K = 1\nOutput: 1\n\n\nExample 2:\nInput: A = [1,2], K = 4\nOutput: -1\n\n\nExample 3:\nInput: A = [2,-1,2], K = 3\nOutput: 3\n\n \nNote:\n\n1 <= A.length <= 50000\n-10 ^ 5 <= A[i] <= 10 ^ 5\n1 <= K <= 10 ^ 9", "starter_code": "\nclass Solution:\n def shortestSubarray(self, A: List[int], K: int) -> int:\n ", "test_cases": {"inputs": [[[1], 1]], "outputs": [1], "fn_name": "shortestSubarray"}, "test_case_format": "function_call", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "fad4b7573479bc26ea11c5bc16034480ca6f4d2a", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "shortestSubarray"} {"seed_id": "apps-00193", "original_id": null, "source": "apps", "domain": "code", "problem": "There is a pizza with 3n slices of varying size, you and your friends will take slices of pizza as follows:\n\nYou will pick any pizza slice.\nYour friend Alice will pick next slice in anti clockwise direction of your pick. \nYour friend Bob will pick next slice in clockwise direction of your pick.\nRepeat until there are no more slices of pizzas.\n\nSizes of Pizza slices is represented by circular array slices in clockwise direction.\nReturn the maximum possible sum of slice sizes which you can have.\n \nExample 1:\n\nInput: slices = [1,2,3,4,5,6]\nOutput: 10\nExplanation: Pick pizza slice of size 4, Alice and Bob will pick slices with size 3 and 5 respectively. Then Pick slices with size 6, finally Alice and Bob will pick slice of size 2 and 1 respectively. Total = 4 + 6.\n\nExample 2:\n\nInput: slices = [8,9,8,6,1,1]\nOutput: 16\nOutput: Pick pizza slice of size 8 in each turn. If you pick slice with size 9 your partners will pick slices of size 8.\n\nExample 3:\nInput: slices = [4,1,2,5,8,3,1,9,7]\nOutput: 21\n\nExample 4:\nInput: slices = [3,1,2]\nOutput: 3\n\n \nConstraints:\n\n1 <= slices.length <= 500\nslices.length % 3 == 0\n1 <= slices[i] <= 1000", "starter_code": "\nclass Solution:\n def maxSizeSlices(self, slices: List[int]) -> int:\n ", "test_cases": {"inputs": [[[1, 2, 3, 4, 5, 6]]], "outputs": [10], "fn_name": "maxSizeSlices"}, "test_case_format": "function_call", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "452ebaa814d55d072f8191446313d81f0c6d6a1a", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "maxSizeSlices"} {"seed_id": "apps-00198", "original_id": null, "source": "apps", "domain": "code", "problem": "Given s1, s2, s3, find whether s3 is formed by the interleaving of s1 and s2.\n\nExample 1:\n\n\nInput: s1 = \"aabcc\", s2 = \"dbbca\", s3 = \"aadbbcbcac\"\nOutput: true\n\n\nExample 2:\n\n\nInput: s1 = \"aabcc\", s2 = \"dbbca\", s3 = \"aadbbbaccc\"\nOutput: false", "starter_code": "\nclass Solution:\n def isInterleave(self, s1: str, s2: str, s3: str) -> bool:\n ", "test_cases": {"inputs": [["\"aabcc\"", "\"dbbca\"", "\"aadbbcbcac\""]], "outputs": [false], "fn_name": "isInterleave"}, "test_case_format": "function_call", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "66d4573d857c135bc0ce20ade9f6e2c97912e83a", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "isInterleave"} {"seed_id": "apps-00203", "original_id": null, "source": "apps", "domain": "code", "problem": "Validate if a given string is numeric.\n\nSome examples:\n\"0\" => true\n\" 0.1 \" => true\n\"abc\" => false\n\"1 a\" => false\n\"2e10\" => true\n\nNote: It is intended for the problem statement to be ambiguous. You should gather all requirements up front before implementing one.\n\nUpdate (2015-02-10):\nThe signature of the C++ function had been updated. If you still see your function signature accepts a const char * argument, please click the reload button to reset your code definition.", "starter_code": "\nclass Solution:\n def isNumber(self, s: str) -> bool:\n ", "test_cases": {"inputs": [["\"0\""]], "outputs": [false], "fn_name": "isNumber"}, "test_case_format": "function_call", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "b619582aa90f8c81f54d5e796b3b9c7fb16090e5", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "isNumber"} {"seed_id": "apps-00208", "original_id": null, "source": "apps", "domain": "code", "problem": "You are installing a billboard and want it to have the largest height.  The billboard will have two steel supports, one on each side.  Each steel support must be an equal height.\nYou have a collection of rods which can be welded together.  For example, if you have rods of lengths 1, 2, and 3, you can weld them together to make a support of length 6.\nReturn the largest possible height of your billboard installation.  If you cannot support the billboard, return 0.\n \nExample 1:\nInput: [1,2,3,6]\nOutput: 6\nExplanation: We have two disjoint subsets {1,2,3} and {6}, which have the same sum = 6.\n\n\nExample 2:\nInput: [1,2,3,4,5,6]\nOutput: 10\nExplanation: We have two disjoint subsets {2,3,5} and {4,6}, which have the same sum = 10.\n\n\n\nExample 3:\nInput: [1,2]\nOutput: 0\nExplanation: The billboard cannot be supported, so we return 0.\n\n\n \nNote:\n\n0 <= rods.length <= 20\n1 <= rods[i] <= 1000\nThe sum of rods is at most 5000.", "starter_code": "\nclass Solution:\n def tallestBillboard(self, rods: List[int]) -> int:\n ", "test_cases": {"inputs": [[[1, 2, 3, 6]]], "outputs": [6], "fn_name": "tallestBillboard"}, "test_case_format": "function_call", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "6aaf225690aa7b5b385b11bf8f7fd7c4344a52bc", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "tallestBillboard"} {"seed_id": "apps-00213", "original_id": null, "source": "apps", "domain": "code", "problem": "Write a program to find the n-th ugly number.\n\nUgly numbers are positive numbers whose prime factors only include 2, 3, 5. \n\nExample:\n\n\nInput: n = 10\nOutput: 12\nExplanation: 1, 2, 3, 4, 5, 6, 8, 9, 10, 12 is the sequence of the first 10 ugly numbers.\n\nNote:  \n\n\n 1 is typically treated as an ugly number.\n n does not exceed 1690.", "starter_code": "\nclass Solution:\n def nthUglyNumber(self, n: int) -> int:\n ", "test_cases": {"inputs": [[10]], "outputs": [12], "fn_name": "nthUglyNumber"}, "test_case_format": "function_call", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "49233f3a846591637bf12aa098ac9b960f5bdca7", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "nthUglyNumber"} {"seed_id": "apps-00218", "original_id": null, "source": "apps", "domain": "code", "problem": "Given an array of integers, return the maximum sum for a non-empty subarray (contiguous elements) with at most one element deletion. In other words, you want to choose a subarray and optionally delete one element from it so that there is still at least one element left and the sum of the remaining elements is maximum possible.\nNote that the subarray needs to be non-empty after deleting one element.\n \nExample 1:\nInput: arr = [1,-2,0,3]\nOutput: 4\nExplanation: Because we can choose [1, -2, 0, 3] and drop -2, thus the subarray [1, 0, 3] becomes the maximum value.\nExample 2:\nInput: arr = [1,-2,-2,3]\nOutput: 3\nExplanation: We just choose [3] and it's the maximum sum.\n\nExample 3:\nInput: arr = [-1,-1,-1,-1]\nOutput: -1\nExplanation: The final subarray needs to be non-empty. You can't choose [-1] and delete -1 from it, then get an empty subarray to make the sum equals to 0.\n\n \nConstraints:\n\n1 <= arr.length <= 10^5\n-10^4 <= arr[i] <= 10^4", "starter_code": "\nclass Solution:\n def maximumSum(self, arr: List[int]) -> int:\n ", "test_cases": {"inputs": [[[1, -2, 0, 3]]], "outputs": [4], "fn_name": "maximumSum"}, "test_case_format": "function_call", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "cd8951b0940015a1ab9c7a3f1f70e5dfa8d7aa23", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "maximumSum"} {"seed_id": "apps-00223", "original_id": null, "source": "apps", "domain": "code", "problem": "Given an array of integers nums and an integer target.\nReturn the number of non-empty subsequences of nums such that the sum of the minimum and maximum element on it is less or equal than target.\nSince the answer may be too large, return it modulo 10^9 + 7.\n \nExample 1:\nInput: nums = [3,5,6,7], target = 9\nOutput: 4\nExplanation: There are 4 subsequences that satisfy the condition.\n[3] -> Min value + max value <= target (3 + 3 <= 9)\n[3,5] -> (3 + 5 <= 9)\n[3,5,6] -> (3 + 6 <= 9)\n[3,6] -> (3 + 6 <= 9)\n\nExample 2:\nInput: nums = [3,3,6,8], target = 10\nOutput: 6\nExplanation: There are 6 subsequences that satisfy the condition. (nums can have repeated numbers).\n[3] , [3] , [3,3], [3,6] , [3,6] , [3,3,6]\nExample 3:\nInput: nums = [2,3,3,4,6,7], target = 12\nOutput: 61\nExplanation: There are 63 non-empty subsequences, two of them don't satisfy the condition ([6,7], [7]).\nNumber of valid subsequences (63 - 2 = 61).\n\nExample 4:\nInput: nums = [5,2,4,1,7,6,8], target = 16\nOutput: 127\nExplanation: All non-empty subset satisfy the condition (2^7 - 1) = 127\n \nConstraints:\n\n1 <= nums.length <= 10^5\n1 <= nums[i] <= 10^6\n1 <= target <= 10^6", "starter_code": "\nclass Solution:\n def numSubseq(self, nums: List[int], target: int) -> int:\n ", "test_cases": {"inputs": [[[3, 5, 6, 7], 9]], "outputs": [4], "fn_name": "numSubseq"}, "test_case_format": "function_call", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "ca60e9bdb1864b3afb0a7ec5764c30cc33bca907", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "numSubseq"} {"seed_id": "apps-00228", "original_id": null, "source": "apps", "domain": "code", "problem": "To some string S, we will perform some replacement operations that replace groups of letters with new ones (not necessarily the same size).\nEach replacement operation has 3 parameters: a starting index i, a source word x and a target word y.  The rule is that if x starts at position i in the original string S, then we will replace that occurrence of x with y.  If not, we do nothing.\nFor example, if we have S = \"abcd\" and we have some replacement operation i = 2, x = \"cd\", y = \"ffff\", then because \"cd\" starts at position 2 in the original string S, we will replace it with \"ffff\".\nUsing another example on S = \"abcd\", if we have both the replacement operation i = 0, x = \"ab\", y = \"eee\", as well as another replacement operation i = 2, x = \"ec\", y = \"ffff\", this second operation does nothing because in the original string S[2] = 'c', which doesn't match x[0] = 'e'.\nAll these operations occur simultaneously.  It's guaranteed that there won't be any overlap in replacement: for example, S = \"abc\", indexes = [0, 1], sources = [\"ab\",\"bc\"] is not a valid test case.\nExample 1:\nInput: S = \"abcd\", indexes = [0,2], sources = [\"a\",\"cd\"], targets = [\"eee\",\"ffff\"]\nOutput: \"eeebffff\"\nExplanation: \"a\" starts at index 0 in S, so it's replaced by \"eee\".\n\"cd\" starts at index 2 in S, so it's replaced by \"ffff\".\n\nExample 2:\nInput: S = \"abcd\", indexes = [0,2], sources = [\"ab\",\"ec\"], targets = [\"eee\",\"ffff\"]\nOutput: \"eeecd\"\nExplanation: \"ab\" starts at index 0 in S, so it's replaced by \"eee\". \n\"ec\" doesn't starts at index 2 in the original S, so we do nothing.\n\nNotes:\n\n0 <= indexes.length = sources.length = targets.length <= 100\n0 < indexes[i] < S.length <= 1000\nAll characters in given inputs are lowercase letters.", "starter_code": "\nclass Solution:\n def findReplaceString(self, S: str, indexes: List[int], sources: List[str], targets: List[str]) -> str:\n ", "test_cases": {"inputs": [["\"abcd\"", [0, 2], ["\"a\"", " \"cd\""], ["\"eee\"", " \"ffff\""]]], "outputs": ["\"abcd\""], "fn_name": "findReplaceString"}, "test_case_format": "function_call", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "da8e2b4098f1a8ec1db41adb1afa6f2a3d347b8e", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "findReplaceString"} {"seed_id": "apps-00233", "original_id": null, "source": "apps", "domain": "code", "problem": "Let's define a function countUniqueChars(s) that returns the number of unique characters on s, for example if s = \"LEETCODE\" then \"L\", \"T\",\"C\",\"O\",\"D\" are the unique characters since they appear only once in s, therefore countUniqueChars(s) = 5.\n\nOn this problem given a string s we need to return the sum of countUniqueChars(t) where t is a substring of s. Notice that some substrings can be repeated so on this case you have to count the repeated ones too.\nSince the answer can be very large, return the answer modulo 10 ^ 9 + 7.\n \nExample 1:\nInput: s = \"ABC\"\nOutput: 10\nExplanation: All possible substrings are: \"A\",\"B\",\"C\",\"AB\",\"BC\" and \"ABC\".\nEvey substring is composed with only unique letters.\nSum of lengths of all substring is 1 + 1 + 1 + 2 + 2 + 3 = 10\n\nExample 2:\nInput: s = \"ABA\"\nOutput: 8\nExplanation: The same as example 1, except countUniqueChars(\"ABA\") = 1.\n\nExample 3:\nInput: s = \"LEETCODE\"\nOutput: 92\n\n \nConstraints:\n\n0 <= s.length <= 10^4\ns contain upper-case English letters only.", "starter_code": "\nclass Solution:\n def uniqueLetterString(self, s: str) -> int:\n ", "test_cases": {"inputs": [["\"ABC\""]], "outputs": [33], "fn_name": "uniqueLetterString"}, "test_case_format": "function_call", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "82e1d3e3e1d25fe368478c321d2906807c93c353", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "uniqueLetterString"} {"seed_id": "apps-00238", "original_id": null, "source": "apps", "domain": "code", "problem": "Given an input string (s) and a pattern (p), implement regular expression matching with support for '.' and '*'.\n\n\n'.' Matches any single character.\n'*' Matches zero or more of the preceding element.\n\n\nThe matching should cover the entire input string (not partial).\n\nNote:\n\n\n s could be empty and contains only lowercase letters a-z.\n p could be empty and contains only lowercase letters a-z, and characters like . or *.\n\n\nExample 1:\n\n\nInput:\ns = \"aa\"\np = \"a\"\nOutput: false\nExplanation: \"a\" does not match the entire string \"aa\".\n\n\nExample 2:\n\n\nInput:\ns = \"aa\"\np = \"a*\"\nOutput: true\nExplanation: '*' means zero or more of the precedeng element, 'a'. Therefore, by repeating 'a' once, it becomes \"aa\".\n\n\nExample 3:\n\n\nInput:\ns = \"ab\"\np = \".*\"\nOutput: true\nExplanation: \".*\" means \"zero or more (*) of any character (.)\".\n\n\nExample 4:\n\n\nInput:\ns = \"aab\"\np = \"c*a*b\"\nOutput: true\nExplanation: c can be repeated 0 times, a can be repeated 1 time. Therefore it matches \"aab\".\n\n\nExample 5:\n\n\nInput:\ns = \"mississippi\"\np = \"mis*is*p*.\"\nOutput: false", "starter_code": "\nclass Solution:\n def isMatch(self, s: str, p: str) -> bool:\n ", "test_cases": {"inputs": [["\"aa\"", "\"a\""]], "outputs": [false], "fn_name": "isMatch"}, "test_case_format": "function_call", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "1b63962dec36eb6854874cc1536f12e0bb70f664", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "isMatch"} {"seed_id": "apps-00243", "original_id": null, "source": "apps", "domain": "code", "problem": "A positive integer is magical if it is divisible by either A or B.\nReturn the N-th magical number.  Since the answer may be very large, return it modulo 10^9 + 7.\n \n\n\n\nExample 1:\nInput: N = 1, A = 2, B = 3\nOutput: 2\n\n\nExample 2:\nInput: N = 4, A = 2, B = 3\nOutput: 6\n\n\nExample 3:\nInput: N = 5, A = 2, B = 4\nOutput: 10\n\n\nExample 4:\nInput: N = 3, A = 6, B = 4\nOutput: 8\n\n \nNote:\n\n1 <= N <= 10^9\n2 <= A <= 40000\n2 <= B <= 40000", "starter_code": "\nclass Solution:\n def nthMagicalNumber(self, N: int, A: int, B: int) -> int:\n ", "test_cases": {"inputs": [[1, 2, 3]], "outputs": [2], "fn_name": "nthMagicalNumber"}, "test_case_format": "function_call", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "ff97fdcf843e03c3ab7494f4bcd5d20c18ec3f7f", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "nthMagicalNumber"} {"seed_id": "apps-00248", "original_id": null, "source": "apps", "domain": "code", "problem": "A peak element is an element that is greater than its neighbors.\n\nGiven an input array nums, where nums[i] ≠ nums[i+1], find a peak element and return its index.\n\nThe array may contain multiple peaks, in that case return the index to any one of the peaks is fine.\n\nYou may imagine that nums[-1] = nums[n] = -∞.\n\nExample 1:\n\n\nInput: nums = [1,2,3,1]\nOutput: 2\nExplanation: 3 is a peak element and your function should return the index number 2.\n\nExample 2:\n\n\nInput: nums = [1,2,1,3,5,6,4]\nOutput: 1 or 5 \nExplanation: Your function can return either index number 1 where the peak element is 2, \n  or index number 5 where the peak element is 6.\n\n\nNote:\n\nYour solution should be in logarithmic complexity.", "starter_code": "\nclass Solution:\n def findPeakElement(self, nums: List[int]) -> int:\n ", "test_cases": {"inputs": [[[1, 2, 3, 1]]], "outputs": [2], "fn_name": "findPeakElement"}, "test_case_format": "function_call", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "d9fe95caee2736b627e8b0245cc90a5aacad3b5f", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "findPeakElement"} {"seed_id": "apps-00253", "original_id": null, "source": "apps", "domain": "code", "problem": "In a given integer array A, we must move every element of A to either list B or list C. (B and C initially start empty.)\nReturn true if and only if after such a move, it is possible that the average value of B is equal to the average value of C, and B and C are both non-empty.\nExample :\nInput: \n[1,2,3,4,5,6,7,8]\nOutput: true\nExplanation: We can split the array into [1,4,5,8] and [2,3,6,7], and both of them have the average of 4.5.\n\nNote:\n\nThe length of A will be in the range [1, 30].\nA[i] will be in the range of [0, 10000].", "starter_code": "\nclass Solution:\n def splitArraySameAverage(self, A: List[int]) -> bool:\n ", "test_cases": {"inputs": [[[1, 2, 3, 4, 5, 6, 7, 8]]], "outputs": [true], "fn_name": "splitArraySameAverage"}, "test_case_format": "function_call", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "da52ed0e08309bb7e7d9fd40945a30ad4a111f43", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "splitArraySameAverage"} {"seed_id": "apps-00258", "original_id": null, "source": "apps", "domain": "code", "problem": "Given a non-empty integer array, find the minimum number of moves required to make all array elements equal, where a move is incrementing a selected element by 1 or decrementing a selected element by 1.\n\nYou may assume the array's length is at most 10,000.\n\nExample:\n\nInput:\n[1,2,3]\n\nOutput:\n2\n\nExplanation:\nOnly two moves are needed (remember each move increments or decrements one element):\n\n[1,2,3] => [2,2,3] => [2,2,2]", "starter_code": "\nclass Solution:\n def minMoves2(self, nums: List[int]) -> int:\n ", "test_cases": {"inputs": [[[1, 2, 3]]], "outputs": [2], "fn_name": "minMoves2"}, "test_case_format": "function_call", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "4b284c3955cb372f940d82db48520c22a1b0b7fb", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "minMoves2"} {"seed_id": "apps-00263", "original_id": null, "source": "apps", "domain": "code", "problem": "Given n non-negative integers representing the histogram's bar height where the width of each bar is 1, find the area of largest rectangle in the histogram.\n\n\nAbove is a histogram where width of each bar is 1, given height = [2,1,5,6,2,3].\n\n \n\n\nThe largest rectangle is shown in the shaded area, which has area = 10 unit.\n\n \n\nExample:\n\n\nInput: [2,1,5,6,2,3]\nOutput: 10", "starter_code": "\nclass Solution:\n def largestRectangleArea(self, heights: List[int]) -> int:\n ", "test_cases": {"inputs": [[[2, 1, 5, 6, 2, 3, -1]]], "outputs": [10], "fn_name": "largestRectangleArea"}, "test_case_format": "function_call", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "3095cf6d23e7af0b69edc9454dac392cc32e2a15", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "largestRectangleArea"} {"seed_id": "apps-00268", "original_id": null, "source": "apps", "domain": "code", "problem": "Given two words (beginWord and endWord), and a dictionary's word list, find the length of shortest transformation sequence from beginWord to endWord, such that:\n\n\n Only one letter can be changed at a time.\n Each transformed word must exist in the word list. Note that beginWord is not a transformed word.\n\n\nNote:\n\n\n Return 0 if there is no such transformation sequence.\n All words have the same length.\n All words contain only lowercase alphabetic characters.\n You may assume no duplicates in the word list.\n You may assume beginWord and endWord are non-empty and are not the same.\n\n\nExample 1:\n\n\nInput:\nbeginWord = \"hit\",\nendWord = \"cog\",\nwordList = [\"hot\",\"dot\",\"dog\",\"lot\",\"log\",\"cog\"]\n\nOutput: 5\n\nExplanation: As one shortest transformation is \"hit\" -> \"hot\" -> \"dot\" -> \"dog\" -> \"cog\",\nreturn its length 5.\n\n\nExample 2:\n\n\nInput:\nbeginWord = \"hit\"\nendWord = \"cog\"\nwordList = [\"hot\",\"dot\",\"dog\",\"lot\",\"log\"]\n\nOutput: 0\n\nExplanation: The endWord \"cog\" is not in wordList, therefore no possible transformation.", "starter_code": "\nclass Solution:\n def ladderLength(self, beginWord: str, endWord: str, wordList: List[str]) -> int:\n ", "test_cases": {"inputs": [["\"hit\"", "\"cog\"", ["\"hot\"", "\"dot\"", "\"dog\"", "\"lot\"", "\"log\"", "\"cog\""]]], "outputs": [5], "fn_name": "ladderLength"}, "test_case_format": "function_call", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "8e099d221caff2e33a50aa2e9a32cdaa980419bc", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "ladderLength"} {"seed_id": "apps-00273", "original_id": null, "source": "apps", "domain": "code", "problem": "You have d dice, and each die has f faces numbered 1, 2, ..., f.\nReturn the number of possible ways (out of fd total ways) modulo 10^9 + 7 to roll the dice so the sum of the face up numbers equals target.\n \nExample 1:\nInput: d = 1, f = 6, target = 3\nOutput: 1\nExplanation: \nYou throw one die with 6 faces. There is only one way to get a sum of 3.\n\nExample 2:\nInput: d = 2, f = 6, target = 7\nOutput: 6\nExplanation: \nYou throw two dice, each with 6 faces. There are 6 ways to get a sum of 7:\n1+6, 2+5, 3+4, 4+3, 5+2, 6+1.\n\nExample 3:\nInput: d = 2, f = 5, target = 10\nOutput: 1\nExplanation: \nYou throw two dice, each with 5 faces. There is only one way to get a sum of 10: 5+5.\n\nExample 4:\nInput: d = 1, f = 2, target = 3\nOutput: 0\nExplanation: \nYou throw one die with 2 faces. There is no way to get a sum of 3.\n\nExample 5:\nInput: d = 30, f = 30, target = 500\nOutput: 222616187\nExplanation: \nThe answer must be returned modulo 10^9 + 7.\n\n \nConstraints:\n\n1 <= d, f <= 30\n1 <= target <= 1000", "starter_code": "\nclass Solution:\n def numRollsToTarget(self, d: int, f: int, target: int) -> int:\n ", "test_cases": {"inputs": [[1, 6, 3]], "outputs": [1], "fn_name": "numRollsToTarget"}, "test_case_format": "function_call", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "458f66280a3d78462311185192626e15e546989d", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "numRollsToTarget"} {"seed_id": "apps-00278", "original_id": null, "source": "apps", "domain": "code", "problem": "There are two sorted arrays nums1 and nums2 of size m and n respectively.\n\nFind the median of the two sorted arrays. The overall run time complexity should be O(log (m+n)).\n\nExample 1:\n\nnums1 = [1, 3]\nnums2 = [2]\n\nThe median is 2.0\n\n\n\nExample 2:\n\nnums1 = [1, 2]\nnums2 = [3, 4]\n\nThe median is (2 + 3)/2 = 2.5", "starter_code": "\nclass Solution:\n def findMedianSortedArrays(self, nums1: List[int], nums2: List[int]) -> float:\n ", "test_cases": {"inputs": [[[1, 3], [2]]], "outputs": [2.0], "fn_name": "findMedianSortedArrays"}, "test_case_format": "function_call", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "f3f90a15c49cb3f017e70e8c5b491ca65b62f686", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "findMedianSortedArrays"} {"seed_id": "apps-00283", "original_id": null, "source": "apps", "domain": "code", "problem": "Given a string s, find the longest palindromic substring in s. You may assume that the maximum length of s is 1000.\n\nExample 1:\n\n\nInput: \"babad\"\nOutput: \"bab\"\nNote: \"aba\" is also a valid answer.\n\n\nExample 2:\n\n\nInput: \"cbbd\"\nOutput: \"bb\"", "starter_code": "\nclass Solution:\n def longestPalindrome(self, s: str) -> str:\n ", "test_cases": {"inputs": [["\"babad\""]], "outputs": ["bab"], "fn_name": "longestPalindrome"}, "test_case_format": "function_call", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "6eb44f371fab3b2daf97abfcaa020731606ace82", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "longestPalindrome"} {"seed_id": "apps-00288", "original_id": null, "source": "apps", "domain": "code", "problem": "We are given a 2-dimensional grid. \".\" is an empty cell, \"#\" is a wall, \"@\" is the starting point, (\"a\", \"b\", ...) are keys, and (\"A\", \"B\", ...) are locks.\nWe start at the starting point, and one move consists of walking one space in one of the 4 cardinal directions.  We cannot walk outside the grid, or walk into a wall.  If we walk over a key, we pick it up.  We can't walk over a lock unless we have the corresponding key.\nFor some 1 <= K <= 6, there is exactly one lowercase and one uppercase letter of the first K letters of the English alphabet in the grid.  This means that there is exactly one key for each lock, and one lock for each key; and also that the letters used to represent the keys and locks were chosen in the same order as the English alphabet.\nReturn the lowest number of moves to acquire all keys.  If it's impossible, return -1.\n \n\nExample 1:\nInput: [\"@.a.#\",\"###.#\",\"b.A.B\"]\nOutput: 8\n\n\nExample 2:\nInput: [\"@..aA\",\"..B#.\",\"....b\"]\nOutput: 6\n\n\n \nNote:\n\n1 <= grid.length <= 30\n1 <= grid[0].length <= 30\ngrid[i][j] contains only '.', '#', '@', 'a'-'f' and 'A'-'F'\nThe number of keys is in [1, 6].  Each key has a different letter and opens exactly one lock.", "starter_code": "\nclass Solution:\n def shortestPathAllKeys(self, grid: List[str]) -> int:\n ", "test_cases": {"inputs": [[["\"@.a.#\"", "\"###.#\"", "\"b.A.B\""]]], "outputs": [8], "fn_name": "shortestPathAllKeys"}, "test_case_format": "function_call", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "ab74fbe9816c6fbe0ed6cb9c58534e1acfd1f891", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "shortestPathAllKeys"} {"seed_id": "apps-00293", "original_id": null, "source": "apps", "domain": "code", "problem": "Given an array of integers arr and two integers k and threshold.\nReturn the number of sub-arrays of size k and average greater than or equal to threshold.\n \nExample 1:\nInput: arr = [2,2,2,2,5,5,5,8], k = 3, threshold = 4\nOutput: 3\nExplanation: Sub-arrays [2,5,5],[5,5,5] and [5,5,8] have averages 4, 5 and 6 respectively. All other sub-arrays of size 3 have averages less than 4 (the threshold).\n\nExample 2:\nInput: arr = [1,1,1,1,1], k = 1, threshold = 0\nOutput: 5\n\nExample 3:\nInput: arr = [11,13,17,23,29,31,7,5,2,3], k = 3, threshold = 5\nOutput: 6\nExplanation: The first 6 sub-arrays of size 3 have averages greater than 5. Note that averages are not integers.\n\nExample 4:\nInput: arr = [7,7,7,7,7,7,7], k = 7, threshold = 7\nOutput: 1\n\nExample 5:\nInput: arr = [4,4,4,4], k = 4, threshold = 1\nOutput: 1\n\n \nConstraints:\n\n1 <= arr.length <= 10^5\n1 <= arr[i] <= 10^4\n1 <= k <= arr.length\n0 <= threshold <= 10^4", "starter_code": "\nclass Solution:\n def numOfSubarrays(self, arr: List[int], k: int, threshold: int) -> int:\n ", "test_cases": {"inputs": [[[2, 2, 2, 2, 5, 5, 5, 8], 3, 4]], "outputs": [3], "fn_name": "numOfSubarrays"}, "test_case_format": "function_call", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "555cc09813b07dad7852979bc30fb20c5f0bac86", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "numOfSubarrays"} {"seed_id": "apps-00298", "original_id": null, "source": "apps", "domain": "code", "problem": "Given an array arr that represents a permutation of numbers from 1 to n. You have a binary string of size n that initially has all its bits set to zero.\nAt each step i (assuming both the binary string and arr are 1-indexed) from 1 to n, the bit at position arr[i] is set to 1. You are given an integer m and you need to find the latest step at which there exists a group of ones of length m. A group of ones is a contiguous substring of 1s such that it cannot be extended in either direction.\nReturn the latest step at which there exists a group of ones of length exactly m. If no such group exists, return -1.\n \nExample 1:\nInput: arr = [3,5,1,2,4], m = 1\nOutput: 4\nExplanation:\nStep 1: \"00100\", groups: [\"1\"]\nStep 2: \"00101\", groups: [\"1\", \"1\"]\nStep 3: \"10101\", groups: [\"1\", \"1\", \"1\"]\nStep 4: \"11101\", groups: [\"111\", \"1\"]\nStep 5: \"11111\", groups: [\"11111\"]\nThe latest step at which there exists a group of size 1 is step 4.\nExample 2:\nInput: arr = [3,1,5,4,2], m = 2\nOutput: -1\nExplanation:\nStep 1: \"00100\", groups: [\"1\"]\nStep 2: \"10100\", groups: [\"1\", \"1\"]\nStep 3: \"10101\", groups: [\"1\", \"1\", \"1\"]\nStep 4: \"10111\", groups: [\"1\", \"111\"]\nStep 5: \"11111\", groups: [\"11111\"]\nNo group of size 2 exists during any step.\n\nExample 3:\nInput: arr = [1], m = 1\nOutput: 1\n\nExample 4:\nInput: arr = [2,1], m = 2\nOutput: 2\n\n \nConstraints:\n\nn == arr.length\n1 <= n <= 10^5\n1 <= arr[i] <= n\nAll integers in arr are distinct.\n1 <= m <= arr.length", "starter_code": "\nclass Solution:\n def findLatestStep(self, arr: List[int], m: int) -> int:\n ", "test_cases": {"inputs": [[[3, 5, 1, 2, 4], 1]], "outputs": [4], "fn_name": "findLatestStep"}, "test_case_format": "function_call", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "2b4a76304924436b8fdb84f70feb989c5e745174", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "findLatestStep"} {"seed_id": "apps-00303", "original_id": null, "source": "apps", "domain": "code", "problem": "n passengers board an airplane with exactly n seats. The first passenger has lost the ticket and picks a seat randomly. But after that, the rest of passengers will:\n\nTake their own seat if it is still available, \nPick other seats randomly when they find their seat occupied \n\nWhat is the probability that the n-th person can get his own seat?\n \nExample 1:\nInput: n = 1\nOutput: 1.00000\nExplanation: The first person can only get the first seat.\nExample 2:\nInput: n = 2\nOutput: 0.50000\nExplanation: The second person has a probability of 0.5 to get the second seat (when first person gets the first seat).\n\n \nConstraints:\n\n1 <= n <= 10^5", "starter_code": "\nclass Solution:\n def nthPersonGetsNthSeat(self, n: int) -> float:\n ", "test_cases": {"inputs": [[1]], "outputs": [1.0], "fn_name": "nthPersonGetsNthSeat"}, "test_case_format": "function_call", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "fcaf26d0df459d43c5442dd49c952a1b74aebb80", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "nthPersonGetsNthSeat"} {"seed_id": "apps-00308", "original_id": null, "source": "apps", "domain": "code", "problem": "Suppose an array sorted in ascending order is rotated at some pivot unknown to you beforehand.\n\n(i.e.,  [0,1,2,4,5,6,7] might become  [4,5,6,7,0,1,2]).\n\nFind the minimum element.\n\nYou may assume no duplicate exists in the array.\n\nExample 1:\n\n\nInput: [3,4,5,1,2] \nOutput: 1\n\n\nExample 2:\n\n\nInput: [4,5,6,7,0,1,2]\nOutput: 0", "starter_code": "\nclass Solution:\n def findMin(self, nums: List[int]) -> int:\n ", "test_cases": {"inputs": [[[3, 4, 5, 1, 2]]], "outputs": [1], "fn_name": "findMin"}, "test_case_format": "function_call", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "c2d9ce47604f557a0a9a24d70cafd39e4dccebb3", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "findMin"} {"seed_id": "apps-00313", "original_id": null, "source": "apps", "domain": "code", "problem": "A frog is crossing a river. The river is divided into x units and at each unit there may or may not exist a stone. The frog can jump on a stone, but it must not jump into the water.\n\nGiven a list of stones' positions (in units) in sorted ascending order, determine if the frog is able to cross the river by landing on the last stone. Initially, the frog is on the first stone and assume the first jump must be 1 unit.\n\n\nIf the frog's last jump was k units, then its next jump must be either k - 1, k, or k + 1 units. Note that the frog can only jump in the forward direction.\n\nNote:\n\nThe number of stones is ≥ 2 and is < 1,100.\nEach stone's position will be a non-negative integer < 231.\nThe first stone's position is always 0.\n\n\n\nExample 1:\n\n[0,1,3,5,6,8,12,17]\n\nThere are a total of 8 stones.\nThe first stone at the 0th unit, second stone at the 1st unit,\nthird stone at the 3rd unit, and so on...\nThe last stone at the 17th unit.\n\nReturn true. The frog can jump to the last stone by jumping \n1 unit to the 2nd stone, then 2 units to the 3rd stone, then \n2 units to the 4th stone, then 3 units to the 6th stone, \n4 units to the 7th stone, and 5 units to the 8th stone.\n\n\n\nExample 2:\n\n[0,1,2,3,4,8,9,11]\n\nReturn false. There is no way to jump to the last stone as \nthe gap between the 5th and 6th stone is too large.", "starter_code": "\nclass Solution:\n def canCross(self, stones: List[int]) -> bool:\n ", "test_cases": {"inputs": [[[0, 1, 3, 4, 5, 7, 9, 10, 12]]], "outputs": [true], "fn_name": "canCross"}, "test_case_format": "function_call", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "98d8b92d076179ea33e1b9611dfbb9763b4b315d", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "canCross"} {"seed_id": "apps-00318", "original_id": null, "source": "apps", "domain": "code", "problem": "A company has n employees with a unique ID for each employee from 0 to n - 1. The head of the company has is the one with headID.\nEach employee has one direct manager given in the manager array where manager[i] is the direct manager of the i-th employee, manager[headID] = -1. Also it's guaranteed that the subordination relationships have a tree structure.\nThe head of the company wants to inform all the employees of the company of an urgent piece of news. He will inform his direct subordinates and they will inform their subordinates and so on until all employees know about the urgent news.\nThe i-th employee needs informTime[i] minutes to inform all of his direct subordinates (i.e After informTime[i] minutes, all his direct subordinates can start spreading the news).\nReturn the number of minutes needed to inform all the employees about the urgent news.\n \nExample 1:\nInput: n = 1, headID = 0, manager = [-1], informTime = [0]\nOutput: 0\nExplanation: The head of the company is the only employee in the company.\n\nExample 2:\n\nInput: n = 6, headID = 2, manager = [2,2,-1,2,2,2], informTime = [0,0,1,0,0,0]\nOutput: 1\nExplanation: The head of the company with id = 2 is the direct manager of all the employees in the company and needs 1 minute to inform them all.\nThe tree structure of the employees in the company is shown.\n\nExample 3:\n\nInput: n = 7, headID = 6, manager = [1,2,3,4,5,6,-1], informTime = [0,6,5,4,3,2,1]\nOutput: 21\nExplanation: The head has id = 6. He will inform employee with id = 5 in 1 minute.\nThe employee with id = 5 will inform the employee with id = 4 in 2 minutes.\nThe employee with id = 4 will inform the employee with id = 3 in 3 minutes.\nThe employee with id = 3 will inform the employee with id = 2 in 4 minutes.\nThe employee with id = 2 will inform the employee with id = 1 in 5 minutes.\nThe employee with id = 1 will inform the employee with id = 0 in 6 minutes.\nNeeded time = 1 + 2 + 3 + 4 + 5 + 6 = 21.\n\nExample 4:\nInput: n = 15, headID = 0, manager = [-1,0,0,1,1,2,2,3,3,4,4,5,5,6,6], informTime = [1,1,1,1,1,1,1,0,0,0,0,0,0,0,0]\nOutput: 3\nExplanation: The first minute the head will inform employees 1 and 2.\nThe second minute they will inform employees 3, 4, 5 and 6.\nThe third minute they will inform the rest of employees.\n\nExample 5:\nInput: n = 4, headID = 2, manager = [3,3,-1,2], informTime = [0,0,162,914]\nOutput: 1076\n\n \nConstraints:\n\n1 <= n <= 10^5\n0 <= headID < n\nmanager.length == n\n0 <= manager[i] < n\nmanager[headID] == -1\ninformTime.length == n\n0 <= informTime[i] <= 1000\ninformTime[i] == 0 if employee i has no subordinates.\nIt is guaranteed that all the employees can be informed.", "starter_code": "\nclass Solution:\n def numOfMinutes(self, n: int, headID: int, manager: List[int], informTime: List[int]) -> int:\n ", "test_cases": {"inputs": [[1, 0, [-1], [0]]], "outputs": [0], "fn_name": "numOfMinutes"}, "test_case_format": "function_call", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "18a979b5a7cdebd3b5330f25970a6d79bf33a83e", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "numOfMinutes"} {"seed_id": "apps-00323", "original_id": null, "source": "apps", "domain": "code", "problem": "Given an integer array nums, return the sum of divisors of the integers in that array that have exactly four divisors.\nIf there is no such integer in the array, return 0.\n \nExample 1:\nInput: nums = [21,4,7]\nOutput: 32\nExplanation:\n21 has 4 divisors: 1, 3, 7, 21\n4 has 3 divisors: 1, 2, 4\n7 has 2 divisors: 1, 7\nThe answer is the sum of divisors of 21 only.\n\n \nConstraints:\n\n1 <= nums.length <= 10^4\n1 <= nums[i] <= 10^5", "starter_code": "\nclass Solution:\n def sumFourDivisors(self, nums: List[int]) -> int:\n ", "test_cases": {"inputs": [[[21, 4, 7]]], "outputs": [32], "fn_name": "sumFourDivisors"}, "test_case_format": "function_call", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "5dda338af1edb1cfbbbc0dec56299438be7c8dac", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "sumFourDivisors"} {"seed_id": "apps-00328", "original_id": null, "source": "apps", "domain": "code", "problem": "Given an array of integers arr.\nWe want to select three indices i, j and k where (0 <= i < j <= k < arr.length).\nLet's define a and b as follows:\n\na = arr[i] ^ arr[i + 1] ^ ... ^ arr[j - 1]\nb = arr[j] ^ arr[j + 1] ^ ... ^ arr[k]\n\nNote that ^ denotes the bitwise-xor operation.\nReturn the number of triplets (i, j and k) Where a == b.\n \nExample 1:\nInput: arr = [2,3,1,6,7]\nOutput: 4\nExplanation: The triplets are (0,1,2), (0,2,2), (2,3,4) and (2,4,4)\n\nExample 2:\nInput: arr = [1,1,1,1,1]\nOutput: 10\n\nExample 3:\nInput: arr = [2,3]\nOutput: 0\n\nExample 4:\nInput: arr = [1,3,5,7,9]\nOutput: 3\n\nExample 5:\nInput: arr = [7,11,12,9,5,2,7,17,22]\nOutput: 8\n\n \nConstraints:\n\n1 <= arr.length <= 300\n1 <= arr[i] <= 10^8", "starter_code": "\nclass Solution:\n def countTriplets(self, arr: List[int]) -> int:\n ", "test_cases": {"inputs": [[[2, 3, 1, 6, 7]]], "outputs": [4], "fn_name": "countTriplets"}, "test_case_format": "function_call", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "83c99303cd9b3ac1edbb2dd56f4abab76611d885", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "countTriplets"} {"seed_id": "apps-00333", "original_id": null, "source": "apps", "domain": "code", "problem": "There is a brick wall in front of you. The wall is rectangular and has several rows of bricks. The bricks have the same height but different width. You want to draw a vertical line from the top to the bottom and cross the least bricks. \n\n\nThe brick wall is represented by a list of rows. Each row is a list of integers representing the width of each brick in this row from left to right. \n\n\nIf your line go through the edge of a brick, then the brick is not considered as crossed. You need to find out how to draw the line to cross the least bricks and return the number of crossed bricks. \n\nYou cannot draw a line just along one of the two vertical edges of the wall, in which case the line will obviously cross no bricks. \n\nExample:\n\nInput: \n[[1,2,2,1],\n [3,1,2],\n [1,3,2],\n [2,4],\n [3,1,2],\n [1,3,1,1]]\nOutput: 2\nExplanation: \n\n\n\n\nNote:\n\nThe width sum of bricks in different rows are the same and won't exceed INT_MAX.\nThe number of bricks in each row is in range [1,10,000]. The height of wall is in range [1,10,000]. Total number of bricks of the wall won't exceed 20,000.", "starter_code": "\nclass Solution:\n def leastBricks(self, wall: List[List[int]]) -> int:\n ", "test_cases": {"inputs": [[[[1, 2, 2, 1], [3, 1, 2], [1, 3, 2], [2, 4], [3, 1, 2], [1, 3, 1, 1], [], []]]], "outputs": [4], "fn_name": "leastBricks"}, "test_case_format": "function_call", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "6f0be30d7532924b4e98d6570d843cdeea21b8fd", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "leastBricks"} {"seed_id": "apps-00338", "original_id": null, "source": "apps", "domain": "code", "problem": "Find the smallest prime palindrome greater than or equal to N.\nRecall that a number is prime if it's only divisors are 1 and itself, and it is greater than 1. \nFor example, 2,3,5,7,11 and 13 are primes.\nRecall that a number is a palindrome if it reads the same from left to right as it does from right to left. \nFor example, 12321 is a palindrome.\n \n\nExample 1:\nInput: 6\nOutput: 7\n\n\nExample 2:\nInput: 8\nOutput: 11\n\n\nExample 3:\nInput: 13\nOutput: 101\n\n\n\n \nNote:\n\n1 <= N <= 10^8\nThe answer is guaranteed to exist and be less than 2 * 10^8.", "starter_code": "\nclass Solution:\n def primePalindrome(self, N: int) -> int:\n ", "test_cases": {"inputs": [[6]], "outputs": [7], "fn_name": "primePalindrome"}, "test_case_format": "function_call", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "e94ffab60e018d8d15d0a74bc9251e11be541a89", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "primePalindrome"} {"seed_id": "apps-00343", "original_id": null, "source": "apps", "domain": "code", "problem": "There are N rooms and you start in room 0.  Each room has a distinct number in 0, 1, 2, ..., N-1, and each room may have some keys to access the next room. \nFormally, each room i has a list of keys rooms[i], and each key rooms[i][j] is an integer in [0, 1, ..., N-1] where N = rooms.length.  A key rooms[i][j] = v opens the room with number v.\nInitially, all the rooms start locked (except for room 0). \nYou can walk back and forth between rooms freely.\nReturn true if and only if you can enter every room.\n\n\nExample 1:\nInput: [[1],[2],[3],[]]\nOutput: true\nExplanation: \nWe start in room 0, and pick up key 1.\nWe then go to room 1, and pick up key 2.\nWe then go to room 2, and pick up key 3.\nWe then go to room 3. Since we were able to go to every room, we return true.\n\nExample 2:\nInput: [[1,3],[3,0,1],[2],[0]]\nOutput: false\nExplanation: We can't enter the room with number 2.\n\nNote:\n\n1 <= rooms.length <= 1000\n0 <= rooms[i].length <= 1000\nThe number of keys in all rooms combined is at most 3000.", "starter_code": "\nclass Solution:\n def canVisitAllRooms(self, rooms: List[List[int]]) -> bool:\n ", "test_cases": {"inputs": [[[[1], [2], [3], [], [], []]]], "outputs": [false], "fn_name": "canVisitAllRooms"}, "test_case_format": "function_call", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "89f5d7f7d34dfc5ae928916ef1818c36b741b5b5", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "canVisitAllRooms"} {"seed_id": "apps-00348", "original_id": null, "source": "apps", "domain": "code", "problem": "We have n jobs, where every job is scheduled to be done from startTime[i] to endTime[i], obtaining a profit of profit[i].\nYou're given the startTime , endTime and profit arrays, you need to output the maximum profit you can take such that there are no 2 jobs in the subset with overlapping time range.\nIf you choose a job that ends at time X you will be able to start another job that starts at time X.\n \nExample 1:\n\nInput: startTime = [1,2,3,3], endTime = [3,4,5,6], profit = [50,10,40,70]\nOutput: 120\nExplanation: The subset chosen is the first and fourth job. \nTime range [1-3]+[3-6] , we get profit of 120 = 50 + 70.\n\nExample 2:\n \n\nInput: startTime = [1,2,3,4,6], endTime = [3,5,10,6,9], profit = [20,20,100,70,60]\nOutput: 150\nExplanation: The subset chosen is the first, fourth and fifth job. \nProfit obtained 150 = 20 + 70 + 60.\n\nExample 3:\n\nInput: startTime = [1,1,1], endTime = [2,3,4], profit = [5,6,4]\nOutput: 6\n\n \nConstraints:\n\n1 <= startTime.length == endTime.length == profit.length <= 5 * 10^4\n1 <= startTime[i] < endTime[i] <= 10^9\n1 <= profit[i] <= 10^4", "starter_code": "\nclass Solution:\n def jobScheduling(self, startTime: List[int], endTime: List[int], profit: List[int]) -> int:\n ", "test_cases": {"inputs": [[[1, 2, 3, 3], [3, 4, 5, 6], [50, 10, 40, 70]]], "outputs": [120], "fn_name": "jobScheduling"}, "test_case_format": "function_call", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "02d5fb21ac36e359115ba1f739ca815eb55e92d7", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "jobScheduling"} {"seed_id": "apps-00353", "original_id": null, "source": "apps", "domain": "code", "problem": "You are given a string s that consists of lower case English letters and brackets. \nReverse the strings in each pair of matching parentheses, starting from the innermost one.\nYour result should not contain any brackets.\n \nExample 1:\nInput: s = \"(abcd)\"\nOutput: \"dcba\"\n\nExample 2:\nInput: s = \"(u(love)i)\"\nOutput: \"iloveu\"\nExplanation: The substring \"love\" is reversed first, then the whole string is reversed.\n\nExample 3:\nInput: s = \"(ed(et(oc))el)\"\nOutput: \"leetcode\"\nExplanation: First, we reverse the substring \"oc\", then \"etco\", and finally, the whole string.\n\nExample 4:\nInput: s = \"a(bcdefghijkl(mno)p)q\"\nOutput: \"apmnolkjihgfedcbq\"\n\n \nConstraints:\n\n0 <= s.length <= 2000\ns only contains lower case English characters and parentheses.\nIt's guaranteed that all parentheses are balanced.", "starter_code": "\nclass Solution:\n def reverseParentheses(self, s: str) -> str:\n ", "test_cases": {"inputs": [["\"(abcd)\""]], "outputs": ["\"dcba\""], "fn_name": "reverseParentheses"}, "test_case_format": "function_call", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "47ce4004761e971d5aed4d9684cb8dc60df4746d", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "reverseParentheses"} {"seed_id": "apps-00358", "original_id": null, "source": "apps", "domain": "code", "problem": "You are given a string S of length N consisting of lowercase English letters.\nProcess Q queries of the following two types:\n - Type 1: change the i_q-th character of S to c_q. (Do nothing if the i_q-th character is already c_q.)\n - Type 2: answer the number of different characters occurring in the substring of S between the l_q-th and r_q-th characters (inclusive).\n\n-----Constraints-----\n - N, Q, i_q, l_q, and r_q are integers.\n - S is a string consisting of lowercase English letters.\n - c_q is a lowercase English letter.\n - 1 \\leq N \\leq 500000\n - 1 \\leq Q \\leq 20000\n - |S| = N\n - 1 \\leq i_q \\leq N\n - 1 \\leq l_q \\leq r_q \\leq N\n - There is at least one query of type 2 in each testcase.\n\n-----Input-----\nInput is given from Standard Input in the following format:\nN\nS\nQ\nQuery_1\n\\vdots\nQuery_Q\n\nHere, Query_i in the 4-th through (Q+3)-th lines is one of the following:\n1 i_q c_q\n\n2 l_q r_q\n\n-----Output-----\nFor each query of type 2, print a line containing the answer.\n\n-----Sample Input-----\n7\nabcdbbd\n6\n2 3 6\n1 5 z\n2 1 1\n1 4 a\n1 7 d\n2 1 7\n\n-----Sample Output-----\n3\n1\n5\n\nIn the first query, cdbb contains three kinds of letters: b , c , and d, so we print 3.\nIn the second query, S is modified to abcdzbd.\nIn the third query, a contains one kind of letter: a, so we print 1.\nIn the fourth query, S is modified to abcazbd.\nIn the fifth query, S does not change and is still abcazbd.\nIn the sixth query, abcazbd contains five kinds of letters: a, b, c, d, and z, so we print 5.", "starter_code": "", "test_cases": {"inputs": ["7\nabcdbbd\n6\n2 3 6\n1 5 z\n2 1 1\n1 4 a\n1 7 d\n2 1 7\n"], "outputs": ["3\n1\n5\n"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "ddde85753a5cfc58728f8089715175567490b733", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-00363", "original_id": null, "source": "apps", "domain": "code", "problem": "Indian National Olympiad in Informatics 2015\nA string is any nonempty sequence of 0s and 1s. Examples of strings are 00, 101, 111000, 1, 0, 01. The length of a string is the number of symbols in it. For example, the length of 111000 is 6. If u and v are strings, then uv is the string obtained by concatenating u and v. For example if u = 110 and v = 0010 then uv = 1100010.\nA string w is periodic if there exists a string v such that w = vn = vv · · · v (n times), for some n ≥ 2. Note that in this case the length of v is strictly less than that of w. For example, 110110 is periodic, because it is vv for v = 110.\nGiven a positive integer N , find the number of strings of length N which are not periodic. Report the answer modulo M . The non-periodic strings of length 2 are 10 and 01. The non- periodic strings of length 3 are 001, 010, 011, 100, 101, and 110.\n\n-----Input format-----\nA single line, with two space-separated integers, N and M .\n\n-----Output format-----\nA single integer, the number of non-periodic strings of length N , modulo M .\n\n-----Test Data-----\nIn all subtasks, 2 ≤ M ≤ 108. The testdata is grouped into 4 subtasks.\nSubtask 1 (10 marks) 1 ≤ N ≤ 4000. N is the product of two distinct prime numbers.\nSubtask 2 (20 marks) 1 ≤ N ≤ 4000. N is a power of a prime number.\nSubtask 3 (35 marks) 1 ≤ N ≤ 4000.\nSubtask 4 (35 marks) 1 ≤ N ≤ 150000.\n\n-----Example-----\nHere is the sample input and output corresponding to the example above:\n\n-----Sample input-----\n3 176\n\n-----Sample output-----\n6\n\nNote: Your program should not print anything other than what is specified in the output format. Please remove all diagnostic print statements before making your final submission. A program with extraneous output will be treated as incorrect!", "starter_code": "", "test_cases": {"inputs": ["3 176"], "outputs": ["6"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "9a6d0478c44b9de7d1699ae0370ab3b42fe993e1", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-00368", "original_id": null, "source": "apps", "domain": "code", "problem": "Three Best Friends $AMAN$ , $AKBAR$ , $ANTHONY$ are planning to go to “GOA” , but just like every other goa trip plan there is a problem to their plan too.\nTheir parents will only give permission if they can solve this problem for them\nThey are a given a number N and they have to calculate the total number of triplets (x ,y ,z)\nSatisfying the given condition y * x +z=n.\nFor ex if N=3\nThen there exist 3 triplets( x ,y ,z): (1,1,2) , (1,2,1) , (2,1,1) which satisfy the condition\nHelp the group to get permission for the trip\n\n-----Input:-----\n- First line will contain the number $N$.\n\n-----Output:-----\nthe possible number of triplets satisfying the given condition\n\n-----Constraints-----\n- $2 \\leq N \\leq 10^6$\n\n-----Sample Input:-----\n3\n\n-----Sample Output:-----\n3\n\n-----EXPLANATION:-----\nthere exist 3 triplets ( x ,y ,z): (1,1,2) , (1,2,1) , (2,1,1) which satisfy the condition", "starter_code": "", "test_cases": {"inputs": ["3"], "outputs": ["3"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "0e9dd5b10d29a792ab594d034e1d1596949a773f", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-00373", "original_id": null, "source": "apps", "domain": "code", "problem": "Recently in JEC ants have become huge, the Principal is on a journey to snipe them !!\nPrincipal has limited $N$ practice Bullets to practice so that he can be sure to kill ants.\n- The Practice ground has max length $L$.\n- There is a Limit X such that if the bullet is fired beyond this, it will destroy and it wont be of any further use.\n- Bullet can be reused if fired in a range strictly less than X.\nHe wants to find minimum number of shots taken to find the distance X by using $N$ bullets.\n\n-----Input:-----\n- First line will contain $T$, number of testcases. Then the testcases follow. \n- Each testcase contains of a single line of input, two integers $N, L$. \n\n-----Output:-----\nFor each testcase, output in a single line answer the minimum number of shots to find the distance X.\n\n-----Constraints-----\n- $1 \\leq T \\leq 10$\n- $2 \\leq N,L \\leq 100$\n*N is always less than equal to square root of L\n\n-----Subtasks-----\n- 10 points : $ N = 1$\n- 40 points : $ N = 2$\n- 50 points : Original Constraints.\n\n-----Sample Input:-----\n2\n1 10\n2 10\n\n-----Sample Output:-----\n10\n4\n\n-----EXPLANATION:-----\n- \nThere is only single bullet which is to be fired from distance 1 to 10 to get the distance X so in the worst case it can take up to 10 shots to find the distance X.\n- \nthere are 2 bullets and distance 10 meters suppose if distance X is 10 we can get to that by firing first bullet at 4 then 7 then 9 then at 10 it will break it took only 4 turns, and if the distance X was 3, we can get that by firing first bullet at 4 it will get destroyed than we use 2nd bullet at 1 , 2, 3 and 2nd bullet will also break it also took 4 turns. You can check for any position minimum number of turns will be at most 4.", "starter_code": "", "test_cases": {"inputs": ["2\n1 10\n2 10"], "outputs": ["10\n4"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "2a88f892dad9a461aa0afce391df14d597dacd90", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-00378", "original_id": null, "source": "apps", "domain": "code", "problem": "2021 was approaching and the world was about to end. So 2 gods Saurabhx and Saurabhy (from Celesta) created the Cyberverse. But this time disappointed with humans both the gods decided not to have humans in this world. So they created a world of cyborgs. A world without humans. Isn’t it interesting? So let us dive into the cyberverse and have a look at their problems.\nThere are $N$ kid cyborgs with Chief Cyborg '100gods' and he has $K$ weapons with him. He wants to distribute those $K$ weapons among $N$ kid cyborgs. Since all the kid cyborgs are very good friends, so they set a rule among themselves for taking those weapons. The rule states that the difference between kid cyborg having the maximum weapons and the kid cyborg having minimum weapons should be less than or equal to $1$.\n\nFind the value of the minimum number of weapons a kid cyborg can have when all the $K$ weapons are distributed among them.\n\n-----Input:-----\n- The first line contains an integer $T$, denoting the number of test cases.\n- Each of the next $T$ lines will contain two space-separated integers denoting $N$ and $K$ respectively.\n\n-----Output:-----\n- For each test case ,output a single line containing an integer $X$ denoting the minimum number of weapons a kid cyborg can have in that test case. \n\n-----Constraints:-----\n- $1 \\leq T \\leq 10^5$\n- $1 \\leq N \\leq 10^5$\n- $1 \\leq K \\leq 10^9$\n\n-----Sample Input:-----\n1\n5 8\n\n-----Expected Output:-----\n1\n\n-----Explanation-----\n- There are $5$ kids and $8$ weapons. \n- Hence we will distribute the weapons such that $3$ kids have $2$ weapons each and the remaining $2$ kids have $1$ weapon each. \n- Hence the minimum number of weapons a kid cyborg has is $1$. ( That is, $min(1,2)$ = $1$ )", "starter_code": "", "test_cases": {"inputs": ["1\n5 8"], "outputs": ["1"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "d4c7aa4a4d7b3b55aba2d11aa12aa592bb210093", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-00383", "original_id": null, "source": "apps", "domain": "code", "problem": "\"Humankind cannot gain anything without first giving something in return. To obtain, something of equal value must be lost. That is alchemy's first law of Equivalent Exchange. In those days, we really believed that to be the world's one, and only truth.\"\n-- Alphonse Elric\nNow, here we have an equivalent exchange law for triangles which states that two right-angled isosceles triangles of the same color can be made into a square of the same color using Alchemy.\nYou are given N$N$ right-angled isosceles colored triangles numbered from 1$1$ to N$N$. For each triangle, the two equal sides have a length of 1$1$ unit. The Color of i$i$-th triangle is given by Ci$C_i$.\nTo create a tower, we choose some consecutive (2×k)+1$2 \\times k)+1$ triangles for any k≥0$k \\geq 0$. We then pick some 2×k$2 \\times k$ of them (these need not be consecutive), and form k$k$ pairs of triangles such that both triangles in pair have the same color. Also, each of the 2×k$2 \\times k$ should be in exactly one pair. Then the two triangles in each pair are joined using Alchemy (following the law of equivalent exchange for triangles) to form squares and these k$k$ squares are placed one upon other. The one remaining triangle is placed as a roof to the tower. This results in a tower of the height of k$k$.\nFind the maximum height of the tower that can be formed. \nIn other words, you should select the largest consecutive segment of triangles, such that you can form a tower using every single one of those triangles. In particular, you leave out one triangle, which will form the roof, and the other triangles should all be paired up such that both triangles in a pair have the same colour.\n\n-----Input:-----\n- The first line contains T$T$, the number of test cases. Then the test cases follow. \n- For every test case, the first line contains N$N$ denoting the number of triangles.\n- For every test case, the second line contains N$N$ space-separated integers Ci$C_{i}$ denoting the color of the triangles. ( 1≤i≤N$1 \\leq i \\leq N$).\n\n-----Output:-----\nFor every test case, output a single integer denoting the maximum height of the tower that can be formed.\n\n-----Constraints-----\n- 1≤T≤100$1 \\leq T \\leq 100$ \n- 1≤N≤105$1 \\leq N \\leq 10^{5}$ \n- 1≤Ci≤30$1 \\leq C_{i} \\leq 30$ \n- Sum of N$N$ over all test cases doesn't exceed 5×105$5\\times 10^{5}$ \n\n-----Sample Input:-----\n4\n14\n5 4 2 2 3 2 1 3 2 7 4 9 9 9\n3\n1 2 1\n3\n1 1 1\n5\n1 2 3 4 1\n\n-----Sample Output:-----\n3\n1\n1\n0\n\n-----EXPLANATION:-----\n- #1$1$: The subarray [2,2,3,2,1,3,2]$[2, 2, 3, 2, 1, 3, 2]$ results in a tower of height 3$3$.\n- #2$2$: The subarray [1,2,1]$[ 1, 2, 1 ]$ results in a tower of height 1$1$.\n- #3$3$: The subarray [1,1,1]$[ 1, 1, 1 ]$ results in a tower of height 1$1$. \n- #4$4$: The subarrays [1]$[ 1 ]$, [2]$[ 2 ]$ , [3]$[ 3 ]$, [4]$[ 4 ]$ and [1]$[ 1 ]$ all results in a tower of height 0$0$.\n\nThe above tower is possible by subarray [2,2,3,2,1,3,2]$[2, 2, 3, 2, 1, 3, 2]$ resulting in a height of 3$3$ in test case 1$1$.", "starter_code": "", "test_cases": {"inputs": ["4\n14\n5 4 2 2 3 2 1 3 2 7 4 9 9 9\n3\n1 2 1\n3\n1 1 1\n5\n1 2 3 4 1"], "outputs": ["3\n1\n1\n0"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "5bd664be2f48b018aefc277234b44f976343a607", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-00388", "original_id": null, "source": "apps", "domain": "code", "problem": "There is Chef and Chef’s Crush who are playing a game of numbers.\n\nChef’s crush has a number $A$ and Chef has a number $B$.\n\nNow, Chef wants Chef’s crush to win the game always, since she is his crush. The game ends when the greatest value of A^B is reached after performing some number of operations (possibly zero), Where ^ is Bitwise XOR.\n\nBefore performing any operation you have to ensure that both $A$ and $B$ have the same number of bits without any change in the values. It is not guaranteed that $A$ and $B$ should have same number of bits in the input.\nFor example, if $A$ is $2$ and $B$ is $15$, then the binary representation of both the numbers will have to be $0010$ and $1111$ respectively, before performing any operation. \nThe operation is defined as : \n- Right circular shift of the bits of only $B$ from MSB$_B$ to LSB$_B$ i.e. if we consider $B_1 B_2 B_3 B_4$ as binary number, then after one circular right shift, it would be $B_4 B_1 B_2 B_3$\nThey both are busy with themselves, can you find the number of operations to end the game?\n\n-----Input :-----\n- The first line of input contains $T$, (number of test cases) \n- Then each of the next $T$ lines contain : two integers $A$ and $B$ respectively.\n\n-----Output :-----\nFor each test case print two space-separated integers, The number of operations to end the game and value of A^B when the game ends.\n\n-----Constraints :-----\n- $1 \\leq T \\leq100$ \n- $1\\leq A,B \\leq 10^{18}$\n\n-----Subtasks :-----\n- 30 Points: $1\\leq A,B \\leq 10^5$\n- 70 Points: Original Constraints\n\n-----Sample Input :-----\n1\n4 5\n\n-----Sample Output :-----\n2 7\n\n-----Explanation :-----\nBinary representation of $4$ is $100$ and binary representation $5$ is $101$. \n- After operation $1$ : $B$ $=$ $110$, so A^B $=$ $2$ \n- After operation $2$ : $B$ $=$ $011$, so A^B $=$ $7$ \nSo, the value of A^B will be $7$. Which is the greatest possible value for A^B and the number of operations are $2$.", "starter_code": "", "test_cases": {"inputs": ["1\n4 5"], "outputs": ["2 7"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "58293fb4cef76544f2cdf5c0ef60960f00fb4ba0", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-00393", "original_id": null, "source": "apps", "domain": "code", "problem": "A robot is initially at $(0,0)$ on the cartesian plane. It can move in 4 directions - up, down, left, right denoted by letter u, d, l, r respectively. More formally:\n- if the position of robot is $(x,y)$ then u makes it $(x,y+1)$\n- if the position of robot is $(x,y)$ then l makes it $(x-1,y)$\n- if the position of robot is $(x,y)$ then d makes it $(x,y-1)$\n- if the position of robot is $(x,y)$ then r makes it $(x+1,y)$\nThe robot is performing a counter-clockwise spiral movement such that his movement can be represented by the following sequence of moves -\nulddrruuulllddddrrrruuuuu… and so on.\nA single move takes 1 sec. You have to find out the position of the robot on the cartesian plane at $t$ second.\n\n-----Input:-----\n- The first line of the input contains a single integer $T$ denoting the number of test cases. The description of $T$ test cases follows.\n- The first line of each test case contains a single integer $t$.\n\n-----Output:-----\nFor each test case, print two space-separated integers, $(x,y)$ — the position of the robot.\n\n-----Constraints-----\n- $1 \\leq T \\leq 10^6$\n- $1 \\leq t \\leq 10^{18}$\n\n-----Sample Input:-----\n5\n1\n2\n3\n50\n12233443\n\n-----Sample Output:-----\n0 1\n-1 1\n-1 0\n2 4\n-1749 812", "starter_code": "", "test_cases": {"inputs": ["5\n1\n2\n3\n50\n12233443"], "outputs": ["0 1\n-1 1\n-1 0\n2 4\n-1749 812"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "7b4308ac1867b119500a4199202c8e47d9763c93", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-00398", "original_id": null, "source": "apps", "domain": "code", "problem": "Chef loves to play chess, so he bought a new chessboard with width M$M$ and height N$N$ recently.\nChef considers a chessboard correct if its width (number of columns) is equal to its height (number of rows) and each cell has no side-adjacent cell of the same color (this is the so-called \"chess order\" which you can see in real-world chessboards). Chef's chessboard does not have to be a correct chessboard (in particular, it may have N≠M$N \\neq M$).\nA sub-board of Chef's chessboard is a rectangular piece of this board with an arbitrarily chosen top left and bottom right cell (possibly equal to the original chessboard). Every sub-board is also a chessboard.\nChef can invert some cells; inverting a cell means changing its color from white to black or from black to white. After inverting those cells, he wants to cut the maximum correct sub-board out of the original chessboard.\nChef has not yet decided how many cells he would like to invert. Now he wonders about the answers to Q$Q$ question. In the i$i$-th question (1≤i≤Q$1 \\le i \\le Q$), he is allowed to invert at most ci$c_i$ cells (possibly zero); he would like to know the side length of the largest possible correct sub-board of his chessboard. Help Chef answer these questions.\n\n-----Input-----\n- The first line of the input contains two space-separated integers N$N$ and M$M$.\n- N$N$ lines follow. For each valid i$i$, the i$i$-th of these lines contains a string with length M$M$ describing the i$i$-th row of Chef's chessboard. Each character of this string is either '0', representing a black cell, or '1', representing a white cell.\n- The next line contains a single integer Q$Q$.\n- The last line contains Q$Q$ space-separated integers c1,c2,…,cQ$c_1, c_2, \\dots, c_Q$.\n\n-----Output-----\nFor each question, print a single line containing one integer — the maximum size of a correct sub-board.\n\n-----Constraints-----\n- 1≤N,M≤200$1 \\le N, M \\le 200$\n- 1≤Q≤105$1 \\le Q \\le 10^5$\n- 0≤ci≤109$0 \\le c_i \\le 10^9$ for each valid i$i$\n\n-----Subtasks-----\nSubtask #1 (20 points):\n- 1≤N,M≤20$1 \\le N, M \\le 20$\n- 1≤Q≤100$1 \\le Q \\le 100$\nSubtask #2 (30 points): 1≤N,M≤20$1 \\le N, M \\le 20$\nSubtask #3 (50 points): original constraints\n\n-----Example Input-----\n8 8\n00101010\n00010101\n10101010\n01010101\n10101010\n01010101\n10101010\n01010101\n4\n1 2 0 1001\n\n-----Example Output-----\n7\n8\n6\n8\n\n-----Explanation-----\nIf we don't change the board, the best answer here is the 6x6 bottom right sub-board. We can invert cells (2,2)$(2, 2)$ and (1,1)$(1, 1)$ to get a better answer.", "starter_code": "", "test_cases": {"inputs": ["8 8\n00101010\n00010101\n10101010\n01010101\n10101010\n01010101\n10101010\n01010101\n4\n1 2 0 1001"], "outputs": ["7\n8\n6\n8"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "385ad7cb8b89cb746cf04741b2e49dd8c6e53340", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-00403", "original_id": null, "source": "apps", "domain": "code", "problem": "Sandu, a teacher in Chefland introduced his students to a new sequence i.e.\n0,1,0,1,2,0,1,2,3,0,1,2,3,4........\nThe Sequence starts from 0 and increases by one till $i$(initially i equals to 1), then repeat itself with $i$ changed to $i+1$\nStudents being curious about the sequence asks the Nth element of the sequence. Help Sandu to answer the Students\n\n-----Input:-----\n- The first-line will contain $T$, the number of test cases. Then the test case follows. \n- Each test case contains a single numbers N.\n\n-----Output:-----\nPrint the Nth element of the sequence\n\n-----Constraints-----\n- $1 \\leq T \\leq 1000$\n- $1 \\leq N \\leq 10^{18}$\n\n-----Sample Input:-----\n5\n8\n9\n20\n32\n109\n\n-----Sample Output:-----\n2\n3\n5\n4\n4", "starter_code": "", "test_cases": {"inputs": ["5\n8\n9\n20\n32\n109"], "outputs": ["2\n3\n5\n4\n4"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "f34ba9e3ea01af6e2bf538fdd680cc76c4f224e0", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-00408", "original_id": null, "source": "apps", "domain": "code", "problem": "You came across this story while reading a book. Long a ago when the modern entertainment systems did not exist people used to go to watch plays in theaters, where people would perform live in front of an audience. There was a beautiful actress who had a disability she could not pronounce the character $'r'$. To win her favours which many have been denied in past, you decide to write a whole play without the character $'r'$. Now you have to get the script reviewed by the editor before presenting it to her.\nThe editor was flattered by the script and agreed to you to proceed. The editor will edit the script in this way to suit her style. For each word replace it with a sub-sequence of itself such that it contains the character 'a'. \nA subsequence is a sequence that can be derived from another sequence by deleting some or no elements without changing the order of the remaining elements Wikipedia \nNow given a script with $N$ words, for each word in the script you wish to know the number of subsequences with which it can be replaced. \n\n-----Input:-----\n- First-line will contain $N$, the number of words in the script. Then next $N$ line with one test case each. \n- Each test case contains a single word $W_i$\n\n-----Output:-----\nFor each test case, output in a single line number of subsequences with which it can be replaced. \n\n-----Constraints-----\n- $1 \\leq N \\leq 1000$\n- $1 \\leq$ length of $W_i$ $\\leq 20$\n- $W_i$ on contains lowercase english alphabets and does not have the character 'r'\n\n-----Sample Input 1:-----\n2\nabc\naba\n\n-----Sample Output 1:-----\n4\n6\n\n-----EXPLANATION:-----\nThis subsequences with which $abc$ can be replaed : ${a,ab,ac,abc}$. \nThis subsequences with which $aba$ can be replaed : ${a,ab,aba,a,ba,a}$. \n\n-----Sample Input 2:-----\n3\nabcde\nabcdea\nxyz\n\n-----Sample Output 2:-----\n16\n48\n0", "starter_code": "", "test_cases": {"inputs": ["2\nabc\naba"], "outputs": ["4\n6"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "736240e26ef0b6b646d7f77b28ef333a2cbca95a", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-00413", "original_id": null, "source": "apps", "domain": "code", "problem": "Let's call a sequence good if the sum of all its elements is $0$.\nYou have a sequence of integers $A_1, A_2, \\ldots, A_N$. You may perform any number of operations on this sequence (including zero). In one operation, you should choose a valid index $i$ and decrease $A_i$ by $i$. Can you make the sequence good using these operations?\n\n-----Input-----\n- The first line of the input contains a single integer $T$ denoting the number of test cases. The description of $T$ test cases follows.\n- The first line of each test case contains a single integer $N$.\n- The second line contains $N$ space-separated integers $A_1, A_2, \\ldots, A_N$.\n\n-----Output-----\nFor each test case, print a single line containing the string \"YES\" if it is possible to make the given sequence good or \"NO\" if it is impossible.\n\n-----Constraints-----\n- $1 \\le T \\le 1,000$\n- $1 \\le N \\le 10$\n- $|A_i| \\le 100$ for each valid $i$\n\n-----Subtasks-----\nSubtask #1 (10 points): $N = 1$\nSubtask #2 (30 points): $N \\le 2$\nSubtask #3 (60 points): original constraints\n\n-----Example Input-----\n2\n1\n-1\n2\n1 2\n\n-----Example Output-----\nNO\nYES\n\n-----Explanation-----\nExample case 2: We can perform two operations ― subtract $1$ from $A_1$ and $2$ from $A_2$.", "starter_code": "", "test_cases": {"inputs": ["2\n1\n-1\n2\n1 2"], "outputs": ["NO\nYES"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "b8cb66da5b56b7e194121268c4112507481c889e", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-00418", "original_id": null, "source": "apps", "domain": "code", "problem": "Chef has an array A consisting of N integers (1-based indexing). He asks you to perform the following operation M times:\n\n\tfor i = 2 to N:\n\t\tAi = Ai + Ai-1\n\nYour task is to find the xth element of the array (i.e., Ax) after performing the above operation M times. As the answer could be large, please output it modulo 109 + 7.\n\n-----Input-----\n- The first line of input contains an integer T denoting the number of test cases.\n- The first line of each test case contains three space-separated integers — N, x, and M — denoting the size of the array, index of the element you need to find, and the amount of times you need to repeat operation before finding the element, respectively. The second line contains N space-separated integers A1, A2, …, AN.\n\n-----Output-----\nFor each test case, output a single line containing one integer: Ax modulo 109 + 7. \n\n-----Constraints-----\n- 1 ≤ T ≤ 10\n- 1 ≤ x ≤ N ≤ 105\n- 1 ≤ M ≤ 1018 \n- 1 ≤ Ai ≤ 1018\n\n-----Subtasks-----Subtask 1 (8 points):\n- 1 ≤ x ≤ min{2, N}Subtask 2 (24 points):\n- 1 ≤ N * M ≤ 106Subtask 3 (68 points): No additional constraints\n\n-----Example-----\nInput:\n2\n3 2 3\n1 2 3\n3 3 3 \n1 2 3\n\nOutput:\n5\n15\n\n-----Explanation-----\nValues in the array A:\n- Before the operations: [1, 2, 3]\n- After the first operation: [1, 3, 6]\n- After the second operation: [1, 4, 10]\n- After the third operation: [1, 5, 15]\n\nSince input file can be fairly large (about 8 MB), it's recommended to use fast I/O (for example, in C++, use scanf/printf instead of cin/cout).", "starter_code": "", "test_cases": {"inputs": ["2\n3 2 3\n1 2 3\n3 3 3\n1 2 3"], "outputs": ["5\n15"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "cb1200106639580b0e29c22870ca175a4617c64b", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-00423", "original_id": null, "source": "apps", "domain": "code", "problem": "Chef Ada is building a new restaurant in the following way:\n- First, $N$ points $X_1, X_2, \\ldots, X_N$ are chosen on the $x$-axis.\n- Then, $N$ columns (numbered $1$ through $N$) are made. For simplicity, the columns are represented as vertical segments; for each valid $i$, the height of the $i$-th segment is $H_i$.\n- Ada assigns a column to each of the points $X_1, X_2, \\ldots, X_N$ in an arbitrary way (each column must be assigned to exactly one point).\n- Finally, Ada constructs the roof of the restaurant, represented by a polyline with $N$ vertices. Let's denote the column assigned to the $i$-th point by $P_i$. For each valid $i$, the $i$-th of these vertices is $(X_i, H_{P_i})$, i.e. the polyline joins the tops of the columns from left to right.\nAda wants the biggest restaurant. Help her choose the positions of the columns in such a way that the area below the roof is the biggest possible. Formally, she wants to maximise the area of the polygon whose perimeter is formed by the roof and the segments $(X_N, H_{P_N}) - (X_N, 0) - (X_1, 0) - (X_1, H_{P_1})$. Let $S$ be this maximum area; you should compute $2 \\cdot S$ (it is guaranteed that $2 \\cdot S$ is an integer).\n\n-----Input-----\n- The first line of the input contains a single integer $T$ denoting the number of test cases. The description of $T$ test cases follows.\n- The first line of each test case contains a single integer $N$.\n- $N$ lines follow. For each valid $i$, the $i$-th of these lines contains two space-separated integers $X_i$ and $H_i$.\n\n-----Output-----\nFor each test case, print a single line containing one integer $2 \\cdot S$.\n\n-----Constraints-----\n- $1 \\le T \\le 3 \\cdot 10^5$\n- $2 \\le N \\le 10^5$\n- $0 \\le X_1 < X_2 < \\ldots < X_N \\le 2 \\cdot 10^9$\n- $1 \\le H_i \\le 10^9$ for each valid $i$\n- the sum of $N$ over all test cases does not exceed $10^6$\n\n-----Example Input-----\n1\n5\n1 1\n2 2\n3 3\n4 4\n5 5\n\n-----Example Output-----\n27\n\n-----Explanation-----", "starter_code": "", "test_cases": {"inputs": ["1\n5\n1 1\n2 2\n3 3\n4 4\n5 5"], "outputs": ["27"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "bbd0c603e1d660c89a988d74aa3168902380eb50", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-00428", "original_id": null, "source": "apps", "domain": "code", "problem": "There is a rectangular grid of cells consisting of n rows and m columns.\nYou will place a robot on one of the grid cells and provide it with a command string s, consisting of characters ‘L’, ‘R’, ‘U’, ‘D’.\nAfter being placed, the robot will follow the instructions of the command string, where 'L' corresponds moving to the left, 'R' towards the right, 'U' for moving up, and 'D' means down.\n\nYou have already selected the command string s, and are wondering if it is possible to place the robot in one of the grid cells initially and have it always stay entirely within the grid upon execution of the command string s.\nOutput “safe” if there is a starting cell for which the robot doesn’t fall off the grid on following command s, otherwise, output \"unsafe\".\n\n-----Input-----\n\nThe first line of input will contain an integer T, the number of test cases.\n\nEach test case will be on two lines. \n\nThe first line will have two space separated integers n,m. \n\nThe second line will have the command string s.\n\n-----Output-----\n\nFor each test case, output \"safe\" (without quotes) or \"unsafe\" (without quotes) in a new line.\n\n-----Constraints-----\n- 1 ≤ T ≤ 1,000\n- 1 ≤ n,m ≤ 10\n- 1 ≤ |s| ≤ 10\n\n-----Example-----\nInput:\n5\n1 1\nR\n2 3\nLLRU\n3 2\nLLRU\n4 3\nULURUDRDLD\n3 6\nRURUR\n\nOutput:\nunsafe\nsafe\nunsafe\nsafe\nsafe\n\n-----Explanation-----\n\nFor the first case, there is only one grid square, so we must place our robot there. When the robot follows the command, it'll fall off, so it is unsafe.\n\nFor the second case, we can place the robot on the bottom right grid square. Here is an image denoting the moves that the robot will make.", "starter_code": "", "test_cases": {"inputs": ["5\n1 1\nR\n2 3\nLLRU\n3 2\nLLRU\n4 3\nULURUDRDLD\n3 6\nRURUR"], "outputs": ["unsafe\nsafe\nunsafe\nsafe\nsafe"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "48f41b38d2e5b88192b3759a44aa4264737a627f", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-00433", "original_id": null, "source": "apps", "domain": "code", "problem": "\"What do you know about happiness?\" — Yoda \nChef is happy only if three conditions hold:\n- Chef finished cooking a delicious meal\n- Chef got AC for a programming problem with an almost correct code\n- Chef got a new problem with a sequence of integers\nToday, all three conditions are satisfied. Chef would like you to feel his happiness and provide him with a solution for this new problem with a sequence of integers. The problem is as follows.\nYou are given a sequence $A_1, A_2, \\dots, A_N$. You need to determine if it is possible to choose two indices $i$ and $j$ such that $A_i \\neq A_j$, but $A_{A_i}$ = $A_{A_j}$. (If it was possible, Chef would be truly happy.)\n\n-----Input-----\n- The first line of the input contains a single integer $T$ denoting the number of test cases. The description of $T$ test cases follows.\n- The first line of each test case contains a single integer $N$.\n- The second line contains $N$ space-separated integers $A_1, A_2, \\ldots, A_N$.\n\n-----Output-----\nFor each test case, print a single line containing the string \"Truly Happy\" if it is possible to choose required indices or \"Poor Chef\" otherwise.\n\n-----Constraints-----\n- $1 \\le T \\le 1,000$\n- $1 \\le N \\le 10^5$\n- $1 \\le A_i \\le N$ for each valid $i$\n- the sum of $N$ over all test cases does not exceed $2 \\cdot 10^5$\n\n-----Subtasks-----\nSubtask #1 (27 points): $1 \\le N \\le 1,000$\nSubtask #2 (73 points): original constraints\n\n-----Example Input-----\n4\n4\n1 1 2 3\n4\n2 1 3 3\n5\n5 4 4 3 1\n5\n3 2 1 1 4\n\n-----Example Output-----\nTruly Happy\nPoor Chef\nPoor Chef\nTruly Happy\n\n-----Explanation-----\nExample case 1: Chef is truly happy because $A_{A_3} = A_{A_1}$ and $A_3 \\neq A_1$.\nExample case 2: There is no pair of indices which would make Chef truly happy. For instance, $A_{A_3} = A_{A_4}$, but $A_3 = A_4$,", "starter_code": "", "test_cases": {"inputs": ["4\n4\n1 1 2 3\n4\n2 1 3 3\n5\n5 4 4 3 1\n5\n3 2 1 1 4"], "outputs": ["Truly Happy\nPoor Chef\nPoor Chef\nTruly Happy"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "32df040865db671c05c33e32410c86915336eafc", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-00438", "original_id": null, "source": "apps", "domain": "code", "problem": "We all know that Share market is place where drastic change occurs within moments. So we have one Stockholder, Isabella, who wants to maximize her profit by selling her shares. She has $N$ shares of a Doofenshmirtz Corporation which is represented by $N$ different lines where each line contains two space separated integers $a_i$ , $b_i$ corresponding to initial and final values of the share prize. Isabella can sell any number of shares. But, she will sell those shares only if the following condition is satisfied - \n- for any pair $(i,j)$ of shares that she choses to sell, $a_i \\leq a_j$ and $b_i < b_j$ must be satisfied. \nYou need to tell Isabella the maximum number of Shares she can sell.\n\n-----Input:-----\n- First line will contain $T$, number of test cases. \n- Each test case has the following format:\n- First line of each test case contain single integer $N$, the number of shares of Isabella. \n- Next $N$ lines of each test case contain two space separated integers $a_i$, $b_i$ (initial and final value of share prize respectively) for each $1 \\leq i \\leq N$.\n\n-----Output:-----\nFor each test case output a single integer: the maximum number of shares that can be sold by Isabella.\n\n-----Constraints-----\n- $1 \\leq T \\leq 5$\n- $1 \\leq N \\leq 10^5$\n- $1 \\leq a_i , b_i \\leq 10^9 , for each $1$ \\leq $i$ \\leq $N \n\n-----Sample Input:-----\n$1$\n$4$ \n$1$ $2$\n$4$ $3$\n$3$ $5$ \n$2$ $4$ \n\n-----Sample Output:-----\n$3$ \n\n-----Explanation:-----\nHere, Isabella decided to sell share 1, share 3 and share 4 as any two pair of \nchosen share hold the given condition.", "starter_code": "", "test_cases": {"inputs": ["1\n4\n1 2\n4 3\n3 5\n2 4"], "outputs": ["3"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "63d60a0ada96d90b5da716f68fd4b8e2acc34b68", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-00443", "original_id": null, "source": "apps", "domain": "code", "problem": "Once, a genius guy Cristo visited NASA where he met many scientists. A young intern Mark at NASA asked Cristo to observe the strange behaviour of two\n\nindependent particles (say Alpha and Beta) moving in the free space.Cristo was astonished to see the movement of Alpha and Beta. However, he formulated a procedure\n\nto evaluate the distance covered by the particles in given time.\nThe procedure calculates the distance covered by Alpha and Beta for a given time. Mark, however struggles\n\nto evaluate the procedure manually and asks you to help him. \nCristo's Procedure :- \nalpha = 0\nbeta = 0\nProcedure CristoSutra( Ti ) :\nif Ti <= 0 :\nalpha = alpha + 1 \nelse if Ti == 1 :\n\tbeta = beta + 1\nelse :\nCristoSutra(Ti-1)\n\t CristoSutra(Ti-2)\n\t CristoSutra(Ti-3)\nend procedure\nNote: Print the answer by taking mod from 109+7 .\n\n-----Constraints:-----\n- 1<=T<=105\n- 1<=Ti<=105\n\n-----Input Format:-----\nFirst line consists an integer t, number of Test cases.For each test case, there is an integer denoting time Ti.\n\n-----Output Format:-----\nFor each test case, a single output line contains two space seperated numbers ,distance covered by alpha and beta in the given time.\n\n-----Subtasks:-----\nSubtask 1 (30 points)\n- 1<=T<=10\n- 1<=Ti<=1000\nSubtask 2 (70 points)\noriginal contraints\nSample Input:\n2\n1\n2\nSample Output:\n0 1\n2 1", "starter_code": "", "test_cases": {"inputs": ["2\n1\n2"], "outputs": ["0 1\n2 1"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "1e447cfd7ebf30c90667b0bfc966bd9aa6c63f95", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-00448", "original_id": null, "source": "apps", "domain": "code", "problem": "Well known investigative reporter Kim \"Sherlock'' Bumjun needs your help! Today, his mission is to sabotage the operations of the evil JSA. If the JSA is allowed to succeed, they will use the combined power of the WQS binary search and the UFDS to take over the world!\nBut Kim doesn't know where the base is located. He knows that the base is on the highest peak of the Himalayan Mountains. He also knows the heights of each of the $N$ mountains. Can you help Kim find the height of the mountain where the base is located? \n\n-----Input:-----\n- First line will contain $T$, number of testcases. Then the testcases follow. \n- The first line in each testcase contains one integer, $N$. \n- The following $N$ lines of each test case each contain one integer: the height of a new mountain.\n\n-----Output:-----\nFor each testcase, output one line with one integer: the height of the tallest mountain for that test case.\n\n-----Constraints-----\n- $1 \\leq T \\leq 10$\n- $1 \\leq N \\leq 100000$\n- $0 \\leq$ height of each mountain $\\leq 10^9$\n\n-----Subtasks:-----\n- 100 points: No additional constraints.\n\n-----Sample Input:-----\n1\n5\n4\n7\n6\n3\n1\n\n-----Sample Output:-----\n7", "starter_code": "", "test_cases": {"inputs": ["1\n5\n4\n7\n6\n3\n1"], "outputs": ["7"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "805677d7c0479bf9ac3a630af92252181bfac6f4", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-00453", "original_id": null, "source": "apps", "domain": "code", "problem": "For a string $S$ let the unique set of characters that occur in it one or more times be $C$. Consider a permutation of the elements of $C$ as $(c_1, c_2, c_3 ... )$. Let $f(c)$ be the number of times $c$ occurs in $S$.\nIf any such permutation of the elements of $C$ satisfies $f(c_i) = f(c_{i-1}) + f(c_{i-2})$ for all $i \\ge 3$, the string is said to be a dynamic string.\nMr Bancroft is given the task to check if the string is dynamic, but he is busy playing with sandpaper. Would you help him in such a state?\nNote that if the number of distinct characters in the string is less than 3, i.e. if $|C| < 3$, then the string is always dynamic.\n\n-----Input:-----\n- First line will contain $T$, number of testcases. Then the testcases follow. \n- Each testcase contains of a single line of input, a string $S$.\n\n-----Output:-----\nFor each testcase, output in a single line \"Dynamic\" if the given string is dynamic, otherwise print \"Not\". (Note that the judge is case sensitive)\n\n-----Constraints-----\n- $1 \\leq T \\leq 10$\n- $1 \\leq |S| \\leq 10^5$\n- $S$ contains only lower case alphabets: $a$, $b$, …, $z$\n\n-----Sample Input:-----\n3\naaaabccc\naabbcc\nppppmmnnoooopp\n\n-----Sample Output:-----\nDynamic\nNot\nDynamic\n\n-----Explanation:-----\n- Testase 1: For the given string, $C = \\{a, b, c\\}$ and $f(a)=4, f(b)=1, f(c)=3$. $f(a) = f(c) + f(b)$ so the permutation $(b, c, a)$ satisfies the requirement.\n- Testcase 2: Here too $C = \\{a, b, c\\}$ but no permutation satisfies the requirement of a dynamic string.\n- Testcase 3: Here $C = \\{m, n, o, p\\}$ and $(m, n, o, p)$ is a permutation that makes it a dynamic string.", "starter_code": "", "test_cases": {"inputs": ["3\naaaabccc\naabbcc\nppppmmnnoooopp"], "outputs": ["Dynamic\nNot\nDynamic"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "c8e6a6114ab16c00984517a6d4226f30131a9ac7", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-00458", "original_id": null, "source": "apps", "domain": "code", "problem": "There are $N$ friends in a group. Each of them have $A_{i}$ candies.\nCan they share all of these candies among themselves such that each one of them have equal no. of candies.\n\n-----Input:-----\n- First line will contain $T$, number of testcases. Then the testcases follow. \n- First line of each testcase contains of a single line of input, an integer $N$ denoting no. of friends in the group. \n- Next line contains $N$ space separated integers $A_{i}$ denoting the no. candies $i^{th}$ friend has.\n\n-----Output:-----\nFor each testcase, output $\"Yes\"$ if it is possible to share equally else $\"No\"$ (without \" \").\n\n-----Constraints-----\n- $1 \\leq T \\leq 10$\n- $1 \\leq N \\leq 100$\n- $0 \\leq A_{i} \\leq 1000$\n\n-----Sample Input:-----\n1\n\n3\n\n1 2 3\n\n-----Sample Output:-----\nYes\n\n-----EXPLANATION:-----\nEach of them have $2$ candies after sharing.", "starter_code": "", "test_cases": {"inputs": ["1\n3\n1 2 3"], "outputs": ["Yes"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "8891d4cc2dc0e38b867b1851e6d40a8318dc8061", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-00463", "original_id": null, "source": "apps", "domain": "code", "problem": "Mandarin chinese\n, Russian and Vietnamese as well.\nYou are given a grid with $n$ rows and $m$ columns. Each cell of this grid can either be empty or it contains one particle. It can never contain more than one particle. Let's denote the cell in the $i$-th row and $j$-th column by $(i, j)$, with the top left corner being $(0, 0)$. From a cell $(i, j)$, a particle could move in one of the following four directions:\n- to the left, i.e. to the cell $(i, j - 1)$\n- to the right, i.e. to the cell $(i, j + 1)$\n- up, i.e. to the cell $(i - 1, j)$\n- down, i.e. to the cell $(i + 1, j)$\nIt is not possible for a particle to move to a cell that already contains a particle or to a cell that does not exist (leave the grid).\nIt is possible to apply a force in each of these directions. When a force is applied in a given direction, all particles will simultaneously start moving in this direction as long as it is still possible for them to move.\nYou are given a sequence of forces. Each subsequent force is applied only after all particles have stopped moving. Determine which cells of the grid contain particles after all forces from this sequence are applied in the given order.\n\n-----Input-----\n- The first line of the input contains a single integer $T$ denoting the number of test cases. The description of $T$ test cases follows.\n- The first line of each test case contains two space-separated integers $n$ and $m$.\n- $n$ lines describing the initial grid follow. For each $i$ ($1 \\le i \\le n$), the $i$-th of these lines contains a binary string with length $m$ describing the $i$-th row of the grid. For each $j$ ($1 \\le j \\le m$), if the $j$-th character of this string is '1', then the cell $(i, j)$ contains a particle, and if it is '0', then the cell $(i, j)$ is empty.\n- The last line contains a single string $S$ describing the sequence of applied forces. Each character of this string corresponds to applying a force in some direction; forces applied in the directions left, right, up, down correspond to characters 'L', 'R', 'U', 'D' respectively.\n\n-----Output-----\nFor each test case, print $n$ lines each containing a binary string of length $m$, describing the resulting grid (after all the forces are applied) in the same format as the input grid.\n\n-----Constraints-----\n- $1 \\le T \\le 200$\n- $1 \\le n, m \\le 100$\n- $1 \\le |S| \\le 2 \\cdot 10^4$\n\n-----Subtasks-----\nSubtaks #1 (30 points):\n- $1 \\le T \\le 10$\n- $1 \\le n, m \\le 10$\n- $1 \\le |S| \\le 100$\nSubtask #2 (70 points): Original constraints\n\n-----Example Input-----\n3\n4 4\n1010\n0010\n1001\n0100\nLRDU\n4 3\n000\n010\n001\n101\nLRL\n3 2\n01\n10\n00\nD\n\n-----Example Output-----\n0011\n0011\n0001\n0001\n000\n100\n100\n110\n00\n00\n11\n\n-----Explanation-----\nExample case 1: The initial grid is:\n1010\n0010\n1001\n0100\n\nAfter applying the first force (in the direction \"L\", i.e. to the left), the grid is:\n1100\n1000\n1100\n1000\n\nAfter applying the second force (in the direction \"R\"), the grid is:\n0011\n0001\n0011\n0001\n\nAfter applying the third force (in the direction \"D\"), the grid is:\n0001\n0001\n0011\n0011\n\nAfter applying the fourth force (in the direction \"U\"), the final grid is:\n0011\n0011\n0001\n0001", "starter_code": "", "test_cases": {"inputs": ["3\n4 4\n1010\n0010\n1001\n0100\nLRDU\n4 3\n000\n010\n001\n101\nLRL\n3 2\n01\n10\n00\nD"], "outputs": ["0011\n0011\n0001\n0001\n000\n100\n100\n110\n00\n00\n11"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "309a3b7533a550613aa3cad7c9620eee7b31b25d", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-00468", "original_id": null, "source": "apps", "domain": "code", "problem": "\tThree numbers A, B and C are the inputs. Write a program to find second largest among them.\n\n-----Input-----\n\nThe first line contains an integer T, the total number of testcases. Then T lines follow, each line contains three integers A, B and C. \n\n-----Output-----\nFor each test case, display the second largest among A, B and C, in a new line.\n\n-----Constraints-----\n- 1 ≤ T ≤ 1000\n- 1 ≤ A,B,C ≤ 1000000\n\n-----Example-----\nInput\n3 \n120 11 400\n10213 312 10\n10 3 450\n\nOutput\n\n120\n312\n10", "starter_code": "", "test_cases": {"inputs": ["3\n120 11 400\n10213 312 10\n10 3 450"], "outputs": ["120\n312\n10"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "fa0d7d64005f1bb8873caf630ee021517979946e", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-00473", "original_id": null, "source": "apps", "domain": "code", "problem": "Raju has created a program to find the square root of a number. But his program can store only integers. Being a newbie, he didn't know about rounding the numbers. Hence his program returns the absolute value of the result if possible. For example, sqrt(3) = 1.73205080757……. His program will return 1\nGiven a number $N$, and it's integral square root $S$, His instructor will consider the answer correct if Difference between $N$ and the square of $S$ is within less than or equal to $X$% of $N$.\n\n-----Input:-----\n- First line contains $T$ no. of test cases and $X$ separated by space\n- For every test case, a line contains an integer $N$\n\n-----Output:-----\nFor every test case, print yes if his programs return square root and (N-(S^2)) <= 0.01XN . For everything else, print no on a new line\n\n-----Constraints-----\n10 points:\n- $1 \\leq T \\leq 10$\n- $0\\leq N \\leq 10$\n20 points:\n- $1 \\leq T \\leq 30000$\n- $-10^9 \\leq N \\leq 10^9$\n70 points:\n- $1 \\leq T \\leq 10^6$\n- $-10^9 \\leq N \\leq 10^9$\n\n-----Sample Input:-----\n2 20\n5\n3\n\n-----Sample Output:-----\nyes\nno\n\n-----EXPLANATION:-----\nIn #1, sqrt(5) = 2.2360679775. Taking integral value, S = 2.\n\nS2 = 4. Difference=1 which is within 20% of 5\nIn #1, sqrt(3) = 1.73205080757. Taking integral value, S = 1.\n\nS2 = 1. Difference=2 which is not within 20% of 3", "starter_code": "", "test_cases": {"inputs": ["2 20\n5\n3"], "outputs": ["yes\nno"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "9accf96e2c876f3fb7bb8edfafd0703462f1bff5", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-00478", "original_id": null, "source": "apps", "domain": "code", "problem": "The chef is trying to solve some pattern problems, Chef wants your help to code it. Chef has one number K to form a new pattern. Help the chef to code this pattern problem.\n\n-----Input:-----\n- First-line will contain $T$, the number of test cases. Then the test cases follow. \n- Each test case contains a single line of input, one integer $K$. \n\n-----Output:-----\nFor each test case, output as the pattern.\n\n-----Constraints-----\n- $1 \\leq T \\leq 100$\n- $1 \\leq K \\leq 100$\n\n-----Sample Input:-----\n4\n1\n2\n3\n4\n\n-----Sample Output:-----\n1\n12\n34\n123\n456\n789\n1234\n5678\n9101112\n13141516\n\n-----EXPLANATION:-----\nNo need, else pattern can be decode easily.", "starter_code": "", "test_cases": {"inputs": ["4\n1\n2\n3\n4"], "outputs": ["1\n12\n34\n123\n456\n789\n1234\n5678\n9101112\n13141516"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "df022e8d531441110dcfcc2b8439597eb8824a66", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-00483", "original_id": null, "source": "apps", "domain": "code", "problem": "Chef is going to start playing Fantasy Football League (FFL) this season. In FFL, each team consists of exactly $15$ players: $2$ goalkeepers, $5$ defenders, $5$ midfielders and $3$ forwards. Chef has already bought $13$ players; he is only missing one defender and one forward.\nThere are $N$ available players (numbered $1$ through $N$). For each valid $i$, the $i$-th player is either a defender or a forward and has a price $P_i$. The sum of prices of all players in a team must not exceed $100$ dollars and the players Chef bought already cost him $S$ dollars.\nCan you help Chef determine if he can complete the team by buying one defender and one forward in such a way that he does not exceed the total price limit?\n\n-----Input-----\n- The first line of the input contains a single integer $T$ denoting the number of test cases. The description of $T$ test cases follows.\n- The first line of each test case contains two space-separated integers $N$ and $S$.\n- The second line contains $N$ space-separated integers $P_1, P_2, \\ldots, P_N$.\n- The last line contains $N$ space-separated integers. For each valid $i$, the $i$-th of these integers is $0$ if the $i$-th player is a defender or $1$ if the $i$-th player is a forward.\n\n-----Output-----\nFor each test case, print a single line containing the string \"yes\" if it is possible to build a complete team or \"no\" otherwise (without quotes).\n\n-----Constraints-----\n- $1 \\le T \\le 100$\n- $1 \\le N \\le 100$\n- $13 \\le S \\le 100$\n- $1 \\le P_i \\le 100$ for each valid $i$\n\n-----Subtasks-----\nSubtask #1 (100 points): original constraints\n\n-----Example Input-----\n2\n4 90\n3 8 6 5\n0 1 1 0\n4 90\n5 7 6 5\n0 1 1 0\n\n-----Example Output-----\nyes\nno\n\n-----Explanation-----\nExample case 1: If Chef buys the $1$-st and $3$-rd player, the total price of his team is $90 + 9 = 99$, which is perfectly fine. There is no other valid way to pick two players.\nExample case 2: Chef cannot buy two players in such a way that all conditions are satisfied.", "starter_code": "", "test_cases": {"inputs": ["2\n4 90\n3 8 6 5\n0 1 1 0\n4 90\n5 7 6 5\n0 1 1 0"], "outputs": ["yes\nno"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "fcbda050a9cb3f92d9507bc087c47a370b9ef6bd", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-00488", "original_id": null, "source": "apps", "domain": "code", "problem": "You are given two integer sequences $A_1, A_2, \\ldots, A_N$ and $B_1, B_2, \\ldots, B_M$. For any two sequences $U_1, U_2, \\ldots, U_p$ and $V_1, V_2, \\ldots, V_q$, we define\nScore(U,V)=∑i=1p∑j=1qUi⋅Vj.Score(U,V)=∑i=1p∑j=1qUi⋅Vj.Score(U, V) = \\sum_{i=1}^p \\sum_{j=1}^q U_i \\cdot V_j \\,.\nYou should process $Q$ queries of three types:\n- $1$ $L$ $R$ $X$: Add $X$ to each of the elements $A_L, A_{L+1}, \\ldots, A_R$.\n- $2$ $L$ $R$ $X$: Add $X$ to each of the elements $B_L, B_{L+1}, \\ldots, B_R$.\n- $3$: Print $Score(A, B)$ modulo $998,244,353$.\n\n-----Input-----\n- The first line of the input contains a single integer $T$ denoting the number of test cases. The description of $T$ test cases follows.\n- The first line of each test case contains two integers, $N$ and $M$, denoting the length of $A$ and $B$ respectively.\n- The second line contains $N$ integers, elements of $A$.\n- The third line contains $M$ integers, elements of $B$.\n- The next line will contain an integer, $Q$, number of queries.\n- Each of the next $Q$ lines will contain one of $3$ kinds of updates as mentioned in the statement\nIt’s guaranteed that each update is a valid update operation.\n\n-----Output-----\nFor each query of the third type, print a single line containing one integer - the answer to that query.\n\n-----Constraints-----\n- $1 \\le T \\le 10$\n- $2 \\le N, M, Q \\le 10^5$\n- $0 \\le |A_i|, |B_i|, |X| \\le 10^5$\n\n-----Example Input-----\n1\n3 4\n2 -1 5\n3 3 2 4\n6\n3\n1 2 3 -2\n3\n1 1 3 1\n2 2 4 2\n3\n\n-----Example Output-----\n72\n24\n90\n\n-----Explanation-----\nBefore the first operation, $A = [2, -1, 5],\\ B = [3, 3, 2, 4]$\nSo, for the first operation,\n$Score(A,\\ B) = 2*3 + 2*3 + 2*2 + 2*4$ $+ (-1)*3$ $+ (-1)*3$ $+ (-1)*2$ $+$ $(-1)*4$ $+ 5*3$ $+ 5*3$ $+ 5*2$ $+ 5*4$ $= 72.$\nAfter the second query $A = [2, -3, 3]$, $B = [3, 3, 2, 4]$\nSo, for the third query, $Score(A, B) = 2*3 + 2*3 + 2*2$ $+ 2*4$ $+ (-3)*3$ $+ (-3)*3$ $+ (-3)*2$ $+ (-3)*4$ $+ 3*3$ $+ 3*3$ $+ 3*2$ $+ 3*4$ $= 24$.", "starter_code": "", "test_cases": {"inputs": ["1\n3 4\n2 -1 5\n3 3 2 4\n6\n3\n1 2 3 -2\n3\n1 1 3 1\n2 2 4 2\n3"], "outputs": ["72\n24\n90"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "f7218d9c951de39d37d2bb744e0b9a11b0148d6f", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-00493", "original_id": null, "source": "apps", "domain": "code", "problem": "You are given a string s of length 8 consisting solely of '0's and '1's. Assume that the characters of the string are written in a circular fashion. You need to find the number of 0-1 or 1-0 transitions that one has to make while making a single traversal over the string. ie. start from any character and go circularly until you get back to the same character, and find the number of transitions that you made. The string is said to be said to be uniform if there are at most two such transitions. Otherwise, it is called non-uniform.\nGiven the string s, tell whether the string is uniform or not.\n\n-----Input-----\nThe first line of the input contains an integer T denoting the number of test cases. The description of T test cases follows.\nThe only line of input contains the string s.\n\n-----Output-----\nFor each test case, output \"uniform\" if the given string is uniform and \"non-uniform\" otherwise.\n\n-----Constraints-----\n- 1 ≤ T ≤ 256\n- Length of s is 8\n\n-----Example-----\nInput\n4\n00000000\n10101010\n10000001\n10010011\n\nOutput\nuniform\nnon-uniform\nuniform\nnon-uniform\n\n-----Explanation-----\nThe number of transitions are 0, 8, 2 and 4 for the respective cases. So, the first and third one are uniform while the second and fourth one are non-uniform.", "starter_code": "", "test_cases": {"inputs": ["4\n00000000\n10101010\n10000001\n10010011"], "outputs": ["uniform\nnon-uniform\nuniform\nnon-uniform"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "6829b209607ecc761ff1a9436d56574201d7ebe3", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-00498", "original_id": null, "source": "apps", "domain": "code", "problem": "Write a program to find the factorial value of any number entered by the user.\n\n-----Input-----\n\nThe first line contains an integer T, the total number of testcases. Then T lines follow, each line contains an integer N. \n\n-----Output-----\nFor each test case, display the factorial of the given number N in a new line.\n\n-----Constraints-----\n- 1 ≤ T ≤ 1000\n- 0 ≤ N ≤ 20\n\n-----Example-----\nInput\n3 \n3 \n4\n5\n\nOutput\n\n6\n24\n120", "starter_code": "", "test_cases": {"inputs": ["3\n3\n4\n5"], "outputs": ["6\n24\n120"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "63375e6c9851b2b876378deba1ff03539166be8b", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-00503", "original_id": null, "source": "apps", "domain": "code", "problem": "Chef wants to host some Division-3 contests. Chef has $N$ setters who are busy creating new problems for him. The $i^{th}$ setter has made $A_i$ problems where $1 \\leq i \\leq N$. \nA Division-3 contest should have exactly $K$ problems. Chef wants to plan for the next $D$ days using the problems that they have currently. But Chef cannot host more than one Division-3 contest in a day.\nGiven these constraints, can you help Chef find the maximum number of Division-3 contests that can be hosted in these $D$ days?\n\n-----Input:-----\n- The first line of input contains a single integer $T$ denoting the number of test cases. The description of $T$ test cases follows.\n- The first line of each test case contains three space-separated integers - $N$, $K$ and $D$ respectively.\n- The second line of each test case contains $N$ space-separated integers $A_1, A_2, \\ldots, A_N$ respectively. \n\n-----Output:-----\nFor each test case, print a single line containing one integer ― the maximum number of Division-3 contests Chef can host in these $D$ days.\n\n-----Constraints-----\n- $1 \\leq T \\leq 10^3$\n- $1 \\leq N \\leq 10^2$\n- $1 \\le K \\le 10^9$ \n- $1 \\le D \\le 10^9$\n- $1 \\le A_i \\le 10^7$ for each valid $i$\n\n-----Subtasks-----\nSubtask #1 (40 points):\n- $N = 1$\n- $1 \\le A_1 \\le 10^5$\nSubtask #2 (60 points): Original constraints\n\n-----Sample Input:-----\n5\n1 5 31\n4\n1 10 3\n23\n2 5 7\n20 36\n2 5 10\n19 2\n3 3 300\n1 1 1\n\n-----Sample Output:-----\n0\n2\n7\n4\n1\n\n-----Explanation:-----\n- \nExample case 1: Chef only has $A_1 = 4$ problems and he needs $K = 5$ problems for a Division-3 contest. So Chef won't be able to host any Division-3 contest in these 31 days. Hence the first output is $0$.\n- \nExample case 2: Chef has $A_1 = 23$ problems and he needs $K = 10$ problems for a Division-3 contest. Chef can choose any $10+10 = 20$ problems and host $2$ Division-3 contests in these 3 days. Hence the second output is $2$.\n- \nExample case 3: Chef has $A_1 = 20$ problems from setter-1 and $A_2 = 36$ problems from setter-2, and so has a total of $56$ problems. Chef needs $K = 5$ problems for each Division-3 contest. Hence Chef can prepare $11$ Division-3 contests. But since we are planning only for the next $D = 7$ days and Chef cannot host more than $1$ contest in a day, Chef cannot host more than $7$ contests. Hence the third output is $7$.", "starter_code": "", "test_cases": {"inputs": ["5\n1 5 31\n4\n1 10 3\n23\n2 5 7\n20 36\n2 5 10\n19 2\n3 3 300\n1 1 1"], "outputs": ["0\n2\n7\n4\n1"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "735b50eaa2b33ae0188d6140a927937d38884b47", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-00508", "original_id": null, "source": "apps", "domain": "code", "problem": "Eugene has to do his homework. But today, he is feeling very lazy and wants to you do his homework. His homework has the following given maths problem.\nYou are given three integers: A, N, M. You write the number A appended to itself N times in a row. Let's call the resulting big number X. For example, if A = 120, N = 3, then X will be 120120120. Find out the value of X modulo M.\n\n-----Input-----\nThe first line of the input contains an integer T denoting the number of test cases. The description of T test cases follow.\nEach test case is described in one line containing three integers: A, N and M as described in the problem statement.\n\n-----Output-----\nFor each test case, output a single line containing an integer denoting the value of X modulo M.\n\n-----Constraints-----\n- 1 ≤ T ≤ 105\n- 0 ≤ A ≤ 109\n- 1 ≤ N ≤ 1012\n- 2 ≤ M ≤ 109\n\n-----Subtasks-----\nSubtask #1 (15 points):\n- 0 ≤ A ≤ 100\n- 1 ≤ N ≤ 105\n\nSubtask #2 (25 points):\n- 1 ≤ N ≤ 109\n\nSubtask #3 (60 points):\n- Original constraints\n\n-----Example-----\nInput:\n2\n12 2 17\n523 3 11\n\nOutput:\n5\n6\n\n-----Explanation-----\nExample 1: As A = 12, N = 2, X = 1212, 1212 modulo 17 = 5\nExample 2. As A = 523, N = 3, X = 523523523, 523523523 modulo 11 = 6", "starter_code": "", "test_cases": {"inputs": ["2\n12 2 17\n523 3 11\n\n"], "outputs": ["5\n6"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "4e5a2bd55da3091517958bc0f67cca1fc8dd69ca", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-00513", "original_id": null, "source": "apps", "domain": "code", "problem": "$Gogi$, $Tapu$ and $Sonu$ are the elite members of $Tapu$ $Sena$. $Gogi$ is always stoned and asks absurd questions, But this time he asked a question which seems to be very serious and interesting. $Tapu$ wants to solve this question to impress $Sonu$. He gave an array of length N to $Tapu$, $Tapu$ can perform the following operations exactly once:\n- Remove any subarray from the given array given the resulting array formed after the removal is non-empty. \n- Reverse the whole array.\nRemember you can’t shuffle the elements of the array.\nTapu needs to find out the maximum possible GCD of all the numbers in the array after applying the given operations exactly once. Tapu is very weak at programming, he wants you to solve this problem so that he can impress $Sonu$.\n\n-----Input:-----\n- The first line contains $T$, the number of test cases.\n- For each test case\n-FIrst line contains $N$.\n- Last line contains $N$ numbers of the array. \n\n-----Output:-----\nA single integer in a new line, maximum possible GCD. \n\n-----Constraints-----\n- $1 \\leq T \\leq 10^2$\n- $1 \\leq N \\leq 10^4$\n- $1 \\leq a[i] \\leq 10^9$\n\nSummation of N for all testcases is less than $10^6$ \n\n-----Sample Input 1:-----\n1\n1\n2\n\n-----Sample Output 1:-----\n2", "starter_code": "", "test_cases": {"inputs": ["1\n1\n2"], "outputs": ["2"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "45e4c7e570c9e8ea606f492fed71acb4e41aaf34", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-00518", "original_id": null, "source": "apps", "domain": "code", "problem": "Chef has created a special dividing machine that supports the below given operations on an array of positive integers.\nThere are two operations that Chef implemented on the machine.\nType 0 Operation\n\nUpdate(L,R):\n\tfor i = L to R:\n\t\ta[i] = a[i] / LeastPrimeDivisor(a[i])\n\nType 1 Operation\n\nGet(L,R):\n\tresult = 1\n\tfor i = L to R:\n\t\tresult = max(result, LeastPrimeDivisor(a[i]))\n\treturn result;\n\nThe function LeastPrimeDivisor(x) finds the smallest prime divisor of a number. If the number does not have any prime divisors, then it returns 1.\nChef has provided you an array of size N, on which you have to apply M operations using the special machine. Each operation will be one of the above given two types. Your task is to implement the special dividing machine operations designed by Chef. Chef finds this task quite easy using his machine, do you too?\n\n-----Input-----\n\nThe first line of the input contains an integer T denoting the number of test cases. The description of T test cases follows. \nThe first line of each test case contains two space-separated integers N, M, denoting the size of array A and the number of queries correspondingly.\n\nThe second line of each test case contains N space-separated integers A1, A2, ..., AN denoting the initial array for dividing machine.\nEach of following M lines contain three space-separated integers type, L, R - the type of operation (0 - Update operation, 1 - Get operation), and the arguments of function, respectively\n\n-----Output-----\nFor each test case, output answer of each query of type 1 (Get query) separated by space. Each test case from the same file should start from the new line.\n\n-----Constraints-----\n- 1 ≤ T ≤ 100\n- 1 ≤ Ai ≤ 106\n- 1 ≤ L ≤ R ≤ N\n- 0 ≤ type ≤ 1\n- Sum of M over all test cases in a single test file does not exceed 106\n\n-----Subtasks-----\nSubtask #1: (10 points) \n- 1 ≤ N, M ≤ 103\n\nSubtask #2: (25 points)\n- 1 ≤ N, M ≤ 105\n- Ai is a prime number. \n\nSubtask #3: (65 points)\n- 1 ≤ N, M ≤ 105\n\n-----Example-----\nInput:\n2\n6 7\n2 5 8 10 3 44\n1 2 6\n0 2 3\n1 2 6\n0 4 6\n1 1 6\n0 1 6\n1 4 6\n2 2\n1 3\n0 2 2\n1 1 2\nOutput:\n5 3 5 11\n1\n\n-----Explanation-----\nExample case 1.The states of array A after each Update-operation:\nA: = [2 1 4 10 3 44]\nA: = [2 1 4 5 1 22]\nA: = [1 1 2 1 1 11]", "starter_code": "", "test_cases": {"inputs": ["2\n6 7\n2 5 8 10 3 44\n1 2 6\n0 2 3\n1 2 6\n0 4 6\n1 1 6\n0 1 6\n1 4 6\n2 2\n1 3\n0 2 2\n1 1 2"], "outputs": ["5 3 5 11\n1"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "79be6d86da8a85b3d53d17c93b4dca83def874c7", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-00523", "original_id": null, "source": "apps", "domain": "code", "problem": "In this problem, you will be given a polynomial, you have to print what it becomes after differentiation.\n\nFollowing are the rules for differentiation:\n- For a polynomial f(x), its differentiation is defined as f'(x).\n- If a is a constant, then differentiation of af(x) is af'(x).\n- If f(x) = h(x) + g(x) , then f'(x) = h'(x) + g'(x) \n- If f(x) = x n, then f'(x) = nxn-1. This is true for all n ≠ 0 .\n- If f(x) = c, where c is a constant, f'(x) = 0.\n\nIf you are still uncomfortable with differentiation, please read the following:\n- Link to Wikihow page\n- Link to Wikipedia entry.\n\n-----Input-----\n\nFirst line contains T, the number of test cases to follow. \n\nEach test case contains the follows, the first line contains N, the number of non zero terms in the polynomial. Then N lines follow, each line contains a pair of integer which denotes a term in the polynomial, where the first element denotes the coefficient (a) and the second denotes the exponent (p) of the term.\n\n-----Output-----\nPrint the polynomial after differentiation in the desired format as described below.\n- If the coefficient of a term in the output polynomial is 3, and the corresponding exponent is 2, print it as 3x^2\n- Print \" + \" (with single space on both side) between each output term.\n- Print the terms in decreasing value of exponent.\n- For the constant term (if any), you have to just print the coefficient. You should not print x^0.\n\n-----Constraints-----\n- 1 ≤ T ≤ 10\n- Subtask 1 (20 points)\n\n- 1 ≤ N ≤ 3\n- 1 ≤ a ≤ 10\n- 0 ≤ p ≤ 10\n- Subtask 2 (80 points)\n\n- 1 ≤ N ≤ 10000\n- 1 ≤ a ≤ 100000000\n- 0 ≤ p ≤ 100000000\n- No two inputs in a test case will have the same exponent.\n\n-----Example-----\nInput:\n2\n1\n1 2\n3\n1 3\n1 1\n1 0\n\nOutput:\n2x^1\n3x^2 + 1", "starter_code": "", "test_cases": {"inputs": ["2\n1\n1 2\n3\n1 3\n1 1\n1 0"], "outputs": ["2x^1\n3x^2 + 1"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "fe4758280c6a67f3de7bfe72fa1f7a92862e97e8", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-00528", "original_id": null, "source": "apps", "domain": "code", "problem": "Alice and Bob are walking on an infinite straight street. Initially, both are at the position $X=0$ and they start walking in the direction of increasing $X$. After $N$ seconds, they stop. Let's denote Alice's speed and Bob's speed during the $i$-th of these seconds by $A_i$ and $B_i$ respectively.\nSometimes, Alice and Bob walk together, i.e. with the same speed side by side. Let's define the weird distance as the total distance they walk this way. Find this weird distance.\n\n-----Input-----\n- The first line of the input contains a single integer $T$ denoting the number of test cases. The description of $T$ test cases follows.\n- The first line of each test case contains a single integer $N$.\n- The second line contains $N$ space-separated integers $A_1, A_2, \\ldots, A_N$.\n- The third line contains $N$ space-separated integers $B_1, B_2, \\ldots, B_N$.\n\n-----Output-----\nFor each test case, print a single line containing one integer ― the total weird distance. It can be proved that this distance is an integer.\n\n-----Constraints-----\n- $1 \\le T \\le 20$\n- $1 \\le N \\le 10^5$\n- $1 \\le A_i \\le 10^5$ for each valid $i$\n- $1 \\le B_i \\le 10^5$ for each valid $i$\n- the sum of $N$ over all test cases does not exceed $10^6$\n\n-----Subtasks-----\nSubtask #1 (30 points): $1 \\le N \\le 1,000$\nSubtask #2 (70 points): original constraints\n\n-----Example Input-----\n3\n4\n1 3 3 4\n1 2 4 4\n2\n2 3\n3 2\n2\n3 3\n3 3\n\n-----Example Output-----\n5\n0\n6\n\n-----Explanation-----\nExample case 1:\n- Alice and Bob walk side by side during the first second, from $X=0$ to $X=1$.\n- Then, Alice starts walking faster than Bob, so they do not walk side by side during second $2$. At the end of second $2$, Alice is at $X=4$, while Bob is at $X=3$.\n- During the next second, they again do not walk side by side, but Bob walks faster, so they both end up at $X=7$.\n- During the last second, they both walk side by side and the distance they walk is $4$.\n- Alice and Bob walk side by side during the $1$-st and $4$-th second and the total weird distance they travel is $1+4=5$.\nExample case 2:\n- First, Alice walks with speed $2$ and Bob walks with speed $3$, so they do not walk side by side. Alice ends up at $X=2$, while Bob ends up at $X=3$ at the end of the $1$-st second.\n- Then, Alice walks with speed $3$ and Bob walks with speed $2$, so they do not walk side by side either.\n- Although Alice and Bob both end up at $X=5$ at the end of the $2$-nd second, the weird distance is $0$.\nExample case 3: We can see that Alice and Bob always walk together, so the weird distance is $3+3=6$.", "starter_code": "", "test_cases": {"inputs": ["3\n4\n1 3 3 4\n1 2 4 4\n2\n2 3\n3 2\n2\n3 3\n3 3"], "outputs": ["5\n0\n6"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "7025492706afaa48b47cc2278bd1db3cd1a0b3f8", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-00533", "original_id": null, "source": "apps", "domain": "code", "problem": "Rodriguez is a happy and content farmer. He has got a square field of side length $x$. Miguel, his son has himself grown into a man and his father wants to gift him something out of which he can make a living. So he gift's his son a square piece of land cut out from a corner of his field of side length $ y (y < x) $ leaving him with a L-shaped land.\nBut in Spanish tradition, it is considered inauspicious to own something which is prime in number. This worries Rodriguez as he doesn't want his left out area to be a prime number leading to bad luck. Find whether the spilt will be in terms with the tradition leaving Rodriguez happy.\n\n-----Input:-----\n- First line will contain $T$, number of testcases. Then the testcases follow. \n- Each testcase contains two integers $x, y$. \n\n-----Output:-----\nPrint YES if Rodriguez will be happy. Otherwise print NO.\n\n-----Constraints-----\n- $1 \\leq T \\leq 5$\n- $1 \\leq y < x \\leq 100000000000$\n\n-----Sample Input:-----\n2\n7 5\n6 5\n\n-----Sample Output:-----\nYES\nNO\n\n-----EXPLANATION:-----\nIn case 1 :\nLeft out area is 24, which is not prime.\nIn case 2:\nLeft out area is 11, which is prime.", "starter_code": "", "test_cases": {"inputs": ["2\n7 5\n6 5"], "outputs": ["YES\nNO"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "18e3a2d0d699e077b29531025f2a2653ac97da9d", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-00538", "original_id": null, "source": "apps", "domain": "code", "problem": "Rakesh has built a model rocket and wants to test how stable it is. He usually uses a magic box which runs some tests on the rocket and tells if it is stable or not, but his friend broke it by trying to find out how stable he is (very delicate magic indeed). The box only gives a polynomial equation now which can help Rakesh find the stability (a failsafe by the manufacturers). \n\nRakesh reads the manual for the magic box and understands that in order to determine stability, he needs to take every other term and put them in two rows. Eg. If the polynomial is:\n10 x^4 + 12 x^3 + 4 x^2 + 5 x + 3, the first two rows will be: \n\nRow 1: 10 4 3\n\nRow 2: 12 5 0\n\nFor all other rows, the nth element of the rth row is found recursively by multiplying the 1st element of the (r-1)th row and (n+1)th element of the (r-2)th row and subtracting it with 1st element of the (r-2)th row multiplied by (n+1)th element of the (r-1)th row.\n\nSo Row 3 will be (12 * 4 - 10 * 5) (12 * 3 - 10 * 0)\n\nRow 3: -2 36 0\n\nRow 4: -442 0 0\n\nRow 5: -15912 0 0\n\nThere will not be any row six (number of rows = maximum power of x + 1)\n\nThe rocket is stable if there are no sign changes in the first column. \n\nIf all the elements of the rth row are 0, replace the nth element of the rth row by the nth element of the (r-1)th row multiplied by (maximum power of x + 4 - r - 2n).\n\nIf the first element of any row is 0 and some of the other elements are non zero, the rocket is unstable.\n\nCan you help Rakesh check if his rocket is stable?\n\nInput Format:\n\n1. First row with number of test cases (T).\n\n2. Next T rows with the coefficients of the polynomials for each case (10 12 4 5 3 for the case above).\n\nOutput Format:\n\n1. \"1\" if stable (without \"\")\n\n2. \"0\" if unstable (without \"\")\n\nSample Input: \n\n1\n\n10 12 4 5 3\n\nSample Output:\n\n0", "starter_code": "", "test_cases": {"inputs": ["1\n10 12 4 5 3"], "outputs": ["0"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "9cff0056fce8b9745affcd90207034289ab5d864", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-00543", "original_id": null, "source": "apps", "domain": "code", "problem": "It's autumn now, the time of the leaf fall.\nSergey likes to collect fallen leaves in autumn. In his city, he can find fallen leaves of maple, oak and poplar. These leaves can be of three different colors: green, yellow or red.\nSergey has collected some leaves of each type and color. Now he wants to create the biggest nice bouquet from them. He considers the bouquet nice iff all the leaves in it are either from the same type of tree or of the same color (or both). Moreover, he doesn't want to create a bouquet with even number of leaves in it, since this kind of bouquets are considered to attract bad luck. However, if it's impossible to make any nice bouquet, he won't do anything, thus, obtaining a bouquet with zero leaves.\nPlease help Sergey to find the maximal number of leaves he can have in a nice bouquet, which satisfies all the above mentioned requirements.\nPlease note that Sergey doesn't have to use all the leaves of the same color or of the same type. For example, if he has 20 maple leaves, he can still create a bouquet of 19 leaves.\n\n-----Input-----\nIThe first line of the input contains an integer T denoting the number of test cases. The description of T test cases follows.\"\nThe first line of each test case contains three space-separated integers MG MY MR denoting the number of green, yellow and red maple leaves respectively.\nThe second line contains three space-separated integers OG OY OR denoting the number of green, yellow and red oak leaves respectively.\nThe third line of each test case contains three space-separated integers PG PY PR denoting the number of green, yellow and red poplar leaves respectively.\n\n-----Output-----\nFor each test case, output a single line containing the maximal amount of flowers in nice bouquet, satisfying all conditions or 0 if it's impossible to create any bouquet, satisfying the conditions.\n\n-----Constraints-----\n\n- 1 ≤ T ≤ 10000\n- Subtask 1 (50 points): 0 ≤ MG, MY, MR, OG, OY, OR, PG, PY, PR ≤ 5\n- Subtask 2 (50 points): 0 ≤ MG, MY, MR, OG, OY, OR, PG, PY, PR ≤ 109\n\n-----Example-----\nInput:1\n1 2 3\n3 2 1\n1 3 4\n\nOutput:7\n\n-----Explanation-----\nExample case 1. We can create a bouquet with 7 leaves, for example, by collecting all yellow leaves. This is not the only way to create the nice bouquet with 7 leaves (for example, Sergey can use all but one red leaves), but it is impossible to create a nice bouquet with more than 7 leaves.", "starter_code": "", "test_cases": {"inputs": ["1\n1 2 3\n3 2 1\n1 3 4"], "outputs": ["7"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "93eb1423077cc5cc0ed5789079b7e3e648a90f45", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-00548", "original_id": null, "source": "apps", "domain": "code", "problem": "Tara was completing an Algorithms assignment and got stuck on a question. She thought of who can help her, and got reminded of Kabir who has good problem solving skills. The question is:\nGiven N$N$ the number of elements in the sequence A1$A_1$,A2$A_2$ … An$A_n$. Find out the prime factor which occurred maximum number of times among the largest prime factor corresponding to each element. if there are more than one such prime factors print the largest one.\nYou are friends with Kabir, help him to solve the problem for Tara.\n\n-----Input:-----\n- The first line of the input contains a single integer T$T$ denoting the number of test cases. The description of T test cases follows. \n- First line of each test case contains N$N$, the number of elements in the sequence.\n- Second line contains N space separated elements A1$A_1$,A2$A_2$ … An$A_n$.\n\n-----Output:-----\n- For each test case, print a single line, the number which occurs maximum number of times from the largest prime factor corresponding to each element.\n\n-----Constraints-----\n- 1≤T≤10$1 \\leq T \\leq 10$\n- 1≤N≤105$1 \\leq N \\leq 10^5$\n- 2≤A[i]≤105$2 \\leq A[i] \\leq 10^5$\n\n-----Sample Input:-----\n1\n7\n\n3 2 15 6 8 5 10\n\n-----Sample Output:-----\n5\n\n-----EXPLANATION:-----\nThe largest prime factors of numbers are:\n3 2 5 3 2 5 5 , of which 5 is most frequent.", "starter_code": "", "test_cases": {"inputs": ["1\n7\n3 2 15 6 8 5 10"], "outputs": ["5"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "b45bda4d335885bf85adf47089b2dc09f916a0a9", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-00553", "original_id": null, "source": "apps", "domain": "code", "problem": "Chef has an array of N natural numbers. Cheffina challenges the chef to choose the two numbers from the array and following the condition as the area of the rectangle formed from the two numbers is maximum. Cheffina also asks the chef to choose two numbers different from the previous two to form the rectangle with a minimum area.\n\n-----Input:-----\n- First-line will contain $T$, the number of test cases. Then the test cases follow. \n- Each test case contains a single line of input, $N$.\n- N space-separated natural numbers. \n\n-----Output:-----\nFor each test case, output in one line answers maximum and minimum area of a rectangle.\n\n-----Constraints-----\n- $1 \\leq T \\leq 10$\n- $4 \\leq N \\leq 10^5$\n- $1 \\leq arr[i] \\leq 10^6$\n\n-----Sample Input:-----\n1\n5\n4 2 1 5 3\n\n-----Sample Output:-----\n20 2", "starter_code": "", "test_cases": {"inputs": ["1\n5\n4 2 1 5 3"], "outputs": ["20 2"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "89b4c5cf289e52423349d05151b19aede7c4956a", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-00558", "original_id": null, "source": "apps", "domain": "code", "problem": "You are given a binary string S of N bits. The bits in the string are indexed starting from 1. S[i] denotes the ith bit of S.\n\nLet's say that a sequence i1, i2, …, iK(1 ≤ K; 1 ≤ i1 < i2 < … < iK ≤ N) produces a palindrome when applied to S, if the string S[i1] S[i2] … S[ik] is a palindrome (that is, reads the same backward or forward).\n\nIn addition, a sequence i1, i2, …, iK(1 ≤ K; 1 ≤ i1 < i2 < … < iK ≤ N) is said to be exponential, if ij + 1 = p * ij for each integer 1 ≤ j < K and for some integer p > 1. Note, that a sequence of one element is always exponential.\n\nYour task is to count the number of exponential sequences that produce a palindrome when applied to S.\n\n-----Input-----\nThe first line of input contains an integer T denoting the number of test cases. The description of T test cases follows.\n\nThe only line of description for each test case contains a binary string S of N bits.\n\n-----Output-----\n\nFor each test case, output a single line containing the number of exponential sequences that produce a palindrome.\n\n-----Constraints-----\n- 1 ≤ T ≤ 10\n- Subtask 1(20 points): 1 ≤ N ≤ 20\n- Subtask 2(30 points): 1 ≤ N ≤ 1000\n- Subtask 3(50 points): 1 ≤ N ≤ 5 × 105\n\n-----Note-----\n\nThe first test of the first subtask is the example test. It's made for you to make sure that your solution produces the same verdict both on your machine and our server.\n\n-----Time Limits-----\n\nTime limit for the first and the second subtasks is 3s. Time limit for the third subtask is 6s.\n\n-----Example-----\nInput:\n2\n11010\n101001011\n\nOutput:\n9\n18\n\n-----Explanation of the first case in the example test-----\n\nThe following sequences are counted in the answer: {1}, {2}, {3}, {4}, {5}, {1, 2}, {1, 4}, {2, 4}, {1, 2, 4}.", "starter_code": "", "test_cases": {"inputs": ["2\n11010\n101001011\n\n"], "outputs": ["9\n18"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "ceae35e8fba919437ae984358e3e7fbf92833dd2", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-00563", "original_id": null, "source": "apps", "domain": "code", "problem": "Tanish is the president of the chemistry club at his school. He considers everyone who doesn't like chemistry as his enemy. After years of research, he has invented a lethal poison, which he named success. Now Tanish plans to kill all his enemies with his success. Success is extremely deadly and is untraceable in small concentrations.\nTanish has $\\text{N}$ flasks lying on the shelf of his lab. All of these flasks contain the same volume of poison solution. The concentration of poison in the $\\text{ith}$ flask is $\\mathbf{a_i}$. In one move - Tanish picks up any two flasks, pours half of the contents of each of these flasks into a third initially empty flask, discards the two flasks and places the third flask (which now has the same volume of solution as all other flasks) on the shelf. He performs N-1 such moves to end up with only one flask of poison on the shelf. He wishes to perform these moves such that the concentration of poison in this flask is the minimum possible. What is the minimum concentration of poison that he can achieve?\n\n-----Input-----\nFirst line of the input contains a single integer $\\text{T}$ - the number of test cases. \nFor each test case,\nThe first line contains a single integer $\\text{N}$, the number of bottles. \nThe second line contains N space-separated integers, the concentrations. \n\n-----Output-----\nFor each test case, print one line containing the lowest final concentration. The output will be accepted if the absolute error is $\\leq 10^{-6}$.\n\n-----Constraints-----\n$1 \\leq \\text{T} \\leq 10$\n$2 \\leq \\text{N} \\leq 10^4$\n$0 \\leq \\mathbf{a_i} \\leq 10^9$\n\n-----Sample Input-----\n2\n2\n9 3\n3\n3 2 9\n\n-----Sample Output-----\n6.00000000\n4.00000000\n\n-----Explanation-----\nIn test 1, Tanish mixes flasks 1 and 2. In test 2, he first mixes flasks 1 and 3 to get a flask of concentration 6 and then mixes this flask with flask 2 to get a flask of poison concentration 4. \n\n-----Note-----\nThe concentration is given in the unit ppb i.e. parts per billion.\n1 gram poison in $10^9$ ml solution is 1 ppb.\nConcentration in ppb = (Number of grams of poison / Volume of solution in ml) x $10^9$", "starter_code": "", "test_cases": {"inputs": ["2\n2\n9 3\n3\n3 2 9"], "outputs": ["6.00000000\n4.00000000"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "0af6d7ea4e96cc1e6f868e85ad6a48f986536913", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-00568", "original_id": null, "source": "apps", "domain": "code", "problem": "One of Chef's friends offered him a deal: during $D$ days, they are going to exchange money. For each $i$ ($1 \\le i \\le D$), on the $i$-th day, Chef's friend would give Chef $A$ rupees, while Chef would give his friend $2^{i-1}$ rupees ($1$ rupee on day $1$, $2$ rupees on day $2$, $4$ rupees on day $3$, and so on). Chef's profit from the deal is the total number of rupees he received from his friend minus the total number of rupees he gave his friend.\nChef decided to ask for your advice before accepting the deal. You want to help him by telling him two numbers $D_1$ and $D_2$, where $D_1$ is the maximum value of $D$ such that Chef should accept the deal, i.e. his profit from the deal is positive if $D = D_1$, and $D_2$ is the value of $D$ that leads to the maximum possible profit for Chef. If there are multiple values of $D$ that lead to the maximum profit, $D_2$ is the smallest of these values.\n\n-----Input-----\n- The first line of the input contains a single integer $T$ denoting the number of test cases. The description of $T$ test cases follows.\n- The first and only line of each test case contains a single integer $A$.\n\n-----Output-----\nFor each test case, print a single line containing two space-separated integers $D_1$ and $D_2$.\n\n-----Constraints-----\n- $1 \\le T \\le 100,000$\n- $5 \\le A \\le 10^9$\n\n-----Subtasks-----\nSubtask #1 (100 points): original constraints\n\n-----Example Input-----\n4\n5\n8\n9\n1000000000\n\n-----Example Output-----\n4 3\n5 3\n5 4\n35 30", "starter_code": "", "test_cases": {"inputs": ["4\n5\n8\n9\n1000000000"], "outputs": ["4 3\n5 3\n5 4\n35 30"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "255eea7f236172eca817cd9a47690bcc9c58145b", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-00573", "original_id": null, "source": "apps", "domain": "code", "problem": "Dustin, is the head of an Intelligence agency. He wants to send a secret message S$S$ to his colleague.The message is a single word consisting of only lowercase english letters but he decides to encrypt the message for security reasons. He makes a string M$M$ of length N$N$, such that after deleting a substring of non-zero length from M$M$, the remaining string is S$S$.\nCalculate the number of all such possible strings he can form.\n\n-----Input:-----\n- First line will contain T$T$, number of testcases. Then the testcases follow.\n- For each testcase the there is a single line which contains an integer, N$N$ and then a string S$S$.\n\n-----Output:-----\nFor each testcase, output the number of possible strings modulo 109+7$10^9+7$.\n\n-----Constraints-----\n- 1≤T≤50$1 \\leq T \\leq 50$\n- 1≤N≤1018$1 \\leq N \\leq 10^{18}$\n- 1≤|S|≤105$1 \\leq |S| \\leq 10^5$\n- S$S$ can contain only lowercase English letters.\n\n-----Sample Input:-----\n2\n\n3 a\n\n3 ab \n\n-----Sample Output:-----\n1326\n\n76", "starter_code": "", "test_cases": {"inputs": ["2\n3 a\n3 ab"], "outputs": ["1326\n76"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "81fb2468977af5eaeafc439f8c0515967f73bba4", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-00578", "original_id": null, "source": "apps", "domain": "code", "problem": "One upon a time there were three best friends Abhinav, Harsh, and Akash decided to form a \nteam and take part in ICPC from KIIT. Participants are usually offered several problems during \nthe programming contest. Long before the start, the friends decided that they will implement a \nproblem if at least two of them are sure about the solution. Otherwise, friends won't write the \nproblem's solution. \nThis contest offers $N$ problems to the participants. For each problem we know, which friend is \nsure about the solution. Help the KIITians find the number of problems for which they will write a \nsolution. \nThen n lines contain three integers each, each integer is either 0 or 1. If the first number in the \nline equals 1, then Abhinav is sure about the problem's solution, otherwise, he isn't sure. The \nsecond number shows Harsh's view on the solution, the third number shows Akash's view. The \nnumbers on the lines are \n\n-----Input:-----\n- A single integer will contain $N$, number of problems. \n\n-----Output:-----\nPrint a single integer — the number of problems the friends will implement on the contest. \n\n-----Constraints-----\n- $1 \\leq N \\leq 1000$ \n\n-----Sample Input:-----\n3\n\n1 1 0\n\n1 1 1\n\n1 0 0 \n\n-----Sample Output:-----\n2 \n\n-----EXPLANATION:-----\nIn the first sample, Abhinav and Harsh are sure that they know how to solve the first problem \nand all three of them know how to solve the second problem. That means that they will write \nsolutions for these problems. Only Abhinav is sure about the solution for the third problem, but \nthat isn't enough, so the group won't take it.", "starter_code": "", "test_cases": {"inputs": ["3\n1 1 0\n1 1 1\n1 0 0"], "outputs": ["2"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "8a6d9dfde53e1775200ca220602eca04c0094eae", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-00583", "original_id": null, "source": "apps", "domain": "code", "problem": "You are given an array A of size N. Let us list down all the subarrays of the given array. There will be a total of N * (N + 1) / 2 subarrays of the given array. Let us sort each of the subarrays in descending order of the numbers in it. \n\nNow you want to sort these subarrays in descending order. You can compare two subarrays B, C, as follows.\n\ncompare(B, C):\nAppend N - |B| zeros at the end of the array B.\nAppend N - |C| zeros at the end of the array C.\nfor i = 1 to N:\nif B[i] < C[i]:\nreturn B is less than C\nif B[i] > C[i]:\nreturn B is greater than C\nreturn B and C are equal.\n\nYou are given M queries asking for the maximum element in the pth subarray (1-based indexing).\n\n-----Input-----\nThe first line of input contains T, the number of test cases.\nThe first line of each test case contains two space separated integers N and M, denoting the array size and the number of queries respectively.\nThe next line contains N space-separated integers denoting the array elements.\n\nEach of the next M lines contains a single integer - p.\n\n-----Output-----\nOutput a single integer corresponding to the maximum element in the pth subarray.\n\n-----Constraints-----\n- 1 ≤ Ai ≤ 109\n- 1 ≤ p ≤ N+1C2\n\n-----Subtasks-----Subtask #1 (20 points):\n- 1 ≤ T ≤ 20\n- 1 ≤ N ≤ 200\n- 1 ≤ M ≤ 104\nSubtask #2 (30 points):\n- 1 ≤ T ≤ 20\n- 1 ≤ N ≤ 3000\n- 1 ≤ M ≤ 104\nSubtask #3 (50 points):\n- 1 ≤ T ≤ 5\n- 1 ≤ N ≤ 105\n- 1 ≤ M ≤ 105\n\n-----Example-----\nInput:1\n4 2\n3 1 2 4\n1\n5\n\nOutput:4\n3", "starter_code": "", "test_cases": {"inputs": ["1\n4 2\n3 1 2 4\n1\n5"], "outputs": ["4\n3"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "78ec03ccc53bf328d1162dcfcdd731a2a84329dd", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-00588", "original_id": null, "source": "apps", "domain": "code", "problem": "Johnny has some difficulty memorizing the small prime numbers. So, his computer science teacher has asked him to play with the following puzzle game frequently.\nThe puzzle is a 3x3 board consisting of numbers from 1 to 9. The objective of the puzzle is to swap the tiles until the following final state is reached:\n1 2 3\n4 5 6\n7 8 9\n\nAt each step, Johnny may swap two adjacent tiles if their sum is a prime number. Two tiles are considered adjacent if they have a common edge.\nHelp Johnny to find the shortest number of steps needed to reach the goal state.\n\n-----Input-----\nThe first line contains t, the number of test cases (about 50). Then t test cases follow. Each test case consists of a 3x3 table describing a puzzle which Johnny would like to solve.\nThe input data for successive test cases is separated by a blank line.\n\n-----Output-----\nFor each test case print a single line containing the shortest number of steps needed to solve the corresponding puzzle. If there is no way to reach the final state, print the number -1.\n\n-----Example-----\nInput:\n2\n\n7 3 2 \n4 1 5 \n6 8 9 \n\n9 8 5 \n2 4 1 \n3 7 6 \n\nOutput:\n6\n-1\n\n-----Output details-----\nThe possible 6 steps in the first test case are described in the following figure:", "starter_code": "", "test_cases": {"inputs": ["2\n\n7 3 2 \n4 1 5 \n6 8 9 \n\n9 8 5 \n2 4 1 \n3 7 6 \n\n"], "outputs": ["6\n-1"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "27cd4b2490be155922ad29f4da93a47aa2fa7f13", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-00593", "original_id": null, "source": "apps", "domain": "code", "problem": "You are given $n$ intervals on the $X$ axis. Each interval $i$ is specified by its ends $[L_i, R_i]$. You want to color each interval either blue or yellow. After coloring all the intervals, the $X$ axis will will have $4$ colors:\n- White, the part of $X$ axis contained in no interval\n- Blue, the part of $X$ axis contained in atleast one blue colored interval and no yellow colored interval.\n- Yellow, the part of $X$ axis contained in atleast one yellow colored interval and no blue colored interval.\n- Green, the part of $X$ axis contained in at least one blue colored interval and at least one yellow colored interval.\nYou want to color the intervals so that the total length of the part colored green is maximized. If there are multiple ways to color which maximize the green part, you can output any of them.\n\n-----Input:-----\n- First line will contain $T$, number of testcases. Then the testcases follow. \n- The first line of each testcase contains $n$, the number of intervals.\n- The $i^{\\text{th}}$ of the next $n$ lines contains two integers $L_i$ and $R_i$ describing the $i^{\\text{th}}$ interval.\n\n-----Output:-----\nFor each testcase, output a single string on a new line, whose $i^{\\text{th}}$ character is $0$ if you color the $i^{\\text{th}}$ interval blue, and $1$ if you color it yellow.\n\n-----Constraints-----\n- $ 1 \\leq T \\leq 10^5 $\n- $ 1 \\leq n \\leq 10^5 $\n- The sum of $n$ over all testcases doesn't exceed $10^5$.\n- $ 1 \\leq L_i \\leq R_i \\leq 10^9 $ for al $ 1 \\leq i \\leq n$.\n\n-----Sample Input:-----\n1\n3\n3 7\n2 5\n6 9\n\n-----Sample Output:-----\n100\n\n-----Explanation:-----\nThe intervals are $[3, 7]$, $[2, 5]$, $[6, 9]$. It is optimal to color them in yellow, blue and blue respectively. In this coloring:\n- $[2, 3) \\cup (7, 9]$ is colored blue.\n- $(5, 6)$ is colored yellow.\n- $[3, 5] \\cup [6, 7]$ is colored green, with a total length of $(5 - 3) + (7 - 6) = 3$.\n- Rest of the $X$ axis is colored white.\nPlease note that colors at the endpoints of the intervals don't matter when computing the lengths, and we can ignore them. Open and closed intervals have been used in the explanation section only for clarity, and it doesn't matter whether they are open or closed.\nNote that 011 is also a valid output.", "starter_code": "", "test_cases": {"inputs": ["1\n3\n3 7\n2 5\n6 9"], "outputs": ["100"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "ac38fa424192568f647c804091689bd3f608ff46", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-00598", "original_id": null, "source": "apps", "domain": "code", "problem": "Limak has a string S, that consists of N lowercase English letters.\nLimak then created a new string by repeating S exactly K times.\nFor example, for S = \"abcb\" and K = 2, he would get \"abcbabcb\".\nYour task is to count the number of subsequences \"ab\" (not necessarily consecutive) in the new string.\nIn other words, find the number pairs of indices i < j, such that the i-th and j-th characters in the new string are 'a' and 'b' respectively.\n\n-----Input-----\nThe first line of the input contains an integer T denoting the number of test cases. The description of T test cases follows.\nThe first line of each test case contains two integers N and K, denoting the length of the initial string S and the number of repetitions respectively.\nThe second line contains a string S.\nIts length is exactly N, and each of its characters is a lowercase English letter.\n\n-----Output-----\nFor each test case, output a single line containing one integer — the number of subsequences \"ab\" in the new string.\nFor the given constraints, it can be proved that the answer fits in the 64-bit signed type.\n\n-----Constraints-----\n- 1 ≤ T ≤ 10\n- 1 ≤ N ≤ 105\n- 1 ≤ N * K ≤ 109 (in other words, the new string has length up to 109)\n\n-----Example-----\nInput:\n3\n4 2\nabcb\n7 1\naayzbaa\n12 80123123\nabzbabzbazab\n\nOutput:\n6\n2\n64197148392731290\n\n-----Explanation-----\nTest case 1. Limak repeated the string \"abcb\" 2 times, and so he got \"abcbabcb\". There are 6 occurrences of the subsequence \"ab\":\n- ABcbabcb (the two letters marked uppercase)\n- AbcBabcb\n- AbcbaBcb\n- AbcbabcB\n- abcbABcb\n- abcbAbcB\nTest case 2. Since K = 1, the new string is equal to the given S (\"aayzbaa\"). There are 2 occurrences of the subsequence \"ab\" in this string: AayzBaa and aAyzBaa.", "starter_code": "", "test_cases": {"inputs": ["3\n4 2\nabcb\n7 1\naayzbaa\n12 80123123\nabzbabzbazab\n\n"], "outputs": ["6\n2\n64197148392731290"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "1174b959c66f8ae8cbcaa14b6b2fbeda87e10c8d", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-00603", "original_id": null, "source": "apps", "domain": "code", "problem": "Striver$Striver$ wants to strive hard in order to reach his goals, hence asks his mentor to give him a question for which he has to strive hard. \nThe mentor gives Striver$Striver$ a N$N$ X N$N$ matrix consisting of lowercase characters (′a′$'a'$ to ′z′$'z'$) and Q$Q$ queries. Every query consists of X$X$ and Y$Y$. From any position in the matrix, one can either move towards the right or towards down. He asks striver to write down all the paths from (1,1)$(1, 1)$ to (X,Y)$(X, Y)$ and find out which string has the maximum number of character ′a′$'a'$ in it and answer him the number of characters which are not 'a' in that string. \nStriver wants to strive hard but also wants to impress his mentor. He asks for your help to answer Q$Q$ queries given by his mentor as fast as he can so that he can impress his mentor also. Can you help him to answer the Q queries?\n\n-----Input:-----\n- First line will contain T$T$, number of test cases. Then the test cases follow. \n- First line of every test case contains a number N$N$ and Q$Q$ which denotes the dimensions of the matrix and number of queries respectively. \n- N lines follow, which contains N numbers each denoting the elements of the matrix. \n- Q line follow, every line contains X and Y. \n\n-----Output:-----\nFor every test case, print a single integer which prints the answer to mentor's every query. \n\n-----Constraints-----\n- 1≤T≤10$1 \\leq T \\leq 10$\n- 1≤N≤103$1 \\leq N \\leq 10^3$\n- 1≤Q≤105$1 \\leq Q \\leq 10^5$\n- 1≤X,Y≤N$1 \\leq X, Y \\leq N$\n\n-----Sample Input:-----\n1\n3 2 \na b a \na c d \nb a b\n1 3\n3 3 \n\n-----Sample Output:-----\n1 \n2\n\n-----EXPLANATION:-----\nQuery-1: There is only one path from (1,1) to (1,3) i.e.,\"aba\" and the number of characters which are not 'a' is 1. \nQuery-2: The path which has the maximum number of 'a' in it is \"aabab\", hence non 'a' characters are 2.", "starter_code": "", "test_cases": {"inputs": ["1\n3 2\na b a\na c d\nb a b\n1 3\n3 3"], "outputs": ["1\n2"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "cd29add5eaf70ca70aefe6733cfd97d1445a2a4d", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-00608", "original_id": null, "source": "apps", "domain": "code", "problem": "The chef is trying to solve some pattern problems, Chef wants your help to code it. Chef has one number K to form a new pattern. Help the chef to code this pattern problem.\n\n-----Input:-----\n- First-line will contain $T$, the number of test cases. Then the test cases follow. \n- Each test case contains a single line of input, one integer $K$. \n\n-----Output:-----\nFor each test case, output as the pattern.\n\n-----Constraints-----\n- $1 \\leq T \\leq 100$\n- $1 \\leq K \\leq 100$\n\n-----Sample Input:-----\n3\n5\n3\n4\n\n-----Sample Output:-----\n1 1\n2 2\n3\n4 4\n5 5\n1 1\n2\n3 3\n1 1\n22\n33\n4 4\n\n-----EXPLANATION:-----\nNo need, else pattern can be decode easily.", "starter_code": "", "test_cases": {"inputs": ["3\n5\n3\n4"], "outputs": ["1 1\n2 2\n3\n4 4\n5 5\n1 1\n2\n3 3\n1 1\n22\n33\n4 4"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "e9338a2039b9ed8c4ef3af979669e27cd8e05457", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-00613", "original_id": null, "source": "apps", "domain": "code", "problem": "Coach Moony wants the best team to represent their college in ICPC. He has $N$ students standing in a circle with certain rating $X_i$ on a competitive coding platform. It is an established fact that any coder with more rating on the platform is a better coder. \nMoony wants to send his best $3$ coders based upon their rating. But all coders only want to have their friends in their team and every coder is friends with four other coders, adjacent two on left side in the circle, and adjacent two on right. So Moony comes up with a solution that team with maximum cumulative rating of all three members in a team shall be representing their college.\nYou need to give the cumulative score of the team that will be representing the college.\n\n-----Input:-----\n- First line will contain $T$, number of testcases. \n- First line of each test case contains a single integer $N$.\n- Second line of each test case takes $N$ integers, denoting rating of $ith$ coder.\n\n-----Output:-----\nFor each testcase, output a single integer denoting cumulative rating of the team.\n\n-----Constraints-----\n- $1 \\leq T \\leq 10$\n- $7 \\leq N \\leq 10^5$ \n- $0 \\leq X_i \\leq 10^9$\n\n-----Sample Input:-----\n1\n\n7\n\n10 40 30 30 20 0 0 \n\n-----Sample Output:-----\n100", "starter_code": "", "test_cases": {"inputs": ["1\n7\n10 40 30 30 20 0 0"], "outputs": ["100"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "2814400b83fac96b5ea9a5f3c3eeea83dcaed6c8", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-00618", "original_id": null, "source": "apps", "domain": "code", "problem": "Accepts a string from the user and print the reverse string as the output without using any built-in function.\n\n-----Input:-----\nEach testcase contains of a single line of input, a string.\n\n-----Output:-----\nFor each testcase, output in a single line answer, the reverse string.\n\n-----Sample Input:-----\n1\nTracy\n\n-----Sample Output:-----\nycarT", "starter_code": "", "test_cases": {"inputs": ["1\nTracy"], "outputs": ["ycarT"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "dd4d18e28ab1bf5c2a7eb259695b16c2cf5088b7", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-00623", "original_id": null, "source": "apps", "domain": "code", "problem": "Minion Chef likes to eat bananas a lot. There are N piles of bananas in front of Chef; for each i (1 ≤ i ≤ N), the i-th pile contains Ai bananas.\nChef's mother wants her to eat the bananas and be healthy. She has gone to the office right now and will come back in H hours. Chef would like to make sure that she can finish eating all bananas by that time.\nSuppose Chef has an eating speed of K bananas per hour. Each hour, she will choose some pile of bananas. If this pile contains at least K bananas, then she will eat K bananas from it. Otherwise, she will simply eat the whole pile (and won't eat any more bananas during this hour).\nChef likes to eat slowly, but still wants to finish eating all the bananas on time. Therefore, she would like to choose the minimum K such that she is able to eat all the bananas in H hours. Help Chef find that value of K.\n\n-----Input-----\n- The first line of the input contains a single integer T denoting the number of test cases. The description of T test cases follows.\n- The first line of each test case contains two space-separated integers N and H denoting the number of piles and the number of hours after which Chef's mom will come home.\n- The second line contains N space-separated integers A1, A2, ..., AN.\n\n-----Output-----\nFor each test case, print a single line containing one integer — the minimum possible value of K.\n\n-----Constraints-----\n- 1 ≤ T ≤ 10\n- 1 ≤ N ≤ 105\n- N ≤ H ≤ 109\n- 1 ≤ Ai ≤ 109 for each valid i\n\n-----Subtasks-----\nSubtask #1 (30 points):\n- 1 ≤ N ≤ 100\n- Ai ≤ 103 for each valid i\n\nSubtask #2 (70 points): original constraints\n\n-----Example-----\nInput:\n\n3\n3 3\n1 2 3\n3 4\n1 2 3\n4 5\n4 3 2 7\n\nOutput:\n\n3\n2\n4\n\n-----Explanation-----\nExample case 1: With a speed of K = 3 bananas per hour, Chef can finish eating all the bananas in 3 hours. It's the minimum possible speed with which she can eat all the bananas in 3 hours. With a speed of 2 bananas per hour, she would take at least 4 hours and with a speed of 1 banana per hour, she would take at least 6 hours.", "starter_code": "", "test_cases": {"inputs": ["3\n3 3\n1 2 3\n3 4\n1 2 3\n4 5\n4 3 2 7"], "outputs": ["3\n2\n4"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "4254abb9c85b1ebe27dbc02d3f7e374aa5e85fa3", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-00628", "original_id": null, "source": "apps", "domain": "code", "problem": "Given N, count how many permutations of [1, 2, 3, ..., N] satisfy the following property.\n\nLet P1, P2, ..., PN denote the permutation. The property we want to satisfy is that there exists an i between 2 and n-1 (inclusive) such that\n\n- Pj > Pj + 1 ∀ i ≤ j ≤ N - 1.\n- Pj > Pj - 1 ∀ 2 ≤ j ≤ i.\n\n-----Input-----\nFirst line contains T, the number of test cases. Each test case consists of N in one line.\n\n-----Output-----\nFor each test case, output the answer modulo 109+7.\n\n-----Constraints-----\n- 1 ≤ T ≤ 100\n- 1 ≤ N ≤ 109\n\n-----Subtasks-----\n- Subtask #1(40 points): 1 ≤ N ≤ 1000\n- Subtask #2(60 points): original constraints\n\n-----Example-----\nInput:\n2\n2\n3\n\nOutput:\n0\n2\n\n-----Explanation-----\n\nTest case 1:\n\nNo permutation satisfies.\n\nTest case 2:\n\nPermutations [1, 3, 2] and [2, 3, 1] satisfy the property.", "starter_code": "", "test_cases": {"inputs": ["2\n2\n3"], "outputs": ["0\n2"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "486e3dd7634b1360db9085ab6b3c9c4d922b4800", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-00633", "original_id": null, "source": "apps", "domain": "code", "problem": "You are given a grid with $R$ rows (numbered $1$ through $R$) and $C$ columns (numbered $1$ through $C$). Initially, each cell of this grid is either empty, contains an ant or an anteater. Each ant is moving in a fixed direction: up, down, left or right. The anteaters do not move.\nThe movement of ants happens in discrete steps. For example, when an ant is in the cell in the $i$-th row and $j$-th column at some point in time (in some step) and it is moving down, then in the next step, it enters the cell in the $(i+1)$-th row and $j$-th column. Two ants meet each other when they enter the same cell at the same point in time (in the same step). When ants meet, they do not interact in any way and keep moving in their fixed directions.\nIf an ant reaches an anteater, that anteater eats the ant, so the ant completely disappears. If an ant attempts to leave the grid, it also disappears. When two ants enter a cell containing an anteater at the same time, they are eaten before they could meet.\nCalculate the total number of pairs of ants that meet each other.\n\n-----Input-----\n- The first line of the input contains a single integer $T$ denoting the number of test cases. The description of $T$ test cases follows.\n- The first line of each test case contains two space-separated integers $R$ and $C$.\n- Each of the following $R$ lines contains a single string with length $C$. For each valid $i, j$, the $j$-th character in the $i$-th string is:\n- '#' if the cell in the $i$-th row and $j$-th column of the grid contains an anteater\n- 'U', 'D', 'L' or 'R' if this cell contains an ant moving up, down, left or right respectively\n- '-' if this cell is empty\n\n-----Output-----\nFor each test case, print a single line containing one integer — the number of pairs of ants that meet.\n\n-----Constraints-----\n- $1 \\le T \\le 10$\n- $1 \\le R, C \\le 50$\n- each string contains only characters 'U', 'D', 'L', 'R', '#' and '-'\n\n-----Example Input-----\n10\n3 3\nR--\n---\n--U\n1 4\nR--R\n2 2\n--\n--\n1 4\nR--L\n1 4\n-R-L\n1 4\n-R#L\n3 3\nR-D\n-#-\nR-U\n3 3\nR-D\n---\nR#U\n3 3\n-D-\nR-L\n-U-\n1 7\nRLLLLLL\n\n-----Example Output-----\n1\n0\n0\n0\n1\n0\n3\n2\n6\n3", "starter_code": "", "test_cases": {"inputs": ["10\n3 3\nR--\n---\n--U\n1 4\nR--R\n2 2\n--\n--\n1 4\nR--L\n1 4\n-R-L\n1 4\n-R#L\n3 3\nR-D\n-#-\nR-U\n3 3\nR-D\n---\nR#U\n3 3\n-D-\nR-L\n-U-\n1 7\nRLLLLLL\n"], "outputs": ["1\n0\n0\n0\n1\n0\n3\n2\n6\n3"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "358fd111a7ef7096de120158f265859419210688", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-00638", "original_id": null, "source": "apps", "domain": "code", "problem": "A policeman wants to catch a thief. Both the policeman and the thief can only move on a line on integer coordinates between $0$ and $N$ (inclusive).\nInitially, the policeman is at a coordinate $x$ and the thief is at a coordinate $y$. During each second, each of them must move to the left or right (not necessarily both in the same direction) by distance $\\textbf{exactly}$ equal to $K$. No one may go to the left of the coordinate $0$ or to the right of $N$. Both the policeman and the thief move simultaneously and they cannot meet while moving, only at the end of each second.\nWill the policeman be able to catch the thief if they both move optimally? The thief is caught as soon as the policeman and thief meet at the same position at the same time.\n\n-----Input-----\n- The first line of the input contains a single integer $T$ denoting the number of test cases. The description of $T$ test cases follows.\n- The first and only line of each test case contains four space-separated integers $x$, $y$, $K$ and $N$.\n\n-----Output-----\nFor each test case, print a single line containing the string \"Yes\" if the thief can be caught or \"No\" if the thief cannot be caught (without quotes).\n\n-----Constraints-----\n- $1 \\le T \\le 1,000$\n- $1 \\le N \\le 10^9$\n- $1 \\le K \\le N$\n- $0 \\le x, y \\le N$\n- $x \\neq y$\n\n-----Example Input-----\n5\n0 1 1 1\n1 4 1 5\n4 2 1 7\n3 7 2 10\n8 2 3 15\n\n-----Example Output-----\nNo\nNo\nYes\nYes\nYes\n\n-----Explanation-----\nExample case 1: The policeman is at $0$ and the thief is at $1$. After the $1$-st second, the policeman is at $1$ and the thief is at $0$. After the next second, the policeman is again at $0$ and the thief at $1$. They cannot end up at the same coordinate.", "starter_code": "", "test_cases": {"inputs": ["5\n0 1 1 1\n1 4 1 5\n4 2 1 7\n3 7 2 10\n8 2 3 15"], "outputs": ["No\nNo\nYes\nYes\nYes"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "3eb99b0172f45e866c7e2f24a80ce1de8a0a3c89", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-00643", "original_id": null, "source": "apps", "domain": "code", "problem": "It's year 2018 and it's Christmas time! Before going for vacations, students of Hogwarts School of Witchcraft and Wizardry had their end semester exams.\n$N$ students attended the semester exam. Once the exam was over, their results were displayed as either \"Pass\" or \"Fail\" behind their magic jacket which they wore. A student cannot see his/her result but can see everyone else's results. Each of $N$ students count the number of passed students they can see.\nGiven the number of \"Pass\" verdicts that each of the $N$ students counted, we have to figure out conclusively, the number of students who failed, or report that there is some inconsistency or that we cannot be sure.\n\n-----Input:-----\n- First line will contain $T$, number of testcases. Then the testcases follow. \n- The first line of each test case will contain $N$, representing the number of students who attended the exam.\n- Next line contains $N$ spaced integers representing the number of \"Pass\" counted by each of the $N$ students.\n\n-----Output:-----\n- For each test case, output the answer in a single line. \n- If the counts reported by the students are not consistent with each other or if it's not possible to predict the number of failed students from the given input, then print -1.\n\n-----Constraints-----\n- $1 \\leq T \\leq 50$\n- $1 \\leq N \\leq 10^{5}$\n- $0 \\leq$ Count given by each Student $\\leq 10^{5}$\n\n-----Sample Input:-----\n1\n4\n3 2 2 2\n\n-----Sample Output:-----\n1\n\n-----EXPLANATION:-----\nThere are 4 students, and they counted the number of passed students as 3,2,2,2. The first student can see that all others have passed, and all other students can see only 2 students who have passed. Hence, the first student must have failed, and others have all passed. Hence, the answer is 1.", "starter_code": "", "test_cases": {"inputs": ["1\n4\n3 2 2 2"], "outputs": ["1"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "195c9e60b8fc2c5274242d67c1c0f33faaa3fe48", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-00648", "original_id": null, "source": "apps", "domain": "code", "problem": "Cherry has a string S$S$ consisting of lowercase English letters. Using this string, he formed a pyramid of infinite length with certain rules:\n- N$N$-th row of pyramid contains N$N$ characters.\n- Each row of pyramid begins with the first character of the string.\n- The subsequent characters of the row are appended to the string in cyclic fashion, until the size of string for that Row is reached (See example pyramid for better understanding).\nHe has another string T$T$ of smaller (or equal) size.\nYou are asked Q$Q$ queries. Each query is provided with a row number N$N$. The answer to the query is number of occurrences of string T$T$ in that particular row of pyramid. No of occurrences of String T$T$ in a string V$V$ would mean that you'd need to find number of substrings Vi,Vi+1...Vj$V_i, V_{i+1} ... V_j$ which are equal to String T$T$, where i≤j$i \\leq j$.\nFor eg: If the string is code, then the pyramid will be of the form:\nc\nco\ncod\ncode\ncodec\ncodeco\ncodecod\ncodecode\ncodecodec\ncodecodeco\n...\n\n-----Input:-----\n- The first line contains string S$S$ — consisting of lowercase English letters.\n- The second line contains string T$T$ — consisting of lowercase English letters.\n- Next line contains an integer Q$Q$ — the number of queries.\n- Then follow Q$Q$ lines with queries descriptions. Each of them contains a single integer N$N$ denoting the row number of pyramid.\n\n-----Output:-----\n- Print Q$Q$ lines. The i$i$-th of them should contain a integer denoting occurrences of string T$T$ in that particular row.\n\n-----Constraints-----\n- 1≤|S|≤105$1 \\leq |S| \\leq 10^5$\n- 1≤|T|≤|S|$1 \\leq |T| \\leq |S|$\n- 1≤Q≤105$1 \\leq Q \\leq 10^5$\n- 1≤N≤109$1 \\leq N \\leq 10^9$\n\n-----Sample Input:-----\ncodechef\nchefcode\n3\n4\n12\n1455\n\n-----Sample Output:-----\n0\n1\n181\n\n-----Explanation:-----\nPyramid will be formed as explained in the statement.\nQuery 1: Row number 4 of the pyramid is code. The number of occurrences of chefcode in code is 0.\nQuery 2: Row number 12 of the pyramid is codechefcode. The number of occurrences of chefcode in codechefcode is 1.", "starter_code": "", "test_cases": {"inputs": ["codechef\nchefcode\n3\n4\n12\n1455"], "outputs": ["0\n1\n181"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "03a709aee737c8f1f3dd9a03b37c30f95ad75a64", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-00653", "original_id": null, "source": "apps", "domain": "code", "problem": "Note : This question carries $150$ $points$\nThere is an outcry in Middle Earth, as the greatest war between Orgs of Dark Lord Sauron and Frodo Baggins is about to begin. To end the war, Frodo decides to destroy the ring in the volcano of Mordor. There are many ships that lead Frodo to Mordor, and he is confused about which one he should board. Given two-ship numbers $M$ and $N$, Frodo has to solve a problem to find the ship which he should board.\nFind the number of pairs (x, y), such that $1<=x<=M$ and $1<=y<=N$, for which $x*y + x+ y = string(x)+string(y)$ is true. \nAlso, calculate the number of distinct x satisfying the given condition. The number of pairs and the number of distinct x will help select Frodo the boat he should board. Help Frodo defeat Sauron. \n\n-----Input :-----\n- First line contains $T$ as number of test cases \n- Each test case contains two integers $M$ and $N$ \n\n-----Output :-----\n- For each test case, print two integers - the number of such pairs (x,y) and the number of distinct x\n\n-----Constraints :-----\n- 1 ≤ T ≤ 5000\n- 1 ≤ M, N ≤ 10^9\n\n-----Sample Input :-----\n1\n1 9\n\n-----Sample Output :-----\n1 1\n\n-----Explanation :-----\nFor test case two M=1 and N=9 Pair (1,9) satisfies the above condition 1*9+1+9= “19” and only x=1 satisfies the equation.", "starter_code": "", "test_cases": {"inputs": ["1\n1 9"], "outputs": ["1 1"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "34243d9cecbfef0f6fc07f47190674e1e147a7ab", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-00658", "original_id": null, "source": "apps", "domain": "code", "problem": "Kabir likes Tara's smile and wants to look at her smile. They are sitting in the class and you are friends with Kabir. You have to place a mirror (point size) in the front wall of the class so that Kabir can have a glimpse of Tara's smile.\nConsider the front wall as x-axis . You are given the coordinates of position of Kabir (x1,y1)$(x1,y1)$ and Tara (x2,y2)$(x2,y2)$. Find the position where the mirror should be placed. \n\n-----Input:-----\n- First line will contain T$T$, number of testcases. Then the testcases follow. \n- First line of each testcase contains two integers x1,y1$x1, y1$.\n- Second line of each testcase contains two integers x2,y2$x2, y2$. \n\n-----Output:-----\nFor each testcase, print the x-coordinate of the mirror. Absolute error of 10−2$10^{−2}$ is allowed.\n\n-----Constraints:-----\n- 1≤T≤1000$1 \\leq T \\leq 1000$\n- 1≤x1,y1,x2,y2≤105$1 \\leq x1,y1,x2,y2 \\leq 10^5 $\n\n-----Sample Input:-----\n1\n1 1\n\n4 4\n\n-----Sample Output:-----\n1.60", "starter_code": "", "test_cases": {"inputs": ["1\n1 1\n4 4"], "outputs": ["1.60"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "2a7be1e0395f29e55767c53d07299c58dd6c587d", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-00663", "original_id": null, "source": "apps", "domain": "code", "problem": "-----Problem Statement-----\nA classroom has several students, half of whom are boys and half of whom are girls. You need to arrange all of them in a line for the morning assembly such that the following conditions are satisfied:\n- The students must be in order of non-decreasing height.\n- Two boys or two girls must not be adjacent to each other.\nYou have been given the heights of the boys in the array $b$ and the heights of the girls in the array $g$. Find out whether you can arrange them in an order which satisfies the given conditions. Print \"YES\" if it is possible, or \"NO\" if it is not.\nFor example, let's say there are $n = 3$ boys and $n = 3$ girls, where the boys' heights are $b = [5, 3, 8]$ and the girls' heights are $g = [2, 4, 6]$. These students can be arranged in the order $[g_0, b_1, g_1, b_0, g_2, b_2]$, which is $[2, 3, 4, 5, 6, 8]$. Because this is in order of non-decreasing height, and no two boys or two girls are adjacent to each other, this satisfies the conditions. Therefore, the answer is \"YES\".\n\n-----Input-----\n- The first line contains an integer, $t$, denoting the number of test cases.\n- The first line of each test case contains an integer, $n$, denoting the number of boys and girls in the classroom.\n- The second line of each test case contains $n$ space separated integers, $b_1,b_2, ... b_n$, denoting the heights of the boys.\n- The second line of each test case contains $n$ space separated integers, $g_1,g_2,... g_n$, denoting the heights of the girls.\n\n-----Output-----\nPrint exactly $t$ lines. In the $i^{th}$ of them, print a single line containing \"$YES$\" without quotes if it is possible to arrange the students in the $i^{th}$ test case, or \"$NO$\" without quotes if it is not.\n\n-----Constraints-----\n- $1 \\leq t \\leq 10$\n- $1 \\leq n \\leq 100$\n- $1 \\leq b_i, g_i \\leq 100$\n\n-----Sample Input-----\n1\n2\n1 3\n2 4\n\n-----Sample Output-----\nYES\n\n-----EXPLANATION-----\nThe following arrangement would satisfy the given conditions: $[b_1, g_1, b_2, g_2]$. This is because the boys and girls and separated, and the height is in non-decreasing order.", "starter_code": "", "test_cases": {"inputs": ["1\n2\n1 3\n2 4"], "outputs": ["YES"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "90c5a61df85545982203eadd55071cec83ea8bb8", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-00668", "original_id": null, "source": "apps", "domain": "code", "problem": "You are teaching a class of $N$ students. Today, during the morning prayer, all the students are standing in a line. You are given a string $s$ with length $N$; for each valid $i$, the $i$-th character of this string is 'b' if the $i$-th student in the line is a boy or 'g' if this student is a girl.\nThe awkwardness of this configuration of students is defined as the sum of pairwise distances between each boy and girl. The distance between the $i$-th and $j$-th student in the line is $|i - j|$. Formally, the awkwardness is ∑i=1N∑j=i+1sj≠siN(j−i).∑i=1N∑j=i+1sj≠siN(j−i).\\sum\\limits_{i=1}^N \\, \\sum\\limits_{j=i+1\\\\ s_j \\neq s_i}^N (j - i)\\,.\nAs the teacher, it is your responsibility to reorder the students in such a way that the awkwardness of the resulting configuration is the smallest possible. You may reorder the students in the line in any way you want. Find the minimum awkwardness that can be achieved.\n\n-----Input-----\n- The first line of the input contains a single integer $T$ denoting the number of test cases. The description of $T$ test cases follows.\n- The first and only line of each test case contains a single string $s$.\n\n-----Output-----\nFor each test case, print a single line containing one integer - the minimum possible awkwardness.\n\n-----Constraints-----\n- $1 \\le T \\le 10^5$\n- $1 \\le |s| \\le 10^5$\n- each character of $s$ is either 'b' or 'g'\n- the sum of $|s|$ over all test cases does not exceed $4 \\cdot 10^6$\n\n-----Example Input-----\n3\ngb\nbgg\nbbgg\n\n-----Example Output-----\n1\n2\n6\n\n-----Explanation-----\nExample case 1: The total awkwardness is $|1 - 0| = 1$, no matter how you arrange the students.\nExample case 2: Initially, the awkwardness is $|1 - 0| + |2 - 0| = 1 + 2 = 3$. However, you can move the boy between the two girls, i.e. choose the configuration \"gbg\". Here, the awkwardness is $|1 - 0| + |2 - 1| = 1 + 1 = 2$.", "starter_code": "", "test_cases": {"inputs": ["3\ngb\nbgg\nbbgg"], "outputs": ["1\n2\n6"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "261dbf81a2dc7f10dab75334cf3cfd8945abe209", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-00673", "original_id": null, "source": "apps", "domain": "code", "problem": "Mohit(Ex GenSec ) is the most active member of the roasting club who loves giving tasks to other members. One day he observed that none of the members were paying attention to the online classes, so he decided to have some fun and overcome the boring lectures. He wrote N numbers on the virtual board (where the first number is 1, the last one is N and the ith number being i).\nThen he asked M questions to every other member of the club. In each question, a number K was given by Mohit and the members had to give a single integer as an answer which will be the sum of all numbers present on the whiteboard.\nThere are some conditions that every member has to follow while answering.\n- If K is already present on the whiteboard then swap the first and last number.\n- Otherwise, replace the last number with K.\n\n-----Input:-----\n- First-line will consist of space-separated integers N and M. The board will contain the list of numbers from 1 to N and M is the number of questions that Mohit will ask.\n- Next M lines contain the number Ki, which will be provided by Mohit and (1<=i<=M).\n\n-----Output:-----\nFor each question, report the sum of all integers present\n\n-----Constraints-----\n- $1 \\leq N,M \\leq 1000000$\n- $2 \\leq K \\leq 10^9$\n\n-----Sample Input:-----\n5 4\n7\n12 \n10 \n1 \n\n-----Sample Output:-----\n17\n22 \n20\n20", "starter_code": "", "test_cases": {"inputs": ["5 4\n7\n12\n10\n1"], "outputs": ["17\n22\n20\n20"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "47382d448fc0fcf1cf2ba8979af6dd8a44696585", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-00678", "original_id": null, "source": "apps", "domain": "code", "problem": "Given a triplet of integers (X , Y , Z), such that X ≤ Y and Y ≥ Z, we define f(X , Y , Z) to be (X + Y) * (Y + Z). If either X > Y or Y < Z, or both, then f(X , Y , Z) is defined to be 0.\nYou are provided three arrays A , B and C of any length (their lengths may or may not be equal). \nYour task is to find the sum of f(X , Y , Z) over all triplets (X, Y , Z) where X, Y and Z belong to A, B and C respectively.\nOutput your sum for each test case modulo 1000000007.\n\n-----Input-----\n- The first line contains a single integer, T, which is the number of test cases. The description of each testcase follows:\n- The first line of each testcase contains 3 integers: p, q and r. These denote the lengths of A,B and C respectively. \n- The second line contains p integers, which are the elements of A\n- The third line contains q integers, which are the elements of B\n- The fourth line contains r integers, which are the elements of C\n\n-----Output-----\nOutput the required sum modulo 1000000007 for each test case in a new line.\n\n-----Constraints-----\n- 1 ≤ T ≤ 10 \n- 1 ≤ p, q, r ≤ 100000 \n- 1 ≤ every array element ≤ 1000000000\n\n-----Subtasks -----\n- Subtask #1 (30 points): 1 ≤ p,q,r ≤ 100 \n- Subtask #2 (70 points): 1 ≤ p,q,r ≤ 100000 \n\n-----Example : -----\nInput:\n1 \n3 1 3\n1 2 3\n5\n4 5 6\n\nOutput:\n399\n\n-----Explanation: -----\nAs there is only one choice for Y which equals to 5, to get a non-zero function value,we can choose any element for X from the set { 1 , 2 , 3 } and for Z from the set { 4 , 5 } \nSo triplets which give non-zero function values are: \n{ 1 , 5 , 4 } : ( 1 + 5 ) * ( 5 + 4 ) = 54 \n{ 1 , 5 , 5 } : ( 1 + 5 ) * ( 5 + 5 ) = 60 \n{ 2 , 5 , 4 } : ( 2 + 5 ) * ( 5 + 4 ) = 63 \n{ 2 , 5 , 5 } : ( 2 + 5 ) * ( 5 + 5 ) = 70 \n{ 3 , 5 , 4 } : ( 3 + 5 ) * ( 5 + 4 ) = 72 \n{ 3 , 5 , 5 } : ( 3 + 5 ) * ( 5 + 5 ) = 80 \nFinal answer : 54 + 60 + 63 + 70 + 72 + 80 = 399", "starter_code": "", "test_cases": {"inputs": ["1 \n3 1 3\n1 2 3\n5\n4 5 6\n\n"], "outputs": ["399"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "a14b9eb8311cbfb3c871167e42d9f898cc70c37d", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-00683", "original_id": null, "source": "apps", "domain": "code", "problem": "Chef loves lucky numbers. Everybody knows that lucky numbers are positive integers whose decimal representation contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.\n\nLet F(X) equals to the number of lucky digits in decimal representation of X. Chef wants to know the number of such integers X, that L ≤ X ≤ R and F(X) is a lucky number. Help him and calculate that number modulo 109+7.\n\n-----Input-----\nFirst line contains one integer T, the number of test cases. Each of the following T lines contains two space separated positive integers L and R.\n\n-----Output-----\nFor each of the T test cases print one integer, the number of such X, that L ≤ X ≤ R and F(X) is a lucky number, modulo 1000000007.\n\n-----Constraints-----\n\n1 ≤ T ≤ 10\n\n1 ≤ L ≤ R ≤ 101000\n\n-----Example-----\nInput:\n4\n1 100\n1 10000\n1 100000\n4444 4447\n\nOutput:\n0\n16\n640\n2\n\n-----Notes-----\nFirst test case: of course, any number of less than 4 digits can't contain lucky number of lucky digits, so the answer is 0.\n\nSecond test case: 16 required numbers are 4444 4447 4474 4477 4744 4747 4774 4777 7444 7447 7474 7477 7744 7747 7774 7777.\n\nThird test case: there are 640 required lucky numbers. Some of them are 4474, 14747, 41474, 77277, 44407, 74749.\n\nFourth test case: the only two required numbers are 4444 and 4447.", "starter_code": "", "test_cases": {"inputs": ["4\n1 100\n1 10000\n1 100000\n4444 4447\n\n"], "outputs": ["0\n16\n640\n2"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "dd8ddff590c9bdb2815918291b496a5737d94148", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-00688", "original_id": null, "source": "apps", "domain": "code", "problem": "Given an array $A$ of length $N$.\nWe have to find the $maximum$ sum of elements of the subarray between $two$ nearest occurrences of $same$ elements (excluding both).\nIf both the elements are $even$ then the total number of $even$ elements in that subarray should be $even$ then and then only we consider that subarray and if both the elements are $odd$ then the total number of $odd$ element in that subarray should be $odd$ then and then only we consider that subarray.\nIf the condition never matches print $0$.\n\n-----Input:-----\n- First line contains $T$, number of test cases. Then the test cases follow.\n- Each testcase consists of two lines: \nThe first line has $N$ : number of elements in the array and second-line has $N$ space separated integers: elements of the array.\n\n-----Output:-----\n- For each test case, output in a single line $maximum$ sum.\n\n-----Constraints-----\n- $1 \\leq T \\leq 10$\n- $3 \\leq N \\leq 2*10^5$\n- $1 \\leq A[i] \\leq 10^8$\n$NOTE $: Use of Fast Input Output is recommended.\n\n-----Sample Input:-----\n1\n10\n1 2 3 2 1 5 1 2 8 2\n\n-----Sample Output:-----\n7\n\n-----EXPLANATION:-----\nThe maximum sum is 7, between 1 at 1st position and 1 at 5th position i.e sum of 2,3,2", "starter_code": "", "test_cases": {"inputs": ["1\n10\n1 2 3 2 1 5 1 2 8 2"], "outputs": ["7"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "0d87fd06ade38a67527b74975baf44b241d6f6c3", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-00693", "original_id": null, "source": "apps", "domain": "code", "problem": "Chef has a string of size $N$ which consists only lowercase English alphabet. The chef doesn't like the consonant alphabet at all. So he is thinking of changing every single consonant alphabet to any vowel alphabet. There is some cost for performing this operation.\n- Number all alphabet [a,b,c,……,z] as [1,2,3,…..,26]\n- So if you want to change c to e then cost will be |e-c| = |5-3| = 2\nYou need the answer at what minimum cost chef can change every single consonant alphabet to any vowel alphabet. \n\n-----Input:-----\n- First-line will contain $T$, the number of test cases. Then the test cases follow. \n- Each test case contains of a single line of input, a string of lowercase alphabet. \n\n-----Output:-----\nFor each test case, output in a single line answer.\n\n-----Constraints-----\n- $1 \\leq T \\leq 100$\n- $1 \\leq |s| \\leq 10^2$\n\n-----Sample Input:-----\n2\naeiou\ndbcc \n\n-----Sample Output:-----\n0\n6\n\n-----EXPLANATION:-----\nIn the first test case, all characters are already vowel so we don't need to change.\nIn the second tect case\n|e-d|=|5-4|=1\n|a-b|=|1-2|=1\n|a-c|=|1-3|=2\n|a-c|=|1-3|=2\n1+1+2+2=6", "starter_code": "", "test_cases": {"inputs": ["2\naeiou\ndbcc"], "outputs": ["0\n6"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "15ba4155c872571c2fbc219228ad232f442d1eb1", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-00698", "original_id": null, "source": "apps", "domain": "code", "problem": "You are given an array with $N$ integers: $A[1], A[2], \\ldots, A[N]$ (where $N$ is even). You are allowed to permute the elements however you want. Say, after permuting the elements, you end up with the array $A'[1], A'[2], \\ldots, A'[N]$. Your goal is to maximize the following sum:\n|A′[1]−A′[2]| + |A′[3]−A′[4]| + ... + |A′[N−1]−A′[N]||A′[1]−A′[2]| + |A′[3]−A′[4]| + ... + |A′[N−1]−A′[N]|\n|A'[1] - A'[2]| \\ + \\ |A'[3] - A'[4]| \\ + \\ ... \\ + \\ |A'[N - 1] - A'[N]|\n\nHere, $|x|$ denotes the absolute value of $x$.\nYou have to print the maximum sum achievable.\n\n-----Input-----\n- The first line contains $T$, the number of test cases.\n- Each test case starts with an integer $N$ in the first line.\n- The second line of each test case contains $N$ space separated integers, denoting the values of array $A$.\n\n-----Output-----\nFor each test case, output the maximum sum achievable in a new line.\n\n-----Constraints-----\n- $1 \\le T \\le 10^5$\n- $1 \\le N \\le 10^5$\n- $N$ is even\n- $|A[i]| \\le 10^9$\n- Sum of $N$ over all test cases $\\le 2 * 10^5$\n\n-----Example Input 1-----\n1\n4\n1 -3 2 -3\n\n-----Example Output 1-----\n9\n\n-----Explanation 1-----\nThe original array is {$1, -3, 2, -3$}. Suppose you permute it and get the array {$2, 1, -3, -3$}. Then the corresponding sum would be $|2 - 1| \\ + \\ |-3 - (-3)| = 1 + 0 = 1$.\nBut suppose you permute it differently and get the array {$-3, 2, 1, -3$}. Then the corresponding sum would be $|-3 - 2| \\ + \\ |1 - (-3)| = 5 + 4 = 9$. You can check that you cannot do any better, and hence the answer is 9.", "starter_code": "", "test_cases": {"inputs": ["1\n4\n1 -3 2 -3"], "outputs": ["9"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "a83b87cae10eeae22bb766bc5fcf0c0400b3fd5c", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-00703", "original_id": null, "source": "apps", "domain": "code", "problem": "You are given a rooted tree on N vertices. The nodes are numbered from 1 to N, and Node 1 is the root. Each node u has an associated value attached to it: Au.\nFor each vertex v, we consider the path going upwards from v to the root. Suppose that path is v1, v2, .., vk, where v1 = v and vk = 1. The cost of any node on this path is equal to the minimum value among all the nodes to its left in the path sequence, including itself. That is, cost(vi) = min1 <= j <= i{Avj}. And the cost of the path is the sum of costs of all the nodes in it.\nFor every node in the tree, find the cost of the path from that node to the root.\n\n-----Input-----\n- The first line of the input contains a single integer, N, denoting the number of nodes in the tree.\n- The next line contains N-1 integers, the i-th of which denotes the parent of node i+1.\n- The next line contains N integers, the i-th of which denotes Ai.\n\n-----Output-----\nOutput a single line containing N integers, the i-th of which should be the cost of the path from node i to the root.\n\n-----Constraints-----\n- 1 ≤ N ≤ 100,000\n- -1,000,000,000 ≤ Av ≤ 1,000,000,000\n\n-----Subtasks-----\n- Subtask #1 (30 points): 1 ≤ N ≤ 2000\n- Subtask #2 (70 points): Original constraints.\n\n-----Example-----\nInput:\n8\n1 1 1 1 5 8 6\n1 2 3 4 5 15 70 10\n\nOutput: \n1 3 4 5 6 21 96 26\n\n-----Explanation-----\nFor example, take a look at the path from vertex 7: The path is 7 -> 8 -> 6 -> 5 -> 1.\nCost(7) has no choice but to be A7. So Cost(7) = 70.\nCost(8) will be minimum of A7 and A8, which turns out to be A8. So Cost(8) = 10.\nCost(6) = minimum {A7, A8, A6} = minimum {70, 10, 15} = 10.\nCost(5) = minimum {70, 10, 15, 5} = 5.\nCost(1) = minimum {70, 10, 15, 5, 1} = 1. \nSo, the cost of the path from 7 to the root is 70 + 10 + 10 + 5 + 1 = 96.", "starter_code": "", "test_cases": {"inputs": ["8\n1 1 1 1 5 8 6\n1 2 3 4 5 15 70 10"], "outputs": ["1 3 4 5 6 21 96 26"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "8eace21d7a809b0a1951d69b3b91771d64718818", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-00708", "original_id": null, "source": "apps", "domain": "code", "problem": "Mr. Pr and Ms. Ad are at $a$ and $b$ respectively on an infinite number line. Mr. Pr wants to meet Ms. Ad.\nMr. Pr can choose to move $c$ or $d$ units in 1 second. If Mr. Pr moves $c$ units then Ms. Ad will move $d$ units and vice versa. (Both of them always moved in positive x-direction)\nYou have to determine if Mr. Pr can meet with Ms. Ad after some integral amount of time, given that Mr. Pr chooses optimally. Note that meeting after a fractional amount of time does not count.\n\n-----Input:-----\n- First line will contain $T$, number of testcases. Then the testcases follow. \n- Each testcase contains four space separated integers, $a$, $b$, $c$, and $d$.\n\n-----Output:-----\n- For each test case, output a single line containing \"YES\" if Mr. Pr meets with Ms. Ad, otherwise \"NO\".\n\n-----Constraints-----\n- $1 \\leq T \\leq 10^5$\n- $1 \\leq a,b,c,d \\leq 10^9$\n\n-----Sample Input:-----\n2\n3 4 1 2\n10 20 3 7\n\n-----Sample Output:-----\nYES\nNO\n\n-----Explanation:-----\nIn the first test case, Mr. Pr will move 2 units in the first second and Ms. Ad moves 1 unit simultaneously and they meet. \nIn the second test case, it is impossible to meet (fractional time is not allowed).", "starter_code": "", "test_cases": {"inputs": ["2\n3 4 1 2\n10 20 3 7"], "outputs": ["YES\nNO"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "f856f66f79a1acafb2f2cd9352a7b5d7345d8e85", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-00713", "original_id": null, "source": "apps", "domain": "code", "problem": "Jem is famous for his laziness at school. He always leaves things to last minute. Now Jem has N problems in the assignment of \"Advanced topics in algorithm\" class to solved. The assignment is due tomorrow and as you may guess he hasn't touch any of the problems. Fortunately he got a plan as always.\n\nThe first step will be buying a pack of Red Bull and then to work as hard as he can. Here is how he is going to spend the remaining time:\n\nJem will not take a break until he finishes at least half of the remaining problems. Formally, if N is even then he will take he first break after finishing N / 2 problems. If N is odd then the break will be after he done (N + 1) / 2 problems. Each of his break will last for B minutes. Initially, he takes M minutes in solving a problem, after each break he will take twice more time in solving a problem, i.e. 2 * M minutes per problem after the first break.\n\nJem will start working soon and ask you to help him calculate how much time it will take until he finish the last problem!\n\n-----Input-----\n\nThe first line contains a single integer T represents the number of test cases in the input.\nEach line in the next T line contains three integers N, B and M represents a test case.\n\n-----Output-----\n\nFor each test case output a single line containing an integer represent how much time Jem will need (in minutes).\n\n-----Constraints-----\n- 1 ≤ T ≤ 100\n- 1 ≤ N, B, M ≤ 108\n\n-----Example-----\nInput:\n2\n9 1 2\n123456 123456 123456\n\nOutput:\n45\n131351258112\n\n-----Explanation-----\n\nIn the first test case, Jem will proceed as below:\n\n- Initially, Jem has 9 problems to solve. since it is an odd number, Jem will finish the first (9 + 1) / 2 = 5 problems with speed of 2 minutes/problem.\n- After that, Jem takes 1 minute break.\n- Now he has 4 problems to solve, which is an even number, so Jem will solve the next 4 / 2 = 2 problems. his speed after the first break has now became 4 minutes/problem.\n\n- Again, he takes a 1 minute break.\n- he has now 2 problems left so he do one more problem in 8 minutes.\n- He takes 1 minute break.\n- he solves the last problem in 16 minutes.\n\nSo, Jem will need time = 5 × 2 + 1 + 2 × 4 + 1 + 8 + 1 + 16 = 45", "starter_code": "", "test_cases": {"inputs": ["2\n9 1 2\n123456 123456 123456"], "outputs": ["45\n131351258112"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "c1a38025ac7647819a366b953893d6f110762e30", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-00718", "original_id": null, "source": "apps", "domain": "code", "problem": "Back in 2015, Usain Bolt announced that he'll be retiring after the 2017 World Championship. Though his final season did not end gloriously, we all know that he is a true legend and we witnessed his peak during 2008 - 2013. \nPost retirement, Usain Bolt is still leading an adventurous life. He's exploring the unexplored parts of the globe. But sometimes he gets bored, and reads questions asked about him on Quora. One such question he read was, \"Who would win a race between Usain Bolt and a tiger if the race is on a straight line track and the tiger is $distancetoBolt$ meters behind Bolt? The finishing point is $finish$ meters away from Bolt's starting position. The tiger starts with an initial speed of $0$ $meter/second$, and will accelerate itself with $tigerAccelaration$ $m/s^2$. Bolt can run with a constant speed of $boltSpeed$ $m/s$ from start to finish. Given these values, find out who will win the race - Bolt or the tiger? \"\nNote that Bolt will win the race if and only if he touches the finishing line before the tiger touches it. If both of them finish together, the tiger is announced as the winner since Bolt was given an initial advantage. See the figure below for more clarity.\n\nSince Bolt was busy practicing in the tracks during his Physics school classes, he is asking for your help to solve the question. Can you please help him?\nHe just remembers two formulae from the class, and thinks that they will be useful to you:\n$Displacement (S) $ = $ut$ +$ (1/2)at^2$ where $u$ is the initial velocity , #$ $is the acceleration and $t$ is the time taken.\n$Velocity$ = $Displacement /Time$\n\n-----Input:-----\n- The first line will contain $T$, the number of testcases. Then the description of each test case follow. \n- Each test case contains 4 integers $finish, distancetoBolt, tigerAccelaration, boltSpeed$. \n\n-----Output:-----\nFor each testcase, output in a single line, the word \"Bolt\" or \"Tiger\" without quotes, depending on whether Bolt wins or the tiger wins.\n\n-----Constraints-----\n- $1 \\leq T \\leq 100000$\n- $1 \\leq finish\\leq 10^5$\n- $1 \\leq distancetoBolt\\leq 10^5$\n- $1 \\leq tigerAccelaration\\leq 10^5$\n- $1 \\leq boltSpeed\\leq 10^5$\n\n-----Sample Input:-----\n2\n10 100 10 10\n100 10 5 10\n\n-----Sample Output:-----\nBolt\nTiger", "starter_code": "", "test_cases": {"inputs": ["2\n10 100 10 10\n100 10 5 10"], "outputs": ["Bolt\nTiger"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "a9df6998f97a4e742c25d95210714ff70abca44d", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-00723", "original_id": null, "source": "apps", "domain": "code", "problem": "Supermarket Dilemma\nChef is going to local supermarket but there appears a problem with chef as he is confused about which Supermarket he can choose to go as he is not able to decide whether he can park his car in that particular supermarket’s parking lot or not! There are N parking slots in each supermarket which are marked from 1,2,3,4…N.\nChef will go to that supermarket in which he gets to know that there is exactly 1 empty parking slot having number K that exactly divides the total number of slots (N) available in that supermarket.\nThe 1st and Nth parking slots are always occupied by the staff of every supermarket. Rest parking slots are empty as Chef is arriving early morning to the supermarket.\nNow Chef needs your help in determining whether he can park his car in a supermarket or not!\nInput\nThe first line contains the single integer N showing how many supermarkets are there for the chef to choose.\nThe next N lines contain a number ‘ai’ which represents the total parking slots available in ith supermarket.\nOutput\nYou need to output \"YES\" (without the quotes), if a supermarket can be reached by Chef, and \"NO\" (without the quotes), if it can't.\nConstraints\n1<=N<=10^5\n1<=ai<=10^12\nSample Input :\n2\n4\n5\nSample Output :\nYES\nNO", "starter_code": "", "test_cases": {"inputs": ["2\n4\n5"], "outputs": ["YES\nNO"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "3c40dc839f2a1aac9bafe896d2ef7bf5611383df", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-00728", "original_id": null, "source": "apps", "domain": "code", "problem": "You are given an N × N grid initially filled by zeros. Let the rows and columns of the grid be numbered from 1 to N, inclusive. There are two types of operations can be applied to the grid:\n\n- RowAdd R X: all numbers in the row R should be increased by X.\n- ColAdd C X: all numbers in the column C should be increased by X.\n\nNow after performing the sequence of such operations you need to find the maximum element in the grid.\n\n-----Input-----\nThe first line of the input contains two space separated integers N and Q denoting the size of the grid and the number of performed operations respectively. Each of the following Q lines describe an operation in the format described above.\n\n-----Output-----\nOutput a single line containing the maximum number at the grid after performing all the operations.\n\n-----Constraints-----\n- 1 ≤ N ≤ 314159\n- 1 ≤ Q ≤ 314159\n- 1 ≤ X ≤ 3141\n- 1 ≤ R, C ≤ N\n\n-----Example-----\nInput:\n2 4\nRowAdd 1 3\nColAdd 2 1\nColAdd 1 4\nRowAdd 2 1\n\nOutput:\n7\n\n-----Explanation-----\nThe grid changes as follows:\n00 33 34 74 74\n00 00 01 41 52\n\nThe maximum number in the final grid is 7.", "starter_code": "", "test_cases": {"inputs": ["2 4\nRowAdd 1 3\nColAdd 2 1\nColAdd 1 4\nRowAdd 2 1"], "outputs": ["7"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "5ebb37170abb5eabf03c92214bf8868786c66dcc", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-00733", "original_id": null, "source": "apps", "domain": "code", "problem": "Takaki Tono is a Computer Programmer in Tokyo. His boss at work shows him an online puzzle, which if solved would earn the solver a full expense paid trip to Los Angeles, California. Takaki really wants to solve this, as the love of his life, Akari, lives in Los Angeles and he hasn't met her since four years. Upon reading the puzzle he realizes that it is a query based problem. The problem is as follows :-\n\nYou are given a Tree T with N nodes numbered from 1 to N, with each node numbered z having a positive integer Az written on it. This integer denotes the value of the node. You have to process Q queries, of the following forms :- \n1) C x y : Report the closest two values in the unique path from x to y i.e compute min(|Ap - Aq|) where p and q are two distinct nodes on the unique path from x to y. \n\n2) F x y : Report the farthest two values in the unique path from x to y i.e. compute max(|Ap - Aq|) where p and q are two distinct nodes on the unique path from x to y.\n\nIt is also mentioned that x is not equal to y in any query and that no two nodes have the same value printed on them. Also, |x| denotes the absolute value of x. \n\nTakaki is perplexed and requires your help to solve this task? Can you help him out?\n\n-----Input-----\nThe first line of the input contains an integer N denoting the number of nodes in tree T. \nThe second line comprises N space separated integers denoting A, where the i-th integer denotes Ai. \nThe next N-1 lines each comprise two space separated integers u and v, denoting that node u and node v\nare connected by an edge. It is guaranteed that the final graph will be a connected tree.\nThe next line contains a single integer Q, denoting number of queries. \nThe next Q lines comprise the queries. Each such line is of the format C x y or F x y. \n\n-----Output-----\nFor each query, print the required output as mentioned above. \n\n-----Constraints-----\n- 2 ≤ N ≤ 35000\n- 1 ≤ Ai ≤ 109\n- 1 ≤ Q ≤ 35000\n- 1 ≤ u, v ≤ N\n- No two nodes have the same value printed on them.\n- x is not equal to y in any query.\n\n-----Subtasks-----\n\n-----Subtasks-----Subtask #1 (15 points)\n- N, Q ≤ 1000Subtask #2 (20 points)\n- Only Type F queries are present.Subtask #3 (65 points)\n- Original constraints\n\n-----Example-----\nInput:5\n1 2 7 4 5\n1 2\n2 3\n2 4\n2 5\n7\nC 1 5\nF 1 5\nC 2 4\nC 1 2\nF 1 3\nF 3 4\nF 2 4\n\nOutput:1\n4\n2\n1\n6\n5\n2\n\n-----Explanation-----\nGiven below is the tree corresponding to the sample input. Each node has two numbers written in it. \nThe first number represents the node index and the second number indicates node value.", "starter_code": "", "test_cases": {"inputs": ["5\n1 2 7 4 5\n1 2\n2 3\n2 4\n2 5\n7\nC 1 5\nF 1 5\nC 2 4\nC 1 2\nF 1 3\nF 3 4\nF 2 4"], "outputs": ["1\n4\n2\n1\n6\n5\n2"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "bd42b49bad542ee895a1027c88719d5517a469e8", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-00738", "original_id": null, "source": "apps", "domain": "code", "problem": "Chef is a really nice and respectful person, in sharp contrast to his little brother, who is a very nasty and disrespectful person. Chef always sends messages to his friends in all small letters, whereas the little brother sends messages in all capital letters.\nYou just received a message given by a string s. You don't know whether this message is sent by Chef or his brother. Also, the communication channel through which you received the message is erroneous and hence can flip a letter from uppercase to lowercase or vice versa. However, you know that this channel can make at most K such flips.\nDetermine whether the message could have been sent only by Chef, only by the little brother, by both or by none.\n\n-----Input-----\n\n- The first line of the input contains a single integer T denoting the number of test cases. The description of T test cases follows.\n- The first line of each test case contains two space-separated integers N and K denoting the length of the string s and the maximum number of flips that the erroneous channel can make.\n- The second line contains a single string s denoting the message you received.\n\n-----Output-----\nFor each test case, output a single line containing one string — \"chef\", \"brother\", \"both\" or \"none\".\n\n-----Constraints-----\n- 1 ≤ T ≤ 1000\n- 1 ≤ N ≤ 100\n- 0 ≤ K ≤ N\n- s consists only of (lowercase and uppercase) English letters\n\n-----Example-----\nInput\n\n4\n5 1\nfrauD\n5 1\nFRAUD\n4 4\nLife\n10 4\nsTRAWBerry\n\nOutput\n\nchef\nbrother\nboth\nnone\n\n-----Explanation-----\nExample case 1: Only one flip is possible. So it is possible that Chef sent \"fraud\" and the channel flipped the last character to get \"frauD\". However, it is not possible for the brother to have sent \"FRAUD\", because then it would need 4 flips. Hence the answer is \"chef\".\nExample case 2: Only one flip is possible. So it is possible that the brother sent \"FRAUD\" and the channel didn't flip anything. However, it is not possible for Chef to have sent \"fraud\", because then it would need 5 flips. Hence the answer is \"brother\".\nExample case 3: Four flips are allowed. It is possible that Chef sent \"life\" and the channel flipped the first character to get \"Life\". It is also possible that the brother sent \"LIFE\" and the channel flipped the last three characters to get \"Life\". Hence the answer is \"both\".\nExample case 4: Four flips are allowed. It is not possible that Chef sent \"strawberry\", because it would need five flips to get \"sTRAWBerry\". It is also not possible that the brother sent \"STRAWBERRY\", because that would also need five flips. Hence the answer is \"none\".", "starter_code": "", "test_cases": {"inputs": ["4\n5 1\nfrauD\n5 1\nFRAUD\n4 4\nLife\n10 4\nsTRAWBerry"], "outputs": ["chef\nbrother\nboth\nnone"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "c4d86f6fe693b55ff8aaa30d5e04c583170d6941", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-00743", "original_id": null, "source": "apps", "domain": "code", "problem": "Chef recently started working at ABC corporation. Let's number weekdays (Monday through Friday) by integers $1$ through $5$. For each valid $i$, the number of hours Chef spent working at the office on weekday $i$ was $A_i$.\nUnfortunately, due to the COVID-19 pandemic, Chef started working from home and his productivity decreased by a considerable amount. As per Chef's analysis, $1$ hour of work done at the office is equivalent to $P$ hours of work done at home.\nNow, in order to complete his work properly, Chef has to spend more hours working from home, possibly at the cost of other things like sleep. However, he does not have to do the same work on each day as he would have in the office ― for each weekday, he can start the work for this day on an earlier day and/or complete it on a later day. The only requirement is that his work does not pile up indefinitely, i.e. he can complete his work for each week during the same week. One day has $24$ hours.\nIf Chef is unable to complete his work for a week during those five weekdays, then he has to work during the weekend too. Chef wishes to know whether he has to work on weekends or if he can complete his work by working only on weekdays. Help him answer that question. (It is possible that Chef would be unable to finish his work even if he worked all the time, but he does not want to know about that.)\n\n-----Input-----\n- The first line of the input contains a single integer $T$ denoting the number of test cases. The description of $T$ test cases follows.\n- The first and only line of each test case contains six space-separated integers $A_1$, $A_2$, $A_3$, $A_4$, $A_5$ and $P$.\n\n-----Output-----\nFor each test case, print a single line containing the string \"Yes\" if Chef has to work on weekends or \"No\" otherwise (without quotes).\n\n-----Constraints-----\n- $1 \\le T \\le 1,000$\n- $0 \\le A_i \\le 24$ for each valid $i$\n- $1 \\le P \\le 24$\n\n-----Subtasks-----\nSubtask #1 (100 points): original constraints\n\n-----Example Input-----\n2\n14 10 12 6 18 2\n10 10 10 10 10 3\n\n-----Example Output-----\nNo\nYes\n\n-----Explanation-----\nExample case 1: Here, $P=2$, so the number of hours Chef has to work from home to handle his workload for days $1$ through $5$ is $[28,20,24,12,36]$. If he works for full $24$ hours on each of the five weekdays, he finishes all the work, so he does not have to work on weekends.\nExample case 2: No matter what Chef does, he will have to work on weekends.", "starter_code": "", "test_cases": {"inputs": ["2\n14 10 12 6 18 2\n10 10 10 10 10 3"], "outputs": ["No\nYes"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "bb10888471751c3db0ea2ab0656009a2184db3c7", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-00748", "original_id": null, "source": "apps", "domain": "code", "problem": "There are $N$ cities on a circle, numbered $1$ through $N$. For each $i$ ($1 \\le i \\le N-1$), cities $i$ and $i+1$ are directly connected by a bidirectional road with length $A_i$, and cities $N$ and $1$ are also directly connected by a bidirectional road with length $A_N$. However, we do not know the lengths of some roads.\nFor each city $i$, we do know that it has an opposite city — formally, there is a city $j \\neq i$ such that the clockwise distance between cities $i$ and $j$ is equal to the counterclockwise distance between these cities.\nPlease find the lengths of all roads in such a way that the above condition is satisfied and the sum of lengths of all roads is minimised.\n\n-----Input-----\n- The first line of the input contains a single integer $T$ denoting the number of test cases. The description of $T$ test cases follows.\n- The first line of the input contains a single integer $N$.\n- The second line contains $N$ space-separated integers $A_1, A_2, \\dots, A_N$. For each valid $i$, $A_i = -1$ denotes that the length of road $i$ is unknown.\n\n-----Output-----\nFor each test case, print a line containing the string \"NO\" if there is no solution or \"YES\" otherwise. If a solution exists, print a second line containing $N$ space-separated positive integers — the lengths of all roads in your solution. Each of these integers should be $\\le 10^9$. If there are multiple solutions, you may print any one.\n\n-----Constraints-----\n- $1 \\le T \\le 100$\n- $3 \\le N \\le 10^5$\n- $1 \\le A_i \\le 10^9$ or $A_i = -1$ for each valid $i$\n- the sum of $N$ for all test cases does not exceed $3\\cdot 10^5$\n\n-----Subtasks-----\nSubtask #1 (10 points): $N \\le 4$\nSubtask #2 (20 points): $A_i = \\pm 1$ for each valid $i$\nSubtask #3 (70 points): original constraints\n\n-----Example Input-----\n4\n4\n1 1 1 1\n4\n1 1 1 2\n4\n1 -1 -1 4\n4\n1 -1 2 -1\n\n-----Example Output-----\nYES\n1 1 1 1\nNO\nYES\n1 4 1 4\nNO", "starter_code": "", "test_cases": {"inputs": ["4\n4\n1 1 1 1\n4\n1 1 1 2\n4\n1 -1 -1 4\n4\n1 -1 2 -1"], "outputs": ["YES\n1 1 1 1\nNO\nYES\n1 4 1 4\nNO"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "c3cfa8cde89800b4672270c7e7c1953a4f8111ac", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-00753", "original_id": null, "source": "apps", "domain": "code", "problem": "Chef has some numbers. His girlfriend Chefina feels good when chef gives her a particular pattern number also called as Armstrong number.\nArmstrong number is a number whose sum of its all individual digit raise to the power of the number of digit in that number is equal to that number itself\neg.. 153 = 1^3 + 5^3 + 3^3 (153 is an Armstrong number)\n1634 = 1^4 + 6^4 + 3^4 + 4^4 (1634 is an Armstrong number)\nAs a love guru of chef you have to help chef to find Armstrong numbers Among the numbers which chef has initially so that Chefina feels good\n\n-----Input:-----\nFirst line will contain a positive Integer $T$ which is the number of testcases\nNext $T$ lines follows an Integer $N$.\n\n-----Output:-----\nFor Every n You have to print \"FEELS GOOD\" without qoutes if it is an armstrong number otherwise Print \"FEELS BAD\" without quotes\n\n-----Constraints-----\n- $1 \\leq T \\leq 10$\n- $2 \\leq N \\leq 10^6$\n\n-----Sample Input:-----\n3\n153\n11\n1634\n\n-----Sample Output:-----\nFEELS GOOD\nFEELS BAD\nFEELS GOOD\n\n-----EXPLANATION:-----\nFor test case 1 --> 153 = 1^3 + 5^3 + 3^3 (153 is an armstrong number)", "starter_code": "", "test_cases": {"inputs": ["3\n153\n11\n1634"], "outputs": ["FEELS GOOD\nFEELS BAD\nFEELS GOOD"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "7c0abd2502d24eb6e63be9461903eed166dab845", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-00758", "original_id": null, "source": "apps", "domain": "code", "problem": "Ada is playing pawn chess with Suzumo.\nPawn chess is played on a long board with N$N$ squares in one row. Initially, some of the squares contain pawns.\nNote that the colours of the squares and pawns do not matter in this game, but otherwise, the standard chess rules apply:\n- no two pawns can occupy the same square at the same time\n- a pawn cannot jump over another pawn (they are no knights!), i.e. if there is a pawn at square i$i$, then it can only be moved to square i−2$i-2$ if squares i−1$i-1$ and i−2$i-2$ are empty\n- pawns cannot move outside of the board (outs are forbidden)\nThe players alternate turns; as usual, Ada plays first. In each turn, the current player must choose a pawn and move it either one or two squares to the left of its current position. The player that cannot make a move loses.\nCan Ada always beat Suzumo? Remember that Ada is a chess grandmaster, so she always plays optimally.\n\n-----Input-----\n- The first line of the input contains a single integer T$T$ denoting the number of test cases. The description of T$T$ test cases follows.\n- The first and only line of each test case contains a single string S$S$ with length N$N$ describing the initial board from left to right. An empty square and a square containing a pawn are denoted by the characters '.' and 'P' respectively.\n\n-----Output-----\nFor each test case, print a single line containing the string \"Yes\" if Ada wins the game or \"No\" otherwise (without quotes).\n\n-----Constraints-----\n- 1≤T≤500$1 \\le T \\le 500$\n- 2≤N≤128$2 \\le N \\le 128$\n- S$S$ contains only characters '.' and 'P'\n\n-----Example Input-----\n1\n..P.P\n\n-----Example Output-----\nYes\n\n-----Explanation-----\nExample case 1: Ada can move the first pawn two squares to the left; the board after this move looks like\nP...P\n\nand now, Suzumo can only move the second pawn. If he moves it one square to the left, Ada will move it two squares to the left on her next move, and if he moves it two squares to the left, Ada will move it one square to the left, so the board after Ada's next move will look like\nPP...\n\nand Suzumo cannot make any move here.", "starter_code": "", "test_cases": {"inputs": ["1\n..P.P"], "outputs": ["Yes"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "90fcf6241a5b9c392c1624667c023d693fbd86c0", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-00763", "original_id": null, "source": "apps", "domain": "code", "problem": "Chef wants to gift pairs to his friends this new year. But his friends like good pairs\nonly.\nA pair (a , b) is called a good pair if 1 <= a < b <= N such that GCD(a*b , P) = 1.\nSince Chef is busy in preparation for the party, he wants your help to find all the\ngood pairs.\n—————————————————————————————————————\nINPUT\n• The first line of the input contains a single integer T.\n• The first and only line of each test case contain two integer N,P.\n————————————————————————————————————————\nOUTPUT\nFor each test case, print a single line containing one integer — the total number of good\npairs\n————————————————————————————————————————\nCONSTRAINTS\n• 1 ≤ T≤ 50\n• 2 ≤ N,P ≤10^5\n—————————————————————————————————————\nExample Input\n2\n2 3\n3 3\n————————————————————————————————————————\nExample Output\n1\n1", "starter_code": "", "test_cases": {"inputs": ["2\n2 3\n3 3\n————————————————————————————————————————"], "outputs": ["1\n1"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "8bbc3adc15e335a9acf058da311662d6fe25128f", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-00768", "original_id": null, "source": "apps", "domain": "code", "problem": "You are given positive integers $N$ and $D$. You may perform operations of the following two types:\n- add $D$ to $N$, i.e. change $N$ to $N+D$\n- change $N$ to $\\mathop{\\mathrm{digitsum}}(N)$\nHere, $\\mathop{\\mathrm{digitsum}}(x)$ is the sum of decimal digits of $x$. For example, $\\mathop{\\mathrm{digitsum}}(123)=1+2+3=6$, $\\mathop{\\mathrm{digitsum}}(100)=1+0+0=1$, $\\mathop{\\mathrm{digitsum}}(365)=3+6+5=14$.\nYou may perform any number of operations (including zero) in any order. Please find the minimum obtainable value of $N$ and the minimum number of operations required to obtain this value.\n\n-----Input-----\n- The first line of the input contains a single integer $T$ denoting the number of test cases. The description of $T$ test cases follows.\n- The first and only line of each test case contains two space-separated integers $N$ and $D$.\n\n-----Output-----\nFor each test case, print a single line containing two space-separated integers — the minimum value of $N$ and the minimum required number of operations.\n\n-----Constraints-----\n- $1 \\le T \\le 10$\n- $1 \\le N, D \\le 10^{10}$\n\n-----Subtasks-----\nSubtask #1 (30 points): $1 \\le N, D \\le 100$\nSubtask #2 (70 points): original constraints\n\n-----Example Input-----\n3\n2 1\n9 3\n11 13\n\n-----Example Output-----\n1 9\n3 2\n1 4\n\n-----Explanation-----\nExample case 1: The value $N=1$ can be achieved by 8 successive \"add\" operations (changing $N$ to $10$) and one \"digit-sum\" operation.\nExample case 2: You can prove that you cannot obtain $N=1$ and $N=2$, and you can obtain $N=3$.\nThe value $N=3$ can be achieved by one \"add\" and one \"digitsum\" operation, changing $9$ to $12$ and $12$ to $3$. \nExample case 3: $N=1$ can be achieved by operations \"add\", \"add\", \"digitsum\", \"digitsum\": $11 \\rightarrow 24 \\rightarrow 37 \\rightarrow 10 \\rightarrow 1$.", "starter_code": "", "test_cases": {"inputs": ["3\n2 1\n9 3\n11 13\n"], "outputs": ["1 9\n3 2\n1 4"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "d3bb8e72791369533e5041533ecf876a1d57a297", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-00773", "original_id": null, "source": "apps", "domain": "code", "problem": "There is a popular apps named “Exbook” like “Facebook”. To sign up in this app , You have to make a strong password with more than 3 digits and less than 10 digits . But I am a pro hacker and so I make a Exbook hacking site . You need to login in this site to hack exbook account and then you will get a portal. You can give any user exbook login link using this site and when anyone login into exbook using your link ,you can see his/her password .\nBut I made a mistake and so you cannot find original password in your portal . The portal showing you by adding two in every digit . So , now you have to find out the original password of an user if I give you the password which is showing in your portal .\n\n-----Input:-----\nThe first line contains a single integer t (1 ≤ t ≤ 1000) — the number of test cases.\nThe first line of each test case contains a single integer n which is showing in your portal . Mind it , every digit of n is greater than one .\n\n-----Output:-----\nPrint , original password of user .\n\n-----Sample Input:-----\n2\n3527\n47269\n\n-----Sample Output:-----\n1305\n25047", "starter_code": "", "test_cases": {"inputs": ["2\n3527\n47269"], "outputs": ["1305\n25047"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "19b8efdf476a305e9dfac4dfec89edbddc2dee90", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-00778", "original_id": null, "source": "apps", "domain": "code", "problem": "Write a program to find the remainder when an integer A is divided by an integer B.\n\n-----Input-----\n\nThe first line contains an integer T, the total number of test cases. Then T lines follow, each line contains two Integers A and B. \n\n-----Output-----\nFor each test case, find the remainder when A is divided by B, and display it in a new line.\n\n-----Constraints-----\n- 1 ≤ T ≤ 1000\n- 1 ≤ A,B ≤ 10000\n\n-----Example-----\nInput\n3 \n1 2\n100 200\n40 15\n\nOutput\n1\n100\n10", "starter_code": "", "test_cases": {"inputs": ["3\n1 2\n100 200\n40 15"], "outputs": ["1\n100\n10"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "602b9e9c6c1d0d8abb4b4a211c680a8dfbd02ca2", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-00783", "original_id": null, "source": "apps", "domain": "code", "problem": "Shivam is the youngest programmer in the world, he is just 12 years old. Shivam is learning programming and today he is writing his first program. \n\nProgram is very simple, Given two integers A and B, write a program to add these two numbers.\n\n-----Input-----\n\nThe first line contains an integer T, the total number of test cases. Then follow T lines, each line contains two Integers A and B. \n\n-----Output-----\nFor each test case, add A and B and display it in a new line.\n\n-----Constraints-----\n- 1 ≤ T ≤ 1000\n- 0 ≤ A,B ≤ 10000\n\n-----Example-----\nInput\n3 \n1 2\n100 200\n10 40\n\nOutput\n3\n300\n50", "starter_code": "", "test_cases": {"inputs": ["3\n1 2\n100 200\n10 40"], "outputs": ["3\n300\n50"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "c4c200cf959e8e3d9938e9256de2d0fb64d66d79", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-00788", "original_id": null, "source": "apps", "domain": "code", "problem": "Chef is making Window frames for his new office, for this he has n wooden Logs whose lengths are l1, l2, … ln respectively. Chef Doesn’t want to break any logs or Stick 2 or more logs together.\nTo make a h × w Window Frame, he needs two Logs with lengths equal h and two with length . \nThe Chef wants as much sunlight in as possible and for it he has decided to make from the available logs as many frames as possible. Help him in finding the number of window Frames that he can make. \nNote : Chef do not need to use all the logs\nInput:\nThe first line of the input contains a single integer T denoting the number of test cases. The description of each test case follows :.\nThe first line of each test case contains a single integer n the number of wooden logs. \nThe second line contains n space-separated integers l1,l2,l3….ln The length of each wooden log\nOutput: \nThe only line in Output Contains single Integer denoting the maximum possible number of Wooden Frames.\nConstraints:\n1 ≤ T ≤ 10\n1 ≤ n ≤ 100\n1 ≤ li ≤ 10000\nExample Input:\n2\n4\n1 2 1 2\n8\n1 2 1 3 4 1 5 6\nExample Output:\n1\n0\nExplanation :\nFirst Case : We can build a frame of dimension 1x2 as two logs of each dimension are available.\nSecond Case : We can’t build any Frame as no logs of length except 1 have more than one piece.", "starter_code": "", "test_cases": {"inputs": ["2\n4\n1 2 1 2\n8\n1 2 1 3 4 1 5 6"], "outputs": ["1\n0"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "c68d25e71fadc6586437215ca40dc33edee82b38", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-00793", "original_id": null, "source": "apps", "domain": "code", "problem": "A spy needs your help to encrypt a 5 letter message. \nTo encrypt the message the following steps are need to be done:\n1)Each letter of the message will be converted to it's equivalent number (i.e A=0, B=1,..Z=25) \n2)98, 57, 31, 45, 46 are the 5 numbers in the key.\n3)Add the equivalent number of the first letter of the message to the first number of the key, then the equivalent number of the second letter of the message to the second number of the key and so on.\n4)Take modulo 26 of the sum of each expression.\n5)Convert the newly obtained numbers into it's equivalent letters (i.e 0=A, 1=B,…25=Z)\nPrint the final encrypted string.\nNote: It is guaranteed that the given string only contains Only Upper-case Latin Letters.\n\n-----Input:-----\n- The first line of the input contains a single Integer $T$. $T$ denoting the number of testcases, description of each testcases contains.\n- The first line of the each testcase contains a single string $S$. $S$ denoting the string which you need to encrypt\n\n-----Output:-----\n- For each test case, print encypted string i.e result of above operation.\nNote: Each testcase output must be printed on new line\n\n-----Constraints:-----\n- $1 \\leq T \\leq 100$\n- $1 \\leq S \\leq 5$\n\n-----Sample Input:-----\n2\nHELLO\nHELL\n\n-----Sample Output:-----\nBJQEI\nBJQE\n\n-----Explanation:-----\n- For 1st Testcase : The conversion of \"HELLO\" to its equivalent number will be 7, 4, 11, 11, 14 respectively.\nThen we add each equivalent number of the message with corresponding number in the key:\n7 + 98 = 105\n4 + 57 = 61 \n11 + 31 = 42 \n11 + 45 = 56\n14 + 46 = 60\nFurther we take the sum:\n105 modulo 26 = 1\n61 modulo 26 = 9\n42 modulo 26 = 16\n56 modulo 26 = 4\n60 modulo 26 = 8 \nFinally, convert the newly obtained numbers into it's equivalent letters:\nB\nJ\nQ\nE\nI\nPrint the final string:\nBJQEI", "starter_code": "", "test_cases": {"inputs": ["2\nHELLO\nHELL"], "outputs": ["BJQEI\nBJQE"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "7f7f26fdfe1f78405c9ffa501d452952efdd3566", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-00798", "original_id": null, "source": "apps", "domain": "code", "problem": "The garden has a tree with too many leaves on it and gardner wants to cut the unwanted leaves. This is a rooted tree, where a node $v$ is called parent of another node $u$, if there exists a directed edge from $v$ to $u$. Leaf node is a node with no outgoing edges.\nGardner cuts the tree in a peculiar way:\n- For each parent node(which has a valid leaf node attached to it), he cuts $x$ leaf nodes, such that $x$ is a multiple of 3.\nExample : If a parent node has 7 leaf nodes, 6 leaf nodes will be cut and 1 will be left.\n- If a parent has all its leaf nodes cut, only then the parent node itself becomes a new leaf node. If new leaf nodes are created, Gardner repeats step 1 until he can cut no more leaf nodes.\nAfter completing all operations, gardner wants to know the minimum number of nodes left on the tree.\n\nIt is guaranteed that the given input is a rooted tree.\nThe root of the tree is vertex 1.\n\n-----Input:-----\n- First line will contain $T$, number of testcases. Then the testcases follow. \n- First line of each testcase contains an integer $n$, the number of vertices in the tree. \n- Second line of each testcase contains array $A$ of size $n-1$, where $A_{i}(1≤i≤n-1)$, is the index of the parent of the $(i+1)^{th}$ vertex. \n\n-----Output:-----\nFor each testcase, output single integer, the number of nodes finally left on the tree. \n\n-----Constraints-----\n- $1 \\leq T \\leq 10$\n- $2 \\leq n \\leq 10^5$ \n- $1 \\leq A_i \\leq i$\n\n-----Sample Input:-----\n1\n\n13\n\n1 1 1 1 1 4 3 4 4 3 4 3 \n\n-----Sample Output:-----\n4\n\n-----EXPLANATION:-----", "starter_code": "", "test_cases": {"inputs": ["1\n13\n1 1 1 1 1 4 3 4 4 3 4 3"], "outputs": ["4"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "7c580b01688793aede904053a2467744e2b3e7f1", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-00803", "original_id": null, "source": "apps", "domain": "code", "problem": "Zonal Computing Olympiad 2012, 26 Nov 2011\n\nThe year is 2102 and today is the day of ZCO. This year there are N contests and the starting and ending times of each contest is known to you. You have to participate in exactly one of these contests. Different contests may overlap. The duration of different contests might be different. \n\nThere is only one examination centre. There is a wormhole V that transports you from your house to the examination centre and another wormhole W that transports you from the examination centre back to your house. Obviously, transportation through a wormhole does not take any time; it is instantaneous. But the wormholes can be used at only certain fixed times, and these are known to you.\n\nSo, you use a V wormhole to reach the exam centre, possibly wait for some time before the next contest begins, take part in the contest, possibly wait for some more time and then use a W wormhole to return back home. If you leave through a V wormhole at time t1 and come back through a W wormhole at time t2, then the total time you have spent is (t2 - t1 + 1). Your aim is to spend as little time as possible overall while ensuring\nthat you take part in one of the contests.\n\nYou can reach the centre exactly at the starting time of the contest, if possible. And you can leave the examination centre the very second the contest ends, if possible. You can assume that you will always be able to attend at least one contest–that is, there will always be a contest such that there is a V wormhole before it and a W wormhole after it.\n\nFor instance, suppose there are 3 contests with (start,end) times (15,21), (5,10), and (7,25), respectively. Suppose the V wormhole is available at times 4, 14, 25, 2 and the W wormhole is available at times 13 and 21. In this case, you can leave by the V wormhole at time 14, take part in the contest from time 15 to 21, and then use the W wormhole at time 21 to get back home. Therefore the time you have spent is (21 - 14 + 1) = 8. You can check that you cannot do better than this.\n\n-----Input format-----\nThe first line contains 3 space separated integers N, X, and Y, where N is the number of contests, X is the number of time instances when wormhole V can be used and Y is the number of time instances when wormhole W can be used. The next N lines describe each contest. Each of these N lines contains two space separated integers S and E, where S is the starting time of the particular contest and E is the ending time of that contest, with S < E. The next line contains X space separated integers which are the time instances when the wormhole V can be used. The next line contains Y space separated integers which are the time instances when the wormhole W can be used.\n\n-----Output format-----\nPrint a single line that contains a single integer, the minimum time needed to be spent to take part in a contest.\n\n-----Testdata-----\nAll the starting and ending times of contests are distinct and no contest starts at the same time as another contest ends. The time instances when wormholes are available are all distinct, but may coincide with starting and ending times of contests. All the time instances (the contest timings and the wormhole timings) will be integers between 1 and 1000000 (inclusive).\n\n- Subtask 1 (30 marks)\n- Subtask 2 (70 marks)\n\nYou may assume that \n1 ≤ N ≤ 105,\n1 ≤ X ≤ 105, and\n1 ≤ Y ≤ 105.\n\nIn 30% of the cases, \n1 ≤ N ≤ 103,\n1 ≤ X ≤ 103, and\n1 ≤ Y ≤ 103.\n\n-----Sample Input-----\n3 4 2\n15 21\n5 10\n7 25\n4 14 25 2\n13 21\n\n-----Sample Output-----\n8", "starter_code": "", "test_cases": {"inputs": ["3 4 2\n15 21\n5 10\n7 25\n4 14 25 2\n13 21"], "outputs": ["8"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "479dc23cc7d82ceab6705351f4cf0b70c76dbddb", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-00808", "original_id": null, "source": "apps", "domain": "code", "problem": "On Miu's smart phone, there is a search feature which lets her search for a contact name by typing digits on the keypad where each digit may correspond to any of the characters given below it. For example, to search for TOM, she can type 866 and for MAX she can type 629.\n+------+-----+------+\n| 1 | 2 | 3 |\n| | ABC | DEF |\n+------+-----+------+\n| 4 | 5 | 6 |\n| GHI | JKL | MNO |\n+------+-----+------+\n| 7 | 8 | 9 |\n| PQRS | TUV | WXYZ |\n+------+-----+------+\n| | 0 | |\n+------+-----+------+\n\nMiu typed a random string of digits $S$ on the keypad while playing around, where each digit is between 2 and 9 inclusive. Now she wants to know the number of possible strings which would map to $S$. \nSince this number can be very large, output it modulo 10^9 + 7 (1000000007)\n\n-----Input:-----\n- \nThe first line of the input consists of a single integer $T$ denoting the number of test cases.\n- \nEach test case consists of a string $S$.\n\n-----Output:-----\n- For each test case, print a single line containing one integer - the count of all possible strings mod 1,000,000,007\n\n-----Constraints-----\n- \n1 <= $T$ <= 10\n- \n1 <= $|S|$ <= 105\n\n-----Subtasks-----\nSubtask #1 (10 points):\n- 1 <= $|S|$ <= 10\nSubtask #2 (90 points):\n- Original Constraints\n\n-----Sample Input:-----\n2\n\n5\n\n72 \n\n-----Sample Output:-----\n3\n\n12 \n\n-----EXPLANATION:-----\n- \nExample Case 1:\n\nOn the key 5, we have the character set JKL.\n\nHence the possible strings are J,K,L.\n\nHence the answer is 3 % (1000000007) = 3. \n- \nExample Case 2:\nOn key 7, we have the character set PQRS.\n\nOn key 2, we have the character set ABC.\n\nHence the possible strings are PA,PB,PC,QA,QB,QC,RA,RB,RC,SA,SB,SC.\n\nHence the answer is 12 % (1000000007) = 12.", "starter_code": "", "test_cases": {"inputs": ["2\n5\n72"], "outputs": ["3\n12"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "f33cae91421fb4249dfdd8507d87645b2fbab82f", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-00813", "original_id": null, "source": "apps", "domain": "code", "problem": "Sumit and Dhiraj are roommates in a hostel of NIT Jamshedpur,One day after completing there boring assignments of Artificial Intelligence, they decided to play a game as it was dhiraj,s idea to play a game so he started explaining the rules of the game to sumit.\nSo the game was as follows-They randomly took a number N after that they find all its divisors.Suppose first sumit took a divisor then dhiraj and so on.The player who will be having the last divisor with him will win the game.Rohit their mutual friend,was observing them play. Can you help Rohit predict the outcome of game? If Sumit wins print \"YES\" without quotes and \"NO\" without quotes, if Dhiraj wins\nthe game.\n\n-----Input-----\nInput starts with an integer T denoting the number of test cases Each test case starts with a line containing an integer N the number.\n\n-----Output-----\nOutcome of each game in a separate line\n\n-----Constraints-----\n- 1 ≤ T ≤ 10^3\n- 1 ≤ N ≤ 10^18\n\n-----Sub tasks-----\n- Subtask #1:(10 points)\n\n- 1 ≤ T ≤ 10\n- 1 ≤ N ≤ 103\n- Subtask #2:(25 points)\n\n- 1 ≤ T ≤ 50\n- 1 ≤ N ≤ 1016\n- Subtask #3:(65 points)\n\n- 1 ≤ T ≤ 103\n- 1 ≤ N ≤ 1018\n\n-----Example-----\nInput:\n2\n4\n5\n\nOutput:\nYES\nNO", "starter_code": "", "test_cases": {"inputs": ["2\n4\n5"], "outputs": ["YES\nNO"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "c1fbeb16429823d99e1ac055e96a12874e4cbe51", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-00818", "original_id": null, "source": "apps", "domain": "code", "problem": "-----Problem Statement-----\nWe have an integer sequence $A$, whose length is $N$.\nFind the number of the non-empty contiguous subsequences of $A$ whose sum is $0$. Note that we are counting the ways to take out subsequences. That is, even if the contents of some two subsequences are the same, they are counted individually if they are taken from different positions.\n\n-----Input-----\nInput is given in the following format:\n$N$\n$A_1$ $A_2$ . . . $A_N$\n\n-----Output-----\nFind the number of the non-empty contiguous subsequences of $A$ whose sum is $0$.\n\n-----Constraints-----\n- $1 \\leq N \\leq 2\\times10^5$\n- $-10^9 \\leq A_i \\leq 10^9$\n- All values in input are integers.\n\n-----Sample Input-----\n6\n1 3 -4 2 2 -2\n\n-----Sample Output-----\n3\n\n-----EXPLANATION-----\nThere are three contiguous subsequences whose sums are $0$: $(1, 3, -4)$, $(-4, 2, 2)$ and $(2, -2)$", "starter_code": "", "test_cases": {"inputs": ["6\n1 3 -4 2 2 -2"], "outputs": ["3"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "b08ab5b9cd104a94cdd6fb51a675d42f93be093f", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-00823", "original_id": null, "source": "apps", "domain": "code", "problem": "Ravi is very good student in mathematics and he also like Even numbers very much .\n\nOn the other hand his friend Jhon like Odd numbers . Both of them are preparing for IIT JEE Advance .One day they are solving a question together the question was Find the sum of first $n$ terms of the given series $1^2+2.2^2+3^2+2.4^2+5^2+2.6^2+...........$\nIf the sum is odd then Jhon will be happy and will solve 2 more questions,and Ravi will not attempt more questions. If sum is even Ravi will be happy and will solve 2 more questions and Jhon will not attempt more questions. \nSo Your task is to decide who will solve more questions.\n\n-----Input:-----\n- First line will contain $n$, number of terms in the given series.\n\n-----Output:-----\nOutput single line \"Ravi\" if he solve more questions or \"Jhon\" if he solve more questions.\n\n-----Constraints-----\n- $1 \\leq n \\leq 100$\n\n-----Sample Input:-----\n2\n\n3 \n\n-----Sample Output:-----\nJhon \nRavi \n\n-----EXPLANATION:-----\nIn the first test cases sum of 2 terms is 9 (according to the given series) which is an odd number so Jhon will solve 2 more questions and Ravi will not attempt more questions.\nIn second test case sum of 3 terms is 18 (according to the given series) which is an even number according to the given series so Ravi will solve 3 more questions and Jhon will not attempt more questions.", "starter_code": "", "test_cases": {"inputs": ["2\n3"], "outputs": ["Jhon\nRavi"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "467c629ec969a37af7cc89699078c915913f6c75", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-00828", "original_id": null, "source": "apps", "domain": "code", "problem": "Nitika was once reading a history book and wanted to analyze it. So she asked her brother to create a list of names of the various famous personalities in the book. Her brother gave Nitika the list. Nitika was furious when she saw the list. The names of the people were not properly formatted. She doesn't like this and would like to properly format it.\nA name can have at most three parts: first name, middle name and last name. It will have at least one part. The last name is always present. The rules of formatting a name are very simple:\n\n- Only the first letter of each part of the name should be capital.\n- All the parts of the name except the last part should be represented by only two characters. The first character should be the first letter of the part and should be capitalized. The second character should be \".\".\n\nLet us look at some examples of formatting according to these rules:\n- gandhi -> Gandhi\n\n- mahatma gandhI -> M. Gandhi \n- Mohndas KaramChand ganDhi -> M. K. Gandhi \n\n-----Input-----\nThe first line of the input contains an integer T denoting the number of test cases.\nThe only line of each test case contains the space separated parts of the name.\n\n-----Output-----\nFor each case, output the properly formatted name.\n\n-----Constraints-----\n- 1 ≤ T ≤ 100\n- 2 ≤ Length of each part of the name ≤ 10\n- Each part of the name contains the letters from lower and upper case English alphabets (i.e. from 'a' to 'z', or 'A' to 'Z')\n\n-----Subtasks-----\nSubtask #1 (40 points)\n- There is exactly one part in the name.\n\nSubtask #2 (60 points)\n- Original constraints.\n\n-----Example-----\nInput:\n3\ngandhi\nmahatma gandhI\nMohndas KaramChand gandhi\n\nOutput:\nGandhi \nM. Gandhi \nM. K. Gandhi \n\n-----Explanation-----\nThe examples are already explained in the problem statement.", "starter_code": "", "test_cases": {"inputs": ["3\ngandhi\nmahatma gandhI\nMohndas KaramChand gandhi\n\n"], "outputs": ["Gandhi \nM. Gandhi \nM. K. Gandhi "]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "011fa8d00ab0fec86ab1cecac41a71001b703b78", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-00833", "original_id": null, "source": "apps", "domain": "code", "problem": "Shaun was given $N$ pairs of parenthesis ( ) by his teacher who gave him a difficult task.The task consists of two steps. First,Shaun should colour all $N$ pairs of parenthesis each with different color but opening and closing bracket of a particular pair should be of same colour. Then,Shaun should report to his teacher the number of ways he can arrange all $2*N$ brackets such that sequence form is valid. Teacher defined valid sequence by these rules:\n- Any left parenthesis '(' must have a corresponding right parenthesis ')'.\n- Any right parenthesis ')' must have a corresponding left parenthesis '('.\n- Left parenthesis '(' must go before the corresponding right parenthesis ')'. \nNote: Shaun could match opening and closing brackets of different colours. \nSince number of ways can be large, Shaun would report the answer as modulo 1000000007 ($10^9 + 7$).\n\n-----Input:-----\n- First line will contain $T$, number of testcases. Then the testcases follow. \n- Each testcase contains of a single line of input, one integer $N$. \n\n-----Output:-----\nFor each testcase, output in a single line answer given by Shaun to his teacher modulo 1000000007.\n\n-----Constraints-----\n- $1 \\leq T \\leq 100000$\n- $1 \\leq N \\leq 100000$\n\n-----Sample Input:-----\n3\n1\n2\n3\n\n-----Sample Output:-----\n1\n6\n90\n\n-----EXPLANATION:-----\nHere numbers from $1$ to $N$ have been used to denote parenthesis.A unique number corresponds to a unique pair of parenthesis.\n-In the first test case , you can use only one color to color the parenthesis you could arrange it only in one way i.e, 1 1\n-In the second test case you can use two colors and the possible ways of arranging it are\n1 1 2 2\n1 2 2 1\n1 2 1 2\n2 2 1 1\n2 1 1 2\n2 1 2 1", "starter_code": "", "test_cases": {"inputs": ["3\n1\n2\n3"], "outputs": ["1\n6\n90"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "bf877a67acf4cd438cc522f9b4ac85d573609f89", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-00838", "original_id": null, "source": "apps", "domain": "code", "problem": "The chef is very expert in coding, so to keep his password safe from the hackers. He always enters a decoded code of his password. You are a hacker and your work is to find the maximum number of possible ways to unlock his password in encoded form.\n\nThe encoded message containing only letters from A-Z is being encoded with numbers using the following mapping: \n\n'A' -> 1 \n\n'B' -> 2 ... \n\n'Z' -> 26\n\nYou have given a non-empty string containing only digits, determine the total number of ways to encode it. \n\nIf the total number of ways are even then you are able to unlock the password. \n\nInput: \nThe first line has a single integer T, denoting the number of test cases. The first line of each test case contains string “S” decoded number.\n\nOutput:\nFor each test case, in a new line, print 'YES' if number of maximum ways are even, otherwise\n'NO'. (without quotes)\n\nConstraints:\n1 ≤ T ≤ 50\n\n1 ≤ S ≤ 30\n\nSample Input:\n2\n\n12\n\n223\n\nSample Output:\nYES\n\nNO\n\nExplanation:\nFor first test case, It could be encoded as \"AB\" (1 2) or \"L\" (12), hence the number of\nmaximum possible ways are 2 so output is “YES”.", "starter_code": "", "test_cases": {"inputs": ["2\n12\n223"], "outputs": ["YES\nNO"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "bb8c25c0b9909d8453ba7a602ad182b334269bb0", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-00843", "original_id": null, "source": "apps", "domain": "code", "problem": "In a bizarre game of chess ,knight was so drunk, that instead of his usual move he started walking straight. In every move Knight jumps on 2n steps forward (n is number of block that he had travelled so far from starting) but after that he has to take either 1 step forward or backward.\nNow the Knight needs to get to position X so King (i.e. You) needs to decide the order of his backward or forward step in such a way that he can reach its destination in minimum number of steps. Remember he always travels in a straight line and the length of the board is infinite.\n\n-----Input-----\nThe first line of the input contains an integer T denoting the number of test cases, for each test case enter value X ( i.e. destination)\nNote : initially knight is at n = 1.\n\n-----Output-----\nFor each test case the output should be string of numbers 1 & 2 where 1 denotes backward step and 2 denote the forward step \nNote : for no solution print 0.\n\n-----Constraints-----\n- 1 ≤ T ≤ 100\n- 1 ≤ X ≤ 10^10\n\n-----Example-----\nInput:\n2\n17\n10\nOutput:\n2111\n0\n\n-----Explanation-----\nCase 1 : starting from n = 1 , knight moves to n = 3 ('2') , 5 ('1') , 9 ('1') , 17 ('1') i.e. string printed is 2 1 1 1\nCase 2 : no solution is possible", "starter_code": "", "test_cases": {"inputs": ["2\n17\n10"], "outputs": ["2111\n0"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "a6ac909db54d24a303de0f5d6d29fd3cad91a97c", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-00848", "original_id": null, "source": "apps", "domain": "code", "problem": "Chef and his friends are playing the game AMONG US. They all have chosen their names as numbers. There are N people in Chef’s group including him, and each swears that he is not the imposter. However, it turns out there were N+1 people in the game. Now all that Chef needs to know is the name of the imposter, which is a number. Also remember that numbers can be duplicate. Can you help out Chef in finding the imposter?\nInput : \nFirst line contains the value of N. Second line contains the N numbers that Chef’s friends used as their names. Third line contains the N+1 numbers that people in the game have used as their names.\nOutput : \nPrint the extra number in new line.\nConstraints : \n1 ≤ Numbers used as names ≤ 1,000\n1 ≤ N ≤ 1,000,000\nSample Input : \n3\n4 2 5\n4 2 3 5\nSample Output : \n3", "starter_code": "", "test_cases": {"inputs": ["3\n4 2 5\n4 2 3 5"], "outputs": ["3"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "d6abd3ffc7ba0dfd67201d308a6391508cd78329", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-00853", "original_id": null, "source": "apps", "domain": "code", "problem": "Tom has finally taken over the business empire and now looking for \na new Name of the business to make a new start.\n\nJoe (Tom's dear friend) suggested a string $S$ consisting of\nUppercase and lowercase letters \n\nTom wants to make some changes as per the following criteria:\n\n1) String should $not$ have any vowels .\n\n2) Every other uppercase consonant(other characters except vowels) should \nbe in lowercase\n\nFor ex:\n\nIf the consonant character is Z then it should be z\n\n3) There should be a character \".\" before each consonant.\n\nHelp Tom to make the required Changes.\n\n-----Input:-----\n- First line will contain string $S$,This string only consists of uppercase and lowercase letters.\n\n-----Output:-----\nPrint the resulting string. It is guaranteed that this string is not empty.\n\n-----Constraints-----\n- Length of string is in [1 .. 100]\n\n-----Sample Input:-----\n$CodeSprInT$\n\n-----Sample Output:-----\n.c.d.s.p.r.n.t \n\n-----EXPLANATION:-----\nC is a consonant and it is in uppercase so turn it in lower case and add a “.” before it\no is a vowel so it is deleted\nd is a consonant and in lowercase so just add a “.” before it\ne is a vowel so it is deleted\nS is a consonant and it is in uppercase so turn it in lower case and add a “.” before it\np is a consonant and in lowercase so just add a “.” before it\nr is a consonant and in lowercase so just add a “.” before it\nI is a vowel so it is deleted\nn is a consonant and in lowercase so just add a “.” before it\nT is a consonant and it is in uppercase so turn it in lower case and add a “.” before it", "starter_code": "", "test_cases": {"inputs": ["CodeSprInT"], "outputs": [".c.d.s.p.r.n.t"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "aefb1155f6a9d9771263b3fc392518d0234f39af", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-00858", "original_id": null, "source": "apps", "domain": "code", "problem": "Oliver and Nova are true lovers. Inspite of knowing that Nova will die Oliver married her at the lake where they met. But they had a conflict about even and odd numbers. Nova likes the odd numbers and Oliver prefers even. One day they went to a fair where Oliver bought some square shaped marshmallows and Nova bought some round shaped. Then they decided to play a game. They will pick a natural number N . Nova will sum up the odd numbers from 1 to N and and she will notedown LCM of R(R is defined in the picture) and the sum she calculated before. And Oliver will sum up the even numbers from 1 to N and and he will notedown LCM of S(S is defined in the picture) and the sum he calculated before. You must use the ceil value of R and S.\n\nNow whose LCM is strictly greater than the other will win.If both of their LCM is equal Nova will win because Oliver is afraid of Nova.\n$N.B.$ define the value of pi with $acos(-1)$.\n$N.B.$ Sum of all odd number and sum of all even number will not exceed 10^18. \n\n-----Input:-----\nThe first line contains an integer $T$ — the number of test cases in the input. Next, T test cases are given, one per line.\nEach test case is a positive integer $N$ . \n\n-----Output:-----\nPrint T answers to the test cases.\nIn each test cases,\nIf Oliver wins the game, print \"Nova's gonna kill me\" (without quotes) .\nIf Nova wins the game, print \"YESS(sunglass emo)\" (without quotes) .\n\n-----Constraints-----\n- $1 \\leq T \\leq 2000$\n- $1 \\leq N \\leq 1845271$\n\n-----Sample Input:-----\n1\n111\n\n-----Sample Output:-----\nYESS(sunglass emo)", "starter_code": "", "test_cases": {"inputs": ["1\n111"], "outputs": ["YESS(sunglass emo)"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "8476ea0e99e97dc648d2954aa3954be75f0c1983", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-00863", "original_id": null, "source": "apps", "domain": "code", "problem": "Chef has a natural number N. Cheffina challenges chef to check whether the given number is divisible by the sum of its digits or not. If the given number is divisible then print \"Yes\" else \"No\".\n\n-----Input:-----\n- First-line will contain $T$, the number of test cases. Then the test cases follow. \n- Each test case contains a single line of input, $N$. \n\n-----Output:-----\nFor each test case, output in a single line answer.\n\n-----Constraints-----\n- $1 \\leq T \\leq 10^6$\n- $1 \\leq N \\leq 10^6$\n\n-----Sample Input:-----\n2\n16\n27\n\n-----Sample Output:-----\nNo\nYes", "starter_code": "", "test_cases": {"inputs": ["2\n16\n27"], "outputs": ["No\nYes"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "0d4934db9975d0aba14095364bec1c41b98833d8", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-00868", "original_id": null, "source": "apps", "domain": "code", "problem": "Chef is a private detective. He was asked to investigate a case of murder in the city of Frangton.\nChef arrived in Frangton to find out that the mafia was involved in the case. Chef spent some time watching for people that belong to the clan and was able to build a map of relationships between them. He knows that a mafia's organizational structure consists of a single Don, heading a hierarchical criminal organization. Each member reports exactly to one other member of the clan. It's obvious that there are no cycles in the reporting system of the mafia.\nThere are N people in the clan, for simplicity indexed from 1 to N, and Chef knows who each of them report to. Member i reports to member Ri.\nNow, Chef needs to identfy all potential killers to continue his investigation. Having considerable knowledge about the mafia's activities, Chef knows that the killer must be a minor criminal, that is, one of the members who nobody reports to. Please find the list of potential killers for Chef. Since Don reports to nobody, his Ri will be equal to 0.\n\n-----Input-----\nThe first line of input contains one integer N.\nNext line has N space-separated integers, the ith integer denotes Ri — the person whom the ith member reports to.\n\n-----Output-----\nOutput a list of space-separated integers in ascending order — the indices of potential killers.\n\n-----Constraints-----\n- 1 ≤ N ≤ 105\n- 1 ≤ Ri ≤ N except for Don, whose Ri equals to 0.\n- It is guaranteed that there are no cycles in the reporting structure.\n\n-----Subtasks-----\n- Subtask #1 [50 points]: N ≤ 10000\n- Subtask #2 [50 points]: No additional constraints\n\n-----Example-----\nInput:\n6\n0 1 1 2 2 3\n\nOutput:\n4 5 6\n\n-----Explanation-----\nThe reporting structure:", "starter_code": "", "test_cases": {"inputs": ["6\n0 1 1 2 2 3"], "outputs": ["4 5 6"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "452f2d5e8ded588d2b725aeee727d17310a9efcd", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-00873", "original_id": null, "source": "apps", "domain": "code", "problem": "Chefland has all the cities on a straight line. There are $N$ cities in Chefland numbered $1$ to $N$. City $i$ is located at coordinate $x_i$ on the x-axis. Guru wants to travel from city $A$ to city $B$. He starts at time t=0. He has following choices to travel.\n- He can walk $1$ metre in $P$ secs.\n- There is a train that travels from city $C$ to city $D$ which travels $1$ metre in $Q$ secs which starts at time t=$Y$ secs. Guru can take the train only at city $C$ and leave the train only at city $D$.\nCan you help Guru find the minimum time he will need to travel from city $A$ to $B$. Note that you cannot board the train after time t =$Y$.\n\n-----Input:-----\n- First line will contain $T$, number of testcases. Then the testcases follow. \n- First line of each testcase contains eight space separated integers $N, A, B, C, D, P, Q, Y $. \n- Second line of each testcase contains $N$ space-separated integers with the $i$-th integer representing $x_i$.\n\n-----Output:-----\nFor each testcase, output in a single line containing the minimum travel time.\n\n-----Constraints-----\n- $1 \\leq T \\leq 300$\n- $2 \\leq N \\leq 300$\n- $-1000 \\leq x_i \\leq 1000$\n- $0 \\leq Y \\leq 100000$\n- $1 \\leq A,B,C,D \\leq n $\n- $A \\neq B$\n- $C \\neq D$\n- $1 \\leq P, Q \\leq 100$\n- $x_i < x_j$ if $i < j$\n\n-----Sample Input:-----\n1\n4 1 3 2 4 3 2 4\n1 2 3 4\n\n-----Sample Output:-----\n6\n\n-----EXPLANATION:-----\nGuru can walk directly in 6 secs.\nIf Guru takes train, then he will need atleast 11 secs.", "starter_code": "", "test_cases": {"inputs": ["1\n4 1 3 2 4 3 2 4\n1 2 3 4"], "outputs": ["6"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "56394edd7b9a8bcecccd899b43ee798170f83e6f", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-00878", "original_id": null, "source": "apps", "domain": "code", "problem": "Two sisters, A and B, play the piano every day. During the day, they can play in any order. That is, A might play first and then B, or it could be B first and then A. But each one of them plays the piano exactly once per day. They maintain a common log, in which they write their name whenever they play.\nYou are given the entries of the log, but you're not sure if it has been tampered with or not. Your task is to figure out whether these entries could be valid or not.\n\n-----Input-----\n- The first line of the input contains an integer $T$ denoting the number of test cases. The description of the test cases follows.\n- The first line of each test case contains a string $s$ denoting the entries of the log.\n\n-----Output-----\n- For each test case, output yes or no according to the answer to the problem.\n\n-----Constraints-----\n- $1 \\le T \\le 500$\n- $2 \\le |s| \\le 100$\n- $|s|$ is even\n- Each character of $s$ is either 'A' or 'B'\n\n-----Example Input-----\n4\nAB\nABBA\nABAABB\nAA\n\n-----Example Output-----\nyes\nyes\nno\nno\n\n-----Explanation-----\nTestcase 1: There is only one day, and both A and B have played exactly once. So this is a valid log. Hence 'yes'.\nTestcase 2: On the first day, A has played before B, and on the second day, B has played first. Hence, this is also a valid log.\nTestcase 3: On the first day, A played before B, but on the second day, A seems to have played twice. This cannot happen, and hence this is 'no'.", "starter_code": "", "test_cases": {"inputs": ["4\nAB\nABBA\nABAABB\nAA"], "outputs": ["yes\nyes\nno\nno"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "beba7a0d7e1e3aa3ac4198549934afd449acc46c", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-00883", "original_id": null, "source": "apps", "domain": "code", "problem": "Chef is solving mathematics problems. He is preparing for Engineering Entrance exam. He's stuck in a problem.\n$f(n)=1^n*2^{n-1}*3^{n-2} * \\ldots * n^{1} $ \nHelp Chef to find the value of $f(n)$.Since this number could be very large, compute it modulo $1000000007$.\n\n-----Input:-----\n- First line will contain $T$, number of testcases. Then the testcases follow. \n- Each testcase contains of a single line of input, $N$. \n\n-----Output:-----\nFor each testcase, output in a single line the value of $f(n)$ mod $1000000007$.\n\n-----Constraints-----\n- $1 \\leq T \\leq 10^6$\n- $1 \\leq N \\leq 10^6$\n\n-----Subtasks-----\nSubtask 1(24 points) : \n- $1 \\leq T \\leq 5000$\n- $1 \\leq N \\leq 5000$\nSubtask 2(51 points) : original constraints\n\n-----Sample Input:-----\n1\n3\n\n-----Sample Output:-----\n12", "starter_code": "", "test_cases": {"inputs": ["1\n3"], "outputs": ["12"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "5e5d8d4a95f5f7b975b2b900cd2fbd62b5be7b19", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-00888", "original_id": null, "source": "apps", "domain": "code", "problem": "Chef and his competitor Kefa own two restaurants located at a straight road. The position of Chef's restaurant is $X_1$, the position of Kefa's restaurant is $X_2$.\nChef and Kefa found out at the same time that a bottle with a secret recipe is located on the road between their restaurants. The position of the bottle is $X_3$.\nThe cooks immediately started to run to the bottle. Chef runs with speed $V_1$, Kefa with speed $V_2$.\nYour task is to figure out who reaches the bottle first and gets the secret recipe (of course, it is possible that both cooks reach the bottle at the same time).\n\n-----Input-----\n- The first line of the input contains a single integer $T$ denoting the number of test cases. The description of $T$ test cases follows.\n- The first and only line of each test case contains five space-separated integers $X_1$, $X_2$, $X_3$, $V_1$ and $V_2$. \n\n-----Output-----\nFor each test case, print a single line containing the string \"Chef\" if Chef reaches the bottle first, \"Kefa\" if Kefa reaches the bottle first or \"Draw\" if Chef and Kefa reach the bottle at the same time (without quotes). \n\n-----Constraints-----\n- $1 \\le T \\le 10^5$\n- $|X_1|, |X_2|, |X_3| \\le 10^5$\n- $X_1 < X_3 < X_2$\n- $1 \\le V_1 \\le 10^5$\n- $1 \\le V_2 \\le 10^5$\n\n-----Example Input-----\n3\n1 3 2 1 2\n1 5 2 1 2\n1 5 3 2 2\n\n-----Example Output-----\nKefa\nChef\nDraw\n\n-----Explanation-----\nExample case 1. Chef and Kefa are on the same distance from the bottle, but Kefa has speed $2$, while Chef has speed $1$.", "starter_code": "", "test_cases": {"inputs": ["3\n1 3 2 1 2\n1 5 2 1 2\n1 5 3 2 2"], "outputs": ["Kefa\nChef\nDraw"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "e7ff7c21debee884f3c3ba850fa6a80a43472c16", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-00893", "original_id": null, "source": "apps", "domain": "code", "problem": "Richik$Richik$ has just completed his engineering and has got a job in one of the firms at Sabrina$Sabrina$ which is ranked among the top seven islands in the world in terms of the pay scale. \nSince Richik$Richik$ has to travel a lot to reach the firm, the owner assigns him a number X$X$, and asks him to come to work only on the day which is a multiple of X$X$. Richik joins the firm on 1-st day but starts working from X-th day. Richik$Richik$ is paid exactly the same amount in Dollars as the day number. For example, if Richik$Richik$ has been assigned X=3$X = 3$, then he will be paid 3$3$ dollars and 6$6$ dollars on the 3rd$3rd$ and 6th$6th$ day on which he comes for work. \nOn N−th$N-th$ day, the owner calls up Richik$Richik$ and asks him not to come to his firm anymore. Hence Richik$Richik$ demands his salary of all his working days together. Since it will take a lot of time to add, Richik$Richik$ asks help from people around him, let's see if you can help him out. \n\n-----Input:-----\n- First line will contain T$T$, number of testcases. Then the testcases follow. \n- Each testcase contains of a single line of input, two integers X,N$X, N$. \n\n-----Output:-----\nFor each testcase, output in a single line which is the salary which Richik$Richik$ demands. \n\n-----Constraints-----\n- 1≤T≤1000$1 \\leq T \\leq 1000$\n- 1≤X<=N≤107$1 \\leq X<=N \\leq 10^7$\n\n-----Sample Input:-----\n1\n3 10\n\n-----Sample Output:-----\n18", "starter_code": "", "test_cases": {"inputs": ["1\n3 10"], "outputs": ["18"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "bc3957800d48ad6f7cba8b5d205a0f9474aba5d6", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-00898", "original_id": null, "source": "apps", "domain": "code", "problem": "It's the annual military parade, and all the soldier snakes have arrived at the parade arena, But they aren't standing properly. The entire parade must be visible from the main podium, and all the snakes must be in a line. But the soldiers are lazy, and hence you must tell the soldiers to move to their new positions in such a manner that the total movement is minimized.\nFormally, the entire parade strip can be thought of as the integer line. There are N snakes, where each snake is a line segment of length L. The i-th snake is initially at the segment [Si, Si + L]. The initial positions of the snakes can overlap. The only segment of the strip visible from the podium is [A, B], and hence all the snakes should be moved so that all of them are visible from the podium. They should also all be in a line without gaps and every consecutive pair touching each other. In other words, they should occupy the segments [X, X + L], [X + L, X + 2*L], ... , [X + (N-1)*L, X + N*L], for some X, such that A ≤ X ≤ X + N*L ≤ B. You are guaranteed that the visible strip is long enough to fit all the snakes.\n\nIf a snake was initially at the position [X1, X1 + L] and finally is at the position [X2, X2 + L], then the snake is said to have moved a distance of |X2 - X1|. The total distance moved by the snakes is just the summation of this value over all the snakes. You need to move the snakes in such a manner that it satisfies all the conditions mentioned above, as well as minimize the total distance. You should output the minimum total distance achievable.\n\n-----Input-----\n- The first line contains a single integer, T, the number of testcases. The description of each testcase follows.\n- The first line of each testcase contains four integers, N, L, A and B, where N denotes the number of snakes, L denotes the length of each snake, and [A, B] is the segment visible from the podium.\n- The next line contains N integers, the i-th of which is Si. This denotes that the i-th snake is initially in the segment [Si, Si + L].\n\n-----Output-----\n- For each testcase, output a single integer in a new line: the minimum total distance achievable.\n\n-----Constraints-----\n- 1 ≤ T ≤ 10\n- 1 ≤ N ≤ 105\n- 1 ≤ Si ≤ 109\n- 1 ≤ L ≤ 109\n- 1 ≤ A ≤ B ≤ 109\n- N * L ≤ B - A\n\n-----Example-----\nInput:\n2\n3 4 11 23\n10 11 30\n3 4 11 40\n10 11 30\n\nOutput:\n16\n16\n\n-----Explanation-----\nIn the first testcase, the three snakes are initially at segments [10, 14], [11, 15], and [30, 34]. One optimal solution is to move the first snake which was at [10, 14] to [15, 19] and the third snake which was at [30, 34] to [19, 23]. After this, the snakes would form a valid parade because they will be from [11, 15], [15, 19] and [19, 23]. Hence they are all in a line without any gaps in between them, and they are all visible, because they all lie in the visible segment, which is [11, 23].\nThe distance traveled by the first snake is |15 - 10| = 5, by the second snake is |11 - 11| = 0 and by the third snake is |19 - 30| = 11. Hence the total distance traveled is 5 + 0 + 11 = 16. This is the best that you can do, and hence the answer is 16.\nIn the second testcase, only the visible segment has increased. But you can check that the same final configuration as in the first subtask is still optimal here. Hence the answer is 16.", "starter_code": "", "test_cases": {"inputs": ["2\n3 4 11 23\n10 11 30\n3 4 11 40\n10 11 30"], "outputs": ["16\n16"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "249bb11677c95799c6b5524f5423a803a4357d72", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-00903", "original_id": null, "source": "apps", "domain": "code", "problem": "AND gates and OR gates are basic components used in building digital circuits. Both gates have two input lines and one output line. The output of an AND gate is 1 if both inputs are 1, otherwise the output is 0. The output of an OR gate is 1 if at least one input is 1, otherwise the output is 0.\n\nYou are given a digital circuit composed of only AND and OR gates where one node (gate or input) is specially designated as the output. Furthermore, for any gate G and any input node I, at most one of the inputs to G depends on the value of node I.\n\nNow consider the following random experiment. Fix some probability p in [0,1] and set each input bit to 1 independently at random with probability p (and to 0 with probability 1-p). The output is then 1 with some probability that depends on p. You wonder what value of p causes the circuit to output a 1 with probability 1/2.\n\n-----Input-----\n\nThe first line indicates the number of test cases to follow (about 100).\n\nEach test case begins with a single line containing a single integer n with 1 ≤ n ≤ 100 indicating the number of nodes (inputs and gates) in the circuit. Following this, n lines follow where the i'th line describes the i'th node. If the node is an input, the line simply consists of the integer 0. Otherwise, if the node is an OR gate then the line begins with a 1 and if the node is an AND gate then the line begins with a 2. In either case, two more integers a,b follow, both less than i, which indicate that the outputs from both a and b are used as the two input to gate i.\n\nAs stated before, the circuit will be such that no gate has both of its inputs depending on the value of a common input node.\n\nTest cases are separated by a blank line including a blank line preceding the first test case.\n\n\n-----Output-----\n\nFor each test case you are to output a single line containing the value p for which the output of node n is 1 with probability exactly 1/2 if the inputs are independently and randomly set to value 1 with probability p. The value p should be printed with exactly 5 digits after the decimal.\n\n\n-----Example-----\nInput:\n\n4\n\n1\n0\n\n3\n0\n0\n1 1 2\n\n3\n0\n0\n2 1 2\n\n5\n0\n0\n0\n2 1 2\n1 3 4\n\nOutput:\n\n0.50000\n0.29289\n0.70711\n0.40303\n\n-----Temporary Stuff-----\n\nA horizontal rule follows.\n\n***\n\nHere's a definition list (with `definitionLists` option):\n\napples\n: Good for making applesauce.\noranges\n: Citrus!\ntomatoes\n: There's no \"e\" in tomatoe.\n\n#PRACTICE\n- This must be done\n[http:codechef.com/users/dpraveen](http:codechef.com/users/dpraveen)\n\n(0.8944272−0.44721360.4472136−0.8944272)(10005)(0.89442720.4472136−0.4472136−0.8944272)(10005)\n\\left(\\begin{array}{cc} \n0.8944272 & 0.4472136\\\\\n-0.4472136 & -0.8944272\n\\end{array}\\right)\n\\left(\\begin{array}{cc} \n10 & 0\\\\ \n0 & 5\n\\end{array}\\right)", "starter_code": "", "test_cases": {"inputs": ["4\n\n1\n0\n\n3\n0\n0\n1 1 2\n\n3\n0\n0\n2 1 2\n\n5\n0\n0\n0\n2 1 2\n1 3 4\n\n"], "outputs": ["0.50000\n0.29289\n0.70711\n0.40303"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "c42ee029deef6ff24af2880f48396c51469a3628", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-00908", "original_id": null, "source": "apps", "domain": "code", "problem": "The chef is having one array of natural numbers. Cheffina challenges chef that find the sum of weights all the natural numbers present in the array, but the main problem is that all numbers have not original weights. After every 6 natural numbers weight is set to 1 as weight increases by 1 after that. (i.e. weight of 1 is 1, weight of 2 is 2 but the weight of 7 is 1 and weight of 8 is 2 and so on…). Help the chef to find the sum. \n\n-----Input:-----\n- First line will contain $T$, number of testcases. Then the testcases follow. \n- Each testcase contains two lines of input, one integer $N$.\n- Next line has N space separate natural numbers. \n\n-----Output:-----\nFor each testcase, output in a single line answer.\n\n-----Constraints-----\n- $1 \\leq T \\leq 10$\n- $1 \\leq N \\leq 10^5$\n- $1 \\leq arr[i] \\leq 10^6$\n\n-----Sample Input:-----\n1\n6\n6 7 9 11 4 16\n\n-----Sample Output:-----\n23\n\n-----EXPLANATION:-----\nArray after conversion = [6, 1, 3, 5, 4, 4]", "starter_code": "", "test_cases": {"inputs": ["1\n6\n6 7 9 11 4 16"], "outputs": ["23"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "d44fa36e4826461615c5c69335409752d4de9e4b", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-00913", "original_id": null, "source": "apps", "domain": "code", "problem": "Chef has recently learned about number bases and is becoming fascinated.\nChef learned that for bases greater than ten, new digit symbols need to be introduced, and that the convention is to use the first few letters of the English alphabet. For example, in base 16, the digits are 0123456789ABCDEF. Chef thought that this is unsustainable; the English alphabet only has 26 letters, so this scheme can only work up to base 36. But this is no problem for Chef, because Chef is very creative and can just invent new digit symbols when she needs them. (Chef is very creative.)\nChef also noticed that in base two, all positive integers start with the digit 1! However, this is the only base where this is true. So naturally, Chef wonders: Given some integer N, how many bases b are there such that the base-b representation of N starts with a 1?\n\n-----Input-----\nThe first line of the input contains an integer T denoting the number of test cases. The description of T test cases follows.\nEach test case consists of one line containing a single integer N (in base ten).\n\n-----Output-----\nFor each test case, output a single line containing the number of bases b, or INFINITY if there are an infinite number of them.\n\n-----Constraints-----\n\n-----Subtasks-----Subtask #1 (16 points):\n- 1 ≤ T ≤ 103\n- 0 ≤ N < 103\nSubtask #2 (24 points):\n- 1 ≤ T ≤ 103\n- 0 ≤ N < 106\nSubtask #3 (28 points):\n- 1 ≤ T ≤ 103\n- 0 ≤ N < 1012\nSubtask #4 (32 points):\n- 1 ≤ T ≤ 105\n- 0 ≤ N < 1012\n\n-----Example-----\nInput:4\n6\n9\n11\n24\n\nOutput:4\n7\n8\n14\n\n-----Explanation-----\nIn the first test case, 6 has a leading digit 1 in bases 2, 4, 5 and 6: 610 = 1102 = 124 = 115 = 106.", "starter_code": "", "test_cases": {"inputs": ["4\n6\n9\n11\n24"], "outputs": ["4\n7\n8\n14"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "a2557567a5513aa2bcc50ccb6bb0c9a9755c1769", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-00918", "original_id": null, "source": "apps", "domain": "code", "problem": "You are teaching students to generate strings consisting of unique lowercase latin characters (a-z). You give an example reference string $s$ to the students.\nYou notice that your students just copy paste the reference string instead of creating their own string. So, you tweak the requirements for strings submitted by the students.\nLet us define a function F(s, t) where s and t are strings as the number of characters that are same in both the strings. Note that the position doesn't matter. Here are a few examples of F(s, t):\nF(\"abc\", \"def\") = 0\nF(\"abc\", \"acb\") = 3\nF(\"back\", \"abcd\") = 3\nNow you ask your students to output a string t with lowercase unique characters of the same length as $s$, such that F(s, t) $\\leq k$ where you are also given the value of $k$. If there are multiple such strings, you ask them to output the lexicographically smallest possible string. If no such string is possible, output the string \"NOPE\" without quotes.\n\n-----Input:-----\n- The first line will contain $T$, the number of testcases. Then the testcases follow. \n- Each testcase contains of a single line of input, which contains a string $s$ and an integer $k$.\n\n-----Output:-----\nFor each testcase, output in a single line the lexicographically smallest string t such that F(s, t) <= k or \"NOPE\" without quotes if no such string exists.\n\n-----Constraints-----\n- $1 \\leq T \\leq 10000$\n- $1 \\leq $length of string s $(|s|) \\leq 26$\n- $s$ only consists of characters $a$ to $z$\n- There are no repeating characters in s\n- $0 \\leq k \\leq |s|$\n\n-----Sample Input:-----\n4\nhelowrd 0\nbackground 0\nabcdefghijklmnopqrstuvwxyz 0\nb 1\n\n-----Sample Output:-----\nabcfgij\nefhijlmpqs\nNOPE\na", "starter_code": "", "test_cases": {"inputs": ["4\nhelowrd 0\nbackground 0\nabcdefghijklmnopqrstuvwxyz 0\nb 1"], "outputs": ["abcfgij\nefhijlmpqs\nNOPE\na"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "eaad50f39be6cd99d45c517971118352ad4b1a3b", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-00923", "original_id": null, "source": "apps", "domain": "code", "problem": "An area named Renus, is divided into $(N \\times M)$ cells. According to archaeological survey the area contains huge amount of treasure. Some cells out of $(N \\times M)$ cells contain treasure. But problem is, you can't go to every cell as some of the cells are blocked. \nFor every $a_{ij}$ cell($1 \\leq i \\leq N$,$1 \\leq j \\leq M$), your task is to find the distance of the nearest cell having treasure. \nNote:\n- You can only traverse up, down, left and right from a given cell.\n- Diagonal movements are not allowed.\n- Cells having treasure can't be blocked, only empty cells ( cells without treasure) can be blocked. \n\n-----Input Format:------\n- First line contains $T$, the number of test cases.\n- Second line contains two space-separated integers $N\\ and\\ M$.\n- Third line contains a single integer $X$ denoting number of cells having treasures, followed by $X$ lines containing two space-separated integers $x_i$ and $y_i$ denoting position of row and column of $i^{th}$ treasure, for every $1\\leq i \\leq X$\n- The next line contains a single integer $Y$ denoting the number of cells that are blocked, and it is followed by subsequent $Y$ lines containing two space-separated integers $u_i$ and $v_i$ denoting position of row and column of blocked cells , for every $1\\leq i \\leq Y$\n\n-----Constraints:------\n- $1\\le T \\le 100$\n- $1 \\le N, M \\le 200$\n- $1 \\le X < N*M$\n- $0 \\le Y <(N*M) - X$\n- $1 \\le x_i,u_j \\le N, for\\ every\\ 1 \\le i \\le X\\ and\\ 1 \\le j \\le Y$\n- $1 \\le y_i,v_j \\le M, for\\ every\\ 1 \\le i \\le X\\ and\\ 1 \\le j \\le Y$\n\n-----Output Format:------\nFor each test case print a $N \\times M$ matrix where each cell consists of distance of nearest treasure. Cells that are blocked will show \"$X$\" (without quotes). Also cells that doesn't have access to any treasure will show \"$-1$\" (without quotes).\nNote: Co-ordinate of top left cell is $(1,1)$.\n\n-----Sample Input-----\n1\n3 3\n2\n1 1\n1 3\n2\n2 1\n2 2\n\n-----Sample Output-----\n0 1 0 \nX X 1\n4 3 2\n\n-----Explanation:-----\n- Coordinates (1,1) and (1,3) shows \"0\" because they contain treasure and nearest distance is 0.\n- Coordinates (2,1) and (2,2) shows \"X\" as they are blocked.\n- Rest shows distance of nearest cell having treasure.", "starter_code": "", "test_cases": {"inputs": ["1\n3 3\n2\n1 1\n1 3\n2\n2 1\n2 2"], "outputs": ["0 1 0\nX X 1\n4 3 2"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "2087689e37b3b6cb11355b618a5b72f263b4ccaf", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-00928", "original_id": null, "source": "apps", "domain": "code", "problem": "Once again, we have a lot of requests from coders for a challenging problem on geometry. Geometry expert Nitin is thinking about a problem with parabolas, icosahedrons, crescents and trapezoids, but for now, to encourage beginners, he chooses to work with circles and rectangles.\nYou are given two sequences $A_1, A_2, \\ldots, A_N$ and $B_1, B_2, \\ldots, B_N$. You should choose a permutation $P_1, P_2, \\ldots, P_N$ of the integers $1$ through $N$ and construct $N$ rectangles with dimensions $A_1 \\times B_{P_1}, A_2 \\times B_{P_2}, \\ldots, A_N \\times B_{P_N}$. Then, for each of these rectangles, you should construct an inscribed circle, i.e. a circle with the maximum possible area that is completely contained in that rectangle.\nLet $S$ be the sum of diameters of these $N$ circles. Your task is to find the maximum value of $S$.\n\n-----Input-----\n- The first line of the input contains a single integer $T$ denoting the number of test cases. The description of $T$ test cases follows.\n- The first line of each test case contains a single integer $N$.\n- The second line contains $N$ space-separated integers $A_1, A_2, \\ldots, A_N$. \n- The third line contains $N$ space-separated integers $B_1, B_2, \\ldots, B_N$. \n\n-----Output-----\nFor each test case, print a single line containing one integer ― the maximum value of $S$. It is guaranteed that this value is always an integer.\n\n-----Constraints-----\n- $1 \\le T \\le 50$\n- $1 \\le N \\le 10^4$\n- $1 \\le A_i, B_i \\le 10^9$ for each valid $i$\n\n-----Subtasks-----\nSubtask #1 (20 points):\n- $A_1 = A_2 = \\ldots = A_N$\n- $B_1 = B_2 = \\ldots = B_N$\nSubtask #2 (80 points): original constraints\n\n-----Example Input-----\n2\n4\n8 8 10 12\n15 20 3 5\n3\n20 20 20\n10 10 10\n\n-----Example Output-----\n30\n30\n\n-----Explanation-----\nExample case 1: Four rectangles with dimensions $8 \\times 3$, $8 \\times 5$, $10 \\times 20$ and $12 \\times 15$ lead to an optimal answer.", "starter_code": "", "test_cases": {"inputs": ["2\n4\n8 8 10 12\n15 20 3 5\n3\n20 20 20\n10 10 10"], "outputs": ["30\n30"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "8b286c0f6b0941e5d21ff363ff458edd056649e6", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-00933", "original_id": null, "source": "apps", "domain": "code", "problem": "Emily and Mia are friends. Emily got Mia’s essay paper, but since she is a prankster, she decided to meddle with the words present in the paper. She changes all the words in the paper into palindromes. To do this, she follows two rules: \n- In one operation she can only reduce the value of an alphabet by 1, i.e. she can change ‘d’ to ‘c’, but she cannot change ‘c’ to ‘d’ or ‘d’ to ‘b’. \n- The alphabet ‘a’ will not be reduced any further. \nEach reduction in the value of any alphabet is counted as a single operation. Find the minimum number of operations required to convert a given string into a palindrome.\n\n-----Input:-----\n- The first line contains an integer $T$, denoting the number of test cases. \n- Each test case consists of a string $S$ containing only lowercase characters with no spaces.\n\n-----Output:-----\nFor each test case on a new line, print the minimum number of operations for the corresponding test case.\n\n-----Constraints-----\n- $1<=T<=10$\n- $1<=|S|<=10^7$, where $|S|$ denotes length of string S.\n\n-----Sample Input:-----\n4 \nabc \nabcba \nabcd \ncba\n\n-----Sample Output:-----\n2 \n0\n4\n2\n\n-----EXPLANATION:-----\nFor the first test case string = “abc” \nc->b->a so the string become “aba” which is a palindrome. For this we perform 2 operations", "starter_code": "", "test_cases": {"inputs": ["4\nabc\nabcba\nabcd\ncba"], "outputs": ["2\n0\n4\n2"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "caf870a1de8830c04386cd079f7d33ac8ffe534b", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-00938", "original_id": null, "source": "apps", "domain": "code", "problem": "Chef is learning linear algebra. Recently, he learnt that for a square matrix $M$, $\\mathop{\\rm trace}(M)$ is defined as the sum of all elements on the main diagonal of $M$ (an element lies on the main diagonal if its row index and column index are equal).\nNow, Chef wants to solve some excercises related to this new quantity, so he wrote down a square matrix $A$ with size $N\\times N$. A square submatrix of $A$ with size $l\\times l$ is a contiguous block of $l\\times l$ elements of $A$. Formally, if $B$ is a submatrix of $A$ with size $l\\times l$, then there must be integers $r$ and $c$ ($1\\le r, c \\le N+1-l$) such that $B_{i,j} = A_{r+i-1, c+j-1}$ for each $1 \\le i, j \\le l$.\nHelp Chef find the maximum trace of a square submatrix of $A$.\n\n-----Input-----\n- The first line of the input contains a single integer $T$ denoting the number of test cases. The description of $T$ test cases follows.\n- The first line of each test case contains a single integer $N$.\n- $N$ lines follow. For each $i$ ($1 \\le i \\le N$), the $i$-th of these lines contains $N$ space-separated integers $A_{i,1}, A_{i,2}, \\dots, A_{i, N}$ denoting the $i$-th row of the matrix $A$.\n\n-----Output-----\nFor each test case, print a single line containing one integer — the maximum possible trace.\n\n-----Constraints-----\n- $1 \\le T \\le 100$\n- $2 \\le N \\le 100$\n- $1 \\le A_{i,j} \\le 100$ for each valid $i, j$\n\n-----Subtasks-----\nSubtask #1 (100 points): original constraints\n\n-----Example Input-----\n1\n3\n1 2 5\n6 3 4\n2 7 1\n\n-----Example Output-----\n13\n\n-----Explanation-----\nExample case 1: The submatrix with the largest trace is \n6 3\n2 7\n\nwhich has trace equal to $6 + 7 = 13$. (This submatrix is obtained for $r=2, c=1, l=2$.)", "starter_code": "", "test_cases": {"inputs": ["1\n3\n1 2 5\n6 3 4\n2 7 1"], "outputs": ["13"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "72e04fb4932201b55d2a3939cfb1dd9951026d04", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-00943", "original_id": null, "source": "apps", "domain": "code", "problem": "You are given a grid of size N x M consisting of '.' (empty), 'W' (white) or 'B' (black) cells. We follow the convention that the top left corner is the position (1,1) and bottom right corner is (N,M). \nFrom every '.' cell (i, j), a ray is shot towards the right. If the ray reaches a 'B' cell, it loses it's strength fully and stops there. When a ray\nreaches a 'W' cell, it's strength drops drastically so that the ray stops when it reaches a second 'W' cell. That is, if there is no 'B'\ncell in between, a ray can cross at most one 'W' cell, and it will stop when it reaches the second 'W' cell. It passes unchanged through any '.' cell. If it reaches a boundary cell (ie. (i,M), for some i), it stops there.\nLet L(i, j) be length travelled by the ray starting from the cell (i, j). If (i,j) is 'W' or 'B', no ray starts from here, and hence L(i,j) is defined to be 0. If a ray starts from (i,j) and stops at (i,k), then the distance travelled by this ray is k-j+1. i.e, inclusive of both starting and ending cells.\nFor the given grid your task is to find the sum of L(i, j) over all 1 <= i <= N and 1 <= j <= M. \nThe description of the grid is given as follows: In addition to N and M, you are given the number of 'W' cells (w) and the number of 'B' cells (b)\nand you are given the locations of these w + b cells. (The other cells contain '.')\n\n-----Constraints:-----\nFor all testcases,\n- 1 <= N, M <= 10^6. \n- 0 <= w,b <= 10^5\nSubtask 1: 15%\nIt is guaranteed that 1 <= N,M <= 500\nSubtask 2: 25%\nIt is guaranteed that 1 <= N,M <= 2000\nSubtask 3: 60%\nNo additional guarantees.\n\n-----Input format:-----\n- There is only one line of input which contains 4 + 2w + 2b space separated integers. The first four integers are N, M, w and b. \n- The next 2*w integers denote the cells which contains a 'W': x1 y1 x2 y2 .. xw yw. These denote that (xi,yi) contains 'W'.\n- The next 2*b integers denote the cells which contains a 'B': x1 y1 x2 y2 .. xb yb. These denote that (xi,yi) contains 'B'.\n- The cells which are not in the input have to be assumed to be '.' \n\n-----Output format:-----\nOutput a single integer which is the sum of L(i,j) over all 1 <= i <= N and 1 <= j <= M.\n\n-----Sample Input 1:-----\n4 4 5 2 1 3 2 1 3 2 3 3 4 3 1 4 2 3\n\n-----Sample Output 1:-----\n22\n\n-----Explanation:-----\nThe grid is:\n. . W B\nW . B .\n. W W .\n. . W .\n\nL(i,j) for each cell is:\n4 3 0 0\n0 2 0 1\n3 0 0 1\n4 3 0 1\n\nTherefore, the total is 22.\n\n-----Note:-----\nAs the answer might be large, please use 64 bit integers (long long int in C/C++ and long in Java) instead of 32 bit int.", "starter_code": "", "test_cases": {"inputs": ["4 4 5 2 1 3 2 1 3 2 3 3 4 3 1 4 2 3"], "outputs": ["22"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "39e33db385e65e6b5e164025899adb8b8d40d0e4", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-00948", "original_id": null, "source": "apps", "domain": "code", "problem": "Chef has just started Programming, he is in first year of Engineering. Chef is reading about Relational Operators. \n\nRelational Operators are operators which check relatioship between two values. Given two numerical values A and B you need to help chef in finding the relationship between them that is, \n\n- First one is greater than second or,\n- First one is less than second or,\n- First and second one are equal.\n\n-----Input-----\nFirst line contains an integer T, which denotes the number of testcases. Each of the T lines contain two integers A and B. \n\n-----Output-----\nFor each line of input produce one line of output. This line contains any one of the relational operators\n\n'<' , '>' , '='.\n\n-----Constraints-----\n\n- 1 ≤ T ≤ 10000\n- 1 ≤ A, B ≤ 1000000001\n\n-----Example-----\nInput:\n3\n10 20\n20 10\n10 10\n\nOutput:\n<\n>\n=\n\n-----Explanation-----\nExample case 1. In this example 1 as 10 is lesser than 20.", "starter_code": "", "test_cases": {"inputs": ["3\n10 20\n20 10\n10 10"], "outputs": ["<\n>\n="]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "a01f05d95413269efd32b43a8799d10f569345aa", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-00953", "original_id": null, "source": "apps", "domain": "code", "problem": "The Chef has bought $N$ boxes of Tiles. The number of tiles present in $i^{th}$ box is $i$ ($i $ varies from $1$ to $N$) . The Chef has two houses with $N$ rooms each, whose floors is a square with area $(i*i)$ ,i varies from $(1....N)$. He want to distribute equal number of tiles from $i^{th}$ box to any two rooms (each room must belong to one house ) such that all tiles of $i^ { th}$ box is used and floor of both rooms of different houses are tiled completely.\nSince chef is busy doing some other works so he wants your help to count the total number of rooms of both houses that will be tiled completely.\nNote $:$ size of each tile present in boxes has length and breadth equal to $1$. It is not mandatory to use all the boxes.\nA room should be tilled completely from a single box.\n\n-----Input:-----\n- First line will contain $T$, number of testcases. Then the testcases follow. \n- Each testcase contains one integer $N$.\n\n-----Output:-----\nFor each testcase print the total number of rooms of both houses that will be tiled completely.\n\n-----Constraints-----\n- $1 \\leq T \\leq 5000$\n- $1 \\leq N \\leq 10^{12}$\n\n-----Sample Input:-----\n1\n16\n\n-----Sample Output:-----\n4\n\n-----EXPLANATION:-----\nThe room $1$ and $2$ of both the houses are completely tiled.", "starter_code": "", "test_cases": {"inputs": ["1\n16"], "outputs": ["4"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "22049f3050b23881cd2238d5a1c09a966ff88eb6", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-00958", "original_id": null, "source": "apps", "domain": "code", "problem": "Raj is suffering from shot term memory loss so he is unable to remember his laptop password but he has a list of some string and the only thing that he remember about his password is alphanumeric and also that all the characters are unique.\nGiven a list of strings, your task is to find a valid password.\n\n-----Input-----\nEach String contains lower case alphabets and 0-9.\n\n-----Output-----\nprint \"Invalid\"(without quotes) if password is not valid else print \"Valid\"(without quotes) and stop processing input after it.\n\n-----Constraints-----\n1<=length of string <=100\n\n-----Example-----\nInput:\nabsdbads\nasdjenfef\ntyerbet\nabc564\n\nOutput:\nInvalid\nInvalid\nInvalid\nValid", "starter_code": "", "test_cases": {"inputs": ["absdbads\nasdjenfef\ntyerbet\nabc564"], "outputs": ["Invalid\nInvalid\nInvalid\nValid"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "382104e21c9478a28481d2daf04376fb3bd44957", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-00963", "original_id": null, "source": "apps", "domain": "code", "problem": "You are given an equilateral triangle ΔABC with the side BC being the base. Each side of the triangle is of length L. There are L-1 additional points on each of the sides dividing the sides into equal parts of unit lengths. Points on the sides of the triangle are called major points. Joining these points with lines parallel to the sides of ΔABC will produce some more equilateral triangles. The intersection points of these parallel lines are called minor points. \n\nLook at the picture below. It contains \n\n- Major points: A, B, C, P1, P2, Q1, Q3, R1, R4, S1, S2, S3 (note that we consider A, B, C as major points as well)\n- Minor points: Q2, R2, R3\n- Equilateral triangles ΔP1Q1Q2, ΔQ2S1S3, etc\n\nWe consider an equilateral triangle to be valid if\n\n- Each of its vertices is either a major or a minor point, and\n- The distance from its base (the base of a triangle is the side parallel to BC) to BC is less than the distance from the other vertex of the triangle (i.e. opposite vertex that doesn't lie on the base of triangle) to BC.\n\nIn the figure above, ΔQ2P1P2 is not a valid triangle but ΔQ2R2R3 is a valid triangle.\n\nYou will be given L, the length of the original triangle ΔABC. You need to find out the number of valid equilateral triangles with side length exactly K.\n\n-----Input-----\n- The first line of the input contains an integer T denoting the number of test cases. The description of each testcase follows.\n- Each test case has one line containing two space-separated integers: L and K.\n\n-----Output-----\nFor each testcase, print \"Case i: \", and then the answer, where i is the testcase number, 1-indexed.\n\n-----Constraints-----\n- 1 ≤ T ≤ 500\n- 1 ≤ L, K ≤ 5000\n\n-----Example-----\nInput:\n2\n4 3\n4 4\n\nOutput:\nCase 1: 3\nCase 2: 1\n\n-----Explanation-----\n\nThe figure presented in the problem description is a triangle with side length 4.\nIn testcase 1, the valid triangles are ΔAR1R4, ΔP1BS3, ΔP2S1C\n\nIn testcase 2, the only valid triangle is ΔABC", "starter_code": "", "test_cases": {"inputs": ["2\n4 3\n4 4"], "outputs": ["Case 1: 3\nCase 2: 1"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "303b7dc72e152cf16d062159c03faccee91a1c76", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-00968", "original_id": null, "source": "apps", "domain": "code", "problem": "The government of Siruseri has just commissioned one of the longest and most modern railway routes in the world. This route runs the entire length of Siruseri and passes through many of the big cities and a large number of small towns and villages in Siruseri.\nThe railway stations along this route have all been constructed keeping in mind the comfort of the travellers. Every station has big parking lots, comfortable waiting rooms and plenty of space for eateries. The railway authorities would like to contract out the catering services of these eateries.\nThe Siruseri Economic Survey has done a through feasibility study of the different stations and documented the expected profits (or losses) for the eateries in all the railway stations on this route. The authorities would like to ensure that every station is catered to. To prevent caterers from bidding only for profitable stations, the authorities have decided to give out catering contracts for contiguous segments of stations.\nThe minister in charge realises that one of the bidders is his bitter adversary and he has decided to hand out as useless a segment as possible to him. On the other hand, he does not want to be seen to be blatantly unfair by handing out a large loss-making section to the adversary. Instead he wants to find the largest segment whose sum is closest to $0$, so that his adversary spends all his time running a large number of canteens and makes either a small loss or a small profit or, even better, nothing at all!\nIn other words, if the profits/losses at the stations are $p_1, p_2, ..., p_N$ the minister would like to handover a sequence $i, i+1, ..., j$ such that the absolute value of $p_i + p_{i+1} + ... + p_j$ is minimized. If there is more than one sequence with this minimum absolute value then he would like to hand over the longest one.\nFor example, suppose there are $8$ stations along the line and their profitability is as follows:\n$ $\nStation 1 2 3 4 5 6 7 8 \nExpected Profits -20 90 -30 -20 80 -70 -60 125 \n\n$ $\nIf the adversary is awarded the section $1$ through $4$, he will make a net profit of $20$. On the other hand if he is given stations $6, 7$ and $8$, he will make loss of $5$ rupees. This is the best possible value.\n\n-----Input:-----\nThe first line of the input contains a single integer $N$ indicating the number of stations. The next $N$ lines (lines $2, 3, ..., N+1$) describe the profitability of the $N$ stations. Line $i+1$ contains a single integer denoting the expected profit at station $i$.\n\n-----Output:-----\nThe first line contains a single integer indicating the minimum possible profit/loss among all segments. The second line contains two integers indicating the starting and ending point of the longest sequence with this minimum profit/loss. If there is more than one answer, it suffices to print one.\n\n-----Constraints:-----\n- $1 \\leq N \\leq 100000$.\n- $-10^9 \\leq p_i \\leq 10^9$\n\n-----Subtasks-----\n- Subtask 1 - 40% - $1 \\leq N \\leq 4000$\n- Subtask 2 - 60% - Original constraints\n\n-----Sample Input-----\n8\n-20\n90\n-30\n-20\n80\n-70\n-60\n125\n\n-----Sample Output-----\n-5\n6 8", "starter_code": "", "test_cases": {"inputs": ["8\n-20\n90\n-30\n-20\n80\n-70\n-60\n125"], "outputs": ["-5\n6 8"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "74c6b9f96cc803739573c315a5df7c8539f0754d", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-00973", "original_id": null, "source": "apps", "domain": "code", "problem": "Sometimes Sergey visits fast food restaurants. Today he is going to visit the one called PizzaKing.\nSergey wants to buy N meals, which he had enumerated by integers from 1 to N. He knows that the meal i costs Ci rubles. He also knows that there are M meal sets in the restaurant.\nThe meal set is basically a set of meals, where you pay Pj burles and get Qj meals - Aj, 1, Aj, 2, ..., Aj, Qj.\nSergey has noticed that sometimes he can save money by buying the meals in the meal sets instead of buying each one separately. And now he is curious about what is the smallest amount of rubles he needs to spend to have at least one portion of each of the meals.\n\n-----Input-----\nThe first line of the input contains an integer T denoting the number of test cases. The description of T test cases follows.\nThe first line of each test case contains a pair of integer numbers N and M denoting the number of meals and the number of the meal sets.\nThe second line contains N space-separated integers C1, C2, ..., CN denoting the costs of the meals, bought separately.\nEach of the following M lines starts with a pair of integer numbers Pi and Qi, denoting the cost of the meal set and the number of meals in it, followed with the integer numbers Ai, 1 Ai, 2, ..., Ai, Qi denoting the meal numbers.\n\n-----Output-----\nFor each test case, output a single line containing the minimal total amount of money Sergey needs to spend in order to have at least one portion of each meal.\n\n-----Constraints-----\n- 1 ≤ Pi, Ci ≤ 106\n- 1 ≤ M ≤ min{2N, 2 × 100000}\n- No meal appears in the set twice or more times.\n- Subtask 1 (16 points): 1 ≤ T ≤ 103, 1 ≤ N ≤ 8\n- Subtask 2 (23 points): For each test file, either 1 ≤ T ≤ 10, 1 ≤ N ≤ 12 or the constraints for Subtask 1 are held.\n- Subtask 3 (61 points): For each test file, either T = 1, 1 ≤ N ≤ 18 or the constraints for Subtask 1 or 2 are held.\n\n-----Example-----\nInput:1\n3 3\n3 5 6\n11 3 1 2 3\n5 2 1 2\n5 2 1 3\n\nOutput:10\n\n-----Explanation-----\nExample case 1. If Sergey buys all the meals separately, it would cost him 3 + 5 + 6 = 14 rubles. He can buy all of them at once by buying the first meal set, which costs for 11 rubles, but the optimal strategy would be either to buy the second and the third meal set, thus, paying 5 + 5 = 10 rubles, or to buy the third meal set and the second meal separately by paying the same amount of 10 rubles.", "starter_code": "", "test_cases": {"inputs": ["1\n3 3\n3 5 6\n11 3 1 2 3\n5 2 1 2\n5 2 1 3"], "outputs": ["10"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "ac5ceb081110a4cf8180613babab59fec9ce19d7", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-00978", "original_id": null, "source": "apps", "domain": "code", "problem": "-----General Statement:-----\nRead a number in scientific notation and output its equivalent decimal value.\n\n-----Input:-----\nAll data is on a single line. The first integer indicates how many pairs of numbers follow. The first of each pair is A, the base number, and the second is E, the power of 10.\n\n-----Output:-----\nRound each answer to 2 decimal places. Trailing zeros to the right of the decimal point are required. A leading zero to the left of the decimal point is not required.\nThe output is to be formatted exactly like that for the sample output given below.\n\n-----Assumptions:-----\nE is in the range –10 .. 10. A is 1 or larger but less than 10.\nDiscussion: \nIf A = 3.926 and E = 4, the number represented is 3.926 X 104 or 39260, which is 39260.00 when rounded to 2 decimal places.\n\n-----Sample Input:-----\n4 4.296 3 3.8 -2 1.8 2 2.8678 1\n\n-----Sample Output:-----\n4296.00\n0.04\n180.00\n28.68", "starter_code": "", "test_cases": {"inputs": ["4 4.296 3 3.8 -2 1.8 2 2.8678 1"], "outputs": ["4296.00\n0.04\n180.00\n28.68"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "d33834820968529fe76e610afa4cdfff30849eb4", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-00983", "original_id": null, "source": "apps", "domain": "code", "problem": "Chef Watson uses a social network called ChefBook, which has a new feed consisting of posts by his friends. Each post can be characterized by f - the identifier of the friend who created the post, p - the popularity of the post(which is pre-calculated by ChefBook platform using some machine learning algorithm) and s - the contents of the post which is a string of lower and uppercase English alphabets.\nAlso, Chef has some friends, which he has marked as special.\nThe algorithm used by ChefBook for determining the order of posts in news feed is as follows:\n\n- Posts of special friends should be shown first, irrespective of popularity. Among all such posts the popular ones should be shown earlier.\n- Among all other posts, popular posts should be shown earlier.\n\nGiven, a list of identifiers of Chef's special friends and a list of posts, you have to implement this algorithm for engineers of ChefBook and output the correct ordering of posts in the new feed. \n\n-----Input-----\nFirst line contains N, number of special friends of Chef and M, the number of posts. Next line contains N integers A1, A2, ..., AN denoting the identifiers of special friends of Chef. Each of the next M lines contains a pair of integers and a string denoting f, p and s, identifier of the friend who created the post, the popularity of the post and the contents of the post, respectively. It is guaranteed that no two posts have same popularity, but the same friend might make multiple posts.\n\n-----Output-----\nOutput correct ordering of posts in news feed in M lines. Output only the contents of a post.\n\n-----Constraints-----\n- 1 ≤ N, M ≤ 103\n- 1 ≤ Ai, f, p ≤ 105\n- 1 ≤ length(s) ≤ 100\n\n-----Example-----\nInput:\n2 4\n1 2\n1 1 WhoDoesntLoveChefBook\n2 2 WinterIsComing\n3 10 TheseViolentDelightsHaveViolentEnds\n4 3 ComeAtTheKingBestNotMiss\n\nOutput:\nWinterIsComing\nWhoDoesntLoveChefBook\nTheseViolentDelightsHaveViolentEnds\nComeAtTheKingBestNotMiss\n\n-----Explanation-----\n\nFirst we should show posts created by friends with identifiers 1 and 2. Among the posts by these friends, the one with more popularity should be shown first.\n\nAmong remaining posts, we show those which are more popular first.", "starter_code": "", "test_cases": {"inputs": ["2 4\n1 2\n1 1 WhoDoesntLoveChefBook\n2 2 WinterIsComing\n3 10 TheseViolentDelightsHaveViolentEnds\n4 3 ComeAtTheKingBestNotMiss"], "outputs": ["WinterIsComing\nWhoDoesntLoveChefBook\nTheseViolentDelightsHaveViolentEnds\nComeAtTheKingBestNotMiss"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "47bde56b21b6c0d063023d850506e10dc4f1f632", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-00988", "original_id": null, "source": "apps", "domain": "code", "problem": "Chef owns an icecream shop in Chefland named scoORZ. There are only three types of coins in Chefland: Rs. 5, Rs. 10 and Rs. 15. An icecream costs Rs. 5.\nThere are $N$ people (numbered $1$ through $N$) standing in a queue to buy icecream from scoORZ. Each person wants to buy exactly one icecream. For each valid $i$, the $i$-th person has one coin with value $a_i$. It is only possible for someone to buy an icecream when Chef can give them back their change exactly ― for example, if someone pays with a Rs. 10 coin, Chef needs to have a Rs. 5 coin that he gives to this person as change.\nInitially, Chef has no money. He wants to know if he can sell icecream to everyone in the queue, in the given order. Since he is busy eating his own icecream, can you tell him if he can serve all these people?\n\n-----Input-----\n- The first line of the input contains a single integer $T$ denoting the number of test cases. The description of $T$ test cases follows.\n- The first line of each test case contains a single integer $N$.\n- The second line contains $N$ space-separated integers $a_1, a_2, \\ldots, a_N$.\n\n-----Output-----\nFor each test case, print a single line containing the string \"YES\" if all people can be served or \"NO\" otherwise (without quotes).\n\n-----Constraints-----\n- $1 \\le T \\le 100$\n- $1 \\le N \\le 10^3$\n- $a_i \\in \\{5, 10, 15\\}$ for each valid $i$\n\n-----Subtasks-----\nSubtask #1 (40 points): $a_i \\in \\{5, 10\\}$ for each valid $i$\nSubtask #2 (60 points): original constraints\n\n-----Example Input-----\n3\n2\n5 10\n2\n10 5\n2\n5 15\n\n-----Example Output-----\nYES\nNO\nNO\n\n-----Explanation-----\nExample case 1: The first person pays with a Rs. 5 coin. The second person pays with a Rs. 10 coin and Chef gives them back the Rs. 5 coin (which he got from the first person) as change.\nExample case 2: The first person already cannot buy an icecream because Chef cannot give them back Rs. 5.\nExample case 3: The first person pays with a Rs. 5 coin. The second person cannot buy the icecream because Chef has only one Rs. 5 coin, but he needs to give a total of Rs. 10 back as change.", "starter_code": "", "test_cases": {"inputs": ["3\n2\n5 10\n2\n10 5\n2\n5 15\n"], "outputs": ["YES\nNO\nNO"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "d0fe50312b36b245fb47d7b4e135754a6440600c", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-00993", "original_id": null, "source": "apps", "domain": "code", "problem": "Master Shifu is training Po to become The Dragon Warrior and as a final assignment he must obtain maximum deliciousness from dumplings. There are $N$ plates of dumplings in front of him with deliciousness $A_1, A_2, \\ldots, A_N$, Po can choose any number of continuous plates of dumplings. The total deliciousness is the sum of deliciousness of all the chosen dumplings.\nWhat is the minimum number of plates he must choose so that total deliciousness is maximum possible?\nNote: Po must choose atleast one plate.\n\n-----Input:-----\n- The first line of the input contains a single integer $T$ denoting the number of test cases. The description of $T$ test cases follows.\n- The first line of each test case contains a single integer $N$.\n- The second line contains $N$ space-separated integers $A_1, A_2, \\ldots, A_N$.\n\n-----Output:-----\nFor each test case, print a single line containing one integer.\n\n-----Constraints-----\n- $1 \\le T \\le 10$\n- $1 \\le N \\le 2 \\cdot 10^5$\n- $0 \\le A_i \\le 10^9$\n\n-----Sample Input:-----\n2\n4\n1 2 3 4\n5\n3 2 0 3 0\n\n-----Sample Output:-----\n4\n4", "starter_code": "", "test_cases": {"inputs": ["2\n4\n1 2 3 4\n5\n3 2 0 3 0"], "outputs": ["4\n4"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "21ee3edf701198cf88371e90b30f0697f44ff21c", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-00998", "original_id": null, "source": "apps", "domain": "code", "problem": "Chef made $N$ pieces of cakes, numbered them $1$ through $N$ and arranged them in a row in this order. There are $K$ possible types of flavours (numbered $1$ through $K$); for each valid $i$, the $i$-th piece of cake has a flavour $A_i$.\nChef wants to select a contiguous subsegment of the pieces of cake such that there is at least one flavour which does not occur in that subsegment. Find the maximum possible length of such a subsegment of cakes.\n\n-----Input-----\n- The first line of the input contains a single integer $T$ denoting the number of test cases. The description of $T$ test cases follows.\n- The first line of each test case contains two integers $N$ and $K$.\n- The second line contains $N$ space-separated integers $A_1, A_2, \\ldots, A_N$.\n\n-----Output-----\nFor each test case, print a single line containing one integer ― the maximum length of a valid subsegment.\n\n-----Constraints-----\n- $1 \\le T \\le 1,000$\n- $1 \\le N \\le 10^5$\n- $2 \\le K \\le 10^5$\n- $1 \\le A_i \\le K$ for each valid $i$\n- the sum of $N$ over all test cases does not exceed $10^6$\n\n-----Subtasks-----\nSubtask #1 (50 points):\n- $N \\le 10^3$\n- $K = 2$\n- the sum of $N$ over all test cases does not exceed $10^4$\nSubtask #2 (50 points): original constraints\n\n-----Example Input-----\n2\n6 2\n1 1 1 2 2 1\n5 3\n1 1 2 2 1\n\n-----Example Output-----\n3\n5", "starter_code": "", "test_cases": {"inputs": ["2\n6 2\n1 1 1 2 2 1\n5 3\n1 1 2 2 1"], "outputs": ["3\n5"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "641964322aee477a08121e3ecfe36f015f7ba3c5", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-01003", "original_id": null, "source": "apps", "domain": "code", "problem": "The chef was searching for his pen in the garage but he found his old machine with a display and some numbers on it. If some numbers entered then some different output occurs on the display. Chef wants to crack the algorithm that the machine is following.\nExample to identify the pattern :\nInput Output\n9 36\n5 10\n1 0\n2 1\n\n-----Input:-----\n- First-line will contain $T$, the number of test cases. Then the test cases follow. \n- Each test case contains a single line of input, $N$. \n\n-----Output:-----\nFor each test case, output in a single line answer as displayed on the screen.\n\n-----Constraints-----\n- $1 \\leq T \\leq 10^6$\n- $1 \\leq N \\leq 10^6$\n\n-----Sample Input:-----\n1\n7\n\n-----Sample Output:-----\n21", "starter_code": "", "test_cases": {"inputs": ["1\n7"], "outputs": ["21"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "a0f55e341c3043483440324013f5038dc1034e5f", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-01008", "original_id": null, "source": "apps", "domain": "code", "problem": "In India, every individual is charged with income tax on the total income each year. This tax is applied to specific ranges of income, which are called income tax slabs. The slabs of income tax keep changing from year to year. This fiscal year (2020-21), the tax slabs and their respective tax rates are as follows:Total income (in rupees)Tax rateup to Rs. 250,0000%from Rs. 250,001 to Rs. 500,0005%from Rs. 500,001 to Rs. 750,00010%from Rs. 750,001 to Rs. 1,000,00015%from Rs. 1,000,001 to Rs. 1,250,00020%from Rs. 1,250,001 to Rs. 1,500,00025%above Rs. 1,500,00030%\nSee the sample explanation for details on how the income tax is calculated.\nYou are given Chef's total income: $N$ rupees (Rs.). Find his net income. The net income is calculated by subtracting the total tax (also called tax reduction) from the total income. Note that you do not need to worry about any other kind of tax reductions, only the one described above.\n\n-----Input-----\n- The first line of the input contains a single integer $T$ denoting the number of test cases. The description of $T$ test cases follows.\n- The first and only line of each test case contains a single integer $N$.\n\n-----Output-----\nFor each test case, print a single line containing one integer — Chef's net income.\n\n-----Constraints-----\n- $1 \\le T \\le 10^3$\n- $0 \\le N \\le 10^7$\n- $N$ is a multiple of $100$\n\n-----Example Input-----\n2\n600000\n250000\n\n-----Example Output-----\n577500\n250000\n\n-----Explanation-----\nExample case 1: We know that the total income is Rs. $6$ lakh ($1$ lakh rupees = $10^5$ rupees). The total tax for each slab is calculated as follows:\n- Up to $2.5$ lakh, the tax is Rs. $0$, since the tax rate is $0$ percent.\n- From above Rs. $2.5$ lakh to Rs. $5$ lakh, the tax rate is $5$ percent. Therefore, this tax is $0.05 \\cdot (500,000-250,000)$, which is Rs. $12,500$.\n- From above Rs. $5$ lakh to Rs. $6$ lakh, the tax rate is $10$ percent. Therefore, this tax is $0.10 \\cdot (600,000-500,000)$, which is Rs. $10,000$.\n- Summing them up, we get that the total tax on Chef's whole income is Rs. $22,500$. Since the net income is the total income minus the tax reduction, it is Rs. $600,000$ minus Rs. $22,500$, which is Rs. $577,500$.\nExample case 2: For income up to Rs. $2.5$ lakh, we have no tax, so the net income is the same as the total income: Rs. $2.5$ lakh.", "starter_code": "", "test_cases": {"inputs": ["2\n600000\n250000"], "outputs": ["577500\n250000"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "ebe6872e3c34cae3b43489de0cd68273eb371668", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-01013", "original_id": null, "source": "apps", "domain": "code", "problem": "Chef's pizza is the tastiest pizza to exist, and the reason for that is his special, juicy homegrown tomatoes. \nTomatoes can be grown in rectangular patches of any side lengths. However, Chef only has a limited amount of land. \nConsider the entire town of Chefville to be consisting of cells in a rectangular grid of positive coordinates. \nChef own all cells (x,y)$(x, y)$ that satisfy x∗y≤N$x*y \\leq N$\nAs an example if N=4$N = 4$, Chef owns the following cells: \n(1,1),(1,2),(1,3),(1,4),(2,1),(2,2),(3,1),(4,1)$(1, 1), (1, 2), (1, 3), (1, 4), (2, 1), (2, 2), (3, 1), (4, 1) $\nChef can only grow tomatoes in rectangular patches consisting only of cells which belong to him. Also, if he uses a cell, he must use it entirely. He cannot use only a portion of it. \nHelp Chef find the number of unique patches of rectangular land that he can grow tomatoes in! Since this number can be very large, output it modulo 1000000007$1000000007$.\n\n-----Input:-----\n- The first line of the input contains T$T$, the number of test cases.\n- The next T$T$ lines of input contains one integer N$N$.\n\n-----Output:-----\nFor each testcase, output the number of ways modulo 1000000007$1000000007$.\n\n-----Constraints-----\n- 1≤T≤5$1 \\leq T \\leq 5$\n- 1≤N≤1010$1 \\leq N \\leq 10^{10}$\n\n-----Sample Input:-----\n2\n4\n10000000000\n\n-----Sample Output:-----\n23\n227374950", "starter_code": "", "test_cases": {"inputs": ["2\n4\n10000000000"], "outputs": ["23\n227374950"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "755bcb24543b2c71640078508f1dc20848c13feb", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-01018", "original_id": null, "source": "apps", "domain": "code", "problem": "Give me Chocolate\n\nAnushka wants to buy chocolates.there are many chocolates in front of her, tagged with their prices.\n\nAnushka has only a certain amount to spend, and she wants to maximize the number of chocolates she buys with this money.\n\nGiven a list of prices and an amount to spend, what is the maximum number of chocolates Anushka can buy? \n\nFor example, \n\nif prices =[1,2,3,4]\nand Anushka has k=7 to spend, she can buy items [1,2,3] for 6 , or [3,4] for 7 units of currency. she would choose the first group of 3 items.\n\nInput Format\n\nThe first line contains two integers, n and k , the number of priced chocolates and the amount Anushka has to spend.\n\nThe next line contains n space-separated integers prices[i]\n\nConstraints\n\n1<= n <= 105\n\n1<= k <= 109\n\n1<= prices[i] <= 109\n\n\n\nA chocolate can't be bought multiple times.\n\nOutput Format\n\nAn integer that denotes the maximum number of chocolates Anushka can buy for her.\n\nSample Input\n\n7 50\n\n1 12 5 111 200 1000 10\n\nSample Output\n\n4\n\nExplanation\n\nshe can buy only 4 chocolatess at most. These chocolates have the following prices: 1, 12, 5, 10.", "starter_code": "", "test_cases": {"inputs": ["7 50\n1 12 5 111 200 1000 10"], "outputs": ["4"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "0182f2e367e1dc802b98fd7b03839db00f759690", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-01023", "original_id": null, "source": "apps", "domain": "code", "problem": "Motu and Patlu are racing against each other on a circular track of radius $R$. Initially they are at the same point on the track and will run in same direction .The coach ordered them to run $X$ rounds of the circular field. Patlu wants to know how many times they will meet after the race starts and before any of them finishes $X$ rounds. But he is busy in warm up so he wants you to calculate this. You are given speed of both Motu and Patlu ($A$ and $B$). \n\n-----Input:-----\n- First line will contain $T$, number of testcases. Then the testcases follow. \n- Each testcase contains of a single line of input, four integers $X, R, A, B$. \n\n-----Output:-----\nFor each testcase, output in a single line answer the number of times whey will meet before any of them completes $X$ rounds.\n\n-----Constraints-----\n- $1 \\leq T \\leq 1000$\n- $1 \\leq R \\leq 10^9$\n- $1 \\leq X \\leq 10^9$\n- $1 \\leq A \\leq 10^9$\n- $1 \\leq B \\leq 10^9$\n- Speed of both are different\n\n-----Sample Input:-----\n2\n3 10 2 5\n2 20 5 10\n\n-----Sample Output:-----\n1\n0", "starter_code": "", "test_cases": {"inputs": ["2\n3 10 2 5\n2 20 5 10"], "outputs": ["1\n0"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "ed7dc52353f6c00f3e0b62b858b012d40b76326b", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-01028", "original_id": null, "source": "apps", "domain": "code", "problem": "Mr. Wilson was planning to record his new Progressive Rock music album called \"Digits. Cannot. Separate\". Xenny and PowerShell, popular pseudo-number-theoreticists from the Land of Lazarus were called by him to devise a strategy to ensure the success of this new album. Xenny and Powershell took their Piano Lessons and arrived at the Studio in different Trains.\nMr. Wilson, creative as usual, had created one single, long music track S. The track consisted of N musical notes. The beauty of each musical note was represented by a decimal digit from 0 to 9.\nMr. Wilson told them that he wanted to create multiple musical tracks out of this long song. Since Xenny and Powershell were more into the number theory part of music, they didn’t know much about their real workings. Mr. Wilson told them that a separator could be placed between 2 digits. After placing separators, the digits between 2 separators would be the constituents of this new track and the number formed by joining them together would represent the Quality Value of that track. He also wanted them to make sure that no number formed had greater than M digits.\nMr. Wilson had Y separators with him. He wanted Xenny and PowerShell to use at least X of those separators, otherwise he would have to ask them to Drive Home.\nXenny and PowerShell knew straight away that they had to put place separators in such a way that the Greatest Common Divisor (GCD) of all the Quality Values would eventually determine the success of this new album. Hence, they had to find a strategy to maximize the GCD.\nIf you find the maximum GCD of all Quality Values that can be obtained after placing the separators, Xenny and PowerShell shall present you with a Porcupine Tree.\nNote:\n- \nYou can read about GCD here.\n\n- \nGreatest Common Divisor of 0 and 0 is defined as 0.\n\n-----Input-----\nThe first line of input consists of a single integer T - the number of testcases.\nEach test case is of the following format:\nFirst line contains a single integer N - the length of the long musical track.\nSecond line contains the string of digits S.\nThird line contains 3 space-separated integers - M, X and Y - the maximum number of digits in a number, the minimum number of separators to be used and the maximum number of separators to be used.\n\n-----Output-----\nFor each testcase, output a single integer on a new line - the maximum GCD possible after placing the separators.\n\n-----Constraints-----\nSubtask 1: 20 points\n\n- 1 ≤ T ≤ 10\n- 1 ≤ N ≤ 18\n- 1 ≤ M ≤ 2\n- 1 ≤ X ≤ Y ≤ (N - 1)\n\nSubtask 2: 80 points\n\n- 1 ≤ T ≤ 10\n- 1 ≤ N ≤ 300\n- 1 ≤ M ≤ 10\n- 1 ≤ X ≤ Y ≤ (N - 1)\n\nFor both Subtask 1 and Subtask 2:\n\n- 1 ≤ X ≤ Y ≤ (N - 1)\n- M*(Y+1) ≥ N\n- S may contain leading 0s.\n\n-----Example-----Input:\n2\n3\n474\n2 1 1\n34\n6311861109697810998905373107116111\n10 4 25\n\nOutput:\n2\n1\n\n-----Explanation-----\nTest case 1. \nSince only 1 separator can be placed, we can only have 2 possibilities:\n\na. 4 | 74\n\nThe GCD in this case is 2.\n\nb. 47 | 4\n\nThe GCD in this case is 1.\n\nHence, the maximum GCD is 2.\nTest case 2.\n\nOne of the optimal partitions is:\n63|118|61|109|69|78|109|98|90|53|73|107|116|111\nBonus: Decode the above partition to unlock a hidden treasure.", "starter_code": "", "test_cases": {"inputs": ["2\n3\n474\n2 1 1\n34\n6311861109697810998905373107116111\n10 4 25"], "outputs": ["2\n1"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "c16062b06f0a16e66029b6a27db3bccad420db5f", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-01033", "original_id": null, "source": "apps", "domain": "code", "problem": "Pied Piper is a startup company trying to build a new Internet called Pipernet. Currently, they have $A$ users and they gain $X$ users everyday. There is also another company called Hooli, which has currently $B$ users and gains $Y$ users everyday.\nWhichever company reaches $Z$ users first takes over Pipernet. In case both companies reach $Z$ users on the same day, Hooli takes over.\nHooli is a very evil company (like E-Corp in Mr. Robot or Innovative Online Industries in Ready Player One). Therefore, many people are trying to help Pied Piper gain some users.\nPied Piper has $N$ supporters with contribution values $C_1, C_2, \\ldots, C_N$. For each valid $i$, when the $i$-th supporter contributes, Pied Piper gains $C_i$ users instantly. After contributing, the contribution value of the supporter is halved, i.e. $C_i$ changes to $\\left\\lfloor C_i / 2 \\right\\rfloor$. Each supporter may contribute any number of times, including zero. Supporters may contribute at any time until one of the companies takes over Pipernet, even during the current day.\nFind the minimum number of times supporters must contribute (the minimum total number of contributions) so that Pied Piper gains control of Pipernet.\n\n-----Input-----\n- The first line of the input contains a single integer $T$ denoting the number of test cases. The description of $T$ test cases follows.\n- The first line of each test case contains six space-separated integers $N$, $A$, $B$, $X$, $Y$ and $Z$.\n- The second line contains $N$ space-separated integers $C_1, C_2, \\ldots, C_N$ — the initial contribution values.\n\n-----Output-----\nFor each test case, if Hooli will always gain control of Pipernet, print a single line containing the string \"RIP\" (without quotes). Otherwise, print a single line containing one integer — the minimum number of times supporters must contribute.\n\n-----Constraints-----\n- $1 \\le T \\le 10$\n- $1 \\le N \\le 10^5$\n- $1 \\le A, B, X, Y, Z \\le 10^9$\n- $A, B < Z$\n- $0 \\le C_i \\le 10^9$ for each valid $i$\n\n-----Example Input-----\n3\n3 10 15 5 10 100\n12 15 18\n3 10 15 5 10 100\n5 5 10\n4 40 80 30 30 100\n100 100 100 100\n\n-----Example Output-----\n4\nRIP\n1\n\n-----Explanation-----\nExample case 1: After $8$ days, Pied Piper will have $50$ users and Hooli will have $95$ users. Then, if each supporter contributes once, Pied Piper will also have $95$ users. After that, they still need $5$ more users, so supporter $3$ can contribute again, with $18/2 = 9$ more users. So the answer will be $4$.\nExample case 2: There is no way to beat Hooli.", "starter_code": "", "test_cases": {"inputs": ["3\n3 10 15 5 10 100\n12 15 18\n3 10 15 5 10 100\n5 5 10\n4 40 80 30 30 100\n100 100 100 100"], "outputs": ["4\nRIP\n1"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "e4317ed20ac22a624d0372ba873755b213c671de", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-01038", "original_id": null, "source": "apps", "domain": "code", "problem": "There's a tree and every one of its nodes has a cost associated with it. Some of these nodes are labelled special nodes. You are supposed to answer a few queries on this tree. In each query, a source and destination node (SNODE$SNODE$ and DNODE$DNODE$) is given along with a value W$W$. For a walk between SNODE$SNODE$ and DNODE$DNODE$ to be valid you have to choose a special node and call it the pivot P$P$. Now the path will be SNODE$SNODE$ ->P$ P$ -> DNODE$DNODE$. For any valid path, there is a path value (PV$PV$) attached to it. It is defined as follows:\nSelect a subset of nodes(can be empty) in the path from SNODE$SNODE$ to P$P$ (both inclusive) such that sum of their costs (CTOT1$CTOT_{1}$) doesn't exceed W$W$.\nSelect a subset of nodes(can be empty) in the path from P$P$ to DNODE$DNODE$ (both inclusive) such that sum of their costs (CTOT2$CTOT_{2}$) doesn't exceed W$W$.\nNow define PV=CTOT1+CTOT2$PV = CTOT_{1} + CTOT_{2}$ such that the absolute difference x=|CTOT1−CTOT2|$x = |CTOT_{1} - CTOT_{2}|$ is as low as possible. If there are multiple pairs of subsets that give the same minimum absolute difference, the pair of subsets which maximize PV$PV$ should be chosen.\nFor each query, output the path value PV$PV$ minimizing x$x$ as defined above. \nNote that the sum of costs of an empty subset is zero.\n\n-----Input-----\n- First line contains three integers N$N$ - number of vertices in the tree, NSP$NSP$ - number of special nodes in the tree and Q$Q$ - number of queries to answer. \n- Second line contains N−1$N-1$ integers. If the i$i$th integer is Vi$V_i$ then there is an undirected edge between i+1$i + 1$ and Vi$V_i$ (i$i$ starts from 1$1$ and goes till N−1$N-1$). \n- Third line contains N$N$ integers, the i$i$th integer represents cost of the i$i$th vertex. \n- Fourth line contains NSP$NSP$ integers - these represent which nodes are the special nodes. \n- Following Q$Q$ lines contains three integers each - SNODE$SNODE$, DNODE$DNODE$ and W$W$ for each query.\n\n-----Output-----\nFor each query output a single line containing a single integer - the path value PV$PV$ between SNODE$SNODE$ and DNODE$DNODE$.\n\n-----Constraints:-----\n- 1≤$1 \\leq $ Number of nodes ≤1000$ \\leq 1000 $ \n- 0≤W≤1000$ 0 \\leq W \\leq 1000 $ \n- 1≤$ 1 \\leq $ Number of special nodes ≤10$ \\leq 10 $ \n- 0≤$ 0 \\leq $ Cost of each node ≤1000$ \\leq 1000 $ \n- 1≤$ 1 \\leq $ Number of queries ≤1000$ \\leq 1000 $\n\n-----Sample Input-----\n7 1 5\n\n1 1 2 2 3 3\n\n3 5 4 2 7 9 1\n\n1\n\n2 3 100\n\n1 1 100\n\n2 1 100\n\n4 5 100\n\n4 7 100 \n\n-----Sample Output:-----\n6\n\n6\n\n6\n\n20\n\n16 \n\n-----Explanation:-----\nConsider query 4$4$. The only path is 4−>2−>1−>2−>5$4->2->1->2->5$. The two sets defined for this path are {3,2,5${3,2,5}$} and {3,5,7${3,5,7}$}. Pick subsets {3,2,5${3,2,5}$} and {3,7${3,7}$} from each set which minimizes PV$PV$. Note that node 2$2$ can repeat as it is in different paths (both to and from the pivot).", "starter_code": "", "test_cases": {"inputs": ["7 1 5\n1 1 2 2 3 3\n3 5 4 2 7 9 1\n1\n2 3 100\n1 1 100\n2 1 100\n4 5 100\n4 7 100"], "outputs": ["6\n6\n6\n20\n16"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "892e315563da602d21e201062eca7384731a963f", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-01043", "original_id": null, "source": "apps", "domain": "code", "problem": "Chef is baking a cake.\n\nWhile baking, in each minute the size of cake doubles as compared to its previous size.\n\nIn this cake, baking of cake is directly proportional to its size.\nYou are given $a$, the total time taken(in minutes) to bake the whole cake.\n\nLet cake be half baked at $k^{th}$ minute. \nYour task is to find the value of $k+2$.\n\n-----Input:-----\n- The first line of the input contains a single integer $T$ denoting the number of test cases. The description of T test cases follows. \n- The first and only line of each test case contains a single integer $a$.\n\n-----Output:-----\nFor each testcase , print one line, the value of $k+2$.\n\n-----Constraints-----\n- $1 \\leq T \\leq 8 $\n- $2 \\leq a \\leq 10^{128}$\n\n-----Sample Input:-----\n1\n\n2\n\n-----Sample Output:-----\n3\n\n-----Explaination-----\nTime was 1 min when cake was half baked by chef so answer is 1+2=3", "starter_code": "", "test_cases": {"inputs": ["1\n2"], "outputs": ["3"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "37926e74ad65f9da0ee068194f595c377aa1449f", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-01048", "original_id": null, "source": "apps", "domain": "code", "problem": "Leha is a usual student at 'The Usual University for Usual Students'. Sometimes he studies hard; at other times he plays truant and gets busy with other things besides academics. He has already studied at the university for N months. For the ith month (1 ≤ i ≤ N), he has received some non-negative integer grade A[i].\nNow he wants to analyse his progress for some periods of his university education. An arbitrary period, defined by two positive integers L and R, begins at Leha's Lth month at the university and ends at the Rth. The analysis is performed via the following steps.\n\n1. Write down all the grades for each month from L to R and sort them. Let's call the sorted list S.\n\n2. Calculate the sum of squared differences of consecutive elements in S, that is, (S[2] - S[1])2 + (S[3] - S[2])2 + ... + (S[R-L+1] - S[R-L])2.\n\n-----Input-----\nThe first line contains one integer N — the number of months Leha has already studied at the university.\nThe second line contains N integers — list A of Leha's grades.\nThe third line contains one integer M — the number of periods Leha is interested in analyzing.\nEach of the following M lines contain two integers L and R describing each period.\n\n-----Output-----\nFor each query, output one integer — the result of the progress analysis for the corresponding period.\n\n-----Constraints-----\n- 1 ≤ N, M ≤ 5*104\n- 0 ≤ A[i] ≤ 106\n\n-----Subtasks-----\n- Subtask 1 (19 points) 1 ≤ N, M ≤ 200, time limit = 2 sec\n- Subtask 2 (31 points) 1 ≤ N, M ≤ 10 000, time limit = 2 sec\n- Subtask 3 (26 points) 0 ≤ A[i] ≤ 100, time limit = 5 sec\n- Subtask 4 (24 points) no additional constraints, , time limit = 5 sec\n\n-----Example-----\nInput:5\n1 3 2 4 5\n5\n1 5\n1 4\n2 4\n3 3\n3 5\n\nOutput:4\n3\n2\n0\n5\n\nExplanation\n\nThe first query: sorted array looks like (1, 2, 3, 4, 5) and the answer is calculated as (2-1)2 + (3-2)2 + (4-3)2 + (5-4)2 = 4\n\nThe second query: sorted array looks like (1, 2, 3, 4) and the answer is calculated as (2-1)2 + (3-2)2 + (4-3)2 = 3\n\nThe last query: sorted array looks like (2, 4, 5) and the answer is calculated as (4-2)2 + (5-4)2 = 5", "starter_code": "", "test_cases": {"inputs": ["5\n1 3 2 4 5\n5\n1 5\n1 4\n2 4\n3 3\n3 5"], "outputs": ["4\n3\n2\n0\n5"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "aa3ef7ad895644f18e906678ce671a370070eb00", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-01053", "original_id": null, "source": "apps", "domain": "code", "problem": "The name of our college is \"Government College of Engineering and Textile Technology Berhampore\". There is another college named \"Government College of Engineering and Textile Technology Serampore\". As the names are quite similar, those who are unaware of existence of both the colleges, often get confused. And mistake one with other.\n\nGiven a string, if it contains the word berhampore (case insensitive), print GCETTB or if it contains serampore(case-insensitive), print GCETTS . If the string contains neither print Others. If it contains both Berhampore and Serampore print Both \nInput \n- First line contains single integer T, No. of test case \n- Next line for every test contain case a string S \nOutput\n\nPrint GCETTB or GCETTS or Others or Both on a new line\nConstraints \n- 1 <= T <= 10 \n- 0 <= len(S) <= 100 \n- S contain a-z and A-Z and space only\nSample Input\n3\nGovernment clg Berhampore\nSeRaMporE textile college \nGirls college Kolkata\n\nSample Output\n\nGCETTB\n\nGCETTS\n\nOthers \nExplanation\n\nSelf-Explanatory", "starter_code": "", "test_cases": {"inputs": ["3\nGovernment clg Berhampore\nSeRaMporE textile college\nGirls college Kolkata"], "outputs": ["GCETTB\nGCETTS\nOthers"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "1c92f066319b9258d3e5b7a4613f94fd79b0a1f1", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-01058", "original_id": null, "source": "apps", "domain": "code", "problem": "Ahmed Gafer failed to pass the test, but he got the job because of his friendship with Said and Shahhoud. After working in the kitchen for a while, he blew it. The customers didn't like the food anymore and one day he even burned the kitchen. Now the master Chef is very upset.\nAhmed isn't useful anymore at being a co-Chef, so S&S decided to give him a last chance. They decided to give Ahmed a new job, and make him work as the cashier of the restaurant. Nevertheless, in order not to repeat their previous mistake, they decided to give him a little test to check if his counting skills are good enough for the job. The problem is as follows: \nGiven a string A of lowercase English letters, Ahmad was asked to find the number of good substrings.\nA substring A[L, R] is good if:\n\n- The length of the substring is exactly 2 and AL = AR, OR\n- The length of the substring is greater than 2,AL = AR and the substring A[L + 1, R - 1] has only one distinct letter.\n\nAnyways, Ahmed struggled trying to find a solution for the problem. Since his mathematical skills are very poor as it turned out, he decided to cheat and contacted you asking for your help. Can you help him in this challenge?\n\n-----Input-----\nThe first line of the input contains the integer T, indicating the number of test cases.\nEach of the following T lines, contains a string A.\n\n-----Output-----\nFor each test case, output a single line containing a single number, indicating the number of good substrings.\n\n-----Constraints-----\n\n- 1 ≤ T ≤ 100 \n- 1 ≤ |A| ≤ 105 \n- It's guaranteed that the sum of |A| over all test cases doesn't exceed 5x105. \n\n-----Example-----\nInput:\n2\na\nabba\n\nOutput:\n0\n2\n\n\n-----Explanation-----\nExample case 2. The good substrings of abba are: { bb } and { abba }.", "starter_code": "", "test_cases": {"inputs": ["2\na\nabba"], "outputs": ["0\n2"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "afc40f38bbdc6c3c229a634acd35e53f31a5643e", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-01063", "original_id": null, "source": "apps", "domain": "code", "problem": "Let's define a periodic infinite sequence S$S$ (0$0$-indexed) with period K$K$ using the formula Si=(i%K)+1$S_i = (i \\% K) + 1$.\nChef has found a sequence of positive integers A$A$ with length N$N$ buried underground. He suspects that it is a contiguous subsequence of some periodic sequence. Unfortunately, some elements of A$A$ are unreadable. Can you tell Chef the longest possible period K$K$ of an infinite periodic sequence which contains A$A$ (after suitably filling in the unreadable elements) as a contiguous subsequence?\n\n-----Input-----\n- The first line of the input contains a single integer T$T$ denoting the number of test cases. The description of T$T$ test cases follows.\n- The first line of each test case contains a single integer N$N$. \n- The second line contains N$N$ space-separated integers A1,A2,…,AN$A_1, A_2, \\dots, A_N$. Unreadable elements are denoted by −1$-1$.\n\n-----Output-----\nFor each test case, print a single line.\n- If the period can be arbitrarily large, this line should contain a single string \"inf\".\n- Otherwise, if A$A$ cannot be a contiguous subsequence of a periodic sequence, it should contain a single string \"impossible\".\n- Otherwise, it should contain a single integer — the maximum possible period.\n\n-----Constraints-----\n- 1≤T≤100$1 \\le T \\le 100$\n- 2≤N≤105$2 \\le N \\le 10^5$\n- the sum of N$N$ over all test cases does not exceed 106$10^6$\n- for each valid i$i$, 1≤Ai≤106$1 \\le A_i \\le 10^6$ or Ai=−1$A_i = -1$\n\n-----Subtasks-----\nSubtask #1 (50 points):\n- 2≤N≤1,000$2 \\le N \\le 1,000$\n- the sum of N$N$ over all test cases does not exceed 10,000$10,000$\nSubtask #2 (50 points): original constraints\n\n-----Example Input-----\n3\n3\n-1 -1 -1\n5\n1 -1 -1 4 1\n4\n4 6 7 -1\n\n-----Example Output-----\ninf\n4\nimpossible", "starter_code": "", "test_cases": {"inputs": ["3\n3\n-1 -1 -1\n5\n1 -1 -1 4 1\n4\n4 6 7 -1"], "outputs": ["inf\n4\nimpossible"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "5e115487fdf083b3268a6b77a89aa1e3416e4bb2", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-01068", "original_id": null, "source": "apps", "domain": "code", "problem": "Young Sheldon is given the task to teach Chemistry to his brother Georgie. After teaching him how to find total atomic weight, Sheldon gives him some formulas which consist of $x$, $y$ and $z$ atoms as an assignment. \nYou already know that Georgie doesn't like Chemistry, so he want you to help him solve this assignment.\nLet the chemical formula be given by the string $S$. It consists of any combination of x, y and z with some value associated with it as well as parenthesis to encapsulate any combination. Moreover, the atomic weight of x, y and z are 2, 4 and 10 respectively.\nYou are supposed to find the total atomic weight of the element represented by the given formula.\nFor example, for the formula $(x_2y_2)_3z$, given string $S$ will be: $(x2y2)3z$. Hence, substituting values of x, y and z, total atomic weight will be \n$(2*2+4*2)*3 + 10 = 46$.\n\n-----Input:-----\n- First line will contain $T$, number of testcases. Then the testcases follow. \n- Each testcase contains of a single line of input $S$. \n\n-----Output:-----\nFor each testcase, output in a single line, the total atomic weight.\n\n-----Constraints-----\n- $1 \\leq T \\leq 100$\n- Length of string $S \\leq 100$\n- String contains $x, y, z, 1, 2,..., 9$ and parenthesis\n\n-----Sample Input:-----\n2\n(xy)2\nx(x2y)3(z)2\n\n-----Sample Output:-----\n12\n46", "starter_code": "", "test_cases": {"inputs": ["2\n(xy)2\nx(x2y)3(z)2"], "outputs": ["12\n46"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "bf3f3c07ca930466ad7e849dc8d208f07a6103ba", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-01073", "original_id": null, "source": "apps", "domain": "code", "problem": "Rahul is a serial killer. Rahul has been betrayed by his lover in the past and now he want to eliminate entire Universe.He has already Eliminated majority of the population and now only a handful number of people are left. Like other Serial killers, he has an interesting pattern of killing people. \nHe either kill one individual at a time or if he find two individuals of different heights,he eliminates both of them simultaneously. Now Rahul wants to eliminate them as quickly as he can.\nSo given $N$ as the number of people left and an array containing height of those $N$ people,tell the minimum number of kills Rahul require to eliminate the entire universe.\n\n-----Input:-----\n- First line will contain $T$, number of testcases. Then the testcases follow. \n- Each test case constitutes of Two lines. \n- First line contains $N$, representing the number of people left in the universe\n- The second line contains an array $a[i]$ of size $N$ containing heights of those $N$ people.\n\n-----Output:-----\nFor each testcase, you have to output a Single line Containing the minimum number of kills required by Rahul to eliminate the Universe.\n\n-----Constraints-----\n- $1 \\leq T \\leq 50000$\n- $1 \\leq N \\leq 50000$\n- $100 \\leq a[i] \\leq 10^5$\n\n-----Sample Input:-----\n1\n10\n178 184 178 177 171 173 171 183 171 175\n\n-----Sample Output:-----\n5", "starter_code": "", "test_cases": {"inputs": ["1\n10\n178 184 178 177 171 173 171 183 171 175"], "outputs": ["5"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "fe179b9b45e763000cf0bfc357deb739f0d14061", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-01078", "original_id": null, "source": "apps", "domain": "code", "problem": "After completing some serious investigation, Watson and Holmes are now chilling themselves in the Shimla hills. Very soon Holmes became bored. Holmes lived entirely for his profession. We know he is a workaholic. So Holmes wants to stop his vacation and get back to work. But after a tiresome season, Watson is in no mood to return soon. So to keep Holmes engaged, he decided to give Holmes one math problem. And Holmes agreed to solve the problem and said as soon as he solves the problem, they should return back to work. Watson too agreed. \nThe problem was as follows. Watson knows Holmes’ favorite numbers are 6 and 5. So he decided to give Holmes N single digit numbers. Watson asked Holmes to form a new number with the given N numbers in such a way that the newly formed number should be completely divisible by 5 and 6. Watson told Holmes that he should also form the number from these digits in such a way that the formed number is maximum. He may or may not use all the given numbers. But he is not allowed to use leading zeros. Though he is allowed to leave out some of the numbers, he is not allowed to add any extra numbers, which means the maximum count of each digit in the newly formed number, is the same as the number of times that number is present in those given N digits.\n\n-----Input-----\nThe first line of input contains one integers T denoting the number of test cases.\nEach test case consists of one integer N, number of numbers.\nNext line contains contains N single digit integers \n\n-----Output-----\nFor each test case output a single number, where the above said conditions are satisfied. If it is not possible to create such a number with the given constraints print -1.If there exists a solution, the maximised number should be greater than or equal to 0. \n\n-----Constraints-----\n- 1 ≤ T ≤ 100\n- 1 ≤ N ≤ 10000\n- 0 ≤ Each digit ≤ 9\n\n-----Subtasks-----\nSubtask #1 : (90 points)\n- 1 ≤ T ≤ 100\n- 1 ≤ N ≤ 10000\n\nSubtask 2 : (10 points) \n\n- 1 ≤ T ≤ 10\n- 1 ≤ N≤ 10\n\n-----Example-----\nInput:\n2\n12\n3 1 2 3 2 0 2 2 2 0 2 3\n11\n3 9 9 6 4 3 6 4 9 6 0\n\nOutput:\n33322222200\n999666330", "starter_code": "", "test_cases": {"inputs": ["2\n12\n3 1 2 3 2 0 2 2 2 0 2 3\n11\n3 9 9 6 4 3 6 4 9 6 0"], "outputs": ["33322222200\n999666330"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "1b7f508ced4987763655a2120517561b9ed27ccb", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-01083", "original_id": null, "source": "apps", "domain": "code", "problem": "Your are given a string $S$ containing only lowercase letter and a array of character $arr$. Find whether the given string only contains characters from the given character array. \nPrint $1$ if the string contains characters from the given array only else print $0$.\nNote: string contains characters in lower case only.\n\n-----Input:-----\n- First line will contain $T$, number of testcases. Then the testcases follow. \n- Each testcase contains- \na string $S$ of lowercase letter\na integer $n$ denoting length of character array $arr$\nnext line contains $n$ space separated characters.\n\n-----Output:-----\nFor each testcase, Print $1$ if the string contains characters from the given array only else print $0$.\n\n-----Constraints-----\n- $1 \\leq T \\leq 1000$\n- $0 \\leq n \\leq 10^5$\n\n-----Sample Input:-----\n3\nabcd\n4\na b c d\naabbbcccdddd\n4\na b c d\nacd\n3\na b d\n\n-----Sample Output:-----\n1\n1\n0", "starter_code": "", "test_cases": {"inputs": ["3\nabcd\n4\na b c d\naabbbcccdddd\n4\na b c d\nacd\n3\na b d"], "outputs": ["1\n1\n0"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "f42693279b5817f381c7f0479b006cd8f9059bc2", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-01088", "original_id": null, "source": "apps", "domain": "code", "problem": "You are given a grid with dimension $n$ x $m$ and two points with coordinates $X(x1,y1)$ and $Y(x2,y2)$ . Your task is to find the number of ways in which one can go from point $A(0, 0)$ to point $B (n, m)$ using the $shortest$ possible path such that the shortest path neither passes through $X$ nor through $Y$. \n\nConsider the above 4 x 4 grid . Our shortest path can't pass through points (1,3) and (3,3) (marked by yellow dots). One of the possible shortest path is from $A$ to $C$ and then from $C$ to $B$.\n\n-----Input:-----\n- First line contains $T$, number of testcases. Then the testcases follow. \n- Each testcase contains of a single line of input, six space separated integers $n, m, x1, y1, x2, y2$. \n\n-----Output:-----\n- For each testcase, output in a single line number of ways modulo $998244353$.\n\n-----Constraints-----\n- $1 \\leq T \\leq 10^5$\n- $3 \\leq n,m \\leq 10^5$\n- $1 \\leq x1, x2 \\leq n - 1$\n- $1 \\leq y1, y2 \\leq m - 1$\n- $x1 \\leq x2$\n- $y1 \\leq y2$\n- $X$ and $Y$ never coincide.\n\n-----Sample Input:-----\n1\n3 3 1 1 1 2\n\n-----Sample Output:-----\n5", "starter_code": "", "test_cases": {"inputs": ["1\n3 3 1 1 1 2"], "outputs": ["5"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "529c67715ac43ab8c2ac237dc5cd4cbe49549300", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-01093", "original_id": null, "source": "apps", "domain": "code", "problem": "Raj is a math pro and number theory expert. One day, he met his age-old friend Chef. Chef claimed to be better at number theory than Raj, so Raj gave him some fuzzy problems to solve. In one of those problems, he gave Chef a 3$3$-tuple of non-negative integers (a0,b0,c0)$(a_0, b_0, c_0)$ and told Chef to convert it to another tuple (x,y,z)$(x, y, z)$.\nChef may perform the following operations any number of times (including zero) on his current tuple (a,b,c)$(a, b, c)$, in any order:\n- Choose one element of this tuple, i.e. a$a$, b$b$ or c$c$. Either add 1$1$ to that element or subtract 1$1$ from it. The cost of this operation is 1$1$.\n- Merge: Change the tuple to (a−1,b−1,c+1)$(a-1, b-1, c+1)$, (a−1,b+1,c−1)$(a-1, b+1, c-1)$ or (a+1,b−1,c−1)$(a+1, b-1, c-1)$, i.e. add 1$1$ to one element and subtract 1$1$ from the other two. The cost of this operation is 0$0$.\n- Split: Change the tuple to (a−1,b+1,c+1)$(a-1, b+1, c+1)$, (a+1,b−1,c+1)$(a+1, b-1, c+1)$ or (a+1,b+1,c−1)$(a+1, b+1, c-1)$, i.e. subtract 1$1$ from one element and add 1$1$ to the other two. The cost of this operation is also 0$0$.\nAfter each operation, all elements of Chef's tuple must be non-negative. It is not allowed to perform an operation that would make one or more elements of this tuple negative.\nCan you help Chef find the minimum cost of converting the tuple (a0,b0,c0)$(a_0, b_0, c_0)$ to the tuple (x,y,z)$(x, y, z)$? It can be easily proved that it is always possible to convert any tuple of non-negative integers to any other.\n\n-----Input-----\n- The first line of the input contains a single integer T$T$ denoting the number of test cases. The description of T$T$ test cases follows.\n- The first and only line of each test case contains six space-separated integers a0$a_0$, b0$b_0$, c0$c_0$, x$x$, y$y$ and z$z$.\n\n-----Output-----\nFor each test case, print a single line containing one integer ― the minimum cost.\n\n-----Constraints-----\n- 1≤T≤105$1 \\le T \\le 10^5$\n- 0≤a0,b0,c0,x,y,z≤1018$0 \\le a_0, b_0, c_0, x, y, z \\le 10^{18}$\n\n-----Subtasks-----\nSubtask #1 (20 points): 0≤a0,b0,c0,x,y,z≤100$0 \\le a_0, b_0, c_0, x, y, z \\le 100$\nSubtask #2 (80 points): original constraints\n\n-----Example Input-----\n2\n1 1 1 2 2 2\n1 2 3 2 4 2\n\n-----Example Output-----\n0\n1\n\n-----Explanation-----\nExample case 1: The tuple (1,1,1)$(1, 1, 1)$ can be converted to (2,2,2)$(2, 2, 2)$ using only three Split operations, with cost 0$0$: (1,1,1)→(2,0,2)→(1,1,3)→(2,2,2)$(1, 1, 1) \\rightarrow (2, 0, 2) \\rightarrow (1, 1, 3) \\rightarrow (2, 2, 2)$.\nExample case 2: We can use one addition operation and one Split operation: (1,2,3)→(1,3,3)→(2,4,2)$(1, 2, 3) \\rightarrow (1, 3, 3) \\rightarrow (2, 4, 2)$.", "starter_code": "", "test_cases": {"inputs": ["2\n1 1 1 2 2 2\n1 2 3 2 4 2"], "outputs": ["0\n1"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "504c9b77eedffdd47aeab01b781df696511d78db", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-01098", "original_id": null, "source": "apps", "domain": "code", "problem": "In order to win over and get noticed by his favorite streamer Daenerys, Jon decides to donate a significant amount of money . Every donation made to Daenerys is of $at$ $least$ $1$ $beastcoin$ and is displayed on Daenerys's stream alongside any message written and is visible to every viewer.\nAfter spotting that Daenerys had set out a target for the streaming day at minimum $X$ beastcoins, all her viewers would only donate amounts less than $X$ beastcoins. Jon decided to better all of them by straight out donating more than or equal to $X$ beastcoins. Further, he decides to write a message along with his special donation to leave her in awe. His message would be : \"Crossing my donation with any other donation will only increase the value of my donation\". By Crossing, he means to take the $XOR$ . \nBut even for all his intellectual brilliance, money doesn't grow on trees for Jon. After all he is an underpaid employee in his fancy big name MNC. Unlike Daenerys's daily cash cow who makes videos of how she donated carelessly to other people, Jon has a budget and in this case too, he is looking for the minimum donation he needs to make.\nCan you tell Jon the minimum amount he needs to donate to Daenerys so that he is able to credibly put out the above comment alongside the donation in order to HOPEFULLY win her over.\n\n-----Input Format-----\n- First line contain an interger $T$, which denotes number of testcases. Next $T$ lines contain single interger $X$. \n\n-----Output Format-----\n- For every testcase print one integer, i.e. minimum donation Jon needs to make.\n\n-----Constriants-----\n- $ 1 \\leq T \\leq 100000 $ \n- $ 2 \\leq X \\leq 10^{18} $ \n\n-----Sample Input-----\n2\n\n3\n\n7 \n\n-----Sample Output-----\n4\n\n8", "starter_code": "", "test_cases": {"inputs": ["2\n3\n7"], "outputs": ["4\n8"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "42f0627b2f6dcf9c84853b3e8ad3454d8d1c6ebd", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-01103", "original_id": null, "source": "apps", "domain": "code", "problem": "Alice and Bob created $N$ and $M$ recipes, respectively ($N, M \\ge 1$), and submitted them to Chef for evaluation. Each recipe is represented by a string containing only lowercase English letters. Let's denote Alice's recipes by $A_1, A_2, \\ldots, A_N$ and Bob's recipes by $B_1, B_2, \\ldots, B_M$.\nAccidentally, Chef mixed up those recipes ― now, he has $L = N+M$ recipes in a sequence $S_1, S_2, \\ldots, S_L$. Thankfully, the recipes created by Alice and Bob are distinguishable from each other. It is well-known that for each recipe $s$ created by Alice, the following property holds, and for each recipe created by Bob, it does not hold: For each $1 \\le l < r \\le |s|$, the substring $s_l, s_{l+1}, \\ldots, s_r$ contains at least as many vowels as consonants. The letters 'a', 'e', 'i', 'o', 'u' are vowels, while the other letters are consonants.\nThe score of a candidate who made $K$ recipes is calculated as the product of $\\frac{x_c}{fx_c^K}$ for all letters $c$ that occur in at least one of these recipes; here, $x_c$ is the number of recipes which contain the letter $c$ and $fx_c$ is the total number of occurrences of this letter in all $K$ recipes.\nLet's denote the scores of Alice and Bob by $sc_A$ and $sc_B$ respectively. Chef wants to know their ratio $sc_A/sc_B$. We know that Chef is a legendary cook, but he is not very good at calculating, so he is asking you to find that number.\n\n-----Input-----\n- The first line of the input contains a single integer $T$ denoting the number of test cases. The description of $T$ test cases follows.\n- The first line of each test case contains a single integer $L$.\n- $L$ lines follow. For each valid $i$, the $i$-th of these lines contains a single string $S_i$.\n\n-----Output-----\nFor each test case, if the ratio of scores exceeds $10^7$, print a single line containing the string \"Infinity\" (without quotes); otherwise, print a single line containing one real number $sc_A/sc_B$.\nYour answer will be considered correct if its absolute or relative error does not exceed $10^{-6}$. It is guaranteed that $sc_A/sc_B$ does not lie in the range $10^7 \\pm 10$.\n\n-----Constraints-----\n- $1 \\le T \\le 10^5$\n- $2 \\le L \\le 10^5$\n- $2 \\le |S_i| \\le 10^5$ for each valid $i$\n- for each valid $i$, $S_i$ contains only lowercase English letters\n- the sum of $|S_1| + |S_2| + \\ldots + |S_L|$ over all test cases does not exceed $10^7$\n\n-----Subtasks-----\nSubtask #1 (25 points):\n- $L \\le 10$\n- $|S_i| \\le 10$ for each valid $i$\nSubtask #2 (75 points): original constraints\n\n-----Example Input-----\n2\n4\naba\nabc\nbab\naac\n3\naba\nbaab\nabc\n\n-----Example Output-----\n1.1250000\n0.0277778\n\n-----Explanation-----\nExample case 1: The recipes \"aba\" and \"aac\" are created by Alice, while the recipes \"abc\" and \"bab\" are created by Bob. The scores are:\n- $sc_A = \\frac{x_a}{fx_a^N} \\cdot \\frac{x_b}{fx_b^N} \\cdot \\frac{x_c}{fx_c^N} = \\frac{2}{4^2} \\cdot \\frac{1}{1^2} \\cdot \\frac{1}{1^2} = \\frac{1}{8}$\n- $sc_B = \\frac{x_a}{fx_a^M} \\cdot \\frac{x_b}{fx_b^M} \\cdot \\frac{x_c}{fx_c^M} = \\frac{2}{2^2} \\cdot \\frac{2}{3^2} \\cdot \\frac{1}{1^2} = \\frac{1}{9}$\n- $\\frac{sc_A}{sc_B} = \\frac{1/8}{1/9} = 1.125$", "starter_code": "", "test_cases": {"inputs": ["2\n4\naba\nabc\nbab\naac\n3\naba\nbaab\nabc"], "outputs": ["1.1250000\n0.0277778"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "16c34a2cf6e8b458098cb6a95f5633be66252aa2", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-01108", "original_id": null, "source": "apps", "domain": "code", "problem": "You are given a weighted graph with $N$ nodes and $M$ edges. Some of the nodes are marked as special nodes. Your task is to find the shortest pairwise distance between any two different special nodes.\n\n-----Input-----\n- The first line of the input contains three space-separated integers $N$, $M$ and $K$ denoting the number of nodes, the number of edges, and the number of special nodes. \n- The next line contains $K$ space-separated distinct integers $A_{1}$, $A_{2}$, $\\ldots$, $A_{K}$, denoting the special nodes.\n- The next $M$ lines each contain three space-separated integers - $X$, $Y$, $Z$, denoting an edge connecting the nodes $X$ and $Y$, with weight $Z$.\n\n-----Output-----\nOutput the shortest pairwise distance between any two different special nodes.\n\n-----Constraints-----\n- The given graph is connected.\n- The given graph doesn't contain self loops and multiple edges.\n- $1 \\leq A_{i} \\leq N$\n- $1 \\leq Z_{j} \\leq 10^{4}$\n- $1 \\leq X_{j}, Y_{j} \\leq N$\n\n-----Subtasks-----\nSubtask #1 (20 points): \n- $2 \\leq N \\leq 300$\n- $N-1 \\leq M \\leq \\frac{N \\cdot (N-1)}{2}$\n- $2 \\leq K \\leq N$\nSubtask #2 (25 points):\n- $2 \\leq N \\leq 10^5$\n- $N-1 \\leq M \\leq 10^5$\n- $2 \\leq K \\leq 10$\nSubtask #3 (55 points):\n- $2 \\leq N \\leq 10^5$\n- $N-1 \\leq M \\leq 3 \\cdot 10^5$\n- $2 \\leq K \\leq 10^4$\n\n-----Example Input-----\n5 5 3\n1 3 5\n1 2 3\n2 3 4\n3 4 1\n4 5 8\n1 5 19\n\n-----Example Output-----\n7\n\n-----Explanation-----\nNodes $1$, $3$, and $5$ are special nodes. Shortest distance between nodes $1$ and $3$ is $7$, and that between nodes $3$ and $5$ is $9$. Shortest distance between nodes $1$ and $5$ is $16$. Minimum of these distances is $7$. Hence answer is $7$.", "starter_code": "", "test_cases": {"inputs": ["5 5 3\n1 3 5\n1 2 3\n2 3 4\n3 4 1\n4 5 8\n1 5 19"], "outputs": ["7"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "891d4af1fb061c31e1b0271c1cf261c7e274f9a3", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-01113", "original_id": null, "source": "apps", "domain": "code", "problem": "Two integers A and B are the inputs. Write a program to find GCD and LCM of A and B.\n\n-----Input-----\n\nThe first line contains an integer T, total number of testcases. Then follow T lines, each line contains an integer A and B. \n\n-----Output-----\nDisplay the GCD and LCM of A and B separated by space respectively. The answer for each test case must be displayed in a new line.\n\n-----Constraints-----\n- 1 ≤ T ≤ 1000\n- 1 ≤ A,B ≤ 1000000\n\n-----Example-----\nInput\n3 \n120 140\n10213 312\n10 30\n\nOutput\n\n20 840\n1 3186456\n10 30", "starter_code": "", "test_cases": {"inputs": ["3\n120 140\n10213 312\n10 30"], "outputs": ["20 840\n1 3186456\n10 30"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "85bb8c182a9ab9edad8fb162895f166baf440e59", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-01118", "original_id": null, "source": "apps", "domain": "code", "problem": "Chef loves triangles. But the chef is poor at maths. Given three random lengths Chef wants to find if the three sides form a right-angled triangle or not. Can you help Chef in this endeavour?\n\n-----Input:-----\n- First-line will contain $T$, the number of test cases. Then the test cases follow. \n- Each test case contains a single line of input, three Integers $A,B and C$\n\n-----Output:-----\nFor each test case, output in a single line \"YES\" if it is possible to form a triangle using the given numbers or \"NO\" if it is not possible to form a triangle.\n\n-----Constraints-----\n- $1 \\leq T \\leq 1000000$\n- $0 \\leq A,B,C \\leq 100$\n\n-----Sample Input:-----\n2\n3 4 5\n1 3 4\n\n-----Sample Output:-----\nYES\nNO\n\n-----EXPLANATION:-----\n3,4,5 forms a right-angled triangle. 1, 3 and 4 does not form a right-angled triangle.", "starter_code": "", "test_cases": {"inputs": ["2\n3 4 5\n1 3 4"], "outputs": ["YES\nNO"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "23d62325da37c7f1ef312b63bccadb909edf6ced", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-01123", "original_id": null, "source": "apps", "domain": "code", "problem": "Chef has two piles of stones with him, one has n1 stones and the other has n2 stones. Fired up by boredom, he invented a game with the two piles.\n\nBefore the start of the game Chef chooses an integer m.\n\nIn the j-th move: \n\n- He chooses a number xj such that 1 ≤ xj ≤ m, and removes xj stones from both the piles (this is only possible when both the piles have ≥ xj stones).\n- The number chosen must be unique over all the moves in the game. That is, for all k < j, xj ≠ xk. \n\nThe game stops when Chef is unable to make any more moves.\n\nChef wants to make the moves in such a way that the sum of the number of stones remaining in the two piles is minimized. Please help Chef find this.\n\n-----Input-----\n- The first line of input contains an integer T denoting the number of test cases.\n- Each test case consists of 1 line with three integers — n1, n2 and m — separated by single spaces.\n\n-----Output-----\nFor each test case, output a single line containing the minimum sum of the number of stones of two piles.\n\n-----Constraints-----\nSubtask 1 : (5 pts)\n- 1 ≤ T ≤ 100\n- 0 ≤ m ≤ 18\n- 0 ≤ n1, n2 ≤ 100\nSubtask 2 : (25 pts)\n- 1 ≤ T ≤ 1000\n- 0 ≤ m ≤ 10000\n- 0 ≤ n1, n2 ≤ 10000\nSubtask 3 : (70 pts)\n- 1 ≤ T ≤ 105\n- 0 ≤ m ≤ 109\n- 0 ≤ n1, n2 ≤ 1018\n\n-----Example-----\nInput:3\n1 1 1\n1 2 1\n4 5 2\n\nOutput:0\n1\n3\n\n-----Explanation-----\nExample case 1. : Remove 1 stone from each of the piles. Now 0 stones are remaining, so chef cannot remove any more stones from the piles. Hence, answer is 0+0 = 0\nExample case 2. : Again, remove 1 stone from both the piles to get (0,1) stones. Now chef cannot remove any more stones from pile 1, so he stops. Hence, answer is 0+1 = 1.\nExample case 3. : First remove 1 stone from both the piles to get (3,4) stones. Now, remove 2 stones from both the piles so that (1,2) stones are remaining. Now chef cannot remove any more stones owing to the condition that he cannot remove the same number of stones twice. So, the answer is 1+2 = 3.", "starter_code": "", "test_cases": {"inputs": ["3\n1 1 1\n1 2 1\n4 5 2"], "outputs": ["0\n1\n3"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "a0c7e64779c512323adf78885f01fd2a796fb5b7", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-01128", "original_id": null, "source": "apps", "domain": "code", "problem": "Anas is playing an amazing game on a grid with $N$ rows and $M$ columns. The rows are numbered $1$ through $N$ from top to bottom and the columns are numbered $1$ through $M$ from left to right.\nAnas wants to destroy this grid. To do that, he wants to send two heroes from the top left cell to the bottom right cell:\n- The first hero visits cells in row-major order: $(1,1) \\rightarrow (1,2) \\rightarrow \\ldots \\rightarrow (1,M) \\rightarrow (2,1) \\rightarrow (2,2) \\rightarrow \\ldots \\rightarrow (2,M) \\rightarrow \\ldots \\rightarrow (N,M)$.\n- The second hero visits cells in column-major order: $(1,1) \\rightarrow (2,1) \\rightarrow \\ldots \\rightarrow (N,1) \\rightarrow (1,2) \\rightarrow (2,2) \\rightarrow \\ldots \\rightarrow (N,2) \\rightarrow \\ldots \\rightarrow (N,M)$.\nWe know that each hero destroys the first cell he visits, rests in the next $K$ cells he visits without destroying them, then destroys the next cell he visits, rests in the next $K$ cells, destroys the next cell, and so on until he reaches (and rests in or destroys) the last cell he visits.\nAnas does not know the value of $K$. Therefore, for each value of $K$ between $0$ and $N \\cdot M - 1$ inclusive, he wants to calculate the number of cells that will be destroyed by at least one hero. Can you help him?\n\n-----Input-----\n- The first line of the input contains a single integer $T$ denoting the number of test cases. The description of $T$ test cases follows.\n- The first and only line of each test case contains two space-separated integers $N$ and $M$.\n\n-----Output-----\nFor each test case, print a single line containing $N \\cdot M$ space-separated integers as described above.\n\n-----Constraints-----\n- $1 \\le T \\le 100$\n- $2 \\le N, M \\le 1,000$\n- the sum of $N \\cdot M$ over all test cases does not exceed $2 \\cdot 10^6$\n\n-----Subtasks-----\nSubtask #1 (30 points):\n- $2 \\le N, M \\le 50$\n- the sum of $N \\cdot M$ over all test cases does not exceed $5,000$\nSubtask #2 (70 points): original constraints\n\n-----Example Input-----\n1\n2 3\n\n-----Example Output-----\n6 4 3 3 2 1\n\n-----Explanation-----\nExample case 1:\n- $K = 0$: All cells will be destroyed by the heroes.\n- $K = 1$: The first hero will destroy the cells $[(1,1), (1,3), (2,2)]$, while the second one will destroy the cells $[(1,1), (1,2), (1,3)]$.\n- $K = 2$: The first hero will destroy the cells $[(1,1), (2,1)]$, while the second one will destroy the cells $[(1,1), (2,2)]$.\n- $K = 3$: The first hero will destroy the cells $[(1,1), (2,2)]$, while the second one will destroy the cells $[(1,1), (1,3)]$.\n- $K = 4$: The first hero will destroy the cells $[(1,1), (2,3)]$ and the second one will also destroy the cells $[(1,1), (2,3)]$.\n- $K = 5$ : The first hero will destroy the cell $(1,1)$ and the second one will also destroy the cell $(1,1)$.", "starter_code": "", "test_cases": {"inputs": ["1\n2 3"], "outputs": ["6 4 3 3 2 1"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "677151b50cac145c6f4906e5934b9f2120a6c860", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-01133", "original_id": null, "source": "apps", "domain": "code", "problem": "A reversed arabic no is one whose digits have been written in the reversed order. However in this any trailing zeroes are omitted. The task at hand here is a simple one. You need to add two numbers which have been written in reversed arabic and return the output back in reversed arabic form, assuming no zeroes were lost while reversing.\n\n\n-----Input-----\nThe input consists of N cases. The first line of the input contains only a positive integer N. Then follow the cases. Each case consists of exactly one line with two positive integers seperated by space. These are the reversednumbers you are to add.\n\n\n-----Output-----\nFor each case, print exactly one line containing only one integer- the reversed sum of two reversed numbers. Omit any leading zeroes in the output.\n\n\n-----Example-----\nInput:\n1\n24 1\n\nOutput:\n34", "starter_code": "", "test_cases": {"inputs": ["1\n24 1"], "outputs": ["34"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "e047829aadbb8d9775ee8d1cc74c5c443bf711d1", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-01138", "original_id": null, "source": "apps", "domain": "code", "problem": "The chef is placing the laddus on the large square plat. The plat has the side of length N. Each laddu takes unit sq.unit area. Cheffina comes and asks the chef one puzzle to the chef as, how many squares can be formed in this pattern with all sides of new square are parallel to the original edges of the plate.\n\n-----Input:-----\n- First-line will contain $T$, the number of test cases. Then the test cases follow. \n- Each test case contains a single line of input, one integer $N$. \n\n-----Output:-----\nFor each test case, output in a single line answer as maximum squares on plate satisfying the condition.\n\n-----Constraints-----\n- $1 \\leq T \\leq 1000$\n- $1 \\leq N \\leq 10^5$\n\n-----Sample Input:-----\n2\n1\n2 \n\n-----Sample Output:-----\n1\n5\n\n-----EXPLANATION:-----\nFor 1) Only 1 Square\nFor 2) 4 squares with area 1 sq.unit\n1 square with area 4 sq.unit", "starter_code": "", "test_cases": {"inputs": ["2\n1\n2"], "outputs": ["1\n5"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "92e9fe0ec9f3ca45f7430d7b1b0b3c6343dd885d", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-01143", "original_id": null, "source": "apps", "domain": "code", "problem": "You must have tried to solve the Rubik’s cube. You might even have succeeded at it. Rubik’s cube is a 3x3x3 cube which has 6 different color for each face.The Rubik’s cube is made from 26 smaller pieces which are called cubies. There are 6 cubies at the centre of each face and these comprise of a single color. There are 8 cubies at the 8 corners which comprise of exactly 3 colors. The 12 reamaining cubies comprise of exactly 2 colors.\n\nApple has come up with a variation of the Rubik’s Cube, it’s the Rubik’s cuboid which has different colors on its 6 faces. The Rubik’s Cuboid comes in various sizes represented by M x N x O (M,N,O are natural numbers). Apple is giving away 100 Rubik’s cuboid for free to people who can answer a simple questions. Apple wants to know, in a Rubik’s cuboid with arbitrary dimensions, how many cubies would be there, which comprise of exactly 2 color.\n\n-----Input-----\nThe input contains several test cases.The first line of the input contains an integer T denoting the number of test cases.\n\nEach test case comprises of 3 natural numbers, M,N & O, which denote the dimensions of the Rubiks Cuboid.\n\n-----Output-----\nFor each test case you are required to output the number of cubies which comprise of 2 squares, each of which is of a different color.\n\n-----Constraints-----\n- 1 ≤ T ≤ <1000\n- 1 ≤ M ≤ <100000\n- 1 ≤ N ≤ <100000\n- 1 ≤ O ≤ <100000\n\n-----Example-----\nInput:\n1\n3\n3\n3\n\nOutput:\n\n12", "starter_code": "", "test_cases": {"inputs": ["1\n3\n3\n3"], "outputs": ["12"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "b1a35b746fc3d6396596ae166d771ea8376d8ef7", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-01148", "original_id": null, "source": "apps", "domain": "code", "problem": "Devu loves to play with his dear mouse Jerry. One day they play a game on 2 dimensional grid of dimensions n * n (n ≥ 2). Jerry is currently at coordinates (sx, sy) and wants to move to location (ex, ey) where cheese is placed by Devu. Also Devu is very cunning and has placed a bomb at location (bx, by). All these three locations are distinct. \n\nIn a single move, Jerry can go either up, down, left or right in the grid such that it never goes out of the grid. Also, it has to avoid the bomb. Find out minimum number of moves Jerry needs. It is guaranteed that it is always possible to do so.\n\n-----Input-----\n- The first line of the input contains an integer T denoting the number of test cases. The description of T test cases follows.\"\n- The first line of each test case contains seven space separated integers n, sx, sy , ex, ey, bx, by. \n\n-----Output-----\n- For each test case, output a single line containing an integer corresponding to minimum number of moves Jerry needs.\n\n-----Constraints-----\n- 1 ≤ T ≤ 1000\n- 2 ≤ n ≤ 20\n- 1 ≤ sx, sy , ex, ey, bx, by ≤ n \n- No two or more poitns in the three points are same.\n\n-----Example-----\nInput:\n2\n2 1 1 2 2 1 2\n3 1 1 1 3 1 2\n\nOutput:\n2\n4\n\n-----Explanation-----\nExample case 1. ...\nJerry will move directly (1, 1) to (2, 1) and then to (2, 2) in total 2 moves.\n\nExample case 2. ...", "starter_code": "", "test_cases": {"inputs": ["2\n2 1 1 2 2 1 2\n3 1 1 1 3 1 2"], "outputs": ["2\n4"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "3cd87f9aa7efe50dd131b5760e907ed13222766e", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-01153", "original_id": null, "source": "apps", "domain": "code", "problem": "Mance Rayder, the King-Beyond-the-Wall, has always wanted to lead the largest army the North has ever seen against the NIght’s Watch. For this humungous feat he has banded the waring tribes, the Giants, Thenns and Wildings, together by going to great extents. But the King is facing with an issue he always saw it coming.\nThe huge army is divided into smaller divisions and each division can be of the type $G, T$ or $W$ standing for Giants, Thenns and Wildings respectively. Mance doesn’t want two divisions of the same type standing together as he fears it might lead to a mutiny or an unorganised charge or retreat. \nFor a given numbers of $G, T$ and $W$, find whether an army can be organised in accordance to the rules set by Mance. Not to forget that Mance has to include all the divisions in his battle formation in order to stand a chance against the Wall’s defences.\n\n-----Input:-----\n- First line will contain $N$, the number of test cases.\n- Each of the next $N$ lines will contain three integers $G$, $T$ and $W$ - the number of Giant, Thenn and Wildling divisions respectively.\n\n-----Output:-----\nFor each testcase, output in a single line $Yes$ if a battle formation is possible or $No$ otherwise.\n\n-----Constraints-----\n- $1 \\leq N \\leq 100$\n- $1 \\leq G,T,W \\leq 10^9$\n\n-----Sample Input:-----\n1\n1 2 1\n\n-----Sample Output:-----\nYes\n\n-----Explanation:-----\nThe first case can be formed as : $ TGWT $. Hence the answer is $ Yes $.", "starter_code": "", "test_cases": {"inputs": ["1\n1 2 1"], "outputs": ["Yes"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "d149afe83e4266461c7dfa62f96ec88a01e452a2", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-01158", "original_id": null, "source": "apps", "domain": "code", "problem": "Nobody outside the cooking community knows that Chef is a big fan of Chefgram™ — a social network where chefs and cooks upload their secret kitchen photos.\nRecently Chef clicked a beautiful photo, which is represented using 10 pixels in a single row. Respecting Chefgram™'s boolean roots, every pixel is either white or black.\n\nChefgram™ has N filters. Every filter is a string containing 10 symbols. Every symbol is either '+' or '-'.\n\n- A '+' at the ith position in a filter means that if Chef applies this filter to his photo, the ith pixel will be inverted: it becomes black if it was originally white, and vice versa. \n- A '-' at the ith position in a filter string means that if Chef applies this filter to his photo, the ith pixel will remain unchanged.\n\nChef can apply as many filters as he wants from a list. He can pick any subset of filters and consequently apply them to a photo.\n\nFor example:\n\n- Imagine that Chef has a photo \"bbwwbbwwbb\" (where 'b' stands for black and 'w' stands for white).\n- He applies filters \"++--++--++\", \"-+-+-+-+-+\".\n- Applying the first filter will transform his picture to \"wwwwwwwwww\". \n- Applying the second filter on the transformed picture will give Chef the picture \"wbwbwbwbwb\".\n\nEven if Chefgram™ has two or more identical filters, they are still considered different!\n\nChef is extremely interested in knowing how many different subsets of all the Chefgram™ filters can he apply to transform his photo into 10 black pixels?\n\n-----Input-----\n- The first line of input contains a single integer T — the number of test cases.\n- First line of each test case contains a string S. Each symbol is either 'b' or 'w'. This is Chef's photo.\n- Second line of each test case contains a single integer N — the number of Chefgram™ filters.\n- Each of the next N lines contains a single string Fi, each symbol of which is either '+' or '-'. This string is the ith Chefgram™ filter.\n\n-----Output-----\n- For each test case, output a single line containing a single integer — answer to Chef's question modulo 109+7.\n\n-----Constraints-----\n- 1 ≤ T ≤ 5\n- |S| = 10\n- 1 ≤ N ≤ 10^5\n- |Fi| = 10\n\n-----Subtasks-----\n- Subtask 1: T ≤ 5; N ≤ 20; Points: 20\n- Subtask 2: T ≤ 5; N ≤ 10^3; Points: 30\n- Subtask 3: T ≤ 5; N ≤ 10^5; Points: 50\n\n-----Example-----\nInput:\n3\nwwwwwwwwww\n3\n+-+-+-+-+-\n----------\n+---------\nwbwbwbwbwb\n3\n+-+-+-+-+-\n+-+-------\n----+-+-+-\nbbbbbbbbbb\n2\n----------\n----------\n\nOutput:\n0\n2\n4\n\n-----Explanation-----\nExample case 1. There is no filter or combination of filters transforming the picture to whole black. \nExample case 2. Chef can either apply the first filter (and invert all whites) or apply the second and third filters in any order.\nExample case 3. Picture is already fully black, and we have two different identity filters. Chef can either apply the empty subset of filters, the first filter only, the second filter only, or both.", "starter_code": "", "test_cases": {"inputs": ["3\nwwwwwwwwww\n3\n+-+-+-+-+-\n----------\n+---------\nwbwbwbwbwb\n3\n+-+-+-+-+-\n+-+-------\n----+-+-+-\nbbbbbbbbbb\n2\n----------\n----------\n\n"], "outputs": ["0\n2\n4"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "a14cb4356be6979a710d22ac1befc9e866fd1e5a", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-01163", "original_id": null, "source": "apps", "domain": "code", "problem": "Write a function that accepts a square matrix (`N x N` 2D array) and returns the determinant of the matrix.\n\nHow to take the determinant of a matrix -- it is simplest to start with the smallest cases:\n\nA 1x1 matrix `|a|` has determinant `a`.\n\nA 2x2 matrix `[ [a, b], [c, d] ]` or\n```\n|a b|\n|c d|\n```\nhas determinant: `a*d - b*c`.\n\nThe determinant of an `n x n` sized matrix is calculated by reducing the problem to the calculation of the determinants of `n` matrices of`n-1 x n-1` size.\n\nFor the 3x3 case, `[ [a, b, c], [d, e, f], [g, h, i] ]` or\n```\n|a b c| \n|d e f| \n|g h i| \n```\nthe determinant is: `a * det(a_minor) - b * det(b_minor) + c * det(c_minor)` where `det(a_minor)` refers to taking the determinant of the 2x2 matrix created by crossing out the row and column in which the element a occurs:\n```\n|- - -|\n|- e f|\n|- h i| \n```\nNote the alternation of signs. \n\nThe determinant of larger matrices are calculated analogously, e.g. if M is a 4x4 matrix with first row `[a, b, c, d]`, then:\n\n`det(M) = a * det(a_minor) - b * det(b_minor) + c * det(c_minor) - d * det(d_minor)`", "starter_code": "\ndef determinant(matrix):\n\t", "test_cases": {"inputs": [[[[5]]]], "outputs": [[5]], "fn_name": "determinant"}, "test_case_format": "function_call", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "900167f9afbfccefaf28170233bbe97b4a84612b", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "determinant"} {"seed_id": "apps-01168", "original_id": null, "source": "apps", "domain": "code", "problem": "# Connect Four\n\nTake a look at wiki description of Connect Four game:\n\n[Wiki Connect Four](https://en.wikipedia.org/wiki/Connect_Four)\n\nThe grid is 6 row by 7 columns, those being named from A to G.\n\nYou will receive a list of strings showing the order of the pieces which dropped in columns:\n\n```python\n pieces_position_list = [\"A_Red\",\n \"B_Yellow\",\n \"A_Red\",\n \"B_Yellow\",\n \"A_Red\",\n \"B_Yellow\",\n \"G_Red\",\n \"B_Yellow\"]\n```\n\nThe list may contain up to 42 moves and shows the order the players are playing.\n\nThe first player who connects four items of the same color is the winner.\n\nYou should return \"Yellow\", \"Red\" or \"Draw\" accordingly.", "starter_code": "\ndef who_is_winner(pieces_position_list):\n\t", "test_cases": {"inputs": [[["C_Yellow", "E_Red", "G_Yellow", "B_Red", "D_Yellow", "B_Red", "B_Yellow", "G_Red", "C_Yellow", "C_Red", "D_Yellow", "F_Red", "E_Yellow", "A_Red", "A_Yellow", "G_Red", "A_Yellow", "F_Red", "F_Yellow", "D_Red", "B_Yellow", "E_Red", "D_Yellow", "A_Red", "G_Yellow", "D_Red", "D_Yellow", "C_Red"]], [["C_Yellow", "B_Red", "B_Yellow", "E_Red", "D_Yellow", "G_Red", "B_Yellow", "G_Red", "E_Yellow", "A_Red", "G_Yellow", "C_Red", "A_Yellow", "A_Red", "D_Yellow", "B_Red", "G_Yellow", "A_Red", "F_Yellow", "B_Red", "D_Yellow", "A_Red", "F_Yellow", "F_Red", "B_Yellow", "F_Red", "F_Yellow", "G_Red", "A_Yellow", "F_Red", "C_Yellow", "C_Red", "G_Yellow", "C_Red", "D_Yellow", "D_Red", "E_Yellow", "D_Red", "E_Yellow", "C_Red", "E_Yellow", "E_Red"]], [["F_Yellow", "G_Red", "D_Yellow", "C_Red", "A_Yellow", "A_Red", "E_Yellow", "D_Red", "D_Yellow", "F_Red", "B_Yellow", "E_Red", "C_Yellow", "D_Red", "F_Yellow", "D_Red", "D_Yellow", "F_Red", "G_Yellow", "C_Red", "F_Yellow", "E_Red", "A_Yellow", "A_Red", "C_Yellow", "B_Red", "E_Yellow", "C_Red", "E_Yellow", "G_Red", "A_Yellow", "A_Red", "G_Yellow", "C_Red", "B_Yellow", "E_Red", "F_Yellow", "G_Red", "G_Yellow", "B_Red", "B_Yellow", "B_Red"]], [["A_Yellow", "B_Red", "B_Yellow", "C_Red", "G_Yellow", "C_Red", "C_Yellow", "D_Red", "G_Yellow", "D_Red", "G_Yellow", "D_Red", "F_Yellow", "E_Red", "D_Yellow"]], [["A_Red", "B_Yellow", "A_Red", "B_Yellow", "A_Red", "B_Yellow", "G_Red", "B_Yellow"]]], "outputs": [["Yellow"], ["Yellow"], ["Red"], ["Red"], ["Yellow"]], "fn_name": "who_is_winner"}, "test_case_format": "function_call", "n_test_cases_total": 5, "n_test_cases_kept": 5, "test_cases_truncated": false, "problem_sha1": "26fead3f9de0ac18e7d51d45059a26a975bc3092", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "who_is_winner"} {"seed_id": "apps-01173", "original_id": null, "source": "apps", "domain": "code", "problem": "This kata generalizes [Twice Linear](https://www.codewars.com/kata/5672682212c8ecf83e000050). You may want to attempt that kata first.\n\n## Sequence\n\nConsider an integer sequence `U(m)` defined as:\n\n1. `m` is a given non-empty set of positive integers.\n2. `U(m)[0] = 1`, the first number is always 1.\n3. For each `x` in `U(m)`, and each `y` in `m`, `x * y + 1` must also be in `U(m)`.\n4. No other numbers are in `U(m)`.\n5. `U(m)` is sorted, with no duplicates.\n\n### Sequence Examples\n\n#### `U(2, 3) = [1, 3, 4, 7, 9, 10, 13, 15, 19, 21, 22, 27, ...]`\n\n1 produces 3 and 4, since `1 * 2 + 1 = 3`, and `1 * 3 + 1 = 4`.\n\n3 produces 7 and 10, since `3 * 2 + 1 = 7`, and `3 * 3 + 1 = 10`.\n\n#### `U(5, 7, 8) = [1, 6, 8, 9, 31, 41, 43, 46, 49, 57, 64, 65, 73, 156, 206, ...]`\n\n1 produces 6, 8, and 9.\n\n6 produces 31, 43, and 49.\n\n## Task:\n\nImplement `n_linear` or `nLinear`: given a set of postive integers `m`, and an index `n`, find `U(m)[n]`, the `n`th value in the `U(m)` sequence.\n\n### Tips\n\n* Tests use large n values. Slow algorithms may time-out.\n* Tests use large values in the m set. Algorithms which multiply further than neccessary may overflow.\n* Linear run time and memory usage is possible.\n* How can you build the sequence iteratively, without growing extra data structures?", "starter_code": "\ndef n_linear(m,n):\n\t", "test_cases": {"inputs": [[[2, 3], 0], [[3, 2, 5], 0], [[2, 3], 1], [[2, 3], 2], [[2, 3], 3], [[2, 3], 4], [[2, 3], 5], [[2, 3], 6], [[2, 3], 7], [[2, 3], 8], [[2, 3], 9], [[2, 3], 10], [[2, 3], 11], [[2, 3], 12], [[2, 3], 13], [[2, 3], 14], [[2, 3], 15], [[2, 3], 16], [[2, 3], 17], [[2, 3], 18], [[2, 3], 19], [[2, 3], 20], [[2, 3], 30], [[2, 3], 50], [[2, 3], 97], [[2, 3], 100], [[2, 3], 144], [[2, 3], 200], [[2, 3], 951], [[2, 3], 1000], [[5, 7, 8], 10], [[5, 7, 8], 11], [[2, 3, 4, 5], 33], [[2, 3, 4, 5], 100], [[3, 5, 7, 9, 11], 50], [[3, 5, 7, 9, 11], 70], [[3, 5, 7, 9, 11], 90], [[3, 2], 10], [[3, 2], 234], [[3, 2], 923], [[3, 2], 445], [[1, 3], 999], [[1, 5], 1000], [[5, 12], 519], [[14, 10], 56], [[2, 6], 416], [[10, 13], 741], [[3, 5], 351], [[5, 9], 246], [[8, 13], 864]], "outputs": [[1], [1], [3], [4], [7], [9], [10], [13], [15], [19], [21], [22], [27], [28], [31], [39], [40], [43], [45], [46], [55], [57], [91], [175], [406], [447], [706], [1051], [8013], [8488], [64], [65], [46], [139], [154], [226], [316], [22], [1339], [7537], [2983], [1000], [1001], [32961973], [304795], [37339], [3172655773], [58596], [1553901], [1727528929]], "fn_name": "n_linear"}, "test_case_format": "function_call", "n_test_cases_total": 87, "n_test_cases_kept": 50, "test_cases_truncated": true, "problem_sha1": "cadbec0545eef755a266b15413cc12b018113277", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "n_linear"} {"seed_id": "apps-01178", "original_id": null, "source": "apps", "domain": "code", "problem": "Story:\nIn the realm of numbers, the apocalypse has arrived. Hordes of zombie numbers have infiltrated and are ready to turn everything into undead. The properties of zombies are truly apocalyptic: they reproduce themselves unlimitedly and freely interact with each other. Anyone who equals them is doomed. Out of an infinite number of natural numbers, only a few remain. This world needs a hero who leads remaining numbers in hope for survival: The highest number to lead those who still remain.\n\nBriefing:\nThere is a list of positive natural numbers. Find the largest number that cannot be represented as the sum of this numbers, given that each number can be added unlimited times. Return this number, either 0 if there are no such numbers, or -1 if there are an infinite number of them.\n\nExample:\n```\nLet's say [3,4] are given numbers. Lets check each number one by one:\n1 - (no solution) - good\n2 - (no solution) - good\n3 = 3 won't go\n4 = 4 won't go\n5 - (no solution) - good\n6 = 3+3 won't go\n7 = 3+4 won't go\n8 = 4+4 won't go\n9 = 3+3+3 won't go\n10 = 3+3+4 won't go\n11 = 3+4+4 won't go\n13 = 3+3+3+4 won't go\n```\n...and so on. So 5 is the biggest 'good'. return 5\n\nTest specs:\nRandom cases will input up to 10 numbers with up to 1000 value\n\nSpecial thanks:\nThanks to Voile-sama, mathsisfun-sama, and Avanta-sama for heavy assistance. And to everyone who tried and beaten the kata ^_^", "starter_code": "\ndef survivor(zombies):\n\t", "test_cases": {"inputs": [[[7, 11]], [[1, 7, 15]], [[2, 10]], [[687, 829, 998]], [[]], [[1]]], "outputs": [[59], [0], [-1], [45664], [-1], [0]], "fn_name": "survivor"}, "test_case_format": "function_call", "n_test_cases_total": 6, "n_test_cases_kept": 6, "test_cases_truncated": false, "problem_sha1": "9ce1585eb85efdcb450d343e4b722986e7d9ecd8", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "survivor"} {"seed_id": "apps-01183", "original_id": null, "source": "apps", "domain": "code", "problem": "A product-sum number is a natural number N which can be expressed as both the product and the sum of the same set of numbers.\n\nN = a1 × a2 × ... × ak = a1 + a2 + ... + ak\n\nFor example, 6 = 1 × 2 × 3 = 1 + 2 + 3.\n\nFor a given set of size, k, we shall call the smallest N with this property a minimal product-sum number. The minimal product-sum numbers for sets of size, k = 2, 3, 4, 5, and 6 are as follows.\n```\nk=2: 4 = 2 × 2 = 2 + 2\nk=3: 6 = 1 × 2 × 3 = 1 + 2 + 3\nk=4: 8 = 1 × 1 × 2 × 4 = 1 + 1 + 2 + 4\nk=5: 8 = 1 × 1 × 2 × 2 × 2 = 1 + 1 + 2 + 2 + 2\nk=6: 12 = 1 × 1 × 1 × 1 × 2 × 6 = 1 + 1 + 1 + 1 + 2 + 6\n```\n\nHence for 2 ≤ k ≤ 6, the sum of all the minimal product-sum numbers is 4+6+8+12 = 30; note that 8 is only counted once in the sum.\n\nYour task is to write an algorithm to compute the sum of all minimal product-sum numbers where 2 ≤ k ≤ n.\n\nCourtesy of ProjectEuler.net", "starter_code": "\ndef productsum(n):\n\t", "test_cases": {"inputs": [[3], [6], [12], [2]], "outputs": [[10], [30], [61], [4]], "fn_name": "productsum"}, "test_case_format": "function_call", "n_test_cases_total": 4, "n_test_cases_kept": 4, "test_cases_truncated": false, "problem_sha1": "9b4281e9ec55d6c0f33e86c8d50f528d94bf0d2a", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "productsum"} {"seed_id": "apps-01188", "original_id": null, "source": "apps", "domain": "code", "problem": "## Task\n\nGiven a positive integer, `n`, return the number of possible ways such that `k` positive integers multiply to `n`. Order matters.\n\n**Examples**\n```\nn = 24\nk = 2\n(1, 24), (2, 12), (3, 8), (4, 6), (6, 4), (8, 3), (12, 2), (24, 1) -> 8\n\nn = 100\nk = 1\n100 -> 1\n\nn = 20\nk = 3\n(1, 1, 20), (1, 2, 10), (1, 4, 5), (1, 5, 4), (1, 10, 2), (1, 20, 1),\n(2, 1, 10), (2, 2, 5), (2, 5, 2), (2, 10, 1), (4, 1, 5), (4, 5, 1),\n(5, 1, 4), (5, 2, 2), (5, 4, 1), (10, 1, 2), (10, 2, 1), (20, 1, 1) -> 18\n```\n**Constraints**\n`1 <= n <= 500_000_000`\nand `1 <= k <= 1000`", "starter_code": "\ndef multiply(n, k):\n\t", "test_cases": {"inputs": [[24, 2], [100, 1], [20, 3], [1, 2], [1000000, 3], [10, 2], [36, 4]], "outputs": [[8], [1], [18], [1], [784], [4], [100]], "fn_name": "multiply"}, "test_case_format": "function_call", "n_test_cases_total": 7, "n_test_cases_kept": 7, "test_cases_truncated": false, "problem_sha1": "0d2aa938954c39c6d3fa1edaf0706449f2c2d61c", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "multiply"} {"seed_id": "apps-01193", "original_id": null, "source": "apps", "domain": "code", "problem": "We want to generate all the numbers of three digits where:\n\n- the sum of their digits is equal to 10.\n\n- their digits are in increasing order (the numbers may have two or more equal contiguous digits)\n\nThe numbers that fulfill the two above constraints are: ```118, 127, 136, 145, 226, 235, 244, 334```\n\nMake a function that receives two arguments:\n\n- the sum of digits value \n\n- the desired number of digits for the numbers\n\nThe function should output an array with three values: \\[1,2,3\\]\n\n1 - the total number of possible numbers\n\n2 - the minimum number\n\n3 - the maximum number\n\nThe example given above should be:\n\n```python\nfind_all(10, 3) == [8, 118, 334]\n```\n\nIf we have only one possible number as a solution, it should output a result like the one below:\n\n```python\nfind_all(27, 3) == [1, 999, 999]\n```\n\nIf there are no possible numbers, the function should output the empty array.\n\n```python\nfind_all(84, 4) == []\n```\n\nThe number of solutions climbs up when the number of digits increases.\n\n```python\nfind_all(35, 6) == [123, 116999, 566666]\n```\n\nFeatures of the random tests:\n\n* Number of tests: `112`\n* Sum of digits value between `20` and `65`\n* Amount of digits between `2` and `17`", "starter_code": "\ndef find_all(sum_dig, digs):\n\t", "test_cases": {"inputs": [[10, 3], [27, 3], [84, 4], [35, 6]], "outputs": [[[8, 118, 334]], [[1, 999, 999]], [[]], [[123, 116999, 566666]]], "fn_name": "find_all"}, "test_case_format": "function_call", "n_test_cases_total": 4, "n_test_cases_kept": 4, "test_cases_truncated": false, "problem_sha1": "0dbe080a43ae2522c6b725b30796cb4af871c838", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "find_all"} {"seed_id": "apps-01198", "original_id": null, "source": "apps", "domain": "code", "problem": "This kata is blatantly copied from inspired by This Kata\nWelcome\n\nthis is the second in the series of the string iterations kata!\n\nHere we go!\n\n---------------------------------------------------------------------------------\n\nWe have a string s\n\nLet's say you start with this: \"String\"\n\nThe first thing you do is reverse it: \"gnirtS\"\n\nThen you will take the string from the 1st position and reverse it again: \"gStrin\"\n\nThen you will take the string from the 2nd position and reverse it again: \"gSnirt\"\n\nThen you will take the string from the 3rd position and reverse it again: \"gSntri\"\n\nContinue this pattern until you have done every single position, and then you will return the string you have created. For this particular string, you would return: \n\"gSntir\"\n\nnow,\n\nThe Task:\n\nIn this kata, we also have a number x\n\ntake that reversal function, and apply it to the string x times.\n\n\nreturn the result of the string after applying the reversal function to it x times.\n\n example where s = \"String\" and x = 3:\n\n after 0 iteration s = \"String\"\n after 1 iteration s = \"gSntir\"\n after 2 iterations s = \"rgiStn\"\n after 3 iterations s = \"nrtgSi\"\n \n so you would return \"nrtgSi\".\n\n Note \n\nString lengths may exceed 2 million\n\n\nx exceeds a billion\n\n\nbe read to optimize\n\n\n\nif this is too hard, go here https://www.codewars.com/kata/string-%3E-n-iterations-%3E-string/java", "starter_code": "\ndef string_func(s, n):\n\t", "test_cases": {"inputs": [["This is a string exemplification!", 0], ["String for test: incommensurability", 1], ["Ohh Man God Damn", 7], ["Ohh Man God Damnn", 19], ["I like it!", 1234], ["codingisfornerdsyounerd", 10101010], ["this_test_will_hurt_you", 12345678987654321]], "outputs": [["This is a string exemplification!"], ["ySttirliinbga rfuosrn etmemsotc:n i"], [" nGOnmohaadhMD "], ["haG mnad MhO noDn"], ["iitkIl !e "], ["fonroisreinrddgdneyscou"], ["tt_rt_swuhyeihiotl_su_l"]], "fn_name": "string_func"}, "test_case_format": "function_call", "n_test_cases_total": 7, "n_test_cases_kept": 7, "test_cases_truncated": false, "problem_sha1": "5c0fb4d736cc581a275ee58bc213e37df41995df", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "string_func"} {"seed_id": "apps-01203", "original_id": null, "source": "apps", "domain": "code", "problem": "## Description\n\nGiven an array X of positive integers, its elements are to be transformed by running the following operation on them as many times as required:\n\n```if X[i] > X[j] then X[i] = X[i] - X[j]```\n\nWhen no more transformations are possible, return its sum (\"smallest possible sum\").\n\nFor instance, the successive transformation of the elements of input X = [6, 9, 21] is detailed below:\n```\nX_1 = [6, 9, 12] # -> X_1[2] = X[2] - X[1] = 21 - 9\nX_2 = [6, 9, 6] # -> X_2[2] = X_1[2] - X_1[0] = 12 - 6\nX_3 = [6, 3, 6] # -> X_3[1] = X_2[1] - X_2[0] = 9 - 6\nX_4 = [6, 3, 3] # -> X_4[2] = X_3[2] - X_3[1] = 6 - 3\nX_5 = [3, 3, 3] # -> X_5[1] = X_4[0] - X_4[1] = 6 - 3\n```\nThe returning output is the sum of the final transformation (here 9).\n\n## Example\n\n## Solution steps:\n\n## Additional notes:\n\nThere are performance tests consisted of very big numbers and arrays of size at least 30000. Please write an efficient algorithm to prevent timeout.", "starter_code": "\ndef solution(a):\n\t", "test_cases": {"inputs": [[[6, 9, 21]], [[9]], [[30, 12]], [[11, 22]], [[1, 21, 55]], [[4, 16, 24]], [[3, 13, 23, 7, 83]], [[60, 12, 96, 48, 60, 24, 72, 36, 72, 72, 48]], [[71, 71, 71, 71, 71, 71, 71, 71, 71, 71, 71, 71, 71]]], "outputs": [[9], [9], [12], [22], [3], [12], [5], [132], [923]], "fn_name": "solution"}, "test_case_format": "function_call", "n_test_cases_total": 9, "n_test_cases_kept": 9, "test_cases_truncated": false, "problem_sha1": "23536636e809bb66fa485578f69cb2c2ef94519b", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "solution"} {"seed_id": "apps-01208", "original_id": null, "source": "apps", "domain": "code", "problem": "Toad Rash has a binary string $s$. A binary string consists only of zeros and ones.\n\nLet $n$ be the length of $s$.\n\nRash needs to find the number of such pairs of integers $l$, $r$ that $1 \\leq l \\leq r \\leq n$ and there is at least one pair of integers $x$, $k$ such that $1 \\leq x, k \\leq n$, $l \\leq x < x + 2k \\leq r$, and $s_x = s_{x+k} = s_{x+2k}$.\n\nFind this number of pairs for Rash.\n\n\n-----Input-----\n\nThe first line contains the string $s$ ($1 \\leq |s| \\leq 300\\,000$), consisting of zeros and ones.\n\n\n-----Output-----\n\nOutput one integer: the number of such pairs of integers $l$, $r$ that $1 \\leq l \\leq r \\leq n$ and there is at least one pair of integers $x$, $k$ such that $1 \\leq x, k \\leq n$, $l \\leq x < x + 2k \\leq r$, and $s_x = s_{x+k} = s_{x+2k}$.\n\n\n-----Examples-----\nInput\n010101\n\nOutput\n3\n\nInput\n11001100\n\nOutput\n0\n\n\n\n-----Note-----\n\nIn the first example, there are three $l$, $r$ pairs we need to count: $1$, $6$; $2$, $6$; and $1$, $5$.\n\nIn the second example, there are no values $x$, $k$ for the initial string, so the answer is $0$.", "starter_code": "", "test_cases": {"inputs": ["010101\n", "11001100\n", "0\n", "00\n", "01\n", "000\n", "100\n", "001\n", "101\n", "0000\n", "0100101110\n", "1101111000011110111111110101100111111110111100001111011010111001101100010110000001010101101010111000\n", "1000\n", "0010\n", "1010\n", "0001\n", "1001\n", "0011\n", "1011\n"], "outputs": ["3\n", "0\n", "0\n", "0\n", "0\n", "1\n", "0\n", "0\n", "0\n", "3\n", "16\n", "4672\n", "2\n", "0\n", "0\n", "2\n", "0\n", "0\n", "0\n"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 19, "n_test_cases_kept": 19, "test_cases_truncated": false, "problem_sha1": "2acdf02ee7e8c4e4c4e35f59f8a56d6c0f198459", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-01213", "original_id": null, "source": "apps", "domain": "code", "problem": "There are N people, conveniently numbered 1 through N.\nWe want to divide them into some number of groups, under the following two conditions:\n - Every group contains between A and B people, inclusive.\n - Let F_i be the number of the groups containing exactly i people. Then, for all i, either F_i=0 or C≤F_i≤D holds.\nFind the number of these ways to divide the people into groups.\nHere, two ways to divide them into groups is considered different if and only if there exists two people such that they belong to the same group in exactly one of the two ways.\nSince the number of these ways can be extremely large, print the count modulo 10^9+7.\n\n-----Constraints-----\n - 1≤N≤10^3\n - 1≤A≤B≤N\n - 1≤C≤D≤N\n\n-----Input-----\nThe input is given from Standard Input in the following format:\nN A B C D\n\n-----Output-----\nPrint the number of ways to divide the people into groups under the conditions, modulo 10^9+7.\n\n-----Sample Input-----\n3 1 3 1 2\n\n-----Sample Output-----\n4\n\nThere are four ways to divide the people:\n - (1,2),(3)\n - (1,3),(2)\n - (2,3),(1)\n - (1,2,3)\nThe following way to divide the people does not count: (1),(2),(3). This is because it only satisfies the first condition and not the second.", "starter_code": "", "test_cases": {"inputs": ["3 1 3 1 2\n", "7 2 3 1 3\n", "1000 1 1000 1 1000\n", "10 3 4 2 5\n", "1000 1 68 1 986\n", "1000 1 934 8 993\n", "1000 1 80 2 980\n", "1000 1 467 4 942\n", "1000 739 920 1 679\n", "1000 340 423 2 935\n", "1 1 1 1 1\n", "522 155 404 151 358\n", "81 7 60 34 67\n", "775 211 497 3 226\n", "156 42 153 1 129\n"], "outputs": ["4\n", "105\n", "465231251\n", "0\n", "567116057\n", "671590509\n", "6786109\n", "999969801\n", "0\n", "0\n", "1\n", "0\n", "0\n", "0\n", "269383946\n"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 15, "n_test_cases_kept": 15, "test_cases_truncated": false, "problem_sha1": "f2200e8ae389032cbb31c65686351d08791c6660", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-01218", "original_id": null, "source": "apps", "domain": "code", "problem": "10^{10^{10}} participants, including Takahashi, competed in two programming contests.\nIn each contest, all participants had distinct ranks from first through 10^{10^{10}}-th.\nThe score of a participant is the product of his/her ranks in the two contests.\nProcess the following Q queries:\n - In the i-th query, you are given two positive integers A_i and B_i. Assuming that Takahashi was ranked A_i-th in the first contest and B_i-th in the second contest, find the maximum possible number of participants whose scores are smaller than Takahashi's.\n\n-----Constraints-----\n - 1 \\leq Q \\leq 100\n - 1\\leq A_i,B_i\\leq 10^9(1\\leq i\\leq Q)\n - All values in input are integers.\n\n-----Input-----\nInput is given from Standard Input in the following format:\nQ\nA_1 B_1\n:\nA_Q B_Q\n\n-----Output-----\nFor each query, print the maximum possible number of participants whose scores are smaller than Takahashi's.\n\n-----Sample Input-----\n8\n1 4\n10 5\n3 3\n4 11\n8 9\n22 40\n8 36\n314159265 358979323\n\n-----Sample Output-----\n1\n12\n4\n11\n14\n57\n31\n671644785\n\nLet us denote a participant who was ranked x-th in the first contest and y-th in the second contest as (x,y).\nIn the first query, (2,1) is a possible candidate of a participant whose score is smaller than Takahashi's. There are never two or more participants whose scores are smaller than Takahashi's, so we should print 1.", "starter_code": "", "test_cases": {"inputs": ["8\n1 4\n10 5\n3 3\n4 11\n8 9\n22 40\n8 36\n314159265 358979323\n", "99\n207579013 207579013\n376140463 376140463\n186969586 186969586\n326402540 326402540\n158176573 158176573\n127860890 127860890\n570870045 570870045\n178509023 178509023\n61263305 61263305\n558212775 558212775\n26389630 26389630\n496148000 496148000\n837151741 837151741\n656585276 656585276\n902071051 902071051\n727123763 727123763\n296231663 296231663\n899374334 899374334\n798571511 798571511\n799313373 799313373\n789204467 789204467\n162733265 162733265\n555253432 555253432\n181457955 181457955\n751354014 751354014\n152040411 152040411\n458000643 458000643\n164556874 164556874\n205461190 205461190\n167035009 167035009\n300206285 300206285\n775142615 775142615\n896205951 896205951\n457641319 457641319\n590064714 590064714\n909420688 909420688\n55434271 55434271\n210461043 210461043\n537850353 537850353\n614794872 614794872\n905203770 905203770\n904237002 904237002\n337246325 337246325\n150625750 150625750\n644505509 644505509\n1738704 1738704\n226102989 226102989\n122173998 122173998\n583502198 583502198\n747545899 747545899\n620479532 620479532\n541326149 541326149\n203959041 203959041\n491192255 491192255\n101365768 101365768\n960570656 960570656\n440998363 440998363\n484916146 484916146\n917826070 917826070\n607465477 607465477\n596079578 596079578\n649320809 649320809\n530909771 530909771\n666130551 666130551\n618524434 618524434\n781321609 781321609\n338249948 338249948\n116584253 116584253\n166308313 166308313\n688253174 688253174\n439133758 439133758\n163916122 163916122\n887651011 887651011\n322205909 322205909\n842842918 842842918\n77623317 77623317\n112541862 112541862\n987809421 987809421\n528855176 528855176\n546812146 546812146\n650982038 650982038\n108056513 108056513\n802439067 802439067\n593571254 593571254\n189607912 189607912\n21890134 21890134\n60051922 60051922\n928042087 928042087\n15765553 15765553\n233605234 233605234\n366127331 366127331\n861562696 861562696\n857043783 857043783\n432087162 432087162\n71055043 71055043\n588455136 588455136\n867602751 867602751\n961242387 961242387\n387771815 387771815\n", "98\n153203339 153203340\n778377584 778377585\n703186338 703186339\n53312704 53312703\n781534200 781534199\n399552959 399552960\n182061002 182061003\n228141366 228141365\n472301827 472301826\n430648520 430648519\n669286311 669286312\n927216003 927216002\n28692073 28692074\n33339990 33339989\n431545624 431545625\n939969171 939969172\n851655467 851655466\n611182710 611182709\n10986041 10986040\n827862935 827862934\n779079810 779079809\n575075190 575075189\n211940198 211940199\n911405559 911405560\n662413805 662413804\n846206435 846206434\n87516990 87516989\n330156388 330156387\n206036265 206036264\n695392393 695392392\n295261852 295261853\n398615495 398615496\n248748594 248748593\n24601206 24601207\n9940127 9940128\n445134161 445134162\n750824260 750824261\n574966008 574966007\n279164579 279164578\n93898861 93898862\n927952095 927952096\n692477850 692477849\n936211525 936211524\n472616393 472616392\n459249086 459249087\n830572586 830572585\n734324577 734324576\n52046928 52046927\n695371488 695371487\n463536819 463536820\n702243862 702243861\n148656433 148656432\n497589120 497589119\n367803782 367803781\n57022144 57022145\n764116952 764116951\n667023643 667023642\n608970028 608970029\n264619514 264619515\n719217138 719217137\n857661295 857661294\n675902582 675902581\n542817957 542817958\n9719149 9719148\n784365687 784365688\n688620652 688620653\n479234013 479234012\n645203572 645203571\n356952178 356952179\n459021408 459021407\n534233339 534233340\n4860790 4860789\n888331742 888331741\n698565084 698565083\n27652514 27652515\n971368734 971368735\n933552501 933552502\n5127855 5127854\n125553579 125553578\n622876764 622876765\n719103542 719103543\n71047395 71047396\n416880435 416880436\n30920284 30920285\n129735006 129735007\n817164487 817164486\n457827994 457827993\n804626056 804626057\n990016105 990016106\n527093991 527093992\n274625657 274625656\n593594001 593594000\n756056854 756056853\n981626899 981626898\n424066480 424066479\n942690 942689\n166168415 166168414\n371382612 371382613\n", "100\n342421272 250204768\n275903100 36659799\n23319666 57339784\n98115328 6489103\n26107200 173427325\n181267950 312932352\n99942128 122619068\n109357697 177261632\n200427200 111950528\n60761421 170931789\n307279902 286391118\n84529575 118621503\n98569494 1275264\n496605780 77973005\n15976960 3893760\n286645920 261393000\n120408704 159394976\n322009348 2124688\n60920475 43947819\n3746736 823504064\n2621808 8164800\n1798067 97686272\n136305625 248850625\n229074944 138661544\n3214941 23241876\n424622640 68214960\n14941465 92061585\n253853905 233512000\n11504801 12768161\n27177512 22625000\n177326496 46769850\n461012011 28880064\n443280012 178547712\n517405050 185587872\n229641080 644213630\n43799112 23688\n47189826 2105344\n623492865 429926625\n63700992 39269772\n663533021 618561104\n211631616 152829824\n13329441 7536609\n712787796 58847796\n508608 53002075\n2292144 160500876\n1373328 15169572\n644899878 4236800\n596464350 994734\n473472 9062550\n380880000 262663200\n298021698 46773792\n26929620 429998605\n130014150 12615000\n199999600 324622576\n479581280 326798720\n111297368 186368\n392608125 90843893\n199756800 254803968\n217306400 74847776\n92145600 209637639\n394902288 374667953\n177917432 40077792\n115046316 4762604\n25408640 257882210\n529767500 159335867\n115843608 80779032\n306587655 36353295\n2593537 2108425\n707917504 191049579\n171101952 100800\n522956980 714328020\n134571668 39034688\n1152 4829832\n132720665 21765065\n25609662 67462200\n177949964 151926284\n70592582 155998208\n11667520 325628545\n442352768 126850592\n495870336 311619224\n8251425 137494672\n19193161 37173409\n114525373 87800413\n1474742 1923750\n50171537 229321508\n443787433 6606073\n25295627 133188300\n501993 41731425\n1100800 165863728\n1710720 61585920\n54271888 1350628\n268984161 226574596\n298248000 508610880\n6439850 15863306\n5009724 48981519\n161240540 39017340\n262773344 210364256\n71500 441724140\n527494012 60299200\n481235532 311739072\n", "99\n79923898 900\n2202127 278\n12888042 751\n1282655 424\n30631554 239\n825772306 995\n306234 105\n480056952 991\n413861995 614\n636799913 754\n569 474301674\n802 759277631\n237 144931970\n710 216340392\n791 665144116\n91107497 748\n823 439779834\n918 618770459\n3468168 669\n632716 807\n170 6332523\n230527944 549\n452764578 685\n136 473475\n86400300 960\n658 585126785\n754 21535163\n181070490 407\n774 27356444\n224 4774930\n303599420 547\n2788368 10\n104363358 982\n35221931 52\n830 650077635\n1020474 425\n735680880 950\n99 32732450\n324731814 433\n970 156756282\n45058686 457\n97401151 132\n801 745912190\n93437542 668\n908 117024307\n485972354 648\n105566912 213\n334 332000003\n6137095 680\n767 18190326\n337 232719888\n856 85477052\n318945008 564\n62580999 700\n222 45556851\n198 56461422\n18 4182314\n726 544468922\n260738166 710\n6447728 514\n194158716 480\n310131510 319\n92766804 203\n14031181 632\n5795685 318\n1325854 263\n439 48680604\n1582945 314\n44 203524\n179438160 512\n1642578 19\n724 600863715\n394699620 587\n9614010 218\n226 8505930\n736 536571\n121 42981732\n81730780 566\n62313930 157\n225 179828994\n464 416999604\n404 64964005\n73534632 255\n873 90516454\n69310 693\n311 215800312\n177 34423578\n583392264 853\n507 12180830\n149719 518\n653 51929454\n58415430 269\n146931332 976\n1271745 628\n740 278977654\n511 467999796\n701 220619982\n398 98310079\n4548244 338\n", "98\n682582034 9480858\n857223175 395011806\n343124157 346019554\n536293122 874416351\n749078689 294344339\n258447755 392529770\n574773516 238110922\n75949591 50330840\n539580840 584701118\n423924791 82319314\n697716494 714922949\n828921039 61328381\n268136346 40206233\n206191219 465776880\n285260154 229755362\n582039598 858648900\n872437744 34362633\n36944170 925370183\n780437797 332348157\n703728723 358334511\n115916040 587271024\n880816094 531213803\n681109409 342227225\n303766813 307214632\n591142707 944846761\n419309641 237986269\n466908021 801668910\n435609124 890707078\n15958123 59422284\n384650586 643020308\n645373679 119899476\n282255764 35680439\n912166219 251653050\n56462137 964982388\n799400558 147741053\n104940747 251193502\n907846406 590598434\n965967250 42209925\n359423419 631957781\n590888833 11421546\n403253644 294346078\n273393193 967547874\n955882932 948389468\n475553810 17381202\n170113132 718477075\n72162677 171199126\n920587775 290562484\n673072958 71071438\n70762340 313880861\n518100074 692835420\n929594266 943870479\n43445914 918279977\n690978143 602808468\n32925808 533486496\n946013151 126914792\n801194842 45180601\n770895414 551306762\n854185644 412688186\n329041614 410718973\n68952621 828806142\n129222118 348647764\n654649853 93411693\n774102818 394427196\n335496356 526290753\n173659689 384304372\n655083255 187360503\n46586241 225046156\n39357697 817306561\n872988585 369043937\n315413220 576210687\n430883447 186626264\n274043436 50391231\n849269940 45915609\n24648841 397707614\n656272885 48357007\n29282702 33245857\n42397917 376694972\n278327699 370260523\n305221326 788722211\n499338696 434248000\n204209329 756559830\n499978302 405281046\n580748171 597646907\n404724492 365590154\n347059295 68726333\n912416936 480109849\n711253955 477696854\n929193326 282608437\n331036623 637939123\n409250311 442071096\n391600713 887679649\n598906290 251421933\n297729933 57407166\n14270774 493897213\n49544574 387934881\n422799495 34615835\n975745365 740112157\n411206913 434037289\n", "100\n41 60\n89 29\n11 59\n41 43\n7 32\n41 47\n19 59\n3 67\n74 91\n99 10\n29 44\n35 36\n61 44\n84 14\n3 70\n1 18\n42 79\n96 8\n37 4\n64 12\n1 14\n27 28\n66 2\n48 28\n94 69\n61 99\n86 79\n83 33\n33 9\n59 30\n88 18\n98 97\n66 47\n95 57\n87 83\n48 44\n61 39\n16 13\n7 65\n3 45\n5 10\n22 83\n20 79\n17 44\n66 36\n85 84\n88 100\n68 49\n20 55\n74 9\n94 6\n47 39\n21 15\n56 72\n21 72\n54 6\n67 10\n81 33\n88 90\n88 62\n8 19\n41 51\n23 1\n38 29\n32 42\n74 3\n61 15\n84 80\n42 95\n56 75\n68 99\n87 65\n31 42\n92 81\n70 76\n57 7\n11 75\n67 35\n96 5\n57 49\n4 60\n72 29\n85 4\n43 68\n92 91\n23 14\n58 42\n64 45\n63 58\n29 22\n15 25\n82 1\n15 47\n91 56\n20 48\n100 25\n27 63\n15 33\n85 95\n75 34\n", "99\n675327540 672524204\n497075416 898369316\n178150518 341282365\n585178897 322660866\n806624377 806624377\n666275660 666275660\n23941449 139287204\n79 55\n4845273 4845273\n16 1\n18 58\n716746526 716746525\n196148982 196148982\n897690387 897690387\n544160979 714\n401539995 401539995\n33 92\n99 72\n4483003 4483004\n402199659 539487719\n30296448 15838550\n93 74\n198216141 10102164\n510 56214572\n974839853 763383053\n537600792 537600792\n710797277 710797277\n1537464 391500000\n91 82\n781708445 332471457\n388 386450550\n567305716 567305716\n31 52\n85 7\n725775109 810860286\n2966801 39779225\n64373184 64373183\n363916229 363916228\n52379125 4264960\n270176220 785733743\n4902215 132826140\n75 95\n697990169 697990169\n695 551748186\n118551030 8806317\n761 30440200\n632816351 632816352\n968689187 968689188\n232 85762656\n11 34\n68429858 92269500\n453192250 631418479\n74 89\n27196928 574634318\n406 9013755\n24685480 24685480\n97 22\n51 23\n2427600 9653364\n74 52\n298423445 298423445\n18911232 525312\n623567589 623567589\n37200038 150198144\n732120438 732120437\n263602540 28064140\n251687912 414807050\n89690858 89690859\n62 93\n626193809 626193810\n843421137 843421138\n58 63\n90 53\n59 47\n122676939 1849536\n759422597 759422597\n249662339 54810196\n469952087 469952086\n234567403 234567403\n726 109859435\n74425844 31647581\n28185666 307\n214598981 297461336\n922001569 922001568\n16 98\n666583124 666583124\n13068123 163824990\n406 30927732\n30 100\n210525716 210525717\n31 28\n6 9\n146429495 146429496\n516303374 516303374\n47788103 266213241\n711638585 711638586\n311 215282496\n22499325 131116288\n187211250 20801250\n", "98\n71744790 402418520\n978001001 978001000\n840052802 430653505\n92515890 92515890\n195079104 198542711\n4526652 186\n662450618 974077607\n30492770 763852320\n22875250 366\n611661121 441892303\n33 70\n74 66\n161791875 44391875\n483575 20844992\n72 12\n241567992 586773823\n918198470 979952853\n574265812 726395239\n75 4538946\n69207408 69207408\n83 41\n648869928 648869928\n57 57\n473473324 37272848\n158496268 158496268\n14 20\n730789452 845656502\n177879872 124717268\n991744361 967036516\n166 104389727\n70421727 70421728\n799677321 799677321\n725267321 725267320\n40316131 22203811\n528119945 350234851\n46 96\n53 33\n48263690 50075871\n932 201522165\n200019028 385938432\n866 106692417\n49579813 620653437\n973317354 973317354\n750718122 750718121\n864863012 17284019\n520 164239442\n920885463 920885463\n215358518 572277810\n23968256 7583706\n460792028 550884642\n729 492830\n540682956 166614048\n21305889 21305890\n852539989 852539989\n60552000 131276880\n119193866 119193867\n26690916 797\n147348091 410830968\n382960239 507644799\n227020910 227020911\n313764 18\n6 3\n876298605 876298606\n70 70\n469606179 469606180\n365584790 919221115\n456426204 140199364\n708548232 983\n278645816 792053476\n21 82\n800693574 800693573\n365783040 278784000\n1751088 35997888\n81589227 69788196\n799125174 799125174\n343477007 343477006\n33 12\n820266679 194826237\n3840100 384\n346123366 566\n925 92952642\n173462896 173462897\n956988850 956988850\n27 29\n617 555330\n51294584 834\n728540366 958798108\n312824679 312824679\n715873188 715873187\n49 63\n27341120 267\n73 90\n869183947 869183947\n19125838 139737088\n150462103 35263415\n450 258554558\n4712519 40724775\n689 13504540\n", "100\n37882 56\n23348596 23348597\n66964743 66964743\n872393938 872393937\n79 69\n349057774 402285893\n436340579 436340580\n231948288 10955412\n705530638 705530638\n6 35\n86461132 12078700\n110 84798118\n647801830 647801831\n76962776 61551576\n957803433 252932498\n16205280 641\n961538871 961538872\n231747642 171716328\n117951526 379646134\n7267165 33456085\n82258077 522380480\n16 16\n42850830 42850831\n244483456 224131894\n350 19992589\n215 20661810\n26153481 122\n477820591 477820592\n2528470 516\n2945488 3095872\n128446642 855658593\n44712051 968519612\n32443488 21718368\n43 90\n541468232 49183362\n813594538 813594539\n377172800 426320192\n60575631 60575631\n473791816 473791817\n360506203 360506204\n49280670 676\n350801850 481\n121828608 94897172\n701788138 221720993\n935119877 935119876\n724357167 724357168\n128277108 632101167\n658411361 658411362\n646013952 178806612\n56 57\n28064501 185760909\n565875769 565875768\n638367880 991838538\n354118118 795963780\n73478016 73478016\n68596622 68596621\n575315212 399884\n62388478 62388479\n201494948 201494948\n82 40\n82 8\n40021305 797460324\n26 100\n955 65055816\n480722501 109436058\n253236091 253236090\n316846080 50519500\n678329903 973699982\n15925248 9806592\n631777057 501037819\n401093478 60162048\n422349611 422349611\n479730381 479730382\n165288216 165288215\n6 60\n82061189 573453125\n112377358 112377358\n188743780 535017411\n890 791432553\n943673388 858585956\n87643510 912\n214551060 247\n118822156 501\n993533949 671364548\n196716059 482435813\n865903925 865903925\n987004820 987004820\n53806619 80693739\n49689515 49689515\n253554918 253554918\n77236918 759\n582435 14068460\n27997420 27997421\n67960418 67960418\n309719484 917401142\n666293310 666293309\n89 17\n503657418 503657418\n66 37\n512767278 56748909\n", "99\n225497868 1086828\n642 91247195\n35019270 397\n1181004 610\n881384110 881384111\n182998419 480459607\n531433416 908325859\n560454384 560454384\n699459065 699459064\n100641792 414892800\n75 89\n317697269 210740095\n78 100\n22266720 444528000\n13803440 130371500\n201757866 448355653\n83627271 430\n381375065 381375065\n51 41\n61 43\n527538370 527538369\n100 1\n888370649 888370649\n407 161026516\n230772880 145626345\n563823120 563823120\n697738155 697738154\n2794045 2794045\n122451200 86564052\n877590646 877590646\n287490 17177160\n158714127 686\n43 68\n196827229 196827230\n629313965 629313966\n42 51\n787799974 125030923\n16 75\n925227771 916923008\n517801385 517801385\n2399544 8107694\n763584400 476417476\n77 56\n519303810 519303811\n472164347 472164347\n27513510 27513510\n146988073 146988073\n864 851947329\n561491781 561491781\n755799 694\n686138853 686138852\n980 11643489\n725269597 725269597\n38357785 38357784\n63 82\n40093867 150\n38 20\n252968331 252968332\n60601902 375\n610106345 610106346\n23263216 23263216\n404505620 410947790\n645003643 645413353\n641293515 641293516\n85 70\n78128469 13688125\n82 30\n499585900 499585899\n289525858 16087372\n43 91\n32111238 32111238\n681484580 741\n542391811 542391811\n98 2\n821357242 821357242\n881926236 881926237\n422131412 869958795\n75 89\n10210364 25339100\n46310506 46310507\n147026157 479666616\n274544724 142934580\n97 46\n672767048 672767049\n879185915 879185915\n973233835 298781525\n41538115 47694640\n85503774 66885600\n4704237 133809408\n632345530 632345530\n476616101 679200587\n83 37\n117742335 292\n44358904 4477824\n5079911 669559388\n292858879 292858878\n326484452 83835968\n75 14\n786217715 786217715\n", "10\n1 1\n1 2\n1 3\n1 4\n1 5\n1 6\n1 7\n1 8\n1 9\n1 10\n"], "outputs": ["1\n12\n4\n11\n14\n57\n31\n671644785\n", "415158024\n752280924\n373939170\n652805078\n316353144\n255721778\n1141740088\n357018044\n122526608\n1116425548\n52779258\n992295998\n1674303480\n1313170550\n1804142100\n1454247524\n592463324\n1798748666\n1597143020\n1598626744\n1578408932\n325466528\n1110506862\n362915908\n1502708026\n304080820\n916001284\n329113746\n410922378\n334070016\n600412568\n1550285228\n1792411900\n915282636\n1180129426\n1818841374\n110868540\n420922084\n1075700704\n1229589742\n1810407538\n1808474002\n674492648\n301251498\n1289011016\n3477406\n452205976\n244347994\n1167004394\n1495091796\n1240959062\n1082652296\n407918080\n982384508\n202731534\n1921141310\n881996724\n969832290\n1835652138\n1214930952\n1192159154\n1298641616\n1061819540\n1332261100\n1237048866\n1562643216\n676499894\n233168504\n332616624\n1376506346\n878267514\n327832242\n1775302020\n644411816\n1685685834\n155246632\n225083722\n1975618840\n1057710350\n1093624290\n1301964074\n216113024\n1604878132\n1187142506\n379215822\n43780266\n120103842\n1856084172\n31531104\n467210466\n732254660\n1723125390\n1714087564\n864174322\n142110084\n1176910270\n1735205500\n1922484772\n775543628\n", "306406676\n1556755166\n1406372674\n106625404\n1563068396\n799105916\n364122002\n456282728\n944603650\n861297036\n1338572620\n1854432002\n57384144\n66679976\n863091246\n1879938340\n1703310930\n1222365416\n21972078\n1655725866\n1558159616\n1150150376\n423880394\n1822811116\n1324827606\n1692412866\n175033976\n660312772\n412072526\n1390784782\n590523702\n797230988\n497497184\n49202410\n19880252\n890268320\n1501648518\n1149932012\n558329154\n187797720\n1855904188\n1384955696\n1872423046\n945232782\n918498170\n1661145168\n1468649150\n104093852\n1390742972\n927073636\n1404487720\n297312862\n995178236\n735607560\n114044286\n1528233900\n1334047282\n1217940054\n529239026\n1438434272\n1715322586\n1351805160\n1085635912\n19438294\n1568731372\n1377241302\n958468022\n1290407140\n713904354\n918042812\n1068466676\n9721576\n1776663480\n1397130164\n55305026\n1942737466\n1867105000\n10255706\n251107154\n1245753526\n1438207082\n142094788\n833760868\n61840566\n259470010\n1634328970\n915655984\n1609252110\n1980032208\n1054187980\n549251310\n1187187998\n1512113704\n1963253794\n848132956\n1885376\n332336826\n742765222\n", "585407325\n201142257\n73133973\n50465053\n134576397\n476338557\n221402893\n278459501\n299585917\n203824023\n593303409\n200270067\n22423389\n393557337\n15774717\n547456797\n277074301\n52313261\n103485687\n111093693\n9253437\n26506333\n368346247\n356448509\n17288289\n340385757\n74176407\n486941197\n24240059\n49593997\n182137677\n230773101\n562660221\n619755117\n769253957\n2037165\n19934973\n1035482847\n100030461\n1281305141\n359686653\n20045823\n409614405\n10384077\n38360973\n9128589\n104543037\n48716457\n4142877\n632591997\n236132205\n215218017\n80996997\n509605277\n791774077\n9108733\n377709147\n451215357\n255067837\n277972557\n769304181\n168885021\n46815381\n161894237\n581071297\n193470765\n211144227\n4676867\n735519789\n8305917\n1222395717\n144954653\n149181\n107492767\n83130837\n328848149\n209879165\n123276557\n473762429\n786187581\n67365477\n53421911\n200552983\n3368697\n214526569\n108290203\n116087577\n9153987\n27024637\n20528637\n17123213\n493740729\n778953597\n20214577\n31329465\n158633877\n470225981\n11239797\n356692957\n774648093\n", "536398\n49482\n196760\n46638\n171122\n1812888\n11338\n1379470\n1008186\n1385850\n1038992\n1560690\n370666\n783838\n1450692\n522102\n1203224\n1507354\n96334\n45190\n65618\n711502\n1113808\n16046\n575998\n1240986\n254850\n542936\n291022\n65406\n815028\n10558\n640262\n85590\n1469098\n41648\n1671998\n113848\n749954\n779878\n286994\n226774\n1545928\n499662\n651942\n1122334\n299902\n665994\n129198\n236234\n560092\n540990\n848254\n418598\n201130\n211462\n17350\n1257430\n860518\n115134\n610558\n629066\n274454\n188334\n85858\n37344\n292372\n44586\n5982\n606206\n11170\n1319126\n962678\n91558\n87686\n39742\n144230\n430158\n197818\n402298\n879742\n324006\n273868\n562210\n13858\n518124\n156112\n1410860\n157168\n17610\n368290\n250706\n757374\n56518\n908718\n978052\n786520\n395610\n78414\n", "160890809\n1163809732\n689137626\n1369588950\n939121015\n637019425\n739891481\n123654463\n1123376195\n373615832\n1412534646\n450938509\n207660802\n619803523\n512015817\n1413884944\n346290384\n369794715\n1018581489\n1004331194\n521820394\n1368066761\n965596565\n610971714\n1494709698\n631790903\n1223610465\n1245793126\n61587922\n994662027\n556345092\n200708837\n958226299\n466840303\n687326063\n324717929\n1464476239\n403848510\n953185030\n164302937\n689046088\n1028632104\n1904257654\n181831753\n699206363\n222298781\n1034385362\n437430051\n298066730\n1198262210\n1873410348\n399477220\n1290778795\n265069603\n693002342\n380517879\n1303840255\n1187454963\n735237738\n478114443\n424513849\n494578408\n1105128413\n840401401\n516674664\n700676037\n204783341\n358704912\n1135202436\n852629972\n567147837\n235026686\n394941748\n198020519\n356288602\n62402835\n252753491\n642039745\n981294732\n931314832\n786121045\n900292681\n1178273901\n769319929\n308882582\n1323722563\n1165785186\n1024886086\n919089140\n850688503\n1179179345\n776088078\n261471462\n167908252\n277272920\n241955014\n1699601135\n844935815\n", "97\n99\n48\n81\n27\n85\n64\n26\n162\n60\n69\n68\n101\n66\n26\n6\n113\n53\n22\n53\n5\n52\n20\n71\n159\n153\n162\n102\n32\n82\n77\n192\n109\n145\n167\n89\n95\n26\n40\n21\n12\n83\n77\n52\n95\n166\n185\n113\n64\n49\n45\n83\n33\n124\n75\n33\n49\n101\n175\n145\n22\n89\n7\n64\n71\n27\n58\n161\n124\n127\n162\n148\n70\n170\n143\n37\n55\n94\n41\n103\n28\n89\n34\n106\n180\n33\n96\n105\n118\n48\n36\n16\n51\n140\n59\n97\n80\n42\n177\n98\n", "1347848826\n1336498859\n493151618\n869055415\n1613248752\n1332551318\n115494369\n129\n9690544\n5\n62\n1433493048\n392297962\n1795380772\n1246642\n803079988\n108\n166\n8966004\n931626053\n43811037\n163\n89496633\n338638\n1725312981\n1075201582\n1421594552\n49067997\n170\n1019599420\n774446\n1134611430\n78\n46\n1534277955\n21727127\n128746364\n727832454\n29892797\n921491338\n51034977\n166\n1395980336\n1238488\n64621912\n304398\n1265632700\n1937378372\n282110\n36\n158921221\n1069867206\n160\n250026301\n120986\n49370958\n90\n66\n9681837\n122\n596846888\n6303741\n1247135176\n149497511\n1464240872\n172020677\n646225717\n179381714\n149\n1252387616\n1686842272\n118\n136\n103\n30126093\n1518845192\n233957615\n939904170\n469134804\n564826\n97064881\n186040\n505311385\n1844003134\n77\n1333166246\n92539397\n224110\n107\n421051430\n56\n12\n292858988\n1032606746\n225582140\n1423277168\n517502\n108628317\n124807497\n", "339831910\n1956001998\n1202949179\n185031778\n393606573\n58030\n1606584340\n305234157\n182998\n1039785247\n94\n137\n169496247\n6349837\n56\n752982797\n1897146497\n1291733641\n36898\n138414814\n114\n1297739854\n112\n265689284\n316992534\n31\n1572255513\n297890525\n1958625037\n263274\n140843452\n1599354640\n1450534638\n59838839\n860153496\n130\n81\n98322860\n866758\n555679869\n607930\n350838315\n1946634706\n1501436240\n244526550\n584478\n1841770924\n702125061\n26964285\n1007657184\n37906\n600284517\n42611776\n1705079976\n178315197\n238387730\n291700\n492077873\n881833935\n454041818\n4750\n6\n1752597208\n138\n939212356\n1159402013\n505927516\n1669132\n939579451\n80\n1601387144\n638668797\n15878973\n150916729\n1598250346\n686954010\n37\n799523532\n76798\n885222\n586448\n346925790\n1913977698\n53\n37018\n413662\n1671553915\n625649356\n1431746372\n109\n170878\n160\n1738367892\n103394173\n145681947\n682198\n27706767\n192918\n", "2910\n46697190\n133929484\n1744787872\n145\n749455849\n872681156\n100818429\n1411061274\n26\n64632437\n193158\n1295603658\n137654349\n984397508\n203836\n1923077740\n398972949\n423224953\n31185307\n414584193\n30\n85701658\n468173213\n167298\n133298\n112970\n955641180\n72238\n6039485\n663042901\n416194655\n53089341\n122\n326381541\n1627189074\n801988477\n121151260\n947583630\n721012404\n365038\n821546\n215045949\n788926262\n1870239750\n1448714332\n569505431\n1316822720\n679739848\n110\n144406191\n1131751534\n1591424347\n1061819560\n146956030\n137193240\n30335412\n124776954\n402989894\n112\n49\n357297648\n99\n498508\n458730313\n506472178\n253036797\n1625410486\n24993789\n1125245213\n310680573\n844699220\n959460760\n330576428\n35\n433858247\n224754714\n635550809\n1678538\n1800249667\n565438\n460406\n487972\n1633430095\n616126192\n1731807848\n1974009638\n131785539\n99379028\n507109834\n484240\n5725017\n55994838\n135920834\n1066090066\n1332586616\n75\n1007314834\n96\n341168481\n", "31309893\n484066\n235816\n53678\n1762768218\n593037428\n1389553471\n1120908766\n1398918126\n408683517\n161\n517499959\n174\n198979197\n84842797\n601528982\n379258\n762750128\n89\n100\n1055076736\n17\n1776741296\n512004\n366642117\n1127646238\n1395476306\n5588088\n205911357\n1755181290\n4444437\n659930\n106\n393654456\n1258627928\n90\n627692145\n67\n1842132057\n1035602768\n8821509\n1206291757\n129\n1038607618\n944328692\n55027018\n293976144\n1715902\n1122983560\n45802\n1372277702\n213638\n1450539192\n76715566\n141\n155098\n53\n505936660\n301498\n1220212688\n46526430\n815427960\n1290416928\n1282587028\n152\n65404347\n97\n999171796\n136494835\n123\n64222474\n1421236\n1084783620\n25\n1642714482\n1763852470\n1212001540\n161\n32169637\n92621010\n531125366\n396191541\n131\n1345534094\n1758371828\n1078488364\n89020117\n151247757\n50178525\n1264691058\n1137924311\n108\n370838\n28187325\n116641364\n585717754\n330884509\n62\n1572435428\n", "0\n0\n1\n1\n2\n2\n3\n3\n3\n4\n"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 12, "n_test_cases_kept": 12, "test_cases_truncated": false, "problem_sha1": "ef35965d60b68d761b7e2a4afaeba2ccdac8c423", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-01223", "original_id": null, "source": "apps", "domain": "code", "problem": "Hamed has recently found a string t and suddenly became quite fond of it. He spent several days trying to find all occurrences of t in other strings he had. Finally he became tired and started thinking about the following problem. Given a string s how many ways are there to extract k ≥ 1 non-overlapping substrings from it such that each of them contains string t as a substring? More formally, you need to calculate the number of ways to choose two sequences a_1, a_2, ..., a_{k} and b_1, b_2, ..., b_{k} satisfying the following requirements:\n\n k ≥ 1 $\\forall i(1 \\leq i \\leq k) 1 \\leq a_{i}, b_{i} \\leq|s|$ $\\forall i(1 \\leq i \\leq k) b_{i} \\geq a_{i}$ $\\forall i(2 \\leq i \\leq k) a_{i} > b_{i - 1}$ $\\forall i(1 \\leq i \\leq k)$  t is a substring of string s_{a}_{i}s_{a}_{i} + 1... s_{b}_{i} (string s is considered as 1-indexed). \n\nAs the number of ways can be rather large print it modulo 10^9 + 7.\n\n\n-----Input-----\n\nInput consists of two lines containing strings s and t (1 ≤ |s|, |t| ≤ 10^5). Each string consists of lowercase Latin letters.\n\n\n-----Output-----\n\nPrint the answer in a single line.\n\n\n-----Examples-----\nInput\nababa\naba\n\nOutput\n5\n\nInput\nwelcometoroundtwohundredandeightytwo\nd\n\nOutput\n274201\n\nInput\nddd\nd\n\nOutput\n12", "starter_code": "", "test_cases": {"inputs": ["ababa\naba\n", "welcometoroundtwohundredandeightytwo\nd\n", "ddd\nd\n", "vnssnssnssnssnssnssnssnssnssnssnssnssnssnssnssnssn\nnssnssns\n", "kpjmawawawawawawawawawawawawawawawawawawawawawawaw\nwawawawa\n", "vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv\nvvvvvvvv\n", "a\na\n", "a\naa\n", "a\nb\n", "ababababab\nabab\n"], "outputs": ["5\n", "274201\n", "12\n", "943392\n", "834052\n", "2728075\n", "1\n", "0\n", "0\n", "35\n"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 10, "n_test_cases_kept": 10, "test_cases_truncated": false, "problem_sha1": "96d0701b26a8bf103cf895443580b68142bfe810", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-01228", "original_id": null, "source": "apps", "domain": "code", "problem": "Polycarp took $n$ videos, the duration of the $i$-th video is $a_i$ seconds. The videos are listed in the chronological order, i.e. the $1$-st video is the earliest, the $2$-nd video is the next, ..., the $n$-th video is the last.\n\nNow Polycarp wants to publish exactly $k$ ($1 \\le k \\le n$) posts in Instabram. Each video should be a part of a single post. The posts should preserve the chronological order, it means that the first post should contain one or more of the earliest videos, the second post should contain a block (one or more videos) going next and so on. In other words, if the number of videos in the $j$-th post is $s_j$ then:\n\n $s_1+s_2+\\dots+s_k=n$ ($s_i>0$), the first post contains the videos: $1, 2, \\dots, s_1$; the second post contains the videos: $s_1+1, s_1+2, \\dots, s_1+s_2$; the third post contains the videos: $s_1+s_2+1, s_1+s_2+2, \\dots, s_1+s_2+s_3$; ... the $k$-th post contains videos: $n-s_k+1,n-s_k+2,\\dots,n$. \n\nPolycarp is a perfectionist, he wants the total duration of videos in each post to be the same.\n\nHelp Polycarp to find such positive integer values $s_1, s_2, \\dots, s_k$ that satisfy all the conditions above.\n\n\n-----Input-----\n\nThe first line contains two integers $n$ and $k$ ($1 \\le k \\le n \\le 10^5$). The next line contains $n$ positive integer numbers $a_1, a_2, \\dots, a_n$ ($1 \\le a_i \\le 10^4$), where $a_i$ is the duration of the $i$-th video.\n\n\n-----Output-----\n\nIf solution exists, print \"Yes\" in the first line. Print $k$ positive integers $s_1, s_2, \\dots, s_k$ ($s_1+s_2+\\dots+s_k=n$) in the second line. The total duration of videos in each post should be the same. It can be easily proven that the answer is unique (if it exists).\n\nIf there is no solution, print a single line \"No\".\n\n\n-----Examples-----\nInput\n6 3\n3 3 1 4 1 6\n\nOutput\nYes\n2 3 1 \nInput\n3 3\n1 1 1\n\nOutput\nYes\n1 1 1 \nInput\n3 3\n1 1 2\n\nOutput\nNo\nInput\n3 1\n1 10 100\n\nOutput\nYes\n3", "starter_code": "", "test_cases": {"inputs": ["6 3\n3 3 1 4 1 6\n", "3 3\n1 1 1\n", "3 3\n1 1 2\n", "3 1\n1 10 100\n", "1 1\n3\n", "2 1\n1 3\n", "2 1\n3 3\n", "2 2\n3 1\n", "2 2\n1 3\n", "4 2\n2 1 3 1\n"], "outputs": ["Yes\n2 3 1 ", "Yes\n1 1 1 ", "No", "Yes\n3 ", "Yes\n1 ", "Yes\n2 ", "Yes\n2 ", "No", "No", "No"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 10, "n_test_cases_kept": 10, "test_cases_truncated": false, "problem_sha1": "1703fef4c297fffe3a1bf49e40f8a3bcbe93e310", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-01233", "original_id": null, "source": "apps", "domain": "code", "problem": "You are given a directed graph of $n$ vertices and $m$ edges. Vertices are numbered from $1$ to $n$. There is a token in vertex $1$.\n\nThe following actions are allowed: Token movement. To move the token from vertex $u$ to vertex $v$ if there is an edge $u \\to v$ in the graph. This action takes $1$ second. Graph transposition. To transpose all the edges in the graph: replace each edge $u \\to v$ by an edge $v \\to u$. This action takes increasingly more time: $k$-th transposition takes $2^{k-1}$ seconds, i.e. the first transposition takes $1$ second, the second one takes $2$ seconds, the third one takes $4$ seconds, and so on. \n\nThe goal is to move the token from vertex $1$ to vertex $n$ in the shortest possible time. Print this time modulo $998\\,244\\,353$.\n\n\n-----Input-----\n\nThe first line of input contains two integers $n, m$ ($1 \\le n, m \\le 200\\,000$).\n\nThe next $m$ lines contain two integers each: $u, v$ ($1 \\le u, v \\le n; u \\ne v$), which represent the edges of the graph. It is guaranteed that all ordered pairs $(u, v)$ are distinct.\n\nIt is guaranteed that it is possible to move the token from vertex $1$ to vertex $n$ using the actions above.\n\n\n-----Output-----\n\nPrint one integer: the minimum required time modulo $998\\,244\\,353$.\n\n\n-----Examples-----\nInput\n4 4\n1 2\n2 3\n3 4\n4 1\n\nOutput\n2\n\nInput\n4 3\n2 1\n2 3\n4 3\n\nOutput\n10\n\n\n\n-----Note-----\n\nThe first example can be solved by transposing the graph and moving the token to vertex $4$, taking $2$ seconds.\n\nThe best way to solve the second example is the following: transpose the graph, move the token to vertex $2$, transpose the graph again, move the token to vertex $3$, transpose the graph once more and move the token to vertex $4$.", "starter_code": "", "test_cases": {"inputs": ["4 4\n1 2\n2 3\n3 4\n4 1\n", "4 3\n2 1\n2 3\n4 3\n", "10 20\n2 1\n7 9\n10 2\n4 9\n3 1\n6 4\n3 6\n2 9\n5 2\n3 9\n6 8\n8 7\n10 4\n7 4\n8 5\n3 4\n6 7\n2 6\n10 6\n3 8\n", "10 9\n8 5\n3 5\n3 7\n10 6\n4 6\n8 1\n9 2\n4 2\n9 7\n", "50 49\n1 3\n6 46\n47 25\n11 49\n47 10\n26 10\n12 38\n45 38\n24 39\n34 22\n36 3\n21 16\n43 44\n45 23\n2 31\n26 13\n28 42\n43 30\n12 27\n32 44\n24 25\n28 20\n15 19\n6 48\n41 7\n15 17\n8 9\n2 48\n33 5\n33 23\n4 19\n40 31\n11 9\n40 39\n35 27\n14 37\n32 50\n41 20\n21 13\n14 42\n18 30\n35 22\n36 5\n18 7\n4 49\n29 16\n29 17\n8 37\n34 46\n", "13 13\n2 1\n2 3\n1 4\n4 5\n5 6\n6 7\n7 3\n8 3\n8 9\n10 9\n10 11\n12 11\n12 13\n", "2 1\n2 1\n"], "outputs": ["2\n", "10\n", "3\n", "520\n", "16495294\n", "74\n", "2\n"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 7, "n_test_cases_kept": 7, "test_cases_truncated": false, "problem_sha1": "6799b06dd06e8e53f7119722cb72e77e1519af08", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-01238", "original_id": null, "source": "apps", "domain": "code", "problem": "Rudolf is on his way to the castle. Before getting into the castle, the security staff asked him a question:\n\nGiven two binary numbers $a$ and $b$ of length $n$. How many different ways of swapping two digits in $a$ (only in $a$, not $b$) so that bitwise OR of these two numbers will be changed? In other words, let $c$ be the bitwise OR of $a$ and $b$, you need to find the number of ways of swapping two bits in $a$ so that bitwise OR will not be equal to $c$.\n\nNote that binary numbers can contain leading zeros so that length of each number is exactly $n$.\n\nBitwise OR is a binary operation. A result is a binary number which contains a one in each digit if there is a one in at least one of the two numbers. For example, $01010_2$ OR $10011_2$ = $11011_2$.\n\nWell, to your surprise, you are not Rudolf, and you don't need to help him$\\ldots$ You are the security staff! Please find the number of ways of swapping two bits in $a$ so that bitwise OR will be changed.\n\n\n-----Input-----\n\nThe first line contains one integer $n$ ($2\\leq n\\leq 10^5$) — the number of bits in each number.\n\nThe second line contains a binary number $a$ of length $n$.\n\nThe third line contains a binary number $b$ of length $n$.\n\n\n-----Output-----\n\nPrint the number of ways to swap two bits in $a$ so that bitwise OR will be changed.\n\n\n-----Examples-----\nInput\n5\n01011\n11001\n\nOutput\n4\n\nInput\n6\n011000\n010011\n\nOutput\n6\n\n\n\n-----Note-----\n\nIn the first sample, you can swap bits that have indexes $(1, 4)$, $(2, 3)$, $(3, 4)$, and $(3, 5)$.\n\nIn the second example, you can swap bits that have indexes $(1, 2)$, $(1, 3)$, $(2, 4)$, $(3, 4)$, $(3, 5)$, and $(3, 6)$.", "starter_code": "", "test_cases": {"inputs": ["5\n01011\n11001\n", "6\n011000\n010011\n", "10\n0110101101\n1010000101\n", "30\n011110110100010000011001000100\n110111101001011001100001101101\n", "2\n00\n00\n", "2\n00\n11\n"], "outputs": ["4\n", "6\n", "21\n", "146\n", "0\n", "0\n"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 6, "n_test_cases_kept": 6, "test_cases_truncated": false, "problem_sha1": "f317f4074d6bea08b9be7065d302b1fe2735b1cc", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-01243", "original_id": null, "source": "apps", "domain": "code", "problem": "Oleg's favorite subjects are History and Math, and his favorite branch of mathematics is division.\n\nTo improve his division skills, Oleg came up with $t$ pairs of integers $p_i$ and $q_i$ and for each pair decided to find the greatest integer $x_i$, such that: $p_i$ is divisible by $x_i$; $x_i$ is not divisible by $q_i$. Oleg is really good at division and managed to find all the answers quickly, how about you?\n\n\n-----Input-----\n\nThe first line contains an integer $t$ ($1 \\le t \\le 50$) — the number of pairs.\n\nEach of the following $t$ lines contains two integers $p_i$ and $q_i$ ($1 \\le p_i \\le 10^{18}$; $2 \\le q_i \\le 10^{9}$) — the $i$-th pair of integers.\n\n\n-----Output-----\n\nPrint $t$ integers: the $i$-th integer is the largest $x_i$ such that $p_i$ is divisible by $x_i$, but $x_i$ is not divisible by $q_i$.\n\nOne can show that there is always at least one value of $x_i$ satisfying the divisibility conditions for the given constraints.\n\n\n-----Example-----\nInput\n3\n10 4\n12 6\n179 822\n\nOutput\n10\n4\n179\n\n\n\n-----Note-----\n\nFor the first pair, where $p_1 = 10$ and $q_1 = 4$, the answer is $x_1 = 10$, since it is the greatest divisor of $10$ and $10$ is not divisible by $4$.\n\nFor the second pair, where $p_2 = 12$ and $q_2 = 6$, note that $12$ is not a valid $x_2$, since $12$ is divisible by $q_2 = 6$; $6$ is not valid $x_2$ as well: $6$ is also divisible by $q_2 = 6$. The next available divisor of $p_2 = 12$ is $4$, which is the answer, since $4$ is not divisible by $6$.", "starter_code": "", "test_cases": {"inputs": ["3\n10 4\n12 6\n179 822\n", "10\n246857872446986130 713202678\n857754240051582063 933416507\n873935277189052612 530795521\n557307185726829409 746530097\n173788420792057536 769449696\n101626841876448103 132345797\n598448092106640578 746411314\n733629261048200000 361714100\n981271355542147402 38\n559754147245184151 431517529\n", "10\n228282288 228282288\n1000000000000000000 1000000000\n1244094302301841 35271721\n998005893107997601 999002449\n999999874000003969 999999937\n956980859148255595 5\n1 323\n1 1000000000\n424001357601318819 537974673\n100000000 1000000000\n", "1\n42034266112 80174\n"], "outputs": ["10\n4\n179\n", "123428936223493065\n918940509\n37932865019708\n1\n57929473597352512\n767888699\n299224046053320289\n31896924393400000\n490635677771073701\n26946235365387\n", "114141144\n976562500000000\n5939\n31607\n1\n191396171829651119\n1\n1\n424001357601318819\n100000000\n", "1048576\n"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 4, "n_test_cases_kept": 4, "test_cases_truncated": false, "problem_sha1": "7a5a8c0f14952915ea993bc644e964e0ec77e566", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-01248", "original_id": null, "source": "apps", "domain": "code", "problem": "There is a tree with N vertices numbered 1 through N.\nThe i-th edge connects Vertex x_i and y_i.\nEach vertex is painted white or black.\nThe initial color of Vertex i is represented by a letter c_i.\nc_i = W represents the vertex is white; c_i = B represents the vertex is black.\nA cat will walk along this tree.\nMore specifically, she performs one of the following in one second repeatedly:\n - Choose a vertex that is adjacent to the vertex where she is currently, and move to that vertex. Then, invert the color of the destination vertex.\n - Invert the color of the vertex where she is currently.\nThe cat's objective is to paint all the vertices black. She may start and end performing actions at any vertex.\nAt least how many seconds does it takes for the cat to achieve her objective?\n\n-----Constraints-----\n - 1 ≤ N ≤ 10^5\n - 1 ≤ x_i,y_i ≤ N (1 ≤ i ≤ N-1)\n - The given graph is a tree.\n - c_i = W or c_i = B.\n\n-----Input-----\nInput is given from Standard Input in the following format:\nN\nx_1 y_1\nx_2 y_2\n:\nx_{N-1} y_{N-1}\nc_1c_2..c_N\n\n-----Output-----\nPrint the minimum number of seconds required to achieve the objective.\n\n-----Sample Input-----\n5\n1 2\n2 3\n2 4\n4 5\nWBBWW\n\n-----Sample Output-----\n5\n\nThe objective can be achieved in five seconds, for example, as follows:\n - Start at Vertex 1. Change the color of Vertex 1 to black.\n - Move to Vertex 2, then change the color of Vertex 2 to white.\n - Change the color of Vertex 2 to black.\n - Move to Vertex 4, then change the color of Vertex 4 to black.\n - Move to Vertex 5, then change the color of Vertex 5 to black.", "starter_code": "", "test_cases": {"inputs": ["5\n1 2\n2 3\n2 4\n4 5\nWBBWW\n", "6\n3 1\n4 5\n2 6\n6 1\n3 4\nWWBWBB\n", "1\nB\n", "20\n2 19\n5 13\n6 4\n15 6\n12 19\n13 19\n3 11\n8 3\n3 20\n16 13\n7 14\n3 17\n7 8\n10 20\n11 9\n8 18\n8 2\n10 1\n6 13\nWBWBWBBWWWBBWWBBBBBW\n"], "outputs": ["5\n", "7\n", "0\n", "21\n"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 4, "n_test_cases_kept": 4, "test_cases_truncated": false, "problem_sha1": "7181593f315789e4302d40c8df86c7d6582bbf6c", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-01253", "original_id": null, "source": "apps", "domain": "code", "problem": "This is an easier version of the next problem. The difference is only in constraints.\n\nYou are given a rectangular $n \\times m$ matrix $a$. In one move you can choose any column and cyclically shift elements in this column. You can perform this operation as many times as you want (possibly zero). You can perform this operation to a column multiple times.\n\nAfter you are done with cyclical shifts, you compute for every row the maximal value in it. Suppose that for $i$-th row it is equal $r_i$. What is the maximal possible value of $r_1+r_2+\\ldots+r_n$?\n\n\n-----Input-----\n\nThe first line contains an integer $t$ ($1 \\le t \\le 40$), the number of test cases in the input.\n\nThe first line of each test case contains integers $n$ and $m$ ($1 \\le n \\le 4$, $1 \\le m \\le 100$) — the number of rows and the number of columns in the given matrix $a$. \n\nEach of the following $n$ lines contains $m$ integers, the elements of $a$ ($1 \\le a_{i, j} \\le 10^5$).\n\n\n-----Output-----\n\nPrint $t$ integers: answers for all test cases in the order they are given in the input.\n\n\n-----Example-----\nInput\n2\n2 3\n2 5 7\n4 2 4\n3 6\n4 1 5 2 10 4\n8 6 6 4 9 10\n5 4 9 5 8 7\n\nOutput\n12\n29\n\n\n\n-----Note-----\n\nIn the first test case, you can shift the third column down by one, this way there will be $r_1 = 5$ and $r_2 = 7$.\n\nIn the second case you can don't rotate anything at all, this way there will be $r_1 = r_2 = 10$ and $r_3 = 9$.", "starter_code": "", "test_cases": {"inputs": ["2\n2 3\n2 5 7\n4 2 4\n3 6\n4 1 5 2 10 4\n8 6 6 4 9 10\n5 4 9 5 8 7\n", "40\n2 2\n5 2\n1 5\n1 1\n3\n1 2\n1 1\n1 2\n1 1\n1 2\n2 3\n2 1\n1\n1\n1 1\n1\n2 1\n1\n1\n1 2\n2 3\n2 2\n1 3\n3 3\n1 1\n1\n2 1\n3\n4\n1 1\n2\n2 2\n1 1\n1 1\n2 2\n1 1\n1 1\n1 1\n1\n2 1\n1\n1\n2 1\n5\n3\n1 1\n2\n1 2\n2 2\n2 1\n1\n1\n2 2\n3 2\n2 4\n1 1\n5\n1 2\n2 1\n1 2\n1 1\n1 2\n1 1\n1 2\n1 1\n1 1\n3\n2 2\n1 2\n2 2\n1 2\n4 3\n1 1\n3\n2 1\n2\n2\n1 2\n3 2\n2 1\n3\n1\n2 1\n1\n1\n2 1\n1\n2\n2 2\n2 1\n2 1\n1 1\n2\n1 2\n3 5\n1 1\n2\n", "1\n4 2\n1 1\n2 1\n1 2\n2 2\n"], "outputs": ["12\n29\n", "10\n3\n1\n1\n3\n2\n1\n2\n3\n6\n1\n7\n2\n2\n2\n1\n2\n8\n2\n2\n2\n7\n5\n2\n1\n1\n1\n3\n4\n4\n3\n4\n3\n4\n2\n3\n4\n2\n5\n2\n", "7\n"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 3, "n_test_cases_kept": 3, "test_cases_truncated": false, "problem_sha1": "759846e1fdf931ca5ac0be6a354fa7f1268083b0", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-01258", "original_id": null, "source": "apps", "domain": "code", "problem": "There are N towns on a line running east-west.\nThe towns are numbered 1 through N, in order from west to east.\nEach point on the line has a one-dimensional coordinate, and a point that is farther east has a greater coordinate value.\nThe coordinate of town i is X_i.\nYou are now at town 1, and you want to visit all the other towns.\nYou have two ways to travel:\n - Walk on the line.\nYour fatigue level increases by A each time you travel a distance of 1, regardless of direction.\n - Teleport to any location of your choice.\nYour fatigue level increases by B, regardless of the distance covered.\nFind the minimum possible total increase of your fatigue level when you visit all the towns in these two ways.\n\n-----Constraints-----\n - All input values are integers.\n - 2≤N≤10^5\n - 1≤X_i≤10^9\n - For all i(1≤i≤N-1), X_i bool:\n ", "test_cases": {"inputs": [["\"abba\"", "\"dog cat cat dog\""]], "outputs": [false], "fn_name": "wordPattern"}, "test_case_format": "function_call", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "6561794ff1b729573b5d1e36a1242a4dd8af224a", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "wordPattern"} {"seed_id": "apps-01288", "original_id": null, "source": "apps", "domain": "code", "problem": "Let's call an array arr a mountain if the following properties hold:\n\narr.length >= 3\nThere exists some i with 0 < i < arr.length - 1 such that:\n \narr[0] < arr[1] < ... arr[i-1] < arr[i] \narr[i] > arr[i+1] > ... > arr[arr.length - 1]\n\n\n\nGiven an integer array arr that is guaranteed to be a mountain, return any i such that arr[0] < arr[1] < ... arr[i - 1] < arr[i] > arr[i + 1] > ... > arr[arr.length - 1].\n \nExample 1:\nInput: arr = [0,1,0]\nOutput: 1\nExample 2:\nInput: arr = [0,2,1,0]\nOutput: 1\nExample 3:\nInput: arr = [0,10,5,2]\nOutput: 1\nExample 4:\nInput: arr = [3,4,5,1]\nOutput: 2\nExample 5:\nInput: arr = [24,69,100,99,79,78,67,36,26,19]\nOutput: 2\n\n \nConstraints:\n\n3 <= arr.length <= 104\n0 <= arr[i] <= 106\narr is guaranteed to be a mountain array.", "starter_code": "\nclass Solution:\n def peakIndexInMountainArray(self, arr: List[int]) -> int:\n ", "test_cases": {"inputs": [[[0, 1, 0]]], "outputs": [1], "fn_name": "peakIndexInMountainArray"}, "test_case_format": "function_call", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "b71b491479216e2fba10302a8d0608a7bb027a5d", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "peakIndexInMountainArray"} {"seed_id": "apps-01293", "original_id": null, "source": "apps", "domain": "code", "problem": "Given a non-empty array of integers, return the third maximum number in this array. If it does not exist, return the maximum number. The time complexity must be in O(n).\n\nExample 1:\n\nInput: [3, 2, 1]\n\nOutput: 1\n\nExplanation: The third maximum is 1.\n\n\n\nExample 2:\n\nInput: [1, 2]\n\nOutput: 2\n\nExplanation: The third maximum does not exist, so the maximum (2) is returned instead.\n\n\n\nExample 3:\n\nInput: [2, 2, 3, 1]\n\nOutput: 1\n\nExplanation: Note that the third maximum here means the third maximum distinct number.\nBoth numbers with value 2 are both considered as second maximum.", "starter_code": "\nclass Solution:\n def thirdMax(self, nums: List[int]) -> int:\n ", "test_cases": {"inputs": [[[3, 2, 1]]], "outputs": [1], "fn_name": "thirdMax"}, "test_case_format": "function_call", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "0542b9c7967d617e36382924dc0ab8a3129a56c2", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "thirdMax"} {"seed_id": "apps-01298", "original_id": null, "source": "apps", "domain": "code", "problem": "Given a positive integer num, write a function which returns True if num is a perfect square else False.\n\n\nNote: Do not use any built-in library function such as sqrt.\n\n\nExample 1:\n\nInput: 16\nReturns: True\n\n\n\nExample 2:\n\nInput: 14\nReturns: False\n\n\n\nCredits:Special thanks to @elmirap for adding this problem and creating all test cases.", "starter_code": "\nclass Solution:\n def isPerfectSquare(self, num: int) -> bool:\n ", "test_cases": {"inputs": [[16]], "outputs": [true], "fn_name": "isPerfectSquare"}, "test_case_format": "function_call", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "155733566afed7ab8f0c93beae4ecbb1bdea9cfb", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "isPerfectSquare"} {"seed_id": "apps-01303", "original_id": null, "source": "apps", "domain": "code", "problem": "Given an array of integers nums, you start with an initial positive value startValue.\nIn each iteration, you calculate the step by step sum of startValue plus elements in nums (from left to right).\nReturn the minimum positive value of startValue such that the step by step sum is never less than 1.\n \nExample 1:\nInput: nums = [-3,2,-3,4,2]\nOutput: 5\nExplanation: If you choose startValue = 4, in the third iteration your step by step sum is less than 1.\n step by step sum\n  startValue = 4 | startValue = 5 | nums\n  (4 -3 ) = 1 | (5 -3 ) = 2 | -3\n  (1 +2 ) = 3 | (2 +2 ) = 4 | 2\n  (3 -3 ) = 0 | (4 -3 ) = 1 | -3\n  (0 +4 ) = 4 | (1 +4 ) = 5 | 4\n  (4 +2 ) = 6 | (5 +2 ) = 7 | 2\n\nExample 2:\nInput: nums = [1,2]\nOutput: 1\nExplanation: Minimum start value should be positive. \n\nExample 3:\nInput: nums = [1,-2,-3]\nOutput: 5\n\n \nConstraints:\n\n1 <= nums.length <= 100\n-100 <= nums[i] <= 100", "starter_code": "\nclass Solution:\n def minStartValue(self, nums: List[int]) -> int:\n ", "test_cases": {"inputs": [[[-3, 2, -3, 4, 2]]], "outputs": [5], "fn_name": "minStartValue"}, "test_case_format": "function_call", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "dfbd8418d6ed9da896fe9e4946f5569032db3ed8", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "minStartValue"} {"seed_id": "apps-01308", "original_id": null, "source": "apps", "domain": "code", "problem": "Given a positive integer, check whether it has alternating bits: namely, if two adjacent bits will always have different values.\n\nExample 1:\n\nInput: 5\nOutput: True\nExplanation:\nThe binary representation of 5 is: 101\n\n\n\nExample 2:\n\nInput: 7\nOutput: False\nExplanation:\nThe binary representation of 7 is: 111.\n\n\n\nExample 3:\n\nInput: 11\nOutput: False\nExplanation:\nThe binary representation of 11 is: 1011.\n\n\n\nExample 4:\n\nInput: 10\nOutput: True\nExplanation:\nThe binary representation of 10 is: 1010.", "starter_code": "\nclass Solution:\n def hasAlternatingBits(self, n: int) -> bool:\n ", "test_cases": {"inputs": [[5]], "outputs": [true], "fn_name": "hasAlternatingBits"}, "test_case_format": "function_call", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "96533fb5ed373cc4ccc665802543e0ef36455e47", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "hasAlternatingBits"} {"seed_id": "apps-01313", "original_id": null, "source": "apps", "domain": "code", "problem": "Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases.\n\nNote: For the purpose of this problem, we define empty string as valid palindrome.\n\nExample 1:\n\n\nInput: \"A man, a plan, a canal: Panama\"\nOutput: true\n\n\nExample 2:\n\n\nInput: \"race a car\"\nOutput: false", "starter_code": "\nclass Solution:\n def isPalindrome(self, s: str) -> bool:\n ", "test_cases": {"inputs": [["\"A man, a plan, a canal: Panama\""]], "outputs": [true], "fn_name": "isPalindrome"}, "test_case_format": "function_call", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "4e80e0669d3750da2e40e46cd0e4e585985daec4", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "isPalindrome"} {"seed_id": "apps-01318", "original_id": null, "source": "apps", "domain": "code", "problem": "Given a string s of lower and upper case English letters.\nA good string is a string which doesn't have two adjacent characters s[i] and s[i + 1] where:\n\n0 <= i <= s.length - 2\ns[i] is a lower-case letter and s[i + 1] is the same letter but in upper-case or vice-versa.\n\nTo make the string good, you can choose two adjacent characters that make the string bad and remove them. You can keep doing this until the string becomes good.\nReturn the string after making it good. The answer is guaranteed to be unique under the given constraints.\nNotice that an empty string is also good.\n \nExample 1:\nInput: s = \"leEeetcode\"\nOutput: \"leetcode\"\nExplanation: In the first step, either you choose i = 1 or i = 2, both will result \"leEeetcode\" to be reduced to \"leetcode\".\n\nExample 2:\nInput: s = \"abBAcC\"\nOutput: \"\"\nExplanation: We have many possible scenarios, and all lead to the same answer. For example:\n\"abBAcC\" --> \"aAcC\" --> \"cC\" --> \"\"\n\"abBAcC\" --> \"abBA\" --> \"aA\" --> \"\"\n\nExample 3:\nInput: s = \"s\"\nOutput: \"s\"\n\n \nConstraints:\n\n1 <= s.length <= 100\ns contains only lower and upper case English letters.", "starter_code": "\nclass Solution:\n def makeGood(self, s: str) -> str:\n ", "test_cases": {"inputs": [["\"leEeetcode\""]], "outputs": ["\"leetcode\""], "fn_name": "makeGood"}, "test_case_format": "function_call", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "9bdd7cf575f2f12dec912feb33a86fb60b04104a", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "makeGood"} {"seed_id": "apps-01323", "original_id": null, "source": "apps", "domain": "code", "problem": "We define a harmonious array is an array where the difference between its maximum value and its minimum value is exactly 1.\n\nNow, given an integer array, you need to find the length of its longest harmonious subsequence among all its possible subsequences.\n\nExample 1:\n\nInput: [1,3,2,2,5,2,3,7]\nOutput: 5\nExplanation: The longest harmonious subsequence is [3,2,2,2,3].\n\n\n\nNote:\nThe length of the input array will not exceed 20,000.", "starter_code": "\nclass Solution:\n def findLHS(self, nums: List[int]) -> int:\n ", "test_cases": {"inputs": [[[1, 3, 2, 2, 5, 2, 3, 7]]], "outputs": [5], "fn_name": "findLHS"}, "test_case_format": "function_call", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "39002df68bc3626d25beef74eaff16df33492488", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "findLHS"} {"seed_id": "apps-01328", "original_id": null, "source": "apps", "domain": "code", "problem": "Given an arbitrary ransom note string and another string containing letters from all the magazines, write a function that will return true if the ransom \nnote can be constructed from the magazines ; otherwise, it will return false. \n\n\nEach letter in the magazine string can only be used once in your ransom note.\n\n\nNote:\nYou may assume that both strings contain only lowercase letters.\n\n\n\ncanConstruct(\"a\", \"b\") -> false\ncanConstruct(\"aa\", \"ab\") -> false\ncanConstruct(\"aa\", \"aab\") -> true", "starter_code": "\nclass Solution:\n def canConstruct(self, ransomNote: str, magazine: str) -> bool:\n ", "test_cases": {"inputs": [["\"a\"", "\"b\""]], "outputs": [false], "fn_name": "canConstruct"}, "test_case_format": "function_call", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "9760ba6ba8a813a779fb8eab0232239f173d71b0", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "canConstruct"} {"seed_id": "apps-01333", "original_id": null, "source": "apps", "domain": "code", "problem": "Given two strings S and T, return if they are equal when both are typed into empty text editors. # means a backspace character.\nNote that after backspacing an empty text, the text will continue empty.\n\nExample 1:\nInput: S = \"ab#c\", T = \"ad#c\"\nOutput: true\nExplanation: Both S and T become \"ac\".\n\n\nExample 2:\nInput: S = \"ab##\", T = \"c#d#\"\nOutput: true\nExplanation: Both S and T become \"\".\n\n\nExample 3:\nInput: S = \"a##c\", T = \"#a#c\"\nOutput: true\nExplanation: Both S and T become \"c\".\n\n\nExample 4:\nInput: S = \"a#c\", T = \"b\"\nOutput: false\nExplanation: S becomes \"c\" while T becomes \"b\".\n\nNote:\n\n1 <= S.length <= 200\n1 <= T.length <= 200\nS and T only contain lowercase letters and '#' characters.\n\nFollow up:\n\nCan you solve it in O(N) time and O(1) space?", "starter_code": "\nclass Solution:\n def backspaceCompare(self, S: str, T: str) -> bool:\n ", "test_cases": {"inputs": [["\"ab#c\"", "\"ad#c\""]], "outputs": [true], "fn_name": "backspaceCompare"}, "test_case_format": "function_call", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "b15fcaa5222ffedfd2ae2d812cc8f94a440dccb2", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "backspaceCompare"} {"seed_id": "apps-01338", "original_id": null, "source": "apps", "domain": "code", "problem": "Given an integer, write a function to determine if it is a power of two.\n\nExample 1:\n\n\nInput: 1\nOutput: true \nExplanation: 20 = 1\n\n\nExample 2:\n\n\nInput: 16\nOutput: true\nExplanation: 24 = 16\n\nExample 3:\n\n\nInput: 218\nOutput: false", "starter_code": "\nclass Solution:\n def isPowerOfTwo(self, n: int) -> bool:\n ", "test_cases": {"inputs": [[1]], "outputs": [true], "fn_name": "isPowerOfTwo"}, "test_case_format": "function_call", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "cada027c36f83cdeac58e805106507f1a7cc7ec8", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "isPowerOfTwo"} {"seed_id": "apps-01343", "original_id": null, "source": "apps", "domain": "code", "problem": "Tic-tac-toe is played by two players A and B on a 3 x 3 grid.\nHere are the rules of Tic-Tac-Toe:\n\nPlayers take turns placing characters into empty squares (\" \").\nThe first player A always places \"X\" characters, while the second player B always places \"O\" characters.\n\"X\" and \"O\" characters are always placed into empty squares, never on filled ones.\nThe game ends when there are 3 of the same (non-empty) character filling any row, column, or diagonal.\nThe game also ends if all squares are non-empty.\nNo more moves can be played if the game is over.\n\nGiven an array moves where each element is another array of size 2 corresponding to the row and column of the grid where they mark their respective character in the order in which A and B play.\nReturn the winner of the game if it exists (A or B), in case the game ends in a draw return \"Draw\", if there are still movements to play return \"Pending\".\nYou can assume that moves is valid (It follows the rules of Tic-Tac-Toe), the grid is initially empty and A will play first.\n \nExample 1:\nInput: moves = [[0,0],[2,0],[1,1],[2,1],[2,2]]\nOutput: \"A\"\nExplanation: \"A\" wins, he always plays first.\n\"X \" \"X \" \"X \" \"X \" \"X \"\n\" \" -> \" \" -> \" X \" -> \" X \" -> \" X \"\n\" \" \"O \" \"O \" \"OO \" \"OOX\"\n\nExample 2:\nInput: moves = [[0,0],[1,1],[0,1],[0,2],[1,0],[2,0]]\nOutput: \"B\"\nExplanation: \"B\" wins.\n\"X \" \"X \" \"XX \" \"XXO\" \"XXO\" \"XXO\"\n\" \" -> \" O \" -> \" O \" -> \" O \" -> \"XO \" -> \"XO \" \n\" \" \" \" \" \" \" \" \" \" \"O \"\n\nExample 3:\nInput: moves = [[0,0],[1,1],[2,0],[1,0],[1,2],[2,1],[0,1],[0,2],[2,2]]\nOutput: \"Draw\"\nExplanation: The game ends in a draw since there are no moves to make.\n\"XXO\"\n\"OOX\"\n\"XOX\"\n\nExample 4:\nInput: moves = [[0,0],[1,1]]\nOutput: \"Pending\"\nExplanation: The game has not finished yet.\n\"X \"\n\" O \"\n\" \"\n\n \nConstraints:\n\n1 <= moves.length <= 9\nmoves[i].length == 2\n0 <= moves[i][j] <= 2\nThere are no repeated elements on moves.\nmoves follow the rules of tic tac toe.", "starter_code": "\nclass Solution:\n def tictactoe(self, moves: List[List[int]]) -> str:\n ", "test_cases": {"inputs": [[[[0, 0], [2, 0], [1, 1], [2, 1], [2, 2], [], []]]], "outputs": ["A"], "fn_name": "tictactoe"}, "test_case_format": "function_call", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "fbff3cb92c606a499e6ac311fe33ee1ca49f85db", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "tictactoe"} {"seed_id": "apps-01348", "original_id": null, "source": "apps", "domain": "code", "problem": "Implement int sqrt(int x).\n\nCompute and return the square root of x, where x is guaranteed to be a non-negative integer.\n\nSince the return type is an integer, the decimal digits are truncated and only the integer part of the result is returned.\n\nExample 1:\n\n\nInput: 4\nOutput: 2\n\n\nExample 2:\n\n\nInput: 8\nOutput: 2\nExplanation: The square root of 8 is 2.82842..., and since \n  the decimal part is truncated, 2 is returned.", "starter_code": "\nclass Solution:\n def mySqrt(self, x: int) -> int:\n ", "test_cases": {"inputs": [[4]], "outputs": [2], "fn_name": "mySqrt"}, "test_case_format": "function_call", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "0e608492d689b32d66643da21577741c96b09593", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "mySqrt"} {"seed_id": "apps-01353", "original_id": null, "source": "apps", "domain": "code", "problem": "Initially, there is a Robot at position (0, 0). Given a sequence of its moves, judge if this robot makes a circle, which means it moves back to the original place. \n\n\n\nThe move sequence is represented by a string. And each move is represent by a character. The valid robot moves are R (Right), L (Left), U (Up) and D (down). The output should be true or false representing whether the robot makes a circle.\n\n\nExample 1:\n\nInput: \"UD\"\nOutput: true\n\n\n\nExample 2:\n\nInput: \"LL\"\nOutput: false", "starter_code": "\nclass Solution:\n def judgeCircle(self, moves: str) -> bool:\n", "test_cases": {"inputs": [["\"UD\""]], "outputs": [true], "fn_name": "judgeCircle"}, "test_case_format": "function_call", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "169cb3d05a92b0e11b47a794226065046116a3d0", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "judgeCircle"} {"seed_id": "apps-01358", "original_id": null, "source": "apps", "domain": "code", "problem": "For two strings s and t, we say \"t divides s\" if and only if s = t + ... + t  (t concatenated with itself 1 or more times)\nGiven two strings str1 and str2, return the largest string x such that x divides both str1 and str2.\n \nExample 1:\nInput: str1 = \"ABCABC\", str2 = \"ABC\"\nOutput: \"ABC\"\nExample 2:\nInput: str1 = \"ABABAB\", str2 = \"ABAB\"\nOutput: \"AB\"\nExample 3:\nInput: str1 = \"LEET\", str2 = \"CODE\"\nOutput: \"\"\nExample 4:\nInput: str1 = \"ABCDEF\", str2 = \"ABC\"\nOutput: \"\"\n\n \nConstraints:\n\n1 <= str1.length <= 1000\n1 <= str2.length <= 1000\nstr1 and str2 consist of English uppercase letters.", "starter_code": "\nclass Solution:\n def gcdOfStrings(self, str1: str, str2: str) -> str:\n ", "test_cases": {"inputs": [["\"ABCABC\"", "\"ABC\""]], "outputs": [""], "fn_name": "gcdOfStrings"}, "test_case_format": "function_call", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "b8a6823e82f84a909fabdecff8a7bddacbd454ff", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "gcdOfStrings"} {"seed_id": "apps-01363", "original_id": null, "source": "apps", "domain": "code", "problem": "Say you have an array for which the ith element is the price of a given stock on day i.\n\nIf you were only permitted to complete at most one transaction (i.e., buy one and sell one share of the stock), design an algorithm to find the maximum profit.\n\nNote that you cannot sell a stock before you buy one.\n\nExample 1:\n\n\nInput: [7,1,5,3,6,4]\nOutput: 5\nExplanation: Buy on day 2 (price = 1) and sell on day 5 (price = 6), profit = 6-1 = 5.\n  Not 7-1 = 6, as selling price needs to be larger than buying price.\n\n\nExample 2:\n\n\nInput: [7,6,4,3,1]\nOutput: 0\nExplanation: In this case, no transaction is done, i.e. max profit = 0.", "starter_code": "\nclass Solution:\n def maxProfit(self, prices: List[int]) -> int:\n ", "test_cases": {"inputs": [[[7, 1, 5, 3, 6, 4]]], "outputs": [5], "fn_name": "maxProfit"}, "test_case_format": "function_call", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "b392271424a5d89d4badf4d8f1cb96993b633c3c", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "maxProfit"} {"seed_id": "apps-01368", "original_id": null, "source": "apps", "domain": "code", "problem": "Given a valid (IPv4) IP address, return a defanged version of that IP address.\nA defanged IP address replaces every period \".\" with \"[.]\".\n \nExample 1:\nInput: address = \"1.1.1.1\"\nOutput: \"1[.]1[.]1[.]1\"\nExample 2:\nInput: address = \"255.100.50.0\"\nOutput: \"255[.]100[.]50[.]0\"\n\n \nConstraints:\n\nThe given address is a valid IPv4 address.", "starter_code": "\nclass Solution:\n def defangIPaddr(self, address: str) -> str:\n ", "test_cases": {"inputs": [["\"1.1.1.1\""]], "outputs": ["\"1[.]1[.]1[.]1\""], "fn_name": "defangIPaddr"}, "test_case_format": "function_call", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "4d0f8c337e2772016aa2bf5d0ffa449618b60be0", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "defangIPaddr"} {"seed_id": "apps-01373", "original_id": null, "source": "apps", "domain": "code", "problem": "In a deck of cards, each card has an integer written on it.\nReturn true if and only if you can choose X >= 2 such that it is possible to split the entire deck into 1 or more groups of cards, where:\n\nEach group has exactly X cards.\nAll the cards in each group have the same integer.\n\n \nExample 1:\nInput: deck = [1,2,3,4,4,3,2,1]\nOutput: true\nExplanation: Possible partition [1,1],[2,2],[3,3],[4,4].\n\nExample 2:\nInput: deck = [1,1,1,2,2,2,3,3]\nOutput: false´\nExplanation: No possible partition.\n\nExample 3:\nInput: deck = [1]\nOutput: false\nExplanation: No possible partition.\n\nExample 4:\nInput: deck = [1,1]\nOutput: true\nExplanation: Possible partition [1,1].\n\nExample 5:\nInput: deck = [1,1,2,2,2,2]\nOutput: true\nExplanation: Possible partition [1,1],[2,2],[2,2].\n\n \nConstraints:\n\n1 <= deck.length <= 10^4\n0 <= deck[i] < 10^4", "starter_code": "\nclass Solution:\n def hasGroupsSizeX(self, deck: List[int]) -> bool:\n ", "test_cases": {"inputs": [[[1, 2, 3, 4, 4, 3, 2, 1]]], "outputs": [true], "fn_name": "hasGroupsSizeX"}, "test_case_format": "function_call", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "d1b2a3538c125a664ed5124f8e8db88fc0ddd674", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "hasGroupsSizeX"} {"seed_id": "apps-01378", "original_id": null, "source": "apps", "domain": "code", "problem": "Given an array of positive integers arr, calculate the sum of all possible odd-length subarrays.\nA subarray is a contiguous subsequence of the array.\nReturn the sum of all odd-length subarrays of arr.\n \nExample 1:\nInput: arr = [1,4,2,5,3]\nOutput: 58\nExplanation: The odd-length subarrays of arr and their sums are:\n[1] = 1\n[4] = 4\n[2] = 2\n[5] = 5\n[3] = 3\n[1,4,2] = 7\n[4,2,5] = 11\n[2,5,3] = 10\n[1,4,2,5,3] = 15\nIf we add all these together we get 1 + 4 + 2 + 5 + 3 + 7 + 11 + 10 + 15 = 58\nExample 2:\nInput: arr = [1,2]\nOutput: 3\nExplanation: There are only 2 subarrays of odd length, [1] and [2]. Their sum is 3.\nExample 3:\nInput: arr = [10,11,12]\nOutput: 66\n\n \nConstraints:\n\n1 <= arr.length <= 100\n1 <= arr[i] <= 1000", "starter_code": "\nclass Solution:\n def sumOddLengthSubarrays(self, arr: List[int]) -> int:\n ", "test_cases": {"inputs": [[[1, 4, 2, 5, 3]]], "outputs": [58], "fn_name": "sumOddLengthSubarrays"}, "test_case_format": "function_call", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "8add5ac75f00260e638453d42c32869d571d59cd", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "sumOddLengthSubarrays"} {"seed_id": "apps-01383", "original_id": null, "source": "apps", "domain": "code", "problem": "Given a non-empty integer array of size n, find the minimum number of moves required to make all array elements equal, where a move is incrementing n - 1 elements by 1.\n\nExample:\n\nInput:\n[1,2,3]\n\nOutput:\n3\n\nExplanation:\nOnly three moves are needed (remember each move increments two elements):\n\n[1,2,3] => [2,3,3] => [3,4,3] => [4,4,4]", "starter_code": "\nclass Solution:\n def minMoves(self, nums: List[int]) -> int:\n ", "test_cases": {"inputs": [[[1, 2, 3]]], "outputs": [3], "fn_name": "minMoves"}, "test_case_format": "function_call", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "1ab1a2796db69ad7006aa5ce98fb09c226ac4bb5", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "minMoves"} {"seed_id": "apps-01388", "original_id": null, "source": "apps", "domain": "code", "problem": "Given two integer arrays arr1 and arr2, and the integer d, return the distance value between the two arrays.\nThe distance value is defined as the number of elements arr1[i] such that there is not any element arr2[j] where |arr1[i]-arr2[j]| <= d.\n \nExample 1:\nInput: arr1 = [4,5,8], arr2 = [10,9,1,8], d = 2\nOutput: 2\nExplanation: \nFor arr1[0]=4 we have: \n|4-10|=6 > d=2 \n|4-9|=5 > d=2 \n|4-1|=3 > d=2 \n|4-8|=4 > d=2 \nFor arr1[1]=5 we have: \n|5-10|=5 > d=2 \n|5-9|=4 > d=2 \n|5-1|=4 > d=2 \n|5-8|=3 > d=2\nFor arr1[2]=8 we have:\n|8-10|=2 <= d=2\n|8-9|=1 <= d=2\n|8-1|=7 > d=2\n|8-8|=0 <= d=2\n\nExample 2:\nInput: arr1 = [1,4,2,3], arr2 = [-4,-3,6,10,20,30], d = 3\nOutput: 2\n\nExample 3:\nInput: arr1 = [2,1,100,3], arr2 = [-5,-2,10,-3,7], d = 6\nOutput: 1\n\n \nConstraints:\n\n1 <= arr1.length, arr2.length <= 500\n-10^3 <= arr1[i], arr2[j] <= 10^3\n0 <= d <= 100", "starter_code": "\nclass Solution:\n def findTheDistanceValue(self, arr1: List[int], arr2: List[int], d: int) -> int:\n ", "test_cases": {"inputs": [[[4, 5, 8], [10, 9, 1, 8], 2]], "outputs": [2], "fn_name": "findTheDistanceValue"}, "test_case_format": "function_call", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "4c47206edf3a4a4f8276c9ec5f2ca0e58de8c27d", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "findTheDistanceValue"} {"seed_id": "apps-01393", "original_id": null, "source": "apps", "domain": "code", "problem": "Given a sentence that consists of some words separated by a single space, and a searchWord.\nYou have to check if searchWord is a prefix of any word in sentence.\nReturn the index of the word in sentence where searchWord is a prefix of this word (1-indexed).\nIf searchWord is a prefix of more than one word, return the index of the first word (minimum index). If there is no such word return -1.\nA prefix of a string S is any leading contiguous substring of S.\n \nExample 1:\nInput: sentence = \"i love eating burger\", searchWord = \"burg\"\nOutput: 4\nExplanation: \"burg\" is prefix of \"burger\" which is the 4th word in the sentence.\n\nExample 2:\nInput: sentence = \"this problem is an easy problem\", searchWord = \"pro\"\nOutput: 2\nExplanation: \"pro\" is prefix of \"problem\" which is the 2nd and the 6th word in the sentence, but we return 2 as it's the minimal index.\n\nExample 3:\nInput: sentence = \"i am tired\", searchWord = \"you\"\nOutput: -1\nExplanation: \"you\" is not a prefix of any word in the sentence.\n\nExample 4:\nInput: sentence = \"i use triple pillow\", searchWord = \"pill\"\nOutput: 4\n\nExample 5:\nInput: sentence = \"hello from the other side\", searchWord = \"they\"\nOutput: -1\n\n \nConstraints:\n\n1 <= sentence.length <= 100\n1 <= searchWord.length <= 10\nsentence consists of lowercase English letters and spaces.\nsearchWord consists of lowercase English letters.", "starter_code": "\nclass Solution:\n def isPrefixOfWord(self, sentence: str, searchWord: str) -> int:\n ", "test_cases": {"inputs": [["\"i love eating burger\"", "\"burg\""]], "outputs": [-1], "fn_name": "isPrefixOfWord"}, "test_case_format": "function_call", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "b3c67bdee9cbb1ed4ad8770c9db24d93bcdde77b", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "isPrefixOfWord"} {"seed_id": "apps-01398", "original_id": null, "source": "apps", "domain": "code", "problem": "The Hamming distance between two integers is the number of positions at which the corresponding bits are different.\n\nGiven two integers x and y, calculate the Hamming distance.\n\nNote:\n0 ≤ x, y < 231.\n\n\nExample:\n\nInput: x = 1, y = 4\n\nOutput: 2\n\nExplanation:\n1 (0 0 0 1)\n4 (0 1 0 0)\n ↑ ↑\n\nThe above arrows point to positions where the corresponding bits are different.", "starter_code": "\nclass Solution:\n def hammingDistance(self, x: int, y: int) -> int:\n ", "test_cases": {"inputs": [[1, 4]], "outputs": [2], "fn_name": "hammingDistance"}, "test_case_format": "function_call", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "13e2e4cd0f4df52ac863d5ccac66b1801d109bc5", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "hammingDistance"} {"seed_id": "apps-01403", "original_id": null, "source": "apps", "domain": "code", "problem": "Given an integer array, you need to find one continuous subarray that if you only sort this subarray in ascending order, then the whole array will be sorted in ascending order, too. \n\nYou need to find the shortest such subarray and output its length.\n\nExample 1:\n\nInput: [2, 6, 4, 8, 10, 9, 15]\nOutput: 5\nExplanation: You need to sort [6, 4, 8, 10, 9] in ascending order to make the whole array sorted in ascending order.\n\n\n\nNote:\n\nThen length of the input array is in range [1, 10,000].\nThe input array may contain duplicates, so ascending order here means .", "starter_code": "\nclass Solution:\n def findUnsortedSubarray(self, nums: List[int]) -> int:\n ", "test_cases": {"inputs": [[[2, 6, 4, 8, 10, 9, 15]]], "outputs": [5], "fn_name": "findUnsortedSubarray"}, "test_case_format": "function_call", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "de64178d261d31d01bcbe4b8da57a4f89d759c72", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "findUnsortedSubarray"} {"seed_id": "apps-01408", "original_id": null, "source": "apps", "domain": "code", "problem": "Given an array of integers arr, a lucky integer is an integer which has a frequency in the array equal to its value.\nReturn a lucky integer in the array. If there are multiple lucky integers return the largest of them. If there is no lucky integer return -1.\n \nExample 1:\nInput: arr = [2,2,3,4]\nOutput: 2\nExplanation: The only lucky number in the array is 2 because frequency[2] == 2.\n\nExample 2:\nInput: arr = [1,2,2,3,3,3]\nOutput: 3\nExplanation: 1, 2 and 3 are all lucky numbers, return the largest of them.\n\nExample 3:\nInput: arr = [2,2,2,3,3]\nOutput: -1\nExplanation: There are no lucky numbers in the array.\n\nExample 4:\nInput: arr = [5]\nOutput: -1\n\nExample 5:\nInput: arr = [7,7,7,7,7,7,7]\nOutput: 7\n\n \nConstraints:\n\n1 <= arr.length <= 500\n1 <= arr[i] <= 500", "starter_code": "\nclass Solution:\n def findLucky(self, arr: List[int]) -> int:\n ", "test_cases": {"inputs": [[[2, 2, 3, 4]]], "outputs": [2], "fn_name": "findLucky"}, "test_case_format": "function_call", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "98fb5143ab3a332bea6043e4b85cca2cdbbc25d7", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "findLucky"} {"seed_id": "apps-01413", "original_id": null, "source": "apps", "domain": "code", "problem": "Given an integer (signed 32 bits), write a function to check whether it is a power of 4.\n\nExample:\nGiven num = 16, return true.\nGiven num = 5, return false.\n\n\nFollow up: Could you solve it without loops/recursion?\n\nCredits:Special thanks to @yukuairoy for adding this problem and creating all test cases.", "starter_code": "\nclass Solution:\n def isPowerOfFour(self, num: int) -> bool:\n ", "test_cases": {"inputs": [[16]], "outputs": [true], "fn_name": "isPowerOfFour"}, "test_case_format": "function_call", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "0fe0dfe9084472f3cb96be68aec47287471ceb78", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "isPowerOfFour"} {"seed_id": "apps-01418", "original_id": null, "source": "apps", "domain": "code", "problem": "Given a m * n matrix grid which is sorted in non-increasing order both row-wise and column-wise. \nReturn the number of negative numbers in grid.\n \nExample 1:\nInput: grid = [[4,3,2,-1],[3,2,1,-1],[1,1,-1,-2],[-1,-1,-2,-3]]\nOutput: 8\nExplanation: There are 8 negatives number in the matrix.\n\nExample 2:\nInput: grid = [[3,2],[1,0]]\nOutput: 0\n\nExample 3:\nInput: grid = [[1,-1],[-1,-1]]\nOutput: 3\n\nExample 4:\nInput: grid = [[-1]]\nOutput: 1\n\n \nConstraints:\n\nm == grid.length\nn == grid[i].length\n1 <= m, n <= 100\n-100 <= grid[i][j] <= 100", "starter_code": "\nclass Solution:\n def countNegatives(self, grid: List[List[int]]) -> int:\n ", "test_cases": {"inputs": [[[[4, 3, 2, -1], [3, 2, 1, -1], [1, 1, -1, -2], [-1, -1, -2, -3], [], []]]], "outputs": [8], "fn_name": "countNegatives"}, "test_case_format": "function_call", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "b4f2507ccfc94ed3461c9d3be4b86d8624b36eee", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "countNegatives"} {"seed_id": "apps-01423", "original_id": null, "source": "apps", "domain": "code", "problem": "Given an integer array sorted in non-decreasing order, there is exactly one integer in the array that occurs more than 25% of the time.\nReturn that integer.\n \nExample 1:\nInput: arr = [1,2,2,6,6,6,6,7,10]\nOutput: 6\n\n \nConstraints:\n\n1 <= arr.length <= 10^4\n0 <= arr[i] <= 10^5", "starter_code": "\nclass Solution:\n def findSpecialInteger(self, arr: List[int]) -> int:\n ", "test_cases": {"inputs": [[[1, 2, 2, 6, 6, 6, 6, 7, 10]]], "outputs": [6], "fn_name": "findSpecialInteger"}, "test_case_format": "function_call", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "4ecac86d0ac8c68468961cc2b45dd738600e7619", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "findSpecialInteger"} {"seed_id": "apps-01428", "original_id": null, "source": "apps", "domain": "code", "problem": "=====Function Descriptions=====\nitertools.product()\n\nThis tool computes the cartesian product of input iterables.\nIt is equivalent to nested for-loops.\nFor example, product(A, B) returns the same as ((x,y) for x in A for y in B).\n\nSample Code\n\n>>> from itertools import product\n>>>\n>>> print list(product([1,2,3],repeat = 2))\n[(1, 1), (1, 2), (1, 3), (2, 1), (2, 2), (2, 3), (3, 1), (3, 2), (3, 3)]\n>>>\n>>> print list(product([1,2,3],[3,4]))\n[(1, 3), (1, 4), (2, 3), (2, 4), (3, 3), (3, 4)]\n>>>\n>>> A = [[1,2,3],[3,4,5]]\n>>> print list(product(*A))\n[(1, 3), (1, 4), (1, 5), (2, 3), (2, 4), (2, 5), (3, 3), (3, 4), (3, 5)]\n>>>\n>>> B = [[1,2,3],[3,4,5],[7,8]]\n>>> print list(product(*B))\n[(1, 3, 7), (1, 3, 8), (1, 4, 7), (1, 4, 8), (1, 5, 7), (1, 5, 8), (2, 3, 7), (2, 3, 8), (2, 4, 7), (2, 4, 8), (2, 5, 7), (2, 5, 8), (3, 3, 7), (3, 3, 8), (3, 4, 7), (3, 4, 8), (3, 5, 7), (3, 5, 8)]\n\n=====Problem Statement=====\nYou are given a two lists A and B. Your task is to compute their cartesian product AXB.\nExample\nA = [1, 2]\nB = [3, 4]\n\nAxB = [(1, 3), (1, 4), (2, 3), (2, 4)]\nNote: A and B are sorted lists, and the cartesian product's tuples should be output in sorted order.\n\n=====Input Format=====\nThe first line contains the space separated elements of list A.\nThe second line contains the space separated elements of list B.\nBoth lists have no duplicate integer elements.\n\n=====Constraints=====\n0>> s = set('HackerRank')\n>>> s.add('H')\n>>> print s\nset(['a', 'c', 'e', 'H', 'k', 'n', 'r', 'R'])\n>>> print s.add('HackerRank')\nNone\n>>> print s\nset(['a', 'c', 'e', 'HackerRank', 'H', 'k', 'n', 'r', 'R'])\n\n=====Problem Statement=====\nApply your knowledge of the .add() operation to help your friend Rupal.\nRupal has a huge collection of country stamps. She decided to count the total number of distinct country stamps in her collection. She asked for your help. You pick the stamps one by one from a stack of N country stamps.\nFind the total number of distinct country stamps.\n\n=====Input Format=====\nThe fist line contains an integer N, the total number of country stamps.\nThe next N lines contains the name of the country where the stamp is from.\n\n=====Constraints=====\n0>> print set()\nset([])\n\n>>> print set('HackerRank')\nset(['a', 'c', 'e', 'H', 'k', 'n', 'r', 'R'])\n\n>>> print set([1,2,1,2,3,4,5,6,0,9,12,22,3])\nset([0, 1, 2, 3, 4, 5, 6, 9, 12, 22])\n\n>>> print set((1,2,3,4,5,5))\nset([1, 2, 3, 4, 5])\n\n>>> print set(set(['H','a','c','k','e','r','r','a','n','k']))\nset(['a', 'c', 'r', 'e', 'H', 'k', 'n'])\n\n>>> print set({'Hacker' : 'DOSHI', 'Rank' : 616 })\nset(['Hacker', 'Rank'])\n\n>>> print set(enumerate(['H','a','c','k','e','r','r','a','n','k']))\nset([(6, 'r'), (7, 'a'), (3, 'k'), (4, 'e'), (5, 'r'), (9, 'k'), (2, 'c'), (0, 'H'), (1, 'a'), (8, 'n')])\n\nBasically, sets are used for membership testing and eliminating duplicate entries.\n\n=====Problem Statement=====\nNow, let's use our knowledge of sets and help Mickey.\n\nMs. Gabriel Williams is a botany professor at District College. One day, she asked her student Mickey to compute the average of all the plants with distinct heights in her greenhouse.\n\nFormula used: \nAverage = Sum of Distinct Heights / Total Number of Distinct Heights\n\n=====Input Format=====\nThe first line contains the integer, N, the total number of plants.\nThe second line contains the N space separated heights of the plants.\n\n=====Constraints=====\n0>> from itertools import permutations\n>>> print permutations(['1','2','3'])\n\n>>> \n>>> print list(permutations(['1','2','3']))\n[('1', '2', '3'), ('1', '3', '2'), ('2', '1', '3'), ('2', '3', '1'), ('3', '1', '2'), ('3', '2', '1')]\n>>> \n>>> print list(permutations(['1','2','3'],2))\n[('1', '2'), ('1', '3'), ('2', '1'), ('2', '3'), ('3', '1'), ('3', '2')]\n>>>\n>>> print list(permutations('abc',3))\n[('a', 'b', 'c'), ('a', 'c', 'b'), ('b', 'a', 'c'), ('b', 'c', 'a'), ('c', 'a', 'b'), ('c', 'b', 'a')]\n\n=====Problem Statement=====\nYou are given a string S.\nYour task is to print all possible permutations of size k of the string in lexicographic sorted order.\n\n=====Input Format=====\nA single line containing the space separated string S and the integer value k.\n\n=====Output Format=====\nPrint the permutations of the string S on separate lines.", "starter_code": "\n# Enter your code here. Read input from STDIN. Print output to STDOUT", "test_cases": {"inputs": ["HACK 2"], "outputs": ["AC\nAH\nAK\nCA\nCH\nCK\nHA\nHC\nHK\nKA\nKC\nKH"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "17a67a0042349dd0af0bc34e1fdbe13d6b17568e", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-01463", "original_id": null, "source": "apps", "domain": "code", "problem": "=====Function Descriptions=====\n.intersection()\n\nThe .intersection() operator returns the intersection of a set and the set of elements in an iterable.\nSometimes, the & operator is used in place of the .intersection() operator, but it only operates on the set of elements in set.\nThe set is immutable to the .intersection() operation (or & operation).\n\n>>> s = set(\"Hacker\")\n>>> print s.intersection(\"Rank\")\nset(['a', 'k'])\n\n>>> print s.intersection(set(['R', 'a', 'n', 'k']))\nset(['a', 'k'])\n\n>>> print s.intersection(['R', 'a', 'n', 'k'])\nset(['a', 'k'])\n\n>>> print s.intersection(enumerate(['R', 'a', 'n', 'k']))\nset([])\n\n>>> print s.intersection({\"Rank\":1})\nset([])\n\n>>> s & set(\"Rank\")\nset(['a', 'k'])\n\n=====Problem Statement=====\nThe students of District College have subscriptions to English and French newspapers. Some students have subscribed only to English, some have subscribed only to French, and some have subscribed to both newspapers.\n\nYou are given two sets of student roll numbers. One set has subscribed to the English newspaper, one set has subscribed to the French newspaper. Your task is to find the total number of students who have subscribed to both newspapers.\n\n=====Input Format=====\nThe first line contains n, the number of students who have subscribed to the English newspaper.\nThe second line contains n space separated roll numbers of those students.\nThe third line contains b, the number of students who have subscribed to the French newspaper.\nThe fourth line contains b space separated roll numbers of those students.\n\n=====Constraints=====\n0 < Total number of students in college < 1000\n\n=====Output Format=====\nOutput the total number of students who have subscriptions to both English and French newspapers.", "starter_code": "\n# Enter your code here. Read input from STDIN. Print output to STDOUT", "test_cases": {"inputs": ["9\n1 2 3 4 5 6 7 8 9\n9\n10 1 2 3 11 21 55 6 8"], "outputs": ["5"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "e7950fff3924427dea38291294110772d4f8f238", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-01468", "original_id": null, "source": "apps", "domain": "code", "problem": "=====Problem Statement=====\nConsider a list (list = []). You can perform the following commands:\n1. insert i e: Insert integer e at position i.\n2. print: Print the list.\n3. remove e: Delete the first occurrence of integer e.\n4. append e: Insert integer e at the end of the list.\n5. sort: Sort the list.\n6. pop: Pop the last element from the list.\n7. reverse: Reverse the list.\nInitialize your list and read in the value of n followed by n lines of commands where each command will be 7 of the types listed above. Iterate through each command in order and perform the corresponding operation on your list.\n\n=====Example=====\nN = 4\nappend 1\nappend 2\ninsert 3 1\nprint\nappend 1: Append 1 to the list, arr = [1].\nappend 2: Append 2 to the list, arr = [1,2].\ninsert 3 1: Insert 3 at index 1, arr = [1,3,2].\nprint: Print the array\nOutput:\n[1, 3, 2]\n\n=====Input Format=====\nThe first line contains an integer, n, denoting the number of commands. Each line i of the subsequent n lines contains one of the commands described above.\n\n=====Constraints=====\nThe elements added to the list must be integers\n\n=====Output Format=====\nFor each command of type print, print the list on a new line.", "starter_code": "\nif __name__ == '__main__':\n N = int(input())", "test_cases": {"inputs": ["12\ninsert 0 5\ninsert 1 10\ninsert 0 6\nprint\nremove 6\nappend 9\nappend 1\nsort\nprint\npop\nreverse\nprint"], "outputs": ["[6, 5, 10]\n[1, 5, 9, 10]\n[9, 5, 1]"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "b07b5adc28652ac18ef9da5d0f434aa1b13e20cf", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-01473", "original_id": null, "source": "apps", "domain": "code", "problem": "=====Problem Statement=====\nThe provided code stub reads two integers from STDIN, a and b. Add code to print three lines where:\nThe first line contains the sum of the two numbers.\nThe second line contains the difference of the two numbers (first - second).\nThe third line contains the product of the two numbers.\n\n=====Example=====\na = 3\nb = 5\n\nPrint the following:\n8\n-2\n15\n\n=====Input Format=====\nThe first line contains the first integer, a.\nThe second line contains the second integer, b.\n\n=====Constraints=====\n1≤a≤10^10\n1≤b≤10^10\n\n=====Output Format=====\nPrint the three lines as explained above.", "starter_code": "\nif __name__ == '__main__':\n a = int(input())\n b = int(input())", "test_cases": {"inputs": ["3\n2"], "outputs": ["5\n1\n6"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "a7d9264f3cfa23cb0fd004423229297d7d664846", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-01478", "original_id": null, "source": "apps", "domain": "code", "problem": "=====Function Descriptions=====\nHTML\nHypertext Markup Language is a standard markup language used for creating World Wide Web pages.\n\nParsing\nParsing is the process of syntactic analysis of a string of symbols. It involves resolving a string into its component parts and describing their syntactic roles.\n\nHTMLParser\nAn HTMLParser instance is fed HTML data and calls handler methods when start tags, end tags, text, comments, and other markup elements are encountered.\n\nExample (based on the original Python documentation):\n\nCode\n\nfrom HTMLParser import HTMLParser\n\n# create a subclass and override the handler methods\nclass MyHTMLParser(HTMLParser):\n def handle_starttag(self, tag, attrs):\n print \"Found a start tag :\", tag\n def handle_endtag(self, tag):\n print \"Found an end tag :\", tag\n def handle_startendtag(self, tag, attrs):\n print \"Found an empty tag :\", tag\n\n# instantiate the parser and fed it some HTML\nparser = MyHTMLParser()\nparser.feed(\"HTML Parser - I\"\n +\"

HackerRank


\")\n\nOutput\n\nFound a start tag : html\nFound a start tag : head\nFound a start tag : title\nFound an end tag : title\nFound an end tag : head\nFound a start tag : body\nFound a start tag : h1\nFound an end tag : h1\nFound an empty tag : br\nFound an end tag : body\nFound an end tag : html\n\n\n.handle_starttag(tag, attrs)\n\nThis method is called to handle the start tag of an element. (For example:
)\nThe tag argument is the name of the tag converted to lowercase.\nThe attrs argument is a list of (name, value) pairs containing the attributes found inside the tag’s <> brackets.\n\n.handle_endtag(tag)\n\nThis method is called to handle the end tag of an element. (For example:
)\nThe tag argument is the name of the tag converted to lowercase.\n\n.handle_startendtag(tag,attrs)\n\nThis method is called to handle the empty tag of an element. (For example:
)\nThe tag argument is the name of the tag converted to lowercase.\nThe attrs argument is a list of (name, value) pairs containing the attributes found inside the tag’s <> brackets.\n\n=====Problem Statement=====\nYou are given an HTML code snippet of N lines.\nYour task is to print start tags, end tags and empty tags separately.\n\nFormat your results in the following way:\n\nStart : Tag1\nEnd : Tag1\nStart : Tag2\n-> Attribute2[0] > Attribute_value2[0]\n-> Attribute2[1] > Attribute_value2[1]\n-> Attribute2[2] > Attribute_value2[2]\nStart : Tag3\n-> Attribute3[0] > None\nEmpty : Tag4\n-> Attribute4[0] > Attribute_value4[0]\nEnd : Tag3\nEnd : Tag2\n\nHere, the -> symbol indicates that the tag contains an attribute. It is immediately followed by the name of the attribute and the attribute value.\nThe > symbol acts as a separator of the attribute and the attribute value.\n\nIf an HTML tag has no attribute then simply print the name of the tag.\nIf an attribute has no attribute value then simply print the name of the attribute value as None.\n\nNote: Do not detect any HTML tag, attribute or attribute value inside the HTML comment tags ().Comments can be multiline as well.\n\n=====Input Format=====\nThe first line contains integer N, the number of lines in a HTML code snippet.\nThe next N lines contain HTML code.\n\n=====Constraints=====\n0HTML Parser - I\n

HackerRank


"], "outputs": ["Start : html\nStart : head\nStart : title\nEnd : title\nEnd : head\nStart : body\n-> data-modal-target > None\n-> class > 1\nStart : h1\nEnd : h1\nEmpty : br\nEnd : body\nEnd : html"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "4b3ae60efd8f715b3ac905fe47ce4492977d9d3f", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-01483", "original_id": null, "source": "apps", "domain": "code", "problem": "=====Problem Statement=====\nIn this challenge, the user enters a string and a substring. You have to print the number of times that the substring occurs in the given string. String traversal will take place from left to right, not from right to left.\n\nNOTE: String letters are case-sensitive.\n\n=====Input Format=====\nThe first line of input contains the original string. The next line contains the substring.\n\n=====Constraints=====\n1 ≤ len(string) ≤ 200\nEach character in the string is an ascii character.\n\n=====Output Format=====\nOutput the integer number indicating the total number of occurrences of the substring in the original string.", "starter_code": "\ndef count_substring(string, sub_string):\n return\n\nif __name__ == '__main__':\n string = input().strip()\n sub_string = input().strip()\n \n count = count_substring(string, sub_string)\n print(count)", "test_cases": {"inputs": ["ABCDCDC\nCDC"], "outputs": ["2"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "e0ed013469c38df454f9ee74d8ebf9b6846cb92f", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-01488", "original_id": null, "source": "apps", "domain": "code", "problem": "=====Function Descriptions=====\nPython has built-in string validation methods for basic data. It can check if a string is composed of alphabetical characters, alphanumeric characters, digits, etc.\n\nstr.isalnum()\nThis method checks if all the characters of a string are alphanumeric (a-z, A-Z and 0-9).\n\n>>> print 'ab123'.isalnum()\nTrue\n>>> print 'ab123#'.isalnum()\nFalse\n\nstr.isalpha()\nThis method checks if all the characters of a string are alphabetical (a-z and A-Z).\n\n>>> print 'abcD'.isalpha()\nTrue\n>>> print 'abcd1'.isalpha()\nFalse\n\nstr.isdigit()\nThis method checks if all the characters of a string are digits (0-9).\n\n>>> print '1234'.isdigit()\nTrue\n>>> print '123edsd'.isdigit()\nFalse\n\nstr.islower()\nThis method checks if all the characters of a string are lowercase characters (a-z).\n\n>>> print 'abcd123#'.islower()\nTrue\n>>> print 'Abcd123#'.islower()\nFalse\n\nstr.isupper()\nThis method checks if all the characters of a string are uppercase characters (A-Z).\n\n>>> print 'ABCD123#'.isupper()\nTrue\n>>> print 'Abcd123#'.isupper()\nFalse\n\n=====Problem Statement=====\nYou are given a string S.\nYour task is to find out if the string S contains: alphanumeric characters, alphabetical characters, digits, lowercase and uppercase characters.\n\n=====Input Format=====\nA single line containing a string S.\n\n=====Constraints=====\n0 < len(S) < 1000\n\n=====Output Format=====\nIn the first line, print True if S has any alphanumeric characters. Otherwise, print False.\nIn the second line, print True if S has any alphabetical characters. Otherwise, print False.\nIn the third line, print True if S has any digits. Otherwise, print False.\nIn the fourth line, print True if S has any lowercase characters. Otherwise, print False.\nIn the fifth line, print True if S has any uppercase characters. Otherwise, print False.", "starter_code": "\nif __name__ == '__main__':\n s = input()", "test_cases": {"inputs": ["qA2"], "outputs": ["True\nTrue\nTrue\nTrue\nTrue"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "f9a8736d4838af8449023c10eada4f4123cb4602", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-01493", "original_id": null, "source": "apps", "domain": "code", "problem": "=====Problem Statement=====\nHere is a sample line of code that can be executed in Python:\nprint(\"Hello, World!\")\n\nYou can just as easily store a string as a variable and then print it to stdout:\nmy_string = \"Hello, World!\"\nprint(my_string)\n\nThe above code will print Hello, World! on your screen. Try it yourself in the editor below!\n\n=====Input Format=====\nYou do not need to read any input in this challenge.\n\n=====Output Format=====\nPrint Hello, World! to stdout.", "starter_code": "\nprint(\"\")", "test_cases": {"inputs": [""], "outputs": ["Hello, World!"]}, "test_case_format": "stdin_stdout", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "ee91ff2ecc3b21c047ad29e3c227c299dafff4d9", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true} {"seed_id": "apps-01498", "original_id": null, "source": "apps", "domain": "code", "problem": "You've arrived at a carnival and head straight for the duck shooting tent. Why wouldn't you?\n\nYou will be given a set amount of ammo, and an aim rating of between 1 and 0. No your aim is not always perfect - hey maybe someone fiddled with the sights on the gun...\n\nAnyway your task is to calculate how many successful shots you will be able to make given the available ammo and your aim score, then return a string representing the pool of ducks, with those ducks shot marked with 'X' and those that survived left unchanged. You will always shoot left to right.\n\nExample of start and end duck string with two successful shots:\n\nStart ---> |~~~~~22~2~~~~~|\n\n**Bang!! Bang!!**\n\nEnd ---> |~~~~~XX~2~~~~~|\n\nAll inputs will be correct type and never empty.", "starter_code": "\ndef duck_shoot(ammo, aim, ducks):\n\t", "test_cases": {"inputs": [[4, 0.64, "|~~2~~~22~2~~22~2~~~~2~~~|"], [9, 0.22, "|~~~~~~~2~2~~~|"], [6, 0.41, "|~~~~~22~2~~~~~|"], [8, 0.05, "|2~~~~|"], [8, 0.92, "|~~~~2~2~~~~~22~~2~~~~2~~~2|"]], "outputs": [["|~~X~~~X2~2~~22~2~~~~2~~~|"], ["|~~~~~~~X~2~~~|"], ["|~~~~~XX~2~~~~~|"], ["|2~~~~|"], ["|~~~~X~X~~~~~XX~~X~~~~X~~~X|"]], "fn_name": "duck_shoot"}, "test_case_format": "function_call", "n_test_cases_total": 5, "n_test_cases_kept": 5, "test_cases_truncated": false, "problem_sha1": "2ae1a6da827c1d7c78121c567bf131432651edbd", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "duck_shoot"} {"seed_id": "apps-01503", "original_id": null, "source": "apps", "domain": "code", "problem": "Pete and his mate Phil are out in the countryside shooting clay pigeons with a shotgun - amazing fun. \n\nThey decide to have a competition. 3 rounds, 2 shots each. Winner is the one with the most hits.\n\nSome of the clays have something attached to create lots of smoke when hit, guarenteed by the packaging to generate 'real excitement!' (genuinely this happened). None of the explosive things actually worked, but for this kata lets say they did.\n\nFor each round you will receive the following format:\n\n[{P1:'XX', P2:'XO'}, true]\n\nThat is an array containing an object and a boolean. Pl represents Pete, P2 represents Phil. X represents a hit and O represents a miss. If the boolean is true, any hit is worth 2. If it is false, any hit is worth 1.\n\nFind out who won. If it's Pete, return 'Pete Wins!'. If it is Phil, return 'Phil Wins!'. If the scores are equal, return 'Draw!'.\n\nNote that as there are three rounds, the actual input (x) will look something like this:\n\n[[{P1:'XX', P2:'XO'}, true], [{P1:'OX', P2:'OO'}, false], [{P1:'XX', P2:'OX'}, true]]", "starter_code": "\ndef shoot(results):\n\t", "test_cases": {"inputs": [[[[{"P1": "XX", "P2": "XO"}, true], [{"P1": "OX", "P2": "OO"}, false], [{"P1": "XX", "P2": "OX"}, true]]], [[[{"P1": "XX", "P2": "XO"}, false], [{"P1": "OX", "P2": "XX"}, false], [{"P1": "OO", "P2": "XX"}, true]]], [[[{"P1": "OO", "P2": "XX"}, false], [{"P1": "OO", "P2": "XX"}, false], [{"P1": "XX", "P2": "OO"}, true]]], [[[{"P1": "XX", "P2": "XX"}, true], [{"P1": "XX", "P2": "OX"}, false], [{"P1": "OO", "P2": "OX"}, true]]], [[[{"P1": "XX", "P2": "XX"}, true], [{"P1": "OO", "P2": "OO"}, false], [{"P1": "XX", "P2": "XX"}, true]]]], "outputs": [["Pete Wins!"], ["Phil Wins!"], ["Draw!"], ["Phil Wins!"], ["Draw!"]], "fn_name": "shoot"}, "test_case_format": "function_call", "n_test_cases_total": 5, "n_test_cases_kept": 5, "test_cases_truncated": false, "problem_sha1": "adcab9a293f73094d5d72a29faae189d0e34a505", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "shoot"} {"seed_id": "apps-01508", "original_id": null, "source": "apps", "domain": "code", "problem": "Will you make it?\n\nYou were camping with your friends far away from home, but when it's time to go back, you realize that your fuel is running out and the nearest pump is ```50``` miles away! You know that on average, your car runs on about ```25``` miles per gallon. There are ```2``` gallons left. Considering these factors, write a function that tells you if it is possible to get to the pump or not. Function should return ``true`` (`1` in Prolog) if it is possible and ``false`` (`0` in Prolog) if not.\nThe input values are always positive.", "starter_code": "\ndef zero_fuel(distance_to_pump, mpg, fuel_left):\n\t", "test_cases": {"inputs": [[50, 25, 2], [60, 30, 3], [70, 25, 1], [100, 25, 3]], "outputs": [[true], [true], [false], [false]], "fn_name": "zero_fuel"}, "test_case_format": "function_call", "n_test_cases_total": 4, "n_test_cases_kept": 4, "test_cases_truncated": false, "problem_sha1": "40ba7444c9f94c56adce9445ac11d0348c61fd83", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "zero_fuel"} {"seed_id": "apps-01513", "original_id": null, "source": "apps", "domain": "code", "problem": "Passer ratings are the generally accepted standard for evaluating NFL quarterbacks.\nI knew a rating of 100 is pretty good, but never knew what makes up the rating.\nSo out of curiosity I took a look at the wikipedia page and had an idea or my first kata: https://en.wikipedia.org/wiki/Passer_rating\n\n## Formula\n\nThere are four parts to the NFL formula:\n```python\nA = ((Completions / Attempts) - .3) * 5\nB = ((Yards / Attempts) - 3) * .25\nC = (Touchdowns / Attempt) * 20\nD = 2.375 - ((Interceptions / Attempts) * 25)\n```\nHowever, if the result of any calculation is greater than `2.375`, it is set to `2.375`. If the result is a negative number, it is set to zero.\n\nFinally the passer rating is: `((A + B + C + D) / 6) * 100`\n\nReturn the rating rounded to the nearest tenth.\n\n## Example\n\nLast year Tom Brady had 432 attempts, 3554 yards, 291 completions, 28 touchdowns, and 2 interceptions.\nHis passer rating was 112.2\n\nHappy coding!", "starter_code": "\ndef passer_rating(att, yds, comp, td, ints):\n\t", "test_cases": {"inputs": [[432, 3554, 291, 28, 2], [5, 76, 4, 1, 0], [48, 192, 19, 2, 3], [1, 2, 1, 1, 0], [34, 172, 20, 1, 1], [10, 17, 2, 0, 1]], "outputs": [[112.2], [158.3], [39.6], [118.8], [69.7], [0.0]], "fn_name": "passer_rating"}, "test_case_format": "function_call", "n_test_cases_total": 6, "n_test_cases_kept": 6, "test_cases_truncated": false, "problem_sha1": "06f1acb7012d812d291f10c62ed49a121e2461bf", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "passer_rating"} {"seed_id": "apps-01518", "original_id": null, "source": "apps", "domain": "code", "problem": "Two tortoises named ***A*** and ***B*** must run a race. ***A*** starts with an average speed of ```720 feet per hour```.\nYoung ***B*** knows she runs faster than ***A***, and furthermore has not finished her cabbage.\n\nWhen she starts, at last, she can see that ***A*** has a `70 feet lead` but ***B***'s speed is `850 feet per hour`.\nHow long will it take ***B*** to catch ***A***?\n\nMore generally:\ngiven two speeds `v1` (***A***'s speed, integer > 0) and `v2` (***B***'s speed, integer > 0) and a lead `g` (integer > 0)\nhow long will it take ***B*** to catch ***A***? \n\nThe result will be an array ```[hour, min, sec]``` which is the time needed in hours, minutes and seconds (round down to the nearest second)\nor a string in some languages.\n\nIf `v1 >= v2` then return `nil`, `nothing`, `null`, `None` or `{-1, -1, -1}` for C++, C, Go, Nim, `[]` for Kotlin or \"-1 -1 -1\".\n\n## Examples:\n(form of the result depends on the language)\n```\nrace(720, 850, 70) => [0, 32, 18] or \"0 32 18\"\nrace(80, 91, 37) => [3, 21, 49] or \"3 21 49\"\n```\n\n** Note: \n\n- See other examples in \"Your test cases\".\n\n- In Fortran - as in any other language - the returned string is not permitted to contain any redundant trailing whitespace: you can use dynamically allocated character strings.\n\n** Hints for people who don't know how to convert to hours, minutes, seconds:\n\n- Tortoises don't care about fractions of seconds\n\n- Think of calculation by hand using only integers (in your code use or simulate integer division)\n\n- or Google: \"convert decimal time to hours minutes seconds\"", "starter_code": "\ndef race(v1, v2, g):\n\t", "test_cases": {"inputs": [[720, 850, 70], [80, 91, 37], [80, 100, 40], [720, 850, 37], [720, 850, 370], [120, 850, 37], [820, 850, 550], [820, 81, 550]], "outputs": [[[0, 32, 18]], [[3, 21, 49]], [[2, 0, 0]], [[0, 17, 4]], [[2, 50, 46]], [[0, 3, 2]], [[18, 20, 0]], [null]], "fn_name": "race"}, "test_case_format": "function_call", "n_test_cases_total": 8, "n_test_cases_kept": 8, "test_cases_truncated": false, "problem_sha1": "81500852e26d91fa5369f9d1472eca18465186c1", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "race"} {"seed_id": "apps-01523", "original_id": null, "source": "apps", "domain": "code", "problem": "Create a function that takes a string as a parameter and does the following, in this order:\n\n1. replaces every letter with the letter following it in the alphabet (see note below)\n2. makes any vowels capital\n3. makes any consonants lower case\n\n**Note:** the alphabet should wrap around, so `Z` becomes `A`\n\nSo, for example the string `\"Cat30\"` would return `\"dbU30\"` (`Cat30 --> Dbu30 --> dbU30`)", "starter_code": "\ndef changer(string):\n\t", "test_cases": {"inputs": [["Cat30"], ["Alice"], ["sponge1"], ["Hello World"], ["dogs"], ["z"]], "outputs": [["dbU30"], ["bmjdf"], ["tqpOhf1"], ["Ifmmp xpsmE"], ["Epht"], ["A"]], "fn_name": "changer"}, "test_case_format": "function_call", "n_test_cases_total": 6, "n_test_cases_kept": 6, "test_cases_truncated": false, "problem_sha1": "f7e1f325f5f241b2b0b12c4d4a1b9310a36eb525", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "changer"} {"seed_id": "apps-01528", "original_id": null, "source": "apps", "domain": "code", "problem": "#Bubbleing around\n\nSince everybody hates chaos and loves sorted lists we should implement some more sorting algorithms. Your task is to implement a Bubble sort (for some help look at https://en.wikipedia.org/wiki/Bubble_sort) and return a list of snapshots after **each change** of the initial list.\n\ne.g. \n\nIf the initial list would be l=[1,2,4,3] my algorithm rotates l[2] and l[3] and after that it adds [1,2,3,4] to the result, which is a list of snapshots.\n```\n[1,2,4,3] should return [ [1,2,3,4] ]\n[2,1,4,3] should return [ [1,2,4,3], [1,2,3,4] ]\n[1,2,3,4] should return []\n```", "starter_code": "\ndef bubble(l):\n\t", "test_cases": {"inputs": [[[]], [[1, 2, 3, 4, 5, 6, 7, 8, 9]], [[1, 3, 3, 7, 4, 2]]], "outputs": [[[]], [[]], [[[1, 3, 3, 4, 7, 2], [1, 3, 3, 4, 2, 7], [1, 3, 3, 2, 4, 7], [1, 3, 2, 3, 4, 7], [1, 2, 3, 3, 4, 7]]]], "fn_name": "bubble"}, "test_case_format": "function_call", "n_test_cases_total": 3, "n_test_cases_kept": 3, "test_cases_truncated": false, "problem_sha1": "246d67ab21c4357fae2a40625797459fe5470488", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "bubble"} {"seed_id": "apps-01533", "original_id": null, "source": "apps", "domain": "code", "problem": "## Your Story\n\"A *piano* in the home meant something.\" - *Fried Green Tomatoes at the Whistle Stop Cafe*\n\nYou've just realized a childhood dream by getting a beautiful and beautiful-sounding upright piano from a friend who was leaving the country. You immediately started doing things like playing \"Heart and Soul\" over and over again, using one finger to pick out any melody that came into your head, requesting some sheet music books from the library, signing up for some MOOCs like Developing Your Musicianship, and wondering if you will think of any good ideas for writing piano-related katas and apps. \n\nNow you're doing an exercise where you play the very first (leftmost, lowest in pitch) key on the 88-key keyboard, which (as shown below) is white, with the little finger on your left hand, then the second key, which is black, with the ring finger on your left hand, then the third key, which is white, with the middle finger on your left hand, then the fourth key, also white, with your left index finger, and then the fifth key, which is black, with your left thumb. Then you play the sixth key, which is white, with your right thumb, and continue on playing the seventh, eighth, ninth, and tenth keys with the other four fingers of your right hand. Then for the eleventh key you go back to your left little finger, and so on. Once you get to the rightmost/highest, 88th, key, you start all over again with your left little finger on the first key. Your thought is that this will help you to learn to move smoothly and with uniform pressure on the keys from each finger to the next and back and forth between hands.\n\n\n\nYou're not saying the names of the notes while you're doing this, but instead just counting each key press out loud (not starting again at 1 after 88, but continuing on to 89 and so forth) to try to keep a steady rhythm going and to see how far you can get before messing up. You move gracefully and with flourishes, and between screwups you hear, see, and feel that you are part of some great repeating progression between low and high notes and black and white keys. \n\n## Your Function\nThe function you are going to write is not actually going to help you with your piano playing, but just explore one of the patterns you're experiencing: Given the number you stopped on, was it on a black key or a white key? For example, in the description of your piano exercise above, if you stopped at 5, your left thumb would be on the fifth key of the piano, which is black. Or if you stopped at 92, you would have gone all the way from keys 1 to 88 and then wrapped around, so that you would be on the fourth key, which is white.\n\nYour function will receive an integer between 1 and 10000 (maybe you think that in principle it would be cool to count up to, say, a billion, but considering how many years it would take it is just not possible) and return the string \"black\" or \"white\" -- here are a few more examples:\n```\n1 \"white\"\n12 \"black\"\n42 \"white\"\n100 \"black\"\n2017 \"white\"\n```\nHave fun! And if you enjoy this kata, check out the sequel: Piano Kata, Part 2", "starter_code": "\ndef black_or_white_key(key_press_count):\n\t", "test_cases": {"inputs": [[1], [5], [12], [42], [88], [89], [92], [100], [111], [200], [2017]], "outputs": [["white"], ["black"], ["black"], ["white"], ["white"], ["white"], ["white"], ["black"], ["white"], ["black"], ["white"]], "fn_name": "black_or_white_key"}, "test_case_format": "function_call", "n_test_cases_total": 11, "n_test_cases_kept": 11, "test_cases_truncated": false, "problem_sha1": "ffbea08328a0c7843e5a750ac7d8881cc8c51dbf", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "black_or_white_key"} {"seed_id": "apps-01538", "original_id": null, "source": "apps", "domain": "code", "problem": "## Task\n\nWrite a function that accepts two arguments and generates a sequence containing the integers from the first argument to the second inclusive. \n\n## Input\n\nPair of integers greater than or equal to `0`. The second argument will always be greater than or equal to the first. \n\n## Example\n\n```python\ngenerate_integers(2, 5) # --> [2, 3, 4, 5]\n```", "starter_code": "\ndef generate_integers(m, n):\n\t", "test_cases": {"inputs": [[2, 5]], "outputs": [[[2, 3, 4, 5]]], "fn_name": "generate_integers"}, "test_case_format": "function_call", "n_test_cases_total": 1, "n_test_cases_kept": 1, "test_cases_truncated": false, "problem_sha1": "a7365078685608776639dc45ac4c9050a8e535cd", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "generate_integers"} {"seed_id": "apps-01543", "original_id": null, "source": "apps", "domain": "code", "problem": "# One is the loneliest number\n\n## Task\n\nThe range of vision of a digit is its own value. `1` can see one digit to the left and one digit to the right,` 2` can see two digits, and so on.\n\nThus, the loneliness of a digit `N` is the sum of the digits which it can see.\n\nGiven a non-negative integer, your funtion must determine if there's at least one digit `1` in this integer such that its loneliness value is minimal.\n\n## Example\n\n```\nnumber = 34315\n```\n\ndigit | can see on the left | can see on the right | loneliness\n--- | --- | --- | ---\n3 | - | 431 | 4 + 3 + 1 = 8\n4 | 3 | 315 | 3 + 3 + 1 + 5 = 12\n3 | 34 | 15 | 3 + 4 + 1 + 5 = 13\n1 | 3 | 5 | 3 + 5 = 8\n5 | 3431 | - | 3 + 4 + 3 + 1 = 11\n\nIs there a `1` for which the loneliness is minimal? Yes.", "starter_code": "\ndef loneliest(number):\n\t", "test_cases": {"inputs": [[34315], [123456], [8854778], [65432165432], [0], [1], [11111]], "outputs": [[true], [true], [false], [false], [false], [true], [true]], "fn_name": "loneliest"}, "test_case_format": "function_call", "n_test_cases_total": 7, "n_test_cases_kept": 7, "test_cases_truncated": false, "problem_sha1": "e306ac4719844daee06a1b9a91300060cdc236dc", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "loneliest"} {"seed_id": "apps-01548", "original_id": null, "source": "apps", "domain": "code", "problem": "# Task\n Timed Reading is an educational tool used in many schools to improve and advance reading skills. A young elementary student has just finished his very first timed reading exercise. Unfortunately he's not a very good reader yet, so whenever he encountered a word longer than maxLength, he simply skipped it and read on.\n\n Help the teacher figure out how many words the boy has read by calculating the number of words in the text he has read, no longer than maxLength.\n\n Formally, a word is a substring consisting of English letters, such that characters to the left of the leftmost letter and to the right of the rightmost letter are not letters.\n\n# Example\n\n For `maxLength = 4` and `text = \"The Fox asked the stork, 'How is the soup?'\"`, the output should be `7`\n\n The boy has read the following words: `\"The\", \"Fox\", \"the\", \"How\", \"is\", \"the\", \"soup\".`\n\n# Input/Output\n\n\n - `[input]` integer `maxLength`\n\n A positive integer, the maximum length of the word the boy can read.\n\n Constraints: `1 ≤ maxLength ≤ 10.`\n\n\n - `[input]` string `text`\n\n A non-empty string of English letters and punctuation marks.\n\n\n - `[output]` an integer\n\n The number of words the boy has read.", "starter_code": "\ndef timed_reading(max_length, text):\n\t", "test_cases": {"inputs": [[4, "The Fox asked the stork, 'How is the soup?'"], [1, "..."], [3, "This play was good for us."], [3, "Suddenly he stopped, and glanced up at the houses"], [6, "Zebras evolved among the Old World horses within the last four million years."], [5, "Although zebra species may have overlapping ranges, they do not interbreed."], [1, "Oh!"], [5, "Now and then, however, he is horribly thoughtless, and seems to take a real delight in giving me pain."]], "outputs": [[7], [0], [3], [5], [11], [6], [0], [14]], "fn_name": "timed_reading"}, "test_case_format": "function_call", "n_test_cases_total": 8, "n_test_cases_kept": 8, "test_cases_truncated": false, "problem_sha1": "b6359685b6b5ba76abd755d266d124627aab3cd3", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "timed_reading"} {"seed_id": "apps-01553", "original_id": null, "source": "apps", "domain": "code", "problem": "You are given a string of numbers between 0-9. Find the average of these numbers and return it as a floored whole number (ie: no decimal places) written out as a string. Eg:\n\n\"zero nine five two\" -> \"four\"\n\nIf the string is empty or includes a number greater than 9, return \"n/a\"", "starter_code": "\ndef average_string(s):\n\t", "test_cases": {"inputs": [["zero nine five two"], ["four six two three"], ["one two three four five"], ["five four"], ["zero zero zero zero zero"], ["one one eight one"], ["one"], [""], ["ten"], ["pippi"]], "outputs": [["four"], ["three"], ["three"], ["four"], ["zero"], ["two"], ["one"], ["n/a"], ["n/a"], ["n/a"]], "fn_name": "average_string"}, "test_case_format": "function_call", "n_test_cases_total": 10, "n_test_cases_kept": 10, "test_cases_truncated": false, "problem_sha1": "bce994679558b4a3bfc6cf077a855146da93070e", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "average_string"} {"seed_id": "apps-01558", "original_id": null, "source": "apps", "domain": "code", "problem": "###Instructions\n\nWrite a function that takes a negative or positive integer, which represents the number of minutes before (-) or after (+) Sunday midnight, and returns the current day of the week and the current time in 24hr format ('hh:mm') as a string. \n\n```python\nday_and_time(0) should return 'Sunday 00:00'\nday_and_time(-3) should return 'Saturday 23:57'\nday_and_time(45) should return 'Sunday 00:45'\nday_and_time(759) should return 'Sunday 12:39'\nday_and_time(1236) should return 'Sunday 20:36'\nday_and_time(1447) should return 'Monday 00:07'\nday_and_time(7832) should return 'Friday 10:32'\nday_and_time(18876) should return 'Saturday 02:36'\nday_and_time(259180) should return 'Thursday 23:40' \nday_and_time(-349000) should return 'Tuesday 15:20'\n```", "starter_code": "\ndef day_and_time(mins):\n\t", "test_cases": {"inputs": [[0], [-3], [45], [759], [1236], [1447], [7832], [18876], [259180], [-349000]], "outputs": [["Sunday 00:00"], ["Saturday 23:57"], ["Sunday 00:45"], ["Sunday 12:39"], ["Sunday 20:36"], ["Monday 00:07"], ["Friday 10:32"], ["Saturday 02:36"], ["Thursday 23:40"], ["Tuesday 15:20"]], "fn_name": "day_and_time"}, "test_case_format": "function_call", "n_test_cases_total": 10, "n_test_cases_kept": 10, "test_cases_truncated": false, "problem_sha1": "8c7e2d030773296daeaa3b7ab21ad9defab18a84", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "day_and_time"} {"seed_id": "apps-01563", "original_id": null, "source": "apps", "domain": "code", "problem": "You are given an array that of arbitrary depth that needs to be nearly flattened into a 2 dimensional array. The given array's depth is also non-uniform, so some parts may be deeper than others.\n\nAll of lowest level arrays (most deeply nested) will contain only integers and none of the higher level arrays will contain anything but other arrays. All arrays given will be at least 2 dimensional. All lowest level arrays will contain at least one element.\n\nYour solution should be an array containing all of the lowest level arrays and only these. The sub-arrays should be ordered by the smallest element within each, so `[1,2]` should preceed `[3,4,5]`. Note: integers will not be repeated.\n\nFor example:\n\nIf you receive `[[[1,2,3],[4,5]],[6,7]]`, your answer should be `[[1,2,3],[4,5],[6,7]]`.", "starter_code": "\ndef near_flatten(nested):\n\t", "test_cases": {"inputs": [[[[1]]], [[[1, 2, 3], [4, 5, 6]]], [[[1, 2, 3], [[4, 5], [[6], [7, 8]]]]], [[[[1, 2, 3], [9, 10]], [[4, 5], [6, 7, 8]]]]], "outputs": [[[[1]]], [[[1, 2, 3], [4, 5, 6]]], [[[1, 2, 3], [4, 5], [6], [7, 8]]], [[[1, 2, 3], [4, 5], [6, 7, 8], [9, 10]]]], "fn_name": "near_flatten"}, "test_case_format": "function_call", "n_test_cases_total": 4, "n_test_cases_kept": 4, "test_cases_truncated": false, "problem_sha1": "46e9ff59632bc28a6a2cea12777d362856d2981c", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "near_flatten"} {"seed_id": "apps-01568", "original_id": null, "source": "apps", "domain": "code", "problem": "Program a function `sumAverage(arr)` where `arr` is an array containing arrays full of numbers, for example:\n\n```python\nsum_average([[1, 2, 2, 1], [2, 2, 2, 1]])\n```\n\nFirst, determine the average of each array. Then, return the sum of all the averages.\n\n- All numbers will be less than 100 and greater than -100.\n- `arr` will contain a maximum of 50 arrays.\n- After calculating all the averages, add them **all** together, **then** round down, as shown in the example below:\n\nThe example given: `sumAverage([[3, 4, 1, 3, 5, 1, 4], [21, 54, 33, 21, 77]])`, the answer being 44.\n1. Calculate the average of each individual array:\n```\n[3, 4, 1, 3, 5, 1, 4] = (3 + 4 + 1 + 3 + 5 + 1 + 4) / 7 = 3\n[21, 54, 33, 21, 77] = (21 + 54 + 33 + 21 + 77) / 5 = 41.2\n```\n2. Add the average of each array together:\n```\n3 + 41.2 = 44.2\n```\n3. Round the final average down:\n\n~~~if:julia\nIn Julia, the `Statistics` package is preloaded.\n~~~\n```python\nimport math\nmath.floor(44.2) = 44\n```", "starter_code": "\ndef sum_average(arr):\n\t", "test_cases": {"inputs": [[[[1, 2, 2, 1], [2, 2, 2, 1]]], [[[52, 64, 84, 21, 54], [44, 87, 46, 90, 43]]], [[[44, 76, 12], [96, 12, 34, 53, 76, 34, 56, 86, 21], [34, 65, 34, 76, 34, 87, 34]]], [[[41, 16, 99, 93, 59, 18, 35, 23, 55, 45, 38, 39, 74, 60, 95, 44, 59, 70, 44, 89, 90, 19, 23, 67, 65, 66, 41, 89, 49, 22, 23, 47, 60, 12, 59, 58, 25, 69, 66, 82, 53, 41, 51, 69, 78, 18, 17, 44, 74, 96, 46, 73, 22, 37, 95, 32, 62, 49, 8, 88, 59, 66, 23, 10, 61, 28, 11, 99, 27, 98, 8, 18, 73, 18, 61, 25, 60, 38, 81, 13, 36, 63, 12, 83, 57, 11, 19, 51, 41, 20, 37, 63, 79, 94, 25, 45, 24, 73, 67, 42]]], [[[3, 4, 1, 3, 5, 1, 4], [21, 54, 33, 21, 76]]], [[[-4, 3, -8, -2], [2, 9, 1, -5], [-7, -2, -6, -4]]]], "outputs": [[3], [117], [148], [50], [44], [-6]], "fn_name": "sum_average"}, "test_case_format": "function_call", "n_test_cases_total": 6, "n_test_cases_kept": 6, "test_cases_truncated": false, "problem_sha1": "d9c091d8a46bb8c590f54496d0d50ef391e6ab9a", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "sum_average"} {"seed_id": "apps-01573", "original_id": null, "source": "apps", "domain": "code", "problem": "Given: an array containing hashes of names\n\nReturn: a string formatted as a list of names separated by commas except for the last two names, which should be separated by an ampersand.\n\nExample:\n\n``` ruby\nlist([ {name: 'Bart'}, {name: 'Lisa'}, {name: 'Maggie'} ])\n# returns 'Bart, Lisa & Maggie'\n\nlist([ {name: 'Bart'}, {name: 'Lisa'} ])\n# returns 'Bart & Lisa'\n\nlist([ {name: 'Bart'} ])\n# returns 'Bart'\n\nlist([])\n# returns ''\n```\n``` elixir\nlist([ %{name: \"Bart\"}, %{name: \"Lisa\"}, %{name: \"Maggie\"} ])\n# returns 'Bart, Lisa & Maggie'\n\nlist([ %{name: \"Bart\"}, %{name: \"Lisa\"} ])\n# returns 'Bart & Lisa'\n\nlist([ %{name: \"Bart\"} ])\n# returns 'Bart'\n\nlist([])\n# returns ''\n```\n``` javascript\nlist([ {name: 'Bart'}, {name: 'Lisa'}, {name: 'Maggie'} ])\n// returns 'Bart, Lisa & Maggie'\n\nlist([ {name: 'Bart'}, {name: 'Lisa'} ])\n// returns 'Bart & Lisa'\n\nlist([ {name: 'Bart'} ])\n// returns 'Bart'\n\nlist([])\n// returns ''\n```\n```python\nnamelist([ {'name': 'Bart'}, {'name': 'Lisa'}, {'name': 'Maggie'} ])\n# returns 'Bart, Lisa & Maggie'\n\nnamelist([ {'name': 'Bart'}, {'name': 'Lisa'} ])\n# returns 'Bart & Lisa'\n\nnamelist([ {'name': 'Bart'} ])\n# returns 'Bart'\n\nnamelist([])\n# returns ''\n```\n\nNote: all the hashes are pre-validated and will only contain A-Z, a-z, '-' and '.'.", "starter_code": "\ndef namelist(names):\n\t", "test_cases": {"inputs": [[[{"name": "Bart"}, {"name": "Lisa"}, {"name": "Maggie"}, {"name": "Homer"}, {"name": "Marge"}]], [[{"name": "Bart"}, {"name": "Lisa"}, {"name": "Maggie"}]], [[{"name": "Bart"}, {"name": "Lisa"}]], [[{"name": "Bart"}]], [[]]], "outputs": [["Bart, Lisa, Maggie, Homer & Marge"], ["Bart, Lisa & Maggie"], ["Bart & Lisa"], ["Bart"], [""]], "fn_name": "namelist"}, "test_case_format": "function_call", "n_test_cases_total": 5, "n_test_cases_kept": 5, "test_cases_truncated": false, "problem_sha1": "75233a2837ac0b43cc40caa7ade2f94072132e99", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "namelist"} {"seed_id": "apps-01578", "original_id": null, "source": "apps", "domain": "code", "problem": "KISS stands for Keep It Simple Stupid.\nIt is a design principle for keeping things simple rather than complex.\n\nYou are the boss of Joe.\n\nJoe is submitting words to you to publish to a blog. He likes to complicate things.\n\nDefine a function that determines if Joe's work is simple or complex.\n\nInput will be non emtpy strings with no punctuation.\n\nIt is simple if:\n``` the length of each word does not exceed the amount of words in the string ```\n(See example test cases)\n\nOtherwise it is complex.\n\nIf complex:\n```python\nreturn \"Keep It Simple Stupid\"\n```\nor if it was kept simple:\n```python\nreturn \"Good work Joe!\"\n```\n\nNote: Random test are random and nonsensical. Here is a silly example of a random test:\n```python\n\"jump always mostly is touchy dancing choice is pineapples mostly\"\n```", "starter_code": "\ndef is_kiss(words):\n\t", "test_cases": {"inputs": [["Joe had a bad day"], ["Joe had some bad days"], ["Joe is having no fun"], ["Sometimes joe cries for hours"], ["Joe is having lots of fun"], ["Joe is working hard a lot"], ["Joe listened to the noise and it was an onamonapia"], ["Joe listened to the noises and there were some onamonapias"]], "outputs": [["Good work Joe!"], ["Good work Joe!"], ["Keep It Simple Stupid"], ["Keep It Simple Stupid"], ["Good work Joe!"], ["Keep It Simple Stupid"], ["Good work Joe!"], ["Keep It Simple Stupid"]], "fn_name": "is_kiss"}, "test_case_format": "function_call", "n_test_cases_total": 8, "n_test_cases_kept": 8, "test_cases_truncated": false, "problem_sha1": "099ed51c5a42b23a9d4a4aca894ec331f1f01381", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "is_kiss"} {"seed_id": "apps-01583", "original_id": null, "source": "apps", "domain": "code", "problem": "```if-not:ruby\nCreate a function, that accepts an arbitrary number of arrays and returns a single array generated by alternately appending elements from the passed in arguments. If one of them is shorter than the others, the result should be padded with empty elements.\n```\n```if:ruby\nCreate a function, that accepts an arbitrary number of arrays and returns a single array generated by alternately appending elements from the passed in arguments. If one of them is shorter than the others, the result should be padded with `nil`s.\n```\n\nExamples:\n\n```python\ninterleave([1, 2, 3], [\"c\", \"d\", \"e\"]) == [1, \"c\", 2, \"d\", 3, \"e\"]\ninterleave([1, 2, 3], [4, 5]) == [1, 4, 2, 5, 3, None]\ninterleave([1, 2, 3], [4, 5, 6], [7, 8, 9]) == [1, 4, 7, 2, 5, 8, 3, 6, 9]\ninterleave([]) == []\n```", "starter_code": "\ndef interleave(*args):\n\t", "test_cases": {"inputs": [[[1, 2, 3], ["c", "d", "e"]], [[1, 2, 3], [4, 5]], [[1, 2], [3, 4, 5]], [[null], [null, null], [null, null, null]], [[1, 2, 3], [4, 5, 6], [7, 8, 9]], [[]]], "outputs": [[[1, "c", 2, "d", 3, "e"]], [[1, 4, 2, 5, 3, null]], [[1, 3, 2, 4, null, 5]], [[null, null, null, null, null, null, null, null, null]], [[1, 4, 7, 2, 5, 8, 3, 6, 9]], [[]]], "fn_name": "interleave"}, "test_case_format": "function_call", "n_test_cases_total": 6, "n_test_cases_kept": 6, "test_cases_truncated": false, "problem_sha1": "eb4d4822e0ce9a7dfe5ca3e79f8099d63985ef5b", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "interleave"} {"seed_id": "apps-01588", "original_id": null, "source": "apps", "domain": "code", "problem": "We are interested in collecting the triples of positive integers ```(a, b, c)``` that fulfill the following equation:\n```python\na² + b² = c³\n```\nThe first triple with the lowest values that satisfies the equation we have above is (2, 2 ,2).\nIn effect:\n```python\n2² + 2² = 2³\n4 + 4 = 8\n```\nThe first pair of triples that \"shares\" the same value of ```c``` is: ```(2, 11, 5)``` and ```(5, 10, 5)```. \n\nBoth triples share the same value of ```c``` is ```c = 5```. \n```python\nTriple (2, 11, 5) Triple(5, 10, 5)\n2² + 11² = 5³ 5² + 10² = 5³\n4 + 121 = 125 25 + 100 = 125\n```\nSo, we say that the value ```c``` has two solutions because there are two triples sharing the same value of ```c```.\n\nThere are some values of ```c``` with no solutions.\n\nThe first value of ```c``` that have a surprising number of solutions is ```65``` with ```8``` different triples.\n\nIn order to avoid duplications you will consider that ```a <= b``` always.\n\nMake the function ```find_abc_sumsqcube()```, that may give us the values of c for an specific number of solutions.\n\nFor that purpose the above required function will receive two arguments, ```c_max``` and ```num_sol```. It is understandable that ```c_max``` will give to our function the upper limit of ```c``` and ```num_sol```, the specific number of solutions.\n\nThe function will output a sorted list with the values of ```c``` that have a number of solutions equals to ```num_sol```\n\nLet's see some cases: \n```python\nfind_abc_sumsqcube(5, 1) == [2] # below or equal to c_max = 5 we have triple the (2, 2, 2) (see above)\n\nfind_abc_sumsqcube(5, 2) == [5] # now we want the values of ```c ≤ c_max``` with two solutions (see above again)\n\nfind_abc_sumsqcube(10, 2) == [5, 10]\n\nfind_abc_sumsqcube(20, 8) == [] # There are no values of c equal and bellow 20 having 8 solutions.\n```\n\nOur tests will have the following ranges for our two arguments:\n```python\n5 ≤ c_max ≤ 1000\n1 ≤ num_sol ≤ 10\n```\nHappy coding!!", "starter_code": "\ndef find_abc_sumsqcube(c_max, num_sol):\n\t", "test_cases": {"inputs": [[5, 1], [5, 2], [10, 2], [20, 8], [100, 8], [100, 3], [100, 2]], "outputs": [[[2]], [[5]], [[5, 10]], [[]], [[65, 85]], [[25, 100]], [[5, 10, 13, 17, 20, 26, 29, 34, 37, 40, 41, 45, 52, 53, 58, 61, 68, 73, 74, 80, 82, 89, 90, 97]]], "fn_name": "find_abc_sumsqcube"}, "test_case_format": "function_call", "n_test_cases_total": 7, "n_test_cases_kept": 7, "test_cases_truncated": false, "problem_sha1": "bd0aaab5dcda5d7f73031926acafbf54d91cf249", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "find_abc_sumsqcube"} {"seed_id": "apps-01593", "original_id": null, "source": "apps", "domain": "code", "problem": "# Task\n Consider the following ciphering algorithm:\n```\nFor each character replace it with its code.\nConcatenate all of the obtained numbers.\n```\nGiven a ciphered string, return the initial one if it is known that it consists only of lowercase letters.\n\n Note: here the character's code means its `decimal ASCII code`, the numerical representation of a character used by most modern programming languages.\n\n# Example\n\n For `cipher = \"10197115121\"`, the output should be `\"easy\"`.\n\n Explanation: \n ```\n charCode('e') = 101, \n charCode('a') = 97, \n charCode('s') = 115 \n charCode('y') = 121.\n```\n# Input/Output\n\n\n - `[input]` string `cipher`\n\n A non-empty string which is guaranteed to be a cipher for some other string of lowercase letters.\n\n\n - `[output]` a string", "starter_code": "\ndef decipher(cipher):\n\t", "test_cases": {"inputs": [["10197115121"], ["98"], ["122"]], "outputs": [["easy"], ["b"], ["z"]], "fn_name": "decipher"}, "test_case_format": "function_call", "n_test_cases_total": 3, "n_test_cases_kept": 3, "test_cases_truncated": false, "problem_sha1": "ed99aeacd9bf7ed2aa4af3934f032d03b853c3ed", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "decipher"} {"seed_id": "apps-01598", "original_id": null, "source": "apps", "domain": "code", "problem": "Your task is to convert a given number into a string with commas added for easier readability. The number should be rounded to 3 decimal places and the commas should be added at intervals of three digits before the decimal point. There does not need to be a comma at the end of the number.\n\nYou will receive both positive and negative numbers.\n\n## Examples\n\n```python\ncommas(1) == \"1\"\ncommas(1000) == \"1,000\"\ncommas(100.2346) == \"100.235\"\ncommas(1000000000.23) == \"1,000,000,000.23\"\ncommas(-1) == \"-1\"\ncommas(-1000000.123) == \"-1,000,000.123\"\n```", "starter_code": "\ndef commas(num):\n\t", "test_cases": {"inputs": [[1], [1000], [100.2346], [1000000000.23], [9123.212], [-1], [-1000000.123], [-2000.0], [-999.9999], [-1234567.0001236]], "outputs": [["1"], ["1,000"], ["100.235"], ["1,000,000,000.23"], ["9,123.212"], ["-1"], ["-1,000,000.123"], ["-2,000"], ["-1,000"], ["-1,234,567"]], "fn_name": "commas"}, "test_case_format": "function_call", "n_test_cases_total": 10, "n_test_cases_kept": 10, "test_cases_truncated": false, "problem_sha1": "63d5120a90490b1daa90e12f56a27f0849aa2f53", "leakage_note": "question_and_tests_only_no_solution_or_reasoning; test_cases are the VERIFIER not an answer", "do_not_use_fields": ["ground_truth_solution", "deepseek_solution", "deepseek_reasoning"], "reference_passed": true, "fn_name": "commas"}